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

Add SDK token for PayPal domain #172

Merged
merged 2 commits into from
Dec 5, 2023
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
4 changes: 4 additions & 0 deletions src/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,10 @@ export function getUserExperienceFlow(): ?string {
return getSDKAttribute(SDK_SETTINGS.USER_EXPERIENCE_FLOW);
}

export function getSDKToken(): ?string {
return getSDKAttribute(SDK_SETTINGS.SDK_TOKEN);
}

// whether in zoid window
export function isChildWindow(): boolean {
return Boolean(window.xprops);
Expand Down
16 changes: 16 additions & 0 deletions test/client/scriptUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
getCSPNonce,
getEnableThreeDomainSecure,
getUserExperienceFlow,
getSDKToken,
isChildWindow,
} from "../../src/script";
import { insertMockSDKScript } from "../../src";
Expand Down Expand Up @@ -162,6 +163,21 @@ describe(`script utils cases`, () => {
}
});

it("getSDKToken should return a sdk-token string", () => {
insertMockSDKScript({
attributes: {
"data-sdk-client-token": "sdk-token",
},
});
const result = getSDKToken();

if (result !== "sdk-token") {
throw new Error(
`should return the "sdk-token" word, but got: ${String(result)}`
);
}
});

it("getCSPNonce should return a data-csp-nonce string", () => {
insertMockSDKScript({
attributes: {
Expand Down