react-plaid-link
Advanced tools
Comparing version 3.3.0 to 3.3.1
@@ -52,3 +52,3 @@ /// <reference types="react" /> | ||
type PlaidLinkOnSuccess = (public_token: string, metadata: PlaidLinkOnSuccessMetadata) => void; | ||
type PlaidLinkOnExit = (error: null | PlaidLinkError, metadata: PlaidLinkOnExitMetadata) => void; // The following event names are stable and will not be deprecated or changed | ||
type PlaidLinkOnExit = (error: null | PlaidLinkError, metadata: PlaidLinkOnExitMetadata) => void; | ||
// The following event names are stable and will not be deprecated or changed | ||
@@ -82,6 +82,3 @@ declare enum PlaidLinkStableEvent { | ||
onEvent?: PlaidLinkOnEvent; | ||
} /** | ||
* @deprecated Public key integrations are deprecated and should not be used. | ||
* https://plaid.com/docs/link/link-token-migration-guide/ | ||
*/ | ||
} | ||
/** | ||
@@ -132,4 +129,3 @@ * @deprecated Public key integrations are deprecated and should not be used. | ||
receivedRedirectUri?: string; | ||
}; // Either the publicKey or the token field must be configured. The publicKey | ||
// is deprecated so prefer to initialize Link with a Link Token instead. | ||
}; | ||
// Either the publicKey or the token field must be configured. The publicKey | ||
@@ -136,0 +132,0 @@ // is deprecated so prefer to initialize Link with a Link Token instead. |
@@ -52,3 +52,3 @@ /// <reference types="react" /> | ||
type PlaidLinkOnSuccess = (public_token: string, metadata: PlaidLinkOnSuccessMetadata) => void; | ||
type PlaidLinkOnExit = (error: null | PlaidLinkError, metadata: PlaidLinkOnExitMetadata) => void; // The following event names are stable and will not be deprecated or changed | ||
type PlaidLinkOnExit = (error: null | PlaidLinkError, metadata: PlaidLinkOnExitMetadata) => void; | ||
// The following event names are stable and will not be deprecated or changed | ||
@@ -82,6 +82,3 @@ declare enum PlaidLinkStableEvent { | ||
onEvent?: PlaidLinkOnEvent; | ||
} /** | ||
* @deprecated Public key integrations are deprecated and should not be used. | ||
* https://plaid.com/docs/link/link-token-migration-guide/ | ||
*/ | ||
} | ||
/** | ||
@@ -132,4 +129,3 @@ * @deprecated Public key integrations are deprecated and should not be used. | ||
receivedRedirectUri?: string; | ||
}; // Either the publicKey or the token field must be configured. The publicKey | ||
// is deprecated so prefer to initialize Link with a Link Token instead. | ||
}; | ||
// Either the publicKey or the token field must be configured. The publicKey | ||
@@ -136,0 +132,0 @@ // is deprecated so prefer to initialize Link with a Link Token instead. |
@@ -8,10 +8,5 @@ import react, { useState, useEffect } from 'react'; | ||
var symbols = Object.getOwnPropertySymbols(object); | ||
if (enumerableOnly) { | ||
symbols = symbols.filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
}); | ||
} | ||
keys.push.apply(keys, symbols); | ||
enumerableOnly && (symbols = symbols.filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
})), keys.push.apply(keys, symbols); | ||
} | ||
@@ -24,15 +19,8 @@ | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
if (i % 2) { | ||
ownKeys(Object(source), true).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} else if (Object.getOwnPropertyDescriptors) { | ||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); | ||
} else { | ||
ownKeys(Object(source)).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
}); | ||
} | ||
var source = null != arguments[i] ? arguments[i] : {}; | ||
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
}); | ||
} | ||
@@ -103,3 +91,3 @@ | ||
function _iterableToArrayLimit(arr, i) { | ||
var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]); | ||
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; | ||
@@ -180,5 +168,26 @@ if (_i == null) return; | ||
}); | ||
exports.scripts = void 0; | ||
// Previously loading/loaded scripts and their current status | ||
exports.scripts = {}; // Check for existing <script> tags with this src. If so, update scripts[src] | ||
// and return the new status; otherwise, return undefined. | ||
var checkExisting = function (src) { | ||
var existing = document.querySelector("script[src=\"" + src + "\"]"); | ||
if (existing) { | ||
// Assume existing <script> tag is already loaded, | ||
// and cache that data for future use. | ||
return exports.scripts[src] = { | ||
loading: false, | ||
error: null, | ||
scriptEl: existing | ||
}; | ||
} | ||
return undefined; | ||
}; | ||
function useScript(_a) { | ||
@@ -188,9 +197,17 @@ var src = _a.src, | ||
checkForExisting = _b === void 0 ? false : _b, | ||
attributes = __rest(_a, ["src", "checkForExisting"]); | ||
attributes = __rest(_a, ["src", "checkForExisting"]); // Check whether some instance of this hook considered this src. | ||
var _c = (0, react.useState)(Boolean(src)), | ||
var status = src ? exports.scripts[src] : undefined; // If requested, check for existing <script> tags with this src | ||
// (unless we've already loaded the script ourselves). | ||
if (!status && checkForExisting && src && isBrowser) { | ||
status = checkExisting(src); | ||
} | ||
var _c = (0, react.useState)(status ? status.loading : Boolean(src)), | ||
loading = _c[0], | ||
setLoading = _c[1]; | ||
var _d = (0, react.useState)(null), | ||
var _d = (0, react.useState)(status ? status.error : null), | ||
error = _d[0], | ||
@@ -200,26 +217,40 @@ setError = _d[1]; | ||
(0, react.useEffect)(function () { | ||
if (!isBrowser || !src) return; | ||
// Nothing to do on server, or if no src specified, or | ||
// if loading has already resolved to "loaded" or "error" state. | ||
if (!isBrowser || !src || !loading || error) return; // Check again for existing <script> tags with this src | ||
// in case it's changed since mount. | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
if (checkForExisting) { | ||
var existing = document.querySelector("script[src=\"" + src + "\"]"); | ||
status = exports.scripts[src]; | ||
if (existing) { | ||
setLoading(existing.getAttribute('data-status') === 'loading'); | ||
return; | ||
} | ||
} | ||
if (!status && checkForExisting) { | ||
status = checkExisting(src); | ||
} // Determine or create <script> element to listen to. | ||
var scriptEl = document.createElement('script'); | ||
scriptEl.setAttribute('src', src); | ||
scriptEl.setAttribute('data-status', 'loading'); | ||
Object.keys(attributes).forEach(function (key) { | ||
if (scriptEl[key] === undefined) { | ||
scriptEl.setAttribute(key, attributes[key]); | ||
} else { | ||
scriptEl[key] = attributes[key]; | ||
} | ||
}); | ||
var scriptEl; | ||
if (status) { | ||
scriptEl = status.scriptEl; | ||
} else { | ||
scriptEl = document.createElement('script'); | ||
scriptEl.src = src; | ||
Object.keys(attributes).forEach(function (key) { | ||
if (scriptEl[key] === undefined) { | ||
scriptEl.setAttribute(key, attributes[key]); | ||
} else { | ||
scriptEl[key] = attributes[key]; | ||
} | ||
}); | ||
status = exports.scripts[src] = { | ||
loading: true, | ||
error: null, | ||
scriptEl: scriptEl | ||
}; | ||
} // `status` is now guaranteed to be defined: either the old status | ||
// from a previous load, or a newly created one. | ||
var handleLoad = function () { | ||
scriptEl.setAttribute('data-status', 'ready'); | ||
if (status) status.loading = false; | ||
setLoading(false); | ||
@@ -229,3 +260,3 @@ }; | ||
var handleError = function (error) { | ||
scriptEl.setAttribute('data-status', 'error'); | ||
if (status) status.error = error; | ||
setError(error); | ||
@@ -241,3 +272,2 @@ }; | ||
}; // we need to ignore the attributes as they're a new object per call, so we'd never skip an effect call | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [src]); | ||
@@ -252,2 +282,3 @@ return [loading, error]; | ||
unwrapExports(useScript_1); | ||
var useScript_2 = useScript_1.scripts; | ||
@@ -265,3 +296,3 @@ var lib = createCommonjsModule(function (module, exports) { | ||
}); | ||
exports.default = void 0; | ||
exports.scripts = exports.default = void 0; | ||
@@ -276,5 +307,12 @@ | ||
}); | ||
Object.defineProperty(exports, "scripts", { | ||
enumerable: true, | ||
get: function () { | ||
return useScript_1.scripts; | ||
} | ||
}); | ||
}); | ||
var useScript = unwrapExports(lib); | ||
var lib_1 = lib.scripts; | ||
@@ -392,6 +430,6 @@ var renameKeyInObject = function renameKeyInObject(o, oldKey, newKey) { | ||
return; | ||
} // If the token is undefined, return prematurely | ||
} // If the token and publicKey is undefined, return prematurely | ||
if (!options.token) { | ||
if (!options.token && !options.publicKey) { | ||
return; | ||
@@ -431,3 +469,3 @@ } | ||
}; | ||
}, [loading, error, options.token, products]); | ||
}, [loading, error, options.publicKey, options.token, products]); | ||
var ready = plaid != null && (!loading || iframeLoaded); | ||
@@ -434,0 +472,0 @@ |
@@ -15,10 +15,5 @@ 'use strict'; | ||
var symbols = Object.getOwnPropertySymbols(object); | ||
if (enumerableOnly) { | ||
symbols = symbols.filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
}); | ||
} | ||
keys.push.apply(keys, symbols); | ||
enumerableOnly && (symbols = symbols.filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
})), keys.push.apply(keys, symbols); | ||
} | ||
@@ -31,15 +26,8 @@ | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
if (i % 2) { | ||
ownKeys(Object(source), true).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} else if (Object.getOwnPropertyDescriptors) { | ||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); | ||
} else { | ||
ownKeys(Object(source)).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
}); | ||
} | ||
var source = null != arguments[i] ? arguments[i] : {}; | ||
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
}); | ||
} | ||
@@ -110,3 +98,3 @@ | ||
function _iterableToArrayLimit(arr, i) { | ||
var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]); | ||
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; | ||
@@ -187,5 +175,26 @@ if (_i == null) return; | ||
}); | ||
exports.scripts = void 0; | ||
// Previously loading/loaded scripts and their current status | ||
exports.scripts = {}; // Check for existing <script> tags with this src. If so, update scripts[src] | ||
// and return the new status; otherwise, return undefined. | ||
var checkExisting = function (src) { | ||
var existing = document.querySelector("script[src=\"" + src + "\"]"); | ||
if (existing) { | ||
// Assume existing <script> tag is already loaded, | ||
// and cache that data for future use. | ||
return exports.scripts[src] = { | ||
loading: false, | ||
error: null, | ||
scriptEl: existing | ||
}; | ||
} | ||
return undefined; | ||
}; | ||
function useScript(_a) { | ||
@@ -195,9 +204,17 @@ var src = _a.src, | ||
checkForExisting = _b === void 0 ? false : _b, | ||
attributes = __rest(_a, ["src", "checkForExisting"]); | ||
attributes = __rest(_a, ["src", "checkForExisting"]); // Check whether some instance of this hook considered this src. | ||
var _c = (0, react__default.useState)(Boolean(src)), | ||
var status = src ? exports.scripts[src] : undefined; // If requested, check for existing <script> tags with this src | ||
// (unless we've already loaded the script ourselves). | ||
if (!status && checkForExisting && src && isBrowser) { | ||
status = checkExisting(src); | ||
} | ||
var _c = (0, react__default.useState)(status ? status.loading : Boolean(src)), | ||
loading = _c[0], | ||
setLoading = _c[1]; | ||
var _d = (0, react__default.useState)(null), | ||
var _d = (0, react__default.useState)(status ? status.error : null), | ||
error = _d[0], | ||
@@ -207,26 +224,40 @@ setError = _d[1]; | ||
(0, react__default.useEffect)(function () { | ||
if (!isBrowser || !src) return; | ||
// Nothing to do on server, or if no src specified, or | ||
// if loading has already resolved to "loaded" or "error" state. | ||
if (!isBrowser || !src || !loading || error) return; // Check again for existing <script> tags with this src | ||
// in case it's changed since mount. | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
if (checkForExisting) { | ||
var existing = document.querySelector("script[src=\"" + src + "\"]"); | ||
status = exports.scripts[src]; | ||
if (existing) { | ||
setLoading(existing.getAttribute('data-status') === 'loading'); | ||
return; | ||
} | ||
} | ||
if (!status && checkForExisting) { | ||
status = checkExisting(src); | ||
} // Determine or create <script> element to listen to. | ||
var scriptEl = document.createElement('script'); | ||
scriptEl.setAttribute('src', src); | ||
scriptEl.setAttribute('data-status', 'loading'); | ||
Object.keys(attributes).forEach(function (key) { | ||
if (scriptEl[key] === undefined) { | ||
scriptEl.setAttribute(key, attributes[key]); | ||
} else { | ||
scriptEl[key] = attributes[key]; | ||
} | ||
}); | ||
var scriptEl; | ||
if (status) { | ||
scriptEl = status.scriptEl; | ||
} else { | ||
scriptEl = document.createElement('script'); | ||
scriptEl.src = src; | ||
Object.keys(attributes).forEach(function (key) { | ||
if (scriptEl[key] === undefined) { | ||
scriptEl.setAttribute(key, attributes[key]); | ||
} else { | ||
scriptEl[key] = attributes[key]; | ||
} | ||
}); | ||
status = exports.scripts[src] = { | ||
loading: true, | ||
error: null, | ||
scriptEl: scriptEl | ||
}; | ||
} // `status` is now guaranteed to be defined: either the old status | ||
// from a previous load, or a newly created one. | ||
var handleLoad = function () { | ||
scriptEl.setAttribute('data-status', 'ready'); | ||
if (status) status.loading = false; | ||
setLoading(false); | ||
@@ -236,3 +267,3 @@ }; | ||
var handleError = function (error) { | ||
scriptEl.setAttribute('data-status', 'error'); | ||
if (status) status.error = error; | ||
setError(error); | ||
@@ -248,3 +279,2 @@ }; | ||
}; // we need to ignore the attributes as they're a new object per call, so we'd never skip an effect call | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [src]); | ||
@@ -259,2 +289,3 @@ return [loading, error]; | ||
unwrapExports(useScript_1); | ||
var useScript_2 = useScript_1.scripts; | ||
@@ -272,3 +303,3 @@ var lib = createCommonjsModule(function (module, exports) { | ||
}); | ||
exports.default = void 0; | ||
exports.scripts = exports.default = void 0; | ||
@@ -283,5 +314,12 @@ | ||
}); | ||
Object.defineProperty(exports, "scripts", { | ||
enumerable: true, | ||
get: function () { | ||
return useScript_1.scripts; | ||
} | ||
}); | ||
}); | ||
var useScript = unwrapExports(lib); | ||
var lib_1 = lib.scripts; | ||
@@ -399,6 +437,6 @@ var renameKeyInObject = function renameKeyInObject(o, oldKey, newKey) { | ||
return; | ||
} // If the token is undefined, return prematurely | ||
} // If the token and publicKey is undefined, return prematurely | ||
if (!options.token) { | ||
if (!options.token && !options.publicKey) { | ||
return; | ||
@@ -438,3 +476,3 @@ } | ||
}; | ||
}, [loading, error, options.token, products]); | ||
}, [loading, error, options.publicKey, options.token, products]); | ||
var ready = plaid != null && (!loading || iframeLoaded); | ||
@@ -441,0 +479,0 @@ |
@@ -52,3 +52,3 @@ /// <reference types="react" /> | ||
type PlaidLinkOnSuccess = (public_token: string, metadata: PlaidLinkOnSuccessMetadata) => void; | ||
type PlaidLinkOnExit = (error: null | PlaidLinkError, metadata: PlaidLinkOnExitMetadata) => void; // The following event names are stable and will not be deprecated or changed | ||
type PlaidLinkOnExit = (error: null | PlaidLinkError, metadata: PlaidLinkOnExitMetadata) => void; | ||
// The following event names are stable and will not be deprecated or changed | ||
@@ -82,6 +82,3 @@ declare enum PlaidLinkStableEvent { | ||
onEvent?: PlaidLinkOnEvent; | ||
} /** | ||
* @deprecated Public key integrations are deprecated and should not be used. | ||
* https://plaid.com/docs/link/link-token-migration-guide/ | ||
*/ | ||
} | ||
/** | ||
@@ -132,4 +129,3 @@ * @deprecated Public key integrations are deprecated and should not be used. | ||
receivedRedirectUri?: string; | ||
}; // Either the publicKey or the token field must be configured. The publicKey | ||
// is deprecated so prefer to initialize Link with a Link Token instead. | ||
}; | ||
// Either the publicKey or the token field must be configured. The publicKey | ||
@@ -136,0 +132,0 @@ // is deprecated so prefer to initialize Link with a Link Token instead. |
@@ -14,10 +14,5 @@ (function (global, factory) { | ||
var symbols = Object.getOwnPropertySymbols(object); | ||
if (enumerableOnly) { | ||
symbols = symbols.filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
}); | ||
} | ||
keys.push.apply(keys, symbols); | ||
enumerableOnly && (symbols = symbols.filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
})), keys.push.apply(keys, symbols); | ||
} | ||
@@ -30,15 +25,8 @@ | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
if (i % 2) { | ||
ownKeys(Object(source), true).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} else if (Object.getOwnPropertyDescriptors) { | ||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); | ||
} else { | ||
ownKeys(Object(source)).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
}); | ||
} | ||
var source = null != arguments[i] ? arguments[i] : {}; | ||
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
}); | ||
} | ||
@@ -109,3 +97,3 @@ | ||
function _iterableToArrayLimit(arr, i) { | ||
var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]); | ||
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; | ||
@@ -186,5 +174,26 @@ if (_i == null) return; | ||
}); | ||
exports.scripts = void 0; | ||
// Previously loading/loaded scripts and their current status | ||
exports.scripts = {}; // Check for existing <script> tags with this src. If so, update scripts[src] | ||
// and return the new status; otherwise, return undefined. | ||
var checkExisting = function (src) { | ||
var existing = document.querySelector("script[src=\"" + src + "\"]"); | ||
if (existing) { | ||
// Assume existing <script> tag is already loaded, | ||
// and cache that data for future use. | ||
return exports.scripts[src] = { | ||
loading: false, | ||
error: null, | ||
scriptEl: existing | ||
}; | ||
} | ||
return undefined; | ||
}; | ||
function useScript(_a) { | ||
@@ -194,9 +203,17 @@ var src = _a.src, | ||
checkForExisting = _b === void 0 ? false : _b, | ||
attributes = __rest(_a, ["src", "checkForExisting"]); | ||
attributes = __rest(_a, ["src", "checkForExisting"]); // Check whether some instance of this hook considered this src. | ||
var _c = (0, react__default.useState)(Boolean(src)), | ||
var status = src ? exports.scripts[src] : undefined; // If requested, check for existing <script> tags with this src | ||
// (unless we've already loaded the script ourselves). | ||
if (!status && checkForExisting && src && isBrowser) { | ||
status = checkExisting(src); | ||
} | ||
var _c = (0, react__default.useState)(status ? status.loading : Boolean(src)), | ||
loading = _c[0], | ||
setLoading = _c[1]; | ||
var _d = (0, react__default.useState)(null), | ||
var _d = (0, react__default.useState)(status ? status.error : null), | ||
error = _d[0], | ||
@@ -206,26 +223,40 @@ setError = _d[1]; | ||
(0, react__default.useEffect)(function () { | ||
if (!isBrowser || !src) return; | ||
// Nothing to do on server, or if no src specified, or | ||
// if loading has already resolved to "loaded" or "error" state. | ||
if (!isBrowser || !src || !loading || error) return; // Check again for existing <script> tags with this src | ||
// in case it's changed since mount. | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
if (checkForExisting) { | ||
var existing = document.querySelector("script[src=\"" + src + "\"]"); | ||
status = exports.scripts[src]; | ||
if (existing) { | ||
setLoading(existing.getAttribute('data-status') === 'loading'); | ||
return; | ||
} | ||
} | ||
if (!status && checkForExisting) { | ||
status = checkExisting(src); | ||
} // Determine or create <script> element to listen to. | ||
var scriptEl = document.createElement('script'); | ||
scriptEl.setAttribute('src', src); | ||
scriptEl.setAttribute('data-status', 'loading'); | ||
Object.keys(attributes).forEach(function (key) { | ||
if (scriptEl[key] === undefined) { | ||
scriptEl.setAttribute(key, attributes[key]); | ||
} else { | ||
scriptEl[key] = attributes[key]; | ||
} | ||
}); | ||
var scriptEl; | ||
if (status) { | ||
scriptEl = status.scriptEl; | ||
} else { | ||
scriptEl = document.createElement('script'); | ||
scriptEl.src = src; | ||
Object.keys(attributes).forEach(function (key) { | ||
if (scriptEl[key] === undefined) { | ||
scriptEl.setAttribute(key, attributes[key]); | ||
} else { | ||
scriptEl[key] = attributes[key]; | ||
} | ||
}); | ||
status = exports.scripts[src] = { | ||
loading: true, | ||
error: null, | ||
scriptEl: scriptEl | ||
}; | ||
} // `status` is now guaranteed to be defined: either the old status | ||
// from a previous load, or a newly created one. | ||
var handleLoad = function () { | ||
scriptEl.setAttribute('data-status', 'ready'); | ||
if (status) status.loading = false; | ||
setLoading(false); | ||
@@ -235,3 +266,3 @@ }; | ||
var handleError = function (error) { | ||
scriptEl.setAttribute('data-status', 'error'); | ||
if (status) status.error = error; | ||
setError(error); | ||
@@ -247,3 +278,2 @@ }; | ||
}; // we need to ignore the attributes as they're a new object per call, so we'd never skip an effect call | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [src]); | ||
@@ -258,2 +288,3 @@ return [loading, error]; | ||
unwrapExports(useScript_1); | ||
var useScript_2 = useScript_1.scripts; | ||
@@ -271,3 +302,3 @@ var lib = createCommonjsModule(function (module, exports) { | ||
}); | ||
exports.default = void 0; | ||
exports.scripts = exports.default = void 0; | ||
@@ -282,5 +313,12 @@ | ||
}); | ||
Object.defineProperty(exports, "scripts", { | ||
enumerable: true, | ||
get: function () { | ||
return useScript_1.scripts; | ||
} | ||
}); | ||
}); | ||
var useScript = unwrapExports(lib); | ||
var lib_1 = lib.scripts; | ||
@@ -398,6 +436,6 @@ var renameKeyInObject = function renameKeyInObject(o, oldKey, newKey) { | ||
return; | ||
} // If the token is undefined, return prematurely | ||
} // If the token and publicKey is undefined, return prematurely | ||
if (!options.token) { | ||
if (!options.token && !options.publicKey) { | ||
return; | ||
@@ -437,3 +475,3 @@ } | ||
}; | ||
}, [loading, error, options.token, products]); | ||
}, [loading, error, options.publicKey, options.token, products]); | ||
var ready = plaid != null && (!loading || iframeLoaded); | ||
@@ -440,0 +478,0 @@ |
@@ -52,3 +52,3 @@ /// <reference types="react" /> | ||
type PlaidLinkOnSuccess = (public_token: string, metadata: PlaidLinkOnSuccessMetadata) => void; | ||
type PlaidLinkOnExit = (error: null | PlaidLinkError, metadata: PlaidLinkOnExitMetadata) => void; // The following event names are stable and will not be deprecated or changed | ||
type PlaidLinkOnExit = (error: null | PlaidLinkError, metadata: PlaidLinkOnExitMetadata) => void; | ||
// The following event names are stable and will not be deprecated or changed | ||
@@ -82,6 +82,3 @@ declare enum PlaidLinkStableEvent { | ||
onEvent?: PlaidLinkOnEvent; | ||
} /** | ||
* @deprecated Public key integrations are deprecated and should not be used. | ||
* https://plaid.com/docs/link/link-token-migration-guide/ | ||
*/ | ||
} | ||
/** | ||
@@ -132,4 +129,3 @@ * @deprecated Public key integrations are deprecated and should not be used. | ||
receivedRedirectUri?: string; | ||
}; // Either the publicKey or the token field must be configured. The publicKey | ||
// is deprecated so prefer to initialize Link with a Link Token instead. | ||
}; | ||
// Either the publicKey or the token field must be configured. The publicKey | ||
@@ -136,0 +132,0 @@ // is deprecated so prefer to initialize Link with a Link Token instead. |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e=e||self).PlaidLink={},e.React)}(this,(function(e,t){"use strict";var n="default"in t?t.default:t;function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){i(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function l(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==n)return;var r,o,i=[],a=!0,l=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){l=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(l)throw o}}return i}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return u(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function d(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function f(e,t){return e(t={exports:{}},t.exports),t.exports}var s=f((function(e,t){var r=c&&c.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){var t=e.src,i=e.checkForExisting,a=void 0!==i&&i,l=r(e,["src","checkForExisting"]),u=(0,n.useState)(Boolean(t)),c=u[0],d=u[1],f=(0,n.useState)(null),s=f[0],p=f[1];return(0,n.useEffect)((function(){if(o&&t){if(a){var e=document.querySelector('script[src="'+t+'"]');if(e)return void d("loading"===e.getAttribute("data-status"))}var n=document.createElement("script");n.setAttribute("src",t),n.setAttribute("data-status","loading"),Object.keys(l).forEach((function(e){void 0===n[e]?n.setAttribute(e,l[e]):n[e]=l[e]}));var r=function(){n.setAttribute("data-status","ready"),d(!1)},i=function(e){n.setAttribute("data-status","error"),p(e)};return n.addEventListener("load",r),n.addEventListener("error",i),document.body.appendChild(n),function(){n.removeEventListener("load",r),n.removeEventListener("error",i)}}}),[t]),[c,s]};var o="undefined"!=typeof window&&void 0!==window.document}));d(s);var p,b=d(f((function(e,t){var n=c&&c.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(s).default}})}))),y=function(e){var t={plaid:null,open:!1,onExitCallback:null};if("undefined"==typeof window||!window.Plaid)throw new Error("Plaid not loaded");var n,r,a,l,u=(n=e,r="publicKey",a="key",l={},delete Object.assign(l,n,i({},a,n[r]))[r],l);t.plaid=window.Plaid.create(o(o({},u),{},{onExit:function(e,n){t.open=!1,u.onExit&&u.onExit(e,n),t.onExitCallback&&t.onExitCallback()}}));return{open:function(){t.plaid&&(t.open=!0,t.onExitCallback=null,t.plaid.open())},exit:function(e,n){t.open&&t.plaid?(t.onExitCallback=n,t.plaid.exit(e),e&&e.force&&(t.open=!1)):n&&n()},destroy:function(){t.plaid&&(t.plaid.destroy(),t.plaid=null)}}},O=function(){},v=function(e){var n=l(b({src:"https://cdn.plaid.com/link/v2/stable/link-initialize.js",checkForExisting:!0}),2),r=n[0],i=n[1],a=l(t.useState(null),2),u=a[0],c=a[1],d=l(t.useState(!1),2),f=d[0],s=d[1],p=(e.product||[]).slice().sort().join(",");t.useEffect((function(){if(!r&&e.token){if(!i&&window.Plaid){null!=u&&u.exit({force:!0},(function(){return u.destroy()}));var t=y(o(o({},e),{},{onLoad:function(){s(!0),e.onLoad&&e.onLoad()}}));return c(t),function(){return t.exit({force:!0},(function(){return t.destroy()}))}}console.error("Error loading Plaid",i)}}),[r,i,e.token,p]);return{error:i,ready:null!=u&&(!r||f),exit:u?u.exit:O,open:u?u.open:function(){e.token||console.warn("react-plaid-link: You cannot call open() without a valid token supplied to usePlaidLink. This is a no-op.")}}},E=["children","style","className"],m=function(e){var t=e.children,r=e.style,i=e.className,l=a(e,E),u=v(o({},l)),c=u.error,d=u.open;return n.createElement("button",{disabled:Boolean(c),type:"button",className:i,style:o({padding:"6px 4px",outline:"none",background:"#FFFFFF",border:"2px solid #F1F1F1",borderRadius:"4px"},r),onClick:function(){return d()}},t)};m.displayName="PlaidLink",(p=e.PlaidLinkStableEvent||(e.PlaidLinkStableEvent={})).OPEN="OPEN",p.EXIT="EXIT",p.HANDOFF="HANDOFF",p.SELECT_INSTITUTION="SELECT_INSTITUTION",p.ERROR="ERROR",e.PlaidLink=m,e.usePlaidLink=v,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e=e||self).PlaidLink={},e.React)}(this,(function(e,t){"use strict";var n="default"in t?t.default:t;function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){i(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function a(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var r,o,i=[],l=!0,a=!1;try{for(n=n.call(e);!(l=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);l=!0);}catch(e){a=!0,o=e}finally{try{l||null==n.return||n.return()}finally{if(a)throw o}}return i}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return u(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function d(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function f(e,t){return e(t={exports:{}},t.exports),t.exports}var s=f((function(e,t){var r=c&&c.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.scripts=void 0,t.scripts={};var o=function(e){var n=document.querySelector('script[src="'+e+'"]');if(n)return t.scripts[e]={loading:!1,error:null,scriptEl:n}};t.default=function(e){var l=e.src,a=e.checkForExisting,u=void 0!==a&&a,c=r(e,["src","checkForExisting"]),d=l?t.scripts[l]:void 0;!d&&u&&l&&i&&(d=o(l));var f=(0,n.useState)(d?d.loading:Boolean(l)),s=f[0],p=f[1],y=(0,n.useState)(d?d.error:null),b=y[0],v=y[1];return(0,n.useEffect)((function(){if(i&&l&&s&&!b){var e;!(d=t.scripts[l])&&u&&(d=o(l)),d?e=d.scriptEl:((e=document.createElement("script")).src=l,Object.keys(c).forEach((function(t){void 0===e[t]?e.setAttribute(t,c[t]):e[t]=c[t]})),d=t.scripts[l]={loading:!0,error:null,scriptEl:e});var n=function(){d&&(d.loading=!1),p(!1)},r=function(e){d&&(d.error=e),v(e)};return e.addEventListener("load",n),e.addEventListener("error",r),document.body.appendChild(e),function(){e.removeEventListener("load",n),e.removeEventListener("error",r)}}}),[l]),[s,b]};var i="undefined"!=typeof window&&void 0!==window.document}));d(s);s.scripts;var p,y=f((function(e,t){var n=c&&c.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.scripts=t.default=void 0,Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(s).default}}),Object.defineProperty(t,"scripts",{enumerable:!0,get:function(){return s.scripts}})})),b=d(y),v=(y.scripts,function(e){var t={plaid:null,open:!1,onExitCallback:null};if("undefined"==typeof window||!window.Plaid)throw new Error("Plaid not loaded");var n,r,l,a,u=(n=e,r="publicKey",l="key",a={},delete Object.assign(a,n,i({},l,n[r]))[r],a);t.plaid=window.Plaid.create(o(o({},u),{},{onExit:function(e,n){t.open=!1,u.onExit&&u.onExit(e,n),t.onExitCallback&&t.onExitCallback()}}));return{open:function(){t.plaid&&(t.open=!0,t.onExitCallback=null,t.plaid.open())},exit:function(e,n){t.open&&t.plaid?(t.onExitCallback=n,t.plaid.exit(e),e&&e.force&&(t.open=!1)):n&&n()},destroy:function(){t.plaid&&(t.plaid.destroy(),t.plaid=null)}}}),O=function(){},E=function(e){var n=a(b({src:"https://cdn.plaid.com/link/v2/stable/link-initialize.js",checkForExisting:!0}),2),r=n[0],i=n[1],l=a(t.useState(null),2),u=l[0],c=l[1],d=a(t.useState(!1),2),f=d[0],s=d[1],p=(e.product||[]).slice().sort().join(",");t.useEffect((function(){if(!r&&(e.token||e.publicKey)){if(!i&&window.Plaid){null!=u&&u.exit({force:!0},(function(){return u.destroy()}));var t=v(o(o({},e),{},{onLoad:function(){s(!0),e.onLoad&&e.onLoad()}}));return c(t),function(){return t.exit({force:!0},(function(){return t.destroy()}))}}console.error("Error loading Plaid",i)}}),[r,i,e.publicKey,e.token,p]);return{error:i,ready:null!=u&&(!r||f),exit:u?u.exit:O,open:u?u.open:function(){e.token||console.warn("react-plaid-link: You cannot call open() without a valid token supplied to usePlaidLink. This is a no-op.")}}},g=["children","style","className"],m=function(e){var t=e.children,r=e.style,i=e.className,a=l(e,g),u=E(o({},a)),c=u.error,d=u.open;return n.createElement("button",{disabled:Boolean(c),type:"button",className:i,style:o({padding:"6px 4px",outline:"none",background:"#FFFFFF",border:"2px solid #F1F1F1",borderRadius:"4px"},r),onClick:function(){return d()}},t)};m.displayName="PlaidLink",(p=e.PlaidLinkStableEvent||(e.PlaidLinkStableEvent={})).OPEN="OPEN",p.EXIT="EXIT",p.HANDOFF="HANDOFF",p.SELECT_INSTITUTION="SELECT_INSTITUTION",p.ERROR="ERROR",e.PlaidLink=m,e.usePlaidLink=E,Object.defineProperty(e,"__esModule",{value:!0})})); |
{ | ||
"name": "react-plaid-link", | ||
"version": "3.3.0", | ||
"version": "3.3.1", | ||
"description": "A React component for Plaid Link", | ||
@@ -36,2 +36,3 @@ "registry": "https://registry.npmjs.org", | ||
"lint": "eslint '{src,examples}/**/*.{ts,tsx,js,jsx}' --ignore-path .gitignore", | ||
"test": "NODE_ENV=test BABEL_ENV=testing jest", | ||
"storybook": "start-storybook -p 9001", | ||
@@ -48,3 +49,3 @@ "deploy-storybook": "storybook-to-ghpages", | ||
"prop-types": "^15.7.2", | ||
"react-script-hook": "1.5.0" | ||
"react-script-hook": "^1.6.0" | ||
}, | ||
@@ -61,2 +62,3 @@ "peerDependencies": { | ||
"@babel/preset-react": "^7.14.3", | ||
"@babel/preset-typescript": "^7.16.7", | ||
"@storybook/addon-actions": "^5.3.17", | ||
@@ -70,2 +72,5 @@ "@storybook/addon-console": "^1.2.1", | ||
"@storybook/storybook-deployer": "^2.8.3", | ||
"@testing-library/react": "^12.1.4", | ||
"@testing-library/react-hooks": "^7.0.2", | ||
"@types/jest": "^27.4.1", | ||
"@types/react": "^17.0.9", | ||
@@ -89,2 +94,3 @@ "@types/react-dom": "^17.0.6", | ||
"husky": "^4.2.3", | ||
"jest": "^27.5.1", | ||
"mocha": "2.3.x", | ||
@@ -91,0 +97,0 @@ "prettier": "^1.19.1", |
@@ -43,4 +43,7 @@ import { useEffect, useState } from 'react'; | ||
// If the token is undefined, return prematurely | ||
if (!options.token) { | ||
// If the token and publicKey is undefined, return prematurely | ||
if ( | ||
!options.token && | ||
!(options as PlaidLinkOptionsWithPublicKey).publicKey | ||
) { | ||
return; | ||
@@ -73,3 +76,9 @@ } | ||
return () => next.exit({ force: true }, () => next.destroy()); | ||
}, [loading, error, options.token, products]); | ||
}, [ | ||
loading, | ||
error, | ||
(options as PlaidLinkOptionsWithPublicKey).publicKey, | ||
options.token, | ||
products, | ||
]); | ||
@@ -76,0 +85,0 @@ const ready = plaid != null && (!loading || iframeLoaded); |
103282
2395
51
+ Addedreact-script-hook@1.7.2(transitive)
- Removedreact-script-hook@1.5.0(transitive)
Updatedreact-script-hook@^1.6.0