@docknetwork/wallet-sdk-wasm 1.5.14 → 1.7.6
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/generate-docs.js +49 -0
- package/jsdoc.conf.json +29 -6
- package/lib/index.js +9 -1
- package/lib/index.mjs +9 -1
- package/lib/modules/network-manager.js +15 -12
- package/lib/modules/network-manager.mjs +15 -12
- package/lib/rpc-server.js +11 -1
- package/lib/rpc-server.mjs +11 -1
- package/lib/services/blockchain/cached-did-resolver.js +113 -0
- package/lib/services/blockchain/cached-did-resolver.mjs +109 -0
- package/lib/services/blockchain/index.js +11 -0
- package/lib/services/blockchain/index.mjs +11 -0
- package/lib/services/blockchain/service-rpc.js +12 -0
- package/lib/services/blockchain/service-rpc.mjs +12 -0
- package/lib/services/blockchain/service.js +161 -19
- package/lib/services/blockchain/service.mjs +162 -20
- package/lib/services/credential/bbs-revocation.js +11 -0
- package/lib/services/credential/bbs-revocation.mjs +11 -0
- package/lib/services/credential/bound-check.js +1 -1
- package/lib/services/credential/bound-check.mjs +1 -1
- package/lib/services/credential/config.js +4 -1
- package/lib/services/credential/config.mjs +4 -1
- package/lib/services/credential/delegatable-credentials.js +300 -0
- package/lib/services/credential/delegatable-credentials.mjs +263 -0
- package/lib/services/credential/index.js +53 -0
- package/lib/services/credential/index.mjs +18 -0
- package/lib/services/credential/pex-helpers.js +4 -4
- package/lib/services/credential/pex-helpers.mjs +4 -4
- package/lib/services/credential/sd-jwt.js +214 -0
- package/lib/services/credential/sd-jwt.mjs +200 -0
- package/lib/services/credential/service-rpc.js +9 -0
- package/lib/services/credential/service-rpc.mjs +9 -0
- package/lib/services/credential/service.js +324 -7
- package/lib/services/credential/service.mjs +324 -7
- package/lib/services/edv/index.js +1 -0
- package/lib/services/edv/index.mjs +1 -0
- package/lib/services/edv/service-rpc.js +23 -0
- package/lib/services/edv/service-rpc.mjs +23 -0
- package/lib/services/edv/service.js +226 -2
- package/lib/services/edv/service.mjs +223 -3
- package/lib/services/index.js +14 -0
- package/lib/services/index.mjs +14 -0
- package/lib/services/pex/config.js +4 -0
- package/lib/services/pex/config.mjs +4 -0
- package/lib/services/pex/service-rpc.js +4 -0
- package/lib/services/pex/service-rpc.mjs +4 -0
- package/lib/services/pex/service.js +7 -0
- package/lib/services/pex/service.mjs +7 -0
- package/lib/services/relay-service/service.js +124 -1
- package/lib/services/relay-service/service.mjs +124 -1
- package/lib/services/rpc-service-client.js +0 -3
- package/lib/services/rpc-service-client.mjs +0 -3
- package/lib/services/storage/index.js +19 -2
- package/lib/services/storage/index.mjs +24 -1
- package/lib/services/storage/service-rpc.js +7 -3
- package/lib/services/storage/service-rpc.mjs +7 -3
- package/lib/services/storage/service.js +4 -0
- package/lib/services/storage/service.mjs +4 -0
- package/lib/setup-nodejs.js +9 -1
- package/lib/setup-nodejs.mjs +9 -1
- package/lib/setup-tests.js +9 -1
- package/lib/setup-tests.mjs +9 -1
- package/lib/src/modules/event-manager.d.ts +0 -1
- package/lib/src/modules/event-manager.d.ts.map +1 -1
- package/lib/src/modules/network-manager.d.ts +2 -4
- package/lib/src/modules/network-manager.d.ts.map +1 -1
- package/lib/src/services/blockchain/cached-did-resolver.d.ts +28 -0
- package/lib/src/services/blockchain/cached-did-resolver.d.ts.map +1 -0
- package/lib/src/services/blockchain/cached-did-resolver.test.d.ts +2 -0
- package/lib/src/services/blockchain/cached-did-resolver.test.d.ts.map +1 -0
- package/lib/src/services/blockchain/configs.d.ts +1 -2
- package/lib/src/services/blockchain/configs.d.ts.map +1 -1
- package/lib/src/services/blockchain/service.d.ts +117 -19
- package/lib/src/services/blockchain/service.d.ts.map +1 -1
- package/lib/src/services/credential/bbs-revocation.d.ts +1 -1
- package/lib/src/services/credential/bbs-revocation.d.ts.map +1 -1
- package/lib/src/services/credential/bound-check.d.ts.map +1 -1
- package/lib/src/services/credential/config.d.ts.map +1 -1
- package/lib/src/services/credential/delegatable-credentials.d.ts +272 -0
- package/lib/src/services/credential/delegatable-credentials.d.ts.map +1 -0
- package/lib/src/services/credential/index.d.ts +4 -0
- package/lib/src/services/credential/index.d.ts.map +1 -1
- package/lib/src/services/credential/pex-helpers.d.ts +2 -2
- package/lib/src/services/credential/pex-helpers.d.ts.map +1 -1
- package/lib/src/services/credential/sd-jwt.test.d.ts +2 -0
- package/lib/src/services/credential/sd-jwt.test.d.ts.map +1 -0
- package/lib/src/services/credential/service.d.ts +274 -4
- package/lib/src/services/credential/service.d.ts.map +1 -1
- package/lib/src/services/dids/keypair-utils.d.ts +2 -2
- package/lib/src/services/dids/keypair-utils.d.ts.map +1 -1
- package/lib/src/services/dids/service.d.ts +35 -3
- package/lib/src/services/dids/service.d.ts.map +1 -1
- package/lib/src/services/edv/service.d.ts +201 -2
- package/lib/src/services/edv/service.d.ts.map +1 -1
- package/lib/src/services/pex/config.d.ts +1 -0
- package/lib/src/services/pex/config.d.ts.map +1 -1
- package/lib/src/services/pex/service.d.ts +1 -0
- package/lib/src/services/pex/service.d.ts.map +1 -1
- package/lib/src/services/relay-service/service.d.ts +148 -8
- package/lib/src/services/relay-service/service.d.ts.map +1 -1
- package/lib/src/services/rpc-service-client.d.ts +2 -2
- package/lib/src/services/rpc-service-client.d.ts.map +1 -1
- package/lib/src/services/storage/index.d.ts +1 -1
- package/lib/src/services/storage/index.d.ts.map +1 -1
- package/lib/src/services/storage/service-rpc.d.ts +9 -0
- package/lib/src/services/storage/service-rpc.d.ts.map +1 -0
- package/lib/src/services/storage/service.d.ts +1 -0
- package/lib/src/services/storage/service.d.ts.map +1 -1
- package/lib/src/services/util-crypto/service.d.ts +2 -2
- package/lib/src/services/util-crypto/service.d.ts.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/wallet/rpc-storage-interface.js +13 -3
- package/lib/wallet/rpc-storage-interface.mjs +11 -1
- package/lib/wallet/rpc-storage-wallet.js +10 -0
- package/lib/wallet/rpc-storage-wallet.mjs +10 -0
- package/package.json +29 -16
- package/rollup.config.mjs +5 -3
- package/src/globals.d.ts +3 -0
- package/src/modules/network-manager.ts +15 -14
- package/src/services/blockchain/cached-did-resolver.test.ts +288 -0
- package/src/services/blockchain/cached-did-resolver.ts +126 -0
- package/src/services/blockchain/configs.ts +1 -2
- package/src/services/blockchain/service-rpc.js +12 -0
- package/src/services/blockchain/service.ts +167 -20
- package/src/services/credential/bound-check.ts +1 -1
- package/src/services/credential/config.ts +7 -1
- package/src/services/credential/delegatable-credentials.ts +409 -0
- package/src/services/credential/index.ts +16 -0
- package/src/services/credential/pex-helpers.js +4 -4
- package/src/services/credential/pex-helpers.test.js +2 -2
- package/src/services/credential/sd-jwt.test.ts +718 -0
- package/src/services/credential/sd-jwt.ts +231 -0
- package/src/services/credential/service-rpc.js +9 -0
- package/src/services/credential/service.ts +328 -7
- package/src/services/edv/index.test.js +229 -0
- package/src/services/edv/service-rpc.js +23 -0
- package/src/services/edv/service.ts +272 -1
- package/src/services/pex/config.ts +4 -0
- package/src/services/pex/service-rpc.js +4 -0
- package/src/services/pex/service.ts +13 -0
- package/src/services/pex/tests/pex-service.test.js +210 -0
- package/src/services/relay-service/service.ts +130 -1
- package/src/services/rpc-service-client.js +0 -3
- package/src/services/storage/index.js +15 -1
- package/src/services/storage/service-rpc.js +7 -3
- package/src/services/storage/service.ts +5 -0
|
@@ -44,4 +44,16 @@ export class BlockchainServiceRpc extends RpcService {
|
|
|
44
44
|
resolveDID(did: string): Promise<any> {
|
|
45
45
|
return this.call('resolveDID', did);
|
|
46
46
|
}
|
|
47
|
+
|
|
48
|
+
getCachedDIDs(): Promise<any> {
|
|
49
|
+
return this.call('getCachedDIDs');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
getCacheEntry(did: string): Promise<any> {
|
|
53
|
+
return this.call('getCacheEntry', did);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
clearCache(did?: string): Promise<any> {
|
|
57
|
+
return this.call('clearCache', did);
|
|
58
|
+
}
|
|
47
59
|
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @module blockchain-service
|
|
5
|
+
* @description Blockchain connectivity and DID resolution service for the Wallet SDK.
|
|
6
|
+
* This module provides functionality for connecting to Cheqd blockchain, resolving DIDs,
|
|
7
|
+
* and managing accumulator-related operations.
|
|
8
|
+
*/
|
|
9
|
+
|
|
3
10
|
import {DirectSecp256k1HdWallet} from '@cosmjs/proto-signing';
|
|
4
11
|
import {CheqdAPI} from '@docknetwork/cheqd-blockchain-api';
|
|
5
12
|
import {CheqdCoreModules} from '@docknetwork/cheqd-blockchain-modules';
|
|
@@ -18,6 +25,10 @@ import {once} from '../../modules/event-manager';
|
|
|
18
25
|
import {utilCryptoService} from '../util-crypto';
|
|
19
26
|
import {InitParams} from './configs';
|
|
20
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Universal resolver URL for DID resolution fallback
|
|
30
|
+
* @constant {string}
|
|
31
|
+
*/
|
|
21
32
|
export const universalResolverUrl = 'https://uniresolver.truvera.io';
|
|
22
33
|
|
|
23
34
|
import {
|
|
@@ -25,13 +36,23 @@ import {
|
|
|
25
36
|
AccumulatorId,
|
|
26
37
|
AccumulatorPublicKey,
|
|
27
38
|
} from '@docknetwork/credential-sdk/types';
|
|
39
|
+
import { CachedDIDResolver } from './cached-did-resolver';
|
|
28
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Resolver that accepts any DID method using wildcard matching
|
|
43
|
+
* @class
|
|
44
|
+
* @extends ResolverRouter
|
|
45
|
+
* @private
|
|
46
|
+
*/
|
|
29
47
|
class AnyDIDResolver extends ResolverRouter {
|
|
30
48
|
method = WILDCARD;
|
|
31
49
|
}
|
|
32
50
|
|
|
33
51
|
/**
|
|
34
|
-
*
|
|
52
|
+
* Main blockchain service class for managing blockchain connections and DID resolution
|
|
53
|
+
* @class
|
|
54
|
+
* @description Provides methods for connecting to Cheqd blockchain, resolving DIDs,
|
|
55
|
+
* and managing blockchain-related operations
|
|
35
56
|
*/
|
|
36
57
|
export class BlockchainService {
|
|
37
58
|
dock;
|
|
@@ -39,7 +60,17 @@ export class BlockchainService {
|
|
|
39
60
|
cheqdApi;
|
|
40
61
|
cheqdApiUrl;
|
|
41
62
|
isBlockchainReady = false;
|
|
42
|
-
|
|
63
|
+
private _resolver: any;
|
|
64
|
+
|
|
65
|
+
get resolver(): any {
|
|
66
|
+
return this._resolver;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Event names emitted by the blockchain service
|
|
70
|
+
* @static
|
|
71
|
+
* @readonly
|
|
72
|
+
* @property {string} BLOCKCHAIN_READY - Emitted when blockchain connection is established
|
|
73
|
+
*/
|
|
43
74
|
static Events = {
|
|
44
75
|
BLOCKCHAIN_READY: 'blockchain-ready',
|
|
45
76
|
};
|
|
@@ -50,17 +81,35 @@ export class BlockchainService {
|
|
|
50
81
|
BlockchainService.prototype.init,
|
|
51
82
|
BlockchainService.prototype.isApiConnected,
|
|
52
83
|
BlockchainService.prototype.getAddress,
|
|
84
|
+
BlockchainService.prototype.resolveDID,
|
|
85
|
+
BlockchainService.prototype.getCachedDIDs,
|
|
86
|
+
BlockchainService.prototype.clearCache,
|
|
87
|
+
BlockchainService.prototype.getCacheEntry,
|
|
53
88
|
];
|
|
54
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Creates a new BlockchainService instance
|
|
92
|
+
* @constructor
|
|
93
|
+
*/
|
|
55
94
|
constructor() {
|
|
56
95
|
this.name = 'blockchain';
|
|
57
96
|
this.cheqdApi = new CheqdAPI();
|
|
58
97
|
this.cheqdModules = new CheqdCoreModules(this.cheqdApi);
|
|
59
98
|
this.modules = new MultiApiCoreModules([this.cheqdModules]);
|
|
60
99
|
this.emitter = new EventEmitter();
|
|
61
|
-
|
|
100
|
+
// Blockchain is not ready yet, but we can use fallback resolvers
|
|
101
|
+
this._resolver = this.createDIDResolver();
|
|
62
102
|
}
|
|
63
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Gets the types and modules needed for DID or accumulator operations
|
|
106
|
+
* @param {string} didOrRegistryId - DID or registry identifier
|
|
107
|
+
* @returns {Object} Object containing accumulator-related types and modules
|
|
108
|
+
* @returns {typeof AccumulatorPublicKey} returns.PublicKey - Accumulator public key type
|
|
109
|
+
* @returns {typeof AccumulatorId} returns.AccumulatorId - Accumulator ID type
|
|
110
|
+
* @returns {typeof AccumulatorCommon} returns.AccumulatorCommon - Common accumulator type
|
|
111
|
+
* @returns {Object} returns.AccumulatorModule - Accumulator module instance
|
|
112
|
+
*/
|
|
64
113
|
getTypesForDIDOrAccumulator(didOrRegistryId) {
|
|
65
114
|
return {
|
|
66
115
|
PublicKey: AccumulatorPublicKey,
|
|
@@ -71,8 +120,11 @@ export class BlockchainService {
|
|
|
71
120
|
}
|
|
72
121
|
|
|
73
122
|
/**
|
|
74
|
-
*
|
|
75
|
-
* @returns
|
|
123
|
+
* Ensures the blockchain connection is ready before proceeding
|
|
124
|
+
* @returns {Promise<void>} Resolves when blockchain is ready
|
|
125
|
+
* @example
|
|
126
|
+
* await blockchainService.ensureBlockchainReady();
|
|
127
|
+
* // Blockchain is now connected and ready
|
|
76
128
|
*/
|
|
77
129
|
async ensureBlockchainReady() {
|
|
78
130
|
if (await this.isApiConnected()) {
|
|
@@ -82,17 +134,69 @@ export class BlockchainService {
|
|
|
82
134
|
return once(this.emitter, BlockchainService.Events.BLOCKCHAIN_READY);
|
|
83
135
|
}
|
|
84
136
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Gets the cached DIDs
|
|
140
|
+
* @returns {Promise<string[]>} Cached DIDs
|
|
141
|
+
*/
|
|
142
|
+
getCachedDIDs() {
|
|
143
|
+
return this.resolver.getCachedDIDs();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Gets the cached DID resolution data
|
|
148
|
+
* @param {string} did - The DID to get the cache entry for
|
|
149
|
+
* @returns {Promise<any>} Cached DID resolution data
|
|
150
|
+
*/
|
|
151
|
+
getCacheEntry(did) {
|
|
152
|
+
return this.resolver.getCacheEntry(did);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Clears cached data for a specific DID
|
|
157
|
+
* @param {string} did - The DID to clear from cache
|
|
158
|
+
* @returns {void}
|
|
159
|
+
*/
|
|
160
|
+
clearCache(did) {
|
|
161
|
+
return this.resolver.clearCache(did);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Creates a DID resolver with caching support
|
|
166
|
+
* @private
|
|
167
|
+
* @returns {CachedDIDResolver} Cached DID resolver instance
|
|
168
|
+
*/
|
|
169
|
+
createDIDResolver(isBlockchainReady: boolean) {
|
|
170
|
+
let resolvers = [
|
|
89
171
|
new UniversalResolver(universalResolverUrl),
|
|
90
|
-
|
|
172
|
+
new DIDKeyResolver(),
|
|
173
|
+
]
|
|
174
|
+
|
|
175
|
+
// Add blockchain resolvers if the blockchain is ready
|
|
176
|
+
if (isBlockchainReady) {
|
|
177
|
+
resolvers = [
|
|
178
|
+
new CoreResolver(this.modules),
|
|
179
|
+
...resolvers
|
|
180
|
+
]
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const router = new AnyDIDResolver(resolvers);
|
|
184
|
+
|
|
185
|
+
return new CachedDIDResolver(router);
|
|
91
186
|
}
|
|
92
187
|
/**
|
|
93
|
-
*
|
|
94
|
-
* @param {
|
|
95
|
-
* @
|
|
188
|
+
* Initializes the blockchain service with connection parameters
|
|
189
|
+
* @param {InitParams} params - Initialization parameters
|
|
190
|
+
* @param {string} params.cheqdApiUrl - URL of the Cheqd API endpoint
|
|
191
|
+
* @param {string} [params.networkId] - Cheqd network identifier
|
|
192
|
+
* @param {string} [params.cheqdMnemonic] - Mnemonic for Cheqd wallet (auto-generated if not provided)
|
|
193
|
+
* @returns {Promise<boolean>} True if initialization successful
|
|
194
|
+
* @throws {Error} If cheqdApiUrl is not provided
|
|
195
|
+
* @example
|
|
196
|
+
* await blockchainService.init({
|
|
197
|
+
* cheqdApiUrl: 'https://api.cheqd.network',
|
|
198
|
+
* networkId: 'mainnet'
|
|
199
|
+
* });
|
|
96
200
|
*/
|
|
97
201
|
async init(params: InitParams) {
|
|
98
202
|
if (!params?.cheqdApiUrl) {
|
|
@@ -127,16 +231,18 @@ export class BlockchainService {
|
|
|
127
231
|
try {
|
|
128
232
|
await this.cheqdApi.init({
|
|
129
233
|
wallet,
|
|
130
|
-
|
|
234
|
+
urls: Array.isArray(checkdApiUrl) ? checkdApiUrl : [checkdApiUrl],
|
|
131
235
|
network: cheqdNetworkId,
|
|
132
236
|
});
|
|
133
237
|
Logger.info(`Cheqd initialized at: ${checkdApiUrl}`);
|
|
134
238
|
} catch (err) {
|
|
239
|
+
debugger
|
|
135
240
|
Logger.error(`Failed to initialize cheqd at: ${checkdApiUrl}`, err);
|
|
136
241
|
}
|
|
137
242
|
|
|
138
243
|
|
|
139
|
-
|
|
244
|
+
// Re-create the resolver with the new blockchain connection
|
|
245
|
+
this._resolver = this.createDIDResolver(true);
|
|
140
246
|
|
|
141
247
|
if (
|
|
142
248
|
process.env.NODE_ENV !== 'test' ||
|
|
@@ -151,8 +257,10 @@ export class BlockchainService {
|
|
|
151
257
|
}
|
|
152
258
|
|
|
153
259
|
/**
|
|
154
|
-
*
|
|
155
|
-
* @returns
|
|
260
|
+
* Disconnects from the blockchain
|
|
261
|
+
* @returns {Promise<void>} Resolves when disconnection is complete
|
|
262
|
+
* @example
|
|
263
|
+
* await blockchainService.disconnect();
|
|
156
264
|
*/
|
|
157
265
|
async disconnect() {
|
|
158
266
|
let result;
|
|
@@ -166,6 +274,11 @@ export class BlockchainService {
|
|
|
166
274
|
return result;
|
|
167
275
|
}
|
|
168
276
|
|
|
277
|
+
/**
|
|
278
|
+
* Waits for the blockchain to be ready
|
|
279
|
+
* @returns {Promise<void>} Resolves when blockchain is ready
|
|
280
|
+
* @private
|
|
281
|
+
*/
|
|
169
282
|
async waitBlockchainReady() {
|
|
170
283
|
return new Promise(resolve => {
|
|
171
284
|
if (this.isBlockchainReady) {
|
|
@@ -176,21 +289,41 @@ export class BlockchainService {
|
|
|
176
289
|
});
|
|
177
290
|
}
|
|
178
291
|
|
|
292
|
+
/**
|
|
293
|
+
* Resolves a DID to its document
|
|
294
|
+
* @param {string} did - The DID to resolve
|
|
295
|
+
* @returns {Promise<Object>} The resolved DID document
|
|
296
|
+
* @example
|
|
297
|
+
* const didDoc = await blockchainService.resolveDID('did:key:z6Mk...');
|
|
298
|
+
*/
|
|
179
299
|
async resolveDID(did: string) {
|
|
180
300
|
return this.resolver.resolve(did);
|
|
181
301
|
}
|
|
182
302
|
/**
|
|
183
|
-
*
|
|
184
|
-
* @returns
|
|
303
|
+
* Checks if the blockchain API is connected
|
|
304
|
+
* @returns {Promise<boolean>} True if connected, false otherwise
|
|
305
|
+
* @example
|
|
306
|
+
* const isConnected = await blockchainService.isApiConnected();
|
|
185
307
|
*/
|
|
186
308
|
async isApiConnected() {
|
|
187
309
|
return this.cheqdApi.isInitialized();
|
|
188
310
|
}
|
|
189
311
|
|
|
190
|
-
|
|
312
|
+
/**
|
|
313
|
+
* Gets the current Cheqd API URL
|
|
314
|
+
* @returns {Promise<string>} The Cheqd API URL
|
|
315
|
+
* @example
|
|
316
|
+
* const apiUrl = await blockchainService.getAddress();
|
|
317
|
+
*/
|
|
318
|
+
async getAddress(): Promise<string | string[]> {
|
|
191
319
|
return this.cheqdApiUrl;
|
|
192
320
|
}
|
|
193
321
|
|
|
322
|
+
/**
|
|
323
|
+
* Sets the blockchain ready state and emits events
|
|
324
|
+
* @private
|
|
325
|
+
* @param {boolean} isBlockchainReady - Whether blockchain is ready
|
|
326
|
+
*/
|
|
194
327
|
_setBlockchainReady(isBlockchainReady) {
|
|
195
328
|
this.isBlockchainReady = isBlockchainReady;
|
|
196
329
|
|
|
@@ -200,4 +333,18 @@ export class BlockchainService {
|
|
|
200
333
|
}
|
|
201
334
|
}
|
|
202
335
|
|
|
336
|
+
/**
|
|
337
|
+
* Singleton instance of the blockchain service
|
|
338
|
+
* @type {BlockchainService}
|
|
339
|
+
* @example
|
|
340
|
+
* import { blockchainService } from '@docknetwork/wallet-sdk-wasm/services/blockchain';
|
|
341
|
+
*
|
|
342
|
+
* // Initialize the service
|
|
343
|
+
* await blockchainService.init({
|
|
344
|
+
* cheqdApiUrl: 'https://api.cheqd.network'
|
|
345
|
+
* });
|
|
346
|
+
*
|
|
347
|
+
* // Resolve a DID
|
|
348
|
+
* const didDoc = await blockchainService.resolveDID('did:key:z6Mk...');
|
|
349
|
+
*/
|
|
203
350
|
export const blockchainService: BlockchainService = new BlockchainService();
|
|
@@ -107,7 +107,7 @@ export function blobFromBase64(base64String: string): Uint8Array {
|
|
|
107
107
|
/^data:application\/octet-stream;base64,/,
|
|
108
108
|
'',
|
|
109
109
|
);
|
|
110
|
-
return base64url.toBuffer(cleanedBase64);
|
|
110
|
+
return new Uint8Array(base64url.toBuffer(cleanedBase64));
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
export async function isBase64OrDataUrl(str: string): Promise<boolean> {
|
|
@@ -12,7 +12,13 @@ export const validation = {
|
|
|
12
12
|
},
|
|
13
13
|
verifyCredential: params => {
|
|
14
14
|
const {credential} = params;
|
|
15
|
-
assert(
|
|
15
|
+
assert(
|
|
16
|
+
typeof credential === 'object' || typeof credential === 'string',
|
|
17
|
+
'invalid credential',
|
|
18
|
+
);
|
|
19
|
+
if (typeof credential === 'object') {
|
|
20
|
+
assert(Object.keys(credential).length > 0, 'invalid credential');
|
|
21
|
+
}
|
|
16
22
|
},
|
|
17
23
|
createBBSPresentation: params => {
|
|
18
24
|
const {credentials} = params;
|