@hexclave/next 1.0.82 → 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-C8dYjvTN.d.ts → admin-app-impl-PVoJQhtl.d.ts} +3 -3
  2. package/dist/{admin-app-impl-C8dYjvTN.d.ts.map → admin-app-impl-PVoJQhtl.d.ts.map} +1 -1
  3. package/dist/esm/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts +2 -2
  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 +4 -4
  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
@@ -18,8 +18,8 @@ let ____________generated_env_js = require("../../../../generated/env.js");
18
18
  let ____________utils_react_js = require("../../../../utils/react.js");
19
19
  let ______url_targets_js = require("../../url-targets.js");
20
20
  //#region src/lib/hexclave-app/apps/implementations/common.ts
21
- const clientVersion = "js @hexclave/next@1.0.82";
22
- if ("js @hexclave/next@1.0.82".startsWith("STACK_COMPILE_TIME"));
21
+ const clientVersion = "js @hexclave/next@1.0.83";
22
+ if ("js @hexclave/next@1.0.83".startsWith("STACK_COMPILE_TIME"));
23
23
  const replaceHexclavePortPrefix = (input) => {
24
24
  if (!input) return input;
25
25
  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-C8dYjvTN.js";
1
+ import { n as _HexclaveServerAppImplIncomplete, r as _HexclaveClientAppImplIncomplete, t as _HexclaveAdminAppImplIncomplete } from "../../../../admin-app-impl-PVoJQhtl.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-C8dYjvTN.js";
1
+ import { n as _HexclaveServerAppImplIncomplete } from "../../../../admin-app-impl-PVoJQhtl.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/next",
4
- "version": "1.0.82",
4
+ "version": "1.0.83",
5
5
  "repository": "https://github.com/hexclave/hexclave",
6
6
  "sideEffects": false,
7
7
  "main": "./dist/index.js",
@@ -74,9 +74,9 @@
74
74
  "tailwindcss-animate": "^1.0.7",
75
75
  "rrweb": "^1.1.3",
76
76
  "yup": "^1.7.1",
77
- "@hexclave/ui": "1.0.82",
78
- "@hexclave/sc": "1.0.82",
79
- "@hexclave/shared": "1.0.82"
77
+ "@hexclave/sc": "1.0.83",
78
+ "@hexclave/shared": "1.0.83",
79
+ "@hexclave/ui": "1.0.83"
80
80
  },
81
81
  "peerDependencies": {
82
82
  "@types/react": ">=18.0.0",
@@ -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;
@@ -1554,7 +1554,12 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
1554
1554
  this._storedBrowserCookieTokenStore = new Store<TokenObject>(this._getCurrentBrowserCookieTokenStoreValue(null));
1555
1555
  let hasSucceededInWriting = true;
1556
1556
 
1557
- setInterval(() => {
1557
+ // Tests and server-side lifecycles can outlive browser globals, so stop polling when cookie reads no longer apply.
1558
+ const pollInterval = setInterval(() => {
1559
+ if (!isBrowserLike()) {
1560
+ clearInterval(pollInterval);
1561
+ return;
1562
+ }
1558
1563
  if (hasSucceededInWriting) {
1559
1564
  const oldValue = this._storedBrowserCookieTokenStore!.get();
1560
1565
  const currentValue = this._getCurrentBrowserCookieTokenStoreValue(oldValue);
@@ -1563,6 +1568,7 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
1563
1568
  }
1564
1569
  }
1565
1570
  }, 100);
1571
+ if (typeof pollInterval === "object") pollInterval.unref();
1566
1572
  this._storedBrowserCookieTokenStore.onChange((value) => {
1567
1573
  try {
1568
1574
  const refreshToken = value.refreshToken;