@leancodepl/login-manager 9.6.4 → 9.6.6

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.
package/README.md CHANGED
@@ -91,16 +91,16 @@ import { SyncLoginManager, LocalTokenStorage } from "@leancodepl/login-manager"
91
91
 
92
92
  const tokenStorage = new LocalTokenStorage()
93
93
  const loginManager = new SyncLoginManager(
94
- tokenStorage,
95
- "https://api.example.com",
96
- "client_secret",
97
- "client_id",
98
- "openid profile email",
94
+ tokenStorage,
95
+ "https://api.example.com",
96
+ "client_secret",
97
+ "client_id",
98
+ "openid profile email",
99
99
  )
100
100
 
101
101
  const result = await loginManager.trySignIn("user@example.com", "password")
102
102
  if (result.type === "success") {
103
- console.log("Signed in successfully")
103
+ console.log("Signed in successfully")
104
104
  }
105
105
  ```
106
106
 
@@ -111,11 +111,11 @@ import { AsyncLoginManager, SessionTokenStorage } from "@leancodepl/login-manage
111
111
 
112
112
  const tokenStorage = new SessionTokenStorage()
113
113
  const loginManager = new AsyncLoginManager(
114
- tokenStorage,
115
- "https://api.example.com",
116
- undefined, // No client secret for public clients
117
- "public_client_id",
118
- "openid profile",
114
+ tokenStorage,
115
+ "https://api.example.com",
116
+ undefined, // No client secret for public clients
117
+ "public_client_id",
118
+ "openid profile",
119
119
  )
120
120
 
121
121
  await loginManager.load()
@@ -130,19 +130,19 @@ import { FacebookClient, SyncLoginManager, LocalTokenStorage } from "@leancodepl
130
130
 
131
131
  const facebookClient = new FacebookClient("your-facebook-app-id", "email,public_profile")
132
132
  const loginManager = new SyncLoginManager(
133
- new LocalTokenStorage(),
134
- "https://api.example.com",
135
- "client_secret",
136
- "client_id",
137
- "openid profile",
133
+ new LocalTokenStorage(),
134
+ "https://api.example.com",
135
+ "client_secret",
136
+ "client_id",
137
+ "openid profile",
138
138
  )
139
139
 
140
140
  facebookClient.setup()
141
141
  facebookClient.login(async accessToken => {
142
- const result = await loginManager.trySignInWithFacebook(accessToken)
143
- if (result.type === "success") {
144
- console.log("Facebook login successful")
145
- }
142
+ const result = await loginManager.trySignInWithFacebook(accessToken)
143
+ if (result.type === "success") {
144
+ console.log("Facebook login successful")
145
+ }
146
146
  })
147
147
  ```
148
148
 
@@ -153,21 +153,21 @@ import { CannotRefreshToken, SyncLoginManager, LocalTokenStorage } from "@leanco
153
153
 
154
154
  const tokenStorage = new LocalTokenStorage()
155
155
  const loginManager = new SyncLoginManager(
156
- tokenStorage,
157
- "https://api.example.com",
158
- "client_secret",
159
- "client_id",
160
- "openid profile",
156
+ tokenStorage,
157
+ "https://api.example.com",
158
+ "client_secret",
159
+ "client_id",
160
+ "openid profile",
161
161
  )
162
162
 
163
163
  try {
164
- const token = await loginManager.getToken()
165
- console.log("Access token:", token)
164
+ const token = await loginManager.getToken()
165
+ console.log("Access token:", token)
166
166
  } catch (error) {
167
- if (error instanceof CannotRefreshToken) {
168
- console.log("Token expired, user needs to sign in again")
169
- await loginManager.signOut()
170
- }
167
+ if (error instanceof CannotRefreshToken) {
168
+ console.log("Token expired, user needs to sign in again")
169
+ await loginManager.signOut()
170
+ }
171
171
  }
172
172
  ```
173
173
 
@@ -178,19 +178,19 @@ import { SyncLoginManager, LocalTokenStorage } from "@leancodepl/login-manager"
178
178
 
179
179
  const tokenStorage = new LocalTokenStorage()
180
180
  const loginManager = new SyncLoginManager(
181
- tokenStorage,
182
- "https://api.example.com",
183
- "client_secret",
184
- "client_id",
185
- "openid profile",
181
+ tokenStorage,
182
+ "https://api.example.com",
183
+ "client_secret",
184
+ "client_id",
185
+ "openid profile",
186
186
  )
187
187
 
188
188
  loginManager.onChange(isSignedIn => {
189
- if (isSignedIn) {
190
- console.log("User is now signed in")
191
- } else {
192
- console.log("User signed out")
193
- }
189
+ if (isSignedIn) {
190
+ console.log("User is now signed in")
191
+ } else {
192
+ console.log("User signed out")
193
+ }
194
194
  })
195
195
  ```
