Skip to content

Commit

Permalink
chore: bump resolver versions
Browse files Browse the repository at this point in the history
  • Loading branch information
zixiang2018 committed Dec 27, 2023
1 parent 2fd078f commit 8dcb315
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 52 deletions.
62 changes: 22 additions & 40 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
"@govtechsg/token-registry": "^4.1.7",
"axios": "^1.6.2",
"debug": "^4.3.1",
"did-resolver": "^3.1.0",
"did-resolver": "^4.1.0",
"ethers": "^5.7.2",
"ethr-did-resolver": "^4.3.3",
"ethr-did-resolver": "^8.1.2",
"node-cache": "^5.1.2",
"runtypes": "^6.3.0",
"web-did-resolver": "^2.0.4"
"web-did-resolver": "^2.0.27"
},
"devDependencies": {
"@commitlint/cli": "^18.4.3",
Expand Down
7 changes: 2 additions & 5 deletions src/did/resolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,15 @@ import { Resolver } from "did-resolver";
import { getResolver } from "ethr-did-resolver";

const didDoc = {
"@context": [
"https://www.w3.org/ns/did/v1",
"https://identity.foundation/EcdsaSecp256k1RecoverySignature2020/lds-ecdsa-secp256k1-recovery2020-0.0.jsonld",
],
"@context": ["https://www.w3.org/ns/did/v1", "https://w3id.org/security/suites/secp256k1recovery-2020/v2"],
assertionMethod: ["did:ethr:sepolia:0x0cE1854a3836daF9130028Cf90D6d35B1Ae46457#controller"],
id: "did:ethr:sepolia:0x0cE1854a3836daF9130028Cf90D6d35B1Ae46457",
verificationMethod: [
{
id: "did:ethr:sepolia:0x0cE1854a3836daF9130028Cf90D6d35B1Ae46457#controller",
type: "EcdsaSecp256k1RecoveryMethod2020",
controller: "did:ethr:sepolia:0x0cE1854a3836daF9130028Cf90D6d35B1Ae46457",
blockchainAccountId: "0x0cE1854a3836daF9130028Cf90D6d35B1Ae46457@eip155:11155111",
blockchainAccountId: "eip155:11155111:0x0cE1854a3836daF9130028Cf90D6d35B1Ae46457",
},
],
authentication: ["did:ethr:sepolia:0x0cE1854a3836daF9130028Cf90D6d35B1Ae46457#controller"],
Expand Down
4 changes: 2 additions & 2 deletions src/did/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ const didResolutionCache = new NodeCache({ stdTTL: 5 * 60 }); // 5 min
const defaultResolver = new Resolver({
...ethrGetResolver(getProviderConfig()),
...webGetResolver(),
} as ResolverRegistry);
});

export const createResolver = ({ ethrResolverConfig }: { ethrResolverConfig?: EthrResolverConfig }): Resolver => {
return ethrResolverConfig
? new Resolver({ ...ethrGetResolver(ethrResolverConfig), ...webGetResolver() } as ResolverRegistry)
? new Resolver({ ...ethrGetResolver(ethrResolverConfig), ...webGetResolver() })
: defaultResolver;
};

Expand Down
4 changes: 2 additions & 2 deletions src/did/verifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ export const verifySecp256k1VerificationKey2018 = ({
},
};
}
// blockchainAccountId looks like 0x0cE1854a3836daF9130028Cf90D6d35B1Ae46457@eip155:3, let's get rid of the part after @, @ included
const ethereumAddress = blockchainAccountId.split("@")[0];
// blockchainAccountId looks like eip155:3:0x0cE1854a3836daF9130028Cf90D6d35B1Ae46457, let's only extract out the ethereum address
const ethereumAddress = blockchainAccountId.split(":").pop() || "";

const merkleRootSigned = utils.verifyMessage(messageBytes, signature).toLowerCase() === ethereumAddress.toLowerCase();
if (!merkleRootSigned) {
Expand Down

0 comments on commit 8dcb315

Please sign in to comment.