@scaleway/auth-scw 1.2.5 → 1.2.6
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/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/useAuthScw/AuthScwProvider.d.ts +1 -2
- package/dist/useAuthScw/AuthScwProvider.js +4 -5
- package/dist/useAuthScw/index.d.ts +2 -1
- package/dist/useAuthScw/useAuthScw.d.ts +2 -0
- package/dist/useAuthScw/useAuthScw.js +5 -0
- package/dist/zodSchemas.d.ts +6 -5
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { AuthStoreManager, createAuthStoreManager } from "./useAuthScw/authStore
|
|
|
3
3
|
import { EmptySession } from "./constants.js";
|
|
4
4
|
import { AudienceIdType, AuthScwContextType, EncodedJWT, StorageType } from "./types/index.js";
|
|
5
5
|
import "./useAuthScw/index.js";
|
|
6
|
-
import { AuthScwProvider
|
|
6
|
+
import { AuthScwProvider } from "./useAuthScw/AuthScwProvider.js";
|
|
7
|
+
import { useAuthScw } from "./useAuthScw/useAuthScw.js";
|
|
7
8
|
import "./useAuthScw/authStoreManager/index.js";
|
|
8
9
|
export { type AudienceIdType, type AuthScwContextType, AuthScwProvider, AuthStoreManager, COOKIE_AGE, DEFAULT_AUTH_SUFFIX_KEY, DOMAIN, EmptySession, type EncodedJWT, type StorageType, createAuthStoreManager, getUniqueHostnameString, useAuthScw };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EmptySession } from "./constants.js";
|
|
2
|
-
import { AuthScwProvider
|
|
2
|
+
import { AuthScwProvider } from "./useAuthScw/AuthScwProvider.js";
|
|
3
|
+
import { useAuthScw } from "./useAuthScw/useAuthScw.js";
|
|
3
4
|
import { AuthStoreManager, createAuthStoreManager } from "./useAuthScw/authStoreManager/authStoreManager.js";
|
|
4
5
|
import { COOKIE_AGE, DEFAULT_AUTH_SUFFIX_KEY, DOMAIN, getUniqueHostnameString } from "./useAuthScw/authStoreManager/constants.js";
|
|
5
6
|
export { AuthScwProvider, AuthStoreManager, COOKIE_AGE, DEFAULT_AUTH_SUFFIX_KEY, DOMAIN, EmptySession, createAuthStoreManager, getUniqueHostnameString, useAuthScw };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SingleXOR } from "../types/dist/index.js";
|
|
2
|
-
import {
|
|
2
|
+
import { ConfigAuthProvider, CookieOptions, OnError } from "../types/index.js";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
type CookieStorageOptions = {
|
|
5
5
|
storageType?: 'cookie';
|
|
@@ -22,6 +22,5 @@ export type AuthProviderParamType = ConfigAuthProvider & {
|
|
|
22
22
|
*/
|
|
23
23
|
migrateFromCookie?: boolean;
|
|
24
24
|
} & SingleXOR<CookieStorageOptions, LocalStorageOptions>;
|
|
25
|
-
export declare const useAuthScw: () => AuthScwContextType;
|
|
26
25
|
export declare const AuthScwProvider: ({ clientSettings, IamV1Alpha1, IamUnauthenticatedV1Alpha1, children, cookie, urlParamTokenName, onError, storageType, migrateFromCookie }: AuthProviderParamType) => import("react").JSX.Element;
|
|
27
26
|
export {};
|
|
@@ -3,11 +3,10 @@ import { createAuthStoreManager } from "./authStoreManager/authStoreManager.js";
|
|
|
3
3
|
import { clientSingleton } from "./createClient.js";
|
|
4
4
|
import { decodeToken, encodeToken, getStoredJWT, refreshSession } from "./helpers.js";
|
|
5
5
|
import { proxyJwt } from "./proxyJwt.js";
|
|
6
|
-
import {
|
|
6
|
+
import { AuthScwContext } from "./useAuthScw.js";
|
|
7
|
+
import { useCallback, useMemo, useState } from "react";
|
|
7
8
|
import { jsx } from "react/jsx-runtime";
|
|
8
9
|
// src/useAuthScw/AuthScwProvider.tsx
|
|
9
|
-
const AuthScwContext = createContext({});
|
|
10
|
-
const useAuthScw = () => useContext(AuthScwContext);
|
|
11
10
|
const AuthScwProvider = ({ clientSettings, IamV1Alpha1, IamUnauthenticatedV1Alpha1, children, cookie, urlParamTokenName, onError, storageType = "cookie", migrateFromCookie = false }) => {
|
|
12
11
|
const storeManager = useMemo(() => createAuthStoreManager({
|
|
13
12
|
storageType,
|
|
@@ -57,7 +56,7 @@ const AuthScwProvider = ({ clientSettings, IamV1Alpha1, IamUnauthenticatedV1Alph
|
|
|
57
56
|
const storedJWT = getStoredJWT(audienceId, storeManager);
|
|
58
57
|
if (storedJWT?.jwt) {
|
|
59
58
|
const { renewToken, token, jwt: currentJWT } = storedJWT;
|
|
60
|
-
if (currentJWT.expiresAt !== void 0 && !isExpired(new Date(currentJWT.expiresAt))) return {
|
|
59
|
+
if (currentJWT.expiresAt !== void 0 && currentJWT.expiresAt !== null && !isExpired(new Date(currentJWT.expiresAt))) return {
|
|
61
60
|
jwt: currentJWT,
|
|
62
61
|
renewToken,
|
|
63
62
|
source: "storage",
|
|
@@ -143,4 +142,4 @@ const AuthScwProvider = ({ clientSettings, IamV1Alpha1, IamUnauthenticatedV1Alph
|
|
|
143
142
|
children
|
|
144
143
|
});
|
|
145
144
|
};
|
|
146
|
-
export { AuthScwProvider
|
|
145
|
+
export { AuthScwProvider };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DEFAULT_AUTH_SUFFIX_KEY, getUniqueHostnameString } from "./authStoreManager/constants.js";
|
|
2
|
-
import { AuthScwProvider
|
|
2
|
+
import { AuthScwProvider } from "./AuthScwProvider.js";
|
|
3
|
+
import { useAuthScw } from "./useAuthScw.js";
|
|
3
4
|
import "./authStoreManager/index.js";
|
|
4
5
|
export { AuthScwProvider, useAuthScw };
|
package/dist/zodSchemas.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Iamv1alpha1 } from "./types/iam/index.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
type OptionalDate = string | Date | null | undefined;
|
|
3
4
|
type TransformJWT = Omit<Iamv1alpha1.JWT, 'createdAt' | 'updatedAt' | 'expiresAt' | 'srn'> & {
|
|
4
|
-
createdAt?:
|
|
5
|
-
updatedAt?:
|
|
6
|
-
expiresAt?:
|
|
7
|
-
srn?: string;
|
|
5
|
+
createdAt?: OptionalDate;
|
|
6
|
+
updatedAt?: OptionalDate;
|
|
7
|
+
expiresAt?: OptionalDate;
|
|
8
|
+
srn?: string | null;
|
|
8
9
|
};
|
|
9
10
|
type ValidateJWTSchema = {
|
|
10
|
-
jwt?: TransformJWT;
|
|
11
|
+
jwt?: TransformJWT | null;
|
|
11
12
|
token: string;
|
|
12
13
|
renewToken: string;
|
|
13
14
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scaleway/auth-scw",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"description": "Auth Scaleway",
|
|
5
5
|
"homepage": "https://github.com/scaleway/scaleway-lib/tree/main/packages/auth-scw",
|
|
6
6
|
"bugs": {
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@scaleway/sdk-iam": "2.22.0",
|
|
30
|
-
"cookie": "2.0.
|
|
30
|
+
"cookie": "2.0.2",
|
|
31
31
|
"date-fns": "4.4.0",
|
|
32
32
|
"zod": "4.6.7"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@scaleway/sdk-client": "2.
|
|
35
|
+
"@scaleway/sdk-client": "2.17.0",
|
|
36
36
|
"@scaleway/types": "1.2.0",
|
|
37
37
|
"@types/react": "19.3.0",
|
|
38
38
|
"react": "19.3.1"
|