@leancodepl/login-manager 9.7.2 → 9.7.3

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,4 +1,4 @@
1
- import { SyncTokenStorage, Token } from "./tokenStorage";
1
+ import { SyncTokenStorage, Token } from './tokenStorage';
2
2
  /**
3
3
  * Stores OAuth2 tokens in browser sessionStorage.
4
4
  *
@@ -27,3 +27,4 @@ export declare class SessionTokenStorage implements SyncTokenStorage {
27
27
  private setValue;
28
28
  private remove;
29
29
  }
30
+ //# sourceMappingURL=sessionTokenStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sessionTokenStorage.d.ts","sourceRoot":"","sources":["../../src/lib/sessionTokenStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAExD;;;;;;;;;;;;;;GAcG;AACH,qBAAa,mBAAoB,YAAW,gBAAgB;IAExD,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,SAAS;gBAFT,QAAQ,SAAU,EAClB,UAAU,SAAkB,EAC5B,SAAS,SAAoB;IAGhC,QAAQ,IAAI,KAAK,GAAG,IAAI;IAYxB,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAM9B,UAAU,IAAI,IAAI;IAMzB,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,MAAM;CAGf"}
@@ -1,5 +1,5 @@
1
- import { BaseLoginManager, LoginManager } from "./baseLoginManager";
2
- import { SyncTokenStorage } from "./tokenStorage";
1
+ import { BaseLoginManager, LoginManager } from './baseLoginManager';
2
+ import { SyncTokenStorage } from './tokenStorage';
3
3
  /**
4
4
  * Manages OAuth2 authentication with synchronous token storage.
5
5
  *
@@ -29,3 +29,4 @@ export declare class SyncLoginManager extends BaseLoginManager<SyncTokenStorage>
29
29
  isSigned(): boolean;
30
30
  getToken(): Promise<string | null>;
31
31
  }
32
+ //# sourceMappingURL=syncLoginManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syncLoginManager.d.ts","sourceRoot":"","sources":["../../src/lib/syncLoginManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAEjD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,gBAAiB,SAAQ,gBAAgB,CAAC,gBAAgB,CAAE,YAAW,YAAY;IACvF,OAAO;IAKP,QAAQ;IAIF,QAAQ;CActB"}
@@ -15,3 +15,4 @@ export interface AsyncTokenStorage {
15
15
  storeToken(token: Token): Promise<void>;
16
16
  resetToken(): Promise<void>;
17
17
  }
18
+ //# sourceMappingURL=tokenStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenStorage.d.ts","sourceRoot":"","sources":["../../src/lib/tokenStorage.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,KAAK;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE,MAAM,CAAA;IACpB,cAAc,EAAE,IAAI,CAAA;IACpB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED,MAAM,MAAM,YAAY,GAAG,iBAAiB,GAAG,gBAAgB,CAAA;AAE/D,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,IAAI,KAAK,GAAG,IAAI,CAAA;IACxB,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;IAC9B,UAAU,IAAI,IAAI,CAAA;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,IAAI,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,CAAA;IACjC,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACvC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CAC5B"}
package/package.json CHANGED
@@ -1,7 +1,19 @@
1
1
  {
2
2
  "name": "@leancodepl/login-manager",
3
- "version": "9.7.2",
3
+ "version": "9.7.3",
4
4
  "license": "Apache-2.0",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ "./package.json": "./package.json",
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js",
14
+ "default": "./dist/index.js"
15
+ }
16
+ },
5
17
  "dependencies": {
6
18
  "buffer": ">=6.0.0"
7
19
  },
@@ -10,7 +22,7 @@
10
22
  "registry": "https://registry.npmjs.org/"
11
23
  },
12
24
  "engines": {
13
- "node": ">=18.0.0"
25
+ "node": ">=22.0.0"
14
26
  },
15
27
  "repository": {
16
28
  "type": "git",
@@ -37,16 +49,9 @@
37
49
  "url": "https://leancode.co"
38
50
  },
39
51
  "sideEffects": false,
40
- "exports": {
41
- "./package.json": "./package.json",
42
- ".": {
43
- "module": "./index.esm.js",
44
- "types": "./index.d.ts",
45
- "import": "./index.cjs.mjs",
46
- "default": "./index.cjs.js"
47
- }
48
- },
49
- "module": "./index.esm.js",
50
- "main": "./index.cjs.js",
51
- "types": "./index.d.ts"
52
+ "files": [
53
+ "dist",
54
+ "CHANGELOG.md",
55
+ "!**/*.tsbuildinfo"
56
+ ]
52
57
  }
