@quickback-dev/cli 0.40.2 → 0.47.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 (107) hide show
  1. package/dist/commands/claude.d.ts.map +1 -1
  2. package/dist/commands/claude.js +8 -0
  3. package/dist/commands/claude.js.map +1 -1
  4. package/dist/commands/compile.d.ts.map +1 -1
  5. package/dist/commands/compile.js +13 -2
  6. package/dist/commands/compile.js.map +1 -1
  7. package/dist/commands/compile.test.js +26 -21
  8. package/dist/commands/compile.test.js.map +1 -1
  9. package/dist/commands/create.js +6 -9
  10. package/dist/commands/create.js.map +1 -1
  11. package/dist/commands/login.d.ts.map +1 -1
  12. package/dist/commands/login.js +0 -9
  13. package/dist/commands/login.js.map +1 -1
  14. package/dist/commands/start.d.ts.map +1 -1
  15. package/dist/commands/start.js +6 -7
  16. package/dist/commands/start.js.map +1 -1
  17. package/dist/commands/whoami.d.ts.map +1 -1
  18. package/dist/commands/whoami.js +0 -4
  19. package/dist/commands/whoami.js.map +1 -1
  20. package/dist/docs/content.d.ts.map +1 -1
  21. package/dist/docs/content.js +22 -32
  22. package/dist/docs/content.js.map +1 -1
  23. package/dist/index.js +1 -1
  24. package/dist/lib/api-client.d.ts +0 -12
  25. package/dist/lib/api-client.d.ts.map +1 -1
  26. package/dist/lib/api-client.js +0 -10
  27. package/dist/lib/api-client.js.map +1 -1
  28. package/dist/lib/api-client.test.js +13 -8
  29. package/dist/lib/api-client.test.js.map +1 -1
  30. package/dist/lib/auth.d.ts +0 -1
  31. package/dist/lib/auth.d.ts.map +1 -1
  32. package/dist/lib/auth.js.map +1 -1
  33. package/dist/lib/compiler-stubs.d.ts +12 -0
  34. package/dist/lib/compiler-stubs.d.ts.map +1 -1
  35. package/dist/lib/compiler-stubs.js +18 -0
  36. package/dist/lib/compiler-stubs.js.map +1 -1
  37. package/dist/lib/file-loader.d.ts +14 -0
  38. package/dist/lib/file-loader.d.ts.map +1 -1
  39. package/dist/lib/file-loader.js +63 -9
  40. package/dist/lib/file-loader.js.map +1 -1
  41. package/dist/skill/SKILL.md +76 -6
  42. package/dist/skill/docs/changelog.md +278 -0
  43. package/dist/skill/docs/compiler/cloud-compiler/authentication.md +1 -2
  44. package/dist/skill/docs/compiler/cloud-compiler/cli.md +7 -8
  45. package/dist/skill/docs/compiler/config/agents.md +49 -1
  46. package/dist/skill/docs/compiler/config/auth.md +20 -5
  47. package/dist/skill/docs/compiler/config/security.md +46 -0
  48. package/dist/skill/docs/compiler/definitions/access.md +1 -1
  49. package/dist/skill/docs/compiler/definitions/actions.md +46 -4
  50. package/dist/skill/docs/compiler/definitions/diagnostics.md +88 -57
  51. package/dist/skill/docs/compiler/definitions/scopes.md +11 -3
  52. package/dist/skill/docs/compiler/getting-started/full-example.md +5 -3
  53. package/dist/skill/docs/compiler/getting-started/index.md +7 -7
  54. package/dist/skill/docs/compiler/getting-started/patterns.md +39 -5
  55. package/dist/skill/docs/compiler/getting-started/template-blog.md +65 -44
  56. package/dist/skill/docs/compiler/getting-started/template-cloudflare.md +4 -5
  57. package/dist/skill/docs/compiler/getting-started/template-empty.md +7 -1
  58. package/dist/skill/docs/compiler/getting-started/templates.md +6 -6
  59. package/dist/skill/docs/compiler/targets/hono-api/using-the-api/openapi.md +23 -0
  60. package/dist/skill/docs/stack/account-ui/features/passwordless.md +4 -10
  61. package/dist/skill/docs/stack/account-ui/hooks.md +24 -1
  62. package/dist/skill/docs/stack/auth/plugins/aws-ses.md +0 -7
  63. package/dist/skill/docs/stack/auth/plugins/index.md +36 -39
  64. package/dist/templates/registry.d.ts +0 -12
  65. package/dist/templates/registry.d.ts.map +1 -1
  66. package/dist/templates/registry.js +0 -42
  67. package/dist/templates/registry.js.map +1 -1
  68. package/package.json +1 -1
  69. package/src/skill/SKILL.md +76 -6
  70. package/src/skill/docs/changelog.md +278 -0
  71. package/src/skill/docs/compiler/cloud-compiler/authentication.md +1 -2
  72. package/src/skill/docs/compiler/cloud-compiler/cli.md +7 -8
  73. package/src/skill/docs/compiler/config/agents.md +49 -1
  74. package/src/skill/docs/compiler/config/auth.md +20 -5
  75. package/src/skill/docs/compiler/config/security.md +46 -0
  76. package/src/skill/docs/compiler/definitions/access.md +1 -1
  77. package/src/skill/docs/compiler/definitions/actions.md +46 -4
  78. package/src/skill/docs/compiler/definitions/diagnostics.md +88 -57
  79. package/src/skill/docs/compiler/definitions/scopes.md +11 -3
  80. package/src/skill/docs/compiler/getting-started/full-example.md +5 -3
  81. package/src/skill/docs/compiler/getting-started/index.md +7 -7
  82. package/src/skill/docs/compiler/getting-started/patterns.md +39 -5
  83. package/src/skill/docs/compiler/getting-started/template-blog.md +65 -44
  84. package/src/skill/docs/compiler/getting-started/template-cloudflare.md +4 -5
  85. package/src/skill/docs/compiler/getting-started/template-empty.md +7 -1
  86. package/src/skill/docs/compiler/getting-started/templates.md +6 -6
  87. package/src/skill/docs/compiler/targets/hono-api/using-the-api/openapi.md +23 -0
  88. package/src/skill/docs/stack/account-ui/features/passwordless.md +4 -10
  89. package/src/skill/docs/stack/account-ui/hooks.md +24 -1
  90. package/src/skill/docs/stack/auth/plugins/aws-ses.md +0 -7
  91. package/src/skill/docs/stack/auth/plugins/index.md +36 -39
  92. package/dist/commands/init.d.ts +0 -6
  93. package/dist/commands/init.d.ts.map +0 -1
  94. package/dist/commands/init.js +0 -405
  95. package/dist/commands/init.js.map +0 -1
  96. package/dist/lib/sweep-stale.d.ts +0 -25
  97. package/dist/lib/sweep-stale.d.ts.map +0 -1
  98. package/dist/lib/sweep-stale.js +0 -179
  99. package/dist/lib/sweep-stale.js.map +0 -1
  100. package/dist/lib/sweep-stale.test.d.ts +0 -2
  101. package/dist/lib/sweep-stale.test.d.ts.map +0 -1
  102. package/dist/lib/sweep-stale.test.js +0 -130
  103. package/dist/lib/sweep-stale.test.js.map +0 -1
  104. package/dist/skill/docs/stack/auth/plugins/combo-auth.md +0 -74
  105. package/dist/skill/docs/stack/auth/plugins/upgrade-anonymous.md +0 -155
  106. package/src/skill/docs/stack/auth/plugins/combo-auth.md +0 -74
  107. package/src/skill/docs/stack/auth/plugins/upgrade-anonymous.md +0 -155
