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: allow extra parameters to pass through to the bridge url #220

Closed
wants to merge 2 commits into from

Conversation

gregjopa
Copy link
Contributor

This PR updates the web sdk bridge logic to allow for extra parameters to be passed through. These extra parameters will be validated and accepted/rejected at a different step outside this codebase. The purpose of this change is to make updating sdk-client easier in the future for the web sdk.

@gregjopa gregjopa requested a review from a team as a code owner October 21, 2024 17:40
@gregjopa gregjopa force-pushed the allow-extra-params-for-bridge-url branch from 4f01f79 to 4324d38 Compare October 21, 2024 17:43
throw new Error(`Expected script url to be ${sdkUrl} - got ${src}`);
}
if (uid !== sdkUID) {
throw new Error(`Expected data UID be ${sdkUID} - got ${uid}`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i was about to say "you should use an expect for this" but i just realized what repo we are in 😂

}

// supported query string parameters
const { origin, version, ["payment-flow"]: paymentflow, debug } = query;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still want or need to maintain the list of required parameters?

Copy link
Contributor

@bywood bywood Oct 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this allows whoever is using unpackSDKMeta to catch these errors, whereas it would be harder to detect that the SDK server responded with a validation error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When would this line of code error? I may be missing something. Best I can tell, query should always be an object. And if one of these values is not defined, it would not error:

const query = {};
const { origin, version } = query;
console.log(origin) // => undefined

I added this destructuring just for readability. The code below it contains the checks for if the values are required or not (ex: if (version === undefined);

query["payment-flow"] === undefined ||
!validPaymentFlows.includes(query["payment-flow"])
) {
if (paymentflow === undefined || !validPaymentFlows.includes(paymentflow)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to do this validation on the server-side as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm open to removing it here.

@gregjopa
Copy link
Contributor Author

We chatted through this PR. Going to close this out as unmerged.

@gregjopa gregjopa closed this Oct 21, 2024
@gregjopa gregjopa deleted the allow-extra-params-for-bridge-url branch October 21, 2024 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants