@hexclave/js 1.0.71 → 1.0.72

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 (56) hide show
  1. package/dist/admin-app-impl-BBSNNr6S.d.ts.map +1 -1
  2. package/dist/clickmap/clickmap-core.js +4 -4
  3. package/dist/clickmap/index.js +1 -1
  4. package/dist/dev-tool/dev-tool-core.js +2 -2
  5. package/dist/dev-tool/index.js +1 -1
  6. package/dist/esm/clickmap/clickmap-core.js +4 -4
  7. package/dist/esm/clickmap/index.js +1 -1
  8. package/dist/esm/dev-tool/dev-tool-core.js +2 -2
  9. package/dist/esm/dev-tool/index.js +1 -1
  10. package/dist/esm/lib/auth.js +1 -1
  11. package/dist/esm/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts.map +1 -1
  12. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.js +3 -3
  13. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.js.map +1 -1
  14. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.d.ts.map +1 -1
  15. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.js +5 -6
  16. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.js.map +1 -1
  17. package/dist/esm/lib/hexclave-app/apps/implementations/common.js +4 -4
  18. package/dist/esm/lib/hexclave-app/apps/implementations/event-tracker.js +1 -1
  19. package/dist/esm/lib/hexclave-app/apps/implementations/redirect-page-urls.js +1 -1
  20. package/dist/esm/lib/hexclave-app/apps/implementations/server-app-impl.d.ts.map +1 -1
  21. package/dist/esm/lib/hexclave-app/apps/implementations/server-app-impl.js +2 -2
  22. package/dist/esm/lib/hexclave-app/apps/implementations/server-app-impl.js.map +1 -1
  23. package/dist/esm/lib/hexclave-app/apps/implementations/session-replay.test.js +1 -1
  24. package/dist/esm/lib/hexclave-app/passkey-rp-id.d.ts +12 -0
  25. package/dist/esm/lib/hexclave-app/passkey-rp-id.d.ts.map +1 -0
  26. package/dist/esm/lib/hexclave-app/passkey-rp-id.js +15 -0
  27. package/dist/esm/lib/hexclave-app/passkey-rp-id.js.map +1 -0
  28. package/dist/esm/lib/hexclave-app/passkey-rp-id.test.d.ts +1 -0
  29. package/dist/esm/lib/hexclave-app/passkey-rp-id.test.js +26 -0
  30. package/dist/esm/lib/hexclave-app/passkey-rp-id.test.js.map +1 -0
  31. package/dist/esm/pushed-config-error-overlay/index.js +1 -1
  32. package/dist/lib/auth.js +1 -1
  33. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.js +3 -3
  34. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.js.map +1 -1
  35. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.js +5 -6
  36. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.js.map +1 -1
  37. package/dist/lib/hexclave-app/apps/implementations/common.js +4 -4
  38. package/dist/lib/hexclave-app/apps/implementations/event-tracker.js +1 -1
  39. package/dist/lib/hexclave-app/apps/implementations/redirect-page-urls.js +1 -1
  40. package/dist/lib/hexclave-app/apps/implementations/server-app-impl.js +2 -2
  41. package/dist/lib/hexclave-app/apps/implementations/server-app-impl.js.map +1 -1
  42. package/dist/lib/hexclave-app/apps/implementations/session-replay.test.js +1 -1
  43. package/dist/lib/hexclave-app/passkey-rp-id.d.ts +12 -0
  44. package/dist/lib/hexclave-app/passkey-rp-id.d.ts.map +1 -0
  45. package/dist/lib/hexclave-app/passkey-rp-id.js +17 -0
  46. package/dist/lib/hexclave-app/passkey-rp-id.js.map +1 -0
  47. package/dist/lib/hexclave-app/passkey-rp-id.test.d.ts +1 -0
  48. package/dist/lib/hexclave-app/passkey-rp-id.test.js +25 -0
  49. package/dist/lib/hexclave-app/passkey-rp-id.test.js.map +1 -0
  50. package/dist/pushed-config-error-overlay/index.js +1 -1
  51. package/package.json +2 -2
  52. package/src/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.ts +3 -3
  53. package/src/lib/hexclave-app/apps/implementations/client-app-impl.ts +10 -11
  54. package/src/lib/hexclave-app/apps/implementations/server-app-impl.ts +2 -7
  55. package/src/lib/hexclave-app/passkey-rp-id.test.ts +43 -0
  56. package/src/lib/hexclave-app/passkey-rp-id.ts +27 -0
