@fonderie/auth 1.3.1 → 2.0.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/dist/index.js CHANGED
@@ -177,14 +177,19 @@ function tokenPairCookies(accessToken, refreshToken, config) {
177
177
  return [
178
178
  `access_token=${accessToken}; HttpOnly; SameSite=Strict; Path=/${secure}`,
179
179
  `refresh_token=${refreshToken}; HttpOnly; SameSite=Strict; Path=/auth/refresh${secure}`
180
- ].join(", ");
180
+ ];
181
181
  }
182
182
  function clearedTokenCookies(config) {
183
183
  const secure = secureAttr(config);
184
184
  return [
185
185
  `access_token=; HttpOnly; SameSite=Strict; Path=/; Max-Age=0${secure}`,
186
186
  `refresh_token=; HttpOnly; SameSite=Strict; Path=/auth/refresh; Max-Age=0${secure}`
187
- ].join(", ");
187
+ ];
188
+ }
189
+ function cookieHeaders(cookies) {
190
+ const headers = new Headers();
191
+ for (const c of cookies) headers.append("Set-Cookie", c);
192
+ return headers;
188
193
  }
189
194
 
190
195
  // src/controllers/mfa.controller.ts
@@ -781,9 +786,7 @@ function mfaController(store, config, issuer, bus) {
781
786
  },
782
787
  {
783
788
  status: 200,
784
- headers: {
785
- "Set-Cookie": tokenPairCookies(accessToken, refreshToken, config)
786
- }
789
+ headers: cookieHeaders(tokenPairCookies(accessToken, refreshToken, config))
787
790
  }
788
791
  );
789
792
  },
@@ -1115,9 +1118,7 @@ function authController(store, config, bus) {
1115
1118
  },
1116
1119
  {
1117
1120
  status: 201,
1118
- headers: {
1119
- "Set-Cookie": tokenPairCookies(accessToken, refreshToken, config)
1120
- }
1121
+ headers: cookieHeaders(tokenPairCookies(accessToken, refreshToken, config))
1121
1122
  }
1122
1123
  );
1123
1124
  }
@@ -1177,9 +1178,7 @@ function authController(store, config, bus) {
1177
1178
  },
1178
1179
  {
1179
1180
  status: 202,
1180
- headers: {
1181
- "Set-Cookie": tokenPairCookies(accessToken, refreshToken, config)
1182
- }
1181
+ headers: cookieHeaders(tokenPairCookies(accessToken, refreshToken, config))
1183
1182
  }
1184
1183
  );
1185
1184
  }
@@ -1236,9 +1235,7 @@ function authController(store, config, bus) {
1236
1235
  },
1237
1236
  {
1238
1237
  status: 200,
1239
- headers: {
1240
- "Set-Cookie": tokenPairCookies(accessToken, refreshToken, config)
1241
- }
1238
+ headers: cookieHeaders(tokenPairCookies(accessToken, refreshToken, config))
1242
1239
  }
1243
1240
  );
1244
1241
  }
@@ -1279,9 +1276,7 @@ function authController(store, config, bus) {
1279
1276
  },
1280
1277
  {
1281
1278
  status: 202,
1282
- headers: {
1283
- "Set-Cookie": tokenPairCookies(accessToken, refreshToken, config)
1284
- }
1279
+ headers: cookieHeaders(tokenPairCookies(accessToken, refreshToken, config))
1285
1280
  }
1286
1281
  );
1287
1282
  }
@@ -1300,9 +1295,7 @@ function authController(store, config, bus) {
1300
1295
  { reason: "USER_LOGOUT", explanation: "Logged out successfully." },
1301
1296
  {
1302
1297
  status: 200,
1303
- headers: {
1304
- "Set-Cookie": clearedTokenCookies(config)
1305
- }
1298
+ headers: cookieHeaders(clearedTokenCookies(config))
1306
1299
  }
1307
1300
  );
1308
1301
  },
@@ -1341,9 +1334,7 @@ function authController(store, config, bus) {
1341
1334
  },
1342
1335
  {
1343
1336
  status: 200,
1344
- headers: {
1345
- "Set-Cookie": tokenPairCookies(accessToken, refreshToken, config)
1346
- }
1337
+ headers: cookieHeaders(tokenPairCookies(accessToken, refreshToken, config))
1347
1338
  }
1348
1339
  );
1349
1340
  },
@@ -1490,9 +1481,7 @@ function authController(store, config, bus) {
1490
1481
  },
1491
1482
  {
1492
1483
  status: 200,
1493
- headers: {
1494
- "Set-Cookie": tokenPairCookies(accessToken, refreshToken, config)
1495
- }
1484
+ headers: cookieHeaders(tokenPairCookies(accessToken, refreshToken, config))
1496
1485
  }
1497
1486
  );
1498
1487
  }
@@ -1796,9 +1785,7 @@ function userController(store, config, bus) {
1796
1785
  { reason: "ACCOUNT_DELETED", explanation: "Account successfully deleted." },
1797
1786
  {
1798
1787
  status: 200,
1799
- headers: {
1800
- "Set-Cookie": clearedTokenCookies(config)
1801
- }
1788
+ headers: cookieHeaders(clearedTokenCookies(config))
1802
1789
  }
1803
1790
  );
1804
1791
  }
@@ -1900,9 +1887,7 @@ function oauthController(store, config) {
1900
1887
  },
1901
1888
  {
1902
1889
  status: 200,
1903
- headers: {
1904
- "Set-Cookie": tokenPairCookies(accessToken, refreshToken, config)
1905
- }
1890
+ headers: cookieHeaders(tokenPairCookies(accessToken, refreshToken, config))
1906
1891
  }
1907
1892
  );
1908
1893
  }