/** * Copyright 2026 - present Nazmul Hassan * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { E as Numeric, Lt as TimeWithUnit, a as Branded, ni as GenericObject } from "./index-Dx3yeNwR.cjs"; //#region src/types/hash.d.ts /** UUID versions as number from `1-8` */ type $UUIDVersion = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8; /** UUID versions as string from `v1-v8` */ type UUIDVersion = `v${$UUIDVersion}`; /** Supported UUID versions (without `v2`) as string */ type SupportedVersion = `v${Exclude<$UUIDVersion, 2>}`; /** General 5 parts UUID string type */ type $UUID = `${string}-${string}-${string}-${string}-${string}`; /** General 5 parts UUID string as {@link Branded} type */ type UUID = Branded<$UUID, V>; /** * Options for generating UUID for `v3` and `v5` */ interface $UUIDOptionsV3V5 extends $UUIDOptions { /** Namespace for `v3` and `v5` UUID (must be another valid UUID) */ namespace: $UUID; /** Name for `v3` and `v5` UUID (must be a non-empty string) */ name: string; } /** * General Options for generating UUID */ interface $UUIDOptions { /** UUID version, default `'v4'` */ version?: V | SupportedVersion; /** Whether to use uppercase characters (default `false`) */ uppercase?: boolean; } /** * Options for generating UUID */ type UUIDOptions = V extends 'v3' | 'v5' ? $UUIDOptionsV3V5 : $UUIDOptions; /** Type representing decoded UUID info */ interface DecodedUUID { /** Original UUID */ raw: UUID; /** Plain version of the UUID without hyphens (`-`) */ plain: string; /** Version of the UUID as number */ version: $UUIDVersion; /** Variant of the UUID */ variant: 'NCS' | 'RFC4122' | 'Microsoft' | 'Future'; /** Single integer value of the UUID in bigint */ singleInt: bigint; /** Timestamp for `v1`, `v6`, `v7` and `v8` (in ms since epoch) */ timestamp?: number; /** v1 node (MAC) */ node?: string; } /** Header for `Signet` */ interface SignetHeader { /** Algorithm used. Currently supports `'HS256'` only */ alg: 'HS256'; /** Type of token. Fixed `'SIGNET+JWT'` */ typ: 'SIGNET+JWT'; } /** Options for token verification */ interface VerifyOptions { /** Where the token is allowed to be used */ audience?: string | string[]; /** Who the token is about */ subject?: string; /** From where/who the token is issued */ issuer?: string; } /** Token signing options */ interface SignOptions extends VerifyOptions { /** * * Specifies when the token expires after issuing it. * * @remarks * - A numeric value (number or numeric string ({@link Numeric})) is interpreted as seconds count, e.g., `120` or `'120'` will be treated as `'120 seconds'`. * - If you use time value with unit ({@link TimeWithUnit}) be sure you provide the time units (days, hours, etc.), otherwise it will return `NaN`, e.g., `'120 unknown'` will return `NaN`. */ expiresIn?: TimeWithUnit | Numeric; /** * * Specifies when the token becomes active/valid in the future. * * @remarks * - A numeric value (number or numeric string ({@link Numeric})) is interpreted as seconds count, e.g., `120` or `'120'` will be treated as `'120 seconds'`. * - If you use time value with unit ({@link TimeWithUnit}) be sure you provide the time units (days, hours, etc.), otherwise it will return `NaN`, e.g., `'120 unknown'` will return `NaN`. */ notBefore?: TimeWithUnit | Numeric; } /** 3-parts dot separated token string */ type TokenString = `${string}.${string}.${string}`; /** Interface of token verification result if token is valid */ interface $ValidToken { /** Whether the token is valid */ isValid: true; /** Decoded payload after successful verification with common {@link SignetPayload} properties */ payload: SignetPayload; } /** Interface of token verification result if token is invalid */ interface $InvalidToken { /** Whether the token is valid */ isValid: false; /** Error message if the token is invalid */ error: string; } /** Result of token verification */ type VerifiedToken = $ValidToken | $InvalidToken; /** Interface of `Signet` payload with `iat` and optional claims */ interface $SignetPayload { /** When the token was created (unix timestamp in seconds) */ iat: number; /** When the token was created (as JavaScript {@link Date}) */ iatDate: Date; /** When the token expires (unix timestamp in seconds) */ exp?: number; /** When the token expires (as JavaScript {@link Date}) */ expDate?: Date; /** When the token becomes valid (unix timestamp in seconds) */ nbf?: number; /** When the token becomes valid (as JavaScript {@link Date}) */ nbfDate?: Date; /** Where the token is allowed to be used */ aud?: string | string[]; /** Who the token is about */ sub?: string; /** From where/who the token is issued */ iss?: string; } /** Decoded `Signet` payload with `iat` and optional claims */ type SignetPayload = $SignetPayload & T; /** Interface of a decoded token */ interface DecodedToken { /** Token header info, algorithm, type etc. */ header: SignetHeader; /** Decoded payload after with common {@link SignetPayload} properties */ payload: SignetPayload; /** * The `Base64`-encoded signature from the token. * This is the third part of the token string. */ signature: string; /** The header and payload in encrypted `Base64` format.*/ signingInput: `${string}.${string}`; } //#endregion export { UUIDVersion as _, $UUIDOptionsV3V5 as a, DecodedToken as c, SignetHeader as d, SignetPayload as f, UUIDOptions as g, UUID as h, $UUIDOptions as i, DecodedUUID as l, TokenString as m, $SignetPayload as n, $UUIDVersion as o, SupportedVersion as p, $UUID as r, $ValidToken as s, $InvalidToken as t, SignOptions as u, VerifiedToken as v, VerifyOptions as y };