tibi-docs/docs/md/server-javascript-kontext/packages/jwt.md
2023-06-03 18:07:58 +00:00

917 B

jwt

interface JwtPackage {
    /**
     * create a jwt signed token string
     *
     * @param claims data object
     * @param options options (secret, validityDuration = expiry in X seconds)
     */
    create(
        claims: {
            [key: string]: any
        },
        options?: {
            secret?: string
            validityDuration?: number
        }
    ): string

    /**
     * parse jwt token string
     *
     * @param token token string
     * @param options options (secret)
     */
    parse(
        token: string,
        options?: {
            secret?: string
        }
    ): {
        error?: string
        valid: boolean
        method: {
            Name: string
            Hash: number
        }
        header: {
            alg: string
            typ: string
        }
        claims: {
            exp?: number
            [key: string]: any
        }
    }
}