Skip to content

Commit b030997

Browse files
committed
refactor(org.id-resolver): added support for the new blockchainAccountId format
1 parent 38b9f1f commit b030997

File tree

5 files changed

+319
-463
lines changed

5 files changed

+319
-463
lines changed

packages/resolver/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
"url": "git+ssh://[email protected]:windingtree/org.id-resolver.git"
3333
},
3434
"dependencies": {
35-
"@windingtree/org.id": "3.0.0-beta.6",
36-
"@windingtree/org.id-auth": "1.0.0-beta.32",
37-
"@windingtree/org.id-core": "1.0.0-beta.32",
38-
"@windingtree/org.id-utils": "1.0.0-beta.32",
35+
"@windingtree/org.id": "^3.0.0-beta.6",
36+
"@windingtree/org.id-auth": "^1.0.0-beta.45",
37+
"@windingtree/org.id-core": "^1.0.0-beta.45",
38+
"@windingtree/org.id-utils": "^1.0.0-beta.45",
3939
"@windingtree/org.json-schema": "1.0.1",
4040
"ethers": "5.5.3",
4141
"luxon": "2.3.0"

packages/resolver/src/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -625,23 +625,23 @@ export const OrgIdResolver = (options: ResolverOptions): OrgIdResolverAPI => {
625625
}
626626

627627
const {
628-
accountId,
628+
accountAddress,
629629
blockchainType,
630-
blockchainId
630+
chainId
631631
} = parseBlockchainAccountId(orgJsonVerificationMethod.blockchainAccountId);
632632

633-
if (accountId !== orgIdOwner) {
633+
if (accountAddress !== orgIdOwner) {
634634
throw new Error(
635-
`Verification method blockchain account Id "${orgIdOwner}" is expected but found "${accountId}" in the VC proof`
635+
`Verification method blockchain account Id "${orgIdOwner}" is expected but found "${accountAddress}" in the VC proof`
636636
);
637637
}
638638

639639
if (
640640
blockchainType !== selectedChain.config.blockchainType ||
641-
blockchainId !== selectedChain.config.blockchainId
641+
chainId !== selectedChain.config.blockchainId
642642
) {
643643
throw new Error(
644-
`Verification method blockchain type "${selectedChain.config.blockchainType}" and Id "${selectedChain.config.blockchainId}" are expected but found "${blockchainType}" and "${blockchainId}" in the VC proof`
644+
`Verification method blockchain type "${selectedChain.config.blockchainType}" and Id "${selectedChain.config.blockchainId}" are expected but found "${blockchainType}" and "${chainId}" in the VC proof`
645645
);
646646
}
647647

packages/resolver/test/fixtures/org.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"id": "did:orgid:4:0x9300bad07f0b9d904b23781e8bbb05c1219530c51e7e494701db2539b7a5a119#key-1",
2424
"controller": "did:orgid:4:0x9300bad07f0b9d904b23781e8bbb05c1219530c51e7e494701db2539b7a5a119",
2525
"type": "EcdsaSecp256k1RecoveryMethod2020",
26-
"blockchainAccountId": "0xBfD9EebE27d5a2F1113220b53844E5066889035C@eip155:1337"
26+
"blockchainAccountId": "eip155:1337:0xBfD9EebE27d5a2F1113220b53844E5066889035C"
2727
}
2828
],
2929
"service": [],

packages/resolver/test/fixtures/resolver.spec.ts renamed to packages/resolver/test/resolver.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type {
1010
FetcherConfig,
1111
OrgIdResolverAPI,
1212
ResolverOptions
13-
} from '../../src';
13+
} from '../src';
1414
import { orgIdSetup } from '@windingtree/org.id-test-setup';
1515
import {
1616
generateSalt,
@@ -22,7 +22,7 @@ import {
2222
buildHttpFetcherConfig,
2323
parseDid,
2424
parseUri
25-
} from '../../src';
25+
} from '../src';
2626
import chai, { expect } from 'chai';
2727
import chp from 'chai-as-promised';
2828
chai.use(chp);
@@ -250,7 +250,7 @@ describe('ORGiD DID Resolver', () => {
250250
"id": "did:orgid:1337:0x2389deb1e582b49ab388c7ebc16b49e5a95e0b8c92ffa9c74881a9904074de9a#key-100",
251251
"controller": "did:orgid:1337:0x2389deb1e582b49ab388c7ebc16b49e5a95e0b8c92ffa9c74881a9904074de9a",
252252
"type": "EcdsaSecp256k1RecoveryMethod2020",
253-
"blockchainAccountId": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266@eip155:1337"
253+
"blockchainAccountId": "eip155:1337:0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
254254
}
255255
]
256256
};
@@ -316,7 +316,7 @@ describe('ORGiD DID Resolver', () => {
316316
"id": `did:orgid:1337:${orgIdHash}#key-111`,
317317
"controller": `did:orgid:1337:${orgIdHash}`,
318318
"type": "EcdsaSecp256k1RecoveryMethod2020",
319-
"blockchainAccountId": `${ownerAddress}@${invalidBlockchainType}:1337`
319+
"blockchainAccountId": `${invalidBlockchainType}:1337:${ownerAddress}`
320320
}
321321
]
322322
};

0 commit comments

Comments
 (0)