New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@clerk/clerk-react

Package Overview
Dependencies
Maintainers
8
Versions
2619
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@clerk/clerk-react - npm Package Compare versions

Comparing version 2.3.0 to 2.3.1-staging.0

dist/components/SignInButton.d.ts

202

dist/clerk-react.cjs.development.js

@@ -91,3 +91,3 @@ 'use strict';

var version = "2.3.0";
var version = "2.3.1-staging.0";

@@ -183,2 +183,5 @@ var FAILED_TO_LOAD_ERROR = 'Clerk: Failed to load Clerk';

var hocChildrenNotAFunctionError = 'Clerk: Child of WithClerk must be a function.';
var multipleChildrenInButtonComponent = function multipleChildrenInButtonComponent(name) {
return "Clerk: You've passed multiple children components to <" + name + "/>. You can only pass a single child component or text.";
};
var MagicLinkErrorCode = {

@@ -192,2 +195,30 @@ Expired: 'expired',

var assertSingleChild = function assertSingleChild(children) {
return function (name) {
try {
return React__default.Children.only(children);
} catch (e) {
throw new Error(multipleChildrenInButtonComponent(name));
}
};
};
var normalizeWithDefaultValue = function normalizeWithDefaultValue(children, defaultText) {
if (!children) {
children = defaultText;
}
if (typeof children === 'string') {
children = React__default.createElement("button", null, children);
}
return children;
};
var safeExecute = function safeExecute(cb) {
return function () {
if (cb && typeof cb === 'function') {
return cb.apply(void 0, arguments);
}
};
};
var IsomorphicClerk = /*#__PURE__*/function () {

@@ -414,7 +445,7 @@ function IsomorphicClerk(frontendApi, options, Clerk) {

this.redirectToSignIn = function (returnBack) {
this.redirectToSignIn = function (opts) {
var callback = function callback() {
var _this2$clerkjs3;
return (_this2$clerkjs3 = _this2.clerkjs) === null || _this2$clerkjs3 === void 0 ? void 0 : _this2$clerkjs3.redirectToSignIn(returnBack);
return (_this2$clerkjs3 = _this2.clerkjs) === null || _this2$clerkjs3 === void 0 ? void 0 : _this2$clerkjs3.redirectToSignIn(opts);
};

@@ -429,7 +460,7 @@

this.redirectToSignUp = function (returnBack) {
this.redirectToSignUp = function (opts) {
var callback = function callback() {
var _this2$clerkjs4;
return (_this2$clerkjs4 = _this2.clerkjs) === null || _this2$clerkjs4 === void 0 ? void 0 : _this2$clerkjs4.redirectToSignUp(returnBack);
return (_this2$clerkjs4 = _this2.clerkjs) === null || _this2$clerkjs4 === void 0 ? void 0 : _this2$clerkjs4.redirectToSignUp(opts);
};

@@ -1231,6 +1262,18 @@

return userCtx.value === undefined ? React__default.createElement(React__default.Fragment, null, children) : null;
};
}; // DX: returnBack deprecated <=2.4.2
// Deprecate the boolean type before removing returnBack
var RedirectToSignIn = /*#__PURE__*/withClerk(function (_ref5) {
var clerk = _ref5.clerk,
returnBack = _ref5.returnBack;
props = _objectWithoutPropertiesLoose(_ref5, ["clerk"]);
var returnBack = props.returnBack,
afterSignUpUrl = props.afterSignUpUrl,
redirectUrl = props.redirectUrl,
afterSignInUrl = props.afterSignInUrl;
var redirectOptions = {
afterSignUpUrl: afterSignUpUrl,
redirectUrl: redirectUrl,
afterSignInUrl: afterSignInUrl
};
var client = clerk.client,

@@ -1246,12 +1289,24 @@ session = clerk.session; // TODO: Remove temp use of __unstable__environment

} else {
clerk.redirectToSignIn(returnBack);
void clerk.redirectToSignIn(returnBack || redirectOptions);
}
}, []);
return null;
}, 'RedirectToSignIn');
}, 'RedirectToSignIn'); // DX: returnBack deprecated <=2.4.2
// Deprecate the boolean type before removing returnBack
var RedirectToSignUp = /*#__PURE__*/withClerk(function (_ref6) {
var clerk = _ref6.clerk,
returnBack = _ref6.returnBack;
props = _objectWithoutPropertiesLoose(_ref6, ["clerk"]);
var returnBack = props.returnBack,
afterSignUpUrl = props.afterSignUpUrl,
redirectUrl = props.redirectUrl,
afterSignInUrl = props.afterSignInUrl;
var redirectOptions = {
afterSignUpUrl: afterSignUpUrl,
redirectUrl: redirectUrl,
afterSignInUrl: afterSignInUrl
};
React__default.useEffect(function () {
clerk.redirectToSignUp(returnBack);
void clerk.redirectToSignUp(returnBack || redirectOptions);
}, []);

@@ -1277,2 +1332,124 @@ return null;

var SignInButton = /*#__PURE__*/withClerk(function (_ref) {
var clerk = _ref.clerk,
children = _ref.children,
props = _objectWithoutPropertiesLoose(_ref, ["clerk", "children"]);
var afterSignInUrl = props.afterSignInUrl,
afterSignUpUrl = props.afterSignUpUrl,
redirectUrl = props.redirectUrl,
mode = props.mode,
rest = _objectWithoutPropertiesLoose(props, ["afterSignInUrl", "afterSignUpUrl", "redirectUrl", "mode"]);
children = normalizeWithDefaultValue(children, 'Sign in');
var child = assertSingleChild(children)('SignInButton');
var clickHandler = function clickHandler() {
var opts = {
afterSignInUrl: afterSignInUrl,
afterSignUpUrl: afterSignUpUrl,
redirectUrl: redirectUrl
};
if (mode === 'modal') {
return clerk.openSignIn(opts);
}
return clerk.redirectToSignIn(opts);
};
var wrappedChildClickHandler = function wrappedChildClickHandler(e) {
try {
return Promise.resolve(safeExecute(child.props.onClick)(e)).then(function () {
return clickHandler();
});
} catch (e) {
return Promise.reject(e);
}
};
var childProps = _extends({}, rest, {
onClick: wrappedChildClickHandler
});
return React__default.cloneElement(child, childProps);
}, 'SignInButton');
var SignUpButton = /*#__PURE__*/withClerk(function (_ref) {
var clerk = _ref.clerk,
children = _ref.children,
props = _objectWithoutPropertiesLoose(_ref, ["clerk", "children"]);
var afterSignInUrl = props.afterSignInUrl,
afterSignUpUrl = props.afterSignUpUrl,
redirectUrl = props.redirectUrl,
mode = props.mode,
rest = _objectWithoutPropertiesLoose(props, ["afterSignInUrl", "afterSignUpUrl", "redirectUrl", "mode"]);
children = normalizeWithDefaultValue(children, 'Sign up');
var child = assertSingleChild(children)('SignUpButton');
var clickHandler = function clickHandler() {
var opts = {
afterSignInUrl: afterSignInUrl,
afterSignUpUrl: afterSignUpUrl,
redirectUrl: redirectUrl
};
if (mode === 'modal') {
return clerk.openSignUp(opts);
}
return clerk.redirectToSignUp(opts);
};
var wrappedChildClickHandler = function wrappedChildClickHandler(e) {
try {
return Promise.resolve(safeExecute(child.props.onClick)(e)).then(function () {
return clickHandler();
});
} catch (e) {
return Promise.reject(e);
}
};
var childProps = _extends({}, rest, {
onClick: wrappedChildClickHandler
});
return React__default.cloneElement(child, childProps);
}, 'SignUpButton');
var SignOutButton = /*#__PURE__*/withClerk(function (_ref) {
var clerk = _ref.clerk,
children = _ref.children,
props = _objectWithoutPropertiesLoose(_ref, ["clerk", "children"]);
var signOutCallback = props.signOutCallback,
rest = _objectWithoutPropertiesLoose(props, ["signOutCallback"]);
children = normalizeWithDefaultValue(children, 'Sign out');
var child = assertSingleChild(children)('SignOutButton');
var clickHandler = function clickHandler() {
return clerk.signOutOne(signOutCallback);
};
var wrappedChildClickHandler = function wrappedChildClickHandler(e) {
try {
return Promise.resolve(safeExecute(child.props.onClick)(e)).then(function () {
return clickHandler();
});
} catch (e) {
return Promise.reject(e);
}
};
var childProps = _extends({}, rest, {
onClick: wrappedChildClickHandler
});
return React__default.cloneElement(child, childProps);
}, 'SignOutButton');
exports.AuthenticateWithRedirectCallback = AuthenticateWithRedirectCallback;

@@ -1287,3 +1464,6 @@ exports.ClerkLoaded = ClerkLoaded;

exports.SignIn = SignIn;
exports.SignInButton = SignInButton;
exports.SignOutButton = SignOutButton;
exports.SignUp = SignUp;
exports.SignUpButton = SignUpButton;
exports.SignedIn = SignedIn;

@@ -1290,0 +1470,0 @@ exports.SignedOut = SignedOut;

2

dist/clerk-react.cjs.production.min.js

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,n=require("react"),r=(e=n)&&"object"==typeof e&&"default"in e?e.default:e;function t(){return(t=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e}).apply(this,arguments)}function o(e,n){if(null==e)return{};var r,t,o={},i=Object.keys(e);for(t=0;t<i.length;t++)n.indexOf(r=i[t])>=0||(o[r]=e[r]);return o}function i(){return"undefined"!=typeof window}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var u=new Map;function s(e,n,o){var i=function(i){return function(e,n,t){void 0===t&&(t=1),r.useEffect((function(){var r=u.get(e)||0;if(r==t)throw new Error(n);return u.set(e,r+1),function(){u.set(e,(u.get(e)||1)-1)}}),[])}(n,o),r.createElement(e,t({},i))};return i.displayName="withMaxAllowedInstancesGuard("+(e.displayName||e.name||n||"Component")+")",i}var l={Expired:"expired",Failed:"failed"},a=function(){function e(e,n,r){var t=this,o=this,u=this,s=this,l=this;void 0===n&&(n={}),void 0===r&&(r=null),this.mode=void 0,this.frontendApi=void 0,this.options=void 0,this.Clerk=void 0,this.clerkjs=null,this.preopenSignIn=null,this.preopenSignUp=null,this.premountSignInNodes=new Map,this.premountSignUpNodes=new Map,this.premountUserProfileNodes=new Map,this.premountUserButtonNodes=new Map,this.premountMethodCalls=new Map,this._loaded=!1,this.ssrData=null,this.ssrClient=void 0,this.ssrSession=void 0,this.hydrateClerkJS=function(e){try{if(!e)throw new Error("Failed to hydrate latest Clerk JS");return o.clerkjs=e,o.premountMethodCalls.forEach((function(e){return e()})),null!==o.preopenSignIn&&e.openSignIn(o.preopenSignIn),null!==o.preopenSignUp&&e.openSignUp(o.preopenSignUp),o.premountSignInNodes.forEach((function(n,r){e.mountSignIn(r,n)})),o.premountSignUpNodes.forEach((function(n,r){e.mountSignUp(r,n)})),o.premountUserProfileNodes.forEach((function(n,r){e.mountUserProfile(r,n)})),o.premountUserButtonNodes.forEach((function(n,r){e.mountUserButton(r,n)})),o._loaded=!0,Promise.resolve(o.clerkjs)}catch(e){return Promise.reject(e)}},this.setSession=function(e,n){return t.clerkjs?t.clerkjs.setSession(e,n):Promise.reject()},this.openSignIn=function(e){t.clerkjs&&t._loaded?t.clerkjs.openSignIn(e):t.preopenSignIn=e},this.closeSignIn=function(){t.clerkjs&&t._loaded?t.clerkjs.closeSignIn():t.preopenSignIn=null},this.openSignUp=function(e){t.clerkjs&&t._loaded?t.clerkjs.openSignUp(e):t.preopenSignUp=e},this.closeSignUp=function(){t.clerkjs&&t._loaded?t.clerkjs.closeSignUp():t.preopenSignUp=null},this.mountSignIn=function(e,n){t.clerkjs&&t._loaded?t.clerkjs.mountSignIn(e,n):t.premountSignInNodes.set(e,n)},this.unmountSignIn=function(e){t.clerkjs&&t._loaded?t.clerkjs.unmountSignIn(e):t.premountSignInNodes.delete(e)},this.mountSignUp=function(e,n){t.clerkjs&&t._loaded?t.clerkjs.mountSignUp(e,n):t.premountSignUpNodes.set(e,n)},this.unmountSignUp=function(e){t.clerkjs&&t._loaded?t.clerkjs.unmountSignUp(e):t.premountSignUpNodes.delete(e)},this.mountUserProfile=function(e,n){t.clerkjs&&t._loaded?t.clerkjs.mountUserProfile(e,n):t.premountUserProfileNodes.set(e,n)},this.unmountUserProfile=function(e){t.clerkjs&&t._loaded?t.clerkjs.unmountUserProfile(e):t.premountUserProfileNodes.delete(e)},this.mountUserButton=function(e,n){t.clerkjs&&t._loaded?t.clerkjs.mountUserButton(e,n):t.premountUserButtonNodes.set(e,n)},this.unmountUserButton=function(e){t.clerkjs&&t._loaded?t.clerkjs.unmountUserButton(e):t.premountUserButtonNodes.delete(e)},this.addListener=function(e){var n=function(){var n;return null===(n=t.clerkjs)||void 0===n?void 0:n.addListener(e)};t.clerkjs?n():t.premountMethodCalls.set("addListener",n)},this.loadFromServer=function(e){"browser"===t.mode&&t.throwError("loadFromServer cannot be called in a browser context."),t.ssrData=JSON.stringify({client:t.client,session:t.session,token:e})},this.navigate=function(e){var n=function(){var n;return null===(n=t.clerkjs)||void 0===n?void 0:n.navigate(e)};t.clerkjs&&t._loaded?n():t.premountMethodCalls.set("navigate",n)},this.redirectToSignIn=function(e){var n=function(){var n;return null===(n=t.clerkjs)||void 0===n?void 0:n.redirectToSignIn(e)};t.clerkjs&&t._loaded?n():t.premountMethodCalls.set("redirectToSignIn",n)},this.redirectToSignUp=function(e){var n=function(){var n;return null===(n=t.clerkjs)||void 0===n?void 0:n.redirectToSignUp(e)};t.clerkjs&&t._loaded?n():t.premountMethodCalls.set("redirectToSignUp",n)},this.redirectToUserProfile=function(){var e=function(){var e;return null===(e=t.clerkjs)||void 0===e?void 0:e.redirectToUserProfile()};t.clerkjs&&t._loaded?e():t.premountMethodCalls.set("redirectToUserProfile",e)},this.handleRedirectCallback=function(e){var n=function(){var n;return null===(n=t.clerkjs)||void 0===n?void 0:n.handleRedirectCallback(e)};t.clerkjs&&t._loaded?n():t.premountMethodCalls.set("handleRedirectCallback",n)},this.handleMagicLinkVerification=function(e){try{var n=function(){var n;return null===(n=u.clerkjs)||void 0===n?void 0:n.handleMagicLinkVerification(e)};return u.clerkjs&&u._loaded?Promise.resolve(n()):(u.premountMethodCalls.set("handleMagicLinkVerification",n),Promise.resolve())}catch(e){return Promise.reject(e)}},this.signOut=function(e){try{var n=function(){var n;return null===(n=s.clerkjs)||void 0===n?void 0:n.signOut(e)};return s.clerkjs&&s._loaded?Promise.resolve(n()):(s.premountMethodCalls.set("signOut",n),Promise.resolve())}catch(e){return Promise.reject(e)}},this.signOutOne=function(e){try{var n=function(){var n;return null===(n=l.clerkjs)||void 0===n?void 0:n.signOutOne(e)};return l.clerkjs&&l._loaded?Promise.resolve(n()):(l.premountMethodCalls.set("signOutOne",n),Promise.resolve())}catch(e){return Promise.reject(e)}},this.frontendApi=e,this.options=n,this.Clerk=r,this.mode=i()?"browser":"server"}var n,r=e.prototype;return r.loadClerkJS=function(){try{var e=this;return e.frontendApi||e.throwError("Clerk: You must add the frontendApi prop to your <ClerkProvider>"),Promise.resolve(function(n,r){try{var t=function(){function n(n){return e.hydrateClerkJS(global.Clerk)}var r=function(){if(e.Clerk){var n,r=function(){global.Clerk=n},t=function(){if("function"==typeof e.Clerk)return n=new e.Clerk(e.frontendApi),Promise.resolve(n.load(e.options)).then((function(){}));n=e.Clerk;var r=function(){if(!n.isReady())return Promise.resolve(n.load(e.options)).then((function(){}))}();return r&&r.then?r.then((function(){})):void 0}();return t&&t.then?t.then(r):r()}return Promise.resolve((o=e.frontendApi,i=e.options.scriptUrl,new Promise((function(e,n){global.Clerk&&e(null),o||n("Clerk: Missing provider");var r=document.createElement("script"),t=function(e,n){if(n)return n;var r=function(e){return e.endsWith(".lclstage.dev")||e.endsWith(".stgstage.dev")||e.endsWith(".clerkstage.dev")}(e)?"staging":parseInt("2.3.0".split(".")[0],10);return"https://"+e+"/npm/@clerk/clerk-js@"+r+"/dist/clerk.browser.js"}(o,i);r.setAttribute("data-clerk-frontend-api",o),r.setAttribute("crossorigin","anonymous"),r.async=!0,document.body||n("Clerk: Missing <body> element."),r.addEventListener("load",(function(){return e(r)})),r.addEventListener("error",(function(){return n("Clerk: Failed to load Clerk")})),r.src=t,document.body.appendChild(r)})))).then((function(){if(!global.Clerk)throw new Error("Failed to download latest ClerkJS. Contact support@clerk.dev.");return Promise.resolve(global.Clerk.load(e.options)).then((function(){}))}));var o,i}();return r&&r.then?r.then(n):n()}()}catch(e){return r(e)}return t&&t.then?t.then(void 0,r):t}(0,(function(n){var r;r=n instanceof Error?n.message:String(n),e.throwError(r)})))}catch(e){return Promise.reject(e)}},r.throwError=function(e){throw console.error(e),new Error(e)},(n=[{key:"version",get:function(){var e;return null===(e=this.clerkjs)||void 0===e?void 0:e.version}},{key:"client",get:function(){return this.clerkjs?this.clerkjs.client:void 0}},{key:"session",get:function(){return this.clerkjs?this.clerkjs.session:void 0}},{key:"user",get:function(){return this.clerkjs?this.clerkjs.user:void 0}},{key:"__unstable__environment",get:function(){return this.clerkjs?this.clerkjs.__unstable__environment:void 0}}])&&function(e,n){for(var r=0;r<n.length;r++){var t=n[r];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,t.key,t)}}(e.prototype,n),e}();function c(e){if(!e)throw new Error("Clerk: You must wrap your application in a <ClerkProvider> component.")}function d(e,n){if(!e)throw new Error(function(e){return"Clerk: You're calling "+e+" before there's a guarantee the client has been loaded. Call "+e+" from a child of <SignedIn>, <SignedOut>, or <ClerkLoaded>, or use the withClerk() HOC."}(n))}function f(e,n){if(!e)throw new Error(function(e){return"Clerk: You're calling "+e+" before there's a guarantee there's an active user. Call "+e+" from a child of <SignedIn> or use the withUser() HOC."}(n))}var p=Object.freeze({noGuarantees:Object.freeze({guaranteedLoaded:!1,guaranteedUser:!1}),guaranteedLoaded:Object.freeze({guaranteedLoaded:!0,guaranteedUser:!1}),guaranteedAll:Object.freeze({guaranteedLoaded:!0,guaranteedUser:!0})}),v=r.createContext(void 0);v.displayName="StructureContext";var m=r.createContext(void 0);m.displayName="IsomorphicClerkContext";var h=function(e,o){e.displayName=o=o||e.displayName||e.name||"Component";var u=function(o){var u=n.useContext(v),s=n.useContext(m);if(!i())return null;c(u),c(s);var l=s.value;return l?u.guaranteedLoaded?r.createElement(e,t({},o,{clerk:l})):l.client?r.createElement(v.Provider,{value:p.guaranteedLoaded},r.createElement(e,t({},o,{clerk:l}))):null:null};return u.displayName="withClerk("+o+")",u},g=r.createContext(void 0);g.displayName="ClientContext";var k=r.createContext(void 0);k.displayName="SessionContext";var C=r.createContext(void 0);function S(){var e=n.useContext(C);return c(e),e}C.displayName="UserContext";var U=function(e,o){e.displayName=o=o||e.displayName||e.name||"Component";var u=function(o){var u=n.useContext(v),s=n.useContext(C);if(!i())return null;c(u),c(s);var l=s.value;return u.guaranteedUser&&l?r.createElement(e,t({},o,{user:l})):l?r.createElement(v.Provider,{value:p.guaranteedAll},r.createElement(e,t({},o,{user:l}))):null};return u.displayName="withUser("+o+")",u};function y(e){var n=e.children,o=e.clerkLoaded,i=e.isomorphicClerk,u=r.useState({client:i.client,session:i.session,user:i.user}),s=u[0],l=u[1];r.useEffect((function(){return i.addListener((function(e){return l(t({},e))}))}),[]);var a=s.client,c=s.session,d=s.user,f=r.useMemo((function(){return{value:i}}),[o]),p=r.useMemo((function(){return{value:a}}),[a]),v=r.useMemo((function(){return{value:c}}),[c]),h=r.useMemo((function(){return{value:d}}),[d]);return r.createElement(m.Provider,{value:f},r.createElement(g.Provider,{value:p},r.createElement(k.Provider,{value:v},r.createElement(C.Provider,{value:h},r.createElement(r.Fragment,{key:c?c.id:"no-users"},n)))))}function j(e){var t=n.useMemo((function(){var n=e.frontendApi,r=void 0===n?"":n,t=e.Clerk,i=o(e,["frontendApi","Clerk"]);return new a(r,i,t)}),[]),i=n.useState(!1),u=i[0],s=i[1];return n.useEffect((function(){t.loadClerkJS().then((function(){return s(!0)}))}),[]),r.createElement(v.Provider,{value:p.noGuarantees},t instanceof a&&t.ssrData&&r.createElement("script",{type:"application/json","data-clerk":"SSR",dangerouslySetInnerHTML:{__html:t.ssrData}}),r.createElement(y,{isomorphicClerk:t,clerkLoaded:u},e.children))}var E=s(j,"ClerkProvider","Clerk: You've added multiple <ClerkProvider> components in your React component tree. Wrap your components in a single <ClerkProvider>."),x=function(e){var n,t;function o(){for(var n,t=arguments.length,o=new Array(t),i=0;i<t;i++)o[i]=arguments[i];return(n=e.call.apply(e,[this].concat(o))||this).portalRef=r.createRef(),n}t=e,(n=o).prototype=Object.create(t.prototype),n.prototype.constructor=n,n.__proto__=t;var i=o.prototype;return i.componentDidMount=function(){this.portalRef.current&&this.props.mount(this.portalRef.current,this.props.props)},i.componentWillUnmount=function(){this.portalRef.current&&this.props.unmount(this.portalRef.current)},i.render=function(){return r.createElement("div",{ref:this.portalRef})},o}(r.PureComponent),w=h((function(e){var n=e.clerk,t=o(e,["clerk"]);return r.createElement(x,{mount:n.mountSignIn,unmount:n.unmountSignIn,props:t})}),"SignIn"),P=h((function(e){var n=e.clerk,t=o(e,["clerk"]);return r.createElement(x,{mount:n.mountSignUp,unmount:n.unmountSignUp,props:t})}),"SignUp"),b=h((function(e){var n=e.clerk,t=o(e,["clerk"]);return r.createElement(x,{mount:n.mountUserProfile,unmount:n.unmountUserProfile,props:t})}),"UserProfile"),I=h((function(e){var n=e.clerk,t=o(e,["clerk"]);return r.createElement(x,{mount:n.mountUserButton,unmount:n.unmountUserButton,props:t})}),"UserButton"),_=U((function(e){return r.createElement(r.Fragment,null,e.children)}),"SignedIn"),L=h((function(e){var n=e.children;return null===S().value?r.createElement(r.Fragment,null,n):null}),"SignedOut"),M=h((function(e){return r.createElement(r.Fragment,null,e.children)}),"ClerkLoaded"),N=h((function(e){var n=e.clerk,t=e.returnBack,o=n.client,i=n.session,u=n.__unstable__environment,s=o.activeSessions&&o.activeSessions.length>0;return r.useEffect((function(){null===i&&s&&u?n.navigate(u.displayConfig.afterSignOutOneUrl):n.redirectToSignIn(t)}),[]),null}),"RedirectToSignIn"),O=h((function(e){var n=e.clerk,t=e.returnBack;return r.useEffect((function(){n.redirectToSignUp(t)}),[]),null}),"RedirectToSignUp"),A=h((function(e){var n=e.clerk;return r.useEffect((function(){n.redirectToUserProfile()}),[]),null}),"RedirectToUserProfile");exports.AuthenticateWithRedirectCallback=h((function(e){var n=e.clerk,t=o(e,["clerk"]);return r.useEffect((function(){n.handleRedirectCallback(t)}),[]),null}),"AuthenticateWithRedirectCallback"),exports.ClerkLoaded=M,exports.ClerkLoading=function(e){var n=e.children;return void 0===S().value?r.createElement(r.Fragment,null,n):null},exports.ClerkProvider=E,exports.MagicLinkErrorCode=l,exports.RedirectToSignIn=N,exports.RedirectToSignUp=O,exports.RedirectToUserProfile=A,exports.SignIn=w,exports.SignUp=P,exports.SignedIn=_,exports.SignedOut=L,exports.UserButton=I,exports.UserProfile=b,exports.WithClerk=function(e){var n=e.children;return r.createElement(v.Consumer,null,(function(e){return r.createElement(m.Consumer,null,(function(t){if("function"!=typeof n)throw new Error("Clerk: Child of WithClerk must be a function.");c(e),c(t);var o=t.value;return o?e.guaranteedLoaded?n(o):o.client?r.createElement(v.Provider,{value:p.guaranteedLoaded},n(o)):null:null}))}))},exports.WithSession=function(e){var n=e.children;return r.createElement(v.Consumer,null,(function(e){return r.createElement(k.Consumer,null,(function(t){if("function"!=typeof n)throw new Error("Clerk: Child of WithClerk must be a function.");c(e),c(t);var o=t.value;return e.guaranteedUser&&o?n(o):o?r.createElement(v.Provider,{value:p.guaranteedAll},n(o)):null}))}))},exports.WithUser=function(e){var n=e.children;return r.createElement(v.Consumer,null,(function(e){return r.createElement(C.Consumer,null,(function(t){if("function"!=typeof n)throw new Error("Clerk: Child of WithClerk must be a function.");c(e),c(t);var o=t.value;return e.guaranteedUser&&o?n(o):o?r.createElement(v.Provider,{value:p.guaranteedAll},n(o)):null}))}))},exports.isMagicLinkError=function(e){return!!e&&(e.code===l.Expired||e.code===l.Failed)},exports.useClerk=function(){var e=n.useContext(v),r=n.useContext(m);return c(e),c(r),d(e.guaranteedLoaded,"useClerk()"),d(r.value,"useClerk()"),r.value},exports.useSession=function(e){var r=t({},e);r.withAssertions=r.withAssertions||!1;var o=n.useContext(v),i=function(){var e=n.useContext(k);return c(e),e}();return r.withAssertions?t({session:i.value},{isLoading:function(e){return void 0===e},isSignedOut:function(e){return null===e},isSignedIn:function(e){return null!=e}}):(c(o),f(o.guaranteedUser,"useSession()"),f(i.value,"useSession()"),i.value)},exports.useSessionList=function(){var e=n.useContext(v),t=r.useContext(g);return c(t),c(e),d(e.guaranteedLoaded,"useSessionList()"),t.value.sessions},exports.useSignIn=function(){var e=n.useContext(v),t=r.useContext(g);return c(t),c(e),d(e.guaranteedLoaded,"useSignIn()"),t.value.signIn},exports.useSignUp=function(){var e=n.useContext(v),t=r.useContext(g);return c(t),c(e),d(e.guaranteedLoaded,"useSignUp()"),t.value.signUp},exports.useUser=function(e){var r=t({},e);r.withAssertions=r.withAssertions||!1;var o=n.useContext(v),i=S();return r.withAssertions?t({user:i.value},{isLoading:function(e){return void 0===e},isSignedOut:function(e){return null===e},isSignedIn:function(e){return!!e}}):(c(o),f(o.guaranteedUser,"useUser()"),f(i.value,"useUser()"),i.value)},exports.withClerk=h,exports.withSession=function(e,o){e.displayName=o=o||e.displayName||e.name||"Component";var u=function(o){var u=n.useContext(v),s=n.useContext(k);if(!i())return null;c(u),c(s);var l=s.value;return u.guaranteedUser&&l?r.createElement(e,t({},o,{session:l})):l?r.createElement(v.Provider,{value:p.guaranteedAll},r.createElement(e,t({},o,{session:l}))):null};return u.displayName="withSession("+o+")",u},exports.withUser=U;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,n=require("react"),r=(e=n)&&"object"==typeof e&&"default"in e?e.default:e;function t(){return(t=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e}).apply(this,arguments)}function o(e,n){if(null==e)return{};var r,t,o={},i=Object.keys(e);for(t=0;t<i.length;t++)n.indexOf(r=i[t])>=0||(o[r]=e[r]);return o}function i(){return"undefined"!=typeof window}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var u=new Map;function l(e,n,o){var i=function(i){return function(e,n,t){void 0===t&&(t=1),r.useEffect((function(){var r=u.get(e)||0;if(r==t)throw new Error(n);return u.set(e,r+1),function(){u.set(e,(u.get(e)||1)-1)}}),[])}(n,o),r.createElement(e,t({},i))};return i.displayName="withMaxAllowedInstancesGuard("+(e.displayName||e.name||n||"Component")+")",i}var s={Expired:"expired",Failed:"failed"},a=function(e){return function(n){try{return r.Children.only(e)}catch(e){throw new Error(function(e){return"Clerk: You've passed multiple children components to <"+e+"/>. You can only pass a single child component or text."}(n))}}},c=function(e,n){return e||(e=n),"string"==typeof e&&(e=r.createElement("button",null,e)),e},d=function(e){return function(){if(e&&"function"==typeof e)return e.apply(void 0,arguments)}},f=function(){function e(e,n,r){var t=this,o=this,u=this,l=this,s=this;void 0===n&&(n={}),void 0===r&&(r=null),this.mode=void 0,this.frontendApi=void 0,this.options=void 0,this.Clerk=void 0,this.clerkjs=null,this.preopenSignIn=null,this.preopenSignUp=null,this.premountSignInNodes=new Map,this.premountSignUpNodes=new Map,this.premountUserProfileNodes=new Map,this.premountUserButtonNodes=new Map,this.premountMethodCalls=new Map,this._loaded=!1,this.ssrData=null,this.ssrClient=void 0,this.ssrSession=void 0,this.hydrateClerkJS=function(e){try{if(!e)throw new Error("Failed to hydrate latest Clerk JS");return o.clerkjs=e,o.premountMethodCalls.forEach((function(e){return e()})),null!==o.preopenSignIn&&e.openSignIn(o.preopenSignIn),null!==o.preopenSignUp&&e.openSignUp(o.preopenSignUp),o.premountSignInNodes.forEach((function(n,r){e.mountSignIn(r,n)})),o.premountSignUpNodes.forEach((function(n,r){e.mountSignUp(r,n)})),o.premountUserProfileNodes.forEach((function(n,r){e.mountUserProfile(r,n)})),o.premountUserButtonNodes.forEach((function(n,r){e.mountUserButton(r,n)})),o._loaded=!0,Promise.resolve(o.clerkjs)}catch(e){return Promise.reject(e)}},this.setSession=function(e,n){return t.clerkjs?t.clerkjs.setSession(e,n):Promise.reject()},this.openSignIn=function(e){t.clerkjs&&t._loaded?t.clerkjs.openSignIn(e):t.preopenSignIn=e},this.closeSignIn=function(){t.clerkjs&&t._loaded?t.clerkjs.closeSignIn():t.preopenSignIn=null},this.openSignUp=function(e){t.clerkjs&&t._loaded?t.clerkjs.openSignUp(e):t.preopenSignUp=e},this.closeSignUp=function(){t.clerkjs&&t._loaded?t.clerkjs.closeSignUp():t.preopenSignUp=null},this.mountSignIn=function(e,n){t.clerkjs&&t._loaded?t.clerkjs.mountSignIn(e,n):t.premountSignInNodes.set(e,n)},this.unmountSignIn=function(e){t.clerkjs&&t._loaded?t.clerkjs.unmountSignIn(e):t.premountSignInNodes.delete(e)},this.mountSignUp=function(e,n){t.clerkjs&&t._loaded?t.clerkjs.mountSignUp(e,n):t.premountSignUpNodes.set(e,n)},this.unmountSignUp=function(e){t.clerkjs&&t._loaded?t.clerkjs.unmountSignUp(e):t.premountSignUpNodes.delete(e)},this.mountUserProfile=function(e,n){t.clerkjs&&t._loaded?t.clerkjs.mountUserProfile(e,n):t.premountUserProfileNodes.set(e,n)},this.unmountUserProfile=function(e){t.clerkjs&&t._loaded?t.clerkjs.unmountUserProfile(e):t.premountUserProfileNodes.delete(e)},this.mountUserButton=function(e,n){t.clerkjs&&t._loaded?t.clerkjs.mountUserButton(e,n):t.premountUserButtonNodes.set(e,n)},this.unmountUserButton=function(e){t.clerkjs&&t._loaded?t.clerkjs.unmountUserButton(e):t.premountUserButtonNodes.delete(e)},this.addListener=function(e){var n=function(){var n;return null===(n=t.clerkjs)||void 0===n?void 0:n.addListener(e)};t.clerkjs?n():t.premountMethodCalls.set("addListener",n)},this.loadFromServer=function(e){"browser"===t.mode&&t.throwError("loadFromServer cannot be called in a browser context."),t.ssrData=JSON.stringify({client:t.client,session:t.session,token:e})},this.navigate=function(e){var n=function(){var n;return null===(n=t.clerkjs)||void 0===n?void 0:n.navigate(e)};t.clerkjs&&t._loaded?n():t.premountMethodCalls.set("navigate",n)},this.redirectToSignIn=function(e){var n=function(){var n;return null===(n=t.clerkjs)||void 0===n?void 0:n.redirectToSignIn(e)};t.clerkjs&&t._loaded?n():t.premountMethodCalls.set("redirectToSignIn",n)},this.redirectToSignUp=function(e){var n=function(){var n;return null===(n=t.clerkjs)||void 0===n?void 0:n.redirectToSignUp(e)};t.clerkjs&&t._loaded?n():t.premountMethodCalls.set("redirectToSignUp",n)},this.redirectToUserProfile=function(){var e=function(){var e;return null===(e=t.clerkjs)||void 0===e?void 0:e.redirectToUserProfile()};t.clerkjs&&t._loaded?e():t.premountMethodCalls.set("redirectToUserProfile",e)},this.handleRedirectCallback=function(e){var n=function(){var n;return null===(n=t.clerkjs)||void 0===n?void 0:n.handleRedirectCallback(e)};t.clerkjs&&t._loaded?n():t.premountMethodCalls.set("handleRedirectCallback",n)},this.handleMagicLinkVerification=function(e){try{var n=function(){var n;return null===(n=u.clerkjs)||void 0===n?void 0:n.handleMagicLinkVerification(e)};return u.clerkjs&&u._loaded?Promise.resolve(n()):(u.premountMethodCalls.set("handleMagicLinkVerification",n),Promise.resolve())}catch(e){return Promise.reject(e)}},this.signOut=function(e){try{var n=function(){var n;return null===(n=l.clerkjs)||void 0===n?void 0:n.signOut(e)};return l.clerkjs&&l._loaded?Promise.resolve(n()):(l.premountMethodCalls.set("signOut",n),Promise.resolve())}catch(e){return Promise.reject(e)}},this.signOutOne=function(e){try{var n=function(){var n;return null===(n=s.clerkjs)||void 0===n?void 0:n.signOutOne(e)};return s.clerkjs&&s._loaded?Promise.resolve(n()):(s.premountMethodCalls.set("signOutOne",n),Promise.resolve())}catch(e){return Promise.reject(e)}},this.frontendApi=e,this.options=n,this.Clerk=r,this.mode=i()?"browser":"server"}var n,r=e.prototype;return r.loadClerkJS=function(){try{var e=this;return e.frontendApi||e.throwError("Clerk: You must add the frontendApi prop to your <ClerkProvider>"),Promise.resolve(function(n,r){try{var t=function(){function n(n){return e.hydrateClerkJS(global.Clerk)}var r=function(){if(e.Clerk){var n,r=function(){global.Clerk=n},t=function(){if("function"==typeof e.Clerk)return n=new e.Clerk(e.frontendApi),Promise.resolve(n.load(e.options)).then((function(){}));n=e.Clerk;var r=function(){if(!n.isReady())return Promise.resolve(n.load(e.options)).then((function(){}))}();return r&&r.then?r.then((function(){})):void 0}();return t&&t.then?t.then(r):r()}return Promise.resolve((o=e.frontendApi,i=e.options.scriptUrl,new Promise((function(e,n){global.Clerk&&e(null),o||n("Clerk: Missing provider");var r=document.createElement("script"),t=function(e,n){if(n)return n;var r=function(e){return e.endsWith(".lclstage.dev")||e.endsWith(".stgstage.dev")||e.endsWith(".clerkstage.dev")}(e)?"staging":parseInt("2.3.1-staging.0".split(".")[0],10);return"https://"+e+"/npm/@clerk/clerk-js@"+r+"/dist/clerk.browser.js"}(o,i);r.setAttribute("data-clerk-frontend-api",o),r.setAttribute("crossorigin","anonymous"),r.async=!0,document.body||n("Clerk: Missing <body> element."),r.addEventListener("load",(function(){return e(r)})),r.addEventListener("error",(function(){return n("Clerk: Failed to load Clerk")})),r.src=t,document.body.appendChild(r)})))).then((function(){if(!global.Clerk)throw new Error("Failed to download latest ClerkJS. Contact support@clerk.dev.");return Promise.resolve(global.Clerk.load(e.options)).then((function(){}))}));var o,i}();return r&&r.then?r.then(n):n()}()}catch(e){return r(e)}return t&&t.then?t.then(void 0,r):t}(0,(function(n){var r;r=n instanceof Error?n.message:String(n),e.throwError(r)})))}catch(e){return Promise.reject(e)}},r.throwError=function(e){throw console.error(e),new Error(e)},(n=[{key:"version",get:function(){var e;return null===(e=this.clerkjs)||void 0===e?void 0:e.version}},{key:"client",get:function(){return this.clerkjs?this.clerkjs.client:void 0}},{key:"session",get:function(){return this.clerkjs?this.clerkjs.session:void 0}},{key:"user",get:function(){return this.clerkjs?this.clerkjs.user:void 0}},{key:"__unstable__environment",get:function(){return this.clerkjs?this.clerkjs.__unstable__environment:void 0}}])&&function(e,n){for(var r=0;r<n.length;r++){var t=n[r];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,t.key,t)}}(e.prototype,n),e}();function p(e){if(!e)throw new Error("Clerk: You must wrap your application in a <ClerkProvider> component.")}function v(e,n){if(!e)throw new Error(function(e){return"Clerk: You're calling "+e+" before there's a guarantee the client has been loaded. Call "+e+" from a child of <SignedIn>, <SignedOut>, or <ClerkLoaded>, or use the withClerk() HOC."}(n))}function m(e,n){if(!e)throw new Error(function(e){return"Clerk: You're calling "+e+" before there's a guarantee there's an active user. Call "+e+" from a child of <SignedIn> or use the withUser() HOC."}(n))}var h=Object.freeze({noGuarantees:Object.freeze({guaranteedLoaded:!1,guaranteedUser:!1}),guaranteedLoaded:Object.freeze({guaranteedLoaded:!0,guaranteedUser:!1}),guaranteedAll:Object.freeze({guaranteedLoaded:!0,guaranteedUser:!0})}),g=r.createContext(void 0);g.displayName="StructureContext";var k=r.createContext(void 0);k.displayName="IsomorphicClerkContext";var S=function(e,o){e.displayName=o=o||e.displayName||e.name||"Component";var u=function(o){var u=n.useContext(g),l=n.useContext(k);if(!i())return null;p(u),p(l);var s=l.value;return s?u.guaranteedLoaded?r.createElement(e,t({},o,{clerk:s})):s.client?r.createElement(g.Provider,{value:h.guaranteedLoaded},r.createElement(e,t({},o,{clerk:s}))):null:null};return u.displayName="withClerk("+o+")",u},C=r.createContext(void 0);C.displayName="ClientContext";var U=r.createContext(void 0);U.displayName="SessionContext";var y=r.createContext(void 0);function j(){var e=n.useContext(y);return p(e),e}y.displayName="UserContext";var E=function(e,o){e.displayName=o=o||e.displayName||e.name||"Component";var u=function(o){var u=n.useContext(g),l=n.useContext(y);if(!i())return null;p(u),p(l);var s=l.value;return u.guaranteedUser&&s?r.createElement(e,t({},o,{user:s})):s?r.createElement(g.Provider,{value:h.guaranteedAll},r.createElement(e,t({},o,{user:s}))):null};return u.displayName="withUser("+o+")",u};function x(e){var n=e.children,o=e.clerkLoaded,i=e.isomorphicClerk,u=r.useState({client:i.client,session:i.session,user:i.user}),l=u[0],s=u[1];r.useEffect((function(){return i.addListener((function(e){return s(t({},e))}))}),[]);var a=l.client,c=l.session,d=l.user,f=r.useMemo((function(){return{value:i}}),[o]),p=r.useMemo((function(){return{value:a}}),[a]),v=r.useMemo((function(){return{value:c}}),[c]),m=r.useMemo((function(){return{value:d}}),[d]);return r.createElement(k.Provider,{value:f},r.createElement(C.Provider,{value:p},r.createElement(U.Provider,{value:v},r.createElement(y.Provider,{value:m},r.createElement(r.Fragment,{key:c?c.id:"no-users"},n)))))}function P(e){var t=n.useMemo((function(){var n=e.frontendApi,r=void 0===n?"":n,t=e.Clerk,i=o(e,["frontendApi","Clerk"]);return new f(r,i,t)}),[]),i=n.useState(!1),u=i[0],l=i[1];return n.useEffect((function(){t.loadClerkJS().then((function(){return l(!0)}))}),[]),r.createElement(g.Provider,{value:h.noGuarantees},t instanceof f&&t.ssrData&&r.createElement("script",{type:"application/json","data-clerk":"SSR",dangerouslySetInnerHTML:{__html:t.ssrData}}),r.createElement(x,{isomorphicClerk:t,clerkLoaded:u},e.children))}var w=l(P,"ClerkProvider","Clerk: You've added multiple <ClerkProvider> components in your React component tree. Wrap your components in a single <ClerkProvider>."),I=function(e){var n,t;function o(){for(var n,t=arguments.length,o=new Array(t),i=0;i<t;i++)o[i]=arguments[i];return(n=e.call.apply(e,[this].concat(o))||this).portalRef=r.createRef(),n}t=e,(n=o).prototype=Object.create(t.prototype),n.prototype.constructor=n,n.__proto__=t;var i=o.prototype;return i.componentDidMount=function(){this.portalRef.current&&this.props.mount(this.portalRef.current,this.props.props)},i.componentWillUnmount=function(){this.portalRef.current&&this.props.unmount(this.portalRef.current)},i.render=function(){return r.createElement("div",{ref:this.portalRef})},o}(r.PureComponent),b=S((function(e){var n=e.clerk,t=o(e,["clerk"]);return r.createElement(I,{mount:n.mountSignIn,unmount:n.unmountSignIn,props:t})}),"SignIn"),_=S((function(e){var n=e.clerk,t=o(e,["clerk"]);return r.createElement(I,{mount:n.mountSignUp,unmount:n.unmountSignUp,props:t})}),"SignUp"),O=S((function(e){var n=e.clerk,t=o(e,["clerk"]);return r.createElement(I,{mount:n.mountUserProfile,unmount:n.unmountUserProfile,props:t})}),"UserProfile"),L=S((function(e){var n=e.clerk,t=o(e,["clerk"]);return r.createElement(I,{mount:n.mountUserButton,unmount:n.unmountUserButton,props:t})}),"UserButton"),M=E((function(e){return r.createElement(r.Fragment,null,e.children)}),"SignedIn"),N=S((function(e){var n=e.children;return null===j().value?r.createElement(r.Fragment,null,n):null}),"SignedOut"),A=S((function(e){return r.createElement(r.Fragment,null,e.children)}),"ClerkLoaded"),B=S((function(e){var n=e.clerk,t=o(e,["clerk"]),i=t.returnBack,u={afterSignUpUrl:t.afterSignUpUrl,redirectUrl:t.redirectUrl,afterSignInUrl:t.afterSignInUrl},l=n.client,s=n.session,a=n.__unstable__environment,c=l.activeSessions&&l.activeSessions.length>0;return r.useEffect((function(){null===s&&c&&a?n.navigate(a.displayConfig.afterSignOutOneUrl):n.redirectToSignIn(i||u)}),[]),null}),"RedirectToSignIn"),R=S((function(e){var n=e.clerk,t=o(e,["clerk"]),i=t.returnBack,u={afterSignUpUrl:t.afterSignUpUrl,redirectUrl:t.redirectUrl,afterSignInUrl:t.afterSignInUrl};return r.useEffect((function(){n.redirectToSignUp(i||u)}),[]),null}),"RedirectToSignUp"),T=S((function(e){var n=e.clerk;return r.useEffect((function(){n.redirectToUserProfile()}),[]),null}),"RedirectToUserProfile"),W=S((function(e){var n=e.clerk,t=o(e,["clerk"]);return r.useEffect((function(){n.handleRedirectCallback(t)}),[]),null}),"AuthenticateWithRedirectCallback"),F=S((function(e){var n=e.clerk,i=e.children,u=o(e,["clerk","children"]),l=u.afterSignInUrl,s=u.afterSignUpUrl,f=u.redirectUrl,p=u.mode,v=o(u,["afterSignInUrl","afterSignUpUrl","redirectUrl","mode"]);i=c(i,"Sign in");var m=a(i)("SignInButton"),h=t({},v,{onClick:function(e){try{return Promise.resolve(d(m.props.onClick)(e)).then((function(){return e={afterSignInUrl:l,afterSignUpUrl:s,redirectUrl:f},"modal"===p?n.openSignIn(e):n.redirectToSignIn(e);var e}))}catch(e){return Promise.reject(e)}}});return r.cloneElement(m,h)}),"SignInButton"),J=S((function(e){var n=e.clerk,i=e.children,u=o(e,["clerk","children"]),l=u.afterSignInUrl,s=u.afterSignUpUrl,f=u.redirectUrl,p=u.mode,v=o(u,["afterSignInUrl","afterSignUpUrl","redirectUrl","mode"]);i=c(i,"Sign up");var m=a(i)("SignUpButton"),h=t({},v,{onClick:function(e){try{return Promise.resolve(d(m.props.onClick)(e)).then((function(){return e={afterSignInUrl:l,afterSignUpUrl:s,redirectUrl:f},"modal"===p?n.openSignUp(e):n.redirectToSignUp(e);var e}))}catch(e){return Promise.reject(e)}}});return r.cloneElement(m,h)}),"SignUpButton"),Y=S((function(e){var n=e.clerk,i=e.children,u=o(e,["clerk","children"]),l=u.signOutCallback,s=o(u,["signOutCallback"]);i=c(i,"Sign out");var f=a(i)("SignOutButton"),p=t({},s,{onClick:function(e){try{return Promise.resolve(d(f.props.onClick)(e)).then((function(){return n.signOutOne(l)}))}catch(e){return Promise.reject(e)}}});return r.cloneElement(f,p)}),"SignOutButton");exports.AuthenticateWithRedirectCallback=W,exports.ClerkLoaded=A,exports.ClerkLoading=function(e){var n=e.children;return void 0===j().value?r.createElement(r.Fragment,null,n):null},exports.ClerkProvider=w,exports.MagicLinkErrorCode=s,exports.RedirectToSignIn=B,exports.RedirectToSignUp=R,exports.RedirectToUserProfile=T,exports.SignIn=b,exports.SignInButton=F,exports.SignOutButton=Y,exports.SignUp=_,exports.SignUpButton=J,exports.SignedIn=M,exports.SignedOut=N,exports.UserButton=L,exports.UserProfile=O,exports.WithClerk=function(e){var n=e.children;return r.createElement(g.Consumer,null,(function(e){return r.createElement(k.Consumer,null,(function(t){if("function"!=typeof n)throw new Error("Clerk: Child of WithClerk must be a function.");p(e),p(t);var o=t.value;return o?e.guaranteedLoaded?n(o):o.client?r.createElement(g.Provider,{value:h.guaranteedLoaded},n(o)):null:null}))}))},exports.WithSession=function(e){var n=e.children;return r.createElement(g.Consumer,null,(function(e){return r.createElement(U.Consumer,null,(function(t){if("function"!=typeof n)throw new Error("Clerk: Child of WithClerk must be a function.");p(e),p(t);var o=t.value;return e.guaranteedUser&&o?n(o):o?r.createElement(g.Provider,{value:h.guaranteedAll},n(o)):null}))}))},exports.WithUser=function(e){var n=e.children;return r.createElement(g.Consumer,null,(function(e){return r.createElement(y.Consumer,null,(function(t){if("function"!=typeof n)throw new Error("Clerk: Child of WithClerk must be a function.");p(e),p(t);var o=t.value;return e.guaranteedUser&&o?n(o):o?r.createElement(g.Provider,{value:h.guaranteedAll},n(o)):null}))}))},exports.isMagicLinkError=function(e){return!!e&&(e.code===s.Expired||e.code===s.Failed)},exports.useClerk=function(){var e=n.useContext(g),r=n.useContext(k);return p(e),p(r),v(e.guaranteedLoaded,"useClerk()"),v(r.value,"useClerk()"),r.value},exports.useSession=function(e){var r=t({},e);r.withAssertions=r.withAssertions||!1;var o=n.useContext(g),i=function(){var e=n.useContext(U);return p(e),e}();return r.withAssertions?t({session:i.value},{isLoading:function(e){return void 0===e},isSignedOut:function(e){return null===e},isSignedIn:function(e){return null!=e}}):(p(o),m(o.guaranteedUser,"useSession()"),m(i.value,"useSession()"),i.value)},exports.useSessionList=function(){var e=n.useContext(g),t=r.useContext(C);return p(t),p(e),v(e.guaranteedLoaded,"useSessionList()"),t.value.sessions},exports.useSignIn=function(){var e=n.useContext(g),t=r.useContext(C);return p(t),p(e),v(e.guaranteedLoaded,"useSignIn()"),t.value.signIn},exports.useSignUp=function(){var e=n.useContext(g),t=r.useContext(C);return p(t),p(e),v(e.guaranteedLoaded,"useSignUp()"),t.value.signUp},exports.useUser=function(e){var r=t({},e);r.withAssertions=r.withAssertions||!1;var o=n.useContext(g),i=j();return r.withAssertions?t({user:i.value},{isLoading:function(e){return void 0===e},isSignedOut:function(e){return null===e},isSignedIn:function(e){return!!e}}):(p(o),m(o.guaranteedUser,"useUser()"),m(i.value,"useUser()"),i.value)},exports.withClerk=S,exports.withSession=function(e,o){e.displayName=o=o||e.displayName||e.name||"Component";var u=function(o){var u=n.useContext(g),l=n.useContext(U);if(!i())return null;p(u),p(l);var s=l.value;return u.guaranteedUser&&s?r.createElement(e,t({},o,{session:s})):s?r.createElement(g.Provider,{value:h.guaranteedAll},r.createElement(e,t({},o,{session:s}))):null};return u.displayName="withSession("+o+")",u},exports.withUser=E;
//# sourceMappingURL=clerk-react.cjs.production.min.js.map

