@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.cjs CHANGED
@@ -212,14 +212,19 @@ function tokenPairCookies(accessToken, refreshToken, config) {
212
212
  return [
213
213
  `access_token=${accessToken}; HttpOnly; SameSite=Strict; Path=/${secure}`,
214
214
  `refresh_token=${refreshToken}; HttpOnly; SameSite=Strict; Path=/auth/refresh${secure}`
215
- ].join(", ");
215
+ ];
216
216
  }
217
217
  function clearedTokenCookies(config) {
218
218
  const secure = secureAttr(config);
219
219
  return [
220
220
  `access_token=; HttpOnly; SameSite=Strict; Path=/; Max-Age=0${secure}`,
221
221
  `refresh_token=; HttpOnly; SameSite=Strict; Path=/auth/refresh; Max-Age=0${secure}`
222
- ].join(", ");
222
+ ];
223
+ }
224
+ function cookieHeaders(cookies) {
225
+ const headers = new Headers();
226
+ for (const c of cookies) headers.append("Set-Cookie", c);
227
+ return headers;
223
228
  }
224
229
 
225
230
  // src/controllers/mfa.controller.ts
@@ -816,9 +821,7 @@ function mfaController(store, config, issuer, bus) {
816
821
  },
817
822
  {
818
823
  status: 200,
819
- headers: {
820
- "Set-Cookie": tokenPairCookies(accessToken, refreshToken, config)
821
- }
824
+ headers: cookieHeaders(tokenPairCookies(accessToken, refreshToken, config))
822
825
  }
823
826
  );
824
827
  },
@@ -1150,9 +1153,7 @@ function authController(store, config, bus) {
1150
1153
  },
1151
1154
  {
1152
1155
  status: 201,
1153
- headers: {
1154
- "Set-Cookie": tokenPairCookies(accessToken, refreshToken, config)
1155
- }
1156
+ headers: cookieHeaders(tokenPairCookies(accessToken, refreshToken, config))
1156
1157
  }
1157
1158
  );
1158
1159
  }
@@ -1212,9 +1213,7 @@ function authController(store, config, bus) {
1212
1213
  },
1213
1214
  {
1214
1215
  status: 202,
1215
- headers: {
1216
- "Set-Cookie": tokenPairCookies(accessToken, refreshToken, config)
1217
- }
1216
+ headers: cookieHeaders(tokenPairCookies(accessToken, refreshToken, config))
1218
1217
  }
1219
1218
  );
1220
1219
  }
@@ -1271,9 +1270,7 @@ function authController(store, config, bus) {
1271
1270
  },
1272
1271
  {
1273
1272
  status: 200,
1274
- headers: {
1275
- "Set-Cookie": tokenPairCookies(accessToken, refreshToken, config)
1276
- }
1273
+ headers: cookieHeaders(tokenPairCookies(accessToken, refreshToken, config))
1277
1274
  }
1278
1275
  );
1279
1276
  }
@@ -1314,9 +1311,7 @@ function authController(store, config, bus) {
1314
1311
  },
1315
1312
  {
1316
1313
  status: 202,
1317
- headers: {
1318
- "Set-Cookie": tokenPairCookies(accessToken, refreshToken, config)
1319
- }
1314
+ headers: cookieHeaders(tokenPairCookies(accessToken, refreshToken, config))
1320
1315
  }
1321
1316
  );
1322
1317
  }
@@ -1335,9 +1330,7 @@ function authController(store, config, bus) {
1335
1330
  { reason: "USER_LOGOUT", explanation: "Logged out successfully." },
1336
1331
  {
1337
1332
  status: 200,
1338
- headers: {
1339
- "Set-Cookie": clearedTokenCookies(config)
1340
- }
1333
+ headers: cookieHeaders(clearedTokenCookies(config))
1341
1334
  }
1342
1335
  );
1343
1336
  },
@@ -1376,9 +1369,7 @@ function authController(store, config, bus) {
1376
1369
  },
1377
1370
  {
1378
1371
  status: 200,
1379
- headers: {
1380
- "Set-Cookie": tokenPairCookies(accessToken, refreshToken, config)
1381
- }
1372
+ headers: cookieHeaders(tokenPairCookies(accessToken, refreshToken, config))
1382
1373
  }
1383
1374
  );
1384
1375
  },
@@ -1525,9 +1516,7 @@ function authController(store, config, bus) {
1525
1516
  },
1526
1517
  {
1527
1518
  status: 200,
1528
- headers: {
1529
- "Set-Cookie": tokenPairCookies(accessToken, refreshToken, config)
1530
- }
1519
+ headers: cookieHeaders(tokenPairCookies(accessToken, refreshToken, config))
1531
1520
  }
1532
1521
  );
1533
1522
  }
@@ -1831,9 +1820,7 @@ function userController(store, config, bus) {
1831
1820
  { reason: "ACCOUNT_DELETED", explanation: "Account successfully deleted." },
1832
1821
  {
1833
1822
  status: 200,
1834
- headers: {
1835
- "Set-Cookie": clearedTokenCookies(config)
1836
- }
1823
+ headers: cookieHeaders(clearedTokenCookies(config))
1837
1824
  }
1838
1825
  );
1839
1826
  }
@@ -1935,9 +1922,7 @@ function oauthController(store, config) {
1935
1922
  },
1936
1923
  {
1937
1924
  status: 200,
1938
- headers: {
1939
- "Set-Cookie": tokenPairCookies(accessToken, refreshToken, config)
1940
- }
1925
+ headers: cookieHeaders(tokenPairCookies(accessToken, refreshToken, config))
1941
1926
  }
1942
1927
  );
1943
1928
  }