diff --git a/example-dimo-auth/dimo-network-login-with-dimo-0.0.16.tgz b/example-dimo-auth/dimo-network-login-with-dimo-0.0.16.tgz index 767685e..a6ae1c8 100644 Binary files a/example-dimo-auth/dimo-network-login-with-dimo-0.0.16.tgz and b/example-dimo-auth/dimo-network-login-with-dimo-0.0.16.tgz differ diff --git a/example-dimo-auth/dimo-network-login-with-dimo-0.0.17.tgz b/example-dimo-auth/dimo-network-login-with-dimo-0.0.17.tgz new file mode 100644 index 0000000..bfadd5e Binary files /dev/null and b/example-dimo-auth/dimo-network-login-with-dimo-0.0.17.tgz differ diff --git a/example-dimo-auth/package-lock.json b/example-dimo-auth/package-lock.json index 393f980..b2fa8cc 100644 --- a/example-dimo-auth/package-lock.json +++ b/example-dimo-auth/package-lock.json @@ -8,7 +8,7 @@ "name": "example-dimo-auth", "version": "0.1.0", "dependencies": { - "@dimo-network/login-with-dimo": "file:./dimo-network-login-with-dimo-0.0.16.tgz", + "@dimo-network/login-with-dimo": "file:./dimo-network-login-with-dimo-0.0.17.tgz", "@testing-library/jest-dom": "^5.17.0", "@testing-library/react": "^13.4.0", "@testing-library/user-event": "^13.5.0", @@ -2209,9 +2209,9 @@ } }, "node_modules/@dimo-network/login-with-dimo": { - "version": "0.0.16", - "resolved": "file:dimo-network-login-with-dimo-0.0.16.tgz", - "integrity": "sha512-UW4TUlOYYZ9sMlo26V4hac/zaEwJISLp4k9pz1xHK+Aqv+3hvNDmuIdQjyOpz48EvwXWyZ8Z0MnBVPYrprIbTQ==", + "version": "0.0.17", + "resolved": "file:dimo-network-login-with-dimo-0.0.17.tgz", + "integrity": "sha512-pe2ar5z1e2XYk2E9VMZcCiGnTialRhJQMjBykEhmrbGA5lJBcYbOc5nqlbv/8dTK5henY6a4NjWcVAqfzgyJ3A==", "license": "ISC", "peerDependencies": { "react": "^18.0.0", @@ -3556,9 +3556,9 @@ "integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==" }, "node_modules/@types/node": { - "version": "16.18.124", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.124.tgz", - "integrity": "sha512-8ADCm5WzM/IpWxjs1Jhtwo6j+Fb8z4yr/CobP5beUUPdyCI0mg87/bqQYxNcqnhZ24Dc9RME8SQWu5eI/FmSGA==" + "version": "16.18.125", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.125.tgz", + "integrity": "sha512-w7U5ojboSPfZP4zD98d+/cjcN2BDW6lKH2M0ubipt8L8vUC7qUAC6ENKGSJL4tEktH2Saw2K4y1uwSjyRGKMhw==" }, "node_modules/@types/node-forge": { "version": "1.3.11", @@ -3687,9 +3687,9 @@ "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==" }, "node_modules/@types/ws": { - "version": "8.5.13", - "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.13.tgz", - "integrity": "sha512-osM/gWBTPKgHV8XkTunnegTRIsvF6owmf5w+JtAfOw472dptdm0dlGv4xCt6GwQRcC2XVOvvRE/0bAoQcL2QkA==", + "version": "8.5.14", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.14.tgz", + "integrity": "sha512-bd/YFLW+URhBzMXurx7lWByOu+xzU9+kb3RboOteXYDfW+tr+JZa99OyNmPINEGB/ahzKrEuc8rcv4gnpJmxTw==", "dependencies": { "@types/node": "*" } @@ -3926,9 +3926,9 @@ } }, "node_modules/@ungap/structured-clone": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.1.tgz", - "integrity": "sha512-fEzPV3hSkSMltkw152tJKNARhOupqbH96MZWyRjNaYZOMIzbrTeQDG+MTc6Mr2pgzFQzFxAfmhGDNP5QK++2ZA==" + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.3.0.tgz", + "integrity": "sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g==" }, "node_modules/@webassemblyjs/ast": { "version": "1.14.1", @@ -4519,6 +4519,14 @@ "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz", "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==" }, + "node_modules/async-function": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/async-function/-/async-function-1.0.0.tgz", + "integrity": "sha512-hsU18Ae8CDTR6Kgu9DYf0EbCr/a5iGL0rytQDobUcdpYOKokk8LEjVphnXkDkgpi0wYVsqrXuP0bZxJaTqdgoA==", + "engines": { + "node": ">= 0.4" + } + }, "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -5107,9 +5115,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001692", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001692.tgz", - "integrity": "sha512-A95VKan0kdtrsnMubMKxEKUKImOPSuCpYgxSQBo036P5YYgVIcOYJEgt/txJWqObiRQeISNCfef9nvlQ0vbV7A==", + "version": "1.0.30001695", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001695.tgz", + "integrity": "sha512-vHyLade6wTgI2u1ec3WQBxv+2BrTERV28UXQu9LO6lZ9pYeMk34vjXFLOxo1A4UBA8XTL4njRQZdno/yYaSmWw==", "funding": [ { "type": "opencollective", @@ -6007,9 +6015,9 @@ } }, "node_modules/decimal.js": { - "version": "10.4.3", - "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.3.tgz", - "integrity": "sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA==" + "version": "10.5.0", + "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.5.0.tgz", + "integrity": "sha512-8vDa8Qxvr/+d94hSh5P3IJwI5t8/c0KsMp+g8bNw9cY2icONa5aPfvKeieW1WlG0WQYwwhJ7mjui2xtiePQSXw==" }, "node_modules/dedent": { "version": "0.7.0", @@ -6386,9 +6394,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.83", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.83.tgz", - "integrity": "sha512-LcUDPqSt+V0QmI47XLzZrz5OqILSMGsPFkDYus22rIbgorSvBYEFqq854ltTmUdHkY92FSdAAvsh4jWEULMdfQ==" + "version": "1.5.87", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.87.tgz", + "integrity": "sha512-mPFwmEWmRivw2F8x3w3l2m6htAUN97Gy0kwpO++2m9iT1Gt8RCFVUfv9U/sIbHJ6rY4P6/ooqFL/eL7ock+pPg==" }, "node_modules/emittery": { "version": "0.8.1", @@ -7456,9 +7464,9 @@ "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==" }, "node_modules/fast-uri": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.0.5.tgz", - "integrity": "sha512-5JnBCWpFlMo0a3ciDy/JckMzzv1U9coZrIhedq+HXxxUfDTAiS0LA8OKVao4G9BxmCVck/jtA5r3KAtRWEyD8Q==", + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.0.6.tgz", + "integrity": "sha512-Atfo14OibSv5wAp4VWNsFYE1AchQRTv9cBGWET4pZWHzYshFSS9NQI6I57rdKn9croWVMbYFbLhJ+yJvmZIIHw==", "funding": [ { "type": "github", @@ -8695,10 +8703,11 @@ "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==" }, "node_modules/is-async-function": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-async-function/-/is-async-function-2.1.0.tgz", - "integrity": "sha512-GExz9MtyhlZyXYLxzlJRj5WUCE661zhDa1Yna52CN57AJsymh+DvXXjyveSioqSRdxvUrdKdvqB1b5cVKsNpWQ==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-async-function/-/is-async-function-2.1.1.tgz", + "integrity": "sha512-9dgM/cZBnNvjzaMYHVoxxfPj2QXt22Ev7SuuPrs+xav0ukGB0S6d4ydZdEiM48kLx5kDV+QBPrpVnFyefL8kkQ==", "dependencies": { + "async-function": "^1.0.0", "call-bound": "^1.0.3", "get-proto": "^1.0.1", "has-tostringtag": "^1.0.2", diff --git a/example-dimo-auth/package.json b/example-dimo-auth/package.json index 0e93a6e..360b43c 100644 --- a/example-dimo-auth/package.json +++ b/example-dimo-auth/package.json @@ -10,7 +10,7 @@ "@types/node": "^16.18.114", "@types/react": "^18.3.11", "@types/react-dom": "^18.3.1", - "@dimo-network/login-with-dimo": "file:./dimo-network-login-with-dimo-0.0.16.tgz", + "@dimo-network/login-with-dimo": "file:./dimo-network-login-with-dimo-0.0.17.tgz", "react": "^18.3.1", "react-dom": "^18.3.1", "react-scripts": "5.0.1", diff --git a/sdk/README.md b/sdk/README.md index f955b43..5c00e7b 100644 --- a/sdk/README.md +++ b/sdk/README.md @@ -101,7 +101,7 @@ import { console.log("Success:", authData)} + onSuccess={(authData) => console.log("Success:", authData)} //authData will include the sharedVehicles onError={(error) => console.error("Error:", error)} permissionTemplateId={"1"} //REQUIRED: "1" is the template for all SACD permissions //expirationDate={} //OPTIONAL ISO STRING diff --git a/sdk/package.json b/sdk/package.json index efa95cb..9aa0cc8 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@dimo-network/login-with-dimo", - "version": "0.0.16", + "version": "0.0.17", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/sdk/src/utils/authUtils.ts b/sdk/src/utils/authUtils.ts index d16e28f..bfc83cf 100644 --- a/sdk/src/utils/authUtils.ts +++ b/sdk/src/utils/authUtils.ts @@ -6,20 +6,22 @@ import { } from "../storage/storageManager"; export const processAuthResponse = ( - { token, walletAddress, email }: any, + { token, walletAddress, email, sharedVehicles }: any, setAuthenticated: (status: boolean) => void, onSuccess: (data: { token: string; - transactionHash?: string; - transactionReceipt?: any; + sharedVehicles: string[] }) => void ) => { + //This auth response may be triggered for a coupled or decoupled flow + //If decoupled, it will only return token + //If coupled, it will return token + updatedVehicles if (walletAddress) storeWalletAddressInLocalStorage(walletAddress); if (email) storeEmailInLocalStorage(email); if (token) { storeJWTInCookies(token); setAuthenticated(true); - onSuccess({ token }); + onSuccess({ token, sharedVehicles }); } }; diff --git a/sdk/src/utils/eventHandler.ts b/sdk/src/utils/eventHandler.ts index 84f4742..e35c808 100644 --- a/sdk/src/utils/eventHandler.ts +++ b/sdk/src/utils/eventHandler.ts @@ -70,6 +70,7 @@ export const handleMessageForPopup = ( email, mode, transactionHash, + sharedVehicles, message, } = event.data; @@ -93,7 +94,7 @@ export const handleMessageForPopup = ( if (eventType === "authResponse") { processAuthResponse( - { token, walletAddress, email }, + { token, walletAddress, email, sharedVehicles }, setAuthenticated, onSuccess );