@zkpassport/sdk 0.5.6 → 0.5.7-beta.10
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/dist/cjs/index.cjs +3169 -0
- package/dist/cjs/{index.d.ts → index.d.cts} +14 -10
- package/dist/cjs/logger.cjs +47 -0
- package/dist/cjs/{logger.d.ts → logger.d.cts} +4 -2
- package/dist/esm/chunk-AFLQN3AC.js +22 -0
- package/dist/esm/index.d.ts +14 -10
- package/dist/esm/index.js +3069 -2235
- package/dist/esm/logger.d.ts +4 -2
- package/dist/esm/logger.js +7 -11
- package/package.json +34 -37
- package/dist/cjs/assets/abi/ZKPassportVerifier.json +0 -744
- package/dist/cjs/encryption.d.ts +0 -7
- package/dist/cjs/encryption.js +0 -79
- package/dist/cjs/index.js +0 -2345
- package/dist/cjs/json-rpc.d.ts +0 -6
- package/dist/cjs/json-rpc.js +0 -47
- package/dist/cjs/logger.js +0 -15
- package/dist/cjs/mobile.d.ts +0 -39
- package/dist/cjs/mobile.js +0 -130
- package/dist/cjs/websocket.d.ts +0 -2
- package/dist/cjs/websocket.js +0 -18
- package/dist/esm/assets/abi/ZKPassportVerifier.json +0 -744
- package/dist/esm/encryption.d.ts +0 -7
- package/dist/esm/encryption.js +0 -40
- package/dist/esm/json-rpc.d.ts +0 -6
- package/dist/esm/json-rpc.js +0 -41
- package/dist/esm/mobile.d.ts +0 -39
- package/dist/esm/mobile.js +0 -126
- package/dist/esm/websocket.d.ts +0 -2
- package/dist/esm/websocket.js +0 -15
- package/src/assets/abi/ZKPassportVerifier.json +0 -744
- package/src/index.ts +0 -3174
- package/src/logger.ts +0 -13
- package/tsconfig.json +0 -24
package/dist/cjs/encryption.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare function generateECDHKeyPair(): Promise<{
|
|
2
|
-
privateKey: import("@noble/secp256k1").Bytes;
|
|
3
|
-
publicKey: import("@noble/secp256k1").Bytes;
|
|
4
|
-
}>;
|
|
5
|
-
export declare function getSharedSecret(privateKey: string, publicKey: string): Promise<Uint8Array<ArrayBuffer>>;
|
|
6
|
-
export declare function encrypt(message: string, sharedSecret: Uint8Array, topic: string): Promise<Uint8Array<ArrayBufferLike>>;
|
|
7
|
-
export declare function decrypt(ciphertext: Uint8Array, sharedSecret: Uint8Array, topic: string): Promise<string>;
|
package/dist/cjs/encryption.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.generateECDHKeyPair = generateECDHKeyPair;
|
|
37
|
-
exports.getSharedSecret = getSharedSecret;
|
|
38
|
-
exports.encrypt = encrypt;
|
|
39
|
-
exports.decrypt = decrypt;
|
|
40
|
-
const aes_1 = require("@noble/ciphers/aes");
|
|
41
|
-
const utils_1 = require("@noble/ciphers/utils");
|
|
42
|
-
async function sha256Truncate(topic) {
|
|
43
|
-
const encoder = new TextEncoder();
|
|
44
|
-
const data = encoder.encode(topic);
|
|
45
|
-
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
|
|
46
|
-
const fullHashArray = new Uint8Array(hashBuffer);
|
|
47
|
-
const truncatedHashArray = fullHashArray.slice(0, 12);
|
|
48
|
-
return truncatedHashArray;
|
|
49
|
-
}
|
|
50
|
-
async function generateECDHKeyPair() {
|
|
51
|
-
const secp256k1 = await Promise.resolve().then(() => __importStar(require("@noble/secp256k1")));
|
|
52
|
-
const privKey = secp256k1.utils.randomPrivateKey();
|
|
53
|
-
const pubKey = secp256k1.getPublicKey(privKey);
|
|
54
|
-
return {
|
|
55
|
-
privateKey: privKey,
|
|
56
|
-
publicKey: pubKey,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
async function getSharedSecret(privateKey, publicKey) {
|
|
60
|
-
const secp256k1 = await Promise.resolve().then(() => __importStar(require("@noble/secp256k1")));
|
|
61
|
-
const sharedSecret = secp256k1.getSharedSecret(privateKey, publicKey);
|
|
62
|
-
return sharedSecret.slice(0, 32);
|
|
63
|
-
}
|
|
64
|
-
async function encrypt(message, sharedSecret, topic) {
|
|
65
|
-
// Nonce must be 12 bytes
|
|
66
|
-
const nonce = await sha256Truncate(topic);
|
|
67
|
-
const aes = (0, aes_1.gcm)(sharedSecret, nonce);
|
|
68
|
-
const data = (0, utils_1.utf8ToBytes)(message);
|
|
69
|
-
const ciphertext = aes.encrypt(data);
|
|
70
|
-
return ciphertext;
|
|
71
|
-
}
|
|
72
|
-
async function decrypt(ciphertext, sharedSecret, topic) {
|
|
73
|
-
// Nonce must be 12 bytes
|
|
74
|
-
const nonce = await sha256Truncate(topic);
|
|
75
|
-
const aes = (0, aes_1.gcm)(sharedSecret, nonce);
|
|
76
|
-
const data = aes.decrypt(ciphertext);
|
|
77
|
-
const dataString = new TextDecoder().decode(data);
|
|
78
|
-
return dataString;
|
|
79
|
-
}
|