@casual-simulation/aux-common
Version:
Common library for AUX projects
52 lines • 2.4 kB
TypeScript
/**
* Defines a type that represents the different kinds of policies that a record key can have.
*
* - null and "subjectfull" indicate that actions performed with this key must require a subject to provide their access token in order for operations to succeed.
* - "subjectless" indicates that actions may be performed with key despite not having an access key from a subject.
*
* @dochash types/records/key
* @docname PublicRecordKeyPolicy
*/
export type PublicRecordKeyPolicy = null | 'subjectfull' | 'subjectless';
/**
* The default policy for keys that do not have a specified record key.
*/
export declare const DEFAULT_RECORD_KEY_POLICY: PublicRecordKeyPolicy;
/**
* Formats the given record name and record secret into a record key.
* @param recordName The name of the record.
* @param recordSecret The secret that is used to access the record.
*/
export declare function formatV1RecordKey(recordName: string, recordSecret: string): string;
/**
* Formats the given record name and record secret into a record key.
* @param recordName The name of the record.
* @param recordSecret The secret that is used to access the record.
* @param keyPolicy The policy that the key uses.
*/
export declare function formatV2RecordKey(recordName: string, recordSecret: string, keyPolicy: PublicRecordKeyPolicy): string;
/**
* Parses the given record key into a name and password pair.
* Returns null if the key cannot be parsed.
* @param key The key to parse.
*/
export declare function parseRecordKey(key: string): [name: string, password: string, policy: PublicRecordKeyPolicy];
/**
* Parses a version 2 record key into a name, password, and policy trio.
* Returns null if the key cannot be parsed or if it is not a V2 key.
* @param key The key to parse.
*/
export declare function parseV2RecordKey(key: string): [name: string, password: string, policy: PublicRecordKeyPolicy];
/**
* Parses a version 1 record key into a name and password pair.
* Returns null if the key cannot be parsed or if it is not a V1 key.
* @param key The key to parse.
*/
export declare function parseV1RecordKey(key: string): [name: string, password: string, policy: PublicRecordKeyPolicy];
/**
* Determines if the given value is a record key.
* @param key The value to check.
* @returns
*/
export declare function isRecordKey(key: unknown): key is string;
//# sourceMappingURL=RecordKeys.d.ts.map