@medusajs/user 3.0.0-snapshot-20250410112222 → 3.0.0-snapshot-20251104011621
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/migrations/Migration20240214033943.d.ts +1 -1
- package/dist/migrations/Migration20240214033943.d.ts.map +1 -1
- package/dist/migrations/Migration20240214033943.js +1 -1
- package/dist/migrations/Migration20240214033943.js.map +1 -1
- package/dist/migrations/Migration20240703095850.d.ts +1 -1
- package/dist/migrations/Migration20240703095850.d.ts.map +1 -1
- package/dist/migrations/Migration20240703095850.js +1 -1
- package/dist/migrations/Migration20240703095850.js.map +1 -1
- package/dist/migrations/Migration20241202103352.d.ts +1 -1
- package/dist/migrations/Migration20241202103352.d.ts.map +1 -1
- package/dist/migrations/Migration20241202103352.js +1 -1
- package/dist/migrations/Migration20241202103352.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 +43 -62
- package/dist/services/user-module.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/services/index.js +17 -7
- package/dist/types/services/index.js.map +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 +14 -28
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Migration20240214033943.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20240214033943.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"Migration20240214033943.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20240214033943.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAA;AAEpE,qBAAa,uBAAwB,SAAQ,SAAS;IAC9C,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IA2CnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAK5B"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Migration20240214033943 = void 0;
|
|
4
4
|
const utils_1 = require("@medusajs/framework/utils");
|
|
5
|
-
const migrations_1 = require("@mikro-orm/migrations");
|
|
5
|
+
const migrations_1 = require("@medusajs/framework/mikro-orm/migrations");
|
|
6
6
|
class Migration20240214033943 extends migrations_1.Migration {
|
|
7
7
|
async up() {
|
|
8
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"));');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Migration20240214033943.js","sourceRoot":"","sources":["../../src/migrations/Migration20240214033943.ts"],"names":[],"mappings":";;;AAAA,qDAAwF;AACxF,
|
|
1
|
+
{"version":3,"file":"Migration20240214033943.js","sourceRoot":"","sources":["../../src/migrations/Migration20240214033943.ts"],"names":[],"mappings":";;;AAAA,qDAAwF;AACxF,yEAAoE;AAEpE,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Migration20240703095850.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20240703095850.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"Migration20240703095850.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20240703095850.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAA;AAEpE,qBAAa,uBAAwB,SAAQ,SAAS;IAC9C,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAYnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAK5B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Migration20240703095850 = void 0;
|
|
4
|
-
const migrations_1 = require("@mikro-orm/migrations");
|
|
4
|
+
const migrations_1 = require("@medusajs/framework/mikro-orm/migrations");
|
|
5
5
|
class Migration20240703095850 extends migrations_1.Migration {
|
|
6
6
|
async up() {
|
|
7
7
|
this.addSql('drop index if exists "IDX_user_email";');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Migration20240703095850.js","sourceRoot":"","sources":["../../src/migrations/Migration20240703095850.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"Migration20240703095850.js","sourceRoot":"","sources":["../../src/migrations/Migration20240703095850.ts"],"names":[],"mappings":";;;AAAA,yEAAoE;AAEpE,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Migration20241202103352.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20241202103352.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"Migration20241202103352.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20241202103352.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AAErE,qBAAa,uBAAwB,SAAQ,SAAS;IAE9C,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAQnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ5B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Migration20241202103352 = void 0;
|
|
4
|
-
const migrations_1 = require("@mikro-orm/migrations");
|
|
4
|
+
const migrations_1 = require("@medusajs/framework/mikro-orm/migrations");
|
|
5
5
|
class Migration20241202103352 extends migrations_1.Migration {
|
|
6
6
|
async up() {
|
|
7
7
|
this.addSql('drop index if exists "IDX_invite_email";');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Migration20241202103352.js","sourceRoot":"","sources":["../../src/migrations/Migration20241202103352.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"Migration20241202103352.js","sourceRoot":"","sources":["../../src/migrations/Migration20241202103352.ts"],"names":[],"mappings":";;;AAAA,yEAAqE;AAErE,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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Context, DAL, InferEntityType, InternalModuleDeclaration, ModulesSdkTypes, UserTypes } from "@medusajs/framework/types";
|
|
1
|
+
import { Context, DAL, InferEntityType, InternalModuleDeclaration, ModulesSdkTypes, ProjectConfigOptions, UserTypes } from "@medusajs/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("@medusajs/framework/utils").Medusa
|
|
|
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.IMedusaInternalService<InferEntityType<typeof User>>;
|
|
20
19
|
protected readonly inviteService_: ModulesSdkTypes.IMedusaInternalService<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,2BAA2B,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,oBAAoB,EACpB,SAAS,EACV,MAAM,2BAA2B,CAAA;AAmBlC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAGtC,KAAK,oBAAoB,GAAG;IAC1B,cAAc,EAAE,GAAG,CAAC,iBAAiB,CAAA;IACrC,WAAW,EAAE,eAAe,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAA;IACxD,aAAa,EAAE,eAAe,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAA;CAC3D,CAAA;;UAKS;QACJ,GAAG,EAAE,SAAS,CAAC,OAAO,CAAA;KACvB;YACO;Q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AO,EAAE,CAAC;IAE/B,WAAW,CACT,IAAI,EAAE,SAAS,CAAC,aAAa,EAC7B,aAAa,CAAC,EAAE,OAAO,GACtB,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC;IAqB7B,WAAW,CACT,IAAI,EAAE,SAAS,CAAC,aAAa,EAAE,EAC/B,aAAa,CAAC,EAAE,OAAO,GACtB,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;IAE/B,WAAW,CACT,IAAI,EAAE,SAAS,CAAC,aAAa,EAC7B,aAAa,CAAC,EAAE,OAAO,GACtB,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC;IAqB7B,aAAa,CACX,IAAI,EAAE,SAAS,CAAC,eAAe,EAAE,EACjC,aAAa,CAAC,EAAE,OAAO,GACtB,OAAO,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC;IAEjC,aAAa,CACX,IAAI,EAAE,SAAS,CAAC,eAAe,EAC/B,aAAa,CAAC,EAAE,OAAO,GACtB,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC;YA+BjB,cAAc;IAiC5B,aAAa,CACX,IAAI,EAAE,SAAS,CAAC,eAAe,EAAE,EACjC,aAAa,CAAC,EAAE,OAAO,GACtB,OAAO,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC;IAEjC,aAAa,CACX,IAAI,EAAE,SAAS,CAAC,eAAe,EAC/B,aAAa,CAAC,EAAE,OAAO,GACtB,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC;IAiC/B,OAAO,CAAC,aAAa;CAYtB"}
|
|
@@ -19,49 +19,59 @@ const utils_1 = require("@medusajs/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.MedusaService)({ 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.MedusaError(utils_1.MedusaError.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.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "The invite has expired");
|
|
46
59
|
}
|
|
47
|
-
return await this.baseRepository_.serialize(invite
|
|
48
|
-
populate: true,
|
|
49
|
-
});
|
|
60
|
+
return await this.baseRepository_.serialize(invite);
|
|
50
61
|
}
|
|
51
62
|
async refreshInviteTokens(inviteIds, sharedContext = {}) {
|
|
52
63
|
const invites = await this.refreshInviteTokens_(inviteIds, sharedContext);
|
|
64
|
+
const serializedInvites = await this.baseRepository_.serialize(invites);
|
|
53
65
|
(0, utils_1.moduleEventBuilderFactory)({
|
|
54
66
|
eventName: utils_1.UserEvents.INVITE_TOKEN_GENERATED,
|
|
55
67
|
source: utils_1.Modules.USER,
|
|
56
|
-
action:
|
|
68
|
+
action: utils_1.CommonEvents.CREATED,
|
|
57
69
|
object: "invite",
|
|
58
70
|
})({
|
|
59
|
-
data:
|
|
71
|
+
data: serializedInvites,
|
|
60
72
|
sharedContext,
|
|
61
73
|
});
|
|
62
|
-
return
|
|
63
|
-
populate: true,
|
|
64
|
-
});
|
|
74
|
+
return serializedInvites;
|
|
65
75
|
}
|
|
66
76
|
async refreshInviteTokens_(inviteIds, sharedContext = {}) {
|
|
67
77
|
const [invites, count] = await this.inviteService_.listAndCount({ id: inviteIds }, {}, sharedContext);
|
|
@@ -71,10 +81,11 @@ class UserModuleService extends (0, utils_1.MedusaService)({ User: _models_1.Use
|
|
|
71
81
|
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `The following invites do not exist: ${missing.join(", ")}`);
|
|
72
82
|
}
|
|
73
83
|
}
|
|
84
|
+
const expiresAt = (0, utils_2.getExpiresAt)(this.config.jwtOptions.expiresIn);
|
|
74
85
|
const updates = invites.map((invite) => {
|
|
75
86
|
return {
|
|
76
87
|
id: invite.id,
|
|
77
|
-
expires_at:
|
|
88
|
+
expires_at: expiresAt,
|
|
78
89
|
token: this.generateToken({ id: invite.id, email: invite.email }),
|
|
79
90
|
};
|
|
80
91
|
});
|
|
@@ -84,54 +95,21 @@ class UserModuleService extends (0, utils_1.MedusaService)({ User: _models_1.Use
|
|
|
84
95
|
async createUsers(data, sharedContext = {}) {
|
|
85
96
|
const input = Array.isArray(data) ? data : [data];
|
|
86
97
|
const users = await this.userService_.create(input, sharedContext);
|
|
87
|
-
const serializedUsers = await this.baseRepository_.serialize(users
|
|
88
|
-
populate: true,
|
|
89
|
-
});
|
|
90
|
-
(0, utils_1.moduleEventBuilderFactory)({
|
|
91
|
-
eventName: utils_1.UserEvents.USER_CREATED,
|
|
92
|
-
source: utils_1.Modules.USER,
|
|
93
|
-
action: utils_1.CommonEvents.CREATED,
|
|
94
|
-
object: "user",
|
|
95
|
-
})({
|
|
96
|
-
data: serializedUsers,
|
|
97
|
-
sharedContext,
|
|
98
|
-
});
|
|
98
|
+
const serializedUsers = await this.baseRepository_.serialize(users);
|
|
99
99
|
return Array.isArray(data) ? serializedUsers : serializedUsers[0];
|
|
100
100
|
}
|
|
101
101
|
// @ts-expect-error
|
|
102
102
|
async updateUsers(data, sharedContext = {}) {
|
|
103
103
|
const input = Array.isArray(data) ? data : [data];
|
|
104
104
|
const updatedUsers = await this.userService_.update(input, sharedContext);
|
|
105
|
-
const serializedUsers = await this.baseRepository_.serialize(updatedUsers
|
|
106
|
-
populate: true,
|
|
107
|
-
});
|
|
108
|
-
(0, utils_1.moduleEventBuilderFactory)({
|
|
109
|
-
eventName: utils_1.UserEvents.USER_UPDATED,
|
|
110
|
-
source: utils_1.Modules.USER,
|
|
111
|
-
action: utils_1.CommonEvents.UPDATED,
|
|
112
|
-
object: "user",
|
|
113
|
-
})({
|
|
114
|
-
data: serializedUsers,
|
|
115
|
-
sharedContext,
|
|
116
|
-
});
|
|
105
|
+
const serializedUsers = await this.baseRepository_.serialize(updatedUsers);
|
|
117
106
|
return Array.isArray(data) ? serializedUsers : serializedUsers[0];
|
|
118
107
|
}
|
|
119
108
|
// @ts-expect-error
|
|
120
109
|
async createInvites(data, sharedContext = {}) {
|
|
121
110
|
const input = Array.isArray(data) ? data : [data];
|
|
122
111
|
const invites = await this.createInvites_(input, sharedContext);
|
|
123
|
-
const serializedInvites = await this.baseRepository_.serialize(invites
|
|
124
|
-
populate: true,
|
|
125
|
-
});
|
|
126
|
-
(0, utils_1.moduleEventBuilderFactory)({
|
|
127
|
-
eventName: utils_1.UserEvents.INVITE_CREATED,
|
|
128
|
-
source: utils_1.Modules.USER,
|
|
129
|
-
action: utils_1.CommonEvents.CREATED,
|
|
130
|
-
object: "invite",
|
|
131
|
-
})({
|
|
132
|
-
data: serializedInvites,
|
|
133
|
-
sharedContext,
|
|
134
|
-
});
|
|
112
|
+
const serializedInvites = await this.baseRepository_.serialize(invites);
|
|
135
113
|
(0, utils_1.moduleEventBuilderFactory)({
|
|
136
114
|
eventName: utils_1.UserEvents.INVITE_TOKEN_GENERATED,
|
|
137
115
|
source: utils_1.Modules.USER,
|
|
@@ -152,12 +130,13 @@ class UserModuleService extends (0, utils_1.MedusaService)({ User: _models_1.Use
|
|
|
152
130
|
.map((u) => u.email)
|
|
153
131
|
.join(", ")}`);
|
|
154
132
|
}
|
|
133
|
+
const expiresAt = (0, utils_2.getExpiresAt)(this.config.jwtOptions.expiresIn);
|
|
155
134
|
const toCreate = data.map((invite) => {
|
|
156
135
|
const id = (0, utils_1.generateEntityId)(invite.id, "invite");
|
|
157
136
|
return {
|
|
158
137
|
...invite,
|
|
159
138
|
id,
|
|
160
|
-
expires_at:
|
|
139
|
+
expires_at: expiresAt,
|
|
161
140
|
token: this.generateToken({ id, email: invite.email }),
|
|
162
141
|
};
|
|
163
142
|
});
|
|
@@ -167,13 +146,11 @@ class UserModuleService extends (0, utils_1.MedusaService)({ User: _models_1.Use
|
|
|
167
146
|
async updateInvites(data, sharedContext = {}) {
|
|
168
147
|
const input = Array.isArray(data) ? data : [data];
|
|
169
148
|
const updatedInvites = await this.inviteService_.update(input, sharedContext);
|
|
170
|
-
const serializedInvites = await this.baseRepository_.serialize(updatedInvites
|
|
171
|
-
populate: true,
|
|
172
|
-
});
|
|
149
|
+
const serializedInvites = await this.baseRepository_.serialize(updatedInvites);
|
|
173
150
|
(0, utils_1.moduleEventBuilderFactory)({
|
|
174
|
-
eventName: utils_1.UserEvents.
|
|
151
|
+
eventName: utils_1.UserEvents.INVITE_TOKEN_GENERATED,
|
|
175
152
|
source: utils_1.Modules.USER,
|
|
176
|
-
action:
|
|
153
|
+
action: "token_generated",
|
|
177
154
|
object: "invite",
|
|
178
155
|
})({
|
|
179
156
|
data: serializedInvites,
|
|
@@ -182,16 +159,20 @@ class UserModuleService extends (0, utils_1.MedusaService)({ User: _models_1.Use
|
|
|
182
159
|
return Array.isArray(data) ? serializedInvites : serializedInvites[0];
|
|
183
160
|
}
|
|
184
161
|
generateToken(data) {
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
162
|
+
const jwtId = this.config.jwtOptions.jwtid ?? node_crypto_1.default.randomUUID();
|
|
163
|
+
const token = (0, utils_1.generateJwtToken)(data, {
|
|
164
|
+
secret: this.config.jwtSecret,
|
|
165
|
+
jwtOptions: {
|
|
166
|
+
...this.config.jwtOptions,
|
|
167
|
+
jwtid: jwtId,
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
return token;
|
|
190
171
|
}
|
|
191
172
|
}
|
|
192
173
|
exports.default = UserModuleService;
|
|
193
174
|
__decorate([
|
|
194
|
-
(0, utils_1.
|
|
175
|
+
(0, utils_1.InjectManager)(),
|
|
195
176
|
__param(1, (0, utils_1.MedusaContext)()),
|
|
196
177
|
__metadata("design:type", Function),
|
|
197
178
|
__metadata("design:paramtypes", [String, 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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/Migration20241202103352.ts","../src/models/index.ts","../src/models/invite.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.
|
|
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/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.9.3"}
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.InviteServiceTypes = void 0;
|
|
27
37
|
exports.InviteServiceTypes = __importStar(require("./invite"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/services/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAA8C"}
|
|
@@ -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": "@medusajs/user",
|
|
3
|
-
"version": "3.0.0-snapshot-
|
|
3
|
+
"version": "3.0.0-snapshot-20251104011621",
|
|
4
4
|
"description": "Medusa Users module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -24,39 +24,25 @@
|
|
|
24
24
|
"author": "Medusa",
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"scripts": {
|
|
27
|
-
"watch": "tsc --build --watch",
|
|
28
|
-
"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
|
-
"build": "rimraf dist && tsc --build && npm run resolve:aliases",
|
|
31
|
-
"test": "jest --
|
|
32
|
-
"test:integration": "jest --forceExit --
|
|
33
|
-
"migration:initial": "
|
|
34
|
-
"migration:create": "
|
|
35
|
-
"migration:up": "
|
|
36
|
-
"orm:cache:clear": "
|
|
27
|
+
"watch": "yarn run -T tsc --build --watch",
|
|
28
|
+
"watch:test": "yarn run -T tsc --build tsconfig.spec.json --watch",
|
|
29
|
+
"resolve:aliases": "yarn run -T tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && yarn run -T tsc-alias -p tsconfig.resolved.json && yarn run -T rimraf tsconfig.resolved.json",
|
|
30
|
+
"build": "yarn run -T rimraf dist && yarn run -T tsc --build && npm run resolve:aliases",
|
|
31
|
+
"test": "../../../node_modules/.bin/jest --passWithNoTests --bail --forceExit --testPathPattern=src",
|
|
32
|
+
"test:integration": "../../../node_modules/.bin/jest --passWithNoTests --forceExit --testPathPattern=\"integration-tests/__tests__/.*\\.ts\"",
|
|
33
|
+
"migration:initial": "MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts MIKRO_ORM_ALLOW_GLOBAL_CLI=true medusa-mikro-orm migration:create --initial",
|
|
34
|
+
"migration:create": "MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts MIKRO_ORM_ALLOW_GLOBAL_CLI=true medusa-mikro-orm migration:create",
|
|
35
|
+
"migration:up": "MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts MIKRO_ORM_ALLOW_GLOBAL_CLI=true medusa-mikro-orm migration:up",
|
|
36
|
+
"orm:cache:clear": "MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts MIKRO_ORM_ALLOW_GLOBAL_CLI=true medusa-mikro-orm cache:clear"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@medusajs/framework": "3.0.0-snapshot-
|
|
40
|
-
"@medusajs/test-utils": "3.0.0-snapshot-
|
|
41
|
-
"@mikro-orm/cli": "6.4.3",
|
|
42
|
-
"@mikro-orm/core": "6.4.3",
|
|
43
|
-
"@mikro-orm/migrations": "6.4.3",
|
|
44
|
-
"@mikro-orm/postgresql": "6.4.3",
|
|
45
|
-
"@swc/core": "^1.7.28",
|
|
46
|
-
"@swc/jest": "^0.2.36",
|
|
47
|
-
"jest": "^29.7.0",
|
|
48
|
-
"rimraf": "^3.0.2",
|
|
49
|
-
"tsc-alias": "^1.8.6",
|
|
50
|
-
"typescript": "^5.6.2"
|
|
39
|
+
"@medusajs/framework": "3.0.0-snapshot-20251104011621",
|
|
40
|
+
"@medusajs/test-utils": "3.0.0-snapshot-20251104011621"
|
|
51
41
|
},
|
|
52
42
|
"dependencies": {
|
|
53
43
|
"jsonwebtoken": "^9.0.2"
|
|
54
44
|
},
|
|
55
45
|
"peerDependencies": {
|
|
56
|
-
"@medusajs/framework": "3.0.0-snapshot-
|
|
57
|
-
"@mikro-orm/core": "6.4.3",
|
|
58
|
-
"@mikro-orm/migrations": "6.4.3",
|
|
59
|
-
"@mikro-orm/postgresql": "6.4.3",
|
|
60
|
-
"awilix": "^8.0.1"
|
|
46
|
+
"@medusajs/framework": "3.0.0-snapshot-20251104011621"
|
|
61
47
|
}
|
|
62
48
|
}
|