@@ -1 +0,0 @@
1
- exports._default = require('./index.cjs.js').default;
package/index.cjs.js DELETED
@@ -1,545 +0,0 @@
1
- 'use strict';
2
-
3
- var buffer = require('buffer');
4
-
5
- function _extends() {
6
- _extends = Object.assign || function assign(target) {
7
- for(var i = 1; i < arguments.length; i++){
8
- var source = arguments[i];
9
- for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
10
- }
11
- return target;
12
- };
13
- return _extends.apply(this, arguments);
14
- }
15
-
16
- class BaseLoginManager {
17
- trySignIn(username, password) {
18
- return this.acquireToken(this.buildSignInRequest(username, password));
19
- }
20
- trySignInWithFacebook(accessToken) {
21
- return this.acquireToken(this.buildSignInWithFacebookRequest(accessToken));
22
- }
23
- trySignInWithOneTimeToken(token) {
24
- return this.acquireToken(this.buildSignInWithOneTimeTokenRequest(token));
25
- }
26
- trySignInWithGoogle(accessToken) {
27
- return this.acquireToken(this.buildSignInWithGoogleRequest(accessToken));
28
- }
29
- trySignInWithLinkedIn(accessToken) {
30
- return this.acquireToken(this.buildSignInWithLinkedInRequest(accessToken));
31
- }
32
- trySignInWithApple(accessToken) {
33
- return this.acquireToken(this.buildSignInWithAppleRequest(accessToken));
34
- }
35
- async tryRefreshToken() {
36
- const token = await this.storage.getToken();
37
- if (token !== null) {
38
- return await this.tryRefreshTokenInternal(token);
39
- } else {
40
- return null;
41
- }
42
- }
43
- tryRefreshTokenInternal(token) {
44
- if (!this.isRefreshingToken) {
45
- this.isRefreshingToken = true;
46
- this.acquireToken(this.buildRefreshRequest(token)).then((result)=>{
47
- this.isRefreshingToken = false;
48
- this.refreshTokenCallbacks.forEach((c)=>c(result.type === "success"));
49
- this.refreshTokenCallbacks = [];
50
- });
51
- }
52
- return new Promise((resolve)=>{
53
- this.refreshTokenCallbacks.push(resolve);
54
- });
55
- }
56
- onChange(callback) {
57
- this.callbacks.push(callback);
58
- }
59
- removeOnChange(callback) {
60
- const idx = this.callbacks.indexOf(callback);
61
- if (idx !== -1) {
62
- this.callbacks.splice(idx, 1);
63
- }
64
- }
65
- async acquireToken(init) {
66
- try {
67
- const result = await fetch(this.endpoint + "/connect/token", init);
68
- if (!result.ok) {
69
- if (result.status === 400) {
70
- await this.signOut();
71
- }
72
- return {
73
- type: "failure"
74
- };
75
- }
76
- const tokenResult = await result.json();
77
- const expDate = new Date();
78
- expDate.setSeconds(new Date().getSeconds() + tokenResult.expires_in);
79
- await this.storage.storeToken({
80
- token: tokenResult.access_token,
81
- refreshToken: tokenResult.refresh_token,
82
- expirationDate: expDate
83
- });
84
- this.notify(true);
85
- return {
86
- type: "success"
87
- };
88
- } catch (e) {
89
- console.warn("Cannot call Auth server, error: ", e);
90
- return {
91
- type: "networkError"
92
- };
93
- }
94
- }
95
- buildSignInRequest(username, password) {
96
- const data = _extends({
97
- grant_type: "password",
98
- scope: this.scopes,
99
- username: username,
100
- password: password
101
- }, this.additionalParams);
102
- return {
103
- method: "POST",
104
- headers: this.prepareHeaders(),
105
- body: new URLSearchParams(data)
106
- };
107
- }
108
- buildSignInWithOneTimeTokenRequest(token) {
109
- const data = _extends({
110
- grant_type: "onetime",
111
- scope: this.scopes,
112
- token
113
- }, this.additionalParams);
114
- return {
115
- method: "POST",
116
- headers: this.prepareHeaders(),
117
- body: new URLSearchParams(data)
118
- };
119
- }
120
- buildAssertionSignInRequest(accessToken, grantType) {
121
- const data = _extends({
122
- grant_type: grantType,
123
- scope: this.scopes,
124
- assertion: accessToken
125
- }, this.additionalParams);
126
- return {
127
- method: "POST",
128
- headers: this.prepareHeaders(),
129
- body: new URLSearchParams(data)
130
- };
131
- }
132
- buildSignInWithFacebookRequest(accessToken) {
133
- return this.buildAssertionSignInRequest(accessToken, "facebook");
134
- }
135
- buildSignInWithGoogleRequest(accessToken) {
136
- return this.buildAssertionSignInRequest(accessToken, "google");
137
- }
138
- buildSignInWithLinkedInRequest(accessToken) {
139
- return this.buildAssertionSignInRequest(accessToken, "linkedin");
140
- }
141
- buildSignInWithAppleRequest(accessToken) {
142
- return this.buildAssertionSignInRequest(accessToken, "apple");
143
- }
144
- buildRefreshRequest(token) {
145
- const data = _extends({
146
- grant_type: "refresh_token",
147
- scope: this.scopes,
148
- refresh_token: token.refreshToken || ""
149
- }, this.additionalParams);
150
- return {
151
- method: "POST",
152
- headers: this.prepareHeaders(),
153
- body: new URLSearchParams(data)
154
- };
155
- }
156
- prepareHeaders() {
157
- const headers = new Headers();
158
- if (this.clientSecret) {
159
- const sec = buffer.Buffer.from(`${this.clientId}:${this.clientSecret}`, "binary").toString("base64");
160
- headers.append("Authorization", "Basic " + sec);
161
- }
162
- headers.append("Content-Type", "application/x-www-form-urlencoded");
163
- return headers;
164
- }
165
- notify(isSignedIn) {
166
- for (const c of this.callbacks){
167
- c(isSignedIn);
168
- }
169
- }
170
- /* eslint-disable-next-line max-params */ constructor(storage, endpoint, clientSecret, clientId, scopes, additionalParams){
171
- this.storage = storage;
172
- this.endpoint = endpoint;
173
- this.clientSecret = clientSecret;
174
- this.clientId = clientId;
175
- this.scopes = scopes;
176
- this.additionalParams = additionalParams;
177
- this.callbacks = [];
178
- this.refreshTokenCallbacks = [];
179
- this.isRefreshingToken = false;
180
- if (!clientSecret) {
181
- this.additionalParams = _extends({}, additionalParams, {
182
- client_id: clientId
183
- });
184
- }
185
- }
186
- }
187
-
188
- /**
189
- * Error thrown when token refresh fails.
190
- *
191
- * Indicates that the refresh token is invalid or expired, requiring user to sign in again.
192
- *
193
- * @example
194
- * ```typescript
195
- * try {
196
- * const token = await loginManager.getToken();
197
- * } catch (error) {
198
- * if (error instanceof CannotRefreshToken) {
199
- * console.log('User needs to sign in again');
200
- * }
201
- * }
202
- * ```
203
- */ class CannotRefreshToken extends Error {
204
- constructor(m){
205
- super(m);
206
- Object.setPrototypeOf(this, CannotRefreshToken.prototype);
207
- }
208
- }
209
-
210
- /**
211
- * Manages OAuth2 authentication with asynchronous token storage.
212
- *
213
- * Extends BaseLoginManager to work with async storage implementations like IndexedDB or remote storage.
214
- * Handles token refresh, expiration, and authentication state management.
215
- *
216
- * @param storage - Token storage implementation
217
- * @param endpoint - OAuth2 server endpoint
218
- * @param clientSecret - Client secret for authentication
219
- * @param clientId - OAuth2 client identifier
220
- * @param scopes - Space-separated OAuth2 scopes
221
- * @param additionalParams - Additional OAuth2 parameters
222
- * @example
223
- * ```typescript
224
- * const tokenStorage = new CustomAsyncStorage();
225
- * const loginManager = new AsyncLoginManager(
226
- * tokenStorage,
227
- * 'https://api.example.com',
228
- * 'client_secret',
229
- * 'client_id',
230
- * 'openid profile'
231
- * );
232
- * ```
233
- */ class AsyncLoginManager extends BaseLoginManager {
234
- async signOut() {
235
- await this.storage.resetToken();
236
- this.notify(false);
237
- }
238
- async isSigned() {
239
- return await this.storage.getToken() !== null;
240
- }
241
- async getToken() {
242
- const token = await this.storage.getToken();
243
- if (token === null) {
244
- return null;
245
- } else if (token.expirationDate < new Date()) {
246
- if (await this.tryRefreshTokenInternal(token)) {
247
- var _this;
248
- var _token;
249
- return (_token = (_this = await this.storage.getToken()) == null ? void 0 : _this.token) != null ? _token : null;
250
- } else {
251
- throw new CannotRefreshToken("Cannot refresh access token after it has expired");
252
- }
253
- } else {
254
- return token.token;
255
- }
256
- }
257
- async load() {
258
- const isSignedIn = await this.isSigned();
259
- this.notify(isSignedIn);
260
- }
261
- }
262
-
263
- /// <reference types="facebook-js-sdk" />
264
- /**
265
- * Integrates Facebook Login SDK for web applications.
266
- *
267
- * Handles Facebook authentication flow and provides access tokens for OAuth2 sign-in.
268
- * Automatically loads Facebook SDK and manages login state.
269
- *
270
- * @param facebookAppId - Facebook App ID
271
- * @param facebookPermissions - Comma-separated Facebook permissions
272
- * @example
273
- * ```typescript
274
- * const facebookClient = new FacebookClient('your-app-id', 'email,public_profile');
275
- * facebookClient.setup();
276
- * facebookClient.login((accessToken) => {
277
- * return loginManager.trySignInWithFacebook(accessToken);
278
- * });
279
- * ```
280
- */ class FacebookClient {
281
- get accessToken() {
282
- return this.token;
283
- }
284
- setup(loginCallback) {
285
- const ref = document.getElementsByTagName("script")[0];
286
- const id = "facebook-jssdk";
287
- if (document.getElementById(id)) {
288
- this.initializeSDK();
289
- this.getLoginStatus(loginCallback);
290
- return;
291
- }
292
- const js = document.createElement("script");
293
- js.id = id;
294
- js.async = true;
295
- js.src = "//connect.facebook.net/pl_PL/sdk.js";
296
- if (ref.parentNode != null) {
297
- ref.parentNode.insertBefore(js, ref);
298
- }
299
- js.onload = ()=>{
300
- this.initializeSDK();
301
- this.getLoginStatus(loginCallback);
302
- };
303
- }
304
- login(callback) {
305
- FB.login((response)=>{
306
- if (response.status === "connected") {
307
- this.isSignedIn = true;
308
- this.token = response.authResponse.accessToken;
309
- if (callback) {
310
- callback(response.authResponse.accessToken);
311
- }
312
- } else {
313
- this.isSignedIn = false;
314
- }
315
- }, {
316
- scope: this.facebookPermissions
317
- });
318
- }
319
- getLoginStatus(callback) {
320
- FB.getLoginStatus((response)=>{
321
- if (response.status === "connected") {
322
- this.isSignedIn = true;
323
- this.token = response.authResponse.accessToken;
324
- if (callback) {
325
- callback(response.authResponse.accessToken);
326
- }
327
- } else {
328
- this.isSignedIn = false;
329
- }
330
- });
331
- }
332
- initializeSDK() {
333
- FB.init({
334
- appId: this.facebookAppId,
335
- xfbml: true,
336
- version: "v2.9"
337
- });
338
- }
339
- constructor(facebookAppId, facebookPermissions){
340
- this.facebookAppId = facebookAppId;
341
- this.facebookPermissions = facebookPermissions;
342
- this.isSignedIn = undefined;
343
- this.token = "";
344
- }
345
- }
346
-
347
- /**
348
- * Stores OAuth2 tokens in browser localStorage.
349
- *
350
- * Provides persistent token storage that survives browser sessions.
351
- * Implements SyncTokenStorage interface for synchronous operations.
352
- *
353
- * @param tokenKey - localStorage key for access token (default: "token")
354
- * @param refreshKey - localStorage key for refresh token (default: "refresh_token")
355
- * @param expiryKey - localStorage key for expiry date (default: "expiration_date")
356
- * @example
357
- * ```typescript
358
- * const storage = new LocalTokenStorage();
359
- * const loginManager = new SyncLoginManager(storage, endpoint, secret, clientId, scopes);
360
- * ```
361
- */ class LocalTokenStorage {
362
- getToken() {
363
- if (this.hasValue(this.tokenKey)) {
364
- return {
365
- token: this.getValue(this.tokenKey),
366
- refreshToken: this.getValue(this.refreshKey),
367
- expirationDate: new Date(Number(this.getValue(this.expiryKey)))
368
- };
369
- } else {
370
- return null;
371
- }
372
- }
373
- storeToken(token) {
374
- this.setValue(this.tokenKey, token.token);
375
- this.setValue(this.refreshKey, token.refreshToken);
376
- this.setValue(this.expiryKey, token.expirationDate.getTime().toString());
377
- }
378
- resetToken() {
379
- this.remove(this.tokenKey);
380
- this.remove(this.refreshKey);
381
- this.remove(this.expiryKey);
382
- }
383
- hasValue(key) {
384
- return localStorage.getItem(key) !== null;
385
- }
386
- getValue(key) {
387
- return localStorage.getItem(key);
388
- }
389
- setValue(key, val) {
390
- localStorage.setItem(key, val);
391
- }
392
- remove(key) {
393
- localStorage.removeItem(key);
394
- }
395
- constructor(tokenKey = "token", refreshKey = "refresh_token", expiryKey = "expiration_date"){
396
- this.tokenKey = tokenKey;
397
- this.refreshKey = refreshKey;
398
- this.expiryKey = expiryKey;
399
- }
400
- }
401
-
402
- /**
403
- * Stores OAuth2 tokens in memory.
404
- *
405
- * Provides temporary token storage that clears when the page is refreshed.
406
- * Implements SyncTokenStorage interface for synchronous operations.
407
- *
408
- * @example
409
- * ```typescript
410
- * const storage = new MemoryTokenStorage();
411
- * const loginManager = new SyncLoginManager(storage, endpoint, secret, clientId, scopes);
412
- * ```
413
- */ class MemoryTokenStorage {
414
- getToken() {
415
- return this.token;
416
- }
417
- storeToken(token) {
418
- this.token = {
419
- token: token.token,
420
- refreshToken: token.refreshToken,
421
- expirationDate: token.expirationDate
422
- };
423
- return Promise.resolve();
424
- }
425
- resetToken() {
426
- this.token = null;
427
- return Promise.resolve();
428
- }
429
- constructor(){
430
- this.token = null;
431
- }
432
- }
433
-
434
- /**
435
- * Stores OAuth2 tokens in browser sessionStorage.
436
- *
437
- * Provides session-based token storage that clears when the browser tab is closed.
438
- * Implements SyncTokenStorage interface for synchronous operations.
439
- *
440
- * @param tokenKey - sessionStorage key for access token (default: "token")
441
- * @param refreshKey - sessionStorage key for refresh token (default: "refresh_token")
442
- * @param expiryKey - sessionStorage key for expiry date (default: "expiration_date")
443
- * @example
444
- * ```typescript
445
- * const storage = new SessionTokenStorage();
446
- * const loginManager = new SyncLoginManager(storage, endpoint, secret, clientId, scopes);
447
- * ```
448
- */ class SessionTokenStorage {
449
- getToken() {
450
- if (this.hasValue(this.tokenKey)) {
451
- return {
452
- token: this.getValue(this.tokenKey),
453
- refreshToken: this.getValue(this.refreshKey),
454
- expirationDate: new Date(Number(this.getValue(this.expiryKey)))
455
- };
456
- } else {
457
- return null;
458
- }
459
- }
460
- storeToken(token) {
461
- this.setValue(this.tokenKey, token.token);
462
- this.setValue(this.refreshKey, token.refreshToken);
463
- this.setValue(this.expiryKey, token.expirationDate.getTime().toString());
464
- }
465
- resetToken() {
466
- this.remove(this.tokenKey);
467
- this.remove(this.refreshKey);
468
- this.remove(this.expiryKey);
469
- }
470
- hasValue(key) {
471
- return sessionStorage.getItem(key) !== null;
472
- }
473
- getValue(key) {
474
- return sessionStorage.getItem(key);
475
- }
476
- setValue(key, val) {
477
- sessionStorage.setItem(key, val);
478
- }
479
- remove(key) {
480
- sessionStorage.removeItem(key);
481
- }
482
- constructor(tokenKey = "token", refreshKey = "refresh_token", expiryKey = "expiration_date"){
483
- this.tokenKey = tokenKey;
484
- this.refreshKey = refreshKey;
485
- this.expiryKey = expiryKey;
486
- }
487
- }
488
-
489
- /**
490
- * Manages OAuth2 authentication with synchronous token storage.
491
- *
492
- * Extends BaseLoginManager to work with sync storage implementations like localStorage or sessionStorage.
493
- * Handles token refresh, expiration, and authentication state management.
494
- *
495
- * @param storage - Token storage implementation
496
- * @param endpoint - OAuth2 server endpoint
497
- * @param clientSecret - Client secret for authentication
498
- * @param clientId - OAuth2 client identifier
499
- * @param scopes - Space-separated OAuth2 scopes
500
- * @param additionalParams - Additional OAuth2 parameters
501
- * @example
502
- * ```typescript
503
- * const tokenStorage = new LocalTokenStorage();
504
- * const loginManager = new SyncLoginManager(
505
- * tokenStorage,
506
- * 'https://api.example.com',
507
- * 'client_secret',
508
- * 'client_id',
509
- * 'openid profile'
510
- * );
511
- * ```
512
- */ class SyncLoginManager extends BaseLoginManager {
513
- signOut() {
514
- this.storage.resetToken();
515
- this.notify(false);
516
- }
517
- isSigned() {
518
- return this.storage.getToken() !== null;
519
- }
520
- async getToken() {
521
- const token = this.storage.getToken();
522
- if (token === null) {
523
- return null;
524
- } else if (token.expirationDate < new Date()) {
525
- if (await this.tryRefreshTokenInternal(token)) {
526
- var _this_storage_getToken;
527
- var _this_storage_getToken_token;
528
- return (_this_storage_getToken_token = (_this_storage_getToken = this.storage.getToken()) == null ? void 0 : _this_storage_getToken.token) != null ? _this_storage_getToken_token : null;
529
- } else {
530
- throw new CannotRefreshToken("Cannot refresh access token after it has expired");
531
- }
532
- } else {
533
- return token.token;
534
- }
535
- }
536
- }
537
-
538
- exports.AsyncLoginManager = AsyncLoginManager;
539
- exports.BaseLoginManager = BaseLoginManager;
540
- exports.CannotRefreshToken = CannotRefreshToken;
541
- exports.FacebookClient = FacebookClient;
542
- exports.LocalTokenStorage = LocalTokenStorage;
543
- exports.MemoryTokenStorage = MemoryTokenStorage;
544
- exports.SessionTokenStorage = SessionTokenStorage;
545
- exports.SyncLoginManager = SyncLoginManager;
package/index.cjs.mjs DELETED
@@ -1,2 +0,0 @@
1
- export * from './index.cjs.js';
2
- export { _default as default } from './index.cjs.default.js';
package/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./src/index";