@veramo/utils
Advanced tools
Comparing version 5.4.2-next.21 to 5.4.2-unstable.23
import { asArray, isDefined } from './type-utils.js'; | ||
import { decodeJWT } from 'did-jwt'; | ||
import { normalizeCredential, normalizePresentation } from 'did-jwt-vc'; | ||
import { blake2b } from '@noble/hashes/blake2b'; | ||
import { bytesToHex } from './encodings.js'; | ||
import { sha256 } from 'multiformats/hashes/sha2'; | ||
import { code, encode, prepare } from '@ipld/dag-pb'; | ||
import { CID } from 'multiformats/cid'; | ||
import { UnixFS } from 'ipfs-unixfs'; | ||
/** | ||
@@ -81,3 +83,11 @@ * Every Verifiable Credential `@context` property must contain this. | ||
} | ||
return bytesToHex(blake2b(hashable)); | ||
const unixfs = new UnixFS({ | ||
type: 'file', | ||
data: new TextEncoder().encode(hashable) | ||
}); | ||
const bytes = encode(prepare({ Data: unixfs.marshal() })); | ||
const multihash = sha256.digest(bytes); | ||
//@ts-ignore | ||
const cid = CID.create(0, code, multihash).toString(); | ||
return cid; | ||
} | ||
@@ -84,0 +94,0 @@ /** |
{ | ||
"name": "@veramo/utils", | ||
"description": "Helper methods for Veramo plugins", | ||
"version": "5.4.2-next.21+e8c270f01", | ||
"version": "5.4.2-unstable.23+229e8cad1", | ||
"main": "build/index.js", | ||
@@ -15,5 +15,5 @@ "exports": "./build/index.js", | ||
"@ethersproject/transactions": "^5.7.0", | ||
"@ipld/dag-pb": "^4.0.5", | ||
"@noble/curves": "^1.1.0", | ||
"@noble/hashes": "^1.3.1", | ||
"@veramo/core-types": "^5.4.2-next.21+e8c270f01", | ||
"@veramo/core-types": "^5.4.2-unstable.23+229e8cad1", | ||
"credential-status": "^2.0.5", | ||
@@ -25,2 +25,3 @@ "cross-fetch": "^4.0.0", | ||
"did-resolver": "^4.1.0", | ||
"ipfs-unixfs": "^11.1.0", | ||
"multiformats": "^12.0.1", | ||
@@ -51,3 +52,3 @@ "uint8arrays": "^4.0.6" | ||
], | ||
"gitHead": "e8c270f01d0e82d62489b444a3ce22442ad6ca0f" | ||
"gitHead": "229e8cad1c1fb263226c80cc8b3a1c0f064f2ed4" | ||
} |
@@ -184,3 +184,3 @@ import { | ||
expect(computeEntryHash(serializedCred)).toEqual( | ||
'452f0fb4b876e22867585ee15a6aabb7a6f9ccccf6a2ee664e9f7618737792d64b219fef0792b9d73f3ff756a265083526ecb7313ae4972ef6290b600cacbe88', | ||
'QmYBWeZCoB1zbJwGou1svfgrq9muVQyy7uzokMfdeSEoHH', | ||
) | ||
@@ -212,3 +212,3 @@ }) | ||
expect(computeEntryHash(serializedCred)).toEqual( | ||
'357436ca94682f2872b26c35a64d52c8e12dfbf86561a8f219cb395482f5978758fb577c927874cdb01189853054433a07eca81a4b3a999be12290021eb9bcbb', | ||
'QmYeBhqpqiFUcsTS1qz7tkuVCJq8Z4VrrSJsjJc4Q7k9ig', | ||
) | ||
@@ -215,0 +215,0 @@ }) |
@@ -14,5 +14,6 @@ import { asArray, isDefined } from './type-utils.js' | ||
import { normalizeCredential, normalizePresentation } from 'did-jwt-vc' | ||
import { blake2b } from '@noble/hashes/blake2b' | ||
import { bytesToHex } from './encodings.js' | ||
import { sha256 } from 'multiformats/hashes/sha2' | ||
import { code, encode, prepare } from '@ipld/dag-pb' | ||
import { CID } from 'multiformats/cid' | ||
import { UnixFS } from 'ipfs-unixfs' | ||
/** | ||
@@ -100,3 +101,14 @@ * Every Verifiable Credential `@context` property must contain this. | ||
} | ||
return bytesToHex(blake2b(hashable)) | ||
const unixfs = new UnixFS({ | ||
type: 'file', | ||
data: new TextEncoder().encode(hashable) | ||
}) | ||
const bytes = encode(prepare({ Data: unixfs.marshal() })) | ||
const multihash = sha256.digest(bytes) | ||
//@ts-ignore | ||
const cid = CID.create(0, code, multihash).toString() | ||
return cid | ||
} | ||
@@ -103,0 +115,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
134490
2486
14
+ Added@ipld/dag-pb@^4.0.5
+ Addedipfs-unixfs@^11.1.0
+ Added@ipld/dag-pb@4.1.3(transitive)
+ Addedipfs-unixfs@11.2.0(transitive)
+ Addedmultiformats@13.3.1(transitive)
+ Addedprotons-runtime@5.5.0(transitive)
+ Addeduint8-varint@2.0.4(transitive)
+ Addeduint8arraylist@2.4.8(transitive)
+ Addeduint8arrays@5.1.0(transitive)
- Removed@noble/hashes@^1.3.1