@wrcb/cb-common 1.0.257 → 1.0.259
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/build/helpers/authHelper.js +4 -11
- package/package.json +1 -1
|
@@ -13,22 +13,15 @@ function signUpReturnCookie(id, overrides) {
|
|
|
13
13
|
// Build a JWT payload
|
|
14
14
|
const payload = Object.assign({ id: id !== null && id !== void 0 ? id : new mongoose_1.default.Types.ObjectId().toHexString(), email: 'test@test.com', nickName: 'apelido', role: userRole_1.UserRole.User, language: country_1.Language.Português, country: country_1.Country.Brasil, isKycDone: true, isEmailVerified: false, isPhoneNumberVerified: false, isPersonalDataProvided: false, isAddressDataProvided: false }, overrides // sobrescreve os valores padrão
|
|
15
15
|
);
|
|
16
|
-
|
|
17
|
-
const token = jsonwebtoken_1.default.sign(payload, process.env.JWT_KEY);
|
|
18
|
-
// Build session object {jwt: MY_JWT}
|
|
19
|
-
const session = { jwt: token };
|
|
20
|
-
// Turn that session into JSON
|
|
21
|
-
const sessionJSON = JSON.stringify(session);
|
|
22
|
-
// Take JSON and encode it as base64
|
|
23
|
-
const base64 = Buffer.from(sessionJSON).toString('base64');
|
|
24
|
-
// return a string that the cookie with the encoded data
|
|
25
|
-
const cookieString = [`session=${base64}`];
|
|
26
|
-
return cookieString;
|
|
16
|
+
return buildCookie(payload);
|
|
27
17
|
}
|
|
28
18
|
function signUpReturnCookieAdmin(id, overrides) {
|
|
29
19
|
// Build a JWT payload
|
|
30
20
|
const payload = Object.assign({ id: id !== null && id !== void 0 ? id : new mongoose_1.default.Types.ObjectId().toHexString(), email: 'test@test.com', nickName: 'apelido', role: userRole_1.UserRole.Admin, isKycDone: true, language: country_1.Language.Português, country: country_1.Country.Brasil, isEmailVerified: false, isPhoneNumberVerified: false, isPersonalDataProvided: false, isAddressDataProvided: false }, overrides // sobrescreve os valores padrão
|
|
31
21
|
);
|
|
22
|
+
return buildCookie(payload);
|
|
23
|
+
}
|
|
24
|
+
function buildCookie(payload) {
|
|
32
25
|
// Create the JWT
|
|
33
26
|
const token = jsonwebtoken_1.default.sign(payload, process.env.JWT_KEY);
|
|
34
27
|
// Build session object {jwt: MY_JWT}
|