From 60062690634fe42b93fd90c2a5314aa75b4c1f11 Mon Sep 17 00:00:00 2001 From: Ricardo Seromenho Date: Tue, 26 Jan 2021 12:45:14 +0000 Subject: [PATCH] Get and pass jss nonce to options if it exists --- src/factory.ts | 4 ++++ src/types/index.ts | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/factory.ts b/src/factory.ts index 58474114..b832055b 100644 --- a/src/factory.ts +++ b/src/factory.ts @@ -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', diff --git a/src/types/index.ts b/src/types/index.ts index 5203fe6c..78d2a692 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -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 & {