Merge branch 'testing-improvements'
Combines testing improvements with org invites feature: - Sessions and devices now use subrouter structure (me.sessions.*, me.devices.*) - Added me.invites subrouter for org invitations - Updated test scripts to include coverage and unit tests Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -42,12 +42,16 @@ export const meRoutes = {
|
||||
accept: acceptInvite,
|
||||
decline: declineInvite,
|
||||
},
|
||||
listSessions,
|
||||
revokeSession,
|
||||
revokeAllSessions,
|
||||
getDeviceInfo,
|
||||
trustDevice,
|
||||
listTrustedDevices,
|
||||
untrustDevice,
|
||||
revokeAllTrustedDevices,
|
||||
sessions: {
|
||||
list: listSessions,
|
||||
revoke: revokeSession,
|
||||
revokeAll: revokeAllSessions,
|
||||
},
|
||||
devices: {
|
||||
getInfo: getDeviceInfo,
|
||||
trust: trustDevice,
|
||||
listTrusted: listTrustedDevices,
|
||||
untrust: untrustDevice,
|
||||
revokeAll: revokeAllTrustedDevices,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -13,7 +13,7 @@ import { defaultDeviceName, requireDeviceFingerprint } from "./helpers.js";
|
||||
* @throws BAD_REQUEST if no device fingerprint found
|
||||
* @throws NOT_FOUND if device doesn't exist
|
||||
*/
|
||||
export const getDeviceInfo = os.me.getDeviceInfo
|
||||
export const getDeviceInfo = os.me.devices.getInfo
|
||||
.use(authMiddleware)
|
||||
.handler(async ({ context }) => {
|
||||
const fingerprint = requireDeviceFingerprint(context.reqHeaders);
|
||||
@@ -48,7 +48,7 @@ export const getDeviceInfo = os.me.getDeviceInfo
|
||||
* @throws BAD_REQUEST if no device fingerprint found
|
||||
* @throws NOT_FOUND if device doesn't exist
|
||||
*/
|
||||
export const trustDevice = os.me.trustDevice
|
||||
export const trustDevice = os.me.devices.trust
|
||||
.use(authMiddleware)
|
||||
.handler(async ({ input, context }) => {
|
||||
const { name } = input;
|
||||
@@ -73,7 +73,7 @@ export const trustDevice = os.me.trustDevice
|
||||
* - Requires authentication
|
||||
* - Returns all trusted devices for the current user
|
||||
*/
|
||||
export const listTrustedDevices = os.me.listTrustedDevices
|
||||
export const listTrustedDevices = os.me.devices.listTrusted
|
||||
.use(authMiddleware)
|
||||
.handler(async ({ context }) => {
|
||||
const devices = await context.db
|
||||
@@ -102,7 +102,7 @@ export const listTrustedDevices = os.me.listTrustedDevices
|
||||
* - Marks device as untrusted by ID
|
||||
* @throws NOT_FOUND if device doesn't exist
|
||||
*/
|
||||
export const untrustDevice = os.me.untrustDevice
|
||||
export const untrustDevice = os.me.devices.untrust
|
||||
.use(authMiddleware)
|
||||
.handler(async ({ input, context }) => {
|
||||
const result = await context.db
|
||||
@@ -124,7 +124,7 @@ export const untrustDevice = os.me.untrustDevice
|
||||
* - Requires authentication
|
||||
* - Marks all devices as untrusted
|
||||
*/
|
||||
export const revokeAllTrustedDevices = os.me.revokeAllTrustedDevices
|
||||
export const revokeAllTrustedDevices = os.me.devices.revokeAll
|
||||
.use(authMiddleware)
|
||||
.handler(async ({ context }) => {
|
||||
await context.db
|
||||
|
||||
@@ -11,7 +11,7 @@ import { authMiddleware, os } from "../base.js";
|
||||
* - Returns all sessions for the current user
|
||||
* - Includes isCurrent flag to identify active session
|
||||
*/
|
||||
export const listSessions = os.me.listSessions
|
||||
export const listSessions = os.me.sessions.list
|
||||
.use(authMiddleware)
|
||||
.handler(async ({ context }) => {
|
||||
const sessions = await context.db
|
||||
@@ -42,7 +42,7 @@ export const listSessions = os.me.listSessions
|
||||
* @throws NOT_FOUND if session doesn't exist
|
||||
* @throws BAD_REQUEST if trying to revoke current session
|
||||
*/
|
||||
export const revokeSession = os.me.revokeSession
|
||||
export const revokeSession = os.me.sessions.revoke
|
||||
.use(authMiddleware)
|
||||
.handler(async ({ input, context }) => {
|
||||
const { sessionId } = input;
|
||||
@@ -74,7 +74,7 @@ export const revokeSession = os.me.revokeSession
|
||||
* - Requires authentication
|
||||
* - Revokes all sessions except current
|
||||
*/
|
||||
export const revokeAllSessions = os.me.revokeAllSessions
|
||||
export const revokeAllSessions = os.me.sessions.revokeAll
|
||||
.use(authMiddleware)
|
||||
.handler(async ({ context }) => {
|
||||
// Revoke all sessions except current
|
||||
|
||||
Reference in New Issue
Block a user