@0xpolygonid/js-sdk 1.10.4 → 1.11.0
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/README.md +11 -0
- package/dist/browser/esm/index.js +8360 -17398
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.js +8381 -17414
- package/dist/browser/umd/index.js.map +1 -1
- package/dist/node/cjs/blockchain/index.js +17 -0
- package/dist/node/cjs/blockchain/transaction-service.js +55 -0
- package/dist/node/cjs/credentials/credential-wallet.js +1 -1
- package/dist/node/cjs/credentials/status/reverse-sparse-merkle-tree.js +5 -1
- package/dist/node/cjs/iden3comm/handlers/auth.js +62 -27
- package/dist/node/cjs/iden3comm/handlers/common.js +4 -4
- package/dist/node/cjs/iden3comm/handlers/contract-request.js +34 -15
- package/dist/node/cjs/iden3comm/handlers/credential-proposal.js +33 -14
- package/dist/node/cjs/iden3comm/handlers/fetch.js +65 -34
- package/dist/node/cjs/iden3comm/handlers/index.js +1 -0
- package/dist/node/cjs/iden3comm/handlers/message-handler.js +96 -0
- package/dist/node/cjs/iden3comm/handlers/revocation-status.js +58 -30
- package/dist/node/cjs/iden3comm/packageManager.js +16 -0
- package/dist/node/cjs/iden3comm/packers/jws.js +63 -49
- package/dist/node/cjs/iden3comm/packers/plain.js +13 -3
- package/dist/node/cjs/iden3comm/packers/zkp.js +9 -0
- package/dist/node/cjs/iden3comm/utils/did.js +11 -11
- package/dist/node/cjs/identity/identity-wallet.js +228 -43
- package/dist/node/cjs/index.js +1 -0
- package/dist/node/cjs/kms/key-providers/bjj-provider.js +9 -0
- package/dist/node/cjs/kms/key-providers/ed25519-provider.js +13 -1
- package/dist/node/cjs/kms/key-providers/index.js +1 -1
- package/dist/node/cjs/kms/key-providers/{sec256k1-provider.js → secp256k1-provider.js} +37 -26
- package/dist/node/cjs/kms/kms.js +15 -0
- package/dist/node/cjs/proof/proof-service.js +3 -33
- package/dist/node/cjs/proof/provers/inputs-generator.js +2 -7
- package/dist/node/cjs/storage/blockchain/onchain-revocation.js +4 -12
- package/dist/node/cjs/storage/blockchain/onchain-zkp-verifier.js +3 -10
- package/dist/node/cjs/storage/blockchain/state.js +39 -10
- package/dist/node/cjs/utils/did-helper.js +36 -2
- package/dist/node/cjs/verifiable/constants.js +2 -1
- package/dist/node/esm/blockchain/index.js +1 -0
- package/dist/node/esm/blockchain/transaction-service.js +51 -0
- package/dist/node/esm/credentials/credential-wallet.js +1 -1
- package/dist/node/esm/credentials/status/reverse-sparse-merkle-tree.js +6 -2
- package/dist/node/esm/iden3comm/handlers/auth.js +62 -27
- package/dist/node/esm/iden3comm/handlers/common.js +4 -4
- package/dist/node/esm/iden3comm/handlers/contract-request.js +34 -15
- package/dist/node/esm/iden3comm/handlers/credential-proposal.js +33 -14
- package/dist/node/esm/iden3comm/handlers/fetch.js +65 -34
- package/dist/node/esm/iden3comm/handlers/index.js +1 -0
- package/dist/node/esm/iden3comm/handlers/message-handler.js +91 -0
- package/dist/node/esm/iden3comm/handlers/revocation-status.js +58 -30
- package/dist/node/esm/iden3comm/packageManager.js +16 -0
- package/dist/node/esm/iden3comm/packers/jws.js +63 -49
- package/dist/node/esm/iden3comm/packers/plain.js +13 -3
- package/dist/node/esm/iden3comm/packers/zkp.js +9 -0
- package/dist/node/esm/iden3comm/utils/did.js +11 -8
- package/dist/node/esm/identity/identity-wallet.js +230 -45
- package/dist/node/esm/index.js +1 -0
- package/dist/node/esm/kms/key-providers/bjj-provider.js +10 -1
- package/dist/node/esm/kms/key-providers/ed25519-provider.js +13 -1
- package/dist/node/esm/kms/key-providers/index.js +1 -1
- package/dist/node/esm/kms/key-providers/secp256k1-provider.js +85 -0
- package/dist/node/esm/kms/kms.js +15 -0
- package/dist/node/esm/proof/proof-service.js +4 -34
- package/dist/node/esm/proof/provers/inputs-generator.js +3 -8
- package/dist/node/esm/storage/blockchain/onchain-revocation.js +4 -12
- package/dist/node/esm/storage/blockchain/onchain-zkp-verifier.js +3 -10
- package/dist/node/esm/storage/blockchain/state.js +39 -10
- package/dist/node/esm/utils/did-helper.js +33 -1
- package/dist/node/esm/verifiable/constants.js +2 -1
- package/dist/types/blockchain/index.d.ts +1 -0
- package/dist/types/blockchain/transaction-service.d.ts +80 -0
- package/dist/types/iden3comm/handlers/auth.d.ts +17 -2
- package/dist/types/iden3comm/handlers/common.d.ts +2 -2
- package/dist/types/iden3comm/handlers/contract-request.d.ts +10 -2
- package/dist/types/iden3comm/handlers/credential-proposal.d.ts +5 -2
- package/dist/types/iden3comm/handlers/fetch.d.ts +15 -6
- package/dist/types/iden3comm/handlers/index.d.ts +1 -0
- package/dist/types/iden3comm/handlers/message-handler.d.ts +83 -0
- package/dist/types/iden3comm/handlers/revocation-status.d.ts +18 -2
- package/dist/types/iden3comm/packageManager.d.ts +10 -0
- package/dist/types/iden3comm/packers/jws.d.ts +9 -0
- package/dist/types/iden3comm/packers/plain.d.ts +10 -2
- package/dist/types/iden3comm/packers/zkp.d.ts +7 -0
- package/dist/types/iden3comm/types/packageManager.d.ts +10 -0
- package/dist/types/iden3comm/types/packer.d.ts +24 -2
- package/dist/types/iden3comm/types/protocol/auth.d.ts +5 -15
- package/dist/types/iden3comm/types/protocol/contract-request.d.ts +2 -6
- package/dist/types/iden3comm/types/protocol/credentials.d.ts +7 -44
- package/dist/types/iden3comm/types/protocol/messages.d.ts +2 -9
- package/dist/types/iden3comm/types/protocol/proof.d.ts +3 -16
- package/dist/types/iden3comm/types/protocol/revocation.d.ts +3 -16
- package/dist/types/identity/identity-wallet.d.ts +80 -7
- package/dist/types/index.d.ts +1 -0
- package/dist/types/kms/key-providers/bjj-provider.d.ts +1 -0
- package/dist/types/kms/key-providers/ed25519-provider.d.ts +8 -0
- package/dist/types/kms/key-providers/index.d.ts +1 -1
- package/dist/types/kms/key-providers/{sec256k1-provider.d.ts → secp256k1-provider.d.ts} +15 -9
- package/dist/types/kms/kms.d.ts +18 -0
- package/dist/types/proof/proof-service.d.ts +2 -2
- package/dist/types/storage/blockchain/onchain-revocation.d.ts +1 -0
- package/dist/types/storage/blockchain/state.d.ts +7 -2
- package/dist/types/storage/interfaces/state.d.ts +26 -2
- package/dist/types/utils/did-helper.d.ts +9 -1
- package/dist/types/verifiable/constants.d.ts +1 -0
- package/package.json +10 -12
- package/LICENSE +0 -691
- package/dist/node/esm/kms/key-providers/sec256k1-provider.js +0 -71
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import Elliptic from 'elliptic';
|
|
2
|
-
import * as providerHelpers from '../provider-helpers';
|
|
3
|
-
import { ES256KSigner } from 'did-jwt';
|
|
4
|
-
import { base64UrlToBytes, byteEncoder, bytesToHex, hexToBytes } from '../../utils';
|
|
5
|
-
/**
|
|
6
|
-
* Provider for Sec256p1 keys256p1
|
|
7
|
-
* @public
|
|
8
|
-
* @class Sec256p1Provider
|
|
9
|
-
* @implements implements IKeyProvider interface
|
|
10
|
-
*/
|
|
11
|
-
export class Sec256k1Provider {
|
|
12
|
-
/**
|
|
13
|
-
* Creates an instance of BjjProvider.
|
|
14
|
-
* @param {KmsKeyType} keyType - kms key type
|
|
15
|
-
* @param {AbstractPrivateKeyStore} keyStore - key store for kms
|
|
16
|
-
*/
|
|
17
|
-
constructor(keyType, keyStore) {
|
|
18
|
-
this.keyType = keyType;
|
|
19
|
-
this._keyStore = keyStore;
|
|
20
|
-
this._ec = new Elliptic.ec('secp256k1');
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* generates a baby jub jub key from a seed phrase
|
|
24
|
-
* @param {Uint8Array} seed - byte array seed
|
|
25
|
-
* @returns kms key identifier
|
|
26
|
-
*/
|
|
27
|
-
async newPrivateKeyFromSeed(seed) {
|
|
28
|
-
if (seed.length !== 32) {
|
|
29
|
-
throw new Error('Seed should be 32 bytes');
|
|
30
|
-
}
|
|
31
|
-
const keyPair = this._ec.keyFromPrivate(seed);
|
|
32
|
-
const kmsId = {
|
|
33
|
-
type: this.keyType,
|
|
34
|
-
id: providerHelpers.keyPath(this.keyType, keyPair.getPublic().encode('hex', false))
|
|
35
|
-
};
|
|
36
|
-
await this._keyStore.importKey({ alias: kmsId.id, key: keyPair.getPrivate().toString('hex') });
|
|
37
|
-
return kmsId;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Gets public key by kmsKeyId
|
|
41
|
-
*
|
|
42
|
-
* @param {KmsKeyId} keyId - key identifier
|
|
43
|
-
*/
|
|
44
|
-
async publicKey(keyId) {
|
|
45
|
-
const privateKeyHex = await this.privateKey(keyId);
|
|
46
|
-
return this._ec.keyFromPrivate(privateKeyHex, 'hex').getPublic().encode('hex', false);
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* signs prepared payload of size,
|
|
50
|
-
* with a key id
|
|
51
|
-
*
|
|
52
|
-
* @param {KmsKeyId} keyId - key identifier
|
|
53
|
-
* @param {Uint8Array} data - data to sign (32 bytes)
|
|
54
|
-
* @returns Uint8Array signature
|
|
55
|
-
*/
|
|
56
|
-
async sign(keyId, data, opts = { alg: 'ES256K' }) {
|
|
57
|
-
const privateKeyHex = await this.privateKey(keyId);
|
|
58
|
-
if (!privateKeyHex) {
|
|
59
|
-
throw new Error('Private key not found for keyId: ' + keyId.id);
|
|
60
|
-
}
|
|
61
|
-
const signatureBase64 = await ES256KSigner(hexToBytes(privateKeyHex), opts.alg === 'ES256K-R')(data);
|
|
62
|
-
const signatureHex = bytesToHex(base64UrlToBytes(signatureBase64.toString()));
|
|
63
|
-
if (typeof signatureHex !== 'string') {
|
|
64
|
-
throw new Error('Signature is not a string');
|
|
65
|
-
}
|
|
66
|
-
return byteEncoder.encode(signatureBase64.toString());
|
|
67
|
-
}
|
|
68
|
-
async privateKey(keyId) {
|
|
69
|
-
return this._keyStore.get({ alias: keyId.id });
|
|
70
|
-
}
|
|
71
|
-
}
|