muffin-admin 11.5.0 → 11.6.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/dist/authprovider.d.ts +1 -1
- package/dist/authprovider.js +10 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/authprovider.ts +101 -86
- package/src/index.tsx +1 -1
package/dist/authprovider.d.ts
CHANGED
package/dist/authprovider.js
CHANGED
|
@@ -9,8 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import Cookies from "js-cookie";
|
|
11
11
|
import { findBuilder, makeRequest, requestHeaders, setupAdmin } from ".";
|
|
12
|
-
setupAdmin(["auth-storage-get"], ({ storage, storageName }) => () => storage == "localstorage"
|
|
13
|
-
|
|
12
|
+
setupAdmin(["auth-storage-get"], ({ storage, storageName }) => () => storage == "localstorage"
|
|
13
|
+
? localStorage.getItem(storageName)
|
|
14
|
+
: Cookies.get(storageName));
|
|
15
|
+
setupAdmin(["auth-storage-set"], ({ storage }) => (name, value, requestOnly) => {
|
|
14
16
|
if (storage == "localstorage") {
|
|
15
17
|
localStorage.setItem(name, value);
|
|
16
18
|
requestHeaders["Authorization"] = value;
|
|
@@ -19,11 +21,15 @@ setupAdmin(["auth-storage-set"], ({ storage }) => (name, value) => {
|
|
|
19
21
|
Cookies.set(name, value);
|
|
20
22
|
});
|
|
21
23
|
export function MuffinAuthProvider(props) {
|
|
22
|
-
const { identityURL, authorizeURL, logoutURL, required, storageName } = props;
|
|
24
|
+
const { identityURL, authorizeURL, logoutURL, required, storageName, storage, } = props;
|
|
23
25
|
const authGet = findBuilder(["auth-storage-get"])(props);
|
|
24
26
|
const authSet = findBuilder(["auth-storage-set"])(props);
|
|
25
27
|
// Initialize request headers
|
|
26
|
-
|
|
28
|
+
if (storage == "localstorage") {
|
|
29
|
+
const token = authGet(storageName);
|
|
30
|
+
if (token)
|
|
31
|
+
requestHeaders["Authorization"] = token;
|
|
32
|
+
}
|
|
27
33
|
const getIdentity = () => __awaiter(this, void 0, void 0, function* () {
|
|
28
34
|
if (identityURL) {
|
|
29
35
|
const { json } = yield makeRequest(identityURL);
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED