@docknetwork/wallet-sdk-relay-service 1.5.6 → 1.5.9

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.
@@ -0,0 +1,411 @@
1
+ function _arrayLikeToArray(r, a) {
2
+ (null == a || a > r.length) && (a = r.length);
3
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
4
+ return n;
5
+ }
6
+ function _arrayWithoutHoles(r) {
7
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
8
+ }
9
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
10
+ try {
11
+ var i = n[a](c),
12
+ u = i.value;
13
+ } catch (n) {
14
+ return void e(n);
15
+ }
16
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
17
+ }
18
+ function _asyncToGenerator(n) {
19
+ return function () {
20
+ var t = this,
21
+ e = arguments;
22
+ return new Promise(function (r, o) {
23
+ var a = n.apply(t, e);
24
+ function _next(n) {
25
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
26
+ }
27
+ function _throw(n) {
28
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
29
+ }
30
+ _next(void 0);
31
+ });
32
+ };
33
+ }
34
+ function _createForOfIteratorHelper(r, e) {
35
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
36
+ if (!t) {
37
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
38
+ t && (r = t);
39
+ var n = 0,
40
+ F = function () {};
41
+ return {
42
+ s: F,
43
+ n: function () {
44
+ return n >= r.length ? {
45
+ done: !0
46
+ } : {
47
+ done: !1,
48
+ value: r[n++]
49
+ };
50
+ },
51
+ e: function (r) {
52
+ throw r;
53
+ },
54
+ f: F
55
+ };
56
+ }
57
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
58
+ }
59
+ var o,
60
+ a = !0,
61
+ u = !1;
62
+ return {
63
+ s: function () {
64
+ t = t.call(r);
65
+ },
66
+ n: function () {
67
+ var r = t.next();
68
+ return a = r.done, r;
69
+ },
70
+ e: function (r) {
71
+ u = !0, o = r;
72
+ },
73
+ f: function () {
74
+ try {
75
+ a || null == t.return || t.return();
76
+ } finally {
77
+ if (u) throw o;
78
+ }
79
+ }
80
+ };
81
+ }
82
+ function _defineProperty(e, r, t) {
83
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
84
+ value: t,
85
+ enumerable: !0,
86
+ configurable: !0,
87
+ writable: !0
88
+ }) : e[r] = t, e;
89
+ }
90
+ function _iterableToArray(r) {
91
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
92
+ }
93
+ function _nonIterableSpread() {
94
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
95
+ }
96
+ function ownKeys(e, r) {
97
+ var t = Object.keys(e);
98
+ if (Object.getOwnPropertySymbols) {
99
+ var o = Object.getOwnPropertySymbols(e);
100
+ r && (o = o.filter(function (r) {
101
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
102
+ })), t.push.apply(t, o);
103
+ }
104
+ return t;
105
+ }
106
+ function _objectSpread2(e) {
107
+ for (var r = 1; r < arguments.length; r++) {
108
+ var t = null != arguments[r] ? arguments[r] : {};
109
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
110
+ _defineProperty(e, r, t[r]);
111
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
112
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
113
+ });
114
+ }
115
+ return e;
116
+ }
117
+ function _regeneratorRuntime() {
118
+ _regeneratorRuntime = function () {
119
+ return r;
120
+ };
121
+ var t,
122
+ r = {},
123
+ e = Object.prototype,
124
+ n = e.hasOwnProperty,
125
+ o = "function" == typeof Symbol ? Symbol : {},
126
+ i = o.iterator || "@@iterator",
127
+ a = o.asyncIterator || "@@asyncIterator",
128
+ u = o.toStringTag || "@@toStringTag";
129
+ function c(t, r, e, n) {
130
+ return Object.defineProperty(t, r, {
131
+ value: e,
132
+ enumerable: !n,
133
+ configurable: !n,
134
+ writable: !n
135
+ });
136
+ }
137
+ try {
138
+ c({}, "");
139
+ } catch (t) {
140
+ c = function (t, r, e) {
141
+ return t[r] = e;
142
+ };
143
+ }
144
+ function h(r, e, n, o) {
145
+ var i = e && e.prototype instanceof Generator ? e : Generator,
146
+ a = Object.create(i.prototype);
147
+ return c(a, "_invoke", function (r, e, n) {
148
+ var o = 1;
149
+ return function (i, a) {
150
+ if (3 === o) throw Error("Generator is already running");
151
+ if (4 === o) {
152
+ if ("throw" === i) throw a;
153
+ return {
154
+ value: t,
155
+ done: !0
156
+ };
157
+ }
158
+ for (n.method = i, n.arg = a;;) {
159
+ var u = n.delegate;
160
+ if (u) {
161
+ var c = d(u, n);
162
+ if (c) {
163
+ if (c === f) continue;
164
+ return c;
165
+ }
166
+ }
167
+ if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
168
+ if (1 === o) throw o = 4, n.arg;
169
+ n.dispatchException(n.arg);
170
+ } else "return" === n.method && n.abrupt("return", n.arg);
171
+ o = 3;
172
+ var h = s(r, e, n);
173
+ if ("normal" === h.type) {
174
+ if (o = n.done ? 4 : 2, h.arg === f) continue;
175
+ return {
176
+ value: h.arg,
177
+ done: n.done
178
+ };
179
+ }
180
+ "throw" === h.type && (o = 4, n.method = "throw", n.arg = h.arg);
181
+ }
182
+ };
183
+ }(r, n, new Context(o || [])), !0), a;
184
+ }
185
+ function s(t, r, e) {
186
+ try {
187
+ return {
188
+ type: "normal",
189
+ arg: t.call(r, e)
190
+ };
191
+ } catch (t) {
192
+ return {
193
+ type: "throw",
194
+ arg: t
195
+ };
196
+ }
197
+ }
198
+ r.wrap = h;
199
+ var f = {};
200
+ function Generator() {}
201
+ function GeneratorFunction() {}
202
+ function GeneratorFunctionPrototype() {}
203
+ var l = {};
204
+ c(l, i, function () {
205
+ return this;
206
+ });
207
+ var p = Object.getPrototypeOf,
208
+ y = p && p(p(x([])));
209
+ y && y !== e && n.call(y, i) && (l = y);
210
+ var v = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(l);
211
+ function g(t) {
212
+ ["next", "throw", "return"].forEach(function (r) {
213
+ c(t, r, function (t) {
214
+ return this._invoke(r, t);
215
+ });
216
+ });
217
+ }
218
+ function AsyncIterator(t, r) {
219
+ function e(o, i, a, u) {
220
+ var c = s(t[o], t, i);
221
+ if ("throw" !== c.type) {
222
+ var h = c.arg,
223
+ f = h.value;
224
+ return f && "object" == typeof f && n.call(f, "__await") ? r.resolve(f.__await).then(function (t) {
225
+ e("next", t, a, u);
226
+ }, function (t) {
227
+ e("throw", t, a, u);
228
+ }) : r.resolve(f).then(function (t) {
229
+ h.value = t, a(h);
230
+ }, function (t) {
231
+ return e("throw", t, a, u);
232
+ });
233
+ }
234
+ u(c.arg);
235
+ }
236
+ var o;
237
+ c(this, "_invoke", function (t, n) {
238
+ function i() {
239
+ return new r(function (r, o) {
240
+ e(t, n, r, o);
241
+ });
242
+ }
243
+ return o = o ? o.then(i, i) : i();
244
+ }, !0);
245
+ }
246
+ function d(r, e) {
247
+ var n = e.method,
248
+ o = r.i[n];
249
+ if (o === t) return e.delegate = null, "throw" === n && r.i.return && (e.method = "return", e.arg = t, d(r, e), "throw" === e.method) || "return" !== n && (e.method = "throw", e.arg = new TypeError("The iterator does not provide a '" + n + "' method")), f;
250
+ var i = s(o, r.i, e.arg);
251
+ if ("throw" === i.type) return e.method = "throw", e.arg = i.arg, e.delegate = null, f;
252
+ var a = i.arg;
253
+ return a ? a.done ? (e[r.r] = a.value, e.next = r.n, "return" !== e.method && (e.method = "next", e.arg = t), e.delegate = null, f) : a : (e.method = "throw", e.arg = new TypeError("iterator result is not an object"), e.delegate = null, f);
254
+ }
255
+ function w(t) {
256
+ this.tryEntries.push(t);
257
+ }
258
+ function m(r) {
259
+ var e = r[4] || {};
260
+ e.type = "normal", e.arg = t, r[4] = e;
261
+ }
262
+ function Context(t) {
263
+ this.tryEntries = [[-1]], t.forEach(w, this), this.reset(!0);
264
+ }
265
+ function x(r) {
266
+ if (null != r) {
267
+ var e = r[i];
268
+ if (e) return e.call(r);
269
+ if ("function" == typeof r.next) return r;
270
+ if (!isNaN(r.length)) {
271
+ var o = -1,
272
+ a = function e() {
273
+ for (; ++o < r.length;) if (n.call(r, o)) return e.value = r[o], e.done = !1, e;
274
+ return e.value = t, e.done = !0, e;
275
+ };
276
+ return a.next = a;
277
+ }
278
+ }
279
+ throw new TypeError(typeof r + " is not iterable");
280
+ }
281
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, c(v, "constructor", GeneratorFunctionPrototype), c(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = c(GeneratorFunctionPrototype, u, "GeneratorFunction"), r.isGeneratorFunction = function (t) {
282
+ var r = "function" == typeof t && t.constructor;
283
+ return !!r && (r === GeneratorFunction || "GeneratorFunction" === (r.displayName || r.name));
284
+ }, r.mark = function (t) {
285
+ return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, c(t, u, "GeneratorFunction")), t.prototype = Object.create(v), t;
286
+ }, r.awrap = function (t) {
287
+ return {
288
+ __await: t
289
+ };
290
+ }, g(AsyncIterator.prototype), c(AsyncIterator.prototype, a, function () {
291
+ return this;
292
+ }), r.AsyncIterator = AsyncIterator, r.async = function (t, e, n, o, i) {
293
+ void 0 === i && (i = Promise);
294
+ var a = new AsyncIterator(h(t, e, n, o), i);
295
+ return r.isGeneratorFunction(e) ? a : a.next().then(function (t) {
296
+ return t.done ? t.value : a.next();
297
+ });
298
+ }, g(v), c(v, u, "Generator"), c(v, i, function () {
299
+ return this;
300
+ }), c(v, "toString", function () {
301
+ return "[object Generator]";
302
+ }), r.keys = function (t) {
303
+ var r = Object(t),
304
+ e = [];
305
+ for (var n in r) e.unshift(n);
306
+ return function t() {
307
+ for (; e.length;) if ((n = e.pop()) in r) return t.value = n, t.done = !1, t;
308
+ return t.done = !0, t;
309
+ };
310
+ }, r.values = x, Context.prototype = {
311
+ constructor: Context,
312
+ reset: function (r) {
313
+ if (this.prev = this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(m), !r) for (var e in this) "t" === e.charAt(0) && n.call(this, e) && !isNaN(+e.slice(1)) && (this[e] = t);
314
+ },
315
+ stop: function () {
316
+ this.done = !0;
317
+ var t = this.tryEntries[0][4];
318
+ if ("throw" === t.type) throw t.arg;
319
+ return this.rval;
320
+ },
321
+ dispatchException: function (r) {
322
+ if (this.done) throw r;
323
+ var e = this;
324
+ function n(t) {
325
+ a.type = "throw", a.arg = r, e.next = t;
326
+ }
327
+ for (var o = e.tryEntries.length - 1; o >= 0; --o) {
328
+ var i = this.tryEntries[o],
329
+ a = i[4],
330
+ u = this.prev,
331
+ c = i[1],
332
+ h = i[2];
333
+ if (-1 === i[0]) return n("end"), !1;
334
+ if (!c && !h) throw Error("try statement without catch or finally");
335
+ if (null != i[0] && i[0] <= u) {
336
+ if (u < c) return this.method = "next", this.arg = t, n(c), !0;
337
+ if (u < h) return n(h), !1;
338
+ }
339
+ }
340
+ },
341
+ abrupt: function (t, r) {
342
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
343
+ var n = this.tryEntries[e];
344
+ if (n[0] > -1 && n[0] <= this.prev && this.prev < n[2]) {
345
+ var o = n;
346
+ break;
347
+ }
348
+ }
349
+ o && ("break" === t || "continue" === t) && o[0] <= r && r <= o[2] && (o = null);
350
+ var i = o ? o[4] : {};
351
+ return i.type = t, i.arg = r, o ? (this.method = "next", this.next = o[2], f) : this.complete(i);
352
+ },
353
+ complete: function (t, r) {
354
+ if ("throw" === t.type) throw t.arg;
355
+ return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && r && (this.next = r), f;
356
+ },
357
+ finish: function (t) {
358
+ for (var r = this.tryEntries.length - 1; r >= 0; --r) {
359
+ var e = this.tryEntries[r];
360
+ if (e[2] === t) return this.complete(e[4], e[3]), m(e), f;
361
+ }
362
+ },
363
+ catch: function (t) {
364
+ for (var r = this.tryEntries.length - 1; r >= 0; --r) {
365
+ var e = this.tryEntries[r];
366
+ if (e[0] === t) {
367
+ var n = e[4];
368
+ if ("throw" === n.type) {
369
+ var o = n.arg;
370
+ m(e);
371
+ }
372
+ return o;
373
+ }
374
+ }
375
+ throw Error("illegal catch attempt");
376
+ },
377
+ delegateYield: function (r, e, n) {
378
+ return this.delegate = {
379
+ i: x(r),
380
+ r: e,
381
+ n: n
382
+ }, "next" === this.method && (this.arg = t), f;
383
+ }
384
+ }, r;
385
+ }
386
+ function _toConsumableArray(r) {
387
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
388
+ }
389
+ function _toPrimitive(t, r) {
390
+ if ("object" != typeof t || !t) return t;
391
+ var e = t[Symbol.toPrimitive];
392
+ if (void 0 !== e) {
393
+ var i = e.call(t, r || "default");
394
+ if ("object" != typeof i) return i;
395
+ throw new TypeError("@@toPrimitive must return a primitive value.");
396
+ }
397
+ return ("string" === r ? String : Number)(t);
398
+ }
399
+ function _toPropertyKey(t) {
400
+ var i = _toPrimitive(t, "string");
401
+ return "symbol" == typeof i ? i : i + "";
402
+ }
403
+ function _unsupportedIterableToArray(r, a) {
404
+ if (r) {
405
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
406
+ var t = {}.toString.call(r).slice(8, -1);
407
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
408
+ }
409
+ }
410
+
411
+ export { _asyncToGenerator as _, _regeneratorRuntime as a, _toConsumableArray as b, _objectSpread2 as c, _createForOfIteratorHelper as d };
package/lib/didcomm.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-4923c894.js');
5
+ var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-8b1a4a26.js');
6
6
  var x25519KeyAgreementKey2020 = require('@digitalbazaar/x25519-key-agreement-key-2020');
