Files
SnowLuma/.pnpm-store/v11/files/d4/e8031d20a9c84c98681016749fb42cdbb49962c46c600162cf17aa82c955f0186146a8038f20132783e73dd353e408f02679ecc93723b841b100137d62ee4a
TanTan 2a69b23b47
Dev Build / cleanup (push) Canceled after 0s
Dev Build / typecheck (push) Canceled after 0s
Dev Build / build (linux-arm64, ubuntu-24.04-arm, linux-arm64) (push) Canceled after 0s
Dev Build / build (linux-x64, ubuntu-latest, linux-x64) (push) Canceled after 0s
Dev Build / build (win-x64, windows-latest, win32-x64) (push) Canceled after 0s
Dev Build / dispatch-dev-docker (push) Canceled after 0s
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

40 lines
1.6 KiB
Plaintext

import { AsymmetricAlgorithm, SignatureAlgorithm } from "./jwa.js";
import { HonoJsonWebKey, SignatureKey } from "./jws.js";
import { JWTPayload } from "./types.js";
//#region src/utils/jwt/jwt.d.ts
export interface TokenHeader {
alg: SignatureAlgorithm;
typ?: 'JWT';
kid?: string;
}
export declare function isTokenHeader(obj: unknown): obj is TokenHeader;
export declare const sign: (payload: JWTPayload, privateKey: SignatureKey, alg?: SignatureAlgorithm) => Promise<string>;
export type VerifyOptions = {
/** The expected issuer used for verifying the token */
iss?: string | RegExp;
/** Verify the `nbf` claim (default: `true`) */
nbf?: boolean;
/** Verify the `exp` claim (default: `true`) */
exp?: boolean;
/** Verify the `iat` claim (default: `true`) */
iat?: boolean;
/** Acceptable audience(s) for the token */
aud?: string | string[] | RegExp;
};
export type VerifyOptionsWithAlg = {
/** The algorithm used for decoding the token */
alg: SignatureAlgorithm;
} & VerifyOptions;
export declare const verify: (token: string, publicKey: SignatureKey, algOrOptions: SignatureAlgorithm | VerifyOptionsWithAlg) => Promise<JWTPayload>;
export declare const verifyWithJwks: (token: string, options: {
keys?: HonoJsonWebKey[];
jwks_uri?: string;
verification?: VerifyOptions;
allowedAlgorithms: readonly AsymmetricAlgorithm[];
}, init?: RequestInit) => Promise<JWTPayload>;
export declare const decode: (token: string) => {
header: TokenHeader;
payload: JWTPayload;
};
export declare const decodeHeader: (token: string) => TokenHeader;
//#endregion