mirror of
https://codeberg.org/timelimit/timelimit-server.git
synced 2026-08-31 19:03:45 +02:00
Compare commits
24
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
63c23060f6 | ||
|
|
c3793f71a8 | ||
|
|
c693cfdbd4 | ||
|
|
d3675d484b | ||
|
|
053c59899b | ||
|
|
c1e2ea8c84 | ||
|
|
07ee3c268a | ||
|
|
0f92e6b1b7 | ||
|
|
b4a3862c1e | ||
|
|
24fa354f09 | ||
|
|
3d307bee6e | ||
|
|
d227f112e4 | ||
|
|
d83b8a2c26 | ||
|
|
333ac4a8a2 | ||
|
|
77e39752ed | ||
|
|
7c81f50ad2 | ||
|
|
44e7d16b5c | ||
|
|
473fbe80e9 | ||
|
|
1930dd0a27 | ||
|
|
a79fcf235e | ||
|
|
cb1347fffa | ||
|
|
48ecbd8ada | ||
|
|
e6cc08a292 | ||
|
|
120ea33547 |
@@ -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 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
|
||||
|
||||
#### example response
|
||||
|
||||
@@ -410,6 +410,9 @@
|
||||
},
|
||||
"perDay": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"e": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
@@ -1458,6 +1461,9 @@
|
||||
},
|
||||
"perDay": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"e": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
|
||||
+15
@@ -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") |
|
||||
| [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") |
|
||||
| [e](#e) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-e.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/e") |
|
||||
|
||||
## ruleId
|
||||
|
||||
@@ -208,3 +209,21 @@ https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule
|
||||
### perDay Type
|
||||
|
||||
`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`
|
||||
|
||||
+15
@@ -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`
|
||||
+15
@@ -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") |
|
||||
| [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") |
|
||||
| [e](#e) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-e.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/e") |
|
||||
|
||||
## type
|
||||
|
||||
@@ -216,3 +217,21 @@ https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelim
|
||||
### perDay Type
|
||||
|
||||
`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`
|
||||
|
||||
@@ -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") |
|
||||
| [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") |
|
||||
| [e](#e) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-e.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/e") |
|
||||
|
||||
### ruleId
|
||||
|
||||
@@ -1080,6 +1081,24 @@ Reference this group by using
|
||||
|
||||
`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
|
||||
|
||||
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") |
|
||||
| [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") |
|
||||
| [e](#e-1) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-e.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/e") |
|
||||
|
||||
### type
|
||||
|
||||
@@ -4586,6 +4606,24 @@ Reference this group by using
|
||||
|
||||
`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
|
||||
|
||||
Reference this group by using
|
||||
|
||||
@@ -57,3 +57,5 @@
|
||||
- SIGN_SECRET
|
||||
- used for signing tokens
|
||||
- if not set or set to an empty string, then the features that depend on it are disabled
|
||||
- UA_MAIL_BLOCKLIST
|
||||
- List of user agents, separated by comma, that are not allowed to trigger sign in mails
|
||||
|
||||
Generated
+129
@@ -22,6 +22,7 @@
|
||||
"nodemailer": "^7.0.9",
|
||||
"pg": "^8.5.1",
|
||||
"pg-hstore": "^2.3.3",
|
||||
"pkijs": "^3.0.16",
|
||||
"rate-limiter-flexible": "^2.1.15",
|
||||
"sequelize": "^6.25.5",
|
||||
"socket.io": "^4.0.1",
|
||||
@@ -1107,6 +1108,24 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/asn1js": {
|
||||
"version": "3.0.5",
|
||||
"resolved": "https://registry.npmjs.org/asn1js/-/asn1js-3.0.5.tgz",
|
||||
"integrity": "sha512-FVnvrKJwpt9LP2lAMl8qZswRNm3T4q9CON+bxldk2iwk3FFpuwhx2FfinyitizWHsVYyaY+y5JzDR0rCMV5yTQ==",
|
||||
"dependencies": {
|
||||
"pvtsutils": "^1.3.2",
|
||||
"pvutils": "^1.1.3",
|
||||
"tslib": "^2.4.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/asn1js/node_modules/tslib": {
|
||||
"version": "2.6.2",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
|
||||
"integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q=="
|
||||
},
|
||||
"node_modules/async": {
|
||||
"version": "3.2.3",
|
||||
"resolved": "https://registry.npmjs.org/async/-/async-3.2.3.tgz",
|
||||
@@ -1262,6 +1281,14 @@
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/bytestreamjs": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/bytestreamjs/-/bytestreamjs-2.0.1.tgz",
|
||||
"integrity": "sha512-U1Z/ob71V/bXfVABvNr/Kumf5VyeQRBEm6Txb0PQ6S7V5GpBM3w4Cbqz/xPDicR5tN0uvDifng8C+5qECeGwyQ==",
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/cacache": {
|
||||
"version": "15.3.0",
|
||||
"resolved": "https://registry.npmjs.org/cacache/-/cacache-15.3.0.tgz",
|
||||
@@ -4549,6 +4576,26 @@
|
||||
"url": "https://github.com/sponsors/jonschlinkert"
|
||||
}
|
||||
},
|
||||
"node_modules/pkijs": {
|
||||
"version": "3.0.16",
|
||||
"resolved": "https://registry.npmjs.org/pkijs/-/pkijs-3.0.16.tgz",
|
||||
"integrity": "sha512-iDUm90wfgtfd1PDV1oEnQj/4jBIU9hCSJeV0kQKThwDpbseFxC4TdpoMYlwE9maol5u0wMGZX9cNG2h1/0Lhww==",
|
||||
"dependencies": {
|
||||
"asn1js": "^3.0.5",
|
||||
"bytestreamjs": "^2.0.0",
|
||||
"pvtsutils": "^1.3.2",
|
||||
"pvutils": "^1.1.3",
|
||||
"tslib": "^2.4.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/pkijs/node_modules/tslib": {
|
||||
"version": "2.6.2",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
|
||||
"integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q=="
|
||||
},
|
||||
"node_modules/please-upgrade-node": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz",
|
||||
@@ -4658,6 +4705,27 @@
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/pvtsutils": {
|
||||
"version": "1.3.5",
|
||||
"resolved": "https://registry.npmjs.org/pvtsutils/-/pvtsutils-1.3.5.tgz",
|
||||
"integrity": "sha512-ARvb14YB9Nm2Xi6nBq1ZX6dAM0FsJnuk+31aUp4TrcZEdKUlSqOqsxJHUPJDNE3qiIp+iUPEIeR6Je/tgV7zsA==",
|
||||
"dependencies": {
|
||||
"tslib": "^2.6.1"
|
||||
}
|
||||
},
|
||||
"node_modules/pvtsutils/node_modules/tslib": {
|
||||
"version": "2.6.2",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
|
||||
"integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q=="
|
||||
},
|
||||
"node_modules/pvutils": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/pvutils/-/pvutils-1.1.3.tgz",
|
||||
"integrity": "sha512-pMpnA0qRdFp32b1sJl1wOJNxZLQ2cbQx+k6tjNtZ8CpvVhNqEPRgivZ2WOUev2YMajecdH7ctUPDvEe87nariQ==",
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/qs": {
|
||||
"version": "6.13.0",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz",
|
||||
@@ -6907,6 +6975,23 @@
|
||||
"integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==",
|
||||
"dev": true
|
||||
},
|
||||
"asn1js": {
|
||||
"version": "3.0.5",
|
||||
"resolved": "https://registry.npmjs.org/asn1js/-/asn1js-3.0.5.tgz",
|
||||
"integrity": "sha512-FVnvrKJwpt9LP2lAMl8qZswRNm3T4q9CON+bxldk2iwk3FFpuwhx2FfinyitizWHsVYyaY+y5JzDR0rCMV5yTQ==",
|
||||
"requires": {
|
||||
"pvtsutils": "^1.3.2",
|
||||
"pvutils": "^1.1.3",
|
||||
"tslib": "^2.4.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"tslib": {
|
||||
"version": "2.6.2",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
|
||||
"integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"async": {
|
||||
"version": "3.2.3",
|
||||
"resolved": "https://registry.npmjs.org/async/-/async-3.2.3.tgz",
|
||||
@@ -7025,6 +7110,11 @@
|
||||
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
|
||||
"integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg=="
|
||||
},
|
||||
"bytestreamjs": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/bytestreamjs/-/bytestreamjs-2.0.1.tgz",
|
||||
"integrity": "sha512-U1Z/ob71V/bXfVABvNr/Kumf5VyeQRBEm6Txb0PQ6S7V5GpBM3w4Cbqz/xPDicR5tN0uvDifng8C+5qECeGwyQ=="
|
||||
},
|
||||
"cacache": {
|
||||
"version": "15.3.0",
|
||||
"resolved": "https://registry.npmjs.org/cacache/-/cacache-15.3.0.tgz",
|
||||
@@ -9370,6 +9460,25 @@
|
||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
|
||||
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="
|
||||
},
|
||||
"pkijs": {
|
||||
"version": "3.0.16",
|
||||
"resolved": "https://registry.npmjs.org/pkijs/-/pkijs-3.0.16.tgz",
|
||||
"integrity": "sha512-iDUm90wfgtfd1PDV1oEnQj/4jBIU9hCSJeV0kQKThwDpbseFxC4TdpoMYlwE9maol5u0wMGZX9cNG2h1/0Lhww==",
|
||||
"requires": {
|
||||
"asn1js": "^3.0.5",
|
||||
"bytestreamjs": "^2.0.0",
|
||||
"pvtsutils": "^1.3.2",
|
||||
"pvutils": "^1.1.3",
|
||||
"tslib": "^2.4.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"tslib": {
|
||||
"version": "2.6.2",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
|
||||
"integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"please-upgrade-node": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz",
|
||||
@@ -9452,6 +9561,26 @@
|
||||
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
|
||||
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
|
||||
},
|
||||
"pvtsutils": {
|
||||
"version": "1.3.5",
|
||||
"resolved": "https://registry.npmjs.org/pvtsutils/-/pvtsutils-1.3.5.tgz",
|
||||
"integrity": "sha512-ARvb14YB9Nm2Xi6nBq1ZX6dAM0FsJnuk+31aUp4TrcZEdKUlSqOqsxJHUPJDNE3qiIp+iUPEIeR6Je/tgV7zsA==",
|
||||
"requires": {
|
||||
"tslib": "^2.6.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"tslib": {
|
||||
"version": "2.6.2",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
|
||||
"integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"pvutils": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/pvutils/-/pvutils-1.1.3.tgz",
|
||||
"integrity": "sha512-pMpnA0qRdFp32b1sJl1wOJNxZLQ2cbQx+k6tjNtZ8CpvVhNqEPRgivZ2WOUev2YMajecdH7ctUPDvEe87nariQ=="
|
||||
},
|
||||
"qs": {
|
||||
"version": "6.13.0",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz",
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
"nodemailer": "^7.0.9",
|
||||
"pg": "^8.5.1",
|
||||
"pg-hstore": "^2.3.3",
|
||||
"pkijs": "^3.0.16",
|
||||
"rate-limiter-flexible": "^2.1.15",
|
||||
"sequelize": "^6.25.5",
|
||||
"socket.io": "^4.0.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* 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
|
||||
* 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 sessionPauseMilliseconds: number
|
||||
readonly perDay: boolean
|
||||
readonly expiresAt?: number
|
||||
|
||||
constructor ({
|
||||
ruleId, maximumTimeInMillis, dayMask, applyToExtraTimeUsage,
|
||||
start, end, sessionDurationMilliseconds, sessionPauseMilliseconds,
|
||||
perDay
|
||||
perDay, expiresAt
|
||||
}: {
|
||||
ruleId: string
|
||||
maximumTimeInMillis: number
|
||||
@@ -47,6 +48,7 @@ export class UpdateTimelimitRuleAction extends ParentAction {
|
||||
sessionDurationMilliseconds: number
|
||||
sessionPauseMilliseconds: number
|
||||
perDay: boolean
|
||||
expiresAt?: number
|
||||
}) {
|
||||
super()
|
||||
|
||||
@@ -59,6 +61,7 @@ export class UpdateTimelimitRuleAction extends ParentAction {
|
||||
this.sessionDurationMilliseconds = sessionDurationMilliseconds
|
||||
this.sessionPauseMilliseconds = sessionPauseMilliseconds
|
||||
this.perDay = perDay
|
||||
this.expiresAt = expiresAt
|
||||
|
||||
assertIdWithinFamily({ actionType, field: 'ruleId', value: ruleId })
|
||||
|
||||
@@ -92,9 +95,17 @@ export class UpdateTimelimitRuleAction extends ParentAction {
|
||||
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({
|
||||
ruleId,
|
||||
maximumTimeInMillis: time,
|
||||
@@ -104,7 +115,8 @@ export class UpdateTimelimitRuleAction extends ParentAction {
|
||||
end: end ?? MinuteOfDay.MAX,
|
||||
sessionDurationMilliseconds: dur ?? 0,
|
||||
sessionPauseMilliseconds: pause ?? 0,
|
||||
perDay: perDay ?? false
|
||||
perDay: perDay ?? false,
|
||||
expiresAt: e
|
||||
})
|
||||
)
|
||||
}
|
||||
@@ -120,4 +132,5 @@ export interface SerializedUpdateTimelimitRuleAction {
|
||||
dur?: number
|
||||
pause?: number
|
||||
perDay?: boolean
|
||||
e?: number
|
||||
}
|
||||
|
||||
+13
-3
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* 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
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
@@ -17,7 +17,8 @@
|
||||
|
||||
import { json } from 'body-parser'
|
||||
import { Router } from 'express'
|
||||
import { BadRequest } from 'http-errors'
|
||||
import { BadRequest, Forbidden } from 'http-errors'
|
||||
import { config } from '../config'
|
||||
import { Database } from '../database'
|
||||
import { sendLoginCode, signInByMailCode } from '../function/authentication/login-by-mail'
|
||||
import { isMailAddressCoveredByWhitelist, isMailServerBlacklisted, sanitizeMailAddress } from '../util/mail'
|
||||
@@ -25,11 +26,17 @@ import {
|
||||
isSendMailLoginCodeRequest,
|
||||
isSignInByMailCodeRequest
|
||||
} from './validator'
|
||||
import { analyze } from './integrity'
|
||||
|
||||
export const createAuthRouter = (database: Database) => {
|
||||
const router = Router()
|
||||
|
||||
router.post('/send-mail-login-code-v2', json(), async (req, res, next) => {
|
||||
const info = {
|
||||
ua: req.headers['user-agent'],
|
||||
cert: analyze(req),
|
||||
}
|
||||
|
||||
try {
|
||||
if (!isSendMailLoginCodeRequest(req.body)) {
|
||||
throw new BadRequest()
|
||||
@@ -45,12 +52,15 @@ export const createAuthRouter = (database: Database) => {
|
||||
res.json({ mailAddressNotWhitelisted: true })
|
||||
} else if (isMailServerBlacklisted(mail)) {
|
||||
res.json({ mailServerBlacklisted: true })
|
||||
} else if (config.uaMailBlocklist.indexOf(req.headers['user-agent'] || '') !== -1) {
|
||||
throw new Forbidden()
|
||||
} else {
|
||||
const { mailLoginToken } = await sendLoginCode({
|
||||
mail,
|
||||
deviceAuthToken: req.body.deviceAuthToken,
|
||||
locale: req.body.locale,
|
||||
database
|
||||
database,
|
||||
info: Buffer.from(JSON.stringify(info), 'utf8')
|
||||
})
|
||||
|
||||
res.json({ mailLoginToken })
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
import { X509Certificate } from 'crypto'
|
||||
import { Request } from 'express'
|
||||
import { fromBER, Sequence, Integer, OctetString, Set } from 'asn1js'
|
||||
import { Certificate } from 'pkijs'
|
||||
|
||||
export interface CertInfo {
|
||||
applicationCerts: Array<string>
|
||||
}
|
||||
|
||||
export function analyze(req: Request): CertInfo | null {
|
||||
try {
|
||||
const certStr = req.headers['clientcertificate']
|
||||
|
||||
if (typeof certStr !== 'string') return null
|
||||
|
||||
const nativeCert = new X509Certificate(decodeURIComponent(certStr))
|
||||
|
||||
const now = Date.now()
|
||||
const from = Date.parse(nativeCert.validFrom)
|
||||
const to = Date.parse(nativeCert.validTo)
|
||||
|
||||
if (from > now || to < now) return null
|
||||
if (from > to || from + 1000 * 60 * 5 < to) return null
|
||||
|
||||
const cert1 = fromBER(nativeCert.raw)
|
||||
|
||||
if (cert1.offset === -1) return null
|
||||
|
||||
const cert2 = new Certificate({ schema: cert1.result })
|
||||
const androidExtension = (cert2.extensions || []).find((item) => item.extnID === '1.3.6.1.4.1.11129.2.1.17')?.extnValue?.valueBlock?.valueHexView
|
||||
|
||||
if (!androidExtension) return null
|
||||
|
||||
const androidExtensionParsed = fromBER(androidExtension)
|
||||
|
||||
if (androidExtensionParsed.offset === -1) return null
|
||||
|
||||
const androidExtensionSequence = androidExtensionParsed.result
|
||||
|
||||
if (!(androidExtensionSequence instanceof Sequence)) return null
|
||||
|
||||
const versionInteger = androidExtensionSequence.valueBlock.value[0]
|
||||
|
||||
if (!(versionInteger instanceof Integer)) return null
|
||||
|
||||
const versionValue = versionInteger.valueBlock.valueDec
|
||||
|
||||
const authorizationLists = androidExtensionSequence.valueBlock.value.slice(6, 8)
|
||||
|
||||
let applicationId = null
|
||||
|
||||
for (const authList of authorizationLists) {
|
||||
if (!(authList instanceof Sequence)) continue
|
||||
|
||||
for (const authListItem of authList.valueBlock.value) {
|
||||
if (
|
||||
// version 1 does not provide this data structure
|
||||
versionValue !== 1 &&
|
||||
authListItem.idBlock.tagNumber === 709
|
||||
) {
|
||||
if (!('value' in authListItem.valueBlock)) continue
|
||||
|
||||
const value = (authListItem.valueBlock as unknown as { value: object }).value
|
||||
|
||||
if (!Array.isArray(value) || value.length !== 1) continue
|
||||
|
||||
if (value[0] instanceof OctetString) applicationId = value[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!applicationId) return null
|
||||
|
||||
const parsedApplicationId = fromBER(applicationId.valueBlock.valueHexView)
|
||||
|
||||
if (parsedApplicationId.offset === -1) return null
|
||||
|
||||
if (!(parsedApplicationId.result instanceof Sequence)) return null
|
||||
|
||||
const parsedApplicationIdInfo = parsedApplicationId.result.valueBlock.value
|
||||
|
||||
if (parsedApplicationIdInfo.length !== 2) return null
|
||||
|
||||
const signatureDigests = parsedApplicationIdInfo[1]
|
||||
|
||||
if (!(signatureDigests instanceof Set)) return null
|
||||
|
||||
const applicationCerts = []
|
||||
|
||||
for (const cert of signatureDigests.valueBlock.value) {
|
||||
if (cert instanceof OctetString) {
|
||||
applicationCerts.push(Buffer.from(cert.valueBlock.valueHexView).toString('hex'))
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
applicationCerts
|
||||
}
|
||||
} catch (ex) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
@@ -409,6 +409,9 @@ const definitions = {
|
||||
},
|
||||
"perDay": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"e": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
@@ -1417,6 +1420,9 @@ const definitions = {
|
||||
},
|
||||
"perDay": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"e": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
|
||||
+9
-3
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* 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
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
@@ -22,6 +22,7 @@ interface Config {
|
||||
pingInterval: number
|
||||
alwaysPro: boolean
|
||||
signSecret: string
|
||||
uaMailBlocklist: Array<string>
|
||||
}
|
||||
|
||||
function parseYesNo (value: string) {
|
||||
@@ -34,12 +35,17 @@ function parseYesNo (value: string) {
|
||||
}
|
||||
}
|
||||
|
||||
function parseList(list: string) {
|
||||
return list.split(',').map((item) => item.trim()).filter((item) => item.length > 0)
|
||||
}
|
||||
|
||||
class ParseYesNoException extends Error {}
|
||||
|
||||
export const config: Config = {
|
||||
mailWhitelist: (process.env.MAIL_WHITELIST || '').split(',').map((item) => item.trim()).filter((item) => item.length > 0),
|
||||
mailWhitelist: parseList(process.env.MAIL_WHITELIST || ''),
|
||||
disableSignup: parseYesNo(process.env.DISABLE_SIGNUP || 'no'),
|
||||
pingInterval: parseInt(process.env.PING_INTERVAL_SEC || '25', 10) * 1000,
|
||||
alwaysPro: process.env.ALWAYS_PRO ? parseYesNo(process.env.ALWAYS_PRO) : false,
|
||||
signSecret: process.env.SIGN_SECRET || ''
|
||||
signSecret: process.env.SIGN_SECRET || '',
|
||||
uaMailBlocklist: parseList(process.env.UA_MAIL_BLOCKLIST || '')
|
||||
}
|
||||
|
||||
@@ -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 })
|
||||
})
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* 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
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
@@ -41,8 +41,13 @@ interface TimelimitRuleAttributesVersion3 {
|
||||
perDay: number
|
||||
}
|
||||
|
||||
interface TimelimitRuleAttributesVersion4 {
|
||||
expiresAt: string | null
|
||||
}
|
||||
|
||||
type TimelimitRuleAttributes = TimelimitRuleAttributesVersion1 &
|
||||
TimelimitRuleAttributesVersion2 & TimelimitRuleAttributesVersion3
|
||||
TimelimitRuleAttributesVersion2 & TimelimitRuleAttributesVersion3 &
|
||||
TimelimitRuleAttributesVersion4
|
||||
|
||||
export type TimelimitRuleModel = Sequelize.Model<TimelimitRuleAttributes> & TimelimitRuleAttributes
|
||||
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> = {
|
||||
...attributesVersion1,
|
||||
...attributesVersion2,
|
||||
...attributesVersion3
|
||||
...attributesVersion3,
|
||||
...attributesVersion4
|
||||
}
|
||||
|
||||
export const createTimelimitRuleModel = (sequelize: Sequelize.Sequelize): TimelimitRuleModelStatic => sequelize.define('TimelimitRule', attributes) as TimelimitRuleModelStatic
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* 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
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
@@ -23,11 +23,12 @@ import { checkMailSendLimit } from '../../util/ratelimit-authmail'
|
||||
import { generateAuthToken } from '../../util/token'
|
||||
import { createAuthTokenByMailAddress } from './index'
|
||||
|
||||
export const sendLoginCode = async ({ mail, deviceAuthToken, locale, database }: {
|
||||
export const sendLoginCode = async ({ mail, deviceAuthToken, locale, database, info }: {
|
||||
mail: string
|
||||
deviceAuthToken?: string
|
||||
locale: string
|
||||
database: Database
|
||||
info: Buffer
|
||||
// no transaction here because this is directly called from an API endpoint
|
||||
}): Promise<{ mailLoginToken: string }> => {
|
||||
let deviceName = null
|
||||
@@ -82,7 +83,8 @@ export const sendLoginCode = async ({ mail, deviceAuthToken, locale, database }:
|
||||
receiver: mail,
|
||||
code,
|
||||
locale,
|
||||
deviceName
|
||||
deviceName,
|
||||
info
|
||||
})
|
||||
|
||||
await database.transaction(async (transaction) => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* 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
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
@@ -55,7 +55,8 @@ export async function dispatchCreateTimeLimitRule ({ action, cache, fromChildSel
|
||||
endMinuteOfDay: action.rule.end,
|
||||
sessionDurationMilliseconds: action.rule.sessionDurationMilliseconds,
|
||||
sessionPauseMilliseconds: action.rule.sessionPauseMilliseconds,
|
||||
perDay: action.rule.perDay ? 1 : 0
|
||||
perDay: action.rule.perDay ? 1 : 0,
|
||||
expiresAt: action.rule.expiresAt ? action.rule.expiresAt.toString() : null
|
||||
}, { transaction: cache.transaction })
|
||||
|
||||
cache.categoriesWithModifiedTimeLimitRules.add(action.rule.categoryId)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* 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
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
@@ -81,7 +81,8 @@ export async function dispatchUpdateTimelimitRule ({
|
||||
action.sessionDurationMilliseconds <= ruleEntry.sessionDurationMilliseconds &&
|
||||
action.sessionPauseMilliseconds >= ruleEntry.sessionPauseMilliseconds
|
||||
)) &&
|
||||
(!action.perDay || ruleEntry.perDay || countOldAffectedDays <= 1)
|
||||
(!action.perDay || ruleEntry.perDay || countOldAffectedDays <= 1) &&
|
||||
(action.expiresAt === undefined || (ruleEntry.expiresAt !== null && action.expiresAt >= parseInt(ruleEntry.expiresAt, 10)))
|
||||
|
||||
if (!isAtLeastAsStrictAsPreviously) {
|
||||
throw new CanNotRelaxRestrictionsSelfLimitException()
|
||||
@@ -96,6 +97,7 @@ export async function dispatchUpdateTimelimitRule ({
|
||||
ruleEntry.sessionDurationMilliseconds = action.sessionDurationMilliseconds
|
||||
ruleEntry.sessionPauseMilliseconds = action.sessionPauseMilliseconds
|
||||
ruleEntry.perDay = action.perDay ? 1 : 0
|
||||
ruleEntry.expiresAt = action.expiresAt ? action.expiresAt.toString() : null
|
||||
|
||||
await ruleEntry.save({ transaction: cache.transaction })
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* 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
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
@@ -45,7 +45,8 @@ export async function getRules ({ database, transaction, categoryIdsToSyncRules,
|
||||
'endMinuteOfDay',
|
||||
'sessionDurationMilliseconds',
|
||||
'sessionPauseMilliseconds',
|
||||
'perDay'
|
||||
'perDay',
|
||||
'expiresAt'
|
||||
],
|
||||
transaction
|
||||
})).map((item) => ({
|
||||
@@ -58,7 +59,8 @@ export async function getRules ({ database, transaction, categoryIdsToSyncRules,
|
||||
endMinuteOfDay: item.endMinuteOfDay,
|
||||
sessionDurationMilliseconds: item.sessionDurationMilliseconds,
|
||||
sessionPauseMilliseconds: item.sessionPauseMilliseconds,
|
||||
perDay: item.perDay
|
||||
perDay: item.perDay,
|
||||
expiresAt: item.expiresAt ? parseInt(item.expiresAt, 10) : undefined
|
||||
}))
|
||||
|
||||
const getCategoryRulesVersion = (categoryId: string) => (
|
||||
@@ -76,7 +78,8 @@ export async function getRules ({ database, transaction, categoryIdsToSyncRules,
|
||||
end: item.endMinuteOfDay,
|
||||
session: item.sessionDurationMilliseconds,
|
||||
pause: item.sessionPauseMilliseconds,
|
||||
perDay: item.perDay !== 0 ? true : false
|
||||
perDay: item.perDay !== 0 ? true : false,
|
||||
e: item.expiresAt
|
||||
})),
|
||||
version: getCategoryRulesVersion(categoryId)
|
||||
}))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* 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
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
@@ -58,7 +58,7 @@ export const generateServerDataStatus = async ({
|
||||
familyEntry.hasFullVersion ? parseInt(familyEntry.fullVersionUntil, 10) : 0
|
||||
),
|
||||
message: await getStatusMessage({ database, transaction }) || undefined,
|
||||
apiLevel: 7
|
||||
apiLevel: 8
|
||||
}
|
||||
|
||||
if (familyEntry.deviceListVersion !== clientStatus.devices) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* 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
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
@@ -29,11 +29,12 @@ export class TimelimitRule {
|
||||
readonly sessionDurationMilliseconds: number
|
||||
readonly sessionPauseMilliseconds: number
|
||||
readonly perDay: boolean
|
||||
readonly expiresAt?: number
|
||||
|
||||
constructor ({
|
||||
ruleId, categoryId, maxTimeInMillis, dayMask, applyToExtraTimeUsage,
|
||||
start, end, sessionDurationMilliseconds, sessionPauseMilliseconds,
|
||||
perDay
|
||||
perDay, expiresAt
|
||||
}: {
|
||||
ruleId: string
|
||||
categoryId: string
|
||||
@@ -45,6 +46,7 @@ export class TimelimitRule {
|
||||
sessionDurationMilliseconds: number
|
||||
sessionPauseMilliseconds: number
|
||||
perDay: boolean
|
||||
expiresAt?: number
|
||||
}) {
|
||||
this.ruleId = ruleId
|
||||
this.categoryId = categoryId
|
||||
@@ -56,6 +58,7 @@ export class TimelimitRule {
|
||||
this.sessionDurationMilliseconds = sessionDurationMilliseconds
|
||||
this.sessionPauseMilliseconds = sessionPauseMilliseconds
|
||||
this.perDay = perDay
|
||||
this.expiresAt = expiresAt
|
||||
|
||||
assertIdWithinFamily(ruleId)
|
||||
assertIdWithinFamily(categoryId)
|
||||
@@ -88,6 +91,14 @@ export class TimelimitRule {
|
||||
if (sessionDurationMilliseconds < 0 || sessionPauseMilliseconds < 0) {
|
||||
throw new ParseTimeLimitRuleException()
|
||||
}
|
||||
|
||||
if (expiresAt !== undefined) {
|
||||
if (!Number.isSafeInteger(expiresAt)) throw new ParseTimeLimitRuleException()
|
||||
|
||||
if (expiresAt <= 0) {
|
||||
throw new ParseTimeLimitRuleException()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
serialize = (): SerializedTimeLimitRule => ({
|
||||
@@ -99,10 +110,11 @@ export class TimelimitRule {
|
||||
start: this.start,
|
||||
end: this.end,
|
||||
pause: this.sessionPauseMilliseconds,
|
||||
dur: this.sessionDurationMilliseconds
|
||||
dur: this.sessionDurationMilliseconds,
|
||||
e: this.expiresAt
|
||||
})
|
||||
|
||||
static parse = ({ ruleId, categoryId, time, days, extraTime, start, end, dur, pause, perDay }: SerializedTimeLimitRule) => (
|
||||
static parse = ({ ruleId, categoryId, time, days, extraTime, start, end, dur, pause, perDay, e }: SerializedTimeLimitRule) => (
|
||||
new TimelimitRule({
|
||||
ruleId,
|
||||
categoryId,
|
||||
@@ -113,7 +125,8 @@ export class TimelimitRule {
|
||||
end: end ?? MinuteOfDay.MAX,
|
||||
sessionDurationMilliseconds: dur ?? 0,
|
||||
sessionPauseMilliseconds: pause ?? 0,
|
||||
perDay: perDay ?? false
|
||||
perDay: perDay ?? false,
|
||||
expiresAt: e
|
||||
})
|
||||
)
|
||||
}
|
||||
@@ -129,6 +142,7 @@ export interface SerializedTimeLimitRule {
|
||||
dur?: number
|
||||
pause?: number
|
||||
perDay?: boolean
|
||||
e?: number // expiresAt
|
||||
}
|
||||
|
||||
export class ParseTimeLimitRuleException extends Error {}
|
||||
|
||||
+16
-6
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* 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
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
@@ -45,9 +45,10 @@ function createMailTemplateSender (templateName: string) {
|
||||
const textTemplate = compileTemplate('text.ejs')
|
||||
const htmlTemplate = compileTemplate('html.ejs')
|
||||
|
||||
const sendMail = async ({ receiver, params }: {
|
||||
const sendMail = async ({ receiver, params, info }: {
|
||||
receiver: string
|
||||
params: object
|
||||
info?: Buffer
|
||||
}) => {
|
||||
if (!mailTransport) {
|
||||
throw new Error('can not send mails without mail config and without NODE_ENV=development')
|
||||
@@ -56,6 +57,9 @@ function createMailTemplateSender (templateName: string) {
|
||||
const subject = subjectTemplate(params).replace(/\n/g, ' ')
|
||||
const text = textTemplate(params)
|
||||
const html = htmlTemplate(params)
|
||||
const headers: {[key: string]: string} = info ? {
|
||||
'X-TlInfo': info.toString('base64')
|
||||
} : {}
|
||||
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
mailTransport.sendMail({
|
||||
@@ -63,7 +67,8 @@ function createMailTemplateSender (templateName: string) {
|
||||
to: receiver,
|
||||
subject,
|
||||
text,
|
||||
html
|
||||
html,
|
||||
headers
|
||||
}, (err, info) => {
|
||||
if (err) {
|
||||
reject(err)
|
||||
@@ -90,9 +95,13 @@ function createMailTemplateSender (templateName: string) {
|
||||
const loginMailSender = createMailTemplateSender('login')
|
||||
|
||||
export const sendAuthenticationMail = async ({
|
||||
receiver, code, locale, deviceName
|
||||
receiver, code, locale, deviceName, info
|
||||
}: {
|
||||
receiver: string, code: string, locale: string, deviceName: string | null
|
||||
receiver: string
|
||||
code: string
|
||||
locale: string
|
||||
deviceName: string | null
|
||||
info: Buffer
|
||||
}) => {
|
||||
await loginMailSender.sendMail({
|
||||
receiver,
|
||||
@@ -105,7 +114,8 @@ export const sendAuthenticationMail = async ({
|
||||
deviceName,
|
||||
deviceNameIntro: locale === 'de' ? 'Die Anmeldung wurde am Gerät' : 'The login was attempted at the device',
|
||||
deviceNameOutro: locale === 'de' ? 'versucht.' : '.'
|
||||
}
|
||||
},
|
||||
info
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user