@docknetwork/wallet-sdk-wasm 1.5.8 → 1.5.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/lib/core/format-utils.js +0 -28
- package/lib/core/format-utils.mjs +1 -24
- package/lib/core/validation.js +1 -24
- package/lib/core/validation.mjs +2 -21
- package/lib/index.js +13 -32
- package/lib/index.mjs +13 -32
- package/lib/rpc-server.js +13 -32
- package/lib/rpc-server.mjs +13 -32
- package/lib/rpc-util.js +14 -0
- package/lib/rpc-util.mjs +14 -0
- package/lib/services/blockchain/index.js +3 -8
- package/lib/services/blockchain/index.mjs +3 -8
- package/lib/services/blockchain/service.js +37 -80
- package/lib/services/blockchain/service.mjs +38 -81
- package/lib/services/credential/bbs-revocation.js +4 -9
- package/lib/services/credential/bbs-revocation.mjs +3 -8
- package/lib/services/credential/bound-check.js +9 -4
- package/lib/services/credential/bound-check.mjs +9 -4
- package/lib/services/credential/index.js +11 -15
- package/lib/services/credential/index.mjs +11 -15
- package/lib/services/credential/service.js +18 -20
- package/lib/services/credential/service.mjs +15 -17
- package/lib/services/credential/utils.js +65 -28
- package/lib/services/credential/utils.mjs +62 -32
- package/lib/services/dids/index.js +11 -16
- package/lib/services/dids/index.mjs +11 -16
- package/lib/services/dids/keypair-utils.js +142 -0
- package/lib/services/dids/keypair-utils.mjs +113 -0
- package/lib/services/dids/service.js +16 -37
- package/lib/services/dids/service.mjs +16 -37
- package/lib/services/edv/index.js +8 -16
- package/lib/services/edv/index.mjs +8 -16
- package/lib/services/edv/service.js +10 -24
- package/lib/services/edv/service.mjs +10 -24
- package/lib/services/index.js +13 -37
- package/lib/services/index.mjs +13 -37
- package/lib/services/pex/service.js +2 -1
- package/lib/services/pex/service.mjs +2 -1
- package/lib/services/relay-service/configs.js +0 -1
- package/lib/services/relay-service/configs.mjs +0 -1
- package/lib/services/relay-service/index.android.js +0 -1
- package/lib/services/relay-service/index.android.mjs +0 -1
- package/lib/services/relay-service/index.ios.js +0 -1
- package/lib/services/relay-service/index.ios.mjs +0 -1
- package/lib/services/relay-service/index.js +0 -1
- package/lib/services/relay-service/index.mjs +0 -1
- package/lib/services/relay-service/service-rpc.js +0 -1
- package/lib/services/relay-service/service-rpc.mjs +0 -1
- package/lib/services/relay-service/service.js +0 -1
- package/lib/services/relay-service/service.mjs +0 -1
- package/lib/services/test-utils.js +0 -239
- package/lib/services/test-utils.mjs +1 -234
- package/lib/services/util-crypto/configs.js +0 -12
- package/lib/services/util-crypto/configs.mjs +0 -12
- package/lib/services/util-crypto/index.android.js +0 -3
- package/lib/services/util-crypto/index.android.mjs +0 -3
- package/lib/services/util-crypto/index.ios.js +0 -3
- package/lib/services/util-crypto/index.ios.mjs +0 -3
- package/lib/services/util-crypto/index.js +4 -7
- package/lib/services/util-crypto/index.mjs +4 -7
- package/lib/services/util-crypto/service-rpc.js +0 -23
- package/lib/services/util-crypto/service-rpc.mjs +0 -23
- package/lib/services/util-crypto/service.js +68 -61
- package/lib/services/util-crypto/service.mjs +50 -59
- package/lib/services/wallet/configs.js +0 -63
- package/lib/services/wallet/configs.mjs +1 -64
- package/lib/services/wallet/index.android.js +0 -1
- package/lib/services/wallet/index.android.mjs +0 -1
- package/lib/services/wallet/index.ios.js +0 -1
- package/lib/services/wallet/index.ios.mjs +0 -1
- package/lib/services/wallet/index.js +2 -12
- package/lib/services/wallet/index.mjs +2 -12
- package/lib/services/wallet/service-rpc.js +0 -77
- package/lib/services/wallet/service-rpc.mjs +0 -77
- package/lib/services/wallet/service.js +1 -215
- package/lib/services/wallet/service.mjs +1 -211
- package/lib/setup-nodejs.js +13 -32
- package/lib/setup-nodejs.mjs +13 -32
- package/lib/setup-tests.js +13 -32
- package/lib/setup-tests.mjs +13 -32
- package/lib/src/core/format-utils.d.ts +0 -5
- package/lib/src/core/format-utils.d.ts.map +1 -1
- package/lib/src/core/validation.d.ts +0 -3
- package/lib/src/core/validation.d.ts.map +1 -1
- package/lib/src/rpc-util.d.ts.map +1 -1
- package/lib/src/services/blockchain/service.d.ts +7 -3
- package/lib/src/services/blockchain/service.d.ts.map +1 -1
- package/lib/src/services/credential/bbs-revocation.d.ts.map +1 -1
- package/lib/src/services/credential/bound-check.d.ts +1 -1
- package/lib/src/services/credential/bound-check.d.ts.map +1 -1
- package/lib/src/services/credential/service.d.ts.map +1 -1
- package/lib/src/services/credential/utils.d.ts +2 -1
- package/lib/src/services/credential/utils.d.ts.map +1 -1
- package/lib/src/services/dids/keypair-utils.d.ts +15 -0
- package/lib/src/services/dids/keypair-utils.d.ts.map +1 -0
- package/lib/src/services/dids/service.d.ts +6 -6
- package/lib/src/services/dids/service.d.ts.map +1 -1
- package/lib/src/services/edv/service.d.ts.map +1 -1
- package/lib/src/services/pex/service.d.ts.map +1 -1
- package/lib/src/services/util-crypto/configs.d.ts +0 -3
- package/lib/src/services/util-crypto/configs.d.ts.map +1 -1
- package/lib/src/services/util-crypto/service.d.ts +3 -8
- package/lib/src/services/util-crypto/service.d.ts.map +1 -1
- package/lib/src/services/wallet/configs.d.ts +13 -0
- package/lib/src/services/wallet/configs.d.ts.map +1 -0
- package/lib/src/services/wallet/service.d.ts +1 -44
- package/lib/src/services/wallet/service.d.ts.map +1 -1
- package/lib/test-utils.js +0 -4
- package/lib/test-utils.mjs +1 -4
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -27
- package/readme.md +0 -61
- package/src/core/format-utils.test.js +1 -28
- package/src/core/format-utils.ts +0 -33
- package/src/core/validation.test.js +1 -33
- package/src/core/validation.ts +1 -25
- package/src/rpc-server.test.js +2 -9
- package/src/rpc-util.js +14 -0
- package/src/services/blockchain/index.test.js +4 -15
- package/src/services/blockchain/service.ts +39 -98
- package/src/services/credential/bbs-revocation.ts +2 -1
- package/src/services/credential/bound-check.test.ts +6 -6
- package/src/services/credential/bound-check.ts +4 -4
- package/src/services/credential/index.test.js +0 -2
- package/src/services/credential/service.ts +5 -2
- package/src/services/credential/utils.js +65 -23
- package/src/services/dids/index.test.js +9 -20
- package/src/services/dids/keypair-utils.js +111 -0
- package/src/services/dids/service.ts +7 -26
- package/src/services/edv/service.ts +2 -9
- package/src/services/index.js +0 -8
- package/src/services/pex/service.ts +7 -1
- package/src/services/test-utils.js +0 -207
- package/src/services/util-crypto/configs.ts +0 -12
- package/src/services/util-crypto/index.test.js +6 -83
- package/src/services/util-crypto/service-rpc.js +0 -20
- package/src/services/util-crypto/service.ts +62 -75
- package/src/services/wallet/configs.ts +1 -113
- package/src/services/wallet/index.test.js +0 -159
- package/src/services/wallet/service-rpc.js +1 -88
- package/src/services/wallet/service.ts +0 -258
- package/src/test-utils.js +0 -13
- package/lib/account-8fa95046.js +0 -774
- package/lib/account-e7156c51.js +0 -764
- package/lib/core/polkadot-utils.js +0 -119
- package/lib/core/polkadot-utils.mjs +0 -94
- package/lib/core/realm-schemas.js +0 -50
- package/lib/core/realm-schemas.mjs +0 -44
- package/lib/core/subscan.js +0 -75
- package/lib/core/subscan.mjs +0 -64
- package/lib/fixtures.js +0 -56
- package/lib/fixtures.mjs +0 -52
- package/lib/modules/account.js +0 -55
- package/lib/modules/account.mjs +0 -47
- package/lib/modules/accounts.js +0 -56
- package/lib/modules/accounts.mjs +0 -47
- package/lib/modules/data-migration.js +0 -72
- package/lib/modules/data-migration.mjs +0 -68
- package/lib/modules/wallet-backup.js +0 -82
- package/lib/modules/wallet-backup.mjs +0 -71
- package/lib/modules/wallet.js +0 -56
- package/lib/modules/wallet.mjs +0 -47
- package/lib/services/example/configs.js +0 -21
- package/lib/services/example/configs.mjs +0 -13
- package/lib/services/example/index.js +0 -18
- package/lib/services/example/index.mjs +0 -14
- package/lib/services/example/service-rpc.js +0 -25
- package/lib/services/example/service-rpc.mjs +0 -21
- package/lib/services/example/service.js +0 -25
- package/lib/services/example/service.mjs +0 -20
- package/lib/services/keyring/configs.js +0 -70
- package/lib/services/keyring/configs.mjs +0 -61
- package/lib/services/keyring/index.android.js +0 -22
- package/lib/services/keyring/index.android.mjs +0 -18
- package/lib/services/keyring/index.ios.js +0 -22
- package/lib/services/keyring/index.ios.mjs +0 -18
- package/lib/services/keyring/index.js +0 -16
- package/lib/services/keyring/index.mjs +0 -8
- package/lib/services/keyring/service-rpc.js +0 -65
- package/lib/services/keyring/service-rpc.mjs +0 -61
- package/lib/services/keyring/service.js +0 -84
- package/lib/services/keyring/service.mjs +0 -74
- package/lib/services/polkadot/configs.js +0 -17
- package/lib/services/polkadot/configs.mjs +0 -13
- package/lib/services/polkadot/index.android.js +0 -22
- package/lib/services/polkadot/index.android.mjs +0 -18
- package/lib/services/polkadot/index.ios.js +0 -22
- package/lib/services/polkadot/index.ios.mjs +0 -18
- package/lib/services/polkadot/index.js +0 -15
- package/lib/services/polkadot/index.mjs +0 -7
- package/lib/services/polkadot/service-rpc.js +0 -30
- package/lib/services/polkadot/service-rpc.mjs +0 -26
- package/lib/services/polkadot/service.js +0 -28
- package/lib/services/polkadot/service.mjs +0 -23
- package/lib/services/substrate/api-utils.js +0 -85
- package/lib/services/substrate/api-utils.mjs +0 -74
- package/lib/services/substrate/configs.js +0 -30
- package/lib/services/substrate/configs.mjs +0 -21
- package/lib/services/substrate/index.android.js +0 -22
- package/lib/services/substrate/index.android.mjs +0 -18
- package/lib/services/substrate/index.ios.js +0 -22
- package/lib/services/substrate/index.ios.mjs +0 -18
- package/lib/services/substrate/index.js +0 -37
- package/lib/services/substrate/index.mjs +0 -29
- package/lib/services/substrate/service-rpc.js +0 -37
- package/lib/services/substrate/service-rpc.mjs +0 -33
- package/lib/services/substrate/service.js +0 -115
- package/lib/services/substrate/service.mjs +0 -102
- package/lib/services/trust-registry/configs.js +0 -25
- package/lib/services/trust-registry/configs.mjs +0 -16
- package/lib/services/trust-registry/index.android.js +0 -19
- package/lib/services/trust-registry/index.android.mjs +0 -15
- package/lib/services/trust-registry/index.ios.js +0 -19
- package/lib/services/trust-registry/index.ios.mjs +0 -15
- package/lib/services/trust-registry/index.js +0 -33
- package/lib/services/trust-registry/index.mjs +0 -25
- package/lib/services/trust-registry/service-rpc.js +0 -29
- package/lib/services/trust-registry/service-rpc.mjs +0 -25
- package/lib/services/trust-registry/service.js +0 -89
- package/lib/services/trust-registry/service.mjs +0 -85
- package/lib/src/core/polkadot-utils.d.ts +0 -11
- package/lib/src/core/polkadot-utils.d.ts.map +0 -1
- package/lib/src/modules/account.d.ts +0 -60
- package/lib/src/modules/account.d.ts.map +0 -1
- package/lib/src/modules/accounts.d.ts +0 -49
- package/lib/src/modules/accounts.d.ts.map +0 -1
- package/lib/src/modules/data-migration.d.ts +0 -7
- package/lib/src/modules/data-migration.d.ts.map +0 -1
- package/lib/src/modules/wallet-backup.d.ts +0 -12
- package/lib/src/modules/wallet-backup.d.ts.map +0 -1
- package/lib/src/modules/wallet.d.ts +0 -134
- package/lib/src/modules/wallet.d.ts.map +0 -1
- package/lib/src/services/blockchain/index.d.ts +0 -2
- package/lib/src/services/blockchain/index.d.ts.map +0 -1
- package/lib/src/services/example/configs.d.ts +0 -9
- package/lib/src/services/example/configs.d.ts.map +0 -1
- package/lib/src/services/example/service.d.ts +0 -8
- package/lib/src/services/example/service.d.ts.map +0 -1
- package/lib/src/services/keyring/configs.d.ts +0 -39
- package/lib/src/services/keyring/configs.d.ts.map +0 -1
- package/lib/src/services/keyring/index.d.ts +0 -2
- package/lib/src/services/keyring/index.d.ts.map +0 -1
- package/lib/src/services/polkadot/configs.d.ts +0 -8
- package/lib/src/services/polkadot/configs.d.ts.map +0 -1
- package/lib/src/services/polkadot/index.d.ts +0 -2
- package/lib/src/services/polkadot/index.d.ts.map +0 -1
- package/lib/src/services/polkadot/service.d.ts +0 -8
- package/lib/src/services/polkadot/service.d.ts.map +0 -1
- package/lib/src/services/substrate/api-utils.d.ts +0 -14
- package/lib/src/services/substrate/api-utils.d.ts.map +0 -1
- package/lib/src/services/substrate/configs.d.ts +0 -16
- package/lib/src/services/substrate/configs.d.ts.map +0 -1
- package/lib/src/services/substrate/index.d.ts +0 -2
- package/lib/src/services/substrate/index.d.ts.map +0 -1
- package/lib/src/services/substrate/service.d.ts +0 -13
- package/lib/src/services/substrate/service.d.ts.map +0 -1
- package/lib/src/services/trust-registry/configs.d.ts +0 -6
- package/lib/src/services/trust-registry/configs.d.ts.map +0 -1
- package/lib/src/services/trust-registry/service.d.ts +0 -25
- package/lib/src/services/trust-registry/service.d.ts.map +0 -1
- package/lib/src/services/wallet/index.d.ts +0 -2
- package/lib/src/services/wallet/index.d.ts.map +0 -1
- package/lib/test/axiosMocks.js +0 -431
- package/lib/test/axiosMocks.mjs +0 -420
- package/lib/test/setup-test-state.js +0 -93
- package/lib/test/setup-test-state.mjs +0 -85
- package/src/core/polkadot-utils.js +0 -99
- package/src/core/realm-schemas.js +0 -42
- package/src/core/subscan.js +0 -62
- package/src/core/subscan.test.js +0 -56
- package/src/fixtures.js +0 -43
- package/src/modules/account.test.js +0 -56
- package/src/modules/account.ts +0 -128
- package/src/modules/accounts.test.js +0 -88
- package/src/modules/accounts.ts +0 -264
- package/src/modules/data-migration.test.js +0 -72
- package/src/modules/data-migration.ts +0 -86
- package/src/modules/wallet-backup.test.js +0 -24
- package/src/modules/wallet-backup.ts +0 -68
- package/src/modules/wallet.test.js +0 -227
- package/src/modules/wallet.ts +0 -424
- package/src/services/example/configs.js +0 -14
- package/src/services/example/index.js +0 -3
- package/src/services/example/index.test.js +0 -28
- package/src/services/example/service-rpc.js +0 -11
- package/src/services/example/service.ts +0 -18
- package/src/services/keyring/configs.ts +0 -110
- package/src/services/keyring/index.android.js +0 -3
- package/src/services/keyring/index.ios.js +0 -3
- package/src/services/keyring/index.js +0 -1
- package/src/services/keyring/index.test.js +0 -48
- package/src/services/keyring/service-rpc.js +0 -56
- package/src/services/keyring/service.ts +0 -111
- package/src/services/polkadot/configs.ts +0 -13
- package/src/services/polkadot/index.android.js +0 -3
- package/src/services/polkadot/index.ios.js +0 -3
- package/src/services/polkadot/index.js +0 -1
- package/src/services/polkadot/index.test.js +0 -52
- package/src/services/polkadot/service-rpc.js +0 -13
- package/src/services/polkadot/service.ts +0 -21
- package/src/services/substrate/api-utils.test.js +0 -73
- package/src/services/substrate/api-utils.ts +0 -66
- package/src/services/substrate/configs.ts +0 -34
- package/src/services/substrate/index.android.js +0 -3
- package/src/services/substrate/index.ios.js +0 -3
- package/src/services/substrate/index.js +0 -1
- package/src/services/substrate/index.test.js +0 -116
- package/src/services/substrate/service-rpc.js +0 -24
- package/src/services/substrate/service.ts +0 -117
- package/src/services/trust-registry/configs.ts +0 -14
- package/src/services/trust-registry/index.android.js +0 -3
- package/src/services/trust-registry/index.ios.js +0 -3
- package/src/services/trust-registry/index.js +0 -1
- package/src/services/trust-registry/index.test.js +0 -67
- package/src/services/trust-registry/service-rpc.js +0 -15
- package/src/services/trust-registry/service.ts +0 -94
- package/src/test/axiosMocks.js +0 -20
- package/src/test/fixtures/subscan-failure.json +0 -5
- package/src/test/fixtures/subscan-success.json +0 -370
- package/src/test/fixtures/subscan-too-many-requests.json +0 -9
- package/src/test/setup-test-state.js +0 -37
- package/src/test/test-wallet.test.js +0 -15
|
@@ -7,37 +7,27 @@ var cryptoWasmTs = require('@docknetwork/crypto-wasm-ts');
|
|
|
7
7
|
var oid4vciClient = require('@sphereon/oid4vci-client');
|
|
8
8
|
var oid4vciCommon = require('@sphereon/oid4vci-common');
|
|
9
9
|
var keypairs = require('@docknetwork/universal-wallet/methods/keypairs');
|
|
10
|
+
var utils = require('@docknetwork/credential-sdk/utils');
|
|
10
11
|
var vc = require('@docknetwork/credential-sdk/vc');
|
|
11
12
|
var pex$1 = require('@sphereon/pex');
|
|
12
|
-
var services_credential_utils = require('./utils.js');
|
|
13
13
|
var services_blockchain_service = require('../blockchain/service.js');
|
|
14
14
|
var services_credential_boundCheck = require('./bound-check.js');
|
|
15
15
|
var assert = require('assert');
|
|
16
16
|
var services_credential_bbsRevocation = require('./bbs-revocation.js');
|
|
17
17
|
var services_credential_pexHelpers = require('./pex-helpers.js');
|
|
18
18
|
var services_dids_service = require('../dids/service.js');
|
|
19
|
-
require('base58-universal');
|
|
20
|
-
require('@docknetwork/credential-sdk/vc/crypto');
|
|
21
|
-
require('../keyring/service.js');
|
|
22
|
-
require('@polkadot/keyring');
|
|
23
|
-
require('@polkadot/util-crypto');
|
|
24
|
-
require('../keyring/configs.js');
|
|
25
|
-
require('../../core/validation.js');
|
|
26
|
-
require('bignumber.js');
|
|
27
|
-
require('../../types.js');
|
|
28
19
|
require('@cosmjs/proto-signing');
|
|
29
20
|
require('@docknetwork/cheqd-blockchain-api');
|
|
30
21
|
require('@docknetwork/cheqd-blockchain-modules');
|
|
31
22
|
require('@docknetwork/credential-sdk/modules');
|
|
32
23
|
require('@docknetwork/credential-sdk/resolver');
|
|
33
24
|
require('@docknetwork/crypto-wasm-ts/lib/index');
|
|
34
|
-
require('@docknetwork/dock-blockchain-api');
|
|
35
|
-
require('@docknetwork/dock-blockchain-modules');
|
|
36
25
|
require('events');
|
|
37
26
|
require('../../core/logger.js');
|
|
38
27
|
require('../../modules/event-manager.js');
|
|
39
28
|
require('../util-crypto/service.js');
|
|
40
|
-
require('@
|
|
29
|
+
require('@scure/bip39');
|
|
30
|
+
require('@scure/bip39/wordlists/english');
|
|
41
31
|
require('../util-crypto/configs.js');
|
|
42
32
|
require('@docknetwork/credential-sdk/types');
|
|
43
33
|
require('@docknetwork/crypto-wasm-ts/lib/legosnark');
|
|
@@ -45,9 +35,15 @@ require('base64url');
|
|
|
45
35
|
require('@astronautlabs/jsonpath');
|
|
46
36
|
require('@docknetwork/wallet-sdk-dids/lib');
|
|
47
37
|
require('../dids/config.js');
|
|
48
|
-
require('../../core/polkadot-utils.js');
|
|
49
38
|
require('@docknetwork/credential-sdk/keypairs');
|
|
50
|
-
require('
|
|
39
|
+
require('./utils.js');
|
|
40
|
+
require('base58-universal');
|
|
41
|
+
require('@docknetwork/credential-sdk/vc/crypto');
|
|
42
|
+
require('@digitalbazaar/x25519-key-agreement-key-2020');
|
|
43
|
+
require('@digitalbazaar/x25519-key-agreement-key-2019');
|
|
44
|
+
require('@digitalbazaar/ed25519-verification-key-2018');
|
|
45
|
+
require('@digitalbazaar/ed25519-verification-key-2020');
|
|
46
|
+
require('../dids/keypair-utils.js');
|
|
51
47
|
|
|
52
48
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
53
49
|
|
|
@@ -124,11 +120,13 @@ class CredentialService {
|
|
|
124
120
|
if (!shouldSkipSigning) {
|
|
125
121
|
vp.setHolder(keyDoc.controller);
|
|
126
122
|
}
|
|
127
|
-
|
|
123
|
+
const keyPair = keypairs.getKeypairFromDoc(keyDoc);
|
|
124
|
+
keyPair.signer = keyPair.signer();
|
|
125
|
+
const suite = await vc.getSuiteFromKeyDoc(keyPair);
|
|
128
126
|
if (shouldSkipSigning) {
|
|
129
127
|
return vp.toJSON();
|
|
130
128
|
}
|
|
131
|
-
return vp.sign(
|
|
129
|
+
return vp.sign(suite, challenge, domain, services_blockchain_service.blockchainService.resolver);
|
|
132
130
|
}
|
|
133
131
|
async verifyPresentation({ presentation, options }) {
|
|
134
132
|
return vc.verifyPresentation(presentation, options);
|
|
@@ -290,15 +288,15 @@ class CredentialService {
|
|
|
290
288
|
const removals = [];
|
|
291
289
|
if (updates.length && updates[0].additions !== null) {
|
|
292
290
|
for (const a of updates[0].additions) {
|
|
293
|
-
additions.push(hexToU8a(a));
|
|
291
|
+
additions.push(utils.hexToU8a(a));
|
|
294
292
|
}
|
|
295
293
|
}
|
|
296
294
|
if (updates.length && updates[0].removals !== null) {
|
|
297
295
|
for (const a of updates[0].removals) {
|
|
298
|
-
removals.push(hexToU8a(a));
|
|
296
|
+
removals.push(utils.hexToU8a(a));
|
|
299
297
|
}
|
|
300
298
|
}
|
|
301
|
-
const queriedWitnessInfo = new cryptoWasmTs.WitnessUpdatePublicInfo(hexToU8a(updates[0].witnessUpdateInfo));
|
|
299
|
+
const queriedWitnessInfo = new cryptoWasmTs.WitnessUpdatePublicInfo(utils.hexToU8a(updates[0].witnessUpdateInfo));
|
|
302
300
|
const witness = cryptoWasmTs.MembershipWitness.fromJSON(membershipWitnessJSON);
|
|
303
301
|
witness.updateUsingPublicInfoPostBatchUpdate(member, additions, removals, queriedWitnessInfo);
|
|
304
302
|
return witness.toJSON();
|
|
@@ -3,37 +3,27 @@ import { Accumulator, WitnessUpdatePublicInfo, MembershipWitness, VB_ACCUMULATOR
|
|
|
3
3
|
import { OpenID4VCIClientV1_0_13 } from '@sphereon/oid4vci-client';
|
|
4
4
|
import { Alg } from '@sphereon/oid4vci-common';
|
|
5
5
|
import { getKeypairFromDoc } from '@docknetwork/universal-wallet/methods/keypairs';
|
|
6
|
+
import { hexToU8a } from '@docknetwork/credential-sdk/utils';
|
|
6
7
|
import { VerifiableCredential, getSuiteFromKeyDoc, VerifiablePresentation, verifyPresentation, verifyCredential, Presentation } from '@docknetwork/credential-sdk/vc';
|
|
7
8
|
import { PEX } from '@sphereon/pex';
|
|
8
|
-
import { keyDocToKeypair } from './utils.mjs';
|
|
9
9
|
import { blockchainService } from '../blockchain/service.mjs';
|
|
10
10
|
import { hasProvingKey, fetchProvingKey, applyEnforceBounds } from './bound-check.mjs';
|
|
11
11
|
import assert from 'assert';
|
|
12
12
|
import { getIsRevoked, getWitnessDetails } from './bbs-revocation.mjs';
|
|
13
13
|
import { getPexRequiredAttributes } from './pex-helpers.mjs';
|
|
14
14
|
import { didService } from '../dids/service.mjs';
|
|
15
|
-
import 'base58-universal';
|
|
16
|
-
import '@docknetwork/credential-sdk/vc/crypto';
|
|
17
|
-
import '../keyring/service.mjs';
|
|
18
|
-
import '@polkadot/keyring';
|
|
19
|
-
import '@polkadot/util-crypto';
|
|
20
|
-
import '../keyring/configs.mjs';
|
|
21
|
-
import '../../core/validation.mjs';
|
|
22
|
-
import 'bignumber.js';
|
|
23
|
-
import '../../types.mjs';
|
|
24
15
|
import '@cosmjs/proto-signing';
|
|
25
16
|
import '@docknetwork/cheqd-blockchain-api';
|
|
26
17
|
import '@docknetwork/cheqd-blockchain-modules';
|
|
27
18
|
import '@docknetwork/credential-sdk/modules';
|
|
28
19
|
import '@docknetwork/credential-sdk/resolver';
|
|
29
20
|
import '@docknetwork/crypto-wasm-ts/lib/index';
|
|
30
|
-
import '@docknetwork/dock-blockchain-api';
|
|
31
|
-
import '@docknetwork/dock-blockchain-modules';
|
|
32
21
|
import 'events';
|
|
33
22
|
import '../../core/logger.mjs';
|
|
34
23
|
import '../../modules/event-manager.mjs';
|
|
35
24
|
import '../util-crypto/service.mjs';
|
|
36
|
-
import '@
|
|
25
|
+
import '@scure/bip39';
|
|
26
|
+
import '@scure/bip39/wordlists/english';
|
|
37
27
|
import '../util-crypto/configs.mjs';
|
|
38
28
|
import '@docknetwork/credential-sdk/types';
|
|
39
29
|
import '@docknetwork/crypto-wasm-ts/lib/legosnark';
|
|
@@ -41,9 +31,15 @@ import 'base64url';
|
|
|
41
31
|
import '@astronautlabs/jsonpath';
|
|
42
32
|
import '@docknetwork/wallet-sdk-dids/lib';
|
|
43
33
|
import '../dids/config.mjs';
|
|
44
|
-
import '../../core/polkadot-utils.mjs';
|
|
45
34
|
import '@docknetwork/credential-sdk/keypairs';
|
|
46
|
-
import '
|
|
35
|
+
import './utils.mjs';
|
|
36
|
+
import 'base58-universal';
|
|
37
|
+
import '@docknetwork/credential-sdk/vc/crypto';
|
|
38
|
+
import '@digitalbazaar/x25519-key-agreement-key-2020';
|
|
39
|
+
import '@digitalbazaar/x25519-key-agreement-key-2019';
|
|
40
|
+
import '@digitalbazaar/ed25519-verification-key-2018';
|
|
41
|
+
import '@digitalbazaar/ed25519-verification-key-2020';
|
|
42
|
+
import '../dids/keypair-utils.mjs';
|
|
47
43
|
|
|
48
44
|
// @ts-nocheck
|
|
49
45
|
const pex = new PEX();
|
|
@@ -116,11 +112,13 @@ class CredentialService {
|
|
|
116
112
|
if (!shouldSkipSigning) {
|
|
117
113
|
vp.setHolder(keyDoc.controller);
|
|
118
114
|
}
|
|
119
|
-
|
|
115
|
+
const keyPair = getKeypairFromDoc(keyDoc);
|
|
116
|
+
keyPair.signer = keyPair.signer();
|
|
117
|
+
const suite = await getSuiteFromKeyDoc(keyPair);
|
|
120
118
|
if (shouldSkipSigning) {
|
|
121
119
|
return vp.toJSON();
|
|
122
120
|
}
|
|
123
|
-
return vp.sign(
|
|
121
|
+
return vp.sign(suite, challenge, domain, blockchainService.resolver);
|
|
124
122
|
}
|
|
125
123
|
async verifyPresentation({ presentation, options }) {
|
|
126
124
|
return verifyPresentation(presentation, options);
|
|
@@ -4,14 +4,14 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var bs58 = require('base58-universal');
|
|
6
6
|
var crypto = require('@docknetwork/credential-sdk/vc/crypto');
|
|
7
|
-
var
|
|
8
|
-
require('@
|
|
9
|
-
require('@
|
|
10
|
-
require('
|
|
11
|
-
require('
|
|
12
|
-
require('
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
var utils = require('@docknetwork/credential-sdk/utils');
|
|
8
|
+
var x25519KeyAgreementKey2020 = require('@digitalbazaar/x25519-key-agreement-key-2020');
|
|
9
|
+
var x25519KeyAgreementKey2019 = require('@digitalbazaar/x25519-key-agreement-key-2019');
|
|
10
|
+
var ed25519VerificationKey2018 = require('@digitalbazaar/ed25519-verification-key-2018');
|
|
11
|
+
var ed25519VerificationKey2020 = require('@digitalbazaar/ed25519-verification-key-2020');
|
|
12
|
+
var keypairs = require('@docknetwork/credential-sdk/keypairs');
|
|
13
|
+
|
|
14
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
15
|
|
|
16
16
|
function _interopNamespace(e) {
|
|
17
17
|
if (e && e.__esModule) return e;
|
|
@@ -32,13 +32,16 @@ function _interopNamespace(e) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
var bs58__namespace = /*#__PURE__*/_interopNamespace(bs58);
|
|
35
|
+
var x25519KeyAgreementKey2020__default = /*#__PURE__*/_interopDefaultLegacy(x25519KeyAgreementKey2020);
|
|
36
|
+
var x25519KeyAgreementKey2019__default = /*#__PURE__*/_interopDefaultLegacy(x25519KeyAgreementKey2019);
|
|
37
|
+
var ed25519VerificationKey2018__default = /*#__PURE__*/_interopDefaultLegacy(ed25519VerificationKey2018);
|
|
38
|
+
var ed25519VerificationKey2020__default = /*#__PURE__*/_interopDefaultLegacy(ed25519VerificationKey2020);
|
|
39
|
+
|
|
40
|
+
async function keyDocToKeypair(keyDoc) {
|
|
41
|
+
if (keyDoc.keypair) {
|
|
42
|
+
return keyDoc;
|
|
43
|
+
}
|
|
35
44
|
|
|
36
|
-
const docToKeyMap = {
|
|
37
|
-
Sr25519VerificationKey2020: 'sr25519',
|
|
38
|
-
Ed25519VerificationKey2018: 'ed25519',
|
|
39
|
-
};
|
|
40
|
-
function keyDocToKeypair(keyDoc, dock) {
|
|
41
|
-
// For now we expect multibase to just be b58, this needs fixing later if/when we support more keys
|
|
42
45
|
const {
|
|
43
46
|
type,
|
|
44
47
|
privateKeyBase58,
|
|
@@ -46,27 +49,61 @@ function keyDocToKeypair(keyDoc, dock) {
|
|
|
46
49
|
privateKeyMultibase,
|
|
47
50
|
publicKeyMultibase,
|
|
48
51
|
} = keyDoc;
|
|
49
|
-
|
|
52
|
+
|
|
53
|
+
const publicKeyEncoded = publicKeyBase58 || publicKeyMultibase.substr(1);
|
|
54
|
+
const privateKeyEncoded =
|
|
55
|
+
privateKeyBase58 || (privateKeyMultibase && privateKeyMultibase.substr(1));
|
|
56
|
+
if (!privateKeyEncoded) {
|
|
57
|
+
throw new Error(
|
|
58
|
+
`No private key in document found, this should not happen. Got: ${JSON.stringify(
|
|
59
|
+
keyDoc,
|
|
60
|
+
null,
|
|
61
|
+
2,
|
|
62
|
+
)}`,
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
50
66
|
const privateKeyBytes = bs58__namespace.decode(privateKeyEncoded);
|
|
67
|
+
const publicKeyBytes = bs58__namespace.decode(publicKeyEncoded);
|
|
51
68
|
|
|
52
69
|
if (type === 'Bls12381G2VerificationKeyDock2022') {
|
|
53
70
|
return new crypto.Bls12381G2KeyPairDock2022(keyDoc);
|
|
71
|
+
} else if (type === 'Bls12381BBSVerificationKeyDock2023') {
|
|
72
|
+
return new crypto.Bls12381BBSKeyPairDock2023(keyDoc);
|
|
73
|
+
} else if (type === 'Bls12381BBDT16VerificationKeyDock2024') {
|
|
74
|
+
return new crypto.Bls12381BBDT16KeyPairDock2024(keyDoc);
|
|
75
|
+
} else if (
|
|
76
|
+
type === 'Ed25519VerificationKey2020' ||
|
|
77
|
+
type === 'Ed25519VerificationKey2018'
|
|
78
|
+
) {
|
|
79
|
+
const key = new keypairs.Ed25519Keypair(utils.randomAsHex(32));
|
|
80
|
+
key.keyPair.publicKey = publicKeyBytes;
|
|
81
|
+
key.keyPair.secretKey = privateKeyBytes;
|
|
82
|
+
return key;
|
|
54
83
|
} else {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
throw new Error(`Unsupported key type: ${type}`);
|
|
59
|
-
}
|
|
84
|
+
throw new Error(`Unsupported key type: ${type}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
60
87
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
88
|
+
const keyConstructors = {
|
|
89
|
+
Ed25519VerificationKey2018: keypairOptions =>
|
|
90
|
+
new ed25519VerificationKey2018__default["default"].Ed25519VerificationKey2018(keypairOptions),
|
|
91
|
+
Ed25519VerificationKey2020: keypairOptions =>
|
|
92
|
+
new ed25519VerificationKey2020__default["default"].Ed25519VerificationKey2020(keypairOptions),
|
|
93
|
+
X25519KeyAgreementKey2019: keypairOptions =>
|
|
94
|
+
new x25519KeyAgreementKey2019__default["default"].X25519KeyAgreementKey2019(keypairOptions),
|
|
95
|
+
X25519KeyAgreementKey2020: keypairOptions =>
|
|
96
|
+
new x25519KeyAgreementKey2020__default["default"].X25519KeyAgreementKey2020(keypairOptions),
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
function getKeypairFromDoc(keypairOptions) {
|
|
100
|
+
const {type} = keypairOptions;
|
|
101
|
+
const keyConstructor = keyConstructors[type];
|
|
102
|
+
if (!keyConstructor) {
|
|
103
|
+
throw new Error(`Unrecognized keypair type to construct: ${type}`);
|
|
69
104
|
}
|
|
105
|
+
return keyConstructor(keypairOptions);
|
|
70
106
|
}
|
|
71
107
|
|
|
108
|
+
exports.getKeypairFromDoc = getKeypairFromDoc;
|
|
72
109
|
exports.keyDocToKeypair = keyDocToKeypair;
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import * as bs58 from 'base58-universal';
|
|
2
|
-
import { Bls12381G2KeyPairDock2022 } from '@docknetwork/credential-sdk/vc/crypto';
|
|
3
|
-
import {
|
|
4
|
-
import '@
|
|
5
|
-
import '@
|
|
6
|
-
import '
|
|
7
|
-
import '
|
|
8
|
-
import '
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
function keyDocToKeypair(keyDoc, dock) {
|
|
17
|
-
// For now we expect multibase to just be b58, this needs fixing later if/when we support more keys
|
|
2
|
+
import { Bls12381G2KeyPairDock2022, Bls12381BBSKeyPairDock2023, Bls12381BBDT16KeyPairDock2024 } from '@docknetwork/credential-sdk/vc/crypto';
|
|
3
|
+
import { randomAsHex } from '@docknetwork/credential-sdk/utils';
|
|
4
|
+
import x25519KeyAgreementKey2020 from '@digitalbazaar/x25519-key-agreement-key-2020';
|
|
5
|
+
import x25519KeyAgreementKey2019 from '@digitalbazaar/x25519-key-agreement-key-2019';
|
|
6
|
+
import ed25519VerificationKey2018 from '@digitalbazaar/ed25519-verification-key-2018';
|
|
7
|
+
import ed25519VerificationKey2020 from '@digitalbazaar/ed25519-verification-key-2020';
|
|
8
|
+
import { Ed25519Keypair } from '@docknetwork/credential-sdk/keypairs';
|
|
9
|
+
|
|
10
|
+
async function keyDocToKeypair(keyDoc) {
|
|
11
|
+
if (keyDoc.keypair) {
|
|
12
|
+
return keyDoc;
|
|
13
|
+
}
|
|
14
|
+
|
|
18
15
|
const {
|
|
19
16
|
type,
|
|
20
17
|
privateKeyBase58,
|
|
@@ -22,27 +19,60 @@ function keyDocToKeypair(keyDoc, dock) {
|
|
|
22
19
|
privateKeyMultibase,
|
|
23
20
|
publicKeyMultibase,
|
|
24
21
|
} = keyDoc;
|
|
25
|
-
|
|
22
|
+
|
|
23
|
+
const publicKeyEncoded = publicKeyBase58 || publicKeyMultibase.substr(1);
|
|
24
|
+
const privateKeyEncoded =
|
|
25
|
+
privateKeyBase58 || (privateKeyMultibase && privateKeyMultibase.substr(1));
|
|
26
|
+
if (!privateKeyEncoded) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
`No private key in document found, this should not happen. Got: ${JSON.stringify(
|
|
29
|
+
keyDoc,
|
|
30
|
+
null,
|
|
31
|
+
2,
|
|
32
|
+
)}`,
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
26
36
|
const privateKeyBytes = bs58.decode(privateKeyEncoded);
|
|
37
|
+
const publicKeyBytes = bs58.decode(publicKeyEncoded);
|
|
27
38
|
|
|
28
39
|
if (type === 'Bls12381G2VerificationKeyDock2022') {
|
|
29
40
|
return new Bls12381G2KeyPairDock2022(keyDoc);
|
|
41
|
+
} else if (type === 'Bls12381BBSVerificationKeyDock2023') {
|
|
42
|
+
return new Bls12381BBSKeyPairDock2023(keyDoc);
|
|
43
|
+
} else if (type === 'Bls12381BBDT16VerificationKeyDock2024') {
|
|
44
|
+
return new Bls12381BBDT16KeyPairDock2024(keyDoc);
|
|
45
|
+
} else if (
|
|
46
|
+
type === 'Ed25519VerificationKey2020' ||
|
|
47
|
+
type === 'Ed25519VerificationKey2018'
|
|
48
|
+
) {
|
|
49
|
+
const key = new Ed25519Keypair(randomAsHex(32));
|
|
50
|
+
key.keyPair.publicKey = publicKeyBytes;
|
|
51
|
+
key.keyPair.secretKey = privateKeyBytes;
|
|
52
|
+
return key;
|
|
30
53
|
} else {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
54
|
+
throw new Error(`Unsupported key type: ${type}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const keyConstructors = {
|
|
59
|
+
Ed25519VerificationKey2018: keypairOptions =>
|
|
60
|
+
new ed25519VerificationKey2018.Ed25519VerificationKey2018(keypairOptions),
|
|
61
|
+
Ed25519VerificationKey2020: keypairOptions =>
|
|
62
|
+
new ed25519VerificationKey2020.Ed25519VerificationKey2020(keypairOptions),
|
|
63
|
+
X25519KeyAgreementKey2019: keypairOptions =>
|
|
64
|
+
new x25519KeyAgreementKey2019.X25519KeyAgreementKey2019(keypairOptions),
|
|
65
|
+
X25519KeyAgreementKey2020: keypairOptions =>
|
|
66
|
+
new x25519KeyAgreementKey2020.X25519KeyAgreementKey2020(keypairOptions),
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
function getKeypairFromDoc(keypairOptions) {
|
|
70
|
+
const {type} = keypairOptions;
|
|
71
|
+
const keyConstructor = keyConstructors[type];
|
|
72
|
+
if (!keyConstructor) {
|
|
73
|
+
throw new Error(`Unrecognized keypair type to construct: ${type}`);
|
|
45
74
|
}
|
|
75
|
+
return keyConstructor(keypairOptions);
|
|
46
76
|
}
|
|
47
77
|
|
|
48
|
-
export { keyDocToKeypair };
|
|
78
|
+
export { getKeypairFromDoc, keyDocToKeypair };
|
|
@@ -6,16 +6,6 @@ var services_dids_service = require('./service.js');
|
|
|
6
6
|
require('@docknetwork/wallet-sdk-dids/lib');
|
|
7
7
|
require('./config.js');
|
|
8
8
|
require('assert');
|
|
9
|
-
require('../keyring/service.js');
|
|
10
|
-
require('@polkadot/keyring');
|
|
11
|
-
require('@polkadot/util-crypto');
|
|
12
|
-
require('../keyring/configs.js');
|
|
13
|
-
require('../../core/validation.js');
|
|
14
|
-
require('bignumber.js');
|
|
15
|
-
require('../../types.js');
|
|
16
|
-
require('../util-crypto/service.js');
|
|
17
|
-
require('@polkadot/util');
|
|
18
|
-
require('../util-crypto/configs.js');
|
|
19
9
|
require('../blockchain/service.js');
|
|
20
10
|
require('@cosmjs/proto-signing');
|
|
21
11
|
require('@docknetwork/cheqd-blockchain-api');
|
|
@@ -23,20 +13,25 @@ require('@docknetwork/cheqd-blockchain-modules');
|
|
|
23
13
|
require('@docknetwork/credential-sdk/modules');
|
|
24
14
|
require('@docknetwork/credential-sdk/resolver');
|
|
25
15
|
require('@docknetwork/crypto-wasm-ts/lib/index');
|
|
26
|
-
require('@docknetwork/dock-blockchain-api');
|
|
27
|
-
require('@docknetwork/dock-blockchain-modules');
|
|
28
16
|
require('events');
|
|
29
17
|
require('../../core/logger.js');
|
|
30
18
|
require('../../modules/event-manager.js');
|
|
19
|
+
require('../util-crypto/service.js');
|
|
20
|
+
require('@docknetwork/credential-sdk/utils');
|
|
21
|
+
require('@scure/bip39');
|
|
22
|
+
require('@scure/bip39/wordlists/english');
|
|
23
|
+
require('../util-crypto/configs.js');
|
|
31
24
|
require('@docknetwork/credential-sdk/types');
|
|
32
|
-
require('../../core/polkadot-utils.js');
|
|
33
25
|
require('@docknetwork/credential-sdk/keypairs');
|
|
34
|
-
require('@polkadot/keyring/pair/decode');
|
|
35
|
-
require('base58-universal');
|
|
36
|
-
require('@docknetwork/universal-wallet/methods/keypairs');
|
|
37
26
|
require('base64url');
|
|
38
27
|
require('../credential/utils.js');
|
|
28
|
+
require('base58-universal');
|
|
39
29
|
require('@docknetwork/credential-sdk/vc/crypto');
|
|
30
|
+
require('@digitalbazaar/x25519-key-agreement-key-2020');
|
|
31
|
+
require('@digitalbazaar/x25519-key-agreement-key-2019');
|
|
32
|
+
require('@digitalbazaar/ed25519-verification-key-2018');
|
|
33
|
+
require('@digitalbazaar/ed25519-verification-key-2020');
|
|
34
|
+
require('./keypair-utils.js');
|
|
40
35
|
|
|
41
36
|
const didServiceRPC = services_dids_service.didService;
|
|
42
37
|
|
|
@@ -2,16 +2,6 @@ import { didService } from './service.mjs';
|
|
|
2
2
|
import '@docknetwork/wallet-sdk-dids/lib';
|
|
3
3
|
import './config.mjs';
|
|
4
4
|
import 'assert';
|
|
5
|
-
import '../keyring/service.mjs';
|
|
6
|
-
import '@polkadot/keyring';
|
|
7
|
-
import '@polkadot/util-crypto';
|
|
8
|
-
import '../keyring/configs.mjs';
|
|
9
|
-
import '../../core/validation.mjs';
|
|
10
|
-
import 'bignumber.js';
|
|
11
|
-
import '../../types.mjs';
|
|
12
|
-
import '../util-crypto/service.mjs';
|
|
13
|
-
import '@polkadot/util';
|
|
14
|
-
import '../util-crypto/configs.mjs';
|
|
15
5
|
import '../blockchain/service.mjs';
|
|
16
6
|
import '@cosmjs/proto-signing';
|
|
17
7
|
import '@docknetwork/cheqd-blockchain-api';
|
|
@@ -19,20 +9,25 @@ import '@docknetwork/cheqd-blockchain-modules';
|
|
|
19
9
|
import '@docknetwork/credential-sdk/modules';
|
|
20
10
|
import '@docknetwork/credential-sdk/resolver';
|
|
21
11
|
import '@docknetwork/crypto-wasm-ts/lib/index';
|
|
22
|
-
import '@docknetwork/dock-blockchain-api';
|
|
23
|
-
import '@docknetwork/dock-blockchain-modules';
|
|
24
12
|
import 'events';
|
|
25
13
|
import '../../core/logger.mjs';
|
|
26
14
|
import '../../modules/event-manager.mjs';
|
|
15
|
+
import '../util-crypto/service.mjs';
|
|
16
|
+
import '@docknetwork/credential-sdk/utils';
|
|
17
|
+
import '@scure/bip39';
|
|
18
|
+
import '@scure/bip39/wordlists/english';
|
|
19
|
+
import '../util-crypto/configs.mjs';
|
|
27
20
|
import '@docknetwork/credential-sdk/types';
|
|
28
|
-
import '../../core/polkadot-utils.mjs';
|
|
29
21
|
import '@docknetwork/credential-sdk/keypairs';
|
|
30
|
-
import '@polkadot/keyring/pair/decode';
|
|
31
|
-
import 'base58-universal';
|
|
32
|
-
import '@docknetwork/universal-wallet/methods/keypairs';
|
|
33
22
|
import 'base64url';
|
|
34
23
|
import '../credential/utils.mjs';
|
|
24
|
+
import 'base58-universal';
|
|
35
25
|
import '@docknetwork/credential-sdk/vc/crypto';
|
|
26
|
+
import '@digitalbazaar/x25519-key-agreement-key-2020';
|
|
27
|
+
import '@digitalbazaar/x25519-key-agreement-key-2019';
|
|
28
|
+
import '@digitalbazaar/ed25519-verification-key-2018';
|
|
29
|
+
import '@digitalbazaar/ed25519-verification-key-2020';
|
|
30
|
+
import './keypair-utils.mjs';
|
|
36
31
|
|
|
37
32
|
const didServiceRPC = didService;
|
|
38
33
|
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var keypairs = require('@docknetwork/credential-sdk/keypairs');
|
|
6
|
+
var utils = require('@docknetwork/credential-sdk/utils');
|
|
7
|
+
var bs58 = require('base58-universal');
|
|
8
|
+
|
|
9
|
+
function _interopNamespace(e) {
|
|
10
|
+
if (e && e.__esModule) return e;
|
|
11
|
+
var n = Object.create(null);
|
|
12
|
+
if (e) {
|
|
13
|
+
Object.keys(e).forEach(function (k) {
|
|
14
|
+
if (k !== 'default') {
|
|
15
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return e[k]; }
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
n["default"] = e;
|
|
24
|
+
return Object.freeze(n);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var bs58__namespace = /*#__PURE__*/_interopNamespace(bs58);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* This code is based on the implementation from truvera api
|
|
31
|
+
* https://github.com/docknetwork/web/blob/3c706c5dc5de4ae63f548c76ec6edeb17533a0c9/apps/api/src/utils/key-manager.js
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
function getKeyPairType(key) {
|
|
35
|
+
const keyType = key.type || key.constructor.VerKeyType;
|
|
36
|
+
if (keyType) {
|
|
37
|
+
return keyType;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (key instanceof keypairs.Ed25519Keypair) {
|
|
41
|
+
return 'Ed25519VerificationKey2018';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
throw new Error(`Unknown key type for ${key.constructor.name}`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const MULTIBASE_BASE58BTC_HEADER = 'z';
|
|
48
|
+
const MULTICODEC_ED25519_PUB_HEADER = new Uint8Array([0xed, 0x01]);
|
|
49
|
+
const MULTICODEC_ED25519_PRIV_HEADER = new Uint8Array([0x80, 0x26]);
|
|
50
|
+
|
|
51
|
+
function encodeMbKey(header, key) {
|
|
52
|
+
const mbKey = new Uint8Array(header.length + key.length);
|
|
53
|
+
mbKey.set(header);
|
|
54
|
+
mbKey.set(key, header.length);
|
|
55
|
+
return MULTIBASE_BASE58BTC_HEADER + bs58__namespace.encode(mbKey);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function getKeyFingerprint(keyType, publicKey) {
|
|
59
|
+
if (keyType.startsWith('Ed25519')) {
|
|
60
|
+
return encodeMbKey(MULTICODEC_ED25519_PUB_HEADER, publicKey);
|
|
61
|
+
} else {
|
|
62
|
+
throw new Error(`Cannot detect key type for fingerprint: ${keyType}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const keyTypeToDocType = {
|
|
67
|
+
bjj: 'BJJVerificationKey2021',
|
|
68
|
+
secp256k1: 'EcdsaSecp256k1VerificationKey2019',
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
function keypairToKeydoc(key, controller, id = undefined) {
|
|
72
|
+
const keyType = getKeyPairType(key);
|
|
73
|
+
let keyDoc;
|
|
74
|
+
if (
|
|
75
|
+
keyType === 'Ed25519VerificationKey2020' ||
|
|
76
|
+
keyType === 'Ed25519VerificationKey2018'
|
|
77
|
+
) {
|
|
78
|
+
const publicKey = utils.u8aToU8a(
|
|
79
|
+
(key.keyPair &&
|
|
80
|
+
key.keyPair.publicKey &&
|
|
81
|
+
utils.u8aToU8a(key.keyPair.publicKey)) ||
|
|
82
|
+
key.publicKeyBuffer ||
|
|
83
|
+
(key.pk && key.pk.value),
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
if (!publicKey) {
|
|
87
|
+
throw new Error('Cannot find public key');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const pk = utils.u8aToU8a(
|
|
91
|
+
(key.keyPair && key.keyPair.secretKey) ||
|
|
92
|
+
key.privateKeyBuffer ||
|
|
93
|
+
(key.sk &&
|
|
94
|
+
(typeof key.sk === 'string'
|
|
95
|
+
? utils.hexToU8a(key.sk)
|
|
96
|
+
: key.sk.value || key.sk)) ||
|
|
97
|
+
utils.hexToU8a(key.pk),
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
const publicKeyBase58 = bs58__namespace.encode(publicKey);
|
|
101
|
+
const privateKeyBase58 = bs58__namespace.encode(pk);
|
|
102
|
+
|
|
103
|
+
const fingerprint =
|
|
104
|
+
(key.fingerprint && key.fingerprint()) ||
|
|
105
|
+
getKeyFingerprint(keyType, publicKey);
|
|
106
|
+
|
|
107
|
+
// auto create controller
|
|
108
|
+
if (!controller) {
|
|
109
|
+
controller = `did:key:${fingerprint}`;
|
|
110
|
+
id = id || key.id || `${controller}#${fingerprint}`;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const keyId = id || key.id || `${controller}#${fingerprint}`;
|
|
114
|
+
const type = keyTypeToDocType[keyType] || keyType;
|
|
115
|
+
keyDoc = {
|
|
116
|
+
controller,
|
|
117
|
+
type,
|
|
118
|
+
id: keyId,
|
|
119
|
+
publicKeyMultibase: encodeMbKey(MULTICODEC_ED25519_PUB_HEADER, publicKey),
|
|
120
|
+
privateKeyMultibase: encodeMbKey(MULTICODEC_ED25519_PRIV_HEADER, pk),
|
|
121
|
+
privateKeyBase58,
|
|
122
|
+
publicKeyBase58,
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
if (key.seed) {
|
|
126
|
+
keyDoc.seed = utils.u8aToHex(key.seed);
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
throw new Error(`Unknown keypairToKeydoc type: ${keyType}`);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
keyDoc['@context'] = ['https://w3id.org/wallet/v1'];
|
|
133
|
+
|
|
134
|
+
return keyDoc;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
exports.MULTIBASE_BASE58BTC_HEADER = MULTIBASE_BASE58BTC_HEADER;
|
|
138
|
+
exports.MULTICODEC_ED25519_PRIV_HEADER = MULTICODEC_ED25519_PRIV_HEADER;
|
|
139
|
+
exports.MULTICODEC_ED25519_PUB_HEADER = MULTICODEC_ED25519_PUB_HEADER;
|
|
140
|
+
exports.encodeMbKey = encodeMbKey;
|
|
141
|
+
exports.getKeyPairType = getKeyPairType;
|
|
142
|
+
exports.keypairToKeydoc = keypairToKeydoc;
|