@credo-ts/askar 0.5.0-alpha.101
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 +62 -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 +145 -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 +109 -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 +3 -0
- package/build/utils/askarKeyTypes.js +17 -0
- package/build/utils/askarKeyTypes.js.map +1 -0
- package/build/utils/askarWalletConfig.d.ts +14 -0
- package/build/utils/askarWalletConfig.js +73 -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 +73 -0
- package/build/wallet/AskarBaseWallet.js +429 -0
- package/build/wallet/AskarBaseWallet.js.map +1 -0
- package/build/wallet/AskarProfileWallet.d.ts +24 -0
- package/build/wallet/AskarProfileWallet.js +166 -0
- package/build/wallet/AskarProfileWallet.js.map +1 -0
- package/build/wallet/AskarWallet.d.ts +64 -0
- package/build/wallet/AskarWallet.js +338 -0
- package/build/wallet/AskarWallet.js.map +1 -0
- package/build/wallet/AskarWalletPostgresStorageConfig.d.ts +19 -0
- package/build/wallet/AskarWalletPostgresStorageConfig.js +3 -0
- package/build/wallet/AskarWalletPostgresStorageConfig.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/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,429 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AskarBaseWallet = void 0;
|
|
7
|
+
const core_1 = require("@credo-ts/core");
|
|
8
|
+
const aries_askar_shared_1 = require("@hyperledger/aries-askar-shared");
|
|
9
|
+
// eslint-disable-next-line import/order
|
|
10
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
|
11
|
+
const isError = (error) => error instanceof Error;
|
|
12
|
+
const utils_1 = require("../utils");
|
|
13
|
+
const JweEnvelope_1 = require("./JweEnvelope");
|
|
14
|
+
class AskarBaseWallet {
|
|
15
|
+
constructor(logger, signingKeyProviderRegistry) {
|
|
16
|
+
this.logger = logger;
|
|
17
|
+
this.signingKeyProviderRegistry = signingKeyProviderRegistry;
|
|
18
|
+
}
|
|
19
|
+
get session() {
|
|
20
|
+
if (!this._session) {
|
|
21
|
+
throw new core_1.AriesFrameworkError('No Wallet Session is opened');
|
|
22
|
+
}
|
|
23
|
+
return this._session;
|
|
24
|
+
}
|
|
25
|
+
get supportedKeyTypes() {
|
|
26
|
+
const signingKeyProviderSupportedKeyTypes = this.signingKeyProviderRegistry.supportedKeyTypes;
|
|
27
|
+
return Array.from(new Set([...utils_1.keyTypesSupportedByAskar, ...signingKeyProviderSupportedKeyTypes]));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Create a key with an optional seed and keyType.
|
|
31
|
+
* The keypair is also automatically stored in the wallet afterwards
|
|
32
|
+
*/
|
|
33
|
+
async createKey({ seed, privateKey, keyType }) {
|
|
34
|
+
try {
|
|
35
|
+
if (seed && privateKey) {
|
|
36
|
+
throw new core_1.WalletError('Only one of seed and privateKey can be set');
|
|
37
|
+
}
|
|
38
|
+
if (seed && !(0, core_1.isValidSeed)(seed, keyType)) {
|
|
39
|
+
throw new core_1.WalletError('Invalid seed provided');
|
|
40
|
+
}
|
|
41
|
+
if (privateKey && !(0, core_1.isValidPrivateKey)(privateKey, keyType)) {
|
|
42
|
+
throw new core_1.WalletError('Invalid private key provided');
|
|
43
|
+
}
|
|
44
|
+
if ((0, utils_1.isKeyTypeSupportedByAskar)(keyType)) {
|
|
45
|
+
const algorithm = (0, aries_askar_shared_1.keyAlgFromString)(keyType);
|
|
46
|
+
// Create key
|
|
47
|
+
let key;
|
|
48
|
+
try {
|
|
49
|
+
const key = privateKey
|
|
50
|
+
? aries_askar_shared_1.Key.fromSecretBytes({ secretKey: privateKey, algorithm })
|
|
51
|
+
: seed
|
|
52
|
+
? aries_askar_shared_1.Key.fromSeed({ seed, algorithm })
|
|
53
|
+
: aries_askar_shared_1.Key.generate(algorithm);
|
|
54
|
+
const keyPublicBytes = key.publicBytes;
|
|
55
|
+
// Store key
|
|
56
|
+
await this.session.insertKey({ key, name: core_1.TypedArrayEncoder.toBase58(keyPublicBytes) });
|
|
57
|
+
key.handle.free();
|
|
58
|
+
return core_1.Key.fromPublicKey(keyPublicBytes, keyType);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
key === null || key === void 0 ? void 0 : key.handle.free();
|
|
62
|
+
// Handle case where key already exists
|
|
63
|
+
if ((0, utils_1.isAskarError)(error, utils_1.AskarErrorCode.Duplicate)) {
|
|
64
|
+
throw new core_1.WalletKeyExistsError('Key already exists');
|
|
65
|
+
}
|
|
66
|
+
// Otherwise re-throw error
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
// Check if there is a signing key provider for the specified key type.
|
|
72
|
+
if (this.signingKeyProviderRegistry.hasProviderForKeyType(keyType)) {
|
|
73
|
+
const signingKeyProvider = this.signingKeyProviderRegistry.getProviderForKeyType(keyType);
|
|
74
|
+
const keyPair = await signingKeyProvider.createKeyPair({ seed, privateKey });
|
|
75
|
+
await this.storeKeyPair(keyPair);
|
|
76
|
+
return core_1.Key.fromPublicKeyBase58(keyPair.publicKeyBase58, keyType);
|
|
77
|
+
}
|
|
78
|
+
throw new core_1.WalletError(`Unsupported key type: '${keyType}'`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
// If already instance of `WalletError`, re-throw
|
|
83
|
+
if (error instanceof core_1.WalletError)
|
|
84
|
+
throw error;
|
|
85
|
+
if (!isError(error)) {
|
|
86
|
+
throw new core_1.AriesFrameworkError('Attempted to throw error, but it was not of type Error', { cause: error });
|
|
87
|
+
}
|
|
88
|
+
throw new core_1.WalletError(`Error creating key with key type '${keyType}': ${error.message}`, { cause: error });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* sign a Buffer with an instance of a Key class
|
|
93
|
+
*
|
|
94
|
+
* @param data Buffer The data that needs to be signed
|
|
95
|
+
* @param key Key The key that is used to sign the data
|
|
96
|
+
*
|
|
97
|
+
* @returns A signature for the data
|
|
98
|
+
*/
|
|
99
|
+
async sign({ data, key }) {
|
|
100
|
+
let keyEntry;
|
|
101
|
+
try {
|
|
102
|
+
if ((0, utils_1.isKeyTypeSupportedByAskar)(key.keyType)) {
|
|
103
|
+
if (!core_1.TypedArrayEncoder.isTypedArray(data)) {
|
|
104
|
+
throw new core_1.WalletError(`Currently not supporting signing of multiple messages`);
|
|
105
|
+
}
|
|
106
|
+
keyEntry = await this.session.fetchKey({ name: key.publicKeyBase58 });
|
|
107
|
+
if (!keyEntry) {
|
|
108
|
+
throw new core_1.WalletError('Key entry not found');
|
|
109
|
+
}
|
|
110
|
+
const signed = keyEntry.key.signMessage({ message: data });
|
|
111
|
+
keyEntry.key.handle.free();
|
|
112
|
+
return core_1.Buffer.from(signed);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
// Check if there is a signing key provider for the specified key type.
|
|
116
|
+
if (this.signingKeyProviderRegistry.hasProviderForKeyType(key.keyType)) {
|
|
117
|
+
const signingKeyProvider = this.signingKeyProviderRegistry.getProviderForKeyType(key.keyType);
|
|
118
|
+
const keyPair = await this.retrieveKeyPair(key.publicKeyBase58);
|
|
119
|
+
const signed = await signingKeyProvider.sign({
|
|
120
|
+
data,
|
|
121
|
+
privateKeyBase58: keyPair.privateKeyBase58,
|
|
122
|
+
publicKeyBase58: key.publicKeyBase58,
|
|
123
|
+
});
|
|
124
|
+
return signed;
|
|
125
|
+
}
|
|
126
|
+
throw new core_1.WalletError(`Unsupported keyType: ${key.keyType}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
keyEntry === null || keyEntry === void 0 ? void 0 : keyEntry.key.handle.free();
|
|
131
|
+
if (!isError(error)) {
|
|
132
|
+
throw new core_1.AriesFrameworkError('Attempted to throw error, but it was not of type Error', { cause: error });
|
|
133
|
+
}
|
|
134
|
+
throw new core_1.WalletError(`Error signing data with verkey ${key.publicKeyBase58}. ${error.message}`, { cause: error });
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Verify the signature with the data and the used key
|
|
139
|
+
*
|
|
140
|
+
* @param data Buffer The data that has to be confirmed to be signed
|
|
141
|
+
* @param key Key The key that was used in the signing process
|
|
142
|
+
* @param signature Buffer The signature that was created by the signing process
|
|
143
|
+
*
|
|
144
|
+
* @returns A boolean whether the signature was created with the supplied data and key
|
|
145
|
+
*
|
|
146
|
+
* @throws {WalletError} When it could not do the verification
|
|
147
|
+
* @throws {WalletError} When an unsupported keytype is used
|
|
148
|
+
*/
|
|
149
|
+
async verify({ data, key, signature }) {
|
|
150
|
+
let askarKey;
|
|
151
|
+
try {
|
|
152
|
+
if ((0, utils_1.isKeyTypeSupportedByAskar)(key.keyType)) {
|
|
153
|
+
if (!core_1.TypedArrayEncoder.isTypedArray(data)) {
|
|
154
|
+
throw new core_1.WalletError(`Currently not supporting verification of multiple messages`);
|
|
155
|
+
}
|
|
156
|
+
const askarKey = aries_askar_shared_1.Key.fromPublicBytes({
|
|
157
|
+
algorithm: (0, aries_askar_shared_1.keyAlgFromString)(key.keyType),
|
|
158
|
+
publicKey: key.publicKey,
|
|
159
|
+
});
|
|
160
|
+
const verified = askarKey.verifySignature({ message: data, signature });
|
|
161
|
+
askarKey.handle.free();
|
|
162
|
+
return verified;
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
// Check if there is a signing key provider for the specified key type.
|
|
166
|
+
if (this.signingKeyProviderRegistry.hasProviderForKeyType(key.keyType)) {
|
|
167
|
+
const signingKeyProvider = this.signingKeyProviderRegistry.getProviderForKeyType(key.keyType);
|
|
168
|
+
const signed = await signingKeyProvider.verify({
|
|
169
|
+
data,
|
|
170
|
+
signature,
|
|
171
|
+
publicKeyBase58: key.publicKeyBase58,
|
|
172
|
+
});
|
|
173
|
+
return signed;
|
|
174
|
+
}
|
|
175
|
+
throw new core_1.WalletError(`Unsupported keyType: ${key.keyType}`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
askarKey === null || askarKey === void 0 ? void 0 : askarKey.handle.free();
|
|
180
|
+
if (!isError(error)) {
|
|
181
|
+
throw new core_1.AriesFrameworkError('Attempted to throw error, but it was not of type Error', { cause: error });
|
|
182
|
+
}
|
|
183
|
+
throw new core_1.WalletError(`Error verifying signature of data signed with verkey ${key.publicKeyBase58}`, {
|
|
184
|
+
cause: error,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Pack a message using DIDComm V1 algorithm
|
|
190
|
+
*
|
|
191
|
+
* @param payload message to send
|
|
192
|
+
* @param recipientKeys array containing recipient keys in base58
|
|
193
|
+
* @param senderVerkey sender key in base58
|
|
194
|
+
* @returns JWE Envelope to send
|
|
195
|
+
*/
|
|
196
|
+
async pack(payload, recipientKeys, senderVerkey // in base58
|
|
197
|
+
) {
|
|
198
|
+
let cek;
|
|
199
|
+
let senderKey;
|
|
200
|
+
let senderExchangeKey;
|
|
201
|
+
try {
|
|
202
|
+
cek = aries_askar_shared_1.Key.generate(aries_askar_shared_1.KeyAlgs.Chacha20C20P);
|
|
203
|
+
senderKey = senderVerkey ? await this.session.fetchKey({ name: senderVerkey }) : undefined;
|
|
204
|
+
if (senderVerkey && !senderKey) {
|
|
205
|
+
throw new core_1.WalletError(`Unable to pack message. Sender key ${senderVerkey} not found in wallet.`);
|
|
206
|
+
}
|
|
207
|
+
senderExchangeKey = senderKey ? senderKey.key.convertkey({ algorithm: aries_askar_shared_1.KeyAlgs.X25519 }) : undefined;
|
|
208
|
+
const recipients = [];
|
|
209
|
+
for (const recipientKey of recipientKeys) {
|
|
210
|
+
let targetExchangeKey;
|
|
211
|
+
try {
|
|
212
|
+
targetExchangeKey = aries_askar_shared_1.Key.fromPublicBytes({
|
|
213
|
+
publicKey: core_1.Key.fromPublicKeyBase58(recipientKey, core_1.KeyType.Ed25519).publicKey,
|
|
214
|
+
algorithm: aries_askar_shared_1.KeyAlgs.Ed25519,
|
|
215
|
+
}).convertkey({ algorithm: aries_askar_shared_1.KeyAlgs.X25519 });
|
|
216
|
+
if (senderVerkey && senderExchangeKey) {
|
|
217
|
+
const encryptedSender = aries_askar_shared_1.CryptoBox.seal({
|
|
218
|
+
recipientKey: targetExchangeKey,
|
|
219
|
+
message: core_1.Buffer.from(senderVerkey),
|
|
220
|
+
});
|
|
221
|
+
const nonce = aries_askar_shared_1.CryptoBox.randomNonce();
|
|
222
|
+
const encryptedCek = aries_askar_shared_1.CryptoBox.cryptoBox({
|
|
223
|
+
recipientKey: targetExchangeKey,
|
|
224
|
+
senderKey: senderExchangeKey,
|
|
225
|
+
message: cek.secretBytes,
|
|
226
|
+
nonce,
|
|
227
|
+
});
|
|
228
|
+
recipients.push(new JweEnvelope_1.JweRecipient({
|
|
229
|
+
encryptedKey: encryptedCek,
|
|
230
|
+
header: {
|
|
231
|
+
kid: recipientKey,
|
|
232
|
+
sender: core_1.TypedArrayEncoder.toBase64URL(encryptedSender),
|
|
233
|
+
iv: core_1.TypedArrayEncoder.toBase64URL(nonce),
|
|
234
|
+
},
|
|
235
|
+
}));
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
const encryptedCek = aries_askar_shared_1.CryptoBox.seal({
|
|
239
|
+
recipientKey: targetExchangeKey,
|
|
240
|
+
message: cek.secretBytes,
|
|
241
|
+
});
|
|
242
|
+
recipients.push(new JweEnvelope_1.JweRecipient({
|
|
243
|
+
encryptedKey: encryptedCek,
|
|
244
|
+
header: {
|
|
245
|
+
kid: recipientKey,
|
|
246
|
+
},
|
|
247
|
+
}));
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
finally {
|
|
251
|
+
targetExchangeKey === null || targetExchangeKey === void 0 ? void 0 : targetExchangeKey.handle.free();
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
const protectedJson = {
|
|
255
|
+
enc: 'xchacha20poly1305_ietf',
|
|
256
|
+
typ: 'JWM/1.0',
|
|
257
|
+
alg: senderVerkey ? 'Authcrypt' : 'Anoncrypt',
|
|
258
|
+
recipients: recipients.map((item) => core_1.JsonTransformer.toJSON(item)),
|
|
259
|
+
};
|
|
260
|
+
const { ciphertext, tag, nonce } = cek.aeadEncrypt({
|
|
261
|
+
message: core_1.Buffer.from(JSON.stringify(payload)),
|
|
262
|
+
aad: core_1.Buffer.from(core_1.JsonEncoder.toBase64URL(protectedJson)),
|
|
263
|
+
}).parts;
|
|
264
|
+
const envelope = new JweEnvelope_1.JweEnvelope({
|
|
265
|
+
ciphertext: core_1.TypedArrayEncoder.toBase64URL(ciphertext),
|
|
266
|
+
iv: core_1.TypedArrayEncoder.toBase64URL(nonce),
|
|
267
|
+
protected: core_1.JsonEncoder.toBase64URL(protectedJson),
|
|
268
|
+
tag: core_1.TypedArrayEncoder.toBase64URL(tag),
|
|
269
|
+
}).toJson();
|
|
270
|
+
return envelope;
|
|
271
|
+
}
|
|
272
|
+
finally {
|
|
273
|
+
cek === null || cek === void 0 ? void 0 : cek.handle.free();
|
|
274
|
+
senderKey === null || senderKey === void 0 ? void 0 : senderKey.key.handle.free();
|
|
275
|
+
senderExchangeKey === null || senderExchangeKey === void 0 ? void 0 : senderExchangeKey.handle.free();
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Unpacks a JWE Envelope coded using DIDComm V1 algorithm
|
|
280
|
+
*
|
|
281
|
+
* @param messagePackage JWE Envelope
|
|
282
|
+
* @returns UnpackedMessageContext with plain text message, sender key and recipient key
|
|
283
|
+
*/
|
|
284
|
+
async unpack(messagePackage) {
|
|
285
|
+
const protectedJson = core_1.JsonEncoder.fromBase64(messagePackage.protected);
|
|
286
|
+
const alg = protectedJson.alg;
|
|
287
|
+
if (!['Anoncrypt', 'Authcrypt'].includes(alg)) {
|
|
288
|
+
throw new core_1.WalletError(`Unsupported pack algorithm: ${alg}`);
|
|
289
|
+
}
|
|
290
|
+
const recipients = [];
|
|
291
|
+
for (const recip of protectedJson.recipients) {
|
|
292
|
+
const kid = recip.header.kid;
|
|
293
|
+
if (!kid) {
|
|
294
|
+
throw new core_1.WalletError('Blank recipient key');
|
|
295
|
+
}
|
|
296
|
+
const sender = recip.header.sender ? core_1.TypedArrayEncoder.fromBase64(recip.header.sender) : undefined;
|
|
297
|
+
const iv = recip.header.iv ? core_1.TypedArrayEncoder.fromBase64(recip.header.iv) : undefined;
|
|
298
|
+
if (sender && !iv) {
|
|
299
|
+
throw new core_1.WalletError('Missing IV');
|
|
300
|
+
}
|
|
301
|
+
else if (!sender && iv) {
|
|
302
|
+
throw new core_1.WalletError('Unexpected IV');
|
|
303
|
+
}
|
|
304
|
+
recipients.push({
|
|
305
|
+
kid,
|
|
306
|
+
sender,
|
|
307
|
+
iv,
|
|
308
|
+
encrypted_key: core_1.TypedArrayEncoder.fromBase64(recip.encrypted_key),
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
let payloadKey, senderKey, recipientKey;
|
|
312
|
+
for (const recipient of recipients) {
|
|
313
|
+
let recipientKeyEntry;
|
|
314
|
+
let sender_x;
|
|
315
|
+
let recip_x;
|
|
316
|
+
try {
|
|
317
|
+
recipientKeyEntry = await this.session.fetchKey({ name: recipient.kid });
|
|
318
|
+
if (recipientKeyEntry) {
|
|
319
|
+
const recip_x = recipientKeyEntry.key.convertkey({ algorithm: aries_askar_shared_1.KeyAlgs.X25519 });
|
|
320
|
+
recipientKey = recipient.kid;
|
|
321
|
+
if (recipient.sender && recipient.iv) {
|
|
322
|
+
senderKey = core_1.TypedArrayEncoder.toUtf8String(aries_askar_shared_1.CryptoBox.sealOpen({
|
|
323
|
+
recipientKey: recip_x,
|
|
324
|
+
ciphertext: recipient.sender,
|
|
325
|
+
}));
|
|
326
|
+
const sender_x = aries_askar_shared_1.Key.fromPublicBytes({
|
|
327
|
+
algorithm: aries_askar_shared_1.KeyAlgs.Ed25519,
|
|
328
|
+
publicKey: core_1.TypedArrayEncoder.fromBase58(senderKey),
|
|
329
|
+
}).convertkey({ algorithm: aries_askar_shared_1.KeyAlgs.X25519 });
|
|
330
|
+
payloadKey = aries_askar_shared_1.CryptoBox.open({
|
|
331
|
+
recipientKey: recip_x,
|
|
332
|
+
senderKey: sender_x,
|
|
333
|
+
message: recipient.encrypted_key,
|
|
334
|
+
nonce: recipient.iv,
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
payloadKey = aries_askar_shared_1.CryptoBox.sealOpen({ ciphertext: recipient.encrypted_key, recipientKey: recip_x });
|
|
339
|
+
}
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
finally {
|
|
344
|
+
recipientKeyEntry === null || recipientKeyEntry === void 0 ? void 0 : recipientKeyEntry.key.handle.free();
|
|
345
|
+
sender_x === null || sender_x === void 0 ? void 0 : sender_x.handle.free();
|
|
346
|
+
recip_x === null || recip_x === void 0 ? void 0 : recip_x.handle.free();
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
if (!payloadKey) {
|
|
350
|
+
throw new core_1.WalletError('No corresponding recipient key found');
|
|
351
|
+
}
|
|
352
|
+
if (!senderKey && alg === 'Authcrypt') {
|
|
353
|
+
throw new core_1.WalletError('Sender public key not provided for Authcrypt');
|
|
354
|
+
}
|
|
355
|
+
let cek;
|
|
356
|
+
try {
|
|
357
|
+
cek = aries_askar_shared_1.Key.fromSecretBytes({ algorithm: aries_askar_shared_1.KeyAlgs.Chacha20C20P, secretKey: payloadKey });
|
|
358
|
+
const message = cek.aeadDecrypt({
|
|
359
|
+
ciphertext: core_1.TypedArrayEncoder.fromBase64(messagePackage.ciphertext),
|
|
360
|
+
nonce: core_1.TypedArrayEncoder.fromBase64(messagePackage.iv),
|
|
361
|
+
tag: core_1.TypedArrayEncoder.fromBase64(messagePackage.tag),
|
|
362
|
+
aad: core_1.TypedArrayEncoder.fromString(messagePackage.protected),
|
|
363
|
+
});
|
|
364
|
+
return {
|
|
365
|
+
plaintextMessage: core_1.JsonEncoder.fromBuffer(message),
|
|
366
|
+
senderKey,
|
|
367
|
+
recipientKey,
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
finally {
|
|
371
|
+
cek === null || cek === void 0 ? void 0 : cek.handle.free();
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
async generateNonce() {
|
|
375
|
+
try {
|
|
376
|
+
// generate an 80-bit nonce suitable for AnonCreds proofs
|
|
377
|
+
const nonce = aries_askar_shared_1.CryptoBox.randomNonce().slice(0, 10);
|
|
378
|
+
return new bn_js_1.default(nonce).toString();
|
|
379
|
+
}
|
|
380
|
+
catch (error) {
|
|
381
|
+
if (!isError(error)) {
|
|
382
|
+
throw new core_1.AriesFrameworkError('Attempted to throw error, but it was not of type Error', { cause: error });
|
|
383
|
+
}
|
|
384
|
+
throw new core_1.WalletError('Error generating nonce', { cause: error });
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
async generateWalletKey() {
|
|
388
|
+
try {
|
|
389
|
+
return aries_askar_shared_1.Store.generateRawKey();
|
|
390
|
+
}
|
|
391
|
+
catch (error) {
|
|
392
|
+
throw new core_1.WalletError('Error generating wallet key', { cause: error });
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
async retrieveKeyPair(publicKeyBase58) {
|
|
396
|
+
try {
|
|
397
|
+
const entryObject = await this.session.fetch({ category: 'KeyPairRecord', name: `key-${publicKeyBase58}` });
|
|
398
|
+
if (entryObject === null || entryObject === void 0 ? void 0 : entryObject.value) {
|
|
399
|
+
return core_1.JsonEncoder.fromString(entryObject === null || entryObject === void 0 ? void 0 : entryObject.value);
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
throw new core_1.WalletError(`No content found for record with public key: ${publicKeyBase58}`);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
catch (error) {
|
|
406
|
+
throw new core_1.WalletError('Error retrieving KeyPair record', { cause: error });
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
async storeKeyPair(keyPair) {
|
|
410
|
+
try {
|
|
411
|
+
await this.session.insert({
|
|
412
|
+
category: 'KeyPairRecord',
|
|
413
|
+
name: `key-${keyPair.publicKeyBase58}`,
|
|
414
|
+
value: JSON.stringify(keyPair),
|
|
415
|
+
tags: {
|
|
416
|
+
keyType: keyPair.keyType,
|
|
417
|
+
},
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
catch (error) {
|
|
421
|
+
if ((0, utils_1.isAskarError)(error, utils_1.AskarErrorCode.Duplicate)) {
|
|
422
|
+
throw new core_1.WalletKeyExistsError('Key already exists');
|
|
423
|
+
}
|
|
424
|
+
throw new core_1.WalletError('Error saving KeyPair record', { cause: error });
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
exports.AskarBaseWallet = AskarBaseWallet;
|
|
429
|
+
//# sourceMappingURL=AskarBaseWallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AskarBaseWallet.js","sourceRoot":"","sources":["../../src/wallet/AskarBaseWallet.ts"],"names":[],"mappings":";;;;;;AAgBA,yCAYuB;AACvB,wEAA8G;AAC9G,wCAAwC;AACxC,kDAA6B;AAE7B,MAAM,OAAO,GAAG,CAAC,KAAc,EAAkB,EAAE,CAAC,KAAK,YAAY,KAAK,CAAA;AAE1E,oCAA4G;AAE5G,+CAAyD;AAEzD,MAAsB,eAAe;IAMnC,YAAmB,MAAc,EAAE,0BAAmD;QACpF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,0BAA0B,GAAG,0BAA0B,CAAA;IAC9D,CAAC;IAkBD,IAAW,OAAO;QAChB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB,MAAM,IAAI,0BAAmB,CAAC,6BAA6B,CAAC,CAAA;SAC7D;QAED,OAAO,IAAI,CAAC,QAAQ,CAAA;IACtB,CAAC;IAED,IAAW,iBAAiB;QAC1B,MAAM,mCAAmC,GAAG,IAAI,CAAC,0BAA0B,CAAC,iBAAiB,CAAA;QAE7F,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,gCAAwB,EAAE,GAAG,mCAAmC,CAAC,CAAC,CAAC,CAAA;IACnG,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,UAAU,E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,CAAC,EAAE,QAAQ,EAAE,eAAe,EAAE,IAAI,EAAE,OAAO,eAAe,EAAE,EAAE,CAAC,CAAA;YAE3G,IAAI,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,KAAK,EAAE;gBACtB,OAAO,kBAAW,CAAC,UAAU,CAAC,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,KAAe,CAAY,CAAA;aACvE;iBAAM;gBACL,MAAM,IAAI,kBAAW,CAAC,gDAAgD,eAAe,EAAE,CAAC,CAAA;aACzF;SACF;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,IAAI,kBAAW,CAAC,iCAAiC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;SAC3E;IACH,CAAC;IAEO,KAAK,CAAC,YAAY,CAAC,OAAgB;QACzC,IAAI;YACF,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;gBACxB,QAAQ,EAAE,eAAe;gBACzB,IAAI,EAAE,OAAO,OAAO,CAAC,eAAe,EAAE;gBACtC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;gBAC9B,IAAI,EAAE;oBACJ,OAAO,EAAE,OAAO,CAAC,OAAO;iBACzB;aACF,CAAC,CAAA;SACH;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,IAAA,oBAAY,EAAC,KAAK,EAAE,sBAAc,CAAC,SAAS,CAAC,EAAE;gBACjD,MAAM,IAAI,2BAAoB,CAAC,oBAAoB,CAAC,CAAA;aACrD;YACD,MAAM,IAAI,kBAAW,CAAC,6BAA6B,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;SACvE;IACH,CAAC;CACF;AA3dD,0CA2dC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { WalletConfig } from '@credo-ts/core';
|
|
2
|
+
import { Logger, SigningProviderRegistry } from '@credo-ts/core';
|
|
3
|
+
import { Store } from '@hyperledger/aries-askar-shared';
|
|
4
|
+
import { AskarBaseWallet } from './AskarBaseWallet';
|
|
5
|
+
export declare class AskarProfileWallet extends AskarBaseWallet {
|
|
6
|
+
private walletConfig?;
|
|
7
|
+
readonly store: Store;
|
|
8
|
+
constructor(store: Store, logger: Logger, signingKeyProviderRegistry: SigningProviderRegistry);
|
|
9
|
+
get isInitialized(): boolean;
|
|
10
|
+
get isProvisioned(): boolean;
|
|
11
|
+
get profile(): string;
|
|
12
|
+
/**
|
|
13
|
+
* Dispose method is called when an agent context is disposed.
|
|
14
|
+
*/
|
|
15
|
+
dispose(): Promise<void>;
|
|
16
|
+
create(walletConfig: WalletConfig): Promise<void>;
|
|
17
|
+
open(walletConfig: WalletConfig): Promise<void>;
|
|
18
|
+
createAndOpen(walletConfig: WalletConfig): Promise<void>;
|
|
19
|
+
delete(): Promise<void>;
|
|
20
|
+
export(): Promise<void>;
|
|
21
|
+
import(): Promise<void>;
|
|
22
|
+
rotateKey(): Promise<void>;
|
|
23
|
+
close(): Promise<void>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
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.AskarProfileWallet = 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
|
+
let AskarProfileWallet = class AskarProfileWallet extends AskarBaseWallet_1.AskarBaseWallet {
|
|
22
|
+
constructor(store, logger, signingKeyProviderRegistry) {
|
|
23
|
+
super(logger, signingKeyProviderRegistry);
|
|
24
|
+
this.store = store;
|
|
25
|
+
}
|
|
26
|
+
get isInitialized() {
|
|
27
|
+
return this._session !== undefined;
|
|
28
|
+
}
|
|
29
|
+
get isProvisioned() {
|
|
30
|
+
return this.walletConfig !== undefined;
|
|
31
|
+
}
|
|
32
|
+
get profile() {
|
|
33
|
+
if (!this.walletConfig) {
|
|
34
|
+
throw new core_1.WalletError('No profile configured.');
|
|
35
|
+
}
|
|
36
|
+
return this.walletConfig.id;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Dispose method is called when an agent context is disposed.
|
|
40
|
+
*/
|
|
41
|
+
async dispose() {
|
|
42
|
+
if (this.isInitialized) {
|
|
43
|
+
await this.close();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async create(walletConfig) {
|
|
47
|
+
this.logger.debug(`Creating wallet for profile '${walletConfig.id}'`);
|
|
48
|
+
try {
|
|
49
|
+
await this.store.createProfile(walletConfig.id);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
if ((0, utils_1.isAskarError)(error, utils_1.AskarErrorCode.Duplicate)) {
|
|
53
|
+
const errorMessage = `Wallet for profile '${walletConfig.id}' already exists`;
|
|
54
|
+
this.logger.debug(errorMessage);
|
|
55
|
+
throw new core_1.WalletDuplicateError(errorMessage, {
|
|
56
|
+
walletType: 'AskarProfileWallet',
|
|
57
|
+
cause: error,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
const errorMessage = `Error creating wallet for profile '${walletConfig.id}'`;
|
|
61
|
+
this.logger.error(errorMessage, {
|
|
62
|
+
error,
|
|
63
|
+
errorMessage: error.message,
|
|
64
|
+
});
|
|
65
|
+
throw new core_1.WalletError(errorMessage, { cause: error });
|
|
66
|
+
}
|
|
67
|
+
this.logger.debug(`Successfully created wallet for profile '${walletConfig.id}'`);
|
|
68
|
+
}
|
|
69
|
+
async open(walletConfig) {
|
|
70
|
+
this.logger.debug(`Opening wallet for profile '${walletConfig.id}'`);
|
|
71
|
+
try {
|
|
72
|
+
this.walletConfig = walletConfig;
|
|
73
|
+
this._session = await this.store.session(walletConfig.id).open();
|
|
74
|
+
// FIXME: opening a session for a profile that does not exist, will not throw an error until
|
|
75
|
+
// the session is actually used. We can check if the profile exists by doing something with
|
|
76
|
+
// the session, which will throw a not found error if the profile does not exists,
|
|
77
|
+
// but that is not very efficient as it needs to be done on every open.
|
|
78
|
+
// See: https://github.com/hyperledger/aries-askar/issues/163
|
|
79
|
+
await this._session.fetch({
|
|
80
|
+
category: 'fetch-to-see-if-profile-exists',
|
|
81
|
+
name: 'fetch-to-see-if-profile-exists',
|
|
82
|
+
forUpdate: false,
|
|
83
|
+
isJson: false,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
// Profile does not exist
|
|
88
|
+
if ((0, utils_1.isAskarError)(error, utils_1.AskarErrorCode.NotFound)) {
|
|
89
|
+
const errorMessage = `Wallet for profile '${walletConfig.id}' not found`;
|
|
90
|
+
this.logger.debug(errorMessage);
|
|
91
|
+
throw new core_1.WalletNotFoundError(errorMessage, {
|
|
92
|
+
walletType: 'AskarProfileWallet',
|
|
93
|
+
cause: error,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
const errorMessage = `Error opening wallet for profile '${walletConfig.id}'`;
|
|
97
|
+
this.logger.error(errorMessage, {
|
|
98
|
+
error,
|
|
99
|
+
errorMessage: error.message,
|
|
100
|
+
});
|
|
101
|
+
throw new core_1.WalletError(errorMessage, { cause: error });
|
|
102
|
+
}
|
|
103
|
+
this.logger.debug(`Successfully opened wallet for profile '${walletConfig.id}'`);
|
|
104
|
+
}
|
|
105
|
+
async createAndOpen(walletConfig) {
|
|
106
|
+
await this.create(walletConfig);
|
|
107
|
+
await this.open(walletConfig);
|
|
108
|
+
}
|
|
109
|
+
async delete() {
|
|
110
|
+
if (!this.walletConfig) {
|
|
111
|
+
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');
|
|
112
|
+
}
|
|
113
|
+
this.logger.info(`Deleting profile '${this.walletConfig.id}'`);
|
|
114
|
+
if (this._session) {
|
|
115
|
+
await this.close();
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
await this.store.removeProfile(this.walletConfig.id);
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
const errorMessage = `Error deleting wallet for profile '${this.walletConfig.id}': ${error.message}`;
|
|
122
|
+
this.logger.error(errorMessage, {
|
|
123
|
+
error,
|
|
124
|
+
errorMessage: error.message,
|
|
125
|
+
});
|
|
126
|
+
throw new core_1.WalletError(errorMessage, { cause: error });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
async export() {
|
|
130
|
+
// This PR should help with this: https://github.com/hyperledger/aries-askar/pull/159
|
|
131
|
+
throw new core_1.WalletError('Exporting a profile is not supported.');
|
|
132
|
+
}
|
|
133
|
+
async import() {
|
|
134
|
+
// This PR should help with this: https://github.com/hyperledger/aries-askar/pull/159
|
|
135
|
+
throw new core_1.WalletError('Importing a profile is not supported.');
|
|
136
|
+
}
|
|
137
|
+
async rotateKey() {
|
|
138
|
+
throw new core_1.WalletError('Rotating a key is not supported for a profile. You can rotate the key on the main askar wallet.');
|
|
139
|
+
}
|
|
140
|
+
async close() {
|
|
141
|
+
var _a, _b;
|
|
142
|
+
this.logger.debug(`Closing wallet for profile ${(_a = this.walletConfig) === null || _a === void 0 ? void 0 : _a.id}`);
|
|
143
|
+
if (!this._session) {
|
|
144
|
+
throw new core_1.WalletError('Wallet is in invalid state, you are trying to close wallet that has no handle.');
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
await this.session.close();
|
|
148
|
+
this._session = undefined;
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
const errorMessage = `Error closing wallet for profile ${(_b = this.walletConfig) === null || _b === void 0 ? void 0 : _b.id}: ${error.message}`;
|
|
152
|
+
this.logger.error(errorMessage, {
|
|
153
|
+
error,
|
|
154
|
+
errorMessage: error.message,
|
|
155
|
+
});
|
|
156
|
+
throw new core_1.WalletError(errorMessage, { cause: error });
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
AskarProfileWallet = __decorate([
|
|
161
|
+
(0, tsyringe_1.injectable)(),
|
|
162
|
+
__param(1, (0, tsyringe_1.inject)(core_1.InjectionSymbols.Logger)),
|
|
163
|
+
__metadata("design:paramtypes", [aries_askar_shared_1.Store, Object, core_1.SigningProviderRegistry])
|
|
164
|
+
], AskarProfileWallet);
|
|
165
|
+
exports.AskarProfileWallet = AskarProfileWallet;
|
|
166
|
+
//# sourceMappingURL=AskarProfileWallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AskarProfileWallet.js","sourceRoot":"","sources":["../../src/wallet/AskarProfileWallet.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,yCAOuB;AACvB,wEAAuD;AACvD,uCAA6C;AAE7C,oCAAuD;AAEvD,uDAAmD;AAG5C,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,iCAAe;IAIrD,YACE,KAAY,EACqB,MAAc,EAC/C,0BAAmD;QAEnD,KAAK,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAA;QAEz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