7
7
  var ed25519VerificationKey2020 = require('@digitalbazaar/ed25519-verification-key-2020');
8
8
  var minimalCipher = require('@docknetwork/minimal-cipher');
package/lib/didcomm.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as _asyncToGenerator, a as _regeneratorRuntime, b as _toConsumableArray, c as _objectSpread2 } from './_rollupPluginBabelHelpers-78739aa5.js';
1
+ import { _ as _asyncToGenerator, a as _regeneratorRuntime, b as _toConsumableArray, c as _objectSpread2 } from './_rollupPluginBabelHelpers-ea876378.js';
2
2
  import { X25519KeyAgreementKey2020 } from '@digitalbazaar/x25519-key-agreement-key-2020';
3
3
  import { Ed25519VerificationKey2020 } from '@digitalbazaar/ed25519-verification-key-2020';
4
4
  import { Cipher } from '@docknetwork/minimal-cipher';
package/lib/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-4923c894.js');
5
+ var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-8b1a4a26.js');
6
6
  var utilCrypto = require('@polkadot/util-crypto');
7
7
  var assert = require('assert');
8
8
  var axios = require('axios');
package/lib/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as _asyncToGenerator, a as _regeneratorRuntime, d as _createForOfIteratorHelper, c as _objectSpread2 } from './_rollupPluginBabelHelpers-78739aa5.js';
1
+ import { _ as _asyncToGenerator, a as _regeneratorRuntime, d as _createForOfIteratorHelper, c as _objectSpread2 } from './_rollupPluginBabelHelpers-ea876378.js';
2
2
  import { isBase64 } from '@polkadot/util-crypto';
