@objectstack/plugin-auth 3.2.5 → 3.2.6

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.mjs CHANGED
@@ -216,14 +216,16 @@ var AUTH_VERIFICATION_CONFIG = {
216
216
  }
217
217
  };
218
218
  var AUTH_ORGANIZATION_SCHEMA = {
219
- modelName: "sys_organization",
219
+ modelName: SystemObjectName2.ORGANIZATION,
220
+ // 'sys_organization'
220
221
  fields: {
221
222
  createdAt: "created_at",
222
223
  updatedAt: "updated_at"
223
224
  }
224
225
  };
225
226
  var AUTH_MEMBER_SCHEMA = {
226
- modelName: "sys_member",
227
+ modelName: SystemObjectName2.MEMBER,
228
+ // 'sys_member'
227
229
  fields: {
228
230
  organizationId: "organization_id",
229
231
  userId: "user_id",
@@ -231,7 +233,8 @@ var AUTH_MEMBER_SCHEMA = {
231
233
  }
232
234
  };
233
235
  var AUTH_INVITATION_SCHEMA = {
234
- modelName: "sys_invitation",
236
+ modelName: SystemObjectName2.INVITATION,
237
+ // 'sys_invitation'
235
238
  fields: {
236
239
  organizationId: "organization_id",
237
240
  inviterId: "inviter_id",
@@ -245,7 +248,8 @@ var AUTH_ORG_SESSION_FIELDS = {
245
248
  activeTeamId: "active_team_id"
246
249
  };
247
250
  var AUTH_TEAM_SCHEMA = {
248
- modelName: "sys_team",
251
+ modelName: SystemObjectName2.TEAM,
252
+ // 'sys_team'
249
253
  fields: {
250
254
  organizationId: "organization_id",
251
255
  createdAt: "created_at",
@@ -253,7 +257,8 @@ var AUTH_TEAM_SCHEMA = {
253
257
  }
254
258
  };
255
259
  var AUTH_TEAM_MEMBER_SCHEMA = {
256
- modelName: "sys_team_member",
260
+ modelName: SystemObjectName2.TEAM_MEMBER,
261
+ // 'sys_team_member'
257
262
  fields: {
258
263
  teamId: "team_id",
259
264
  userId: "user_id",
@@ -261,7 +266,8 @@ var AUTH_TEAM_MEMBER_SCHEMA = {
261
266
  }
262
267
  };
263
268
  var AUTH_TWO_FACTOR_SCHEMA = {
264
- modelName: "sys_two_factor",
269
+ modelName: SystemObjectName2.TWO_FACTOR,
270
+ // 'sys_two_factor'
265
271
  fields: {
266
272
  backupCodes: "backup_codes",
267
273
  userId: "user_id"
@@ -580,18 +586,19 @@ var AuthPlugin = class {
580
586
  }
581
587
  };
582
588
 
583
- // src/objects/auth-user.object.ts
589
+ // src/objects/sys-user.object.ts
584
590
  import { ObjectSchema, Field } from "@objectstack/spec/data";
585
- var AuthUser = ObjectSchema.create({
586
- name: "sys_user",
591
+ var SysUser = ObjectSchema.create({
592
+ namespace: "sys",
593
+ name: "user",
587
594
  label: "User",
588
595
  pluralLabel: "Users",
589
596
  icon: "user",
597
+ isSystem: true,
590
598
  description: "User accounts for authentication",
591
599
  titleFormat: "{name} ({email})",
592
600
  compactLayout: ["name", "email", "email_verified"],
593
601
  fields: {
594
- // ID is auto-generated by ObjectQL
595
602
  id: Field.text({
596
603
  label: "User ID",
597
604
  required: true,
@@ -627,12 +634,10 @@ var AuthUser = ObjectSchema.create({
627
634
  required: false
628
635
  })
629
636
  },
630
- // Database indexes for performance
631
637
  indexes: [
632
638
  { fields: ["email"], unique: true },
633
639
  { fields: ["created_at"], unique: false }
634
640
  ],
635
- // Enable features
636
641
  enable: {
637
642
  trackHistory: true,
638
643
  searchable: true,
@@ -641,7 +646,6 @@ var AuthUser = ObjectSchema.create({
641
646
  trash: true,
642
647
  mru: true
643
648
  },
644
- // Validation Rules
645
649
  validations: [
646
650
  {
647
651
  name: "email_unique",
@@ -654,13 +658,15 @@ var AuthUser = ObjectSchema.create({
654
658
  ]
655
659
  });
656
660
 
657
- // src/objects/auth-session.object.ts
661
+ // src/objects/sys-session.object.ts
658
662
  import { ObjectSchema as ObjectSchema2, Field as Field2 } from "@objectstack/spec/data";
659
- var AuthSession = ObjectSchema2.create({
660
- name: "sys_session",
663
+ var SysSession = ObjectSchema2.create({
664
+ namespace: "sys",
665
+ name: "session",
661
666
  label: "Session",
662
667
  pluralLabel: "Sessions",
663
668
  icon: "key",
669
+ isSystem: true,
664
670
  description: "Active user sessions",
665
671
  titleFormat: "Session {token}",
666
672
  compactLayout: ["user_id", "expires_at", "ip_address"],
@@ -703,33 +709,30 @@ var AuthSession = ObjectSchema2.create({
703
709
  required: false
704
710
  })
705
711
  },
706
- // Database indexes for performance
707
712
  indexes: [
708
713
  { fields: ["token"], unique: true },
709
714
  { fields: ["user_id"], unique: false },
710
715
  { fields: ["expires_at"], unique: false }
711
716
  ],
712
- // Enable features
713
717
  enable: {
714
718
  trackHistory: false,
715
- // Sessions don't need history tracking
716
719
  searchable: false,
717
720
  apiEnabled: true,
718
721
  apiMethods: ["get", "list", "create", "delete"],
719
- // No update for sessions
720
722
  trash: false,
721
- // Sessions should be hard deleted
722
723
  mru: false
723
724
  }
724
725
  });
725
726
 
726
- // src/objects/auth-account.object.ts
727
+ // src/objects/sys-account.object.ts
727
728
  import { ObjectSchema as ObjectSchema3, Field as Field3 } from "@objectstack/spec/data";
728
- var AuthAccount = ObjectSchema3.create({
729
- name: "sys_account",
729
+ var SysAccount = ObjectSchema3.create({
730
+ namespace: "sys",
731
+ name: "account",
730
732
  label: "Account",
731
733
  pluralLabel: "Accounts",
732
734
  icon: "link",
735
+ isSystem: true,
733
736
  description: "OAuth and authentication provider accounts",
734
737
  titleFormat: "{provider_id} - {account_id}",
735
738
  compactLayout: ["provider_id", "user_id", "account_id"],
@@ -794,12 +797,10 @@ var AuthAccount = ObjectSchema3.create({
794
797
  description: "Hashed password for email/password provider"
795
798
  })
796
799
  },
797
- // Database indexes for performance
798
800
  indexes: [
799
801
  { fields: ["user_id"], unique: false },
800
802
  { fields: ["provider_id", "account_id"], unique: true }
801
803
  ],
802
- // Enable features
803
804
  enable: {
804
805
  trackHistory: false,
805
806
  searchable: false,
@@ -810,13 +811,15 @@ var AuthAccount = ObjectSchema3.create({
810
811
  }
811
812
  });
812
813
 
813
- // src/objects/auth-verification.object.ts
814
+ // src/objects/sys-verification.object.ts
814
815
  import { ObjectSchema as ObjectSchema4, Field as Field4 } from "@objectstack/spec/data";
815
- var AuthVerification = ObjectSchema4.create({
816
- name: "sys_verification",
816
+ var SysVerification = ObjectSchema4.create({
817
+ namespace: "sys",
818
+ name: "verification",
817
819
  label: "Verification",
818
820
  pluralLabel: "Verifications",
819
821
  icon: "shield-check",
822
+ isSystem: true,
820
823
  description: "Email and phone verification tokens",
821
824
  titleFormat: "Verification for {identifier}",
822
825
  compactLayout: ["identifier", "expires_at", "created_at"],
@@ -851,21 +854,444 @@ var AuthVerification = ObjectSchema4.create({
851
854
  description: "Email address or phone number"
852
855
  })
853
856
  },
854
- // Database indexes for performance
855
857
  indexes: [
856
858
  { fields: ["value"], unique: true },
857
859
  { fields: ["identifier"], unique: false },
858
860
  { fields: ["expires_at"], unique: false }
859
861
  ],
860
- // Enable features
861
862
  enable: {
862
863
  trackHistory: false,
863
864
  searchable: false,
864
865
  apiEnabled: true,
865
866
  apiMethods: ["get", "create", "delete"],
866
- // No list or update
867
867
  trash: false,
868
- // Hard delete expired tokens
868
+ mru: false
869
+ }
870
+ });
871
+
872
+ // src/objects/sys-organization.object.ts
873
+ import { ObjectSchema as ObjectSchema5, Field as Field5 } from "@objectstack/spec/data";
874
+ var SysOrganization = ObjectSchema5.create({
875
+ namespace: "sys",
876
+ name: "organization",
877
+ label: "Organization",
878
+ pluralLabel: "Organizations",
879
+ icon: "building-2",
880
+ isSystem: true,
881
+ description: "Organizations for multi-tenant grouping",
882
+ titleFormat: "{name}",
883
+ compactLayout: ["name", "slug", "created_at"],
884
+ fields: {
885
+ id: Field5.text({
886
+ label: "Organization ID",
887
+ required: true,
888
+ readonly: true
889
+ }),
890
+ created_at: Field5.datetime({
891
+ label: "Created At",
892
+ defaultValue: "NOW()",
893
+ readonly: true
894
+ }),
895
+ updated_at: Field5.datetime({
896
+ label: "Updated At",
897
+ defaultValue: "NOW()",
898
+ readonly: true
899
+ }),
900
+ name: Field5.text({
901
+ label: "Name",
902
+ required: true,
903
+ searchable: true,
904
+ maxLength: 255
905
+ }),
906
+ slug: Field5.text({
907
+ label: "Slug",
908
+ required: false,
909
+ maxLength: 255,
910
+ description: "URL-friendly identifier"
911
+ }),
912
+ logo: Field5.url({
913
+ label: "Logo",
914
+ required: false
915
+ }),
916
+ metadata: Field5.textarea({
917
+ label: "Metadata",
918
+ required: false,
919
+ description: "JSON-serialized organization metadata"
920
+ })
921
+ },
922
+ indexes: [
923
+ { fields: ["slug"], unique: true },
924
+ { fields: ["name"] }
925
+ ],
926
+ enable: {
927
+ trackHistory: true,
928
+ searchable: true,
929
+ apiEnabled: true,
930
+ apiMethods: ["get", "list", "create", "update", "delete"],
931
+ trash: true,
932
+ mru: true
933
+ }
934
+ });
935
+
936
+ // src/objects/sys-member.object.ts
937
+ import { ObjectSchema as ObjectSchema6, Field as Field6 } from "@objectstack/spec/data";
938
+ var SysMember = ObjectSchema6.create({
939
+ namespace: "sys",
940
+ name: "member",
941
+ label: "Member",
942
+ pluralLabel: "Members",
943
+ icon: "user-check",
944
+ isSystem: true,
945
+ description: "Organization membership records",
946
+ titleFormat: "{user_id} in {organization_id}",
947
+ compactLayout: ["user_id", "organization_id", "role"],
948
+ fields: {
949
+ id: Field6.text({
950
+ label: "Member ID",
951
+ required: true,
952
+ readonly: true
953
+ }),
954
+ created_at: Field6.datetime({
955
+ label: "Created At",
956
+ defaultValue: "NOW()",
957
+ readonly: true
958
+ }),
959
+ organization_id: Field6.text({
960
+ label: "Organization ID",
961
+ required: true
962
+ }),
963
+ user_id: Field6.text({
964
+ label: "User ID",
965
+ required: true
966
+ }),
967
+ role: Field6.text({
968
+ label: "Role",
969
+ required: false,
970
+ description: "Member role within the organization (e.g. admin, member)",
971
+ maxLength: 100
972
+ })
973
+ },
974
+ indexes: [
975
+ { fields: ["organization_id", "user_id"], unique: true },
976
+ { fields: ["user_id"] }
977
+ ],
978
+ enable: {
979
+ trackHistory: true,
980
+ searchable: false,
981
+ apiEnabled: true,
982
+ apiMethods: ["get", "list", "create", "update", "delete"],
983
+ trash: false,
984
+ mru: false
985
+ }
986
+ });
987
+
988
+ // src/objects/sys-invitation.object.ts
989
+ import { ObjectSchema as ObjectSchema7, Field as Field7 } from "@objectstack/spec/data";
990
+ var SysInvitation = ObjectSchema7.create({
991
+ namespace: "sys",
992
+ name: "invitation",
993
+ label: "Invitation",
994
+ pluralLabel: "Invitations",
995
+ icon: "mail",
996
+ isSystem: true,
997
+ description: "Organization invitations for user onboarding",
998
+ titleFormat: "Invitation to {organization_id}",
999
+ compactLayout: ["email", "organization_id", "status"],
1000
+ fields: {
1001
+ id: Field7.text({
1002
+ label: "Invitation ID",
1003
+ required: true,
1004
+ readonly: true
1005
+ }),
1006
+ created_at: Field7.datetime({
1007
+ label: "Created At",
1008
+ defaultValue: "NOW()",
1009
+ readonly: true
1010
+ }),
1011
+ organization_id: Field7.text({
1012
+ label: "Organization ID",
1013
+ required: true
1014
+ }),
1015
+ email: Field7.email({
1016
+ label: "Email",
1017
+ required: true,
1018
+ description: "Email address of the invited user"
1019
+ }),
1020
+ role: Field7.text({
1021
+ label: "Role",
1022
+ required: false,
1023
+ maxLength: 100,
1024
+ description: "Role to assign upon acceptance"
1025
+ }),
1026
+ status: Field7.select(["pending", "accepted", "rejected", "expired", "canceled"], {
1027
+ label: "Status",
1028
+ required: true,
1029
+ defaultValue: "pending"
1030
+ }),
1031
+ inviter_id: Field7.text({
1032
+ label: "Inviter ID",
1033
+ required: true,
1034
+ description: "User ID of the person who sent the invitation"
1035
+ }),
1036
+ expires_at: Field7.datetime({
1037
+ label: "Expires At",
1038
+ required: true
1039
+ }),
1040
+ team_id: Field7.text({
1041
+ label: "Team ID",
1042
+ required: false,
1043
+ description: "Optional team to assign upon acceptance"
1044
+ })
1045
+ },
1046
+ indexes: [
1047
+ { fields: ["organization_id"] },
1048
+ { fields: ["email"] },
1049
+ { fields: ["expires_at"] }
1050
+ ],
1051
+ enable: {
1052
+ trackHistory: true,
1053
+ searchable: false,
1054
+ apiEnabled: true,
1055
+ apiMethods: ["get", "list", "create", "update", "delete"],
1056
+ trash: false,
1057
+ mru: false
1058
+ }
1059
+ });
1060
+
1061
+ // src/objects/sys-team.object.ts
1062
+ import { ObjectSchema as ObjectSchema8, Field as Field8 } from "@objectstack/spec/data";
1063
+ var SysTeam = ObjectSchema8.create({
1064
+ namespace: "sys",
1065
+ name: "team",
1066
+ label: "Team",
1067
+ pluralLabel: "Teams",
1068
+ icon: "users",
1069
+ isSystem: true,
1070
+ description: "Teams within organizations for fine-grained grouping",
1071
+ titleFormat: "{name}",
1072
+ compactLayout: ["name", "organization_id", "created_at"],
1073
+ fields: {
1074
+ id: Field8.text({
1075
+ label: "Team ID",
1076
+ required: true,
1077
+ readonly: true
1078
+ }),
1079
+ created_at: Field8.datetime({
1080
+ label: "Created At",
1081
+ defaultValue: "NOW()",
1082
+ readonly: true
1083
+ }),
1084
+ updated_at: Field8.datetime({
1085
+ label: "Updated At",
1086
+ defaultValue: "NOW()",
1087
+ readonly: true
1088
+ }),
1089
+ name: Field8.text({
1090
+ label: "Name",
1091
+ required: true,
1092
+ searchable: true,
1093
+ maxLength: 255
1094
+ }),
1095
+ organization_id: Field8.text({
1096
+ label: "Organization ID",
1097
+ required: true
1098
+ })
1099
+ },
1100
+ indexes: [
1101
+ { fields: ["organization_id"] },
1102
+ { fields: ["name", "organization_id"], unique: true }
1103
+ ],
1104
+ enable: {
1105
+ trackHistory: true,
1106
+ searchable: true,
1107
+ apiEnabled: true,
1108
+ apiMethods: ["get", "list", "create", "update", "delete"],
1109
+ trash: true,
1110
+ mru: false
1111
+ }
1112
+ });
1113
+
1114
+ // src/objects/sys-team-member.object.ts
1115
+ import { ObjectSchema as ObjectSchema9, Field as Field9 } from "@objectstack/spec/data";
1116
+ var SysTeamMember = ObjectSchema9.create({
1117
+ namespace: "sys",
1118
+ name: "team_member",
1119
+ label: "Team Member",
1120
+ pluralLabel: "Team Members",
1121
+ icon: "user-plus",
1122
+ isSystem: true,
1123
+ description: "Team membership records linking users to teams",
1124
+ titleFormat: "{user_id} in {team_id}",
1125
+ compactLayout: ["user_id", "team_id", "created_at"],
1126
+ fields: {
1127
+ id: Field9.text({
1128
+ label: "Team Member ID",
1129
+ required: true,
1130
+ readonly: true
1131
+ }),
1132
+ created_at: Field9.datetime({
1133
+ label: "Created At",
1134
+ defaultValue: "NOW()",
1135
+ readonly: true
1136
+ }),
1137
+ team_id: Field9.text({
1138
+ label: "Team ID",
1139
+ required: true
1140
+ }),
1141
+ user_id: Field9.text({
1142
+ label: "User ID",
1143
+ required: true
1144
+ })
1145
+ },
1146
+ indexes: [
1147
+ { fields: ["team_id", "user_id"], unique: true },
1148
+ { fields: ["user_id"] }
1149
+ ],
1150
+ enable: {
1151
+ trackHistory: true,
1152
+ searchable: false,
1153
+ apiEnabled: true,
1154
+ apiMethods: ["get", "list", "create", "delete"],
1155
+ trash: false,
1156
+ mru: false
1157
+ }
1158
+ });
1159
+
1160
+ // src/objects/sys-api-key.object.ts
1161
+ import { ObjectSchema as ObjectSchema10, Field as Field10 } from "@objectstack/spec/data";
1162
+ var SysApiKey = ObjectSchema10.create({
1163
+ namespace: "sys",
1164
+ name: "api_key",
1165
+ label: "API Key",
1166
+ pluralLabel: "API Keys",
1167
+ icon: "key-round",
1168
+ isSystem: true,
1169
+ description: "API keys for programmatic access",
1170
+ titleFormat: "{name}",
1171
+ compactLayout: ["name", "user_id", "expires_at"],
1172
+ fields: {
1173
+ id: Field10.text({
1174
+ label: "API Key ID",
1175
+ required: true,
1176
+ readonly: true
1177
+ }),
1178
+ created_at: Field10.datetime({
1179
+ label: "Created At",
1180
+ defaultValue: "NOW()",
1181
+ readonly: true
1182
+ }),
1183
+ updated_at: Field10.datetime({
1184
+ label: "Updated At",
1185
+ defaultValue: "NOW()",
1186
+ readonly: true
1187
+ }),
1188
+ name: Field10.text({
1189
+ label: "Name",
1190
+ required: true,
1191
+ maxLength: 255,
1192
+ description: "Human-readable label for the API key"
1193
+ }),
1194
+ key: Field10.text({
1195
+ label: "Key",
1196
+ required: true,
1197
+ description: "Hashed API key value"
1198
+ }),
1199
+ prefix: Field10.text({
1200
+ label: "Prefix",
1201
+ required: false,
1202
+ maxLength: 16,
1203
+ description: 'Visible prefix for identifying the key (e.g., "osk_")'
1204
+ }),
1205
+ user_id: Field10.text({
1206
+ label: "User ID",
1207
+ required: true,
1208
+ description: "Owner user of this API key"
1209
+ }),
1210
+ scopes: Field10.textarea({
1211
+ label: "Scopes",
1212
+ required: false,
1213
+ description: "JSON array of permission scopes"
1214
+ }),
1215
+ expires_at: Field10.datetime({
1216
+ label: "Expires At",
1217
+ required: false
1218
+ }),
1219
+ last_used_at: Field10.datetime({
1220
+ label: "Last Used At",
1221
+ required: false
1222
+ }),
1223
+ revoked: Field10.boolean({
1224
+ label: "Revoked",
1225
+ defaultValue: false
1226
+ })
1227
+ },
1228
+ indexes: [
1229
+ { fields: ["key"], unique: true },
1230
+ { fields: ["user_id"] },
1231
+ { fields: ["prefix"] }
1232
+ ],
1233
+ enable: {
1234
+ trackHistory: true,
1235
+ searchable: false,
1236
+ apiEnabled: true,
1237
+ apiMethods: ["get", "list", "create", "update", "delete"],
1238
+ trash: false,
1239
+ mru: false
1240
+ }
1241
+ });
1242
+
1243
+ // src/objects/sys-two-factor.object.ts
1244
+ import { ObjectSchema as ObjectSchema11, Field as Field11 } from "@objectstack/spec/data";
1245
+ var SysTwoFactor = ObjectSchema11.create({
1246
+ namespace: "sys",
1247
+ name: "two_factor",
1248
+ label: "Two Factor",
1249
+ pluralLabel: "Two Factor Credentials",
1250
+ icon: "smartphone",
1251
+ isSystem: true,
1252
+ description: "Two-factor authentication credentials",
1253
+ titleFormat: "Two-factor for {user_id}",
1254
+ compactLayout: ["user_id", "created_at"],
1255
+ fields: {
1256
+ id: Field11.text({
1257
+ label: "Two Factor ID",
1258
+ required: true,
1259
+ readonly: true
1260
+ }),
1261
+ created_at: Field11.datetime({
1262
+ label: "Created At",
1263
+ defaultValue: "NOW()",
1264
+ readonly: true
1265
+ }),
1266
+ updated_at: Field11.datetime({
1267
+ label: "Updated At",
1268
+ defaultValue: "NOW()",
1269
+ readonly: true
1270
+ }),
1271
+ user_id: Field11.text({
1272
+ label: "User ID",
1273
+ required: true
1274
+ }),
1275
+ secret: Field11.text({
1276
+ label: "Secret",
1277
+ required: true,
1278
+ description: "TOTP secret key"
1279
+ }),
1280
+ backup_codes: Field11.textarea({
1281
+ label: "Backup Codes",
1282
+ required: false,
1283
+ description: "JSON-serialized backup recovery codes"
1284
+ })
1285
+ },
1286
+ indexes: [
1287
+ { fields: ["user_id"], unique: true }
1288
+ ],
1289
+ enable: {
1290
+ trackHistory: false,
1291
+ searchable: false,
1292
+ apiEnabled: true,
1293
+ apiMethods: ["get", "create", "update", "delete"],
1294
+ trash: false,
869
1295
  mru: false
870
1296
  }
871
1297
  });
@@ -883,12 +1309,23 @@ export {
883
1309
  AUTH_TWO_FACTOR_USER_FIELDS,
884
1310
  AUTH_USER_CONFIG,
885
1311
  AUTH_VERIFICATION_CONFIG,
886
- AuthAccount,
1312
+ SysAccount as AuthAccount,
887
1313
  AuthManager,
888
1314
  AuthPlugin,
889
- AuthSession,
890
- AuthUser,
891
- AuthVerification,
1315
+ SysSession as AuthSession,
1316
+ SysUser as AuthUser,
1317
+ SysVerification as AuthVerification,
1318
+ SysAccount,
1319
+ SysApiKey,
1320
+ SysInvitation,
1321
+ SysMember,
1322
+ SysOrganization,
1323
+ SysSession,
1324
+ SysTeam,
1325
+ SysTeamMember,
1326
+ SysTwoFactor,
1327
+ SysUser,
1328
+ SysVerification,
892
1329
  buildOrganizationPluginSchema,
893
1330
  buildTwoFactorPluginSchema,
894
1331
  createObjectQLAdapter,