@authup/client-auth-console 1.0.0-beta.70 → 1.0.0-beta.71

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.
@@ -13,7 +13,7 @@
13
13
  <link rel="icon" type="image/svg+xml" href="/console/auth/assets/favicon-CEtVE1SK.svg" />
14
14
  <title>Authup</title>
15
15
  <!--preload-links-->
16
- <script type="module" crossorigin src="/console/auth/assets/index-oZXM2RN4.js"></script>
16
+ <script type="module" crossorigin src="/console/auth/assets/index-Pd7hWwbo.js"></script>
17
17
  <link rel="stylesheet" crossorigin href="/console/auth/assets/index-CyF87xq2.css">
18
18
  </head>
19
19
  <body>
@@ -39743,6 +39743,15 @@ var OAuth2Error = class extends AuthupError {
39743
39743
  }
39744
39744
  };
39745
39745
  //#endregion
39746
+ //#region ../../packages/specs/src/oauth2/check.ts
39747
+ /**
39748
+ * Whether the code is one of the errors RFC 6749 §5.2 defines for a
39749
+ * token endpoint response, read from the response body's `error` field.
39750
+ */
39751
+ function isOAuth2TokenErrorCode(code) {
39752
+ return code === OAuth2ErrorCode.INVALID_REQUEST || code === OAuth2ErrorCode.INVALID_CLIENT || code === OAuth2ErrorCode.INVALID_GRANT || code === OAuth2ErrorCode.UNAUTHORIZED_CLIENT || code === OAuth2ErrorCode.UNSUPPORTED_GRANT_TYPE || code === OAuth2ErrorCode.INVALID_SCOPE;
39753
+ }
39754
+ //#endregion
39746
39755
  //#region ../../packages/specs/src/oauth2/scope/helpers.ts
39747
39756
  /**
39748
39757
  * Deserialize a string representation of multiple oauth2 scopes.
@@ -82875,6 +82884,14 @@ function getClientErrorCode(err) {
82875
82884
  if (!isObject$7(err.response.data) || typeof err.response.data.code !== "string") return null;
82876
82885
  return err.response.data.code;
82877
82886
  }
82887
+ /**
82888
+ * The OAuth2 `error` field of a response body (RFC 6749 §5.2).
82889
+ */
82890
+ function getClientOAuth2ErrorCode(err) {
82891
+ if (!isObject$7(err) || !isObject$7(err.response)) return null;
82892
+ if (!isObject$7(err.response.data) || typeof err.response.data.error !== "string") return null;
82893
+ return err.response.data.error;
82894
+ }
82878
82895
  //#endregion
82879
82896
  //#region ../../node_modules/@rapiq/parser-expression/dist/index.mjs
82880
82897
  var ExpressionFieldsParser = class extends SimpleFieldsParser {};
