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

CSP: Get and pass jss nonce to options if it exists #168

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export const createPlaid = (options: PlaidLinkOptions) => {
throw new Error('Plaid not loaded');
}

// Pass jss nonce if it's set
const nonceNode = document.querySelector('meta[property="csp-nonce"]')
options.nonce = nonceNode ? nonceNode.getAttribute('content') : null

const config = renameKeyInObject(
options,
'publicKey',
Expand Down
2 changes: 2 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ interface CommonPlaidLinkOptions {
onLoad?: Function;
// A callback that is called during a user's flow in Link.
onEvent?: Function;
// jss nonce setting from the page if the user has set it.
nonce?: string | null
}

export type PlaidLinkOptionsWithPublicKey = (CommonPlaidLinkOptions & {
Expand Down