@shopsbuilder/auth-sdk 1.2.9 → 1.2.10
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/SaleorAuthClient.d.mts +8 -1
- package/dist/SaleorAuthClient.d.ts +8 -1
- package/dist/SaleorAuthClient.js +4 -2
- package/dist/SaleorAuthClient.mjs +1 -1
- package/dist/{chunk-GFXR244N.mjs → chunk-3UGMWVQN.mjs} +4 -2
- package/dist/{chunk-WJVMUY3P.mjs → chunk-FY2QDW7J.mjs} +5 -4
- package/dist/index.js +4 -2
- package/dist/index.mjs +1 -1
- package/dist/react/SaleorAuthProvider.mjs +1 -1
- package/dist/react/context.mjs +1 -1
- package/dist/react/index.js +5 -4
- package/dist/react/index.mjs +2 -2
- package/dist/react/useAuthChange.d.mts +2 -1
- package/dist/react/useAuthChange.d.ts +2 -1
- package/dist/react/useAuthChange.js +5 -4
- package/dist/react/useAuthChange.mjs +1 -1
- package/package.json +1 -1
|
@@ -3,6 +3,13 @@ import { StorageRepository, FetchWithAdditionalParams, PasswordResetVariables, P
|
|
|
3
3
|
interface SaleorAuthClientProps {
|
|
4
4
|
onAuthRefresh?: (isAuthenticating: boolean) => void;
|
|
5
5
|
saleorApiUrl: string;
|
|
6
|
+
/**
|
|
7
|
+
* Override the key prefix used for storage/cookies.
|
|
8
|
+
* Defaults to `saleorApiUrl`. Useful when the server uses a different
|
|
9
|
+
* internal URL (e.g. `http://api:8000`) while the client uses the public
|
|
10
|
+
* URL — pass the client URL here so cookie names match.
|
|
11
|
+
*/
|
|
12
|
+
storageKeyPrefix?: string;
|
|
6
13
|
refreshTokenStorage?: StorageRepository;
|
|
7
14
|
accessTokenStorage?: StorageRepository;
|
|
8
15
|
tokenGracePeriod?: number;
|
|
@@ -33,7 +40,7 @@ declare class SaleorAuthClient {
|
|
|
33
40
|
* }, [])
|
|
34
41
|
* ```
|
|
35
42
|
*/
|
|
36
|
-
constructor({ saleorApiUrl, refreshTokenStorage, accessTokenStorage, onAuthRefresh, tokenGracePeriod, defaultRequestInit, }: SaleorAuthClientProps);
|
|
43
|
+
constructor({ saleorApiUrl, storageKeyPrefix, refreshTokenStorage, accessTokenStorage, onAuthRefresh, tokenGracePeriod, defaultRequestInit, }: SaleorAuthClientProps);
|
|
37
44
|
cleanup: () => void;
|
|
38
45
|
private runAuthorizedRequest;
|
|
39
46
|
private handleRequestWithTokenRefresh;
|
|
@@ -3,6 +3,13 @@ import { StorageRepository, FetchWithAdditionalParams, PasswordResetVariables, P
|
|
|
3
3
|
interface SaleorAuthClientProps {
|
|
4
4
|
onAuthRefresh?: (isAuthenticating: boolean) => void;
|
|
5
5
|
saleorApiUrl: string;
|
|
6
|
+
/**
|
|
7
|
+
* Override the key prefix used for storage/cookies.
|
|
8
|
+
* Defaults to `saleorApiUrl`. Useful when the server uses a different
|
|
9
|
+
* internal URL (e.g. `http://api:8000`) while the client uses the public
|
|
10
|
+
* URL — pass the client URL here so cookie names match.
|
|
11
|
+
*/
|
|
12
|
+
storageKeyPrefix?: string;
|
|
6
13
|
refreshTokenStorage?: StorageRepository;
|
|
7
14
|
accessTokenStorage?: StorageRepository;
|
|
8
15
|
tokenGracePeriod?: number;
|
|
@@ -33,7 +40,7 @@ declare class SaleorAuthClient {
|
|
|
33
40
|
* }, [])
|
|
34
41
|
* ```
|
|
35
42
|
*/
|
|
36
|
-
constructor({ saleorApiUrl, refreshTokenStorage, accessTokenStorage, onAuthRefresh, tokenGracePeriod, defaultRequestInit, }: SaleorAuthClientProps);
|
|
43
|
+
constructor({ saleorApiUrl, storageKeyPrefix, refreshTokenStorage, accessTokenStorage, onAuthRefresh, tokenGracePeriod, defaultRequestInit, }: SaleorAuthClientProps);
|
|
37
44
|
cleanup: () => void;
|
|
38
45
|
private runAuthorizedRequest;
|
|
39
46
|
private handleRequestWithTokenRefresh;
|
package/dist/SaleorAuthClient.js
CHANGED
|
@@ -294,6 +294,7 @@ var SaleorAuthClient = class {
|
|
|
294
294
|
*/
|
|
295
295
|
constructor({
|
|
296
296
|
saleorApiUrl,
|
|
297
|
+
storageKeyPrefix,
|
|
297
298
|
refreshTokenStorage,
|
|
298
299
|
accessTokenStorage,
|
|
299
300
|
onAuthRefresh,
|
|
@@ -306,10 +307,11 @@ var SaleorAuthClient = class {
|
|
|
306
307
|
}
|
|
307
308
|
this.onAuthRefresh = onAuthRefresh;
|
|
308
309
|
this.saleorApiUrl = saleorApiUrl;
|
|
310
|
+
const keyPrefix = storageKeyPrefix ?? saleorApiUrl;
|
|
309
311
|
const refreshTokenRepo = refreshTokenStorage ?? (typeof window !== "undefined" ? window.localStorage : void 0);
|
|
310
|
-
this.refreshTokenStorage = refreshTokenRepo ? new SaleorRefreshTokenStorageHandler(refreshTokenRepo,
|
|
312
|
+
this.refreshTokenStorage = refreshTokenRepo ? new SaleorRefreshTokenStorageHandler(refreshTokenRepo, keyPrefix) : null;
|
|
311
313
|
const accessTokenRepo = accessTokenStorage ?? getInMemoryAccessTokenStorage();
|
|
312
|
-
this.accessTokenStorage = new SaleorAccessTokenStorageHandler(accessTokenRepo,
|
|
314
|
+
this.accessTokenStorage = new SaleorAccessTokenStorageHandler(accessTokenRepo, keyPrefix);
|
|
313
315
|
}
|
|
314
316
|
cleanup = () => {
|
|
315
317
|
this.refreshTokenStorage?.cleanup();
|
|
@@ -47,6 +47,7 @@ var SaleorAuthClient = class {
|
|
|
47
47
|
*/
|
|
48
48
|
constructor({
|
|
49
49
|
saleorApiUrl,
|
|
50
|
+
storageKeyPrefix,
|
|
50
51
|
refreshTokenStorage,
|
|
51
52
|
accessTokenStorage,
|
|
52
53
|
onAuthRefresh,
|
|
@@ -59,10 +60,11 @@ var SaleorAuthClient = class {
|
|
|
59
60
|
}
|
|
60
61
|
this.onAuthRefresh = onAuthRefresh;
|
|
61
62
|
this.saleorApiUrl = saleorApiUrl;
|
|
63
|
+
const keyPrefix = storageKeyPrefix ?? saleorApiUrl;
|
|
62
64
|
const refreshTokenRepo = refreshTokenStorage ?? (typeof window !== "undefined" ? window.localStorage : void 0);
|
|
63
|
-
this.refreshTokenStorage = refreshTokenRepo ? new SaleorRefreshTokenStorageHandler(refreshTokenRepo,
|
|
65
|
+
this.refreshTokenStorage = refreshTokenRepo ? new SaleorRefreshTokenStorageHandler(refreshTokenRepo, keyPrefix) : null;
|
|
64
66
|
const accessTokenRepo = accessTokenStorage ?? getInMemoryAccessTokenStorage();
|
|
65
|
-
this.accessTokenStorage = new SaleorAccessTokenStorageHandler(accessTokenRepo,
|
|
67
|
+
this.accessTokenStorage = new SaleorAccessTokenStorageHandler(accessTokenRepo, keyPrefix);
|
|
66
68
|
}
|
|
67
69
|
cleanup = () => {
|
|
68
70
|
this.refreshTokenStorage?.cleanup();
|
|
@@ -4,9 +4,10 @@ import {
|
|
|
4
4
|
|
|
5
5
|
// src/react/useAuthChange.ts
|
|
6
6
|
import { useEffect } from "react";
|
|
7
|
-
var useAuthChange = ({ saleorApiUrl, onSignedOut, onSignedIn }) => {
|
|
7
|
+
var useAuthChange = ({ saleorApiUrl, storageKeyPrefix, onSignedOut, onSignedIn }) => {
|
|
8
|
+
const keyPrefix = storageKeyPrefix ?? saleorApiUrl;
|
|
8
9
|
const handleAuthChange = (event) => {
|
|
9
|
-
const isCustomAuthEvent = event?.type === getStorageAuthEventKey(
|
|
10
|
+
const isCustomAuthEvent = event?.type === getStorageAuthEventKey(keyPrefix);
|
|
10
11
|
if (!isCustomAuthEvent) {
|
|
11
12
|
return;
|
|
12
13
|
}
|
|
@@ -21,9 +22,9 @@ var useAuthChange = ({ saleorApiUrl, onSignedOut, onSignedIn }) => {
|
|
|
21
22
|
if (typeof window === "undefined") {
|
|
22
23
|
return;
|
|
23
24
|
}
|
|
24
|
-
window.addEventListener(getStorageAuthEventKey(
|
|
25
|
+
window.addEventListener(getStorageAuthEventKey(keyPrefix), handleAuthChange);
|
|
25
26
|
return () => {
|
|
26
|
-
window.removeEventListener(getStorageAuthEventKey(
|
|
27
|
+
window.removeEventListener(getStorageAuthEventKey(keyPrefix), handleAuthChange);
|
|
27
28
|
};
|
|
28
29
|
}, []);
|
|
29
30
|
};
|
package/dist/index.js
CHANGED
|
@@ -297,6 +297,7 @@ var SaleorAuthClient = class {
|
|
|
297
297
|
*/
|
|
298
298
|
constructor({
|
|
299
299
|
saleorApiUrl,
|
|
300
|
+
storageKeyPrefix,
|
|
300
301
|
refreshTokenStorage,
|
|
301
302
|
accessTokenStorage,
|
|
302
303
|
onAuthRefresh,
|
|
@@ -309,10 +310,11 @@ var SaleorAuthClient = class {
|
|
|
309
310
|
}
|
|
310
311
|
this.onAuthRefresh = onAuthRefresh;
|
|
311
312
|
this.saleorApiUrl = saleorApiUrl;
|
|
313
|
+
const keyPrefix = storageKeyPrefix ?? saleorApiUrl;
|
|
312
314
|
const refreshTokenRepo = refreshTokenStorage ?? (typeof window !== "undefined" ? window.localStorage : void 0);
|
|
313
|
-
this.refreshTokenStorage = refreshTokenRepo ? new SaleorRefreshTokenStorageHandler(refreshTokenRepo,
|
|
315
|
+
this.refreshTokenStorage = refreshTokenRepo ? new SaleorRefreshTokenStorageHandler(refreshTokenRepo, keyPrefix) : null;
|
|
314
316
|
const accessTokenRepo = accessTokenStorage ?? getInMemoryAccessTokenStorage();
|
|
315
|
-
this.accessTokenStorage = new SaleorAccessTokenStorageHandler(accessTokenRepo,
|
|
317
|
+
this.accessTokenStorage = new SaleorAccessTokenStorageHandler(accessTokenRepo, keyPrefix);
|
|
316
318
|
}
|
|
317
319
|
cleanup = () => {
|
|
318
320
|
this.refreshTokenStorage?.cleanup();
|
package/dist/index.mjs
CHANGED
package/dist/react/context.mjs
CHANGED
package/dist/react/index.js
CHANGED
|
@@ -177,9 +177,10 @@ var SaleorAuthProvider = ({ children, client }) => {
|
|
|
177
177
|
|
|
178
178
|
// src/react/useAuthChange.ts
|
|
179
179
|
var import_react2 = require("react");
|
|
180
|
-
var useAuthChange = ({ saleorApiUrl, onSignedOut, onSignedIn }) => {
|
|
180
|
+
var useAuthChange = ({ saleorApiUrl, storageKeyPrefix, onSignedOut, onSignedIn }) => {
|
|
181
|
+
const keyPrefix = storageKeyPrefix ?? saleorApiUrl;
|
|
181
182
|
const handleAuthChange = (event) => {
|
|
182
|
-
const isCustomAuthEvent = event?.type === getStorageAuthEventKey(
|
|
183
|
+
const isCustomAuthEvent = event?.type === getStorageAuthEventKey(keyPrefix);
|
|
183
184
|
if (!isCustomAuthEvent) {
|
|
184
185
|
return;
|
|
185
186
|
}
|
|
@@ -194,9 +195,9 @@ var useAuthChange = ({ saleorApiUrl, onSignedOut, onSignedIn }) => {
|
|
|
194
195
|
if (typeof window === "undefined") {
|
|
195
196
|
return;
|
|
196
197
|
}
|
|
197
|
-
window.addEventListener(getStorageAuthEventKey(
|
|
198
|
+
window.addEventListener(getStorageAuthEventKey(keyPrefix), handleAuthChange);
|
|
198
199
|
return () => {
|
|
199
|
-
window.removeEventListener(getStorageAuthEventKey(
|
|
200
|
+
window.removeEventListener(getStorageAuthEventKey(keyPrefix), handleAuthChange);
|
|
200
201
|
};
|
|
201
202
|
}, []);
|
|
202
203
|
};
|
package/dist/react/index.mjs
CHANGED
|
@@ -8,11 +8,11 @@ import {
|
|
|
8
8
|
} from "../chunk-NAQNA6DI.mjs";
|
|
9
9
|
import {
|
|
10
10
|
useAuthChange
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-FY2QDW7J.mjs";
|
|
12
12
|
import {
|
|
13
13
|
useSaleorExternalAuth
|
|
14
14
|
} from "../chunk-Q3UFWDCC.mjs";
|
|
15
|
-
import "../chunk-
|
|
15
|
+
import "../chunk-3UGMWVQN.mjs";
|
|
16
16
|
import "../chunk-B326YIV6.mjs";
|
|
17
17
|
import "../chunk-263DHBMK.mjs";
|
|
18
18
|
import "../chunk-T35JF4IS.mjs";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
interface UseAuthChangeProps {
|
|
2
2
|
saleorApiUrl: string;
|
|
3
|
+
storageKeyPrefix?: string;
|
|
3
4
|
onSignedIn?: () => void;
|
|
4
5
|
onSignedOut?: () => void;
|
|
5
6
|
}
|
|
6
|
-
declare const useAuthChange: ({ saleorApiUrl, onSignedOut, onSignedIn }: UseAuthChangeProps) => void;
|
|
7
|
+
declare const useAuthChange: ({ saleorApiUrl, storageKeyPrefix, onSignedOut, onSignedIn }: UseAuthChangeProps) => void;
|
|
7
8
|
|
|
8
9
|
export { useAuthChange };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
interface UseAuthChangeProps {
|
|
2
2
|
saleorApiUrl: string;
|
|
3
|
+
storageKeyPrefix?: string;
|
|
3
4
|
onSignedIn?: () => void;
|
|
4
5
|
onSignedOut?: () => void;
|
|
5
6
|
}
|
|
6
|
-
declare const useAuthChange: ({ saleorApiUrl, onSignedOut, onSignedIn }: UseAuthChangeProps) => void;
|
|
7
|
+
declare const useAuthChange: ({ saleorApiUrl, storageKeyPrefix, onSignedOut, onSignedIn }: UseAuthChangeProps) => void;
|
|
7
8
|
|
|
8
9
|
export { useAuthChange };
|
|
@@ -29,9 +29,10 @@ var import_react = require("react");
|
|
|
29
29
|
var getStorageAuthEventKey = (prefix) => [prefix, "saleor_storage_auth_change"].filter(Boolean).join("+");
|
|
30
30
|
|
|
31
31
|
// src/react/useAuthChange.ts
|
|
32
|
-
var useAuthChange = ({ saleorApiUrl, onSignedOut, onSignedIn }) => {
|
|
32
|
+
var useAuthChange = ({ saleorApiUrl, storageKeyPrefix, onSignedOut, onSignedIn }) => {
|
|
33
|
+
const keyPrefix = storageKeyPrefix ?? saleorApiUrl;
|
|
33
34
|
const handleAuthChange = (event) => {
|
|
34
|
-
const isCustomAuthEvent = event?.type === getStorageAuthEventKey(
|
|
35
|
+
const isCustomAuthEvent = event?.type === getStorageAuthEventKey(keyPrefix);
|
|
35
36
|
if (!isCustomAuthEvent) {
|
|
36
37
|
return;
|
|
37
38
|
}
|
|
@@ -46,9 +47,9 @@ var useAuthChange = ({ saleorApiUrl, onSignedOut, onSignedIn }) => {
|
|
|
46
47
|
if (typeof window === "undefined") {
|
|
47
48
|
return;
|
|
48
49
|
}
|
|
49
|
-
window.addEventListener(getStorageAuthEventKey(
|
|
50
|
+
window.addEventListener(getStorageAuthEventKey(keyPrefix), handleAuthChange);
|
|
50
51
|
return () => {
|
|
51
|
-
window.removeEventListener(getStorageAuthEventKey(
|
|
52
|
+
window.removeEventListener(getStorageAuthEventKey(keyPrefix), handleAuthChange);
|
|
52
53
|
};
|
|
53
54
|
}, []);
|
|
54
55
|
};
|