@didcid/keymaster 0.3.4 → 0.3.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/README.md +7 -7
- package/dist/cjs/db/typeGuards.cjs +2 -2
- package/dist/cjs/keymaster-client.cjs +9 -9
- package/dist/cjs/keymaster.cjs +73 -66
- package/dist/esm/cli.js +65 -61
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/db/typeGuards.js +2 -2
- package/dist/esm/db/typeGuards.js.map +1 -1
- package/dist/esm/keymaster-client.js +9 -9
- package/dist/esm/keymaster-client.js.map +1 -1
- package/dist/esm/keymaster.js +73 -66
- package/dist/esm/keymaster.js.map +1 -1
- package/dist/types/keymaster-client.d.ts +4 -4
- package/dist/types/keymaster.d.ts +7 -7
- package/dist/types/types.d.ts +8 -8
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -198,14 +198,14 @@ keymaster list-ids
|
|
|
198
198
|
| `create-response <challenge>` | Respond to a challenge |
|
|
199
199
|
| `verify-response <response>` | Verify a response |
|
|
200
200
|
|
|
201
|
-
#####
|
|
201
|
+
##### Aliases
|
|
202
202
|
|
|
203
203
|
| Command | Description |
|
|
204
204
|
|---------|-------------|
|
|
205
|
-
| `add-
|
|
206
|
-
| `get-
|
|
207
|
-
| `remove-
|
|
208
|
-
| `list-
|
|
205
|
+
| `add-alias <alias> <did>` | Add alias for DID |
|
|
206
|
+
| `get-alias <alias>` | Get DID by alias |
|
|
207
|
+
| `remove-alias <alias>` | Remove alias |
|
|
208
|
+
| `list-aliases` | List all aliases |
|
|
209
209
|
|
|
210
210
|
##### Groups
|
|
211
211
|
|
|
@@ -276,13 +276,13 @@ Many commands support these options:
|
|
|
276
276
|
|
|
277
277
|
| Option | Description |
|
|
278
278
|
|--------|-------------|
|
|
279
|
-
| `-
|
|
279
|
+
| `-a, --alias <alias>` | Assign an alias to created DID |
|
|
280
280
|
| `-r, --registry <registry>` | Specify DID registry |
|
|
281
281
|
|
|
282
282
|
Example:
|
|
283
283
|
```bash
|
|
284
284
|
keymaster create-id MyBot -r hyperswarm
|
|
285
|
-
keymaster create-schema schema.json -
|
|
285
|
+
keymaster create-schema schema.json -a my-schema -r local
|
|
286
286
|
```
|
|
287
287
|
|
|
288
288
|
### Client
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
function isWalletEncFile(obj) {
|
|
4
|
-
return !!obj && obj.version === 1 && typeof obj.enc === 'string' && obj.seed?.mnemonicEnc;
|
|
4
|
+
return !!obj && (obj.version === 1 || obj.version === 2) && typeof obj.enc === 'string' && obj.seed?.mnemonicEnc;
|
|
5
5
|
}
|
|
6
6
|
function isWalletFile(obj) {
|
|
7
|
-
return !!obj && obj.version === 1 && obj.seed?.mnemonicEnc && !('enc' in obj);
|
|
7
|
+
return !!obj && (obj.version === 1 || obj.version === 2) && obj.seed?.mnemonicEnc && !('enc' in obj);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
exports.isWalletEncFile = isWalletEncFile;
|
|
@@ -275,36 +275,36 @@ class KeymasterClient {
|
|
|
275
275
|
throwError(error);
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
|
-
async
|
|
278
|
+
async listAliases() {
|
|
279
279
|
try {
|
|
280
|
-
const response = await axios.get(`${this.API}/
|
|
281
|
-
return response.data.
|
|
280
|
+
const response = await axios.get(`${this.API}/aliases`);
|
|
281
|
+
return response.data.aliases;
|
|
282
282
|
}
|
|
283
283
|
catch (error) {
|
|
284
284
|
throwError(error);
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
|
-
async
|
|
287
|
+
async addAlias(alias, did) {
|
|
288
288
|
try {
|
|
289
|
-
const response = await axios.post(`${this.API}/
|
|
289
|
+
const response = await axios.post(`${this.API}/aliases`, { alias, did });
|
|
290
290
|
return response.data.ok;
|
|
291
291
|
}
|
|
292
292
|
catch (error) {
|
|
293
293
|
throwError(error);
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
|
-
async
|
|
296
|
+
async getAlias(alias) {
|
|
297
297
|
try {
|
|
298
|
-
const response = await axios.get(`${this.API}/
|
|
298
|
+
const response = await axios.get(`${this.API}/aliases/${alias}`);
|
|
299
299
|
return response.data.did;
|
|
300
300
|
}
|
|
301
301
|
catch (error) {
|
|
302
302
|
throwError(error);
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
|
-
async
|
|
305
|
+
async removeAlias(alias) {
|
|
306
306
|
try {
|
|
307
|
-
const response = await axios.delete(`${this.API}/
|
|
307
|
+
const response = await axios.delete(`${this.API}/aliases/${alias}`);
|
|
308
308
|
return response.data.ok;
|
|
309
309
|
}
|
|
310
310
|
catch (error) {
|
package/dist/cjs/keymaster.cjs
CHANGED
|
@@ -1126,7 +1126,7 @@ class Keymaster {
|
|
|
1126
1126
|
cipher;
|
|
1127
1127
|
defaultRegistry;
|
|
1128
1128
|
ephemeralRegistry;
|
|
1129
|
-
|
|
1129
|
+
maxAliasLength;
|
|
1130
1130
|
maxDataLength;
|
|
1131
1131
|
_walletCache;
|
|
1132
1132
|
_hdkeyCache;
|
|
@@ -1149,7 +1149,7 @@ class Keymaster {
|
|
|
1149
1149
|
this.cipher = options.cipher;
|
|
1150
1150
|
this.defaultRegistry = options.defaultRegistry || 'hyperswarm';
|
|
1151
1151
|
this.ephemeralRegistry = 'hyperswarm';
|
|
1152
|
-
this.
|
|
1152
|
+
this.maxAliasLength = options.maxAliasLength || 32;
|
|
1153
1153
|
this.maxDataLength = 8 * 1024; // 8 KB max data to store in a JSON object
|
|
1154
1154
|
}
|
|
1155
1155
|
async listRegistries() {
|
|
@@ -1181,18 +1181,18 @@ class Keymaster {
|
|
|
1181
1181
|
if (!stored) {
|
|
1182
1182
|
stored = await this.newWallet();
|
|
1183
1183
|
}
|
|
1184
|
-
const
|
|
1185
|
-
this._walletCache = await this.
|
|
1184
|
+
const decrypted = await this.decryptWallet(stored);
|
|
1185
|
+
this._walletCache = await this.upgradeWallet(decrypted);
|
|
1186
1186
|
return this._walletCache;
|
|
1187
1187
|
}
|
|
1188
1188
|
async saveWallet(wallet, overwrite = true) {
|
|
1189
|
-
let upgraded = await this.upgradeWallet(wallet);
|
|
1190
1189
|
// Decrypt if encrypted to verify passphrase and get decrypted form
|
|
1191
|
-
const decrypted = await this.decryptWallet(
|
|
1192
|
-
|
|
1190
|
+
const decrypted = await this.decryptWallet(wallet);
|
|
1191
|
+
const upgraded = await this.upgradeWallet(decrypted);
|
|
1192
|
+
let toStore = await this.encryptWalletForStorage(upgraded);
|
|
1193
1193
|
const ok = await this.db.saveWallet(toStore, overwrite);
|
|
1194
1194
|
if (ok) {
|
|
1195
|
-
this._walletCache =
|
|
1195
|
+
this._walletCache = upgraded;
|
|
1196
1196
|
}
|
|
1197
1197
|
return ok;
|
|
1198
1198
|
}
|
|
@@ -1208,7 +1208,7 @@ class Keymaster {
|
|
|
1208
1208
|
}
|
|
1209
1209
|
const mnemonicEnc = await encryption.encMnemonic(mnemonic, this.passphrase);
|
|
1210
1210
|
const wallet = {
|
|
1211
|
-
version:
|
|
1211
|
+
version: 2,
|
|
1212
1212
|
seed: { mnemonicEnc },
|
|
1213
1213
|
counter: 0,
|
|
1214
1214
|
ids: {}
|
|
@@ -1275,10 +1275,10 @@ class Keymaster {
|
|
|
1275
1275
|
}
|
|
1276
1276
|
}
|
|
1277
1277
|
}
|
|
1278
|
-
if (wallet.
|
|
1279
|
-
for (const
|
|
1278
|
+
if (wallet.aliases) {
|
|
1279
|
+
for (const alias of Object.keys(wallet.aliases)) {
|
|
1280
1280
|
try {
|
|
1281
|
-
const doc = await this.resolveDID(wallet.
|
|
1281
|
+
const doc = await this.resolveDID(wallet.aliases[alias]);
|
|
1282
1282
|
if (doc.didDocumentMetadata?.deactivated) {
|
|
1283
1283
|
deleted += 1;
|
|
1284
1284
|
}
|
|
@@ -1295,7 +1295,7 @@ class Keymaster {
|
|
|
1295
1295
|
let idsRemoved = 0;
|
|
1296
1296
|
let ownedRemoved = 0;
|
|
1297
1297
|
let heldRemoved = 0;
|
|
1298
|
-
let
|
|
1298
|
+
let aliasesRemoved = 0;
|
|
1299
1299
|
await this.mutateWallet(async (wallet) => {
|
|
1300
1300
|
for (const name of Object.keys(wallet.ids)) {
|
|
1301
1301
|
let remove = false;
|
|
@@ -1353,11 +1353,11 @@ class Keymaster {
|
|
|
1353
1353
|
}
|
|
1354
1354
|
}
|
|
1355
1355
|
}
|
|
1356
|
-
if (wallet.
|
|
1357
|
-
for (const
|
|
1356
|
+
if (wallet.aliases) {
|
|
1357
|
+
for (const alias of Object.keys(wallet.aliases)) {
|
|
1358
1358
|
let remove = false;
|
|
1359
1359
|
try {
|
|
1360
|
-
const doc = await this.resolveDID(wallet.
|
|
1360
|
+
const doc = await this.resolveDID(wallet.aliases[alias]);
|
|
1361
1361
|
if (doc.didDocumentMetadata?.deactivated) {
|
|
1362
1362
|
remove = true;
|
|
1363
1363
|
}
|
|
@@ -1366,13 +1366,13 @@ class Keymaster {
|
|
|
1366
1366
|
remove = true;
|
|
1367
1367
|
}
|
|
1368
1368
|
if (remove) {
|
|
1369
|
-
delete wallet.
|
|
1370
|
-
|
|
1369
|
+
delete wallet.aliases[alias];
|
|
1370
|
+
aliasesRemoved++;
|
|
1371
1371
|
}
|
|
1372
1372
|
}
|
|
1373
1373
|
}
|
|
1374
1374
|
});
|
|
1375
|
-
return { idsRemoved, ownedRemoved, heldRemoved,
|
|
1375
|
+
return { idsRemoved, ownedRemoved, heldRemoved, aliasesRemoved };
|
|
1376
1376
|
}
|
|
1377
1377
|
async resolveSeedBank() {
|
|
1378
1378
|
const keypair = await this.hdKeyPair();
|
|
@@ -1502,10 +1502,10 @@ class Keymaster {
|
|
|
1502
1502
|
for (const k in current) {
|
|
1503
1503
|
delete current[k];
|
|
1504
1504
|
}
|
|
1505
|
-
// Upgrade the recovered wallet to the latest version if needed
|
|
1506
|
-
wallet = await this.upgradeWallet(wallet);
|
|
1507
1505
|
// Decrypt the wallet if needed
|
|
1508
1506
|
wallet = db_typeGuards.isWalletEncFile(wallet) ? await this.decryptWalletFromStorage(wallet) : wallet;
|
|
1507
|
+
// Upgrade the recovered wallet to the latest version if needed
|
|
1508
|
+
wallet = await this.upgradeWallet(wallet);
|
|
1509
1509
|
// Copy all properties from the recovered wallet into the cleared current wallet
|
|
1510
1510
|
// This effectively replaces the current wallet with the recovered one
|
|
1511
1511
|
Object.assign(current, wallet);
|
|
@@ -1608,16 +1608,16 @@ class Keymaster {
|
|
|
1608
1608
|
return null;
|
|
1609
1609
|
}
|
|
1610
1610
|
async createAsset(data, options = {}) {
|
|
1611
|
-
let { registry = this.defaultRegistry, controller, validUntil,
|
|
1611
|
+
let { registry = this.defaultRegistry, controller, validUntil, alias } = options;
|
|
1612
1612
|
if (validUntil) {
|
|
1613
1613
|
const validate = new Date(validUntil);
|
|
1614
1614
|
if (isNaN(validate.getTime())) {
|
|
1615
1615
|
throw new InvalidParameterError('options.validUntil');
|
|
1616
1616
|
}
|
|
1617
1617
|
}
|
|
1618
|
-
if (
|
|
1618
|
+
if (alias) {
|
|
1619
1619
|
const wallet = await this.loadWallet();
|
|
1620
|
-
this.
|
|
1620
|
+
this.validateAlias(alias, wallet, 'alias');
|
|
1621
1621
|
}
|
|
1622
1622
|
if (!data) {
|
|
1623
1623
|
throw new InvalidParameterError('data');
|
|
@@ -1644,8 +1644,8 @@ class Keymaster {
|
|
|
1644
1644
|
if (!validUntil) {
|
|
1645
1645
|
await this.addToOwned(did);
|
|
1646
1646
|
}
|
|
1647
|
-
if (
|
|
1648
|
-
await this.
|
|
1647
|
+
if (alias) {
|
|
1648
|
+
await this.addAlias(alias, did);
|
|
1649
1649
|
}
|
|
1650
1650
|
return did;
|
|
1651
1651
|
}
|
|
@@ -1989,8 +1989,8 @@ class Keymaster {
|
|
|
1989
1989
|
throw new InvalidDIDError();
|
|
1990
1990
|
}
|
|
1991
1991
|
const wallet = await this.loadWallet();
|
|
1992
|
-
if (wallet.
|
|
1993
|
-
return wallet.
|
|
1992
|
+
if (wallet.aliases && name in wallet.aliases) {
|
|
1993
|
+
return wallet.aliases[name];
|
|
1994
1994
|
}
|
|
1995
1995
|
if (wallet.ids && name in wallet.ids) {
|
|
1996
1996
|
return wallet.ids[name].did;
|
|
@@ -2080,25 +2080,25 @@ class Keymaster {
|
|
|
2080
2080
|
const id = await this.fetchIdInfo(owner);
|
|
2081
2081
|
return id.owned || [];
|
|
2082
2082
|
}
|
|
2083
|
-
|
|
2084
|
-
if (typeof
|
|
2085
|
-
throw new InvalidParameterError(
|
|
2083
|
+
validateAlias(alias, wallet, label = 'name') {
|
|
2084
|
+
if (typeof alias !== 'string' || !alias.trim()) {
|
|
2085
|
+
throw new InvalidParameterError(`${label} must be a non-empty string`);
|
|
2086
2086
|
}
|
|
2087
|
-
|
|
2088
|
-
if (
|
|
2089
|
-
throw new InvalidParameterError(
|
|
2087
|
+
alias = alias.trim(); // Remove leading/trailing whitespace
|
|
2088
|
+
if (alias.length > this.maxAliasLength) {
|
|
2089
|
+
throw new InvalidParameterError(`${label} too long`);
|
|
2090
2090
|
}
|
|
2091
|
-
if (/[^\P{Cc}]/u.test(
|
|
2092
|
-
throw new InvalidParameterError(
|
|
2091
|
+
if (/[^\P{Cc}]/u.test(alias)) {
|
|
2092
|
+
throw new InvalidParameterError(`${label} contains unprintable characters`);
|
|
2093
2093
|
}
|
|
2094
|
-
const alreadyUsedError =
|
|
2095
|
-
if (wallet && wallet.
|
|
2094
|
+
const alreadyUsedError = `${label} already used`;
|
|
2095
|
+
if (wallet && wallet.aliases && alias in wallet.aliases) {
|
|
2096
2096
|
throw new InvalidParameterError(alreadyUsedError);
|
|
2097
2097
|
}
|
|
2098
|
-
if (wallet && wallet.ids &&
|
|
2098
|
+
if (wallet && wallet.ids && alias in wallet.ids) {
|
|
2099
2099
|
throw new InvalidParameterError(alreadyUsedError);
|
|
2100
2100
|
}
|
|
2101
|
-
return
|
|
2101
|
+
return alias;
|
|
2102
2102
|
}
|
|
2103
2103
|
async createId(name, options = {}) {
|
|
2104
2104
|
let did = '';
|
|
@@ -2116,7 +2116,7 @@ class Keymaster {
|
|
|
2116
2116
|
async createIdOperation(name, account = 0, options = {}) {
|
|
2117
2117
|
const { registry = this.defaultRegistry } = options;
|
|
2118
2118
|
const wallet = await this.loadWallet();
|
|
2119
|
-
name = this.
|
|
2119
|
+
name = this.validateAlias(name, wallet);
|
|
2120
2120
|
const hdkey = await this.getHDKeyFromCacheOrMnemonic(wallet);
|
|
2121
2121
|
const path = `m/44'/0'/${account}'/0/0`;
|
|
2122
2122
|
const didkey = hdkey.derive(path);
|
|
@@ -2162,7 +2162,7 @@ class Keymaster {
|
|
|
2162
2162
|
}
|
|
2163
2163
|
async renameId(id, name) {
|
|
2164
2164
|
await this.mutateWallet((wallet) => {
|
|
2165
|
-
name = this.
|
|
2165
|
+
name = this.validateAlias(name);
|
|
2166
2166
|
if (!(id in wallet.ids)) {
|
|
2167
2167
|
throw new UnknownIDError();
|
|
2168
2168
|
}
|
|
@@ -2271,40 +2271,40 @@ class Keymaster {
|
|
|
2271
2271
|
});
|
|
2272
2272
|
return ok;
|
|
2273
2273
|
}
|
|
2274
|
-
async
|
|
2274
|
+
async listAliases(options = {}) {
|
|
2275
2275
|
const { includeIDs = false } = options;
|
|
2276
2276
|
const wallet = await this.loadWallet();
|
|
2277
|
-
const
|
|
2277
|
+
const aliases = { ...(wallet.aliases || {}) };
|
|
2278
2278
|
if (includeIDs) {
|
|
2279
2279
|
for (const [name, id] of Object.entries(wallet.ids || {})) {
|
|
2280
|
-
|
|
2280
|
+
aliases[name] = id.did;
|
|
2281
2281
|
}
|
|
2282
2282
|
}
|
|
2283
|
-
return
|
|
2283
|
+
return aliases;
|
|
2284
2284
|
}
|
|
2285
|
-
async
|
|
2285
|
+
async addAlias(alias, did) {
|
|
2286
2286
|
await this.mutateWallet((wallet) => {
|
|
2287
|
-
if (!wallet.
|
|
2288
|
-
wallet.
|
|
2287
|
+
if (!wallet.aliases) {
|
|
2288
|
+
wallet.aliases = {};
|
|
2289
2289
|
}
|
|
2290
|
-
|
|
2291
|
-
wallet.
|
|
2290
|
+
alias = this.validateAlias(alias, wallet, 'alias');
|
|
2291
|
+
wallet.aliases[alias] = did;
|
|
2292
2292
|
});
|
|
2293
2293
|
return true;
|
|
2294
2294
|
}
|
|
2295
|
-
async
|
|
2295
|
+
async getAlias(alias) {
|
|
2296
2296
|
const wallet = await this.loadWallet();
|
|
2297
|
-
if (wallet.
|
|
2298
|
-
return wallet.
|
|
2297
|
+
if (wallet.aliases && alias in wallet.aliases) {
|
|
2298
|
+
return wallet.aliases[alias];
|
|
2299
2299
|
}
|
|
2300
2300
|
return null;
|
|
2301
2301
|
}
|
|
2302
|
-
async
|
|
2302
|
+
async removeAlias(alias) {
|
|
2303
2303
|
await this.mutateWallet((wallet) => {
|
|
2304
|
-
if (!wallet.
|
|
2304
|
+
if (!wallet.aliases || !(alias in wallet.aliases)) {
|
|
2305
2305
|
return;
|
|
2306
2306
|
}
|
|
2307
|
-
delete wallet.
|
|
2307
|
+
delete wallet.aliases[alias];
|
|
2308
2308
|
});
|
|
2309
2309
|
return true;
|
|
2310
2310
|
}
|
|
@@ -3378,7 +3378,7 @@ class Keymaster {
|
|
|
3378
3378
|
await this.checkVaultOwner(vaultId);
|
|
3379
3379
|
const vault = await this.getVault(vaultId);
|
|
3380
3380
|
const { privateJwk, items } = await this.decryptVault(vault);
|
|
3381
|
-
const validName = this.
|
|
3381
|
+
const validName = this.validateAlias(name);
|
|
3382
3382
|
const encryptedData = this.cipher.encryptBytes(vault.publicJwk, privateJwk, buffer);
|
|
3383
3383
|
const cid = await this.gatekeeper.addText(encryptedData);
|
|
3384
3384
|
const sha256 = this.cipher.hashMessage(buffer);
|
|
@@ -3428,7 +3428,7 @@ class Keymaster {
|
|
|
3428
3428
|
const id = await this.fetchIdInfo(undefined, wallet);
|
|
3429
3429
|
const list = id.dmail || {};
|
|
3430
3430
|
const dmailList = {};
|
|
3431
|
-
const nameList = await this.
|
|
3431
|
+
const nameList = await this.listAliases({ includeIDs: true });
|
|
3432
3432
|
const didToName = Object.entries(nameList).reduce((acc, [name, did]) => {
|
|
3433
3433
|
acc[did] = name;
|
|
3434
3434
|
return acc;
|
|
@@ -3466,7 +3466,7 @@ class Keymaster {
|
|
|
3466
3466
|
const tagSet = new Set();
|
|
3467
3467
|
for (const tag of tags) {
|
|
3468
3468
|
try {
|
|
3469
|
-
tagSet.add(this.
|
|
3469
|
+
tagSet.add(this.validateAlias(tag));
|
|
3470
3470
|
}
|
|
3471
3471
|
catch (error) {
|
|
3472
3472
|
throw new InvalidParameterError(`Invalid tag: '${tag}'`);
|
|
@@ -3499,7 +3499,7 @@ class Keymaster {
|
|
|
3499
3499
|
if (!Array.isArray(list)) {
|
|
3500
3500
|
throw new InvalidParameterError('list');
|
|
3501
3501
|
}
|
|
3502
|
-
const nameList = await this.
|
|
3502
|
+
const nameList = await this.listAliases({ includeIDs: true });
|
|
3503
3503
|
let newList = [];
|
|
3504
3504
|
for (const id of list) {
|
|
3505
3505
|
if (typeof id !== 'string') {
|
|
@@ -3702,9 +3702,9 @@ class Keymaster {
|
|
|
3702
3702
|
}
|
|
3703
3703
|
const poll = await this.getPoll(noticeDID);
|
|
3704
3704
|
if (poll) {
|
|
3705
|
-
const names = await this.
|
|
3705
|
+
const names = await this.listAliases();
|
|
3706
3706
|
if (!Object.values(names).includes(noticeDID)) {
|
|
3707
|
-
await this.
|
|
3707
|
+
await this.addUnaliasedPoll(noticeDID);
|
|
3708
3708
|
}
|
|
3709
3709
|
await this.addToNotices(did, [exports.NoticeTags.POLL]);
|
|
3710
3710
|
continue;
|
|
@@ -3788,10 +3788,10 @@ class Keymaster {
|
|
|
3788
3788
|
}
|
|
3789
3789
|
return payload && typeof payload.poll === "string" && typeof payload.vote === "number";
|
|
3790
3790
|
}
|
|
3791
|
-
async
|
|
3791
|
+
async addUnaliasedPoll(did) {
|
|
3792
3792
|
const fallbackName = did.slice(-32);
|
|
3793
3793
|
try {
|
|
3794
|
-
await this.
|
|
3794
|
+
await this.addAlias(fallbackName, did);
|
|
3795
3795
|
}
|
|
3796
3796
|
catch { }
|
|
3797
3797
|
}
|
|
@@ -3841,7 +3841,14 @@ class Keymaster {
|
|
|
3841
3841
|
return wallet;
|
|
3842
3842
|
}
|
|
3843
3843
|
async upgradeWallet(wallet) {
|
|
3844
|
-
if (wallet.version
|
|
3844
|
+
if (wallet.version === 1) {
|
|
3845
|
+
if (wallet.names && !wallet.aliases) {
|
|
3846
|
+
wallet.aliases = wallet.names;
|
|
3847
|
+
delete wallet.names;
|
|
3848
|
+
}
|
|
3849
|
+
wallet.version = 2;
|
|
3850
|
+
}
|
|
3851
|
+
if (wallet.version !== 2) {
|
|
3845
3852
|
throw new KeymasterError("Unsupported wallet version.");
|
|
3846
3853
|
}
|
|
3847
3854
|
return wallet;
|