@skyware/labeler
Version:
A lightweight alternative to Ozone for operating an atproto labeler.
36 lines (35 loc) • 1.38 kB
TypeScript
export declare const P256_JWT_ALG = "ES256";
export declare const SECP256K1_JWT_ALG = "ES256K";
/**
* Resolves the atproto signing key for a DID.
* @param did The DID to resolve.
* @param forceRefresh Whether to skip the cache and always resolve the DID.
* @returns The resolved signing key.
*/
export declare function resolveDidToSigningKey(did: string, forceRefresh?: boolean): Promise<string>;
/**
* Verifies a JWT.
* @param jwtStr The JWT to verify.
* @param ownDid The DID of the service that is receiving the request.
* @param lxm The lexicon method that is being called.
* @returns The payload of the JWT.
*/
export declare function verifyJwt(jwtStr: string, ownDid: string | null, lxm: string | null): Promise<{
iss: string;
aud: string;
exp: number;
lxm?: string;
jti?: string;
}>;
export declare function k256Sign(privateKey: Uint8Array, msg: Uint8Array): Uint8Array;
/**
* Parses a hex- or base64-encoded private key to a Uint8Array.
* @param privateKey The private key to parse.
*/
export declare const parsePrivateKey: (privateKey: string) => Uint8Array;
/**
* Formats a pubkey in did:key format.
* @param jwtAlg The JWT algorithm used by the signing key.
* @param keyBytes The bytes of the pubkey.
*/
export declare const formatDidKey: (jwtAlg: typeof P256_JWT_ALG | typeof SECP256K1_JWT_ALG, keyBytes: Uint8Array) => string;