@attocash/cli 0.1.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 +28 -0
- package/README.md +707 -0
- package/dist/application/app.d.ts +138 -0
- package/dist/application/app.js +654 -0
- package/dist/application/operations.d.ts +9 -0
- package/dist/application/operations.js +96 -0
- package/dist/cli/cli.d.ts +1 -0
- package/dist/cli/cli.js +460 -0
- package/dist/cli/help.d.ts +4 -0
- package/dist/cli/help.js +49 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +13 -0
- package/dist/cli/onboarding.d.ts +14 -0
- package/dist/cli/onboarding.js +144 -0
- package/dist/cli/output.d.ts +2 -0
- package/dist/cli/output.js +231 -0
- package/dist/cli/terminal.d.ts +6 -0
- package/dist/cli/terminal.js +92 -0
- package/dist/cli/update-check.d.ts +1 -0
- package/dist/cli/update-check.js +12 -0
- package/dist/cli/updates.d.ts +2 -0
- package/dist/cli/updates.js +98 -0
- package/dist/core.d.ts +14 -0
- package/dist/core.js +14 -0
- package/dist/doctor/credential-probe.d.ts +7 -0
- package/dist/doctor/credential-probe.js +49 -0
- package/dist/doctor/doctor.d.ts +4 -0
- package/dist/doctor/doctor.js +213 -0
- package/dist/doctor/keyring.d.ts +7 -0
- package/dist/doctor/keyring.js +150 -0
- package/dist/doctor/profile.d.ts +19 -0
- package/dist/doctor/profile.js +73 -0
- package/dist/doctor/types.d.ts +40 -0
- package/dist/doctor/types.js +1 -0
- package/dist/domain/amount.d.ts +6 -0
- package/dist/domain/amount.js +27 -0
- package/dist/domain/errors.d.ts +10 -0
- package/dist/domain/errors.js +16 -0
- package/dist/labels/directory.d.ts +87 -0
- package/dist/labels/directory.js +140 -0
- package/dist/labels/personal.d.ts +17 -0
- package/dist/labels/personal.js +56 -0
- package/dist/labels/presentation.d.ts +154 -0
- package/dist/labels/presentation.js +90 -0
- package/dist/network/reader.d.ts +31 -0
- package/dist/network/reader.js +370 -0
- package/dist/network/retry.d.ts +7 -0
- package/dist/network/retry.js +53 -0
- package/dist/network/work.d.ts +3 -0
- package/dist/network/work.js +66 -0
- package/dist/pricing/market.d.ts +29 -0
- package/dist/pricing/market.js +150 -0
- package/dist/pricing/terms.d.ts +6 -0
- package/dist/pricing/terms.js +12 -0
- package/dist/spending/destination.d.ts +16 -0
- package/dist/spending/destination.js +42 -0
- package/dist/spending/journal.d.ts +28 -0
- package/dist/spending/journal.js +69 -0
- package/dist/spending/ledger.d.ts +118 -0
- package/dist/spending/ledger.js +444 -0
- package/dist/spending/payments.d.ts +67 -0
- package/dist/spending/payments.js +424 -0
- package/dist/spending/pool.d.ts +13 -0
- package/dist/spending/pool.js +38 -0
- package/dist/spending/reconcile.d.ts +18 -0
- package/dist/spending/reconcile.js +64 -0
- package/dist/storage/profiles.d.ts +13 -0
- package/dist/storage/profiles.js +86 -0
- package/dist/storage/secrets.d.ts +16 -0
- package/dist/storage/secrets.js +104 -0
- package/dist/storage/state.d.ts +32 -0
- package/dist/storage/state.js +255 -0
- package/dist/wallet/auto-receive.d.ts +57 -0
- package/dist/wallet/auto-receive.js +140 -0
- package/dist/wallet/defaults.d.ts +3 -0
- package/dist/wallet/defaults.js +26 -0
- package/dist/wallet/signing.d.ts +17 -0
- package/dist/wallet/signing.js +128 -0
- package/dist/wallet/types.d.ts +65 -0
- package/dist/wallet/types.js +1 -0
- package/dist/wallet/work.d.ts +29 -0
- package/dist/wallet/work.js +154 -0
- package/dist/watches/manager.d.ts +75 -0
- package/dist/watches/manager.js +197 -0
- package/node_modules/@attocash/commons-core/Kotlin-DateTime-library-kotlinx-datetime.mjs +6678 -0
- package/node_modules/@attocash/commons-core/Kotlin-DateTime-library-kotlinx-datetime.mjs.map +1 -0
- package/node_modules/@attocash/commons-core/LICENSE +28 -0
- package/node_modules/@attocash/commons-core/README.md +118 -0
- package/node_modules/@attocash/commons-core/commons-commons-core.d.mts +1036 -0
- package/node_modules/@attocash/commons-core/commons-commons-core.mjs +7701 -0
- package/node_modules/@attocash/commons-core/commons-commons-core.mjs.map +1 -0
- package/node_modules/@attocash/commons-core/kotlin-kotlin-stdlib.mjs +17681 -0
- package/node_modules/@attocash/commons-core/kotlin-kotlin-stdlib.mjs.map +1 -0
- package/node_modules/@attocash/commons-core/kotlin_org_jetbrains_kotlin_kotlin_dom_api_compat.mjs +4 -0
- package/node_modules/@attocash/commons-core/kotlin_org_jetbrains_kotlin_kotlin_dom_api_compat.mjs.map +1 -0
- package/node_modules/@attocash/commons-core/kotlinx-io-kotlinx-io-bytestring.mjs +209 -0
- package/node_modules/@attocash/commons-core/kotlinx-io-kotlinx-io-bytestring.mjs.map +1 -0
- package/node_modules/@attocash/commons-core/kotlinx-io-kotlinx-io-core.mjs +2284 -0
- package/node_modules/@attocash/commons-core/kotlinx-io-kotlinx-io-core.mjs.map +1 -0
- package/node_modules/@attocash/commons-core/kotlinx-serialization-kotlinx-serialization-core.mjs +6042 -0
- package/node_modules/@attocash/commons-core/kotlinx-serialization-kotlinx-serialization-core.mjs.map +1 -0
- package/node_modules/@attocash/commons-core/kotlinx-serialization-kotlinx-serialization-json.mjs +5294 -0
- package/node_modules/@attocash/commons-core/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -0
- package/node_modules/@attocash/commons-core/package.json +27 -0
- package/node_modules/@attocash/commons-node/LICENSE +28 -0
- package/node_modules/@attocash/commons-node/README.md +92 -0
- package/node_modules/@attocash/commons-node/commons-commons-node.d.mts +255 -0
- package/node_modules/@attocash/commons-node/commons-commons-node.mjs +2977 -0
- package/node_modules/@attocash/commons-node/commons-commons-node.mjs.map +1 -0
- package/node_modules/@attocash/commons-node/kotlin-logging.mjs +432 -0
- package/node_modules/@attocash/commons-node/kotlin-logging.mjs.map +1 -0
- package/node_modules/@attocash/commons-node/kotlinx-serialization-kotlinx-serialization-json.mjs +5294 -0
- package/node_modules/@attocash/commons-node/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -0
- package/node_modules/@attocash/commons-node/package.json +29 -0
- package/node_modules/@attocash/commons-node-remote/LICENSE +28 -0
- package/node_modules/@attocash/commons-node-remote/README.md +61 -0
- package/node_modules/@attocash/commons-node-remote/commons-commons-node-remote.d.mts +122 -0
- package/node_modules/@attocash/commons-node-remote/commons-commons-node-remote.mjs +1810 -0
- package/node_modules/@attocash/commons-node-remote/commons-commons-node-remote.mjs.map +1 -0
- package/node_modules/@attocash/commons-node-remote/kotlin-logging.mjs +432 -0
- package/node_modules/@attocash/commons-node-remote/kotlin-logging.mjs.map +1 -0
- package/node_modules/@attocash/commons-node-remote/kotlinx-browser.mjs +8 -0
- package/node_modules/@attocash/commons-node-remote/kotlinx-browser.mjs.map +1 -0
- package/node_modules/@attocash/commons-node-remote/kotlinx-serialization-kotlinx-serialization-json-io.mjs +4 -0
- package/node_modules/@attocash/commons-node-remote/kotlinx-serialization-kotlinx-serialization-json-io.mjs.map +1 -0
- package/node_modules/@attocash/commons-node-remote/kotlinx-serialization-kotlinx-serialization-json.mjs +5294 -0
- package/node_modules/@attocash/commons-node-remote/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -0
- package/node_modules/@attocash/commons-node-remote/package.json +31 -0
- package/node_modules/@attocash/commons-transport/LICENSE +28 -0
- package/node_modules/@attocash/commons-transport/README.md +5 -0
- package/node_modules/@attocash/commons-transport/commons-commons-transport.d.mts +64 -0
- package/node_modules/@attocash/commons-transport/commons-commons-transport.mjs +249 -0
- package/node_modules/@attocash/commons-transport/commons-commons-transport.mjs.map +1 -0
- package/node_modules/@attocash/commons-transport/kotlinx-atomicfu.mjs +263 -0
- package/node_modules/@attocash/commons-transport/kotlinx-atomicfu.mjs.map +1 -0
- package/node_modules/@attocash/commons-transport/kotlinx-browser.mjs +8 -0
- package/node_modules/@attocash/commons-transport/kotlinx-browser.mjs.map +1 -0
- package/node_modules/@attocash/commons-transport/kotlinx-coroutines-core.mjs +11604 -0
- package/node_modules/@attocash/commons-transport/kotlinx-coroutines-core.mjs.map +1 -0
- package/node_modules/@attocash/commons-transport/kotlinx-serialization-kotlinx-serialization-json-io.mjs +4 -0
- package/node_modules/@attocash/commons-transport/kotlinx-serialization-kotlinx-serialization-json-io.mjs.map +1 -0
- package/node_modules/@attocash/commons-transport/kotlinx-serialization-kotlinx-serialization-json.mjs +5294 -0
- package/node_modules/@attocash/commons-transport/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -0
- package/node_modules/@attocash/commons-transport/ktor-ktor-client-content-negotiation.mjs +499 -0
- package/node_modules/@attocash/commons-transport/ktor-ktor-client-content-negotiation.mjs.map +1 -0
- package/node_modules/@attocash/commons-transport/ktor-ktor-client-core.mjs +6456 -0
- package/node_modules/@attocash/commons-transport/ktor-ktor-client-core.mjs.map +1 -0
- package/node_modules/@attocash/commons-transport/ktor-ktor-events.mjs +83 -0
- package/node_modules/@attocash/commons-transport/ktor-ktor-events.mjs.map +1 -0
- package/node_modules/@attocash/commons-transport/ktor-ktor-http-cio.mjs +1714 -0
- package/node_modules/@attocash/commons-transport/ktor-ktor-http-cio.mjs.map +1 -0
- package/node_modules/@attocash/commons-transport/ktor-ktor-http.mjs +3197 -0
- package/node_modules/@attocash/commons-transport/ktor-ktor-http.mjs.map +1 -0
- package/node_modules/@attocash/commons-transport/ktor-ktor-io.mjs +2290 -0
- package/node_modules/@attocash/commons-transport/ktor-ktor-io.mjs.map +1 -0
- package/node_modules/@attocash/commons-transport/ktor-ktor-serialization-kotlinx-json.mjs +46 -0
- package/node_modules/@attocash/commons-transport/ktor-ktor-serialization-kotlinx-json.mjs.map +1 -0
- package/node_modules/@attocash/commons-transport/ktor-ktor-serialization-kotlinx.mjs +482 -0
- package/node_modules/@attocash/commons-transport/ktor-ktor-serialization-kotlinx.mjs.map +1 -0
- package/node_modules/@attocash/commons-transport/ktor-ktor-serialization.mjs +165 -0
- package/node_modules/@attocash/commons-transport/ktor-ktor-serialization.mjs.map +1 -0
- package/node_modules/@attocash/commons-transport/ktor-ktor-sse.mjs +4 -0
- package/node_modules/@attocash/commons-transport/ktor-ktor-sse.mjs.map +1 -0
- package/node_modules/@attocash/commons-transport/ktor-ktor-utils.mjs +3222 -0
- package/node_modules/@attocash/commons-transport/ktor-ktor-utils.mjs.map +1 -0
- package/node_modules/@attocash/commons-transport/ktor-ktor-websocket-serialization.mjs +4 -0
- package/node_modules/@attocash/commons-transport/ktor-ktor-websocket-serialization.mjs.map +1 -0
- package/node_modules/@attocash/commons-transport/ktor-ktor-websockets.mjs +1485 -0
- package/node_modules/@attocash/commons-transport/ktor-ktor-websockets.mjs.map +1 -0
- package/node_modules/@attocash/commons-transport/package.json +29 -0
- package/node_modules/@attocash/commons-worker/LICENSE +28 -0
- package/node_modules/@attocash/commons-worker/README.md +48 -0
- package/node_modules/@attocash/commons-worker/commons-commons-worker.d.mts +73 -0
- package/node_modules/@attocash/commons-worker/commons-commons-worker.mjs +702 -0
- package/node_modules/@attocash/commons-worker/commons-commons-worker.mjs.map +1 -0
- package/node_modules/@attocash/commons-worker/kotlin-logging.mjs +432 -0
- package/node_modules/@attocash/commons-worker/kotlin-logging.mjs.map +1 -0
- package/node_modules/@attocash/commons-worker/kotlinx-serialization-kotlinx-serialization-json.mjs +5294 -0
- package/node_modules/@attocash/commons-worker/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -0
- package/node_modules/@attocash/commons-worker/package.json +29 -0
- package/node_modules/@attocash/commons-worker-remote/LICENSE +28 -0
- package/node_modules/@attocash/commons-worker-remote/README.md +60 -0
- package/node_modules/@attocash/commons-worker-remote/commons-commons-worker-remote.d.mts +93 -0
- package/node_modules/@attocash/commons-worker-remote/commons-commons-worker-remote.mjs +289 -0
- package/node_modules/@attocash/commons-worker-remote/commons-commons-worker-remote.mjs.map +1 -0
- package/node_modules/@attocash/commons-worker-remote/kotlin-logging.mjs +432 -0
- package/node_modules/@attocash/commons-worker-remote/kotlin-logging.mjs.map +1 -0
- package/node_modules/@attocash/commons-worker-remote/kotlinx-browser.mjs +8 -0
- package/node_modules/@attocash/commons-worker-remote/kotlinx-browser.mjs.map +1 -0
- package/node_modules/@attocash/commons-worker-remote/kotlinx-serialization-kotlinx-serialization-json-io.mjs +4 -0
- package/node_modules/@attocash/commons-worker-remote/kotlinx-serialization-kotlinx-serialization-json-io.mjs.map +1 -0
- package/node_modules/@attocash/commons-worker-remote/kotlinx-serialization-kotlinx-serialization-json.mjs +5294 -0
- package/node_modules/@attocash/commons-worker-remote/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -0
- package/node_modules/@attocash/commons-worker-remote/package.json +31 -0
- package/node_modules/@js-joda/core/CHANGELOG.md +363 -0
- package/node_modules/@js-joda/core/CheatSheet.md +947 -0
- package/node_modules/@js-joda/core/LICENSE +34 -0
- package/node_modules/@js-joda/core/README.md +155 -0
- package/node_modules/@js-joda/core/bower.json +21 -0
- package/node_modules/@js-joda/core/dist/js-joda.d.ts +2452 -0
- package/node_modules/@js-joda/core/dist/js-joda.esm.js +13564 -0
- package/node_modules/@js-joda/core/dist/js-joda.flow.js +949 -0
- package/node_modules/@js-joda/core/dist/js-joda.js +13630 -0
- package/node_modules/@js-joda/core/dist/js-joda.js.map +1 -0
- package/node_modules/@js-joda/core/dist/js-joda.min.js +5 -0
- package/node_modules/@js-joda/core/package.json +76 -0
- package/node_modules/@js-joda/core/src/Clock.js +330 -0
- package/node_modules/@js-joda/core/src/DayOfWeek.js +451 -0
- package/node_modules/@js-joda/core/src/Duration.js +1205 -0
- package/node_modules/@js-joda/core/src/Enum.js +30 -0
- package/node_modules/@js-joda/core/src/Instant.js +1012 -0
- package/node_modules/@js-joda/core/src/LocalDate.js +1703 -0
- package/node_modules/@js-joda/core/src/LocalDateTime.js +1686 -0
- package/node_modules/@js-joda/core/src/LocalTime.js +1415 -0
- package/node_modules/@js-joda/core/src/MathUtil.js +236 -0
- package/node_modules/@js-joda/core/src/Month.js +600 -0
- package/node_modules/@js-joda/core/src/MonthDay.js +730 -0
- package/node_modules/@js-joda/core/src/OffsetDateTime.js +757 -0
- package/node_modules/@js-joda/core/src/OffsetTime.js +621 -0
- package/node_modules/@js-joda/core/src/Period.js +933 -0
- package/node_modules/@js-joda/core/src/StringUtil.js +43 -0
- package/node_modules/@js-joda/core/src/Year.js +1015 -0
- package/node_modules/@js-joda/core/src/YearConstants.js +21 -0
- package/node_modules/@js-joda/core/src/YearMonth.js +1096 -0
- package/node_modules/@js-joda/core/src/ZoneId.js +236 -0
- package/node_modules/@js-joda/core/src/ZoneIdFactory.js +201 -0
- package/node_modules/@js-joda/core/src/ZoneOffset.js +486 -0
- package/node_modules/@js-joda/core/src/ZoneRegion.js +72 -0
- package/node_modules/@js-joda/core/src/ZonedDateTime.js +2007 -0
- package/node_modules/@js-joda/core/src/_init.js +68 -0
- package/node_modules/@js-joda/core/src/assert.js +33 -0
- package/node_modules/@js-joda/core/src/chrono/ChronoLocalDate.js +230 -0
- package/node_modules/@js-joda/core/src/chrono/ChronoLocalDateTime.js +130 -0
- package/node_modules/@js-joda/core/src/chrono/ChronoZonedDateTime.js +194 -0
- package/node_modules/@js-joda/core/src/chrono/IsoChronology.js +235 -0
- package/node_modules/@js-joda/core/src/convert.js +83 -0
- package/node_modules/@js-joda/core/src/errors.js +54 -0
- package/node_modules/@js-joda/core/src/format/DateTimeBuilder.js +535 -0
- package/node_modules/@js-joda/core/src/format/DateTimeFormatter.js +728 -0
- package/node_modules/@js-joda/core/src/format/DateTimeFormatterBuilder.js +1545 -0
- package/node_modules/@js-joda/core/src/format/DateTimeParseContext.js +297 -0
- package/node_modules/@js-joda/core/src/format/DateTimePrintContext.js +138 -0
- package/node_modules/@js-joda/core/src/format/DecimalStyle.js +113 -0
- package/node_modules/@js-joda/core/src/format/EnumMap.js +70 -0
- package/node_modules/@js-joda/core/src/format/ParsePosition.js +31 -0
- package/node_modules/@js-joda/core/src/format/ResolverStyle.js +93 -0
- package/node_modules/@js-joda/core/src/format/SignStyle.js +38 -0
- package/node_modules/@js-joda/core/src/format/StringBuilder.js +47 -0
- package/node_modules/@js-joda/core/src/format/TextStyle.js +114 -0
- package/node_modules/@js-joda/core/src/format/parser/CharLiteralPrinterParser.js +46 -0
- package/node_modules/@js-joda/core/src/format/parser/CompositePrinterParser.js +89 -0
- package/node_modules/@js-joda/core/src/format/parser/FractionPrinterParser.js +162 -0
- package/node_modules/@js-joda/core/src/format/parser/NumberPrinterParser.js +367 -0
- package/node_modules/@js-joda/core/src/format/parser/OffsetIdPrinterParser.js +177 -0
- package/node_modules/@js-joda/core/src/format/parser/PadPrinterParserDecorator.js +81 -0
- package/node_modules/@js-joda/core/src/format/parser/SettingsParser.js +44 -0
- package/node_modules/@js-joda/core/src/format/parser/StringLiteralPrinterParser.js +39 -0
- package/node_modules/@js-joda/core/src/format/parser/ZoneIdPrinterParser.js +218 -0
- package/node_modules/@js-joda/core/src/js-joda.js +210 -0
- package/node_modules/@js-joda/core/src/license-preamble.js +3 -0
- package/node_modules/@js-joda/core/src/temporal/ChronoField.js +470 -0
- package/node_modules/@js-joda/core/src/temporal/ChronoUnit.js +310 -0
- package/node_modules/@js-joda/core/src/temporal/DefaultInterfaceTemporal.js +118 -0
- package/node_modules/@js-joda/core/src/temporal/IsoFields.js +859 -0
- package/node_modules/@js-joda/core/src/temporal/NativeJsTemporal.js +105 -0
- package/node_modules/@js-joda/core/src/temporal/Temporal.js +346 -0
- package/node_modules/@js-joda/core/src/temporal/TemporalAccessor.js +125 -0
- package/node_modules/@js-joda/core/src/temporal/TemporalAdjuster.js +92 -0
- package/node_modules/@js-joda/core/src/temporal/TemporalAdjusters.js +464 -0
- package/node_modules/@js-joda/core/src/temporal/TemporalAmount.js +166 -0
- package/node_modules/@js-joda/core/src/temporal/TemporalField.js +248 -0
- package/node_modules/@js-joda/core/src/temporal/TemporalQueries.js +223 -0
- package/node_modules/@js-joda/core/src/temporal/TemporalQueriesFactory.js +77 -0
- package/node_modules/@js-joda/core/src/temporal/TemporalQuery.js +107 -0
- package/node_modules/@js-joda/core/src/temporal/TemporalUnit.js +179 -0
- package/node_modules/@js-joda/core/src/temporal/ValueRange.js +257 -0
- package/node_modules/@js-joda/core/src/use.js +20 -0
- package/node_modules/@js-joda/core/src/zone/SystemDefaultZoneId.js +31 -0
- package/node_modules/@js-joda/core/src/zone/SystemDefaultZoneRules.js +162 -0
- package/node_modules/@js-joda/core/src/zone/ZoneOffsetTransition.js +289 -0
- package/node_modules/@js-joda/core/src/zone/ZoneRules.js +464 -0
- package/node_modules/@js-joda/core/src/zone/ZoneRulesProvider.js +36 -0
- package/node_modules/@noble/hashes/LICENSE +21 -0
- package/node_modules/@noble/hashes/README.md +563 -0
- package/node_modules/@noble/hashes/_blake.d.ts +21 -0
- package/node_modules/@noble/hashes/_blake.d.ts.map +1 -0
- package/node_modules/@noble/hashes/_blake.js +52 -0
- package/node_modules/@noble/hashes/_blake.js.map +1 -0
- package/node_modules/@noble/hashes/_md.d.ts +99 -0
- package/node_modules/@noble/hashes/_md.d.ts.map +1 -0
- package/node_modules/@noble/hashes/_md.js +202 -0
- package/node_modules/@noble/hashes/_md.js.map +1 -0
- package/node_modules/@noble/hashes/_u64.d.ts +63 -0
- package/node_modules/@noble/hashes/_u64.d.ts.map +1 -0
- package/node_modules/@noble/hashes/_u64.js +84 -0
- package/node_modules/@noble/hashes/_u64.js.map +1 -0
- package/node_modules/@noble/hashes/argon2.d.ts +112 -0
- package/node_modules/@noble/hashes/argon2.d.ts.map +1 -0
- package/node_modules/@noble/hashes/argon2.js +517 -0
- package/node_modules/@noble/hashes/argon2.js.map +1 -0
- package/node_modules/@noble/hashes/blake1.d.ts +156 -0
- package/node_modules/@noble/hashes/blake1.d.ts.map +1 -0
- package/node_modules/@noble/hashes/blake1.js +560 -0
- package/node_modules/@noble/hashes/blake1.js.map +1 -0
- package/node_modules/@noble/hashes/blake2.d.ts +184 -0
- package/node_modules/@noble/hashes/blake2.d.ts.map +1 -0
- package/node_modules/@noble/hashes/blake2.js +501 -0
- package/node_modules/@noble/hashes/blake2.js.map +1 -0
- package/node_modules/@noble/hashes/blake3.d.ts +68 -0
- package/node_modules/@noble/hashes/blake3.d.ts.map +1 -0
- package/node_modules/@noble/hashes/blake3.js +284 -0
- package/node_modules/@noble/hashes/blake3.js.map +1 -0
- package/node_modules/@noble/hashes/eskdf.d.ts +92 -0
- package/node_modules/@noble/hashes/eskdf.d.ts.map +1 -0
- package/node_modules/@noble/hashes/eskdf.js +218 -0
- package/node_modules/@noble/hashes/eskdf.js.map +1 -0
- package/node_modules/@noble/hashes/hkdf.d.ts +64 -0
- package/node_modules/@noble/hashes/hkdf.d.ts.map +1 -0
- package/node_modules/@noble/hashes/hkdf.js +120 -0
- package/node_modules/@noble/hashes/hkdf.js.map +1 -0
- package/node_modules/@noble/hashes/hmac.d.ts +47 -0
- package/node_modules/@noble/hashes/hmac.d.ts.map +1 -0
- package/node_modules/@noble/hashes/hmac.js +93 -0
- package/node_modules/@noble/hashes/hmac.js.map +1 -0
- package/node_modules/@noble/hashes/index.d.ts +2 -0
- package/node_modules/@noble/hashes/index.d.ts.map +1 -0
- package/node_modules/@noble/hashes/index.js +35 -0
- package/node_modules/@noble/hashes/index.js.map +1 -0
- package/node_modules/@noble/hashes/legacy.d.ts +102 -0
- package/node_modules/@noble/hashes/legacy.d.ts.map +1 -0
- package/node_modules/@noble/hashes/legacy.js +327 -0
- package/node_modules/@noble/hashes/legacy.js.map +1 -0
- package/node_modules/@noble/hashes/package.json +97 -0
- package/node_modules/@noble/hashes/pbkdf2.d.ts +56 -0
- package/node_modules/@noble/hashes/pbkdf2.d.ts.map +1 -0
- package/node_modules/@noble/hashes/pbkdf2.js +135 -0
- package/node_modules/@noble/hashes/pbkdf2.js.map +1 -0
- package/node_modules/@noble/hashes/scrypt.d.ts +65 -0
- package/node_modules/@noble/hashes/scrypt.d.ts.map +1 -0
- package/node_modules/@noble/hashes/scrypt.js +257 -0
- package/node_modules/@noble/hashes/scrypt.js.map +1 -0
- package/node_modules/@noble/hashes/sha2.d.ts +249 -0
- package/node_modules/@noble/hashes/sha2.d.ts.map +1 -0
- package/node_modules/@noble/hashes/sha2.js +458 -0
- package/node_modules/@noble/hashes/sha2.js.map +1 -0
- package/node_modules/@noble/hashes/sha3-addons.d.ts +461 -0
- package/node_modules/@noble/hashes/sha3-addons.d.ts.map +1 -0
- package/node_modules/@noble/hashes/sha3-addons.js +783 -0
- package/node_modules/@noble/hashes/sha3-addons.js.map +1 -0
- package/node_modules/@noble/hashes/sha3.d.ts +199 -0
- package/node_modules/@noble/hashes/sha3.d.ts.map +1 -0
- package/node_modules/@noble/hashes/sha3.js +431 -0
- package/node_modules/@noble/hashes/sha3.js.map +1 -0
- package/node_modules/@noble/hashes/src/_blake.ts +57 -0
- package/node_modules/@noble/hashes/src/_md.ts +222 -0
- package/node_modules/@noble/hashes/src/_u64.ts +117 -0
- package/node_modules/@noble/hashes/src/argon2.ts +667 -0
- package/node_modules/@noble/hashes/src/blake1.ts +614 -0
- package/node_modules/@noble/hashes/src/blake2.ts +582 -0
- package/node_modules/@noble/hashes/src/blake3.ts +317 -0
- package/node_modules/@noble/hashes/src/eskdf.ts +259 -0
- package/node_modules/@noble/hashes/src/hkdf.ts +133 -0
- package/node_modules/@noble/hashes/src/hmac.ts +126 -0
- package/node_modules/@noble/hashes/src/index.ts +33 -0
- package/node_modules/@noble/hashes/src/legacy.ts +339 -0
- package/node_modules/@noble/hashes/src/pbkdf2.ts +175 -0
- package/node_modules/@noble/hashes/src/scrypt.ts +315 -0
- package/node_modules/@noble/hashes/src/sha2.ts +530 -0
- package/node_modules/@noble/hashes/src/sha3-addons.ts +983 -0
- package/node_modules/@noble/hashes/src/sha3.ts +485 -0
- package/node_modules/@noble/hashes/src/utils.ts +848 -0
- package/node_modules/@noble/hashes/src/webcrypto.ts +239 -0
- package/node_modules/@noble/hashes/utils.d.ts +519 -0
- package/node_modules/@noble/hashes/utils.d.ts.map +1 -0
- package/node_modules/@noble/hashes/utils.js +578 -0
- package/node_modules/@noble/hashes/utils.js.map +1 -0
- package/node_modules/@noble/hashes/webcrypto.d.ts +120 -0
- package/node_modules/@noble/hashes/webcrypto.d.ts.map +1 -0
- package/node_modules/@noble/hashes/webcrypto.js +165 -0
- package/node_modules/@noble/hashes/webcrypto.js.map +1 -0
- package/node_modules/ws/LICENSE +20 -0
- package/node_modules/ws/README.md +548 -0
- package/node_modules/ws/browser.js +8 -0
- package/node_modules/ws/index.js +22 -0
- package/node_modules/ws/lib/buffer-util.js +131 -0
- package/node_modules/ws/lib/constants.js +19 -0
- package/node_modules/ws/lib/event-target.js +292 -0
- package/node_modules/ws/lib/extension.js +203 -0
- package/node_modules/ws/lib/limiter.js +55 -0
- package/node_modules/ws/lib/permessage-deflate.js +530 -0
- package/node_modules/ws/lib/receiver.js +743 -0
- package/node_modules/ws/lib/sender.js +607 -0
- package/node_modules/ws/lib/stream.js +161 -0
- package/node_modules/ws/lib/subprotocol.js +62 -0
- package/node_modules/ws/lib/validation.js +152 -0
- package/node_modules/ws/lib/websocket-server.js +562 -0
- package/node_modules/ws/lib/websocket.js +1407 -0
- package/node_modules/ws/package.json +74 -0
- package/node_modules/ws/wrapper.mjs +21 -0
- package/package.json +53 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HKDF (RFC 5869): extract + expand in one step.
|
|
3
|
+
* See {@link https://soatok.blog/2021/11/17/understanding-hkdf/}.
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { hmac } from './hmac.ts';
|
|
7
|
+
import { abytes, ahash, anumber, type CHash, clean, type TArg, type TRet } from './utils.ts';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* HKDF-extract from spec. Less important part. `HKDF-Extract(IKM, salt) -> PRK`
|
|
11
|
+
* Arguments position differs from spec (IKM is first one, since it is not optional)
|
|
12
|
+
* Local validation only checks `hash`; `ikm` / `salt` byte validation is delegated to `hmac()`.
|
|
13
|
+
* @param hash - hash function that would be used (e.g. sha256)
|
|
14
|
+
* @param ikm - input keying material, the initial key
|
|
15
|
+
* @param salt - optional salt value (a non-secret random value)
|
|
16
|
+
* @returns Pseudorandom key derived from input keying material.
|
|
17
|
+
* @example
|
|
18
|
+
* Run the HKDF extract step.
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { extract } from '@noble/hashes/hkdf.js';
|
|
21
|
+
* import { sha256 } from '@noble/hashes/sha2.js';
|
|
22
|
+
* extract(sha256, new Uint8Array([1, 2, 3]), new Uint8Array([4, 5, 6]));
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export function extract(
|
|
26
|
+
hash: TArg<CHash>,
|
|
27
|
+
ikm: TArg<Uint8Array>,
|
|
28
|
+
salt?: TArg<Uint8Array>
|
|
29
|
+
): TRet<Uint8Array> {
|
|
30
|
+
ahash(hash);
|
|
31
|
+
// NOTE: some libraries treat zero-length array as 'not provided';
|
|
32
|
+
// we don't, since we have undefined as 'not provided'
|
|
33
|
+
// https://github.com/RustCrypto/KDFs/issues/15
|
|
34
|
+
if (salt === undefined) salt = new Uint8Array(hash.outputLen);
|
|
35
|
+
return hmac(hash, salt, ikm);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Shared mutable scratch byte for the RFC 5869 block counter `N`.
|
|
39
|
+
// Safe to reuse because `expand()` is synchronous and resets it with `clean(...)` before returning.
|
|
40
|
+
const HKDF_COUNTER = /* @__PURE__ */ Uint8Array.of(0);
|
|
41
|
+
// Shared RFC 5869 empty string for both `info === undefined` and the first-block `T(0)` input.
|
|
42
|
+
const EMPTY_BUFFER = /* @__PURE__ */ Uint8Array.of();
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* HKDF-expand from the spec. The most important part. `HKDF-Expand(PRK, info, L) -> OKM`
|
|
46
|
+
* @param hash - hash function that would be used (e.g. sha256)
|
|
47
|
+
* @param prk - a pseudorandom key of at least HashLen octets
|
|
48
|
+
* (usually, the output from the extract step)
|
|
49
|
+
* @param info - optional context and application specific information (can be a zero-length string)
|
|
50
|
+
* @param length - length of output keying material in bytes.
|
|
51
|
+
* RFC 5869 §2.3 allows `0..255*HashLen`, so `0` returns an empty OKM.
|
|
52
|
+
* @returns Output keying material with the requested length.
|
|
53
|
+
* @throws If the requested output length exceeds the HKDF limit
|
|
54
|
+
* for the selected hash. {@link Error}
|
|
55
|
+
* @example
|
|
56
|
+
* Run the HKDF expand step.
|
|
57
|
+
* ```ts
|
|
58
|
+
* import { expand } from '@noble/hashes/hkdf.js';
|
|
59
|
+
* import { sha256 } from '@noble/hashes/sha2.js';
|
|
60
|
+
* expand(sha256, new Uint8Array(32), new Uint8Array([1, 2, 3]), 16);
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export function expand(
|
|
64
|
+
hash: TArg<CHash>,
|
|
65
|
+
prk: TArg<Uint8Array>,
|
|
66
|
+
info?: TArg<Uint8Array>,
|
|
67
|
+
length: number = 32
|
|
68
|
+
): TRet<Uint8Array> {
|
|
69
|
+
ahash(hash);
|
|
70
|
+
anumber(length, 'length');
|
|
71
|
+
abytes(prk, undefined, 'prk');
|
|
72
|
+
const olen = hash.outputLen;
|
|
73
|
+
// RFC 5869 §2.3: PRK is "a pseudorandom key of at least HashLen octets".
|
|
74
|
+
if (prk.length < olen) throw new Error('"prk" must be at least HashLen octets');
|
|
75
|
+
// RFC 5869 §2.3 only bounds `L` by `<= 255*HashLen`; `L=0` is valid and yields empty OKM.
|
|
76
|
+
if (length > 255 * olen) throw new Error('Length must be <= 255*HashLen');
|
|
77
|
+
const blocks = Math.ceil(length / olen);
|
|
78
|
+
if (info === undefined) info = EMPTY_BUFFER;
|
|
79
|
+
else abytes(info, undefined, 'info');
|
|
80
|
+
// first L(ength) octets of T
|
|
81
|
+
const okm = new Uint8Array(blocks * olen);
|
|
82
|
+
// Re-use HMAC instance between blocks
|
|
83
|
+
const HMAC = hmac.create(hash, prk);
|
|
84
|
+
const HMACTmp = HMAC._cloneInto();
|
|
85
|
+
const T = new Uint8Array(HMAC.outputLen);
|
|
86
|
+
for (let counter = 0; counter < blocks; counter++) {
|
|
87
|
+
HKDF_COUNTER[0] = counter + 1;
|
|
88
|
+
// T(0) = empty string (zero length)
|
|
89
|
+
// T(N) = HMAC-Hash(PRK, T(N-1) | info | N)
|
|
90
|
+
HMACTmp.update(counter === 0 ? EMPTY_BUFFER : T)
|
|
91
|
+
.update(info)
|
|
92
|
+
.update(HKDF_COUNTER)
|
|
93
|
+
.digestInto(T);
|
|
94
|
+
okm.set(T, olen * counter);
|
|
95
|
+
HMAC._cloneInto(HMACTmp);
|
|
96
|
+
}
|
|
97
|
+
HMAC.destroy();
|
|
98
|
+
HMACTmp.destroy();
|
|
99
|
+
clean(T, HKDF_COUNTER);
|
|
100
|
+
return okm.slice(0, length) as TRet<Uint8Array>;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* HKDF (RFC 5869): derive keys from an initial input.
|
|
105
|
+
* Combines hkdf_extract + hkdf_expand in one step
|
|
106
|
+
* @param hash - hash function that would be used (e.g. sha256)
|
|
107
|
+
* @param ikm - input keying material, the initial key
|
|
108
|
+
* @param salt - optional salt value (a non-secret random value)
|
|
109
|
+
* @param info - optional context and application specific information bytes
|
|
110
|
+
* @param length - length of output keying material in bytes.
|
|
111
|
+
* RFC 5869 §2.3 allows `0..255*HashLen`, so `0` returns an empty OKM.
|
|
112
|
+
* @returns Output keying material derived from the input key.
|
|
113
|
+
* @throws If the requested output length exceeds the HKDF limit
|
|
114
|
+
* for the selected hash. {@link Error}
|
|
115
|
+
* @example
|
|
116
|
+
* HKDF (RFC 5869): derive keys from an initial input.
|
|
117
|
+
* ```ts
|
|
118
|
+
* import { hkdf } from '@noble/hashes/hkdf.js';
|
|
119
|
+
* import { sha256 } from '@noble/hashes/sha2.js';
|
|
120
|
+
* import { randomBytes, utf8ToBytes } from '@noble/hashes/utils.js';
|
|
121
|
+
* const inputKey = randomBytes(32);
|
|
122
|
+
* const salt = randomBytes(32);
|
|
123
|
+
* const info = utf8ToBytes('application-key');
|
|
124
|
+
* const okm = hkdf(sha256, inputKey, salt, info, 32);
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
export const hkdf = (
|
|
128
|
+
hash: TArg<CHash>,
|
|
129
|
+
ikm: TArg<Uint8Array>,
|
|
130
|
+
salt: TArg<Uint8Array | undefined>,
|
|
131
|
+
info: TArg<Uint8Array | undefined>,
|
|
132
|
+
length: number
|
|
133
|
+
): TRet<Uint8Array> => expand(hash, extract(hash, ikm, salt), info, length);
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HMAC: RFC2104 message authentication code.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
import {
|
|
6
|
+
abytes,
|
|
7
|
+
aexists,
|
|
8
|
+
ahash,
|
|
9
|
+
aoutput,
|
|
10
|
+
clean,
|
|
11
|
+
type CHash,
|
|
12
|
+
type Hash,
|
|
13
|
+
type TArg,
|
|
14
|
+
type TRet,
|
|
15
|
+
} from './utils.ts';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Internal class for HMAC.
|
|
19
|
+
* Accepts any byte key, although RFC 2104 §3 recommends keys at least
|
|
20
|
+
* `HashLen` bytes long.
|
|
21
|
+
*/
|
|
22
|
+
export class _HMAC<T extends Hash<T>> implements Hash<_HMAC<T>> {
|
|
23
|
+
oHash: T;
|
|
24
|
+
iHash: T;
|
|
25
|
+
blockLen: number;
|
|
26
|
+
outputLen: number;
|
|
27
|
+
canXOF = false;
|
|
28
|
+
private finished = false;
|
|
29
|
+
private destroyed = false;
|
|
30
|
+
|
|
31
|
+
constructor(hash: TArg<CHash>, key: TArg<Uint8Array>) {
|
|
32
|
+
ahash(hash);
|
|
33
|
+
abytes(key, undefined, 'key');
|
|
34
|
+
this.iHash = hash.create() as T;
|
|
35
|
+
if (typeof this.iHash.update !== 'function')
|
|
36
|
+
throw new Error('Expected instance of class which extends utils.Hash');
|
|
37
|
+
this.blockLen = this.iHash.blockLen;
|
|
38
|
+
this.outputLen = this.iHash.outputLen;
|
|
39
|
+
const blockLen = this.blockLen;
|
|
40
|
+
const pad = new Uint8Array(blockLen);
|
|
41
|
+
// blockLen can be bigger than outputLen
|
|
42
|
+
pad.set(key.length > blockLen ? hash.create().update(key).digest() : key);
|
|
43
|
+
for (let i = 0; i < pad.length; i++) pad[i] ^= 0x36;
|
|
44
|
+
this.iHash.update(pad);
|
|
45
|
+
// By doing update (processing of the first block) of the outer hash here,
|
|
46
|
+
// we can re-use it between multiple calls via clone.
|
|
47
|
+
this.oHash = hash.create() as T;
|
|
48
|
+
// Undo internal XOR && apply outer XOR
|
|
49
|
+
for (let i = 0; i < pad.length; i++) pad[i] ^= 0x36 ^ 0x5c;
|
|
50
|
+
this.oHash.update(pad);
|
|
51
|
+
clean(pad);
|
|
52
|
+
}
|
|
53
|
+
update(buf: TArg<Uint8Array>): this {
|
|
54
|
+
aexists(this);
|
|
55
|
+
this.iHash.update(buf);
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
digestInto(out: TArg<Uint8Array>): void {
|
|
59
|
+
aexists(this);
|
|
60
|
+
aoutput(out, this);
|
|
61
|
+
this.finished = true;
|
|
62
|
+
const buf = out.subarray(0, this.outputLen);
|
|
63
|
+
// Reuse the first outputLen bytes for the inner digest; the outer hash consumes them before
|
|
64
|
+
// overwriting that same prefix with the final tag, leaving any oversized tail untouched.
|
|
65
|
+
this.iHash.digestInto(buf);
|
|
66
|
+
this.oHash.update(buf);
|
|
67
|
+
this.oHash.digestInto(buf);
|
|
68
|
+
this.destroy();
|
|
69
|
+
}
|
|
70
|
+
digest(): TRet<Uint8Array> {
|
|
71
|
+
const out = new Uint8Array(this.oHash.outputLen);
|
|
72
|
+
this.digestInto(out);
|
|
73
|
+
return out as TRet<Uint8Array>;
|
|
74
|
+
}
|
|
75
|
+
_cloneInto(to?: _HMAC<T>): _HMAC<T> {
|
|
76
|
+
// Create new instance without calling constructor since the key
|
|
77
|
+
// is already in state and we don't know it.
|
|
78
|
+
to ||= Object.create(Object.getPrototypeOf(this), {});
|
|
79
|
+
const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;
|
|
80
|
+
to = to as this;
|
|
81
|
+
to.finished = finished;
|
|
82
|
+
to.destroyed = destroyed;
|
|
83
|
+
to.blockLen = blockLen;
|
|
84
|
+
to.outputLen = outputLen;
|
|
85
|
+
to.oHash = oHash._cloneInto(to.oHash);
|
|
86
|
+
to.iHash = iHash._cloneInto(to.iHash);
|
|
87
|
+
return to;
|
|
88
|
+
}
|
|
89
|
+
clone(): _HMAC<T> {
|
|
90
|
+
return this._cloneInto();
|
|
91
|
+
}
|
|
92
|
+
destroy(): void {
|
|
93
|
+
this.destroyed = true;
|
|
94
|
+
this.oHash.destroy();
|
|
95
|
+
this.iHash.destroy();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* HMAC: RFC2104 message authentication code.
|
|
101
|
+
* @param hash - function that would be used e.g. sha256
|
|
102
|
+
* @param key - authentication key bytes
|
|
103
|
+
* @param message - message bytes to authenticate
|
|
104
|
+
* @returns Authentication tag bytes.
|
|
105
|
+
* @example
|
|
106
|
+
* Compute an RFC 2104 HMAC.
|
|
107
|
+
* ```ts
|
|
108
|
+
* import { hmac } from '@noble/hashes/hmac.js';
|
|
109
|
+
* import { sha256 } from '@noble/hashes/sha2.js';
|
|
110
|
+
* const mac = hmac(sha256, new Uint8Array([1, 2, 3]), new Uint8Array([4, 5, 6]));
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
type HmacFn = {
|
|
114
|
+
(hash: TArg<CHash>, key: TArg<Uint8Array>, message: TArg<Uint8Array>): TRet<Uint8Array>;
|
|
115
|
+
create(hash: TArg<CHash>, key: TArg<Uint8Array>): TRet<_HMAC<any>>;
|
|
116
|
+
};
|
|
117
|
+
export const hmac: TRet<HmacFn> = /* @__PURE__ */ (() => {
|
|
118
|
+
const hmac_ = ((
|
|
119
|
+
hash: TArg<CHash>,
|
|
120
|
+
key: TArg<Uint8Array>,
|
|
121
|
+
message: TArg<Uint8Array>
|
|
122
|
+
): TRet<Uint8Array> => new _HMAC<any>(hash, key).update(message).digest()) as TRet<HmacFn>;
|
|
123
|
+
hmac_.create = (hash: TArg<CHash>, key: TArg<Uint8Array>): TRet<_HMAC<any>> =>
|
|
124
|
+
new _HMAC<any>(hash, key) as TRet<_HMAC<any>>;
|
|
125
|
+
return hmac_;
|
|
126
|
+
})();
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Audited & minimal JS implementation of hash functions, MACs, and KDFs.
|
|
3
|
+
* Check out individual modules.
|
|
4
|
+
* @module
|
|
5
|
+
* @example
|
|
6
|
+
```js
|
|
7
|
+
import {
|
|
8
|
+
sha256, sha384, sha512, sha224, sha512_224, sha512_256
|
|
9
|
+
} from '@noble/hashes/sha2.js';
|
|
10
|
+
import {
|
|
11
|
+
sha3_224, sha3_256, sha3_384, sha3_512,
|
|
12
|
+
keccak_224, keccak_256, keccak_384, keccak_512,
|
|
13
|
+
shake128, shake256
|
|
14
|
+
} from '@noble/hashes/sha3.js';
|
|
15
|
+
import {
|
|
16
|
+
cshake128, cshake256,
|
|
17
|
+
turboshake128, turboshake256,
|
|
18
|
+
kt128, kt256,
|
|
19
|
+
kmac128, kmac256,
|
|
20
|
+
tuplehash256, parallelhash256,
|
|
21
|
+
keccakprg
|
|
22
|
+
} from '@noble/hashes/sha3-addons.js';
|
|
23
|
+
import { blake3 } from '@noble/hashes/blake3.js';
|
|
24
|
+
import { blake2b, blake2s } from '@noble/hashes/blake2.js';
|
|
25
|
+
import { hmac } from '@noble/hashes/hmac.js';
|
|
26
|
+
import { hkdf } from '@noble/hashes/hkdf.js';
|
|
27
|
+
import { pbkdf2, pbkdf2Async } from '@noble/hashes/pbkdf2.js';
|
|
28
|
+
import { scrypt, scryptAsync } from '@noble/hashes/scrypt.js';
|
|
29
|
+
import { md5, ripemd160, sha1 } from '@noble/hashes/legacy.js';
|
|
30
|
+
import * as utils from '@noble/hashes/utils.js';
|
|
31
|
+
```
|
|
32
|
+
*/
|
|
33
|
+
throw new Error('root module cannot be imported: import submodules instead. Check out README');
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
/**
|
|
2
|
+
|
|
3
|
+
SHA1 (RFC 3174), MD5 (RFC 1321), and RIPEMD160 legacy, weak hash functions.
|
|
4
|
+
RFC 2286 only covers HMAC-RIPEMD160 wrapper material and test vectors,
|
|
5
|
+
not the base RIPEMD-160 compression spec.
|
|
6
|
+
Don't use them in a new protocol. What "weak" means:
|
|
7
|
+
|
|
8
|
+
- Collisions can be made with 2^18 effort in MD5, 2^60 in SHA1, 2^80 in RIPEMD160.
|
|
9
|
+
- No practical pre-image attacks (only theoretical, 2^123.4)
|
|
10
|
+
- HMAC seems kinda ok: https://www.rfc-editor.org/rfc/rfc6151
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import { Chi, HashMD, Maj } from './_md.ts';
|
|
14
|
+
import { type CHash, clean, createHasher, rotl, type TRet } from './utils.ts';
|
|
15
|
+
|
|
16
|
+
/** Initial SHA-1 state from RFC 3174 §6.1. */
|
|
17
|
+
const SHA1_IV = /* @__PURE__ */ Uint32Array.from([
|
|
18
|
+
0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0,
|
|
19
|
+
]);
|
|
20
|
+
|
|
21
|
+
// Reusable 80-word SHA-1 message schedule buffer.
|
|
22
|
+
const SHA1_W = /* @__PURE__ */ new Uint32Array(80);
|
|
23
|
+
|
|
24
|
+
/** Internal SHA1 legacy hash class. */
|
|
25
|
+
export class _SHA1 extends HashMD<_SHA1> {
|
|
26
|
+
private A = SHA1_IV[0] | 0;
|
|
27
|
+
private B = SHA1_IV[1] | 0;
|
|
28
|
+
private C = SHA1_IV[2] | 0;
|
|
29
|
+
private D = SHA1_IV[3] | 0;
|
|
30
|
+
private E = SHA1_IV[4] | 0;
|
|
31
|
+
|
|
32
|
+
constructor() {
|
|
33
|
+
super(64, 20, 8, false);
|
|
34
|
+
}
|
|
35
|
+
protected get(): [number, number, number, number, number] {
|
|
36
|
+
const { A, B, C, D, E } = this;
|
|
37
|
+
return [A, B, C, D, E];
|
|
38
|
+
}
|
|
39
|
+
protected set(A: number, B: number, C: number, D: number, E: number): void {
|
|
40
|
+
this.A = A | 0;
|
|
41
|
+
this.B = B | 0;
|
|
42
|
+
this.C = C | 0;
|
|
43
|
+
this.D = D | 0;
|
|
44
|
+
this.E = E | 0;
|
|
45
|
+
}
|
|
46
|
+
protected process(view: DataView, offset: number): void {
|
|
47
|
+
for (let i = 0; i < 16; i++, offset += 4) SHA1_W[i] = view.getUint32(offset, false);
|
|
48
|
+
for (let i = 16; i < 80; i++)
|
|
49
|
+
SHA1_W[i] = rotl(SHA1_W[i - 3] ^ SHA1_W[i - 8] ^ SHA1_W[i - 14] ^ SHA1_W[i - 16], 1);
|
|
50
|
+
// Compression function main loop, 80 rounds
|
|
51
|
+
let { A, B, C, D, E } = this;
|
|
52
|
+
for (let i = 0; i < 80; i++) {
|
|
53
|
+
let F, K;
|
|
54
|
+
if (i < 20) {
|
|
55
|
+
F = Chi(B, C, D);
|
|
56
|
+
K = 0x5a827999;
|
|
57
|
+
} else if (i < 40) {
|
|
58
|
+
F = B ^ C ^ D;
|
|
59
|
+
K = 0x6ed9eba1;
|
|
60
|
+
} else if (i < 60) {
|
|
61
|
+
F = Maj(B, C, D);
|
|
62
|
+
K = 0x8f1bbcdc;
|
|
63
|
+
} else {
|
|
64
|
+
F = B ^ C ^ D;
|
|
65
|
+
K = 0xca62c1d6;
|
|
66
|
+
}
|
|
67
|
+
const T = (rotl(A, 5) + F + E + K + SHA1_W[i]) | 0;
|
|
68
|
+
E = D;
|
|
69
|
+
D = C;
|
|
70
|
+
C = rotl(B, 30);
|
|
71
|
+
B = A;
|
|
72
|
+
A = T;
|
|
73
|
+
}
|
|
74
|
+
// Add the compressed chunk to the current hash value
|
|
75
|
+
A = (A + this.A) | 0;
|
|
76
|
+
B = (B + this.B) | 0;
|
|
77
|
+
C = (C + this.C) | 0;
|
|
78
|
+
D = (D + this.D) | 0;
|
|
79
|
+
E = (E + this.E) | 0;
|
|
80
|
+
this.set(A, B, C, D, E);
|
|
81
|
+
}
|
|
82
|
+
protected roundClean(): void {
|
|
83
|
+
clean(SHA1_W);
|
|
84
|
+
}
|
|
85
|
+
destroy(): void {
|
|
86
|
+
// HashMD callers route post-destroy usability through `destroyed`; zeroizing alone still leaves
|
|
87
|
+
// update()/digest() callable on reused instances.
|
|
88
|
+
this.destroyed = true;
|
|
89
|
+
this.set(0, 0, 0, 0, 0);
|
|
90
|
+
clean(this.buffer);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* SHA1 (RFC 3174) legacy hash function. It was cryptographically broken.
|
|
96
|
+
* @param msg - message bytes to hash
|
|
97
|
+
* @returns Digest bytes.
|
|
98
|
+
* @example
|
|
99
|
+
* Hash a message with SHA1.
|
|
100
|
+
* ```ts
|
|
101
|
+
* sha1(new Uint8Array([97, 98, 99]));
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export const sha1: TRet<CHash> = /* @__PURE__ */ createHasher(() => new _SHA1());
|
|
105
|
+
|
|
106
|
+
/** RFC 1321 `T[i]` uses `floor(2^32 * abs(sin(i)))`; this is the shared `2^32` scale factor. */
|
|
107
|
+
const p32 = /* @__PURE__ */ Math.pow(2, 32);
|
|
108
|
+
/** RFC 1321 `T[1..64]` table. */
|
|
109
|
+
const K = /* @__PURE__ */ Array.from({ length: 64 }, (_, i) =>
|
|
110
|
+
Math.floor(p32 * Math.abs(Math.sin(i + 1)))
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
/** MD5 initial state from RFC 1321, stored as 4 u32 words. */
|
|
114
|
+
const MD5_IV = /* @__PURE__ */ SHA1_IV.slice(0, 4);
|
|
115
|
+
|
|
116
|
+
// Reusable 16-word MD5 message block buffer.
|
|
117
|
+
const MD5_W = /* @__PURE__ */ new Uint32Array(16);
|
|
118
|
+
/** Internal MD5 legacy hash class. */
|
|
119
|
+
export class _MD5 extends HashMD<_MD5> {
|
|
120
|
+
private A = MD5_IV[0] | 0;
|
|
121
|
+
private B = MD5_IV[1] | 0;
|
|
122
|
+
private C = MD5_IV[2] | 0;
|
|
123
|
+
private D = MD5_IV[3] | 0;
|
|
124
|
+
|
|
125
|
+
constructor() {
|
|
126
|
+
super(64, 16, 8, true);
|
|
127
|
+
}
|
|
128
|
+
protected get(): [number, number, number, number] {
|
|
129
|
+
const { A, B, C, D } = this;
|
|
130
|
+
return [A, B, C, D];
|
|
131
|
+
}
|
|
132
|
+
protected set(A: number, B: number, C: number, D: number): void {
|
|
133
|
+
this.A = A | 0;
|
|
134
|
+
this.B = B | 0;
|
|
135
|
+
this.C = C | 0;
|
|
136
|
+
this.D = D | 0;
|
|
137
|
+
}
|
|
138
|
+
protected process(view: DataView, offset: number): void {
|
|
139
|
+
for (let i = 0; i < 16; i++, offset += 4) MD5_W[i] = view.getUint32(offset, true);
|
|
140
|
+
// Compression function main loop, 64 rounds
|
|
141
|
+
let { A, B, C, D } = this;
|
|
142
|
+
for (let i = 0; i < 64; i++) {
|
|
143
|
+
let F, g, s;
|
|
144
|
+
if (i < 16) {
|
|
145
|
+
F = Chi(B, C, D);
|
|
146
|
+
g = i;
|
|
147
|
+
s = [7, 12, 17, 22];
|
|
148
|
+
} else if (i < 32) {
|
|
149
|
+
// RFC 1321 round 2 uses G(B,C,D) = (B & D) | (C & ~D), which is `Chi(D, B, C)`.
|
|
150
|
+
F = Chi(D, B, C);
|
|
151
|
+
g = (5 * i + 1) % 16;
|
|
152
|
+
s = [5, 9, 14, 20];
|
|
153
|
+
} else if (i < 48) {
|
|
154
|
+
F = B ^ C ^ D;
|
|
155
|
+
g = (3 * i + 5) % 16;
|
|
156
|
+
s = [4, 11, 16, 23];
|
|
157
|
+
} else {
|
|
158
|
+
F = C ^ (B | ~D);
|
|
159
|
+
g = (7 * i) % 16;
|
|
160
|
+
s = [6, 10, 15, 21];
|
|
161
|
+
}
|
|
162
|
+
F = F + A + K[i] + MD5_W[g];
|
|
163
|
+
A = D;
|
|
164
|
+
D = C;
|
|
165
|
+
C = B;
|
|
166
|
+
B = B + rotl(F, s[i % 4]);
|
|
167
|
+
}
|
|
168
|
+
// Add the compressed chunk to the current hash value
|
|
169
|
+
A = (A + this.A) | 0;
|
|
170
|
+
B = (B + this.B) | 0;
|
|
171
|
+
C = (C + this.C) | 0;
|
|
172
|
+
D = (D + this.D) | 0;
|
|
173
|
+
this.set(A, B, C, D);
|
|
174
|
+
}
|
|
175
|
+
protected roundClean(): void {
|
|
176
|
+
clean(MD5_W);
|
|
177
|
+
}
|
|
178
|
+
destroy(): void {
|
|
179
|
+
// HashMD callers route post-destroy usability through `destroyed`; zeroizing alone still leaves
|
|
180
|
+
// update()/digest() callable on reused instances.
|
|
181
|
+
this.destroyed = true;
|
|
182
|
+
this.set(0, 0, 0, 0);
|
|
183
|
+
clean(this.buffer);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* MD5 (RFC 1321) legacy hash function. It was cryptographically broken.
|
|
189
|
+
* MD5 architecture is similar to SHA1, with some differences:
|
|
190
|
+
* - Reduced output length: 16 bytes (128 bit) instead of 20
|
|
191
|
+
* - 64 rounds, instead of 80
|
|
192
|
+
* - Little-endian: could be faster, but will require more code
|
|
193
|
+
* - Non-linear index selection: huge speed-up for unroll
|
|
194
|
+
* - Per round constants: more memory accesses, additional speed-up for unroll
|
|
195
|
+
* @param msg - message bytes to hash
|
|
196
|
+
* @returns Digest bytes.
|
|
197
|
+
* @example
|
|
198
|
+
* Hash a message with MD5.
|
|
199
|
+
* ```ts
|
|
200
|
+
* md5(new Uint8Array([97, 98, 99]));
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
export const md5: TRet<CHash> = /* @__PURE__ */ createHasher(() => new _MD5());
|
|
204
|
+
|
|
205
|
+
// RIPEMD-160
|
|
206
|
+
|
|
207
|
+
// Permutation repeatedly applied to derive the later RIPEMD-160 message-order tables.
|
|
208
|
+
const Rho160 = /* @__PURE__ */ Uint8Array.from([
|
|
209
|
+
7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
|
|
210
|
+
]);
|
|
211
|
+
const Id160 = /* @__PURE__ */ (() => Uint8Array.from(new Array(16).fill(0).map((_, i) => i)))();
|
|
212
|
+
const Pi160 = /* @__PURE__ */ (() => Id160.map((i) => (9 * i + 5) % 16))();
|
|
213
|
+
// Five left/right message-word orderings for the RIPEMD-160 dual-lane rounds.
|
|
214
|
+
const idxLR = /* @__PURE__ */ (() => {
|
|
215
|
+
const L = [Id160];
|
|
216
|
+
const R = [Pi160];
|
|
217
|
+
const res = [L, R];
|
|
218
|
+
for (let i = 0; i < 4; i++) for (let j of res) j.push(j[i].map((k) => Rho160[k]));
|
|
219
|
+
return res;
|
|
220
|
+
})();
|
|
221
|
+
const idxL = /* @__PURE__ */ (() => idxLR[0])();
|
|
222
|
+
const idxR = /* @__PURE__ */ (() => idxLR[1])();
|
|
223
|
+
// const [idxL, idxR] = idxLR;
|
|
224
|
+
|
|
225
|
+
// Base per-group shift table before the left/right message-order permutations are applied.
|
|
226
|
+
const shifts160 = /* @__PURE__ */ [
|
|
227
|
+
[11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8],
|
|
228
|
+
[12, 13, 11, 15, 6, 9, 9, 7, 12, 15, 11, 13, 7, 8, 7, 7],
|
|
229
|
+
[13, 15, 14, 11, 7, 7, 6, 8, 13, 14, 13, 12, 5, 5, 6, 9],
|
|
230
|
+
[14, 11, 12, 14, 8, 6, 5, 5, 15, 12, 15, 14, 9, 9, 8, 6],
|
|
231
|
+
[15, 12, 13, 13, 9, 5, 8, 6, 14, 11, 12, 11, 8, 6, 5, 5],
|
|
232
|
+
].map((i) => Uint8Array.from(i));
|
|
233
|
+
const shiftsL160 = /* @__PURE__ */ idxL.map((idx, i) => idx.map((j) => shifts160[i][j]));
|
|
234
|
+
const shiftsR160 = /* @__PURE__ */ idxR.map((idx, i) => idx.map((j) => shifts160[i][j]));
|
|
235
|
+
// Five left-lane additive constants for RIPEMD-160.
|
|
236
|
+
const Kl160 = /* @__PURE__ */ Uint32Array.from([
|
|
237
|
+
0x00000000, 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xa953fd4e,
|
|
238
|
+
]);
|
|
239
|
+
// Five right-lane additive constants for RIPEMD-160.
|
|
240
|
+
const Kr160 = /* @__PURE__ */ Uint32Array.from([
|
|
241
|
+
0x50a28be6, 0x5c4dd124, 0x6d703ef3, 0x7a6d76e9, 0x00000000,
|
|
242
|
+
]);
|
|
243
|
+
// Called `f()` in the spec; valid `group` values are 0..4, and out-of-range
|
|
244
|
+
// inputs currently fall through to the group-4 branch.
|
|
245
|
+
function ripemd_f(group: number, x: number, y: number, z: number): number {
|
|
246
|
+
if (group === 0) return x ^ y ^ z;
|
|
247
|
+
if (group === 1) return (x & y) | (~x & z);
|
|
248
|
+
if (group === 2) return (x | ~y) ^ z;
|
|
249
|
+
if (group === 3) return (x & z) | (y & ~z);
|
|
250
|
+
return x ^ (y | ~z);
|
|
251
|
+
}
|
|
252
|
+
// Reusable 16-word RIPEMD-160 message block buffer.
|
|
253
|
+
const BUF_160 = /* @__PURE__ */ new Uint32Array(16);
|
|
254
|
+
/**
|
|
255
|
+
* Internal RIPEMD-160 legacy hash class.
|
|
256
|
+
* RFC 2286 only adds HMAC-RIPEMD160 material, not the core hash specification.
|
|
257
|
+
*/
|
|
258
|
+
export class _RIPEMD160 extends HashMD<_RIPEMD160> {
|
|
259
|
+
private h0 = 0x67452301 | 0;
|
|
260
|
+
private h1 = 0xefcdab89 | 0;
|
|
261
|
+
private h2 = 0x98badcfe | 0;
|
|
262
|
+
private h3 = 0x10325476 | 0;
|
|
263
|
+
private h4 = 0xc3d2e1f0 | 0;
|
|
264
|
+
|
|
265
|
+
constructor() {
|
|
266
|
+
super(64, 20, 8, true);
|
|
267
|
+
}
|
|
268
|
+
protected get(): [number, number, number, number, number] {
|
|
269
|
+
const { h0, h1, h2, h3, h4 } = this;
|
|
270
|
+
return [h0, h1, h2, h3, h4];
|
|
271
|
+
}
|
|
272
|
+
protected set(h0: number, h1: number, h2: number, h3: number, h4: number): void {
|
|
273
|
+
this.h0 = h0 | 0;
|
|
274
|
+
this.h1 = h1 | 0;
|
|
275
|
+
this.h2 = h2 | 0;
|
|
276
|
+
this.h3 = h3 | 0;
|
|
277
|
+
this.h4 = h4 | 0;
|
|
278
|
+
}
|
|
279
|
+
protected process(view: DataView, offset: number): void {
|
|
280
|
+
for (let i = 0; i < 16; i++, offset += 4) BUF_160[i] = view.getUint32(offset, true);
|
|
281
|
+
// prettier-ignore
|
|
282
|
+
let al = this.h0 | 0, ar = al,
|
|
283
|
+
bl = this.h1 | 0, br = bl,
|
|
284
|
+
cl = this.h2 | 0, cr = cl,
|
|
285
|
+
dl = this.h3 | 0, dr = dl,
|
|
286
|
+
el = this.h4 | 0, er = el;
|
|
287
|
+
|
|
288
|
+
// Instead of iterating 0 to 80, we split it into 5 groups
|
|
289
|
+
// And use the groups in constants, functions, etc. Much simpler
|
|
290
|
+
for (let group = 0; group < 5; group++) {
|
|
291
|
+
const rGroup = 4 - group;
|
|
292
|
+
const hbl = Kl160[group], hbr = Kr160[group]; // prettier-ignore
|
|
293
|
+
const rl = idxL[group], rr = idxR[group]; // prettier-ignore
|
|
294
|
+
const sl = shiftsL160[group], sr = shiftsR160[group]; // prettier-ignore
|
|
295
|
+
for (let i = 0; i < 16; i++) {
|
|
296
|
+
const tl = (rotl(al + ripemd_f(group, bl, cl, dl) + BUF_160[rl[i]] + hbl, sl[i]) + el) | 0;
|
|
297
|
+
al = el, el = dl, dl = rotl(cl, 10) | 0, cl = bl, bl = tl; // prettier-ignore
|
|
298
|
+
}
|
|
299
|
+
// 2 loops are 10% faster
|
|
300
|
+
for (let i = 0; i < 16; i++) {
|
|
301
|
+
const tr = (rotl(ar + ripemd_f(rGroup, br, cr, dr) + BUF_160[rr[i]] + hbr, sr[i]) + er) | 0;
|
|
302
|
+
ar = er, er = dr, dr = rotl(cr, 10) | 0, cr = br, br = tr; // prettier-ignore
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
// Add the compressed chunk to the current hash value
|
|
306
|
+
// Final recombination cross-adds the left/right lane accumulators into the next h0..h4 order.
|
|
307
|
+
this.set(
|
|
308
|
+
(this.h1 + cl + dr) | 0,
|
|
309
|
+
(this.h2 + dl + er) | 0,
|
|
310
|
+
(this.h3 + el + ar) | 0,
|
|
311
|
+
(this.h4 + al + br) | 0,
|
|
312
|
+
(this.h0 + bl + cr) | 0
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
protected roundClean(): void {
|
|
316
|
+
clean(BUF_160);
|
|
317
|
+
}
|
|
318
|
+
destroy(): void {
|
|
319
|
+
this.destroyed = true;
|
|
320
|
+
clean(this.buffer);
|
|
321
|
+
this.set(0, 0, 0, 0, 0);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* RIPEMD-160 - a legacy hash function from 1990s.
|
|
327
|
+
* RFC 2286 only covers HMAC-RIPEMD160 test material; the links below point
|
|
328
|
+
* at the base RIPEMD-160 references.
|
|
329
|
+
* * {@link https://homes.esat.kuleuven.be/~bosselae/ripemd160.html}
|
|
330
|
+
* * {@link https://homes.esat.kuleuven.be/~bosselae/ripemd160/pdf/AB-9601/AB-9601.pdf}
|
|
331
|
+
* @param msg - message bytes to hash
|
|
332
|
+
* @returns Digest bytes.
|
|
333
|
+
* @example
|
|
334
|
+
* Hash a message with RIPEMD-160.
|
|
335
|
+
* ```ts
|
|
336
|
+
* ripemd160(new Uint8Array([97, 98, 99]));
|
|
337
|
+
* ```
|
|
338
|
+
*/
|
|
339
|
+
export const ripemd160: TRet<CHash> = /* @__PURE__ */ createHasher(() => new _RIPEMD160());
|