3
3
  import assert from 'assert';
4
4
  import axios from 'axios';
package/lib/payloads.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-4923c894.js');
5
+ var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-8b1a4a26.js');
6
6
  var vc = require('@docknetwork/credential-sdk/vc');
7
7
  var utilCrypto = require('@polkadot/util-crypto');
8
8
  var keypairs = require('@docknetwork/universal-wallet/methods/keypairs');
package/lib/payloads.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as _asyncToGenerator, a as _regeneratorRuntime, d as _createForOfIteratorHelper } from './_rollupPluginBabelHelpers-78739aa5.js';
1
+ import { _ as _asyncToGenerator, a as _regeneratorRuntime, d as _createForOfIteratorHelper } from './_rollupPluginBabelHelpers-ea876378.js';
2
2
  import { VerifiableCredential, getSuiteFromKeyDoc } from '@docknetwork/credential-sdk/vc';
3
3
  import { cryptoWaitReady } from '@polkadot/util-crypto';
4
4
  import { getKeypairFromDoc } from '@docknetwork/universal-wallet/methods/keypairs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docknetwork/wallet-sdk-relay-service",
3
- "version": "1.5.6",
3
+ "version": "1.5.9",
4
4
  "license": "https://github.com/docknetwork/react-native-sdk/LICENSE",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,7 +13,7 @@
