@auth0/auth0-spa-js 1.22.3 → 2.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +50 -41
  2. package/dist/auth0-spa-js.development.js +996 -4901
  3. package/dist/auth0-spa-js.development.js.map +1 -1
  4. package/dist/auth0-spa-js.production.esm.js +1 -1
  5. package/dist/auth0-spa-js.production.esm.js.map +1 -1
  6. package/dist/auth0-spa-js.production.js +1 -1
  7. package/dist/auth0-spa-js.production.js.map +1 -1
  8. package/dist/lib/auth0-spa-js.cjs.js +1768 -5532
  9. package/dist/lib/auth0-spa-js.cjs.js.map +1 -1
  10. package/dist/typings/Auth0Client.d.ts +21 -41
  11. package/dist/typings/Auth0Client.utils.d.ts +26 -0
  12. package/dist/typings/cache/cache-manager.d.ts +11 -7
  13. package/dist/typings/cache/shared.d.ts +16 -11
  14. package/dist/typings/constants.d.ts +0 -7
  15. package/dist/typings/errors.d.ts +0 -4
  16. package/dist/typings/global.d.ts +125 -167
  17. package/dist/typings/index.d.ts +3 -13
  18. package/dist/typings/transaction-manager.d.ts +1 -1
  19. package/dist/typings/utils.d.ts +8 -7
  20. package/dist/typings/version.d.ts +1 -1
  21. package/package.json +35 -36
  22. package/src/Auth0Client.ts +407 -562
  23. package/src/Auth0Client.utils.ts +73 -0
  24. package/src/cache/cache-localstorage.ts +1 -1
  25. package/src/cache/cache-manager.ts +58 -29
  26. package/src/cache/shared.ts +29 -17
  27. package/src/constants.ts +0 -17
  28. package/src/errors.ts +10 -14
  29. package/src/global.ts +132 -183
  30. package/src/http.ts +0 -5
  31. package/src/index.ts +15 -14
  32. package/src/jwt.ts +3 -3
  33. package/src/storage.ts +1 -1
  34. package/src/transaction-manager.ts +1 -1
  35. package/src/utils.ts +37 -42
  36. package/src/version.ts +1 -1
  37. package/src/worker/token.worker.ts +4 -3
  38. package/dist/typings/index.cjs.d.ts +0 -5
  39. package/dist/typings/user-agent.d.ts +0 -1
  40. package/src/index.cjs.ts +0 -23
  41. package/src/user-agent.ts +0 -1
package/README.md CHANGED
@@ -1,7 +1,10 @@
1
- # @auth0/auth0-spa-js
1
+ # @auth0/auth0-spa-js (Beta)
2
2
 
3
3
  Auth0 SDK for Single Page Applications using [Authorization Code Grant Flow with PKCE](https://auth0.com/docs/api-auth/tutorials/authorization-code-grant-pkce).
4
4
 
5
+ > :warning: Please be aware that v2 is currently in [**Beta**](https://auth0.com/docs/troubleshoot/product-lifecycle/product-release-stages). Whilst we encourage you to test the update within your applications, we do no recommend using this version in production yet. Please follow the [migration guide](./MIGRATION_GUIDE.md) when updating your application.
6
+
7
+ ![Stage: Beta Release](https://img.shields.io/badge/stage-fa-yellow)
5
8
  [![CircleCI](https://circleci.com/gh/auth0/auth0-spa-js.svg?style=svg)](https://circleci.com/gh/auth0/auth0-spa-js)
6
9
  ![Release](https://img.shields.io/github/v/release/auth0/auth0-spa-js)
7
10
  [![Codecov](https://img.shields.io/codecov/c/github/auth0/auth0-spa-js)](https://codecov.io/gh/auth0/auth0-spa-js)
@@ -37,13 +40,13 @@ From the CDN:
37
40
  Using [npm](https://npmjs.org):
38
41
 
39
42
  ```sh
40
- npm install @auth0/auth0-spa-js
43
+ npm install @auth0/auth0-spa-js@fa
41
44
  ```
42
45
 
43
46
  Using [yarn](https://yarnpkg.com):
44
47
 
45
48
  ```sh
46
- yarn add @auth0/auth0-spa-js
49
+ yarn add @auth0/auth0-spa-js@fa
47
50
  ```
48
51
 
49
52
  ## Getting Started
@@ -75,20 +78,24 @@ Take note of the **Client ID** and **Domain** values under the "Basic Informatio
75
78
  Create an `Auth0Client` instance before rendering or initializing your application. You should only have one instance of the client.
76
79
 
77
80
  ```js
78
- import createAuth0Client from '@auth0/auth0-spa-js';
81
+ import { createAuth0Client } from '@auth0/auth0-spa-js';
79
82
 
80
83
  //with async/await
81
84
  const auth0 = await createAuth0Client({
82
85
  domain: '<AUTH0_DOMAIN>',
83
- client_id: '<AUTH0_CLIENT_ID>',
84
- redirect_uri: '<MY_CALLBACK_URL>'
86
+ clientId: '<AUTH0_CLIENT_ID>',
87
+ authorizationParams: {
88
+ redirect_uri: '<MY_CALLBACK_URL>'
89
+ }
85
90
  });
86
91
 
87
92
  //with promises
88
93
  createAuth0Client({
89
94
  domain: '<AUTH0_DOMAIN>',
90
- client_id: '<AUTH0_CLIENT_ID>',
91
- redirect_uri: '<MY_CALLBACK_URL>'
95
+ clientId: '<AUTH0_CLIENT_ID>',
96
+ authorizationParams: {
97
+ redirect_uri: '<MY_CALLBACK_URL>'
98
+ }
92
99
  }).then(auth0 => {
93
100
  //...
94
101
  });
@@ -98,8 +105,10 @@ import { Auth0Client } from '@auth0/auth0-spa-js';
98
105
 
99
106
  const auth0 = new Auth0Client({
100
107
  domain: '<AUTH0_DOMAIN>',
101
- client_id: '<AUTH0_CLIENT_ID>',
102
- redirect_uri: '<MY_CALLBACK_URL>'
108
+ clientId: '<AUTH0_CLIENT_ID>',
109
+ authorizationParams: {
110
+ redirect_uri: '<MY_CALLBACK_URL>'
111
+ }
103
112
  });
104
113
 
105
114
  //if you do this, you'll need to check the session yourself
@@ -200,7 +209,7 @@ document.getElementById('call-api').addEventListener('click', () => {
200
209
  ```
201
210
 
202
211
  ```js
203
- import createAuth0Client from '@auth0/auth0-spa-js';
212
+ import { createAuth0Client } from '@auth0/auth0-spa-js';
204
213
 
205
214
  document.getElementById('logout').addEventListener('click', () => {
206
215
  auth0.logout();
@@ -224,9 +233,11 @@ To use the in-memory mode, no additional options need are required as this is th
224
233
  ```js
225
234
  await createAuth0Client({
226
235
  domain: '<AUTH0_DOMAIN>',
227
- client_id: '<AUTH0_CLIENT_ID>',
228
- redirect_uri: '<MY_CALLBACK_URL>',
229
- cacheLocation: 'localstorage' // valid values are: 'memory' or 'localstorage'
236
+ clientId: '<AUTH0_CLIENT_ID>',,
237
+ cacheLocation: 'localstorage' // valid values are: 'memory' or 'localstorage',
238
+ authorizationParams: {
239
+ redirect_uri: '<MY_CALLBACK_URL>'
240
+ }
230
241
  });
231
242
  ```
232
243
 
@@ -271,9 +282,11 @@ const sessionStorageCache = {
271
282
 
272
283
  await createAuth0Client({
273
284
  domain: '<AUTH0_DOMAIN>',
274
- client_id: '<AUTH0_CLIENT_ID>',
275
- redirect_uri: '<MY_CALLBACK_URL>',
276
- cache: sessionStorageCache
285
+ clientId: '<AUTH0_CLIENT_ID>',
286
+ cache: sessionStorageCache,
287
+ authorizationParams: {
288
+ redirect_uri: '<MY_CALLBACK_URL>'
289
+ }
277
290
  });
278
291
  ```
279
292
 
@@ -290,9 +303,11 @@ To enable the use of refresh tokens, set the `useRefreshTokens` option to `true`
290
303
  ```js
291
304
  await createAuth0Client({
292
305
  domain: '<AUTH0_DOMAIN>',
293
- client_id: '<AUTH0_CLIENT_ID>',
294
- redirect_uri: '<MY_CALLBACK_URL>',
295
- useRefreshTokens: true
306
+ clientId: '<AUTH0_CLIENT_ID>',
307
+ useRefreshTokens: true,
308
+ authorizationParams: {
309
+ redirect_uri: '<MY_CALLBACK_URL>'
310
+ }
296
311
  });
297
312
  ```
298
313
 
@@ -319,9 +334,11 @@ Log in to an organization by specifying the `organization` parameter when settin
319
334
  ```js
320
335
  createAuth0Client({
321
336
  domain: '<AUTH0_DOMAIN>',
322
- client_id: '<AUTH0_CLIENT_ID>',
323
- redirect_uri: '<MY_CALLBACK_URL>',
324
- organization: '<MY_ORG_ID>'
337
+ clientId: '<AUTH0_CLIENT_ID>',
338
+ authorizationParams: {
339
+ organization: '<MY_ORG_ID>',
340
+ redirect_uri: '<MY_CALLBACK_URL>'
341
+ }
325
342
  });
326
343
  ```
327
344
 
@@ -330,12 +347,16 @@ You can also specify the organization when logging in:
330
347
  ```js
331
348
  // Using a redirect
332
349
  client.loginWithRedirect({
333
- organization: '<MY_ORG_ID>'
350
+ authorizationParams: {
351
+ organization: '<MY_ORG_ID>'
352
+ }
334
353
  });
335
354
 
336
355
  // Using a popup window
337
356
  client.loginWithPopup({
338
- organization: '<MY_ORG_ID>'
357
+ authorizationParams: {
358
+ organization: '<MY_ORG_ID>'
359
+ }
339
360
  });
340
361
  ```
341
362
 
@@ -351,26 +372,14 @@ const invitation = params.get('invitation');
351
372
 
352
373
  if (organization && invitation) {
353
374
  client.loginWithRedirect({
354
- organization,
355
- invitation
375
+ authorizationParams: {
376
+ invitation,
377
+ organization
378
+ }
356
379
  });
357
380
  }
358
381
  ```
359
382
 
360
- ### Advanced options
361
-
362
- Advanced options can be set by specifying the `advancedOptions` property when configuring `Auth0Client`. Learn about the complete set of advanced options in the [API documentation](https://auth0.github.io/auth0-spa-js/interfaces/advancedoptions.html)
363
-
364
- ```js
365
- createAuth0Client({
366
- domain: '<AUTH0_DOMAIN>',
367
- client_id: '<AUTH0_CLIENT_ID>',
368
- advancedOptions: {
369
- defaultScope: 'email' // change the scopes that are applied to every authz request. **Note**: `openid` is always specified regardless of this setting
370
- }
371
- });
372
- ```
373
-
374
383
  ## Contributing
375
384
 
376
385
  We appreciate feedback and contribution to this repo! Before you get started, please see the following: