@metamask-previews/kyc-controller 0.0.0-preview-823dcff → 0.0.0-preview-e57e5c3dc

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 (155) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +10 -2
  3. package/dist/KycController-method-action-types.cjs +7 -0
  4. package/dist/KycController-method-action-types.cjs.map +1 -0
  5. package/dist/KycController-method-action-types.d.cts +168 -0
  6. package/dist/KycController-method-action-types.d.cts.map +1 -0
  7. package/dist/KycController-method-action-types.d.mts +168 -0
  8. package/dist/KycController-method-action-types.d.mts.map +1 -0
  9. package/dist/KycController-method-action-types.mjs +6 -0
  10. package/dist/KycController-method-action-types.mjs.map +1 -0
  11. package/dist/KycController.cjs +1085 -0
  12. package/dist/KycController.cjs.map +1 -0
  13. package/dist/KycController.d.cts +255 -0
  14. package/dist/KycController.d.cts.map +1 -0
  15. package/dist/KycController.d.mts +255 -0
  16. package/dist/KycController.d.mts.map +1 -0
  17. package/dist/KycController.mjs +1080 -0
  18. package/dist/KycController.mjs.map +1 -0
  19. package/dist/KycService-method-action-types.cjs +7 -0
  20. package/dist/KycService-method-action-types.cjs.map +1 -0
  21. package/dist/KycService-method-action-types.d.cts +121 -0
  22. package/dist/KycService-method-action-types.d.cts.map +1 -0
  23. package/dist/KycService-method-action-types.d.mts +121 -0
  24. package/dist/KycService-method-action-types.d.mts.map +1 -0
  25. package/dist/KycService-method-action-types.mjs +6 -0
  26. package/dist/KycService-method-action-types.mjs.map +1 -0
  27. package/dist/KycService.cjs +417 -0
  28. package/dist/KycService.cjs.map +1 -0
  29. package/dist/KycService.d.cts +307 -0
  30. package/dist/KycService.d.cts.map +1 -0
  31. package/dist/KycService.d.mts +307 -0
  32. package/dist/KycService.d.mts.map +1 -0
  33. package/dist/KycService.mjs +413 -0
  34. package/dist/KycService.mjs.map +1 -0
  35. package/dist/countryCodes.cjs +274 -0
  36. package/dist/countryCodes.cjs.map +1 -0
  37. package/dist/countryCodes.d.cts +18 -0
  38. package/dist/countryCodes.d.cts.map +1 -0
  39. package/dist/countryCodes.d.mts +18 -0
  40. package/dist/countryCodes.d.mts.map +1 -0
  41. package/dist/countryCodes.mjs +270 -0
  42. package/dist/countryCodes.mjs.map +1 -0
  43. package/dist/crypto.cjs +154 -0
  44. package/dist/crypto.cjs.map +1 -0
  45. package/dist/crypto.d.cts +84 -0
  46. package/dist/crypto.d.cts.map +1 -0
  47. package/dist/crypto.d.mts +84 -0
  48. package/dist/crypto.d.mts.map +1 -0
  49. package/dist/crypto.mjs +149 -0
  50. package/dist/crypto.mjs.map +1 -0
  51. package/dist/encoding.cjs +40 -0
  52. package/dist/encoding.cjs.map +1 -0
  53. package/dist/encoding.d.cts +24 -0
  54. package/dist/encoding.d.cts.map +1 -0
  55. package/dist/encoding.d.mts +24 -0
  56. package/dist/encoding.d.mts.map +1 -0
  57. package/dist/encoding.mjs +35 -0
  58. package/dist/encoding.mjs.map +1 -0
  59. package/dist/index.cjs +34 -10
  60. package/dist/index.cjs.map +1 -1
  61. package/dist/index.d.cts +18 -7
  62. package/dist/index.d.cts.map +1 -1
  63. package/dist/index.d.mts +18 -7
  64. package/dist/index.d.mts.map +1 -1
  65. package/dist/index.mjs +11 -9
  66. package/dist/index.mjs.map +1 -1
  67. package/dist/selectors.cjs +30 -0
  68. package/dist/selectors.cjs.map +1 -0
  69. package/dist/selectors.d.cts +24 -0
  70. package/dist/selectors.d.cts.map +1 -0
  71. package/dist/selectors.d.mts +24 -0
  72. package/dist/selectors.d.mts.map +1 -0
  73. package/dist/selectors.mjs +24 -0
  74. package/dist/selectors.mjs.map +1 -0
  75. package/dist/types.cjs +10 -0
  76. package/dist/types.cjs.map +1 -0
  77. package/dist/types.d.cts +124 -0
  78. package/dist/types.d.cts.map +1 -0
  79. package/dist/types.d.mts +124 -0
  80. package/dist/types.d.mts.map +1 -0
  81. package/dist/types.mjs +9 -0
  82. package/dist/types.mjs.map +1 -0
  83. package/dist/ukyc/constants.cjs +75 -0
  84. package/dist/ukyc/constants.cjs.map +1 -0
  85. package/dist/ukyc/constants.d.cts +69 -0
  86. package/dist/ukyc/constants.d.cts.map +1 -0
  87. package/dist/ukyc/constants.d.mts +69 -0
  88. package/dist/ukyc/constants.d.mts.map +1 -0
  89. package/dist/ukyc/constants.mjs +72 -0
  90. package/dist/ukyc/constants.mjs.map +1 -0
  91. package/dist/ukyc/deriveClientMaterial.cjs +65 -0
  92. package/dist/ukyc/deriveClientMaterial.cjs.map +1 -0
  93. package/dist/ukyc/deriveClientMaterial.d.cts +54 -0
  94. package/dist/ukyc/deriveClientMaterial.d.cts.map +1 -0
  95. package/dist/ukyc/deriveClientMaterial.d.mts +54 -0
  96. package/dist/ukyc/deriveClientMaterial.d.mts.map +1 -0
  97. package/dist/ukyc/deriveClientMaterial.mjs +60 -0
  98. package/dist/ukyc/deriveClientMaterial.mjs.map +1 -0
  99. package/dist/ukyc/jwtChain.cjs +54 -0
  100. package/dist/ukyc/jwtChain.cjs.map +1 -0
  101. package/dist/ukyc/jwtChain.d.cts +40 -0
  102. package/dist/ukyc/jwtChain.d.cts.map +1 -0
  103. package/dist/ukyc/jwtChain.d.mts +40 -0
  104. package/dist/ukyc/jwtChain.d.mts.map +1 -0
  105. package/dist/ukyc/jwtChain.mjs +50 -0
  106. package/dist/ukyc/jwtChain.mjs.map +1 -0
  107. package/dist/ukyc/localUserSecret.cjs +98 -0
  108. package/dist/ukyc/localUserSecret.cjs.map +1 -0
  109. package/dist/ukyc/localUserSecret.d.cts +65 -0
  110. package/dist/ukyc/localUserSecret.d.cts.map +1 -0
  111. package/dist/ukyc/localUserSecret.d.mts +65 -0
  112. package/dist/ukyc/localUserSecret.d.mts.map +1 -0
  113. package/dist/ukyc/localUserSecret.mjs +92 -0
  114. package/dist/ukyc/localUserSecret.mjs.map +1 -0
  115. package/dist/ukyc/storageAccessToken.cjs +139 -0
  116. package/dist/ukyc/storageAccessToken.cjs.map +1 -0
  117. package/dist/ukyc/storageAccessToken.d.cts +99 -0
  118. package/dist/ukyc/storageAccessToken.d.cts.map +1 -0
  119. package/dist/ukyc/storageAccessToken.d.mts +99 -0
  120. package/dist/ukyc/storageAccessToken.d.mts.map +1 -0
  121. package/dist/ukyc/storageAccessToken.mjs +133 -0
  122. package/dist/ukyc/storageAccessToken.mjs.map +1 -0
  123. package/dist/ukyc/testToken.cjs +61 -0
  124. package/dist/ukyc/testToken.cjs.map +1 -0
  125. package/dist/ukyc/testToken.d.cts +50 -0
  126. package/dist/ukyc/testToken.d.cts.map +1 -0
  127. package/dist/ukyc/testToken.d.mts +50 -0
  128. package/dist/ukyc/testToken.d.mts.map +1 -0
  129. package/dist/ukyc/testToken.mjs +57 -0
  130. package/dist/ukyc/testToken.mjs.map +1 -0
  131. package/dist/ukyc/wrapEncryptionKey.cjs +28 -0
  132. package/dist/ukyc/wrapEncryptionKey.cjs.map +1 -0
  133. package/dist/ukyc/wrapEncryptionKey.d.cts +34 -0
  134. package/dist/ukyc/wrapEncryptionKey.d.cts.map +1 -0
  135. package/dist/ukyc/wrapEncryptionKey.d.mts +34 -0
  136. package/dist/ukyc/wrapEncryptionKey.d.mts.map +1 -0
  137. package/dist/ukyc/wrapEncryptionKey.mjs +25 -0
  138. package/dist/ukyc/wrapEncryptionKey.mjs.map +1 -0
  139. package/dist/ukyc/wrapUserKey.cjs +80 -0
  140. package/dist/ukyc/wrapUserKey.cjs.map +1 -0
  141. package/dist/ukyc/wrapUserKey.d.cts +26 -0
  142. package/dist/ukyc/wrapUserKey.d.cts.map +1 -0
  143. package/dist/ukyc/wrapUserKey.d.mts +26 -0
  144. package/dist/ukyc/wrapUserKey.d.mts.map +1 -0
  145. package/dist/ukyc/wrapUserKey.mjs +76 -0
  146. package/dist/ukyc/wrapUserKey.mjs.map +1 -0
  147. package/dist/ukyc/wrappedRelayPayload.cjs +32 -0
  148. package/dist/ukyc/wrappedRelayPayload.cjs.map +1 -0
  149. package/dist/ukyc/wrappedRelayPayload.d.cts +35 -0
  150. package/dist/ukyc/wrappedRelayPayload.d.cts.map +1 -0
  151. package/dist/ukyc/wrappedRelayPayload.d.mts +35 -0
  152. package/dist/ukyc/wrappedRelayPayload.d.mts.map +1 -0
  153. package/dist/ukyc/wrappedRelayPayload.mjs +28 -0
  154. package/dist/ukyc/wrappedRelayPayload.mjs.map +1 -0
  155. package/package.json +24 -3
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Shared types for the KYC controller and service.
3
+ *
4
+ * The KYC flow is vendor-backed (currently MoonPay for identity + SumSub for
5
+ * document verification) but the surface exposed to consumers (ramps, card) is
6
+ * intentionally vendor-neutral so a future vendor swap does not ripple out.
7
+ */
8
+ /**
9
+ * A MetaMask feature that consumes KYC. Used to key the per-product
10
+ * "is KYC required" cache so ramps and card can share one controller.
11
+ */
12
+ export type KycProduct = 'ramps' | 'card';
13
+ /**
14
+ * Identity vendors supported behind the KYC surface.
15
+ */
16
+ export type KycVendor = 'moonpay';
17
+ /**
18
+ * Phases of the end-to-end identity flow.
19
+ *
20
+ * - `idle` — nothing started.
21
+ * - `terms` — waiting for the customer to accept the vendor terms.
22
+ * - `session` — creating the vendor session.
23
+ * - `check` — running the invisible connection-check frame.
24
+ * - `auth` — running the visible authentication (OTP) frame.
25
+ * - `form` — authenticated. When the flow is scoped to a product, the
26
+ * KYC-required check runs automatically from here; otherwise the consumer
27
+ * drives it manually via `checkKycRequired`.
28
+ * - `submit` — submitting the KYC-required check.
29
+ * - `done` — flow complete; see `kycRequiredByProduct` / `sumsub`. When KYC is
30
+ * required, the document-verification sub-flow is launched automatically.
31
+ * - `error` — flow halted; see `error`.
32
+ */
33
+ export type KycPhase = 'idle' | 'terms' | 'session' | 'check' | 'auth' | 'form' | 'submit' | 'done' | 'error';
34
+ /**
35
+ * Progress of the SumSub document-verification sub-flow.
36
+ *
37
+ * - `polling` — the SDK finished and the controller is polling the UKYC
38
+ * backend for the session's final decision (see `KycSessionStatus`). The
39
+ * sub-flow resolves to `complete` or `failed` once a terminal status arrives.
40
+ * - `vendorProcessing` — session creation reported that the applicant is
41
+ * already approved on the relay (`kycStatus`) while the vendor is still
42
+ * finalizing its own decision (`finalStatus`). There is nothing left for the
43
+ * applicant to do, so the SDK is not launched; see `statusMessage`.
44
+ */
45
+ export type KycSumSubStatus = 'idle' | 'creatingSession' | 'fetchingToken' | 'launching' | 'inProgress' | 'polling' | 'complete' | 'failed' | 'vendorProcessing';
46
+ /**
47
+ * The status of a UKYC session, returned by the `GET /sessions/{id}/status`
48
+ * endpoint and polled after the SumSub SDK completes to determine the final
49
+ * verification decision.
50
+ */
51
+ export type KycSessionStatus = {
52
+ /**
53
+ * The overall status of the session. Terminal values (e.g. `approved`,
54
+ * `completed`, `rejected`, `failed`, `blocked`) end polling; any other value
55
+ * keeps polling.
56
+ */
57
+ finalStatus: string;
58
+ /** Optional human-readable message describing the status. */
59
+ statusMessage?: string;
60
+ /** The vendor-agnostic external user id associated with the session. */
61
+ externalUserId: string;
62
+ /** The KYC decision status. */
63
+ kycStatus: string;
64
+ /** The identity vendor that handled the session. */
65
+ vendor: string;
66
+ /** The vendor-specific status. */
67
+ vendorStatus: string;
68
+ };
69
+ /**
70
+ * A single disclaimer/term the customer must accept before a session is
71
+ * created.
72
+ */
73
+ export type KycDisclaimer = {
74
+ id: string;
75
+ display_name: string;
76
+ url: string;
77
+ };
78
+ /**
79
+ * Parameters passed to a platform SumSub launcher.
80
+ */
81
+ export type KycSumSubLaunchParams = {
82
+ /**
83
+ * The applicant access token used to initialize the SumSub SDK.
84
+ */
85
+ applicantAccessToken: string;
86
+ /**
87
+ * Called by the SDK when the access token expires; must resolve with a fresh
88
+ * applicant access token.
89
+ */
90
+ onTokenExpiration: () => Promise<string>;
91
+ /**
92
+ * Called when the SDK reports a status transition.
93
+ */
94
+ onStatusChange?: (prevStatus: string, newStatus: string) => void;
95
+ /**
96
+ * BCP-47 locale for the SDK UI.
97
+ */
98
+ locale?: string;
99
+ /**
100
+ * Enables SDK debug logging.
101
+ */
102
+ debug?: boolean;
103
+ };
104
+ /**
105
+ * Platform adapter that launches the native/web SumSub SDK.
106
+ *
107
+ * The KYC controller is platform-agnostic and does not import any SDK; each
108
+ * client (mobile / extension / web) injects an implementation of this
109
+ * interface. The controller owns all orchestration (session creation, token
110
+ * exchange, token refresh, state) and only delegates the actual SDK
111
+ * presentation to `launch`.
112
+ */
113
+ export type KycSumSubLauncher = {
114
+ /**
115
+ * Whether the underlying SDK is available in the current runtime (e.g. the
116
+ * native module is linked). When `false`, `startSumSub` fails fast.
117
+ */
118
+ isAvailable(): boolean;
119
+ /**
120
+ * Presents the SumSub verification flow and resolves with the SDK result.
121
+ */
122
+ launch(params: KycSumSubLaunchParams): Promise<Record<string, unknown>>;
123
+ };
124
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,CAAC;AAE1C;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,SAAS,CAAC;AAElC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,QAAQ,GAChB,MAAM,GACN,OAAO,GACP,SAAS,GACT,OAAO,GACP,MAAM,GACN,MAAM,GACN,QAAQ,GACR,MAAM,GACN,OAAO,CAAC;AAEZ;;;;;;;;;;GAUG;AACH,MAAM,MAAM,eAAe,GACvB,MAAM,GACN,iBAAiB,GACjB,eAAe,GACf,WAAW,GACX,YAAY,GACZ,SAAS,GACT,UAAU,GACV,QAAQ,GACR,kBAAkB,CAAC;AAEvB;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,6DAA6D;IAC7D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wEAAwE;IACxE,cAAc,EAAE,MAAM,CAAC;IACvB,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IAGX,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAE7B;;;OAGG;IACH,iBAAiB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAEzC;;OAEG;IACH,cAAc,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAEjE;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;OAGG;IACH,WAAW,IAAI,OAAO,CAAC;IAEvB;;OAEG;IACH,MAAM,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACzE,CAAC"}
package/dist/types.mjs ADDED
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Shared types for the KYC controller and service.
3
+ *
4
+ * The KYC flow is vendor-backed (currently MoonPay for identity + SumSub for
5
+ * document verification) but the surface exposed to consumers (ramps, card) is
6
+ * intentionally vendor-neutral so a future vendor swap does not ripple out.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG","sourcesContent":["/**\n * Shared types for the KYC controller and service.\n *\n * The KYC flow is vendor-backed (currently MoonPay for identity + SumSub for\n * document verification) but the surface exposed to consumers (ramps, card) is\n * intentionally vendor-neutral so a future vendor swap does not ripple out.\n */\n\n/**\n * A MetaMask feature that consumes KYC. Used to key the per-product\n * \"is KYC required\" cache so ramps and card can share one controller.\n */\nexport type KycProduct = 'ramps' | 'card';\n\n/**\n * Identity vendors supported behind the KYC surface.\n */\nexport type KycVendor = 'moonpay';\n\n/**\n * Phases of the end-to-end identity flow.\n *\n * - `idle` — nothing started.\n * - `terms` — waiting for the customer to accept the vendor terms.\n * - `session` — creating the vendor session.\n * - `check` — running the invisible connection-check frame.\n * - `auth` — running the visible authentication (OTP) frame.\n * - `form` — authenticated. When the flow is scoped to a product, the\n * KYC-required check runs automatically from here; otherwise the consumer\n * drives it manually via `checkKycRequired`.\n * - `submit` — submitting the KYC-required check.\n * - `done` — flow complete; see `kycRequiredByProduct` / `sumsub`. When KYC is\n * required, the document-verification sub-flow is launched automatically.\n * - `error` — flow halted; see `error`.\n */\nexport type KycPhase =\n | 'idle'\n | 'terms'\n | 'session'\n | 'check'\n | 'auth'\n | 'form'\n | 'submit'\n | 'done'\n | 'error';\n\n/**\n * Progress of the SumSub document-verification sub-flow.\n *\n * - `polling` — the SDK finished and the controller is polling the UKYC\n * backend for the session's final decision (see `KycSessionStatus`). The\n * sub-flow resolves to `complete` or `failed` once a terminal status arrives.\n * - `vendorProcessing` — session creation reported that the applicant is\n * already approved on the relay (`kycStatus`) while the vendor is still\n * finalizing its own decision (`finalStatus`). There is nothing left for the\n * applicant to do, so the SDK is not launched; see `statusMessage`.\n */\nexport type KycSumSubStatus =\n | 'idle'\n | 'creatingSession'\n | 'fetchingToken'\n | 'launching'\n | 'inProgress'\n | 'polling'\n | 'complete'\n | 'failed'\n | 'vendorProcessing';\n\n/**\n * The status of a UKYC session, returned by the `GET /sessions/{id}/status`\n * endpoint and polled after the SumSub SDK completes to determine the final\n * verification decision.\n */\nexport type KycSessionStatus = {\n /**\n * The overall status of the session. Terminal values (e.g. `approved`,\n * `completed`, `rejected`, `failed`, `blocked`) end polling; any other value\n * keeps polling.\n */\n finalStatus: string;\n /** Optional human-readable message describing the status. */\n statusMessage?: string;\n /** The vendor-agnostic external user id associated with the session. */\n externalUserId: string;\n /** The KYC decision status. */\n kycStatus: string;\n /** The identity vendor that handled the session. */\n vendor: string;\n /** The vendor-specific status. */\n vendorStatus: string;\n};\n\n/**\n * A single disclaimer/term the customer must accept before a session is\n * created.\n */\nexport type KycDisclaimer = {\n id: string;\n // Mirrors the vendor API response field, which is snake_case.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n display_name: string;\n url: string;\n};\n\n/**\n * Parameters passed to a platform SumSub launcher.\n */\nexport type KycSumSubLaunchParams = {\n /**\n * The applicant access token used to initialize the SumSub SDK.\n */\n applicantAccessToken: string;\n\n /**\n * Called by the SDK when the access token expires; must resolve with a fresh\n * applicant access token.\n */\n onTokenExpiration: () => Promise<string>;\n\n /**\n * Called when the SDK reports a status transition.\n */\n onStatusChange?: (prevStatus: string, newStatus: string) => void;\n\n /**\n * BCP-47 locale for the SDK UI.\n */\n locale?: string;\n\n /**\n * Enables SDK debug logging.\n */\n debug?: boolean;\n};\n\n/**\n * Platform adapter that launches the native/web SumSub SDK.\n *\n * The KYC controller is platform-agnostic and does not import any SDK; each\n * client (mobile / extension / web) injects an implementation of this\n * interface. The controller owns all orchestration (session creation, token\n * exchange, token refresh, state) and only delegates the actual SDK\n * presentation to `launch`.\n */\nexport type KycSumSubLauncher = {\n /**\n * Whether the underlying SDK is available in the current runtime (e.g. the\n * native module is linked). When `false`, `startSumSub` fails fast.\n */\n isAvailable(): boolean;\n\n /**\n * Presents the SumSub verification flow and resolves with the SDK result.\n */\n launch(params: KycSumSubLaunchParams): Promise<Record<string, unknown>>;\n};\n"]}
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ /**
3
+ * Constants for the UKYC client-derived key material and storage-authorization
4
+ * layer. See the architecture doc, section "Client-Derived Material".
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.UKYC_JWKS_PATH = exports.UKYC_CAPABILITY_AUTH_SCHEME = exports.UKYC_STORAGE_ACCESS_TOKEN_AUDIENCES = exports.UKYC_KWIL_AUDIENCE = exports.UKYC_STORAGE_ACCESS_TOKEN_AUDIENCE = exports.UKYC_STORAGE_ACCESS_TOKEN_VERSION = exports.UKYC_KDF_INFO = exports.UKYC_DERIVED_KEY_SIZES = exports.UKYC_LOCAL_USER_SECRET_SIZE_BYTES = exports.UKYC_LOCAL_USER_SECRET_PATH = void 0;
8
+ /**
9
+ * Fully-qualified key path for the `local_user_secret` in Encrypted User
10
+ * Storage.
11
+ */
12
+ exports.UKYC_LOCAL_USER_SECRET_PATH = `ukyc.local_user_secret`;
13
+ /**
14
+ * Size of the `local_user_secret` in bytes. 32 bytes (256 bits) provides high
15
+ * entropy and matches the input length expected by the HKDF-SHA256 derivations
16
+ * below.
17
+ */
18
+ exports.UKYC_LOCAL_USER_SECRET_SIZE_BYTES = 32;
19
+ /**
20
+ * Byte length of each value derived from `local_user_secret`.
21
+ *
22
+ * `signingKey` is 32 bytes because it is used directly as the Ed25519
23
+ * private key (for Ed25519 the 32-byte seed *is* the private key).
24
+ */
25
+ exports.UKYC_DERIVED_KEY_SIZES = {
26
+ storageId: 32,
27
+ dataEncryptionKey: 32,
28
+ signingKey: 32,
29
+ relayTunnelKey: 32,
30
+ };
31
+ /**
32
+ * HKDF `info` labels providing domain separation between the values derived
33
+ * from `local_user_secret`.
34
+ */
35
+ exports.UKYC_KDF_INFO = {
36
+ storageId: 'metamask.ukyc.storage.v1.storage_id',
37
+ dataEncryptionKey: 'metamask.ukyc.storage.v1.data_encryption_key',
38
+ signingKey: 'metamask.ukyc.storage.v1.signing_key',
39
+ relayTunnelKey: 'metamask.ukyc.storage.v1.relay_tunnel_key',
40
+ };
41
+ /**
42
+ * Version bound into every `storage_access_token` payload.
43
+ */
44
+ exports.UKYC_STORAGE_ACCESS_TOKEN_VERSION = 1;
45
+ /**
46
+ * Audience identifying the UKYC user-storage service. Required by UKYC Storage
47
+ * when it verifies a `storage_access_token`.
48
+ */
49
+ exports.UKYC_STORAGE_ACCESS_TOKEN_AUDIENCE = 'metamask:user-storage:ukyc';
50
+ /**
51
+ * Audience identifying the idOS Kwil credential-registry nodes. Required by
52
+ * idOS Kwil when it verifies a `storage_access_token`.
53
+ */
54
+ exports.UKYC_KWIL_AUDIENCE = 'idos:kwil';
55
+ /**
56
+ * Full audience list bound into every `storage_access_token` payload. `aud`
57
+ * lists every verifier that may accept the token, so both UKYC Storage and
58
+ * idOS Kwil can each find their own entry.
59
+ */
60
+ exports.UKYC_STORAGE_ACCESS_TOKEN_AUDIENCES = [
61
+ exports.UKYC_STORAGE_ACCESS_TOKEN_AUDIENCE,
62
+ exports.UKYC_KWIL_AUDIENCE,
63
+ ];
64
+ /**
65
+ * Authorization scheme under which a signed `storage_access_token` envelope is
66
+ * carried to UKYC Storage: `Authorization: AccessToken <base64url(envelope)>`.
67
+ * The credentials portion is what `encodeStorageAccessTokenForHeader` returns.
68
+ */
69
+ exports.UKYC_CAPABILITY_AUTH_SCHEME = 'AccessToken';
70
+ /**
71
+ * Standard well-known path where the Fractal encryption service publishes its
72
+ * JWKS (the Ed25519 public keys used to sign the `jwtChain`).
73
+ */
74
+ exports.UKYC_JWKS_PATH = '/.well-known/jwks.json';
75
+ //# sourceMappingURL=constants.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.cjs","sourceRoot":"","sources":["../../src/ukyc/constants.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;GAGG;AACU,QAAA,2BAA2B,GAAG,wBAAiC,CAAC;AAE7E;;;;GAIG;AACU,QAAA,iCAAiC,GAAG,EAAE,CAAC;AAEpD;;;;;GAKG;AACU,QAAA,sBAAsB,GAAG;IACpC,SAAS,EAAE,EAAE;IACb,iBAAiB,EAAE,EAAE;IACrB,UAAU,EAAE,EAAE;IACd,cAAc,EAAE,EAAE;CACV,CAAC;AAEX;;;GAGG;AACU,QAAA,aAAa,GAAG;IAC3B,SAAS,EAAE,qCAAqC;IAChD,iBAAiB,EAAE,8CAA8C;IACjE,UAAU,EAAE,sCAAsC;IAClD,cAAc,EAAE,2CAA2C;CACnD,CAAC;AAEX;;GAEG;AACU,QAAA,iCAAiC,GAAG,CAAC,CAAC;AAEnD;;;GAGG;AACU,QAAA,kCAAkC,GAC7C,4BAAqC,CAAC;AAExC;;;GAGG;AACU,QAAA,kBAAkB,GAAG,WAAoB,CAAC;AAEvD;;;;GAIG;AACU,QAAA,mCAAmC,GAAG;IACjD,0CAAkC;IAClC,0BAAkB;CACV,CAAC;AAEX;;;;GAIG;AACU,QAAA,2BAA2B,GAAG,aAAsB,CAAC;AAElE;;;GAGG;AACU,QAAA,cAAc,GAAG,wBAAwB,CAAC","sourcesContent":["/**\n * Constants for the UKYC client-derived key material and storage-authorization\n * layer. See the architecture doc, section \"Client-Derived Material\".\n */\n\n/**\n * Fully-qualified key path for the `local_user_secret` in Encrypted User\n * Storage.\n */\nexport const UKYC_LOCAL_USER_SECRET_PATH = `ukyc.local_user_secret` as const;\n\n/**\n * Size of the `local_user_secret` in bytes. 32 bytes (256 bits) provides high\n * entropy and matches the input length expected by the HKDF-SHA256 derivations\n * below.\n */\nexport const UKYC_LOCAL_USER_SECRET_SIZE_BYTES = 32;\n\n/**\n * Byte length of each value derived from `local_user_secret`.\n *\n * `signingKey` is 32 bytes because it is used directly as the Ed25519\n * private key (for Ed25519 the 32-byte seed *is* the private key).\n */\nexport const UKYC_DERIVED_KEY_SIZES = {\n storageId: 32,\n dataEncryptionKey: 32,\n signingKey: 32,\n relayTunnelKey: 32,\n} as const;\n\n/**\n * HKDF `info` labels providing domain separation between the values derived\n * from `local_user_secret`.\n */\nexport const UKYC_KDF_INFO = {\n storageId: 'metamask.ukyc.storage.v1.storage_id',\n dataEncryptionKey: 'metamask.ukyc.storage.v1.data_encryption_key',\n signingKey: 'metamask.ukyc.storage.v1.signing_key',\n relayTunnelKey: 'metamask.ukyc.storage.v1.relay_tunnel_key',\n} as const;\n\n/**\n * Version bound into every `storage_access_token` payload.\n */\nexport const UKYC_STORAGE_ACCESS_TOKEN_VERSION = 1;\n\n/**\n * Audience identifying the UKYC user-storage service. Required by UKYC Storage\n * when it verifies a `storage_access_token`.\n */\nexport const UKYC_STORAGE_ACCESS_TOKEN_AUDIENCE =\n 'metamask:user-storage:ukyc' as const;\n\n/**\n * Audience identifying the idOS Kwil credential-registry nodes. Required by\n * idOS Kwil when it verifies a `storage_access_token`.\n */\nexport const UKYC_KWIL_AUDIENCE = 'idos:kwil' as const;\n\n/**\n * Full audience list bound into every `storage_access_token` payload. `aud`\n * lists every verifier that may accept the token, so both UKYC Storage and\n * idOS Kwil can each find their own entry.\n */\nexport const UKYC_STORAGE_ACCESS_TOKEN_AUDIENCES = [\n UKYC_STORAGE_ACCESS_TOKEN_AUDIENCE,\n UKYC_KWIL_AUDIENCE,\n] as const;\n\n/**\n * Authorization scheme under which a signed `storage_access_token` envelope is\n * carried to UKYC Storage: `Authorization: AccessToken <base64url(envelope)>`.\n * The credentials portion is what `encodeStorageAccessTokenForHeader` returns.\n */\nexport const UKYC_CAPABILITY_AUTH_SCHEME = 'AccessToken' as const;\n\n/**\n * Standard well-known path where the Fractal encryption service publishes its\n * JWKS (the Ed25519 public keys used to sign the `jwtChain`).\n */\nexport const UKYC_JWKS_PATH = '/.well-known/jwks.json';\n"]}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Constants for the UKYC client-derived key material and storage-authorization
3
+ * layer. See the architecture doc, section "Client-Derived Material".
4
+ */
5
+ /**
6
+ * Fully-qualified key path for the `local_user_secret` in Encrypted User
7
+ * Storage.
8
+ */
9
+ export declare const UKYC_LOCAL_USER_SECRET_PATH: "ukyc.local_user_secret";
10
+ /**
11
+ * Size of the `local_user_secret` in bytes. 32 bytes (256 bits) provides high
12
+ * entropy and matches the input length expected by the HKDF-SHA256 derivations
13
+ * below.
14
+ */
15
+ export declare const UKYC_LOCAL_USER_SECRET_SIZE_BYTES = 32;
16
+ /**
17
+ * Byte length of each value derived from `local_user_secret`.
18
+ *
19
+ * `signingKey` is 32 bytes because it is used directly as the Ed25519
20
+ * private key (for Ed25519 the 32-byte seed *is* the private key).
21
+ */
22
+ export declare const UKYC_DERIVED_KEY_SIZES: {
23
+ readonly storageId: 32;
24
+ readonly dataEncryptionKey: 32;
25
+ readonly signingKey: 32;
26
+ readonly relayTunnelKey: 32;
27
+ };
28
+ /**
29
+ * HKDF `info` labels providing domain separation between the values derived
30
+ * from `local_user_secret`.
31
+ */
32
+ export declare const UKYC_KDF_INFO: {
33
+ readonly storageId: "metamask.ukyc.storage.v1.storage_id";
34
+ readonly dataEncryptionKey: "metamask.ukyc.storage.v1.data_encryption_key";
35
+ readonly signingKey: "metamask.ukyc.storage.v1.signing_key";
36
+ readonly relayTunnelKey: "metamask.ukyc.storage.v1.relay_tunnel_key";
37
+ };
38
+ /**
39
+ * Version bound into every `storage_access_token` payload.
40
+ */
41
+ export declare const UKYC_STORAGE_ACCESS_TOKEN_VERSION = 1;
42
+ /**
43
+ * Audience identifying the UKYC user-storage service. Required by UKYC Storage
44
+ * when it verifies a `storage_access_token`.
45
+ */
46
+ export declare const UKYC_STORAGE_ACCESS_TOKEN_AUDIENCE: "metamask:user-storage:ukyc";
47
+ /**
48
+ * Audience identifying the idOS Kwil credential-registry nodes. Required by
49
+ * idOS Kwil when it verifies a `storage_access_token`.
50
+ */
51
+ export declare const UKYC_KWIL_AUDIENCE: "idos:kwil";
52
+ /**
53
+ * Full audience list bound into every `storage_access_token` payload. `aud`
54
+ * lists every verifier that may accept the token, so both UKYC Storage and
55
+ * idOS Kwil can each find their own entry.
56
+ */
57
+ export declare const UKYC_STORAGE_ACCESS_TOKEN_AUDIENCES: readonly ["metamask:user-storage:ukyc", "idos:kwil"];
58
+ /**
59
+ * Authorization scheme under which a signed `storage_access_token` envelope is
60
+ * carried to UKYC Storage: `Authorization: AccessToken <base64url(envelope)>`.
61
+ * The credentials portion is what `encodeStorageAccessTokenForHeader` returns.
62
+ */
63
+ export declare const UKYC_CAPABILITY_AUTH_SCHEME: "AccessToken";
64
+ /**
65
+ * Standard well-known path where the Fractal encryption service publishes its
66
+ * JWKS (the Ed25519 public keys used to sign the `jwtChain`).
67
+ */
68
+ export declare const UKYC_JWKS_PATH = "/.well-known/jwks.json";
69
+ //# sourceMappingURL=constants.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.cts","sourceRoot":"","sources":["../../src/ukyc/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,eAAO,MAAM,2BAA2B,0BAAoC,CAAC;AAE7E;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,KAAK,CAAC;AAEpD;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB;;;;;CAKzB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;CAKhB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,iCAAiC,IAAI,CAAC;AAEnD;;;GAGG;AACH,eAAO,MAAM,kCAAkC,8BACR,CAAC;AAExC;;;GAGG;AACH,eAAO,MAAM,kBAAkB,aAAuB,CAAC;AAEvD;;;;GAIG;AACH,eAAO,MAAM,mCAAmC,sDAGtC,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,eAAyB,CAAC;AAElE;;;GAGG;AACH,eAAO,MAAM,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Constants for the UKYC client-derived key material and storage-authorization
3
+ * layer. See the architecture doc, section "Client-Derived Material".
4
+ */
5
+ /**
6
+ * Fully-qualified key path for the `local_user_secret` in Encrypted User
7
+ * Storage.
8
+ */
9
+ export declare const UKYC_LOCAL_USER_SECRET_PATH: "ukyc.local_user_secret";
10
+ /**
11
+ * Size of the `local_user_secret` in bytes. 32 bytes (256 bits) provides high
12
+ * entropy and matches the input length expected by the HKDF-SHA256 derivations
13
+ * below.
14
+ */
15
+ export declare const UKYC_LOCAL_USER_SECRET_SIZE_BYTES = 32;
16
+ /**
17
+ * Byte length of each value derived from `local_user_secret`.
18
+ *
19
+ * `signingKey` is 32 bytes because it is used directly as the Ed25519
20
+ * private key (for Ed25519 the 32-byte seed *is* the private key).
21
+ */
22
+ export declare const UKYC_DERIVED_KEY_SIZES: {
23
+ readonly storageId: 32;
24
+ readonly dataEncryptionKey: 32;
25
+ readonly signingKey: 32;
26
+ readonly relayTunnelKey: 32;
27
+ };
28
+ /**
29
+ * HKDF `info` labels providing domain separation between the values derived
30
+ * from `local_user_secret`.
31
+ */
32
+ export declare const UKYC_KDF_INFO: {
33
+ readonly storageId: "metamask.ukyc.storage.v1.storage_id";
34
+ readonly dataEncryptionKey: "metamask.ukyc.storage.v1.data_encryption_key";
35
+ readonly signingKey: "metamask.ukyc.storage.v1.signing_key";
36
+ readonly relayTunnelKey: "metamask.ukyc.storage.v1.relay_tunnel_key";
37
+ };
38
+ /**
39
+ * Version bound into every `storage_access_token` payload.
40
+ */
41
+ export declare const UKYC_STORAGE_ACCESS_TOKEN_VERSION = 1;
42
+ /**
43
+ * Audience identifying the UKYC user-storage service. Required by UKYC Storage
44
+ * when it verifies a `storage_access_token`.
45
+ */
46
+ export declare const UKYC_STORAGE_ACCESS_TOKEN_AUDIENCE: "metamask:user-storage:ukyc";
47
+ /**
48
+ * Audience identifying the idOS Kwil credential-registry nodes. Required by
49
+ * idOS Kwil when it verifies a `storage_access_token`.
50
+ */
51
+ export declare const UKYC_KWIL_AUDIENCE: "idos:kwil";
52
+ /**
53
+ * Full audience list bound into every `storage_access_token` payload. `aud`
54
+ * lists every verifier that may accept the token, so both UKYC Storage and
55
+ * idOS Kwil can each find their own entry.
56
+ */
57
+ export declare const UKYC_STORAGE_ACCESS_TOKEN_AUDIENCES: readonly ["metamask:user-storage:ukyc", "idos:kwil"];
58
+ /**
59
+ * Authorization scheme under which a signed `storage_access_token` envelope is
60
+ * carried to UKYC Storage: `Authorization: AccessToken <base64url(envelope)>`.
61
+ * The credentials portion is what `encodeStorageAccessTokenForHeader` returns.
62
+ */
63
+ export declare const UKYC_CAPABILITY_AUTH_SCHEME: "AccessToken";
64
+ /**
65
+ * Standard well-known path where the Fractal encryption service publishes its
66
+ * JWKS (the Ed25519 public keys used to sign the `jwtChain`).
67
+ */
68
+ export declare const UKYC_JWKS_PATH = "/.well-known/jwks.json";
69
+ //# sourceMappingURL=constants.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../../src/ukyc/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,eAAO,MAAM,2BAA2B,0BAAoC,CAAC;AAE7E;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,KAAK,CAAC;AAEpD;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB;;;;;CAKzB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;CAKhB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,iCAAiC,IAAI,CAAC;AAEnD;;;GAGG;AACH,eAAO,MAAM,kCAAkC,8BACR,CAAC;AAExC;;;GAGG;AACH,eAAO,MAAM,kBAAkB,aAAuB,CAAC;AAEvD;;;;GAIG;AACH,eAAO,MAAM,mCAAmC,sDAGtC,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,eAAyB,CAAC;AAElE;;;GAGG;AACH,eAAO,MAAM,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Constants for the UKYC client-derived key material and storage-authorization
3
+ * layer. See the architecture doc, section "Client-Derived Material".
4
+ */
5
+ /**
6
+ * Fully-qualified key path for the `local_user_secret` in Encrypted User
7
+ * Storage.
8
+ */
9
+ export const UKYC_LOCAL_USER_SECRET_PATH = `ukyc.local_user_secret`;
10
+ /**
11
+ * Size of the `local_user_secret` in bytes. 32 bytes (256 bits) provides high
12
+ * entropy and matches the input length expected by the HKDF-SHA256 derivations
13
+ * below.
14
+ */
15
+ export const UKYC_LOCAL_USER_SECRET_SIZE_BYTES = 32;
16
+ /**
17
+ * Byte length of each value derived from `local_user_secret`.
18
+ *
19
+ * `signingKey` is 32 bytes because it is used directly as the Ed25519
20
+ * private key (for Ed25519 the 32-byte seed *is* the private key).
21
+ */
22
+ export const UKYC_DERIVED_KEY_SIZES = {
23
+ storageId: 32,
24
+ dataEncryptionKey: 32,
25
+ signingKey: 32,
26
+ relayTunnelKey: 32,
27
+ };
28
+ /**
29
+ * HKDF `info` labels providing domain separation between the values derived
30
+ * from `local_user_secret`.
31
+ */
32
+ export const UKYC_KDF_INFO = {
33
+ storageId: 'metamask.ukyc.storage.v1.storage_id',
34
+ dataEncryptionKey: 'metamask.ukyc.storage.v1.data_encryption_key',
35
+ signingKey: 'metamask.ukyc.storage.v1.signing_key',
36
+ relayTunnelKey: 'metamask.ukyc.storage.v1.relay_tunnel_key',
37
+ };
38
+ /**
39
+ * Version bound into every `storage_access_token` payload.
40
+ */
41
+ export const UKYC_STORAGE_ACCESS_TOKEN_VERSION = 1;
42
+ /**
43
+ * Audience identifying the UKYC user-storage service. Required by UKYC Storage
44
+ * when it verifies a `storage_access_token`.
45
+ */
46
+ export const UKYC_STORAGE_ACCESS_TOKEN_AUDIENCE = 'metamask:user-storage:ukyc';
47
+ /**
48
+ * Audience identifying the idOS Kwil credential-registry nodes. Required by
49
+ * idOS Kwil when it verifies a `storage_access_token`.
50
+ */
51
+ export const UKYC_KWIL_AUDIENCE = 'idos:kwil';
52
+ /**
53
+ * Full audience list bound into every `storage_access_token` payload. `aud`
54
+ * lists every verifier that may accept the token, so both UKYC Storage and
55
+ * idOS Kwil can each find their own entry.
56
+ */
57
+ export const UKYC_STORAGE_ACCESS_TOKEN_AUDIENCES = [
58
+ UKYC_STORAGE_ACCESS_TOKEN_AUDIENCE,
59
+ UKYC_KWIL_AUDIENCE,
60
+ ];
61
+ /**
62
+ * Authorization scheme under which a signed `storage_access_token` envelope is
63
+ * carried to UKYC Storage: `Authorization: AccessToken <base64url(envelope)>`.
64
+ * The credentials portion is what `encodeStorageAccessTokenForHeader` returns.
65
+ */
66
+ export const UKYC_CAPABILITY_AUTH_SCHEME = 'AccessToken';
67
+ /**
68
+ * Standard well-known path where the Fractal encryption service publishes its
69
+ * JWKS (the Ed25519 public keys used to sign the `jwtChain`).
70
+ */
71
+ export const UKYC_JWKS_PATH = '/.well-known/jwks.json';
72
+ //# sourceMappingURL=constants.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../../src/ukyc/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,wBAAiC,CAAC;AAE7E;;;;GAIG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,EAAE,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,SAAS,EAAE,EAAE;IACb,iBAAiB,EAAE,EAAE;IACrB,UAAU,EAAE,EAAE;IACd,cAAc,EAAE,EAAE;CACV,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,SAAS,EAAE,qCAAqC;IAChD,iBAAiB,EAAE,8CAA8C;IACjE,UAAU,EAAE,sCAAsC;IAClD,cAAc,EAAE,2CAA2C;CACnD,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,CAAC;AAEnD;;;GAGG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAC7C,4BAAqC,CAAC;AAExC;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,WAAoB,CAAC;AAEvD;;;;GAIG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAG;IACjD,kCAAkC;IAClC,kBAAkB;CACV,CAAC;AAEX;;;;GAIG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,aAAsB,CAAC;AAElE;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,wBAAwB,CAAC","sourcesContent":["/**\n * Constants for the UKYC client-derived key material and storage-authorization\n * layer. See the architecture doc, section \"Client-Derived Material\".\n */\n\n/**\n * Fully-qualified key path for the `local_user_secret` in Encrypted User\n * Storage.\n */\nexport const UKYC_LOCAL_USER_SECRET_PATH = `ukyc.local_user_secret` as const;\n\n/**\n * Size of the `local_user_secret` in bytes. 32 bytes (256 bits) provides high\n * entropy and matches the input length expected by the HKDF-SHA256 derivations\n * below.\n */\nexport const UKYC_LOCAL_USER_SECRET_SIZE_BYTES = 32;\n\n/**\n * Byte length of each value derived from `local_user_secret`.\n *\n * `signingKey` is 32 bytes because it is used directly as the Ed25519\n * private key (for Ed25519 the 32-byte seed *is* the private key).\n */\nexport const UKYC_DERIVED_KEY_SIZES = {\n storageId: 32,\n dataEncryptionKey: 32,\n signingKey: 32,\n relayTunnelKey: 32,\n} as const;\n\n/**\n * HKDF `info` labels providing domain separation between the values derived\n * from `local_user_secret`.\n */\nexport const UKYC_KDF_INFO = {\n storageId: 'metamask.ukyc.storage.v1.storage_id',\n dataEncryptionKey: 'metamask.ukyc.storage.v1.data_encryption_key',\n signingKey: 'metamask.ukyc.storage.v1.signing_key',\n relayTunnelKey: 'metamask.ukyc.storage.v1.relay_tunnel_key',\n} as const;\n\n/**\n * Version bound into every `storage_access_token` payload.\n */\nexport const UKYC_STORAGE_ACCESS_TOKEN_VERSION = 1;\n\n/**\n * Audience identifying the UKYC user-storage service. Required by UKYC Storage\n * when it verifies a `storage_access_token`.\n */\nexport const UKYC_STORAGE_ACCESS_TOKEN_AUDIENCE =\n 'metamask:user-storage:ukyc' as const;\n\n/**\n * Audience identifying the idOS Kwil credential-registry nodes. Required by\n * idOS Kwil when it verifies a `storage_access_token`.\n */\nexport const UKYC_KWIL_AUDIENCE = 'idos:kwil' as const;\n\n/**\n * Full audience list bound into every `storage_access_token` payload. `aud`\n * lists every verifier that may accept the token, so both UKYC Storage and\n * idOS Kwil can each find their own entry.\n */\nexport const UKYC_STORAGE_ACCESS_TOKEN_AUDIENCES = [\n UKYC_STORAGE_ACCESS_TOKEN_AUDIENCE,\n UKYC_KWIL_AUDIENCE,\n] as const;\n\n/**\n * Authorization scheme under which a signed `storage_access_token` envelope is\n * carried to UKYC Storage: `Authorization: AccessToken <base64url(envelope)>`.\n * The credentials portion is what `encodeStorageAccessTokenForHeader` returns.\n */\nexport const UKYC_CAPABILITY_AUTH_SCHEME = 'AccessToken' as const;\n\n/**\n * Standard well-known path where the Fractal encryption service publishes its\n * JWKS (the Ed25519 public keys used to sign the `jwtChain`).\n */\nexport const UKYC_JWKS_PATH = '/.well-known/jwks.json';\n"]}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.encodeClientMaterial = exports.deriveClientMaterial = void 0;
4
+ const utils_1 = require("@metamask/utils");
5
+ const ed25519_1 = require("@noble/curves/ed25519");
6
+ const hkdf_1 = require("@noble/hashes/hkdf");
7
+ const sha2_1 = require("@noble/hashes/sha2");
8
+ const constants_js_1 = require("./constants.cjs");
9
+ const encoding_js_1 = require("../encoding.cjs");
10
+ /**
11
+ * Derives a single labeled value from `local_user_secret`.
12
+ *
13
+ * No salt is used: `local_user_secret` is already a high-entropy
14
+ * uniformly-random secret, so per-output domain separation comes entirely from
15
+ * the `info` label.
16
+ *
17
+ * @param localUserSecret - The root `local_user_secret` bytes.
18
+ * @param info - Domain-separation label for this output.
19
+ * @param length - Desired output length in bytes.
20
+ * @returns The derived bytes.
21
+ */
22
+ function deriveLabeled(localUserSecret, info, length) {
23
+ return (0, hkdf_1.hkdf)(sha2_1.sha256, localUserSecret, undefined, (0, utils_1.stringToBytes)(info), length);
24
+ }
25
+ /**
26
+ * Derives all UKYC client material from the root `local_user_secret`.
27
+ *
28
+ * This is a pure function of `local_user_secret`: the same input always yields
29
+ * the same outputs, which is what makes `storage_id` and `signing_key` stable
30
+ * across sessions and devices.
31
+ *
32
+ * @param localUserSecret - The `local_user_secret` produced by
33
+ * `getOrCreateLocalUserSecret`.
34
+ * @returns The derived {@link UkycClientMaterial}.
35
+ */
36
+ function deriveClientMaterial(localUserSecret) {
37
+ const storageId = deriveLabeled(localUserSecret, constants_js_1.UKYC_KDF_INFO.storageId, constants_js_1.UKYC_DERIVED_KEY_SIZES.storageId);
38
+ const dataEncryptionKey = deriveLabeled(localUserSecret, constants_js_1.UKYC_KDF_INFO.dataEncryptionKey, constants_js_1.UKYC_DERIVED_KEY_SIZES.dataEncryptionKey);
39
+ const signingKey = deriveLabeled(localUserSecret, constants_js_1.UKYC_KDF_INFO.signingKey, constants_js_1.UKYC_DERIVED_KEY_SIZES.signingKey);
40
+ const relayTunnelKey = deriveLabeled(localUserSecret, constants_js_1.UKYC_KDF_INFO.relayTunnelKey, constants_js_1.UKYC_DERIVED_KEY_SIZES.relayTunnelKey);
41
+ const signingPublicKey = ed25519_1.ed25519.getPublicKey(signingKey);
42
+ return {
43
+ storageId,
44
+ dataEncryptionKey,
45
+ signingKey,
46
+ signingPublicKey,
47
+ relayTunnelKey,
48
+ };
49
+ }
50
+ exports.deriveClientMaterial = deriveClientMaterial;
51
+ /**
52
+ * Encodes the non-secret client material into the base64url wire shapes used by
53
+ * the UKYC storage API (`storage_id` and `signing_public_key`).
54
+ *
55
+ * @param material - The derived client material.
56
+ * @returns The base64url-encoded, non-secret fields.
57
+ */
58
+ function encodeClientMaterial(material) {
59
+ return {
60
+ storageId: (0, encoding_js_1.toBase64Url)(material.storageId),
61
+ signingPublicKey: (0, encoding_js_1.toBase64Url)(material.signingPublicKey),
62
+ };
63
+ }
64
+ exports.encodeClientMaterial = encodeClientMaterial;
65
+ //# sourceMappingURL=deriveClientMaterial.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deriveClientMaterial.cjs","sourceRoot":"","sources":["../../src/ukyc/deriveClientMaterial.ts"],"names":[],"mappings":";;;AAAA,2CAAgD;AAChD,mDAAgD;AAChD,6CAA0C;AAC1C,6CAA4C;AAE5C,kDAAuE;AACvE,iDAA6C;AAsC7C;;;;;;;;;;;GAWG;AACH,SAAS,aAAa,CACpB,eAA2B,EAC3B,IAAY,EACZ,MAAc;IAEd,OAAO,IAAA,WAAI,EAAC,aAAM,EAAE,eAAe,EAAE,SAAS,EAAE,IAAA,qBAAa,EAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;AAC/E,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,oBAAoB,CAClC,eAA2B;IAE3B,MAAM,SAAS,GAAG,aAAa,CAC7B,eAAe,EACf,4BAAa,CAAC,SAAS,EACvB,qCAAsB,CAAC,SAAS,CACjC,CAAC;IAEF,MAAM,iBAAiB,GAAG,aAAa,CACrC,eAAe,EACf,4BAAa,CAAC,iBAAiB,EAC/B,qCAAsB,CAAC,iBAAiB,CACzC,CAAC;IAEF,MAAM,UAAU,GAAG,aAAa,CAC9B,eAAe,EACf,4BAAa,CAAC,UAAU,EACxB,qCAAsB,CAAC,UAAU,CAClC,CAAC;IAEF,MAAM,cAAc,GAAG,aAAa,CAClC,eAAe,EACf,4BAAa,CAAC,cAAc,EAC5B,qCAAsB,CAAC,cAAc,CACtC,CAAC;IAEF,MAAM,gBAAgB,GAAG,iBAAO,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IAE1D,OAAO;QACL,SAAS;QACT,iBAAiB;QACjB,UAAU;QACV,gBAAgB;QAChB,cAAc;KACf,CAAC;AACJ,CAAC;AApCD,oDAoCC;AAED;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAClC,QAA4B;IAE5B,OAAO;QACL,SAAS,EAAE,IAAA,yBAAW,EAAC,QAAQ,CAAC,SAAS,CAAC;QAC1C,gBAAgB,EAAE,IAAA,yBAAW,EAAC,QAAQ,CAAC,gBAAgB,CAAC;KACzD,CAAC;AACJ,CAAC;AAPD,oDAOC","sourcesContent":["import { stringToBytes } from '@metamask/utils';\nimport { ed25519 } from '@noble/curves/ed25519';\nimport { hkdf } from '@noble/hashes/hkdf';\nimport { sha256 } from '@noble/hashes/sha2';\n\nimport { UKYC_DERIVED_KEY_SIZES, UKYC_KDF_INFO } from './constants.js';\nimport { toBase64Url } from '../encoding.js';\n\n/**\n * Derives UKYC client material from the root `local_user_secret` using\n * HKDF-SHA256 with domain-separated `info` labels — see the architecture doc,\n * section \"Client-Derived Material\".\n */\n\n/**\n * The set of values derived from `local_user_secret`.\n */\nexport type UkycClientMaterial = {\n /** Opaque lookup key for the encrypted KYC object. */\n storageId: Uint8Array;\n /** Symmetric key that encrypts `encrypted_kyc_data` (or wraps per-blob keys). */\n dataEncryptionKey: Uint8Array;\n /**\n * Ed25519 private key used to sign `storage_access_token` capabilities. For\n * Ed25519 the 32-byte HKDF output *is* the private key. The private half\n * never leaves the device.\n */\n signingKey: Uint8Array;\n /** Public half of `signingKey`, registered with the object on first write. */\n signingPublicKey: Uint8Array;\n /** Key for establishing/authenticating the encrypted tunnel to idOS, if needed. */\n relayTunnelKey: Uint8Array;\n};\n\n/**\n * The same material with byte fields base64url-encoded, matching the wire\n * shapes in the architecture doc (`storage_id` as an opaque id, public key as a\n * \"base64url public key\"). Secret material is intentionally omitted.\n */\nexport type EncodedUkycClientMaterial = {\n storageId: string;\n signingPublicKey: string;\n};\n\n/**\n * Derives a single labeled value from `local_user_secret`.\n *\n * No salt is used: `local_user_secret` is already a high-entropy\n * uniformly-random secret, so per-output domain separation comes entirely from\n * the `info` label.\n *\n * @param localUserSecret - The root `local_user_secret` bytes.\n * @param info - Domain-separation label for this output.\n * @param length - Desired output length in bytes.\n * @returns The derived bytes.\n */\nfunction deriveLabeled(\n localUserSecret: Uint8Array,\n info: string,\n length: number,\n): Uint8Array {\n return hkdf(sha256, localUserSecret, undefined, stringToBytes(info), length);\n}\n\n/**\n * Derives all UKYC client material from the root `local_user_secret`.\n *\n * This is a pure function of `local_user_secret`: the same input always yields\n * the same outputs, which is what makes `storage_id` and `signing_key` stable\n * across sessions and devices.\n *\n * @param localUserSecret - The `local_user_secret` produced by\n * `getOrCreateLocalUserSecret`.\n * @returns The derived {@link UkycClientMaterial}.\n */\nexport function deriveClientMaterial(\n localUserSecret: Uint8Array,\n): UkycClientMaterial {\n const storageId = deriveLabeled(\n localUserSecret,\n UKYC_KDF_INFO.storageId,\n UKYC_DERIVED_KEY_SIZES.storageId,\n );\n\n const dataEncryptionKey = deriveLabeled(\n localUserSecret,\n UKYC_KDF_INFO.dataEncryptionKey,\n UKYC_DERIVED_KEY_SIZES.dataEncryptionKey,\n );\n\n const signingKey = deriveLabeled(\n localUserSecret,\n UKYC_KDF_INFO.signingKey,\n UKYC_DERIVED_KEY_SIZES.signingKey,\n );\n\n const relayTunnelKey = deriveLabeled(\n localUserSecret,\n UKYC_KDF_INFO.relayTunnelKey,\n UKYC_DERIVED_KEY_SIZES.relayTunnelKey,\n );\n\n const signingPublicKey = ed25519.getPublicKey(signingKey);\n\n return {\n storageId,\n dataEncryptionKey,\n signingKey,\n signingPublicKey,\n relayTunnelKey,\n };\n}\n\n/**\n * Encodes the non-secret client material into the base64url wire shapes used by\n * the UKYC storage API (`storage_id` and `signing_public_key`).\n *\n * @param material - The derived client material.\n * @returns The base64url-encoded, non-secret fields.\n */\nexport function encodeClientMaterial(\n material: UkycClientMaterial,\n): EncodedUkycClientMaterial {\n return {\n storageId: toBase64Url(material.storageId),\n signingPublicKey: toBase64Url(material.signingPublicKey),\n };\n}\n"]}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Derives UKYC client material from the root `local_user_secret` using
3
+ * HKDF-SHA256 with domain-separated `info` labels — see the architecture doc,
4
+ * section "Client-Derived Material".
5
+ */
6
+ /**
7
+ * The set of values derived from `local_user_secret`.
8
+ */
9
+ export type UkycClientMaterial = {
10
+ /** Opaque lookup key for the encrypted KYC object. */
11
+ storageId: Uint8Array;
12
+ /** Symmetric key that encrypts `encrypted_kyc_data` (or wraps per-blob keys). */
13
+ dataEncryptionKey: Uint8Array;
14
+ /**
15
+ * Ed25519 private key used to sign `storage_access_token` capabilities. For
16
+ * Ed25519 the 32-byte HKDF output *is* the private key. The private half
17
+ * never leaves the device.
18
+ */
19
+ signingKey: Uint8Array;
20
+ /** Public half of `signingKey`, registered with the object on first write. */
21
+ signingPublicKey: Uint8Array;
22
+ /** Key for establishing/authenticating the encrypted tunnel to idOS, if needed. */
23
+ relayTunnelKey: Uint8Array;
24
+ };
25
+ /**
26
+ * The same material with byte fields base64url-encoded, matching the wire
27
+ * shapes in the architecture doc (`storage_id` as an opaque id, public key as a
28
+ * "base64url public key"). Secret material is intentionally omitted.
29
+ */
30
+ export type EncodedUkycClientMaterial = {
31
+ storageId: string;
32
+ signingPublicKey: string;
33
+ };
34
+ /**
35
+ * Derives all UKYC client material from the root `local_user_secret`.
36
+ *
37
+ * This is a pure function of `local_user_secret`: the same input always yields
38
+ * the same outputs, which is what makes `storage_id` and `signing_key` stable
39
+ * across sessions and devices.
40
+ *
41
+ * @param localUserSecret - The `local_user_secret` produced by
42
+ * `getOrCreateLocalUserSecret`.
43
+ * @returns The derived {@link UkycClientMaterial}.
44
+ */
45
+ export declare function deriveClientMaterial(localUserSecret: Uint8Array): UkycClientMaterial;
46
+ /**
47
+ * Encodes the non-secret client material into the base64url wire shapes used by
48
+ * the UKYC storage API (`storage_id` and `signing_public_key`).
49
+ *
50
+ * @param material - The derived client material.
51
+ * @returns The base64url-encoded, non-secret fields.
52
+ */
53
+ export declare function encodeClientMaterial(material: UkycClientMaterial): EncodedUkycClientMaterial;
54
+ //# sourceMappingURL=deriveClientMaterial.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deriveClientMaterial.d.cts","sourceRoot":"","sources":["../../src/ukyc/deriveClientMaterial.ts"],"names":[],"mappings":"AAQA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,sDAAsD;IACtD,SAAS,EAAE,UAAU,CAAC;IACtB,iFAAiF;IACjF,iBAAiB,EAAE,UAAU,CAAC;IAC9B;;;;OAIG;IACH,UAAU,EAAE,UAAU,CAAC;IACvB,8EAA8E;IAC9E,gBAAgB,EAAE,UAAU,CAAC;IAC7B,mFAAmF;IACnF,cAAc,EAAE,UAAU,CAAC;CAC5B,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAsBF;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,eAAe,EAAE,UAAU,GAC1B,kBAAkB,CAkCpB;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,kBAAkB,GAC3B,yBAAyB,CAK3B"}