ra-auth-auth0 1.1.1 → 2.0.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.
package/Readme.md CHANGED
@@ -43,10 +43,7 @@ const authProvider = Auth0AuthProvider(auth0, {
43
43
  const App = () => {
44
44
  return (
45
45
  <BrowserRouter>
46
- <Admin
47
- authProvider={authProvider}
48
- dataProvider={dataProvider}
49
- >
46
+ <Admin authProvider={authProvider} dataProvider={dataProvider}>
50
47
  <Resource name="posts" {...posts} />
51
48
  </Admin>
52
49
  </BrowserRouter>
@@ -69,8 +66,13 @@ If you want to pass the Auth0 authentication token to your backend, you can use
69
66
 
70
67
  ```js
71
68
  import jsonServerProvider from 'ra-data-json-server';
72
- import { Auth0Client } from './auth0';
73
- const dataProvider = jsonServerProvider('http://localhost:3000', httpClient(auth0));
69
+ import { httpClient } from 'ra-auth-auth0';
70
+ import { auth0 } from './auth0';
71
+
72
+ const dataProvider = jsonServerProvider(
73
+ 'http://localhost:3000',
74
+ httpClient(auth0)
75
+ );
74
76
  ```
75
77
 
76
78
  ## Handling Permissions
@@ -92,8 +94,8 @@ const authProvider = {
92
94
 
93
95
  const claims = await client.getIdTokenClaims();
94
96
  return claims['https://my-app.example.com/roles'];
95
- }
96
- }
97
+ },
98
+ };
97
99
  ```
98
100
 
99
101
  ## Demo
@@ -102,4 +104,4 @@ You can find a working demo, along with the source code, in this project's repos
102
104
 
103
105
  ## License
104
106
 
105
- This auth provider is licensed under the MIT License and sponsored by [marmelab](https://marmelab.com).
107
+ This auth provider is licensed under the MIT License and sponsored by [Marmelab](https://marmelab.com).
@@ -1,4 +1,4 @@
1
- import { AuthProvider } from 'ra-core';
1
+ import { AuthProvider } from 'react-admin';
2
2
  import { Auth0Client } from '@auth0/auth0-spa-js';
3
3
  /**
4
4
  * An authProvider which handles authentication via the Auth0 instance.
@@ -1 +1 @@
1
- {"version":3,"file":"authProvider.d.ts","sourceRoot":"","sources":["../src/authProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA8B,MAAM,SAAS,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,eAAO,MAAM,iBAAiB,WAClB,WAAW;uBAMI,MAAM;wBACL,MAAM;0BACJ,OAAO;MAIlC,YAoFD,CAAC"}
1
+ {"version":3,"file":"authProvider.d.ts","sourceRoot":"","sources":["../src/authProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA8B,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,eAAO,MAAM,iBAAiB,WAClB,WAAW,kEAKhB;IACC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC,KAGF,YAoFD,CAAC"}
@@ -34,7 +34,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
34
34
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
35
  }
36
36
  };
37
- import { PreviousLocationStorageKey } from 'ra-core';
37
+ import { PreviousLocationStorageKey } from 'react-admin';
38
38
  /**
39
39
  * An authProvider which handles authentication via the Auth0 instance.
40
40
  *
@@ -123,9 +123,9 @@ export var Auth0AuthProvider = function (client, _a) {
123
123
  },
124
124
  // called when the API returns an error
125
125
  checkError: function (_a) {
126
- var status = _a.status;
127
- return __awaiter(this, void 0, void 0, function () {
128
- return __generator(this, function (_b) {
126
+ return __awaiter(this, arguments, void 0, function (_b) {
127
+ var status = _b.status;
128
+ return __generator(this, function (_c) {
129
129
  if (status === 401 || status === 403) {
130
130
  throw new Error('Unauthorized');
131
131
  }
@@ -1,4 +1,4 @@
1
- import { fetchUtils } from 'ra-core';
1
+ import { fetchUtils } from 'react-admin';
2
2
  /**
3
3
  * An httpClient that adds authentication headers needed by Auth0 in all requests.
4
4
  * @param auth0Client the Auth0 client.
@@ -1 +1 @@
1
- {"version":3,"file":"httpClient.d.ts","sourceRoot":"","sources":["../src/httpClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC;;;;GAIG;AACH,eAAO,MAAM,UAAU,gBAAiB,GAAG,WAClC,GAAG,WACC,WAAW,OAAO,GAAG,SAAS;;;;;EAa1C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,UACjB,MAAM,GAAG,IAAI,WACX,WAAW,OAAO,GAAG,SAAS,KACxC,OASF,CAAC"}
1
+ {"version":3,"file":"httpClient.d.ts","sourceRoot":"","sources":["../src/httpClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;GAIG;AACH,eAAO,MAAM,UAAU,gBAAiB,GAAG,WAClC,GAAG,WACC,UAAU,CAAC,OAAO,GAAG,SAAS;;;;;EAa1C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,UACjB,MAAM,GAAG,IAAI,WACX,UAAU,CAAC,OAAO,GAAG,SAAS,KACxC,OASF,CAAC"}
package/esm/httpClient.js CHANGED
@@ -45,7 +45,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
45
45
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
46
  }
47
47
  };
48
- import { fetchUtils } from 'ra-core';
48
+ import { fetchUtils } from 'react-admin';
49
49
  /**
50
50
  * An httpClient that adds authentication headers needed by Auth0 in all requests.
51
51
  * @param auth0Client the Auth0 client.
@@ -1,4 +1,4 @@
1
- import { AuthProvider } from 'ra-core';
1
+ import { AuthProvider } from 'react-admin';
2
2
  import { Auth0Client } from '@auth0/auth0-spa-js';
3
3
  /**
4
4
  * An authProvider which handles authentication via the Auth0 instance.
@@ -1 +1 @@
1
- {"version":3,"file":"authProvider.d.ts","sourceRoot":"","sources":["../src/authProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA8B,MAAM,SAAS,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,eAAO,MAAM,iBAAiB,WAClB,WAAW;uBAMI,MAAM;wBACL,MAAM;0BACJ,OAAO;MAIlC,YAoFD,CAAC"}
1
+ {"version":3,"file":"authProvider.d.ts","sourceRoot":"","sources":["../src/authProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA8B,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,eAAO,MAAM,iBAAiB,WAClB,WAAW,kEAKhB;IACC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC,KAGF,YAoFD,CAAC"}
@@ -37,7 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.Auth0AuthProvider = void 0;
40
- var ra_core_1 = require("ra-core");
40
+ var react_admin_1 = require("react-admin");
41
41
  /**
42
42
  * An authProvider which handles authentication via the Auth0 instance.
43
43
  *
@@ -126,9 +126,9 @@ var Auth0AuthProvider = function (client, _a) {
126
126
  },
127
127
  // called when the API returns an error
128
128
  checkError: function (_a) {
129
- var status = _a.status;
130
- return __awaiter(this, void 0, void 0, function () {
131
- return __generator(this, function (_b) {
129
+ return __awaiter(this, arguments, void 0, function (_b) {
130
+ var status = _b.status;
131
+ return __generator(this, function (_c) {
132
132
  if (status === 401 || status === 403) {
133
133
  throw new Error('Unauthorized');
134
134
  }
@@ -149,7 +149,7 @@ var Auth0AuthProvider = function (client, _a) {
149
149
  return [2 /*return*/];
150
150
  }
151
151
  if (redirectOnCheckAuth) {
152
- localStorage.setItem(ra_core_1.PreviousLocationStorageKey, window.location.href);
152
+ localStorage.setItem(react_admin_1.PreviousLocationStorageKey, window.location.href);
153
153
  return [2 /*return*/, client.loginWithRedirect({
154
154
  authorizationParams: {
155
155
  redirect_uri: loginRedirectUri !== null && loginRedirectUri !== void 0 ? loginRedirectUri : "".concat(window.location.origin, "/auth-callback"),
@@ -1,4 +1,4 @@
1
- import { fetchUtils } from 'ra-core';
1
+ import { fetchUtils } from 'react-admin';
2
2
  /**
3
3
  * An httpClient that adds authentication headers needed by Auth0 in all requests.
4
4
  * @param auth0Client the Auth0 client.
@@ -1 +1 @@
1
- {"version":3,"file":"httpClient.d.ts","sourceRoot":"","sources":["../src/httpClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC;;;;GAIG;AACH,eAAO,MAAM,UAAU,gBAAiB,GAAG,WAClC,GAAG,WACC,WAAW,OAAO,GAAG,SAAS;;;;;EAa1C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,UACjB,MAAM,GAAG,IAAI,WACX,WAAW,OAAO,GAAG,SAAS,KACxC,OASF,CAAC"}
1
+ {"version":3,"file":"httpClient.d.ts","sourceRoot":"","sources":["../src/httpClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;GAIG;AACH,eAAO,MAAM,UAAU,gBAAiB,GAAG,WAClC,GAAG,WACC,UAAU,CAAC,OAAO,GAAG,SAAS;;;;;EAa1C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,UACjB,MAAM,GAAG,IAAI,WACX,UAAU,CAAC,OAAO,GAAG,SAAS,KACxC,OASF,CAAC"}
package/lib/httpClient.js CHANGED
@@ -48,7 +48,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
48
48
  };
49
49
  Object.defineProperty(exports, "__esModule", { value: true });
50
50
  exports.getAuth0Headers = exports.httpClient = void 0;
51
- var ra_core_1 = require("ra-core");
51
+ var react_admin_1 = require("react-admin");
52
52
  /**
53
53
  * An httpClient that adds authentication headers needed by Auth0 in all requests.
54
54
  * @param auth0Client the Auth0 client.
@@ -72,7 +72,7 @@ var httpClient = function (auth0Client) { return function (url, options) { retur
72
72
  return [3 /*break*/, 4];
73
73
  case 4:
74
74
  requestHeaders = (0, exports.getAuth0Headers)(token, options);
75
- return [2 /*return*/, ra_core_1.fetchUtils.fetchJson(url, __assign(__assign({}, options), { headers: requestHeaders }))];
75
+ return [2 /*return*/, react_admin_1.fetchUtils.fetchJson(url, __assign(__assign({}, options), { headers: requestHeaders }))];
76
76
  }
77
77
  });
78
78
  }); }; };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ra-auth-auth0",
3
- "version": "1.1.1",
3
+ "version": "2.0.0",
4
4
  "repository": "git@github.com:marmelab/ra-auth-auth0.git",
5
5
  "author": "Anthony Rimet <anthony@marmelab.com> (https://marmelab.com/)",
6
6
  "license": "MIT",
@@ -16,9 +16,9 @@
16
16
  "sideEffects": false,
17
17
  "peerDependencies": {
18
18
  "@auth0/auth0-spa-js": "^2.0.0",
19
- "ra-core": "^4.10.0",
20
- "react": "^16.9.0 || ^17.0.0 || ^18.0.0",
21
- "react-dom": "^16.9.0 || ^17.0.0 || ^18.0.0"
19
+ "react": "^18.0.0 || ^19.0.0",
20
+ "react-admin": "^5.1.1",
21
+ "react-dom": "^18.0.0 || ^19.0.0"
22
22
  },
23
23
  "scripts": {
24
24
  "build": "yarn run build-cjs && yarn run build-esm",
@@ -32,11 +32,11 @@
32
32
  "@types/jest": "^29.1.0",
33
33
  "jest": "^29.1.1",
34
34
  "jest-environment-jsdom": "^29.1.1",
35
- "react": "^18.2.0",
36
- "react-dom": "^18.2.0",
35
+ "react": "^18.3.1",
36
+ "react-dom": "^18.3.1",
37
37
  "rimraf": "^3.0.2",
38
38
  "ts-jest": "^29.0.3",
39
- "typescript": "^4.8.4"
39
+ "typescript": "^5.5.4"
40
40
  },
41
41
  "jest": {
42
42
  "preset": "ts-jest",
@@ -1,4 +1,4 @@
1
- import { AuthProvider, PreviousLocationStorageKey } from 'ra-core';
1
+ import { AuthProvider, PreviousLocationStorageKey } from 'react-admin';
2
2
  import { Auth0Client } from '@auth0/auth0-spa-js';
3
3
 
4
4
  /**
package/src/httpClient.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { fetchUtils } from 'ra-core';
1
+ import { fetchUtils } from 'react-admin';
2
2
 
3
3
  /**
4
4
  * An httpClient that adds authentication headers needed by Auth0 in all requests.