@webda/core 4.0.0-beta.1 → 4.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +252 -0
- package/lib/application/application.d.ts +437 -0
- package/lib/application/application.d.ts.map +1 -0
- package/lib/application/application.js +792 -0
- package/lib/application/application.js.map +1 -0
- package/lib/application/hooks.d.ts +34 -0
- package/lib/application/hooks.d.ts.map +1 -0
- package/lib/application/hooks.js +57 -0
- package/lib/application/hooks.js.map +1 -0
- package/lib/application/iapplication.d.ts +43 -0
- package/lib/application/iapplication.d.ts.map +1 -0
- package/lib/application/iapplication.js +2 -0
- package/lib/application/iapplication.js.map +1 -0
- package/lib/application/iconfiguration.d.ts +176 -0
- package/lib/application/iconfiguration.d.ts.map +1 -0
- package/lib/application/iconfiguration.js +8 -0
- package/lib/application/iconfiguration.js.map +1 -0
- package/lib/application/runner.d.ts +8 -0
- package/lib/application/runner.d.ts.map +1 -0
- package/lib/application/runner.js +26 -0
- package/lib/application/runner.js.map +1 -0
- package/lib/application/unpackedapplication.d.ts +104 -0
- package/lib/application/unpackedapplication.d.ts.map +1 -0
- package/lib/application/unpackedapplication.js +492 -0
- package/lib/application/unpackedapplication.js.map +1 -0
- package/lib/bin/cli-phase.d.ts +28 -0
- package/lib/bin/cli-phase.d.ts.map +1 -0
- package/lib/bin/cli-phase.js +44 -0
- package/lib/bin/cli-phase.js.map +1 -0
- package/lib/bin/cli.d.ts +161 -0
- package/lib/bin/cli.d.ts.map +1 -0
- package/lib/bin/cli.js +828 -0
- package/lib/bin/cli.js.map +1 -0
- package/lib/bin/launcher.d.ts +3 -0
- package/lib/bin/launcher.d.ts.map +1 -0
- package/lib/bin/launcher.js +50 -0
- package/lib/bin/launcher.js.map +1 -0
- package/lib/cache/cache.d.ts +33 -0
- package/lib/cache/cache.d.ts.map +1 -0
- package/lib/cache/cache.js +8 -0
- package/lib/cache/cache.js.map +1 -0
- package/lib/{services/configuration.d.ts → configurations/configuration.service.d.ts} +58 -49
- package/lib/configurations/configuration.service.d.ts.map +1 -0
- package/lib/configurations/configuration.service.js +248 -0
- package/lib/configurations/configuration.service.js.map +1 -0
- package/lib/configurations/fileconfiguration.service.d.ts +30 -0
- package/lib/configurations/fileconfiguration.service.d.ts.map +1 -0
- package/lib/configurations/fileconfiguration.service.js +65 -0
- package/lib/configurations/fileconfiguration.service.js.map +1 -0
- package/lib/configurations/kubernetesconfiguration.service.d.ts +43 -0
- package/lib/configurations/kubernetesconfiguration.service.d.ts.map +1 -0
- package/lib/configurations/kubernetesconfiguration.service.js +83 -0
- package/lib/configurations/kubernetesconfiguration.service.js.map +1 -0
- package/lib/contexts/execution.d.ts +33 -0
- package/lib/contexts/execution.d.ts.map +1 -0
- package/lib/contexts/execution.js +73 -0
- package/lib/contexts/execution.js.map +1 -0
- package/lib/contexts/globalcontext.d.ts +29 -0
- package/lib/contexts/globalcontext.d.ts.map +1 -0
- package/lib/contexts/globalcontext.js +38 -0
- package/lib/contexts/globalcontext.js.map +1 -0
- package/lib/{utils → contexts}/httpcontext.d.ts +45 -19
- package/lib/contexts/httpcontext.d.ts.map +1 -0
- package/lib/{utils → contexts}/httpcontext.js +102 -34
- package/lib/contexts/httpcontext.js.map +1 -0
- package/lib/contexts/icontext.d.ts +236 -0
- package/lib/contexts/icontext.d.ts.map +1 -0
- package/lib/contexts/icontext.js +230 -0
- package/lib/contexts/icontext.js.map +1 -0
- package/lib/contexts/operationcontext.d.ts +179 -0
- package/lib/contexts/operationcontext.d.ts.map +1 -0
- package/lib/contexts/operationcontext.js +358 -0
- package/lib/contexts/operationcontext.js.map +1 -0
- package/lib/contexts/simplecontext.d.ts +31 -0
- package/lib/contexts/simplecontext.d.ts.map +1 -0
- package/lib/contexts/simplecontext.js +45 -0
- package/lib/contexts/simplecontext.js.map +1 -0
- package/lib/contexts/webcontext.d.ts +218 -0
- package/lib/contexts/webcontext.d.ts.map +1 -0
- package/lib/contexts/webcontext.js +389 -0
- package/lib/contexts/webcontext.js.map +1 -0
- package/lib/core/authorizer.d.ts +23 -0
- package/lib/core/authorizer.d.ts.map +1 -0
- package/lib/core/authorizer.js +17 -0
- package/lib/core/authorizer.js.map +1 -0
- package/lib/core/core.d.ts +225 -0
- package/lib/core/core.d.ts.map +1 -0
- package/lib/core/core.js +576 -0
- package/lib/core/core.js.map +1 -0
- package/lib/core/hooks.d.ts +72 -0
- package/lib/core/hooks.d.ts.map +1 -0
- package/lib/core/hooks.js +73 -0
- package/lib/core/hooks.js.map +1 -0
- package/lib/core/icore.d.ts +249 -0
- package/lib/core/icore.d.ts.map +1 -0
- package/lib/core/icore.js +15 -0
- package/lib/core/icore.js.map +1 -0
- package/lib/core/instancestorage.d.ts +61 -0
- package/lib/core/instancestorage.d.ts.map +1 -0
- package/lib/core/instancestorage.js +75 -0
- package/lib/core/instancestorage.js.map +1 -0
- package/lib/core/operations.d.ts +181 -0
- package/lib/core/operations.d.ts.map +1 -0
- package/lib/core/operations.js +559 -0
- package/lib/core/operations.js.map +1 -0
- package/lib/errors/errors.d.ts +126 -0
- package/lib/errors/errors.d.ts.map +1 -0
- package/lib/errors/errors.js +165 -0
- package/lib/errors/errors.js.map +1 -0
- package/lib/events/asynceventemitter.d.ts +159 -0
- package/lib/events/asynceventemitter.d.ts.map +1 -0
- package/lib/events/asynceventemitter.js +152 -0
- package/lib/events/asynceventemitter.js.map +1 -0
- package/lib/events/events.d.ts +112 -0
- package/lib/events/events.d.ts.map +1 -0
- package/lib/events/events.js +45 -0
- package/lib/events/events.js.map +1 -0
- package/lib/index.d.ts +84 -51
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +82 -59
- package/lib/index.js.map +1 -1
- package/lib/loggers/console.service.d.ts +24 -0
- package/lib/loggers/console.service.d.ts.map +1 -0
- package/lib/loggers/console.service.js +30 -0
- package/lib/loggers/console.service.js.map +1 -0
- package/lib/loggers/file.service.d.ts +25 -0
- package/lib/loggers/file.service.d.ts.map +1 -0
- package/lib/loggers/file.service.js +33 -0
- package/lib/loggers/file.service.js.map +1 -0
- package/lib/loggers/hooks.d.ts +20 -0
- package/lib/loggers/hooks.d.ts.map +1 -0
- package/lib/loggers/hooks.js +40 -0
- package/lib/loggers/hooks.js.map +1 -0
- package/lib/loggers/ilogger.d.ts +76 -0
- package/lib/loggers/ilogger.d.ts.map +1 -0
- package/lib/loggers/ilogger.js +108 -0
- package/lib/loggers/ilogger.js.map +1 -0
- package/lib/loggers/logger.d.ts +13 -0
- package/lib/loggers/logger.d.ts.map +1 -0
- package/lib/loggers/logger.js +18 -0
- package/lib/loggers/logger.js.map +1 -0
- package/lib/loggers/memory.service.d.ts +18 -0
- package/lib/loggers/memory.service.d.ts.map +1 -0
- package/lib/loggers/memory.service.js +21 -0
- package/lib/loggers/memory.service.js.map +1 -0
- package/lib/loggers/params.d.ts +47 -0
- package/lib/loggers/params.d.ts.map +1 -0
- package/lib/loggers/params.js +56 -0
- package/lib/loggers/params.js.map +1 -0
- package/lib/metrics/metrics.d.ts +25 -0
- package/lib/metrics/metrics.d.ts.map +1 -0
- package/lib/metrics/metrics.js +51 -0
- package/lib/metrics/metrics.js.map +1 -0
- package/lib/models/aclmodel.d.ts +21 -77
- package/lib/models/aclmodel.d.ts.map +1 -0
- package/lib/models/aclmodel.js +27 -204
- package/lib/models/aclmodel.js.map +1 -1
- package/lib/models/coremodel.model.d.ts +5 -0
- package/lib/models/coremodel.model.d.ts.map +1 -0
- package/lib/models/coremodel.model.js +5 -0
- package/lib/models/coremodel.model.js.map +1 -0
- package/lib/models/decorator.d.ts +63 -0
- package/lib/models/decorator.d.ts.map +1 -0
- package/lib/models/decorator.js +63 -0
- package/lib/models/decorator.js.map +1 -0
- package/lib/models/deployment.d.ts +2 -1
- package/lib/models/deployment.d.ts.map +1 -0
- package/lib/models/ident.model.d.ts +89 -0
- package/lib/models/ident.model.d.ts.map +1 -0
- package/lib/models/ident.model.js +115 -0
- package/lib/models/ident.model.js.map +1 -0
- package/lib/models/ownermodel.model.d.ts +68 -0
- package/lib/models/ownermodel.model.d.ts.map +1 -0
- package/lib/models/ownermodel.model.js +112 -0
- package/lib/models/ownermodel.model.js.map +1 -0
- package/lib/models/registry.model.d.ts +76 -0
- package/lib/models/registry.model.d.ts.map +1 -0
- package/lib/models/registry.model.js +104 -0
- package/lib/models/registry.model.js.map +1 -0
- package/lib/models/rolemodel.model.d.ts +28 -0
- package/lib/models/rolemodel.model.d.ts.map +1 -0
- package/lib/models/rolemodel.model.js +53 -0
- package/lib/models/rolemodel.model.js.map +1 -0
- package/lib/models/simpleuser.model.d.ts +78 -0
- package/lib/models/simpleuser.model.d.ts.map +1 -0
- package/lib/models/simpleuser.model.js +123 -0
- package/lib/models/simpleuser.model.js.map +1 -0
- package/lib/models/types.d.ts +113 -0
- package/lib/models/types.d.ts.map +1 -0
- package/lib/models/types.js +2 -0
- package/lib/models/types.js.map +1 -0
- package/lib/models/user.model.d.ts +103 -0
- package/lib/models/user.model.d.ts.map +1 -0
- package/lib/models/user.model.js +125 -0
- package/lib/models/user.model.js.map +1 -0
- package/lib/queues/memoryqueue.service.d.ts +72 -0
- package/lib/queues/memoryqueue.service.d.ts.map +1 -0
- package/lib/queues/memoryqueue.service.js +136 -0
- package/lib/queues/memoryqueue.service.js.map +1 -0
- package/lib/queues/pubsubservice.d.ts +9 -6
- package/lib/queues/pubsubservice.d.ts.map +1 -0
- package/lib/queues/pubsubservice.js +5 -4
- package/lib/queues/pubsubservice.js.map +1 -1
- package/lib/queues/queueservice.d.ts +10 -11
- package/lib/queues/queueservice.d.ts.map +1 -0
- package/lib/queues/queueservice.js +48 -20
- package/lib/queues/queueservice.js.map +1 -1
- package/lib/rest/hooks.d.ts +8 -0
- package/lib/rest/hooks.d.ts.map +1 -0
- package/lib/rest/hooks.js +10 -0
- package/lib/rest/hooks.js.map +1 -0
- package/lib/rest/irest.d.ts +212 -0
- package/lib/rest/irest.d.ts.map +1 -0
- package/lib/rest/irest.js +39 -0
- package/lib/rest/irest.js.map +1 -0
- package/lib/rest/originfilter.d.ts +38 -0
- package/lib/rest/originfilter.d.ts.map +1 -0
- package/lib/rest/originfilter.js +61 -0
- package/lib/rest/originfilter.js.map +1 -0
- package/lib/rest/restoperationstransport.service.d.ts +193 -0
- package/lib/rest/restoperationstransport.service.d.ts.map +1 -0
- package/lib/rest/restoperationstransport.service.js +780 -0
- package/lib/rest/restoperationstransport.service.js.map +1 -0
- package/lib/rest/router.service.d.ts +244 -0
- package/lib/rest/router.service.d.ts.map +1 -0
- package/lib/rest/router.service.js +843 -0
- package/lib/rest/router.service.js.map +1 -0
- package/lib/schemas/hooks.d.ts +48 -0
- package/lib/schemas/hooks.d.ts.map +1 -0
- package/lib/schemas/hooks.js +152 -0
- package/lib/schemas/hooks.js.map +1 -0
- package/lib/services/audit.model.d.ts +208 -0
- package/lib/services/audit.model.d.ts.map +1 -0
- package/lib/services/audit.model.js +431 -0
- package/lib/services/audit.model.js.map +1 -0
- package/lib/services/{authentication.d.ts → authentication.service.d.ts} +140 -58
- package/lib/services/authentication.service.d.ts.map +1 -0
- package/lib/services/authentication.service.js +932 -0
- package/lib/services/authentication.service.js.map +1 -0
- package/lib/services/binary.service.d.ts +808 -0
- package/lib/services/binary.service.d.ts.map +1 -0
- package/lib/services/binary.service.js +1365 -0
- package/lib/services/binary.service.js.map +1 -0
- package/lib/services/cloudbinary.d.ts +19 -13
- package/lib/services/cloudbinary.d.ts.map +1 -0
- package/lib/services/cloudbinary.js +24 -18
- package/lib/services/cloudbinary.js.map +1 -1
- package/lib/services/command.d.ts +118 -0
- package/lib/services/command.d.ts.map +1 -0
- package/lib/services/command.js +97 -0
- package/lib/services/command.js.map +1 -0
- package/lib/services/cron.service.d.ts +142 -0
- package/lib/services/cron.service.d.ts.map +1 -0
- package/lib/services/cron.service.js +291 -0
- package/lib/services/cron.service.js.map +1 -0
- package/lib/services/{cryptoservice.d.ts → cryptoservice.service.d.ts} +77 -142
- package/lib/services/cryptoservice.service.d.ts.map +1 -0
- package/lib/services/cryptoservice.service.js +527 -0
- package/lib/services/cryptoservice.service.js.map +1 -0
- package/lib/services/debugmailer.service.d.ts +49 -0
- package/lib/services/debugmailer.service.d.ts.map +1 -0
- package/lib/services/debugmailer.service.js +66 -0
- package/lib/services/debugmailer.service.js.map +1 -0
- package/lib/services/domainservice.service.d.ts +203 -0
- package/lib/services/domainservice.service.d.ts.map +1 -0
- package/lib/services/domainservice.service.js +600 -0
- package/lib/services/domainservice.service.js.map +1 -0
- package/lib/services/httpserver.service.d.ts +248 -0
- package/lib/services/httpserver.service.d.ts.map +1 -0
- package/lib/services/httpserver.service.js +673 -0
- package/lib/services/httpserver.service.js.map +1 -0
- package/lib/services/iauthentication.d.ts +9 -0
- package/lib/services/iauthentication.d.ts.map +1 -0
- package/lib/services/iauthentication.js +2 -0
- package/lib/services/iauthentication.js.map +1 -0
- package/lib/services/icryptoservice.d.ts +127 -0
- package/lib/services/icryptoservice.d.ts.map +1 -0
- package/lib/services/icryptoservice.js +68 -0
- package/lib/services/icryptoservice.js.map +1 -0
- package/lib/services/imailer.d.ts +17 -0
- package/lib/services/imailer.d.ts.map +1 -0
- package/lib/services/imailer.js +2 -0
- package/lib/services/imailer.js.map +1 -0
- package/lib/services/iservice.d.ts +104 -0
- package/lib/services/iservice.d.ts.map +1 -0
- package/lib/services/iservice.js +63 -0
- package/lib/services/iservice.js.map +1 -0
- package/lib/services/mailer.service.d.ts +220 -0
- package/lib/services/mailer.service.d.ts.map +1 -0
- package/lib/services/mailer.service.js +251 -0
- package/lib/services/mailer.service.js.map +1 -0
- package/lib/services/{notificationservice.d.ts → notificationservice.service.d.ts} +10 -10
- package/lib/services/notificationservice.service.d.ts.map +1 -0
- package/lib/services/{notificationservice.js → notificationservice.service.js} +24 -12
- package/lib/services/notificationservice.service.js.map +1 -0
- package/lib/services/oauth.d.ts +58 -31
- package/lib/services/oauth.d.ts.map +1 -0
- package/lib/services/oauth.js +365 -251
- package/lib/services/oauth.js.map +1 -1
- package/lib/services/operationstransport.d.ts +65 -0
- package/lib/services/operationstransport.d.ts.map +1 -0
- package/lib/services/operationstransport.js +103 -0
- package/lib/services/operationstransport.js.map +1 -0
- package/lib/services/{prometheus.d.ts → prometheus.service.d.ts} +13 -11
- package/lib/services/prometheus.service.d.ts.map +1 -0
- package/lib/services/prometheus.service.js +203 -0
- package/lib/services/prometheus.service.js.map +1 -0
- package/lib/services/resource.service.d.ts +121 -0
- package/lib/services/resource.service.d.ts.map +1 -0
- package/lib/services/resource.service.js +301 -0
- package/lib/services/resource.service.js.map +1 -0
- package/lib/services/service.d.ts +88 -189
- package/lib/services/service.d.ts.map +1 -0
- package/lib/services/service.js +407 -432
- package/lib/services/service.js.map +1 -1
- package/lib/services/servicecommands.d.ts +99 -0
- package/lib/services/servicecommands.d.ts.map +1 -0
- package/lib/services/servicecommands.js +165 -0
- package/lib/services/servicecommands.js.map +1 -0
- package/lib/services/serviceparameters.d.ts +33 -0
- package/lib/services/serviceparameters.d.ts.map +1 -0
- package/lib/services/serviceparameters.js +79 -0
- package/lib/services/serviceparameters.js.map +1 -0
- package/lib/{utils → session}/cookie.d.ts +32 -18
- package/lib/session/cookie.d.ts.map +1 -0
- package/lib/{utils → session}/cookie.js +76 -23
- package/lib/session/cookie.js.map +1 -0
- package/lib/session/manager.model.d.ts +71 -0
- package/lib/session/manager.model.d.ts.map +1 -0
- package/lib/session/manager.model.js +155 -0
- package/lib/session/manager.model.js.map +1 -0
- package/lib/session/session.d.ts +57 -0
- package/lib/session/session.d.ts.map +1 -0
- package/lib/session/session.js +126 -0
- package/lib/session/session.js.map +1 -0
- package/lib/stores/istore.d.ts +99 -0
- package/lib/stores/istore.d.ts.map +1 -0
- package/lib/stores/istore.js +26 -0
- package/lib/stores/istore.js.map +1 -0
- package/lib/stores/memory.service.d.ts +114 -0
- package/lib/stores/memory.service.d.ts.map +1 -0
- package/lib/stores/memory.service.js +343 -0
- package/lib/stores/memory.service.js.map +1 -0
- package/lib/stores/store.d.ts +127 -768
- package/lib/stores/store.d.ts.map +1 -0
- package/lib/stores/store.js +258 -1718
- package/lib/stores/store.js.map +1 -1
- package/lib/templates/templates.d.ts +39 -0
- package/lib/templates/templates.d.ts.map +1 -0
- package/lib/templates/templates.js +92 -0
- package/lib/templates/templates.js.map +1 -0
- package/lib/test/application.d.ts +174 -0
- package/lib/test/application.d.ts.map +1 -0
- package/lib/test/application.js +288 -0
- package/lib/test/application.js.map +1 -0
- package/lib/test/asyncstorage.d.ts +16 -0
- package/lib/test/asyncstorage.d.ts.map +1 -0
- package/lib/test/asyncstorage.js +32 -0
- package/lib/test/asyncstorage.js.map +1 -0
- package/lib/test/core.d.ts +63 -0
- package/lib/test/core.d.ts.map +1 -0
- package/lib/test/core.js +190 -0
- package/lib/test/core.js.map +1 -0
- package/lib/test/index.d.ts +7 -0
- package/lib/test/index.d.ts.map +1 -0
- package/lib/test/index.js +8 -0
- package/lib/test/index.js.map +1 -0
- package/lib/test/internal.d.ts +34 -0
- package/lib/test/internal.d.ts.map +1 -0
- package/lib/test/internal.js +156 -0
- package/lib/test/internal.js.map +1 -0
- package/lib/test/objects.d.ts +318 -0
- package/lib/test/objects.d.ts.map +1 -0
- package/lib/test/objects.js +443 -0
- package/lib/test/objects.js.map +1 -0
- package/lib/utils/abstractdeployer.d.ts +5 -2
- package/lib/utils/abstractdeployer.d.ts.map +1 -0
- package/lib/utils/abstractdeployer.js +3 -0
- package/lib/utils/abstractdeployer.js.map +1 -1
- package/package.json +85 -56
- package/test/cachedapp/webda.config.json +1 -5
- package/test/config-cached.json +1 -5
- package/test/config.json +6 -99
- package/test/data/.env +1 -0
- package/test/my-cnf.json +9 -0
- package/webda.module.json +3462 -2231
- package/lib/application.d.ts +0 -876
- package/lib/application.js +0 -741
- package/lib/application.js.map +0 -1
- package/lib/application.spec.d.ts +0 -1
- package/lib/application.spec.js +0 -234
- package/lib/application.spec.js.map +0 -1
- package/lib/core.d.ts +0 -740
- package/lib/core.js +0 -1310
- package/lib/core.js.map +0 -1
- package/lib/core.spec.d.ts +0 -1
- package/lib/core.spec.js +0 -761
- package/lib/core.spec.js.map +0 -1
- package/lib/errors.d.ts +0 -65
- package/lib/errors.js +0 -113
- package/lib/errors.js.map +0 -1
- package/lib/errors.spec.d.ts +0 -1
- package/lib/errors.spec.js +0 -33
- package/lib/errors.spec.js.map +0 -1
- package/lib/models/aclmodel.spec.d.ts +0 -1
- package/lib/models/aclmodel.spec.js +0 -187
- package/lib/models/aclmodel.spec.js.map +0 -1
- package/lib/models/coremodel.d.ts +0 -887
- package/lib/models/coremodel.js +0 -1208
- package/lib/models/coremodel.js.map +0 -1
- package/lib/models/coremodel.spec.d.ts +0 -1
- package/lib/models/coremodel.spec.js +0 -462
- package/lib/models/coremodel.spec.js.map +0 -1
- package/lib/models/ident.d.ts +0 -53
- package/lib/models/ident.js +0 -40
- package/lib/models/ident.js.map +0 -1
- package/lib/models/ident.spec.d.ts +0 -1
- package/lib/models/ident.spec.js +0 -43
- package/lib/models/ident.spec.js.map +0 -1
- package/lib/models/ownermodel.d.ts +0 -50
- package/lib/models/ownermodel.js +0 -65
- package/lib/models/ownermodel.js.map +0 -1
- package/lib/models/ownermodel.spec.d.ts +0 -1
- package/lib/models/ownermodel.spec.js +0 -191
- package/lib/models/ownermodel.spec.js.map +0 -1
- package/lib/models/relations.d.ts +0 -181
- package/lib/models/relations.js +0 -157
- package/lib/models/relations.js.map +0 -1
- package/lib/models/relations.spec.d.ts +0 -12
- package/lib/models/relations.spec.js +0 -224
- package/lib/models/relations.spec.js.map +0 -1
- package/lib/models/rolemodel.d.ts +0 -10
- package/lib/models/rolemodel.js +0 -35
- package/lib/models/rolemodel.js.map +0 -1
- package/lib/models/rolemodel.spec.d.ts +0 -1
- package/lib/models/rolemodel.spec.js +0 -86
- package/lib/models/rolemodel.spec.js.map +0 -1
- package/lib/models/user.d.ts +0 -100
- package/lib/models/user.js +0 -157
- package/lib/models/user.js.map +0 -1
- package/lib/models/user.spec.d.ts +0 -1
- package/lib/models/user.spec.js +0 -88
- package/lib/models/user.spec.js.map +0 -1
- package/lib/queues/filequeue.d.ts +0 -58
- package/lib/queues/filequeue.js +0 -131
- package/lib/queues/filequeue.js.map +0 -1
- package/lib/queues/filequeue.spec.d.ts +0 -1
- package/lib/queues/filequeue.spec.js +0 -78
- package/lib/queues/filequeue.spec.js.map +0 -1
- package/lib/queues/memoryqueue.d.ts +0 -45
- package/lib/queues/memoryqueue.js +0 -81
- package/lib/queues/memoryqueue.js.map +0 -1
- package/lib/queues/memoryqueue.spec.d.ts +0 -1
- package/lib/queues/memoryqueue.spec.js +0 -192
- package/lib/queues/memoryqueue.spec.js.map +0 -1
- package/lib/queues/queue.spec.d.ts +0 -5
- package/lib/queues/queue.spec.js +0 -55
- package/lib/queues/queue.spec.js.map +0 -1
- package/lib/router.d.ts +0 -172
- package/lib/router.js +0 -419
- package/lib/router.js.map +0 -1
- package/lib/router.spec.d.ts +0 -1
- package/lib/router.spec.js +0 -229
- package/lib/router.spec.js.map +0 -1
- package/lib/services/asyncevents.d.ts +0 -151
- package/lib/services/asyncevents.js +0 -217
- package/lib/services/asyncevents.js.map +0 -1
- package/lib/services/asyncevents.spec.d.ts +0 -1
- package/lib/services/asyncevents.spec.js +0 -118
- package/lib/services/asyncevents.spec.js.map +0 -1
- package/lib/services/authentication.js +0 -772
- package/lib/services/authentication.js.map +0 -1
- package/lib/services/authentication.spec.d.ts +0 -1
- package/lib/services/authentication.spec.js +0 -458
- package/lib/services/authentication.spec.js.map +0 -1
- package/lib/services/binary.d.ts +0 -549
- package/lib/services/binary.js +0 -986
- package/lib/services/binary.js.map +0 -1
- package/lib/services/binary.spec.d.ts +0 -44
- package/lib/services/binary.spec.js +0 -438
- package/lib/services/binary.spec.js.map +0 -1
- package/lib/services/cloudbinary.spec.d.ts +0 -13
- package/lib/services/cloudbinary.spec.js +0 -192
- package/lib/services/cloudbinary.spec.js.map +0 -1
- package/lib/services/configuration.js +0 -178
- package/lib/services/configuration.js.map +0 -1
- package/lib/services/configuration.spec.d.ts +0 -1
- package/lib/services/configuration.spec.js +0 -87
- package/lib/services/configuration.spec.js.map +0 -1
- package/lib/services/cron.d.ts +0 -73
- package/lib/services/cron.js +0 -141
- package/lib/services/cron.js.map +0 -1
- package/lib/services/cron.spec.d.ts +0 -1
- package/lib/services/cron.spec.js +0 -76
- package/lib/services/cron.spec.js.map +0 -1
- package/lib/services/cryptoservice.js +0 -434
- package/lib/services/cryptoservice.js.map +0 -1
- package/lib/services/cryptoservice.spec.d.ts +0 -1
- package/lib/services/cryptoservice.spec.js +0 -177
- package/lib/services/cryptoservice.spec.js.map +0 -1
- package/lib/services/debugmailer.d.ts +0 -36
- package/lib/services/debugmailer.js +0 -52
- package/lib/services/debugmailer.js.map +0 -1
- package/lib/services/debugmailer.spec.d.ts +0 -1
- package/lib/services/debugmailer.spec.js +0 -29
- package/lib/services/debugmailer.spec.js.map +0 -1
- package/lib/services/domainservice.d.ts +0 -152
- package/lib/services/domainservice.js +0 -881
- package/lib/services/domainservice.js.map +0 -1
- package/lib/services/domainservice.spec.d.ts +0 -1
- package/lib/services/domainservice.spec.js +0 -401
- package/lib/services/domainservice.spec.js.map +0 -1
- package/lib/services/filebinary.d.ts +0 -133
- package/lib/services/filebinary.js +0 -371
- package/lib/services/filebinary.js.map +0 -1
- package/lib/services/filebinary.spec.d.ts +0 -21
- package/lib/services/filebinary.spec.js +0 -415
- package/lib/services/filebinary.spec.js.map +0 -1
- package/lib/services/fileconfiguration.d.ts +0 -22
- package/lib/services/fileconfiguration.js +0 -48
- package/lib/services/fileconfiguration.js.map +0 -1
- package/lib/services/fileconfiguration.spec.d.ts +0 -1
- package/lib/services/fileconfiguration.spec.js +0 -177
- package/lib/services/fileconfiguration.spec.js.map +0 -1
- package/lib/services/invitationservice.d.ts +0 -222
- package/lib/services/invitationservice.js +0 -526
- package/lib/services/invitationservice.js.map +0 -1
- package/lib/services/invitationservice.spec.d.ts +0 -1
- package/lib/services/invitationservice.spec.js +0 -516
- package/lib/services/invitationservice.spec.js.map +0 -1
- package/lib/services/kubernetesconfiguration.d.ts +0 -26
- package/lib/services/kubernetesconfiguration.js +0 -54
- package/lib/services/kubernetesconfiguration.js.map +0 -1
- package/lib/services/kubernetesconfiguration.spec.d.ts +0 -1
- package/lib/services/kubernetesconfiguration.spec.js +0 -147
- package/lib/services/kubernetesconfiguration.spec.js.map +0 -1
- package/lib/services/mailer.d.ts +0 -165
- package/lib/services/mailer.js +0 -176
- package/lib/services/mailer.js.map +0 -1
- package/lib/services/mailer.spec.d.ts +0 -1
- package/lib/services/mailer.spec.js +0 -144
- package/lib/services/mailer.spec.js.map +0 -1
- package/lib/services/notificationservice.js.map +0 -1
- package/lib/services/notificationservice.spec.d.ts +0 -1
- package/lib/services/notificationservice.spec.js +0 -78
- package/lib/services/notificationservice.spec.js.map +0 -1
- package/lib/services/oauth.spec.d.ts +0 -1
- package/lib/services/oauth.spec.js +0 -184
- package/lib/services/oauth.spec.js.map +0 -1
- package/lib/services/prometheus.js +0 -160
- package/lib/services/prometheus.js.map +0 -1
- package/lib/services/prometheus.spec.d.ts +0 -1
- package/lib/services/prometheus.spec.js +0 -57
- package/lib/services/prometheus.spec.js.map +0 -1
- package/lib/services/resource.d.ts +0 -87
- package/lib/services/resource.js +0 -156
- package/lib/services/resource.js.map +0 -1
- package/lib/services/resource.spec.d.ts +0 -1
- package/lib/services/resource.spec.js +0 -122
- package/lib/services/resource.spec.js.map +0 -1
- package/lib/services/service.spec.d.ts +0 -1
- package/lib/services/service.spec.js +0 -268
- package/lib/services/service.spec.js.map +0 -1
- package/lib/stores/aggregator.d.ts +0 -41
- package/lib/stores/aggregator.js +0 -80
- package/lib/stores/aggregator.js.map +0 -1
- package/lib/stores/aliasstore.d.ts +0 -108
- package/lib/stores/aliasstore.js +0 -168
- package/lib/stores/aliasstore.js.map +0 -1
- package/lib/stores/aliasstore.spec.d.ts +0 -11
- package/lib/stores/aliasstore.spec.js +0 -89
- package/lib/stores/aliasstore.spec.js.map +0 -1
- package/lib/stores/file.d.ts +0 -107
- package/lib/stores/file.js +0 -188
- package/lib/stores/file.js.map +0 -1
- package/lib/stores/file.spec.d.ts +0 -19
- package/lib/stores/file.spec.js +0 -232
- package/lib/stores/file.spec.js.map +0 -1
- package/lib/stores/mapper.d.ts +0 -149
- package/lib/stores/mapper.js +0 -293
- package/lib/stores/mapper.js.map +0 -1
- package/lib/stores/mapper.spec.d.ts +0 -1
- package/lib/stores/mapper.spec.js +0 -160
- package/lib/stores/mapper.spec.js.map +0 -1
- package/lib/stores/memory.d.ts +0 -151
- package/lib/stores/memory.js +0 -371
- package/lib/stores/memory.js.map +0 -1
- package/lib/stores/memory.spec.d.ts +0 -20
- package/lib/stores/memory.spec.js +0 -328
- package/lib/stores/memory.spec.js.map +0 -1
- package/lib/stores/modelmapper.d.ts +0 -61
- package/lib/stores/modelmapper.js +0 -199
- package/lib/stores/modelmapper.js.map +0 -1
- package/lib/stores/store.spec.d.ts +0 -65
- package/lib/stores/store.spec.js +0 -906
- package/lib/stores/store.spec.js.map +0 -1
- package/lib/test.d.ts +0 -162
- package/lib/test.js +0 -399
- package/lib/test.js.map +0 -1
- package/lib/unpackedapplication.d.ts +0 -76
- package/lib/unpackedapplication.js +0 -299
- package/lib/unpackedapplication.js.map +0 -1
- package/lib/utils/abstractdeployer.spec.d.ts +0 -1
- package/lib/utils/abstractdeployer.spec.js +0 -21
- package/lib/utils/abstractdeployer.spec.js.map +0 -1
- package/lib/utils/case.d.ts +0 -7
- package/lib/utils/case.js +0 -43
- package/lib/utils/case.js.map +0 -1
- package/lib/utils/case.spec.d.ts +0 -1
- package/lib/utils/case.spec.js +0 -50
- package/lib/utils/case.spec.js.map +0 -1
- package/lib/utils/context.d.ts +0 -462
- package/lib/utils/context.js +0 -732
- package/lib/utils/context.js.map +0 -1
- package/lib/utils/context.spec.d.ts +0 -9
- package/lib/utils/context.spec.js +0 -372
- package/lib/utils/context.spec.js.map +0 -1
- package/lib/utils/cookie.js.map +0 -1
- package/lib/utils/cookie.spec.d.ts +0 -1
- package/lib/utils/cookie.spec.js +0 -78
- package/lib/utils/cookie.spec.js.map +0 -1
- package/lib/utils/esm.d.ts +0 -13
- package/lib/utils/esm.js +0 -19
- package/lib/utils/esm.js.map +0 -1
- package/lib/utils/httpcontext.js.map +0 -1
- package/lib/utils/httpcontext.spec.d.ts +0 -4
- package/lib/utils/httpcontext.spec.js +0 -77
- package/lib/utils/httpcontext.spec.js.map +0 -1
- package/lib/utils/logger.d.ts +0 -91
- package/lib/utils/logger.js +0 -121
- package/lib/utils/logger.js.map +0 -1
- package/lib/utils/logger.spec.d.ts +0 -1
- package/lib/utils/logger.spec.js +0 -48
- package/lib/utils/logger.spec.js.map +0 -1
- package/lib/utils/serializers.d.ts +0 -161
- package/lib/utils/serializers.js +0 -420
- package/lib/utils/serializers.js.map +0 -1
- package/lib/utils/serializers.spec.d.ts +0 -1
- package/lib/utils/serializers.spec.js +0 -313
- package/lib/utils/serializers.spec.js.map +0 -1
- package/lib/utils/session.d.ts +0 -126
- package/lib/utils/session.js +0 -166
- package/lib/utils/session.js.map +0 -1
- package/lib/utils/session.spec.d.ts +0 -1
- package/lib/utils/session.spec.js +0 -71
- package/lib/utils/session.spec.js.map +0 -1
- package/lib/utils/throttler.d.ts +0 -102
- package/lib/utils/throttler.js +0 -168
- package/lib/utils/throttler.js.map +0 -1
- package/lib/utils/throttler.spec.d.ts +0 -1
- package/lib/utils/throttler.spec.js +0 -55
- package/lib/utils/throttler.spec.js.map +0 -1
- package/lib/utils/waiter.d.ts +0 -93
- package/lib/utils/waiter.js +0 -148
- package/lib/utils/waiter.js.map +0 -1
- package/lib/utils/waiter.spec.d.ts +0 -1
- package/lib/utils/waiter.spec.js +0 -98
- package/lib/utils/waiter.spec.js.map +0 -1
- package/test/config-file-missing-file-no-default.json +0 -44
- package/test/config-file-missing-file.json +0 -55
- package/test/config-file-no-reload.json +0 -69
- package/test/config-file-reload.json +0 -68
- package/test/config-invitation.json +0 -63
- package/test/config-kube-reload.json +0 -68
- package/test/config-reload.json +0 -66
- package/test/config.old.json +0 -152
- package/test/jsonutils/mdocs.yaml +0 -56
- package/test/jsonutils/test.json +0 -3
- package/test/jsonutils/test.yml +0 -5
- package/test/moddas/annotatedservice.js +0 -23
- package/test/moddas/debugmailer.js +0 -13
- package/test/moddas/fakeservice.js +0 -4
- package/test/moddas/voidstore.js +0 -66
- package/test/models/ident.js +0 -36
- package/test/models/task.js +0 -42
package/lib/services/cron.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { createHash } from "crypto";
|
|
2
|
-
import { schedule } from "node-cron";
|
|
3
|
-
import { CancelablePromise } from "../index.js";
|
|
4
|
-
import { Service } from "./service.js";
|
|
5
|
-
/**
|
|
6
|
-
* Cron item
|
|
7
|
-
*/
|
|
8
|
-
export class CronDefinition {
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
* @param cron
|
|
12
|
-
* @param args
|
|
13
|
-
* @param serviceName
|
|
14
|
-
* @param method
|
|
15
|
-
* @param description
|
|
16
|
-
*/
|
|
17
|
-
constructor(cron, args = [], serviceName = "", method = "", description = "") {
|
|
18
|
-
this.cron = cron;
|
|
19
|
-
this.serviceName = serviceName;
|
|
20
|
-
this.method = method;
|
|
21
|
-
this.description = description;
|
|
22
|
-
this.args = args;
|
|
23
|
-
}
|
|
24
|
-
toString() {
|
|
25
|
-
return `${this.cron}: ${this.serviceName}.${this.method}(${this.args.map(a => a.toString()).join(",")})${this.description !== "" ? ` # ${this.description}` : ""}`;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* @WebdaModda
|
|
30
|
-
*/
|
|
31
|
-
class CronService extends Service {
|
|
32
|
-
constructor() {
|
|
33
|
-
super(...arguments);
|
|
34
|
-
this.crons = [];
|
|
35
|
-
this.crontabSchedule = schedule;
|
|
36
|
-
this._scanned = false;
|
|
37
|
-
}
|
|
38
|
-
static Annotation(cron, description = "", ...args) {
|
|
39
|
-
return (_target, property, descriptor) => {
|
|
40
|
-
descriptor.value.cron = descriptor.value.cron || [];
|
|
41
|
-
descriptor.value.cron.push(new CronDefinition(cron, args, "", property, description));
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
static getCronId(cron, name = "") {
|
|
45
|
-
let hash = createHash("sha256");
|
|
46
|
-
return hash
|
|
47
|
-
.update(JSON.stringify(cron) + name)
|
|
48
|
-
.digest("hex")
|
|
49
|
-
.substring(0, 8);
|
|
50
|
-
}
|
|
51
|
-
static loadAnnotations(services) {
|
|
52
|
-
let cronsResult = [];
|
|
53
|
-
for (let i in services) {
|
|
54
|
-
let props = Object.getOwnPropertyDescriptors(services[i].constructor.prototype);
|
|
55
|
-
for (let method in props) {
|
|
56
|
-
// @ts-ignore
|
|
57
|
-
let crons = props[method].value?.cron;
|
|
58
|
-
if (crons) {
|
|
59
|
-
crons.forEach(cron => {
|
|
60
|
-
cron.method = method;
|
|
61
|
-
cron.serviceName = i;
|
|
62
|
-
cronsResult.push(cron);
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return cronsResult;
|
|
68
|
-
}
|
|
69
|
-
addAnnotations() {
|
|
70
|
-
if (this._scanned) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
this._scanned = true;
|
|
74
|
-
this.crons.push(...CronService.loadAnnotations(this._webda.getServices()));
|
|
75
|
-
}
|
|
76
|
-
getCrontab() {
|
|
77
|
-
// Load all annotations
|
|
78
|
-
this.addAnnotations();
|
|
79
|
-
return this.crons;
|
|
80
|
-
}
|
|
81
|
-
work(annotations = "true") {
|
|
82
|
-
return this.run(annotations === "true");
|
|
83
|
-
}
|
|
84
|
-
run(annotations = true) {
|
|
85
|
-
this.log("INFO", "Running crontab with" + (annotations ? "" : "out"), "annotations");
|
|
86
|
-
// Load all annotations
|
|
87
|
-
if (annotations) {
|
|
88
|
-
this.addAnnotations();
|
|
89
|
-
}
|
|
90
|
-
this.enable = true;
|
|
91
|
-
// Run schedule
|
|
92
|
-
this.crons.forEach(i => {
|
|
93
|
-
if (i.cb) {
|
|
94
|
-
this.schedule(i.cron, i.cb);
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
this.schedule(i.cron, () => {
|
|
98
|
-
this.getService(i.serviceName)[i.method](...i.args);
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
let msgs = [];
|
|
103
|
-
// Display before
|
|
104
|
-
this.crons.forEach(c => {
|
|
105
|
-
if (c.cb) {
|
|
106
|
-
msgs.push(`[NativeCode:${c.context || ""}]`);
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
msgs.push(`${c.serviceName}.${c.method}(${c.args.length ? "..." + c.args : ""})`);
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
let cronPad = Math.max(...this.crons.map(c => c.cron.length));
|
|
113
|
-
let servicePad = Math.max(...msgs.map(c => c.length));
|
|
114
|
-
this.crons.forEach((c, i) => {
|
|
115
|
-
this.log("INFO", `${c.cron.padEnd(cronPad)} : ${msgs[i].padEnd(servicePad)}${c.description ? " # " + c.description : ""}`);
|
|
116
|
-
});
|
|
117
|
-
// Remove from memory
|
|
118
|
-
this.crons = [];
|
|
119
|
-
return new CancelablePromise();
|
|
120
|
-
}
|
|
121
|
-
schedule(cron, cb, description = "") {
|
|
122
|
-
if (this.enable) {
|
|
123
|
-
this.crontabSchedule(cron, cb);
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
let context;
|
|
127
|
-
try {
|
|
128
|
-
throw new Error();
|
|
129
|
-
}
|
|
130
|
-
catch (err) {
|
|
131
|
-
// Based on stack trace (not super clean)
|
|
132
|
-
let info = err.stack.split("\n")[2].match(/\((.*)\)/);
|
|
133
|
-
context = info[1].replace(process.cwd() + "/", "");
|
|
134
|
-
}
|
|
135
|
-
this.crons.push({ cron, cb, description, context });
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
const Cron = CronService.Annotation;
|
|
140
|
-
export { Cron, CronService };
|
|
141
|
-
//# sourceMappingURL=cron.js.map
|
package/lib/services/cron.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cron.js","sourceRoot":"","sources":["../../src/services/cron.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;GAEG;AACH,MAAM,OAAO,cAAc;IAwBzB;;;;;;;OAOG;IACH,YAAY,IAAY,EAAE,OAAc,EAAE,EAAE,cAAsB,EAAE,EAAE,SAAiB,EAAE,EAAE,cAAsB,EAAE;QACjH,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,QAAQ;QACN,OAAO,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IACnG,IAAI,CAAC,WAAW,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EACvD,EAAE,CAAC;IACL,CAAC;CACF;AAED;;GAEG;AACH,MAAM,WAAY,SAAQ,OAAO;IAAjC;;QAEE,UAAK,GAQC,EAAE,CAAC;QACT,oBAAe,GAAG,QA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arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
import { suite, test } from "@testdeck/mocha";
|
|
8
|
-
import * as assert from "assert";
|
|
9
|
-
import { Cron, CronDefinition, CronService, Service } from "...js";
|
|
10
|
-
import { WebdaTest } from "../test.js";
|
|
11
|
-
class MyService extends Service {
|
|
12
|
-
test() {
|
|
13
|
-
// Empty one
|
|
14
|
-
}
|
|
15
|
-
test2(myArg) { }
|
|
16
|
-
}
|
|
17
|
-
__decorate([
|
|
18
|
-
Cron("0/15 * * * *", "plop")
|
|
19
|
-
], MyService.prototype, "test", null);
|
|
20
|
-
__decorate([
|
|
21
|
-
Cron("0/25 * * * *", undefined, "myArg")
|
|
22
|
-
], MyService.prototype, "test2", null);
|
|
23
|
-
let CronServiceTest = class CronServiceTest extends WebdaTest {
|
|
24
|
-
async buildWebda() {
|
|
25
|
-
await super.buildWebda();
|
|
26
|
-
this.webda.getBeans = () => { };
|
|
27
|
-
}
|
|
28
|
-
annotations() {
|
|
29
|
-
this.registerService(new MyService(this.webda, "myService", {}));
|
|
30
|
-
let def = new CronDefinition("0/15 * * * *", [], "myService", "test", "plop");
|
|
31
|
-
let service = new CronService(this.webda, "cron", {});
|
|
32
|
-
service.schedule("* * * * *", () => { }, "mine");
|
|
33
|
-
assert.deepStrictEqual(service.getCrontab()[1], def);
|
|
34
|
-
// for cov
|
|
35
|
-
assert.deepStrictEqual(service.getCrontab()[1], def);
|
|
36
|
-
service.crontabSchedule = (cron, cb) => {
|
|
37
|
-
try {
|
|
38
|
-
cb();
|
|
39
|
-
}
|
|
40
|
-
catch (err) { }
|
|
41
|
-
};
|
|
42
|
-
try {
|
|
43
|
-
let promise = service.work();
|
|
44
|
-
promise.cancel();
|
|
45
|
-
service.enable = false;
|
|
46
|
-
service.schedule("* * * * *", () => { }, "mine");
|
|
47
|
-
service.crons[0].context = undefined;
|
|
48
|
-
promise = service.run();
|
|
49
|
-
promise.cancel();
|
|
50
|
-
promise = service.run(false);
|
|
51
|
-
promise.cancel();
|
|
52
|
-
}
|
|
53
|
-
finally {
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
__decorate([
|
|
58
|
-
test
|
|
59
|
-
], CronServiceTest.prototype, "annotations", null);
|
|
60
|
-
CronServiceTest = __decorate([
|
|
61
|
-
suite
|
|
62
|
-
], CronServiceTest);
|
|
63
|
-
let CronDefinitionTest = class CronDefinitionTest {
|
|
64
|
-
testString() {
|
|
65
|
-
assert.strictEqual(new CronDefinition("* * * * *").toString(), "* * * * *: .()");
|
|
66
|
-
assert.strictEqual(CronService.getCronId(new CronDefinition("* * * * *"), "plop"), "5e281c06");
|
|
67
|
-
assert.strictEqual(new CronDefinition("* * * * *", [{}, {}], "plop", "method", "desc").toString(), "* * * * *: plop.method([object Object],[object Object]) # desc");
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
__decorate([
|
|
71
|
-
test
|
|
72
|
-
], CronDefinitionTest.prototype, "testString", null);
|
|
73
|
-
CronDefinitionTest = __decorate([
|
|
74
|
-
suite
|
|
75
|
-
], CronDefinitionTest);
|
|
76
|
-
//# sourceMappingURL=cron.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cron.spec.js","sourceRoot":"","sources":["../../src/services/cron.spec.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,IAAI,E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IAAI;oDAQJ;AATG,kBAAkB;IADvB,KAAK;GACA,kBAAkB,CAUvB"}
|
|
@@ -1,434 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
import { createCipheriv, createDecipheriv, createHash, createHmac, generateKeyPairSync, randomBytes } from "crypto";
|
|
8
|
-
import jwt from "jsonwebtoken";
|
|
9
|
-
import { pem2jwk } from "pem-jwk";
|
|
10
|
-
import * as util from "util";
|
|
11
|
-
import { Core } from "../index.js";
|
|
12
|
-
import { JSONUtils } from "../utils/serializers.js";
|
|
13
|
-
import { Inject, Route, Service, ServiceParameters } from "./service.js";
|
|
14
|
-
export class SecretString {
|
|
15
|
-
constructor(str, encrypter) {
|
|
16
|
-
this.str = str;
|
|
17
|
-
this.encrypter = encrypter;
|
|
18
|
-
}
|
|
19
|
-
static from(value, path) {
|
|
20
|
-
if (value instanceof SecretString) {
|
|
21
|
-
return value.getValue();
|
|
22
|
-
}
|
|
23
|
-
if (Core.get()) {
|
|
24
|
-
Core.get()?.log("WARN", "A secret string is not encrypted", value);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
console.error("WARN", "A secret string is not encrypted");
|
|
28
|
-
}
|
|
29
|
-
return value;
|
|
30
|
-
}
|
|
31
|
-
getValue() {
|
|
32
|
-
return this.str;
|
|
33
|
-
}
|
|
34
|
-
toString() {
|
|
35
|
-
return "********";
|
|
36
|
-
}
|
|
37
|
-
[util.inspect.custom](depth, options, inspect) {
|
|
38
|
-
return "********";
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
export class CryptoServiceParameters extends ServiceParameters {
|
|
42
|
-
constructor(params) {
|
|
43
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
44
|
-
super(params);
|
|
45
|
-
this.symetricKeyLength ?? (this.symetricKeyLength = 256);
|
|
46
|
-
this.symetricCipher ?? (this.symetricCipher = "aes-256-ctr");
|
|
47
|
-
this.asymetricType ?? (this.asymetricType = "rsa");
|
|
48
|
-
this.asymetricOptions ?? (this.asymetricOptions = {});
|
|
49
|
-
(_a = this.asymetricOptions).modulusLength ?? (_a.modulusLength = 2048);
|
|
50
|
-
(_b = this.asymetricOptions).privateKeyEncoding ?? (_b.privateKeyEncoding = {});
|
|
51
|
-
(_c = this.asymetricOptions.privateKeyEncoding).format ?? (_c.format = "pem");
|
|
52
|
-
(_d = this.asymetricOptions.privateKeyEncoding).type ?? (_d.type = "pkcs8");
|
|
53
|
-
(_e = this.asymetricOptions).publicKeyEncoding ?? (_e.publicKeyEncoding = {});
|
|
54
|
-
(_f = this.asymetricOptions.publicKeyEncoding).format ?? (_f.format = "pem");
|
|
55
|
-
(_g = this.asymetricOptions.publicKeyEncoding).type ?? (_g.type = "spki");
|
|
56
|
-
this.jwt ?? (this.jwt = {});
|
|
57
|
-
(_h = this.jwt).algorithm ?? (_h.algorithm = "HS256");
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* @WebdaModda
|
|
62
|
-
*/
|
|
63
|
-
class CryptoService extends Service {
|
|
64
|
-
constructor() {
|
|
65
|
-
super(...arguments);
|
|
66
|
-
/**
|
|
67
|
-
* JWKS cache
|
|
68
|
-
*/
|
|
69
|
-
this.jwks = {};
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Register an encrypter for configuration
|
|
73
|
-
* @param name
|
|
74
|
-
* @param encrypter
|
|
75
|
-
*/
|
|
76
|
-
static registerEncrypter(name, encrypter) {
|
|
77
|
-
if (CryptoService.encrypters[name]) {
|
|
78
|
-
console.error("Encrypter", name, "already registered");
|
|
79
|
-
}
|
|
80
|
-
CryptoService.encrypters[name] = encrypter;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* @override
|
|
84
|
-
*/
|
|
85
|
-
loadParameters(params) {
|
|
86
|
-
return new CryptoServiceParameters(params);
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* @override
|
|
90
|
-
*/
|
|
91
|
-
async init() {
|
|
92
|
-
await super.init();
|
|
93
|
-
CryptoService.encrypters["self"] = this;
|
|
94
|
-
// Load keys
|
|
95
|
-
if (!(await this.load()) && this.parameters.autoCreate) {
|
|
96
|
-
await this.rotate();
|
|
97
|
-
}
|
|
98
|
-
return this;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
*
|
|
102
|
-
*/
|
|
103
|
-
async serveJWKS(context) {
|
|
104
|
-
context.write({
|
|
105
|
-
keys: Object.keys(this.keys).map(k => {
|
|
106
|
-
if (!this.jwks[k]) {
|
|
107
|
-
/*
|
|
108
|
-
when Node >= 16
|
|
109
|
-
this.jwks[k] = createPublicKey(this.keys[k].publicKey).export({ format: "jwk" });
|
|
110
|
-
and remove pem-jwk
|
|
111
|
-
*/
|
|
112
|
-
this.jwks[k] = pem2jwk(this.keys[k].publicKey);
|
|
113
|
-
}
|
|
114
|
-
return {
|
|
115
|
-
kty: "RSA",
|
|
116
|
-
kid: k,
|
|
117
|
-
n: this.jwks[k].n,
|
|
118
|
-
e: this.jwks[k].e
|
|
119
|
-
};
|
|
120
|
-
})
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Load keys from registry
|
|
125
|
-
*/
|
|
126
|
-
async load() {
|
|
127
|
-
let load = await this.registry.get("keys");
|
|
128
|
-
if (!load) {
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
|
-
this.keys = {};
|
|
132
|
-
Object.keys(load)
|
|
133
|
-
.filter(k => k.startsWith("key_"))
|
|
134
|
-
.forEach(k => {
|
|
135
|
-
this.keys[k.substring(4)] = load[k];
|
|
136
|
-
});
|
|
137
|
-
this.current = load.current.startsWith("init-") ? undefined : load.current;
|
|
138
|
-
this.age = parseInt(this.current, 36);
|
|
139
|
-
return true;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Generate asymetric key
|
|
143
|
-
* @returns
|
|
144
|
-
*/
|
|
145
|
-
generateAsymetricKeys() {
|
|
146
|
-
const { publicKey, privateKey } = generateKeyPairSync(
|
|
147
|
-
// @ts-ignore
|
|
148
|
-
this.parameters.asymetricType, this.parameters.asymetricOptions);
|
|
149
|
-
return { publicKey, privateKey };
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Generate symetric key
|
|
153
|
-
* @returns
|
|
154
|
-
*/
|
|
155
|
-
generateSymetricKey() {
|
|
156
|
-
return randomBytes(this.parameters.symetricKeyLength / 8).toString("base64");
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Return current key set
|
|
160
|
-
*/
|
|
161
|
-
async getCurrentKeys() {
|
|
162
|
-
if (!this.keys || !this.current || !this.keys[this.current]) {
|
|
163
|
-
throw new Error("CryptoService not initialized");
|
|
164
|
-
}
|
|
165
|
-
return { keys: this.keys[this.current], id: this.current };
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Retrieve a HMAC for a string
|
|
169
|
-
* @param data
|
|
170
|
-
* @param keyId to use
|
|
171
|
-
* @returns
|
|
172
|
-
*/
|
|
173
|
-
async hmac(data, keyId) {
|
|
174
|
-
if (typeof data !== "string") {
|
|
175
|
-
data = JSONUtils.stringify(data);
|
|
176
|
-
}
|
|
177
|
-
let key = keyId ? { id: keyId, keys: this.keys[keyId] } : await this.getCurrentKeys();
|
|
178
|
-
return key.id + "." + createHmac("sha256", key.keys.symetric).update(data).digest("hex");
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Verify a HMAC for a string
|
|
182
|
-
* @param data
|
|
183
|
-
* @returns
|
|
184
|
-
*/
|
|
185
|
-
async hmacVerify(data, hmac) {
|
|
186
|
-
if (typeof data !== "string") {
|
|
187
|
-
data = JSONUtils.stringify(data);
|
|
188
|
-
}
|
|
189
|
-
let [keyId, mac] = hmac.split(".");
|
|
190
|
-
if (!(await this.checkKey(keyId))) {
|
|
191
|
-
return false;
|
|
192
|
-
}
|
|
193
|
-
return createHmac("sha256", this.keys[keyId].symetric).update(data).digest("hex") === mac;
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* JWT token generation
|
|
197
|
-
*/
|
|
198
|
-
async jwtSign(data, options) {
|
|
199
|
-
let res = { ...this.parameters.jwt, ...options };
|
|
200
|
-
let key = res.secretOrPublicKey;
|
|
201
|
-
// Default to our current private key
|
|
202
|
-
if (!res.secretOrPublicKey) {
|
|
203
|
-
let keyInfo = await this.getCurrentKeys();
|
|
204
|
-
// Depending on the algo fallback to the right key
|
|
205
|
-
if (res.algorithm.startsWith("HS")) {
|
|
206
|
-
key = keyInfo.keys.symetric;
|
|
207
|
-
res.keyid = "S" + keyInfo.id;
|
|
208
|
-
}
|
|
209
|
-
else {
|
|
210
|
-
key = keyInfo.keys.privateKey;
|
|
211
|
-
res.keyid = "A" + keyInfo.id;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
delete res.secretOrPublicKey;
|
|
215
|
-
return jwt.sign(data, key, res);
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
*
|
|
219
|
-
* @param keyId
|
|
220
|
-
* @returns
|
|
221
|
-
*/
|
|
222
|
-
async checkKey(keyId) {
|
|
223
|
-
if (!this.keys[keyId]) {
|
|
224
|
-
// Key is more recent than current one so try to reload
|
|
225
|
-
if (parseInt(keyId, 36) > this.age) {
|
|
226
|
-
await this.load();
|
|
227
|
-
}
|
|
228
|
-
// Key is still not found
|
|
229
|
-
if (!this.keys[keyId]) {
|
|
230
|
-
return false;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
return true;
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Get JWT key based on kid
|
|
237
|
-
*/
|
|
238
|
-
async getJWTKey(header, callback) {
|
|
239
|
-
if (!header.kid) {
|
|
240
|
-
callback(new Error("Unknown key"));
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
let keyId = header.kid.substring(1);
|
|
244
|
-
if (!(await this.checkKey(keyId))) {
|
|
245
|
-
callback(new Error("Unknown key"));
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
// Check first letter that define Symetric or Asymetric
|
|
249
|
-
if (header.kid.startsWith("S")) {
|
|
250
|
-
callback(null, this.keys[keyId].symetric);
|
|
251
|
-
}
|
|
252
|
-
else if (header.kid.startsWith("A")) {
|
|
253
|
-
callback(null, this.keys[keyId].publicKey);
|
|
254
|
-
}
|
|
255
|
-
else {
|
|
256
|
-
callback(new Error("Unknown key"));
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* JWT token verification
|
|
261
|
-
*/
|
|
262
|
-
async jwtVerify(token, options) {
|
|
263
|
-
return new Promise((resolve, reject) => {
|
|
264
|
-
jwt.verify(token, options?.secretOrPublicKey || this.getJWTKey.bind(this), {
|
|
265
|
-
...options,
|
|
266
|
-
secretOrPublicKey: undefined
|
|
267
|
-
}, (err, result) => {
|
|
268
|
-
if (err) {
|
|
269
|
-
reject(err);
|
|
270
|
-
}
|
|
271
|
-
else {
|
|
272
|
-
resolve(result);
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
/**
|
|
278
|
-
* Encrypt data
|
|
279
|
-
*/
|
|
280
|
-
async encrypt(data) {
|
|
281
|
-
let key = await this.getCurrentKeys();
|
|
282
|
-
// Initialization Vector
|
|
283
|
-
let iv = randomBytes(16);
|
|
284
|
-
let cipher = createCipheriv(this.parameters.symetricCipher, Buffer.from(key.keys.symetric, "base64"), iv);
|
|
285
|
-
let encrypted = Buffer.concat([iv, cipher.update(Buffer.from(JSON.stringify(data))), cipher.final()]).toString("base64");
|
|
286
|
-
return this.jwtSign(encrypted, {
|
|
287
|
-
keyid: `S${key.id}`,
|
|
288
|
-
secretOrPublicKey: key.keys.symetric
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
/**
|
|
292
|
-
* Parse the JWT header section
|
|
293
|
-
*/
|
|
294
|
-
getJWTHeader(token) {
|
|
295
|
-
return JSON.parse(Buffer.from(token.split(".")[0], "base64").toString());
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* Encrypt configuration
|
|
299
|
-
* @param data
|
|
300
|
-
*/
|
|
301
|
-
static async encryptConfiguration(data) {
|
|
302
|
-
if (data instanceof Object) {
|
|
303
|
-
for (let i in data) {
|
|
304
|
-
data[i] = await CryptoService.encryptConfiguration(data[i]);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
else if (typeof data === "string") {
|
|
308
|
-
if (data.startsWith("encrypt:") || data.startsWith("sencrypt:")) {
|
|
309
|
-
let str = data.substring(data.indexOf(":") + 1);
|
|
310
|
-
let type = str.substring(0, str.indexOf(":"));
|
|
311
|
-
str = str.substring(str.indexOf(":") + 1);
|
|
312
|
-
if (!CryptoService.encrypters[type]) {
|
|
313
|
-
throw new Error("Unknown encrypter " + type);
|
|
314
|
-
}
|
|
315
|
-
if (data.startsWith("s")) {
|
|
316
|
-
data = `scrypt:${type}:` + (await CryptoService.encrypters[type].encrypt(str));
|
|
317
|
-
}
|
|
318
|
-
else {
|
|
319
|
-
data = `crypt:${type}:` + (await CryptoService.encrypters[type].encrypt(str));
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
return data;
|
|
324
|
-
}
|
|
325
|
-
/**
|
|
326
|
-
*
|
|
327
|
-
* @param data
|
|
328
|
-
*/
|
|
329
|
-
static async decryptConfiguration(data) {
|
|
330
|
-
if (data instanceof Object) {
|
|
331
|
-
for (let i in data) {
|
|
332
|
-
data[i] = await CryptoService.decryptConfiguration(data[i]);
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
else if (typeof data === "string") {
|
|
336
|
-
if (data.startsWith("crypt:") || data.startsWith("scrypt:")) {
|
|
337
|
-
let str = data.substring(data.indexOf(":") + 1);
|
|
338
|
-
let type = str.substring(0, str.indexOf(":"));
|
|
339
|
-
str = str.substring(str.indexOf(":") + 1);
|
|
340
|
-
if (!CryptoService.encrypters[type]) {
|
|
341
|
-
throw new Error("Unknown encrypter " + type);
|
|
342
|
-
}
|
|
343
|
-
// We keep the ability to map to a simple string for incompatible module
|
|
344
|
-
if (data.startsWith("scrypt:")) {
|
|
345
|
-
return await CryptoService.encrypters[type].decrypt(str);
|
|
346
|
-
}
|
|
347
|
-
else {
|
|
348
|
-
return new SecretString(await CryptoService.encrypters[type].decrypt(str), type);
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
return data;
|
|
353
|
-
}
|
|
354
|
-
/**
|
|
355
|
-
* Decrypt data
|
|
356
|
-
*/
|
|
357
|
-
async decrypt(token) {
|
|
358
|
-
let input = Buffer.from(await this.jwtVerify(token), "base64");
|
|
359
|
-
let header = this.getJWTHeader(token);
|
|
360
|
-
let iv = input.subarray(0, 16);
|
|
361
|
-
let decipher = createDecipheriv(this.parameters.symetricCipher, Buffer.from(this.keys[header.kid.substring(1)].symetric, "base64"), iv);
|
|
362
|
-
return JSON.parse(decipher.update(input.subarray(16)).toString() + decipher.final().toString());
|
|
363
|
-
}
|
|
364
|
-
/**
|
|
365
|
-
* Get next id
|
|
366
|
-
*/
|
|
367
|
-
getNextId() {
|
|
368
|
-
// Should be good for years as 8char
|
|
369
|
-
let age = Math.floor(Date.now() / 1000);
|
|
370
|
-
return { age, id: age.toString(36) };
|
|
371
|
-
}
|
|
372
|
-
/**
|
|
373
|
-
* Rotate keys
|
|
374
|
-
*/
|
|
375
|
-
async rotate() {
|
|
376
|
-
const { age, id } = this.getNextId();
|
|
377
|
-
let next = {
|
|
378
|
-
current: id,
|
|
379
|
-
rotationInstance: this.getWebda().getInstanceId()
|
|
380
|
-
};
|
|
381
|
-
next[`key_${id}`] = {
|
|
382
|
-
...this.generateAsymetricKeys(),
|
|
383
|
-
symetric: this.generateSymetricKey()
|
|
384
|
-
};
|
|
385
|
-
if (!(await this.registry.exists("keys"))) {
|
|
386
|
-
this.current = `init-${this.getWebda().getInstanceId()}`;
|
|
387
|
-
await this.registry.put("keys", { current: this.current });
|
|
388
|
-
}
|
|
389
|
-
if (await this.registry.conditionalPatch("keys", next, "current", this.current)) {
|
|
390
|
-
this.keys ?? (this.keys = {});
|
|
391
|
-
this.keys[id] = next[`key_${id}`];
|
|
392
|
-
this.current = id;
|
|
393
|
-
this.age = age;
|
|
394
|
-
}
|
|
395
|
-
else {
|
|
396
|
-
// Reload as something else has modified
|
|
397
|
-
await this.load();
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
CryptoService.encrypters = {};
|
|
402
|
-
export default CryptoService;
|
|
403
|
-
__decorate([
|
|
404
|
-
Inject("Registry")
|
|
405
|
-
], CryptoService.prototype, "registry", void 0);
|
|
406
|
-
__decorate([
|
|
407
|
-
Route(".", ["GET"], {
|
|
408
|
-
description: "Serve JWKS keys",
|
|
409
|
-
get: {
|
|
410
|
-
operationId: "getJWKS"
|
|
411
|
-
}
|
|
412
|
-
})
|
|
413
|
-
], CryptoService.prototype, "serveJWKS", null);
|
|
414
|
-
/**
|
|
415
|
-
* Encrypt data with local machine id
|
|
416
|
-
*/
|
|
417
|
-
CryptoService.registerEncrypter("local", {
|
|
418
|
-
encrypt: async (data) => {
|
|
419
|
-
// Initialization Vector
|
|
420
|
-
let iv = randomBytes(16);
|
|
421
|
-
const key = createHash("sha256").update(Core.getMachineId()).digest();
|
|
422
|
-
let cipher = createCipheriv("aes-256-ctr", key, iv);
|
|
423
|
-
return Buffer.concat([iv, cipher.update(Buffer.from(data)), cipher.final()]).toString("base64");
|
|
424
|
-
},
|
|
425
|
-
decrypt: async (data) => {
|
|
426
|
-
let input = Buffer.from(data, "base64");
|
|
427
|
-
let iv = input.subarray(0, 16);
|
|
428
|
-
const key = createHash("sha256").update(Core.getMachineId()).digest();
|
|
429
|
-
let decipher = createDecipheriv("aes-256-ctr", key, iv);
|
|
430
|
-
return decipher.update(input.subarray(16)).toString() + decipher.final().toString();
|
|
431
|
-
}
|
|
432
|
-
});
|
|
433
|
-
export { CryptoService };
|
|
434
|
-
//# sourceMappingURL=cryptoservice.js.map
|