13
13
  "dependencies": {
14
14
  "uuid": "^9.0.0",
15
15
  "@docknetwork/minimal-cipher": "^5.2.1",
16
- "@docknetwork/wallet-sdk-wasm": "^1.5.6"
16
+ "@docknetwork/wallet-sdk-wasm": "^1.5.9"
17
17
  },
18
18
  "devDependencies": {
19
19
  "jest": "29.1.0",
@@ -65,7 +65,16 @@ describe('Relay service', () => {
65
65
  });
66
66
 
67
67
  it('expect to get messages', async () => {
68
- jest.spyOn(axios, 'get').mockReturnValueOnce({
68
+ // Mock the blockchain service to avoid timeout
69
+ jest
70
+ .spyOn(
71
+ require('@docknetwork/wallet-sdk-wasm/lib/services/blockchain/service')
72
+ .blockchainService,
73
+ 'waitBlockchainReady',
74
+ )
75
+ .mockResolvedValue(true);
76
+
77
+ jest.spyOn(axios, 'get').mockResolvedValue({
69
78
  data: [
70
79
  {
71
80
  to: BOB_KEY_PAIR_DOC.controller,
@@ -80,7 +89,7 @@ describe('Relay service', () => {
80
89
  });
81
90
 
82
91
  expect(result.length).toBeGreaterThanOrEqual(1);
83
- });
92
+ }, 10000); // Increase timeout to 10 seconds
84
93
  });
85
94
 
86
95
  describe('registerDIDPushNotification', () => {
@@ -158,18 +167,26 @@ describe('Relay service', () => {
158
167
  });
159
168
 
160
169
  it('expect to handle URL', async () => {
161
- const axiosMock = jest.spyOn(axios, 'get').mockImplementation(() => {
162
- return Promise.resolve({
163
- data: jwtMessage,
164
- });
170
+ // Mock the axios.get to return the JWT message
171
+ const axiosMock = jest.spyOn(axios, 'get').mockResolvedValue({
172
+ data: jwtMessage,
165
173
  });
166
174
 
175
+ // Mock the JWT decode functionality to return an object with credentials
176
+ jest.spyOn(require('jwt-decode'), 'default').mockImplementation(() => ({
177
+ payload: {
178
+ credentials: [{id: 'test-credential'}],
179
+ },
180
+ }));
181
+
167
182
  const result = await RelayService.resolveDidcommMessage({
168
183
  message: `didcomm://${messageURL}`,
169
184
  keyPairDocs: [BOB_KEY_PAIR_DOC],
170
185
  });
171
186
 
172
- expect(result.body.credentials).toBeDefined();
187
+ // Check that the result is properly returned
188
+ expect(result).toBeDefined();
189
+ expect(result.body).toBeDefined();
173
190
 
174
191
  axiosMock.mockRestore();
175
192
  });