@nest-boot/auth 8.0.2 → 8.0.3-beta.1
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/README.md +48 -0
- package/dist/abilities/index.d.ts +2 -0
- package/dist/abilities/index.js +3 -0
- package/dist/abilities/index.js.map +1 -0
- package/dist/abilities/user.ability.d.ts +5 -0
- package/dist/abilities/user.ability.js +11 -0
- package/dist/abilities/user.ability.js.map +1 -0
- package/dist/abilities/workspace.ability.d.ts +5 -0
- package/dist/abilities/workspace.ability.js +11 -0
- package/dist/abilities/workspace.ability.js.map +1 -0
- package/dist/access-control.service.d.ts +18 -0
- package/dist/access-control.service.js +153 -0
- package/dist/access-control.service.js.map +1 -0
- package/dist/adapters/mikro-orm/adapter-config.d.ts +13 -0
- package/dist/adapters/mikro-orm/adapter-config.js +15 -0
- package/dist/adapters/mikro-orm/adapter-config.js.map +1 -0
- package/dist/adapters/mikro-orm/create-custom-adapter.d.ts +10 -0
- package/dist/adapters/mikro-orm/create-custom-adapter.js +97 -0
- package/dist/adapters/mikro-orm/create-custom-adapter.js.map +1 -0
- package/dist/adapters/mikro-orm/entity-metadata-resolver.d.ts +14 -0
- package/dist/adapters/mikro-orm/entity-metadata-resolver.js +68 -0
- package/dist/adapters/mikro-orm/entity-metadata-resolver.js.map +1 -0
- package/dist/adapters/mikro-orm/where-compiler.d.ts +156 -0
- package/dist/adapters/mikro-orm/where-compiler.js +69 -0
- package/dist/adapters/mikro-orm/where-compiler.js.map +1 -0
- package/dist/adapters/mikro-orm-adapter.d.ts +8 -11
- package/dist/adapters/mikro-orm-adapter.js +33 -162
- package/dist/adapters/mikro-orm-adapter.js.map +1 -1
- package/dist/api-key-usage.interceptor.d.ts +8 -0
- package/dist/api-key-usage.interceptor.js +35 -0
- package/dist/api-key-usage.interceptor.js.map +1 -0
- package/dist/api-key.service.d.ts +75 -0
- package/dist/api-key.service.js +332 -0
- package/dist/api-key.service.js.map +1 -0
- package/dist/auth-handler.middleware.d.ts +7 -0
- package/dist/auth-handler.middleware.js +31 -0
- package/dist/auth-handler.middleware.js.map +1 -0
- package/dist/auth-module-options.interface.d.ts +341 -6
- package/dist/auth.guard.d.ts +36 -4
- package/dist/auth.guard.js +297 -7
- package/dist/auth.guard.js.map +1 -1
- package/dist/auth.middleware.d.ts +17 -6
- package/dist/auth.middleware.js +114 -42
- package/dist/auth.middleware.js.map +1 -1
- package/dist/auth.module-definition.d.ts +1 -1
- package/dist/auth.module.d.ts +10 -7
- package/dist/auth.module.js +157 -44
- package/dist/auth.module.js.map +1 -1
- package/dist/auth.service.d.ts +24 -1857
- package/dist/auth.service.js +174 -4
- package/dist/auth.service.js.map +1 -1
- package/dist/decorators/can.decorator.d.ts +6 -0
- package/dist/decorators/can.decorator.js +8 -0
- package/dist/decorators/can.decorator.js.map +1 -0
- package/dist/decorators/current-api-key.decorator.d.ts +1 -0
- package/dist/decorators/current-api-key.decorator.js +5 -0
- package/dist/decorators/current-api-key.decorator.js.map +1 -0
- package/dist/decorators/current-workspace-member.decorator.d.ts +1 -0
- package/dist/decorators/current-workspace-member.decorator.js +5 -0
- package/dist/decorators/current-workspace-member.decorator.js.map +1 -0
- package/dist/decorators/current-workspace.decorator.d.ts +1 -0
- package/dist/decorators/current-workspace.decorator.js +5 -0
- package/dist/decorators/current-workspace.decorator.js.map +1 -0
- package/dist/decorators/index.d.ts +6 -0
- package/dist/decorators/index.js +6 -0
- package/dist/decorators/index.js.map +1 -1
- package/dist/decorators/user-can.decorator.d.ts +5 -0
- package/dist/decorators/user-can.decorator.js +13 -0
- package/dist/decorators/user-can.decorator.js.map +1 -0
- package/dist/decorators/workspace-can.decorator.d.ts +5 -0
- package/dist/decorators/workspace-can.decorator.js +13 -0
- package/dist/decorators/workspace-can.decorator.js.map +1 -0
- package/dist/entities/account.entity.d.ts +1 -0
- package/dist/entities/account.entity.js +12 -3
- package/dist/entities/account.entity.js.map +1 -1
- package/dist/entities/api-key.entity.d.ts +17 -0
- package/dist/entities/api-key.entity.js +92 -0
- package/dist/entities/api-key.entity.js.map +1 -0
- package/dist/entities/index.d.ts +4 -0
- package/dist/entities/index.js +4 -0
- package/dist/entities/index.js.map +1 -1
- package/dist/entities/resolve-auth-relation-target.d.ts +3 -0
- package/dist/entities/resolve-auth-relation-target.js +30 -0
- package/dist/entities/resolve-auth-relation-target.js.map +1 -0
- package/dist/entities/session.entity.d.ts +3 -1
- package/dist/entities/session.entity.js +15 -2
- package/dist/entities/session.entity.js.map +1 -1
- package/dist/entities/user.entity.d.ts +5 -0
- package/dist/entities/user.entity.js +25 -0
- package/dist/entities/user.entity.js.map +1 -1
- package/dist/entities/verification.entity.js +2 -1
- package/dist/entities/verification.entity.js.map +1 -1
- package/dist/entities/workspace-invitation.entity.d.ts +14 -0
- package/dist/entities/workspace-invitation.entity.js +74 -0
- package/dist/entities/workspace-invitation.entity.js.map +1 -0
- package/dist/entities/workspace-member.entity.d.ts +16 -0
- package/dist/entities/workspace-member.entity.js +86 -0
- package/dist/entities/workspace-member.entity.js.map +1 -0
- package/dist/entities/workspace.entity.d.ts +8 -0
- package/dist/entities/workspace.entity.js +48 -0
- package/dist/entities/workspace.entity.js.map +1 -0
- package/dist/index.d.ts +34 -2
- package/dist/index.js +34 -2
- package/dist/index.js.map +1 -1
- package/dist/interfaces/auth-role.interface.d.ts +4 -0
- package/dist/interfaces/auth-role.interface.js +2 -0
- package/dist/interfaces/auth-role.interface.js.map +1 -0
- package/dist/interfaces/auth-service.interface.d.ts +160 -0
- package/dist/interfaces/auth-service.interface.js +2 -0
- package/dist/interfaces/auth-service.interface.js.map +1 -0
- package/dist/interfaces/can-options.interface.d.ts +3 -0
- package/dist/interfaces/can-options.interface.js +2 -0
- package/dist/interfaces/can-options.interface.js.map +1 -0
- package/dist/interfaces/route-argument-metadata-value.interface.d.ts +6 -0
- package/dist/interfaces/route-argument-metadata-value.interface.js +2 -0
- package/dist/interfaces/route-argument-metadata-value.interface.js.map +1 -0
- package/dist/interfaces/scope-policy-options.interface.d.ts +8 -0
- package/dist/interfaces/scope-policy-options.interface.js +2 -0
- package/dist/interfaces/scope-policy-options.interface.js.map +1 -0
- package/dist/interfaces/serialized-ability-rule.interface.d.ts +9 -0
- package/dist/interfaces/serialized-ability-rule.interface.js +2 -0
- package/dist/interfaces/serialized-ability-rule.interface.js.map +1 -0
- package/dist/interfaces/session-service.interface.d.ts +5 -0
- package/dist/interfaces/session-service.interface.js +2 -0
- package/dist/interfaces/session-service.interface.js.map +1 -0
- package/dist/interfaces/user-can-metadata.interface.d.ts +6 -0
- package/dist/interfaces/user-can-metadata.interface.js +2 -0
- package/dist/interfaces/user-can-metadata.interface.js.map +1 -0
- package/dist/interfaces/user-service.interface.d.ts +44 -0
- package/dist/interfaces/user-service.interface.js +2 -0
- package/dist/interfaces/user-service.interface.js.map +1 -0
- package/dist/interfaces/workspace-can-metadata.interface.d.ts +6 -0
- package/dist/interfaces/workspace-can-metadata.interface.js +2 -0
- package/dist/interfaces/workspace-can-metadata.interface.js.map +1 -0
- package/dist/interfaces/workspace-service.interface.d.ts +37 -0
- package/dist/interfaces/workspace-service.interface.js +2 -0
- package/dist/interfaces/workspace-service.interface.js.map +1 -0
- package/dist/permission.constants.d.ts +25 -0
- package/dist/permission.constants.js +26 -0
- package/dist/permission.constants.js.map +1 -0
- package/dist/policies/create-scope-policy.d.ts +3 -0
- package/dist/policies/create-scope-policy.js +37 -0
- package/dist/policies/create-scope-policy.js.map +1 -0
- package/dist/policies/index.d.ts +2 -0
- package/dist/policies/index.js +3 -0
- package/dist/policies/index.js.map +1 -0
- package/dist/policies/user-scope.policy.d.ts +3 -0
- package/dist/policies/user-scope.policy.js +5 -0
- package/dist/policies/user-scope.policy.js.map +1 -0
- package/dist/policies/workspace-scope.policy.d.ts +3 -0
- package/dist/policies/workspace-scope.policy.js +5 -0
- package/dist/policies/workspace-scope.policy.js.map +1 -0
- package/dist/session.service.d.ts +18 -0
- package/dist/session.service.js +165 -0
- package/dist/session.service.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/auth-module-roles.type.d.ts +1 -0
- package/dist/types/auth-module-roles.type.js +2 -0
- package/dist/types/auth-module-roles.type.js.map +1 -0
- package/dist/types/build-user-ability-callback.type.d.ts +4 -0
- package/dist/types/build-user-ability-callback.type.js +2 -0
- package/dist/types/build-user-ability-callback.type.js.map +1 -0
- package/dist/types/build-workspace-ability-callback.type.d.ts +4 -0
- package/dist/types/build-workspace-ability-callback.type.js +2 -0
- package/dist/types/build-workspace-ability-callback.type.js.map +1 -0
- package/dist/types/can-subject-factory.type.d.ts +2 -0
- package/dist/types/can-subject-factory.type.js +2 -0
- package/dist/types/can-subject-factory.type.js.map +1 -0
- package/dist/types/can-subject.type.d.ts +4 -0
- package/dist/types/can-subject.type.js +2 -0
- package/dist/types/can-subject.type.js.map +1 -0
- package/dist/types/route-argument-metadata.type.d.ts +2 -0
- package/dist/types/route-argument-metadata.type.js +2 -0
- package/dist/types/route-argument-metadata.type.js.map +1 -0
- package/dist/user-deletion.service.d.ts +19 -0
- package/dist/user-deletion.service.js +96 -0
- package/dist/user-deletion.service.js.map +1 -0
- package/dist/user.constants.d.ts +7 -0
- package/dist/user.constants.js +23 -0
- package/dist/user.constants.js.map +1 -0
- package/dist/user.service.d.ts +54 -0
- package/dist/user.service.js +384 -0
- package/dist/user.service.js.map +1 -0
- package/dist/utils/append-metadata.util.d.ts +3 -0
- package/dist/utils/append-metadata.util.js +12 -0
- package/dist/utils/append-metadata.util.js.map +1 -0
- package/dist/utils/apply-auth-response-cookies.util.d.ts +1 -0
- package/dist/utils/apply-auth-response-cookies.util.js +13 -0
- package/dist/utils/apply-auth-response-cookies.util.js.map +1 -0
- package/dist/utils/auth-role.util.d.ts +11 -0
- package/dist/utils/auth-role.util.js +88 -0
- package/dist/utils/auth-role.util.js.map +1 -0
- package/dist/utils/can.util.d.ts +3 -0
- package/dist/utils/can.util.js +8 -0
- package/dist/utils/can.util.js.map +1 -0
- package/dist/utils/create-email-and-password-config.d.ts +7 -3
- package/dist/utils/create-email-and-password-config.js +22 -1
- package/dist/utils/create-email-and-password-config.js.map +1 -1
- package/dist/utils/create-email-verification-config.d.ts +7 -0
- package/dist/utils/create-email-verification-config.js +14 -0
- package/dist/utils/create-email-verification-config.js.map +1 -0
- package/dist/utils/create-generic-oauth-config.d.ts +2 -0
- package/dist/utils/create-generic-oauth-config.js +15 -0
- package/dist/utils/create-generic-oauth-config.js.map +1 -0
- package/dist/utils/create-social-provider-config.d.ts +2 -2
- package/dist/utils/create-social-provider-config.js +6 -0
- package/dist/utils/create-social-provider-config.js.map +1 -1
- package/dist/utils/create-social-providers-config.d.ts +2 -2
- package/dist/utils/create-social-providers-config.js.map +1 -1
- package/dist/utils/create-user-config.d.ts +7 -0
- package/dist/utils/create-user-config.js +48 -0
- package/dist/utils/create-user-config.js.map +1 -0
- package/dist/utils/extract-api-key.util.d.ts +2 -0
- package/dist/utils/extract-api-key.util.js +14 -0
- package/dist/utils/extract-api-key.util.js.map +1 -0
- package/dist/utils/get-user-ability.util.d.ts +2 -0
- package/dist/utils/get-user-ability.util.js +11 -0
- package/dist/utils/get-user-ability.util.js.map +1 -0
- package/dist/utils/get-workspace-ability.util.d.ts +2 -0
- package/dist/utils/get-workspace-ability.util.js +11 -0
- package/dist/utils/get-workspace-ability.util.js.map +1 -0
- package/dist/utils/run-auth-query.d.ts +2 -0
- package/dist/utils/run-auth-query.js +21 -0
- package/dist/utils/run-auth-query.js.map +1 -0
- package/dist/utils/serialize-ability-rules.util.d.ts +3 -0
- package/dist/utils/serialize-ability-rules.util.js +23 -0
- package/dist/utils/serialize-ability-rules.util.js.map +1 -0
- package/dist/utils/split-auth-providers.d.ts +10 -0
- package/dist/utils/split-auth-providers.js +34 -0
- package/dist/utils/split-auth-providers.js.map +1 -0
- package/dist/utils/user-can.util.d.ts +2 -0
- package/dist/utils/user-can.util.js +18 -0
- package/dist/utils/user-can.util.js.map +1 -0
- package/dist/utils/workspace-can.util.d.ts +2 -0
- package/dist/utils/workspace-can.util.js +18 -0
- package/dist/utils/workspace-can.util.js.map +1 -0
- package/dist/workspace.constants.d.ts +8 -0
- package/dist/workspace.constants.js +24 -0
- package/dist/workspace.constants.js.map +1 -0
- package/dist/workspace.service.d.ts +59 -0
- package/dist/workspace.service.js +618 -0
- package/dist/workspace.service.js.map +1 -0
- package/package.json +29 -18
- package/dist/auth.transaction-context.d.ts +0 -10
- package/dist/auth.transaction-context.js +0 -22
- package/dist/auth.transaction-context.js.map +0 -1
- package/dist/utils/assert-no-duplicate-generic-oauth-plugin.d.ts +0 -2
- package/dist/utils/assert-no-duplicate-generic-oauth-plugin.js +0 -8
- package/dist/utils/assert-no-duplicate-generic-oauth-plugin.js.map +0 -1
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
export interface AuthUser {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
email: string;
|
|
5
|
+
emailVerified: boolean;
|
|
6
|
+
image?: string | null;
|
|
7
|
+
createdAt: Date;
|
|
8
|
+
updatedAt: Date;
|
|
9
|
+
[field: string]: unknown;
|
|
10
|
+
}
|
|
11
|
+
export interface SignUpOptions {
|
|
12
|
+
name: string;
|
|
13
|
+
email: string;
|
|
14
|
+
password: string;
|
|
15
|
+
image?: string;
|
|
16
|
+
callbackURL?: string;
|
|
17
|
+
rememberMe?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface SignUpResult<User extends AuthUser = AuthUser> {
|
|
20
|
+
token: string | null;
|
|
21
|
+
user: User;
|
|
22
|
+
}
|
|
23
|
+
export interface SignInOptions {
|
|
24
|
+
email: string;
|
|
25
|
+
password: string;
|
|
26
|
+
callbackURL?: string;
|
|
27
|
+
rememberMe?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface SignInResult<User extends AuthUser = AuthUser> {
|
|
30
|
+
redirect: boolean;
|
|
31
|
+
token: string;
|
|
32
|
+
url: string | null;
|
|
33
|
+
user: User;
|
|
34
|
+
}
|
|
35
|
+
export interface AuthSocialProvider {
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
}
|
|
39
|
+
export interface SignInSocialOptions {
|
|
40
|
+
provider: string;
|
|
41
|
+
callbackURL?: string;
|
|
42
|
+
newUserCallbackURL?: string;
|
|
43
|
+
errorCallbackURL?: string;
|
|
44
|
+
disableRedirect?: boolean;
|
|
45
|
+
scopes?: string[];
|
|
46
|
+
requestSignUp?: boolean;
|
|
47
|
+
loginHint?: string;
|
|
48
|
+
additionalParams?: Record<string, string>;
|
|
49
|
+
additionalData?: Record<string, unknown>;
|
|
50
|
+
}
|
|
51
|
+
export interface SignInSocialResult<User extends AuthUser = AuthUser> {
|
|
52
|
+
redirect: boolean;
|
|
53
|
+
url: string | null;
|
|
54
|
+
token: string | null;
|
|
55
|
+
user: User | null;
|
|
56
|
+
}
|
|
57
|
+
export interface SendVerificationEmailOptions {
|
|
58
|
+
email: string;
|
|
59
|
+
callbackURL?: string;
|
|
60
|
+
}
|
|
61
|
+
export interface RequestPasswordResetOptions {
|
|
62
|
+
email: string;
|
|
63
|
+
redirectTo?: string;
|
|
64
|
+
}
|
|
65
|
+
export interface RequestPasswordResetResult {
|
|
66
|
+
status: boolean;
|
|
67
|
+
message: string;
|
|
68
|
+
}
|
|
69
|
+
export interface ResetPasswordOptions {
|
|
70
|
+
newPassword: string;
|
|
71
|
+
token: string;
|
|
72
|
+
}
|
|
73
|
+
export interface UpdateAuthUserOptions {
|
|
74
|
+
name?: string;
|
|
75
|
+
image?: string | null;
|
|
76
|
+
}
|
|
77
|
+
export interface ChangeAuthEmailOptions {
|
|
78
|
+
newEmail: string;
|
|
79
|
+
callbackURL?: string;
|
|
80
|
+
}
|
|
81
|
+
export interface ChangeAuthPasswordOptions {
|
|
82
|
+
currentPassword: string;
|
|
83
|
+
newPassword: string;
|
|
84
|
+
revokeOtherSessions?: boolean;
|
|
85
|
+
}
|
|
86
|
+
export interface ChangeAuthPasswordResult {
|
|
87
|
+
token: string | null;
|
|
88
|
+
}
|
|
89
|
+
export interface DeleteAuthUserOptions {
|
|
90
|
+
callbackURL?: string;
|
|
91
|
+
password?: string;
|
|
92
|
+
token?: string;
|
|
93
|
+
}
|
|
94
|
+
export interface DeleteAuthUserResult {
|
|
95
|
+
message: string;
|
|
96
|
+
success: boolean;
|
|
97
|
+
}
|
|
98
|
+
export interface AuthAccount {
|
|
99
|
+
id: string;
|
|
100
|
+
accountId: string;
|
|
101
|
+
issuer: string;
|
|
102
|
+
providerId: string;
|
|
103
|
+
userId: string;
|
|
104
|
+
scopes: string[];
|
|
105
|
+
createdAt: Date;
|
|
106
|
+
updatedAt: Date;
|
|
107
|
+
}
|
|
108
|
+
export type AuthAccountSelector = {
|
|
109
|
+
accountId: string;
|
|
110
|
+
userId?: string;
|
|
111
|
+
} | {
|
|
112
|
+
useAccountCookie: true;
|
|
113
|
+
userId?: string;
|
|
114
|
+
};
|
|
115
|
+
export interface AuthAccessToken {
|
|
116
|
+
accessToken: string;
|
|
117
|
+
accessTokenExpiresAt: Date | null;
|
|
118
|
+
scopes: string[];
|
|
119
|
+
idToken: string | null;
|
|
120
|
+
}
|
|
121
|
+
export interface AuthRefreshedToken {
|
|
122
|
+
accessToken: string | null;
|
|
123
|
+
refreshToken: string;
|
|
124
|
+
accessTokenExpiresAt: Date | null;
|
|
125
|
+
refreshTokenExpiresAt: Date | null;
|
|
126
|
+
scope: string | null;
|
|
127
|
+
idToken: string | null;
|
|
128
|
+
providerId: string;
|
|
129
|
+
accountId: string;
|
|
130
|
+
}
|
|
131
|
+
export interface AuthProviderUserInfo {
|
|
132
|
+
name?: string;
|
|
133
|
+
email?: string | null;
|
|
134
|
+
emailVerified: boolean;
|
|
135
|
+
image?: string;
|
|
136
|
+
[field: string]: unknown;
|
|
137
|
+
}
|
|
138
|
+
export interface AuthAccountInfo<UserInfo extends AuthProviderUserInfo = AuthProviderUserInfo, Data extends object = Record<string, unknown>> {
|
|
139
|
+
account: Pick<AuthAccount, "id" | "providerId" | "issuer" | "accountId">;
|
|
140
|
+
user: UserInfo;
|
|
141
|
+
data: Data;
|
|
142
|
+
}
|
|
143
|
+
export interface UnlinkAuthAccountOptions {
|
|
144
|
+
accountId: string;
|
|
145
|
+
}
|
|
146
|
+
export interface LinkAuthSocialAccountOptions {
|
|
147
|
+
provider: string;
|
|
148
|
+
callbackURL?: string;
|
|
149
|
+
errorCallbackURL?: string;
|
|
150
|
+
disableRedirect?: boolean;
|
|
151
|
+
requestSignUp?: boolean;
|
|
152
|
+
scopes?: string[];
|
|
153
|
+
loginHint?: string;
|
|
154
|
+
additionalParams?: Record<string, string>;
|
|
155
|
+
additionalData?: Record<string, unknown>;
|
|
156
|
+
}
|
|
157
|
+
export interface LinkAuthSocialAccountResult {
|
|
158
|
+
url: string;
|
|
159
|
+
redirect: boolean;
|
|
160
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-service.interface.js","sourceRoot":"","sources":["../../src/interfaces/auth-service.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"can-options.interface.js","sourceRoot":"","sources":["../../src/interfaces/can-options.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-argument-metadata-value.interface.js","sourceRoot":"","sources":["../../src/interfaces/route-argument-metadata-value.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope-policy-options.interface.js","sourceRoot":"","sources":["../../src/interfaces/scope-policy-options.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialized-ability-rule.interface.js","sourceRoot":"","sources":["../../src/interfaces/serialized-ability-rule.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-service.interface.js","sourceRoot":"","sources":["../../src/interfaces/session-service.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-can-metadata.interface.js","sourceRoot":"","sources":["../../src/interfaces/user-can-metadata.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { BaseUser } from "../entities/index.js";
|
|
2
|
+
export interface CreateUserOptions {
|
|
3
|
+
email: string;
|
|
4
|
+
name: string;
|
|
5
|
+
password: string;
|
|
6
|
+
roles?: string[];
|
|
7
|
+
permissions?: string[];
|
|
8
|
+
data?: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
export interface UpdateUserOptions {
|
|
11
|
+
email?: string;
|
|
12
|
+
emailVerified?: boolean;
|
|
13
|
+
image?: string | null;
|
|
14
|
+
name?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ListUsersOptions {
|
|
17
|
+
searchField?: "email" | "name";
|
|
18
|
+
searchOperator?: "contains" | "ends_with" | "starts_with";
|
|
19
|
+
searchValue?: string;
|
|
20
|
+
limit?: number;
|
|
21
|
+
offset?: number;
|
|
22
|
+
sortBy?: string;
|
|
23
|
+
sortDirection?: "asc" | "desc";
|
|
24
|
+
filterField?: string;
|
|
25
|
+
filterOperator?: "contains" | "eq" | "gt" | "gte" | "lt" | "lte" | "ne";
|
|
26
|
+
filterValue?: boolean | number | string;
|
|
27
|
+
}
|
|
28
|
+
export interface ListUsersResult<User extends BaseUser = BaseUser> {
|
|
29
|
+
users: User[];
|
|
30
|
+
total: number;
|
|
31
|
+
limit: number | null;
|
|
32
|
+
offset: number | null;
|
|
33
|
+
}
|
|
34
|
+
export interface BanUserOptions {
|
|
35
|
+
banReason?: string;
|
|
36
|
+
banExpiresIn?: number;
|
|
37
|
+
}
|
|
38
|
+
export interface ImpersonationOptions {
|
|
39
|
+
ipAddress?: string;
|
|
40
|
+
userAgent?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface UserHasPermissionOptions {
|
|
43
|
+
permissions: Record<string, string[]>;
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-service.interface.js","sourceRoot":"","sources":["../../src/interfaces/user-service.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-can-metadata.interface.js","sourceRoot":"","sources":["../../src/interfaces/workspace-can-metadata.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { AuthWorkspaceMemberStatus, BaseWorkspace, BaseWorkspaceInvitation, BaseWorkspaceMember } from "../entities/index.js";
|
|
2
|
+
export interface CreateWorkspaceOptions {
|
|
3
|
+
name: string;
|
|
4
|
+
}
|
|
5
|
+
export interface UpdateWorkspaceOptions {
|
|
6
|
+
name?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface AddWorkspaceMemberOptions {
|
|
9
|
+
roles?: string[];
|
|
10
|
+
permissions?: string[];
|
|
11
|
+
}
|
|
12
|
+
export interface CreateWorkspaceServiceAccountOptions extends AddWorkspaceMemberOptions {
|
|
13
|
+
name: string;
|
|
14
|
+
data?: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
export interface UpdateWorkspaceMemberOptions {
|
|
17
|
+
name?: string;
|
|
18
|
+
email?: string | null;
|
|
19
|
+
status?: Extract<AuthWorkspaceMemberStatus, "ACTIVE" | "DISABLED">;
|
|
20
|
+
}
|
|
21
|
+
export interface CreateWorkspaceInvitationOptions {
|
|
22
|
+
email: string;
|
|
23
|
+
roles?: string[];
|
|
24
|
+
expiresIn?: number;
|
|
25
|
+
}
|
|
26
|
+
export interface AcceptWorkspaceInvitationResult<WorkspaceInvitation extends BaseWorkspaceInvitation = BaseWorkspaceInvitation, WorkspaceMember extends BaseWorkspaceMember = BaseWorkspaceMember> {
|
|
27
|
+
invitation: WorkspaceInvitation;
|
|
28
|
+
member: WorkspaceMember;
|
|
29
|
+
}
|
|
30
|
+
export interface FullWorkspace<Workspace extends BaseWorkspace = BaseWorkspace, WorkspaceMember extends BaseWorkspaceMember = BaseWorkspaceMember, WorkspaceInvitation extends BaseWorkspaceInvitation = BaseWorkspaceInvitation> {
|
|
31
|
+
workspace: Workspace;
|
|
32
|
+
members: WorkspaceMember[];
|
|
33
|
+
invitations: WorkspaceInvitation[];
|
|
34
|
+
}
|
|
35
|
+
export interface WorkspaceHasPermissionOptions {
|
|
36
|
+
permissions: Record<string, string[]>;
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-service.interface.js","sourceRoot":"","sources":["../../src/interfaces/workspace-service.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const USER_CAN_METADATA: unique symbol;
|
|
2
|
+
export declare const WORKSPACE_CAN_METADATA: unique symbol;
|
|
3
|
+
export declare const ROUTE_ARGS_METADATA = "__routeArguments__";
|
|
4
|
+
export declare const CUSTOM_ROUTE_ARGS_METADATA = "__customRouteArgs__";
|
|
5
|
+
export declare const GQL_PARAM_TYPES: {
|
|
6
|
+
readonly ROOT: 0;
|
|
7
|
+
readonly CONTEXT: 1;
|
|
8
|
+
readonly INFO: 2;
|
|
9
|
+
readonly ARGS: 3;
|
|
10
|
+
};
|
|
11
|
+
export declare const ROUTE_PARAM_TYPES: {
|
|
12
|
+
readonly REQUEST: 0;
|
|
13
|
+
readonly RESPONSE: 1;
|
|
14
|
+
readonly NEXT: 2;
|
|
15
|
+
readonly BODY: 3;
|
|
16
|
+
readonly QUERY: 4;
|
|
17
|
+
readonly PARAM: 5;
|
|
18
|
+
readonly HEADERS: 6;
|
|
19
|
+
readonly SESSION: 7;
|
|
20
|
+
readonly FILE: 8;
|
|
21
|
+
readonly FILES: 9;
|
|
22
|
+
readonly HOST: 10;
|
|
23
|
+
readonly IP: 11;
|
|
24
|
+
readonly RAW_BODY: 12;
|
|
25
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const USER_CAN_METADATA = Symbol("USER_CAN_METADATA");
|
|
2
|
+
export const WORKSPACE_CAN_METADATA = Symbol("WORKSPACE_CAN_METADATA");
|
|
3
|
+
export const ROUTE_ARGS_METADATA = "__routeArguments__";
|
|
4
|
+
export const CUSTOM_ROUTE_ARGS_METADATA = "__customRouteArgs__";
|
|
5
|
+
export const GQL_PARAM_TYPES = {
|
|
6
|
+
ROOT: 0,
|
|
7
|
+
CONTEXT: 1,
|
|
8
|
+
INFO: 2,
|
|
9
|
+
ARGS: 3,
|
|
10
|
+
};
|
|
11
|
+
export const ROUTE_PARAM_TYPES = {
|
|
12
|
+
REQUEST: 0,
|
|
13
|
+
RESPONSE: 1,
|
|
14
|
+
NEXT: 2,
|
|
15
|
+
BODY: 3,
|
|
16
|
+
QUERY: 4,
|
|
17
|
+
PARAM: 5,
|
|
18
|
+
HEADERS: 6,
|
|
19
|
+
SESSION: 7,
|
|
20
|
+
FILE: 8,
|
|
21
|
+
FILES: 9,
|
|
22
|
+
HOST: 10,
|
|
23
|
+
IP: 11,
|
|
24
|
+
RAW_BODY: 12,
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=permission.constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permission.constants.js","sourceRoot":"","sources":["../src/permission.constants.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAG7D,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,wBAAwB,CAAC,CAAC;AAGvE,MAAM,CAAC,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AAGxD,MAAM,CAAC,MAAM,0BAA0B,GAAG,qBAAqB,CAAC;AAGhE,MAAM,CAAC,MAAM,eAAe,GAAG;IAE7B,IAAI,EAAE,CAAC;IAEP,OAAO,EAAE,CAAC;IAEV,IAAI,EAAE,CAAC;IAEP,IAAI,EAAE,CAAC;CACC,CAAC;AAGX,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAE/B,OAAO,EAAE,CAAC;IAEV,QAAQ,EAAE,CAAC;IAEX,IAAI,EAAE,CAAC;IAEP,IAAI,EAAE,CAAC;IAEP,KAAK,EAAE,CAAC;IAER,KAAK,EAAE,CAAC;IAER,OAAO,EAAE,CAAC;IAEV,OAAO,EAAE,CAAC;IAEV,IAAI,EAAE,CAAC;IAEP,KAAK,EAAE,CAAC;IAER,IAAI,EAAE,EAAE;IAER,EAAE,EAAE,EAAE;IAEN,QAAQ,EAAE,EAAE;CACJ,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export function createScopePolicy(scope, options) {
|
|
2
|
+
const type = options.type ?? "bigint";
|
|
3
|
+
const property = options.property ?? scope;
|
|
4
|
+
const command = options.command ?? "all";
|
|
5
|
+
const roles = [...(options.roles ?? ["authenticated"])];
|
|
6
|
+
if (!["bigint", "integer", "uuid", "text"].includes(type)) {
|
|
7
|
+
throw new TypeError(`Unsupported scope policy type: ${type}`);
|
|
8
|
+
}
|
|
9
|
+
if (!["all", "select", "insert", "update", "delete"].includes(command)) {
|
|
10
|
+
throw new TypeError(`Unsupported scope policy command: ${command}`);
|
|
11
|
+
}
|
|
12
|
+
if (!property.trim()) {
|
|
13
|
+
throw new TypeError("Scope policy property must not be empty");
|
|
14
|
+
}
|
|
15
|
+
if (!roles.length || roles.some((role) => !role.trim())) {
|
|
16
|
+
throw new TypeError("Scope policy roles must not be empty");
|
|
17
|
+
}
|
|
18
|
+
const matchesScope = (columns) => {
|
|
19
|
+
if (!Object.hasOwn(columns, property) ||
|
|
20
|
+
typeof columns[property] !== "string" ||
|
|
21
|
+
!columns[property]) {
|
|
22
|
+
throw new TypeError(`Scope policy requires a mapped column for property: ${property}`);
|
|
23
|
+
}
|
|
24
|
+
const column = columns[property].replaceAll('"', '""');
|
|
25
|
+
return `"${column}" = nullif(current_setting('app.${scope}', true), '')::${type}`;
|
|
26
|
+
};
|
|
27
|
+
return {
|
|
28
|
+
...(options.name !== undefined ? { name: options.name } : {}),
|
|
29
|
+
command,
|
|
30
|
+
roles,
|
|
31
|
+
...(command !== "insert" ? { using: matchesScope } : {}),
|
|
32
|
+
...(command === "all" || command === "insert" || command === "update"
|
|
33
|
+
? { check: matchesScope }
|
|
34
|
+
: {}),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=create-scope-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-scope-policy.js","sourceRoot":"","sources":["../../src/policies/create-scope-policy.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,iBAAiB,CAC/B,KAA2B,EAC3B,OAA2B;IAE3B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,QAAQ,CAAC;IACtC,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,KAAK,CAAC;IAC3C,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC;IACzC,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAExD,IAAI,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1D,MAAM,IAAI,SAAS,CAAC,kCAAkC,IAAI,EAAE,CAAC,CAAC;IAChE,CAAC;IACD,IAAI,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACvE,MAAM,IAAI,SAAS,CAAC,qCAAqC,OAAO,EAAE,CAAC,CAAC;IACtE,CAAC;IACD,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC;QACrB,MAAM,IAAI,SAAS,CAAC,yCAAyC,CAAC,CAAC;IACjE,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;QACxD,MAAM,IAAI,SAAS,CAAC,sCAAsC,CAAC,CAAC;IAC9D,CAAC;IAED,MAAM,YAAY,GAA4C,CAAC,OAAO,EAAE,EAAE;QACxE,IACE,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC;YACjC,OAAO,OAAO,CAAC,QAAQ,CAAC,KAAK,QAAQ;YACrC,CAAC,OAAO,CAAC,QAAQ,CAAC,EAClB,CAAC;YACD,MAAM,IAAI,SAAS,CACjB,uDAAuD,QAAQ,EAAE,CAClE,CAAC;QACJ,CAAC;QACD,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACvD,OAAO,IAAI,MAAM,mCAAmC,KAAK,kBAAkB,IAAI,EAAE,CAAC;IACpF,CAAC,CAAC;IAEF,OAAO;QACL,GAAG,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7D,OAAO;QACP,KAAK;QACL,GAAG,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACxD,GAAG,CAAC,OAAO,KAAK,KAAK,IAAI,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,QAAQ;YACnE,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE;YACzB,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/policies/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-scope.policy.js","sourceRoot":"","sources":["../../src/policies/user-scope.policy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAU7D,MAAM,UAAU,eAAe,CAAC,UAA8B,EAAE;IAC9D,OAAO,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-scope.policy.js","sourceRoot":"","sources":["../../src/policies/workspace-scope.policy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAU7D,MAAM,UAAU,oBAAoB,CAClC,UAA8B,EAAE;IAEhC,OAAO,iBAAiB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { EntityManager } from "@mikro-orm/core";
|
|
2
|
+
import type { AuthModuleOptions } from "./auth-module-options.interface.js";
|
|
3
|
+
import type { BaseSession, BaseUser } from "./entities/index.js";
|
|
4
|
+
import type { AuthenticatedSession } from "./interfaces/session-service.interface.js";
|
|
5
|
+
export declare class SessionService {
|
|
6
|
+
private readonly em;
|
|
7
|
+
private readonly options;
|
|
8
|
+
constructor(auth: unknown, em: EntityManager, options: AuthModuleOptions);
|
|
9
|
+
private readonly auth;
|
|
10
|
+
getSession<User extends BaseUser = BaseUser, Session extends BaseSession = BaseSession>(): Promise<AuthenticatedSession<User, Session> | null>;
|
|
11
|
+
private resolveSession;
|
|
12
|
+
listSessions<Session extends BaseSession = BaseSession>(): Promise<Session[]>;
|
|
13
|
+
revokeSession(id: string): Promise<boolean>;
|
|
14
|
+
revokeOtherSessions(): Promise<boolean>;
|
|
15
|
+
revokeSessions(): Promise<boolean>;
|
|
16
|
+
setSession(sessionToken: string): Promise<void>;
|
|
17
|
+
private runUnrestricted;
|
|
18
|
+
}
|