@scaleway/auth-scw 1.0.2 → 1.0.4

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.
@@ -1,5 +1,4 @@
1
1
  import { EncodedJWT } from "./types/index.js";
2
2
  //#region src/constants.d.ts
3
- declare const EmptySession: NonNullable<EncodedJWT>;
4
- //#endregion
5
- export { EmptySession };
3
+ export declare const EmptySession: NonNullable<EncodedJWT>;
4
+ //#endregion
@@ -1,8 +1,7 @@
1
1
  import { API, DeleteJWTRequest, EncodedJWT, JWT, UnauthenticatedAPI, UnauthenticatedApiRenewJWTRequest } from "./types.js";
2
2
  //#region src/types/iam/index.d.ts
3
- declare namespace Iamv1alpha1 {
3
+ export declare namespace Iamv1alpha1 {
4
4
  export type { API, UnauthenticatedAPI };
5
5
  export type { DeleteJWTRequest, EncodedJWT, JWT, UnauthenticatedApiRenewJWTRequest };
6
6
  }
7
- //#endregion
8
- export { Iamv1alpha1 };
7
+ //#endregion
@@ -1,10 +1,10 @@
1
1
  import { API } from "@scaleway/sdk-client";
2
2
  import { Iamv1alpha1 } from "@scaleway/sdk-iam";
3
3
  //#region src/types/iam/types.d.ts
4
- type JWT = Iamv1alpha1.JWT;
5
- type EncodedJWT = Iamv1alpha1.EncodedJWT;
6
- type DeleteJWTRequest = Iamv1alpha1.DeleteJWTRequest;
7
- type UnauthenticatedApiRenewJWTRequest = {
4
+ export type JWT = Iamv1alpha1.JWT;
5
+ export type EncodedJWT = Iamv1alpha1.EncodedJWT;
6
+ export type DeleteJWTRequest = Iamv1alpha1.DeleteJWTRequest;
7
+ export type UnauthenticatedApiRenewJWTRequest = {
8
8
  /**
9
9
  * The JWT ID of the JWT to renew.
10
10
  */
@@ -30,7 +30,7 @@ declare class API$1 extends API {
30
30
  /**
31
31
  * Unauthenticated API.
32
32
  */
33
- declare class UnauthenticatedAPI extends API {
33
+ export declare class UnauthenticatedAPI extends API {
34
34
  /**
35
35
  * Renew a JWT.
36
36
  *
@@ -40,4 +40,4 @@ declare class UnauthenticatedAPI extends API {
40
40
  renewJWT: (request: Readonly<UnauthenticatedApiRenewJWTRequest>) => Promise<EncodedJWT>;
41
41
  }
42
42
  //#endregion
43
- export { API$1 as API, DeleteJWTRequest, EncodedJWT, JWT, UnauthenticatedAPI, UnauthenticatedApiRenewJWTRequest };
43
+ export { API$1 as API };
@@ -3,9 +3,9 @@ import { audienceIdSchema, jwtSchema } from "../zodSchemas.js";
3
3
  import { z } from "zod";
4
4
  import { API, Client, Settings } from "@scaleway/sdk-client";
5
5
  //#region src/types/index.d.ts
6
- type EncodedJWT = z.infer<typeof jwtSchema>;
7
- type AudienceIdType = z.infer<typeof audienceIdSchema>;
8
- type OnError = (onError: {
6
+ export type EncodedJWT = z.infer<typeof jwtSchema>;
7
+ export type AudienceIdType = z.infer<typeof audienceIdSchema>;
8
+ export type OnError = (onError: {
9
9
  title: string;
10
10
  error: unknown;
11
11
  extra?: Record<string, unknown>;
@@ -14,7 +14,7 @@ type GetJWT = (audienceId?: string) => Promise<(EncodedJWT & {
14
14
  source: 'refreshSession' | 'cookie';
15
15
  }) | undefined>;
16
16
  type GetJwtTokenResponse = NonNullable<Awaited<ReturnType<GetJWT>>>['token'] | undefined;
17
- type AuthScwContextType = {
17
+ export type AuthScwContextType = {
18
18
  audienceId?: string;
19
19
  setAudienceId: (audienceId: string) => void;
20
20
  jti?: string;
@@ -26,24 +26,23 @@ type AuthScwContextType = {
26
26
  logout: () => void;
27
27
  authenticated: boolean;
28
28
  };
29
- declare class IamV1alpha1API extends API {
29
+ export declare class IamV1alpha1API extends API {
30
30
  deleteJWT: Iamv1alpha1.API['deleteJWT'];
31
31
  }
32
- declare class IamV1alpha1UnauthenticatedAPI extends API {
32
+ export declare class IamV1alpha1UnauthenticatedAPI extends API {
33
33
  renewJWT: Iamv1alpha1.UnauthenticatedAPI['renewJWT'];
34
34
  }
35
- type ConfigurationClientAPIs = {
35
+ export type ConfigurationClientAPIs = {
36
36
  IamV1Alpha1: new (client: Client) => IamV1alpha1API;
37
37
  IamUnauthenticatedV1Alpha1: new (client: Client) => IamV1alpha1UnauthenticatedAPI;
38
38
  };
39
- type ConfigAuthProvider = {
39
+ export type ConfigAuthProvider = {
40
40
  clientSettings: Settings;
41
41
  } & ConfigurationClientAPIs;
42
- type CookieConfigType = {
42
+ export type CookieConfigType = {
43
43
  httpOnly: boolean;
44
44
  path: string;
45
45
  sameSite: 'lax' | 'none' | 'strict' | boolean | undefined;
46
46
  secure: boolean;
47
47
  };
48
- //#endregion
49
- export { AudienceIdType, AuthScwContextType, ConfigAuthProvider, ConfigurationClientAPIs, CookieConfigType, EncodedJWT, IamV1alpha1API, IamV1alpha1UnauthenticatedAPI, OnError };
48
+ //#endregion
@@ -1,14 +1,13 @@
1
1
  import { AuthScwContextType, ConfigAuthProvider, CookieConfigType, OnError } from "../types/index.js";
2
2
  import { ReactNode } from "react";
3
3
  //#region src/useAuthScw/AuthScwProvider.d.ts
4
- type AuthProviderParamType = ConfigAuthProvider & {
4
+ export type AuthProviderParamType = ConfigAuthProvider & {
5
5
  children: ReactNode;
6
6
  cookieSuffix: string;
7
7
  urlParamTokenName: string;
8
8
  onError?: OnError;
9
9
  cookieConfig?: CookieConfigType;
10
10
  };
11
- declare const useAuthScw: () => AuthScwContextType;
12
- declare const AuthScwProvider: ({ clientSettings, IamV1Alpha1, IamUnauthenticatedV1Alpha1, children, cookieSuffix, cookieConfig, urlParamTokenName, onError }: AuthProviderParamType) => import("react").JSX.Element;
13
- //#endregion
14
- export { AuthProviderParamType, AuthScwProvider, useAuthScw };
11
+ export declare const useAuthScw: () => AuthScwContextType;
12
+ export declare const AuthScwProvider: ({ clientSettings, IamV1Alpha1, IamUnauthenticatedV1Alpha1, children, cookieSuffix, cookieConfig, urlParamTokenName, onError }: AuthProviderParamType) => import("react").JSX.Element;
13
+ //#endregion
@@ -96,7 +96,7 @@ const AuthScwProvider = ({ clientSettings, IamV1Alpha1, IamUnauthenticatedV1Alph
96
96
  if (cookieJWT?.jwt) return cookieJWT.jwt.jti;
97
97
  }
98
98
  }, [currentAudienceId]);
99
- const isAuthenticated = useMemo(() => !!(currentAudienceId && getCookieJWT(currentAudienceId)), [currentAudienceId]);
99
+ const isAuthenticated = useMemo(() => Boolean(currentAudienceId && getCookieJWT(currentAudienceId)), [currentAudienceId]);
100
100
  const setAudienceId = useCallback((audienceId) => {
101
101
  setCurrentAudienceId(audienceId);
102
102
  }, []);
@@ -1,7 +1,7 @@
1
1
  import { AudienceIdType, EncodedJWT } from "../types/index.js";
2
2
  //#region src/useAuthScw/authStoreManager.d.ts
3
3
  declare const getUniqueHostnameString: (inputString: string) => string;
4
- declare const AuthStoreManager: {
4
+ export declare const AuthStoreManager: {
5
5
  COOKIE_AGE: number;
6
6
  DOMAIN: string;
7
7
  deleteAllJwts(): void;
@@ -22,5 +22,4 @@ declare const AuthStoreManager: {
22
22
  typeGuardAudienceId(untypedObject: unknown): untypedObject is AudienceIdType;
23
23
  typeGuardJWT(untypedObject: unknown): untypedObject is EncodedJWT;
24
24
  };
25
- //#endregion
26
- export { AuthStoreManager };
25
+ //#endregion
@@ -10,7 +10,7 @@ const clientSingleton = {
10
10
  this.clientSettings = clientSettings;
11
11
  },
12
12
  createClient({ getAsyncToken }) {
13
- if (!this.IamV1Alpha1 || !this.IamUnauthenticatedV1Alpha1 || !this.clientSettings) throw "You must set apis and client settings to use package: auth-scw";
13
+ if (!this.IamV1Alpha1 || !this.IamUnauthenticatedV1Alpha1 || !this.clientSettings) throw new Error("You must set apis and client settings to use package: auth-scw");
14
14
  const client = createAdvancedClient(withProfile(this.clientSettings), withAdditionalInterceptors([...this.clientSettings.interceptors, { request: async ({ request }) => getAsyncToken ? addAsyncHeaderInterceptor(SESSION_HEADER_KEY, getAsyncToken)({ request }) : request }]));
15
15
  const iamv1alpha1API = new this.IamV1Alpha1(client);
16
16
  const iamUnauthenticatedV1Alpha1API = new this.IamUnauthenticatedV1Alpha1(client);
@@ -2,7 +2,7 @@ import { AuthStoreManager } from "./authStoreManager.js";
2
2
  import { clientSingleton } from "./createClient.js";
3
3
  import { Errors } from "@scaleway/sdk-client";
4
4
  //#region src/useAuthScw/helpers.ts
5
- let refreshSessionPromise;
5
+ let refreshSessionPromise = void 0;
6
6
  const refreshSession = ({ paramsRenewRequest, setJWT, onError }) => {
7
7
  if (refreshSessionPromise !== void 0) return refreshSessionPromise;
8
8
  const { renewJWT } = clientSingleton.createClient({});
@@ -11,9 +11,8 @@ type ValidateJWTSchema = {
11
11
  token: string;
12
12
  renewToken: string;
13
13
  };
14
- declare const jwtSchema: z.ZodType<ValidateJWTSchema, unknown, z.core.$ZodTypeInternals<ValidateJWTSchema, unknown>>;
15
- declare const audienceIdSchema: z.ZodObject<{
14
+ export declare const jwtSchema: z.ZodType<ValidateJWTSchema, unknown, z.core.$ZodTypeInternals<ValidateJWTSchema, unknown>>;
15
+ export declare const audienceIdSchema: z.ZodObject<{
16
16
  audienceId: z.ZodString;
17
17
  }, z.core.$strip>;
18
- //#endregion
19
- export { audienceIdSchema, jwtSchema };
18
+ //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scaleway/auth-scw",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Auth Scaleway",
5
5
  "homepage": "https://github.com/scaleway/scaleway-lib/tree/main/packages/auth-scw",
6
6
  "bugs": {
@@ -28,17 +28,17 @@
28
28
  "dependencies": {
29
29
  "cookie": "2.0.1",
30
30
  "date-fns": "4.4.0",
31
- "zod": "4.5.4"
31
+ "zod": "4.6.2"
32
32
  },
33
33
  "devDependencies": {
34
- "@scaleway/sdk-client": "2.6.0",
35
- "@scaleway/sdk-iam": "2.14.0",
36
- "@types/react": "19.2.18",
37
- "react": "19.2.8"
34
+ "@scaleway/sdk-client": "2.8.0",
35
+ "@scaleway/sdk-iam": "2.15.0",
36
+ "@types/react": "19.3.0",
37
+ "react": "19.3.0"
38
38
  },
39
39
  "peerDependencies": {
40
- "@scaleway/sdk-client": "2.6.0",
41
- "@scaleway/sdk-iam": "2.14.0",
40
+ "@scaleway/sdk-client": "2.8.0",
41
+ "@scaleway/sdk-iam": "2.15.0",
42
42
  "react": ">=18.0"
43
43
  },
44
44
  "scripts": {