Skip to content

Commit

Permalink
Merge branch 'main' into tshamilov/connect-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
shamilovtim committed Aug 4, 2024
2 parents d231207 + 51ac075 commit f57e605
Show file tree
Hide file tree
Showing 30 changed files with 102 additions and 153 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/alpha-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ jobs:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
run: pnpm whoami

- name: Print Node.js, npm, & pnpm versions for debugging if needed
run: |
node -v
npm -v
pnpm -v
- name: Install dependencies
run: pnpm install --frozen-lockfile

Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ jobs:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: pnpm whoami

- name: Print Node.js, npm, & pnpm versions for debugging if needed
run: |
node -v
npm -v
pnpm -v
- name: Install dependencies
run: pnpm install --frozen-lockfile

Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/tests-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,16 @@ jobs:
with:
cache: "true"

- name: Print Node.js, npm, & pnpm versions for debugging if needed
run: |
node -v
npm -v
pnpm -v
- name: Install dependencies
run: pnpm install --no-frozen-lockfile

- name: Get Playwright Version (for cache)
- name: Get Playwright version referenced by DIDs package (for cache)
id: get-playwright-version
run: |
PLAYWRIGHT_VERSION=$(pnpm --filter dids ls @playwright/test | grep '@playwright/test' | awk 'NR==1{print $2}')
Expand All @@ -123,11 +129,11 @@ jobs:
path: ~/Library/Caches/ms-playwright
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}

- name: Install Playwright Browsers (if no cache)
- name: Install Playwright browsers referenced by DIDs package (if no cache)
if: steps.cache-playwright-restore.outputs.cache-hit != 'true'
run: pnpm --filter dids exec playwright install --with-deps

- name: Build esm
- name: Build ESM
run: pnpm --recursive --stream build:esm

- name: Build browser for matrix ${{ matrix.group }}
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion bin/corepack
2 changes: 1 addition & 1 deletion bin/node
2 changes: 1 addition & 1 deletion bin/npm
2 changes: 1 addition & 1 deletion bin/npx
2 changes: 1 addition & 1 deletion bin/pnpm
9 changes: 4 additions & 5 deletions packages/agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"node": ">=18.0.0"
},
"dependencies": {
"@noble/ciphers": "0.4.1",
"@noble/ciphers": "0.5.3",
"@scure/bip39": "1.2.2",
"@tbd54566975/dwn-sdk-js": "0.4.4",
"@web5/common": "1.0.0",
Expand All @@ -84,7 +84,7 @@
"ulidx": "2.1.0"
},
"devDependencies": {
"@playwright/test": "1.40.1",
"@playwright/test": "1.45.3",
"@types/chai": "4.3.6",
"@types/cors": "2.8.17",
"@types/dns-packet": "5.6.4",
Expand All @@ -110,10 +110,9 @@
"mocha": "10.2.0",
"mocha-junit-reporter": "2.2.1",
"node-stdlib-browser": "1.2.0",
"playwright": "1.40.1",
"playwright": "1.45.3",
"rimraf": "4.4.0",
"sinon": "18.0.0",
"typescript": "5.1.6",
"ws": "8.17.0"
"typescript": "5.1.6"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Convert } from '@web5/common';
import { getWebcryptoSubtle } from '@noble/ciphers/webcrypto/utils';
import { getWebcryptoSubtle } from '@noble/ciphers/webcrypto';

import type { Jwk } from '@web5/crypto';

Expand Down
2 changes: 1 addition & 1 deletion packages/agent/src/prototyping/crypto/primitives/aes-kw.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// ! TODO : Make sure I remove `@noble/ciphers` from the Agent package.json once this is moved to the `@web5/crypto` package.
import { getWebcryptoSubtle } from '@noble/ciphers/webcrypto/utils';
import { getWebcryptoSubtle } from '@noble/ciphers/webcrypto';

import type { Jwk } from '@web5/crypto';

Expand Down
2 changes: 1 addition & 1 deletion packages/agent/src/prototyping/crypto/primitives/hkdf.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// ! TODO : Make sure I remove `@noble/ciphers` from the Agent package.json once this is moved to the `@web5/crypto` package.
import { getWebcryptoSubtle } from '@noble/ciphers/webcrypto/utils';
import { getWebcryptoSubtle } from '@noble/ciphers/webcrypto';

import { Convert } from '@web5/common';
import { DeriveKeyBytesParams } from '../types/params-direct.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/agent/src/prototyping/crypto/primitives/pbkdf2.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// ! TODO : Make sure I remove `@noble/ciphers` from the Agent package.json once this is moved to the `@web5/crypto` package.
import { getWebcryptoSubtle } from '@noble/ciphers/webcrypto/utils';
import { getWebcryptoSubtle } from '@noble/ciphers/webcrypto';

