@auth0/auth0-spa-js 2.3.0 → 2.4.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 (43) hide show
  1. package/README.md +1 -1
  2. package/dist/auth0-spa-js.development.js +600 -14
  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/auth0-spa-js.worker.development.js +10 -2
  9. package/dist/auth0-spa-js.worker.development.js.map +1 -1
  10. package/dist/auth0-spa-js.worker.production.js +1 -1
  11. package/dist/auth0-spa-js.worker.production.js.map +1 -1
  12. package/dist/lib/auth0-spa-js.cjs.js +641 -14
  13. package/dist/lib/auth0-spa-js.cjs.js.map +1 -1
  14. package/dist/typings/Auth0Client.d.ts +50 -0
  15. package/dist/typings/Auth0Client.utils.d.ts +1 -1
  16. package/dist/typings/api.d.ts +1 -1
  17. package/dist/typings/cache/shared.d.ts +1 -0
  18. package/dist/typings/dpop/dpop.d.ts +17 -0
  19. package/dist/typings/dpop/storage.d.ts +27 -0
  20. package/dist/typings/dpop/utils.d.ts +15 -0
  21. package/dist/typings/errors.d.ts +7 -0
  22. package/dist/typings/fetcher.d.ts +48 -0
  23. package/dist/typings/global.d.ts +19 -0
  24. package/dist/typings/http.d.ts +2 -1
  25. package/dist/typings/index.d.ts +2 -1
  26. package/dist/typings/utils.d.ts +6 -0
  27. package/dist/typings/version.d.ts +1 -1
  28. package/package.json +22 -19
  29. package/src/Auth0Client.ts +112 -5
  30. package/src/Auth0Client.utils.ts +4 -2
  31. package/src/api.ts +6 -1
  32. package/src/cache/shared.ts +1 -0
  33. package/src/dpop/dpop.ts +56 -0
  34. package/src/dpop/storage.ts +134 -0
  35. package/src/dpop/utils.ts +66 -0
  36. package/src/errors.ts +11 -0
  37. package/src/fetcher.ts +224 -0
  38. package/src/global.ts +21 -0
  39. package/src/http.ts +70 -5
  40. package/src/index.ts +4 -1
  41. package/src/utils.ts +15 -0
  42. package/src/version.ts +1 -1
  43. package/src/worker/token.worker.ts +11 -5
@@ -1,5 +1,6 @@
1
1
  import { MissingRefreshTokenError } from '../errors';
2
- import { createQueryParams } from '../utils';
2
+ import { FetchResponse } from '../global';
3
+ import { createQueryParams, fromEntries } from '../utils';
3
4
  import { WorkerRefreshTokenMessage } from './worker.types';
4
5
 
5
6
  let refreshTokens: Record<string, string> = {};
@@ -19,7 +20,7 @@ const deleteRefreshToken = (audience: string, scope: string) =>
19
20
  delete refreshTokens[cacheKey(audience, scope)];
20
21
 
21
22
  const wait = (time: number) =>
22
- new Promise(resolve => setTimeout(resolve, time));
23
+ new Promise<void>(resolve => setTimeout(resolve, time));
23
24
 
24
25
  const formDataToObject = (formData: string): Record<string, any> => {
25
26
  const queryParams = new URLSearchParams(formData);
@@ -36,6 +37,8 @@ const messageHandler = async ({
36
37
  data: { timeout, auth, fetchUrl, fetchOptions, useFormData },
37
38
  ports: [port]
38
39
  }: MessageEvent<WorkerRefreshTokenMessage>) => {
40
+ let headers: FetchResponse['headers'] = {};
41
+
39
42
  let json: {
40
43
  refresh_token?: string;
41
44
  };
@@ -72,7 +75,7 @@ const messageHandler = async ({
72
75
  fetchOptions.signal = abortController.signal;
73
76
  }
74
77
 
75
- let response: any;
78
+ let response: void | Response;
76
79
 
77
80
  try {
78
81
  response = await Promise.race([
@@ -99,6 +102,7 @@ const messageHandler = async ({
99
102
  return;
100
103
  }
101
104
 
105
+ headers = fromEntries(response.headers);
102
106
  json = await response.json();
103
107
 
104
108
  if (json.refresh_token) {
@@ -110,7 +114,8 @@ const messageHandler = async ({
110
114
 
111
115
  port.postMessage({
112
116
  ok: response.ok,
113
- json
117
+ json,
118
+ headers
114
119
  });
115
120
  } catch (error) {
116
121
  port.postMessage({
@@ -118,7 +123,8 @@ const messageHandler = async ({
118
123
  json: {
119
124
  error: error.error,
120
125
  error_description: error.message
121
- }
126
+ },
127
+ headers
122
128
  });
123
129
  }
124
130
  };