@hexclave/js 1.0.111 → 1.0.112

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 (34) hide show
  1. package/dist/{admin-app-impl-BXZH8f0X.d.ts → admin-app-impl-DLUdv3HI.d.ts} +8 -8
  2. package/dist/{admin-app-impl-BXZH8f0X.d.ts.map → admin-app-impl-DLUdv3HI.d.ts.map} +1 -1
  3. package/dist/{cookie-DTOQvCYn.d.ts → cookie-DwI1VmzU.d.ts} +6 -1
  4. package/dist/cookie-DwI1VmzU.d.ts.map +1 -0
  5. package/dist/esm/lib/cookie.d.ts +5 -0
  6. package/dist/esm/lib/cookie.d.ts.map +1 -1
  7. package/dist/esm/lib/cookie.js +5 -0
  8. package/dist/esm/lib/cookie.js.map +1 -1
  9. package/dist/esm/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts +4 -4
  10. package/dist/esm/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts.map +1 -1
  11. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.d.ts +2 -2
  12. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.d.ts.map +1 -1
  13. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.js.map +1 -1
  14. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.next-server-session.test.d.ts +1 -0
  15. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.next-server-session.test.js +46 -0
  16. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.next-server-session.test.js.map +1 -0
  17. package/dist/esm/lib/hexclave-app/apps/implementations/common.js +2 -2
  18. package/dist/lib/cookie.d.ts +1 -1
  19. package/dist/lib/cookie.js +5 -0
  20. package/dist/lib/cookie.js.map +1 -1
  21. package/dist/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts +1 -1
  22. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.d.ts +1 -1
  23. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.js.map +1 -1
  24. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.next-server-session.test.d.ts +1 -0
  25. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.next-server-session.test.js +45 -0
  26. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.next-server-session.test.js.map +1 -0
  27. package/dist/lib/hexclave-app/apps/implementations/common.js +2 -2
  28. package/dist/lib/hexclave-app/apps/implementations/index.d.ts +1 -1
  29. package/dist/lib/hexclave-app/apps/implementations/server-app-impl.d.ts +1 -1
  30. package/package.json +2 -2
  31. package/src/lib/cookie.ts +9 -0
  32. package/src/lib/hexclave-app/apps/implementations/client-app-impl.next-server-session.test.ts +55 -0
  33. package/src/lib/hexclave-app/apps/implementations/client-app-impl.ts +1 -0
  34. package/dist/cookie-DTOQvCYn.d.ts.map +0 -1
@@ -0,0 +1,45 @@
1
+ let vitest = require("vitest");
2
+ let ___interfaces_client_app_js = require("../interfaces/client-app.js");
3
+ //#region src/lib/hexclave-app/apps/implementations/client-app-impl.next-server-session.test.ts
4
+ function createCookieHelper(identity) {
5
+ return {
6
+ identity,
7
+ get: () => null,
8
+ getAll: () => ({}),
9
+ set: () => {},
10
+ setOrDelete: () => {},
11
+ delete: () => {}
12
+ };
13
+ }
14
+ function createClientApp() {
15
+ return new ___interfaces_client_app_js.StackClientApp({
16
+ baseUrl: "http://localhost:12345",
17
+ projectId: "00000000-0000-4000-8000-000000000000",
18
+ publishableClientKey: "stack-pk-test",
19
+ tokenStore: "memory",
20
+ redirectMethod: "none",
21
+ noAutomaticPrefetch: true,
22
+ devTool: false
23
+ });
24
+ }
25
+ (0, vitest.describe)("StackClientApp Next.js server sessions", () => {
26
+ (0, vitest.it)("shares one token store and session across cookie helpers from the same request", () => {
27
+ const clientApp = createClientApp();
28
+ const getTokenStore = Reflect.get(clientApp, "_getOrCreateTokenStore");
29
+ const getSession = Reflect.get(clientApp, "_getSessionFromTokenStore");
30
+ const requestIdentity = {};
31
+ const firstStore = getTokenStore.call(clientApp, createCookieHelper(requestIdentity), "nextjs-cookie");
32
+ const secondStore = getTokenStore.call(clientApp, createCookieHelper(requestIdentity), "nextjs-cookie");
33
+ (0, vitest.expect)(secondStore).toBe(firstStore);
34
+ (0, vitest.expect)(getSession.call(clientApp, secondStore)).toBe(getSession.call(clientApp, firstStore));
35
+ });
36
+ (0, vitest.it)("isolates token stores belonging to different requests", () => {
37
+ const clientApp = createClientApp();
38
+ const getTokenStore = Reflect.get(clientApp, "_getOrCreateTokenStore");
39
+ const firstStore = getTokenStore.call(clientApp, createCookieHelper({}), "nextjs-cookie");
40
+ (0, vitest.expect)(getTokenStore.call(clientApp, createCookieHelper({}), "nextjs-cookie")).not.toBe(firstStore);
41
+ });
42
+ });
43
+ //#endregion
44
+
45
+ //# sourceMappingURL=client-app-impl.next-server-session.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-app-impl.next-server-session.test.js","names":["StackClientApp"],"sources":["../../../../../src/lib/hexclave-app/apps/implementations/client-app-impl.next-server-session.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 { CookieHelper } from \"../../../cookie\";\nimport { StackClientApp } from \"../interfaces/client-app\";\n\nfunction createCookieHelper(identity: object): CookieHelper {\n return {\n identity,\n get: () => null,\n getAll: () => ({}),\n set: () => {},\n setOrDelete: () => {},\n delete: () => {},\n };\n}\n\nfunction createClientApp() {\n return new StackClientApp({\n baseUrl: \"http://localhost:12345\",\n projectId: \"00000000-0000-4000-8000-000000000000\",\n publishableClientKey: \"stack-pk-test\",\n tokenStore: \"memory\",\n redirectMethod: \"none\",\n noAutomaticPrefetch: true,\n devTool: false,\n });\n}\n\ndescribe(\"StackClientApp Next.js server sessions\", () => {\n it(\"shares one token store and session across cookie helpers from the same request\", () => {\n const clientApp = createClientApp();\n const getTokenStore = Reflect.get(clientApp, \"_getOrCreateTokenStore\");\n const getSession = Reflect.get(clientApp, \"_getSessionFromTokenStore\");\n const requestIdentity = {};\n\n const firstStore = getTokenStore.call(clientApp, createCookieHelper(requestIdentity), \"nextjs-cookie\");\n const secondStore = getTokenStore.call(clientApp, createCookieHelper(requestIdentity), \"nextjs-cookie\");\n\n expect(secondStore).toBe(firstStore);\n expect(getSession.call(clientApp, secondStore)).toBe(getSession.call(clientApp, firstStore));\n });\n\n it(\"isolates token stores belonging to different requests\", () => {\n const clientApp = createClientApp();\n const getTokenStore = Reflect.get(clientApp, \"_getOrCreateTokenStore\");\n\n const firstStore = getTokenStore.call(clientApp, createCookieHelper({}), \"nextjs-cookie\");\n const secondStore = getTokenStore.call(clientApp, createCookieHelper({}), \"nextjs-cookie\");\n\n expect(secondStore).not.toBe(firstStore);\n });\n});\n"],"mappings":";;;AAQA,SAAS,mBAAmB,UAAgC;CAC1D,OAAO;EACL;EACA,WAAW;EACX,eAAe,CAAC;EAChB,WAAW,CAAC;EACZ,mBAAmB,CAAC;EACpB,cAAc,CAAC;CACjB;AACF;AAEA,SAAS,kBAAkB;CACzB,OAAO,IAAIA,4BAAAA,eAAe;EACxB,SAAS;EACT,WAAW;EACX,sBAAsB;EACtB,YAAY;EACZ,gBAAgB;EAChB,qBAAqB;EACrB,SAAS;CACX,CAAC;AACH;qBAES,gDAAgD;CACvD,CAAA,GAAA,OAAA,GAAA,CAAG,wFAAwF;EACzF,MAAM,YAAY,gBAAgB;EAClC,MAAM,gBAAgB,QAAQ,IAAI,WAAW,wBAAwB;EACrE,MAAM,aAAa,QAAQ,IAAI,WAAW,2BAA2B;EACrE,MAAM,kBAAkB,CAAC;EAEzB,MAAM,aAAa,cAAc,KAAK,WAAW,mBAAmB,eAAe,GAAG,eAAe;EACrG,MAAM,cAAc,cAAc,KAAK,WAAW,mBAAmB,eAAe,GAAG,eAAe;EAEtG,CAAA,GAAA,OAAA,OAAA,CAAO,WAAW,CAAC,CAAC,KAAK,UAAU;EACnC,CAAA,GAAA,OAAA,OAAA,CAAO,WAAW,KAAK,WAAW,WAAW,CAAC,CAAC,CAAC,KAAK,WAAW,KAAK,WAAW,UAAU,CAAC;CAC7F,CAAC;CAED,CAAA,GAAA,OAAA,GAAA,CAAG,+DAA+D;EAChE,MAAM,YAAY,gBAAgB;EAClC,MAAM,gBAAgB,QAAQ,IAAI,WAAW,wBAAwB;EAErE,MAAM,aAAa,cAAc,KAAK,WAAW,mBAAmB,CAAC,CAAC,GAAG,eAAe;EAGxF,CAAA,GAAA,OAAA,OAAA,CAFoB,cAAc,KAAK,WAAW,mBAAmB,CAAC,CAAC,GAAG,eAEzD,CAAC,CAAC,CAAC,IAAI,KAAK,UAAU;CACzC,CAAC;AACH,CAAC"}
@@ -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.111";
17
- if ("js @hexclave/js@1.0.111".startsWith("STACK_COMPILE_TIME"));
16
+ const clientVersion = "js @hexclave/js@1.0.112";
17
+ if ("js @hexclave/js@1.0.112".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-BXZH8f0X.js";
1
+ import { n as _HexclaveServerAppImplIncomplete, r as _HexclaveClientAppImplIncomplete, t as _HexclaveAdminAppImplIncomplete } from "../../../../admin-app-impl-DLUdv3HI.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-BXZH8f0X.js";
1
+ import { n as _HexclaveServerAppImplIncomplete } from "../../../../admin-app-impl-DLUdv3HI.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.111",
4
+ "version": "1.0.112",
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.111"
68
+ "@hexclave/shared": "1.0.112"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@quetzallabs/i18n": "^0.1.19",
package/src/lib/cookie.ts CHANGED
@@ -78,6 +78,11 @@ function ensureClient() {
78
78
  }
79
79
 
80
80
  export type CookieHelper = {
81
+ /**
82
+ * Stable for the browser or server request that owns this helper. Consumers use this to share request-local state
83
+ * even when multiple helper wrappers are created for the same underlying cookie store.
84
+ */
85
+ readonly identity: object,
81
86
  get: (name: string) => string | null,
82
87
  getAll: () => Record<string, string>,
83
88
  set: (name: string, value: string, options: SetCookieOptions) => void,
@@ -91,6 +96,7 @@ export async function createPlaceholderCookieHelper(): Promise<CookieHelper> {
91
96
  throw new HexclaveAssertionError("Throwing cookie helper is just a placeholder. This should never be called");
92
97
  }
93
98
  return {
99
+ identity: placeholderCookieHelperIdentity,
94
100
  get: throwError,
95
101
  getAll: throwError,
96
102
  set: throwError,
@@ -125,6 +131,7 @@ export function createCookieHelperSync(): CookieHelper {
125
131
  throw new HexclaveAssertionError("Synchronous server cookie helpers are not available on this platform");
126
132
  }
127
133
  return {
134
+ identity: placeholderCookieHelperIdentity,
128
135
  get: throwError,
129
136
  getAll: throwError,
130
137
  set: throwError,
@@ -134,8 +141,10 @@ export function createCookieHelperSync(): CookieHelper {
134
141
  }
135
142
 
136
143
 
144
+ const browserCookieHelperIdentity = { "browser cookie helper identity": true };
137
145
  export function createBrowserCookieHelper(): CookieHelper {
138
146
  return {
147
+ identity: browserCookieHelperIdentity,
139
148
  get: getCookieClient,
140
149
  getAll: getAllCookiesClient,
141
150
  set: setCookieClient,
@@ -0,0 +1,55 @@
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 { CookieHelper } from "../../../cookie";
7
+ import { StackClientApp } from "../interfaces/client-app";
8
+
9
+ function createCookieHelper(identity: object): CookieHelper {
10
+ return {
11
+ identity,
12
+ get: () => null,
13
+ getAll: () => ({}),
14
+ set: () => {},
15
+ setOrDelete: () => {},
16
+ delete: () => {},
17
+ };
18
+ }
19
+
20
+ function createClientApp() {
21
+ return new StackClientApp({
22
+ baseUrl: "http://localhost:12345",
23
+ projectId: "00000000-0000-4000-8000-000000000000",
24
+ publishableClientKey: "stack-pk-test",
25
+ tokenStore: "memory",
26
+ redirectMethod: "none",
27
+ noAutomaticPrefetch: true,
28
+ devTool: false,
29
+ });
30
+ }
31
+
32
+ describe("StackClientApp Next.js server sessions", () => {
33
+ it("shares one token store and session across cookie helpers from the same request", () => {
34
+ const clientApp = createClientApp();
35
+ const getTokenStore = Reflect.get(clientApp, "_getOrCreateTokenStore");
36
+ const getSession = Reflect.get(clientApp, "_getSessionFromTokenStore");
37
+ const requestIdentity = {};
38
+
39
+ const firstStore = getTokenStore.call(clientApp, createCookieHelper(requestIdentity), "nextjs-cookie");
40
+ const secondStore = getTokenStore.call(clientApp, createCookieHelper(requestIdentity), "nextjs-cookie");
41
+
42
+ expect(secondStore).toBe(firstStore);
43
+ expect(getSession.call(clientApp, secondStore)).toBe(getSession.call(clientApp, firstStore));
44
+ });
45
+
46
+ it("isolates token stores belonging to different requests", () => {
47
+ const clientApp = createClientApp();
48
+ const getTokenStore = Reflect.get(clientApp, "_getOrCreateTokenStore");
49
+
50
+ const firstStore = getTokenStore.call(clientApp, createCookieHelper({}), "nextjs-cookie");
51
+ const secondStore = getTokenStore.call(clientApp, createCookieHelper({}), "nextjs-cookie");
52
+
53
+ expect(secondStore).not.toBe(firstStore);
54
+ });
55
+ });
@@ -1610,6 +1610,7 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
1610
1610
  if (isBrowserLike()) {
1611
1611
  return this._getBrowserCookieTokenStore();
1612
1612
  } else {
1613
+
1613
1614
  const tokens = this._getTokensFromCookies(cookieHelper.getAll());
1614
1615
  const store = new Store<TokenObject>(tokens);
1615
1616
  store.onChange((value) => {
@@ -1 +0,0 @@
1
- {"version":3,"file":"cookie-DTOQvCYn.d.ts","names":[],"sources":["../src/lib/cookie.ts"],"mappings":";KAqEK,gBAAA;EAAqB,MAAA;EAA4B,qBAAA;EAAiC,MAAA;EAAiB,MAAA;AAAA;AAAA,KACnG,mBAAA;EAAwB,qBAAA;EAAiC,MAAM;AAAA;AAAA,KASxD,YAAA;EACV,GAAA,GAAM,IAAA;EACN,MAAA,QAAc,MAAA;EACd,GAAA,GAAM,IAAA,UAAc,KAAA,UAAe,OAAA,EAAS,gBAAA;EAC5C,WAAA,GAAc,IAAA,UAAc,KAAA,iBAAsB,OAAA,EAAS,gBAAA,GAAmB,mBAAA;EAC9E,MAAA,GAAS,IAAA,UAAc,OAAA,EAAS,mBAAA;AAAA;AAAA,iBAIZ,6BAAA,IAAiC,OAAO,CAAC,YAAA;AAAA,iBAuBzC,kBAAA,IAAsB,OAAO,CAAC,YAAA;AAAA,iBAQpC,sBAAA,IAA0B,YAAY;AAAA,iBAiBtC,yBAAA,IAA6B,YAAY;AAAA,iBAuBzC,eAAA,CAAgB,IAAY;AAAA,iBAK5B,mBAAA,IAAuB,MAAM;AAAA,iBASvB,SAAA,CAAU,IAAA,WAAe,OAAO;AAAA,iBAKhC,QAAA,IAAY,OAAO;AAAA,iBAqFzB,uBAAA,CAAwB,IAAA,UAAc,KAAA,iBAAsB,OAAA,EAAS,gBAAA,GAAmB,mBAAmB;AAAA,iBASrG,iBAAA,CAAkB,IAAA,UAAc,KAAA,iBAAsB,OAAA,EAAS,gBAAA,GAAmB,mBAAA,GAAmB,OAAA;AAAA,iBAK3G,kBAAA,CAAmB,IAAA,UAAc,OAAA,EAAS,mBAAmB;AAAA,iBAKvD,YAAA,CAAa,IAAA,UAAc,OAAA,EAAS,mBAAA,GAAmB,OAAA;AAAA,iBAK7D,eAAA,CAAgB,IAAA,UAAc,KAAA,UAAe,OAAA,EAAS,gBAAgB;AAAA,iBAKhE,SAAA,CAAU,IAAA,UAAc,KAAA,UAAe,OAAA,EAAS,gBAAA,GAAgB,OAAA;AAAA,iBAKhE,oBAAA,IAAoB,OAAA;;;;iBAe1B,6BAAA,CAA8B,KAAA;EAAA,YAAA;AAAA"}