Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@clerk/clerk-react

Package Overview
Dependencies
Maintainers
2
Versions
2472
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 0.1.2-beta.3 to 0.1.2-beta.4

68

dist/clerk-react.cjs.development.js

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

var noProviderError = 'Clerk: You must wrap your application in a <ClerkProvider> component.';
var noGuaranteeError = "Clerk: You're calling useClerk() before there's a guarantee the session has been loaded. Call useClerk() from a child of <SignedIn>, <SignedOut>, or <ClerkLoaded>, or use the withClerk() HOC.";
var noGuaranteeError = "Clerk: You're calling useClerk() before there's a guarantee the client has been loaded. Call useClerk() from a child of <SignedIn>, <SignedOut>, or <ClerkLoaded>, or use the withClerk() HOC.";
var noGuaranteedUserError = "Clerk: You're calling useUser() before there's a guarantee there's an active user. Call useUser() from a child of <SignedIn> or use the withUser() HOC.";

@@ -84,9 +84,9 @@ var browser = typeof window !== 'undefined';

_this.listener = function (_ref) {
var session = _ref.session,
userSession = _ref.userSession,
var client = _ref.client,
session = _ref.session,
user = _ref.user;
_this.setState({
client: client,
session: session,
userSession: userSession,
user: user

@@ -110,4 +110,4 @@ });

_this.state = {
client: _this.clerk.client,
session: _this.clerk.session,
userSession: _this.clerk.userSession,
user: _this.clerk.user

@@ -117,4 +117,4 @@ };

_this.state = {
client: undefined,
session: undefined,
userSession: undefined,
user: undefined

@@ -145,11 +145,11 @@ };

_proto.defaultInitialUser = function defaultInitialUser(session) {
var userSession = session.userSessions.find(function (x) {
_proto.defaultInitialUser = function defaultInitialUser(client) {
var session = client.sessions.find(function (x) {
return x.status === 'active';
});
return userSession ? userSession.user : null;
return session ? session.user : null;
};
_proto.render = function render() {
var userSession = this.state.userSession;
var session = this.state.session;

@@ -175,3 +175,3 @@ if (!this.clerk) {

}), React__default.createElement(React__default.Fragment, {
key: userSession ? userSession.id : 'no-usrses'
key: session ? session.id : 'no-usrses'
}, this.props.children));

@@ -212,3 +212,3 @@ };

}
} else if (ctx.clerk && typeof ctx.clerk.userSession === 'undefined') {
} else if (ctx.clerk && typeof ctx.clerk.session === 'undefined') {
return null;

@@ -219,3 +219,3 @@ } else if (ctx.guaranteedLoaded) {

}));
} else if (ctx.clerk.session) {
} else if (ctx.clerk.client) {
return React__default.createElement(ClerkContext.Provider, {

@@ -243,7 +243,7 @@ value: _extends({}, ctx, {

throw new Error(noProviderError);
} else if (ctx.clerk && typeof ctx.clerk.userSession === 'undefined') {
} else if (ctx.clerk && typeof ctx.clerk.session === 'undefined') {
return null;
} else if (ctx.guaranteedLoaded) {
return children(ctx.clerk);
} else if (ctx.clerk.session) {
} else if (ctx.clerk.client) {
return React__default.createElement(ClerkContext.Provider, {

@@ -268,4 +268,4 @@ value: _extends({}, ctx, {

throw new Error(noProviderError);
} else if (ctx.guaranteedUser && ctx.clerk.userSession) {
return ctx.clerk.userSession.user;
} else if (ctx.guaranteedUser && ctx.clerk.session) {
return ctx.clerk.session.user;
} else {

@@ -289,7 +289,7 @@ throw new Error(noGuaranteedUserError);

}
} else if (ctx.guaranteedUser && ctx.clerk.userSession) {
} else if (ctx.guaranteedUser && ctx.clerk.session) {
return React__default.createElement(Component, Object.assign({}, props, {
user: ctx.clerk.userSession.user
user: ctx.clerk.session.user
}));
} else if (ctx.clerk.session && ctx.clerk.userSession) {
} else if (ctx.clerk.client && ctx.clerk.session) {
return React__default.createElement(ClerkContext.Provider, {

@@ -301,3 +301,3 @@ value: _extends({}, ctx, {

}, React__default.createElement(Component, Object.assign({}, props, {
user: ctx.clerk.userSession.user
user: ctx.clerk.session.user
})));

@@ -319,5 +319,5 @@ } else {

throw new Error(noProviderError);
} else if (ctx.guaranteedUser && ctx.clerk.userSession) {
return children(ctx.clerk.userSession.user);
} else if (ctx.clerk.session && ctx.clerk.userSession) {
} else if (ctx.guaranteedUser && ctx.clerk.session) {
return children(ctx.clerk.session.user);
} else if (ctx.clerk.client && ctx.clerk.session) {
return React__default.createElement(ClerkContext.Provider, {

@@ -328,3 +328,3 @@ value: _extends({}, ctx, {

})
}, children(ctx.clerk.userSession.user));
}, children(ctx.clerk.session.user));
} else {

@@ -464,3 +464,3 @@ return null;

clerk = _ref9.clerk;
return clerk.userSession === null ? React__default.createElement(React__default.Fragment, null, children) : null;
return clerk.session === null ? React__default.createElement(React__default.Fragment, null, children) : null;
}, 'SignedOut');

@@ -484,5 +484,5 @@ var ClerkLoaded = /*#__PURE__*/withClerk(function (_ref10) {

this.setUserSession = function (userSession, beforeEmit) {
this.setSession = function (session, beforeEmit) {
if (_this3.clerkjs) {
return _this3.clerkjs.setUserSession(userSession, beforeEmit);
return _this3.clerkjs.setSession(session, beforeEmit);
} else {

@@ -614,4 +614,4 @@ return Promise.reject();

_this3.ssrData = JSON.stringify({
client: _this3.client,
session: _this3.session,
userSession: _this3.userSession,
token: token

@@ -700,4 +700,4 @@ });

var parsedData = JSON.parse(this.ssrData);
this.ssrClient = parsedData.client;
this.ssrSession = parsedData.session;
this.ssrUserSession = parsedData.userSession;
}

@@ -729,6 +729,6 @@ }

_createClass(IsomorphicClerk, [{
key: "session",
key: "client",
get: function get() {
if (this.clerkjs) {
return this.clerkjs.session; // TODO: add ssr condition
return this.clerkjs.client; // TODO: add ssr condition
} else {

@@ -739,6 +739,6 @@ return undefined;

}, {
key: "userSession",
key: "session",
get: function get() {
if (this.clerkjs) {
return this.clerkjs.userSession; // TODO: add ssr condition
return this.clerkjs.session; // TODO: add ssr condition
} else {

@@ -745,0 +745,0 @@ return undefined;

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("react"),n=(e=r)&&"object"==typeof e&&"default"in e?e.default:e;function t(){return(t=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e}).apply(this,arguments)}function o(e,r){e.prototype=Object.create(r.prototype),e.prototype.constructor=e,e.__proto__=r}function s(e,r){if(null==e)return{};var n,t,o={},s=Object.keys(e);for(t=0;t<s.length;t++)r.indexOf(n=s[t])>=0||(o[n]=e[n]);return o}var i="Clerk: You must wrap your application in a <ClerkProvider> component.",u="undefined"!=typeof window,l=null,c=n.createContext(void 0);c.displayName="ClerkContext";var a=function(e){function r(r){var n;if((n=e.call(this,r)||this).listener=function(e){n.setState({session:e.session,userSession:e.userSession,user:e.user})},r.clerk)n.clerk=r.clerk;else if(l)n.clerk=l;else{if(u)throw new Error("Clerk: ClerkProvider is being used in a browser context but loadClerk hasn't been called.");n.clerk=null}return n.state=n.clerk?{session:n.clerk.session,userSession:n.clerk.userSession,user:n.clerk.user}:{session:void 0,userSession:void 0,user:void 0},n}o(r,e);var t=r.prototype;return t.debug=function(){for(var e,r=arguments.length,n=new Array(r),t=0;t<r;t++)n[t]=arguments[t];(e=console).log.apply(e,[this.props.byClerkJS?" CLERK: ":"CLIENT:"].concat(n))},t.componentDidMount=function(){this.clerk&&this.clerk.addListener(this.listener)},t.defaultInitialUser=function(e){var r=e.userSessions.find((function(e){return"active"===e.status}));return r?r.user:null},t.render=function(){var e=this.state.userSession;return this.clerk?n.createElement(c.Provider,{value:{guaranteedLoaded:!1,guaranteedUser:!1,clerk:this.clerk}},this.clerk instanceof C&&this.clerk.ssrData&&n.createElement("script",{type:"application/json","data-clerk":this.clerk.ssrKey,dangerouslySetInnerHTML:{__html:this.clerk.ssrData}}),n.createElement(n.Fragment,{key:e?e.id:"no-usrses"},this.props.children)):n.createElement(n.Fragment,{key:"loading"},this.props.children)},r}(n.PureComponent),p=function(){var e=r.useContext(c);if(e){if(e.guaranteedLoaded)return e.clerk;throw new Error("Clerk: You're calling useClerk() before there's a guarantee the session has been loaded. Call useClerk() from a child of <SignedIn>, <SignedOut>, or <ClerkLoaded>, or use the withClerk() HOC.")}throw new Error(i)},d=function(e,o){e.displayName=o=o||e.displayName||e.name||"Component";var s=function(o){var s=r.useContext(c);if(s)return s.clerk&&void 0===s.clerk.userSession?null:s.guaranteedLoaded?n.createElement(e,Object.assign({},o,{clerk:s.clerk})):s.clerk.session?n.createElement(c.Provider,{value:t({},s,{guaranteedLoaded:!0})},n.createElement(e,Object.assign({},o,{clerk:s.clerk}))):null;if(u)throw new Error(i);return null};return s.displayName="withClerk("+o+")",s},f=function(e,o){e.displayName=o=o||e.displayName||e.name||"Component";var s=function(o){var s=r.useContext(c);if(s)return s.guaranteedUser&&s.clerk.userSession?n.createElement(e,Object.assign({},o,{user:s.clerk.userSession.user})):s.clerk.session&&s.clerk.userSession?n.createElement(c.Provider,{value:t({},s,{guaranteedLoaded:!0,guaranteedUser:!0})},n.createElement(e,Object.assign({},o,{user:s.clerk.userSession.user}))):null;if(u)throw new Error(i);return null};return s.displayName="withUser("+o+")",s},m=function(e){function r(){var r;return(r=e.apply(this,arguments)||this).portalRef=n.createRef(),r}o(r,e);var t=r.prototype;return t.componentDidMount=function(){this.portalRef.current&&this.props.mount(this.portalRef.current,this.props.props)},t.componentWillUnmount=function(){this.portalRef.current&&this.props.unmount(this.portalRef.current)},t.render=function(){return n.createElement("div",{ref:this.portalRef})},r}(n.PureComponent),h=function(e){function r(){return e.apply(this,arguments)||this}o(r,e);var n=r.prototype;return n.componentDidMount=function(){this.props.open(t({onClose:function(){}},this.props.props))},n.componentWillUnmount=function(){this.props.close()},n.render=function(){return null},r}(n.PureComponent),k=d((function(e){var r=s(e,["clerk"]),t=p();return r.mode&&"mounted"===r.mode?n.createElement(m,{mount:t.mountSignIn,unmount:t.unmountSignIn,props:r}):n.createElement(h,{open:t.openSignIn,close:t.closeSignIn,props:r})}),"SignIn"),S=d((function(e){var r=s(e,["clerk"]),t=p();return r.mode&&"mounted"===r.mode?n.createElement(m,{mount:t.mountSignUp,unmount:t.unmountSignUp,props:r}):n.createElement(h,{open:t.openSignUp,close:t.closeSignUp,props:r})}),"SignUp"),g=d((function(e){var r=s(e,["clerk"]),t=p();return n.createElement(m,{mount:t.mountUserProfile,unmount:t.unmountUserProfile,props:r})}),"UserProfile"),v=d((function(e){var r=s(e,["clerk"]),t=p();return n.createElement(m,{mount:t.mountUserButton,unmount:t.unmountUserButton,props:r})}),"UserButton"),y=f((function(e){return n.createElement(n.Fragment,null,e.children)}),"SignedIn"),U=d((function(e){return null===e.clerk.userSession?n.createElement(n.Fragment,null,e.children):null}),"SignedOut"),w=d((function(e){return n.createElement(n.Fragment,null,e.children)}),"ClerkLoaded"),C=function(){function e(e,r){var n=this,t=this;this.listeners=[],this.clerkjs=null,this.componentsReady=!1,this.ssrKey=null,this.ssrData=null,this.setUserSession=function(e,r){return t.clerkjs?t.clerkjs.setUserSession(e,r):Promise.reject()},this.preopenSignIn=null,this.preopenSignUp=null,this.premountSignInNodes=new Map,this.premountSignUpNodes=new Map,this.premountUserProfileNodes=new Map,this.premountUserButtonNodes=new Map,this.openSignIn=function(e){t.clerkjs&&t.componentsReady?t.clerkjs.openSignIn(e):t.preopenSignIn=e},this.closeSignIn=function(){t.clerkjs&&t.componentsReady?t.clerkjs.closeSignIn():t.preopenSignIn=null},this.openSignUp=function(e){t.clerkjs&&t.componentsReady?t.clerkjs.openSignUp(e):t.preopenSignUp=e},this.closeSignUp=function(){t.clerkjs&&t.componentsReady?t.clerkjs.closeSignUp():t.preopenSignUp=null},this.mountSignIn=function(e,r){t.clerkjs&&t.componentsReady?t.clerkjs.mountSignIn(e,r):t.premountSignInNodes.set(e,r)},this.unmountSignIn=function(e){t.clerkjs&&t.componentsReady?t.clerkjs.unmountSignIn(e):t.premountSignInNodes.delete(e)},this.mountSignUp=function(e,r){t.clerkjs&&t.componentsReady?t.clerkjs.mountSignUp(e,r):t.premountSignUpNodes.set(e,r)},this.unmountSignUp=function(e){t.clerkjs&&t.componentsReady?t.clerkjs.unmountSignUp(e):t.premountSignUpNodes.delete(e)},this.mountUserProfile=function(e,r){t.clerkjs&&t.componentsReady?t.clerkjs.mountUserProfile(e,r):t.premountUserProfileNodes.set(e,r)},this.unmountUserProfile=function(e){t.clerkjs&&t.componentsReady?t.clerkjs.unmountUserProfile(e):t.premountUserProfileNodes.delete(e)},this.mountUserButton=function(e,r){t.clerkjs&&t.componentsReady?t.clerkjs.mountUserButton(e,r):t.premountUserButtonNodes.set(e,r)},this.unmountUserButton=function(e){t.clerkjs&&t.componentsReady?t.clerkjs.unmountUserButton(e):t.premountUserButtonNodes.delete(e)},this.addListener=function(e){t.clerkjs?t.clerkjs.addListener(e):t.listeners.push(e)},this.loadFromServer=function(e){if("browser"===t.mode)throw new Error("loadFromServer cannot be called in a browser context.");if(null===t.ssrKey)throw new Error("loadFromServer cannot be called because `ssrKey` is null. Please pass `ssrKey` in the `options` argument of IsomorphicClerk.");t.ssrData=JSON.stringify({session:t.session,userSession:t.userSession,token:e})},this.setClerkJS=function(e){try{return n.clerkjs=e,n.listeners.forEach((function(r){e.addListener(r)})),Promise.resolve(e.onComponentsReady).then((function(){null!==n.preopenSignIn&&e.openSignIn(n.preopenSignIn),null!==n.preopenSignUp&&e.openSignUp(n.preopenSignUp),n.premountSignInNodes.forEach((function(r,n){e.mountSignIn(n,r)})),n.premountSignUpNodes.forEach((function(r,n){e.mountSignUp(n,r)})),n.premountUserProfileNodes.forEach((function(r,n){e.mountUserProfile(n,r)})),n.componentsReady=!0}))}catch(e){return Promise.reject(e)}},this.getScriptUrl=function(){return t.options.baseUrl+"/v1/clerk.js"},this.injectScript=function(){var e=document.createElement("script");if(e.src=t.getScriptUrl(),e.setAttribute("data-provider",t.provider),e.setAttribute("crossorigin","anonymous"),e.async=!0,!document.body)throw new Error("Clerk requires a <body> element.");return document.body.appendChild(e),e},this.provider=e;var o=r||{},i=o.baseUrl,u=o.ssrKey,l=s(o,["baseUrl","ssrKey"]);if(this.options={baseUrl:i||"https://js.clerk.dev",ssrKey:u||null},this.ssrKey=this.options.ssrKey,"undefined"==typeof window)this.mode="server";else{if(this.mode="browser",this.ssrKey){var c=document.querySelector('script[data-clerk="'+this.ssrKey+'"]');if(c){this.ssrData=c.innerHTML;var a=JSON.parse(this.ssrData);this.ssrSession=a.session,this.ssrUserSession=a.userSession}}if(window.Clerk)window.Clerk.init(l),this.setClerkJS(window.Clerk);else{var p=document.querySelector('script[src="'+this.getScriptUrl()+'"]')||this.injectScript();p.addEventListener("load",(function(){if(!window.Clerk)throw new Error("Clerk: IsomorphicClerk failed to find window.Clerk");window.Clerk.init(l),t.setClerkJS(window.Clerk)})),p.addEventListener("error",(function(e){throw console.error(e),new Error("Clerk: Failed to load Clerk")}))}}}var r;return(r=[{key:"session",get:function(){return this.clerkjs?this.clerkjs.session:void 0}},{key:"userSession",get:function(){return this.clerkjs?this.clerkjs.userSession:void 0}},{key:"user",get:function(){return this.clerkjs?this.clerkjs.user:void 0}}])&&function(e,r){for(var n=0;n<r.length;n++){var t=r[n];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,t.key,t)}}(e.prototype,r),e}();exports.ClerkContext=c,exports.ClerkLoaded=w,exports.ClerkProvider=a,exports.SignIn=k,exports.SignUp=S,exports.SignedIn=y,exports.SignedOut=U,exports.UserButton=v,exports.UserProfile=g,exports.WithClerk=function(e){var r=e.children;return n.createElement(c.Consumer,null,(function(e){if("function"==typeof r){if(e)return e.clerk&&void 0===e.clerk.userSession?null:e.guaranteedLoaded?r(e.clerk):e.clerk.session?n.createElement(c.Provider,{value:t({},e,{guaranteedLoaded:!0})},r(e.clerk)):null;throw new Error(i)}throw new Error("Clerk: Child of WithClerk must be a function.")}))},exports.WithUser=function(e){var r=e.children;return n.createElement(c.Consumer,null,(function(e){if("function"==typeof r){if(e)return e.guaranteedUser&&e.clerk.userSession?r(e.clerk.userSession.user):e.clerk.session&&e.clerk.userSession?n.createElement(c.Provider,{value:t({},e,{guaranteedLoaded:!0,guaranteedUser:!0})},r(e.clerk.userSession.user)):null;throw new Error(i)}throw new Error("Clerk: Child of WithClerk must be a function.")}))},exports.isClerkAPIError=function(e){return"clerkError"in e},exports.loadClerk=function(e,r){l=new C(e,t({},r,{ssrKey:"CLERK_IDENTITY_DATA"}))},exports.loadSessionFromToken=function(e){if(null===l)throw new Error("You must call loadClerk before loadSessionFromToken.");l.loadFromServer&&l.loadFromServer(e)},exports.useClerk=p,exports.useUser=function(){var e=r.useContext(c);if(e){if(e.guaranteedUser&&e.clerk.userSession)return e.clerk.userSession.user;throw new Error("Clerk: You're calling useUser() before there's a guarantee there's an active user. Call useUser() from a child of <SignedIn> or use the withUser() HOC.")}throw new Error(i)},exports.withClerk=d,exports.withUser=f;
"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){e.prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n}function s(e,n){if(null==e)return{};var r,t,o={},s=Object.keys(e);for(t=0;t<s.length;t++)n.indexOf(r=s[t])>=0||(o[r]=e[r]);return o}var i="Clerk: You must wrap your application in a <ClerkProvider> component.",l="undefined"!=typeof window,u=null,c=r.createContext(void 0);c.displayName="ClerkContext";var a=function(e){function n(n){var r;if((r=e.call(this,n)||this).listener=function(e){r.setState({client:e.client,session:e.session,user:e.user})},n.clerk)r.clerk=n.clerk;else if(u)r.clerk=u;else{if(l)throw new Error("Clerk: ClerkProvider is being used in a browser context but loadClerk hasn't been called.");r.clerk=null}return r.state=r.clerk?{client:r.clerk.client,session:r.clerk.session,user:r.clerk.user}:{client:void 0,session:void 0,user:void 0},r}o(n,e);var t=n.prototype;return t.debug=function(){for(var e,n=arguments.length,r=new Array(n),t=0;t<n;t++)r[t]=arguments[t];(e=console).log.apply(e,[this.props.byClerkJS?" CLERK: ":"CLIENT:"].concat(r))},t.componentDidMount=function(){this.clerk&&this.clerk.addListener(this.listener)},t.defaultInitialUser=function(e){var n=e.sessions.find((function(e){return"active"===e.status}));return n?n.user:null},t.render=function(){var e=this.state.session;return this.clerk?r.createElement(c.Provider,{value:{guaranteedLoaded:!1,guaranteedUser:!1,clerk:this.clerk}},this.clerk instanceof C&&this.clerk.ssrData&&r.createElement("script",{type:"application/json","data-clerk":this.clerk.ssrKey,dangerouslySetInnerHTML:{__html:this.clerk.ssrData}}),r.createElement(r.Fragment,{key:e?e.id:"no-usrses"},this.props.children)):r.createElement(r.Fragment,{key:"loading"},this.props.children)},n}(r.PureComponent),p=function(){var e=n.useContext(c);if(e){if(e.guaranteedLoaded)return e.clerk;throw new Error("Clerk: You're calling useClerk() before there's a guarantee the client has been loaded. Call useClerk() from a child of <SignedIn>, <SignedOut>, or <ClerkLoaded>, or use the withClerk() HOC.")}throw new Error(i)},d=function(e,o){e.displayName=o=o||e.displayName||e.name||"Component";var s=function(o){var s=n.useContext(c);if(s)return s.clerk&&void 0===s.clerk.session?null:s.guaranteedLoaded?r.createElement(e,Object.assign({},o,{clerk:s.clerk})):s.clerk.client?r.createElement(c.Provider,{value:t({},s,{guaranteedLoaded:!0})},r.createElement(e,Object.assign({},o,{clerk:s.clerk}))):null;if(l)throw new Error(i);return null};return s.displayName="withClerk("+o+")",s},f=function(e,o){e.displayName=o=o||e.displayName||e.name||"Component";var s=function(o){var s=n.useContext(c);if(s)return s.guaranteedUser&&s.clerk.session?r.createElement(e,Object.assign({},o,{user:s.clerk.session.user})):s.clerk.client&&s.clerk.session?r.createElement(c.Provider,{value:t({},s,{guaranteedLoaded:!0,guaranteedUser:!0})},r.createElement(e,Object.assign({},o,{user:s.clerk.session.user}))):null;if(l)throw new Error(i);return null};return s.displayName="withUser("+o+")",s},m=function(e){function n(){var n;return(n=e.apply(this,arguments)||this).portalRef=r.createRef(),n}o(n,e);var t=n.prototype;return t.componentDidMount=function(){this.portalRef.current&&this.props.mount(this.portalRef.current,this.props.props)},t.componentWillUnmount=function(){this.portalRef.current&&this.props.unmount(this.portalRef.current)},t.render=function(){return r.createElement("div",{ref:this.portalRef})},n}(r.PureComponent),h=function(e){function n(){return e.apply(this,arguments)||this}o(n,e);var r=n.prototype;return r.componentDidMount=function(){this.props.open(t({onClose:function(){}},this.props.props))},r.componentWillUnmount=function(){this.props.close()},r.render=function(){return null},n}(r.PureComponent),k=d((function(e){var n=s(e,["clerk"]),t=p();return n.mode&&"mounted"===n.mode?r.createElement(m,{mount:t.mountSignIn,unmount:t.unmountSignIn,props:n}):r.createElement(h,{open:t.openSignIn,close:t.closeSignIn,props:n})}),"SignIn"),g=d((function(e){var n=s(e,["clerk"]),t=p();return n.mode&&"mounted"===n.mode?r.createElement(m,{mount:t.mountSignUp,unmount:t.unmountSignUp,props:n}):r.createElement(h,{open:t.openSignUp,close:t.closeSignUp,props:n})}),"SignUp"),S=d((function(e){var n=s(e,["clerk"]),t=p();return r.createElement(m,{mount:t.mountUserProfile,unmount:t.unmountUserProfile,props:n})}),"UserProfile"),v=d((function(e){var n=s(e,["clerk"]),t=p();return r.createElement(m,{mount:t.mountUserButton,unmount:t.unmountUserButton,props:n})}),"UserButton"),y=f((function(e){return r.createElement(r.Fragment,null,e.children)}),"SignedIn"),U=d((function(e){return null===e.clerk.session?r.createElement(r.Fragment,null,e.children):null}),"SignedOut"),w=d((function(e){return r.createElement(r.Fragment,null,e.children)}),"ClerkLoaded"),C=function(){function e(e,n){var r=this,t=this;this.listeners=[],this.clerkjs=null,this.componentsReady=!1,this.ssrKey=null,this.ssrData=null,this.setSession=function(e,n){return t.clerkjs?t.clerkjs.setSession(e,n):Promise.reject()},this.preopenSignIn=null,this.preopenSignUp=null,this.premountSignInNodes=new Map,this.premountSignUpNodes=new Map,this.premountUserProfileNodes=new Map,this.premountUserButtonNodes=new Map,this.openSignIn=function(e){t.clerkjs&&t.componentsReady?t.clerkjs.openSignIn(e):t.preopenSignIn=e},this.closeSignIn=function(){t.clerkjs&&t.componentsReady?t.clerkjs.closeSignIn():t.preopenSignIn=null},this.openSignUp=function(e){t.clerkjs&&t.componentsReady?t.clerkjs.openSignUp(e):t.preopenSignUp=e},this.closeSignUp=function(){t.clerkjs&&t.componentsReady?t.clerkjs.closeSignUp():t.preopenSignUp=null},this.mountSignIn=function(e,n){t.clerkjs&&t.componentsReady?t.clerkjs.mountSignIn(e,n):t.premountSignInNodes.set(e,n)},this.unmountSignIn=function(e){t.clerkjs&&t.componentsReady?t.clerkjs.unmountSignIn(e):t.premountSignInNodes.delete(e)},this.mountSignUp=function(e,n){t.clerkjs&&t.componentsReady?t.clerkjs.mountSignUp(e,n):t.premountSignUpNodes.set(e,n)},this.unmountSignUp=function(e){t.clerkjs&&t.componentsReady?t.clerkjs.unmountSignUp(e):t.premountSignUpNodes.delete(e)},this.mountUserProfile=function(e,n){t.clerkjs&&t.componentsReady?t.clerkjs.mountUserProfile(e,n):t.premountUserProfileNodes.set(e,n)},this.unmountUserProfile=function(e){t.clerkjs&&t.componentsReady?t.clerkjs.unmountUserProfile(e):t.premountUserProfileNodes.delete(e)},this.mountUserButton=function(e,n){t.clerkjs&&t.componentsReady?t.clerkjs.mountUserButton(e,n):t.premountUserButtonNodes.set(e,n)},this.unmountUserButton=function(e){t.clerkjs&&t.componentsReady?t.clerkjs.unmountUserButton(e):t.premountUserButtonNodes.delete(e)},this.addListener=function(e){t.clerkjs?t.clerkjs.addListener(e):t.listeners.push(e)},this.loadFromServer=function(e){if("browser"===t.mode)throw new Error("loadFromServer cannot be called in a browser context.");if(null===t.ssrKey)throw new Error("loadFromServer cannot be called because `ssrKey` is null. Please pass `ssrKey` in the `options` argument of IsomorphicClerk.");t.ssrData=JSON.stringify({client:t.client,session:t.session,token:e})},this.setClerkJS=function(e){try{return r.clerkjs=e,r.listeners.forEach((function(n){e.addListener(n)})),Promise.resolve(e.onComponentsReady).then((function(){null!==r.preopenSignIn&&e.openSignIn(r.preopenSignIn),null!==r.preopenSignUp&&e.openSignUp(r.preopenSignUp),r.premountSignInNodes.forEach((function(n,r){e.mountSignIn(r,n)})),r.premountSignUpNodes.forEach((function(n,r){e.mountSignUp(r,n)})),r.premountUserProfileNodes.forEach((function(n,r){e.mountUserProfile(r,n)})),r.componentsReady=!0}))}catch(e){return Promise.reject(e)}},this.getScriptUrl=function(){return t.options.baseUrl+"/v1/clerk.js"},this.injectScript=function(){var e=document.createElement("script");if(e.src=t.getScriptUrl(),e.setAttribute("data-provider",t.provider),e.setAttribute("crossorigin","anonymous"),e.async=!0,!document.body)throw new Error("Clerk requires a <body> element.");return document.body.appendChild(e),e},this.provider=e;var o=n||{},i=o.baseUrl,l=o.ssrKey,u=s(o,["baseUrl","ssrKey"]);if(this.options={baseUrl:i||"https://js.clerk.dev",ssrKey:l||null},this.ssrKey=this.options.ssrKey,"undefined"==typeof window)this.mode="server";else{if(this.mode="browser",this.ssrKey){var c=document.querySelector('script[data-clerk="'+this.ssrKey+'"]');if(c){this.ssrData=c.innerHTML;var a=JSON.parse(this.ssrData);this.ssrClient=a.client,this.ssrSession=a.session}}if(window.Clerk)window.Clerk.init(u),this.setClerkJS(window.Clerk);else{var p=document.querySelector('script[src="'+this.getScriptUrl()+'"]')||this.injectScript();p.addEventListener("load",(function(){if(!window.Clerk)throw new Error("Clerk: IsomorphicClerk failed to find window.Clerk");window.Clerk.init(u),t.setClerkJS(window.Clerk)})),p.addEventListener("error",(function(e){throw console.error(e),new Error("Clerk: Failed to load Clerk")}))}}}var n;return(n=[{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}}])&&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}();exports.ClerkContext=c,exports.ClerkLoaded=w,exports.ClerkProvider=a,exports.SignIn=k,exports.SignUp=g,exports.SignedIn=y,exports.SignedOut=U,exports.UserButton=v,exports.UserProfile=S,exports.WithClerk=function(e){var n=e.children;return r.createElement(c.Consumer,null,(function(e){if("function"==typeof n){if(e)return e.clerk&&void 0===e.clerk.session?null:e.guaranteedLoaded?n(e.clerk):e.clerk.client?r.createElement(c.Provider,{value:t({},e,{guaranteedLoaded:!0})},n(e.clerk)):null;throw new Error(i)}throw new Error("Clerk: Child of WithClerk must be a function.")}))},exports.WithUser=function(e){var n=e.children;return r.createElement(c.Consumer,null,(function(e){if("function"==typeof n){if(e)return e.guaranteedUser&&e.clerk.session?n(e.clerk.session.user):e.clerk.client&&e.clerk.session?r.createElement(c.Provider,{value:t({},e,{guaranteedLoaded:!0,guaranteedUser:!0})},n(e.clerk.session.user)):null;throw new Error(i)}throw new Error("Clerk: Child of WithClerk must be a function.")}))},exports.isClerkAPIError=function(e){return"clerkError"in e},exports.loadClerk=function(e,n){u=new C(e,t({},n,{ssrKey:"CLERK_IDENTITY_DATA"}))},exports.loadSessionFromToken=function(e){if(null===u)throw new Error("You must call loadClerk before loadSessionFromToken.");u.loadFromServer&&u.loadFromServer(e)},exports.useClerk=p,exports.useUser=function(){var e=n.useContext(c);if(e){if(e.guaranteedUser&&e.clerk.session)return e.clerk.session.user;throw new Error("Clerk: You're calling useUser() before there's a guarantee there's an active user. Call useUser() from a child of <SignedIn> or use the withUser() HOC.")}throw new Error(i)},exports.withClerk=d,exports.withUser=f;
//# sourceMappingURL=clerk-react.cjs.production.min.js.map

@@ -60,3 +60,3 @@ import React, { useContext } from 'react';

var noProviderError = 'Clerk: You must wrap your application in a <ClerkProvider> component.';
var noGuaranteeError = "Clerk: You're calling useClerk() before there's a guarantee the session has been loaded. Call useClerk() from a child of <SignedIn>, <SignedOut>, or <ClerkLoaded>, or use the withClerk() HOC.";
var noGuaranteeError = "Clerk: You're calling useClerk() before there's a guarantee the client has been loaded. Call useClerk() from a child of <SignedIn>, <SignedOut>, or <ClerkLoaded>, or use the withClerk() HOC.";
var noGuaranteedUserError = "Clerk: You're calling useUser() before there's a guarantee there's an active user. Call useUser() from a child of <SignedIn> or use the withUser() HOC.";

@@ -77,9 +77,9 @@ var browser = typeof window !== 'undefined';

_this.listener = function (_ref) {
var session = _ref.session,
userSession = _ref.userSession,
var client = _ref.client,
session = _ref.session,
user = _ref.user;
_this.setState({
client: client,
session: session,
userSession: userSession,
user: user

@@ -103,4 +103,4 @@ });

_this.state = {
client: _this.clerk.client,
session: _this.clerk.session,
userSession: _this.clerk.userSession,
user: _this.clerk.user

@@ -110,4 +110,4 @@ };

_this.state = {
client: undefined,
session: undefined,
userSession: undefined,
user: undefined

@@ -138,11 +138,11 @@ };

_proto.defaultInitialUser = function defaultInitialUser(session) {
var userSession = session.userSessions.find(function (x) {
_proto.defaultInitialUser = function defaultInitialUser(client) {
var session = client.sessions.find(function (x) {
return x.status === 'active';
});
return userSession ? userSession.user : null;
return session ? session.user : null;
};
_proto.render = function render() {
var userSession = this.state.userSession;
var session = this.state.session;

@@ -168,3 +168,3 @@ if (!this.clerk) {

}), React.createElement(React.Fragment, {
key: userSession ? userSession.id : 'no-usrses'
key: session ? session.id : 'no-usrses'
}, this.props.children));

@@ -205,3 +205,3 @@ };

}
} else if (ctx.clerk && typeof ctx.clerk.userSession === 'undefined') {
} else if (ctx.clerk && typeof ctx.clerk.session === 'undefined') {
return null;

@@ -212,3 +212,3 @@ } else if (ctx.guaranteedLoaded) {

}));
} else if (ctx.clerk.session) {
} else if (ctx.clerk.client) {
return React.createElement(ClerkContext.Provider, {

@@ -236,7 +236,7 @@ value: _extends({}, ctx, {

throw new Error(noProviderError);
} else if (ctx.clerk && typeof ctx.clerk.userSession === 'undefined') {
} else if (ctx.clerk && typeof ctx.clerk.session === 'undefined') {
return null;
} else if (ctx.guaranteedLoaded) {
return children(ctx.clerk);
} else if (ctx.clerk.session) {
} else if (ctx.clerk.client) {
return React.createElement(ClerkContext.Provider, {

@@ -261,4 +261,4 @@ value: _extends({}, ctx, {

throw new Error(noProviderError);
} else if (ctx.guaranteedUser && ctx.clerk.userSession) {
return ctx.clerk.userSession.user;
} else if (ctx.guaranteedUser && ctx.clerk.session) {
return ctx.clerk.session.user;
} else {

@@ -282,7 +282,7 @@ throw new Error(noGuaranteedUserError);

}
} else if (ctx.guaranteedUser && ctx.clerk.userSession) {
} else if (ctx.guaranteedUser && ctx.clerk.session) {
return React.createElement(Component, Object.assign({}, props, {
user: ctx.clerk.userSession.user
user: ctx.clerk.session.user
}));
} else if (ctx.clerk.session && ctx.clerk.userSession) {
} else if (ctx.clerk.client && ctx.clerk.session) {
return React.createElement(ClerkContext.Provider, {

@@ -294,3 +294,3 @@ value: _extends({}, ctx, {

}, React.createElement(Component, Object.assign({}, props, {
user: ctx.clerk.userSession.user
user: ctx.clerk.session.user
})));

@@ -312,5 +312,5 @@ } else {

throw new Error(noProviderError);
} else if (ctx.guaranteedUser && ctx.clerk.userSession) {
return children(ctx.clerk.userSession.user);
} else if (ctx.clerk.session && ctx.clerk.userSession) {
} else if (ctx.guaranteedUser && ctx.clerk.session) {
return children(ctx.clerk.session.user);
} else if (ctx.clerk.client && ctx.clerk.session) {
return React.createElement(ClerkContext.Provider, {

@@ -321,3 +321,3 @@ value: _extends({}, ctx, {

})
}, children(ctx.clerk.userSession.user));
}, children(ctx.clerk.session.user));
} else {

@@ -457,3 +457,3 @@ return null;

clerk = _ref9.clerk;
return clerk.userSession === null ? React.createElement(React.Fragment, null, children) : null;
return clerk.session === null ? React.createElement(React.Fragment, null, children) : null;
}, 'SignedOut');

@@ -477,5 +477,5 @@ var ClerkLoaded = /*#__PURE__*/withClerk(function (_ref10) {

this.setUserSession = function (userSession, beforeEmit) {
this.setSession = function (session, beforeEmit) {
if (_this3.clerkjs) {
return _this3.clerkjs.setUserSession(userSession, beforeEmit);
return _this3.clerkjs.setSession(session, beforeEmit);
} else {

@@ -607,4 +607,4 @@ return Promise.reject();

_this3.ssrData = JSON.stringify({
client: _this3.client,
session: _this3.session,
userSession: _this3.userSession,
token: token

@@ -693,4 +693,4 @@ });

var parsedData = JSON.parse(this.ssrData);
this.ssrClient = parsedData.client;
this.ssrSession = parsedData.session;
this.ssrUserSession = parsedData.userSession;
}

@@ -722,6 +722,6 @@ }

_createClass(IsomorphicClerk, [{
key: "session",
key: "client",
get: function get() {
if (this.clerkjs) {
return this.clerkjs.session; // TODO: add ssr condition
return this.clerkjs.client; // TODO: add ssr condition
} else {

@@ -732,6 +732,6 @@ return undefined;

}, {
key: "userSession",
key: "session",
get: function get() {
if (this.clerkjs) {
return this.clerkjs.userSession; // TODO: add ssr condition
return this.clerkjs.session; // TODO: add ssr condition
} else {

@@ -738,0 +738,0 @@ return undefined;

import React from 'react';
import { SignInProps, SignUpProps, UserProfileProps, UserButtonProps, ListenerEmission, ClerkContextType, ContextProps, ContextState, LoadedClerkType, IsomorphicClerkOptions, ClerkAPIError, UserResource } from './types';
import { ClerkAPIError, ClerkContextType, ContextProps, ContextState, IsomorphicClerkOptions, ListenerEmission, LoadedClerkType, SignInProps, SignUpProps, UserButtonProps, UserProfileProps, UserResource } from './types';
export * from './types';
export { loadClerk, loadSessionFromToken, ClerkContext, ClerkProvider, SignIn, SignUp, UserProfile, UserButton, useClerk, withClerk, WithClerk, useUser, withUser, WithUser, SignedIn, SignedOut, ClerkLoaded, isClerkAPIError, };
declare const ClerkContext: React.Context<ClerkContextType | undefined>;

@@ -9,5 +10,5 @@ declare class ClerkProvider extends React.PureComponent<ContextProps, ContextState> {

constructor(props: ContextProps);
listener: ({ session, userSession, user }: ListenerEmission) => void;
listener: ({ client, session, user }: ListenerEmission) => void;
componentDidMount(): void;
defaultInitialUser(session: any): any;
defaultInitialUser(client: any): any;
render(): JSX.Element;

@@ -39,2 +40,1 @@ }

declare const loadSessionFromToken: (token: string) => void;
export { loadClerk, loadSessionFromToken, ClerkContext, ClerkProvider, SignIn, SignUp, UserProfile, UserButton, useClerk, withClerk, WithClerk, useUser, withUser, WithUser, SignedIn, SignedOut, ClerkLoaded, isClerkAPIError, };

@@ -12,3 +12,3 @@ declare global {

export interface InitOpts {
selectInitialUserSession?: (session: SessionResource) => UserSessionResource | null;
selectInitialSession?: (client: ClientResource) => SessionResource | null;
navigate?: historyChange;

@@ -21,7 +21,7 @@ signInURL?: string;

userProfileNavigate?: historyChange;
afterSignIn?: (userSession: UserSessionResource) => void;
afterSignUp?: (userSession: UserSessionResource) => void;
afterSignIn?: (session: SessionResource) => void;
afterSignUp?: (session: SessionResource) => void;
afterSignOutOne?: () => void;
afterSignOutAll?: () => void;
afterSwitchUserSession?: (userSession: UserSessionResource) => void;
afterSwitchSession?: (session: SessionResource) => void;
}

@@ -61,4 +61,4 @@ export interface ClerkAPIFieldErrorJSON {

export interface ListenerEmission {
session: SessionResource;
userSession?: UserSessionResource | null;
client: ClientResource;
session?: SessionResource | null;
user?: UserResource | null;

@@ -71,4 +71,4 @@ }

export interface ContextState {
session?: SessionResource;
userSession?: UserSessionResource | null;
client?: ClientResource;
session?: SessionResource | null;
user?: UserResource | null;

@@ -92,3 +92,3 @@ }

init: (opts?: InitOpts) => Promise<void>;
updateSession: (session: SessionResource) => void;
updateClient: (client: ClientResource) => void;
onComponentsReady: Promise<void>;

@@ -103,7 +103,7 @@ components: any;

export interface LoadedClerkType extends ClerkType {
session: SessionResource;
client: ClientResource;
}
export interface ClerkType {
session?: SessionResource;
userSession?: UserSessionResource | null;
client?: ClientResource;
session?: SessionResource | null;
user?: UserResource | null;

@@ -123,5 +123,5 @@ openSignIn: (props?: SignInProps) => void;

addListener: (listener: (emission: ListenerEmission) => void) => void;
setUserSession: (userSession: UserSessionResource | string | null, beforeEmit?: (userSession: UserSessionResource | null) => Promise<any> | void) => Promise<void>;
setSession: (session: SessionResource | string | null, beforeEmit?: (session: SessionResource | null) => Promise<any> | void) => Promise<void>;
}
export interface SignInProps extends Omit<InitOpts, 'selectInitialUserSession'> {
export interface SignInProps extends Omit<InitOpts, 'selectInitialSession'> {
mode?: 'modal' | 'mounted';

@@ -131,3 +131,3 @@ path?: string;

}
export interface SignUpProps extends Omit<InitOpts, 'selectInitialUserSession'> {
export interface SignUpProps extends Omit<InitOpts, 'selectInitialSession'> {
mode?: 'modal' | 'mounted';

@@ -137,6 +137,6 @@ path?: string;

}
export interface UserProfileProps extends Omit<InitOpts, 'selectInitialUserSession'> {
export interface UserProfileProps extends Omit<InitOpts, 'selectInitialSession'> {
path: string;
}
export declare type UserButtonProps = Omit<InitOpts, 'selectInitialUserSession'>;
export declare type UserButtonProps = Omit<InitOpts, 'selectInitialSession'>;
export interface ClerkResource {

@@ -149,5 +149,7 @@ provider: string;

}
export interface SessionJSON extends ClerkResourceJSON {
export interface ClientJSON extends ClerkResourceJSON {
object: 'client';
id: string;
status: any;
user_sessions: UserSessionJSON[];
sessions: SessionJSON[];
sign_in_attempt: SignInJSON | null;

@@ -157,10 +159,10 @@ sign_up_attempt: SignUpJSON | null;

}
export interface SessionResource extends ClerkResource {
userSessions: UserSessionResource[];
export interface ClientResource extends ClerkResource {
sessions: SessionResource[];
signInAttempt: SignInResource;
signUpAttempt: SignUpResource;
destroy: () => Promise<void>;
lastActiveUserSessionId: string | null;
lastActiveSessionId: string | null;
}
export declare type SessionResourceC = ClerkResourceC<SessionResource, SessionJSON | null>;
export declare type ClientResourceC = ClerkResourceC<ClientResource, ClientJSON | null>;
export interface EmailAddressJSON extends ClerkResourceJSON {

@@ -244,3 +246,3 @@ object: 'email_address';

factorTwoVerification: VerificationResource;
createdUserSessionId: string | null;
createdSessionId: string | null;
create: (params: any) => Promise<SignInResource>;

@@ -287,3 +289,3 @@ prepareFactorOne: (params: any) => Promise<SignInResource>;

hasPassword: boolean;
createdUserSessionId: string | null;
createdSessionId: string | null;
abandonAt: number | null;

@@ -335,4 +337,4 @@ create: (params: any) => Promise<SignUpResource>;

export declare type UserResourceC = ClerkResourceC<UserResource, UserJSON>;
export interface UserSessionJSON extends ClerkResourceJSON {
object: 'user_session';
export interface SessionJSON extends ClerkResourceJSON {
object: 'session';
id: string;

@@ -344,3 +346,3 @@ status: string;

}
export interface UserSessionResource extends ClerkResource {
export interface SessionResource extends ClerkResource {
id: string;

@@ -351,7 +353,7 @@ status: string;

user: UserResource;
end: () => Promise<UserSessionResource>;
remove: () => Promise<UserSessionResource>;
touch: () => Promise<UserSessionResource>;
end: () => Promise<SessionResource>;
remove: () => Promise<SessionResource>;
touch: () => Promise<SessionResource>;
}
export declare type UserSessionResourceC = ClerkResourceC<UserSessionResource, UserSessionJSON>;
export declare type SessionResourceC = ClerkResourceC<SessionResource, SessionJSON>;
export interface VerificationPrepareParams {

@@ -358,0 +360,0 @@ strategy: string;

{
"version": "0.1.2-beta.3",
"version": "0.1.2-beta.4",
"license": "MIT",

@@ -4,0 +4,0 @@ "main": "dist/index.js",

@@ -15,5 +15,3 @@ declare global {

export interface InitOpts {
selectInitialUserSession?: (
session: SessionResource
) => UserSessionResource | null;
selectInitialSession?: (client: ClientResource) => SessionResource | null;
navigate?: historyChange;

@@ -26,7 +24,7 @@ signInURL?: string;

userProfileNavigate?: historyChange;
afterSignIn?: (userSession: UserSessionResource) => void;
afterSignUp?: (userSession: UserSessionResource) => void;
afterSignIn?: (session: SessionResource) => void;
afterSignUp?: (session: SessionResource) => void;
afterSignOutOne?: () => void;
afterSignOutAll?: () => void;
afterSwitchUserSession?: (userSession: UserSessionResource) => void;
afterSwitchSession?: (session: SessionResource) => void;
}

@@ -70,4 +68,4 @@

export interface ListenerEmission {
session: SessionResource;
userSession?: UserSessionResource | null;
client: ClientResource;
session?: SessionResource | null;
user?: UserResource | null;

@@ -82,4 +80,4 @@ }

export interface ContextState {
session?: SessionResource;
userSession?: UserSessionResource | null;
client?: ClientResource;
session?: SessionResource | null;
user?: UserResource | null;

@@ -107,3 +105,3 @@ }

init: (opts?: InitOpts) => Promise<void>;
updateSession: (session: SessionResource) => void;
updateClient: (client: ClientResource) => void;
onComponentsReady: Promise<void>;

@@ -121,8 +119,8 @@ components: any;

export interface LoadedClerkType extends ClerkType {
session: SessionResource;
client: ClientResource;
}
export interface ClerkType {
session?: SessionResource;
userSession?: UserSessionResource | null;
client?: ClientResource;
session?: SessionResource | null;
user?: UserResource | null;

@@ -142,7 +140,5 @@ openSignIn: (props?: SignInProps) => void;

addListener: (listener: (emission: ListenerEmission) => void) => void;
setUserSession: (
userSession: UserSessionResource | string | null,
beforeEmit?: (
userSession: UserSessionResource | null
) => Promise<any> | void
setSession: (
session: SessionResource | string | null,
beforeEmit?: (session: SessionResource | null) => Promise<any> | void
) => Promise<void>;

@@ -153,4 +149,3 @@ }

export interface SignInProps
extends Omit<InitOpts, 'selectInitialUserSession'> {
export interface SignInProps extends Omit<InitOpts, 'selectInitialSession'> {
mode?: 'modal' | 'mounted';

@@ -161,4 +156,3 @@ path?: string;

export interface SignUpProps
extends Omit<InitOpts, 'selectInitialUserSession'> {
export interface SignUpProps extends Omit<InitOpts, 'selectInitialSession'> {
mode?: 'modal' | 'mounted';

@@ -170,7 +164,7 @@ path?: string;

export interface UserProfileProps
extends Omit<InitOpts, 'selectInitialUserSession'> {
extends Omit<InitOpts, 'selectInitialSession'> {
path: string;
}
export type UserButtonProps = Omit<InitOpts, 'selectInitialUserSession'>;
export type UserButtonProps = Omit<InitOpts, 'selectInitialSession'>;

@@ -191,6 +185,8 @@ /////////////////////////////

// Session
export interface SessionJSON extends ClerkResourceJSON {
// Client
export interface ClientJSON extends ClerkResourceJSON {
object: 'client';
id: string;
status: any;
user_sessions: UserSessionJSON[];
sessions: SessionJSON[];
sign_in_attempt: SignInJSON | null;

@@ -200,13 +196,10 @@ sign_up_attempt: SignUpJSON | null;

}
export interface SessionResource extends ClerkResource {
userSessions: UserSessionResource[];
export interface ClientResource extends ClerkResource {
sessions: SessionResource[];
signInAttempt: SignInResource;
signUpAttempt: SignUpResource;
destroy: () => Promise<void>;
lastActiveUserSessionId: string | null;
lastActiveSessionId: string | null;
}
export type SessionResourceC = ClerkResourceC<
SessionResource,
SessionJSON | null
>;
export type ClientResourceC = ClerkResourceC<ClientResource, ClientJSON | null>;

@@ -321,3 +314,3 @@ // EmailAddress

factorTwoVerification: VerificationResource;
createdUserSessionId: string | null;
createdSessionId: string | null;
create: (params: any) => Promise<SignInResource>;

@@ -378,3 +371,3 @@ prepareFactorOne: (params: any) => Promise<SignInResource>;

hasPassword: boolean;
createdUserSessionId: string | null;
createdSessionId: string | null;
abandonAt: number | null;

@@ -436,5 +429,5 @@ create: (params: any) => Promise<SignUpResource>;

// UserSession
export interface UserSessionJSON extends ClerkResourceJSON {
object: 'user_session';
// Session
export interface SessionJSON extends ClerkResourceJSON {
object: 'session';
id: string;

@@ -446,3 +439,3 @@ status: string;

}
export interface UserSessionResource extends ClerkResource {
export interface SessionResource extends ClerkResource {
id: string;

@@ -453,11 +446,8 @@ status: string;

user: UserResource;
end: () => Promise<UserSessionResource>;
remove: () => Promise<UserSessionResource>;
touch: () => Promise<UserSessionResource>;
end: () => Promise<SessionResource>;
remove: () => Promise<SessionResource>;
touch: () => Promise<SessionResource>;
}
export type UserSessionResourceC = ClerkResourceC<
UserSessionResource,
UserSessionJSON
>;
export type SessionResourceC = ClerkResourceC<SessionResource, SessionJSON>;

@@ -464,0 +454,0 @@ // Verifcation

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

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