@glinr/theauth 0.4.2 → 0.6.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.
@@ -1,7 +1,7 @@
1
- import { D as Database, A as AgentIdentity, i as AuthorizeRequest, j as AuthorizeResult, P as Permission } from '../types-D1sBnWrs.js';
2
- export { ar as PermissionConstraints } from '../types-D1sBnWrs.js';
1
+ import { D as Database, A as AgentIdentity, n as AuthorizeRequest, o as AuthorizeResult, P as Permission } from '../types-JOx1R8-Q.js';
2
+ export { at as PermissionConstraints } from '../types-JOx1R8-Q.js';
3
3
  import 'drizzle-orm/sqlite-core';
4
- import '../types-BiUe9e8u.js';
4
+ import '../types-XoCxTUZj.js';
5
5
  import 'zod';
6
6
  import '../redirect/index.js';
7
7
 
@@ -6,7 +6,7 @@ function generateId() {
6
6
  return globalThis.crypto.randomUUID();
7
7
  }
8
8
  new TextEncoder();
9
- var users = sqliteTable("kavach_users", {
9
+ var users = sqliteTable("theauth_users", {
10
10
  id: text("id").primaryKey(),
11
11
  email: text("email").notNull().unique(),
12
12
  name: text("name"),
@@ -22,14 +22,14 @@ var users = sqliteTable("kavach_users", {
22
22
  banExpiresAt: integer("ban_expires_at", { mode: "timestamp" }),
23
23
  forcePasswordReset: integer("force_password_reset").notNull().default(0),
24
24
  emailVerified: integer("email_verified").notNull().default(0),
25
- // Stripe integration fields (populated by kavach-stripe plugin)
25
+ // Stripe integration fields (populated by theauth-stripe plugin)
26
26
  stripeCustomerId: text("stripe_customer_id").unique(),
27
27
  stripeSubscriptionId: text("stripe_subscription_id"),
28
28
  stripeSubscriptionStatus: text("stripe_subscription_status"),
29
29
  stripePriceId: text("stripe_price_id"),
30
30
  stripeCurrentPeriodEnd: integer("stripe_current_period_end", { mode: "timestamp" }),
31
31
  stripeCancelAtPeriodEnd: integer("stripe_cancel_at_period_end", { mode: "boolean" }).notNull().default(false),
32
- // Polar integration fields (populated by kavach-polar plugin)
32
+ // Polar integration fields (populated by theauth-polar plugin)
33
33
  polarCustomerId: text("polar_customer_id").unique(),
34
34
  polarSubscriptionId: text("polar_subscription_id"),
35
35
  polarSubscriptionStatus: text("polar_subscription_status"),
@@ -39,7 +39,7 @@ var users = sqliteTable("kavach_users", {
39
39
  createdAt: integer("created_at", { mode: "timestamp" }).notNull(),
40
40
  updatedAt: integer("updated_at", { mode: "timestamp" }).notNull()
41
41
  });
42
- var tenants = sqliteTable("kavach_tenants", {
42
+ var tenants = sqliteTable("theauth_tenants", {
43
43
  id: text("id").primaryKey(),
44
44
  name: text("name").notNull(),
45
45
  slug: text("slug").notNull().unique(),
@@ -48,7 +48,7 @@ var tenants = sqliteTable("kavach_tenants", {
48
48
  createdAt: integer("created_at", { mode: "timestamp" }).notNull(),
49
49
  updatedAt: integer("updated_at", { mode: "timestamp" }).notNull()
50
50
  });
51
- var agents = sqliteTable("kavach_agents", {
51
+ var agents = sqliteTable("theauth_agents", {
52
52
  id: text("id").primaryKey(),
53
53
  ownerId: text("owner_id").notNull().references(() => users.id),
54
54
  tenantId: text("tenant_id").references(() => tenants.id),
@@ -66,7 +66,7 @@ var agents = sqliteTable("kavach_agents", {
66
66
  createdAt: integer("created_at", { mode: "timestamp" }).notNull(),
67
67
  updatedAt: integer("updated_at", { mode: "timestamp" }).notNull()
68
68
  });
69
- sqliteTable("kavach_permissions", {
69
+ sqliteTable("theauth_permissions", {
70
70
  id: text("id").primaryKey(),
71
71
  agentId: text("agent_id").notNull().references(() => agents.id, { onDelete: "cascade" }),
72
72
  resource: text("resource").notNull(),
@@ -78,7 +78,7 @@ sqliteTable("kavach_permissions", {
78
78
  relation: text("relation"),
79
79
  createdAt: integer("created_at", { mode: "timestamp" }).notNull()
80
80
  });
81
- sqliteTable("kavach_delegation_chains", {
81
+ sqliteTable("theauth_delegation_chains", {
82
82
  id: text("id").primaryKey(),
83
83
  fromAgentId: text("from_agent_id").notNull().references(() => agents.id),
84
84
  toAgentId: text("to_agent_id").notNull().references(() => agents.id),
@@ -89,7 +89,7 @@ sqliteTable("kavach_delegation_chains", {
89
89
  expiresAt: integer("expires_at", { mode: "timestamp" }).notNull(),
90
90
  createdAt: integer("created_at", { mode: "timestamp" }).notNull()
91
91
  });
92
- var auditLogs = sqliteTable("kavach_audit_logs", {
92
+ var auditLogs = sqliteTable("theauth_audit_logs", {
93
93
  id: text("id").primaryKey(),
94
94
  agentId: text("agent_id").notNull().references(() => agents.id),
95
95
  userId: text("user_id").notNull().references(() => users.id),
@@ -109,14 +109,14 @@ var auditLogs = sqliteTable("kavach_audit_logs", {
109
109
  cacheHit: integer("cache_hit", { mode: "boolean" }).notNull().default(false),
110
110
  timestamp: integer("timestamp", { mode: "timestamp" }).notNull()
111
111
  });
112
- var rateLimits = sqliteTable("kavach_rate_limits", {
112
+ var rateLimits = sqliteTable("theauth_rate_limits", {
113
113
  id: text("id").primaryKey(),
114
114
  agentId: text("agent_id").notNull().references(() => agents.id, { onDelete: "cascade" }),
115
115
  resource: text("resource").notNull(),
116
116
  windowStart: integer("window_start", { mode: "timestamp" }).notNull(),
117
117
  count: integer("count").notNull().default(0)
118
118
  });
119
- sqliteTable("kavach_mcp_servers", {
119
+ sqliteTable("theauth_mcp_servers", {
120
120
  id: text("id").primaryKey(),
121
121
  name: text("name").notNull(),
122
122
  endpoint: text("endpoint").notNull().unique(),
@@ -127,14 +127,14 @@ sqliteTable("kavach_mcp_servers", {
127
127
  createdAt: integer("created_at", { mode: "timestamp" }).notNull(),
128
128
  updatedAt: integer("updated_at", { mode: "timestamp" }).notNull()
129
129
  });
130
- sqliteTable("kavach_sessions", {
130
+ sqliteTable("theauth_sessions", {
131
131
  id: text("id").primaryKey(),
132
132
  userId: text("user_id").notNull().references(() => users.id),
133
133
  expiresAt: integer("expires_at", { mode: "timestamp" }).notNull(),
134
134
  metadata: text("metadata", { mode: "json" }).$type(),
135
135
  createdAt: integer("created_at", { mode: "timestamp" }).notNull()
136
136
  });
137
- var oauthClients = sqliteTable("kavach_oauth_clients", {
137
+ var oauthClients = sqliteTable("theauth_oauth_clients", {
138
138
  id: text("id").primaryKey(),
139
139
  clientId: text("client_id").notNull().unique(),
140
140
  clientSecret: text("client_secret"),
@@ -151,7 +151,7 @@ var oauthClients = sqliteTable("kavach_oauth_clients", {
151
151
  createdAt: integer("created_at", { mode: "timestamp" }).notNull(),
152
152
  updatedAt: integer("updated_at", { mode: "timestamp" }).notNull()
153
153
  });
154
- sqliteTable("kavach_oauth_access_tokens", {
154
+ sqliteTable("theauth_oauth_access_tokens", {
155
155
  id: text("id").primaryKey(),
156
156
  accessToken: text("access_token").notNull().unique(),
157
157
  refreshToken: text("refresh_token").unique(),
@@ -165,7 +165,7 @@ sqliteTable("kavach_oauth_access_tokens", {
165
165
  refreshTokenExpiresAt: integer("refresh_token_expires_at", { mode: "timestamp" }),
166
166
  createdAt: integer("created_at", { mode: "timestamp" }).notNull()
167
167
  });
168
- sqliteTable("kavach_oauth_authorization_codes", {
168
+ sqliteTable("theauth_oauth_authorization_codes", {
169
169
  id: text("id").primaryKey(),
170
170
  code: text("code").notNull().unique(),
171
171
  clientId: text("client_id").notNull().references(() => oauthClients.clientId),
@@ -181,7 +181,7 @@ sqliteTable("kavach_oauth_authorization_codes", {
181
181
  expiresAt: integer("expires_at", { mode: "timestamp" }).notNull(),
182
182
  createdAt: integer("created_at", { mode: "timestamp" }).notNull()
183
183
  });
184
- sqliteTable("kavach_budget_policies", {
184
+ sqliteTable("theauth_budget_policies", {
185
185
  id: text("id").primaryKey(),
186
186
  agentId: text("agent_id").references(() => agents.id, { onDelete: "cascade" }),
187
187
  // nullable
@@ -195,7 +195,7 @@ sqliteTable("kavach_budget_policies", {
195
195
  status: text("status", { enum: ["active", "triggered", "disabled"] }).notNull().default("active"),
196
196
  createdAt: integer("created_at", { mode: "timestamp" }).notNull()
197
197
  });
198
- sqliteTable("kavach_agent_cards", {
198
+ sqliteTable("theauth_agent_cards", {
199
199
  id: text("id").primaryKey(),
200
200
  agentId: text("agent_id").notNull().references(() => agents.id, { onDelete: "cascade" }),
201
201
  name: text("name").notNull(),
@@ -209,7 +209,7 @@ sqliteTable("kavach_agent_cards", {
209
209
  createdAt: integer("created_at", { mode: "timestamp" }).notNull(),
210
210
  updatedAt: integer("updated_at", { mode: "timestamp" }).notNull()
211
211
  });
212
- sqliteTable("kavach_approval_requests", {
212
+ sqliteTable("theauth_approval_requests", {
213
213
  id: text("id").primaryKey(),
214
214
  agentId: text("agent_id").notNull().references(() => agents.id, { onDelete: "cascade" }),
215
215
  userId: text("user_id").notNull().references(() => users.id),
@@ -222,7 +222,7 @@ sqliteTable("kavach_approval_requests", {
222
222
  respondedBy: text("responded_by"),
223
223
  createdAt: integer("created_at", { mode: "timestamp" }).notNull()
224
224
  });
225
- sqliteTable("kavach_trust_scores", {
225
+ sqliteTable("theauth_trust_scores", {
226
226
  agentId: text("agent_id").primaryKey().references(() => agents.id, { onDelete: "cascade" }),
227
227
  score: integer("score").notNull(),
228
228
  level: text("level", {
@@ -231,7 +231,7 @@ sqliteTable("kavach_trust_scores", {
231
231
  factors: text("factors", { mode: "json" }).notNull().$type(),
232
232
  computedAt: integer("computed_at", { mode: "timestamp" }).notNull()
233
233
  });
234
- sqliteTable("kavach_magic_links", {
234
+ sqliteTable("theauth_magic_links", {
235
235
  id: text("id").primaryKey(),
236
236
  email: text("email").notNull(),
237
237
  token: text("token").notNull().unique(),
@@ -239,7 +239,7 @@ sqliteTable("kavach_magic_links", {
239
239
  used: integer("used", { mode: "boolean" }).notNull().default(false),
240
240
  createdAt: integer("created_at", { mode: "timestamp" }).notNull()
241
241
  });
242
- sqliteTable("kavach_email_otps", {
242
+ sqliteTable("theauth_email_otps", {
243
243
  id: text("id").primaryKey(),
244
244
  email: text("email").notNull(),
245
245
  codeHash: text("code_hash").notNull(),
@@ -247,7 +247,7 @@ sqliteTable("kavach_email_otps", {
247
247
  attempts: integer("attempts").notNull().default(0),
248
248
  createdAt: integer("created_at", { mode: "timestamp" }).notNull()
249
249
  });
250
- sqliteTable("kavach_totp", {
250
+ sqliteTable("theauth_totp", {
251
251
  userId: text("user_id").primaryKey().references(() => users.id),
252
252
  secret: text("secret").notNull(),
253
253
  // base32-encoded TOTP secret
@@ -256,7 +256,7 @@ sqliteTable("kavach_totp", {
256
256
  createdAt: integer("created_at", { mode: "timestamp" }).notNull(),
257
257
  updatedAt: integer("updated_at", { mode: "timestamp" }).notNull()
258
258
  });
259
- var organizations = sqliteTable("kavach_organizations", {
259
+ var organizations = sqliteTable("theauth_organizations", {
260
260
  id: text("id").primaryKey(),
261
261
  name: text("name").notNull(),
262
262
  slug: text("slug").notNull().unique(),
@@ -265,14 +265,14 @@ var organizations = sqliteTable("kavach_organizations", {
265
265
  createdAt: integer("created_at", { mode: "timestamp" }).notNull(),
266
266
  updatedAt: integer("updated_at", { mode: "timestamp" }).notNull()
267
267
  });
268
- sqliteTable("kavach_org_members", {
268
+ sqliteTable("theauth_org_members", {
269
269
  id: text("id").primaryKey(),
270
270
  orgId: text("org_id").notNull().references(() => organizations.id, { onDelete: "cascade" }),
271
271
  userId: text("user_id").notNull().references(() => users.id),
272
272
  role: text("role").notNull().default("member"),
273
273
  joinedAt: integer("joined_at", { mode: "timestamp" }).notNull()
274
274
  });
275
- sqliteTable("kavach_org_invitations", {
275
+ sqliteTable("theauth_org_invitations", {
276
276
  id: text("id").primaryKey(),
277
277
  orgId: text("org_id").notNull().references(() => organizations.id, { onDelete: "cascade" }),
278
278
  email: text("email").notNull(),
@@ -282,13 +282,13 @@ sqliteTable("kavach_org_invitations", {
282
282
  expiresAt: integer("expires_at", { mode: "timestamp" }).notNull(),
283
283
  createdAt: integer("created_at", { mode: "timestamp" }).notNull()
284
284
  });
285
- sqliteTable("kavach_org_roles", {
285
+ sqliteTable("theauth_org_roles", {
286
286
  id: text("id").primaryKey(),
287
287
  orgId: text("org_id").notNull().references(() => organizations.id, { onDelete: "cascade" }),
288
288
  name: text("name").notNull(),
289
289
  permissions: text("permissions", { mode: "json" }).notNull().$type()
290
290
  });
291
- sqliteTable("kavach_passkey_credentials", {
291
+ sqliteTable("theauth_passkey_credentials", {
292
292
  id: text("id").primaryKey(),
293
293
  userId: text("user_id").notNull().references(() => users.id),
294
294
  credentialId: text("credential_id").notNull().unique(),
@@ -301,7 +301,7 @@ sqliteTable("kavach_passkey_credentials", {
301
301
  createdAt: integer("created_at", { mode: "timestamp" }).notNull(),
302
302
  lastUsedAt: integer("last_used_at", { mode: "timestamp" }).notNull()
303
303
  });
304
- sqliteTable("kavach_sso_connections", {
304
+ sqliteTable("theauth_sso_connections", {
305
305
  id: text("id").primaryKey(),
306
306
  orgId: text("org_id").notNull(),
307
307
  providerId: text("provider_id").notNull(),
@@ -310,7 +310,7 @@ sqliteTable("kavach_sso_connections", {
310
310
  enabled: integer("enabled").notNull().default(1),
311
311
  createdAt: integer("created_at", { mode: "timestamp" }).notNull()
312
312
  });
313
- sqliteTable("kavach_api_keys", {
313
+ sqliteTable("theauth_api_keys", {
314
314
  id: text("id").primaryKey(),
315
315
  userId: text("user_id").notNull().references(() => users.id),
316
316
  name: text("name").notNull(),
@@ -321,7 +321,7 @@ sqliteTable("kavach_api_keys", {
321
321
  lastUsedAt: integer("last_used_at", { mode: "timestamp" }),
322
322
  createdAt: integer("created_at", { mode: "timestamp" }).notNull()
323
323
  });
324
- sqliteTable("kavach_passkey_challenges", {
324
+ sqliteTable("theauth_passkey_challenges", {
325
325
  id: text("id").primaryKey(),
326
326
  challenge: text("challenge").notNull().unique(),
327
327
  userId: text("user_id"),
@@ -330,7 +330,7 @@ sqliteTable("kavach_passkey_challenges", {
330
330
  expiresAt: integer("expires_at", { mode: "timestamp" }).notNull(),
331
331
  createdAt: integer("created_at", { mode: "timestamp" }).notNull()
332
332
  });
333
- sqliteTable("kavach_username_accounts", {
333
+ sqliteTable("theauth_username_accounts", {
334
334
  id: text("id").primaryKey(),
335
335
  userId: text("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
336
336
  username: text("username").notNull().unique(),
@@ -338,7 +338,7 @@ sqliteTable("kavach_username_accounts", {
338
338
  createdAt: integer("created_at", { mode: "timestamp" }).notNull(),
339
339
  updatedAt: integer("updated_at", { mode: "timestamp" }).notNull()
340
340
  });
341
- sqliteTable("kavach_phone_verifications", {
341
+ sqliteTable("theauth_phone_verifications", {
342
342
  id: text("id").primaryKey(),
343
343
  phoneNumber: text("phone_number").notNull(),
344
344
  codeHash: text("code_hash").notNull(),
@@ -346,7 +346,7 @@ sqliteTable("kavach_phone_verifications", {
346
346
  expiresAt: integer("expires_at", { mode: "timestamp" }).notNull(),
347
347
  createdAt: integer("created_at", { mode: "timestamp" }).notNull()
348
348
  });
349
- sqliteTable("kavach_trusted_devices", {
349
+ sqliteTable("theauth_trusted_devices", {
350
350
  id: text("id").primaryKey(),
351
351
  userId: text("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
352
352
  fingerprint: text("fingerprint").notNull(),
@@ -356,7 +356,7 @@ sqliteTable("kavach_trusted_devices", {
356
356
  trustedAt: integer("trusted_at", { mode: "timestamp" }).notNull(),
357
357
  expiresAt: integer("expires_at", { mode: "timestamp" }).notNull()
358
358
  });
359
- sqliteTable("kavach_one_time_tokens", {
359
+ sqliteTable("theauth_one_time_tokens", {
360
360
  id: text("id").primaryKey(),
361
361
  tokenHash: text("token_hash").notNull().unique(),
362
362
  // SHA-256 hex of the raw token
@@ -370,7 +370,7 @@ sqliteTable("kavach_one_time_tokens", {
370
370
  expiresAt: integer("expires_at", { mode: "timestamp" }).notNull(),
371
371
  createdAt: integer("created_at", { mode: "timestamp" }).notNull()
372
372
  });
373
- sqliteTable("kavach_login_history", {
373
+ sqliteTable("theauth_login_history", {
374
374
  id: text("id").primaryKey(),
375
375
  userId: text("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
376
376
  method: text("method").notNull(),
@@ -379,7 +379,7 @@ sqliteTable("kavach_login_history", {
379
379
  userAgent: text("user_agent"),
380
380
  timestamp: integer("timestamp", { mode: "timestamp_ms" }).notNull()
381
381
  });
382
- sqliteTable("kavach_agent_dids", {
382
+ sqliteTable("theauth_agent_dids", {
383
383
  agentId: text("agent_id").primaryKey().references(() => agents.id, { onDelete: "cascade" }),
384
384
  did: text("did").notNull().unique(),
385
385
  method: text("method", { enum: ["key", "web"] }).notNull(),
@@ -389,7 +389,7 @@ sqliteTable("kavach_agent_dids", {
389
389
  // JSON-serialised DID Document
390
390
  createdAt: integer("created_at", { mode: "timestamp" }).notNull()
391
391
  });
392
- sqliteTable("kavach_oidc_clients", {
392
+ sqliteTable("theauth_oidc_clients", {
393
393
  id: text("id").primaryKey(),
394
394
  clientId: text("client_id").notNull().unique(),
395
395
  clientSecretHash: text("client_secret_hash").notNull(),
@@ -403,7 +403,7 @@ sqliteTable("kavach_oidc_clients", {
403
403
  createdAt: integer("created_at", { mode: "timestamp" }).notNull(),
404
404
  updatedAt: integer("updated_at", { mode: "timestamp" }).notNull()
405
405
  });
406
- sqliteTable("kavach_oidc_auth_codes", {
406
+ sqliteTable("theauth_oidc_auth_codes", {
407
407
  id: text("id").primaryKey(),
408
408
  codeHash: text("code_hash").notNull().unique(),
409
409
  // SHA-256 hex of the raw code
@@ -420,7 +420,7 @@ sqliteTable("kavach_oidc_auth_codes", {
420
420
  expiresAt: integer("expires_at", { mode: "timestamp" }).notNull(),
421
421
  createdAt: integer("created_at", { mode: "timestamp" }).notNull()
422
422
  });
423
- sqliteTable("kavach_oidc_refresh_tokens", {
423
+ sqliteTable("theauth_oidc_refresh_tokens", {
424
424
  id: text("id").primaryKey(),
425
425
  tokenHash: text("token_hash").notNull().unique(),
426
426
  // SHA-256 hex of the raw token
@@ -432,7 +432,7 @@ sqliteTable("kavach_oidc_refresh_tokens", {
432
432
  expiresAt: integer("expires_at", { mode: "timestamp" }).notNull(),
433
433
  createdAt: integer("created_at", { mode: "timestamp" }).notNull()
434
434
  });
435
- sqliteTable("kavach_cost_events", {
435
+ sqliteTable("theauth_cost_events", {
436
436
  id: text("id").primaryKey(),
437
437
  agentId: text("agent_id").notNull().references(() => agents.id, { onDelete: "cascade" }),
438
438
  tool: text("tool").notNull(),
@@ -447,7 +447,7 @@ sqliteTable("kavach_cost_events", {
447
447
  // null when not part of a chain
448
448
  recordedAt: integer("recorded_at", { mode: "timestamp" }).notNull()
449
449
  });
450
- sqliteTable("kavach_ephemeral_sessions", {
450
+ sqliteTable("theauth_ephemeral_sessions", {
451
451
  id: text("id").primaryKey(),
452
452
  agentId: text("agent_id").notNull().references(() => agents.id, { onDelete: "cascade" }),
453
453
  ownerId: text("owner_id").notNull().references(() => users.id),
@@ -461,7 +461,7 @@ sqliteTable("kavach_ephemeral_sessions", {
461
461
  createdAt: integer("created_at", { mode: "timestamp" }).notNull(),
462
462
  updatedAt: integer("updated_at", { mode: "timestamp" }).notNull()
463
463
  });
464
- sqliteTable("kavach_stream_events", {
464
+ sqliteTable("theauth_stream_events", {
465
465
  id: text("id").primaryKey(),
466
466
  type: text("type").notNull(),
467
467
  timestamp: integer("timestamp", { mode: "timestamp" }).notNull(),
@@ -469,7 +469,7 @@ sqliteTable("kavach_stream_events", {
469
469
  agentId: text("agent_id"),
470
470
  userId: text("user_id")
471
471
  });
472
- sqliteTable("kavach_jwt_refresh_tokens", {
472
+ sqliteTable("theauth_jwt_refresh_tokens", {
473
473
  id: text("id").primaryKey(),
474
474
  /** SHA-256 hex of the raw refresh token. The raw token is never stored. */
475
475
  tokenHash: text("token_hash").notNull().unique(),
@@ -480,7 +480,7 @@ sqliteTable("kavach_jwt_refresh_tokens", {
480
480
  expiresAt: integer("expires_at", { mode: "timestamp" }).notNull(),
481
481
  createdAt: integer("created_at", { mode: "timestamp" }).notNull()
482
482
  });
483
- sqliteTable("kavach_rebac_resources", {
483
+ sqliteTable("theauth_rebac_resources", {
484
484
  id: text("id").notNull().primaryKey(),
485
485
  type: text("type").notNull(),
486
486
  // 'org', 'workspace', 'project', 'document', etc.
@@ -488,7 +488,7 @@ sqliteTable("kavach_rebac_resources", {
488
488
  parentType: text("parent_type"),
489
489
  createdAt: integer("created_at", { mode: "timestamp" }).notNull()
490
490
  });
491
- sqliteTable("kavach_rebac_relationships", {
491
+ sqliteTable("theauth_rebac_relationships", {
492
492
  id: text("id").primaryKey(),
493
493
  subjectType: text("subject_type").notNull(),
494
494
  // 'user', 'agent', 'team', 'role'
@@ -499,7 +499,7 @@ sqliteTable("kavach_rebac_relationships", {
499
499
  objectId: text("object_id").notNull(),
500
500
  createdAt: integer("created_at", { mode: "timestamp" }).notNull()
501
501
  });
502
- sqliteTable("kavach_federation_instances", {
502
+ sqliteTable("theauth_federation_instances", {
503
503
  id: text("id").primaryKey(),
504
504
  instanceId: text("instance_id").notNull().unique(),
505
505
  instanceUrl: text("instance_url").notNull(),
@@ -510,7 +510,7 @@ sqliteTable("kavach_federation_instances", {
510
510
  createdAt: integer("created_at", { mode: "timestamp" }).notNull(),
511
511
  updatedAt: integer("updated_at", { mode: "timestamp" }).notNull()
512
512
  });
513
- sqliteTable("kavach_federation_tokens", {
513
+ sqliteTable("theauth_federation_tokens", {
514
514
  id: text("id").primaryKey(),
515
515
  tokenJti: text("token_jti").notNull().unique(),
516
516
  // JWT ID for dedup
@@ -524,7 +524,7 @@ sqliteTable("kavach_federation_tokens", {
524
524
  expiresAt: integer("expires_at", { mode: "timestamp" }).notNull(),
525
525
  createdAt: integer("created_at", { mode: "timestamp" }).notNull()
526
526
  });
527
- var refreshTokenFamilies = sqliteTable("kavach_refresh_token_families", {
527
+ var refreshTokenFamilies = sqliteTable("theauth_refresh_token_families", {
528
528
  id: text("id").primaryKey(),
529
529
  userId: text("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
530
530
  /** Absolute session expiry — no rotation can extend beyond this date. */
@@ -533,7 +533,7 @@ var refreshTokenFamilies = sqliteTable("kavach_refresh_token_families", {
533
533
  revoked: integer("revoked").notNull().default(0),
534
534
  createdAt: integer("created_at", { mode: "timestamp" }).notNull()
535
535
  });
536
- sqliteTable("kavach_refresh_tokens", {
536
+ sqliteTable("theauth_refresh_tokens", {
537
537
  id: text("id").primaryKey(),
538
538
  familyId: text("family_id").notNull().references(() => refreshTokenFamilies.id, { onDelete: "cascade" }),
539
539
  /** SHA-256 hash of the opaque token — never store the raw token. */
@@ -713,7 +713,8 @@ function createPermissionEngine(config) {
713
713
  subjectId: agent.id,
714
714
  resource: request.resource,
715
715
  arguments: request.arguments,
716
- ip: request.ip
716
+ // Adapters pass the client IP via context; direct callers may set request.ip.
717
+ ip: request.context?.ip ?? request.ip
717
718
  },
718
719
  matchingPermission.constraints
719
720
  );
@@ -750,7 +751,7 @@ async function writeAuditLog(db, agent, request, result, startTime, auditId) {
750
751
  reason: result.reason ?? null,
751
752
  durationMs,
752
753
  timestamp: /* @__PURE__ */ new Date(),
753
- ip: request.context?.ip ?? null,
754
+ ip: request.context?.ip ?? request.ip ?? null,
754
755
  userAgent: request.context?.userAgent ?? null
755
756
  });
756
757
  }