did-jwt
- Version 8.0.4
- Published
- 1.27 MB
- 9 dependencies
- Apache-2.0 license
Install
npm i did-jwt
yarn add did-jwt
pnpm add did-jwt
Overview
Library for Signing and Verifying JWTs that use DIDs as issuers and JWEs that use DIDs as recipients
Index
Variables
Functions
- base58ToBytes()
- base64ToBytes()
- bytesToBase58()
- bytesToBase64url()
- bytesToHex()
- bytesToMultibase()
- computeX25519Ecdh1PUv3Kek()
- computeX25519EcdhEsKek()
- concatKDF()
- createAnonDecrypter()
- createAnonEncrypter()
- createAuthDecrypter()
- createAuthEncrypter()
- createFullEncrypter()
- createJWE()
- createJWS()
- createJWT()
- createMultisignatureJWT()
- createX25519ECDH()
- createX25519Ecdh1PUv3Kek()
- createX25519EcdhEsKek()
- decodeJWT()
- decryptJWE()
- EdDSASigner()
- EllipticSigner()
- ES256KSigner()
- ES256Signer()
- extractPublicKeyBytes()
- genX25519EphemeralKeyPair()
- hexToBytes()
- multibaseToBytes()
- NaclSigner()
- resolveX25519Encrypters()
- SimpleSigner()
- toEthereumAddress()
- verifyJWS()
- verifyJWT()
- x25519Decrypter()
- x25519Encrypter()
- xc20pAuthDecrypterEcdh1PuV3x25519WithXc20PkwV2()
- xc20pAuthEncrypterEcdh1PuV3x25519WithXc20PkwV2()
- xc20pDirDecrypter()
- xc20pDirEncrypter()
Interfaces
Type Aliases
Namespaces
Variables
variable JWT_ERROR
const JWT_ERROR: { INVALID_JWT: string; INVALID_AUDIENCE: string; INVALID_SIGNATURE: string; NO_SUITABLE_KEYS: string; NOT_SUPPORTED: string; RESOLVER_ERROR: string;};
Error prefixes used for known verification failure cases.
For compatibility, these error prefixes match the existing error messages, but will be adjusted in a future major version update to match the scenarios better.
Modifiers
@beta
variable supportedCodecs
const supportedCodecs: Record<KNOWN_CODECS, number>;
Functions
function base58ToBytes
base58ToBytes: (s: string) => Uint8Array;
function base64ToBytes
base64ToBytes: (s: string) => Uint8Array;
function bytesToBase58
bytesToBase58: (b: Uint8Array) => string;
function bytesToBase64url
bytesToBase64url: (b: Uint8Array) => string;
function bytesToHex
bytesToHex: (b: Uint8Array) => string;
function bytesToMultibase
bytesToMultibase: ( b: Uint8Array, base?: BaseName, codec?: keyof typeof supportedCodecs | number) => string;
Encodes the given byte array to a multibase string (defaulting to base58btc). If a codec is provided, the corresponding multicodec prefix will be added.
Parameter b
the Uint8Array to be encoded
Parameter base
the base to use for encoding (defaults to base58btc)
Parameter codec
the codec to use for encoding (defaults to no codec)
Returns
the multibase encoded string
Modifiers
@public
function computeX25519Ecdh1PUv3Kek
computeX25519Ecdh1PUv3Kek: ( recipient: Recipient, recipientSecret: Uint8Array | ECDH, senderPublicKey: Uint8Array, alg: string) => Promise<Uint8Array>;
function computeX25519EcdhEsKek
computeX25519EcdhEsKek: ( recipient: Recipient, receiverSecret: Uint8Array | ECDH, alg: string) => Promise<Uint8Array>;
function concatKDF
concatKDF: ( secret: Uint8Array, keyLen: number, alg: string, producerInfo?: Uint8Array, consumerInfo?: Uint8Array) => Uint8Array;
function createAnonDecrypter
createAnonDecrypter: (recipientSecret: Uint8Array | ECDH) => Decrypter;
Deprecated
Use xc20pAnonDecrypterEcdhESx25519WithXc20PkwV2() instead
function createAnonEncrypter
createAnonEncrypter: ( publicKey: Uint8Array, options?: Partial<AnonEncryptParams>) => Encrypter;
Deprecated
Use xc20pAnonEncrypterEcdhESx25519WithXc20PkwV2() instead
function createAuthDecrypter
createAuthDecrypter: ( recipientSecret: Uint8Array | ECDH, senderPublicKey: Uint8Array) => Decrypter;
Deprecated
Use xc20pAuthDecrypterEcdh1PuV3x25519WithXc20PkwV2() instead
function createAuthEncrypter
createAuthEncrypter: ( recipientPublicKey: Uint8Array, senderSecret: Uint8Array | ECDH, options?: Partial<AuthEncryptParams>) => Encrypter;
Deprecated
Use xc20pAuthEncrypterEcdh1PuV3x25519WithXc20PkwV2() instead
function createFullEncrypter
createFullEncrypter: ( recipientPublicKey: Uint8Array, senderSecret: Uint8Array | ECDH | undefined, options: Partial<AuthEncryptParams>, kekCreator: KekCreator, keyWrapper: KeyWrapper, contentEncrypter: ContentEncrypter) => Encrypter;
function createJWE
createJWE: ( cleartext: Uint8Array, encrypters: Encrypter[], protectedHeader?: ProtectedHeader, aad?: Uint8Array, useSingleEphemeralKey?: boolean) => Promise<JWE>;
function createJWS
createJWS: ( payload: string | Partial<JWTPayload>, signer: Signer, header?: Partial<JWTHeader>, options?: JWSCreationOptions) => Promise<string>;
Creates a signed JWS given a payload, a signer, and an optional header.
Parameter payload
payload object
Parameter signer
a signer, see
ES256KSigner or
EdDSASigner`Parameter header
optional object to specify or customize the JWS header
Parameter options
can be used to trigger automatic canonicalization of header and payload properties {Promise} a Promise which resolves to a JWS string or rejects with an error
Example 1
const signer = ES256KSigner(process.env.PRIVATE_KEY) const jws = await createJWS({ my: 'payload' }, signer)
function createJWT
createJWT: ( payload: Partial<JWTPayload>, { issuer, signer, alg, expiresIn, canonicalize }: JWTOptions, header?: Partial<JWTHeader>) => Promise<string>;
Creates a signed JWT given an address which becomes the issuer, a signer, and a payload for which the signature is over.
Parameter payload
payload object
Parameter options
an unsigned credential object
Parameter
{String} options.issuer The DID of the issuer (signer) of JWT
Parameter
{String} options.alg [DEPRECATED] The JWT signing algorithm to use. Supports: [ES256K, ES256K-R, Ed25519, EdDSA], Defaults to: ES256K. Please use
header.alg
to specify the algorithmParameter
{Signer} options.signer a
Signer
function, Please seeES256KSigner
orEdDSASigner
Parameter
{boolean} options.canonicalize optional flag to canonicalize header and payload before signing
Parameter header
optional object to specify or customize the JWT header {Promise<Object, Error>} a promise which resolves with a signed JSON Web Token or rejects with an error
Example 1
const signer = ES256KSigner(process.env.PRIVATE_KEY) createJWT({address: '5A8bRWU3F7j3REx3vkJ...', signer}, {key1: 'value', key2: ..., ... }).then(jwt => { ... })
function createMultisignatureJWT
createMultisignatureJWT: ( payload: Partial<JWTPayload>, { expiresIn, canonicalize }: Partial<JWTOptions>, issuers: { issuer: string; signer: Signer; alg: string }[]) => Promise<string>;
Creates a multi-signature signed JWT given multiple issuers and their corresponding signers, and a payload for which the signature is over.
Parameter payload
payload object
Parameter options
an unsigned credential object
Parameter
{boolean} options.expiresIn optional flag to denote the expiration time
Parameter
{boolean} options.canonicalize optional flag to canonicalize header and payload before signing
Parameter issuers
array of the issuers, their signers and algorithms
Parameter issuers
[].issuer The DID of the issuer (signer) of JWT
Parameter issuers
[].signer a
Signer
function, Please seeES256KSigner
orEdDSASigner
Parameter issuers
[].alg [DEPRECATED] The JWT signing algorithm to use. Supports: [ES256K, ES256K-R, Ed25519, EdDSA], Defaults to: ES256K. Please use
header.alg
to specify the algorithm {Promise<Object, Error>} a promise which resolves with a signed JSON Web Token or rejects with an errorExample 1
const signer = ES256KSigner(process.env.PRIVATE_KEY) createJWT({address: '5A8bRWU3F7j3REx3vkJ...', signer}, {key1: 'value', key2: ..., ... }).then(jwt => { ... })
function createX25519ECDH
createX25519ECDH: (mySecretKey: Uint8Array) => ECDH;
Wraps an X25519 secret key into an ECDH method that can be used to compute a shared secret with a public key.
Parameter mySecretKey
A
Uint8Array
of length 32 representing the bytes of my secret keyReturns
an
ECDH
method with the signature(theirPublicKey: Uint8Array) => Promise<Uint8Array>
Throws
'invalid_argument:...' if the secret key size is wrong
function createX25519Ecdh1PUv3Kek
createX25519Ecdh1PUv3Kek: ( recipientPublicKey: Uint8Array, senderSecret: Uint8Array | ECDH, alg: string, apu: string | undefined, apv: string | undefined, ephemeralKeyPair: EphemeralKeyPair | undefined) => Promise<{ epk: { kty: string; crv: string; x: string }; kek: Uint8Array }>;
function createX25519EcdhEsKek
createX25519EcdhEsKek: ( recipientPublicKey: Uint8Array, senderSecret: Uint8Array | ECDH | undefined, alg: string, apu: string | undefined, apv: string | undefined, ephemeralKeyPair: EphemeralKeyPair | undefined) => Promise<{ epk: { kty: string; crv: string; x: string }; kek: Uint8Array }>;
function decodeJWT
decodeJWT: (jwt: string, recurse?: boolean) => JWTDecoded;
Decodes a JWT and returns an object representing the payload
Parameter jwt
a JSON Web Token to verify
Parameter recurse
whether to recurse into the payload to decode any nested JWTs {Object} a JS object representing the decoded JWT
Example 1
decodeJWT('eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NksifQ.eyJpYXQiOjE1...')
function decryptJWE
decryptJWE: (jwe: JWE, decrypter: Decrypter) => Promise<Uint8Array>;
function EdDSASigner
EdDSASigner: (secretKey: Uint8Array) => Signer;
Creates a configured signer function for signing data using the EdDSA (Ed25519) algorithm.
The private key is expected to be a
Uint8Array
of 32 bytes, but for compatibility 64 bytes are also acceptable. Users of@stablelib/ed25519
ortweetnacl
will be able to use the 64 byte secret keys that library generates. These libraries precompute the public key and append it as the last 32 bytes of the secretKey, to speed up later signing operations.The signing function itself takes the data as a
Uint8Array
or utf8string
and returns abase64Url
-encoded signatureParameter secretKey
a 32 or 64 byte secret key as
Uint8Array
{Function} a configured signer function(data: string | Uint8Array): Promise<string>
Example 1
```typescript const sign: Signer = EdDSASigner(process.env.PRIVATE_KEY) const signature: string = await sign(data) ```
function EllipticSigner
EllipticSigner: (hexPrivateKey: string) => Signer;
Parameter hexPrivateKey
a hex encoded private key {Function} a configured signer function
Example 1
```typescript const signer = EllipticSigner(process.env.PRIVATE_KEY) signer(data).then( (signature: string) => { ... }) ```
Deprecated
Please use ES256KSigner The EllipticSigner returns a configured function for signing data.
function ES256KSigner
ES256KSigner: (privateKey: Uint8Array, recoverable?: boolean) => Signer;
Creates a configured signer function for signing data using the ES256K (secp256k1 + sha256) algorithm.
The signing function itself takes the data as a
Uint8Array
orstring
and returns abase64Url
-encoded signatureParameter privateKey
a private key as
Uint8Array
Parameter recoverable
an optional flag to add the recovery param to the generated signatures {Function} a configured signer function
(data: string | Uint8Array): Promise<string>
Example 1
```typescript const sign: Signer = ES256KSigner(process.env.PRIVATE_KEY) const signature: string = await sign(data) ```
function ES256Signer
ES256Signer: (privateKey: Uint8Array) => Signer;
Creates a configured signer function for signing data using the ES256 (secp256r1 + sha256) algorithm.
The signing function itself takes the data as a
Uint8Array
orstring
and returns abase64Url
-encoded signatureParameter privateKey
a private key as
Uint8Array
{Function} a configured signer function(data: string | Uint8Array): Promise<string>
Example 1
```typescript const sign: Signer = ES256Signer(process.env.PRIVATE_KEY) const signature: string = await sign(data) ```
function extractPublicKeyBytes
extractPublicKeyBytes: (pk: VerificationMethod) => { keyBytes: Uint8Array; keyType?: KNOWN_KEY_TYPE;};
Extracts the raw byte representation of a public key from a VerificationMethod along with an inferred key type
Parameter pk
a VerificationMethod entry from a DIDDocument an object containing the
keyBytes
of the public key and an inferredkeyType
function genX25519EphemeralKeyPair
genX25519EphemeralKeyPair: () => EphemeralKeyPair;
function hexToBytes
hexToBytes: (s: string, minLength?: number) => Uint8Array;
function multibaseToBytes
multibaseToBytes: (s: string) => { keyBytes: Uint8Array; keyType?: KNOWN_KEY_TYPE;};
Converts a multibase string to the Uint8Array it represents. This method will assume the byte array that is multibase encoded is a multicodec and will attempt to decode it.
Parameter s
the string to be converted
Throws
if the string is not formatted correctly.
Modifiers
@public
function NaclSigner
NaclSigner: (base64PrivateKey: string) => Signer;
Parameter base64PrivateKey
a 64 byte base64 encoded private key {Function} a configured signer function
Example 1
const signer = NaclSigner(process.env.PRIVATE_KEY) const data: string = '...' signer(data).then( (signature: string) => { ... })
Deprecated
Please use EdDSASigner
The NaclSigner returns a configured function for signing data using the Ed25519 algorithm.
The signing function itself takes the data as a
string
orUint8Array
parameter and returns abase64Url
-encoded signature.
function resolveX25519Encrypters
resolveX25519Encrypters: ( dids: string[], resolver: Resolvable) => Promise<Encrypter[]>;
function SimpleSigner
SimpleSigner: (hexPrivateKey: string) => Signer;
Parameter hexPrivateKey
a hex encoded private key {Function} a configured signer function
Example 1
const signer = SimpleSigner(process.env.PRIVATE_KEY) signer(data, (err, signature) => { ... })
Deprecated
Please use ES256KSigner The SimpleSigner returns a configured function for signing data.
function toEthereumAddress
toEthereumAddress: (hexPublicKey: string) => string;
function verifyJWS
verifyJWS: ( jws: string, pubKeys: VerificationMethod | VerificationMethod[]) => VerificationMethod;
Verifies given JWS. If the JWS is valid, returns the public key that was used to sign the JWS, or throws an
Error
if none of thepubKeys
match.Parameter jws
A JWS string to verify
Parameter pubKeys
The public keys used to verify the JWS {VerificationMethod} The public key used to sign the JWS
Example 1
const pubKey = verifyJWS('eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NksifQ.eyJyZXF1Z....', { publicKeyHex: '0x12341...' })
function verifyJWT
verifyJWT: (jwt: string, options?: JWTVerifyOptions) => Promise<JWTVerified>;
Verifies given JWT. If the JWT is valid, the promise returns an object including the JWT, the payload of the JWT, and the DID document of the issuer of the JWT.
Parameter jwt
a JSON Web Token to verify
Parameter options
an unsigned credential object
Parameter
{Boolean} options.auth Require signer to be listed in the authentication section of the DID document (for Authentication purposes)
Parameter
{String} options.audience DID of the recipient of the JWT
Parameter
{String} options.callbackUrl callback url in JWT {Promise<Object, Error>} a promise which resolves with a response object or rejects with an error
Example 1
```ts verifyJWT( 'did:uport:eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NksifQ.eyJyZXF1Z....', {audience: '5A8bRWU3F7j3REx3vkJ...', callbackUrl: 'https://...'} ).then(obj => { const did = obj.did // DID of signer const payload = obj.payload const doc = obj.didResolutionResult.didDocument // DID Document of issuer const jwt = obj.jwt const signerKeyId = obj.signer.id // ID of key in DID document that signed JWT ... }) ```
function x25519Decrypter
x25519Decrypter: (receiverSecret: Uint8Array | ECDH) => Decrypter;
Deprecated
Use xc20pAnonDecrypterEcdhESx25519WithXc20PkwV2() instead
function x25519Encrypter
x25519Encrypter: ( publicKey: Uint8Array, kid?: string, apv?: string) => Encrypter;
Deprecated
Use xc20pAnonEncrypterEcdhESx25519WithXc20PkwV2() instead
function xc20pAuthDecrypterEcdh1PuV3x25519WithXc20PkwV2
xc20pAuthDecrypterEcdh1PuV3x25519WithXc20PkwV2: ( recipientSecret: Uint8Array | ECDH, senderPublicKey: Uint8Array) => Decrypter;
Recommended decrypter for authenticated encryption (i.e. sender authentication and requires sender public key to decrypt the data). Uses ECDH-1PU v3 and XC20PKW v2.
Parameter recipientSecret
either a Uint8Array representing the recipient secret key or an ECDH function that wraps the key and can promise a shared secret given a public key
Parameter senderPublicKey
the byte array representing the sender public key
Returns
a Decrypter instance usable with decryptJWE
NOTE: ECDH-1PU and XC20PKW are proposed drafts in IETF and not a standard yet and are subject to change as new revisions or until the official CFRG specification are released.
Implements ECDH-1PU+XC20PKW with XChaCha20Poly1305 based on the following specs: - XC20PKW - ECDH-1PU
Modifiers
@beta
function xc20pAuthEncrypterEcdh1PuV3x25519WithXc20PkwV2
xc20pAuthEncrypterEcdh1PuV3x25519WithXc20PkwV2: ( recipientPublicKey: Uint8Array, senderSecret: Uint8Array | ECDH, options?: Partial<AuthEncryptParams>) => Encrypter;
Recommended encrypter for authenticated encryption (i.e. sender authentication and requires sender private key to encrypt the data). Uses ECDH-1PU v3 and XC20PKW v2.
Parameter recipientPublicKey
the byte array representing the recipient public key
Parameter senderSecret
either a Uint8Array representing the sender secret key or an ECDH function that wraps the key and can promise a shared secret given a public key
Parameter options
AuthEncryptParams used to specify extra header parameters
Returns
an Encrypter instance usable with createJWE
NOTE: ECDH-1PU and XC20PKW are proposed drafts in IETF and not a standard yet and are subject to change as new revisions or until the official CFRG specification are released.
Implements ECDH-1PU+XC20PKW with XChaCha20Poly1305 based on the following specs: - XC20PKW - ECDH-1PU
function xc20pDirDecrypter
xc20pDirDecrypter: (key: Uint8Array) => Decrypter;
function xc20pDirEncrypter
xc20pDirEncrypter: (key: Uint8Array) => Encrypter;
Interfaces
interface Decrypter
interface Decrypter {}
An object that can perform decryption of a ciphertext. It also describes the content encryption (enc) and key agreement + wrapping (alg) algorithms it supports.
interface Encrypter
interface Encrypter {}
An object that can perform content encryption and optionally key wrapping and key generation.
property alg
alg: string;
property enc
enc: string;
property encrypt
encrypt: ( cleartext: Uint8Array, protectedHeader: ProtectedHeader, aad?: Uint8Array, ephemeralKeyPair?: EphemeralKeyPair) => Promise<EncryptionResult>;
property encryptCek
encryptCek?: ( cek: Uint8Array, ephemeralKeyPair?: EphemeralKeyPair) => Promise<Recipient>;
property genEpk
genEpk?: () => EphemeralKeyPair;
interface EncryptionResult
interface EncryptionResult {}
property cek
cek?: Uint8Array;
property ciphertext
ciphertext: Uint8Array;
property iv
iv?: Uint8Array;
property protectedHeader
protectedHeader?: string;
property recipient
recipient?: Recipient;
property tag
tag?: Uint8Array;
interface EphemeralKeyPair
interface EphemeralKeyPair {}
A pair of an ephemeral public key (JWK) and its corresponding secret key. This is used to encrypt content encryption key (cek) for a recipient.
See Also
property publicKeyJWK
publicKeyJWK: EphemeralPublicKey;
property secretKey
secretKey: Uint8Array;
interface EphemeralPublicKey
interface EphemeralPublicKey {}
The JWK representation of an ephemeral public key. See https://www.rfc-editor.org/rfc/rfc7518.html#section-6
interface JWE
interface JWE {}
property aad
aad?: string;
property ciphertext
ciphertext: string;
property iv
iv: string;
property protected
protected: string;
property recipients
recipients?: Recipient[];
property tag
tag: string;
interface JWTHeader
interface JWTHeader {}
interface JWTOptions
interface JWTOptions {}
property alg
alg?: string;
Deprecated
Please use
header.alg
to specify the JWT algorithm.
property canonicalize
canonicalize?: boolean;
property expiresIn
expiresIn?: number;
property issuer
issuer: string;
property signer
signer: Signer;
interface JWTPayload
interface JWTPayload {}
interface JWTVerified
interface JWTVerified {}
Result object returned by verifyJWT
property didResolutionResult
didResolutionResult: DIDResolutionResult;
The result of resolving the issuer DID
property issuer
issuer: string;
the issuer DID
property jwt
jwt: string;
The original JWT that was verified
property payload
payload: Partial<JWTPayload>;
The decoded JWT payload
property policies
policies?: JWTVerifyPolicies;
Any overrides that were used during verification
property signer
signer: VerificationMethod;
The public key of the issuer that matches the JWT signature
property verified
verified: true;
Set to true for a JWT that passes all the required checks minus any verification overrides.
interface JWTVerifyOptions
interface JWTVerifyOptions {}
property audience
audience?: string;
property auth
auth?: boolean;
Deprecated
Please use
proofPurpose: 'authentication' instead
property callbackUrl
callbackUrl?: string;
property didAuthenticator
didAuthenticator?: DIDAuthenticator;
property policies
policies?: JWTVerifyPolicies;
property proofPurpose
proofPurpose?: ProofPurposeTypes;
See https://www.w3.org/TR/did-spec-registries/#verification-relationships
property resolver
resolver?: Resolvable;
property skewTime
skewTime?: number;
interface Recipient
interface Recipient {}
property encrypted_key
encrypted_key: string;
property header
header: RecipientHeader;
interface RecipientHeader
interface RecipientHeader {}
interface WrappingResult
interface WrappingResult {}
Type Aliases
type AnonEncryptParams
type AnonEncryptParams = { /** * recipient key ID */ kid?: string;
/** * See {@link https://datatracker.ietf.org/doc/html/rfc7518#section-4.6.1.3} * base64url encoded */ apv?: string;};
Extra parameters for JWE using anonymous encryption
type AuthEncryptParams
type AuthEncryptParams = { /** * recipient key ID */ kid?: string;
/** * See {@link https://datatracker.ietf.org/doc/html/rfc7518#section-4.6.1.2} * base64url encoded */ apu?: string;
/** * See {@link https://datatracker.ietf.org/doc/html/rfc7518#section-4.6.1.3} * base64url encoded */ apv?: string;};
Extra parameters for JWE using authenticated encryption
type ContentEncrypter
type ContentEncrypter = { /** * Create a content `Encrypter` from a content encryption key (cek). * @param cek */ from(cek: Uint8Array): Encrypter; // content encryption algorithm enc: 'XC20P' | 'A256GCM' | 'A256CBC-HS512' | string;};
type ECDH
type ECDH = (theirPublicKey: Uint8Array) => Promise<Uint8Array>;
A wrapper around
mySecretKey
that can compute a shared secret usingtheirPublicKey
. The promise should resolve to aUint8Array
containing the raw shared secret.This method is meant to be used when direct access to a secret key is impossible or not desired.
Parameter theirPublicKey
Uint8Array
the other party's public keyReturns
a
Promise
that resolves to aUint8Array
representing the computed shared secret
type KekCreator
type KekCreator = { createKek( recipientPublicKey: Uint8Array, senderSecret: Uint8Array | ECDH | undefined, // key agreement + key wrapping algorithm. e.g. ECDH-ES+A256KW alg: string, apu: string | undefined, apv: string | undefined, ephemeralKeyPair: EphemeralKeyPair | undefined ): Promise<{ epk: JsonWebKey; kek: Uint8Array }>;
// key agreement algorithm alg: 'ECDH-ES' | 'ECDH-1PU' | string;};
type KeyWrapper
type KeyWrapper = { /** * Create a key wrapper from a key encryption key (kek). * @param kek */ // eslint-disable-next-line @typescript-eslint/no-explicit-any from: (kek: Uint8Array) => { wrap: (cek: Uint8Array, options?: any) => Promise<WrappingResult>; }; // key wrapping algorithm (e.g. A256KW, XC20PKW) alg: 'A256KW' | 'XC20PKW' | string;};
An object that can perform key unwrapping.
type ProtectedHeader
type ProtectedHeader = Record<string, any> & Partial<RecipientHeader>;
type Signer
type Signer = (data: string | Uint8Array) => Promise<EcdsaSignature | string>;
Namespaces
namespace multiformats
module 'multiformats' {}
namespace multiformats.varint
namespace multiformats.varint {}
function decode
decode: (data: Uint8Array, offset?: number | undefined) => [number, number];
function encodeTo
encodeTo: ( int: number, target: Uint8Array, offset?: number | undefined) => Uint8Array;
function encodingLength
encodingLength: (int: number) => number;
namespace uint8arrays
module 'uint8arrays' {}
function compare
compare: (a: Uint8Array, b: Uint8Array) => 0 | 1 | -1;
function concat
concat: ( arrays: Array<ArrayLike<number>>, length?: number | undefined) => Uint8Array;
function fromString
fromString: ( string: string, encoding?: SupportedEncodings | undefined) => Uint8Array;
function toString
toString: ( array: Uint8Array, encoding?: SupportedEncodings | undefined) => string;
type SupportedEncodings
type SupportedEncodings = | 'utf8' | 'utf-8' | 'hex' | 'ascii' | 'base10' | 'base16' | 'base16upper' | 'base58btc' | 'base64' | 'base64url' | 'base64pad';
Package Files (20)
- src/Digest.ts
- src/Errors.ts
- src/JWT.ts
- src/dependency.types.d.ts
- src/encryption/ECDH.ts
- src/encryption/JWE.ts
- src/encryption/X25519-ECDH-1PU.ts
- src/encryption/X25519-ECDH-ES.ts
- src/encryption/createEncrypter.ts
- src/encryption/types.ts
- src/encryption/xc20pDir.ts
- src/encryption/xc20pEncryption.ts
- src/index.ts
- src/signers/ES256KSigner.ts
- src/signers/ES256Signer.ts
- src/signers/EdDSASigner.ts
- src/signers/EllipticSigner.ts
- src/signers/NaclSigner.ts
- src/signers/SimpleSigner.ts
- src/util.ts
Dependencies (9)
Dev Dependencies (38)
- @babel/core
- @babel/preset-env
- @babel/preset-typescript
- @ethersproject/address
- @greymass/eosio
- @jest/globals
- @semantic-release/changelog
- @semantic-release/git
- @tonomy/antelope-did
- @types/jest
- @types/jsonwebtoken
- @types/jwk-to-pem
- @types/node
- @typescript-eslint/eslint-plugin
- @typescript-eslint/parser
- codecov
- cross-env
- eslint
- eslint-config-prettier
- eslint-plugin-jest
- eslint-plugin-prettier
- jest
- jest-config
- jsontokens
- jsonwebtoken
- jwk-to-pem
- microbundle
- mockdate
- prettier
- regenerator-runtime
- rimraf
- semantic-release
- ts-jest
- ts-node
- tweetnacl
- typescript
- webpack
- webpack-cli
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/did-jwt
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/did-jwt)
- HTML<a href="https://www.jsdocs.io/package/did-jwt"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 6139 ms. - Missing or incorrect documentation? Open an issue for this package.