Compare commits

...
30 Commits
Author SHA1 Message Date
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
59 changed files with 2965 additions and 3091 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
}
};
+1 -1
View File
@@ -5,7 +5,7 @@ RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# 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 scripts/ /usr/src/app/scripts/
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 properties: ``purchaseToken`` and ``purchaseId``
request properties: ``purchaseToken``, ``purchaseId`` and ``dryRun``
- ``purchasetoken`` is a string which the client shows at the purchase screen
- ``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
@@ -120,6 +124,7 @@ The response contains the following properties:
- optional object
- should be shown to the support
- ``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
+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)
Note that ``type`` is not used at all.
### response
On a invalid request body: HTTP status code 400 Bad request
+1 -2
View File
@@ -14,8 +14,7 @@
},
"additionalProperties": false,
"required": [
"deviceAuthToken",
"type"
"deviceAuthToken"
],
"definitions": {},
"$schema": "http://json-schema.org/draft-07/schema#",
+6
View File
@@ -130,6 +130,8 @@
* [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`
* [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`
* [ServerPing](./serverdatastatus-definitions-serverping.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerPing`
* [ServerSessionDurationItem](./serverdatastatus-definitions-serversessiondurationitem.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerSessionDurationItem`
* [ServerTimeLimitRule](./serverdatastatus-definitions-servertimelimitrule.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerTimeLimitRule`
@@ -346,6 +350,8 @@
* [Untitled array in ServerDataStatus](./serverdatastatus-properties-kr.md) `https://timelimit.io/ServerDataStatus#/properties/kr`
* [Untitled array in ServerDataStatus](./serverdatastatus-properties-pings.md) `https://timelimit.io/ServerDataStatus#/properties/pings`
* [Untitled array in ServerDataStatus](./serverdatastatus-definitions-u2fdata-properties-d.md) `https://timelimit.io/ServerDataStatus#/definitions/U2fData/properties/d`
## Version Note
@@ -21,6 +21,9 @@
{
"$ref": "#/definitions/SerializedMarkTaskPendingAction"
},
{
"$ref": "#/definitions/SerializedPingAction"
},
{
"$ref": "#/definitions/SerializedUpdateInstalledAppsAction"
},
@@ -309,6 +312,43 @@
],
"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": {
"type": "object",
"properties": {
+31
View File
@@ -67,6 +67,12 @@
"$ref": "#/definitions/ServerKeyResponse"
}
},
"pings": {
"type": "array",
"items": {
"$ref": "#/definitions/ServerPing"
}
},
"dh": {
"$ref": "#/definitions/ServerDhKey"
},
@@ -927,6 +933,31 @@
],
"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": {
"type": "object",
"properties": {
+2 -2
View File
@@ -18,7 +18,7 @@ https://timelimit.io/CanDoPurchaseRequest
| 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") |
## type
@@ -27,7 +27,7 @@ https://timelimit.io/CanDoPurchaseRequest
`type`
* is required
* is optional
* 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`
+127 -9
View File
@@ -30,6 +30,8 @@ any of
* [SerializedMarkTaskPendingAction](serializedapplogicaction-definitions-serializedmarktaskpendingaction.md "check type definition")
* [SerializedPingAction](serializedapplogicaction-definitions-serializedpingaction.md "check type definition")
* [SerializedUpdateInstalledAppsAction](serializedapplogicaction-definitions-serializedupdateinstalledappsaction.md "check type definition")
* [SerializedRemoveInstalledAppsAction](serializedapplogicaction-definitions-serializedremoveinstalledappsaction.md "check type definition")
@@ -688,6 +690,122 @@ Reference this group by using
`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
Reference this group by using
@@ -698,7 +816,7 @@ Reference this group by using
| 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") |
| [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") |
@@ -793,7 +911,7 @@ Reference this group by using
| 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") |
### type
@@ -850,9 +968,9 @@ Reference this group by using
| 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") |
| [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") |
| [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") |
@@ -1002,7 +1120,7 @@ Reference this group by using
| 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
@@ -1040,7 +1158,7 @@ Reference this group by using
| 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
@@ -1078,7 +1196,7 @@ Reference this group by using
| 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") |
| [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 |
| :---------------------------------------------------------- | :-------- | :------- | :------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [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") |
| [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") |
@@ -1518,7 +1636,7 @@ Reference this group by using
| 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") |
### type
@@ -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))
+96
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") |
| [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") |
| [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") |
| [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") |
@@ -252,6 +253,24 @@ https://timelimit.io/ServerDataStatus
`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
@@ -3449,6 +3468,83 @@ Reference this group by using
`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
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' }]
}
}
)
+1586 -2977
View File
File diff suppressed because it is too large Load Diff
+9 -10
View File
@@ -6,10 +6,10 @@
"scripts": {
"start": "node ./build/index.js",
"test": "node scripts/test-launch-with-different-databases.js",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"lint:fix": "eslint . --ext .js,.jsx,.ts,.tsx --fix",
"lint": "eslint .",
"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:clean": "rimraf build",
"build:clean": "rm -rf build",
"build:json": "node ./scripts/build-schemas.js",
"build:ts": "tsc",
"build:doc": "npm run build:doc:json",
@@ -30,6 +30,7 @@
"homepage": "https://gitlab.com/timelimit.io/timelimit-server-2018#README",
"devDependencies": {
"@adobe/jsonschema2md": "^8.0.8",
"@eslint/js": "^10.0.1",
"@types/basic-auth": "^1.1.3",
"@types/body-parser": "^1.19.0",
"@types/ejs": "^3.1.0",
@@ -38,15 +39,13 @@
"@types/lodash": "^4.14.166",
"@types/node": "^16.11.59",
"@types/nodemailer": "^6.4.4",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"eslint": "^8.7.0",
"rimraf": "^3.0.2",
"eslint": "^10.0.1",
"typescript": "^5.5.4",
"typescript-eslint": "^8.56.0",
"typescript-json-schema": "^0.52.0"
},
"dependencies": {
"ajv": "^7.0.2",
"ajv": "^8.18.0",
"basic-auth": "^2.0.1",
"body-parser": "^1.19.0",
"ejs": "^3.1.5",
@@ -56,7 +55,7 @@
"jose": "^4.9.3",
"lodash": "^4.17.21",
"mariadb": "^2.5.2",
"nodemailer": "^7.0.9",
"nodemailer": "^9.0.4",
"pg": "^8.5.1",
"pg-hstore": "^2.3.3",
"rate-limiter-flexible": "^2.1.15",
@@ -65,6 +64,6 @@
"umzug": "^3.8.1"
},
"optionalDependencies": {
"sqlite3": "^5.0.0"
"sqlite3": "npm:@vscode/sqlite3@^5.1.12-vscode"
}
}
+4 -2
View File
@@ -24,6 +24,8 @@ const { spawnAsync } = require('../process.js')
const { sleep } = require('../sleep.js')
async function startMariadb() {
const osUsername = require('os').userInfo().username
try { await mkdirAsync(tempDir) } catch (ex) {/* ignore */}
const instanceDir = resolve(tempDir, generateShortToken())
@@ -60,12 +62,12 @@ async function startMariadb() {
for (command of commands) {
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 {
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)
})
},
+1 -1
View File
@@ -58,7 +58,7 @@ async function startPostgres() {
const password = generateToken() // this database accepts anything
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 {
shutdown: () => task.kill('SIGINT'),
+2 -1
View File
@@ -1,6 +1,6 @@
/*
* 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
* 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 { UpdateUserLimitLoginCategory } from './updateuserlimitlogincategory'
export { MarkTaskPendingAction } from './marktaskpendingaction'
export { PingAction } from './ping'
export { DeleteChildTaskAction } from './deletechildtaskaction'
export { UpdateChildTaskAction } from './updatechildtaskaction'
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
* Copyright (C) 2019 - 2022 Jonas Lochmann
* 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
@@ -24,6 +24,7 @@ import { ForceSyncAction, SerializedForceSyncAction } from '../forcesync'
import { ReplyToKeyRequestAction, SerializedReplyToKeyRequestAction } from '../replytokeyrequest'
import { MarkTaskPendingAction, SerializedMarkTaskPendingAction } from '../marktaskpendingaction'
import { UnknownActionTypeException } from '../meta/exception'
import { PingAction, SerializedPingAction } from '../ping'
import { UpdateInstalledAppsAction, SerializedUpdateInstalledAppsAction } from '../updateinstalledapps'
import { RemoveInstalledAppsAction, SerializedRemoveInstalledAppsAction } from '../removeinstalledapps'
import { SendKeyRequestAction, SerializedSendKeyRequestAction } from '../sendkeyrequest'
@@ -41,6 +42,7 @@ export type SerializedAppLogicAction =
SerializedForceSyncAction |
SerializedReplyToKeyRequestAction |
SerializedMarkTaskPendingAction |
SerializedPingAction |
SerializedUpdateInstalledAppsAction |
SerializedRemoveInstalledAppsAction |
SerializedSendKeyRequestAction |
@@ -65,6 +67,8 @@ export const parseAppLogicAction = (serialized: SerializedAppLogicAction): AppLo
return ReplyToKeyRequestAction.parse(serialized)
} else if (serialized.type === 'MARK_TASK_PENDING') {
return MarkTaskPendingAction.parse(serialized)
} else if (serialized.type === 'PING') {
return PingAction.parse(serialized)
} else if (serialized.type === 'UPDATE_INSTALLED_APPS') {
return UpdateInstalledAppsAction.parse(serialized)
} else if (serialized.type === 'REMOVE_INSTALLED_APPS') {
+26 -13
View File
@@ -1,6 +1,6 @@
/*
* 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
* it under the terms of the GNU Affero General Public License as
@@ -140,15 +140,23 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: {
if (
typeof req.body !== 'object' ||
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()
}
const purchaseToken: string = req.body.purchaseToken
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') {
res.json({ ok: false, error: 'token invalid', detail: 'wrong purpose' })
@@ -226,7 +234,10 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: {
error: 'family not found'
}
const canDoPurchase = canDoNextPurchase({ fullVersionUntil: parseInt(familyEntry.fullVersionUntil) })
const canDoPurchase = canDoNextPurchase({
fullVersionUntil: parseInt(familyEntry.fullVersionUntil),
fullVersionDebts: parseInt(familyEntry.fullVersionDebts),
})
if (!canDoPurchase) {
const lastPurchase = await database.purchase.findOne({
@@ -250,15 +261,17 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: {
}
}
await addPurchase({
database,
familyId: tokenContent.familyId,
type: 'year',
service: 'directpurchase',
transactionId: purchaseId,
websocket,
transaction
})
if (!dryRun) {
await addPurchase({
database,
familyId: tokenContent.familyId,
type,
service: 'directpurchase',
transactionId: purchaseId,
websocket,
transaction
})
}
}
return {
+10 -7
View File
@@ -1,6 +1,6 @@
/*
* 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
* it under the terms of the GNU Affero General Public License as
@@ -37,16 +37,16 @@ export const createPurchaseRouter = ({ database, websocket }: {
const router = Router()
router.post('/can-do-purchase', json(), async (req, res, next) => {
if (!areGooglePlayPaymentsPossible) {
res.json({ canDoPurchase: 'no because not supported by the server' })
return
}
try {
if (!isCanDoPurchaseRequest(req.body)) {
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 familyEntry = await requireFamilyEntry({
database,
@@ -54,7 +54,10 @@ export const createPurchaseRouter = ({ database, websocket }: {
transaction
})
return canDoNextPurchase({ fullVersionUntil: parseInt(familyEntry.fullVersionUntil, 10) })
return canDoNextPurchase({
fullVersionUntil: parseInt(familyEntry.fullVersionUntil, 10),
fullVersionDebts: parseInt(familyEntry.fullVersionDebts, 10),
})
})
res.json({
+1 -1
View File
@@ -113,7 +113,7 @@ export interface CreateRegisterDeviceTokenRequest {
}
export interface CanDoPurchaseRequest {
type: 'googleplay' | 'any'
type?: 'googleplay' | 'any'
deviceAuthToken: string
}
+63 -2
View File
@@ -1759,6 +1759,41 @@ const definitions = {
"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": {
"type": "object",
"properties": {
@@ -2815,6 +2850,30 @@ const definitions = {
"tempKey"
]
},
"ServerPing": {
"type": "object",
"properties": {
"deviceId": {
"type": "string"
},
"token": {
"type": "string"
},
"type": {
"enum": [
"ping",
"pong"
],
"type": "string"
}
},
"additionalProperties": false,
"required": [
"deviceId",
"token",
"type"
]
},
"ServerDhKey": {
"type": "object",
"properties": {
@@ -3213,6 +3272,9 @@ export const isSerializedAppLogicAction: (value: unknown) => value is Serialized
{
"$ref": "#/definitions/SerializedMarkTaskPendingAction"
},
{
"$ref": "#/definitions/SerializedPingAction"
},
{
"$ref": "#/definitions/SerializedUpdateInstalledAppsAction"
},
@@ -3291,8 +3353,7 @@ export const isCanDoPurchaseRequest: (value: unknown) => value is CanDoPurchaseR
},
"additionalProperties": false,
"required": [
"deviceAuthToken",
"type"
"deviceAuthToken"
],
"definitions": definitions,
"$schema": "http://json-schema.org/draft-07/schema#"
+20 -3
View File
@@ -1,6 +1,6 @@
/*
* 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
* it under the terms of the GNU Affero General Public License as
@@ -37,8 +37,13 @@ export interface FamilyAttributesVersion3 {
u2fKeysVersion: string
}
export interface FamilyAttributesVersion4 {
fullVersionDebts: string
}
export type FamilyAttributes = FamilyAttributesVersion1 &
FamilyAttributesVersion2 & FamilyAttributesVersion3
FamilyAttributesVersion2 & FamilyAttributesVersion3 &
FamilyAttributesVersion4
export type FamilyModel = Sequelize.Model<FamilyAttributes> & FamilyAttributes
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> = {
...attributesVersion1,
...attributesVersion2,
...attributesVersion3
...attributesVersion3,
...attributesVersion4
}
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
* Copyright (C) 2019 - 2022 Jonas Lochmann
* 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
@@ -33,6 +33,7 @@ import { createKeyResponseModel, KeyResponseModelStatic } from './keyresponse'
import { createMailLoginTokenModel, MailLoginTokenModelStatic } from './maillogintoken'
import { createUmzug } from './migration/umzug'
import { createOldDeviceModel, OldDeviceModelStatic } from './olddevice'
import { createPingModel, PingModelStatic } from './ping'
import { createPurchaseModel, PurchaseModelStatic } from './purchase'
import { createSessionDurationModel, SessionDurationModelStatic } from './sessionduration'
import { createTimelimitRuleModel, TimelimitRuleModelStatic } from './timelimitrule'
@@ -61,6 +62,7 @@ export interface Database {
keyResponse: KeyResponseModelStatic
mailLoginToken: MailLoginTokenModelStatic
oldDevice: OldDeviceModelStatic
ping: PingModelStatic
purchase: PurchaseModelStatic
sessionDuration: SessionDurationModelStatic
timelimitRule: TimelimitRuleModelStatic
@@ -97,6 +99,7 @@ const createDatabase = (sequelize: Sequelize.Sequelize): Database => ({
keyResponse: createKeyResponseModel(sequelize),
mailLoginToken: createMailLoginTokenModel(sequelize),
oldDevice: createOldDeviceModel(sequelize),
ping: createPingModel(sequelize),
purchase: createPurchaseModel(sequelize),
sessionDuration: createSessionDurationModel(sequelize),
timelimitRule: createTimelimitRuleModel(sequelize),
@@ -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 })
})
}
+2 -2
View File
@@ -1,6 +1,6 @@
/*
* server component for the TimeLimit App
* Copyright (C) 2019 - 2024 Jonas Lochmann
* 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
@@ -27,7 +27,7 @@ export const createUmzug = (sequelize: Sequelize) => (
resolve: ({ name, path }) => {
if (!path) throw new Error()
// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-require-imports
const migration = require(path)
return {
+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
* Copyright (C) 2019 - 2022 Jonas Lochmann
* 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
@@ -23,7 +23,7 @@ export interface PurchaseAttributes {
familyId: string
service: 'googleplay' | 'directpurchase'
transactionId: string
type: 'month' | 'year'
type: 'month' | 'year' | 'unpaid14'
loggedAt: string
previousFullVersionEndTime: string
newFullVersionEndTime: string
@@ -44,7 +44,7 @@ export const attributes: SequelizeAttributes<PurchaseAttributes> = {
type: Sequelize.STRING,
primaryKey: true
},
type: createEnumColumn(['month', 'year']),
type: createEnumColumn(['month', 'year', 'unpaid14']),
loggedAt: { ...timestampColumn },
previousFullVersionEndTime: { ...timestampColumn },
newFullVersionEndTime: { ...timestampColumn }
+3 -2
View File
@@ -1,6 +1,6 @@
/*
* 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
* it under the terms of the GNU Affero General Public License as
@@ -82,7 +82,8 @@ export async function createFamily ({
fullVersionUntil: (Date.now() + 1000 * 60 * 60 * 24 * 14).toString(10),
hasFullVersion: true,
nextServerKeyRequestSeq: '1',
u2fKeysVersion: generateVersionId()
u2fKeysVersion: generateVersionId(),
fullVersionDebts: '0'
}, { transaction })
// create parent user
+38 -6
View File
@@ -1,6 +1,6 @@
/*
* 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
* it under the terms of the GNU Affero General Public License as
@@ -21,13 +21,14 @@ import { notifyClientsAboutChangesDelayed } from '../../function/websocket'
import { WebsocketApi } from '../../websocket'
const day = 1000 * 60 * 60 * 24
const week = day * 7
const month = day * 31
const year = day * 366
export const addPurchase = async ({ database, familyId, type, service, transactionId, websocket, transaction }: {
database: Database
familyId: string
type: 'month' | 'year'
type: 'month' | 'year' | 'unpaid14'
service: 'googleplay' | 'directpurchase'
transactionId: string
websocket: WebsocketApi
@@ -57,11 +58,42 @@ export const addPurchase = async ({ database, familyId, type, service, transacti
}
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
familyEntry.fullVersionUntil = newFullVersionUntil.toString(10)
familyEntry.hasFullVersion = true
if (typeDuration > previousFullVersionDebts) {
const newFullVersionUntil = Math.max(parseInt(familyEntry.fullVersionUntil, 10), Date.now()) + typeDuration - previousFullVersionDebts
familyEntry.fullVersionUntil = newFullVersionUntil.toString(10)
familyEntry.fullVersionDebts = '0'
familyEntry.hasFullVersion = true
} else {
familyEntry.fullVersionDebts = (previousFullVersionDebts - typeDuration).toString(10)
}
} else if (type === 'unpaid14') {
const debtsAdd = 2 * week
const debtsMax = 3 * week
const newDebts = Math.min(debtsMax, previousFullVersionDebts + debtsAdd)
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 })
@@ -72,7 +104,7 @@ export const addPurchase = async ({ database, familyId, type, service, transacti
type,
loggedAt: Date.now().toString(10),
previousFullVersionEndTime,
newFullVersionEndTime: newFullVersionUntil.toString(10)
newFullVersionEndTime: familyEntry.fullVersionUntil
}, {
transaction
})
@@ -1,6 +1,6 @@
/*
* 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
* 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/>.
*/
export const canDoNextPurchase = ({ fullVersionUntil }: {fullVersionUntil: number}) => (
fullVersionUntil < (Date.now() + 1000 * 60 * 60 * 24 * 31) // 31 days
export const canDoNextPurchase = ({ fullVersionUntil, fullVersionDebts }: {
fullVersionUntil: number
fullVersionDebts: number
}) => (
(fullVersionUntil - fullVersionDebts) < (Date.now() + 1000 * 60 * 60 * 24 * 31) // 31 days
)
@@ -1,6 +1,6 @@
/*
* 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
* it under the terms of the GNU Affero General Public License as
@@ -43,7 +43,7 @@ export const requireFamilyEntry = async ({ database, deviceAuthToken, transactio
where: {
familyId: deviceEntry.familyId
},
attributes: ['fullVersionUntil'],
attributes: ['fullVersionUntil', 'fullVersionDebts'],
transaction
})
@@ -52,7 +52,8 @@ export const requireFamilyEntry = async ({ database, deviceAuthToken, transactio
}
const familyEntry = {
fullVersionUntil: familyEntryUnsafe.fullVersionUntil
fullVersionUntil: familyEntryUnsafe.fullVersionUntil,
fullVersionDebts: familyEntryUnsafe.fullVersionDebts,
}
return familyEntry
@@ -1,6 +1,6 @@
/*
* 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
* it under the terms of the GNU Affero General Public License as
@@ -89,7 +89,6 @@ export async function dispatchAddUsedTimeVersion2 ({ deviceId, action, cache, ev
addUsedTimeForADifferentUserThanTheCurrentUserOfTheDevice = true
}
// eslint-disable-next-line no-inner-declarations
async function handle (start: number, end: number) {
const lengthInMinutes = (end - start) + 1
const lengthInMs = lengthInMinutes * 1000 * 60
@@ -215,10 +214,10 @@ export async function dispatchAddUsedTimeVersion2 ({ deviceId, action, cache, ev
const fittingDurationItemsLastUsageFiltered =
hasTrustedTimestamp ?
fittingDurationItems.filter((it) => {
fittingDurationItems.filter((it) => (
action.trustedTimestamp - item.timeToAdd <=
parseInt(it.lastUsage, 10) + it.sessionPauseDuration - tolerance
}) : fittingDurationItems
)) : fittingDurationItems
return fittingDurationItemsLastUsageFiltered
.map((it) => it.lastSessionDuration)
@@ -1,6 +1,6 @@
/*
* 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
* it under the terms of the GNU Affero General Public License as
@@ -23,6 +23,7 @@ import {
FinishKeyRequestAction,
ForceSyncAction,
MarkTaskPendingAction,
PingAction,
ReplyToKeyRequestAction,
RemoveInstalledAppsAction,
SendKeyRequestAction,
@@ -41,6 +42,7 @@ import { dispatchAddUsedTimeVersion2 } from './addusedtime2'
import { dispatchFinishKeyRequestAction } from './finishkeyrequest'
import { dispatchForceSyncAction } from './forcesync'
import { dispatchMarkTaskPendingAction } from './marktaskpendingaction'
import { dispatchPingAction } from './ping'
import { dispatchReplyToKeyRequestAction } from './replytokeyrequest'
import { dispatchSendKeyRequestAction } from './sendkeyrequest'
import { dispatchSignOutAtDevice } from './signoutatdevice'
@@ -67,6 +69,8 @@ export const dispatchAppLogicAction = async ({ action, deviceId, cache, eventHan
await dispatchForceSyncAction({ deviceId, action, cache })
} else if (action instanceof MarkTaskPendingAction) {
await dispatchMarkTaskPendingAction({ deviceId, action, cache })
} else if (action instanceof PingAction) {
await dispatchPingAction({ deviceId, action, cache })
} else if (action instanceof ReplyToKeyRequestAction) {
await dispatchReplyToKeyRequestAction({ deviceId, action, cache, eventHandler })
} else if (action instanceof RemoveInstalledAppsAction) {
@@ -0,0 +1,73 @@
/*
* 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 { PingAction } from '../../../../action'
import { types as pingTypes } from '../../../../database/ping'
import { Cache } from '../cache'
export async function dispatchPingAction ({ action, cache, deviceId }: {
deviceId: string
action: PingAction
cache: Cache
}) {
// handle insertion
if (action.event === 'ping' || action.event === 'pong') {
let type
if (action.event === 'ping') type = pingTypes.ping
else if (action.event === 'pong') type = pingTypes.pong
else throw new Error()
// delete any previous ping/pong
await cache.database.ping.destroy({
where: {
familyId: cache.familyId,
receiverDeviceId: action.deviceId,
senderDeviceId: deviceId,
type: type
},
transaction: cache.transaction
})
// insert
await cache.database.ping.create({
familyId: cache.familyId,
receiverDeviceId: action.deviceId,
senderDeviceId: deviceId,
type,
token: action.token
}, {
transaction: cache.transaction
})
// notify
cache.incrementTargetedTriggeredSyncLevel(action.deviceId, 2)
}
// handle deleting
if (action.event === 'pong' || action.event === 'clear') {
await cache.database.ping.destroy({
where: {
familyId: cache.familyId,
receiverDeviceId: deviceId,
senderDeviceId: action.deviceId,
token: action.token
},
transaction: cache.transaction
})
}
}
@@ -1,6 +1,6 @@
/*
* 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
* it under the terms of the GNU Affero General Public License as
@@ -48,7 +48,8 @@ export const dispatchChildChangePassword = async ({ action, childUserId, cache }
{
const clear = cache.getSecondPasswordHashOfChild.cache.clear
clear && clear()
if (clear) clear()
}
cache.invalidiateUserList = true
@@ -1,6 +1,6 @@
/*
* 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
* it under the terms of the GNU Affero General Public License as
@@ -55,7 +55,8 @@ export async function dispatchChangeParentPassword ({ action, cache }: {
{
const clear = cache.getSecondPasswordHashOfParent.cache.clear
clear && clear()
if (clear) clear()
}
cache.invalidiateUserList = true
@@ -1,6 +1,6 @@
/*
* 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
* it under the terms of the GNU Affero General Public License as
@@ -47,7 +47,8 @@ export async function dispatchSetChildPassword ({ action, cache }: {
{
const clear = cache.getSecondPasswordHashOfChild.cache.clear
clear && clear()
if (clear) clear()
}
cache.invalidiateUserList = true
@@ -1,6 +1,6 @@
/*
* server component for the TimeLimit App
* Copyright (C) 2019 - 2024 Jonas Lochmann
* 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
@@ -67,6 +67,9 @@ export async function dispatchUpdateTimelimitRule ({
const wasSessionDurationLimitationEnabled =
ruleEntry.sessionPauseMilliseconds > 0 && ruleEntry.sessionDurationMilliseconds > 0
const isSessionDurationLimitationEnabled =
action.sessionPauseMilliseconds > 0 && action.sessionDurationMilliseconds > 0
const countOldAffectedDays = Array(7)
.fill(0)
.reduce((sum, _, index) => sum + ((ruleEntry.dayMaskAsBitmask >> index) & 1), 0)
@@ -78,6 +81,7 @@ export async function dispatchUpdateTimelimitRule ({
action.start <= ruleEntry.startMinuteOfDay &&
action.end >= ruleEntry.endMinuteOfDay &&
(!wasSessionDurationLimitationEnabled || (
isSessionDurationLimitationEnabled &&
action.sessionDurationMilliseconds <= ruleEntry.sessionDurationMilliseconds &&
action.sessionPauseMilliseconds >= ruleEntry.sessionPauseMilliseconds
)) &&
@@ -0,0 +1,64 @@
/*
* 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 { createHash } from 'crypto'
const updateMessage =
'Please update the TimeLimit App to the latest release. ' +
'In your current version, synchronization and purchases may not work as expected.' +
'\n\n' +
'Bitte die TimeLimit-App aktualisieren. ' +
'Mit der momentan installierten Version kann es zu Einschränkungen bei der Synchronisation und bei Käufen kommen.'
export function getCampaign({ familyId, isClient750OrNewer }: {
familyId: string
isClient750OrNewer: boolean
}): string | undefined {
const now = Date.now()
const campaigns = [
{
enable: !isClient750OrNewer,
seed: 'Q05NwM4nyUfiYg6K', // require('crypto').randomBytes(12).toString('base64')
startTime: 1784160000000, // new Date('2026-07-16').valueOf()
endTime: 1785369600000, // new Date('2026-07-30').valueOf()
startPercentage: 0,
endPercentage: 10,
message: updateMessage,
}
]
for (const campaign of campaigns) {
if (!campaign.enable) continue
if (now < campaign.startTime) continue
const progress = Math.min((now - campaign.startTime) / (campaign.endTime - campaign.startTime), 1)
const chanceInPercent = campaign.startPercentage + progress * (campaign.endPercentage - campaign.startPercentage)
const hasher = createHash('SHA3-224')
hasher.update(campaign.seed, 'base64')
hasher.update(familyId)
const hash = hasher.digest().readUInt32BE(0)
const match = hash < chanceInPercent * Math.pow(2, 32) / 100
if (match) return campaign.message
}
return undefined
}
@@ -1,6 +1,6 @@
/*
* server component for the TimeLimit App
* Copyright (C) 2019 - 2024 Jonas Lochmann
* 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
@@ -22,6 +22,7 @@ import { getStatusMessage } from '../../../function/statusmessage'
import { ClientDataStatus } from '../../../object/clientdatastatus'
import { ServerDataStatus } from '../../../object/serverdatastatus'
import { EventHandler } from '../../../monitoring/eventhandler'
import { getCampaign } from './campaign'
import {
getCategoryAssignedApps, getCategoryBaseDatas, getCategoryDataToSync,
getRules, getTasks, getUsedTimes
@@ -30,6 +31,7 @@ import { getDeviceDetailList } from './device-detail'
import { getDeviceList } from './device-list'
import { getDeviceDhKeys } from './dh-keys'
import { getFamilyEntry } from './family-entry'
import { getPings } from './pings'
import { getUserList } from './user-list'
import { getKeyRequests } from './key-requests'
import { getKeyResponses } from './key-responses'
@@ -52,13 +54,20 @@ export const generateServerDataStatus = async ({
const doesClientSupportCryptoApps = clientLevel >= 4
const doesClientSupportDh = clientLevel >= 5
const doesClientSupportU2f = clientLevel >= 6
const doesClientSupportPing = clientLevel >= 7
const isClient750OrNewer = clientLevel >= 8 // first release in the post gplay time
const message: string | undefined =
await getStatusMessage({ database, transaction }) ||
getCampaign({ familyId, isClient750OrNewer }) ||
undefined
const result: ServerDataStatus = {
fullVersion: config.alwaysPro ? 1 : (
familyEntry.hasFullVersion ? parseInt(familyEntry.fullVersionUntil, 10) : 0
),
message: await getStatusMessage({ database, transaction }) || undefined,
apiLevel: 8
message,
apiLevel: 9
}
if (familyEntry.deviceListVersion !== clientStatus.devices) {
@@ -160,5 +169,14 @@ export const generateServerDataStatus = async ({
}) || undefined
}
if (doesClientSupportPing) {
result.pings = await getPings({
database,
transaction,
familyEntry,
deviceId
})
}
return result
}
@@ -0,0 +1,52 @@
/*
* 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 { Database } from '../../../database'
import { types as pingTypes } from '../../../database/ping'
import { ServerPing } from '../../../object/serverdatastatus'
import { FamilyEntry } from './family-entry'
export async function getPings ({
database, transaction, familyEntry, deviceId
}: {
database: Database
transaction: Sequelize.Transaction
familyEntry: FamilyEntry
deviceId: string
}): Promise<Array<ServerPing>> {
const savedData = await database.ping.findAll({
where: {
familyId: familyEntry.familyId,
receiverDeviceId: deviceId,
},
attributes: ['senderDeviceId', 'type', 'token'],
transaction
})
return savedData.map((row) => ({
deviceId: row.senderDeviceId,
type: convertType(row.type),
token: row.token
}))
}
function convertType(type: number): 'ping' | 'pong' {
if (type === pingTypes.ping) return 'ping'
else if (type === pingTypes.pong) return 'pong'
else throw new Error()
}
+8 -1
View File
@@ -1,6 +1,6 @@
/*
* 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
* it under the terms of the GNU Affero General Public License as
@@ -34,6 +34,7 @@ export interface ServerDataStatus {
users?: ServerUserList // newUserList
krq?: Array<ServerKeyRequest> // pendingKeyRequests
kr?: Array<ServerKeyResponse> // keyResponses
pings?: Array<ServerPing>
dh?: ServerDhKey // Diffie Hellman
u2f?: U2fData
fullVersion: number // fullVersionUntil
@@ -257,6 +258,12 @@ export interface ServerKeyResponse {
signature: string
}
export interface ServerPing {
deviceId: string
token: string
type: 'ping' | 'pong'
}
export interface ServerDhKey {
v: string // version
k: string // key, base64
+6 -3
View File
@@ -1,6 +1,6 @@
/*
* 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
* it under the terms of the GNU Affero General Public License as
@@ -33,12 +33,15 @@ export async function createIdentityToken({ purpose, familyId, userId, mail }: I
.join('\n')
}
export async function verifyIdentitifyToken(token: string): Promise<IdentityTokenPayload> {
export async function verifyIdentitifyToken(token: string, dryRun: boolean): Promise<IdentityTokenPayload> {
try {
const { payload } = await jwtVerify(
Buffer.from(token, 'base64').toString('ascii'),
getSignSecret(),
{ algorithms: ['HS512'] }
{
algorithms: ['HS512'],
clockTolerance: dryRun ? 0 : '4w',
}
)
if (!isIdentityTokenPayload(payload)) throw new BadPayloadException()
+2 -2
View File
@@ -1,6 +1,6 @@
/*
* 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
* it under the terms of the GNU Affero General Public License as
@@ -56,7 +56,7 @@ export const createWebsocketHandler = ({ connectedDevicesManager, database }: {
const importantSyncForAllListener = () => {
setTimeout(() => {
socket.connected && socket.emit('should sync', { isImportant: true })
if (socket.connected) socket.emit('should sync', { isImportant: true })
}, Math.random() * 1000 * 60 /* wait up to one minute */)
}