@reclaimprotocol/client 0.1.29 → 0.1.32

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.
Files changed (110) hide show
  1. package/README.md +255 -234
  2. package/lib/api.d.ts +2 -0
  3. package/lib/api.js +2 -0
  4. package/lib/client.js +2 -0
  5. package/lib/enckeys.d.ts +1 -1
  6. package/lib/enckeys.js +2 -2
  7. package/lib/encoding.d.ts +4 -0
  8. package/lib/encoding.js +10 -0
  9. package/lib/feature-flags.d.ts +9 -0
  10. package/lib/feature-flags.js +19 -0
  11. package/lib/index.d.ts +4 -4
  12. package/lib/index.js +4 -4
  13. package/lib/jwks.d.ts +8 -8
  14. package/lib/jwks.js +38 -17
  15. package/lib/launch/destination.d.ts +14 -0
  16. package/lib/launch/destination.js +89 -0
  17. package/lib/launch/device.d.ts +30 -0
  18. package/lib/launch/device.js +168 -0
  19. package/lib/launch/environment.d.ts +224 -0
  20. package/lib/launch/environment.js +98 -0
  21. package/lib/launch/errors.d.ts +20 -0
  22. package/lib/launch/errors.js +25 -0
  23. package/lib/launch/extension.d.ts +42 -0
  24. package/lib/launch/extension.js +72 -0
  25. package/lib/launch/flow.d.ts +82 -0
  26. package/lib/launch/flow.js +222 -0
  27. package/lib/launch/index.d.ts +16 -0
  28. package/lib/launch/index.js +12 -0
  29. package/lib/launch/mobile.d.ts +77 -0
  30. package/lib/launch/mobile.js +124 -0
  31. package/lib/launch/modal.d.ts +50 -0
  32. package/lib/launch/modal.js +258 -0
  33. package/lib/launch/options.d.ts +74 -0
  34. package/lib/launch/options.js +20 -0
  35. package/lib/launch/portal.d.ts +28 -0
  36. package/lib/launch/portal.js +68 -0
  37. package/lib/launch/qr.d.ts +5 -0
  38. package/lib/launch/qr.js +28 -0
  39. package/lib/launch/target.d.ts +46 -0
  40. package/lib/launch/target.js +128 -0
  41. package/lib/launch/vendor/qrcodegen.d.ts +134 -0
  42. package/lib/launch/vendor/qrcodegen.js +822 -0
  43. package/lib/legacy-proof.d.ts +2 -0
  44. package/lib/legacy-proof.js +37 -7
  45. package/lib/proof-hash.d.ts +5 -5
  46. package/lib/proof-hash.js +1 -1
  47. package/lib/proof-recipe.d.ts +3 -3
  48. package/lib/proof-recipe.js +1 -1
  49. package/lib/proof-types.d.ts +35 -8
  50. package/lib/reclaim.d.ts +81 -70
  51. package/lib/reclaim.js +79 -130
  52. package/lib/request-proof.d.ts +60 -0
  53. package/lib/request-proof.js +241 -0
  54. package/lib/result.d.ts +46 -38
  55. package/lib/result.js +160 -100
  56. package/lib/routes.gen.d.ts +76 -28
  57. package/lib/routes.gen.js +24 -11
  58. package/lib/tee-binding.d.ts +1 -1
  59. package/lib/types/openapi.d.ts +1 -0
  60. package/lib/types/openapi.gen.d.ts +1598 -485
  61. package/lib/types/openapi.gen.js +5 -0
  62. package/lib/verification-clients.d.ts +28 -14
  63. package/lib/verification-clients.js +31 -11
  64. package/lib/verify-attestor-tee.d.ts +19 -2
  65. package/lib/verify-attestor-tee.js +40 -4
  66. package/lib/verify-tee.d.ts +10 -1
  67. package/lib/verify-tee.js +34 -10
  68. package/package.json +5 -1
  69. package/src/api.ts +9 -0
  70. package/src/client.ts +2 -0
  71. package/src/enckeys.ts +2 -2
  72. package/src/encoding.ts +12 -0
  73. package/src/feature-flags.ts +39 -0
  74. package/src/index.ts +13 -14
  75. package/src/jwks.ts +52 -30
  76. package/src/launch/destination.ts +111 -0
  77. package/src/launch/device.ts +242 -0
  78. package/src/launch/environment.ts +337 -0
  79. package/src/launch/errors.ts +49 -0
  80. package/src/launch/extension.ts +124 -0
  81. package/src/launch/flow.ts +369 -0
  82. package/src/launch/index.ts +42 -0
  83. package/src/launch/mobile.ts +184 -0
  84. package/src/launch/modal.ts +378 -0
  85. package/src/launch/options.ts +99 -0
  86. package/src/launch/portal.ts +104 -0
  87. package/src/launch/qr.ts +37 -0
  88. package/src/launch/target.ts +150 -0
  89. package/src/launch/vendor/qrcodegen.ts +1034 -0
  90. package/src/proof-hash.ts +6 -6
  91. package/src/proof-recipe.ts +3 -3
  92. package/src/proof-types.ts +36 -8
  93. package/src/reclaim.ts +185 -218
  94. package/src/{legacy-proof.ts → request-proof.ts} +81 -36
  95. package/src/result.ts +238 -172
  96. package/src/routes.gen.ts +24 -11
  97. package/src/tee-binding.ts +1 -1
  98. package/src/types/openapi.gen.ts +1603 -485
  99. package/src/types/openapi.ts +3 -1
  100. package/src/verification-clients.ts +33 -19
  101. package/src/verify-attestor-tee.ts +66 -8
  102. package/src/verify-tee.ts +44 -13
  103. package/lib/api-client.d.ts +0 -31
  104. package/lib/api-client.js +0 -112
  105. package/lib/api-consts.d.ts +0 -4
  106. package/lib/api-consts.js +0 -4
  107. package/lib/api-errors.d.ts +0 -13
  108. package/lib/api-errors.js +0 -30
  109. package/lib/eip712.d.ts +0 -20
  110. package/lib/eip712.js +0 -108
