@asaidimu/hestia-mock 1.15.0 → 1.16.1
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/index.cjs +29 -2
- package/index.cjs.map +1 -1
- package/{index.d.ts → index.d.mts} +1 -1
- package/{index.js → index.mjs} +30 -3
- package/index.mjs.map +1 -0
- package/package.json +2 -2
- package/index.js.map +0 -1
|
@@ -560,4 +560,4 @@ declare const err: {
|
|
|
560
560
|
};
|
|
561
561
|
//#endregion
|
|
562
562
|
export { DEFAULT_DB_NAME, DEFAULT_SEED, EventBus, type IdbPersistenceConfig, IndexedDbTransport, type IndexedDbTransportOptions, type MockHestia, type MockHestiaOptions, MockHestiaServer, type MockHestiaServerConfig, MockHttpError, type MockServerOptions, type MockTables, STORES, type SeedConfig, type StoredDocument, Topics, createIdbPersistence, createMockHestia, evaluateFilter, executeQuery, getField, err as mockErrors, openMockDatabase, seedDatabase, sortDocs, statusForError, wipeAllStores };
|
|
563
|
-
//# sourceMappingURL=index.d.
|
|
563
|
+
//# sourceMappingURL=index.d.mts.map
|
package/{index.js → index.mjs}
RENAMED
|
@@ -673,6 +673,10 @@ const OPERATION_POLICIES = [
|
|
|
673
673
|
name: "system:auth:session:delete",
|
|
674
674
|
rule: "authenticated"
|
|
675
675
|
},
|
|
676
|
+
{
|
|
677
|
+
name: "system:auth:session:get",
|
|
678
|
+
rule: "authenticated"
|
|
679
|
+
},
|
|
676
680
|
{
|
|
677
681
|
name: "system:auth:password:reset",
|
|
678
682
|
rule: "anonymous"
|
|
@@ -1250,13 +1254,32 @@ function userHandlers(deps) {
|
|
|
1250
1254
|
if (!email || !password) throw err.invalidCredentials();
|
|
1251
1255
|
const user = await verifyCredentials(tables, email, password);
|
|
1252
1256
|
if (!user) throw err.invalidCredentials();
|
|
1257
|
+
const session = await createSession(tables, user._id_);
|
|
1253
1258
|
ctx.identity = {
|
|
1254
1259
|
user,
|
|
1255
1260
|
auth_method: "password",
|
|
1256
|
-
session_id:
|
|
1261
|
+
session_id: session.token,
|
|
1257
1262
|
is_admin: isAdmin(user)
|
|
1258
1263
|
};
|
|
1259
|
-
return ok({
|
|
1264
|
+
return ok({
|
|
1265
|
+
user: sanitizeUser(clone(user)),
|
|
1266
|
+
expires_at: Math.floor(session.expires_at / 1e3)
|
|
1267
|
+
});
|
|
1268
|
+
}
|
|
1269
|
+
},
|
|
1270
|
+
"system:auth:session:get": {
|
|
1271
|
+
access: "authenticated",
|
|
1272
|
+
handler: async (ctx) => {
|
|
1273
|
+
const identity = ctx.identity;
|
|
1274
|
+
let expiresAt = null;
|
|
1275
|
+
if (identity.session_id) {
|
|
1276
|
+
const session = await tables.sessions.get(identity.session_id);
|
|
1277
|
+
expiresAt = session ? Math.floor(session.expires_at / 1e3) : null;
|
|
1278
|
+
}
|
|
1279
|
+
return ok({
|
|
1280
|
+
user: sanitizeUser(clone(identity.user)),
|
|
1281
|
+
expires_at: expiresAt
|
|
1282
|
+
});
|
|
1260
1283
|
}
|
|
1261
1284
|
},
|
|
1262
1285
|
"system:auth:session:delete": {
|
|
@@ -3208,6 +3231,10 @@ const MOCK_ROUTE_TABLE = {
|
|
|
3208
3231
|
method: "DELETE",
|
|
3209
3232
|
route: "/system/auth/session/delete"
|
|
3210
3233
|
},
|
|
3234
|
+
"system:auth:session:get": {
|
|
3235
|
+
method: "GET",
|
|
3236
|
+
route: "/system/auth/session/get"
|
|
3237
|
+
},
|
|
3211
3238
|
"system:auth:token:elevate": {
|
|
3212
3239
|
method: "POST",
|
|
3213
3240
|
route: "/system/auth/token/elevate"
|
|
@@ -3967,4 +3994,4 @@ async function createMockHestia(options = {}) {
|
|
|
3967
3994
|
//#endregion
|
|
3968
3995
|
export { DEFAULT_DB_NAME, DEFAULT_SEED, EventBus, IndexedDbTransport, MockHestiaServer, MockHttpError, STORES, Topics, createIdbPersistence, createMockHestia, evaluateFilter, executeQuery, getField, err as mockErrors, openMockDatabase, seedDatabase, sortDocs, statusForError, wipeAllStores };
|
|
3969
3996
|
|
|
3970
|
-
//# sourceMappingURL=index.
|
|
3997
|
+
//# sourceMappingURL=index.mjs.map
|