@atlasauth/pca-sdjwt 0.0.0-stage → 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Atlas Authorization
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,54 @@
1
- # Temporary Holding Version
1
+ # @atlasauth/pca-sdjwt
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ SD-JWT serialization of a Proof-Carrying Authority action proof (PCActn), so PCA proofs drop into existing JWT / SD-JWT tooling. The standard claims (`iss`, `sub`, `aud`, `iat`, `exp`, `ver`) stay in the clear; the capability claims (`action`, `plan`, `cap_chain`, `sig`, and so on) are selectively disclosable, with optional holder key binding (KB-JWT). It is a bridge, not a replacement: the PCActn's own canonical signature rides along as a disclosable `sig` claim and stays the source of truth.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm i @atlasauth/pca-sdjwt @atlasauth/pca jose
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { issuePcaSdJwt, present, verifyPcaSdJwt, importEd25519PrivateKey } from '@atlasauth/pca-sdjwt';
15
+
16
+ // Issuer: serialize a signed PCActn. `keyBinding: {}` embeds the leaf holder as the `cnf` key.
17
+ const sdjwt = await issuePcaSdJwt(pcactn, { issuerKey, keyBinding: {} });
18
+
19
+ // Holder: disclose only some claims and bind the presentation to the verifier (KB-JWT).
20
+ const presentation = await present(sdjwt, ['action', 'sig'], {
21
+ keyBinding: {
22
+ holderKey: importEd25519PrivateKey(agentSecretKey), // raw 32-byte PCA seed -> jose key
23
+ audience: 'https://rs.example.com',
24
+ nonce: 'n-123',
25
+ },
26
+ });
27
+
28
+ // Verifier: fail-closed.
29
+ const res = await verifyPcaSdJwt(presentation, {
30
+ issuerKey: issuerPublicKey,
31
+ expectedAudience: 'https://rs.example.com',
32
+ requireKeyBinding: true,
33
+ expectedNonce: 'n-123',
34
+ requiredDisclosures: ['action'],
35
+ });
36
+ if (res.ok) console.log(res.disclosed, res.keyBinding); // { action, sig }, { presented, verified, aud, nonce }
37
+ else console.error(res.reason);
38
+ ```
39
+
40
+ `issuerKey` is a jose `KeyLike` (a Node `KeyObject` works); the default algorithm is EdDSA.
41
+
42
+ ## API
43
+
44
+ - `issuePcaSdJwt(pcactn, options)`, `present(sdjwt, claimNames, options?)`, `verifyPcaSdJwt(sdjwt, options)`.
45
+ - Key helpers: `ed25519PublicJwk`, `importEd25519PrivateKey`, `importEd25519PublicKey` (bridge raw PCA Ed25519 keys to jose).
46
+ - Constants: `PCA_CAPABILITY_CLAIMS`, `SD_ALG`, `PCA_SD_JWT_TYP`, `KB_JWT_TYP`, `DEFAULT_SIGNING_ALG`.
47
+
48
+ ## Status
49
+
50
+ Experimental. Verifying an SD-JWT checks the issuer's JWT signature, disclosure digests and key binding. It does not re-run the PCA verification of the embedded chain, plan and `sig`; do that with `@atlasauth/pca` on the recovered claims. The SD-JWT specification is still moving, and this package is unaudited.
51
+
52
+ ## License
53
+
54
+ MIT - see LICENSE
@@ -0,0 +1,198 @@
1
+ /**
2
+ * @atlasauth/pca-sdjwt — SD-JWT serialization of a PCA `PCActn`.
3
+ *
4
+ * ┌──────────────────────────────────────────────────────────────────────────────────────────────┐
5
+ * │ A PCActn is an EPHEMERAL, signed proof-of-authority for ONE action (packages/pca `pcactn.ts`). │
6
+ * │ This package re-expresses that proof as an IETF SD-JWT so it drops into the JWT / SD-JWT │
7
+ * │ verifiers the wider ecosystem already runs, with selective disclosure of the capability claims │
8
+ * │ and optional holder key-binding. It is a BRIDGE, not a replacement: the PCActn's own canonical │
9
+ * │ signature (`sig`, over `thresholdMessage`) remains the source of truth; here it rides as a │
10
+ * │ selectively-disclosable claim alongside the rest of the proof. │
11
+ * └──────────────────────────────────────────────────────────────────────────────────────────────┘
12
+ *
13
+ * STANDARDS
14
+ * - **IETF SD-JWT** (draft-ietf-oauth-selective-disclosure-jwt → RFC 9701 family): an issuer-signed JWT
15
+ * whose payload carries `_sd` (an array of base64url SHA-256 digests of salted *Disclosures*) and
16
+ * `_sd_alg: "sha-256"`, serialized as `<Issuer-signed JWT>~<Disclosure 1>~…~<Disclosure N>~[<KB-JWT>]`.
17
+ * Each Disclosure is `base64url(UTF-8(JSON([salt, claim_name, claim_value])))`; its digest is
18
+ * `base64url(SHA-256(ASCII(<Disclosure>)))`. A holder MAY drop Disclosures to withhold claims.
19
+ * - **SD-JWT Key Binding**: the issuer-signed JWT carries a `cnf` confirmation claim holding the holder's
20
+ * public JWK; at presentation the holder appends a **KB-JWT** (`typ: "kb+jwt"`) signed by that key, whose
21
+ * payload binds `iat`, `aud`, optional `nonce`, and `sd_hash` = `base64url(SHA-256(ASCII(<everything up
22
+ * to and including the last '~' before the KB-JWT>)))`. This is holder proof-of-possession.
23
+ *
24
+ * ──────────────────────────────────────────────────────────────────────────────────────────────────
25
+ * CLAIM MAPPING (PCActn ↔ SD-JWT)
26
+ * ──────────────────────────────────────────────────────────────────────────────────────────────────
27
+ * Standard JWT claims (always in the clear, so a plain JWT verifier reads them):
28
+ * iss ← `cap_chain[0].issuer` (the ROOT issuer = the principal public key)
29
+ * sub ← `cap_chain[last].holder` (the acting agent — the leaf holder; the cnf key)
30
+ * aud ← `aud` (the resource server / Atlas instance id)
31
+ * iat ← floor(`iat` / 1000) (PCActn `iat` is epoch MS; JWT NumericDate is seconds)
32
+ * exp ← ceil(`exp` / 1000) (PCActn `exp` is epoch MS; JWT NumericDate is seconds)
33
+ * ver ← `ver` (protocol version; a stable, non-sensitive discriminator)
34
+ *
35
+ * Capability claims (selectively-disclosable by default — one Disclosure + `_sd` digest each; the claim
36
+ * name equals the PCActn field name so a full disclosure reconstructs the proof verbatim):
37
+ * action, grant_ref, cap_chain, plan, attestation, provenance, freshness, counter, risk_claim,
38
+ * nonce?, caution?, rationale_commitment?, progress_step?, prohibition_evidence?, tool_binding?,
39
+ * alg?, pq_pk?, sig, pq_sig?, threshold?, zk_compliance?, bond_ref?
40
+ * (`disclosable` overrides this set; any capability claim NOT selected is emitted in the clear instead.)
41
+ *
42
+ * cnf → `{ jwk: <holder public JWK> }` when key-binding is requested (defaults to the leaf holder key).
43
+ *
44
+ * ──────────────────────────────────────────────────────────────────────────────────────────────────
45
+ * AP2 / WIMSE ALIGNMENT
46
+ * ──────────────────────────────────────────────────────────────────────────────────────────────────
47
+ * - **WIMSE** (IETF Workload Identity in Multi-System Environments): a workload-identity token is a JWT
48
+ * whose SUBJECT is the acting workload, proof-of-possession–bound to a key in `cnf`. A PCA SD-JWT is
49
+ * exactly that shape — `sub` is the acting agent (leaf holder) and `cnf` carries its PoP key — so a PCA
50
+ * proof travels as a WIMSE-style WIT, with the authority chain + action attached as SD claims.
51
+ * - **AP2** (Agent Payments Protocol): AP2 mandates are a chain of signed credentials that only ever
52
+ * NARROW authority (Intent → Cart → Payment). A PCActn's `cap_chain` is the same attenuating chain, and
53
+ * this SD-JWT is the single-action analogue of an AP2 mandate credential — `aud`/`exp` bound, holder
54
+ * key-bound, selectively disclosable. See `@atlasauth/pca-ap2` for the full Intent→Cart→Payment bridge;
55
+ * this package is the generic single-proof SD-JWT those mandates can be carried as.
56
+ */
57
+ import { type JWK, type JWTPayload, type JWTHeaderParameters, type KeyLike } from 'jose';
58
+ import type { PCActn } from '@atlasauth/pca';
59
+ /** The SD-JWT hash algorithm (`_sd_alg`) this package emits and the only one it accepts. */
60
+ export declare const SD_ALG: "sha-256";
61
+ /** `typ` of the issuer-signed JWT — a PCA SD-JWT media type. */
62
+ export declare const PCA_SD_JWT_TYP: "pca+sd-jwt";
63
+ /** `typ` of the Key-Binding JWT, per the SD-JWT spec. */
64
+ export declare const KB_JWT_TYP: "kb+jwt";
65
+ /** Default JWS algorithm for both the issuer JWT and the KB-JWT (PCA leaf keys are Ed25519 ⇒ EdDSA). */
66
+ export declare const DEFAULT_SIGNING_ALG: "EdDSA";
67
+ /**
68
+ * The PCActn fields carried as selectively-disclosable capability claims by default (claim name == field
69
+ * name). The standard-mapped fields (`aud`/`iat`/`exp`) and the clear discriminator (`ver`) are excluded.
70
+ */
71
+ export declare const PCA_CAPABILITY_CLAIMS: readonly string[];
72
+ /** A `{ kty:'OKP', crv:'Ed25519', x }` JWK for a raw 32-byte Ed25519 public key. */
73
+ export declare function ed25519PublicJwk(raw: Uint8Array): JWK;
74
+ /** Import a raw 32-byte Ed25519 SEED (the PCA secret key) into a jose-signable `KeyLike`. */
75
+ export declare function importEd25519PrivateKey(rawSeed: Uint8Array): KeyLike;
76
+ /** Import a raw 32-byte Ed25519 public key into a jose-verifiable `KeyLike`. */
77
+ export declare function importEd25519PublicKey(raw: Uint8Array): KeyLike;
78
+ /** Holder key material to embed as the `cnf` confirmation claim (enables later KB-JWT binding). */
79
+ export interface KeyBindingEmbed {
80
+ /**
81
+ * The holder's PUBLIC key for `cnf`: either a JWK, a raw 32-byte Ed25519 public key, or omitted. When
82
+ * omitted the leaf holder of the capability chain (`cap_chain[last].holder`, a b64u Ed25519 key) is used,
83
+ * binding the proof to the acting agent itself.
84
+ */
85
+ holderPublicKey?: JWK | Uint8Array;
86
+ }
87
+ export interface IssueOptions {
88
+ /** The issuer's signing key (jose `KeyLike`; a Node `KeyObject` works). EdDSA keys are the default. */
89
+ issuerKey: KeyLike | Uint8Array;
90
+ /**
91
+ * Capability claim names to make selectively-disclosable. Default: {@link PCA_CAPABILITY_CLAIMS}. Any
92
+ * capability claim NOT selected here is emitted in the CLEAR instead of behind a Disclosure.
93
+ */
94
+ disclosable?: readonly string[];
95
+ /** Embed a `cnf` holder key so the proof can later be KB-bound at presentation. */
96
+ keyBinding?: KeyBindingEmbed;
97
+ /** Override the `iss` claim (default: the capability chain's root issuer). */
98
+ iss?: string;
99
+ /** Override the `sub` claim (default: the capability chain's leaf holder). */
100
+ sub?: string;
101
+ /** Override the issuer JWT `typ` header (default {@link PCA_SD_JWT_TYP}). */
102
+ typ?: string;
103
+ /** JWS algorithm for the issuer JWT (default {@link DEFAULT_SIGNING_ALG}). */
104
+ signingAlg?: string;
105
+ }
106
+ /**
107
+ * Serialize a signed `PCActn` as an IETF SD-JWT: `<Issuer-signed JWT>~<Disclosure 1>~…~<Disclosure N>~`.
108
+ * The standard JWT claims (`iss`/`sub`/`aud`/`iat`/`exp`/`ver`) are in the clear; the capability claims are
109
+ * selectively disclosable (one Disclosure each, digests in `_sd`). No KB-JWT is attached at issuance — the
110
+ * holder attaches one at {@link present} time; `keyBinding` only embeds the `cnf` key that enables it.
111
+ */
112
+ export declare function issuePcaSdJwt(pcActn: PCActn, options: IssueOptions): Promise<string>;
113
+ /** Key-binding material the holder uses to sign a KB-JWT at presentation time. */
114
+ export interface PresentKeyBinding {
115
+ /** The holder's signing key (jose `KeyLike`). Use {@link importEd25519PrivateKey} for a raw PCA seed. */
116
+ holderKey: KeyLike | Uint8Array;
117
+ /** The verifier this presentation is for (KB-JWT `aud`). */
118
+ audience: string;
119
+ /** Verifier-supplied anti-replay nonce (KB-JWT `nonce`). */
120
+ nonce?: string;
121
+ /** KB-JWT `iat` (unix seconds); defaults to now. */
122
+ iat?: number;
123
+ /** JWS algorithm for the KB-JWT (default {@link DEFAULT_SIGNING_ALG}). */
124
+ alg?: string;
125
+ }
126
+ export interface PresentOptions {
127
+ /** When set, append a KB-JWT proving holder possession of the `cnf` key over this exact presentation. */
128
+ keyBinding?: PresentKeyBinding;
129
+ }
130
+ /**
131
+ * Produce a holder presentation of an issued SD-JWT that discloses ONLY `selectClaims` (by claim name) and
132
+ * drops every other Disclosure. Any existing KB-JWT is stripped and, when `options.keyBinding` is given, a
133
+ * fresh KB-JWT is signed over the new presentation. Claim names that are not disclosable (they are in the
134
+ * clear, or absent) are simply ignored.
135
+ */
136
+ export declare function present(sdjwt: string, selectClaims: readonly string[], options?: PresentOptions): Promise<string>;
137
+ /** Outcome of the key-binding check. */
138
+ export interface KeyBindingResult {
139
+ /** Whether a KB-JWT was attached to the presentation. */
140
+ presented: boolean;
141
+ /** Whether the KB-JWT verified (signature, `sd_hash`, and any aud/nonce expectations). */
142
+ verified: boolean;
143
+ /** The KB-JWT `aud`, when present. */
144
+ aud?: string;
145
+ /** The KB-JWT `nonce`, when present. */
146
+ nonce?: string;
147
+ }
148
+ export interface VerifyOptions {
149
+ /** The issuer's public key (jose `KeyLike`). Use {@link importEd25519PublicKey} for a raw PCA key. */
150
+ issuerKey: KeyLike | Uint8Array;
151
+ /** Claim names that MUST be among the presented Disclosures (else verification fails). */
152
+ requiredDisclosures?: readonly string[];
153
+ /** When set, the `aud` claim MUST equal this (enforced on BOTH the issuer JWT and any KB-JWT). */
154
+ expectedAudience?: string;
155
+ /**
156
+ * The holder key the KB MUST be bound to. When set, verification REQUIRES a KB-JWT and requires that the
157
+ * issuer's `cnf` key equals this key (JWK, raw Ed25519 bytes, or a `KeyLike`).
158
+ */
159
+ keyBindingKey?: KeyLike | JWK | Uint8Array;
160
+ /** When set, the KB-JWT `nonce` MUST equal this. */
161
+ expectedNonce?: string;
162
+ /** Require a KB-JWT even without `keyBindingKey` (default false). */
163
+ requireKeyBinding?: boolean;
164
+ /** Permitted issuer-JWT JWS algorithms (default `['EdDSA']`). */
165
+ algorithms?: string[];
166
+ /** Permitted KB-JWT JWS algorithms (default `['EdDSA']`). */
167
+ kbAlgorithms?: string[];
168
+ /** Verification clock (unix ms); defaults to the real clock. */
169
+ now?: number;
170
+ /** Clock tolerance (seconds) passed through to jose. */
171
+ clockToleranceSec?: number;
172
+ }
173
+ export type VerifyResult = {
174
+ ok: true;
175
+ /** The issuer JWT payload (standard + any clear capability claims). */
176
+ payload: JWTPayload;
177
+ /** The issuer JWT protected header. */
178
+ protectedHeader: JWTHeaderParameters;
179
+ /** The capability claims recovered from the presented Disclosures. */
180
+ disclosed: Record<string, unknown>;
181
+ /** Clear capability claims ∪ disclosed capability claims (everything but the reserved std claims). */
182
+ claims: Record<string, unknown>;
183
+ keyBinding: KeyBindingResult;
184
+ } | {
185
+ ok: false;
186
+ reason: string;
187
+ };
188
+ /**
189
+ * Verify a PCA SD-JWT, FAIL-CLOSED: any bad signature, unknown `_sd_alg`, unmatched/forged Disclosure,
190
+ * audience/expiry violation, or key-binding failure returns `{ ok: false }`. On success it returns the
191
+ * issuer payload, the recovered capability claims, and the key-binding outcome.
192
+ *
193
+ * Steps: (1) verify the issuer JWS (jose enforces `exp`/`nbf`, and `aud` when `expectedAudience` is set);
194
+ * (2) require `_sd_alg === "sha-256"` when any `_sd` is present; (3) for each presented Disclosure,
195
+ * recompute its digest and require it to appear in `_sd` (an unknown Disclosure is a tamper → fail);
196
+ * (4) enforce `requiredDisclosures`; (5) verify the KB-JWT when present/required.
197
+ */
198
+ export declare function verifyPcaSdJwt(sdjwt: string, options: VerifyOptions): Promise<VerifyResult>;
package/dist/index.js ADDED
@@ -0,0 +1,417 @@
1
+ "use strict";
2
+ /**
3
+ * @atlasauth/pca-sdjwt — SD-JWT serialization of a PCA `PCActn`.
4
+ *
5
+ * ┌──────────────────────────────────────────────────────────────────────────────────────────────┐
6
+ * │ A PCActn is an EPHEMERAL, signed proof-of-authority for ONE action (packages/pca `pcactn.ts`). │
7
+ * │ This package re-expresses that proof as an IETF SD-JWT so it drops into the JWT / SD-JWT │
8
+ * │ verifiers the wider ecosystem already runs, with selective disclosure of the capability claims │
9
+ * │ and optional holder key-binding. It is a BRIDGE, not a replacement: the PCActn's own canonical │
10
+ * │ signature (`sig`, over `thresholdMessage`) remains the source of truth; here it rides as a │
11
+ * │ selectively-disclosable claim alongside the rest of the proof. │
12
+ * └──────────────────────────────────────────────────────────────────────────────────────────────┘
13
+ *
14
+ * STANDARDS
15
+ * - **IETF SD-JWT** (draft-ietf-oauth-selective-disclosure-jwt → RFC 9701 family): an issuer-signed JWT
16
+ * whose payload carries `_sd` (an array of base64url SHA-256 digests of salted *Disclosures*) and
17
+ * `_sd_alg: "sha-256"`, serialized as `<Issuer-signed JWT>~<Disclosure 1>~…~<Disclosure N>~[<KB-JWT>]`.
18
+ * Each Disclosure is `base64url(UTF-8(JSON([salt, claim_name, claim_value])))`; its digest is
19
+ * `base64url(SHA-256(ASCII(<Disclosure>)))`. A holder MAY drop Disclosures to withhold claims.
20
+ * - **SD-JWT Key Binding**: the issuer-signed JWT carries a `cnf` confirmation claim holding the holder's
21
+ * public JWK; at presentation the holder appends a **KB-JWT** (`typ: "kb+jwt"`) signed by that key, whose
22
+ * payload binds `iat`, `aud`, optional `nonce`, and `sd_hash` = `base64url(SHA-256(ASCII(<everything up
23
+ * to and including the last '~' before the KB-JWT>)))`. This is holder proof-of-possession.
24
+ *
25
+ * ──────────────────────────────────────────────────────────────────────────────────────────────────
26
+ * CLAIM MAPPING (PCActn ↔ SD-JWT)
27
+ * ──────────────────────────────────────────────────────────────────────────────────────────────────
28
+ * Standard JWT claims (always in the clear, so a plain JWT verifier reads them):
29
+ * iss ← `cap_chain[0].issuer` (the ROOT issuer = the principal public key)
30
+ * sub ← `cap_chain[last].holder` (the acting agent — the leaf holder; the cnf key)
31
+ * aud ← `aud` (the resource server / Atlas instance id)
32
+ * iat ← floor(`iat` / 1000) (PCActn `iat` is epoch MS; JWT NumericDate is seconds)
33
+ * exp ← ceil(`exp` / 1000) (PCActn `exp` is epoch MS; JWT NumericDate is seconds)
34
+ * ver ← `ver` (protocol version; a stable, non-sensitive discriminator)
35
+ *
36
+ * Capability claims (selectively-disclosable by default — one Disclosure + `_sd` digest each; the claim
37
+ * name equals the PCActn field name so a full disclosure reconstructs the proof verbatim):
38
+ * action, grant_ref, cap_chain, plan, attestation, provenance, freshness, counter, risk_claim,
39
+ * nonce?, caution?, rationale_commitment?, progress_step?, prohibition_evidence?, tool_binding?,
40
+ * alg?, pq_pk?, sig, pq_sig?, threshold?, zk_compliance?, bond_ref?
41
+ * (`disclosable` overrides this set; any capability claim NOT selected is emitted in the clear instead.)
42
+ *
43
+ * cnf → `{ jwk: <holder public JWK> }` when key-binding is requested (defaults to the leaf holder key).
44
+ *
45
+ * ──────────────────────────────────────────────────────────────────────────────────────────────────
46
+ * AP2 / WIMSE ALIGNMENT
47
+ * ──────────────────────────────────────────────────────────────────────────────────────────────────
48
+ * - **WIMSE** (IETF Workload Identity in Multi-System Environments): a workload-identity token is a JWT
49
+ * whose SUBJECT is the acting workload, proof-of-possession–bound to a key in `cnf`. A PCA SD-JWT is
50
+ * exactly that shape — `sub` is the acting agent (leaf holder) and `cnf` carries its PoP key — so a PCA
51
+ * proof travels as a WIMSE-style WIT, with the authority chain + action attached as SD claims.
52
+ * - **AP2** (Agent Payments Protocol): AP2 mandates are a chain of signed credentials that only ever
53
+ * NARROW authority (Intent → Cart → Payment). A PCActn's `cap_chain` is the same attenuating chain, and
54
+ * this SD-JWT is the single-action analogue of an AP2 mandate credential — `aud`/`exp` bound, holder
55
+ * key-bound, selectively disclosable. See `@atlasauth/pca-ap2` for the full Intent→Cart→Payment bridge;
56
+ * this package is the generic single-proof SD-JWT those mandates can be carried as.
57
+ */
58
+ Object.defineProperty(exports, "__esModule", { value: true });
59
+ exports.PCA_CAPABILITY_CLAIMS = exports.DEFAULT_SIGNING_ALG = exports.KB_JWT_TYP = exports.PCA_SD_JWT_TYP = exports.SD_ALG = void 0;
60
+ exports.ed25519PublicJwk = ed25519PublicJwk;
61
+ exports.importEd25519PrivateKey = importEd25519PrivateKey;
62
+ exports.importEd25519PublicKey = importEd25519PublicKey;
63
+ exports.issuePcaSdJwt = issuePcaSdJwt;
64
+ exports.present = present;
65
+ exports.verifyPcaSdJwt = verifyPcaSdJwt;
66
+ const node_crypto_1 = require("node:crypto");
67
+ const jose_1 = require("jose");
68
+ // ===================================================================================================
69
+ // Constants
70
+ // ===================================================================================================
71
+ /** The SD-JWT hash algorithm (`_sd_alg`) this package emits and the only one it accepts. */
72
+ exports.SD_ALG = 'sha-256';
73
+ /** `typ` of the issuer-signed JWT — a PCA SD-JWT media type. */
74
+ exports.PCA_SD_JWT_TYP = 'pca+sd-jwt';
75
+ /** `typ` of the Key-Binding JWT, per the SD-JWT spec. */
76
+ exports.KB_JWT_TYP = 'kb+jwt';
77
+ /** Default JWS algorithm for both the issuer JWT and the KB-JWT (PCA leaf keys are Ed25519 ⇒ EdDSA). */
78
+ exports.DEFAULT_SIGNING_ALG = 'EdDSA';
79
+ /**
80
+ * The PCActn fields carried as selectively-disclosable capability claims by default (claim name == field
81
+ * name). The standard-mapped fields (`aud`/`iat`/`exp`) and the clear discriminator (`ver`) are excluded.
82
+ */
83
+ exports.PCA_CAPABILITY_CLAIMS = [
84
+ 'action',
85
+ 'grant_ref',
86
+ 'cap_chain',
87
+ 'plan',
88
+ 'attestation',
89
+ 'provenance',
90
+ 'freshness',
91
+ 'counter',
92
+ 'risk_claim',
93
+ 'nonce',
94
+ 'caution',
95
+ 'rationale_commitment',
96
+ 'progress_step',
97
+ 'prohibition_evidence',
98
+ 'tool_binding',
99
+ 'alg',
100
+ 'pq_pk',
101
+ 'sig',
102
+ 'pq_sig',
103
+ 'threshold',
104
+ 'zk_compliance',
105
+ 'bond_ref',
106
+ ];
107
+ /** PCActn fields that become standard JWT claims (not eligible for a capability Disclosure). */
108
+ const STANDARD_MAPPED = new Set(['aud', 'iat', 'exp']);
109
+ /** Field carried in the clear as a discriminator (not disclosable). */
110
+ const CLEAR_DISCRIMINATOR = 'ver';
111
+ /** Reserved top-level claim names that are never treated as recovered capability claims. */
112
+ const RESERVED_CLAIMS = new Set(['iss', 'sub', 'aud', 'iat', 'exp', '_sd', '_sd_alg', 'cnf']);
113
+ // ===================================================================================================
114
+ // base64url / sha-256 helpers (Node built-ins only; no new deps)
115
+ // ===================================================================================================
116
+ function b64uBytes(bytes) {
117
+ return Buffer.from(bytes).toString('base64url');
118
+ }
119
+ /** `base64url(SHA-256(ASCII(input)))` — the SD-JWT Disclosure digest / KB `sd_hash` construction. */
120
+ function sha256b64u(asciiInput) {
121
+ return (0, node_crypto_1.createHash)('sha256').update(asciiInput, 'ascii').digest().toString('base64url');
122
+ }
123
+ function isPlainObject(v) {
124
+ return typeof v === 'object' && v !== null && !Array.isArray(v) && !(v instanceof Uint8Array);
125
+ }
126
+ function isJwk(v) {
127
+ return isPlainObject(v) && typeof v.kty === 'string';
128
+ }
129
+ // ===================================================================================================
130
+ // Ed25519 raw-key ⇄ jose bridge (so the actual PCA leaf keys can issue / bind, not only jose keys)
131
+ // ===================================================================================================
132
+ // Fixed ASN.1 prefixes for a 32-byte Ed25519 key (RFC 8410): PKCS#8 private, SPKI public.
133
+ const ED25519_PKCS8_PREFIX = Buffer.from('302e020100300506032b657004220420', 'hex');
134
+ const ED25519_SPKI_PREFIX = Buffer.from('302a300506032b6570032100', 'hex');
135
+ /** A `{ kty:'OKP', crv:'Ed25519', x }` JWK for a raw 32-byte Ed25519 public key. */
136
+ function ed25519PublicJwk(raw) {
137
+ if (raw.length !== 32)
138
+ throw new Error('pca-sdjwt: Ed25519 public key must be 32 bytes');
139
+ return { kty: 'OKP', crv: 'Ed25519', x: b64uBytes(raw) };
140
+ }
141
+ /** Import a raw 32-byte Ed25519 SEED (the PCA secret key) into a jose-signable `KeyLike`. */
142
+ function importEd25519PrivateKey(rawSeed) {
143
+ if (rawSeed.length !== 32)
144
+ throw new Error('pca-sdjwt: Ed25519 private seed must be 32 bytes');
145
+ const der = Buffer.concat([ED25519_PKCS8_PREFIX, Buffer.from(rawSeed)]);
146
+ return (0, node_crypto_1.createPrivateKey)({ key: der, format: 'der', type: 'pkcs8' });
147
+ }
148
+ /** Import a raw 32-byte Ed25519 public key into a jose-verifiable `KeyLike`. */
149
+ function importEd25519PublicKey(raw) {
150
+ if (raw.length !== 32)
151
+ throw new Error('pca-sdjwt: Ed25519 public key must be 32 bytes');
152
+ const der = Buffer.concat([ED25519_SPKI_PREFIX, Buffer.from(raw)]);
153
+ return (0, node_crypto_1.createPublicKey)({ key: der, format: 'der', type: 'spki' });
154
+ }
155
+ function decodeB64uToBytes(s) {
156
+ return new Uint8Array(Buffer.from(s, 'base64url'));
157
+ }
158
+ function leafHolderJwk(pcActn) {
159
+ const chain = pcActn.cap_chain;
160
+ const leaf = Array.isArray(chain) && chain.length > 0 ? chain[chain.length - 1] : undefined;
161
+ if (!leaf || typeof leaf.holder !== 'string' || leaf.holder.length === 0) {
162
+ throw new Error('pca-sdjwt: cannot derive holder key — cap_chain leaf holder is missing');
163
+ }
164
+ const raw = decodeB64uToBytes(leaf.holder);
165
+ return ed25519PublicJwk(raw);
166
+ }
167
+ function resolveCnfJwk(pcActn, kb) {
168
+ const hp = kb.holderPublicKey;
169
+ if (hp === undefined)
170
+ return leafHolderJwk(pcActn);
171
+ if (hp instanceof Uint8Array)
172
+ return ed25519PublicJwk(hp);
173
+ if (isJwk(hp))
174
+ return hp;
175
+ throw new Error('pca-sdjwt: keyBinding.holderPublicKey must be a JWK or a raw Ed25519 public key');
176
+ }
177
+ function toNumericDate(ms, label, round) {
178
+ if (typeof ms !== 'number' || !Number.isFinite(ms))
179
+ throw new Error(`pca-sdjwt: PCActn.${label} must be a finite number (epoch ms)`);
180
+ return round(ms / 1000);
181
+ }
182
+ function makeDisclosure(name, value) {
183
+ const salt = (0, node_crypto_1.randomBytes)(16).toString('base64url');
184
+ const encoded = Buffer.from(JSON.stringify([salt, name, value]), 'utf8').toString('base64url');
185
+ return { name, encoded, digest: sha256b64u(encoded) };
186
+ }
187
+ /**
188
+ * Serialize a signed `PCActn` as an IETF SD-JWT: `<Issuer-signed JWT>~<Disclosure 1>~…~<Disclosure N>~`.
189
+ * The standard JWT claims (`iss`/`sub`/`aud`/`iat`/`exp`/`ver`) are in the clear; the capability claims are
190
+ * selectively disclosable (one Disclosure each, digests in `_sd`). No KB-JWT is attached at issuance — the
191
+ * holder attaches one at {@link present} time; `keyBinding` only embeds the `cnf` key that enables it.
192
+ */
193
+ async function issuePcaSdJwt(pcActn, options) {
194
+ if (!isPlainObject(pcActn))
195
+ throw new Error('pca-sdjwt: pcActn must be an object');
196
+ const chain = pcActn.cap_chain;
197
+ if (!Array.isArray(chain) || chain.length === 0)
198
+ throw new Error('pca-sdjwt: pcActn.cap_chain must be a non-empty array');
199
+ const root = chain[0];
200
+ const leaf = chain[chain.length - 1];
201
+ if (!root || typeof root.issuer !== 'string')
202
+ throw new Error('pca-sdjwt: cap_chain root issuer is missing');
203
+ if (!leaf || typeof leaf.holder !== 'string')
204
+ throw new Error('pca-sdjwt: cap_chain leaf holder is missing');
205
+ if (typeof pcActn.aud !== 'string' || pcActn.aud.length === 0)
206
+ throw new Error('pca-sdjwt: pcActn.aud is required');
207
+ const iss = options.iss ?? root.issuer;
208
+ const sub = options.sub ?? leaf.holder;
209
+ const iat = toNumericDate(pcActn.iat, 'iat', Math.floor);
210
+ let exp = toNumericDate(pcActn.exp, 'exp', Math.ceil);
211
+ if (exp <= iat)
212
+ exp = iat + 1; // keep exp strictly after iat even for sub-second lifetimes
213
+ const disclosableSet = new Set(options.disclosable ?? exports.PCA_CAPABILITY_CLAIMS);
214
+ const payload = { iss, sub, aud: pcActn.aud, iat, exp, [CLEAR_DISCRIMINATOR]: pcActn.ver, _sd_alg: exports.SD_ALG };
215
+ const disclosures = [];
216
+ const sd = [];
217
+ const record = pcActn;
218
+ for (const key of Object.keys(record)) {
219
+ if (STANDARD_MAPPED.has(key) || key === CLEAR_DISCRIMINATOR)
220
+ continue; // mapped to a standard/clear claim
221
+ const value = record[key];
222
+ if (value === undefined)
223
+ continue;
224
+ if (disclosableSet.has(key)) {
225
+ const d = makeDisclosure(key, value);
226
+ disclosures.push(d);
227
+ sd.push(d.digest);
228
+ }
229
+ else {
230
+ payload[key] = value; // caller chose to keep this capability claim in the clear
231
+ }
232
+ }
233
+ if (sd.length > 0)
234
+ payload._sd = sd;
235
+ if (options.keyBinding)
236
+ payload.cnf = { jwk: resolveCnfJwk(pcActn, options.keyBinding) };
237
+ const header = { alg: options.signingAlg ?? exports.DEFAULT_SIGNING_ALG, typ: options.typ ?? exports.PCA_SD_JWT_TYP };
238
+ const jwt = await new jose_1.SignJWT(payload).setProtectedHeader(header).sign(options.issuerKey);
239
+ // SD-JWT serialization: issuer JWT then each Disclosure, each terminated by '~'. No KB-JWT at issuance.
240
+ return [jwt, ...disclosures.map((d) => d.encoded)].map((p) => `${p}~`).join('');
241
+ }
242
+ function parseSdJwt(sdjwt) {
243
+ if (typeof sdjwt !== 'string' || sdjwt.length === 0)
244
+ throw new Error('pca-sdjwt: empty SD-JWT');
245
+ const segments = sdjwt.split('~');
246
+ if (segments.length < 2)
247
+ throw new Error('pca-sdjwt: malformed SD-JWT (missing ~ separator)');
248
+ const jwt = segments[0];
249
+ if (jwt === undefined || jwt === '')
250
+ throw new Error('pca-sdjwt: empty issuer JWT');
251
+ const last = segments[segments.length - 1];
252
+ const disclosures = segments.slice(1, segments.length - 1).filter((s) => s.length > 0);
253
+ if (last === undefined || last === '') {
254
+ // No KB-JWT: the string ends with '~'. The whole string is the presentation head.
255
+ return { jwt, disclosures, presentationHead: sdjwt };
256
+ }
257
+ // KB-JWT present: head is everything up to and including the final '~' before it.
258
+ const presentationHead = sdjwt.slice(0, sdjwt.length - last.length);
259
+ return { jwt, disclosures, kbJwt: last, presentationHead };
260
+ }
261
+ function decodeDisclosure(encoded) {
262
+ let parsed;
263
+ try {
264
+ parsed = JSON.parse(Buffer.from(encoded, 'base64url').toString('utf8'));
265
+ }
266
+ catch {
267
+ throw new Error('pca-sdjwt: disclosure is not valid base64url JSON');
268
+ }
269
+ if (!Array.isArray(parsed) || parsed.length !== 3)
270
+ throw new Error('pca-sdjwt: disclosure must be a [salt, name, value] triple');
271
+ const salt = parsed[0];
272
+ const name = parsed[1];
273
+ if (typeof salt !== 'string' || typeof name !== 'string')
274
+ throw new Error('pca-sdjwt: disclosure salt and name must be strings');
275
+ return { salt, name, value: parsed[2] };
276
+ }
277
+ /**
278
+ * Produce a holder presentation of an issued SD-JWT that discloses ONLY `selectClaims` (by claim name) and
279
+ * drops every other Disclosure. Any existing KB-JWT is stripped and, when `options.keyBinding` is given, a
280
+ * fresh KB-JWT is signed over the new presentation. Claim names that are not disclosable (they are in the
281
+ * clear, or absent) are simply ignored.
282
+ */
283
+ async function present(sdjwt, selectClaims, options) {
284
+ const parsed = parseSdJwt(sdjwt);
285
+ const keep = new Set(selectClaims);
286
+ const kept = [];
287
+ for (const encoded of parsed.disclosures) {
288
+ const { name } = decodeDisclosure(encoded);
289
+ if (keep.has(name))
290
+ kept.push(encoded);
291
+ }
292
+ const head = [parsed.jwt, ...kept].join('~') + '~';
293
+ if (!options?.keyBinding)
294
+ return head;
295
+ const kb = options.keyBinding;
296
+ const now = kb.iat ?? Math.floor(Date.now() / 1000);
297
+ const kbPayload = { iat: now, aud: kb.audience, sd_hash: sha256b64u(head) };
298
+ if (kb.nonce !== undefined)
299
+ kbPayload.nonce = kb.nonce;
300
+ const kbHeader = { alg: kb.alg ?? exports.DEFAULT_SIGNING_ALG, typ: exports.KB_JWT_TYP };
301
+ const kbJwt = await new jose_1.SignJWT(kbPayload).setProtectedHeader(kbHeader).sign(kb.holderKey);
302
+ return head + kbJwt;
303
+ }
304
+ async function jwkThumbX(k) {
305
+ if (k instanceof Uint8Array)
306
+ return b64uBytes(k);
307
+ if (isJwk(k))
308
+ return typeof k.x === 'string' ? k.x : undefined;
309
+ const j = await (0, jose_1.exportJWK)(k);
310
+ return typeof j.x === 'string' ? j.x : undefined;
311
+ }
312
+ /**
313
+ * Verify a PCA SD-JWT, FAIL-CLOSED: any bad signature, unknown `_sd_alg`, unmatched/forged Disclosure,
314
+ * audience/expiry violation, or key-binding failure returns `{ ok: false }`. On success it returns the
315
+ * issuer payload, the recovered capability claims, and the key-binding outcome.
316
+ *
317
+ * Steps: (1) verify the issuer JWS (jose enforces `exp`/`nbf`, and `aud` when `expectedAudience` is set);
318
+ * (2) require `_sd_alg === "sha-256"` when any `_sd` is present; (3) for each presented Disclosure,
319
+ * recompute its digest and require it to appear in `_sd` (an unknown Disclosure is a tamper → fail);
320
+ * (4) enforce `requiredDisclosures`; (5) verify the KB-JWT when present/required.
321
+ */
322
+ async function verifyPcaSdJwt(sdjwt, options) {
323
+ try {
324
+ const parsed = parseSdJwt(sdjwt);
325
+ const algorithms = options.algorithms ?? [exports.DEFAULT_SIGNING_ALG];
326
+ const verified = await (0, jose_1.jwtVerify)(parsed.jwt, options.issuerKey, {
327
+ algorithms,
328
+ ...(options.expectedAudience !== undefined ? { audience: options.expectedAudience } : {}),
329
+ ...(options.now !== undefined ? { currentDate: new Date(options.now) } : {}),
330
+ ...(options.clockToleranceSec !== undefined ? { clockTolerance: options.clockToleranceSec } : {}),
331
+ });
332
+ const payload = verified.payload;
333
+ const protectedHeader = verified.protectedHeader;
334
+ // _sd / Disclosure matching.
335
+ const sdList = Array.isArray(payload._sd) ? payload._sd.filter((x) => typeof x === 'string') : [];
336
+ if (sdList.length > 0 && payload._sd_alg !== exports.SD_ALG) {
337
+ return { ok: false, reason: `unsupported _sd_alg (require "${exports.SD_ALG}")` };
338
+ }
339
+ const sdSet = new Set(sdList);
340
+ const disclosed = {};
341
+ const seenDigests = new Set();
342
+ for (const encoded of parsed.disclosures) {
343
+ const digest = sha256b64u(encoded);
344
+ if (!sdSet.has(digest))
345
+ return { ok: false, reason: 'a presented disclosure does not match any _sd digest (tampered)' };
346
+ if (seenDigests.has(digest))
347
+ return { ok: false, reason: 'duplicate disclosure' };
348
+ seenDigests.add(digest);
349
+ const { name, value } = decodeDisclosure(encoded);
350
+ if (Object.prototype.hasOwnProperty.call(disclosed, name))
351
+ return { ok: false, reason: `disclosure claim '${name}' appears more than once` };
352
+ disclosed[name] = value;
353
+ }
354
+ for (const required of options.requiredDisclosures ?? []) {
355
+ if (!Object.prototype.hasOwnProperty.call(disclosed, required)) {
356
+ return { ok: false, reason: `required disclosure '${required}' was not presented` };
357
+ }
358
+ }
359
+ // Key binding.
360
+ const cnf = payload.cnf;
361
+ const cnfJwk = isPlainObject(cnf) && isJwk(cnf.jwk) ? cnf.jwk : undefined;
362
+ const keyBinding = { presented: parsed.kbJwt !== undefined, verified: false };
363
+ if (parsed.kbJwt !== undefined) {
364
+ if (cnfJwk === undefined)
365
+ return { ok: false, reason: 'KB-JWT presented but issuer JWT has no cnf key' };
366
+ if (options.keyBindingKey !== undefined) {
367
+ const [want, have] = await Promise.all([jwkThumbX(options.keyBindingKey), jwkThumbX(cnfJwk)]);
368
+ if (want === undefined || have === undefined || want !== have) {
369
+ return { ok: false, reason: 'cnf key does not match the expected keyBindingKey' };
370
+ }
371
+ }
372
+ const kbAlgorithms = options.kbAlgorithms ?? [exports.DEFAULT_SIGNING_ALG];
373
+ const kbKey = await (0, jose_1.importJWK)(cnfJwk, kbAlgorithms[0] ?? exports.DEFAULT_SIGNING_ALG);
374
+ let kb;
375
+ try {
376
+ kb = await (0, jose_1.jwtVerify)(parsed.kbJwt, kbKey, {
377
+ algorithms: kbAlgorithms,
378
+ ...(options.expectedAudience !== undefined ? { audience: options.expectedAudience } : {}),
379
+ ...(options.now !== undefined ? { currentDate: new Date(options.now) } : {}),
380
+ ...(options.clockToleranceSec !== undefined ? { clockTolerance: options.clockToleranceSec } : {}),
381
+ });
382
+ }
383
+ catch (e) {
384
+ return { ok: false, reason: `KB-JWT signature/claims invalid: ${e.message}` };
385
+ }
386
+ if (kb.protectedHeader.typ !== exports.KB_JWT_TYP)
387
+ return { ok: false, reason: `KB-JWT typ must be "${exports.KB_JWT_TYP}"` };
388
+ if (kb.payload.sd_hash !== sha256b64u(parsed.presentationHead)) {
389
+ return { ok: false, reason: 'KB-JWT sd_hash does not cover this presentation' };
390
+ }
391
+ if (options.expectedNonce !== undefined && kb.payload.nonce !== options.expectedNonce) {
392
+ return { ok: false, reason: 'KB-JWT nonce does not match' };
393
+ }
394
+ keyBinding.verified = true;
395
+ if (typeof kb.payload.aud === 'string')
396
+ keyBinding.aud = kb.payload.aud;
397
+ if (typeof kb.payload.nonce === 'string')
398
+ keyBinding.nonce = kb.payload.nonce;
399
+ }
400
+ else if (options.keyBindingKey !== undefined || options.requireKeyBinding) {
401
+ return { ok: false, reason: 'key binding required but no KB-JWT was presented' };
402
+ }
403
+ // Recovered capability claims = clear (non-reserved) ∪ disclosed.
404
+ const claims = {};
405
+ for (const key of Object.keys(payload)) {
406
+ if (!RESERVED_CLAIMS.has(key))
407
+ claims[key] = payload[key];
408
+ }
409
+ for (const key of Object.keys(disclosed))
410
+ claims[key] = disclosed[key];
411
+ return { ok: true, payload, protectedHeader, disclosed, claims, keyBinding };
412
+ }
413
+ catch (e) {
414
+ return { ok: false, reason: e.message };
415
+ }
416
+ }
417
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;;;AA8FH,4CAGC;AAGD,0DAIC;AAGD,wDAIC;AAkFD,sCA4CC;AA2ED,0BAkBC;AA4ED,wCAyFC;AA7eD,6CAAyF;AACzF,+BASc;AAG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vE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;IAC/E,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAG,CAAW,CAAC,OAAO,EAAE,CAAC;IACrD,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,57 @@
1
1
  {
2
2
  "name": "@atlasauth/pca-sdjwt",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.2.0",
4
+ "description": "SD-JWT serialization of a PCActn for PCA: emit/verify a PCActn (and its capability claims) as a selectively-disclosable SD-JWT so PCA proofs drop into existing JWT/SD-JWT verifiers and align with WIMSE / AP2 mandate shape.",
5
+ "keywords": [
6
+ "sd-jwt",
7
+ "selective disclosure",
8
+ "jwt",
9
+ "agent authorization",
10
+ "proof-carrying authority",
11
+ "pca",
12
+ "ai agents"
13
+ ],
14
+ "license": "MIT",
15
+ "homepage": "https://github.com/Atlas-Authorization/pca#readme",
16
+ "bugs": {
17
+ "url": "https://github.com/Atlas-Authorization/pca/issues"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/Atlas-Authorization/pca.git",
22
+ "directory": "packages/pca-sdjwt"
23
+ },
24
+ "main": "./dist/index.js",
25
+ "types": "./dist/index.d.ts",
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/index.d.ts",
29
+ "default": "./dist/index.js"
30
+ },
31
+ "./package.json": "./package.json"
32
+ },
33
+ "dependencies": {
34
+ "jose": "^5.9.6",
35
+ "@atlasauth/pca": "0.2.0"
36
+ },
37
+ "devDependencies": {
38
+ "typescript": "^5.6.3",
39
+ "vitest": "^2.1.4"
40
+ },
41
+ "files": [
42
+ "dist",
43
+ "README.md",
44
+ "LICENSE"
45
+ ],
46
+ "engines": {
47
+ "node": ">=20"
48
+ },
49
+ "publishConfig": {
50
+ "access": "public"
51
+ },
52
+ "scripts": {
53
+ "build": "tsc -p tsconfig.build.json",
54
+ "typecheck": "tsc -p tsconfig.json --noEmit",
55
+ "test": "vitest run"
56
+ }
6
57
  }