@credo-ts/askar 0.4.1-alpha.157
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/LICENSE +202 -0
- package/README.md +31 -0
- package/build/AskarModule.d.ts +9 -0
- package/build/AskarModule.js +58 -0
- package/build/AskarModule.js.map +1 -0
- package/build/AskarModuleConfig.d.ts +68 -0
- package/build/AskarModuleConfig.js +33 -0
- package/build/AskarModuleConfig.js.map +1 -0
- package/build/index.d.ts +4 -0
- package/build/index.js +16 -0
- package/build/index.js.map +1 -0
- package/build/storage/AskarStorageService.d.ts +17 -0
- package/build/storage/AskarStorageService.js +139 -0
- package/build/storage/AskarStorageService.js.map +1 -0
- package/build/storage/index.d.ts +1 -0
- package/build/storage/index.js +18 -0
- package/build/storage/index.js.map +1 -0
- package/build/storage/utils.d.ts +15 -0
- package/build/storage/utils.js +110 -0
- package/build/storage/utils.js.map +1 -0
- package/build/utils/askarError.d.ts +14 -0
- package/build/utils/askarError.js +20 -0
- package/build/utils/askarError.js.map +1 -0
- package/build/utils/askarKeyTypes.d.ts +7 -0
- package/build/utils/askarKeyTypes.js +45 -0
- package/build/utils/askarKeyTypes.js.map +1 -0
- package/build/utils/askarWalletConfig.d.ts +14 -0
- package/build/utils/askarWalletConfig.js +75 -0
- package/build/utils/askarWalletConfig.js.map +1 -0
- package/build/utils/assertAskarWallet.d.ts +3 -0
- package/build/utils/assertAskarWallet.js +15 -0
- package/build/utils/assertAskarWallet.js.map +1 -0
- package/build/utils/index.d.ts +3 -0
- package/build/utils/index.js +20 -0
- package/build/utils/index.js.map +1 -0
- package/build/wallet/AskarBaseWallet.d.ts +89 -0
- package/build/wallet/AskarBaseWallet.js +385 -0
- package/build/wallet/AskarBaseWallet.js.map +1 -0
- package/build/wallet/AskarProfileWallet.d.ts +24 -0
- package/build/wallet/AskarProfileWallet.js +150 -0
- package/build/wallet/AskarProfileWallet.js.map +1 -0
- package/build/wallet/AskarWallet.d.ts +58 -0
- package/build/wallet/AskarWallet.js +342 -0
- package/build/wallet/AskarWallet.js.map +1 -0
- package/build/wallet/AskarWalletStorageConfig.d.ts +31 -0
- package/build/wallet/AskarWalletStorageConfig.js +12 -0
- package/build/wallet/AskarWalletStorageConfig.js.map +1 -0
- package/build/wallet/JweEnvelope.d.ts +32 -0
- package/build/wallet/JweEnvelope.js +55 -0
- package/build/wallet/JweEnvelope.js.map +1 -0
- package/build/wallet/didcommV1.d.ts +8 -0
- package/build/wallet/didcommV1.js +156 -0
- package/build/wallet/didcommV1.js.map +1 -0
- package/build/wallet/index.d.ts +3 -0
- package/build/wallet/index.js +23 -0
- package/build/wallet/index.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.AskarWallet = void 0;
|
|
16
|
+
const core_1 = require("@credo-ts/core");
|
|
17
|
+
const aries_askar_shared_1 = require("@hyperledger/aries-askar-shared");
|
|
18
|
+
const tsyringe_1 = require("tsyringe");
|
|
19
|
+
const utils_1 = require("../utils");
|
|
20
|
+
const AskarBaseWallet_1 = require("./AskarBaseWallet");
|
|
21
|
+
const AskarWalletStorageConfig_1 = require("./AskarWalletStorageConfig");
|
|
22
|
+
/**
|
|
23
|
+
* @todo: rename after 0.5.0, as we now have multiple types of AskarWallet
|
|
24
|
+
*/
|
|
25
|
+
let AskarWallet = class AskarWallet extends AskarBaseWallet_1.AskarBaseWallet {
|
|
26
|
+
constructor(logger, fileSystem, signingKeyProviderRegistry) {
|
|
27
|
+
super(logger, signingKeyProviderRegistry);
|
|
28
|
+
this.fileSystem = fileSystem;
|
|
29
|
+
}
|
|
30
|
+
get isProvisioned() {
|
|
31
|
+
return this.walletConfig !== undefined;
|
|
32
|
+
}
|
|
33
|
+
get isInitialized() {
|
|
34
|
+
return this._store !== undefined;
|
|
35
|
+
}
|
|
36
|
+
get store() {
|
|
37
|
+
if (!this._store) {
|
|
38
|
+
throw new core_1.CredoError('Wallet has not been initialized yet. Make sure to await agent.initialize() before using the agent.');
|
|
39
|
+
}
|
|
40
|
+
return this._store;
|
|
41
|
+
}
|
|
42
|
+
get profile() {
|
|
43
|
+
if (!this.walletConfig) {
|
|
44
|
+
throw new core_1.WalletError('No profile configured.');
|
|
45
|
+
}
|
|
46
|
+
return this.walletConfig.id;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Dispose method is called when an agent context is disposed.
|
|
50
|
+
*/
|
|
51
|
+
async dispose() {
|
|
52
|
+
if (this.isInitialized) {
|
|
53
|
+
await this.close();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* @throws {WalletDuplicateError} if the wallet already exists
|
|
58
|
+
* @throws {WalletError} if another error occurs
|
|
59
|
+
*/
|
|
60
|
+
async create(walletConfig) {
|
|
61
|
+
await this.createAndOpen(walletConfig);
|
|
62
|
+
await this.close();
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* @throws {WalletDuplicateError} if the wallet already exists
|
|
66
|
+
* @throws {WalletError} if another error occurs
|
|
67
|
+
*/
|
|
68
|
+
async createAndOpen(walletConfig) {
|
|
69
|
+
this.logger.debug(`Creating wallet '${walletConfig.id}`);
|
|
70
|
+
const askarWalletConfig = await this.getAskarWalletConfig(walletConfig);
|
|
71
|
+
// Check if database exists
|
|
72
|
+
const { path: filePath } = (0, utils_1.uriFromWalletConfig)(walletConfig, this.fileSystem.dataPath);
|
|
73
|
+
if (filePath && (await this.fileSystem.exists(filePath))) {
|
|
74
|
+
throw new core_1.WalletDuplicateError(`Wallet '${walletConfig.id}' already exists.`, {
|
|
75
|
+
walletType: 'AskarWallet',
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
// Make sure path exists before creating the wallet
|
|
80
|
+
if (filePath) {
|
|
81
|
+
await this.fileSystem.createDirectory(filePath);
|
|
82
|
+
}
|
|
83
|
+
this._store = await aries_askar_shared_1.Store.provision({
|
|
84
|
+
recreate: false,
|
|
85
|
+
uri: askarWalletConfig.uri,
|
|
86
|
+
profile: askarWalletConfig.profile,
|
|
87
|
+
keyMethod: askarWalletConfig.keyMethod,
|
|
88
|
+
passKey: askarWalletConfig.passKey,
|
|
89
|
+
});
|
|
90
|
+
// TODO: Should we do something to check if it exists?
|
|
91
|
+
// Like this.withSession()?
|
|
92
|
+
this.walletConfig = walletConfig;
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
// FIXME: Askar should throw a Duplicate error code, but is currently returning Encryption
|
|
96
|
+
// And if we provide the very same wallet key, it will open it without any error
|
|
97
|
+
if ((0, utils_1.isAskarError)(error) &&
|
|
98
|
+
(error.code === utils_1.AskarErrorCode.Encryption || error.code === utils_1.AskarErrorCode.Duplicate)) {
|
|
99
|
+
const errorMessage = `Wallet '${walletConfig.id}' already exists`;
|
|
100
|
+
this.logger.debug(errorMessage);
|
|
101
|
+
throw new core_1.WalletDuplicateError(errorMessage, {
|
|
102
|
+
walletType: 'AskarWallet',
|
|
103
|
+
cause: error,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
const errorMessage = `Error creating wallet '${walletConfig.id}'`;
|
|
107
|
+
this.logger.error(errorMessage, {
|
|
108
|
+
error,
|
|
109
|
+
errorMessage: error.message,
|
|
110
|
+
});
|
|
111
|
+
throw new core_1.WalletError(errorMessage, { cause: error });
|
|
112
|
+
}
|
|
113
|
+
this.logger.debug(`Successfully created wallet '${walletConfig.id}'`);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* @throws {WalletNotFoundError} if the wallet does not exist
|
|
117
|
+
* @throws {WalletError} if another error occurs
|
|
118
|
+
*/
|
|
119
|
+
async open(walletConfig) {
|
|
120
|
+
await this._open(walletConfig);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* @throws {WalletNotFoundError} if the wallet does not exist
|
|
124
|
+
* @throws {WalletError} if another error occurs
|
|
125
|
+
*/
|
|
126
|
+
async rotateKey(walletConfig) {
|
|
127
|
+
if (!walletConfig.rekey) {
|
|
128
|
+
throw new core_1.WalletError('Wallet rekey undefined!. Please specify the new wallet key');
|
|
129
|
+
}
|
|
130
|
+
await this._open({
|
|
131
|
+
id: walletConfig.id,
|
|
132
|
+
key: walletConfig.key,
|
|
133
|
+
keyDerivationMethod: walletConfig.keyDerivationMethod,
|
|
134
|
+
}, walletConfig.rekey, walletConfig.rekeyDerivationMethod);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* @throws {WalletNotFoundError} if the wallet does not exist
|
|
138
|
+
* @throws {WalletError} if another error occurs
|
|
139
|
+
*/
|
|
140
|
+
async _open(walletConfig, rekey, rekeyDerivation) {
|
|
141
|
+
var _a;
|
|
142
|
+
if (this._store) {
|
|
143
|
+
throw new core_1.WalletError('Wallet instance already opened. Close the currently opened wallet before re-opening the wallet');
|
|
144
|
+
}
|
|
145
|
+
const askarWalletConfig = await this.getAskarWalletConfig(walletConfig);
|
|
146
|
+
try {
|
|
147
|
+
this._store = await aries_askar_shared_1.Store.open({
|
|
148
|
+
uri: askarWalletConfig.uri,
|
|
149
|
+
keyMethod: askarWalletConfig.keyMethod,
|
|
150
|
+
passKey: askarWalletConfig.passKey,
|
|
151
|
+
});
|
|
152
|
+
if (rekey) {
|
|
153
|
+
await this._store.rekey({
|
|
154
|
+
passKey: rekey,
|
|
155
|
+
keyMethod: (0, utils_1.keyDerivationMethodToStoreKeyMethod)(rekeyDerivation !== null && rekeyDerivation !== void 0 ? rekeyDerivation : core_1.KeyDerivationMethod.Argon2IMod),
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
// TODO: Should we do something to check if it exists?
|
|
159
|
+
// Like this.withSession()?
|
|
160
|
+
this.walletConfig = walletConfig;
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
if ((0, utils_1.isAskarError)(error) &&
|
|
164
|
+
(error.code === utils_1.AskarErrorCode.NotFound ||
|
|
165
|
+
(error.code === utils_1.AskarErrorCode.Backend &&
|
|
166
|
+
(0, AskarWalletStorageConfig_1.isAskarWalletSqliteStorageConfig)(walletConfig.storage) &&
|
|
167
|
+
((_a = walletConfig.storage.config) === null || _a === void 0 ? void 0 : _a.inMemory)))) {
|
|
168
|
+
const errorMessage = `Wallet '${walletConfig.id}' not found`;
|
|
169
|
+
this.logger.debug(errorMessage);
|
|
170
|
+
throw new core_1.WalletNotFoundError(errorMessage, {
|
|
171
|
+
walletType: 'AskarWallet',
|
|
172
|
+
cause: error,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
else if ((0, utils_1.isAskarError)(error) && error.code === utils_1.AskarErrorCode.Encryption) {
|
|
176
|
+
const errorMessage = `Incorrect key for wallet '${walletConfig.id}'`;
|
|
177
|
+
this.logger.debug(errorMessage);
|
|
178
|
+
throw new core_1.WalletInvalidKeyError(errorMessage, {
|
|
179
|
+
walletType: 'AskarWallet',
|
|
180
|
+
cause: error,
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
throw new core_1.WalletError(`Error opening wallet ${walletConfig.id}: ${error.message}`, { cause: error });
|
|
184
|
+
}
|
|
185
|
+
this.logger.debug(`Wallet '${walletConfig.id}' opened with handle '${this._store.handle.handle}'`);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* @throws {WalletNotFoundError} if the wallet does not exist
|
|
189
|
+
* @throws {WalletError} if another error occurs
|
|
190
|
+
*/
|
|
191
|
+
async delete() {
|
|
192
|
+
if (!this.walletConfig) {
|
|
193
|
+
throw new core_1.WalletError('Can not delete wallet that does not have wallet config set. Make sure to call create wallet before deleting the wallet');
|
|
194
|
+
}
|
|
195
|
+
this.logger.info(`Deleting wallet '${this.walletConfig.id}'`);
|
|
196
|
+
if (this._store) {
|
|
197
|
+
await this.close();
|
|
198
|
+
}
|
|
199
|
+
try {
|
|
200
|
+
const { uri } = (0, utils_1.uriFromWalletConfig)(this.walletConfig, this.fileSystem.dataPath);
|
|
201
|
+
await aries_askar_shared_1.Store.remove(uri);
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
const errorMessage = `Error deleting wallet '${this.walletConfig.id}': ${error.message}`;
|
|
205
|
+
this.logger.error(errorMessage, {
|
|
206
|
+
error,
|
|
207
|
+
errorMessage: error.message,
|
|
208
|
+
});
|
|
209
|
+
throw new core_1.WalletError(errorMessage, { cause: error });
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
async export(exportConfig) {
|
|
213
|
+
var _a;
|
|
214
|
+
if (!this.walletConfig) {
|
|
215
|
+
throw new core_1.WalletError('Can not export wallet that does not have wallet config set. Make sure to open it before exporting');
|
|
216
|
+
}
|
|
217
|
+
const { path: destinationPath, key: exportKey } = exportConfig;
|
|
218
|
+
const { path: sourcePath } = (0, utils_1.uriFromWalletConfig)(this.walletConfig, this.fileSystem.dataPath);
|
|
219
|
+
if ((0, AskarWalletStorageConfig_1.isAskarWalletSqliteStorageConfig)(this.walletConfig.storage) && ((_a = this.walletConfig.storage) === null || _a === void 0 ? void 0 : _a.inMemory)) {
|
|
220
|
+
throw new core_1.WalletExportUnsupportedError('Export is not supported for in memory wallet');
|
|
221
|
+
}
|
|
222
|
+
if (!sourcePath) {
|
|
223
|
+
throw new core_1.WalletExportUnsupportedError('Export is only supported for SQLite backend');
|
|
224
|
+
}
|
|
225
|
+
try {
|
|
226
|
+
// Export path already exists
|
|
227
|
+
if (await this.fileSystem.exists(destinationPath)) {
|
|
228
|
+
throw new core_1.WalletExportPathExistsError(`Unable to create export, wallet export at path '${exportConfig.path}' already exists`);
|
|
229
|
+
}
|
|
230
|
+
const exportedWalletConfig = await this.getAskarWalletConfig(Object.assign(Object.assign({}, this.walletConfig), { key: exportKey, storage: { type: 'sqlite', config: { path: destinationPath } } }));
|
|
231
|
+
// Make sure destination path exists
|
|
232
|
+
await this.fileSystem.createDirectory(destinationPath);
|
|
233
|
+
await this.store.copyTo({
|
|
234
|
+
recreate: false,
|
|
235
|
+
uri: exportedWalletConfig.uri,
|
|
236
|
+
keyMethod: exportedWalletConfig.keyMethod,
|
|
237
|
+
passKey: exportedWalletConfig.passKey,
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
catch (error) {
|
|
241
|
+
const errorMessage = `Error exporting wallet '${this.walletConfig.id}': ${error.message}`;
|
|
242
|
+
this.logger.error(errorMessage, {
|
|
243
|
+
error,
|
|
244
|
+
errorMessage: error.message,
|
|
245
|
+
});
|
|
246
|
+
if (error instanceof core_1.WalletExportPathExistsError)
|
|
247
|
+
throw error;
|
|
248
|
+
throw new core_1.WalletError(errorMessage, { cause: error });
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
async import(walletConfig, importConfig) {
|
|
252
|
+
const { path: sourcePath, key: importKey } = importConfig;
|
|
253
|
+
const { path: destinationPath } = (0, utils_1.uriFromWalletConfig)(walletConfig, this.fileSystem.dataPath);
|
|
254
|
+
if (!destinationPath) {
|
|
255
|
+
throw new core_1.WalletError('Import is only supported for SQLite backend');
|
|
256
|
+
}
|
|
257
|
+
let sourceWalletStore = undefined;
|
|
258
|
+
try {
|
|
259
|
+
const importWalletConfig = await this.getAskarWalletConfig(walletConfig);
|
|
260
|
+
// Import path already exists
|
|
261
|
+
if (await this.fileSystem.exists(destinationPath)) {
|
|
262
|
+
throw new core_1.WalletExportPathExistsError(`Unable to import wallet. Path '${destinationPath}' already exists`);
|
|
263
|
+
}
|
|
264
|
+
// Make sure destination path exists
|
|
265
|
+
await this.fileSystem.createDirectory(destinationPath);
|
|
266
|
+
// Open imported wallet and copy to destination
|
|
267
|
+
sourceWalletStore = await aries_askar_shared_1.Store.open({
|
|
268
|
+
uri: `sqlite://${sourcePath}`,
|
|
269
|
+
keyMethod: importWalletConfig.keyMethod,
|
|
270
|
+
passKey: importKey,
|
|
271
|
+
});
|
|
272
|
+
const defaultProfile = await sourceWalletStore.getDefaultProfile();
|
|
273
|
+
if (defaultProfile !== importWalletConfig.profile) {
|
|
274
|
+
throw new core_1.WalletError(`Trying to import wallet with walletConfig.id ${importWalletConfig.profile}, however the wallet contains a default profile with id ${defaultProfile}. The walletConfig.id MUST match with the default profile. In the future this behavior may be changed. See https://github.com/hyperledger/aries-askar/issues/221 for more information.`);
|
|
275
|
+
}
|
|
276
|
+
await sourceWalletStore.copyTo({
|
|
277
|
+
recreate: false,
|
|
278
|
+
uri: importWalletConfig.uri,
|
|
279
|
+
keyMethod: importWalletConfig.keyMethod,
|
|
280
|
+
passKey: importWalletConfig.passKey,
|
|
281
|
+
});
|
|
282
|
+
await sourceWalletStore.close();
|
|
283
|
+
}
|
|
284
|
+
catch (error) {
|
|
285
|
+
await (sourceWalletStore === null || sourceWalletStore === void 0 ? void 0 : sourceWalletStore.close());
|
|
286
|
+
const errorMessage = `Error importing wallet '${walletConfig.id}': ${error.message}`;
|
|
287
|
+
this.logger.error(errorMessage, {
|
|
288
|
+
error,
|
|
289
|
+
errorMessage: error.message,
|
|
290
|
+
});
|
|
291
|
+
if (error instanceof core_1.WalletImportPathExistsError)
|
|
292
|
+
throw error;
|
|
293
|
+
// Cleanup any wallet file we could have created
|
|
294
|
+
if (await this.fileSystem.exists(destinationPath)) {
|
|
295
|
+
await this.fileSystem.delete(destinationPath);
|
|
296
|
+
}
|
|
297
|
+
throw new core_1.WalletError(errorMessage, { cause: error });
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* @throws {WalletError} if the wallet is already closed or another error occurs
|
|
302
|
+
*/
|
|
303
|
+
async close() {
|
|
304
|
+
var _a;
|
|
305
|
+
this.logger.debug(`Closing wallet ${(_a = this.walletConfig) === null || _a === void 0 ? void 0 : _a.id}`);
|
|
306
|
+
if (!this._store) {
|
|
307
|
+
throw new core_1.WalletError('Wallet is in invalid state, you are trying to close wallet that has no handle.');
|
|
308
|
+
}
|
|
309
|
+
try {
|
|
310
|
+
await this.store.close();
|
|
311
|
+
this._store = undefined;
|
|
312
|
+
}
|
|
313
|
+
catch (error) {
|
|
314
|
+
const errorMessage = `Error closing wallet': ${error.message}`;
|
|
315
|
+
this.logger.error(errorMessage, {
|
|
316
|
+
error,
|
|
317
|
+
errorMessage: error.message,
|
|
318
|
+
});
|
|
319
|
+
throw new core_1.WalletError(errorMessage, { cause: error });
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
async getAskarWalletConfig(walletConfig) {
|
|
323
|
+
var _a;
|
|
324
|
+
const { uri, path } = (0, utils_1.uriFromWalletConfig)(walletConfig, this.fileSystem.dataPath);
|
|
325
|
+
return {
|
|
326
|
+
uri,
|
|
327
|
+
path,
|
|
328
|
+
profile: walletConfig.id,
|
|
329
|
+
// FIXME: Default derivation method should be set somewhere in either agent config or some constants
|
|
330
|
+
keyMethod: (0, utils_1.keyDerivationMethodToStoreKeyMethod)((_a = walletConfig.keyDerivationMethod) !== null && _a !== void 0 ? _a : core_1.KeyDerivationMethod.Argon2IMod),
|
|
331
|
+
passKey: walletConfig.key,
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
AskarWallet = __decorate([
|
|
336
|
+
(0, tsyringe_1.injectable)(),
|
|
337
|
+
__param(0, (0, tsyringe_1.inject)(core_1.InjectionSymbols.Logger)),
|
|
338
|
+
__param(1, (0, tsyringe_1.inject)(core_1.InjectionSymbols.FileSystem)),
|
|
339
|
+
__metadata("design:paramtypes", [Object, Object, core_1.SigningProviderRegistry])
|
|
340
|
+
], AskarWallet);
|
|
341
|
+
exports.AskarWallet = AskarWallet;
|
|
342
|
+
//# sourceMappingURL=AskarWallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AskarWallet.js","sourceRoot":"","sources":["../../src/wallet/AskarWallet.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,yCAcuB;AACvB,wEAAuD;AACvD,uCAA6C;AAE7C,oCAAiH;AAEjH,uDAAmD;AACnD,yEAA6E;AAE7E;;GAEG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,iCAAe;IAM9C,YACmC,MAAc,EACV,UAAsB,EAC3D,0BAAmD;QAEnD,KAAK,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAA;QACzC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;IAED,IAAW,aAAa;QACtB,OAAO,IAAI,CAAC,YAAY,KAAK,SAAS,CAAA;IACxC,CAAC;IAED,IAAW,aAAa;QACtB,OAAO,IAAI,CAAC,MAAM,KAAK,SAAS,CAAA;IAClC,CAAC;IAED,IAAW,KAAK;QACd,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,MAAM,IAAI,iBAAU,CAClB,oGAAoG,CACrG,CAAA;SACF;QAED,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;IAED,IAAW,OAAO;QAChB,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;YACtB,MAAM,IAAI,kBAAW,CAAC,wBAAwB,CAAC,CAAA;SAChD;QAED,OAAO,IAAI,CA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YAAY,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;SACtD;IACH,CAAC;IAEO,KAAK,CAAC,oBAAoB,CAAC,YAA0B;;QAC3D,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,IAAA,2BAAmB,EAAC,YAAY,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;QAEjF,OAAO;YACL,GAAG;YACH,IAAI;YACJ,OAAO,EAAE,YAAY,CAAC,EAAE;YACxB,oGAAoG;YACpG,SAAS,EAAE,IAAA,2CAAmC,EAC5C,MAAA,YAAY,CAAC,mBAAmB,mCAAI,0BAAmB,CAAC,UAAU,CACnE;YACD,OAAO,EAAE,YAAY,CAAC,GAAG;SAC1B,CAAA;IACH,CAAC;CACF,CAAA;AAxYY,WAAW;IADvB,IAAA,qBAAU,GAAE;IAQR,WAAA,IAAA,iBAAM,EAAC,uBAAgB,CAAC,MAAM,CAAC,CAAA;IAC/B,WAAA,IAAA,iBAAM,EAAC,uBAAgB,CAAC,UAAU,CAAC,CAAA;qDACR,8BAAuB;GAT1C,WAAW,CAwYvB;AAxYY,kCAAW"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { WalletStorageConfig } from '@credo-ts/core';
|
|
2
|
+
export interface AskarWalletPostgresConfig {
|
|
3
|
+
host: string;
|
|
4
|
+
connectTimeout?: number;
|
|
5
|
+
idleTimeout?: number;
|
|
6
|
+
maxConnections?: number;
|
|
7
|
+
minConnections?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface AskarWalletSqliteConfig {
|
|
10
|
+
maxConnections?: number;
|
|
11
|
+
minConnections?: number;
|
|
12
|
+
inMemory?: boolean;
|
|
13
|
+
path?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface AskarWalletPostgresCredentials {
|
|
16
|
+
account: string;
|
|
17
|
+
password: string;
|
|
18
|
+
adminAccount?: string;
|
|
19
|
+
adminPassword?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface AskarWalletPostgresStorageConfig extends WalletStorageConfig {
|
|
22
|
+
type: 'postgres';
|
|
23
|
+
config: AskarWalletPostgresConfig;
|
|
24
|
+
credentials: AskarWalletPostgresCredentials;
|
|
25
|
+
}
|
|
26
|
+
export interface AskarWalletSqliteStorageConfig extends WalletStorageConfig {
|
|
27
|
+
type: 'sqlite';
|
|
28
|
+
config?: AskarWalletSqliteConfig;
|
|
29
|
+
}
|
|
30
|
+
export declare function isAskarWalletSqliteStorageConfig(config?: WalletStorageConfig): config is AskarWalletSqliteStorageConfig;
|
|
31
|
+
export declare function isAskarWalletPostgresStorageConfig(config?: WalletStorageConfig): config is AskarWalletPostgresStorageConfig;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isAskarWalletPostgresStorageConfig = exports.isAskarWalletSqliteStorageConfig = void 0;
|
|
4
|
+
function isAskarWalletSqliteStorageConfig(config) {
|
|
5
|
+
return (config === null || config === void 0 ? void 0 : config.type) === 'sqlite';
|
|
6
|
+
}
|
|
7
|
+
exports.isAskarWalletSqliteStorageConfig = isAskarWalletSqliteStorageConfig;
|
|
8
|
+
function isAskarWalletPostgresStorageConfig(config) {
|
|
9
|
+
return (config === null || config === void 0 ? void 0 : config.type) === 'postgres';
|
|
10
|
+
}
|
|
11
|
+
exports.isAskarWalletPostgresStorageConfig = isAskarWalletPostgresStorageConfig;
|
|
12
|
+
//# sourceMappingURL=AskarWalletStorageConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AskarWalletStorageConfig.js","sourceRoot":"","sources":["../../src/wallet/AskarWalletStorageConfig.ts"],"names":[],"mappings":";;;AAoCA,SAAgB,gCAAgC,CAC9C,MAA4B;IAE5B,OAAO,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,MAAK,QAAQ,CAAA;AAClC,CAAC;AAJD,4EAIC;AAED,SAAgB,kCAAkC,CAChD,MAA4B;IAE5B,OAAO,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,MAAK,UAAU,CAAA;AACpC,CAAC;AAJD,gFAIC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare class JweRecipient {
|
|
2
|
+
encryptedKey: string;
|
|
3
|
+
header?: Record<string, string>;
|
|
4
|
+
constructor(options: {
|
|
5
|
+
encryptedKey: Uint8Array;
|
|
6
|
+
header?: Record<string, string>;
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
export interface JweEnvelopeOptions {
|
|
10
|
+
protected: string;
|
|
11
|
+
unprotected?: string;
|
|
12
|
+
recipients?: JweRecipient[];
|
|
13
|
+
ciphertext: string;
|
|
14
|
+
iv: string;
|
|
15
|
+
tag: string;
|
|
16
|
+
aad?: string;
|
|
17
|
+
header?: string[];
|
|
18
|
+
encryptedKey?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare class JweEnvelope {
|
|
21
|
+
protected: string;
|
|
22
|
+
unprotected?: string;
|
|
23
|
+
recipients?: JweRecipient[];
|
|
24
|
+
ciphertext: string;
|
|
25
|
+
iv: string;
|
|
26
|
+
tag: string;
|
|
27
|
+
aad?: string;
|
|
28
|
+
header?: string[];
|
|
29
|
+
encryptedKey?: string;
|
|
30
|
+
constructor(options: JweEnvelopeOptions);
|
|
31
|
+
toJson(): Record<string, any>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.JweEnvelope = exports.JweRecipient = void 0;
|
|
13
|
+
const core_1 = require("@credo-ts/core");
|
|
14
|
+
const class_transformer_1 = require("class-transformer");
|
|
15
|
+
class JweRecipient {
|
|
16
|
+
constructor(options) {
|
|
17
|
+
if (options) {
|
|
18
|
+
this.encryptedKey = core_1.TypedArrayEncoder.toBase64URL(options.encryptedKey);
|
|
19
|
+
this.header = options.header;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
__decorate([
|
|
24
|
+
(0, class_transformer_1.Expose)({ name: 'encrypted_key' }),
|
|
25
|
+
__metadata("design:type", String)
|
|
26
|
+
], JweRecipient.prototype, "encryptedKey", void 0);
|
|
27
|
+
exports.JweRecipient = JweRecipient;
|
|
28
|
+
class JweEnvelope {
|
|
29
|
+
constructor(options) {
|
|
30
|
+
if (options) {
|
|
31
|
+
this.protected = options.protected;
|
|
32
|
+
this.unprotected = options.unprotected;
|
|
33
|
+
this.recipients = options.recipients;
|
|
34
|
+
this.ciphertext = options.ciphertext;
|
|
35
|
+
this.iv = options.iv;
|
|
36
|
+
this.tag = options.tag;
|
|
37
|
+
this.aad = options.aad;
|
|
38
|
+
this.header = options.header;
|
|
39
|
+
this.encryptedKey = options.encryptedKey;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
toJson() {
|
|
43
|
+
return core_1.JsonTransformer.toJSON(this);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, class_transformer_1.Type)(() => JweRecipient),
|
|
48
|
+
__metadata("design:type", Array)
|
|
49
|
+
], JweEnvelope.prototype, "recipients", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, class_transformer_1.Expose)({ name: 'encrypted_key' }),
|
|
52
|
+
__metadata("design:type", String)
|
|
53
|
+
], JweEnvelope.prototype, "encryptedKey", void 0);
|
|
54
|
+
exports.JweEnvelope = JweEnvelope;
|
|
55
|
+
//# sourceMappingURL=JweEnvelope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JweEnvelope.js","sourceRoot":"","sources":["../../src/wallet/JweEnvelope.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAmE;AACnE,yDAAgD;AAEhD,MAAa,YAAY;IAKvB,YAAmB,OAAsE;QACvF,IAAI,OAAO,EAAE;YACX,IAAI,CAAC,YAAY,GAAG,wBAAiB,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;YAEvE,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;SAC7B;IACH,CAAC;CACF;AAXC;IAAC,IAAA,0BAAM,EAAC,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC;;kDACN;AAF9B,oCAYC;AAcD,MAAa,WAAW;IAetB,YAAmB,OAA2B;QAC5C,IAAI,OAAO,EAAE;YACX,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAA;YAClC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAA;YACtC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAA;YACpC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAA;YACpC,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,CAAA;YACpB,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;YACtB,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;YACtB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;YAC5B,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAA;SACzC;IACH,CAAC;IAEM,MAAM;QACX,OAAO,sBAAe,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACrC,CAAC;CACF;AA5BC;IAAC,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,YAAY,CAAC;;+CACS;AAOlC;IAAC,IAAA,0BAAM,EAAC,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC;;iDACN;AAb9B,kCAgCC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { EncryptedMessage } from '@credo-ts/core';
|
|
2
|
+
import { Key as AskarKey } from '@hyperledger/aries-askar-shared';
|
|
3
|
+
export declare function didcommV1Pack(payload: Record<string, unknown>, recipientKeys: string[], senderKey?: AskarKey): EncryptedMessage;
|
|
4
|
+
export declare function didcommV1Unpack(messagePackage: EncryptedMessage, recipientKey: AskarKey): {
|
|
5
|
+
plaintextMessage: any;
|
|
6
|
+
senderKey: string | undefined;
|
|
7
|
+
recipientKey: string;
|
|
8
|
+
};
|