196
196
 
@@ -201,11 +201,11 @@ import { SyncLoginManager, LocalTokenStorage } from "@leancodepl/login-manager"
201
201
 
202
202
  const tokenStorage = new LocalTokenStorage()
203
203
  const loginManager = new SyncLoginManager(
204
- tokenStorage,
205
- "https://api.example.com",
206
- "client_secret",
207
- "client_id",
208
- "openid profile",
204
+ tokenStorage,
205
+ "https://api.example.com",
206
+ "client_secret",
207
+ "client_id",
208
+ "openid profile",
209
209
  )
210
210
 
211
211
  const googleResult = await loginManager.trySignInWithGoogle("google_access_token")
package/index.cjs.js CHANGED
@@ -187,9 +187,9 @@ class BaseLoginManager {
187
187
 
188
188
  /**
189
189
  * Error thrown when token refresh fails.
190
- *
190
+ *
191
191
  * Indicates that the refresh token is invalid or expired, requiring user to sign in again.
192
- *
192
+ *
193
193
  * @example
194
194
  * ```typescript
195
195
  * try {
@@ -209,10 +209,10 @@ class BaseLoginManager {
209
209
 
210
210
  /**
211
211
  * Manages OAuth2 authentication with asynchronous token storage.
212
- *
212
+ *
213
213
  * Extends BaseLoginManager to work with async storage implementations like IndexedDB or remote storage.
214
214
  * Handles token refresh, expiration, and authentication state management.
215
- *
215
+ *
216
216
  * @param storage - Token storage implementation
217
217
  * @param endpoint - OAuth2 server endpoint
218
218
  * @param clientSecret - Client secret for authentication
@@ -263,10 +263,10 @@ class BaseLoginManager {
263
263
  /// <reference types="facebook-js-sdk" />
264
264
  /**
265
265
  * Integrates Facebook Login SDK for web applications.
266
- *
266
+ *
267
267
  * Handles Facebook authentication flow and provides access tokens for OAuth2 sign-in.
268
268
  * Automatically loads Facebook SDK and manages login state.
269
- *
269
+ *
270
270
  * @param facebookAppId - Facebook App ID
271
271
  * @param facebookPermissions - Comma-separated Facebook permissions
272
272
  * @example
@@ -346,10 +346,10 @@ class BaseLoginManager {
346
346
 
347
347
  /**
348
348
  * Stores OAuth2 tokens in browser localStorage.
349
- *
349
+ *
350
350
  * Provides persistent token storage that survives browser sessions.
351
351
  * Implements SyncTokenStorage interface for synchronous operations.
352
- *
352
+ *
353
353
  * @param tokenKey - localStorage key for access token (default: "token")
354
354
  * @param refreshKey - localStorage key for refresh token (default: "refresh_token")
355
355
  * @param expiryKey - localStorage key for expiry date (default: "expiration_date")
@@ -401,10 +401,10 @@ class BaseLoginManager {
401
401
 
402
402
  /**
403
403
  * Stores OAuth2 tokens in memory.
404
- *
404
+ *
405
405
  * Provides temporary token storage that clears when the page is refreshed.
406
406
  * Implements SyncTokenStorage interface for synchronous operations.
407
- *
407
+ *
408
408
  * @example
409
409
  * ```typescript
410
410
  * const storage = new MemoryTokenStorage();
@@ -433,10 +433,10 @@ class BaseLoginManager {
433
433
 
434
434
  /**
435
435
  * Stores OAuth2 tokens in browser sessionStorage.
436
- *
436
+ *
437
437
  * Provides session-based token storage that clears when the browser tab is closed.
438
438
  * Implements SyncTokenStorage interface for synchronous operations.
439
- *
439
+ *
440
440
  * @param tokenKey - sessionStorage key for access token (default: "token")
441
441
  * @param refreshKey - sessionStorage key for refresh token (default: "refresh_token")
442
442
  * @param expiryKey - sessionStorage key for expiry date (default: "expiration_date")
@@ -488,10 +488,10 @@ class BaseLoginManager {
488
488
 
489
489
  /**
490
490
  * Manages OAuth2 authentication with synchronous token storage.
491
- *
491
+ *
492
492
  * Extends BaseLoginManager to work with sync storage implementations like localStorage or sessionStorage.
493
493
  * Handles token refresh, expiration, and authentication state management.
494
- *
494
+ *
495
495
  * @param storage - Token storage implementation
496
496
  * @param endpoint - OAuth2 server endpoint
497
497
  * @param clientSecret - Client secret for authentication
package/index.esm.js CHANGED
@@ -185,9 +185,9 @@ class BaseLoginManager {
185
185
 
186
186
  /**
187
187
  * Error thrown when token refresh fails.
188
- *
188
+ *
189
189
  * Indicates that the refresh token is invalid or expired, requiring user to sign in again.
190
- *
190
+ *
191
191
  * @example
192
192
  * ```typescript
193
193
  * try {
@@ -207,10 +207,10 @@ class BaseLoginManager {
207
207
 
208
208
  /**
209
209
  * Manages OAuth2 authentication with asynchronous token storage.
210
- *
210
+ *
211
211
  * Extends BaseLoginManager to work with async storage implementations like IndexedDB or remote storage.
212
212
  * Handles token refresh, expiration, and authentication state management.
213
- *
213
+ *
214
214
  * @param storage - Token storage implementation
215
215
  * @param endpoint - OAuth2 server endpoint
216
216
  * @param clientSecret - Client secret for authentication
@@ -261,10 +261,10 @@ class BaseLoginManager {
261
261
  /// <reference types="facebook-js-sdk" />
262
262
  /**
263
263
  * Integrates Facebook Login SDK for web applications.
264
- *
264
+ *
265
265
  * Handles Facebook authentication flow and provides access tokens for OAuth2 sign-in.
266
266
  * Automatically loads Facebook SDK and manages login state.
267
- *
267
+ *
268
268
  * @param facebookAppId - Facebook App ID
269
269
  * @param facebookPermissions - Comma-separated Facebook permissions
270
270
  * @example
@@ -344,10 +344,10 @@ class BaseLoginManager {
344
344
 
345
345
  /**
346
346
  * Stores OAuth2 tokens in browser localStorage.
347
- *
347
+ *
348
348
  * Provides persistent token storage that survives browser sessions.
349
349
  * Implements SyncTokenStorage interface for synchronous operations.
350
- *
350
+ *
351
351
  * @param tokenKey - localStorage key for access token (default: "token")
352
352
  * @param refreshKey - localStorage key for refresh token (default: "refresh_token")
353
353
  * @param expiryKey - localStorage key for expiry date (default: "expiration_date")
@@ -399,10 +399,10 @@ class BaseLoginManager {
399
399
 
400
400
  /**
401
401
  * Stores OAuth2 tokens in memory.
402
- *
402
+ *
403
403
  * Provides temporary token storage that clears when the page is refreshed.
404
404
  * Implements SyncTokenStorage interface for synchronous operations.
405
- *
405
+ *
406
406
  * @example
407
407
  * ```typescript
408
408
  * const storage = new MemoryTokenStorage();
@@ -431,10 +431,10 @@ class BaseLoginManager {
431
431
 
432
432
  /**
433
433
  * Stores OAuth2 tokens in browser sessionStorage.
434
- *
434
+ *
435
435
  * Provides session-based token storage that clears when the browser tab is closed.
436
436
  * Implements SyncTokenStorage interface for synchronous operations.
437
- *
437
+ *
438
438
  * @param tokenKey - sessionStorage key for access token (default: "token")
439
439
  * @param refreshKey - sessionStorage key for refresh token (default: "refresh_token")
440
440
  * @param expiryKey - sessionStorage key for expiry date (default: "expiration_date")
@@ -486,10 +486,10 @@ class BaseLoginManager {
486
486
 
487
487
  /**
488
488
  * Manages OAuth2 authentication with synchronous token storage.
489
- *
489
+ *
490
490
  * Extends BaseLoginManager to work with sync storage implementations like localStorage or sessionStorage.
491
491
  * Handles token refresh, expiration, and authentication state management.
492
- *
492
+ *
493
493
  * @param storage - Token storage implementation
494
494
  * @param endpoint - OAuth2 server endpoint
495
495
  * @param clientSecret - Client secret for authentication
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leancodepl/login-manager",
3
- "version": "9.6.4",
3
+ "version": "9.6.6",
4
4
  "license": "Apache-2.0",
5
5
  "dependencies": {
6
6
  "buffer": ">=6.0.0"