Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: replaced requestId double with UUID v7 #32

Merged
merged 3 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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": {
Expand Down
36 changes: 32 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion services/liquid-auth-api-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"rawId": "AYMPi2Rbhcnu2gSHOO1TNvzDJ38iU00rrlCqyH874XCIEoIotRc7eVRFpx0TvsQurg7BAnXy5KnWdKC8LeWs0k0",
"clientExtensionResults": {
"liquid": {
"requestId": 0.4352672418598509
"requestId": "019097ff-bb8c-75b3-a913-761d038cb9c0"
}
},
"response": {
Expand All @@ -20,7 +20,7 @@
"rawId": "ASk2I69zskHtkQLgnI_zHCAS9n7AwYoGSN8TEfE2D2IrVjETxVJADCdlYAu5lqhigqWvjGq8M0cfHcludnSD-3I",
"clientExtensionResults": {
"liquid": {
"requestId": 0.6811027920177524
"requestId": "019097ff-bb8c-7c61-af46-2788c0870b9e"
}
},
"response": {
Expand All @@ -35,7 +35,7 @@
"rawId": "AbqTh-5GQBr6NoOMkL_bTOpCDOVBF7_yHvi084BjrlLy8LYLoCJ3Uknichga4FDPY9vq6r3tdGPWS8a9s_Kkpco",
"clientExtensionResults": {
"liquid": {
"requestId": 0.45568228623762996
"requestId": "019097ff-bb8c-77e8-b1b9-7d14f6e80906"
}
},
"response": {
Expand All @@ -50,7 +50,7 @@
"rawId": "Af6bB9Z_zx0PmRlncq9IbzRzTuxPS-yvEwOrtojHy7eOOVnhGxxHICrKQfoiXv8sINQjs_3AX9TEejK7VOvav-c",
"clientExtensionResults": {
"liquid": {
"requestId": 0.22356418742804784
"requestId": "019097ff-bb8c-7260-b7cc-e1c8b2abb809"
}
},
"response": {
Expand All @@ -65,7 +65,7 @@
"rawId": "AVl7TsljN83pJD7_FfyXNoGubqbs37t41TGV9Y7V4jtgb30BnpqqlUwsQiB-a2h5ovTpkoJg5ChnQEmMlC6L0Sw",
"clientExtensionResults": {
"liquid": {
"requestId": 0.3868176416671725
"requestId": "019097ff-bb8c-7f14-836e-f3293f0dcf55"
}
},
"response": {
Expand All @@ -80,7 +80,7 @@
"rawId": "AYvDA1VZ-qkvCPmf7Re7_GVDY4AwzmUFbI1Njsl3kDcI9BFKTqTd0YUC47IK-peJbf3weNCUdqmB2_QDEPy7iR4",
"clientExtensionResults": {
"liquid": {
"requestId": 0.05638003353723975
"requestId": "019097ff-bb8c-7676-9175-a8eec9ea825d"
}
},
"response": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export type LiquidAuthClientExtensionResults = {
address: string;

device?: string;
requestId?: string | number;
requestId?: string;
};
};
export type LiquidAttestationExtensionsClientInput =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions services/liquid-auth-api-js/src/signals/signals.gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, any>;
this.logger.debug(
Expand Down
2 changes: 1 addition & 1 deletion sites/dapp-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion sites/dapp-ui/src/components/ConnectModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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%',
Expand Down Expand Up @@ -39,7 +40,7 @@ export function ConnectModal({
}) {
const { client, loading, dataChannel } = useSignalClient();
const navigate = useNavigate();
const [requestId] = useState(SignalClient.generateRequestId());
const [requestId] = useState<string>(SignalClient.generateRequestId());

const [open, setOpen] = React.useState(false);
const [barcode, setBarcode] = React.useState('/qr-loading.png');
Expand Down
Loading