@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
package/dist/auth.service.js
CHANGED
|
@@ -10,18 +10,188 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
11
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
12
|
};
|
|
13
|
-
import {
|
|
13
|
+
import { headers } from "@nest-boot/request-context";
|
|
14
|
+
import { Inject, Injectable } from "@nestjs/common";
|
|
14
15
|
import { AUTH_TOKEN } from "./auth.constants.js";
|
|
16
|
+
import { applyAuthResponseCookies } from "./utils/apply-auth-response-cookies.util.js";
|
|
15
17
|
let AuthService = class AuthService {
|
|
16
|
-
auth;
|
|
17
18
|
constructor(auth) {
|
|
18
19
|
this.auth = auth;
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
auth;
|
|
22
|
+
async listSocialProviders() {
|
|
23
|
+
const context = await this.auth.$context;
|
|
24
|
+
return context.socialProviders.map(({ id, name }) => ({
|
|
25
|
+
id,
|
|
26
|
+
name,
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
async signUp(options) {
|
|
30
|
+
const result = await this.auth.api.signUpEmail({
|
|
31
|
+
body: options,
|
|
32
|
+
headers: headers(),
|
|
33
|
+
returnHeaders: true,
|
|
34
|
+
});
|
|
35
|
+
applyAuthResponseCookies(result.headers);
|
|
36
|
+
return result.response;
|
|
37
|
+
}
|
|
38
|
+
async signIn(options) {
|
|
39
|
+
const result = await this.auth.api.signInEmail({
|
|
40
|
+
body: options,
|
|
41
|
+
headers: headers(),
|
|
42
|
+
returnHeaders: true,
|
|
43
|
+
});
|
|
44
|
+
applyAuthResponseCookies(result.headers);
|
|
45
|
+
return this.normalizeSignInResult(result.response);
|
|
46
|
+
}
|
|
47
|
+
async signInSocial(options) {
|
|
48
|
+
const result = await this.auth.api.signInSocial({
|
|
49
|
+
body: options,
|
|
50
|
+
headers: headers(),
|
|
51
|
+
returnHeaders: true,
|
|
52
|
+
});
|
|
53
|
+
applyAuthResponseCookies(result.headers);
|
|
54
|
+
return this.normalizeSignInSocialResult(result.response);
|
|
55
|
+
}
|
|
56
|
+
async signOut() {
|
|
57
|
+
const result = await this.auth.api.signOut({
|
|
58
|
+
headers: headers(),
|
|
59
|
+
returnHeaders: true,
|
|
60
|
+
});
|
|
61
|
+
applyAuthResponseCookies(result.headers);
|
|
62
|
+
return result.response.success;
|
|
63
|
+
}
|
|
64
|
+
async sendVerificationEmail(options) {
|
|
65
|
+
const result = await this.auth.api.sendVerificationEmail({ body: options });
|
|
66
|
+
return result.status;
|
|
67
|
+
}
|
|
68
|
+
async requestPasswordReset(options) {
|
|
69
|
+
return await this.auth.api.requestPasswordReset({ body: options });
|
|
70
|
+
}
|
|
71
|
+
async resetPassword(options) {
|
|
72
|
+
const result = await this.auth.api.resetPassword({ body: options });
|
|
73
|
+
return result.status;
|
|
74
|
+
}
|
|
75
|
+
async verifyPassword(password) {
|
|
76
|
+
const result = await this.auth.api.verifyPassword({
|
|
77
|
+
body: { password },
|
|
78
|
+
headers: headers(),
|
|
79
|
+
});
|
|
80
|
+
return result.status;
|
|
81
|
+
}
|
|
82
|
+
async updateUser(options) {
|
|
83
|
+
const result = await this.auth.api.updateUser({
|
|
84
|
+
body: options,
|
|
85
|
+
headers: headers(),
|
|
86
|
+
returnHeaders: true,
|
|
87
|
+
});
|
|
88
|
+
applyAuthResponseCookies(result.headers);
|
|
89
|
+
return result.response.status;
|
|
90
|
+
}
|
|
91
|
+
async changeEmail(options) {
|
|
92
|
+
const result = await this.auth.api.changeEmail({
|
|
93
|
+
body: options,
|
|
94
|
+
headers: headers(),
|
|
95
|
+
returnHeaders: true,
|
|
96
|
+
});
|
|
97
|
+
applyAuthResponseCookies(result.headers);
|
|
98
|
+
return result.response.status;
|
|
99
|
+
}
|
|
100
|
+
async changePassword(options) {
|
|
101
|
+
const result = await this.auth.api.changePassword({
|
|
102
|
+
body: options,
|
|
103
|
+
headers: headers(),
|
|
104
|
+
returnHeaders: true,
|
|
105
|
+
});
|
|
106
|
+
applyAuthResponseCookies(result.headers);
|
|
107
|
+
return { token: result.response.token };
|
|
108
|
+
}
|
|
109
|
+
async setPassword(newPassword) {
|
|
110
|
+
const result = await this.auth.api.setPassword({
|
|
111
|
+
body: { newPassword },
|
|
112
|
+
headers: headers(),
|
|
113
|
+
});
|
|
114
|
+
return result.status;
|
|
115
|
+
}
|
|
116
|
+
async deleteUser(options) {
|
|
117
|
+
const result = await this.auth.api.deleteUser({
|
|
118
|
+
body: options ?? {},
|
|
119
|
+
headers: headers(),
|
|
120
|
+
returnHeaders: true,
|
|
121
|
+
});
|
|
122
|
+
applyAuthResponseCookies(result.headers);
|
|
123
|
+
return result.response;
|
|
124
|
+
}
|
|
125
|
+
async listAccounts() {
|
|
126
|
+
return await this.auth.api.listUserAccounts({ headers: headers() });
|
|
127
|
+
}
|
|
128
|
+
async linkSocialAccount(options) {
|
|
129
|
+
const result = await this.auth.api.linkSocialAccount({
|
|
130
|
+
body: options,
|
|
131
|
+
headers: headers(),
|
|
132
|
+
returnHeaders: true,
|
|
133
|
+
});
|
|
134
|
+
applyAuthResponseCookies(result.headers);
|
|
135
|
+
return result.response;
|
|
136
|
+
}
|
|
137
|
+
async unlinkAccount(options) {
|
|
138
|
+
const result = await this.auth.api.unlinkAccount({
|
|
139
|
+
body: options,
|
|
140
|
+
headers: headers(),
|
|
141
|
+
});
|
|
142
|
+
return result.status;
|
|
143
|
+
}
|
|
144
|
+
async getAccessToken(selector) {
|
|
145
|
+
const result = await this.auth.api.getAccessToken({
|
|
146
|
+
body: selector,
|
|
147
|
+
headers: headers(),
|
|
148
|
+
});
|
|
149
|
+
return {
|
|
150
|
+
accessToken: result.accessToken,
|
|
151
|
+
accessTokenExpiresAt: result.accessTokenExpiresAt ?? null,
|
|
152
|
+
scopes: result.scopes,
|
|
153
|
+
idToken: result.idToken ?? null,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
async refreshToken(selector) {
|
|
157
|
+
const result = await this.auth.api.refreshToken({
|
|
158
|
+
body: selector,
|
|
159
|
+
headers: headers(),
|
|
160
|
+
});
|
|
161
|
+
return {
|
|
162
|
+
accessToken: result.accessToken ?? null,
|
|
163
|
+
refreshToken: result.refreshToken,
|
|
164
|
+
accessTokenExpiresAt: result.accessTokenExpiresAt ?? null,
|
|
165
|
+
refreshTokenExpiresAt: result.refreshTokenExpiresAt ?? null,
|
|
166
|
+
scope: result.scope ?? null,
|
|
167
|
+
idToken: result.idToken ?? null,
|
|
168
|
+
providerId: result.providerId,
|
|
169
|
+
accountId: result.accountId,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
async accountInfo(selector) {
|
|
173
|
+
return (await this.auth.api.accountInfo({
|
|
174
|
+
query: selector,
|
|
175
|
+
headers: headers(),
|
|
176
|
+
}));
|
|
177
|
+
}
|
|
178
|
+
normalizeSignInResult(result) {
|
|
179
|
+
return {
|
|
180
|
+
...result,
|
|
181
|
+
url: result.url ?? null,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
normalizeSignInSocialResult(result) {
|
|
185
|
+
return {
|
|
186
|
+
redirect: result.redirect,
|
|
187
|
+
url: result.url ?? null,
|
|
188
|
+
token: result.token ?? null,
|
|
189
|
+
user: result.user ?? null,
|
|
190
|
+
};
|
|
22
191
|
}
|
|
23
192
|
};
|
|
24
193
|
AuthService = __decorate([
|
|
194
|
+
Injectable(),
|
|
25
195
|
__param(0, Inject(AUTH_TOKEN)),
|
|
26
196
|
__metadata("design:paramtypes", [Object])
|
|
27
197
|
], AuthService);
|
package/dist/auth.service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../src/auth.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../src/auth.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AA8BjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAC;AA0HhF,IAAM,WAAW,GAAjB,MAAM,WAAW;IAKtB,YAAgC,IAAa;QAC3C,IAAI,CAAC,IAAI,GAAG,IAAoB,CAAC;IACnC,CAAC;IAEgB,IAAI,CAAe;IAGpC,KAAK,CAAC,mBAAmB;QACvB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;QACzC,OAAO,OAAO,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;YACpD,EAAE;YACF,IAAI;SACL,CAAC,CAAC,CAAC;IACN,CAAC;IAGD,KAAK,CAAC,MAAM,CACV,OAAsB;QAEtB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC;YAC7C,IAAI,EAAE,OAAO;YACb,OAA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,EAAE,MAAM,CAAC,oBAAoB,IAAI,IAAI;YACzD,qBAAqB,EAAE,MAAM,CAAC,qBAAqB,IAAI,IAAI;YAC3D,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,IAAI;YAC3B,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,IAAI;YAC/B,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,SAAS,EAAE,MAAM,CAAC,SAAS;SAC5B,CAAC;IACJ,CAAC;IAGD,KAAK,CAAC,WAAW,CAGf,QAA6B;QAC7B,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC;YACtC,KAAK,EAAE,QAAQ;YACf,OAAO,EAAE,OAAO,EAAE;SACnB,CAAC,CAAoC,CAAC;IACzC,CAAC;IAEO,qBAAqB,CAC3B,MAAoD;QAEpD,OAAO;YACL,GAAG,MAAM;YACT,GAAG,EAAE,MAAM,CAAC,GAAG,IAAI,IAAI;SACF,CAAC;IAC1B,CAAC;IAEO,2BAA2B,CAAwB,MAK1D;QACC,OAAO;YACL,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,GAAG,EAAE,MAAM,CAAC,GAAG,IAAI,IAAI;YACvB,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,IAAI;YAC3B,IAAI,EAAG,MAAM,CAAC,IAAyB,IAAI,IAAI;SAChD,CAAC;IACJ,CAAC;CACF,CAAA;AA9PY,WAAW;IADvB,UAAU,EAAE;IAME,WAAA,MAAM,CAAC,UAAU,CAAC,CAAA;;GALpB,WAAW,CA8PvB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Subject } from "@casl/ability";
|
|
2
|
+
import type { CustomDecorator } from "@nestjs/common";
|
|
3
|
+
import type { CanOptions } from "../interfaces/can-options.interface.js";
|
|
4
|
+
import { USER_CAN_METADATA, WORKSPACE_CAN_METADATA } from "../permission.constants.js";
|
|
5
|
+
import type { CanSubject } from "../types/can-subject.type.js";
|
|
6
|
+
export declare function Can<T extends Subject = Subject>(action: string, subject: CanSubject<T>, options?: CanOptions): CustomDecorator<typeof USER_CAN_METADATA | typeof WORKSPACE_CAN_METADATA>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { UserCan } from "./user-can.decorator.js";
|
|
2
|
+
import { WorkspaceCan } from "./workspace-can.decorator.js";
|
|
3
|
+
export function Can(action, subject, options = {}) {
|
|
4
|
+
return options.scope === "user"
|
|
5
|
+
? UserCan(action, subject)
|
|
6
|
+
: WorkspaceCan(action, subject);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=can.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"can.decorator.js","sourceRoot":"","sources":["../../src/decorators/can.decorator.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAwB5D,MAAM,UAAU,GAAG,CACjB,MAAc,EACd,OAAsB,EACtB,UAAsB,EAAE;IAExB,OAAO,OAAO,CAAC,KAAK,KAAK,MAAM;QAC7B,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC;QAC1B,CAAC,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CurrentApiKey: (...dataOrPipes: any[]) => ParameterDecorator;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { RequestContext } from "@nest-boot/request-context";
|
|
2
|
+
import { createParamDecorator } from "@nestjs/common";
|
|
3
|
+
import { BaseApiKey } from "../entities/index.js";
|
|
4
|
+
export const CurrentApiKey = createParamDecorator(() => RequestContext.get(BaseApiKey));
|
|
5
|
+
//# sourceMappingURL=current-api-key.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current-api-key.decorator.js","sourceRoot":"","sources":["../../src/decorators/current-api-key.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGlD,MAAM,CAAC,MAAM,aAAa,GAAG,oBAAoB,CAAC,GAAG,EAAE,CACrD,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,CAC/B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CurrentWorkspaceMember: (...dataOrPipes: any[]) => ParameterDecorator;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { RequestContext } from "@nest-boot/request-context";
|
|
2
|
+
import { createParamDecorator } from "@nestjs/common";
|
|
3
|
+
import { BaseWorkspaceMember } from "../entities/index.js";
|
|
4
|
+
export const CurrentWorkspaceMember = createParamDecorator(() => RequestContext.get(BaseWorkspaceMember));
|
|
5
|
+
//# sourceMappingURL=current-workspace-member.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current-workspace-member.decorator.js","sourceRoot":"","sources":["../../src/decorators/current-workspace-member.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAG3D,MAAM,CAAC,MAAM,sBAAsB,GAAG,oBAAoB,CAAC,GAAG,EAAE,CAC9D,cAAc,CAAC,GAAG,CAAC,mBAAmB,CAAC,CACxC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CurrentWorkspace: (...dataOrPipes: any[]) => ParameterDecorator;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { RequestContext } from "@nest-boot/request-context";
|
|
2
|
+
import { createParamDecorator } from "@nestjs/common";
|
|
3
|
+
import { BaseWorkspace } from "../entities/index.js";
|
|
4
|
+
export const CurrentWorkspace = createParamDecorator(() => RequestContext.get(BaseWorkspace));
|
|
5
|
+
//# sourceMappingURL=current-workspace.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current-workspace.decorator.js","sourceRoot":"","sources":["../../src/decorators/current-workspace.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,MAAM,CAAC,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,GAAG,EAAE,CACxD,cAAc,CAAC,GAAG,CAAC,aAAa,CAAC,CAClC,CAAC"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
export * from "./can.decorator.js";
|
|
2
|
+
export * from "./current-api-key.decorator.js";
|
|
1
3
|
export * from "./current-session.decorator.js";
|
|
2
4
|
export * from "./current-user.decorator.js";
|
|
5
|
+
export * from "./current-workspace.decorator.js";
|
|
6
|
+
export * from "./current-workspace-member.decorator.js";
|
|
3
7
|
export * from "./public.decorator.js";
|
|
8
|
+
export * from "./user-can.decorator.js";
|
|
9
|
+
export * from "./workspace-can.decorator.js";
|
package/dist/decorators/index.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
export * from "./can.decorator.js";
|
|
2
|
+
export * from "./current-api-key.decorator.js";
|
|
1
3
|
export * from "./current-session.decorator.js";
|
|
2
4
|
export * from "./current-user.decorator.js";
|
|
5
|
+
export * from "./current-workspace.decorator.js";
|
|
6
|
+
export * from "./current-workspace-member.decorator.js";
|
|
3
7
|
export * from "./public.decorator.js";
|
|
8
|
+
export * from "./user-can.decorator.js";
|
|
9
|
+
export * from "./workspace-can.decorator.js";
|
|
4
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AACjD,cAAc,yCAAyC,CAAC;AACxD,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Subject } from "@casl/ability";
|
|
2
|
+
import type { CustomDecorator } from "@nestjs/common";
|
|
3
|
+
import { USER_CAN_METADATA } from "../permission.constants.js";
|
|
4
|
+
import type { CanSubject } from "../types/can-subject.type.js";
|
|
5
|
+
export declare function UserCan<T extends Subject = Subject>(action: string, subject: CanSubject<T>): CustomDecorator<typeof USER_CAN_METADATA>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { USER_CAN_METADATA } from "../permission.constants.js";
|
|
2
|
+
import { appendMetadata } from "../utils/append-metadata.util.js";
|
|
3
|
+
export function UserCan(action, subject) {
|
|
4
|
+
if (!subject) {
|
|
5
|
+
throw new TypeError("Permission subject is required.");
|
|
6
|
+
}
|
|
7
|
+
const metadata = {
|
|
8
|
+
action,
|
|
9
|
+
subject,
|
|
10
|
+
};
|
|
11
|
+
return appendMetadata(USER_CAN_METADATA, metadata);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=user-can.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-can.decorator.js","sourceRoot":"","sources":["../../src/decorators/user-can.decorator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAUlE,MAAM,UAAU,OAAO,CACrB,MAAc,EACd,OAAsB;IAEtB,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,SAAS,CAAC,iCAAiC,CAAC,CAAC;IACzD,CAAC;IAED,MAAM,QAAQ,GAAuB;QACnC,MAAM;QACN,OAAO;KACR,CAAC;IAEF,OAAO,cAAc,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Subject } from "@casl/ability";
|
|
2
|
+
import type { CustomDecorator } from "@nestjs/common";
|
|
3
|
+
import { WORKSPACE_CAN_METADATA } from "../permission.constants.js";
|
|
4
|
+
import type { CanSubject } from "../types/can-subject.type.js";
|
|
5
|
+
export declare function WorkspaceCan<T extends Subject = Subject>(action: string, subject: CanSubject<T>): CustomDecorator<typeof WORKSPACE_CAN_METADATA>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { WORKSPACE_CAN_METADATA } from "../permission.constants.js";
|
|
2
|
+
import { appendMetadata } from "../utils/append-metadata.util.js";
|
|
3
|
+
export function WorkspaceCan(action, subject) {
|
|
4
|
+
if (!subject) {
|
|
5
|
+
throw new TypeError("Permission subject is required.");
|
|
6
|
+
}
|
|
7
|
+
const metadata = {
|
|
8
|
+
action,
|
|
9
|
+
subject,
|
|
10
|
+
};
|
|
11
|
+
return appendMetadata(WORKSPACE_CAN_METADATA, metadata);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=workspace-can.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-can.decorator.js","sourceRoot":"","sources":["../../src/decorators/workspace-can.decorator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAUlE,MAAM,UAAU,YAAY,CAC1B,MAAc,EACd,OAAsB;IAEtB,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,SAAS,CAAC,iCAAiC,CAAC,CAAC;IACzD,CAAC;IAED,MAAM,QAAQ,GAA4B;QACxC,MAAM;QACN,OAAO;KACR,CAAC;IAEF,OAAO,cAAc,CAAC,sBAAsB,EAAE,QAAQ,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -8,11 +8,14 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
10
|
import { BaseEntity, Cascade, t } from "@mikro-orm/core";
|
|
11
|
-
import { Entity, ManyToOne, PrimaryKey, Property, } from "@mikro-orm/decorators/legacy";
|
|
11
|
+
import { Entity, Index, ManyToOne, PrimaryKey, Property, Unique, } from "@mikro-orm/decorators/legacy";
|
|
12
12
|
import { randomUUID } from "crypto";
|
|
13
|
+
import { resolveAuthRelationTarget } from "./resolve-auth-relation-target.js";
|
|
14
|
+
import { BaseUser } from "./user.entity.js";
|
|
13
15
|
let BaseAccount = class BaseAccount extends BaseEntity {
|
|
14
16
|
id = randomUUID();
|
|
15
17
|
accountId;
|
|
18
|
+
issuer;
|
|
16
19
|
providerId;
|
|
17
20
|
userId;
|
|
18
21
|
accessToken;
|
|
@@ -33,13 +36,18 @@ __decorate([
|
|
|
33
36
|
Property({ type: t.text }),
|
|
34
37
|
__metadata("design:type", String)
|
|
35
38
|
], BaseAccount.prototype, "accountId", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
Property({ type: t.text }),
|
|
41
|
+
__metadata("design:type", String)
|
|
42
|
+
], BaseAccount.prototype, "issuer", void 0);
|
|
36
43
|
__decorate([
|
|
37
44
|
Property({ type: t.text }),
|
|
38
45
|
__metadata("design:type", String)
|
|
39
46
|
], BaseAccount.prototype, "providerId", void 0);
|
|
40
47
|
__decorate([
|
|
48
|
+
Index(),
|
|
41
49
|
ManyToOne({
|
|
42
|
-
entity: () => "User",
|
|
50
|
+
entity: () => resolveAuthRelationTarget(BaseUser, "User"),
|
|
43
51
|
fieldName: "user_id",
|
|
44
52
|
mapToPk: true,
|
|
45
53
|
cascade: [Cascade.REMOVE],
|
|
@@ -87,7 +95,8 @@ __decorate([
|
|
|
87
95
|
__metadata("design:type", Object)
|
|
88
96
|
], BaseAccount.prototype, "updatedAt", void 0);
|
|
89
97
|
BaseAccount = __decorate([
|
|
90
|
-
Entity({ abstract: true })
|
|
98
|
+
Entity({ abstract: true }),
|
|
99
|
+
Unique({ properties: ["issuer", "accountId"] })
|
|
91
100
|
], BaseAccount);
|
|
92
101
|
export { BaseAccount };
|
|
93
102
|
//# sourceMappingURL=account.entity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.entity.js","sourceRoot":"","sources":["../../src/entities/account.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAY,CAAC,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EACL,MAAM,EACN,SAAS,EACT,UAAU,EACV,QAAQ,
|
|
1
|
+
{"version":3,"file":"account.entity.js","sourceRoot":"","sources":["../../src/entities/account.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAY,CAAC,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EACL,MAAM,EACN,KAAK,EACL,SAAS,EACT,UAAU,EACV,QAAQ,EACR,MAAM,GACP,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EA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C,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4CACrB;AAItB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yDACd;AAIjC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0DACb;AAIlC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0CACvB;AAIpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACpB;AAIvB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;;8CAClB;AAQlC;IALC,QAAQ,CAAC;QACR,IAAI,EAAE,CAAC,CAAC,QAAQ;QAChB,UAAU,EAAE,OAAO;QACnB,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE;KAC3B,CAAC;;8CACgC;AAjEd,WAAW;IAFhC,MAAM,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC1B,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC,QAAQ,EAAE,WAAW,CAAC,EAAE,CAAC;GAC1B,WAAW,CAkEhC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseEntity, type Opt, type Ref } from "@mikro-orm/core";
|
|
2
|
+
import { BaseUser } from "./user.entity.js";
|
|
3
|
+
import { BaseWorkspace } from "./workspace.entity.js";
|
|
4
|
+
export declare class BaseApiKey extends BaseEntity {
|
|
5
|
+
id: Opt<string>;
|
|
6
|
+
name: string;
|
|
7
|
+
start?: Opt<string> | null;
|
|
8
|
+
prefix?: Opt<string> | null;
|
|
9
|
+
key: string;
|
|
10
|
+
enabled: Opt<boolean>;
|
|
11
|
+
permissions: Opt<string[]>;
|
|
12
|
+
createdAt: Opt<Date>;
|
|
13
|
+
updatedAt: Opt<Date>;
|
|
14
|
+
lastUsedAt?: Opt<Date> | null;
|
|
15
|
+
expiresAt?: Opt<Date> | null;
|
|
16
|
+
owner: Ref<BaseUser | BaseWorkspace>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { randomUUID } from "node:crypto";
|
|
11
|
+
import { BaseEntity, t } from "@mikro-orm/core";
|
|
12
|
+
import { Entity, ManyToOne, PrimaryKey, Property, Unique, } from "@mikro-orm/decorators/legacy";
|
|
13
|
+
import { resolveAuthRelationTarget } from "./resolve-auth-relation-target.js";
|
|
14
|
+
import { BaseUser } from "./user.entity.js";
|
|
15
|
+
import { BaseWorkspace } from "./workspace.entity.js";
|
|
16
|
+
let BaseApiKey = class BaseApiKey extends BaseEntity {
|
|
17
|
+
id = randomUUID();
|
|
18
|
+
name;
|
|
19
|
+
start = null;
|
|
20
|
+
prefix = null;
|
|
21
|
+
key;
|
|
22
|
+
enabled = true;
|
|
23
|
+
permissions = [];
|
|
24
|
+
createdAt = new Date();
|
|
25
|
+
updatedAt = new Date();
|
|
26
|
+
lastUsedAt = null;
|
|
27
|
+
expiresAt = null;
|
|
28
|
+
owner;
|
|
29
|
+
};
|
|
30
|
+
__decorate([
|
|
31
|
+
PrimaryKey({ type: t.uuid }),
|
|
32
|
+
__metadata("design:type", Object)
|
|
33
|
+
], BaseApiKey.prototype, "id", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
Property({ type: t.text }),
|
|
36
|
+
__metadata("design:type", String)
|
|
37
|
+
], BaseApiKey.prototype, "name", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
Property({ type: t.text, nullable: true }),
|
|
40
|
+
__metadata("design:type", Object)
|
|
41
|
+
], BaseApiKey.prototype, "start", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
Property({ type: t.text, nullable: true }),
|
|
44
|
+
__metadata("design:type", Object)
|
|
45
|
+
], BaseApiKey.prototype, "prefix", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
Property({ type: t.text }),
|
|
48
|
+
Unique(),
|
|
49
|
+
__metadata("design:type", String)
|
|
50
|
+
], BaseApiKey.prototype, "key", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
Property({ type: t.boolean, default: true }),
|
|
53
|
+
__metadata("design:type", Object)
|
|
54
|
+
], BaseApiKey.prototype, "enabled", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
Property({ type: t.array }),
|
|
57
|
+
__metadata("design:type", Object)
|
|
58
|
+
], BaseApiKey.prototype, "permissions", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
Property({ type: t.datetime, defaultRaw: "now()" }),
|
|
61
|
+
__metadata("design:type", Object)
|
|
62
|
+
], BaseApiKey.prototype, "createdAt", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
Property({
|
|
65
|
+
type: t.datetime,
|
|
66
|
+
defaultRaw: "now()",
|
|
67
|
+
onUpdate: () => new Date(),
|
|
68
|
+
}),
|
|
69
|
+
__metadata("design:type", Object)
|
|
70
|
+
], BaseApiKey.prototype, "updatedAt", void 0);
|
|
71
|
+
__decorate([
|
|
72
|
+
Property({ type: t.datetime, nullable: true }),
|
|
73
|
+
__metadata("design:type", Object)
|
|
74
|
+
], BaseApiKey.prototype, "lastUsedAt", void 0);
|
|
75
|
+
__decorate([
|
|
76
|
+
Property({ type: t.datetime, nullable: true }),
|
|
77
|
+
__metadata("design:type", Object)
|
|
78
|
+
], BaseApiKey.prototype, "expiresAt", void 0);
|
|
79
|
+
__decorate([
|
|
80
|
+
ManyToOne({
|
|
81
|
+
entity: () => [
|
|
82
|
+
resolveAuthRelationTarget(BaseUser, "User"),
|
|
83
|
+
resolveAuthRelationTarget(BaseWorkspace, "Workspace"),
|
|
84
|
+
],
|
|
85
|
+
}),
|
|
86
|
+
__metadata("design:type", Object)
|
|
87
|
+
], BaseApiKey.prototype, "owner", void 0);
|
|
88
|
+
BaseApiKey = __decorate([
|
|
89
|
+
Entity({ abstract: true })
|
|
90
|
+
], BaseApiKey);
|
|
91
|
+
export { BaseApiKey };
|
|
92
|
+
//# sourceMappingURL=api-key.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-key.entity.js","sourceRoot":"","sources":["../../src/entities/api-key.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAsB,CAAC,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EACL,MAAM,EACN,SAAS,EACT,UAAU,EACV,QAAQ,EACR,MAAM,GACP,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAU/C,IAAM,UAAU,GAAhB,MAAM,UAAW,SAA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,EAAE,OAAO;QACnB,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE;KAC3B,CAAC;;6CACgC;AAIlC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CACV;AAIrC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACX;AAUpC;IAPC,SAAS,CAAC;QACT,MAAM,EAAE,GAAG,EAAE,CACX;YACE,yBAAyB,CAAC,QAAQ,EAAE,MAAM,CAAC;YAC3C,yBAAyB,CAAC,aAAa,EAAE,WAAW,CAAC;SAC/C;KACX,CAAC;;yCACoC;AA1D3B,UAAU;IADtB,MAAM,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;GACd,UAAU,CA2DtB"}
|
package/dist/entities/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export * from "./account.entity.js";
|
|
2
|
+
export * from "./api-key.entity.js";
|
|
2
3
|
export * from "./session.entity.js";
|
|
3
4
|
export * from "./user.entity.js";
|
|
4
5
|
export * from "./verification.entity.js";
|
|
6
|
+
export * from "./workspace.entity.js";
|
|
7
|
+
export * from "./workspace-invitation.entity.js";
|
|
8
|
+
export * from "./workspace-member.entity.js";
|
package/dist/entities/index.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export * from "./account.entity.js";
|
|
2
|
+
export * from "./api-key.entity.js";
|
|
2
3
|
export * from "./session.entity.js";
|
|
3
4
|
export * from "./user.entity.js";
|
|
4
5
|
export * from "./verification.entity.js";
|
|
6
|
+
export * from "./workspace.entity.js";
|
|
7
|
+
export * from "./workspace-invitation.entity.js";
|
|
8
|
+
export * from "./workspace-member.entity.js";
|
|
5
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/entities/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/entities/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type Constructor, type EntityClass } from "@mikro-orm/core";
|
|
2
|
+
export declare function configureAuthRelationTargets(entries: Iterable<readonly [Constructor<object>, EntityClass<object>]>): void;
|
|
3
|
+
export declare function resolveAuthRelationTarget<Entity extends object>(baseEntity: Constructor<Entity>, conventionalName: string): EntityClass<Entity> | string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { MetadataStorage, } from "@mikro-orm/core";
|
|
2
|
+
let configuredTargets = new Map();
|
|
3
|
+
export function configureAuthRelationTargets(entries) {
|
|
4
|
+
configuredTargets = new Map(entries);
|
|
5
|
+
}
|
|
6
|
+
export function resolveAuthRelationTarget(baseEntity, conventionalName) {
|
|
7
|
+
const configuredTarget = configuredTargets.get(baseEntity);
|
|
8
|
+
if (configuredTarget)
|
|
9
|
+
return configuredTarget;
|
|
10
|
+
const candidates = new Set();
|
|
11
|
+
for (const metadata of Object.values(MetadataStorage.getMetadata())) {
|
|
12
|
+
const entity = metadata.class;
|
|
13
|
+
if (metadata.name &&
|
|
14
|
+
entity &&
|
|
15
|
+
entity !== baseEntity &&
|
|
16
|
+
entity.prototype instanceof baseEntity) {
|
|
17
|
+
candidates.add(entity);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const conventionalEntity = [...candidates].find((entity) => entity.name === conventionalName);
|
|
21
|
+
if (conventionalEntity)
|
|
22
|
+
return conventionalEntity;
|
|
23
|
+
const [onlyCandidate] = candidates;
|
|
24
|
+
if (candidates.size === 1 && onlyCandidate)
|
|
25
|
+
return onlyCandidate;
|
|
26
|
+
if (candidates.size === 0)
|
|
27
|
+
return conventionalName;
|
|
28
|
+
throw new Error(`Multiple concrete entities extend ${baseEntity.name}; unable to resolve the auth relation target`);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=resolve-auth-relation-target.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-auth-relation-target.js","sourceRoot":"","sources":["../../src/entities/resolve-auth-relation-target.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,GAChB,MAAM,iBAAiB,CAAC;AAEzB,IAAI,iBAAiB,GAAG,IAAI,GAAG,EAA4C,CAAC;AAG5E,MAAM,UAAU,4BAA4B,CAC1C,OAAsE;IAEtE,iBAAiB,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;AACvC,CAAC;AAGD,MAAM,UAAU,yBAAyB,CACvC,UAA+B,EAC/B,gBAAwB;IAExB,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC3D,IAAI,gBAAgB;QAAE,OAAO,gBAAuC,CAAC;IAErE,MAAM,UAAU,GAAG,IAAI,GAAG,EAAuB,CAAC;IAElD,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;QACpE,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAwC,CAAC;QACjE,IACE,QAAQ,CAAC,IAAI;YACb,MAAM;YACN,MAAM,KAAK,UAAU;YACrB,MAAM,CAAC,SAAS,YAAY,UAAU,EACtC,CAAC;YACD,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IAED,MAAM,kBAAkB,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC,IAAI,CAC7C,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,gBAAgB,CAC7C,CAAC;IACF,IAAI,kBAAkB;QAAE,OAAO,kBAAkB,CAAC;IAClD,MAAM,CAAC,aAAa,CAAC,GAAG,UAAU,CAAC;IACnC,IAAI,UAAU,CAAC,IAAI,KAAK,CAAC,IAAI,aAAa;QAAE,OAAO,aAAa,CAAC;IACjE,IAAI,UAAU,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,gBAAgB,CAAC;IAEnD,MAAM,IAAI,KAAK,CACb,qCAAqC,UAAU,CAAC,IAAI,8CAA8C,CACnG,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { BaseEntity, type Opt } from "@mikro-orm/core";
|
|
1
|
+
import { BaseEntity, type Opt, type Ref } from "@mikro-orm/core";
|
|
2
|
+
import { BaseUser } from "./user.entity.js";
|
|
2
3
|
export declare class BaseSession extends BaseEntity {
|
|
3
4
|
id: Opt<string>;
|
|
4
5
|
token: string;
|
|
@@ -6,6 +7,7 @@ export declare class BaseSession extends BaseEntity {
|
|
|
6
7
|
expiresAt: Date;
|
|
7
8
|
ipAddress?: Opt<string>;
|
|
8
9
|
userAgent?: Opt<string>;
|
|
10
|
+
impersonatedBy?: Ref<BaseUser> | null;
|
|
9
11
|
createdAt: Opt<Date>;
|
|
10
12
|
updatedAt: Opt<Date>;
|
|
11
13
|
}
|