UNPKG

@aeternity/aepp-sdk

Version:

SDK for the æternity blockchain

54 lines (53 loc) 1.74 kB
import AccountBase from '../account/Base.js'; import { Encoded } from './encoder.js'; declare const header = "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9"; /** * JWT including specific header * @category JWT */ export type Jwt = `${typeof header}.${string}.${string}`; /** * Generate a signed JWT * Provide `"sub_jwk": undefined` in payload to omit signer public key added by default. * @param originalPayload - Payload to sign * @param account - Account to sign by * @category JWT */ export declare function signJwt(originalPayload: any, account: AccountBase): Promise<Jwt>; /** * Unpack JWT. It will check signature if address or "sub_jwk" provided. * @param jwt - JWT to unpack * @param address - Address to check signature * @category JWT */ export declare function unpackJwt(jwt: Jwt, address?: Encoded.AccountAddress): { /** * JWT payload as object */ payload: any; /** * Undefined returned in case signature is not checked */ signer: Encoded.AccountAddress | undefined; }; /** * Check is string a JWT or not. Use to validate the user input. * @param maybeJwt - A string to check * @returns True if argument is a JWT * @category JWT */ export declare function isJwt(maybeJwt: string): maybeJwt is Jwt; /** * Throws an error if argument is not JWT. Use to ensure that a value is JWT. * @param maybeJwt - A string to check * @category JWT */ export declare function ensureJwt(maybeJwt: string): asserts maybeJwt is Jwt; /** * Check is JWT signed by address from arguments or "sub_jwk" * @param jwt - JWT to check * @param address - Address to check signature * @category JWT */ export declare function verifyJwt(jwt: Jwt, address?: Encoded.AccountAddress): boolean; export {};