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

@clerk/shared

Package Overview
Dependencies
Maintainers
7
Versions
2137
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@clerk/shared - npm Package Compare versions

Comparing version 0.17.2 to 0.18.0-snap.9208293

dist/cjs/errors/thrower.js

63

dist/esm/index.js

@@ -1,26 +0,39 @@

import{c as Z}from"./chunk-GW3MP3TA.js";var It=Object.freeze({InvalidFrontendApiErrorMessage:"The frontendApi passed to Clerk is invalid. You can get your Frontend API key at https://dashboard.clerk.com/last-active?path=api-keys. (key={{key}})",InvalidProxyUrlErrorMessage:"The proxyUrl passed to Clerk is invalid. The expected value for proxyUrl is an absolute URL or a relative path with a leading '/'. (key={{url}})",InvalidPublishableKeyErrorMessage:"The publishableKey passed to Clerk is invalid. You can get your Publishable key at https://dashboard.clerk.com/last-active?path=api-keys. (key={{key}})",MissingPublishableKeyErrorMessage:"Missing publishableKey. You can get your key at https://dashboard.clerk.com/last-active?path=api-keys."});function Lt({packageName:e,customMessages:r}){let t=e,n={...It,...r};function o(i,a){if(!a)return`${t}: ${i}`;let s=i,f=i.matchAll(/{{([a-zA-Z0-9-_]+)}}/g);for(let u of f){let c=(a[u[1]]||"").toString();s=s.replace(`{{${u[1]}}}`,c)}return`${t}: ${s}`}return{setPackageName({packageName:i}){return typeof i=="string"&&(t=i),this},setMessages({customMessages:i}){return Object.assign(n,i||{}),this},throwInvalidPublishableKeyError(i){throw new Error(o(n.InvalidPublishableKeyErrorMessage,i))},throwInvalidFrontendApiError(i){throw new Error(o(n.InvalidFrontendApiErrorMessage,i))},throwInvalidProxyUrl(i){throw new Error(o(n.InvalidProxyUrlErrorMessage,i))},throwMissingPublishableKeyError(){throw new Error(o(n.MissingPublishableKeyErrorMessage))}}}var Xr=e=>{if(e.length==0)return"";if(e.length==1)return e[0];let r=e.slice(0,-1).join(", ");return r+=`, or ${e.slice(-1)}`,r};function Ke(){return typeof window<"u"}var zt=["bot","spider","crawl","APIs-Google","AdsBot","Googlebot","mediapartners","Google Favicon","FeedFetcher","Google-Read-Aloud","DuplexWeb-Google","googleweblight","bing","yandex","baidu","duckduck","yahoo","ecosia","ia_archiver","facebook","instagram","pinterest","reddit","slack","twitter","whatsapp","youtube","semrush"],Mt=new RegExp(zt.join("|"),"i");function Dt(e){return e?Mt.test(e):!1}function Pt(){let e=window?.navigator;return!Ke()||!e?!1:!Dt(e?.userAgent)&&!e?.webdriver}function At(){let e=window?.navigator;if(!Ke()||!e)return!1;let r=e?.onLine;return e?.connection?.rtt!==0&&e?.connection?.downlink!==0&&r}function qr(){return At()&&Pt()}var Ut=/^#?([A-F0-9]{6}|[A-F0-9]{3})$/i,_t=/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/i,Ft=/^rgba\((\d+),\s*(\d+),\s*(\d+)(,\s*\d+(\.\d+)?)\)$/i,Wt=/^hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)$/i,Vt=/^hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%(,\s*\d+(\.\d+)?)*\)$/i,oe=e=>!!e.match(Ut),ve=e=>!!(e.match(_t)||e.match(Ft)),he=e=>!!e.match(Wt)||!!e.match(Vt),je=e=>typeof e!="string"&&"r"in e,Xe=e=>typeof e!="string"&&"h"in e,be=e=>e==="transparent",Zr=e=>typeof e!="string"&&e.a!=null&&e.a<1;var $t=/[hsla()]/g,Ht=/[rgba()]/g,tn=e=>e==="transparent"?{h:0,s:0,l:0,a:0}:oe(e)?jt(e):he(e)?Je(e):ve(e)?Ye(e):null,rn=e=>(e=e.trim(),oe(e)?e.startsWith("#")?e:`#${e}`:ve(e)?qe(e):he(e)?Je(e):be(e)?e:""),Nt=e=>typeof e=="string"&&(oe(e)||be(e))?e:je(e)?Gt(e):Xe(e)?Kt(e):"",Bt=e=>{e=e.replace("#","");let r=parseInt(e.substring(0,2),16),t=parseInt(e.substring(2,4),16),n=parseInt(e.substring(4,6),16);return{r,g:t,b:n}},Gt=e=>{let{a:r,b:t,g:n,r:o}=e;return e.a===0?"transparent":e.a!=null?`rgba(${o},${n},${t},${r})`:`rgb(${o},${n},${t})`},Kt=e=>{let{h:r,s:t,l:n,a:o}=e,i=Math.round(t*100),a=Math.round(n*100);return e.a===0?"transparent":e.a!=null?`hsla(${r},${i}%,${a}%,${o})`:`hsl(${r},${i}%,${a}%)`},jt=e=>{let r=Nt(Bt(e));return Ye(r)},Ye=e=>{let r=qe(e),t=r.r/255,n=r.g/255,o=r.b/255,i=Math.max(t,n,o),a=Math.min(t,n,o),s,f,u=(i+a)/2;if(i==a)s=f=0;else{let l=i-a;switch(f=u>=.5?l/(2-(i+a)):l/(i+a),i){case t:s=(n-o)/l*60;break;case n:s=((o-t)/l+2)*60;break;default:s=((t-n)/l+4)*60;break}}let c={h:Math.round(s),s:f,l:u},p=r.a;return p!=null&&(c.a=p),c},qe=e=>{let[r,t,n,o]=e.replace(Ht,"").split(",").map(i=>Number.parseFloat(i));return{r,g:t,b:n,a:o}},Je=e=>{let[r,t,n,o]=e.replace($t,"").split(",").map(i=>Number.parseFloat(i));return{h:r,s:t/100,l:n/100,a:o}};function ae(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)e[n]=t[n]}return e}var Xt={read:function(e){return e[0]==='"'&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function ye(e,r){function t(o,i,a){if(!(typeof document>"u")){a=ae({},r,a),typeof a.expires=="number"&&(a.expires=new Date(Date.now()+a.expires*864e5)),a.expires&&(a.expires=a.expires.toUTCString()),o=encodeURIComponent(o).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var s="";for(var f in a)a[f]&&(s+="; "+f,a[f]!==!0&&(s+="="+a[f].split(";")[0]));return document.cookie=o+"="+e.write(i,o)+s}}function n(o){if(!(typeof document>"u"||arguments.length&&!o)){for(var i=document.cookie?document.cookie.split("; "):[],a={},s=0;s<i.length;s++){var f=i[s].split("="),u=f.slice(1).join("=");try{var c=decodeURIComponent(f[0]);if(a[c]=e.read(u,c),o===c)break}catch{}}return o?a[o]:a}}return Object.create({set:t,get:n,remove:function(o,i){t(o,"",ae({},i,{expires:-1}))},withAttributes:function(o){return ye(this.converter,ae({},this.attributes,o))},withConverter:function(o){return ye(ae({},this.converter,o),this.attributes)}},{attributes:{value:Object.freeze(r)},converter:{value:Object.freeze(e)}})}var Yt=ye(Xt,{path:"/"}),se=Yt;function sn(e){return{get(){return se.get(e)},set(r,t={}){return se.set(e,r,t)},remove(r){se.remove(e,r)}}}var cn=()=>{let e=Z,r=Z;return{promise:new Promise((n,o)=>{e=n,r=o}),resolve:e,reject:r}};function fn(e){return e?e.toLocaleString("en-US",{hour:"2-digit",minute:"numeric",hour12:!0}):""}function qt(e,r,{absolute:t=!0}={}){if(!e||!r)return 0;let n=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()),o=Date.UTC(r.getFullYear(),r.getMonth(),r.getDate()),i=Math.floor((o-n)/864e5);return t?Math.abs(i):i}function Ce(e){try{return new Date(e||new Date)}catch{return new Date}}function pn(e){let{date:r,relativeTo:t}=e;if(!r||!t)return null;let n=Ce(r),o=Ce(t),i=qt(o,n,{absolute:!1});return i<-6?{relativeDateCase:"other",date:n}:i<-1?{relativeDateCase:"previous6Days",date:n}:i===-1?{relativeDateCase:"lastDay",date:n}:i===0?{relativeDateCase:"sameDay",date:n}:i===1?{relativeDateCase:"nextDay",date:n}:i<7?{relativeDateCase:"next6Days",date:n}:{relativeDateCase:"other",date:n}}function gn(e,r){let t=Ce(e);return t.setFullYear(t.getFullYear()+r),t}function vn(e){let r=e?.status;return e?.errors?.[0]?.code==="authentication_invalid"&&r===401}function hn(e){return(`${e.message}${e.name}`||"").toLowerCase().replace(/\s+/g,"").includes("networkerror")}function yn(e){return new Promise((r,t)=>{let n=new FileReader;n.addEventListener("load",function(){let o=JSON.parse(n.result);r(o)}),n.addEventListener("error",t),n.readAsText(e)})}var xe=e=>typeof atob<"u"&&typeof atob=="function"?atob(e):typeof global<"u"&&global.Buffer?new global.Buffer(e,"base64").toString():e;var Te="pk_live_",Ze="pk_test_",Jt=/^(([a-z]+)-){2}([0-9]{1,2})\.clerk\.accounts([a-z.]*)(dev|com)$/i;function wn(e){return`${Jt.test(e)?Ze:Te}${btoa(`${e}$`)}`}function Rn(e){if(e=e||"",!Zt(e))return null;let r=e.startsWith(Te)?"production":"development",t=xe(e.split("_")[2]);return t.endsWith("$")?(t=t.slice(0,-1),{instanceType:r,frontendApi:t}):null}function Zt(e){e=e||"";let r=e.startsWith(Te)||e.startsWith(Ze),t=xe(e.split("_")[2]||"").endsWith("$");return r&&t}function On(e){return e=e||"",e.startsWith("clerk.")}function En(){let e=[".lcl.dev",".stg.dev",".lclstage.dev",".stgstage.dev",".dev.lclclerk.com",".stg.lclclerk.com",".accounts.lclclerk.com","accountsstage.dev","accounts.dev"],r=new Map;return{isDevOrStagingUrl:t=>{if(!t)return!1;let n=typeof t=="string"?t:t.hostname,o=r.get(n);return o===void 0&&(o=e.some(i=>n.endsWith(i)),r.set(n,o)),o}}}function Sn(){if(!window.matchMedia)return!1;let e=window.matchMedia("only screen and (min--moz-device-pixel-ratio: 1.3), only screen and (-o-min-device-pixel-ratio: 2.6/2), only screen and (-webkit-min-device-pixel-ratio: 1.3), only screen and (min-device-pixel-ratio: 1.3), only screen and (min-resolution: 1.3dppx)");return e&&e.matches||window.devicePixelRatio>1}var Qt="__lsbc__",Qe=class{constructor(r){this.eventTarget=window;this.postMessage=r=>{try{localStorage.setItem(this.channelKey,JSON.stringify(r)),localStorage.removeItem(this.channelKey)}catch{}};this.addEventListener=(r,t)=>{this.eventTarget.addEventListener(this.prefixEventName(r),n=>{t(n)})};this.setupLocalStorageListener=()=>{let r=t=>{if(!(t.key!==this.channelKey||!t.newValue))try{let n=JSON.parse(t.newValue||""),o=new MessageEvent(this.prefixEventName("message"),{data:n});this.eventTarget.dispatchEvent(o)}catch{}};window.addEventListener("storage",r)};this.channelKey=Qt+r,this.setupLocalStorageListener()}prefixEventName(r){return this.channelKey+r}};var er=Object.freeze({"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/x-icon":"ico","image/vnd.microsoft.icon":"ico"}),zn=e=>er[e];function Dn(e,r,t){if(typeof e=="function")return e(r);if(typeof e<"u")return e;if(typeof t<"u")return t}var tr=/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;function An(e){return tr.test(e||"")}function Un(e){let r=e||"";return r.charAt(0).toUpperCase()+r.slice(1)}function et(e){return e?e.replace(/([-_][a-z])/g,r=>r.toUpperCase().replace(/-|_/,"")):""}function tt(e){return e?e.replace(/[A-Z]/g,r=>`_${r.toLowerCase()}`):""}var rt=e=>{let r=t=>{if(!t)return t;if(Array.isArray(t))return t.map(i=>typeof i=="object"||Array.isArray(i)?r(i):i);let n={...t},o=Object.keys(n);for(let i of o){let a=e(i.toString());a!==i&&(n[a]=n[i],delete n[i]),typeof n[a]=="object"&&(n[a]=r(n[a]))}return n};return r},Wn=rt(tt),Vn=rt(et);var we=`const respond=r=>{self.postMessage(r)},workerToTabIds={};self.addEventListener("message",r=>{const e=r.data;switch(e.type){case"setTimeout":workerToTabIds[e.id]=setTimeout(()=>{respond({id:e.id})},e.ms);break;case"clearTimeout":workerToTabIds[e.id]&&(clearTimeout(workerToTabIds[e.id]),delete workerToTabIds[e.id]);break;case"setInterval":workerToTabIds[e.id]=setInterval(()=>{respond({id:e.id})},e.ms);break;case"clearInterval":workerToTabIds[e.id]&&(clearInterval(workerToTabIds[e.id]),delete workerToTabIds[e.id]);break}});
`;var nt=(e,r={})=>{if(typeof Worker>"u")return null;try{let t=new Blob([e],{type:"application/javascript; charset=utf-8"}),n=globalThis.URL.createObjectURL(t);return new Worker(n,r)}catch{return console.warn("Clerk: Cannot create worker from blob. Consider adding worker-src blob:; to your CSP"),null}},nr=()=>{let e=globalThis.setTimeout.bind(globalThis),r=globalThis.setInterval.bind(globalThis),t=globalThis.clearTimeout.bind(globalThis),n=globalThis.clearInterval.bind(globalThis);return{setTimeout:e,setInterval:r,clearTimeout:t,clearInterval:n,cleanup:Z}},Re=()=>{let e=0,r=()=>e++,t=new Map,n=(l,m)=>l?.postMessage(m),o=l=>{t.get(l.data.id)?.()},i=nt(we,{name:"clerk-timers"});if(i?.addEventListener("message",o),!i)return nr();let a=()=>{i||(i=nt(we,{name:"clerk-timers"}),i?.addEventListener("message",o))};return{setTimeout:(l,m)=>{a();let C=r();return t.set(C,l),n(i,{type:"setTimeout",id:C,ms:m}),C},setInterval:(l,m)=>{a();let C=r();return t.set(C,l),n(i,{type:"setInterval",id:C,ms:m}),C},clearTimeout:l=>{a(),t.delete(l),n(i,{type:"clearTimeout",id:l})},clearInterval:l=>{a(),t.delete(l),n(i,{type:"clearInterval",id:l})},cleanup:()=>{i&&(i.terminate(),i=null,t.clear())}}};function Yn({delayInMs:e}={delayInMs:1e3}){let r=Re(),t,n=!1,o=()=>{t&&(r.clearTimeout(t),r.cleanup()),n=!0},i=async a=>{n=!1,await a(o),!n&&(t=r.setTimeout(()=>{i(a)},e))};return{run:i,stop:o}}function Jn(e){return e?ir(e)||it(e):!0}function ir(e){return/^http(s)?:\/\//.test(e||"")}function it(e){return e.startsWith("/")}function Zn(e){return e?it(e)?new URL(e,window.location.origin).toString():e:""}function Qn({request:e,relativePath:r}){let{headers:t,url:n}=e,o=new URL(n),i=t.get("X-Forwarded-Host")??t.get("host")??t.host??o.host,a=(t.get("X-Forwarded-Proto")??t["X-Forwarded-Proto"])?.split(",")[0]??o.protocol;return a=a.replace(/[:/]/,""),new URL(r||o.pathname,`${a}://${i}`)}var ti=()=>typeof window<"u";function ni(e=""){return e.startsWith("?")&&(e=e.slice(1)),new URLSearchParams(e)}function ii(e=""){return(e||"").replace(/^.+:\/\//,"")}function oi(e){if(!e)return"";let r;if(e.match(/^(clerk\.)+\w*$/))r=/(clerk\.)*(?=clerk\.)/;else{if(e.match(/\.clerk.accounts/))return e;r=/^(clerk\.)*/gi}return`clerk.${e.replace(r,"")}`}var or={firstDelay:125,maxDelay:0,timeMultiple:2,shouldRetry:()=>!0},ar=async e=>new Promise(r=>setTimeout(r,e)),sr=e=>{let r=0,t=()=>{let n=e.firstDelay,o=e.timeMultiple,i=n*Math.pow(o,r);return Math.min(e.maxDelay||i,i)};return async()=>{await ar(t()),r++}},si=async(e,r={})=>{let t=0,{shouldRetry:n,firstDelay:o,maxDelay:i,timeMultiple:a}={...or,...r},s=sr({firstDelay:o,maxDelay:i,timeMultiple:a});for(;;)try{return await e()}catch(f){if(t++,!n(f,t))throw f;await s()}};import ur from"glob-to-regexp";var ci={toRegexp:e=>{try{return ur(e)}catch(r){throw new Error(`Invalid pattern: ${e}.
Consult the documentation of glob-to-regexp here: https://www.npmjs.com/package/glob-to-regexp.
${r.message}`)}}};import Oe from"react";function ot(e,r){if(!e)throw typeof r=="string"?new Error(r):new Error(`${r.displayName} not found`)}var V=(e,r)=>{let{assertCtxFn:t=ot}=r||{},n=Oe.createContext(void 0);return n.displayName=e,[n,()=>{let a=Oe.useContext(n);return t(a,`${e} not found`),a.value},()=>{let a=Oe.useContext(n);return a?a.value:{}}]};import{useEffect as lr,useLayoutEffect as cr,createContext as dr,useContext as lt,useState as ct,createElement as fr,useRef as $,useCallback as Se,useDebugValue as pr}from"react";function dt(e,r,t,n){function o(i){return i instanceof t?i:new t(function(a){a(i)})}return new(t||(t=Promise))(function(i,a){function s(c){try{u(n.next(c))}catch(p){a(p)}}function f(c){try{u(n.throw(c))}catch(p){a(p)}}function u(c){c.done?i(c.value):o(c.value).then(s,f)}u((n=n.apply(e,r||[])).next())})}function ft(e,r){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,o,i,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(u){return function(c){return f([u,c])}}function f(u){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,o&&(i=u[0]&2?o.return:u[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,u[1])).done)return i;switch(o=0,i&&(u=[u[0]&2,i.value]),u[0]){case 0:case 1:i=u;break;case 4:return t.label++,{value:u[1],done:!1};case 5:t.label++,o=u[1],u=[0];continue;case 7:u=t.ops.pop(),t.trys.pop();continue;default:if(i=t.trys,!(i=i.length>0&&i[i.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){t.label=u[1];break}if(u[0]===6&&t.label<i[1]){t.label=i[1],i=u;break}if(i&&t.label<i[2]){t.label=i[2],t.ops.push(u);break}i[2]&&t.ops.pop(),t.trys.pop();continue}u=r.call(e,t)}catch(c){u=[6,c],o=0}finally{n=i=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}var I=function(){},h=I(),Q=Object,y=function(e){return e===h},A=function(e){return typeof e=="function"},M=function(e,r){return Q.assign({},e,r)},Pe="undefined",Ae=function(){return typeof window!=Pe},gr=function(){return typeof document!=Pe},mr=function(){return Ae()&&typeof window.requestAnimationFrame!=Pe},ue=new WeakMap,vr=0,re=function(e){var r=typeof e,t=e&&e.constructor,n=t==Date,o,i;if(Q(e)===e&&!n&&t!=RegExp){if(o=ue.get(e),o)return o;if(o=++vr+"~",ue.set(e,o),t==Array){for(o="@",i=0;i<e.length;i++)o+=re(e[i])+",";ue.set(e,o)}if(t==Q){o="#";for(var a=Q.keys(e).sort();!y(i=a.pop());)y(e[i])||(o+=i+":"+re(e[i])+",");ue.set(e,o)}}else o=n?e.toJSON():r=="symbol"?e.toString():r=="string"?JSON.stringify(e):""+e;return o},Ie=!0,hr=function(){return Ie},pt=Ae(),Ue=gr(),Le=pt&&window.addEventListener?window.addEventListener.bind(window):I,br=Ue?document.addEventListener.bind(document):I,ze=pt&&window.removeEventListener?window.removeEventListener.bind(window):I,yr=Ue?document.removeEventListener.bind(document):I,Cr=function(){var e=Ue&&document.visibilityState;return y(e)||e!=="hidden"},xr=function(e){return br("visibilitychange",e),Le("focus",e),function(){yr("visibilitychange",e),ze("focus",e)}},Tr=function(e){var r=function(){Ie=!0,e()},t=function(){Ie=!1};return Le("online",r),Le("offline",t),function(){ze("online",r),ze("offline",t)}},wr={isOnline:hr,isVisible:Cr},Rr={initFocus:xr,initReconnect:Tr},le=!Ae()||"Deno"in window,Or=function(e){return mr()?window.requestAnimationFrame(e):setTimeout(e,1)},ee=le?lr:cr,Ee=typeof navigator<"u"&&navigator.connection,at=!le&&Ee&&(["slow-2g","2g"].includes(Ee.effectiveType)||Ee.saveData),gt=function(e){if(A(e))try{e=e()}catch{e=""}var r=[].concat(e);e=typeof e=="string"?e:(Array.isArray(e)?e.length:e)?re(e):"";var t=e?"$swr$"+e:"";return[e,r,t]},H=new WeakMap,mt=0,vt=1,ht=2,te=function(e,r,t,n,o,i,a){a===void 0&&(a=!0);var s=H.get(e),f=s[0],u=s[1],c=s[3],p=f[r],l=u[r];if(a&&l)for(var m=0;m<l.length;++m)l[m](t,n,o);return i&&(delete c[r],p&&p[0])?p[0](ht).then(function(){return e.get(r)}):e.get(r)},Er=0,Me=function(){return++Er},bt=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return dt(void 0,void 0,void 0,function(){var t,n,o,i,a,s,f,u,c,p,l,m,C,x,g,d,K,U,L,E,_;return ft(this,function(D){switch(D.label){case 0:if(t=e[0],n=e[1],o=e[2],i=e[3],a=typeof i=="boolean"?{revalidate:i}:i||{},s=y(a.populateCache)?!0:a.populateCache,f=a.revalidate!==!1,u=a.rollbackOnError!==!1,c=a.optimisticData,p=gt(n),l=p[0],m=p[2],!l)return[2];if(C=H.get(t),x=C[2],e.length<3)return[2,te(t,l,t.get(l),h,h,f,!0)];if(g=o,K=Me(),x[l]=[K,0],U=!y(c),L=t.get(l),U&&(E=A(c)?c(L):c,t.set(l,E),te(t,l,E)),A(g))try{g=g(t.get(l))}catch(F){d=F}return g&&A(g.then)?[4,g.catch(function(F){d=F})]:[3,2];case 1:if(g=D.sent(),K!==x[l][0]){if(d)throw d;return[2,g]}else d&&U&&u&&(s=!0,g=L,t.set(l,L));D.label=2;case 2:return s&&(d||(A(s)&&(g=s(g,L)),t.set(l,g)),t.set(m,M(t.get(m),{error:d}))),x[l][1]=Me(),[4,te(t,l,g,d,h,f,!!s)];case 3:if(_=D.sent(),d)throw d;return[2,s?_:g]}})})},st=function(e,r){for(var t in e)e[t][0]&&e[t][0](r)},yt=function(e,r){if(!H.has(e)){var t=M(Rr,r),n={},o=bt.bind(h,e),i=I;if(H.set(e,[n,{},{},{},o]),!le){var a=t.initFocus(setTimeout.bind(h,st.bind(h,n,mt))),s=t.initReconnect(setTimeout.bind(h,st.bind(h,n,vt)));i=function(){a&&a(),s&&s(),H.delete(e)}}return[e,o,i]}return[e,H.get(e)[4]]},kr=function(e,r,t,n,o){var i=t.errorRetryCount,a=o.retryCount,s=~~((Math.random()+.5)*(1<<(a<8?a:8)))*t.errorRetryInterval;!y(i)&&a>i||setTimeout(n,s,o)},Ct=yt(new Map),xt=Ct[0],Sr=Ct[1],Tt=M({onLoadingSlow:I,onSuccess:I,onError:I,onErrorRetry:kr,onDiscarded:I,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:at?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:at?5e3:3e3,compare:function(e,r){return re(e)==re(r)},isPaused:function(){return!1},cache:xt,mutate:Sr,fallback:{}},wr),wt=function(e,r){var t=M(e,r);if(r){var n=e.use,o=e.fallback,i=r.use,a=r.fallback;n&&i&&(t.use=n.concat(i)),o&&a&&(t.fallback=M(o,a))}return t},De=dr({}),Ir=function(e){var r=e.value,t=wt(lt(De),r),n=r&&r.provider,o=ct(function(){return n?yt(n(t.cache||xt),r):h})[0];return o&&(t.cache=o[0],t.mutate=o[1]),ee(function(){return o?o[2]:h},[]),fr(De.Provider,M(e,{value:t}))},Lr=function(e,r){var t=ct({})[1],n=$(e),o=$({data:!1,error:!1,isValidating:!1}),i=Se(function(a){var s=!1,f=n.current;for(var u in a){var c=u;f[c]!==a[c]&&(f[c]=a[c],o.current[c]&&(s=!0))}s&&!r.current&&t({})},[]);return ee(function(){n.current=e}),[n,o.current,i]},zr=function(e){return A(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(e[1]===null?e[2]:e[1])||{}]},Mr=function(){return M(Tt,lt(De))},Dr=function(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var o=Mr(),i=zr(t),a=i[0],s=i[1],f=i[2],u=wt(o,f),c=e,p=u.use;if(p)for(var l=p.length;l-- >0;)c=p[l](c);return c(a,s||u.fetcher,u)}},ut=function(e,r,t){var n=r[e]||(r[e]=[]);return n.push(t),function(){var o=n.indexOf(t);o>=0&&(n[o]=n[n.length-1],n.pop())}},ke={dedupe:!0},Pr=function(e,r,t){var n=t.cache,o=t.compare,i=t.fallbackData,a=t.suspense,s=t.revalidateOnMount,f=t.refreshInterval,u=t.refreshWhenHidden,c=t.refreshWhenOffline,p=H.get(n),l=p[0],m=p[1],C=p[2],x=p[3],g=gt(e),d=g[0],K=g[1],U=g[2],L=$(!1),E=$(!1),_=$(d),D=$(r),F=$(t),v=function(){return F.current},ce=function(){return v().isVisible()&&v().isOnline()},ne=function(R){return n.set(U,M(n.get(U),R))},$e=n.get(d),Et=y(i)?t.fallback[d]:i,z=y($e)?Et:$e,He=n.get(U)||{},j=He.error,Ne=!L.current,Be=function(){return Ne&&!y(s)?s:v().isPaused()?!1:a?y(z)?!1:t.revalidateIfStale:y(z)||t.revalidateIfStale},kt=function(){return!d||!r?!1:He.isValidating?!0:Ne&&Be()},de=kt(),fe=Lr({data:z,error:j,isValidating:de},E),B=fe[0],pe=fe[1],ie=fe[2],W=Se(function(R){return dt(void 0,void 0,void 0,function(){var T,w,O,X,Y,k,b,P,S,ge,q,G,me;return ft(this,function(J){switch(J.label){case 0:if(T=D.current,!d||!T||E.current||v().isPaused())return[2,!1];X=!0,Y=R||{},k=!x[d]||!Y.dedupe,b=function(){return!E.current&&d===_.current&&L.current},P=function(){var Ge=x[d];Ge&&Ge[1]===O&&delete x[d]},S={isValidating:!1},ge=function(){ne({isValidating:!1}),b()&&ie(S)},ne({isValidating:!0}),ie({isValidating:!0}),J.label=1;case 1:return J.trys.push([1,3,,4]),k&&(te(n,d,B.current.data,B.current.error,!0),t.loadingTimeout&&!n.get(d)&&setTimeout(function(){X&&b()&&v().onLoadingSlow(d,t)},t.loadingTimeout),x[d]=[T.apply(void 0,K),Me()]),me=x[d],w=me[0],O=me[1],[4,w];case 2:return w=J.sent(),k&&setTimeout(P,t.dedupingInterval),!x[d]||x[d][1]!==O?(k&&b()&&v().onDiscarded(d),[2,!1]):(ne({error:h}),S.error=h,q=C[d],!y(q)&&(O<=q[0]||O<=q[1]||q[1]===0)?(ge(),k&&b()&&v().onDiscarded(d),[2,!1]):(o(B.current.data,w)?S.data=B.current.data:S.data=w,o(n.get(d),w)||n.set(d,w),k&&b()&&v().onSuccess(w,d,t),[3,4]));case 3:return G=J.sent(),P(),v().isPaused()||(ne({error:G}),S.error=G,k&&b()&&(v().onError(G,d,t),(typeof t.shouldRetryOnError=="boolean"&&t.shouldRetryOnError||A(t.shouldRetryOnError)&&t.shouldRetryOnError(G))&&ce()&&v().onErrorRetry(G,d,t,W,{retryCount:(Y.retryCount||0)+1,dedupe:!0}))),[3,4];case 4:return X=!1,ge(),b()&&k&&te(n,d,S.data,S.error,!1),[2,!0]}})})},[d]),St=Se(bt.bind(h,n,function(){return _.current}),[]);if(ee(function(){D.current=r,F.current=t}),ee(function(){if(d){var R=d!==_.current,T=W.bind(h,ke),w=function(b,P,S){ie(M({error:P,isValidating:S},o(B.current.data,b)?h:{data:b}))},O=0,X=function(b){if(b==mt){var P=Date.now();v().revalidateOnFocus&&P>O&&ce()&&(O=P+v().focusThrottleInterval,T())}else if(b==vt)v().revalidateOnReconnect&&ce()&&T();else if(b==ht)return W()},Y=ut(d,m,w),k=ut(d,l,X);return E.current=!1,_.current=d,L.current=!0,R&&ie({data:z,error:j,isValidating:de}),Be()&&(y(z)||le?T():Or(T)),function(){E.current=!0,Y(),k()}}},[d,W]),ee(function(){var R;function T(){var O=A(f)?f(z):f;O&&R!==-1&&(R=setTimeout(w,O))}function w(){!B.current.error&&(u||v().isVisible())&&(c||v().isOnline())?W(ke).then(T):T()}return T(),function(){R&&(clearTimeout(R),R=-1)}},[f,u,c,W]),pr(z),a&&y(z)&&d)throw D.current=r,F.current=t,E.current=!1,y(j)?W(ke):j;return{mutate:St,get data(){return pe.data=!0,z},get error(){return pe.error=!0,j},get isValidating(){return pe.isValidating=!0,de}}},mi=Q.defineProperty(Ir,"default",{value:Tt});var _e=Dr(Pr);var[Ar,N]=V("ClerkInstanceContext"),[Ur,Fe]=V("UserContext"),[_r,Fr]=V("ClientContext"),[Wr,We]=V("SessionContext"),[Vr,Ve]=V("OrganizationContext");var $r=e=>{let{invitationList:r,membershipList:t}=e||{},{organization:n,lastOrganizationMember:o,lastOrganizationInvitation:i}=Ve(),a=We(),s=N(),f=s.loaded&&a&&n,u=s.loaded?()=>s.organization?.getPendingInvitations(r):()=>[],c=s.loaded?()=>s.organization?.getMemberships(t):()=>[],{data:p,isValidating:l,mutate:m}=_e(f&&r?Rt("invites",n,i,r):null,u),{data:C,isValidating:x,mutate:g}=_e(f&&t?Rt("memberships",n,o,t):null,c);return n===void 0?{isLoaded:!1,organization:void 0,invitationList:void 0,membershipList:void 0,membership:void 0}:n===null?{isLoaded:!0,organization:null,invitationList:null,membershipList:null,membership:null}:!s.loaded&&n?{isLoaded:!0,organization:n,invitationList:void 0,membershipList:void 0,membership:void 0}:{isLoaded:!x&&!l,organization:n,membershipList:C,membership:Hr(a.user.organizationMemberships,n.id),invitationList:p,unstable__mutate:()=>{g(),m()}}};function Hr(e,r){return e.find(t=>t.organization.id===r)}function Rt(e,r,t,n){return[e,r.id,t?.id,t?.updatedAt,n.offset,n.limit].filter(Boolean).join("-")}var Nr=()=>{let e=N(),r=Fe();return!e.loaded||!r?{isLoaded:!1,organizationList:void 0,createOrganization:void 0,setActive:void 0}:{isLoaded:!0,organizationList:Br(r.organizationMemberships),setActive:e.setActive,createOrganization:e.createOrganization}};function Br(e){return e.map(r=>({membership:r,organization:r.organization}))}var Gr=()=>{let e=N();return e.loaded?{isLoaded:!0,createOrganization:e.createOrganization,getOrganizationMemberships:e.getOrganizationMemberships,getOrganization:e.getOrganization}:{isLoaded:!1,createOrganization:void 0,getOrganizationMemberships:void 0,getOrganization:void 0}};import Ot from"react";var Kr=typeof window<"u"?Ot.useLayoutEffect:Ot.useEffect;export{Ar as ClerkInstanceContext,_r as ClientContext,Qe as LocalStorageBroadcastChannel,Vr as OrganizationContext,Yn as Poller,Wr as SessionContext,Ur as UserContext,oi as addClerkPrefix,gn as addYears,ot as assertContextExists,Lt as buildErrorThrower,wn as buildPublishableKey,tt as camelToSnake,Nt as colorToSameTypeString,V as createContextAndHook,sn as createCookieHandler,cn as createDeferredPromise,En as createDevOrStagingUrlCache,Re as createWorkerTimers,fn as dateTo12HourTime,Wn as deepCamelToSnake,Vn as deepSnakeToCamel,qt as differenceInCalendarDays,zn as extension,pn as formatRelative,Qn as getRequestUrl,ci as globs,Dn as handleValueOrFn,Zr as hasAlpha,Bt as hexStringToRgbaColor,Ke as inBrowser,ti as inClientSide,At as isBrowserOnline,Xe as isHSLColor,ir as isHttpOrHttps,An as isIPV4Address,On as isLegacyFrontendApiKey,hn as isNetworkError,it as isProxyUrlRelative,Zt as isPublishableKey,je as isRGBColor,Sn as isRetinaDisplay,be as isTransparent,vn as isUnauthorizedError,Pt as isValidBrowser,qr as isValidBrowserOnline,oe as isValidHexString,he as isValidHslaString,Jn as isValidProxyUrl,ve as isValidRgbaString,xe as isomorphicAtob,Z as noop,Ce as normalizeDate,Rn as parsePublishableKey,ni as parseSearchParams,Zn as proxyUrlToAbsoluteURL,yn as readJSONFile,si as runWithExponentialBackOff,et as snakeToCamel,tn as stringToHslaColor,rn as stringToSameTypeColor,ii as stripScheme,Un as titleize,Xr as toSentence,N as useClerkInstanceContext,Fr as useClientContext,$r as useOrganization,Ve as useOrganizationContext,Nr as useOrganizationList,Gr as useOrganizations,Kr as useSafeLayoutEffect,We as useSessionContext,Fe as useUserContext,Dt as userAgentIsRobot};
/*! Bundled license information:
js-cookie/dist/js.cookie.mjs:
(*! js-cookie v3.0.1 | MIT *)
swr/dist/index.mjs:
(*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** *)
*/
import { buildErrorThrower } from "./errors/thrower";
export * from "./utils";
import { assertContextExists, createContextAndHook } from "./hooks/createContextAndHook";
import { useOrganization } from "./hooks/useOrganization";
import { useOrganizationList } from "./hooks/useOrganizationList";
import { useOrganizations } from "./hooks/useOrganizations";
import { useSafeLayoutEffect } from "./hooks/useSafeLayoutEffect";
import {
ClerkInstanceContext,
ClientContext,
OrganizationContext,
SessionContext,
useClerkInstanceContext,
useClientContext,
useOrganizationContext,
UserContext,
useSessionContext,
useUserContext
} from "./hooks/contexts";
export {
ClerkInstanceContext,
ClientContext,
OrganizationContext,
SessionContext,
UserContext,
assertContextExists,
buildErrorThrower,
createContextAndHook,
useClerkInstanceContext,
useClientContext,
useOrganization,
useOrganizationContext,
useOrganizationList,
useOrganizations,
useSafeLayoutEffect,
useSessionContext,
useUserContext
};
//# sourceMappingURL=index.js.map

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

import{a as n,b as e,c as o}from"../chunk-GW3MP3TA.js";var t={};n(t,{noop:()=>o,render:()=>m,userEvent:()=>p});var r={};n(r,{noop:()=>o,render:()=>m,userEvent:()=>p});import"@testing-library/jest-dom/extend-expect";import{render as a}from"@testing-library/react";e(r,R);import*as R from"@testing-library/react";import{default as p}from"@testing-library/user-event";var m=(i,s)=>a(i,s);e(t,r);export{o as noop,m as render,p as userEvent};
export * from "./testUtils";
//# sourceMappingURL=index.js.map

@@ -9,3 +9,2 @@ export * from './array';

export * from './file';
export * from './index';
export * from './keys';

@@ -27,2 +26,3 @@ export * from './isRetinaDisplay';

export * from './globs';
export * from './loadScript';
//# sourceMappingURL=index.d.ts.map
{
"name": "@clerk/shared",
"version": "0.17.2",
"version": "0.18.0-snap.9208293",
"description": "Internal package utils used by the Clerk SDKs",
"types": "./dist/types/index.d.ts",
"main": "./dist/index.js",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",

@@ -13,5 +13,20 @@ "sideEffects": false,

],
"exports": {
".": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js",
"types": "./dist/types/index.d.ts"
},
"./testUtils": {
"import": "./dist/esm/testUtils/index.js",
"require": "./dist/cjs/testUtils/index.js",
"types": "./dist/types/testUtils/index.d.ts"
}
},
"scripts": {
"build": "tsup",
"dev": "tsup --watch",
"build": "tsup --env.NODE_ENV production",
"dev:publish": "npm run dev -- --env.PUBLISH=true",
"build:declarations": "tsc -p tsconfig.json",
"publish:local": "npx yalc push --replace --sig",
"clean": "rimraf ./dist",

@@ -48,4 +63,3 @@ "lint": "eslint .",

"glob-to-regexp": "0.4.1"
},
"gitHead": "329c59fb4906dbd5f5afd4edcd50e4663df4bd54"
}
}
{
"name": "testUtils",
"main": "../dist/testUtils/index.js",
"module": "../dist/testUtils/index.mjs",
"main": "../dist/cjs/testUtils/index.js",
"module": "../dist/esm/testUtils/index.js",
"types": "../dist/types/testUtils/index.d.ts"
}

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