From c84699e5385a3e6e7e2f1a210c096bd60e332958 Mon Sep 17 00:00:00 2001 From: Tim Shamilov Date: Fri, 16 Aug 2024 11:55:58 -0400 Subject: [PATCH] fix crypto import (#161) i missed fixing this breaking change when i bumped web5 dids - added an assertion that would have caught the bug - added explicit dependency on web5/crypto because its there and was hidden --- package-lock.json | 7 ++++--- package.json | 1 + src/web5-connect/web5-connect-server.ts | 4 ++-- tests/scenarios/web5-connect.spec.ts | 2 ++ 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0a47ee9..631ede4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "dependencies": { "@tbd54566975/dwn-sdk-js": "0.4.5", "@tbd54566975/dwn-sql-store": "0.6.5", + "@web5/crypto": "^1.0.3", "better-sqlite3": "^8.5.0", "body-parser": "^1.20.2", "bytes": "3.1.2", @@ -3166,9 +3167,9 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "node_modules/elliptic": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", - "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", + "version": "6.5.7", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.7.tgz", + "integrity": "sha512-ESVCtTwiA+XhY3wyh24QqRGBoP3rEdDUl3EDUUo9tft074fi19IrdpH7hLCMMP3CIj7jb3W96rn8lt/BqIlt5Q==", "dev": true, "dependencies": { "bn.js": "^4.11.9", diff --git a/package.json b/package.json index bd0ca56..6cd7eda 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "dependencies": { "@tbd54566975/dwn-sdk-js": "0.4.5", "@tbd54566975/dwn-sql-store": "0.6.5", + "@web5/crypto": "^1.0.3", "better-sqlite3": "^8.5.0", "body-parser": "^1.20.2", "bytes": "3.1.2", diff --git a/src/web5-connect/web5-connect-server.ts b/src/web5-connect/web5-connect-server.ts index 72ff1e6..7176102 100644 --- a/src/web5-connect/web5-connect-server.ts +++ b/src/web5-connect/web5-connect-server.ts @@ -1,5 +1,5 @@ import { getDialectFromUrl } from "../storage.js"; -import { randomUuid } from '@web5/crypto/utils'; +import { CryptoUtils } from '@web5/crypto'; import { SqlTtlCache } from "./sql-ttl-cache.js"; /** @@ -67,7 +67,7 @@ export class Web5ConnectServer { */ public async setWeb5ConnectRequest(request: Web5ConnectRequest): Promise { // Generate a request URI - const requestId = randomUuid(); + const requestId = CryptoUtils.randomUuid(); const request_uri = `${this.baseUrl}/connect/authorize/${requestId}.jwt`; // Store the Request Object. diff --git a/tests/scenarios/web5-connect.spec.ts b/tests/scenarios/web5-connect.spec.ts index 3533600..28c2f58 100644 --- a/tests/scenarios/web5-connect.spec.ts +++ b/tests/scenarios/web5-connect.spec.ts @@ -71,6 +71,8 @@ describe('Web5 Connect scenarios', function () { // 2. Identity Provider (wallet) fetches the Web5 Connect Request object from the Web5 Connect server. const requestUrl = (await postWeb5ConnectRequestResult.json() as any).request_uri; + const regex = /^http:\/\/localhost:3000\/connect\/authorize\/[a-zA-Z0-9\-]{21,}\.jwt$/; + expect(requestUrl).to.match(regex); let getWeb5ConnectRequestResult; await Poller.pollUntilSuccessOrTimeout(async () => {