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

chore: cut release #989

Merged
merged 2 commits into from
Sep 20, 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
2 changes: 2 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<!--
PLEASE REVIEW BEFORE OPENING
PR guidelines:
- Delete this comment so the preview begins with your description
- Make sure not to include any internal links
- Please fill out all sections where applicable!
- PR title should be in the format <prefix>: <short description>
- for a reminder of what prefixes are available, see here: https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines
Expand Down
13 changes: 9 additions & 4 deletions src/library/controllers/modal/setup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import stringStartsWith from 'core-js-pure/stable/string/starts-with';

import { getInlineOptions, getGlobalState, awaitDOMContentLoaded, getAllBySelector, objectMerge } from '../../../utils';
import {
getInlineOptions,
getGlobalState,
awaitDOMContentLoaded,
getAllBySelector,
objectMerge,
isZoidComponent
} from '../../../utils';
import Modal from './interface';
import { getModalComponent } from '../../zoid/modal';

Expand All @@ -27,7 +32,7 @@ export default function setup() {
}

// Prevent auto render from firing inside zoid iframe
if (!stringStartsWith(window.name, '__zoid__')) {
if (!isZoidComponent()) {
const handleContentLoaded = () => {
// If merchant includes multiple SDK scripts, the 1st script will destroy itself
// and its globalState before this runs causing the account to be undefined
Expand Down
3 changes: 2 additions & 1 deletion src/library/zoid/message/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { uniqueID, getCurrentScriptUID } from '@krakenjs/belter/src';
import { create } from '@krakenjs/zoid/src';

import {
TAG,
getDisableSetCookie,
getMeta,
getEnv,
Expand Down Expand Up @@ -34,7 +35,7 @@ import containerTemplate from './containerTemplate';

export default createGlobalVariableGetter('__paypal_credit_message__', () =>
create({
tag: 'paypal-message',
tag: TAG.MESSAGE,
url: getGlobalUrl('MESSAGE'),
// eslint-disable-next-line security/detect-unsafe-regex
domain: /\.paypal\.com(:\d+)?$/,
Expand Down
3 changes: 2 additions & 1 deletion src/library/zoid/modal/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { create } from '@krakenjs/zoid/src';
import { uniqueID, getCurrentScriptUID } from '@krakenjs/belter/src';

import {
TAG,
getDisableSetCookie,
getMeta,
getEnv,
Expand Down Expand Up @@ -32,7 +33,7 @@ import prerenderTemplate from './prerenderTemplate';

export default createGlobalVariableGetter('__paypal_credit_modal__', () =>
create({
tag: 'paypal-credit-modal',
tag: TAG.MODAL,
url: getGlobalUrl('MODAL'),
// eslint-disable-next-line security/detect-unsafe-regex
domain: /\.paypal\.com(:\d+)?$/,
Expand Down
3 changes: 2 additions & 1 deletion src/library/zoid/treatments/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { node, dom } from '@krakenjs/jsx-pragmatic/src';
import { getCurrentScriptUID } from '@krakenjs/belter/src';

// Direct imports to avoid import cycle by importing from ../../../utils
import { TAG } from '../../../utils/constants';
import {
getMeta,
getEnv,
Expand All @@ -19,7 +20,7 @@ import { ppDebug } from '../../../utils/debug';

export default createGlobalVariableGetter('__paypal_credit_treatments__', () =>
create({
tag: 'paypal-credit-treatments',
tag: TAG.TREATEMENTS,
url: getGlobalUrl('TREATMENTS'),
// eslint-disable-next-line security/detect-unsafe-regex
domain: /\.paypal\.com(:\d+)?$/,
Expand Down
6 changes: 6 additions & 0 deletions src/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ export const OFFER = {
PAYPAL_CREDIT_INSTALLMENTS: 'PAYPAL_CREDIT_INSTALLMENTS',
PAYPAL_CREDIT_NO_INTEREST: 'PAYPAL_CREDIT_NO_INTEREST'
};

export const TAG = {
MESSAGE: 'paypal-message',
MODAL: 'paypal-credit-modal',
TREATEMENTS: 'paypal-credit-treatments'
};
7 changes: 5 additions & 2 deletions src/utils/sdk.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable eslint-comments/disable-enable-pair, no-else-return */
import stringStartsWith from 'core-js-pure/stable/string/starts-with';
import arrayFrom from 'core-js-pure/stable/array/from';

import { isLocalStorageEnabled, getStorage as getBelterStorage } from '@krakenjs/belter/src';
Expand All @@ -21,6 +20,8 @@ import {
getDisableSetCookie as getSDKDisableCookie
} from '@paypal/sdk-client/src';

import { TAG } from './constants';

export function getDisableSetCookie() {
if (__MESSAGES__.__TARGET__ === 'SDK') {
return getSDKDisableCookie();
Expand Down Expand Up @@ -128,7 +129,9 @@ export function getLibraryVersion() {
}

export function isZoidComponent() {
return stringStartsWith(window.name, '__zoid__');
// Merchants may use `zoid` to place our components inside an IFrame
// so we ensure that we check for the tags of our components
return Object.values(TAG).some(tag => window.name.startsWith(`__zoid__${tag.replace(/-/g, '_')}`));
}

export function getStorage() {
Expand Down
2 changes: 1 addition & 1 deletion utils/devServerProxy/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default (app, server, compiler) => {

app.get('/credit-presentment/experiments/local', (req, res) => {
const { scriptUID } = req.query;
const interfaceScript = `<script>var interface = window.top.document.querySelector('[data-uid-auto="${scriptUID}"]').outerHTML; document.write(interface);</script>`;
const interfaceScript = `<script>var interface = (window.opener ?? window.parent).document.querySelector('[data-uid-auto="${scriptUID}"]').outerHTML; document.write(interface);</script>`;
const initializerScript = `
<script>
window.xprops.onReady({
Expand Down
Loading