@docknetwork/wallet-sdk-wasm 1.5.14 → 1.7.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.
Files changed (91) hide show
  1. package/generate-docs.js +49 -0
  2. package/jsdoc.conf.json +29 -6
  3. package/lib/index.js +8 -1
  4. package/lib/index.mjs +8 -1
  5. package/lib/rpc-server.js +10 -1
  6. package/lib/rpc-server.mjs +10 -1
  7. package/lib/services/blockchain/cached-did-resolver.js +113 -0
  8. package/lib/services/blockchain/cached-did-resolver.mjs +109 -0
  9. package/lib/services/blockchain/index.js +11 -0
  10. package/lib/services/blockchain/index.mjs +11 -0
  11. package/lib/services/blockchain/service-rpc.js +12 -0
  12. package/lib/services/blockchain/service-rpc.mjs +12 -0
  13. package/lib/services/blockchain/service.js +140 -11
  14. package/lib/services/blockchain/service.mjs +140 -11
  15. package/lib/services/credential/bbs-revocation.js +11 -0
  16. package/lib/services/credential/bbs-revocation.mjs +11 -0
  17. package/lib/services/credential/config.js +4 -1
  18. package/lib/services/credential/config.mjs +4 -1
  19. package/lib/services/credential/index.js +14 -0
  20. package/lib/services/credential/index.mjs +14 -0
  21. package/lib/services/credential/sd-jwt.js +214 -0
  22. package/lib/services/credential/sd-jwt.mjs +200 -0
  23. package/lib/services/credential/service-rpc.js +9 -0
  24. package/lib/services/credential/service-rpc.mjs +9 -0
  25. package/lib/services/credential/service.js +324 -7
  26. package/lib/services/credential/service.mjs +324 -7
  27. package/lib/services/edv/service.js +145 -1
  28. package/lib/services/edv/service.mjs +145 -1
  29. package/lib/services/index.js +13 -0
  30. package/lib/services/index.mjs +13 -0
  31. package/lib/services/relay-service/service.js +124 -1
  32. package/lib/services/relay-service/service.mjs +124 -1
  33. package/lib/services/rpc-service-client.js +0 -3
  34. package/lib/services/rpc-service-client.mjs +0 -3
  35. package/lib/services/storage/index.js +19 -2
  36. package/lib/services/storage/index.mjs +24 -1
  37. package/lib/services/storage/service-rpc.js +7 -3
  38. package/lib/services/storage/service-rpc.mjs +7 -3
  39. package/lib/services/storage/service.js +4 -0
  40. package/lib/services/storage/service.mjs +4 -0
  41. package/lib/setup-nodejs.js +8 -1
  42. package/lib/setup-nodejs.mjs +8 -1
  43. package/lib/setup-tests.js +8 -1
  44. package/lib/setup-tests.mjs +8 -1
  45. package/lib/src/services/blockchain/cached-did-resolver.d.ts +28 -0
  46. package/lib/src/services/blockchain/cached-did-resolver.d.ts.map +1 -0
  47. package/lib/src/services/blockchain/cached-did-resolver.test.d.ts +2 -0
  48. package/lib/src/services/blockchain/cached-did-resolver.test.d.ts.map +1 -0
  49. package/lib/src/services/blockchain/service.d.ts +114 -17
  50. package/lib/src/services/blockchain/service.d.ts.map +1 -1
  51. package/lib/src/services/credential/config.d.ts.map +1 -1
  52. package/lib/src/services/credential/index.d.ts +3 -0
  53. package/lib/src/services/credential/index.d.ts.map +1 -1
  54. package/lib/src/services/credential/sd-jwt.test.d.ts +2 -0
  55. package/lib/src/services/credential/sd-jwt.test.d.ts.map +1 -0
  56. package/lib/src/services/credential/service.d.ts +274 -4
  57. package/lib/src/services/credential/service.d.ts.map +1 -1
  58. package/lib/src/services/edv/service.d.ts +151 -1
  59. package/lib/src/services/edv/service.d.ts.map +1 -1
  60. package/lib/src/services/relay-service/service.d.ts +129 -1
  61. package/lib/src/services/relay-service/service.d.ts.map +1 -1
  62. package/lib/src/services/rpc-service-client.d.ts +2 -2
  63. package/lib/src/services/rpc-service-client.d.ts.map +1 -1
  64. package/lib/src/services/storage/index.d.ts +1 -1
  65. package/lib/src/services/storage/index.d.ts.map +1 -1
  66. package/lib/src/services/storage/service-rpc.d.ts +9 -0
  67. package/lib/src/services/storage/service-rpc.d.ts.map +1 -0
  68. package/lib/src/services/storage/service.d.ts +1 -0
  69. package/lib/src/services/storage/service.d.ts.map +1 -1
  70. package/lib/src/services/util-crypto/service.d.ts +1 -1
  71. package/lib/tsconfig.tsbuildinfo +1 -1
  72. package/lib/wallet/rpc-storage-interface.js +13 -3
  73. package/lib/wallet/rpc-storage-interface.mjs +11 -1
  74. package/lib/wallet/rpc-storage-wallet.js +10 -0
  75. package/lib/wallet/rpc-storage-wallet.mjs +10 -0
  76. package/package.json +13 -8
  77. package/src/services/blockchain/cached-did-resolver.test.ts +288 -0
  78. package/src/services/blockchain/cached-did-resolver.ts +126 -0
  79. package/src/services/blockchain/service-rpc.js +12 -0
  80. package/src/services/blockchain/service.ts +142 -11
  81. package/src/services/credential/config.ts +7 -1
  82. package/src/services/credential/sd-jwt.test.ts +718 -0
  83. package/src/services/credential/sd-jwt.ts +231 -0
  84. package/src/services/credential/service-rpc.js +9 -0
  85. package/src/services/credential/service.ts +328 -7
  86. package/src/services/edv/service.ts +153 -1
  87. package/src/services/relay-service/service.ts +130 -1
  88. package/src/services/rpc-service-client.js +0 -3
  89. package/src/services/storage/index.js +15 -1
  90. package/src/services/storage/service-rpc.js +7 -3
  91. package/src/services/storage/service.ts +5 -0
