@jgb-solutions/kit 0.2.2 → 0.3.0

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 (40) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +129 -3
  3. package/dist/admin/blocks/ActivityFeed.d.ts +20 -0
  4. package/dist/admin/blocks/BarChart.d.ts +26 -0
  5. package/dist/admin/blocks/ChartPoints.d.ts +24 -0
  6. package/dist/admin/blocks/DataTable.d.ts +58 -0
  7. package/dist/admin/blocks/Filters.d.ts +12 -0
  8. package/dist/admin/blocks/Hero.d.ts +22 -0
  9. package/dist/admin/blocks/LineChart.d.ts +24 -0
  10. package/dist/admin/blocks/Pagination.d.ts +30 -0
  11. package/dist/admin/blocks/Segmented.d.ts +15 -0
  12. package/dist/admin/blocks/Stat.d.ts +35 -0
  13. package/dist/admin/blocks/Status.d.ts +22 -0
  14. package/dist/admin/blocks/Tile.d.ts +20 -0
  15. package/dist/admin/blocks/sorting.d.ts +29 -0
  16. package/dist/admin/contrast.d.ts +12 -0
  17. package/dist/admin/forms/ConfirmDialog.d.ts +25 -0
  18. package/dist/admin/forms/Field.d.ts +48 -0
  19. package/dist/admin/forms/People.d.ts +28 -0
  20. package/dist/admin/forms/Toast.d.ts +17 -0
  21. package/dist/admin/icons.d.ts +31 -0
  22. package/dist/admin/index.d.ts +33 -0
  23. package/dist/admin/shell/AdminShell.d.ts +31 -0
  24. package/dist/admin/shell/Dock.d.ts +8 -0
  25. package/dist/admin/shell/PageHeader.d.ts +19 -0
  26. package/dist/admin/shell/Sidebar.d.ts +27 -0
  27. package/dist/admin/shell/ThemeToggle.d.ts +10 -0
  28. package/dist/admin/shell/nav.d.ts +33 -0
  29. package/dist/admin/styles.css +1677 -0
  30. package/dist/admin/theme.d.ts +30 -0
  31. package/dist/admin/ui/Avatar.d.ts +14 -0
  32. package/dist/admin/ui/Button.d.ts +19 -0
  33. package/dist/admin.d.ts +2 -0
  34. package/dist/admin.js +2168 -0
  35. package/dist/auth/expo.d.ts +6 -0
  36. package/dist/auth/expo.js +7 -8
  37. package/dist/auth/rules.d.ts +6 -2
  38. package/dist/auth/rules.js +2 -2
  39. package/dist/auth.js +2 -2
  40. package/package.json +36 -7
@@ -33,6 +33,12 @@ export type MobileAuthConfig<U> = {
33
33
  fetchMe: () => Promise<U>;
34
34
  /** Runs after each sign-in (`firstTime`) and each launch with a saved session: syncing what the phone holds. */
35
35
  onSignedIn?: (firstTime: boolean) => Promise<void>;
36
+ /**
37
+ * A random UUID, for the placeholder address of an account made without an email. Defaults to the
38
+ * runtime's `crypto.randomUUID`, which React Native's Hermes doesn't have: pass expo-crypto's
39
+ * `randomUUID` there. Without either, signUp without an email answers `NO_RANDOM_ID`.
40
+ */
41
+ randomId?: () => string;
36
42
  /** For tests. */
37
43
  fetch?: typeof fetch;
38
44
  };
package/dist/auth/expo.js CHANGED
@@ -14,8 +14,8 @@ var PLACEHOLDER_EMAIL_DOMAIN = "users.invalid";
14
14
  function isPlaceholderEmail(email) {
15
15
  return email.toLowerCase().endsWith(`@${PLACEHOLDER_EMAIL_DOMAIN}`);
16
16
  }
