@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,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal Merkle-Damgard hash utils.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
import { type Hash, type TArg, type TRet } from './utils.ts';
|
|
6
|
+
/**
|
|
7
|
+
* Shared 32-bit conditional boolean primitive reused by SHA-256, SHA-1, and MD5 `F`.
|
|
8
|
+
* Returns bits from `b` when `a` is set, otherwise from `c`.
|
|
9
|
+
* The XOR form is equivalent to MD5's `F(X,Y,Z) = XY v not(X)Z` because the masked terms never
|
|
10
|
+
* set the same bit.
|
|
11
|
+
* @param a - selector word
|
|
12
|
+
* @param b - word chosen when selector bit is set
|
|
13
|
+
* @param c - word chosen when selector bit is clear
|
|
14
|
+
* @returns Mixed 32-bit word.
|
|
15
|
+
* @example
|
|
16
|
+
* Combine three words with the shared 32-bit choice primitive.
|
|
17
|
+
* ```ts
|
|
18
|
+
* Chi(0xffffffff, 0x12345678, 0x87654321);
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function Chi(a: number, b: number, c: number): number;
|
|
22
|
+
/**
|
|
23
|
+
* Shared 32-bit majority primitive reused by SHA-256 and SHA-1.
|
|
24
|
+
* Returns bits shared by at least two inputs.
|
|
25
|
+
* @param a - first input word
|
|
26
|
+
* @param b - second input word
|
|
27
|
+
* @param c - third input word
|
|
28
|
+
* @returns Mixed 32-bit word.
|
|
29
|
+
* @example
|
|
30
|
+
* Combine three words with the shared 32-bit majority primitive.
|
|
31
|
+
* ```ts
|
|
32
|
+
* Maj(0xffffffff, 0x12345678, 0x87654321);
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function Maj(a: number, b: number, c: number): number;
|
|
36
|
+
/**
|
|
37
|
+
* Merkle-Damgard hash construction base class.
|
|
38
|
+
* Could be used to create MD5, RIPEMD, SHA1, SHA2.
|
|
39
|
+
* Accepts only byte-aligned `Uint8Array` input, even when the underlying spec describes bit
|
|
40
|
+
* strings with partial-byte tails.
|
|
41
|
+
* @param blockLen - internal block size in bytes
|
|
42
|
+
* @param outputLen - digest size in bytes
|
|
43
|
+
* @param padOffset - trailing length field size in bytes
|
|
44
|
+
* @param isLE - whether length and state words are encoded in little-endian
|
|
45
|
+
* @example
|
|
46
|
+
* Use a concrete subclass to get the shared Merkle-Damgard update/digest flow.
|
|
47
|
+
* ```ts
|
|
48
|
+
* import { _SHA1 } from '@noble/hashes/legacy.js';
|
|
49
|
+
* const hash = new _SHA1();
|
|
50
|
+
* hash.update(new Uint8Array([97, 98, 99]));
|
|
51
|
+
* hash.digest();
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare abstract class HashMD<T extends HashMD<T>> implements Hash<T> {
|
|
55
|
+
protected abstract process(buf: DataView, offset: number): void;
|
|
56
|
+
protected abstract get(): number[];
|
|
57
|
+
protected abstract set(...args: number[]): void;
|
|
58
|
+
abstract destroy(): void;
|
|
59
|
+
protected abstract roundClean(): void;
|
|
60
|
+
readonly blockLen: number;
|
|
61
|
+
readonly outputLen: number;
|
|
62
|
+
readonly canXOF = false;
|
|
63
|
+
readonly padOffset: number;
|
|
64
|
+
readonly isLE: boolean;
|
|
65
|
+
protected buffer: Uint8Array;
|
|
66
|
+
protected view: DataView;
|
|
67
|
+
protected finished: boolean;
|
|
68
|
+
protected length: number;
|
|
69
|
+
protected pos: number;
|
|
70
|
+
protected destroyed: boolean;
|
|
71
|
+
constructor(blockLen: number, outputLen: number, padOffset: number, isLE: boolean);
|
|
72
|
+
update(data: TArg<Uint8Array>): this;
|
|
73
|
+
digestInto(out: TArg<Uint8Array>): void;
|
|
74
|
+
digest(): TRet<Uint8Array>;
|
|
75
|
+
_cloneInto(to?: T): T;
|
|
76
|
+
clone(): T;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53.
|
|
80
|
+
* Check out `test/misc/sha2-gen-iv.js` for recomputation guide.
|
|
81
|
+
*/
|
|
82
|
+
/** Initial SHA256 state from RFC 6234 §6.1: the first 32 bits of the fractional parts of the
|
|
83
|
+
* square roots of the first eight prime numbers. Exported as a shared table; callers must treat
|
|
84
|
+
* it as read-only because constructors copy words from it by index. */
|
|
85
|
+
export declare const SHA256_IV: TRet<Uint32Array>;
|
|
86
|
+
/** Initial SHA224 state `H(0)` from RFC 6234 §6.1. Exported as a shared table; callers must
|
|
87
|
+
* treat it as read-only because constructors copy words from it by index. */
|
|
88
|
+
export declare const SHA224_IV: TRet<Uint32Array>;
|
|
89
|
+
/** Initial SHA384 state from RFC 6234 §6.3: eight RFC 64-bit `H(0)` words stored as sixteen
|
|
90
|
+
* big-endian 32-bit halves. Derived from the fractional parts of the square roots of the ninth
|
|
91
|
+
* through sixteenth prime numbers. Exported as a shared table; callers must treat it as read-only
|
|
92
|
+
* because constructors copy halves from it by index. */
|
|
93
|
+
export declare const SHA384_IV: TRet<Uint32Array>;
|
|
94
|
+
/** Initial SHA512 state from RFC 6234 §6.3: eight RFC 64-bit `H(0)` words stored as sixteen
|
|
95
|
+
* big-endian 32-bit halves. Derived from the fractional parts of the square roots of the first
|
|
96
|
+
* eight prime numbers. Exported as a shared table; callers must treat it as read-only because
|
|
97
|
+
* constructors copy halves from it by index. */
|
|
98
|
+
export declare const SHA512_IV: TRet<Uint32Array>;
|
|
99
|
+
//# sourceMappingURL=_md.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_md.d.ts","sourceRoot":"","sources":["src/_md.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAML,KAAK,IAAI,EACT,KAAK,IAAI,EACT,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,8BAAsB,MAAM,CAAC,CAAC,SAAS,MAAM,CAAC,CAAC,CAAC,CAAE,YAAW,IAAI,CAAC,CAAC,CAAC;IAGlE,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAC/D,SAAS,CAAC,QAAQ,CAAC,GAAG,IAAI,MAAM,EAAE;IAClC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI;IAC/C,QAAQ,CAAC,OAAO,IAAI,IAAI;IACxB,SAAS,CAAC,QAAQ,CAAC,UAAU,IAAI,IAAI;IAErC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ytes, aexists, aoutput, clean, createView, } from "./utils.js";
|
|
6
|
+
/**
|
|
7
|
+
* Shared 32-bit conditional boolean primitive reused by SHA-256, SHA-1, and MD5 `F`.
|
|
8
|
+
* Returns bits from `b` when `a` is set, otherwise from `c`.
|
|
9
|
+
* The XOR form is equivalent to MD5's `F(X,Y,Z) = XY v not(X)Z` because the masked terms never
|
|
10
|
+
* set the same bit.
|
|
11
|
+
* @param a - selector word
|
|
12
|
+
* @param b - word chosen when selector bit is set
|
|
13
|
+
* @param c - word chosen when selector bit is clear
|
|
14
|
+
* @returns Mixed 32-bit word.
|
|
15
|
+
* @example
|
|
16
|
+
* Combine three words with the shared 32-bit choice primitive.
|
|
17
|
+
* ```ts
|
|
18
|
+
* Chi(0xffffffff, 0x12345678, 0x87654321);
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export function Chi(a, b, c) {
|
|
22
|
+
return (a & b) ^ (~a & c);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Shared 32-bit majority primitive reused by SHA-256 and SHA-1.
|
|
26
|
+
* Returns bits shared by at least two inputs.
|
|
27
|
+
* @param a - first input word
|
|
28
|
+
* @param b - second input word
|
|
29
|
+
* @param c - third input word
|
|
30
|
+
* @returns Mixed 32-bit word.
|
|
31
|
+
* @example
|
|
32
|
+
* Combine three words with the shared 32-bit majority primitive.
|
|
33
|
+
* ```ts
|
|
34
|
+
* Maj(0xffffffff, 0x12345678, 0x87654321);
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export function Maj(a, b, c) {
|
|
38
|
+
return (a & b) ^ (a & c) ^ (b & c);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Merkle-Damgard hash construction base class.
|
|
42
|
+
* Could be used to create MD5, RIPEMD, SHA1, SHA2.
|
|
43
|
+
* Accepts only byte-aligned `Uint8Array` input, even when the underlying spec describes bit
|
|
44
|
+
* strings with partial-byte tails.
|
|
45
|
+
* @param blockLen - internal block size in bytes
|
|
46
|
+
* @param outputLen - digest size in bytes
|
|
47
|
+
* @param padOffset - trailing length field size in bytes
|
|
48
|
+
* @param isLE - whether length and state words are encoded in little-endian
|
|
49
|
+
* @example
|
|
50
|
+
* Use a concrete subclass to get the shared Merkle-Damgard update/digest flow.
|
|
51
|
+
* ```ts
|
|
52
|
+
* import { _SHA1 } from '@noble/hashes/legacy.js';
|
|
53
|
+
* const hash = new _SHA1();
|
|
54
|
+
* hash.update(new Uint8Array([97, 98, 99]));
|
|
55
|
+
* hash.digest();
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export class HashMD {
|
|
59
|
+
blockLen;
|
|
60
|
+
outputLen;
|
|
61
|
+
canXOF = false;
|
|
62
|
+
padOffset;
|
|
63
|
+
isLE;
|
|
64
|
+
// For partial updates less than block size
|
|
65
|
+
buffer;
|
|
66
|
+
view;
|
|
67
|
+
finished = false;
|
|
68
|
+
length = 0;
|
|
69
|
+
pos = 0;
|
|
70
|
+
destroyed = false;
|
|
71
|
+
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
72
|
+
this.blockLen = blockLen;
|
|
73
|
+
this.outputLen = outputLen;
|
|
74
|
+
this.padOffset = padOffset;
|
|
75
|
+
this.isLE = isLE;
|
|
76
|
+
this.buffer = new Uint8Array(blockLen);
|
|
77
|
+
this.view = createView(this.buffer);
|
|
78
|
+
}
|
|
79
|
+
update(data) {
|
|
80
|
+
aexists(this);
|
|
81
|
+
abytes(data);
|
|
82
|
+
const { view, buffer, blockLen } = this;
|
|
83
|
+
const len = data.length;
|
|
84
|
+
for (let pos = 0; pos < len;) {
|
|
85
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
86
|
+
// Fast path only when there is no buffered partial block: `take === blockLen` implies
|
|
87
|
+
// `this.pos === 0`, so we can process full blocks directly from the input view.
|
|
88
|
+
if (take === blockLen) {
|
|
89
|
+
const dataView = createView(data);
|
|
90
|
+
for (; blockLen <= len - pos; pos += blockLen)
|
|
91
|
+
this.process(dataView, pos);
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
95
|
+
this.pos += take;
|
|
96
|
+
pos += take;
|
|
97
|
+
if (this.pos === blockLen) {
|
|
98
|
+
this.process(view, 0);
|
|
99
|
+
this.pos = 0;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
this.length += data.length;
|
|
103
|
+
this.roundClean();
|
|
104
|
+
return this;
|
|
105
|
+
}
|
|
106
|
+
digestInto(out) {
|
|
107
|
+
aexists(this);
|
|
108
|
+
aoutput(out, this);
|
|
109
|
+
this.finished = true;
|
|
110
|
+
// Padding
|
|
111
|
+
// We can avoid allocation of buffer for padding completely if it
|
|
112
|
+
// was previously not allocated here. But it won't change performance.
|
|
113
|
+
const { buffer, view, blockLen, isLE } = this;
|
|
114
|
+
let { pos } = this;
|
|
115
|
+
// append the bit '1' to the message
|
|
116
|
+
buffer[pos++] = 0b10000000;
|
|
117
|
+
clean(this.buffer.subarray(pos));
|
|
118
|
+
// we have less than padOffset left in buffer, so we cannot put length in
|
|
119
|
+
// current block, need process it and pad again
|
|
120
|
+
if (this.padOffset > blockLen - pos) {
|
|
121
|
+
this.process(view, 0);
|
|
122
|
+
pos = 0;
|
|
123
|
+
}
|
|
124
|
+
// Pad until full block byte with zeros
|
|
125
|
+
for (let i = pos; i < blockLen; i++)
|
|
126
|
+
buffer[i] = 0;
|
|
127
|
+
// `padOffset` reserves the whole length field. For SHA-384/512 the high 64 bits stay zero from
|
|
128
|
+
// the padding fill above, and JS will overflow before user input can make that half non-zero.
|
|
129
|
+
// So we only need to write the low 64 bits here.
|
|
130
|
+
view.setBigUint64(blockLen - 8, BigInt(this.length * 8), isLE);
|
|
131
|
+
this.process(view, 0);
|
|
132
|
+
const oview = createView(out);
|
|
133
|
+
const len = this.outputLen;
|
|
134
|
+
// NOTE: we do division by 4 later, which must be fused in single op with modulo by JIT
|
|
135
|
+
if (len % 4)
|
|
136
|
+
throw new Error('_sha2: outputLen must be aligned to 32bit');
|
|
137
|
+
const outLen = len / 4;
|
|
138
|
+
const state = this.get();
|
|
139
|
+
if (outLen > state.length)
|
|
140
|
+
throw new Error('_sha2: outputLen bigger than state');
|
|
141
|
+
for (let i = 0; i < outLen; i++)
|
|
142
|
+
oview.setUint32(4 * i, state[i], isLE);
|
|
143
|
+
}
|
|
144
|
+
digest() {
|
|
145
|
+
const { buffer, outputLen } = this;
|
|
146
|
+
this.digestInto(buffer);
|
|
147
|
+
// Copy before destroy(): subclasses wipe `buffer` during cleanup, but `digest()` must return
|
|
148
|
+
// fresh bytes to the caller.
|
|
149
|
+
const res = buffer.slice(0, outputLen);
|
|
150
|
+
this.destroy();
|
|
151
|
+
return res;
|
|
152
|
+
}
|
|
153
|
+
_cloneInto(to) {
|
|
154
|
+
to ||= new this.constructor();
|
|
155
|
+
to.set(...this.get());
|
|
156
|
+
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
157
|
+
to.destroyed = destroyed;
|
|
158
|
+
to.finished = finished;
|
|
159
|
+
to.length = length;
|
|
160
|
+
to.pos = pos;
|
|
161
|
+
// Only partial-block bytes need copying: when `length % blockLen === 0`, `pos === 0` and
|
|
162
|
+
// later `update()` / `digestInto()` overwrite `to.buffer` from the start before reading it.
|
|
163
|
+
if (length % blockLen)
|
|
164
|
+
to.buffer.set(buffer);
|
|
165
|
+
return to;
|
|
166
|
+
}
|
|
167
|
+
clone() {
|
|
168
|
+
return this._cloneInto();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53.
|
|
173
|
+
* Check out `test/misc/sha2-gen-iv.js` for recomputation guide.
|
|
174
|
+
*/
|
|
175
|
+
/** Initial SHA256 state from RFC 6234 §6.1: the first 32 bits of the fractional parts of the
|
|
176
|
+
* square roots of the first eight prime numbers. Exported as a shared table; callers must treat
|
|
177
|
+
* it as read-only because constructors copy words from it by index. */
|
|
178
|
+
export const SHA256_IV = /* @__PURE__ */ Uint32Array.from([
|
|
179
|
+
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,
|
|
180
|
+
]);
|
|
181
|
+
/** Initial SHA224 state `H(0)` from RFC 6234 §6.1. Exported as a shared table; callers must
|
|
182
|
+
* treat it as read-only because constructors copy words from it by index. */
|
|
183
|
+
export const SHA224_IV = /* @__PURE__ */ Uint32Array.from([
|
|
184
|
+
0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4,
|
|
185
|
+
]);
|
|
186
|
+
/** Initial SHA384 state from RFC 6234 §6.3: eight RFC 64-bit `H(0)` words stored as sixteen
|
|
187
|
+
* big-endian 32-bit halves. Derived from the fractional parts of the square roots of the ninth
|
|
188
|
+
* through sixteenth prime numbers. Exported as a shared table; callers must treat it as read-only
|
|
189
|
+
* because constructors copy halves from it by index. */
|
|
190
|
+
export const SHA384_IV = /* @__PURE__ */ Uint32Array.from([
|
|
191
|
+
0xcbbb9d5d, 0xc1059ed8, 0x629a292a, 0x367cd507, 0x9159015a, 0x3070dd17, 0x152fecd8, 0xf70e5939,
|
|
192
|
+
0x67332667, 0xffc00b31, 0x8eb44a87, 0x68581511, 0xdb0c2e0d, 0x64f98fa7, 0x47b5481d, 0xbefa4fa4,
|
|
193
|
+
]);
|
|
194
|
+
/** Initial SHA512 state from RFC 6234 §6.3: eight RFC 64-bit `H(0)` words stored as sixteen
|
|
195
|
+
* big-endian 32-bit halves. Derived from the fractional parts of the square roots of the first
|
|
196
|
+
* eight prime numbers. Exported as a shared table; callers must treat it as read-only because
|
|
197
|
+
* constructors copy halves from it by index. */
|
|
198
|
+
export const SHA512_IV = /* @__PURE__ */ Uint32Array.from([
|
|
199
|
+
0x6a09e667, 0xf3bcc908, 0xbb67ae85, 0x84caa73b, 0x3c6ef372, 0xfe94f82b, 0xa54ff53a, 0x5f1d36f1,
|
|
200
|
+
0x510e527f, 0xade682d1, 0x9b05688c, 0x2b3e6c1f, 0x1f83d9ab, 0xfb41bd6b, 0x5be0cd19, 0x137e2179,
|
|
201
|
+
]);
|
|
202
|
+
//# sourceMappingURL=_md.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_md.js","sourceRoot":"","sources":["src/_md.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,MAAM,EACN,OAAO,EACP,OAAO,EACP,KAAK,EACL,UAAU,GAIX,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS;IACjD,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAC5B,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS;IACjD,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AACrC,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAgB,MAAM;IASjB,QAAQ,CAAS;IACjB,SAAS,CAAS;IAClB,MAAM,GAAG,KAAK,CAAC;IACf,SAAS,CAAS;IAClB,IAAI,CAAU;IAEvB,2CAA2C;IACjC,MAAM,CAAa;IACnB,IAAI,CAAW;IACf,QAAQ,GAAG,KAAK,CAAC;IACjB,MAAM,GAAG,CAAC,CAAC;IACX,GAAG,GAAG,CAAC,CAAC;IACR,SAAS,GAAG,KAAK,CAAC;IAE5B,YAAY,QAAgB,EAAE,SAAiB,EAAE,SAAiB,EAAE,IAAa;QAC/E,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAC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UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU;IAC9F,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU;CAC/F,CAAC,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal helpers for u64.
|
|
3
|
+
* BigUint64Array is too slow as per 2026, so we implement it using
|
|
4
|
+
* Uint32Array.
|
|
5
|
+
* @privateRemarks TODO: re-check {@link https://issues.chromium.org/issues/42212588}
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import type { TRet } from './utils.ts';
|
|
9
|
+
declare function fromBig(n: bigint, le?: boolean): {
|
|
10
|
+
h: number;
|
|
11
|
+
l: number;
|
|
12
|
+
};
|
|
13
|
+
declare function split(lst: bigint[], le?: boolean): TRet<Uint32Array[]>;
|
|
14
|
+
declare const toBig: (h: number, l: number) => bigint;
|
|
15
|
+
declare const shrSH: (h: number, _l: number, s: number) => number;
|
|
16
|
+
declare const shrSL: (h: number, l: number, s: number) => number;
|
|
17
|
+
declare const rotrSH: (h: number, l: number, s: number) => number;
|
|
18
|
+
declare const rotrSL: (h: number, l: number, s: number) => number;
|
|
19
|
+
declare const rotrBH: (h: number, l: number, s: number) => number;
|
|
20
|
+
declare const rotrBL: (h: number, l: number, s: number) => number;
|
|
21
|
+
declare const rotr32H: (_h: number, l: number) => number;
|
|
22
|
+
declare const rotr32L: (h: number, _l: number) => number;
|
|
23
|
+
declare const rotlSH: (h: number, l: number, s: number) => number;
|
|
24
|
+
declare const rotlSL: (h: number, l: number, s: number) => number;
|
|
25
|
+
declare const rotlBH: (h: number, l: number, s: number) => number;
|
|
26
|
+
declare const rotlBL: (h: number, l: number, s: number) => number;
|
|
27
|
+
declare function add(Ah: number, Al: number, Bh: number, Bl: number): {
|
|
28
|
+
h: number;
|
|
29
|
+
l: number;
|
|
30
|
+
};
|
|
31
|
+
declare const add3L: (Al: number, Bl: number, Cl: number) => number;
|
|
32
|
+
declare const add3H: (low: number, Ah: number, Bh: number, Ch: number) => number;
|
|
33
|
+
declare const add4L: (Al: number, Bl: number, Cl: number, Dl: number) => number;
|
|
34
|
+
declare const add4H: (low: number, Ah: number, Bh: number, Ch: number, Dh: number) => number;
|
|
35
|
+
declare const add5L: (Al: number, Bl: number, Cl: number, Dl: number, El: number) => number;
|
|
36
|
+
declare const add5H: (low: number, Ah: number, Bh: number, Ch: number, Dh: number, Eh: number) => number;
|
|
37
|
+
export { add, add3H, add3L, add4H, add4L, add5H, add5L, fromBig, rotlBH, rotlBL, rotlSH, rotlSL, rotr32H, rotr32L, rotrBH, rotrBL, rotrSH, rotrSL, shrSH, shrSL, split, toBig };
|
|
38
|
+
declare const u64: {
|
|
39
|
+
fromBig: typeof fromBig;
|
|
40
|
+
split: typeof split;
|
|
41
|
+
toBig: (h: number, l: number) => bigint;
|
|
42
|
+
shrSH: (h: number, _l: number, s: number) => number;
|
|
43
|
+
shrSL: (h: number, l: number, s: number) => number;
|
|
44
|
+
rotrSH: (h: number, l: number, s: number) => number;
|
|
45
|
+
rotrSL: (h: number, l: number, s: number) => number;
|
|
46
|
+
rotrBH: (h: number, l: number, s: number) => number;
|
|
47
|
+
rotrBL: (h: number, l: number, s: number) => number;
|
|
48
|
+
rotr32H: (_h: number, l: number) => number;
|
|
49
|
+
rotr32L: (h: number, _l: number) => number;
|
|
50
|
+
rotlSH: (h: number, l: number, s: number) => number;
|
|
51
|
+
rotlSL: (h: number, l: number, s: number) => number;
|
|
52
|
+
rotlBH: (h: number, l: number, s: number) => number;
|
|
53
|
+
rotlBL: (h: number, l: number, s: number) => number;
|
|
54
|
+
add: typeof add;
|
|
55
|
+
add3L: (Al: number, Bl: number, Cl: number) => number;
|
|
56
|
+
add3H: (low: number, Ah: number, Bh: number, Ch: number) => number;
|
|
57
|
+
add4L: (Al: number, Bl: number, Cl: number, Dl: number) => number;
|
|
58
|
+
add4H: (low: number, Ah: number, Bh: number, Ch: number, Dh: number) => number;
|
|
59
|
+
add5H: (low: number, Ah: number, Bh: number, Ch: number, Dh: number, Eh: number) => number;
|
|
60
|
+
add5L: (Al: number, Bl: number, Cl: number, Dl: number, El: number) => number;
|
|
61
|
+
};
|
|
62
|
+
export default u64;
|
|
63
|
+
//# sourceMappingURL=_u64.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_u64.d.ts","sourceRoot":"","sources":["src/_u64.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAOvC,iBAAS,OAAO,CACd,CAAC,EAAE,MAAM,EACT,EAAE,UAAQ,GACT;IACD,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAGA;AAID,iBAAS,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,UAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,CAS7D;AAID,QAAA,MAAM,KAAK,GAAI,GAAG,MAAM,EAAE,GAAG,MAAM,KAAG,MAAqD,CAAC;AAE5F,QAAA,MAAM,KAAK,GAAI,GAAG,MAAM,EAAE,IAAI,MAAM,EAAE,GAAG,MAAM,KAAG,MAAiB,CAAC;AAEpE,QAAA,MAAM,KAAK,GAAI,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,KAAG,MAAqC,CAAC;AAEvF,QAAA,MAAM,MAAM,GAAI,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,KAAG,MAAqC,CAAC;AAExF,QAAA,MAAM,MAAM,GAAI,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,KAAG,MAAqC,CAAC;AAExF,QAAA,MAAM,MAAM,GAAI,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,KAAG,MAA4C,CAAC;AAE/F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MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC;CAOrpC,CAAC;AAEF,eAAe,GAAG,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
2
|
+
const _32n = /* @__PURE__ */ BigInt(32);
|
|
3
|
+
// Split bigint into two 32-bit halves. With `le=true`, returned fields become `{ h: low, l: high
|
|
4
|
+
// }` to match little-endian word order rather than the property names.
|
|
5
|
+
function fromBig(n, le = false) {
|
|
6
|
+
if (le)
|
|
7
|
+
return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };
|
|
8
|
+
return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
|
|
9
|
+
}
|
|
10
|
+
// Split bigint list into `[highWords, lowWords]` when `le=false`; with `le=true`, the first array
|
|
11
|
+
// holds the low halves because `fromBig(...)` swaps the semantic meaning of `h` and `l`.
|
|
12
|
+
function split(lst, le = false) {
|
|
13
|
+
const len = lst.length;
|
|
14
|
+
let Ah = new Uint32Array(len);
|
|
15
|
+
let Al = new Uint32Array(len);
|
|
16
|
+
for (let i = 0; i < len; i++) {
|
|
17
|
+
const { h, l } = fromBig(lst[i], le);
|
|
18
|
+
[Ah[i], Al[i]] = [h, l];
|
|
19
|
+
}
|
|
20
|
+
return [Ah, Al];
|
|
21
|
+
}
|
|
22
|
+
// Combine explicit `(high, low)` 32-bit halves into a bigint; `>>> 0` normalizes signed JS
|
|
23
|
+
// bitwise results back to uint32 first, and little-endian callers must swap.
|
|
24
|
+
const toBig = (h, l) => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0);
|
|
25
|
+
// High 32-bit half of a 64-bit logical right shift for `s` in `0..31`.
|
|
26
|
+
const shrSH = (h, _l, s) => h >>> s;
|
|
27
|
+
// Low 32-bit half of a 64-bit logical right shift, valid for `s` in `1..31`.
|
|
28
|
+
const shrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
|
|
29
|
+
// High 32-bit half of a 64-bit right rotate, valid for `s` in `1..31`.
|
|
30
|
+
const rotrSH = (h, l, s) => (h >>> s) | (l << (32 - s));
|
|
31
|
+
// Low 32-bit half of a 64-bit right rotate, valid for `s` in `1..31`.
|
|
32
|
+
const rotrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
|
|
33
|
+
// High 32-bit half of a 64-bit right rotate, valid for `s` in `33..63`; `32` uses `rotr32*`.
|
|
34
|
+
const rotrBH = (h, l, s) => (h << (64 - s)) | (l >>> (s - 32));
|
|
35
|
+
// Low 32-bit half of a 64-bit right rotate, valid for `s` in `33..63`; `32` uses `rotr32*`.
|
|
36
|
+
const rotrBL = (h, l, s) => (h >>> (s - 32)) | (l << (64 - s));
|
|
37
|
+
// High 32-bit half of a 64-bit right rotate for `s === 32`; this is just the swapped low half.
|
|
38
|
+
const rotr32H = (_h, l) => l;
|
|
39
|
+
// Low 32-bit half of a 64-bit right rotate for `s === 32`; this is just the swapped high half.
|
|
40
|
+
const rotr32L = (h, _l) => h;
|
|
41
|
+
// High 32-bit half of a 64-bit left rotate, valid for `s` in `1..31`.
|
|
42
|
+
const rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s));
|
|
43
|
+
// Low 32-bit half of a 64-bit left rotate, valid for `s` in `1..31`.
|
|
44
|
+
const rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s));
|
|
45
|
+
// High 32-bit half of a 64-bit left rotate, valid for `s` in `33..63`; `32` uses `rotr32*`.
|
|
46
|
+
const rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));
|
|
47
|
+
// Low 32-bit half of a 64-bit left rotate, valid for `s` in `33..63`; `32` uses `rotr32*`.
|
|
48
|
+
const rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
|
|
49
|
+
// Add two split 64-bit words and return the split `{ h, l }` sum.
|
|
50
|
+
// JS uses 32-bit signed integers for bitwise operations, so we cannot simply shift the carry out
|
|
51
|
+
// of the low sum and instead use division.
|
|
52
|
+
function add(Ah, Al, Bh, Bl) {
|
|
53
|
+
const l = (Al >>> 0) + (Bl >>> 0);
|
|
54
|
+
return { h: (Ah + Bh + ((l / 2 ** 32) | 0)) | 0, l: l | 0 };
|
|
55
|
+
}
|
|
56
|
+
// Addition with more than 2 elements
|
|
57
|
+
// Unmasked low-word accumulator for 3-way addition; pass the raw result into `add3H(...)`.
|
|
58
|
+
const add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
|
|
59
|
+
// High-word finalize step for 3-way addition; `low` must be the untruncated output of `add3L(...)`.
|
|
60
|
+
const add3H = (low, Ah, Bh, Ch) => (Ah + Bh + Ch + ((low / 2 ** 32) | 0)) | 0;
|
|
61
|
+
// Unmasked low-word accumulator for 4-way addition; pass the raw result into `add4H(...)`.
|
|
62
|
+
const add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
|
|
63
|
+
// High-word finalize step for 4-way addition; `low` must be the untruncated output of `add4L(...)`.
|
|
64
|
+
const add4H = (low, Ah, Bh, Ch, Dh) => (Ah + Bh + Ch + Dh + ((low / 2 ** 32) | 0)) | 0;
|
|
65
|
+
// Unmasked low-word accumulator for 5-way addition; pass the raw result into `add5H(...)`.
|
|
66
|
+
const add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
|
|
67
|
+
// High-word finalize step for 5-way addition; `low` must be the untruncated output of `add5L(...)`.
|
|
68
|
+
const add5H = (low, Ah, Bh, Ch, Dh, Eh) => (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0;
|
|
69
|
+
// prettier-ignore
|
|
70
|
+
export { add, add3H, add3L, add4H, add4L, add5H, add5L, fromBig, rotlBH, rotlBL, rotlSH, rotlSL, rotr32H, rotr32L, rotrBH, rotrBL, rotrSH, rotrSL, shrSH, shrSL, split, toBig };
|
|
71
|
+
// Canonical grouped namespace for callers that prefer one object.
|
|
72
|
+
// Named exports stay for direct imports.
|
|
73
|
+
// prettier-ignore
|
|
74
|
+
const u64 = {
|
|
75
|
+
fromBig, split, toBig,
|
|
76
|
+
shrSH, shrSL,
|
|
77
|
+
rotrSH, rotrSL, rotrBH, rotrBL,
|
|
78
|
+
rotr32H, rotr32L,
|
|
79
|
+
rotlSH, rotlSL, rotlBH, rotlBL,
|
|
80
|
+
add, add3L, add3H, add4L, add4H, add5H, add5L,
|
|
81
|
+
};
|
|
82
|
+
// Default export mirrors named `u64` for compatibility with object-style imports.
|
|
83
|
+
export default u64;
|
|
84
|
+
//# sourceMappingURL=_u64.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_u64.js","sourceRoot":"","sources":["src/_u64.ts"],"names":[],"mappings":"AASA,MAAM,UAAU,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;AACvD,MAAM,IAAI,GAAG,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAExC,iGAAiG;AACjG,uEAAuE;AACvE,SAAS,OAAO,CACd,CAAS,EACT,EAAE,GA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AAG,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;AACjE,oGAAoG;AACpG,MAAM,KAAK,GAAG,CAAC,GAAW,EAAE,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,EAAU,EAAU,EAAE,CAChG,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAEvD,kBAAkB;AAClB,OAAO,EACL,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EACrK,CAAC;AACF,kEAAkE;AAClE,yCAAyC;AACzC,kBAAkB;AAClB,MAAM,GAAG,GAAkpC;IACzpC,OAAO,EAAE,KAAK,EAAE,KAAK;IACrB,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAC9B,OAAO,EAAE,OAAO;IAChB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAC9B,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK;CAC9C,CAAC;AACF,kFAAkF;AAClF,eAAe,GAAG,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { type KDFInput, type TArg, type TRet } from './utils.ts';
|
|
2
|
+
/** Argon2 cost, output, and optional secret/personalization inputs. */
|
|
3
|
+
export type ArgonOpts = {
|
|
4
|
+
/** Time cost measured in iterations. */
|
|
5
|
+
t: number;
|
|
6
|
+
/** Memory cost in kibibytes. */
|
|
7
|
+
m: number;
|
|
8
|
+
/** Parallelization parameter. */
|
|
9
|
+
p: number;
|
|
10
|
+
/** Argon2 version number. Defaults to `0x13`. */
|
|
11
|
+
version?: number;
|
|
12
|
+
/** Optional secret key mixed into initialization. */
|
|
13
|
+
key?: KDFInput;
|
|
14
|
+
/** Optional personalization string or bytes. */
|
|
15
|
+
personalization?: KDFInput;
|
|
16
|
+
/** Desired output length in bytes. RFC 9106 §3.1 requires `T` in the 4..(2^32 - 1) range. */
|
|
17
|
+
dkLen?: number;
|
|
18
|
+
/** Max scheduler block time in milliseconds for the async variants. */
|
|
19
|
+
asyncTick?: number;
|
|
20
|
+
/** Maximum temporary memory budget in bytes. */
|
|
21
|
+
maxmem?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Optional progress callback invoked during long-running derivations.
|
|
24
|
+
* param progress - completion fraction in the `0..1` range
|
|
25
|
+
*/
|
|
26
|
+
onProgress?: (progress: number) => void;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Argon2d GPU-resistant version.
|
|
30
|
+
* @param password - password or input key material
|
|
31
|
+
* @param salt - unique salt value
|
|
32
|
+
* @param opts - Argon2 cost and optional tuning parameters. See {@link ArgonOpts}.
|
|
33
|
+
* @returns Derived key bytes.
|
|
34
|
+
* @throws If the Argon2 input or cost parameters are invalid. {@link Error}
|
|
35
|
+
* @example
|
|
36
|
+
* Derive a key with Argon2d.
|
|
37
|
+
* ```ts
|
|
38
|
+
* argon2d('password', 'salt1234', { t: 1, m: 8, p: 1, dkLen: 32 });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare const argon2d: (password: TArg<KDFInput>, salt: TArg<KDFInput>, opts: TArg<ArgonOpts>) => TRet<Uint8Array>;
|
|
42
|
+
/**
|
|
43
|
+
* Argon2i side-channel-resistant version.
|
|
44
|
+
* @param password - password or input key material
|
|
45
|
+
* @param salt - unique salt value
|
|
46
|
+
* @param opts - Argon2 cost and optional tuning parameters. See {@link ArgonOpts}.
|
|
47
|
+
* @returns Derived key bytes.
|
|
48
|
+
* @throws If the Argon2 input or cost parameters are invalid. {@link Error}
|
|
49
|
+
* @example
|
|
50
|
+
* Derive a key with Argon2i.
|
|
51
|
+
* ```ts
|
|
52
|
+
* argon2i('password', 'salt1234', { t: 1, m: 8, p: 1, dkLen: 32 });
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare const argon2i: (password: TArg<KDFInput>, salt: TArg<KDFInput>, opts: TArg<ArgonOpts>) => TRet<Uint8Array>;
|
|
56
|
+
/**
|
|
57
|
+
* Argon2id, combining i+d, the most popular version from RFC 9106.
|
|
58
|
+
* @param password - password or input key material
|
|
59
|
+
* @param salt - unique salt value
|
|
60
|
+
* @param opts - Argon2 cost and optional tuning parameters. See {@link ArgonOpts}.
|
|
61
|
+
* @returns Derived key bytes.
|
|
62
|
+
* @throws If the Argon2 input or cost parameters are invalid. {@link Error}
|
|
63
|
+
* @example
|
|
64
|
+
* Derive a key with Argon2id.
|
|
65
|
+
* ```ts
|
|
66
|
+
* argon2id('password', 'salt1234', { t: 1, m: 8, p: 1, dkLen: 32 });
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare const argon2id: (password: TArg<KDFInput>, salt: TArg<KDFInput>, opts: TArg<ArgonOpts>) => TRet<Uint8Array>;
|
|
70
|
+
/**
|
|
71
|
+
* Argon2d async GPU-resistant version.
|
|
72
|
+
* @param password - password or input key material
|
|
73
|
+
* @param salt - unique salt value
|
|
74
|
+
* @param opts - Argon2 cost and optional tuning parameters. See {@link ArgonOpts}.
|
|
75
|
+
* @returns Promise resolving to derived key bytes.
|
|
76
|
+
* @throws If the Argon2 input or cost parameters are invalid. {@link Error}
|
|
77
|
+
* @example
|
|
78
|
+
* Derive a key with Argon2d asynchronously.
|
|
79
|
+
* ```ts
|
|
80
|
+
* await argon2dAsync('password', 'salt1234', { t: 1, m: 8, p: 1, dkLen: 32 });
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export declare const argon2dAsync: (password: TArg<KDFInput>, salt: TArg<KDFInput>, opts: TArg<ArgonOpts>) => Promise<TRet<Uint8Array>>;
|
|
84
|
+
/**
|
|
85
|
+
* Argon2i async side-channel-resistant version.
|
|
86
|
+
* @param password - password or input key material
|
|
87
|
+
* @param salt - unique salt value
|
|
88
|
+
* @param opts - Argon2 cost and optional tuning parameters. See {@link ArgonOpts}.
|
|
89
|
+
* @returns Promise resolving to derived key bytes.
|
|
90
|
+
* @throws If the Argon2 input or cost parameters are invalid. {@link Error}
|
|
91
|
+
* @example
|
|
92
|
+
* Derive a key with Argon2i asynchronously.
|
|
93
|
+
* ```ts
|
|
94
|
+
* await argon2iAsync('password', 'salt1234', { t: 1, m: 8, p: 1, dkLen: 32 });
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export declare const argon2iAsync: (password: TArg<KDFInput>, salt: TArg<KDFInput>, opts: TArg<ArgonOpts>) => Promise<TRet<Uint8Array>>;
|
|
98
|
+
/**
|
|
99
|
+
* Argon2id async, combining i+d, the most popular version from RFC 9106.
|
|
100
|
+
* @param password - password or input key material
|
|
101
|
+
* @param salt - unique salt value
|
|
102
|
+
* @param opts - Argon2 cost and optional tuning parameters. See {@link ArgonOpts}.
|
|
103
|
+
* @returns Promise resolving to derived key bytes.
|
|
104
|
+
* @throws If the Argon2 input or cost parameters are invalid. {@link Error}
|
|
105
|
+
* @example
|
|
106
|
+
* Derive a key with Argon2id asynchronously.
|
|
107
|
+
* ```ts
|
|
108
|
+
* await argon2idAsync('password', 'salt1234', { t: 1, m: 8, p: 1, dkLen: 32 });
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
export declare const argon2idAsync: (password: TArg<KDFInput>, salt: TArg<KDFInput>, opts: TArg<ArgonOpts>) => Promise<TRet<Uint8Array>>;
|
|
112
|
+
//# sourceMappingURL=argon2.d.ts.map
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