@hexclave/js 1.0.5 → 1.0.6
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/dist/esm/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.js +183 -0
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.js.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.d.ts +1 -0
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.d.ts.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.js +31 -9
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/common.js +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/server-app-impl.js +1 -1
- package/dist/esm/lib/hexclave-app/url-targets.d.ts.map +1 -1
- package/dist/esm/lib/hexclave-app/url-targets.js +21 -7
- package/dist/esm/lib/hexclave-app/url-targets.js.map +1 -1
- package/dist/esm/lib/hexclave-app/url-targets.test.js +12 -0
- package/dist/esm/lib/hexclave-app/url-targets.test.js.map +1 -1
- package/dist/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts.map +1 -1
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.js +183 -0
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.js.map +1 -1
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.d.ts +1 -0
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.d.ts.map +1 -1
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.js +30 -8
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/lib/hexclave-app/apps/implementations/common.js +1 -1
- package/dist/lib/hexclave-app/apps/implementations/server-app-impl.js +1 -1
- package/dist/lib/hexclave-app/url-targets.d.ts.map +1 -1
- package/dist/lib/hexclave-app/url-targets.js +21 -7
- package/dist/lib/hexclave-app/url-targets.js.map +1 -1
- package/dist/lib/hexclave-app/url-targets.test.js +12 -0
- package/dist/lib/hexclave-app/url-targets.test.js.map +1 -1
- package/package.json +2 -2
- package/src/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.ts +212 -0
- package/src/lib/hexclave-app/apps/implementations/client-app-impl.ts +36 -7
- package/src/lib/hexclave-app/url-targets.test.ts +17 -0
- package/src/lib/hexclave-app/url-targets.ts +21 -3
|
@@ -100,6 +100,23 @@ describe("handler URL targets", () => {
|
|
|
100
100
|
expect(urls.cliAuthConfirm).toBe("https://project-id.example-stack-hosted.test/handler/cli-auth-confirm");
|
|
101
101
|
});
|
|
102
102
|
|
|
103
|
+
it("keeps redirect-only post-auth targets local even when the default target is hosted", () => {
|
|
104
|
+
vi.stubEnv("NEXT_PUBLIC_STACK_HOSTED_HANDLER_DOMAIN_SUFFIX", ".example-stack-hosted.test");
|
|
105
|
+
|
|
106
|
+
const urls = resolveHandlerUrls({
|
|
107
|
+
projectId: "project-id",
|
|
108
|
+
urls: {
|
|
109
|
+
default: { type: "hosted" },
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
expect(urls.signIn).toBe("https://project-id.example-stack-hosted.test/handler/sign-in");
|
|
114
|
+
expect(urls.signOut).toBe("https://project-id.example-stack-hosted.test/handler/sign-out");
|
|
115
|
+
expect(urls.afterSignIn).toBe("/");
|
|
116
|
+
expect(urls.afterSignUp).toBe("/");
|
|
117
|
+
expect(urls.afterSignOut).toBe("/");
|
|
118
|
+
});
|
|
119
|
+
|
|
103
120
|
it("rejects absolute OAuth callback string targets", () => {
|
|
104
121
|
expect(() => resolveHandlerUrls({
|
|
105
122
|
projectId: "project-id",
|
|
@@ -124,6 +124,12 @@ const isRelativeUrlString = (url: string): boolean => {
|
|
|
124
124
|
return !schemePrefixRegex.test(url);
|
|
125
125
|
};
|
|
126
126
|
|
|
127
|
+
const nonHostedHandlerNames = new Set<keyof HandlerUrls>([
|
|
128
|
+
"afterSignIn",
|
|
129
|
+
"afterSignUp",
|
|
130
|
+
"afterSignOut",
|
|
131
|
+
]);
|
|
132
|
+
|
|
127
133
|
export const isLocalHandlerUrlTarget = (options: {
|
|
128
134
|
targetUrl: string,
|
|
129
135
|
handlerPath: string,
|
|
@@ -159,6 +165,9 @@ const resolveUrlTarget = (options: {
|
|
|
159
165
|
return options.fallbackPath;
|
|
160
166
|
}
|
|
161
167
|
case "hosted": {
|
|
168
|
+
if (nonHostedHandlerNames.has(options.handlerName)) {
|
|
169
|
+
return options.fallbackPath;
|
|
170
|
+
}
|
|
162
171
|
return getHostedHandlerUrl({
|
|
163
172
|
projectId: options.projectId,
|
|
164
173
|
pagePath: getHostedPagePathForHandlerName(options.handlerName),
|
|
@@ -206,15 +215,24 @@ export const resolveHandlerUrls = (options: { urls: HandlerUrlOptions | undefine
|
|
|
206
215
|
});
|
|
207
216
|
}
|
|
208
217
|
|
|
218
|
+
const homeTarget = configuredUrls?.home ?? defaultTarget;
|
|
219
|
+
const localHome = resolveUrlTarget({
|
|
220
|
+
target: typeof homeTarget !== "string" && homeTarget.type === "hosted"
|
|
221
|
+
? { type: "handler-component" }
|
|
222
|
+
: homeTarget,
|
|
223
|
+
fallbackPath: "/",
|
|
224
|
+
handlerName: "home",
|
|
225
|
+
projectId: options.projectId,
|
|
226
|
+
});
|
|
209
227
|
const home = resolveUrlTarget({
|
|
210
|
-
target:
|
|
228
|
+
target: homeTarget,
|
|
211
229
|
fallbackPath: "/",
|
|
212
230
|
handlerName: "home",
|
|
213
231
|
projectId: options.projectId,
|
|
214
232
|
});
|
|
215
233
|
const afterSignIn = resolveUrlTarget({
|
|
216
234
|
target: configuredUrls?.afterSignIn ?? defaultTarget,
|
|
217
|
-
fallbackPath:
|
|
235
|
+
fallbackPath: localHome,
|
|
218
236
|
handlerName: "afterSignIn",
|
|
219
237
|
projectId: options.projectId,
|
|
220
238
|
});
|
|
@@ -253,7 +271,7 @@ export const resolveHandlerUrls = (options: { urls: HandlerUrlOptions | undefine
|
|
|
253
271
|
}),
|
|
254
272
|
afterSignOut: resolveUrlTarget({
|
|
255
273
|
target: configuredUrls?.afterSignOut ?? defaultTarget,
|
|
256
|
-
fallbackPath:
|
|
274
|
+
fallbackPath: localHome,
|
|
257
275
|
handlerName: "afterSignOut",
|
|
258
276
|
projectId: options.projectId,
|
|
259
277
|
}),
|