@@ -0,0 +1,25 @@
1
+ let vitest = require("vitest");
2
+ let __passkey_rp_id_js = require("./passkey-rp-id.js");
3
+ //#region src/lib/hexclave-app/passkey-rp-id.test.ts
4
+ const passkeyRpIdSentinel = "THIS_VALUE_WILL_BE_REPLACED.example.com";
5
+ vitest.describe.each(["project-id.built-with-hexclave.com", "project-id.built-with-stack-auth.com"])("passkeys on %s", (hostname) => {
6
+ (0, vitest.it)("scopes registration to the current hostname", () => {
7
+ const options = { rp: { id: passkeyRpIdSentinel } };
8
+ (0, __passkey_rp_id_js.scopePasskeyRegistrationToHostname)(options, hostname);
9
+ (0, vitest.expect)(options.rp.id).toBe(hostname);
10
+ });
11
+ (0, vitest.it)("scopes authentication to the current hostname", () => {
12
+ const options = { rpId: passkeyRpIdSentinel };
13
+ (0, __passkey_rp_id_js.scopePasskeyAuthenticationToHostname)(options, hostname);
14
+ (0, vitest.expect)(options.rpId).toBe(hostname);
15
+ });
16
+ });
17
+ (0, vitest.it)("rejects registration options without the server sentinel", () => {
18
+ (0, vitest.expect)(() => (0, __passkey_rp_id_js.scopePasskeyRegistrationToHostname)({ rp: { id: "unexpected.example.com" } }, "project-id.built-with-hexclave.com")).toThrow("Expected returned RP ID from server to equal sentinel");
19
+ });
20
+ (0, vitest.it)("rejects authentication options without the server sentinel", () => {
21
+ (0, vitest.expect)(() => (0, __passkey_rp_id_js.scopePasskeyAuthenticationToHostname)({ rpId: "unexpected.example.com" }, "project-id.built-with-hexclave.com")).toThrow("Expected returned RP ID from server to equal sentinel");
22
+ });
23
+ //#endregion
24
+
25
+ //# sourceMappingURL=passkey-rp-id.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"passkey-rp-id.test.js","names":["describe"],"sources":["../../../src/lib/hexclave-app/passkey-rp-id.test.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY UNLESS YOU ALSO EDIT THE CORRESPONDING FILE IN packages/template\n//===========================================\nimport { describe, expect, it } from \"vitest\";\nimport { scopePasskeyAuthenticationToHostname, scopePasskeyRegistrationToHostname } from \"./passkey-rp-id\";\n\nconst passkeyRpIdSentinel = \"THIS_VALUE_WILL_BE_REPLACED.example.com\";\n\ndescribe.each([\n \"project-id.built-with-hexclave.com\",\n \"project-id.built-with-stack-auth.com\",\n])(\"passkeys on %s\", (hostname) => {\n it(\"scopes registration to the current hostname\", () => {\n const options = { rp: { id: passkeyRpIdSentinel } };\n\n scopePasskeyRegistrationToHostname(options, hostname);\n\n expect(options.rp.id).toBe(hostname);\n });\n\n it(\"scopes authentication to the current hostname\", () => {\n const options = { rpId: passkeyRpIdSentinel };\n\n scopePasskeyAuthenticationToHostname(options, hostname);\n\n expect(options.rpId).toBe(hostname);\n });\n});\n\nit(\"rejects registration options without the server sentinel\", () => {\n expect(() => scopePasskeyRegistrationToHostname(\n { rp: { id: \"unexpected.example.com\" } },\n \"project-id.built-with-hexclave.com\",\n )).toThrow(\"Expected returned RP ID from server to equal sentinel\");\n});\n\nit(\"rejects authentication options without the server sentinel\", () => {\n expect(() => scopePasskeyAuthenticationToHostname(\n { rpId: \"unexpected.example.com\" },\n \"project-id.built-with-hexclave.com\",\n )).toThrow(\"Expected returned RP ID from server to equal sentinel\");\n});\n"],"mappings":";;;AAOA,MAAM,sBAAsB;AAE5BA,OAAAA,SAAS,KAAK,CACZ,sCACA,sCACF,CAAC,CAAC,CAAC,mBAAmB,aAAa;CACjC,CAAA,GAAA,OAAA,GAAA,CAAG,qDAAqD;EACtD,MAAM,UAAU,EAAE,IAAI,EAAE,IAAI,oBAAoB,EAAE;EAElD,CAAA,GAAA,mBAAA,mCAAA,CAAmC,SAAS,QAAQ;EAEpD,CAAA,GAAA,OAAA,OAAA,CAAO,QAAQ,GAAG,EAAE,CAAC,CAAC,KAAK,QAAQ;CACrC,CAAC;CAED,CAAA,GAAA,OAAA,GAAA,CAAG,uDAAuD;EACxD,MAAM,UAAU,EAAE,MAAM,oBAAoB;EAE5C,CAAA,GAAA,mBAAA,qCAAA,CAAqC,SAAS,QAAQ;EAEtD,CAAA,GAAA,OAAA,OAAA,CAAO,QAAQ,IAAI,CAAC,CAAC,KAAK,QAAQ;CACpC,CAAC;AACH,CAAC;eAEE,kEAAkE;CACnE,CAAA,GAAA,OAAA,OAAA,QAAA,GAAA,mBAAA,mCAAA,CACE,EAAE,IAAI,EAAE,IAAI,yBAAyB,EAAE,GACvC,oCACF,CAAC,CAAC,CAAC,QAAQ,uDAAuD;AACpE,CAAC;eAEE,oEAAoE;CACrE,CAAA,GAAA,OAAA,OAAA,QAAA,GAAA,mBAAA,qCAAA,CACE,EAAE,MAAM,yBAAyB,GACjC,oCACF,CAAC,CAAC,CAAC,QAAQ,uDAAuD;AACpE,CAAC"}
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  let _hexclave_shared_dist_utils_promises = require("@hexclave/shared/dist/utils/promises");
3
- let _hexclave_shared_dist_utils_urls = require("@hexclave/shared/dist/utils/urls");
4
3
  let ___in_page_ui_dom_js = require("../in-page-ui/dom.js");
