@slopware/sloppy-darwin-arm64 0.1.0-alpha.0
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/LICENSE +201 -0
- package/README.md +5 -0
- package/bin/sloppy +0 -0
- package/bin/sloppyc +0 -0
- package/docs/KNOWN_LIMITATIONS.md +16 -0
- package/docs/LICENSES.md +6 -0
- package/docs/NOTICE.md +8 -0
- package/examples/README.md +140 -0
- package/examples/auth-api/README.md +20 -0
- package/examples/auth-api/app.js +61 -0
- package/examples/auth-api/appsettings.json +7 -0
- package/examples/auth-api/sloppy.json +5 -0
- package/examples/cache-basic/README.md +9 -0
- package/examples/cache-basic/app.js +32 -0
- package/examples/cache-hybrid-postgres/README.md +10 -0
- package/examples/cache-hybrid-postgres/app.js +27 -0
- package/examples/cache-output-api/README.md +10 -0
- package/examples/cache-output-api/app.js +35 -0
- package/examples/codec-base64-hex/README.md +14 -0
- package/examples/codec-base64-hex/app.js +15 -0
- package/examples/codec-checksums/README.md +15 -0
- package/examples/codec-checksums/app.js +8 -0
- package/examples/codec-compression/README.md +13 -0
- package/examples/codec-compression/app.js +9 -0
- package/examples/codec-streaming-compression/README.md +19 -0
- package/examples/codec-streaming-compression/app.js +16 -0
- package/examples/codec-text-binary/README.md +16 -0
- package/examples/codec-text-binary/app.js +17 -0
- package/examples/compiler-hello/README.md +71 -0
- package/examples/compiler-hello/app.js +7 -0
- package/examples/compiler-hello/expected/app.js +8 -0
- package/examples/compiler-hello/expected/app.js.map +53 -0
- package/examples/compiler-hello/expected/app.plan.json +229 -0
- package/examples/compiler-hello/expected/routes.slrt +0 -0
- package/examples/config-basic/README.md +13 -0
- package/examples/config-basic/app.js +13 -0
- package/examples/config-basic/appsettings.json +7 -0
- package/examples/config-secrets-redaction/README.md +9 -0
- package/examples/config-secrets-redaction/app.js +9 -0
- package/examples/config-secrets-redaction/appsettings.json +5 -0
- package/examples/config-strict-mode/README.md +7 -0
- package/examples/config-strict-mode/app.js +10 -0
- package/examples/config-strict-mode/appsettings.json +7 -0
- package/examples/configured-api/README.md +38 -0
- package/examples/configured-api/app.js +12 -0
- package/examples/configured-api/appsettings.Development.json +5 -0
- package/examples/configured-api/appsettings.json +6 -0
- package/examples/configured-api/sloppy.json +5 -0
- package/examples/core-config-secrets/README.md +10 -0
- package/examples/core-config-secrets/app.js +15 -0
- package/examples/core-fs-time-codec/README.md +9 -0
- package/examples/core-fs-time-codec/app.js +8 -0
- package/examples/core-network-time-codec/README.md +11 -0
- package/examples/core-network-time-codec/app.js +20 -0
- package/examples/core-policy-audit/README.md +7 -0
- package/examples/core-policy-audit/app.js +22 -0
- package/examples/core-process-time-codec/README.md +8 -0
- package/examples/core-process-time-codec/app.js +28 -0
- package/examples/core-worker-time/README.md +8 -0
- package/examples/core-worker-time/app.js +17 -0
- package/examples/crypto-hash-hmac/README.md +17 -0
- package/examples/crypto-hash-hmac/app.js +29 -0
- package/examples/crypto-password/README.md +21 -0
- package/examples/crypto-password/app.js +12 -0
- package/examples/crypto-random-token/README.md +16 -0
- package/examples/crypto-random-token/app.js +12 -0
- package/examples/crypto-secret-constant-time/README.md +21 -0
- package/examples/crypto-secret-constant-time/app.js +15 -0
- package/examples/data-foundation/README.md +39 -0
- package/examples/data-foundation/app.js +63 -0
- package/examples/dependency-graph/README.md +19 -0
- package/examples/dependency-graph/fixtures/graph-helper/index.js +3 -0
- package/examples/dependency-graph/fixtures/graph-helper/package.json +6 -0
- package/examples/dependency-graph/package.json +7 -0
- package/examples/dependency-graph/public/message.txt +1 -0
- package/examples/dependency-graph/sloppy.json +9 -0
- package/examples/dependency-graph/src/main.ts +8 -0
- package/examples/dogfood/README.md +23 -0
- package/examples/dogfood/dogfood.json +136 -0
- package/examples/dynamic-module-include/README.md +20 -0
- package/examples/dynamic-module-include/public/readme.txt +1 -0
- package/examples/dynamic-module-include/sloppy.json +12 -0
- package/examples/dynamic-module-include/src/main.ts +6 -0
- package/examples/dynamic-module-include/src/plugins/alpha.js +3 -0
- package/examples/dynamic-module-include/src/plugins/beta.js +3 -0
- package/examples/ergonomics/README.md +42 -0
- package/examples/ergonomics/app.js +38 -0
- package/examples/framework-controller/README.md +12 -0
- package/examples/framework-controller/app.js +31 -0
- package/examples/framework-di-services/README.md +17 -0
- package/examples/framework-di-services/app.ts +40 -0
- package/examples/framework-explicit-binding/README.md +12 -0
- package/examples/framework-explicit-binding/app.ts +34 -0
- package/examples/framework-hello/README.md +16 -0
- package/examples/framework-hello/app.ts +16 -0
- package/examples/framework-postgres-crud/README.md +73 -0
- package/examples/framework-postgres-crud/app.ts +64 -0
- package/examples/framework-sqlite-crud/README.md +52 -0
- package/examples/framework-sqlite-crud/app.ts +90 -0
- package/examples/framework-sqlite-crud/appsettings.json +11 -0
- package/examples/framework-sqlserver-crud/README.md +73 -0
- package/examples/framework-sqlserver-crud/app.ts +64 -0
- package/examples/framework-validation-errors/README.md +12 -0
- package/examples/framework-validation-errors/app.ts +16 -0
- package/examples/fs-basic/README.md +24 -0
- package/examples/fs-basic/app.js +12 -0
- package/examples/fs-roots-policy/README.md +14 -0
- package/examples/fs-roots-policy/app.js +4 -0
- package/examples/fs-streams/README.md +18 -0
- package/examples/fs-streams/app.js +11 -0
- package/examples/fs-watch/README.md +19 -0
- package/examples/fs-watch/app.js +11 -0
- package/examples/hello/README.md +63 -0
- package/examples/hello/app.js +19 -0
- package/examples/hello-minimal/README.md +51 -0
- package/examples/hello-minimal/sloppy.json +5 -0
- package/examples/hello-minimal/src/main.ts +9 -0
- package/examples/http-client-basic/README.md +11 -0
- package/examples/http-client-basic/app.js +46 -0
- package/examples/http-client-generated/README.md +22 -0
- package/examples/http-client-generated/openapi.json +45 -0
- package/examples/http-client-resilience/README.md +4 -0
- package/examples/http-client-resilience/app.js +38 -0
- package/examples/http-client-runtime-loopback/README.md +24 -0
- package/examples/http-client-testhost/README.md +4 -0
- package/examples/http-client-testhost/app.js +27 -0
- package/examples/http-client-testhost-package-mock/README.md +26 -0
- package/examples/http-client-typed/README.md +5 -0
- package/examples/http-client-typed/app.js +33 -0
- package/examples/modules-api/README.md +30 -0
- package/examples/modules-api/app.js +9 -0
- package/examples/modules-api/modules/routes.js +16 -0
- package/examples/modules-api/sloppy.json +5 -0
- package/examples/modules-basic/README.md +32 -0
- package/examples/modules-basic/app.js +41 -0
- package/examples/net-deadline-cancel/README.md +13 -0
- package/examples/net-deadline-cancel/app.js +34 -0
- package/examples/net-local-ipc/README.md +12 -0
- package/examples/net-local-ipc/app.js +46 -0
- package/examples/net-policy-strict/README.md +12 -0
- package/examples/net-policy-strict/app.js +34 -0
- package/examples/net-tcp-client/README.md +10 -0
- package/examples/net-tcp-client/app.js +23 -0
- package/examples/net-tcp-echo/README.md +11 -0
- package/examples/net-tcp-echo/app.js +45 -0
- package/examples/net-tcp-server/README.md +10 -0
- package/examples/net-tcp-server/app.js +28 -0
- package/examples/node-compat-path-events/README.md +15 -0
- package/examples/node-compat-path-events/sloppy.json +6 -0
- package/examples/node-compat-path-events/src/main.ts +15 -0
- package/examples/ops-compiler/README.md +9 -0
- package/examples/ops-compiler/app.js +26 -0
- package/examples/ops-health-metrics-management/README.md +14 -0
- package/examples/ops-health-metrics-management/app.js +24 -0
- package/examples/orm-basic/README.md +17 -0
- package/examples/orm-basic/app.js +82 -0
- package/examples/orm-cursor-export/README.md +16 -0
- package/examples/orm-cursor-export/app.js +28 -0
- package/examples/orm-migrations/README.md +14 -0
- package/examples/orm-migrations/migrations/.gitkeep +1 -0
- package/examples/orm-migrations/sloppy.json +9 -0
- package/examples/orm-migrations/src/app.ts +34 -0
- package/examples/orm-relations-includes/README.md +10 -0
- package/examples/orm-relations-includes/app.js +47 -0
- package/examples/orm-testservices/README.md +37 -0
- package/examples/orm-testservices/test.mjs +32 -0
- package/examples/os-runtime-api/README.md +11 -0
- package/examples/os-runtime-api/app.js +44 -0
- package/examples/package-zod-like/README.md +28 -0
- package/examples/package-zod-like/fixtures/zod-like/index.js +48 -0
- package/examples/package-zod-like/fixtures/zod-like/package.json +12 -0
- package/examples/package-zod-like/package.json +7 -0
- package/examples/package-zod-like/sloppy.json +6 -0
- package/examples/package-zod-like/src/main.ts +16 -0
- package/examples/postgres-basic/README.md +31 -0
- package/examples/postgres-basic/app.js +50 -0
- package/examples/prealpha-control-plane/README.md +50 -0
- package/examples/prealpha-control-plane/appsettings.Development.json +11 -0
- package/examples/prealpha-control-plane/appsettings.json +15 -0
- package/examples/prealpha-control-plane/sloppy.json +5 -0
- package/examples/prealpha-control-plane/src/db/schema.js +7 -0
- package/examples/prealpha-control-plane/src/db/seed.js +6 -0
- package/examples/prealpha-control-plane/src/main.js +21 -0
- package/examples/prealpha-control-plane/src/routes/apps.js +34 -0
- package/examples/prealpha-control-plane/src/routes/builds.js +25 -0
- package/examples/prealpha-control-plane/src/routes/deployments.js +19 -0
- package/examples/prealpha-control-plane/src/routes/diagnostics.js +11 -0
- package/examples/prealpha-control-plane/src/routes/health.js +27 -0
- package/examples/prealpha-control-plane/src/routes/projects.js +38 -0
- package/examples/prealpha-control-plane/src/services/diagnosticsSink.js +11 -0
- package/examples/prealpha-control-plane/src/services/repositories.js +9 -0
- package/examples/prealpha-control-plane/src/validation/schemas.js +6 -0
- package/examples/program-fs-process/README.md +31 -0
- package/examples/program-fs-process/sloppy.json +9 -0
- package/examples/program-fs-process/src/main.ts +27 -0
- package/examples/program-hello/README.md +32 -0
- package/examples/program-hello/main.ts +8 -0
- package/examples/program-hello/message.ts +1 -0
- package/examples/program-hello/sloppy.json +5 -0
- package/examples/rate-limit-auth/README.md +3 -0
- package/examples/rate-limit-auth/app.js +14 -0
- package/examples/rate-limit-basic/README.md +3 -0
- package/examples/rate-limit-basic/app.js +13 -0
- package/examples/rate-limit-redis/README.md +5 -0
- package/examples/rate-limit-redis/app.js +20 -0
- package/examples/rate-limit-testhost/README.md +4 -0
- package/examples/rate-limit-testhost/app.js +13 -0
- package/examples/rate-limit-websocket/README.md +3 -0
- package/examples/rate-limit-websocket/app.js +16 -0
- package/examples/realtime-auth/README.md +8 -0
- package/examples/realtime-auth/app.js +25 -0
- package/examples/realtime-auth/test.mjs +43 -0
- package/examples/realtime-chat/README.md +8 -0
- package/examples/realtime-chat/app.js +32 -0
- package/examples/realtime-chat/test.mjs +52 -0
- package/examples/realtime-dashboard/README.md +20 -0
- package/examples/realtime-dashboard/app.js +37 -0
- package/examples/realtime-presence/README.md +8 -0
- package/examples/realtime-presence/app.js +32 -0
- package/examples/realtime-presence/test.mjs +50 -0
- package/examples/realtime-testhost/README.md +8 -0
- package/examples/realtime-testhost/test.mjs +31 -0
- package/examples/redis-basic/README.md +17 -0
- package/examples/redis-basic/app.js +39 -0
- package/examples/redis-cache/README.md +14 -0
- package/examples/redis-cache/app.js +36 -0
- package/examples/redis-locks/README.md +13 -0
- package/examples/redis-locks/app.js +49 -0
- package/examples/request-context/README.md +32 -0
- package/examples/request-context/app.js +15 -0
- package/examples/sqlite-basic/README.md +52 -0
- package/examples/sqlite-basic/app.js +56 -0
- package/examples/sqlserver-basic/README.md +36 -0
- package/examples/sqlserver-basic/app.js +59 -0
- package/examples/static-files-basic/README.md +11 -0
- package/examples/static-files-basic/app.js +12 -0
- package/examples/static-files-basic/public/app.js +1 -0
- package/examples/static-files-basic/public/site.css +3 -0
- package/examples/static-files-package/README.md +12 -0
- package/examples/static-files-package/app.js +10 -0
- package/examples/static-files-package/public/index.html +2 -0
- package/examples/static-files-precompressed/README.md +12 -0
- package/examples/static-files-precompressed/app.js +11 -0
- package/examples/static-files-precompressed/public/app.js +1 -0
- package/examples/static-files-precompressed/public/app.js.br +0 -0
- package/examples/static-files-precompressed/public/app.js.gz +0 -0
- package/examples/static-files-spa/README.md +12 -0
- package/examples/static-files-spa/app.js +16 -0
- package/examples/static-files-spa/dist/assets/app.js +1 -0
- package/examples/static-files-spa/dist/index.html +4 -0
- package/examples/static-files-testhost/README.md +8 -0
- package/examples/static-files-testhost/app.js +13 -0
- package/examples/static-files-testhost/public/app.js +1 -0
- package/examples/static-files-testhost/public/app.js.gz +0 -0
- package/examples/static-files-testhost/test.mjs +38 -0
- package/examples/testhost-basic/README.md +26 -0
- package/examples/testhost-db/README.md +31 -0
- package/examples/testservices-postgres/README.md +68 -0
- package/examples/testservices-redis/README.md +71 -0
- package/examples/testservices-sqlserver/README.md +75 -0
- package/examples/time-basic/README.md +18 -0
- package/examples/time-basic/app.js +12 -0
- package/examples/time-deadline-cancellation/README.md +11 -0
- package/examples/time-deadline-cancellation/app.js +27 -0
- package/examples/time-fake-clock/README.md +14 -0
- package/examples/time-fake-clock/app.js +25 -0
- package/examples/time-interval-schedule/README.md +13 -0
- package/examples/time-interval-schedule/app.js +60 -0
- package/examples/users-api-sqlite/README.md +74 -0
- package/examples/users-api-sqlite/app.js +11 -0
- package/examples/users-api-sqlite/appsettings.Development.json +11 -0
- package/examples/users-api-sqlite/appsettings.json +11 -0
- package/examples/users-api-sqlite/modules/users.js +40 -0
- package/examples/users-api-sqlite/sloppy.json +5 -0
- package/examples/validation-errors/README.md +36 -0
- package/examples/validation-errors/app.js +14 -0
- package/examples/validation-errors/invalid-user.http +6 -0
- package/examples/validation-errors/sloppy.json +5 -0
- package/examples/web-dynamic-routes/README.md +17 -0
- package/examples/web-dynamic-routes/app.ts +27 -0
- package/examples/webhooks-basic/README.md +11 -0
- package/examples/webhooks-basic/app.js +48 -0
- package/examples/websocket-auth/README.md +8 -0
- package/examples/websocket-auth/app.js +16 -0
- package/examples/websocket-echo/README.md +9 -0
- package/examples/websocket-echo/app.js +36 -0
- package/examples/websocket-json-schema/README.md +5 -0
- package/examples/websocket-json-schema/app.js +25 -0
- package/examples/websocket-testhost/README.md +11 -0
- package/examples/websocket-testhost/test.mjs +49 -0
- package/examples/workers-background-service/README.md +7 -0
- package/examples/workers-background-service/app.js +16 -0
- package/examples/workers-js-isolate/README.md +8 -0
- package/examples/workers-js-isolate/app.js +19 -0
- package/examples/workers-js-isolate/workers/parser.ts +11 -0
- package/examples/workers-shutdown/README.md +6 -0
- package/examples/workers-shutdown/app.js +26 -0
- package/examples/workers-workerpool/README.md +6 -0
- package/examples/workers-workerpool/app.js +23 -0
- package/examples/workers-workqueue/README.md +8 -0
- package/examples/workers-workqueue/app.js +24 -0
- package/manifest.json +59 -0
- package/package.json +31 -0
- package/stdlib/sloppy/README.md +177 -0
- package/stdlib/sloppy/app.js +2142 -0
- package/stdlib/sloppy/auth.js +1813 -0
- package/stdlib/sloppy/bootstrap.manifest.json +83 -0
- package/stdlib/sloppy/cache.js +1542 -0
- package/stdlib/sloppy/codec.js +1153 -0
- package/stdlib/sloppy/config.js +61 -0
- package/stdlib/sloppy/crypto.js +312 -0
- package/stdlib/sloppy/data.js +2945 -0
- package/stdlib/sloppy/ffi.js +185 -0
- package/stdlib/sloppy/fs.js +795 -0
- package/stdlib/sloppy/health.js +603 -0
- package/stdlib/sloppy/http.js +1595 -0
- package/stdlib/sloppy/index.js +59 -0
- package/stdlib/sloppy/internal/bytes.js +31 -0
- package/stdlib/sloppy/internal/capabilities.js +155 -0
- package/stdlib/sloppy/internal/config.js +640 -0
- package/stdlib/sloppy/internal/disposable.js +31 -0
- package/stdlib/sloppy/internal/headers.js +63 -0
- package/stdlib/sloppy/internal/intrinsics.js +2 -0
- package/stdlib/sloppy/internal/json.js +20 -0
- package/stdlib/sloppy/internal/logging.js +278 -0
- package/stdlib/sloppy/internal/modules.js +405 -0
- package/stdlib/sloppy/internal/redaction.js +87 -0
- package/stdlib/sloppy/internal/routes.js +2279 -0
- package/stdlib/sloppy/internal/runtime-classic.js +19837 -0
- package/stdlib/sloppy/internal/services.js +690 -0
- package/stdlib/sloppy/internal/shared.js +32 -0
- package/stdlib/sloppy/internal/testhost-diagnostics.js +88 -0
- package/stdlib/sloppy/internal/testhost-http-server.js +238 -0
- package/stdlib/sloppy/internal/testhost-http.js +118 -0
- package/stdlib/sloppy/internal/testhost-loopback.js +50 -0
- package/stdlib/sloppy/internal/testservices-docker.js +154 -0
- package/stdlib/sloppy/internal/validation.js +117 -0
- package/stdlib/sloppy/metrics.js +427 -0
- package/stdlib/sloppy/net.js +5208 -0
- package/stdlib/sloppy/node/assert/strict.js +39 -0
- package/stdlib/sloppy/node/assert.js +228 -0
- package/stdlib/sloppy/node/buffer.js +247 -0
- package/stdlib/sloppy/node/console.js +33 -0
- package/stdlib/sloppy/node/constants.js +9 -0
- package/stdlib/sloppy/node/crypto.js +89 -0
- package/stdlib/sloppy/node/diagnostics_channel.js +41 -0
- package/stdlib/sloppy/node/events.js +113 -0
- package/stdlib/sloppy/node/fs/promises.js +27 -0
- package/stdlib/sloppy/node/fs.js +280 -0
- package/stdlib/sloppy/node/http.js +11 -0
- package/stdlib/sloppy/node/https.js +11 -0
- package/stdlib/sloppy/node/module.js +40 -0
- package/stdlib/sloppy/node/os.js +22 -0
- package/stdlib/sloppy/node/path.js +78 -0
- package/stdlib/sloppy/node/perf_hooks.js +12 -0
- package/stdlib/sloppy/node/process.js +129 -0
- package/stdlib/sloppy/node/querystring.js +21 -0
- package/stdlib/sloppy/node/stream/promises.js +3 -0
- package/stdlib/sloppy/node/stream.js +132 -0
- package/stdlib/sloppy/node/string_decoder.js +23 -0
- package/stdlib/sloppy/node/timers.js +26 -0
- package/stdlib/sloppy/node/tty.js +18 -0
- package/stdlib/sloppy/node/url.js +17 -0
- package/stdlib/sloppy/node/util.js +95 -0
- package/stdlib/sloppy/node/zlib.js +72 -0
- package/stdlib/sloppy/orm.js +2188 -0
- package/stdlib/sloppy/os.js +580 -0
- package/stdlib/sloppy/problem-details.js +29 -0
- package/stdlib/sloppy/providers/sqlite.js +26 -0
- package/stdlib/sloppy/rate-limit.js +856 -0
- package/stdlib/sloppy/realtime.js +1508 -0
- package/stdlib/sloppy/redis.js +1272 -0
- package/stdlib/sloppy/request-id.js +184 -0
- package/stdlib/sloppy/request-logging.js +101 -0
- package/stdlib/sloppy/results.js +933 -0
- package/stdlib/sloppy/schema.js +546 -0
- package/stdlib/sloppy/testing.js +4081 -0
- package/stdlib/sloppy/testservices.js +1041 -0
- package/stdlib/sloppy/time.js +894 -0
- package/stdlib/sloppy/webhooks.js +1330 -0
- package/stdlib/sloppy/workers.js +986 -0
- package/templates/api/README.md +82 -0
- package/templates/api/appsettings.Development.json +14 -0
- package/templates/api/appsettings.json +13 -0
- package/templates/api/data/.gitkeep +1 -0
- package/templates/api/gitignore +4 -0
- package/templates/api/migrations/0001_create_users.sql +1 -0
- package/templates/api/package.json +16 -0
- package/templates/api/public/hello.txt +1 -0
- package/templates/api/sloppy.json +14 -0
- package/templates/api/src/config.ts +1 -0
- package/templates/api/src/db/migrate.ts +14 -0
- package/templates/api/src/db/schema.ts +4 -0
- package/templates/api/src/db/usersRepository.ts +23 -0
- package/templates/api/src/main.ts +18 -0
- package/templates/api/src/models/user.ts +7 -0
- package/templates/api/src/routes/health.ts +20 -0
- package/templates/api/src/routes/users.ts +40 -0
- package/templates/api/src/services/usersService.ts +21 -0
- package/templates/api/tsconfig.json +15 -0
- package/templates/cli/README.md +16 -0
- package/templates/cli/gitignore +2 -0
- package/templates/cli/package.json +13 -0
- package/templates/cli/sloppy.json +6 -0
- package/templates/cli/src/commands/echo.ts +9 -0
- package/templates/cli/src/commands/inspect.ts +20 -0
- package/templates/cli/src/main.ts +50 -0
- package/templates/cli/tsconfig.json +15 -0
- package/templates/minimal-api/README.md +14 -0
- package/templates/minimal-api/gitignore +3 -0
- package/templates/minimal-api/package.json +14 -0
- package/templates/minimal-api/sloppy.json +5 -0
- package/templates/minimal-api/src/main.ts +9 -0
- package/templates/minimal-api/tsconfig.json +15 -0
- package/templates/node-compat/README.md +40 -0
- package/templates/node-compat/gitignore +2 -0
- package/templates/node-compat/package.json +11 -0
- package/templates/node-compat/sloppy.json +6 -0
- package/templates/node-compat/src/main.ts +40 -0
- package/templates/package-api/README.md +44 -0
- package/templates/package-api/fixtures/validator-lite/index.js +7 -0
- package/templates/package-api/fixtures/validator-lite/package.json +6 -0
- package/templates/package-api/gitignore +3 -0
- package/templates/package-api/package.json +17 -0
- package/templates/package-api/sloppy.json +5 -0
- package/templates/package-api/src/main.ts +10 -0
- package/templates/package-api/src/routes/health.ts +5 -0
- package/templates/package-api/src/routes/users.ts +12 -0
- package/templates/package-api/tsconfig.json +15 -0
- package/templates/program/README.md +12 -0
- package/templates/program/gitignore +1 -0
- package/templates/program/package.json +10 -0
- package/templates/program/sloppy.json +6 -0
- package/templates/program/src/main.ts +9 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import base, {
|
|
2
|
+
AssertionError,
|
|
3
|
+
deepEqual,
|
|
4
|
+
deepStrictEqual,
|
|
5
|
+
doesNotReject,
|
|
6
|
+
doesNotThrow,
|
|
7
|
+
fail,
|
|
8
|
+
ifError,
|
|
9
|
+
notStrictEqual,
|
|
10
|
+
ok,
|
|
11
|
+
rejects,
|
|
12
|
+
strictEqual,
|
|
13
|
+
throws,
|
|
14
|
+
} from "../assert.js";
|
|
15
|
+
|
|
16
|
+
const equal = strictEqual;
|
|
17
|
+
function strict(value, message = undefined) {
|
|
18
|
+
return ok(value, message);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
Object.assign(strict, base, { equal });
|
|
22
|
+
|
|
23
|
+
export {
|
|
24
|
+
AssertionError,
|
|
25
|
+
deepEqual,
|
|
26
|
+
deepStrictEqual,
|
|
27
|
+
doesNotReject,
|
|
28
|
+
doesNotThrow,
|
|
29
|
+
equal,
|
|
30
|
+
fail,
|
|
31
|
+
ifError,
|
|
32
|
+
notStrictEqual,
|
|
33
|
+
ok,
|
|
34
|
+
rejects,
|
|
35
|
+
strictEqual,
|
|
36
|
+
throws,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default strict;
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
class AssertionError extends Error {
|
|
2
|
+
constructor(options = {}) {
|
|
3
|
+
super(options.message ?? "Assertion failed");
|
|
4
|
+
this.name = "AssertionError";
|
|
5
|
+
this.actual = options.actual;
|
|
6
|
+
this.expected = options.expected;
|
|
7
|
+
this.operator = options.operator;
|
|
8
|
+
this.code = "ERR_ASSERTION";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function internalFail(options) {
|
|
13
|
+
throw new AssertionError(options);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function fail(actual = undefined, expected = undefined, message = undefined, operator = "!=") {
|
|
17
|
+
if (arguments.length === 0) {
|
|
18
|
+
internalFail({ message: "Failed", operator: "fail" });
|
|
19
|
+
}
|
|
20
|
+
if (arguments.length === 1) {
|
|
21
|
+
if (actual instanceof Error) {
|
|
22
|
+
throw actual;
|
|
23
|
+
}
|
|
24
|
+
internalFail({ message: actual === undefined ? "Failed" : actual, operator: "fail" });
|
|
25
|
+
}
|
|
26
|
+
internalFail({
|
|
27
|
+
actual,
|
|
28
|
+
expected,
|
|
29
|
+
message: message ?? `${actual} ${operator} ${expected}`,
|
|
30
|
+
operator,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function ok(value, message = undefined) {
|
|
35
|
+
if (!value) {
|
|
36
|
+
internalFail({ actual: value, expected: true, operator: "ok", message });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function equal(actual, expected, message = undefined) {
|
|
41
|
+
if (actual != expected) {
|
|
42
|
+
internalFail({ actual, expected, operator: "==", message });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function strictEqual(actual, expected, message = undefined) {
|
|
47
|
+
if (!Object.is(actual, expected)) {
|
|
48
|
+
internalFail({ actual, expected, operator: "strictEqual", message });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function notStrictEqual(actual, expected, message = undefined) {
|
|
53
|
+
if (Object.is(actual, expected)) {
|
|
54
|
+
internalFail({ actual, expected, operator: "notStrictEqual", message });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function stable(value) {
|
|
59
|
+
if (value === null || typeof value !== "object") {
|
|
60
|
+
return JSON.stringify(value);
|
|
61
|
+
}
|
|
62
|
+
if (Array.isArray(value)) {
|
|
63
|
+
return `[${value.map(stable).join(",")}]`;
|
|
64
|
+
}
|
|
65
|
+
return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${stable(value[key])}`).join(",")}}`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function deepStrictEqual(actual, expected, message = undefined) {
|
|
69
|
+
if (stable(actual) !== stable(expected)) {
|
|
70
|
+
internalFail({ actual, expected, operator: "deepStrictEqual", message });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const deepEqual = deepStrictEqual;
|
|
75
|
+
|
|
76
|
+
function matchExpected(error, expected) {
|
|
77
|
+
if (expected === undefined) {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
if (typeof expected === "function") {
|
|
81
|
+
try {
|
|
82
|
+
if (error instanceof expected) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
} catch {
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
return expected(error) === true;
|
|
89
|
+
} catch {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (expected instanceof RegExp) {
|
|
94
|
+
return expected.test(String(error?.message ?? error));
|
|
95
|
+
}
|
|
96
|
+
if (expected !== null && typeof expected === "object") {
|
|
97
|
+
return Object.entries(expected).every(([key, value]) => Object.is(error?.[key], value));
|
|
98
|
+
}
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function mismatch(error, expected, operator, message) {
|
|
103
|
+
internalFail({
|
|
104
|
+
actual: error,
|
|
105
|
+
expected,
|
|
106
|
+
operator,
|
|
107
|
+
message: message ?? `${operator} validation failed.`,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function isPromiseLike(value) {
|
|
112
|
+
return value !== null
|
|
113
|
+
&& (typeof value === "object" || typeof value === "function")
|
|
114
|
+
&& typeof value.then === "function";
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function requirePromiseLike(value, operator) {
|
|
118
|
+
if (!isPromiseLike(value)) {
|
|
119
|
+
throw new TypeError(`${operator} expects a Promise or a function returning a Promise.`);
|
|
120
|
+
}
|
|
121
|
+
return value;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function throws(fn, expected = undefined, message = undefined) {
|
|
125
|
+
if (typeof fn !== "function") {
|
|
126
|
+
throw new TypeError("assert.throws expects a function.");
|
|
127
|
+
}
|
|
128
|
+
try {
|
|
129
|
+
fn();
|
|
130
|
+
} catch (error) {
|
|
131
|
+
if (!matchExpected(error, expected)) {
|
|
132
|
+
mismatch(error, expected, "throws", message);
|
|
133
|
+
}
|
|
134
|
+
return error;
|
|
135
|
+
}
|
|
136
|
+
internalFail({ actual: undefined, expected, operator: "throws", message });
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function doesNotThrow(fn, expected = undefined, message = undefined) {
|
|
140
|
+
if (typeof fn !== "function") {
|
|
141
|
+
throw new TypeError("assert.doesNotThrow expects a function.");
|
|
142
|
+
}
|
|
143
|
+
if (typeof expected === "string" && message === undefined) {
|
|
144
|
+
message = expected;
|
|
145
|
+
expected = undefined;
|
|
146
|
+
}
|
|
147
|
+
try {
|
|
148
|
+
fn();
|
|
149
|
+
} catch (error) {
|
|
150
|
+
if (expected === undefined || matchExpected(error, expected)) {
|
|
151
|
+
mismatch(error, expected, "doesNotThrow", message);
|
|
152
|
+
}
|
|
153
|
+
throw error;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
async function rejects(fn, expected = undefined, message = undefined) {
|
|
158
|
+
const promise = requirePromiseLike(typeof fn === "function" ? fn() : fn, "assert.rejects");
|
|
159
|
+
try {
|
|
160
|
+
await promise;
|
|
161
|
+
} catch (error) {
|
|
162
|
+
if (!matchExpected(error, expected)) {
|
|
163
|
+
mismatch(error, expected, "rejects", message);
|
|
164
|
+
}
|
|
165
|
+
return error;
|
|
166
|
+
}
|
|
167
|
+
internalFail({ actual: undefined, expected, operator: "rejects", message });
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
async function doesNotReject(fn, expected = undefined, message = undefined) {
|
|
171
|
+
if (typeof expected === "string" && message === undefined) {
|
|
172
|
+
message = expected;
|
|
173
|
+
expected = undefined;
|
|
174
|
+
}
|
|
175
|
+
const promise = requirePromiseLike(typeof fn === "function" ? fn() : fn, "assert.doesNotReject");
|
|
176
|
+
try {
|
|
177
|
+
await promise;
|
|
178
|
+
} catch (error) {
|
|
179
|
+
if (expected === undefined || matchExpected(error, expected)) {
|
|
180
|
+
mismatch(error, expected, "doesNotReject", message);
|
|
181
|
+
}
|
|
182
|
+
throw error;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function ifError(value) {
|
|
187
|
+
if (value !== null && value !== undefined) {
|
|
188
|
+
internalFail({ actual: value, expected: null, operator: "ifError", message: value?.message });
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function assert(value, message = undefined) {
|
|
193
|
+
return ok(value, message);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
Object.assign(assert, {
|
|
197
|
+
AssertionError,
|
|
198
|
+
deepEqual,
|
|
199
|
+
deepStrictEqual,
|
|
200
|
+
doesNotReject,
|
|
201
|
+
doesNotThrow,
|
|
202
|
+
equal,
|
|
203
|
+
fail,
|
|
204
|
+
ifError,
|
|
205
|
+
notStrictEqual,
|
|
206
|
+
ok,
|
|
207
|
+
rejects,
|
|
208
|
+
strictEqual,
|
|
209
|
+
throws,
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
export {
|
|
213
|
+
AssertionError,
|
|
214
|
+
deepEqual,
|
|
215
|
+
deepStrictEqual,
|
|
216
|
+
doesNotReject,
|
|
217
|
+
doesNotThrow,
|
|
218
|
+
equal,
|
|
219
|
+
fail,
|
|
220
|
+
ifError,
|
|
221
|
+
notStrictEqual,
|
|
222
|
+
ok,
|
|
223
|
+
rejects,
|
|
224
|
+
strictEqual,
|
|
225
|
+
throws,
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
export default assert;
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { Base64, Base64Url, Hex, Text } from "../codec.js";
|
|
2
|
+
|
|
3
|
+
function normalizeEncoding(encoding = "utf8") {
|
|
4
|
+
const normalized = String(encoding).toLowerCase();
|
|
5
|
+
if (normalized === "utf-8") {
|
|
6
|
+
return "utf8";
|
|
7
|
+
}
|
|
8
|
+
if (["utf8", "hex", "base64", "base64url"].includes(normalized)) {
|
|
9
|
+
return normalized;
|
|
10
|
+
}
|
|
11
|
+
throw new TypeError(`Sloppy Buffer encoding is not supported: ${encoding}`);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function bytesFromString(value, encoding) {
|
|
15
|
+
switch (normalizeEncoding(encoding)) {
|
|
16
|
+
case "utf8":
|
|
17
|
+
return Text.utf8.encode(value);
|
|
18
|
+
case "hex":
|
|
19
|
+
return Hex.decode(value);
|
|
20
|
+
case "base64":
|
|
21
|
+
return Base64.decode(value);
|
|
22
|
+
case "base64url":
|
|
23
|
+
return Base64Url.decode(value, { padding: "optional" });
|
|
24
|
+
default:
|
|
25
|
+
throw new TypeError(`Sloppy Buffer encoding is not supported: ${encoding}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function bytesToString(value, encoding) {
|
|
30
|
+
switch (normalizeEncoding(encoding)) {
|
|
31
|
+
case "utf8":
|
|
32
|
+
return Text.utf8.decode(value);
|
|
33
|
+
case "hex":
|
|
34
|
+
return Hex.encode(value);
|
|
35
|
+
case "base64":
|
|
36
|
+
return Base64.encode(value);
|
|
37
|
+
case "base64url":
|
|
38
|
+
return Base64Url.encode(value);
|
|
39
|
+
default:
|
|
40
|
+
throw new TypeError(`Sloppy Buffer encoding is not supported: ${encoding}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
class Buffer extends Uint8Array {
|
|
45
|
+
static from(value, encoding = "utf8") {
|
|
46
|
+
if (typeof value === "string") {
|
|
47
|
+
return new Buffer(bytesFromString(value, encoding));
|
|
48
|
+
}
|
|
49
|
+
if (value instanceof ArrayBuffer || ArrayBuffer.isView(value) || Array.isArray(value)) {
|
|
50
|
+
return new Buffer(value);
|
|
51
|
+
}
|
|
52
|
+
throw new TypeError("Sloppy Buffer.from expects a string, bytes, or array.");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static compare(left, right) {
|
|
56
|
+
left = Buffer.from(left);
|
|
57
|
+
right = Buffer.from(right);
|
|
58
|
+
const length = Math.min(left.byteLength, right.byteLength);
|
|
59
|
+
for (let index = 0; index < length; index += 1) {
|
|
60
|
+
if (left[index] !== right[index]) {
|
|
61
|
+
return left[index] < right[index] ? -1 : 1;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (left.byteLength === right.byteLength) {
|
|
65
|
+
return 0;
|
|
66
|
+
}
|
|
67
|
+
return left.byteLength < right.byteLength ? -1 : 1;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static isEncoding(encoding) {
|
|
71
|
+
if (encoding === undefined || encoding === null) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
normalizeEncoding(encoding);
|
|
76
|
+
return true;
|
|
77
|
+
} catch {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
static alloc(size, fill = 0) {
|
|
83
|
+
const buffer = new Buffer(size);
|
|
84
|
+
buffer.fill(fill);
|
|
85
|
+
return buffer;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
static allocUnsafe(size) {
|
|
89
|
+
return Buffer.alloc(size);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
static isBuffer(value) {
|
|
93
|
+
return value instanceof Buffer;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
static byteLength(value, encoding = "utf8") {
|
|
97
|
+
return Buffer.from(value, encoding).byteLength;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
static concat(list, totalLength = undefined) {
|
|
101
|
+
if (!Array.isArray(list)) {
|
|
102
|
+
throw new TypeError("Sloppy Buffer.concat expects an array.");
|
|
103
|
+
}
|
|
104
|
+
const buffers = list.map((entry) => Buffer.from(entry));
|
|
105
|
+
const length = totalLength === undefined
|
|
106
|
+
? buffers.reduce((sum, entry) => sum + entry.byteLength, 0)
|
|
107
|
+
: Number(totalLength);
|
|
108
|
+
if (!Number.isInteger(length) || length < 0) {
|
|
109
|
+
throw new TypeError("Sloppy Buffer.concat totalLength must be a non-negative integer.");
|
|
110
|
+
}
|
|
111
|
+
const output = new Buffer(length);
|
|
112
|
+
let offset = 0;
|
|
113
|
+
for (const buffer of buffers) {
|
|
114
|
+
output.set(buffer.subarray(0, Math.max(0, length - offset)), offset);
|
|
115
|
+
offset += buffer.byteLength;
|
|
116
|
+
if (offset >= length) {
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return output;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
equals(other) {
|
|
124
|
+
const buffer = Buffer.from(other);
|
|
125
|
+
if (buffer.byteLength !== this.byteLength) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
for (let index = 0; index < this.byteLength; index += 1) {
|
|
129
|
+
if (this[index] !== buffer[index]) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
subarray(start = 0, end = undefined) {
|
|
137
|
+
const view = super.subarray(start, end);
|
|
138
|
+
Object.setPrototypeOf(view, Buffer.prototype);
|
|
139
|
+
return view;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
slice(start = 0, end = undefined) {
|
|
143
|
+
return this.subarray(start, end);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
compare(other) {
|
|
147
|
+
return Buffer.compare(this, other);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
readUInt8(offset = 0) {
|
|
151
|
+
return this.#readUInt(offset, 1);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
readUInt16LE(offset = 0) {
|
|
155
|
+
return this.#readUInt(offset, 2, true);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
readUInt16BE(offset = 0) {
|
|
159
|
+
return this.#readUInt(offset, 2, false);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
readUInt32LE(offset = 0) {
|
|
163
|
+
return this.#readUInt(offset, 4, true);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
readUInt32BE(offset = 0) {
|
|
167
|
+
return this.#readUInt(offset, 4, false);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
writeUInt8(value, offset = 0) {
|
|
171
|
+
return this.#writeUInt(value, offset, 1);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
writeUInt16LE(value, offset = 0) {
|
|
175
|
+
return this.#writeUInt(value, offset, 2, true);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
writeUInt16BE(value, offset = 0) {
|
|
179
|
+
return this.#writeUInt(value, offset, 2, false);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
writeUInt32LE(value, offset = 0) {
|
|
183
|
+
return this.#writeUInt(value, offset, 4, true);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
writeUInt32BE(value, offset = 0) {
|
|
187
|
+
return this.#writeUInt(value, offset, 4, false);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
write(value, offset = 0, length = undefined, encoding = "utf8") {
|
|
191
|
+
if (typeof offset === "string") {
|
|
192
|
+
encoding = offset;
|
|
193
|
+
offset = 0;
|
|
194
|
+
length = undefined;
|
|
195
|
+
} else if (typeof length === "string") {
|
|
196
|
+
encoding = length;
|
|
197
|
+
length = undefined;
|
|
198
|
+
}
|
|
199
|
+
const bytes = Buffer.from(String(value), encoding);
|
|
200
|
+
const start = Number(offset);
|
|
201
|
+
const available = this.byteLength - start;
|
|
202
|
+
const count = Math.min(length === undefined ? bytes.byteLength : Number(length), available);
|
|
203
|
+
if (!Number.isInteger(start) || start < 0 || !Number.isInteger(count) || count < 0) {
|
|
204
|
+
throw new RangeError("Sloppy Buffer.write offset and length must be non-negative integers.");
|
|
205
|
+
}
|
|
206
|
+
this.set(bytes.subarray(0, count), start);
|
|
207
|
+
return count;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
toString(encoding = "utf8") {
|
|
211
|
+
return bytesToString(this, encoding);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
#checkBounds(offset, width) {
|
|
215
|
+
offset = Number(offset);
|
|
216
|
+
if (!Number.isInteger(offset) || offset < 0 || offset + width > this.byteLength) {
|
|
217
|
+
throw new RangeError("Sloppy Buffer offset is outside the buffer bounds.");
|
|
218
|
+
}
|
|
219
|
+
return offset;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
#readUInt(offset, width, littleEndian = true) {
|
|
223
|
+
offset = this.#checkBounds(offset, width);
|
|
224
|
+
let value = 0;
|
|
225
|
+
for (let index = 0; index < width; index += 1) {
|
|
226
|
+
const byte = this[offset + (littleEndian ? index : width - 1 - index)];
|
|
227
|
+
value += byte * 2 ** (8 * index);
|
|
228
|
+
}
|
|
229
|
+
return value;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
#writeUInt(value, offset, width, littleEndian = true) {
|
|
233
|
+
offset = this.#checkBounds(offset, width);
|
|
234
|
+
value = Number(value);
|
|
235
|
+
const max = 2 ** (8 * width);
|
|
236
|
+
if (!Number.isInteger(value) || value < 0 || value >= max) {
|
|
237
|
+
throw new RangeError("Sloppy Buffer unsigned integer value is outside the supported range.");
|
|
238
|
+
}
|
|
239
|
+
for (let index = 0; index < width; index += 1) {
|
|
240
|
+
this[offset + (littleEndian ? index : width - 1 - index)] = Math.floor(value / 2 ** (8 * index)) & 0xff;
|
|
241
|
+
}
|
|
242
|
+
return offset + width;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export { Buffer };
|
|
247
|
+
export default { Buffer };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const runtimeConsole = globalThis.console;
|
|
2
|
+
|
|
3
|
+
const Console = runtimeConsole?.Console ?? class Console {
|
|
4
|
+
log(...values) {
|
|
5
|
+
runtimeConsole?.log?.(...values);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
error(...values) {
|
|
9
|
+
runtimeConsole?.error?.(...values);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
warn(...values) {
|
|
13
|
+
(runtimeConsole?.warn ?? runtimeConsole?.log)?.(...values);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
info(...values) {
|
|
17
|
+
(runtimeConsole?.info ?? runtimeConsole?.log)?.(...values);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
debug(...values) {
|
|
21
|
+
(runtimeConsole?.debug ?? runtimeConsole?.log)?.(...values);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const log = runtimeConsole?.log?.bind(runtimeConsole) ?? (() => {});
|
|
26
|
+
const error = runtimeConsole?.error?.bind(runtimeConsole) ?? (() => {});
|
|
27
|
+
const warn = runtimeConsole?.warn?.bind(runtimeConsole) ?? log;
|
|
28
|
+
const info = runtimeConsole?.info?.bind(runtimeConsole) ?? log;
|
|
29
|
+
const debug = runtimeConsole?.debug?.bind(runtimeConsole) ?? log;
|
|
30
|
+
const consoleModule = runtimeConsole ?? { Console, debug, error, info, log, warn };
|
|
31
|
+
|
|
32
|
+
export { Console, debug, error, info, log, warn };
|
|
33
|
+
export default consoleModule;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const O_RDONLY = 0;
|
|
2
|
+
const O_WRONLY = 1;
|
|
3
|
+
const O_RDWR = 2;
|
|
4
|
+
const S_IFMT = 0o170000;
|
|
5
|
+
const S_IFREG = 0o100000;
|
|
6
|
+
const S_IFDIR = 0o040000;
|
|
7
|
+
|
|
8
|
+
export { O_RDONLY, O_RDWR, O_WRONLY, S_IFDIR, S_IFMT, S_IFREG };
|
|
9
|
+
export default { O_RDONLY, O_RDWR, O_WRONLY, S_IFDIR, S_IFMT, S_IFREG };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { ConstantTime, Hash, Hmac, Random, Secret } from "../crypto.js";
|
|
2
|
+
import { Hex, Text } from "../codec.js";
|
|
3
|
+
|
|
4
|
+
function randomBytes(size) {
|
|
5
|
+
return Random.bytes(size);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function randomUUID() {
|
|
9
|
+
return Random.uuid();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function normalizeAlgorithm(algorithm, operation) {
|
|
13
|
+
const normalized = String(algorithm).toLowerCase().replace(/-/g, "");
|
|
14
|
+
if (normalized === "sha256") {
|
|
15
|
+
return "sha256";
|
|
16
|
+
}
|
|
17
|
+
if (normalized === "sha384") {
|
|
18
|
+
return "sha384";
|
|
19
|
+
}
|
|
20
|
+
if (normalized === "sha512") {
|
|
21
|
+
return "sha512";
|
|
22
|
+
}
|
|
23
|
+
throw new TypeError(`SLOPPY_E_NODE_CRYPTO_UNSUPPORTED: node:crypto.${operation} only supports sha256, sha384, and sha512.`);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function createHash(algorithm) {
|
|
27
|
+
return Hash.create(normalizeAlgorithm(algorithm, "createHash"));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function bytesFrom(value, operation) {
|
|
31
|
+
if (typeof value === "string") {
|
|
32
|
+
return Text.utf8.encode(value);
|
|
33
|
+
}
|
|
34
|
+
if (value instanceof ArrayBuffer) {
|
|
35
|
+
return new Uint8Array(value).slice();
|
|
36
|
+
}
|
|
37
|
+
if (ArrayBuffer.isView(value)) {
|
|
38
|
+
return new Uint8Array(value.buffer, value.byteOffset, value.byteLength).slice();
|
|
39
|
+
}
|
|
40
|
+
throw new TypeError(`${operation} requires a string, ArrayBuffer, or typed-array bytes.`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function secretFrom(value) {
|
|
44
|
+
return typeof value === "string"
|
|
45
|
+
? Secret.fromUtf8(value)
|
|
46
|
+
: Secret.fromBytes(bytesFrom(value, "node:crypto.createHmac key"));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function createHmac(algorithm, key) {
|
|
50
|
+
const normalized = normalizeAlgorithm(algorithm, "createHmac");
|
|
51
|
+
if (normalized !== "sha256") {
|
|
52
|
+
throw new TypeError("SLOPPY_E_NODE_CRYPTO_UNSUPPORTED: node:crypto.createHmac currently supports sha256.");
|
|
53
|
+
}
|
|
54
|
+
const secret = secretFrom(key);
|
|
55
|
+
const chunks = [];
|
|
56
|
+
return {
|
|
57
|
+
update(value) {
|
|
58
|
+
chunks.push(bytesFrom(value, "node:crypto.Hmac.update"));
|
|
59
|
+
return this;
|
|
60
|
+
},
|
|
61
|
+
async digest(encoding = undefined) {
|
|
62
|
+
const length = chunks.reduce((total, chunk) => total + chunk.byteLength, 0);
|
|
63
|
+
const input = new Uint8Array(length);
|
|
64
|
+
let offset = 0;
|
|
65
|
+
for (const chunk of chunks) {
|
|
66
|
+
input.set(chunk, offset);
|
|
67
|
+
offset += chunk.byteLength;
|
|
68
|
+
}
|
|
69
|
+
const bytes = await Hmac.sha256(secret, input);
|
|
70
|
+
if (encoding === "hex") {
|
|
71
|
+
return Hex.encode(bytes);
|
|
72
|
+
}
|
|
73
|
+
if (encoding !== undefined && encoding !== "bytes") {
|
|
74
|
+
throw new TypeError("Sloppy node:crypto Hmac digest encoding must be bytes or hex.");
|
|
75
|
+
}
|
|
76
|
+
return bytes;
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function timingSafeEqual(left, right) {
|
|
82
|
+
if (left.byteLength !== right.byteLength) {
|
|
83
|
+
throw new RangeError("Input buffers must have the same byte length.");
|
|
84
|
+
}
|
|
85
|
+
return ConstantTime.equals(left, right);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export { createHash, createHmac, randomBytes, randomUUID, timingSafeEqual };
|
|
89
|
+
export default { createHash, createHmac, randomBytes, randomUUID, timingSafeEqual };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { EventEmitter } from "./events.js";
|
|
2
|
+
|
|
3
|
+
const channels = new Map();
|
|
4
|
+
|
|
5
|
+
class Channel extends EventEmitter {
|
|
6
|
+
constructor(name) {
|
|
7
|
+
super();
|
|
8
|
+
this.name = name;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
publish(message) {
|
|
12
|
+
this.emit("message", message, this.name);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
subscribe(listener) {
|
|
16
|
+
this.on("message", listener);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
unsubscribe(listener) {
|
|
20
|
+
this.removeListener("message", listener);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
hasSubscribers() {
|
|
24
|
+
return this.listenerCount("message") > 0;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function channel(name) {
|
|
29
|
+
name = String(name);
|
|
30
|
+
if (!channels.has(name)) {
|
|
31
|
+
channels.set(name, new Channel(name));
|
|
32
|
+
}
|
|
33
|
+
return channels.get(name);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function hasSubscribers(name) {
|
|
37
|
+
return channels.get(String(name))?.hasSubscribers() ?? false;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { channel, hasSubscribers };
|
|
41
|
+
export default { channel, hasSubscribers };
|