From 3cb05b205b5ccc03448054fc9be0b77899d4365a Mon Sep 17 00:00:00 2001 From: Kyle Breeding Date: Sat, 13 Jul 2024 18:42:50 -0700 Subject: [PATCH 1/3] feat: replaced requestId double with UUID v7 --- ARCHITECTURE.md | 8 ++++---- package-lock.json | 16 +++++++++++++++- services/liquid-auth-api-js/package.json | 3 ++- .../assertion.response.body.fixtures.json | 12 ++++++------ .../attestation.response.body.fixtures.json | 12 ++++++------ .../src/attestation/attestation.dto.ts | 2 +- .../src/signals/signals.gateway.spec.ts | 8 ++++---- .../src/signals/signals.gateway.ts | 4 ++-- sites/dapp-ui/src/components/ConnectModal.tsx | 3 ++- 9 files changed, 42 insertions(+), 26 deletions(-) diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index d3344ec..4678418 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -21,14 +21,14 @@ interface LiquidClientAttestationExtensionResults { type: string; // Currently only "algorand" supported address: string; // Wallet Address signature: string; // Base64URL Encoded Signature - requestId?: any // Optional Request ID , authenticate a remote user simaltaneously + requestId?: string // Optional Request ID , authenticate a remote user simaltaneously device?: string // Optional Device Name } } // Authenticator Get Response interface LiquidClientAssertionExtensionResults { liquid: { - requestId?: any; // Optional Request ID + requestId?: string; // Optional Request ID } } @@ -112,7 +112,7 @@ This will associate the credential with the wallet address and the credential ca "clientExtensionResults": { "liquid": { "type": "algorand", - "requestId": 0.6050027432326752, + "requestId": "019097ff-bb8c-7c42-9700-f11b9446fad7", "address": "2SPDE6XLJNXFTOO7OIGNRNKSEDOHJWVD3HBSEAPHONZQ4IQEYOGYTP6LXA", "signature": "QY31mdH8AwpJ9p4pCXBO2iA5WdU-BjG52xEtJNuSJNHJIaJ10uzqk3FdR0fvYVfb_rzXTuWn4k1PFFeg-vpEDw", "device": "Pixel 8 Pro" @@ -176,7 +176,7 @@ Optionally add a `requestId` to also authenticate a remote session "rawId": "AYMPi2Rbhcnu2gSHOO1TNvzDJ38iU00rrlCqyH874XCIEoIotRc7eVRFpx0TvsQurg7BAnXy5KnWdKC8LeWs0k0", "clientExtensionResults": { "liquid": { - "requestId": 0.4352672418598509 + "requestId": "019097ff-bb8d-75d8-b950-33de977c2d3f" } }, "response": { diff --git a/package-lock.json b/package-lock.json index 98455ee..a3578b2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17098,7 +17098,8 @@ "reflect-metadata": "^0.1.13", "rxjs": "^7.8.1", "tweetnacl": "^1.0.3", - "ua-parser-js": "^1.0.36" + "ua-parser-js": "^1.0.36", + "uuid": "^10.0.0" }, "devDependencies": { "@faker-js/faker": "^8.4.1", @@ -17133,6 +17134,19 @@ "node": ">=18.0.0" } }, + "services/liquid-auth-api-js/node_modules/uuid": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz", + "integrity": "sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } + }, "sites/dapp-ui": { "version": "0.0.1", "license": "MIT", diff --git a/services/liquid-auth-api-js/package.json b/services/liquid-auth-api-js/package.json index c13e08e..8bb523a 100644 --- a/services/liquid-auth-api-js/package.json +++ b/services/liquid-auth-api-js/package.json @@ -58,7 +58,8 @@ "reflect-metadata": "^0.1.13", "rxjs": "^7.8.1", "tweetnacl": "^1.0.3", - "ua-parser-js": "^1.0.36" + "ua-parser-js": "^1.0.36", + "uuid": "^10.0.0" }, "devDependencies": { "@faker-js/faker": "^8.4.1", diff --git a/services/liquid-auth-api-js/src/assertion/__fixtures__/assertion.response.body.fixtures.json b/services/liquid-auth-api-js/src/assertion/__fixtures__/assertion.response.body.fixtures.json index 0d0285b..3e8348a 100644 --- a/services/liquid-auth-api-js/src/assertion/__fixtures__/assertion.response.body.fixtures.json +++ b/services/liquid-auth-api-js/src/assertion/__fixtures__/assertion.response.body.fixtures.json @@ -5,7 +5,7 @@ "rawId": "AYMPi2Rbhcnu2gSHOO1TNvzDJ38iU00rrlCqyH874XCIEoIotRc7eVRFpx0TvsQurg7BAnXy5KnWdKC8LeWs0k0", "clientExtensionResults": { "liquid": { - "requestId": 0.4352672418598509 + "requestId": "019097ff-bb8c-75b3-a913-761d038cb9c0" } }, "response": { @@ -20,7 +20,7 @@ "rawId": "ASk2I69zskHtkQLgnI_zHCAS9n7AwYoGSN8TEfE2D2IrVjETxVJADCdlYAu5lqhigqWvjGq8M0cfHcludnSD-3I", "clientExtensionResults": { "liquid": { - "requestId": 0.6811027920177524 + "requestId": "019097ff-bb8c-7c61-af46-2788c0870b9e" } }, "response": { @@ -35,7 +35,7 @@ "rawId": "AbqTh-5GQBr6NoOMkL_bTOpCDOVBF7_yHvi084BjrlLy8LYLoCJ3Uknichga4FDPY9vq6r3tdGPWS8a9s_Kkpco", "clientExtensionResults": { "liquid": { - "requestId": 0.45568228623762996 + "requestId": "019097ff-bb8c-77e8-b1b9-7d14f6e80906" } }, "response": { @@ -50,7 +50,7 @@ "rawId": "Af6bB9Z_zx0PmRlncq9IbzRzTuxPS-yvEwOrtojHy7eOOVnhGxxHICrKQfoiXv8sINQjs_3AX9TEejK7VOvav-c", "clientExtensionResults": { "liquid": { - "requestId": 0.22356418742804784 + "requestId": "019097ff-bb8c-7260-b7cc-e1c8b2abb809" } }, "response": { @@ -65,7 +65,7 @@ "rawId": "AVl7TsljN83pJD7_FfyXNoGubqbs37t41TGV9Y7V4jtgb30BnpqqlUwsQiB-a2h5ovTpkoJg5ChnQEmMlC6L0Sw", "clientExtensionResults": { "liquid": { - "requestId": 0.3868176416671725 + "requestId": "019097ff-bb8c-7f14-836e-f3293f0dcf55" } }, "response": { @@ -80,7 +80,7 @@ "rawId": "AYvDA1VZ-qkvCPmf7Re7_GVDY4AwzmUFbI1Njsl3kDcI9BFKTqTd0YUC47IK-peJbf3weNCUdqmB2_QDEPy7iR4", "clientExtensionResults": { "liquid": { - "requestId": 0.05638003353723975 + "requestId": "019097ff-bb8c-7676-9175-a8eec9ea825d" } }, "response": { diff --git a/services/liquid-auth-api-js/src/attestation/__fixtures__/attestation.response.body.fixtures.json b/services/liquid-auth-api-js/src/attestation/__fixtures__/attestation.response.body.fixtures.json index 0ab04ef..9303a4e 100644 --- a/services/liquid-auth-api-js/src/attestation/__fixtures__/attestation.response.body.fixtures.json +++ b/services/liquid-auth-api-js/src/attestation/__fixtures__/attestation.response.body.fixtures.json @@ -6,7 +6,7 @@ "clientExtensionResults": { "liquid": { "type": "algorand", - "requestId": 0.6050027432326752, + "requestId": "019097ff-bb8c-7514-a0c6-5209d2405a4a", "address": "2SPDE6XLJNXFTOO7OIGNRNKSEDOHJWVD3HBSEAPHONZQ4IQEYOGYTP6LXA", "signature": "QY31mdH8AwpJ9p4pCXBO2iA5WdU-BjG52xEtJNuSJNHJIaJ10uzqk3FdR0fvYVfb_rzXTuWn4k1PFFeg-vpEDw", "device": "Pixel 8 Pro" @@ -25,7 +25,7 @@ "clientExtensionResults": { "liquid": { "type": "algorand", - "requestId": 0.1824949283001871, + "requestId": "019097ff-bb8c-7bf7-ac3e-a85e1d40062f", "address": "KH4XYQ4ZYKARWZAYVIVAY6WPWXNU3FWU2QC6HF2666KKM6CH4APTUIOQHU", "signature": "f0KUNI-Q5H54aSurcxCYwhCuQP8UtuHn2Ne5RhxeXfribsH1plCgbNVI4gwn183WxW8aSA-2JhxqLSe2J7ApCA", "device": "Pixel 8 Pro" @@ -44,7 +44,7 @@ "clientExtensionResults": { "liquid": { "type": "algorand", - "requestId": 0.1294004256903012, + "requestId": "019097ff-bb8c-7176-a12d-0ca31e3b5cf5", "address": "6P3TIK6KEPUNVHM77UXVG7ZIZRCCJX6IKZ5FA3WMXKRBHIXW4SAQ3OSEY4", "signature": "t6LqTuixeQ7WG1M-XxhSJvKBydY5YBEXCZi2BU_W9zJf2qWBGIbVlnMSfQnfc0ApYjsOO-bKnnoJtJdbh0lACQ", "device": "Pixel 8 Pro" @@ -63,7 +63,7 @@ "clientExtensionResults": { "liquid": { "type": "algorand", - "requestId": 0.5687522830110388, + "requestId": "019097ff-bb8c-7ec0-8912-fe9dfcf346b4", "address": "2W5VGV43VOKJTVFZXCEZ6L647XCQEXCDNZGDVFROWAR4FZJJCOWHVXLFOE", "signature": "QL0e1z24j1K5ZErHtwhpJPBBb7z-tdSb8IOuAuGVzL8KvxMQdAQihWM3-us-Vl3DkQD1GuXMlwB8BpZijvLyDw", "device": "Pixel 8 Pro" @@ -82,7 +82,7 @@ "clientExtensionResults": { "liquid": { "type": "algorand", - "requestId": 0.7699192258303749, + "requestId": "019097ff-bb8c-793f-a8b1-23ae835eb9fa", "address": "L72CSGO2C7K6QJZHVC2AYCLZ5GY3IMN7GJVKVNXU5WDDKLENPKSBZ7GE7U", "signature": "RX-r27Alz0i4IF9wRaEy2kp6na29mTTOYSYzHwBWfwv5wNHkPwvIT2spDFdsvaxlt_M16OKo0PVqOUOAuhhGAQ", "device": "Pixel 8 Pro" @@ -101,7 +101,7 @@ "clientExtensionResults": { "liquid": { "type": "algorand", - "requestId": 0.07304218671956053, + "requestId": "019097ff-bb8c-77fc-8ff2-eca0584cf04f", "address": "OXOACNIWZ7VDJXJXJHQ53BMNFQTSPPW524RU5JVAFLHSSGGQZCTII65ZII", "signature": "Fy7gb4f5PSrLOPRRFtQwB-f6kDuapV_T_MDtDY6TwT2ha9D1Km01KBmdFCgHN5VF9G__ae4bTRzC2VtOx37YAQ", "device": "Pixel 8 Pro" diff --git a/services/liquid-auth-api-js/src/attestation/attestation.dto.ts b/services/liquid-auth-api-js/src/attestation/attestation.dto.ts index 011eced..3ca240d 100644 --- a/services/liquid-auth-api-js/src/attestation/attestation.dto.ts +++ b/services/liquid-auth-api-js/src/attestation/attestation.dto.ts @@ -18,7 +18,7 @@ export type LiquidAuthClientExtensionResults = { address: string; device?: string; - requestId?: string | number; + requestId?: string; }; }; export type LiquidAttestationExtensionsClientInput = diff --git a/services/liquid-auth-api-js/src/signals/signals.gateway.spec.ts b/services/liquid-auth-api-js/src/signals/signals.gateway.spec.ts index eda108b..5b643bc 100644 --- a/services/liquid-auth-api-js/src/signals/signals.gateway.spec.ts +++ b/services/liquid-auth-api-js/src/signals/signals.gateway.spec.ts @@ -110,7 +110,7 @@ describe('SignalsGateway', () => { expect(gateway.logger.debug).toHaveBeenCalled(); }); it('should handle a link event', async () => { - await gateway.link({ requestId: 0.1 }, clientMock); + await gateway.link({ requestId: '019097ff-bb8c-7d5d-9822-7c9eb2c0d419' }, clientMock); expect(clientMock.join).toHaveBeenCalledWith( sessionFixtures.authorized.wallet, ); @@ -119,16 +119,16 @@ describe('SignalsGateway', () => { globalThis.handleObserver({ next: jest.fn(), complete: jest.fn() }), ).toBeUndefined(); expect( - linkEventFn(null, JSON.stringify({ data: { requestId: 0.1 } })), + linkEventFn(null, JSON.stringify({ data: { requestId: '019097ff-bb8c-7d5d-9822-7c9eb2c0d419' } })), ).resolves.toBeUndefined(); expect(globalThis.handleObserverMap).toBeInstanceOf(Function); expect( globalThis.handleObserverMap({ credId: '0.1', - requestId: 0.1, + requestId: '019097ff-bb8c-7d5d-9822-7c9eb2c0d419', wallet: '0.1', }), - ).toStrictEqual({ data: { credId: '0.1', requestId: 0.1, wallet: '0.1' } }); + ).toStrictEqual({ data: { credId: '0.1', requestId: '019097ff-bb8c-7d5d-9822-7c9eb2c0d419', wallet: '0.1' } }); }); it('should signal a offer-description', async () => { await gateway.onOfferDescription(sdpFixtures.call, clientMock); diff --git a/services/liquid-auth-api-js/src/signals/signals.gateway.ts b/services/liquid-auth-api-js/src/signals/signals.gateway.ts index 4c5f67b..d5d38c5 100644 --- a/services/liquid-auth-api-js/src/signals/signals.gateway.ts +++ b/services/liquid-auth-api-js/src/signals/signals.gateway.ts @@ -93,10 +93,10 @@ export class SignalsGateway */ @SubscribeMessage('link') async link( - @MessageBody() body: { requestId: string | number }, + @MessageBody() body: { requestId: string }, @ConnectedSocket() client: Socket, ): Promise< - Observable<{ data: { requestId: string | number; wallet: string } }> + Observable<{ data: { requestId: string; wallet: string } }> > { const request = client.request as Record; this.logger.debug( diff --git a/sites/dapp-ui/src/components/ConnectModal.tsx b/sites/dapp-ui/src/components/ConnectModal.tsx index 3469367..0fb9091 100644 --- a/sites/dapp-ui/src/components/ConnectModal.tsx +++ b/sites/dapp-ui/src/components/ConnectModal.tsx @@ -8,6 +8,7 @@ import CircularProgress from '@mui/material/CircularProgress'; import { useNavigate } from 'react-router-dom'; import { useSignalClient } from '@/hooks/useSignalClient.ts'; import { SignalClient } from '@algorandfoundation/liquid-client'; + const style = { position: 'absolute' as const, top: '50%', @@ -39,7 +40,7 @@ export function ConnectModal({ }) { const { client, loading, dataChannel } = useSignalClient(); const navigate = useNavigate(); - const [requestId] = useState(SignalClient.generateRequestId()); + const [requestId] = useState(SignalClient.generateRequestId()); const [open, setOpen] = React.useState(false); const [barcode, setBarcode] = React.useState('/qr-loading.png'); From ae64c58b633560307aa2e73f82a2ec736dd62714 Mon Sep 17 00:00:00 2001 From: Kyle Breeding Date: Wed, 17 Jul 2024 15:42:04 -0700 Subject: [PATCH 2/3] feat(dapp-ui): updated liquid-client dependency --- package-lock.json | 2 +- sites/dapp-ui/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index a3578b2..37ff8ec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17151,7 +17151,7 @@ "version": "0.0.1", "license": "MIT", "dependencies": { - "@algorandfoundation/liquid-client": "github:algorandfoundation/liquid-auth-js#feat/deep-links", + "@algorandfoundation/liquid-client": "github:algorandfoundation/liquid-auth-js#chore/switch-request-id-to-uuid", "@emotion/react": "^11.11.3", "@emotion/server": "^11.11.0", "@emotion/styled": "^11.11.0", diff --git a/sites/dapp-ui/package.json b/sites/dapp-ui/package.json index c019c33..18c0516 100644 --- a/sites/dapp-ui/package.json +++ b/sites/dapp-ui/package.json @@ -12,7 +12,7 @@ "lint": "eslint \"{src,apps,libs,test}/**/*.{ts,tsx}\" --fix" }, "dependencies": { - "@algorandfoundation/liquid-client": "github:algorandfoundation/liquid-auth-js#feat/deep-links", + "@algorandfoundation/liquid-client": "github:algorandfoundation/liquid-auth-js#chore/switch-request-id-to-uuid", "@emotion/react": "^11.11.3", "@emotion/server": "^11.11.0", "@emotion/styled": "^11.11.0", From 5fbc3c875f7d7c7afbf77b81a5318759a0c55ffd Mon Sep 17 00:00:00 2001 From: Kyle Breeding Date: Thu, 18 Jul 2024 13:02:19 -0700 Subject: [PATCH 3/3] fix: updated lockfile for liquid-auth-js branch --- package-lock.json | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 37ff8ec..9e7a735 100644 --- a/package-lock.json +++ b/package-lock.json @@ -75,7 +75,7 @@ }, "node_modules/@algorandfoundation/liquid-client": { "version": "0.0.1", - "resolved": "git+ssh://git@github.com/algorandfoundation/liquid-auth-js.git#b56d66eeecf89014692c76578b534b5be3b282a0", + "resolved": "git+ssh://git@github.com/algorandfoundation/liquid-auth-js.git#334a3434afaf3dc4fab62bcb14ee152922501c57", "hasInstallScript": true, "license": "AGPL-3.0", "dependencies": { @@ -83,7 +83,21 @@ "eventemitter3": "^5.0.1", "qr-code-styling": "*", "socket.io-client": "^4.7.5", - "tweetnacl": "^1.0.3" + "tweetnacl": "^1.0.3", + "uuid": "^10.0.0" + } + }, + "node_modules/@algorandfoundation/liquid-client/node_modules/uuid": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz", + "integrity": "sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" } }, "node_modules/@ampproject/remapping": {