@trimble-oss/trimble-id-react 0.1.0 → 0.1.1

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.
@@ -1,11 +1,12 @@
1
- var wt = Object.defineProperty;
2
- var bt = (a, t, n) => t in a ? wt(a, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : a[t] = n;
3
- var p = (a, t, n) => (bt(a, typeof t != "symbol" ? t + "" : t, n), n);
4
- import { OpenIdEndpointProvider as Ct, AuthorizationCodeGrantTokenProvider as Le, AnalyticsHttpClient as Pt, BearerTokenHttpClientProvider as Ot } from "@trimble-oss/trimble-id";
5
- import * as ue from "es-cookie";
6
- import It from "jwt-decode";
7
- import Be, { createContext as xt, useContext as ze, useState as At, useReducer as Kt, useRef as Ut, useMemo as Fe, useEffect as He, useCallback as W } from "react";
8
- class Dt {
1
+ var H = Object.defineProperty;
2
+ var B = (i, e, t) => e in i ? H(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
+ var a = (i, e, t) => (B(i, typeof e != "symbol" ? e + "" : e, t), t);
4
+ import { OpenIdEndpointProvider as Y, AuthorizationCodeGrantTokenProvider as A, AnalyticsHttpClient as z, BearerTokenHttpClientProvider as Q } from "@trimble-oss/trimble-id";
5
+ import * as p from "es-cookie";
6
+ import X from "jwt-decode";
7
+ import { createContext as q, useContext as N, useState as Z, useReducer as j, useRef as ee, useMemo as R, useEffect as b, useCallback as f } from "react";
8
+ import { jsx as W, Fragment as te } from "react/jsx-runtime";
9
+ class ie {
9
10
  constructor() {
10
11
  /**
11
12
  * This function generate a encapsulation function to store
@@ -14,8 +15,8 @@ class Dt {
14
15
  * @see {https://medium.com/javascript-scene/encapsulation-in-javascript-26be60e325b4} Encapsulation
15
16
  * @return {CacheStorage} Key for the token
16
17
  */
17
- p(this, "generateCache", function() {
18
- const t = {
18
+ a(this, "generateCache", function() {
19
+ const e = {
19
20
  token: void 0,
20
21
  user: void 0
21
22
  };
@@ -25,93 +26,93 @@ class Dt {
25
26
  * @return {Promise<TIDAuthToken | undefined>} Token store in memory
26
27
  */
27
28
  async getToken() {
28
- return t.token;
29
+ return e.token;
29
30
  },
30
31
  /**
31
32
  * Get user store in cache
32
33
  * @return {Promise<TIDUser | undefined>} User store in memory
33
34
  */
34
35
  async getUser() {
35
- return t.user;
36
+ return e.user;
36
37
  },
37
38
  /**
38
39
  * Store token in cache
39
40
  * @param {TIDAuthToken} token - Token that you want to store in cache
40
41
  * @return {Promise<void>} Empty promise
41
42
  */
42
- async storeToken(n) {
43
- t.token = n;
43
+ async storeToken(t) {
44
+ e.token = t;
44
45
  },
45
46
  /**
46
47
  * Store user in cache
47
48
  * @param {TIDUser} user - User that you want to store in cache
48
49
  * @return {Promise<void>} Empty promise
49
50
  */
50
- async storeUser(n) {
51
- t.user = n;
51
+ async storeUser(t) {
52
+ e.user = t;
52
53
  },
53
54
  /**
54
55
  * The clear the cache from the storage
55
56
  * @return {Promise<void>} Empty promise
56
57
  */
57
58
  clear() {
58
- return t.token = void 0, t.user = void 0, Promise.resolve(void 0);
59
+ return e.token = void 0, e.user = void 0, Promise.resolve(void 0);
59
60
  }
60
61
  };
61
62
  }());
62
63
  }
63
64
  }
64
- class Mt {
65
+ class se {
65
66
  /**
66
67
  * Initialized configuration to store information into local storage
67
68
  * @param {LocalStorageCacheOptions} options - Configuration for caching in localstorage
68
69
  */
69
- constructor(t) {
70
+ constructor(e) {
70
71
  /**
71
72
  * Local storage from the browser
72
73
  * @type {Storage}
73
74
  */
74
- p(this, "localStorage");
75
+ a(this, "localStorage");
75
76
  /**
76
77
  * The cache key represents the keys for storing and retrieving user and token from auth
77
78
  * @type {CacheKey}
78
79
  */
79
- p(this, "cacheKey");
80
- this.localStorage = window.localStorage, this.cacheKey = t.cacheKey;
80
+ a(this, "cacheKey");
81
+ this.localStorage = window.localStorage, this.cacheKey = e.cacheKey;
81
82
  }
82
83
  /**
83
84
  * Get token store in localstorage
84
85
  * @return {Promise<TIDAuthToken | undefined>} - Token store in localstorage
85
86
  */
86
87
  async getToken() {
87
- const t = this.getAuthKey(), n = localStorage.getItem(t);
88
- return n ? JSON.parse(n) : void 0;
88
+ const e = this.getAuthKey(), t = localStorage.getItem(e);
89
+ return t ? JSON.parse(t) : void 0;
89
90
  }
90
91
  /**
91
92
  * Get user store in localstorage
92
93
  * @return {Promise<TIDUser | undefined>} - User store in localstorage
93
94
  */
94
95
  async getUser() {
95
- const t = this.getUserKey(), n = localStorage.getItem(t);
96
- return n ? JSON.parse(n) : void 0;
96
+ const e = this.getUserKey(), t = localStorage.getItem(e);
97
+ return t ? JSON.parse(t) : void 0;
97
98
  }
98
99
  /**
99
100
  * Store token in localstorage
100
101
  * @param {TIDAuthToken} token - Token that you want to store in localstorage
101
102
  * @return {Promise<void>} Empty promise
102
103
  */
103
- async storeToken(t) {
104
- const n = this.getAuthKey(), o = JSON.stringify(t);
105
- localStorage.setItem(n, o);
104
+ async storeToken(e) {
105
+ const t = this.getAuthKey(), s = JSON.stringify(e);
106
+ localStorage.setItem(t, s);
106
107
  }
107
108
  /**
108
109
  * Store user in cache
109
110
  * @param {TIDUser} user - User that you want to store in localstorage
110
111
  * @return {Promise<void>} Empty promise
111
112
  */
112
- async storeUser(t) {
113
- const n = this.getUserKey(), o = JSON.stringify(t);
114
- localStorage.setItem(n, o);
113
+ async storeUser(e) {
114
+ const t = this.getUserKey(), s = JSON.stringify(e);
115
+ localStorage.setItem(t, s);
115
116
  }
116
117
  /**
117
118
  * Get the full key from the cachekey for the user
@@ -135,34 +136,34 @@ class Mt {
135
136
  return this.localStorage.removeItem(this.getAuthKey()), this.localStorage.removeItem(this.getUserKey()), Promise.resolve(void 0);
136
137
  }
137
138
  }
138
- const ge = "@TID", jt = `${ge}_AUTH_KEY`, Lt = `${ge}_USER_KEY`;
139
- class Ft {
139
+ const T = "@TID", re = `${T}_AUTH_KEY`, ne = `${T}_USER_KEY`;
140
+ class oe {
140
141
  /**
141
142
  * Initialized the cache key
142
143
  * @param {CacheKeyOptions} cacheKeyOptions - Cache key options to edit the default values
143
144
  */
144
- constructor(t) {
145
+ constructor(e) {
145
146
  /**
146
147
  * Client id of the application created in trimble developer console
147
148
  * @type {string}
148
149
  */
149
- p(this, "clientId");
150
+ a(this, "clientId");
150
151
  /**
151
152
  * Prefix value of the key, by default the prefix is based on the constant PREFIX_KEY
152
153
  * @type {string}
153
154
  */
154
- p(this, "prefix", ge);
155
+ a(this, "prefix", T);
155
156
  /**
156
157
  * Suffix value use it to generate the key to store and retrieve the token, by default the prefix is based on the constant AUTH_KEY
157
158
  * @type {string}
158
159
  */
159
- p(this, "authSuffix", jt);
160
+ a(this, "authSuffix", re);
160
161
  /**
161
162
  * Suffix value use it to generate the key to store and retrieve the user, by default the prefix is based on the constant USER_KEY
162
163
  * @type {string}
163
164
  */
164
- p(this, "userSuffix", Lt);
165
- this.clientId = t.client_id;
165
+ a(this, "userSuffix", ne);
166
+ this.clientId = e.client_id;
166
167
  }
167
168
  /**
168
169
  * Get key to store/retrieve user
@@ -179,57 +180,57 @@ class Ft {
179
180
  return `${this.prefix}_${this.authSuffix}_${this.clientId}`;
180
181
  }
181
182
  }
182
- class Nt {
183
+ class ae {
183
184
  /**
184
185
  * Initialized configuration to store information into session storage
185
186
  * @param {SessionStorageCacheOptions} options - Configuration for caching in session storage
186
187
  */
187
- constructor(t) {
188
+ constructor(e) {
188
189
  /**
189
190
  * Session storage from the browser
190
191
  * @type {Storage}
191
192
  */
192
- p(this, "sessionStorage");
193
+ a(this, "sessionStorage");
193
194
  /**
194
195
  * The cache key represents the keys for storing and retrieving user and token from auth
195
196
  * @type {CacheKey}
196
197
  */
197
- p(this, "cacheKey");
198
- this.sessionStorage = window.sessionStorage, this.cacheKey = t.cacheKey;
198
+ a(this, "cacheKey");
199
+ this.sessionStorage = window.sessionStorage, this.cacheKey = e.cacheKey;
199
200
  }
200
201
  /**
201
202
  * Get token store in session storage
202
203
  * @return {Promise<TIDAuthToken | undefined>} - Token store in session storage
203
204
  */
204
205
  async getToken() {
205
- const t = this.getAuthKey(), n = sessionStorage.getItem(t);
206
- return n ? JSON.parse(n) : void 0;
206
+ const e = this.getAuthKey(), t = sessionStorage.getItem(e);
207
+ return t ? JSON.parse(t) : void 0;
207
208
  }
208
209
  /**
209
210
  * Get user store in session storage
210
211
  * @return {Promise<TIDUser | undefined>} - User store in session storage
211
212
  */
212
213
  async getUser() {
213
- const t = this.getUserKey(), n = sessionStorage.getItem(t);
214
- return n ? JSON.parse(n) : void 0;
214
+ const e = this.getUserKey(), t = sessionStorage.getItem(e);
215
+ return t ? JSON.parse(t) : void 0;
215
216
  }
216
217
  /**
217
218
  * Store token in session storage
218
219
  * @param {TIDAuthToken} authToken - Token that you want to store in session storage
219
220
  * @return {Promise<void>} Empty promise
220
221
  */
221
- async storeToken(t) {
222
- const n = this.getAuthKey(), o = JSON.stringify(t);
223
- sessionStorage.setItem(n, o);
222
+ async storeToken(e) {
223
+ const t = this.getAuthKey(), s = JSON.stringify(e);
224
+ sessionStorage.setItem(t, s);
224
225
  }
225
226
  /**
226
227
  * Store user in cache
227
228
  * @param {TIDUser} user - User that you want to store in session storage
228
229
  * @return {Promise<void>} Empty promise
229
230
  */
230
- async storeUser(t) {
231
- const n = this.getUserKey(), o = JSON.stringify(t);
232
- sessionStorage.setItem(n, o);
231
+ async storeUser(e) {
232
+ const t = this.getUserKey(), s = JSON.stringify(e);
233
+ sessionStorage.setItem(t, s);
233
234
  }
234
235
  /**
235
236
  * Get the full key from the cachekey for the user
@@ -253,12 +254,12 @@ class Nt {
253
254
  return this.sessionStorage.removeItem(this.getAuthKey()), this.sessionStorage.removeItem(this.getUserKey()), Promise.resolve(void 0);
254
255
  }
255
256
  }
256
- class Wt {
257
+ class ce {
257
258
  /**
258
259
  * Create a cache manager to extract or save the user, and token
259
260
  * @param {CacheManagerOptions} options - Configuration for the managing the caching
260
261
  */
261
- constructor(t) {
262
+ constructor(e) {
262
263
  /**
263
264
  * Type persistent you want the user and token to be store
264
265
  * in-memory - This one will only persist will the user stays in the page
@@ -266,40 +267,40 @@ class Wt {
266
267
  * sessionStorage - This one is cleared when the page session ends
267
268
  * @type {PersistentStore}
268
269
  */
269
- p(this, "persistentStore");
270
+ a(this, "persistentStore");
270
271
  /**
271
272
  * Cache option selected
272
273
  * @type {CacheStorage}
273
274
  */
274
- p(this, "cacheStorage");
275
+ a(this, "cacheStorage");
275
276
  /**
276
277
  * The cache key represents the keys for storing and retrieving user and token from auth
277
278
  * @type {CacheKey}
278
279
  */
279
- p(this, "cacheKey");
280
- this.persistentStore = t.persistentStore, this.cacheKey = new Ft({
281
- client_id: t.clientId
282
- }), this.persistentStore === "localStorage" ? this.cacheStorage = new Mt({
280
+ a(this, "cacheKey");
281
+ this.persistentStore = e.persistentStore, this.cacheKey = new oe({
282
+ client_id: e.clientId
283
+ }), this.persistentStore === "localStorage" ? this.cacheStorage = new se({
283
284
  cacheKey: this.cacheKey
284
- }) : this.persistentStore === "sessionStorage" ? this.cacheStorage = new Nt({
285
+ }) : this.persistentStore === "sessionStorage" ? this.cacheStorage = new ae({
285
286
  cacheKey: this.cacheKey
286
- }) : this.cacheStorage = new Dt().generateCache;
287
+ }) : this.cacheStorage = new ie().generateCache;
287
288
  }
288
289
  /**
289
290
  * Store token in cache
290
291
  * @param {TIDAuthToken} token - Token that you want to store in cache
291
292
  * @return {Promise<void>} Empty promise
292
293
  */
293
- async setToken(t) {
294
- await this.cacheStorage.storeToken(t);
294
+ async setToken(e) {
295
+ await this.cacheStorage.storeToken(e);
295
296
  }
296
297
  /**
297
298
  * Store user in cache
298
299
  * @param {TIDUser} user - User that you want to store in cache
299
300
  * @return {Promise<void>} Empty promise
300
301
  */
301
- async setUser(t) {
302
- await this.cacheStorage.storeUser(t);
302
+ async setUser(e) {
303
+ await this.cacheStorage.storeUser(e);
303
304
  }
304
305
  /**
305
306
  * Get user store in cache
@@ -323,45 +324,45 @@ class Wt {
323
324
  await this.cacheStorage.clear();
324
325
  }
325
326
  }
326
- const Ne = 5 * 6e4, $t = ["code", "state"], We = (a) => a.split("?")[0], Vt = (a) => a.split("?")[1], qe = (a) => {
327
- let t = a;
328
- if (!a.startsWith("?"))
327
+ const x = 5 * 6e4, le = ["code", "state"], O = (i) => i.split("?")[0], he = (i) => i.split("?")[1], V = (i) => {
328
+ let e = i;
329
+ if (!i.startsWith("?"))
329
330
  try {
330
- t = new URL(a).search;
331
+ e = new URL(i).search;
331
332
  } catch {
332
333
  }
333
- return new URLSearchParams(t);
334
- }, Yt = (a = window.location.href, t) => {
335
- if (t != null) {
336
- const o = We(t), c = We(a ?? "");
337
- if (o !== c)
334
+ return new URLSearchParams(e);
335
+ }, de = (i = window.location.href, e) => {
336
+ if (e != null) {
337
+ const s = O(e), r = O(i ?? "");
338
+ if (s !== r)
338
339
  return !1;
339
340
  }
340
- const n = qe(a);
341
- for (const o of $t)
342
- if (!n.has(o))
341
+ const t = V(i);
342
+ for (const s of le)
343
+ if (!t.has(s))
343
344
  return !1;
344
345
  return !0;
345
- }, Gt = (a) => ({
346
- id: a.sub,
347
- name: `${a.given_name} ${a.family_name}`,
348
- given_name: a.given_name,
349
- family_name: a.family_name,
350
- picture: a.picture,
351
- email: a.email,
352
- email_verified: a.email_verified,
346
+ }, ue = (i) => ({
347
+ id: i.sub,
348
+ name: `${i.given_name} ${i.family_name}`,
349
+ given_name: i.given_name,
350
+ family_name: i.family_name,
351
+ picture: i.picture,
352
+ email: i.email,
353
+ email_verified: i.email_verified,
353
354
  phone_number_verified: !1
354
- }), Jt = "@TID_COOKIE";
355
- class Bt {
355
+ }), ge = "@TID_COOKIE";
356
+ class ye {
356
357
  /**
357
358
  * Retrieve a cookie from the browser
358
359
  * @param {string} key - Key to retrieve the cookies
359
360
  */
360
- get(t) {
361
- const n = ue.get(t);
362
- if (n == null)
361
+ get(e) {
362
+ const t = p.get(e);
363
+ if (t == null)
363
364
  throw new Error("Cookie not found");
364
- return JSON.parse(n);
365
+ return JSON.parse(t);
365
366
  }
366
367
  /**
367
368
  * Store cookies in the browser
@@ -373,12 +374,12 @@ class Bt {
373
374
  * @example Save cookies with a custom domain
374
375
  * cookiesStorage.set('key',{data:{...}},{domain:'https://example.com/subpath'})
375
376
  */
376
- set(t, n, o) {
377
- let c = {};
378
- window.location.protocol === "https:" && (c = {
377
+ set(e, t, s) {
378
+ let r = {};
379
+ window.location.protocol === "https:" && (r = {
379
380
  secure: !0,
380
381
  sameSite: "none"
381
- }), o != null && o.expires && (c.expires = o.expires), o != null && o.domain && (c.domain = o.domain), ue.set(t, JSON.stringify(n), c);
382
+ }), s != null && s.expires && (r.expires = s.expires), s != null && s.domain && (r.domain = s.domain), p.set(e, JSON.stringify(t), r);
382
383
  }
383
384
  /**
384
385
  * Remove a cookie from the browser
@@ -389,35 +390,35 @@ class Bt {
389
390
  * @example Remove cookies with custom domain
390
391
  * cookiesStorage.remove('key',{domain:'https://example.com/subpath'})
391
392
  */
392
- remove(t, n) {
393
- const o = {};
394
- n != null && n.domain && (o.domain = n.domain), ue.remove(t, o);
393
+ remove(e, t) {
394
+ const s = {};
395
+ t != null && t.domain && (s.domain = t.domain), p.remove(e, s);
395
396
  }
396
397
  }
397
- class zt {
398
+ class fe {
398
399
  /**
399
400
  * Create a cookies manager to extract or save cookies in the browser
400
401
  * @param {CookiesManagerOptions} options - Configuration for the managing the cookies
401
402
  */
402
- constructor(t) {
403
+ constructor(e) {
403
404
  /**
404
405
  * Cookie full key to store and retrieve the information from cookies
405
406
  * @type {string}
406
407
  */
407
- p(this, "cookieKey");
408
+ a(this, "cookieKey");
408
409
  /**
409
410
  * Cookie storage. This object contain all functions necessary to retrieve and store tokens using cookies
410
411
  * @type {CookiesStorage}
411
412
  */
412
- p(this, "cookiesStorage");
413
- this.cookieKey = `${Jt}.${t.clientId}`, this.cookiesStorage = new Bt();
413
+ a(this, "cookiesStorage");
414
+ this.cookieKey = `${ge}.${e.clientId}`, this.cookiesStorage = new ye();
414
415
  }
415
416
  /**
416
417
  * Store cookies in the browser
417
418
  * @param {CookieValue} value - information to store
418
419
  */
419
- save(t) {
420
- this.cookiesStorage.set(this.cookieKey, t, {
420
+ save(e) {
421
+ this.cookiesStorage.set(this.cookieKey, e, {
421
422
  expires: 1
422
423
  });
423
424
  }
@@ -439,75 +440,75 @@ class zt {
439
440
  this.cookiesStorage.remove(this.cookieKey);
440
441
  }
441
442
  }
442
- class $e extends Error {
443
+ class M extends Error {
443
444
  }
444
- class Ve extends Error {
445
+ class L extends Error {
445
446
  }
446
- class Ht extends Error {
447
+ class ke extends Error {
447
448
  }
448
- const O = "@trimble-oss/trimble-id-react", I = "0.1.0", qt = {
449
+ const d = "@trimble-oss/trimble-id-react", u = "0.1.1", me = {
449
450
  configurationEndpoint: "",
450
451
  clientId: "",
451
452
  redirectUrl: "",
452
453
  logoutRedirectUrl: "",
453
454
  scopes: []
454
- }, Xt = {
455
+ }, Se = {
455
456
  persistentStore: "in-memory"
456
457
  };
457
- class Qt {
458
+ class pe {
458
459
  /**
459
460
  * Create a TID client to handle manage all user authentication functions and information
460
461
  * @param {CacheManagerOptions} props - TID client configuration
461
462
  */
462
- constructor(t) {
463
+ constructor(e) {
463
464
  /**
464
465
  * Token provider SDK. This object handles all necessary communication with TID
465
466
  * @type {AuthorizationCodeGrantTokenProvider}
466
467
  */
467
- p(this, "tokenProvider");
468
+ a(this, "tokenProvider");
468
469
  /**
469
470
  * This object manage all caching, and all configurations necessary
470
471
  * @type {CacheManager}
471
472
  */
472
- p(this, "cacheManager");
473
+ a(this, "cacheManager");
473
474
  /**
474
475
  * This object manage all cookies administration, and all configurations necessary
475
476
  * @type {CookiesManager}
476
477
  */
477
- p(this, "cookiesManager");
478
+ a(this, "cookiesManager");
478
479
  /**
479
480
  * Client id of the application created in trimble developer console
480
481
  * @type {string}
481
482
  */
482
- p(this, "clientId");
483
+ a(this, "clientId");
483
484
  /**
484
485
  * Callback url to redirect the user after the authentication is successful
485
486
  * @type {string}
486
487
  */
487
- p(this, "redirectUrl");
488
+ a(this, "redirectUrl");
488
489
  /**
489
490
  * AnalyticsHttpClient for sending events
490
491
  * @type {AnalyticsHttpClient}
491
492
  */
492
- p(this, "analyticshttpclient");
493
- const { config: n = qt, persistentOptions: o = Xt } = t;
494
- if (this.redirectUrl = n.redirectUrl, n.configurationEndpoint == null || n.configurationEndpoint == "")
493
+ a(this, "analyticshttpclient");
494
+ const { config: t = me, persistentOptions: s = Se } = e;
495
+ if (this.redirectUrl = t.redirectUrl, t.configurationEndpoint == null || t.configurationEndpoint == "")
495
496
  throw new Error("Configuration endpoint not defined");
496
- if (n.clientId == null || n.clientId == "")
497
+ if (t.clientId == null || t.clientId == "")
497
498
  throw new Error("Consumer key is not defined");
498
- this.cookiesManager = new zt({
499
- clientId: n.clientId
499
+ this.cookiesManager = new fe({
500
+ clientId: t.clientId
500
501
  });
501
- const c = this.cookiesManager.get(), S = new Ct(n.configurationEndpoint);
502
- let _ = new Le(
503
- S,
504
- n.clientId,
505
- n.redirectUrl
506
- ).WithScopes(n.scopes);
507
- n.logoutRedirectUrl && (_ = _.WithLogoutRedirect(n.logoutRedirectUrl)), (c == null ? void 0 : c.code_verifier) != null && (_ = _.WithProofKeyForCodeExchange(c.code_verifier)), this.tokenProvider = _, this.cacheManager = new Wt({
508
- clientId: n.clientId,
509
- persistentStore: o.persistentStore
510
- }), this.clientId = n.clientId, this.analyticshttpclient = Pt, this.analyticshttpclient.sendInitEvent("TIDClient", this.clientId, O, I);
502
+ const r = this.cookiesManager.get(), l = new Y(t.configurationEndpoint);
503
+ let c = new A(
504
+ l,
505
+ t.clientId,
506
+ t.redirectUrl
507
+ ).WithScopes(t.scopes);
508
+ t.logoutRedirectUrl && (c = c.WithLogoutRedirect(t.logoutRedirectUrl)), (r == null ? void 0 : r.code_verifier) != null && (c = c.WithProofKeyForCodeExchange(r.code_verifier)), this.tokenProvider = c, this.cacheManager = new ce({
509
+ clientId: t.clientId,
510
+ persistentStore: s.persistentStore
511
+ }), this.clientId = t.clientId, this.analyticshttpclient = z, this.analyticshttpclient.sendInitEvent("TIDClient", this.clientId, d, u);
511
512
  }
512
513
  /**
513
514
  * Redirect the user to TID using the browser
@@ -521,12 +522,12 @@ class Qt {
521
522
  * // Redirect calls onRedirect with the log-out url for TID
522
523
  * // So it can be handled by the developer
523
524
  */
524
- async loginWithRedirect(t) {
525
- this.analyticshttpclient.sendMethodEvent(this.loginWithRedirect.name, this.clientId, O, I);
526
- const { onRedirect: n } = t || {}, o = Le.GenerateCodeVerifier();
527
- this.cookiesManager.save({ code_verifier: o }), this.tokenProvider = this.tokenProvider.WithProofKeyForCodeExchange(o);
528
- const c = await this.tokenProvider.GetOAuthRedirect("state");
529
- n != null ? n(c) : window.location.assign(c);
525
+ async loginWithRedirect(e) {
526
+ this.analyticshttpclient.sendMethodEvent(this.loginWithRedirect.name, this.clientId, d, u);
527
+ const { onRedirect: t } = e || {}, s = A.GenerateCodeVerifier();
528
+ this.cookiesManager.save({ code_verifier: s }), this.tokenProvider = this.tokenProvider.WithProofKeyForCodeExchange(s);
529
+ const r = await this.tokenProvider.GetOAuthRedirect("state");
530
+ t != null ? t(r) : window.location.assign(r);
530
531
  }
531
532
  /**
532
533
  * Authenticated the user using the url callback params
@@ -540,13 +541,13 @@ class Qt {
540
541
  * handleCallback('https://example.com?code=code....')
541
542
  * // Will try to log in the user with the url assign by the developer
542
543
  */
543
- async handleCallback(t = window.location.href) {
544
- const n = this.cookiesManager.get();
545
- if (n == null || (n == null ? void 0 : n.code_verifier) == null)
546
- throw new Ht("Code verifier not available");
547
- const o = Vt(t), c = qe(t), S = c.get("identity_provider") ?? "", _ = c.get("state") ?? "";
548
- return await this.tokenProvider.ValidateQuery(o), await this.generateToken(S), {
549
- authState: _
544
+ async handleCallback(e = window.location.href) {
545
+ const t = this.cookiesManager.get();
546
+ if (t == null || (t == null ? void 0 : t.code_verifier) == null)
547
+ throw new ke("Code verifier not available");
548
+ const s = he(e), r = V(e), l = r.get("identity_provider") ?? "", c = r.get("state") ?? "";
549
+ return await this.tokenProvider.ValidateQuery(s), await this.generateToken(l), {
550
+ authState: c
550
551
  };
551
552
  }
552
553
  /**
@@ -554,33 +555,33 @@ class Qt {
554
555
  * @param {string} identityProvider - Type of identity provider used
555
556
  * @return {Promise<void>} Empty promise
556
557
  */
557
- async generateToken(t) {
558
- var R, f;
559
- const n = await this.tokenProvider.RetrieveToken(), o = await this.tokenProvider.RetrieveRefreshToken(), c = await this.tokenProvider.RetrieveIdToken(), S = await this.tokenProvider.RetrieveTokenExpiry(), w = new Date(S).getTime(), v = (f = (R = this.tokenProvider) == null ? void 0 : R._scopes) == null ? void 0 : f.join(" ");
558
+ async generateToken(e) {
559
+ var S, n;
560
+ const t = await this.tokenProvider.RetrieveToken(), s = await this.tokenProvider.RetrieveRefreshToken(), r = await this.tokenProvider.RetrieveIdToken(), l = await this.tokenProvider.RetrieveTokenExpiry(), k = new Date(l).getTime(), y = (n = (S = this.tokenProvider) == null ? void 0 : S._scopes) == null ? void 0 : n.join(" ");
560
561
  await this.cacheManager.setToken({
561
- scope: v,
562
+ scope: y,
562
563
  state: "",
563
564
  session_state: "",
564
- identity_provider: t,
565
+ identity_provider: e,
565
566
  token_type: "bearer",
566
- access_token: n,
567
- refresh_token: o,
568
- id_token: c,
569
- expires_at: w
567
+ access_token: t,
568
+ refresh_token: s,
569
+ id_token: r,
570
+ expires_at: k
570
571
  });
571
- const P = It(c), T = Gt(P);
572
- await this.cacheManager.setUser(T), await this.reloadCodeVerifier();
572
+ const m = X(r), E = ue(m);
573
+ await this.cacheManager.setUser(E), await this.reloadCodeVerifier();
573
574
  }
574
575
  async reloadCodeVerifier() {
575
- const t = await this.tokenProvider.RetrieveCodeVerifier();
576
- this.cookiesManager.save({ code_verifier: t }), this.tokenProvider = this.tokenProvider.WithProofKeyForCodeExchange(t);
576
+ const e = await this.tokenProvider.RetrieveCodeVerifier();
577
+ this.cookiesManager.save({ code_verifier: e }), this.tokenProvider = this.tokenProvider.WithProofKeyForCodeExchange(e);
577
578
  }
578
579
  /**
579
580
  * Return the user stored in cache
580
581
  * @return {Promise<TIDUser | undefined>} User in cache
581
582
  */
582
583
  async getUser() {
583
- return this.analyticshttpclient.sendMethodEvent(this.getUser.name, this.clientId, O, I), await this.cacheManager.getUser();
584
+ return this.analyticshttpclient.sendMethodEvent(this.getUser.name, this.clientId, d, u), await this.cacheManager.getUser();
584
585
  }
585
586
  /**
586
587
  * Gets the access token from cache. If the token already expired,
@@ -590,20 +591,20 @@ class Qt {
590
591
  * @throws {TokenExpiredException} Will throw an exception if the user token expired
591
592
  */
592
593
  async getAccessTokenSilently() {
593
- this.analyticshttpclient.sendMethodEvent(this.getAccessTokenSilently.name, this.clientId, O, I);
594
- let t = await this.cacheManager.getToken();
595
- if (t == null)
596
- throw this.analyticshttpclient.sendExceptionEvent(this.getAccessTokenSilently.name, "No token available", this.clientId, O, I), new Ve("No token available");
597
- const n = new Date((/* @__PURE__ */ new Date()).getTime() + Ne);
598
- if ((t == null ? void 0 : t.expires_at) == null || (t == null ? void 0 : t.expires_at) < n.getTime()) {
594
+ this.analyticshttpclient.sendMethodEvent(this.getAccessTokenSilently.name, this.clientId, d, u);
595
+ let e = await this.cacheManager.getToken();
596
+ if (e == null)
597
+ throw this.analyticshttpclient.sendExceptionEvent(this.getAccessTokenSilently.name, "No token available", this.clientId, d, u), new L("No token available");
598
+ const t = new Date((/* @__PURE__ */ new Date()).getTime() + x);
599
+ if ((e == null ? void 0 : e.expires_at) == null || (e == null ? void 0 : e.expires_at) < t.getTime()) {
599
600
  try {
600
601
  await this.tokenProvider.RetrieveToken();
601
- } catch (o) {
602
- throw this.analyticshttpclient.sendExceptionEvent(this.getAccessTokenSilently.name, o.message, this.clientId, O, I), new $e(o.message);
602
+ } catch (s) {
603
+ throw this.analyticshttpclient.sendExceptionEvent(this.getAccessTokenSilently.name, s.message, this.clientId, d, u), new M(s.message);
603
604
  }
604
- await this.generateToken((t == null ? void 0 : t.identity_provider) ?? ""), t = await this.cacheManager.getToken();
605
+ await this.generateToken((e == null ? void 0 : e.identity_provider) ?? ""), e = await this.cacheManager.getToken();
605
606
  }
606
- return (t == null ? void 0 : t.access_token) || "";
607
+ return (e == null ? void 0 : e.access_token) || "";
607
608
  }
608
609
  /**
609
610
  * Retrieves token details from the cache, including the access token, ID token, and expiration time.
@@ -613,23 +614,23 @@ class Qt {
613
614
  * @throws {TokenExpiredException} Will throw an exception if the user token expired
614
615
  */
615
616
  async getTokens() {
616
- this.analyticshttpclient.sendMethodEvent(this.getTokens.name, this.clientId, O, I);
617
- let t = await this.cacheManager.getToken();
618
- if (t == null)
619
- throw this.analyticshttpclient.sendExceptionEvent(this.getTokens.name, "No token available", this.clientId, O, I), new Ve("No token available");
620
- const n = new Date((/* @__PURE__ */ new Date()).getTime() + Ne);
621
- if ((t == null ? void 0 : t.expires_at) == null || (t == null ? void 0 : t.expires_at) < n.getTime()) {
617
+ this.analyticshttpclient.sendMethodEvent(this.getTokens.name, this.clientId, d, u);
618
+ let e = await this.cacheManager.getToken();
619
+ if (e == null)
620
+ throw this.analyticshttpclient.sendExceptionEvent(this.getTokens.name, "No token available", this.clientId, d, u), new L("No token available");
621
+ const t = new Date((/* @__PURE__ */ new Date()).getTime() + x);
622
+ if ((e == null ? void 0 : e.expires_at) == null || (e == null ? void 0 : e.expires_at) < t.getTime()) {
622
623
  try {
623
624
  await this.tokenProvider.RetrieveToken();
624
- } catch (o) {
625
- throw this.analyticshttpclient.sendExceptionEvent(this.getTokens.name, o.message, this.clientId, O, I), new $e(o.message);
625
+ } catch (s) {
626
+ throw this.analyticshttpclient.sendExceptionEvent(this.getTokens.name, s.message, this.clientId, d, u), new M(s.message);
626
627
  }
627
- await this.generateToken((t == null ? void 0 : t.identity_provider) ?? ""), t = await this.cacheManager.getToken();
628
+ await this.generateToken((e == null ? void 0 : e.identity_provider) ?? ""), e = await this.cacheManager.getToken();
628
629
  }
629
630
  return {
630
- access_token: (t == null ? void 0 : t.access_token) || "",
631
- expires_at: (t == null ? void 0 : t.expires_at) || 0,
632
- id_token: (t == null ? void 0 : t.id_token) || ""
631
+ access_token: (e == null ? void 0 : e.access_token) || "",
632
+ expires_at: (e == null ? void 0 : e.expires_at) || 0,
633
+ id_token: (e == null ? void 0 : e.id_token) || ""
633
634
  };
634
635
  }
635
636
  /**
@@ -644,14 +645,14 @@ class Qt {
644
645
  * // Redirect calls onRedirect with the log-out url for TID
645
646
  * // So it can be handled by the developer
646
647
  */
647
- async logout(t) {
648
- this.analyticshttpclient.sendMethodEvent(this.logout.name, this.clientId, O, I);
649
- const { onRedirect: n, disabledAutoRedirect: o } = t || {};
648
+ async logout(e) {
649
+ this.analyticshttpclient.sendMethodEvent(this.logout.name, this.clientId, d, u);
650
+ const { onRedirect: t, disabledAutoRedirect: s } = e || {};
650
651
  this.cacheManager && await this.cacheManager.clear(), this.cookiesManager && this.cookiesManager.clear();
651
- const c = await this.tokenProvider.GetOAuthLogoutRedirect("state");
652
- if (n != null)
653
- return n(c);
654
- o || window.location.assign(c);
652
+ const r = await this.tokenProvider.GetOAuthLogoutRedirect("state");
653
+ if (t != null)
654
+ return t(r);
655
+ s || window.location.assign(r);
655
656
  }
656
657
  /**
657
658
  * Check if the user still has a valid session
@@ -677,18 +678,18 @@ class Qt {
677
678
  * @return {Promise<void>} Empty promise
678
679
  */
679
680
  async loadCacheSessionIntoSDK() {
680
- const t = await this.cacheManager.getToken();
681
- if (t == null)
681
+ const e = await this.cacheManager.getToken();
682
+ if (e == null)
682
683
  return;
683
- const n = t.access_token, o = t.refresh_token || "", c = t.id_token, S = t.expires_at;
684
- this.tokenProvider = this.tokenProvider.WithAccessToken(n, S).WithRefreshToken(o).WithIdToken(c);
684
+ const t = e.access_token, s = e.refresh_token || "", r = e.id_token, l = e.expires_at;
685
+ this.tokenProvider = this.tokenProvider.WithAccessToken(t, l).WithRefreshToken(s).WithIdToken(r);
685
686
  }
686
687
  /**
687
688
  * Get a http bearer token client to use it for another SDK (Ex: Processing framework)
688
689
  * @return {any} - BearerTokenHttpClientProvider
689
690
  */
690
- getBearerTokenHttpClient(t) {
691
- return new Ot(this.tokenProvider, t);
691
+ getBearerTokenHttpClient(e) {
692
+ return new Q(this.tokenProvider, e);
692
693
  }
693
694
  /**
694
695
  * Get the redirect url to TID
@@ -698,796 +699,168 @@ class Qt {
698
699
  return this.redirectUrl;
699
700
  }
700
701
  }
701
- const fe = xt(null), Xe = () => ze(fe) ?? {};
702
- var de = { exports: {} }, $ = {};
703
- /**
704
- * @license React
705
- * react-jsx-runtime.production.min.js
706
- *
707
- * Copyright (c) Facebook, Inc. and its affiliates.
708
- *
709
- * This source code is licensed under the MIT license found in the
710
- * LICENSE file in the root directory of this source tree.
711
- */
712
- var Ye;
713
- function Zt() {
714
- if (Ye)
715
- return $;
716
- Ye = 1;
717
- var a = Be, t = Symbol.for("react.element"), n = Symbol.for("react.fragment"), o = Object.prototype.hasOwnProperty, c = a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, S = { key: !0, ref: !0, __self: !0, __source: !0 };
718
- function _(w, v, P) {
719
- var T, R = {}, f = null, D = null;
720
- P !== void 0 && (f = "" + P), v.key !== void 0 && (f = "" + v.key), v.ref !== void 0 && (D = v.ref);
721
- for (T in v)
722
- o.call(v, T) && !S.hasOwnProperty(T) && (R[T] = v[T]);
723
- if (w && w.defaultProps)
724
- for (T in v = w.defaultProps, v)
725
- R[T] === void 0 && (R[T] = v[T]);
726
- return { $$typeof: t, type: w, key: f, ref: D, props: R, _owner: c.current };
727
- }
728
- return $.Fragment = n, $.jsx = _, $.jsxs = _, $;
729
- }
730
- var V = {};
731
- /**
732
- * @license React
733
- * react-jsx-runtime.development.js
734
- *
735
- * Copyright (c) Facebook, Inc. and its affiliates.
736
- *
737
- * This source code is licensed under the MIT license found in the
738
- * LICENSE file in the root directory of this source tree.
739
- */
740
- var Ge;
741
- function er() {
742
- return Ge || (Ge = 1, process.env.NODE_ENV !== "production" && function() {
743
- var a = Be, t = Symbol.for("react.element"), n = Symbol.for("react.portal"), o = Symbol.for("react.fragment"), c = Symbol.for("react.strict_mode"), S = Symbol.for("react.profiler"), _ = Symbol.for("react.provider"), w = Symbol.for("react.context"), v = Symbol.for("react.forward_ref"), P = Symbol.for("react.suspense"), T = Symbol.for("react.suspense_list"), R = Symbol.for("react.memo"), f = Symbol.for("react.lazy"), D = Symbol.for("react.offscreen"), x = Symbol.iterator, Y = "@@iterator";
744
- function ee(e) {
745
- if (e === null || typeof e != "object")
746
- return null;
747
- var r = x && e[x] || e[Y];
748
- return typeof r == "function" ? r : null;
749
- }
750
- var A = a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
751
- function E(e) {
752
- {
753
- for (var r = arguments.length, i = new Array(r > 1 ? r - 1 : 0), s = 1; s < r; s++)
754
- i[s - 1] = arguments[s];
755
- G("error", e, i);
756
- }
757
- }
758
- function G(e, r, i) {
759
- {
760
- var s = A.ReactDebugCurrentFrame, d = s.getStackAddendum();
761
- d !== "" && (r += "%s", i = i.concat([d]));
762
- var h = i.map(function(u) {
763
- return String(u);
764
- });
765
- h.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, h);
766
- }
767
- }
768
- var J = !1, B = !1, te = !1, g = !1, b = !1, z;
769
- z = Symbol.for("react.module.reference");
770
- function Qe(e) {
771
- return !!(typeof e == "string" || typeof e == "function" || e === o || e === S || b || e === c || e === P || e === T || g || e === D || J || B || te || typeof e == "object" && e !== null && (e.$$typeof === f || e.$$typeof === R || e.$$typeof === _ || e.$$typeof === w || e.$$typeof === v || // This needs to include all possible module reference object
772
- // types supported by any Flight configuration anywhere since
773
- // we don't know which Flight build this will end up being used
774
- // with.
775
- e.$$typeof === z || e.getModuleId !== void 0));
776
- }
777
- function Ze(e, r, i) {
778
- var s = e.displayName;
779
- if (s)
780
- return s;
781
- var d = r.displayName || r.name || "";
782
- return d !== "" ? i + "(" + d + ")" : i;
783
- }
784
- function ve(e) {
785
- return e.displayName || "Context";
786
- }
787
- function K(e) {
788
- if (e == null)
789
- return null;
790
- if (typeof e.tag == "number" && E("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
791
- return e.displayName || e.name || null;
792
- if (typeof e == "string")
793
- return e;
794
- switch (e) {
795
- case o:
796
- return "Fragment";
797
- case n:
798
- return "Portal";
799
- case S:
800
- return "Profiler";
801
- case c:
802
- return "StrictMode";
803
- case P:
804
- return "Suspense";
805
- case T:
806
- return "SuspenseList";
807
- }
808
- if (typeof e == "object")
809
- switch (e.$$typeof) {
810
- case w:
811
- var r = e;
812
- return ve(r) + ".Consumer";
813
- case _:
814
- var i = e;
815
- return ve(i._context) + ".Provider";
816
- case v:
817
- return Ze(e, e.render, "ForwardRef");
818
- case R:
819
- var s = e.displayName || null;
820
- return s !== null ? s : K(e.type) || "Memo";
821
- case f: {
822
- var d = e, h = d._payload, u = d._init;
823
- try {
824
- return K(u(h));
825
- } catch {
826
- return null;
827
- }
828
- }
829
- }
830
- return null;
831
- }
832
- var M = Object.assign, F = 0, ye, pe, me, Ee, _e, Te, Se;
833
- function ke() {
834
- }
835
- ke.__reactDisabledLog = !0;
836
- function et() {
837
- {
838
- if (F === 0) {
839
- ye = console.log, pe = console.info, me = console.warn, Ee = console.error, _e = console.group, Te = console.groupCollapsed, Se = console.groupEnd;
840
- var e = {
841
- configurable: !0,
842
- enumerable: !0,
843
- value: ke,
844
- writable: !0
845
- };
846
- Object.defineProperties(console, {
847
- info: e,
848
- log: e,
849
- warn: e,
850
- error: e,
851
- group: e,
852
- groupCollapsed: e,
853
- groupEnd: e
854
- });
855
- }
856
- F++;
857
- }
858
- }
859
- function tt() {
860
- {
861
- if (F--, F === 0) {
862
- var e = {
863
- configurable: !0,
864
- enumerable: !0,
865
- writable: !0
866
- };
867
- Object.defineProperties(console, {
868
- log: M({}, e, {
869
- value: ye
870
- }),
871
- info: M({}, e, {
872
- value: pe
873
- }),
874
- warn: M({}, e, {
875
- value: me
876
- }),
877
- error: M({}, e, {
878
- value: Ee
879
- }),
880
- group: M({}, e, {
881
- value: _e
882
- }),
883
- groupCollapsed: M({}, e, {
884
- value: Te
885
- }),
886
- groupEnd: M({}, e, {
887
- value: Se
888
- })
889
- });
890
- }
891
- F < 0 && E("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
892
- }
893
- }
894
- var re = A.ReactCurrentDispatcher, ne;
895
- function H(e, r, i) {
896
- {
897
- if (ne === void 0)
898
- try {
899
- throw Error();
900
- } catch (d) {
901
- var s = d.stack.trim().match(/\n( *(at )?)/);
902
- ne = s && s[1] || "";
903
- }
904
- return `
905
- ` + ne + e;
906
- }
907
- }
908
- var ie = !1, q;
909
- {
910
- var rt = typeof WeakMap == "function" ? WeakMap : Map;
911
- q = new rt();
912
- }
913
- function Re(e, r) {
914
- if (!e || ie)
915
- return "";
916
- {
917
- var i = q.get(e);
918
- if (i !== void 0)
919
- return i;
920
- }
921
- var s;
922
- ie = !0;
923
- var d = Error.prepareStackTrace;
924
- Error.prepareStackTrace = void 0;
925
- var h;
926
- h = re.current, re.current = null, et();
927
- try {
928
- if (r) {
929
- var u = function() {
930
- throw Error();
931
- };
932
- if (Object.defineProperty(u.prototype, "props", {
933
- set: function() {
934
- throw Error();
935
- }
936
- }), typeof Reflect == "object" && Reflect.construct) {
937
- try {
938
- Reflect.construct(u, []);
939
- } catch (U) {
940
- s = U;
941
- }
942
- Reflect.construct(e, [], u);
943
- } else {
944
- try {
945
- u.call();
946
- } catch (U) {
947
- s = U;
948
- }
949
- e.call(u.prototype);
950
- }
951
- } else {
952
- try {
953
- throw Error();
954
- } catch (U) {
955
- s = U;
956
- }
957
- e();
958
- }
959
- } catch (U) {
960
- if (U && s && typeof U.stack == "string") {
961
- for (var l = U.stack.split(`
962
- `), k = s.stack.split(`
963
- `), y = l.length - 1, m = k.length - 1; y >= 1 && m >= 0 && l[y] !== k[m]; )
964
- m--;
965
- for (; y >= 1 && m >= 0; y--, m--)
966
- if (l[y] !== k[m]) {
967
- if (y !== 1 || m !== 1)
968
- do
969
- if (y--, m--, m < 0 || l[y] !== k[m]) {
970
- var C = `
971
- ` + l[y].replace(" at new ", " at ");
972
- return e.displayName && C.includes("<anonymous>") && (C = C.replace("<anonymous>", e.displayName)), typeof e == "function" && q.set(e, C), C;
973
- }
974
- while (y >= 1 && m >= 0);
975
- break;
976
- }
977
- }
978
- } finally {
979
- ie = !1, re.current = h, tt(), Error.prepareStackTrace = d;
980
- }
981
- var L = e ? e.displayName || e.name : "", je = L ? H(L) : "";
982
- return typeof e == "function" && q.set(e, je), je;
983
- }
984
- function nt(e, r, i) {
985
- return Re(e, !1);
986
- }
987
- function it(e) {
988
- var r = e.prototype;
989
- return !!(r && r.isReactComponent);
990
- }
991
- function X(e, r, i) {
992
- if (e == null)
993
- return "";
994
- if (typeof e == "function")
995
- return Re(e, it(e));
996
- if (typeof e == "string")
997
- return H(e);
998
- switch (e) {
999
- case P:
1000
- return H("Suspense");
1001
- case T:
1002
- return H("SuspenseList");
1003
- }
1004
- if (typeof e == "object")
1005
- switch (e.$$typeof) {
1006
- case v:
1007
- return nt(e.render);
1008
- case R:
1009
- return X(e.type, r, i);
1010
- case f: {
1011
- var s = e, d = s._payload, h = s._init;
1012
- try {
1013
- return X(h(d), r, i);
1014
- } catch {
1015
- }
1016
- }
1017
- }
1018
- return "";
1019
- }
1020
- var Q = Object.prototype.hasOwnProperty, we = {}, be = A.ReactDebugCurrentFrame;
1021
- function Z(e) {
1022
- if (e) {
1023
- var r = e._owner, i = X(e.type, e._source, r ? r.type : null);
1024
- be.setExtraStackFrame(i);
1025
- } else
1026
- be.setExtraStackFrame(null);
1027
- }
1028
- function at(e, r, i, s, d) {
1029
- {
1030
- var h = Function.call.bind(Q);
1031
- for (var u in e)
1032
- if (h(e, u)) {
1033
- var l = void 0;
1034
- try {
1035
- if (typeof e[u] != "function") {
1036
- var k = Error((s || "React class") + ": " + i + " type `" + u + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[u] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
1037
- throw k.name = "Invariant Violation", k;
1038
- }
1039
- l = e[u](r, u, s, i, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
1040
- } catch (y) {
1041
- l = y;
1042
- }
1043
- l && !(l instanceof Error) && (Z(d), E("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", s || "React class", i, u, typeof l), Z(null)), l instanceof Error && !(l.message in we) && (we[l.message] = !0, Z(d), E("Failed %s type: %s", i, l.message), Z(null));
1044
- }
1045
- }
1046
- }
1047
- var ot = Array.isArray;
1048
- function ae(e) {
1049
- return ot(e);
1050
- }
1051
- function st(e) {
1052
- {
1053
- var r = typeof Symbol == "function" && Symbol.toStringTag, i = r && e[Symbol.toStringTag] || e.constructor.name || "Object";
1054
- return i;
1055
- }
1056
- }
1057
- function ct(e) {
1058
- try {
1059
- return Ce(e), !1;
1060
- } catch {
1061
- return !0;
1062
- }
1063
- }
1064
- function Ce(e) {
1065
- return "" + e;
1066
- }
1067
- function Pe(e) {
1068
- if (ct(e))
1069
- return E("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", st(e)), Ce(e);
1070
- }
1071
- var N = A.ReactCurrentOwner, lt = {
1072
- key: !0,
1073
- ref: !0,
1074
- __self: !0,
1075
- __source: !0
1076
- }, Oe, Ie, oe;
1077
- oe = {};
1078
- function ut(e) {
1079
- if (Q.call(e, "ref")) {
1080
- var r = Object.getOwnPropertyDescriptor(e, "ref").get;
1081
- if (r && r.isReactWarning)
1082
- return !1;
1083
- }
1084
- return e.ref !== void 0;
1085
- }
1086
- function ft(e) {
1087
- if (Q.call(e, "key")) {
1088
- var r = Object.getOwnPropertyDescriptor(e, "key").get;
1089
- if (r && r.isReactWarning)
1090
- return !1;
1091
- }
1092
- return e.key !== void 0;
1093
- }
1094
- function dt(e, r) {
1095
- if (typeof e.ref == "string" && N.current && r && N.current.stateNode !== r) {
1096
- var i = K(N.current.type);
1097
- oe[i] || (E('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', K(N.current.type), e.ref), oe[i] = !0);
1098
- }
1099
- }
1100
- function ht(e, r) {
1101
- {
1102
- var i = function() {
1103
- Oe || (Oe = !0, E("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
1104
- };
1105
- i.isReactWarning = !0, Object.defineProperty(e, "key", {
1106
- get: i,
1107
- configurable: !0
1108
- });
1109
- }
1110
- }
1111
- function gt(e, r) {
1112
- {
1113
- var i = function() {
1114
- Ie || (Ie = !0, E("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
1115
- };
1116
- i.isReactWarning = !0, Object.defineProperty(e, "ref", {
1117
- get: i,
1118
- configurable: !0
1119
- });
1120
- }
1121
- }
1122
- var vt = function(e, r, i, s, d, h, u) {
1123
- var l = {
1124
- // This tag allows us to uniquely identify this as a React Element
1125
- $$typeof: t,
1126
- // Built-in properties that belong on the element
1127
- type: e,
1128
- key: r,
1129
- ref: i,
1130
- props: u,
1131
- // Record the component responsible for creating this element.
1132
- _owner: h
1133
- };
1134
- return l._store = {}, Object.defineProperty(l._store, "validated", {
1135
- configurable: !1,
1136
- enumerable: !1,
1137
- writable: !0,
1138
- value: !1
1139
- }), Object.defineProperty(l, "_self", {
1140
- configurable: !1,
1141
- enumerable: !1,
1142
- writable: !1,
1143
- value: s
1144
- }), Object.defineProperty(l, "_source", {
1145
- configurable: !1,
1146
- enumerable: !1,
1147
- writable: !1,
1148
- value: d
1149
- }), Object.freeze && (Object.freeze(l.props), Object.freeze(l)), l;
1150
- };
1151
- function yt(e, r, i, s, d) {
1152
- {
1153
- var h, u = {}, l = null, k = null;
1154
- i !== void 0 && (Pe(i), l = "" + i), ft(r) && (Pe(r.key), l = "" + r.key), ut(r) && (k = r.ref, dt(r, d));
1155
- for (h in r)
1156
- Q.call(r, h) && !lt.hasOwnProperty(h) && (u[h] = r[h]);
1157
- if (e && e.defaultProps) {
1158
- var y = e.defaultProps;
1159
- for (h in y)
1160
- u[h] === void 0 && (u[h] = y[h]);
1161
- }
1162
- if (l || k) {
1163
- var m = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
1164
- l && ht(u, m), k && gt(u, m);
1165
- }
1166
- return vt(e, l, k, d, s, N.current, u);
1167
- }
1168
- }
1169
- var se = A.ReactCurrentOwner, xe = A.ReactDebugCurrentFrame;
1170
- function j(e) {
1171
- if (e) {
1172
- var r = e._owner, i = X(e.type, e._source, r ? r.type : null);
1173
- xe.setExtraStackFrame(i);
1174
- } else
1175
- xe.setExtraStackFrame(null);
1176
- }
1177
- var ce;
1178
- ce = !1;
1179
- function le(e) {
1180
- return typeof e == "object" && e !== null && e.$$typeof === t;
1181
- }
1182
- function Ae() {
1183
- {
1184
- if (se.current) {
1185
- var e = K(se.current.type);
1186
- if (e)
1187
- return `
1188
-
1189
- Check the render method of \`` + e + "`.";
1190
- }
1191
- return "";
1192
- }
1193
- }
1194
- function pt(e) {
1195
- {
1196
- if (e !== void 0) {
1197
- var r = e.fileName.replace(/^.*[\\\/]/, ""), i = e.lineNumber;
1198
- return `
1199
-
1200
- Check your code at ` + r + ":" + i + ".";
1201
- }
1202
- return "";
1203
- }
1204
- }
1205
- var Ke = {};
1206
- function mt(e) {
1207
- {
1208
- var r = Ae();
1209
- if (!r) {
1210
- var i = typeof e == "string" ? e : e.displayName || e.name;
1211
- i && (r = `
1212
-
1213
- Check the top-level render call using <` + i + ">.");
1214
- }
1215
- return r;
1216
- }
1217
- }
1218
- function Ue(e, r) {
1219
- {
1220
- if (!e._store || e._store.validated || e.key != null)
1221
- return;
1222
- e._store.validated = !0;
1223
- var i = mt(r);
1224
- if (Ke[i])
1225
- return;
1226
- Ke[i] = !0;
1227
- var s = "";
1228
- e && e._owner && e._owner !== se.current && (s = " It was passed a child from " + K(e._owner.type) + "."), j(e), E('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', i, s), j(null);
1229
- }
1230
- }
1231
- function De(e, r) {
1232
- {
1233
- if (typeof e != "object")
1234
- return;
1235
- if (ae(e))
1236
- for (var i = 0; i < e.length; i++) {
1237
- var s = e[i];
1238
- le(s) && Ue(s, r);
1239
- }
1240
- else if (le(e))
1241
- e._store && (e._store.validated = !0);
1242
- else if (e) {
1243
- var d = ee(e);
1244
- if (typeof d == "function" && d !== e.entries)
1245
- for (var h = d.call(e), u; !(u = h.next()).done; )
1246
- le(u.value) && Ue(u.value, r);
1247
- }
1248
- }
1249
- }
1250
- function Et(e) {
1251
- {
1252
- var r = e.type;
1253
- if (r == null || typeof r == "string")
1254
- return;
1255
- var i;
1256
- if (typeof r == "function")
1257
- i = r.propTypes;
1258
- else if (typeof r == "object" && (r.$$typeof === v || // Note: Memo only checks outer props here.
1259
- // Inner props are checked in the reconciler.
1260
- r.$$typeof === R))
1261
- i = r.propTypes;
1262
- else
1263
- return;
1264
- if (i) {
1265
- var s = K(r);
1266
- at(i, e.props, "prop", s, e);
1267
- } else if (r.PropTypes !== void 0 && !ce) {
1268
- ce = !0;
1269
- var d = K(r);
1270
- E("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", d || "Unknown");
1271
- }
1272
- typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && E("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
1273
- }
1274
- }
1275
- function _t(e) {
1276
- {
1277
- for (var r = Object.keys(e.props), i = 0; i < r.length; i++) {
1278
- var s = r[i];
1279
- if (s !== "children" && s !== "key") {
1280
- j(e), E("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", s), j(null);
1281
- break;
1282
- }
1283
- }
1284
- e.ref !== null && (j(e), E("Invalid attribute `ref` supplied to `React.Fragment`."), j(null));
1285
- }
1286
- }
1287
- function Me(e, r, i, s, d, h) {
1288
- {
1289
- var u = Qe(e);
1290
- if (!u) {
1291
- var l = "";
1292
- (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (l += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
1293
- var k = pt(d);
1294
- k ? l += k : l += Ae();
1295
- var y;
1296
- e === null ? y = "null" : ae(e) ? y = "array" : e !== void 0 && e.$$typeof === t ? (y = "<" + (K(e.type) || "Unknown") + " />", l = " Did you accidentally export a JSX literal instead of a component?") : y = typeof e, E("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", y, l);
1297
- }
1298
- var m = yt(e, r, i, d, h);
1299
- if (m == null)
1300
- return m;
1301
- if (u) {
1302
- var C = r.children;
1303
- if (C !== void 0)
1304
- if (s)
1305
- if (ae(C)) {
1306
- for (var L = 0; L < C.length; L++)
1307
- De(C[L], e);
1308
- Object.freeze && Object.freeze(C);
1309
- } else
1310
- E("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
1311
- else
1312
- De(C, e);
1313
- }
1314
- return e === o ? _t(m) : Et(m), m;
1315
- }
1316
- }
1317
- function Tt(e, r, i) {
1318
- return Me(e, r, i, !0);
1319
- }
1320
- function St(e, r, i) {
1321
- return Me(e, r, i, !1);
1322
- }
1323
- var kt = St, Rt = Tt;
1324
- V.Fragment = o, V.jsx = kt, V.jsxs = Rt;
1325
- }()), V;
1326
- }
1327
- process.env.NODE_ENV === "production" ? de.exports = Zt() : de.exports = er();
1328
- var he = de.exports;
1329
- const tr = (a, t) => {
1330
- switch (t.type) {
702
+ const v = q(null), $ = () => N(v) ?? {}, ve = (i, e) => {
703
+ switch (e.type) {
1331
704
  case "INIT":
1332
705
  return {
1333
- ...a,
706
+ ...i,
1334
707
  isLoading: !1,
1335
- isAuthenticated: t.user != null,
1336
- user: t.user,
708
+ isAuthenticated: e.user != null,
709
+ user: e.user,
1337
710
  error: void 0
1338
711
  };
1339
712
  case "GET_TOKENS_COMPLETE":
1340
713
  case "HANDLE_CALLBACK_COMPLETE":
1341
714
  case "GET_ACCESS_TOKEN_COMPLETE":
1342
715
  return {
1343
- ...a,
716
+ ...i,
1344
717
  isLoading: !1,
1345
- isAuthenticated: t.user != null,
1346
- user: t.user,
718
+ isAuthenticated: e.user != null,
719
+ user: e.user,
1347
720
  error: void 0
1348
721
  };
1349
722
  case "LOGOUT":
1350
723
  return {
1351
- ...a,
724
+ ...i,
1352
725
  isAuthenticated: !1,
1353
726
  user: void 0
1354
727
  };
1355
728
  case "ERROR":
1356
729
  return {
1357
- ...a,
730
+ ...i,
1358
731
  isLoading: !1,
1359
- error: t.error
732
+ error: e.error
1360
733
  };
1361
734
  }
1362
- }, rr = {
735
+ }, Te = {
1363
736
  isLoading: !0,
1364
737
  isAuthenticated: !1
1365
- }, Je = (a) => {
1366
- if (a == null || Object.keys(a).length <= 0)
738
+ }, D = (i) => {
739
+ if (i == null || Object.keys(i).length <= 0)
1367
740
  return !0;
1368
- const t = Object.keys(a);
1369
- for (const n of t)
1370
- if (a[n] != null && a[n] !== "")
741
+ const e = Object.keys(i);
742
+ for (const t of e)
743
+ if (i[t] != null && i[t] !== "")
1371
744
  return !1;
1372
745
  return !0;
1373
- }, nr = (a) => {
1374
- const t = Je(a.config), n = Je(a.persistentOptions);
1375
- return !t || !n;
1376
- }, ir = (a) => {
746
+ }, Ee = (i) => {
747
+ const e = D(i.config), t = D(i.persistentOptions);
748
+ return !e || !t;
749
+ }, we = (i) => {
1377
750
  const {
1378
- children: t,
1379
- configurationEndpoint: n,
1380
- clientId: o,
1381
- redirectUrl: c,
1382
- logoutRedirectUrl: S,
1383
- scopes: _,
1384
- persistentStore: w,
1385
- onRedirectCallback: v,
1386
- checkRedirectUrlMatch: P
1387
- } = a;
1388
- if (ze(fe) != null)
751
+ children: e,
752
+ configurationEndpoint: t,
753
+ clientId: s,
754
+ redirectUrl: r,
755
+ logoutRedirectUrl: l,
756
+ scopes: c,
757
+ persistentStore: k,
758
+ onRedirectCallback: y,
759
+ checkRedirectUrlMatch: m
760
+ } = i;
761
+ if (N(v) != null)
1389
762
  throw new Error("TID Provider already defined");
1390
- const R = {
763
+ const S = {
1391
764
  config: {
1392
- configurationEndpoint: n ?? "",
1393
- clientId: o ?? "",
1394
- redirectUrl: c ?? "",
1395
- logoutRedirectUrl: S ?? "",
1396
- scopes: _ ?? [""]
765
+ configurationEndpoint: t ?? "",
766
+ clientId: s ?? "",
767
+ redirectUrl: r ?? "",
768
+ logoutRedirectUrl: l ?? "",
769
+ scopes: c ?? [""]
1397
770
  },
1398
771
  persistentOptions: {
1399
- persistentStore: w ?? "in-memory"
772
+ persistentStore: k ?? "in-memory"
1400
773
  }
1401
- }, [f] = At(a.tidClient ?? new Qt(R)), [D, x] = Kt(tr, rr), Y = Ut(!1), ee = Fe(
1402
- () => P ? f.getRedirectUrl() : void 0,
1403
- [P, f]
774
+ }, [n] = Z(i.tidClient ?? new pe(S)), [w, g] = j(ve, Te), _ = ee(!1), G = R(
775
+ () => m ? n.getRedirectUrl() : void 0,
776
+ [m, n]
1404
777
  );
1405
- He(() => {
1406
- Y.current || (a.tidClient != null && nr({
778
+ b(() => {
779
+ _.current || (i.tidClient != null && Ee({
1407
780
  config: {
1408
- configurationEndpoint: n,
1409
- clientId: o,
1410
- redirectUrl: c,
1411
- logoutRedirectUrl: S,
1412
- scopes: _
781
+ configurationEndpoint: t,
782
+ clientId: s,
783
+ redirectUrl: r,
784
+ logoutRedirectUrl: l,
785
+ scopes: c
1413
786
  },
1414
787
  persistentOptions: {
1415
- persistentStore: w
788
+ persistentStore: k
1416
789
  }
1417
790
  }) && console.warn(
1418
791
  "When TID client is pass as prop, any client configuration property sent directly to the TID Provider component will be ignored"
1419
- ), Y.current = !0, (async () => {
792
+ ), _.current = !0, (async () => {
1420
793
  try {
1421
- let g;
1422
- if (Yt(void 0, ee)) {
1423
- const { authState: b } = await f.handleCallback();
1424
- g = await f.getUser(), v != null && v(b);
794
+ let o;
795
+ if (de(void 0, G)) {
796
+ const { authState: h } = await n.handleCallback();
797
+ o = await n.getUser(), y != null && y(h);
1425
798
  } else
1426
- await f.loadUserSession(), g = await f.getUser();
1427
- x({ type: "INIT", user: g });
1428
- } catch (g) {
1429
- let b = g;
1430
- typeof g == "string" && (b = new Error(g)), x({ type: "ERROR", error: b });
799
+ await n.loadUserSession(), o = await n.getUser();
800
+ g({ type: "INIT", user: o });
801
+ } catch (o) {
802
+ let h = o;
803
+ typeof o == "string" && (h = new Error(o)), g({ type: "ERROR", error: h });
1431
804
  }
1432
805
  })());
1433
- }, [f, v]);
1434
- const A = W(async () => {
1435
- const g = await f.getAccessTokenSilently(), b = await f.getUser();
1436
- return x({
806
+ }, [n, y]);
807
+ const I = f(async () => {
808
+ const o = await n.getAccessTokenSilently(), h = await n.getUser();
809
+ return g({
1437
810
  type: "GET_ACCESS_TOKEN_COMPLETE",
1438
- user: b
1439
- }), g;
1440
- }, [f]), E = W(async () => {
1441
- const g = await f.getTokens(), b = await f.getUser();
1442
- return x({
811
+ user: h
812
+ }), o;
813
+ }, [n]), K = f(async () => {
814
+ const o = await n.getTokens(), h = await n.getUser();
815
+ return g({
1443
816
  type: "GET_TOKENS_COMPLETE",
1444
- user: b
1445
- }), g;
1446
- }, [f]), G = W(
1447
- async (g) => {
1448
- await f.loginWithRedirect(g);
817
+ user: h
818
+ }), o;
819
+ }, [n]), C = f(
820
+ async (o) => {
821
+ await n.loginWithRedirect(o);
1449
822
  },
1450
- [f]
1451
- ), J = W(
1452
- async (g) => {
1453
- await f.logout(g), (g == null ? void 0 : g.disabledAutoRedirect) != null && g.disabledAutoRedirect && x({
823
+ [n]
824
+ ), U = f(
825
+ async (o) => {
826
+ await n.logout(o), (o == null ? void 0 : o.disabledAutoRedirect) != null && o.disabledAutoRedirect && g({
1454
827
  type: "LOGOUT"
1455
828
  });
1456
829
  },
1457
- [f]
1458
- ), B = W(
1459
- async (g) => {
1460
- const { authState: b } = await f.handleCallback(g), z = await f.getUser();
1461
- return x({
830
+ [n]
831
+ ), P = f(
832
+ async (o) => {
833
+ const { authState: h } = await n.handleCallback(o), J = await n.getUser();
834
+ return g({
1462
835
  type: "HANDLE_CALLBACK_COMPLETE",
1463
- user: z
836
+ user: J
1464
837
  }), {
1465
- authState: b
838
+ authState: h
1466
839
  };
1467
840
  },
1468
- [f]
1469
- ), te = Fe(
841
+ [n]
842
+ ), F = R(
1470
843
  () => ({
1471
- ...D,
1472
- getAccessTokenSilently: A,
1473
- getTokens: E,
1474
- loginWithRedirect: G,
1475
- handleCallback: B,
1476
- logout: J
844
+ ...w,
845
+ getAccessTokenSilently: I,
846
+ getTokens: K,
847
+ loginWithRedirect: C,
848
+ handleCallback: P,
849
+ logout: U
1477
850
  }),
1478
- [D, A, E, G, B, J]
851
+ [w, I, K, C, P, U]
1479
852
  );
1480
- return /* @__PURE__ */ he.jsx(fe.Provider, { value: te, children: t });
1481
- }, lr = Xe, ur = ir, fr = ({ renderComponent: a, loader: t }) => {
1482
- const { isAuthenticated: n, isLoading: o, loginWithRedirect: c } = Xe();
1483
- return He(() => {
1484
- !o && !n && (async () => await c())();
1485
- }, [o, n, c]), n ? a : t || /* @__PURE__ */ he.jsx(he.Fragment, {});
853
+ return /* @__PURE__ */ W(v.Provider, { value: F, children: e });
854
+ }, Pe = $, Ae = we, Re = ({ renderComponent: i, loader: e }) => {
855
+ const { isAuthenticated: t, isLoading: s, loginWithRedirect: r } = $();
856
+ return b(() => {
857
+ !s && !t && (async () => await r())();
858
+ }, [s, t, r]), t ? i : e || /* @__PURE__ */ W(te, {});
1486
859
  };
1487
860
  export {
1488
- fr as AuthenticationGuard,
1489
- Qt as TIDClient,
1490
- fe as TIDContext,
1491
- ur as TIDProvider,
1492
- lr as useAuth
861
+ Re as AuthenticationGuard,
862
+ pe as TIDClient,
863
+ v as TIDContext,
864
+ Ae as TIDProvider,
865
+ Pe as useAuth
1493
866
  };