Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/paypal/paypal-sdk-client in…
Browse files Browse the repository at this point in the history
…to test-fraudnet
  • Loading branch information
siddy2181 committed Dec 6, 2023
2 parents c105605 + df528dc commit e73731d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ jobs:
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- name: 🤝 Set Node version from .nvmrc
run: echo NVMRC=`cat .nvmrc` >> $GITHUB_ENV

- name: ⎔ Setup node
# sets up the .npmrc file to publish to npm
uses: actions/setup-node@v3
with:
node-version: "16"
node-version: ${{ env.NVMRC }}
registry-url: "https://registry.npmjs.org"

- name: 📥 Download deps
Expand Down
23 changes: 18 additions & 5 deletions publish.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh

# This script will determine the type of release based on the git branch. When the default branch is used, it will be a `patch` that's published to npm under the `latest` dist-tag. Any other branch will be a `prelease` that's published to npm under the `alpha` dist-tag.

set -e;

if ! git diff-files --quiet; then
Expand All @@ -15,10 +17,21 @@ fi;
rm -rf node_modules
npm install

npm test;
current_branch=$(git rev-parse --abbrev-ref HEAD)
default_branch=$(git remote show origin | sed -n '/HEAD branch/s/.*: //p')

npm version ${1-patch}
if [ "$current_branch" != "$default_branch" ]; then
bump='prerelease'
tag='alpha'
npm --no-git-tag-version version $bump --preid=$tag
git push
npm publish --tag $tag
else
npm test;
npm version ${1-patch}
echo "Publishing NPM version: ${1-patch}"

git push;
git push --tags;
npm publish;
git push;
git push --tags;
npm publish;
fi
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

0 comments on commit e73731d

Please sign in to comment.