@objectstack/plugin-auth 3.2.5 → 3.2.7

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.js CHANGED
@@ -33,12 +33,23 @@ __export(index_exports, {
33
33
  AUTH_TWO_FACTOR_USER_FIELDS: () => AUTH_TWO_FACTOR_USER_FIELDS,
34
34
  AUTH_USER_CONFIG: () => AUTH_USER_CONFIG,
35
35
  AUTH_VERIFICATION_CONFIG: () => AUTH_VERIFICATION_CONFIG,
36
- AuthAccount: () => AuthAccount,
36
+ AuthAccount: () => SysAccount,
37
37
  AuthManager: () => AuthManager,
38
38
  AuthPlugin: () => AuthPlugin,
39
- AuthSession: () => AuthSession,
40
- AuthUser: () => AuthUser,
41
- AuthVerification: () => AuthVerification,
39
+ AuthSession: () => SysSession,
40
+ AuthUser: () => SysUser,
41
+ AuthVerification: () => SysVerification,
42
+ SysAccount: () => SysAccount,
43
+ SysApiKey: () => SysApiKey,
44
+ SysInvitation: () => SysInvitation,
45
+ SysMember: () => SysMember,
46
+ SysOrganization: () => SysOrganization,
47
+ SysSession: () => SysSession,
48
+ SysTeam: () => SysTeam,
49
+ SysTeamMember: () => SysTeamMember,
50
+ SysTwoFactor: () => SysTwoFactor,
51
+ SysUser: () => SysUser,
52
+ SysVerification: () => SysVerification,
42
53
  buildOrganizationPluginSchema: () => buildOrganizationPluginSchema,
43
54
  buildTwoFactorPluginSchema: () => buildTwoFactorPluginSchema,
44
55
  createObjectQLAdapter: () => createObjectQLAdapter,
@@ -265,14 +276,16 @@ var AUTH_VERIFICATION_CONFIG = {
265
276
  }
266
277
  };
267
278
  var AUTH_ORGANIZATION_SCHEMA = {
268
- modelName: "sys_organization",
279
+ modelName: import_system2.SystemObjectName.ORGANIZATION,
280
+ // 'sys_organization'
269
281
  fields: {
270
282
  createdAt: "created_at",
271
283
  updatedAt: "updated_at"
272
284
  }
273
285
  };
274
286
  var AUTH_MEMBER_SCHEMA = {
275
- modelName: "sys_member",
287
+ modelName: import_system2.SystemObjectName.MEMBER,
288
+ // 'sys_member'
276
289
  fields: {
277
290
  organizationId: "organization_id",
278
291
  userId: "user_id",
@@ -280,7 +293,8 @@ var AUTH_MEMBER_SCHEMA = {
280
293
  }
281
294
  };
282
295
  var AUTH_INVITATION_SCHEMA = {
283
- modelName: "sys_invitation",
296
+ modelName: import_system2.SystemObjectName.INVITATION,
297
+ // 'sys_invitation'
284
298
  fields: {
285
299
  organizationId: "organization_id",
286
300
  inviterId: "inviter_id",
@@ -294,7 +308,8 @@ var AUTH_ORG_SESSION_FIELDS = {
294
308
  activeTeamId: "active_team_id"
295
309
  };
296
310
  var AUTH_TEAM_SCHEMA = {
297
- modelName: "sys_team",
311
+ modelName: import_system2.SystemObjectName.TEAM,
312
+ // 'sys_team'
298
313
  fields: {
299
314
  organizationId: "organization_id",
300
315
  createdAt: "created_at",
@@ -302,7 +317,8 @@ var AUTH_TEAM_SCHEMA = {
302
317
  }
303
318
  };
304
319
  var AUTH_TEAM_MEMBER_SCHEMA = {
305
- modelName: "sys_team_member",
320
+ modelName: import_system2.SystemObjectName.TEAM_MEMBER,
321
+ // 'sys_team_member'
306
322
  fields: {
307
323
  teamId: "team_id",
308
324
  userId: "user_id",
@@ -310,7 +326,8 @@ var AUTH_TEAM_MEMBER_SCHEMA = {
310
326
  }
311
327
  };
312
328
  var AUTH_TWO_FACTOR_SCHEMA = {
313
- modelName: "sys_two_factor",
329
+ modelName: import_system2.SystemObjectName.TWO_FACTOR,
330
+ // 'sys_two_factor'
314
331
  fields: {
315
332
  backupCodes: "backup_codes",
316
333
  userId: "user_id"
@@ -382,10 +399,28 @@ var AuthManager = class {
382
399
  verification: {
383
400
  ...AUTH_VERIFICATION_CONFIG
384
401
  },
385
- // Email configuration
402
+ // Social / OAuth providers
403
+ ...this.config.socialProviders ? { socialProviders: this.config.socialProviders } : {},
404
+ // Email and password configuration
386
405
  emailAndPassword: {
387
- enabled: true
406
+ enabled: this.config.emailAndPassword?.enabled ?? true,
407
+ ...this.config.emailAndPassword?.disableSignUp != null ? { disableSignUp: this.config.emailAndPassword.disableSignUp } : {},
408
+ ...this.config.emailAndPassword?.requireEmailVerification != null ? { requireEmailVerification: this.config.emailAndPassword.requireEmailVerification } : {},
409
+ ...this.config.emailAndPassword?.minPasswordLength != null ? { minPasswordLength: this.config.emailAndPassword.minPasswordLength } : {},
410
+ ...this.config.emailAndPassword?.maxPasswordLength != null ? { maxPasswordLength: this.config.emailAndPassword.maxPasswordLength } : {},
411
+ ...this.config.emailAndPassword?.resetPasswordTokenExpiresIn != null ? { resetPasswordTokenExpiresIn: this.config.emailAndPassword.resetPasswordTokenExpiresIn } : {},
412
+ ...this.config.emailAndPassword?.autoSignIn != null ? { autoSignIn: this.config.emailAndPassword.autoSignIn } : {},
413
+ ...this.config.emailAndPassword?.revokeSessionsOnPasswordReset != null ? { revokeSessionsOnPasswordReset: this.config.emailAndPassword.revokeSessionsOnPasswordReset } : {}
388
414
  },
415
+ // Email verification
416
+ ...this.config.emailVerification ? {
417
+ emailVerification: {
418
+ ...this.config.emailVerification.sendOnSignUp != null ? { sendOnSignUp: this.config.emailVerification.sendOnSignUp } : {},
419
+ ...this.config.emailVerification.sendOnSignIn != null ? { sendOnSignIn: this.config.emailVerification.sendOnSignIn } : {},
420
+ ...this.config.emailVerification.autoSignInAfterVerification != null ? { autoSignInAfterVerification: this.config.emailVerification.autoSignInAfterVerification } : {},
421
+ ...this.config.emailVerification.expiresIn != null ? { expiresIn: this.config.emailVerification.expiresIn } : {}
422
+ }
423
+ } : {},
389
424
  // Session configuration
390
425
  session: {
391
426
  ...AUTH_SESSION_CONFIG,
@@ -395,7 +430,18 @@ var AuthManager = class {
395
430
  // 1 day default
396
431
  },
397
432
  // better-auth plugins — registered based on AuthPluginConfig flags
398
- plugins: this.buildPluginList()
433
+ plugins: this.buildPluginList(),
434
+ // Trusted origins for CSRF protection (supports wildcards like "https://*.example.com")
435
+ ...this.config.trustedOrigins?.length ? { trustedOrigins: this.config.trustedOrigins } : {},
436
+ // Advanced options (cross-subdomain cookies, secure cookies, CSRF, etc.)
437
+ ...this.config.advanced ? {
438
+ advanced: {
439
+ ...this.config.advanced.crossSubDomainCookies ? { crossSubDomainCookies: this.config.advanced.crossSubDomainCookies } : {},
440
+ ...this.config.advanced.useSecureCookies != null ? { useSecureCookies: this.config.advanced.useSecureCookies } : {},
441
+ ...this.config.advanced.disableCSRFCheck != null ? { disableCSRFCheck: this.config.advanced.disableCSRFCheck } : {},
442
+ ...this.config.advanced.cookiePrefix != null ? { cookiePrefix: this.config.advanced.cookiePrefix } : {}
443
+ }
444
+ } : {}
399
445
  };
400
446
  return (0, import_better_auth.betterAuth)(betterAuthConfig);
401
447
  }
@@ -465,6 +511,25 @@ var AuthManager = class {
465
511
  }
466
512
  return envSecret;
467
513
  }
514
+ /**
515
+ * Update the base URL at runtime.
516
+ *
517
+ * This **must** be called before the first request triggers lazy
518
+ * initialisation of the better-auth instance — typically from a
519
+ * `kernel:ready` hook where the actual server port is known.
520
+ *
521
+ * If the auth instance has already been created this is a no-op and
522
+ * a warning is emitted.
523
+ */
524
+ setRuntimeBaseUrl(url) {
525
+ if (this.auth) {
526
+ console.warn(
527
+ "[AuthManager] setRuntimeBaseUrl() called after the auth instance was already created \u2014 ignoring. Ensure this method is called before the first request."
528
+ );
529
+ return;
530
+ }
531
+ this.config = { ...this.config, baseUrl: url };
532
+ }
468
533
  /**
469
534
  * Get the underlying better-auth instance
470
535
  * Useful for advanced use cases
@@ -548,6 +613,21 @@ var AuthPlugin = class {
548
613
  } catch {
549
614
  }
550
615
  if (httpServer) {
616
+ const serverWithPort = httpServer;
617
+ if (this.authManager && typeof serverWithPort.getPort === "function") {
618
+ const actualPort = serverWithPort.getPort();
619
+ if (actualPort) {
620
+ const configuredUrl = this.options.baseUrl || "http://localhost:3000";
621
+ const configuredOrigin = new URL(configuredUrl).origin;
622
+ const actualUrl = `http://localhost:${actualPort}`;
623
+ if (configuredOrigin !== actualUrl) {
624
+ this.authManager.setRuntimeBaseUrl(actualUrl);
625
+ ctx.logger.info(
626
+ `Auth baseUrl auto-updated to ${actualUrl} (configured: ${configuredUrl})`
627
+ );
628
+ }
629
+ }
630
+ }
551
631
  this.registerAuthRoutes(httpServer, ctx);
552
632
  ctx.logger.info(`Auth routes registered at ${this.options.basePath}`);
553
633
  } else {
@@ -629,18 +709,19 @@ var AuthPlugin = class {
629
709
  }
630
710
  };
631
711
 
632
- // src/objects/auth-user.object.ts
712
+ // src/objects/sys-user.object.ts
633
713
  var import_data = require("@objectstack/spec/data");
634
- var AuthUser = import_data.ObjectSchema.create({
635
- name: "sys_user",
714
+ var SysUser = import_data.ObjectSchema.create({
715
+ namespace: "sys",
716
+ name: "user",
636
717
  label: "User",
637
718
  pluralLabel: "Users",
638
719
  icon: "user",
720
+ isSystem: true,
639
721
  description: "User accounts for authentication",
640
722
  titleFormat: "{name} ({email})",
641
723
  compactLayout: ["name", "email", "email_verified"],
642
724
  fields: {
643
- // ID is auto-generated by ObjectQL
644
725
  id: import_data.Field.text({
645
726
  label: "User ID",
646
727
  required: true,
@@ -676,12 +757,10 @@ var AuthUser = import_data.ObjectSchema.create({
676
757
  required: false
677
758
  })
678
759
  },
679
- // Database indexes for performance
680
760
  indexes: [
681
761
  { fields: ["email"], unique: true },
682
762
  { fields: ["created_at"], unique: false }
683
763
  ],
684
- // Enable features
685
764
  enable: {
686
765
  trackHistory: true,
687
766
  searchable: true,
@@ -690,7 +769,6 @@ var AuthUser = import_data.ObjectSchema.create({
690
769
  trash: true,
691
770
  mru: true
692
771
  },
693
- // Validation Rules
694
772
  validations: [
695
773
  {
696
774
  name: "email_unique",
@@ -703,13 +781,15 @@ var AuthUser = import_data.ObjectSchema.create({
703
781
  ]
704
782
  });
705
783
 
706
- // src/objects/auth-session.object.ts
784
+ // src/objects/sys-session.object.ts
707
785
  var import_data2 = require("@objectstack/spec/data");
708
- var AuthSession = import_data2.ObjectSchema.create({
709
- name: "sys_session",
786
+ var SysSession = import_data2.ObjectSchema.create({
787
+ namespace: "sys",
788
+ name: "session",
710
789
  label: "Session",
711
790
  pluralLabel: "Sessions",
712
791
  icon: "key",
792
+ isSystem: true,
713
793
  description: "Active user sessions",
714
794
  titleFormat: "Session {token}",
715
795
  compactLayout: ["user_id", "expires_at", "ip_address"],
@@ -752,33 +832,30 @@ var AuthSession = import_data2.ObjectSchema.create({
752
832
  required: false
753
833
  })
754
834
  },
755
- // Database indexes for performance
756
835
  indexes: [
757
836
  { fields: ["token"], unique: true },
758
837
  { fields: ["user_id"], unique: false },
759
838
  { fields: ["expires_at"], unique: false }
760
839
  ],
761
- // Enable features
762
840
  enable: {
763
841
  trackHistory: false,
764
- // Sessions don't need history tracking
765
842
  searchable: false,
766
843
  apiEnabled: true,
767
844
  apiMethods: ["get", "list", "create", "delete"],
768
- // No update for sessions
769
845
  trash: false,
770
- // Sessions should be hard deleted
771
846
  mru: false
772
847
  }
773
848
  });
774
849
 
775
- // src/objects/auth-account.object.ts
850
+ // src/objects/sys-account.object.ts
776
851
  var import_data3 = require("@objectstack/spec/data");
777
- var AuthAccount = import_data3.ObjectSchema.create({
778
- name: "sys_account",
852
+ var SysAccount = import_data3.ObjectSchema.create({
853
+ namespace: "sys",
854
+ name: "account",
779
855
  label: "Account",
780
856
  pluralLabel: "Accounts",
781
857
  icon: "link",
858
+ isSystem: true,
782
859
  description: "OAuth and authentication provider accounts",
783
860
  titleFormat: "{provider_id} - {account_id}",
784
861
  compactLayout: ["provider_id", "user_id", "account_id"],
@@ -843,12 +920,10 @@ var AuthAccount = import_data3.ObjectSchema.create({
843
920
  description: "Hashed password for email/password provider"
844
921
  })
845
922
  },
846
- // Database indexes for performance
847
923
  indexes: [
848
924
  { fields: ["user_id"], unique: false },
849
925
  { fields: ["provider_id", "account_id"], unique: true }
850
926
  ],
851
- // Enable features
852
927
  enable: {
853
928
  trackHistory: false,
854
929
  searchable: false,
@@ -859,13 +934,15 @@ var AuthAccount = import_data3.ObjectSchema.create({
859
934
  }
860
935
  });
861
936
 
862
- // src/objects/auth-verification.object.ts
937
+ // src/objects/sys-verification.object.ts
863
938
  var import_data4 = require("@objectstack/spec/data");
864
- var AuthVerification = import_data4.ObjectSchema.create({
865
- name: "sys_verification",
939
+ var SysVerification = import_data4.ObjectSchema.create({
940
+ namespace: "sys",
941
+ name: "verification",
866
942
  label: "Verification",
867
943
  pluralLabel: "Verifications",
868
944
  icon: "shield-check",
945
+ isSystem: true,
869
946
  description: "Email and phone verification tokens",
870
947
  titleFormat: "Verification for {identifier}",
871
948
  compactLayout: ["identifier", "expires_at", "created_at"],
@@ -900,21 +977,444 @@ var AuthVerification = import_data4.ObjectSchema.create({
900
977
  description: "Email address or phone number"
901
978
  })
902
979
  },
903
- // Database indexes for performance
904
980
  indexes: [
905
981
  { fields: ["value"], unique: true },
906
982
  { fields: ["identifier"], unique: false },
907
983
  { fields: ["expires_at"], unique: false }
908
984
  ],
909
- // Enable features
910
985
  enable: {
911
986
  trackHistory: false,
912
987
  searchable: false,
913
988
  apiEnabled: true,
914
989
  apiMethods: ["get", "create", "delete"],
915
- // No list or update
916
990
  trash: false,
917
- // Hard delete expired tokens
991
+ mru: false
992
+ }
993
+ });
994
+
995
+ // src/objects/sys-organization.object.ts
996
+ var import_data5 = require("@objectstack/spec/data");
997
+ var SysOrganization = import_data5.ObjectSchema.create({
998
+ namespace: "sys",
999
+ name: "organization",
1000
+ label: "Organization",
1001
+ pluralLabel: "Organizations",
1002
+ icon: "building-2",
1003
+ isSystem: true,
1004
+ description: "Organizations for multi-tenant grouping",
1005
+ titleFormat: "{name}",
1006
+ compactLayout: ["name", "slug", "created_at"],
1007
+ fields: {
1008
+ id: import_data5.Field.text({
1009
+ label: "Organization ID",
1010
+ required: true,
1011
+ readonly: true
1012
+ }),
1013
+ created_at: import_data5.Field.datetime({
1014
+ label: "Created At",
1015
+ defaultValue: "NOW()",
1016
+ readonly: true
1017
+ }),
1018
+ updated_at: import_data5.Field.datetime({
1019
+ label: "Updated At",
1020
+ defaultValue: "NOW()",
1021
+ readonly: true
1022
+ }),
1023
+ name: import_data5.Field.text({
1024
+ label: "Name",
1025
+ required: true,
1026
+ searchable: true,
1027
+ maxLength: 255
1028
+ }),
1029
+ slug: import_data5.Field.text({
1030
+ label: "Slug",
1031
+ required: false,
1032
+ maxLength: 255,
1033
+ description: "URL-friendly identifier"
1034
+ }),
1035
+ logo: import_data5.Field.url({
1036
+ label: "Logo",
1037
+ required: false
1038
+ }),
1039
+ metadata: import_data5.Field.textarea({
1040
+ label: "Metadata",
1041
+ required: false,
1042
+ description: "JSON-serialized organization metadata"
1043
+ })
1044
+ },
1045
+ indexes: [
1046
+ { fields: ["slug"], unique: true },
1047
+ { fields: ["name"] }
1048
+ ],
1049
+ enable: {
1050
+ trackHistory: true,
1051
+ searchable: true,
1052
+ apiEnabled: true,
1053
+ apiMethods: ["get", "list", "create", "update", "delete"],
1054
+ trash: true,
1055
+ mru: true
1056
+ }
1057
+ });
1058
+
1059
+ // src/objects/sys-member.object.ts
1060
+ var import_data6 = require("@objectstack/spec/data");
1061
+ var SysMember = import_data6.ObjectSchema.create({
1062
+ namespace: "sys",
1063
+ name: "member",
1064
+ label: "Member",
1065
+ pluralLabel: "Members",
1066
+ icon: "user-check",
1067
+ isSystem: true,
1068
+ description: "Organization membership records",
1069
+ titleFormat: "{user_id} in {organization_id}",
1070
+ compactLayout: ["user_id", "organization_id", "role"],
1071
+ fields: {
1072
+ id: import_data6.Field.text({
1073
+ label: "Member ID",
1074
+ required: true,
1075
+ readonly: true
1076
+ }),
1077
+ created_at: import_data6.Field.datetime({
1078
+ label: "Created At",
1079
+ defaultValue: "NOW()",
1080
+ readonly: true
1081
+ }),
1082
+ organization_id: import_data6.Field.text({
1083
+ label: "Organization ID",
1084
+ required: true
1085
+ }),
1086
+ user_id: import_data6.Field.text({
1087
+ label: "User ID",
1088
+ required: true
1089
+ }),
1090
+ role: import_data6.Field.text({
1091
+ label: "Role",
1092
+ required: false,
1093
+ description: "Member role within the organization (e.g. admin, member)",
1094
+ maxLength: 100
1095
+ })
1096
+ },
1097
+ indexes: [
1098
+ { fields: ["organization_id", "user_id"], unique: true },
1099
+ { fields: ["user_id"] }
1100
+ ],
1101
+ enable: {
1102
+ trackHistory: true,
1103
+ searchable: false,
1104
+ apiEnabled: true,
1105
+ apiMethods: ["get", "list", "create", "update", "delete"],
1106
+ trash: false,
1107
+ mru: false
1108
+ }
1109
+ });
1110
+
1111
+ // src/objects/sys-invitation.object.ts
1112
+ var import_data7 = require("@objectstack/spec/data");
1113
+ var SysInvitation = import_data7.ObjectSchema.create({
1114
+ namespace: "sys",
1115
+ name: "invitation",
1116
+ label: "Invitation",
1117
+ pluralLabel: "Invitations",
1118
+ icon: "mail",
1119
+ isSystem: true,
1120
+ description: "Organization invitations for user onboarding",
1121
+ titleFormat: "Invitation to {organization_id}",
1122
+ compactLayout: ["email", "organization_id", "status"],
1123
+ fields: {
1124
+ id: import_data7.Field.text({
1125
+ label: "Invitation ID",
1126
+ required: true,
1127
+ readonly: true
1128
+ }),
1129
+ created_at: import_data7.Field.datetime({
1130
+ label: "Created At",
1131
+ defaultValue: "NOW()",
1132
+ readonly: true
1133
+ }),
1134
+ organization_id: import_data7.Field.text({
1135
+ label: "Organization ID",
1136
+ required: true
1137
+ }),
1138
+ email: import_data7.Field.email({
1139
+ label: "Email",
1140
+ required: true,
1141
+ description: "Email address of the invited user"
1142
+ }),
1143
+ role: import_data7.Field.text({
1144
+ label: "Role",
1145
+ required: false,
1146
+ maxLength: 100,
1147
+ description: "Role to assign upon acceptance"
1148
+ }),
1149
+ status: import_data7.Field.select(["pending", "accepted", "rejected", "expired", "canceled"], {
1150
+ label: "Status",
1151
+ required: true,
1152
+ defaultValue: "pending"
1153
+ }),
1154
+ inviter_id: import_data7.Field.text({
1155
+ label: "Inviter ID",
1156
+ required: true,
1157
+ description: "User ID of the person who sent the invitation"
1158
+ }),
1159
+ expires_at: import_data7.Field.datetime({
1160
+ label: "Expires At",
1161
+ required: true
1162
+ }),
1163
+ team_id: import_data7.Field.text({
1164
+ label: "Team ID",
1165
+ required: false,
1166
+ description: "Optional team to assign upon acceptance"
1167
+ })
1168
+ },
1169
+ indexes: [
1170
+ { fields: ["organization_id"] },
1171
+ { fields: ["email"] },
1172
+ { fields: ["expires_at"] }
1173
+ ],
1174
+ enable: {
1175
+ trackHistory: true,
1176
+ searchable: false,
1177
+ apiEnabled: true,
1178
+ apiMethods: ["get", "list", "create", "update", "delete"],
1179
+ trash: false,
1180
+ mru: false
1181
+ }
1182
+ });
1183
+
1184
+ // src/objects/sys-team.object.ts
1185
+ var import_data8 = require("@objectstack/spec/data");
1186
+ var SysTeam = import_data8.ObjectSchema.create({
1187
+ namespace: "sys",
1188
+ name: "team",
1189
+ label: "Team",
1190
+ pluralLabel: "Teams",
1191
+ icon: "users",
1192
+ isSystem: true,
1193
+ description: "Teams within organizations for fine-grained grouping",
1194
+ titleFormat: "{name}",
1195
+ compactLayout: ["name", "organization_id", "created_at"],
1196
+ fields: {
1197
+ id: import_data8.Field.text({
1198
+ label: "Team ID",
1199
+ required: true,
1200
+ readonly: true
1201
+ }),
1202
+ created_at: import_data8.Field.datetime({
1203
+ label: "Created At",
1204
+ defaultValue: "NOW()",
1205
+ readonly: true
1206
+ }),
1207
+ updated_at: import_data8.Field.datetime({
1208
+ label: "Updated At",
1209
+ defaultValue: "NOW()",
1210
+ readonly: true
1211
+ }),
1212
+ name: import_data8.Field.text({
1213
+ label: "Name",
1214
+ required: true,
1215
+ searchable: true,
1216
+ maxLength: 255
1217
+ }),
1218
+ organization_id: import_data8.Field.text({
1219
+ label: "Organization ID",
1220
+ required: true
1221
+ })
1222
+ },
1223
+ indexes: [
1224
+ { fields: ["organization_id"] },
1225
+ { fields: ["name", "organization_id"], unique: true }
1226
+ ],
1227
+ enable: {
1228
+ trackHistory: true,
1229
+ searchable: true,
1230
+ apiEnabled: true,
1231
+ apiMethods: ["get", "list", "create", "update", "delete"],
1232
+ trash: true,
1233
+ mru: false
1234
+ }
1235
+ });
1236
+
1237
+ // src/objects/sys-team-member.object.ts
1238
+ var import_data9 = require("@objectstack/spec/data");
1239
+ var SysTeamMember = import_data9.ObjectSchema.create({
1240
+ namespace: "sys",
1241
+ name: "team_member",
1242
+ label: "Team Member",
1243
+ pluralLabel: "Team Members",
1244
+ icon: "user-plus",
1245
+ isSystem: true,
1246
+ description: "Team membership records linking users to teams",
1247
+ titleFormat: "{user_id} in {team_id}",
1248
+ compactLayout: ["user_id", "team_id", "created_at"],
1249
+ fields: {
1250
+ id: import_data9.Field.text({
1251
+ label: "Team Member ID",
1252
+ required: true,
1253
+ readonly: true
1254
+ }),
1255
+ created_at: import_data9.Field.datetime({
1256
+ label: "Created At",
1257
+ defaultValue: "NOW()",
1258
+ readonly: true
1259
+ }),
1260
+ team_id: import_data9.Field.text({
1261
+ label: "Team ID",
1262
+ required: true
1263
+ }),
1264
+ user_id: import_data9.Field.text({
1265
+ label: "User ID",
1266
+ required: true
1267
+ })
1268
+ },
1269
+ indexes: [
1270
+ { fields: ["team_id", "user_id"], unique: true },
1271
+ { fields: ["user_id"] }
1272
+ ],
1273
+ enable: {
1274
+ trackHistory: true,
1275
+ searchable: false,
1276
+ apiEnabled: true,
1277
+ apiMethods: ["get", "list", "create", "delete"],
1278
+ trash: false,
1279
+ mru: false
1280
+ }
1281
+ });
1282
+
1283
+ // src/objects/sys-api-key.object.ts
1284
+ var import_data10 = require("@objectstack/spec/data");
1285
+ var SysApiKey = import_data10.ObjectSchema.create({
1286
+ namespace: "sys",
1287
+ name: "api_key",
1288
+ label: "API Key",
1289
+ pluralLabel: "API Keys",
1290
+ icon: "key-round",
1291
+ isSystem: true,
1292
+ description: "API keys for programmatic access",
1293
+ titleFormat: "{name}",
1294
+ compactLayout: ["name", "user_id", "expires_at"],
1295
+ fields: {
1296
+ id: import_data10.Field.text({
1297
+ label: "API Key ID",
1298
+ required: true,
1299
+ readonly: true
1300
+ }),
1301
+ created_at: import_data10.Field.datetime({
1302
+ label: "Created At",
1303
+ defaultValue: "NOW()",
1304
+ readonly: true
1305
+ }),
1306
+ updated_at: import_data10.Field.datetime({
1307
+ label: "Updated At",
1308
+ defaultValue: "NOW()",
1309
+ readonly: true
1310
+ }),
1311
+ name: import_data10.Field.text({
1312
+ label: "Name",
1313
+ required: true,
1314
+ maxLength: 255,
1315
+ description: "Human-readable label for the API key"
1316
+ }),
1317
+ key: import_data10.Field.text({
1318
+ label: "Key",
1319
+ required: true,
1320
+ description: "Hashed API key value"
1321
+ }),
1322
+ prefix: import_data10.Field.text({
1323
+ label: "Prefix",
1324
+ required: false,
1325
+ maxLength: 16,
1326
+ description: 'Visible prefix for identifying the key (e.g., "osk_")'
1327
+ }),
1328
+ user_id: import_data10.Field.text({
1329
+ label: "User ID",
1330
+ required: true,
1331
+ description: "Owner user of this API key"
1332
+ }),
1333
+ scopes: import_data10.Field.textarea({
1334
+ label: "Scopes",
1335
+ required: false,
1336
+ description: "JSON array of permission scopes"
1337
+ }),
1338
+ expires_at: import_data10.Field.datetime({
1339
+ label: "Expires At",
1340
+ required: false
1341
+ }),
1342
+ last_used_at: import_data10.Field.datetime({
1343
+ label: "Last Used At",
1344
+ required: false
1345
+ }),
1346
+ revoked: import_data10.Field.boolean({
1347
+ label: "Revoked",
1348
+ defaultValue: false
1349
+ })
1350
+ },
1351
+ indexes: [
1352
+ { fields: ["key"], unique: true },
1353
+ { fields: ["user_id"] },
1354
+ { fields: ["prefix"] }
1355
+ ],
1356
+ enable: {
1357
+ trackHistory: true,
1358
+ searchable: false,
1359
+ apiEnabled: true,
1360
+ apiMethods: ["get", "list", "create", "update", "delete"],
1361
+ trash: false,
1362
+ mru: false
1363
+ }
1364
+ });
1365
+
1366
+ // src/objects/sys-two-factor.object.ts
1367
+ var import_data11 = require("@objectstack/spec/data");
1368
+ var SysTwoFactor = import_data11.ObjectSchema.create({
1369
+ namespace: "sys",
1370
+ name: "two_factor",
1371
+ label: "Two Factor",
1372
+ pluralLabel: "Two Factor Credentials",
1373
+ icon: "smartphone",
1374
+ isSystem: true,
1375
+ description: "Two-factor authentication credentials",
1376
+ titleFormat: "Two-factor for {user_id}",
1377
+ compactLayout: ["user_id", "created_at"],
1378
+ fields: {
1379
+ id: import_data11.Field.text({
1380
+ label: "Two Factor ID",
1381
+ required: true,
1382
+ readonly: true
1383
+ }),
1384
+ created_at: import_data11.Field.datetime({
1385
+ label: "Created At",
1386
+ defaultValue: "NOW()",
1387
+ readonly: true
1388
+ }),
1389
+ updated_at: import_data11.Field.datetime({
1390
+ label: "Updated At",
1391
+ defaultValue: "NOW()",
1392
+ readonly: true
1393
+ }),
1394
+ user_id: import_data11.Field.text({
1395
+ label: "User ID",
1396
+ required: true
1397
+ }),
1398
+ secret: import_data11.Field.text({
1399
+ label: "Secret",
1400
+ required: true,
1401
+ description: "TOTP secret key"
1402
+ }),
1403
+ backup_codes: import_data11.Field.textarea({
1404
+ label: "Backup Codes",
1405
+ required: false,
1406
+ description: "JSON-serialized backup recovery codes"
1407
+ })
1408
+ },
1409
+ indexes: [
1410
+ { fields: ["user_id"], unique: true }
1411
+ ],
1412
+ enable: {
1413
+ trackHistory: false,
1414
+ searchable: false,
1415
+ apiEnabled: true,
1416
+ apiMethods: ["get", "create", "update", "delete"],
1417
+ trash: false,
918
1418
  mru: false
919
1419
  }
920
1420
  });
@@ -939,6 +1439,17 @@ var AuthVerification = import_data4.ObjectSchema.create({
939
1439
  AuthSession,
940
1440
  AuthUser,
941
1441
  AuthVerification,
1442
+ SysAccount,
1443
+ SysApiKey,
1444
+ SysInvitation,
1445
+ SysMember,
1446
+ SysOrganization,
1447
+ SysSession,
1448
+ SysTeam,
1449
+ SysTeamMember,
1450
+ SysTwoFactor,
1451
+ SysUser,
1452
+ SysVerification,
942
1453
  buildOrganizationPluginSchema,
943
1454
  buildTwoFactorPluginSchema,
944
1455
  createObjectQLAdapter,