@hexclave/next 1.0.75 → 1.0.76

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.
Files changed (114) hide show
  1. package/dist/{admin-app-impl-sTQD2d-3.d.ts → admin-app-impl-CsH-gVGz.d.ts} +7 -7
  2. package/dist/{admin-app-impl-sTQD2d-3.d.ts.map → admin-app-impl-CsH-gVGz.d.ts.map} +1 -1
  3. package/dist/components/api-key-dialogs.d.ts +1 -1
  4. package/dist/components/elements/sidebar-layout.js +1 -1
  5. package/dist/dev-tool/dev-tool-core.d.ts.map +1 -1
  6. package/dist/dev-tool/dev-tool-core.js +2 -2
  7. package/dist/dev-tool/dev-tool-core.js.map +1 -1
  8. package/dist/dev-tool/index.d.ts.map +1 -1
  9. package/dist/dev-tool/index.js +2 -8
  10. package/dist/dev-tool/index.js.map +1 -1
  11. package/dist/esm/components/api-key-dialogs.d.ts +1 -1
  12. package/dist/esm/components/elements/sidebar-layout.js +1 -1
  13. package/dist/esm/dev-tool/dev-tool-core.d.ts.map +1 -1
  14. package/dist/esm/dev-tool/dev-tool-core.js +1 -1
  15. package/dist/esm/dev-tool/dev-tool-core.js.map +1 -1
  16. package/dist/esm/dev-tool/index.d.ts.map +1 -1
  17. package/dist/esm/dev-tool/index.js +2 -8
  18. package/dist/esm/dev-tool/index.js.map +1 -1
  19. package/dist/esm/generated/quetzal-translations.d.ts +2 -2
  20. package/dist/esm/in-page-ui/dev-environment.d.ts +5 -0
  21. package/dist/esm/in-page-ui/dev-environment.d.ts.map +1 -0
  22. package/dist/esm/in-page-ui/dev-environment.js +18 -0
  23. package/dist/esm/in-page-ui/dev-environment.js.map +1 -0
  24. package/dist/esm/in-page-ui/issue-card.d.ts +52 -0
  25. package/dist/esm/in-page-ui/issue-card.d.ts.map +1 -0
  26. package/dist/esm/in-page-ui/issue-card.js +392 -0
  27. package/dist/esm/in-page-ui/issue-card.js.map +1 -0
  28. package/dist/esm/in-page-ui/issue-card.test.d.ts +1 -0
  29. package/dist/esm/in-page-ui/issue-card.test.js +60 -0
  30. package/dist/esm/in-page-ui/issue-card.test.js.map +1 -0
  31. package/dist/esm/in-page-ui/logo.d.ts +5 -0
  32. package/dist/esm/in-page-ui/logo.d.ts.map +1 -0
  33. package/dist/esm/in-page-ui/logo.js +6 -0
  34. package/dist/esm/in-page-ui/logo.js.map +1 -0
  35. package/dist/esm/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts +4 -4
  36. package/dist/esm/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts.map +1 -1
  37. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.js +140 -15
  38. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.js.map +1 -1
  39. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.d.ts +2 -2
  40. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.d.ts.map +1 -1
  41. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.js +95 -12
  42. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.js.map +1 -1
  43. package/dist/esm/lib/hexclave-app/apps/implementations/common.js +2 -2
  44. package/dist/esm/lib/hexclave-app/apps/implementations/redirect-page-urls.test.js +1 -0
  45. package/dist/esm/lib/hexclave-app/apps/implementations/redirect-page-urls.test.js.map +1 -1
  46. package/dist/esm/pushed-config-error-overlay/index.d.ts.map +1 -1
  47. package/dist/esm/pushed-config-error-overlay/index.js +42 -343
  48. package/dist/esm/pushed-config-error-overlay/index.js.map +1 -1
  49. package/dist/esm/setup-error-overlay/index.d.ts +16 -0
  50. package/dist/esm/setup-error-overlay/index.d.ts.map +1 -0
  51. package/dist/esm/setup-error-overlay/index.js +106 -0
  52. package/dist/esm/setup-error-overlay/index.js.map +1 -0
  53. package/dist/esm/setup-error-overlay/index.test.d.ts +1 -0
  54. package/dist/esm/setup-error-overlay/index.test.js +125 -0
  55. package/dist/esm/setup-error-overlay/index.test.js.map +1 -0
  56. package/dist/generated/quetzal-translations.d.ts +1 -1
  57. package/dist/{hexclave-provider-BKxi3Vy-.d.ts → hexclave-provider-BA97jMlx.d.ts} +2 -2
  58. package/dist/{hexclave-provider-BKxi3Vy-.d.ts.map → hexclave-provider-BA97jMlx.d.ts.map} +1 -1
  59. package/dist/in-page-ui/dev-environment.d.ts +5 -0
  60. package/dist/in-page-ui/dev-environment.d.ts.map +1 -0
  61. package/dist/in-page-ui/dev-environment.js +19 -0
  62. package/dist/in-page-ui/dev-environment.js.map +1 -0
  63. package/dist/in-page-ui/issue-card.d.ts +52 -0
  64. package/dist/in-page-ui/issue-card.d.ts.map +1 -0
  65. package/dist/in-page-ui/issue-card.js +397 -0
  66. package/dist/in-page-ui/issue-card.js.map +1 -0
  67. package/dist/in-page-ui/issue-card.test.d.ts +1 -0
  68. package/dist/in-page-ui/issue-card.test.js +59 -0
  69. package/dist/in-page-ui/issue-card.test.js.map +1 -0
  70. package/dist/in-page-ui/logo.d.ts +5 -0
  71. package/dist/in-page-ui/logo.d.ts.map +1 -0
  72. package/dist/in-page-ui/logo.js +7 -0
  73. package/dist/in-page-ui/logo.js.map +1 -0
  74. package/dist/index.d.ts +1 -1
  75. package/dist/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts +1 -1
  76. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.js +140 -15
  77. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.js.map +1 -1
  78. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.d.ts +1 -1
  79. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.js +94 -11
  80. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.js.map +1 -1
  81. package/dist/lib/hexclave-app/apps/implementations/common.js +2 -2
  82. package/dist/lib/hexclave-app/apps/implementations/index.d.ts +1 -1
  83. package/dist/lib/hexclave-app/apps/implementations/redirect-page-urls.test.js +1 -0
  84. package/dist/lib/hexclave-app/apps/implementations/redirect-page-urls.test.js.map +1 -1
  85. package/dist/lib/hexclave-app/apps/implementations/server-app-impl.d.ts +1 -1
  86. package/dist/providers/hexclave-provider.d.ts +1 -1
  87. package/dist/providers/translation-provider.d.ts +1 -1
  88. package/dist/pushed-config-error-overlay/index.d.ts.map +1 -1
  89. package/dist/pushed-config-error-overlay/index.js +41 -342
  90. package/dist/pushed-config-error-overlay/index.js.map +1 -1
  91. package/dist/{quetzal-translations-XeH3zQ9l.d.ts → quetzal-translations-CK45_4Dm.d.ts} +3 -3
  92. package/dist/{quetzal-translations-XeH3zQ9l.d.ts.map → quetzal-translations-CK45_4Dm.d.ts.map} +1 -1
  93. package/dist/setup-error-overlay/index.d.ts +16 -0
  94. package/dist/setup-error-overlay/index.d.ts.map +1 -0
  95. package/dist/setup-error-overlay/index.js +108 -0
  96. package/dist/setup-error-overlay/index.js.map +1 -0
  97. package/dist/setup-error-overlay/index.test.d.ts +1 -0
  98. package/dist/setup-error-overlay/index.test.js +124 -0
  99. package/dist/setup-error-overlay/index.test.js.map +1 -0
  100. package/dist/{translation-provider-WOaZXqAz.d.ts → translation-provider-DQ3BJepJ.d.ts} +2 -2
  101. package/dist/{translation-provider-WOaZXqAz.d.ts.map → translation-provider-DQ3BJepJ.d.ts.map} +1 -1
  102. package/package.json +4 -4
  103. package/src/dev-tool/dev-tool-core.ts +1 -4
  104. package/src/dev-tool/index.ts +4 -15
  105. package/src/in-page-ui/dev-environment.ts +33 -0
  106. package/src/in-page-ui/issue-card.test.ts +67 -0
  107. package/src/in-page-ui/issue-card.ts +500 -0
  108. package/src/in-page-ui/logo.ts +8 -0
  109. package/src/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.ts +158 -0
  110. package/src/lib/hexclave-app/apps/implementations/client-app-impl.ts +125 -17
  111. package/src/lib/hexclave-app/apps/implementations/redirect-page-urls.test.ts +1 -0
  112. package/src/pushed-config-error-overlay/index.ts +45 -386
  113. package/src/setup-error-overlay/index.test.ts +133 -0
  114. package/src/setup-error-overlay/index.ts +150 -0
