@verii/metadata-registration 1.1.0-pre.1765263230 → 1.1.0-pre.1765351552

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verii/metadata-registration",
3
- "version": "1.1.0-pre.1765263230",
3
+ "version": "1.1.0-pre.1765351552",
4
4
  "description": "Package allows interacting with the smart contracts, based on ethers.js",
5
5
  "repository": "https://github.com/LFDT-Verii/core",
6
6
  "main": "./index.js",
@@ -17,19 +17,19 @@
17
17
  "lint:fix": "eslint --fix --ext .js ."
18
18
  },
19
19
  "dependencies": {
20
- "@verii/base-contract-io": "1.1.0-pre.1765263230",
21
- "@verii/blockchain-functions": "1.1.0-pre.1765263230",
22
- "@verii/common-functions": "1.1.0-pre.1765263230",
23
- "@verii/contract-permissions": "1.1.0-pre.1765263230",
24
- "@verii/cose-key": "1.1.0-pre.1765263230",
25
- "@verii/crypto": "1.1.0-pre.1765263230",
26
- "@verii/jwt": "1.1.0-pre.1765263230",
20
+ "@verii/base-contract-io": "1.1.0-pre.1765351552",
21
+ "@verii/blockchain-functions": "1.1.0-pre.1765351552",
22
+ "@verii/common-functions": "1.1.0-pre.1765351552",
23
+ "@verii/contract-permissions": "1.1.0-pre.1765351552",
24
+ "@verii/cose-key": "1.1.0-pre.1765351552",
25
+ "@verii/crypto": "1.1.0-pre.1765351552",
26
+ "@verii/jwt": "1.1.0-pre.1765351552",
27
27
  "eth-url-parser": "1.0.4",
28
28
  "lodash": "4.17.21"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@spencejs/spence-config": "0.10.2",
32
- "@verii/tests-helpers": "1.1.0-pre.1765263230",
32
+ "@verii/tests-helpers": "1.1.0-pre.1765351552",
33
33
  "date-fns": "4.1.0",
34
34
  "expect": "30.2.0",
35
35
  "nanoid": "5.1.6"
@@ -39,5 +39,5 @@
39
39
  "lib"
40
40
  ]
41
41
  },
42
- "gitHead": "c30da923ffb992d60a2a42d26be030755533d1ee"
42
+ "gitHead": "6a7ce7a831716e1159ac237d5a5566b2833b1d24"
43
43
  }
@@ -245,8 +245,7 @@ const initMetadataRegistry = async (
245
245
 
246
246
  const multiToken = ':multi:';
247
247
  if (did.indexOf(multiToken) === -1) {
248
- const [, , , accountId, listId, index, contentHash] = did.split(':');
249
- return [{ accountId, listId, index, contentHash }];
248
+ return [parseSingleVelocityDid(did)];
250
249
  }
251
250
 
252
251
  const [, entriesPart] = did.split(multiToken);
@@ -255,6 +254,10 @@ const initMetadataRegistry = async (
255
254
  return { accountId, listId, index, contentHash };
256
255
  }, entriesPart.split(';'));
257
256
  };
257
+ const parseSingleVelocityDid = (did) => {
258
+ const [, , , accountId, listId, index, contentHash] = did.split(':');
259
+ return { accountId, listId, index, contentHash };
260
+ };
258
261
 
259
262
  const resolvePublicKey = async ({ id, entry, secret }) => {
260
263
  log.info({ id, entry, secret }, 'resolvePublicKey');
@@ -367,8 +370,14 @@ const initMetadataRegistry = async (
367
370
 
368
371
  const credentialEntries = await Promise.all(
369
372
  mapWithIndex(async (entry, i) => {
370
- const id = toDID(indexEntries[i]).toLowerCase();
371
- const credential = find((c) => c.id.toLowerCase() === id, credentials);
373
+ const credential = find((c) => {
374
+ const credentialIndexEntry = parseSingleVelocityDid(c.id);
375
+ return (
376
+ credentialIndexEntry.accountId === indexEntries[i].accountId &&
377
+ credentialIndexEntry.listId === indexEntries[i].listId &&
378
+ credentialIndexEntry.index === indexEntries[i].index
379
+ );
380
+ }, credentials);
372
381
  const secret =
373
382
  indexEntries[i].contentHash != null
374
383
  ? await deriveEncryptionSecretFromPassword(
@@ -377,7 +386,7 @@ const initMetadataRegistry = async (
377
386
  : await deriveEncryptionSecret(credential);
378
387
  return {
379
388
  entry,
380
- id,
389
+ id: credential.id,
381
390
  credentialType: credential.credentialType,
382
391
  secret,
383
392
  };
@@ -447,14 +456,6 @@ const initMetadataRegistry = async (
447
456
  return tx.wait();
448
457
  };
449
458
 
450
- const toDID = ({ accountId, listId, index, contentHash }) => {
451
- if (contentHash != null) {
452
- return `did:velocity:v2:${accountId}:${listId}:${index}:${contentHash}`;
453
- }
454
-
455
- return `did:velocity:v2:${accountId}:${listId}:${index}`;
456
- };
457
-
458
459
  const pullCreatedMetadataListEvents = pullEvents('CreatedMetadataList');
459
460
 
460
461
  const pullAddedCredentialMetadataEvents = pullEvents(