@etohq/user 1.3.0 → 1.5.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/LICENSE +21 -0
- package/dist/migrations/Migration20240214033943.d.ts +6 -0
- package/dist/migrations/Migration20240214033943.d.ts.map +1 -0
- package/dist/migrations/Migration20240214033943.js +25 -0
- package/dist/migrations/Migration20240214033943.js.map +1 -0
- package/dist/migrations/Migration20240703095850.d.ts +6 -0
- package/dist/migrations/Migration20240703095850.d.ts.map +1 -0
- package/dist/migrations/Migration20240703095850.js +17 -0
- package/dist/migrations/Migration20240703095850.js.map +1 -0
- package/dist/migrations/Migration20241202103352.d.ts +6 -0
- package/dist/migrations/Migration20241202103352.d.ts.map +1 -0
- package/dist/migrations/Migration20241202103352.js +20 -0
- package/dist/migrations/Migration20241202103352.js.map +1 -0
- package/dist/models/index.d.ts +4 -4
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +4 -7
- package/dist/models/index.js.map +1 -1
- package/dist/models/invite.d.ts +1 -2
- package/dist/models/invite.d.ts.map +1 -1
- package/dist/models/invite.js +2 -2
- package/dist/models/invite.js.map +1 -1
- package/dist/models/role.d.ts +1 -2
- package/dist/models/role.d.ts.map +1 -1
- package/dist/models/role.js +2 -2
- package/dist/models/role.js.map +1 -1
- package/dist/models/user-term-of-service.d.ts +1 -2
- package/dist/models/user-term-of-service.d.ts.map +1 -1
- package/dist/models/user-term-of-service.js +2 -2
- package/dist/models/user-term-of-service.js.map +1 -1
- package/dist/models/user.d.ts +1 -22
- package/dist/models/user.d.ts.map +1 -1
- package/dist/models/user.js +2 -66
- package/dist/models/user.js.map +1 -1
- package/dist/services/user-module.d.ts +6 -3
- package/dist/services/user-module.d.ts.map +1 -1
- package/dist/services/user-module.js +82 -45
- package/dist/services/user-module.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/utils.d.ts +2 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/utils/utils.js +14 -0
- package/dist/utils/utils.js.map +1 -0
- package/package.json +29 -29
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Etohq
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration20240214033943.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20240214033943.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,qBAAa,uBAAwB,SAAQ,SAAS;IAC9C,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IA2CnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAK5B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Migration20240214033943 = void 0;
|
|
4
|
+
const utils_1 = require("@etohq/framework/utils");
|
|
5
|
+
const migrations_1 = require("@mikro-orm/migrations");
|
|
6
|
+
class Migration20240214033943 extends migrations_1.Migration {
|
|
7
|
+
async up() {
|
|
8
|
+
this.addSql('create table if not exists "invite" ("id" text not null, "email" text not null, "accepted" boolean not null default false, "token" text not null, "expires_at" timestamptz not null, "metadata" jsonb null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "invite_pkey" primary key ("id"));');
|
|
9
|
+
this.addSql('alter table "invite" add column if not exists "email" text not null;');
|
|
10
|
+
this.addSql((0, utils_1.generatePostgresAlterColummnIfExistStatement)("invite", ["user_email"], "DROP NOT NULL"));
|
|
11
|
+
this.addSql('CREATE UNIQUE INDEX IF NOT EXISTS "IDX_invite_email" ON "invite" (email) WHERE deleted_at IS NULL;');
|
|
12
|
+
this.addSql('CREATE INDEX IF NOT EXISTS "IDX_invite_token" ON "invite" (token) WHERE deleted_at IS NULL;');
|
|
13
|
+
this.addSql('CREATE INDEX IF NOT EXISTS "IDX_invite_deleted_at" ON "invite" (deleted_at) WHERE deleted_at IS NOT NULL;');
|
|
14
|
+
this.addSql('create table if not exists "user" ("id" text not null, "first_name" text null, "last_name" text null, "email" text not null, "avatar_url" text null, "metadata" jsonb null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "user_pkey" primary key ("id"));');
|
|
15
|
+
this.addSql('alter table "user" add column if not exists "avatar_url" text null;');
|
|
16
|
+
this.addSql('CREATE INDEX IF NOT EXISTS "IDX_user_email" ON "user" (email) WHERE deleted_at IS NULL;');
|
|
17
|
+
this.addSql('CREATE INDEX IF NOT EXISTS "IDX_user_deleted_at" ON "user" (deleted_at) WHERE deleted_at IS NOT NULL;');
|
|
18
|
+
}
|
|
19
|
+
async down() {
|
|
20
|
+
this.addSql('drop table if exists "invite" cascade;');
|
|
21
|
+
this.addSql('drop table if exists "user" cascade;');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.Migration20240214033943 = Migration20240214033943;
|
|
25
|
+
//# sourceMappingURL=Migration20240214033943.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration20240214033943.js","sourceRoot":"","sources":["../../src/migrations/Migration20240214033943.ts"],"names":[],"mappings":";;;AAAA,kDAAqF;AACrF,sDAAiD;AAEjD,MAAa,uBAAwB,SAAQ,sBAAS;IACpD,KAAK,CAAC,EAAE;QACN,IAAI,CAAC,MAAM,CACT,4XAA4X,CAC7X,CAAA;QACD,IAAI,CAAC,MAAM,CACT,sEAAsE,CACvE,CAAA;QAED,IAAI,CAAC,MAAM,CACT,IAAA,oDAA4C,EAC1C,QAAQ,EACR,CAAC,YAAY,CAAC,EACd,eAAe,CAChB,CACF,CAAA;QAED,IAAI,CAAC,MAAM,CACT,oGAAoG,CACrG,CAAA;QAED,IAAI,CAAC,MAAM,CACT,6FAA6F,CAC9F,CAAA;QACD,IAAI,CAAC,MAAM,CACT,2GAA2G,CAC5G,CAAA;QAED,IAAI,CAAC,MAAM,CACT,0VAA0V,CAC3V,CAAA;QAED,IAAI,CAAC,MAAM,CACT,qEAAqE,CACtE,CAAA;QAED,IAAI,CAAC,MAAM,CACT,yFAAyF,CAC1F,CAAA;QACD,IAAI,CAAC,MAAM,CACT,uGAAuG,CACxG,CAAA;IACH,CAAC;IAED,KAAK,CAAC,IAAI;QACR,IAAI,CAAC,MAAM,CAAC,wCAAwC,CAAC,CAAA;QAErD,IAAI,CAAC,MAAM,CAAC,sCAAsC,CAAC,CAAA;IACrD,CAAC;CACF;AAjDD,0DAiDC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration20240703095850.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20240703095850.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,qBAAa,uBAAwB,SAAQ,SAAS;IAC9C,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAYnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAK5B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Migration20240703095850 = void 0;
|
|
4
|
+
const migrations_1 = require("@mikro-orm/migrations");
|
|
5
|
+
class Migration20240703095850 extends migrations_1.Migration {
|
|
6
|
+
async up() {
|
|
7
|
+
this.addSql('drop index if exists "IDX_user_email";');
|
|
8
|
+
this.addSql('CREATE UNIQUE INDEX "IDX_user_email" ON "user" (email) WHERE deleted_at IS NULL;');
|
|
9
|
+
// Adding this log here as the point of failure is not in this function, but bundled up when running all pending migration
|
|
10
|
+
console.info(`Note: If the index "IDX_user_email" fails to create, then delete any existing users with duplicate emails before retrying the migration.`);
|
|
11
|
+
}
|
|
12
|
+
async down() {
|
|
13
|
+
this.addSql('CREATE INDEX IF NOT EXISTS "IDX_user_email" ON "user" (email) WHERE deleted_at IS NULL;');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.Migration20240703095850 = Migration20240703095850;
|
|
17
|
+
//# sourceMappingURL=Migration20240703095850.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration20240703095850.js","sourceRoot":"","sources":["../../src/migrations/Migration20240703095850.ts"],"names":[],"mappings":";;;AAAA,sDAAiD;AAEjD,MAAa,uBAAwB,SAAQ,sBAAS;IACpD,KAAK,CAAC,EAAE;QACN,IAAI,CAAC,MAAM,CAAC,wCAAwC,CAAC,CAAA;QAErD,IAAI,CAAC,MAAM,CACT,kFAAkF,CACnF,CAAA;QACD,0HAA0H;QAC1H,OAAO,CAAC,IAAI,CACV,0IAA0I,CAC3I,CAAA;IACH,CAAC;IAED,KAAK,CAAC,IAAI;QACR,IAAI,CAAC,MAAM,CACT,yFAAyF,CAC1F,CAAA;IACH,CAAC;CACF;AAlBD,0DAkBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration20241202103352.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20241202103352.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,qBAAa,uBAAwB,SAAQ,SAAS;IAE9C,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAQnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ5B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Migration20241202103352 = void 0;
|
|
4
|
+
const migrations_1 = require("@mikro-orm/migrations");
|
|
5
|
+
class Migration20241202103352 extends migrations_1.Migration {
|
|
6
|
+
async up() {
|
|
7
|
+
this.addSql('drop index if exists "IDX_invite_email";');
|
|
8
|
+
this.addSql('CREATE UNIQUE INDEX IF NOT EXISTS "IDX_invite_email_unique" ON "invite" (email) WHERE deleted_at IS NULL;');
|
|
9
|
+
this.addSql('drop index if exists "IDX_user_email";');
|
|
10
|
+
this.addSql('CREATE UNIQUE INDEX IF NOT EXISTS "IDX_user_email_unique" ON "user" (email) WHERE deleted_at IS NULL;');
|
|
11
|
+
}
|
|
12
|
+
async down() {
|
|
13
|
+
this.addSql('drop index if exists "IDX_invite_email_unique";');
|
|
14
|
+
this.addSql('CREATE UNIQUE INDEX IF NOT EXISTS "IDX_invite_email" ON "invite" (email) WHERE deleted_at IS NULL;');
|
|
15
|
+
this.addSql('drop index if exists "IDX_user_email_unique";');
|
|
16
|
+
this.addSql('CREATE UNIQUE INDEX IF NOT EXISTS "IDX_user_email" ON "user" (email) WHERE deleted_at IS NULL;');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.Migration20241202103352 = Migration20241202103352;
|
|
20
|
+
//# sourceMappingURL=Migration20241202103352.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration20241202103352.js","sourceRoot":"","sources":["../../src/migrations/Migration20241202103352.ts"],"names":[],"mappings":";;;AAAA,sDAAkD;AAElD,MAAa,uBAAwB,SAAQ,sBAAS;IAEpD,KAAK,CAAC,EAAE;QACN,IAAI,CAAC,MAAM,CAAC,0CAA0C,CAAC,CAAC;QACxD,IAAI,CAAC,MAAM,CAAC,2GAA2G,CAAC,CAAC;QAEzH,IAAI,CAAC,MAAM,CAAC,wCAAwC,CAAC,CAAC;QACtD,IAAI,CAAC,MAAM,CAAC,uGAAuG,CAAC,CAAC;IACvH,CAAC;IAED,KAAK,CAAC,IAAI;QACR,IAAI,CAAC,MAAM,CAAC,iDAAiD,CAAC,CAAC;QAC/D,IAAI,CAAC,MAAM,CAAC,oGAAoG,CAAC,CAAC;QAElH,IAAI,CAAC,MAAM,CAAC,+CAA+C,CAAC,CAAC;QAC7D,IAAI,CAAC,MAAM,CAAC,gGAAgG,CAAC,CAAC;IAChH,CAAC;CAEF;AAlBD,0DAkBC"}
|
package/dist/models/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
1
|
+
export { User } from "./user";
|
|
2
|
+
export { Invite } from "./invite";
|
|
3
|
+
export { Role } from "./role";
|
|
4
|
+
export { UserTermsOfService } from "./user-term-of-service";
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA"}
|
package/dist/models/index.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.UserTermsOfService = exports.Role = exports.Invite = exports.User = void 0;
|
|
7
4
|
var user_1 = require("./user");
|
|
8
|
-
Object.defineProperty(exports, "User", { enumerable: true, get: function () { return
|
|
5
|
+
Object.defineProperty(exports, "User", { enumerable: true, get: function () { return user_1.User; } });
|
|
9
6
|
var invite_1 = require("./invite");
|
|
10
|
-
Object.defineProperty(exports, "Invite", { enumerable: true, get: function () { return
|
|
7
|
+
Object.defineProperty(exports, "Invite", { enumerable: true, get: function () { return invite_1.Invite; } });
|
|
11
8
|
var role_1 = require("./role");
|
|
12
|
-
Object.defineProperty(exports, "Role", { enumerable: true, get: function () { return
|
|
9
|
+
Object.defineProperty(exports, "Role", { enumerable: true, get: function () { return role_1.Role; } });
|
|
13
10
|
var user_term_of_service_1 = require("./user-term-of-service");
|
|
14
|
-
Object.defineProperty(exports, "UserTermsOfService", { enumerable: true, get: function () { return
|
|
11
|
+
Object.defineProperty(exports, "UserTermsOfService", { enumerable: true, get: function () { return user_term_of_service_1.UserTermsOfService; } });
|
|
15
12
|
//# sourceMappingURL=index.js.map
|
package/dist/models/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":";;;AAAA,+BAA6B;AAApB,4FAAA,IAAI,OAAA;AACb,mCAAiC;AAAxB,gGAAA,MAAM,OAAA;AACf,+BAA6B;AAApB,4FAAA,IAAI,OAAA;AACb,+DAA2D;AAAlD,0HAAA,kBAAkB,OAAA"}
|
package/dist/models/invite.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const Invite: import("@etohq/framework/utils").DmlEntity<import("@etohq/framework/utils").DMLEntitySchemaBuilder<{
|
|
1
|
+
export declare const Invite: import("@etohq/framework/utils").DmlEntity<import("@etohq/framework/utils").DMLEntitySchemaBuilder<{
|
|
2
2
|
id: import("@etohq/framework/utils").PrimaryKeyModifier<string, import("@etohq/framework/utils").IdProperty>;
|
|
3
3
|
email: import("@etohq/framework/utils").TextProperty;
|
|
4
4
|
accepted: import("@etohq/framework/utils").BooleanProperty;
|
|
@@ -6,5 +6,4 @@ declare const Invite: import("@etohq/framework/utils").DmlEntity<import("@etohq/
|
|
|
6
6
|
expires_at: import("@etohq/framework/utils").DateTimeProperty;
|
|
7
7
|
metadata: import("@etohq/framework/utils").NullableModifier<Record<string, unknown>, import("@etohq/framework/utils").JSONProperty>;
|
|
8
8
|
}>, "invite">;
|
|
9
|
-
export default Invite;
|
|
10
9
|
//# sourceMappingURL=invite.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invite.d.ts","sourceRoot":"","sources":["../../src/models/invite.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"invite.d.ts","sourceRoot":"","sources":["../../src/models/invite.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM;;;;;;;aAmBf,CAAA"}
|
package/dist/models/invite.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Invite = void 0;
|
|
3
4
|
const utils_1 = require("@etohq/framework/utils");
|
|
4
|
-
|
|
5
|
+
exports.Invite = utils_1.model
|
|
5
6
|
.define("invite", {
|
|
6
7
|
id: utils_1.model.id({ prefix: "invite" }).primaryKey(),
|
|
7
8
|
email: utils_1.model.text().searchable(),
|
|
@@ -21,5 +22,4 @@ const Invite = utils_1.model
|
|
|
21
22
|
where: "deleted_at IS NULL",
|
|
22
23
|
},
|
|
23
24
|
]);
|
|
24
|
-
exports.default = Invite;
|
|
25
25
|
//# sourceMappingURL=invite.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invite.js","sourceRoot":"","sources":["../../src/models/invite.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"invite.js","sourceRoot":"","sources":["../../src/models/invite.ts"],"names":[],"mappings":";;;AAAA,kDAA8C;AAEjC,QAAA,MAAM,GAAG,aAAK;KACxB,MAAM,CAAC,QAAQ,EAAE;IAChB,EAAE,EAAE,aAAK,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC,UAAU,EAAE;IAC/C,KAAK,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE;IAChC,QAAQ,EAAE,aAAK,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IACxC,KAAK,EAAE,aAAK,CAAC,IAAI,EAAE;IACnB,UAAU,EAAE,aAAK,CAAC,QAAQ,EAAE;IAC5B,QAAQ,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;CAClC,CAAC;KACD,OAAO,CAAC;IACP;QACE,EAAE,EAAE,CAAC,OAAO,CAAC;QACb,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,oBAAoB;KAC5B;IACD;QACE,EAAE,EAAE,CAAC,OAAO,CAAC;QACb,KAAK,EAAE,oBAAoB;KAC5B;CACF,CAAC,CAAA"}
|
package/dist/models/role.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const Role: import("@etohq/framework/utils").DmlEntity<import("@etohq/framework/utils").DMLEntitySchemaBuilder<{
|
|
1
|
+
export declare const Role: import("@etohq/framework/utils").DmlEntity<import("@etohq/framework/utils").DMLEntitySchemaBuilder<{
|
|
2
2
|
id: import("@etohq/framework/utils").PrimaryKeyModifier<string, import("@etohq/framework/utils").TextProperty>;
|
|
3
3
|
name: import("@etohq/framework/utils").NullableModifier<string, import("@etohq/framework/utils").TextProperty>;
|
|
4
4
|
display_name: import("@etohq/framework/utils").NullableModifier<string, import("@etohq/framework/utils").TextProperty>;
|
|
@@ -7,5 +7,4 @@ declare const Role: import("@etohq/framework/utils").DmlEntity<import("@etohq/fr
|
|
|
7
7
|
scheme_managed: import("@etohq/framework/utils").NullableModifier<boolean, import("@etohq/framework/utils").BooleanProperty>;
|
|
8
8
|
built_in: import("@etohq/framework/utils").NullableModifier<boolean, import("@etohq/framework/utils").BooleanProperty>;
|
|
9
9
|
}>, "Role">;
|
|
10
|
-
export default Role;
|
|
11
10
|
//# sourceMappingURL=role.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role.d.ts","sourceRoot":"","sources":["../../src/models/role.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"role.d.ts","sourceRoot":"","sources":["../../src/models/role.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI;;;;;;;;WAQf,CAAA"}
|
package/dist/models/role.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Role = void 0;
|
|
3
4
|
const utils_1 = require("@etohq/framework/utils");
|
|
4
|
-
|
|
5
|
+
exports.Role = utils_1.model.define("Role", {
|
|
5
6
|
id: utils_1.model.text().primaryKey(),
|
|
6
7
|
name: utils_1.model.text().unique("roles_name_key").nullable(),
|
|
7
8
|
display_name: utils_1.model.text().nullable(),
|
|
@@ -10,5 +11,4 @@ const Role = utils_1.model.define("Role", {
|
|
|
10
11
|
scheme_managed: utils_1.model.boolean().nullable(),
|
|
11
12
|
built_in: utils_1.model.boolean().nullable(),
|
|
12
13
|
});
|
|
13
|
-
exports.default = Role;
|
|
14
14
|
//# sourceMappingURL=role.js.map
|
package/dist/models/role.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role.js","sourceRoot":"","sources":["../../src/models/role.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"role.js","sourceRoot":"","sources":["../../src/models/role.ts"],"names":[],"mappings":";;;AAAA,kDAA8C;AAEjC,QAAA,IAAI,GAAG,aAAK,CAAC,MAAM,CAAC,MAAM,EAAE;IACvC,EAAE,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE;IAC7B,IAAI,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,QAAQ,EAAE;IACtD,YAAY,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IACrC,WAAW,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IACpC,WAAW,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IACpC,cAAc,EAAE,aAAK,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC1C,QAAQ,EAAE,aAAK,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;CACrC,CAAC,CAAA"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
declare const UserTermsOfService: import("@etohq/framework/utils").DmlEntity<import("@etohq/framework/utils").DMLEntitySchemaBuilder<{
|
|
1
|
+
export declare const UserTermsOfService: import("@etohq/framework/utils").DmlEntity<import("@etohq/framework/utils").DMLEntitySchemaBuilder<{
|
|
2
2
|
user_id: import("@etohq/framework/utils").PrimaryKeyModifier<string, import("@etohq/framework/utils").TextProperty>;
|
|
3
3
|
terms_of_service_id: import("@etohq/framework/utils").NullableModifier<string, import("@etohq/framework/utils").TextProperty>;
|
|
4
4
|
}>, "use_terms_of_service">;
|
|
5
|
-
export default UserTermsOfService;
|
|
6
5
|
//# sourceMappingURL=user-term-of-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-term-of-service.d.ts","sourceRoot":"","sources":["../../src/models/user-term-of-service.ts"],"names":[],"mappings":"AAKA,
|
|
1
|
+
{"version":3,"file":"user-term-of-service.d.ts","sourceRoot":"","sources":["../../src/models/user-term-of-service.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,kBAAkB;;;2BAG7B,CAAA"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserTermsOfService = void 0;
|
|
3
4
|
const utils_1 = require("@etohq/framework/utils");
|
|
4
5
|
// UserTermsOfService
|
|
5
6
|
// Description: Tracks user acceptance of terms of service.
|
|
6
7
|
// Why: Ensures legal compliance with user agreements.
|
|
7
|
-
|
|
8
|
+
exports.UserTermsOfService = utils_1.model.define("use_terms_of_service", {
|
|
8
9
|
user_id: utils_1.model.text().primaryKey(),
|
|
9
10
|
terms_of_service_id: utils_1.model.text().nullable(),
|
|
10
11
|
});
|
|
11
|
-
exports.default = UserTermsOfService;
|
|
12
12
|
//# sourceMappingURL=user-term-of-service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-term-of-service.js","sourceRoot":"","sources":["../../src/models/user-term-of-service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"user-term-of-service.js","sourceRoot":"","sources":["../../src/models/user-term-of-service.ts"],"names":[],"mappings":";;;AAAA,kDAA8C;AAE9C,qBAAqB;AACrB,2DAA2D;AAC3D,sDAAsD;AACzC,QAAA,kBAAkB,GAAG,aAAK,CAAC,MAAM,CAAC,sBAAsB,EAAE;IACrE,OAAO,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE;IAClC,mBAAmB,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;CAC7C,CAAC,CAAA"}
|
package/dist/models/user.d.ts
CHANGED
|
@@ -1,30 +1,9 @@
|
|
|
1
|
-
declare const User: import("@etohq/framework/utils").DmlEntity<import("@etohq/framework/utils").DMLEntitySchemaBuilder<{
|
|
1
|
+
export declare const User: import("@etohq/framework/utils").DmlEntity<import("@etohq/framework/utils").DMLEntitySchemaBuilder<{
|
|
2
2
|
id: import("@etohq/framework/utils").PrimaryKeyModifier<string, import("@etohq/framework/utils").IdProperty>;
|
|
3
3
|
first_name: import("@etohq/framework/utils").NullableModifier<string, import("@etohq/framework/utils").TextProperty>;
|
|
4
4
|
last_name: import("@etohq/framework/utils").NullableModifier<string, import("@etohq/framework/utils").TextProperty>;
|
|
5
|
-
user_name: import("@etohq/framework/utils").NullableModifier<string, import("@etohq/framework/utils").TextProperty>;
|
|
6
5
|
email: import("@etohq/framework/utils").TextProperty;
|
|
7
|
-
email_verified: import("@etohq/framework/utils").NullableModifier<boolean, import("@etohq/framework/utils").BooleanProperty>;
|
|
8
6
|
avatar_url: import("@etohq/framework/utils").NullableModifier<string, import("@etohq/framework/utils").TextProperty>;
|
|
9
|
-
auth_data: import("@etohq/framework/utils").NullableModifier<string, import("@etohq/framework/utils").TextProperty>;
|
|
10
|
-
auth_service: import("@etohq/framework/utils").NullableModifier<string, import("@etohq/framework/utils").TextProperty>;
|
|
11
|
-
nick_name: import("@etohq/framework/utils").NullableModifier<string, import("@etohq/framework/utils").TextProperty>;
|
|
12
|
-
roles: import("@etohq/framework/utils").NullableModifier<string, import("@etohq/framework/utils").TextProperty>;
|
|
13
|
-
allow_marketing: import("@etohq/framework/utils").NullableModifier<boolean, import("@etohq/framework/utils").BooleanProperty>;
|
|
14
|
-
props: import("@etohq/framework/utils").NullableModifier<Record<string, unknown>, import("@etohq/framework/utils").JSONProperty>;
|
|
15
|
-
notify_props: import("@etohq/framework/utils").NullableModifier<Record<string, unknown>, import("@etohq/framework/utils").JSONProperty>;
|
|
16
|
-
last_password_update: import("@etohq/framework/utils").NullableModifier<number, import("@etohq/framework/utils").BigNumberProperty>;
|
|
17
|
-
last_picture_update: import("@etohq/framework/utils").NullableModifier<number, import("@etohq/framework/utils").BigNumberProperty>;
|
|
18
|
-
failed_attempts: import("@etohq/framework/utils").NullableModifier<number, import("@etohq/framework/utils").NumberProperty>;
|
|
19
|
-
locale: import("@etohq/framework/utils").NullableModifier<string, import("@etohq/framework/utils").TextProperty>;
|
|
20
|
-
mfa_active: import("@etohq/framework/utils").NullableModifier<boolean, import("@etohq/framework/utils").BooleanProperty>;
|
|
21
|
-
mfa_secret: import("@etohq/framework/utils").NullableModifier<string, import("@etohq/framework/utils").TextProperty>;
|
|
22
|
-
position: import("@etohq/framework/utils").NullableModifier<string, import("@etohq/framework/utils").TextProperty>;
|
|
23
|
-
time_zone: import("@etohq/framework/utils").NullableModifier<Record<string, unknown>, import("@etohq/framework/utils").JSONProperty>;
|
|
24
|
-
remote_id: import("@etohq/framework/utils").NullableModifier<string, import("@etohq/framework/utils").TextProperty>;
|
|
25
|
-
last_login: import("@etohq/framework/utils").BigNumberProperty;
|
|
26
|
-
mfa_used_timestamps: import("@etohq/framework/utils").NullableModifier<Record<string, unknown>, import("@etohq/framework/utils").JSONProperty>;
|
|
27
7
|
metadata: import("@etohq/framework/utils").NullableModifier<Record<string, unknown>, import("@etohq/framework/utils").JSONProperty>;
|
|
28
8
|
}>, "user">;
|
|
29
|
-
export default User;
|
|
30
9
|
//# sourceMappingURL=user.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/models/user.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/models/user.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI;;;;;;;WAeb,CAAA"}
|
package/dist/models/user.js
CHANGED
|
@@ -1,33 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.User = void 0;
|
|
3
4
|
const utils_1 = require("@etohq/framework/utils");
|
|
4
|
-
|
|
5
|
+
exports.User = utils_1.model
|
|
5
6
|
.define("user", {
|
|
6
7
|
id: utils_1.model.id({ prefix: "user" }).primaryKey(),
|
|
7
8
|
first_name: utils_1.model.text().searchable().nullable(),
|
|
8
9
|
last_name: utils_1.model.text().searchable().nullable(),
|
|
9
|
-
user_name: utils_1.model.text().unique().searchable().nullable(),
|
|
10
10
|
email: utils_1.model.text().searchable(),
|
|
11
|
-
email_verified: utils_1.model.boolean().nullable(),
|
|
12
11
|
avatar_url: utils_1.model.text().nullable(),
|
|
13
|
-
auth_data: utils_1.model.text().unique("users_authdata_key").nullable(),
|
|
14
|
-
auth_service: utils_1.model.text().nullable(),
|
|
15
|
-
nick_name: utils_1.model.text().searchable().nullable(),
|
|
16
|
-
roles: utils_1.model.text().nullable(),
|
|
17
|
-
allow_marketing: utils_1.model.boolean().nullable(),
|
|
18
|
-
props: utils_1.model.json().nullable(),
|
|
19
|
-
notify_props: utils_1.model.json().nullable(), // notification config at global level.
|
|
20
|
-
last_password_update: utils_1.model.bigNumber().nullable(),
|
|
21
|
-
last_picture_update: utils_1.model.bigNumber().nullable(),
|
|
22
|
-
failed_attempts: utils_1.model.number().nullable(),
|
|
23
|
-
locale: utils_1.model.text().nullable(),
|
|
24
|
-
mfa_active: utils_1.model.boolean().nullable(),
|
|
25
|
-
mfa_secret: utils_1.model.text().nullable(),
|
|
26
|
-
position: utils_1.model.text().nullable(),
|
|
27
|
-
time_zone: utils_1.model.json().nullable(),
|
|
28
|
-
remote_id: utils_1.model.text().nullable(),
|
|
29
|
-
last_login: utils_1.model.bigNumber().default(0),
|
|
30
|
-
mfa_used_timestamps: utils_1.model.json().nullable(),
|
|
31
12
|
metadata: utils_1.model.json().nullable(),
|
|
32
13
|
})
|
|
33
14
|
.indexes([
|
|
@@ -36,50 +17,5 @@ const User = utils_1.model
|
|
|
36
17
|
on: ["email"],
|
|
37
18
|
where: "deleted_at IS NULL",
|
|
38
19
|
},
|
|
39
|
-
{
|
|
40
|
-
name: "idx_users_all_no_full_name_txt",
|
|
41
|
-
on: ["user_name", "nick_name", "email"],
|
|
42
|
-
unique: false,
|
|
43
|
-
}, // Approximation for GIN
|
|
44
|
-
{
|
|
45
|
-
name: "idx_users_all_txt",
|
|
46
|
-
on: ["user_name", "first_name", "last_name", "nick_name", "email"],
|
|
47
|
-
unique: false,
|
|
48
|
-
}, // Approximation for GIN
|
|
49
|
-
{ name: "idx_users_created_at", on: ["created_at"], unique: false },
|
|
50
|
-
{ name: "idx_users_deleted_at", on: ["deleted_at"], unique: false },
|
|
51
|
-
{ name: "idx_users_email_lower_textpattern", on: ["email"], unique: false },
|
|
52
|
-
{
|
|
53
|
-
name: "idx_users_firstname_lower_textpattern",
|
|
54
|
-
on: ["first_name"],
|
|
55
|
-
unique: false,
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
name: "idx_users_lastname_lower_textpattern",
|
|
59
|
-
on: ["last_name"],
|
|
60
|
-
unique: false,
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
name: "idx_users_names_no_full_name_txt",
|
|
64
|
-
on: ["user_name", "nick_name"],
|
|
65
|
-
unique: false,
|
|
66
|
-
}, // Approximation for GIN
|
|
67
|
-
{
|
|
68
|
-
name: "idx_users_names_txt",
|
|
69
|
-
on: ["user_name", "first_name", "last_name", "nick_name"],
|
|
70
|
-
unique: false,
|
|
71
|
-
}, // Approximation for GIN
|
|
72
|
-
{
|
|
73
|
-
name: "idx_users_nickname_lower_textpattern",
|
|
74
|
-
on: ["nick_name"],
|
|
75
|
-
unique: false,
|
|
76
|
-
},
|
|
77
|
-
{ name: "idx_users_updated_at", on: ["updated_at"], unique: false },
|
|
78
|
-
{
|
|
79
|
-
name: "idx_users_username_lower_textpattern",
|
|
80
|
-
on: ["user_name"],
|
|
81
|
-
unique: false,
|
|
82
|
-
},
|
|
83
20
|
]);
|
|
84
|
-
exports.default = User;
|
|
85
21
|
//# sourceMappingURL=user.js.map
|
package/dist/models/user.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../src/models/user.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../src/models/user.ts"],"names":[],"mappings":";;;AAAA,kDAA8C;AAEjC,QAAA,IAAI,GAAG,aAAK;KACtB,MAAM,CAAC,MAAM,EAAE;IACd,EAAE,EAAE,aAAK,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,UAAU,EAAE;IAC7C,UAAU,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE;IAChD,SAAS,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE;IAC/C,KAAK,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE;IAChC,UAAU,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IACnC,QAAQ,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;CAClC,CAAC;KACD,OAAO,CAAC;IACP;QACE,MAAM,EAAE,IAAI;QACZ,EAAE,EAAE,CAAC,OAAO,CAAC;QACb,KAAK,EAAE,oBAAoB;KAC5B;CACF,CAAC,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Context, DAL, InferEntityType, InternalModuleDeclaration, ModulesSdkTypes, UserTypes } from "@etohq/framework/types";
|
|
1
|
+
import { Context, DAL, InferEntityType, InternalModuleDeclaration, ModulesSdkTypes, ProjectConfigOptions, UserTypes } from "@etohq/framework/types";
|
|
2
2
|
import { Invite, User } from "../models";
|
|
3
3
|
type InjectedDependencies = {
|
|
4
4
|
baseRepository: DAL.RepositoryService;
|
|
@@ -14,13 +14,16 @@ declare const UserModuleService_base: import("@etohq/framework/utils").EtoServic
|
|
|
14
14
|
};
|
|
15
15
|
}>;
|
|
16
16
|
export default class UserModuleService extends UserModuleService_base implements UserTypes.IUserModuleService {
|
|
17
|
-
protected readonly moduleDeclaration: InternalModuleDeclaration;
|
|
18
17
|
protected baseRepository_: DAL.RepositoryService;
|
|
19
18
|
protected readonly userService_: ModulesSdkTypes.IEtoInternalService<InferEntityType<typeof User>>;
|
|
20
19
|
protected readonly inviteService_: ModulesSdkTypes.IEtoInternalService<InferEntityType<typeof Invite>>;
|
|
21
20
|
protected readonly config: {
|
|
22
21
|
jwtSecret: string;
|
|
23
|
-
|
|
22
|
+
jwtPublicKey?: string;
|
|
23
|
+
jwt_verify_options: ProjectConfigOptions["http"]["jwtVerifyOptions"];
|
|
24
|
+
jwtOptions: ProjectConfigOptions["http"]["jwtOptions"] & {
|
|
25
|
+
expiresIn: number;
|
|
26
|
+
};
|
|
24
27
|
};
|
|
25
28
|
constructor({ userService, inviteService, baseRepository }: InjectedDependencies, moduleDeclaration: InternalModuleDeclaration);
|
|
26
29
|
validateInviteToken(token: string, sharedContext?: Context): Promise<UserTypes.InviteDTO>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-module.d.ts","sourceRoot":"","sources":["../../src/services/user-module.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,GAAG,EACH,eAAe,EACf,yBAAyB,EACzB,eAAe,EACf,SAAS,EACV,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"user-module.d.ts","sourceRoot":"","sources":["../../src/services/user-module.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,GAAG,EACH,eAAe,EACf,yBAAyB,EACzB,eAAe,EACf,oBAAo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AC,EAAE,OAAO,GACtB,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC;IAmC/B,OAAO,CAAC,aAAa;CAYtB"}
|
|
@@ -19,27 +19,40 @@ const utils_1 = require("@etohq/framework/utils");
|
|
|
19
19
|
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
20
20
|
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
21
21
|
const _models_1 = require("../models");
|
|
22
|
+
const utils_2 = require("../utils/utils");
|
|
22
23
|
const DEFAULT_VALID_INVITE_DURATION_SECONDS = 60 * 60 * 24;
|
|
23
24
|
class UserModuleService extends (0, utils_1.EtoService)({ User: _models_1.User, Invite: _models_1.Invite }) {
|
|
24
25
|
constructor({ userService, inviteService, baseRepository }, moduleDeclaration) {
|
|
25
26
|
// @ts-ignore
|
|
26
27
|
super(...arguments);
|
|
27
|
-
this.moduleDeclaration = moduleDeclaration;
|
|
28
28
|
this.baseRepository_ = baseRepository;
|
|
29
29
|
this.userService_ = userService;
|
|
30
30
|
this.inviteService_ = inviteService;
|
|
31
31
|
this.config = {
|
|
32
32
|
jwtSecret: moduleDeclaration["jwt_secret"],
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
jwtPublicKey: moduleDeclaration["jwt_public_key"],
|
|
34
|
+
jwt_verify_options: moduleDeclaration["jwt_verify_options"],
|
|
35
|
+
jwtOptions: {
|
|
36
|
+
...moduleDeclaration["jwt_options"],
|
|
37
|
+
expiresIn: moduleDeclaration["valid_duration"] ??
|
|
38
|
+
moduleDeclaration["jwt_options"]?.expiresIn ??
|
|
39
|
+
DEFAULT_VALID_INVITE_DURATION_SECONDS,
|
|
40
|
+
},
|
|
35
41
|
};
|
|
36
42
|
if (!this.config.jwtSecret) {
|
|
37
43
|
throw new utils_1.EtoError(utils_1.EtoError.Types.INVALID_DATA, "No jwt_secret was provided in the UserModule's options. Please add one.");
|
|
38
44
|
}
|
|
39
45
|
}
|
|
40
46
|
async validateInviteToken(token, sharedContext = {}) {
|
|
41
|
-
const
|
|
42
|
-
|
|
47
|
+
const options = {
|
|
48
|
+
...(this.config.jwt_verify_options ?? this.config.jwtOptions),
|
|
49
|
+
complete: true,
|
|
50
|
+
};
|
|
51
|
+
if (!options.algorithms && options.algorithm) {
|
|
52
|
+
options.algorithms = [options.algorithm];
|
|
53
|
+
delete options.algorithm;
|
|
54
|
+
}
|
|
55
|
+
const decoded = jsonwebtoken_1.default.verify(token, this.config.jwtPublicKey ?? this.config.jwtSecret, options);
|
|
43
56
|
const invite = await this.inviteService_.retrieve(decoded.payload.id, {}, sharedContext);
|
|
44
57
|
if (invite.expires_at < new Date()) {
|
|
45
58
|
throw new utils_1.EtoError(utils_1.EtoError.Types.INVALID_DATA, "The invite has expired");
|
|
@@ -50,14 +63,15 @@ class UserModuleService extends (0, utils_1.EtoService)({ User: _models_1.User,
|
|
|
50
63
|
}
|
|
51
64
|
async refreshInviteTokens(inviteIds, sharedContext = {}) {
|
|
52
65
|
const invites = await this.refreshInviteTokens_(inviteIds, sharedContext);
|
|
53
|
-
|
|
66
|
+
(0, utils_1.moduleEventBuilderFactory)({
|
|
54
67
|
eventName: utils_1.UserEvents.INVITE_TOKEN_GENERATED,
|
|
55
|
-
source:
|
|
68
|
+
source: utils_1.Modules.USER,
|
|
56
69
|
action: "token_generated",
|
|
57
70
|
object: "invite",
|
|
58
|
-
|
|
59
|
-
data:
|
|
60
|
-
|
|
71
|
+
})({
|
|
72
|
+
data: invites,
|
|
73
|
+
sharedContext,
|
|
74
|
+
});
|
|
61
75
|
return await this.baseRepository_.serialize(invites, {
|
|
62
76
|
populate: true,
|
|
63
77
|
});
|
|
@@ -70,69 +84,77 @@ class UserModuleService extends (0, utils_1.EtoService)({ User: _models_1.User,
|
|
|
70
84
|
throw new utils_1.EtoError(utils_1.EtoError.Types.INVALID_DATA, `The following invites do not exist: ${missing.join(", ")}`);
|
|
71
85
|
}
|
|
72
86
|
}
|
|
87
|
+
const expiresAt = (0, utils_2.getExpiresAt)(this.config.jwtOptions.expiresIn);
|
|
73
88
|
const updates = invites.map((invite) => {
|
|
74
89
|
return {
|
|
75
90
|
id: invite.id,
|
|
76
|
-
expires_at:
|
|
91
|
+
expires_at: expiresAt,
|
|
77
92
|
token: this.generateToken({ id: invite.id, email: invite.email }),
|
|
78
93
|
};
|
|
79
94
|
});
|
|
80
95
|
return await this.inviteService_.update(updates, sharedContext);
|
|
81
96
|
}
|
|
97
|
+
// @ts-expect-error
|
|
82
98
|
async createUsers(data, sharedContext = {}) {
|
|
83
99
|
const input = Array.isArray(data) ? data : [data];
|
|
84
100
|
const users = await this.userService_.create(input, sharedContext);
|
|
85
101
|
const serializedUsers = await this.baseRepository_.serialize(users, {
|
|
86
102
|
populate: true,
|
|
87
103
|
});
|
|
88
|
-
|
|
104
|
+
(0, utils_1.moduleEventBuilderFactory)({
|
|
89
105
|
eventName: utils_1.UserEvents.USER_CREATED,
|
|
90
|
-
source:
|
|
106
|
+
source: utils_1.Modules.USER,
|
|
91
107
|
action: utils_1.CommonEvents.CREATED,
|
|
92
108
|
object: "user",
|
|
93
|
-
|
|
94
|
-
data:
|
|
95
|
-
|
|
109
|
+
})({
|
|
110
|
+
data: serializedUsers,
|
|
111
|
+
sharedContext,
|
|
112
|
+
});
|
|
96
113
|
return Array.isArray(data) ? serializedUsers : serializedUsers[0];
|
|
97
114
|
}
|
|
115
|
+
// @ts-expect-error
|
|
98
116
|
async updateUsers(data, sharedContext = {}) {
|
|
99
117
|
const input = Array.isArray(data) ? data : [data];
|
|
100
118
|
const updatedUsers = await this.userService_.update(input, sharedContext);
|
|
101
119
|
const serializedUsers = await this.baseRepository_.serialize(updatedUsers, {
|
|
102
120
|
populate: true,
|
|
103
121
|
});
|
|
104
|
-
|
|
122
|
+
(0, utils_1.moduleEventBuilderFactory)({
|
|
105
123
|
eventName: utils_1.UserEvents.USER_UPDATED,
|
|
106
|
-
source:
|
|
124
|
+
source: utils_1.Modules.USER,
|
|
107
125
|
action: utils_1.CommonEvents.UPDATED,
|
|
108
126
|
object: "user",
|
|
109
|
-
|
|
110
|
-
data:
|
|
111
|
-
|
|
127
|
+
})({
|
|
128
|
+
data: serializedUsers,
|
|
129
|
+
sharedContext,
|
|
130
|
+
});
|
|
112
131
|
return Array.isArray(data) ? serializedUsers : serializedUsers[0];
|
|
113
132
|
}
|
|
133
|
+
// @ts-expect-error
|
|
114
134
|
async createInvites(data, sharedContext = {}) {
|
|
115
135
|
const input = Array.isArray(data) ? data : [data];
|
|
116
136
|
const invites = await this.createInvites_(input, sharedContext);
|
|
117
137
|
const serializedInvites = await this.baseRepository_.serialize(invites, {
|
|
118
138
|
populate: true,
|
|
119
139
|
});
|
|
120
|
-
|
|
140
|
+
(0, utils_1.moduleEventBuilderFactory)({
|
|
121
141
|
eventName: utils_1.UserEvents.INVITE_CREATED,
|
|
122
|
-
source:
|
|
142
|
+
source: utils_1.Modules.USER,
|
|
123
143
|
action: utils_1.CommonEvents.CREATED,
|
|
124
144
|
object: "invite",
|
|
125
|
-
|
|
126
|
-
data:
|
|
127
|
-
|
|
128
|
-
|
|
145
|
+
})({
|
|
146
|
+
data: serializedInvites,
|
|
147
|
+
sharedContext,
|
|
148
|
+
});
|
|
149
|
+
(0, utils_1.moduleEventBuilderFactory)({
|
|
129
150
|
eventName: utils_1.UserEvents.INVITE_TOKEN_GENERATED,
|
|
130
|
-
source:
|
|
151
|
+
source: utils_1.Modules.USER,
|
|
131
152
|
action: "token_generated",
|
|
132
153
|
object: "invite",
|
|
133
|
-
|
|
134
|
-
data:
|
|
135
|
-
|
|
154
|
+
})({
|
|
155
|
+
data: serializedInvites,
|
|
156
|
+
sharedContext,
|
|
157
|
+
});
|
|
136
158
|
return Array.isArray(data) ? serializedInvites : serializedInvites[0];
|
|
137
159
|
}
|
|
138
160
|
async createInvites_(data, sharedContext = {}) {
|
|
@@ -144,39 +166,46 @@ class UserModuleService extends (0, utils_1.EtoService)({ User: _models_1.User,
|
|
|
144
166
|
.map((u) => u.email)
|
|
145
167
|
.join(", ")}`);
|
|
146
168
|
}
|
|
169
|
+
const expiresAt = (0, utils_2.getExpiresAt)(this.config.jwtOptions.expiresIn);
|
|
147
170
|
const toCreate = data.map((invite) => {
|
|
148
171
|
const id = (0, utils_1.generateEntityId)(invite.id, "invite");
|
|
149
172
|
return {
|
|
150
173
|
...invite,
|
|
151
174
|
id,
|
|
152
|
-
expires_at:
|
|
175
|
+
expires_at: expiresAt,
|
|
153
176
|
token: this.generateToken({ id, email: invite.email }),
|
|
154
177
|
};
|
|
155
178
|
});
|
|
156
179
|
return await this.inviteService_.create(toCreate, sharedContext);
|
|
157
180
|
}
|
|
181
|
+
// @ts-expect-error
|
|
158
182
|
async updateInvites(data, sharedContext = {}) {
|
|
159
183
|
const input = Array.isArray(data) ? data : [data];
|
|
160
184
|
const updatedInvites = await this.inviteService_.update(input, sharedContext);
|
|
161
185
|
const serializedInvites = await this.baseRepository_.serialize(updatedInvites, {
|
|
162
186
|
populate: true,
|
|
163
187
|
});
|
|
164
|
-
|
|
188
|
+
(0, utils_1.moduleEventBuilderFactory)({
|
|
165
189
|
eventName: utils_1.UserEvents.INVITE_UPDATED,
|
|
166
|
-
source:
|
|
190
|
+
source: utils_1.Modules.USER,
|
|
167
191
|
action: utils_1.CommonEvents.UPDATED,
|
|
168
192
|
object: "invite",
|
|
169
|
-
|
|
170
|
-
data:
|
|
171
|
-
|
|
193
|
+
})({
|
|
194
|
+
data: serializedInvites,
|
|
195
|
+
sharedContext,
|
|
196
|
+
});
|
|
172
197
|
return Array.isArray(data) ? serializedInvites : serializedInvites[0];
|
|
173
198
|
}
|
|
174
199
|
generateToken(data) {
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
200
|
+
const jwtId = this.config.jwtOptions.jwtid ?? node_crypto_1.default.randomUUID();
|
|
201
|
+
const token = (0, utils_1.generateJwtToken)(data, {
|
|
202
|
+
secret: this.config.jwtSecret,
|
|
203
|
+
jwtOptions: {
|
|
204
|
+
...this.config.jwtOptions,
|
|
205
|
+
jwtid: jwtId,
|
|
206
|
+
},
|
|
179
207
|
});
|
|
208
|
+
return token;
|
|
180
209
|
}
|
|
181
210
|
}
|
|
182
211
|
exports.default = UserModuleService;
|
|
@@ -204,7 +233,9 @@ __decorate([
|
|
|
204
233
|
], UserModuleService.prototype, "refreshInviteTokens_", null);
|
|
205
234
|
__decorate([
|
|
206
235
|
(0, utils_1.InjectManager)(),
|
|
207
|
-
(0, utils_1.EmitEvents)()
|
|
236
|
+
(0, utils_1.EmitEvents)()
|
|
237
|
+
// @ts-expect-error
|
|
238
|
+
,
|
|
208
239
|
__param(1, (0, utils_1.EtoContext)()),
|
|
209
240
|
__metadata("design:type", Function),
|
|
210
241
|
__metadata("design:paramtypes", [Object, Object]),
|
|
@@ -212,7 +243,9 @@ __decorate([
|
|
|
212
243
|
], UserModuleService.prototype, "createUsers", null);
|
|
213
244
|
__decorate([
|
|
214
245
|
(0, utils_1.InjectManager)(),
|
|
215
|
-
(0, utils_1.EmitEvents)()
|
|
246
|
+
(0, utils_1.EmitEvents)()
|
|
247
|
+
// @ts-expect-error
|
|
248
|
+
,
|
|
216
249
|
__param(1, (0, utils_1.EtoContext)()),
|
|
217
250
|
__metadata("design:type", Function),
|
|
218
251
|
__metadata("design:paramtypes", [Object, Object]),
|
|
@@ -220,7 +253,9 @@ __decorate([
|
|
|
220
253
|
], UserModuleService.prototype, "updateUsers", null);
|
|
221
254
|
__decorate([
|
|
222
255
|
(0, utils_1.InjectManager)(),
|
|
223
|
-
(0, utils_1.EmitEvents)()
|
|
256
|
+
(0, utils_1.EmitEvents)()
|
|
257
|
+
// @ts-expect-error
|
|
258
|
+
,
|
|
224
259
|
__param(1, (0, utils_1.EtoContext)()),
|
|
225
260
|
__metadata("design:type", Function),
|
|
226
261
|
__metadata("design:paramtypes", [Object, Object]),
|
|
@@ -235,7 +270,9 @@ __decorate([
|
|
|
235
270
|
], UserModuleService.prototype, "createInvites_", null);
|
|
236
271
|
__decorate([
|
|
237
272
|
(0, utils_1.InjectManager)(),
|
|
238
|
-
(0, utils_1.EmitEvents)()
|
|
273
|
+
(0, utils_1.EmitEvents)()
|
|
274
|
+
// @ts-expect-error
|
|
275
|
+
,
|
|
239
276
|
__param(1, (0, utils_1.EtoContext)()),
|
|
240
277
|
__metadata("design:type", Function),
|
|
241
278
|
__metadata("design:paramtypes", [Object, Object]),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-module.js","sourceRoot":"","sources":["../../src/services/user-module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"user-module.js","sourceRoot":"","sources":["../../src/services/user-module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AASA,kDAc+B;AAC/B,gEAA0E;AAC1E,8DAAgC;AAEhC,qCAAsC;AACtC,0CAA6C;AAQ7C,MAAM,qCAAqC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAA;AAC1D,MAAqB,iBACnB,SAAQ,IAAA,kBAAU,EAOf,EAAE,IAAI,EAAJ,cAAI,EAAE,MAAM,EAAN,gBAAM,EAAE,CAAC;IAoBpB,YACE,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,EAAwB,EACpE,iBAA4C;QAE5C,aAAa;QACb,KAAK,CAAC,GAAG,SAAS,CAAC,CAAA;QAEnB,IAAI,CAAC,eAAe,GAAG,cAAc,CAAA;QACrC,IAAI,CAAC,YAAY,GAAG,WAAW,CAAA;QAC/B,IAAI,CAAC,cAAc,GAAG,aAAa,CAAA;QAEnC,IAAI,CAAC,MAAM,GAAG;YACZ,SAAS,EAAE,iBAAiB,CAAC,YAAY,CAAC;YAC1C,YAAY,EAAE,iBAAiB,CAAC,gBAAgB,CAAC;YACjD,kBAAkB,EAAE,iBAAiB,CAAC,oBAAoB,CAAC;YAC3D,UAAU,EAAE;gBACV,GAAG,iBAAiB,CAAC,aAAa,CAAC;gBACnC,SAAS,EACP,iBAAiB,CAAC,gBAAgB,CAAC;oBAC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../src/models/role.ts","../src/models/user-term-of-service.ts","../src/models/user.ts","../src/services/index.ts","../src/services/user-module.ts","../src/types/index.ts","../src/types/services/index.ts","../src/types/services/invite.ts"],"version":"5.8.3"}
|
|
1
|
+
{"root":["../src/index.ts","../src/migrations/migration20240214033943.ts","../src/migrations/migration20240703095850.ts","../src/migrations/migration20241202103352.ts","../src/models/index.ts","../src/models/invite.ts","../src/models/role.ts","../src/models/user-term-of-service.ts","../src/models/user.ts","../src/services/index.ts","../src/services/user-module.ts","../src/types/index.ts","../src/types/services/index.ts","../src/types/services/invite.ts","../src/utils/utils.ts"],"version":"5.8.3"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,QAOtD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getExpiresAt = getExpiresAt;
|
|
7
|
+
const timespan_1 = __importDefault(require("jsonwebtoken/lib/timespan"));
|
|
8
|
+
function getExpiresAt(expiresIn) {
|
|
9
|
+
const expiresAt = typeof expiresIn === "number"
|
|
10
|
+
? new Date(Date.now() + expiresIn * 1000)
|
|
11
|
+
: new Date(Math.floor((0, timespan_1.default)(expiresIn)) * 1000);
|
|
12
|
+
return expiresAt;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":";;;;;AAEA,oCAOC;AATD,yEAAgD;AAEhD,SAAgB,YAAY,CAAC,SAA0B;IACrD,MAAM,SAAS,GACb,OAAO,SAAS,KAAK,QAAQ;QAC3B,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,GAAG,IAAI,CAAC;QACzC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAA,kBAAQ,EAAC,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;IAEtD,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etohq/user",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Eto Users module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -23,42 +23,42 @@
|
|
|
23
23
|
},
|
|
24
24
|
"author": "Eto",
|
|
25
25
|
"license": "MIT",
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@mikro-orm/cli": "6.4.3",
|
|
28
|
+
"@mikro-orm/core": "6.4.3",
|
|
29
|
+
"@mikro-orm/migrations": "6.4.3",
|
|
30
|
+
"@mikro-orm/postgresql": "6.4.3",
|
|
31
|
+
"@swc/core": "1.7.28",
|
|
32
|
+
"@swc/jest": "0.2.36",
|
|
33
|
+
"@types/jest": "29.5.14",
|
|
34
|
+
"awilix": "8.0.1",
|
|
35
|
+
"jest": "29.7.0",
|
|
36
|
+
"rimraf": "5.0.2",
|
|
37
|
+
"tsc-alias": "1.8.6",
|
|
38
|
+
"typescript": "5.8.3",
|
|
39
|
+
"@etohq/framework": "1.5.0",
|
|
40
|
+
"@etohq/test-utils": "1.5.0"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"jsonwebtoken": "9.0.2"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"@mikro-orm/core": "6.4.3",
|
|
47
|
+
"@mikro-orm/migrations": "6.4.3",
|
|
48
|
+
"@mikro-orm/postgresql": "6.4.3",
|
|
49
|
+
"awilix": "8.0.1",
|
|
50
|
+
"@etohq/framework": "1.5.0"
|
|
51
|
+
},
|
|
26
52
|
"scripts": {
|
|
27
53
|
"watch": "tsc --build --watch",
|
|
28
54
|
"watch:test": "tsc --build tsconfig.spec.json --watch",
|
|
29
|
-
"resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json",
|
|
30
55
|
"build": "rimraf dist && tsc --build && npm run resolve:aliases",
|
|
56
|
+
"resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json",
|
|
31
57
|
"test": "jest --runInBand --passWithNoTests --bail --forceExit -- src",
|
|
32
58
|
"test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts",
|
|
33
59
|
"migration:initial": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts eto-mikro-orm migration:create --initial",
|
|
34
60
|
"migration:create": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts eto-mikro-orm migration:create",
|
|
35
61
|
"migration:up": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts eto-mikro-orm migration:up",
|
|
36
62
|
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts eto-mikro-orm cache:clear"
|
|
37
|
-
},
|
|
38
|
-
"devDependencies": {
|
|
39
|
-
"@etohq/framework": "^1.3.0",
|
|
40
|
-
"@etohq/test-utils": "^1.3.0",
|
|
41
|
-
"@mikro-orm/cli": "5.9.7",
|
|
42
|
-
"@mikro-orm/core": "5.9.7",
|
|
43
|
-
"@mikro-orm/migrations": "5.9.7",
|
|
44
|
-
"@mikro-orm/postgresql": "5.9.7",
|
|
45
|
-
"@swc/core": "^1.7.28",
|
|
46
|
-
"@swc/jest": "^0.2.36",
|
|
47
|
-
"@types/jest": "^29.5.14",
|
|
48
|
-
"awilix": "^8.0.1",
|
|
49
|
-
"jest": "^29.7.0",
|
|
50
|
-
"rimraf": "^5.0.2",
|
|
51
|
-
"tsc-alias": "^1.8.6",
|
|
52
|
-
"typescript": "^5.8.3"
|
|
53
|
-
},
|
|
54
|
-
"dependencies": {
|
|
55
|
-
"jsonwebtoken": "^9.0.2"
|
|
56
|
-
},
|
|
57
|
-
"peerDependencies": {
|
|
58
|
-
"@etohq/framework": "^1.1.0",
|
|
59
|
-
"@mikro-orm/core": "5.9.7",
|
|
60
|
-
"@mikro-orm/migrations": "5.9.7",
|
|
61
|
-
"@mikro-orm/postgresql": "5.9.7",
|
|
62
|
-
"awilix": "^8.0.1"
|
|
63
63
|
}
|
|
64
|
-
}
|
|
64
|
+
}
|