propro-utils 1.4.48 → 1.4.49
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/package.json
CHANGED
|
@@ -39,7 +39,7 @@ const setAuthCookies = (res, tokens, account, user) => {
|
|
|
39
39
|
|
|
40
40
|
res.cookie(
|
|
41
41
|
'has_account_token',
|
|
42
|
-
JSON.stringify({ value: 'true', expires:
|
|
42
|
+
JSON.stringify({ value: 'true', expires: accessMaxAge }),
|
|
43
43
|
{
|
|
44
44
|
maxAge: accessMaxAge,
|
|
45
45
|
secure: process.env.NODE_ENV === 'production',
|
|
@@ -76,14 +76,6 @@ describe('setAuthCookies', () => {
|
|
|
76
76
|
);
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
it('should set the has_account_token cookie with the correct options', () => {
|
|
80
|
-
setAuthCookies(res, tokens, account, user);
|
|
81
|
-
expect(res.cookie).toHaveBeenCalledWith('has_account_token', 'true', {
|
|
82
|
-
maxAge: expect.any(Number),
|
|
83
|
-
secure: process.env.NODE_ENV === 'production',
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
|
|
87
79
|
it('should set the maxAge of refresh-related cookies to the correct value', () => {
|
|
88
80
|
const currentDateTime = new Date();
|
|
89
81
|
const refreshMaxAge =
|
|
@@ -116,10 +108,22 @@ describe('setAuthCookies', () => {
|
|
|
116
108
|
expect.any(String),
|
|
117
109
|
expect.objectContaining({ maxAge: accessMaxAge })
|
|
118
110
|
);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('should set the has_account_token cookie with the correct options', () => {
|
|
114
|
+
const currentDateTime = new Date();
|
|
115
|
+
const accessMaxAge =
|
|
116
|
+
new Date(tokens.access.expires).getTime() - currentDateTime.getTime();
|
|
117
|
+
|
|
118
|
+
setAuthCookies(res, tokens, account, user);
|
|
119
|
+
|
|
119
120
|
expect(res.cookie).toHaveBeenCalledWith(
|
|
120
121
|
'has_account_token',
|
|
121
|
-
|
|
122
|
-
|
|
122
|
+
JSON.stringify({ value: 'true', expires: accessMaxAge }),
|
|
123
|
+
{
|
|
124
|
+
maxAge: accessMaxAge,
|
|
125
|
+
secure: process.env.NODE_ENV === 'production',
|
|
126
|
+
}
|
|
123
127
|
);
|
|
124
128
|
});
|
|
125
129
|
});
|