@didtools/pkh-ethereum
Advanced tools
Comparing version 0.4.2-next.0 to 0.5.0
@@ -25,2 +25,5 @@ import { Cacao, SiweMessage } from '@didtools/cacao'; | ||
} | ||
/** | ||
* Get a configured authMethod for an Ethereum account in a web based environment | ||
*/ // eslint-disable-next-line @typescript-eslint/require-await | ||
EthereumWebAuth.getAuthMethod = getAuthMethod; | ||
@@ -37,2 +40,5 @@ })(EthereumWebAuth || (EthereumWebAuth = {})); | ||
} | ||
/** | ||
* Get a configured authMethod for an Ethereum account in a Node based environment | ||
*/ // eslint-disable-next-line @typescript-eslint/require-await | ||
EthereumNodeAuth.getAuthMethod = getAuthMethod; | ||
@@ -39,0 +45,0 @@ })(EthereumNodeAuth || (EthereumNodeAuth = {})); |
@@ -32,14 +32,16 @@ import { SiweMessage, asLegacyChainIdString, verifyTimeChecks, assertSigned } from '@didtools/cacao'; | ||
verifyTimeChecks(cacao, options); | ||
const recoveredAddress = verifyMessage(SiweMessage.fromCacao(cacao).toMessage(), cacao.s.s); | ||
const recoveredAddresses = [ | ||
recoveredAddress | ||
]; | ||
if (Date.parse(cacao.p.iat) <= LEGACY_CHAIN_ID_REORG_DATE) { | ||
const legacyChainIdRecoveredAddress = verifyMessage(asLegacyChainIdString(SiweMessage.fromCacao(cacao), 'Ethereum'), cacao.s.s); | ||
recoveredAddresses.push(legacyChainIdRecoveredAddress); | ||
const issuer = AccountId.parse(cacao.p.iss.replace('did:pkh:', '')).address.toLowerCase(); | ||
// assume the message doesn't use eip55 for the ethereum address | ||
let recovered = verifyMessage(SiweMessage.fromCacao(cacao).toMessage(), cacao.s.s); | ||
if (recovered !== issuer) { | ||
// try to verify signature using eip55 address | ||
recovered = verifyMessage(SiweMessage.fromCacao(cacao).toMessageEip55(), cacao.s.s); | ||
} | ||
const issuerAddress = AccountId.parse(cacao.p.iss.replace('did:pkh:', '')).address.toLowerCase(); | ||
if (!recoveredAddresses.includes(issuerAddress)) { | ||
if (recovered !== issuer && Date.parse(cacao.p.iat) <= LEGACY_CHAIN_ID_REORG_DATE) { | ||
// might be an old CACAOv1 format | ||
recovered = verifyMessage(asLegacyChainIdString(SiweMessage.fromCacao(cacao), 'Ethereum'), cacao.s.s); | ||
} | ||
if (recovered !== issuer) { | ||
throw new Error(`Signature does not belong to issuer`); | ||
} | ||
} |
{ | ||
"name": "@didtools/pkh-ethereum", | ||
"version": "0.4.2-next.0", | ||
"version": "0.5.0", | ||
"author": "3Box Labs", | ||
@@ -34,8 +34,8 @@ "license": "(Apache-2.0 OR MIT)", | ||
"devDependencies": { | ||
"typescript": "^5.0.4" | ||
"typescript": "^5.3.2" | ||
}, | ||
"dependencies": { | ||
"@didtools/cacao": "^2.1.1-next.0", | ||
"@noble/hashes": "^1.3.1", | ||
"@noble/curves": "^1.1.0", | ||
"@didtools/cacao": "^3.0.0", | ||
"@noble/curves": "^1.2.0", | ||
"@noble/hashes": "^1.3.2", | ||
"@stablelib/random": "^1.0.2", | ||
@@ -42,0 +42,0 @@ "caip": "^1.1.0" |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
20840
426
1
+ Added@adraffy/ens-normalize@1.10.0(transitive)
+ Added@didtools/cacao@3.0.1(transitive)
+ Added@didtools/codecs@3.0.0(transitive)
+ Added@didtools/siwx@2.0.0(transitive)
+ Added@noble/curves@1.2.0(transitive)
+ Added@noble/hashes@1.3.21.3.3(transitive)
+ Added@scure/base@1.1.9(transitive)
+ Added@scure/bip32@1.3.2(transitive)
+ Added@scure/bip39@1.2.1(transitive)
+ Addedabitype@0.9.8(transitive)
+ Addedisows@1.0.3(transitive)
+ Addeduint8arrays@5.1.0(transitive)
+ Addedviem@1.21.4(transitive)
+ Addedws@8.13.0(transitive)
- Removed@didtools/cacao@2.1.1-next.0(transitive)
- Removed@didtools/codecs@1.0.2-next.0(transitive)
- Removed@didtools/siwx@1.0.1-next.0(transitive)
- Removedmultiformats@11.0.212.1.3(transitive)
- Removeduint8arrays@4.0.10(transitive)
Updated@didtools/cacao@^3.0.0
Updated@noble/curves@^1.2.0
Updated@noble/hashes@^1.3.2