package/src/proof-hash.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { keccak_256 } from '@noble/hashes/sha3.js'
2
2
  import { canonicalJson as canonical } from './canonical.ts'
3
3
  import { bytesToHex } from './encoding.ts'
4
- import type { HashRequirement, LegacyProof } from './proof-types.ts'
4
+ import type { HashRequirement, ReclaimRequestProof } from './proof-types.ts'
5
5
 
6
6
  export interface HttpProofParams {
7
7
  url: string
@@ -30,7 +30,7 @@ export interface ProofRequestSpec extends HttpProofParams {
30
30
  templateParamsMode?: 'separate' | 'merge'
31
31
  }
32
32
 
33
- /** Exact legacy canonical HTTP-provider hashes, including optional matches. */
33
+ /** Exact canonical HTTP-provider hashes, including optional matches. */
34
34
  export function hashProofClaimParams(params: HttpProofParams): string[] {
35
35
  return canonicalProofParams(params).map((serialized) => (
36
36
  '0x' + bytesToHex(keccak_256(new TextEncoder().encode(serialized)))
@@ -38,7 +38,7 @@ export function hashProofClaimParams(params: HttpProofParams): string[] {
38
38
  }
39
39
 
40
40
  export function getHashFromProof(
41
- proof: LegacyProof,
41
+ proof: ReclaimRequestProof,
42
42
  hasNoPii = false,
43
43
  ): string[] {
44
44
  if(hasNoPii) {
@@ -74,7 +74,7 @@ export function hashRequestSpec(request: ProofRequestSpec): HashRequirement {
74
74
  export function hashRequirementsFromSpecs(
75
75
  requestData: ProofRequestSpec[],
76
76
  allowedInjectedRequestData: ProofRequestSpec[],
77
- proofs: LegacyProof[],
77
+ proofs: ReclaimRequestProof[],
78
78
  ): HashRequirement[] {
79
79
  const templates = expandTemplates(
80
80
  allowedInjectedRequestData,
@@ -84,7 +84,7 @@ export function hashRequirementsFromSpecs(
84
84
  }
85
85
 
86
86
  export function assertValidProofHashes(
87
- proofs: LegacyProof[],
87
+ proofs: ReclaimRequestProof[],
88
88
  requirements: Array<string | HashRequirement>,
89
89
  hasNoPii = false,
90
90
  ) {
@@ -251,7 +251,7 @@ function substitute(
251
251
  }
252
252
  }
253
253
 
254
- function templateParametersFromProofs(proofs: LegacyProof[]) {
254
+ function templateParametersFromProofs(proofs: ReclaimRequestProof[]) {
255
255
  const combined: Record<string, unknown> = {}
256
256
  for(const proof of proofs) {
257
257
  for(const raw of [proof.claimData.parameters, proof.claimData.context]) {
@@ -3,7 +3,7 @@ import {
3
3
  hashRequirementsFromSpecs,
4
4
  type ProofRequestSpec,
5
5
  } from './proof-hash.ts'
6
- import type { LegacyProof } from './proof-types.ts'
6
+ import type { ReclaimRequestProof } from './proof-types.ts'
7
7
 
8
8
  type RequestSelection = components['schemas']['RequestSelection']
9
9
  type RequestSelectionTemplate =
@@ -19,12 +19,12 @@ export interface BuilderProofRecipe {
19
19
  }
20
20
 
21
21
  /**
22
- * Derive the exact hash requirements consumed by legacy `verifyProof` from a
22
+ * Derive the exact hash requirements consumed by `verifyRequestProof` from a
23
23
  * resolved Builder recipe. Builder's fixed requests are required once each.
24
24
  */
25
25
  export function proofHashesFromBuilderRecipe(
26
26
  recipe: BuilderProofRecipe,
27
- proofs: LegacyProof[],
27
+ proofs: ReclaimRequestProof[],
28
28
  ) {
29
29
  return hashRequirementsFromSpecs(
30
30
  recipe.requests.map((request) => toRequestSpec(
@@ -1,16 +1,20 @@
1
- /** Exact legacy proof structures carried inside Builder result envelopes. */
2
- export interface LegacyProof {
1
+ /** Exact proof structure for one verified request, carried inside Builder
2
+ * result envelopes. Every Verification Client — the in-app SDK, the browser
3
+ * extension, portals, and Builder's own client — emits this shape. */
4
+ export interface ReclaimRequestProof {
3
5
  identifier: string
4
- claimData: LegacyClaimData
6
+ claimData: RequestClaimData
5
7
  signatures: string[]
6
- witnesses: LegacyWitness[]
8
+ witnesses: RequestWitness[]
7
9
  extractedParameterValues: unknown
8
10
  publicData?: unknown
9
11
  taskId?: number
10
- teeAttestation?: TeeAttestation | string
12
+ /** Client-specific legacy TEE data. Verification validates a supported
13
+ * representation only when TEE verification is requested. */
14
+ teeAttestation?: unknown
11
15
  }
12
16
 
13
- export interface LegacyClaimData {
17
+ export interface RequestClaimData {
14
18
  provider: string
15
19
  parameters: string
16
20
  owner: string
@@ -20,16 +24,40 @@ export interface LegacyClaimData {
20
24
  epoch: number
21
25
  }
22
26
 
23
- export interface LegacyWitness {
27
+ export interface RequestWitness {
24
28
  id: string
25
29
  url: string
26
30
  claimAttestation?: AttestorClaimAttestation
27
31
  }
28
32
 
33
+ /**
34
+ * Which kind of attestation a witness carries.
35
+ *
36
+ * `embedded-attestor` — the in-app SDK and the browser extension. The attestor
37
+ * signs the claim and, on a TEE run, may also return its own
38
+ * `attestation_report`.
39
+ *
40
+ * `confidential-space` — portals. The browser runtime signs the claim inside a
41
+ * GCP Confidential Space and returns `tee_attestation`, bound to the claim
42
+ * through `context.attestationNonce`.
43
+ */
44
+ export type ClaimAttestationType = 'embedded-attestor' | 'confidential-space'
45
+
29
46
  export interface AttestorClaimAttestation {
47
+ type: ClaimAttestationType
30
48
  attestor_address: string
31
49
  claim_signature: string
32
- attestation_report: string
50
+ /** `embedded-attestor` only, and optional even then: the attestor's own GCP
51
+ * Confidential Space attestation (an RS256 JWT). Attestors in production
52
+ * sign claims without returning one, so a witness routinely carries only
53
+ * the address and the claim signature. */
54
+ attestation_report?: string
55
+ /** `confidential-space` only: the same payload legacy proofs carry in the
56
+ * proof's top-level `teeAttestation`, and typed the same way. It comes
57
+ * from an external producer and is preserved verbatim, so callers validate
58
+ * it at runtime — `verifyTeeAttestation` does — rather than trusting a
59
+ * shape the wire does not guarantee. */
60
+ tee_attestation?: unknown
33
61
  }
34
62
 
35
63
  export interface TeeAttestation {