@contentgrowth/content-auth 0.0.4 → 0.2.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.
@@ -1027,6 +1027,23 @@ declare const invitations: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
1027
1027
  }, {}, {
1028
1028
  length: number | undefined;
1029
1029
  }>;
1030
+ createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
1031
+ name: "createdAt";
1032
+ tableName: "invitations";
1033
+ dataType: "date";
1034
+ columnType: "SQLiteTimestamp";
1035
+ data: Date;
1036
+ driverParam: number;
1037
+ notNull: true;
1038
+ hasDefault: false;
1039
+ isPrimaryKey: false;
1040
+ isAutoincrement: false;
1041
+ hasRuntimeDefault: false;
1042
+ enumValues: undefined;
1043
+ baseColumn: never;
1044
+ identity: undefined;
1045
+ generated: undefined;
1046
+ }, {}, {}>;
1030
1047
  };
1031
1048
  dialect: "sqlite";
1032
1049
  }>;
@@ -4,7 +4,7 @@ import {
4
4
  createAuth,
5
5
  createAuthApp,
6
6
  schema_exports
7
- } from "../chunk-OOXZHG4Y.js";
7
+ } from "../chunk-C2QC5WEH.js";
8
8
  import "../chunk-R5U7XKVJ.js";
9
9
  export {
10
10
  Hono,
@@ -86,7 +86,8 @@ var invitations = sqliteTable("invitations", {
86
86
  role: text("role"),
87
87
  status: text("status").notNull(),
88
88
  expiresAt: integer("expiresAt", { mode: "timestamp" }).notNull(),
89
- inviterId: text("inviterId").notNull().references(() => users.id, { onDelete: "cascade" })
89
+ inviterId: text("inviterId").notNull().references(() => users.id, { onDelete: "cascade" }),
90
+ createdAt: integer("createdAt", { mode: "timestamp" }).notNull()
90
91
  });
91
92
 
92
93
  // src/backend/native-hashing.ts
@@ -115,8 +116,21 @@ async function hashPassword(password) {
115
116
  const hashB64 = btoa(String.fromCharCode(...new Uint8Array(hashBuffer)));
116
117
  return `pbkdf2:100000:${saltB64}:${hashB64}`;
117
118
  }
118
- async function verifyPassword(password, storedHash) {
119
- const parts = storedHash.split(":");
119
+ async function verifyPassword(passwordOrData, storedHash) {
120
+ let password;
121
+ let hash;
122
+ if (typeof passwordOrData === "object" && passwordOrData !== null) {
123
+ password = passwordOrData.password;
124
+ hash = passwordOrData.hash;
125
+ } else {
126
+ password = passwordOrData;
127
+ hash = storedHash;
128
+ }
129
+ if (!hash) {
130
+ console.error("[Auth] verifyPassword called with empty/undefined hash");
131
+ return false;
132
+ }
133
+ const parts = hash.split(":");
120
134
  if (parts.length !== 4) return false;
121
135
  const [alg, iterationsStr, saltB64, hashB64] = parts;
122
136
  if (alg !== "pbkdf2") return false;
@@ -628,7 +628,7 @@ declare const createClient: (baseUrl?: string) => {
628
628
  sortDirection?: "asc" | "desc" | undefined;
629
629
  filterField?: string | undefined;
630
630
  filterValue?: string | number | boolean | undefined;
631
- filterOperator?: "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "contains" | undefined;
631
+ filterOperator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "contains" | undefined;
632
632
  organizationId?: string | undefined;
633
633
  organizationSlug?: string | undefined;
634
634
  }> & Record<string, any>, Record<string, any> | undefined>>(data_0?: better_auth.Prettify<{
@@ -639,7 +639,7 @@ declare const createClient: (baseUrl?: string) => {
639
639
  sortDirection?: "asc" | "desc" | undefined;
640
640
  filterField?: string | undefined;
641
641
  filterValue?: string | number | boolean | undefined;
642
- filterOperator?: "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "contains" | undefined;
642
+ filterOperator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "contains" | undefined;
643
643
  organizationId?: string | undefined;
644
644
  organizationSlug?: string | undefined;
645
645
  } | undefined;
@@ -746,7 +746,7 @@ declare const createClient: (baseUrl?: string) => {
746
746
  } & {
747
747
  signIn: {
748
748
  social: <FetchOptions extends better_auth.ClientFetchOption<Partial<{
749
- provider: (string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "vercel";
749
+ provider: (string & {}) | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linear" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "vercel";
750
750
  callbackURL?: string | undefined;
751
751
  newUserCallbackURL?: string | undefined;
752
752
  errorCallbackURL?: string | undefined;
@@ -763,7 +763,7 @@ declare const createClient: (baseUrl?: string) => {
763
763
  loginHint?: string | undefined;
764
764
  additionalData?: Record<string, any> | undefined;
765
765
  }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: better_auth.Prettify<{
766
- provider: (string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "vercel";
766
+ provider: (string & {}) | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linear" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "vercel";
767
767
  callbackURL?: string | undefined;
768
768
  newUserCallbackURL?: string | undefined;
769
769
  errorCallbackURL?: string | undefined;
@@ -2205,7 +2205,7 @@ declare const authClient: {
2205
2205
  sortDirection?: "asc" | "desc" | undefined;
2206
2206
  filterField?: string | undefined;
2207
2207
  filterValue?: string | number | boolean | undefined;
2208
- filterOperator?: "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "contains" | undefined;
2208
+ filterOperator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "contains" | undefined;
2209
2209
  organizationId?: string | undefined;
2210
2210
  organizationSlug?: string | undefined;
2211
2211
  }> & Record<string, any>, Record<string, any> | undefined>>(data_0?: better_auth.Prettify<{
@@ -2216,7 +2216,7 @@ declare const authClient: {
2216
2216
  sortDirection?: "asc" | "desc" | undefined;
2217
2217
  filterField?: string | undefined;
2218
2218
  filterValue?: string | number | boolean | undefined;
2219
- filterOperator?: "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "contains" | undefined;
2219
+ filterOperator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "contains" | undefined;
2220
2220
  organizationId?: string | undefined;
2221
2221
  organizationSlug?: string | undefined;
2222
2222
  } | undefined;
@@ -2323,7 +2323,7 @@ declare const authClient: {
2323
2323
  } & {
2324
2324
  signIn: {
2325
2325
  social: <FetchOptions extends better_auth.ClientFetchOption<Partial<{
2326
- provider: (string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "vercel";
2326
+ provider: (string & {}) | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linear" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "vercel";
2327
2327
  callbackURL?: string | undefined;
2328
2328
  newUserCallbackURL?: string | undefined;
2329
2329
  errorCallbackURL?: string | undefined;
@@ -2340,7 +2340,7 @@ declare const authClient: {
2340
2340
  loginHint?: string | undefined;
2341
2341
  additionalData?: Record<string, any> | undefined;
2342
2342
  }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: better_auth.Prettify<{
2343
- provider: (string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "vercel";
2343
+ provider: (string & {}) | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linear" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "vercel";
2344
2344
  callbackURL?: string | undefined;
2345
2345
  newUserCallbackURL?: string | undefined;
2346
2346
  errorCallbackURL?: string | undefined;
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  createAuth,
5
5
  createAuthApp,
6
6
  schema_exports
7
- } from "./chunk-OOXZHG4Y.js";
7
+ } from "./chunk-C2QC5WEH.js";
8
8
  import {
9
9
  AuthForm,
10
10
  CreateOrganizationForm,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentgrowth/content-auth",
3
- "version": "0.0.4",
3
+ "version": "0.2.0",
4
4
  "description": "Better Auth wrapper with UI components for Cloudflare Workers & Pages",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/schema/auth.sql CHANGED
@@ -19,7 +19,7 @@
19
19
  -- ==========================================
20
20
 
21
21
  -- Users
22
- CREATE TABLE IF NOT EXISTS user (
22
+ CREATE TABLE IF NOT EXISTS users (
23
23
  id TEXT PRIMARY KEY,
24
24
  name TEXT NOT NULL,
25
25
  email TEXT NOT NULL UNIQUE,
@@ -30,7 +30,7 @@ CREATE TABLE IF NOT EXISTS user (
30
30
  );
31
31
 
32
32
  -- Sessions
33
- CREATE TABLE IF NOT EXISTS session (
33
+ CREATE TABLE IF NOT EXISTS sessions (
34
34
  id TEXT PRIMARY KEY,
35
35
  expiresAt TIMESTAMP NOT NULL,
36
36
  token TEXT NOT NULL UNIQUE,
@@ -38,15 +38,16 @@ CREATE TABLE IF NOT EXISTS session (
38
38
  updatedAt TIMESTAMP NOT NULL,
39
39
  ipAddress TEXT,
40
40
  userAgent TEXT,
41
- userId TEXT NOT NULL REFERENCES user(id) ON DELETE CASCADE
41
+ userId TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
42
+ activeOrganizationId TEXT
42
43
  );
43
44
 
44
45
  -- OAuth/Credential Accounts
45
- CREATE TABLE IF NOT EXISTS account (
46
+ CREATE TABLE IF NOT EXISTS accounts (
46
47
  id TEXT PRIMARY KEY,
47
48
  accountId TEXT NOT NULL,
48
49
  providerId TEXT NOT NULL,
49
- userId TEXT NOT NULL REFERENCES user(id) ON DELETE CASCADE,
50
+ userId TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
50
51
  accessToken TEXT,
51
52
  refreshToken TEXT,
52
53
  idToken TEXT,
@@ -59,7 +60,7 @@ CREATE TABLE IF NOT EXISTS account (
59
60
  );
60
61
 
61
62
  -- Email/Token Verification
62
- CREATE TABLE IF NOT EXISTS verification (
63
+ CREATE TABLE IF NOT EXISTS verifications (
63
64
  id TEXT PRIMARY KEY,
64
65
  identifier TEXT NOT NULL,
65
66
  value TEXT NOT NULL,
@@ -73,7 +74,7 @@ CREATE TABLE IF NOT EXISTS verification (
73
74
  -- ==========================================
74
75
 
75
76
  -- Organizations
76
- CREATE TABLE IF NOT EXISTS organization (
77
+ CREATE TABLE IF NOT EXISTS organizations (
77
78
  id TEXT PRIMARY KEY,
78
79
  name TEXT NOT NULL,
79
80
  slug TEXT UNIQUE,
@@ -83,23 +84,24 @@ CREATE TABLE IF NOT EXISTS organization (
83
84
  );
84
85
 
85
86
  -- Organization Members
86
- CREATE TABLE IF NOT EXISTS member (
87
+ CREATE TABLE IF NOT EXISTS members (
87
88
  id TEXT PRIMARY KEY,
88
- organizationId TEXT NOT NULL REFERENCES organization(id) ON DELETE CASCADE,
89
- userId TEXT NOT NULL REFERENCES user(id) ON DELETE CASCADE,
89
+ organizationId TEXT NOT NULL REFERENCES organizations(id) ON DELETE CASCADE,
90
+ userId TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
90
91
  role TEXT NOT NULL, -- 'owner', 'admin', 'member'
91
92
  createdAt TIMESTAMP NOT NULL
92
93
  );
93
94
 
94
95
  -- Organization Invitations
95
- CREATE TABLE IF NOT EXISTS invitation (
96
+ CREATE TABLE IF NOT EXISTS invitations (
96
97
  id TEXT PRIMARY KEY,
97
- organizationId TEXT NOT NULL REFERENCES organization(id) ON DELETE CASCADE,
98
+ organizationId TEXT NOT NULL REFERENCES organizations(id) ON DELETE CASCADE,
98
99
  email TEXT NOT NULL,
99
100
  role TEXT,
100
101
  status TEXT NOT NULL, -- 'pending', 'accepted', 'rejected', 'expired'
101
102
  expiresAt TIMESTAMP NOT NULL,
102
- inviterId TEXT NOT NULL REFERENCES user(id) ON DELETE CASCADE
103
+ inviterId TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
104
+ createdAt TIMESTAMP NOT NULL
103
105
  );
104
106
 
105
107
  -- ==========================================
@@ -109,7 +111,7 @@ CREATE TABLE IF NOT EXISTS invitation (
109
111
  --
110
112
  -- CREATE TABLE IF NOT EXISTS my_entity (
111
113
  -- id TEXT PRIMARY KEY,
112
- -- org_id TEXT NOT NULL, -- References organization.id
114
+ -- org_id TEXT NOT NULL, -- References organizations.id
113
115
  -- name TEXT NOT NULL,
114
116
  -- created_at INTEGER
115
117
  -- );