@scaleway/auth-scw 1.2.3 → 1.2.5

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,4 +1,2 @@
1
1
  import { EncodedJWT } from "./types/index.js";
2
- //#region src/constants.d.ts
3
- export declare const EmptySession: NonNullable<EncodedJWT>;
4
- //#endregion
2
+ export declare const EmptySession: NonNullable<EncodedJWT>;
package/dist/constants.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/constants.ts
1
+ // src/constants.ts
2
2
  const EmptySession = {
3
3
  jwt: {
4
4
  audienceId: "",
@@ -20,5 +20,4 @@ const COOKIE_CONFIG = {
20
20
  sameSite: "strict",
21
21
  secure: true
22
22
  };
23
- //#endregion
24
23
  export { COOKIE_CONFIG, EmptySession };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { COOKIE_AGE, DEFAULT_AUTH_SUFFIX_KEY, DOMAIN, getUniqueHostnameString } from "./useAuthScw/authStoreManager/constants.js";
2
2
  import { AuthStoreManager, createAuthStoreManager } from "./useAuthScw/authStoreManager/authStoreManager.js";
3
- import "./useAuthScw/authStoreManager/index.js";
4
- import { AudienceIdType, AuthScwContextType, EncodedJWT, StorageType } from "./types/index.js";
5
3
  import { EmptySession } from "./constants.js";
6
- import { AuthScwProvider, useAuthScw } from "./useAuthScw/AuthScwProvider.js";
4
+ import { AudienceIdType, AuthScwContextType, EncodedJWT, StorageType } from "./types/index.js";
7
5
  import "./useAuthScw/index.js";
6
+ import { AuthScwProvider, useAuthScw } from "./useAuthScw/AuthScwProvider.js";
7
+ import "./useAuthScw/authStoreManager/index.js";
8
8
  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,5 @@
1
1
  import { EmptySession } from "./constants.js";
2
- import { COOKIE_AGE, DEFAULT_AUTH_SUFFIX_KEY, DOMAIN, getUniqueHostnameString } from "./useAuthScw/authStoreManager/constants.js";
3
- import { AuthStoreManager, createAuthStoreManager } from "./useAuthScw/authStoreManager/authStoreManager.js";
4
2
  import { AuthScwProvider, useAuthScw } from "./useAuthScw/AuthScwProvider.js";
3
+ import { AuthStoreManager, createAuthStoreManager } from "./useAuthScw/authStoreManager/authStoreManager.js";
4
+ import { COOKIE_AGE, DEFAULT_AUTH_SUFFIX_KEY, DOMAIN, getUniqueHostnameString } from "./useAuthScw/authStoreManager/constants.js";
5
5
  export { AuthScwProvider, AuthStoreManager, COOKIE_AGE, DEFAULT_AUTH_SUFFIX_KEY, DOMAIN, EmptySession, createAuthStoreManager, getUniqueHostnameString, useAuthScw };
package/dist/isExpired.js CHANGED
@@ -1,5 +1,4 @@
1
1
  const isExpired = (expireTimestampRaw) => {
2
2
  return Math.floor(Date.now() / 1e3) > expireTimestampRaw.getTime() / 1e3 - 30;
3
3
  };
4
- //#endregion
5
4
  export { isExpired };
@@ -1,4 +1,3 @@
1
- //#region ../types/dist/index.d.ts
2
1
  /**
3
2
  * A utility used for XOR: marks every key that is only in T (and not in U)
4
3
  * as optional-never, effectively requiring those keys to be absent.
@@ -9,5 +8,4 @@ export type Without<T, U> = Partial<Record<Exclude<keyof T, keyof U>, never>>;
9
8
  * (T without any U-specific keys) OR (U without any T-specific keys),
10
9
  * so only one of them may be present. For non-object unions it falls back to T | U.
11
10
  */
12
- export type SingleXOR<T, U> = T | U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
13
- //#endregion
11
+ export type SingleXOR<T, U> = T | U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
@@ -1,7 +1,5 @@
1
1
  import { API, DeleteJWTRequest, EncodedJWT, JWT, UnauthenticatedAPI, UnauthenticatedApiRenewJWTRequest } from "./types.js";
2
- //#region src/types/iam/index.d.ts
3
2
  export declare namespace Iamv1alpha1 {
4
3
  export type { API, UnauthenticatedAPI };
5
4
  export type { DeleteJWTRequest, EncodedJWT, JWT, UnauthenticatedApiRenewJWTRequest };
6
- }
7
- //#endregion
5
+ }
@@ -1,6 +1,5 @@
1
1
  import { API } from "@scaleway/sdk-client";
2
2
  import { Iamv1alpha1 } from "@scaleway/sdk-iam";
3
- //#region src/types/iam/types.d.ts
4
3
  export type JWT = Iamv1alpha1.JWT;
5
4
  export type EncodedJWT = Iamv1alpha1.EncodedJWT;
6
5
  export type DeleteJWTRequest = Iamv1alpha1.DeleteJWTRequest;
@@ -39,5 +38,4 @@ export declare class UnauthenticatedAPI extends API {
39
38
  */
40
39
  renewJWT: (request: Readonly<UnauthenticatedApiRenewJWTRequest>) => Promise<EncodedJWT>;
41
40
  }
42
- //#endregion
43
41
  export { API$1 as API };
@@ -1,10 +1,9 @@
1
1
  import { AuthStoreManagerInstance } from "../useAuthScw/authStoreManager/authStoreManager.js";
2
2
  import "../useAuthScw/authStoreManager/index.js";
3
- import { Iamv1alpha1 } from "./iam/index.js";
4
3
  import { audienceIdSchema, jwtSchema } from "../zodSchemas.js";
4
+ import { Iamv1alpha1 } from "./iam/index.js";
5
5
  import { z } from "zod";
6
6
  import { API, Client, Settings } from "@scaleway/sdk-client";
7
- //#region src/types/index.d.ts
8
7
  export type EncodedJWT = z.infer<typeof jwtSchema>;
9
8
  export type AudienceIdType = z.infer<typeof audienceIdSchema>;
10
9
  export type OnError = (onError: {
@@ -63,5 +62,4 @@ export type CookieOptions = {
63
62
  * - `'localStorage'`: scoped to a single origin, survives reloads, avoids cookie size limits.
64
63
  */
65
64
  export type StorageType = 'cookie' | 'localStorage';
66
- //#endregion
67
65
  export {};
@@ -1,7 +1,6 @@
1
- import { AuthScwContextType, ConfigAuthProvider, CookieOptions, OnError } from "../types/index.js";
2
1
  import { SingleXOR } from "../types/dist/index.js";
2
+ import { AuthScwContextType, ConfigAuthProvider, CookieOptions, OnError } from "../types/index.js";
3
3
  import { ReactNode } from "react";
4
- //#region src/useAuthScw/AuthScwProvider.d.ts
5
4
  type CookieStorageOptions = {
6
5
  storageType?: 'cookie';
7
6
  cookie: CookieOptions;
@@ -25,5 +24,4 @@ export type AuthProviderParamType = ConfigAuthProvider & {
25
24
  } & SingleXOR<CookieStorageOptions, LocalStorageOptions>;
26
25
  export declare const useAuthScw: () => AuthScwContextType;
27
26
  export declare const AuthScwProvider: ({ clientSettings, IamV1Alpha1, IamUnauthenticatedV1Alpha1, children, cookie, urlParamTokenName, onError, storageType, migrateFromCookie }: AuthProviderParamType) => import("react").JSX.Element;
28
- //#endregion
29
27
  export {};
@@ -5,7 +5,7 @@ import { decodeToken, encodeToken, getStoredJWT, refreshSession } from "./helper
5
5
  import { proxyJwt } from "./proxyJwt.js";
6
6
  import { createContext, useCallback, useContext, useMemo, useState } from "react";
7
7
  import { jsx } from "react/jsx-runtime";
8
- //#region src/useAuthScw/AuthScwProvider.tsx
8
+ // src/useAuthScw/AuthScwProvider.tsx
9
9
  const AuthScwContext = createContext({});
10
10
  const useAuthScw = () => useContext(AuthScwContext);
11
11
  const AuthScwProvider = ({ clientSettings, IamV1Alpha1, IamUnauthenticatedV1Alpha1, children, cookie, urlParamTokenName, onError, storageType = "cookie", migrateFromCookie = false }) => {
@@ -143,5 +143,4 @@ const AuthScwProvider = ({ clientSettings, IamV1Alpha1, IamUnauthenticatedV1Alph
143
143
  children
144
144
  });
145
145
  };
146
- //#endregion
147
146
  export { AuthScwProvider, useAuthScw };
@@ -1,7 +1,6 @@
1
- import { CreateAuthStoreManagerOptions } from "./types.js";
2
- import { COOKIE_AGE, DEFAULT_AUTH_SUFFIX_KEY, DOMAIN, getUniqueHostnameString } from "./constants.js";
3
1
  import { AudienceIdType, EncodedJWT, StorageType } from "../../types/index.js";
4
- //#region src/useAuthScw/authStoreManager/authStoreManager.d.ts
2
+ import { COOKIE_AGE, DEFAULT_AUTH_SUFFIX_KEY, DOMAIN, getUniqueHostnameString } from "./constants.js";
3
+ import { CreateAuthStoreManagerOptions } from "./types.js";
5
4
  export type AuthStoreManagerInstance = ReturnType<typeof createAuthStoreManager>;
6
5
  /**
7
6
  * Factory that creates an isolated AuthStoreManager instance with its own
@@ -55,5 +54,4 @@ export declare const createAuthStoreManager: (param?: StorageType | CreateAuthSt
55
54
  * @deprecated Use `useAuthScw().storeManager` or `createAuthStoreManager()` instead.
56
55
  * The singleton bypasses the provider's configuration and shares global state across all providers.
57
56
  */
58
- export declare const AuthStoreManager: AuthStoreManagerInstance;
59
- //#endregion
57
+ export declare const AuthStoreManager: AuthStoreManagerInstance;
@@ -1,8 +1,8 @@
1
- import { COOKIE_AGE, DOMAIN, getUniqueHostnameString } from "./constants.js";
2
1
  import { audienceIdSchema, jwtSchema } from "../../zodSchemas.js";
2
+ import { COOKIE_AGE, DOMAIN, getUniqueHostnameString } from "./constants.js";
3
3
  import { createCookieBackend } from "./cookieBackend.js";
4
4
  import { createLocalStorageBackend } from "./localStorageBackend.js";
5
- //#region src/useAuthScw/authStoreManager/authStoreManager.ts
5
+ // src/useAuthScw/authStoreManager/authStoreManager.ts
6
6
  const KEY_SESSION = "_scw_session";
7
7
  const KEY_AUDIENCE_ID = "_scw_audience_id";
8
8
  const DEFAULT_SUFFIX_KEY = "";
@@ -139,5 +139,4 @@ const AuthStoreManager = new Proxy(createAuthStoreManager(), { get(target, prop,
139
139
  warnSingletonUsage();
140
140
  return Reflect.get(target, prop, receiver);
141
141
  } });
142
- //#endregion
143
142
  export { AuthStoreManager, createAuthStoreManager };
@@ -1,6 +1,4 @@
1
- //#region src/useAuthScw/authStoreManager/constants.d.ts
2
1
  export declare const COOKIE_AGE: number;
3
2
  export declare const DOMAIN: string;
4
3
  export declare const getUniqueHostnameString: (inputString: string) => string;
5
- export declare const DEFAULT_AUTH_SUFFIX_KEY: string;
6
- //#endregion
4
+ export declare const DEFAULT_AUTH_SUFFIX_KEY: string;
@@ -1,7 +1,6 @@
1
- //#region src/useAuthScw/authStoreManager/constants.ts
1
+ // src/useAuthScw/authStoreManager/constants.ts
2
2
  const COOKIE_AGE = 2678400;
3
3
  const DOMAIN = typeof globalThis !== "undefined" && "location" in globalThis ? globalThis.location.hostname : "";
4
4
  const getUniqueHostnameString = (inputString) => inputString.replaceAll(".", "_").replaceAll("-", "_");
5
5
  const DEFAULT_AUTH_SUFFIX_KEY = getUniqueHostnameString(DOMAIN);
6
- //#endregion
7
6
  export { COOKIE_AGE, DEFAULT_AUTH_SUFFIX_KEY, DOMAIN, getUniqueHostnameString };
@@ -1,7 +1,7 @@
1
1
  import { COOKIE_CONFIG } from "../../constants.js";
2
2
  import { DOMAIN } from "./constants.js";
3
3
  import { parseCookie, stringifySetCookie } from "cookie";
4
- //#region src/useAuthScw/authStoreManager/cookieBackend.ts
4
+ // src/useAuthScw/authStoreManager/cookieBackend.ts
5
5
  const getCookie = (key) => {
6
6
  const cookies = parseCookie(document.cookie);
7
7
  if (key in cookies && cookies[key]) {
@@ -60,5 +60,4 @@ const createCookieBackend = (options = {}) => {
60
60
  };
61
61
  };
62
62
  createCookieBackend();
63
- //#endregion
64
63
  export { createCookieBackend };
@@ -1,4 +1,4 @@
1
- //#region src/useAuthScw/authStoreManager/localStorageBackend.ts
1
+ // src/useAuthScw/authStoreManager/localStorageBackend.ts
2
2
  /**
3
3
  * localStorage-based storage backend.
4
4
  *
@@ -39,5 +39,4 @@ const createLocalStorageBackend = () => ({
39
39
  } catch {}
40
40
  }
41
41
  });
42
- //#endregion
43
42
  export { createLocalStorageBackend };
@@ -1,9 +1,7 @@
1
1
  import { CookieConfigType, StorageType } from "../../types/index.js";
2
- //#region src/useAuthScw/authStoreManager/types.d.ts
3
2
  export type CreateAuthStoreManagerOptions = {
4
3
  storageType?: StorageType;
5
4
  cookieConfig?: CookieConfigType;
6
5
  cookieAge?: number;
7
6
  suffixKey?: string;
8
- };
9
- //#endregion
7
+ };
@@ -1,5 +1,5 @@
1
1
  import { SESSION_HEADER_KEY, addAsyncHeaderInterceptor, createAdvancedClient, withAdditionalInterceptors, withProfile } from "@scaleway/sdk-client";
2
- //#region src/useAuthScw/createClient.ts
2
+ // src/useAuthScw/createClient.ts
3
3
  const clientSingleton = {
4
4
  IamV1Alpha1: void 0,
5
5
  IamUnauthenticatedV1Alpha1: void 0,
@@ -20,5 +20,4 @@ const clientSingleton = {
20
20
  };
21
21
  }
22
22
  };
23
- //#endregion
24
23
  export { clientSingleton };
@@ -1,6 +1,6 @@
1
1
  import { clientSingleton } from "./createClient.js";
2
2
  import { Errors } from "@scaleway/sdk-client";
3
- //#region src/useAuthScw/helpers.ts
3
+ // src/useAuthScw/helpers.ts
4
4
  let refreshSessionPromise = void 0;
5
5
  const refreshSession = async ({ paramsRenewRequest, setJWT, onError }) => {
6
6
  if (refreshSessionPromise !== void 0) return refreshSessionPromise;
@@ -35,5 +35,4 @@ const decodeToken = (encodedToken, storeManager) => {
35
35
  };
36
36
  const encodeToken = (jwt) => btoa(JSON.stringify(jwt));
37
37
  const getStoredJWT = (audienceId, storeManager) => storeManager.getJwt(audienceId);
38
- //#endregion
39
38
  export { decodeToken, encodeToken, getStoredJWT, refreshSession };
@@ -1,4 +1,4 @@
1
1
  import { DEFAULT_AUTH_SUFFIX_KEY, getUniqueHostnameString } from "./authStoreManager/constants.js";
2
- import "./authStoreManager/index.js";
3
2
  import { AuthScwProvider, useAuthScw } from "./AuthScwProvider.js";
3
+ import "./authStoreManager/index.js";
4
4
  export { AuthScwProvider, useAuthScw };
@@ -1,5 +1,5 @@
1
1
  import { subMinutes, subSeconds } from "date-fns";
2
- //#region src/useAuthScw/proxyJwt.ts
2
+ // src/useAuthScw/proxyJwt.ts
3
3
  const defaultUpdateValue = {
4
4
  shouldOutdated: false,
5
5
  subMinuteOfExpires: 59,
@@ -25,5 +25,4 @@ const proxyJwt = (jwtInfoParam, updateJwt = defaultUpdateValue) => {
25
25
  }
26
26
  return jwtInfoParam;
27
27
  };
28
- //#endregion
29
28
  export { proxyJwt };
@@ -1,6 +1,5 @@
1
1
  import { Iamv1alpha1 } from "./types/iam/index.js";
2
2
  import { z } from "zod";
3
- //#region src/zodSchemas.d.ts
4
3
  type TransformJWT = Omit<Iamv1alpha1.JWT, 'createdAt' | 'updatedAt' | 'expiresAt' | 'srn'> & {
5
4
  createdAt?: string | Date;
6
5
  updatedAt?: string | Date;
@@ -16,5 +15,4 @@ export declare const jwtSchema: z.ZodType<ValidateJWTSchema, unknown, z.core.$Zo
16
15
  export declare const audienceIdSchema: z.ZodObject<{
17
16
  audienceId: z.ZodString;
18
17
  }, z.core.$strip>;
19
- //#endregion
20
18
  export {};
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- //#region src/zodSchemas.ts
2
+ // src/zodSchemas.ts
3
3
  const dateScheme = z.union([z.string().min(1), z.date()]);
4
4
  const rawJwtSchema = z.object({
5
5
  jwt: z.object({
@@ -18,5 +18,4 @@ const rawJwtSchema = z.object({
18
18
  });
19
19
  const jwtSchema = z.compile(rawJwtSchema);
20
20
  const audienceIdSchema = z.compile(z.object({ audienceId: z.string().min(1) }));
21
- //#endregion
22
21
  export { audienceIdSchema, jwtSchema };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scaleway/auth-scw",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
4
4
  "description": "Auth Scaleway",
5
5
  "homepage": "https://github.com/scaleway/scaleway-lib/tree/main/packages/auth-scw",
6
6
  "bugs": {
@@ -26,16 +26,16 @@
26
26
  "access": "public"
27
27
  },
28
28
  "dependencies": {
29
- "@scaleway/sdk-iam": "2.21.2",
29
+ "@scaleway/sdk-iam": "2.22.0",
30
30
  "cookie": "2.0.1",
31
31
  "date-fns": "4.4.0",
32
- "zod": "4.6.6"
32
+ "zod": "4.6.7"
33
33
  },
34
34
  "devDependencies": {
35
- "@scaleway/sdk-client": "2.13.0",
35
+ "@scaleway/sdk-client": "2.16.0",
36
36
  "@scaleway/types": "1.2.0",
37
37
  "@types/react": "19.3.0",
38
- "react": "19.3.0"
38
+ "react": "19.3.1"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "@scaleway/sdk-client": "2.x",