@@ -0,0 +1,150 @@
1
+
2
+ //===========================================
3
+ // THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY UNLESS YOU ALSO EDIT THE CORRESPONDING FILE IN packages/template
4
+ //===========================================
5
+
6
+ // Renders an error card on the page when an auth flow dies because of a setup problem in the developer's project (a
7
+ // domain missing from the trusted domains, for example). Those failures used to be logged with captureError only, which
8
+ // meant the flow just quietly stopped: the developer saw a page that never signed anybody in, with the explanation
9
+ // buried in the console or in Sentry. Setup errors are always the developer's to fix and never recoverable at runtime,
10
+ // so they get the same treatment as a broken pushed config: a card that is impossible to miss.
11
+
12
+ import { HexclaveSetupError, captureError, errorToNiceString } from "@hexclave/shared/dist/utils/errors";
13
+ import { isLikelyDevelopmentEnvironment } from "../in-page-ui/dev-environment";
14
+ import { canMountIntoDom, getGlobalUiInstance, h, setGlobalUiInstance } from "../in-page-ui/dom";
15
+ import { getIssueCardCSS, renderIssueCard, renderIssuePill, trapFocusInIssueCard, type IssueCardFocusTrap } from "../in-page-ui/issue-card";
16
+
17
+ /** Exported so tests can drop the singleton; every other consumer should go through `showSetupErrorOverlay`. */
18
+ export const SETUP_ERROR_OVERLAY_GLOBAL_INSTANCE_KEY = "__hexclave-setup-error-overlay";
19
+
20
+ const css = getIssueCardCSS(".hexclave-setup-error-overlay");
21
+
22
+ const unexpectedErrorHowToFix = [
23
+ "Check the browser console and your Hexclave dashboard's logs for the full error.",
24
+ "Make sure your Hexclave SDK packages are up to date.",
25
+ "If the error looks like a bug in Hexclave, report it at https://github.com/hexclave/hexclave/issues.",
26
+ ] as const;
27
+
28
+ type SetupIssue = {
29
+ title: string,
30
+ message: string,
31
+ howToFix: readonly string[],
32
+ // Setup errors are known to be fatal for their flow, so the card says so. Anything else may well be transient (a
33
+ // network blip while resolving a session, say), and claiming that nobody can sign in anymore would be misleading.
34
+ isFatal: boolean,
35
+ };
36
+
37
+ function toSetupIssue(error: unknown): SetupIssue {
38
+ if (HexclaveSetupError.isSetupError(error)) {
39
+ return {
40
+ title: error.title,
41
+ message: error.message,
42
+ howToFix: error.howToFix,
43
+ isFatal: true,
44
+ };
45
+ }
46
+ return {
47
+ title: "Hexclave could not finish an authentication flow",
48
+ message: errorToNiceString(error),
49
+ howToFix: unexpectedErrorHowToFix,
50
+ isFatal: false,
51
+ };
52
+ }
53
+
54
+ function buildAiPrompt(issue: SetupIssue): string {
55
+ return [
56
+ "Help me fix this Hexclave setup error.",
57
+ "",
58
+ "Hexclave reminder:",
59
+ "This error was thrown by the Hexclave SDK in the browser while it was resolving an authentication flow, and the flow was aborted because of it. It is a problem with how my project is set up, not something my users can work around. Use your web fetch tool to read https://skill.hexclave.com to learn more about Hexclave.",
60
+ "",
61
+ "Error message:",
62
+ issue.message,
63
+ "",
64
+ "Hexclave suggests:",
65
+ ...issue.howToFix.map((step) => `- ${step}`),
66
+ "",
67
+ "Please explain the likely cause and suggest the smallest safe fix.",
68
+ ].join("\n");
69
+ }
70
+
71
+ /**
72
+ * Shows `error` as an error card on the current page.
73
+ *
74
+ * Setup errors are always shown, because the flow they aborted cannot complete no matter what the end user does, and
75
+ * their messages are written for exactly this purpose. Any other error is only shown while developing — those messages
76
+ * are internal diagnostics, so in production they stay in captureError's hands.
77
+ *
78
+ * Returns a cleanup function that removes the card again.
79
+ */
80
+ export function showSetupErrorOverlay(error: unknown): () => void {
81
+ if (!canMountIntoDom()) {
82
+ return () => {};
83
+ }
84
+ if (!HexclaveSetupError.isSetupError(error) && !isLikelyDevelopmentEnvironment()) {
85
+ return () => {};
86
+ }
87
+
88
+ const issue = toSetupIssue(error);
89
+ const existingInstance = getGlobalUiInstance(SETUP_ERROR_OVERLAY_GLOBAL_INSTANCE_KEY);
90
+ if (existingInstance != null) {
91
+ // A single broken setup usually throws the same error on every page load and sometimes from several flows at once.
92
+ // Stacking cards on top of each other would only hide the first (and most relevant) one, so later errors keep to
93
+ // captureError and leave the card that is already up alone.
94
+ return () => {};
95
+ }
96
+
97
+ const root = h("div", { className: "hexclave-setup-error-overlay" });
98
+ const style = h("style", null, css);
99
+ root.appendChild(style);
100
+ document.body.appendChild(root);
101
+
102
+ let focusTrap: IssueCardFocusTrap | null = null;
103
+ const render = (minimized: boolean) => {
104
+ focusTrap?.release();
105
+ focusTrap = null;
106
+ root.replaceChildren(style);
107
+ if (minimized) {
108
+ root.appendChild(renderIssuePill({
109
+ kind: "error",
110
+ label: "Setup error",
111
+ ariaLabel: "Show Hexclave setup error",
112
+ onClick: () => render(false),
113
+ }));
114
+ return;
115
+ }
116
+ root.appendChild(renderIssueCard({
117
+ kind: "error",
118
+ badge: "Setup error",
119
+ title: issue.title,
120
+ bodyText: issue.isFatal
121
+ ? "Hexclave stopped the authentication flow that ran into this error, so nobody can sign in through it until it is fixed."
122
+ : "Hexclave aborted the authentication flow that ran into this error. Errors like this one may also be transient, in which case retrying the flow works.",
123
+ messageLabel: "Error message",
124
+ message: issue.message,
125
+ howToFix: issue.howToFix,
126
+ footerText: issue.isFatal
127
+ ? "This card is shown by the Hexclave SDK. Fix the problem above and reload the page to try the flow again."
128
+ : "This card is shown by the Hexclave SDK while developing, and never in production.",
129
+ ariaLabel: "Hexclave setup error",
130
+ aiPrompt: buildAiPrompt(issue),
131
+ onCopyError: (copyError) => captureError("setup-error-overlay-copy", copyError),
132
+ onCopyAiPromptError: (copyError) => captureError("setup-error-overlay-copy-ai-prompt", copyError),
133
+ onMinimize: () => render(true),
134
+ }));
135
+ focusTrap = trapFocusInIssueCard(root);
136
+ };
137
+ render(false);
138
+
139
+ const cleanup = () => {
140
+ focusTrap?.release();
141
+ focusTrap = null;
142
+ root.remove();
143
+ if (getGlobalUiInstance(SETUP_ERROR_OVERLAY_GLOBAL_INSTANCE_KEY)?.cleanup === cleanup) {
144
+ setGlobalUiInstance(SETUP_ERROR_OVERLAY_GLOBAL_INSTANCE_KEY, null);
145
+ }
146
+ };
147
+ setGlobalUiInstance(SETUP_ERROR_OVERLAY_GLOBAL_INSTANCE_KEY, { cleanup });
148
+ return cleanup;
149
+ }
150
+