@e-sig/uaid-exch 0.1.0-preview.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 ADDED
@@ -0,0 +1,105 @@
1
+ # @e-sig/uaid-exch
2
+
3
+ **Preview implementation of the proposed [IAASO Exchange Profile (ADR-006)](../../../../iaaso/proposals/ADR-006-exchange-profile.md).** The doctrine is under review by the IAASO standards council. This package is versioned `0.1.0-preview` and its wire format will be re-shaped to conform to the accepted schemas when ADR-006 lands. Use in production only after ADR-006 is Accepted and the schemas ship under `iaaso/artifacts/schemas/exchange/*/v1/`.
4
+
5
+ Wraps every `@e-sig/core` signing operation as a per-transaction signed authorization on the UUAID Network — subject + issuer proofs, network-side receipt, scope-checked authorization, and a Polygon-anchored batch inclusion proof that anyone can look up at `tx.uuaid.org/<id>`.
6
+
7
+ **Wire format note.** The current preview uses W3C `DataIntegrityProof` shape (`eddsa-jcs-2022`) as an ergonomic starting point. Per IAASO ADR-002, the accepted wire format for IAASO objects is the **UUAID SignatureEnvelope** (`{alg, keyId?, publicKey?, sig, created?}` — JCS + Ed25519, keccak256 for anchor). When ADR-006 is Accepted, this package will re-emit both shapes (VC shape for external interop, SignatureEnvelope for IAASO conformance) via a single call.
8
+
9
+ ```bash
10
+ npm i @e-sig/uaid-exch @uuaid/sdk
11
+ ```
12
+
13
+ MIT-licensed. Opt-in. If UUAID env is unset, this package is a no-op.
14
+
15
+ ## Why
16
+
17
+ `@e-sig/core` already produces a real cryptographic PDF signature. `@e-sig/uuaid` already stamps the acting agent's UUAID into the audit log. This package closes the loop by producing a **portable, per-exchange Verifiable Credential** that:
18
+
19
+ - **Public.** Anyone can `GET https://api.uuaid.org/v1/exchanges/<id>` without a key.
20
+ - **Three-party attested.** Agent proof + Issuer TSP proof + (asynchronously) a Network receipt.
21
+ - **Scope-checked.** The Signing Credential's `scope` (actions, counterparty allowlist, value ceiling, assurance minimum) is machine-enforced by verifiers before the counterparty acts.
22
+ - **Anchored.** Every batch of receipts is Merkle-rooted and anchored to Polygon mainnet by the UUAID registry. Rewriting history means contradicting a public blockchain.
23
+ - **Interoperable.** Compatible with Google AP2 as an extension credential (`uuaid.exchange.v1`); the AP2 Payment Mandate id can be cross-referenced in `external_refs.ap2_payment_mandate`.
24
+
25
+ ## Quickstart
26
+
27
+ ```ts
28
+ import { signDocument } from "@e-sig/core";
29
+ import { UuaidClient } from "@uuaid/sdk";
30
+ import {
31
+ createExchange,
32
+ exchangeInputFromEsigEnvelope,
33
+ UaidNetworkClient,
34
+ } from "@e-sig/uaid-exch";
35
+
36
+ // 1. Sign the PDF as usual with @e-sig/core.
37
+ const signed = await signDocument({ /* ...as usual... */ });
38
+
39
+ // 2. Build a UAP-EXCH-1 Exchange over that signing action.
40
+ const network = new UaidNetworkClient({ apiKey: process.env.UUAID_API_KEY! });
41
+
42
+ const exchange = await createExchange(
43
+ exchangeInputFromEsigEnvelope({
44
+ envelopeId: signed.envelopeId,
45
+ signingCredentialId: process.env.UUAID_SIGNING_CREDENTIAL_ID!,
46
+ principal: "did:web:acme.com",
47
+ counterparty: "did:web:customer.com",
48
+ pdfSha256: `sha256:${signed.pdfSha256Hex}`,
49
+ pdfSize: signed.signedPdfBytes.length,
50
+ pdfUri: signed.signedPdfUrl,
51
+ purpose: "MSA Q3 renewal",
52
+ value_impact: { currency: "USD", amount: 24000, term_months: 12 },
53
+ soleControl: {
54
+ challenge_type: "webauthn-prf",
55
+ challenge_at: signed.consent.givenAt,
56
+ challenge_evidence_hash: `sha256:${signed.consent.evidenceSha256Hex}`,
57
+ },
58
+ }),
59
+ agentSigner, // provide { agentUuaid, verificationMethod, sign(bytes) }
60
+ issuerSigner // provide { issuerDid, verificationMethod, sign(bytes) }
61
+ );
62
+
63
+ // 3. Submit to the network. The receipt anchors ~10 minutes later.
64
+ const { exchange_id, estimated_anchor_at } = await network.submit(exchange);
65
+
66
+ // 4. Anyone can now verify at tx.uuaid.org/<tx_short_id> once anchored.
67
+ console.log(network.resolverUrl(exchange_id));
68
+ ```
69
+
70
+ ## Assurance ladder
71
+
72
+ Per [UAP-EXCH-1 § 4](https://github.com/uuaid/spec/blob/main/docs/profiles/UAP-EXCH-1/v0.1.md#4-assurance-ladder):
73
+
74
+ | Level | Requirements |
75
+ |---|---|
76
+ | **L0** | Software-key Agent, no KYA. |
77
+ | **L1** | Software-key + verified Principal. |
78
+ | **L2** | HW-attested key + org-verified Principal. |
79
+ | **L3** | L2 + continuous evidence from an Assurance Provider (e.g. DSalvus). |
80
+ | **L4** | L3 + industry KYA depth (HIPAA / PCI / SOX / 21 CFR Part 11) + insurance. |
81
+ | **L5** | L4 + eIDAS QES by a QTSP on the EU Trusted List. |
82
+
83
+ Counterparties enforce a minimum level; this SDK renders it into the Signing Credential and Exchange so verification is one JSON check.
84
+
85
+ ## Strictly opt-in
86
+
87
+ Absent `UUAID_API_KEY`, the package is a pure library — no network calls. `UaidNetworkClient.submit()` throws early rather than dropping data into a silent no-op. Reads (`get`, `getReceipt`) are unauthenticated per the spec.
88
+
89
+ ## Interoperability
90
+
91
+ - **AP2 (Google + 60 partners).** UAID Exchange embeds inside an AP2 A2A task under extension key `uuaid.exchange.v1`; conversely, the AP2 Payment Mandate id can be referenced from `external_refs.ap2_payment_mandate`.
92
+ - **W3C VC-Data-Model 2.0.** Every artifact this package produces is a conformant VC.
93
+ - **eIDAS QES.** At L5, `external_refs` also carries the QTSP-produced PKCS#7/CAdES-T reference.
94
+
95
+ ## Development
96
+
97
+ ```bash
98
+ npm install
99
+ npm run build
100
+ npm test
101
+ ```
102
+
103
+ ## License
104
+
105
+ MIT. Part of the [esig-suite](https://github.com/vmvtech/esig-suite) family.
@@ -0,0 +1,227 @@
1
+ /**
2
+ * @e-sig/uaid-exch — reference implementation of UAP-EXCH-1 v0.1
3
+ * (UUAID Exchange Profile).
4
+ *
5
+ * MIT-licensed. Ships alongside @e-sig/core and @e-sig/uuaid; consumes
6
+ * @uuaid/sdk for identifier resolution and Network submission.
7
+ *
8
+ * See docs/profiles/UAP-EXCH-1/v0.1.md in the uuaid repo for the normative
9
+ * profile. This module implements the § 5 (Signing Credential), § 6 (Exchange),
10
+ * and § 7 (Receipt) shapes plus the § 8 submission API.
11
+ */
12
+ export type AssuranceLevel = "L0" | "L1" | "L2" | "L3" | "L4" | "L5";
13
+ export interface UaidSigningCredential {
14
+ "@context": string[];
15
+ type: ["VerifiableCredential", "UaidSigningCredential"];
16
+ id: string;
17
+ issuer: string;
18
+ validFrom: string;
19
+ validUntil: string;
20
+ credentialSubject: {
21
+ id: string;
22
+ principal: string;
23
+ scope: {
24
+ actions: string[];
25
+ resource_pattern?: string;
26
+ counterparty_allowlist?: string[];
27
+ value_ceiling?: {
28
+ currency: string;
29
+ amount: number;
30
+ };
31
+ geographies?: string[];
32
+ assurance_min?: AssuranceLevel;
33
+ };
34
+ authenticator: {
35
+ type: "platform" | "hardware" | "hsm" | "qscd";
36
+ attestation?: string;
37
+ public_key_jwk: JsonWebKey;
38
+ };
39
+ assurance_level: AssuranceLevel;
40
+ assurance_evidence?: Array<{
41
+ provider: string;
42
+ evidence_uri: string;
43
+ hash: string;
44
+ }>;
45
+ kya_hash: string;
46
+ };
47
+ proof: DataIntegrityProof;
48
+ }
49
+ export interface UaidExchange {
50
+ "@context": string[];
51
+ type: ["VerifiableCredential", "UaidExchange"];
52
+ id: string;
53
+ issuer: string;
54
+ validFrom: string;
55
+ credentialSubject: {
56
+ authorization: {
57
+ signing_credential: string;
58
+ principal: string;
59
+ };
60
+ exchange: {
61
+ action: string;
62
+ counterparty: string;
63
+ resource: {
64
+ type: string;
65
+ sha256: string;
66
+ size: number;
67
+ uri?: string;
68
+ };
69
+ purpose: string;
70
+ value_impact?: Record<string, unknown>;
71
+ external_refs?: {
72
+ ap2_payment_mandate?: string;
73
+ esign_envelope?: string;
74
+ };
75
+ };
76
+ sole_control: {
77
+ challenge_type: string;
78
+ challenge_at: string;
79
+ challenge_evidence_hash: string;
80
+ };
81
+ policy_evaluation?: {
82
+ provider: string;
83
+ verdict: "PASS" | "FAIL" | "WARN" | "EXCEPTION_APPROVED";
84
+ bundle: string;
85
+ evidence_uri?: string;
86
+ evidence_hash?: string;
87
+ };
88
+ };
89
+ proof: DataIntegrityProof[];
90
+ }
91
+ export interface UaidExchangeReceipt {
92
+ "@context": string[];
93
+ type: ["VerifiableCredential", "UaidExchangeReceipt"];
94
+ id: string;
95
+ issuer: string;
96
+ validFrom: string;
97
+ credentialSubject: {
98
+ exchange: string;
99
+ verified_proofs: string[];
100
+ policy_evaluation_verified: boolean;
101
+ anchor: {
102
+ chain: string;
103
+ contract: string;
104
+ batch_root: string;
105
+ batch_index: number;
106
+ batch_position: number;
107
+ block_number: number;
108
+ anchored_at: string;
109
+ };
110
+ tx_short_id: string;
111
+ };
112
+ proof: DataIntegrityProof;
113
+ }
114
+ export interface DataIntegrityProof {
115
+ type: "DataIntegrityProof";
116
+ cryptosuite: "eddsa-jcs-2022";
117
+ created: string;
118
+ verificationMethod: string;
119
+ proofPurpose: "authentication" | "assertionMethod";
120
+ proofValue: string;
121
+ }
122
+ export interface AgentSigner {
123
+ agentUuaid: string;
124
+ verificationMethod: string;
125
+ sign(canonicalBytes: Uint8Array): Promise<string>;
126
+ }
127
+ export interface IssuerSigner {
128
+ issuerDid: string;
129
+ verificationMethod: string;
130
+ sign(canonicalBytes: Uint8Array): Promise<string>;
131
+ }
132
+ export interface CreateExchangeInput {
133
+ signingCredentialId: string;
134
+ principal: string;
135
+ action: string;
136
+ counterparty: string;
137
+ resource: {
138
+ type: string;
139
+ sha256: string;
140
+ size: number;
141
+ uri?: string;
142
+ };
143
+ purpose: string;
144
+ value_impact?: Record<string, unknown>;
145
+ external_refs?: UaidExchange["credentialSubject"]["exchange"]["external_refs"];
146
+ soleControl: {
147
+ challenge_type: string;
148
+ challenge_at: string;
149
+ challenge_evidence_hash: string;
150
+ };
151
+ policyEvaluation?: UaidExchange["credentialSubject"]["policy_evaluation"];
152
+ now?: () => Date;
153
+ idFactory?: () => string;
154
+ }
155
+ export interface UaidNetworkClientOptions {
156
+ baseUrl?: string;
157
+ apiKey?: string;
158
+ fetchImpl?: typeof fetch;
159
+ }
160
+ /**
161
+ * Build the unsigned Exchange body, canonicalize it (JCS per RFC 8785),
162
+ * sign it once with the Agent key and once with the Issuer key, and return
163
+ * the assembled UaidExchange ready to submit.
164
+ */
165
+ export declare function createExchange(input: CreateExchangeInput, agent: AgentSigner, issuer: IssuerSigner): Promise<UaidExchange>;
166
+ /**
167
+ * Wrap an existing esig-suite envelope as a UAID Exchange. Convenience helper
168
+ * for the common case where you're signing a PDF via @e-sig/core.signDocument().
169
+ */
170
+ export declare function exchangeInputFromEsigEnvelope(args: {
171
+ envelopeId: string;
172
+ signingCredentialId: string;
173
+ principal: string;
174
+ counterparty: string;
175
+ pdfSha256: string;
176
+ pdfSize: number;
177
+ pdfUri?: string;
178
+ purpose: string;
179
+ value_impact?: Record<string, unknown>;
180
+ soleControl: CreateExchangeInput["soleControl"];
181
+ policyEvaluation?: CreateExchangeInput["policyEvaluation"];
182
+ }): CreateExchangeInput;
183
+ export declare class UaidNetworkClient {
184
+ private readonly baseUrl;
185
+ private readonly apiKey?;
186
+ private readonly fetchImpl;
187
+ constructor(opts?: UaidNetworkClientOptions);
188
+ /** POST /v1/exchanges — submit a signed Exchange for verification + anchoring. */
189
+ submit(exchange: UaidExchange): Promise<{
190
+ exchange_id: string;
191
+ status: "verified" | "queued";
192
+ receipt_pending_anchor: boolean;
193
+ estimated_anchor_at?: string;
194
+ }>;
195
+ /** GET /v1/exchanges/:id — unauthenticated. Returns { exchange, receipt? }. */
196
+ get(exchangeId: string): Promise<{
197
+ exchange: UaidExchange;
198
+ receipt?: UaidExchangeReceipt;
199
+ }>;
200
+ /** GET /v1/exchanges/:id/receipt — unauthenticated. */
201
+ getReceipt(exchangeId: string): Promise<UaidExchangeReceipt>;
202
+ /** Convenience: the public browser URL for a receipt's tx_short_id. */
203
+ txBrowserUrl(txShortId: string): string;
204
+ /** Convenience: the resolver URL for a full exchange id. */
205
+ resolverUrl(exchangeId: string): string;
206
+ }
207
+ /**
208
+ * RFC 8785 JSON Canonicalization Scheme.
209
+ *
210
+ * Rules implemented:
211
+ * - Object keys sorted lexicographically by UTF-16 code units.
212
+ * - No insignificant whitespace.
213
+ * - Strings encoded with the minimal escape set.
214
+ * - Numbers serialized per ECMA-262 7.1.12.1 (JS default `String(number)` is
215
+ * compliant for the finite-number subset we accept here).
216
+ *
217
+ * We reject NaN, ±Infinity, and non-integer numeric keys per RFC 8785 § 3.2.
218
+ */
219
+ export declare function jcs(value: unknown): string;
220
+ /** Convenience: canonicalize + UTF-8 encode. */
221
+ export declare function jcsBytes(value: unknown): Uint8Array;
222
+ /**
223
+ * Generate a UUIDv7 (unix-time-ordered). Matches the format UUAID uses under
224
+ * the hood; safe as an identifier suffix.
225
+ */
226
+ export declare function uuidv7(): string;
227
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAErE,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,IAAI,EAAE,CAAC,sBAAsB,EAAE,uBAAuB,CAAC,CAAC;IACxD,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE;QACjB,EAAE,EAAE,MAAM,CAAC;QACX,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE;YACL,OAAO,EAAE,MAAM,EAAE,CAAC;YAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;YAC1B,sBAAsB,CAAC,EAAE,MAAM,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U,GAAG,QAAQ,CAAC;QAC9B,sBAAsB,EAAE,OAAO,CAAC;QAChC,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B,CAAC;IAyBF,+EAA+E;IACzE,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;QACrC,QAAQ,EAAE,YAAY,CAAC;QACvB,OAAO,CAAC,EAAE,mBAAmB,CAAC;KAC/B,CAAC;IAaF,uDAAuD;IACjD,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAUlE,uEAAuE;IACvE,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAIvC,4DAA4D;IAC5D,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;CAGxC;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,GAAG,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAE1C;AAED,gDAAgD;AAChD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAEnD;AA+DD;;;GAGG;AACH,wBAAgB,MAAM,IAAI,MAAM,CAsB/B"}
package/dist/index.js ADDED
@@ -0,0 +1,273 @@
1
+ /**
2
+ * @e-sig/uaid-exch — reference implementation of UAP-EXCH-1 v0.1
3
+ * (UUAID Exchange Profile).
4
+ *
5
+ * MIT-licensed. Ships alongside @e-sig/core and @e-sig/uuaid; consumes
6
+ * @uuaid/sdk for identifier resolution and Network submission.
7
+ *
8
+ * See docs/profiles/UAP-EXCH-1/v0.1.md in the uuaid repo for the normative
9
+ * profile. This module implements the § 5 (Signing Credential), § 6 (Exchange),
10
+ * and § 7 (Receipt) shapes plus the § 8 submission API.
11
+ */
12
+ // ============================================================================
13
+ // Exchange creation
14
+ // ============================================================================
15
+ const CONTEXT = [
16
+ "https://www.w3.org/ns/credentials/v2",
17
+ "https://uuaid.org/spec/UAP-EXCH-1/v1",
18
+ ];
19
+ /**
20
+ * Build the unsigned Exchange body, canonicalize it (JCS per RFC 8785),
21
+ * sign it once with the Agent key and once with the Issuer key, and return
22
+ * the assembled UaidExchange ready to submit.
23
+ */
24
+ export async function createExchange(input, agent, issuer) {
25
+ const now = (input.now ?? (() => new Date()))();
26
+ const id = `uuaid:foundation:exchange:${(input.idFactory ?? uuidv7)()}`;
27
+ const body = {
28
+ "@context": CONTEXT,
29
+ type: ["VerifiableCredential", "UaidExchange"],
30
+ id,
31
+ issuer: agent.agentUuaid,
32
+ validFrom: now.toISOString(),
33
+ credentialSubject: {
34
+ authorization: {
35
+ signing_credential: input.signingCredentialId,
36
+ principal: input.principal,
37
+ },
38
+ exchange: {
39
+ action: input.action,
40
+ counterparty: input.counterparty,
41
+ resource: input.resource,
42
+ purpose: input.purpose,
43
+ value_impact: input.value_impact ?? {},
44
+ external_refs: input.external_refs ?? {},
45
+ },
46
+ sole_control: input.soleControl,
47
+ policy_evaluation: input.policyEvaluation,
48
+ },
49
+ };
50
+ const canonicalBytes = jcsBytes(body);
51
+ const [agentProofValue, issuerProofValue] = await Promise.all([
52
+ agent.sign(canonicalBytes),
53
+ issuer.sign(canonicalBytes),
54
+ ]);
55
+ const agentProof = {
56
+ type: "DataIntegrityProof",
57
+ cryptosuite: "eddsa-jcs-2022",
58
+ created: now.toISOString(),
59
+ verificationMethod: agent.verificationMethod,
60
+ proofPurpose: "authentication",
61
+ proofValue: agentProofValue,
62
+ };
63
+ const issuerProof = {
64
+ type: "DataIntegrityProof",
65
+ cryptosuite: "eddsa-jcs-2022",
66
+ created: now.toISOString(),
67
+ verificationMethod: issuer.verificationMethod,
68
+ proofPurpose: "assertionMethod",
69
+ proofValue: issuerProofValue,
70
+ };
71
+ return { ...body, proof: [agentProof, issuerProof] };
72
+ }
73
+ /**
74
+ * Wrap an existing esig-suite envelope as a UAID Exchange. Convenience helper
75
+ * for the common case where you're signing a PDF via @e-sig/core.signDocument().
76
+ */
77
+ export function exchangeInputFromEsigEnvelope(args) {
78
+ return {
79
+ signingCredentialId: args.signingCredentialId,
80
+ principal: args.principal,
81
+ action: "sign.contract",
82
+ counterparty: args.counterparty,
83
+ resource: {
84
+ type: "application/pdf",
85
+ sha256: args.pdfSha256,
86
+ size: args.pdfSize,
87
+ uri: args.pdfUri,
88
+ },
89
+ purpose: args.purpose,
90
+ value_impact: args.value_impact,
91
+ external_refs: { esign_envelope: `esig:envelope:${args.envelopeId}` },
92
+ soleControl: args.soleControl,
93
+ policyEvaluation: args.policyEvaluation,
94
+ };
95
+ }
96
+ // ============================================================================
97
+ // Network client
98
+ // ============================================================================
99
+ export class UaidNetworkClient {
100
+ baseUrl;
101
+ apiKey;
102
+ fetchImpl;
103
+ constructor(opts = {}) {
104
+ this.baseUrl = (opts.baseUrl ?? "https://api.uuaid.org").replace(/\/$/, "");
105
+ this.apiKey = opts.apiKey;
106
+ this.fetchImpl = opts.fetchImpl ?? fetch;
107
+ }
108
+ /** POST /v1/exchanges — submit a signed Exchange for verification + anchoring. */
109
+ async submit(exchange) {
110
+ if (!this.apiKey) {
111
+ throw new Error("UaidNetworkClient.submit requires a partner apiKey (UUAID_API_KEY).");
112
+ }
113
+ const res = await this.fetchImpl(`${this.baseUrl}/v1/exchanges`, {
114
+ method: "POST",
115
+ headers: {
116
+ "content-type": "application/json",
117
+ authorization: `Bearer ${this.apiKey}`,
118
+ },
119
+ body: JSON.stringify(exchange),
120
+ });
121
+ if (res.status !== 201) {
122
+ throw new Error(`submit failed: HTTP ${res.status}: ${await res.text()}`);
123
+ }
124
+ return res.json();
125
+ }
126
+ /** GET /v1/exchanges/:id — unauthenticated. Returns { exchange, receipt? }. */
127
+ async get(exchangeId) {
128
+ const res = await this.fetchImpl(`${this.baseUrl}/v1/exchanges/${encodeURIComponent(exchangeId)}`);
129
+ if (!res.ok) {
130
+ throw new Error(`get failed: HTTP ${res.status}`);
131
+ }
132
+ return res.json();
133
+ }
134
+ /** GET /v1/exchanges/:id/receipt — unauthenticated. */
135
+ async getReceipt(exchangeId) {
136
+ const res = await this.fetchImpl(`${this.baseUrl}/v1/exchanges/${encodeURIComponent(exchangeId)}/receipt`);
137
+ if (!res.ok) {
138
+ throw new Error(`getReceipt failed: HTTP ${res.status}`);
139
+ }
140
+ return res.json();
141
+ }
142
+ /** Convenience: the public browser URL for a receipt's tx_short_id. */
143
+ txBrowserUrl(txShortId) {
144
+ return `https://tx.uuaid.org/${encodeURIComponent(txShortId)}`;
145
+ }
146
+ /** Convenience: the resolver URL for a full exchange id. */
147
+ resolverUrl(exchangeId) {
148
+ return `https://registry.uuaid.org/exchange/${encodeURIComponent(exchangeId)}`;
149
+ }
150
+ }
151
+ // ============================================================================
152
+ // JCS canonicalization (RFC 8785) — minimal, dependency-free
153
+ // ============================================================================
154
+ /**
155
+ * RFC 8785 JSON Canonicalization Scheme.
156
+ *
157
+ * Rules implemented:
158
+ * - Object keys sorted lexicographically by UTF-16 code units.
159
+ * - No insignificant whitespace.
160
+ * - Strings encoded with the minimal escape set.
161
+ * - Numbers serialized per ECMA-262 7.1.12.1 (JS default `String(number)` is
162
+ * compliant for the finite-number subset we accept here).
163
+ *
164
+ * We reject NaN, ±Infinity, and non-integer numeric keys per RFC 8785 § 3.2.
165
+ */
166
+ export function jcs(value) {
167
+ return jcsSerialize(value);
168
+ }
169
+ /** Convenience: canonicalize + UTF-8 encode. */
170
+ export function jcsBytes(value) {
171
+ return new TextEncoder().encode(jcs(value));
172
+ }
173
+ function jcsSerialize(v) {
174
+ if (v === null)
175
+ return "null";
176
+ if (typeof v === "boolean")
177
+ return v ? "true" : "false";
178
+ if (typeof v === "number") {
179
+ if (!Number.isFinite(v)) {
180
+ throw new Error("JCS: non-finite numbers are not permitted");
181
+ }
182
+ return jcsNumber(v);
183
+ }
184
+ if (typeof v === "string")
185
+ return jcsString(v);
186
+ if (Array.isArray(v)) {
187
+ return "[" + v.map(jcsSerialize).join(",") + "]";
188
+ }
189
+ if (typeof v === "object") {
190
+ const keys = Object.keys(v)
191
+ .filter((k) => v[k] !== undefined)
192
+ .sort(); // lexicographic on UTF-16 code units is the default
193
+ return ("{" +
194
+ keys
195
+ .map((k) => jcsString(k) +
196
+ ":" +
197
+ jcsSerialize(v[k]))
198
+ .join(",") +
199
+ "}");
200
+ }
201
+ throw new Error(`JCS: unsupported value type: ${typeof v}`);
202
+ }
203
+ function jcsString(s) {
204
+ let out = '"';
205
+ for (let i = 0; i < s.length; i++) {
206
+ const c = s.charCodeAt(i);
207
+ if (c === 0x22)
208
+ out += '\\"';
209
+ else if (c === 0x5c)
210
+ out += "\\\\";
211
+ else if (c === 0x08)
212
+ out += "\\b";
213
+ else if (c === 0x0c)
214
+ out += "\\f";
215
+ else if (c === 0x0a)
216
+ out += "\\n";
217
+ else if (c === 0x0d)
218
+ out += "\\r";
219
+ else if (c === 0x09)
220
+ out += "\\t";
221
+ else if (c < 0x20)
222
+ out += "\\u" + c.toString(16).padStart(4, "0");
223
+ else
224
+ out += s[i];
225
+ }
226
+ return out + '"';
227
+ }
228
+ function jcsNumber(n) {
229
+ if (n === 0)
230
+ return "0";
231
+ // JavaScript's default number stringification matches ECMA-262 7.1.12.1,
232
+ // which JCS references. This is correct for finite numbers.
233
+ return String(n);
234
+ }
235
+ // ============================================================================
236
+ // UUIDv7 — small, dependency-free
237
+ // ============================================================================
238
+ /**
239
+ * Generate a UUIDv7 (unix-time-ordered). Matches the format UUAID uses under
240
+ * the hood; safe as an identifier suffix.
241
+ */
242
+ export function uuidv7() {
243
+ const ms = BigInt(Date.now());
244
+ const rand = new Uint8Array(10);
245
+ cryptoRandomFill(rand);
246
+ const bytes = new Uint8Array(16);
247
+ bytes[0] = Number((ms >> 40n) & 0xffn);
248
+ bytes[1] = Number((ms >> 32n) & 0xffn);
249
+ bytes[2] = Number((ms >> 24n) & 0xffn);
250
+ bytes[3] = Number((ms >> 16n) & 0xffn);
251
+ bytes[4] = Number((ms >> 8n) & 0xffn);
252
+ bytes[5] = Number(ms & 0xffn);
253
+ bytes[6] = 0x70 | (rand[0] & 0x0f); // version 7
254
+ bytes[7] = rand[1];
255
+ bytes[8] = 0x80 | (rand[2] & 0x3f); // variant 10
256
+ bytes.set(rand.slice(3), 9);
257
+ const hex = Array.from(bytes)
258
+ .map((b) => b.toString(16).padStart(2, "0"))
259
+ .join("");
260
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
261
+ }
262
+ function cryptoRandomFill(out) {
263
+ const g = globalThis.crypto;
264
+ if (g?.getRandomValues) {
265
+ g.getRandomValues(out);
266
+ return;
267
+ }
268
+ // Fallback — Node 20 always exposes globalThis.crypto, so this branch
269
+ // should never run in production. Kept for defensive symmetry.
270
+ for (let i = 0; i < out.length; i++)
271
+ out[i] = Math.floor(Math.random() * 256);
272
+ }
273
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAgKH,+EAA+E;AAC/E,oBAAoB;AACpB,+EAA+E;AAE/E,MAAM,OAAO,GAAG;IACd,sCAAsC;IACtC,sCAAsC;CACvC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,KAA0B,EAC1B,KAAkB,EAClB,MAAoB;IAEpB,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;IAChD,MAAM,EAAE,GAAG,6BAA6B,CAAC,KAAK,CAAC,SAAS,IAAI,MAAM,CAAC,EAAE,EAAE,CAAC;IAExE,MAAM,IAAI,GAAgC;QACxC,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE,CAAC,sBAAsB,EAAE,cAAc,CAAC;QAC9C,EAAE;QACF,MAAM,EAAE,KAAK,CAAC,UAAU;QACxB,SAAS,EAAE,GAAG,CAAC,WAAW,EAAE;QAC5B,iBAAiB,EAAE;YACjB,aAAa,EA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,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE;QAAE,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC;AAChF,CAAC"}
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@e-sig/uaid-exch",
3
+ "version": "0.1.0-preview.0",
4
+ "description": "Preview implementation of the IAASO Exchange Profile (ADR-006, under review). Wraps @e-sig/core envelopes as per-transaction signed authorizations on the UUAID Network with subject + issuer proofs and Polygon-anchored batch receipts. Wire format will be finalized when ADR-006 is Accepted.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js",
14
+ "default": "./dist/index.js"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist/",
19
+ "README.md",
20
+ "LICENSE"
21
+ ],
22
+ "scripts": {
23
+ "build": "tsc -p tsconfig.build.json",
24
+ "clean": "rm -rf dist",
25
+ "prepublishOnly": "npm run clean && npm run build",
26
+ "pretest": "npm run build",
27
+ "test": "vitest run",
28
+ "test:watch": "vitest"
29
+ },
30
+ "engines": {
31
+ "node": ">=20"
32
+ },
33
+ "keywords": [
34
+ "uuaid",
35
+ "uap-exch-1",
36
+ "verifiable-credentials",
37
+ "agent-signing",
38
+ "ai-agent",
39
+ "exchange",
40
+ "network",
41
+ "polygon",
42
+ "pdf",
43
+ "esignature",
44
+ "self-contained"
45
+ ],
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "https://github.com/vmvtech/esig-suite.git",
49
+ "directory": "packages/esig-uaid-exch"
50
+ },
51
+ "homepage": "https://github.com/vmvtech/esig-suite/tree/main/packages/esig-uaid-exch#readme",
52
+ "dependencies": {
53
+ "@uuaid/sdk": "^0.1.0"
54
+ },
55
+ "peerDependencies": {
56
+ "@e-sig/core": "^0.5.0"
57
+ },
58
+ "devDependencies": {
59
+ "@e-sig/core": "^0.5.0",
60
+ "@types/node": "^22.0.0",
61
+ "typescript": "^5.4.0",
62
+ "vitest": "^2.1.9"
63
+ },
64
+ "publishConfig": {
65
+ "registry": "https://registry.npmjs.org",
66
+ "access": "public"
67
+ }
68
+ }