Add platformLevel and platformType

This commit is contained in:
Jonas Lochmann 2023-06-12 02:00:00 +02:00
parent 376a2cc624
commit 8ec0781859
No known key found for this signature in database
GPG key ID: 8B8C9AEE10FA5B36
18 changed files with 375 additions and 11 deletions

View file

@ -545,6 +545,12 @@
},
"addedManipulationFlags": {
"type": "number"
},
"platformType": {
"type": "string"
},
"platformLevel": {
"type": "number"
}
},
"additionalProperties": false,

View file

@ -212,6 +212,12 @@
},
"pk": {
"type": "string"
},
"pType": {
"type": "string"
},
"pLevel": {
"type": "number"
}
},
"additionalProperties": false,
@ -240,6 +246,7 @@
"model",
"name",
"networkTime",
"pLevel",
"qOrLater",
"reboot",
"rebootIsManipulation",

View file

@ -0,0 +1,15 @@
# Untitled number in SerializedAppLogicAction Schema
```txt
https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateDeviceStatusAction/properties/platformLevel
```
| Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In |
| :------------------ | :--------- | :------------- | :---------------------- | :---------------- | :-------------------- | :------------------ | :---------------------------------------------------------------------------------------------------- |
| Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [SerializedAppLogicAction.schema.json\*](SerializedAppLogicAction.schema.json "open original schema") |
## platformLevel Type
`number`

View file

@ -0,0 +1,15 @@
# Untitled string in SerializedAppLogicAction Schema
```txt
https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateDeviceStatusAction/properties/platformType
```
| Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In |
| :------------------ | :--------- | :------------- | :---------------------- | :---------------- | :-------------------- | :------------------ | :---------------------------------------------------------------------------------------------------- |
| Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [SerializedAppLogicAction.schema.json\*](SerializedAppLogicAction.schema.json "open original schema") |
## platformType Type
`string`

View file