@@ -84,3 +84,3 @@ import React, { useContext, useMemo, useState, useEffect } from 'react';

var version = "2.3.0";
var version = "2.3.1-staging.0";

@@ -176,2 +176,5 @@ var FAILED_TO_LOAD_ERROR = 'Clerk: Failed to load Clerk';

var hocChildrenNotAFunctionError = 'Clerk: Child of WithClerk must be a function.';
var multipleChildrenInButtonComponent = function multipleChildrenInButtonComponent(name) {
return "Clerk: You've passed multiple children components to <" + name + "/>. You can only pass a single child component or text.";
};
var MagicLinkErrorCode = {

@@ -185,2 +188,30 @@ Expired: 'expired',

var assertSingleChild = function assertSingleChild(children) {
return function (name) {
try {
return React.Children.only(children);
} catch (e) {
throw new Error(multipleChildrenInButtonComponent(name));
}
};
};
var normalizeWithDefaultValue = function normalizeWithDefaultValue(children, defaultText) {
if (!children) {
children = defaultText;
}
if (typeof children === 'string') {
children = React.createElement("button", null, children);
}
return children;
};
var safeExecute = function safeExecute(cb) {
return function () {
if (cb && typeof cb === 'function') {
return cb.apply(void 0, arguments);
}
};
};
var IsomorphicClerk = /*#__PURE__*/function () {

@@ -407,7 +438,7 @@ function IsomorphicClerk(frontendApi, options, Clerk) {

this.redirectToSignIn = function (returnBack) {
this.redirectToSignIn = function (opts) {
var callback = function callback() {
var _this2$clerkjs3;
return (_this2$clerkjs3 = _this2.clerkjs) === null || _this2$clerkjs3 === void 0 ? void 0 : _this2$clerkjs3.redirectToSignIn(returnBack);
return (_this2$clerkjs3 = _this2.clerkjs) === null || _this2$clerkjs3 === void 0 ? void 0 : _this2$clerkjs3.redirectToSignIn(opts);
};

@@ -422,7 +453,7 @@

this.redirectToSignUp = function (returnBack) {
this.redirectToSignUp = function (opts) {
var callback = function callback() {
var _this2$clerkjs4;
return (_this2$clerkjs4 = _this2.clerkjs) === null || _this2$clerkjs4 === void 0 ? void 0 : _this2$clerkjs4.redirectToSignUp(returnBack);
return (_this2$clerkjs4 = _this2.clerkjs) === null || _this2$clerkjs4 === void 0 ? void 0 : _this2$clerkjs4.redirectToSignUp(opts);
};

@@ -1227,6 +1258,18 @@

return userCtx.value === undefined ? React.createElement(React.Fragment, null, children) : null;
};
}; // DX: returnBack deprecated <=2.4.2
// Deprecate the boolean type before removing returnBack
var RedirectToSignIn = /*#__PURE__*/withClerk(function (_ref5) {
var clerk = _ref5.clerk,
returnBack = _ref5.returnBack;
props = _objectWithoutPropertiesLoose(_ref5, ["clerk"]);
var returnBack = props.returnBack,
afterSignUpUrl = props.afterSignUpUrl,
redirectUrl = props.redirectUrl,
afterSignInUrl = props.afterSignInUrl;
var redirectOptions = {
afterSignUpUrl: afterSignUpUrl,
redirectUrl: redirectUrl,
afterSignInUrl: afterSignInUrl
};
var client = clerk.client,

@@ -1242,12 +1285,24 @@ session = clerk.session; // TODO: Remove temp use of __unstable__environment

} else {
clerk.redirectToSignIn(returnBack);
void clerk.redirectToSignIn(returnBack || redirectOptions);
}
}, []);
return null;
}, 'RedirectToSignIn');
}, 'RedirectToSignIn'); // DX: returnBack deprecated <=2.4.2
// Deprecate the boolean type before removing returnBack
var RedirectToSignUp = /*#__PURE__*/withClerk(function (_ref6) {
var clerk = _ref6.clerk,
returnBack = _ref6.returnBack;
props = _objectWithoutPropertiesLoose(_ref6, ["clerk"]);
var returnBack = props.returnBack,
afterSignUpUrl = props.afterSignUpUrl,
redirectUrl = props.redirectUrl,
afterSignInUrl = props.afterSignInUrl;
var redirectOptions = {
afterSignUpUrl: afterSignUpUrl,
redirectUrl: redirectUrl,
afterSignInUrl: afterSignInUrl
};
React.useEffect(function () {
clerk.redirectToSignUp(returnBack);
void clerk.redirectToSignUp(returnBack || redirectOptions);
}, []);

@@ -1273,3 +1328,125 @@ return null;

export { AuthenticateWithRedirectCallback, ClerkLoaded, ClerkLoading, ClerkProvider, MagicLinkErrorCode, RedirectToSignIn, RedirectToSignUp, RedirectToUserProfile, SignIn, SignUp, SignedIn, SignedOut, UserButton, UserProfile, WithClerk, WithSession, WithUser, isMagicLinkError, useClerk, useSession, useSessionList, useSignIn, useSignUp, useUser, withClerk, withSession, withUser };
var SignInButton = /*#__PURE__*/withClerk(function (_ref) {
var clerk = _ref.clerk,
children = _ref.children,
props = _objectWithoutPropertiesLoose(_ref, ["clerk", "children"]);
var afterSignInUrl = props.afterSignInUrl,
afterSignUpUrl = props.afterSignUpUrl,
redirectUrl = props.redirectUrl,
mode = props.mode,
rest = _objectWithoutPropertiesLoose(props, ["afterSignInUrl", "afterSignUpUrl", "redirectUrl", "mode"]);
children = normalizeWithDefaultValue(children, 'Sign in');
var child = assertSingleChild(children)('SignInButton');
var clickHandler = function clickHandler() {
var opts = {
afterSignInUrl: afterSignInUrl,
afterSignUpUrl: afterSignUpUrl,
redirectUrl: redirectUrl
};
if (mode === 'modal') {
return clerk.openSignIn(opts);
}
return clerk.redirectToSignIn(opts);
};
var wrappedChildClickHandler = function wrappedChildClickHandler(e) {
try {
return Promise.resolve(safeExecute(child.props.onClick)(e)).then(function () {
return clickHandler();
});
} catch (e) {
return Promise.reject(e);
}
};
var childProps = _extends({}, rest, {
onClick: wrappedChildClickHandler
});
return React.cloneElement(child, childProps);
}, 'SignInButton');
var SignUpButton = /*#__PURE__*/withClerk(function (_ref) {
var clerk = _ref.clerk,
children = _ref.children,
props = _objectWithoutPropertiesLoose(_ref, ["clerk", "children"]);
var afterSignInUrl = props.afterSignInUrl,
afterSignUpUrl = props.afterSignUpUrl,
redirectUrl = props.redirectUrl,
mode = props.mode,
rest = _objectWithoutPropertiesLoose(props, ["afterSignInUrl", "afterSignUpUrl", "redirectUrl", "mode"]);
children = normalizeWithDefaultValue(children, 'Sign up');
var child = assertSingleChild(children)('SignUpButton');
var clickHandler = function clickHandler() {
var opts = {
afterSignInUrl: afterSignInUrl,
afterSignUpUrl: afterSignUpUrl,
redirectUrl: redirectUrl
};
if (mode === 'modal') {
return clerk.openSignUp(opts);
}
return clerk.redirectToSignUp(opts);
};
var wrappedChildClickHandler = function wrappedChildClickHandler(e) {
try {
return Promise.resolve(safeExecute(child.props.onClick)(e)).then(function () {
return clickHandler();
});
} catch (e) {
return Promise.reject(e);
}
};
var childProps = _extends({}, rest, {
onClick: wrappedChildClickHandler
});
return React.cloneElement(child, childProps);
}, 'SignUpButton');
var SignOutButton = /*#__PURE__*/withClerk(function (_ref) {
var clerk = _ref.clerk,
children = _ref.children,
props = _objectWithoutPropertiesLoose(_ref, ["clerk", "children"]);
var signOutCallback = props.signOutCallback,
rest = _objectWithoutPropertiesLoose(props, ["signOutCallback"]);
children = normalizeWithDefaultValue(children, 'Sign out');
var child = assertSingleChild(children)('SignOutButton');
var clickHandler = function clickHandler() {
return clerk.signOutOne(signOutCallback);
};
var wrappedChildClickHandler = function wrappedChildClickHandler(e) {
try {
return Promise.resolve(safeExecute(child.props.onClick)(e)).then(function () {
return clickHandler();
});
} catch (e) {
return Promise.reject(e);
}
};
var childProps = _extends({}, rest, {
onClick: wrappedChildClickHandler
});
return React.cloneElement(child, childProps);
}, 'SignOutButton');
export { AuthenticateWithRedirectCallback, ClerkLoaded, ClerkLoading, ClerkProvider, MagicLinkErrorCode, RedirectToSignIn, RedirectToSignUp, RedirectToUserProfile, SignIn, SignInButton, SignOutButton, SignUp, SignUpButton, SignedIn, SignedOut, UserButton, UserProfile, WithClerk, WithSession, WithUser, isMagicLinkError, useClerk, useSession, useSessionList, useSignIn, useSignUp, useUser, withClerk, withSession, withUser };
//# sourceMappingURL=clerk-react.esm.js.map

@@ -10,3 +10,3 @@ import React from 'react';

returnBack?: boolean | undefined;
} & {
} & import("@clerk/types").RedirectOptions & {
clerk: import("../types").LoadedClerk;

@@ -19,3 +19,3 @@ }, "clerk">): JSX.Element | null;

returnBack?: boolean | undefined;
} & {
} & import("@clerk/types").RedirectOptions & {
clerk: import("../types").LoadedClerk;

@@ -22,0 +22,0 @@ }, "clerk">): JSX.Element | null;

export { SignUp, SignIn, UserProfile, UserButton } from './uiComponents';
export { ClerkLoaded, ClerkLoading, SignedOut, SignedIn, RedirectToSignIn, RedirectToSignUp, RedirectToUserProfile, AuthenticateWithRedirectCallback, } from './controlComponents';
export * from './SignInButton';
export * from './SignUpButton';
export * from './SignOutButton';

@@ -1,5 +0,10 @@

/// <reference types="react" />
import { SignInProps, SignUpProps, UserButtonProps, UserProfileProps } from '@clerk/types';
import { UserButtonProps, UserProfileProps } from '@clerk/types';
export declare const SignIn: {
(props: Omit<SignInProps & {
(props: Omit<{
routing?: import("@clerk/types").RoutingStrategy | undefined;
path?: string | undefined;
signUpUrl?: string | undefined;
afterSignIn?: string | null | undefined;
signUpURL?: string | undefined;
} & import("@clerk/types").RedirectOptions & {
clerk: import("../types").LoadedClerk;

@@ -10,3 +15,9 @@ }, "clerk">): JSX.Element | null;

export declare const SignUp: {
(props: Omit<SignUpProps & {
(props: Omit<{
routing?: import("@clerk/types").RoutingStrategy | undefined;
path?: string | undefined;
signInUrl?: string | undefined;
afterSignUp?: string | null | undefined;
signInURL?: string | undefined;
} & import("@clerk/types").RedirectOptions & {
clerk: import("../types").LoadedClerk;

@@ -13,0 +24,0 @@ }, "clerk">): JSX.Element | null;

@@ -7,2 +7,3 @@ export declare const noFrontendApiError = "Clerk: You must add the frontendApi prop to your <ClerkProvider>";

export declare const hocChildrenNotAFunctionError = "Clerk: Child of WithClerk must be a function.";
export declare const multipleChildrenInButtonComponent: (name: string) => string;
export declare const MagicLinkErrorCode: {

@@ -9,0 +10,0 @@ Expired: string;

import type { BrowserClerk, ClerkProp, IsomorphicClerkOptions } from './types';
import type { ActiveSessionResource, ClientResource, HandleMagicLinkVerificationParams, HandleOAuthCallbackParams, Resources, SessionResource, SignInProps, SignOutCallback, SignUpProps, UserButtonProps, UserProfileProps, UserResource } from '@clerk/types';
import type { ActiveSessionResource, ClientResource, HandleMagicLinkVerificationParams, HandleOAuthCallbackParams, RedirectOptions, Resources, SessionResource, SignInProps, SignOutCallback, SignUpProps, UserButtonProps, UserProfileProps, UserResource } from '@clerk/types';
export interface Global {

@@ -48,4 +48,4 @@ Clerk?: BrowserClerk;

navigate: (to: string) => void;
redirectToSignIn: (returnBack?: boolean | undefined) => void;
redirectToSignUp: (returnBack?: boolean | undefined) => void;
redirectToSignIn: (opts: RedirectOptions | boolean) => void;
redirectToSignUp: (opts: RedirectOptions | boolean) => void;
redirectToUserProfile: () => void;

@@ -52,0 +52,0 @@ handleRedirectCallback: (params: HandleOAuthCallbackParams) => void;

@@ -0,2 +1,5 @@

/// <reference types="react" />
import type { Clerk, ClerkOptions, ClientResource, UserResource } from '@clerk/types';
import { RedirectOptions } from '@clerk/types';
import { SignOutCallback } from '@clerk/types/src';
export interface IsomorphicClerkOptions extends ClerkOptions {

@@ -29,1 +32,21 @@ scriptUrl?: string;

export declare type ClerkProp = BrowserClerkConstructor | BrowserClerk | undefined | null;
declare type ButtonProps = {
afterSignInUrl?: string;
afterSignUpUrl?: string;
redirectUrl?: string;
mode?: 'redirect' | 'modal';
children?: React.ReactNode;
};
export declare type SignInButtonProps = ButtonProps;
export declare type SignUpButtonProps = ButtonProps;
export declare type SignOutButtonProps = {
signOutCallback?: SignOutCallback;
children?: React.ReactNode;
};
export declare type RedirectToProps = {
/**
* @deprecated The returnBack prop has been deprecated and will be removed soon. Use `redirectUrl` instead.
*/
returnBack?: boolean;
} & RedirectOptions;
export {};

@@ -5,1 +5,2 @@ export * from './inBrowser';

export * from './useMaxAllowedInstancesGuard';
export * from './childrenUtils';
{
"name": "@clerk/clerk-react",
"version": "2.3.0",
"version": "2.3.1-staging.0",
"license": "MIT",

@@ -37,3 +37,3 @@ "description": "Clerk.dev React library",

"dependencies": {
"@clerk/types": "1.18.0"
"@clerk/types": "1.18.1-staging.0"
},

@@ -40,0 +40,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc