@darkbio/crypto 0.1.6 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/dist/cose.d.ts +0 -67
- package/dist/cose.d.ts.map +1 -1
- package/dist/cwt.d.ts +205 -0
- package/dist/cwt.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2155 -1278
- package/dist/index.js.map +1 -1
- package/dist/xdsa.d.ts +30 -36
- package/dist/xdsa.d.ts.map +1 -1
- package/dist/xhpke.d.ts +57 -45
- package/dist/xhpke.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,15 +9,13 @@ The library is opinionated. Parameters and primitives were selected to provide m
|
|
|
9
9
|
|
|
10
10
|

|
|
11
11
|
|
|
12
|
-
- Certificates
|
|
13
|
-
- **x509 ([RFC-5280](https://datatracker.ietf.org/doc/html/rfc5280))**: `xDSA`, `xHPKE`
|
|
14
12
|
- Digital signatures
|
|
15
13
|
- **xDSA ([RFC-DRAFT](https://datatracker.ietf.org/doc/html/draft-ietf-lamps-pq-composite-sigs))**: `MLDSA`, `EdDSA`, `SHA512`
|
|
16
14
|
- **EdDSA ([RFC-8032](https://datatracker.ietf.org/doc/html/rfc8032))**: `Ed25519`
|
|
17
|
-
- **MLDSA ([RFC-
|
|
15
|
+
- **MLDSA ([RFC-9881](https://datatracker.ietf.org/doc/html/rfc9881))**: Security level 3 (`ML-DSA-65`)
|
|
18
16
|
- **RSA¹ ([RFC-8017](https://datatracker.ietf.org/doc/html/rfc8017))**: 2048-bit, `SHA256`
|
|
19
17
|
- Encryption
|
|
20
|
-
- **xHPKE ([RFC-9180](https://datatracker.ietf.org/doc/html/rfc9180))**: `X-WING`, `HKDF`, `SHA256`, `ChaCha20`, `Poly1305`
|
|
18
|
+
- **xHPKE ([RFC-9180](https://datatracker.ietf.org/doc/html/rfc9180))**: `X-WING`, `HKDF`, `SHA256`, `ChaCha20`, `Poly1305`, `dark-bio-v1:` domain prefix
|
|
21
19
|
- **X-WING ([RFC-DRAFT](https://datatracker.ietf.org/doc/html/draft-connolly-cfrg-xwing-kem))**: `MLKEM`, `ECC`
|
|
22
20
|
- **ECC ([RFC-7748](https://datatracker.ietf.org/doc/html/rfc7748))**: `X25519`
|
|
23
21
|
- **MLKEM([RFC-DRAFT](https://datatracker.ietf.org/doc/html/draft-ietf-ipsecme-ikev2-mlkem))**: Security level 3 (`ML-KEM-768`)
|
|
@@ -28,6 +26,9 @@ The library is opinionated. Parameters and primitives were selected to provide m
|
|
|
28
26
|
- Serialization
|
|
29
27
|
- **CBOR² ([RFC-8949](https://datatracker.ietf.org/doc/html/rfc8949))**: restricted to `bool`,`null`, `integer`, `text`, `bytes`, `array`, `map[int]`, `option`
|
|
30
28
|
- **COSE ([RFC-8152](https://datatracker.ietf.org/doc/html/rfc8152))**: `COSE_Sign1`, `COSE_Encrypt0`, `dark-bio-v1:` domain prefix
|
|
29
|
+
- Credential / Attestation
|
|
30
|
+
- **CWT ([RFC-8392](https://datatracker.ietf.org/doc/html/rfc8392))**: `xDSA`, `xHPKE`
|
|
31
|
+
- **EAT ([RFC-9711](https://datatracker.ietf.org/doc/html/rfc9711))**
|
|
31
32
|
|
|
32
33
|
*¹ Whilst RSA is used in the Dark Bio project for secure boot signatures on pre-quantum hardware, there was no reason to expose that in the TypeScript wrappers. It's available in Rust so anyone needing it can expose it easily themselves.*
|
|
33
34
|
|
|
@@ -48,4 +49,4 @@ Sibling wrapper exists in one other repo:
|
|
|
48
49
|
|
|
49
50
|
Shoutout to Filippo Valsorda ([@filosottile](https://github.com/filosottile)) for lots of tips and nudges on what kind of cryptographic primitives to use and how to combine them properly; and also for his work in general on cryptography standards.
|
|
50
51
|
|
|
51
|
-
Naturally, many thanks to the authors of all the libraries this project depends on.
|
|
52
|
+
Naturally, many thanks to the authors of all the libraries this project depends on.
|
package/dist/cose.d.ts
CHANGED
|
@@ -2,49 +2,22 @@ import { SecretKey as XdsaSecretKey, PublicKey as XdsaPublicKey, Fingerprint as
|
|
|
2
2
|
import { SecretKey as XhpkeSecretKey, PublicKey as XhpkePublicKey, Fingerprint as XhpkeFingerprint } from './xhpke.js';
|
|
3
3
|
/**
|
|
4
4
|
* Create a COSE_Sign1 signature with an embedded payload.
|
|
5
|
-
*
|
|
6
|
-
* @param msgToEmbed - The payload to embed and sign (will be CBOR encoded)
|
|
7
|
-
* @param msgToAuth - Additional authenticated data (will be CBOR encoded)
|
|
8
|
-
* @param signer - The xDSA secret key
|
|
9
|
-
* @param domain - Application-specific domain separator
|
|
10
|
-
* @returns The serialized COSE_Sign1 structure
|
|
11
5
|
*/
|
|
12
6
|
export declare function sign<E, A>(msgToEmbed: E, msgToAuth: A, signer: XdsaSecretKey, domain: Uint8Array): Promise<Uint8Array>;
|
|
13
7
|
/**
|
|
14
8
|
* Create a COSE_Sign1 signature without an embedded payload (detached mode).
|
|
15
|
-
*
|
|
16
|
-
* @param msgToAuth - The message to authenticate (will be CBOR encoded)
|
|
17
|
-
* @param signer - The xDSA secret key
|
|
18
|
-
* @param domain - Application-specific domain separator
|
|
19
|
-
* @returns The serialized COSE_Sign1 structure (with null payload)
|
|
20
9
|
*/
|
|
21
10
|
export declare function signDetached<A>(msgToAuth: A, signer: XdsaSecretKey, domain: Uint8Array): Promise<Uint8Array>;
|
|
22
11
|
/**
|
|
23
12
|
* Verify a COSE_Sign1 signature and return the embedded payload.
|
|
24
|
-
*
|
|
25
|
-
* @param msgToCheck - The COSE_Sign1 structure to verify
|
|
26
|
-
* @param msgToAuth - Additional authenticated data (will be CBOR encoded)
|
|
27
|
-
* @param verifier - The xDSA public key
|
|
28
|
-
* @param domain - Application-specific domain separator
|
|
29
|
-
* @param maxDriftSecs - Maximum allowed clock drift (undefined for no time check)
|
|
30
|
-
* @returns The decoded embedded payload
|
|
31
13
|
*/
|
|
32
14
|
export declare function verify<T, A>(msgToCheck: Uint8Array, msgToAuth: A, verifier: XdsaPublicKey, domain: Uint8Array, maxDriftSecs?: number): Promise<T>;
|
|
33
15
|
/**
|
|
34
16
|
* Verify a COSE_Sign1 signature with a detached payload.
|
|
35
|
-
*
|
|
36
|
-
* @param msgToCheck - The COSE_Sign1 structure to verify
|
|
37
|
-
* @param msgToAuth - The detached message to authenticate (will be CBOR encoded)
|
|
38
|
-
* @param verifier - The xDSA public key
|
|
39
|
-
* @param domain - Application-specific domain separator
|
|
40
|
-
* @param maxDriftSecs - Maximum allowed clock drift (undefined for no time check)
|
|
41
17
|
*/
|
|
42
18
|
export declare function verifyDetached<A>(msgToCheck: Uint8Array, msgToAuth: A, verifier: XdsaPublicKey, domain: Uint8Array, maxDriftSecs?: number): Promise<void>;
|
|
43
19
|
/**
|
|
44
20
|
* Extract the signer's fingerprint from a COSE_Sign1 without verifying.
|
|
45
|
-
*
|
|
46
|
-
* @param signature - The COSE_Sign1 structure
|
|
47
|
-
* @returns The signer fingerprint
|
|
48
21
|
*/
|
|
49
22
|
export declare function signer(signature: Uint8Array): Promise<XdsaFingerprint>;
|
|
50
23
|
/**
|
|
@@ -52,66 +25,26 @@ export declare function signer(signature: Uint8Array): Promise<XdsaFingerprint>;
|
|
|
52
25
|
*
|
|
53
26
|
* Warning: The returned payload is unauthenticated and should not be
|
|
54
27
|
* trusted until verified with `verify`.
|
|
55
|
-
*
|
|
56
|
-
* @param signature - The COSE_Sign1 structure
|
|
57
|
-
* @returns The decoded (but unverified) payload
|
|
58
28
|
*/
|
|
59
29
|
export declare function peek<T>(signature: Uint8Array): Promise<T>;
|
|
60
30
|
/**
|
|
61
31
|
* Extract the recipient's fingerprint from a COSE_Encrypt0 without decrypting.
|
|
62
|
-
*
|
|
63
|
-
* @param ciphertext - The COSE_Encrypt0 structure
|
|
64
|
-
* @returns The recipient fingerprint
|
|
65
32
|
*/
|
|
66
33
|
export declare function recipient(ciphertext: Uint8Array): Promise<XhpkeFingerprint>;
|
|
67
34
|
/**
|
|
68
35
|
* Sign a message then encrypt it to a recipient (sign-then-encrypt).
|
|
69
|
-
*
|
|
70
|
-
* @param msgToSeal - The payload to sign and encrypt (will be CBOR encoded)
|
|
71
|
-
* @param msgToAuth - Additional authenticated data (will be CBOR encoded)
|
|
72
|
-
* @param signerKey - The xDSA secret key to sign with
|
|
73
|
-
* @param recipientKey - The xHPKE public key to encrypt to
|
|
74
|
-
* @param domain - Application-specific domain separator
|
|
75
|
-
* @returns The sealed COSE structure
|
|
76
36
|
*/
|
|
77
37
|
export declare function seal<S, A>(msgToSeal: S, msgToAuth: A, signerKey: XdsaSecretKey, recipientKey: XhpkePublicKey, domain: Uint8Array): Promise<Uint8Array>;
|
|
78
38
|
/**
|
|
79
39
|
* Decrypt and verify a sealed message.
|
|
80
|
-
*
|
|
81
|
-
* @param msgToOpen - The sealed COSE structure
|
|
82
|
-
* @param msgToAuth - Additional authenticated data (will be CBOR encoded)
|
|
83
|
-
* @param recipientKey - The xHPKE secret key to decrypt with
|
|
84
|
-
* @param senderKey - The xDSA public key to verify against
|
|
85
|
-
* @param domain - Application-specific domain separator
|
|
86
|
-
* @param maxDriftSecs - Maximum allowed clock drift (undefined for no time check)
|
|
87
|
-
* @returns The decoded payload
|
|
88
40
|
*/
|
|
89
41
|
export declare function open<T, A>(msgToOpen: Uint8Array, msgToAuth: A, recipientKey: XhpkeSecretKey, senderKey: XdsaPublicKey, domain: Uint8Array, maxDriftSecs?: number): Promise<T>;
|
|
90
42
|
/**
|
|
91
43
|
* Encrypt an already-signed COSE_Sign1 to a recipient.
|
|
92
|
-
*
|
|
93
|
-
* For most use cases, prefer `seal` which signs and encrypts in one step.
|
|
94
|
-
* Use this only when re-encrypting a message to a different recipient
|
|
95
|
-
* without access to the original signer's key.
|
|
96
|
-
*
|
|
97
|
-
* @param sign1 - The COSE_Sign1 structure to encrypt
|
|
98
|
-
* @param msgToAuth - Additional authenticated data (will be CBOR encoded)
|
|
99
|
-
* @param recipientKey - The xHPKE public key to encrypt to
|
|
100
|
-
* @param domain - Application-specific domain separator
|
|
101
|
-
* @returns The COSE_Encrypt0 structure
|
|
102
44
|
*/
|
|
103
45
|
export declare function encrypt<A>(sign1: Uint8Array, msgToAuth: A, recipientKey: XhpkePublicKey, domain: Uint8Array): Promise<Uint8Array>;
|
|
104
46
|
/**
|
|
105
47
|
* Decrypt a sealed message without verifying the signature.
|
|
106
|
-
*
|
|
107
|
-
* This allows inspecting the signer before verification. Use `signer` to
|
|
108
|
-
* extract the signer's fingerprint, then verify with `verify`.
|
|
109
|
-
*
|
|
110
|
-
* @param msgToOpen - The COSE_Encrypt0 structure
|
|
111
|
-
* @param msgToAuth - Additional authenticated data (will be CBOR encoded)
|
|
112
|
-
* @param recipientKey - The xHPKE secret key to decrypt with
|
|
113
|
-
* @param domain - Application-specific domain separator
|
|
114
|
-
* @returns The decrypted COSE_Sign1 structure (not yet verified)
|
|
115
48
|
*/
|
|
116
49
|
export declare function decrypt<A>(msgToOpen: Uint8Array, msgToAuth: A, recipientKey: XhpkeSecretKey, domain: Uint8Array): Promise<Uint8Array>;
|
|
117
50
|
//# sourceMappingURL=cose.d.ts.map
|
package/dist/cose.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cose.d.ts","sourceRoot":"","sources":["../src/cose.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,SAAS,IAAI,aAAa,EAC1B,SAAS,IAAI,aAAa,EAC1B,WAAW,IAAI,eAAe,EAC/B,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,SAAS,IAAI,cAAc,EAC3B,SAAS,IAAI,cAAc,EAC3B,WAAW,IAAI,gBAAgB,EAChC,MAAM,YAAY,CAAC;AA6BpB
|
|
1
|
+
{"version":3,"file":"cose.d.ts","sourceRoot":"","sources":["../src/cose.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,SAAS,IAAI,aAAa,EAC1B,SAAS,IAAI,aAAa,EAC1B,WAAW,IAAI,eAAe,EAC/B,MAAM,WAAW,CAAC;AACnB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,EAC7B,SAAS,EAAE,CAAC,EACZ,SAAS,EAAE,CAAC,EACZ,SAAS,EAAE,aAAa,EACxB,YAAY,EAAE,cAAc,EAC5B,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC,UAAU,CAAC,CAarB;AAED;;GAEG;AACH,wBAAsB,IAAI,CAAC,CAAC,EAAE,CAAC,EAC7B,SAAS,EAAE,UAAU,EACrB,SAAS,EAAE,CAAC,EACZ,YAAY,EAAE,cAAc,EAC5B,SAAS,EAAE,aAAa,EACxB,MAAM,EAAE,UAAU,EAClB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,CAAC,CAAC,CAYZ;AAED;;GAEG;AACH,wBAAsB,OAAO,CAAC,CAAC,EAC7B,KAAK,EAAE,UAAU,EACjB,SAAS,EAAE,CAAC,EACZ,YAAY,EAAE,cAAc,EAC5B,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC,UAAU,CAAC,CAMrB;AAED;;GAEG;AACH,wBAAsB,OAAO,CAAC,CAAC,EAC7B,SAAS,EAAE,UAAU,EACrB,SAAS,EAAE,CAAC,EACZ,YAAY,EAAE,cAAc,EAC5B,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC,UAAU,CAAC,CAMrB"}
|
package/dist/cwt.d.ts
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { SecretKey as XdsaSecretKey, PublicKey as XdsaPublicKey, Fingerprint as XdsaFingerprint } from './xdsa.js';
|
|
2
|
+
import { PublicKey as XhpkePublicKey } from './xhpke.js';
|
|
3
|
+
/**
|
|
4
|
+
* Debug port state per RFC 9711 Section 4.2.9.
|
|
5
|
+
*/
|
|
6
|
+
export declare enum DebugState {
|
|
7
|
+
/** Debug is currently enabled. */
|
|
8
|
+
Enabled = 0,
|
|
9
|
+
/** Debug is currently disabled. */
|
|
10
|
+
Disabled = 1,
|
|
11
|
+
/** Debug was disabled at boot and has not been enabled since. */
|
|
12
|
+
DisabledSinceBoot = 2,
|
|
13
|
+
/** Debug is disabled and cannot be re-enabled. */
|
|
14
|
+
DisabledPermanently = 3,
|
|
15
|
+
/** All debug, including DMA-based, is permanently disabled. */
|
|
16
|
+
DisabledFullyPermanently = 4
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Token intended purpose per RFC 9711 Section 4.3.3.
|
|
20
|
+
*/
|
|
21
|
+
export declare enum IntendedUse {
|
|
22
|
+
/** General-purpose attestation. */
|
|
23
|
+
Generic = 1,
|
|
24
|
+
/** Attestation for service registration. */
|
|
25
|
+
Registration = 2,
|
|
26
|
+
/** Attestation prior to key/config provisioning. */
|
|
27
|
+
Provisioning = 3,
|
|
28
|
+
/** Attestation for certificate signing requests. */
|
|
29
|
+
CertIssuance = 4,
|
|
30
|
+
/** Attestation accompanying a proof-of-possession. */
|
|
31
|
+
ProofOfPossession = 5
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A CWT claims set with typed accessors for standard CWT (RFC 8392) and
|
|
35
|
+
* EAT (RFC 9711) claims.
|
|
36
|
+
*
|
|
37
|
+
* Standard claims are exposed as typed properties. Custom or application-
|
|
38
|
+
* specific claims can be accessed via `get()` / `set()` using their integer key.
|
|
39
|
+
*/
|
|
40
|
+
export declare class Claims {
|
|
41
|
+
private readonly map;
|
|
42
|
+
/** Creates an empty claims set. */
|
|
43
|
+
constructor();
|
|
44
|
+
private static fromMap;
|
|
45
|
+
/** Issuer: identifies the principal that issued the token (key 1). */
|
|
46
|
+
get issuer(): string | undefined;
|
|
47
|
+
set issuer(value: string | undefined);
|
|
48
|
+
/** Subject: identifies the principal that is the subject of the token (key 2). */
|
|
49
|
+
get subject(): string | undefined;
|
|
50
|
+
set subject(value: string | undefined);
|
|
51
|
+
/** Audience: identifies the recipients the token is intended for (key 3). */
|
|
52
|
+
get audience(): string | undefined;
|
|
53
|
+
set audience(value: string | undefined);
|
|
54
|
+
/**
|
|
55
|
+
* Expiration: the time on or after which the token must not be accepted
|
|
56
|
+
* (key 4, Unix timestamp in seconds).
|
|
57
|
+
*/
|
|
58
|
+
get expiration(): number | undefined;
|
|
59
|
+
set expiration(value: number | undefined);
|
|
60
|
+
/**
|
|
61
|
+
* NotBefore: the time before which the token must not be accepted
|
|
62
|
+
* (key 5, Unix timestamp in seconds).
|
|
63
|
+
*/
|
|
64
|
+
get notBefore(): number | undefined;
|
|
65
|
+
set notBefore(value: number | undefined);
|
|
66
|
+
/**
|
|
67
|
+
* IssuedAt: the time at which the token was issued
|
|
68
|
+
* (key 6, Unix timestamp in seconds).
|
|
69
|
+
*/
|
|
70
|
+
get issuedAt(): number | undefined;
|
|
71
|
+
set issuedAt(value: number | undefined);
|
|
72
|
+
/** TokenID: a unique identifier for the token (key 7). */
|
|
73
|
+
get tokenId(): Uint8Array | undefined;
|
|
74
|
+
set tokenId(value: Uint8Array | undefined);
|
|
75
|
+
/**
|
|
76
|
+
* Sets the Confirm claim to bind an xDSA public key to this token.
|
|
77
|
+
* Encoded as: `{8: {1: {1: -70000, -2: <key_bytes>}}}`
|
|
78
|
+
*/
|
|
79
|
+
setConfirmXdsa(key: XdsaPublicKey): void;
|
|
80
|
+
/**
|
|
81
|
+
* Sets the Confirm claim to bind an xHPKE public key to this token.
|
|
82
|
+
* Encoded as: `{8: {1: {1: -70001, -2: <key_bytes>}}}`
|
|
83
|
+
*/
|
|
84
|
+
setConfirmXhpke(key: XhpkePublicKey): void;
|
|
85
|
+
/**
|
|
86
|
+
* Extracts the bound xDSA public key from the Confirm claim, or undefined
|
|
87
|
+
* if absent or a different key type.
|
|
88
|
+
*/
|
|
89
|
+
getConfirmXdsa(): Promise<XdsaPublicKey | undefined>;
|
|
90
|
+
/**
|
|
91
|
+
* Extracts the bound xHPKE public key from the Confirm claim, or undefined
|
|
92
|
+
* if absent or a different key type.
|
|
93
|
+
*/
|
|
94
|
+
getConfirmXhpke(): Promise<XhpkePublicKey | undefined>;
|
|
95
|
+
private readConfirm;
|
|
96
|
+
/** UEID: a globally unique device identifier (key 256). */
|
|
97
|
+
get ueid(): Uint8Array | undefined;
|
|
98
|
+
set ueid(value: Uint8Array | undefined);
|
|
99
|
+
/**
|
|
100
|
+
* OEMID: hardware manufacturer identifier (key 258).
|
|
101
|
+
*
|
|
102
|
+
* Use {@link setOemidRandom}, {@link setOemidIeee}, or {@link setOemidPen} to set.
|
|
103
|
+
* The getter returns the raw CBOR value (Uint8Array or number).
|
|
104
|
+
*/
|
|
105
|
+
get oemid(): Uint8Array | number | undefined;
|
|
106
|
+
/** Sets OEMID to a 16-byte random manufacturer identifier. */
|
|
107
|
+
setOemidRandom(id: Uint8Array): void;
|
|
108
|
+
/** Sets OEMID to a 3-byte IEEE OUI/MA-L. */
|
|
109
|
+
setOemidIeee(id: Uint8Array): void;
|
|
110
|
+
/** Sets OEMID to an IANA Private Enterprise Number. */
|
|
111
|
+
setOemidPen(pen: number): void;
|
|
112
|
+
/** HwModel: product or board model identifier (key 259). */
|
|
113
|
+
get hwModel(): Uint8Array | undefined;
|
|
114
|
+
set hwModel(value: Uint8Array | undefined);
|
|
115
|
+
/**
|
|
116
|
+
* HwVersion: hardware revision identifier (key 260).
|
|
117
|
+
* Stored as a 1-element CBOR array per RFC 9711 Section 4.2.5.
|
|
118
|
+
*/
|
|
119
|
+
get hwVersion(): string | undefined;
|
|
120
|
+
set hwVersion(value: string | undefined);
|
|
121
|
+
/** Uptime: seconds since last boot (key 261). */
|
|
122
|
+
get uptime(): number | undefined;
|
|
123
|
+
set uptime(value: number | undefined);
|
|
124
|
+
/** OemBoot: whether the boot chain is OEM-authorized (key 262). */
|
|
125
|
+
get oemBoot(): boolean | undefined;
|
|
126
|
+
set oemBoot(value: boolean | undefined);
|
|
127
|
+
/** DebugStatus: debug port state (key 263). */
|
|
128
|
+
get debugStatus(): DebugState | undefined;
|
|
129
|
+
set debugStatus(value: DebugState | undefined);
|
|
130
|
+
/** BootCount: number of times the device has booted (key 267). */
|
|
131
|
+
get bootCount(): number | undefined;
|
|
132
|
+
set bootCount(value: number | undefined);
|
|
133
|
+
/** BootSeed: random value unique to the current boot cycle (key 268). */
|
|
134
|
+
get bootSeed(): Uint8Array | undefined;
|
|
135
|
+
set bootSeed(value: Uint8Array | undefined);
|
|
136
|
+
/** SwName: name of the firmware or software (key 270). */
|
|
137
|
+
get swName(): string | undefined;
|
|
138
|
+
set swName(value: string | undefined);
|
|
139
|
+
/**
|
|
140
|
+
* SwVersion: software version identifier (key 271).
|
|
141
|
+
* Stored as a 1-element CBOR array per RFC 9711 Section 4.2.7.
|
|
142
|
+
*/
|
|
143
|
+
get swVersion(): string | undefined;
|
|
144
|
+
set swVersion(value: string | undefined);
|
|
145
|
+
/** IntendedUse: the token's purpose (key 275). */
|
|
146
|
+
get intendedUse(): IntendedUse | undefined;
|
|
147
|
+
set intendedUse(value: IntendedUse | undefined);
|
|
148
|
+
/** Gets a custom claim by its integer key. */
|
|
149
|
+
get(key: number): unknown;
|
|
150
|
+
/** Sets a custom claim by its integer key. */
|
|
151
|
+
set(key: number, value: unknown): void;
|
|
152
|
+
private setOrDelete;
|
|
153
|
+
/** Encodes the claims to CBOR bytes. @internal */
|
|
154
|
+
encode(): Uint8Array;
|
|
155
|
+
/** Decodes claims from CBOR bytes. @internal */
|
|
156
|
+
static decode(bytes: Uint8Array): Claims;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Issues a CWT by signing the claims with COSE Sign1.
|
|
160
|
+
*
|
|
161
|
+
* Uses the current system time as the COSE signature timestamp.
|
|
162
|
+
*
|
|
163
|
+
* @param claims - The claims to include in the token
|
|
164
|
+
* @param signer - The xDSA secret key to sign with
|
|
165
|
+
* @param domain - Application-specific domain separator
|
|
166
|
+
* @returns The serialized CWT
|
|
167
|
+
*/
|
|
168
|
+
export declare function issue(claims: Claims, signer: XdsaSecretKey, domain: Uint8Array): Promise<Uint8Array>;
|
|
169
|
+
/**
|
|
170
|
+
* Verifies a CWT's COSE signature and temporal validity, then returns the
|
|
171
|
+
* decoded claims.
|
|
172
|
+
*
|
|
173
|
+
* When `now` is provided (Unix timestamp in seconds), temporal claims are
|
|
174
|
+
* validated: nbf must be present and `nbf <= now`, and if exp is present
|
|
175
|
+
* then `now < exp`. When `now` is undefined, temporal validation is skipped.
|
|
176
|
+
*
|
|
177
|
+
* @param token - The serialized CWT
|
|
178
|
+
* @param verifier - The xDSA public key to verify against
|
|
179
|
+
* @param domain - Application-specific domain separator
|
|
180
|
+
* @param now - Current Unix timestamp for temporal validation (undefined to skip)
|
|
181
|
+
* @returns The decoded claims
|
|
182
|
+
*/
|
|
183
|
+
export declare function verify(token: Uint8Array, verifier: XdsaPublicKey, domain: Uint8Array, now?: number): Promise<Claims>;
|
|
184
|
+
/**
|
|
185
|
+
* Extracts the signer's fingerprint from a CWT without verifying.
|
|
186
|
+
*
|
|
187
|
+
* The returned data is unauthenticated. Use this to look up the appropriate
|
|
188
|
+
* verification key before calling {@link verify}.
|
|
189
|
+
*
|
|
190
|
+
* @param token - The serialized CWT
|
|
191
|
+
* @returns The signer fingerprint
|
|
192
|
+
*/
|
|
193
|
+
export declare function signer(token: Uint8Array): Promise<XdsaFingerprint>;
|
|
194
|
+
/**
|
|
195
|
+
* Extracts claims from a CWT without verifying the signature.
|
|
196
|
+
*
|
|
197
|
+
* **Warning**: The returned payload is unauthenticated and should not be
|
|
198
|
+
* trusted until verified with {@link verify}. Use {@link signer} to extract
|
|
199
|
+
* the signer's fingerprint for key lookup.
|
|
200
|
+
*
|
|
201
|
+
* @param token - The serialized CWT
|
|
202
|
+
* @returns The decoded (but unverified) claims
|
|
203
|
+
*/
|
|
204
|
+
export declare function peek(token: Uint8Array): Promise<Claims>;
|
|
205
|
+
//# sourceMappingURL=cwt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cwt.d.ts","sourceRoot":"","sources":["../src/cwt.ts"],"names":[],"mappings":"AA+CA,OAAO,EACL,SAAS,IAAI,aAAa,EAC1B,SAAS,IAAI,aAAa,EAC1B,WAAW,IAAI,eAAe,EAC/B,MA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;GASG;AACH,wBAAsB,KAAK,CACzB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC,UAAU,CAAC,CAIrB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,MAAM,CAC1B,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,aAAa,EACvB,MAAM,EAAE,UAAU,EAClB,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC,CAYjB;AAED;;;;;;;;GAQG;AACH,wBAAsB,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,eAAe,CAAC,CAGxE;AAED;;;;;;;;;GASG;AACH,wBAAsB,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAI7D"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC"}
|