mirror of
https://codeberg.org/timelimit/timelimit-server.git
synced 2026-08-31 19:03:45 +02:00
Add basically support for encrypted app list syncing
This commit is contained in:
+4
-3
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* server component for the TimeLimit App
|
||||
* Copyright (C) 2019 - 2020 Jonas Lochmann
|
||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
@@ -90,7 +90,7 @@ export const createSyncRouter = ({ database, websocket, connectedDevicesManager,
|
||||
where: {
|
||||
deviceAuthToken: body.deviceAuthToken
|
||||
},
|
||||
attributes: ['familyId', 'lastConnectivity'],
|
||||
attributes: ['familyId', 'deviceId', 'lastConnectivity'],
|
||||
transaction
|
||||
})
|
||||
|
||||
@@ -98,7 +98,7 @@ export const createSyncRouter = ({ database, websocket, connectedDevicesManager,
|
||||
throw new Unauthorized()
|
||||
}
|
||||
|
||||
const { familyId, lastConnectivity } = deviceEntryUnsafe
|
||||
const { familyId, deviceId, lastConnectivity } = deviceEntryUnsafe
|
||||
const now = getRoundedTimestampForLastConnectivity()
|
||||
|
||||
if (parseInt(lastConnectivity, 10) !== now) {
|
||||
@@ -115,6 +115,7 @@ export const createSyncRouter = ({ database, websocket, connectedDevicesManager,
|
||||
return generateServerDataStatus({
|
||||
database,
|
||||
familyId,
|
||||
deviceId,
|
||||
clientStatus: body.status,
|
||||
transaction
|
||||
})
|
||||
|
||||
@@ -60,6 +60,18 @@ const definitions = {
|
||||
},
|
||||
"clientLevel": {
|
||||
"type": "number"
|
||||
},
|
||||
"devicesDetail": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"$ref": "#/definitions/DeviceDataStatus"
|
||||
}
|
||||
},
|
||||
"kri": {
|
||||
"type": "number"
|
||||
},
|
||||
"kr": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
@@ -97,6 +109,18 @@ const definitions = {
|
||||
"usedTime"
|
||||
]
|
||||
},
|
||||
"DeviceDataStatus": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"appsB": {
|
||||
"type": "string"
|
||||
},
|
||||
"appsD": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"ParentPassword": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -1555,6 +1579,25 @@ const definitions = {
|
||||
"type"
|
||||
]
|
||||
},
|
||||
"SerializedFinishKeyRequestAction": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"FINISH_KEY_REQUEST"
|
||||
]
|
||||
},
|
||||
"dsn": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"dsn",
|
||||
"type"
|
||||
]
|
||||
},
|
||||
"SerializedForceSyncAction": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -1570,6 +1613,37 @@ const definitions = {
|
||||
"type"
|
||||
]
|
||||
},
|
||||
"SerializedReplyToKeyRequestAction": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"REPLY_TO_KEY_REQUEST"
|
||||
]
|
||||
},
|
||||
"rsn": {
|
||||
"type": "number"
|
||||
},
|
||||
"tempKey": {
|
||||
"type": "string"
|
||||
},
|
||||
"encryptedKey": {
|
||||
"type": "string"
|
||||
},
|
||||
"signature": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"encryptedKey",
|
||||
"rsn",
|
||||
"signature",
|
||||
"tempKey",
|
||||
"type"
|
||||
]
|
||||
},
|
||||
"SerializedMarkTaskPendingAction": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -1589,6 +1663,31 @@ const definitions = {
|
||||
"type"
|
||||
]
|
||||
},
|
||||
"SerializedUpdateInstalledAppsAction": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"UPDATE_INSTALLED_APPS"
|
||||
]
|
||||
},
|
||||
"b": {
|
||||
"type": "string"
|
||||
},
|
||||
"d": {
|
||||
"type": "string"
|
||||
},
|
||||
"w": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"type",
|
||||
"w"
|
||||
]
|
||||
},
|
||||
"SerializedRemoveInstalledAppsAction": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -1611,6 +1710,43 @@ const definitions = {
|
||||
"type"
|
||||
]
|
||||
},
|
||||
"SerializedSendKeyRequestAction": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"SEND_KEY_REQUEST"
|
||||
]
|
||||
},
|
||||
"dsn": {
|
||||
"type": "number"
|
||||
},
|
||||
"deviceId": {
|
||||
"type": "string"
|
||||
},
|
||||
"categoryId": {
|
||||
"type": "string"
|
||||
},
|
||||
"dataType": {
|
||||
"type": "number"
|
||||
},
|
||||
"tempKey": {
|
||||
"type": "string"
|
||||
},
|
||||
"signature": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"dataType",
|
||||
"dsn",
|
||||
"signature",
|
||||
"tempKey",
|
||||
"type"
|
||||
]
|
||||
},
|
||||
"SerializedSignOutAtDeviceAction": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -1763,6 +1899,25 @@ const definitions = {
|
||||
"type"
|
||||
]
|
||||
},
|
||||
"SerializedUploadDevicePublicKeyAction": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"UPLOAD_DEVICE_PUBLIC_KEY"
|
||||
]
|
||||
},
|
||||
"key": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"key",
|
||||
"type"
|
||||
]
|
||||
},
|
||||
"SerializedChildChangePasswordAction": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -1916,6 +2071,9 @@ const definitions = {
|
||||
},
|
||||
"mFlags": {
|
||||
"type": "number"
|
||||
},
|
||||
"pk": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
@@ -1978,6 +2136,40 @@ const definitions = {
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"ServerExtendedDeviceData": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"deviceId": {
|
||||
"type": "string"
|
||||
},
|
||||
"appsBase": {
|
||||
"$ref": "#/definitions/ServerCryptContainer"
|
||||
},
|
||||
"appsDiff": {
|
||||
"$ref": "#/definitions/ServerCryptContainer"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"deviceId"
|
||||
]
|
||||
},
|
||||
"ServerCryptContainer": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"version": {
|
||||
"type": "string"
|
||||
},
|
||||
"data": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"data",
|
||||
"version"
|
||||
]
|
||||
},
|
||||
"ServerInstalledAppsData": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -2443,6 +2635,76 @@ const definitions = {
|
||||
"timeZone",
|
||||
"type"
|
||||
]
|
||||
},
|
||||
"ServerKeyRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"srvSeq": {
|
||||
"type": "number"
|
||||
},
|
||||
"senId": {
|
||||
"type": "string"
|
||||
},
|
||||
"senSeq": {
|
||||
"type": "number"
|
||||
},
|
||||
"deviceId": {
|
||||
"type": "string"
|
||||
},
|
||||
"categoryId": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"type": "number"
|
||||
},
|
||||
"tempKey": {
|
||||
"type": "string"
|
||||
},
|
||||
"signature": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"senId",
|
||||
"senSeq",
|
||||
"signature",
|
||||
"srvSeq",
|
||||
"tempKey",
|
||||
"type"
|
||||
]
|
||||
},
|
||||
"ServerKeyResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"srvSeq": {
|
||||
"type": "number"
|
||||
},
|
||||
"sender": {
|
||||
"type": "string"
|
||||
},
|
||||
"rqSeq": {
|
||||
"type": "number"
|
||||
},
|
||||
"tempKey": {
|
||||
"type": "string"
|
||||
},
|
||||
"cryptKey": {
|
||||
"type": "string"
|
||||
},
|
||||
"signature": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"cryptKey",
|
||||
"rqSeq",
|
||||
"sender",
|
||||
"signature",
|
||||
"srvSeq",
|
||||
"tempKey"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2753,15 +3015,27 @@ export const isSerializedAppLogicAction: (value: unknown) => value is Serialized
|
||||
{
|
||||
"$ref": "#/definitions/SerializedAddUsedTimeActionVersion2"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/SerializedFinishKeyRequestAction"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/SerializedForceSyncAction"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/SerializedReplyToKeyRequestAction"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/SerializedMarkTaskPendingAction"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/SerializedUpdateInstalledAppsAction"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/SerializedRemoveInstalledAppsAction"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/SerializedSendKeyRequestAction"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/SerializedSignOutAtDeviceAction"
|
||||
},
|
||||
@@ -2773,6 +3047,9 @@ export const isSerializedAppLogicAction: (value: unknown) => value is Serialized
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/SerializedUpdateDeviceStatusAction"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/SerializedUploadDevicePublicKeyAction"
|
||||
}
|
||||
],
|
||||
"definitions": definitions,
|
||||
|
||||
Reference in New Issue
Block a user