@zkpassport/sdk 0.2.1 → 0.2.3
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/encryption.d.ts +4 -4
- package/dist/cjs/encryption.js +10 -20
- package/dist/cjs/index.d.ts +7 -7
- package/dist/cjs/index.js +150 -124
- package/dist/cjs/json-rpc.d.ts +2 -2
- package/dist/cjs/json-rpc.js +11 -12
- package/dist/cjs/logger.d.ts +7 -2
- package/dist/cjs/logger.js +8 -32
- package/dist/cjs/mobile.js +23 -24
- package/dist/cjs/websocket.js +3 -3
- package/dist/esm/encryption.d.ts +4 -4
- package/dist/esm/encryption.js +5 -5
- package/dist/esm/index.d.ts +7 -7
- package/dist/esm/index.js +132 -128
- package/dist/esm/json-rpc.d.ts +2 -2
- package/dist/esm/json-rpc.js +13 -13
- package/dist/esm/logger.d.ts +7 -2
- package/dist/esm/logger.js +7 -32
- package/dist/esm/mobile.js +25 -25
- package/dist/esm/websocket.js +3 -3
- package/package.json +17 -7
- package/src/encryption.ts +5 -5
- package/src/index.ts +144 -140
- package/src/json-rpc.ts +15 -15
- package/src/logger.ts +7 -38
- package/src/mobile.ts +26 -26
- package/src/websocket.ts +4 -4
package/dist/cjs/encryption.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare function generateECDHKeyPair(): Promise<{
|
|
2
|
-
privateKey:
|
|
3
|
-
publicKey:
|
|
2
|
+
privateKey: Uint8Array;
|
|
3
|
+
publicKey: Uint8Array;
|
|
4
4
|
}>;
|
|
5
|
-
export declare function getSharedSecret(privateKey: string, publicKey: string): Promise<Uint8Array
|
|
6
|
-
export declare function encrypt(message: string, sharedSecret: Uint8Array, topic: string): Promise<Uint8Array
|
|
5
|
+
export declare function getSharedSecret(privateKey: string, publicKey: string): Promise<Uint8Array>;
|
|
6
|
+
export declare function encrypt(message: string, sharedSecret: Uint8Array, topic: string): Promise<Uint8Array>;
|
|
7
7
|
export declare function decrypt(ciphertext: Uint8Array, sharedSecret: Uint8Array, topic: string): Promise<string>;
|
package/dist/cjs/encryption.js
CHANGED
|
@@ -15,23 +15,13 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) ||
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
})();
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
35
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
26
|
exports.generateECDHKeyPair = generateECDHKeyPair;
|
|
37
27
|
exports.getSharedSecret = getSharedSecret;
|
|
@@ -42,13 +32,13 @@ const utils_1 = require("@noble/ciphers/utils");
|
|
|
42
32
|
async function sha256Truncate(topic) {
|
|
43
33
|
const encoder = new TextEncoder();
|
|
44
34
|
const data = encoder.encode(topic);
|
|
45
|
-
const hashBuffer = await crypto.subtle.digest(
|
|
35
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
|
|
46
36
|
const fullHashArray = new Uint8Array(hashBuffer);
|
|
47
37
|
const truncatedHashArray = fullHashArray.slice(0, 12);
|
|
48
38
|
return truncatedHashArray;
|
|
49
39
|
}
|
|
50
40
|
async function generateECDHKeyPair() {
|
|
51
|
-
const secp256k1 = await Promise.resolve().then(() => __importStar(require(
|
|
41
|
+
const secp256k1 = await Promise.resolve().then(() => __importStar(require("@noble/secp256k1")));
|
|
52
42
|
const privKey = secp256k1.utils.randomPrivateKey();
|
|
53
43
|
const pubKey = secp256k1.getPublicKey(privKey);
|
|
54
44
|
return {
|
|
@@ -57,7 +47,7 @@ async function generateECDHKeyPair() {
|
|
|
57
47
|
};
|
|
58
48
|
}
|
|
59
49
|
async function getSharedSecret(privateKey, publicKey) {
|
|
60
|
-
const secp256k1 = await Promise.resolve().then(() => __importStar(require(
|
|
50
|
+
const secp256k1 = await Promise.resolve().then(() => __importStar(require("@noble/secp256k1")));
|
|
61
51
|
const sharedSecret = secp256k1.getSharedSecret(privateKey, publicKey);
|
|
62
52
|
return sharedSecret.slice(0, 32);
|
|
63
53
|
}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type DisclosableIDCredential, type IDCredential, type IDCredentialValue, type NumericalIDCredential, type ProofResult, type QueryResult } from
|
|
2
|
-
export type * from
|
|
3
|
-
export { SANCTIONED_COUNTRIES, EU_COUNTRIES, EEA_COUNTRIES, SCHENGEN_COUNTRIES, ASEAN_COUNTRIES, MERCOSUR_COUNTRIES, } from
|
|
1
|
+
import { type DisclosableIDCredential, type IDCredential, type IDCredentialValue, type NumericalIDCredential, type ProofResult, type QueryResult } from "@zkpassport/utils";
|
|
2
|
+
export type * from "@zkpassport/utils";
|
|
3
|
+
export { SANCTIONED_COUNTRIES, EU_COUNTRIES, EEA_COUNTRIES, SCHENGEN_COUNTRIES, ASEAN_COUNTRIES, MERCOSUR_COUNTRIES, } from "@zkpassport/utils";
|
|
4
4
|
export type QueryBuilderResult = {
|
|
5
5
|
/**
|
|
6
6
|
* The URL of the request.
|
|
@@ -85,13 +85,13 @@ export type QueryBuilder = {
|
|
|
85
85
|
* @param key The attribute to compare.
|
|
86
86
|
* @param value The value of the attribute you require.
|
|
87
87
|
*/
|
|
88
|
-
lte: <T extends
|
|
88
|
+
lte: <T extends "birthdate" | "expiry_date">(key: T, value: IDCredentialValue<T>) => QueryBuilder;
|
|
89
89
|
/**
|
|
90
90
|
* Requires this attribute to be less than the provided value.
|
|
91
91
|
* @param key The attribute to compare.
|
|
92
92
|
* @param value The value of the attribute you require.
|
|
93
93
|
*/
|
|
94
|
-
lt: <T extends
|
|
94
|
+
lt: <T extends "age">(key: T, value: IDCredentialValue<T>) => QueryBuilder;
|
|
95
95
|
/**
|
|
96
96
|
* Requires this attribute to be included in the provided range.
|
|
97
97
|
* @param key The attribute to compare.
|
|
@@ -104,13 +104,13 @@ export type QueryBuilder = {
|
|
|
104
104
|
* @param key The attribute to compare.
|
|
105
105
|
* @param value The list of values to check inclusion against.
|
|
106
106
|
*/
|
|
107
|
-
in: <T extends
|
|
107
|
+
in: <T extends "nationality">(key: T, value: IDCredentialValue<T>[]) => QueryBuilder;
|
|
108
108
|
/**
|
|
109
109
|
* Requires this attribute to be excluded from the provided list.
|
|
110
110
|
* @param key The attribute to compare.
|
|
111
111
|
* @param value The list of values to check exclusion against.
|
|
112
112
|
*/
|
|
113
|
-
out: <T extends
|
|
113
|
+
out: <T extends "nationality">(key: T, value: IDCredentialValue<T>[]) => QueryBuilder;
|
|
114
114
|
/**
|
|
115
115
|
* Requires this attribute to be disclosed.
|
|
116
116
|
* @param key The attribute to disclose.
|