Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update package dnsprove #24

Merged
merged 6 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
INFURA_API_KEY=
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ dist/
*.iml
.DS_Store
coverage
.env
8 changes: 4 additions & 4 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"license": "Apache-2.0",
"dependencies": {
"@govtechsg/oa-did-sign": "^2.2.0",
"@tradetrust-tt/dnsprove": "^2.12.2",
"@tradetrust-tt/dnsprove": "^2.12.3",
"@tradetrust-tt/document-store": "^2.7.0",
"@tradetrust-tt/token-registry": "^4.9.0",
"@tradetrust-tt/tradetrust": "^6.9.0",
Expand Down
43 changes: 21 additions & 22 deletions src/did/resolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ const didDoc = {
"https://www.w3.org/ns/did/v1",
"https://identity.foundation/EcdsaSecp256k1RecoverySignature2020/lds-ecdsa-secp256k1-recovery2020-0.0.jsonld",
],
assertionMethod: ["did:ethr:goerli:0x0cE1854a3836daF9130028Cf90D6d35B1Ae46457#controller"],
id: "did:ethr:goerli:0x0cE1854a3836daF9130028Cf90D6d35B1Ae46457",
assertionMethod: ["did:ethr:0x1245e5B64D785b25057f7438F715f4aA5D965733#controller"],
id: "did:ethr:0x1245e5B64D785b25057f7438F715f4aA5D965733",
verificationMethod: [
{
id: "did:ethr:goerli:0x0cE1854a3836daF9130028Cf90D6d35B1Ae46457#controller",
id: "did:ethr:0x1245e5B64D785b25057f7438F715f4aA5D965733#controller",
type: "EcdsaSecp256k1RecoveryMethod2020",
controller: "did:ethr:goerli:0x0cE1854a3836daF9130028Cf90D6d35B1Ae46457",
blockchainAccountId: "0x0cE1854a3836daF9130028Cf90D6d35B1Ae46457@eip155:5",
controller: "did:ethr:0x1245e5B64D785b25057f7438F715f4aA5D965733",
blockchainAccountId: "0x1245e5B64D785b25057f7438F715f4aA5D965733@eip155:1",
},
],
authentication: ["did:ethr:goerli:0x0cE1854a3836daF9130028Cf90D6d35B1Ae46457#controller"],
authentication: ["did:ethr:0x1245e5B64D785b25057f7438F715f4aA5D965733#controller"],
};

