Compare commits

...
70 Commits
Author SHA1 Message Date
Jonas Lochmann d269e33524 extend update notification campaign 2026-08-24 02:00:00 +02:00
Jonas Lochmann e907a98c5c prepare new database abstraction layer 2026-08-03 02:00:00 +02:00
Jonas Lochmann 7df7790288 Update nodemailer 2026-08-03 02:00:00 +02:00
Jonas Lochmann 1aee08f409 Update dependencies 2026-08-03 02:00:00 +02:00
Jonas Lochmann 85cd9f3bb0 update dependencies 2026-07-20 02:00:00 +02:00
Jonas Lochmann 52bde0bc23 only check for google play purchase support of this method is requested 2026-07-13 02:00:00 +02:00
Jonas Lochmann 1e5e74659e undo incorrect purchase api documentation changes 2026-07-13 02:00:00 +02:00
Jonas Lochmann 893f3664cf add update notification campaign 2026-07-13 02:00:00 +02:00
Jonas Lochmann ccfbf97d36 adjust isAtLeastAsStrictAsPreviously calculation 2026-06-15 02:00:00 +02:00
Jonas Lochmann bf338f4aff fix documentation of unlock-premium-v2 2026-06-15 02:00:00 +02:00
Jonas Lochmann 91cb44d244 add expiry tolerance if not dryRun to the admin premium unlock api 2026-06-15 02:00:00 +02:00
Jonas Lochmann 235115168f add unpaid14 to the premium unlock api 2026-06-15 02:00:00 +02:00
Jonas Lochmann b2bcc3715f Update dependencies 2026-06-15 02:00:00 +02:00
Jonas Lochmann 2f35b969bf make CanDoPurchaseRequest.type optional 2026-06-08 02:00:00 +02:00
Jonas Lochmann 48d6a061f8 add full version debts system
foundation for granting the full version while consuming the same amount
automatically at the next purchase
2026-06-08 02:00:00 +02:00
Jonas Lochmann 0b6ece0d28 Update dependencies 2026-05-18 02:00:00 +02:00
Jonas Lochmann 271b27ffe9 Update dependencies 2026-05-18 02:00:00 +02:00
jonas-l b80b74b072 Merge pull request 'Fix eslint COPY in Dockerfile' (#46) from jaakristioja/timelimit-server:fix-eslint-in-dockerfile into master
Reviewed-on: https://codeberg.org/timelimit/timelimit-server/pulls/46
2026-05-17 15:16:39 +02:00
Jaak Ristioja 190ae54602 Fix eslint COPY in Dockerfile
Broken since commit a13656b27d.
2026-05-14 23:42:11 +03:00
Jonas Lochmann eb87d331b3 Update dependencies 2026-05-04 02:00:00 +02:00
Jonas Lochmann 5a6f37e4c7 Update dependencies 2026-04-06 02:00:00 +02:00
Jonas Lochmann bd4b5b206b Update dependencies 2026-03-30 02:00:00 +02:00
Jonas Lochmann a8db1ec1a9 Update dependencies 2026-03-30 02:00:00 +02:00
Jonas Lochmann 3aed2010c7 Add ping support 2026-03-23 01:00:00 +01:00
Jonas Lochmann 510c61bafd Adjust test scripts for current database versions 2026-03-23 01:00:00 +01:00
Jonas Lochmann 6fefd4cf18 Update dependencies 2026-03-23 01:00:00 +01:00
Jonas Lochmann bedaa955b5 Update dependencies 2026-03-16 01:00:00 +01:00
Jonas Lochmann a13656b27d update eslint 2026-02-16 01:00:00 +01:00
Jonas Lochmann abb2d1657e Remove rimraf 2026-02-16 01:00:00 +01:00
Jonas Lochmann 47c4e866bf Update ajv 2026-02-16 01:00:00 +01:00
Jonas Lochmann 65f1f8a410 Update Dependencies 2026-02-09 01:00:00 +01:00
Jonas Lochmann c6c0051f82 Add dryRun parameter to the purchase api 2026-01-26 01:00:00 +01:00
Jonas Lochmann 6935c0811c Update dependencies 2025-12-29 01:00:00 +01:00
jonas-l 66001b547f Merge pull request 'chore: update base image to current node lts' (#43) from aveltens/timelimit-server:master into master
Reviewed-on: https://codeberg.org/timelimit/timelimit-server/pulls/43
2025-12-29 08:29:03 +01:00
aveltens c574fccda7 chore: update base image to current node lts 2025-12-28 20:23:12 +01:00
Jonas Lochmann 2cfa0babe1 Update dependencies 2025-12-01 01:00:00 +01:00
Jonas Lochmann 2f2d932d10 Update dependencies 2025-12-01 01:00:00 +01:00
Jonas Lochmann 1215c0c8a2 Add support for time limit rules that expire 2025-11-10 01:00:00 +01:00
Jonas Lochmann 93337e5e08 Add new send-mail-login-code-v2 error responses 2025-11-10 01:00:00 +01:00
Jonas Lochmann e871188661 Update dependencies 2025-11-10 01:00:00 +01:00
Jonas Lochmann ac9f655c44 Update dependencies 2025-10-20 02:00:00 +02:00
Jonas Lochmann 717d8f243a Update dependencies 2025-10-06 02:00:00 +02:00
Jonas Lochmann 6189601459 Update dependencies 2025-06-14 19:08:56 +02:00
Jonas Lochmann 569e5ce62d Update dependencies 2024-12-02 01:00:00 +01:00
Jonas Lochmann 6220cc6bb9 Update dependencies 2024-11-18 01:00:00 +01:00
Jonas Lochmann 33d9fd732f Update dependencies 2024-10-07 02:00:00 +02:00
Jonas Lochmann 764f240707 Update dependencies 2024-09-09 02:00:00 +02:00
Jonas Lochmann b392ca295a Update dependencies 2024-09-09 02:00:00 +02:00
Jonas Lochmann f5fc8e6cd6 Update dependencies 2024-08-19 02:00:00 +02:00
Jonas Lochmann 9c2048af64 Fix lint warnings 2024-07-29 02:00:00 +02:00
Jonas Lochmann b69271f7df Update umzug 2024-07-29 02:00:00 +02:00
Jonas Lochmann 97d2730b20 Update dependencies 2024-06-17 02:00:00 +02:00
Jonas Lochmann 0346197c23 Update dependencies 2024-06-10 02:00:00 +02:00
Jonas Lochmann a7ed01af74 Update dependencies 2024-06-03 02:00:00 +02:00
Jonas Lochmann f77d91ff56 Update dependencies 2024-04-29 02:00:00 +02:00
Jonas Lochmann 2d035da0da Update dependencies 2024-04-08 02:00:00 +02:00
Jonas Lochmann 2d73cba90e Update dependencies 2024-04-08 02:00:00 +02:00
Jonas Lochmann 1918c74277 Update dependencies 2024-03-25 01:00:00 +01:00
Jonas Lochmann e55d1fd1a9 Update dependencies 2024-03-18 01:00:00 +01:00
Jonas Lochmann f10b79a023 Add skipLibCheck to tsconfig.json 2024-03-18 01:00:00 +01:00
Jonas Lochmann 2c401288a3 Adjust json schema generation parameters 2024-03-18 01:00:00 +01:00
Jonas Lochmann 89f3325a18 Update dependencies 2024-03-04 01:00:00 +01:00
Jonas Lochmann 7aaad00881 Update dependencies 2024-02-05 01:00:00 +01:00
Jonas Lochmann c7e4cfc9f9 Add workaround for session duration change logic bug 2024-01-01 01:00:00 +01:00
Jonas Lochmann 12ed5d73cd Update dependencies 2023-09-18 02:00:00 +02:00
Jonas Lochmann 4df809a306 Update dependencies 2023-07-10 02:00:00 +02:00
Jonas Lochmann 8ec0781859 Add platformLevel and platformType 2023-06-13 16:17:53 +02:00
Jonas Lochmann 376a2cc624 Update dependencies 2023-06-13 16:17:46 +02:00
Jonas Lochmann e14237be7d Update dependencies 2023-05-29 02:00:00 +02:00
Jonas Lochmann 4183ea615a Update dependencies 2023-05-08 02:00:00 +02:00
329 changed files with 11159 additions and 9619 deletions
-3
View File
@@ -1,3 +0,0 @@
node_modules
build
scripts
-14
View File
@@ -1,14 +0,0 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
],
env: {
node: true
}
};
+2 -2
View File
@@ -1,11 +1,11 @@
FROM node:16-alpine FROM node:24-alpine
# Create app directories # Create app directories
RUN mkdir -p /usr/src/app RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app WORKDIR /usr/src/app
# Install app dependencies # Install app dependencies
COPY package.json package-lock.json tsconfig.json .eslintignore .eslintrc.js Readme.md /usr/src/app/ COPY package.json package-lock.json tsconfig.json eslint.config.mjs Readme.md /usr/src/app/
COPY src/ /usr/src/app/src/ COPY src/ /usr/src/app/src/
COPY scripts/ /usr/src/app/scripts/ COPY scripts/ /usr/src/app/scripts/
COPY other/ /usr/src/app/other/ COPY other/ /usr/src/app/other/
+6 -1
View File
@@ -96,10 +96,14 @@ Use this to unlock all features for one user for a specified duration.
### request ### request
request properties: ``purchaseToken`` and ``purchaseId`` request properties: ``purchaseToken``, ``purchaseId`` and ``dryRun``
- ``purchasetoken`` is a string which the client shows at the purchase screen - ``purchasetoken`` is a string which the client shows at the purchase screen
- ``purchaseId`` is the ID that is used at the bill - ``purchaseId`` is the ID that is used at the bill
- ``dryRun`` is a boolean
- setting true will skip the actual unlocking
- false will add a four week tolerance to the token expiry to permit checking now and unlocking later
- ``type`` is a string and must be ``year``, ``month`` or ``unpaid14``
### response ### response
@@ -120,6 +124,7 @@ The response contains the following properties:
- optional object - optional object
- should be shown to the support - should be shown to the support
- ``wasAlreadyExecuted`` (boolean, set if and only if ``ok`` is true) - ``wasAlreadyExecuted`` (boolean, set if and only if ``ok`` is true)
- ``mail`` (string, set if and only if ``ok`` is true)
If the request was malformed: HTTP status code 400 Bad Request If the request was malformed: HTTP status code 400 Bad Request
+4
View File
@@ -41,6 +41,10 @@ If a whitelist was configured and the mail address is not within it: ``{"mailAdd
If a blacklist was configured and the mail server is within it: ``{"mailServerBlacklisted": true}`` If a blacklist was configured and the mail server is within it: ``{"mailServerBlacklisted": true}``
If a temporarily blacklist was configured and the mail server is within it (used in case of known mail delivery issues): ``{"mailServerBlacklistedTemporarily": true}``
If the client is suspicious: ``{"blockedForIntegrityReasons": true}``
On success: a object with a ``mailLoginToken`` of the type string On success: a object with a ``mailLoginToken`` of the type string
#### example response #### example response
+2
View File
@@ -15,6 +15,8 @@ Use this before a purchase to check if a purchase is possible.
see [this JSON schema](../schema/candopurchaserequest.md) see [this JSON schema](../schema/candopurchaserequest.md)
Note that ``type`` is not used at all.
### response ### response
On a invalid request body: HTTP status code 400 Bad request On a invalid request body: HTTP status code 400 Bad request
+1 -2
View File
@@ -14,8 +14,7 @@
}, },
"additionalProperties": false, "additionalProperties": false,
"required": [ "required": [
"deviceAuthToken", "deviceAuthToken"
"type"
], ],
"definitions": {}, "definitions": {},
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
+5 -57
View File
@@ -130,6 +130,8 @@
* [SerializedMarkTaskPendingAction](./serializedapplogicaction-definitions-serializedmarktaskpendingaction.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedMarkTaskPendingAction` * [SerializedMarkTaskPendingAction](./serializedapplogicaction-definitions-serializedmarktaskpendingaction.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedMarkTaskPendingAction`
* [SerializedPingAction](./serializedapplogicaction-definitions-serializedpingaction.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedPingAction`
* [SerializedRemoveCategoryAppsAction](./serializedparentaction-definitions-serializedremovecategoryappsaction.md) `https://timelimit.io/SerializedParentAction#/definitions/SerializedRemoveCategoryAppsAction` * [SerializedRemoveCategoryAppsAction](./serializedparentaction-definitions-serializedremovecategoryappsaction.md) `https://timelimit.io/SerializedParentAction#/definitions/SerializedRemoveCategoryAppsAction`
* [SerializedRemoveInstalledAppsAction](./serializedapplogicaction-definitions-serializedremoveinstalledappsaction.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedRemoveInstalledAppsAction` * [SerializedRemoveInstalledAppsAction](./serializedapplogicaction-definitions-serializedremoveinstalledappsaction.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedRemoveInstalledAppsAction`
@@ -238,6 +240,8 @@
* [ServerKeyResponse](./serverdatastatus-definitions-serverkeyresponse.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerKeyResponse` * [ServerKeyResponse](./serverdatastatus-definitions-serverkeyresponse.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerKeyResponse`
* [ServerPing](./serverdatastatus-definitions-serverping.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerPing`
* [ServerSessionDurationItem](./serverdatastatus-definitions-serversessiondurationitem.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerSessionDurationItem` * [ServerSessionDurationItem](./serverdatastatus-definitions-serversessiondurationitem.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerSessionDurationItem`
* [ServerTimeLimitRule](./serverdatastatus-definitions-servertimelimitrule.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerTimeLimitRule` * [ServerTimeLimitRule](./serverdatastatus-definitions-servertimelimitrule.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerTimeLimitRule`
@@ -270,14 +274,6 @@
* [Untitled object in ClientPullChangesRequest](./clientpullchangesrequest-definitions-clientdatastatus-properties-devicesdetail.md) `https://timelimit.io/ClientPullChangesRequest#/definitions/ClientDataStatus/properties/devicesDetail` * [Untitled object in ClientPullChangesRequest](./clientpullchangesrequest-definitions-clientdatastatus-properties-devicesdetail.md) `https://timelimit.io/ClientPullChangesRequest#/definitions/ClientDataStatus/properties/devicesDetail`
* [Untitled object in ClientPullChangesRequest](./clientpullchangesrequest-definitions-clientdatastatus-properties-apps.md) `https://timelimit.io/ClientPullChangesRequest#/definitions/ClientDataStatus/properties/apps`
* [Untitled object in ClientPullChangesRequest](./clientpullchangesrequest-definitions-clientdatastatus-properties-categories.md) `https://timelimit.io/ClientPullChangesRequest#/definitions/ClientDataStatus/properties/categories`
* [Untitled object in ClientPullChangesRequest](./clientpullchangesrequest-definitions-clientdatastatus-properties-devicesdetail.md) `https://timelimit.io/ClientPullChangesRequest#/definitions/ClientDataStatus/properties/devicesDetail`
* [Untitled object in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedaddusedtimeactionversion2-properties-i-items.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedAddUsedTimeActionVersion2/properties/i/items`
* [Untitled object in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedaddusedtimeactionversion2-properties-i-items.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedAddUsedTimeActionVersion2/properties/i/items` * [Untitled object in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedaddusedtimeactionversion2-properties-i-items.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedAddUsedTimeActionVersion2/properties/i/items`
### Arrays ### Arrays
@@ -306,32 +302,6 @@
* [Untitled array in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedupdateappactivitiesaction-properties-updatedoradded.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateAppActivitiesAction/properties/updatedOrAdded` * [Untitled array in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedupdateappactivitiesaction-properties-updatedoradded.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateAppActivitiesAction/properties/updatedOrAdded`
* [Untitled array in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedaddinstalledappsaction-properties-apps.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedAddInstalledAppsAction/properties/apps`
* [Untitled array in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedaddusedtimeactionversion2-properties-i.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedAddUsedTimeActionVersion2/properties/i`
* [Untitled array in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedaddusedtimeactionversion2-properties-i-items-properties-as.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedAddUsedTimeActionVersion2/properties/i/items/properties/as`
* [Untitled array in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedaddusedtimeactionversion2-properties-i-items-properties-as-items.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedAddUsedTimeActionVersion2/properties/i/items/properties/as/items`
* [Untitled array in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedaddusedtimeactionversion2-properties-i-items-properties-sdl.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedAddUsedTimeActionVersion2/properties/i/items/properties/sdl`
* [Untitled array in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedaddusedtimeactionversion2-properties-i-items-properties-sdl-items.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedAddUsedTimeActionVersion2/properties/i/items/properties/sdl/items`
* [Untitled array in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedremoveinstalledappsaction-properties-packagenames.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedRemoveInstalledAppsAction/properties/packageNames`
* [Untitled array in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedupdateappactivitiesaction-properties-removed.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateAppActivitiesAction/properties/removed`
* [Untitled array in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedupdateappactivitiesaction-properties-removed-items.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateAppActivitiesAction/properties/removed/items`
* [Untitled array in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedupdateappactivitiesaction-properties-updatedoradded.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateAppActivitiesAction/properties/updatedOrAdded`
* [Untitled array in SerializedParentAction](./serializedparentaction-definitions-serializedaddcategoryappsaction-properties-packagenames.md) `https://timelimit.io/SerializedParentAction#/definitions/SerializedAddCategoryAppsAction/properties/packageNames`
* [Untitled array in SerializedParentAction](./serializedparentaction-definitions-serializedremovecategoryappsaction-properties-packagenames.md) `https://timelimit.io/SerializedParentAction#/definitions/SerializedRemoveCategoryAppsAction/properties/packageNames`
* [Untitled array in SerializedParentAction](./serializedparentaction-definitions-serializedupdatecategorysortingaction-properties-categoryids.md) `https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateCategorySortingAction/properties/categoryIds`
* [Untitled array in SerializedParentAction](./serializedparentaction-definitions-serializedaddcategoryappsaction-properties-packagenames.md) `https://timelimit.io/SerializedParentAction#/definitions/SerializedAddCategoryAppsAction/properties/packageNames` * [Untitled array in SerializedParentAction](./serializedparentaction-definitions-serializedaddcategoryappsaction-properties-packagenames.md) `https://timelimit.io/SerializedParentAction#/definitions/SerializedAddCategoryAppsAction/properties/packageNames`
* [Untitled array in SerializedParentAction](./serializedparentaction-definitions-serializedremovecategoryappsaction-properties-packagenames.md) `https://timelimit.io/SerializedParentAction#/definitions/SerializedRemoveCategoryAppsAction/properties/packageNames` * [Untitled array in SerializedParentAction](./serializedparentaction-definitions-serializedremovecategoryappsaction-properties-packagenames.md) `https://timelimit.io/SerializedParentAction#/definitions/SerializedRemoveCategoryAppsAction/properties/packageNames`
@@ -380,29 +350,7 @@
* [Untitled array in ServerDataStatus](./serverdatastatus-properties-kr.md) `https://timelimit.io/ServerDataStatus#/properties/kr` * [Untitled array in ServerDataStatus](./serverdatastatus-properties-kr.md) `https://timelimit.io/ServerDataStatus#/properties/kr`
* [Untitled array in ServerDataStatus](./serverdatastatus-definitions-u2fdata-properties-d.md) `https://timelimit.io/ServerDataStatus#/definitions/U2fData/properties/d` * [Untitled array in ServerDataStatus](./serverdatastatus-properties-pings.md) `https://timelimit.io/ServerDataStatus#/properties/pings`
* [Untitled array in ServerDataStatus](./serverdatastatus-definitions-serverdevicelist-properties-data.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerDeviceList/properties/data`
* [Untitled array in ServerDataStatus](./serverdatastatus-definitions-serverinstalledappsdata-properties-apps.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerInstalledAppsData/properties/apps`
* [Untitled array in ServerDataStatus](./serverdatastatus-definitions-serverinstalledappsdata-properties-activities.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerInstalledAppsData/properties/activities`
* [Untitled array in ServerDataStatus](./serverdatastatus-definitions-serverupdatedcategorybasedata-properties-networks.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerUpdatedCategoryBaseData/properties/networks`
* [Untitled array in ServerDataStatus](./serverdatastatus-definitions-serverupdatedcategorybasedata-properties-atw.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerUpdatedCategoryBaseData/properties/atw`
* [Untitled array in ServerDataStatus](./serverdatastatus-definitions-serverupdatedcategoryassignedapps-properties-apps.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerUpdatedCategoryAssignedApps/properties/apps`
* [Untitled array in ServerDataStatus](./serverdatastatus-definitions-serverupdatedcategoryusedtimes-properties-times.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerUpdatedCategoryUsedTimes/properties/times`
* [Untitled array in ServerDataStatus](./serverdatastatus-definitions-serverupdatedcategoryusedtimes-properties-sessiondurations.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerUpdatedCategoryUsedTimes/properties/sessionDurations`
* [Untitled array in ServerDataStatus](./serverdatastatus-definitions-serverupdatedtimelimitrules-properties-rules.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerUpdatedTimeLimitRules/properties/rules`
* [Untitled array in ServerDataStatus](./serverdatastatus-definitions-serverupdatedcategorytasks-properties-tasks.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerUpdatedCategoryTasks/properties/tasks`
* [Untitled array in ServerDataStatus](./serverdatastatus-definitions-serveruserlist-properties-data.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerUserList/properties/data`
* [Untitled array in ServerDataStatus](./serverdatastatus-definitions-u2fdata-properties-d.md) `https://timelimit.io/ServerDataStatus#/definitions/U2fData/properties/d` * [Untitled array in ServerDataStatus](./serverdatastatus-definitions-u2fdata-properties-d.md) `https://timelimit.io/ServerDataStatus#/definitions/U2fData/properties/d`
@@ -21,6 +21,9 @@
{ {
"$ref": "#/definitions/SerializedMarkTaskPendingAction" "$ref": "#/definitions/SerializedMarkTaskPendingAction"
}, },
{
"$ref": "#/definitions/SerializedPingAction"
},
{ {
"$ref": "#/definitions/SerializedUpdateInstalledAppsAction" "$ref": "#/definitions/SerializedUpdateInstalledAppsAction"
}, },
@@ -309,6 +312,43 @@
], ],
"title": "SerializedMarkTaskPendingAction" "title": "SerializedMarkTaskPendingAction"
}, },
"SerializedPingAction": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"PING"
]
},
"deviceId": {
"type": "string"
},
"event": {
"$ref": "#/definitions/PingEvent"
},
"token": {
"type": "string"
}
},
"additionalProperties": false,
"required": [
"deviceId",
"event",
"token",
"type"
],
"title": "SerializedPingAction"
},
"PingEvent": {
"enum": [
"clear",
"ping",
"pong"
],
"type": "string",
"title": "PingEvent"
},
"SerializedUpdateInstalledAppsAction": { "SerializedUpdateInstalledAppsAction": {
"type": "object", "type": "object",
"properties": { "properties": {
@@ -545,6 +585,12 @@
}, },
"addedManipulationFlags": { "addedManipulationFlags": {
"type": "number" "type": "number"
},
"platformType": {
"type": "string"
},
"platformLevel": {
"type": "number"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
@@ -410,6 +410,9 @@
}, },
"perDay": { "perDay": {
"type": "boolean" "type": "boolean"
},
"e": {
"type": "number"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
@@ -1458,6 +1461,9 @@
}, },
"perDay": { "perDay": {
"type": "boolean" "type": "boolean"
},
"e": {
"type": "number"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
+38
View File
@@ -67,6 +67,12 @@
"$ref": "#/definitions/ServerKeyResponse" "$ref": "#/definitions/ServerKeyResponse"
} }
}, },
"pings": {
"type": "array",
"items": {
"$ref": "#/definitions/ServerPing"
}
},
"dh": { "dh": {
"$ref": "#/definitions/ServerDhKey" "$ref": "#/definitions/ServerDhKey"
}, },
@@ -212,6 +218,12 @@
}, },
"pk": { "pk": {
"type": "string" "type": "string"
},
"pType": {
"type": "string"
},
"pLevel": {
"type": "number"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
@@ -240,6 +252,7 @@
"model", "model",
"name", "name",
"networkTime", "networkTime",
"pLevel",
"qOrLater", "qOrLater",
"reboot", "reboot",
"rebootIsManipulation", "rebootIsManipulation",
@@ -920,6 +933,31 @@
], ],
"title": "ServerKeyResponse" "title": "ServerKeyResponse"
}, },
"ServerPing": {
"type": "object",
"properties": {
"deviceId": {
"type": "string"
},
"token": {
"type": "string"
},
"type": {
"enum": [
"ping",
"pong"
],
"type": "string"
}
},
"additionalProperties": false,
"required": [
"deviceId",
"token",
"type"
],
"title": "ServerPing"
},
"ServerDhKey": { "ServerDhKey": {
"type": "object", "type": "object",
"properties": { "properties": {
+2 -2
View File
@@ -18,7 +18,7 @@ https://timelimit.io/CanDoPurchaseRequest
| Property | Type | Required | Nullable | Defined by | | Property | Type | Required | Nullable | Defined by |
| :---------------------------------- | :------- | :------- | :------------- | :------------------------------------------------------------------------------------------------------------------------------------------------- | | :---------------------------------- | :------- | :------- | :------------- | :------------------------------------------------------------------------------------------------------------------------------------------------- |
| [type](#type) | `string` | Required | cannot be null | [CanDoPurchaseRequest](candopurchaserequest-properties-type.md "https://timelimit.io/CanDoPurchaseRequest#/properties/type") | | [type](#type) | `string` | Optional | cannot be null | [CanDoPurchaseRequest](candopurchaserequest-properties-type.md "https://timelimit.io/CanDoPurchaseRequest#/properties/type") |
| [deviceAuthToken](#deviceauthtoken) | `string` | Required | cannot be null | [CanDoPurchaseRequest](candopurchaserequest-properties-deviceauthtoken.md "https://timelimit.io/CanDoPurchaseRequest#/properties/deviceAuthToken") | | [deviceAuthToken](#deviceauthtoken) | `string` | Required | cannot be null | [CanDoPurchaseRequest](candopurchaserequest-properties-deviceauthtoken.md "https://timelimit.io/CanDoPurchaseRequest#/properties/deviceAuthToken") |
## type ## type
@@ -27,7 +27,7 @@ https://timelimit.io/CanDoPurchaseRequest
`type` `type`
* is required * is optional
* Type: `string` * Type: `string`
@@ -0,0 +1,25 @@
# PingEvent Schema
```txt
https://timelimit.io/SerializedAppLogicAction#/definitions/PingEvent
```
| 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") |
## PingEvent Type
`string` ([PingEvent](serializedapplogicaction-definitions-pingevent.md))
## PingEvent Constraints
**enum**: the value of this property must be equal to one of the following values:
| Value | Explanation |
| :-------- | :---------- |
| `"clear"` | |
| `"ping"` | |
| `"pong"` | |
@@ -0,0 +1,15 @@
# Untitled string in SerializedAppLogicAction Schema
```txt
https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedPingAction/properties/deviceId
```
| 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") |
## deviceId Type
`string`
@@ -0,0 +1,25 @@
# PingEvent Schema
```txt
https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedPingAction/properties/event
```
| 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") |
## event Type
`string` ([PingEvent](serializedapplogicaction-definitions-serializedpingaction-properties-pingevent.md))
## event Constraints
**enum**: the value of this property must be equal to one of the following values:
| Value | Explanation |
| :-------- | :---------- |
| `"clear"` | |
| `"ping"` | |
| `"pong"` | |
@@ -0,0 +1,15 @@
# Untitled string in SerializedAppLogicAction Schema
```txt
https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedPingAction/properties/token
```
| 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") |
## token Type
`string`
@@ -0,0 +1,23 @@
# Untitled string in SerializedAppLogicAction Schema
```txt
https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedPingAction/properties/type
```
| 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") |
## type Type
`string`
## type Constraints
**enum**: the value of this property must be equal to one of the following values:
| Value | Explanation |
| :------- | :---------- |
| `"PING"` | |
@@ -0,0 +1,114 @@
# SerializedPingAction Schema
```txt
https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedPingAction
```
| Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In |
| :------------------ | :--------- | :------------- | :----------- | :---------------- | :-------------------- | :------------------ | :---------------------------------------------------------------------------------------------------- |
| Can be instantiated | No | Unknown status | No | Forbidden | Forbidden | none | [SerializedAppLogicAction.schema.json\*](SerializedAppLogicAction.schema.json "open original schema") |
## SerializedPingAction Type
`object` ([SerializedPingAction](serializedapplogicaction-definitions-serializedpingaction.md))
# SerializedPingAction Properties
| Property | Type | Required | Nullable | Defined by |
| :-------------------- | :------- | :------- | :------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [type](#type) | `string` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedpingaction-properties-type.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedPingAction/properties/type") |
| [deviceId](#deviceid) | `string` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedpingaction-properties-deviceid.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedPingAction/properties/deviceId") |
| [event](#event) | `string` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedpingaction-properties-pingevent.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedPingAction/properties/event") |
| [token](#token) | `string` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedpingaction-properties-token.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedPingAction/properties/token") |
## type
`type`
* is required
* Type: `string`
* cannot be null
* defined in: [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedpingaction-properties-type.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedPingAction/properties/type")
### type Type
`string`
### type Constraints
**enum**: the value of this property must be equal to one of the following values:
| Value | Explanation |
| :------- | :---------- |
| `"PING"` | |
## deviceId
`deviceId`
* is required
* Type: `string`
* cannot be null
* defined in: [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedpingaction-properties-deviceid.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedPingAction/properties/deviceId")
### deviceId Type
`string`
## event
`event`
* is required
* Type: `string` ([PingEvent](serializedapplogicaction-definitions-serializedpingaction-properties-pingevent.md))
* cannot be null
* defined in: [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedpingaction-properties-pingevent.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedPingAction/properties/event")
### event Type
`string` ([PingEvent](serializedapplogicaction-definitions-serializedpingaction-properties-pingevent.md))
### event Constraints
**enum**: the value of this property must be equal to one of the following values:
| Value | Explanation |
| :-------- | :---------- |
| `"clear"` | |
| `"ping"` | |
| `"pong"` | |
## token
`token`
* is required
* Type: `string`
* cannot be null
* defined in: [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedpingaction-properties-token.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedPingAction/properties/token")
### token Type
`string`
@@ -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`
@@ -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`
@@ -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") | | [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") | | [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") | | [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 ## type
@@ -257,3 +259,39 @@ https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateDevic
### addedManipulationFlags Type ### addedManipulationFlags Type
`number` `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`
+165 -9
View File
@@ -30,6 +30,8 @@ any of
* [SerializedMarkTaskPendingAction](serializedapplogicaction-definitions-serializedmarktaskpendingaction.md "check type definition") * [SerializedMarkTaskPendingAction](serializedapplogicaction-definitions-serializedmarktaskpendingaction.md "check type definition")
* [SerializedPingAction](serializedapplogicaction-definitions-serializedpingaction.md "check type definition")
* [SerializedUpdateInstalledAppsAction](serializedapplogicaction-definitions-serializedupdateinstalledappsaction.md "check type definition") * [SerializedUpdateInstalledAppsAction](serializedapplogicaction-definitions-serializedupdateinstalledappsaction.md "check type definition")
* [SerializedRemoveInstalledAppsAction](serializedapplogicaction-definitions-serializedremoveinstalledappsaction.md "check type definition") * [SerializedRemoveInstalledAppsAction](serializedapplogicaction-definitions-serializedremoveinstalledappsaction.md "check type definition")
@@ -688,6 +690,122 @@ Reference this group by using
`string` `string`
## Definitions group SerializedPingAction
Reference this group by using
```json
{"$ref":"https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedPingAction"}
```
| Property | Type | Required | Nullable | Defined by |
| :-------------------- | :------- | :------- | :------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [type](#type-7) | `string` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedpingaction-properties-type.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedPingAction/properties/type") |
| [deviceId](#deviceid) | `string` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedpingaction-properties-deviceid.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedPingAction/properties/deviceId") |
| [event](#event) | `string` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedpingaction-properties-pingevent.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedPingAction/properties/event") |
| [token](#token) | `string` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedpingaction-properties-token.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedPingAction/properties/token") |
### type
`type`
* is required
* Type: `string`
* cannot be null
* defined in: [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedpingaction-properties-type.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedPingAction/properties/type")
#### type Type
`string`
#### type Constraints
**enum**: the value of this property must be equal to one of the following values:
| Value | Explanation |
| :------- | :---------- |
| `"PING"` | |
### deviceId
`deviceId`
* is required
* Type: `string`
* cannot be null
* defined in: [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedpingaction-properties-deviceid.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedPingAction/properties/deviceId")
#### deviceId Type
`string`
### event
`event`
* is required
* Type: `string` ([PingEvent](serializedapplogicaction-definitions-serializedpingaction-properties-pingevent.md))
* cannot be null
* defined in: [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedpingaction-properties-pingevent.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedPingAction/properties/event")
#### event Type
`string` ([PingEvent](serializedapplogicaction-definitions-serializedpingaction-properties-pingevent.md))
#### event Constraints
**enum**: the value of this property must be equal to one of the following values:
| Value | Explanation |
| :-------- | :---------- |
| `"clear"` | |
| `"ping"` | |
| `"pong"` | |
### token
`token`
* is required
* Type: `string`
* cannot be null
* defined in: [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedpingaction-properties-token.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedPingAction/properties/token")
#### token Type
`string`
## Definitions group PingEvent
Reference this group by using
```json
{"$ref":"https://timelimit.io/SerializedAppLogicAction#/definitions/PingEvent"}
```
| Property | Type | Required | Nullable | Defined by |
| :------- | :--- | :------- | :------- | :--------- |
## Definitions group SerializedUpdateInstalledAppsAction ## Definitions group SerializedUpdateInstalledAppsAction
Reference this group by using Reference this group by using
@@ -698,7 +816,7 @@ Reference this group by using
| Property | Type | Required | Nullable | Defined by | | Property | Type | Required | Nullable | Defined by |
| :-------------- | :-------- | :------- | :------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | :-------------- | :-------- | :------- | :------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [type](#type-7) | `string` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdateinstalledappsaction-properties-type.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateInstalledAppsAction/properties/type") | | [type](#type-8) | `string` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdateinstalledappsaction-properties-type.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateInstalledAppsAction/properties/type") |
| [b](#b) | `string` | Optional | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdateinstalledappsaction-properties-b.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateInstalledAppsAction/properties/b") | | [b](#b) | `string` | Optional | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdateinstalledappsaction-properties-b.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateInstalledAppsAction/properties/b") |
| [d](#d-1) | `string` | Optional | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdateinstalledappsaction-properties-d.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateInstalledAppsAction/properties/d") | | [d](#d-1) | `string` | Optional | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdateinstalledappsaction-properties-d.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateInstalledAppsAction/properties/d") |
| [w](#w) | `boolean` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdateinstalledappsaction-properties-w.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateInstalledAppsAction/properties/w") | | [w](#w) | `boolean` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdateinstalledappsaction-properties-w.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateInstalledAppsAction/properties/w") |
@@ -793,7 +911,7 @@ Reference this group by using
| Property | Type | Required | Nullable | Defined by | | Property | Type | Required | Nullable | Defined by |
| :---------------------------- | :------- | :------- | :------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | :---------------------------- | :------- | :------- | :------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [type](#type-8) | `string` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedremoveinstalledappsaction-properties-type.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedRemoveInstalledAppsAction/properties/type") | | [type](#type-9) | `string` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedremoveinstalledappsaction-properties-type.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedRemoveInstalledAppsAction/properties/type") |
| [packageNames](#packagenames) | `array` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedremoveinstalledappsaction-properties-packagenames.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedRemoveInstalledAppsAction/properties/packageNames") | | [packageNames](#packagenames) | `array` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedremoveinstalledappsaction-properties-packagenames.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedRemoveInstalledAppsAction/properties/packageNames") |
### type ### type
@@ -850,9 +968,9 @@ Reference this group by using
| Property | Type | Required | Nullable | Defined by | | Property | Type | Required | Nullable | Defined by |
| :-------------------------- | :------- | :------- | :------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | :-------------------------- | :------- | :------- | :------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [type](#type-9) | `string` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedsendkeyrequestaction-properties-type.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedSendKeyRequestAction/properties/type") | | [type](#type-10) | `string` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedsendkeyrequestaction-properties-type.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedSendKeyRequestAction/properties/type") |
| [dsn](#dsn-1) | `number` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedsendkeyrequestaction-properties-dsn.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedSendKeyRequestAction/properties/dsn") | | [dsn](#dsn-1) | `number` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedsendkeyrequestaction-properties-dsn.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedSendKeyRequestAction/properties/dsn") |
| [deviceId](#deviceid) | `string` | Optional | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedsendkeyrequestaction-properties-deviceid.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedSendKeyRequestAction/properties/deviceId") | | [deviceId](#deviceid-1) | `string` | Optional | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedsendkeyrequestaction-properties-deviceid.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedSendKeyRequestAction/properties/deviceId") |
| [categoryId](#categoryid-1) | `string` | Optional | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedsendkeyrequestaction-properties-categoryid.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedSendKeyRequestAction/properties/categoryId") | | [categoryId](#categoryid-1) | `string` | Optional | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedsendkeyrequestaction-properties-categoryid.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedSendKeyRequestAction/properties/categoryId") |
| [dataType](#datatype) | `number` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedsendkeyrequestaction-properties-datatype.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedSendKeyRequestAction/properties/dataType") | | [dataType](#datatype) | `number` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedsendkeyrequestaction-properties-datatype.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedSendKeyRequestAction/properties/dataType") |
| [tempKey](#tempkey-1) | `string` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedsendkeyrequestaction-properties-tempkey.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedSendKeyRequestAction/properties/tempKey") | | [tempKey](#tempkey-1) | `string` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedsendkeyrequestaction-properties-tempkey.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedSendKeyRequestAction/properties/tempKey") |
@@ -1002,7 +1120,7 @@ Reference this group by using
| Property | Type | Required | Nullable | Defined by | | Property | Type | Required | Nullable | Defined by |
| :--------------- | :------- | :------- | :------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | :--------------- | :------- | :------- | :------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [type](#type-10) | `string` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedsignoutatdeviceaction-properties-type.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedSignOutAtDeviceAction/properties/type") | | [type](#type-11) | `string` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedsignoutatdeviceaction-properties-type.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedSignOutAtDeviceAction/properties/type") |
### type ### type
@@ -1040,7 +1158,7 @@ Reference this group by using
| Property | Type | Required | Nullable | Defined by | | Property | Type | Required | Nullable | Defined by |
| :--------------- | :------- | :------- | :------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | :--------------- | :------- | :------- | :------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [type](#type-11) | `string` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serialiezdtrieddisablingdeviceadminaction-properties-type.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerialiezdTriedDisablingDeviceAdminAction/properties/type") | | [type](#type-12) | `string` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serialiezdtrieddisablingdeviceadminaction-properties-type.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerialiezdTriedDisablingDeviceAdminAction/properties/type") |
### type ### type
@@ -1078,7 +1196,7 @@ Reference this group by using
| Property | Type | Required | Nullable | Defined by | | Property | Type | Required | Nullable | Defined by |
| :-------------------------------- | :------- | :------- | :------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | :-------------------------------- | :------- | :------- | :------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [type](#type-12) | `string` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdateappactivitiesaction-properties-type.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateAppActivitiesAction/properties/type") | | [type](#type-13) | `string` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdateappactivitiesaction-properties-type.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateAppActivitiesAction/properties/type") |
| [removed](#removed) | `array` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdateappactivitiesaction-properties-removed.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateAppActivitiesAction/properties/removed") | | [removed](#removed) | `array` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdateappactivitiesaction-properties-removed.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateAppActivitiesAction/properties/removed") |
| [updatedOrAdded](#updatedoradded) | `array` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdateappactivitiesaction-properties-updatedoradded.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateAppActivitiesAction/properties/updatedOrAdded") | | [updatedOrAdded](#updatedoradded) | `array` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdateappactivitiesaction-properties-updatedoradded.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateAppActivitiesAction/properties/updatedOrAdded") |
@@ -1230,7 +1348,7 @@ Reference this group by using
| Property | Type | Required | Nullable | Defined by | | Property | Type | Required | Nullable | Defined by |
| :---------------------------------------------------------- | :-------- | :------- | :------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | :---------------------------------------------------------- | :-------- | :------- | :------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [type](#type-13) | `string` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdatedevicestatusaction-properties-type.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateDeviceStatusAction/properties/type") | | [type](#type-14) | `string` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdatedevicestatusaction-properties-type.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateDeviceStatusAction/properties/type") |
| [protectionLevel](#protectionlevel) | `string` | Optional | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdatedevicestatusaction-properties-protectionlevel.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateDeviceStatusAction/properties/protectionLevel") | | [protectionLevel](#protectionlevel) | `string` | Optional | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdatedevicestatusaction-properties-protectionlevel.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateDeviceStatusAction/properties/protectionLevel") |
| [usageStats](#usagestats) | `string` | Optional | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdatedevicestatusaction-properties-usagestats.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateDeviceStatusAction/properties/usageStats") | | [usageStats](#usagestats) | `string` | Optional | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdatedevicestatusaction-properties-usagestats.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateDeviceStatusAction/properties/usageStats") |
| [notificationAccess](#notificationaccess) | `string` | Optional | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdatedevicestatusaction-properties-notificationaccess.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateDeviceStatusAction/properties/notificationAccess") | | [notificationAccess](#notificationaccess) | `string` | Optional | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializedupdatedevicestatusaction-properties-notificationaccess.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateDeviceStatusAction/properties/notificationAccess") |
@@ -1240,6 +1358,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") | | [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") | | [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") | | [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 ### type
@@ -1470,6 +1590,42 @@ Reference this group by using
`number` `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 ## Definitions group SerializedUploadDevicePublicKeyAction
Reference this group by using Reference this group by using
@@ -1480,7 +1636,7 @@ Reference this group by using
| Property | Type | Required | Nullable | Defined by | | Property | Type | Required | Nullable | Defined by |
| :--------------- | :------- | :------- | :------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | :--------------- | :------- | :------- | :------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [type](#type-14) | `string` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializeduploaddevicepublickeyaction-properties-type.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUploadDevicePublicKeyAction/properties/type") | | [type](#type-15) | `string` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializeduploaddevicepublickeyaction-properties-type.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUploadDevicePublicKeyAction/properties/type") |
| [key](#key) | `string` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializeduploaddevicepublickeyaction-properties-key.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUploadDevicePublicKeyAction/properties/key") | | [key](#key) | `string` | Required | cannot be null | [SerializedAppLogicAction](serializedapplogicaction-definitions-serializeduploaddevicepublickeyaction-properties-key.md "https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUploadDevicePublicKeyAction/properties/key") |
### type ### type
@@ -1,7 +1,7 @@
# EncryptableParentPassword Schema # EncryptableParentPassword Schema
```txt ```txt
https://timelimit.io/SerializedParentAction#/definitions/SerializedSetChildPasswordAction/properties/newPassword https://timelimit.io/SerializedParentAction#/definitions/EncryptableParentPassword
``` ```
@@ -10,11 +10,11 @@ https://timelimit.io/SerializedParentAction#/definitions/SerializedSetChildPassw
| :------------------ | :--------- | :------------- | :----------- | :---------------- | :-------------------- | :------------------ | :------------------------------------------------------------------------------------------------ | | :------------------ | :--------- | :------------- | :----------- | :---------------- | :-------------------- | :------------------ | :------------------------------------------------------------------------------------------------ |
| Can be instantiated | No | Unknown status | No | Forbidden | Forbidden | none | [SerializedParentAction.schema.json\*](SerializedParentAction.schema.json "open original schema") | | Can be instantiated | No | Unknown status | No | Forbidden | Forbidden | none | [SerializedParentAction.schema.json\*](SerializedParentAction.schema.json "open original schema") |
## newPassword Type ## EncryptableParentPassword Type
`object` ([EncryptableParentPassword](serializedparentaction-definitions-encryptableparentpassword.md)) `object` ([EncryptableParentPassword](serializedparentaction-definitions-encryptableparentpassword.md))
# newPassword Properties # EncryptableParentPassword Properties
| Property | Type | Required | Nullable | Defined by | | Property | Type | Required | Nullable | Defined by |
| :------------------------ | :-------- | :------- | :------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | :------------------------ | :-------- | :------- | :------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -0,0 +1,15 @@
# Untitled number in SerializedParentAction Schema
```txt
https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/e
```
| Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In |
| :------------------ | :--------- | :------------- | :---------------------- | :---------------- | :-------------------- | :------------------ | :------------------------------------------------------------------------------------------------ |
| Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [SerializedParentAction.schema.json\*](SerializedParentAction.schema.json "open original schema") |
## e Type
`number`
@@ -28,6 +28,7 @@ https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule
| [dur](#dur) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-dur.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/dur") | | [dur](#dur) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-dur.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/dur") |
| [pause](#pause) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-pause.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/pause") | | [pause](#pause) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-pause.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/pause") |
| [perDay](#perday) | `boolean` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-perday.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/perDay") | | [perDay](#perday) | `boolean` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-perday.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/perDay") |
| [e](#e) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-e.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/e") |
## ruleId ## ruleId
@@ -208,3 +209,21 @@ https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule
### perDay Type ### perDay Type
`boolean` `boolean`
## e
`e`
* is optional
* Type: `number`
* cannot be null
* defined in: [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-e.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/e")
### e Type
`number`
@@ -0,0 +1,15 @@
# Untitled number in SerializedParentAction Schema
```txt
https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/e
```
| Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In |
| :------------------ | :--------- | :------------- | :---------------------- | :---------------- | :-------------------- | :------------------ | :------------------------------------------------------------------------------------------------ |
| Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [SerializedParentAction.schema.json\*](SerializedParentAction.schema.json "open original schema") |
## e Type
`number`
@@ -0,0 +1,15 @@
# Untitled number in SerializedParentAction Schema
```txt
https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/expiresAt
```
| Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In |
| :------------------ | :--------- | :------------- | :---------------------- | :---------------- | :-------------------- | :------------------ | :------------------------------------------------------------------------------------------------ |
| Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [SerializedParentAction.schema.json\*](SerializedParentAction.schema.json "open original schema") |
## expiresAt Type
`number`
@@ -28,6 +28,7 @@ https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelim
| [dur](#dur) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-dur.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/dur") | | [dur](#dur) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-dur.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/dur") |
| [pause](#pause) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-pause.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/pause") | | [pause](#pause) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-pause.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/pause") |
| [perDay](#perday) | `boolean` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-perday.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/perDay") | | [perDay](#perday) | `boolean` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-perday.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/perDay") |
| [e](#e) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-e.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/e") |
## type ## type
@@ -216,3 +217,21 @@ https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelim
### perDay Type ### perDay Type
`boolean` `boolean`
## e
`e`
* is optional
* Type: `number`
* cannot be null
* defined in: [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-e.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/e")
### e Type
`number`
+38
View File
@@ -899,6 +899,7 @@ Reference this group by using
| [dur](#dur) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-dur.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/dur") | | [dur](#dur) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-dur.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/dur") |
| [pause](#pause) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-pause.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/pause") | | [pause](#pause) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-pause.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/pause") |
| [perDay](#perday) | `boolean` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-perday.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/perDay") | | [perDay](#perday) | `boolean` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-perday.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/perDay") |
| [e](#e) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-e.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/e") |
### ruleId ### ruleId
@@ -1080,6 +1081,24 @@ Reference this group by using
`boolean` `boolean`
### e
`e`
* is optional
* Type: `number`
* cannot be null
* defined in: [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-e.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/e")
#### e Type
`number`
## Definitions group SerializedDeleteCategoryAction ## Definitions group SerializedDeleteCategoryAction
Reference this group by using Reference this group by using
@@ -4397,6 +4416,7 @@ Reference this group by using
| [dur](#dur-1) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-dur.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/dur") | | [dur](#dur-1) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-dur.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/dur") |
| [pause](#pause-1) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-pause.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/pause") | | [pause](#pause-1) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-pause.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/pause") |
| [perDay](#perday-1) | `boolean` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-perday.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/perDay") | | [perDay](#perday-1) | `boolean` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-perday.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/perDay") |
| [e](#e-1) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-e.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/e") |
### type ### type
@@ -4586,6 +4606,24 @@ Reference this group by using
`boolean` `boolean`
### e
`e`
* is optional
* Type: `number`
* cannot be null
* defined in: [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-e.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/e")
#### e Type
`number`
## Definitions group SerializedUpdateUserFlagsAction ## Definitions group SerializedUpdateUserFlagsAction
Reference this group by using Reference this group by using
@@ -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`
@@ -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`
@@ -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") | | [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") | | [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") | | [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 ## deviceId
@@ -718,3 +720,39 @@ https://timelimit.io/ServerDataStatus#/definitions/ServerDeviceData
### pk Type ### pk Type
`string` `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`
@@ -0,0 +1,15 @@
# Untitled string in ServerDataStatus Schema
```txt
https://timelimit.io/ServerDataStatus#/definitions/ServerPing/properties/deviceId
```
| 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") |
## deviceId Type
`string`
@@ -0,0 +1,15 @@
# Untitled string in ServerDataStatus Schema
```txt
https://timelimit.io/ServerDataStatus#/definitions/ServerPing/properties/token
```
| 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") |
## token Type
`string`
@@ -0,0 +1,24 @@
# Untitled string in ServerDataStatus Schema
```txt
https://timelimit.io/ServerDataStatus#/definitions/ServerPing/properties/type
```
| 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") |
## type Type
`string`
## type Constraints
**enum**: the value of this property must be equal to one of the following values:
| Value | Explanation |
| :------- | :---------- |
| `"ping"` | |
| `"pong"` | |
@@ -0,0 +1,86 @@
# ServerPing Schema
```txt
https://timelimit.io/ServerDataStatus#/definitions/ServerPing
```
| Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In |
| :------------------ | :--------- | :------------- | :----------- | :---------------- | :-------------------- | :------------------ | :------------------------------------------------------------------------------------ |
| Can be instantiated | No | Unknown status | No | Forbidden | Forbidden | none | [ServerDataStatus.schema.json\*](ServerDataStatus.schema.json "open original schema") |
## ServerPing Type
`object` ([ServerPing](serverdatastatus-definitions-serverping.md))
# ServerPing Properties
| Property | Type | Required | Nullable | Defined by |
| :-------------------- | :------- | :------- | :------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [deviceId](#deviceid) | `string` | Required | cannot be null | [ServerDataStatus](serverdatastatus-definitions-serverping-properties-deviceid.md "https://timelimit.io/ServerDataStatus#/definitions/ServerPing/properties/deviceId") |
| [token](#token) | `string` | Required | cannot be null | [ServerDataStatus](serverdatastatus-definitions-serverping-properties-token.md "https://timelimit.io/ServerDataStatus#/definitions/ServerPing/properties/token") |
| [type](#type) | `string` | Required | cannot be null | [ServerDataStatus](serverdatastatus-definitions-serverping-properties-type.md "https://timelimit.io/ServerDataStatus#/definitions/ServerPing/properties/type") |
## deviceId
`deviceId`
* is required
* Type: `string`
* cannot be null
* defined in: [ServerDataStatus](serverdatastatus-definitions-serverping-properties-deviceid.md "https://timelimit.io/ServerDataStatus#/definitions/ServerPing/properties/deviceId")
### deviceId Type
`string`
## token
`token`
* is required
* Type: `string`
* cannot be null
* defined in: [ServerDataStatus](serverdatastatus-definitions-serverping-properties-token.md "https://timelimit.io/ServerDataStatus#/definitions/ServerPing/properties/token")
### token Type
`string`
## type
`type`
* is required
* Type: `string`
* cannot be null
* defined in: [ServerDataStatus](serverdatastatus-definitions-serverping-properties-type.md "https://timelimit.io/ServerDataStatus#/definitions/ServerPing/properties/type")
### type Type
`string`
### type Constraints
**enum**: the value of this property must be equal to one of the following values:
| Value | Explanation |
| :------- | :---------- |
| `"ping"` | |
| `"pong"` | |
@@ -0,0 +1,15 @@
# Untitled array in ServerDataStatus Schema
```txt
https://timelimit.io/ServerDataStatus#/properties/pings
```
| 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") |
## pings Type
`object[]` ([ServerPing](serverdatastatus-definitions-serverping.md))
+134
View File
@@ -30,6 +30,7 @@ https://timelimit.io/ServerDataStatus
| [users](#users) | `object` | Optional | cannot be null | [ServerDataStatus](serverdatastatus-definitions-serveruserlist.md "https://timelimit.io/ServerDataStatus#/properties/users") | | [users](#users) | `object` | Optional | cannot be null | [ServerDataStatus](serverdatastatus-definitions-serveruserlist.md "https://timelimit.io/ServerDataStatus#/properties/users") |
| [krq](#krq) | `array` | Optional | cannot be null | [ServerDataStatus](serverdatastatus-properties-krq.md "https://timelimit.io/ServerDataStatus#/properties/krq") | | [krq](#krq) | `array` | Optional | cannot be null | [ServerDataStatus](serverdatastatus-properties-krq.md "https://timelimit.io/ServerDataStatus#/properties/krq") |
| [kr](#kr) | `array` | Optional | cannot be null | [ServerDataStatus](serverdatastatus-properties-kr.md "https://timelimit.io/ServerDataStatus#/properties/kr") | | [kr](#kr) | `array` | Optional | cannot be null | [ServerDataStatus](serverdatastatus-properties-kr.md "https://timelimit.io/ServerDataStatus#/properties/kr") |
| [pings](#pings) | `array` | Optional | cannot be null | [ServerDataStatus](serverdatastatus-properties-pings.md "https://timelimit.io/ServerDataStatus#/properties/pings") |
| [dh](#dh) | `object` | Optional | cannot be null | [ServerDataStatus](serverdatastatus-definitions-serverdhkey.md "https://timelimit.io/ServerDataStatus#/properties/dh") | | [dh](#dh) | `object` | Optional | cannot be null | [ServerDataStatus](serverdatastatus-definitions-serverdhkey.md "https://timelimit.io/ServerDataStatus#/properties/dh") |
| [u2f](#u2f) | `object` | Optional | cannot be null | [ServerDataStatus](serverdatastatus-definitions-u2fdata.md "https://timelimit.io/ServerDataStatus#/properties/u2f") | | [u2f](#u2f) | `object` | Optional | cannot be null | [ServerDataStatus](serverdatastatus-definitions-u2fdata.md "https://timelimit.io/ServerDataStatus#/properties/u2f") |
| [fullVersion](#fullversion) | `number` | Required | cannot be null | [ServerDataStatus](serverdatastatus-properties-fullversion.md "https://timelimit.io/ServerDataStatus#/properties/fullVersion") | | [fullVersion](#fullversion) | `number` | Required | cannot be null | [ServerDataStatus](serverdatastatus-properties-fullversion.md "https://timelimit.io/ServerDataStatus#/properties/fullVersion") |
@@ -252,6 +253,24 @@ https://timelimit.io/ServerDataStatus
`object[]` ([ServerKeyResponse](serverdatastatus-definitions-serverkeyresponse.md)) `object[]` ([ServerKeyResponse](serverdatastatus-definitions-serverkeyresponse.md))
## pings
`pings`
* is optional
* Type: `object[]` ([ServerPing](serverdatastatus-definitions-serverping.md))
* cannot be null
* defined in: [ServerDataStatus](serverdatastatus-properties-pings.md "https://timelimit.io/ServerDataStatus#/properties/pings")
### pings Type
`object[]` ([ServerPing](serverdatastatus-definitions-serverping.md))
## dh ## dh
@@ -435,6 +454,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") | | [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") | | [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") | | [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 ### deviceId
@@ -1104,6 +1125,42 @@ Reference this group by using
`string` `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 ## Definitions group ProtectionLevel
Reference this group by using Reference this group by using
@@ -3411,6 +3468,83 @@ Reference this group by using
`string` `string`
## Definitions group ServerPing
Reference this group by using
```json
{"$ref":"https://timelimit.io/ServerDataStatus#/definitions/ServerPing"}
```
| Property | Type | Required | Nullable | Defined by |
| :---------------------- | :------- | :------- | :------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [deviceId](#deviceid-4) | `string` | Required | cannot be null | [ServerDataStatus](serverdatastatus-definitions-serverping-properties-deviceid.md "https://timelimit.io/ServerDataStatus#/definitions/ServerPing/properties/deviceId") |
| [token](#token) | `string` | Required | cannot be null | [ServerDataStatus](serverdatastatus-definitions-serverping-properties-token.md "https://timelimit.io/ServerDataStatus#/definitions/ServerPing/properties/token") |
| [type](#type-2) | `string` | Required | cannot be null | [ServerDataStatus](serverdatastatus-definitions-serverping-properties-type.md "https://timelimit.io/ServerDataStatus#/definitions/ServerPing/properties/type") |
### deviceId
`deviceId`
* is required
* Type: `string`
* cannot be null
* defined in: [ServerDataStatus](serverdatastatus-definitions-serverping-properties-deviceid.md "https://timelimit.io/ServerDataStatus#/definitions/ServerPing/properties/deviceId")
#### deviceId Type
`string`
### token
`token`
* is required
* Type: `string`
* cannot be null
* defined in: [ServerDataStatus](serverdatastatus-definitions-serverping-properties-token.md "https://timelimit.io/ServerDataStatus#/definitions/ServerPing/properties/token")
#### token Type
`string`
### type
`type`
* is required
* Type: `string`
* cannot be null
* defined in: [ServerDataStatus](serverdatastatus-definitions-serverping-properties-type.md "https://timelimit.io/ServerDataStatus#/definitions/ServerPing/properties/type")
#### type Type
`string`
#### type Constraints
**enum**: the value of this property must be equal to one of the following values:
| Value | Explanation |
| :------- | :---------- |
| `"ping"` | |
| `"pong"` | |
## Definitions group ServerDhKey ## Definitions group ServerDhKey
Reference this group by using Reference this group by using
+18
View File
@@ -0,0 +1,18 @@
// @ts-check
import eslint from '@eslint/js';
import { defineConfig } from 'eslint/config';
import tseslint from 'typescript-eslint';
export default defineConfig(
eslint.configs.recommended,
tseslint.configs.recommended,
{
ignores: ['build', 'scripts']
},
{
rules: {
'@typescript-eslint/no-unused-vars': ['warn', { caughtErrors: 'none' }]
}
}
)
+3849 -4175
View File
File diff suppressed because it is too large Load Diff
+12 -15
View File
@@ -6,10 +6,10 @@
"scripts": { "scripts": {
"start": "node ./build/index.js", "start": "node ./build/index.js",
"test": "node scripts/test-launch-with-different-databases.js", "test": "node scripts/test-launch-with-different-databases.js",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx", "lint": "eslint .",
"lint:fix": "eslint . --ext .js,.jsx,.ts,.tsx --fix", "lint:fix": "eslint . --fix",
"build": "npm run build:clean && npm run build:json && npm run build:ts && npm run lint && npm run build:doc", "build": "npm run build:clean && npm run build:json && npm run build:ts && npm run lint && npm run build:doc",
"build:clean": "rimraf build", "build:clean": "rm -rf build",
"build:json": "node ./scripts/build-schemas.js", "build:json": "node ./scripts/build-schemas.js",
"build:ts": "tsc", "build:ts": "tsc",
"build:doc": "npm run build:doc:json", "build:doc": "npm run build:doc:json",
@@ -29,7 +29,8 @@
}, },
"homepage": "https://gitlab.com/timelimit.io/timelimit-server-2018#README", "homepage": "https://gitlab.com/timelimit.io/timelimit-server-2018#README",
"devDependencies": { "devDependencies": {
"@adobe/jsonschema2md": "^7.0.0", "@adobe/jsonschema2md": "^8.0.8",
"@eslint/js": "^10.0.1",
"@types/basic-auth": "^1.1.3", "@types/basic-auth": "^1.1.3",
"@types/body-parser": "^1.19.0", "@types/body-parser": "^1.19.0",
"@types/ejs": "^3.1.0", "@types/ejs": "^3.1.0",
@@ -38,16 +39,13 @@
"@types/lodash": "^4.14.166", "@types/lodash": "^4.14.166",
"@types/node": "^16.11.59", "@types/node": "^16.11.59",
"@types/nodemailer": "^6.4.4", "@types/nodemailer": "^6.4.4",
"@types/umzug": "^2.3.0", "eslint": "^10.0.1",
"@typescript-eslint/eslint-plugin": "^5.10.0", "typescript": "^5.5.4",
"@typescript-eslint/parser": "^5.10.0", "typescript-eslint": "^8.56.0",
"eslint": "^8.7.0",
"rimraf": "^3.0.2",
"typescript": "^4.4.4",
"typescript-json-schema": "^0.52.0" "typescript-json-schema": "^0.52.0"
}, },
"dependencies": { "dependencies": {
"ajv": "^7.0.2", "ajv": "^8.18.0",
"basic-auth": "^2.0.1", "basic-auth": "^2.0.1",
"body-parser": "^1.19.0", "body-parser": "^1.19.0",
"ejs": "^3.1.5", "ejs": "^3.1.5",
@@ -57,16 +55,15 @@
"jose": "^4.9.3", "jose": "^4.9.3",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"mariadb": "^2.5.2", "mariadb": "^2.5.2",
"nodemailer": "^6.7.2", "nodemailer": "^9.0.4",
"pg": "^8.5.1", "pg": "^8.5.1",
"pg-hstore": "^2.3.3", "pg-hstore": "^2.3.3",
"rate-limiter-flexible": "^2.1.15", "rate-limiter-flexible": "^2.1.15",
"sequelize": "^6.25.5", "sequelize": "^6.25.5",
"socket.io": "^4.0.1", "socket.io": "^4.0.1",
"sqlite3": "^4.0.0", "umzug": "^3.8.1"
"umzug": "^2.3.0"
}, },
"optionalDependencies": { "optionalDependencies": {
"sqlite3": "^4.0.0" "sqlite3": "npm:@vscode/sqlite3@^5.1.12-vscode"
} }
} }
+4 -2
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2023 Jonas Lochmann * Copyright (C) 2019 - 2024 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -58,7 +58,9 @@ const allTypes = [
const settings = { const settings = {
required: true, required: true,
noExtraProps: true noExtraProps: true,
// otherwise it finds errors in dependencies that we don't care about
ignoreErrors: true
}; };
const compilerOptions = { const compilerOptions = {
+4 -2
View File
@@ -24,6 +24,8 @@ const { spawnAsync } = require('../process.js')
const { sleep } = require('../sleep.js') const { sleep } = require('../sleep.js')
async function startMariadb() { async function startMariadb() {
const osUsername = require('os').userInfo().username
try { await mkdirAsync(tempDir) } catch (ex) {/* ignore */} try { await mkdirAsync(tempDir) } catch (ex) {/* ignore */}
const instanceDir = resolve(tempDir, generateShortToken()) const instanceDir = resolve(tempDir, generateShortToken())
@@ -60,12 +62,12 @@ async function startMariadb() {
for (command of commands) { for (command of commands) {
console.log(command) console.log(command)
await spawnAsync('mysql', ['-S', socketPath, '-u', 'root', '-e', command], { stdio: 'inherit' }) await spawnAsync('mysql', ['-S', socketPath, '-u', osUsername, '-e', command], { stdio: 'inherit' })
} }
return { return {
shutdown: () => { shutdown: () => {
spawnAsync('mysql', ['-S', socketPath, '-u', 'root', '-e', 'SHUTDOWN;'], { stdio: 'inherit' }).catch((ex) => { spawnAsync('mysql', ['-S', socketPath, '-u', osUsername, '-e', 'SHUTDOWN;'], { stdio: 'inherit' }).catch((ex) => {
console.warn(ex) console.warn(ex)
}) })
}, },
+1 -1
View File
@@ -58,7 +58,7 @@ async function startPostgres() {
const password = generateToken() // this database accepts anything const password = generateToken() // this database accepts anything
await spawnAsync('createuser', ['-h', socketDir, username], { stdio: 'inherit' }) await spawnAsync('createuser', ['-h', socketDir, username], { stdio: 'inherit' })
await spawnAsync('createdb', ['-h', socketDir, database], { stdio: 'inherit' }) await spawnAsync('createdb', ['-h', socketDir, '--owner', username, database], { stdio: 'inherit' })
return { return {
shutdown: () => task.kill('SIGINT'), shutdown: () => task.kill('SIGINT'),
+2 -1
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -78,6 +78,7 @@ export { UpdateTimelimitRuleAction } from './updatetimelimitrule'
export { UpdateUserFlagsAction } from './updateuserflags' export { UpdateUserFlagsAction } from './updateuserflags'
export { UpdateUserLimitLoginCategory } from './updateuserlimitlogincategory' export { UpdateUserLimitLoginCategory } from './updateuserlimitlogincategory'
export { MarkTaskPendingAction } from './marktaskpendingaction' export { MarkTaskPendingAction } from './marktaskpendingaction'
export { PingAction } from './ping'
export { DeleteChildTaskAction } from './deletechildtaskaction' export { DeleteChildTaskAction } from './deletechildtaskaction'
export { UpdateChildTaskAction } from './updatechildtaskaction' export { UpdateChildTaskAction } from './updatechildtaskaction'
export { ReviewChildTaskAction } from './reviewchildtaskaction' export { ReviewChildTaskAction } from './reviewchildtaskaction'
+55
View File
@@ -0,0 +1,55 @@
/*
* server component for the TimeLimit App
* Copyright (C) 2019 - 2026 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 { AppLogicAction } from './basetypes'
import { assertIdWithinFamily } from './meta/util'
const actionType = 'PingAction'
export class PingAction extends AppLogicAction {
readonly deviceId: string
readonly event: PingEvent
readonly token: string
constructor ({ deviceId, event, token }: {
deviceId: string
event: PingEvent
token: string
}) {
super()
assertIdWithinFamily({ actionType, field: 'deviceId', value: deviceId })
assertIdWithinFamily({ actionType, field: 'token', value: token })
this.deviceId = deviceId
this.event = event
this.token = token
}
static parse = ({ deviceId, event, token }: SerializedPingAction) => (
new PingAction({ deviceId, event, token })
)
}
export interface SerializedPingAction {
type: 'PING'
deviceId: string
event: PingEvent
token: string
}
export type PingEvent = 'ping' | 'pong' | 'clear'
+5 -1
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -24,6 +24,7 @@ import { ForceSyncAction, SerializedForceSyncAction } from '../forcesync'
import { ReplyToKeyRequestAction, SerializedReplyToKeyRequestAction } from '../replytokeyrequest' import { ReplyToKeyRequestAction, SerializedReplyToKeyRequestAction } from '../replytokeyrequest'
import { MarkTaskPendingAction, SerializedMarkTaskPendingAction } from '../marktaskpendingaction' import { MarkTaskPendingAction, SerializedMarkTaskPendingAction } from '../marktaskpendingaction'
import { UnknownActionTypeException } from '../meta/exception' import { UnknownActionTypeException } from '../meta/exception'
import { PingAction, SerializedPingAction } from '../ping'
import { UpdateInstalledAppsAction, SerializedUpdateInstalledAppsAction } from '../updateinstalledapps' import { UpdateInstalledAppsAction, SerializedUpdateInstalledAppsAction } from '../updateinstalledapps'
import { RemoveInstalledAppsAction, SerializedRemoveInstalledAppsAction } from '../removeinstalledapps' import { RemoveInstalledAppsAction, SerializedRemoveInstalledAppsAction } from '../removeinstalledapps'
import { SendKeyRequestAction, SerializedSendKeyRequestAction } from '../sendkeyrequest' import { SendKeyRequestAction, SerializedSendKeyRequestAction } from '../sendkeyrequest'
@@ -41,6 +42,7 @@ export type SerializedAppLogicAction =
SerializedForceSyncAction | SerializedForceSyncAction |
SerializedReplyToKeyRequestAction | SerializedReplyToKeyRequestAction |
SerializedMarkTaskPendingAction | SerializedMarkTaskPendingAction |
SerializedPingAction |
SerializedUpdateInstalledAppsAction | SerializedUpdateInstalledAppsAction |
SerializedRemoveInstalledAppsAction | SerializedRemoveInstalledAppsAction |
SerializedSendKeyRequestAction | SerializedSendKeyRequestAction |
@@ -65,6 +67,8 @@ export const parseAppLogicAction = (serialized: SerializedAppLogicAction): AppLo
return ReplyToKeyRequestAction.parse(serialized) return ReplyToKeyRequestAction.parse(serialized)
} else if (serialized.type === 'MARK_TASK_PENDING') { } else if (serialized.type === 'MARK_TASK_PENDING') {
return MarkTaskPendingAction.parse(serialized) return MarkTaskPendingAction.parse(serialized)
} else if (serialized.type === 'PING') {
return PingAction.parse(serialized)
} else if (serialized.type === 'UPDATE_INSTALLED_APPS') { } else if (serialized.type === 'UPDATE_INSTALLED_APPS') {
return UpdateInstalledAppsAction.parse(serialized) return UpdateInstalledAppsAction.parse(serialized)
} else if (serialized.type === 'REMOVE_INSTALLED_APPS') { } else if (serialized.type === 'REMOVE_INSTALLED_APPS') {
+33 -4
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * 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 * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * 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/>. * 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 { NewPermissionStatus } from '../model/newpermissionstatus'
import { ProtectionLevel } from '../model/protectionlevel' import { ProtectionLevel } from '../model/protectionlevel'
import { RuntimePermissionStatus } from '../model/runtimepermissionstatus' import { RuntimePermissionStatus } from '../model/runtimepermissionstatus'
@@ -33,6 +34,8 @@ export class UpdateDeviceStatusAction extends AppLogicAction {
readonly didReboot: boolean readonly didReboot: boolean
readonly isQOrLaterNow: boolean readonly isQOrLaterNow: boolean
readonly addedManipulationFlags: number readonly addedManipulationFlags: number
readonly platformType?: string
readonly platformLevel?: number
constructor ({ constructor ({
newProtetionLevel, newProtetionLevel,
@@ -43,7 +46,9 @@ export class UpdateDeviceStatusAction extends AppLogicAction {
newAppVersion, newAppVersion,
didReboot, didReboot,
isQOrLaterNow, isQOrLaterNow,
addedManipulationFlags addedManipulationFlags,
platformType,
platformLevel
}: { }: {
newProtetionLevel?: ProtectionLevel newProtetionLevel?: ProtectionLevel
newUsageStatsPermissionStatus?: RuntimePermissionStatus newUsageStatsPermissionStatus?: RuntimePermissionStatus
@@ -54,6 +59,8 @@ export class UpdateDeviceStatusAction extends AppLogicAction {
didReboot: boolean didReboot: boolean
isQOrLaterNow: boolean isQOrLaterNow: boolean
addedManipulationFlags: number addedManipulationFlags: number
platformType?: string
platformLevel?: number
}) { }) {
super() super()
@@ -67,6 +74,20 @@ export class UpdateDeviceStatusAction extends AppLogicAction {
assertSafeInteger({ actionType, field: 'addedManipulationFlags', value: addedManipulationFlags }) 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.newProtetionLevel = newProtetionLevel
this.newUsageStatsPermissionStatus = newUsageStatsPermissionStatus this.newUsageStatsPermissionStatus = newUsageStatsPermissionStatus
this.newNotificationAccessPermission = newNotificationAccessPermission this.newNotificationAccessPermission = newNotificationAccessPermission
@@ -76,6 +97,8 @@ export class UpdateDeviceStatusAction extends AppLogicAction {
this.didReboot = didReboot this.didReboot = didReboot
this.isQOrLaterNow = isQOrLaterNow this.isQOrLaterNow = isQOrLaterNow
this.addedManipulationFlags = addedManipulationFlags this.addedManipulationFlags = addedManipulationFlags
this.platformType = platformType
this.platformLevel = platformLevel
} }
static parse = ({ static parse = ({
@@ -87,7 +110,9 @@ export class UpdateDeviceStatusAction extends AppLogicAction {
appVersion, appVersion,
didReboot, didReboot,
isQOrLaterNow, isQOrLaterNow,
addedManipulationFlags addedManipulationFlags,
platformType,
platformLevel
}: SerializedUpdateDeviceStatusAction) => ( }: SerializedUpdateDeviceStatusAction) => (
new UpdateDeviceStatusAction({ new UpdateDeviceStatusAction({
newProtetionLevel: protectionLevel, newProtetionLevel: protectionLevel,
@@ -98,7 +123,9 @@ export class UpdateDeviceStatusAction extends AppLogicAction {
newAppVersion: appVersion, newAppVersion: appVersion,
didReboot: !!didReboot, didReboot: !!didReboot,
isQOrLaterNow: !!isQOrLaterNow, isQOrLaterNow: !!isQOrLaterNow,
addedManipulationFlags: addedManipulationFlags || 0 addedManipulationFlags: addedManipulationFlags || 0,
platformType: platformType,
platformLevel: platformLevel
}) })
) )
} }
@@ -114,4 +141,6 @@ export interface SerializedUpdateDeviceStatusAction {
didReboot?: boolean didReboot?: boolean
isQOrLaterNow?: boolean isQOrLaterNow?: boolean
addedManipulationFlags?: number addedManipulationFlags?: number
platformType?: string
platformLevel?: number
} }
+17 -4
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2020 Jonas Lochmann * Copyright (C) 2019 - 2024 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -32,11 +32,12 @@ export class UpdateTimelimitRuleAction extends ParentAction {
readonly sessionDurationMilliseconds: number readonly sessionDurationMilliseconds: number
readonly sessionPauseMilliseconds: number readonly sessionPauseMilliseconds: number
readonly perDay: boolean readonly perDay: boolean
readonly expiresAt?: number
constructor ({ constructor ({
ruleId, maximumTimeInMillis, dayMask, applyToExtraTimeUsage, ruleId, maximumTimeInMillis, dayMask, applyToExtraTimeUsage,
start, end, sessionDurationMilliseconds, sessionPauseMilliseconds, start, end, sessionDurationMilliseconds, sessionPauseMilliseconds,
perDay perDay, expiresAt
}: { }: {
ruleId: string ruleId: string
maximumTimeInMillis: number maximumTimeInMillis: number
@@ -47,6 +48,7 @@ export class UpdateTimelimitRuleAction extends ParentAction {
sessionDurationMilliseconds: number sessionDurationMilliseconds: number
sessionPauseMilliseconds: number sessionPauseMilliseconds: number
perDay: boolean perDay: boolean
expiresAt?: number
}) { }) {
super() super()
@@ -59,6 +61,7 @@ export class UpdateTimelimitRuleAction extends ParentAction {
this.sessionDurationMilliseconds = sessionDurationMilliseconds this.sessionDurationMilliseconds = sessionDurationMilliseconds
this.sessionPauseMilliseconds = sessionPauseMilliseconds this.sessionPauseMilliseconds = sessionPauseMilliseconds
this.perDay = perDay this.perDay = perDay
this.expiresAt = expiresAt
assertIdWithinFamily({ actionType, field: 'ruleId', value: ruleId }) assertIdWithinFamily({ actionType, field: 'ruleId', value: ruleId })
@@ -92,9 +95,17 @@ export class UpdateTimelimitRuleAction extends ParentAction {
staticMessage: 'session duration lesser than zero' staticMessage: 'session duration lesser than zero'
}) })
} }
if (expiresAt !== undefined) {
assertSafeInteger({ actionType, field: 'expiresAt', value: expiresAt })
if (expiresAt <= 0) {
throwOutOfRange({ actionType, field: 'expiresAt', value: expiresAt })
}
}
} }
static parse = ({ ruleId, time, days, extraTime, start, end, dur, pause, perDay }: SerializedUpdateTimelimitRuleAction) => ( static parse = ({ ruleId, time, days, extraTime, start, end, dur, pause, perDay, e }: SerializedUpdateTimelimitRuleAction) => (
new UpdateTimelimitRuleAction({ new UpdateTimelimitRuleAction({
ruleId, ruleId,
maximumTimeInMillis: time, maximumTimeInMillis: time,
@@ -104,7 +115,8 @@ export class UpdateTimelimitRuleAction extends ParentAction {
end: end ?? MinuteOfDay.MAX, end: end ?? MinuteOfDay.MAX,
sessionDurationMilliseconds: dur ?? 0, sessionDurationMilliseconds: dur ?? 0,
sessionPauseMilliseconds: pause ?? 0, sessionPauseMilliseconds: pause ?? 0,
perDay: perDay ?? false perDay: perDay ?? false,
expiresAt: e
}) })
) )
} }
@@ -120,4 +132,5 @@ export interface SerializedUpdateTimelimitRuleAction {
dur?: number dur?: number
pause?: number pause?: number
perDay?: boolean perDay?: boolean
e?: number
} }
+39 -25
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -19,7 +19,7 @@ import { json } from 'body-parser'
import { Router } from 'express' import { Router } from 'express'
import { BadRequest, Conflict } from 'http-errors' import { BadRequest, Conflict } from 'http-errors'
import * as Sequelize from 'sequelize' import * as Sequelize from 'sequelize'
import { Database } from '../database' import { SimpleDatabase } from '../database/simple'
import { addPurchase, canDoNextPurchase } from '../function/purchase' import { addPurchase, canDoNextPurchase } from '../function/purchase'
import { getStatusMessage, setStatusMessage } from '../function/statusmessage' import { getStatusMessage, setStatusMessage } from '../function/statusmessage'
import { EventHandler } from '../monitoring/eventhandler' import { EventHandler } from '../monitoring/eventhandler'
@@ -28,7 +28,7 @@ import { verifyIdentitifyToken, TokenValidationException } from '../util/identit
import { WebsocketApi } from '../websocket' import { WebsocketApi } from '../websocket'
export const createAdminRouter = ({ database, websocket, eventHandler }: { export const createAdminRouter = ({ database, websocket, eventHandler }: {
database: Database database: SimpleDatabase
websocket: WebsocketApi websocket: WebsocketApi
eventHandler: EventHandler eventHandler: EventHandler
}) => { }) => {
@@ -60,7 +60,9 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: {
router.get('/status-message', async (_, res, next) => { router.get('/status-message', async (_, res, next) => {
try { try {
const currentStatusMessage = await getStatusMessage({ database }) const currentStatusMessage = await database.transaction(async (transaction) => {
return getStatusMessage({ transaction })
})
res.json({ res.json({
statusMessage: currentStatusMessage statusMessage: currentStatusMessage
@@ -102,12 +104,12 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: {
} }
await database.transaction(async (transaction) => { await database.transaction(async (transaction) => {
const userEntryUnsafe = await database.user.findOne({ const userEntryUnsafe = await transaction.legacy.database.user.findOne({
where: { where: {
mail mail
}, },
attributes: ['familyId'], attributes: ['familyId'],
transaction transaction: transaction.legacy.transaction
}) })
if (!userEntryUnsafe) { if (!userEntryUnsafe) {
@@ -119,13 +121,12 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: {
} }
await addPurchase({ await addPurchase({
database, transaction,
familyId: userEntry.familyId, familyId: userEntry.familyId,
type, type,
service: 'directpurchase', service: 'directpurchase',
transactionId: 'legacyunlock-' + type + '-' + generatePurchaseId(), transactionId: 'legacyunlock-' + type + '-' + generatePurchaseId(),
websocket, websocket
transaction
}) })
}) })
@@ -140,15 +141,23 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: {
if ( if (
typeof req.body !== 'object' || typeof req.body !== 'object' ||
typeof req.body.purchaseToken !== 'string' || typeof req.body.purchaseToken !== 'string' ||
typeof req.body.purchaseId !== 'string' typeof req.body.purchaseId !== 'string' ||
typeof req.body.dryRun !== 'boolean' ||
typeof req.body.type !== 'string'
) { ) {
throw new BadRequest() throw new BadRequest()
} }
const purchaseToken: string = req.body.purchaseToken const purchaseToken: string = req.body.purchaseToken
const purchaseId: string = req.body.purchaseId const purchaseId: string = req.body.purchaseId
const dryRun: boolean = req.body.dryRun
const type: string = req.body.type
const tokenContent = await verifyIdentitifyToken(purchaseToken) if (type !== 'month' && type !== 'year' && type !== 'unpaid14') {
throw new BadRequest()
}
const tokenContent = await verifyIdentitifyToken(purchaseToken, dryRun)
if (tokenContent.purpose !== 'purchase') { if (tokenContent.purpose !== 'purchase') {
res.json({ ok: false, error: 'token invalid', detail: 'wrong purpose' }) res.json({ ok: false, error: 'token invalid', detail: 'wrong purpose' })
@@ -157,14 +166,14 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: {
} }
const response = await database.transaction(async (transaction) => { const response = await database.transaction(async (transaction) => {
const userValid = await database.user.count({ const userValid = await transaction.legacy.database.user.count({
where: { where: {
familyId: tokenContent.familyId, familyId: tokenContent.familyId,
userId: tokenContent.userId, userId: tokenContent.userId,
mail: tokenContent.mail, mail: tokenContent.mail,
type: 'parent' type: 'parent'
}, },
transaction transaction: transaction.legacy.transaction
}) })
if (!userValid) return { if (!userValid) return {
@@ -177,7 +186,7 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: {
if (tokenContent.mail !== '') mailToReturn = tokenContent.mail if (tokenContent.mail !== '') mailToReturn = tokenContent.mail
else { else {
const userEntryWithMail = await database.user.findOne({ const userEntryWithMail = await transaction.legacy.database.user.findOne({
where: { where: {
familyId: tokenContent.familyId, familyId: tokenContent.familyId,
mail: { mail: {
@@ -185,7 +194,7 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: {
}, },
type: 'parent' type: 'parent'
}, },
transaction transaction: transaction.legacy.transaction
}) })
if (!userEntryWithMail) return { if (!userEntryWithMail) return {
@@ -199,11 +208,12 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: {
let wasAlreadyExecuted: boolean let wasAlreadyExecuted: boolean
const oldPurchaseByPurchaseId = await database.purchase.findOne({ const oldPurchaseByPurchaseId = await transaction.legacy.database.purchase.findOne({
where: { where: {
service: 'directpurchase', service: 'directpurchase',
transactionId: purchaseId transactionId: purchaseId
} },
transaction: transaction.legacy.transaction
}) })
if (oldPurchaseByPurchaseId === null) wasAlreadyExecuted = false if (oldPurchaseByPurchaseId === null) wasAlreadyExecuted = false
@@ -214,11 +224,11 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: {
} }
if (!wasAlreadyExecuted) { if (!wasAlreadyExecuted) {
const familyEntry = await database.family.findOne({ const familyEntry = await transaction.legacy.database.family.findOne({
where: { where: {
familyId: tokenContent.familyId familyId: tokenContent.familyId
}, },
transaction transaction: transaction.legacy.transaction
}) })
if (!familyEntry) return { if (!familyEntry) return {
@@ -226,14 +236,17 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: {
error: 'family not found' error: 'family not found'
} }
const canDoPurchase = canDoNextPurchase({ fullVersionUntil: parseInt(familyEntry.fullVersionUntil) }) const canDoPurchase = canDoNextPurchase({
fullVersionUntil: parseInt(familyEntry.fullVersionUntil),
fullVersionDebts: parseInt(familyEntry.fullVersionDebts),
})
if (!canDoPurchase) { if (!canDoPurchase) {
const lastPurchase = await database.purchase.findOne({ const lastPurchase = await transaction.legacy.database.purchase.findOne({
where: { where: {
familyId: tokenContent.familyId familyId: tokenContent.familyId
}, },
transaction, transaction: transaction.legacy.transaction,
order: [['loggedAt', 'DESC']], order: [['loggedAt', 'DESC']],
limit: 1 limit: 1
}) })
@@ -250,16 +263,17 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: {
} }
} }
if (!dryRun) {
await addPurchase({ await addPurchase({
database, transaction,
familyId: tokenContent.familyId, familyId: tokenContent.familyId,
type: 'year', type,
service: 'directpurchase', service: 'directpurchase',
transactionId: purchaseId, transactionId: purchaseId,
websocket, websocket,
transaction
}) })
} }
}
return { return {
ok: true, ok: true,
+3 -3
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2021 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -18,7 +18,7 @@
import { json } from 'body-parser' import { json } from 'body-parser'
import { Router } from 'express' import { Router } from 'express'
import { BadRequest } from 'http-errors' import { BadRequest } from 'http-errors'
import { Database } from '../database' import { SimpleDatabase } from '../database/simple'
import { sendLoginCode, signInByMailCode } from '../function/authentication/login-by-mail' import { sendLoginCode, signInByMailCode } from '../function/authentication/login-by-mail'
import { isMailAddressCoveredByWhitelist, isMailServerBlacklisted, sanitizeMailAddress } from '../util/mail' import { isMailAddressCoveredByWhitelist, isMailServerBlacklisted, sanitizeMailAddress } from '../util/mail'
import { import {
@@ -26,7 +26,7 @@ import {
isSignInByMailCodeRequest isSignInByMailCodeRequest
} from './validator' } from './validator'
export const createAuthRouter = (database: Database) => { export const createAuthRouter = (database: SimpleDatabase) => {
const router = Router() const router = Router()
router.post('/send-mail-login-code-v2', json(), async (req, res, next) => { router.post('/send-mail-login-code-v2', json(), async (req, res, next) => {
+3 -3
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -18,7 +18,7 @@
import { json } from 'body-parser' import { json } from 'body-parser'
import { Router } from 'express' import { Router } from 'express'
import { BadRequest } from 'http-errors' import { BadRequest } from 'http-errors'
import { Database } from '../database' import { SimpleDatabase } from '../database/simple'
import { addChildDevice } from '../function/child/add-device' import { addChildDevice } from '../function/child/add-device'
import { logoutAtPrimaryDevice } from '../function/child/logout-at-primary-device' import { logoutAtPrimaryDevice } from '../function/child/logout-at-primary-device'
import { setPrimaryDevice } from '../function/child/set-primary-device' import { setPrimaryDevice } from '../function/child/set-primary-device'
@@ -27,7 +27,7 @@ import { isRegisterChildDeviceRequest, isRequestWithAuthToken, isUpdatePrimaryDe
import { EventHandler } from '../monitoring/eventhandler' import { EventHandler } from '../monitoring/eventhandler'
export const createChildRouter = ({ database, websocket, eventHandler }: { export const createChildRouter = ({ database, websocket, eventHandler }: {
database: Database database: SimpleDatabase
websocket: WebsocketApi websocket: WebsocketApi
eventHandler: EventHandler eventHandler: EventHandler
}) => { }) => {
+3 -3
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -18,7 +18,7 @@
import * as basicAuth from 'basic-auth' import * as basicAuth from 'basic-auth'
import * as express from 'express' import * as express from 'express'
import { VisibleConnectedDevicesManager } from '../connected-devices' import { VisibleConnectedDevicesManager } from '../connected-devices'
import { Database } from '../database' import { SimpleDatabase } from '../database/simple'
import { EventHandler } from '../monitoring/eventhandler' import { EventHandler } from '../monitoring/eventhandler'
import { WebsocketApi } from '../websocket' import { WebsocketApi } from '../websocket'
import { createAdminRouter } from './admin' import { createAdminRouter } from './admin'
@@ -31,7 +31,7 @@ import { createSyncRouter } from './sync'
const adminToken = process.env.ADMIN_TOKEN || '' const adminToken = process.env.ADMIN_TOKEN || ''
export const createApi = ({ database, websocket, connectedDevicesManager, eventHandler }: { export const createApi = ({ database, websocket, connectedDevicesManager, eventHandler }: {
database: Database database: SimpleDatabase
websocket: WebsocketApi websocket: WebsocketApi
connectedDevicesManager: VisibleConnectedDevicesManager connectedDevicesManager: VisibleConnectedDevicesManager
eventHandler: EventHandler eventHandler: EventHandler
+18 -20
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2023 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -20,7 +20,7 @@ import { createHmac } from 'crypto'
import { Router } from 'express' import { Router } from 'express'
import { BadRequest, Forbidden, Unauthorized } from 'http-errors' import { BadRequest, Forbidden, Unauthorized } from 'http-errors'
import { config } from '../config' import { config } from '../config'
import { Database, Transaction } from '../database' import { SimpleDatabase, SimpleDatabaseTransaction } from '../database/simple'
import { deleteAccount } from '../function/cleanup/account-deletion' import { deleteAccount } from '../function/cleanup/account-deletion'
import { removeDevice } from '../function/device/remove-device' import { removeDevice } from '../function/device/remove-device'
import { createAddDeviceToken } from '../function/parent/create-add-device-token' import { createAddDeviceToken } from '../function/parent/create-add-device-token'
@@ -44,7 +44,7 @@ import {
export const createParentRouter = ({ export const createParentRouter = ({
database, websocket, eventHandler database, websocket, eventHandler
}: { }: {
database: Database database: SimpleDatabase
websocket: WebsocketApi websocket: WebsocketApi
eventHandler: EventHandler eventHandler: EventHandler
}) => { }) => {
@@ -58,7 +58,7 @@ export const createParentRouter = ({
const { mailAuthToken } = req.body const { mailAuthToken } = req.body
const { status, mail } = await database.transaction(async (transaction) => { const { status, mail } = await database.transaction(async (transaction) => {
return getStatusByMailToken({ database, mailAuthToken, transaction }) return getStatusByMailToken({ transaction, mailAuthToken })
}) })
res.json({ res.json({
@@ -153,13 +153,13 @@ export const createParentRouter = ({
deviceAuthToken: string deviceAuthToken: string
parentId: string parentId: string
secondPasswordHash: string secondPasswordHash: string
transaction: Transaction transaction: SimpleDatabaseTransaction
}) { }) {
const deviceEntry = await database.device.findOne({ const deviceEntry = await transaction.legacy.database.device.findOne({
where: { where: {
deviceAuthToken: deviceAuthToken deviceAuthToken: deviceAuthToken
}, },
transaction transaction: transaction.legacy.transaction
}) })
if (!deviceEntry) { if (!deviceEntry) {
@@ -171,13 +171,13 @@ export const createParentRouter = ({
throw new Unauthorized() throw new Unauthorized()
} }
const parentEntry = await database.user.findOne({ const parentEntry = await transaction.legacy.database.user.findOne({
where: { where: {
familyId: deviceEntry.familyId, familyId: deviceEntry.familyId,
type: 'parent', type: 'parent',
userId: deviceEntry.currentUserId userId: deviceEntry.currentUserId
}, },
transaction transaction: transaction.legacy.transaction
}) })
if (!parentEntry) { if (!parentEntry) {
@@ -187,11 +187,11 @@ export const createParentRouter = ({
return { deviceEntry, parentEntry } return { deviceEntry, parentEntry }
} else if (secondPasswordHash.startsWith('u2f:')) { } else if (secondPasswordHash.startsWith('u2f:')) {
try { try {
const familyEntryUnsafe = await database.family.findOne({ const familyEntryUnsafe = await transaction.legacy.database.family.findOne({
where: { where: {
familyId: deviceEntry.familyId familyId: deviceEntry.familyId
}, },
transaction, transaction: transaction.legacy.transaction,
attributes: ['hasFullVersion'] attributes: ['hasFullVersion']
}) })
@@ -208,7 +208,6 @@ export const createParentRouter = ({
hasFullVersion, hasFullVersion,
familyId: deviceEntry.familyId, familyId: deviceEntry.familyId,
deviceId: deviceEntry.deviceId, deviceId: deviceEntry.deviceId,
database,
transaction, transaction,
calculateHmac: (secret) => createHmac('sha256', secret) calculateHmac: (secret) => createHmac('sha256', secret)
.update('direct action') .update('direct action')
@@ -217,13 +216,13 @@ export const createParentRouter = ({
if (u2fResult.userId !== parentId) throw new Unauthorized() if (u2fResult.userId !== parentId) throw new Unauthorized()
const parentEntry = await database.user.findOne({ const parentEntry = await transaction.legacy.database.user.findOne({
where: { where: {
familyId: deviceEntry.familyId, familyId: deviceEntry.familyId,
type: 'parent', type: 'parent',
userId: u2fResult.userId userId: u2fResult.userId
}, },
transaction transaction: transaction.legacy.transaction
}) })
if (!parentEntry) { if (!parentEntry) {
@@ -236,14 +235,14 @@ export const createParentRouter = ({
else throw ex else throw ex
} }
} else { } else {
const parentEntry = await database.user.findOne({ const parentEntry = await transaction.legacy.database.user.findOne({
where: { where: {
familyId: deviceEntry.familyId, familyId: deviceEntry.familyId,
type: 'parent', type: 'parent',
userId: parentId, userId: parentId,
secondPasswordHash: secondPasswordHash secondPasswordHash: secondPasswordHash
}, },
transaction transaction: transaction.legacy.transaction
}) })
if (!parentEntry) { if (!parentEntry) {
@@ -268,7 +267,7 @@ export const createParentRouter = ({
transaction transaction
}) })
return createAddDeviceToken({ familyId: deviceEntry.familyId, database, transaction }) return createAddDeviceToken({ familyId: deviceEntry.familyId, transaction })
}) })
res.json({ token, deviceId }) res.json({ token, deviceId })
@@ -313,11 +312,10 @@ export const createParentRouter = ({
}) })
await removeDevice({ await removeDevice({
database, transaction,
familyId: deviceEntry.familyId, familyId: deviceEntry.familyId,
deviceId: req.body.deviceId, deviceId: req.body.deviceId,
websocket, websocket
transaction
}) })
}) })
+17 -16
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -18,7 +18,7 @@
import { json } from 'body-parser' import { json } from 'body-parser'
import { Router } from 'express' import { Router } from 'express'
import { BadRequest, Conflict, Unauthorized } from 'http-errors' import { BadRequest, Conflict, Unauthorized } from 'http-errors'
import { Database } from '../database' import { SimpleDatabase } from '../database/simple'
import { import {
addPurchase, addPurchase,
areGooglePlayPaymentsPossible, areGooglePlayPaymentsPossible,
@@ -31,30 +31,32 @@ import { WebsocketApi } from '../websocket'
import { isCanDoPurchaseRequest, isFinishPurchaseByGooglePlayRequest } from './validator' import { isCanDoPurchaseRequest, isFinishPurchaseByGooglePlayRequest } from './validator'
export const createPurchaseRouter = ({ database, websocket }: { export const createPurchaseRouter = ({ database, websocket }: {
database: Database database: SimpleDatabase
websocket: WebsocketApi websocket: WebsocketApi
}) => { }) => {
const router = Router() const router = Router()
router.post('/can-do-purchase', json(), async (req, res, next) => { router.post('/can-do-purchase', json(), async (req, res, next) => {
if (!areGooglePlayPaymentsPossible) {
res.json({ canDoPurchase: 'no because not supported by the server' })
return
}
try { try {
if (!isCanDoPurchaseRequest(req.body)) { if (!isCanDoPurchaseRequest(req.body)) {
throw new BadRequest() throw new BadRequest()
} }
if (req.body.type === 'googleplay' && !areGooglePlayPaymentsPossible) {
res.json({ canDoPurchase: 'no because not supported by the server' })
return
}
const result: boolean = await database.transaction(async (transaction) => { const result: boolean = await database.transaction(async (transaction) => {
const familyEntry = await requireFamilyEntry({ const familyEntry = await requireFamilyEntry({
database, transaction,
deviceAuthToken: req.body.deviceAuthToken, deviceAuthToken: req.body.deviceAuthToken,
transaction
}) })
return canDoNextPurchase({ fullVersionUntil: parseInt(familyEntry.fullVersionUntil, 10) }) return canDoNextPurchase({
fullVersionUntil: parseInt(familyEntry.fullVersionUntil, 10),
fullVersionDebts: parseInt(familyEntry.fullVersionDebts, 10),
})
}) })
res.json({ res.json({
@@ -73,12 +75,12 @@ export const createPurchaseRouter = ({ database, websocket }: {
} }
await database.transaction(async (transaction) => { await database.transaction(async (transaction) => {
const deviceEntryUnsafe = await database.device.findOne({ const deviceEntryUnsafe = await transaction.legacy.database.device.findOne({
where: { where: {
deviceAuthToken: req.body.deviceAuthToken deviceAuthToken: req.body.deviceAuthToken
}, },
attributes: ['familyId'], attributes: ['familyId'],
transaction transaction: transaction.legacy.transaction
}) })
if (!deviceEntryUnsafe) { if (!deviceEntryUnsafe) {
@@ -119,13 +121,12 @@ export const createPurchaseRouter = ({ database, websocket }: {
} }
await addPurchase({ await addPurchase({
database, transaction,
familyId: deviceEntry.familyId, familyId: deviceEntry.familyId,
type, type,
service: 'googleplay', service: 'googleplay',
transactionId: orderId, transactionId: orderId,
websocket, websocket
transaction
}) })
}) })
+1 -1
View File
@@ -113,7 +113,7 @@ export interface CreateRegisterDeviceTokenRequest {
} }
export interface CanDoPurchaseRequest { export interface CanDoPurchaseRequest {
type: 'googleplay' | 'any' type?: 'googleplay' | 'any'
deviceAuthToken: string deviceAuthToken: string
} }
+10 -11
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -19,7 +19,7 @@ import { json } from 'body-parser'
import { Router } from 'express' import { Router } from 'express'
import { BadRequest, Unauthorized } from 'http-errors' import { BadRequest, Unauthorized } from 'http-errors'
import { VisibleConnectedDevicesManager } from '../connected-devices' import { VisibleConnectedDevicesManager } from '../connected-devices'
import { Database } from '../database' import { SimpleDatabase } from '../database/simple'
import { reportDeviceRemoved } from '../function/device/report-device-removed' import { reportDeviceRemoved } from '../function/device/report-device-removed'
import { applyActionsFromDevice } from '../function/sync/apply-actions' import { applyActionsFromDevice } from '../function/sync/apply-actions'
import { generateServerDataStatus } from '../function/sync/get-server-data-status' import { generateServerDataStatus } from '../function/sync/get-server-data-status'
@@ -34,7 +34,7 @@ const getRoundedTimestampForLastConnectivity = () => {
} }
export const createSyncRouter = ({ database, websocket, connectedDevicesManager, eventHandler }: { export const createSyncRouter = ({ database, websocket, connectedDevicesManager, eventHandler }: {
database: Database database: SimpleDatabase
websocket: WebsocketApi websocket: WebsocketApi
connectedDevicesManager: VisibleConnectedDevicesManager connectedDevicesManager: VisibleConnectedDevicesManager
eventHandler: EventHandler eventHandler: EventHandler
@@ -86,12 +86,12 @@ export const createSyncRouter = ({ database, websocket, connectedDevicesManager,
} }
const serverStatus = await database.transaction(async (transaction) => { const serverStatus = await database.transaction(async (transaction) => {
const deviceEntryUnsafe = await database.device.findOne({ const deviceEntryUnsafe = await transaction.legacy.database.device.findOne({
where: { where: {
deviceAuthToken: body.deviceAuthToken deviceAuthToken: body.deviceAuthToken
}, },
attributes: ['familyId', 'deviceId', 'lastConnectivity'], attributes: ['familyId', 'deviceId', 'lastConnectivity'],
transaction transaction: transaction.legacy.transaction
}) })
if (!deviceEntryUnsafe) { if (!deviceEntryUnsafe) {
@@ -102,22 +102,21 @@ export const createSyncRouter = ({ database, websocket, connectedDevicesManager,
const now = getRoundedTimestampForLastConnectivity() const now = getRoundedTimestampForLastConnectivity()
if (parseInt(lastConnectivity, 10) !== now) { if (parseInt(lastConnectivity, 10) !== now) {
await database.device.update({ await transaction.legacy.database.device.update({
lastConnectivity: now.toString(10) lastConnectivity: now.toString(10)
}, { }, {
where: { where: {
deviceAuthToken: body.deviceAuthToken deviceAuthToken: body.deviceAuthToken
}, },
transaction transaction: transaction.legacy.transaction
}) })
} }
return generateServerDataStatus({ return generateServerDataStatus({
database, transaction,
familyId, familyId,
deviceId, deviceId,
clientStatus: body.status, clientStatus: body.status,
transaction,
eventHandler eventHandler
}) })
}) })
@@ -165,11 +164,11 @@ export const createSyncRouter = ({ database, websocket, connectedDevicesManager,
} }
const isDeviceRemoved: boolean = await database.transaction(async (transaction) => { const isDeviceRemoved: boolean = await database.transaction(async (transaction) => {
const removedEntry = await database.oldDevice.findOne({ const removedEntry = await transaction.legacy.database.oldDevice.findOne({
where: { where: {
deviceAuthToken: req.body.deviceAuthToken deviceAuthToken: req.body.deviceAuthToken
}, },
transaction transaction: transaction.legacy.transaction
}) })
return !!removedEntry return !!removedEntry
+82 -2
View File
@@ -409,6 +409,9 @@ const definitions = {
}, },
"perDay": { "perDay": {
"type": "boolean" "type": "boolean"
},
"e": {
"type": "number"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
@@ -1417,6 +1420,9 @@ const definitions = {
}, },
"perDay": { "perDay": {
"type": "boolean" "type": "boolean"
},
"e": {
"type": "number"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
@@ -1753,6 +1759,41 @@ const definitions = {
"type" "type"
] ]
}, },
"SerializedPingAction": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"PING"
]
},
"deviceId": {
"type": "string"
},
"event": {
"$ref": "#/definitions/PingEvent"
},
"token": {
"type": "string"
}
},
"additionalProperties": false,
"required": [
"deviceId",
"event",
"token",
"type"
]
},
"PingEvent": {
"enum": [
"clear",
"ping",
"pong"
],
"type": "string"
},
"SerializedUpdateInstalledAppsAction": { "SerializedUpdateInstalledAppsAction": {
"type": "object", "type": "object",
"properties": { "properties": {
@@ -1982,6 +2023,12 @@ const definitions = {
}, },
"addedManipulationFlags": { "addedManipulationFlags": {
"type": "number" "type": "number"
},
"platformType": {
"type": "string"
},
"platformLevel": {
"type": "number"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
@@ -2164,6 +2211,12 @@ const definitions = {
}, },
"pk": { "pk": {
"type": "string" "type": "string"
},
"pType": {
"type": "string"
},
"pLevel": {
"type": "number"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
@@ -2192,6 +2245,7 @@ const definitions = {
"model", "model",
"name", "name",
"networkTime", "networkTime",
"pLevel",
"qOrLater", "qOrLater",
"reboot", "reboot",
"rebootIsManipulation", "rebootIsManipulation",
@@ -2796,6 +2850,30 @@ const definitions = {
"tempKey" "tempKey"
] ]
}, },
"ServerPing": {
"type": "object",
"properties": {
"deviceId": {
"type": "string"
},
"token": {
"type": "string"
},
"type": {
"enum": [
"ping",
"pong"
],
"type": "string"
}
},
"additionalProperties": false,
"required": [
"deviceId",
"token",
"type"
]
},
"ServerDhKey": { "ServerDhKey": {
"type": "object", "type": "object",
"properties": { "properties": {
@@ -3194,6 +3272,9 @@ export const isSerializedAppLogicAction: (value: unknown) => value is Serialized
{ {
"$ref": "#/definitions/SerializedMarkTaskPendingAction" "$ref": "#/definitions/SerializedMarkTaskPendingAction"
}, },
{
"$ref": "#/definitions/SerializedPingAction"
},
{ {
"$ref": "#/definitions/SerializedUpdateInstalledAppsAction" "$ref": "#/definitions/SerializedUpdateInstalledAppsAction"
}, },
@@ -3272,8 +3353,7 @@ export const isCanDoPurchaseRequest: (value: unknown) => value is CanDoPurchaseR
}, },
"additionalProperties": false, "additionalProperties": false,
"required": [ "required": [
"deviceAuthToken", "deviceAuthToken"
"type"
], ],
"definitions": definitions, "definitions": definitions,
"$schema": "http://json-schema.org/draft-07/schema#" "$schema": "http://json-schema.org/draft-07/schema#"
+3 -2
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -16,9 +16,10 @@
*/ */
import { defaultDatabase } from '../database' import { defaultDatabase } from '../database'
import { fromLegacy as createSimpleDatabase } from '../database/simple'
import { deleteOldFamilies } from '../function/cleanup/delete-old-families' import { deleteOldFamilies } from '../function/cleanup/delete-old-families'
const database = defaultDatabase const database = createSimpleDatabase(defaultDatabase)
deleteOldFamilies(database) deleteOldFamilies(database)
.then(() => console.log('done')) .then(() => console.log('done'))
+3 -2
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -16,9 +16,10 @@
*/ */
import { defaultDatabase } from '../database' import { defaultDatabase } from '../database'
import { fromLegacy as createSimpleDatabase } from '../database/simple'
import { findOldFamilyIds } from '../function/cleanup/delete-old-families' import { findOldFamilyIds } from '../function/cleanup/delete-old-families'
const database = defaultDatabase const database = createSimpleDatabase(defaultDatabase)
findOldFamilyIds(database) findOldFamilyIds(database)
.then((res) => console.log(JSON.stringify(res))) .then((res) => console.log(JSON.stringify(res)))
+11 -6
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -16,7 +16,7 @@
*/ */
import { EventEmitter } from 'events' import { EventEmitter } from 'events'
import { Database } from '../database' import { SimpleDatabase } from '../database/simple'
export class ConnectedDevicesManager { export class ConnectedDevicesManager {
private deviceConnectionCounters = new Map<string, number>() private deviceConnectionCounters = new Map<string, number>()
@@ -59,10 +59,10 @@ export class ConnectedDevicesManager {
export class VisibleConnectedDevicesManager { export class VisibleConnectedDevicesManager {
connectedDevicesManager = new ConnectedDevicesManager() connectedDevicesManager = new ConnectedDevicesManager()
private database: Database private database: SimpleDatabase
constructor ({ database }: { constructor ({ database }: {
database: Database database: SimpleDatabase
}) { }) {
this.database = database this.database = database
} }
@@ -174,20 +174,25 @@ export class VisibleConnectedDevicesManager {
// add all current devices // add all current devices
;(async () => { ;(async () => {
const devicesUnsafe = await this.database.device.findAll({ const devices = await this.database.transaction(async (transaction) => {
const devicesUnsafe = await transaction.legacy.database.device.findAll({
where: { where: {
familyId familyId
}, },
attributes: [ attributes: [
'deviceId', 'deviceId',
'showDeviceConnected' 'showDeviceConnected'
] ],
transaction: transaction.legacy.transaction
}) })
const devices = devicesUnsafe.map(({ deviceId, showDeviceConnected }) => ({ const devices = devicesUnsafe.map(({ deviceId, showDeviceConnected }) => ({
deviceId, showDeviceConnected deviceId, showDeviceConnected
})) }))
return devices
})
devices.forEach(({ deviceId, showDeviceConnected }) => { devices.forEach(({ deviceId, showDeviceConnected }) => {
addDevice({ deviceId, showDeviceConnected }) addDevice({ deviceId, showDeviceConnected })
}) })
+36 -3
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * 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 * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -37,6 +37,12 @@ export const DeviceManipulationFlags = {
ALL: 1 ALL: 1
} }
export const minPlatformTypeLength = 1
export const maxPlatformTypeLength = 8
export const minPlatformLevel = 0
export const maxPlatformLevel = 128
export interface DeviceAttributesVersion1 { export interface DeviceAttributesVersion1 {
familyId: string familyId: string
deviceId: string deviceId: string
@@ -119,11 +125,17 @@ export interface DeviceAttributesVersion14 {
nextKeyReplySequenceNumber: string nextKeyReplySequenceNumber: string
} }
export interface DeviceAttributesVersion15 {
platformType: string | null
platformLevel: number
}
export type DeviceAttributes = DeviceAttributesVersion1 & DeviceAttributesVersion2 & export type DeviceAttributes = DeviceAttributesVersion1 & DeviceAttributesVersion2 &
DeviceAttributesVersion3 & DeviceAttributesVersion4 & DeviceAttributesVersion5 & DeviceAttributesVersion3 & DeviceAttributesVersion4 & DeviceAttributesVersion5 &
DeviceAttributesVersion6 & DeviceAttributesVersion7 & DeviceAttributesVersion8 & DeviceAttributesVersion6 & DeviceAttributesVersion7 & DeviceAttributesVersion8 &
DeviceAttributesVersion9 & DeviceAttributesVersion10 & DeviceAttributesVersion11 & DeviceAttributesVersion9 & DeviceAttributesVersion10 & DeviceAttributesVersion11 &
DeviceAttributesVersion12 & DeviceAttributesVersion13 & DeviceAttributesVersion14 DeviceAttributesVersion12 & DeviceAttributesVersion13 & DeviceAttributesVersion14 &
DeviceAttributesVersion15
export type DeviceModel = Sequelize.Model<DeviceAttributes> & DeviceAttributes export type DeviceModel = Sequelize.Model<DeviceAttributes> & DeviceAttributes
export type DeviceModelStatic = typeof Sequelize.Model & { 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> = { export const attributes: SequelizeAttributes<DeviceAttributes> = {
...attributesVersion1, ...attributesVersion1,
...attributesVersion2, ...attributesVersion2,
@@ -319,7 +351,8 @@ export const attributes: SequelizeAttributes<DeviceAttributes> = {
...attributesVersion11, ...attributesVersion11,
...attributesVersion12, ...attributesVersion12,
...attributesVersion13, ...attributesVersion13,
...attributesVersion14 ...attributesVersion14,
...attributesVersion15
} }
export const createDeviceModel = (sequelize: Sequelize.Sequelize): DeviceModelStatic => sequelize.define('Device', attributes) as DeviceModelStatic export const createDeviceModel = (sequelize: Sequelize.Sequelize): DeviceModelStatic => sequelize.define('Device', attributes) as DeviceModelStatic
+2 -2
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann * Copyright (C) 2019 - 2024 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -26,7 +26,7 @@ export const config = {
expireTimeRounding: 1000 * 60 * 15 expireTimeRounding: 1000 * 60 * 15
} }
export function calculateExpireTime(now: bigint): BigInt { export function calculateExpireTime(now: bigint): bigint {
const expireBaseTime = now + BigInt(config.expireDelay) const expireBaseTime = now + BigInt(config.expireDelay)
const expireTime = expireBaseTime - expireBaseTime % BigInt(config.expireTimeRounding) + BigInt(config.expireTimeRounding) const expireTime = expireBaseTime - expireBaseTime % BigInt(config.expireTimeRounding) + BigInt(config.expireTimeRounding)
+20 -3
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -37,8 +37,13 @@ export interface FamilyAttributesVersion3 {
u2fKeysVersion: string u2fKeysVersion: string
} }
export interface FamilyAttributesVersion4 {
fullVersionDebts: string
}
export type FamilyAttributes = FamilyAttributesVersion1 & export type FamilyAttributes = FamilyAttributesVersion1 &
FamilyAttributesVersion2 & FamilyAttributesVersion3 FamilyAttributesVersion2 & FamilyAttributesVersion3 &
FamilyAttributesVersion4
export type FamilyModel = Sequelize.Model<FamilyAttributes> & FamilyAttributes export type FamilyModel = Sequelize.Model<FamilyAttributes> & FamilyAttributes
export type FamilyModelStatic = typeof Sequelize.Model & { export type FamilyModelStatic = typeof Sequelize.Model & {
@@ -76,10 +81,22 @@ export const attributesVersion3: SequelizeAttributes<FamilyAttributesVersion3> =
} }
} }
export const attributesVersion4: SequelizeAttributes<FamilyAttributesVersion4> = {
fullVersionDebts: {
type: Sequelize.BIGINT,
allowNull: false,
defaultValue: 0,
validate: {
min: 0
}
}
}
export const attributes: SequelizeAttributes<FamilyAttributes> = { export const attributes: SequelizeAttributes<FamilyAttributes> = {
...attributesVersion1, ...attributesVersion1,
...attributesVersion2, ...attributesVersion2,
...attributesVersion3 ...attributesVersion3,
...attributesVersion4
} }
export const createFamilyModel = (sequelize: Sequelize.Sequelize): FamilyModelStatic => sequelize.define('Family', attributes) as FamilyModelStatic export const createFamilyModel = (sequelize: Sequelize.Sequelize): FamilyModelStatic => sequelize.define('Family', attributes) as FamilyModelStatic
+4 -1
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -33,6 +33,7 @@ import { createKeyResponseModel, KeyResponseModelStatic } from './keyresponse'
import { createMailLoginTokenModel, MailLoginTokenModelStatic } from './maillogintoken' import { createMailLoginTokenModel, MailLoginTokenModelStatic } from './maillogintoken'
import { createUmzug } from './migration/umzug' import { createUmzug } from './migration/umzug'
import { createOldDeviceModel, OldDeviceModelStatic } from './olddevice' import { createOldDeviceModel, OldDeviceModelStatic } from './olddevice'
import { createPingModel, PingModelStatic } from './ping'
import { createPurchaseModel, PurchaseModelStatic } from './purchase' import { createPurchaseModel, PurchaseModelStatic } from './purchase'
import { createSessionDurationModel, SessionDurationModelStatic } from './sessionduration' import { createSessionDurationModel, SessionDurationModelStatic } from './sessionduration'
import { createTimelimitRuleModel, TimelimitRuleModelStatic } from './timelimitrule' import { createTimelimitRuleModel, TimelimitRuleModelStatic } from './timelimitrule'
@@ -61,6 +62,7 @@ export interface Database {
keyResponse: KeyResponseModelStatic keyResponse: KeyResponseModelStatic
mailLoginToken: MailLoginTokenModelStatic mailLoginToken: MailLoginTokenModelStatic
oldDevice: OldDeviceModelStatic oldDevice: OldDeviceModelStatic
ping: PingModelStatic
purchase: PurchaseModelStatic purchase: PurchaseModelStatic
sessionDuration: SessionDurationModelStatic sessionDuration: SessionDurationModelStatic
timelimitRule: TimelimitRuleModelStatic timelimitRule: TimelimitRuleModelStatic
@@ -97,6 +99,7 @@ const createDatabase = (sequelize: Sequelize.Sequelize): Database => ({
keyResponse: createKeyResponseModel(sequelize), keyResponse: createKeyResponseModel(sequelize),
mailLoginToken: createMailLoginTokenModel(sequelize), mailLoginToken: createMailLoginTokenModel(sequelize),
oldDevice: createOldDeviceModel(sequelize), oldDevice: createOldDeviceModel(sequelize),
ping: createPingModel(sequelize),
purchase: createPurchaseModel(sequelize), purchase: createPurchaseModel(sequelize),
sessionDuration: createSessionDurationModel(sequelize), sessionDuration: createSessionDurationModel(sequelize),
timelimitRule: createTimelimitRuleModel(sequelize), timelimitRule: createTimelimitRuleModel(sequelize),
@@ -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 })
})
}
@@ -0,0 +1,39 @@
/*
* server component for the TimeLimit App
* Copyright (C) 2019 - 2024 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 { attributesVersion4 as ruleAttributes } from '../../timelimitrule'
export async function up (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.addColumn('TimelimitRules', 'expiresAt', {
...ruleAttributes.expiresAt
}, {
transaction
})
})
}
export async function down (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.removeColumn('TimelimitRules', 'expiresAt', { transaction })
})
}
@@ -0,0 +1,67 @@
/*
* server component for the TimeLimit App
* Copyright (C) 2019 - 2026 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'
export async function up (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
const dialect = sequelize.getDialect()
const isMysql = dialect === 'mysql' || dialect === 'mariadb'
if (isMysql) {
await sequelize.query(
'CREATE TABLE `Pings` ' +
'(`familyId` VARCHAR(10) NOT NULL,' +
'`receiverDeviceId` VARCHAR(6) NOT NULL,' +
'`senderDeviceId` VARCHAR(6) NOT NULL,' +
'`type` INTEGER NOT NULL,' +
'`token` VARCHAR(6) NOT NULL,' +
'PRIMARY KEY (`familyId`, `receiverDeviceId`, `senderDeviceId`, `type`),' +
'FOREIGN KEY (`familyId`, `receiverDeviceId`) REFERENCES `Devices` (`familyId`, `deviceId`) ON UPDATE CASCADE ON DELETE CASCADE,' +
'FOREIGN KEY (`familyId`, `senderDeviceId`) REFERENCES `Devices` (`familyId`, `deviceId`) ON UPDATE CASCADE ON DELETE CASCADE' +
')',
{ transaction }
)
} else {
await sequelize.query(
'CREATE TABLE "Pings" ' +
'("familyId" VARCHAR(10) NOT NULL,' +
'"receiverDeviceId" VARCHAR(6) NOT NULL,' +
'"senderDeviceId" VARCHAR(6) NOT NULL,' +
'"type" INTEGER NOT NULL,' +
'"token" VARCHAR(6) NOT NULL,' +
'PRIMARY KEY ("familyId", "receiverDeviceId", "senderDeviceId", "type"),' +
'FOREIGN KEY ("familyId", "receiverDeviceId") REFERENCES "Devices" ("familyId", "deviceId") ON UPDATE CASCADE ON DELETE CASCADE,' +
'FOREIGN KEY ("familyId", "senderDeviceId") REFERENCES "Devices" ("familyId", "deviceId") ON UPDATE CASCADE ON DELETE CASCADE' +
')',
{ transaction }
)
}
await queryInterface.addIndex('Pings', ['familyId', 'senderDeviceId'], { transaction })
})
}
export async function down (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.dropTable('Pings', { transaction })
})
}
@@ -0,0 +1,39 @@
/*
* server component for the TimeLimit App
* Copyright (C) 2019 - 2026 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 { attributesVersion4 as familyAttributes } from '../../family'
export async function up (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.addColumn('Families', 'fullVersionDebts', {
...familyAttributes.fullVersionDebts
}, {
transaction
})
})
}
export async function down (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.removeColumn('Families', 'fullVersionDebts', { transaction })
})
}
+17 -9
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -17,18 +17,26 @@
import { resolve } from 'path' import { resolve } from 'path'
import { Sequelize } from 'sequelize' import { Sequelize } from 'sequelize'
import * as Umzug from 'umzug' import { Umzug, SequelizeStorage } from 'umzug'
export const createUmzug = (sequelize: Sequelize) => ( export const createUmzug = (sequelize: Sequelize) => (
new Umzug({ new Umzug({
storage: 'sequelize', storage: new SequelizeStorage({ sequelize }),
storageOptions: {
sequelize
},
migrations: { migrations: {
params: [sequelize.getQueryInterface(), sequelize], glob: resolve(__dirname, '../../../build/database/migration/migrations/*.js'),
path: resolve(__dirname, '../../../build/database/migration/migrations'), resolve: ({ name, path }) => {
pattern: /^\d+[\w-]+\.js$/ if (!path) throw new Error()
// eslint-disable-next-line @typescript-eslint/no-require-imports
const migration = require(path)
return {
name,
up: async () => migration.up(sequelize.getQueryInterface(), sequelize),
down: async () => migration.down(sequelize.getQueryInterface(), sequelize),
} }
},
},
logger: console
}) })
) )
+67
View File
@@ -0,0 +1,67 @@
/*
* server component for the TimeLimit App
* Copyright (C) 2019 - 2026 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 * as Sequelize from 'sequelize'
import { familyIdColumn, idWithinFamilyColumn } from './columns'
import { SequelizeAttributes } from './types'
export interface PingAttributes {
familyId: string
receiverDeviceId: string
senderDeviceId: string
type: number
token: string
}
export const types = {
ping: 1,
pong: 2,
all: [1, 2]
}
export type PingModel = Sequelize.Model<PingAttributes> & PingAttributes
export type PingModelStatic = typeof Sequelize.Model & {
new (values?: object, options?: Sequelize.BuildOptions): PingModel;
}
export const attributes: SequelizeAttributes<PingAttributes> = {
familyId: {
...familyIdColumn,
primaryKey: true
},
receiverDeviceId: {
...idWithinFamilyColumn,
primaryKey: true
},
senderDeviceId: {
...idWithinFamilyColumn,
primaryKey: true
},
type: {
type: Sequelize.INTEGER,
allowNull: false,
validate: {
isIn: [types.all]
},
primaryKey: true
},
token: {
...idWithinFamilyColumn
}
}
export const createPingModel = (sequelize: Sequelize.Sequelize): PingModelStatic => sequelize.define('Ping', attributes) as PingModelStatic
+3 -3
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -23,7 +23,7 @@ export interface PurchaseAttributes {
familyId: string familyId: string
service: 'googleplay' | 'directpurchase' service: 'googleplay' | 'directpurchase'
transactionId: string transactionId: string
type: 'month' | 'year' type: 'month' | 'year' | 'unpaid14'
loggedAt: string loggedAt: string
previousFullVersionEndTime: string previousFullVersionEndTime: string
newFullVersionEndTime: string newFullVersionEndTime: string
@@ -44,7 +44,7 @@ export const attributes: SequelizeAttributes<PurchaseAttributes> = {
type: Sequelize.STRING, type: Sequelize.STRING,
primaryKey: true primaryKey: true
}, },
type: createEnumColumn(['month', 'year']), type: createEnumColumn(['month', 'year', 'unpaid14']),
loggedAt: { ...timestampColumn }, loggedAt: { ...timestampColumn },
previousFullVersionEndTime: { ...timestampColumn }, previousFullVersionEndTime: { ...timestampColumn },
newFullVersionEndTime: { ...timestampColumn } newFullVersionEndTime: { ...timestampColumn }
+59
View File
@@ -0,0 +1,59 @@
/*
* server component for the TimeLimit App
* Copyright (C) 2019 - 2026 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 { Database as LegacyDatabase, Transaction as LegacyTransaction } from '../main'
export interface SimpleDatabase {
legacy: LegacyDatabase
transaction: <T> (
inner: (t: SimpleDatabaseTransaction) => Promise<T>
) => Promise<T>
}
export interface SimpleDatabaseTransaction {
transaction: <T> (
inner: (t: SimpleDatabaseTransaction) => Promise<T>
) => Promise<T>
enqueueAfterCommit(callback: () => void): void
legacy: {
database: LegacyDatabase
transaction: LegacyTransaction
}
}
export function fromLegacy(database: LegacyDatabase): SimpleDatabase {
return {
legacy: database,
transaction: (inner) => database.transaction((legacyTransaction) => inner(fromLegacyTransaction(database, legacyTransaction)))
}
}
function fromLegacyTransaction(database: LegacyDatabase, legacyTransaction: LegacyTransaction): SimpleDatabaseTransaction {
return {
transaction: (inner) => database.transaction(
(innerTransaction) => inner(fromLegacyTransaction(database, innerTransaction)),
{ transaction: legacyTransaction }
),
enqueueAfterCommit: (afterCommitAction) => legacyTransaction.afterCommit(afterCommitAction),
legacy: {
database,
transaction: legacyTransaction
}
}
}
+20 -3
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2021 Jonas Lochmann * Copyright (C) 2019 - 2024 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -41,8 +41,13 @@ interface TimelimitRuleAttributesVersion3 {
perDay: number perDay: number
} }
interface TimelimitRuleAttributesVersion4 {
expiresAt: string | null
}
type TimelimitRuleAttributes = TimelimitRuleAttributesVersion1 & type TimelimitRuleAttributes = TimelimitRuleAttributesVersion1 &
TimelimitRuleAttributesVersion2 & TimelimitRuleAttributesVersion3 TimelimitRuleAttributesVersion2 & TimelimitRuleAttributesVersion3 &
TimelimitRuleAttributesVersion4
export type TimelimitRuleModel = Sequelize.Model<TimelimitRuleAttributes> & TimelimitRuleAttributes export type TimelimitRuleModel = Sequelize.Model<TimelimitRuleAttributes> & TimelimitRuleAttributes
export type TimelimitRuleModelStatic = typeof Sequelize.Model & { export type TimelimitRuleModelStatic = typeof Sequelize.Model & {
@@ -137,10 +142,22 @@ export const attributesVersion3: SequelizeAttributes<TimelimitRuleAttributesVers
} }
} }
export const attributesVersion4: SequelizeAttributes<TimelimitRuleAttributesVersion4> = {
expiresAt: {
type: Sequelize.BIGINT,
validate: {
min: 1
},
allowNull: true,
defaultValue: null
}
}
export const attributes: SequelizeAttributes<TimelimitRuleAttributes> = { export const attributes: SequelizeAttributes<TimelimitRuleAttributes> = {
...attributesVersion1, ...attributesVersion1,
...attributesVersion2, ...attributesVersion2,
...attributesVersion3 ...attributesVersion3,
...attributesVersion4
} }
export const createTimelimitRuleModel = (sequelize: Sequelize.Sequelize): TimelimitRuleModelStatic => sequelize.define('TimelimitRule', attributes) as TimelimitRuleModelStatic export const createTimelimitRuleModel = (sequelize: Sequelize.Sequelize): TimelimitRuleModelStatic => sequelize.define('TimelimitRule', attributes) as TimelimitRuleModelStatic
+15 -15
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2021 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -16,45 +16,45 @@
*/ */
import { Unauthorized } from 'http-errors' import { Unauthorized } from 'http-errors'
import { Database, Transaction } from '../../database' import { SimpleDatabaseTransaction } from '../../database/simple'
import { generateAuthToken } from '../../util/token' import { generateAuthToken } from '../../util/token'
export const createAuthTokenByMailAddress = async ({ export const createAuthTokenByMailAddress = async ({
mail, database, transaction, locale mail, transaction, locale
}: { }: {
mail: string, database: Database, transaction: Transaction, locale: string mail: string, transaction: SimpleDatabaseTransaction, locale: string
}) => { }) => {
const token = generateAuthToken() const token = generateAuthToken()
await database.authtoken.create({ await transaction.legacy.database.authtoken.create({
token, token,
mail, mail,
createdAt: Date.now().toString(), createdAt: Date.now().toString(),
locale locale
}, { transaction }) }, { transaction: transaction.legacy.transaction })
return token return token
} }
export const getMailAndLocaleByAuthToken = async ({ export const getMailAndLocaleByAuthToken = async ({
mailAuthToken, database, transaction, invalidate mailAuthToken, transaction, invalidate
}: { }: {
mailAuthToken: string, database: Database, transaction: Transaction, invalidate: boolean mailAuthToken: string, transaction: SimpleDatabaseTransaction, invalidate: boolean
}) => { }) => {
const entry = await database.authtoken.findOne({ const entry = await transaction.legacy.database.authtoken.findOne({
where: { where: {
token: mailAuthToken token: mailAuthToken
}, },
transaction transaction: transaction.legacy.transaction
}) })
if (entry) { if (entry) {
if (invalidate) { if (invalidate) {
const rowCounter = await database.authtoken.destroy({ const rowCounter = await transaction.legacy.database.authtoken.destroy({
where: { where: {
token: mailAuthToken token: mailAuthToken
}, },
transaction transaction: transaction.legacy.transaction
}) })
if (rowCounter !== 1) { if (rowCounter !== 1) {
@@ -72,11 +72,11 @@ export const getMailAndLocaleByAuthToken = async ({
} }
export const requireMailAndLocaleByAuthToken = async ({ export const requireMailAndLocaleByAuthToken = async ({
mailAuthToken, database, transaction, invalidate mailAuthToken, transaction, invalidate
}: { }: {
mailAuthToken: string, database: Database, transaction: Transaction, invalidate: boolean mailAuthToken: string, transaction: SimpleDatabaseTransaction, invalidate: boolean
}) => { }) => {
const result = await getMailAndLocaleByAuthToken({ mailAuthToken, database, transaction, invalidate }) const result = await getMailAndLocaleByAuthToken({ mailAuthToken, transaction, invalidate })
if (!result) { if (!result) {
throw new Unauthorized() throw new Unauthorized()
+15 -16
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2023 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -16,7 +16,7 @@
*/ */
import { Forbidden, Gone, TooManyRequests, Unauthorized } from 'http-errors' import { Forbidden, Gone, TooManyRequests, Unauthorized } from 'http-errors'
import { Database } from '../../database' import { SimpleDatabase } from '../../database/simple'
import { sendAuthenticationMail } from '../../util/mail' import { sendAuthenticationMail } from '../../util/mail'
import { areWordSequencesEqual, randomWords } from '../../util/random-words' import { areWordSequencesEqual, randomWords } from '../../util/random-words'
import { checkMailSendLimit } from '../../util/ratelimit-authmail' import { checkMailSendLimit } from '../../util/ratelimit-authmail'
@@ -27,17 +27,17 @@ export const sendLoginCode = async ({ mail, deviceAuthToken, locale, database }:
mail: string mail: string
deviceAuthToken?: string deviceAuthToken?: string
locale: string locale: string
database: Database database: SimpleDatabase
// no transaction here because this is directly called from an API endpoint // no transaction here because this is directly called from an API endpoint
}): Promise<{ mailLoginToken: string }> => { }): Promise<{ mailLoginToken: string }> => {
let deviceName = null let deviceName = null
if (deviceAuthToken !== undefined) { if (deviceAuthToken !== undefined) {
const info = await database.transaction(async (transaction) => { const info = await database.transaction(async (transaction) => {
const deviceEntryUnsafe = await database.device.findOne({ const deviceEntryUnsafe = await transaction.legacy.database.device.findOne({
where: { deviceAuthToken }, where: { deviceAuthToken },
attributes: ['familyId', 'name'], attributes: ['familyId', 'name'],
transaction transaction: transaction.legacy.transaction
}) })
if (!deviceEntryUnsafe) { if (!deviceEntryUnsafe) {
@@ -49,12 +49,12 @@ export const sendLoginCode = async ({ mail, deviceAuthToken, locale, database }:
name: deviceEntryUnsafe.name name: deviceEntryUnsafe.name
} }
const userEntryCounter = await database.user.count({ const userEntryCounter = await transaction.legacy.database.user.count({
where: { where: {
familyId: deviceEntry.familyId, familyId: deviceEntry.familyId,
mail mail
}, },
transaction transaction: transaction.legacy.transaction
}) })
if (userEntryCounter === 1) { if (userEntryCounter === 1) {
@@ -86,14 +86,14 @@ export const sendLoginCode = async ({ mail, deviceAuthToken, locale, database }:
}) })
await database.transaction(async (transaction) => { await database.transaction(async (transaction) => {
await database.mailLoginToken.create({ await transaction.legacy.database.mailLoginToken.create({
mailLoginToken, mailLoginToken,
receivedCode: code, receivedCode: code,
mail, mail,
createdAt: Date.now().toString(10), createdAt: Date.now().toString(10),
remainingAttempts: 3, remainingAttempts: 3,
locale locale
}, { transaction }) }, { transaction: transaction.legacy.transaction })
}) })
return { return {
@@ -106,15 +106,15 @@ export const sendLoginCode = async ({ mail, deviceAuthToken, locale, database }:
export const signInByMailCode = async ({ mailLoginToken, receivedCode, database }: { export const signInByMailCode = async ({ mailLoginToken, receivedCode, database }: {
mailLoginToken: string mailLoginToken: string
receivedCode: string receivedCode: string
database: Database database: SimpleDatabase
// no transaction here because this is directly called from an API endpoint // no transaction here because this is directly called from an API endpoint
}): Promise<{ mailAuthToken: string }> => { }): Promise<{ mailAuthToken: string }> => {
const result = await database.transaction(async (transaction) => { const result = await database.transaction(async (transaction) => {
const entry = await database.mailLoginToken.findOne({ const entry = await transaction.legacy.database.mailLoginToken.findOne({
where: { where: {
mailLoginToken mailLoginToken
}, },
transaction transaction: transaction.legacy.transaction
}) })
if ((!entry) || entry.remainingAttempts === 0) { if ((!entry) || entry.remainingAttempts === 0) {
@@ -124,7 +124,7 @@ export const signInByMailCode = async ({ mailLoginToken, receivedCode, database
if (!areWordSequencesEqual(entry.receivedCode, receivedCode)) { if (!areWordSequencesEqual(entry.receivedCode, receivedCode)) {
entry.remainingAttempts-- entry.remainingAttempts--
await entry.save({ transaction }) await entry.save({ transaction: transaction.legacy.transaction })
if (entry.remainingAttempts === 0) { if (entry.remainingAttempts === 0) {
return () => { throw new Gone() } return () => { throw new Gone() }
@@ -133,11 +133,11 @@ export const signInByMailCode = async ({ mailLoginToken, receivedCode, database
} }
} }
const counter = await database.mailLoginToken.destroy({ const counter = await transaction.legacy.database.mailLoginToken.destroy({
where: { where: {
mailLoginToken mailLoginToken
}, },
transaction transaction: transaction.legacy.transaction
}) })
if (counter !== 1) { if (counter !== 1) {
@@ -147,7 +147,6 @@ export const signInByMailCode = async ({ mailLoginToken, receivedCode, database
const mailAuthToken = await createAuthTokenByMailAddress({ const mailAuthToken = await createAuthTokenByMailAddress({
mail: entry.mail, mail: entry.mail,
locale: entry.locale, locale: entry.locale,
database,
transaction transaction
}) })
+13 -15
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -17,7 +17,7 @@
import { Unauthorized } from 'http-errors' import { Unauthorized } from 'http-errors'
import { RegisterChildDeviceRequest } from '../../api/schema' import { RegisterChildDeviceRequest } from '../../api/schema'
import { Database } from '../../database' import { SimpleDatabase } from '../../database/simple'
import { generateAuthToken, generateVersionId } from '../../util/token' import { generateAuthToken, generateVersionId } from '../../util/token'
import { WebsocketApi } from '../../websocket' import { WebsocketApi } from '../../websocket'
import { prepareDeviceEntry } from '../device/prepare-device-entry' import { prepareDeviceEntry } from '../device/prepare-device-entry'
@@ -28,7 +28,7 @@ import { ServerDataStatus } from '../../object/serverdatastatus'
import { createEmptyClientDataStatus } from '../../object/clientdatastatus' import { createEmptyClientDataStatus } from '../../object/clientdatastatus'
export const addChildDevice = async ({ database, eventHandler, websocket, request }: { export const addChildDevice = async ({ database, eventHandler, websocket, request }: {
database: Database database: SimpleDatabase
eventHandler: EventHandler eventHandler: EventHandler
websocket: WebsocketApi websocket: WebsocketApi
request: RegisterChildDeviceRequest request: RegisterChildDeviceRequest
@@ -39,23 +39,23 @@ export const addChildDevice = async ({ database, eventHandler, websocket, reques
data: ServerDataStatus data: ServerDataStatus
}> => { }> => {
return database.transaction(async (transaction) => { return database.transaction(async (transaction) => {
const entry = await database.addDeviceToken.findOne({ const entry = await transaction.legacy.database.addDeviceToken.findOne({
where: { where: {
token: request.registerToken.toLowerCase() token: request.registerToken.toLowerCase()
}, },
transaction transaction: transaction.legacy.transaction
}) })
if (!entry) { if (!entry) {
throw new Unauthorized() throw new Unauthorized()
} }
await entry.destroy({ transaction }) await entry.destroy({ transaction: transaction.legacy.transaction })
const { deviceId, familyId } = entry const { deviceId, familyId } = entry
const deviceAuthToken = generateAuthToken() const deviceAuthToken = generateAuthToken()
await database.device.create(prepareDeviceEntry({ await transaction.legacy.database.device.create(prepareDeviceEntry({
familyId, familyId,
deviceId, deviceId,
deviceAuthToken, deviceAuthToken,
@@ -63,33 +63,31 @@ export const addChildDevice = async ({ database, eventHandler, websocket, reques
newDeviceInfo: request.childDevice, newDeviceInfo: request.childDevice,
userId: '', userId: '',
isUserKeptSignedIn: false isUserKeptSignedIn: false
}), { transaction }) }), { transaction: transaction.legacy.transaction })
await database.family.update({ await transaction.legacy.database.family.update({
deviceListVersion: generateVersionId() deviceListVersion: generateVersionId()
}, { }, {
where: { where: {
familyId familyId
}, },
transaction transaction: transaction.legacy.transaction
}) })
await notifyClientsAboutChangesDelayed({ await notifyClientsAboutChangesDelayed({
familyId, familyId,
websocket, websocket,
database, transaction,
generalLevel: 1, generalLevel: 1,
targetedLevels: new Map(), targetedLevels: new Map(),
sourceDeviceId: deviceId, sourceDeviceId: deviceId
transaction
}) })
const data = await generateServerDataStatus({ const data = await generateServerDataStatus({
database, transaction,
clientStatus: createEmptyClientDataStatus({ clientLevel: request.clientLevel || null }), clientStatus: createEmptyClientDataStatus({ clientLevel: request.clientLevel || null }),
familyId: entry.familyId, familyId: entry.familyId,
deviceId, deviceId,
transaction,
eventHandler eventHandler
}) })
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2020 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -16,21 +16,21 @@
*/ */
import { Conflict, Unauthorized } from 'http-errors' import { Conflict, Unauthorized } from 'http-errors'
import { Database } from '../../database' import { SimpleDatabase } from '../../database/simple'
import { WebsocketApi } from '../../websocket' import { WebsocketApi } from '../../websocket'
export const logoutAtPrimaryDevice = async ({ deviceAuthToken, database, websocket }: { export const logoutAtPrimaryDevice = async ({ deviceAuthToken, database, websocket }: {
deviceAuthToken: string deviceAuthToken: string
database: Database database: SimpleDatabase
websocket: WebsocketApi websocket: WebsocketApi
// no transaction here because this is directly called from an API endpoint // no transaction here because this is directly called from an API endpoint
}) => { }) => {
await database.transaction(async (transaction) => { await database.transaction(async (transaction) => {
const ownDeviceEntryUnsafe = await database.device.findOne({ const ownDeviceEntryUnsafe = await transaction.legacy.database.device.findOne({
where: { where: {
deviceAuthToken deviceAuthToken
}, },
transaction, transaction: transaction.legacy.transaction,
attributes: ['familyId', 'currentUserId', 'deviceId'] attributes: ['familyId', 'currentUserId', 'deviceId']
}) })
@@ -43,14 +43,14 @@ export const logoutAtPrimaryDevice = async ({ deviceAuthToken, database, websock
currentUserId: ownDeviceEntryUnsafe.currentUserId currentUserId: ownDeviceEntryUnsafe.currentUserId
} }
const deviceUserEntryUnsafe = await database.user.findOne({ const deviceUserEntryUnsafe = await transaction.legacy.database.user.findOne({
where: { where: {
familyId: ownDeviceEntry.familyId, familyId: ownDeviceEntry.familyId,
userId: ownDeviceEntry.currentUserId, userId: ownDeviceEntry.currentUserId,
type: 'child' type: 'child'
}, },
attributes: ['currentDevice'], attributes: ['currentDevice'],
transaction transaction: transaction.legacy.transaction
}) })
if (!deviceUserEntryUnsafe) { if (!deviceUserEntryUnsafe) {
@@ -61,14 +61,14 @@ export const logoutAtPrimaryDevice = async ({ deviceAuthToken, database, websock
currentDevice: deviceUserEntryUnsafe.currentDevice currentDevice: deviceUserEntryUnsafe.currentDevice
} }
const otherDeviceEntryUnsafe = await database.device.findOne({ const otherDeviceEntryUnsafe = await transaction.legacy.database.device.findOne({
where: { where: {
familyId: ownDeviceEntry.familyId, familyId: ownDeviceEntry.familyId,
deviceId: deviceUserEntry.currentDevice, deviceId: deviceUserEntry.currentDevice,
currentUserId: ownDeviceEntry.currentUserId currentUserId: ownDeviceEntry.currentUserId
}, },
attributes: ['deviceAuthToken'], attributes: ['deviceAuthToken'],
transaction transaction: transaction.legacy.transaction
}) })
if (!otherDeviceEntryUnsafe) { if (!otherDeviceEntryUnsafe) {
+18 -19
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -17,13 +17,13 @@
import { Conflict, InternalServerError, Unauthorized } from 'http-errors' import { Conflict, InternalServerError, Unauthorized } from 'http-errors'
import { config } from '../../config' import { config } from '../../config'
import { Database } from '../../database' import { SimpleDatabase } from '../../database/simple'
import { generateVersionId } from '../../util/token' import { generateVersionId } from '../../util/token'
import { WebsocketApi } from '../../websocket' import { WebsocketApi } from '../../websocket'
import { notifyClientsAboutChangesDelayed } from '../websocket' import { notifyClientsAboutChangesDelayed } from '../websocket'
export const setPrimaryDevice = async ({ database, websocket, deviceAuthToken, currentUserId, action }: { export const setPrimaryDevice = async ({ database, websocket, deviceAuthToken, currentUserId, action }: {
database: Database database: SimpleDatabase
websocket: WebsocketApi websocket: WebsocketApi
deviceAuthToken: string deviceAuthToken: string
currentUserId: string currentUserId: string
@@ -31,11 +31,11 @@ export const setPrimaryDevice = async ({ database, websocket, deviceAuthToken, c
// no transaction here because this is directly called from an API endpoint // no transaction here because this is directly called from an API endpoint
}): Promise<'assigned to other device' | 'requires full version' | 'success'> => { }): Promise<'assigned to other device' | 'requires full version' | 'success'> => {
return database.transaction(async (transaction): Promise<'assigned to other device' | 'requires full version' | 'success'> => { return database.transaction(async (transaction): Promise<'assigned to other device' | 'requires full version' | 'success'> => {
const deviceEntryUnsafe = await database.device.findOne({ const deviceEntryUnsafe = await transaction.legacy.database.device.findOne({
where: { where: {
deviceAuthToken deviceAuthToken
}, },
transaction, transaction: transaction.legacy.transaction,
attributes: ['familyId', 'currentUserId', 'deviceId'] attributes: ['familyId', 'currentUserId', 'deviceId']
}) })
@@ -53,12 +53,12 @@ export const setPrimaryDevice = async ({ database, websocket, deviceAuthToken, c
throw new Conflict() throw new Conflict()
} }
const userEntryUnsafe = await database.user.findOne({ const userEntryUnsafe = await transaction.legacy.database.user.findOne({
where: { where: {
familyId: deviceEntry.familyId, familyId: deviceEntry.familyId,
userId: deviceEntry.currentUserId userId: deviceEntry.currentUserId
}, },
transaction, transaction: transaction.legacy.transaction,
attributes: ['currentDevice'] attributes: ['currentDevice']
}) })
@@ -70,12 +70,12 @@ export const setPrimaryDevice = async ({ database, websocket, deviceAuthToken, c
currentDevice: userEntryUnsafe.currentDevice currentDevice: userEntryUnsafe.currentDevice
} }
const userDeviceEntriesUnsafe = await database.device.findAll({ const userDeviceEntriesUnsafe = await transaction.legacy.database.device.findAll({
where: { where: {
familyId: deviceEntry.familyId, familyId: deviceEntry.familyId,
currentUserId currentUserId
}, },
transaction, transaction: transaction.legacy.transaction,
attributes: ['deviceId'] attributes: ['deviceId']
}) })
@@ -84,11 +84,11 @@ export const setPrimaryDevice = async ({ database, websocket, deviceAuthToken, c
})) }))
if (userDeviceEntries.length >= 2) { if (userDeviceEntries.length >= 2) {
const familyEntryUnsafe = await database.family.findOne({ const familyEntryUnsafe = await transaction.legacy.database.family.findOne({
where: { where: {
familyId: deviceEntry.familyId familyId: deviceEntry.familyId
}, },
transaction, transaction: transaction.legacy.transaction,
attributes: ['hasFullVersion'] attributes: ['hasFullVersion']
}) })
@@ -112,14 +112,14 @@ export const setPrimaryDevice = async ({ database, websocket, deviceAuthToken, c
} }
// update // update
const [affectedRows] = await database.user.update({ const [affectedRows] = await transaction.legacy.database.user.update({
currentDevice: deviceEntry.deviceId currentDevice: deviceEntry.deviceId
}, { }, {
where: { where: {
familyId: deviceEntry.familyId, familyId: deviceEntry.familyId,
userId: currentUserId userId: currentUserId
}, },
transaction transaction: transaction.legacy.transaction
}) })
if (affectedRows !== 1) { if (affectedRows !== 1) {
@@ -131,14 +131,14 @@ export const setPrimaryDevice = async ({ database, websocket, deviceAuthToken, c
} }
// update // update
const [affectedRows] = await database.user.update({ const [affectedRows] = await transaction.legacy.database.user.update({
currentDevice: '' currentDevice: ''
}, { }, {
where: { where: {
familyId: deviceEntry.familyId, familyId: deviceEntry.familyId,
userId: currentUserId userId: currentUserId
}, },
transaction transaction: transaction.legacy.transaction
}) })
if (affectedRows !== 1) { if (affectedRows !== 1) {
@@ -149,10 +149,10 @@ export const setPrimaryDevice = async ({ database, websocket, deviceAuthToken, c
} }
// invalidiate user list // invalidiate user list
await database.family.update({ await transaction.legacy.database.family.update({
userListVersion: generateVersionId() userListVersion: generateVersionId()
}, { }, {
transaction, transaction: transaction.legacy.transaction,
where: { where: {
familyId: deviceEntry.familyId familyId: deviceEntry.familyId
} }
@@ -163,10 +163,9 @@ export const setPrimaryDevice = async ({ database, websocket, deviceAuthToken, c
familyId: deviceEntry.familyId, familyId: deviceEntry.familyId,
sourceDeviceId: deviceEntry.deviceId, sourceDeviceId: deviceEntry.deviceId,
websocket, websocket,
database, transaction,
generalLevel: 1, // the source device knows it already generalLevel: 1, // the source device knows it already
targetedLevels: new Map(), targetedLevels: new Map(),
transaction
}) })
return 'success' return 'success'
+11 -12
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2023 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -17,7 +17,7 @@
import { Unauthorized } from 'http-errors' import { Unauthorized } from 'http-errors'
import { DeleteAccountPayload } from '../../api/schema' import { DeleteAccountPayload } from '../../api/schema'
import { Database } from '../../database' import { SimpleDatabase } from '../../database/simple'
import { sendAccountDeletedMail } from '../../util/mail' import { sendAccountDeletedMail } from '../../util/mail'
import { WebsocketApi } from '../../websocket' import { WebsocketApi } from '../../websocket'
import { requireMailAndLocaleByAuthToken } from '../authentication' import { requireMailAndLocaleByAuthToken } from '../authentication'
@@ -25,14 +25,14 @@ import { deleteFamilies } from './delete-families'
export async function deleteAccount({ request, database, websocket }: { export async function deleteAccount({ request, database, websocket }: {
request: DeleteAccountPayload request: DeleteAccountPayload
database: Database database: SimpleDatabase
websocket: WebsocketApi websocket: WebsocketApi
}) { }) {
await database.transaction(async (transaction) => { await database.transaction(async (transaction) => {
const deviceEntryUnsafe = await database.device.findOne({ const deviceEntryUnsafe = await transaction.legacy.database.device.findOne({
where: { deviceAuthToken: request.deviceAuthToken }, where: { deviceAuthToken: request.deviceAuthToken },
attributes: ['familyId'], attributes: ['familyId'],
transaction transaction: transaction.legacy.transaction
}) })
if (!deviceEntryUnsafe) { if (!deviceEntryUnsafe) {
@@ -43,13 +43,13 @@ export async function deleteAccount({ request, database, websocket }: {
familyId: deviceEntryUnsafe.familyId familyId: deviceEntryUnsafe.familyId
} }
const userEntries = (await database.user.findAll({ const userEntries = (await transaction.legacy.database.user.findAll({
where: { where: {
familyId: deviceEntry.familyId, familyId: deviceEntry.familyId,
type: 'parent' type: 'parent'
}, },
attributes: ['mail'], attributes: ['mail'],
transaction transaction: transaction.legacy.transaction
})).map((item) => ({ mail: item.mail })) })).map((item) => ({ mail: item.mail }))
const registeredMailAddresses = new Set<string>() const registeredMailAddresses = new Set<string>()
@@ -63,7 +63,6 @@ export async function deleteAccount({ request, database, websocket }: {
for (const mailAuthToken of request.mailAuthTokens) { for (const mailAuthToken of request.mailAuthTokens) {
const info = await requireMailAndLocaleByAuthToken({ const info = await requireMailAndLocaleByAuthToken({
mailAuthToken, mailAuthToken,
database,
transaction, transaction,
invalidate: true invalidate: true
}) })
@@ -79,17 +78,17 @@ export async function deleteAccount({ request, database, websocket }: {
if (!authenticatedMailAddresses.has(mail)) throw new Unauthorized() if (!authenticatedMailAddresses.has(mail)) throw new Unauthorized()
}) })
const deviceEntries = (await database.device.findAll({ const deviceEntries = (await transaction.legacy.database.device.findAll({
where: { where: {
familyId: deviceEntry.familyId familyId: deviceEntry.familyId
}, },
transaction, transaction: transaction.legacy.transaction,
attributes: ['deviceAuthToken'] attributes: ['deviceAuthToken']
})).map((item) => ({ deviceAuthToken: item.deviceAuthToken })) })).map((item) => ({ deviceAuthToken: item.deviceAuthToken }))
await deleteFamilies({ database, transaction, familiyIds: [deviceEntry.familyId] }) await deleteFamilies({ transaction, familiyIds: [deviceEntry.familyId] })
transaction.afterCommit(() => { transaction.enqueueAfterCommit(() => {
for (const device of deviceEntries) { for (const device of deviceEntries) {
websocket.triggerSyncByDeviceAuthToken({ websocket.triggerSyncByDeviceAuthToken({
deviceAuthToken: device.deviceAuthToken, deviceAuthToken: device.deviceAuthToken,
+28 -30
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2023 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -17,138 +17,136 @@
import { difference } from 'lodash' import { difference } from 'lodash'
import * as Sequelize from 'sequelize' import * as Sequelize from 'sequelize'
import { Database, Transaction } from '../../database' import { SimpleDatabaseTransaction } from '../../database/simple'
export async function deleteFamilies ({ database, transaction, familiyIds }: { export async function deleteFamilies ({ transaction, familiyIds }: {
database: Database transaction: SimpleDatabaseTransaction
transaction: Transaction
familiyIds: Array<string> familiyIds: Array<string>
// no transaction here because this should run isolated
}) { }) {
if (familiyIds.length === 0) { if (familiyIds.length === 0) {
return return
} }
// category // category
await database.category.destroy({ await transaction.legacy.database.category.destroy({
where: { where: {
familyId: { familyId: {
[Sequelize.Op.in]: familiyIds [Sequelize.Op.in]: familiyIds
} }
}, },
transaction transaction: transaction.legacy.transaction
}) })
// categoryapp // categoryapp
await database.categoryApp.destroy({ await transaction.legacy.database.categoryApp.destroy({
where: { where: {
familyId: { familyId: {
[Sequelize.Op.in]: familiyIds [Sequelize.Op.in]: familiyIds
} }
}, },
transaction transaction: transaction.legacy.transaction
}) })
// purchase // purchase
await database.purchase.destroy({ await transaction.legacy.database.purchase.destroy({
where: { where: {
familyId: { familyId: {
[Sequelize.Op.in]: familiyIds [Sequelize.Op.in]: familiyIds
} }
}, },
transaction transaction: transaction.legacy.transaction
}) })
// timelimitrule // timelimitrule
await database.timelimitRule.destroy({ await transaction.legacy.database.timelimitRule.destroy({
where: { where: {
familyId: { familyId: {
[Sequelize.Op.in]: familiyIds [Sequelize.Op.in]: familiyIds
} }
}, },
transaction transaction: transaction.legacy.transaction
}) })
// usedtime // usedtime
await database.usedTime.destroy({ await transaction.legacy.database.usedTime.destroy({
where: { where: {
familyId: { familyId: {
[Sequelize.Op.in]: familiyIds [Sequelize.Op.in]: familiyIds
} }
}, },
transaction transaction: transaction.legacy.transaction
}) })
// session durations // session durations
await database.sessionDuration.destroy({ await transaction.legacy.database.sessionDuration.destroy({
where: { where: {
familyId: { familyId: {
[Sequelize.Op.in]: familiyIds [Sequelize.Op.in]: familiyIds
} }
}, },
transaction transaction: transaction.legacy.transaction
}) })
// user // user
await database.user.destroy({ await transaction.legacy.database.user.destroy({
where: { where: {
familyId: { familyId: {
[Sequelize.Op.in]: familiyIds [Sequelize.Op.in]: familiyIds
} }
}, },
transaction transaction: transaction.legacy.transaction
}) })
// device // device
const oldDeviceAuthTokens = (await database.device.findAll({ const oldDeviceAuthTokens = (await transaction.legacy.database.device.findAll({
where: { where: {
familyId: { familyId: {
[Sequelize.Op.in]: familiyIds [Sequelize.Op.in]: familiyIds
} }
}, },
attributes: ['deviceAuthToken'], attributes: ['deviceAuthToken'],
transaction transaction: transaction.legacy.transaction
})).map((item) => item.deviceAuthToken) })).map((item) => item.deviceAuthToken)
await database.device.destroy({ await transaction.legacy.database.device.destroy({
where: { where: {
familyId: { familyId: {
[Sequelize.Op.in]: familiyIds [Sequelize.Op.in]: familiyIds
} }
}, },
transaction transaction: transaction.legacy.transaction
}) })
// olddevice // olddevice
if (oldDeviceAuthTokens.length > 0) { if (oldDeviceAuthTokens.length > 0) {
const knownOldDeviceAuthTokens = (await database.oldDevice.findAll({ const knownOldDeviceAuthTokens = (await transaction.legacy.database.oldDevice.findAll({
where: { where: {
deviceAuthToken: { deviceAuthToken: {
[Sequelize.Op.in]: oldDeviceAuthTokens [Sequelize.Op.in]: oldDeviceAuthTokens
} }
}, },
transaction transaction: transaction.legacy.transaction
})).map((item) => item.deviceAuthToken) })).map((item) => item.deviceAuthToken)
const oldDeviceAuthTokensToAdd = difference(oldDeviceAuthTokens, knownOldDeviceAuthTokens) const oldDeviceAuthTokensToAdd = difference(oldDeviceAuthTokens, knownOldDeviceAuthTokens)
if (oldDeviceAuthTokensToAdd.length > 0) { if (oldDeviceAuthTokensToAdd.length > 0) {
await database.oldDevice.bulkCreate( await transaction.legacy.database.oldDevice.bulkCreate(
oldDeviceAuthTokensToAdd.map((item) => ({ oldDeviceAuthTokensToAdd.map((item) => ({
deviceAuthToken: item deviceAuthToken: item
})), })),
{ transaction } { transaction: transaction.legacy.transaction }
) )
} }
} }
// family // family
await database.family.destroy({ await transaction.legacy.database.family.destroy({
where: { where: {
familyId: { familyId: {
[Sequelize.Op.in]: familiyIds [Sequelize.Op.in]: familiyIds
} }
}, },
transaction transaction: transaction.legacy.transaction
}) })
} }
+8 -9
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2023 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -17,10 +17,10 @@
import { difference } from 'lodash' import { difference } from 'lodash'
import * as Sequelize from 'sequelize' import * as Sequelize from 'sequelize'
import { Database } from '../../database' import { SimpleDatabase } from '../../database/simple'
import { deleteFamilies } from './delete-families' import { deleteFamilies } from './delete-families'
export async function deleteOldFamilies (database: Database) { export async function deleteOldFamilies (database: SimpleDatabase) {
const oldFamilyIds = await findOldFamilyIds(database) const oldFamilyIds = await findOldFamilyIds(database)
if (oldFamilyIds.length > 0) { if (oldFamilyIds.length > 0) {
@@ -28,7 +28,6 @@ export async function deleteOldFamilies (database: Database) {
await database.transaction(async (transaction) => { await database.transaction(async (transaction) => {
await deleteFamilies({ await deleteFamilies({
database,
transaction, transaction,
familiyIds: familyIdsToDelete familiyIds: familyIdsToDelete
}) })
@@ -36,23 +35,23 @@ export async function deleteOldFamilies (database: Database) {
} }
} }
export async function findOldFamilyIds (database: Database) { export async function findOldFamilyIds (database: SimpleDatabase): Promise<Array<string>> {
return database.transaction(async (transaction) => { return database.transaction(async (transaction) => {
const familyIdsWithExpiredLicenses = (await database.family.findAll({ const familyIdsWithExpiredLicenses = (await transaction.legacy.database.family.findAll({
where: { where: {
fullVersionUntil: { fullVersionUntil: {
[Sequelize.Op.lt]: (Date.now() - 1000 * 60 * 60 * 24 * 90 /* 90 days */).toString(10) [Sequelize.Op.lt]: (Date.now() - 1000 * 60 * 60 * 24 * 90 /* 90 days */).toString(10)
} }
}, },
attributes: ['familyId'], attributes: ['familyId'],
transaction transaction: transaction.legacy.transaction
})).map((item) => item.familyId) })).map((item) => item.familyId)
if (familyIdsWithExpiredLicenses.length === 0) { if (familyIdsWithExpiredLicenses.length === 0) {
return [] return []
} }
const recentlyUsedFamilyIds = (await database.device.findAll({ const recentlyUsedFamilyIds = (await transaction.legacy.database.device.findAll({
where: { where: {
familyId: { familyId: {
[Sequelize.Op.in]: familyIdsWithExpiredLicenses [Sequelize.Op.in]: familyIdsWithExpiredLicenses
@@ -62,7 +61,7 @@ export async function findOldFamilyIds (database: Database) {
} }
}, },
attributes: ['familyId'], attributes: ['familyId'],
transaction transaction: transaction.legacy.transaction
})).map((item) => item.familyId) })).map((item) => item.familyId)
return difference(familyIdsWithExpiredLicenses, recentlyUsedFamilyIds) return difference(familyIdsWithExpiredLicenses, recentlyUsedFamilyIds)
+4 -2
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * 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 * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * 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, isQorLater: false,
manipulationFlags: 0, manipulationFlags: 0,
publicKey: null, publicKey: null,
nextKeyReplySequenceNumber: '1' nextKeyReplySequenceNumber: '1',
platformType: null,
platformLevel: 0
}) })
+18 -20
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -16,24 +16,23 @@
*/ */
import { Conflict } from 'http-errors' import { Conflict } from 'http-errors'
import { Database, Transaction } from '../../database' import { SimpleDatabaseTransaction } from '../../database/simple'
import { generateVersionId } from '../../util/token' import { generateVersionId } from '../../util/token'
import { WebsocketApi } from '../../websocket' import { WebsocketApi } from '../../websocket'
import { notifyClientsAboutChangesDelayed } from '../websocket' import { notifyClientsAboutChangesDelayed } from '../websocket'
export async function removeDevice ({ database, familyId, deviceId, websocket, transaction }: { export async function removeDevice ({ familyId, deviceId, websocket, transaction }: {
database: Database transaction: SimpleDatabaseTransaction
familyId: string familyId: string
deviceId: string deviceId: string
websocket: WebsocketApi websocket: WebsocketApi
transaction: Transaction
}) { }) {
const deviceEntry = await database.device.findOne({ const deviceEntry = await transaction.legacy.database.device.findOne({
where: { where: {
familyId, familyId,
deviceId deviceId
}, },
transaction transaction: transaction.legacy.transaction
}) })
if (!deviceEntry) { if (!deviceEntry) {
@@ -41,37 +40,37 @@ export async function removeDevice ({ database, familyId, deviceId, websocket, t
} }
// remove as current device // remove as current device
await database.user.update({ await transaction.legacy.database.user.update({
currentDevice: '' currentDevice: ''
}, { }, {
where: { where: {
familyId, familyId,
currentDevice: deviceId currentDevice: deviceId
}, },
transaction transaction: transaction.legacy.transaction
}) })
// add to old devices if it is not yet there (it could be there if it reported a uninstall) // add to old devices if it is not yet there (it could be there if it reported a uninstall)
const oldOldDeviceEntry = await database.oldDevice.findOne({ const oldOldDeviceEntry = await transaction.legacy.database.oldDevice.findOne({
where: { where: {
deviceAuthToken: deviceEntry.deviceAuthToken deviceAuthToken: deviceEntry.deviceAuthToken
}, },
transaction transaction: transaction.legacy.transaction
}) })
if (!oldOldDeviceEntry) { if (!oldOldDeviceEntry) {
await database.oldDevice.create({ await transaction.legacy.database.oldDevice.create({
deviceAuthToken: deviceEntry.deviceAuthToken deviceAuthToken: deviceEntry.deviceAuthToken
}, { }, {
transaction transaction: transaction.legacy.transaction
}) })
} }
// remove from the device list // remove from the device list
await deviceEntry.destroy({ transaction }) await deviceEntry.destroy({ transaction: transaction.legacy.transaction })
// invalidiate the caches // invalidiate the caches
await database.family.update({ await transaction.legacy.database.family.update({
deviceListVersion: generateVersionId(), deviceListVersion: generateVersionId(),
// the device could have become unassigned during this // the device could have become unassigned during this
userListVersion: generateVersionId() userListVersion: generateVersionId()
@@ -79,20 +78,19 @@ export async function removeDevice ({ database, familyId, deviceId, websocket, t
where: { where: {
familyId: deviceEntry.familyId familyId: deviceEntry.familyId
}, },
transaction transaction: transaction.legacy.transaction
}) })
await notifyClientsAboutChangesDelayed({ await notifyClientsAboutChangesDelayed({
database, transaction,
websocket, websocket,
familyId, familyId,
sourceDeviceId: null, sourceDeviceId: null,
generalLevel: 1, generalLevel: 1,
targetedLevels: new Map(), targetedLevels: new Map()
transaction
}) })
transaction.afterCommit(() => { transaction.enqueueAfterCommit(() => {
websocket.triggerSyncByDeviceAuthToken({ websocket.triggerSyncByDeviceAuthToken({
deviceAuthToken: deviceEntry.deviceAuthToken, deviceAuthToken: deviceEntry.deviceAuthToken,
isImportant: true isImportant: true
+14 -16
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -16,24 +16,24 @@
*/ */
import { Unauthorized } from 'http-errors' import { Unauthorized } from 'http-errors'
import { Database } from '../../database' import { SimpleDatabase } from '../../database/simple'
import { generateAuthToken, generateVersionId } from '../../util/token' import { generateAuthToken, generateVersionId } from '../../util/token'
import { WebsocketApi } from '../../websocket' import { WebsocketApi } from '../../websocket'
import { sendUninstallWarnings } from '../warningmail/uninstall' import { sendUninstallWarnings } from '../warningmail/uninstall'
import { notifyClientsAboutChangesDelayed } from '../websocket' import { notifyClientsAboutChangesDelayed } from '../websocket'
export async function reportDeviceRemoved ({ database, deviceAuthToken, websocket }: { export async function reportDeviceRemoved ({ database, deviceAuthToken, websocket }: {
database: Database database: SimpleDatabase
deviceAuthToken: string deviceAuthToken: string
websocket: WebsocketApi websocket: WebsocketApi
// no transaction here because this is directly called from an API endpoint // no transaction here because this is directly called from an API endpoint
}) { }) {
await database.transaction(async (transaction) => { await database.transaction(async (transaction) => {
const deviceEntry = await database.device.findOne({ const deviceEntry = await transaction.legacy.database.device.findOne({
where: { where: {
deviceAuthToken deviceAuthToken
}, },
transaction transaction: transaction.legacy.transaction
}) })
if (deviceEntry) { if (deviceEntry) {
@@ -41,47 +41,45 @@ export async function reportDeviceRemoved ({ database, deviceAuthToken, websocke
deviceEntry.didDeviceReportUninstall = true deviceEntry.didDeviceReportUninstall = true
deviceEntry.deviceAuthToken = generateAuthToken() // invalidiate the token deviceEntry.deviceAuthToken = generateAuthToken() // invalidiate the token
await deviceEntry.save({ transaction }) await deviceEntry.save({ transaction: transaction.legacy.transaction })
// invalidiate device list // invalidiate device list
await database.family.update({ await transaction.legacy.database.family.update({
deviceListVersion: generateVersionId() deviceListVersion: generateVersionId()
}, { }, {
where: { where: {
familyId: deviceEntry.familyId familyId: deviceEntry.familyId
}, },
transaction transaction: transaction.legacy.transaction
}) })
// add to old devices // add to old devices
await database.oldDevice.create({ await transaction.legacy.database.oldDevice.create({
deviceAuthToken: currentAuthToken deviceAuthToken: currentAuthToken
}, { }, {
transaction transaction: transaction.legacy.transaction
}) })
await notifyClientsAboutChangesDelayed({ await notifyClientsAboutChangesDelayed({
database, transaction,
websocket, websocket,
familyId: deviceEntry.familyId, familyId: deviceEntry.familyId,
sourceDeviceId: null, sourceDeviceId: null,
generalLevel: 1, generalLevel: 1,
targetedLevels: new Map(), targetedLevels: new Map(),
transaction
}) })
await sendUninstallWarnings({ await sendUninstallWarnings({
database, transaction,
familyId: deviceEntry.familyId, familyId: deviceEntry.familyId,
deviceName: deviceEntry.name, deviceName: deviceEntry.name,
transaction
}) })
} else { } else {
const oldDeviceEntry = await database.oldDevice.findOne({ const oldDeviceEntry = await transaction.legacy.database.oldDevice.findOne({
where: { where: {
deviceAuthToken deviceAuthToken
}, },
transaction transaction: transaction.legacy.transaction
}) })
if (!oldDeviceEntry) { if (!oldDeviceEntry) {
+4 -7
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -15,17 +15,15 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import * as Sequelize from 'sequelize'
import { createDecipheriv } from 'crypto' import { createDecipheriv } from 'crypto'
import { Database } from '../../database' import { SimpleDatabaseTransaction } from '../../database/simple'
import { isVersionId } from '../../util/token' import { isVersionId } from '../../util/token'
import { getSharedSecret, SharedSecretException } from './shared-secret' import { getSharedSecret, SharedSecretException } from './shared-secret'
export async function decrypt({ export async function decrypt({
database, transaction, familyId, deviceId, encryptedData, authData transaction, familyId, deviceId, encryptedData, authData
}: { }: {
database: Database transaction: SimpleDatabaseTransaction
transaction: Sequelize.Transaction
familyId: string familyId: string
deviceId: string deviceId: string
encryptedData: string encryptedData: string
@@ -46,7 +44,6 @@ export async function decrypt({
const sharedSecret = await (async () => { const sharedSecret = await (async () => {
try { try {
return getSharedSecret({ return getSharedSecret({
database,
transaction, transaction,
familyId, familyId,
deviceId, deviceId,
+1 -2
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -31,7 +31,6 @@ export async function decryptParentPassword({ cache, password } : {
try { try {
const secondHash = (await decrypt({ const secondHash = (await decrypt({
database: cache.database,
transaction: cache.transaction, transaction: cache.transaction,
familyId: cache.familyId, familyId: cache.familyId,
deviceId: cache.deviceId, deviceId: cache.deviceId,
+7 -9
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -15,17 +15,15 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import * as Sequelize from 'sequelize'
import { createPrivateKey, createPublicKey, diffieHellman } from 'crypto' import { createPrivateKey, createPublicKey, diffieHellman } from 'crypto'
import { Database } from '../../database' import { SimpleDatabaseTransaction } from '../../database/simple'
import { calculateExpireTime } from '../../database/devicedhkey' import { calculateExpireTime } from '../../database/devicedhkey'
import { isVersionId } from '../../util/token' import { isVersionId } from '../../util/token'
export async function getSharedSecret({ export async function getSharedSecret({
database, transaction, familyId, deviceId, keyId, otherPublicKey transaction, familyId, deviceId, keyId, otherPublicKey
}: { }: {
database: Database transaction: SimpleDatabaseTransaction
transaction: Sequelize.Transaction
familyId: string familyId: string
deviceId: string deviceId: string
keyId: string keyId: string
@@ -33,20 +31,20 @@ export async function getSharedSecret({
}) { }) {
if (!isVersionId(keyId)) throw new KeyNotFoundException('invalid key id') if (!isVersionId(keyId)) throw new KeyNotFoundException('invalid key id')
const databaseKeyEntry = await database.deviceDhKey.findOne({ const databaseKeyEntry = await transaction.legacy.database.deviceDhKey.findOne({
where: { where: {
familyId, familyId,
deviceId, deviceId,
version: keyId version: keyId
}, },
transaction transaction: transaction.legacy.transaction
}) })
if (!databaseKeyEntry) throw new KeyNotFoundException('private key not found') if (!databaseKeyEntry) throw new KeyNotFoundException('private key not found')
if (databaseKeyEntry.expireAt === null) { if (databaseKeyEntry.expireAt === null) {
databaseKeyEntry.expireAt = calculateExpireTime(BigInt(Date.now())).toString(10) databaseKeyEntry.expireAt = calculateExpireTime(BigInt(Date.now())).toString(10)
await databaseKeyEntry.save({ transaction }) await databaseKeyEntry.save({ transaction: transaction.legacy.transaction })
} else { } else {
if (BigInt(databaseKeyEntry.expireAt) < BigInt(Date.now())) throw new KeyExpiredException() if (BigInt(databaseKeyEntry.expireAt) < BigInt(Date.now())) throw new KeyExpiredException()
} }
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2020 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -15,31 +15,30 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import { Database, Transaction } from '../../database' import { SimpleDatabaseTransaction } from '../../database/simple'
import { randomWords } from '../../util/random-words' import { randomWords } from '../../util/random-words'
import { generateIdWithinFamily } from '../../util/token' import { generateIdWithinFamily } from '../../util/token'
export const createAddDeviceToken = async ({ familyId, database, transaction }: { export const createAddDeviceToken = async ({ familyId, transaction }: {
familyId: string familyId: string
database: Database transaction: SimpleDatabaseTransaction
transaction: Transaction
}) => { }) => {
const token = randomWords(5) const token = randomWords(5)
const deviceId = generateIdWithinFamily() const deviceId = generateIdWithinFamily()
await database.addDeviceToken.destroy({ await transaction.legacy.database.addDeviceToken.destroy({
where: { where: {
familyId familyId
}, },
transaction transaction: transaction.legacy.transaction
}) })
await database.addDeviceToken.create({ await transaction.legacy.database.addDeviceToken.create({
familyId, familyId,
token: token.toLowerCase(), token: token.toLowerCase(),
deviceId, deviceId,
createdAt: Date.now().toString() createdAt: Date.now().toString()
}, { transaction }) }, { transaction: transaction.legacy.transaction })
return { token, deviceId } return { token, deviceId }
} }
+15 -15
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -18,7 +18,7 @@
import { Conflict } from 'http-errors' import { Conflict } from 'http-errors'
import { generateServerDataStatus } from '../sync/get-server-data-status' import { generateServerDataStatus } from '../sync/get-server-data-status'
import { NewDeviceInfo, PlaintextParentPassword, assertPlaintextParentPasswordValid } from '../../api/schema' import { NewDeviceInfo, PlaintextParentPassword, assertPlaintextParentPasswordValid } from '../../api/schema'
import { Database } from '../../database' import { SimpleDatabase } from '../../database/simple'
import { maxMailNotificationFlags } from '../../database/user' import { maxMailNotificationFlags } from '../../database/user'
import { EventHandler } from '../../monitoring/eventhandler' import { EventHandler } from '../../monitoring/eventhandler'
import { ServerDataStatus } from '../../object/serverdatastatus' import { ServerDataStatus } from '../../object/serverdatastatus'
@@ -33,7 +33,7 @@ export async function createFamily ({
database, eventHandler, mailAuthToken, firstParentDevice, database, eventHandler, mailAuthToken, firstParentDevice,
password, timeZone, parentName, deviceName, clientLevel password, timeZone, parentName, deviceName, clientLevel
}: { }: {
database: Database database: SimpleDatabase
eventHandler: EventHandler eventHandler: EventHandler
mailAuthToken: string mailAuthToken: string
firstParentDevice: NewDeviceInfo firstParentDevice: NewDeviceInfo
@@ -52,14 +52,14 @@ export async function createFamily ({
return database.transaction(async (transaction) => { return database.transaction(async (transaction) => {
const now = Date.now().toString(10) const now = Date.now().toString(10)
const mailInfo = await requireMailAndLocaleByAuthToken({ database, mailAuthToken, transaction, invalidate: true }) const mailInfo = await requireMailAndLocaleByAuthToken({ transaction, mailAuthToken, invalidate: true })
// ensure that no family was created for this mail yet // ensure that no family was created for this mail yet
const existingUserEntry = await database.user.findOne({ const existingUserEntry = await transaction.legacy.database.user.findOne({
where: { where: {
mail: mailInfo.mail mail: mailInfo.mail
}, },
transaction transaction: transaction.legacy.transaction
}) })
if (existingUserEntry) { if (existingUserEntry) {
@@ -72,7 +72,7 @@ export async function createFamily ({
const deviceAuthToken = generateAuthToken() const deviceAuthToken = generateAuthToken()
// create family // create family
await database.family.create({ await transaction.legacy.database.family.create({
familyId, familyId,
name: '', name: '',
createdAt: now, createdAt: now,
@@ -82,11 +82,12 @@ export async function createFamily ({
fullVersionUntil: (Date.now() + 1000 * 60 * 60 * 24 * 14).toString(10), fullVersionUntil: (Date.now() + 1000 * 60 * 60 * 24 * 14).toString(10),
hasFullVersion: true, hasFullVersion: true,
nextServerKeyRequestSeq: '1', nextServerKeyRequestSeq: '1',
u2fKeysVersion: generateVersionId() u2fKeysVersion: generateVersionId(),
}, { transaction }) fullVersionDebts: '0'
}, { transaction: transaction.legacy.transaction })
// create parent user // create parent user
await database.user.create({ await transaction.legacy.database.user.create({
familyId, familyId,
userId, userId,
name: parentName, name: parentName,
@@ -103,10 +104,10 @@ export async function createFamily ({
mailNotificationFlags: maxMailNotificationFlags, mailNotificationFlags: maxMailNotificationFlags,
blockedTimes: '', blockedTimes: '',
flags: '0' flags: '0'
}, { transaction }) }, { transaction: transaction.legacy.transaction })
// add parent device // add parent device
await database.device.create(prepareDeviceEntry({ await transaction.legacy.database.device.create(prepareDeviceEntry({
familyId, familyId,
deviceId, deviceId,
deviceName, deviceName,
@@ -114,14 +115,13 @@ export async function createFamily ({
userId, userId,
deviceAuthToken, deviceAuthToken,
isUserKeptSignedIn: true isUserKeptSignedIn: true
}), { transaction }) }), { transaction: transaction.legacy.transaction })
const data = await generateServerDataStatus({ const data = await generateServerDataStatus({
database, transaction,
clientStatus: createEmptyClientDataStatus({ clientLevel }), clientStatus: createEmptyClientDataStatus({ clientLevel }),
familyId, familyId,
deviceId, deviceId,
transaction,
eventHandler eventHandler
}) })
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2021 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -15,22 +15,22 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import { Database, Transaction } from '../../database' import { SimpleDatabaseTransaction } from '../../database/simple'
import { StaticMessageException } from '../../exception' import { StaticMessageException } from '../../exception'
import { requireMailAndLocaleByAuthToken } from '../authentication' import { requireMailAndLocaleByAuthToken } from '../authentication'
const getStatusByMailAddress = async ({ const getStatusByMailAddress = async ({
mail, database, transaction mail, transaction
}: { mail: string, database: Database, transaction: Transaction }) => { }: { mail: string, transaction: SimpleDatabaseTransaction }) => {
if (!mail) { if (!mail) {
throw new StaticMessageException({ staticMessage: 'getStatusByMailAddress: no mail address provided' }) throw new StaticMessageException({ staticMessage: 'getStatusByMailAddress: no mail address provided' })
} }
const entry = await database.user.findOne({ const entry = await transaction.legacy.database.user.findOne({
where: { where: {
mail mail
}, },
transaction transaction: transaction.legacy.transaction
}) })
if (entry) { if (entry) {
@@ -41,12 +41,12 @@ const getStatusByMailAddress = async ({
} }
export const getStatusByMailToken = async ({ export const getStatusByMailToken = async ({
mailAuthToken, database, transaction mailAuthToken, transaction
}: { mailAuthToken: string, database: Database, transaction: Transaction }) => { }: { mailAuthToken: string, transaction: SimpleDatabaseTransaction }) => {
const mailInfo = await requireMailAndLocaleByAuthToken({ mailAuthToken, database, transaction, invalidate: false }) const mailInfo = await requireMailAndLocaleByAuthToken({ mailAuthToken, transaction, invalidate: false })
const mail = mailInfo.mail const mail = mailInfo.mail
const status = await getStatusByMailAddress({ mail, database, transaction }) const status = await getStatusByMailAddress({ mail, transaction })
return { mail, status } return { mail, status }
} }
+15 -16
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -16,7 +16,7 @@
*/ */
import { Conflict, Unauthorized } from 'http-errors' import { Conflict, Unauthorized } from 'http-errors'
import { Database } from '../../database' import { SimpleDatabase } from '../../database/simple'
import { generateVersionId } from '../../util/token' import { generateVersionId } from '../../util/token'
import { WebsocketApi } from '../../websocket' import { WebsocketApi } from '../../websocket'
import { requireMailAndLocaleByAuthToken } from '../authentication' import { requireMailAndLocaleByAuthToken } from '../authentication'
@@ -27,16 +27,16 @@ export const linkMailAddress = async ({ mailAuthToken, deviceAuthToken, parentUs
deviceAuthToken: string deviceAuthToken: string
parentUserId: string parentUserId: string
parentPasswordSecondHash: string parentPasswordSecondHash: string
database: Database database: SimpleDatabase
websocket: WebsocketApi websocket: WebsocketApi
// no transaction here because this is directly called from an API endpoint // no transaction here because this is directly called from an API endpoint
}) => { }) => {
await database.transaction(async (transaction) => { await database.transaction(async (transaction) => {
const deviceEntry = await database.device.findOne({ const deviceEntry = await transaction.legacy.database.device.findOne({
where: { where: {
deviceAuthToken deviceAuthToken
}, },
transaction transaction: transaction.legacy.transaction
}) })
if (!deviceEntry) { if (!deviceEntry) {
@@ -45,26 +45,26 @@ export const linkMailAddress = async ({ mailAuthToken, deviceAuthToken, parentUs
const familyId = deviceEntry.familyId const familyId = deviceEntry.familyId
const mailInfo = await requireMailAndLocaleByAuthToken({ mailAuthToken, database, transaction, invalidate: true }) const mailInfo = await requireMailAndLocaleByAuthToken({ mailAuthToken, transaction, invalidate: true })
const exisitingUser = await database.user.findOne({ const exisitingUser = await transaction.legacy.database.user.findOne({
where: { where: {
mail: mailInfo.mail mail: mailInfo.mail
}, },
transaction transaction: transaction.legacy.transaction
}) })
if (exisitingUser) { if (exisitingUser) {
throw new Conflict() throw new Conflict()
} }
const parentEntry = await database.user.findOne({ const parentEntry = await transaction.legacy.database.user.findOne({
where: { where: {
type: 'parent', type: 'parent',
familyId, familyId,
userId: parentUserId userId: parentUserId
}, },
transaction transaction: transaction.legacy.transaction
}) })
if (!parentEntry) { if (!parentEntry) {
@@ -85,16 +85,16 @@ export const linkMailAddress = async ({ mailAuthToken, deviceAuthToken, parentUs
parentEntry.mail = mailInfo.mail parentEntry.mail = mailInfo.mail
await parentEntry.save({ transaction }) await parentEntry.save({ transaction: transaction.legacy.transaction })
// invalidiate client caches // invalidiate client caches
await database.family.update({ await transaction.legacy.database.family.update({
userListVersion: generateVersionId() userListVersion: generateVersionId()
}, { }, {
where: { where: {
familyId familyId
}, },
transaction transaction: transaction.legacy.transaction
}) })
// notify // notify
@@ -103,9 +103,8 @@ export const linkMailAddress = async ({ mailAuthToken, deviceAuthToken, parentUs
sourceDeviceId: null, sourceDeviceId: null,
generalLevel: 1, generalLevel: 1,
targetedLevels: new Map(), targetedLevels: new Map(),
database, transaction,
websocket, websocket
transaction
}) })
}) })
} }
+12 -13
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -17,7 +17,7 @@
import { Conflict } from 'http-errors' import { Conflict } from 'http-errors'
import { PlaintextParentPassword, assertPlaintextParentPasswordValid } from '../../api/schema' import { PlaintextParentPassword, assertPlaintextParentPasswordValid } from '../../api/schema'
import { Database } from '../../database' import { SimpleDatabase } from '../../database/simple'
import { sendPasswordRecoveryUsedMail } from '../../util/mail' import { sendPasswordRecoveryUsedMail } from '../../util/mail'
import { generateVersionId } from '../../util/token' import { generateVersionId } from '../../util/token'
import { WebsocketApi } from '../../websocket' import { WebsocketApi } from '../../websocket'
@@ -25,7 +25,7 @@ import { requireMailAndLocaleByAuthToken } from '../authentication'
import { notifyClientsAboutChangesDelayed } from '../websocket' import { notifyClientsAboutChangesDelayed } from '../websocket'
export const recoverParentPassword = async ({ database, websocket, password, mailAuthToken }: { export const recoverParentPassword = async ({ database, websocket, password, mailAuthToken }: {
database: Database database: SimpleDatabase
websocket: WebsocketApi websocket: WebsocketApi
password: PlaintextParentPassword password: PlaintextParentPassword
mailAuthToken: string mailAuthToken: string
@@ -34,14 +34,14 @@ export const recoverParentPassword = async ({ database, websocket, password, mai
assertPlaintextParentPasswordValid(password) assertPlaintextParentPasswordValid(password)
await database.transaction(async (transaction) => { await database.transaction(async (transaction) => {
const mailInfo = await requireMailAndLocaleByAuthToken({ mailAuthToken, database, transaction, invalidate: true }) const mailInfo = await requireMailAndLocaleByAuthToken({ mailAuthToken, transaction, invalidate: true })
// update the user entry // update the user entry
const userEntry = await database.user.findOne({ const userEntry = await transaction.legacy.database.user.findOne({
where: { where: {
mail: mailInfo.mail mail: mailInfo.mail
}, },
transaction transaction: transaction.legacy.transaction
}) })
if (!userEntry) { if (!userEntry) {
@@ -52,29 +52,28 @@ export const recoverParentPassword = async ({ database, websocket, password, mai
userEntry.secondPasswordHash = password.secondHash userEntry.secondPasswordHash = password.secondHash
userEntry.secondPasswordSalt = password.secondSalt userEntry.secondPasswordSalt = password.secondSalt
await userEntry.save({ transaction }) await userEntry.save({ transaction: transaction.legacy.transaction })
// invalidate the user list // invalidate the user list
await database.family.update({ await transaction.legacy.database.family.update({
userListVersion: generateVersionId() userListVersion: generateVersionId()
}, { }, {
where: { where: {
familyId: userEntry.familyId familyId: userEntry.familyId
}, },
transaction transaction: transaction.legacy.transaction
}) })
await notifyClientsAboutChangesDelayed({ await notifyClientsAboutChangesDelayed({
database, transaction,
familyId: userEntry.familyId, familyId: userEntry.familyId,
websocket, websocket,
generalLevel: 2, generalLevel: 2,
targetedLevels: new Map(), targetedLevels: new Map(),
sourceDeviceId: null, sourceDeviceId: null
transaction
}) })
transaction.afterCommit(async () => { transaction.enqueueAfterCommit(async () => {
await sendPasswordRecoveryUsedMail({ await sendPasswordRecoveryUsedMail({
receiver: mailInfo.mail, receiver: mailInfo.mail,
locale: mailInfo.locale locale: mailInfo.locale
+14 -16
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -17,7 +17,7 @@
import { Conflict } from 'http-errors' import { Conflict } from 'http-errors'
import { NewDeviceInfo } from '../../api/schema' import { NewDeviceInfo } from '../../api/schema'
import { Database } from '../../database' import { SimpleDatabase } from '../../database/simple'
import { sendDeviceLinkedMail } from '../../util/mail' import { sendDeviceLinkedMail } from '../../util/mail'
import { generateAuthToken, generateIdWithinFamily, generateVersionId } from '../../util/token' import { generateAuthToken, generateIdWithinFamily, generateVersionId } from '../../util/token'
import { WebsocketApi } from '../../websocket' import { WebsocketApi } from '../../websocket'
@@ -30,7 +30,7 @@ import { ServerDataStatus } from '../../object/serverdatastatus'
import { createEmptyClientDataStatus } from '../../object/clientdatastatus' import { createEmptyClientDataStatus } from '../../object/clientdatastatus'
export const signInIntoFamily = async ({ database, eventHandler, mailAuthToken, newDeviceInfo, deviceName, websocket, clientLevel }: { export const signInIntoFamily = async ({ database, eventHandler, mailAuthToken, newDeviceInfo, deviceName, websocket, clientLevel }: {
database: Database database: SimpleDatabase
eventHandler: EventHandler eventHandler: EventHandler
mailAuthToken: string mailAuthToken: string
newDeviceInfo: NewDeviceInfo newDeviceInfo: NewDeviceInfo
@@ -40,14 +40,14 @@ export const signInIntoFamily = async ({ database, eventHandler, mailAuthToken,
// no transaction here because this is directly called from an API endpoint // no transaction here because this is directly called from an API endpoint
}): Promise<{ deviceId: string; deviceAuthToken: string; data: ServerDataStatus }> => { }): Promise<{ deviceId: string; deviceAuthToken: string; data: ServerDataStatus }> => {
return database.transaction(async (transaction) => { return database.transaction(async (transaction) => {
const mailInfo = await requireMailAndLocaleByAuthToken({ database, mailAuthToken, transaction, invalidate: true }) const mailInfo = await requireMailAndLocaleByAuthToken({ mailAuthToken, transaction, invalidate: true })
const userEntryUnsafe = await database.user.findOne({ const userEntryUnsafe = await transaction.legacy.database.user.findOne({
where: { where: {
mail: mailInfo.mail mail: mailInfo.mail
}, },
attributes: ['familyId', 'userId'], attributes: ['familyId', 'userId'],
transaction transaction: transaction.legacy.transaction
}) })
if (!userEntryUnsafe) { if (!userEntryUnsafe) {
@@ -62,7 +62,7 @@ export const signInIntoFamily = async ({ database, eventHandler, mailAuthToken,
const deviceAuthToken = generateAuthToken() const deviceAuthToken = generateAuthToken()
const deviceId = generateIdWithinFamily() const deviceId = generateIdWithinFamily()
await database.device.create(prepareDeviceEntry({ await transaction.legacy.database.device.create(prepareDeviceEntry({
familyId: userEntry.familyId, familyId: userEntry.familyId,
deviceId, deviceId,
userId: userEntry.userId, userId: userEntry.userId,
@@ -70,29 +70,28 @@ export const signInIntoFamily = async ({ database, eventHandler, mailAuthToken,
deviceAuthToken, deviceAuthToken,
newDeviceInfo, newDeviceInfo,
isUserKeptSignedIn: true isUserKeptSignedIn: true
}), { transaction }) }), { transaction: transaction.legacy.transaction })
// notify about changes // notify about changes
await database.family.update({ await transaction.legacy.database.family.update({
deviceListVersion: generateVersionId() deviceListVersion: generateVersionId()
}, { }, {
where: { where: {
familyId: userEntry.familyId familyId: userEntry.familyId
}, },
transaction transaction: transaction.legacy.transaction
}) })
await notifyClientsAboutChangesDelayed({ await notifyClientsAboutChangesDelayed({
familyId: userEntry.familyId, familyId: userEntry.familyId,
websocket, websocket,
database, transaction,
generalLevel: 1, generalLevel: 1,
targetedLevels: new Map(), targetedLevels: new Map(),
sourceDeviceId: deviceId, sourceDeviceId: deviceId
transaction
}) })
transaction.afterCommit(async () => { transaction.enqueueAfterCommit(async () => {
await sendDeviceLinkedMail({ await sendDeviceLinkedMail({
receiver: mailInfo.mail, receiver: mailInfo.mail,
locale: mailInfo.locale, locale: mailInfo.locale,
@@ -101,11 +100,10 @@ export const signInIntoFamily = async ({ database, eventHandler, mailAuthToken,
}) })
const data = await generateServerDataStatus({ const data = await generateServerDataStatus({
database, transaction,
clientStatus: createEmptyClientDataStatus({ clientLevel }), clientStatus: createEmptyClientDataStatus({ clientLevel }),
familyId: userEntry.familyId, familyId: userEntry.familyId,
deviceId, deviceId,
transaction,
eventHandler eventHandler
}) })
+48 -18
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -16,40 +16,40 @@
*/ */
import { Conflict } from 'http-errors' import { Conflict } from 'http-errors'
import { Database, Transaction } from '../../database' import { SimpleDatabaseTransaction } from '../../database/simple'
import { notifyClientsAboutChangesDelayed } from '../../function/websocket' import { notifyClientsAboutChangesDelayed } from '../../function/websocket'
import { WebsocketApi } from '../../websocket' import { WebsocketApi } from '../../websocket'
const day = 1000 * 60 * 60 * 24 const day = 1000 * 60 * 60 * 24
const week = day * 7
const month = day * 31 const month = day * 31
const year = day * 366 const year = day * 366
export const addPurchase = async ({ database, familyId, type, service, transactionId, websocket, transaction }: { export const addPurchase = async ({ familyId, type, service, transactionId, websocket, transaction }: {
database: Database transaction: SimpleDatabaseTransaction
familyId: string familyId: string
type: 'month' | 'year' type: 'month' | 'year' | 'unpaid14'
service: 'googleplay' | 'directpurchase' service: 'googleplay' | 'directpurchase'
transactionId: string transactionId: string
websocket: WebsocketApi websocket: WebsocketApi
transaction: Transaction
}) => { }) => {
const oldPurchaseEntry = await database.purchase.findOne({ const oldPurchaseEntry = await transaction.legacy.database.purchase.findOne({
where: { where: {
service, service,
transactionId transactionId
}, },
transaction transaction: transaction.legacy.transaction
}) })
if (oldPurchaseEntry) { if (oldPurchaseEntry) {
return return
} }
const familyEntry = await database.family.findOne({ const familyEntry = await transaction.legacy.database.family.findOne({
where: { where: {
familyId familyId
}, },
transaction transaction: transaction.legacy.transaction
}) })
if (!familyEntry) { if (!familyEntry) {
@@ -57,33 +57,63 @@ export const addPurchase = async ({ database, familyId, type, service, transacti
} }
const previousFullVersionEndTime = familyEntry.fullVersionUntil const previousFullVersionEndTime = familyEntry.fullVersionUntil
const previousFullVersionDebts = parseInt(familyEntry.fullVersionDebts, 10)
const newFullVersionUntil = Math.max(parseInt(familyEntry.fullVersionUntil, 10), Date.now()) + (type === 'year' ? year : month) if (type === 'month' || type === 'year') {
const typeDuration = type === 'year' ? year : month
if (typeDuration > previousFullVersionDebts) {
const newFullVersionUntil = Math.max(parseInt(familyEntry.fullVersionUntil, 10), Date.now()) + typeDuration - previousFullVersionDebts
familyEntry.fullVersionUntil = newFullVersionUntil.toString(10) familyEntry.fullVersionUntil = newFullVersionUntil.toString(10)
familyEntry.fullVersionDebts = '0'
familyEntry.hasFullVersion = true familyEntry.hasFullVersion = true
} else {
familyEntry.fullVersionDebts = (previousFullVersionDebts - typeDuration).toString(10)
}
} else if (type === 'unpaid14') {
const debtsAdd = 2 * week
const debtsMax = 3 * week
await familyEntry.save({ transaction }) const newDebts = Math.min(debtsMax, previousFullVersionDebts + debtsAdd)
await database.purchase.create({ if (newDebts <= previousFullVersionDebts) {
// do not save anything
return
}
const durationToAdd = newDebts - previousFullVersionDebts
const newFullVersionUntil = Math.max(parseInt(familyEntry.fullVersionUntil, 10), Date.now()) + durationToAdd
familyEntry.fullVersionUntil = newFullVersionUntil.toString(10)
familyEntry.fullVersionDebts = newDebts.toString(10)
familyEntry.hasFullVersion = true
} else {
throw new Error()
}
await familyEntry.save({ transaction: transaction.legacy.transaction })
await transaction.legacy.database.purchase.create({
familyId, familyId,
service, service,
transactionId, transactionId,
type, type,
loggedAt: Date.now().toString(10), loggedAt: Date.now().toString(10),
previousFullVersionEndTime, previousFullVersionEndTime,
newFullVersionEndTime: newFullVersionUntil.toString(10) newFullVersionEndTime: familyEntry.fullVersionUntil
}, { }, {
transaction transaction: transaction.legacy.transaction
}) })
await notifyClientsAboutChangesDelayed({ await notifyClientsAboutChangesDelayed({
familyId, familyId,
sourceDeviceId: null, sourceDeviceId: null,
database, transaction,
websocket, websocket,
generalLevel: 2, generalLevel: 2,
targetedLevels: new Map(), targetedLevels: new Map()
transaction
}) })
} }
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -15,6 +15,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
export const canDoNextPurchase = ({ fullVersionUntil }: {fullVersionUntil: number}) => ( export const canDoNextPurchase = ({ fullVersionUntil, fullVersionDebts }: {
fullVersionUntil < (Date.now() + 1000 * 60 * 60 * 24 * 31) // 31 days fullVersionUntil: number
fullVersionDebts: number
}) => (
(fullVersionUntil - fullVersionDebts) < (Date.now() + 1000 * 60 * 60 * 24 * 31) // 31 days
) )
+11 -11
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2020 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -16,19 +16,18 @@
*/ */
import { InternalServerError, Unauthorized } from 'http-errors' import { InternalServerError, Unauthorized } from 'http-errors'
import { Database, Transaction } from '../../database' import { SimpleDatabaseTransaction } from '../../database/simple'
export const requireFamilyEntry = async ({ database, deviceAuthToken, transaction }: { export const requireFamilyEntry = async ({ transaction, deviceAuthToken }: {
database: Database transaction: SimpleDatabaseTransaction
deviceAuthToken: string deviceAuthToken: string
transaction: Transaction
}) => { }) => {
const deviceEntryUnsafe = await database.device.findOne({ const deviceEntryUnsafe = await transaction.legacy.database.device.findOne({
where: { where: {
deviceAuthToken deviceAuthToken
}, },
attributes: ['familyId'], attributes: ['familyId'],
transaction transaction: transaction.legacy.transaction
}) })
if (!deviceEntryUnsafe) { if (!deviceEntryUnsafe) {
@@ -39,12 +38,12 @@ export const requireFamilyEntry = async ({ database, deviceAuthToken, transactio
familyId: deviceEntryUnsafe.familyId familyId: deviceEntryUnsafe.familyId
} }
const familyEntryUnsafe = await database.family.findOne({ const familyEntryUnsafe = await transaction.legacy.database.family.findOne({
where: { where: {
familyId: deviceEntry.familyId familyId: deviceEntry.familyId
}, },
attributes: ['fullVersionUntil'], attributes: ['fullVersionUntil', 'fullVersionDebts'],
transaction transaction: transaction.legacy.transaction
}) })
if (!familyEntryUnsafe) { if (!familyEntryUnsafe) {
@@ -52,7 +51,8 @@ export const requireFamilyEntry = async ({ database, deviceAuthToken, transactio
} }
const familyEntry = { const familyEntry = {
fullVersionUntil: familyEntryUnsafe.fullVersionUntil fullVersionUntil: familyEntryUnsafe.fullVersionUntil,
fullVersionDebts: familyEntryUnsafe.fullVersionDebts,
} }
return familyEntry return familyEntry
+14 -12
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2020 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -15,37 +15,39 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import * as Sequelize from 'sequelize' import { SimpleDatabase, SimpleDatabaseTransaction } from '../../database/simple'
import { Database } from '../../database'
import { configItemIds } from '../../database/config' import { configItemIds } from '../../database/config'
export const getStatusMessage = async ({ database, transaction }: { export const getStatusMessage = async ({ transaction }: {
database: Database transaction: SimpleDatabaseTransaction
transaction?: Sequelize.Transaction
}) => { }) => {
const currentStatusMessageItem = await database.config.findByPk(configItemIds.statusMessage, { transaction }) const currentStatusMessageItem = await transaction.legacy.database.config.findByPk(
configItemIds.statusMessage,
{ transaction: transaction.legacy.transaction }
)
const currentStatusMessage = (currentStatusMessageItem ? currentStatusMessageItem.value : null) || '' const currentStatusMessage = (currentStatusMessageItem ? currentStatusMessageItem.value : null) || ''
return currentStatusMessage return currentStatusMessage
} }
export const setStatusMessage = async ({ database, newStatusMessage }: { export const setStatusMessage = async ({ database, newStatusMessage }: {
database: Database database: SimpleDatabase
newStatusMessage: string newStatusMessage: string
}) => { }) => {
await database.transaction(async (transaction) => { await database.transaction(async (transaction) => {
if (newStatusMessage === '') { if (newStatusMessage === '') {
await database.config.destroy({ await transaction.legacy.database.config.destroy({
where: { where: {
id: configItemIds.statusMessage id: configItemIds.statusMessage
}, },
transaction transaction: transaction.legacy.transaction
}) })
} else { } else {
await database.config.upsert({ await transaction.legacy.database.config.upsert({
id: configItemIds.statusMessage, id: configItemIds.statusMessage,
value: newStatusMessage value: newStatusMessage
}, { transaction }) }, { transaction: transaction.legacy.transaction })
} }
}) })
} }
+8 -9
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2020 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -16,7 +16,7 @@
*/ */
import { Unauthorized } from 'http-errors' import { Unauthorized } from 'http-errors'
import { Database, Transaction } from '../../../database' import { SimpleDatabaseTransaction } from '../../../database/simple'
import { SourceFamilyNotFoundException } from './exception/illegal-state' import { SourceFamilyNotFoundException } from './exception/illegal-state'
export interface ApplyActionBaseInfo { export interface ApplyActionBaseInfo {
@@ -26,15 +26,14 @@ export interface ApplyActionBaseInfo {
hasFullVersion: boolean hasFullVersion: boolean
} }
export async function getApplyActionBaseInfo ({ database, transaction, deviceAuthToken }: { export async function getApplyActionBaseInfo ({ transaction, deviceAuthToken }: {
database: Database transaction: SimpleDatabaseTransaction
transaction: Transaction
deviceAuthToken: string deviceAuthToken: string
}): Promise<ApplyActionBaseInfo> { }): Promise<ApplyActionBaseInfo> {
const deviceEntryUnsafe = await database.device.findOne({ const deviceEntryUnsafe = await transaction.legacy.database.device.findOne({
where: { deviceAuthToken }, where: { deviceAuthToken },
attributes: ['familyId', 'deviceId', 'nextSequenceNumber'], attributes: ['familyId', 'deviceId', 'nextSequenceNumber'],
transaction transaction: transaction.legacy.transaction
}) })
if (!deviceEntryUnsafe) { if (!deviceEntryUnsafe) {
@@ -47,11 +46,11 @@ export async function getApplyActionBaseInfo ({ database, transaction, deviceAut
nextSequenceNumber: deviceEntryUnsafe.nextSequenceNumber nextSequenceNumber: deviceEntryUnsafe.nextSequenceNumber
} }
const familyEntryUnsafe = await database.family.findOne({ const familyEntryUnsafe = await transaction.legacy.database.family.findOne({
where: { where: {
familyId: deviceEntry.familyId familyId: deviceEntry.familyId
}, },
transaction, transaction: transaction.legacy.transaction,
attributes: ['hasFullVersion'] attributes: ['hasFullVersion']
}) })
+32 -35
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann * Copyright (C) 2019 - 2026 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -19,7 +19,7 @@ import { memoize } from 'lodash'
import * as Sequelize from 'sequelize' import * as Sequelize from 'sequelize'
import { config } from '../../../config' import { config } from '../../../config'
import { VisibleConnectedDevicesManager } from '../../../connected-devices' import { VisibleConnectedDevicesManager } from '../../../connected-devices'
import { Database } from '../../../database' import { SimpleDatabaseTransaction } from '../../../database/simple'
import { setToList } from '../../../util/list' import { setToList } from '../../../util/list'
import { generateVersionId } from '../../../util/token' import { generateVersionId } from '../../../util/token'
import { SourceUserNotFoundException } from './exception/illegal-state' import { SourceUserNotFoundException } from './exception/illegal-state'
@@ -29,8 +29,7 @@ export class Cache {
readonly familyId: string readonly familyId: string
readonly deviceId: string readonly deviceId: string
readonly hasFullVersion: boolean readonly hasFullVersion: boolean
transaction: Sequelize.Transaction transaction: SimpleDatabaseTransaction
readonly database: Database
readonly connectedDevicesManager: VisibleConnectedDevicesManager readonly connectedDevicesManager: VisibleConnectedDevicesManager
private requireSenderDoFullSync = false private requireSenderDoFullSync = false
@@ -48,18 +47,16 @@ export class Cache {
triggeredSyncLevel: 0 | 1 | 2 = 0 // 0 = no, 1 = unimportant, 2 = important triggeredSyncLevel: 0 | 1 | 2 = 0 // 0 = no, 1 = unimportant, 2 = important
targetedTriggeredSyncLevels = new Map<string, 0 | 1 | 2>() targetedTriggeredSyncLevels = new Map<string, 0 | 1 | 2>()
constructor ({ familyId, deviceId, hasFullVersion, database, transaction, connectedDevicesManager }: { constructor ({ familyId, deviceId, hasFullVersion, transaction, connectedDevicesManager }: {
familyId: string familyId: string
deviceId: string deviceId: string
hasFullVersion: boolean hasFullVersion: boolean
database: Database transaction: SimpleDatabaseTransaction
transaction: Sequelize.Transaction
connectedDevicesManager: VisibleConnectedDevicesManager connectedDevicesManager: VisibleConnectedDevicesManager
}) { }) {
this.familyId = familyId this.familyId = familyId
this.deviceId = deviceId this.deviceId = deviceId
this.hasFullVersion = hasFullVersion || config.alwaysPro this.hasFullVersion = hasFullVersion || config.alwaysPro
this.database = database
this.transaction = transaction this.transaction = transaction
this.connectedDevicesManager = connectedDevicesManager this.connectedDevicesManager = connectedDevicesManager
} }
@@ -77,7 +74,7 @@ export class Cache {
async subtransaction<T> (callback: () => Promise<T>): Promise<T> { async subtransaction<T> (callback: () => Promise<T>): Promise<T> {
const oldTransaction = this.transaction const oldTransaction = this.transaction
return this.database.transaction(async (newTransaction) => { return this.transaction.transaction(async (newTransaction) => {
try { try {
this.transaction = newTransaction this.transaction = newTransaction
@@ -87,18 +84,18 @@ export class Cache {
} finally { } finally {
this.transaction = oldTransaction this.transaction = oldTransaction
} }
}, { transaction: oldTransaction }) })
} }
getSecondPasswordHashOfParent = memoize(async (parentId: string) => { getSecondPasswordHashOfParent = memoize(async (parentId: string) => {
const userEntryUnsafe = await this.database.user.findOne({ const userEntryUnsafe = await this.transaction.legacy.database.user.findOne({
where: { where: {
familyId: this.familyId, familyId: this.familyId,
userId: parentId, userId: parentId,
type: 'parent' type: 'parent'
}, },
attributes: ['secondPasswordHash'], attributes: ['secondPasswordHash'],
transaction: this.transaction transaction: this.transaction.legacy.transaction
}) })
if (!userEntryUnsafe) { if (!userEntryUnsafe) {
@@ -109,14 +106,14 @@ export class Cache {
}) })
getSecondPasswordHashOfChild = memoize(async (childId: string) => { getSecondPasswordHashOfChild = memoize(async (childId: string) => {
const userEntryUnsafe = await this.database.user.findOne({ const userEntryUnsafe = await this.transaction.legacy.database.user.findOne({
where: { where: {
familyId: this.familyId, familyId: this.familyId,
userId: childId, userId: childId,
type: 'child' type: 'child'
}, },
attributes: ['secondPasswordHash'], attributes: ['secondPasswordHash'],
transaction: this.transaction transaction: this.transaction.legacy.transaction
}) })
if (!userEntryUnsafe) { if (!userEntryUnsafe) {
@@ -131,24 +128,24 @@ export class Cache {
}) })
doesCategoryExist = memoize(async (categoryId: string) => { doesCategoryExist = memoize(async (categoryId: string) => {
const categoryEntry = await this.database.category.findOne({ const categoryEntry = await this.transaction.legacy.database.category.findOne({
where: { where: {
familyId: this.familyId, familyId: this.familyId,
categoryId categoryId
}, },
transaction: this.transaction transaction: this.transaction.legacy.transaction
}) })
return !!categoryEntry return !!categoryEntry
}) })
doesUserExist = memoize(async (userId: string) => { doesUserExist = memoize(async (userId: string) => {
const userEntry = await this.database.user.findOne({ const userEntry = await this.transaction.legacy.database.user.findOne({
where: { where: {
familyId: this.familyId, familyId: this.familyId,
userId userId
}, },
transaction: this.transaction transaction: this.transaction.legacy.transaction
}) })
return !!userEntry return !!userEntry
@@ -158,10 +155,10 @@ export class Cache {
requireSenderFullSync: () => void = () => this.requireSenderDoFullSync = true requireSenderFullSync: () => void = () => this.requireSenderDoFullSync = true
async saveModifiedVersionNumbers () { async saveModifiedVersionNumbers () {
const { database, transaction, familyId } = this const { familyId } = this
if (this.categoriesWithModifiedApps.size > 0) { if (this.categoriesWithModifiedApps.size > 0) {
await database.category.update({ await this.transaction.legacy.database.category.update({
assignedAppsVersion: generateVersionId() assignedAppsVersion: generateVersionId()
}, { }, {
where: { where: {
@@ -170,14 +167,14 @@ export class Cache {
[Sequelize.Op.in]: setToList(this.categoriesWithModifiedApps) [Sequelize.Op.in]: setToList(this.categoriesWithModifiedApps)
} }
}, },
transaction transaction: this.transaction.legacy.transaction
}) })
this.categoriesWithModifiedApps.clear() this.categoriesWithModifiedApps.clear()
} }
if (this.categoriesWithModifiedBaseData.size > 0) { if (this.categoriesWithModifiedBaseData.size > 0) {
await database.category.update({ await this.transaction.legacy.database.category.update({
baseVersion: generateVersionId() baseVersion: generateVersionId()
}, { }, {
where: { where: {
@@ -186,14 +183,14 @@ export class Cache {
[Sequelize.Op.in]: setToList(this.categoriesWithModifiedBaseData) [Sequelize.Op.in]: setToList(this.categoriesWithModifiedBaseData)
} }
}, },
transaction transaction: this.transaction.legacy.transaction
}) })
this.categoriesWithModifiedBaseData.clear() this.categoriesWithModifiedBaseData.clear()
} }
if (this.categoriesWithModifiedTimeLimitRules.size > 0) { if (this.categoriesWithModifiedTimeLimitRules.size > 0) {
await database.category.update({ await this.transaction.legacy.database.category.update({
timeLimitRulesVersion: generateVersionId() timeLimitRulesVersion: generateVersionId()
}, { }, {
where: { where: {
@@ -202,14 +199,14 @@ export class Cache {
[Sequelize.Op.in]: setToList(this.categoriesWithModifiedTimeLimitRules) [Sequelize.Op.in]: setToList(this.categoriesWithModifiedTimeLimitRules)
} }
}, },
transaction transaction: this.transaction.legacy.transaction
}) })
this.categoriesWithModifiedTimeLimitRules.clear() this.categoriesWithModifiedTimeLimitRules.clear()
} }
if (this.categoriesWithModifiedUsedTimes.size > 0) { if (this.categoriesWithModifiedUsedTimes.size > 0) {
await database.category.update({ await this.transaction.legacy.database.category.update({
usedTimesVersion: generateVersionId() usedTimesVersion: generateVersionId()
}, { }, {
where: { where: {
@@ -218,14 +215,14 @@ export class Cache {
[Sequelize.Op.in]: setToList(this.categoriesWithModifiedUsedTimes) [Sequelize.Op.in]: setToList(this.categoriesWithModifiedUsedTimes)
} }
}, },
transaction transaction: this.transaction.legacy.transaction
}) })
this.categoriesWithModifiedUsedTimes.clear() this.categoriesWithModifiedUsedTimes.clear()
} }
if (this.categoriesWithModifiedTasks.size > 0) { if (this.categoriesWithModifiedTasks.size > 0) {
await database.category.update({ await this.transaction.legacy.database.category.update({
taskListVersion: generateVersionId() taskListVersion: generateVersionId()
}, { }, {
where: { where: {
@@ -234,46 +231,46 @@ export class Cache {
[Sequelize.Op.in]: setToList(this.categoriesWithModifiedTasks) [Sequelize.Op.in]: setToList(this.categoriesWithModifiedTasks)
} }
}, },
transaction transaction: this.transaction.legacy.transaction
}) })
this.categoriesWithModifiedUsedTimes.clear() this.categoriesWithModifiedUsedTimes.clear()
} }
if (this.invalidiateUserList) { if (this.invalidiateUserList) {
await database.family.update({ await this.transaction.legacy.database.family.update({
userListVersion: generateVersionId() userListVersion: generateVersionId()
}, { }, {
where: { where: {
familyId: this.familyId familyId: this.familyId
}, },
transaction transaction: this.transaction.legacy.transaction
}) })
this.invalidiateUserList = false this.invalidiateUserList = false
} }
if (this.invalidiateDeviceList) { if (this.invalidiateDeviceList) {
await database.family.update({ await this.transaction.legacy.database.family.update({
deviceListVersion: generateVersionId() deviceListVersion: generateVersionId()
}, { }, {
where: { where: {
familyId: this.familyId familyId: this.familyId
}, },
transaction transaction: this.transaction.legacy.transaction
}) })
this.invalidiateDeviceList = false this.invalidiateDeviceList = false
} }
if (this.invalidateU2fList) { if (this.invalidateU2fList) {
await database.family.update({ await this.transaction.legacy.database.family.update({
u2fKeysVersion: generateVersionId() u2fKeysVersion: generateVersionId()
}, { }, {
where: { where: {
familyId: this.familyId familyId: this.familyId
}, },
transaction transaction: this.transaction.legacy.transaction
}) })
this.invalidateU2fList = false this.invalidateU2fList = false

Some files were not shown because too many files have changed in this diff Show More