@zkp2p/zkp2p-attestation 1.0.0-rc.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/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0-rc.0
4
+
5
+ - Rename `@zkp2p/verify-nitro-attestation` to `@zkp2p/zkp2p-attestation`.
6
+ - Add browser/RN/Node WebCrypto verifier entrypoints.
7
+ - Add seller credential upload compact JWE encryption.
8
+ - Add environment-initialized client for staging and production/preprod deployments.
9
+ - Rewrite the verifier CLI on top of the library.
10
+ - Replace the deleted `verify.mjs` script with the `zkp2p-attestation-verify` package binary and `yarn verify` wrapper.
11
+ - Migration: consumers should install/import `@zkp2p/zkp2p-attestation`; any direct references to `package/verify-nitro-attestation/verify.mjs` should move to the package CLI or public library entrypoints.
package/README.md ADDED
@@ -0,0 +1,114 @@
1
+ # @zkp2p/zkp2p-attestation
2
+
3
+ Client-side verifier and encryptor for ZKP2P Nitro seller credential uploads.
4
+
5
+ The package runs in Chrome MV3 service workers, browser DOM contexts, React Native with a Web Crypto polyfill, and Node >= 20. Library entrypoints use `fetch`, `SubtleCrypto`, `crypto.getRandomValues`, and `Uint8Array`; they do not import `node:*` modules or use `Buffer`.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ yarn add @zkp2p/zkp2p-attestation
11
+ ```
12
+
13
+ During monorepo development, point clients at `attestation-service/package/zkp2p-attestation`.
14
+
15
+ ## Environment Init
16
+
17
+ Use the client factory when the host owns an environment variable:
18
+
19
+ ```ts
20
+ import { createNitroAttestationClient } from "@zkp2p/zkp2p-attestation";
21
+
22
+ const nitro = createNitroAttestationClient({
23
+ environment: process.env.ZKP2P_ATTESTATION_ENV === "production" ? "production" : "staging",
24
+ });
25
+ ```
26
+
27
+ Environment defaults:
28
+
29
+ | Environment | Service URL | PCR8 source |
30
+ |---|---|---|
31
+ | `staging` | `https://attestation-service-staging.zkp2p.xyz` | bundled staging pin |
32
+ | `production` | `https://attestation-service-preprod.zkp2p.xyz` | bundled production/preprod pin |
33
+
34
+ Callers can still pass `attestationServiceUrl` and `trust.expectedPcr8Hex` directly. Explicit trust pins always win.
35
+
36
+ ## Fast Path
37
+
38
+ ```ts
39
+ const encryptedUpload = await nitro.createEncryptedSellerCredentialUpload({
40
+ payeeId: "1130030979",
41
+ sessionMaterial: {
42
+ apiToken: "<wise-api-token>",
43
+ profileId: "41246868",
44
+ balanceId: "61249083",
45
+ currency: "EUR",
46
+ },
47
+ });
48
+
49
+ await fetch(`${attestationServiceUrl}/seller/credentials/wise`, {
50
+ method: "POST",
51
+ headers: { "content-type": "application/json" },
52
+ body: JSON.stringify({ encryptedUpload }),
53
+ });
54
+ ```
55
+
56
+ This fetches `GET /attestation?nonce=...`, verifies the Nitro document to the pinned AWS root and PCR8, extracts the attested seller-upload RSA SPKI, and returns a compact JWE for `POST /seller/credentials/:platform`.
57
+
58
+ ## Cache-Friendly Path
59
+
60
+ ```ts
61
+ const verified = await nitro.fetchAndVerifyAttestation();
62
+
63
+ const encryptedUpload = await nitro.encryptSellerCredentialUpload({
64
+ key: verified.attestedSellerUploadKey,
65
+ payeeId: "1130030979",
66
+ sessionMaterial: {},
67
+ });
68
+ ```
69
+
70
+ The attested SPKI is stable within one enclave process. If the enclave restarts, cached keys become stale and upload decrypt will fail; fetch a fresh attestation for a new session.
71
+
72
+ ## React Native Wiring
73
+
74
+ React Native must provide Web Crypto-compatible primitives when they are not on `globalThis.crypto`:
75
+
76
+ ```ts
77
+ const nitro = createNitroAttestationClient({
78
+ environment: "staging",
79
+ subtle: webCrypto.subtle,
80
+ getRandomValues: (out) => webCrypto.getRandomValues(out),
81
+ fetch,
82
+ });
83
+ ```
84
+
85
+ Any conforming `SubtleCrypto` works. The package does not require `Buffer`.
86
+
87
+ ## Direct Entrypoints
88
+
89
+ ```ts
90
+ import {
91
+ createEncryptedSellerCredentialUpload,
92
+ encryptSellerCredentialUpload,
93
+ fetchAndVerifyAttestation,
94
+ } from "@zkp2p/zkp2p-attestation";
95
+ ```
96
+
97
+ Direct functions accept `attestationServiceUrl`, `trust`, `fetch`, `subtle`, `getRandomValues`, `now`, `onWarning`, and `timeoutMs` overrides. If no caller or bundled PCR8 pin exists and `trust.strictPin !== true`, the verifier falls back to the service-advertised PCR8 and emits `TRUST_PIN_NOT_PROVIDED`; production callers should pin.
98
+
99
+ ## PCR8 Rotation Runbook
100
+
101
+ 1. Update `src/trust/pins.ts` from the deployment `STATE.md` published by the attestation-service team.
102
+ 2. Refresh `tests/golden/staging-2026-05-05.raw.json` and expected metadata if staging rotates.
103
+ 3. Run `yarn test:coverage` and `STAGING_E2E=true yarn test:integration`.
104
+ 4. Release a patch version for PCR8-only rotations. Use a major version for wire-format or algorithm changes.
105
+
106
+ ## CLI
107
+
108
+ The existing verifier is preserved on top of the library:
109
+
110
+ ```bash
111
+ yarn verify --service https://attestation-service-staging.zkp2p.xyz
112
+ ```
113
+
114
+ Optional EIP-712 signer cross-check remains available through `--verify-signature`.