Skip to content

Commit

Permalink
feat(twitter): fix failing test cases, revert to older axios version
Browse files Browse the repository at this point in the history
  • Loading branch information
nutrina committed Nov 3, 2022
1 parent f88c718 commit 569684c
Show file tree
Hide file tree
Showing 3 changed files with 235 additions and 212 deletions.
109 changes: 56 additions & 53 deletions app/components/GenericOauthPlatform.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,61 +138,64 @@ export const GenericOauthPlatform = ({ platformgroupspec, platform }: PlatformPr
code: queryCode, // provided by the provider as query params in the redirect
sessionKey: queryState,
},
signer as { signMessage: (message: string) => Promise<string> }
)
.then(async (verified: VerifiableCredentialRecord): Promise<void> => {
// because we provided a types array in the params we expect to receive a credentials array in the response...
const vcs =
verified.credentials
?.map((cred: CredentialResponseBody): Stamp | undefined => {
if (!cred.error) {
// add each of the requested/received stamps to the passport...
return {
provider: cred.record?.type as PROVIDER_ID,
credential: cred.credential as VerifiableCredential,
};
}
})
.filter((v: Stamp | undefined) => v) || [];
// Add all the stamps to the passport at once
await handleAddStamps(vcs as Stamp[]);
// report success to datadog
datadogLogs.logger.info("Successfully saved Stamp", { platform: platform.platformId });
// grab all providers who are verified from the verify response
const actualVerifiedProviders = providerIds.filter(
(providerId: string | undefined) =>
!!vcs.find((vc: Stamp | undefined) => vc?.credential?.credentialSubject?.provider === providerId)
);
// both verified and selected should look the same after save
setVerifiedProviders([...actualVerifiedProviders]);
setSelectedProviders([...actualVerifiedProviders]);
// reset can submit state
setCanSubmit(false);
// Custom Success Toast
toast({
duration: 5000,
isClosable: true,
render: (result: any) => (
<DoneToastContent
title="Success!"
body={`All ${platform.platformId} data points verified.`}
icon="../../assets/check-icon.svg"
platformId={platform.platformId}
result={result}
/>
),
});
})
.catch((e) => {
datadogLogs.logger.error("Verification Error", { error: e, platform: platform.platformId });
throw e;
})
.finally(() => {
setLoading(false);
},
signer as { signMessage: (message: string) => Promise<string> }
)
.then(async (verified: VerifiableCredentialRecord): Promise<void> => {
// because we provided a types array in the params we expect to receive a credentials array in the response...
const vcs =
verified.credentials
?.map((cred: CredentialResponseBody): Stamp | undefined => {
if (!cred.error) {
// add each of the requested/received stamps to the passport...
return {
provider: cred.record?.type as PROVIDER_ID,
credential: cred.credential as VerifiableCredential,
};
}
})
.filter((v: Stamp | undefined) => v) || [];
// Add all the stamps to the passport at once
await handleAddStamps(vcs as Stamp[]);
// report success to datadog
datadogLogs.logger.info("Successfully saved Stamp", { platform: platform.platformId });
// grab all providers who are verified from the verify response
const actualVerifiedProviders = providerIds.filter(
(providerId: string | undefined) =>
!!vcs.find((vc: Stamp | undefined) => vc?.credential?.credentialSubject?.provider === providerId)
);
// both verified and selected should look the same after save
setVerifiedProviders([...actualVerifiedProviders]);
setSelectedProviders([...actualVerifiedProviders]);
// reset can submit state
setCanSubmit(false);
// Custom Success Toast
toast({
duration: 5000,
isClosable: true,
render: (result: any) => (
<DoneToastContent
title="Success!"
body={`All ${platform.platformId} data points verified.`}
icon="../../assets/check-icon.svg"
platformId={platform.platformId}
result={result}
/>
),
});
}
})
.catch((e) => {
datadogLogs.logger.error("Verification Error", { error: e, platform: platform.platformId });
throw e;
})
.finally(() => {
setLoading(false);
});
}
}

// attach and destroy a BroadcastChannel to handle the message
useEffect(() => {
// open the channel
const channel = new BroadcastChannel(`${platform.path}_oauth_channel`);
// event handler will listen for messages from the child (debounced to avoid multiple submissions)
Expand All @@ -201,7 +204,7 @@ export const GenericOauthPlatform = ({ platformgroupspec, platform }: PlatformPr
return () => {
channel.close();
};
});
}, [platform.path, selectedProviders]);

return (
<SideBarContent
Expand Down
2 changes: 1 addition & 1 deletion platforms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@ethersproject/providers": "^5.6.2",
"@gitcoin/passport-types": "^1.0.0",
"@spruceid/didkit-wasm": "^0.3.0-alpha0",
"axios": "^1.1.3",
"axios": "^0.26.1",
"typescript": "~4.6.3"
},
"devDependencies": {
Expand Down
Loading

0 comments on commit 569684c

Please sign in to comment.