@@ -13,19 +13,43 @@ var core_logger = require('../../core/logger.js');
13
13
  var modules_eventManager = require('../../modules/event-manager.js');
14
14
  var services_utilCrypto_service = require('../util-crypto/service.js');
15
15
  var types = require('@docknetwork/credential-sdk/types');
16
+ var services_blockchain_cachedDidResolver = require('./cached-did-resolver.js');
16
17
  require('assert');
17
18
  require('@docknetwork/credential-sdk/utils');
18
19
  require('@scure/bip39');
19
20
  require('@scure/bip39/wordlists/english');
20
21
  require('../util-crypto/configs.js');
22
+ require('../storage/index.js');
23
+ require('../storage/service.js');
24
+ require('../storage/service-rpc.js');
25
+ require('../rpc-service-client.js');
26
+ require('../../rpc-client.js');
27
+ require('json-rpc-2.0');
28
+ require('../../core/crypto.js');
29
+ require('crypto');
30
+ require('../../logger.js');
31
+ require('../../rpc-util.js');
21
32
 
22
33
  // @ts-nocheck
34
+ /**
35
+ * Universal resolver URL for DID resolution fallback
36
+ * @constant {string}
37
+ */
23
38
  const universalResolverUrl = 'https://uniresolver.truvera.io';
39
+ /**
40
+ * Resolver that accepts any DID method using wildcard matching
41
+ * @class
42
+ * @extends ResolverRouter
43
+ * @private
44
+ */
24
45
  class AnyDIDResolver extends resolver.ResolverRouter {
25
46
  method = resolver.WILDCARD;
26
47
  }
27
48
  /**
28
- *
49
+ * Main blockchain service class for managing blockchain connections and DID resolution
50
+ * @class
51
+ * @description Provides methods for connecting to Cheqd blockchain, resolving DIDs,
52
+ * and managing blockchain-related operations
29
53
  */
