@trimble-oss/trimble-id-react 0.1.0-rc.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,7 +37,7 @@ export interface TokenResponse {
37
37
  expires_at: number;
38
38
  }
39
39
  export interface TIDUser {
40
- /** User or application UUID */
40
+ /** User's unique identifier */
41
41
  id?: string;
42
42
  /** End-User's full name */
43
43
  name?: string;
@@ -445,7 +445,7 @@ class Ve extends Error {
445
445
  }
446
446
  class Ht extends Error {
447
447
  }
448
- const O = "@trimble-oss/trimble-id-react", I = "0.1.0-rc.1", qt = {
448
+ const O = "@trimble-oss/trimble-id-react", I = "0.1.0", qt = {
449
449
  configurationEndpoint: "",
450
450
  clientId: "",
451
451
  redirectUrl: "",
@@ -1,4 +1,4 @@
1
- (function(m,T){typeof exports=="object"&&typeof module<"u"?T(exports,require("@trimble-oss/trimble-id"),require("es-cookie"),require("jwt-decode"),require("react")):typeof define=="function"&&define.amd?define(["exports","@trimble-oss/trimble-id","es-cookie","jwt-decode","react"],T):(m=typeof globalThis<"u"?globalThis:m||self,T(m.ReactTID={},m.trimbleId,m.esCookie,m.jwt_decode,m.require$$0))})(this,function(m,T,L,Qe,k){"use strict";var Zt=Object.defineProperty;var qt=(m,T,L)=>T in m?Zt(m,T,{enumerable:!0,configurable:!0,writable:!0,value:L}):m[T]=L;var p=(m,T,L)=>(qt(m,typeof T!="symbol"?T+"":T,L),L);function Ze(a){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const n in a)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(a,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>a[n]})}}return t.default=a,Object.freeze(t)}const ie=Ze(L);class qe{constructor(){p(this,"generateCache",function(){const t={token:void 0,user:void 0};return{async getToken(){return t.token},async getUser(){return t.user},async storeToken(n){t.token=n},async storeUser(n){t.user=n},clear(){return t.token=void 0,t.user=void 0,Promise.resolve(void 0)}}}())}}class et{constructor(t){p(this,"localStorage");p(this,"cacheKey");this.localStorage=window.localStorage,this.cacheKey=t.cacheKey}async getToken(){const t=this.getAuthKey(),n=localStorage.getItem(t);return n?JSON.parse(n):void 0}async getUser(){const t=this.getUserKey(),n=localStorage.getItem(t);return n?JSON.parse(n):void 0}async storeToken(t){const n=this.getAuthKey(),o=JSON.stringify(t);localStorage.setItem(n,o)}async storeUser(t){const n=this.getUserKey(),o=JSON.stringify(t);localStorage.setItem(n,o)}getUserKey(){return this.cacheKey.getUserKey()}getAuthKey(){return this.cacheKey.getAuthKey()}clear(){return this.localStorage.removeItem(this.getAuthKey()),this.localStorage.removeItem(this.getUserKey()),Promise.resolve(void 0)}}const ae="@TID",tt=`${ae}_AUTH_KEY`,rt=`${ae}_USER_KEY`;class nt{constructor(t){p(this,"clientId");p(this,"prefix",ae);p(this,"authSuffix",tt);p(this,"userSuffix",rt);this.clientId=t.client_id}getUserKey(){return`${this.prefix}_${this.userSuffix}_${this.clientId}`}getAuthKey(){return`${this.prefix}_${this.authSuffix}_${this.clientId}`}}class it{constructor(t){p(this,"sessionStorage");p(this,"cacheKey");this.sessionStorage=window.sessionStorage,this.cacheKey=t.cacheKey}async getToken(){const t=this.getAuthKey(),n=sessionStorage.getItem(t);return n?JSON.parse(n):void 0}async getUser(){const t=this.getUserKey(),n=sessionStorage.getItem(t);return n?JSON.parse(n):void 0}async storeToken(t){const n=this.getAuthKey(),o=JSON.stringify(t);sessionStorage.setItem(n,o)}async storeUser(t){const n=this.getUserKey(),o=JSON.stringify(t);sessionStorage.setItem(n,o)}getUserKey(){return this.cacheKey.getUserKey()}getAuthKey(){return this.cacheKey.getAuthKey()}clear(){return this.sessionStorage.removeItem(this.getAuthKey()),this.sessionStorage.removeItem(this.getUserKey()),Promise.resolve(void 0)}}class at{constructor(t){p(this,"persistentStore");p(this,"cacheStorage");p(this,"cacheKey");this.persistentStore=t.persistentStore,this.cacheKey=new nt({client_id:t.clientId}),this.persistentStore==="localStorage"?this.cacheStorage=new et({cacheKey:this.cacheKey}):this.persistentStore==="sessionStorage"?this.cacheStorage=new it({cacheKey:this.cacheKey}):this.cacheStorage=new qe().generateCache}async setToken(t){await this.cacheStorage.storeToken(t)}async setUser(t){await this.cacheStorage.storeUser(t)}async getUser(){return this.cacheStorage.getUser()}async getToken(){return this.cacheStorage.getToken()}async clear(){await this.cacheStorage.clear()}}const me=5*6e4,ot=["code","state"],Ee=a=>a.split("?")[0],st=a=>a.split("?")[1],_e=a=>{let t=a;if(!a.startsWith("?"))try{t=new URL(a).search}catch{}return new URLSearchParams(t)},ct=(a=window.location.href,t)=>{if(t!=null){const o=Ee(t),c=Ee(a??"");if(o!==c)return!1}const n=_e(a);for(const o of ot)if(!n.has(o))return!1;return!0},lt=a=>({id:a.sub,name:`${a.given_name} ${a.family_name}`,given_name:a.given_name,family_name:a.family_name,picture:a.picture,email:a.email,email_verified:a.email_verified,phone_number_verified:!1}),ut="@TID_COOKIE";class ft{get(t){const n=ie.get(t);if(n==null)throw new Error("Cookie not found");return JSON.parse(n)}set(t,n,o){let c={};window.location.protocol==="https:"&&(c={secure:!0,sameSite:"none"}),o!=null&&o.expires&&(c.expires=o.expires),o!=null&&o.domain&&(c.domain=o.domain),ie.set(t,JSON.stringify(n),c)}remove(t,n){const o={};n!=null&&n.domain&&(o.domain=n.domain),ie.remove(t,o)}}class dt{constructor(t){p(this,"cookieKey");p(this,"cookiesStorage");this.cookieKey=`${ut}.${t.clientId}`,this.cookiesStorage=new ft}save(t){this.cookiesStorage.set(this.cookieKey,t,{expires:1})}get(){try{return this.cookiesStorage.get(this.cookieKey)}catch{return}}clear(){this.cookiesStorage.remove(this.cookieKey)}}class Te extends Error{}class ke extends Error{}class ht extends Error{}const A="@trimble-oss/trimble-id-react",K="0.1.0-rc.1",gt={configurationEndpoint:"",clientId:"",redirectUrl:"",logoutRedirectUrl:"",scopes:[]},vt={persistentStore:"in-memory"};class Se{constructor(t){p(this,"tokenProvider");p(this,"cacheManager");p(this,"cookiesManager");p(this,"clientId");p(this,"redirectUrl");p(this,"analyticshttpclient");const{config:n=gt,persistentOptions:o=vt}=t;if(this.redirectUrl=n.redirectUrl,n.configurationEndpoint==null||n.configurationEndpoint=="")throw new Error("Configuration endpoint not defined");if(n.clientId==null||n.clientId=="")throw new Error("Consumer key is not defined");this.cookiesManager=new dt({clientId:n.clientId});const c=this.cookiesManager.get(),w=new T.OpenIdEndpointProvider(n.configurationEndpoint);let S=new T.AuthorizationCodeGrantTokenProvider(w,n.clientId,n.redirectUrl).WithScopes(n.scopes);n.logoutRedirectUrl&&(S=S.WithLogoutRedirect(n.logoutRedirectUrl)),(c==null?void 0:c.code_verifier)!=null&&(S=S.WithProofKeyForCodeExchange(c.code_verifier)),this.tokenProvider=S,this.cacheManager=new at({clientId:n.clientId,persistentStore:o.persistentStore}),this.clientId=n.clientId,this.analyticshttpclient=T.AnalyticsHttpClient,this.analyticshttpclient.sendInitEvent("TIDClient",this.clientId,A,K)}async loginWithRedirect(t){this.analyticshttpclient.sendMethodEvent(this.loginWithRedirect.name,this.clientId,A,K);const{onRedirect:n}=t||{},o=T.AuthorizationCodeGrantTokenProvider.GenerateCodeVerifier();this.cookiesManager.save({code_verifier:o}),this.tokenProvider=this.tokenProvider.WithProofKeyForCodeExchange(o);const c=await this.tokenProvider.GetOAuthRedirect("state");n!=null?n(c):window.location.assign(c)}async handleCallback(t=window.location.href){const n=this.cookiesManager.get();if(n==null||(n==null?void 0:n.code_verifier)==null)throw new ht("Code verifier not available");const o=st(t),c=_e(t),w=c.get("identity_provider")??"",S=c.get("state")??"";return await this.tokenProvider.ValidateQuery(o),await this.generateToken(w),{authState:S}}async generateToken(t){var C,f;const n=await this.tokenProvider.RetrieveToken(),o=await this.tokenProvider.RetrieveRefreshToken(),c=await this.tokenProvider.RetrieveIdToken(),w=await this.tokenProvider.RetrieveTokenExpiry(),P=new Date(w).getTime(),v=(f=(C=this.tokenProvider)==null?void 0:C._scopes)==null?void 0:f.join(" ");await this.cacheManager.setToken({scope:v,state:"",session_state:"",identity_provider:t,token_type:"bearer",access_token:n,refresh_token:o,id_token:c,expires_at:P});const x=Qe(c),R=lt(x);await this.cacheManager.setUser(R),await this.reloadCodeVerifier()}async reloadCodeVerifier(){const t=await this.tokenProvider.RetrieveCodeVerifier();this.cookiesManager.save({code_verifier:t}),this.tokenProvider=this.tokenProvider.WithProofKeyForCodeExchange(t)}async getUser(){return this.analyticshttpclient.sendMethodEvent(this.getUser.name,this.clientId,A,K),await this.cacheManager.getUser()}async getAccessTokenSilently(){this.analyticshttpclient.sendMethodEvent(this.getAccessTokenSilently.name,this.clientId,A,K);let t=await this.cacheManager.getToken();if(t==null)throw this.analyticshttpclient.sendExceptionEvent(this.getAccessTokenSilently.name,"No token available",this.clientId,A,K),new ke("No token available");const n=new Date(new Date().getTime()+me);if((t==null?void 0:t.expires_at)==null||(t==null?void 0:t.expires_at)<n.getTime()){try{await this.tokenProvider.RetrieveToken()}catch(o){throw this.analyticshttpclient.sendExceptionEvent(this.getAccessTokenSilently.name,o.message,this.clientId,A,K),new Te(o.message)}await this.generateToken((t==null?void 0:t.identity_provider)??""),t=await this.cacheManager.getToken()}return(t==null?void 0:t.access_token)||""}async getTokens(){this.analyticshttpclient.sendMethodEvent(this.getTokens.name,this.clientId,A,K);let t=await this.cacheManager.getToken();if(t==null)throw this.analyticshttpclient.sendExceptionEvent(this.getTokens.name,"No token available",this.clientId,A,K),new ke("No token available");const n=new Date(new Date().getTime()+me);if((t==null?void 0:t.expires_at)==null||(t==null?void 0:t.expires_at)<n.getTime()){try{await this.tokenProvider.RetrieveToken()}catch(o){throw this.analyticshttpclient.sendExceptionEvent(this.getTokens.name,o.message,this.clientId,A,K),new Te(o.message)}await this.generateToken((t==null?void 0:t.identity_provider)??""),t=await this.cacheManager.getToken()}return{access_token:(t==null?void 0:t.access_token)||"",expires_at:(t==null?void 0:t.expires_at)||0,id_token:(t==null?void 0:t.id_token)||""}}async logout(t){this.analyticshttpclient.sendMethodEvent(this.logout.name,this.clientId,A,K);const{onRedirect:n,disabledAutoRedirect:o}=t||{};this.cacheManager&&await this.cacheManager.clear(),this.cookiesManager&&this.cookiesManager.clear();const c=await this.tokenProvider.GetOAuthLogoutRedirect("state");if(n!=null)return n(c);o||window.location.assign(c)}async checkSession(){try{await this.getAccessTokenSilently()}catch{return!1}return!0}async loadUserSession(){await this.loadCacheSessionIntoSDK(),await this.checkSession()||await this.cacheManager.clear()}async loadCacheSessionIntoSDK(){const t=await this.cacheManager.getToken();if(t==null)return;const n=t.access_token,o=t.refresh_token||"",c=t.id_token,w=t.expires_at;this.tokenProvider=this.tokenProvider.WithAccessToken(n,w).WithRefreshToken(o).WithIdToken(c)}getBearerTokenHttpClient(t){return new T.BearerTokenHttpClientProvider(this.tokenProvider,t)}getRedirectUrl(){return this.redirectUrl}}const z=k.createContext(null),Re=()=>k.useContext(z)??{};var oe={exports:{}},Y={};/**
1
+ (function(m,T){typeof exports=="object"&&typeof module<"u"?T(exports,require("@trimble-oss/trimble-id"),require("es-cookie"),require("jwt-decode"),require("react")):typeof define=="function"&&define.amd?define(["exports","@trimble-oss/trimble-id","es-cookie","jwt-decode","react"],T):(m=typeof globalThis<"u"?globalThis:m||self,T(m.ReactTID={},m.trimbleId,m.esCookie,m.jwt_decode,m.require$$0))})(this,function(m,T,L,Qe,k){"use strict";var Zt=Object.defineProperty;var qt=(m,T,L)=>T in m?Zt(m,T,{enumerable:!0,configurable:!0,writable:!0,value:L}):m[T]=L;var p=(m,T,L)=>(qt(m,typeof T!="symbol"?T+"":T,L),L);function Ze(a){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const n in a)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(a,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>a[n]})}}return t.default=a,Object.freeze(t)}const ie=Ze(L);class qe{constructor(){p(this,"generateCache",function(){const t={token:void 0,user:void 0};return{async getToken(){return t.token},async getUser(){return t.user},async storeToken(n){t.token=n},async storeUser(n){t.user=n},clear(){return t.token=void 0,t.user=void 0,Promise.resolve(void 0)}}}())}}class et{constructor(t){p(this,"localStorage");p(this,"cacheKey");this.localStorage=window.localStorage,this.cacheKey=t.cacheKey}async getToken(){const t=this.getAuthKey(),n=localStorage.getItem(t);return n?JSON.parse(n):void 0}async getUser(){const t=this.getUserKey(),n=localStorage.getItem(t);return n?JSON.parse(n):void 0}async storeToken(t){const n=this.getAuthKey(),o=JSON.stringify(t);localStorage.setItem(n,o)}async storeUser(t){const n=this.getUserKey(),o=JSON.stringify(t);localStorage.setItem(n,o)}getUserKey(){return this.cacheKey.getUserKey()}getAuthKey(){return this.cacheKey.getAuthKey()}clear(){return this.localStorage.removeItem(this.getAuthKey()),this.localStorage.removeItem(this.getUserKey()),Promise.resolve(void 0)}}const ae="@TID",tt=`${ae}_AUTH_KEY`,rt=`${ae}_USER_KEY`;class nt{constructor(t){p(this,"clientId");p(this,"prefix",ae);p(this,"authSuffix",tt);p(this,"userSuffix",rt);this.clientId=t.client_id}getUserKey(){return`${this.prefix}_${this.userSuffix}_${this.clientId}`}getAuthKey(){return`${this.prefix}_${this.authSuffix}_${this.clientId}`}}class it{constructor(t){p(this,"sessionStorage");p(this,"cacheKey");this.sessionStorage=window.sessionStorage,this.cacheKey=t.cacheKey}async getToken(){const t=this.getAuthKey(),n=sessionStorage.getItem(t);return n?JSON.parse(n):void 0}async getUser(){const t=this.getUserKey(),n=sessionStorage.getItem(t);return n?JSON.parse(n):void 0}async storeToken(t){const n=this.getAuthKey(),o=JSON.stringify(t);sessionStorage.setItem(n,o)}async storeUser(t){const n=this.getUserKey(),o=JSON.stringify(t);sessionStorage.setItem(n,o)}getUserKey(){return this.cacheKey.getUserKey()}getAuthKey(){return this.cacheKey.getAuthKey()}clear(){return this.sessionStorage.removeItem(this.getAuthKey()),this.sessionStorage.removeItem(this.getUserKey()),Promise.resolve(void 0)}}class at{constructor(t){p(this,"persistentStore");p(this,"cacheStorage");p(this,"cacheKey");this.persistentStore=t.persistentStore,this.cacheKey=new nt({client_id:t.clientId}),this.persistentStore==="localStorage"?this.cacheStorage=new et({cacheKey:this.cacheKey}):this.persistentStore==="sessionStorage"?this.cacheStorage=new it({cacheKey:this.cacheKey}):this.cacheStorage=new qe().generateCache}async setToken(t){await this.cacheStorage.storeToken(t)}async setUser(t){await this.cacheStorage.storeUser(t)}async getUser(){return this.cacheStorage.getUser()}async getToken(){return this.cacheStorage.getToken()}async clear(){await this.cacheStorage.clear()}}const me=5*6e4,ot=["code","state"],Ee=a=>a.split("?")[0],st=a=>a.split("?")[1],_e=a=>{let t=a;if(!a.startsWith("?"))try{t=new URL(a).search}catch{}return new URLSearchParams(t)},ct=(a=window.location.href,t)=>{if(t!=null){const o=Ee(t),c=Ee(a??"");if(o!==c)return!1}const n=_e(a);for(const o of ot)if(!n.has(o))return!1;return!0},lt=a=>({id:a.sub,name:`${a.given_name} ${a.family_name}`,given_name:a.given_name,family_name:a.family_name,picture:a.picture,email:a.email,email_verified:a.email_verified,phone_number_verified:!1}),ut="@TID_COOKIE";class ft{get(t){const n=ie.get(t);if(n==null)throw new Error("Cookie not found");return JSON.parse(n)}set(t,n,o){let c={};window.location.protocol==="https:"&&(c={secure:!0,sameSite:"none"}),o!=null&&o.expires&&(c.expires=o.expires),o!=null&&o.domain&&(c.domain=o.domain),ie.set(t,JSON.stringify(n),c)}remove(t,n){const o={};n!=null&&n.domain&&(o.domain=n.domain),ie.remove(t,o)}}class dt{constructor(t){p(this,"cookieKey");p(this,"cookiesStorage");this.cookieKey=`${ut}.${t.clientId}`,this.cookiesStorage=new ft}save(t){this.cookiesStorage.set(this.cookieKey,t,{expires:1})}get(){try{return this.cookiesStorage.get(this.cookieKey)}catch{return}}clear(){this.cookiesStorage.remove(this.cookieKey)}}class Te extends Error{}class ke extends Error{}class ht extends Error{}const A="@trimble-oss/trimble-id-react",K="0.1.0",gt={configurationEndpoint:"",clientId:"",redirectUrl:"",logoutRedirectUrl:"",scopes:[]},vt={persistentStore:"in-memory"};class Se{constructor(t){p(this,"tokenProvider");p(this,"cacheManager");p(this,"cookiesManager");p(this,"clientId");p(this,"redirectUrl");p(this,"analyticshttpclient");const{config:n=gt,persistentOptions:o=vt}=t;if(this.redirectUrl=n.redirectUrl,n.configurationEndpoint==null||n.configurationEndpoint=="")throw new Error("Configuration endpoint not defined");if(n.clientId==null||n.clientId=="")throw new Error("Consumer key is not defined");this.cookiesManager=new dt({clientId:n.clientId});const c=this.cookiesManager.get(),w=new T.OpenIdEndpointProvider(n.configurationEndpoint);let S=new T.AuthorizationCodeGrantTokenProvider(w,n.clientId,n.redirectUrl).WithScopes(n.scopes);n.logoutRedirectUrl&&(S=S.WithLogoutRedirect(n.logoutRedirectUrl)),(c==null?void 0:c.code_verifier)!=null&&(S=S.WithProofKeyForCodeExchange(c.code_verifier)),this.tokenProvider=S,this.cacheManager=new at({clientId:n.clientId,persistentStore:o.persistentStore}),this.clientId=n.clientId,this.analyticshttpclient=T.AnalyticsHttpClient,this.analyticshttpclient.sendInitEvent("TIDClient",this.clientId,A,K)}async loginWithRedirect(t){this.analyticshttpclient.sendMethodEvent(this.loginWithRedirect.name,this.clientId,A,K);const{onRedirect:n}=t||{},o=T.AuthorizationCodeGrantTokenProvider.GenerateCodeVerifier();this.cookiesManager.save({code_verifier:o}),this.tokenProvider=this.tokenProvider.WithProofKeyForCodeExchange(o);const c=await this.tokenProvider.GetOAuthRedirect("state");n!=null?n(c):window.location.assign(c)}async handleCallback(t=window.location.href){const n=this.cookiesManager.get();if(n==null||(n==null?void 0:n.code_verifier)==null)throw new ht("Code verifier not available");const o=st(t),c=_e(t),w=c.get("identity_provider")??"",S=c.get("state")??"";return await this.tokenProvider.ValidateQuery(o),await this.generateToken(w),{authState:S}}async generateToken(t){var C,f;const n=await this.tokenProvider.RetrieveToken(),o=await this.tokenProvider.RetrieveRefreshToken(),c=await this.tokenProvider.RetrieveIdToken(),w=await this.tokenProvider.RetrieveTokenExpiry(),P=new Date(w).getTime(),v=(f=(C=this.tokenProvider)==null?void 0:C._scopes)==null?void 0:f.join(" ");await this.cacheManager.setToken({scope:v,state:"",session_state:"",identity_provider:t,token_type:"bearer",access_token:n,refresh_token:o,id_token:c,expires_at:P});const x=Qe(c),R=lt(x);await this.cacheManager.setUser(R),await this.reloadCodeVerifier()}async reloadCodeVerifier(){const t=await this.tokenProvider.RetrieveCodeVerifier();this.cookiesManager.save({code_verifier:t}),this.tokenProvider=this.tokenProvider.WithProofKeyForCodeExchange(t)}async getUser(){return this.analyticshttpclient.sendMethodEvent(this.getUser.name,this.clientId,A,K),await this.cacheManager.getUser()}async getAccessTokenSilently(){this.analyticshttpclient.sendMethodEvent(this.getAccessTokenSilently.name,this.clientId,A,K);let t=await this.cacheManager.getToken();if(t==null)throw this.analyticshttpclient.sendExceptionEvent(this.getAccessTokenSilently.name,"No token available",this.clientId,A,K),new ke("No token available");const n=new Date(new Date().getTime()+me);if((t==null?void 0:t.expires_at)==null||(t==null?void 0:t.expires_at)<n.getTime()){try{await this.tokenProvider.RetrieveToken()}catch(o){throw this.analyticshttpclient.sendExceptionEvent(this.getAccessTokenSilently.name,o.message,this.clientId,A,K),new Te(o.message)}await this.generateToken((t==null?void 0:t.identity_provider)??""),t=await this.cacheManager.getToken()}return(t==null?void 0:t.access_token)||""}async getTokens(){this.analyticshttpclient.sendMethodEvent(this.getTokens.name,this.clientId,A,K);let t=await this.cacheManager.getToken();if(t==null)throw this.analyticshttpclient.sendExceptionEvent(this.getTokens.name,"No token available",this.clientId,A,K),new ke("No token available");const n=new Date(new Date().getTime()+me);if((t==null?void 0:t.expires_at)==null||(t==null?void 0:t.expires_at)<n.getTime()){try{await this.tokenProvider.RetrieveToken()}catch(o){throw this.analyticshttpclient.sendExceptionEvent(this.getTokens.name,o.message,this.clientId,A,K),new Te(o.message)}await this.generateToken((t==null?void 0:t.identity_provider)??""),t=await this.cacheManager.getToken()}return{access_token:(t==null?void 0:t.access_token)||"",expires_at:(t==null?void 0:t.expires_at)||0,id_token:(t==null?void 0:t.id_token)||""}}async logout(t){this.analyticshttpclient.sendMethodEvent(this.logout.name,this.clientId,A,K);const{onRedirect:n,disabledAutoRedirect:o}=t||{};this.cacheManager&&await this.cacheManager.clear(),this.cookiesManager&&this.cookiesManager.clear();const c=await this.tokenProvider.GetOAuthLogoutRedirect("state");if(n!=null)return n(c);o||window.location.assign(c)}async checkSession(){try{await this.getAccessTokenSilently()}catch{return!1}return!0}async loadUserSession(){await this.loadCacheSessionIntoSDK(),await this.checkSession()||await this.cacheManager.clear()}async loadCacheSessionIntoSDK(){const t=await this.cacheManager.getToken();if(t==null)return;const n=t.access_token,o=t.refresh_token||"",c=t.id_token,w=t.expires_at;this.tokenProvider=this.tokenProvider.WithAccessToken(n,w).WithRefreshToken(o).WithIdToken(c)}getBearerTokenHttpClient(t){return new T.BearerTokenHttpClientProvider(this.tokenProvider,t)}getRedirectUrl(){return this.redirectUrl}}const z=k.createContext(null),Re=()=>k.useContext(z)??{};var oe={exports:{}},Y={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  {
3
3
  "name": "@trimble-oss/trimble-id-react",
4
4
  "private": false,
5
- "version": "0.1.0-rc.1",
5
+ "version": "0.1.0",
6
6
  "homepage": "https://github.com/trimble-oss/trimble-id-sdk-docs-for-react",
7
7
  "author": "Trimble developers <developers@trimble.com>",
8
8
  "license": "MIT",