Skip to content

Commit 2b4b848

Browse files
DIDResolver/UniversalResolver alpha (#709)
Bump `@web5/dids` to `0.4.2` Bump `dwn-sdk-js` to `0.2.20` --------- Signed-off-by: Frank Hinek <[email protected]> Co-authored-by: Frank Hinek <[email protected]>
1 parent b66d4e7 commit 2b4b848

31 files changed

+120
-83
lines changed

.github/workflows/npm-publish-unstable.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ on:
55
branches:
66
- main
77
workflow_dispatch:
8-
inputs:
9-
branchName:
10-
description: 'Branch name to run the workflow on'
11-
required: true
12-
default: 'main'
138

149
jobs:
1510

package-lock.json

Lines changed: 25 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tbd54566975/dwn-sdk-js",
3-
"version": "0.2.18",
3+
"version": "0.2.20",
44
"description": "A reference implementation of https://identity.foundation/decentralized-web-node/spec/",
55
"repository": {
66
"type": "git",
@@ -65,7 +65,7 @@
6565
"@js-temporal/polyfill": "0.4.4",
6666
"@noble/ed25519": "2.0.0",
6767
"@noble/secp256k1": "2.0.0",
68-
"@web5/dids": "0.4.1",
68+
"@web5/dids": "0.4.2",
6969
"abstract-level": "1.0.3",
7070
"ajv": "8.12.0",
7171
"blockstore-core": "4.2.0",

src/dwn.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
12
import type { DataStore } from './types/data-store.js';
3+
import type { DidResolver } from '@web5/dids';
24
import type { EventLog } from './types/event-log.js';
35
import type { EventStream } from './types/subscriptions.js';
46
import type { MessageStore } from './types/message-store.js';
@@ -30,7 +32,7 @@ import { RecordsQueryHandler } from './handlers/records-query.js';
3032
import { RecordsReadHandler } from './handlers/records-read.js';
3133
import { RecordsSubscribeHandler } from './handlers/records-subscribe.js';
3234
import { RecordsWriteHandler } from './handlers/records-write.js';
33-
import { DidDht, DidIon, DidKey, DidResolver, DidResolverCacheLevel } from '@web5/dids';
35+
import { DidDht, DidIon, DidKey, DidResolverCacheLevel, UniversalResolver } from '@web5/dids';
3436
import { DwnInterfaceName, DwnMethodName } from './enums/dwn-interface-method.js';
3537

3638
export class Dwn {
@@ -134,7 +136,7 @@ export class Dwn {
134136
* Creates an instance of the DWN.
135137
*/
136138
public static async create(config: DwnConfig): Promise<Dwn> {
137-
config.didResolver ??= new DidResolver({
139+
config.didResolver ??= new UniversalResolver({
138140
didResolvers : [DidDht, DidIon, DidKey],
139141
cache : new DidResolverCacheLevel({ location: 'RESOLVERCACHE' }),
140142
});

tests/core/auth.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { authenticate } from '../../src/core/auth.js';
22
import { DwnErrorCode } from '../../src/core/dwn-error.js';
33
import { expect } from 'chai';
4-
import { DidDht, DidResolver } from '@web5/dids';
4+
import { DidDht, UniversalResolver } from '@web5/dids';
55

66
describe('Auth', () => {
77
describe('authenticate()', () => {
88
it('should throw if given JWS is `undefined`', async () => {
99
const jws = undefined;
10-
await expect(authenticate(jws, new DidResolver({ didResolvers: [DidDht] }))).to.be.rejectedWith(DwnErrorCode.AuthenticateJwsMissing);
10+
await expect(authenticate(jws, new UniversalResolver({ didResolvers: [DidDht] }))).to.be.rejectedWith(DwnErrorCode.AuthenticateJwsMissing);
1111
});
1212
});
1313
});

tests/features/author-delegated-grant.spec.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { DelegatedGrantMessage } from '../../src/types/delegated-grant-message.js';
2+
import type { DidResolver } from '@web5/dids';
23
import type { EventStream } from '../../src/types/subscriptions.js';
34
import type { DataStore, EventLog, MessageStore, PermissionScope } from '../../src/index.js';
45
import type { RecordEvent, RecordsWriteMessage } from '../../src/types/records-types.js';
@@ -22,7 +23,7 @@ import { TestEventStream } from '../test-event-stream.js';
2223
import { TestStores } from '../test-stores.js';
2324
import { Time } from '../../src/utils/time.js';
2425

25-
import { DidKey, DidResolver } from '@web5/dids';
26+
import { DidKey, UniversalResolver } from '@web5/dids';
2627
import { DwnInterfaceName, DwnMethodName, Encoder, Message, PermissionsGrant, PermissionsRevoke, RecordsDelete, RecordsQuery, RecordsRead, RecordsSubscribe } from '../../src/index.js';
2728

2829
chai.use(chaiAsPromised);
@@ -39,7 +40,7 @@ export function testAuthorDelegatedGrant(): void {
3940
// important to follow the `before` and `after` pattern to initialize and clean the stores in tests
4041
// so that different test suites can reuse the same backend store for testing
4142
before(async () => {
42-
didResolver = new DidResolver({ didResolvers: [DidKey] });
43+
didResolver = new UniversalResolver({ didResolvers: [DidKey] });
4344

4445
const stores = TestStores.get();
4546
messageStore = stores.messageStore;
@@ -1134,6 +1135,8 @@ export function testAuthorDelegatedGrant(): void {
11341135
signer : Jws.createSigner(alice)
11351136
});
11361137

1138+
await Time.minimalSleep();
1139+
11371140
const deviceXGrant2 = await PermissionsGrant.create({
11381141
delegated : true,
11391142
dateExpires : Time.createOffsetTimestamp({ seconds: 100 }),

tests/features/owner-delegated-grant.spec.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { DelegatedGrantMessage } from '../../src/types/delegated-grant-message.js';
2+
import type { DidResolver } from '@web5/dids';
23
import type { EventStream } from '../../src/types/subscriptions.js';
34
import type { DataStore, EventLog, MessageStore, PermissionScope } from '../../src/index.js';
45

@@ -18,7 +19,7 @@ import { TestEventStream } from '../test-event-stream.js';
1819
import { TestStores } from '../test-stores.js';
1920
import { Time } from '../../src/utils/time.js';
2021

21-
import { DidKey, DidResolver } from '@web5/dids';
22+
import { DidKey, UniversalResolver } from '@web5/dids';
2223
import { DwnInterfaceName, DwnMethodName, Encoder, Message, PermissionsGrant, PermissionsRevoke, ProtocolsConfigure } from '../../src/index.js';
2324

2425
chai.use(chaiAsPromised);
@@ -35,7 +36,7 @@ export function testOwnerDelegatedGrant(): void {
3536
// important to follow the `before` and `after` pattern to initialize and clean the stores in tests
3637
// so that different test suites can reuse the same backend store for testing
3738
before(async () => {
38-
didResolver = new DidResolver({ didResolvers: [DidKey] });
39+
didResolver = new UniversalResolver({ didResolvers: [DidKey] });
3940

4041
const stores = TestStores.get();
4142
messageStore = stores.messageStore;
@@ -528,6 +529,8 @@ export function testOwnerDelegatedGrant(): void {
528529
signer : Jws.createSigner(alice)
529530
});
530531

532+
await Time.minimalSleep();
533+
531534
const appXGrant2 = await PermissionsGrant.create({
532535
delegated : true,
533536
dateExpires : Time.createOffsetTimestamp({ seconds: 100 }),

tests/features/owner-signature.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { DidResolver } from '@web5/dids';
12
import type { EventStream } from '../../src/types/subscriptions.js';
23
import type { DataStore, EventLog, MessageStore } from '../../src/index.js';
34

@@ -8,8 +9,6 @@ import chai, { expect } from 'chai';
89

910
import { ArrayUtility } from '../../src/utils/array.js';
1011
import { DataStream } from '../../src/utils/data-stream.js';
11-
import { DidKey } from '@web5/dids';
12-
import { DidResolver } from '@web5/dids';
1312
import { Dwn } from '../../src/dwn.js';
1413
import { DwnErrorCode } from '../../src/core/dwn-error.js';
1514
import { Jws } from '../../src/utils/jws.js';
@@ -18,6 +17,7 @@ import { RecordsWrite } from '../../src/interfaces/records-write.js';
1817
import { TestDataGenerator } from '../utils/test-data-generator.js';
1918
import { TestEventStream } from '../test-event-stream.js';
2019
import { TestStores } from '../test-stores.js';
20+
import { DidKey, UniversalResolver } from '@web5/dids';
2121

2222
chai.use(chaiAsPromised);
2323

@@ -33,7 +33,7 @@ export function testOwnerSignature(): void {
3333
// important to follow the `before` and `after` pattern to initialize and clean the stores in tests
3434
// so that different test suites can reuse the same backend store for testing
3535
before(async () => {
36-
didResolver = new DidResolver({ didResolvers: [DidKey] });
36+
didResolver = new UniversalResolver({ didResolvers: [DidKey] });
3737

3838
const stores = TestStores.get();
3939
messageStore = stores.messageStore;

tests/features/protocol-create-action.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { DidResolver } from '@web5/dids';
12
import type { EventStream } from '../../src/types/subscriptions.js';
23
import type { ProtocolDefinition } from '../../src/types/protocols-types.js';
34
import type { DataStore, EventLog, MessageStore } from '../../src/index.js';
@@ -7,15 +8,14 @@ import sinon from 'sinon';
78
import chai, { expect } from 'chai';
89

910
import { DataStream } from '../../src/utils/data-stream.js';
10-
import { DidKey } from '@web5/dids';
11-
import { DidResolver } from '@web5/dids';
1211
import { Dwn } from '../../src/dwn.js';
1312
import { Jws } from '../../src/utils/jws.js';
1413
import { ProtocolAction } from '../../src/types/protocols-types.js';
1514
import { RecordsWrite } from '../../src/interfaces/records-write.js';
1615
import { TestDataGenerator } from '../utils/test-data-generator.js';
1716
import { TestEventStream } from '../test-event-stream.js';
1817
import { TestStores } from '../test-stores.js';
18+
import { DidKey, UniversalResolver } from '@web5/dids';
1919

2020
import { DwnErrorCode, ProtocolsConfigure } from '../../src/index.js';
2121

@@ -33,7 +33,7 @@ export function testProtocolCreateAction(): void {
3333
// important to follow the `before` and `after` pattern to initialize and clean the stores in tests
3434
// so that different test suites can reuse the same backend store for testing
3535
before(async () => {
36-
didResolver = new DidResolver({ didResolvers: [DidKey] });
36+
didResolver = new UniversalResolver({ didResolvers: [DidKey] });
3737

3838
const stores = TestStores.get();
3939
messageStore = stores.messageStore;

tests/features/protocol-delete-action.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { DidResolver } from '@web5/dids';
12
import type { EventStream } from '../../src/types/subscriptions.js';
23
import type { DataStore, EventLog, MessageStore } from '../../src/index.js';
34
import type { ProtocolDefinition, ProtocolsConfigureDescriptor } from '../../src/types/protocols-types.js';
@@ -7,8 +8,6 @@ import sinon from 'sinon';
78
import chai, { expect } from 'chai';
89

910
import { DataStream } from '../../src/utils/data-stream.js';
10-
import { DidKey } from '@web5/dids';
11-
import { DidResolver } from '@web5/dids';
1211
import { Dwn } from '../../src/dwn.js';
1312
import { Jws } from '../../src/utils/jws.js';
1413
import { ProtocolAction } from '../../src/types/protocols-types.js';
@@ -18,6 +17,7 @@ import { RecordsWrite } from '../../src/interfaces/records-write.js';
1817
import { TestDataGenerator } from '../utils/test-data-generator.js';
1918
import { TestEventStream } from '../test-event-stream.js';
2019
import { TestStores } from '../test-stores.js';
20+
import { DidKey, UniversalResolver } from '@web5/dids';
2121
import { DwnErrorCode, DwnInterfaceName, DwnMethodName, Message, ProtocolsConfigure, RecordsDelete, Time } from '../../src/index.js';
2222

2323
chai.use(chaiAsPromised);
@@ -34,7 +34,7 @@ export function testProtocolDeleteAction(): void {
3434
// important to follow the `before` and `after` pattern to initialize and clean the stores in tests
3535
// so that different test suites can reuse the same backend store for testing
3636
before(async () => {
37-
didResolver = new DidResolver({ didResolvers: [DidKey] });
37+
didResolver = new UniversalResolver({ didResolvers: [DidKey] });
3838

3939
const stores = TestStores.get();
4040
messageStore = stores.messageStore;

0 commit comments

Comments
 (0)