@zkp2p/zkp2p-attestation 3.1.0 → 4.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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.0.0-rc.0
4
+
5
+ - Add X Money seller credential uploads and receipt-gated `register_xmoney` seller identity types. Mailbox credentials support Google OAuth, Microsoft OAuth, and iCloud Mail; standalone X Money identity requests remain unavailable.
6
+
7
+ - BREAKING: Monobank buyer TEE now uses entrepreneur business portal `gatewayState`/`browserId` credentials and `CLIENT_ID`/`TRANSACTION_ID` params. Retire the buyer Open API token shape; enforce settled UAH transfers and a service-owned 14-day timestamp buffer.
8
+
9
+ - Add typed X Money Buyer TEE requests with encrypted captured `url` and headers, and no public params. Replay the captured GraphQL operation ID and derive the transaction ID from the URL instead of accepting duplicate input.
10
+
11
+ - BREAKING: remove the retired HDFC Gmail buyer proof types and action. Amazon
12
+ Pay is the supported UPI buyer and seller verification path.
13
+
3
14
  ## 3.1.0
4
15
 
5
16
  - Remove the retired preproduction hostname and PCR8 from bundled trust pins.
package/README.md CHANGED
@@ -86,15 +86,17 @@ const encryptedUpload = await nitro.createEncryptedSellerCredentialUpload({
86
86
  });
87
87
  ```
88
88
 
89
+ Venmo Gmail OAuth uploads use the same encryption helper with numeric Venmo account id as `payeeId` and `sessionMaterial: { credentialSource: "google_oauth", authorizationCode, redirectUri, oauthClient? }`. The service binds a DKIM-verified receipt recipient to that account through Venmo's public profile API. The optional partner app secret and refresh token remain inside the encrypted seller bundle. Existing Venmo session-cookie uploads remain an independently supported credential type.
90
+
89
91
  PayPal Gmail OAuth seller uploads use the same app-selection model. Pass the seller PayPal email as `payeeId` and use `sessionMaterial: { credentialSource: "google_oauth", authorizationCode, redirectUri }`; the service validates Gmail access against paypal.com DKIM-signed payment receipts. To onboard through a partner-owned Google OAuth app, include `oauthClient: { clientId, clientSecret }` inside the encrypted `sessionMaterial`. The PayPal partner client secret is handled as seller credential material: it rides only in the compact JWE upload plaintext, is sealed with the Gmail refresh token in the KMS-envelope seller credential bundle, and is reused only to refresh that seller's Gmail access token.
90
92
 
91
93
  Buyer TEE requests use the same attested upload key and compact JWE envelope. The typed helper encrypts the captured
92
94
  session material, posts `{ encryptedSessionMaterial, params, chainId, intent }` to
93
95
  `POST /buyer/verify/:platform/:actionType`, unwraps the service envelope, and returns a typed `AttestationOutput`.
94
- The service does not enforce capture-age or one-use replay limits for buyer TEE session material; verification depends
95
- on the upstream session still being active. A leaked encrypted JWE is therefore valid for the upstream session
96
- lifetime — treat any accidental disclosure as equivalent to leaking the underlying upstream credential (cookies, PAT,
97
- etc.) and rotate the upstream session.
96
+ The service does not enforce capture-age or one-use replay limits for reusable
97
+ buyer TEE session material; verification depends on the upstream session still
98
+ being active. Treat any accidental JWE disclosure as equivalent to leaking its
99
+ underlying private evidence.
98
100
 
99
101
  ```ts
