@checodo/better-auth-waitlist 0.0.0-stage → 0.1.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.
- package/CHANGELOG.md +7 -0
- package/LICENSE.md +21 -0
- package/README.md +55 -2
- package/dist/client.d.ts +48 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +43 -0
- package/dist/client.js.map +1 -0
- package/dist/error-codes-DHbT2S8_.js +15 -0
- package/dist/error-codes-DHbT2S8_.js.map +1 -0
- package/dist/index-iWyjVJuS.d.ts +827 -0
- package/dist/index-iWyjVJuS.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +897 -0
- package/dist/index.js.map +1 -0
- package/package.json +72 -3
package/CHANGELOG.md
ADDED
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Clas Heinemeyer
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,56 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @checodo/better-auth-waitlist
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Gate sign-up behind a waitlist in [better-auth](https://better-auth.com): double opt-in, admin approval, invite codes, and a gate that covers every sign-up method.
|
|
4
|
+
|
|
5
|
+
A community plugin, not made by the better-auth team. It looks and works
|
|
6
|
+
like better-auth's own plugins: a server plugin, a typed client plugin,
|
|
7
|
+
error codes, and database tables.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @checodo/better-auth-waitlist
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Requires `better-auth` and `@better-auth/core` 1.7.20 or a later 1.x
|
|
16
|
+
release (peer dependencies). ESM only.
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
// auth.ts
|
|
22
|
+
import { betterAuth } from "better-auth";
|
|
23
|
+
import { waitlist } from "@checodo/better-auth-waitlist";
|
|
24
|
+
|
|
25
|
+
export const auth = betterAuth({
|
|
26
|
+
plugins: [
|
|
27
|
+
waitlist({
|
|
28
|
+
sendConfirmationEmail: async ({ email, token }) => {
|
|
29
|
+
// email a link to your confirm page with the token
|
|
30
|
+
},
|
|
31
|
+
sendInvite: async ({ email, inviteCode }) => {
|
|
32
|
+
// email the invite code once an admin approves the entry
|
|
33
|
+
},
|
|
34
|
+
}),
|
|
35
|
+
],
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
// auth-client.ts
|
|
41
|
+
import { createAuthClient } from "better-auth/client";
|
|
42
|
+
import { waitlistClient } from "@checodo/better-auth-waitlist/client";
|
|
43
|
+
|
|
44
|
+
export const authClient = createAuthClient({ plugins: [waitlistClient()] });
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Create the plugin's tables with the better-auth CLI:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npx auth@latest migrate
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Documentation
|
|
54
|
+
|
|
55
|
+
Every option, endpoint, error code, and table:
|
|
56
|
+
[docs](https://github.com/checodo/better-auth-plugins/blob/main/apps/docs/content/docs/waitlist.mdx).
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { r as WAITLIST_ERROR_CODES, t as WaitlistPlugin } from "./index-iWyjVJuS.js";
|
|
2
|
+
/**
|
|
3
|
+
* Client companion to `waitlist()`. Adds `authClient.waitlist.join`,
|
|
4
|
+
* `confirm`, `getStatus`, `leave`, `checkInvite`, and the admin endpoints
|
|
5
|
+
* (`listEntries`, `getStats`, `approveEntries`, `rejectEntry`,
|
|
6
|
+
* `deleteEntry`, `createInvite`), typed from the server plugin.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { createAuthClient } from "better-auth/client";
|
|
11
|
+
* import { waitlistClient } from "@checodo/better-auth-waitlist/client";
|
|
12
|
+
*
|
|
13
|
+
* export const authClient = createAuthClient({
|
|
14
|
+
* plugins: [waitlistClient()],
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* await authClient.waitlist.join({ email: "ada@example.com" });
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare const waitlistClient: () => {
|
|
21
|
+
id: "waitlist";
|
|
22
|
+
$InferServerPlugin: WaitlistPlugin;
|
|
23
|
+
pathMethods: {
|
|
24
|
+
"/waitlist/join": "POST";
|
|
25
|
+
"/waitlist/confirm": "POST";
|
|
26
|
+
"/waitlist/get-status": "GET";
|
|
27
|
+
"/waitlist/leave": "POST";
|
|
28
|
+
"/waitlist/check-invite": "GET";
|
|
29
|
+
"/waitlist/list-entries": "GET";
|
|
30
|
+
"/waitlist/get-stats": "GET";
|
|
31
|
+
"/waitlist/approve-entries": "POST";
|
|
32
|
+
"/waitlist/reject-entry": "POST";
|
|
33
|
+
"/waitlist/delete-entry": "POST";
|
|
34
|
+
"/waitlist/create-invite": "POST";
|
|
35
|
+
};
|
|
36
|
+
$ERROR_CODES: {
|
|
37
|
+
EMAIL_NOT_APPROVED: import("better-auth").RawError<"EMAIL_NOT_APPROVED">;
|
|
38
|
+
INVITE_CODE_REQUIRED: import("better-auth").RawError<"INVITE_CODE_REQUIRED">;
|
|
39
|
+
INVALID_INVITE_CODE: import("better-auth").RawError<"INVALID_INVITE_CODE">;
|
|
40
|
+
INVALID_TOKEN: import("better-auth").RawError<"INVALID_TOKEN">;
|
|
41
|
+
WAITLIST_FULL: import("better-auth").RawError<"WAITLIST_FULL">;
|
|
42
|
+
ENTRY_NOT_FOUND: import("better-auth").RawError<"ENTRY_NOT_FOUND">;
|
|
43
|
+
METADATA_TOO_LARGE: import("better-auth").RawError<"METADATA_TOO_LARGE">;
|
|
44
|
+
YOU_ARE_NOT_ALLOWED_TO_MANAGE_WAITLIST: import("better-auth").RawError<"YOU_ARE_NOT_ALLOWED_TO_MANAGE_WAITLIST">;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export { WAITLIST_ERROR_CODES };
|
|
48
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","names":[],"sources":["../src/client.ts"],"mappings":";;;;;;;;;;;;;;;;;;;qBAsBa;;EAGiB,oBAAA"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { t as WAITLIST_ERROR_CODES } from "./error-codes-DHbT2S8_.js";
|
|
2
|
+
// src/client.ts
|
|
3
|
+
/**
|
|
4
|
+
* Client companion to `waitlist()`. Adds `authClient.waitlist.join`,
|
|
5
|
+
* `confirm`, `getStatus`, `leave`, `checkInvite`, and the admin endpoints
|
|
6
|
+
* (`listEntries`, `getStats`, `approveEntries`, `rejectEntry`,
|
|
7
|
+
* `deleteEntry`, `createInvite`), typed from the server plugin.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { createAuthClient } from "better-auth/client";
|
|
12
|
+
* import { waitlistClient } from "@checodo/better-auth-waitlist/client";
|
|
13
|
+
*
|
|
14
|
+
* export const authClient = createAuthClient({
|
|
15
|
+
* plugins: [waitlistClient()],
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* await authClient.waitlist.join({ email: "ada@example.com" });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
const waitlistClient = () => {
|
|
22
|
+
return {
|
|
23
|
+
id: "waitlist",
|
|
24
|
+
$InferServerPlugin: {},
|
|
25
|
+
pathMethods: {
|
|
26
|
+
"/waitlist/join": "POST",
|
|
27
|
+
"/waitlist/confirm": "POST",
|
|
28
|
+
"/waitlist/get-status": "GET",
|
|
29
|
+
"/waitlist/leave": "POST",
|
|
30
|
+
"/waitlist/check-invite": "GET",
|
|
31
|
+
"/waitlist/list-entries": "GET",
|
|
32
|
+
"/waitlist/get-stats": "GET",
|
|
33
|
+
"/waitlist/approve-entries": "POST",
|
|
34
|
+
"/waitlist/reject-entry": "POST",
|
|
35
|
+
"/waitlist/delete-entry": "POST",
|
|
36
|
+
"/waitlist/create-invite": "POST"
|
|
37
|
+
},
|
|
38
|
+
$ERROR_CODES: WAITLIST_ERROR_CODES
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export { WAITLIST_ERROR_CODES, waitlistClient };
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","names":[],"sources":["../src/client.ts"],"sourcesContent":["import type { BetterAuthClientPlugin } from \"better-auth/client\";\nimport { WAITLIST_ERROR_CODES } from \"./error-codes\";\nimport type { WaitlistPlugin } from \"./index\";\n\n/**\n * Client companion to `waitlist()`. Adds `authClient.waitlist.join`,\n * `confirm`, `getStatus`, `leave`, `checkInvite`, and the admin endpoints\n * (`listEntries`, `getStats`, `approveEntries`, `rejectEntry`,\n * `deleteEntry`, `createInvite`), typed from the server plugin.\n *\n * @example\n * ```ts\n * import { createAuthClient } from \"better-auth/client\";\n * import { waitlistClient } from \"@checodo/better-auth-waitlist/client\";\n *\n * export const authClient = createAuthClient({\n * plugins: [waitlistClient()],\n * });\n *\n * await authClient.waitlist.join({ email: \"ada@example.com\" });\n * ```\n */\nexport const waitlistClient = () => {\n return {\n id: \"waitlist\",\n $InferServerPlugin: {} as WaitlistPlugin,\n pathMethods: {\n \"/waitlist/join\": \"POST\",\n \"/waitlist/confirm\": \"POST\",\n \"/waitlist/get-status\": \"GET\",\n \"/waitlist/leave\": \"POST\",\n \"/waitlist/check-invite\": \"GET\",\n \"/waitlist/list-entries\": \"GET\",\n \"/waitlist/get-stats\": \"GET\",\n \"/waitlist/approve-entries\": \"POST\",\n \"/waitlist/reject-entry\": \"POST\",\n \"/waitlist/delete-entry\": \"POST\",\n \"/waitlist/create-invite\": \"POST\",\n },\n $ERROR_CODES: WAITLIST_ERROR_CODES,\n } satisfies BetterAuthClientPlugin;\n};\n\nexport { WAITLIST_ERROR_CODES } from \"./error-codes\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,uBAAuB;CAClC,OAAO;EACL,IAAI;EACJ,oBAAoB,CAAC;EACrB,aAAa;GACX,kBAAkB;GAClB,qBAAqB;GACrB,wBAAwB;GACxB,mBAAmB;GACnB,0BAA0B;GAC1B,0BAA0B;GAC1B,uBAAuB;GACvB,6BAA6B;GAC7B,0BAA0B;GAC1B,0BAA0B;GAC1B,2BAA2B;EAC7B;EACA,cAAc;CAChB;AACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { defineErrorCodes } from "@better-auth/core/utils/error-codes";
|
|
2
|
+
// src/error-codes.ts
|
|
3
|
+
const WAITLIST_ERROR_CODES = defineErrorCodes({
|
|
4
|
+
EMAIL_NOT_APPROVED: "This email has not been approved to sign up yet",
|
|
5
|
+
INVITE_CODE_REQUIRED: "An invite code is required to sign up",
|
|
6
|
+
INVALID_INVITE_CODE: "This invite code is invalid or has expired",
|
|
7
|
+
INVALID_TOKEN: "This link is invalid or has expired",
|
|
8
|
+
WAITLIST_FULL: "The waitlist is full",
|
|
9
|
+
ENTRY_NOT_FOUND: "No waitlist entry was found with this id",
|
|
10
|
+
METADATA_TOO_LARGE: "The metadata is too large",
|
|
11
|
+
YOU_ARE_NOT_ALLOWED_TO_MANAGE_WAITLIST: "You are not allowed to manage the waitlist"
|
|
12
|
+
});
|
|
13
|
+
export { WAITLIST_ERROR_CODES as t };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=error-codes-DHbT2S8_.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-codes-DHbT2S8_.js","names":[],"sources":["../src/error-codes.ts"],"sourcesContent":["import { defineErrorCodes } from \"@better-auth/core/utils/error-codes\";\n\nexport const WAITLIST_ERROR_CODES = defineErrorCodes({\n EMAIL_NOT_APPROVED: \"This email has not been approved to sign up yet\",\n INVITE_CODE_REQUIRED: \"An invite code is required to sign up\",\n INVALID_INVITE_CODE: \"This invite code is invalid or has expired\",\n INVALID_TOKEN: \"This link is invalid or has expired\",\n WAITLIST_FULL: \"The waitlist is full\",\n ENTRY_NOT_FOUND: \"No waitlist entry was found with this id\",\n METADATA_TOO_LARGE: \"The metadata is too large\",\n YOU_ARE_NOT_ALLOWED_TO_MANAGE_WAITLIST: \"You are not allowed to manage the waitlist\",\n});\n\nexport type WaitlistErrorCode = keyof typeof WAITLIST_ERROR_CODES;\n"],"mappings":";;AAEA,MAAa,uBAAuB,iBAAiB;CACnD,oBAAoB;CACpB,sBAAsB;CACtB,qBAAqB;CACrB,eAAe;CACf,eAAe;CACf,iBAAiB;CACjB,oBAAoB;CACpB,wCAAwC;AAC1C,CAAC"}
|