@metamask-previews/kyc-controller 0.0.0-preview-e68ab1498 → 0.0.0-preview-4b37525
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 +7 -1
- package/dist/KycController-method-action-types.cjs.map +1 -1
- package/dist/KycController-method-action-types.d.cts +12 -6
- package/dist/KycController-method-action-types.d.cts.map +1 -1
- package/dist/KycController-method-action-types.d.mts +12 -6
- package/dist/KycController-method-action-types.d.mts.map +1 -1
- package/dist/KycController-method-action-types.mjs.map +1 -1
- package/dist/KycController.cjs +313 -72
- package/dist/KycController.cjs.map +1 -1
- package/dist/KycController.d.cts +27 -7
- package/dist/KycController.d.cts.map +1 -1
- package/dist/KycController.d.mts +27 -7
- package/dist/KycController.d.mts.map +1 -1
- package/dist/KycController.mjs +314 -73
- package/dist/KycController.mjs.map +1 -1
- package/dist/KycService-method-action-types.cjs.map +1 -1
- package/dist/KycService-method-action-types.d.cts +60 -31
- package/dist/KycService-method-action-types.d.cts.map +1 -1
- package/dist/KycService-method-action-types.d.mts +60 -31
- package/dist/KycService-method-action-types.d.mts.map +1 -1
- package/dist/KycService-method-action-types.mjs.map +1 -1
- package/dist/KycService.cjs +140 -75
- package/dist/KycService.cjs.map +1 -1
- package/dist/KycService.d.cts +181 -74
- package/dist/KycService.d.cts.map +1 -1
- package/dist/KycService.d.mts +181 -74
- package/dist/KycService.d.mts.map +1 -1
- package/dist/KycService.mjs +140 -75
- package/dist/KycService.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +49 -4
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +49 -4
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/ukyc/jwtChain.cjs +1 -1
- package/dist/ukyc/jwtChain.cjs.map +1 -1
- package/dist/ukyc/jwtChain.d.cts +2 -2
- package/dist/ukyc/jwtChain.d.mts +2 -2
- package/dist/ukyc/jwtChain.mjs +1 -1
- package/dist/ukyc/jwtChain.mjs.map +1 -1
- package/dist/ukyc/wrapEncryptionKey.cjs +16 -7
- package/dist/ukyc/wrapEncryptionKey.cjs.map +1 -1
- package/dist/ukyc/wrapEncryptionKey.d.cts +23 -16
- package/dist/ukyc/wrapEncryptionKey.d.cts.map +1 -1
- package/dist/ukyc/wrapEncryptionKey.d.mts +23 -16
- package/dist/ukyc/wrapEncryptionKey.d.mts.map +1 -1
- package/dist/ukyc/wrapEncryptionKey.mjs +16 -7
- package/dist/ukyc/wrapEncryptionKey.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,34 +1,41 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Wraps
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Wraps a secret for the UKYC session server using NaCl's `crypto_box`
|
|
3
|
+
* (X25519 + XSalsa20-Poly1305) established with a per-secret wrapping key
|
|
4
|
+
* returned inside an encryption schema from `createUkycSession`.
|
|
5
5
|
*
|
|
6
6
|
* Unlike {@link wrapUserKey} (which generates a fresh ephemeral keypair per
|
|
7
|
-
* call), this
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* call), this reuses a session client keypair. There is no prior wrapping-key
|
|
8
|
+
* exchange to register that public key, so `data` is
|
|
9
|
+
* `clientPublicKey (32) || ciphertext+tag` and only `{ data, nonce }` need be
|
|
10
|
+
* transmitted. Used for both the `data_encryption_key` and the
|
|
11
|
+
* `ukyc_capability_token`.
|
|
11
12
|
*/
|
|
12
13
|
/**
|
|
13
|
-
* The transmitted portion of a wrapped
|
|
14
|
-
* ciphertext (which includes the 16-byte Poly1305 auth
|
|
15
|
-
* both unpadded base64url-encoded.
|
|
14
|
+
* The transmitted portion of a wrapped secret: the sender public key prefixed
|
|
15
|
+
* to the `crypto_box` ciphertext (which includes the 16-byte Poly1305 auth
|
|
16
|
+
* tag), and the nonce, both unpadded base64url-encoded. Matches the KYC API
|
|
17
|
+
* `CapabilityAuthorization` wire shape.
|
|
16
18
|
*/
|
|
17
19
|
export type WrappedEncryptionKeyParts = {
|
|
18
|
-
|
|
20
|
+
data: string;
|
|
19
21
|
nonce: string;
|
|
20
22
|
};
|
|
21
23
|
/**
|
|
22
|
-
* Wraps `
|
|
24
|
+
* Wraps `plaintext` for the UKYC session server.
|
|
23
25
|
*
|
|
24
26
|
* The box is sealed with NaCl's `crypto_box`, keyed by the X25519 shared secret
|
|
25
27
|
* between our session client private key and the session server public key
|
|
26
|
-
*
|
|
28
|
+
* from an encryption schema (`encryptionDataKey` or `ukycCapabilityToken`)
|
|
29
|
+
* returned by `createUkycSession`. The 32-byte client public key is prefixed
|
|
30
|
+
* onto `data` so the server can open the box without a prior key-registration
|
|
31
|
+
* step.
|
|
27
32
|
*
|
|
28
33
|
* @param sessionClientPrivateKey - Our session's X25519 private key.
|
|
29
34
|
* @param sessionServerPublicKey - The server's X25519 public key (base64url).
|
|
30
|
-
* @param
|
|
31
|
-
*
|
|
35
|
+
* @param plaintext - The raw bytes to encrypt (e.g. the `data_encryption_key`
|
|
36
|
+
* or the encoded `ukyc_capability_token`).
|
|
37
|
+
* @returns The base64url `data` (`clientPublicKey || ciphertext+tag`) and
|
|
38
|
+
* `nonce`.
|
|
32
39
|
*/
|
|
33
|
-
export declare function wrapEncryptionKey(sessionClientPrivateKey: Uint8Array, sessionServerPublicKey: string,
|
|
40
|
+
export declare function wrapEncryptionKey(sessionClientPrivateKey: Uint8Array, sessionServerPublicKey: string, plaintext: Uint8Array): WrappedEncryptionKeyParts;
|
|
34
41
|
//# sourceMappingURL=wrapEncryptionKey.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapEncryptionKey.d.mts","sourceRoot":"","sources":["../../src/ukyc/wrapEncryptionKey.ts"],"names":[],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"wrapEncryptionKey.d.mts","sourceRoot":"","sources":["../../src/ukyc/wrapEncryptionKey.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAC/B,uBAAuB,EAAE,UAAU,EACnC,sBAAsB,EAAE,MAAM,EAC9B,SAAS,EAAE,UAAU,GACpB,yBAAyB,CAmB3B"}
|
|
@@ -2,23 +2,32 @@ import $tweetnacl from "tweetnacl";
|
|
|
2
2
|
const { randomBytes, box } = $tweetnacl;
|
|
3
3
|
import { base64UrlToBytes, toBase64Url } from "../encoding.mjs";
|
|
4
4
|
/**
|
|
5
|
-
* Wraps `
|
|
5
|
+
* Wraps `plaintext` for the UKYC session server.
|
|
6
6
|
*
|
|
7
7
|
* The box is sealed with NaCl's `crypto_box`, keyed by the X25519 shared secret
|
|
8
8
|
* between our session client private key and the session server public key
|
|
9
|
-
*
|
|
9
|
+
* from an encryption schema (`encryptionDataKey` or `ukycCapabilityToken`)
|
|
10
|
+
* returned by `createUkycSession`. The 32-byte client public key is prefixed
|
|
11
|
+
* onto `data` so the server can open the box without a prior key-registration
|
|
12
|
+
* step.
|
|
10
13
|
*
|
|
11
14
|
* @param sessionClientPrivateKey - Our session's X25519 private key.
|
|
12
15
|
* @param sessionServerPublicKey - The server's X25519 public key (base64url).
|
|
13
|
-
* @param
|
|
14
|
-
*
|
|
16
|
+
* @param plaintext - The raw bytes to encrypt (e.g. the `data_encryption_key`
|
|
17
|
+
* or the encoded `ukyc_capability_token`).
|
|
18
|
+
* @returns The base64url `data` (`clientPublicKey || ciphertext+tag`) and
|
|
19
|
+
* `nonce`.
|
|
15
20
|
*/
|
|
16
|
-
export function wrapEncryptionKey(sessionClientPrivateKey, sessionServerPublicKey,
|
|
21
|
+
export function wrapEncryptionKey(sessionClientPrivateKey, sessionServerPublicKey, plaintext) {
|
|
17
22
|
const serverPublicKey = base64UrlToBytes(sessionServerPublicKey);
|
|
23
|
+
const { publicKey: clientPublicKey } = box.keyPair.fromSecretKey(sessionClientPrivateKey);
|
|
18
24
|
const nonce = randomBytes(box.nonceLength);
|
|
19
|
-
const
|
|
25
|
+
const ciphertext = box(plaintext, nonce, serverPublicKey, sessionClientPrivateKey);
|
|
26
|
+
const data = new Uint8Array(clientPublicKey.length + ciphertext.length);
|
|
27
|
+
data.set(clientPublicKey, 0);
|
|
28
|
+
data.set(ciphertext, clientPublicKey.length);
|
|
20
29
|
return {
|
|
21
|
-
|
|
30
|
+
data: toBase64Url(data),
|
|
22
31
|
nonce: toBase64Url(nonce),
|
|
23
32
|
};
|
|
24
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapEncryptionKey.mjs","sourceRoot":"","sources":["../../src/ukyc/wrapEncryptionKey.ts"],"names":[],"mappings":";;AAEA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,wBAAuB;
|
|
1
|
+
{"version":3,"file":"wrapEncryptionKey.mjs","sourceRoot":"","sources":["../../src/ukyc/wrapEncryptionKey.ts"],"names":[],"mappings":";;AAEA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,wBAAuB;AA0B/D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,iBAAiB,CAC/B,uBAAmC,EACnC,sBAA8B,EAC9B,SAAqB;IAErB,MAAM,eAAe,GAAG,gBAAgB,CAAC,sBAAsB,CAAC,CAAC;IACjE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAC9D,uBAAuB,CACxB,CAAC;IACF,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC3C,MAAM,UAAU,GAAG,GAAG,CACpB,SAAS,EACT,KAAK,EACL,eAAe,EACf,uBAAuB,CACxB,CAAC;IACF,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,eAAe,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IACxE,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC;IAC7B,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;IAC7C,OAAO;QACL,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC;QACvB,KAAK,EAAE,WAAW,CAAC,KAAK,CAAC;KAC1B,CAAC;AACJ,CAAC","sourcesContent":["import { randomBytes, box } from 'tweetnacl';\n\nimport { base64UrlToBytes, toBase64Url } from '../encoding.js';\n\n/**\n * Wraps a secret for the UKYC session server using NaCl's `crypto_box`\n * (X25519 + XSalsa20-Poly1305) established with a per-secret wrapping key\n * returned inside an encryption schema from `createUkycSession`.\n *\n * Unlike {@link wrapUserKey} (which generates a fresh ephemeral keypair per\n * call), this reuses a session client keypair. There is no prior wrapping-key\n * exchange to register that public key, so `data` is\n * `clientPublicKey (32) || ciphertext+tag` and only `{ data, nonce }` need be\n * transmitted. Used for both the `data_encryption_key` and the\n * `ukyc_capability_token`.\n */\n\n/**\n * The transmitted portion of a wrapped secret: the sender public key prefixed\n * to the `crypto_box` ciphertext (which includes the 16-byte Poly1305 auth\n * tag), and the nonce, both unpadded base64url-encoded. Matches the KYC API\n * `CapabilityAuthorization` wire shape.\n */\nexport type WrappedEncryptionKeyParts = {\n data: string;\n nonce: string;\n};\n\n/**\n * Wraps `plaintext` for the UKYC session server.\n *\n * The box is sealed with NaCl's `crypto_box`, keyed by the X25519 shared secret\n * between our session client private key and the session server public key\n * from an encryption schema (`encryptionDataKey` or `ukycCapabilityToken`)\n * returned by `createUkycSession`. The 32-byte client public key is prefixed\n * onto `data` so the server can open the box without a prior key-registration\n * step.\n *\n * @param sessionClientPrivateKey - Our session's X25519 private key.\n * @param sessionServerPublicKey - The server's X25519 public key (base64url).\n * @param plaintext - The raw bytes to encrypt (e.g. the `data_encryption_key`\n * or the encoded `ukyc_capability_token`).\n * @returns The base64url `data` (`clientPublicKey || ciphertext+tag`) and\n * `nonce`.\n */\nexport function wrapEncryptionKey(\n sessionClientPrivateKey: Uint8Array,\n sessionServerPublicKey: string,\n plaintext: Uint8Array,\n): WrappedEncryptionKeyParts {\n const serverPublicKey = base64UrlToBytes(sessionServerPublicKey);\n const { publicKey: clientPublicKey } = box.keyPair.fromSecretKey(\n sessionClientPrivateKey,\n );\n const nonce = randomBytes(box.nonceLength);\n const ciphertext = box(\n plaintext,\n nonce,\n serverPublicKey,\n sessionClientPrivateKey,\n );\n const data = new Uint8Array(clientPublicKey.length + ciphertext.length);\n data.set(clientPublicKey, 0);\n data.set(ciphertext, clientPublicKey.length);\n return {\n data: toBase64Url(data),\n nonce: toBase64Url(nonce),\n };\n}\n"]}
|
package/package.json
CHANGED