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