import type { DeriveKeyBytesParams } from '../types/params-direct.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ import { expect } from 'chai';

import { DwnServerInfoCache, ServerInfo } from '../../../src/prototyping/clients/server-info-types.js';
import { DwnServerInfoCacheMemory } from '../../../src/prototyping/clients/dwn-server-info-cache-memory.js';
import { isNode } from '../../utils/runtimes.js';

describe('DwnServerInfoCache', () => {

describe(`DwnServerInfoCacheMemory`, () => {
let cache: DwnServerInfoCache;
let clock: sinon.SinonFakeTimers;

const exampleInfo:ServerInfo = {
maxFileSize : 100,
Expand All @@ -23,14 +21,12 @@ describe('DwnServerInfoCache', () => {
});

beforeEach(() => {
clock = sinon.useFakeTimers();
cache = new DwnServerInfoCacheMemory();
});

afterEach(async () => {
await cache.clear();
await cache.close();
clock.restore();
});

it('sets server info in cache', async () => {
Expand Down Expand Up @@ -96,11 +92,9 @@ describe('DwnServerInfoCache', () => {
});

it('returns undefined after ttl', async function () {
// skip this test in the browser, sinon fake timers don't seem to work here
// with a an await setTimeout in the test, it passes.
if (!isNode) {
this.skip();
}
// NOTE: tried very hard to use sinon.useFakeTimers() but couldn't get it to work with `TtlCache` implementation in `DwnServerInfoCacheMemory`.
// I sanity added a setInterval here, and it obeys the fake time ticks and its callback is fired, but the `TtlCache` just ignores the fake timer ticks.
cache = new DwnServerInfoCacheMemory({ ttl: '100ms'});

const key = 'some-key1';
await cache.set(key, { ...exampleInfo });
Expand All @@ -109,8 +103,8 @@ describe('DwnServerInfoCache', () => {
expect(result!.webSocketSupport).to.deep.equal(true);
expect(result).to.deep.equal(exampleInfo);

// wait until 15m default ttl is up
await clock.tickAsync('15:01');
// sleep for 100ms
await new Promise((resolve) => setTimeout(resolve, 100));

const resultAfter = await cache.get(key);
expect(resultAfter).to.be.undefined;
Expand Down
4 changes: 2 additions & 2 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"@web5/user-agent": "workspace:*"
},
"devDependencies": {
"@playwright/test": "1.40.1",
"@playwright/test": "1.45.3",
"@tbd54566975/dwn-sdk-js": "0.4.4",
"@types/chai": "4.3.6",
"@types/eslint": "8.56.10",
Expand All @@ -103,7 +103,7 @@
"mocha": "10.2.0",
"mocha-junit-reporter": "2.2.1",
"node-stdlib-browser": "1.2.0",
"playwright": "1.40.1",
"playwright": "1.45.3",
"rimraf": "4.4.0",
"sinon": "18.0.0",
"source-map-loader": "4.0.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"eslint-plugin-mocha": "10.4.3",
"mocha": "10.4.0",
"mocha-junit-reporter": "2.2.1",
"playwright": "1.45.0",
"playwright": "1.45.3",
"rimraf": "5.0.7",
"typescript": "5.5.3"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/crypto-aws-kms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"@web5/crypto": "1.0.0"
},
"devDependencies": {
"@playwright/test": "1.45.0",
"@playwright/test": "1.45.3",
"@types/chai": "4.3.16",
"@types/chai-as-promised": "7.1.8",
"@types/eslint": "9.6.0",
Expand All @@ -93,7 +93,7 @@
"eslint-plugin-mocha": "10.4.3",
"mocha": "10.7.0",
"mocha-junit-reporter": "2.2.1",
"playwright": "1.44.0",
"playwright": "1.45.3",
"rimraf": "5.0.7",
"sinon": "18.0.0",
"source-map-loader": "5.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/crypto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@
"node": ">=18.0.0"
},
"dependencies": {
"@noble/ciphers": "0.4.1",
"@noble/ciphers": "0.5.3",
"@noble/curves": "1.3.0",
"@noble/hashes": "1.4.0",
"@web5/common": "1.0.1"
},
"devDependencies": {
"@playwright/test": "1.40.1",
"@playwright/test": "1.45.3",
"@types/chai": "4.3.16",
"@types/chai-as-promised": "7.1.8",
"@types/eslint": "8.56.10",
Expand Down
2 changes: 1 addition & 1 deletion packages/crypto/src/primitives/aes-ctr.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Convert } from '@web5/common';
import { getWebcryptoSubtle } from '@noble/ciphers/webcrypto/utils';
import { getWebcryptoSubtle } from '@noble/ciphers/crypto';

import type { Jwk } from '../jose/jwk.js';

Expand Down
2 changes: 1 addition & 1 deletion packages/crypto/src/primitives/aes-gcm.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Convert } from '@web5/common';
import { getWebcryptoSubtle } from '@noble/ciphers/webcrypto/utils';
import { getWebcryptoSubtle } from '@noble/ciphers/webcrypto';

import type { Jwk } from '../jose/jwk.js';

Expand Down
2 changes: 1 addition & 1 deletion packages/crypto/src/primitives/xchacha20-poly1305.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Convert } from '@web5/common';
import { xchacha20poly1305 } from '@noble/ciphers/chacha';
import { getWebcryptoSubtle } from '@noble/ciphers/webcrypto/utils';
import { getWebcryptoSubtle } from '@noble/ciphers/webcrypto';

import type { Jwk } from '../jose/jwk.js';

Expand Down
2 changes: 1 addition & 1 deletion packages/crypto/src/primitives/xchacha20.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Convert } from '@web5/common';
import { xchacha20 } from '@noble/ciphers/chacha';
import { getWebcryptoSubtle } from '@noble/ciphers/webcrypto/utils';
import { getWebcryptoSubtle } from '@noble/ciphers/webcrypto';

import type { Jwk } from '../jose/jwk.js';

Expand Down
7 changes: 6 additions & 1 deletion packages/crypto/tests/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,12 @@ describe('Crypto Utils', () => {

it('handles invalid input gracefully', () => {
expect(() => randomBytes(-1)).to.throw(RangeError, 'length'); // Length cannot be negative.
expect(() => randomBytes(1e9)).to.throw(Error, 'exceed'); // Extremely large number that exceeds the available entropy.

// NOTE: only checking for Error being thrown because there is no meaningful message overlap between all browsers:
// Webkit: The quota has been exceeded.
// Firefox: Crypto.getRandomValues: getRandomValues can only generate maximum 65536 bytes
// Chromium: The ArrayBufferView's byte length (1000000000) exceeds the number of bytes of entropy available via this API (65536).
expect(() => randomBytes(1e9)).to.throw(Error); // Extremely large number that exceeds the available entropy.
});

it('produces unique values on each call', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/dids/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"ms": "2.1.3"
},
"devDependencies": {
"@playwright/test": "1.40.1",
"@playwright/test": "1.45.3",
"@types/bencode": "2.0.4",
"@types/chai": "4.3.16",
"@types/chai-as-promised": "7.1.8",
Expand All @@ -108,7 +108,7 @@
"eslint-plugin-mocha": "10.4.3",
"mocha": "10.7.0",
"mocha-junit-reporter": "2.2.1",
"playwright": "1.45.0",
"playwright": "1.45.3",
"rimraf": "5.0.7",
"sinon": "18.0.0",
"source-map-loader": "5.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/identity-agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"@web5/dids": "1.1.0"
},
"devDependencies": {
"@playwright/test": "1.40.1",
"@playwright/test": "1.45.3",
"@types/chai": "4.3.6",
"@types/chai-as-promised": "7.1.5",
"@types/eslint": "8.56.10",
Expand All @@ -95,7 +95,7 @@
"mocha": "10.2.0",
"mocha-junit-reporter": "2.2.1",
"node-stdlib-browser": "1.2.0",
"playwright": "1.40.1",
"playwright": "1.45.3",
"rimraf": "4.4.0",
"sinon": "18.0.0",
"typescript": "5.1.6"
Expand Down
4 changes: 2 additions & 2 deletions packages/proxy-agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"@web5/dids": "1.1.0"
},
"devDependencies": {
"@playwright/test": "1.40.1",
"@playwright/test": "1.45.3",
"@types/chai": "4.3.6",
"@types/chai-as-promised": "7.1.5",
"@types/dns-packet": "5.6.4",
Expand All @@ -95,7 +95,7 @@
"mocha": "10.2.0",
"mocha-junit-reporter": "2.2.1",
"node-stdlib-browser": "1.2.0",
"playwright": "1.40.1",
"playwright": "1.45.3",
"rimraf": "4.4.0",
"typescript": "5.1.6"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/user-agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"@web5/dids": "1.1.0"
},
"devDependencies": {
"@playwright/test": "1.40.1",
"@playwright/test": "1.45.3",
"@types/chai": "4.3.6",
"@types/chai-as-promised": "7.1.5",
"@types/dns-packet": "5.6.4",
Expand All @@ -95,7 +95,7 @@
"mocha": "10.2.0",
"mocha-junit-reporter": "2.2.1",
"node-stdlib-browser": "1.2.0",
"playwright": "1.40.1",
"playwright": "1.45.3",
"rimraf": "4.4.0",
"typescript": "5.1.6"
}
Expand Down
Loading

0 comments on commit f57e605

Please sign in to comment.