5
4
  let ___in_page_ui_base_styles_js = require("../in-page-ui/base-styles.js");
6
5
  let _hexclave_shared_dist_utils_errors = require("@hexclave/shared/dist/utils/errors");
6
+ let _hexclave_shared_dist_utils_urls = require("@hexclave/shared/dist/utils/urls");
7
7
  let ___generated_env_js = require("../generated/env.js");
8
8
  //#region src/pushed-config-error-overlay/index.ts
9
9
  const GLOBAL_INSTANCE_KEY = "__hexclave-pushed-config-error-overlay";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "//": "THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY UNLESS YOU ALSO EDIT THE CORRESPONDING FILE IN packages/template (FOR package.json FILES, PLEASE EDIT package-template.json)",
3
3
  "name": "@hexclave/js",
4
- "version": "1.0.71",
4
+ "version": "1.0.72",
5
5
  "repository": "https://github.com/hexclave/hexclave",
6
6
  "sideEffects": false,
7
7
  "main": "./dist/index.js",
@@ -65,7 +65,7 @@
65
65
  "qrcode": "^1.5.4",
66
66
  "rrweb": "^1.1.3",
67
67
  "yup": "^1.7.1",
68
- "@hexclave/shared": "1.0.71"
68
+ "@hexclave/shared": "1.0.72"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@quetzallabs/i18n": "^0.1.19",
@@ -535,7 +535,7 @@ describe("StackClientApp cross-domain auth", () => {
535
535
  }
536
536
 
537
537
  const errorUrl = new URL(redirectedUrl);
538
- expect(errorUrl.origin).toBe(`https://${projectId}.built-with-stack-auth.com`);
538
+ expect(errorUrl.origin).toBe(`https://${projectId}.built-with-hexclave.com`);
539
539
  expect(errorUrl.pathname).toBe("/handler/error");
540
540
  expect(errorUrl.searchParams.get("errorCode")).toBe("SIGN_UP_REJECTED");
541
541
  expect(errorUrl.searchParams.get("message")).toBe("Your sign up was rejected by an administrator's sign-up rule.");
@@ -715,7 +715,7 @@ describe("StackClientApp cross-domain auth", () => {
715
715
  redirectBackUrl.searchParams.set("hexclave_cross_domain_code_challenge", handoffCodeChallenge);
716
716
  redirectBackUrl.searchParams.set("hexclave_cross_domain_after_callback_redirect_url", handoffAfterCallbackRedirect);
717
717
 
718
- const arrivalUrl = new URL(`https://${projectId}.built-with-stack-auth.com/handler/sign-in`);
718
+ const arrivalUrl = new URL(`https://${projectId}.built-with-hexclave.com/handler/sign-in`);
719
719
  arrivalUrl.searchParams.set("after_auth_return_to", redirectBackUrl.toString());
720
720
  arrivalUrl.searchParams.set("hexclave_cross_domain_state", handoffState);
721
721
  arrivalUrl.searchParams.set("hexclave_cross_domain_code_challenge", handoffCodeChallenge);
@@ -754,7 +754,7 @@ describe("StackClientApp cross-domain auth", () => {
754
754
  .mockResolvedValue(crossDomainAuthorizeRedirect);
755
755
 
756
756
  // All redirect-back query params were dropped before the after-sign-in redirect.
757
- windowMock.location.href = `https://${projectId}.built-with-stack-auth.com/handler/sign-in`;
757
+ windowMock.location.href = `https://${projectId}.built-with-hexclave.com/handler/sign-in`;
758
758
 
759
759
  const redirectUrl = await clientApp[hexclaveAppInternalsSymbol].getRedirectToHandlerUrl("afterSignIn");
760
760
 
@@ -59,6 +59,7 @@ import { EditableTeamMemberProfile, ReceivedTeamInvitation, SentTeamInvitation,
59
59
  import { buildCliAuthConfirmUrl, getHostedHandlerUrl, isHostedHandlerUrlForProject, resolveHandlerUrls } from "../../url-targets";
60
60
  import { augmentUrlWithPersistedRedirectBackState, saveRedirectBackStateFromUrl } from "./redirect-back-state";
61
61
  import { recordRedirectAndThrowIfLoopDetected } from "./redirect-loop-breaker";
62
+ import { scopePasskeyAuthenticationToHostname, scopePasskeyRegistrationToHostname } from "../../passkey-rp-id";
62
63
  import { ActiveSession, Auth, BaseUser, CurrentUser, InternalUserExtra, OAuthProvider, ProjectCurrentUser, SyncedPartialUser, TokenPartialUser, UserExtra, UserUpdateOptions, userUpdateOptionsToCrud, withUserDestructureGuard } from "../../users";
63
64
  import { StackClientApp, StackClientAppConstructorOptions, StackClientAppJson } from "../interfaces/client-app";
64
65
  import { _HexclaveAdminAppImplIncomplete } from "./admin-app-impl";
@@ -2233,12 +2234,11 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
2233
2234
 
2234
2235
  const { options_json, code } = initiationResult.data;
2235
2236
 
2236
- // HACK: Override the rpID to be the actual domain
2237
- if (options_json.rp.id !== "THIS_VALUE_WILL_BE_REPLACED.example.com") {
2238
- throw new HexclaveAssertionError(`Expected returned RP ID from server to equal sentinel, but found ${options_json.rp.id}`);
2239
- }
2240
-
2241
- options_json.rp.id = hostname;
2237
+ // Passkeys intentionally stay scoped to the hostname where they were
2238
+ // registered. In particular, passkeys created on the legacy hosted
2239
+ // components domain continue to work there but are not carried over to
2240
+ // a replacement hosted domain.
2241
+ scopePasskeyRegistrationToHostname(options_json, hostname);
2242
2242
 
2243
2243
  let attResp;
2244
2244
  try {
@@ -3425,11 +3425,10 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
3425
3425
 
3426
3426
  const { options_json, code } = initiationResult.data;
3427
3427
 
3428
- // HACK: Override the rpID to be the actual domain
3429
- if (options_json.rpId !== "THIS_VALUE_WILL_BE_REPLACED.example.com") {
3430
- throw new HexclaveAssertionError(`Expected returned RP ID from server to equal sentinel, but found ${options_json.rpId}`);
3431
- }
3432
- options_json.rpId = window.location.hostname;
3428
+ // Keep authentication scoped to the current hostname. This deliberately
3429
+ // does not add cross-domain compatibility for passkeys created on a
3430
+ // previous hosted components domain.
3431
+ scopePasskeyAuthenticationToHostname(options_json, window.location.hostname);
3433
3432
 
3434
3433
  const authentication_response = await startAuthentication({ optionsJSON: options_json });
3435
3434
  return await this._interface.signInWithPasskey({ authentication_response, code }, session);
@@ -35,6 +35,7 @@ import { Customer, CustomerProductsList, CustomerProductsRequestOptions, InlineP
35
35
  import { DataVaultStore } from "../../data-vault";
36
36
  import { EmailDeliveryInfo, SendEmailOptions } from "../../email";
37
37
  import { NotificationCategory } from "../../notification-categories";
38
+ import { scopePasskeyRegistrationToHostname } from "../../passkey-rp-id";
38
39
  import { AdminProjectPermissionDefinition, AdminTeamPermission, AdminTeamPermissionDefinition } from "../../permissions";
39
40
  import { EditableTeamMemberProfile, ReceivedTeamInvitation, SentTeamInvitation, ServerListTeamsOptions, ServerListUsersOptions, ServerTeam, ServerTeamCreateOptions, ServerTeamUpdateOptions, ServerTeamUser, Team, serverTeamCreateOptionsToCrud, serverTeamUpdateOptionsToCrud } from "../../teams";
40
41
  import { ProjectCurrentServerUser, ServerOAuthProvider, ServerUser, ServerUserCreateOptions, ServerUserUpdateOptions, serverUserCreateOptionsToCrud, serverUserUpdateOptionsToCrud, withUserDestructureGuard } from "../../users";
@@ -780,7 +781,6 @@ export class _HexclaveServerAppImplIncomplete<HasTokenStore extends boolean, Pro
780
781
  return providers.find((p) => p.id === id) ?? null;
781
782
  },
782
783
  async registerPasskey(options?: { hostname?: string }): Promise<Result<undefined, KnownErrors["PasskeyRegistrationFailed"] | KnownErrors["PasskeyWebAuthnError"]>> {
783
- // TODO remove duplicated code between this and the function in client-app-impl.ts
784
784
  const hostname = options?.hostname || (await app._getCurrentUrl())?.hostname;
785
785
  if (!hostname) {
786
786
  throw new HexclaveAssertionError("hostname must be provided if the Stack App does not have a redirect method");
@@ -795,12 +795,7 @@ export class _HexclaveServerAppImplIncomplete<HasTokenStore extends boolean, Pro
795
795
 
796
796
  const { options_json, code } = initiationResult.data;
797
797
 
798
- // HACK: Override the rpID to be the actual domain
799
- if (options_json.rp.id !== "THIS_VALUE_WILL_BE_REPLACED.example.com") {
800
- throw new HexclaveAssertionError(`Expected returned RP ID from server to equal sentinel, but found ${options_json.rp.id}`);
801
- }
802
-
803
- options_json.rp.id = hostname;
798
+ scopePasskeyRegistrationToHostname(options_json, hostname);
804
799
 
805
800
  let attResp;
806
801
  try {
@@ -0,0 +1,43 @@
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
+ import { describe, expect, it } from "vitest";
6
+ import { scopePasskeyAuthenticationToHostname, scopePasskeyRegistrationToHostname } from "./passkey-rp-id";
7
+
8
+ const passkeyRpIdSentinel = "THIS_VALUE_WILL_BE_REPLACED.example.com";
9
+
10
+ describe.each([
11
+ "project-id.built-with-hexclave.com",
12
+ "project-id.built-with-stack-auth.com",
13
+ ])("passkeys on %s", (hostname) => {
14
+ it("scopes registration to the current hostname", () => {
15
+ const options = { rp: { id: passkeyRpIdSentinel } };
16
+
17
+ scopePasskeyRegistrationToHostname(options, hostname);
18
+
19
+ expect(options.rp.id).toBe(hostname);
20
+ });
21
+
22
+ it("scopes authentication to the current hostname", () => {
23
+ const options = { rpId: passkeyRpIdSentinel };
24
+
25
+ scopePasskeyAuthenticationToHostname(options, hostname);
26
+
27
+ expect(options.rpId).toBe(hostname);
28
+ });
29
+ });
30
+
31
+ it("rejects registration options without the server sentinel", () => {
32
+ expect(() => scopePasskeyRegistrationToHostname(
33
+ { rp: { id: "unexpected.example.com" } },
34
+ "project-id.built-with-hexclave.com",
35
+ )).toThrow("Expected returned RP ID from server to equal sentinel");
36
+ });
37
+
38
+ it("rejects authentication options without the server sentinel", () => {
39
+ expect(() => scopePasskeyAuthenticationToHostname(
40
+ { rpId: "unexpected.example.com" },
41
+ "project-id.built-with-hexclave.com",
42
+ )).toThrow("Expected returned RP ID from server to equal sentinel");
43
+ });
@@ -0,0 +1,27 @@
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
+ import { HexclaveAssertionError } from "@hexclave/shared/dist/utils/errors";
6
+
7
+ const passkeyRpIdSentinel = "THIS_VALUE_WILL_BE_REPLACED.example.com";
8
+
9
+ export function scopePasskeyRegistrationToHostname(
10
+ options: { rp: { id?: string } },
11
+ hostname: string,
12
+ ): void {
13
+ if (options.rp.id !== passkeyRpIdSentinel) {
14
+ throw new HexclaveAssertionError(`Expected returned RP ID from server to equal sentinel, but found ${options.rp.id}`);
15
+ }
16
+ options.rp.id = hostname;
17
+ }
18
+
19
+ export function scopePasskeyAuthenticationToHostname(
20
+ options: { rpId?: string },
21
+ hostname: string,
22
+ ): void {
23
+ if (options.rpId !== passkeyRpIdSentinel) {
24
+ throw new HexclaveAssertionError(`Expected returned RP ID from server to equal sentinel, but found ${options.rpId}`);
25
+ }
26
+ options.rpId = hostname;
27
+ }