@owlmeans/mui-oidc-rp 0.1.15 → 0.1.16

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 +1 @@
1
- {"version":3,"file":"dispatcher.d.ts","sourceRoot":"","sources":["../../src/components/dispatcher.tsx"],"names":[],"mappings":"AAUA,eAAO,MAAM,UAAU,6FAiDrB,CAAA"}
1
+ {"version":3,"file":"dispatcher.d.ts","sourceRoot":"","sources":["../../src/components/dispatcher.tsx"],"names":[],"mappings":"AAWA,eAAO,MAAM,UAAU,6FA+DrB,CAAA"}
@@ -4,6 +4,7 @@ import { useEffect } from 'react';
4
4
  import { useContext } from '@owlmeans/web-client';
5
5
  import { useI18nLib } from '@owlmeans/client-i18n';
6
6
  import { AUTH_QUERY } from '@owlmeans/auth';
7
+ import { OIDC_ERROR_DESCRIPTION_QUERY, OIDC_ERROR_QUERY } from '@owlmeans/oidc';
7
8
  import { useFlow } from '@owlmeans/web-flow';
8
9
  import { DEFAULT_ALIAS } from '../consts.js';
9
10
  export const Dispatcher = DispatcherHOC(({ provideToken, navigate }) => {
@@ -11,10 +12,19 @@ export const Dispatcher = DispatcherHOC(({ provideToken, navigate }) => {
11
12
  const [query] = context.router().useSearchParams();
12
13
  const client = useFlow();
13
14
  const t = useI18nLib('auth', 'dispatcher');
15
+ // The provider reports a failed authorization by redirecting BACK here with `error` set. Re-entering
16
+ // the flow at that point sends the browser into the very authorization request that just failed —
17
+ // an endless dispatcher <-> provider redirect loop that also hides the reason. Surface it, stop.
18
+ const error = query.get(OIDC_ERROR_QUERY);
19
+ const errorDescription = query.get(OIDC_ERROR_DESCRIPTION_QUERY);
14
20
  useEffect(() => {
15
21
  if (client == null) {
16
22
  return;
17
23
  }
24
+ if (error != null) {
25
+ console.error(`[oidc] authorization failed: ${error}${errorDescription != null ? ` — ${errorDescription}` : ''}`);
26
+ return;
27
+ }
18
28
  const token = query.get(AUTH_QUERY);
19
29
  const params = {};
20
30
  query.forEach((value, key) => {
@@ -49,7 +59,10 @@ export const Dispatcher = DispatcherHOC(({ provideToken, navigate }) => {
49
59
  }
50
60
  });
51
61
  }
52
- }, [client]);
62
+ }, [client, error]);
63
+ if (error != null) {
64
+ return _jsx("div", { children: t('error', { error: errorDescription ?? error }) });
65
+ }
53
66
  return query.has(AUTH_QUERY)
54
67
  ? _jsx("div", { children: t('loading') })
55
68
  : undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"dispatcher.js","sourceRoot":"","sources":["../../src/components/dispatcher.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAE5C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAE5C,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAC,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,EAAE;IACrE,MAAM,OAAO,GAAG,UAAU,EAAE,CAAA;IAC5B,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,eAAe,EAAE,CAAA;IAClD,MAAM,MAAM,GAAG,OAAO,EAAE,CAAA;IAExB,MAAM,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;IAE1C,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;YACnB,OAAM;QACR,CAAC;QACD,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;QACnC,MAAM,MAAM,GAA2B,EAAE,CAAA;QAC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AG,QAAQ,CAAA;oBACjC,OAAM;gBACR,CAAC;gBACD,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC,aAAa,EAAE,CAAA;gBACvD,IAAI,UAAU,IAAI,IAAI,EAAE,CAAC;oBACvB,YAAY,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,SAAS,CAAC,CAAA;gBACxC,CAAC;qBAAM,CAAC;oBACN,MAAM,QAAQ,EAAE,CAAA;gBAClB,CAAC;YACH,CAAC,CAAC,CAAA;QACJ,CAAC;IACH,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAA;IAEnB,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QAClB,OAAO,wBAAM,CAAC,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,gBAAgB,IAAI,KAAK,EAAE,CAAC,GAAO,CAAA;IACtE,CAAC;IAED,OAAO,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC;QAC1B,CAAC,CAAC,wBAAM,CAAC,CAAC,SAAS,CAAC,GAAO;QAC3B,CAAC,CAAC,SAAS,CAAA;AACf,CAAC,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owlmeans/mui-oidc-rp",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -29,19 +29,19 @@
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@owlmeans/auth": "^0.1.15",
33
- "@owlmeans/basic-envelope": "^0.1.15",
34
- "@owlmeans/client": "^0.1.15",
35
- "@owlmeans/client-auth": "^0.1.15",
36
- "@owlmeans/client-flow": "^0.1.15",
37
- "@owlmeans/client-i18n": "^0.1.15",
38
- "@owlmeans/context": "^0.1.15",
39
- "@owlmeans/flow": "^0.1.15",
40
- "@owlmeans/entrypoint": "^0.1.15",
41
- "@owlmeans/oidc": "^0.1.15",
42
- "@owlmeans/resource": "^0.1.15",
43
- "@owlmeans/web-client": "^0.1.15",
44
- "@owlmeans/web-flow": "^0.1.15",
32
+ "@owlmeans/auth": "^0.1.16",
33
+ "@owlmeans/basic-envelope": "^0.1.16",
34
+ "@owlmeans/client": "^0.1.16",
35
+ "@owlmeans/client-auth": "^0.1.16",
36
+ "@owlmeans/client-flow": "^0.1.16",
37
+ "@owlmeans/client-i18n": "^0.1.16",
38
+ "@owlmeans/context": "^0.1.16",
39
+ "@owlmeans/flow": "^0.1.16",
40
+ "@owlmeans/entrypoint": "^0.1.16",
41
+ "@owlmeans/oidc": "^0.1.16",
42
+ "@owlmeans/resource": "^0.1.16",
43
+ "@owlmeans/web-client": "^0.1.16",
44
+ "@owlmeans/web-flow": "^0.1.16",
45
45
  "oidc-client-ts": "3.5.0"
46
46
  },
47
47
  "peerDependencies": {
@@ -50,7 +50,7 @@
50
50
  },
51
51
  "devDependencies": {
52
52
  "@owlmeans/dep-config": "workspace:*",
53
- "@owlmeans/test-auth": "^0.1.15",
53
+ "@owlmeans/test-auth": "^0.1.16",
54
54
  "@types/bun": "^1.3.14",
55
55
  "@types/react": "^19.2.17",
56
56
  "nodemon": "^3.1.14",
@@ -4,6 +4,7 @@ import { useEffect } from 'react'
4
4
  import { useContext } from '@owlmeans/web-client'
5
5
  import { useI18nLib } from '@owlmeans/client-i18n'
6
6
  import { AUTH_QUERY } from '@owlmeans/auth'
7
+ import { OIDC_ERROR_DESCRIPTION_QUERY, OIDC_ERROR_QUERY } from '@owlmeans/oidc'
7
8
  import { useFlow } from '@owlmeans/web-flow'
8
9
  import { OidcAuthService } from '../types.js'
9
10
  import { DEFAULT_ALIAS } from '../consts.js'
@@ -15,10 +16,20 @@ export const Dispatcher = DispatcherHOC(({ provideToken, navigate }) => {
15
16
 
16
17
  const t = useI18nLib('auth', 'dispatcher')
17
18
 
19
+ // The provider reports a failed authorization by redirecting BACK here with `error` set. Re-entering
20
+ // the flow at that point sends the browser into the very authorization request that just failed —
21
+ // an endless dispatcher <-> provider redirect loop that also hides the reason. Surface it, stop.
22
+ const error = query.get(OIDC_ERROR_QUERY)
23
+ const errorDescription = query.get(OIDC_ERROR_DESCRIPTION_QUERY)
24
+
18
25
  useEffect(() => {
19
26
  if (client == null) {
20
27
  return
21
28
  }
29
+ if (error != null) {
30
+ console.error(`[oidc] authorization failed: ${error}${errorDescription != null ? ` — ${errorDescription}` : ''}`)
31
+ return
32
+ }
22
33
  const token = query.get(AUTH_QUERY)
23
34
  const params: Record<string, string> = {}
24
35
  query.forEach((value, key) => {
@@ -52,7 +63,11 @@ export const Dispatcher = DispatcherHOC(({ provideToken, navigate }) => {
52
63
  }
53
64
  })
54
65
  }
55
- }, [client])
66
+ }, [client, error])
67
+
68
+ if (error != null) {
69
+ return <div>{t('error', { error: errorDescription ?? error })}</div>
70
+ }
56
71
 
57
72
  return query.has(AUTH_QUERY)
58
73
  ? <div>{t('loading')}</div>