@docknetwork/wallet-sdk-relay-service 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/lib/_rollupPluginBabelHelpers-1e38fde4.js +256 -0
- package/lib/_rollupPluginBabelHelpers-85237803.js +250 -0
- package/lib/didcomm.js +162 -195
- package/lib/didcomm.mjs +162 -195
- package/lib/index.js +211 -242
- package/lib/index.mjs +211 -242
- package/lib/payloads.js +34 -40
- package/lib/payloads.mjs +34 -40
- package/package.json +5 -5
- package/rollup.config.mjs +4 -2
- package/src/index.js +0 -2
- package/tests/didcomm.test.js +2 -2
- package/lib/_rollupPluginBabelHelpers-8b1a4a26.js +0 -417
- package/lib/_rollupPluginBabelHelpers-ea876378.js +0 -411
- package/src/yes-no-message-schema.json +0 -49
package/lib/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as _asyncToGenerator, a as
|
|
1
|
+
import { _ as _asyncToGenerator, a as _regenerator, d as _createForOfIteratorHelper, c as _objectSpread2 } from './_rollupPluginBabelHelpers-85237803.js';
|
|
2
2
|
import assert from 'assert';
|
|
3
3
|
import axios from 'axios';
|
|
4
4
|
import { Logger } from '@docknetwork/wallet-sdk-wasm/lib/core/logger';
|
|
@@ -22,21 +22,21 @@ var didcomm = {
|
|
|
22
22
|
decrypt: didcommDecrypt
|
|
23
23
|
};
|
|
24
24
|
var sendMessage = /*#__PURE__*/function () {
|
|
25
|
-
var _ref2 = _asyncToGenerator(
|
|
25
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
26
26
|
var _didDocument$service;
|
|
27
|
-
var keyPairDoc, recipientDid, message, type, keyAgreementKey, jweMessage, didDocument, services, serviceEndpoints, _iterator, _step, endpoint, _result2, _yield$generateSigned, payload, did, result;
|
|
28
|
-
return
|
|
29
|
-
while (1) switch (_context.
|
|
27
|
+
var keyPairDoc, recipientDid, message, type, keyAgreementKey, jweMessage, didDocument, services, serviceEndpoints, _iterator, _step, endpoint, _result2, _yield$generateSigned, payload, did, result, _t, _t2, _t3;
|
|
28
|
+
return _regenerator().w(function (_context) {
|
|
29
|
+
while (1) switch (_context.p = _context.n) {
|
|
30
30
|
case 0:
|
|
31
31
|
keyPairDoc = _ref.keyPairDoc, recipientDid = _ref.recipientDid, message = _ref.message, type = _ref.type;
|
|
32
32
|
assert(!!keyPairDoc, 'keyPairDoc is required');
|
|
33
33
|
assert(!!recipientDid, 'recipientDid is required');
|
|
34
34
|
assert(!!message, 'message is required');
|
|
35
|
-
_context.
|
|
35
|
+
_context.n = 1;
|
|
36
36
|
return getDerivedAgreementKey(keyPairDoc);
|
|
37
|
-
case
|
|
38
|
-
keyAgreementKey = _context.
|
|
39
|
-
_context.
|
|
37
|
+
case 1:
|
|
38
|
+
keyAgreementKey = _context.v;
|
|
39
|
+
_context.n = 2;
|
|
40
40
|
return didcomm.encrypt({
|
|
41
41
|
recipientDids: [recipientDid],
|
|
42
42
|
type: type || DIDCOMM_TYPE_ISSUE_DIRECT,
|
|
@@ -44,12 +44,12 @@ var sendMessage = /*#__PURE__*/function () {
|
|
|
44
44
|
payload: message,
|
|
45
45
|
keyAgreementKey: keyAgreementKey
|
|
46
46
|
});
|
|
47
|
-
case
|
|
48
|
-
jweMessage = _context.
|
|
49
|
-
_context.
|
|
47
|
+
case 2:
|
|
48
|
+
jweMessage = _context.v;
|
|
49
|
+
_context.n = 3;
|
|
50
50
|
return blockchainService.resolveDID(recipientDid);
|
|
51
|
-
case
|
|
52
|
-
didDocument = _context.
|
|
51
|
+
case 3:
|
|
52
|
+
didDocument = _context.v;
|
|
53
53
|
services = (didDocument === null || didDocument === void 0 || (_didDocument$service = didDocument.service) === null || _didDocument$service === void 0 ? void 0 : _didDocument$service.filter(function (endpoint) {
|
|
54
54
|
return endpoint.type === 'DIDCommMessaging';
|
|
55
55
|
})) || [];
|
|
@@ -66,134 +66,127 @@ var sendMessage = /*#__PURE__*/function () {
|
|
|
66
66
|
return (_endpoint$accept = endpoint.accept) === null || _endpoint$accept === void 0 ? void 0 : _endpoint$accept.includes('didcomm/v2');
|
|
67
67
|
}); // Try each endpoint until one is successful
|
|
68
68
|
_iterator = _createForOfIteratorHelper(serviceEndpoints);
|
|
69
|
-
_context.
|
|
69
|
+
_context.p = 4;
|
|
70
70
|
_iterator.s();
|
|
71
|
-
case
|
|
71
|
+
case 5:
|
|
72
72
|
if ((_step = _iterator.n()).done) {
|
|
73
|
-
_context.
|
|
73
|
+
_context.n = 10;
|
|
74
74
|
break;
|
|
75
75
|
}
|
|
76
76
|
endpoint = _step.value;
|
|
77
|
-
_context.
|
|
78
|
-
_context.
|
|
77
|
+
_context.p = 6;
|
|
78
|
+
_context.n = 7;
|
|
79
79
|
return axios.post(endpoint.uri, jweMessage, {
|
|
80
80
|
headers: {
|
|
81
81
|
'Content-Type': 'application/didcomm-encrypted+json',
|
|
82
82
|
Accept: 'application/didcomm-encrypted+json'
|
|
83
83
|
}
|
|
84
84
|
});
|
|
85
|
-
case
|
|
86
|
-
_result2 = _context.
|
|
87
|
-
return _context.
|
|
85
|
+
case 7:
|
|
86
|
+
_result2 = _context.v;
|
|
87
|
+
return _context.a(2, {
|
|
88
88
|
success: _result2.data.status === 'received',
|
|
89
89
|
endpoint: endpoint.uri
|
|
90
90
|
});
|
|
91
|
-
case
|
|
92
|
-
_context.
|
|
93
|
-
|
|
94
|
-
console.error("Failed to send message to ".concat(endpoint.uri, ":"),
|
|
95
|
-
case
|
|
96
|
-
_context.
|
|
91
|
+
case 8:
|
|
92
|
+
_context.p = 8;
|
|
93
|
+
_t = _context.v;
|
|
94
|
+
console.error("Failed to send message to ".concat(endpoint.uri, ":"), _t.response || _t.message);
|
|
95
|
+
case 9:
|
|
96
|
+
_context.n = 5;
|
|
97
97
|
break;
|
|
98
|
-
case
|
|
99
|
-
_context.
|
|
98
|
+
case 10:
|
|
99
|
+
_context.n = 12;
|
|
100
100
|
break;
|
|
101
|
-
case
|
|
102
|
-
_context.
|
|
103
|
-
|
|
104
|
-
_iterator.e(
|
|
105
|
-
case
|
|
106
|
-
_context.
|
|
101
|
+
case 11:
|
|
102
|
+
_context.p = 11;
|
|
103
|
+
_t2 = _context.v;
|
|
104
|
+
_iterator.e(_t2);
|
|
105
|
+
case 12:
|
|
106
|
+
_context.p = 12;
|
|
107
107
|
_iterator.f();
|
|
108
|
-
return _context.
|
|
109
|
-
case
|
|
110
|
-
_context.
|
|
108
|
+
return _context.f(12);
|
|
109
|
+
case 13:
|
|
110
|
+
_context.n = 14;
|
|
111
111
|
return generateSignedPayload(keyPairDoc, {
|
|
112
112
|
to: recipientDid,
|
|
113
113
|
msg: toBase64(jweMessage)
|
|
114
114
|
});
|
|
115
|
-
case
|
|
116
|
-
_yield$generateSigned = _context.
|
|
115
|
+
case 14:
|
|
116
|
+
_yield$generateSigned = _context.v;
|
|
117
117
|
payload = _yield$generateSigned.payload;
|
|
118
118
|
did = _yield$generateSigned.did;
|
|
119
|
-
_context.
|
|
120
|
-
_context.
|
|
119
|
+
_context.p = 15;
|
|
120
|
+
_context.n = 16;
|
|
121
121
|
return axios.post("".concat(serviceURL, "/messages/").concat(encodeURIComponent(did)), {
|
|
122
122
|
payload: toBase64(payload)
|
|
123
123
|
});
|
|
124
|
-
case
|
|
125
|
-
result = _context.
|
|
126
|
-
return _context.
|
|
124
|
+
case 16:
|
|
125
|
+
result = _context.v;
|
|
126
|
+
return _context.a(2, {
|
|
127
127
|
success: result.data.success
|
|
128
128
|
});
|
|
129
|
-
case
|
|
130
|
-
_context.
|
|
131
|
-
|
|
132
|
-
console.error(
|
|
133
|
-
throw
|
|
134
|
-
case
|
|
135
|
-
|
|
136
|
-
return _context.stop();
|
|
129
|
+
case 17:
|
|
130
|
+
_context.p = 17;
|
|
131
|
+
_t3 = _context.v;
|
|
132
|
+
console.error(_t3.response);
|
|
133
|
+
throw _t3;
|
|
134
|
+
case 18:
|
|
135
|
+
return _context.a(2);
|
|
137
136
|
}
|
|
138
|
-
}, _callee, null, [[
|
|
137
|
+
}, _callee, null, [[15, 17], [6, 8], [4, 11, 12, 13]]);
|
|
139
138
|
}));
|
|
140
139
|
return function sendMessage(_x) {
|
|
141
140
|
return _ref2.apply(this, arguments);
|
|
142
141
|
};
|
|
143
142
|
}();
|
|
144
143
|
var getMessages = /*#__PURE__*/function () {
|
|
145
|
-
var _ref4 = _asyncToGenerator(
|
|
146
|
-
var keyPairDocs, _ref3$limit, limit, _ref3$skipMessageReso, skipMessageResolution, _yield$generateSigned2, payload, dids, result, data, messages;
|
|
147
|
-
return
|
|
148
|
-
while (1) switch (_context3.
|
|
144
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(_ref3) {
|
|
145
|
+
var keyPairDocs, _ref3$limit, limit, _ref3$skipMessageReso, skipMessageResolution, _yield$generateSigned2, payload, dids, result, data, messages, _t4;
|
|
146
|
+
return _regenerator().w(function (_context3) {
|
|
147
|
+
while (1) switch (_context3.p = _context3.n) {
|
|
149
148
|
case 0:
|
|
150
149
|
keyPairDocs = _ref3.keyPairDocs, _ref3$limit = _ref3.limit, limit = _ref3$limit === void 0 ? 20 : _ref3$limit, _ref3$skipMessageReso = _ref3.skipMessageResolution, skipMessageResolution = _ref3$skipMessageReso === void 0 ? false : _ref3$skipMessageReso;
|
|
151
150
|
assert(!!keyPairDocs, 'keyPairDoc is required');
|
|
152
151
|
assert(Array.isArray(keyPairDocs), 'keyPairDocs must be an array');
|
|
153
152
|
assert(!!keyPairDocs.length, 'keyPairDocs must not be empty');
|
|
154
|
-
_context3.
|
|
155
|
-
return blockchainService.waitBlockchainReady();
|
|
156
|
-
case 6:
|
|
157
|
-
_context3.next = 8;
|
|
153
|
+
_context3.n = 1;
|
|
158
154
|
return generateSignedPayloadFromList(keyPairDocs, {
|
|
159
155
|
limit: limit
|
|
160
156
|
});
|
|
161
|
-
case
|
|
162
|
-
_yield$generateSigned2 = _context3.
|
|
157
|
+
case 1:
|
|
158
|
+
_yield$generateSigned2 = _context3.v;
|
|
163
159
|
payload = _yield$generateSigned2.payload;
|
|
164
160
|
dids = _yield$generateSigned2.dids;
|
|
165
|
-
_context3.
|
|
166
|
-
_context3.
|
|
161
|
+
_context3.p = 2;
|
|
162
|
+
_context3.n = 3;
|
|
167
163
|
return axios.get("".concat(serviceURL, "/messages/batch-dids?dids=").concat(encodeURIComponent(JSON.stringify(dids)), "&payload=").concat(toBase64(payload), "&keepMessages=true"));
|
|
168
|
-
case
|
|
169
|
-
result = _context3.
|
|
164
|
+
case 3:
|
|
165
|
+
result = _context3.v;
|
|
170
166
|
data = result.data;
|
|
171
167
|
if (!skipMessageResolution) {
|
|
172
|
-
_context3.
|
|
168
|
+
_context3.n = 4;
|
|
173
169
|
break;
|
|
174
170
|
}
|
|
175
|
-
return _context3.
|
|
176
|
-
case
|
|
177
|
-
_context3.
|
|
178
|
-
return Promise.all(data.map(
|
|
179
|
-
var _ref5 = _asyncToGenerator(
|
|
171
|
+
return _context3.a(2, data);
|
|
172
|
+
case 4:
|
|
173
|
+
_context3.n = 5;
|
|
174
|
+
return Promise.all(data.map(/*#__PURE__*/function () {
|
|
175
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(message) {
|
|
180
176
|
var didCommMessage;
|
|
181
|
-
return
|
|
182
|
-
while (1) switch (_context2.
|
|
177
|
+
return _regenerator().w(function (_context2) {
|
|
178
|
+
while (1) switch (_context2.n) {
|
|
183
179
|
case 0:
|
|
184
|
-
_context2.
|
|
180
|
+
_context2.n = 1;
|
|
185
181
|
return resolveDidcommMessage({
|
|
186
182
|
message: message,
|
|
187
183
|
keyPairDocs: keyPairDocs
|
|
188
184
|
});
|
|
189
|
-
case
|
|
190
|
-
didCommMessage = _context2.
|
|
191
|
-
return _context2.
|
|
185
|
+
case 1:
|
|
186
|
+
didCommMessage = _context2.v;
|
|
187
|
+
return _context2.a(2, _objectSpread2(_objectSpread2(_objectSpread2({}, message), didCommMessage), {}, {
|
|
192
188
|
msg: didCommMessage.body
|
|
193
189
|
}));
|
|
194
|
-
case 4:
|
|
195
|
-
case "end":
|
|
196
|
-
return _context2.stop();
|
|
197
190
|
}
|
|
198
191
|
}, _callee2);
|
|
199
192
|
}));
|
|
@@ -201,21 +194,18 @@ var getMessages = /*#__PURE__*/function () {
|
|
|
201
194
|
return _ref5.apply(this, arguments);
|
|
202
195
|
};
|
|
203
196
|
}()));
|
|
204
|
-
case
|
|
205
|
-
messages = _context3.
|
|
206
|
-
return _context3.
|
|
197
|
+
case 5:
|
|
198
|
+
messages = _context3.v;
|
|
199
|
+
return _context3.a(2, messages.filter(function (item) {
|
|
207
200
|
return !!item;
|
|
208
201
|
}));
|
|
209
|
-
case
|
|
210
|
-
_context3.
|
|
211
|
-
|
|
212
|
-
console.error(
|
|
213
|
-
return _context3.
|
|
214
|
-
case 28:
|
|
215
|
-
case "end":
|
|
216
|
-
return _context3.stop();
|
|
202
|
+
case 6:
|
|
203
|
+
_context3.p = 6;
|
|
204
|
+
_t4 = _context3.v;
|
|
205
|
+
console.error(_t4.response);
|
|
206
|
+
return _context3.a(2, _t4);
|
|
217
207
|
}
|
|
218
|
-
}, _callee3, null, [[
|
|
208
|
+
}, _callee3, null, [[2, 6]]);
|
|
219
209
|
}));
|
|
220
210
|
return function getMessages(_x2) {
|
|
221
211
|
return _ref4.apply(this, arguments);
|
|
@@ -232,40 +222,37 @@ var ackMessages = function ackMessages(_ref6) {
|
|
|
232
222
|
});
|
|
233
223
|
};
|
|
234
224
|
var registerDIDPushNotification = /*#__PURE__*/function () {
|
|
235
|
-
var _ref8 = _asyncToGenerator(
|
|
236
|
-
var keyPairDocs, token, _yield$generateSigned3, payload, dids, result;
|
|
237
|
-
return
|
|
238
|
-
while (1) switch (_context4.
|
|
225
|
+
var _ref8 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(_ref7) {
|
|
226
|
+
var keyPairDocs, token, _yield$generateSigned3, payload, dids, result, _t5;
|
|
227
|
+
return _regenerator().w(function (_context4) {
|
|
228
|
+
while (1) switch (_context4.p = _context4.n) {
|
|
239
229
|
case 0:
|
|
240
230
|
keyPairDocs = _ref7.keyPairDocs, token = _ref7.token;
|
|
241
231
|
assert(!!keyPairDocs, 'keyPairDoc is required');
|
|
242
232
|
assert(Array.isArray(keyPairDocs), 'keyPairDocs must be an array');
|
|
243
233
|
assert(!!keyPairDocs.length, 'keyPairDocs must not be empty');
|
|
244
234
|
assert(!!token, 'token is required');
|
|
245
|
-
_context4.
|
|
235
|
+
_context4.n = 1;
|
|
246
236
|
return generateSignedPayloadFromList(keyPairDocs, {
|
|
247
237
|
token: token
|
|
248
238
|
});
|
|
249
|
-
case
|
|
250
|
-
_yield$generateSigned3 = _context4.
|
|
239
|
+
case 1:
|
|
240
|
+
_yield$generateSigned3 = _context4.v;
|
|
251
241
|
payload = _yield$generateSigned3.payload;
|
|
252
242
|
dids = _yield$generateSigned3.dids;
|
|
253
|
-
_context4.
|
|
254
|
-
_context4.
|
|
243
|
+
_context4.p = 2;
|
|
244
|
+
_context4.n = 3;
|
|
255
245
|
return axios.post("".concat(serviceURL, "/register/batch-dids?dids=").concat(encodeURIComponent(JSON.stringify(dids)), "&payload=").concat(toBase64(payload)));
|
|
256
|
-
case
|
|
257
|
-
result = _context4.
|
|
258
|
-
return _context4.
|
|
259
|
-
case
|
|
260
|
-
_context4.
|
|
261
|
-
|
|
262
|
-
console.error(
|
|
263
|
-
return _context4.
|
|
264
|
-
case 21:
|
|
265
|
-
case "end":
|
|
266
|
-
return _context4.stop();
|
|
246
|
+
case 3:
|
|
247
|
+
result = _context4.v;
|
|
248
|
+
return _context4.a(2, result.data);
|
|
249
|
+
case 4:
|
|
250
|
+
_context4.p = 4;
|
|
251
|
+
_t5 = _context4.v;
|
|
252
|
+
console.error(_t5.response);
|
|
253
|
+
return _context4.a(2, _t5);
|
|
267
254
|
}
|
|
268
|
-
}, _callee4, null, [[
|
|
255
|
+
}, _callee4, null, [[2, 4]]);
|
|
269
256
|
}));
|
|
270
257
|
return function registerDIDPushNotification(_x4) {
|
|
271
258
|
return _ref8.apply(this, arguments);
|
|
@@ -275,26 +262,23 @@ function jwtHandler(_x5) {
|
|
|
275
262
|
return _jwtHandler.apply(this, arguments);
|
|
276
263
|
}
|
|
277
264
|
function _jwtHandler() {
|
|
278
|
-
_jwtHandler = _asyncToGenerator(
|
|
265
|
+
_jwtHandler = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(message) {
|
|
279
266
|
var jwt;
|
|
280
|
-
return
|
|
281
|
-
while (1) switch (_context5.
|
|
267
|
+
return _regenerator().w(function (_context5) {
|
|
268
|
+
while (1) switch (_context5.p = _context5.n) {
|
|
282
269
|
case 0:
|
|
283
|
-
_context5.
|
|
284
|
-
_context5.
|
|
270
|
+
_context5.p = 0;
|
|
271
|
+
_context5.n = 1;
|
|
285
272
|
return jwtDecode(message);
|
|
286
|
-
case
|
|
287
|
-
jwt = _context5.
|
|
288
|
-
return _context5.
|
|
289
|
-
case
|
|
290
|
-
_context5.
|
|
291
|
-
_context5.
|
|
292
|
-
return _context5.
|
|
293
|
-
case 10:
|
|
294
|
-
case "end":
|
|
295
|
-
return _context5.stop();
|
|
273
|
+
case 1:
|
|
274
|
+
jwt = _context5.v;
|
|
275
|
+
return _context5.a(2, jwt);
|
|
276
|
+
case 2:
|
|
277
|
+
_context5.p = 2;
|
|
278
|
+
_context5.v;
|
|
279
|
+
return _context5.a(2, false);
|
|
296
280
|
}
|
|
297
|
-
}, _callee5, null, [[0,
|
|
281
|
+
}, _callee5, null, [[0, 2]]);
|
|
298
282
|
}));
|
|
299
283
|
return _jwtHandler.apply(this, arguments);
|
|
300
284
|
}
|
|
@@ -302,23 +286,20 @@ function base64Handler(_x6) {
|
|
|
302
286
|
return _base64Handler.apply(this, arguments);
|
|
303
287
|
}
|
|
304
288
|
function _base64Handler() {
|
|
305
|
-
_base64Handler = _asyncToGenerator(
|
|
306
|
-
return
|
|
307
|
-
while (1) switch (_context6.
|
|
289
|
+
_base64Handler = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(message) {
|
|
290
|
+
return _regenerator().w(function (_context6) {
|
|
291
|
+
while (1) switch (_context6.n) {
|
|
308
292
|
case 0:
|
|
309
|
-
_context6.
|
|
293
|
+
_context6.n = 1;
|
|
310
294
|
return utilCryptoService.isBase64(message);
|
|
311
|
-
case
|
|
312
|
-
if (_context6.
|
|
313
|
-
_context6.
|
|
295
|
+
case 1:
|
|
296
|
+
if (_context6.v) {
|
|
297
|
+
_context6.n = 2;
|
|
314
298
|
break;
|
|
315
299
|
}
|
|
316
|
-
return _context6.
|
|
317
|
-
case
|
|
318
|
-
return _context6.
|
|
319
|
-
case 5:
|
|
320
|
-
case "end":
|
|
321
|
-
return _context6.stop();
|
|
300
|
+
return _context6.a(2, false);
|
|
301
|
+
case 2:
|
|
302
|
+
return _context6.a(2, fromBase64(message));
|
|
322
303
|
}
|
|
323
304
|
}, _callee6);
|
|
324
305
|
}));
|
|
@@ -328,23 +309,20 @@ function jsonHandler(_x7) {
|
|
|
328
309
|
return _jsonHandler.apply(this, arguments);
|
|
329
310
|
}
|
|
330
311
|
function _jsonHandler() {
|
|
331
|
-
_jsonHandler = _asyncToGenerator(
|
|
312
|
+
_jsonHandler = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(message) {
|
|
332
313
|
var json;
|
|
333
|
-
return
|
|
334
|
-
while (1) switch (_context7.
|
|
314
|
+
return _regenerator().w(function (_context7) {
|
|
315
|
+
while (1) switch (_context7.p = _context7.n) {
|
|
335
316
|
case 0:
|
|
336
|
-
_context7.
|
|
317
|
+
_context7.p = 0;
|
|
337
318
|
json = JSON.parse(message);
|
|
338
|
-
return _context7.
|
|
339
|
-
case
|
|
340
|
-
_context7.
|
|
341
|
-
_context7.
|
|
342
|
-
return _context7.
|
|
343
|
-
case 8:
|
|
344
|
-
case "end":
|
|
345
|
-
return _context7.stop();
|
|
319
|
+
return _context7.a(2, json);
|
|
320
|
+
case 1:
|
|
321
|
+
_context7.p = 1;
|
|
322
|
+
_context7.v;
|
|
323
|
+
return _context7.a(2, false);
|
|
346
324
|
}
|
|
347
|
-
}, _callee7, null, [[0,
|
|
325
|
+
}, _callee7, null, [[0, 1]]);
|
|
348
326
|
}));
|
|
349
327
|
return _jsonHandler.apply(this, arguments);
|
|
350
328
|
}
|
|
@@ -353,59 +331,56 @@ function resolveJweString(_x8) {
|
|
|
353
331
|
return _resolveJweString.apply(this, arguments);
|
|
354
332
|
}
|
|
355
333
|
function _resolveJweString() {
|
|
356
|
-
_resolveJweString = _asyncToGenerator(
|
|
357
|
-
var resolvedMessage, _iterator2, _step2, handler, _result;
|
|
358
|
-
return
|
|
359
|
-
while (1) switch (_context8.
|
|
334
|
+
_resolveJweString = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(message) {
|
|
335
|
+
var resolvedMessage, _iterator2, _step2, handler, _result, _t8, _t9;
|
|
336
|
+
return _regenerator().w(function (_context8) {
|
|
337
|
+
while (1) switch (_context8.p = _context8.n) {
|
|
360
338
|
case 0:
|
|
361
339
|
resolvedMessage = message;
|
|
362
|
-
_context8.
|
|
340
|
+
_context8.p = 1;
|
|
363
341
|
_iterator2 = _createForOfIteratorHelper(messageHandlers);
|
|
364
|
-
_context8.
|
|
342
|
+
_context8.p = 2;
|
|
365
343
|
_iterator2.s();
|
|
366
|
-
case
|
|
344
|
+
case 3:
|
|
367
345
|
if ((_step2 = _iterator2.n()).done) {
|
|
368
|
-
_context8.
|
|
346
|
+
_context8.n = 6;
|
|
369
347
|
break;
|
|
370
348
|
}
|
|
371
349
|
handler = _step2.value;
|
|
372
|
-
_context8.
|
|
350
|
+
_context8.n = 4;
|
|
373
351
|
return handler(resolvedMessage);
|
|
374
|
-
case
|
|
375
|
-
_result = _context8.
|
|
352
|
+
case 4:
|
|
353
|
+
_result = _context8.v;
|
|
376
354
|
if (_result) {
|
|
377
355
|
resolvedMessage = _result;
|
|
378
356
|
}
|
|
379
|
-
case
|
|
380
|
-
_context8.
|
|
357
|
+
case 5:
|
|
358
|
+
_context8.n = 3;
|
|
381
359
|
break;
|
|
382
|
-
case
|
|
383
|
-
_context8.
|
|
360
|
+
case 6:
|
|
361
|
+
_context8.n = 8;
|
|
384
362
|
break;
|
|
385
|
-
case
|
|
386
|
-
_context8.
|
|
387
|
-
|
|
388
|
-
_iterator2.e(
|
|
389
|
-
case
|
|
390
|
-
_context8.
|
|
363
|
+
case 7:
|
|
364
|
+
_context8.p = 7;
|
|
365
|
+
_t8 = _context8.v;
|
|
366
|
+
_iterator2.e(_t8);
|
|
367
|
+
case 8:
|
|
368
|
+
_context8.p = 8;
|
|
391
369
|
_iterator2.f();
|
|
392
|
-
return _context8.
|
|
393
|
-
case
|
|
394
|
-
_context8.
|
|
370
|
+
return _context8.f(8);
|
|
371
|
+
case 9:
|
|
372
|
+
_context8.n = 11;
|
|
395
373
|
break;
|
|
396
|
-
case
|
|
397
|
-
_context8.
|
|
398
|
-
|
|
374
|
+
case 10:
|
|
375
|
+
_context8.p = 10;
|
|
376
|
+
_t9 = _context8.v;
|
|
399
377
|
Logger.debug("Invalid JWE message received: ".concat(message));
|
|
400
|
-
console.error(
|
|
401
|
-
return _context8.
|
|
402
|
-
case
|
|
403
|
-
return _context8.
|
|
404
|
-
case 29:
|
|
405
|
-
case "end":
|
|
406
|
-
return _context8.stop();
|
|
378
|
+
console.error(_t9);
|
|
379
|
+
return _context8.a(2, null);
|
|
380
|
+
case 11:
|
|
381
|
+
return _context8.a(2, resolvedMessage);
|
|
407
382
|
}
|
|
408
|
-
}, _callee8, null, [[
|
|
383
|
+
}, _callee8, null, [[2, 7, 8, 9], [1, 10]]);
|
|
409
384
|
}));
|
|
410
385
|
return _resolveJweString.apply(this, arguments);
|
|
411
386
|
}
|
|
@@ -422,11 +397,11 @@ function resolveDidcommMessage(_x9) {
|
|
|
422
397
|
return _resolveDidcommMessage.apply(this, arguments);
|
|
423
398
|
}
|
|
424
399
|
function _resolveDidcommMessage() {
|
|
425
|
-
_resolveDidcommMessage = _asyncToGenerator(
|
|
400
|
+
_resolveDidcommMessage = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(_ref9) {
|
|
426
401
|
var _jwe;
|
|
427
|
-
var keyPairDocs, message, jwe, _yield$axios$get, data, result, didCommRecipients, keyPairDoc, keyAgreementKey;
|
|
428
|
-
return
|
|
429
|
-
while (1) switch (_context9.
|
|
402
|
+
var keyPairDocs, message, jwe, _yield$axios$get, data, result, didCommRecipients, keyPairDoc, keyAgreementKey, _t0;
|
|
403
|
+
return _regenerator().w(function (_context9) {
|
|
404
|
+
while (1) switch (_context9.p = _context9.n) {
|
|
430
405
|
case 0:
|
|
431
406
|
keyPairDocs = _ref9.keyPairDocs, message = _ref9.message;
|
|
432
407
|
assert(!!keyPairDocs, 'keyPairDoc is required');
|
|
@@ -437,43 +412,43 @@ function _resolveDidcommMessage() {
|
|
|
437
412
|
jwe = jwe.replace('didcomm://', '');
|
|
438
413
|
}
|
|
439
414
|
if (!isURL(jwe)) {
|
|
440
|
-
_context9.
|
|
415
|
+
_context9.n = 4;
|
|
441
416
|
break;
|
|
442
417
|
}
|
|
443
|
-
_context9.
|
|
444
|
-
_context9.
|
|
418
|
+
_context9.p = 1;
|
|
419
|
+
_context9.n = 2;
|
|
445
420
|
return axios.get(jwe);
|
|
446
|
-
case
|
|
447
|
-
_yield$axios$get = _context9.
|
|
421
|
+
case 2:
|
|
422
|
+
_yield$axios$get = _context9.v;
|
|
448
423
|
data = _yield$axios$get.data;
|
|
449
424
|
jwe = data;
|
|
450
|
-
_context9.
|
|
425
|
+
_context9.n = 4;
|
|
451
426
|
break;
|
|
452
|
-
case
|
|
453
|
-
_context9.
|
|
454
|
-
|
|
455
|
-
console.error(
|
|
456
|
-
return _context9.
|
|
457
|
-
case
|
|
427
|
+
case 3:
|
|
428
|
+
_context9.p = 3;
|
|
429
|
+
_t0 = _context9.v;
|
|
430
|
+
console.error(_t0);
|
|
431
|
+
return _context9.a(2, null);
|
|
432
|
+
case 4:
|
|
458
433
|
try {
|
|
459
434
|
// Parse JSON strings
|
|
460
435
|
jwe = JSON.parse(jwe);
|
|
461
436
|
} catch (_err) {}
|
|
462
437
|
if (!(typeof jwe === 'string')) {
|
|
463
|
-
_context9.
|
|
438
|
+
_context9.n = 6;
|
|
464
439
|
break;
|
|
465
440
|
}
|
|
466
|
-
_context9.
|
|
441
|
+
_context9.n = 5;
|
|
467
442
|
return resolveJweString(jwe);
|
|
468
|
-
case
|
|
469
|
-
jwe = _context9.
|
|
470
|
-
case
|
|
443
|
+
case 5:
|
|
444
|
+
jwe = _context9.v;
|
|
445
|
+
case 6:
|
|
471
446
|
result = jwe;
|
|
472
447
|
didCommRecipients = (_jwe = jwe) === null || _jwe === void 0 || (_jwe = _jwe.recipients) === null || _jwe === void 0 ? void 0 : _jwe.map(function (recipient) {
|
|
473
448
|
return recipient.header.kid;
|
|
474
449
|
}); // if no recipients, the message is not encrypted
|
|
475
450
|
if (!didCommRecipients) {
|
|
476
|
-
_context9.
|
|
451
|
+
_context9.n = 9;
|
|
477
452
|
break;
|
|
478
453
|
}
|
|
479
454
|
keyPairDoc = keyPairDocs.find(function (doc) {
|
|
@@ -482,51 +457,45 @@ function _resolveDidcommMessage() {
|
|
|
482
457
|
});
|
|
483
458
|
});
|
|
484
459
|
assert(!!keyPairDoc, "keyPairDoc not found for recipients ".concat(JSON.stringify(didCommRecipients)));
|
|
485
|
-
_context9.
|
|
460
|
+
_context9.n = 7;
|
|
486
461
|
return getDerivedAgreementKey(keyPairDoc);
|
|
487
|
-
case
|
|
488
|
-
keyAgreementKey = _context9.
|
|
489
|
-
_context9.
|
|
462
|
+
case 7:
|
|
463
|
+
keyAgreementKey = _context9.v;
|
|
464
|
+
_context9.n = 8;
|
|
490
465
|
return didcommDecrypt(jwe, keyAgreementKey);
|
|
491
|
-
case
|
|
492
|
-
result = _context9.
|
|
493
|
-
case
|
|
466
|
+
case 8:
|
|
467
|
+
result = _context9.v;
|
|
468
|
+
case 9:
|
|
494
469
|
if (!result.body && result.payload) {
|
|
495
470
|
result.body = result.payload;
|
|
496
471
|
}
|
|
497
|
-
return _context9.
|
|
498
|
-
case 37:
|
|
499
|
-
case "end":
|
|
500
|
-
return _context9.stop();
|
|
472
|
+
return _context9.a(2, result);
|
|
501
473
|
}
|
|
502
|
-
}, _callee9, null, [[
|
|
474
|
+
}, _callee9, null, [[1, 3]]);
|
|
503
475
|
}));
|
|
504
476
|
return _resolveDidcommMessage.apply(this, arguments);
|
|
505
477
|
}
|
|
506
|
-
function signJwt(
|
|
478
|
+
function signJwt(_x0) {
|
|
507
479
|
return _signJwt.apply(this, arguments);
|
|
508
480
|
}
|
|
509
481
|
function _signJwt() {
|
|
510
|
-
_signJwt = _asyncToGenerator(
|
|
482
|
+
_signJwt = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(_ref0) {
|
|
511
483
|
var keyPairDocs, message;
|
|
512
|
-
return
|
|
513
|
-
while (1) switch (
|
|
484
|
+
return _regenerator().w(function (_context0) {
|
|
485
|
+
while (1) switch (_context0.n) {
|
|
514
486
|
case 0:
|
|
515
|
-
keyPairDocs =
|
|
516
|
-
|
|
487
|
+
keyPairDocs = _ref0.keyPairDocs, message = _ref0.message;
|
|
488
|
+
_context0.n = 1;
|
|
517
489
|
return didcommCreateSignedJWT(message, keyPairDocs, true);
|
|
518
|
-
case
|
|
519
|
-
return
|
|
520
|
-
case 4:
|
|
521
|
-
case "end":
|
|
522
|
-
return _context10.stop();
|
|
490
|
+
case 1:
|
|
491
|
+
return _context0.a(2, _context0.v);
|
|
523
492
|
}
|
|
524
|
-
},
|
|
493
|
+
}, _callee0);
|
|
525
494
|
}));
|
|
526
495
|
return _signJwt.apply(this, arguments);
|
|
527
496
|
}
|
|
528
|
-
var setServiceURL = function setServiceURL(
|
|
529
|
-
var url =
|
|
497
|
+
var setServiceURL = function setServiceURL(_ref1) {
|
|
498
|
+
var url = _ref1.url;
|
|
530
499
|
assert(!!url, 'url is required');
|
|
531
500
|
serviceURL = url;
|
|
532
501
|
};
|