oidc-spa 10.2.5 → 10.2.7

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,4 @@
1
- // node_modules/magic-string/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
1
+ // node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
2
2
  var comma = ",".charCodeAt(0);
3
3
  var semicolon = ";".charCodeAt(0);
4
4
  var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oidc-spa",
3
- "version": "10.2.5",
3
+ "version": "10.2.7",
4
4
  "description": "OpenID Connect / OAuth2 solution for client-first Web Applications",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,7 +27,7 @@
27
27
  "@angular/router": "*",
28
28
  "@nuxt/kit": "*",
29
29
  "@tanstack/react-router": "*",
30
- "@tanstack/react-start": "*",
30
+ "@tanstack/react-start": ">=1.168.25",
31
31
  "@types/react": "*",
32
32
  "react": "*",
33
33
  "rxjs": "*"
@@ -999,6 +999,15 @@ export async function createOidc_nonMemoized<
999
999
  });
1000
1000
  }
1001
1001
 
1002
+ if (error.message === "Invalid client or Invalid client credentials") {
1003
+ return (
1004
+ await import("./diagnostic")
1005
+ ).createInvalidClientCredentialsInitializationError({
1006
+ clientId,
1007
+ issuerUri
1008
+ });
1009
+ }
1010
+
1002
1011
  {
1003
1012
  const authResponse_error = authResponse.error;
1004
1013
 
@@ -1196,6 +1205,15 @@ export async function createOidc_nonMemoized<
1196
1205
  });
1197
1206
  }
1198
1207
 
1208
+ if (error.message === "Invalid client or Invalid client credentials") {
1209
+ return (
1210
+ await import("./diagnostic")
1211
+ ).createInvalidClientCredentialsInitializationError({
1212
+ clientId,
1213
+ issuerUri
1214
+ });
1215
+ }
1216
+
1199
1217
  if (authResponse_error === undefined) {
1200
1218
  return error;
1201
1219
  }
@@ -338,6 +338,44 @@ export async function createIframeTimeoutInitializationError(params: {
338
338
  });
339
339
  }
340
340
 
341
+ export function createInvalidClientCredentialsInitializationError(params: {
342
+ issuerUri: string;
343
+ clientId: string;
344
+ }): OidcInitializationError {
345
+ const { issuerUri, clientId } = params;
346
+
347
+ return new OidcInitializationError({
348
+ isAuthServerLikelyDown: false,
349
+ messageOrCause: [
350
+ `The token endpoint rejected the OIDC client "${clientId}" with "Invalid client or Invalid client credentials".\n`,
351
+ `This usually means the client is configured as a confidential/private client and requires a client secret.\n`,
352
+ `oidc-spa performs the token exchange in the browser, so the OIDC client must be a public client that does not require a client secret.\n`,
353
+ `Issuer URI: "${issuerUri}"\n`,
354
+ ...(() => {
355
+ if (!isKeycloak({ issuerUri })) {
356
+ return [
357
+ "Check the documentation of your OIDC server and configure this client as a public client using Authorization Code Flow + PKCE."
358
+ ];
359
+ }
360
+
361
+ const kc = createKeycloakUtils({ issuerUri });
362
+
363
+ return [
364
+ `Since it seems that you are using Keycloak, here are the steps to follow:\n`,
365
+ `1. Go to the Keycloak admin console: ${kc.adminConsoleUrl_master}\n`,
366
+ `2. Log in as an admin user.\n`,
367
+ `3. In the top left corner select the realm "${kc.issuerUriParsed.realm}".\n`,
368
+ `4. In the left menu, click on "Clients".\n`,
369
+ `5. Find "${clientId}" in the list of clients and click on it.\n`,
370
+ `6. In "Capability config", turn "Client authentication" off. On older Keycloak versions, set the client access type to "public".\n`,
371
+ `7. Save the changes.\n\n`,
372
+ `More info: https://docs.oidc-spa.dev/v/v10/providers-configuration/keycloak`
373
+ ];
374
+ })()
375
+ ].join(" ")
376
+ });
377
+ }
378
+
341
379
  export async function createFailedToFetchTokenEndpointInitializationError(params: {
342
380
  issuerUri: string;
343
381
  clientId: string;
@@ -1022,7 +1022,7 @@ export function createOidcSpaUtils<
1022
1022
  }
1023
1023
 
1024
1024
  const fetchServerEnvVariableValues = createServerFn({ method: "GET" })
1025
- .inputValidator((data: { envVarNames: string[] }) => {
1025
+ .validator((data: { envVarNames: string[] }) => {
1026
1026
  if (typeof data !== "object" || data === null) {
1027
1027
  throw new Error("Expected an object");
1028
1028
  }