17
- function placeholderEmail() {
18
- return `${crypto.randomUUID().replaceAll("-", "")}@${PLACEHOLDER_EMAIL_DOMAIN}`;
17
+ function placeholderEmail(randomId = () => globalThis.crypto.randomUUID()) {
18
+ return `${randomId().replaceAll("-", "")}@${PLACEHOLDER_EMAIL_DOMAIN}`;
19
19
  }
20
20
  function usernameFromName(name, email, fallback) {
21
21
  const clean = (text) => (typeof text.normalize === "function" ? text.normalize("NFKD") : text).replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[\s-]+/g, ".").replace(/[^a-z0-9_.]/g, "").replace(/\.{2,}/g, ".").replace(/^[._]+|[._]+$/g, "").slice(0, USERNAME.max - 5).replace(/[._]+$/g, "");
@@ -172,12 +172,11 @@ function createMobileAuth(config) {
172
172
  },
173
173
  signUp(input) {
174
174
  const username = input.username.trim().toLowerCase();
175
- return signInWith("/sign-up/email", {
176
- name: input.name?.trim() || username,
177
- username,
178
- email: input.email?.trim() || placeholderEmail(),
179
- password: input.password
180
- });
175
+ const randomId = config.randomId ?? (typeof globalThis.crypto?.randomUUID === "function" ? () => globalThis.crypto.randomUUID() : null);
176
+ const email = input.email?.trim() || (randomId ? placeholderEmail(randomId) : null);
177
+ if (!email)
178
+ return Promise.resolve({ ok: false, code: "NO_RANDOM_ID" });
179
+ return signInWith("/sign-up/email", { name: input.name?.trim() || username, username, email, password: input.password });
181
180
  },
182
181
  signInWithGoogle(idToken, options = {}) {
183
182
  return signInWith("/sign-in/social", {
@@ -24,8 +24,12 @@ export declare function usernameProblem(username: string): 'too-short' | 'too-lo
24
24
  */
25
25
  export declare const PLACEHOLDER_EMAIL_DOMAIN = "users.invalid";
26
26
  export declare function isPlaceholderEmail(email: string): boolean;
27
- /** A new placeholder address, random enough never to collide. */
28
- export declare function placeholderEmail(): string;
27
+ /**
28
+ * A new placeholder address, random enough never to collide. `randomId` defaults to the runtime's
29
+ * `crypto.randomUUID`; React Native's Hermes has no global `crypto`, so an app there passes its own
30
+ * (expo-crypto's `randomUUID`).
31
+ */
32
+ export declare function placeholderEmail(randomId?: () => string): string;
29
33
  /**
30
34
  * A username made from a person's name, for accounts made with Google: "Marie-Ève Dupont" →
31
35
  * "marie.eve.dupont". Accents dropped, spaces and dashes to dots, anything else out, short enough to
@@ -14,8 +14,8 @@ var PLACEHOLDER_EMAIL_DOMAIN = "users.invalid";
14
14
  function isPlaceholderEmail(email) {
15
15
  return email.toLowerCase().endsWith(`@${PLACEHOLDER_EMAIL_DOMAIN}`);
16
16
  }
17
- function placeholderEmail() {
18
- return `${crypto.randomUUID().replaceAll("-", "")}@${PLACEHOLDER_EMAIL_DOMAIN}`;
17
+ function placeholderEmail(randomId = () => globalThis.crypto.randomUUID()) {
18
+ return `${randomId().replaceAll("-", "")}@${PLACEHOLDER_EMAIL_DOMAIN}`;
19
19
  }
20
20
  function usernameFromName(name, email, fallback) {
21
21
  const clean = (text) => (typeof text.normalize === "function" ? text.normalize("NFKD") : text).replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[\s-]+/g, ".").replace(/[^a-z0-9_.]/g, "").replace(/\.{2,}/g, ".").replace(/^[._]+|[._]+$/g, "").slice(0, USERNAME.max - 5).replace(/[._]+$/g, "");
package/dist/auth.js CHANGED
@@ -21,8 +21,8 @@ var PLACEHOLDER_EMAIL_DOMAIN = "users.invalid";
21
21
  function isPlaceholderEmail(email) {
22
22
  return email.toLowerCase().endsWith(`@${PLACEHOLDER_EMAIL_DOMAIN}`);
23
23
  }
24
- function placeholderEmail() {
25
- return `${crypto.randomUUID().replaceAll("-", "")}@${PLACEHOLDER_EMAIL_DOMAIN}`;
24
+ function placeholderEmail(randomId = () => globalThis.crypto.randomUUID()) {
25
+ return `${randomId().replaceAll("-", "")}@${PLACEHOLDER_EMAIL_DOMAIN}`;
26
26
  }
27
27
  function usernameFromName(name, email, fallback) {
28
28
  const clean = (text) => (typeof text.normalize === "function" ? text.normalize("NFKD") : text).replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[\s-]+/g, ".").replace(/[^a-z0-9_.]/g, "").replace(/\.{2,}/g, ".").replace(/^[._]+|[._]+$/g, "").slice(0, USERNAME.max - 5).replace(/[._]+$/g, "");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jgb-solutions/kit",
3
- "version": "0.2.2",
4
- "description": "Generic plumbing for web apps on Bun and Cloudflare Workers: small, typed, tree-shakable modules (Cloudflare Access, Better Auth).",
3
+ "version": "0.3.0",
4
+ "description": "One package for JGB Solutions apps, in tree-shakable namespaces: Cloudflare Access, Better Auth (kit/access, kit/auth\u2026) and the admin panel kit (kit/admin, React 19). An app bundles only the subpaths it imports.",
5
5
  "license": "MIT",
6
6
  "author": "JGB Solutions",
7
7
  "repository": {
@@ -19,10 +19,17 @@
19
19
  "better-auth",
20
20
  "passkeys",
21
21
  "orpc",
22
- "expo"
22
+ "expo",
23
+ "admin",
24
+ "dashboard",
25
+ "react",
26
+ "design-system",
27
+ "accessible"
23
28
  ],
24
29
  "type": "module",
25
- "sideEffects": false,
30
+ "sideEffects": [
31
+ "**/*.css"
32
+ ],
26
33
  "files": [
27
34
  "dist",
28
35
  "README.md",
@@ -54,6 +61,11 @@
54
61
  "types": "./dist/auth/expo.d.ts",
55
62
  "import": "./dist/auth/expo.js"
56
63
  },
64
+ "./admin": {
65
+ "types": "./dist/admin.d.ts",
66
+ "import": "./dist/admin.js"
67
+ },
68
+ "./admin/styles.css": "./dist/admin/styles.css",
57
69
  "./package.json": "./package.json"
58
70
  },
59
71
  "engines": {
@@ -67,12 +79,15 @@
67
79
  "scripts": {
68
80
  "build": "bun scripts/build.ts",
69
81
  "typecheck": "bun check",
70
- "test": "bun test",
82
+ "test": "bun test src",
71
83
  "format": "bun fmt .",
72
84
  "format:check": "bun fmt --check .",
73
85
  "check:package": "bun scripts/check-package.ts",
74
86
  "prepublishOnly": "bun run build && bun run check:package",
75
- "check:install": "bun scripts/check-install.ts"
87
+ "check:install": "bun scripts/check-install.ts",
88
+ "test:e2e": "bun --bun playwright test",
89
+ "playground": "bun playground/serve.ts",
90
+ "screenshots": "bun --bun playwright test e2e/screenshots.spec.ts"
76
91
  },
77
92
  "dependencies": {
78
93
  "jose": "6.2.18"
@@ -80,7 +95,9 @@
80
95
  "peerDependencies": {
81
96
  "better-auth": ">=1.7.22 <2",
82
97
  "@better-auth/passkey": ">=1.7.22 <2",
83
- "@orpc/server": ">=2.0.0-beta.52 <3"
98
+ "@orpc/server": ">=2.0.0-beta.52 <3",
99
+ "react": ">=19 <20",
100
+ "react-dom": ">=19 <20"
84
101
  },
85
102
  "peerDependenciesMeta": {
86
103
  "better-auth": {
@@ -91,13 +108,25 @@
91
108
  },
92
109
  "@orpc/server": {
93
110
  "optional": true
111
+ },
112
+ "react": {
113
+ "optional": true
114
+ },
115
+ "react-dom": {
116
+ "optional": true
94
117
  }
95
118
  },
96
119
  "devDependencies": {
120
+ "@axe-core/playwright": "4.14.0",
97
121
  "@better-auth/passkey": "1.7.27",
98
122
  "@orpc/server": "2.0.0-beta.52",
123
+ "@playwright/test": "1.64.1",
99
124
  "@types/bun": "1.4.5",
125
+ "@types/react": "19.3.0",
126
+ "@types/react-dom": "19.3.0",
100
127
  "better-auth": "1.7.27",
128
+ "react": "19.3.1",
129
+ "react-dom": "19.3.1",
101
130
  "typescript": "6.0.3"
102
131
  }
103
132
  }