@hexclave/js 1.0.81 → 1.0.83

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 (22) hide show
  1. package/dist/{admin-app-impl-BtbWtULl.d.ts → admin-app-impl-CRIq3hPS.d.ts} +2 -2
  2. package/dist/{admin-app-impl-BtbWtULl.d.ts.map → admin-app-impl-CRIq3hPS.d.ts.map} +1 -1
  3. package/dist/esm/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts +1 -1
  4. package/dist/esm/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts.map +1 -1
  5. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.js +40 -0
  6. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.js.map +1 -1
  7. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.d.ts.map +1 -1
  8. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.js +6 -1
  9. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.js.map +1 -1
  10. package/dist/esm/lib/hexclave-app/apps/implementations/common.js +2 -2
  11. package/dist/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts +1 -1
  12. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.js +40 -0
  13. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.js.map +1 -1
  14. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.d.ts +1 -1
  15. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.js +6 -1
  16. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.js.map +1 -1
  17. package/dist/lib/hexclave-app/apps/implementations/common.js +2 -2
  18. package/dist/lib/hexclave-app/apps/implementations/index.d.ts +1 -1
  19. package/dist/lib/hexclave-app/apps/implementations/server-app-impl.d.ts +1 -1
  20. package/package.json +2 -2
  21. package/src/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.ts +47 -0
  22. package/src/lib/hexclave-app/apps/implementations/client-app-impl.ts +7 -1
@@ -13,8 +13,8 @@ let ______url_targets_js = require("../../url-targets.js");
13
13
  let _hexclave_shared_dist_utils_caches = require("@hexclave/shared/dist/utils/caches");
14
14
  let _hexclave_shared_dist_utils_globals = require("@hexclave/shared/dist/utils/globals");
15
15
  //#region src/lib/hexclave-app/apps/implementations/common.ts
16
- const clientVersion = "js @hexclave/js@1.0.81";
17
- if ("js @hexclave/js@1.0.81".startsWith("STACK_COMPILE_TIME"));
16
+ const clientVersion = "js @hexclave/js@1.0.83";
17
+ if ("js @hexclave/js@1.0.83".startsWith("STACK_COMPILE_TIME"));
18
18
  const replaceHexclavePortPrefix = (input) => {
19
19
  if (!input) return input;
20
20
  const prefix = ____________generated_env_js.envVars.HEXCLAVE_PORT_PREFIX;
@@ -1,4 +1,4 @@
1
- import { n as _HexclaveServerAppImplIncomplete, r as _HexclaveClientAppImplIncomplete, t as _HexclaveAdminAppImplIncomplete } from "../../../../admin-app-impl-BtbWtULl.js";
1
+ import { n as _HexclaveServerAppImplIncomplete, r as _HexclaveClientAppImplIncomplete, t as _HexclaveAdminAppImplIncomplete } from "../../../../admin-app-impl-CRIq3hPS.js";
2
2
 
3
3
  //#region src/lib/hexclave-app/apps/implementations/index.d.ts
4
4
  declare const _HexclaveAdminAppImpl: typeof _HexclaveAdminAppImplIncomplete, _HexclaveClientAppImpl: typeof _HexclaveClientAppImplIncomplete, _HexclaveServerAppImpl: typeof _HexclaveServerAppImplIncomplete;
@@ -1,2 +1,2 @@
1
- import { n as _HexclaveServerAppImplIncomplete } from "../../../../admin-app-impl-BtbWtULl.js";
1
+ import { n as _HexclaveServerAppImplIncomplete } from "../../../../admin-app-impl-CRIq3hPS.js";
2
2
  export { _HexclaveServerAppImplIncomplete };
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.81",
4
+ "version": "1.0.83",
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.81"
68
+ "@hexclave/shared": "1.0.83"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@quetzallabs/i18n": "^0.1.19",
@@ -476,6 +476,53 @@ describe("StackClientApp cross-domain auth", () => {
476
476
  expect(refreshedRawRefreshTokens).toEqual(["new-refresh-token"]);
477
477
  });
478
478
 
479
+ it("stops polling the browser cookie store when browser globals are removed", () => {
480
+ vi.useFakeTimers();
481
+ const clearIntervalSpy = vi.spyOn(globalThis, "clearInterval");
482
+ const previousWindow = globalThis.window;
483
+ const previousDocument = globalThis.document;
484
+
485
+ globalThis.document = createMockDocument();
486
+ globalThis.window = {
487
+ location: {
488
+ href: "https://demo.stack-auth.com/",
489
+ protocol: "https:",
490
+ hostname: "demo.stack-auth.com",
491
+ },
492
+ addEventListener: () => {},
493
+ removeEventListener: () => {},
494
+ } as any;
495
+
496
+ try {
497
+ const clientApp = new StackClientApp({
498
+ baseUrl: "http://localhost:12345",
499
+ projectId: "00000000-0000-4000-8000-000000000007",
500
+ publishableClientKey: "stack-pk-test",
501
+ tokenStore: "cookie",
502
+ redirectMethod: "none",
503
+ noAutomaticPrefetch: true,
504
+ automaticSideEffects: false,
505
+ devTool: false,
506
+ });
507
+ const getBrowserCookieTokenStore = Reflect.get(clientApp, "_getBrowserCookieTokenStore");
508
+ if (typeof getBrowserCookieTokenStore !== "function") {
509
+ throw new Error("Expected StackClientApp to expose _getBrowserCookieTokenStore in tests.");
510
+ }
511
+ getBrowserCookieTokenStore.call(clientApp);
512
+
513
+ Reflect.set(globalThis, "window", previousWindow);
514
+ Reflect.set(globalThis, "document", previousDocument);
515
+
516
+ expect(() => vi.advanceTimersByTime(100)).not.toThrow();
517
+ expect(clearIntervalSpy).toHaveBeenCalledOnce();
518
+ } finally {
519
+ Reflect.set(globalThis, "window", previousWindow);
520
+ Reflect.set(globalThis, "document", previousDocument);
521
+ clearIntervalSpy.mockRestore();
522
+ vi.useRealTimers();
523
+ }
524
+ });
525
+
479
526
  it("does not re-bounce nested cross-domain auth after the OAuth callback consumed code+state from the URL", async () => {
480
527
  const projectId = "00000000-0000-4000-8000-000000000008";
481
528
  const previousWindow = globalThis.window;
@@ -1514,7 +1514,12 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
1514
1514
  this._storedBrowserCookieTokenStore = new Store<TokenObject>(this._getCurrentBrowserCookieTokenStoreValue(null));
1515
1515
  let hasSucceededInWriting = true;
1516
1516
 
1517
- setInterval(() => {
1517
+ // Tests and server-side lifecycles can outlive browser globals, so stop polling when cookie reads no longer apply.
1518
+ const pollInterval = setInterval(() => {
1519
+ if (!isBrowserLike()) {
1520
+ clearInterval(pollInterval);
1521
+ return;
1522
+ }
1518
1523
  if (hasSucceededInWriting) {
1519
1524
  const oldValue = this._storedBrowserCookieTokenStore!.get();
1520
1525
  const currentValue = this._getCurrentBrowserCookieTokenStoreValue(oldValue);
@@ -1523,6 +1528,7 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
1523
1528
  }
1524
1529
  }
1525
1530
  }, 100);
1531
+ if (typeof pollInterval === "object") pollInterval.unref();
1526
1532
  this._storedBrowserCookieTokenStore.onChange((value) => {
1527
1533
  try {
1528
1534
  const refreshToken = value.refreshToken;