@nerdfolio/ba-guest-list 0.1.0 → 0.1.2

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/dist/index.cjs CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/index.ts
@@ -36,14 +46,17 @@ var guestListClient = () => {
36
46
  // src/server.ts
37
47
  var import_api = require("better-auth/api");
38
48
  var import_cookies = require("better-auth/cookies");
39
- var import_v4_mini = require("zod/v4-mini");
49
+ var z = __toESM(require("zod/mini"), 1);
40
50
 
41
51
  // src/utils.ts
42
52
  var import_lodash_es = require("lodash-es");
43
- function getHostName(url) {
53
+ function parseEmailDomain(url) {
44
54
  try {
45
- const parsedUrl = new URL(url);
46
- return parsedUrl.hostname;
55
+ const { hostname } = new URL(url);
56
+ if (hostname === "localhost") {
57
+ return "localhost.example.com";
58
+ }
59
+ return hostname;
47
60
  } catch (_error) {
48
61
  return null;
49
62
  }
@@ -77,8 +90,8 @@ var guestList = (options) => {
77
90
  "/sign-in/guest-list",
78
91
  {
79
92
  method: "POST",
80
- body: import_v4_mini.z.object({
81
- name: import_v4_mini.z.string()
93
+ body: z.object({
94
+ name: z.string()
82
95
  }),
83
96
  metadata: {
84
97
  openapi: {
@@ -128,7 +141,7 @@ var guestList = (options) => {
128
141
  message: options?.revealNames ? `Name not on list. Try: ${JSON.stringify(Object.keys(guestLookup))}` : ERROR_CODES.NAME_NOT_ON_GUEST_LIST
129
142
  });
130
143
  }
131
- const { emailDomainName = getHostName(ctx.context.baseURL) } = options ?? {};
144
+ const { emailDomainName = parseEmailDomain(ctx.context.baseURL) } = options ?? {};
132
145
  const email = `${cleanedName.toLowerCase().replaceAll(/\s/g, "")}.onguestlist@${emailDomainName}`;
133
146
  const found = await ctx.context.internalAdapter.findUserByEmail(email);
134
147
  async function createNewUser() {
@@ -140,8 +153,7 @@ var guestList = (options) => {
140
153
  role: guestLookup[cleanedName].role,
141
154
  createdAt: /* @__PURE__ */ new Date(),
142
155
  updatedAt: /* @__PURE__ */ new Date()
143
- },
144
- ctx
156
+ }
145
157
  );
146
158
  if (!newUser) {
147
159
  throw ctx.error("INTERNAL_SERVER_ERROR", {
@@ -151,7 +163,7 @@ var guestList = (options) => {
151
163
  return newUser;
152
164
  }
153
165
  const user = found ? found.user : await createNewUser();
154
- const session = await ctx.context.internalAdapter.createSession(user.id, ctx, true);
166
+ const session = await ctx.context.internalAdapter.createSession(user.id, true);
155
167
  if (!session) {
156
168
  return ctx.json(null, {
157
169
  status: 400,
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as better_auth from 'better-auth';
2
- import { z } from 'zod/v4-mini';
2
+ import * as z from 'zod/mini';
3
3
 
4
4
  type GuestWithRole = {
5
5
  name: string;
@@ -26,132 +26,64 @@ interface GuestListOptions {
26
26
  declare const guestList: (options?: GuestListOptions) => {
27
27
  id: "guest-list";
28
28
  endpoints: {
29
- signInGuestList: {
30
- <AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(inputCtx_0: {
31
- body: {
32
- name: string;
33
- };
34
- } & {
35
- method?: "POST" | undefined;
36
- } & {
37
- query?: Record<string, any> | undefined;
38
- } & {
39
- params?: Record<string, any>;
40
- } & {
41
- request?: Request;
42
- } & {
43
- headers?: HeadersInit;
44
- } & {
45
- asResponse?: boolean;
46
- returnHeaders?: boolean;
47
- use?: better_auth.Middleware[];
48
- path?: string;
49
- } & {
50
- asResponse?: AsResponse | undefined;
51
- returnHeaders?: ReturnHeaders | undefined;
52
- }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? {
53
- headers: Headers;
54
- response: {
55
- token: string;
56
- user: {
57
- id: string;
58
- name: string;
59
- emailVerified: boolean;
60
- email: string;
61
- createdAt: Date;
62
- updatedAt: Date;
63
- image?: string | null | undefined;
64
- };
65
- } | null;
66
- } : {
67
- token: string;
68
- user: {
69
- id: string;
70
- name: string;
71
- emailVerified: boolean;
72
- email: string;
73
- createdAt: Date;
74
- updatedAt: Date;
75
- image?: string | null | undefined;
76
- };
77
- } | null>;
78
- options: {
79
- method: "POST";
80
- body: z.ZodMiniObject<{
81
- name: z.ZodMiniString<string>;
82
- }, z.core.$strip>;
83
- metadata: {
84
- openapi: {
85
- description: string;
86
- responses: {
87
- 200: {
88
- description: string;
89
- content: {
90
- "application/json": {
91
- schema: {
92
- type: "object";
93
- properties: {
94
- token: {
95
- type: string;
96
- description: string;
97
- };
98
- user: {
99
- $ref: string;
100
- };
29
+ signInGuestList: better_auth.StrictEndpoint<"/sign-in/guest-list", {
30
+ method: "POST";
31
+ body: z.ZodMiniObject<{
32
+ name: z.ZodMiniString<string>;
33
+ }, z.core.$strip>;
34
+ metadata: {
35
+ openapi: {
36
+ description: string;
37
+ responses: {
38
+ 200: {
39
+ description: string;
40
+ content: {
41
+ "application/json": {
42
+ schema: {
43
+ type: "object";
44
+ properties: {
45
+ token: {
46
+ type: string;
47
+ description: string;
48
+ };
49
+ user: {
50
+ $ref: string;
101
51
  };
102
- required: string[];
103
52
  };
53
+ required: string[];
104
54
  };
105
55
  };
106
56
  };
107
57
  };
108
58
  };
109
59
  };
110
- } & {
111
- use: any[];
112
60
  };
113
- path: "/sign-in/guest-list";
114
- };
115
- revealGuestList: {
116
- <AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(inputCtx_0?: ({
117
- body?: undefined;
118
- } & {
119
- method?: "GET" | undefined;
120
- } & {
121
- query?: Record<string, any> | undefined;
122
- } & {
123
- params?: Record<string, any>;
124
- } & {
125
- request?: Request;
126
- } & {
127
- headers?: HeadersInit;
128
- } & {
129
- asResponse?: boolean;
130
- returnHeaders?: boolean;
131
- use?: better_auth.Middleware[];
132
- path?: string;
133
- } & {
134
- asResponse?: AsResponse | undefined;
135
- returnHeaders?: ReturnHeaders | undefined;
136
- }) | undefined): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? {
137
- headers: Headers;
138
- response: string[];
139
- } : string[]>;
140
- options: {
141
- method: "GET";
142
- metadata: {
143
- openapi: {
144
- description: string;
145
- responses: {
146
- 200: {
147
- description: string;
148
- content: {
149
- "application/json": {
150
- schema: {
151
- type: "array";
152
- items: {
153
- type: string;
154
- };
61
+ }, {
62
+ token: string;
63
+ user: {
64
+ id: string;
65
+ createdAt: Date;
66
+ updatedAt: Date;
67
+ email: string;
68
+ emailVerified: boolean;
69
+ name: string;
70
+ image?: string | null | undefined;
71
+ };
72
+ } | null>;
73
+ revealGuestList: better_auth.StrictEndpoint<"/sign-in/guest-list/reveal", {
74
+ method: "GET";
75
+ metadata: {
76
+ openapi: {
77
+ description: string;
78
+ responses: {
79
+ 200: {
80
+ description: string;
81
+ content: {
82
+ "application/json": {
83
+ schema: {
84
+ type: "array";
85
+ items: {
86
+ type: string;
155
87
  };
156
88
  };
157
89
  };
@@ -159,11 +91,8 @@ declare const guestList: (options?: GuestListOptions) => {
159
91
  };
160
92
  };
161
93
  };
162
- } & {
163
- use: any[];
164
94
  };
165
- path: "/sign-in/guest-list/reveal";
166
- };
95
+ }, string[]>;
167
96
  };
168
97
  $ERROR_CODES: {
169
98
  readonly NAME_NOT_PROVIDED: "Guest name not provided";
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as better_auth from 'better-auth';
2
- import { z } from 'zod/v4-mini';
2
+ import * as z from 'zod/mini';
3
3
 
4
4
  type GuestWithRole = {
5
5
  name: string;
@@ -26,132 +26,64 @@ interface GuestListOptions {
26
26
  declare const guestList: (options?: GuestListOptions) => {
27
27
  id: "guest-list";
28
28
  endpoints: {
29
- signInGuestList: {
30
- <AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(inputCtx_0: {
31
- body: {
32
- name: string;
33
- };
34
- } & {
35
- method?: "POST" | undefined;
36
- } & {
37
- query?: Record<string, any> | undefined;
38
- } & {
39
- params?: Record<string, any>;
40
- } & {
41
- request?: Request;
42
- } & {
43
- headers?: HeadersInit;
44
- } & {
45
- asResponse?: boolean;
46
- returnHeaders?: boolean;
47
- use?: better_auth.Middleware[];
48
- path?: string;
49
- } & {
50
- asResponse?: AsResponse | undefined;
51
- returnHeaders?: ReturnHeaders | undefined;
52
- }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? {
53
- headers: Headers;
54
- response: {
55
- token: string;
56
- user: {
57
- id: string;
58
- name: string;
59
- emailVerified: boolean;
60
- email: string;
61
- createdAt: Date;
62
- updatedAt: Date;
63
- image?: string | null | undefined;
64
- };
65
- } | null;
66
- } : {
67
- token: string;
68
- user: {
69
- id: string;
70
- name: string;
71
- emailVerified: boolean;
72
- email: string;
73
- createdAt: Date;
74
- updatedAt: Date;
75
- image?: string | null | undefined;
76
- };
77
- } | null>;
78
- options: {
79
- method: "POST";
80
- body: z.ZodMiniObject<{
81
- name: z.ZodMiniString<string>;
82
- }, z.core.$strip>;
83
- metadata: {
84
- openapi: {
85
- description: string;
86
- responses: {
87
- 200: {
88
- description: string;
89
- content: {
90
- "application/json": {
91
- schema: {
92
- type: "object";
93
- properties: {
94
- token: {
95
- type: string;
96
- description: string;
97
- };
98
- user: {
99
- $ref: string;
100
- };
29
+ signInGuestList: better_auth.StrictEndpoint<"/sign-in/guest-list", {
30
+ method: "POST";
31
+ body: z.ZodMiniObject<{
32
+ name: z.ZodMiniString<string>;
33
+ }, z.core.$strip>;
34
+ metadata: {
35
+ openapi: {
36
+ description: string;
37
+ responses: {
38
+ 200: {
39
+ description: string;
40
+ content: {
41
+ "application/json": {
42
+ schema: {
43
+ type: "object";
44
+ properties: {
45
+ token: {
46
+ type: string;
47
+ description: string;
48
+ };
49
+ user: {
50
+ $ref: string;
101
51
  };
102
- required: string[];
103
52
  };
53
+ required: string[];
104
54
  };
105
55
  };
106
56
  };
107
57
  };
108
58
  };
109
59
  };
110
- } & {
111
- use: any[];
112
60
  };
113
- path: "/sign-in/guest-list";
114
- };
115
- revealGuestList: {
116
- <AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(inputCtx_0?: ({
117
- body?: undefined;
118
- } & {
119
- method?: "GET" | undefined;
120
- } & {
121
- query?: Record<string, any> | undefined;
122
- } & {
123
- params?: Record<string, any>;
124
- } & {
125
- request?: Request;
126
- } & {
127
- headers?: HeadersInit;
128
- } & {
129
- asResponse?: boolean;
130
- returnHeaders?: boolean;
131
- use?: better_auth.Middleware[];
132
- path?: string;
133
- } & {
134
- asResponse?: AsResponse | undefined;
135
- returnHeaders?: ReturnHeaders | undefined;
136
- }) | undefined): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? {
137
- headers: Headers;
138
- response: string[];
139
- } : string[]>;
140
- options: {
141
- method: "GET";
142
- metadata: {
143
- openapi: {
144
- description: string;
145
- responses: {
146
- 200: {
147
- description: string;
148
- content: {
149
- "application/json": {
150
- schema: {
151
- type: "array";
152
- items: {
153
- type: string;
154
- };
61
+ }, {
62
+ token: string;
63
+ user: {
64
+ id: string;
65
+ createdAt: Date;
66
+ updatedAt: Date;
67
+ email: string;
68
+ emailVerified: boolean;
69
+ name: string;
70
+ image?: string | null | undefined;
71
+ };
72
+ } | null>;
73
+ revealGuestList: better_auth.StrictEndpoint<"/sign-in/guest-list/reveal", {
74
+ method: "GET";
75
+ metadata: {
76
+ openapi: {
77
+ description: string;
78
+ responses: {
79
+ 200: {
80
+ description: string;
81
+ content: {
82
+ "application/json": {
83
+ schema: {
84
+ type: "array";
85
+ items: {
86
+ type: string;
155
87
  };
156
88
  };
157
89
  };
@@ -159,11 +91,8 @@ declare const guestList: (options?: GuestListOptions) => {
159
91
  };
160
92
  };
161
93
  };
162
- } & {
163
- use: any[];
164
94
  };
165
- path: "/sign-in/guest-list/reveal";
166
- };
95
+ }, string[]>;
167
96
  };
168
97
  $ERROR_CODES: {
169
98
  readonly NAME_NOT_PROVIDED: "Guest name not provided";
package/dist/index.mjs CHANGED
@@ -9,14 +9,17 @@ var guestListClient = () => {
9
9
  // src/server.ts
10
10
  import { APIError, createAuthEndpoint } from "better-auth/api";
11
11
  import { setSessionCookie } from "better-auth/cookies";
12
- import { z } from "zod/v4-mini";
12
+ import * as z from "zod/mini";
13
13
 
14
14
  // src/utils.ts
15
15
  import { capitalize } from "lodash-es";
16
- function getHostName(url) {
16
+ function parseEmailDomain(url) {
17
17
  try {
18
- const parsedUrl = new URL(url);
19
- return parsedUrl.hostname;
18
+ const { hostname } = new URL(url);
19
+ if (hostname === "localhost") {
20
+ return "localhost.example.com";
21
+ }
22
+ return hostname;
20
23
  } catch (_error) {
21
24
  return null;
22
25
  }
@@ -101,7 +104,7 @@ var guestList = (options) => {
101
104
  message: options?.revealNames ? `Name not on list. Try: ${JSON.stringify(Object.keys(guestLookup))}` : ERROR_CODES.NAME_NOT_ON_GUEST_LIST
102
105
  });
103
106
  }
104
- const { emailDomainName = getHostName(ctx.context.baseURL) } = options ?? {};
107
+ const { emailDomainName = parseEmailDomain(ctx.context.baseURL) } = options ?? {};
105
108
  const email = `${cleanedName.toLowerCase().replaceAll(/\s/g, "")}.onguestlist@${emailDomainName}`;
106
109
  const found = await ctx.context.internalAdapter.findUserByEmail(email);
107
110
  async function createNewUser() {
@@ -113,8 +116,7 @@ var guestList = (options) => {
113
116
  role: guestLookup[cleanedName].role,
114
117
  createdAt: /* @__PURE__ */ new Date(),
115
118
  updatedAt: /* @__PURE__ */ new Date()
116
- },
117
- ctx
119
+ }
118
120
  );
119
121
  if (!newUser) {
120
122
  throw ctx.error("INTERNAL_SERVER_ERROR", {
@@ -124,7 +126,7 @@ var guestList = (options) => {
124
126
  return newUser;
125
127
  }
126
128
  const user = found ? found.user : await createNewUser();
127
- const session = await ctx.context.internalAdapter.createSession(user.id, ctx, true);
129
+ const session = await ctx.context.internalAdapter.createSession(user.id, true);
128
130
  if (!session) {
129
131
  return ctx.json(null, {
130
132
  status: 400,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nerdfolio/ba-guest-list",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Similar to anonymous, but with a name that must be on a guest list. Useful for testing or demo with fixed logins",
5
5
  "repository": "https://github.com/nerdfolio/better-auth-goodies",
6
6
  "type": "module",
@@ -29,14 +29,14 @@
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/lodash-es": "^4.17.12",
32
- "better-auth": "1.2.12"
32
+ "better-auth": "^1.4.9"
33
33
  },
34
34
  "peerDependencies": {
35
- "better-auth": "1.2.12"
35
+ "better-auth": "^1.4.9"
36
36
  },
37
37
  "dependencies": {
38
- "lodash-es": "^4.17.21",
39
- "zod": "^3.25.67"
38
+ "lodash-es": "^4.17.22",
39
+ "zod": "^4.2.1"
40
40
  },
41
41
  "scripts": {
42
42
  "test": "echo \"Error: no test specified\" && exit 1",