100
102
  const attestation = await nitro.verifyBuyerTeePayment({
@@ -153,11 +155,41 @@ Buyer TEE platform matrix:
153
155
  | `zelle` | `transfer_zelle_chase` | `Cookie`, `x-jpmc-channel`, `x-jpmc-csrf-token`, `Referer`, `Origin` | `index` |
154
156
  | `zelle` | `transfer_zelle_citi` | `Cookie` | `index` |
155
157
  | `paypal` | `transfer_paypal` | `Cookie` | `PAYMENT_ID` |
158
+ | `monobank` | `transfer_monobank` | `gatewayState`, `browserId` | `CLIENT_ID`, `TRANSACTION_ID` |
156
159
  | `alipay` | `transfer_alipay` | `Cookie` | `TRADE_NO` |
160
+ | `upi` | `transfer_upi_amazonpay` | `Cookie`, `User-Agent`, `body` | `TRANSACTION_URL` |
161
+ | `xmoney` | `transfer_xmoney` | `url`, `Cookie` and other captured session headers | `{}` |
162
+
163
+ Monobank buyer verification uses the entrepreneur business portal session. Capture
164
+ `localStorage.gateway` as `gatewayState`, and encode the raw P-256 public key from
165
+ `localStorage.browserId.publicKey` as unpadded base64url `browserId`. Encrypt both
166
+ inside the normal buyer JWE. `CLIENT_ID` selects the business profile and
167
+ `TRANSACTION_ID` selects its payment detail. The attestor constructs and encrypts
168
+ the bank request itself; caller-supplied payment JSON or encrypted request bodies
169
+ are rejected. It accepts settled outgoing UAH transfers (bank currency code 980),
170
+ hashes the recipient IBAN and bank payment ID, and signs a service-owned 14-day
171
+ buffer. The previous buyer Open API token shape is no longer accepted.
172
+
173
+ X Money replays the captured `url`, including X's current GraphQL operation ID,
174
+ just as Chime replays its captured `body`. Both stay inside encrypted session
175
+ material. The attestor owns endpoint and operation validation; X Money remains
176
+ GET-only on `https://x.com`, derives the transaction ID from the captured URL,
177
+ and requires the response ID to match. Ship the X Money extension capture and attestor changes
178
+ together; captures without `url` are rejected. Chime's contract is unchanged.
157
179
 
158
180
  Zelle buyer verification uses only `platform: "zelle"` with bank-specific action types. Every Zelle action attests
159
181
  `intent.paymentMethod = hashUtf8("zelle")`; direct bank-specific platforms are unsupported.
160
182
 
183
+ Amazon Pay uses `platform: "upi"` and `actionType: "transfer_upi_amazonpay"`.
184
+ Capture the `getTransactionHistory` GraphQL request after signing into Amazon
185
+ Pay and applying a transaction-history filter. Send its headers and exact request
186
+ body as encrypted session material, with only the selected history row's
187
+ `transactionDetailPageURL` as `params.TRANSACTION_URL`. The service rebuilds the
188
+ history query, confirms the selected outgoing payment, and fetches its receipt;
189
+ receipt URL labels alone do not establish payment direction. Both UPI actions use
190
+ the same `upi:<UPI reference>` payment-id preimage. Amazon session cookies remain
191
+ subject to server-side expiry or revocation; the package does not refresh them.
192
+
161
193
  Per-platform session-material types require these headers using the canonical names shown above while still allowing
162
194
  additional captured headers. Captured request bodies are session material because they can contain sensitive data and
163
195
  are encrypted before being sent to the service.
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var ue=Object.defineProperty;var At=Object.getOwnPropertyDescriptor;var Tt=Object.getOwnPropertyNames;var St=Object.prototype.hasOwnProperty;var Et=(e,t)=>{for(var r in t)ue(e,r,{get:t[r],enumerable:!0})},gt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Tt(t))!St.call(e,o)&&o!==r&&ue(e,o,{get:()=>t[o],enumerable:!(n=At(t,o))||n.enumerable});return e};var It=e=>gt(ue({},"__esModule",{value:!0}),e);var Ir={};Et(Ir,{AWS_NITRO_ROOT_FINGERPRINT_SHA256_HEX:()=>W,AWS_NITRO_ROOT_PEM:()=>J,NitroAttestationError:()=>R,createEncryptedBuyerTeeSessionMaterial:()=>M,createEncryptedDisputeSessionMaterial:()=>v,createEncryptedIdentitySessionMaterial:()=>H,createEncryptedSellerCredentialUpload:()=>F,createNitroAttestationClient:()=>rt,encryptBuyerTeeSessionMaterial:()=>w,encryptDisputeSessionMaterial:()=>V,encryptIdentitySessionMaterial:()=>B,encryptSellerCredentialUpload:()=>L,fetchAndVerifyAttestation:()=>K,getDisputeVerifierDomainSeparator:()=>ie,getUnifiedPaymentVerifierDomainSeparator:()=>ne,hashUtf8:()=>y,requestIdentityAttestation:()=>Z,uploadSellerCredential:()=>ee,verifyBuyerTeePayment:()=>te,verifyBuyerTeePaymentAttestation:()=>dt,verifyDispute:()=>re,verifyDisputeAttestation:()=>pt,verifyIdentityAttestation:()=>ft,verifySellerCredentialBundle:()=>yt});module.exports=It(Ir);var R=class extends Error{code;cause;details;constructor(t,r,n={}){super(r),this.name="NitroAttestationError",this.code=t,this.cause=n.cause,this.details=n.details}};function s(e,t,r){throw new R(e,t,r)}async function S(e,t,r){try{return await e}catch(n){s(t,r,{cause:n})}}function j(e){return e!==void 0?(typeof e!="function"&&s("CRYPTO_UNAVAILABLE","fetch is unavailable; pass a fetch implementation"),e):(typeof globalThis.fetch!="function"&&s("CRYPTO_UNAVAILABLE","fetch is unavailable; pass a fetch implementation"),globalThis.fetch.bind(globalThis))}function Pt(e){let t=e??globalThis.crypto?.subtle;return t||s("CRYPTO_UNAVAILABLE","SubtleCrypto is unavailable; pass params.subtle"),t}function ht(e){if(e)return e;let t=globalThis.crypto;return typeof t?.getRandomValues!="function"&&s("CRYPTO_UNAVAILABLE","crypto.getRandomValues is unavailable; pass params.getRandomValues"),r=>t.getRandomValues(r)}function T(e){return{subtle:Pt(e.subtle),getRandomValues:ht(e.getRandomValues)}}function Pe(e,t){return typeof t!="function"&&s("CRYPTO_UNAVAILABLE","crypto.getRandomValues is unavailable; pass params.getRandomValues"),{subtle:e,getRandomValues:t,randomUUID:()=>xt(t)}}function xt(e){let t=e(new Uint8Array(16));t[6]=t[6]&15|64,t[8]=t[8]&63|128;let r=Array.from(t,n=>n.toString(16).padStart(2,"0"));return`${r.slice(0,4).join("")}-${r.slice(4,6).join("")}-${r.slice(6,8).join("")}-${r.slice(8,10).join("")}-${r.slice(10).join("")}`}var G="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",z=Ct(G);function Ct(e){let t={};for(let r=0;r<e.length;r+=1)t[e[r]]=r;return t}function E(e){let t="";for(let r of e)t+=r.toString(16).padStart(2,"0");return t}function P(e){if(typeof TextEncoder<"u")return new TextEncoder().encode(e);let t=[];for(let r=0;r<e.length;r+=1){let n=e.codePointAt(r);n>65535&&(r+=1),n<=127?t.push(n):n<=2047?t.push(192|n>>6,128|n&63):n<=65535?t.push(224|n>>12,128|n>>6&63,128|n&63):t.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|n&63)}return new Uint8Array(t)}function U(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let r=0;r<e.length;r+=1){let n=e[r];n<128?t+=String.fromCodePoint(n):(n&224)===192?t+=String.fromCodePoint((n&31)<<6|e[++r]&63):(n&240)===224?t+=String.fromCodePoint((n&15)<<12|(e[++r]&63)<<6|e[++r]&63):t+=String.fromCodePoint((n&7)<<18|(e[++r]&63)<<12|(e[++r]&63)<<6|e[++r]&63)}return t}function bt(e){let t="";for(let r=0;r<e.length;r+=3){let n=e[r],o=e[r+1]??0,a=e[r+2]??0,i=n<<16|o<<8|a;t+=G[i>>18&63],t+=G[i>>12&63],t+=r+1<e.length?G[i>>6&63]:"=",t+=r+2<e.length?G[i&63]:"="}return t}function he(e){return Dt(e,!1)}function O(e){return bt(e).replaceAll("+","-").replaceAll("/","_").replace(/=+$/,"")}function Dt(e,t){let r=e.replace(/\s+/g,""),n=t?r.replaceAll("-","+").replaceAll("_","/"):r;if(n.length%4===1)throw new Error("Invalid base64 length");let o=n+"=".repeat((4-n.length%4)%4),a=[];for(let i=0;i<o.length;i+=4){let u=o.slice(i,i+4),l=u.endsWith("==")?2:u.endsWith("=")?1:0,c=X(u[0],z),f=X(u[1],z),A=u[2]==="="?0:X(u[2],z),ce=u[3]==="="?0:X(u[3],z),_=c<<18|f<<12|A<<6|ce;a.push(_>>16&255),l<2&&a.push(_>>8&255),l<1&&a.push(_&255)}return new Uint8Array(a)}function X(e,t){let r=t[e];if(r===void 0)throw new Error(`Invalid base64 character: ${e}`);return r}function h(e){let t=e.reduce((o,a)=>o+a.length,0),r=new Uint8Array(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}function g(e){return new Uint8Array(e).buffer}function xe(e){let t={sessionMaterial:e.sessionMaterial,...e.callerAddress!==void 0?{callerAddress:e.callerAddress}:{},boundPubKeySha256:e.key.publicKeySha256Hex,issuedAtMs:e.issuedAtMs,jweId:e.jweId};return e.platform==="wise"||e.platform==="monobank"?t:{payeeId:e.payeeId,...t}}function Ce(e){return{platform:e.platform,actionType:e.actionType,sessionMaterial:e.sessionMaterial,boundPubKeySha256:e.key.publicKeySha256Hex}}function be(e){return JSON.stringify(e)}var Rt={alg:"RSA-OAEP-256",enc:"A256GCM"},Nt=/^[A-Za-z0-9_-]{16,128}$/;async function De(e){let t=e.request.issuedAtMs??e.now(),r=e.request.jweId??Ut(e.getRandomValues);return _t(r),Ue({key:e.request.key,plaintext:xe({...e.request,issuedAtMs:t,jweId:r}),subtle:e.subtle,getRandomValues:e.getRandomValues,failureContext:"seller credential upload"})}async function Re(e){return de({...e,failureContext:"buyer TEE session material"})}async function Ne(e){return de({...e,failureContext:"identity session material"})}async function _e(e){return de({...e,failureContext:"dispute session material"})}async function de(e){return Ue({key:e.request.key,plaintext:Ce(e.request),subtle:e.subtle,getRandomValues:e.getRandomValues,failureContext:e.failureContext})}async function Ue(e){let t=P(be(e.plaintext)),r=e.getRandomValues(new Uint8Array(32)),n=await S(e.subtle.importKey("spki",g(e.key.publicKeyDer),{name:"RSA-OAEP",hash:"SHA-256"},!1,["encrypt"]),"CRYPTO_UNAVAILABLE","Failed to import attested enclave-upload RSA public key"),o=new Uint8Array(await S(e.subtle.encrypt({name:"RSA-OAEP"},n,g(r)),"CRYPTO_UNAVAILABLE","Failed to RSA-OAEP encrypt the content encryption key")),a=e.getRandomValues(new Uint8Array(12)),i=O(P(JSON.stringify(Rt))),u=P(i),l=await S(e.subtle.importKey("raw",g(r),{name:"AES-GCM",length:256},!1,["encrypt"]),"CRYPTO_UNAVAILABLE","Failed to import generated AES-GCM content encryption key"),c=new Uint8Array(await S(e.subtle.encrypt({name:"AES-GCM",iv:g(a),additionalData:g(u),tagLength:128},l,g(t)),"CRYPTO_UNAVAILABLE",`Failed to AES-GCM encrypt ${e.failureContext}`)),f=c.slice(0,c.length-16),A=c.slice(c.length-16);return[i,O(o),O(a),O(f),O(A)].join(".")}function _t(e){Nt.test(e)||s("INVALID_PARAMETER","jweId must be 16-128 URL-safe characters")}function Ut(e){let t=e(new Uint8Array(16));t[6]=t[6]&15|64,t[8]=t[8]&63|128;let r=Array.from(t,n=>n.toString(16).padStart(2,"0"));return`${r.slice(0,4).join("")}-${r.slice(4,6).join("")}-${r.slice(6,8).join("")}-${r.slice(8,10).join("")}-${r.slice(10).join("")}`}async function w(e){let t=T(e);return Re({request:e,subtle:t.subtle,getRandomValues:t.getRandomValues})}var Oe=require("@peculiar/x509");var J=`-----BEGIN CERTIFICATE-----
1
+ "use strict";var ue=Object.defineProperty;var At=Object.getOwnPropertyDescriptor;var Tt=Object.getOwnPropertyNames;var St=Object.prototype.hasOwnProperty;var Et=(e,t)=>{for(var r in t)ue(e,r,{get:t[r],enumerable:!0})},gt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Tt(t))!St.call(e,o)&&o!==r&&ue(e,o,{get:()=>t[o],enumerable:!(n=At(t,o))||n.enumerable});return e};var It=e=>gt(ue({},"__esModule",{value:!0}),e);var Ir={};Et(Ir,{AWS_NITRO_ROOT_FINGERPRINT_SHA256_HEX:()=>W,AWS_NITRO_ROOT_PEM:()=>J,NitroAttestationError:()=>R,createEncryptedBuyerTeeSessionMaterial:()=>M,createEncryptedDisputeSessionMaterial:()=>v,createEncryptedIdentitySessionMaterial:()=>H,createEncryptedSellerCredentialUpload:()=>F,createNitroAttestationClient:()=>rt,encryptBuyerTeeSessionMaterial:()=>w,encryptDisputeSessionMaterial:()=>V,encryptIdentitySessionMaterial:()=>B,encryptSellerCredentialUpload:()=>L,fetchAndVerifyAttestation:()=>K,getDisputeVerifierDomainSeparator:()=>ie,getUnifiedPaymentVerifierDomainSeparator:()=>ne,hashUtf8:()=>y,requestIdentityAttestation:()=>Z,uploadSellerCredential:()=>ee,verifyBuyerTeePayment:()=>te,verifyBuyerTeePaymentAttestation:()=>dt,verifyDispute:()=>re,verifyDisputeAttestation:()=>pt,verifyIdentityAttestation:()=>ft,verifySellerCredentialBundle:()=>yt});module.exports=It(Ir);var R=class extends Error{code;cause;details;constructor(t,r,n={}){super(r),this.name="NitroAttestationError",this.code=t,this.cause=n.cause,this.details=n.details}};function s(e,t,r){throw new R(e,t,r)}async function S(e,t,r){try{return await e}catch(n){s(t,r,{cause:n})}}function j(e){return e!==void 0?(typeof e!="function"&&s("CRYPTO_UNAVAILABLE","fetch is unavailable; pass a fetch implementation"),e):(typeof globalThis.fetch!="function"&&s("CRYPTO_UNAVAILABLE","fetch is unavailable; pass a fetch implementation"),globalThis.fetch.bind(globalThis))}function Pt(e){let t=e??globalThis.crypto?.subtle;return t||s("CRYPTO_UNAVAILABLE","SubtleCrypto is unavailable; pass params.subtle"),t}function ht(e){if(e)return e;let t=globalThis.crypto;return typeof t?.getRandomValues!="function"&&s("CRYPTO_UNAVAILABLE","crypto.getRandomValues is unavailable; pass params.getRandomValues"),r=>t.getRandomValues(r)}function T(e){return{subtle:Pt(e.subtle),getRandomValues:ht(e.getRandomValues)}}function Pe(e,t){return typeof t!="function"&&s("CRYPTO_UNAVAILABLE","crypto.getRandomValues is unavailable; pass params.getRandomValues"),{subtle:e,getRandomValues:t,randomUUID:()=>xt(t)}}function xt(e){let t=e(new Uint8Array(16));t[6]=t[6]&15|64,t[8]=t[8]&63|128;let r=Array.from(t,n=>n.toString(16).padStart(2,"0"));return`${r.slice(0,4).join("")}-${r.slice(4,6).join("")}-${r.slice(6,8).join("")}-${r.slice(8,10).join("")}-${r.slice(10).join("")}`}var G="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",z=Ct(G);function Ct(e){let t={};for(let r=0;r<e.length;r+=1)t[e[r]]=r;return t}function E(e){let t="";for(let r of e)t+=r.toString(16).padStart(2,"0");return t}function P(e){if(typeof TextEncoder<"u")return new TextEncoder().encode(e);let t=[];for(let r=0;r<e.length;r+=1){let n=e.codePointAt(r);n>65535&&(r+=1),n<=127?t.push(n):n<=2047?t.push(192|n>>6,128|n&63):n<=65535?t.push(224|n>>12,128|n>>6&63,128|n&63):t.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|n&63)}return new Uint8Array(t)}function U(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let r=0;r<e.length;r+=1){let n=e[r];n<128?t+=String.fromCodePoint(n):(n&224)===192?t+=String.fromCodePoint((n&31)<<6|e[++r]&63):(n&240)===224?t+=String.fromCodePoint((n&15)<<12|(e[++r]&63)<<6|e[++r]&63):t+=String.fromCodePoint((n&7)<<18|(e[++r]&63)<<12|(e[++r]&63)<<6|e[++r]&63)}return t}function bt(e){let t="";for(let r=0;r<e.length;r+=3){let n=e[r],o=e[r+1]??0,a=e[r+2]??0,i=n<<16|o<<8|a;t+=G[i>>18&63],t+=G[i>>12&63],t+=r+1<e.length?G[i>>6&63]:"=",t+=r+2<e.length?G[i&63]:"="}return t}function he(e){return Dt(e,!1)}function O(e){return bt(e).replaceAll("+","-").replaceAll("/","_").replace(/=+$/,"")}function Dt(e,t){let r=e.replace(/\s+/g,""),n=t?r.replaceAll("-","+").replaceAll("_","/"):r;if(n.length%4===1)throw new Error("Invalid base64 length");let o=n+"=".repeat((4-n.length%4)%4),a=[];for(let i=0;i<o.length;i+=4){let u=o.slice(i,i+4),l=u.endsWith("==")?2:u.endsWith("=")?1:0,c=X(u[0],z),f=X(u[1],z),A=u[2]==="="?0:X(u[2],z),ce=u[3]==="="?0:X(u[3],z),_=c<<18|f<<12|A<<6|ce;a.push(_>>16&255),l<2&&a.push(_>>8&255),l<1&&a.push(_&255)}return new Uint8Array(a)}function X(e,t){let r=t[e];if(r===void 0)throw new Error(`Invalid base64 character: ${e}`);return r}function h(e){let t=e.reduce((o,a)=>o+a.length,0),r=new Uint8Array(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}function g(e){return new Uint8Array(e).buffer}function xe(e){let t={sessionMaterial:e.sessionMaterial,...e.callerAddress!==void 0?{callerAddress:e.callerAddress}:{},boundPubKeySha256:e.key.publicKeySha256Hex,issuedAtMs:e.issuedAtMs,jweId:e.jweId};return e.platform==="wise"||e.platform==="monobank"||e.platform==="upi"?t:{payeeId:e.payeeId,...t}}function Ce(e){return{platform:e.platform,actionType:e.actionType,sessionMaterial:e.sessionMaterial,boundPubKeySha256:e.key.publicKeySha256Hex}}function be(e){return JSON.stringify(e)}var Rt={alg:"RSA-OAEP-256",enc:"A256GCM"},Nt=/^[A-Za-z0-9_-]{16,128}$/;async function De(e){let t=e.request.issuedAtMs??e.now(),r=e.request.jweId??Ut(e.getRandomValues);return _t(r),Ue({key:e.request.key,plaintext:xe({...e.request,issuedAtMs:t,jweId:r}),subtle:e.subtle,getRandomValues:e.getRandomValues,failureContext:"seller credential upload"})}async function Re(e){return de({...e,failureContext:"buyer TEE session material"})}async function Ne(e){return de({...e,failureContext:"identity session material"})}async function _e(e){return de({...e,failureContext:"dispute session material"})}async function de(e){return Ue({key:e.request.key,plaintext:Ce(e.request),subtle:e.subtle,getRandomValues:e.getRandomValues,failureContext:e.failureContext})}async function Ue(e){let t=P(be(e.plaintext)),r=e.getRandomValues(new Uint8Array(32)),n=await S(e.subtle.importKey("spki",g(e.key.publicKeyDer),{name:"RSA-OAEP",hash:"SHA-256"},!1,["encrypt"]),"CRYPTO_UNAVAILABLE","Failed to import attested enclave-upload RSA public key"),o=new Uint8Array(await S(e.subtle.encrypt({name:"RSA-OAEP"},n,g(r)),"CRYPTO_UNAVAILABLE","Failed to RSA-OAEP encrypt the content encryption key")),a=e.getRandomValues(new Uint8Array(12)),i=O(P(JSON.stringify(Rt))),u=P(i),l=await S(e.subtle.importKey("raw",g(r),{name:"AES-GCM",length:256},!1,["encrypt"]),"CRYPTO_UNAVAILABLE","Failed to import generated AES-GCM content encryption key"),c=new Uint8Array(await S(e.subtle.encrypt({name:"AES-GCM",iv:g(a),additionalData:g(u),tagLength:128},l,g(t)),"CRYPTO_UNAVAILABLE",`Failed to AES-GCM encrypt ${e.failureContext}`)),f=c.slice(0,c.length-16),A=c.slice(c.length-16);return[i,O(o),O(a),O(f),O(A)].join(".")}function _t(e){Nt.test(e)||s("INVALID_PARAMETER","jweId must be 16-128 URL-safe characters")}function Ut(e){let t=e(new Uint8Array(16));t[6]=t[6]&15|64,t[8]=t[8]&63|128;let r=Array.from(t,n=>n.toString(16).padStart(2,"0"));return`${r.slice(0,4).join("")}-${r.slice(4,6).join("")}-${r.slice(6,8).join("")}-${r.slice(8,10).join("")}-${r.slice(10).join("")}`}async function w(e){let t=T(e);return Re({request:e,subtle:t.subtle,getRandomValues:t.getRandomValues})}var Oe=require("@peculiar/x509");var J=`-----BEGIN CERTIFICATE-----
2
2
  MIICETCCAZagAwIBAgIRAPkxdWgbkK/hHUbMtOTn+FYwCgYIKoZIzj0EAwMwSTEL
3
3
  MAkGA1UEBhMCVVMxDzANBgNVBAoMBkFtYXpvbjEMMAoGA1UECwwDQVdTMRswGQYD
4
4
  VQQDDBJhd3Mubml0cm8tZW5jbGF2ZXMwHhcNMTkxMDI4MTMyODA1WhcNNDkxMDI4