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

@crossid/crossid-spa-js

Package Overview
Dependencies
Maintainers
2
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@crossid/crossid-spa-js - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

12

CHANGELOG.md
# @crossid/crossid-spa-js
## 0.3.0
[All Changes](https://github.com/crossid/crossid-spa-js/compare/v0.2.0...v0.3.0)
### Minor Changes
- export Oauth2Error.
### Major Changes
- app state can be of any type.
## 0.2.0

@@ -4,0 +16,0 @@

4

dist/client.d.ts

@@ -99,3 +99,3 @@ import { CACHE_INMEM, CACHE_LS, CACHE_SS } from './const';

*/
state?: string;
state?: any;
}

@@ -150,3 +150,3 @@ /**

*/
state?: string;
state?: any;
}

@@ -153,0 +153,0 @@ /**

@@ -15,3 +15,3 @@ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).crossid={})}(this,(function(t){"use strict";

PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,n)};function n(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r=function(){return(r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function o(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}function i(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))}function s(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}var a=function(t){function e(n,r){var o=t.call(this,r)||this;return o.error=n,o.error_description=r,Object.setPrototypeOf(o,e.prototype),o}return n(e,t),e.create=function(t){return new e(t.error,t.error_description)},e}(Error);function u(t){var e=t.wellknown_endpoint;return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,fetch(e)];case 1:return 200!==(t=n.sent()).status?[3,3]:[4,t.json()];case 2:return[2,n.sent()];case 3:throw Error("failed to discover data from well known discovery endpoint.")}}))}))}function c(t){var e=t.tokenEndpoint,n=t.timeout,u=o(t,["tokenEndpoint","timeout"]);return i(this,void 0,void 0,(function(){var t,o,c;return s(this,(function(l){switch(l.label){case 0:return t=new FormData,Object.keys(u).forEach((function(e){return t.append(e,u[e])})),[4,(p=e,d={timeout:n,method:"POST",body:t},void 0===d&&(d={}),i(void 0,void 0,void 0,(function(){var t,e,n,o,i;return s(this,(function(s){switch(s.label){case 0:return t=d.timeout,e=void 0===t?5e3:t,n=new AbortController,o=setTimeout((function(){return n.abort()}),e),[4,fetch(p,r(r({},d),{signal:n.signal}))];case 1:return i=s.sent(),clearTimeout(o),[2,i]}}))})))];case 1:return[4,(o=l.sent()).json()];case 2:if(c=l.sent(),200!==o.status)throw a.create(c);return[2,c]}var p,d}))}))}var l="memory",p="local_storage",d="session_storage",h="__",f="|",v="crossid-spa-js|index",_=function(t){return null!==t&&"Object"===(null==t?void 0:t.constructor.name)},y=function(t){return"number"==typeof t},g=function(t){return"string"==typeof t},w=String.fromCharCode(0),m=function(){function t(t,e){void 0===e&&(e={}),this.gopts=e,this.storage=t,e.purgeOnInit&&this.purge(!0)}return t.prototype.set=function(t,e,n){var r=this._key(t),o=this._ttl(null==n?void 0:n.ttl);try{var i=function(t,e){var n;return e&&e>0?((n={})[w]=t,n.ttl=Date.now()+1e3*e,n):t}(e,o);return this.storage.setItem(r,JSON.stringify(i)),!0}catch(t){return!1}},t.prototype.get=function(t,e){var n,r=this._key(t);try{var o=this.storage.getItem(r);if(null===o)return;var i=JSON.parse(o);return _(n=i)&&w in n?function(t,e){return Date.now()-1e3*e>t.ttl}(i,(null==e?void 0:e.ttl)||0)?void this.storage.removeItem(t):i[w]:i}catch(t){return}},t.prototype.remove=function(t){var e=this._key(t);return!!this.storage.getItem(e)&&(this.storage.removeItem(e),!0)},t.prototype.purge=function(t){var e=this;void 0===t&&(t=!1);var n=0;return Object.keys(this.storage).filter((function(t){return t.startsWith(e.gopts.prefix)})).forEach((function(r){var o=e.storage.getItem(r);if(o){var i;try{i=JSON.parse(o)}catch(t){return}(_(i)&&w in i&&Date.now()>i.ttl||t)&&(n++,e.storage.removeItem(r))}})),n},t.prototype._key=function(t){return this.gopts.prefix?""+this.gopts.prefix+t:t},t.prototype._ttl=function(t){return null===t?null:t||this.gopts.ttl||null},t}(),b=function(t){function e(e){var n=t.call(this,sessionStorage,e)||this;if("undefined"==typeof sessionStorage)throw Error("no support for session storage.");return n}return n(e,t),e}(m),k=function(t){function e(e){var n=t.call(this,localStorage,e)||this;if("undefined"==typeof localStorage)throw Error("no support for local storage.");return n}return n(e,t),e}(m),T=function(){function t(){}return t.prototype.getItem=function(t){return t in this?this[t]:null},t.prototype.setItem=function(t,e){void 0===e?this.removeItem(t):this[t]=""+e},t.prototype.removeItem=function(t){this.hasOwnProperty(t)&&delete this[t]},t}(),O=function(t){function e(e){return t.call(this,new T,e)||this}return n(e,t),e}(m),S=function(t){return Array.from(new Set(t))},j=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return S(t.join(" ").trim().split(/\s+/))},x=function(){return t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",e=Math.floor(86*Math.random()+43),Array.from(window.crypto.getRandomValues(new Uint8Array(e))).map((function(e){return t[e%t.length]})).join("");var t,e},E=function(t){return btoa(t)},C=function(t){return atob(t)},I=function(t){var e={"+":"-","/":"_","=":""};return t.replace(/[+/=]/g,(function(t){return e[t]}))},A=function(t){var e={"-":"+",_:"/"};return t.replace(/[-_]/g,(function(t){return e[t]}))},K=function(t){return Object.keys(t).filter((function(e){return void 0!==t[e]&&null!==t[e]})).map((function(e){return encodeURIComponent(e)+"="+encodeURIComponent(t[e])})).join("&")},D=function(t){var e=t.split("."),n=e[0],r=e[1],o=e[2];if(3!==e.length||!n||!r||!o)throw new Error("malformed JWT token.");var i,s=JSON.parse(C(A(r)));if(s.aud)if(g(s.aud))s.aud=[s.aud];else if(i=s.aud,!Array.isArray(i)||!i.every((function(t){return g(t)})))throw new Error("Audience (aud) must be a string or an array of strings");return{header:JSON.parse(C(A(n))),payload:s}},R=function(t){function e(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var o=t.apply(this,n)||this;return o.fields_=e,o}return n(e,t),e.prototype.getMissingFields=function(){return this.fields_},e}(Error),U=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=e.map((function(e){return e(t)})).filter((function(t){return null!==t}));if(r&&r.length)throw new R(r,r.join(","));return null},F=function(t,e){var n=[];return function(r){return e&&e.filter((function(t){return!r.payload[t]})).forEach((function(t){return n.push(t)})),t&&t.filter((function(t){return!r.header[t]})).forEach((function(t){return n.push(t)})),n&&n.length?n.join(",")+" missing":null}},P=function(t){return function(e){return J("Issuer (iss)",t,e.payload.iss)}},z=function(t){return function(e){return J("Issuer (iss) claim",t,e.header.alg)}},L=function(t){return void 0===t&&(t=[]),function(e){return e.payload.aud&&e.payload.aud.length?(n=t,e.payload.aud.every((function(t){return n.includes(t)}))?null:"Audience (aud) claim mismatch: audience ("+e.payload.aud+") must contain only ("+t+")"):"Audience (aud) claim must be a present string";var n}},N=function(t,e){return void 0===t&&(t=!0),void 0===e&&(e=40),function(n){if(!t&&!n.payload.exp)return null;if(!y(n.payload.exp))return"Expiration Time (exp) claim must be a present number";var r=M(n.payload.exp,e);return new Date(Date.now())>r?"Expiration Time (exp) claim expired ("+r+")":null}},q=function(t,e){return void 0===t&&(t=!0),void 0===e&&(e=40),function(n){if(!t&&!n.payload.nbf)return null;if(!y(n.payload.nbf))return"Not Before (nbf) claim must be a present number";var r=M(n.payload.nbf,-1*e),o=new Date(Date.now());return o<r?"Not Before (nbf) claim cannot be used yet, current time ("+o+") is before ("+r+")":null}},J=function(t,e,n){return e!==n?t+' mismatch: expected "'+e+'" but got "'+n+'"':null},M=function(t,e){void 0===e&&(e=0);var n=new Date(0);return n.setUTCSeconds(t+e),n},W=function(){function t(t){this.opts=t,this.loginStateKey="crossid-spa-js|login",this.logoutStateKey="crossid-spa-js|logout",this.scope=t.scope,this.state=this._stateFactory(this.opts.state_type||d),this.cache=this._cacheFactory(this.opts.cache_type||l),this._purgeIndex()}return t.prototype.createRedirectURL=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return[4,this._createAuthorizationData(t)];case 1:return e=n.sent(),[4,this._persistAuthorizationData(e)];case 2:return n.sent(),[2,this._authorizeUrl(e.request)]}}))}))},t.prototype.loginWithRedirect=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return[4,this.createRedirectURL(t)];case 1:return e=n.sent(),window.location.replace(e),[2]}}))}))},t.prototype.handleRedirectCallback=function(t){return void 0===t&&(t=new URL(window.location.href)),i(this,void 0,void 0,(function(){var e,n,r,o,i,a,u;return s(this,(function(s){switch(s.label){case 0:if(e=t.searchParams,n=e.get("code"),r=e.get("error"))throw new Error(r);if(!(null==(o=this.state.get(this.loginStateKey))?void 0:o.code_verifier))throw new Error("invalid state, try sign-in again");return[4,c({tokenEndpoint:this.opts.token_endpoint,client_id:this.opts.client_id,code_verifier:o.code_verifier,grant_type:"authorization_code",redirect_uri:o.redirect_uri,code:n})];case 1:return(i=s.sent()).id_token&&((a=D(i.id_token)).payload.__bearer=i.id_token,this._assertIDToken(a,o.nonce)),u=D(i.access_token),this.state.remove(this.loginStateKey),this._assertAccessToken(u,o.audience),u.payload._raw=i.access_token,this._cacheTokens(a,u,i.refresh_token),[2,{state:o.state}]}}))}))},t.prototype.getUser=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var e,n,r,o;return s(this,(function(i){return e=t.audience||this.opts.audience,n=j(this.scope,t.scope),r=this._getTokensKeysFromCache("id_token",e,n),[2,null==(o=this._getNarrowedKey(r))?void 0:o.payload]}))}))},t.prototype.getAccessToken=function(t){var e;return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var n,r,o,i;return s(this,(function(s){return n=t.audience||this.opts.audience,r=j(this.scope,t.scope),o=this._getTokensKeysFromCache("access_token",n,r),i=this._getNarrowedKey(o),[2,null===(e=null==i?void 0:i.payload)||void 0===e?void 0:e._raw]}))}))},t.prototype.introspectAccessToken=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var e,n,o,i;return s(this,(function(s){return e=t.audience||this.opts.audience,n=j(this.scope,t.scope),o=this._getTokensKeysFromCache("access_token",e,n),(i=this._getNarrowedKey(o))?[2,r(r({active:!0},i.payload),{_raw:void 0})]:[2,void 0]}))}))},t.prototype.createLogoutRedirectURL=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return[4,this._createLogoutData(t)];case 1:return e=n.sent(),e.request.id_token_hint&&t.post_logout_redirect_uri?[4,this._persistLogoutData(e)]:(this._removeTokens(e.audience,e.scopes),[2,this._logoutUrl()]);case 2:return n.sent(),[2,this._logoutUrl(e.request)]}}))}))},t.prototype.logoutWithRedirect=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return[4,this.createLogoutRedirectURL(t)];case 1:return e=n.sent(),window.location.assign(e),[2]}}))}))},t.prototype.handleLogoutRedirectCallback=function(t){return void 0===t&&(t=new URL(window.location.href)),i(this,void 0,void 0,(function(){var e,n,r,o;return s(this,(function(i){if(e=t.searchParams,n=e.get("state"),r=e.get("error"))throw new Error(r);if(!(null==(o=this.state.get(this.logoutStateKey))?void 0:o.state)||o.state!==n)throw new Error("invalid state, try sign-in again");return this._removeTokens(o.audience,o.scopes),this.state.remove(this.logoutStateKey),[2,{state:o.appState}]}))}))},t.prototype._createAuthorizationData=function(t){return i(this,void 0,void 0,(function(){var e,n,r,o,a,u;return s(this,(function(c){switch(c.label){case 0:return e=I(E(x())),n=I(E(x())),r=x(),[4,(p=r,i(void 0,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,window.crypto.subtle.digest({name:"SHA-256"},(new TextEncoder).encode(p))];case 1:return[2,t.sent()]}}))})))];case 1:return o=c.sent(),l=new Uint8Array(o),a=I(E(String.fromCharCode.apply(String,Array.from(l)))),u={audience:t.audience,redirect_uri:t.redirect_uri,response_type:t.response_type,scope:t.scope,state:e,nonce:n,code_challenge:a},[2,{request:this._mergeAuthorizationCodeParams(u),code_verifier:r,appState:t.state}]}var l,p}))}))},t.prototype._persistAuthorizationData=function(t){return i(this,void 0,void 0,(function(){var e,n;return s(this,(function(r){return e=t.request,n={audience:e.audience,redirect_uri:e.redirect_uri,scope:e.scope,nonce:e.nonce,state:t.appState,code_verifier:t.code_verifier},this.state.set(this.loginStateKey,n),[2]}))}))},t.prototype._mergeAuthorizationCodeParams=function(t){return{client_id:this.opts.client_id,audience:t.audience||this.opts.audience,response_type:t.response_type||this.opts.response_type||"code",redirect_uri:t.redirect_uri||this.opts.redirect_uri,nonce:t.nonce,state:t.state,scope:t.scope||this.opts.scope,code_challenge:t.code_challenge,code_challenge_method:"S256"}},t.prototype._createLogoutData=function(t){return i(this,void 0,void 0,(function(){var e,n;return s(this,(function(r){switch(r.label){case 0:return(e={id_token_hint:t.id_token_hint,post_logout_redirect_uri:t.post_logout_redirect_uri}).id_token_hint||null===e.id_token_hint?[3,2]:[4,this.getUser()];case 1:(n=r.sent())&&n.__bearer&&(e.id_token_hint=n.__bearer),r.label=2;case 2:return e.id_token_hint&&(e.state=I(E(x()))),[2,{request:e,audience:t.audience||this.opts.audience,scopes:(t.scope||this.scope).split(" "),appState:t.state}]}}))}))},t.prototype._persistLogoutData=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){return e={client_id:this.opts.client_id,audience:t.audience,scopes:t.scopes,post_logout_redirect_uri:t.request.post_logout_redirect_uri,state:t.request.state,appState:t.appState},this.state.set(this.logoutStateKey,e),[2]}))}))},t.prototype._assertAccessToken=function(t,e){U(t,F(["alg"],["iss","sub","aud","exp","iat"]),P(this.opts.issuer),z("RS256"),L(e),N(!0),q(!0))},t.prototype._assertIDToken=function(t,e){var n;return U(t,F(["alg"],["iss","sub","aud","nonce","exp","iat"]),P(this.opts.issuer),(n=e,function(t){return J("Nonce (nonce)",n,t.payload.nonce)}),z("RS256"),L([this.opts.client_id]),N(!0),q(!1),(function(t){return y(t.payload.iat)?null:"Issued At (iat) claim must be a present number"})),null},t.prototype._removeTokens=function(t,e){var n=this,r=this._getTokensKeysFromCache("id_token",t,e),o=this._getTokensKeysFromCache("access_token",t,e),i=this._getTokensKeysFromCache("refresh_token",t,e);r.concat(o).concat(i).forEach((function(t){return n.cache.remove(t)})),this._purgeIndex()},t.prototype._authorizeUrl=function(t){return this.opts.authorization_endpoint+"?"+K(t)},t.prototype._logoutUrl=function(t){var e=this.opts.logout_endpoint;return t&&(e=e+"?"+K(t)),e},t.prototype._stateFactory=function(t){var e={ttl:300};switch(t){case p:return new k(e);case d:return new b(e);default:throw new Error('Invalid cache type "'+t+'"')}},t.prototype._cacheFactory=function(t){switch(t){case l:return new O;case p:return new k({purgeOnInit:!0});case d:return new b({purgeOnInit:!0});default:throw new Error('Invalid cache type "'+t+'"')}},t.prototype._cacheTokens=function(t,e,n){var r=this._ttlFromToken(e);this._cacheToken("access_token",e,this.opts.client_id,e.payload.aud,e.payload.scp,r),t&&this._cacheToken("id_token",t,this.opts.client_id,e.payload.aud,e.payload.scp||[],this._ttlFromToken(t)),n&&this._cacheToken("refresh_token",n,this.opts.client_id,e.payload.aud,e.payload.scp,432e3)},t.prototype._cacheToken=function(t,e,n,r,o,i){var s=this._cacheKey({tokType:t,client_id:n,audience:r,scope:o});this.cache.set(s,e,{ttl:i});var a=[r[0]],u=this.cache.get(v);u||(u={}),a.forEach((function(t){u[t]||(u[t]={});var e=u[t];o.forEach((function(t){e[t]||(e[t]=[]),e[t].push(s)}))})),this.cache.set(v,u)},t.prototype._cacheKey=function(t){var e,n=t.tokType,r=t.client_id,o=t.audience,i=t.scope;return i&&i.length&&(i.sort(),e=i.join(h)),["crossid-spa-js",n,r,o.join(h),e].join(f)},t.prototype._decodeKey=function(t){var e=t.split(f),n=e[1],r=e[2],o=e[3];return{tokenType:n,audience:r.split(h),scope:o.split(h)}},t.prototype._getTokensKeysFromCache=function(t,e,n){var r,o=this,i=(this.cache.get(v)||{})[e[0]];if(!i)return[];for(var s=function(e){return i[e]&&i[e].length?r?void(r=r.filter((function(t){return i[e].includes(t)}))):(r=i[e].filter((function(e){return o._decodeKey(e).tokenType===t})),"continue"):{value:[]}},a=0,u=n;a<u.length;a++){var c=s(u[a]);if("object"==typeof c)return c.value}return r},t.prototype._getNarrowedKey=function(t){for(var e in t){var n=this.cache.get(t[e]);if(n)return n}},t.prototype._ttlFromToken=function(t){return(new Date(1e3*t.payload.exp).getTime()-Date.now())/1e3},t.prototype._purgeIndex=function(){var t=this.cache.get(v);if(t){for(var e=0,n=Object.entries(t);e<n.length;e++){for(var r=n[e],o=r[0],i=r[1],s=function(e,n){for(var r=[],i=0;i<n.length;i++)a.cache.get(n[i])||r.push(i);t[o][e]=n.filter((function(t,e){return-1===r.indexOf(e)})),t[o][e].length||delete t[o][e]},a=this,u=0,c=Object.entries(i);u<c.length;u++){var l=c[u];s(l[0],l[1])}Object.keys(t[o]).length||delete t[o]}this.cache.set(v,t)}},t}();t.Client=W,t.newCrossidClient=function(t){return i(this,void 0,void 0,(function(){var e,n,r,i,a,c;return s(this,(function(s){switch(s.label){case 0:return e=t.tenant_id,n=t.auth_server,r=void 0===n?"default":n,i=o(t,["tenant_id","auth_server"]),a=i,[4,u({wellknown_endpoint:"https://"+e+".crossid.io/oauth2/"+r+"/.well-known/openid-configuration"})];case 1:return c=s.sent(),a.authorization_endpoint=c.authorization_endpoint,a.token_endpoint=c.token_endpoint,a.issuer=c.issuer,a.logout_endpoint=a.issuer+"logout",[2,new W(a)]}}))}))},t.newCrossidClientByDiscovery=function(t){return i(this,void 0,void 0,(function(){var e,n,r;return s(this,(function(i){switch(i.label){case 0:return[4,u(t)];case 1:return e=i.sent(),n=o(t,["wellknown_endpoint"]),(r=n).authorization_endpoint=e.authorization_endpoint,r.token_endpoint=e.token_endpoint,r.issuer=e.issuer,[2,new W(r)]}}))}))},t.newCrossidClientCustom=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new W(t)]}))}))},Object.defineProperty(t,"__esModule",{value:!0})}));
***************************************************************************** */var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,n)};function n(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r=function(){return(r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function o(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}function i(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))}function s(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}var a=function(t){function e(n,r){var o=t.call(this,r)||this;return o.error=n,o.error_description=r,Object.setPrototypeOf(o,e.prototype),o}return n(e,t),e.create=function(t){return new e(t.error,t.error_description)},e}(Error);function u(t){var e=t.wellknown_endpoint;return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,fetch(e)];case 1:return 200!==(t=n.sent()).status?[3,3]:[4,t.json()];case 2:return[2,n.sent()];case 3:throw Error("failed to discover data from well known discovery endpoint.")}}))}))}function c(t){var e=t.tokenEndpoint,n=t.timeout,u=o(t,["tokenEndpoint","timeout"]);return i(this,void 0,void 0,(function(){var t,o,c;return s(this,(function(l){switch(l.label){case 0:return t=new FormData,Object.keys(u).forEach((function(e){return t.append(e,u[e])})),[4,(p=e,h={timeout:n,method:"POST",body:t},void 0===h&&(h={}),i(void 0,void 0,void 0,(function(){var t,e,n,o,i;return s(this,(function(s){switch(s.label){case 0:return t=h.timeout,e=void 0===t?5e3:t,n=new AbortController,o=setTimeout((function(){return n.abort()}),e),[4,fetch(p,r(r({},h),{signal:n.signal}))];case 1:return i=s.sent(),clearTimeout(o),[2,i]}}))})))];case 1:return[4,(o=l.sent()).json()];case 2:if(c=l.sent(),200!==o.status)throw a.create(c);return[2,c]}var p,h}))}))}var l="memory",p="local_storage",h="session_storage",d="__",f="|",v="crossid-spa-js|index",_=function(t){return null!==t&&"Object"===(null==t?void 0:t.constructor.name)},y=function(t){return"number"==typeof t},g=function(t){return"string"==typeof t},w=String.fromCharCode(0),m=function(){function t(t,e){void 0===e&&(e={}),this.gopts=e,this.storage=t,e.purgeOnInit&&this.purge(!0)}return t.prototype.set=function(t,e,n){var r=this._key(t),o=this._ttl(null==n?void 0:n.ttl);try{var i=function(t,e){var n;return e&&e>0?((n={})[w]=t,n.ttl=Date.now()+1e3*e,n):t}(e,o);return this.storage.setItem(r,JSON.stringify(i)),!0}catch(t){return!1}},t.prototype.get=function(t,e){var n,r=this._key(t);try{var o=this.storage.getItem(r);if(null===o)return;var i=JSON.parse(o);return _(n=i)&&w in n?function(t,e){return Date.now()-1e3*e>t.ttl}(i,(null==e?void 0:e.ttl)||0)?void this.storage.removeItem(t):i[w]:i}catch(t){return}},t.prototype.remove=function(t){var e=this._key(t);return!!this.storage.getItem(e)&&(this.storage.removeItem(e),!0)},t.prototype.purge=function(t){var e=this;void 0===t&&(t=!1);var n=0;return Object.keys(this.storage).filter((function(t){return t.startsWith(e.gopts.prefix)})).forEach((function(r){var o=e.storage.getItem(r);if(o){var i;try{i=JSON.parse(o)}catch(t){return}(_(i)&&w in i&&Date.now()>i.ttl||t)&&(n++,e.storage.removeItem(r))}})),n},t.prototype._key=function(t){return this.gopts.prefix?""+this.gopts.prefix+t:t},t.prototype._ttl=function(t){return null===t?null:t||this.gopts.ttl||null},t}(),b=function(t){function e(e){var n=t.call(this,sessionStorage,e)||this;if("undefined"==typeof sessionStorage)throw Error("no support for session storage.");return n}return n(e,t),e}(m),k=function(t){function e(e){var n=t.call(this,localStorage,e)||this;if("undefined"==typeof localStorage)throw Error("no support for local storage.");return n}return n(e,t),e}(m),T=function(){function t(){}return t.prototype.getItem=function(t){return t in this?this[t]:null},t.prototype.setItem=function(t,e){void 0===e?this.removeItem(t):this[t]=""+e},t.prototype.removeItem=function(t){this.hasOwnProperty(t)&&delete this[t]},t}(),O=function(t){function e(e){return t.call(this,new T,e)||this}return n(e,t),e}(m),S=function(t){return Array.from(new Set(t))},j=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return S(t.join(" ").trim().split(/\s+/))},x=function(){return t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",e=Math.floor(86*Math.random()+43),Array.from(window.crypto.getRandomValues(new Uint8Array(e))).map((function(e){return t[e%t.length]})).join("");var t,e},E=function(t){return btoa(t)},C=function(t){return atob(t)},I=function(t){var e={"+":"-","/":"_","=":""};return t.replace(/[+/=]/g,(function(t){return e[t]}))},A=function(t){var e={"-":"+",_:"/"};return t.replace(/[-_]/g,(function(t){return e[t]}))},K=function(t){return Object.keys(t).filter((function(e){return void 0!==t[e]&&null!==t[e]})).map((function(e){return encodeURIComponent(e)+"="+encodeURIComponent(t[e])})).join("&")},D=function(t){var e=t.split("."),n=e[0],r=e[1],o=e[2];if(3!==e.length||!n||!r||!o)throw new Error("malformed JWT token.");var i,s=JSON.parse(C(A(r)));if(s.aud)if(g(s.aud))s.aud=[s.aud];else if(i=s.aud,!Array.isArray(i)||!i.every((function(t){return g(t)})))throw new Error("Audience (aud) must be a string or an array of strings");return{header:JSON.parse(C(A(n))),payload:s}},R=function(t){function e(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var o=t.apply(this,n)||this;return o.fields_=e,o}return n(e,t),e.prototype.getMissingFields=function(){return this.fields_},e}(Error),U=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=e.map((function(e){return e(t)})).filter((function(t){return null!==t}));if(r&&r.length)throw new R(r,r.join(","));return null},F=function(t,e){var n=[];return function(r){return e&&e.filter((function(t){return!r.payload[t]})).forEach((function(t){return n.push(t)})),t&&t.filter((function(t){return!r.header[t]})).forEach((function(t){return n.push(t)})),n&&n.length?n.join(",")+" missing":null}},P=function(t){return function(e){return J("Issuer (iss)",t,e.payload.iss)}},z=function(t){return function(e){return J("Issuer (iss) claim",t,e.header.alg)}},L=function(t){return void 0===t&&(t=[]),function(e){return e.payload.aud&&e.payload.aud.length?(n=t,e.payload.aud.every((function(t){return n.includes(t)}))?null:"Audience (aud) claim mismatch: audience ("+e.payload.aud+") must contain only ("+t+")"):"Audience (aud) claim must be a present string";var n}},N=function(t,e){return void 0===t&&(t=!0),void 0===e&&(e=40),function(n){if(!t&&!n.payload.exp)return null;if(!y(n.payload.exp))return"Expiration Time (exp) claim must be a present number";var r=M(n.payload.exp,e);return new Date(Date.now())>r?"Expiration Time (exp) claim expired ("+r+")":null}},q=function(t,e){return void 0===t&&(t=!0),void 0===e&&(e=40),function(n){if(!t&&!n.payload.nbf)return null;if(!y(n.payload.nbf))return"Not Before (nbf) claim must be a present number";var r=M(n.payload.nbf,-1*e),o=new Date(Date.now());return o<r?"Not Before (nbf) claim cannot be used yet, current time ("+o+") is before ("+r+")":null}},J=function(t,e,n){return e!==n?t+' mismatch: expected "'+e+'" but got "'+n+'"':null},M=function(t,e){void 0===e&&(e=0);var n=new Date(0);return n.setUTCSeconds(t+e),n},W=function(){function t(t){this.opts=t,this.loginStateKey="crossid-spa-js|login",this.logoutStateKey="crossid-spa-js|logout",this.scope=t.scope,this.state=this._stateFactory(this.opts.state_type||h),this.cache=this._cacheFactory(this.opts.cache_type||l),this._purgeIndex()}return t.prototype.createRedirectURL=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return[4,this._createAuthorizationData(t)];case 1:return e=n.sent(),[4,this._persistAuthorizationData(e)];case 2:return n.sent(),[2,this._authorizeUrl(e.request)]}}))}))},t.prototype.loginWithRedirect=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return[4,this.createRedirectURL(t)];case 1:return e=n.sent(),window.location.replace(e),[2]}}))}))},t.prototype.handleRedirectCallback=function(t){return void 0===t&&(t=new URL(window.location.href)),i(this,void 0,void 0,(function(){var e,n,r,o,i,a,u;return s(this,(function(s){switch(s.label){case 0:if(e=t.searchParams,n=e.get("code"),r=e.get("error"))throw new Error(r);if(!(null==(o=this.state.get(this.loginStateKey))?void 0:o.code_verifier))throw new Error("invalid state, try sign-in again");return[4,c({tokenEndpoint:this.opts.token_endpoint,client_id:this.opts.client_id,code_verifier:o.code_verifier,grant_type:"authorization_code",redirect_uri:o.redirect_uri,code:n})];case 1:return(i=s.sent()).id_token&&((a=D(i.id_token)).payload.__bearer=i.id_token,this._assertIDToken(a,o.nonce)),u=D(i.access_token),this.state.remove(this.loginStateKey),this._assertAccessToken(u,o.audience),u.payload._raw=i.access_token,this._cacheTokens(a,u,i.refresh_token),[2,{state:o.state}]}}))}))},t.prototype.getUser=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var e,n,r,o;return s(this,(function(i){return e=t.audience||this.opts.audience,n=j(this.scope,t.scope),r=this._getTokensKeysFromCache("id_token",e,n),[2,null==(o=this._getNarrowedKey(r))?void 0:o.payload]}))}))},t.prototype.getAccessToken=function(t){var e;return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var n,r,o,i;return s(this,(function(s){return n=t.audience||this.opts.audience,r=j(this.scope,t.scope),o=this._getTokensKeysFromCache("access_token",n,r),i=this._getNarrowedKey(o),[2,null===(e=null==i?void 0:i.payload)||void 0===e?void 0:e._raw]}))}))},t.prototype.introspectAccessToken=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var e,n,o,i;return s(this,(function(s){return e=t.audience||this.opts.audience,n=j(this.scope,t.scope),o=this._getTokensKeysFromCache("access_token",e,n),(i=this._getNarrowedKey(o))?[2,r(r({active:!0},i.payload),{_raw:void 0})]:[2,void 0]}))}))},t.prototype.createLogoutRedirectURL=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return[4,this._createLogoutData(t)];case 1:return e=n.sent(),e.request.id_token_hint&&t.post_logout_redirect_uri?[4,this._persistLogoutData(e)]:(this._removeTokens(e.audience,e.scopes),[2,this._logoutUrl()]);case 2:return n.sent(),[2,this._logoutUrl(e.request)]}}))}))},t.prototype.logoutWithRedirect=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return[4,this.createLogoutRedirectURL(t)];case 1:return e=n.sent(),window.location.assign(e),[2]}}))}))},t.prototype.handleLogoutRedirectCallback=function(t){return void 0===t&&(t=new URL(window.location.href)),i(this,void 0,void 0,(function(){var e,n,r,o;return s(this,(function(i){if(e=t.searchParams,n=e.get("state"),r=e.get("error"))throw new Error(r);if(!(null==(o=this.state.get(this.logoutStateKey))?void 0:o.state)||o.state!==n)throw new Error("invalid state, try sign-in again");return this._removeTokens(o.audience,o.scopes),this.state.remove(this.logoutStateKey),[2,{state:o.appState}]}))}))},t.prototype._createAuthorizationData=function(t){return i(this,void 0,void 0,(function(){var e,n,r,o,a,u;return s(this,(function(c){switch(c.label){case 0:return e=I(E(x())),n=I(E(x())),r=x(),[4,(p=r,i(void 0,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,window.crypto.subtle.digest({name:"SHA-256"},(new TextEncoder).encode(p))];case 1:return[2,t.sent()]}}))})))];case 1:return o=c.sent(),l=new Uint8Array(o),a=I(E(String.fromCharCode.apply(String,Array.from(l)))),u={audience:t.audience,redirect_uri:t.redirect_uri,response_type:t.response_type,scope:t.scope,state:e,nonce:n,code_challenge:a},[2,{request:this._mergeAuthorizationCodeParams(u),code_verifier:r,appState:t.state}]}var l,p}))}))},t.prototype._persistAuthorizationData=function(t){return i(this,void 0,void 0,(function(){var e,n;return s(this,(function(r){return e=t.request,n={audience:e.audience,redirect_uri:e.redirect_uri,scope:e.scope,nonce:e.nonce,state:t.appState,code_verifier:t.code_verifier},this.state.set(this.loginStateKey,n),[2]}))}))},t.prototype._mergeAuthorizationCodeParams=function(t){return{client_id:this.opts.client_id,audience:t.audience||this.opts.audience,response_type:t.response_type||this.opts.response_type||"code",redirect_uri:t.redirect_uri||this.opts.redirect_uri,nonce:t.nonce,state:t.state,scope:t.scope||this.opts.scope,code_challenge:t.code_challenge,code_challenge_method:"S256"}},t.prototype._createLogoutData=function(t){return i(this,void 0,void 0,(function(){var e,n;return s(this,(function(r){switch(r.label){case 0:return(e={id_token_hint:t.id_token_hint,post_logout_redirect_uri:t.post_logout_redirect_uri}).id_token_hint||null===e.id_token_hint?[3,2]:[4,this.getUser()];case 1:(n=r.sent())&&n.__bearer&&(e.id_token_hint=n.__bearer),r.label=2;case 2:return e.id_token_hint&&(e.state=I(E(x()))),[2,{request:e,audience:t.audience||this.opts.audience,scopes:(t.scope||this.scope).split(" "),appState:t.state}]}}))}))},t.prototype._persistLogoutData=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){return e={client_id:this.opts.client_id,audience:t.audience,scopes:t.scopes,post_logout_redirect_uri:t.request.post_logout_redirect_uri,state:t.request.state,appState:t.appState},this.state.set(this.logoutStateKey,e),[2]}))}))},t.prototype._assertAccessToken=function(t,e){U(t,F(["alg"],["iss","sub","aud","exp","iat"]),P(this.opts.issuer),z("RS256"),L(e),N(!0),q(!0))},t.prototype._assertIDToken=function(t,e){var n;return U(t,F(["alg"],["iss","sub","aud","nonce","exp","iat"]),P(this.opts.issuer),(n=e,function(t){return J("Nonce (nonce)",n,t.payload.nonce)}),z("RS256"),L([this.opts.client_id]),N(!0),q(!1),(function(t){return y(t.payload.iat)?null:"Issued At (iat) claim must be a present number"})),null},t.prototype._removeTokens=function(t,e){var n=this,r=this._getTokensKeysFromCache("id_token",t,e),o=this._getTokensKeysFromCache("access_token",t,e),i=this._getTokensKeysFromCache("refresh_token",t,e);r.concat(o).concat(i).forEach((function(t){return n.cache.remove(t)})),this._purgeIndex()},t.prototype._authorizeUrl=function(t){return this.opts.authorization_endpoint+"?"+K(t)},t.prototype._logoutUrl=function(t){var e=this.opts.logout_endpoint;return t&&(e=e+"?"+K(t)),e},t.prototype._stateFactory=function(t){var e={ttl:300};switch(t){case p:return new k(e);case h:return new b(e);default:throw new Error('Invalid cache type "'+t+'"')}},t.prototype._cacheFactory=function(t){switch(t){case l:return new O;case p:return new k({purgeOnInit:!0});case h:return new b({purgeOnInit:!0});default:throw new Error('Invalid cache type "'+t+'"')}},t.prototype._cacheTokens=function(t,e,n){var r=this._ttlFromToken(e);this._cacheToken("access_token",e,this.opts.client_id,e.payload.aud,e.payload.scp,r),t&&this._cacheToken("id_token",t,this.opts.client_id,e.payload.aud,e.payload.scp||[],this._ttlFromToken(t)),n&&this._cacheToken("refresh_token",n,this.opts.client_id,e.payload.aud,e.payload.scp,432e3)},t.prototype._cacheToken=function(t,e,n,r,o,i){var s=this._cacheKey({tokType:t,client_id:n,audience:r,scope:o});this.cache.set(s,e,{ttl:i});var a=[r[0]],u=this.cache.get(v);u||(u={}),a.forEach((function(t){u[t]||(u[t]={});var e=u[t];o.forEach((function(t){e[t]||(e[t]=[]),e[t].push(s)}))})),this.cache.set(v,u)},t.prototype._cacheKey=function(t){var e,n=t.tokType,r=t.client_id,o=t.audience,i=t.scope;return i&&i.length&&(i.sort(),e=i.join(d)),["crossid-spa-js",n,r,o.join(d),e].join(f)},t.prototype._decodeKey=function(t){var e=t.split(f),n=e[1],r=e[2],o=e[3];return{tokenType:n,audience:r.split(d),scope:o.split(d)}},t.prototype._getTokensKeysFromCache=function(t,e,n){var r,o=this,i=(this.cache.get(v)||{})[e[0]];if(!i)return[];for(var s=function(e){return i[e]&&i[e].length?r?void(r=r.filter((function(t){return i[e].includes(t)}))):(r=i[e].filter((function(e){return o._decodeKey(e).tokenType===t})),"continue"):{value:[]}},a=0,u=n;a<u.length;a++){var c=s(u[a]);if("object"==typeof c)return c.value}return r},t.prototype._getNarrowedKey=function(t){for(var e in t){var n=this.cache.get(t[e]);if(n)return n}},t.prototype._ttlFromToken=function(t){return(new Date(1e3*t.payload.exp).getTime()-Date.now())/1e3},t.prototype._purgeIndex=function(){var t=this.cache.get(v);if(t){for(var e=0,n=Object.entries(t);e<n.length;e++){for(var r=n[e],o=r[0],i=r[1],s=function(e,n){for(var r=[],i=0;i<n.length;i++)a.cache.get(n[i])||r.push(i);t[o][e]=n.filter((function(t,e){return-1===r.indexOf(e)})),t[o][e].length||delete t[o][e]},a=this,u=0,c=Object.entries(i);u<c.length;u++){var l=c[u];s(l[0],l[1])}Object.keys(t[o]).length||delete t[o]}this.cache.set(v,t)}},t}();t.Client=W,t.OAuth2Error=a,t.newCrossidClient=function(t){return i(this,void 0,void 0,(function(){var e,n,r,i,a,c;return s(this,(function(s){switch(s.label){case 0:return e=t.tenant_id,n=t.auth_server,r=void 0===n?"default":n,i=o(t,["tenant_id","auth_server"]),a=i,[4,u({wellknown_endpoint:"https://"+e+".crossid.io/oauth2/"+r+"/.well-known/openid-configuration"})];case 1:return c=s.sent(),a.authorization_endpoint=c.authorization_endpoint,a.token_endpoint=c.token_endpoint,a.issuer=c.issuer,a.logout_endpoint=a.issuer+"logout",[2,new W(a)]}}))}))},t.newCrossidClientByDiscovery=function(t){return i(this,void 0,void 0,(function(){var e,n,r;return s(this,(function(i){switch(i.label){case 0:return[4,u(t)];case 1:return e=i.sent(),n=o(t,["wellknown_endpoint"]),(r=n).authorization_endpoint=e.authorization_endpoint,r.token_endpoint=e.token_endpoint,r.issuer=e.issuer,[2,new W(r)]}}))}))},t.newCrossidClientCustom=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new W(t)]}))}))},Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=crossid-spa-js.js.map
import Client, { ClientCrossidOpts, ClientDiscoveryOpts, ClientOpts, GetUserOpts, GetAccessTokenOpts, AuthorizationOpts, LogoutOpts } from './client';
import { OAuth2Error } from './errors';
import { IDToken } from './types';

@@ -26,2 +27,2 @@ /**

export declare function newCrossidClientCustom(opts: ClientOpts): Promise<Client>;
export { Client, IDToken, ClientOpts, ClientDiscoveryOpts, ClientCrossidOpts, GetUserOpts, GetAccessTokenOpts, AuthorizationOpts, LogoutOpts, };
export { Client, IDToken, ClientOpts, ClientDiscoveryOpts, ClientCrossidOpts, GetUserOpts, GetAccessTokenOpts, AuthorizationOpts, LogoutOpts, OAuth2Error, };

@@ -15,3 +15,3 @@ /*! *****************************************************************************

***************************************************************************** */
var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};function e(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return(n=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function r(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}function o(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))}function i(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}var s=function(t){function n(e,r){var o=t.call(this,r)||this;return o.error=e,o.error_description=r,Object.setPrototypeOf(o,n.prototype),o}return e(n,t),n.create=function(t){return new n(t.error,t.error_description)},n}(Error);function a(t){var e=t.wellknown_endpoint;return o(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return[4,fetch(e)];case 1:return 200!==(t=n.sent()).status?[3,3]:[4,t.json()];case 2:return[2,n.sent()];case 3:throw Error("failed to discover data from well known discovery endpoint.")}}))}))}function u(t){var e=t.tokenEndpoint,a=t.timeout,u=r(t,["tokenEndpoint","timeout"]);return o(this,void 0,void 0,(function(){var t,r,c;return i(this,(function(p){switch(p.label){case 0:return t=new FormData,Object.keys(u).forEach((function(e){return t.append(e,u[e])})),[4,(l=e,h={timeout:a,method:"POST",body:t},void 0===h&&(h={}),o(void 0,void 0,void 0,(function(){var t,e,r,o,s;return i(this,(function(i){switch(i.label){case 0:return t=h.timeout,e=void 0===t?5e3:t,r=new AbortController,o=setTimeout((function(){return r.abort()}),e),[4,fetch(l,n(n({},h),{signal:r.signal}))];case 1:return s=i.sent(),clearTimeout(o),[2,s]}}))})))];case 1:return[4,(r=p.sent()).json()];case 2:if(c=p.sent(),200!==r.status)throw s.create(c);return[2,c]}var l,h}))}))}var c="crossid-spa-js|index",p=function(t){return null!==t&&"Object"===(null==t?void 0:t.constructor.name)},l=function(t){return"number"==typeof t},h=function(t){return"string"==typeof t},d=String.fromCharCode(0),f=function(){function t(t,e){void 0===e&&(e={}),this.gopts=e,this.storage=t,e.purgeOnInit&&this.purge(!0)}return t.prototype.set=function(t,e,n){var r=this._key(t),o=this._ttl(null==n?void 0:n.ttl);try{var i=function(t,e){var n;return e&&e>0?((n={})[d]=t,n.ttl=Date.now()+1e3*e,n):t}(e,o);return this.storage.setItem(r,JSON.stringify(i)),!0}catch(t){return!1}},t.prototype.get=function(t,e){var n,r=this._key(t);try{var o=this.storage.getItem(r);if(null===o)return;var i=JSON.parse(o);return p(n=i)&&d in n?function(t,e){return Date.now()-1e3*e>t.ttl}(i,(null==e?void 0:e.ttl)||0)?void this.storage.removeItem(t):i[d]:i}catch(t){return}},t.prototype.remove=function(t){var e=this._key(t);return!!this.storage.getItem(e)&&(this.storage.removeItem(e),!0)},t.prototype.purge=function(t){var e=this;void 0===t&&(t=!1);var n=0;return Object.keys(this.storage).filter((function(t){return t.startsWith(e.gopts.prefix)})).forEach((function(r){var o=e.storage.getItem(r);if(o){var i;try{i=JSON.parse(o)}catch(t){return}(p(i)&&d in i&&Date.now()>i.ttl||t)&&(n++,e.storage.removeItem(r))}})),n},t.prototype._key=function(t){return this.gopts.prefix?""+this.gopts.prefix+t:t},t.prototype._ttl=function(t){return null===t?null:t||this.gopts.ttl||null},t}(),_=function(t){function n(e){var n=t.call(this,sessionStorage,e)||this;if("undefined"==typeof sessionStorage)throw Error("no support for session storage.");return n}return e(n,t),n}(f),v=function(t){function n(e){var n=t.call(this,localStorage,e)||this;if("undefined"==typeof localStorage)throw Error("no support for local storage.");return n}return e(n,t),n}(f),y=function(){function t(){}return t.prototype.getItem=function(t){return t in this?this[t]:null},t.prototype.setItem=function(t,e){void 0===e?this.removeItem(t):this[t]=""+e},t.prototype.removeItem=function(t){this.hasOwnProperty(t)&&delete this[t]},t}(),g=function(t){function n(e){return t.call(this,new y,e)||this}return e(n,t),n}(f),w=function(t){return Array.from(new Set(t))},m=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return w(t.join(" ").trim().split(/\s+/))},b=function(){return t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",e=Math.floor(86*Math.random()+43),Array.from(window.crypto.getRandomValues(new Uint8Array(e))).map((function(e){return t[e%t.length]})).join("");var t,e},k=function(t){return btoa(t)},T=function(t){return atob(t)},S=function(t){var e={"+":"-","/":"_","=":""};return t.replace(/[+/=]/g,(function(t){return e[t]}))},O=function(t){var e={"-":"+",_:"/"};return t.replace(/[-_]/g,(function(t){return e[t]}))},j=function(t){return Object.keys(t).filter((function(e){return void 0!==t[e]&&null!==t[e]})).map((function(e){return encodeURIComponent(e)+"="+encodeURIComponent(t[e])})).join("&")},x=function(t){var e=t.split("."),n=e[0],r=e[1],o=e[2];if(3!==e.length||!n||!r||!o)throw new Error("malformed JWT token.");var i,s=JSON.parse(T(O(r)));if(s.aud)if(h(s.aud))s.aud=[s.aud];else if(i=s.aud,!Array.isArray(i)||!i.every((function(t){return h(t)})))throw new Error("Audience (aud) must be a string or an array of strings");return{header:JSON.parse(T(O(n))),payload:s}},E=function(t){function n(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var o=t.apply(this,n)||this;return o.fields_=e,o}return e(n,t),n.prototype.getMissingFields=function(){return this.fields_},n}(Error),I=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=e.map((function(e){return e(t)})).filter((function(t){return null!==t}));if(r&&r.length)throw new E(r,r.join(","));return null},A=function(t,e){var n=[];return function(r){return e&&e.filter((function(t){return!r.payload[t]})).forEach((function(t){return n.push(t)})),t&&t.filter((function(t){return!r.header[t]})).forEach((function(t){return n.push(t)})),n&&n.length?n.join(",")+" missing":null}},K=function(t){return function(e){return F("Issuer (iss)",t,e.payload.iss)}},C=function(t){return function(e){return F("Issuer (iss) claim",t,e.header.alg)}},D=function(t){return void 0===t&&(t=[]),function(e){return e.payload.aud&&e.payload.aud.length?(n=t,e.payload.aud.every((function(t){return n.includes(t)}))?null:"Audience (aud) claim mismatch: audience ("+e.payload.aud+") must contain only ("+t+")"):"Audience (aud) claim must be a present string";var n}},R=function(t,e){return void 0===t&&(t=!0),void 0===e&&(e=40),function(n){if(!t&&!n.payload.exp)return null;if(!l(n.payload.exp))return"Expiration Time (exp) claim must be a present number";var r=z(n.payload.exp,e);return new Date(Date.now())>r?"Expiration Time (exp) claim expired ("+r+")":null}},U=function(t,e){return void 0===t&&(t=!0),void 0===e&&(e=40),function(n){if(!t&&!n.payload.nbf)return null;if(!l(n.payload.nbf))return"Not Before (nbf) claim must be a present number";var r=z(n.payload.nbf,-1*e),o=new Date(Date.now());return o<r?"Not Before (nbf) claim cannot be used yet, current time ("+o+") is before ("+r+")":null}},F=function(t,e,n){return e!==n?t+' mismatch: expected "'+e+'" but got "'+n+'"':null},z=function(t,e){void 0===e&&(e=0);var n=new Date(0);return n.setUTCSeconds(t+e),n},P=function(){function t(t){this.opts=t,this.loginStateKey="crossid-spa-js|login",this.logoutStateKey="crossid-spa-js|logout",this.scope=t.scope,this.state=this._stateFactory(this.opts.state_type||"session_storage"),this.cache=this._cacheFactory(this.opts.cache_type||"memory"),this._purgeIndex()}return t.prototype.createRedirectURL=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,this._createAuthorizationData(t)];case 1:return e=n.sent(),[4,this._persistAuthorizationData(e)];case 2:return n.sent(),[2,this._authorizeUrl(e.request)]}}))}))},t.prototype.loginWithRedirect=function(t){return o(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,this.createRedirectURL(t)];case 1:return e=n.sent(),window.location.replace(e),[2]}}))}))},t.prototype.handleRedirectCallback=function(t){return void 0===t&&(t=new URL(window.location.href)),o(this,void 0,void 0,(function(){var e,n,r,o,s,a,c;return i(this,(function(i){switch(i.label){case 0:if(e=t.searchParams,n=e.get("code"),r=e.get("error"))throw new Error(r);if(!(null==(o=this.state.get(this.loginStateKey))?void 0:o.code_verifier))throw new Error("invalid state, try sign-in again");return[4,u({tokenEndpoint:this.opts.token_endpoint,client_id:this.opts.client_id,code_verifier:o.code_verifier,grant_type:"authorization_code",redirect_uri:o.redirect_uri,code:n})];case 1:return(s=i.sent()).id_token&&((a=x(s.id_token)).payload.__bearer=s.id_token,this._assertIDToken(a,o.nonce)),c=x(s.access_token),this.state.remove(this.loginStateKey),this._assertAccessToken(c,o.audience),c.payload._raw=s.access_token,this._cacheTokens(a,c,s.refresh_token),[2,{state:o.state}]}}))}))},t.prototype.getUser=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){var e,n,r,o;return i(this,(function(i){return e=t.audience||this.opts.audience,n=m(this.scope,t.scope),r=this._getTokensKeysFromCache("id_token",e,n),[2,null==(o=this._getNarrowedKey(r))?void 0:o.payload]}))}))},t.prototype.getAccessToken=function(t){var e;return void 0===t&&(t={}),o(this,void 0,void 0,(function(){var n,r,o,s;return i(this,(function(i){return n=t.audience||this.opts.audience,r=m(this.scope,t.scope),o=this._getTokensKeysFromCache("access_token",n,r),s=this._getNarrowedKey(o),[2,null===(e=null==s?void 0:s.payload)||void 0===e?void 0:e._raw]}))}))},t.prototype.introspectAccessToken=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){var e,r,o,s;return i(this,(function(i){return e=t.audience||this.opts.audience,r=m(this.scope,t.scope),o=this._getTokensKeysFromCache("access_token",e,r),(s=this._getNarrowedKey(o))?[2,n(n({active:!0},s.payload),{_raw:void 0})]:[2,void 0]}))}))},t.prototype.createLogoutRedirectURL=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,this._createLogoutData(t)];case 1:return e=n.sent(),e.request.id_token_hint&&t.post_logout_redirect_uri?[4,this._persistLogoutData(e)]:(this._removeTokens(e.audience,e.scopes),[2,this._logoutUrl()]);case 2:return n.sent(),[2,this._logoutUrl(e.request)]}}))}))},t.prototype.logoutWithRedirect=function(t){return o(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,this.createLogoutRedirectURL(t)];case 1:return e=n.sent(),window.location.assign(e),[2]}}))}))},t.prototype.handleLogoutRedirectCallback=function(t){return void 0===t&&(t=new URL(window.location.href)),o(this,void 0,void 0,(function(){var e,n,r,o;return i(this,(function(i){if(e=t.searchParams,n=e.get("state"),r=e.get("error"))throw new Error(r);if(!(null==(o=this.state.get(this.logoutStateKey))?void 0:o.state)||o.state!==n)throw new Error("invalid state, try sign-in again");return this._removeTokens(o.audience,o.scopes),this.state.remove(this.logoutStateKey),[2,{state:o.appState}]}))}))},t.prototype._createAuthorizationData=function(t){return o(this,void 0,void 0,(function(){var e,n,r,s,a,u;return i(this,(function(c){switch(c.label){case 0:return e=S(k(b())),n=S(k(b())),r=b(),[4,(l=r,o(void 0,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,window.crypto.subtle.digest({name:"SHA-256"},(new TextEncoder).encode(l))];case 1:return[2,t.sent()]}}))})))];case 1:return s=c.sent(),p=new Uint8Array(s),a=S(k(String.fromCharCode.apply(String,Array.from(p)))),u={audience:t.audience,redirect_uri:t.redirect_uri,response_type:t.response_type,scope:t.scope,state:e,nonce:n,code_challenge:a},[2,{request:this._mergeAuthorizationCodeParams(u),code_verifier:r,appState:t.state}]}var p,l}))}))},t.prototype._persistAuthorizationData=function(t){return o(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){return e=t.request,n={audience:e.audience,redirect_uri:e.redirect_uri,scope:e.scope,nonce:e.nonce,state:t.appState,code_verifier:t.code_verifier},this.state.set(this.loginStateKey,n),[2]}))}))},t.prototype._mergeAuthorizationCodeParams=function(t){return{client_id:this.opts.client_id,audience:t.audience||this.opts.audience,response_type:t.response_type||this.opts.response_type||"code",redirect_uri:t.redirect_uri||this.opts.redirect_uri,nonce:t.nonce,state:t.state,scope:t.scope||this.opts.scope,code_challenge:t.code_challenge,code_challenge_method:"S256"}},t.prototype._createLogoutData=function(t){return o(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:return(e={id_token_hint:t.id_token_hint,post_logout_redirect_uri:t.post_logout_redirect_uri}).id_token_hint||null===e.id_token_hint?[3,2]:[4,this.getUser()];case 1:(n=r.sent())&&n.__bearer&&(e.id_token_hint=n.__bearer),r.label=2;case 2:return e.id_token_hint&&(e.state=S(k(b()))),[2,{request:e,audience:t.audience||this.opts.audience,scopes:(t.scope||this.scope).split(" "),appState:t.state}]}}))}))},t.prototype._persistLogoutData=function(t){return o(this,void 0,void 0,(function(){var e;return i(this,(function(n){return e={client_id:this.opts.client_id,audience:t.audience,scopes:t.scopes,post_logout_redirect_uri:t.request.post_logout_redirect_uri,state:t.request.state,appState:t.appState},this.state.set(this.logoutStateKey,e),[2]}))}))},t.prototype._assertAccessToken=function(t,e){I(t,A(["alg"],["iss","sub","aud","exp","iat"]),K(this.opts.issuer),C("RS256"),D(e),R(!0),U(!0))},t.prototype._assertIDToken=function(t,e){var n;return I(t,A(["alg"],["iss","sub","aud","nonce","exp","iat"]),K(this.opts.issuer),(n=e,function(t){return F("Nonce (nonce)",n,t.payload.nonce)}),C("RS256"),D([this.opts.client_id]),R(!0),U(!1),(function(t){return l(t.payload.iat)?null:"Issued At (iat) claim must be a present number"})),null},t.prototype._removeTokens=function(t,e){var n=this,r=this._getTokensKeysFromCache("id_token",t,e),o=this._getTokensKeysFromCache("access_token",t,e),i=this._getTokensKeysFromCache("refresh_token",t,e);r.concat(o).concat(i).forEach((function(t){return n.cache.remove(t)})),this._purgeIndex()},t.prototype._authorizeUrl=function(t){return this.opts.authorization_endpoint+"?"+j(t)},t.prototype._logoutUrl=function(t){var e=this.opts.logout_endpoint;return t&&(e=e+"?"+j(t)),e},t.prototype._stateFactory=function(t){var e={ttl:300};switch(t){case"local_storage":return new v(e);case"session_storage":return new _(e);default:throw new Error('Invalid cache type "'+t+'"')}},t.prototype._cacheFactory=function(t){switch(t){case"memory":return new g;case"local_storage":return new v({purgeOnInit:!0});case"session_storage":return new _({purgeOnInit:!0});default:throw new Error('Invalid cache type "'+t+'"')}},t.prototype._cacheTokens=function(t,e,n){var r=this._ttlFromToken(e);this._cacheToken("access_token",e,this.opts.client_id,e.payload.aud,e.payload.scp,r),t&&this._cacheToken("id_token",t,this.opts.client_id,e.payload.aud,e.payload.scp||[],this._ttlFromToken(t)),n&&this._cacheToken("refresh_token",n,this.opts.client_id,e.payload.aud,e.payload.scp,432e3)},t.prototype._cacheToken=function(t,e,n,r,o,i){var s=this._cacheKey({tokType:t,client_id:n,audience:r,scope:o});this.cache.set(s,e,{ttl:i});var a=[r[0]],u=this.cache.get(c);u||(u={}),a.forEach((function(t){u[t]||(u[t]={});var e=u[t];o.forEach((function(t){e[t]||(e[t]=[]),e[t].push(s)}))})),this.cache.set(c,u)},t.prototype._cacheKey=function(t){var e,n=t.tokType,r=t.client_id,o=t.audience,i=t.scope;return i&&i.length&&(i.sort(),e=i.join("__")),["crossid-spa-js",n,r,o.join("__"),e].join("|")},t.prototype._decodeKey=function(t){var e=t.split("|"),n=e[1],r=e[2],o=e[3];return{tokenType:n,audience:r.split("__"),scope:o.split("__")}},t.prototype._getTokensKeysFromCache=function(t,e,n){var r,o=this,i=(this.cache.get(c)||{})[e[0]];if(!i)return[];for(var s=function(e){return i[e]&&i[e].length?r?void(r=r.filter((function(t){return i[e].includes(t)}))):(r=i[e].filter((function(e){return o._decodeKey(e).tokenType===t})),"continue"):{value:[]}},a=0,u=n;a<u.length;a++){var p=s(u[a]);if("object"==typeof p)return p.value}return r},t.prototype._getNarrowedKey=function(t){for(var e in t){var n=this.cache.get(t[e]);if(n)return n}},t.prototype._ttlFromToken=function(t){return(new Date(1e3*t.payload.exp).getTime()-Date.now())/1e3},t.prototype._purgeIndex=function(){var t=this.cache.get(c);if(t){for(var e=0,n=Object.entries(t);e<n.length;e++){for(var r=n[e],o=r[0],i=r[1],s=function(e,n){for(var r=[],i=0;i<n.length;i++)a.cache.get(n[i])||r.push(i);t[o][e]=n.filter((function(t,e){return-1===r.indexOf(e)})),t[o][e].length||delete t[o][e]},a=this,u=0,p=Object.entries(i);u<p.length;u++){var l=p[u];s(l[0],l[1])}Object.keys(t[o]).length||delete t[o]}this.cache.set(c,t)}},t}();function L(t){return o(this,void 0,void 0,(function(){var e,n,o,s,u,c;return i(this,(function(i){switch(i.label){case 0:return e=t.tenant_id,n=t.auth_server,o=void 0===n?"default":n,s=r(t,["tenant_id","auth_server"]),u=s,[4,a({wellknown_endpoint:"https://"+e+".crossid.io/oauth2/"+o+"/.well-known/openid-configuration"})];case 1:return c=i.sent(),u.authorization_endpoint=c.authorization_endpoint,u.token_endpoint=c.token_endpoint,u.issuer=c.issuer,u.logout_endpoint=u.issuer+"logout",[2,new P(u)]}}))}))}function N(t){return o(this,void 0,void 0,(function(){var e,n,o;return i(this,(function(i){switch(i.label){case 0:return[4,a(t)];case 1:return e=i.sent(),n=r(t,["wellknown_endpoint"]),(o=n).authorization_endpoint=e.authorization_endpoint,o.token_endpoint=e.token_endpoint,o.issuer=e.issuer,[2,new P(o)]}}))}))}function q(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,new P(t)]}))}))}export{P as Client,L as newCrossidClient,N as newCrossidClientByDiscovery,q as newCrossidClientCustom};
var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};function e(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return(n=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function r(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}function o(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))}function i(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}var s=function(t){function n(e,r){var o=t.call(this,r)||this;return o.error=e,o.error_description=r,Object.setPrototypeOf(o,n.prototype),o}return e(n,t),n.create=function(t){return new n(t.error,t.error_description)},n}(Error);function a(t){var e=t.wellknown_endpoint;return o(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return[4,fetch(e)];case 1:return 200!==(t=n.sent()).status?[3,3]:[4,t.json()];case 2:return[2,n.sent()];case 3:throw Error("failed to discover data from well known discovery endpoint.")}}))}))}function u(t){var e=t.tokenEndpoint,a=t.timeout,u=r(t,["tokenEndpoint","timeout"]);return o(this,void 0,void 0,(function(){var t,r,c;return i(this,(function(p){switch(p.label){case 0:return t=new FormData,Object.keys(u).forEach((function(e){return t.append(e,u[e])})),[4,(l=e,h={timeout:a,method:"POST",body:t},void 0===h&&(h={}),o(void 0,void 0,void 0,(function(){var t,e,r,o,s;return i(this,(function(i){switch(i.label){case 0:return t=h.timeout,e=void 0===t?5e3:t,r=new AbortController,o=setTimeout((function(){return r.abort()}),e),[4,fetch(l,n(n({},h),{signal:r.signal}))];case 1:return s=i.sent(),clearTimeout(o),[2,s]}}))})))];case 1:return[4,(r=p.sent()).json()];case 2:if(c=p.sent(),200!==r.status)throw s.create(c);return[2,c]}var l,h}))}))}var c="crossid-spa-js|index",p=function(t){return null!==t&&"Object"===(null==t?void 0:t.constructor.name)},l=function(t){return"number"==typeof t},h=function(t){return"string"==typeof t},d=String.fromCharCode(0),f=function(){function t(t,e){void 0===e&&(e={}),this.gopts=e,this.storage=t,e.purgeOnInit&&this.purge(!0)}return t.prototype.set=function(t,e,n){var r=this._key(t),o=this._ttl(null==n?void 0:n.ttl);try{var i=function(t,e){var n;return e&&e>0?((n={})[d]=t,n.ttl=Date.now()+1e3*e,n):t}(e,o);return this.storage.setItem(r,JSON.stringify(i)),!0}catch(t){return!1}},t.prototype.get=function(t,e){var n,r=this._key(t);try{var o=this.storage.getItem(r);if(null===o)return;var i=JSON.parse(o);return p(n=i)&&d in n?function(t,e){return Date.now()-1e3*e>t.ttl}(i,(null==e?void 0:e.ttl)||0)?void this.storage.removeItem(t):i[d]:i}catch(t){return}},t.prototype.remove=function(t){var e=this._key(t);return!!this.storage.getItem(e)&&(this.storage.removeItem(e),!0)},t.prototype.purge=function(t){var e=this;void 0===t&&(t=!1);var n=0;return Object.keys(this.storage).filter((function(t){return t.startsWith(e.gopts.prefix)})).forEach((function(r){var o=e.storage.getItem(r);if(o){var i;try{i=JSON.parse(o)}catch(t){return}(p(i)&&d in i&&Date.now()>i.ttl||t)&&(n++,e.storage.removeItem(r))}})),n},t.prototype._key=function(t){return this.gopts.prefix?""+this.gopts.prefix+t:t},t.prototype._ttl=function(t){return null===t?null:t||this.gopts.ttl||null},t}(),_=function(t){function n(e){var n=t.call(this,sessionStorage,e)||this;if("undefined"==typeof sessionStorage)throw Error("no support for session storage.");return n}return e(n,t),n}(f),v=function(t){function n(e){var n=t.call(this,localStorage,e)||this;if("undefined"==typeof localStorage)throw Error("no support for local storage.");return n}return e(n,t),n}(f),y=function(){function t(){}return t.prototype.getItem=function(t){return t in this?this[t]:null},t.prototype.setItem=function(t,e){void 0===e?this.removeItem(t):this[t]=""+e},t.prototype.removeItem=function(t){this.hasOwnProperty(t)&&delete this[t]},t}(),g=function(t){function n(e){return t.call(this,new y,e)||this}return e(n,t),n}(f),w=function(t){return Array.from(new Set(t))},m=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return w(t.join(" ").trim().split(/\s+/))},b=function(){return t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",e=Math.floor(86*Math.random()+43),Array.from(window.crypto.getRandomValues(new Uint8Array(e))).map((function(e){return t[e%t.length]})).join("");var t,e},k=function(t){return btoa(t)},T=function(t){return atob(t)},S=function(t){var e={"+":"-","/":"_","=":""};return t.replace(/[+/=]/g,(function(t){return e[t]}))},O=function(t){var e={"-":"+",_:"/"};return t.replace(/[-_]/g,(function(t){return e[t]}))},j=function(t){return Object.keys(t).filter((function(e){return void 0!==t[e]&&null!==t[e]})).map((function(e){return encodeURIComponent(e)+"="+encodeURIComponent(t[e])})).join("&")},x=function(t){var e=t.split("."),n=e[0],r=e[1],o=e[2];if(3!==e.length||!n||!r||!o)throw new Error("malformed JWT token.");var i,s=JSON.parse(T(O(r)));if(s.aud)if(h(s.aud))s.aud=[s.aud];else if(i=s.aud,!Array.isArray(i)||!i.every((function(t){return h(t)})))throw new Error("Audience (aud) must be a string or an array of strings");return{header:JSON.parse(T(O(n))),payload:s}},E=function(t){function n(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var o=t.apply(this,n)||this;return o.fields_=e,o}return e(n,t),n.prototype.getMissingFields=function(){return this.fields_},n}(Error),I=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=e.map((function(e){return e(t)})).filter((function(t){return null!==t}));if(r&&r.length)throw new E(r,r.join(","));return null},A=function(t,e){var n=[];return function(r){return e&&e.filter((function(t){return!r.payload[t]})).forEach((function(t){return n.push(t)})),t&&t.filter((function(t){return!r.header[t]})).forEach((function(t){return n.push(t)})),n&&n.length?n.join(",")+" missing":null}},K=function(t){return function(e){return F("Issuer (iss)",t,e.payload.iss)}},C=function(t){return function(e){return F("Issuer (iss) claim",t,e.header.alg)}},D=function(t){return void 0===t&&(t=[]),function(e){return e.payload.aud&&e.payload.aud.length?(n=t,e.payload.aud.every((function(t){return n.includes(t)}))?null:"Audience (aud) claim mismatch: audience ("+e.payload.aud+") must contain only ("+t+")"):"Audience (aud) claim must be a present string";var n}},R=function(t,e){return void 0===t&&(t=!0),void 0===e&&(e=40),function(n){if(!t&&!n.payload.exp)return null;if(!l(n.payload.exp))return"Expiration Time (exp) claim must be a present number";var r=z(n.payload.exp,e);return new Date(Date.now())>r?"Expiration Time (exp) claim expired ("+r+")":null}},U=function(t,e){return void 0===t&&(t=!0),void 0===e&&(e=40),function(n){if(!t&&!n.payload.nbf)return null;if(!l(n.payload.nbf))return"Not Before (nbf) claim must be a present number";var r=z(n.payload.nbf,-1*e),o=new Date(Date.now());return o<r?"Not Before (nbf) claim cannot be used yet, current time ("+o+") is before ("+r+")":null}},F=function(t,e,n){return e!==n?t+' mismatch: expected "'+e+'" but got "'+n+'"':null},z=function(t,e){void 0===e&&(e=0);var n=new Date(0);return n.setUTCSeconds(t+e),n},P=function(){function t(t){this.opts=t,this.loginStateKey="crossid-spa-js|login",this.logoutStateKey="crossid-spa-js|logout",this.scope=t.scope,this.state=this._stateFactory(this.opts.state_type||"session_storage"),this.cache=this._cacheFactory(this.opts.cache_type||"memory"),this._purgeIndex()}return t.prototype.createRedirectURL=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,this._createAuthorizationData(t)];case 1:return e=n.sent(),[4,this._persistAuthorizationData(e)];case 2:return n.sent(),[2,this._authorizeUrl(e.request)]}}))}))},t.prototype.loginWithRedirect=function(t){return o(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,this.createRedirectURL(t)];case 1:return e=n.sent(),window.location.replace(e),[2]}}))}))},t.prototype.handleRedirectCallback=function(t){return void 0===t&&(t=new URL(window.location.href)),o(this,void 0,void 0,(function(){var e,n,r,o,s,a,c;return i(this,(function(i){switch(i.label){case 0:if(e=t.searchParams,n=e.get("code"),r=e.get("error"))throw new Error(r);if(!(null==(o=this.state.get(this.loginStateKey))?void 0:o.code_verifier))throw new Error("invalid state, try sign-in again");return[4,u({tokenEndpoint:this.opts.token_endpoint,client_id:this.opts.client_id,code_verifier:o.code_verifier,grant_type:"authorization_code",redirect_uri:o.redirect_uri,code:n})];case 1:return(s=i.sent()).id_token&&((a=x(s.id_token)).payload.__bearer=s.id_token,this._assertIDToken(a,o.nonce)),c=x(s.access_token),this.state.remove(this.loginStateKey),this._assertAccessToken(c,o.audience),c.payload._raw=s.access_token,this._cacheTokens(a,c,s.refresh_token),[2,{state:o.state}]}}))}))},t.prototype.getUser=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){var e,n,r,o;return i(this,(function(i){return e=t.audience||this.opts.audience,n=m(this.scope,t.scope),r=this._getTokensKeysFromCache("id_token",e,n),[2,null==(o=this._getNarrowedKey(r))?void 0:o.payload]}))}))},t.prototype.getAccessToken=function(t){var e;return void 0===t&&(t={}),o(this,void 0,void 0,(function(){var n,r,o,s;return i(this,(function(i){return n=t.audience||this.opts.audience,r=m(this.scope,t.scope),o=this._getTokensKeysFromCache("access_token",n,r),s=this._getNarrowedKey(o),[2,null===(e=null==s?void 0:s.payload)||void 0===e?void 0:e._raw]}))}))},t.prototype.introspectAccessToken=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){var e,r,o,s;return i(this,(function(i){return e=t.audience||this.opts.audience,r=m(this.scope,t.scope),o=this._getTokensKeysFromCache("access_token",e,r),(s=this._getNarrowedKey(o))?[2,n(n({active:!0},s.payload),{_raw:void 0})]:[2,void 0]}))}))},t.prototype.createLogoutRedirectURL=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,this._createLogoutData(t)];case 1:return e=n.sent(),e.request.id_token_hint&&t.post_logout_redirect_uri?[4,this._persistLogoutData(e)]:(this._removeTokens(e.audience,e.scopes),[2,this._logoutUrl()]);case 2:return n.sent(),[2,this._logoutUrl(e.request)]}}))}))},t.prototype.logoutWithRedirect=function(t){return o(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,this.createLogoutRedirectURL(t)];case 1:return e=n.sent(),window.location.assign(e),[2]}}))}))},t.prototype.handleLogoutRedirectCallback=function(t){return void 0===t&&(t=new URL(window.location.href)),o(this,void 0,void 0,(function(){var e,n,r,o;return i(this,(function(i){if(e=t.searchParams,n=e.get("state"),r=e.get("error"))throw new Error(r);if(!(null==(o=this.state.get(this.logoutStateKey))?void 0:o.state)||o.state!==n)throw new Error("invalid state, try sign-in again");return this._removeTokens(o.audience,o.scopes),this.state.remove(this.logoutStateKey),[2,{state:o.appState}]}))}))},t.prototype._createAuthorizationData=function(t){return o(this,void 0,void 0,(function(){var e,n,r,s,a,u;return i(this,(function(c){switch(c.label){case 0:return e=S(k(b())),n=S(k(b())),r=b(),[4,(l=r,o(void 0,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,window.crypto.subtle.digest({name:"SHA-256"},(new TextEncoder).encode(l))];case 1:return[2,t.sent()]}}))})))];case 1:return s=c.sent(),p=new Uint8Array(s),a=S(k(String.fromCharCode.apply(String,Array.from(p)))),u={audience:t.audience,redirect_uri:t.redirect_uri,response_type:t.response_type,scope:t.scope,state:e,nonce:n,code_challenge:a},[2,{request:this._mergeAuthorizationCodeParams(u),code_verifier:r,appState:t.state}]}var p,l}))}))},t.prototype._persistAuthorizationData=function(t){return o(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){return e=t.request,n={audience:e.audience,redirect_uri:e.redirect_uri,scope:e.scope,nonce:e.nonce,state:t.appState,code_verifier:t.code_verifier},this.state.set(this.loginStateKey,n),[2]}))}))},t.prototype._mergeAuthorizationCodeParams=function(t){return{client_id:this.opts.client_id,audience:t.audience||this.opts.audience,response_type:t.response_type||this.opts.response_type||"code",redirect_uri:t.redirect_uri||this.opts.redirect_uri,nonce:t.nonce,state:t.state,scope:t.scope||this.opts.scope,code_challenge:t.code_challenge,code_challenge_method:"S256"}},t.prototype._createLogoutData=function(t){return o(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:return(e={id_token_hint:t.id_token_hint,post_logout_redirect_uri:t.post_logout_redirect_uri}).id_token_hint||null===e.id_token_hint?[3,2]:[4,this.getUser()];case 1:(n=r.sent())&&n.__bearer&&(e.id_token_hint=n.__bearer),r.label=2;case 2:return e.id_token_hint&&(e.state=S(k(b()))),[2,{request:e,audience:t.audience||this.opts.audience,scopes:(t.scope||this.scope).split(" "),appState:t.state}]}}))}))},t.prototype._persistLogoutData=function(t){return o(this,void 0,void 0,(function(){var e;return i(this,(function(n){return e={client_id:this.opts.client_id,audience:t.audience,scopes:t.scopes,post_logout_redirect_uri:t.request.post_logout_redirect_uri,state:t.request.state,appState:t.appState},this.state.set(this.logoutStateKey,e),[2]}))}))},t.prototype._assertAccessToken=function(t,e){I(t,A(["alg"],["iss","sub","aud","exp","iat"]),K(this.opts.issuer),C("RS256"),D(e),R(!0),U(!0))},t.prototype._assertIDToken=function(t,e){var n;return I(t,A(["alg"],["iss","sub","aud","nonce","exp","iat"]),K(this.opts.issuer),(n=e,function(t){return F("Nonce (nonce)",n,t.payload.nonce)}),C("RS256"),D([this.opts.client_id]),R(!0),U(!1),(function(t){return l(t.payload.iat)?null:"Issued At (iat) claim must be a present number"})),null},t.prototype._removeTokens=function(t,e){var n=this,r=this._getTokensKeysFromCache("id_token",t,e),o=this._getTokensKeysFromCache("access_token",t,e),i=this._getTokensKeysFromCache("refresh_token",t,e);r.concat(o).concat(i).forEach((function(t){return n.cache.remove(t)})),this._purgeIndex()},t.prototype._authorizeUrl=function(t){return this.opts.authorization_endpoint+"?"+j(t)},t.prototype._logoutUrl=function(t){var e=this.opts.logout_endpoint;return t&&(e=e+"?"+j(t)),e},t.prototype._stateFactory=function(t){var e={ttl:300};switch(t){case"local_storage":return new v(e);case"session_storage":return new _(e);default:throw new Error('Invalid cache type "'+t+'"')}},t.prototype._cacheFactory=function(t){switch(t){case"memory":return new g;case"local_storage":return new v({purgeOnInit:!0});case"session_storage":return new _({purgeOnInit:!0});default:throw new Error('Invalid cache type "'+t+'"')}},t.prototype._cacheTokens=function(t,e,n){var r=this._ttlFromToken(e);this._cacheToken("access_token",e,this.opts.client_id,e.payload.aud,e.payload.scp,r),t&&this._cacheToken("id_token",t,this.opts.client_id,e.payload.aud,e.payload.scp||[],this._ttlFromToken(t)),n&&this._cacheToken("refresh_token",n,this.opts.client_id,e.payload.aud,e.payload.scp,432e3)},t.prototype._cacheToken=function(t,e,n,r,o,i){var s=this._cacheKey({tokType:t,client_id:n,audience:r,scope:o});this.cache.set(s,e,{ttl:i});var a=[r[0]],u=this.cache.get(c);u||(u={}),a.forEach((function(t){u[t]||(u[t]={});var e=u[t];o.forEach((function(t){e[t]||(e[t]=[]),e[t].push(s)}))})),this.cache.set(c,u)},t.prototype._cacheKey=function(t){var e,n=t.tokType,r=t.client_id,o=t.audience,i=t.scope;return i&&i.length&&(i.sort(),e=i.join("__")),["crossid-spa-js",n,r,o.join("__"),e].join("|")},t.prototype._decodeKey=function(t){var e=t.split("|"),n=e[1],r=e[2],o=e[3];return{tokenType:n,audience:r.split("__"),scope:o.split("__")}},t.prototype._getTokensKeysFromCache=function(t,e,n){var r,o=this,i=(this.cache.get(c)||{})[e[0]];if(!i)return[];for(var s=function(e){return i[e]&&i[e].length?r?void(r=r.filter((function(t){return i[e].includes(t)}))):(r=i[e].filter((function(e){return o._decodeKey(e).tokenType===t})),"continue"):{value:[]}},a=0,u=n;a<u.length;a++){var p=s(u[a]);if("object"==typeof p)return p.value}return r},t.prototype._getNarrowedKey=function(t){for(var e in t){var n=this.cache.get(t[e]);if(n)return n}},t.prototype._ttlFromToken=function(t){return(new Date(1e3*t.payload.exp).getTime()-Date.now())/1e3},t.prototype._purgeIndex=function(){var t=this.cache.get(c);if(t){for(var e=0,n=Object.entries(t);e<n.length;e++){for(var r=n[e],o=r[0],i=r[1],s=function(e,n){for(var r=[],i=0;i<n.length;i++)a.cache.get(n[i])||r.push(i);t[o][e]=n.filter((function(t,e){return-1===r.indexOf(e)})),t[o][e].length||delete t[o][e]},a=this,u=0,p=Object.entries(i);u<p.length;u++){var l=p[u];s(l[0],l[1])}Object.keys(t[o]).length||delete t[o]}this.cache.set(c,t)}},t}();function L(t){return o(this,void 0,void 0,(function(){var e,n,o,s,u,c;return i(this,(function(i){switch(i.label){case 0:return e=t.tenant_id,n=t.auth_server,o=void 0===n?"default":n,s=r(t,["tenant_id","auth_server"]),u=s,[4,a({wellknown_endpoint:"https://"+e+".crossid.io/oauth2/"+o+"/.well-known/openid-configuration"})];case 1:return c=i.sent(),u.authorization_endpoint=c.authorization_endpoint,u.token_endpoint=c.token_endpoint,u.issuer=c.issuer,u.logout_endpoint=u.issuer+"logout",[2,new P(u)]}}))}))}function N(t){return o(this,void 0,void 0,(function(){var e,n,o;return i(this,(function(i){switch(i.label){case 0:return[4,a(t)];case 1:return e=i.sent(),n=r(t,["wellknown_endpoint"]),(o=n).authorization_endpoint=e.authorization_endpoint,o.token_endpoint=e.token_endpoint,o.issuer=e.issuer,[2,new P(o)]}}))}))}function q(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,new P(t)]}))}))}export{P as Client,s as OAuth2Error,L as newCrossidClient,N as newCrossidClientByDiscovery,q as newCrossidClientCustom};
//# sourceMappingURL=index.js.map

@@ -79,3 +79,3 @@ interface IDTokenAddressClaim {

code_verifier: string;
state?: string;
state?: any;
tenantId?: string;

@@ -87,3 +87,3 @@ }

export interface LoginCompleteResponse {
state: string;
state: any;
}

@@ -93,3 +93,3 @@ export interface LogoutRequest {

post_logout_redirect_uri?: string;
state?: string;
state?: any;
}

@@ -100,3 +100,3 @@ export interface LogoutData {

scopes: string[];
appState: string;
appState: any;
}

@@ -109,3 +109,3 @@ export interface LogoutState {

state: string;
appState: string;
appState: any;
}

@@ -116,4 +116,4 @@ /**

export interface LogoutCompleteResponse {
state: string;
state: any;
}
export {};
{
"name": "@crossid/crossid-spa-js",
"version": "0.2.0",
"version": "0.3.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "dist/crossid-spa-js.js",

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