Skip to content

Commit

Permalink
Merge pull request #50 from DIMO-Network/development
Browse files Browse the repository at this point in the history
Development -> Main (Include SharedVehicles in Response)
  • Loading branch information
MoizAhmedd authored Jan 23, 2025
2 parents 0cb333d + cca6106 commit b69fe51
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 36 deletions.
Binary file modified example-dimo-auth/dimo-network-login-with-dimo-0.0.16.tgz
Binary file not shown.
Binary file not shown.
65 changes: 37 additions & 28 deletions example-dimo-auth/package-lock.json

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

2 changes: 1 addition & 1 deletion example-dimo-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ import {
<ShareVehiclesWithDimo
mode="popup"
onSuccess={(authData) => 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
Expand Down
2 changes: 1 addition & 1 deletion sdk/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
10 changes: 6 additions & 4 deletions sdk/src/utils/authUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
};

Expand Down
3 changes: 2 additions & 1 deletion sdk/src/utils/eventHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export const handleMessageForPopup = (
email,
mode,
transactionHash,
sharedVehicles,
message,
} = event.data;

Expand All @@ -93,7 +94,7 @@ export const handleMessageForPopup = (

if (eventType === "authResponse") {
processAuthResponse(
{ token, walletAddress, email },
{ token, walletAddress, email, sharedVehicles },
setAuthenticated,
onSuccess
);
Expand Down

0 comments on commit b69fe51

Please sign in to comment.