// this document has been created using:
Expand All @@ -37,7 +37,7 @@ const v3DidSigned = {
],
issuanceDate: "2010-01-01T19:23:24Z",
issuer: {
id: "did:ethr:goerli:0x0cE1854a3836daF9130028Cf90D6d35B1Ae46457",
id: "did:ethr:0x7020be74e640afa14430f2c807f511b1559c5f60",
name: "anyway",
},
type: ["VerifiableCredential", "Name"],
Expand All @@ -49,43 +49,41 @@ const v3DidSigned = {
proof: {
type: "OpenAttestationProofMethod",
method: "DID",
value: "did:ethr:goerli:0x0cE1854a3836daF9130028Cf90D6d35B1Ae46457",
value: "did:ethr:0x7020be74e640afa14430f2c807f511b1559c5f60",
revocation: {
type: "NONE",
},
},
identityProof: {
type: "DID",
identifier: "did:ethr:goerli:0x0cE1854a3836daF9130028Cf90D6d35B1Ae46457",
identifier: "did:ethr:0x7020be74e640afa14430f2c807f511b1559c5f60",
},
},
proof: {
type: "OpenAttestationMerkleProofSignature2018",
proofPurpose: "assertionMethod",
targetHash: "b87e09cfd45082d277d3f29957aead552836c0c8ea9744958c05c8554751c9d1",
targetHash: "f01721bd6688499e63b596a76456067a762bd09da8c565e9ff4fd476250946fc",
proofs: [],
merkleRoot: "b87e09cfd45082d277d3f29957aead552836c0c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WV0YWRhdGEucHJvb2YudHlwZSJ9LHsidmFsdWUiOiIzMWQyNjRmOTYwNGRiN2QxYjc4YWI1MDhkMjcwZDgzZjhmMWIxN2I3MmMwODg2YmY1MmZhZjdlYjBhYzQ4ZGUyIiwicGF0aCI6Im9wZW5BdHRlc3RhdGlvbk1ldGFkYXRhLnByb29mLm1ldGhvZCJ9LHsidmFsdWUiOiI5NWZkZDY4Zjc5ZTg2YTJkNjU3YjFjMDBjYTM5MjhlMWEzZGQ4MWY2ZWQxMDkxMjI0N2RmN2IyODc2ZTBkOTJlIiwicGF0aCI6Im9wZW5BdHRlc3RhdGlvbk1ldGFkYXRhLnByb29mLnZhbHVlIn0seyJ2YWx1ZSI6IjIyYTM0YWM2YmNiZTM0ZmE4YjY3N2VhMzBhMGUyMzQzZmVjNDdlZDQ4ZGNiNjA1NTE5M2FiNDAwNWM5MmExZWIiLCJwYXRoIjoib3BlbkF0dGVzdGF0aW9uTWV0YWRhdGEucHJvb2YucmV2b2NhdGlvbi50eXBlIn0seyJ2YWx1ZSI6IjA1M2ExYmMwNzZlNzVjNTE4NzMyYmJkNzJlYzI3MmJiYzk5ODkyOGNjYWY2Y2UzYzkxZmIzY2I2MWUxYzQ3ZjYiLCJwYXRoIjoib3BlbkF0dGVzdGF0aW9uTWV0YWRhdGEuaWRlbnRpdHlQcm9vZi50eXBlIn0seyJ2YWx1ZSI6ImQzYTY4NDQzODQzYWJlOGRhZDczNmVjZWFjODQyMWYzMWRlMzY1ODkyMTljYjc4ZDE5ZmM1NTI3NDM4ZWE4MmMiLCJwYXRoIjoib3BlbkF0dGVzdGF0aW9uTWV0YWRhdGEuaWRlbnRpdHlQcm9vZi5pZGVudGlmaWVyIn1d",
privacy: {
obfuscated: [],
},
key: "did:ethr:goerli:0x0cE1854a3836daF9130028Cf90D6d35B1Ae46457#controller",
key: "did:ethr:0x7020be74e640afa14430f2c807f511b1559c5f60#controller",
signature:
"0x7ffae45f4527cafa40866736ddeda7941ce46ce4b5395c0cb8c5064064f2aa624a1e062579cdc42e51b1e65f2f9eddd6634219047d3fc449a72e097181a920b31b",
"0x1333ef14a32405c1e0c7f0e0926b06e0872bfcc4050b4a28668ffcee29144ef11f5bea1002e09503d7ca773226b1064bcd9e9a2f1688fe389b995ceaa3339b6f1b",
},
} as v3.SignedWrappedDocument;

const customConfig: EthrResolverConfig = {
networks: [{ name: "goerli", rpcUrl: `https://goerli.infura.io/v3/${INFURA_API_KEY}` }],
networks: [{ name: "mainnet", rpcUrl: `https://mainnet.infura.io/v3/${INFURA_API_KEY}` }],
};

describe("custom resolver", () => {
it("should resolve did using resolver", async () => {
const did = await resolve(
"did:ethr:goerli:0x0cE1854a3836daF9130028Cf90D6d35B1Ae46457",
createResolver({ ethrResolverConfig: customConfig })
);
const resolver = createResolver({ ethrResolverConfig: customConfig });
const did = await resolve("did:ethr:0x1245e5B64D785b25057f7438F715f4aA5D965733", resolver);
expect(did).toEqual(didDoc);
});

Expand All @@ -95,10 +93,11 @@ describe("custom resolver", () => {
resolver: createResolver({ ethrResolverConfig: customConfig }),
});
const fragment = await verify(v3DidSigned);
expect(fragment[0].status).toBe("VALID");
expect(fragment[0]).toMatchInlineSnapshot(`
Object {
"data": Object {
"did": "did:ethr:goerli:0x0cE1854a3836daF9130028Cf90D6d35B1Ae46457",
"did": "did:ethr:0x7020be74e640afa14430f2c807f511b1559c5f60",
"verified": true,
},
"name": "OpenAttestationDidIdentityProof",
Expand Down Expand Up @@ -137,10 +136,10 @@ describe("getProviderConfig", () => {

it("should set default when provider type is jsonrpc", () => {
process.env.PROVIDER_ENDPOINT_TYPE = "jsonrpc";
process.env.PROVIDER_NETWORK = "goerli";
process.env.PROVIDER_NETWORK = "mainnet";

expect(getProviderConfig()).toEqual({
networks: [{ name: "mainnet", rpcUrl: "https://mainnet.infura.io/v3/bb46da3f80e040e8ab73c0a9ff365d18" }],
networks: [{ name: "mainnet", rpcUrl: `https://mainnet.infura.io/v3/${INFURA_API_KEY}` }],
});
});

Expand Down
Loading