Skip to content

Commit

Permalink
Bump @web5/dids to 0.3.0 (#679)
Browse files Browse the repository at this point in the history
This PR will:
- Bump the `@web5/dids` dependency from 0.2.4 to 0.3.0.
- Removed the `@types/dns-packet` dev dependency since it is no longer
needed.
- Removes `src/did/did.ts` and the associated tests since there are no
longer any references to these methods in DWN SDK. Equivalent
functionality is available in
[`DidUri`](https://github.com/TBD54566975/web5-js/blob/main/packages/dids/src/did-uri.ts)
should it ever be needed.
- Removes `TestDataGenerator.getKeyId()` since a DID method agnostic
method `getSigningMethod()` is now available across all DID method
implementations in `@web5/dids`.
- Bump release version to `0.2.16`

---------

Signed-off-by: Frank Hinek <[email protected]>
Co-authored-by: Liran Cohen <[email protected]>
  • Loading branch information
frankhinek and LiranCohen authored Feb 2, 2024
1 parent d5c2e6f commit b443822
Show file tree
Hide file tree
Showing 26 changed files with 107 additions and 611 deletions.
538 changes: 52 additions & 486 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tbd54566975/dwn-sdk-js",
"version": "0.2.15",
"version": "0.2.16",
"description": "A reference implementation of https://identity.foundation/decentralized-web-node/spec/",
"repository": {
"type": "git",
Expand Down Expand Up @@ -65,7 +65,7 @@
"@js-temporal/polyfill": "0.4.4",
"@noble/ed25519": "2.0.0",
"@noble/secp256k1": "2.0.0",
"@web5/dids": "^0.2.4",
"@web5/dids": "0.3.0",
"abstract-level": "1.0.3",
"ajv": "8.12.0",
"blockstore-core": "4.2.0",
Expand All @@ -89,7 +89,6 @@
"devDependencies": {
"@types/chai": "4.3.0",
"@types/chai-as-promised": "7.1.5",
"@types/dns-packet": "^5.6.4",
"@types/flat": "^5.0.2",
"@types/karma": "^6.3.3",
"@types/lodash": "4.14.179",
Expand Down Expand Up @@ -159,4 +158,4 @@
"license-check": "license-report --only=prod > license-report.json && node ./build/license-check.cjs",
"publish:unstable": "./build/publish-unstable.sh"
}
}
}
39 changes: 0 additions & 39 deletions src/did/did.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/dwn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { RecordsQueryHandler } from './handlers/records-query.js';
import { RecordsReadHandler } from './handlers/records-read.js';
import { RecordsSubscribeHandler } from './handlers/records-subscribe.js';
import { RecordsWriteHandler } from './handlers/records-write.js';
import { DidDhtMethod, DidIonMethod, DidKeyMethod, DidResolver } from '@web5/dids';
import { DidDht, DidIon, DidKey, DidResolver } from '@web5/dids';
import { DwnInterfaceName, DwnMethodName } from './enums/dwn-interface-method.js';

export class Dwn {
Expand Down Expand Up @@ -134,7 +134,7 @@ export class Dwn {
* Creates an instance of the DWN.
*/
public static async create(config: DwnConfig): Promise<Dwn> {
config.didResolver ??= new DidResolver({ didResolvers: [DidKeyMethod, DidIonMethod, DidDhtMethod] });
config.didResolver ??= new DidResolver({ didResolvers: [DidKey, DidIon, DidDht] });
config.tenantGate ??= new AllowAllTenantGate();

const dwn = new Dwn(config);
Expand Down
4 changes: 2 additions & 2 deletions src/jose/jws/general/verifier.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Cache } from '../../../types/cache.js';
import type { GeneralJws } from '../../../types/jws-types.js';
import type { PublicJwk } from '../../../types/jose-types.js';
import type { DidResolver, VerificationMethod } from '@web5/dids';
import type { DidResolver, DidVerificationMethod } from '@web5/dids';

import { Jws } from '../../../utils/jws.js';
import { MemoryCache } from '../../../utils/memory-cache.js';
Expand Down Expand Up @@ -87,7 +87,7 @@ export class GeneralJwsVerifier {
const { didDocument } = await didResolver.resolve(did);
const { verificationMethod: verificationMethods = [] } = didDocument || {};

let verificationMethod: VerificationMethod | undefined;
let verificationMethod: DidVerificationMethod | undefined;

for (const method of verificationMethods) {
// consider optimizing using a set for O(1) lookups if needed
Expand Down
4 changes: 2 additions & 2 deletions tests/core/auth.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { authenticate } from '../../src/core/auth.js';
import { DwnErrorCode } from '../../src/core/dwn-error.js';
import { expect } from 'chai';
import { DidDhtMethod, DidResolver } from '@web5/dids';
import { DidDht, DidResolver } from '@web5/dids';

describe('Auth', () => {
describe('authenticate()', () => {
it('should throw if given JWS is `undefined`', async () => {
const jws = undefined;
await expect(authenticate(jws, new DidResolver({ didResolvers: [DidDhtMethod] }))).to.be.rejectedWith(DwnErrorCode.AuthenticateJwsMissing);
await expect(authenticate(jws, new DidResolver({ didResolvers: [DidDht] }))).to.be.rejectedWith(DwnErrorCode.AuthenticateJwsMissing);
});
});
});
22 changes: 0 additions & 22 deletions tests/did/did.spec.ts

This file was deleted.

4 changes: 2 additions & 2 deletions tests/handlers/events-get.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { TestDataGenerator } from '../utils/test-data-generator.js';
import { Message } from '../../src/core/message.js';
import { TestEventStream } from '../test-event-stream.js';
import { TestStores } from '../test-stores.js';
import { DidKeyMethod, DidResolver } from '@web5/dids';
import { DidKey, DidResolver } from '@web5/dids';

export function testEventsGetHandler(): void {
describe('EventsGetHandler.handle()', () => {
Expand All @@ -28,7 +28,7 @@ export function testEventsGetHandler(): void {
// important to follow the `before` and `after` pattern to initialize and clean the stores in tests
// so that different test suites can reuse the same backend store for testing
before(async () => {
didResolver = new DidResolver({ didResolvers: [DidKeyMethod] });
didResolver = new DidResolver({ didResolvers: [DidKey] });

const stores = TestStores.get();
messageStore = stores.messageStore;
Expand Down
4 changes: 2 additions & 2 deletions tests/handlers/events-query.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { expect } from 'chai';
import { TestDataGenerator } from '../utils/test-data-generator.js';
import { TestEventStream } from '../test-event-stream.js';
import { TestStores } from '../test-stores.js';
import { DidKeyMethod, DidResolver } from '@web5/dids';
import { DidKey, DidResolver } from '@web5/dids';


export function testEventsQueryHandler(): void {
Expand All @@ -26,7 +26,7 @@ export function testEventsQueryHandler(): void {
// important to follow the `before` and `after` pattern to initialize and clean the stores in tests
// so that different test suites can reuse the same backend store for testing
before(async () => {
didResolver = new DidResolver({ didResolvers: [DidKeyMethod] });
didResolver = new DidResolver({ didResolvers: [DidKey] });

const stores = TestStores.get();
messageStore = stores.messageStore;
Expand Down
6 changes: 3 additions & 3 deletions tests/handlers/events-subscribe.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Message } from '../../src/core/message.js';
import { TestDataGenerator } from '../utils/test-data-generator.js';
import { TestEventStream } from '../test-event-stream.js';
import { TestStores } from '../test-stores.js';
import { DidKeyMethod, DidResolver } from '@web5/dids';
import { DidKey, DidResolver } from '@web5/dids';

import sinon from 'sinon';
import chai, { expect } from 'chai';
Expand All @@ -31,7 +31,7 @@ export function testEventsSubscribeHandler(): void {
// important to follow the `before` and `after` pattern to initialize and clean the stores in tests
// so that different test suites can reuse the same backend store for testing
before(async () => {
didResolver = new DidResolver({ didResolvers: [DidKeyMethod] });
didResolver = new DidResolver({ didResolvers: [DidKey] });

const stores = TestStores.get();
messageStore = stores.messageStore;
Expand Down Expand Up @@ -85,7 +85,7 @@ export function testEventsSubscribeHandler(): void {
// important to follow the `before` and `after` pattern to initialize and clean the stores in tests
// so that different test suites can reuse the same backend store for testing
before(async () => {
didResolver = new DidResolver({ didResolvers: [DidKeyMethod] });
didResolver = new DidResolver({ didResolvers: [DidKey] });

const stores = TestStores.get();
messageStore = stores.messageStore;
Expand Down
4 changes: 2 additions & 2 deletions tests/handlers/messages-get.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { stubInterface } from 'ts-sinon';
import { TestDataGenerator } from '../utils/test-data-generator.js';
import { TestEventStream } from '../test-event-stream.js';
import { TestStores } from '../test-stores.js';
import { DidKeyMethod, DidResolver } from '@web5/dids';
import { DidKey, DidResolver } from '@web5/dids';
import { Dwn, DwnConstant } from '../../src/index.js';

import sinon from 'sinon';
Expand All @@ -30,7 +30,7 @@ export function testMessagesGetHandler(): void {
// important to follow the `before` and `after` pattern to initialize and clean the stores in tests
// so that different test suites can reuse the same backend store for testing
before(async () => {
didResolver = new DidResolver({ didResolvers: [DidKeyMethod] });
didResolver = new DidResolver({ didResolvers: [DidKey] });

const stores = TestStores.get();
messageStore = stores.messageStore;
Expand Down
4 changes: 2 additions & 2 deletions tests/handlers/permissions-grant.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { TestDataGenerator } from '../utils/test-data-generator.js';
import { TestEventStream } from '../test-event-stream.js';
import { TestStores } from '../test-stores.js';
import { Time } from '../../src/utils/time.js';
import { DidKeyMethod, DidResolver } from '@web5/dids';
import { DidKey, DidResolver } from '@web5/dids';
import { DwnInterfaceName, DwnMethodName } from '../../src/enums/dwn-interface-method.js';

export function testPermissionsGrantHandler(): void {
Expand All @@ -35,7 +35,7 @@ export function testPermissionsGrantHandler(): void {
// important to follow the `before` and `after` pattern to initialize and clean the stores in tests
// so that different test suites can reuse the same backend store for testing
before(async () => {
didResolver = new DidResolver({ didResolvers: [DidKeyMethod] });
didResolver = new DidResolver({ didResolvers: [DidKey] });

const stores = TestStores.get();
messageStore = stores.messageStore;
Expand Down
4 changes: 2 additions & 2 deletions tests/handlers/permissions-request.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { PermissionsRequestHandler } from '../../src/handlers/permissions-reques
import { TestDataGenerator } from '../utils/test-data-generator.js';
import { TestEventStream } from '../test-event-stream.js';
import { TestStores } from '../test-stores.js';
import { DidKeyMethod, DidResolver } from '@web5/dids';
import { DidKey, DidResolver } from '@web5/dids';
import { DwnErrorCode, DwnInterfaceName, DwnMethodName } from '../../src/index.js';

export function testPermissionsRequestHandler(): void {
Expand All @@ -32,7 +32,7 @@ export function testPermissionsRequestHandler(): void {
// important to follow the `before` and `after` pattern to initialize and clean the stores in tests
// so that different test suites can reuse the same backend store for testing
before(async () => {
didResolver = new DidResolver({ didResolvers: [DidKeyMethod] });
didResolver = new DidResolver({ didResolvers: [DidKey] });

const stores = TestStores.get();
messageStore = stores.messageStore;
Expand Down
4 changes: 2 additions & 2 deletions tests/handlers/permissions-revoke.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { TestDataGenerator } from '../utils/test-data-generator.js';
import { TestEventStream } from '../test-event-stream.js';
import { TestStores } from '../test-stores.js';
import { Time } from '../../src/utils/time.js';
import { DidKeyMethod, DidResolver } from '@web5/dids';
import { DidKey, DidResolver } from '@web5/dids';

describe('PermissionsRevokeHandler.handle()', () => {
let didResolver: DidResolver;
Expand All @@ -23,7 +23,7 @@ describe('PermissionsRevokeHandler.handle()', () => {

describe('functional tests', () => {
before(async () => {
didResolver = new DidResolver({ didResolvers: [DidKeyMethod] });
didResolver = new DidResolver({ didResolvers: [DidKey] });

// important to follow this pattern to initialize and clean the message and data store in tests
// so that different suites can reuse the same block store and index location for testing
Expand Down
4 changes: 2 additions & 2 deletions tests/handlers/protocols-configure.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { TestStores } from '../test-stores.js';
import { TestStubGenerator } from '../utils/test-stub-generator.js';
import { Time } from '../../src/utils/time.js';

import { DidKeyMethod, DidResolver } from '@web5/dids';
import { DidKey, DidResolver } from '@web5/dids';
import { Dwn, DwnErrorCode, Encoder, Jws } from '../../src/index.js';

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

const stores = TestStores.get();
messageStore = stores.messageStore;
Expand Down
4 changes: 2 additions & 2 deletions tests/handlers/protocols-query.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { TestEventStream } from '../test-event-stream.js';
import { TestStores } from '../test-stores.js';
import { TestStubGenerator } from '../utils/test-stub-generator.js';
import { Time } from '../../src/utils/time.js';
import { DidKeyMethod, DidResolver } from '@web5/dids';
import { DidKey, DidResolver } from '@web5/dids';
import { Dwn, DwnErrorCode, DwnInterfaceName, DwnMethodName, Encoder, Jws, ProtocolsQuery } from '../../src/index.js';

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

const stores = TestStores.get();
messageStore = stores.messageStore;
Expand Down
4 changes: 2 additions & 2 deletions tests/handlers/records-delete.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { TestStores } from '../test-stores.js';
import { TestStubGenerator } from '../utils/test-stub-generator.js';
import { Time } from '../../src/utils/time.js';
import { DataStream, Dwn, Encoder, Jws, RecordsDelete, RecordsRead, RecordsWrite } from '../../src/index.js';
import { DidKeyMethod, DidResolver } from '@web5/dids';
import { DidKey, DidResolver } from '@web5/dids';

chai.use(chaiAsPromised);

Expand All @@ -47,7 +47,7 @@ export function testRecordsDeleteHandler(): void {
// important to follow the `before` and `after` pattern to initialize and clean the stores in tests
// so that different test suites can reuse the same backend store for testing
before(async () => {
didResolver = new DidResolver({ didResolvers: [DidKeyMethod] });
didResolver = new DidResolver({ didResolvers: [DidKey] });

const stores = TestStores.get();
messageStore = stores.messageStore;
Expand Down
4 changes: 2 additions & 2 deletions tests/handlers/records-query.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { TestDataGenerator } from '../utils/test-data-generator.js';
import { TestEventStream } from '../test-event-stream.js';
import { TestStores } from '../test-stores.js';
import { TestStubGenerator } from '../utils/test-stub-generator.js';
import { DidKeyMethod, DidResolver } from '@web5/dids';
import { DidKey, DidResolver } from '@web5/dids';
import { Dwn, RecordsWrite, Time } from '../../src/index.js';

chai.use(chaiAsPromised);
Expand All @@ -44,7 +44,7 @@ export function testRecordsQueryHandler(): void {
// important to follow the `before` and `after` pattern to initialize and clean the stores in tests
// so that different test suites can reuse the same backend store for testing
before(async () => {
didResolver = new DidResolver({ didResolvers: [DidKeyMethod] });
didResolver = new DidResolver({ didResolvers: [DidKey] });

const stores = TestStores.get();
messageStore = stores.messageStore;
Expand Down
4 changes: 2 additions & 2 deletions tests/handlers/records-read.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { TestStores } from '../test-stores.js';
import { TestStubGenerator } from '../utils/test-stub-generator.js';

import { DataStream, Dwn, Jws, Protocols, ProtocolsConfigure, ProtocolsQuery, Records, RecordsDelete, RecordsRead , RecordsWrite, Secp256k1 } from '../../src/index.js';
import { DidKeyMethod, DidResolver } from '@web5/dids';
import { DidKey, DidResolver } from '@web5/dids';

chai.use(chaiAsPromised);

Expand All @@ -51,7 +51,7 @@ export function testRecordsReadHandler(): void {
// important to follow the `before` and `after` pattern to initialize and clean the stores in tests
// so that different test suites can reuse the same backend store for testing
before(async () => {
didResolver = new DidResolver({ didResolvers: [DidKeyMethod] });
didResolver = new DidResolver({ didResolvers: [DidKey] });

const stores = TestStores.get();
messageStore = stores.messageStore;
Expand Down
6 changes: 3 additions & 3 deletions tests/handlers/records-subscribe.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { TestDataGenerator } from '../utils/test-data-generator.js';
import { TestEventStream } from '../test-event-stream.js';
import { TestStores } from '../test-stores.js';
import { TestStubGenerator } from '../utils/test-stub-generator.js';
import { DidKeyMethod, DidResolver } from '@web5/dids';
import { DidKey, DidResolver } from '@web5/dids';
import { Dwn, Time } from '../../src/index.js';
import { DwnErrorCode, DwnInterfaceName, DwnMethodName } from '../../src/index.js';

Expand All @@ -37,7 +37,7 @@ export function testRecordsSubscribeHandler(): void {
// important to follow the `before` and `after` pattern to initialize and clean the stores in tests
// so that different test suites can reuse the same backend store for testing
before(async () => {
didResolver = new DidResolver({ didResolvers: [DidKeyMethod] });
didResolver = new DidResolver({ didResolvers: [DidKey] });

const stores = TestStores.get();
messageStore = stores.messageStore;
Expand Down Expand Up @@ -93,7 +93,7 @@ export function testRecordsSubscribeHandler(): void {
// important to follow the `before` and `after` pattern to initialize and clean the stores in tests
// so that different test suites can reuse the same backend store for testing
before(async () => {
didResolver = new DidResolver({ didResolvers: [DidKeyMethod] });
didResolver = new DidResolver({ didResolvers: [DidKey] });

const stores = TestStores.get();
messageStore = stores.messageStore;
Expand Down
Loading

0 comments on commit b443822

Please sign in to comment.