mirror of
https://codeberg.org/timelimit/timelimit-server.git
synced 2025-10-03 09:49:32 +02:00
Replace tslint by eslint
This commit is contained in:
parent
b43059f8e2
commit
f028b99bbc
24 changed files with 2498 additions and 311 deletions
3
.eslintignore
Normal file
3
.eslintignore
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
node_modules
|
||||||
|
build
|
||||||
|
scripts
|
14
.eslintrc.js
Normal file
14
.eslintrc.js
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
module.exports = {
|
||||||
|
root: true,
|
||||||
|
parser: '@typescript-eslint/parser',
|
||||||
|
plugins: [
|
||||||
|
'@typescript-eslint',
|
||||||
|
],
|
||||||
|
extends: [
|
||||||
|
'eslint:recommended',
|
||||||
|
'plugin:@typescript-eslint/recommended',
|
||||||
|
],
|
||||||
|
env: {
|
||||||
|
node: true
|
||||||
|
}
|
||||||
|
};
|
2648
package-lock.json
generated
2648
package-lock.json
generated
File diff suppressed because it is too large
Load diff
11
package.json
11
package.json
|
@ -6,8 +6,8 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node ./build/index.js",
|
"start": "node ./build/index.js",
|
||||||
"test": "node scripts/test-launch-with-different-databases.js",
|
"test": "node scripts/test-launch-with-different-databases.js",
|
||||||
"lint": "tslint --project .",
|
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
|
||||||
"lint:fix": "tslint --project . --fix",
|
"lint:fix": "eslint . --ext .js,.jsx,.ts,.tsx --fix",
|
||||||
"build": "npm run build:clean && npm run build:json && npm run build:ts && npm run lint && npm run build:doc",
|
"build": "npm run build:clean && npm run build:json && npm run build:ts && npm run lint && npm run build:doc",
|
||||||
"build:clean": "rimraf build",
|
"build:clean": "rimraf build",
|
||||||
"build:json": "node ./scripts/build-schemas.js",
|
"build:json": "node ./scripts/build-schemas.js",
|
||||||
|
@ -40,10 +40,11 @@
|
||||||
"@types/nodemailer": "^6.4.4",
|
"@types/nodemailer": "^6.4.4",
|
||||||
"@types/tokgen": "^1.0.0",
|
"@types/tokgen": "^1.0.0",
|
||||||
"@types/umzug": "^2.3.0",
|
"@types/umzug": "^2.3.0",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^5.10.0",
|
||||||
|
"@typescript-eslint/parser": "^5.10.0",
|
||||||
|
"eslint": "^8.7.0",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"tslint": "^6.1.3",
|
"typescript": "^4.4.4",
|
||||||
"tslint-config-standard": "^9.0.0",
|
|
||||||
"typescript": "^4.1.3",
|
|
||||||
"typescript-json-schema": "^0.52.0"
|
"typescript-json-schema": "^0.52.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -115,7 +115,7 @@ types.forEach((type) => {
|
||||||
const functionBody = 'ajv.compile(' + schemaString + ')'
|
const functionBody = 'ajv.compile(' + schemaString + ')'
|
||||||
const functionName = 'is' + type.substr(0, 1).toUpperCase() + type.substr(1)
|
const functionName = 'is' + type.substr(0, 1).toUpperCase() + type.substr(1)
|
||||||
|
|
||||||
output += 'export const ' + functionName + ': (value: object) => value is ' + type + ' = ' + functionBody + '\n'
|
output += 'export const ' + functionName + ': (value: unknown) => value is ' + type + ' = ' + functionBody + '\n'
|
||||||
})
|
})
|
||||||
|
|
||||||
allTypes.forEach((type) => {
|
allTypes.forEach((type) => {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2020 Jonas Lochmann
|
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
@ -18,13 +18,11 @@
|
||||||
import { ChildAction } from './basetypes'
|
import { ChildAction } from './basetypes'
|
||||||
|
|
||||||
export class ChildSignInAction extends ChildAction {
|
export class ChildSignInAction extends ChildAction {
|
||||||
|
static instance = new ChildSignInAction()
|
||||||
|
|
||||||
constructor () {
|
constructor () {
|
||||||
super()
|
super()
|
||||||
}
|
}
|
||||||
|
|
||||||
static parse = (_: SerializedChildSignInAction) => (
|
|
||||||
new ChildSignInAction()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SerializedChildSignInAction {
|
export interface SerializedChildSignInAction {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2020 Jonas Lochmann
|
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
@ -23,8 +23,6 @@ export class ForceSyncAction extends AppLogicAction {
|
||||||
private constructor () {
|
private constructor () {
|
||||||
super()
|
super()
|
||||||
}
|
}
|
||||||
|
|
||||||
static parse = (_: SerializedForceSyncAction) => ForceSyncAction.instance
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SerializedForceSyncAction {
|
export interface SerializedForceSyncAction {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2020 Jonas Lochmann
|
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
@ -48,13 +48,13 @@ export const parseAppLogicAction = (serialized: SerializedAppLogicAction): AppLo
|
||||||
} else if (serialized.type === 'ADD_INSTALLED_APPS') {
|
} else if (serialized.type === 'ADD_INSTALLED_APPS') {
|
||||||
return AddInstalledAppsAction.parse(serialized)
|
return AddInstalledAppsAction.parse(serialized)
|
||||||
} else if (serialized.type === 'FORCE_SYNC') {
|
} else if (serialized.type === 'FORCE_SYNC') {
|
||||||
return ForceSyncAction.parse(serialized)
|
return ForceSyncAction.instance
|
||||||
} else if (serialized.type === 'MARK_TASK_PENDING') {
|
} else if (serialized.type === 'MARK_TASK_PENDING') {
|
||||||
return MarkTaskPendingAction.parse(serialized)
|
return MarkTaskPendingAction.parse(serialized)
|
||||||
} else if (serialized.type === 'REMOVE_INSTALLED_APPS') {
|
} else if (serialized.type === 'REMOVE_INSTALLED_APPS') {
|
||||||
return RemoveInstalledAppsAction.parse(serialized)
|
return RemoveInstalledAppsAction.parse(serialized)
|
||||||
} else if (serialized.type === 'SIGN_OUT_AT_DEVICE') {
|
} else if (serialized.type === 'SIGN_OUT_AT_DEVICE') {
|
||||||
return SignOutAtDeviceAction.parse(serialized)
|
return SignOutAtDeviceAction.instance
|
||||||
} else if (serialized.type === 'TRIED_DISABLING_DEVICE_ADMIN') {
|
} else if (serialized.type === 'TRIED_DISABLING_DEVICE_ADMIN') {
|
||||||
return new TriedDisablingDeviceAdminAction()
|
return new TriedDisablingDeviceAdminAction()
|
||||||
} else if (serialized.type === 'UPDATE_APP_ACTIVITIES') {
|
} else if (serialized.type === 'UPDATE_APP_ACTIVITIES') {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2020 Jonas Lochmann
|
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
@ -25,7 +25,7 @@ export const parseChildAction = (serialized: SerializedChildAction) => {
|
||||||
if (serialized.type === 'CHILD_CHANGE_PASSWORD') {
|
if (serialized.type === 'CHILD_CHANGE_PASSWORD') {
|
||||||
return ChildChangePasswordAction.parse(serialized)
|
return ChildChangePasswordAction.parse(serialized)
|
||||||
} else if (serialized.type === 'CHILD_SIGN_IN') {
|
} else if (serialized.type === 'CHILD_SIGN_IN') {
|
||||||
return ChildSignInAction.parse(serialized)
|
return ChildSignInAction.instance
|
||||||
} else {
|
} else {
|
||||||
throw new UnknownActionTypeException({ group: 'child' })
|
throw new UnknownActionTypeException({ group: 'child' })
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,6 @@ export class SignOutAtDeviceAction extends AppLogicAction {
|
||||||
private constructor () {
|
private constructor () {
|
||||||
super()
|
super()
|
||||||
}
|
}
|
||||||
|
|
||||||
static parse = (_: SerializedSignOutAtDeviceAction) => SignOutAtDeviceAction.instance
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SerializedSignOutAtDeviceAction {
|
export interface SerializedSignOutAtDeviceAction {
|
||||||
|
|
|
@ -2426,7 +2426,7 @@ const definitions = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const isClientPushChangesRequest: (value: object) => value is ClientPushChangesRequest = ajv.compile({
|
export const isClientPushChangesRequest: (value: unknown) => value is ClientPushChangesRequest = ajv.compile({
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"deviceAuthToken": {
|
"deviceAuthToken": {
|
||||||
|
@ -2447,7 +2447,7 @@ export const isClientPushChangesRequest: (value: object) => value is ClientPushC
|
||||||
"definitions": definitions,
|
"definitions": definitions,
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#"
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
||||||
})
|
})
|
||||||
export const isClientPullChangesRequest: (value: object) => value is ClientPullChangesRequest = ajv.compile({
|
export const isClientPullChangesRequest: (value: unknown) => value is ClientPullChangesRequest = ajv.compile({
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"deviceAuthToken": {
|
"deviceAuthToken": {
|
||||||
|
@ -2465,7 +2465,7 @@ export const isClientPullChangesRequest: (value: object) => value is ClientPullC
|
||||||
"definitions": definitions,
|
"definitions": definitions,
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#"
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
||||||
})
|
})
|
||||||
export const isMailAuthTokenRequestBody: (value: object) => value is MailAuthTokenRequestBody = ajv.compile({
|
export const isMailAuthTokenRequestBody: (value: unknown) => value is MailAuthTokenRequestBody = ajv.compile({
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"mailAuthToken": {
|
"mailAuthToken": {
|
||||||
|
@ -2479,7 +2479,7 @@ export const isMailAuthTokenRequestBody: (value: object) => value is MailAuthTok
|
||||||
"definitions": definitions,
|
"definitions": definitions,
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#"
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
||||||
})
|
})
|
||||||
export const isCreateFamilyByMailTokenRequest: (value: object) => value is CreateFamilyByMailTokenRequest = ajv.compile({
|
export const isCreateFamilyByMailTokenRequest: (value: unknown) => value is CreateFamilyByMailTokenRequest = ajv.compile({
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"mailAuthToken": {
|
"mailAuthToken": {
|
||||||
|
@ -2513,7 +2513,7 @@ export const isCreateFamilyByMailTokenRequest: (value: object) => value is Creat
|
||||||
"definitions": definitions,
|
"definitions": definitions,
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#"
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
||||||
})
|
})
|
||||||
export const isSignIntoFamilyRequest: (value: object) => value is SignIntoFamilyRequest = ajv.compile({
|
export const isSignIntoFamilyRequest: (value: unknown) => value is SignIntoFamilyRequest = ajv.compile({
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"mailAuthToken": {
|
"mailAuthToken": {
|
||||||
|
@ -2535,7 +2535,7 @@ export const isSignIntoFamilyRequest: (value: object) => value is SignIntoFamily
|
||||||
"definitions": definitions,
|
"definitions": definitions,
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#"
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
||||||
})
|
})
|
||||||
export const isRecoverParentPasswordRequest: (value: object) => value is RecoverParentPasswordRequest = ajv.compile({
|
export const isRecoverParentPasswordRequest: (value: unknown) => value is RecoverParentPasswordRequest = ajv.compile({
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"mailAuthToken": {
|
"mailAuthToken": {
|
||||||
|
@ -2553,7 +2553,7 @@ export const isRecoverParentPasswordRequest: (value: object) => value is Recover
|
||||||
"definitions": definitions,
|
"definitions": definitions,
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#"
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
||||||
})
|
})
|
||||||
export const isRegisterChildDeviceRequest: (value: object) => value is RegisterChildDeviceRequest = ajv.compile({
|
export const isRegisterChildDeviceRequest: (value: unknown) => value is RegisterChildDeviceRequest = ajv.compile({
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"registerToken": {
|
"registerToken": {
|
||||||
|
@ -2575,7 +2575,7 @@ export const isRegisterChildDeviceRequest: (value: object) => value is RegisterC
|
||||||
"definitions": definitions,
|
"definitions": definitions,
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#"
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
||||||
})
|
})
|
||||||
export const isSerializedParentAction: (value: object) => value is SerializedParentAction = ajv.compile({
|
export const isSerializedParentAction: (value: unknown) => value is SerializedParentAction = ajv.compile({
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/SerializedAddCategoryAppsAction"
|
"$ref": "#/definitions/SerializedAddCategoryAppsAction"
|
||||||
|
@ -2722,7 +2722,7 @@ export const isSerializedParentAction: (value: object) => value is SerializedPar
|
||||||
"definitions": definitions,
|
"definitions": definitions,
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#"
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
||||||
})
|
})
|
||||||
export const isSerializedAppLogicAction: (value: object) => value is SerializedAppLogicAction = ajv.compile({
|
export const isSerializedAppLogicAction: (value: unknown) => value is SerializedAppLogicAction = ajv.compile({
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/SerializedAddInstalledAppsAction"
|
"$ref": "#/definitions/SerializedAddInstalledAppsAction"
|
||||||
|
@ -2758,7 +2758,7 @@ export const isSerializedAppLogicAction: (value: object) => value is SerializedA
|
||||||
"definitions": definitions,
|
"definitions": definitions,
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#"
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
||||||
})
|
})
|
||||||
export const isSerializedChildAction: (value: object) => value is SerializedChildAction = ajv.compile({
|
export const isSerializedChildAction: (value: unknown) => value is SerializedChildAction = ajv.compile({
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/SerializedChildChangePasswordAction"
|
"$ref": "#/definitions/SerializedChildChangePasswordAction"
|
||||||
|
@ -2770,7 +2770,7 @@ export const isSerializedChildAction: (value: object) => value is SerializedChil
|
||||||
"definitions": definitions,
|
"definitions": definitions,
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#"
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
||||||
})
|
})
|
||||||
export const isCreateRegisterDeviceTokenRequest: (value: object) => value is CreateRegisterDeviceTokenRequest = ajv.compile({
|
export const isCreateRegisterDeviceTokenRequest: (value: unknown) => value is CreateRegisterDeviceTokenRequest = ajv.compile({
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"deviceAuthToken": {
|
"deviceAuthToken": {
|
||||||
|
@ -2792,7 +2792,7 @@ export const isCreateRegisterDeviceTokenRequest: (value: object) => value is Cre
|
||||||
"definitions": definitions,
|
"definitions": definitions,
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#"
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
||||||
})
|
})
|
||||||
export const isCanDoPurchaseRequest: (value: object) => value is CanDoPurchaseRequest = ajv.compile({
|
export const isCanDoPurchaseRequest: (value: unknown) => value is CanDoPurchaseRequest = ajv.compile({
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"type": {
|
"type": {
|
||||||
|
@ -2814,7 +2814,7 @@ export const isCanDoPurchaseRequest: (value: object) => value is CanDoPurchaseRe
|
||||||
"definitions": definitions,
|
"definitions": definitions,
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#"
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
||||||
})
|
})
|
||||||
export const isFinishPurchaseByGooglePlayRequest: (value: object) => value is FinishPurchaseByGooglePlayRequest = ajv.compile({
|
export const isFinishPurchaseByGooglePlayRequest: (value: unknown) => value is FinishPurchaseByGooglePlayRequest = ajv.compile({
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"deviceAuthToken": {
|
"deviceAuthToken": {
|
||||||
|
@ -2836,7 +2836,7 @@ export const isFinishPurchaseByGooglePlayRequest: (value: object) => value is Fi
|
||||||
"definitions": definitions,
|
"definitions": definitions,
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#"
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
||||||
})
|
})
|
||||||
export const isLinkParentMailAddressRequest: (value: object) => value is LinkParentMailAddressRequest = ajv.compile({
|
export const isLinkParentMailAddressRequest: (value: unknown) => value is LinkParentMailAddressRequest = ajv.compile({
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"mailAuthToken": {
|
"mailAuthToken": {
|
||||||
|
@ -2862,7 +2862,7 @@ export const isLinkParentMailAddressRequest: (value: object) => value is LinkPar
|
||||||
"definitions": definitions,
|
"definitions": definitions,
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#"
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
||||||
})
|
})
|
||||||
export const isUpdatePrimaryDeviceRequest: (value: object) => value is UpdatePrimaryDeviceRequest = ajv.compile({
|
export const isUpdatePrimaryDeviceRequest: (value: unknown) => value is UpdatePrimaryDeviceRequest = ajv.compile({
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"action": {
|
"action": {
|
||||||
|
@ -2888,7 +2888,7 @@ export const isUpdatePrimaryDeviceRequest: (value: object) => value is UpdatePri
|
||||||
"definitions": definitions,
|
"definitions": definitions,
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#"
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
||||||
})
|
})
|
||||||
export const isRemoveDeviceRequest: (value: object) => value is RemoveDeviceRequest = ajv.compile({
|
export const isRemoveDeviceRequest: (value: unknown) => value is RemoveDeviceRequest = ajv.compile({
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"deviceAuthToken": {
|
"deviceAuthToken": {
|
||||||
|
@ -2914,7 +2914,7 @@ export const isRemoveDeviceRequest: (value: object) => value is RemoveDeviceRequ
|
||||||
"definitions": definitions,
|
"definitions": definitions,
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#"
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
||||||
})
|
})
|
||||||
export const isRequestWithAuthToken: (value: object) => value is RequestWithAuthToken = ajv.compile({
|
export const isRequestWithAuthToken: (value: unknown) => value is RequestWithAuthToken = ajv.compile({
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"deviceAuthToken": {
|
"deviceAuthToken": {
|
||||||
|
@ -2928,7 +2928,7 @@ export const isRequestWithAuthToken: (value: object) => value is RequestWithAuth
|
||||||
"definitions": definitions,
|
"definitions": definitions,
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#"
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
||||||
})
|
})
|
||||||
export const isSendMailLoginCodeRequest: (value: object) => value is SendMailLoginCodeRequest = ajv.compile({
|
export const isSendMailLoginCodeRequest: (value: unknown) => value is SendMailLoginCodeRequest = ajv.compile({
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"mail": {
|
"mail": {
|
||||||
|
@ -2949,7 +2949,7 @@ export const isSendMailLoginCodeRequest: (value: object) => value is SendMailLog
|
||||||
"definitions": definitions,
|
"definitions": definitions,
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#"
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
||||||
})
|
})
|
||||||
export const isSignInByMailCodeRequest: (value: object) => value is SignInByMailCodeRequest = ajv.compile({
|
export const isSignInByMailCodeRequest: (value: unknown) => value is SignInByMailCodeRequest = ajv.compile({
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"mailLoginToken": {
|
"mailLoginToken": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 Jonas Lochmann
|
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
@ -79,12 +79,12 @@ export class VisibleConnectedDevicesManager {
|
||||||
}): {
|
}): {
|
||||||
shutdown: () => void
|
shutdown: () => void
|
||||||
} => {
|
} => {
|
||||||
let observesDevices = new Set<string>()
|
const observesDevices = new Set<string>()
|
||||||
let devicesWithSharingEnabled = new Set<string>()
|
const devicesWithSharingEnabled = new Set<string>()
|
||||||
let connectedDevices = new Set<string>()
|
const connectedDevices = new Set<string>()
|
||||||
let sentConnectedDevices = new Set<string>()
|
const sentConnectedDevices = new Set<string>()
|
||||||
let hasShutDown = false
|
let hasShutDown = false
|
||||||
let shutdownHooks: Array<() => void> = []
|
const shutdownHooks: Array<() => void> = []
|
||||||
|
|
||||||
const shutdown = () => {
|
const shutdown = () => {
|
||||||
hasShutDown = true
|
hasShutDown = true
|
||||||
|
@ -97,7 +97,7 @@ export class VisibleConnectedDevicesManager {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let result: Array<string> = []
|
const result: Array<string> = []
|
||||||
|
|
||||||
sentConnectedDevices.forEach((deviceId) => result.push(deviceId))
|
sentConnectedDevices.forEach((deviceId) => result.push(deviceId))
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ export class VisibleConnectedDevicesManager {
|
||||||
devices.forEach(({ deviceId, showDeviceConnected }) => {
|
devices.forEach(({ deviceId, showDeviceConnected }) => {
|
||||||
addDevice({ deviceId, showDeviceConnected })
|
addDevice({ deviceId, showDeviceConnected })
|
||||||
})
|
})
|
||||||
})().catch((ex) => { /* ignore */ })
|
})().catch(() => { /* ignore */ })
|
||||||
|
|
||||||
{
|
{
|
||||||
// add all new devices + apply changes of sharing
|
// add all new devices + apply changes of sharing
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2021 Jonas Lochmann
|
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
@ -86,7 +86,7 @@ const createDatabase = (sequelize: Sequelize.Sequelize): Database => ({
|
||||||
transaction: <T> (autoCallback: (transaction: Transaction) => Promise<T>, options?: { transaction: Transaction }) => (sequelize.transaction({
|
transaction: <T> (autoCallback: (transaction: Transaction) => Promise<T>, options?: { transaction: Transaction }) => (sequelize.transaction({
|
||||||
isolationLevel: Sequelize.Transaction.ISOLATION_LEVELS.SERIALIZABLE,
|
isolationLevel: Sequelize.Transaction.ISOLATION_LEVELS.SERIALIZABLE,
|
||||||
transaction: options?.transaction
|
transaction: options?.transaction
|
||||||
}, autoCallback) as any) as Promise<T>,
|
}, autoCallback)) as Promise<T>,
|
||||||
dialect: sequelize.getDialect()
|
dialect: sequelize.getDialect()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 Jonas Lochmann
|
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
import * as Sequelize from 'sequelize'
|
import * as Sequelize from 'sequelize'
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
export type SequelizeAttributes<T extends { [key: string]: any }> = {
|
export type SequelizeAttributes<T extends { [key: string]: any }> = {
|
||||||
[P in keyof T]: Sequelize.ModelAttributeColumnOptions;
|
[P in keyof T]: Sequelize.ModelAttributeColumnOptions;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2021 Jonas Lochmann
|
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
@ -21,7 +21,7 @@ import { Database } from '../main'
|
||||||
|
|
||||||
export class SerializationFeatureCheckException extends Error {}
|
export class SerializationFeatureCheckException extends Error {}
|
||||||
|
|
||||||
export function shouldRetryWithException (database: Database, e: any): boolean {
|
export function shouldRetryWithException (database: Database, e: unknown): boolean {
|
||||||
if (e instanceof Sequelize.TimeoutError) return true
|
if (e instanceof Sequelize.TimeoutError) return true
|
||||||
|
|
||||||
if (!(e instanceof Sequelize.DatabaseError)) return false
|
if (!(e instanceof Sequelize.DatabaseError)) return false
|
||||||
|
@ -32,10 +32,13 @@ export function shouldRetryWithException (database: Database, e: any): boolean {
|
||||||
if (parent.message.startsWith('SQLITE_BUSY:')) return true
|
if (parent.message.startsWith('SQLITE_BUSY:')) return true
|
||||||
} else if (database.dialect === 'postgres') {
|
} else if (database.dialect === 'postgres') {
|
||||||
// 40001 = serialization_failure
|
// 40001 = serialization_failure
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
if ((parent as any).code === '40001') return true
|
if ((parent as any).code === '40001') return true
|
||||||
// 40P01 = deadlock detected
|
// 40P01 = deadlock detected
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
if ((parent as any).code === '40P01') return true
|
if ((parent as any).code === '40P01') return true
|
||||||
} else if (database.dialect === 'mariadb') {
|
} else if (database.dialect === 'mariadb') {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const errno = (parent as any).errno
|
const errno = (parent as any).errno
|
||||||
|
|
||||||
// ER_LOCK_DEADLOCK
|
// ER_LOCK_DEADLOCK
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 Jonas Lochmann
|
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
const IABVerifier: new (publicKey: string) => {
|
const IABVerifier: new (publicKey: string) => {
|
||||||
verifyReceipt: (data: string, signature: string) => boolean
|
verifyReceipt: (data: string, signature: string) => boolean
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
} = require('iab_verifier')
|
} = require('iab_verifier')
|
||||||
|
|
||||||
export const googlePlayPublicKey = process.env.GOOGLE_PLAY_PUBLIC_KEY || ''
|
export const googlePlayPublicKey = process.env.GOOGLE_PLAY_PUBLIC_KEY || ''
|
||||||
|
|
|
@ -86,7 +86,7 @@ export async function dispatchAddUsedTimeVersion2 ({ deviceId, action, cache, ev
|
||||||
addUsedTimeForADifferentUserThanTheCurrentUserOfTheDevice = true
|
addUsedTimeForADifferentUserThanTheCurrentUserOfTheDevice = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// tslint:disable-next-line:no-inner-declarations
|
// eslint-disable-next-line no-inner-declarations
|
||||||
async function handle (start: number, end: number) {
|
async function handle (start: number, end: number) {
|
||||||
const lengthInMinutes = (end - start) + 1
|
const lengthInMinutes = (end - start) + 1
|
||||||
const lengthInMs = lengthInMinutes * 1000 * 60
|
const lengthInMs = lengthInMinutes * 1000 * 60
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2020 Jonas Lochmann
|
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
@ -26,7 +26,7 @@ import { parseEncodedAction } from '../parse-encoded-action'
|
||||||
export async function dispatch<T1 extends { type: string }, T2> ({ type, action, validator, parser, applier, eventHandler }: {
|
export async function dispatch<T1 extends { type: string }, T2> ({ type, action, validator, parser, applier, eventHandler }: {
|
||||||
type: 'app logic' | 'parent' | 'child'
|
type: 'app logic' | 'parent' | 'child'
|
||||||
action: ClientPushChangesRequestAction
|
action: ClientPushChangesRequestAction
|
||||||
validator: (input: any) => input is T1
|
validator: (input: unknown) => input is T1
|
||||||
parser: (input: T1) => T2
|
parser: (input: T1) => T2
|
||||||
applier: (input: T2) => Promise<void>
|
applier: (input: T2) => Promise<void>
|
||||||
eventHandler: EventHandler
|
eventHandler: EventHandler
|
||||||
|
|
|
@ -39,7 +39,7 @@ export const generateServerDataStatus = async ({ database, clientStatus, familyI
|
||||||
const familyEntry = await getFamilyEntry({ database, familyId, transaction })
|
const familyEntry = await getFamilyEntry({ database, familyId, transaction })
|
||||||
const doesClientSupportTasks = clientStatus.clientLevel !== undefined && clientStatus.clientLevel >= 3
|
const doesClientSupportTasks = clientStatus.clientLevel !== undefined && clientStatus.clientLevel >= 3
|
||||||
|
|
||||||
let result: ServerDataStatus = {
|
const result: ServerDataStatus = {
|
||||||
fullVersion: config.alwaysPro ? 1 : (
|
fullVersion: config.alwaysPro ? 1 : (
|
||||||
familyEntry.hasFullVersion ? parseInt(familyEntry.fullVersionUntil, 10) : 0
|
familyEntry.hasFullVersion ? parseInt(familyEntry.fullVersionUntil, 10) : 0
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2020 Jonas Lochmann
|
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
@ -56,7 +56,7 @@ export const validateBitmask = (bitmask: string, maxLength: number) => {
|
||||||
export const validateAndParseBitmask = (bitmask: string, maxLength: number) => {
|
export const validateAndParseBitmask = (bitmask: string, maxLength: number) => {
|
||||||
validateBitmask(bitmask, maxLength)
|
validateBitmask(bitmask, maxLength)
|
||||||
|
|
||||||
const result = range(0, maxLength).map((_) => false)
|
const result = range(0, maxLength).map(() => false)
|
||||||
|
|
||||||
const splitpoints = split(bitmask, ',').map((item) => parseInt(item, 10))
|
const splitpoints = split(bitmask, ',').map((item) => parseInt(item, 10))
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,7 @@ function createMailTemplateSender (templateName: string) {
|
||||||
reject(err)
|
reject(err)
|
||||||
} else {
|
} else {
|
||||||
if (isDevMode) {
|
if (isDevMode) {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const data = (info as any).message
|
const data = (info as any).message
|
||||||
|
|
||||||
console.log(JSON.stringify(JSON.parse(data), null, 2))
|
console.log(JSON.stringify(JSON.parse(data), null, 2))
|
||||||
|
@ -238,6 +239,7 @@ export function sanitizeMailAddress (input: string): string | null {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const address = (parsed as any).address
|
const address = (parsed as any).address
|
||||||
|
|
||||||
if (typeof address !== 'string') {
|
if (typeof address !== 'string') {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 Jonas Lochmann
|
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
@ -28,7 +28,7 @@ const randomWord = () => wordlist[Math.floor(Math.random() * (wordlist.length -
|
||||||
|
|
||||||
export const randomWords = (numberOfWords: number) => (
|
export const randomWords = (numberOfWords: number) => (
|
||||||
range(numberOfWords)
|
range(numberOfWords)
|
||||||
.map((item) => randomWord())
|
.map(() => randomWord())
|
||||||
.join(' ')
|
.join(' ')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2021 Jonas Lochmann
|
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
@ -45,7 +45,7 @@ export const createWebsocketHandler = ({ connectedDevicesManager, database }: {
|
||||||
socketCounter++
|
socketCounter++
|
||||||
socket.on('disconnect', () => socketCounter--)
|
socket.on('disconnect', () => socketCounter--)
|
||||||
|
|
||||||
socket.on('devicelogin', (deviceAuthToken: any, ack: any) => {
|
socket.on('devicelogin', (deviceAuthToken: unknown, ack: unknown) => {
|
||||||
socket.rooms.forEach((room) => socket.leave(room))
|
socket.rooms.forEach((room) => socket.leave(room))
|
||||||
|
|
||||||
if (typeof deviceAuthToken !== 'string') {
|
if (typeof deviceAuthToken !== 'string') {
|
||||||
|
@ -95,7 +95,7 @@ export const createWebsocketHandler = ({ connectedDevicesManager, database }: {
|
||||||
shutdown()
|
shutdown()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})().catch((ex) => { /* ignore */ })
|
})().catch(() => { /* ignore */ })
|
||||||
|
|
||||||
if (typeof ack === 'function') {
|
if (typeof ack === 'function') {
|
||||||
ack()
|
ack()
|
||||||
|
|
12
tslint.json
12
tslint.json
|
@ -1,12 +0,0 @@
|
||||||
{
|
|
||||||
"defaultSeverity": "error",
|
|
||||||
"extends": [
|
|
||||||
"tslint-config-standard"
|
|
||||||
],
|
|
||||||
"jsRules": {},
|
|
||||||
"rules": {
|
|
||||||
"await-promise": [true, "Bluebird"],
|
|
||||||
"ordered-imports": true
|
|
||||||
},
|
|
||||||
"rulesDirectory": []
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue