@hexclave/js 1.0.67 → 1.0.68

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 (65) hide show
  1. package/dist/{admin-app-impl-C051fyaH.d.ts → admin-app-impl-DxZSp6ov.d.ts} +10 -5
  2. package/dist/admin-app-impl-DxZSp6ov.d.ts.map +1 -0
  3. package/dist/clickmap/clickmap-core.d.ts +1 -1
  4. package/dist/clickmap/index.d.ts +1 -1
  5. package/dist/{client-app-o8N3XCYe.d.ts → client-app-DBcv6rRn.d.ts} +13 -6
  6. package/dist/client-app-DBcv6rRn.d.ts.map +1 -0
  7. package/dist/dev-tool/dev-tool-core.d.ts +1 -1
  8. package/dist/dev-tool/index.d.ts +1 -1
  9. package/dist/esm/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts +1 -1
  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 +7 -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 +22 -5
  14. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.js.map +1 -1
  15. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.sign-in-cache-warmup.test.d.ts +1 -0
  16. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.sign-in-cache-warmup.test.js +97 -0
  17. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.sign-in-cache-warmup.test.js.map +1 -0
  18. package/dist/esm/lib/hexclave-app/apps/implementations/common.js +2 -2
  19. package/dist/esm/lib/hexclave-app/apps/implementations/server-app-impl.d.ts.map +1 -1
  20. package/dist/esm/lib/hexclave-app/apps/implementations/server-app-impl.js +1 -4
  21. package/dist/esm/lib/hexclave-app/apps/implementations/server-app-impl.js.map +1 -1
  22. package/dist/esm/lib/hexclave-app/apps/interfaces/client-app.d.ts +1 -1
  23. package/dist/esm/lib/hexclave-app/apps/interfaces/client-app.d.ts.map +1 -1
  24. package/dist/esm/lib/hexclave-app/apps/interfaces/client-app.js.map +1 -1
  25. package/dist/esm/lib/hexclave-app/teams/index.d.ts +1 -0
  26. package/dist/esm/lib/hexclave-app/teams/index.d.ts.map +1 -1
  27. package/dist/esm/lib/hexclave-app/teams/index.js.map +1 -1
  28. package/dist/esm/lib/hexclave-app/users/index.d.ts +10 -4
  29. package/dist/esm/lib/hexclave-app/users/index.d.ts.map +1 -1
  30. package/dist/esm/lib/hexclave-app/users/index.js.map +1 -1
  31. package/dist/index.d.ts +1 -1
  32. package/dist/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts +1 -1
  33. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.d.ts +1 -1
  34. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.js +22 -5
  35. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.js.map +1 -1
  36. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.sign-in-cache-warmup.test.d.ts +1 -0
  37. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.sign-in-cache-warmup.test.js +96 -0
  38. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.sign-in-cache-warmup.test.js.map +1 -0
  39. package/dist/lib/hexclave-app/apps/implementations/common.js +2 -2
  40. package/dist/lib/hexclave-app/apps/implementations/index.d.ts +1 -1
  41. package/dist/lib/hexclave-app/apps/implementations/server-app-impl.d.ts +1 -1
  42. package/dist/lib/hexclave-app/apps/implementations/server-app-impl.js +1 -4
  43. package/dist/lib/hexclave-app/apps/implementations/server-app-impl.js.map +1 -1
  44. package/dist/lib/hexclave-app/apps/index.d.ts +1 -1
  45. package/dist/lib/hexclave-app/apps/interfaces/admin-app.d.ts +1 -1
  46. package/dist/lib/hexclave-app/apps/interfaces/client-app.d.ts +1 -1
  47. package/dist/lib/hexclave-app/apps/interfaces/client-app.js.map +1 -1
  48. package/dist/lib/hexclave-app/apps/interfaces/server-app.d.ts +1 -1
  49. package/dist/lib/hexclave-app/index.d.ts +1 -1
  50. package/dist/lib/hexclave-app/projects/index.d.ts +1 -1
  51. package/dist/lib/hexclave-app/teams/index.d.ts +1 -1
  52. package/dist/lib/hexclave-app/teams/index.js.map +1 -1
  53. package/dist/lib/hexclave-app/users/index.d.ts +1 -1
  54. package/dist/lib/hexclave-app/users/index.js.map +1 -1
  55. package/dist/pushed-config-error-overlay/index.d.ts +1 -1
  56. package/package.json +2 -2
  57. package/src/integrations/convex/component/README.md +4 -4
  58. package/src/lib/hexclave-app/apps/implementations/client-app-impl.sign-in-cache-warmup.test.ts +94 -0
  59. package/src/lib/hexclave-app/apps/implementations/client-app-impl.ts +33 -8
  60. package/src/lib/hexclave-app/apps/implementations/server-app-impl.ts +1 -10
  61. package/src/lib/hexclave-app/apps/interfaces/client-app.ts +1 -1
  62. package/src/lib/hexclave-app/teams/index.ts +1 -0
  63. package/src/lib/hexclave-app/users/index.ts +9 -4
  64. package/dist/admin-app-impl-C051fyaH.d.ts.map +0 -1
  65. package/dist/client-app-o8N3XCYe.d.ts.map +0 -1
@@ -0,0 +1,96 @@
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.sign-in-cache-warmup.test.ts
4
+ function createAccessTokenString(refreshTokenId) {
5
+ const encode = (value) => Buffer.from(JSON.stringify(value)).toString("base64url");
6
+ const nowSeconds = Math.floor(Date.now() / 1e3);
7
+ return [
8
+ encode({
9
+ alg: "none",
10
+ typ: "JWT"
11
+ }),
12
+ encode({
13
+ sub: "user-id",
14
+ exp: nowSeconds + 60,
15
+ iat: nowSeconds,
16
+ refresh_token_id: refreshTokenId
17
+ }),
18
+ ""
19
+ ].join(".");
20
+ }
21
+ function createTestSetup(getUser) {
22
+ const clientApp = new ___interfaces_client_app_js.StackClientApp({
23
+ baseUrl: "http://localhost:12345",
24
+ projectId: "00000000-0000-4000-8000-000000000000",
25
+ publishableClientKey: "stack-pk-test",
26
+ tokenStore: "memory",
27
+ redirectMethod: "none",
28
+ noAutomaticPrefetch: true
29
+ });
30
+ Reflect.set(Reflect.get(clientApp, "_interface"), "getClientUserByToken", getUser);
31
+ const privateMethod = (name) => (...args) => Reflect.get(clientApp, name).apply(clientApp, args);
32
+ return {
33
+ currentUserCache: Reflect.get(clientApp, "_currentUserCache"),
34
+ signIn: (refreshToken) => privateMethod("_signInToAccountWithTokens")({
35
+ accessToken: createAccessTokenString(`${refreshToken}-id`),
36
+ refreshToken
37
+ }),
38
+ getSessionFromTokenStore: privateMethod("_getSessionFromTokenStore"),
39
+ getTokenStore: async () => privateMethod("_getOrCreateTokenStore")(await privateMethod("_createCookieHelper")())
40
+ };
41
+ }
42
+ (0, vitest.describe)("StackClientApp sign-in cache warm-up", () => {
43
+ (0, vitest.it)("has the new session's user cached by the time the token store change is published", async () => {
44
+ let getUserCalls = 0;
45
+ const setup = createTestSetup(async () => {
46
+ getUserCalls += 1;
47
+ return {
48
+ id: "user-id",
49
+ is_anonymous: false,
50
+ is_restricted: false
51
+ };
52
+ });
53
+ const cacheStatusesOnTokenStoreChange = [];
54
+ const tokenStore = await setup.getTokenStore();
55
+ tokenStore.onChange(() => {
56
+ const session = setup.getSessionFromTokenStore(tokenStore);
57
+ cacheStatusesOnTokenStoreChange.push(setup.currentUserCache.getIfCached([session]).status);
58
+ });
59
+ await setup.signIn("refresh-token");
60
+ (0, vitest.expect)(cacheStatusesOnTokenStoreChange).toEqual(["ok"]);
61
+ (0, vitest.expect)(setup.currentUserCache.getIfCached([setup.getSessionFromTokenStore(tokenStore)]).data.data).toMatchObject({ id: "user-id" });
62
+ (0, vitest.expect)(getUserCalls).toBe(1);
63
+ });
64
+ (0, vitest.it)("doesn't let a slow sign-in publish its tokens on top of a sign-in that started later", async () => {
65
+ let onFirstFetchStarted;
66
+ let releaseFirstFetch;
67
+ const firstFetchStarted = new Promise((resolve) => {
68
+ onFirstFetchStarted = resolve;
69
+ });
70
+ const firstFetchReleased = new Promise((resolve) => {
71
+ releaseFirstFetch = resolve;
72
+ });
73
+ let getUserCalls = 0;
74
+ const setup = createTestSetup(async () => {
75
+ if (++getUserCalls === 1) {
76
+ onFirstFetchStarted();
77
+ await firstFetchReleased;
78
+ }
79
+ return {
80
+ id: "user-id",
81
+ is_anonymous: false,
82
+ is_restricted: false
83
+ };
84
+ });
85
+ const slowSignIn = setup.signIn("old-refresh-token");
86
+ await firstFetchStarted;
87
+ await setup.signIn("new-refresh-token");
88
+ releaseFirstFetch();
89
+ await slowSignIn;
90
+ (0, vitest.expect)(getUserCalls).toBe(2);
91
+ (0, vitest.expect)((await setup.getTokenStore()).get().refreshToken).toBe("new-refresh-token");
92
+ });
93
+ });
94
+ //#endregion
95
+
96
+ //# sourceMappingURL=client-app-impl.sign-in-cache-warmup.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-app-impl.sign-in-cache-warmup.test.js","names":["StackClientApp"],"sources":["../../../../../src/lib/hexclave-app/apps/implementations/client-app-impl.sign-in-cache-warmup.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 { StackClientApp } from \"../interfaces/client-app\";\n\nfunction createAccessTokenString(refreshTokenId: string): string {\n const encode = (value: unknown) => Buffer.from(JSON.stringify(value)).toString(\"base64url\");\n const nowSeconds = Math.floor(Date.now() / 1000);\n return [\n encode({ alg: \"none\", typ: \"JWT\" }),\n encode({ sub: \"user-id\", exp: nowSeconds + 60, iat: nowSeconds, refresh_token_id: refreshTokenId }),\n \"\",\n ].join(\".\");\n}\n\nfunction createTestSetup(getUser: () => Promise<unknown>) {\n const clientApp = 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 });\n Reflect.set(Reflect.get(clientApp, \"_interface\"), \"getClientUserByToken\", getUser);\n const privateMethod = (name: string) => (...args: unknown[]) => Reflect.get(clientApp, name).apply(clientApp, args);\n return {\n currentUserCache: Reflect.get(clientApp, \"_currentUserCache\"),\n signIn: (refreshToken: string) => privateMethod(\"_signInToAccountWithTokens\")({\n accessToken: createAccessTokenString(`${refreshToken}-id`),\n refreshToken,\n }),\n getSessionFromTokenStore: privateMethod(\"_getSessionFromTokenStore\"),\n getTokenStore: async () => privateMethod(\"_getOrCreateTokenStore\")(await privateMethod(\"_createCookieHelper\")()),\n };\n}\n\ndescribe(\"StackClientApp sign-in cache warm-up\", () => {\n it(\"has the new session's user cached by the time the token store change is published\", async () => {\n let getUserCalls = 0;\n const setup = createTestSetup(async () => {\n getUserCalls += 1;\n return { id: \"user-id\", is_anonymous: false, is_restricted: false };\n });\n\n // `useUser()` hooks re-read the cache when the session changes, so if the cache were still cold here, they'd\n // suspend and flash their Suspense fallback over the UI that's already on the screen.\n const cacheStatusesOnTokenStoreChange: string[] = [];\n const tokenStore = await setup.getTokenStore();\n tokenStore.onChange(() => {\n const session = setup.getSessionFromTokenStore(tokenStore);\n cacheStatusesOnTokenStoreChange.push(setup.currentUserCache.getIfCached([session]).status);\n });\n\n await setup.signIn(\"refresh-token\");\n\n expect(cacheStatusesOnTokenStoreChange).toEqual([\"ok\"]);\n const cachedUser = setup.currentUserCache.getIfCached([setup.getSessionFromTokenStore(tokenStore)]);\n expect(cachedUser.data.data).toMatchObject({ id: \"user-id\" });\n expect(getUserCalls).toBe(1);\n });\n\n it(\"doesn't let a slow sign-in publish its tokens on top of a sign-in that started later\", async () => {\n let onFirstFetchStarted!: () => void;\n let releaseFirstFetch!: () => void;\n const firstFetchStarted = new Promise<void>((resolve) => {\n onFirstFetchStarted = resolve;\n });\n const firstFetchReleased = new Promise<void>((resolve) => {\n releaseFirstFetch = resolve;\n });\n\n let getUserCalls = 0;\n const setup = createTestSetup(async () => {\n // Only the first sign-in's fetch blocks, so the second one deterministically gets to publish while it waits.\n if (++getUserCalls === 1) {\n onFirstFetchStarted();\n await firstFetchReleased;\n }\n return { id: \"user-id\", is_anonymous: false, is_restricted: false };\n });\n\n const slowSignIn = setup.signIn(\"old-refresh-token\");\n await firstFetchStarted;\n await setup.signIn(\"new-refresh-token\");\n releaseFirstFetch();\n await slowSignIn;\n\n expect(getUserCalls).toBe(2);\n expect((await setup.getTokenStore()).get().refreshToken).toBe(\"new-refresh-token\");\n });\n});\n"],"mappings":";;;AAOA,SAAS,wBAAwB,gBAAgC;CAC/D,MAAM,UAAU,UAAmB,OAAO,KAAK,KAAK,UAAU,KAAK,CAAC,CAAC,CAAC,SAAS,WAAW;CAC1F,MAAM,aAAa,KAAK,MAAM,KAAK,IAAI,IAAI,GAAI;CAC/C,OAAO;EACL,OAAO;GAAE,KAAK;GAAQ,KAAK;EAAM,CAAC;EAClC,OAAO;GAAE,KAAK;GAAW,KAAK,aAAa;GAAI,KAAK;GAAY,kBAAkB;EAAe,CAAC;EAClG;CACF,CAAC,CAAC,KAAK,GAAG;AACZ;AAEA,SAAS,gBAAgB,SAAiC;CACxD,MAAM,YAAY,IAAIA,4BAAAA,eAAe;EACnC,SAAS;EACT,WAAW;EACX,sBAAsB;EACtB,YAAY;EACZ,gBAAgB;EAChB,qBAAqB;CACvB,CAAC;CACD,QAAQ,IAAI,QAAQ,IAAI,WAAW,YAAY,GAAG,wBAAwB,OAAO;CACjF,MAAM,iBAAiB,UAAkB,GAAG,SAAoB,QAAQ,IAAI,WAAW,IAAI,CAAC,CAAC,MAAM,WAAW,IAAI;CAClH,OAAO;EACL,kBAAkB,QAAQ,IAAI,WAAW,mBAAmB;EAC5D,SAAS,iBAAyB,cAAc,4BAA4B,CAAC,CAAC;GAC5E,aAAa,wBAAwB,GAAG,aAAa,IAAI;GACzD;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IAAW,cAAc;IAAO,eAAe;GAAM;EACpE,CAAC;EAED,MAAM,aAAa,MAAM,OAAO,mBAAmB;EACnD,MAAM;EACN,MAAM,MAAM,OAAO,mBAAmB;EACtC,kBAAkB;EAClB,MAAM;EAEN,CAAA,GAAA,OAAA,OAAA,CAAO,YAAY,CAAC,CAAC,KAAK,CAAC;EAC3B,CAAA,GAAA,OAAA,OAAA,EAAQ,MAAM,MAAM,cAAc,EAAA,CAAG,IAAI,CAAC,CAAC,YAAY,CAAC,CAAC,KAAK,mBAAmB;CACnF,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.67";
17
- if ("js @hexclave/js@1.0.67".startsWith("STACK_COMPILE_TIME"));
16
+ const clientVersion = "js @hexclave/js@1.0.68";
17
+ if ("js @hexclave/js@1.0.68".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-C051fyaH.js";
1
+ import { n as _HexclaveServerAppImplIncomplete, r as _HexclaveClientAppImplIncomplete, t as _HexclaveAdminAppImplIncomplete } from "../../../../admin-app-impl-DxZSp6ov.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-C051fyaH.js";
1
+ import { n as _HexclaveServerAppImplIncomplete } from "../../../../admin-app-impl-DxZSp6ov.js";
2
2
  export { _HexclaveServerAppImplIncomplete };
@@ -419,14 +419,11 @@ var _HexclaveServerAppImplIncomplete = class extends __client_app_impl_js._Hexcl
419
419
  options?.or === "redirect"
420
420
  ], "write-only"));
421
421
  }
422
- const crudWithAdminRestriction = crud;
423
422
  return (0, ______users_index_js.withUserDestructureGuard)({
424
423
  ...super._createBaseUser(crud),
425
424
  lastActiveAt: new Date(crud.last_active_at_millis),
426
425
  serverMetadata: crud.server_metadata,
427
- restrictedByAdmin: crudWithAdminRestriction.restricted_by_admin,
428
- restrictedByAdminReason: crudWithAdminRestriction.restricted_by_admin_reason,
429
- restrictedByAdminPrivateDetails: crudWithAdminRestriction.restricted_by_admin_private_details,
426
+ restrictedByAdminPrivateDetails: crud.restricted_by_admin_private_details,
430
427
  countryCode: crud.country_code,
431
428
  riskScores: { signUp: {
432
429
  bot: crud.risk_scores.sign_up.bot,