@objectstack/plugin-auth 3.2.4 → 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/.turbo/turbo-build.log +65 -9
- package/CHANGELOG.md +15 -0
- package/dist/index.d.mts +9994 -51
- package/dist/index.d.ts +9994 -51
- package/dist/index.js +487 -52
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +476 -52
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -4
- package/src/auth-manager.test.ts +39 -0
- package/src/auth-manager.ts +9 -1
- package/src/auth-plugin.ts +5 -22
- package/src/auth-schema-config.ts +6 -6
- package/src/objects/auth-account.object.ts +3 -117
- package/src/objects/auth-session.object.ts +3 -85
- package/src/objects/auth-user.object.ts +3 -93
- package/src/objects/auth-verification.object.ts +3 -74
- package/src/objects/index.ts +30 -4
- package/src/objects/sys-account.object.ts +111 -0
- package/src/objects/sys-api-key.object.ts +104 -0
- package/src/objects/sys-invitation.object.ts +93 -0
- package/src/objects/sys-member.object.ts +68 -0
- package/src/objects/sys-organization.object.ts +82 -0
- package/src/objects/sys-session.object.ts +84 -0
- package/src/objects/sys-team-member.object.ts +61 -0
- package/src/objects/sys-team.object.ts +69 -0
- package/src/objects/sys-two-factor.object.ts +73 -0
- package/src/objects/sys-user.object.ts +91 -0
- package/src/objects/sys-verification.object.ts +75 -0
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
269
|
+
modelName: SystemObjectName2.TWO_FACTOR,
|
|
270
|
+
// 'sys_two_factor'
|
|
265
271
|
fields: {
|
|
266
272
|
backupCodes: "backup_codes",
|
|
267
273
|
userId: "user_id"
|
|
@@ -317,8 +323,7 @@ var AuthManager = class {
|
|
|
317
323
|
// Base configuration
|
|
318
324
|
secret: this.config.secret || this.generateSecret(),
|
|
319
325
|
baseURL: this.config.baseUrl || "http://localhost:3000",
|
|
320
|
-
basePath: "/",
|
|
321
|
-
// ← 关键修复!告诉 better-auth 路径已被剥离
|
|
326
|
+
basePath: this.config.basePath || "/api/v1/auth",
|
|
322
327
|
// Database adapter configuration
|
|
323
328
|
database: this.createDatabaseConfig(),
|
|
324
329
|
// Model/field mapping: camelCase (better-auth) → snake_case (ObjectStack)
|
|
@@ -552,19 +557,7 @@ var AuthPlugin = class {
|
|
|
552
557
|
const rawApp = httpServer.getRawApp();
|
|
553
558
|
rawApp.all(`${basePath}/*`, async (c) => {
|
|
554
559
|
try {
|
|
555
|
-
const
|
|
556
|
-
const url = new URL(request.url);
|
|
557
|
-
const authPath = url.pathname.replace(basePath, "");
|
|
558
|
-
const rewrittenUrl = new URL(authPath || "/", url.origin);
|
|
559
|
-
rewrittenUrl.search = url.search;
|
|
560
|
-
const rewrittenRequest = new Request(rewrittenUrl, {
|
|
561
|
-
method: request.method,
|
|
562
|
-
headers: request.headers,
|
|
563
|
-
body: request.body,
|
|
564
|
-
duplex: "half"
|
|
565
|
-
// Required for Request with body
|
|
566
|
-
});
|
|
567
|
-
const response = await this.authManager.handleRequest(rewrittenRequest);
|
|
560
|
+
const response = await this.authManager.handleRequest(c.req.raw);
|
|
568
561
|
if (response.status >= 500) {
|
|
569
562
|
try {
|
|
570
563
|
const body = await response.clone().text();
|
|
@@ -593,18 +586,19 @@ var AuthPlugin = class {
|
|
|
593
586
|
}
|
|
594
587
|
};
|
|
595
588
|
|
|
596
|
-
// src/objects/
|
|
589
|
+
// src/objects/sys-user.object.ts
|
|
597
590
|
import { ObjectSchema, Field } from "@objectstack/spec/data";
|
|
598
|
-
var
|
|
599
|
-
|
|
591
|
+
var SysUser = ObjectSchema.create({
|
|
592
|
+
namespace: "sys",
|
|
593
|
+
name: "user",
|
|
600
594
|
label: "User",
|
|
601
595
|
pluralLabel: "Users",
|
|
602
596
|
icon: "user",
|
|
597
|
+
isSystem: true,
|
|
603
598
|
description: "User accounts for authentication",
|
|
604
599
|
titleFormat: "{name} ({email})",
|
|
605
600
|
compactLayout: ["name", "email", "email_verified"],
|
|
606
601
|
fields: {
|
|
607
|
-
// ID is auto-generated by ObjectQL
|
|
608
602
|
id: Field.text({
|
|
609
603
|
label: "User ID",
|
|
610
604
|
required: true,
|
|
@@ -640,12 +634,10 @@ var AuthUser = ObjectSchema.create({
|
|
|
640
634
|
required: false
|
|
641
635
|
})
|
|
642
636
|
},
|
|
643
|
-
// Database indexes for performance
|
|
644
637
|
indexes: [
|
|
645
638
|
{ fields: ["email"], unique: true },
|
|
646
639
|
{ fields: ["created_at"], unique: false }
|
|
647
640
|
],
|
|
648
|
-
// Enable features
|
|
649
641
|
enable: {
|
|
650
642
|
trackHistory: true,
|
|
651
643
|
searchable: true,
|
|
@@ -654,7 +646,6 @@ var AuthUser = ObjectSchema.create({
|
|
|
654
646
|
trash: true,
|
|
655
647
|
mru: true
|
|
656
648
|
},
|
|
657
|
-
// Validation Rules
|
|
658
649
|
validations: [
|
|
659
650
|
{
|
|
660
651
|
name: "email_unique",
|
|
@@ -667,13 +658,15 @@ var AuthUser = ObjectSchema.create({
|
|
|
667
658
|
]
|
|
668
659
|
});
|
|
669
660
|
|
|
670
|
-
// src/objects/
|
|
661
|
+
// src/objects/sys-session.object.ts
|
|
671
662
|
import { ObjectSchema as ObjectSchema2, Field as Field2 } from "@objectstack/spec/data";
|
|
672
|
-
var
|
|
673
|
-
|
|
663
|
+
var SysSession = ObjectSchema2.create({
|
|
664
|
+
namespace: "sys",
|
|
665
|
+
name: "session",
|
|
674
666
|
label: "Session",
|
|
675
667
|
pluralLabel: "Sessions",
|
|
676
668
|
icon: "key",
|
|
669
|
+
isSystem: true,
|
|
677
670
|
description: "Active user sessions",
|
|
678
671
|
titleFormat: "Session {token}",
|
|
679
672
|
compactLayout: ["user_id", "expires_at", "ip_address"],
|
|
@@ -716,33 +709,30 @@ var AuthSession = ObjectSchema2.create({
|
|
|
716
709
|
required: false
|
|
717
710
|
})
|
|
718
711
|
},
|
|
719
|
-
// Database indexes for performance
|
|
720
712
|
indexes: [
|
|
721
713
|
{ fields: ["token"], unique: true },
|
|
722
714
|
{ fields: ["user_id"], unique: false },
|
|
723
715
|
{ fields: ["expires_at"], unique: false }
|
|
724
716
|
],
|
|
725
|
-
// Enable features
|
|
726
717
|
enable: {
|
|
727
718
|
trackHistory: false,
|
|
728
|
-
// Sessions don't need history tracking
|
|
729
719
|
searchable: false,
|
|
730
720
|
apiEnabled: true,
|
|
731
721
|
apiMethods: ["get", "list", "create", "delete"],
|
|
732
|
-
// No update for sessions
|
|
733
722
|
trash: false,
|
|
734
|
-
// Sessions should be hard deleted
|
|
735
723
|
mru: false
|
|
736
724
|
}
|
|
737
725
|
});
|
|
738
726
|
|
|
739
|
-
// src/objects/
|
|
727
|
+
// src/objects/sys-account.object.ts
|
|
740
728
|
import { ObjectSchema as ObjectSchema3, Field as Field3 } from "@objectstack/spec/data";
|
|
741
|
-
var
|
|
742
|
-
|
|
729
|
+
var SysAccount = ObjectSchema3.create({
|
|
730
|
+
namespace: "sys",
|
|
731
|
+
name: "account",
|
|
743
732
|
label: "Account",
|
|
744
733
|
pluralLabel: "Accounts",
|
|
745
734
|
icon: "link",
|
|
735
|
+
isSystem: true,
|
|
746
736
|
description: "OAuth and authentication provider accounts",
|
|
747
737
|
titleFormat: "{provider_id} - {account_id}",
|
|
748
738
|
compactLayout: ["provider_id", "user_id", "account_id"],
|
|
@@ -807,12 +797,10 @@ var AuthAccount = ObjectSchema3.create({
|
|
|
807
797
|
description: "Hashed password for email/password provider"
|
|
808
798
|
})
|
|
809
799
|
},
|
|
810
|
-
// Database indexes for performance
|
|
811
800
|
indexes: [
|
|
812
801
|
{ fields: ["user_id"], unique: false },
|
|
813
802
|
{ fields: ["provider_id", "account_id"], unique: true }
|
|
814
803
|
],
|
|
815
|
-
// Enable features
|
|
816
804
|
enable: {
|
|
817
805
|
trackHistory: false,
|
|
818
806
|
searchable: false,
|
|
@@ -823,13 +811,15 @@ var AuthAccount = ObjectSchema3.create({
|
|
|
823
811
|
}
|
|
824
812
|
});
|
|
825
813
|
|
|
826
|
-
// src/objects/
|
|
814
|
+
// src/objects/sys-verification.object.ts
|
|
827
815
|
import { ObjectSchema as ObjectSchema4, Field as Field4 } from "@objectstack/spec/data";
|
|
828
|
-
var
|
|
829
|
-
|
|
816
|
+
var SysVerification = ObjectSchema4.create({
|
|
817
|
+
namespace: "sys",
|
|
818
|
+
name: "verification",
|
|
830
819
|
label: "Verification",
|
|
831
820
|
pluralLabel: "Verifications",
|
|
832
821
|
icon: "shield-check",
|
|
822
|
+
isSystem: true,
|
|
833
823
|
description: "Email and phone verification tokens",
|
|
834
824
|
titleFormat: "Verification for {identifier}",
|
|
835
825
|
compactLayout: ["identifier", "expires_at", "created_at"],
|
|
@@ -864,21 +854,444 @@ var AuthVerification = ObjectSchema4.create({
|
|
|
864
854
|
description: "Email address or phone number"
|
|
865
855
|
})
|
|
866
856
|
},
|
|
867
|
-
// Database indexes for performance
|
|
868
857
|
indexes: [
|
|
869
858
|
{ fields: ["value"], unique: true },
|
|
870
859
|
{ fields: ["identifier"], unique: false },
|
|
871
860
|
{ fields: ["expires_at"], unique: false }
|
|
872
861
|
],
|
|
873
|
-
// Enable features
|
|
874
862
|
enable: {
|
|
875
863
|
trackHistory: false,
|
|
876
864
|
searchable: false,
|
|
877
865
|
apiEnabled: true,
|
|
878
866
|
apiMethods: ["get", "create", "delete"],
|
|
879
|
-
// No list or update
|
|
880
867
|
trash: false,
|
|
881
|
-
|
|
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,
|
|
882
1295
|
mru: false
|
|
883
1296
|
}
|
|
884
1297
|
});
|
|
@@ -896,12 +1309,23 @@ export {
|
|
|
896
1309
|
AUTH_TWO_FACTOR_USER_FIELDS,
|
|
897
1310
|
AUTH_USER_CONFIG,
|
|
898
1311
|
AUTH_VERIFICATION_CONFIG,
|
|
899
|
-
AuthAccount,
|
|
1312
|
+
SysAccount as AuthAccount,
|
|
900
1313
|
AuthManager,
|
|
901
1314
|
AuthPlugin,
|
|
902
|
-
AuthSession,
|
|
903
|
-
AuthUser,
|
|
904
|
-
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,
|
|
905
1329
|
buildOrganizationPluginSchema,
|
|
906
1330
|
buildTwoFactorPluginSchema,
|
|
907
1331
|
createObjectQLAdapter,
|