@faable/auth-sdk 2.4.3 → 2.4.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.
package/README.md CHANGED
@@ -80,7 +80,7 @@ const api = FaableAuthApi.create({
80
80
 
81
81
  | Option | Type | Description |
82
82
  | -------------- | ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
83
- | `domain` | string | **Required.** The account host to target, e.g. `https://<your-account>.auth.faable.link`. No default. |
83
+ | `domain` | string | **Required.** The account host to target, e.g. `https://<your-account>.auth.faable.link`. No default. The protocol is optional — `<your-account>.auth.faable.link` and `https://<your-account>.auth.faable.link` are equivalent. |
84
84
  | `authStrategy` | strategy builder | Auth strategy (`authClientCredentials` \| `authApikey`), re-exported from `@faable/auth-sdk`. Defaults to `authClientCredentials`. |
85
85
  | `auth` | config | Config for the chosen strategy. Its shape is inferred from `authStrategy` (e.g. `{ client_id, client_secret }`). |
86
86
  | `debug` | boolean | Enables verbose logging in the underlying fetcher. |
package/dist/helpers.js CHANGED
@@ -1,10 +1,19 @@
1
1
  import { FaableApiError } from "./error_handler.js";
2
+ // Normaliza el `domain` para que dé igual cómo lo pase el usuario: con o sin
3
+ // protocolo, con trailing slash, o incluso con protocolo duplicado (el valor
4
+ // que el dashboard copia ya trae `https://`). Siempre devuelve
5
+ // `<protocol>://<host>` sin barra final.
2
6
  export const getDomain = (domain) => {
3
- if (!/^(https|http)?:\/\//.test(domain)) {
4
- const protocol = "https";
5
- return `${protocol}//${domain}`;
7
+ const raw = (domain ?? "").trim().replace(/\/+$/, "");
8
+ // Usuario pasó protocolo (uno o varios, p.ej. "https://https://x"):
9
+ // preservar http/https intencionado y descartar duplicados.
10
+ const match = raw.match(/^(https?):\/\/(.*)$/i);
11
+ if (match) {
12
+ const host = match[2].replace(/^(https?:\/\/)+/i, "");
13
+ return `${match[1].toLowerCase()}://${host}`;
6
14
  }
7
- return domain;
15
+ // Sin protocolo: default https.
16
+ return `https://${raw}`;
8
17
  };
9
18
  // Guard required path params (ids) before interpolating them into a URL.
10
19
  // Without this, a `null`/`undefined` id silently builds e.g. `/user/null`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faable/auth-sdk",
3
- "version": "2.4.3",
3
+ "version": "2.4.5",
4
4
  "author": "Marc Pomar <marc@faable.com>",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/spec/openapi.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "info": {
4
4
  "title": "@faablecloud/auth",
5
5
  "description": "Auth Platform made by Faable. Manage Users and Roles",
6
- "version": "1.17.0",
6
+ "version": "1.18.0",
7
7
  "license": {
8
8
  "name": "private",
9
9
  "url": "https://faable.com/docs/platform/privacy-policy"