@@ -87938,6 +87955,7 @@ var ClientAuthenticationHook = class extends EventEmitter$2 {
87938
87955
  const { request } = err;
87939
87956
  const currentState = getClientRequestRetryState(request);
87940
87957
  if (currentState.retryCount > 0) return Promise.reject(err);
87958
+ if (isOAuth2TokenErrorCode(getClientOAuth2ErrorCode(err))) return Promise.reject(err);
87941
87959
  currentState.retryCount += 1;
87942
87960
  const code = getClientErrorCode(err);
87943
87961
  if (isJWKErrorCode(code)) {
@@ -88832,6 +88850,18 @@ var StoreAuthOrigin = /* @__PURE__ */ function(StoreAuthOrigin) {
88832
88850
  return StoreAuthOrigin;
88833
88851
  }({});
88834
88852
  //#endregion
88853
+ //#region ../../packages/client-web-kit/src/core/http-client/build.ts
88854
+ /**
88855
+ * A client for one kit consumer (the store, the provided client, the hook's
88856
+ * refresh and revoke): the result of `httpClient` when it is a function, the
88857
+ * instance itself otherwise, else one built from `baseURL`.
88858
+ */
88859
+ function buildHTTPClient(options) {
88860
+ if (typeof options.httpClient === "function") return options.httpClient();
88861
+ if (options.httpClient) return options.httpClient;
88862
+ return new Client({ baseURL: options.baseURL });
88863
+ }
88864
+ //#endregion
88835
88865
  //#region ../../packages/client-web-kit/src/core/hydration/singleton.ts
88836
88866
  var HydrationStoreSymbol = Symbol.for("AuthupHydrationStore");
88837
88867
  function provideHydrationStore(store, app) {
@@ -89128,7 +89158,7 @@ function createPromiseShareWrapperFn(fn) {
89128
89158
  };
89129
89159
  }
89130
89160
  function createStore(context) {
89131
- const client = context.httpClient ?? new Client({ baseURL: context.baseURL });
89161
+ const client = buildHTTPClient(context);
89132
89162
  const cookiesRead = (0, vue_exports.ref)(false);
89133
89163
  const accessToken = (0, vue_exports.ref)(null);
89134
89164
  const setAccessToken = (input) => {
@@ -90435,11 +90465,12 @@ function installHTTPClientAuthenticationHook(app, options = {}) {
90435
90465
  const store = injectStoreFactory(app)(options.pinia);
90436
90466
  const { refreshToken } = storeToRefs$1(store);
90437
90467
  let refreshTokenInUse = null;
90468
+ const buildClient = () => buildHTTPClient(options);
90438
90469
  const hook = new ClientAuthenticationHook({
90439
90470
  tokenCreator: () => {
90440
90471
  if (!refreshToken.value) throw new Error("No refresh token available.");
90441
90472
  refreshTokenInUse = refreshToken.value;
90442
- return (options.httpClient ?? new Client({ baseURL: options.baseURL })).token.createWithRefreshToken({ refresh_token: refreshTokenInUse });
90473
+ return buildClient().token.createWithRefreshToken({ refresh_token: refreshTokenInUse });
90443
90474
  },
90444
90475
  timer: !options.isServer
90445
90476
  });
@@ -90448,7 +90479,7 @@ function installHTTPClientAuthenticationHook(app, options = {}) {
90448
90479
  if (refreshTokenInUse === null || store.refreshToken !== refreshTokenInUse) {
90449
90480
  handleAccessTokenEvent();
90450
90481
  handleAccessTokenExpireDateEvent();
90451
- const client = options.httpClient ?? new Client({ baseURL: options.baseURL });
90482
+ const client = buildClient();
90452
90483
  Promise.resolve().then(() => client.token.revoke({ token: response.access_token })).catch(() => {});
90453
90484
  if (response.refresh_token) {
90454
90485
  const refresh = response.refresh_token;
@@ -90512,7 +90543,7 @@ function injectHTTPClient(app) {
90512
90543
  //#region ../../packages/client-web-kit/src/core/http-client/install.ts
90513
90544
  function installHTTPClient(app, options = {}) {
90514
90545
  if (hasHTTPClient(app)) return;
90515
- const client = options.httpClient ?? new Client({ baseURL: options.baseURL });
90546
+ const client = buildHTTPClient(options);
90516
90547
  injectHTTPClientAuthenticationHook(app).attach(client);
90517
90548
  provideHTTPClient(client, app);
90518
90549
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@authup/client-auth-console",
3
- "version": "1.0.0-beta.70",
3
+ "version": "1.0.0-beta.71",
4
4
  "type": "module",
5
5
  "license": "AGPL-3.0-only",
6
6
  "description": "Authup's hosted login, consent, registration, password recovery and device pages, as a server-rendered Vue bundle.",
@@ -25,15 +25,15 @@
25
25
  "node": "^22.13.0 || ^23.5.0 || >=24.0.0"
26
26
  },
27
27
  "dependencies": {
28
- "@authup/core-http-kit": "^1.0.0-beta.70"
28
+ "@authup/core-http-kit": "^1.0.0-beta.71"
29
29
  },
30
30
  "devDependencies": {
31
- "@authup/client-web-kit": "^1.0.0-beta.70",
32
- "@authup/client-web-kit-theme": "^1.0.0-beta.70",
33
- "@authup/client-web-theme": "^1.0.0-beta.70",
34
- "@authup/core-kit": "^1.0.0-beta.70",
35
- "@authup/i18n": "^1.0.0-beta.70",
36
- "@authup/kit": "^1.0.0-beta.70",
31
+ "@authup/client-web-kit": "^1.0.0-beta.71",
32
+ "@authup/client-web-kit-theme": "^1.0.0-beta.71",
33
+ "@authup/client-web-theme": "^1.0.0-beta.71",
34
+ "@authup/core-kit": "^1.0.0-beta.71",
35
+ "@authup/i18n": "^1.0.0-beta.71",
36
+ "@authup/kit": "^1.0.0-beta.71",
37
37
  "@fontsource/asap": "^5.3.0",
38
38
  "@fontsource/nunito": "^5.3.0",
39
39
  "@iconify-json/fa6-brands": "^1.2.0",
package/src/contract.ts CHANGED
@@ -103,6 +103,11 @@ export type RenderContext = {
103
103
  * constructed from payload.config.baseURL (host self-call rewrite,
104
104
  * test injection). It carries the visitor's bearer once their session
105
105
  * resolved, so a host must build one per render and never share it.
106
+ *
107
+ * Its base url must be payload.config.baseURL: the app renders urls
108
+ * derived from it (the identity provider buttons), and hydration does
109
+ * not correct an attribute. A host that dials another address does so
110
+ * in the client's transport.
106
111
  */
107
112
  httpClient?: IClient,
108
113
  /**