@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 +17 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -32
- package/dist/index.js.map +1 -1
- package/dist/migrations/sql/001_auth.sql +73 -0
- package/dist/migrations/sql/002_phone_auth.sql +20 -0
- package/dist/migrations/sql/003_phone_registration_name.sql +4 -0
- package/dist/migrations/sql/004_drop_phone_verif_name_cols.sql +5 -0
- package/dist/migrations/sql/005_phone_verification_user_id.sql +6 -0
- package/dist/migrations/sql/006_drop_phone_verified_at.sql +1 -0
- package/dist/migrations/sql/007_email_verif_user_id_pk.sql +14 -0
- package/dist/migrations/sql/008_password_reset_pin.sql +4 -0
- package/dist/migrations/sql/009_password_reset_created_at.sql +1 -0
- package/dist/migrations/sql/010_mfa_pending_secret.sql +3 -0
- package/dist/migrations/sql/011_mfa_backup_codes.sql +10 -0
- package/dist/migrations/sql/012_drop_skills.sql +1 -0
- package/dist/migrations/sql/013_sessions_sid.sql +5 -0
- package/package.json +4 -4
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
|
-
]
|
|
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
|
-
]
|
|
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
|
}
|