@contractspec/lib.identity-rbac 1.57.0 → 1.58.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.
- package/dist/browser/contracts/index.js +1045 -0
- package/dist/browser/contracts/organization.js +655 -0
- package/dist/browser/contracts/rbac.js +599 -0
- package/dist/browser/contracts/user.js +235 -0
- package/dist/browser/entities/index.js +464 -0
- package/dist/browser/entities/organization.js +150 -0
- package/dist/browser/entities/rbac.js +124 -0
- package/dist/browser/entities/user.js +168 -0
- package/dist/browser/events.js +374 -0
- package/dist/browser/identity-rbac.capability.js +28 -0
- package/dist/browser/identity-rbac.feature.js +67 -0
- package/dist/browser/index.js +2099 -0
- package/dist/browser/policies/engine.js +154 -0
- package/dist/browser/policies/index.js +154 -0
- package/dist/contracts/index.d.ts +4 -4
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +1045 -4
- package/dist/contracts/organization.d.ts +758 -764
- package/dist/contracts/organization.d.ts.map +1 -1
- package/dist/contracts/organization.js +653 -602
- package/dist/contracts/rbac.d.ts +517 -523
- package/dist/contracts/rbac.d.ts.map +1 -1
- package/dist/contracts/rbac.js +597 -481
- package/dist/contracts/user.d.ts +513 -519
- package/dist/contracts/user.d.ts.map +1 -1
- package/dist/contracts/user.js +222 -319
- package/dist/entities/index.d.ts +164 -169
- package/dist/entities/index.d.ts.map +1 -1
- package/dist/entities/index.js +462 -33
- package/dist/entities/organization.d.ts +58 -63
- package/dist/entities/organization.d.ts.map +1 -1
- package/dist/entities/organization.js +145 -145
- package/dist/entities/rbac.d.ts +62 -67
- package/dist/entities/rbac.d.ts.map +1 -1
- package/dist/entities/rbac.js +119 -132
- package/dist/entities/user.d.ts +66 -71
- package/dist/entities/user.d.ts.map +1 -1
- package/dist/entities/user.js +164 -189
- package/dist/events.d.ts +537 -543
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +343 -651
- package/dist/identity-rbac.capability.d.ts +2 -7
- package/dist/identity-rbac.capability.d.ts.map +1 -1
- package/dist/identity-rbac.capability.js +29 -29
- package/dist/identity-rbac.feature.d.ts +1 -6
- package/dist/identity-rbac.feature.d.ts.map +1 -1
- package/dist/identity-rbac.feature.js +66 -193
- package/dist/index.d.ts +6 -12
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2100 -14
- package/dist/node/contracts/index.js +1045 -0
- package/dist/node/contracts/organization.js +655 -0
- package/dist/node/contracts/rbac.js +599 -0
- package/dist/node/contracts/user.js +235 -0
- package/dist/node/entities/index.js +464 -0
- package/dist/node/entities/organization.js +150 -0
- package/dist/node/entities/rbac.js +124 -0
- package/dist/node/entities/user.js +168 -0
- package/dist/node/events.js +374 -0
- package/dist/node/identity-rbac.capability.js +28 -0
- package/dist/node/identity-rbac.feature.js +67 -0
- package/dist/node/index.js +2099 -0
- package/dist/node/policies/engine.js +154 -0
- package/dist/node/policies/index.js +154 -0
- package/dist/policies/engine.d.ts +98 -101
- package/dist/policies/engine.d.ts.map +1 -1
- package/dist/policies/engine.js +151 -164
- package/dist/policies/index.d.ts +2 -2
- package/dist/policies/index.d.ts.map +1 -0
- package/dist/policies/index.js +154 -2
- package/package.json +149 -40
- package/dist/contracts/organization.js.map +0 -1
- package/dist/contracts/rbac.js.map +0 -1
- package/dist/contracts/user.js.map +0 -1
- package/dist/entities/index.js.map +0 -1
- package/dist/entities/organization.js.map +0 -1
- package/dist/entities/rbac.js.map +0 -1
- package/dist/entities/user.js.map +0 -1
- package/dist/events.js.map +0 -1
- package/dist/identity-rbac.capability.js.map +0 -1
- package/dist/identity-rbac.feature.js.map +0 -1
- package/dist/policies/engine.js.map +0 -1
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// src/entities/organization.ts
|
|
2
|
+
import {
|
|
3
|
+
defineEntity,
|
|
4
|
+
defineEntityEnum,
|
|
5
|
+
field,
|
|
6
|
+
index
|
|
7
|
+
} from "@contractspec/lib.schema";
|
|
8
|
+
var OrganizationTypeEnum = defineEntityEnum({
|
|
9
|
+
name: "OrganizationType",
|
|
10
|
+
values: ["PLATFORM_ADMIN", "CONTRACT_SPEC_CUSTOMER"],
|
|
11
|
+
schema: "lssm_sigil",
|
|
12
|
+
description: "Type of organization in the platform."
|
|
13
|
+
});
|
|
14
|
+
var OrganizationEntity = defineEntity({
|
|
15
|
+
name: "Organization",
|
|
16
|
+
description: "An organization is a tenant boundary grouping users.",
|
|
17
|
+
schema: "lssm_sigil",
|
|
18
|
+
map: "organization",
|
|
19
|
+
fields: {
|
|
20
|
+
id: field.id({ description: "Unique organization identifier" }),
|
|
21
|
+
name: field.string({ description: "Organization display name" }),
|
|
22
|
+
slug: field.string({
|
|
23
|
+
isOptional: true,
|
|
24
|
+
isUnique: true,
|
|
25
|
+
description: "URL-friendly identifier"
|
|
26
|
+
}),
|
|
27
|
+
logo: field.url({ isOptional: true, description: "Organization logo URL" }),
|
|
28
|
+
description: field.string({
|
|
29
|
+
isOptional: true,
|
|
30
|
+
description: "Organization description"
|
|
31
|
+
}),
|
|
32
|
+
metadata: field.json({
|
|
33
|
+
isOptional: true,
|
|
34
|
+
description: "Arbitrary organization metadata"
|
|
35
|
+
}),
|
|
36
|
+
type: field.enum("OrganizationType", { description: "Organization type" }),
|
|
37
|
+
onboardingCompleted: field.boolean({ default: false }),
|
|
38
|
+
onboardingStep: field.string({ isOptional: true }),
|
|
39
|
+
referralCode: field.string({
|
|
40
|
+
isOptional: true,
|
|
41
|
+
isUnique: true,
|
|
42
|
+
description: "Unique referral code"
|
|
43
|
+
}),
|
|
44
|
+
referredBy: field.string({
|
|
45
|
+
isOptional: true,
|
|
46
|
+
description: "ID of referring user"
|
|
47
|
+
}),
|
|
48
|
+
createdAt: field.createdAt(),
|
|
49
|
+
updatedAt: field.updatedAt(),
|
|
50
|
+
members: field.hasMany("Member"),
|
|
51
|
+
invitations: field.hasMany("Invitation"),
|
|
52
|
+
teams: field.hasMany("Team"),
|
|
53
|
+
policyBindings: field.hasMany("PolicyBinding")
|
|
54
|
+
},
|
|
55
|
+
enums: [OrganizationTypeEnum]
|
|
56
|
+
});
|
|
57
|
+
var MemberEntity = defineEntity({
|
|
58
|
+
name: "Member",
|
|
59
|
+
description: "Membership of a user in an organization with a role.",
|
|
60
|
+
schema: "lssm_sigil",
|
|
61
|
+
map: "member",
|
|
62
|
+
fields: {
|
|
63
|
+
id: field.id(),
|
|
64
|
+
userId: field.foreignKey(),
|
|
65
|
+
organizationId: field.foreignKey(),
|
|
66
|
+
role: field.string({
|
|
67
|
+
description: "Role in organization (owner, admin, member)"
|
|
68
|
+
}),
|
|
69
|
+
createdAt: field.createdAt(),
|
|
70
|
+
user: field.belongsTo("User", ["userId"], ["id"], { onDelete: "Cascade" }),
|
|
71
|
+
organization: field.belongsTo("Organization", ["organizationId"], ["id"], {
|
|
72
|
+
onDelete: "Cascade"
|
|
73
|
+
})
|
|
74
|
+
},
|
|
75
|
+
indexes: [index.unique(["userId", "organizationId"])]
|
|
76
|
+
});
|
|
77
|
+
var InvitationEntity = defineEntity({
|
|
78
|
+
name: "Invitation",
|
|
79
|
+
description: "An invitation to join an organization.",
|
|
80
|
+
schema: "lssm_sigil",
|
|
81
|
+
map: "invitation",
|
|
82
|
+
fields: {
|
|
83
|
+
id: field.id(),
|
|
84
|
+
organizationId: field.foreignKey(),
|
|
85
|
+
email: field.email({ description: "Invited email address" }),
|
|
86
|
+
role: field.string({
|
|
87
|
+
isOptional: true,
|
|
88
|
+
description: "Role to assign on acceptance"
|
|
89
|
+
}),
|
|
90
|
+
status: field.string({
|
|
91
|
+
default: '"pending"',
|
|
92
|
+
description: "Invitation status"
|
|
93
|
+
}),
|
|
94
|
+
acceptedAt: field.dateTime({ isOptional: true }),
|
|
95
|
+
expiresAt: field.dateTime({ isOptional: true }),
|
|
96
|
+
inviterId: field.foreignKey({
|
|
97
|
+
description: "User who sent the invitation"
|
|
98
|
+
}),
|
|
99
|
+
teamId: field.string({ isOptional: true }),
|
|
100
|
+
createdAt: field.createdAt(),
|
|
101
|
+
updatedAt: field.updatedAt(),
|
|
102
|
+
organization: field.belongsTo("Organization", ["organizationId"], ["id"], {
|
|
103
|
+
onDelete: "Cascade"
|
|
104
|
+
}),
|
|
105
|
+
inviter: field.belongsTo("User", ["inviterId"], ["id"], {
|
|
106
|
+
onDelete: "Cascade"
|
|
107
|
+
}),
|
|
108
|
+
team: field.belongsTo("Team", ["teamId"], ["id"], { onDelete: "Cascade" })
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
var TeamEntity = defineEntity({
|
|
112
|
+
name: "Team",
|
|
113
|
+
description: "Team within an organization.",
|
|
114
|
+
schema: "lssm_sigil",
|
|
115
|
+
map: "team",
|
|
116
|
+
fields: {
|
|
117
|
+
id: field.id(),
|
|
118
|
+
name: field.string({ description: "Team name" }),
|
|
119
|
+
organizationId: field.foreignKey(),
|
|
120
|
+
createdAt: field.createdAt(),
|
|
121
|
+
updatedAt: field.updatedAt(),
|
|
122
|
+
organization: field.belongsTo("Organization", ["organizationId"], ["id"], {
|
|
123
|
+
onDelete: "Cascade"
|
|
124
|
+
}),
|
|
125
|
+
members: field.hasMany("TeamMember"),
|
|
126
|
+
invitations: field.hasMany("Invitation")
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
var TeamMemberEntity = defineEntity({
|
|
130
|
+
name: "TeamMember",
|
|
131
|
+
description: "Team membership for a user.",
|
|
132
|
+
schema: "lssm_sigil",
|
|
133
|
+
map: "team_member",
|
|
134
|
+
fields: {
|
|
135
|
+
id: field.id(),
|
|
136
|
+
teamId: field.foreignKey(),
|
|
137
|
+
userId: field.foreignKey(),
|
|
138
|
+
createdAt: field.createdAt(),
|
|
139
|
+
team: field.belongsTo("Team", ["teamId"], ["id"], { onDelete: "Cascade" }),
|
|
140
|
+
user: field.belongsTo("User", ["userId"], ["id"], { onDelete: "Cascade" })
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
export {
|
|
144
|
+
TeamMemberEntity,
|
|
145
|
+
TeamEntity,
|
|
146
|
+
OrganizationTypeEnum,
|
|
147
|
+
OrganizationEntity,
|
|
148
|
+
MemberEntity,
|
|
149
|
+
InvitationEntity
|
|
150
|
+
};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// src/entities/rbac.ts
|
|
2
|
+
import { defineEntity, field, index } from "@contractspec/lib.schema";
|
|
3
|
+
var RoleEntity = defineEntity({
|
|
4
|
+
name: "Role",
|
|
5
|
+
description: "A role defines a named set of permissions.",
|
|
6
|
+
schema: "lssm_sigil",
|
|
7
|
+
map: "role",
|
|
8
|
+
fields: {
|
|
9
|
+
id: field.id(),
|
|
10
|
+
name: field.string({ isUnique: true, description: "Unique role name" }),
|
|
11
|
+
description: field.string({
|
|
12
|
+
isOptional: true,
|
|
13
|
+
description: "Role description"
|
|
14
|
+
}),
|
|
15
|
+
permissions: field.string({
|
|
16
|
+
isArray: true,
|
|
17
|
+
description: "Array of permission names"
|
|
18
|
+
}),
|
|
19
|
+
createdAt: field.createdAt(),
|
|
20
|
+
updatedAt: field.updatedAt(),
|
|
21
|
+
policyBindings: field.hasMany("PolicyBinding")
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
var PermissionEntity = defineEntity({
|
|
25
|
+
name: "Permission",
|
|
26
|
+
description: "A permission represents an atomic access right.",
|
|
27
|
+
schema: "lssm_sigil",
|
|
28
|
+
map: "permission",
|
|
29
|
+
fields: {
|
|
30
|
+
id: field.id(),
|
|
31
|
+
name: field.string({
|
|
32
|
+
isUnique: true,
|
|
33
|
+
description: "Unique permission name"
|
|
34
|
+
}),
|
|
35
|
+
description: field.string({
|
|
36
|
+
isOptional: true,
|
|
37
|
+
description: "Permission description"
|
|
38
|
+
}),
|
|
39
|
+
createdAt: field.createdAt(),
|
|
40
|
+
updatedAt: field.updatedAt()
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
var PolicyBindingEntity = defineEntity({
|
|
44
|
+
name: "PolicyBinding",
|
|
45
|
+
description: "Binds roles to principals (users or organizations).",
|
|
46
|
+
schema: "lssm_sigil",
|
|
47
|
+
map: "policy_binding",
|
|
48
|
+
fields: {
|
|
49
|
+
id: field.id(),
|
|
50
|
+
roleId: field.foreignKey(),
|
|
51
|
+
targetType: field.string({ description: '"user" or "organization"' }),
|
|
52
|
+
targetId: field.string({ description: "ID of User or Organization" }),
|
|
53
|
+
expiresAt: field.dateTime({
|
|
54
|
+
isOptional: true,
|
|
55
|
+
description: "When binding expires"
|
|
56
|
+
}),
|
|
57
|
+
createdAt: field.createdAt(),
|
|
58
|
+
userId: field.string({ isOptional: true }),
|
|
59
|
+
organizationId: field.string({ isOptional: true }),
|
|
60
|
+
role: field.belongsTo("Role", ["roleId"], ["id"], { onDelete: "Cascade" }),
|
|
61
|
+
user: field.belongsTo("User", ["userId"], ["id"]),
|
|
62
|
+
organization: field.belongsTo("Organization", ["organizationId"], ["id"])
|
|
63
|
+
},
|
|
64
|
+
indexes: [index.on(["targetType", "targetId"])]
|
|
65
|
+
});
|
|
66
|
+
var ApiKeyEntity = defineEntity({
|
|
67
|
+
name: "ApiKey",
|
|
68
|
+
description: "API keys for programmatic access.",
|
|
69
|
+
schema: "lssm_sigil",
|
|
70
|
+
map: "api_key",
|
|
71
|
+
fields: {
|
|
72
|
+
id: field.id(),
|
|
73
|
+
name: field.string({ description: "API key name" }),
|
|
74
|
+
start: field.string({
|
|
75
|
+
description: "Starting characters for identification"
|
|
76
|
+
}),
|
|
77
|
+
prefix: field.string({ description: "API key prefix" }),
|
|
78
|
+
key: field.string({ description: "Hashed API key" }),
|
|
79
|
+
userId: field.foreignKey(),
|
|
80
|
+
refillInterval: field.int({ description: "Refill interval in ms" }),
|
|
81
|
+
refillAmount: field.int({ description: "Amount to refill" }),
|
|
82
|
+
lastRefillAt: field.dateTime(),
|
|
83
|
+
remaining: field.int({ description: "Remaining requests" }),
|
|
84
|
+
requestCount: field.int({ description: "Total requests made" }),
|
|
85
|
+
lastRequest: field.dateTime(),
|
|
86
|
+
enabled: field.boolean({ default: true }),
|
|
87
|
+
rateLimitEnabled: field.boolean({ default: true }),
|
|
88
|
+
rateLimitTimeWindow: field.int({ description: "Rate limit window in ms" }),
|
|
89
|
+
rateLimitMax: field.int({ description: "Max requests in window" }),
|
|
90
|
+
expiresAt: field.dateTime(),
|
|
91
|
+
permissions: field.string({ isArray: true }),
|
|
92
|
+
metadata: field.json({ isOptional: true }),
|
|
93
|
+
createdAt: field.createdAt(),
|
|
94
|
+
updatedAt: field.updatedAt(),
|
|
95
|
+
user: field.belongsTo("User", ["userId"], ["id"], { onDelete: "Cascade" })
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
var PasskeyEntity = defineEntity({
|
|
99
|
+
name: "Passkey",
|
|
100
|
+
description: "WebAuthn passkeys for passwordless authentication.",
|
|
101
|
+
schema: "lssm_sigil",
|
|
102
|
+
map: "passkey",
|
|
103
|
+
fields: {
|
|
104
|
+
id: field.id(),
|
|
105
|
+
name: field.string({ description: "Passkey name" }),
|
|
106
|
+
publicKey: field.string({ description: "Public key" }),
|
|
107
|
+
userId: field.foreignKey(),
|
|
108
|
+
credentialID: field.string({ description: "Credential ID" }),
|
|
109
|
+
counter: field.int({ description: "Counter" }),
|
|
110
|
+
deviceType: field.string({ description: "Device type" }),
|
|
111
|
+
backedUp: field.boolean({ description: "Whether passkey is backed up" }),
|
|
112
|
+
transports: field.string({ description: "Transports" }),
|
|
113
|
+
aaguid: field.string({ description: "Authenticator GUID" }),
|
|
114
|
+
createdAt: field.createdAt(),
|
|
115
|
+
user: field.belongsTo("User", ["userId"], ["id"], { onDelete: "Cascade" })
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
export {
|
|
119
|
+
RoleEntity,
|
|
120
|
+
PolicyBindingEntity,
|
|
121
|
+
PermissionEntity,
|
|
122
|
+
PasskeyEntity,
|
|
123
|
+
ApiKeyEntity
|
|
124
|
+
};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
// src/entities/user.ts
|
|
2
|
+
import { defineEntity, field, index } from "@contractspec/lib.schema";
|
|
3
|
+
var UserEntity = defineEntity({
|
|
4
|
+
name: "User",
|
|
5
|
+
description: "A user of the platform. Users hold core profile information and authenticate via Account records.",
|
|
6
|
+
schema: "lssm_sigil",
|
|
7
|
+
map: "user",
|
|
8
|
+
fields: {
|
|
9
|
+
id: field.id({ description: "Unique user identifier" }),
|
|
10
|
+
email: field.email({ isUnique: true, description: "User email address" }),
|
|
11
|
+
emailVerified: field.boolean({
|
|
12
|
+
default: false,
|
|
13
|
+
description: "Whether email has been verified"
|
|
14
|
+
}),
|
|
15
|
+
name: field.string({ isOptional: true, description: "Display name" }),
|
|
16
|
+
firstName: field.string({ isOptional: true, description: "First name" }),
|
|
17
|
+
lastName: field.string({ isOptional: true, description: "Last name" }),
|
|
18
|
+
locale: field.string({
|
|
19
|
+
isOptional: true,
|
|
20
|
+
description: 'User locale (e.g., "en-US")'
|
|
21
|
+
}),
|
|
22
|
+
timezone: field.string({
|
|
23
|
+
isOptional: true,
|
|
24
|
+
description: 'Olson timezone (e.g., "Europe/Paris")'
|
|
25
|
+
}),
|
|
26
|
+
imageUrl: field.url({
|
|
27
|
+
isOptional: true,
|
|
28
|
+
description: "URL of avatar or profile picture"
|
|
29
|
+
}),
|
|
30
|
+
image: field.string({
|
|
31
|
+
isOptional: true,
|
|
32
|
+
description: "Legacy image field"
|
|
33
|
+
}),
|
|
34
|
+
metadata: field.json({
|
|
35
|
+
isOptional: true,
|
|
36
|
+
description: "Arbitrary user metadata"
|
|
37
|
+
}),
|
|
38
|
+
onboardingCompleted: field.boolean({
|
|
39
|
+
default: false,
|
|
40
|
+
description: "Whether onboarding is complete"
|
|
41
|
+
}),
|
|
42
|
+
onboardingStep: field.string({
|
|
43
|
+
isOptional: true,
|
|
44
|
+
description: "Current onboarding step"
|
|
45
|
+
}),
|
|
46
|
+
whitelistedAt: field.dateTime({
|
|
47
|
+
isOptional: true,
|
|
48
|
+
description: "When user was whitelisted"
|
|
49
|
+
}),
|
|
50
|
+
role: field.string({
|
|
51
|
+
isOptional: true,
|
|
52
|
+
default: '"user"',
|
|
53
|
+
description: "User role (user, admin)"
|
|
54
|
+
}),
|
|
55
|
+
banned: field.boolean({
|
|
56
|
+
default: false,
|
|
57
|
+
description: "Whether user is banned"
|
|
58
|
+
}),
|
|
59
|
+
banReason: field.string({
|
|
60
|
+
isOptional: true,
|
|
61
|
+
description: "Reason for ban"
|
|
62
|
+
}),
|
|
63
|
+
banExpires: field.dateTime({
|
|
64
|
+
isOptional: true,
|
|
65
|
+
description: "When ban expires"
|
|
66
|
+
}),
|
|
67
|
+
phoneNumber: field.string({
|
|
68
|
+
isOptional: true,
|
|
69
|
+
isUnique: true,
|
|
70
|
+
description: "Phone number"
|
|
71
|
+
}),
|
|
72
|
+
phoneNumberVerified: field.boolean({
|
|
73
|
+
default: false,
|
|
74
|
+
description: "Whether phone is verified"
|
|
75
|
+
}),
|
|
76
|
+
createdAt: field.createdAt(),
|
|
77
|
+
updatedAt: field.updatedAt(),
|
|
78
|
+
sessions: field.hasMany("Session"),
|
|
79
|
+
accounts: field.hasMany("Account"),
|
|
80
|
+
memberships: field.hasMany("Member"),
|
|
81
|
+
invitations: field.hasMany("Invitation"),
|
|
82
|
+
teamMemberships: field.hasMany("TeamMember"),
|
|
83
|
+
policyBindings: field.hasMany("PolicyBinding"),
|
|
84
|
+
apiKeys: field.hasMany("ApiKey"),
|
|
85
|
+
passkeys: field.hasMany("Passkey")
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
var SessionEntity = defineEntity({
|
|
89
|
+
name: "Session",
|
|
90
|
+
description: "Represents a login session (e.g., web session or API token).",
|
|
91
|
+
schema: "lssm_sigil",
|
|
92
|
+
map: "session",
|
|
93
|
+
fields: {
|
|
94
|
+
id: field.id(),
|
|
95
|
+
userId: field.foreignKey(),
|
|
96
|
+
expiresAt: field.dateTime({ description: "Session expiration time" }),
|
|
97
|
+
token: field.string({ isUnique: true, description: "Session token" }),
|
|
98
|
+
ipAddress: field.string({
|
|
99
|
+
isOptional: true,
|
|
100
|
+
description: "Client IP address"
|
|
101
|
+
}),
|
|
102
|
+
userAgent: field.string({
|
|
103
|
+
isOptional: true,
|
|
104
|
+
description: "Client user agent"
|
|
105
|
+
}),
|
|
106
|
+
impersonatedBy: field.string({
|
|
107
|
+
isOptional: true,
|
|
108
|
+
description: "Admin impersonating this session"
|
|
109
|
+
}),
|
|
110
|
+
activeOrganizationId: field.string({
|
|
111
|
+
isOptional: true,
|
|
112
|
+
description: "Active org context"
|
|
113
|
+
}),
|
|
114
|
+
activeTeamId: field.string({
|
|
115
|
+
isOptional: true,
|
|
116
|
+
description: "Active team context"
|
|
117
|
+
}),
|
|
118
|
+
createdAt: field.createdAt(),
|
|
119
|
+
updatedAt: field.updatedAt(),
|
|
120
|
+
user: field.belongsTo("User", ["userId"], ["id"], { onDelete: "Cascade" })
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
var AccountEntity = defineEntity({
|
|
124
|
+
name: "Account",
|
|
125
|
+
description: "External authentication accounts (OAuth, password, etc.).",
|
|
126
|
+
schema: "lssm_sigil",
|
|
127
|
+
map: "account",
|
|
128
|
+
fields: {
|
|
129
|
+
id: field.id(),
|
|
130
|
+
accountId: field.string({ description: "Account ID from provider" }),
|
|
131
|
+
providerId: field.string({ description: "Provider identifier" }),
|
|
132
|
+
userId: field.foreignKey(),
|
|
133
|
+
accessToken: field.string({ isOptional: true }),
|
|
134
|
+
refreshToken: field.string({ isOptional: true }),
|
|
135
|
+
idToken: field.string({ isOptional: true }),
|
|
136
|
+
accessTokenExpiresAt: field.dateTime({ isOptional: true }),
|
|
137
|
+
refreshTokenExpiresAt: field.dateTime({ isOptional: true }),
|
|
138
|
+
scope: field.string({ isOptional: true }),
|
|
139
|
+
password: field.string({
|
|
140
|
+
isOptional: true,
|
|
141
|
+
description: "Hashed password for password providers"
|
|
142
|
+
}),
|
|
143
|
+
createdAt: field.createdAt(),
|
|
144
|
+
updatedAt: field.updatedAt(),
|
|
145
|
+
user: field.belongsTo("User", ["userId"], ["id"], { onDelete: "Cascade" })
|
|
146
|
+
},
|
|
147
|
+
indexes: [index.unique(["accountId", "providerId"])]
|
|
148
|
+
});
|
|
149
|
+
var VerificationEntity = defineEntity({
|
|
150
|
+
name: "Verification",
|
|
151
|
+
description: "Verification tokens for email/phone confirmation.",
|
|
152
|
+
schema: "lssm_sigil",
|
|
153
|
+
map: "verification",
|
|
154
|
+
fields: {
|
|
155
|
+
id: field.uuid(),
|
|
156
|
+
identifier: field.string({ description: "Email or phone being verified" }),
|
|
157
|
+
value: field.string({ description: "Verification code/token" }),
|
|
158
|
+
expiresAt: field.dateTime({ description: "Token expiration" }),
|
|
159
|
+
createdAt: field.createdAt(),
|
|
160
|
+
updatedAt: field.updatedAt()
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
export {
|
|
164
|
+
VerificationEntity,
|
|
165
|
+
UserEntity,
|
|
166
|
+
SessionEntity,
|
|
167
|
+
AccountEntity
|
|
168
|
+
};
|