@@ -1,130 +0,0 @@
1
- import { describe, expect, test, beforeEach, afterEach } from 'bun:test';
2
- import { promises as fs } from 'fs';
3
- import { join, sep } from 'path';
4
- import { tmpdir } from 'os';
5
- import { sweepStaleGeneratedFiles } from './sweep-stale.js';
6
- const HEADER = '/**\n * Generated by quickback.dev\n */\n';
7
- const PLAIN = '// hand-authored content\n';
8
- let tmp;
9
- beforeEach(async () => {
10
- tmp = await fs.mkdtemp(join(tmpdir(), 'sweep-stale-'));
11
- });
12
- afterEach(async () => {
13
- await fs.rm(tmp, { recursive: true, force: true }).catch(() => { });
14
- });
15
- async function writeFile(rel, content) {
16
- const full = join(tmp, ...rel.split('/'));
17
- await fs.mkdir(join(full, '..'), { recursive: true });
18
- await fs.writeFile(full, content);
19
- }
20
- async function fileExists(rel) {
21
- try {
22
- await fs.access(join(tmp, ...rel.split('/')));
23
- return true;
24
- }
25
- catch {
26
- return false;
27
- }
28
- }
29
- describe('sweepStaleGeneratedFiles', () => {
30
- // User story: As a developer who renames a feature, I want stale generator
31
- // output from the old name to disappear so my project tree reflects only
32
- // what the current config produces — no ghost routes/types lingering.
33
- test('deletes generated files not in the manifest', async () => {
34
- await writeFile('src/features/old/schema.ts', HEADER);
35
- await writeFile('src/features/new/schema.ts', HEADER);
36
- const result = await sweepStaleGeneratedFiles(tmp, 'src', ['src/features/new/schema.ts']);
37
- expect(result.deleted.sort()).toEqual(['src/features/old/schema.ts']);
38
- expect(await fileExists('src/features/old/schema.ts')).toBe(false);
39
- expect(await fileExists('src/features/new/schema.ts')).toBe(true);
40
- });
41
- // User story: As a developer who pasted a personal note into src/, I want
42
- // the sweep to leave my hand-authored file alone — the header check is the
43
- // line between "compiler owns this" and "the user owns this".
44
- test('preserves files without the generated-header marker', async () => {
45
- await writeFile('src/features/new/notes.md', PLAIN);
46
- await writeFile('src/features/new/schema.ts', HEADER);
47
- const result = await sweepStaleGeneratedFiles(tmp, 'src', ['src/features/new/schema.ts']);
48
- expect(result.deleted).toEqual([]);
49
- expect(result.preserved).toEqual(['src/features/new/notes.md']);
50
- expect(await fileExists('src/features/new/notes.md')).toBe(true);
51
- });
52
- // User story: As a developer running quickback compile back-to-back with no
53
- // changes, I want the sweep to be a fast no-op — no spurious archive dirs
54
- // littering the repo every time I recompile.
55
- test('does not archive when nothing is stale', async () => {
56
- await writeFile('src/features/new/schema.ts', HEADER);
57
- const archiveDir = join(tmp, 'quickback', '.archives');
58
- const result = await sweepStaleGeneratedFiles(tmp, 'src', ['src/features/new/schema.ts'], {
59
- archiveDir,
60
- });
61
- expect(result.deleted).toEqual([]);
62
- expect(result.archivePath).toBeUndefined();
63
- expect(await fileExists('quickback/.archives')).toBe(false);
64
- });
65
- // User story: As a developer about to lose 30 generator-emitted files in a
66
- // sweep, I want a snapshot of src/ saved automatically so I can recover if
67
- // the compiler stopped emitting something I was depending on.
68
- test('archives src/ before deleting when orphans are present', async () => {
69
- await writeFile('src/features/old/schema.ts', HEADER);
70
- await writeFile('src/features/new/schema.ts', HEADER);
71
- const archiveDir = join(tmp, 'quickback', '.archives');
72
- const result = await sweepStaleGeneratedFiles(tmp, 'src', ['src/features/new/schema.ts'], {
73
- archiveDir,
74
- });
75
- expect(result.deleted).toEqual(['src/features/old/schema.ts']);
76
- expect(result.archivePath).toBeDefined();
77
- // Archive should contain a copy of the pre-sweep tree.
78
- const archived = await fs.readdir(result.archivePath, { recursive: true });
79
- const flat = archived.map((p) => (sep === '/' ? p : p.split(sep).join('/')));
80
- expect(flat).toContain('features/old/schema.ts');
81
- expect(flat).toContain('features/new/schema.ts');
82
- });
83
- // User story: As a developer who refactors aggressively over a week, I want
84
- // older snapshots pruned automatically so the .archives folder doesn't
85
- // balloon — last 3 generations is enough to walk back from a regret.
86
- test('prunes old archives, keeping most recent N', async () => {
87
- const archiveDir = join(tmp, 'archives');
88
- await fs.mkdir(archiveDir, { recursive: true });
89
- // Pre-seed 5 fake archives with sortable names.
90
- for (const stamp of ['src-0001', 'src-0002', 'src-0003', 'src-0004']) {
91
- await fs.mkdir(join(archiveDir, stamp));
92
- }
93
- await writeFile('src/features/old/schema.ts', HEADER);
94
- await writeFile('src/features/new/schema.ts', HEADER);
95
- await sweepStaleGeneratedFiles(tmp, 'src', ['src/features/new/schema.ts'], {
96
- archiveDir,
97
- archiveKeep: 3,
98
- });
99
- const remaining = (await fs.readdir(archiveDir)).filter((d) => d.startsWith('src-'));
100
- expect(remaining.length).toBe(3);
101
- // Newest survives — pruning is alphabetical-descending.
102
- expect(remaining).toContain('src-0004');
103
- expect(remaining).not.toContain('src-0001');
104
- });
105
- // User story: As a developer with SPA bundles in src/apps/cms/assets/, I want
106
- // the sweep to leave that subtree alone — the upstream code wipes it
107
- // wholesale before each write, so the per-file header probe would be
108
- // wasted work.
109
- test('respects skipPrefixes (SPA asset dirs)', async () => {
110
- await writeFile('src/apps/cms/assets/main-abc123.js', HEADER);
111
- await writeFile('src/apps/cms/assets/main-def456.js', HEADER);
112
- const result = await sweepStaleGeneratedFiles(tmp, 'src', ['src/apps/cms/assets/main-def456.js'], {
113
- skipPrefixes: ['src/apps/cms/assets'],
114
- });
115
- expect(result.deleted).toEqual([]);
116
- expect(await fileExists('src/apps/cms/assets/main-abc123.js')).toBe(true);
117
- });
118
- // User story: As a developer with a now-empty src/features/old/ after a
119
- // sweep, I don't want the bare directory hanging around — the file tree
120
- // should match the manifest, including its shape.
121
- test('removes empty directories left after deletion', async () => {
122
- await writeFile('src/features/old/schema.ts', HEADER);
123
- await writeFile('src/features/old/routes.ts', HEADER);
124
- await writeFile('src/features/new/schema.ts', HEADER);
125
- await sweepStaleGeneratedFiles(tmp, 'src', ['src/features/new/schema.ts']);
126
- expect(await fileExists('src/features/old')).toBe(false);
127
- expect(await fileExists('src/features/new')).toBe(true);
128
- });
129
- });
130
- //# sourceMappingURL=sweep-stale.test.js.map
@@ -1 +0,0 @@
1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AAI,CAAC,IAAI,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;IAEH,wEAAwE;IACxE,wEAAwE;IACxE,kDAAkD;IAClD,IAAI,CAAC,+CAA+C,EAAE,KAAK,IAAI,EAAE;QAC/D,MAAM,SAAS,CAAC,4BAA4B,EAAE,MAAM,CAAC,CAAC;QACtD,MAAM,SAAS,CAAC,4BAA4B,EAAE,MAAM,CAAC,CAAC;QACtD,MAAM,SAAS,CAAC,4BAA4B,EAAE,MAAM,CAAC,CAAC;QACtD,MAAM,wBAAwB,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,4BAA4B,CAAC,CAAC,CAAC;QAC3E,MAAM,CAAC,MAAM,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzD,MAAM,CAAC,MAAM,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,74 +0,0 @@
1
- # Combo Auth Plugin
2
-
3
- `@quickback-dev/better-auth-combo-auth` provides a combined authentication flow that sends both a magic link and an OTP code in a single email. Users can click the link (one-click) or enter the 6-digit OTP code — whichever is more convenient.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install @quickback-dev/better-auth-combo-auth
9
- ```
10
-
11
- ## Server Setup
12
-
13
- Add the plugin to your Better Auth configuration:
14
-
15
- ```typescript
16
- import { betterAuth } from "better-auth";
17
- import { comboAuth } from "@quickback-dev/better-auth-combo-auth";
18
-
19
- export const auth = betterAuth({
20
- plugins: [
21
- comboAuth({
22
- sendComboAuth: async ({ email, otp, url }) => {
23
- // Send email with both the magic link (url) and OTP code (otp)
24
- await sendEmail({
25
- to: email,
26
- subject: "Sign in to My App",
27
- html: `
28
- <p>Click the link below to sign in:</p>
29
- <a href="${url}">Sign in to My App</a>
30
- <p>Or enter this code: <strong>${otp}</strong></p>
31
- `,
32
- });
33
- },
34
- }),
35
- ],
36
- });
37
- ```
38
-
39
- ## Client Usage
40
-
41
- ```typescript
42
- import { createAuthClient } from "better-auth/client";
43
- import { comboAuthClient } from "@quickback-dev/better-auth-combo-auth/client";
44
-
45
- const authClient = createAuthClient({
46
- plugins: [comboAuthClient()],
47
- });
48
-
49
- // Request authentication — sends email with link + OTP
50
- await authClient.signIn.comboAuth({
51
- email: "user@example.com",
52
- });
53
-
54
- // Verify with OTP code (if user enters it manually)
55
- await authClient.signIn.comboAuth({
56
- email: "user@example.com",
57
- otp: "123456",
58
- });
59
- ```
60
-
61
- ## How It Works
62
-
63
- 1. User enters their email and requests sign-in
64
- 2. A single email is sent containing both a magic link and a 6-digit OTP
65
- 3. **Option A:** User clicks the magic link — authenticated immediately
66
- 4. **Option B:** User enters the OTP code — authenticated after verification
67
-
68
- This provides the best of both worlds: convenience of magic links with the reliability of OTP codes (useful when magic links don't work well, e.g., opening email on a different device).
69
-
70
- ## See Also
71
-
72
- - [Auth Plugins](/stack/auth/plugins) — All authentication plugin options
73
- - [Upgrade Anonymous](/stack/auth/plugins/upgrade-anonymous) — Convert anonymous sessions to full accounts
74
- - [AWS SES](/stack/auth/plugins/aws-ses) — Email delivery for auth flows
@@ -1,155 +0,0 @@
1
- # Upgrade Anonymous Plugin
2
-
3
- `@quickback-dev/better-auth-upgrade-anonymous` provides a single endpoint to convert anonymous users into full authenticated users. It flips the `isAnonymous` flag, optionally updates email and name, and refreshes the session — no re-authentication required.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install @quickback-dev/better-auth-upgrade-anonymous
9
- ```
10
-
11
- ## Configuration
12
-
13
- Enable both the `anonymous` and `upgradeAnonymous` plugins:
14
-
15
- ```typescript
16
- auth: defineAuth("better-auth", {
17
- plugins: ["anonymous", "upgradeAnonymous"],
18
- })
19
- ```
20
-
21
- The plugin accepts optional configuration:
22
-
23
- ```typescript
24
- import { upgradeAnonymous } from "@quickback-dev/better-auth-upgrade-anonymous";
25
-
26
- upgradeAnonymous({
27
- emailConfigured: true, // Whether email delivery is available
28
- requireEmailVerification: true, // Whether to require email verification
29
- })
30
- ```
31
-
32
- | Option | Default | Description |
33
- |--------|---------|-------------|
34
- | `emailConfigured` | `false` | When `true` and an email is provided, `emailVerified` is set based on `requireEmailVerification` |
35
- | `requireEmailVerification` | `true` | When `true`, provided emails are marked unverified (requiring OTP). When `false`, emails are marked verified immediately |
36
-
37
- > **Quickback Compiler**
38
- >
39
- > When using the Quickback compiler, these options are set automatically based on your SES environment variables. You don't need to configure them manually.
40
-
41
-
42
- ## Endpoint
43
-
44
- ```
45
- POST /auth/v1/upgrade-anonymous
46
- ```
47
-
48
- ### Flow
49
-
50
- 1. Validates the user's session (returns `401` if not authenticated)
51
- 2. Checks if the user is already upgraded (returns success immediately if so)
52
- 3. If an email is provided, checks for duplicates (returns `400` if email is taken)
53
- 4. Updates `isAnonymous` to `false`, plus optional `email`, `name`, and `emailVerified` fields
54
- 5. Refreshes the session cookie with the updated user object
55
- 6. Returns the updated user, session, and `verificationRequired` flag
56
-
57
- ### Request
58
-
59
- The body is optional. When provided, it accepts:
60
-
61
- | Field | Type | Description |
62
- |-------|------|-------------|
63
- | `email` | `string` (email) | Optional. Real email to replace the anonymous placeholder |
64
- | `name` | `string` | Optional. User's display name |
65
-
66
- ```bash
67
- # Minimal — just upgrade, no email/name
68
- curl -X POST https://api.example.com/auth/v1/upgrade-anonymous \
69
- -H "Cookie: better-auth.session_token=..."
70
-
71
- # With email and name
72
- curl -X POST https://api.example.com/auth/v1/upgrade-anonymous \
73
- -H "Cookie: better-auth.session_token=..." \
74
- -H "Content-Type: application/json" \
75
- -d '{"email": "jane@example.com", "name": "Jane"}'
76
- ```
77
-
78
- ### Response
79
-
80
- ```json
81
- {
82
- "success": true,
83
- "verificationRequired": true,
84
- "user": {
85
- "id": "usr_abc123",
86
- "email": "jane@example.com",
87
- "isAnonymous": false
88
- },
89
- "session": {
90
- "id": "sess_xyz",
91
- "userId": "usr_abc123"
92
- }
93
- }
94
- ```
95
-
96
- The `verificationRequired` field is `true` when all three conditions are met:
97
- - An email was provided in the request body
98
- - `emailConfigured` is `true` in plugin config
99
- - `requireEmailVerification` is `true` in plugin config
100
-
101
- When `verificationRequired` is `true`, the frontend should send a verification OTP and redirect the user to verify their email.
102
-
103
- ## How It Works
104
-
105
- The plugin is designed to be flexible:
106
-
107
- - **Minimal by default** — With no body, only changes `isAnonymous` from `true` to `false`
108
- - **Optional email/name** — Can update email and name in the same request
109
- - **Duplicate protection** — Rejects emails already associated with another account
110
- - **Verification-aware** — Returns `verificationRequired` so the frontend knows whether to trigger OTP
111
- - **Session preserved** — Same session ID, no re-authentication needed
112
- - **Idempotent** — Calling on an already-upgraded user returns success immediately
113
-
114
- ## Typical Flows
115
-
116
- ### Passkey Signup (no email)
117
-
118
- 1. User creates anonymous session
119
- 2. User registers a passkey
120
- 3. App calls `POST /auth/v1/upgrade-anonymous` with no body
121
- 4. User is now a full user with passkey auth — no email on file
122
-
123
- ### Passkey Signup (with email)
124
-
125
- 1. User creates anonymous session
126
- 2. User registers a passkey
127
- 3. User optionally enters email/name on the email collection step
128
- 4. App calls `POST /auth/v1/upgrade-anonymous` with `{ email, name }`
129
- 5. If `verificationRequired`: app sends OTP, user verifies, then redirects to dashboard
130
- 6. Otherwise: user goes straight to dashboard
131
-
132
- ### Email Signup
133
-
134
- 1. User starts as anonymous (created via Better Auth's `anonymous` plugin)
135
- 2. User provides email/password through your UI (via combo auth or signup)
136
- 3. Your app calls `POST /auth/v1/upgrade-anonymous`
137
- 4. User is now a full user with the same ID and all their data intact
138
-
139
- ### Client Plugin
140
-
141
- ```typescript
142
- import { upgradeAnonymousClient } from "@quickback-dev/better-auth-upgrade-anonymous/client";
143
-
144
- const authClient = createAuthClient({
145
- plugins: [upgradeAnonymousClient()],
146
- });
147
-
148
- // Upgrade the current anonymous user
149
- await authClient.upgradeAnonymous();
150
- ```
151
-
152
- ## See Also
153
-
154
- - [Combo Auth Plugin](/stack/auth/plugins/combo-auth) — Combined magic link + OTP for collecting credentials
155
- - [Auth Configuration](/compiler/config/providers) — Configuring auth plugins
@@ -1,74 +0,0 @@
1
- # Combo Auth Plugin
2
-
3
- `@quickback-dev/better-auth-combo-auth` provides a combined authentication flow that sends both a magic link and an OTP code in a single email. Users can click the link (one-click) or enter the 6-digit OTP code — whichever is more convenient.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install @quickback-dev/better-auth-combo-auth
9
- ```
10
-
11
- ## Server Setup
12
-
13
- Add the plugin to your Better Auth configuration:
14
-
15
- ```typescript
16
- import { betterAuth } from "better-auth";
17
- import { comboAuth } from "@quickback-dev/better-auth-combo-auth";
18
-
19
- export const auth = betterAuth({
20
- plugins: [
21
- comboAuth({
22
- sendComboAuth: async ({ email, otp, url }) => {
23
- // Send email with both the magic link (url) and OTP code (otp)
24
- await sendEmail({
25
- to: email,
26
- subject: "Sign in to My App",
27
- html: `
28
- <p>Click the link below to sign in:</p>
29
- <a href="${url}">Sign in to My App</a>
30
- <p>Or enter this code: <strong>${otp}</strong></p>
31
- `,
32
- });
33
- },
34
- }),
35
- ],
36
- });
37
- ```
38
-
39
- ## Client Usage
40
-
41
- ```typescript
42
- import { createAuthClient } from "better-auth/client";
43
- import { comboAuthClient } from "@quickback-dev/better-auth-combo-auth/client";
44
-
45
- const authClient = createAuthClient({
46
- plugins: [comboAuthClient()],
47
- });
48
-
49
- // Request authentication — sends email with link + OTP
50
- await authClient.signIn.comboAuth({
51
- email: "user@example.com",
52
- });
53
-
54
- // Verify with OTP code (if user enters it manually)
55
- await authClient.signIn.comboAuth({
56
- email: "user@example.com",
57
- otp: "123456",
58
- });
59
- ```
60
-
61
- ## How It Works
62
-
63
- 1. User enters their email and requests sign-in
64
- 2. A single email is sent containing both a magic link and a 6-digit OTP
65
- 3. **Option A:** User clicks the magic link — authenticated immediately
66
- 4. **Option B:** User enters the OTP code — authenticated after verification
67
-
68
- This provides the best of both worlds: convenience of magic links with the reliability of OTP codes (useful when magic links don't work well, e.g., opening email on a different device).
69
-
70
- ## See Also
71
-
72
- - [Auth Plugins](/stack/auth/plugins) — All authentication plugin options
73
- - [Upgrade Anonymous](/stack/auth/plugins/upgrade-anonymous) — Convert anonymous sessions to full accounts
74
- - [AWS SES](/stack/auth/plugins/aws-ses) — Email delivery for auth flows
@@ -1,155 +0,0 @@
1
- # Upgrade Anonymous Plugin
2
-
3
- `@quickback-dev/better-auth-upgrade-anonymous` provides a single endpoint to convert anonymous users into full authenticated users. It flips the `isAnonymous` flag, optionally updates email and name, and refreshes the session — no re-authentication required.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install @quickback-dev/better-auth-upgrade-anonymous
9
- ```
10
-
11
- ## Configuration
12
-
13
- Enable both the `anonymous` and `upgradeAnonymous` plugins:
14
-
15
- ```typescript
16
- auth: defineAuth("better-auth", {
17
- plugins: ["anonymous", "upgradeAnonymous"],
18
- })
19
- ```
20
-
21
- The plugin accepts optional configuration:
22
-
23
- ```typescript
24
- import { upgradeAnonymous } from "@quickback-dev/better-auth-upgrade-anonymous";
25
-
26
- upgradeAnonymous({
27
- emailConfigured: true, // Whether email delivery is available
28
- requireEmailVerification: true, // Whether to require email verification
29
- })
30
- ```
31
-
32
- | Option | Default | Description |
33
- |--------|---------|-------------|
34
- | `emailConfigured` | `false` | When `true` and an email is provided, `emailVerified` is set based on `requireEmailVerification` |
35
- | `requireEmailVerification` | `true` | When `true`, provided emails are marked unverified (requiring OTP). When `false`, emails are marked verified immediately |
36
-
37
- > **Quickback Compiler**
38
- >
39
- > When using the Quickback compiler, these options are set automatically based on your SES environment variables. You don't need to configure them manually.
40
-
41
-
42
- ## Endpoint
43
-
44
- ```
45
- POST /auth/v1/upgrade-anonymous
46
- ```
47
-
48
- ### Flow
49
-
50
- 1. Validates the user's session (returns `401` if not authenticated)
51
- 2. Checks if the user is already upgraded (returns success immediately if so)
52
- 3. If an email is provided, checks for duplicates (returns `400` if email is taken)
53
- 4. Updates `isAnonymous` to `false`, plus optional `email`, `name`, and `emailVerified` fields
54
- 5. Refreshes the session cookie with the updated user object
55
- 6. Returns the updated user, session, and `verificationRequired` flag
56
-
57
- ### Request
58
-
59
- The body is optional. When provided, it accepts:
60
-
61
- | Field | Type | Description |
62
- |-------|------|-------------|
63
- | `email` | `string` (email) | Optional. Real email to replace the anonymous placeholder |
64
- | `name` | `string` | Optional. User's display name |
65
-
66
- ```bash
67
- # Minimal — just upgrade, no email/name
68
- curl -X POST https://api.example.com/auth/v1/upgrade-anonymous \
69
- -H "Cookie: better-auth.session_token=..."
70
-
71
- # With email and name
72
- curl -X POST https://api.example.com/auth/v1/upgrade-anonymous \
73
- -H "Cookie: better-auth.session_token=..." \
74
- -H "Content-Type: application/json" \
75
- -d '{"email": "jane@example.com", "name": "Jane"}'
76
- ```
77
-
78
- ### Response
79
-
80
- ```json
81
- {
82
- "success": true,
83
- "verificationRequired": true,
84
- "user": {
85
- "id": "usr_abc123",
86
- "email": "jane@example.com",
87
- "isAnonymous": false
88
- },
89
- "session": {
90
- "id": "sess_xyz",
91
- "userId": "usr_abc123"
92
- }
93
- }
94
- ```
95
-
96
- The `verificationRequired` field is `true` when all three conditions are met:
97
- - An email was provided in the request body
98
- - `emailConfigured` is `true` in plugin config
99
- - `requireEmailVerification` is `true` in plugin config
100
-
101
- When `verificationRequired` is `true`, the frontend should send a verification OTP and redirect the user to verify their email.
102
-
103
- ## How It Works
104
-
105
- The plugin is designed to be flexible:
106
-
107
- - **Minimal by default** — With no body, only changes `isAnonymous` from `true` to `false`
108
- - **Optional email/name** — Can update email and name in the same request
109
- - **Duplicate protection** — Rejects emails already associated with another account
110
- - **Verification-aware** — Returns `verificationRequired` so the frontend knows whether to trigger OTP
111
- - **Session preserved** — Same session ID, no re-authentication needed
112
- - **Idempotent** — Calling on an already-upgraded user returns success immediately
113
-
114
- ## Typical Flows
115
-
116
- ### Passkey Signup (no email)
117
-
118
- 1. User creates anonymous session
119
- 2. User registers a passkey
120
- 3. App calls `POST /auth/v1/upgrade-anonymous` with no body
121
- 4. User is now a full user with passkey auth — no email on file
122
-
123
- ### Passkey Signup (with email)
124
-
125
- 1. User creates anonymous session
126
- 2. User registers a passkey
127
- 3. User optionally enters email/name on the email collection step
128
- 4. App calls `POST /auth/v1/upgrade-anonymous` with `{ email, name }`
129
- 5. If `verificationRequired`: app sends OTP, user verifies, then redirects to dashboard
130
- 6. Otherwise: user goes straight to dashboard
131
-
132
- ### Email Signup
133
-
134
- 1. User starts as anonymous (created via Better Auth's `anonymous` plugin)
135
- 2. User provides email/password through your UI (via combo auth or signup)
136
- 3. Your app calls `POST /auth/v1/upgrade-anonymous`
137
- 4. User is now a full user with the same ID and all their data intact
138
-
139
- ### Client Plugin
140
-
141
- ```typescript
142
- import { upgradeAnonymousClient } from "@quickback-dev/better-auth-upgrade-anonymous/client";
143
-
144
- const authClient = createAuthClient({
145
- plugins: [upgradeAnonymousClient()],
146
- });
147
-
148
- // Upgrade the current anonymous user
149
- await authClient.upgradeAnonymous();
150
- ```
151
-
152
- ## See Also
153
-
154
- - [Combo Auth Plugin](/stack/auth/plugins/combo-auth) — Combined magic link + OTP for collecting credentials
155
- - [Auth Configuration](/compiler/config/providers) — Configuring auth plugins