@ -28,6 +28,8 @@ https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateDevic
| [didReboot](#didreboot) | `boolean` | Optional | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdatedevicestatusaction-properties-didreboot.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateDeviceStatusAction/properties/didReboot") |
| [isQOrLaterNow](#isqorlaternow) | `boolean` | Optional | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdatedevicestatusaction-properties-isqorlaternow.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateDeviceStatusAction/properties/isQOrLaterNow") |
| [addedManipulationFlags](#addedmanipulationflags) | `number` | Optional | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdatedevicestatusaction-properties-addedmanipulationflags.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateDeviceStatusAction/properties/addedManipulationFlags") |
| [platformType](#platformtype) | `string` | Optional | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdatedevicestatusaction-properties-platformtype.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateDeviceStatusAction/properties/platformType") |
| [platformLevel](#platformlevel) | `number` | Optional | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdatedevicestatusaction-properties-platformlevel.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateDeviceStatusAction/properties/platformLevel") |
## type
@ -257,3 +259,39 @@ https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateDevic
### addedManipulationFlags Type
`number`
## platformType
`platformType`
* is optional
* Type: `string`
* cannot be null
* defined in: [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdatedevicestatusaction-properties-platformtype.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateDeviceStatusAction/properties/platformType")
### platformType Type
`string`
## platformLevel
`platformLevel`
* is optional
* Type: `number`
* cannot be null
* defined in: [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdatedevicestatusaction-properties-platformlevel.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateDeviceStatusAction/properties/platformLevel")
### platformLevel Type
`number`

View file

@ -1240,6 +1240,8 @@ Reference this group by using
| [didReboot](#didreboot) | `boolean` | Optional | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdatedevicestatusaction-properties-didreboot.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateDeviceStatusAction/properties/didReboot") |
| [isQOrLaterNow](#isqorlaternow) | `boolean` | Optional | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdatedevicestatusaction-properties-isqorlaternow.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateDeviceStatusAction/properties/isQOrLaterNow") |
| [addedManipulationFlags](#addedmanipulationflags) | `number` | Optional | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdatedevicestatusaction-properties-addedmanipulationflags.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateDeviceStatusAction/properties/addedManipulationFlags") |
| [platformType](#platformtype) | `string` | Optional | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdatedevicestatusaction-properties-platformtype.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateDeviceStatusAction/properties/platformType") |
| [platformLevel](#platformlevel) | `number` | Optional | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdatedevicestatusaction-properties-platformlevel.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateDeviceStatusAction/properties/platformLevel") |
### type
@ -1470,6 +1472,42 @@ Reference this group by using
`number`
### platformType
`platformType`
* is optional
* Type: `string`
* cannot be null
* defined in: [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdatedevicestatusaction-properties-platformtype.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateDeviceStatusAction/properties/platformType")
#### platformType Type
`string`
### platformLevel
`platformLevel`
* is optional
* Type: `number`
* cannot be null
* defined in: [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdatedevicestatusaction-properties-platformlevel.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateDeviceStatusAction/properties/platformLevel")
#### platformLevel Type
`number`
## Definitions group SerializedUploadDevicePublicKeyAction
Reference this group by using

View file

@ -0,0 +1,15 @@
# Untitled number in ServerDataStatus Schema
```txt
https://timelimit.io/ServerDataStatus#/definitions/ServerDeviceData/properties/pLevel
```
| Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In |
| :------------------ | :--------- | :------------- | :---------------------- | :---------------- | :-------------------- | :------------------ | :------------------------------------------------------------------------------------ |
| Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [ServerDataStatus.schema.json\*](ServerDataStatus.schema.json "open original schema") |
## pLevel Type
`number`

View file

@ -0,0 +1,15 @@
# Untitled string in ServerDataStatus Schema
```txt
https://timelimit.io/ServerDataStatus#/definitions/ServerDeviceData/properties/pType
```
| Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In |
| :------------------ | :--------- | :------------- | :---------------------- | :---------------- | :-------------------- | :------------------ | :------------------------------------------------------------------------------------ |
| Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [ServerDataStatus.schema.json\*](ServerDataStatus.schema.json "open original schema") |
## pType Type
`string`

View file

@ -50,6 +50,8 @@ https://timelimit.io/ServerDataStatus#/definitions/ServerDeviceData
| [qOrLater](#qorlater) | `boolean` | Required | cannot be null | [ServerDataStatus](serverdatastatus-definitions-serverdevicedata-properties-qorlater.md "https://timelimit.io/ServerDataStatus#/definitions/ServerDeviceData/properties/qOrLater") |
| [mFlags](#mflags) | `number` | Required | cannot be null | [ServerDataStatus](serverdatastatus-definitions-serverdevicedata-properties-mflags.md "https://timelimit.io/ServerDataStatus#/definitions/ServerDeviceData/properties/mFlags") |
| [pk](#pk) | `string` | Optional | cannot be null | [ServerDataStatus](serverdatastatus-definitions-serverdevicedata-properties-pk.md "https://timelimit.io/ServerDataStatus#/definitions/ServerDeviceData/properties/pk") |
| [pType](#ptype) | `string` | Optional | cannot be null | [ServerDataStatus](serverdatastatus-definitions-serverdevicedata-properties-ptype.md "https://timelimit.io/ServerDataStatus#/definitions/ServerDeviceData/properties/pType") |
| [pLevel](#plevel) | `number` | Required | cannot be null | [ServerDataStatus](serverdatastatus-definitions-serverdevicedata-properties-plevel.md "https://timelimit.io/ServerDataStatus#/definitions/ServerDeviceData/properties/pLevel") |
## deviceId
@ -718,3 +720,39 @@ https://timelimit.io/ServerDataStatus#/definitions/ServerDeviceData
### pk Type
`string`
## pType
`pType`
* is optional
* Type: `string`
* cannot be null
* defined in: [ServerDataStatus](serverdatastatus-definitions-serverdevicedata-properties-ptype.md "https://timelimit.io/ServerDataStatus#/definitions/ServerDeviceData/properties/pType")
### pType Type
`string`
## pLevel
`pLevel`
* is required
* Type: `number`
* cannot be null
* defined in: [ServerDataStatus](serverdatastatus-definitions-serverdevicedata-properties-plevel.md "https://timelimit.io/ServerDataStatus#/definitions/ServerDeviceData/properties/pLevel")
### pLevel Type
`number`

View file

@ -435,6 +435,8 @@ Reference this group by using
| [qOrLater](#qorlater) | `boolean` | Required | cannot be null | [ServerDataStatus](serverdatastatus-definitions-serverdevicedata-properties-qorlater.md "https://timelimit.io/ServerDataStatus#/definitions/ServerDeviceData/properties/qOrLater") |
| [mFlags](#mflags) | `number` | Required | cannot be null | [ServerDataStatus](serverdatastatus-definitions-serverdevicedata-properties-mflags.md "https://timelimit.io/ServerDataStatus#/definitions/ServerDeviceData/properties/mFlags") |
| [pk](#pk) | `string` | Optional | cannot be null | [ServerDataStatus](serverdatastatus-definitions-serverdevicedata-properties-pk.md "https://timelimit.io/ServerDataStatus#/definitions/ServerDeviceData/properties/pk") |
| [pType](#ptype) | `string` | Optional | cannot be null | [ServerDataStatus](serverdatastatus-definitions-serverdevicedata-properties-ptype.md "https://timelimit.io/ServerDataStatus#/definitions/ServerDeviceData/properties/pType") |
| [pLevel](#plevel) | `number` | Required | cannot be null | [ServerDataStatus](serverdatastatus-definitions-serverdevicedata-properties-plevel.md "https://timelimit.io/ServerDataStatus#/definitions/ServerDeviceData/properties/pLevel") |
### deviceId
@ -1104,6 +1106,42 @@ Reference this group by using
`string`
### pType
`pType`
* is optional
* Type: `string`
* cannot be null
* defined in: [ServerDataStatus](serverdatastatus-definitions-serverdevicedata-properties-ptype.md "https://timelimit.io/ServerDataStatus#/definitions/ServerDeviceData/properties/pType")
#### pType Type
`string`
### pLevel
`pLevel`
* is required
* Type: `number`
* cannot be null
* defined in: [ServerDataStatus](serverdatastatus-definitions-serverdevicedata-properties-plevel.md "https://timelimit.io/ServerDataStatus#/definitions/ServerDeviceData/properties/pLevel")
#### pLevel Type
`number`
## Definitions group ProtectionLevel
Reference this group by using

View file

@ -1,6 +1,6 @@
/*
* server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann
* Copyright (C) 2019 - 2023 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
@ -15,6 +15,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { minPlatformLevel, maxPlatformLevel, minPlatformTypeLength, maxPlatformTypeLength } from '../database/device'
import { NewPermissionStatus } from '../model/newpermissionstatus'
import { ProtectionLevel } from '../model/protectionlevel'
import { RuntimePermissionStatus } from '../model/runtimepermissionstatus'
@ -33,6 +34,8 @@ export class UpdateDeviceStatusAction extends AppLogicAction {
readonly didReboot: boolean
readonly isQOrLaterNow: boolean
readonly addedManipulationFlags: number
readonly platformType?: string
readonly platformLevel?: number
constructor ({
newProtetionLevel,
@ -43,7 +46,9 @@ export class UpdateDeviceStatusAction extends AppLogicAction {
newAppVersion,
didReboot,
isQOrLaterNow,
addedManipulationFlags
addedManipulationFlags,
platformType,
platformLevel
}: {
newProtetionLevel?: ProtectionLevel
newUsageStatsPermissionStatus?: RuntimePermissionStatus
@ -54,6 +59,8 @@ export class UpdateDeviceStatusAction extends AppLogicAction {
didReboot: boolean
isQOrLaterNow: boolean
addedManipulationFlags: number
platformType?: string
platformLevel?: number
}) {
super()
@ -67,6 +74,20 @@ export class UpdateDeviceStatusAction extends AppLogicAction {
assertSafeInteger({ actionType, field: 'addedManipulationFlags', value: addedManipulationFlags })
if (platformType !== undefined) {
if (platformType.length < minPlatformTypeLength || platformType.length > maxPlatformTypeLength) {
throwOutOfRange({ actionType, field: 'platformType.length', value: platformType.length })
}
}
if (platformLevel !== undefined) {
assertSafeInteger({ actionType, field: 'platformLevel', value: platformLevel })
if (platformLevel < minPlatformLevel || platformLevel > maxPlatformLevel) {
throwOutOfRange({ actionType, field: 'platformLevel', value: platformLevel })
}
}
this.newProtetionLevel = newProtetionLevel
this.newUsageStatsPermissionStatus = newUsageStatsPermissionStatus
this.newNotificationAccessPermission = newNotificationAccessPermission
@ -76,6 +97,8 @@ export class UpdateDeviceStatusAction extends AppLogicAction {
this.didReboot = didReboot
this.isQOrLaterNow = isQOrLaterNow
this.addedManipulationFlags = addedManipulationFlags
this.platformType = platformType
this.platformLevel = platformLevel
}
static parse = ({
@ -87,7 +110,9 @@ export class UpdateDeviceStatusAction extends AppLogicAction {
appVersion,
didReboot,
isQOrLaterNow,
addedManipulationFlags
addedManipulationFlags,
platformType,
platformLevel
}: SerializedUpdateDeviceStatusAction) => (
new UpdateDeviceStatusAction({
newProtetionLevel: protectionLevel,
@ -98,7 +123,9 @@ export class UpdateDeviceStatusAction extends AppLogicAction {
newAppVersion: appVersion,
didReboot: !!didReboot,
isQOrLaterNow: !!isQOrLaterNow,
addedManipulationFlags: addedManipulationFlags || 0
addedManipulationFlags: addedManipulationFlags || 0,
platformType: platformType,
platformLevel: platformLevel
})
)
}
@ -114,4 +141,6 @@ export interface SerializedUpdateDeviceStatusAction {
didReboot?: boolean
isQOrLaterNow?: boolean
addedManipulationFlags?: number
platformType?: string
platformLevel?: number
}

View file

@ -1982,6 +1982,12 @@ const definitions = {
},
"addedManipulationFlags": {
"type": "number"
},
"platformType": {
"type": "string"
},
"platformLevel": {
"type": "number"
}
},
"additionalProperties": false,
@ -2164,6 +2170,12 @@ const definitions = {
},
"pk": {
"type": "string"
},
"pType": {
"type": "string"
},
"pLevel": {
"type": "number"
}
},
"additionalProperties": false,
@ -2192,6 +2204,7 @@ const definitions = {
"model",
"name",
"networkTime",
"pLevel",
"qOrLater",
"reboot",
"rebootIsManipulation",

View file

@ -1,6 +1,6 @@
/*
* server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann
* Copyright (C) 2019 - 2023 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
@ -37,6 +37,12 @@ export const DeviceManipulationFlags = {
ALL: 1
}
export const minPlatformTypeLength = 1
export const maxPlatformTypeLength = 8
export const minPlatformLevel = 0
export const maxPlatformLevel = 128
export interface DeviceAttributesVersion1 {
familyId: string
deviceId: string
@ -119,11 +125,17 @@ export interface DeviceAttributesVersion14 {
nextKeyReplySequenceNumber: string
}
export interface DeviceAttributesVersion15 {
platformType: string | null
platformLevel: number
}
export type DeviceAttributes = DeviceAttributesVersion1 & DeviceAttributesVersion2 &
DeviceAttributesVersion3 & DeviceAttributesVersion4 & DeviceAttributesVersion5 &
DeviceAttributesVersion6 & DeviceAttributesVersion7 & DeviceAttributesVersion8 &
DeviceAttributesVersion9 & DeviceAttributesVersion10 & DeviceAttributesVersion11 &
DeviceAttributesVersion12 & DeviceAttributesVersion13 & DeviceAttributesVersion14
DeviceAttributesVersion12 & DeviceAttributesVersion13 & DeviceAttributesVersion14 &
DeviceAttributesVersion15
export type DeviceModel = Sequelize.Model<DeviceAttributes> & DeviceAttributes
export type DeviceModelStatic = typeof Sequelize.Model & {
@ -305,6 +317,26 @@ export const attributesVersion14: SequelizeAttributes<DeviceAttributesVersion14>
}
}
export const attributesVersion15: SequelizeAttributes<DeviceAttributesVersion15> = {
platformType: {
type: Sequelize.STRING(maxPlatformTypeLength),
allowNull: true,
defaultValue: null,
validate: {
len: [minPlatformTypeLength, maxPlatformTypeLength]
}
},
platformLevel: {
type: Sequelize.INTEGER,
allowNull: false,
defaultValue: minPlatformLevel,
validate: {
min: minPlatformLevel,
max: maxPlatformLevel
}
}
}
export const attributes: SequelizeAttributes<DeviceAttributes> = {
...attributesVersion1,
...attributesVersion2,
@ -319,7 +351,8 @@ export const attributes: SequelizeAttributes<DeviceAttributes> = {
...attributesVersion11,
...attributesVersion12,
...attributesVersion13,
...attributesVersion14
...attributesVersion14,
...attributesVersion15
}
export const createDeviceModel = (sequelize: Sequelize.Sequelize): DeviceModelStatic => sequelize.define('Device', attributes) as DeviceModelStatic

View file

@ -0,0 +1,46 @@
/*
* server component for the TimeLimit App
* Copyright (C) 2019 - 2023 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
* published by the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { QueryInterface, Sequelize, Transaction } from 'sequelize'
import { attributesVersion15 as deviceAttributes } from '../../device'
export async function up (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.addColumn('Devices', 'platformType', {
...deviceAttributes.platformType
}, {
transaction
})
await queryInterface.addColumn('Devices', 'platformLevel', {
...deviceAttributes.platformLevel
}, {
transaction
})
})
}
export async function down (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.removeColumn('Devices', 'platformLevel', { transaction })
await queryInterface.removeColumn('Devices', 'platformType', { transaction })
})
}

View file

@ -1,6 +1,6 @@
/*
* server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann
* Copyright (C) 2019 - 2023 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
@ -66,5 +66,7 @@ export const prepareDeviceEntry = ({ familyId, userId, deviceAuthToken, deviceId
isQorLater: false,
manipulationFlags: 0,
publicKey: null,
nextKeyReplySequenceNumber: '1'
nextKeyReplySequenceNumber: '1',
platformType: null,
platformLevel: 0
})

View file

@ -1,6 +1,6 @@
/*
* server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann
* Copyright (C) 2019 - 2023 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
@ -155,6 +155,18 @@ export async function dispatchUpdateDeviceStatus ({ deviceId, action, cache }: {
}
}
if (action.platformType !== undefined) {
if (action.platformType !== deviceEntry.platformType) {
deviceEntry.platformType = action.platformType
}
}
if (action.platformLevel !== undefined) {
if (action.platformLevel !== deviceEntry.platformLevel) {
deviceEntry.platformLevel = action.platformLevel
}
}
{
const effectiveManipulationFlags = action.addedManipulationFlags & DeviceManipulationFlags.ALL

View file

@ -66,7 +66,9 @@ export async function getDeviceList ({ database, transaction, familyEntry }: {
activityLevelBlocking: item.activityLevelBlocking,
qOrLater: item.isQorLater,
mFlags: item.manipulationFlags,
pk: item.publicKey ? item.publicKey.toString('base64') : undefined
pk: item.publicKey ? item.publicKey.toString('base64') : undefined,
pType: item.platformType || undefined,
pLevel: item.platformLevel
}))
}
}

View file

@ -103,6 +103,8 @@ export interface ServerDeviceData {
qOrLater: boolean
mFlags: number // manipulation flags
pk?: string // public key
pType?: string
pLevel: number
}
export interface ServerUpdatedCategoryBaseData {