30
54
  class BlockchainService {
31
55
  dock;
@@ -34,6 +58,12 @@ class BlockchainService {
34
58
  cheqdApiUrl;
35
59
  isBlockchainReady = false;
36
60
  resolver;
61
+ /**
62
+ * Event names emitted by the blockchain service
63
+ * @static
64
+ * @readonly
65
+ * @property {string} BLOCKCHAIN_READY - Emitted when blockchain connection is established
66
+ */
37
67
  static Events = {
38
68
  BLOCKCHAIN_READY: 'blockchain-ready',
39
69
  };
@@ -43,7 +73,15 @@ class BlockchainService {
43
73
  BlockchainService.prototype.init,
44
74
  BlockchainService.prototype.isApiConnected,
45
75
  BlockchainService.prototype.getAddress,
76
+ BlockchainService.prototype.resolveDID,
77
+ BlockchainService.prototype.getCachedDIDs,
78
+ BlockchainService.prototype.clearCache,
79
+ BlockchainService.prototype.getCacheEntry,
46
80
  ];
81
+ /**
82
+ * Creates a new BlockchainService instance
83
+ * @constructor
84
+ */
47
85
  constructor() {
48
86
  this.name = 'blockchain';
49
87
  this.cheqdApi = new cheqdBlockchainApi.CheqdAPI();
@@ -52,6 +90,15 @@ class BlockchainService {
52
90
  this.emitter = new events.EventEmitter();
53
91
  this.resolver = this.createDIDResolver();
54
92
  }
93
+ /**
94
+ * Gets the types and modules needed for DID or accumulator operations
95
+ * @param {string} didOrRegistryId - DID or registry identifier
96
+ * @returns {Object} Object containing accumulator-related types and modules
97
+ * @returns {typeof AccumulatorPublicKey} returns.PublicKey - Accumulator public key type
98
+ * @returns {typeof AccumulatorId} returns.AccumulatorId - Accumulator ID type
99
+ * @returns {typeof AccumulatorCommon} returns.AccumulatorCommon - Common accumulator type
100
+ * @returns {Object} returns.AccumulatorModule - Accumulator module instance
101
+ */
55
102
  getTypesForDIDOrAccumulator(didOrRegistryId) {
56
103
  return {
57
104
  PublicKey: types.AccumulatorPublicKey,
@@ -61,8 +108,11 @@ class BlockchainService {
61
108
  };
62
109
  }
63
110
  /**
64
- *
65
- * @returns
111
+ * Ensures the blockchain connection is ready before proceeding
112
+ * @returns {Promise<void>} Resolves when blockchain is ready
113
+ * @example
114
+ * await blockchainService.ensureBlockchainReady();
115
+ * // Blockchain is now connected and ready
66
116
  */
67
117
  async ensureBlockchainReady() {
68
118
  if (await this.isApiConnected()) {
@@ -70,17 +120,55 @@ class BlockchainService {
70
120
  }
71
121
  return modules_eventManager.once(this.emitter, BlockchainService.Events.BLOCKCHAIN_READY);
72
122
  }
123
+ /**
124
+ * Gets the cached DIDs
125
+ * @returns {Promise<string[]>} Cached DIDs
126
+ */
127
+ getCachedDIDs() {
128
+ return this.resolver.getCachedDIDs();
129
+ }
130
+ /**
131
+ * Gets the cached DID resolution data
132
+ * @param {string} did - The DID to get the cache entry for
133
+ * @returns {Promise<any>} Cached DID resolution data
134
+ */
135
+ getCacheEntry(did) {
136
+ return this.resolver.getCacheEntry(did);
137
+ }
138
+ /**
139
+ * Clears cached data for a specific DID
140
+ * @param {string} did - The DID to clear from cache
141
+ * @returns {void}
142
+ */
143
+ clearCache(did) {
144
+ return this.resolver.clearCache(did);
145
+ }
146
+ /**
147
+ * Creates a DID resolver with caching support
148
+ * @private
149
+ * @returns {CachedDIDResolver} Cached DID resolver instance
150
+ */
73
151
  createDIDResolver() {
74
- return new AnyDIDResolver([
152
+ const router = new AnyDIDResolver([
75
153
  new resolver.DIDKeyResolver(),
76
154
  new resolver.CoreResolver(this.modules),
77
155
  new resolver.UniversalResolver(universalResolverUrl),
78
156
  ]);
157
+ return new services_blockchain_cachedDidResolver.CachedDIDResolver(router);
79
158
  }
80
159
  /**
81
- *
82
- * @param {*} params
83
- * @returns
160
+ * Initializes the blockchain service with connection parameters
161
+ * @param {InitParams} params - Initialization parameters
162
+ * @param {string} params.cheqdApiUrl - URL of the Cheqd API endpoint
163
+ * @param {string} [params.networkId] - Cheqd network identifier
164
+ * @param {string} [params.cheqdMnemonic] - Mnemonic for Cheqd wallet (auto-generated if not provided)
165
+ * @returns {Promise<boolean>} True if initialization successful
166
+ * @throws {Error} If cheqdApiUrl is not provided
167
+ * @example
168
+ * await blockchainService.init({
169
+ * cheqdApiUrl: 'https://api.cheqd.network',
170
+ * networkId: 'mainnet'
171
+ * });
84
172
  */
85
173
  async init(params) {
86
174
  if (!params?.cheqdApiUrl) {
@@ -122,8 +210,10 @@ class BlockchainService {
122
210
  return true;
123
211
  }
124
212
  /**
125
- *
126
- * @returns
213
+ * Disconnects from the blockchain
214
+ * @returns {Promise<void>} Resolves when disconnection is complete
215
+ * @example
216
+ * await blockchainService.disconnect();
127
217
  */
128
218
  async disconnect() {
129
219
  let result;
@@ -133,6 +223,11 @@ class BlockchainService {
133
223
  this._setBlockchainReady(false);
134
224
  return result;
135
225
  }
226
+ /**
227
+ * Waits for the blockchain to be ready
228
+ * @returns {Promise<void>} Resolves when blockchain is ready
229
+ * @private
230
+ */
136
231
  async waitBlockchainReady() {
137
232
  return new Promise(resolve => {
138
233
  if (this.isBlockchainReady) {
@@ -143,19 +238,39 @@ class BlockchainService {
143
238
  }
144
239
  });
145
240
  }
241
+ /**
242
+ * Resolves a DID to its document
243
+ * @param {string} did - The DID to resolve
244
+ * @returns {Promise<Object>} The resolved DID document
245
+ * @example
246
+ * const didDoc = await blockchainService.resolveDID('did:key:z6Mk...');
247
+ */
146
248
  async resolveDID(did) {
147
249
  return this.resolver.resolve(did);
148
250
  }
149
251
  /**
150
- *
151
- * @returns
252
+ * Checks if the blockchain API is connected
253
+ * @returns {Promise<boolean>} True if connected, false otherwise
254
+ * @example
255
+ * const isConnected = await blockchainService.isApiConnected();
152
256
  */
153
257
  async isApiConnected() {
154
258
  return this.cheqdApi.isInitialized();
155
259
  }
260
+ /**
261
+ * Gets the current Cheqd API URL
262
+ * @returns {Promise<string>} The Cheqd API URL
263
+ * @example
264
+ * const apiUrl = await blockchainService.getAddress();
265
+ */
156
266
  async getAddress() {
157
267
  return this.cheqdApiUrl;
158
268
  }
269
+ /**
270
+ * Sets the blockchain ready state and emits events
271
+ * @private
272
+ * @param {boolean} isBlockchainReady - Whether blockchain is ready
273
+ */
159
274
  _setBlockchainReady(isBlockchainReady) {
160
275
  this.isBlockchainReady = isBlockchainReady;
161
276
  if (isBlockchainReady) {
@@ -163,6 +278,20 @@ class BlockchainService {
163
278
  }
164
279
  }
165
280
  }
281
+ /**
282
+ * Singleton instance of the blockchain service
283
+ * @type {BlockchainService}
284
+ * @example
285
+ * import { blockchainService } from '@docknetwork/wallet-sdk-wasm/services/blockchain';
286
+ *
287
+ * // Initialize the service
288
+ * await blockchainService.init({
289
+ * cheqdApiUrl: 'https://api.cheqd.network'
290
+ * });
291
+ *
292
+ * // Resolve a DID
293
+ * const didDoc = await blockchainService.resolveDID('did:key:z6Mk...');
294
+ */
166
295
  const blockchainService = new BlockchainService();
167
296
 
168
297
  exports.BlockchainService = BlockchainService;
@@ -9,19 +9,43 @@ import { Logger } from '../../core/logger.mjs';
9
9
  import { once } from '../../modules/event-manager.mjs';
10
10
  import { utilCryptoService } from '../util-crypto/service.mjs';
11
11
  import { AccumulatorPublicKey, AccumulatorId, AccumulatorCommon } from '@docknetwork/credential-sdk/types';
12
+ import { CachedDIDResolver } from './cached-did-resolver.mjs';
12
13
  import 'assert';
13
14
  import '@docknetwork/credential-sdk/utils';
14
15
  import '@scure/bip39';
15
16
  import '@scure/bip39/wordlists/english';
16
17
  import '../util-crypto/configs.mjs';
18
+ import '../storage/index.mjs';
19
+ import '../storage/service.mjs';
20
+ import '../storage/service-rpc.mjs';
21
+ import '../rpc-service-client.mjs';
22
+ import '../../rpc-client.mjs';
23
+ import 'json-rpc-2.0';
24
+ import '../../core/crypto.mjs';
25
+ import 'crypto';
26
+ import '../../logger.mjs';
27
+ import '../../rpc-util.mjs';
17
28
 
18
29
  // @ts-nocheck
30
+ /**
31
+ * Universal resolver URL for DID resolution fallback
32
+ * @constant {string}
33
+ */
19
34
  const universalResolverUrl = 'https://uniresolver.truvera.io';
35
+ /**
36
+ * Resolver that accepts any DID method using wildcard matching
37
+ * @class
38
+ * @extends ResolverRouter
39
+ * @private
40
+ */
20
41
  class AnyDIDResolver extends ResolverRouter {
21
42
  method = WILDCARD;
22
43
  }
23
44
  /**
24
- *
45
+ * Main blockchain service class for managing blockchain connections and DID resolution
46
+ * @class
47
+ * @description Provides methods for connecting to Cheqd blockchain, resolving DIDs,
48
+ * and managing blockchain-related operations
25
49
  */
26
50
  class BlockchainService {
27
51
  dock;
@@ -30,6 +54,12 @@ class BlockchainService {
30
54
  cheqdApiUrl;
31
55
  isBlockchainReady = false;
32
56
  resolver;
57
+ /**
58
+ * Event names emitted by the blockchain service
59
+ * @static
60
+ * @readonly
61
+ * @property {string} BLOCKCHAIN_READY - Emitted when blockchain connection is established
62
+ */
33
63
  static Events = {
34
64
  BLOCKCHAIN_READY: 'blockchain-ready',
35
65
  };
@@ -39,7 +69,15 @@ class BlockchainService {
39
69
  BlockchainService.prototype.init,
40
70
  BlockchainService.prototype.isApiConnected,
41
71
  BlockchainService.prototype.getAddress,
72
+ BlockchainService.prototype.resolveDID,
73
+ BlockchainService.prototype.getCachedDIDs,
74
+ BlockchainService.prototype.clearCache,
75
+ BlockchainService.prototype.getCacheEntry,
42
76
  ];
77
+ /**
78
+ * Creates a new BlockchainService instance
79
+ * @constructor
80
+ */
43
81
  constructor() {
44
82
  this.name = 'blockchain';
45
83
  this.cheqdApi = new CheqdAPI();
@@ -48,6 +86,15 @@ class BlockchainService {
48
86
  this.emitter = new EventEmitter();
49
87
  this.resolver = this.createDIDResolver();
50
88
  }
89
+ /**
90
+ * Gets the types and modules needed for DID or accumulator operations
91
+ * @param {string} didOrRegistryId - DID or registry identifier
92
+ * @returns {Object} Object containing accumulator-related types and modules
93
+ * @returns {typeof AccumulatorPublicKey} returns.PublicKey - Accumulator public key type
94
+ * @returns {typeof AccumulatorId} returns.AccumulatorId - Accumulator ID type
95
+ * @returns {typeof AccumulatorCommon} returns.AccumulatorCommon - Common accumulator type
96
+ * @returns {Object} returns.AccumulatorModule - Accumulator module instance
97
+ */
51
98
  getTypesForDIDOrAccumulator(didOrRegistryId) {
52
99
  return {
53
100
  PublicKey: AccumulatorPublicKey,
@@ -57,8 +104,11 @@ class BlockchainService {
57
104
  };
58
105
  }
59
106
  /**
60
- *
61
- * @returns
107
+ * Ensures the blockchain connection is ready before proceeding
108
+ * @returns {Promise<void>} Resolves when blockchain is ready
109
+ * @example
110
+ * await blockchainService.ensureBlockchainReady();
111
+ * // Blockchain is now connected and ready
62
112
  */
63
113
  async ensureBlockchainReady() {
64
114
  if (await this.isApiConnected()) {
@@ -66,17 +116,55 @@ class BlockchainService {
66
116
  }
67
117
  return once(this.emitter, BlockchainService.Events.BLOCKCHAIN_READY);
68
118
  }
119
+ /**
120
+ * Gets the cached DIDs
121
+ * @returns {Promise<string[]>} Cached DIDs
122
+ */
123
+ getCachedDIDs() {
124
+ return this.resolver.getCachedDIDs();
125
+ }
126
+ /**
127
+ * Gets the cached DID resolution data
128
+ * @param {string} did - The DID to get the cache entry for
129
+ * @returns {Promise<any>} Cached DID resolution data
130
+ */
131
+ getCacheEntry(did) {
132
+ return this.resolver.getCacheEntry(did);
133
+ }
134
+ /**
135
+ * Clears cached data for a specific DID
136
+ * @param {string} did - The DID to clear from cache
137
+ * @returns {void}
138
+ */
139
+ clearCache(did) {
140
+ return this.resolver.clearCache(did);
141
+ }
142
+ /**
143
+ * Creates a DID resolver with caching support
144
+ * @private
145
+ * @returns {CachedDIDResolver} Cached DID resolver instance
146
+ */
69
147
  createDIDResolver() {
70
- return new AnyDIDResolver([
148
+ const router = new AnyDIDResolver([
71
149
  new DIDKeyResolver(),
72
150
  new CoreResolver(this.modules),
73
151
  new UniversalResolver(universalResolverUrl),
74
152
  ]);
153
+ return new CachedDIDResolver(router);
75
154
  }
76
155
  /**
77
- *
78
- * @param {*} params
79
- * @returns
156
+ * Initializes the blockchain service with connection parameters
157
+ * @param {InitParams} params - Initialization parameters
158
+ * @param {string} params.cheqdApiUrl - URL of the Cheqd API endpoint
159
+ * @param {string} [params.networkId] - Cheqd network identifier
160
+ * @param {string} [params.cheqdMnemonic] - Mnemonic for Cheqd wallet (auto-generated if not provided)
161
+ * @returns {Promise<boolean>} True if initialization successful
162
+ * @throws {Error} If cheqdApiUrl is not provided
163
+ * @example
164
+ * await blockchainService.init({
165
+ * cheqdApiUrl: 'https://api.cheqd.network',
166
+ * networkId: 'mainnet'
167
+ * });
80
168
  */
81
169
  async init(params) {
82
170
  if (!params?.cheqdApiUrl) {
@@ -118,8 +206,10 @@ class BlockchainService {
118
206
  return true;
119
207
  }
120
208
  /**
121
- *
122
- * @returns
209
+ * Disconnects from the blockchain
210
+ * @returns {Promise<void>} Resolves when disconnection is complete
211
+ * @example
212
+ * await blockchainService.disconnect();
123
213
  */
124
214
  async disconnect() {
125
215
  let result;
@@ -129,6 +219,11 @@ class BlockchainService {
129
219
  this._setBlockchainReady(false);
130
220
  return result;
131
221
  }
222
+ /**
223
+ * Waits for the blockchain to be ready
224
+ * @returns {Promise<void>} Resolves when blockchain is ready
225
+ * @private
226
+ */
132
227
  async waitBlockchainReady() {
133
228
  return new Promise(resolve => {
134
229
  if (this.isBlockchainReady) {
@@ -139,19 +234,39 @@ class BlockchainService {
139
234
  }
140
235
  });
141
236
  }
237
+ /**
238
+ * Resolves a DID to its document
239
+ * @param {string} did - The DID to resolve
240
+ * @returns {Promise<Object>} The resolved DID document
241
+ * @example
242
+ * const didDoc = await blockchainService.resolveDID('did:key:z6Mk...');
243
+ */
142
244
  async resolveDID(did) {
143
245
  return this.resolver.resolve(did);
144
246
  }
145
247
  /**
146
- *
147
- * @returns
248
+ * Checks if the blockchain API is connected
249
+ * @returns {Promise<boolean>} True if connected, false otherwise
250
+ * @example
251
+ * const isConnected = await blockchainService.isApiConnected();
148
252
  */
149
253
  async isApiConnected() {
150
254
  return this.cheqdApi.isInitialized();
151
255
  }
256
+ /**
257
+ * Gets the current Cheqd API URL
258
+ * @returns {Promise<string>} The Cheqd API URL
259
+ * @example
260
+ * const apiUrl = await blockchainService.getAddress();
261
+ */
152
262
  async getAddress() {
153
263
  return this.cheqdApiUrl;
154
264
  }
265
+ /**
266
+ * Sets the blockchain ready state and emits events
267
+ * @private
268
+ * @param {boolean} isBlockchainReady - Whether blockchain is ready
269
+ */
155
270
  _setBlockchainReady(isBlockchainReady) {
156
271
  this.isBlockchainReady = isBlockchainReady;
157
272
  if (isBlockchainReady) {
@@ -159,6 +274,20 @@ class BlockchainService {
159
274
  }
160
275
  }
161
276
  }
277
+ /**
278
+ * Singleton instance of the blockchain service
279
+ * @type {BlockchainService}
280
+ * @example
281
+ * import { blockchainService } from '@docknetwork/wallet-sdk-wasm/services/blockchain';
282
+ *
283
+ * // Initialize the service
284
+ * await blockchainService.init({
285
+ * cheqdApiUrl: 'https://api.cheqd.network'
286
+ * });
287
+ *
288
+ * // Resolve a DID
289
+ * const didDoc = await blockchainService.resolveDID('did:key:z6Mk...');
290
+ */
162
291
  const blockchainService = new BlockchainService();
163
292
 
164
293
  export { BlockchainService, blockchainService, universalResolverUrl };
@@ -20,6 +20,17 @@ require('@scure/bip39');
20
20
  require('@scure/bip39/wordlists/english');
21
21
  require('../util-crypto/configs.js');
22
22
  require('@docknetwork/credential-sdk/types');
23
+ require('../blockchain/cached-did-resolver.js');
24
+ require('../storage/index.js');
25
+ require('../storage/service.js');
26
+ require('../storage/service-rpc.js');
27
+ require('../rpc-service-client.js');
28
+ require('../../rpc-client.js');
29
+ require('json-rpc-2.0');
30
+ require('../../core/crypto.js');
31
+ require('crypto');
32
+ require('../../logger.js');
33
+ require('../../rpc-util.js');
23
34
 
24
35
  const getWitnessDetails = async (credential, _membershipWitness) => {
25
36
  let witness = _membershipWitness;
@@ -16,6 +16,17 @@ import '@scure/bip39';
16
16
  import '@scure/bip39/wordlists/english';
17
17
  import '../util-crypto/configs.mjs';
18
18
  import '@docknetwork/credential-sdk/types';
19
+ import '../blockchain/cached-did-resolver.mjs';
20
+ import '../storage/index.mjs';
21
+ import '../storage/service.mjs';
22
+ import '../storage/service-rpc.mjs';
23
+ import '../rpc-service-client.mjs';
24
+ import '../../rpc-client.mjs';
25
+ import 'json-rpc-2.0';
26
+ import '../../core/crypto.mjs';
27
+ import 'crypto';
28
+ import '../../logger.mjs';
29
+ import '../../rpc-util.mjs';
19
30
 
20
31
  const getWitnessDetails = async (credential, _membershipWitness) => {
21
32
  let witness = _membershipWitness;
@@ -20,7 +20,10 @@ const validation = {
20
20
  },
21
21
  verifyCredential: params => {
22
22
  const { credential } = params;
23
- assert__default["default"](typeof credential === 'object', 'invalid credential');
23
+ assert__default["default"](typeof credential === 'object' || typeof credential === 'string', 'invalid credential');
24
+ if (typeof credential === 'object') {
25
+ assert__default["default"](Object.keys(credential).length > 0, 'invalid credential');
26
+ }
24
27
  },
25
28
  createBBSPresentation: params => {
26
29
  const { credentials } = params;
@@ -12,7 +12,10 @@ const validation = {
12
12
  },
13
13
  verifyCredential: params => {
14
14
  const { credential } = params;
15
- assert(typeof credential === 'object', 'invalid credential');
15
+ assert(typeof credential === 'object' || typeof credential === 'string', 'invalid credential');
16
+ if (typeof credential === 'object') {
17
+ assert(Object.keys(credential).length > 0, 'invalid credential');
18
+ }
16
19
  },
17
20
  createBBSPresentation: params => {
18
21
  const { credentials } = params;
@@ -27,6 +27,17 @@ require('@scure/bip39');
27
27
  require('@scure/bip39/wordlists/english');
28
28
  require('../util-crypto/configs.js');
29
29
  require('@docknetwork/credential-sdk/types');
30
+ require('../blockchain/cached-did-resolver.js');
31
+ require('../storage/index.js');
32
+ require('../storage/service.js');
33
+ require('../storage/service-rpc.js');
34
+ require('../rpc-service-client.js');
35
+ require('../../rpc-client.js');
36
+ require('json-rpc-2.0');
37
+ require('../../core/crypto.js');
38
+ require('crypto');
39
+ require('../../logger.js');
40
+ require('../../rpc-util.js');
30
41
  require('./bound-check.js');
31
42
  require('@docknetwork/crypto-wasm-ts/lib/legosnark');
32
43
  require('base64url');
@@ -45,6 +56,9 @@ require('@digitalbazaar/x25519-key-agreement-key-2019');
45
56
  require('@digitalbazaar/ed25519-verification-key-2018');
46
57
  require('@digitalbazaar/ed25519-verification-key-2020');
47
58
  require('../dids/keypair-utils.js');
59
+ require('./sd-jwt.js');
60
+ require('@sd-jwt/sd-jwt-vc');
61
+ require('@sd-jwt/crypto-nodejs');
48
62
 
49
63
  // @ts-nocheck
50
64
  // TODO: rename it to credentialService, will need to update dock-app
@@ -23,6 +23,17 @@ import '@scure/bip39';
23
23
  import '@scure/bip39/wordlists/english';
24
24
  import '../util-crypto/configs.mjs';
25
25
  import '@docknetwork/credential-sdk/types';
26
+ import '../blockchain/cached-did-resolver.mjs';
27
+ import '../storage/index.mjs';
28
+ import '../storage/service.mjs';
29
+ import '../storage/service-rpc.mjs';
30
+ import '../rpc-service-client.mjs';
31
+ import '../../rpc-client.mjs';
32
+ import 'json-rpc-2.0';
33
+ import '../../core/crypto.mjs';
34
+ import 'crypto';
35
+ import '../../logger.mjs';
36
+ import '../../rpc-util.mjs';
26
37
  import './bound-check.mjs';
27
38
  import '@docknetwork/crypto-wasm-ts/lib/legosnark';
28
39
  import 'base64url';
@@ -41,6 +52,9 @@ import '@digitalbazaar/x25519-key-agreement-key-2019';
41
52
  import '@digitalbazaar/ed25519-verification-key-2018';
42
53
  import '@digitalbazaar/ed25519-verification-key-2020';
43
54
  import '../dids/keypair-utils.mjs';
55
+ import './sd-jwt.mjs';
56
+ import '@sd-jwt/sd-jwt-vc';
57
+ import '@sd-jwt/crypto-nodejs';
44
58
 
45
59
  // @ts-nocheck
46
60
  // TODO: rename it to credentialService, will need to update dock-app