diff --git a/node_modules/@nestjs/testing/services/testing-logger.service.js b/node_modules/@nestjs/testing/services/testing-logger.service.js new file mode 100644 index 0000000000000000000000000000000000000000..18e48759772d18e15c81feae9a13a332a14abd40 --- /dev/null +++ b/node_modules/@nestjs/testing/services/testing-logger.service.js @@ -0,0 +1,20 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.TestingLogger = void 0; +const common_1 = require("@nestjs/common"); +/** + * @publicApi + */ +class TestingLogger extends common_1.ConsoleLogger { + constructor() { + super('Testing'); + } + log(message) { } + warn(message) { } + debug(message) { } + verbose(message) { } + error(message, ...optionalParams) { + return super.error(message, ...optionalParams); + } +} +exports.TestingLogger = TestingLogger; diff --git a/node_modules/@nestjs/testing/test.d.ts b/node_modules/@nestjs/testing/test.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f5ab05178f320ecc4f4ca77ab7acad10879d7c1a --- /dev/null +++ b/node_modules/@nestjs/testing/test.d.ts @@ -0,0 +1,6 @@ +import { ModuleMetadata } from '@nestjs/common/interfaces/modules/module-metadata.interface'; +import { TestingModuleBuilder, TestingModuleOptions } from './testing-module.builder'; +export declare class Test { + private static readonly metadataScanner; + static createTestingModule(metadata: ModuleMetadata, options?: TestingModuleOptions): TestingModuleBuilder; +} diff --git a/node_modules/@nestjs/testing/test.js b/node_modules/@nestjs/testing/test.js new file mode 100644 index 0000000000000000000000000000000000000000..12e920e4ee294c2a97b5b9344b95f568b9a0df8e --- /dev/null +++ b/node_modules/@nestjs/testing/test.js @@ -0,0 +1,12 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Test = void 0; +const metadata_scanner_1 = require("@nestjs/core/metadata-scanner"); +const testing_module_builder_1 = require("./testing-module.builder"); +class Test { + static createTestingModule(metadata, options) { + return new testing_module_builder_1.TestingModuleBuilder(this.metadataScanner, metadata, options); + } +} +exports.Test = Test; +Test.metadataScanner = new metadata_scanner_1.MetadataScanner(); diff --git a/node_modules/@nestjs/testing/testing-injector.d.ts b/node_modules/@nestjs/testing/testing-injector.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b27ebcc8f340eb43d9cc5099bd2b59a2081bac58 --- /dev/null +++ b/node_modules/@nestjs/testing/testing-injector.d.ts @@ -0,0 +1,23 @@ +import { NestContainer } from '@nestjs/core'; +import { Injector, InjectorDependencyContext } from '@nestjs/core/injector/injector'; +import { ContextId, InstanceWrapper } from '@nestjs/core/injector/instance-wrapper'; +import { Module } from '@nestjs/core/injector/module'; +import { MockFactory } from './interfaces'; +interface ResolutionContext { + contextId: ContextId; + inquirer?: InstanceWrapper; + effectiveInquirerId?: string; +} +/** + * @publicApi + */ +export declare class TestingInjector extends Injector { + protected mocker?: MockFactory; + protected container: NestContainer; + setMocker(mocker: MockFactory): void; + setContainer(container: NestContainer): void; + resolveComponentWrapper(moduleRef: Module, name: any, dependencyContext: InjectorDependencyContext, wrapper: InstanceWrapper, resolutionContext?: ResolutionContext, keyOrIndex?: string | number): Promise; + resolveComponentHost(moduleRef: Module, instanceWrapper: InstanceWrapper, resolutionContext?: ResolutionContext): Promise; + private mockWrapper; +} +export {}; diff --git a/node_modules/@nestjs/testing/testing-injector.js b/node_modules/@nestjs/testing/testing-injector.js new file mode 100644 index 0000000000000000000000000000000000000000..687a9e4a37ba9f272038eed73357b72e08b74186 --- /dev/null +++ b/node_modules/@nestjs/testing/testing-injector.js @@ -0,0 +1,64 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.TestingInjector = void 0; +const constants_1 = require("@nestjs/core/injector/constants"); +const injector_1 = require("@nestjs/core/injector/injector"); +const instance_wrapper_1 = require("@nestjs/core/injector/instance-wrapper"); +/** + * @publicApi + */ +class TestingInjector extends injector_1.Injector { + setMocker(mocker) { + this.mocker = mocker; + } + setContainer(container) { + this.container = container; + } + async resolveComponentWrapper(moduleRef, name, dependencyContext, wrapper, resolutionContext = { contextId: constants_1.STATIC_CONTEXT }, keyOrIndex) { + try { + const existingProviderWrapper = await super.resolveComponentWrapper(moduleRef, name, dependencyContext, wrapper, resolutionContext, keyOrIndex); + return existingProviderWrapper; + } + catch (err) { + return this.mockWrapper(err, moduleRef, name, wrapper); + } + } + async resolveComponentHost(moduleRef, instanceWrapper, resolutionContext = { contextId: constants_1.STATIC_CONTEXT }) { + try { + const existingProviderWrapper = await super.resolveComponentHost(moduleRef, instanceWrapper, resolutionContext); + return existingProviderWrapper; + } + catch (err) { + return this.mockWrapper(err, moduleRef, instanceWrapper.name, instanceWrapper); + } + } + async mockWrapper(err, moduleRef, name, wrapper) { + if (!this.mocker) { + throw err; + } + const mockedInstance = this.mocker(name); + if (!mockedInstance) { + throw err; + } + const newWrapper = new instance_wrapper_1.InstanceWrapper({ + name, + isAlias: false, + scope: wrapper.scope, + instance: mockedInstance, + isResolved: true, + host: moduleRef, + metatype: wrapper.metatype, + }); + const internalCoreModule = this.container.getInternalCoreModuleRef(); + if (!internalCoreModule) { + throw new Error('Expected to have internal core module reference at this point.'); + } + internalCoreModule.addCustomProvider({ + provide: name, + useValue: mockedInstance, + }, internalCoreModule.providers); + internalCoreModule.addExportedProviderOrModule(name); + return newWrapper; + } +} +exports.TestingInjector = TestingInjector; diff --git a/node_modules/@nestjs/testing/testing-instance-loader.d.ts b/node_modules/@nestjs/testing/testing-instance-loader.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f4bd527e1c88fc630f4b0fdbae1cbaa84fc7b067 --- /dev/null +++ b/node_modules/@nestjs/testing/testing-instance-loader.d.ts @@ -0,0 +1,7 @@ +import { InstanceLoader } from '@nestjs/core/injector/instance-loader'; +import { Module } from '@nestjs/core/injector/module'; +import { MockFactory } from './interfaces'; +import { TestingInjector } from './testing-injector'; +export declare class TestingInstanceLoader extends InstanceLoader { + createInstancesOfDependencies(modules?: Map, mocker?: MockFactory): Promise; +} diff --git a/node_modules/@nestjs/testing/testing-instance-loader.js b/node_modules/@nestjs/testing/testing-instance-loader.js new file mode 100644 index 0000000000000000000000000000000000000000..98117c2208e590fd3f25a55c1c80e5221284618b --- /dev/null +++ b/node_modules/@nestjs/testing/testing-instance-loader.js @@ -0,0 +1,12 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.TestingInstanceLoader = void 0; +const instance_loader_1 = require("@nestjs/core/injector/instance-loader"); +class TestingInstanceLoader extends instance_loader_1.InstanceLoader { + async createInstancesOfDependencies(modules = this.container.getModules(), mocker) { + this.injector.setContainer(this.container); + mocker && this.injector.setMocker(mocker); + await super.createInstancesOfDependencies(); + } +} +exports.TestingInstanceLoader = TestingInstanceLoader; diff --git a/node_modules/@nestjs/testing/testing-module.builder.d.ts b/node_modules/@nestjs/testing/testing-module.builder.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b0d0a1589c5404696d55651834ff151c3d7c2d7b --- /dev/null +++ b/node_modules/@nestjs/testing/testing-module.builder.d.ts @@ -0,0 +1,42 @@ +import { LoggerService, ModuleMetadata } from '@nestjs/common'; +import { NestApplicationContextOptions } from '@nestjs/common/interfaces/nest-application-context-options.interface'; +import { ModuleDefinition } from '@nestjs/core/interfaces/module-definition.interface'; +import { MetadataScanner } from '@nestjs/core/metadata-scanner'; +import { MockFactory, OverrideBy } from './interfaces'; +import { OverrideModule } from './interfaces/override-module.interface'; +import { TestingModule } from './testing-module'; +/** + * @publicApi + */ +export type TestingModuleOptions = Pick; +/** + * @publicApi + */ +export declare class TestingModuleBuilder { + private readonly metadataScanner; + private readonly applicationConfig; + private readonly container; + private readonly overloadsMap; + private readonly moduleOverloadsMap; + private readonly module; + private testingLogger; + private mocker?; + constructor(metadataScanner: MetadataScanner, metadata: ModuleMetadata, options?: TestingModuleOptions); + setLogger(testingLogger: LoggerService): this; + overridePipe(typeOrToken: T): OverrideBy; + useMocker(mocker: MockFactory): TestingModuleBuilder; + overrideFilter(typeOrToken: T): OverrideBy; + overrideGuard(typeOrToken: T): OverrideBy; + overrideInterceptor(typeOrToken: T): OverrideBy; + overrideProvider(typeOrToken: T): OverrideBy; + overrideModule(moduleToOverride: ModuleDefinition): OverrideModule; + compile(options?: Pick): Promise; + private override; + private createOverrideByBuilder; + private applyOverloadsMap; + private getModuleOverloads; + private getRootModule; + private createInstancesOfDependencies; + private createModule; + private applyLogger; +} diff --git a/node_modules/@nestjs/testing/testing-module.builder.js b/node_modules/@nestjs/testing/testing-module.builder.js new file mode 100644 index 0000000000000000000000000000000000000000..2f2504632a2f0be6d74b0369de34b70e2d69656c --- /dev/null +++ b/node_modules/@nestjs/testing/testing-module.builder.js @@ -0,0 +1,131 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.TestingModuleBuilder = void 0; +const common_1 = require("@nestjs/common"); +const application_config_1 = require("@nestjs/core/application-config"); +const container_1 = require("@nestjs/core/injector/container"); +const graph_inspector_1 = require("@nestjs/core/inspector/graph-inspector"); +const noop_graph_inspector_1 = require("@nestjs/core/inspector/noop-graph-inspector"); +const uuid_factory_1 = require("@nestjs/core/inspector/uuid-factory"); +const scanner_1 = require("@nestjs/core/scanner"); +const testing_logger_service_1 = require("./services/testing-logger.service"); +const testing_injector_1 = require("./testing-injector"); +const testing_instance_loader_1 = require("./testing-instance-loader"); +const testing_module_1 = require("./testing-module"); +/** + * @publicApi + */ +class TestingModuleBuilder { + constructor(metadataScanner, metadata, options) { + this.metadataScanner = metadataScanner; + this.applicationConfig = new application_config_1.ApplicationConfig(); + this.overloadsMap = new Map(); + this.moduleOverloadsMap = new Map(); + this.container = new container_1.NestContainer(this.applicationConfig, options); + this.module = this.createModule(metadata); + } + setLogger(testingLogger) { + this.testingLogger = testingLogger; + return this; + } + overridePipe(typeOrToken) { + return this.override(typeOrToken, false); + } + useMocker(mocker) { + this.mocker = mocker; + return this; + } + overrideFilter(typeOrToken) { + return this.override(typeOrToken, false); + } + overrideGuard(typeOrToken) { + return this.override(typeOrToken, false); + } + overrideInterceptor(typeOrToken) { + return this.override(typeOrToken, false); + } + overrideProvider(typeOrToken) { + return this.override(typeOrToken, true); + } + overrideModule(moduleToOverride) { + return { + useModule: newModule => { + this.moduleOverloadsMap.set(moduleToOverride, newModule); + return this; + }, + }; + } + async compile(options = {}) { + this.applyLogger(); + let graphInspector; + if (options?.snapshot) { + graphInspector = new graph_inspector_1.GraphInspector(this.container); + uuid_factory_1.UuidFactory.mode = uuid_factory_1.UuidFactoryMode.Deterministic; + } + else { + graphInspector = noop_graph_inspector_1.NoopGraphInspector; + uuid_factory_1.UuidFactory.mode = uuid_factory_1.UuidFactoryMode.Random; + } + const scanner = new scanner_1.DependenciesScanner(this.container, this.metadataScanner, graphInspector, this.applicationConfig); + await scanner.scan(this.module, { + overrides: this.getModuleOverloads(), + }); + this.applyOverloadsMap(); + await this.createInstancesOfDependencies(graphInspector, options); + scanner.applyApplicationProviders(); + const root = this.getRootModule(); + return new testing_module_1.TestingModule(this.container, graphInspector, root, this.applicationConfig); + } + override(typeOrToken, isProvider) { + const addOverload = (options) => { + this.overloadsMap.set(typeOrToken, { + ...options, + isProvider, + }); + return this; + }; + return this.createOverrideByBuilder(addOverload); + } + createOverrideByBuilder(add) { + return { + useValue: value => add({ useValue: value }), + useFactory: (options) => add({ ...options, useFactory: options.factory }), + useClass: metatype => add({ useClass: metatype }), + }; + } + applyOverloadsMap() { + const overloads = [...this.overloadsMap.entries()]; + overloads.forEach(([item, options]) => { + this.container.replace(item, options); + }); + } + getModuleOverloads() { + const overloads = [...this.moduleOverloadsMap.entries()]; + return overloads.map(([moduleToReplace, newModule]) => ({ + moduleToReplace, + newModule, + })); + } + getRootModule() { + const modules = this.container.getModules().values(); + return modules.next().value; + } + async createInstancesOfDependencies(graphInspector, options) { + const injector = new testing_injector_1.TestingInjector({ + preview: options?.preview ?? false, + snapshot: options?.snapshot ?? false, + }); + const instanceLoader = new testing_instance_loader_1.TestingInstanceLoader(this.container, injector, graphInspector); + await instanceLoader.createInstancesOfDependencies(this.container.getModules(), this.mocker); + } + createModule(metadata) { + class RootTestModule { + } + (0, common_1.Module)(metadata)(RootTestModule); + return RootTestModule; + } + applyLogger() { + common_1.Logger.overrideLogger(this.testingLogger || new testing_logger_service_1.TestingLogger()); + } +} +exports.TestingModuleBuilder = TestingModuleBuilder; diff --git a/node_modules/@nestjs/testing/testing-module.d.ts b/node_modules/@nestjs/testing/testing-module.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0b08dfe24534c605f58f2104255eb2a20c3fb566 --- /dev/null +++ b/node_modules/@nestjs/testing/testing-module.d.ts @@ -0,0 +1,22 @@ +import { HttpServer, INestApplication, INestMicroservice, NestApplicationOptions, Type } from '@nestjs/common'; +import { NestMicroserviceOptions } from '@nestjs/common/interfaces/microservices/nest-microservice-options.interface'; +import { AbstractHttpAdapter, NestApplicationContext } from '@nestjs/core'; +import { ApplicationConfig } from '@nestjs/core/application-config'; +import { NestContainer } from '@nestjs/core/injector/container'; +import { Module } from '@nestjs/core/injector/module'; +import { GraphInspector } from '@nestjs/core/inspector/graph-inspector'; +/** + * @publicApi + */ +export declare class TestingModule extends NestApplicationContext { + private readonly applicationConfig; + protected readonly graphInspector: GraphInspector; + constructor(container: NestContainer, graphInspector: GraphInspector, contextModule: Module, applicationConfig: ApplicationConfig, scope?: Type[]); + private isHttpServer; + createNestApplication(httpAdapter: HttpServer | AbstractHttpAdapter, options?: NestApplicationOptions): T; + createNestApplication(options?: NestApplicationOptions): T; + createNestMicroservice(options: NestMicroserviceOptions & T): INestMicroservice; + private createHttpAdapter; + private applyLogger; + private createAdapterProxy; +} diff --git a/node_modules/@nestjs/testing/testing-module.js b/node_modules/@nestjs/testing/testing-module.js new file mode 100644 index 0000000000000000000000000000000000000000..17957b409b224bc43c7e40a1071cf08061366063 --- /dev/null +++ b/node_modules/@nestjs/testing/testing-module.js @@ -0,0 +1,56 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.TestingModule = void 0; +const common_1 = require("@nestjs/common"); +const load_package_util_1 = require("@nestjs/common/utils/load-package.util"); +const shared_utils_1 = require("@nestjs/common/utils/shared.utils"); +const core_1 = require("@nestjs/core"); +/** + * @publicApi + */ +class TestingModule extends core_1.NestApplicationContext { + constructor(container, graphInspector, contextModule, applicationConfig, scope = []) { + const options = {}; + super(container, options, contextModule, scope); + this.applicationConfig = applicationConfig; + this.graphInspector = graphInspector; + } + isHttpServer(serverOrOptions) { + return !!(serverOrOptions && serverOrOptions.patch); + } + createNestApplication(serverOrOptions, options) { + const [httpAdapter, appOptions] = this.isHttpServer(serverOrOptions) + ? [serverOrOptions, options] + : [this.createHttpAdapter(), serverOrOptions]; + this.applyLogger(appOptions); + this.container.setHttpAdapter(httpAdapter); + const instance = new core_1.NestApplication(this.container, httpAdapter, this.applicationConfig, this.graphInspector, appOptions); + return this.createAdapterProxy(instance, httpAdapter); + } + createNestMicroservice(options) { + const { NestMicroservice } = (0, load_package_util_1.loadPackage)('@nestjs/microservices', 'TestingModule', () => require('@nestjs/microservices')); + this.applyLogger(options); + return new NestMicroservice(this.container, options, this.graphInspector, this.applicationConfig); + } + createHttpAdapter(httpServer) { + const { ExpressAdapter } = (0, load_package_util_1.loadPackage)('@nestjs/platform-express', 'NestFactory', () => require('@nestjs/platform-express')); + return new ExpressAdapter(httpServer); + } + applyLogger(options) { + if (!options || (0, shared_utils_1.isUndefined)(options.logger)) { + return; + } + common_1.Logger.overrideLogger(options.logger); + } + createAdapterProxy(app, adapter) { + return new Proxy(app, { + get: (receiver, prop) => { + if (!(prop in receiver) && prop in adapter) { + return adapter[prop]; + } + return receiver[prop]; + }, + }); + } +} +exports.TestingModule = TestingModule; diff --git a/node_modules/@nestjs/testing/tsconfig.build.json b/node_modules/@nestjs/testing/tsconfig.build.json new file mode 100644 index 0000000000000000000000000000000000000000..a5a3a630596a152b43f8dc0d1d00f026109299d4 --- /dev/null +++ b/node_modules/@nestjs/testing/tsconfig.build.json @@ -0,0 +1,32 @@ +{ + "extends": "../tsconfig.build.json", + "compilerOptions": { + "outDir": ".", + "rootDir": ".", + "paths": { + "@nestjs/common": ["../common"], + "@nestjs/common/*": ["../common/*"], + "@nestjs/core": ["../core"], + "@nestjs/core/*": ["../core/*"], + "@nestjs/microservices": ["../microservices"], + "@nestjs/microservices/*": ["../microservices/*"], + "@nestjs/platform-express": ["../platform-express"], + "@nestjs/platform-express/*": ["../platform-express/*"] + } + }, + "exclude": ["node_modules", "dist", "test/**/*", "*.spec.ts"], + "references": [ + { + "path": "../common/tsconfig.build.json" + }, + { + "path": "../core/tsconfig.build.json" + }, + { + "path": "../microservices/tsconfig.build.json" + }, + { + "path": "../platform-express/tsconfig.build.json" + } + ] +} diff --git a/node_modules/@noble/ciphers/LICENSE b/node_modules/@noble/ciphers/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..5a53d5f181739a33f6ea3e58bd464f4ec25cd458 --- /dev/null +++ b/node_modules/@noble/ciphers/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2022 Paul Miller (https://paulmillr.com) +Copyright (c) 2016 Thomas Pornin + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the “Software”), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/node_modules/@noble/ciphers/README.md b/node_modules/@noble/ciphers/README.md new file mode 100644 index 0000000000000000000000000000000000000000..f6761da5dd8c3fe9b6ea448d68f2ed89970edc47 --- /dev/null +++ b/node_modules/@noble/ciphers/README.md @@ -0,0 +1,543 @@ +# noble-ciphers + +Audited & minimal JS implementation of Salsa20, ChaCha and AES. + +- 🔒 [**Audited**](#security) by an independent security firm +- 🔻 Tree-shakeable: unused code is excluded from your builds +- 🏎 Fast: hand-optimized for caveats of JS engines +- 🔍 Reliable: property-based / cross-library / wycheproof tests ensure correctness +- 💼 AES: ECB, CBC, CTR, CFB, GCM, SIV (nonce misuse-resistant), AESKW, AESKWP +- 💃 Salsa20, ChaCha, XSalsa20, XChaCha, ChaCha8, ChaCha12, Poly1305 +- 🥈 Two AES implementations: pure JS or friendly wrapper around webcrypto +- 🪶 29KB (11KB gzipped) for everything, 7KB (3KB gzipped) for ChaCha build + +Take a glance at [GitHub Discussions](https://github.com/paulmillr/noble-ciphers/discussions) for questions and support. + +### This library belongs to _noble_ cryptography + +> **noble cryptography** — high-security, easily auditable set of contained cryptographic libraries and tools. + +- Zero or minimal dependencies +- Highly readable TypeScript / JS code +- PGP-signed releases and transparent NPM builds +- All libraries: + [ciphers](https://github.com/paulmillr/noble-ciphers), + [curves](https://github.com/paulmillr/noble-curves), + [hashes](https://github.com/paulmillr/noble-hashes), + [post-quantum](https://github.com/paulmillr/noble-post-quantum), + 4kb [secp256k1](https://github.com/paulmillr/noble-secp256k1) / + [ed25519](https://github.com/paulmillr/noble-ed25519) +- [Check out homepage](https://paulmillr.com/noble/) + for reading resources, documentation and apps built with noble + +## Usage + +> `npm install @noble/ciphers` + +> `deno add jsr:@noble/ciphers` + +> `deno doc jsr:@noble/ciphers` # command-line documentation + +We support all major platforms and runtimes. +For React Native, you may need a +[polyfill for getRandomValues](https://github.com/LinusU/react-native-get-random-values). +A standalone file +[noble-ciphers.js](https://github.com/paulmillr/noble-ciphers/releases) is also available. + +```ts +// import * from '@noble/ciphers'; // Error: use sub-imports, to ensure small app size +import { gcm, siv } from '@noble/ciphers/aes'; +import { chacha20poly1305, xchacha20poly1305 } from '@noble/ciphers/chacha'; +import { xsalsa20poly1305, secretbox } from '@noble/ciphers/salsa'; + +// Unauthenticated encryption: make sure to use HMAC or similar +import { ctr, cfb, cbc, ecb } from '@noble/ciphers/aes'; +import { salsa20, xsalsa20 } from '@noble/ciphers/salsa'; +import { chacha20, xchacha20, chacha8, chacha12 } from '@noble/ciphers/chacha'; +import { aeskw, aeskwp } from '@noble/ciphers/aes'; // KW +import { bytesToHex, hexToBytes, bytesToUtf8, utf8ToBytes } from '@noble/ciphers/utils'; +import { managedNonce, randomBytes } from '@noble/ciphers/webcrypto'; +``` + +- [Examples](#examples) + - [XChaCha20-Poly1305 encryption](#xchacha20-poly1305-encryption) + - [AES-256-GCM encryption](#aes-256-gcm-encryption) + - [AES: gcm, siv, ctr, cfb, cbc, ecb](#aes-gcm-siv-ctr-cfb-cbc-ecb) + - [Friendly WebCrypto AES](#friendly-webcrypto-aes) + - [AESKW and AESKWP](#aeskw-and-aeskwp) + - [Auto-handle nonces](#auto-handle-nonces) + - [Reuse array for input and output](#reuse-array-for-input-and-output) +- [Internals](#internals) + - [Implemented primitives](#implemented-primitives) + - [Which cipher should I pick?](#which-cipher-should-i-pick) + - [How to encrypt properly](#how-to-encrypt-properly) + - [Nonces](#nonces) + - [Encryption limits](#encryption-limits) + - [AES internals and block modes](#aes-internals-and-block-modes) +- [Security](#security) +- [Speed](#speed) +- [Upgrading](#upgrading) +- [Contributing & testing](#contributing--testing) +- [License](#license) + +## Examples + +> [!NOTE] +> Use different nonce every time `encrypt()` is done. + +#### XChaCha20-Poly1305 encryption + +```js +import { xchacha20poly1305 } from '@noble/ciphers/chacha'; +import { utf8ToBytes } from '@noble/ciphers/utils'; +import { randomBytes } from '@noble/ciphers/webcrypto'; +const key = randomBytes(32); // random key +// const key = new Uint8Array([ // existing key +// 169, 88, 160, 139, 168, 29, 147, 196, 14, 88, 237, 76, 243, 177, 109, 140, +// 195, 140, 80, 10, 216, 134, 215, 71, 191, 48, 20, 104, 189, 37, 38, 55, +// ]); +// import { hexToBytes } from '@noble/ciphers/utils'; // hex key +// const key = hexToBytes('4b7f89bac90a1086fef73f5da2cbe93b2fae9dfbf7678ae1f3e75fd118ddf999'); +const nonce = randomBytes(24); +const chacha = xchacha20poly1305(key, nonce); +const data = utf8ToBytes('hello, noble'); +const ciphertext = chacha.encrypt(data); +const data_ = chacha.decrypt(ciphertext); // utils.bytesToUtf8(data_) === data +``` + +#### AES-256-GCM encryption + +```js +import { gcm } from '@noble/ciphers/aes'; +import { utf8ToBytes } from '@noble/ciphers/utils'; +import { randomBytes } from '@noble/ciphers/webcrypto'; +const key = randomBytes(32); +const nonce = randomBytes(24); +const data = utf8ToBytes('hello, noble'); +const aes = gcm(key, nonce); +const ciphertext = aes.encrypt(data); +const data_ = aes.decrypt(ciphertext); // utils.bytesToUtf8(data_) === data +``` + +#### AES: gcm, siv, ctr, cfb, cbc, ecb + +```js +import { gcm, siv, ctr, cfb, cbc, ecb } from '@noble/ciphers/aes'; +import { randomBytes } from '@noble/ciphers/webcrypto'; +const plaintext = new Uint8Array(32).fill(16); +for (let cipher of [gcm, siv]) { + const key = randomBytes(32); // 24 for AES-192, 16 for AES-128 + const nonce = randomBytes(12); + const ciphertext_ = cipher(key, nonce).encrypt(plaintext); + const plaintext_ = cipher(key, nonce).decrypt(ciphertext_); +} +for (const cipher of [ctr, cbc, cfb]) { + const key = randomBytes(32); // 24 for AES-192, 16 for AES-128 + const nonce = randomBytes(16); + const ciphertext_ = cipher(key, nonce).encrypt(plaintext); + const plaintext_ = cipher(key, nonce).decrypt(ciphertext_); +} +for (const cipher of [ecb]) { + const key = randomBytes(32); // 24 for AES-192, 16 for AES-128 + const ciphertext_ = cipher(key).encrypt(plaintext); + const plaintext_ = cipher(key).decrypt(ciphertext_); +} +``` + +#### Friendly WebCrypto AES + +Noble implements AES. Sometimes people want to use built-in `crypto.subtle` instead. However, it has terrible API. We simplify access to built-ins. + +> [!NOTE] +> Webcrypto methods are always async. + +```js +import { gcm, ctr, cbc, randomBytes } from '@noble/ciphers/webcrypto'; +const plaintext = new Uint8Array(32).fill(16); +const key = randomBytes(32); +for (const cipher of [gcm]) { + const nonce = randomBytes(12); + const ciphertext_ = await cipher(key, nonce).encrypt(plaintext); + const plaintext_ = await cipher(key, nonce).decrypt(ciphertext_); +} +for (const cipher of [ctr, cbc]) { + const nonce = randomBytes(16); + const ciphertext_ = await cipher(key, nonce).encrypt(plaintext); + const plaintext_ = await cipher(key, nonce).decrypt(ciphertext_); +} +``` + +#### AESKW and AESKWP + +```ts +import { aeskw, aeskwp } from '@noble/ciphers/aes'; +import { hexToBytes } from '@noble/ciphers/utils'; + +const kek = hexToBytes('000102030405060708090A0B0C0D0E0F'); +const keyData = hexToBytes('00112233445566778899AABBCCDDEEFF'); +const ciphertext = aeskw(kek).encrypt(keyData); +``` + +#### Auto-handle nonces + +We provide API that manages nonce internally instead of exposing them to library's user. + +For `encrypt`, a `nonceBytes`-length buffer is fetched from CSPRNG and prenended to encrypted ciphertext. + +For `decrypt`, first `nonceBytes` of ciphertext are treated as nonce. + +```js +import { xchacha20poly1305 } from '@noble/ciphers/chacha'; +import { managedNonce } from '@noble/ciphers/webcrypto'; +import { hexToBytes, utf8ToBytes } from '@noble/ciphers/utils'; +const key = hexToBytes('fa686bfdffd3758f6377abbc23bf3d9bdc1a0dda4a6e7f8dbdd579fa1ff6d7e1'); +const chacha = managedNonce(xchacha20poly1305)(key); // manages nonces for you +const data = utf8ToBytes('hello, noble'); +const ciphertext = chacha.encrypt(data); +const data_ = chacha.decrypt(ciphertext); +``` + +#### Reuse array for input and output + +To avoid additional allocations, Uint8Array can be reused +between encryption and decryption calls. + +> [!NOTE] +> Some ciphers don't support unaligned (`byteOffset % 4 !== 0`) Uint8Array as +> destination. It can decrease performance, making the optimization pointless. + +```js +import { chacha20poly1305 } from '@noble/ciphers/chacha'; +import { utf8ToBytes } from '@noble/ciphers/utils'; +import { randomBytes } from '@noble/ciphers/webcrypto'; + +const key = randomBytes(32); +const nonce = randomBytes(12); +const chacha = chacha20poly1305(key, nonce); + +const input = utf8ToBytes('hello, noble'); // length == 12 +const inputLength = input.length; +const tagLength = 16; + +const buf = new Uint8Array(inputLength + tagLength); +const start = buf.subarray(0, inputLength); +start.set(input); // copy input to buf + +chacha.encrypt(start, buf); // encrypt into `buf` +chacha.decrypt(buf, start); // decrypt into `start` +``` + +xsalsa20poly1305 also supports this, but requires 32 additional bytes for encryption / decryption, +due to its inner workings. + +## Internals + +### Implemented primitives + +- [Salsa20](https://cr.yp.to/snuffle.html) stream cipher, released in 2005. + Salsa's goal was to implement AES replacement that does not rely on S-Boxes, + which are hard to implement in a constant-time manner. + Salsa20 is usually faster than AES, a big deal on slow, budget mobile phones. + - [XSalsa20](https://cr.yp.to/snuffle/xsalsa-20110204.pdf), extended-nonce + variant was released in 2008. It switched nonces from 96-bit to 192-bit, + and became safe to be picked at random. - Nacl / Libsodium popularized term "secretbox", a simple black-box + authenticated encryption. Secretbox is just xsalsa20-poly1305. We provide the + alias and corresponding seal / open methods. We don't provide "box" or "sealedbox". + - Check out [PDF](https://cr.yp.to/snuffle/salsafamily-20071225.pdf) and + [wiki](https://en.wikipedia.org/wiki/Salsa20). +- [ChaCha20](https://cr.yp.to/chacha.html) stream cipher, released + in 2008. Developed after Salsa20, ChaCha aims to increase diffusion per round. + It was standardized in [RFC 8439](https://datatracker.ietf.org/doc/html/rfc8439) + and is now used in TLS 1.3. + - [XChaCha20](https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha) + extended-nonce variant is also provided. Similar to XSalsa, it's safe to use with + randomly-generated nonces. + - Check out [PDF](http://cr.yp.to/chacha/chacha-20080128.pdf) and [wiki](https://en.wikipedia.org/wiki/Salsa20). +- [AES](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard) + is a variant of Rijndael block cipher, standardized by NIST in 2001. + We provide the fastest available pure JS implementation. + - We support AES-128, AES-192 and AES-256: the mode is selected dynamically, + based on key length (16, 24, 32). + - [AES-GCM-SIV](https://en.wikipedia.org/wiki/AES-GCM-SIV) + nonce-misuse-resistant mode is also provided. It's recommended to use it, + to prevent catastrophic consequences of nonce reuse. Our implementation of SIV + has the same speed as GCM: there is no performance hit. + - We also have AESKW and AESKWP from + [RFC 3394](https://datatracker.ietf.org/doc/html/rfc3394) / [RFC 5649](https://datatracker.ietf.org/doc/html/rfc5649) + - Check out [AES internals and block modes](#aes-internals-and-block-modes). +- We expose polynomial-evaluation MACs: [Poly1305](https://cr.yp.to/mac.html), AES-GCM's [GHash](https://en.wikipedia.org/wiki/Galois/Counter_Mode) and + AES-SIV's [Polyval](https://en.wikipedia.org/wiki/AES-GCM-SIV). + - Poly1305 ([PDF](https://cr.yp.to/mac/poly1305-20050329.pdf), + [wiki](https://en.wikipedia.org/wiki/Poly1305)) + is a fast and parallel secret-key message-authentication code suitable for + a wide variety of applications. It was standardized in + [RFC 8439](https://datatracker.ietf.org/doc/html/rfc8439) and is now used in TLS 1.3. + - Polynomial MACs are not perfect for every situation: + they lack Random Key Robustness: the MAC can be forged, and can't + be used in PAKE schemes. See + [invisible salamanders attack](https://keymaterial.net/2020/09/07/invisible-salamanders-in-aes-gcm-siv/). + To combat invisible salamanders, `hash(key)` can be included in ciphertext, + however, this would violate ciphertext indistinguishability: + an attacker would know which key was used - so `HKDF(key, i)` + could be used instead. +- Format-preserving encryption algorithm (FPE-FF1) specified in NIST Special Publication 800-38G. + [See more info](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38G.pdf). + +### Which cipher should I pick? + +We suggest to use XChaCha20-Poly1305. +If you can't use it, prefer AES-GCM-SIV, or AES-GCM. + +### How to encrypt properly + +- Use unpredictable key with enough entropy + - Random key must be using cryptographically secure random number generator (CSPRNG), not `Math.random` etc. + - Non-random key generated from KDF is fine + - Re-using key is fine, but be aware of rules for cryptographic key wear-out and [encryption limits](#encryption-limits) +- Use new nonce every time and [don't repeat it](#nonces) + - chacha and salsa20 are fine for sequential counters that _never_ repeat: `01, 02...` + - xchacha and xsalsa20 should use random nonces instead + - AES-GCM should use 12-byte nonces: smaller nonces are security risk +- Prefer authenticated encryption (AEAD) + - chacha20poly1305 / aes-gcm / ChaCha + HMAC / AES + HMAC is good + - chacha20 / aes-ctr / aes-cbc without poly1305 or hmac is bad + - Flipping bits or ciphertext substitution won't be detected in unauthenticated ciphers +- Don't re-use keys between different protocols + - For example, using secp256k1 key in AES can be bad + - Use hkdf or, at least, a hash function to create sub-key instead +- If you need AES, only use AES-256 for new protocols + - For post-quantum security + +### Nonces + +Most ciphers need a key and a nonce (aka initialization vector / IV) to encrypt a data: + + ciphertext = encrypt(plaintext, key, nonce) + +Repeating (key, nonce) pair with different plaintexts would allow an attacker to decrypt it: + + ciphertext_a = encrypt(plaintext_a, key, nonce) + ciphertext_b = encrypt(plaintext_b, key, nonce) + stream_diff = xor(ciphertext_a, ciphertext_b) # Break encryption + +So, you can't repeat nonces. One way of doing so is using counters: + + for i in 0..: + ciphertext[i] = encrypt(plaintexts[i], key, i) + +Another is generating random nonce every time: + + for i in 0..: + rand_nonces[i] = random() + ciphertext[i] = encrypt(plaintexts[i], key, rand_nonces[i]) + +Counters are OK, but it's not always possible to store current counter value: +e.g. in decentralized, unsyncable systems. + +Randomness is OK, but there's a catch: +ChaCha20 and AES-GCM use 96-bit / 12-byte nonces, which implies higher chance of collision. +In the example above, `random()` can collide and produce repeating nonce. +Chance is even higher for 64-bit nonces, which GCM allows - don't use them. + +To safely use random nonces, utilize XSalsa20 or XChaCha: +they increased nonce length to 192-bit, minimizing a chance of collision. +AES-SIV is also fine. In situations where you can't use eXtended-nonce +algorithms, key rotation is advised. hkdf would work great for this case. + +### Encryption limits + +A "protected message" would mean a probability of `2**-50` that a passive attacker +successfully distinguishes the ciphertext outputs of the AEAD scheme from the outputs +of a random function. See [draft-irtf-cfrg-aead-limits](https://datatracker.ietf.org/doc/draft-irtf-cfrg-aead-limits/) for details. + +- Max message size: + - AES-GCM: ~68GB, `2**36-256` + - Salsa, ChaCha, XSalsa, XChaCha: ~256GB, `2**38-64` +- Max amount of protected messages, under same key: + - AES-GCM: `2**32.5` + - Salsa, ChaCha: `2**46`, but only integrity is affected, not confidentiality + - XSalsa, XChaCha: `2**72` +- Max amount of protected messages, across all keys: + - AES-GCM: `2**69/B` where B is max blocks encrypted by a key. Meaning + `2**59` for 1KB, `2**49` for 1MB, `2**39` for 1GB + - Salsa, ChaCha, XSalsa, XChaCha: `2**100` + +##### AES internals and block modes + +`cipher = encrypt(block, key)`. Data is split into 128-bit blocks. Encrypted in 10/12/14 rounds (128/192/256bit). Every round does: + +1. **S-box**, table substitution +2. **Shift rows**, cyclic shift left of all rows of data array +3. **Mix columns**, multiplying every column by fixed polynomial +4. **Add round key**, round_key xor i-th column of array + +For non-deterministic (not ECB) schemes, initialization vector (IV) is mixed to block/key; +and each new round either depends on previous block's key, or on some counter. + +- ECB (Electronic Codebook): Deterministic encryption; identical plaintext blocks yield identical ciphertexts. Insecure due to pattern leakage. + See [AES Penguin](https://words.filippo.io/the-ecb-penguin/) +- CBC (Cipher Block Chaining): Each plaintext block is XORed with the previous ciphertext block before encryption. + Hard to use: requires proper padding and an IV. Needs a separate MAC. +- CTR (Counter Mode): Turns a block cipher into a stream cipher using a counter and IV (nonce). + Efficient and parallelizable. Requires a unique nonce per encryption. Better, but still needs a separate MAC. +- GCM (Galois/Counter Mode): Combines CTR mode with polynomial MAC. Efficient and widely used. +- SIV (Synthetic IV): Nonce-misuse-resistant mode; repeating nonces reveal only if plaintexts are identical. + Maintains security even if nonces are reused. +- XTS: Designed for disk encryption. + Similar to ECB (deterministic), but has `[i][j]` tweak arguments corresponding to sector i and 16-byte block (part of sector) j. + Lacks MAC. + +GCM / SIV are not ideal: + +- Conservative key wear-out is `2**32` (4B) msgs +- MAC can be forged: see Poly1305 section above. Same for SIV + +## Security + +The library has been independently audited: + +- at version 1.0.0, in Sep 2024, by [cure53](https://cure53.de) + - PDFs: [website](https://cure53.de/audit-report_noble-crypto-libs.pdf), [in-repo](./audit/2024-09-cure53-audit-nbl4.pdf) + - [Changes since audit](https://github.com/paulmillr/noble-ciphers/compare/1.0.0..main) + - Scope: everything + - The audit has been funded by [OpenSats](https://opensats.org) + +It is tested against property-based, cross-library and Wycheproof vectors, +and is being fuzzed in [the separate repo](https://github.com/paulmillr/fuzzing). + +If you see anything unusual: investigate and report. + +### Constant-timeness + +We're targetting algorithmic constant time. _JIT-compiler_ and _Garbage Collector_ make "constant time" +extremely hard to achieve [timing attack](https://en.wikipedia.org/wiki/Timing_attack) resistance +in a scripting language. Which means _any other JS library can't have +constant-timeness_. Even statically typed Rust, a language without GC, +[makes it harder to achieve constant-time](https://www.chosenplaintext.ca/open-source/rust-timing-shield/security) +for some cases. If your goal is absolute security, don't use any JS lib — including bindings to native ones. +Use low-level libraries & languages. + +The library uses T-tables for AES, which +[leak access timings](https://cr.yp.to/antiforgery/cachetiming-20050414.pdf). +This is also done in [OpenSSL](https://github.com/openssl/openssl/blob/2f33265039cdbd0e4589c80970e02e208f3f94d2/crypto/aes/aes_core.c#L706) and +[Go stdlib](https://cs.opensource.google/go/go/+/refs/tags/go1.22.6:src/crypto/aes/const.go;l=90) for performance reasons. +The analysis was mentioned in [hal-04652991](https://hal.science/hal-04652991/document). + +### Supply chain security + +- **Commits** are signed with PGP keys, to prevent forgery. Make sure to verify commit signatures +- **Releases** are transparent and built on GitHub CI. Make sure to verify [provenance](https://docs.npmjs.com/generating-provenance-statements) logs + - Use GitHub CLI to verify single-file builds: + `gh attestation verify --owner paulmillr noble-ciphers.js` +- **Rare releasing** is followed to ensure less re-audit need for end-users +- **Dependencies** are minimized and locked-down: any dependency could get hacked and users will be downloading malware with every install. + - We make sure to use as few dependencies as possible + - Automatic dep updates are prevented by locking-down version ranges; diffs are checked with `npm-diff` +- **Dev Dependencies** are disabled for end-users; they are only used to develop / build the source code + +For this package, there are 0 dependencies; and a few dev dependencies: + +- micro-bmark, micro-should and jsbt are used for benchmarking / testing / build tooling and developed by the same author +- prettier, fast-check and typescript are used for code quality / test generation / ts compilation. It's hard to audit their source code thoroughly and fully because of their size + +### Randomness + +We're deferring to built-in +[crypto.getRandomValues](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues) +which is considered cryptographically secure (CSPRNG). + +In the past, browsers had bugs that made it weak: it may happen again. +Implementing a userspace CSPRNG to get resilient to the weakness +is even worse: there is no reliable userspace source of quality entropy. + +## Speed + +To summarize, noble is the fastest JS implementation of Salsa, ChaCha and AES. + +You can gain additional speed-up and +avoid memory allocations by passing `output` +uint8array into encrypt / decrypt methods. + +Benchmark results on Apple M4: + +``` +64B +xsalsa20poly1305 x 675,675 ops/sec @ 1μs/op +chacha20poly1305 x 568,181 ops/sec @ 1μs/op +xchacha20poly1305 x 460,617 ops/sec @ 2μs/op +aes-256-gcm x 201,126 ops/sec @ 4μs/op +aes-256-gcm-siv x 162,284 ops/sec @ 6μs/op +# Unauthenticated encryption +salsa20 x 1,655,629 ops/sec @ 604ns/op +xsalsa20 x 1,400,560 ops/sec @ 714ns/op +chacha20 x 1,996,007 ops/sec @ 501ns/op +xchacha20 x 1,404,494 ops/sec @ 712ns/op +chacha8 x 2,145,922 ops/sec @ 466ns/op +chacha12 x 2,036,659 ops/sec @ 491ns/op +aes-ecb-256 x 1,019,367 ops/sec @ 981ns/op +aes-cbc-256 x 931,966 ops/sec @ 1μs/op +aes-ctr-256 x 954,198 ops/sec @ 1μs/op + +1MB +xsalsa20poly1305 x 322 ops/sec @ 3ms/op +chacha20poly1305 x 327 ops/sec @ 3ms/op +xchacha20poly1305 x 331 ops/sec @ 3ms/op +aes-256-gcm x 94 ops/sec @ 10ms/op +aes-256-gcm-siv x 90 ops/sec @ 11ms/op +# Unauthenticated encryption +salsa20 x 791 ops/sec @ 1ms/op +xsalsa20 x 801 ops/sec @ 1ms/op +chacha20 x 787 ops/sec @ 1ms/op +xchacha20 x 781 ops/sec @ 1ms/op +chacha8 x 1,457 ops/sec @ 686μs/op +chacha12 x 1,130 ops/sec @ 884μs/op +aes-ecb-256 x 289 ops/sec @ 3ms/op +aes-cbc-256 x 114 ops/sec @ 8ms/op +aes-ctr-256 x 127 ops/sec @ 7ms/op +# Wrapper over built-in webcrypto +webcrypto ctr-256 x 6,508 ops/sec @ 153μs/op +webcrypto cbc-256 x 1,820 ops/sec @ 549μs/op +webcrypto gcm-256 x 5,106 ops/sec @ 195μs/op +``` + +Compare to other implementations: + +``` +xsalsa20poly1305 (encrypt, 1MB) +├─tweetnacl x 196 ops/sec +└─noble x 305 ops/sec + +chacha20poly1305 (encrypt, 1MB) +├─node x 1,668 ops/sec +├─stablelib x 202 ops/sec +└─noble x 319 ops/sec + +aes-ctr-256 (encrypt, 1MB) +├─stablelib x 123 ops/sec +├─aesjs x 42 ops/sec +├─noble-webcrypto x 5,965 ops/sec +└─noble x 124 ops/sec +``` + +## Contributing & testing + +- `npm install && npm run build && npm test` will build the code and run tests. +- `npm run lint` / `npm run format` will run linter / fix linter issues. +- `npm run bench` will run benchmarks, which may need their deps first (`npm run bench:install`) +- `npm run build:release` will build single file + +Check out [github.com/paulmillr/guidelines](https://github.com/paulmillr/guidelines) +for general coding practices and rules. + +See [paulmillr.com/noble](https://paulmillr.com/noble/) +for useful resources, articles, documentation and demos +related to the library. + +## License + +The MIT License (MIT) + +Copyright (c) 2023 Paul Miller [(https://paulmillr.com)](https://paulmillr.com) +Copyright (c) 2016 Thomas Pornin + +See LICENSE file. diff --git a/node_modules/@noble/ciphers/_arx.d.ts b/node_modules/@noble/ciphers/_arx.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9b54727a4cbf2ec8d3ff2ceb4e604ada63a0a6e9 --- /dev/null +++ b/node_modules/@noble/ciphers/_arx.d.ts @@ -0,0 +1,59 @@ +/** + * Basic utils for ARX (add-rotate-xor) salsa and chacha ciphers. + +RFC8439 requires multi-step cipher stream, where +authKey starts with counter: 0, actual msg with counter: 1. + +For this, we need a way to re-use nonce / counter: + + const counter = new Uint8Array(4); + chacha(..., counter, ...); // counter is now 1 + chacha(..., counter, ...); // counter is now 2 + +This is complicated: + +- 32-bit counters are enough, no need for 64-bit: max ArrayBuffer size in JS is 4GB +- Original papers don't allow mutating counters +- Counter overflow is undefined [^1] +- Idea A: allow providing (nonce | counter) instead of just nonce, re-use it +- Caveat: Cannot be re-used through all cases: +- * chacha has (counter | nonce) +- * xchacha has (nonce16 | counter | nonce16) +- Idea B: separate nonce / counter and provide separate API for counter re-use +- Caveat: there are different counter sizes depending on an algorithm. +- salsa & chacha also differ in structures of key & sigma: + salsa20: s[0] | k(4) | s[1] | nonce(2) | ctr(2) | s[2] | k(4) | s[3] + chacha: s(4) | k(8) | ctr(1) | nonce(3) + chacha20orig: s(4) | k(8) | ctr(2) | nonce(2) +- Idea C: helper method such as `setSalsaState(key, nonce, sigma, data)` +- Caveat: we can't re-use counter array + +xchacha [^2] uses the subkey and remaining 8 byte nonce with ChaCha20 as normal +(prefixed by 4 NUL bytes, since [RFC8439] specifies a 12-byte nonce). + +[^1]: https://mailarchive.ietf.org/arch/msg/cfrg/gsOnTJzcbgG6OqD8Sc0GO5aR_tU/ +[^2]: https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha#appendix-A.2 + + * @module + */ +import { type XorStream } from './utils.ts'; +export declare function rotl(a: number, b: number): number; +/** Ciphers must use u32 for efficiency. */ +export type CipherCoreFn = (sigma: Uint32Array, key: Uint32Array, nonce: Uint32Array, output: Uint32Array, counter: number, rounds?: number) => void; +/** Method which extends key + short nonce into larger nonce / diff key. */ +export type ExtendNonceFn = (sigma: Uint32Array, key: Uint32Array, input: Uint32Array, output: Uint32Array) => void; +/** ARX cipher options. + * * `allowShortKeys` for 16-byte keys + * * `counterLength` in bytes + * * `counterRight`: right: `nonce|counter`; left: `counter|nonce` + * */ +export type CipherOpts = { + allowShortKeys?: boolean; + extendNonceFn?: ExtendNonceFn; + counterLength?: number; + counterRight?: boolean; + rounds?: number; +}; +/** Creates ARX-like (ChaCha, Salsa) cipher stream from core function. */ +export declare function createCipher(core: CipherCoreFn, opts: CipherOpts): XorStream; +//# sourceMappingURL=_arx.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/_arx.d.ts.map b/node_modules/@noble/ciphers/_arx.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..73c68bbf4a14775ec66ed527ff2b8c92688d68c9 --- /dev/null +++ b/node_modules/@noble/ciphers/_arx.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"_arx.d.ts","sourceRoot":"","sources":["src/_arx.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EACL,KAAK,SAAS,EACf,MAAM,YAAY,CAAC;AAUpB,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,2CAA2C;AAC3C,MAAM,MAAM,YAAY,GAAG,CACzB,KAAK,EAAE,WAAW,EAClB,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,KACZ,IAAI,CAAC;AAEV,2EAA2E;AAC3E,MAAM,MAAM,aAAa,GAAG,CAC1B,KAAK,EAAE,WAAW,EAClB,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,WAAW,KAChB,IAAI,CAAC;AAEV;;;;KAIK;AACL,MAAM,MAAM,UAAU,GAAG;IACvB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAwDF,yEAAyE;AACzE,wBAAgB,YAAY,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,GAAG,SAAS,CAkF5E"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/_arx.js b/node_modules/@noble/ciphers/_arx.js new file mode 100644 index 0000000000000000000000000000000000000000..c82d5bc8bc63bd5fca2a8159f12d3ee785efa5f9 --- /dev/null +++ b/node_modules/@noble/ciphers/_arx.js @@ -0,0 +1,175 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.rotl = rotl; +exports.createCipher = createCipher; +/** + * Basic utils for ARX (add-rotate-xor) salsa and chacha ciphers. + +RFC8439 requires multi-step cipher stream, where +authKey starts with counter: 0, actual msg with counter: 1. + +For this, we need a way to re-use nonce / counter: + + const counter = new Uint8Array(4); + chacha(..., counter, ...); // counter is now 1 + chacha(..., counter, ...); // counter is now 2 + +This is complicated: + +- 32-bit counters are enough, no need for 64-bit: max ArrayBuffer size in JS is 4GB +- Original papers don't allow mutating counters +- Counter overflow is undefined [^1] +- Idea A: allow providing (nonce | counter) instead of just nonce, re-use it +- Caveat: Cannot be re-used through all cases: +- * chacha has (counter | nonce) +- * xchacha has (nonce16 | counter | nonce16) +- Idea B: separate nonce / counter and provide separate API for counter re-use +- Caveat: there are different counter sizes depending on an algorithm. +- salsa & chacha also differ in structures of key & sigma: + salsa20: s[0] | k(4) | s[1] | nonce(2) | ctr(2) | s[2] | k(4) | s[3] + chacha: s(4) | k(8) | ctr(1) | nonce(3) + chacha20orig: s(4) | k(8) | ctr(2) | nonce(2) +- Idea C: helper method such as `setSalsaState(key, nonce, sigma, data)` +- Caveat: we can't re-use counter array + +xchacha [^2] uses the subkey and remaining 8 byte nonce with ChaCha20 as normal +(prefixed by 4 NUL bytes, since [RFC8439] specifies a 12-byte nonce). + +[^1]: https://mailarchive.ietf.org/arch/msg/cfrg/gsOnTJzcbgG6OqD8Sc0GO5aR_tU/ +[^2]: https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha#appendix-A.2 + + * @module + */ +// prettier-ignore +const utils_ts_1 = require("./utils.js"); +// We can't make top-level var depend on utils.utf8ToBytes +// because it's not present in all envs. Creating a similar fn here +const _utf8ToBytes = (str) => Uint8Array.from(str.split('').map((c) => c.charCodeAt(0))); +const sigma16 = _utf8ToBytes('expand 16-byte k'); +const sigma32 = _utf8ToBytes('expand 32-byte k'); +const sigma16_32 = (0, utils_ts_1.u32)(sigma16); +const sigma32_32 = (0, utils_ts_1.u32)(sigma32); +function rotl(a, b) { + return (a << b) | (a >>> (32 - b)); +} +// Is byte array aligned to 4 byte offset (u32)? +function isAligned32(b) { + return b.byteOffset % 4 === 0; +} +// Salsa and Chacha block length is always 512-bit +const BLOCK_LEN = 64; +const BLOCK_LEN32 = 16; +// new Uint32Array([2**32]) // => Uint32Array(1) [ 0 ] +// new Uint32Array([2**32-1]) // => Uint32Array(1) [ 4294967295 ] +const MAX_COUNTER = 2 ** 32 - 1; +const U32_EMPTY = new Uint32Array(); +function runCipher(core, sigma, key, nonce, data, output, counter, rounds) { + const len = data.length; + const block = new Uint8Array(BLOCK_LEN); + const b32 = (0, utils_ts_1.u32)(block); + // Make sure that buffers aligned to 4 bytes + const isAligned = isAligned32(data) && isAligned32(output); + const d32 = isAligned ? (0, utils_ts_1.u32)(data) : U32_EMPTY; + const o32 = isAligned ? (0, utils_ts_1.u32)(output) : U32_EMPTY; + for (let pos = 0; pos < len; counter++) { + core(sigma, key, nonce, b32, counter, rounds); + if (counter >= MAX_COUNTER) + throw new Error('arx: counter overflow'); + const take = Math.min(BLOCK_LEN, len - pos); + // aligned to 4 bytes + if (isAligned && take === BLOCK_LEN) { + const pos32 = pos / 4; + if (pos % 4 !== 0) + throw new Error('arx: invalid block position'); + for (let j = 0, posj; j < BLOCK_LEN32; j++) { + posj = pos32 + j; + o32[posj] = d32[posj] ^ b32[j]; + } + pos += BLOCK_LEN; + continue; + } + for (let j = 0, posj; j < take; j++) { + posj = pos + j; + output[posj] = data[posj] ^ block[j]; + } + pos += take; + } +} +/** Creates ARX-like (ChaCha, Salsa) cipher stream from core function. */ +function createCipher(core, opts) { + const { allowShortKeys, extendNonceFn, counterLength, counterRight, rounds } = (0, utils_ts_1.checkOpts)({ allowShortKeys: false, counterLength: 8, counterRight: false, rounds: 20 }, opts); + if (typeof core !== 'function') + throw new Error('core must be a function'); + (0, utils_ts_1.anumber)(counterLength); + (0, utils_ts_1.anumber)(rounds); + (0, utils_ts_1.abool)(counterRight); + (0, utils_ts_1.abool)(allowShortKeys); + return (key, nonce, data, output, counter = 0) => { + (0, utils_ts_1.abytes)(key); + (0, utils_ts_1.abytes)(nonce); + (0, utils_ts_1.abytes)(data); + const len = data.length; + if (output === undefined) + output = new Uint8Array(len); + (0, utils_ts_1.abytes)(output); + (0, utils_ts_1.anumber)(counter); + if (counter < 0 || counter >= MAX_COUNTER) + throw new Error('arx: counter overflow'); + if (output.length < len) + throw new Error(`arx: output (${output.length}) is shorter than data (${len})`); + const toClean = []; + // Key & sigma + // key=16 -> sigma16, k=key|key + // key=32 -> sigma32, k=key + let l = key.length; + let k; + let sigma; + if (l === 32) { + toClean.push((k = (0, utils_ts_1.copyBytes)(key))); + sigma = sigma32_32; + } + else if (l === 16 && allowShortKeys) { + k = new Uint8Array(32); + k.set(key); + k.set(key, 16); + sigma = sigma16_32; + toClean.push(k); + } + else { + throw new Error(`arx: invalid 32-byte key, got length=${l}`); + } + // Nonce + // salsa20: 8 (8-byte counter) + // chacha20orig: 8 (8-byte counter) + // chacha20: 12 (4-byte counter) + // xsalsa20: 24 (16 -> hsalsa, 8 -> old nonce) + // xchacha20: 24 (16 -> hchacha, 8 -> old nonce) + // Align nonce to 4 bytes + if (!isAligned32(nonce)) + toClean.push((nonce = (0, utils_ts_1.copyBytes)(nonce))); + const k32 = (0, utils_ts_1.u32)(k); + // hsalsa & hchacha: handle extended nonce + if (extendNonceFn) { + if (nonce.length !== 24) + throw new Error(`arx: extended nonce must be 24 bytes`); + extendNonceFn(sigma, k32, (0, utils_ts_1.u32)(nonce.subarray(0, 16)), k32); + nonce = nonce.subarray(16); + } + // Handle nonce counter + const nonceNcLen = 16 - counterLength; + if (nonceNcLen !== nonce.length) + throw new Error(`arx: nonce must be ${nonceNcLen} or 16 bytes`); + // Pad counter when nonce is 64 bit + if (nonceNcLen !== 12) { + const nc = new Uint8Array(12); + nc.set(nonce, counterRight ? 0 : 12 - nonce.length); + nonce = nc; + toClean.push(nonce); + } + const n32 = (0, utils_ts_1.u32)(nonce); + runCipher(core, sigma, k32, n32, data, output, counter, rounds); + (0, utils_ts_1.clean)(...toClean); + return output; + }; +} +//# sourceMappingURL=_arx.js.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/_arx.js.map b/node_modules/@noble/ciphers/_arx.js.map new file mode 100644 index 0000000000000000000000000000000000000000..bb3482ffc4622fcee311840e93016081a0e5c187 --- /dev/null +++ b/node_modules/@noble/ciphers/_arx.js.map @@ -0,0 +1 @@ +{"version":3,"file":"_arx.js","sourceRoot":"","sources":["src/_arx.ts"],"names":[],"mappings":";;AAmDA,oBAEC;AAwFD,oCAkFC;AA/ND;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,kBAAkB;AAClB,yCAEoB;AAEpB,0DAA0D;AAC1D,mEAAmE;AACnE,MAAM,YAAY,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACjG,MAAM,OAAO,GAAG,YAAY,CAAC,kBAAkB,CAAC,CAAC;AACjD,MAAM,OAAO,GAAG,YAAY,CAAC,kBAAkB,CAAC,CAAC;AACjD,MAAM,UAAU,GAAG,IAAA,cAAG,EAAC,OAAO,CAAC,CAAC;AAChC,MAAM,UAAU,GAAG,IAAA,cAAG,EAAC,OAAO,CAAC,CAAC;AAEhC,SAAgB,IAAI,CAAC,CAAS,EAAE,CAAS;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a,CAAC;QACtC,IAAI,UAAU,KAAK,KAAK,CAAC,MAAM;YAC7B,MAAM,IAAI,KAAK,CAAC,sBAAsB,UAAU,cAAc,CAAC,CAAC;QAElE,mCAAmC;QACnC,IAAI,UAAU,KAAK,EAAE,EAAE,CAAC;YACtB,MAAM,EAAE,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;YAC9B,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;YACpD,KAAK,GAAG,EAAE,CAAC;YACX,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;QACD,MAAM,GAAG,GAAG,IAAA,cAAG,EAAC,KAAK,CAAC,CAAC;QACvB,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAChE,IAAA,gBAAK,EAAC,GAAG,OAAO,CAAC,CAAC;QAClB,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/_assert.d.ts b/node_modules/@noble/ciphers/_assert.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5faec8e064ec06f2b141d70acb3054f5a1bf4cbe --- /dev/null +++ b/node_modules/@noble/ciphers/_assert.d.ts @@ -0,0 +1,19 @@ +/** + * Internal assertion helpers. + * @module + * @deprecated + */ +import { abytes as ab, abool as abool_, aexists as ae, anumber as an, aoutput as ao, type IHash as H } from './utils.ts'; +/** @deprecated Use import from `noble/hashes/utils` module */ +export declare const abool: typeof abool_; +/** @deprecated Use import from `noble/hashes/utils` module */ +export declare const abytes: typeof ab; +/** @deprecated Use import from `noble/hashes/utils` module */ +export declare const aexists: typeof ae; +/** @deprecated Use import from `noble/hashes/utils` module */ +export declare const anumber: typeof an; +/** @deprecated Use import from `noble/hashes/utils` module */ +export declare const aoutput: typeof ao; +/** @deprecated Use import from `noble/hashes/utils` module */ +export type Hash = H; +//# sourceMappingURL=_assert.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/_assert.d.ts.map b/node_modules/@noble/ciphers/_assert.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..29b88c4473d75d70c05180b7b9f57c5a5dcb9afc --- /dev/null +++ b/node_modules/@noble/ciphers/_assert.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"_assert.d.ts","sourceRoot":"","sources":["src/_assert.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,MAAM,IAAI,EAAE,EACZ,KAAK,IAAI,MAAM,EACf,OAAO,IAAI,EAAE,EACb,OAAO,IAAI,EAAE,EACb,OAAO,IAAI,EAAE,EACb,KAAK,KAAK,IAAI,CAAC,EAChB,MAAM,YAAY,CAAC;AACpB,8DAA8D;AAC9D,eAAO,MAAM,KAAK,EAAE,OAAO,MAAe,CAAC;AAC3C,8DAA8D;AAC9D,eAAO,MAAM,MAAM,EAAE,OAAO,EAAO,CAAC;AACpC,8DAA8D;AAC9D,eAAO,MAAM,OAAO,EAAE,OAAO,EAAO,CAAC;AACrC,8DAA8D;AAC9D,eAAO,MAAM,OAAO,EAAE,OAAO,EAAO,CAAC;AACrC,8DAA8D;AAC9D,eAAO,MAAM,OAAO,EAAE,OAAO,EAAO,CAAC;AACrC,8DAA8D;AAC9D,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/_assert.js b/node_modules/@noble/ciphers/_assert.js new file mode 100644 index 0000000000000000000000000000000000000000..1e5788deb5e4a5956d21eabc8266356e9e52c71f --- /dev/null +++ b/node_modules/@noble/ciphers/_assert.js @@ -0,0 +1,20 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.aoutput = exports.anumber = exports.aexists = exports.abytes = exports.abool = void 0; +/** + * Internal assertion helpers. + * @module + * @deprecated + */ +const utils_ts_1 = require("./utils.js"); +/** @deprecated Use import from `noble/hashes/utils` module */ +exports.abool = utils_ts_1.abool; +/** @deprecated Use import from `noble/hashes/utils` module */ +exports.abytes = utils_ts_1.abytes; +/** @deprecated Use import from `noble/hashes/utils` module */ +exports.aexists = utils_ts_1.aexists; +/** @deprecated Use import from `noble/hashes/utils` module */ +exports.anumber = utils_ts_1.anumber; +/** @deprecated Use import from `noble/hashes/utils` module */ +exports.aoutput = utils_ts_1.aoutput; +//# sourceMappingURL=_assert.js.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/_assert.js.map b/node_modules/@noble/ciphers/_assert.js.map new file mode 100644 index 0000000000000000000000000000000000000000..b377f349fc9fe65ec3d89d54c3488770102fc8d6 --- /dev/null +++ b/node_modules/@noble/ciphers/_assert.js.map @@ -0,0 +1 @@ +{"version":3,"file":"_assert.js","sourceRoot":"","sources":["src/_assert.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,yCAOoB;AACpB,8DAA8D;AACjD,QAAA,KAAK,GAAkB,gBAAM,CAAC;AAC3C,8DAA8D;AACjD,QAAA,MAAM,GAAc,iBAAE,CAAC;AACpC,8DAA8D;AACjD,QAAA,OAAO,GAAc,kBAAE,CAAC;AACrC,8DAA8D;AACjD,QAAA,OAAO,GAAc,kBAAE,CAAC;AACrC,8DAA8D;AACjD,QAAA,OAAO,GAAc,kBAAE,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/_micro.d.ts b/node_modules/@noble/ciphers/_micro.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6673e9e79d28f1559aaec30fd35adad62dac87d9 --- /dev/null +++ b/node_modules/@noble/ciphers/_micro.d.ts @@ -0,0 +1,41 @@ +import { type Cipher, type XorStream } from './utils.ts'; +export type ARXCipherN = ((key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => Cipher) & { + blockSize: number; + nonceLength: number; + tagLength: number; +}; +/** hsalsa hashes key and nonce into key' and nonce'. */ +export declare function hsalsa(s: Uint32Array, k: Uint32Array, i: Uint32Array, o32: Uint32Array): void; +/** hchacha hashes key and nonce into key' and nonce'. */ +export declare function hchacha(s: Uint32Array, k: Uint32Array, i: Uint32Array, o32: Uint32Array): void; +/** salsa20, 12-byte nonce. */ +export declare const salsa20: XorStream; +/** xsalsa20, 24-byte nonce. */ +export declare const xsalsa20: XorStream; +/** chacha20 non-RFC, original version by djb. 8-byte nonce, 8-byte counter. */ +export declare const chacha20orig: XorStream; +/** chacha20 RFC 8439 (IETF / TLS). 12-byte nonce, 4-byte counter. */ +export declare const chacha20: XorStream; +/** xchacha20 eXtended-nonce. https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha */ +export declare const xchacha20: XorStream; +/** 8-round chacha from the original paper. */ +export declare const chacha8: XorStream; +/** 12-round chacha from the original paper. */ +export declare const chacha12: XorStream; +/** Poly1305 polynomial MAC. Can be speed-up using BigUint64Array, at the cost of complexity. */ +export declare function poly1305(msg: Uint8Array, key: Uint8Array): Uint8Array; +/** xsalsa20-poly1305 eXtended-nonce (24 bytes) salsa. */ +export declare const xsalsa20poly1305: ARXCipherN; +/** Alias to `xsalsa20poly1305`. */ +export declare function secretbox(key: Uint8Array, nonce: Uint8Array): { + seal: (plaintext: Uint8Array) => Uint8Array; + open: (ciphertext: Uint8Array) => Uint8Array; +}; +export declare const _poly1305_aead: (fn: XorStream) => (key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => Cipher; +/** chacha20-poly1305 12-byte-nonce chacha. */ +export declare const chacha20poly1305: ARXCipherN; +/** + * XChaCha20-Poly1305 extended-nonce chacha. Can be safely used with random nonces (CSPRNG). + */ +export declare const xchacha20poly1305: ARXCipherN; +//# sourceMappingURL=_micro.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/_micro.d.ts.map b/node_modules/@noble/ciphers/_micro.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..71935edfd67909952a0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AU,EAAE,GAAG,EAAE,UAAU,GAAG,UAAU,CAcrE;AAuBD,yDAAyD;AACzD,eAAO,MAAM,gBAAgB,EAAE,UAsB9B,CAAC;AAEF,mCAAmC;AACnC,wBAAgB,SAAS,CACvB,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,UAAU,GAChB;IACD,IAAI,EAAE,CAAC,SAAS,EAAE,UAAU,KAAK,UAAU,CAAC;IAC5C,IAAI,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,UAAU,CAAC;CAC9C,CAGA;AAED,eAAO,MAAM,cAAc,GACxB,IAAI,SAAS,MACb,KAAK,UAAU,EAAE,OAAO,UAAU,EAAE,MAAM,UAAU,KAAG,MAgBvD,CAAC;AAEJ,8CAA8C;AAC9C,eAAO,MAAM,gBAAgB,EAAE,UAG9B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,UAG/B,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/_micro.js b/node_modules/@noble/ciphers/_micro.js new file mode 100644 index 0000000000000000000000000000000000000000..165ef95f09f0132b24480c756afd0124fd90dd61 --- /dev/null +++ b/node_modules/@noble/ciphers/_micro.js @@ -0,0 +1,260 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.xchacha20poly1305 = exports.chacha20poly1305 = exports._poly1305_aead = exports.xsalsa20poly1305 = exports.chacha12 = exports.chacha8 = exports.xchacha20 = exports.chacha20 = exports.chacha20orig = exports.xsalsa20 = exports.salsa20 = void 0; +exports.hsalsa = hsalsa; +exports.hchacha = hchacha; +exports.poly1305 = poly1305; +exports.secretbox = secretbox; +/** + * noble-ciphers-micro: more auditable, but 4x slower version of salsa20, chacha & poly1305. + * Implements the same algorithms that are present in other files, but without + * unrolled loops (https://en.wikipedia.org/wiki/Loop_unrolling). + * @module + */ +/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */ +// prettier-ignore +const _arx_ts_1 = require("./_arx.js"); +const utils_ts_1 = require("./utils.js"); +function bytesToNumberLE(bytes) { + (0, utils_ts_1.abytes)(bytes); + return (0, utils_ts_1.hexToNumber)((0, utils_ts_1.bytesToHex)(Uint8Array.from(bytes).reverse())); +} +function numberToBytesLE(n, len) { + return (0, utils_ts_1.numberToBytesBE)(n, len).reverse(); +} +function salsaQR(x, a, b, c, d) { + x[b] ^= (0, _arx_ts_1.rotl)((x[a] + x[d]) | 0, 7); + x[c] ^= (0, _arx_ts_1.rotl)((x[b] + x[a]) | 0, 9); + x[d] ^= (0, _arx_ts_1.rotl)((x[c] + x[b]) | 0, 13); + x[a] ^= (0, _arx_ts_1.rotl)((x[d] + x[c]) | 0, 18); +} +// prettier-ignore +function chachaQR(x, a, b, c, d) { + x[a] = (x[a] + x[b]) | 0; + x[d] = (0, _arx_ts_1.rotl)(x[d] ^ x[a], 16); + x[c] = (x[c] + x[d]) | 0; + x[b] = (0, _arx_ts_1.rotl)(x[b] ^ x[c], 12); + x[a] = (x[a] + x[b]) | 0; + x[d] = (0, _arx_ts_1.rotl)(x[d] ^ x[a], 8); + x[c] = (x[c] + x[d]) | 0; + x[b] = (0, _arx_ts_1.rotl)(x[b] ^ x[c], 7); +} +function salsaRound(x, rounds = 20) { + for (let r = 0; r < rounds; r += 2) { + salsaQR(x, 0, 4, 8, 12); + salsaQR(x, 5, 9, 13, 1); + salsaQR(x, 10, 14, 2, 6); + salsaQR(x, 15, 3, 7, 11); + salsaQR(x, 0, 1, 2, 3); + salsaQR(x, 5, 6, 7, 4); + salsaQR(x, 10, 11, 8, 9); + salsaQR(x, 15, 12, 13, 14); + } +} +function chachaRound(x, rounds = 20) { + for (let r = 0; r < rounds; r += 2) { + chachaQR(x, 0, 4, 8, 12); + chachaQR(x, 1, 5, 9, 13); + chachaQR(x, 2, 6, 10, 14); + chachaQR(x, 3, 7, 11, 15); + chachaQR(x, 0, 5, 10, 15); + chachaQR(x, 1, 6, 11, 12); + chachaQR(x, 2, 7, 8, 13); + chachaQR(x, 3, 4, 9, 14); + } +} +function salsaCore(s, k, n, out, cnt, rounds = 20) { + // prettier-ignore + const y = new Uint32Array([ + s[0], k[0], k[1], k[2], // "expa" Key Key Key + k[3], s[1], n[0], n[1], // Key "nd 3" Nonce Nonce + cnt, 0, s[2], k[4], // Pos. Pos. "2-by" Key + k[5], k[6], k[7], s[3], // Key Key Key "te k" + ]); + const x = y.slice(); + salsaRound(x, rounds); + for (let i = 0; i < 16; i++) + out[i] = (y[i] + x[i]) | 0; +} +/** hsalsa hashes key and nonce into key' and nonce'. */ +// prettier-ignore +function hsalsa(s, k, i, o32) { + const x = new Uint32Array([ + s[0], k[0], k[1], k[2], + k[3], s[1], i[0], i[1], + i[2], i[3], s[2], k[4], + k[5], k[6], k[7], s[3] + ]); + salsaRound(x, 20); + let oi = 0; + o32[oi++] = x[0]; + o32[oi++] = x[5]; + o32[oi++] = x[10]; + o32[oi++] = x[15]; + o32[oi++] = x[6]; + o32[oi++] = x[7]; + o32[oi++] = x[8]; + o32[oi++] = x[9]; +} +function chachaCore(s, k, n, out, cnt, rounds = 20) { + // prettier-ignore + const y = new Uint32Array([ + s[0], s[1], s[2], s[3], // "expa" "nd 3" "2-by" "te k" + k[0], k[1], k[2], k[3], // Key Key Key Key + k[4], k[5], k[6], k[7], // Key Key Key Key + cnt, n[0], n[1], n[2], // Counter Counter Nonce Nonce + ]); + const x = y.slice(); + chachaRound(x, rounds); + for (let i = 0; i < 16; i++) + out[i] = (y[i] + x[i]) | 0; +} +/** hchacha hashes key and nonce into key' and nonce'. */ +// prettier-ignore +function hchacha(s, k, i, o32) { + const x = new Uint32Array([ + s[0], s[1], s[2], s[3], + k[0], k[1], k[2], k[3], + k[4], k[5], k[6], k[7], + i[0], i[1], i[2], i[3], + ]); + chachaRound(x, 20); + let oi = 0; + o32[oi++] = x[0]; + o32[oi++] = x[1]; + o32[oi++] = x[2]; + o32[oi++] = x[3]; + o32[oi++] = x[12]; + o32[oi++] = x[13]; + o32[oi++] = x[14]; + o32[oi++] = x[15]; +} +/** salsa20, 12-byte nonce. */ +exports.salsa20 = (0, _arx_ts_1.createCipher)(salsaCore, { + allowShortKeys: true, + counterRight: true, +}); +/** xsalsa20, 24-byte nonce. */ +exports.xsalsa20 = (0, _arx_ts_1.createCipher)(salsaCore, { + counterRight: true, + extendNonceFn: hsalsa, +}); +/** chacha20 non-RFC, original version by djb. 8-byte nonce, 8-byte counter. */ +exports.chacha20orig = (0, _arx_ts_1.createCipher)(chachaCore, { + allowShortKeys: true, + counterRight: false, + counterLength: 8, +}); +/** chacha20 RFC 8439 (IETF / TLS). 12-byte nonce, 4-byte counter. */ +exports.chacha20 = (0, _arx_ts_1.createCipher)(chachaCore, { + counterRight: false, + counterLength: 4, +}); +/** xchacha20 eXtended-nonce. https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha */ +exports.xchacha20 = (0, _arx_ts_1.createCipher)(chachaCore, { + counterRight: false, + counterLength: 8, + extendNonceFn: hchacha, +}); +/** 8-round chacha from the original paper. */ +exports.chacha8 = (0, _arx_ts_1.createCipher)(chachaCore, { + counterRight: false, + counterLength: 4, + rounds: 8, +}); +/** 12-round chacha from the original paper. */ +exports.chacha12 = (0, _arx_ts_1.createCipher)(chachaCore, { + counterRight: false, + counterLength: 4, + rounds: 12, +}); +const POW_2_130_5 = BigInt(2) ** BigInt(130) - BigInt(5); +const POW_2_128_1 = BigInt(2) ** BigInt(16 * 8) - BigInt(1); +const CLAMP_R = BigInt('0x0ffffffc0ffffffc0ffffffc0fffffff'); +const _0 = BigInt(0); +const _1 = BigInt(1); +/** Poly1305 polynomial MAC. Can be speed-up using BigUint64Array, at the cost of complexity. */ +function poly1305(msg, key) { + (0, utils_ts_1.abytes)(msg); + (0, utils_ts_1.abytes)(key, 32); + let acc = _0; + const r = bytesToNumberLE(key.subarray(0, 16)) & CLAMP_R; + const s = bytesToNumberLE(key.subarray(16)); + // Process by 16 byte chunks + for (let i = 0; i < msg.length; i += 16) { + const m = msg.subarray(i, i + 16); + const n = bytesToNumberLE(m) | (_1 << BigInt(8 * m.length)); + acc = ((acc + n) * r) % POW_2_130_5; + } + const res = (acc + s) & POW_2_128_1; + return numberToBytesLE(res, 16); +} +function computeTag(fn, key, nonce, ciphertext, AAD) { + const res = []; + if (AAD) { + res.push(AAD); + const leftover = AAD.length % 16; + if (leftover > 0) + res.push(new Uint8Array(16 - leftover)); + } + res.push(ciphertext); + const leftover = ciphertext.length % 16; + if (leftover > 0) + res.push(new Uint8Array(16 - leftover)); + res.push((0, utils_ts_1.u64Lengths)(ciphertext.length, AAD ? AAD.length : 0, true)); + const authKey = fn(key, nonce, new Uint8Array(32)); + return poly1305((0, utils_ts_1.concatBytes)(...res), authKey); +} +/** xsalsa20-poly1305 eXtended-nonce (24 bytes) salsa. */ +exports.xsalsa20poly1305 = (0, utils_ts_1.wrapCipher)({ blockSize: 64, nonceLength: 24, tagLength: 16 }, function xsalsapoly(key, nonce) { + return { + encrypt(plaintext) { + const m = (0, utils_ts_1.concatBytes)(new Uint8Array(32), plaintext); + const c = (0, exports.xsalsa20)(key, nonce, m); + const authKey = c.subarray(0, 32); + const data = c.subarray(32); + const tag = poly1305(data, authKey); + return (0, utils_ts_1.concatBytes)(tag, data); + }, + decrypt(ciphertext) { + const c = (0, utils_ts_1.concatBytes)(new Uint8Array(16), ciphertext); + const passedTag = c.subarray(16, 32); + const authKey = (0, exports.xsalsa20)(key, nonce, new Uint8Array(32)); + const tag = poly1305(c.subarray(32), authKey); + if (!(0, utils_ts_1.equalBytes)(tag, passedTag)) + throw new Error('invalid poly1305 tag'); + return (0, exports.xsalsa20)(key, nonce, c).subarray(32); + }, + }; +}); +/** Alias to `xsalsa20poly1305`. */ +function secretbox(key, nonce) { + const xs = (0, exports.xsalsa20poly1305)(key, nonce); + return { seal: xs.encrypt, open: xs.decrypt }; +} +const _poly1305_aead = (fn) => (key, nonce, AAD) => { + const tagLength = 16; + return { + encrypt(plaintext) { + const data = fn(key, nonce, plaintext, undefined, 1); // stream from i=1 + const tag = computeTag(fn, key, nonce, data, AAD); + return (0, utils_ts_1.concatBytes)(data, tag); + }, + decrypt(ciphertext) { + const passedTag = ciphertext.subarray(-tagLength); + const data = ciphertext.subarray(0, -tagLength); + const tag = computeTag(fn, key, nonce, data, AAD); + if (!(0, utils_ts_1.equalBytes)(tag, passedTag)) + throw new Error('invalid poly1305 tag'); + return fn(key, nonce, data, undefined, 1); // stream from i=1 + }, + }; +}; +exports._poly1305_aead = _poly1305_aead; +/** chacha20-poly1305 12-byte-nonce chacha. */ +exports.chacha20poly1305 = (0, utils_ts_1.wrapCipher)({ blockSize: 64, nonceLength: 12, tagLength: 16 }, (0, exports._poly1305_aead)(exports.chacha20)); +/** + * XChaCha20-Poly1305 extended-nonce chacha. Can be safely used with random nonces (CSPRNG). + */ +exports.xchacha20poly1305 = (0, utils_ts_1.wrapCipher)({ blockSize: 64, nonceLength: 24, tagLength: 16 }, (0, exports._poly1305_aead)(exports.xchacha20)); +//# sourceMappingURL=_micro.js.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/_micro.js.map b/node_modules/@noble/ciphers/_micro.js.map new file mode 100644 index 0000000000000000000000000000000000000000..152ccf66fb604262261f2303ef3ef3f39925afb9 --- /dev/null +++ b/node_modules/@noble/ciphers/_micro.js.map @@ -0,0 +1 @@ +{"version":3,"file":"_micro.js","sourceRoot":"","sources":["src/_micro.ts"],"names":[],"mappings":";;;AAmGA,wBAaC;AAwBD,0BAaC;AAuDD,4BAcC;AAiDD,8BASC;AApRD;;;;;GAKG;AACH,uEAAuE;AACvE,kBAAkB;AAClB,uCAA+C;AAC/C,yCAWoB;AAQpB,SAAS,eAAe,CAAC,KAAiB;IACxC,IAAA,iBAAM,EAAC,KAAK,CAAC,CAAC;IACd,OAAO,IAAA,sBAAW,EAAC,IAAA,qBAAU,EAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AACnE,CAAC;AAED,SAAS,eAAe,CAAC,CAAkB,EA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/ciphers/_poly1305.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..921dd3bbb8d753016114539bbb14f80d2b475100 --- /dev/null +++ b/node_modules/@noble/ciphers/_poly1305.d.ts @@ -0,0 +1,29 @@ +/** + * Poly1305 ([PDF](https://cr.yp.to/mac/poly1305-20050329.pdf), + * [wiki](https://en.wikipedia.org/wiki/Poly1305)) + * is a fast and parallel secret-key message-authentication code suitable for + * a wide variety of applications. It was standardized in + * [RFC 8439](https://datatracker.ietf.org/doc/html/rfc8439) and is now used in TLS 1.3. + * + * Polynomial MACs are not perfect for every situation: + * they lack Random Key Robustness: the MAC can be forged, and can't be used in PAKE schemes. + * See [invisible salamanders attack](https://keymaterial.net/2020/09/07/invisible-salamanders-in-aes-gcm-siv/). + * To combat invisible salamanders, `hash(key)` can be included in ciphertext, + * however, this would violate ciphertext indistinguishability: + * an attacker would know which key was used - so `HKDF(key, i)` + * could be used instead. + * + * Check out [original website](https://cr.yp.to/mac.html). + * @module + */ +import { Hash, type Input } from './utils.ts'; +export type CHash = ReturnType; +export declare function wrapConstructorWithKey>(hashCons: (key: Input) => Hash): { + (msg: Input, key: Input): Uint8Array; + outputLen: number; + blockLen: number; + create(key: Input): Hash; +}; +/** Poly1305 MAC from RFC 8439. */ +export declare const poly1305: CHash; +//# sourceMappingURL=_poly1305.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/_poly1305.d.ts.map b/node_modules/@noble/ciphers/_poly1305.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..2c3597eea8aeaa162ccf3956821c62eeddb55c4c --- /dev/null +++ b/node_modules/@noble/ciphers/_poly1305.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"_poly1305.d.ts","sourceRoot":"","sources":["src/_poly1305.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,IAAI,EAAE,KAAK,KAAK,EAA4C,MAAM,YAAY,CAAC;AA4QxF,MAAM,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAC9D,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC,EACtD,QAAQ,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,GAChC;IACD,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,GAAG,UAAU,CAAC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;CAC7B,CAOA;AAED,kCAAkC;AAClC,eAAO,MAAM,QAAQ,EAAE,KAA0D,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/_poly1305.js b/node_modules/@noble/ciphers/_poly1305.js new file mode 100644 index 0000000000000000000000000000000000000000..2e6a5b2a0c24bdf9c70ed7fd8884704a36669e35 --- /dev/null +++ b/node_modules/@noble/ciphers/_poly1305.js @@ -0,0 +1,281 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.poly1305 = void 0; +exports.wrapConstructorWithKey = wrapConstructorWithKey; +/** + * Poly1305 ([PDF](https://cr.yp.to/mac/poly1305-20050329.pdf), + * [wiki](https://en.wikipedia.org/wiki/Poly1305)) + * is a fast and parallel secret-key message-authentication code suitable for + * a wide variety of applications. It was standardized in + * [RFC 8439](https://datatracker.ietf.org/doc/html/rfc8439) and is now used in TLS 1.3. + * + * Polynomial MACs are not perfect for every situation: + * they lack Random Key Robustness: the MAC can be forged, and can't be used in PAKE schemes. + * See [invisible salamanders attack](https://keymaterial.net/2020/09/07/invisible-salamanders-in-aes-gcm-siv/). + * To combat invisible salamanders, `hash(key)` can be included in ciphertext, + * however, this would violate ciphertext indistinguishability: + * an attacker would know which key was used - so `HKDF(key, i)` + * could be used instead. + * + * Check out [original website](https://cr.yp.to/mac.html). + * @module + */ +const utils_ts_1 = require("./utils.js"); +// Based on Public Domain poly1305-donna https://github.com/floodyberry/poly1305-donna +const u8to16 = (a, i) => (a[i++] & 0xff) | ((a[i++] & 0xff) << 8); +class Poly1305 { + constructor(key) { + this.blockLen = 16; + this.outputLen = 16; + this.buffer = new Uint8Array(16); + this.r = new Uint16Array(10); + this.h = new Uint16Array(10); + this.pad = new Uint16Array(8); + this.pos = 0; + this.finished = false; + key = (0, utils_ts_1.toBytes)(key); + (0, utils_ts_1.abytes)(key, 32); + const t0 = u8to16(key, 0); + const t1 = u8to16(key, 2); + const t2 = u8to16(key, 4); + const t3 = u8to16(key, 6); + const t4 = u8to16(key, 8); + const t5 = u8to16(key, 10); + const t6 = u8to16(key, 12); + const t7 = u8to16(key, 14); + // https://github.com/floodyberry/poly1305-donna/blob/e6ad6e091d30d7f4ec2d4f978be1fcfcbce72781/poly1305-donna-16.h#L47 + this.r[0] = t0 & 0x1fff; + this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff; + this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03; + this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff; + this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff; + this.r[5] = (t4 >>> 1) & 0x1ffe; + this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff; + this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81; + this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff; + this.r[9] = (t7 >>> 5) & 0x007f; + for (let i = 0; i < 8; i++) + this.pad[i] = u8to16(key, 16 + 2 * i); + } + process(data, offset, isLast = false) { + const hibit = isLast ? 0 : 1 << 11; + const { h, r } = this; + const r0 = r[0]; + const r1 = r[1]; + const r2 = r[2]; + const r3 = r[3]; + const r4 = r[4]; + const r5 = r[5]; + const r6 = r[6]; + const r7 = r[7]; + const r8 = r[8]; + const r9 = r[9]; + const t0 = u8to16(data, offset + 0); + const t1 = u8to16(data, offset + 2); + const t2 = u8to16(data, offset + 4); + const t3 = u8to16(data, offset + 6); + const t4 = u8to16(data, offset + 8); + const t5 = u8to16(data, offset + 10); + const t6 = u8to16(data, offset + 12); + const t7 = u8to16(data, offset + 14); + let h0 = h[0] + (t0 & 0x1fff); + let h1 = h[1] + (((t0 >>> 13) | (t1 << 3)) & 0x1fff); + let h2 = h[2] + (((t1 >>> 10) | (t2 << 6)) & 0x1fff); + let h3 = h[3] + (((t2 >>> 7) | (t3 << 9)) & 0x1fff); + let h4 = h[4] + (((t3 >>> 4) | (t4 << 12)) & 0x1fff); + let h5 = h[5] + ((t4 >>> 1) & 0x1fff); + let h6 = h[6] + (((t4 >>> 14) | (t5 << 2)) & 0x1fff); + let h7 = h[7] + (((t5 >>> 11) | (t6 << 5)) & 0x1fff); + let h8 = h[8] + (((t6 >>> 8) | (t7 << 8)) & 0x1fff); + let h9 = h[9] + ((t7 >>> 5) | hibit); + let c = 0; + let d0 = c + h0 * r0 + h1 * (5 * r9) + h2 * (5 * r8) + h3 * (5 * r7) + h4 * (5 * r6); + c = d0 >>> 13; + d0 &= 0x1fff; + d0 += h5 * (5 * r5) + h6 * (5 * r4) + h7 * (5 * r3) + h8 * (5 * r2) + h9 * (5 * r1); + c += d0 >>> 13; + d0 &= 0x1fff; + let d1 = c + h0 * r1 + h1 * r0 + h2 * (5 * r9) + h3 * (5 * r8) + h4 * (5 * r7); + c = d1 >>> 13; + d1 &= 0x1fff; + d1 += h5 * (5 * r6) + h6 * (5 * r5) + h7 * (5 * r4) + h8 * (5 * r3) + h9 * (5 * r2); + c += d1 >>> 13; + d1 &= 0x1fff; + let d2 = c + h0 * r2 + h1 * r1 + h2 * r0 + h3 * (5 * r9) + h4 * (5 * r8); + c = d2 >>> 13; + d2 &= 0x1fff; + d2 += h5 * (5 * r7) + h6 * (5 * r6) + h7 * (5 * r5) + h8 * (5 * r4) + h9 * (5 * r3); + c += d2 >>> 13; + d2 &= 0x1fff; + let d3 = c + h0 * r3 + h1 * r2 + h2 * r1 + h3 * r0 + h4 * (5 * r9); + c = d3 >>> 13; + d3 &= 0x1fff; + d3 += h5 * (5 * r8) + h6 * (5 * r7) + h7 * (5 * r6) + h8 * (5 * r5) + h9 * (5 * r4); + c += d3 >>> 13; + d3 &= 0x1fff; + let d4 = c + h0 * r4 + h1 * r3 + h2 * r2 + h3 * r1 + h4 * r0; + c = d4 >>> 13; + d4 &= 0x1fff; + d4 += h5 * (5 * r9) + h6 * (5 * r8) + h7 * (5 * r7) + h8 * (5 * r6) + h9 * (5 * r5); + c += d4 >>> 13; + d4 &= 0x1fff; + let d5 = c + h0 * r5 + h1 * r4 + h2 * r3 + h3 * r2 + h4 * r1; + c = d5 >>> 13; + d5 &= 0x1fff; + d5 += h5 * r0 + h6 * (5 * r9) + h7 * (5 * r8) + h8 * (5 * r7) + h9 * (5 * r6); + c += d5 >>> 13; + d5 &= 0x1fff; + let d6 = c + h0 * r6 + h1 * r5 + h2 * r4 + h3 * r3 + h4 * r2; + c = d6 >>> 13; + d6 &= 0x1fff; + d6 += h5 * r1 + h6 * r0 + h7 * (5 * r9) + h8 * (5 * r8) + h9 * (5 * r7); + c += d6 >>> 13; + d6 &= 0x1fff; + let d7 = c + h0 * r7 + h1 * r6 + h2 * r5 + h3 * r4 + h4 * r3; + c = d7 >>> 13; + d7 &= 0x1fff; + d7 += h5 * r2 + h6 * r1 + h7 * r0 + h8 * (5 * r9) + h9 * (5 * r8); + c += d7 >>> 13; + d7 &= 0x1fff; + let d8 = c + h0 * r8 + h1 * r7 + h2 * r6 + h3 * r5 + h4 * r4; + c = d8 >>> 13; + d8 &= 0x1fff; + d8 += h5 * r3 + h6 * r2 + h7 * r1 + h8 * r0 + h9 * (5 * r9); + c += d8 >>> 13; + d8 &= 0x1fff; + let d9 = c + h0 * r9 + h1 * r8 + h2 * r7 + h3 * r6 + h4 * r5; + c = d9 >>> 13; + d9 &= 0x1fff; + d9 += h5 * r4 + h6 * r3 + h7 * r2 + h8 * r1 + h9 * r0; + c += d9 >>> 13; + d9 &= 0x1fff; + c = ((c << 2) + c) | 0; + c = (c + d0) | 0; + d0 = c & 0x1fff; + c = c >>> 13; + d1 += c; + h[0] = d0; + h[1] = d1; + h[2] = d2; + h[3] = d3; + h[4] = d4; + h[5] = d5; + h[6] = d6; + h[7] = d7; + h[8] = d8; + h[9] = d9; + } + finalize() { + const { h, pad } = this; + const g = new Uint16Array(10); + let c = h[1] >>> 13; + h[1] &= 0x1fff; + for (let i = 2; i < 10; i++) { + h[i] += c; + c = h[i] >>> 13; + h[i] &= 0x1fff; + } + h[0] += c * 5; + c = h[0] >>> 13; + h[0] &= 0x1fff; + h[1] += c; + c = h[1] >>> 13; + h[1] &= 0x1fff; + h[2] += c; + g[0] = h[0] + 5; + c = g[0] >>> 13; + g[0] &= 0x1fff; + for (let i = 1; i < 10; i++) { + g[i] = h[i] + c; + c = g[i] >>> 13; + g[i] &= 0x1fff; + } + g[9] -= 1 << 13; + let mask = (c ^ 1) - 1; + for (let i = 0; i < 10; i++) + g[i] &= mask; + mask = ~mask; + for (let i = 0; i < 10; i++) + h[i] = (h[i] & mask) | g[i]; + h[0] = (h[0] | (h[1] << 13)) & 0xffff; + h[1] = ((h[1] >>> 3) | (h[2] << 10)) & 0xffff; + h[2] = ((h[2] >>> 6) | (h[3] << 7)) & 0xffff; + h[3] = ((h[3] >>> 9) | (h[4] << 4)) & 0xffff; + h[4] = ((h[4] >>> 12) | (h[5] << 1) | (h[6] << 14)) & 0xffff; + h[5] = ((h[6] >>> 2) | (h[7] << 11)) & 0xffff; + h[6] = ((h[7] >>> 5) | (h[8] << 8)) & 0xffff; + h[7] = ((h[8] >>> 8) | (h[9] << 5)) & 0xffff; + let f = h[0] + pad[0]; + h[0] = f & 0xffff; + for (let i = 1; i < 8; i++) { + f = (((h[i] + pad[i]) | 0) + (f >>> 16)) | 0; + h[i] = f & 0xffff; + } + (0, utils_ts_1.clean)(g); + } + update(data) { + (0, utils_ts_1.aexists)(this); + data = (0, utils_ts_1.toBytes)(data); + (0, utils_ts_1.abytes)(data); + const { buffer, blockLen } = this; + const len = data.length; + for (let pos = 0; pos < len;) { + const take = Math.min(blockLen - this.pos, len - pos); + // Fast path: we have at least one block in input + if (take === blockLen) { + for (; blockLen <= len - pos; pos += blockLen) + this.process(data, pos); + continue; + } + buffer.set(data.subarray(pos, pos + take), this.pos); + this.pos += take; + pos += take; + if (this.pos === blockLen) { + this.process(buffer, 0, false); + this.pos = 0; + } + } + return this; + } + destroy() { + (0, utils_ts_1.clean)(this.h, this.r, this.buffer, this.pad); + } + digestInto(out) { + (0, utils_ts_1.aexists)(this); + (0, utils_ts_1.aoutput)(out, this); + this.finished = true; + const { buffer, h } = this; + let { pos } = this; + if (pos) { + buffer[pos++] = 1; + for (; pos < 16; pos++) + buffer[pos] = 0; + this.process(buffer, 0, true); + } + this.finalize(); + let opos = 0; + for (let i = 0; i < 8; i++) { + out[opos++] = h[i] >>> 0; + out[opos++] = h[i] >>> 8; + } + return out; + } + digest() { + const { buffer, outputLen } = this; + this.digestInto(buffer); + const res = buffer.slice(0, outputLen); + this.destroy(); + return res; + } +} +function wrapConstructorWithKey(hashCons) { + const hashC = (msg, key) => hashCons(key).update((0, utils_ts_1.toBytes)(msg)).digest(); + const tmp = hashCons(new Uint8Array(32)); + hashC.outputLen = tmp.outputLen; + hashC.blockLen = tmp.blockLen; + hashC.create = (key) => hashCons(key); + return hashC; +} +/** Poly1305 MAC from RFC 8439. */ +exports.poly1305 = wrapConstructorWithKey((key) => new Poly1305(key)); +//# sourceMappingURL=_poly1305.js.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/_poly1305.js.map b/node_modules/@noble/ciphers/_poly1305.js.map new file mode 100644 index 0000000000000000000000000000000000000000..4bcbc2d387cd9580560f1a1ba1134e72639c8d47 --- /dev/null +++ b/node_modules/@noble/ciphers/_poly1305.js.map @@ -0,0 +1 @@ +{"version":3,"file":"_poly1305.js","sourceRoot":"","sources":["src/_poly1305.ts"],"names":[],"mappings":";;;AA+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AAQ,CAAC;IAC9B,KAAK,CAAC,MAAM,GAAG,CAAC,GAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC7C,OAAO,KAAK,CAAC;AACf,CAAC;AAED,kCAAkC;AACrB,QAAA,QAAQ,GAAU,sBAAsB,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/_polyval.d.ts b/node_modules/@noble/ciphers/_polyval.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..df7d9de768a1cf7f8720a9319d995ff786ada6e1 --- /dev/null +++ b/node_modules/@noble/ciphers/_polyval.d.ts @@ -0,0 +1,33 @@ +/** + * GHash from AES-GCM and its little-endian "mirror image" Polyval from AES-SIV. + * + * Implemented in terms of GHash with conversion function for keys + * GCM GHASH from + * [NIST SP800-38d](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf), + * SIV from + * [RFC 8452](https://datatracker.ietf.org/doc/html/rfc8452). + * + * GHASH modulo: x^128 + x^7 + x^2 + x + 1 + * POLYVAL modulo: x^128 + x^127 + x^126 + x^121 + 1 + * + * @module + */ +import { Hash, type Input } from './utils.ts'; +/** + * `mulX_POLYVAL(ByteReverse(H))` from spec + * @param k mutated in place + */ +export declare function _toGHASHKey(k: Uint8Array): Uint8Array; +export type CHashPV = ReturnType; +declare function wrapConstructorWithKey>(hashCons: (key: Input, expectedLength?: number) => Hash): { + (msg: Input, key: Input): Uint8Array; + outputLen: number; + blockLen: number; + create(key: Input, expectedLength?: number): Hash; +}; +/** GHash MAC for AES-GCM. */ +export declare const ghash: CHashPV; +/** Polyval MAC for AES-SIV. */ +export declare const polyval: CHashPV; +export {}; +//# sourceMappingURL=_polyval.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/_polyval.d.ts.map b/node_modules/@noble/ciphers/_polyval.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..2b69670c933490f9e2946bfa462180a65a27800f --- /dev/null +++ b/node_modules/@noble/ciphers/_polyval.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"_polyval.d.ts","sourceRoot":"","sources":["src/_polyval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAEyB,IAAI,EAAE,KAAK,KAAK,EAC/C,MAAM,YAAY,CAAC;AA6BpB;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,UAAU,GAAG,UAAU,CAYrD;AAiLD,MAAM,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAChE,iBAAS,sBAAsB,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC,EAC/C,QAAQ,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,cAAc,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,GACzD;IACD,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,GAAG,UAAU,CAAC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,GAAG,EAAE,KAAK,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;CACtD,CAQA;AAED,6BAA6B;AAC7B,eAAO,MAAM,KAAK,EAAE,OAEnB,CAAC;AAEF,+BAA+B;AAC/B,eAAO,MAAM,OAAO,EAAE,OAErB,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/_polyval.js b/node_modules/@noble/ciphers/_polyval.js new file mode 100644 index 0000000000000000000000000000000000000000..3cee43906c835028c8083bce49ee5fa2523c5b41 --- /dev/null +++ b/node_modules/@noble/ciphers/_polyval.js @@ -0,0 +1,233 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.polyval = exports.ghash = void 0; +exports._toGHASHKey = _toGHASHKey; +/** + * GHash from AES-GCM and its little-endian "mirror image" Polyval from AES-SIV. + * + * Implemented in terms of GHash with conversion function for keys + * GCM GHASH from + * [NIST SP800-38d](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf), + * SIV from + * [RFC 8452](https://datatracker.ietf.org/doc/html/rfc8452). + * + * GHASH modulo: x^128 + x^7 + x^2 + x + 1 + * POLYVAL modulo: x^128 + x^127 + x^126 + x^121 + 1 + * + * @module + */ +// prettier-ignore +const utils_ts_1 = require("./utils.js"); +const BLOCK_SIZE = 16; +// TODO: rewrite +// temporary padding buffer +const ZEROS16 = /* @__PURE__ */ new Uint8Array(16); +const ZEROS32 = (0, utils_ts_1.u32)(ZEROS16); +const POLY = 0xe1; // v = 2*v % POLY +// v = 2*v % POLY +// NOTE: because x + x = 0 (add/sub is same), mul2(x) != x+x +// We can multiply any number using montgomery ladder and this function (works as double, add is simple xor) +const mul2 = (s0, s1, s2, s3) => { + const hiBit = s3 & 1; + return { + s3: (s2 << 31) | (s3 >>> 1), + s2: (s1 << 31) | (s2 >>> 1), + s1: (s0 << 31) | (s1 >>> 1), + s0: (s0 >>> 1) ^ ((POLY << 24) & -(hiBit & 1)), // reduce % poly + }; +}; +const swapLE = (n) => (((n >>> 0) & 0xff) << 24) | + (((n >>> 8) & 0xff) << 16) | + (((n >>> 16) & 0xff) << 8) | + ((n >>> 24) & 0xff) | + 0; +/** + * `mulX_POLYVAL(ByteReverse(H))` from spec + * @param k mutated in place + */ +function _toGHASHKey(k) { + k.reverse(); + const hiBit = k[15] & 1; + // k >>= 1 + let carry = 0; + for (let i = 0; i < k.length; i++) { + const t = k[i]; + k[i] = (t >>> 1) | carry; + carry = (t & 1) << 7; + } + k[0] ^= -hiBit & 0xe1; // if (hiBit) n ^= 0xe1000000000000000000000000000000; + return k; +} +const estimateWindow = (bytes) => { + if (bytes > 64 * 1024) + return 8; + if (bytes > 1024) + return 4; + return 2; +}; +class GHASH { + // We select bits per window adaptively based on expectedLength + constructor(key, expectedLength) { + this.blockLen = BLOCK_SIZE; + this.outputLen = BLOCK_SIZE; + this.s0 = 0; + this.s1 = 0; + this.s2 = 0; + this.s3 = 0; + this.finished = false; + key = (0, utils_ts_1.toBytes)(key); + (0, utils_ts_1.abytes)(key, 16); + const kView = (0, utils_ts_1.createView)(key); + let k0 = kView.getUint32(0, false); + let k1 = kView.getUint32(4, false); + let k2 = kView.getUint32(8, false); + let k3 = kView.getUint32(12, false); + // generate table of doubled keys (half of montgomery ladder) + const doubles = []; + for (let i = 0; i < 128; i++) { + doubles.push({ s0: swapLE(k0), s1: swapLE(k1), s2: swapLE(k2), s3: swapLE(k3) }); + ({ s0: k0, s1: k1, s2: k2, s3: k3 } = mul2(k0, k1, k2, k3)); + } + const W = estimateWindow(expectedLength || 1024); + if (![1, 2, 4, 8].includes(W)) + throw new Error('ghash: invalid window size, expected 2, 4 or 8'); + this.W = W; + const bits = 128; // always 128 bits; + const windows = bits / W; + const windowSize = (this.windowSize = 2 ** W); + const items = []; + // Create precompute table for window of W bits + for (let w = 0; w < windows; w++) { + // truth table: 00, 01, 10, 11 + for (let byte = 0; byte < windowSize; byte++) { + // prettier-ignore + let s0 = 0, s1 = 0, s2 = 0, s3 = 0; + for (let j = 0; j < W; j++) { + const bit = (byte >>> (W - j - 1)) & 1; + if (!bit) + continue; + const { s0: d0, s1: d1, s2: d2, s3: d3 } = doubles[W * w + j]; + (s0 ^= d0), (s1 ^= d1), (s2 ^= d2), (s3 ^= d3); + } + items.push({ s0, s1, s2, s3 }); + } + } + this.t = items; + } + _updateBlock(s0, s1, s2, s3) { + (s0 ^= this.s0), (s1 ^= this.s1), (s2 ^= this.s2), (s3 ^= this.s3); + const { W, t, windowSize } = this; + // prettier-ignore + let o0 = 0, o1 = 0, o2 = 0, o3 = 0; + const mask = (1 << W) - 1; // 2**W will kill performance. + let w = 0; + for (const num of [s0, s1, s2, s3]) { + for (let bytePos = 0; bytePos < 4; bytePos++) { + const byte = (num >>> (8 * bytePos)) & 0xff; + for (let bitPos = 8 / W - 1; bitPos >= 0; bitPos--) { + const bit = (byte >>> (W * bitPos)) & mask; + const { s0: e0, s1: e1, s2: e2, s3: e3 } = t[w * windowSize + bit]; + (o0 ^= e0), (o1 ^= e1), (o2 ^= e2), (o3 ^= e3); + w += 1; + } + } + } + this.s0 = o0; + this.s1 = o1; + this.s2 = o2; + this.s3 = o3; + } + update(data) { + (0, utils_ts_1.aexists)(this); + data = (0, utils_ts_1.toBytes)(data); + (0, utils_ts_1.abytes)(data); + const b32 = (0, utils_ts_1.u32)(data); + const blocks = Math.floor(data.length / BLOCK_SIZE); + const left = data.length % BLOCK_SIZE; + for (let i = 0; i < blocks; i++) { + this._updateBlock(b32[i * 4 + 0], b32[i * 4 + 1], b32[i * 4 + 2], b32[i * 4 + 3]); + } + if (left) { + ZEROS16.set(data.subarray(blocks * BLOCK_SIZE)); + this._updateBlock(ZEROS32[0], ZEROS32[1], ZEROS32[2], ZEROS32[3]); + (0, utils_ts_1.clean)(ZEROS32); // clean tmp buffer + } + return this; + } + destroy() { + const { t } = this; + // clean precompute table + for (const elm of t) { + (elm.s0 = 0), (elm.s1 = 0), (elm.s2 = 0), (elm.s3 = 0); + } + } + digestInto(out) { + (0, utils_ts_1.aexists)(this); + (0, utils_ts_1.aoutput)(out, this); + this.finished = true; + const { s0, s1, s2, s3 } = this; + const o32 = (0, utils_ts_1.u32)(out); + o32[0] = s0; + o32[1] = s1; + o32[2] = s2; + o32[3] = s3; + return out; + } + digest() { + const res = new Uint8Array(BLOCK_SIZE); + this.digestInto(res); + this.destroy(); + return res; + } +} +class Polyval extends GHASH { + constructor(key, expectedLength) { + key = (0, utils_ts_1.toBytes)(key); + (0, utils_ts_1.abytes)(key); + const ghKey = _toGHASHKey((0, utils_ts_1.copyBytes)(key)); + super(ghKey, expectedLength); + (0, utils_ts_1.clean)(ghKey); + } + update(data) { + data = (0, utils_ts_1.toBytes)(data); + (0, utils_ts_1.aexists)(this); + const b32 = (0, utils_ts_1.u32)(data); + const left = data.length % BLOCK_SIZE; + const blocks = Math.floor(data.length / BLOCK_SIZE); + for (let i = 0; i < blocks; i++) { + this._updateBlock(swapLE(b32[i * 4 + 3]), swapLE(b32[i * 4 + 2]), swapLE(b32[i * 4 + 1]), swapLE(b32[i * 4 + 0])); + } + if (left) { + ZEROS16.set(data.subarray(blocks * BLOCK_SIZE)); + this._updateBlock(swapLE(ZEROS32[3]), swapLE(ZEROS32[2]), swapLE(ZEROS32[1]), swapLE(ZEROS32[0])); + (0, utils_ts_1.clean)(ZEROS32); + } + return this; + } + digestInto(out) { + (0, utils_ts_1.aexists)(this); + (0, utils_ts_1.aoutput)(out, this); + this.finished = true; + // tmp ugly hack + const { s0, s1, s2, s3 } = this; + const o32 = (0, utils_ts_1.u32)(out); + o32[0] = s0; + o32[1] = s1; + o32[2] = s2; + o32[3] = s3; + return out.reverse(); + } +} +function wrapConstructorWithKey(hashCons) { + const hashC = (msg, key) => hashCons(key, msg.length).update((0, utils_ts_1.toBytes)(msg)).digest(); + const tmp = hashCons(new Uint8Array(16), 0); + hashC.outputLen = tmp.outputLen; + hashC.blockLen = tmp.blockLen; + hashC.create = (key, expectedLength) => hashCons(key, expectedLength); + return hashC; +} +/** GHash MAC for AES-GCM. */ +exports.ghash = wrapConstructorWithKey((key, expectedLength) => new GHASH(key, expectedLength)); +/** Polyval MAC for AES-SIV. */ +exports.polyval = wrapConstructorWithKey((key, expectedLength) => new Polyval(key, expectedLength)); +//# sourceMappingURL=_polyval.js.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/_polyval.js.map b/node_modules/@noble/ciphers/_polyval.js.map new file mode 100644 index 0000000000000000000000000000000000000000..4f2b9ffb1de8db142a5ab1dae1e1529c981c99cb --- /dev/null +++ b/node_modules/@noble/ciphers/_polyval.js.map @@ -0,0 +1 @@ +{"version":3,"file":"_polyval.js","sourceRoot":"","sources":["src/_polyval.ts"],"names":[],"mappings":";;;AAmDA,kCAYC;AA/DD;;;;;;;;;;;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GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,IAAA,kBAAO,EAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAC1D,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5C,KAAK,CAAC,SAAS,GAAG,GAAG,CAAC,SAAS,CAAC;IAChC,KAAK,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;IAC9B,KAAK,CAAC,MAAM,GAAG,CAAC,GAAU,EAAE,cAAuB,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;IACtF,OAAO,KAAK,CAAC;AACf,CAAC;AAED,6BAA6B;AAChB,QAAA,KAAK,GAAY,sBAAsB,CAClD,CAAC,GAAG,EAAE,cAAc,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,GAAG,EAAE,cAAc,CAAC,CACxD,CAAC;AAEF,+BAA+B;AAClB,QAAA,OAAO,GAAY,sBAAsB,CACpD,CAAC,GAAG,EAAE,cAAc,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,GAAG,EAAE,cAAc,CAAC,CAC1D,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/aes.d.ts b/node_modules/@noble/ciphers/aes.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..010a88a602e2afe7acd057501fe4327a738644f8 --- /dev/null +++ b/node_modules/@noble/ciphers/aes.d.ts @@ -0,0 +1,117 @@ +import { type Cipher, type CipherWithOutput } from './utils.ts'; +/** Key expansion used in CTR. */ +declare function expandKeyLE(key: Uint8Array): Uint32Array; +declare function expandKeyDecLE(key: Uint8Array): Uint32Array; +declare function encrypt(xk: Uint32Array, s0: number, s1: number, s2: number, s3: number): { + s0: number; + s1: number; + s2: number; + s3: number; +}; +declare function decrypt(xk: Uint32Array, s0: number, s1: number, s2: number, s3: number): { + s0: number; + s1: number; + s2: number; + s3: number; +}; +declare function ctrCounter(xk: Uint32Array, nonce: Uint8Array, src: Uint8Array, dst?: Uint8Array): Uint8Array; +declare function ctr32(xk: Uint32Array, isLE: boolean, nonce: Uint8Array, src: Uint8Array, dst?: Uint8Array): Uint8Array; +/** + * CTR: counter mode. Creates stream cipher. + * Requires good IV. Parallelizable. OK, but no MAC. + */ +export declare const ctr: ((key: Uint8Array, nonce: Uint8Array) => CipherWithOutput) & { + blockSize: number; + nonceLength: number; +}; +/** Options for ECB and CBC. */ +export type BlockOpts = { + disablePadding?: boolean; +}; +/** + * ECB: Electronic CodeBook. Simple deterministic replacement. + * Dangerous: always map x to y. See [AES Penguin](https://words.filippo.io/the-ecb-penguin/). + */ +export declare const ecb: ((key: Uint8Array, opts?: BlockOpts) => CipherWithOutput) & { + blockSize: number; +}; +/** + * CBC: Cipher-Block-Chaining. Key is previous round’s block. + * Fragile: needs proper padding. Unauthenticated: needs MAC. + */ +export declare const cbc: ((key: Uint8Array, iv: Uint8Array, opts?: BlockOpts) => CipherWithOutput) & { + blockSize: number; + nonceLength: number; +}; +/** + * CFB: Cipher Feedback Mode. The input for the block cipher is the previous cipher output. + * Unauthenticated: needs MAC. + */ +export declare const cfb: ((key: Uint8Array, iv: Uint8Array) => CipherWithOutput) & { + blockSize: number; + nonceLength: number; +}; +/** + * GCM: Galois/Counter Mode. + * Modern, parallel version of CTR, with MAC. + * Be careful: MACs can be forged. + * Unsafe to use random nonces under the same key, due to collision chance. + * As for nonce size, prefer 12-byte, instead of 8-byte. + */ +export declare const gcm: ((key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => Cipher) & { + blockSize: number; + nonceLength: number; + tagLength: number; + varSizeNonce: true; +}; +/** + * AES-GCM-SIV: classic AES-GCM with nonce-misuse resistance. + * Guarantees that, when a nonce is repeated, the only security loss is that identical + * plaintexts will produce identical ciphertexts. + * RFC 8452, https://datatracker.ietf.org/doc/html/rfc8452 + */ +export declare const gcmsiv: ((key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => Cipher) & { + blockSize: number; + nonceLength: number; + tagLength: number; + varSizeNonce: true; +}; +/** + * AES-GCM-SIV, not AES-SIV. + * This is legace name, use `gcmsiv` export instead. + * @deprecated + */ +export declare const siv: typeof gcmsiv; +declare function encryptBlock(xk: Uint32Array, block: Uint8Array): Uint8Array; +declare function decryptBlock(xk: Uint32Array, block: Uint8Array): Uint8Array; +/** + * AES-KW (key-wrap). Injects static IV into plaintext, adds counter, encrypts 6 times. + * Reduces block size from 16 to 8 bytes. + * For padded version, use aeskwp. + * [RFC 3394](https://datatracker.ietf.org/doc/rfc3394/), + * [NIST.SP.800-38F](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38F.pdf). + */ +export declare const aeskw: ((kek: Uint8Array) => Cipher) & { + blockSize: number; +}; +/** + * AES-KW, but with padding and allows random keys. + * Second u32 of IV is used as counter for length. + * [RFC 5649](https://www.rfc-editor.org/rfc/rfc5649) + */ +export declare const aeskwp: ((kek: Uint8Array) => Cipher) & { + blockSize: number; +}; +/** Unsafe low-level internal methods. May change at any time. */ +export declare const unsafe: { + expandKeyLE: typeof expandKeyLE; + expandKeyDecLE: typeof expandKeyDecLE; + encrypt: typeof encrypt; + decrypt: typeof decrypt; + encryptBlock: typeof encryptBlock; + decryptBlock: typeof decryptBlock; + ctrCounter: typeof ctrCounter; + ctr32: typeof ctr32; +}; +export {}; +//# sourceMappingURL=aes.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/aes.d.ts.map b/node_modules/@noble/ciphers/aes.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..b6623747ddf782ec5935eb08b4741b796dc0bf17 --- /dev/null +++ b/node_modules/@noble/ciphers/aes.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"aes.d.ts","sourceRoot":"","sources":["src/aes.ts"],"names":[],"mappings":"AAkBA,OAAO,EAIL,KAAK,MAAM,EAAE,KAAK,gBAAgB,EACnC,MAAM,YAAY,CA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;AAEF;;;;GAIG;AACH,eAAO,MAAM,GAAG,EAAE,OAAO,MAAe,CAAC;AAQzC,iBAAS,YAAY,CAAC,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,UAAU,GAAG,UAAU,CAOpE;AAED,iBAAS,YAAY,CAAC,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,UAAU,GAAG,UAAU,CAOpE;AAsED;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,EAAE,CAAC,CAAC,GAAG,EAAE,UAAU,KAAK,MAAM,CAAC,GAAG;IAClD,SAAS,EAAE,MAAM,CAAC;CA0BnB,CAAC;AA0CF;;;;GAIG;AACH,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,GAAG,EAAE,UAAU,KAAK,MAAM,CAAC,GAAG;IACnD,SAAS,EAAE,MAAM,CAAC;CA+BnB,CAAC;AAEF,iEAAiE;AACjE,eAAO,MAAM,MAAM,EAAE;IACnB,WAAW,EAAE,OAAO,WAAW,CAAC;IAChC,cAAc,EAAE,OAAO,cAAc,CAAC;IACtC,OAAO,EAAE,OAAO,OAAO,CAAC;IACxB,OAAO,EAAE,OAAO,OAAO,CAAC;IACxB,YAAY,EAAE,OAAO,YAAY,CAAC;IAClC,YAAY,EAAE,OAAO,YAAY,CAAC;IAClC,UAAU,EAAE,OAAO,UAAU,CAAC;IAC9B,KAAK,EAAE,OAAO,KAAK,CAAC;CAUrB,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/aes.js b/node_modules/@noble/ciphers/aes.js new file mode 100644 index 0000000000000000000000000000000000000000..f3bea92a86594585d2b56190ca0251cc40eba623 --- /dev/null +++ b/node_modules/@noble/ciphers/aes.js @@ -0,0 +1,906 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.unsafe = exports.aeskwp = exports.aeskw = exports.siv = exports.gcmsiv = exports.gcm = exports.cfb = exports.cbc = exports.ecb = exports.ctr = void 0; +/** + * [AES](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard) + * a.k.a. Advanced Encryption Standard + * is a variant of Rijndael block cipher, standardized by NIST in 2001. + * We provide the fastest available pure JS implementation. + * + * Data is split into 128-bit blocks. Encrypted in 10/12/14 rounds (128/192/256 bits). In every round: + * 1. **S-box**, table substitution + * 2. **Shift rows**, cyclic shift left of all rows of data array + * 3. **Mix columns**, multiplying every column by fixed polynomial + * 4. **Add round key**, round_key xor i-th column of array + * + * Check out [FIPS-197](https://csrc.nist.gov/files/pubs/fips/197/final/docs/fips-197.pdf) + * and [original proposal](https://csrc.nist.gov/csrc/media/projects/cryptographic-standards-and-guidelines/documents/aes-development/rijndael-ammended.pdf) + * @module + */ +const _polyval_ts_1 = require("./_polyval.js"); +// prettier-ignore +const utils_ts_1 = require("./utils.js"); +const BLOCK_SIZE = 16; +const BLOCK_SIZE32 = 4; +const EMPTY_BLOCK = /* @__PURE__ */ new Uint8Array(BLOCK_SIZE); +const POLY = 0x11b; // 1 + x + x**3 + x**4 + x**8 +// TODO: remove multiplication, binary ops only +function mul2(n) { + return (n << 1) ^ (POLY & -(n >> 7)); +} +function mul(a, b) { + let res = 0; + for (; b > 0; b >>= 1) { + // Montgomery ladder + res ^= a & -(b & 1); // if (b&1) res ^=a (but const-time). + a = mul2(a); // a = 2*a + } + return res; +} +// AES S-box is generated using finite field inversion, +// an affine transform, and xor of a constant 0x63. +const sbox = /* @__PURE__ */ (() => { + const t = new Uint8Array(256); + for (let i = 0, x = 1; i < 256; i++, x ^= mul2(x)) + t[i] = x; + const box = new Uint8Array(256); + box[0] = 0x63; // first elm + for (let i = 0; i < 255; i++) { + let x = t[255 - i]; + x |= x << 8; + box[t[i]] = (x ^ (x >> 4) ^ (x >> 5) ^ (x >> 6) ^ (x >> 7) ^ 0x63) & 0xff; + } + (0, utils_ts_1.clean)(t); + return box; +})(); +// Inverted S-box +const invSbox = /* @__PURE__ */ sbox.map((_, j) => sbox.indexOf(j)); +// Rotate u32 by 8 +const rotr32_8 = (n) => (n << 24) | (n >>> 8); +const rotl32_8 = (n) => (n << 8) | (n >>> 24); +// The byte swap operation for uint32 (LE<->BE) +const byteSwap = (word) => ((word << 24) & 0xff000000) | + ((word << 8) & 0xff0000) | + ((word >>> 8) & 0xff00) | + ((word >>> 24) & 0xff); +// T-table is optimization suggested in 5.2 of original proposal (missed from FIPS-197). Changes: +// - LE instead of BE +// - bigger tables: T0 and T1 are merged into T01 table and T2 & T3 into T23; +// so index is u16, instead of u8. This speeds up things, unexpectedly +function genTtable(sbox, fn) { + if (sbox.length !== 256) + throw new Error('Wrong sbox length'); + const T0 = new Uint32Array(256).map((_, j) => fn(sbox[j])); + const T1 = T0.map(rotl32_8); + const T2 = T1.map(rotl32_8); + const T3 = T2.map(rotl32_8); + const T01 = new Uint32Array(256 * 256); + const T23 = new Uint32Array(256 * 256); + const sbox2 = new Uint16Array(256 * 256); + for (let i = 0; i < 256; i++) { + for (let j = 0; j < 256; j++) { + const idx = i * 256 + j; + T01[idx] = T0[i] ^ T1[j]; + T23[idx] = T2[i] ^ T3[j]; + sbox2[idx] = (sbox[i] << 8) | sbox[j]; + } + } + return { sbox, sbox2, T0, T1, T2, T3, T01, T23 }; +} +const tableEncoding = /* @__PURE__ */ genTtable(sbox, (s) => (mul(s, 3) << 24) | (s << 16) | (s << 8) | mul(s, 2)); +const tableDecoding = /* @__PURE__ */ genTtable(invSbox, (s) => (mul(s, 11) << 24) | (mul(s, 13) << 16) | (mul(s, 9) << 8) | mul(s, 14)); +const xPowers = /* @__PURE__ */ (() => { + const p = new Uint8Array(16); + for (let i = 0, x = 1; i < 16; i++, x = mul2(x)) + p[i] = x; + return p; +})(); +/** Key expansion used in CTR. */ +function expandKeyLE(key) { + (0, utils_ts_1.abytes)(key); + const len = key.length; + if (![16, 24, 32].includes(len)) + throw new Error('aes: invalid key size, should be 16, 24 or 32, got ' + len); + const { sbox2 } = tableEncoding; + const toClean = []; + if (!(0, utils_ts_1.isAligned32)(key)) + toClean.push((key = (0, utils_ts_1.copyBytes)(key))); + const k32 = (0, utils_ts_1.u32)(key); + const Nk = k32.length; + const subByte = (n) => applySbox(sbox2, n, n, n, n); + const xk = new Uint32Array(len + 28); // expanded key + xk.set(k32); + // 4.3.1 Key expansion + for (let i = Nk; i < xk.length; i++) { + let t = xk[i - 1]; + if (i % Nk === 0) + t = subByte(rotr32_8(t)) ^ xPowers[i / Nk - 1]; + else if (Nk > 6 && i % Nk === 4) + t = subByte(t); + xk[i] = xk[i - Nk] ^ t; + } + (0, utils_ts_1.clean)(...toClean); + return xk; +} +function expandKeyDecLE(key) { + const encKey = expandKeyLE(key); + const xk = encKey.slice(); + const Nk = encKey.length; + const { sbox2 } = tableEncoding; + const { T0, T1, T2, T3 } = tableDecoding; + // Inverse key by chunks of 4 (rounds) + for (let i = 0; i < Nk; i += 4) { + for (let j = 0; j < 4; j++) + xk[i + j] = encKey[Nk - i - 4 + j]; + } + (0, utils_ts_1.clean)(encKey); + // apply InvMixColumn except first & last round + for (let i = 4; i < Nk - 4; i++) { + const x = xk[i]; + const w = applySbox(sbox2, x, x, x, x); + xk[i] = T0[w & 0xff] ^ T1[(w >>> 8) & 0xff] ^ T2[(w >>> 16) & 0xff] ^ T3[w >>> 24]; + } + return xk; +} +// Apply tables +function apply0123(T01, T23, s0, s1, s2, s3) { + return (T01[((s0 << 8) & 0xff00) | ((s1 >>> 8) & 0xff)] ^ + T23[((s2 >>> 8) & 0xff00) | ((s3 >>> 24) & 0xff)]); +} +function applySbox(sbox2, s0, s1, s2, s3) { + return (sbox2[(s0 & 0xff) | (s1 & 0xff00)] | + (sbox2[((s2 >>> 16) & 0xff) | ((s3 >>> 16) & 0xff00)] << 16)); +} +function encrypt(xk, s0, s1, s2, s3) { + const { sbox2, T01, T23 } = tableEncoding; + let k = 0; + (s0 ^= xk[k++]), (s1 ^= xk[k++]), (s2 ^= xk[k++]), (s3 ^= xk[k++]); + const rounds = xk.length / 4 - 2; + for (let i = 0; i < rounds; i++) { + const t0 = xk[k++] ^ apply0123(T01, T23, s0, s1, s2, s3); + const t1 = xk[k++] ^ apply0123(T01, T23, s1, s2, s3, s0); + const t2 = xk[k++] ^ apply0123(T01, T23, s2, s3, s0, s1); + const t3 = xk[k++] ^ apply0123(T01, T23, s3, s0, s1, s2); + (s0 = t0), (s1 = t1), (s2 = t2), (s3 = t3); + } + // last round (without mixcolumns, so using SBOX2 table) + const t0 = xk[k++] ^ applySbox(sbox2, s0, s1, s2, s3); + const t1 = xk[k++] ^ applySbox(sbox2, s1, s2, s3, s0); + const t2 = xk[k++] ^ applySbox(sbox2, s2, s3, s0, s1); + const t3 = xk[k++] ^ applySbox(sbox2, s3, s0, s1, s2); + return { s0: t0, s1: t1, s2: t2, s3: t3 }; +} +// Can't be merged with encrypt: arg positions for apply0123 / applySbox are different +function decrypt(xk, s0, s1, s2, s3) { + const { sbox2, T01, T23 } = tableDecoding; + let k = 0; + (s0 ^= xk[k++]), (s1 ^= xk[k++]), (s2 ^= xk[k++]), (s3 ^= xk[k++]); + const rounds = xk.length / 4 - 2; + for (let i = 0; i < rounds; i++) { + const t0 = xk[k++] ^ apply0123(T01, T23, s0, s3, s2, s1); + const t1 = xk[k++] ^ apply0123(T01, T23, s1, s0, s3, s2); + const t2 = xk[k++] ^ apply0123(T01, T23, s2, s1, s0, s3); + const t3 = xk[k++] ^ apply0123(T01, T23, s3, s2, s1, s0); + (s0 = t0), (s1 = t1), (s2 = t2), (s3 = t3); + } + // Last round + const t0 = xk[k++] ^ applySbox(sbox2, s0, s3, s2, s1); + const t1 = xk[k++] ^ applySbox(sbox2, s1, s0, s3, s2); + const t2 = xk[k++] ^ applySbox(sbox2, s2, s1, s0, s3); + const t3 = xk[k++] ^ applySbox(sbox2, s3, s2, s1, s0); + return { s0: t0, s1: t1, s2: t2, s3: t3 }; +} +// TODO: investigate merging with ctr32 +function ctrCounter(xk, nonce, src, dst) { + (0, utils_ts_1.abytes)(nonce, BLOCK_SIZE); + (0, utils_ts_1.abytes)(src); + const srcLen = src.length; + dst = (0, utils_ts_1.getOutput)(srcLen, dst); + (0, utils_ts_1.complexOverlapBytes)(src, dst); + const ctr = nonce; + const c32 = (0, utils_ts_1.u32)(ctr); + // Fill block (empty, ctr=0) + let { s0, s1, s2, s3 } = encrypt(xk, c32[0], c32[1], c32[2], c32[3]); + const src32 = (0, utils_ts_1.u32)(src); + const dst32 = (0, utils_ts_1.u32)(dst); + // process blocks + for (let i = 0; i + 4 <= src32.length; i += 4) { + dst32[i + 0] = src32[i + 0] ^ s0; + dst32[i + 1] = src32[i + 1] ^ s1; + dst32[i + 2] = src32[i + 2] ^ s2; + dst32[i + 3] = src32[i + 3] ^ s3; + // Full 128 bit counter with wrap around + let carry = 1; + for (let i = ctr.length - 1; i >= 0; i--) { + carry = (carry + (ctr[i] & 0xff)) | 0; + ctr[i] = carry & 0xff; + carry >>>= 8; + } + ({ s0, s1, s2, s3 } = encrypt(xk, c32[0], c32[1], c32[2], c32[3])); + } + // leftovers (less than block) + // It's possible to handle > u32 fast, but is it worth it? + const start = BLOCK_SIZE * Math.floor(src32.length / BLOCK_SIZE32); + if (start < srcLen) { + const b32 = new Uint32Array([s0, s1, s2, s3]); + const buf = (0, utils_ts_1.u8)(b32); + for (let i = start, pos = 0; i < srcLen; i++, pos++) + dst[i] = src[i] ^ buf[pos]; + (0, utils_ts_1.clean)(b32); + } + return dst; +} +// AES CTR with overflowing 32 bit counter +// It's possible to do 32le significantly simpler (and probably faster) by using u32. +// But, we need both, and perf bottleneck is in ghash anyway. +function ctr32(xk, isLE, nonce, src, dst) { + (0, utils_ts_1.abytes)(nonce, BLOCK_SIZE); + (0, utils_ts_1.abytes)(src); + dst = (0, utils_ts_1.getOutput)(src.length, dst); + const ctr = nonce; // write new value to nonce, so it can be re-used + const c32 = (0, utils_ts_1.u32)(ctr); + const view = (0, utils_ts_1.createView)(ctr); + const src32 = (0, utils_ts_1.u32)(src); + const dst32 = (0, utils_ts_1.u32)(dst); + const ctrPos = isLE ? 0 : 12; + const srcLen = src.length; + // Fill block (empty, ctr=0) + let ctrNum = view.getUint32(ctrPos, isLE); // read current counter value + let { s0, s1, s2, s3 } = encrypt(xk, c32[0], c32[1], c32[2], c32[3]); + // process blocks + for (let i = 0; i + 4 <= src32.length; i += 4) { + dst32[i + 0] = src32[i + 0] ^ s0; + dst32[i + 1] = src32[i + 1] ^ s1; + dst32[i + 2] = src32[i + 2] ^ s2; + dst32[i + 3] = src32[i + 3] ^ s3; + ctrNum = (ctrNum + 1) >>> 0; // u32 wrap + view.setUint32(ctrPos, ctrNum, isLE); + ({ s0, s1, s2, s3 } = encrypt(xk, c32[0], c32[1], c32[2], c32[3])); + } + // leftovers (less than a block) + const start = BLOCK_SIZE * Math.floor(src32.length / BLOCK_SIZE32); + if (start < srcLen) { + const b32 = new Uint32Array([s0, s1, s2, s3]); + const buf = (0, utils_ts_1.u8)(b32); + for (let i = start, pos = 0; i < srcLen; i++, pos++) + dst[i] = src[i] ^ buf[pos]; + (0, utils_ts_1.clean)(b32); + } + return dst; +} +/** + * CTR: counter mode. Creates stream cipher. + * Requires good IV. Parallelizable. OK, but no MAC. + */ +exports.ctr = (0, utils_ts_1.wrapCipher)({ blockSize: 16, nonceLength: 16 }, function aesctr(key, nonce) { + function processCtr(buf, dst) { + (0, utils_ts_1.abytes)(buf); + if (dst !== undefined) { + (0, utils_ts_1.abytes)(dst); + if (!(0, utils_ts_1.isAligned32)(dst)) + throw new Error('unaligned destination'); + } + const xk = expandKeyLE(key); + const n = (0, utils_ts_1.copyBytes)(nonce); // align + avoid changing + const toClean = [xk, n]; + if (!(0, utils_ts_1.isAligned32)(buf)) + toClean.push((buf = (0, utils_ts_1.copyBytes)(buf))); + const out = ctrCounter(xk, n, buf, dst); + (0, utils_ts_1.clean)(...toClean); + return out; + } + return { + encrypt: (plaintext, dst) => processCtr(plaintext, dst), + decrypt: (ciphertext, dst) => processCtr(ciphertext, dst), + }; +}); +function validateBlockDecrypt(data) { + (0, utils_ts_1.abytes)(data); + if (data.length % BLOCK_SIZE !== 0) { + throw new Error('aes-(cbc/ecb).decrypt ciphertext should consist of blocks with size ' + BLOCK_SIZE); + } +} +function validateBlockEncrypt(plaintext, pcks5, dst) { + (0, utils_ts_1.abytes)(plaintext); + let outLen = plaintext.length; + const remaining = outLen % BLOCK_SIZE; + if (!pcks5 && remaining !== 0) + throw new Error('aec/(cbc-ecb): unpadded plaintext with disabled padding'); + if (!(0, utils_ts_1.isAligned32)(plaintext)) + plaintext = (0, utils_ts_1.copyBytes)(plaintext); + const b = (0, utils_ts_1.u32)(plaintext); + if (pcks5) { + let left = BLOCK_SIZE - remaining; + if (!left) + left = BLOCK_SIZE; // if no bytes left, create empty padding block + outLen = outLen + left; + } + dst = (0, utils_ts_1.getOutput)(outLen, dst); + (0, utils_ts_1.complexOverlapBytes)(plaintext, dst); + const o = (0, utils_ts_1.u32)(dst); + return { b, o, out: dst }; +} +function validatePCKS(data, pcks5) { + if (!pcks5) + return data; + const len = data.length; + if (!len) + throw new Error('aes/pcks5: empty ciphertext not allowed'); + const lastByte = data[len - 1]; + if (lastByte <= 0 || lastByte > 16) + throw new Error('aes/pcks5: wrong padding'); + const out = data.subarray(0, -lastByte); + for (let i = 0; i < lastByte; i++) + if (data[len - i - 1] !== lastByte) + throw new Error('aes/pcks5: wrong padding'); + return out; +} +function padPCKS(left) { + const tmp = new Uint8Array(16); + const tmp32 = (0, utils_ts_1.u32)(tmp); + tmp.set(left); + const paddingByte = BLOCK_SIZE - left.length; + for (let i = BLOCK_SIZE - paddingByte; i < BLOCK_SIZE; i++) + tmp[i] = paddingByte; + return tmp32; +} +/** + * ECB: Electronic CodeBook. Simple deterministic replacement. + * Dangerous: always map x to y. See [AES Penguin](https://words.filippo.io/the-ecb-penguin/). + */ +exports.ecb = (0, utils_ts_1.wrapCipher)({ blockSize: 16 }, function aesecb(key, opts = {}) { + const pcks5 = !opts.disablePadding; + return { + encrypt(plaintext, dst) { + const { b, o, out: _out } = validateBlockEncrypt(plaintext, pcks5, dst); + const xk = expandKeyLE(key); + let i = 0; + for (; i + 4 <= b.length;) { + const { s0, s1, s2, s3 } = encrypt(xk, b[i + 0], b[i + 1], b[i + 2], b[i + 3]); + (o[i++] = s0), (o[i++] = s1), (o[i++] = s2), (o[i++] = s3); + } + if (pcks5) { + const tmp32 = padPCKS(plaintext.subarray(i * 4)); + const { s0, s1, s2, s3 } = encrypt(xk, tmp32[0], tmp32[1], tmp32[2], tmp32[3]); + (o[i++] = s0), (o[i++] = s1), (o[i++] = s2), (o[i++] = s3); + } + (0, utils_ts_1.clean)(xk); + return _out; + }, + decrypt(ciphertext, dst) { + validateBlockDecrypt(ciphertext); + const xk = expandKeyDecLE(key); + dst = (0, utils_ts_1.getOutput)(ciphertext.length, dst); + const toClean = [xk]; + if (!(0, utils_ts_1.isAligned32)(ciphertext)) + toClean.push((ciphertext = (0, utils_ts_1.copyBytes)(ciphertext))); + (0, utils_ts_1.complexOverlapBytes)(ciphertext, dst); + const b = (0, utils_ts_1.u32)(ciphertext); + const o = (0, utils_ts_1.u32)(dst); + for (let i = 0; i + 4 <= b.length;) { + const { s0, s1, s2, s3 } = decrypt(xk, b[i + 0], b[i + 1], b[i + 2], b[i + 3]); + (o[i++] = s0), (o[i++] = s1), (o[i++] = s2), (o[i++] = s3); + } + (0, utils_ts_1.clean)(...toClean); + return validatePCKS(dst, pcks5); + }, + }; +}); +/** + * CBC: Cipher-Block-Chaining. Key is previous round’s block. + * Fragile: needs proper padding. Unauthenticated: needs MAC. + */ +exports.cbc = (0, utils_ts_1.wrapCipher)({ blockSize: 16, nonceLength: 16 }, function aescbc(key, iv, opts = {}) { + const pcks5 = !opts.disablePadding; + return { + encrypt(plaintext, dst) { + const xk = expandKeyLE(key); + const { b, o, out: _out } = validateBlockEncrypt(plaintext, pcks5, dst); + let _iv = iv; + const toClean = [xk]; + if (!(0, utils_ts_1.isAligned32)(_iv)) + toClean.push((_iv = (0, utils_ts_1.copyBytes)(_iv))); + const n32 = (0, utils_ts_1.u32)(_iv); + // prettier-ignore + let s0 = n32[0], s1 = n32[1], s2 = n32[2], s3 = n32[3]; + let i = 0; + for (; i + 4 <= b.length;) { + (s0 ^= b[i + 0]), (s1 ^= b[i + 1]), (s2 ^= b[i + 2]), (s3 ^= b[i + 3]); + ({ s0, s1, s2, s3 } = encrypt(xk, s0, s1, s2, s3)); + (o[i++] = s0), (o[i++] = s1), (o[i++] = s2), (o[i++] = s3); + } + if (pcks5) { + const tmp32 = padPCKS(plaintext.subarray(i * 4)); + (s0 ^= tmp32[0]), (s1 ^= tmp32[1]), (s2 ^= tmp32[2]), (s3 ^= tmp32[3]); + ({ s0, s1, s2, s3 } = encrypt(xk, s0, s1, s2, s3)); + (o[i++] = s0), (o[i++] = s1), (o[i++] = s2), (o[i++] = s3); + } + (0, utils_ts_1.clean)(...toClean); + return _out; + }, + decrypt(ciphertext, dst) { + validateBlockDecrypt(ciphertext); + const xk = expandKeyDecLE(key); + let _iv = iv; + const toClean = [xk]; + if (!(0, utils_ts_1.isAligned32)(_iv)) + toClean.push((_iv = (0, utils_ts_1.copyBytes)(_iv))); + const n32 = (0, utils_ts_1.u32)(_iv); + dst = (0, utils_ts_1.getOutput)(ciphertext.length, dst); + if (!(0, utils_ts_1.isAligned32)(ciphertext)) + toClean.push((ciphertext = (0, utils_ts_1.copyBytes)(ciphertext))); + (0, utils_ts_1.complexOverlapBytes)(ciphertext, dst); + const b = (0, utils_ts_1.u32)(ciphertext); + const o = (0, utils_ts_1.u32)(dst); + // prettier-ignore + let s0 = n32[0], s1 = n32[1], s2 = n32[2], s3 = n32[3]; + for (let i = 0; i + 4 <= b.length;) { + // prettier-ignore + const ps0 = s0, ps1 = s1, ps2 = s2, ps3 = s3; + (s0 = b[i + 0]), (s1 = b[i + 1]), (s2 = b[i + 2]), (s3 = b[i + 3]); + const { s0: o0, s1: o1, s2: o2, s3: o3 } = decrypt(xk, s0, s1, s2, s3); + (o[i++] = o0 ^ ps0), (o[i++] = o1 ^ ps1), (o[i++] = o2 ^ ps2), (o[i++] = o3 ^ ps3); + } + (0, utils_ts_1.clean)(...toClean); + return validatePCKS(dst, pcks5); + }, + }; +}); +/** + * CFB: Cipher Feedback Mode. The input for the block cipher is the previous cipher output. + * Unauthenticated: needs MAC. + */ +exports.cfb = (0, utils_ts_1.wrapCipher)({ blockSize: 16, nonceLength: 16 }, function aescfb(key, iv) { + function processCfb(src, isEncrypt, dst) { + (0, utils_ts_1.abytes)(src); + const srcLen = src.length; + dst = (0, utils_ts_1.getOutput)(srcLen, dst); + if ((0, utils_ts_1.overlapBytes)(src, dst)) + throw new Error('overlapping src and dst not supported.'); + const xk = expandKeyLE(key); + let _iv = iv; + const toClean = [xk]; + if (!(0, utils_ts_1.isAligned32)(_iv)) + toClean.push((_iv = (0, utils_ts_1.copyBytes)(_iv))); + if (!(0, utils_ts_1.isAligned32)(src)) + toClean.push((src = (0, utils_ts_1.copyBytes)(src))); + const src32 = (0, utils_ts_1.u32)(src); + const dst32 = (0, utils_ts_1.u32)(dst); + const next32 = isEncrypt ? dst32 : src32; + const n32 = (0, utils_ts_1.u32)(_iv); + // prettier-ignore + let s0 = n32[0], s1 = n32[1], s2 = n32[2], s3 = n32[3]; + for (let i = 0; i + 4 <= src32.length;) { + const { s0: e0, s1: e1, s2: e2, s3: e3 } = encrypt(xk, s0, s1, s2, s3); + dst32[i + 0] = src32[i + 0] ^ e0; + dst32[i + 1] = src32[i + 1] ^ e1; + dst32[i + 2] = src32[i + 2] ^ e2; + dst32[i + 3] = src32[i + 3] ^ e3; + (s0 = next32[i++]), (s1 = next32[i++]), (s2 = next32[i++]), (s3 = next32[i++]); + } + // leftovers (less than block) + const start = BLOCK_SIZE * Math.floor(src32.length / BLOCK_SIZE32); + if (start < srcLen) { + ({ s0, s1, s2, s3 } = encrypt(xk, s0, s1, s2, s3)); + const buf = (0, utils_ts_1.u8)(new Uint32Array([s0, s1, s2, s3])); + for (let i = start, pos = 0; i < srcLen; i++, pos++) + dst[i] = src[i] ^ buf[pos]; + (0, utils_ts_1.clean)(buf); + } + (0, utils_ts_1.clean)(...toClean); + return dst; + } + return { + encrypt: (plaintext, dst) => processCfb(plaintext, true, dst), + decrypt: (ciphertext, dst) => processCfb(ciphertext, false, dst), + }; +}); +// TODO: merge with chacha, however gcm has bitLen while chacha has byteLen +function computeTag(fn, isLE, key, data, AAD) { + const aadLength = AAD ? AAD.length : 0; + const h = fn.create(key, data.length + aadLength); + if (AAD) + h.update(AAD); + const num = (0, utils_ts_1.u64Lengths)(8 * data.length, 8 * aadLength, isLE); + h.update(data); + h.update(num); + const res = h.digest(); + (0, utils_ts_1.clean)(num); + return res; +} +/** + * GCM: Galois/Counter Mode. + * Modern, parallel version of CTR, with MAC. + * Be careful: MACs can be forged. + * Unsafe to use random nonces under the same key, due to collision chance. + * As for nonce size, prefer 12-byte, instead of 8-byte. + */ +exports.gcm = (0, utils_ts_1.wrapCipher)({ blockSize: 16, nonceLength: 12, tagLength: 16, varSizeNonce: true }, function aesgcm(key, nonce, AAD) { + // NIST 800-38d doesn't enforce minimum nonce length. + // We enforce 8 bytes for compat with openssl. + // 12 bytes are recommended. More than 12 bytes would be converted into 12. + if (nonce.length < 8) + throw new Error('aes/gcm: invalid nonce length'); + const tagLength = 16; + function _computeTag(authKey, tagMask, data) { + const tag = computeTag(_polyval_ts_1.ghash, false, authKey, data, AAD); + for (let i = 0; i < tagMask.length; i++) + tag[i] ^= tagMask[i]; + return tag; + } + function deriveKeys() { + const xk = expandKeyLE(key); + const authKey = EMPTY_BLOCK.slice(); + const counter = EMPTY_BLOCK.slice(); + ctr32(xk, false, counter, counter, authKey); + // NIST 800-38d, page 15: different behavior for 96-bit and non-96-bit nonces + if (nonce.length === 12) { + counter.set(nonce); + } + else { + const nonceLen = EMPTY_BLOCK.slice(); + const view = (0, utils_ts_1.createView)(nonceLen); + (0, utils_ts_1.setBigUint64)(view, 8, BigInt(nonce.length * 8), false); + // ghash(nonce || u64be(0) || u64be(nonceLen*8)) + const g = _polyval_ts_1.ghash.create(authKey).update(nonce).update(nonceLen); + g.digestInto(counter); // digestInto doesn't trigger '.destroy' + g.destroy(); + } + const tagMask = ctr32(xk, false, counter, EMPTY_BLOCK); + return { xk, authKey, counter, tagMask }; + } + return { + encrypt(plaintext) { + const { xk, authKey, counter, tagMask } = deriveKeys(); + const out = new Uint8Array(plaintext.length + tagLength); + const toClean = [xk, authKey, counter, tagMask]; + if (!(0, utils_ts_1.isAligned32)(plaintext)) + toClean.push((plaintext = (0, utils_ts_1.copyBytes)(plaintext))); + ctr32(xk, false, counter, plaintext, out.subarray(0, plaintext.length)); + const tag = _computeTag(authKey, tagMask, out.subarray(0, out.length - tagLength)); + toClean.push(tag); + out.set(tag, plaintext.length); + (0, utils_ts_1.clean)(...toClean); + return out; + }, + decrypt(ciphertext) { + const { xk, authKey, counter, tagMask } = deriveKeys(); + const toClean = [xk, authKey, tagMask, counter]; + if (!(0, utils_ts_1.isAligned32)(ciphertext)) + toClean.push((ciphertext = (0, utils_ts_1.copyBytes)(ciphertext))); + const data = ciphertext.subarray(0, -tagLength); + const passedTag = ciphertext.subarray(-tagLength); + const tag = _computeTag(authKey, tagMask, data); + toClean.push(tag); + if (!(0, utils_ts_1.equalBytes)(tag, passedTag)) + throw new Error('aes/gcm: invalid ghash tag'); + const out = ctr32(xk, false, counter, data); + (0, utils_ts_1.clean)(...toClean); + return out; + }, + }; +}); +const limit = (name, min, max) => (value) => { + if (!Number.isSafeInteger(value) || min > value || value > max) { + const minmax = '[' + min + '..' + max + ']'; + throw new Error('' + name + ': expected value in range ' + minmax + ', got ' + value); + } +}; +/** + * AES-GCM-SIV: classic AES-GCM with nonce-misuse resistance. + * Guarantees that, when a nonce is repeated, the only security loss is that identical + * plaintexts will produce identical ciphertexts. + * RFC 8452, https://datatracker.ietf.org/doc/html/rfc8452 + */ +exports.gcmsiv = (0, utils_ts_1.wrapCipher)({ blockSize: 16, nonceLength: 12, tagLength: 16, varSizeNonce: true }, function aessiv(key, nonce, AAD) { + const tagLength = 16; + // From RFC 8452: Section 6 + const AAD_LIMIT = limit('AAD', 0, 2 ** 36); + const PLAIN_LIMIT = limit('plaintext', 0, 2 ** 36); + const NONCE_LIMIT = limit('nonce', 12, 12); + const CIPHER_LIMIT = limit('ciphertext', 16, 2 ** 36 + 16); + (0, utils_ts_1.abytes)(key, 16, 24, 32); + NONCE_LIMIT(nonce.length); + if (AAD !== undefined) + AAD_LIMIT(AAD.length); + function deriveKeys() { + const xk = expandKeyLE(key); + const encKey = new Uint8Array(key.length); + const authKey = new Uint8Array(16); + const toClean = [xk, encKey]; + let _nonce = nonce; + if (!(0, utils_ts_1.isAligned32)(_nonce)) + toClean.push((_nonce = (0, utils_ts_1.copyBytes)(_nonce))); + const n32 = (0, utils_ts_1.u32)(_nonce); + // prettier-ignore + let s0 = 0, s1 = n32[0], s2 = n32[1], s3 = n32[2]; + let counter = 0; + for (const derivedKey of [authKey, encKey].map(utils_ts_1.u32)) { + const d32 = (0, utils_ts_1.u32)(derivedKey); + for (let i = 0; i < d32.length; i += 2) { + // aes(u32le(0) || nonce)[:8] || aes(u32le(1) || nonce)[:8] ... + const { s0: o0, s1: o1 } = encrypt(xk, s0, s1, s2, s3); + d32[i + 0] = o0; + d32[i + 1] = o1; + s0 = ++counter; // increment counter inside state + } + } + const res = { authKey, encKey: expandKeyLE(encKey) }; + // Cleanup + (0, utils_ts_1.clean)(...toClean); + return res; + } + function _computeTag(encKey, authKey, data) { + const tag = computeTag(_polyval_ts_1.polyval, true, authKey, data, AAD); + // Compute the expected tag by XORing S_s and the nonce, clearing the + // most significant bit of the last byte and encrypting with the + // message-encryption key. + for (let i = 0; i < 12; i++) + tag[i] ^= nonce[i]; + tag[15] &= 0x7f; // Clear the highest bit + // encrypt tag as block + const t32 = (0, utils_ts_1.u32)(tag); + // prettier-ignore + let s0 = t32[0], s1 = t32[1], s2 = t32[2], s3 = t32[3]; + ({ s0, s1, s2, s3 } = encrypt(encKey, s0, s1, s2, s3)); + (t32[0] = s0), (t32[1] = s1), (t32[2] = s2), (t32[3] = s3); + return tag; + } + // actual decrypt/encrypt of message. + function processSiv(encKey, tag, input) { + let block = (0, utils_ts_1.copyBytes)(tag); + block[15] |= 0x80; // Force highest bit + const res = ctr32(encKey, true, block, input); + // Cleanup + (0, utils_ts_1.clean)(block); + return res; + } + return { + encrypt(plaintext) { + PLAIN_LIMIT(plaintext.length); + const { encKey, authKey } = deriveKeys(); + const tag = _computeTag(encKey, authKey, plaintext); + const toClean = [encKey, authKey, tag]; + if (!(0, utils_ts_1.isAligned32)(plaintext)) + toClean.push((plaintext = (0, utils_ts_1.copyBytes)(plaintext))); + const out = new Uint8Array(plaintext.length + tagLength); + out.set(tag, plaintext.length); + out.set(processSiv(encKey, tag, plaintext)); + // Cleanup + (0, utils_ts_1.clean)(...toClean); + return out; + }, + decrypt(ciphertext) { + CIPHER_LIMIT(ciphertext.length); + const tag = ciphertext.subarray(-tagLength); + const { encKey, authKey } = deriveKeys(); + const toClean = [encKey, authKey]; + if (!(0, utils_ts_1.isAligned32)(ciphertext)) + toClean.push((ciphertext = (0, utils_ts_1.copyBytes)(ciphertext))); + const plaintext = processSiv(encKey, tag, ciphertext.subarray(0, -tagLength)); + const expectedTag = _computeTag(encKey, authKey, plaintext); + toClean.push(expectedTag); + if (!(0, utils_ts_1.equalBytes)(tag, expectedTag)) { + (0, utils_ts_1.clean)(...toClean); + throw new Error('invalid polyval tag'); + } + // Cleanup + (0, utils_ts_1.clean)(...toClean); + return plaintext; + }, + }; +}); +/** + * AES-GCM-SIV, not AES-SIV. + * This is legace name, use `gcmsiv` export instead. + * @deprecated + */ +exports.siv = exports.gcmsiv; +function isBytes32(a) { + return (a instanceof Uint32Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint32Array')); +} +function encryptBlock(xk, block) { + (0, utils_ts_1.abytes)(block, 16); + if (!isBytes32(xk)) + throw new Error('_encryptBlock accepts result of expandKeyLE'); + const b32 = (0, utils_ts_1.u32)(block); + let { s0, s1, s2, s3 } = encrypt(xk, b32[0], b32[1], b32[2], b32[3]); + (b32[0] = s0), (b32[1] = s1), (b32[2] = s2), (b32[3] = s3); + return block; +} +function decryptBlock(xk, block) { + (0, utils_ts_1.abytes)(block, 16); + if (!isBytes32(xk)) + throw new Error('_decryptBlock accepts result of expandKeyLE'); + const b32 = (0, utils_ts_1.u32)(block); + let { s0, s1, s2, s3 } = decrypt(xk, b32[0], b32[1], b32[2], b32[3]); + (b32[0] = s0), (b32[1] = s1), (b32[2] = s2), (b32[3] = s3); + return block; +} +/** + * AES-W (base for AESKW/AESKWP). + * Specs: [SP800-38F](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38F.pdf), + * [RFC 3394](https://datatracker.ietf.org/doc/rfc3394/), + * [RFC 5649](https://datatracker.ietf.org/doc/rfc5649/). + */ +const AESW = { + /* + High-level pseudocode: + ``` + A: u64 = IV + out = [] + for (let i=0, ctr = 0; i<6; i++) { + for (const chunk of chunks(plaintext, 8)) { + A ^= swapEndianess(ctr++) + [A, res] = chunks(encrypt(A || chunk), 8); + out ||= res + } + } + out = A || out + ``` + Decrypt is the same, but reversed. + */ + encrypt(kek, out) { + // Size is limited to 4GB, otherwise ctr will overflow and we'll need to switch to bigints. + // If you need it larger, open an issue. + if (out.length >= 2 ** 32) + throw new Error('plaintext should be less than 4gb'); + const xk = expandKeyLE(kek); + if (out.length === 16) + encryptBlock(xk, out); + else { + const o32 = (0, utils_ts_1.u32)(out); + // prettier-ignore + let a0 = o32[0], a1 = o32[1]; // A + for (let j = 0, ctr = 1; j < 6; j++) { + for (let pos = 2; pos < o32.length; pos += 2, ctr++) { + const { s0, s1, s2, s3 } = encrypt(xk, a0, a1, o32[pos], o32[pos + 1]); + // A = MSB(64, B) ^ t where t = (n*j)+i + (a0 = s0), (a1 = s1 ^ byteSwap(ctr)), (o32[pos] = s2), (o32[pos + 1] = s3); + } + } + (o32[0] = a0), (o32[1] = a1); // out = A || out + } + xk.fill(0); + }, + decrypt(kek, out) { + if (out.length - 8 >= 2 ** 32) + throw new Error('ciphertext should be less than 4gb'); + const xk = expandKeyDecLE(kek); + const chunks = out.length / 8 - 1; // first chunk is IV + if (chunks === 1) + decryptBlock(xk, out); + else { + const o32 = (0, utils_ts_1.u32)(out); + // prettier-ignore + let a0 = o32[0], a1 = o32[1]; // A + for (let j = 0, ctr = chunks * 6; j < 6; j++) { + for (let pos = chunks * 2; pos >= 1; pos -= 2, ctr--) { + a1 ^= byteSwap(ctr); + const { s0, s1, s2, s3 } = decrypt(xk, a0, a1, o32[pos], o32[pos + 1]); + (a0 = s0), (a1 = s1), (o32[pos] = s2), (o32[pos + 1] = s3); + } + } + (o32[0] = a0), (o32[1] = a1); + } + xk.fill(0); + }, +}; +const AESKW_IV = /* @__PURE__ */ new Uint8Array(8).fill(0xa6); // A6A6A6A6A6A6A6A6 +/** + * AES-KW (key-wrap). Injects static IV into plaintext, adds counter, encrypts 6 times. + * Reduces block size from 16 to 8 bytes. + * For padded version, use aeskwp. + * [RFC 3394](https://datatracker.ietf.org/doc/rfc3394/), + * [NIST.SP.800-38F](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38F.pdf). + */ +exports.aeskw = (0, utils_ts_1.wrapCipher)({ blockSize: 8 }, (kek) => ({ + encrypt(plaintext) { + if (!plaintext.length || plaintext.length % 8 !== 0) + throw new Error('invalid plaintext length'); + if (plaintext.length === 8) + throw new Error('8-byte keys not allowed in AESKW, use AESKWP instead'); + const out = (0, utils_ts_1.concatBytes)(AESKW_IV, plaintext); + AESW.encrypt(kek, out); + return out; + }, + decrypt(ciphertext) { + // ciphertext must be at least 24 bytes and a multiple of 8 bytes + // 24 because should have at least two block (1 iv + 2). + // Replace with 16 to enable '8-byte keys' + if (ciphertext.length % 8 !== 0 || ciphertext.length < 3 * 8) + throw new Error('invalid ciphertext length'); + const out = (0, utils_ts_1.copyBytes)(ciphertext); + AESW.decrypt(kek, out); + if (!(0, utils_ts_1.equalBytes)(out.subarray(0, 8), AESKW_IV)) + throw new Error('integrity check failed'); + out.subarray(0, 8).fill(0); // ciphertext.subarray(0, 8) === IV, but we clean it anyway + return out.subarray(8); + }, +})); +/* +We don't support 8-byte keys. The rabbit hole: + +- Wycheproof says: "NIST SP 800-38F does not define the wrapping of 8 byte keys. + RFC 3394 Section 2 on the other hand specifies that 8 byte keys are wrapped + by directly encrypting one block with AES." + - https://github.com/C2SP/wycheproof/blob/master/doc/key_wrap.md + - "RFC 3394 specifies in Section 2, that the input for the key wrap + algorithm must be at least two blocks and otherwise the constant + field and key are simply encrypted with ECB as a single block" +- What RFC 3394 actually says (in Section 2): + - "Before being wrapped, the key data is parsed into n blocks of 64 bits. + The only restriction the key wrap algorithm places on n is that n be + at least two" + - "For key data with length less than or equal to 64 bits, the constant + field used in this specification and the key data form a single + 128-bit codebook input making this key wrap unnecessary." +- Which means "assert(n >= 2)" and "use something else for 8 byte keys" +- NIST SP800-38F actually prohibits 8-byte in "5.3.1 Mandatory Limits". + It states that plaintext for KW should be "2 to 2^54 -1 semiblocks". +- So, where does "directly encrypt single block with AES" come from? + - Not RFC 3394. Pseudocode of key wrap in 2.2 explicitly uses + loop of 6 for any code path + - There is a weird W3C spec: + https://www.w3.org/TR/2002/REC-xmlenc-core-20021210/Overview.html#kw-aes128 + - This spec is outdated, as admitted by Wycheproof authors + - There is RFC 5649 for padded key wrap, which is padding construction on + top of AESKW. In '4.1.2' it says: "If the padded plaintext contains exactly + eight octets, then prepend the AIV as defined in Section 3 above to P[1] and + encrypt the resulting 128-bit block using AES in ECB mode [Modes] with key + K (the KEK). In this case, the output is two 64-bit blocks C[0] and C[1]:" + - Browser subtle crypto is actually crashes on wrapping keys less than 16 bytes: + `Error: error:1C8000E6:Provider routines::invalid input length] { opensslErrorStack: [ 'error:030000BD:digital envelope routines::update error' ]` + +In the end, seems like a bug in Wycheproof. +The 8-byte check can be easily disabled inside of AES_W. +*/ +const AESKWP_IV = 0xa65959a6; // single u32le value +/** + * AES-KW, but with padding and allows random keys. + * Second u32 of IV is used as counter for length. + * [RFC 5649](https://www.rfc-editor.org/rfc/rfc5649) + */ +exports.aeskwp = (0, utils_ts_1.wrapCipher)({ blockSize: 8 }, (kek) => ({ + encrypt(plaintext) { + if (!plaintext.length) + throw new Error('invalid plaintext length'); + const padded = Math.ceil(plaintext.length / 8) * 8; + const out = new Uint8Array(8 + padded); + out.set(plaintext, 8); + const out32 = (0, utils_ts_1.u32)(out); + out32[0] = AESKWP_IV; + out32[1] = byteSwap(plaintext.length); + AESW.encrypt(kek, out); + return out; + }, + decrypt(ciphertext) { + // 16 because should have at least one block + if (ciphertext.length < 16) + throw new Error('invalid ciphertext length'); + const out = (0, utils_ts_1.copyBytes)(ciphertext); + const o32 = (0, utils_ts_1.u32)(out); + AESW.decrypt(kek, out); + const len = byteSwap(o32[1]) >>> 0; + const padded = Math.ceil(len / 8) * 8; + if (o32[0] !== AESKWP_IV || out.length - 8 !== padded) + throw new Error('integrity check failed'); + for (let i = len; i < padded; i++) + if (out[8 + i] !== 0) + throw new Error('integrity check failed'); + out.subarray(0, 8).fill(0); // ciphertext.subarray(0, 8) === IV, but we clean it anyway + return out.subarray(8, 8 + len); + }, +})); +/** Unsafe low-level internal methods. May change at any time. */ +exports.unsafe = { + expandKeyLE, + expandKeyDecLE, + encrypt, + decrypt, + encryptBlock, + decryptBlock, + ctrCounter, + ctr32, +}; +//# sourceMappingURL=aes.js.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/aes.js.map b/node_modules/@noble/ciphers/aes.js.map new file mode 100644 index 0000000000000000000000000000000000000000..cde20ae69f0947b99be1b827e11c970823f2c48b --- /dev/null +++ b/node_modules/@noble/ciphers/aes.js.map @@ -0,0 +1 @@ +{"version":3,"file":"aes.js","sourceRoot":"","sources":["src/aes.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;GAeG;AACH,+CAA+C;AAC/C,kBAAkB;AAClB,yCAKoB;AAEpB,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,YAAY,GAAG,CAAC,CAAC;AACvB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,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QACtC,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,SAAS,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,KAAK,MAAM;YACnD,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC5C,KAAK,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE;YAC/B,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC;gBAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAClE,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,2DAA2D;QACvF,OAAO,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC;IAClC,CAAC;CACF,CAAC,CACH,CAAC;AAEF,iEAAiE;AACpD,QAAA,MAAM,GASf;IACF,WAAW;IACX,cAAc;IACd,OAAO;IACP,OAAO;IACP,YAAY;IACZ,YAAY;IACZ,UAAU;IACV,KAAK;CACN,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/chacha.d.ts b/node_modules/@noble/ciphers/chacha.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c521e9f733bd8805c03f14c608d29fb3b1a9d769 --- /dev/null +++ b/node_modules/@noble/ciphers/chacha.d.ts @@ -0,0 +1,56 @@ +import { type ARXCipher, type CipherWithOutput, type XorStream } from './utils.ts'; +/** + * hchacha helper method, used primarily in xchacha, to hash + * key and nonce into key' and nonce'. + * Same as chachaCore, but there doesn't seem to be a way to move the block + * out without 25% performance hit. + */ +export declare function hchacha(s: Uint32Array, k: Uint32Array, i: Uint32Array, o32: Uint32Array): void; +/** + * Original, non-RFC chacha20 from DJB. 8-byte nonce, 8-byte counter. + */ +export declare const chacha20orig: XorStream; +/** + * ChaCha stream cipher. Conforms to RFC 8439 (IETF, TLS). 12-byte nonce, 4-byte counter. + * With 12-byte nonce, it's not safe to use fill it with random (CSPRNG), due to collision chance. + */ +export declare const chacha20: XorStream; +/** + * XChaCha eXtended-nonce ChaCha. 24-byte nonce. + * With 24-byte nonce, it's safe to use fill it with random (CSPRNG). + * https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha + */ +export declare const xchacha20: XorStream; +/** + * Reduced 8-round chacha, described in original paper. + */ +export declare const chacha8: XorStream; +/** + * Reduced 12-round chacha, described in original paper. + */ +export declare const chacha12: XorStream; +/** + * AEAD algorithm from RFC 8439. + * Salsa20 and chacha (RFC 8439) use poly1305 differently. + * We could have composed them similar to: + * https://github.com/paulmillr/scure-base/blob/b266c73dde977b1dd7ef40ef7a23cc15aab526b3/index.ts#L250 + * But it's hard because of authKey: + * In salsa20, authKey changes position in salsa stream. + * In chacha, authKey can't be computed inside computeTag, it modifies the counter. + */ +export declare const _poly1305_aead: (xorStream: XorStream) => (key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => CipherWithOutput; +/** + * ChaCha20-Poly1305 from RFC 8439. + * + * Unsafe to use random nonces under the same key, due to collision chance. + * Prefer XChaCha instead. + */ +export declare const chacha20poly1305: ARXCipher; +/** + * XChaCha20-Poly1305 extended-nonce chacha. + * + * Can be safely used with random nonces (CSPRNG). + * See [IRTF draft](https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha). + */ +export declare const xchacha20poly1305: ARXCipher; +//# sourceMappingURL=chacha.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/chacha.d.ts.map b/node_modules/@noble/ciphers/chacha.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..cec1ac82a35769ba2952f8dee6b6ddbf2efdcbfa --- /dev/null +++ b/node_modules/@noble/ciphers/chacha.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"chacha.d.ts","sourceRoot":"","sources":["src/chacha.ts"],"names":[],"mappings":"AAgBA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,SAAS,EAMf,MAAM,YAAY,CAAC;AAsEpB;;;;;GAKG;AAEH,wBAAgB,OAAO,CACrB,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,EAAE,GAAG,EAAE,WAAW,GAC/D,IAAI,CAmDN;AACD;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,SAIzB,CAAC;AACH;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,SAIrB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,SAKtB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,SAIpB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,SAIrB,CAAC;AA6BH;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GACxB,WAAW,SAAS,MACpB,KAAK,UAAU,EAAE,OAAO,UAAU,EAAE,MAAM,UAAU,KAAG,gBA0BvD,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAG9B,CAAC;AACF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAG/B,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/chacha.js b/node_modules/@noble/ciphers/chacha.js new file mode 100644 index 0000000000000000000000000000000000000000..9946c8eea5180d0aaf050273ea9c626206c94ff2 --- /dev/null +++ b/node_modules/@noble/ciphers/chacha.js @@ -0,0 +1,320 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.xchacha20poly1305 = exports.chacha20poly1305 = exports._poly1305_aead = exports.chacha12 = exports.chacha8 = exports.xchacha20 = exports.chacha20 = exports.chacha20orig = void 0; +exports.hchacha = hchacha; +/** + * [ChaCha20](https://cr.yp.to/chacha.html) stream cipher, released + * in 2008. Developed after Salsa20, ChaCha aims to increase diffusion per round. + * It was standardized in [RFC 8439](https://datatracker.ietf.org/doc/html/rfc8439) and + * is now used in TLS 1.3. + * + * [XChaCha20](https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha) + * extended-nonce variant is also provided. Similar to XSalsa, it's safe to use with + * randomly-generated nonces. + * + * Check out [PDF](http://cr.yp.to/chacha/chacha-20080128.pdf) and + * [wiki](https://en.wikipedia.org/wiki/Salsa20). + * @module + */ +const _arx_ts_1 = require("./_arx.js"); +const _poly1305_ts_1 = require("./_poly1305.js"); +const utils_ts_1 = require("./utils.js"); +/** + * ChaCha core function. + */ +// prettier-ignore +function chachaCore(s, k, n, out, cnt, rounds = 20) { + let y00 = s[0], y01 = s[1], y02 = s[2], y03 = s[3], // "expa" "nd 3" "2-by" "te k" + y04 = k[0], y05 = k[1], y06 = k[2], y07 = k[3], // Key Key Key Key + y08 = k[4], y09 = k[5], y10 = k[6], y11 = k[7], // Key Key Key Key + y12 = cnt, y13 = n[0], y14 = n[1], y15 = n[2]; // Counter Counter Nonce Nonce + // Save state to temporary variables + let x00 = y00, x01 = y01, x02 = y02, x03 = y03, x04 = y04, x05 = y05, x06 = y06, x07 = y07, x08 = y08, x09 = y09, x10 = y10, x11 = y11, x12 = y12, x13 = y13, x14 = y14, x15 = y15; + for (let r = 0; r < rounds; r += 2) { + x00 = (x00 + x04) | 0; + x12 = (0, _arx_ts_1.rotl)(x12 ^ x00, 16); + x08 = (x08 + x12) | 0; + x04 = (0, _arx_ts_1.rotl)(x04 ^ x08, 12); + x00 = (x00 + x04) | 0; + x12 = (0, _arx_ts_1.rotl)(x12 ^ x00, 8); + x08 = (x08 + x12) | 0; + x04 = (0, _arx_ts_1.rotl)(x04 ^ x08, 7); + x01 = (x01 + x05) | 0; + x13 = (0, _arx_ts_1.rotl)(x13 ^ x01, 16); + x09 = (x09 + x13) | 0; + x05 = (0, _arx_ts_1.rotl)(x05 ^ x09, 12); + x01 = (x01 + x05) | 0; + x13 = (0, _arx_ts_1.rotl)(x13 ^ x01, 8); + x09 = (x09 + x13) | 0; + x05 = (0, _arx_ts_1.rotl)(x05 ^ x09, 7); + x02 = (x02 + x06) | 0; + x14 = (0, _arx_ts_1.rotl)(x14 ^ x02, 16); + x10 = (x10 + x14) | 0; + x06 = (0, _arx_ts_1.rotl)(x06 ^ x10, 12); + x02 = (x02 + x06) | 0; + x14 = (0, _arx_ts_1.rotl)(x14 ^ x02, 8); + x10 = (x10 + x14) | 0; + x06 = (0, _arx_ts_1.rotl)(x06 ^ x10, 7); + x03 = (x03 + x07) | 0; + x15 = (0, _arx_ts_1.rotl)(x15 ^ x03, 16); + x11 = (x11 + x15) | 0; + x07 = (0, _arx_ts_1.rotl)(x07 ^ x11, 12); + x03 = (x03 + x07) | 0; + x15 = (0, _arx_ts_1.rotl)(x15 ^ x03, 8); + x11 = (x11 + x15) | 0; + x07 = (0, _arx_ts_1.rotl)(x07 ^ x11, 7); + x00 = (x00 + x05) | 0; + x15 = (0, _arx_ts_1.rotl)(x15 ^ x00, 16); + x10 = (x10 + x15) | 0; + x05 = (0, _arx_ts_1.rotl)(x05 ^ x10, 12); + x00 = (x00 + x05) | 0; + x15 = (0, _arx_ts_1.rotl)(x15 ^ x00, 8); + x10 = (x10 + x15) | 0; + x05 = (0, _arx_ts_1.rotl)(x05 ^ x10, 7); + x01 = (x01 + x06) | 0; + x12 = (0, _arx_ts_1.rotl)(x12 ^ x01, 16); + x11 = (x11 + x12) | 0; + x06 = (0, _arx_ts_1.rotl)(x06 ^ x11, 12); + x01 = (x01 + x06) | 0; + x12 = (0, _arx_ts_1.rotl)(x12 ^ x01, 8); + x11 = (x11 + x12) | 0; + x06 = (0, _arx_ts_1.rotl)(x06 ^ x11, 7); + x02 = (x02 + x07) | 0; + x13 = (0, _arx_ts_1.rotl)(x13 ^ x02, 16); + x08 = (x08 + x13) | 0; + x07 = (0, _arx_ts_1.rotl)(x07 ^ x08, 12); + x02 = (x02 + x07) | 0; + x13 = (0, _arx_ts_1.rotl)(x13 ^ x02, 8); + x08 = (x08 + x13) | 0; + x07 = (0, _arx_ts_1.rotl)(x07 ^ x08, 7); + x03 = (x03 + x04) | 0; + x14 = (0, _arx_ts_1.rotl)(x14 ^ x03, 16); + x09 = (x09 + x14) | 0; + x04 = (0, _arx_ts_1.rotl)(x04 ^ x09, 12); + x03 = (x03 + x04) | 0; + x14 = (0, _arx_ts_1.rotl)(x14 ^ x03, 8); + x09 = (x09 + x14) | 0; + x04 = (0, _arx_ts_1.rotl)(x04 ^ x09, 7); + } + // Write output + let oi = 0; + out[oi++] = (y00 + x00) | 0; + out[oi++] = (y01 + x01) | 0; + out[oi++] = (y02 + x02) | 0; + out[oi++] = (y03 + x03) | 0; + out[oi++] = (y04 + x04) | 0; + out[oi++] = (y05 + x05) | 0; + out[oi++] = (y06 + x06) | 0; + out[oi++] = (y07 + x07) | 0; + out[oi++] = (y08 + x08) | 0; + out[oi++] = (y09 + x09) | 0; + out[oi++] = (y10 + x10) | 0; + out[oi++] = (y11 + x11) | 0; + out[oi++] = (y12 + x12) | 0; + out[oi++] = (y13 + x13) | 0; + out[oi++] = (y14 + x14) | 0; + out[oi++] = (y15 + x15) | 0; +} +/** + * hchacha helper method, used primarily in xchacha, to hash + * key and nonce into key' and nonce'. + * Same as chachaCore, but there doesn't seem to be a way to move the block + * out without 25% performance hit. + */ +// prettier-ignore +function hchacha(s, k, i, o32) { + let x00 = s[0], x01 = s[1], x02 = s[2], x03 = s[3], x04 = k[0], x05 = k[1], x06 = k[2], x07 = k[3], x08 = k[4], x09 = k[5], x10 = k[6], x11 = k[7], x12 = i[0], x13 = i[1], x14 = i[2], x15 = i[3]; + for (let r = 0; r < 20; r += 2) { + x00 = (x00 + x04) | 0; + x12 = (0, _arx_ts_1.rotl)(x12 ^ x00, 16); + x08 = (x08 + x12) | 0; + x04 = (0, _arx_ts_1.rotl)(x04 ^ x08, 12); + x00 = (x00 + x04) | 0; + x12 = (0, _arx_ts_1.rotl)(x12 ^ x00, 8); + x08 = (x08 + x12) | 0; + x04 = (0, _arx_ts_1.rotl)(x04 ^ x08, 7); + x01 = (x01 + x05) | 0; + x13 = (0, _arx_ts_1.rotl)(x13 ^ x01, 16); + x09 = (x09 + x13) | 0; + x05 = (0, _arx_ts_1.rotl)(x05 ^ x09, 12); + x01 = (x01 + x05) | 0; + x13 = (0, _arx_ts_1.rotl)(x13 ^ x01, 8); + x09 = (x09 + x13) | 0; + x05 = (0, _arx_ts_1.rotl)(x05 ^ x09, 7); + x02 = (x02 + x06) | 0; + x14 = (0, _arx_ts_1.rotl)(x14 ^ x02, 16); + x10 = (x10 + x14) | 0; + x06 = (0, _arx_ts_1.rotl)(x06 ^ x10, 12); + x02 = (x02 + x06) | 0; + x14 = (0, _arx_ts_1.rotl)(x14 ^ x02, 8); + x10 = (x10 + x14) | 0; + x06 = (0, _arx_ts_1.rotl)(x06 ^ x10, 7); + x03 = (x03 + x07) | 0; + x15 = (0, _arx_ts_1.rotl)(x15 ^ x03, 16); + x11 = (x11 + x15) | 0; + x07 = (0, _arx_ts_1.rotl)(x07 ^ x11, 12); + x03 = (x03 + x07) | 0; + x15 = (0, _arx_ts_1.rotl)(x15 ^ x03, 8); + x11 = (x11 + x15) | 0; + x07 = (0, _arx_ts_1.rotl)(x07 ^ x11, 7); + x00 = (x00 + x05) | 0; + x15 = (0, _arx_ts_1.rotl)(x15 ^ x00, 16); + x10 = (x10 + x15) | 0; + x05 = (0, _arx_ts_1.rotl)(x05 ^ x10, 12); + x00 = (x00 + x05) | 0; + x15 = (0, _arx_ts_1.rotl)(x15 ^ x00, 8); + x10 = (x10 + x15) | 0; + x05 = (0, _arx_ts_1.rotl)(x05 ^ x10, 7); + x01 = (x01 + x06) | 0; + x12 = (0, _arx_ts_1.rotl)(x12 ^ x01, 16); + x11 = (x11 + x12) | 0; + x06 = (0, _arx_ts_1.rotl)(x06 ^ x11, 12); + x01 = (x01 + x06) | 0; + x12 = (0, _arx_ts_1.rotl)(x12 ^ x01, 8); + x11 = (x11 + x12) | 0; + x06 = (0, _arx_ts_1.rotl)(x06 ^ x11, 7); + x02 = (x02 + x07) | 0; + x13 = (0, _arx_ts_1.rotl)(x13 ^ x02, 16); + x08 = (x08 + x13) | 0; + x07 = (0, _arx_ts_1.rotl)(x07 ^ x08, 12); + x02 = (x02 + x07) | 0; + x13 = (0, _arx_ts_1.rotl)(x13 ^ x02, 8); + x08 = (x08 + x13) | 0; + x07 = (0, _arx_ts_1.rotl)(x07 ^ x08, 7); + x03 = (x03 + x04) | 0; + x14 = (0, _arx_ts_1.rotl)(x14 ^ x03, 16); + x09 = (x09 + x14) | 0; + x04 = (0, _arx_ts_1.rotl)(x04 ^ x09, 12); + x03 = (x03 + x04) | 0; + x14 = (0, _arx_ts_1.rotl)(x14 ^ x03, 8); + x09 = (x09 + x14) | 0; + x04 = (0, _arx_ts_1.rotl)(x04 ^ x09, 7); + } + let oi = 0; + o32[oi++] = x00; + o32[oi++] = x01; + o32[oi++] = x02; + o32[oi++] = x03; + o32[oi++] = x12; + o32[oi++] = x13; + o32[oi++] = x14; + o32[oi++] = x15; +} +/** + * Original, non-RFC chacha20 from DJB. 8-byte nonce, 8-byte counter. + */ +exports.chacha20orig = (0, _arx_ts_1.createCipher)(chachaCore, { + counterRight: false, + counterLength: 8, + allowShortKeys: true, +}); +/** + * ChaCha stream cipher. Conforms to RFC 8439 (IETF, TLS). 12-byte nonce, 4-byte counter. + * With 12-byte nonce, it's not safe to use fill it with random (CSPRNG), due to collision chance. + */ +exports.chacha20 = (0, _arx_ts_1.createCipher)(chachaCore, { + counterRight: false, + counterLength: 4, + allowShortKeys: false, +}); +/** + * XChaCha eXtended-nonce ChaCha. 24-byte nonce. + * With 24-byte nonce, it's safe to use fill it with random (CSPRNG). + * https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha + */ +exports.xchacha20 = (0, _arx_ts_1.createCipher)(chachaCore, { + counterRight: false, + counterLength: 8, + extendNonceFn: hchacha, + allowShortKeys: false, +}); +/** + * Reduced 8-round chacha, described in original paper. + */ +exports.chacha8 = (0, _arx_ts_1.createCipher)(chachaCore, { + counterRight: false, + counterLength: 4, + rounds: 8, +}); +/** + * Reduced 12-round chacha, described in original paper. + */ +exports.chacha12 = (0, _arx_ts_1.createCipher)(chachaCore, { + counterRight: false, + counterLength: 4, + rounds: 12, +}); +const ZEROS16 = /* @__PURE__ */ new Uint8Array(16); +// Pad to digest size with zeros +const updatePadded = (h, msg) => { + h.update(msg); + const left = msg.length % 16; + if (left) + h.update(ZEROS16.subarray(left)); +}; +const ZEROS32 = /* @__PURE__ */ new Uint8Array(32); +function computeTag(fn, key, nonce, data, AAD) { + const authKey = fn(key, nonce, ZEROS32); + const h = _poly1305_ts_1.poly1305.create(authKey); + if (AAD) + updatePadded(h, AAD); + updatePadded(h, data); + const num = (0, utils_ts_1.u64Lengths)(data.length, AAD ? AAD.length : 0, true); + h.update(num); + const res = h.digest(); + (0, utils_ts_1.clean)(authKey, num); + return res; +} +/** + * AEAD algorithm from RFC 8439. + * Salsa20 and chacha (RFC 8439) use poly1305 differently. + * We could have composed them similar to: + * https://github.com/paulmillr/scure-base/blob/b266c73dde977b1dd7ef40ef7a23cc15aab526b3/index.ts#L250 + * But it's hard because of authKey: + * In salsa20, authKey changes position in salsa stream. + * In chacha, authKey can't be computed inside computeTag, it modifies the counter. + */ +const _poly1305_aead = (xorStream) => (key, nonce, AAD) => { + const tagLength = 16; + return { + encrypt(plaintext, output) { + const plength = plaintext.length; + output = (0, utils_ts_1.getOutput)(plength + tagLength, output, false); + output.set(plaintext); + const oPlain = output.subarray(0, -tagLength); + xorStream(key, nonce, oPlain, oPlain, 1); + const tag = computeTag(xorStream, key, nonce, oPlain, AAD); + output.set(tag, plength); // append tag + (0, utils_ts_1.clean)(tag); + return output; + }, + decrypt(ciphertext, output) { + output = (0, utils_ts_1.getOutput)(ciphertext.length - tagLength, output, false); + const data = ciphertext.subarray(0, -tagLength); + const passedTag = ciphertext.subarray(-tagLength); + const tag = computeTag(xorStream, key, nonce, data, AAD); + if (!(0, utils_ts_1.equalBytes)(passedTag, tag)) + throw new Error('invalid tag'); + output.set(ciphertext.subarray(0, -tagLength)); + xorStream(key, nonce, output, output, 1); // start stream with i=1 + (0, utils_ts_1.clean)(tag); + return output; + }, + }; +}; +exports._poly1305_aead = _poly1305_aead; +/** + * ChaCha20-Poly1305 from RFC 8439. + * + * Unsafe to use random nonces under the same key, due to collision chance. + * Prefer XChaCha instead. + */ +exports.chacha20poly1305 = (0, utils_ts_1.wrapCipher)({ blockSize: 64, nonceLength: 12, tagLength: 16 }, (0, exports._poly1305_aead)(exports.chacha20)); +/** + * XChaCha20-Poly1305 extended-nonce chacha. + * + * Can be safely used with random nonces (CSPRNG). + * See [IRTF draft](https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha). + */ +exports.xchacha20poly1305 = (0, utils_ts_1.wrapCipher)({ blockSize: 64, nonceLength: 24, tagLength: 16 }, (0, exports._poly1305_aead)(exports.xchacha20)); +//# sourceMappingURL=chacha.js.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/chacha.js.map b/node_modules/@noble/ciphers/chacha.js.map new file mode 100644 index 0000000000000000000000000000000000000000..52e9bdf655d2a6f1d1b9bc30a9f204e3e6c9adf4 --- /dev/null +++ b/node_modules/@noble/ciphers/chacha.js.map @@ -0,0 +1 @@ +{"version":3,"file":"chacha.js","sourceRoot":"","sources":["src/chacha.ts"],"names":[],"mappings":";;;AAsGA,0BAqDC;AA3JD;;;;;;;;;;;;;GAaG;AACH,uCAA+C;AAC/C,iDAA0C;AAC1C,yCASoB;AAEpB;;GAEG;AACH,kBAAkB;AAClB,SAAS,UAAU,CACjB,CAAc,EAAE,CAAc,EAAE,CAAc,EAAE,GAAgB,EAAE,GAAW,EAAE,MAAM,GAAG,EAAE;IAE1F,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CA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EAAC,iBAAS,CAAC,CAC1B,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/crypto.d.ts b/node_modules/@noble/ciphers/crypto.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ac181a0247597021010e0d9821dd2fdf4eb077c3 --- /dev/null +++ b/node_modules/@noble/ciphers/crypto.d.ts @@ -0,0 +1,2 @@ +export declare const crypto: any; +//# sourceMappingURL=crypto.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/crypto.d.ts.map b/node_modules/@noble/ciphers/crypto.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..4ecc6bca7aa42a3b588a191f90e89f1cc427a8dc --- /dev/null +++ b/node_modules/@noble/ciphers/crypto.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["src/crypto.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,MAAM,EAAE,GACqE,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/crypto.js b/node_modules/@noble/ciphers/crypto.js new file mode 100644 index 0000000000000000000000000000000000000000..8226391ffa9676473580dabd38450b050349eff0 --- /dev/null +++ b/node_modules/@noble/ciphers/crypto.js @@ -0,0 +1,5 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.crypto = void 0; +exports.crypto = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined; +//# sourceMappingURL=crypto.js.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/crypto.js.map b/node_modules/@noble/ciphers/crypto.js.map new file mode 100644 index 0000000000000000000000000000000000000000..0bb417ce63082bc8f1d4b29f2f7f1315668e5b44 --- /dev/null +++ b/node_modules/@noble/ciphers/crypto.js.map @@ -0,0 +1 @@ +{"version":3,"file":"crypto.js","sourceRoot":"","sources":["src/crypto.ts"],"names":[],"mappings":";;;AAOa,QAAA,MAAM,GACjB,OAAO,UAAU,KAAK,QAAQ,IAAI,QAAQ,IAAI,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/cryptoNode.d.ts b/node_modules/@noble/ciphers/cryptoNode.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..98bda7be4ddd7d83a758d97d502e691c6be18fc9 --- /dev/null +++ b/node_modules/@noble/ciphers/cryptoNode.d.ts @@ -0,0 +1,2 @@ +export declare const crypto: any; +//# sourceMappingURL=cryptoNode.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/cryptoNode.d.ts.map b/node_modules/@noble/ciphers/cryptoNode.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..4303dc76185976300b6741ae57c7a5475d91c85c --- /dev/null +++ b/node_modules/@noble/ciphers/cryptoNode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"cryptoNode.d.ts","sourceRoot":"","sources":["src/cryptoNode.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,MAAM,EAAE,GAKJ,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/cryptoNode.js b/node_modules/@noble/ciphers/cryptoNode.js new file mode 100644 index 0000000000000000000000000000000000000000..eba1a1ffb613251dad55ca8edb8f70308fc17ad9 --- /dev/null +++ b/node_modules/@noble/ciphers/cryptoNode.js @@ -0,0 +1,18 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.crypto = void 0; +/** + * Internal webcrypto alias. + * We prefer WebCrypto aka globalThis.crypto, which exists in node.js 16+. + * Falls back to Node.js built-in crypto for Node.js <=v14. + * See utils.ts for details. + * @module + */ +// @ts-ignore +const nc = require("node:crypto"); +exports.crypto = nc && typeof nc === 'object' && 'webcrypto' in nc + ? nc.webcrypto + : nc && typeof nc === 'object' && 'randomBytes' in nc + ? nc + : undefined; +//# sourceMappingURL=cryptoNode.js.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/cryptoNode.js.map b/node_modules/@noble/ciphers/cryptoNode.js.map new file mode 100644 index 0000000000000000000000000000000000000000..14983d52454d30f7ab7f9b28b7cd8972b3278e2d --- /dev/null +++ b/node_modules/@noble/ciphers/cryptoNode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"cryptoNode.js","sourceRoot":"","sources":["src/cryptoNode.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,aAAa;AACb,kCAAkC;AACrB,QAAA,MAAM,GACjB,EAAE,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,WAAW,IAAI,EAAE;IAC/C,CAAC,CAAE,EAAE,CAAC,SAAiB;IACvB,CAAC,CAAC,EAAE,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,aAAa,IAAI,EAAE;QACnD,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,SAAS,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/_arx.d.ts b/node_modules/@noble/ciphers/esm/_arx.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9b54727a4cbf2ec8d3ff2ceb4e604ada63a0a6e9 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/_arx.d.ts @@ -0,0 +1,59 @@ +/** + * Basic utils for ARX (add-rotate-xor) salsa and chacha ciphers. + +RFC8439 requires multi-step cipher stream, where +authKey starts with counter: 0, actual msg with counter: 1. + +For this, we need a way to re-use nonce / counter: + + const counter = new Uint8Array(4); + chacha(..., counter, ...); // counter is now 1 + chacha(..., counter, ...); // counter is now 2 + +This is complicated: + +- 32-bit counters are enough, no need for 64-bit: max ArrayBuffer size in JS is 4GB +- Original papers don't allow mutating counters +- Counter overflow is undefined [^1] +- Idea A: allow providing (nonce | counter) instead of just nonce, re-use it +- Caveat: Cannot be re-used through all cases: +- * chacha has (counter | nonce) +- * xchacha has (nonce16 | counter | nonce16) +- Idea B: separate nonce / counter and provide separate API for counter re-use +- Caveat: there are different counter sizes depending on an algorithm. +- salsa & chacha also differ in structures of key & sigma: + salsa20: s[0] | k(4) | s[1] | nonce(2) | ctr(2) | s[2] | k(4) | s[3] + chacha: s(4) | k(8) | ctr(1) | nonce(3) + chacha20orig: s(4) | k(8) | ctr(2) | nonce(2) +- Idea C: helper method such as `setSalsaState(key, nonce, sigma, data)` +- Caveat: we can't re-use counter array + +xchacha [^2] uses the subkey and remaining 8 byte nonce with ChaCha20 as normal +(prefixed by 4 NUL bytes, since [RFC8439] specifies a 12-byte nonce). + +[^1]: https://mailarchive.ietf.org/arch/msg/cfrg/gsOnTJzcbgG6OqD8Sc0GO5aR_tU/ +[^2]: https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha#appendix-A.2 + + * @module + */ +import { type XorStream } from './utils.ts'; +export declare function rotl(a: number, b: number): number; +/** Ciphers must use u32 for efficiency. */ +export type CipherCoreFn = (sigma: Uint32Array, key: Uint32Array, nonce: Uint32Array, output: Uint32Array, counter: number, rounds?: number) => void; +/** Method which extends key + short nonce into larger nonce / diff key. */ +export type ExtendNonceFn = (sigma: Uint32Array, key: Uint32Array, input: Uint32Array, output: Uint32Array) => void; +/** ARX cipher options. + * * `allowShortKeys` for 16-byte keys + * * `counterLength` in bytes + * * `counterRight`: right: `nonce|counter`; left: `counter|nonce` + * */ +export type CipherOpts = { + allowShortKeys?: boolean; + extendNonceFn?: ExtendNonceFn; + counterLength?: number; + counterRight?: boolean; + rounds?: number; +}; +/** Creates ARX-like (ChaCha, Salsa) cipher stream from core function. */ +export declare function createCipher(core: CipherCoreFn, opts: CipherOpts): XorStream; +//# sourceMappingURL=_arx.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/_arx.d.ts.map b/node_modules/@noble/ciphers/esm/_arx.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..e02f48cbf09795f51c001f8ce92fdc4039b03f38 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/_arx.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"_arx.d.ts","sourceRoot":"","sources":["../src/_arx.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EACL,KAAK,SAAS,EACf,MAAM,YAAY,CAAC;AAUpB,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,2CAA2C;AAC3C,MAAM,MAAM,YAAY,GAAG,CACzB,KAAK,EAAE,WAAW,EAClB,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,KACZ,IAAI,CAAC;AAEV,2EAA2E;AAC3E,MAAM,MAAM,aAAa,GAAG,CAC1B,KAAK,EAAE,WAAW,EAClB,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,WAAW,KAChB,IAAI,CAAC;AAEV;;;;KAIK;AACL,MAAM,MAAM,UAAU,GAAG;IACvB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAwDF,yEAAyE;AACzE,wBAAgB,YAAY,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,GAAG,SAAS,CAkF5E"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/_arx.js b/node_modules/@noble/ciphers/esm/_arx.js new file mode 100644 index 0000000000000000000000000000000000000000..3b8daee6a8aaa8c3f4b87c51473cc6cbd5fbc3e2 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/_arx.js @@ -0,0 +1,171 @@ +/** + * Basic utils for ARX (add-rotate-xor) salsa and chacha ciphers. + +RFC8439 requires multi-step cipher stream, where +authKey starts with counter: 0, actual msg with counter: 1. + +For this, we need a way to re-use nonce / counter: + + const counter = new Uint8Array(4); + chacha(..., counter, ...); // counter is now 1 + chacha(..., counter, ...); // counter is now 2 + +This is complicated: + +- 32-bit counters are enough, no need for 64-bit: max ArrayBuffer size in JS is 4GB +- Original papers don't allow mutating counters +- Counter overflow is undefined [^1] +- Idea A: allow providing (nonce | counter) instead of just nonce, re-use it +- Caveat: Cannot be re-used through all cases: +- * chacha has (counter | nonce) +- * xchacha has (nonce16 | counter | nonce16) +- Idea B: separate nonce / counter and provide separate API for counter re-use +- Caveat: there are different counter sizes depending on an algorithm. +- salsa & chacha also differ in structures of key & sigma: + salsa20: s[0] | k(4) | s[1] | nonce(2) | ctr(2) | s[2] | k(4) | s[3] + chacha: s(4) | k(8) | ctr(1) | nonce(3) + chacha20orig: s(4) | k(8) | ctr(2) | nonce(2) +- Idea C: helper method such as `setSalsaState(key, nonce, sigma, data)` +- Caveat: we can't re-use counter array + +xchacha [^2] uses the subkey and remaining 8 byte nonce with ChaCha20 as normal +(prefixed by 4 NUL bytes, since [RFC8439] specifies a 12-byte nonce). + +[^1]: https://mailarchive.ietf.org/arch/msg/cfrg/gsOnTJzcbgG6OqD8Sc0GO5aR_tU/ +[^2]: https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha#appendix-A.2 + + * @module + */ +// prettier-ignore +import { abool, abytes, anumber, checkOpts, clean, copyBytes, u32 } from "./utils.js"; +// We can't make top-level var depend on utils.utf8ToBytes +// because it's not present in all envs. Creating a similar fn here +const _utf8ToBytes = (str) => Uint8Array.from(str.split('').map((c) => c.charCodeAt(0))); +const sigma16 = _utf8ToBytes('expand 16-byte k'); +const sigma32 = _utf8ToBytes('expand 32-byte k'); +const sigma16_32 = u32(sigma16); +const sigma32_32 = u32(sigma32); +export function rotl(a, b) { + return (a << b) | (a >>> (32 - b)); +} +// Is byte array aligned to 4 byte offset (u32)? +function isAligned32(b) { + return b.byteOffset % 4 === 0; +} +// Salsa and Chacha block length is always 512-bit +const BLOCK_LEN = 64; +const BLOCK_LEN32 = 16; +// new Uint32Array([2**32]) // => Uint32Array(1) [ 0 ] +// new Uint32Array([2**32-1]) // => Uint32Array(1) [ 4294967295 ] +const MAX_COUNTER = 2 ** 32 - 1; +const U32_EMPTY = new Uint32Array(); +function runCipher(core, sigma, key, nonce, data, output, counter, rounds) { + const len = data.length; + const block = new Uint8Array(BLOCK_LEN); + const b32 = u32(block); + // Make sure that buffers aligned to 4 bytes + const isAligned = isAligned32(data) && isAligned32(output); + const d32 = isAligned ? u32(data) : U32_EMPTY; + const o32 = isAligned ? u32(output) : U32_EMPTY; + for (let pos = 0; pos < len; counter++) { + core(sigma, key, nonce, b32, counter, rounds); + if (counter >= MAX_COUNTER) + throw new Error('arx: counter overflow'); + const take = Math.min(BLOCK_LEN, len - pos); + // aligned to 4 bytes + if (isAligned && take === BLOCK_LEN) { + const pos32 = pos / 4; + if (pos % 4 !== 0) + throw new Error('arx: invalid block position'); + for (let j = 0, posj; j < BLOCK_LEN32; j++) { + posj = pos32 + j; + o32[posj] = d32[posj] ^ b32[j]; + } + pos += BLOCK_LEN; + continue; + } + for (let j = 0, posj; j < take; j++) { + posj = pos + j; + output[posj] = data[posj] ^ block[j]; + } + pos += take; + } +} +/** Creates ARX-like (ChaCha, Salsa) cipher stream from core function. */ +export function createCipher(core, opts) { + const { allowShortKeys, extendNonceFn, counterLength, counterRight, rounds } = checkOpts({ allowShortKeys: false, counterLength: 8, counterRight: false, rounds: 20 }, opts); + if (typeof core !== 'function') + throw new Error('core must be a function'); + anumber(counterLength); + anumber(rounds); + abool(counterRight); + abool(allowShortKeys); + return (key, nonce, data, output, counter = 0) => { + abytes(key); + abytes(nonce); + abytes(data); + const len = data.length; + if (output === undefined) + output = new Uint8Array(len); + abytes(output); + anumber(counter); + if (counter < 0 || counter >= MAX_COUNTER) + throw new Error('arx: counter overflow'); + if (output.length < len) + throw new Error(`arx: output (${output.length}) is shorter than data (${len})`); + const toClean = []; + // Key & sigma + // key=16 -> sigma16, k=key|key + // key=32 -> sigma32, k=key + let l = key.length; + let k; + let sigma; + if (l === 32) { + toClean.push((k = copyBytes(key))); + sigma = sigma32_32; + } + else if (l === 16 && allowShortKeys) { + k = new Uint8Array(32); + k.set(key); + k.set(key, 16); + sigma = sigma16_32; + toClean.push(k); + } + else { + throw new Error(`arx: invalid 32-byte key, got length=${l}`); + } + // Nonce + // salsa20: 8 (8-byte counter) + // chacha20orig: 8 (8-byte counter) + // chacha20: 12 (4-byte counter) + // xsalsa20: 24 (16 -> hsalsa, 8 -> old nonce) + // xchacha20: 24 (16 -> hchacha, 8 -> old nonce) + // Align nonce to 4 bytes + if (!isAligned32(nonce)) + toClean.push((nonce = copyBytes(nonce))); + const k32 = u32(k); + // hsalsa & hchacha: handle extended nonce + if (extendNonceFn) { + if (nonce.length !== 24) + throw new Error(`arx: extended nonce must be 24 bytes`); + extendNonceFn(sigma, k32, u32(nonce.subarray(0, 16)), k32); + nonce = nonce.subarray(16); + } + // Handle nonce counter + const nonceNcLen = 16 - counterLength; + if (nonceNcLen !== nonce.length) + throw new Error(`arx: nonce must be ${nonceNcLen} or 16 bytes`); + // Pad counter when nonce is 64 bit + if (nonceNcLen !== 12) { + const nc = new Uint8Array(12); + nc.set(nonce, counterRight ? 0 : 12 - nonce.length); + nonce = nc; + toClean.push(nonce); + } + const n32 = u32(nonce); + runCipher(core, sigma, k32, n32, data, output, counter, rounds); + clean(...toClean); + return output; + }; +} +//# sourceMappingURL=_arx.js.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/_arx.js.map b/node_modules/@noble/ciphers/esm/_arx.js.map new file mode 100644 index 0000000000000000000000000000000000000000..cddd51f7360c15963f028d5eb13304e06234242a --- /dev/null +++ b/node_modules/@noble/ciphers/esm/_arx.js.map @@ -0,0 +1 @@ +{"version":3,"file":"_arx.js","sourceRoot":"","sources":["../src/_arx.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,kBAAkB;AAClB,OAAO,EACW,KAAK,E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at end of file diff --git a/node_modules/@noble/ciphers/esm/_assert.d.ts b/node_modules/@noble/ciphers/esm/_assert.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5faec8e064ec06f2b141d70acb3054f5a1bf4cbe --- /dev/null +++ b/node_modules/@noble/ciphers/esm/_assert.d.ts @@ -0,0 +1,19 @@ +/** + * Internal assertion helpers. + * @module + * @deprecated + */ +import { abytes as ab, abool as abool_, aexists as ae, anumber as an, aoutput as ao, type IHash as H } from './utils.ts'; +/** @deprecated Use import from `noble/hashes/utils` module */ +export declare const abool: typeof abool_; +/** @deprecated Use import from `noble/hashes/utils` module */ +export declare const abytes: typeof ab; +/** @deprecated Use import from `noble/hashes/utils` module */ +export declare const aexists: typeof ae; +/** @deprecated Use import from `noble/hashes/utils` module */ +export declare const anumber: typeof an; +/** @deprecated Use import from `noble/hashes/utils` module */ +export declare const aoutput: typeof ao; +/** @deprecated Use import from `noble/hashes/utils` module */ +export type Hash = H; +//# sourceMappingURL=_assert.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/_assert.d.ts.map b/node_modules/@noble/ciphers/esm/_assert.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..140a241976b73c43c88945332bb602cd2d2bf289 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/_assert.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"_assert.d.ts","sourceRoot":"","sources":["../src/_assert.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,MAAM,IAAI,EAAE,EACZ,KAAK,IAAI,MAAM,EACf,OAAO,IAAI,EAAE,EACb,OAAO,IAAI,EAAE,EACb,OAAO,IAAI,EAAE,EACb,KAAK,KAAK,IAAI,CAAC,EAChB,MAAM,YAAY,CAAC;AACpB,8DAA8D;AAC9D,eAAO,MAAM,KAAK,EAAE,OAAO,MAAe,CAAC;AAC3C,8DAA8D;AAC9D,eAAO,MAAM,MAAM,EAAE,OAAO,EAAO,CAAC;AACpC,8DAA8D;AAC9D,eAAO,MAAM,OAAO,EAAE,OAAO,EAAO,CAAC;AACrC,8DAA8D;AAC9D,eAAO,MAAM,OAAO,EAAE,OAAO,EAAO,CAAC;AACrC,8DAA8D;AAC9D,eAAO,MAAM,OAAO,EAAE,OAAO,EAAO,CAAC;AACrC,8DAA8D;AAC9D,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/_assert.js b/node_modules/@noble/ciphers/esm/_assert.js new file mode 100644 index 0000000000000000000000000000000000000000..f99c5373bfa3ed5a23643075362d81bad58d3242 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/_assert.js @@ -0,0 +1,17 @@ +/** + * Internal assertion helpers. + * @module + * @deprecated + */ +import { abytes as ab, abool as abool_, aexists as ae, anumber as an, aoutput as ao, } from "./utils.js"; +/** @deprecated Use import from `noble/hashes/utils` module */ +export const abool = abool_; +/** @deprecated Use import from `noble/hashes/utils` module */ +export const abytes = ab; +/** @deprecated Use import from `noble/hashes/utils` module */ +export const aexists = ae; +/** @deprecated Use import from `noble/hashes/utils` module */ +export const anumber = an; +/** @deprecated Use import from `noble/hashes/utils` module */ +export const aoutput = ao; +//# sourceMappingURL=_assert.js.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/_assert.js.map b/node_modules/@noble/ciphers/esm/_assert.js.map new file mode 100644 index 0000000000000000000000000000000000000000..69fe59b49d10f3f687e7a833f0aa29e571856197 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/_assert.js.map @@ -0,0 +1 @@ +{"version":3,"file":"_assert.js","sourceRoot":"","sources":["../src/_assert.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,MAAM,IAAI,EAAE,EACZ,KAAK,IAAI,MAAM,EACf,OAAO,IAAI,EAAE,EACb,OAAO,IAAI,EAAE,EACb,OAAO,IAAI,EAAE,GAEd,MAAM,YAAY,CAAC;AACpB,8DAA8D;AAC9D,MAAM,CAAC,MAAM,KAAK,GAAkB,MAAM,CAAC;AAC3C,8DAA8D;AAC9D,MAAM,CAAC,MAAM,MAAM,GAAc,EAAE,CAAC;AACpC,8DAA8D;AAC9D,MAAM,CAAC,MAAM,OAAO,GAAc,EAAE,CAAC;AACrC,8DAA8D;AAC9D,MAAM,CAAC,MAAM,OAAO,GAAc,EAAE,CAAC;AACrC,8DAA8D;AAC9D,MAAM,CAAC,MAAM,OAAO,GAAc,EAAE,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/_micro.d.ts b/node_modules/@noble/ciphers/esm/_micro.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6673e9e79d28f1559aaec30fd35adad62dac87d9 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/_micro.d.ts @@ -0,0 +1,41 @@ +import { type Cipher, type XorStream } from './utils.ts'; +export type ARXCipherN = ((key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => Cipher) & { + blockSize: number; + nonceLength: number; + tagLength: number; +}; +/** hsalsa hashes key and nonce into key' and nonce'. */ +export declare function hsalsa(s: Uint32Array, k: Uint32Array, i: Uint32Array, o32: Uint32Array): void; +/** hchacha hashes key and nonce into key' and nonce'. */ +export declare function hchacha(s: Uint32Array, k: Uint32Array, i: Uint32Array, o32: Uint32Array): void; +/** salsa20, 12-byte nonce. */ +export declare const salsa20: XorStream; +/** xsalsa20, 24-byte nonce. */ +export declare const xsalsa20: XorStream; +/** chacha20 non-RFC, original version by djb. 8-byte nonce, 8-byte counter. */ +export declare const chacha20orig: XorStream; +/** chacha20 RFC 8439 (IETF / TLS). 12-byte nonce, 4-byte counter. */ +export declare const chacha20: XorStream; +/** xchacha20 eXtended-nonce. https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha */ +export declare const xchacha20: XorStream; +/** 8-round chacha from the original paper. */ +export declare const chacha8: XorStream; +/** 12-round chacha from the original paper. */ +export declare const chacha12: XorStream; +/** Poly1305 polynomial MAC. Can be speed-up using BigUint64Array, at the cost of complexity. */ +export declare function poly1305(msg: Uint8Array, key: Uint8Array): Uint8Array; +/** xsalsa20-poly1305 eXtended-nonce (24 bytes) salsa. */ +export declare const xsalsa20poly1305: ARXCipherN; +/** Alias to `xsalsa20poly1305`. */ +export declare function secretbox(key: Uint8Array, nonce: Uint8Array): { + seal: (plaintext: Uint8Array) => Uint8Array; + open: (ciphertext: Uint8Array) => Uint8Array; +}; +export declare const _poly1305_aead: (fn: XorStream) => (key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => Cipher; +/** chacha20-poly1305 12-byte-nonce chacha. */ +export declare const chacha20poly1305: ARXCipherN; +/** + * XChaCha20-Poly1305 extended-nonce chacha. Can be safely used with random nonces (CSPRNG). + */ +export declare const xchacha20poly1305: ARXCipherN; +//# sourceMappingURL=_micro.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/_micro.d.ts.map b/node_modules/@noble/ciphers/esm/_micro.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..723f6ce0a4a7899d2b33ef90d3e820b5c64cf171 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/_micro.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"_micro.d.ts","sourceRoot":"","sources":["../src/_micro.ts"],"names":[],"mappings":"AASA,OAAO,EACL,KAAK,MAAM,EACX,KAAK,SAAS,EASf,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,CAAC,EAAE,UAAU,KAAK,MAAM,CAAC,GAAG;IAC5F,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAuEF,wDAAwD;AAExD,wBAAgB,MAAM,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,EAAE,GAAG,EAAE,WAAW,GAAG,IAAI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esm/_micro.js b/node_modules/@noble/ciphers/esm/_micro.js new file mode 100644 index 0000000000000000000000000000000000000000..04157cbe742fc3f1e2822f19965692fecc08fd05 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/_micro.js @@ -0,0 +1,252 @@ +/** + * noble-ciphers-micro: more auditable, but 4x slower version of salsa20, chacha & poly1305. + * Implements the same algorithms that are present in other files, but without + * unrolled loops (https://en.wikipedia.org/wiki/Loop_unrolling). + * @module + */ +/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */ +// prettier-ignore +import { createCipher, rotl } from "./_arx.js"; +import { abytes, bytesToHex, concatBytes, equalBytes, hexToNumber, numberToBytesBE, u64Lengths, wrapCipher, } from "./utils.js"; +function bytesToNumberLE(bytes) { + abytes(bytes); + return hexToNumber(bytesToHex(Uint8Array.from(bytes).reverse())); +} +function numberToBytesLE(n, len) { + return numberToBytesBE(n, len).reverse(); +} +function salsaQR(x, a, b, c, d) { + x[b] ^= rotl((x[a] + x[d]) | 0, 7); + x[c] ^= rotl((x[b] + x[a]) | 0, 9); + x[d] ^= rotl((x[c] + x[b]) | 0, 13); + x[a] ^= rotl((x[d] + x[c]) | 0, 18); +} +// prettier-ignore +function chachaQR(x, a, b, c, d) { + x[a] = (x[a] + x[b]) | 0; + x[d] = rotl(x[d] ^ x[a], 16); + x[c] = (x[c] + x[d]) | 0; + x[b] = rotl(x[b] ^ x[c], 12); + x[a] = (x[a] + x[b]) | 0; + x[d] = rotl(x[d] ^ x[a], 8); + x[c] = (x[c] + x[d]) | 0; + x[b] = rotl(x[b] ^ x[c], 7); +} +function salsaRound(x, rounds = 20) { + for (let r = 0; r < rounds; r += 2) { + salsaQR(x, 0, 4, 8, 12); + salsaQR(x, 5, 9, 13, 1); + salsaQR(x, 10, 14, 2, 6); + salsaQR(x, 15, 3, 7, 11); + salsaQR(x, 0, 1, 2, 3); + salsaQR(x, 5, 6, 7, 4); + salsaQR(x, 10, 11, 8, 9); + salsaQR(x, 15, 12, 13, 14); + } +} +function chachaRound(x, rounds = 20) { + for (let r = 0; r < rounds; r += 2) { + chachaQR(x, 0, 4, 8, 12); + chachaQR(x, 1, 5, 9, 13); + chachaQR(x, 2, 6, 10, 14); + chachaQR(x, 3, 7, 11, 15); + chachaQR(x, 0, 5, 10, 15); + chachaQR(x, 1, 6, 11, 12); + chachaQR(x, 2, 7, 8, 13); + chachaQR(x, 3, 4, 9, 14); + } +} +function salsaCore(s, k, n, out, cnt, rounds = 20) { + // prettier-ignore + const y = new Uint32Array([ + s[0], k[0], k[1], k[2], // "expa" Key Key Key + k[3], s[1], n[0], n[1], // Key "nd 3" Nonce Nonce + cnt, 0, s[2], k[4], // Pos. Pos. "2-by" Key + k[5], k[6], k[7], s[3], // Key Key Key "te k" + ]); + const x = y.slice(); + salsaRound(x, rounds); + for (let i = 0; i < 16; i++) + out[i] = (y[i] + x[i]) | 0; +} +/** hsalsa hashes key and nonce into key' and nonce'. */ +// prettier-ignore +export function hsalsa(s, k, i, o32) { + const x = new Uint32Array([ + s[0], k[0], k[1], k[2], + k[3], s[1], i[0], i[1], + i[2], i[3], s[2], k[4], + k[5], k[6], k[7], s[3] + ]); + salsaRound(x, 20); + let oi = 0; + o32[oi++] = x[0]; + o32[oi++] = x[5]; + o32[oi++] = x[10]; + o32[oi++] = x[15]; + o32[oi++] = x[6]; + o32[oi++] = x[7]; + o32[oi++] = x[8]; + o32[oi++] = x[9]; +} +function chachaCore(s, k, n, out, cnt, rounds = 20) { + // prettier-ignore + const y = new Uint32Array([ + s[0], s[1], s[2], s[3], // "expa" "nd 3" "2-by" "te k" + k[0], k[1], k[2], k[3], // Key Key Key Key + k[4], k[5], k[6], k[7], // Key Key Key Key + cnt, n[0], n[1], n[2], // Counter Counter Nonce Nonce + ]); + const x = y.slice(); + chachaRound(x, rounds); + for (let i = 0; i < 16; i++) + out[i] = (y[i] + x[i]) | 0; +} +/** hchacha hashes key and nonce into key' and nonce'. */ +// prettier-ignore +export function hchacha(s, k, i, o32) { + const x = new Uint32Array([ + s[0], s[1], s[2], s[3], + k[0], k[1], k[2], k[3], + k[4], k[5], k[6], k[7], + i[0], i[1], i[2], i[3], + ]); + chachaRound(x, 20); + let oi = 0; + o32[oi++] = x[0]; + o32[oi++] = x[1]; + o32[oi++] = x[2]; + o32[oi++] = x[3]; + o32[oi++] = x[12]; + o32[oi++] = x[13]; + o32[oi++] = x[14]; + o32[oi++] = x[15]; +} +/** salsa20, 12-byte nonce. */ +export const salsa20 = /* @__PURE__ */ createCipher(salsaCore, { + allowShortKeys: true, + counterRight: true, +}); +/** xsalsa20, 24-byte nonce. */ +export const xsalsa20 = /* @__PURE__ */ createCipher(salsaCore, { + counterRight: true, + extendNonceFn: hsalsa, +}); +/** chacha20 non-RFC, original version by djb. 8-byte nonce, 8-byte counter. */ +export const chacha20orig = /* @__PURE__ */ createCipher(chachaCore, { + allowShortKeys: true, + counterRight: false, + counterLength: 8, +}); +/** chacha20 RFC 8439 (IETF / TLS). 12-byte nonce, 4-byte counter. */ +export const chacha20 = /* @__PURE__ */ createCipher(chachaCore, { + counterRight: false, + counterLength: 4, +}); +/** xchacha20 eXtended-nonce. https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha */ +export const xchacha20 = /* @__PURE__ */ createCipher(chachaCore, { + counterRight: false, + counterLength: 8, + extendNonceFn: hchacha, +}); +/** 8-round chacha from the original paper. */ +export const chacha8 = /* @__PURE__ */ createCipher(chachaCore, { + counterRight: false, + counterLength: 4, + rounds: 8, +}); +/** 12-round chacha from the original paper. */ +export const chacha12 = /* @__PURE__ */ createCipher(chachaCore, { + counterRight: false, + counterLength: 4, + rounds: 12, +}); +const POW_2_130_5 = BigInt(2) ** BigInt(130) - BigInt(5); +const POW_2_128_1 = BigInt(2) ** BigInt(16 * 8) - BigInt(1); +const CLAMP_R = BigInt('0x0ffffffc0ffffffc0ffffffc0fffffff'); +const _0 = BigInt(0); +const _1 = BigInt(1); +/** Poly1305 polynomial MAC. Can be speed-up using BigUint64Array, at the cost of complexity. */ +export function poly1305(msg, key) { + abytes(msg); + abytes(key, 32); + let acc = _0; + const r = bytesToNumberLE(key.subarray(0, 16)) & CLAMP_R; + const s = bytesToNumberLE(key.subarray(16)); + // Process by 16 byte chunks + for (let i = 0; i < msg.length; i += 16) { + const m = msg.subarray(i, i + 16); + const n = bytesToNumberLE(m) | (_1 << BigInt(8 * m.length)); + acc = ((acc + n) * r) % POW_2_130_5; + } + const res = (acc + s) & POW_2_128_1; + return numberToBytesLE(res, 16); +} +function computeTag(fn, key, nonce, ciphertext, AAD) { + const res = []; + if (AAD) { + res.push(AAD); + const leftover = AAD.length % 16; + if (leftover > 0) + res.push(new Uint8Array(16 - leftover)); + } + res.push(ciphertext); + const leftover = ciphertext.length % 16; + if (leftover > 0) + res.push(new Uint8Array(16 - leftover)); + res.push(u64Lengths(ciphertext.length, AAD ? AAD.length : 0, true)); + const authKey = fn(key, nonce, new Uint8Array(32)); + return poly1305(concatBytes(...res), authKey); +} +/** xsalsa20-poly1305 eXtended-nonce (24 bytes) salsa. */ +export const xsalsa20poly1305 = /* @__PURE__ */ wrapCipher({ blockSize: 64, nonceLength: 24, tagLength: 16 }, function xsalsapoly(key, nonce) { + return { + encrypt(plaintext) { + const m = concatBytes(new Uint8Array(32), plaintext); + const c = xsalsa20(key, nonce, m); + const authKey = c.subarray(0, 32); + const data = c.subarray(32); + const tag = poly1305(data, authKey); + return concatBytes(tag, data); + }, + decrypt(ciphertext) { + const c = concatBytes(new Uint8Array(16), ciphertext); + const passedTag = c.subarray(16, 32); + const authKey = xsalsa20(key, nonce, new Uint8Array(32)); + const tag = poly1305(c.subarray(32), authKey); + if (!equalBytes(tag, passedTag)) + throw new Error('invalid poly1305 tag'); + return xsalsa20(key, nonce, c).subarray(32); + }, + }; +}); +/** Alias to `xsalsa20poly1305`. */ +export function secretbox(key, nonce) { + const xs = xsalsa20poly1305(key, nonce); + return { seal: xs.encrypt, open: xs.decrypt }; +} +export const _poly1305_aead = (fn) => (key, nonce, AAD) => { + const tagLength = 16; + return { + encrypt(plaintext) { + const data = fn(key, nonce, plaintext, undefined, 1); // stream from i=1 + const tag = computeTag(fn, key, nonce, data, AAD); + return concatBytes(data, tag); + }, + decrypt(ciphertext) { + const passedTag = ciphertext.subarray(-tagLength); + const data = ciphertext.subarray(0, -tagLength); + const tag = computeTag(fn, key, nonce, data, AAD); + if (!equalBytes(tag, passedTag)) + throw new Error('invalid poly1305 tag'); + return fn(key, nonce, data, undefined, 1); // stream from i=1 + }, + }; +}; +/** chacha20-poly1305 12-byte-nonce chacha. */ +export const chacha20poly1305 = /* @__PURE__ */ wrapCipher({ blockSize: 64, nonceLength: 12, tagLength: 16 }, _poly1305_aead(chacha20)); +/** + * XChaCha20-Poly1305 extended-nonce chacha. Can be safely used with random nonces (CSPRNG). + */ +export const xchacha20poly1305 = /* @__PURE__ */ wrapCipher({ blockSize: 64, nonceLength: 24, tagLength: 16 }, _poly1305_aead(xchacha20)); +//# sourceMappingURL=_micro.js.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/_micro.js.map b/node_modules/@noble/ciphers/esm/_micro.js.map new file mode 100644 index 0000000000000000000000000000000000000000..ece8975f1caea38f5ab7154aa14231e1bc21916e --- /dev/null +++ b/node_modules/@noble/ciphers/esm/_micro.js.map @@ -0,0 +1 @@ +{"version":3,"file":"_micro.js","sourceRoot":"","sources":["../src/_micro.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,uEAAuE;AACvE,kBAAkB;AAClB,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAGL,MAAM,EACN,UAAU,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,eAAe,EACf,UAAU,EACV,UAAU,GACX,MAAM,YAAY,CAAC;AAQpB,SAAS,eAAe,CAAC,KAAiB;IACxC,MAAM,CAAC,KAAK,CAAC,CAAC;IACd,OAAO,WAAW,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,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SAAS,CAAC,CAC1B,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/_poly1305.d.ts b/node_modules/@noble/ciphers/esm/_poly1305.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..921dd3bbb8d753016114539bbb14f80d2b475100 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/_poly1305.d.ts @@ -0,0 +1,29 @@ +/** + * Poly1305 ([PDF](https://cr.yp.to/mac/poly1305-20050329.pdf), + * [wiki](https://en.wikipedia.org/wiki/Poly1305)) + * is a fast and parallel secret-key message-authentication code suitable for + * a wide variety of applications. It was standardized in + * [RFC 8439](https://datatracker.ietf.org/doc/html/rfc8439) and is now used in TLS 1.3. + * + * Polynomial MACs are not perfect for every situation: + * they lack Random Key Robustness: the MAC can be forged, and can't be used in PAKE schemes. + * See [invisible salamanders attack](https://keymaterial.net/2020/09/07/invisible-salamanders-in-aes-gcm-siv/). + * To combat invisible salamanders, `hash(key)` can be included in ciphertext, + * however, this would violate ciphertext indistinguishability: + * an attacker would know which key was used - so `HKDF(key, i)` + * could be used instead. + * + * Check out [original website](https://cr.yp.to/mac.html). + * @module + */ +import { Hash, type Input } from './utils.ts'; +export type CHash = ReturnType; +export declare function wrapConstructorWithKey>(hashCons: (key: Input) => Hash): { + (msg: Input, key: Input): Uint8Array; + outputLen: number; + blockLen: number; + create(key: Input): Hash; +}; +/** Poly1305 MAC from RFC 8439. */ +export declare const poly1305: CHash; +//# sourceMappingURL=_poly1305.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/_poly1305.d.ts.map b/node_modules/@noble/ciphers/esm/_poly1305.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..b7070c2656e3502d5c004d6c82d394efe3fc5cd0 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/_poly1305.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"_poly1305.d.ts","sourceRoot":"","sources":["../src/_poly1305.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,IAAI,EAAE,KAAK,KAAK,EAA4C,MAAM,YAAY,CAAC;AA4QxF,MAAM,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAC9D,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC,EACtD,QAAQ,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,GAChC;IACD,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,GAAG,UAAU,CAAC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;CAC7B,CAOA;AAED,kCAAkC;AAClC,eAAO,MAAM,QAAQ,EAAE,KAA0D,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/_poly1305.js b/node_modules/@noble/ciphers/esm/_poly1305.js new file mode 100644 index 0000000000000000000000000000000000000000..4762c5fe639223e5b3d862f27e025360f780cc58 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/_poly1305.js @@ -0,0 +1,277 @@ +/** + * Poly1305 ([PDF](https://cr.yp.to/mac/poly1305-20050329.pdf), + * [wiki](https://en.wikipedia.org/wiki/Poly1305)) + * is a fast and parallel secret-key message-authentication code suitable for + * a wide variety of applications. It was standardized in + * [RFC 8439](https://datatracker.ietf.org/doc/html/rfc8439) and is now used in TLS 1.3. + * + * Polynomial MACs are not perfect for every situation: + * they lack Random Key Robustness: the MAC can be forged, and can't be used in PAKE schemes. + * See [invisible salamanders attack](https://keymaterial.net/2020/09/07/invisible-salamanders-in-aes-gcm-siv/). + * To combat invisible salamanders, `hash(key)` can be included in ciphertext, + * however, this would violate ciphertext indistinguishability: + * an attacker would know which key was used - so `HKDF(key, i)` + * could be used instead. + * + * Check out [original website](https://cr.yp.to/mac.html). + * @module + */ +import { Hash, abytes, aexists, aoutput, clean, toBytes } from "./utils.js"; +// Based on Public Domain poly1305-donna https://github.com/floodyberry/poly1305-donna +const u8to16 = (a, i) => (a[i++] & 0xff) | ((a[i++] & 0xff) << 8); +class Poly1305 { + constructor(key) { + this.blockLen = 16; + this.outputLen = 16; + this.buffer = new Uint8Array(16); + this.r = new Uint16Array(10); + this.h = new Uint16Array(10); + this.pad = new Uint16Array(8); + this.pos = 0; + this.finished = false; + key = toBytes(key); + abytes(key, 32); + const t0 = u8to16(key, 0); + const t1 = u8to16(key, 2); + const t2 = u8to16(key, 4); + const t3 = u8to16(key, 6); + const t4 = u8to16(key, 8); + const t5 = u8to16(key, 10); + const t6 = u8to16(key, 12); + const t7 = u8to16(key, 14); + // https://github.com/floodyberry/poly1305-donna/blob/e6ad6e091d30d7f4ec2d4f978be1fcfcbce72781/poly1305-donna-16.h#L47 + this.r[0] = t0 & 0x1fff; + this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff; + this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03; + this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff; + this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff; + this.r[5] = (t4 >>> 1) & 0x1ffe; + this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff; + this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81; + this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff; + this.r[9] = (t7 >>> 5) & 0x007f; + for (let i = 0; i < 8; i++) + this.pad[i] = u8to16(key, 16 + 2 * i); + } + process(data, offset, isLast = false) { + const hibit = isLast ? 0 : 1 << 11; + const { h, r } = this; + const r0 = r[0]; + const r1 = r[1]; + const r2 = r[2]; + const r3 = r[3]; + const r4 = r[4]; + const r5 = r[5]; + const r6 = r[6]; + const r7 = r[7]; + const r8 = r[8]; + const r9 = r[9]; + const t0 = u8to16(data, offset + 0); + const t1 = u8to16(data, offset + 2); + const t2 = u8to16(data, offset + 4); + const t3 = u8to16(data, offset + 6); + const t4 = u8to16(data, offset + 8); + const t5 = u8to16(data, offset + 10); + const t6 = u8to16(data, offset + 12); + const t7 = u8to16(data, offset + 14); + let h0 = h[0] + (t0 & 0x1fff); + let h1 = h[1] + (((t0 >>> 13) | (t1 << 3)) & 0x1fff); + let h2 = h[2] + (((t1 >>> 10) | (t2 << 6)) & 0x1fff); + let h3 = h[3] + (((t2 >>> 7) | (t3 << 9)) & 0x1fff); + let h4 = h[4] + (((t3 >>> 4) | (t4 << 12)) & 0x1fff); + let h5 = h[5] + ((t4 >>> 1) & 0x1fff); + let h6 = h[6] + (((t4 >>> 14) | (t5 << 2)) & 0x1fff); + let h7 = h[7] + (((t5 >>> 11) | (t6 << 5)) & 0x1fff); + let h8 = h[8] + (((t6 >>> 8) | (t7 << 8)) & 0x1fff); + let h9 = h[9] + ((t7 >>> 5) | hibit); + let c = 0; + let d0 = c + h0 * r0 + h1 * (5 * r9) + h2 * (5 * r8) + h3 * (5 * r7) + h4 * (5 * r6); + c = d0 >>> 13; + d0 &= 0x1fff; + d0 += h5 * (5 * r5) + h6 * (5 * r4) + h7 * (5 * r3) + h8 * (5 * r2) + h9 * (5 * r1); + c += d0 >>> 13; + d0 &= 0x1fff; + let d1 = c + h0 * r1 + h1 * r0 + h2 * (5 * r9) + h3 * (5 * r8) + h4 * (5 * r7); + c = d1 >>> 13; + d1 &= 0x1fff; + d1 += h5 * (5 * r6) + h6 * (5 * r5) + h7 * (5 * r4) + h8 * (5 * r3) + h9 * (5 * r2); + c += d1 >>> 13; + d1 &= 0x1fff; + let d2 = c + h0 * r2 + h1 * r1 + h2 * r0 + h3 * (5 * r9) + h4 * (5 * r8); + c = d2 >>> 13; + d2 &= 0x1fff; + d2 += h5 * (5 * r7) + h6 * (5 * r6) + h7 * (5 * r5) + h8 * (5 * r4) + h9 * (5 * r3); + c += d2 >>> 13; + d2 &= 0x1fff; + let d3 = c + h0 * r3 + h1 * r2 + h2 * r1 + h3 * r0 + h4 * (5 * r9); + c = d3 >>> 13; + d3 &= 0x1fff; + d3 += h5 * (5 * r8) + h6 * (5 * r7) + h7 * (5 * r6) + h8 * (5 * r5) + h9 * (5 * r4); + c += d3 >>> 13; + d3 &= 0x1fff; + let d4 = c + h0 * r4 + h1 * r3 + h2 * r2 + h3 * r1 + h4 * r0; + c = d4 >>> 13; + d4 &= 0x1fff; + d4 += h5 * (5 * r9) + h6 * (5 * r8) + h7 * (5 * r7) + h8 * (5 * r6) + h9 * (5 * r5); + c += d4 >>> 13; + d4 &= 0x1fff; + let d5 = c + h0 * r5 + h1 * r4 + h2 * r3 + h3 * r2 + h4 * r1; + c = d5 >>> 13; + d5 &= 0x1fff; + d5 += h5 * r0 + h6 * (5 * r9) + h7 * (5 * r8) + h8 * (5 * r7) + h9 * (5 * r6); + c += d5 >>> 13; + d5 &= 0x1fff; + let d6 = c + h0 * r6 + h1 * r5 + h2 * r4 + h3 * r3 + h4 * r2; + c = d6 >>> 13; + d6 &= 0x1fff; + d6 += h5 * r1 + h6 * r0 + h7 * (5 * r9) + h8 * (5 * r8) + h9 * (5 * r7); + c += d6 >>> 13; + d6 &= 0x1fff; + let d7 = c + h0 * r7 + h1 * r6 + h2 * r5 + h3 * r4 + h4 * r3; + c = d7 >>> 13; + d7 &= 0x1fff; + d7 += h5 * r2 + h6 * r1 + h7 * r0 + h8 * (5 * r9) + h9 * (5 * r8); + c += d7 >>> 13; + d7 &= 0x1fff; + let d8 = c + h0 * r8 + h1 * r7 + h2 * r6 + h3 * r5 + h4 * r4; + c = d8 >>> 13; + d8 &= 0x1fff; + d8 += h5 * r3 + h6 * r2 + h7 * r1 + h8 * r0 + h9 * (5 * r9); + c += d8 >>> 13; + d8 &= 0x1fff; + let d9 = c + h0 * r9 + h1 * r8 + h2 * r7 + h3 * r6 + h4 * r5; + c = d9 >>> 13; + d9 &= 0x1fff; + d9 += h5 * r4 + h6 * r3 + h7 * r2 + h8 * r1 + h9 * r0; + c += d9 >>> 13; + d9 &= 0x1fff; + c = ((c << 2) + c) | 0; + c = (c + d0) | 0; + d0 = c & 0x1fff; + c = c >>> 13; + d1 += c; + h[0] = d0; + h[1] = d1; + h[2] = d2; + h[3] = d3; + h[4] = d4; + h[5] = d5; + h[6] = d6; + h[7] = d7; + h[8] = d8; + h[9] = d9; + } + finalize() { + const { h, pad } = this; + const g = new Uint16Array(10); + let c = h[1] >>> 13; + h[1] &= 0x1fff; + for (let i = 2; i < 10; i++) { + h[i] += c; + c = h[i] >>> 13; + h[i] &= 0x1fff; + } + h[0] += c * 5; + c = h[0] >>> 13; + h[0] &= 0x1fff; + h[1] += c; + c = h[1] >>> 13; + h[1] &= 0x1fff; + h[2] += c; + g[0] = h[0] + 5; + c = g[0] >>> 13; + g[0] &= 0x1fff; + for (let i = 1; i < 10; i++) { + g[i] = h[i] + c; + c = g[i] >>> 13; + g[i] &= 0x1fff; + } + g[9] -= 1 << 13; + let mask = (c ^ 1) - 1; + for (let i = 0; i < 10; i++) + g[i] &= mask; + mask = ~mask; + for (let i = 0; i < 10; i++) + h[i] = (h[i] & mask) | g[i]; + h[0] = (h[0] | (h[1] << 13)) & 0xffff; + h[1] = ((h[1] >>> 3) | (h[2] << 10)) & 0xffff; + h[2] = ((h[2] >>> 6) | (h[3] << 7)) & 0xffff; + h[3] = ((h[3] >>> 9) | (h[4] << 4)) & 0xffff; + h[4] = ((h[4] >>> 12) | (h[5] << 1) | (h[6] << 14)) & 0xffff; + h[5] = ((h[6] >>> 2) | (h[7] << 11)) & 0xffff; + h[6] = ((h[7] >>> 5) | (h[8] << 8)) & 0xffff; + h[7] = ((h[8] >>> 8) | (h[9] << 5)) & 0xffff; + let f = h[0] + pad[0]; + h[0] = f & 0xffff; + for (let i = 1; i < 8; i++) { + f = (((h[i] + pad[i]) | 0) + (f >>> 16)) | 0; + h[i] = f & 0xffff; + } + clean(g); + } + update(data) { + aexists(this); + data = toBytes(data); + abytes(data); + const { buffer, blockLen } = this; + const len = data.length; + for (let pos = 0; pos < len;) { + const take = Math.min(blockLen - this.pos, len - pos); + // Fast path: we have at least one block in input + if (take === blockLen) { + for (; blockLen <= len - pos; pos += blockLen) + this.process(data, pos); + continue; + } + buffer.set(data.subarray(pos, pos + take), this.pos); + this.pos += take; + pos += take; + if (this.pos === blockLen) { + this.process(buffer, 0, false); + this.pos = 0; + } + } + return this; + } + destroy() { + clean(this.h, this.r, this.buffer, this.pad); + } + digestInto(out) { + aexists(this); + aoutput(out, this); + this.finished = true; + const { buffer, h } = this; + let { pos } = this; + if (pos) { + buffer[pos++] = 1; + for (; pos < 16; pos++) + buffer[pos] = 0; + this.process(buffer, 0, true); + } + this.finalize(); + let opos = 0; + for (let i = 0; i < 8; i++) { + out[opos++] = h[i] >>> 0; + out[opos++] = h[i] >>> 8; + } + return out; + } + digest() { + const { buffer, outputLen } = this; + this.digestInto(buffer); + const res = buffer.slice(0, outputLen); + this.destroy(); + return res; + } +} +export function wrapConstructorWithKey(hashCons) { + const hashC = (msg, key) => hashCons(key).update(toBytes(msg)).digest(); + const tmp = hashCons(new Uint8Array(32)); + hashC.outputLen = tmp.outputLen; + hashC.blockLen = tmp.blockLen; + hashC.create = (key) => hashCons(key); + return hashC; +} +/** Poly1305 MAC from RFC 8439. */ +export const poly1305 = wrapConstructorWithKey((key) => new Poly1305(key)); +//# sourceMappingURL=_poly1305.js.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/_poly1305.js.map b/node_modules/@noble/ciphers/esm/_poly1305.js.map new file mode 100644 index 0000000000000000000000000000000000000000..acb72c175df954e311f452f0b82931aa4af3c313 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/_poly1305.js.map @@ -0,0 +1 @@ +{"version":3,"file":"_poly1305.js","sourceRoot":"","sources":["../src/_poly1305.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,IAAI,EAAc,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,K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C,GAAG,CAAC,CAAC;IAC7C,OAAO,KAAK,CAAC;AACf,CAAC;AAED,kCAAkC;AAClC,MAAM,CAAC,MAAM,QAAQ,GAAU,sBAAsB,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/_polyval.d.ts b/node_modules/@noble/ciphers/esm/_polyval.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..df7d9de768a1cf7f8720a9319d995ff786ada6e1 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/_polyval.d.ts @@ -0,0 +1,33 @@ +/** + * GHash from AES-GCM and its little-endian "mirror image" Polyval from AES-SIV. + * + * Implemented in terms of GHash with conversion function for keys + * GCM GHASH from + * [NIST SP800-38d](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf), + * SIV from + * [RFC 8452](https://datatracker.ietf.org/doc/html/rfc8452). + * + * GHASH modulo: x^128 + x^7 + x^2 + x + 1 + * POLYVAL modulo: x^128 + x^127 + x^126 + x^121 + 1 + * + * @module + */ +import { Hash, type Input } from './utils.ts'; +/** + * `mulX_POLYVAL(ByteReverse(H))` from spec + * @param k mutated in place + */ +export declare function _toGHASHKey(k: Uint8Array): Uint8Array; +export type CHashPV = ReturnType; +declare function wrapConstructorWithKey>(hashCons: (key: Input, expectedLength?: number) => Hash): { + (msg: Input, key: Input): Uint8Array; + outputLen: number; + blockLen: number; + create(key: Input, expectedLength?: number): Hash; +}; +/** GHash MAC for AES-GCM. */ +export declare const ghash: CHashPV; +/** Polyval MAC for AES-SIV. */ +export declare const polyval: CHashPV; +export {}; +//# sourceMappingURL=_polyval.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/_polyval.d.ts.map b/node_modules/@noble/ciphers/esm/_polyval.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..2a5385865416f9945f8ec43eabe1ca819743feec --- /dev/null +++ b/node_modules/@noble/ciphers/esm/_polyval.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"_polyval.d.ts","sourceRoot":"","sources":["../src/_polyval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAEyB,IAAI,EAAE,KAAK,KAAK,EAC/C,MAAM,YAAY,CAAC;AA6BpB;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,UAAU,GAAG,UAAU,CAYrD;AAiLD,MAAM,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAChE,iBAAS,sBAAsB,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC,EAC/C,QAAQ,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,cAAc,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,GACzD;IACD,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,GAAG,UAAU,CAAC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,GAAG,EAAE,KAAK,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;CACtD,CAQA;AAED,6BAA6B;AAC7B,eAAO,MAAM,KAAK,EAAE,OAEnB,CAAC;AAEF,+BAA+B;AAC/B,eAAO,MAAM,OAAO,EAAE,OAErB,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/_polyval.js b/node_modules/@noble/ciphers/esm/_polyval.js new file mode 100644 index 0000000000000000000000000000000000000000..9bb2aecb6a481d9dfbb5ae8ac88fa3761e4015e1 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/_polyval.js @@ -0,0 +1,229 @@ +/** + * GHash from AES-GCM and its little-endian "mirror image" Polyval from AES-SIV. + * + * Implemented in terms of GHash with conversion function for keys + * GCM GHASH from + * [NIST SP800-38d](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf), + * SIV from + * [RFC 8452](https://datatracker.ietf.org/doc/html/rfc8452). + * + * GHASH modulo: x^128 + x^7 + x^2 + x + 1 + * POLYVAL modulo: x^128 + x^127 + x^126 + x^121 + 1 + * + * @module + */ +// prettier-ignore +import { abytes, aexists, aoutput, clean, copyBytes, createView, Hash, toBytes, u32, } from "./utils.js"; +const BLOCK_SIZE = 16; +// TODO: rewrite +// temporary padding buffer +const ZEROS16 = /* @__PURE__ */ new Uint8Array(16); +const ZEROS32 = u32(ZEROS16); +const POLY = 0xe1; // v = 2*v % POLY +// v = 2*v % POLY +// NOTE: because x + x = 0 (add/sub is same), mul2(x) != x+x +// We can multiply any number using montgomery ladder and this function (works as double, add is simple xor) +const mul2 = (s0, s1, s2, s3) => { + const hiBit = s3 & 1; + return { + s3: (s2 << 31) | (s3 >>> 1), + s2: (s1 << 31) | (s2 >>> 1), + s1: (s0 << 31) | (s1 >>> 1), + s0: (s0 >>> 1) ^ ((POLY << 24) & -(hiBit & 1)), // reduce % poly + }; +}; +const swapLE = (n) => (((n >>> 0) & 0xff) << 24) | + (((n >>> 8) & 0xff) << 16) | + (((n >>> 16) & 0xff) << 8) | + ((n >>> 24) & 0xff) | + 0; +/** + * `mulX_POLYVAL(ByteReverse(H))` from spec + * @param k mutated in place + */ +export function _toGHASHKey(k) { + k.reverse(); + const hiBit = k[15] & 1; + // k >>= 1 + let carry = 0; + for (let i = 0; i < k.length; i++) { + const t = k[i]; + k[i] = (t >>> 1) | carry; + carry = (t & 1) << 7; + } + k[0] ^= -hiBit & 0xe1; // if (hiBit) n ^= 0xe1000000000000000000000000000000; + return k; +} +const estimateWindow = (bytes) => { + if (bytes > 64 * 1024) + return 8; + if (bytes > 1024) + return 4; + return 2; +}; +class GHASH { + // We select bits per window adaptively based on expectedLength + constructor(key, expectedLength) { + this.blockLen = BLOCK_SIZE; + this.outputLen = BLOCK_SIZE; + this.s0 = 0; + this.s1 = 0; + this.s2 = 0; + this.s3 = 0; + this.finished = false; + key = toBytes(key); + abytes(key, 16); + const kView = createView(key); + let k0 = kView.getUint32(0, false); + let k1 = kView.getUint32(4, false); + let k2 = kView.getUint32(8, false); + let k3 = kView.getUint32(12, false); + // generate table of doubled keys (half of montgomery ladder) + const doubles = []; + for (let i = 0; i < 128; i++) { + doubles.push({ s0: swapLE(k0), s1: swapLE(k1), s2: swapLE(k2), s3: swapLE(k3) }); + ({ s0: k0, s1: k1, s2: k2, s3: k3 } = mul2(k0, k1, k2, k3)); + } + const W = estimateWindow(expectedLength || 1024); + if (![1, 2, 4, 8].includes(W)) + throw new Error('ghash: invalid window size, expected 2, 4 or 8'); + this.W = W; + const bits = 128; // always 128 bits; + const windows = bits / W; + const windowSize = (this.windowSize = 2 ** W); + const items = []; + // Create precompute table for window of W bits + for (let w = 0; w < windows; w++) { + // truth table: 00, 01, 10, 11 + for (let byte = 0; byte < windowSize; byte++) { + // prettier-ignore + let s0 = 0, s1 = 0, s2 = 0, s3 = 0; + for (let j = 0; j < W; j++) { + const bit = (byte >>> (W - j - 1)) & 1; + if (!bit) + continue; + const { s0: d0, s1: d1, s2: d2, s3: d3 } = doubles[W * w + j]; + (s0 ^= d0), (s1 ^= d1), (s2 ^= d2), (s3 ^= d3); + } + items.push({ s0, s1, s2, s3 }); + } + } + this.t = items; + } + _updateBlock(s0, s1, s2, s3) { + (s0 ^= this.s0), (s1 ^= this.s1), (s2 ^= this.s2), (s3 ^= this.s3); + const { W, t, windowSize } = this; + // prettier-ignore + let o0 = 0, o1 = 0, o2 = 0, o3 = 0; + const mask = (1 << W) - 1; // 2**W will kill performance. + let w = 0; + for (const num of [s0, s1, s2, s3]) { + for (let bytePos = 0; bytePos < 4; bytePos++) { + const byte = (num >>> (8 * bytePos)) & 0xff; + for (let bitPos = 8 / W - 1; bitPos >= 0; bitPos--) { + const bit = (byte >>> (W * bitPos)) & mask; + const { s0: e0, s1: e1, s2: e2, s3: e3 } = t[w * windowSize + bit]; + (o0 ^= e0), (o1 ^= e1), (o2 ^= e2), (o3 ^= e3); + w += 1; + } + } + } + this.s0 = o0; + this.s1 = o1; + this.s2 = o2; + this.s3 = o3; + } + update(data) { + aexists(this); + data = toBytes(data); + abytes(data); + const b32 = u32(data); + const blocks = Math.floor(data.length / BLOCK_SIZE); + const left = data.length % BLOCK_SIZE; + for (let i = 0; i < blocks; i++) { + this._updateBlock(b32[i * 4 + 0], b32[i * 4 + 1], b32[i * 4 + 2], b32[i * 4 + 3]); + } + if (left) { + ZEROS16.set(data.subarray(blocks * BLOCK_SIZE)); + this._updateBlock(ZEROS32[0], ZEROS32[1], ZEROS32[2], ZEROS32[3]); + clean(ZEROS32); // clean tmp buffer + } + return this; + } + destroy() { + const { t } = this; + // clean precompute table + for (const elm of t) { + (elm.s0 = 0), (elm.s1 = 0), (elm.s2 = 0), (elm.s3 = 0); + } + } + digestInto(out) { + aexists(this); + aoutput(out, this); + this.finished = true; + const { s0, s1, s2, s3 } = this; + const o32 = u32(out); + o32[0] = s0; + o32[1] = s1; + o32[2] = s2; + o32[3] = s3; + return out; + } + digest() { + const res = new Uint8Array(BLOCK_SIZE); + this.digestInto(res); + this.destroy(); + return res; + } +} +class Polyval extends GHASH { + constructor(key, expectedLength) { + key = toBytes(key); + abytes(key); + const ghKey = _toGHASHKey(copyBytes(key)); + super(ghKey, expectedLength); + clean(ghKey); + } + update(data) { + data = toBytes(data); + aexists(this); + const b32 = u32(data); + const left = data.length % BLOCK_SIZE; + const blocks = Math.floor(data.length / BLOCK_SIZE); + for (let i = 0; i < blocks; i++) { + this._updateBlock(swapLE(b32[i * 4 + 3]), swapLE(b32[i * 4 + 2]), swapLE(b32[i * 4 + 1]), swapLE(b32[i * 4 + 0])); + } + if (left) { + ZEROS16.set(data.subarray(blocks * BLOCK_SIZE)); + this._updateBlock(swapLE(ZEROS32[3]), swapLE(ZEROS32[2]), swapLE(ZEROS32[1]), swapLE(ZEROS32[0])); + clean(ZEROS32); + } + return this; + } + digestInto(out) { + aexists(this); + aoutput(out, this); + this.finished = true; + // tmp ugly hack + const { s0, s1, s2, s3 } = this; + const o32 = u32(out); + o32[0] = s0; + o32[1] = s1; + o32[2] = s2; + o32[3] = s3; + return out.reverse(); + } +} +function wrapConstructorWithKey(hashCons) { + const hashC = (msg, key) => hashCons(key, msg.length).update(toBytes(msg)).digest(); + const tmp = hashCons(new Uint8Array(16), 0); + hashC.outputLen = tmp.outputLen; + hashC.blockLen = tmp.blockLen; + hashC.create = (key, expectedLength) => hashCons(key, expectedLength); + return hashC; +} +/** GHash MAC for AES-GCM. */ +export const ghash = wrapConstructorWithKey((key, expectedLength) => new GHASH(key, expectedLength)); +/** Polyval MAC for AES-SIV. */ +export const polyval = wrapConstructorWithKey((key, expectedLength) => new Polyval(key, expectedLength)); +//# sourceMappingURL=_polyval.js.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/_polyval.js.map b/node_modules/@noble/ciphers/esm/_polyval.js.map new file mode 100644 index 0000000000000000000000000000000000000000..35ad2ee6b734cfaeea2d7726ba69be125a51513c --- /dev/null +++ b/node_modules/@noble/ciphers/esm/_polyval.js.map @@ -0,0 +1 @@ +{"version":3,"file":"_polyval.js","sourceRoot":"","sources":["../src/_polyval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,kBAAkB;AAClB,OAAO,EACL,MAAM,EAAE,OAAO,EAAE,OAAO,EACxB,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAc,OAAO,EAAE,GAAG,GAC7D,MAAM,YAAY,CAAC;AAEpB,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,gBAAgB;AAChB,2BAA2B;AAC3B,MAAM,OAAO,GAAG,eAAe,CAAC,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;AACnD,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC;AAC7B,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,iBAAiB;AAEpC,iBAAiB;AACjB,4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CAAC;AAED,6BAA6B;AAC7B,MAAM,CAAC,MAAM,KAAK,GAAY,sBAAsB,CAClD,CAAC,GAAG,EAAE,cAAc,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,GAAG,EAAE,cAAc,CAAC,CACxD,CAAC;AAEF,+BAA+B;AAC/B,MAAM,CAAC,MAAM,OAAO,GAAY,sBAAsB,CACpD,CAAC,GAAG,EAAE,cAAc,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,GAAG,EAAE,cAAc,CAAC,CAC1D,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/aes.d.ts b/node_modules/@noble/ciphers/esm/aes.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..010a88a602e2afe7acd057501fe4327a738644f8 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/aes.d.ts @@ -0,0 +1,117 @@ +import { type Cipher, type CipherWithOutput } from './utils.ts'; +/** Key expansion used in CTR. */ +declare function expandKeyLE(key: Uint8Array): Uint32Array; +declare function expandKeyDecLE(key: Uint8Array): Uint32Array; +declare function encrypt(xk: Uint32Array, s0: number, s1: number, s2: number, s3: number): { + s0: number; + s1: number; + s2: number; + s3: number; +}; +declare function decrypt(xk: Uint32Array, s0: number, s1: number, s2: number, s3: number): { + s0: number; + s1: number; + s2: number; + s3: number; +}; +declare function ctrCounter(xk: Uint32Array, nonce: Uint8Array, src: Uint8Array, dst?: Uint8Array): Uint8Array; +declare function ctr32(xk: Uint32Array, isLE: boolean, nonce: Uint8Array, src: Uint8Array, dst?: Uint8Array): Uint8Array; +/** + * CTR: counter mode. Creates stream cipher. + * Requires good IV. Parallelizable. OK, but no MAC. + */ +export declare const ctr: ((key: Uint8Array, nonce: Uint8Array) => CipherWithOutput) & { + blockSize: number; + nonceLength: number; +}; +/** Options for ECB and CBC. */ +export type BlockOpts = { + disablePadding?: boolean; +}; +/** + * ECB: Electronic CodeBook. Simple deterministic replacement. + * Dangerous: always map x to y. See [AES Penguin](https://words.filippo.io/the-ecb-penguin/). + */ +export declare const ecb: ((key: Uint8Array, opts?: BlockOpts) => CipherWithOutput) & { + blockSize: number; +}; +/** + * CBC: Cipher-Block-Chaining. Key is previous round’s block. + * Fragile: needs proper padding. Unauthenticated: needs MAC. + */ +export declare const cbc: ((key: Uint8Array, iv: Uint8Array, opts?: BlockOpts) => CipherWithOutput) & { + blockSize: number; + nonceLength: number; +}; +/** + * CFB: Cipher Feedback Mode. The input for the block cipher is the previous cipher output. + * Unauthenticated: needs MAC. + */ +export declare const cfb: ((key: Uint8Array, iv: Uint8Array) => CipherWithOutput) & { + blockSize: number; + nonceLength: number; +}; +/** + * GCM: Galois/Counter Mode. + * Modern, parallel version of CTR, with MAC. + * Be careful: MACs can be forged. + * Unsafe to use random nonces under the same key, due to collision chance. + * As for nonce size, prefer 12-byte, instead of 8-byte. + */ +export declare const gcm: ((key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => Cipher) & { + blockSize: number; + nonceLength: number; + tagLength: number; + varSizeNonce: true; +}; +/** + * AES-GCM-SIV: classic AES-GCM with nonce-misuse resistance. + * Guarantees that, when a nonce is repeated, the only security loss is that identical + * plaintexts will produce identical ciphertexts. + * RFC 8452, https://datatracker.ietf.org/doc/html/rfc8452 + */ +export declare const gcmsiv: ((key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => Cipher) & { + blockSize: number; + nonceLength: number; + tagLength: number; + varSizeNonce: true; +}; +/** + * AES-GCM-SIV, not AES-SIV. + * This is legace name, use `gcmsiv` export instead. + * @deprecated + */ +export declare const siv: typeof gcmsiv; +declare function encryptBlock(xk: Uint32Array, block: Uint8Array): Uint8Array; +declare function decryptBlock(xk: Uint32Array, block: Uint8Array): Uint8Array; +/** + * AES-KW (key-wrap). Injects static IV into plaintext, adds counter, encrypts 6 times. + * Reduces block size from 16 to 8 bytes. + * For padded version, use aeskwp. + * [RFC 3394](https://datatracker.ietf.org/doc/rfc3394/), + * [NIST.SP.800-38F](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38F.pdf). + */ +export declare const aeskw: ((kek: Uint8Array) => Cipher) & { + blockSize: number; +}; +/** + * AES-KW, but with padding and allows random keys. + * Second u32 of IV is used as counter for length. + * [RFC 5649](https://www.rfc-editor.org/rfc/rfc5649) + */ +export declare const aeskwp: ((kek: Uint8Array) => Cipher) & { + blockSize: number; +}; +/** Unsafe low-level internal methods. May change at any time. */ +export declare const unsafe: { + expandKeyLE: typeof expandKeyLE; + expandKeyDecLE: typeof expandKeyDecLE; + encrypt: typeof encrypt; + decrypt: typeof decrypt; + encryptBlock: typeof encryptBlock; + decryptBlock: typeof decryptBlock; + ctrCounter: typeof ctrCounter; + ctr32: typeof ctr32; +}; +export {}; +//# sourceMappingURL=aes.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/aes.d.ts.map b/node_modules/@noble/ciphers/esm/aes.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..1d9898d6085b791399efa6a028a1f532534569b0 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/aes.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"aes.d.ts","sourceRoot":"","sources":["../src/aes.ts"],"names":[],"mappings":"AAkBA,OAAO,EAIL,KAAK,MAAM,EAAE,KAAK,gBAAgB,EACnC,MAAM,YAAY,CAAC;AA0FpB,iCAAiC;AACjC,iBAAS,WAAW,CAAC,GAAG,EAAE,UAAU,GAAG,WAAW,CAsBjD;AAED,iBAAS,cAAc,CAAC,GAAG,EAAE,UAAU,GAAG,WAAW,CAkBpD;AAwBD,iBAAS,OAAO,CACd,EAAE,EAAE,WAAW,EACf,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,GACT;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAkBpD;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,EAAE,CAAC,CAAC,GAAG,EAAE,UAAU,KAAK,MAAM,CAAC,GAAG;IACnD,SAAS,EAAE,MAAM,CAAC;CA+BnB,CAAC;AAEF,iEAAiE;AACjE,eAAO,MAAM,MAAM,EAAE;IACnB,WAAW,EAAE,OAAO,WAAW,CAAC;IAChC,cAAc,EAAE,OAAO,cAAc,CAAC;IACtC,OAAO,EAAE,OAAO,OAAO,CAAC;IACxB,OAAO,EAAE,OAAO,OAAO,CAAC;IACxB,YAAY,EAAE,OAAO,YAAY,CAAC;IAClC,YAAY,EAAE,OAAO,YAAY,CAAC;IAClC,UAAU,EAAE,OAAO,UAAU,CAAC;IAC9B,KAAK,EAAE,OAAO,KAAK,CAAC;CAUrB,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/aes.js b/node_modules/@noble/ciphers/esm/aes.js new file mode 100644 index 0000000000000000000000000000000000000000..6bcc181048828054b7cc2575b2baeb83302d9ab5 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/aes.js @@ -0,0 +1,903 @@ +/** + * [AES](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard) + * a.k.a. Advanced Encryption Standard + * is a variant of Rijndael block cipher, standardized by NIST in 2001. + * We provide the fastest available pure JS implementation. + * + * Data is split into 128-bit blocks. Encrypted in 10/12/14 rounds (128/192/256 bits). In every round: + * 1. **S-box**, table substitution + * 2. **Shift rows**, cyclic shift left of all rows of data array + * 3. **Mix columns**, multiplying every column by fixed polynomial + * 4. **Add round key**, round_key xor i-th column of array + * + * Check out [FIPS-197](https://csrc.nist.gov/files/pubs/fips/197/final/docs/fips-197.pdf) + * and [original proposal](https://csrc.nist.gov/csrc/media/projects/cryptographic-standards-and-guidelines/documents/aes-development/rijndael-ammended.pdf) + * @module + */ +import { ghash, polyval } from "./_polyval.js"; +// prettier-ignore +import { abytes, clean, complexOverlapBytes, concatBytes, copyBytes, createView, equalBytes, getOutput, isAligned32, overlapBytes, setBigUint64, u32, u64Lengths, u8, wrapCipher, } from "./utils.js"; +const BLOCK_SIZE = 16; +const BLOCK_SIZE32 = 4; +const EMPTY_BLOCK = /* @__PURE__ */ new Uint8Array(BLOCK_SIZE); +const POLY = 0x11b; // 1 + x + x**3 + x**4 + x**8 +// TODO: remove multiplication, binary ops only +function mul2(n) { + return (n << 1) ^ (POLY & -(n >> 7)); +} +function mul(a, b) { + let res = 0; + for (; b > 0; b >>= 1) { + // Montgomery ladder + res ^= a & -(b & 1); // if (b&1) res ^=a (but const-time). + a = mul2(a); // a = 2*a + } + return res; +} +// AES S-box is generated using finite field inversion, +// an affine transform, and xor of a constant 0x63. +const sbox = /* @__PURE__ */ (() => { + const t = new Uint8Array(256); + for (let i = 0, x = 1; i < 256; i++, x ^= mul2(x)) + t[i] = x; + const box = new Uint8Array(256); + box[0] = 0x63; // first elm + for (let i = 0; i < 255; i++) { + let x = t[255 - i]; + x |= x << 8; + box[t[i]] = (x ^ (x >> 4) ^ (x >> 5) ^ (x >> 6) ^ (x >> 7) ^ 0x63) & 0xff; + } + clean(t); + return box; +})(); +// Inverted S-box +const invSbox = /* @__PURE__ */ sbox.map((_, j) => sbox.indexOf(j)); +// Rotate u32 by 8 +const rotr32_8 = (n) => (n << 24) | (n >>> 8); +const rotl32_8 = (n) => (n << 8) | (n >>> 24); +// The byte swap operation for uint32 (LE<->BE) +const byteSwap = (word) => ((word << 24) & 0xff000000) | + ((word << 8) & 0xff0000) | + ((word >>> 8) & 0xff00) | + ((word >>> 24) & 0xff); +// T-table is optimization suggested in 5.2 of original proposal (missed from FIPS-197). Changes: +// - LE instead of BE +// - bigger tables: T0 and T1 are merged into T01 table and T2 & T3 into T23; +// so index is u16, instead of u8. This speeds up things, unexpectedly +function genTtable(sbox, fn) { + if (sbox.length !== 256) + throw new Error('Wrong sbox length'); + const T0 = new Uint32Array(256).map((_, j) => fn(sbox[j])); + const T1 = T0.map(rotl32_8); + const T2 = T1.map(rotl32_8); + const T3 = T2.map(rotl32_8); + const T01 = new Uint32Array(256 * 256); + const T23 = new Uint32Array(256 * 256); + const sbox2 = new Uint16Array(256 * 256); + for (let i = 0; i < 256; i++) { + for (let j = 0; j < 256; j++) { + const idx = i * 256 + j; + T01[idx] = T0[i] ^ T1[j]; + T23[idx] = T2[i] ^ T3[j]; + sbox2[idx] = (sbox[i] << 8) | sbox[j]; + } + } + return { sbox, sbox2, T0, T1, T2, T3, T01, T23 }; +} +const tableEncoding = /* @__PURE__ */ genTtable(sbox, (s) => (mul(s, 3) << 24) | (s << 16) | (s << 8) | mul(s, 2)); +const tableDecoding = /* @__PURE__ */ genTtable(invSbox, (s) => (mul(s, 11) << 24) | (mul(s, 13) << 16) | (mul(s, 9) << 8) | mul(s, 14)); +const xPowers = /* @__PURE__ */ (() => { + const p = new Uint8Array(16); + for (let i = 0, x = 1; i < 16; i++, x = mul2(x)) + p[i] = x; + return p; +})(); +/** Key expansion used in CTR. */ +function expandKeyLE(key) { + abytes(key); + const len = key.length; + if (![16, 24, 32].includes(len)) + throw new Error('aes: invalid key size, should be 16, 24 or 32, got ' + len); + const { sbox2 } = tableEncoding; + const toClean = []; + if (!isAligned32(key)) + toClean.push((key = copyBytes(key))); + const k32 = u32(key); + const Nk = k32.length; + const subByte = (n) => applySbox(sbox2, n, n, n, n); + const xk = new Uint32Array(len + 28); // expanded key + xk.set(k32); + // 4.3.1 Key expansion + for (let i = Nk; i < xk.length; i++) { + let t = xk[i - 1]; + if (i % Nk === 0) + t = subByte(rotr32_8(t)) ^ xPowers[i / Nk - 1]; + else if (Nk > 6 && i % Nk === 4) + t = subByte(t); + xk[i] = xk[i - Nk] ^ t; + } + clean(...toClean); + return xk; +} +function expandKeyDecLE(key) { + const encKey = expandKeyLE(key); + const xk = encKey.slice(); + const Nk = encKey.length; + const { sbox2 } = tableEncoding; + const { T0, T1, T2, T3 } = tableDecoding; + // Inverse key by chunks of 4 (rounds) + for (let i = 0; i < Nk; i += 4) { + for (let j = 0; j < 4; j++) + xk[i + j] = encKey[Nk - i - 4 + j]; + } + clean(encKey); + // apply InvMixColumn except first & last round + for (let i = 4; i < Nk - 4; i++) { + const x = xk[i]; + const w = applySbox(sbox2, x, x, x, x); + xk[i] = T0[w & 0xff] ^ T1[(w >>> 8) & 0xff] ^ T2[(w >>> 16) & 0xff] ^ T3[w >>> 24]; + } + return xk; +} +// Apply tables +function apply0123(T01, T23, s0, s1, s2, s3) { + return (T01[((s0 << 8) & 0xff00) | ((s1 >>> 8) & 0xff)] ^ + T23[((s2 >>> 8) & 0xff00) | ((s3 >>> 24) & 0xff)]); +} +function applySbox(sbox2, s0, s1, s2, s3) { + return (sbox2[(s0 & 0xff) | (s1 & 0xff00)] | + (sbox2[((s2 >>> 16) & 0xff) | ((s3 >>> 16) & 0xff00)] << 16)); +} +function encrypt(xk, s0, s1, s2, s3) { + const { sbox2, T01, T23 } = tableEncoding; + let k = 0; + (s0 ^= xk[k++]), (s1 ^= xk[k++]), (s2 ^= xk[k++]), (s3 ^= xk[k++]); + const rounds = xk.length / 4 - 2; + for (let i = 0; i < rounds; i++) { + const t0 = xk[k++] ^ apply0123(T01, T23, s0, s1, s2, s3); + const t1 = xk[k++] ^ apply0123(T01, T23, s1, s2, s3, s0); + const t2 = xk[k++] ^ apply0123(T01, T23, s2, s3, s0, s1); + const t3 = xk[k++] ^ apply0123(T01, T23, s3, s0, s1, s2); + (s0 = t0), (s1 = t1), (s2 = t2), (s3 = t3); + } + // last round (without mixcolumns, so using SBOX2 table) + const t0 = xk[k++] ^ applySbox(sbox2, s0, s1, s2, s3); + const t1 = xk[k++] ^ applySbox(sbox2, s1, s2, s3, s0); + const t2 = xk[k++] ^ applySbox(sbox2, s2, s3, s0, s1); + const t3 = xk[k++] ^ applySbox(sbox2, s3, s0, s1, s2); + return { s0: t0, s1: t1, s2: t2, s3: t3 }; +} +// Can't be merged with encrypt: arg positions for apply0123 / applySbox are different +function decrypt(xk, s0, s1, s2, s3) { + const { sbox2, T01, T23 } = tableDecoding; + let k = 0; + (s0 ^= xk[k++]), (s1 ^= xk[k++]), (s2 ^= xk[k++]), (s3 ^= xk[k++]); + const rounds = xk.length / 4 - 2; + for (let i = 0; i < rounds; i++) { + const t0 = xk[k++] ^ apply0123(T01, T23, s0, s3, s2, s1); + const t1 = xk[k++] ^ apply0123(T01, T23, s1, s0, s3, s2); + const t2 = xk[k++] ^ apply0123(T01, T23, s2, s1, s0, s3); + const t3 = xk[k++] ^ apply0123(T01, T23, s3, s2, s1, s0); + (s0 = t0), (s1 = t1), (s2 = t2), (s3 = t3); + } + // Last round + const t0 = xk[k++] ^ applySbox(sbox2, s0, s3, s2, s1); + const t1 = xk[k++] ^ applySbox(sbox2, s1, s0, s3, s2); + const t2 = xk[k++] ^ applySbox(sbox2, s2, s1, s0, s3); + const t3 = xk[k++] ^ applySbox(sbox2, s3, s2, s1, s0); + return { s0: t0, s1: t1, s2: t2, s3: t3 }; +} +// TODO: investigate merging with ctr32 +function ctrCounter(xk, nonce, src, dst) { + abytes(nonce, BLOCK_SIZE); + abytes(src); + const srcLen = src.length; + dst = getOutput(srcLen, dst); + complexOverlapBytes(src, dst); + const ctr = nonce; + const c32 = u32(ctr); + // Fill block (empty, ctr=0) + let { s0, s1, s2, s3 } = encrypt(xk, c32[0], c32[1], c32[2], c32[3]); + const src32 = u32(src); + const dst32 = u32(dst); + // process blocks + for (let i = 0; i + 4 <= src32.length; i += 4) { + dst32[i + 0] = src32[i + 0] ^ s0; + dst32[i + 1] = src32[i + 1] ^ s1; + dst32[i + 2] = src32[i + 2] ^ s2; + dst32[i + 3] = src32[i + 3] ^ s3; + // Full 128 bit counter with wrap around + let carry = 1; + for (let i = ctr.length - 1; i >= 0; i--) { + carry = (carry + (ctr[i] & 0xff)) | 0; + ctr[i] = carry & 0xff; + carry >>>= 8; + } + ({ s0, s1, s2, s3 } = encrypt(xk, c32[0], c32[1], c32[2], c32[3])); + } + // leftovers (less than block) + // It's possible to handle > u32 fast, but is it worth it? + const start = BLOCK_SIZE * Math.floor(src32.length / BLOCK_SIZE32); + if (start < srcLen) { + const b32 = new Uint32Array([s0, s1, s2, s3]); + const buf = u8(b32); + for (let i = start, pos = 0; i < srcLen; i++, pos++) + dst[i] = src[i] ^ buf[pos]; + clean(b32); + } + return dst; +} +// AES CTR with overflowing 32 bit counter +// It's possible to do 32le significantly simpler (and probably faster) by using u32. +// But, we need both, and perf bottleneck is in ghash anyway. +function ctr32(xk, isLE, nonce, src, dst) { + abytes(nonce, BLOCK_SIZE); + abytes(src); + dst = getOutput(src.length, dst); + const ctr = nonce; // write new value to nonce, so it can be re-used + const c32 = u32(ctr); + const view = createView(ctr); + const src32 = u32(src); + const dst32 = u32(dst); + const ctrPos = isLE ? 0 : 12; + const srcLen = src.length; + // Fill block (empty, ctr=0) + let ctrNum = view.getUint32(ctrPos, isLE); // read current counter value + let { s0, s1, s2, s3 } = encrypt(xk, c32[0], c32[1], c32[2], c32[3]); + // process blocks + for (let i = 0; i + 4 <= src32.length; i += 4) { + dst32[i + 0] = src32[i + 0] ^ s0; + dst32[i + 1] = src32[i + 1] ^ s1; + dst32[i + 2] = src32[i + 2] ^ s2; + dst32[i + 3] = src32[i + 3] ^ s3; + ctrNum = (ctrNum + 1) >>> 0; // u32 wrap + view.setUint32(ctrPos, ctrNum, isLE); + ({ s0, s1, s2, s3 } = encrypt(xk, c32[0], c32[1], c32[2], c32[3])); + } + // leftovers (less than a block) + const start = BLOCK_SIZE * Math.floor(src32.length / BLOCK_SIZE32); + if (start < srcLen) { + const b32 = new Uint32Array([s0, s1, s2, s3]); + const buf = u8(b32); + for (let i = start, pos = 0; i < srcLen; i++, pos++) + dst[i] = src[i] ^ buf[pos]; + clean(b32); + } + return dst; +} +/** + * CTR: counter mode. Creates stream cipher. + * Requires good IV. Parallelizable. OK, but no MAC. + */ +export const ctr = /* @__PURE__ */ wrapCipher({ blockSize: 16, nonceLength: 16 }, function aesctr(key, nonce) { + function processCtr(buf, dst) { + abytes(buf); + if (dst !== undefined) { + abytes(dst); + if (!isAligned32(dst)) + throw new Error('unaligned destination'); + } + const xk = expandKeyLE(key); + const n = copyBytes(nonce); // align + avoid changing + const toClean = [xk, n]; + if (!isAligned32(buf)) + toClean.push((buf = copyBytes(buf))); + const out = ctrCounter(xk, n, buf, dst); + clean(...toClean); + return out; + } + return { + encrypt: (plaintext, dst) => processCtr(plaintext, dst), + decrypt: (ciphertext, dst) => processCtr(ciphertext, dst), + }; +}); +function validateBlockDecrypt(data) { + abytes(data); + if (data.length % BLOCK_SIZE !== 0) { + throw new Error('aes-(cbc/ecb).decrypt ciphertext should consist of blocks with size ' + BLOCK_SIZE); + } +} +function validateBlockEncrypt(plaintext, pcks5, dst) { + abytes(plaintext); + let outLen = plaintext.length; + const remaining = outLen % BLOCK_SIZE; + if (!pcks5 && remaining !== 0) + throw new Error('aec/(cbc-ecb): unpadded plaintext with disabled padding'); + if (!isAligned32(plaintext)) + plaintext = copyBytes(plaintext); + const b = u32(plaintext); + if (pcks5) { + let left = BLOCK_SIZE - remaining; + if (!left) + left = BLOCK_SIZE; // if no bytes left, create empty padding block + outLen = outLen + left; + } + dst = getOutput(outLen, dst); + complexOverlapBytes(plaintext, dst); + const o = u32(dst); + return { b, o, out: dst }; +} +function validatePCKS(data, pcks5) { + if (!pcks5) + return data; + const len = data.length; + if (!len) + throw new Error('aes/pcks5: empty ciphertext not allowed'); + const lastByte = data[len - 1]; + if (lastByte <= 0 || lastByte > 16) + throw new Error('aes/pcks5: wrong padding'); + const out = data.subarray(0, -lastByte); + for (let i = 0; i < lastByte; i++) + if (data[len - i - 1] !== lastByte) + throw new Error('aes/pcks5: wrong padding'); + return out; +} +function padPCKS(left) { + const tmp = new Uint8Array(16); + const tmp32 = u32(tmp); + tmp.set(left); + const paddingByte = BLOCK_SIZE - left.length; + for (let i = BLOCK_SIZE - paddingByte; i < BLOCK_SIZE; i++) + tmp[i] = paddingByte; + return tmp32; +} +/** + * ECB: Electronic CodeBook. Simple deterministic replacement. + * Dangerous: always map x to y. See [AES Penguin](https://words.filippo.io/the-ecb-penguin/). + */ +export const ecb = /* @__PURE__ */ wrapCipher({ blockSize: 16 }, function aesecb(key, opts = {}) { + const pcks5 = !opts.disablePadding; + return { + encrypt(plaintext, dst) { + const { b, o, out: _out } = validateBlockEncrypt(plaintext, pcks5, dst); + const xk = expandKeyLE(key); + let i = 0; + for (; i + 4 <= b.length;) { + const { s0, s1, s2, s3 } = encrypt(xk, b[i + 0], b[i + 1], b[i + 2], b[i + 3]); + (o[i++] = s0), (o[i++] = s1), (o[i++] = s2), (o[i++] = s3); + } + if (pcks5) { + const tmp32 = padPCKS(plaintext.subarray(i * 4)); + const { s0, s1, s2, s3 } = encrypt(xk, tmp32[0], tmp32[1], tmp32[2], tmp32[3]); + (o[i++] = s0), (o[i++] = s1), (o[i++] = s2), (o[i++] = s3); + } + clean(xk); + return _out; + }, + decrypt(ciphertext, dst) { + validateBlockDecrypt(ciphertext); + const xk = expandKeyDecLE(key); + dst = getOutput(ciphertext.length, dst); + const toClean = [xk]; + if (!isAligned32(ciphertext)) + toClean.push((ciphertext = copyBytes(ciphertext))); + complexOverlapBytes(ciphertext, dst); + const b = u32(ciphertext); + const o = u32(dst); + for (let i = 0; i + 4 <= b.length;) { + const { s0, s1, s2, s3 } = decrypt(xk, b[i + 0], b[i + 1], b[i + 2], b[i + 3]); + (o[i++] = s0), (o[i++] = s1), (o[i++] = s2), (o[i++] = s3); + } + clean(...toClean); + return validatePCKS(dst, pcks5); + }, + }; +}); +/** + * CBC: Cipher-Block-Chaining. Key is previous round’s block. + * Fragile: needs proper padding. Unauthenticated: needs MAC. + */ +export const cbc = /* @__PURE__ */ wrapCipher({ blockSize: 16, nonceLength: 16 }, function aescbc(key, iv, opts = {}) { + const pcks5 = !opts.disablePadding; + return { + encrypt(plaintext, dst) { + const xk = expandKeyLE(key); + const { b, o, out: _out } = validateBlockEncrypt(plaintext, pcks5, dst); + let _iv = iv; + const toClean = [xk]; + if (!isAligned32(_iv)) + toClean.push((_iv = copyBytes(_iv))); + const n32 = u32(_iv); + // prettier-ignore + let s0 = n32[0], s1 = n32[1], s2 = n32[2], s3 = n32[3]; + let i = 0; + for (; i + 4 <= b.length;) { + (s0 ^= b[i + 0]), (s1 ^= b[i + 1]), (s2 ^= b[i + 2]), (s3 ^= b[i + 3]); + ({ s0, s1, s2, s3 } = encrypt(xk, s0, s1, s2, s3)); + (o[i++] = s0), (o[i++] = s1), (o[i++] = s2), (o[i++] = s3); + } + if (pcks5) { + const tmp32 = padPCKS(plaintext.subarray(i * 4)); + (s0 ^= tmp32[0]), (s1 ^= tmp32[1]), (s2 ^= tmp32[2]), (s3 ^= tmp32[3]); + ({ s0, s1, s2, s3 } = encrypt(xk, s0, s1, s2, s3)); + (o[i++] = s0), (o[i++] = s1), (o[i++] = s2), (o[i++] = s3); + } + clean(...toClean); + return _out; + }, + decrypt(ciphertext, dst) { + validateBlockDecrypt(ciphertext); + const xk = expandKeyDecLE(key); + let _iv = iv; + const toClean = [xk]; + if (!isAligned32(_iv)) + toClean.push((_iv = copyBytes(_iv))); + const n32 = u32(_iv); + dst = getOutput(ciphertext.length, dst); + if (!isAligned32(ciphertext)) + toClean.push((ciphertext = copyBytes(ciphertext))); + complexOverlapBytes(ciphertext, dst); + const b = u32(ciphertext); + const o = u32(dst); + // prettier-ignore + let s0 = n32[0], s1 = n32[1], s2 = n32[2], s3 = n32[3]; + for (let i = 0; i + 4 <= b.length;) { + // prettier-ignore + const ps0 = s0, ps1 = s1, ps2 = s2, ps3 = s3; + (s0 = b[i + 0]), (s1 = b[i + 1]), (s2 = b[i + 2]), (s3 = b[i + 3]); + const { s0: o0, s1: o1, s2: o2, s3: o3 } = decrypt(xk, s0, s1, s2, s3); + (o[i++] = o0 ^ ps0), (o[i++] = o1 ^ ps1), (o[i++] = o2 ^ ps2), (o[i++] = o3 ^ ps3); + } + clean(...toClean); + return validatePCKS(dst, pcks5); + }, + }; +}); +/** + * CFB: Cipher Feedback Mode. The input for the block cipher is the previous cipher output. + * Unauthenticated: needs MAC. + */ +export const cfb = /* @__PURE__ */ wrapCipher({ blockSize: 16, nonceLength: 16 }, function aescfb(key, iv) { + function processCfb(src, isEncrypt, dst) { + abytes(src); + const srcLen = src.length; + dst = getOutput(srcLen, dst); + if (overlapBytes(src, dst)) + throw new Error('overlapping src and dst not supported.'); + const xk = expandKeyLE(key); + let _iv = iv; + const toClean = [xk]; + if (!isAligned32(_iv)) + toClean.push((_iv = copyBytes(_iv))); + if (!isAligned32(src)) + toClean.push((src = copyBytes(src))); + const src32 = u32(src); + const dst32 = u32(dst); + const next32 = isEncrypt ? dst32 : src32; + const n32 = u32(_iv); + // prettier-ignore + let s0 = n32[0], s1 = n32[1], s2 = n32[2], s3 = n32[3]; + for (let i = 0; i + 4 <= src32.length;) { + const { s0: e0, s1: e1, s2: e2, s3: e3 } = encrypt(xk, s0, s1, s2, s3); + dst32[i + 0] = src32[i + 0] ^ e0; + dst32[i + 1] = src32[i + 1] ^ e1; + dst32[i + 2] = src32[i + 2] ^ e2; + dst32[i + 3] = src32[i + 3] ^ e3; + (s0 = next32[i++]), (s1 = next32[i++]), (s2 = next32[i++]), (s3 = next32[i++]); + } + // leftovers (less than block) + const start = BLOCK_SIZE * Math.floor(src32.length / BLOCK_SIZE32); + if (start < srcLen) { + ({ s0, s1, s2, s3 } = encrypt(xk, s0, s1, s2, s3)); + const buf = u8(new Uint32Array([s0, s1, s2, s3])); + for (let i = start, pos = 0; i < srcLen; i++, pos++) + dst[i] = src[i] ^ buf[pos]; + clean(buf); + } + clean(...toClean); + return dst; + } + return { + encrypt: (plaintext, dst) => processCfb(plaintext, true, dst), + decrypt: (ciphertext, dst) => processCfb(ciphertext, false, dst), + }; +}); +// TODO: merge with chacha, however gcm has bitLen while chacha has byteLen +function computeTag(fn, isLE, key, data, AAD) { + const aadLength = AAD ? AAD.length : 0; + const h = fn.create(key, data.length + aadLength); + if (AAD) + h.update(AAD); + const num = u64Lengths(8 * data.length, 8 * aadLength, isLE); + h.update(data); + h.update(num); + const res = h.digest(); + clean(num); + return res; +} +/** + * GCM: Galois/Counter Mode. + * Modern, parallel version of CTR, with MAC. + * Be careful: MACs can be forged. + * Unsafe to use random nonces under the same key, due to collision chance. + * As for nonce size, prefer 12-byte, instead of 8-byte. + */ +export const gcm = /* @__PURE__ */ wrapCipher({ blockSize: 16, nonceLength: 12, tagLength: 16, varSizeNonce: true }, function aesgcm(key, nonce, AAD) { + // NIST 800-38d doesn't enforce minimum nonce length. + // We enforce 8 bytes for compat with openssl. + // 12 bytes are recommended. More than 12 bytes would be converted into 12. + if (nonce.length < 8) + throw new Error('aes/gcm: invalid nonce length'); + const tagLength = 16; + function _computeTag(authKey, tagMask, data) { + const tag = computeTag(ghash, false, authKey, data, AAD); + for (let i = 0; i < tagMask.length; i++) + tag[i] ^= tagMask[i]; + return tag; + } + function deriveKeys() { + const xk = expandKeyLE(key); + const authKey = EMPTY_BLOCK.slice(); + const counter = EMPTY_BLOCK.slice(); + ctr32(xk, false, counter, counter, authKey); + // NIST 800-38d, page 15: different behavior for 96-bit and non-96-bit nonces + if (nonce.length === 12) { + counter.set(nonce); + } + else { + const nonceLen = EMPTY_BLOCK.slice(); + const view = createView(nonceLen); + setBigUint64(view, 8, BigInt(nonce.length * 8), false); + // ghash(nonce || u64be(0) || u64be(nonceLen*8)) + const g = ghash.create(authKey).update(nonce).update(nonceLen); + g.digestInto(counter); // digestInto doesn't trigger '.destroy' + g.destroy(); + } + const tagMask = ctr32(xk, false, counter, EMPTY_BLOCK); + return { xk, authKey, counter, tagMask }; + } + return { + encrypt(plaintext) { + const { xk, authKey, counter, tagMask } = deriveKeys(); + const out = new Uint8Array(plaintext.length + tagLength); + const toClean = [xk, authKey, counter, tagMask]; + if (!isAligned32(plaintext)) + toClean.push((plaintext = copyBytes(plaintext))); + ctr32(xk, false, counter, plaintext, out.subarray(0, plaintext.length)); + const tag = _computeTag(authKey, tagMask, out.subarray(0, out.length - tagLength)); + toClean.push(tag); + out.set(tag, plaintext.length); + clean(...toClean); + return out; + }, + decrypt(ciphertext) { + const { xk, authKey, counter, tagMask } = deriveKeys(); + const toClean = [xk, authKey, tagMask, counter]; + if (!isAligned32(ciphertext)) + toClean.push((ciphertext = copyBytes(ciphertext))); + const data = ciphertext.subarray(0, -tagLength); + const passedTag = ciphertext.subarray(-tagLength); + const tag = _computeTag(authKey, tagMask, data); + toClean.push(tag); + if (!equalBytes(tag, passedTag)) + throw new Error('aes/gcm: invalid ghash tag'); + const out = ctr32(xk, false, counter, data); + clean(...toClean); + return out; + }, + }; +}); +const limit = (name, min, max) => (value) => { + if (!Number.isSafeInteger(value) || min > value || value > max) { + const minmax = '[' + min + '..' + max + ']'; + throw new Error('' + name + ': expected value in range ' + minmax + ', got ' + value); + } +}; +/** + * AES-GCM-SIV: classic AES-GCM with nonce-misuse resistance. + * Guarantees that, when a nonce is repeated, the only security loss is that identical + * plaintexts will produce identical ciphertexts. + * RFC 8452, https://datatracker.ietf.org/doc/html/rfc8452 + */ +export const gcmsiv = /* @__PURE__ */ wrapCipher({ blockSize: 16, nonceLength: 12, tagLength: 16, varSizeNonce: true }, function aessiv(key, nonce, AAD) { + const tagLength = 16; + // From RFC 8452: Section 6 + const AAD_LIMIT = limit('AAD', 0, 2 ** 36); + const PLAIN_LIMIT = limit('plaintext', 0, 2 ** 36); + const NONCE_LIMIT = limit('nonce', 12, 12); + const CIPHER_LIMIT = limit('ciphertext', 16, 2 ** 36 + 16); + abytes(key, 16, 24, 32); + NONCE_LIMIT(nonce.length); + if (AAD !== undefined) + AAD_LIMIT(AAD.length); + function deriveKeys() { + const xk = expandKeyLE(key); + const encKey = new Uint8Array(key.length); + const authKey = new Uint8Array(16); + const toClean = [xk, encKey]; + let _nonce = nonce; + if (!isAligned32(_nonce)) + toClean.push((_nonce = copyBytes(_nonce))); + const n32 = u32(_nonce); + // prettier-ignore + let s0 = 0, s1 = n32[0], s2 = n32[1], s3 = n32[2]; + let counter = 0; + for (const derivedKey of [authKey, encKey].map(u32)) { + const d32 = u32(derivedKey); + for (let i = 0; i < d32.length; i += 2) { + // aes(u32le(0) || nonce)[:8] || aes(u32le(1) || nonce)[:8] ... + const { s0: o0, s1: o1 } = encrypt(xk, s0, s1, s2, s3); + d32[i + 0] = o0; + d32[i + 1] = o1; + s0 = ++counter; // increment counter inside state + } + } + const res = { authKey, encKey: expandKeyLE(encKey) }; + // Cleanup + clean(...toClean); + return res; + } + function _computeTag(encKey, authKey, data) { + const tag = computeTag(polyval, true, authKey, data, AAD); + // Compute the expected tag by XORing S_s and the nonce, clearing the + // most significant bit of the last byte and encrypting with the + // message-encryption key. + for (let i = 0; i < 12; i++) + tag[i] ^= nonce[i]; + tag[15] &= 0x7f; // Clear the highest bit + // encrypt tag as block + const t32 = u32(tag); + // prettier-ignore + let s0 = t32[0], s1 = t32[1], s2 = t32[2], s3 = t32[3]; + ({ s0, s1, s2, s3 } = encrypt(encKey, s0, s1, s2, s3)); + (t32[0] = s0), (t32[1] = s1), (t32[2] = s2), (t32[3] = s3); + return tag; + } + // actual decrypt/encrypt of message. + function processSiv(encKey, tag, input) { + let block = copyBytes(tag); + block[15] |= 0x80; // Force highest bit + const res = ctr32(encKey, true, block, input); + // Cleanup + clean(block); + return res; + } + return { + encrypt(plaintext) { + PLAIN_LIMIT(plaintext.length); + const { encKey, authKey } = deriveKeys(); + const tag = _computeTag(encKey, authKey, plaintext); + const toClean = [encKey, authKey, tag]; + if (!isAligned32(plaintext)) + toClean.push((plaintext = copyBytes(plaintext))); + const out = new Uint8Array(plaintext.length + tagLength); + out.set(tag, plaintext.length); + out.set(processSiv(encKey, tag, plaintext)); + // Cleanup + clean(...toClean); + return out; + }, + decrypt(ciphertext) { + CIPHER_LIMIT(ciphertext.length); + const tag = ciphertext.subarray(-tagLength); + const { encKey, authKey } = deriveKeys(); + const toClean = [encKey, authKey]; + if (!isAligned32(ciphertext)) + toClean.push((ciphertext = copyBytes(ciphertext))); + const plaintext = processSiv(encKey, tag, ciphertext.subarray(0, -tagLength)); + const expectedTag = _computeTag(encKey, authKey, plaintext); + toClean.push(expectedTag); + if (!equalBytes(tag, expectedTag)) { + clean(...toClean); + throw new Error('invalid polyval tag'); + } + // Cleanup + clean(...toClean); + return plaintext; + }, + }; +}); +/** + * AES-GCM-SIV, not AES-SIV. + * This is legace name, use `gcmsiv` export instead. + * @deprecated + */ +export const siv = gcmsiv; +function isBytes32(a) { + return (a instanceof Uint32Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint32Array')); +} +function encryptBlock(xk, block) { + abytes(block, 16); + if (!isBytes32(xk)) + throw new Error('_encryptBlock accepts result of expandKeyLE'); + const b32 = u32(block); + let { s0, s1, s2, s3 } = encrypt(xk, b32[0], b32[1], b32[2], b32[3]); + (b32[0] = s0), (b32[1] = s1), (b32[2] = s2), (b32[3] = s3); + return block; +} +function decryptBlock(xk, block) { + abytes(block, 16); + if (!isBytes32(xk)) + throw new Error('_decryptBlock accepts result of expandKeyLE'); + const b32 = u32(block); + let { s0, s1, s2, s3 } = decrypt(xk, b32[0], b32[1], b32[2], b32[3]); + (b32[0] = s0), (b32[1] = s1), (b32[2] = s2), (b32[3] = s3); + return block; +} +/** + * AES-W (base for AESKW/AESKWP). + * Specs: [SP800-38F](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38F.pdf), + * [RFC 3394](https://datatracker.ietf.org/doc/rfc3394/), + * [RFC 5649](https://datatracker.ietf.org/doc/rfc5649/). + */ +const AESW = { + /* + High-level pseudocode: + ``` + A: u64 = IV + out = [] + for (let i=0, ctr = 0; i<6; i++) { + for (const chunk of chunks(plaintext, 8)) { + A ^= swapEndianess(ctr++) + [A, res] = chunks(encrypt(A || chunk), 8); + out ||= res + } + } + out = A || out + ``` + Decrypt is the same, but reversed. + */ + encrypt(kek, out) { + // Size is limited to 4GB, otherwise ctr will overflow and we'll need to switch to bigints. + // If you need it larger, open an issue. + if (out.length >= 2 ** 32) + throw new Error('plaintext should be less than 4gb'); + const xk = expandKeyLE(kek); + if (out.length === 16) + encryptBlock(xk, out); + else { + const o32 = u32(out); + // prettier-ignore + let a0 = o32[0], a1 = o32[1]; // A + for (let j = 0, ctr = 1; j < 6; j++) { + for (let pos = 2; pos < o32.length; pos += 2, ctr++) { + const { s0, s1, s2, s3 } = encrypt(xk, a0, a1, o32[pos], o32[pos + 1]); + // A = MSB(64, B) ^ t where t = (n*j)+i + (a0 = s0), (a1 = s1 ^ byteSwap(ctr)), (o32[pos] = s2), (o32[pos + 1] = s3); + } + } + (o32[0] = a0), (o32[1] = a1); // out = A || out + } + xk.fill(0); + }, + decrypt(kek, out) { + if (out.length - 8 >= 2 ** 32) + throw new Error('ciphertext should be less than 4gb'); + const xk = expandKeyDecLE(kek); + const chunks = out.length / 8 - 1; // first chunk is IV + if (chunks === 1) + decryptBlock(xk, out); + else { + const o32 = u32(out); + // prettier-ignore + let a0 = o32[0], a1 = o32[1]; // A + for (let j = 0, ctr = chunks * 6; j < 6; j++) { + for (let pos = chunks * 2; pos >= 1; pos -= 2, ctr--) { + a1 ^= byteSwap(ctr); + const { s0, s1, s2, s3 } = decrypt(xk, a0, a1, o32[pos], o32[pos + 1]); + (a0 = s0), (a1 = s1), (o32[pos] = s2), (o32[pos + 1] = s3); + } + } + (o32[0] = a0), (o32[1] = a1); + } + xk.fill(0); + }, +}; +const AESKW_IV = /* @__PURE__ */ new Uint8Array(8).fill(0xa6); // A6A6A6A6A6A6A6A6 +/** + * AES-KW (key-wrap). Injects static IV into plaintext, adds counter, encrypts 6 times. + * Reduces block size from 16 to 8 bytes. + * For padded version, use aeskwp. + * [RFC 3394](https://datatracker.ietf.org/doc/rfc3394/), + * [NIST.SP.800-38F](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38F.pdf). + */ +export const aeskw = /* @__PURE__ */ wrapCipher({ blockSize: 8 }, (kek) => ({ + encrypt(plaintext) { + if (!plaintext.length || plaintext.length % 8 !== 0) + throw new Error('invalid plaintext length'); + if (plaintext.length === 8) + throw new Error('8-byte keys not allowed in AESKW, use AESKWP instead'); + const out = concatBytes(AESKW_IV, plaintext); + AESW.encrypt(kek, out); + return out; + }, + decrypt(ciphertext) { + // ciphertext must be at least 24 bytes and a multiple of 8 bytes + // 24 because should have at least two block (1 iv + 2). + // Replace with 16 to enable '8-byte keys' + if (ciphertext.length % 8 !== 0 || ciphertext.length < 3 * 8) + throw new Error('invalid ciphertext length'); + const out = copyBytes(ciphertext); + AESW.decrypt(kek, out); + if (!equalBytes(out.subarray(0, 8), AESKW_IV)) + throw new Error('integrity check failed'); + out.subarray(0, 8).fill(0); // ciphertext.subarray(0, 8) === IV, but we clean it anyway + return out.subarray(8); + }, +})); +/* +We don't support 8-byte keys. The rabbit hole: + +- Wycheproof says: "NIST SP 800-38F does not define the wrapping of 8 byte keys. + RFC 3394 Section 2 on the other hand specifies that 8 byte keys are wrapped + by directly encrypting one block with AES." + - https://github.com/C2SP/wycheproof/blob/master/doc/key_wrap.md + - "RFC 3394 specifies in Section 2, that the input for the key wrap + algorithm must be at least two blocks and otherwise the constant + field and key are simply encrypted with ECB as a single block" +- What RFC 3394 actually says (in Section 2): + - "Before being wrapped, the key data is parsed into n blocks of 64 bits. + The only restriction the key wrap algorithm places on n is that n be + at least two" + - "For key data with length less than or equal to 64 bits, the constant + field used in this specification and the key data form a single + 128-bit codebook input making this key wrap unnecessary." +- Which means "assert(n >= 2)" and "use something else for 8 byte keys" +- NIST SP800-38F actually prohibits 8-byte in "5.3.1 Mandatory Limits". + It states that plaintext for KW should be "2 to 2^54 -1 semiblocks". +- So, where does "directly encrypt single block with AES" come from? + - Not RFC 3394. Pseudocode of key wrap in 2.2 explicitly uses + loop of 6 for any code path + - There is a weird W3C spec: + https://www.w3.org/TR/2002/REC-xmlenc-core-20021210/Overview.html#kw-aes128 + - This spec is outdated, as admitted by Wycheproof authors + - There is RFC 5649 for padded key wrap, which is padding construction on + top of AESKW. In '4.1.2' it says: "If the padded plaintext contains exactly + eight octets, then prepend the AIV as defined in Section 3 above to P[1] and + encrypt the resulting 128-bit block using AES in ECB mode [Modes] with key + K (the KEK). In this case, the output is two 64-bit blocks C[0] and C[1]:" + - Browser subtle crypto is actually crashes on wrapping keys less than 16 bytes: + `Error: error:1C8000E6:Provider routines::invalid input length] { opensslErrorStack: [ 'error:030000BD:digital envelope routines::update error' ]` + +In the end, seems like a bug in Wycheproof. +The 8-byte check can be easily disabled inside of AES_W. +*/ +const AESKWP_IV = 0xa65959a6; // single u32le value +/** + * AES-KW, but with padding and allows random keys. + * Second u32 of IV is used as counter for length. + * [RFC 5649](https://www.rfc-editor.org/rfc/rfc5649) + */ +export const aeskwp = /* @__PURE__ */ wrapCipher({ blockSize: 8 }, (kek) => ({ + encrypt(plaintext) { + if (!plaintext.length) + throw new Error('invalid plaintext length'); + const padded = Math.ceil(plaintext.length / 8) * 8; + const out = new Uint8Array(8 + padded); + out.set(plaintext, 8); + const out32 = u32(out); + out32[0] = AESKWP_IV; + out32[1] = byteSwap(plaintext.length); + AESW.encrypt(kek, out); + return out; + }, + decrypt(ciphertext) { + // 16 because should have at least one block + if (ciphertext.length < 16) + throw new Error('invalid ciphertext length'); + const out = copyBytes(ciphertext); + const o32 = u32(out); + AESW.decrypt(kek, out); + const len = byteSwap(o32[1]) >>> 0; + const padded = Math.ceil(len / 8) * 8; + if (o32[0] !== AESKWP_IV || out.length - 8 !== padded) + throw new Error('integrity check failed'); + for (let i = len; i < padded; i++) + if (out[8 + i] !== 0) + throw new Error('integrity check failed'); + out.subarray(0, 8).fill(0); // ciphertext.subarray(0, 8) === IV, but we clean it anyway + return out.subarray(8, 8 + len); + }, +})); +/** Unsafe low-level internal methods. May change at any time. */ +export const unsafe = { + expandKeyLE, + expandKeyDecLE, + encrypt, + decrypt, + encryptBlock, + decryptBlock, + ctrCounter, + ctr32, +}; +//# sourceMappingURL=aes.js.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/aes.js.map b/node_modules/@noble/ciphers/esm/aes.js.map new file mode 100644 index 0000000000000000000000000000000000000000..434e843cbce31304b122f58ad3a51568a80f14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AAI,GAAG,CAAC,MAAM,GAAG,CAAC,KAAK,MAAM;YACnD,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC5C,KAAK,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE;YAC/B,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC;gBAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAClE,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,2DAA2D;QACvF,OAAO,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC;IAClC,CAAC;CACF,CAAC,CACH,CAAC;AAEF,iEAAiE;AACjE,MAAM,CAAC,MAAM,MAAM,GASf;IACF,WAAW;IACX,cAAc;IACd,OAAO;IACP,OAAO;IACP,YAAY;IACZ,YAAY;IACZ,UAAU;IACV,KAAK;CACN,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/chacha.d.ts b/node_modules/@noble/ciphers/esm/chacha.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c521e9f733bd8805c03f14c608d29fb3b1a9d769 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/chacha.d.ts @@ -0,0 +1,56 @@ +import { type ARXCipher, type CipherWithOutput, type XorStream } from './utils.ts'; +/** + * hchacha helper method, used primarily in xchacha, to hash + * key and nonce into key' and nonce'. + * Same as chachaCore, but there doesn't seem to be a way to move the block + * out without 25% performance hit. + */ +export declare function hchacha(s: Uint32Array, k: Uint32Array, i: Uint32Array, o32: Uint32Array): void; +/** + * Original, non-RFC chacha20 from DJB. 8-byte nonce, 8-byte counter. + */ +export declare const chacha20orig: XorStream; +/** + * ChaCha stream cipher. Conforms to RFC 8439 (IETF, TLS). 12-byte nonce, 4-byte counter. + * With 12-byte nonce, it's not safe to use fill it with random (CSPRNG), due to collision chance. + */ +export declare const chacha20: XorStream; +/** + * XChaCha eXtended-nonce ChaCha. 24-byte nonce. + * With 24-byte nonce, it's safe to use fill it with random (CSPRNG). + * https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha + */ +export declare const xchacha20: XorStream; +/** + * Reduced 8-round chacha, described in original paper. + */ +export declare const chacha8: XorStream; +/** + * Reduced 12-round chacha, described in original paper. + */ +export declare const chacha12: XorStream; +/** + * AEAD algorithm from RFC 8439. + * Salsa20 and chacha (RFC 8439) use poly1305 differently. + * We could have composed them similar to: + * https://github.com/paulmillr/scure-base/blob/b266c73dde977b1dd7ef40ef7a23cc15aab526b3/index.ts#L250 + * But it's hard because of authKey: + * In salsa20, authKey changes position in salsa stream. + * In chacha, authKey can't be computed inside computeTag, it modifies the counter. + */ +export declare const _poly1305_aead: (xorStream: XorStream) => (key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => CipherWithOutput; +/** + * ChaCha20-Poly1305 from RFC 8439. + * + * Unsafe to use random nonces under the same key, due to collision chance. + * Prefer XChaCha instead. + */ +export declare const chacha20poly1305: ARXCipher; +/** + * XChaCha20-Poly1305 extended-nonce chacha. + * + * Can be safely used with random nonces (CSPRNG). + * See [IRTF draft](https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha). + */ +export declare const xchacha20poly1305: ARXCipher; +//# sourceMappingURL=chacha.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/chacha.d.ts.map b/node_modules/@noble/ciphers/esm/chacha.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..6dfe084454c21865556ae2dc0787551dbdbe172f --- /dev/null +++ b/node_modules/@noble/ciphers/esm/chacha.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"chacha.d.ts","sourceRoot":"","sources":["../src/chacha.ts"],"names":[],"mappings":"AAgBA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,SAAS,EAMf,MAAM,YAAY,CAAC;AAsEpB;;;;;GAKG;AAEH,wBAAgB,OAAO,CACrB,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,EAAE,GAAG,EAAE,WAAW,GAC/D,IAAI,CAmDN;AACD;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,SAIzB,CAAC;AACH;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,SAIrB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,SAKtB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,SAIpB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,SAIrB,CAAC;AA6BH;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GACxB,WAAW,SAAS,MACpB,KAAK,UAAU,EAAE,OAAO,UAAU,EAAE,MAAM,UAAU,KAAG,gBA0BvD,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAG9B,CAAC;AACF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAG/B,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/chacha.js b/node_modules/@noble/ciphers/esm/chacha.js new file mode 100644 index 0000000000000000000000000000000000000000..5527ab6cdfad3266bbc3aab78eb46ed360fc9db7 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/chacha.js @@ -0,0 +1,315 @@ +/** + * [ChaCha20](https://cr.yp.to/chacha.html) stream cipher, released + * in 2008. Developed after Salsa20, ChaCha aims to increase diffusion per round. + * It was standardized in [RFC 8439](https://datatracker.ietf.org/doc/html/rfc8439) and + * is now used in TLS 1.3. + * + * [XChaCha20](https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha) + * extended-nonce variant is also provided. Similar to XSalsa, it's safe to use with + * randomly-generated nonces. + * + * Check out [PDF](http://cr.yp.to/chacha/chacha-20080128.pdf) and + * [wiki](https://en.wikipedia.org/wiki/Salsa20). + * @module + */ +import { createCipher, rotl } from "./_arx.js"; +import { poly1305 } from "./_poly1305.js"; +import { clean, equalBytes, getOutput, u64Lengths, wrapCipher, } from "./utils.js"; +/** + * ChaCha core function. + */ +// prettier-ignore +function chachaCore(s, k, n, out, cnt, rounds = 20) { + let y00 = s[0], y01 = s[1], y02 = s[2], y03 = s[3], // "expa" "nd 3" "2-by" "te k" + y04 = k[0], y05 = k[1], y06 = k[2], y07 = k[3], // Key Key Key Key + y08 = k[4], y09 = k[5], y10 = k[6], y11 = k[7], // Key Key Key Key + y12 = cnt, y13 = n[0], y14 = n[1], y15 = n[2]; // Counter Counter Nonce Nonce + // Save state to temporary variables + let x00 = y00, x01 = y01, x02 = y02, x03 = y03, x04 = y04, x05 = y05, x06 = y06, x07 = y07, x08 = y08, x09 = y09, x10 = y10, x11 = y11, x12 = y12, x13 = y13, x14 = y14, x15 = y15; + for (let r = 0; r < rounds; r += 2) { + x00 = (x00 + x04) | 0; + x12 = rotl(x12 ^ x00, 16); + x08 = (x08 + x12) | 0; + x04 = rotl(x04 ^ x08, 12); + x00 = (x00 + x04) | 0; + x12 = rotl(x12 ^ x00, 8); + x08 = (x08 + x12) | 0; + x04 = rotl(x04 ^ x08, 7); + x01 = (x01 + x05) | 0; + x13 = rotl(x13 ^ x01, 16); + x09 = (x09 + x13) | 0; + x05 = rotl(x05 ^ x09, 12); + x01 = (x01 + x05) | 0; + x13 = rotl(x13 ^ x01, 8); + x09 = (x09 + x13) | 0; + x05 = rotl(x05 ^ x09, 7); + x02 = (x02 + x06) | 0; + x14 = rotl(x14 ^ x02, 16); + x10 = (x10 + x14) | 0; + x06 = rotl(x06 ^ x10, 12); + x02 = (x02 + x06) | 0; + x14 = rotl(x14 ^ x02, 8); + x10 = (x10 + x14) | 0; + x06 = rotl(x06 ^ x10, 7); + x03 = (x03 + x07) | 0; + x15 = rotl(x15 ^ x03, 16); + x11 = (x11 + x15) | 0; + x07 = rotl(x07 ^ x11, 12); + x03 = (x03 + x07) | 0; + x15 = rotl(x15 ^ x03, 8); + x11 = (x11 + x15) | 0; + x07 = rotl(x07 ^ x11, 7); + x00 = (x00 + x05) | 0; + x15 = rotl(x15 ^ x00, 16); + x10 = (x10 + x15) | 0; + x05 = rotl(x05 ^ x10, 12); + x00 = (x00 + x05) | 0; + x15 = rotl(x15 ^ x00, 8); + x10 = (x10 + x15) | 0; + x05 = rotl(x05 ^ x10, 7); + x01 = (x01 + x06) | 0; + x12 = rotl(x12 ^ x01, 16); + x11 = (x11 + x12) | 0; + x06 = rotl(x06 ^ x11, 12); + x01 = (x01 + x06) | 0; + x12 = rotl(x12 ^ x01, 8); + x11 = (x11 + x12) | 0; + x06 = rotl(x06 ^ x11, 7); + x02 = (x02 + x07) | 0; + x13 = rotl(x13 ^ x02, 16); + x08 = (x08 + x13) | 0; + x07 = rotl(x07 ^ x08, 12); + x02 = (x02 + x07) | 0; + x13 = rotl(x13 ^ x02, 8); + x08 = (x08 + x13) | 0; + x07 = rotl(x07 ^ x08, 7); + x03 = (x03 + x04) | 0; + x14 = rotl(x14 ^ x03, 16); + x09 = (x09 + x14) | 0; + x04 = rotl(x04 ^ x09, 12); + x03 = (x03 + x04) | 0; + x14 = rotl(x14 ^ x03, 8); + x09 = (x09 + x14) | 0; + x04 = rotl(x04 ^ x09, 7); + } + // Write output + let oi = 0; + out[oi++] = (y00 + x00) | 0; + out[oi++] = (y01 + x01) | 0; + out[oi++] = (y02 + x02) | 0; + out[oi++] = (y03 + x03) | 0; + out[oi++] = (y04 + x04) | 0; + out[oi++] = (y05 + x05) | 0; + out[oi++] = (y06 + x06) | 0; + out[oi++] = (y07 + x07) | 0; + out[oi++] = (y08 + x08) | 0; + out[oi++] = (y09 + x09) | 0; + out[oi++] = (y10 + x10) | 0; + out[oi++] = (y11 + x11) | 0; + out[oi++] = (y12 + x12) | 0; + out[oi++] = (y13 + x13) | 0; + out[oi++] = (y14 + x14) | 0; + out[oi++] = (y15 + x15) | 0; +} +/** + * hchacha helper method, used primarily in xchacha, to hash + * key and nonce into key' and nonce'. + * Same as chachaCore, but there doesn't seem to be a way to move the block + * out without 25% performance hit. + */ +// prettier-ignore +export function hchacha(s, k, i, o32) { + let x00 = s[0], x01 = s[1], x02 = s[2], x03 = s[3], x04 = k[0], x05 = k[1], x06 = k[2], x07 = k[3], x08 = k[4], x09 = k[5], x10 = k[6], x11 = k[7], x12 = i[0], x13 = i[1], x14 = i[2], x15 = i[3]; + for (let r = 0; r < 20; r += 2) { + x00 = (x00 + x04) | 0; + x12 = rotl(x12 ^ x00, 16); + x08 = (x08 + x12) | 0; + x04 = rotl(x04 ^ x08, 12); + x00 = (x00 + x04) | 0; + x12 = rotl(x12 ^ x00, 8); + x08 = (x08 + x12) | 0; + x04 = rotl(x04 ^ x08, 7); + x01 = (x01 + x05) | 0; + x13 = rotl(x13 ^ x01, 16); + x09 = (x09 + x13) | 0; + x05 = rotl(x05 ^ x09, 12); + x01 = (x01 + x05) | 0; + x13 = rotl(x13 ^ x01, 8); + x09 = (x09 + x13) | 0; + x05 = rotl(x05 ^ x09, 7); + x02 = (x02 + x06) | 0; + x14 = rotl(x14 ^ x02, 16); + x10 = (x10 + x14) | 0; + x06 = rotl(x06 ^ x10, 12); + x02 = (x02 + x06) | 0; + x14 = rotl(x14 ^ x02, 8); + x10 = (x10 + x14) | 0; + x06 = rotl(x06 ^ x10, 7); + x03 = (x03 + x07) | 0; + x15 = rotl(x15 ^ x03, 16); + x11 = (x11 + x15) | 0; + x07 = rotl(x07 ^ x11, 12); + x03 = (x03 + x07) | 0; + x15 = rotl(x15 ^ x03, 8); + x11 = (x11 + x15) | 0; + x07 = rotl(x07 ^ x11, 7); + x00 = (x00 + x05) | 0; + x15 = rotl(x15 ^ x00, 16); + x10 = (x10 + x15) | 0; + x05 = rotl(x05 ^ x10, 12); + x00 = (x00 + x05) | 0; + x15 = rotl(x15 ^ x00, 8); + x10 = (x10 + x15) | 0; + x05 = rotl(x05 ^ x10, 7); + x01 = (x01 + x06) | 0; + x12 = rotl(x12 ^ x01, 16); + x11 = (x11 + x12) | 0; + x06 = rotl(x06 ^ x11, 12); + x01 = (x01 + x06) | 0; + x12 = rotl(x12 ^ x01, 8); + x11 = (x11 + x12) | 0; + x06 = rotl(x06 ^ x11, 7); + x02 = (x02 + x07) | 0; + x13 = rotl(x13 ^ x02, 16); + x08 = (x08 + x13) | 0; + x07 = rotl(x07 ^ x08, 12); + x02 = (x02 + x07) | 0; + x13 = rotl(x13 ^ x02, 8); + x08 = (x08 + x13) | 0; + x07 = rotl(x07 ^ x08, 7); + x03 = (x03 + x04) | 0; + x14 = rotl(x14 ^ x03, 16); + x09 = (x09 + x14) | 0; + x04 = rotl(x04 ^ x09, 12); + x03 = (x03 + x04) | 0; + x14 = rotl(x14 ^ x03, 8); + x09 = (x09 + x14) | 0; + x04 = rotl(x04 ^ x09, 7); + } + let oi = 0; + o32[oi++] = x00; + o32[oi++] = x01; + o32[oi++] = x02; + o32[oi++] = x03; + o32[oi++] = x12; + o32[oi++] = x13; + o32[oi++] = x14; + o32[oi++] = x15; +} +/** + * Original, non-RFC chacha20 from DJB. 8-byte nonce, 8-byte counter. + */ +export const chacha20orig = /* @__PURE__ */ createCipher(chachaCore, { + counterRight: false, + counterLength: 8, + allowShortKeys: true, +}); +/** + * ChaCha stream cipher. Conforms to RFC 8439 (IETF, TLS). 12-byte nonce, 4-byte counter. + * With 12-byte nonce, it's not safe to use fill it with random (CSPRNG), due to collision chance. + */ +export const chacha20 = /* @__PURE__ */ createCipher(chachaCore, { + counterRight: false, + counterLength: 4, + allowShortKeys: false, +}); +/** + * XChaCha eXtended-nonce ChaCha. 24-byte nonce. + * With 24-byte nonce, it's safe to use fill it with random (CSPRNG). + * https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha + */ +export const xchacha20 = /* @__PURE__ */ createCipher(chachaCore, { + counterRight: false, + counterLength: 8, + extendNonceFn: hchacha, + allowShortKeys: false, +}); +/** + * Reduced 8-round chacha, described in original paper. + */ +export const chacha8 = /* @__PURE__ */ createCipher(chachaCore, { + counterRight: false, + counterLength: 4, + rounds: 8, +}); +/** + * Reduced 12-round chacha, described in original paper. + */ +export const chacha12 = /* @__PURE__ */ createCipher(chachaCore, { + counterRight: false, + counterLength: 4, + rounds: 12, +}); +const ZEROS16 = /* @__PURE__ */ new Uint8Array(16); +// Pad to digest size with zeros +const updatePadded = (h, msg) => { + h.update(msg); + const left = msg.length % 16; + if (left) + h.update(ZEROS16.subarray(left)); +}; +const ZEROS32 = /* @__PURE__ */ new Uint8Array(32); +function computeTag(fn, key, nonce, data, AAD) { + const authKey = fn(key, nonce, ZEROS32); + const h = poly1305.create(authKey); + if (AAD) + updatePadded(h, AAD); + updatePadded(h, data); + const num = u64Lengths(data.length, AAD ? AAD.length : 0, true); + h.update(num); + const res = h.digest(); + clean(authKey, num); + return res; +} +/** + * AEAD algorithm from RFC 8439. + * Salsa20 and chacha (RFC 8439) use poly1305 differently. + * We could have composed them similar to: + * https://github.com/paulmillr/scure-base/blob/b266c73dde977b1dd7ef40ef7a23cc15aab526b3/index.ts#L250 + * But it's hard because of authKey: + * In salsa20, authKey changes position in salsa stream. + * In chacha, authKey can't be computed inside computeTag, it modifies the counter. + */ +export const _poly1305_aead = (xorStream) => (key, nonce, AAD) => { + const tagLength = 16; + return { + encrypt(plaintext, output) { + const plength = plaintext.length; + output = getOutput(plength + tagLength, output, false); + output.set(plaintext); + const oPlain = output.subarray(0, -tagLength); + xorStream(key, nonce, oPlain, oPlain, 1); + const tag = computeTag(xorStream, key, nonce, oPlain, AAD); + output.set(tag, plength); // append tag + clean(tag); + return output; + }, + decrypt(ciphertext, output) { + output = getOutput(ciphertext.length - tagLength, output, false); + const data = ciphertext.subarray(0, -tagLength); + const passedTag = ciphertext.subarray(-tagLength); + const tag = computeTag(xorStream, key, nonce, data, AAD); + if (!equalBytes(passedTag, tag)) + throw new Error('invalid tag'); + output.set(ciphertext.subarray(0, -tagLength)); + xorStream(key, nonce, output, output, 1); // start stream with i=1 + clean(tag); + return output; + }, + }; +}; +/** + * ChaCha20-Poly1305 from RFC 8439. + * + * Unsafe to use random nonces under the same key, due to collision chance. + * Prefer XChaCha instead. + */ +export const chacha20poly1305 = /* @__PURE__ */ wrapCipher({ blockSize: 64, nonceLength: 12, tagLength: 16 }, _poly1305_aead(chacha20)); +/** + * XChaCha20-Poly1305 extended-nonce chacha. + * + * Can be safely used with random nonces (CSPRNG). + * See [IRTF draft](https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha). + */ +export const xchacha20poly1305 = /* @__PURE__ */ wrapCipher({ blockSize: 64, nonceLength: 24, tagLength: 16 }, _poly1305_aead(xchacha20)); +//# sourceMappingURL=chacha.js.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/chacha.js.map b/node_modules/@noble/ciphers/esm/chacha.js.map new file mode 100644 index 0000000000000000000000000000000000000000..d550fa23bee1f95d35a9bfc8cf8f5b2ecda42718 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/chacha.js.map @@ -0,0 +1 @@ +{"version":3,"file":"chacha.js","sourceRoot":"","sources":["../src/chacha.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAIL,KAAK,EACL,UAAU,EACV,SAAS,EACT,UAAU,EACV,UAAU,GACX,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,kBAAkB;AAClB,SAAS,UAAU,CACjB,CAAc,EAAE,CAAc,EAAE,CAAc,EAAE,GAAgB,EAAE,GAAW,EAAE,MAAM,GAAG,EAAE;IAE1F,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG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AG,UAAU,CAAC,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;YACzD,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,GAAG,CAAC;gBAAE,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;YAChE,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;YAC/C,SAAS,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,wBAAwB;YAClE,KAAK,CAAC,GAAG,CAAC,CAAC;YACX,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAEJ;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAc,eAAe,CAAC,UAAU,CACnE,EAAE,SAAS,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,EACjD,cAAc,CAAC,QAAQ,CAAC,CACzB,CAAC;AACF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAc,eAAe,CAAC,UAAU,CACpE,EAAE,SAAS,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,EACjD,cAAc,CAAC,SAAS,CAAC,CAC1B,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/crypto.d.ts b/node_modules/@noble/ciphers/esm/crypto.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ac181a0247597021010e0d9821dd2fdf4eb077c3 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/crypto.d.ts @@ -0,0 +1,2 @@ +export declare const crypto: any; +//# sourceMappingURL=crypto.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/crypto.d.ts.map b/node_modules/@noble/ciphers/esm/crypto.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..756d98203d7e40877c0d4eb89191cbab9dacc8ee --- /dev/null +++ b/node_modules/@noble/ciphers/esm/crypto.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../src/crypto.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,MAAM,EAAE,GACqE,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/crypto.js b/node_modules/@noble/ciphers/esm/crypto.js new file mode 100644 index 0000000000000000000000000000000000000000..8d499a088aaab5bdf5b46ba4f4fbd2e91c083010 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/crypto.js @@ -0,0 +1,2 @@ +export const crypto = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined; +//# sourceMappingURL=crypto.js.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/crypto.js.map b/node_modules/@noble/ciphers/esm/crypto.js.map new file mode 100644 index 0000000000000000000000000000000000000000..9ad4f45bd5e01672d8281d144d474ebd0380ca3d --- /dev/null +++ b/node_modules/@noble/ciphers/esm/crypto.js.map @@ -0,0 +1 @@ +{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../src/crypto.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,MAAM,GACjB,OAAO,UAAU,KAAK,QAAQ,IAAI,QAAQ,IAAI,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/cryptoNode.d.ts b/node_modules/@noble/ciphers/esm/cryptoNode.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..98bda7be4ddd7d83a758d97d502e691c6be18fc9 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/cryptoNode.d.ts @@ -0,0 +1,2 @@ +export declare const crypto: any; +//# sourceMappingURL=cryptoNode.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/cryptoNode.d.ts.map b/node_modules/@noble/ciphers/esm/cryptoNode.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..90dcc4441615525ae383030b2b6938b5092ae519 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/cryptoNode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"cryptoNode.d.ts","sourceRoot":"","sources":["../src/cryptoNode.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,MAAM,EAAE,GAKJ,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/cryptoNode.js b/node_modules/@noble/ciphers/esm/cryptoNode.js new file mode 100644 index 0000000000000000000000000000000000000000..4f77e8f46c5e242e1e3cb92712dc65e95a8b8eb0 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/cryptoNode.js @@ -0,0 +1,15 @@ +/** + * Internal webcrypto alias. + * We prefer WebCrypto aka globalThis.crypto, which exists in node.js 16+. + * Falls back to Node.js built-in crypto for Node.js <=v14. + * See utils.ts for details. + * @module + */ +// @ts-ignore +import * as nc from 'node:crypto'; +export const crypto = nc && typeof nc === 'object' && 'webcrypto' in nc + ? nc.webcrypto + : nc && typeof nc === 'object' && 'randomBytes' in nc + ? nc + : undefined; +//# sourceMappingURL=cryptoNode.js.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/cryptoNode.js.map b/node_modules/@noble/ciphers/esm/cryptoNode.js.map new file mode 100644 index 0000000000000000000000000000000000000000..6b07d8a6bf77b8edf6e3b373cf4ca2ba2a61d3ec --- /dev/null +++ b/node_modules/@noble/ciphers/esm/cryptoNode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"cryptoNode.js","sourceRoot":"","sources":["../src/cryptoNode.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,aAAa;AACb,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,MAAM,CAAC,MAAM,MAAM,GACjB,EAAE,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,WAAW,IAAI,EAAE;IAC/C,CAAC,CAAE,EAAE,CAAC,SAAiB;IACvB,CAAC,CAAC,EAAE,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,aAAa,IAAI,EAAE;QACnD,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,SAAS,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/ff1.d.ts b/node_modules/@noble/ciphers/esm/ff1.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..00e1a60d50515bf683650c0b5cce278c6d6d2d0e --- /dev/null +++ b/node_modules/@noble/ciphers/esm/ff1.d.ts @@ -0,0 +1,9 @@ +import { type Cipher } from './utils.ts'; +/** FPE-FF1 format-preserving encryption */ +export declare function FF1(radix: number, key: Uint8Array, tweak?: Uint8Array): { + encrypt(x: number[]): number[]; + decrypt(x: number[]): number[]; +}; +/** Binary version of FPE-FF1 format-preserving encryption. */ +export declare function BinaryFF1(key: Uint8Array, tweak?: Uint8Array): Cipher; +//# sourceMappingURL=ff1.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/ff1.d.ts.map b/node_modules/@noble/ciphers/esm/ff1.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..806fc9c238a79569c2c3601f8f4c9119aebd6096 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/ff1.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ff1.d.ts","sourceRoot":"","sources":["../src/ff1.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,MAAM,EAA4D,MAAM,YAAY,CAAC;AA0FnG,2CAA2C;AAC3C,wBAAgB,GAAG,CACjB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,UAAU,EACf,KAAK,GAAE,UAAsB,GAC5B;IAAE,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IAAC,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAA;CAAE,CAgCpE;AAqBD,8DAA8D;AAC9D,wBAAgB,SAAS,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,GAAE,UAAsB,GAAG,MAAM,CAMhF"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/ff1.js b/node_modules/@noble/ciphers/esm/ff1.js new file mode 100644 index 0000000000000000000000000000000000000000..b8d1ec1011da2aeb9840a584eec519c8bbf484e3 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/ff1.js @@ -0,0 +1,160 @@ +/** + * FPE-FF1 (Format-preserving encryption algorithm) specified in + * [NIST 800-38G](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38G.pdf). + * @module + */ +import { unsafe } from "./aes.js"; +import { abytes, anumber, bytesToNumberBE, clean, numberToBytesBE } from "./utils.js"; +// NOTE: no point in inlining encrypt instead of encryptBlock, since BigInt stuff will be slow +const { expandKeyLE, encryptBlock } = unsafe; +// Format-preserving encryption algorithm (FPE-FF1) specified in NIST Special Publication 800-38G. +// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38G.pdf +const BLOCK_LEN = 16; +function mod(a, b) { + const result = a % b; + return result >= 0 ? result : b + result; +} +function NUMradix(radix, data) { + let res = BigInt(0); + for (let i of data) + res = res * BigInt(radix) + BigInt(i); + return res; +} +function getRound(radix, key, tweak, x) { + if (radix > 2 ** 16 - 1) + throw new Error('invalid radix ' + radix); + // radix**minlen ≥ 100 + const minLen = Math.ceil(Math.log(100) / Math.log(radix)); + const maxLen = 2 ** 32 - 1; + // 2 ≤ minlen ≤ maxlen < 2**32 + if (2 > minLen || minLen > maxLen || maxLen >= 2 ** 32) + throw new Error('Invalid radix: 2 ≤ minlen ≤ maxlen < 2**32'); + if (!Array.isArray(x)) + throw new Error('invalid X'); + if (x.length < minLen || x.length > maxLen) + throw new Error('X is outside minLen..maxLen bounds'); + const u = Math.floor(x.length / 2); + const v = x.length - u; + const b = Math.ceil(Math.ceil(v * Math.log2(radix)) / 8); + const d = 4 * Math.ceil(b / 4) + 4; + const padding = mod(-tweak.length - b - 1, 16); + // P = [1]1 || [2]1 || [1]1 || [radix]3 || [10]1 || [u mod 256]1 || [n]4 || [t]4. + const P = Uint8Array.from([1, 2, 1, 0, 0, 0, 10, u, 0, 0, 0, 0, 0, 0, 0, 0]); + const view = new DataView(P.buffer); + view.setUint16(4, radix, false); + view.setUint32(8, x.length, false); + view.setUint32(12, tweak.length, false); + // Q = T || [0](−t−b−1) mod 16 || [i]1 || [NUMradix(B)]b. + const PQ = new Uint8Array(P.length + tweak.length + padding + 1 + b); + PQ.set(P); + clean(P); + PQ.set(tweak, P.length); + const xk = expandKeyLE(key); + const round = (A, B, i, decrypt = false) => { + // Q = ... || [i]1 || [NUMradix(B)]b. + PQ[PQ.length - b - 1] = i; + if (b) + PQ.set(numberToBytesBE(NUMradix(radix, B), b), PQ.length - b); + // PRF + let r = new Uint8Array(16); + for (let j = 0; j < PQ.length / BLOCK_LEN; j++) { + for (let i = 0; i < BLOCK_LEN; i++) + r[i] ^= PQ[j * BLOCK_LEN + i]; + encryptBlock(xk, r); + } + // Let S be the first d bytes of the following string of ⎡d/16⎤ blocks: + // R || CIPHK(R ⊕[1]16) || CIPHK(R ⊕[2]16) ...CIPHK(R ⊕[⎡d / 16⎤ – 1]16). + let s = Array.from(r); + for (let j = 1; s.length < d; j++) { + const block = numberToBytesBE(BigInt(j), 16); + for (let k = 0; k < BLOCK_LEN; k++) + block[k] ^= r[k]; + s.push(...Array.from(encryptBlock(xk, block))); + } + let y = bytesToNumberBE(Uint8Array.from(s.slice(0, d))); + s.fill(0); + if (decrypt) + y = -y; + const m = i % 2 === 0 ? u : v; + let c = mod(NUMradix(radix, A) + y, BigInt(radix) ** BigInt(m)); + // STR(radix, m, c) + const C = Array(m).fill(0); + for (let i = 0; i < m; i++, c /= BigInt(radix)) + C[m - 1 - i] = Number(c % BigInt(radix)); + A.fill(0); + A = B; + B = C; + return [A, B]; + }; + const destroy = () => { + clean(xk, PQ); + }; + return { u, round, destroy }; +} +const EMPTY_BUF = /* @__PURE__ */ Uint8Array.of(); +/** FPE-FF1 format-preserving encryption */ +export function FF1(radix, key, tweak = EMPTY_BUF) { + anumber(radix); + abytes(key); + abytes(tweak); + const PQ = getRound.bind(null, radix, key, tweak); + return { + encrypt(x) { + const { u, round, destroy } = PQ(x); + let [A, B] = [x.slice(0, u), x.slice(u)]; + for (let i = 0; i < 10; i++) + [A, B] = round(A, B, i); + destroy(); + const res = A.concat(B); + A.fill(0); + B.fill(0); + return res; + }, + decrypt(x) { + const { u, round, destroy } = PQ(x); + // The FF1.Decrypt algorithm is similar to the FF1.Encrypt algorithm; + // the differences are in Step 6, where: + // 1) the order of the indices is reversed, + // 2) the roles of A and B are swapped + // 3) modular addition is replaced by modular subtraction, in Step 6vi. + let [B, A] = [x.slice(0, u), x.slice(u)]; + for (let i = 9; i >= 0; i--) + [A, B] = round(A, B, i, true); + destroy(); + const res = B.concat(A); + A.fill(0); + B.fill(0); + return res; + }, + }; +} +// Binary string which encodes each byte in little-endian byte order +const binLE = { + encode(bytes) { + const x = []; + for (let i = 0; i < bytes.length; i++) { + for (let j = 0, tmp = bytes[i]; j < 8; j++, tmp >>= 1) + x.push(tmp & 1); + } + return x; + }, + decode(b) { + if (!Array.isArray(b) || b.length % 8) + throw new Error('Invalid binary string'); + const res = new Uint8Array(b.length / 8); + for (let i = 0, j = 0; i < res.length; i++) { + res[i] = b[j++] | (b[j++] << 1) | (b[j++] << 2) | (b[j++] << 3); + res[i] |= (b[j++] << 4) | (b[j++] << 5) | (b[j++] << 6) | (b[j++] << 7); + } + return res; + }, +}; +/** Binary version of FPE-FF1 format-preserving encryption. */ +export function BinaryFF1(key, tweak = EMPTY_BUF) { + const ff1 = FF1(2, key, tweak); + return { + encrypt: (x) => binLE.decode(ff1.encrypt(binLE.encode(x))), + decrypt: (x) => binLE.decode(ff1.decrypt(binLE.encode(x))), + }; +} +//# sourceMappingURL=ff1.js.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/ff1.js.map b/node_modules/@noble/ciphers/esm/ff1.js.map new file mode 100644 index 0000000000000000000000000000000000000000..006b4f59cd3f33c060b04b291f1a51fa9cc96073 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/ff1.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ff1.js","sourceRoot":"","sources":["../src/ff1.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAe,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEnG,8FAA8F;AAC9F,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;AAE7C,kGAAkG;AAClG,4EAA4E;AAE5E,MAAM,SAAS,GAAG,EAAE,CAAC;AAKrB,SAAS,GAAG,CAAC,CAAM,EAAE,CAAM;IACzB,MAAM,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC;IACrB,OAAO,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;AAC3C,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa,EAAE,IAAc;IAC7C,IAAI,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACpB,KAAK,IAAI,CAAC,IAAI,IAAI;QAAE,GAAG,GAAG,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAC1D,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa,EAAE,GAAe,EAAE,KAAiB,EAAE,CAAW;IAC9E,IAAI,KAAK,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAC;IACnE,sBAAsB;IACtB,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CA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,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1E,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF,CAAC;AAEF,8DAA8D;AAC9D,MAAM,UAAU,SAAS,CAAC,GAAe,EAAE,QAAoB,SAAS;IACtE,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IAC/B,OAAO;QACL,OAAO,EAAE,CAAC,CAAa,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QACtE,OAAO,EAAE,CAAC,CAAa,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;KACvE,CAAC;AACJ,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/index.d.ts b/node_modules/@noble/ciphers/esm/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e26a57a8ca84c682b2b77b57b9d6e340ffd33436 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/index.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/index.d.ts.map b/node_modules/@noble/ciphers/esm/index.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..535b86d29365e19067ae1813e023ccfdf008734a --- /dev/null +++ b/node_modules/@noble/ciphers/esm/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/index.js b/node_modules/@noble/ciphers/esm/index.js new file mode 100644 index 0000000000000000000000000000000000000000..84961f273c22865bb34f1d4bab3b645188c5f3b4 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/index.js @@ -0,0 +1,28 @@ +/** + * Audited & minimal JS implementation of Salsa20, ChaCha and AES. Check out individual modules. + * @example +```js +import { gcm, siv } from '@noble/ciphers/aes'; +import { xsalsa20poly1305 } from '@noble/ciphers/salsa'; +import { secretbox } from '@noble/ciphers/salsa'; // == xsalsa20poly1305 +import { chacha20poly1305, xchacha20poly1305 } from '@noble/ciphers/chacha'; + +// Unauthenticated encryption: make sure to use HMAC or similar +import { ctr, cfb, cbc, ecb } from '@noble/ciphers/aes'; +import { salsa20, xsalsa20 } from '@noble/ciphers/salsa'; +import { chacha20, xchacha20, chacha8, chacha12 } from '@noble/ciphers/chacha'; + +// KW +import { aeskw, aeskwp } from '@noble/ciphers/aes'; + +// Utilities +import { bytesToHex, hexToBytes, bytesToUtf8, utf8ToBytes } from '@noble/ciphers/utils'; +import { managedNonce, randomBytes } from '@noble/ciphers/webcrypto'; +import { poly1305 } from '@noble/ciphers/_poly1305'; +import { ghash, polyval } from '@noble/ciphers/_polyval'; +``` + * @module + */ +throw new Error('root module cannot be imported: import submodules instead. Check out README'); +export {}; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/index.js.map b/node_modules/@noble/ciphers/esm/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..bd1a66b37b28d57077e77e5da931b7f5e03c967c --- /dev/null +++ b/node_modules/@noble/ciphers/esm/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,IAAI,KAAK,CAAC,6EAA6E,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/package.json b/node_modules/@noble/ciphers/esm/package.json new file mode 100644 index 0000000000000000000000000000000000000000..f42e46b18130a0a55bf784034da6d890ba966f2f --- /dev/null +++ b/node_modules/@noble/ciphers/esm/package.json @@ -0,0 +1,10 @@ +{ + "type": "module", + "sideEffects": false, + "browser": { + "node:crypto": false + }, + "node": { + "./crypto": "./esm/cryptoNode.js" + } +} diff --git a/node_modules/@noble/ciphers/esm/salsa.d.ts b/node_modules/@noble/ciphers/esm/salsa.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..dc5931c6878416bc1ac535784c6cd4ffbf441aee --- /dev/null +++ b/node_modules/@noble/ciphers/esm/salsa.d.ts @@ -0,0 +1,33 @@ +import { type ARXCipher, type XorStream } from './utils.ts'; +/** + * hsalsa hashing function, used primarily in xsalsa, to hash + * key and nonce into key' and nonce'. + * Same as salsaCore, but there doesn't seem to be a way to move the block + * out without 25% performance hit. + */ +export declare function hsalsa(s: Uint32Array, k: Uint32Array, i: Uint32Array, o32: Uint32Array): void; +/** + * Salsa20 from original paper. + * Unsafe to use random nonces under the same key, due to collision chance. + * Prefer XSalsa instead. + */ +export declare const salsa20: XorStream; +/** + * xsalsa20 eXtended-nonce salsa. + * Can be safely used with random 24-byte nonces (CSPRNG). + */ +export declare const xsalsa20: XorStream; +/** + * xsalsa20-poly1305 eXtended-nonce salsa. + * Can be safely used with random 24-byte nonces (CSPRNG). + * Also known as secretbox from libsodium / nacl. + */ +export declare const xsalsa20poly1305: ARXCipher; +/** + * Alias to `xsalsa20poly1305`, for compatibility with libsodium / nacl + */ +export declare function secretbox(key: Uint8Array, nonce: Uint8Array): { + seal: (plaintext: Uint8Array, output?: Uint8Array) => Uint8Array; + open: (ciphertext: Uint8Array, output?: Uint8Array) => Uint8Array; +}; +//# sourceMappingURL=salsa.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/salsa.d.ts.map b/node_modules/@noble/ciphers/esm/salsa.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..c7ad02abaaa816a1bfe9b000edc1d8c06dbc7890 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/salsa.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"salsa.d.ts","sourceRoot":"","sources":["../src/salsa.ts"],"names":[],"mappings":"AAiBA,OAAO,EAEL,KAAK,SAAS,EAMd,KAAK,SAAS,EACf,MAAM,YAAY,CAAC;AA+CpB;;;;;GAKG;AAEH,wBAAgB,MAAM,CACpB,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,EAAE,GAAG,EAAE,WAAW,GAC/D,IAAI,CA4BN;AAED;;;;GAIG;AACH,eAAO,MAAM,OAAO,EAAE,SAGpB,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,SAGrB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAsC9B,CAAC;AAEF;;GAEG;AACH,wBAAgB,SAAS,CACvB,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,UAAU,GAChB;IACD,IAAI,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,UAAU,KAAK,UAAU,CAAC;IACjE,IAAI,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,UAAU,KAAK,UAAU,CAAC;CACnE,CAGA"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/salsa.js b/node_modules/@noble/ciphers/esm/salsa.js new file mode 100644 index 0000000000000000000000000000000000000000..744267e0b7214155c52e34cd0f29f6e964073dcf --- /dev/null +++ b/node_modules/@noble/ciphers/esm/salsa.js @@ -0,0 +1,201 @@ +/** + * [Salsa20](https://cr.yp.to/snuffle.html) stream cipher, released in 2005. + * + * Salsa's goal was to implement AES replacement that does not rely on S-Boxes, + * which are hard to implement in a constant-time manner. + * Salsa20 is usually faster than AES, a big deal on slow, budget mobile phones. + * + * [XSalsa20](https://cr.yp.to/snuffle/xsalsa-20110204.pdf), extended-nonce + * variant was released in 2008. It switched nonces from 96-bit to 192-bit, + * and became safe to be picked at random. + * + * Check out [PDF](https://cr.yp.to/snuffle/salsafamily-20071225.pdf) and + * [wiki](https://en.wikipedia.org/wiki/Salsa20). + * @module + */ +import { createCipher, rotl } from "./_arx.js"; +import { poly1305 } from "./_poly1305.js"; +import { abytes, clean, equalBytes, getOutput, wrapCipher, } from "./utils.js"; +/** Salsa20 core function. */ +// prettier-ignore +function salsaCore(s, k, n, out, cnt, rounds = 20) { + // Based on https://cr.yp.to/salsa20.html + let y00 = s[0], y01 = k[0], y02 = k[1], y03 = k[2], // "expa" Key Key Key + y04 = k[3], y05 = s[1], y06 = n[0], y07 = n[1], // Key "nd 3" Nonce Nonce + y08 = cnt, y09 = 0, y10 = s[2], y11 = k[4], // Pos. Pos. "2-by" Key + y12 = k[5], y13 = k[6], y14 = k[7], y15 = s[3]; // Key Key Key "te k" + // Save state to temporary variables + let x00 = y00, x01 = y01, x02 = y02, x03 = y03, x04 = y04, x05 = y05, x06 = y06, x07 = y07, x08 = y08, x09 = y09, x10 = y10, x11 = y11, x12 = y12, x13 = y13, x14 = y14, x15 = y15; + for (let r = 0; r < rounds; r += 2) { + x04 ^= rotl(x00 + x12 | 0, 7); + x08 ^= rotl(x04 + x00 | 0, 9); + x12 ^= rotl(x08 + x04 | 0, 13); + x00 ^= rotl(x12 + x08 | 0, 18); + x09 ^= rotl(x05 + x01 | 0, 7); + x13 ^= rotl(x09 + x05 | 0, 9); + x01 ^= rotl(x13 + x09 | 0, 13); + x05 ^= rotl(x01 + x13 | 0, 18); + x14 ^= rotl(x10 + x06 | 0, 7); + x02 ^= rotl(x14 + x10 | 0, 9); + x06 ^= rotl(x02 + x14 | 0, 13); + x10 ^= rotl(x06 + x02 | 0, 18); + x03 ^= rotl(x15 + x11 | 0, 7); + x07 ^= rotl(x03 + x15 | 0, 9); + x11 ^= rotl(x07 + x03 | 0, 13); + x15 ^= rotl(x11 + x07 | 0, 18); + x01 ^= rotl(x00 + x03 | 0, 7); + x02 ^= rotl(x01 + x00 | 0, 9); + x03 ^= rotl(x02 + x01 | 0, 13); + x00 ^= rotl(x03 + x02 | 0, 18); + x06 ^= rotl(x05 + x04 | 0, 7); + x07 ^= rotl(x06 + x05 | 0, 9); + x04 ^= rotl(x07 + x06 | 0, 13); + x05 ^= rotl(x04 + x07 | 0, 18); + x11 ^= rotl(x10 + x09 | 0, 7); + x08 ^= rotl(x11 + x10 | 0, 9); + x09 ^= rotl(x08 + x11 | 0, 13); + x10 ^= rotl(x09 + x08 | 0, 18); + x12 ^= rotl(x15 + x14 | 0, 7); + x13 ^= rotl(x12 + x15 | 0, 9); + x14 ^= rotl(x13 + x12 | 0, 13); + x15 ^= rotl(x14 + x13 | 0, 18); + } + // Write output + let oi = 0; + out[oi++] = (y00 + x00) | 0; + out[oi++] = (y01 + x01) | 0; + out[oi++] = (y02 + x02) | 0; + out[oi++] = (y03 + x03) | 0; + out[oi++] = (y04 + x04) | 0; + out[oi++] = (y05 + x05) | 0; + out[oi++] = (y06 + x06) | 0; + out[oi++] = (y07 + x07) | 0; + out[oi++] = (y08 + x08) | 0; + out[oi++] = (y09 + x09) | 0; + out[oi++] = (y10 + x10) | 0; + out[oi++] = (y11 + x11) | 0; + out[oi++] = (y12 + x12) | 0; + out[oi++] = (y13 + x13) | 0; + out[oi++] = (y14 + x14) | 0; + out[oi++] = (y15 + x15) | 0; +} +/** + * hsalsa hashing function, used primarily in xsalsa, to hash + * key and nonce into key' and nonce'. + * Same as salsaCore, but there doesn't seem to be a way to move the block + * out without 25% performance hit. + */ +// prettier-ignore +export function hsalsa(s, k, i, o32) { + let x00 = s[0], x01 = k[0], x02 = k[1], x03 = k[2], x04 = k[3], x05 = s[1], x06 = i[0], x07 = i[1], x08 = i[2], x09 = i[3], x10 = s[2], x11 = k[4], x12 = k[5], x13 = k[6], x14 = k[7], x15 = s[3]; + for (let r = 0; r < 20; r += 2) { + x04 ^= rotl(x00 + x12 | 0, 7); + x08 ^= rotl(x04 + x00 | 0, 9); + x12 ^= rotl(x08 + x04 | 0, 13); + x00 ^= rotl(x12 + x08 | 0, 18); + x09 ^= rotl(x05 + x01 | 0, 7); + x13 ^= rotl(x09 + x05 | 0, 9); + x01 ^= rotl(x13 + x09 | 0, 13); + x05 ^= rotl(x01 + x13 | 0, 18); + x14 ^= rotl(x10 + x06 | 0, 7); + x02 ^= rotl(x14 + x10 | 0, 9); + x06 ^= rotl(x02 + x14 | 0, 13); + x10 ^= rotl(x06 + x02 | 0, 18); + x03 ^= rotl(x15 + x11 | 0, 7); + x07 ^= rotl(x03 + x15 | 0, 9); + x11 ^= rotl(x07 + x03 | 0, 13); + x15 ^= rotl(x11 + x07 | 0, 18); + x01 ^= rotl(x00 + x03 | 0, 7); + x02 ^= rotl(x01 + x00 | 0, 9); + x03 ^= rotl(x02 + x01 | 0, 13); + x00 ^= rotl(x03 + x02 | 0, 18); + x06 ^= rotl(x05 + x04 | 0, 7); + x07 ^= rotl(x06 + x05 | 0, 9); + x04 ^= rotl(x07 + x06 | 0, 13); + x05 ^= rotl(x04 + x07 | 0, 18); + x11 ^= rotl(x10 + x09 | 0, 7); + x08 ^= rotl(x11 + x10 | 0, 9); + x09 ^= rotl(x08 + x11 | 0, 13); + x10 ^= rotl(x09 + x08 | 0, 18); + x12 ^= rotl(x15 + x14 | 0, 7); + x13 ^= rotl(x12 + x15 | 0, 9); + x14 ^= rotl(x13 + x12 | 0, 13); + x15 ^= rotl(x14 + x13 | 0, 18); + } + let oi = 0; + o32[oi++] = x00; + o32[oi++] = x05; + o32[oi++] = x10; + o32[oi++] = x15; + o32[oi++] = x06; + o32[oi++] = x07; + o32[oi++] = x08; + o32[oi++] = x09; +} +/** + * Salsa20 from original paper. + * Unsafe to use random nonces under the same key, due to collision chance. + * Prefer XSalsa instead. + */ +export const salsa20 = /* @__PURE__ */ createCipher(salsaCore, { + allowShortKeys: true, + counterRight: true, +}); +/** + * xsalsa20 eXtended-nonce salsa. + * Can be safely used with random 24-byte nonces (CSPRNG). + */ +export const xsalsa20 = /* @__PURE__ */ createCipher(salsaCore, { + counterRight: true, + extendNonceFn: hsalsa, +}); +/** + * xsalsa20-poly1305 eXtended-nonce salsa. + * Can be safely used with random 24-byte nonces (CSPRNG). + * Also known as secretbox from libsodium / nacl. + */ +export const xsalsa20poly1305 = /* @__PURE__ */ wrapCipher({ blockSize: 64, nonceLength: 24, tagLength: 16 }, (key, nonce) => { + return { + encrypt(plaintext, output) { + // xsalsa20poly1305 optimizes by calculating auth key during the same call as encryption. + // Unfortunately, makes it hard to separate tag calculation & encryption itself, + // because 32 bytes is half-block of 64-byte salsa. + output = getOutput(plaintext.length + 32, output, false); // need 32 additional bytes, see above + const authKey = output.subarray(0, 32); // output[0..32] = poly1305 auth key + const ciphPlaintext = output.subarray(32); // output[32..] = plaintext, then ciphertext + output.set(plaintext, 32); + clean(authKey); // authKey is produced by xoring with zeros + xsalsa20(key, nonce, output, output); // output = stream ^ output; authKey = stream ^ zeros(32) + const tag = poly1305(ciphPlaintext, authKey); // calculate tag over ciphertext + output.set(tag, 16); // output[16..32] = tag + clean(output.subarray(0, 16), tag); // clean-up authKey remnants & copy of tag + return output.subarray(16); // return output[16..] + }, + decrypt(ciphertext, output) { + // tmp part passed tag ciphertext + // [0..32] [32..48] [48..] + abytes(ciphertext); + output = getOutput(ciphertext.length + 32, output, false); + const tmp = output.subarray(0, 32); // output[0..32] is used to calc authKey + const passedTag = output.subarray(32, 48); // output[32..48] = passed tag + const ciphPlaintext = output.subarray(48); // output[48..] = ciphertext, then plaintext + output.set(ciphertext, 32); // copy ciphertext into output + clean(tmp); // authKey is produced by xoring with zeros + const authKey = xsalsa20(key, nonce, tmp, tmp); // authKey = stream ^ zeros(32) + const tag = poly1305(ciphPlaintext, authKey); // calculate tag over ciphertext + if (!equalBytes(passedTag, tag)) + throw new Error('invalid tag'); + xsalsa20(key, nonce, output.subarray(16), output.subarray(16)); // output = stream ^ output[16..] + clean(tmp, passedTag, tag); + return ciphPlaintext; // return output[48..], skipping zeroized output[0..48] + }, + }; +}); +/** + * Alias to `xsalsa20poly1305`, for compatibility with libsodium / nacl + */ +export function secretbox(key, nonce) { + const xs = xsalsa20poly1305(key, nonce); + return { seal: xs.encrypt, open: xs.decrypt }; +} +//# sourceMappingURL=salsa.js.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/salsa.js.map b/node_modules/@noble/ciphers/esm/salsa.js.map new file mode 100644 index 0000000000000000000000000000000000000000..48c6847d4945b12ca9febb5765b97869156948d0 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/salsa.js.map @@ -0,0 +1 @@ +{"version":3,"file":"salsa.js","sourceRoot":"","sources":["../src/salsa.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EACL,MAAM,EAGN,KAAK,EACL,UAAU,EACV,SAAS,EACT,UAAU,GAEX,MAAM,YAAY,CAAC;AAEpB,6BAA6B;AAC7B,kBAAkB;AAClB,SAAS,SAAS,CAChB,CAAc,EAAE,CAAc,EAAE,CAAc,EAAE,GAAgB,EAAE,GAAW,EAAE,MAAM,GAAG,EAAE;IAE1F,yCAAyC;IACzC,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,6BAA6B;IAC7E,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAA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C,EAAE,CAAC,CAAC,CAAC,4CAA4C;YACvF,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC,8BAA8B;YAC1D,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,2CAA2C;YACvD,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,+BAA+B;YAC/E,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC,gCAAgC;YAC9E,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,GAAG,CAAC;gBAAE,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;YAChE,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,iCAAiC;YACjG,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;YAC3B,OAAO,aAAa,CAAC,CAAC,uDAAuD;QAC/E,CAAC;KACF,CAAC;AACJ,CAAC,CACF,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,SAAS,CACvB,GAAe,EACf,KAAiB;IAKjB,MAAM,EAAE,GAAG,gBAAgB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACxC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC;AAChD,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/utils.d.ts b/node_modules/@noble/ciphers/esm/utils.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5194ed083312db0e8d719f84264b51693eb28fe7 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/utils.d.ts @@ -0,0 +1,155 @@ +/** + * Utilities for hex, bytes, CSPRNG. + * @module + */ +/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */ +/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */ +export declare function isBytes(a: unknown): a is Uint8Array; +/** Asserts something is boolean. */ +export declare function abool(b: boolean): void; +/** Asserts something is positive integer. */ +export declare function anumber(n: number): void; +/** Asserts something is Uint8Array. */ +export declare function abytes(b: Uint8Array | undefined, ...lengths: number[]): void; +/** + * Asserts something is hash + * TODO: remove + * @deprecated + */ +export declare function ahash(h: IHash): void; +/** Asserts a hash instance has not been destroyed / finished */ +export declare function aexists(instance: any, checkFinished?: boolean): void; +/** Asserts output is properly-sized byte array */ +export declare function aoutput(out: any, instance: any): void; +export type IHash = { + (data: string | Uint8Array): Uint8Array; + blockLen: number; + outputLen: number; + create: any; +}; +/** Generic type encompassing 8/16/32-byte arrays - but not 64-byte. */ +export type TypedArray = Int8Array | Uint8ClampedArray | Uint8Array | Uint16Array | Int16Array | Uint32Array | Int32Array; +/** Cast u8 / u16 / u32 to u8. */ +export declare function u8(arr: TypedArray): Uint8Array; +/** Cast u8 / u16 / u32 to u32. */ +export declare function u32(arr: TypedArray): Uint32Array; +/** Zeroize a byte array. Warning: JS provides no guarantees. */ +export declare function clean(...arrays: TypedArray[]): void; +/** Create DataView of an array for easy byte-level manipulation. */ +export declare function createView(arr: TypedArray): DataView; +/** Is current platform little-endian? Most are. Big-Endian platform: IBM */ +export declare const isLE: boolean; +/** + * Convert byte array to hex string. Uses built-in function, when available. + * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123' + */ +export declare function bytesToHex(bytes: Uint8Array): string; +/** + * Convert hex string to byte array. Uses built-in function, when available. + * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23]) + */ +export declare function hexToBytes(hex: string): Uint8Array; +export declare function hexToNumber(hex: string): bigint; +export declare function bytesToNumberBE(bytes: Uint8Array): bigint; +export declare function numberToBytesBE(n: number | bigint, len: number): Uint8Array; +export declare const nextTick: () => Promise; +/** + * Converts string to bytes using UTF8 encoding. + * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99]) + */ +export declare function utf8ToBytes(str: string): Uint8Array; +/** + * Converts bytes to string using UTF8 encoding. + * @example bytesToUtf8(new Uint8Array([97, 98, 99])) // 'abc' + */ +export declare function bytesToUtf8(bytes: Uint8Array): string; +export type Input = Uint8Array | string; +/** + * Normalizes (non-hex) string or Uint8Array to Uint8Array. + * Warning: when Uint8Array is passed, it would NOT get copied. + * Keep in mind for future mutable operations. + */ +export declare function toBytes(data: string | Uint8Array): Uint8Array; +/** + * Checks if two U8A use same underlying buffer and overlaps. + * This is invalid and can corrupt data. + */ +export declare function overlapBytes(a: Uint8Array, b: Uint8Array): boolean; +/** + * If input and output overlap and input starts before output, we will overwrite end of input before + * we start processing it, so this is not supported for most ciphers (except chacha/salse, which designed with this) + */ +export declare function complexOverlapBytes(input: Uint8Array, output: Uint8Array): void; +/** + * Copies several Uint8Arrays into one. + */ +export declare function concatBytes(...arrays: Uint8Array[]): Uint8Array; +type EmptyObj = {}; +export declare function checkOpts(defaults: T1, opts: T2): T1 & T2; +/** Compares 2 uint8array-s in kinda constant time. */ +export declare function equalBytes(a: Uint8Array, b: Uint8Array): boolean; +/** For runtime check if class implements interface. */ +export declare abstract class Hash> { + abstract blockLen: number; + abstract outputLen: number; + abstract update(buf: string | Uint8Array): this; + abstract digestInto(buf: Uint8Array): void; + abstract digest(): Uint8Array; + /** + * Resets internal state. Makes Hash instance unusable. + * Reset is impossible for keyed hashes if key is consumed into state. If digest is not consumed + * by user, they will need to manually call `destroy()` when zeroing is necessary. + */ + abstract destroy(): void; +} +/** Sync cipher: takes byte array and returns byte array. */ +export type Cipher = { + encrypt(plaintext: Uint8Array): Uint8Array; + decrypt(ciphertext: Uint8Array): Uint8Array; +}; +/** Async cipher e.g. from built-in WebCrypto. */ +export type AsyncCipher = { + encrypt(plaintext: Uint8Array): Promise; + decrypt(ciphertext: Uint8Array): Promise; +}; +/** Cipher with `output` argument which can optimize by doing 1 less allocation. */ +export type CipherWithOutput = Cipher & { + encrypt(plaintext: Uint8Array, output?: Uint8Array): Uint8Array; + decrypt(ciphertext: Uint8Array, output?: Uint8Array): Uint8Array; +}; +/** + * Params are outside of return type, so it is accessible before calling constructor. + * If function support multiple nonceLength's, we return the best one. + */ +export type CipherParams = { + blockSize: number; + nonceLength?: number; + tagLength?: number; + varSizeNonce?: boolean; +}; +/** ARX cipher, like salsa or chacha. */ +export type ARXCipher = ((key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => CipherWithOutput) & { + blockSize: number; + nonceLength: number; + tagLength: number; +}; +export type CipherCons = (key: Uint8Array, ...args: T) => Cipher; +/** + * Wraps a cipher: validates args, ensures encrypt() can only be called once. + * @__NO_SIDE_EFFECTS__ + */ +export declare const wrapCipher: , P extends CipherParams>(params: P, constructor: C) => C & P; +/** Represents salsa / chacha stream. */ +export type XorStream = (key: Uint8Array, nonce: Uint8Array, data: Uint8Array, output?: Uint8Array, counter?: number) => Uint8Array; +/** + * By default, returns u8a of length. + * When out is available, it checks it for validity and uses it. + */ +export declare function getOutput(expectedLength: number, out?: Uint8Array, onlyAligned?: boolean): Uint8Array; +/** Polyfill for Safari 14. */ +export declare function setBigUint64(view: DataView, byteOffset: number, value: bigint, isLE: boolean): void; +export declare function u64Lengths(dataLength: number, aadLength: number, isLE: boolean): Uint8Array; +export declare function isAligned32(bytes: Uint8Array): boolean; +export declare function copyBytes(bytes: Uint8Array): Uint8Array; +export {}; +//# sourceMappingURL=utils.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/utils.d.ts.map b/node_modules/@noble/ciphers/esm/utils.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..fe1a1ad983d263c9594651f9211cc39e317d4418 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/utils.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[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UN;AAED,wBAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,UAAU,CAO3F;AAGD,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAEtD;AAGD,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAEvD"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/utils.js b/node_modules/@noble/ciphers/esm/utils.js new file mode 100644 index 0000000000000000000000000000000000000000..775865c34c3022cb34996329c7c907bacefcb8ed --- /dev/null +++ b/node_modules/@noble/ciphers/esm/utils.js @@ -0,0 +1,339 @@ +/** + * Utilities for hex, bytes, CSPRNG. + * @module + */ +/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */ +/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */ +export function isBytes(a) { + return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array'); +} +/** Asserts something is boolean. */ +export function abool(b) { + if (typeof b !== 'boolean') + throw new Error(`boolean expected, not ${b}`); +} +/** Asserts something is positive integer. */ +export function anumber(n) { + if (!Number.isSafeInteger(n) || n < 0) + throw new Error('positive integer expected, got ' + n); +} +/** Asserts something is Uint8Array. */ +export function abytes(b, ...lengths) { + if (!isBytes(b)) + throw new Error('Uint8Array expected'); + if (lengths.length > 0 && !lengths.includes(b.length)) + throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length); +} +/** + * Asserts something is hash + * TODO: remove + * @deprecated + */ +export function ahash(h) { + if (typeof h !== 'function' || typeof h.create !== 'function') + throw new Error('Hash should be wrapped by utils.createHasher'); + anumber(h.outputLen); + anumber(h.blockLen); +} +/** Asserts a hash instance has not been destroyed / finished */ +export function aexists(instance, checkFinished = true) { + if (instance.destroyed) + throw new Error('Hash instance has been destroyed'); + if (checkFinished && instance.finished) + throw new Error('Hash#digest() has already been called'); +} +/** Asserts output is properly-sized byte array */ +export function aoutput(out, instance) { + abytes(out); + const min = instance.outputLen; + if (out.length < min) { + throw new Error('digestInto() expects output buffer of length at least ' + min); + } +} +/** Cast u8 / u16 / u32 to u8. */ +export function u8(arr) { + return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength); +} +/** Cast u8 / u16 / u32 to u32. */ +export function u32(arr) { + return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4)); +} +/** Zeroize a byte array. Warning: JS provides no guarantees. */ +export function clean(...arrays) { + for (let i = 0; i < arrays.length; i++) { + arrays[i].fill(0); + } +} +/** Create DataView of an array for easy byte-level manipulation. */ +export function createView(arr) { + return new DataView(arr.buffer, arr.byteOffset, arr.byteLength); +} +/** Is current platform little-endian? Most are. Big-Endian platform: IBM */ +export const isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)(); +// Built-in hex conversion https://caniuse.com/mdn-javascript_builtins_uint8array_fromhex +const hasHexBuiltin = /* @__PURE__ */ (() => +// @ts-ignore +typeof Uint8Array.from([]).toHex === 'function' && typeof Uint8Array.fromHex === 'function')(); +// Array where index 0xf0 (240) is mapped to string 'f0' +const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0')); +/** + * Convert byte array to hex string. Uses built-in function, when available. + * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123' + */ +export function bytesToHex(bytes) { + abytes(bytes); + // @ts-ignore + if (hasHexBuiltin) + return bytes.toHex(); + // pre-caching improves the speed 6x + let hex = ''; + for (let i = 0; i < bytes.length; i++) { + hex += hexes[bytes[i]]; + } + return hex; +} +// We use optimized technique to convert hex string to byte array +const asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 }; +function asciiToBase16(ch) { + if (ch >= asciis._0 && ch <= asciis._9) + return ch - asciis._0; // '2' => 50-48 + if (ch >= asciis.A && ch <= asciis.F) + return ch - (asciis.A - 10); // 'B' => 66-(65-10) + if (ch >= asciis.a && ch <= asciis.f) + return ch - (asciis.a - 10); // 'b' => 98-(97-10) + return; +} +/** + * Convert hex string to byte array. Uses built-in function, when available. + * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23]) + */ +export function hexToBytes(hex) { + if (typeof hex !== 'string') + throw new Error('hex string expected, got ' + typeof hex); + // @ts-ignore + if (hasHexBuiltin) + return Uint8Array.fromHex(hex); + const hl = hex.length; + const al = hl / 2; + if (hl % 2) + throw new Error('hex string expected, got unpadded hex of length ' + hl); + const array = new Uint8Array(al); + for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) { + const n1 = asciiToBase16(hex.charCodeAt(hi)); + const n2 = asciiToBase16(hex.charCodeAt(hi + 1)); + if (n1 === undefined || n2 === undefined) { + const char = hex[hi] + hex[hi + 1]; + throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi); + } + array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163 + } + return array; +} +// Used in micro +export function hexToNumber(hex) { + if (typeof hex !== 'string') + throw new Error('hex string expected, got ' + typeof hex); + return BigInt(hex === '' ? '0' : '0x' + hex); // Big Endian +} +// Used in ff1 +// BE: Big Endian, LE: Little Endian +export function bytesToNumberBE(bytes) { + return hexToNumber(bytesToHex(bytes)); +} +// Used in micro, ff1 +export function numberToBytesBE(n, len) { + return hexToBytes(n.toString(16).padStart(len * 2, '0')); +} +// TODO: remove +// There is no setImmediate in browser and setTimeout is slow. +// call of async fn will return Promise, which will be fullfiled only on +// next scheduler queue processing step and this is exactly what we need. +export const nextTick = async () => { }; +/** + * Converts string to bytes using UTF8 encoding. + * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99]) + */ +export function utf8ToBytes(str) { + if (typeof str !== 'string') + throw new Error('string expected'); + return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809 +} +/** + * Converts bytes to string using UTF8 encoding. + * @example bytesToUtf8(new Uint8Array([97, 98, 99])) // 'abc' + */ +export function bytesToUtf8(bytes) { + return new TextDecoder().decode(bytes); +} +/** + * Normalizes (non-hex) string or Uint8Array to Uint8Array. + * Warning: when Uint8Array is passed, it would NOT get copied. + * Keep in mind for future mutable operations. + */ +export function toBytes(data) { + if (typeof data === 'string') + data = utf8ToBytes(data); + else if (isBytes(data)) + data = copyBytes(data); + else + throw new Error('Uint8Array expected, got ' + typeof data); + return data; +} +/** + * Checks if two U8A use same underlying buffer and overlaps. + * This is invalid and can corrupt data. + */ +export function overlapBytes(a, b) { + return (a.buffer === b.buffer && // best we can do, may fail with an obscure Proxy + a.byteOffset < b.byteOffset + b.byteLength && // a starts before b end + b.byteOffset < a.byteOffset + a.byteLength // b starts before a end + ); +} +/** + * If input and output overlap and input starts before output, we will overwrite end of input before + * we start processing it, so this is not supported for most ciphers (except chacha/salse, which designed with this) + */ +export function complexOverlapBytes(input, output) { + // This is very cursed. It works somehow, but I'm completely unsure, + // reasoning about overlapping aligned windows is very hard. + if (overlapBytes(input, output) && input.byteOffset < output.byteOffset) + throw new Error('complex overlap of input and output is not supported'); +} +/** + * Copies several Uint8Arrays into one. + */ +export function concatBytes(...arrays) { + let sum = 0; + for (let i = 0; i < arrays.length; i++) { + const a = arrays[i]; + abytes(a); + sum += a.length; + } + const res = new Uint8Array(sum); + for (let i = 0, pad = 0; i < arrays.length; i++) { + const a = arrays[i]; + res.set(a, pad); + pad += a.length; + } + return res; +} +export function checkOpts(defaults, opts) { + if (opts == null || typeof opts !== 'object') + throw new Error('options must be defined'); + const merged = Object.assign(defaults, opts); + return merged; +} +/** Compares 2 uint8array-s in kinda constant time. */ +export function equalBytes(a, b) { + if (a.length !== b.length) + return false; + let diff = 0; + for (let i = 0; i < a.length; i++) + diff |= a[i] ^ b[i]; + return diff === 0; +} +// TODO: remove +/** For runtime check if class implements interface. */ +export class Hash { +} +/** + * Wraps a cipher: validates args, ensures encrypt() can only be called once. + * @__NO_SIDE_EFFECTS__ + */ +export const wrapCipher = (params, constructor) => { + function wrappedCipher(key, ...args) { + // Validate key + abytes(key); + // Big-Endian hardware is rare. Just in case someone still decides to run ciphers: + if (!isLE) + throw new Error('Non little-endian hardware is not yet supported'); + // Validate nonce if nonceLength is present + if (params.nonceLength !== undefined) { + const nonce = args[0]; + if (!nonce) + throw new Error('nonce / iv required'); + if (params.varSizeNonce) + abytes(nonce); + else + abytes(nonce, params.nonceLength); + } + // Validate AAD if tagLength present + const tagl = params.tagLength; + if (tagl && args[1] !== undefined) { + abytes(args[1]); + } + const cipher = constructor(key, ...args); + const checkOutput = (fnLength, output) => { + if (output !== undefined) { + if (fnLength !== 2) + throw new Error('cipher output not supported'); + abytes(output); + } + }; + // Create wrapped cipher with validation and single-use encryption + let called = false; + const wrCipher = { + encrypt(data, output) { + if (called) + throw new Error('cannot encrypt() twice with same key + nonce'); + called = true; + abytes(data); + checkOutput(cipher.encrypt.length, output); + return cipher.encrypt(data, output); + }, + decrypt(data, output) { + abytes(data); + if (tagl && data.length < tagl) + throw new Error('invalid ciphertext length: smaller than tagLength=' + tagl); + checkOutput(cipher.decrypt.length, output); + return cipher.decrypt(data, output); + }, + }; + return wrCipher; + } + Object.assign(wrappedCipher, params); + return wrappedCipher; +}; +/** + * By default, returns u8a of length. + * When out is available, it checks it for validity and uses it. + */ +export function getOutput(expectedLength, out, onlyAligned = true) { + if (out === undefined) + return new Uint8Array(expectedLength); + if (out.length !== expectedLength) + throw new Error('invalid output length, expected ' + expectedLength + ', got: ' + out.length); + if (onlyAligned && !isAligned32(out)) + throw new Error('invalid output, must be aligned'); + return out; +} +/** Polyfill for Safari 14. */ +export function setBigUint64(view, byteOffset, value, isLE) { + if (typeof view.setBigUint64 === 'function') + return view.setBigUint64(byteOffset, value, isLE); + const _32n = BigInt(32); + const _u32_max = BigInt(0xffffffff); + const wh = Number((value >> _32n) & _u32_max); + const wl = Number(value & _u32_max); + const h = isLE ? 4 : 0; + const l = isLE ? 0 : 4; + view.setUint32(byteOffset + h, wh, isLE); + view.setUint32(byteOffset + l, wl, isLE); +} +export function u64Lengths(dataLength, aadLength, isLE) { + abool(isLE); + const num = new Uint8Array(16); + const view = createView(num); + setBigUint64(view, 0, BigInt(aadLength), isLE); + setBigUint64(view, 8, BigInt(dataLength), isLE); + return num; +} +// Is byte array aligned to 4 byte offset (u32)? +export function isAligned32(bytes) { + return bytes.byteOffset % 4 === 0; +} +// copy bytes to new u8a (aligned). Because Buffer.slice is broken. +export function copyBytes(bytes) { + return Uint8Array.from(bytes); +} +//# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/utils.js.map b/node_modules/@noble/ciphers/esm/utils.js.map new file mode 100644 index 0000000000000000000000000000000000000000..9ca248d51a9b8df0fd9122129daf4f83de9edd1f --- /dev/null +++ b/node_modules/@noble/ciphers/esm/utils.js.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,uEAAuE;AAEvE,qFAAqF;AACrF,MAAM,UAAU,OAAO,CAAC,CAAU;IAChC,OAAO,CAAC,YAAY,UAAU,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC;AACnG,CAAC;AAED,oCAAoC;AACpC,MAAM,UAAU,KAAK,CAAC,CAAU;IAC9B,IAAI,OAAO,CAAC,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,EAAE,CAAC,CAAC;AAC5E,CAAC;AAED,6CAA6C;AAC7C,MAAM,UAAU,OAAO,CAAC,CAAS;IAC/B,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,GAAG,CAAC,CAAC,CAAC;AAChG,CAAC;AAED,uCAAuC;AACvC,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AAU,WAAW,CAAC,KAAiB;IAC3C,OAAO,KAAK,CAAC,UAAU,GAAG,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,SAAS,CAAC,KAAiB;IACzC,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/webcrypto.d.ts b/node_modules/@noble/ciphers/esm/webcrypto.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e79d0e4a6bd8a82e8ad27b5ac240fc3db960b4b1 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/webcrypto.d.ts @@ -0,0 +1,31 @@ +import { type AsyncCipher, type Cipher } from './utils.ts'; +/** + * Secure PRNG. Uses `crypto.getRandomValues`, which defers to OS. + */ +export declare function randomBytes(bytesLength?: number): Uint8Array; +export declare function getWebcryptoSubtle(): any; +type RemoveNonceInner = ((...args: T) => Ret) extends (arg0: any, arg1: any, ...rest: infer R) => any ? (key: Uint8Array, ...args: R) => Ret : never; +type RemoveNonce any> = RemoveNonceInner, ReturnType>; +type CipherWithNonce = ((key: Uint8Array, nonce: Uint8Array, ...args: any[]) => Cipher) & { + nonceLength: number; +}; +/** + * Uses CSPRG for nonce, nonce injected in ciphertext. + * @example + * const gcm = managedNonce(aes.gcm); + * const ciphr = gcm(key).encrypt(data); + * const plain = gcm(key).decrypt(ciph); + */ +export declare function managedNonce(fn: T): RemoveNonce; +export declare const utils: { + encrypt: (key: Uint8Array, ...all: any[]) => Promise; + decrypt: (key: Uint8Array, ...all: any[]) => Promise; +}; +/** AES-CBC, native webcrypto version */ +export declare const cbc: (key: Uint8Array, iv: Uint8Array) => AsyncCipher; +/** AES-CTR, native webcrypto version */ +export declare const ctr: (key: Uint8Array, nonce: Uint8Array) => AsyncCipher; +/** AES-GCM, native webcrypto version */ +export declare const gcm: (key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => AsyncCipher; +export {}; +//# sourceMappingURL=webcrypto.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/webcrypto.d.ts.map b/node_modules/@noble/ciphers/esm/webcrypto.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..9b5b9cef0f07a8d4ed2779d3c13ee2a7704865b7 --- /dev/null +++ b/node_modules/@noble/ciphers/esm/webcrypto.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"webcrypto.d.ts","sourceRoot":"","sources":["../src/webcrypto.ts"],"names":[],"mappings":"AAYA,OAAO,EAAmB,KAAK,WAAW,EAAE,KAAK,MAAM,EAAe,MAAM,YAAY,CAAC;AAEzF;;GAEG;AACH,wBAAgB,WAAW,CAAC,WAAW,SAAK,GAAG,UAAU,CASxD;AAED,wBAAgB,kBAAkB,IAAI,GAAG,CAGxC;AAED,KAAK,gBAAgB,CAAC,CAAC,SAAS,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,GAAG,CAAC,SAAS,CAC1E,IAAI,EAAE,GAAG,EACT,IAAI,EAAE,GAAG,EACT,GAAG,IAAI,EAAE,MAAM,CAAC,KACb,GAAG,GACJ,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,CAAC,KAAK,GAAG,GACpC,KAAK,CAAC;AAEV,KAAK,WAAW,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,IAAI,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AACnG,KAAK,eAAe,GAAG,CAAC,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,MAAM,CAAC,GAAG;IACxF,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,eAAe,EAAE,EAAE,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAiB7E;AAID,eAAO,MAAM,KAAK,EAAE;IAClB,OAAO,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,GAAG,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IACjE,OAAO,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,GAAG,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;CAwBlE,CAAC;AA2CF,wCAAwC;AACxC,eAAO,MAAM,GAAG,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU,KAAK,WAChC,CAAC;AACxB,wCAAwC;AACxC,eAAO,MAAM,GAAG,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,KAAK,WACnC,CAAC;AACxB,wCAAwC;AACxC,eAAO,MAAM,GAAG,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,CAAC,EAAE,UAAU,KAAK,WAC9B,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/webcrypto.js b/node_modules/@noble/ciphers/esm/webcrypto.js new file mode 100644 index 0000000000000000000000000000000000000000..24ff38bc17d76e762d6eb345c6198b64bc8a385e --- /dev/null +++ b/node_modules/@noble/ciphers/esm/webcrypto.js @@ -0,0 +1,135 @@ +/** + * WebCrypto-based AES gcm/ctr/cbc, `managedNonce` and `randomBytes`. + * We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+. + * node.js versions earlier than v19 don't declare it in global scope. + * For node.js, package.js on#exports field mapping rewrites import + * from `crypto` to `cryptoNode`, which imports native module. + * Makes the utils un-importable in browsers without a bundler. + * Once node.js 18 is deprecated, we can just drop the import. + * @module + */ +// Use full path so that Node.js can rewrite it to `cryptoNode.js`. +import { crypto } from '@noble/ciphers/crypto'; +import { abytes, anumber, concatBytes } from "./utils.js"; +/** + * Secure PRNG. Uses `crypto.getRandomValues`, which defers to OS. + */ +export function randomBytes(bytesLength = 32) { + if (crypto && typeof crypto.getRandomValues === 'function') { + return crypto.getRandomValues(new Uint8Array(bytesLength)); + } + // Legacy Node.js compatibility + if (crypto && typeof crypto.randomBytes === 'function') { + return Uint8Array.from(crypto.randomBytes(bytesLength)); + } + throw new Error('crypto.getRandomValues must be defined'); +} +export function getWebcryptoSubtle() { + if (crypto && typeof crypto.subtle === 'object' && crypto.subtle != null) + return crypto.subtle; + throw new Error('crypto.subtle must be defined'); +} +/** + * Uses CSPRG for nonce, nonce injected in ciphertext. + * @example + * const gcm = managedNonce(aes.gcm); + * const ciphr = gcm(key).encrypt(data); + * const plain = gcm(key).decrypt(ciph); + */ +export function managedNonce(fn) { + const { nonceLength } = fn; + anumber(nonceLength); + return ((key, ...args) => ({ + encrypt(plaintext, ...argsEnc) { + const nonce = randomBytes(nonceLength); + const ciphertext = fn(key, nonce, ...args).encrypt(plaintext, ...argsEnc); + const out = concatBytes(nonce, ciphertext); + ciphertext.fill(0); + return out; + }, + decrypt(ciphertext, ...argsDec) { + const nonce = ciphertext.subarray(0, nonceLength); + const data = ciphertext.subarray(nonceLength); + return fn(key, nonce, ...args).decrypt(data, ...argsDec); + }, + })); +} +// Overridable +// @TODO +export const utils = { + async encrypt(key, keyParams, cryptParams, plaintext) { + const cr = getWebcryptoSubtle(); + const iKey = await cr.importKey('raw', key, keyParams, true, ['encrypt']); + const ciphertext = await cr.encrypt(cryptParams, iKey, plaintext); + return new Uint8Array(ciphertext); + }, + async decrypt(key, keyParams, cryptParams, ciphertext) { + const cr = getWebcryptoSubtle(); + const iKey = await cr.importKey('raw', key, keyParams, true, ['decrypt']); + const plaintext = await cr.decrypt(cryptParams, iKey, ciphertext); + return new Uint8Array(plaintext); + }, +}; +const mode = { + CBC: 'AES-CBC', + CTR: 'AES-CTR', + GCM: 'AES-GCM', +}; +function getCryptParams(algo, nonce, AAD) { + if (algo === mode.CBC) + return { name: mode.CBC, iv: nonce }; + if (algo === mode.CTR) + return { name: mode.CTR, counter: nonce, length: 64 }; + if (algo === mode.GCM) { + if (AAD) + return { name: mode.GCM, iv: nonce, additionalData: AAD }; + else + return { name: mode.GCM, iv: nonce }; + } + throw new Error('unknown aes block mode'); +} +function generate(algo) { + return (key, nonce, AAD) => { + abytes(key); + abytes(nonce); + const keyParams = { name: algo, length: key.length * 8 }; + const cryptParams = getCryptParams(algo, nonce, AAD); + let consumed = false; + return { + // keyLength, + encrypt(plaintext) { + abytes(plaintext); + if (consumed) + throw new Error('Cannot encrypt() twice with same key / nonce'); + consumed = true; + return utils.encrypt(key, keyParams, cryptParams, plaintext); + }, + decrypt(ciphertext) { + abytes(ciphertext); + return utils.decrypt(key, keyParams, cryptParams, ciphertext); + }, + }; + }; +} +/** AES-CBC, native webcrypto version */ +export const cbc = /* @__PURE__ */ (() => generate(mode.CBC))(); +/** AES-CTR, native webcrypto version */ +export const ctr = /* @__PURE__ */ (() => generate(mode.CTR))(); +/** AES-GCM, native webcrypto version */ +export const gcm = +/* @__PURE__ */ (() => generate(mode.GCM))(); +// // Type tests +// import { siv, gcm, ctr, ecb, cbc } from '../aes.ts'; +// import { xsalsa20poly1305 } from '../salsa.ts'; +// import { chacha20poly1305, xchacha20poly1305 } from '../chacha.ts'; +// const wsiv = managedNonce(siv); +// const wgcm = managedNonce(gcm); +// const wctr = managedNonce(ctr); +// const wcbc = managedNonce(cbc); +// const wsalsapoly = managedNonce(xsalsa20poly1305); +// const wchacha = managedNonce(chacha20poly1305); +// const wxchacha = managedNonce(xchacha20poly1305); +// // should fail +// const wcbc2 = managedNonce(managedNonce(cbc)); +// const wctr = managedNonce(ctr); +//# sourceMappingURL=webcrypto.js.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/esm/webcrypto.js.map b/node_modules/@noble/ciphers/esm/webcrypto.js.map new file mode 100644 index 0000000000000000000000000000000000000000..2af135d35dde5921736aa84328f795ab8e8d0022 --- /dev/null +++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AChB,uDAAuD;AACvD,kDAAkD;AAClD,sEAAsE;AAEtE,kCAAkC;AAClC,kCAAkC;AAClC,kCAAkC;AAClC,kCAAkC;AAClC,qDAAqD;AACrD,kDAAkD;AAClD,oDAAoD;AAEpD,iBAAiB;AACjB,iDAAiD;AACjD,kCAAkC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/ff1.d.ts b/node_modules/@noble/ciphers/ff1.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..00e1a60d50515bf683650c0b5cce278c6d6d2d0e --- /dev/null +++ b/node_modules/@noble/ciphers/ff1.d.ts @@ -0,0 +1,9 @@ +import { type Cipher } from './utils.ts'; +/** FPE-FF1 format-preserving encryption */ +export declare function FF1(radix: number, key: Uint8Array, tweak?: Uint8Array): { + encrypt(x: number[]): number[]; + decrypt(x: number[]): number[]; +}; +/** Binary version of FPE-FF1 format-preserving encryption. */ +export declare function BinaryFF1(key: Uint8Array, tweak?: Uint8Array): Cipher; +//# sourceMappingURL=ff1.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/ff1.d.ts.map b/node_modules/@noble/ciphers/ff1.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..421d857a41a06322172f2b4f96c0a4c6bf24dede --- /dev/null +++ b/node_modules/@noble/ciphers/ff1.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ff1.d.ts","sourceRoot":"","sources":["src/ff1.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,MAAM,EAA4D,MAAM,YAAY,CAAC;AA0FnG,2CAA2C;AAC3C,wBAAgB,GAAG,CACjB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,UAAU,EACf,KAAK,GAAE,UAAsB,GAC5B;IAAE,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IAAC,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAA;CAAE,CAgCpE;AAqBD,8DAA8D;AAC9D,wBAAgB,SAAS,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,GAAE,UAAsB,GAAG,MAAM,CAMhF"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/ff1.js b/node_modules/@noble/ciphers/ff1.js new file mode 100644 index 0000000000000000000000000000000000000000..1f0d5798c0cbc26bc989f2740bfa26ce0b15ba03 --- /dev/null +++ b/node_modules/@noble/ciphers/ff1.js @@ -0,0 +1,164 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.FF1 = FF1; +exports.BinaryFF1 = BinaryFF1; +/** + * FPE-FF1 (Format-preserving encryption algorithm) specified in + * [NIST 800-38G](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38G.pdf). + * @module + */ +const aes_ts_1 = require("./aes.js"); +const utils_ts_1 = require("./utils.js"); +// NOTE: no point in inlining encrypt instead of encryptBlock, since BigInt stuff will be slow +const { expandKeyLE, encryptBlock } = aes_ts_1.unsafe; +// Format-preserving encryption algorithm (FPE-FF1) specified in NIST Special Publication 800-38G. +// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38G.pdf +const BLOCK_LEN = 16; +function mod(a, b) { + const result = a % b; + return result >= 0 ? result : b + result; +} +function NUMradix(radix, data) { + let res = BigInt(0); + for (let i of data) + res = res * BigInt(radix) + BigInt(i); + return res; +} +function getRound(radix, key, tweak, x) { + if (radix > 2 ** 16 - 1) + throw new Error('invalid radix ' + radix); + // radix**minlen ≥ 100 + const minLen = Math.ceil(Math.log(100) / Math.log(radix)); + const maxLen = 2 ** 32 - 1; + // 2 ≤ minlen ≤ maxlen < 2**32 + if (2 > minLen || minLen > maxLen || maxLen >= 2 ** 32) + throw new Error('Invalid radix: 2 ≤ minlen ≤ maxlen < 2**32'); + if (!Array.isArray(x)) + throw new Error('invalid X'); + if (x.length < minLen || x.length > maxLen) + throw new Error('X is outside minLen..maxLen bounds'); + const u = Math.floor(x.length / 2); + const v = x.length - u; + const b = Math.ceil(Math.ceil(v * Math.log2(radix)) / 8); + const d = 4 * Math.ceil(b / 4) + 4; + const padding = mod(-tweak.length - b - 1, 16); + // P = [1]1 || [2]1 || [1]1 || [radix]3 || [10]1 || [u mod 256]1 || [n]4 || [t]4. + const P = Uint8Array.from([1, 2, 1, 0, 0, 0, 10, u, 0, 0, 0, 0, 0, 0, 0, 0]); + const view = new DataView(P.buffer); + view.setUint16(4, radix, false); + view.setUint32(8, x.length, false); + view.setUint32(12, tweak.length, false); + // Q = T || [0](−t−b−1) mod 16 || [i]1 || [NUMradix(B)]b. + const PQ = new Uint8Array(P.length + tweak.length + padding + 1 + b); + PQ.set(P); + (0, utils_ts_1.clean)(P); + PQ.set(tweak, P.length); + const xk = expandKeyLE(key); + const round = (A, B, i, decrypt = false) => { + // Q = ... || [i]1 || [NUMradix(B)]b. + PQ[PQ.length - b - 1] = i; + if (b) + PQ.set((0, utils_ts_1.numberToBytesBE)(NUMradix(radix, B), b), PQ.length - b); + // PRF + let r = new Uint8Array(16); + for (let j = 0; j < PQ.length / BLOCK_LEN; j++) { + for (let i = 0; i < BLOCK_LEN; i++) + r[i] ^= PQ[j * BLOCK_LEN + i]; + encryptBlock(xk, r); + } + // Let S be the first d bytes of the following string of ⎡d/16⎤ blocks: + // R || CIPHK(R ⊕[1]16) || CIPHK(R ⊕[2]16) ...CIPHK(R ⊕[⎡d / 16⎤ – 1]16). + let s = Array.from(r); + for (let j = 1; s.length < d; j++) { + const block = (0, utils_ts_1.numberToBytesBE)(BigInt(j), 16); + for (let k = 0; k < BLOCK_LEN; k++) + block[k] ^= r[k]; + s.push(...Array.from(encryptBlock(xk, block))); + } + let y = (0, utils_ts_1.bytesToNumberBE)(Uint8Array.from(s.slice(0, d))); + s.fill(0); + if (decrypt) + y = -y; + const m = i % 2 === 0 ? u : v; + let c = mod(NUMradix(radix, A) + y, BigInt(radix) ** BigInt(m)); + // STR(radix, m, c) + const C = Array(m).fill(0); + for (let i = 0; i < m; i++, c /= BigInt(radix)) + C[m - 1 - i] = Number(c % BigInt(radix)); + A.fill(0); + A = B; + B = C; + return [A, B]; + }; + const destroy = () => { + (0, utils_ts_1.clean)(xk, PQ); + }; + return { u, round, destroy }; +} +const EMPTY_BUF = /* @__PURE__ */ Uint8Array.of(); +/** FPE-FF1 format-preserving encryption */ +function FF1(radix, key, tweak = EMPTY_BUF) { + (0, utils_ts_1.anumber)(radix); + (0, utils_ts_1.abytes)(key); + (0, utils_ts_1.abytes)(tweak); + const PQ = getRound.bind(null, radix, key, tweak); + return { + encrypt(x) { + const { u, round, destroy } = PQ(x); + let [A, B] = [x.slice(0, u), x.slice(u)]; + for (let i = 0; i < 10; i++) + [A, B] = round(A, B, i); + destroy(); + const res = A.concat(B); + A.fill(0); + B.fill(0); + return res; + }, + decrypt(x) { + const { u, round, destroy } = PQ(x); + // The FF1.Decrypt algorithm is similar to the FF1.Encrypt algorithm; + // the differences are in Step 6, where: + // 1) the order of the indices is reversed, + // 2) the roles of A and B are swapped + // 3) modular addition is replaced by modular subtraction, in Step 6vi. + let [B, A] = [x.slice(0, u), x.slice(u)]; + for (let i = 9; i >= 0; i--) + [A, B] = round(A, B, i, true); + destroy(); + const res = B.concat(A); + A.fill(0); + B.fill(0); + return res; + }, + }; +} +// Binary string which encodes each byte in little-endian byte order +const binLE = { + encode(bytes) { + const x = []; + for (let i = 0; i < bytes.length; i++) { + for (let j = 0, tmp = bytes[i]; j < 8; j++, tmp >>= 1) + x.push(tmp & 1); + } + return x; + }, + decode(b) { + if (!Array.isArray(b) || b.length % 8) + throw new Error('Invalid binary string'); + const res = new Uint8Array(b.length / 8); + for (let i = 0, j = 0; i < res.length; i++) { + res[i] = b[j++] | (b[j++] << 1) | (b[j++] << 2) | (b[j++] << 3); + res[i] |= (b[j++] << 4) | (b[j++] << 5) | (b[j++] << 6) | (b[j++] << 7); + } + return res; + }, +}; +/** Binary version of FPE-FF1 format-preserving encryption. */ +function BinaryFF1(key, tweak = EMPTY_BUF) { + const ff1 = FF1(2, key, tweak); + return { + encrypt: (x) => binLE.decode(ff1.encrypt(binLE.encode(x))), + decrypt: (x) => binLE.decode(ff1.decrypt(binLE.encode(x))), + }; +} +//# sourceMappingURL=ff1.js.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/ff1.js.map b/node_modules/@noble/ciphers/ff1.js.map new file mode 100644 index 0000000000000000000000000000000000000000..b0c842b7940610c799d7f5acefd7dc428a953501 --- /dev/null +++ b/node_modules/@noble/ciphers/ff1.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ff1.js","sourceRoot":"","sources":["src/ff1.ts"],"names":[],"mappings":";;AAiGA,kBAoCC;AAsBD,8BAMC;AAjKD;;;;GAIG;AACH,qCAAkC;AAClC,yCAAmG;AAEnG,8FAA8F;AAC9F,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,eAAM,CAAC;AAE7C,kGAAkG;AAClG,4EAA4E;AAE5E,MAAM,SAAS,GAAG,EAAE,CAAC;AAKrB,SAAS,GAAG,CAAC,CAAM,EAAE,CAAM;IACzB,MAAM,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC;IACrB,OAAO,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;AAC3C,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa,EAAE,IAAc;IAC7C,IAAI,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACpB,KAAK,IAAI,CAAC,IAAI,IAAI;QAAE,GAAG,GAAG,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAC1D,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa,EAAE,GAAe,EAAE,KAAiB,EAAE,CAAW;IAC9E,IAAI,KAAK,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,C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AC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;YAChE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1E,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF,CAAC;AAEF,8DAA8D;AAC9D,SAAgB,SAAS,CAAC,GAAe,EAAE,QAAoB,SAAS;IACtE,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IAC/B,OAAO;QACL,OAAO,EAAE,CAAC,CAAa,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QACtE,OAAO,EAAE,CAAC,CAAa,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;KACvE,CAAC;AACJ,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/index.d.ts b/node_modules/@noble/ciphers/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f36479a733bbeb24edff9b891531da88194073b7 --- /dev/null +++ b/node_modules/@noble/ciphers/index.d.ts @@ -0,0 +1 @@ +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/index.d.ts.map b/node_modules/@noble/ciphers/index.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..4e8c5816b41ae88c764eefae33e5eb965d87148b --- /dev/null +++ b/node_modules/@noble/ciphers/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/index.js b/node_modules/@noble/ciphers/index.js new file mode 100644 index 0000000000000000000000000000000000000000..164152a14da6e19bb1fee08522276b78e5117e66 --- /dev/null +++ b/node_modules/@noble/ciphers/index.js @@ -0,0 +1,28 @@ +"use strict"; +/** + * Audited & minimal JS implementation of Salsa20, ChaCha and AES. Check out individual modules. + * @example +```js +import { gcm, siv } from '@noble/ciphers/aes'; +import { xsalsa20poly1305 } from '@noble/ciphers/salsa'; +import { secretbox } from '@noble/ciphers/salsa'; // == xsalsa20poly1305 +import { chacha20poly1305, xchacha20poly1305 } from '@noble/ciphers/chacha'; + +// Unauthenticated encryption: make sure to use HMAC or similar +import { ctr, cfb, cbc, ecb } from '@noble/ciphers/aes'; +import { salsa20, xsalsa20 } from '@noble/ciphers/salsa'; +import { chacha20, xchacha20, chacha8, chacha12 } from '@noble/ciphers/chacha'; + +// KW +import { aeskw, aeskwp } from '@noble/ciphers/aes'; + +// Utilities +import { bytesToHex, hexToBytes, bytesToUtf8, utf8ToBytes } from '@noble/ciphers/utils'; +import { managedNonce, randomBytes } from '@noble/ciphers/webcrypto'; +import { poly1305 } from '@noble/ciphers/_poly1305'; +import { ghash, polyval } from '@noble/ciphers/_polyval'; +``` + * @module + */ +throw new Error('root module cannot be imported: import submodules instead. Check out README'); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/index.js.map b/node_modules/@noble/ciphers/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..f3c3c726ef082ec213a86753f74a4b2a31959455 --- /dev/null +++ b/node_modules/@noble/ciphers/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,IAAI,KAAK,CAAC,6EAA6E,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/package.json b/node_modules/@noble/ciphers/package.json new file mode 100644 index 0000000000000000000000000000000000000000..8266948f915d61eda03f529c060f0085692de911 --- /dev/null +++ b/node_modules/@noble/ciphers/package.json @@ -0,0 +1,177 @@ +{ + "name": "@noble/ciphers", + "version": "1.3.0", + "description": "Audited & minimal JS implementation of Salsa20, ChaCha and AES", + "files": [ + "esm", + "src", + "*.js", + "*.js.map", + "*.d.ts", + "*.d.ts.map" + ], + "scripts": { + "bench": "node benchmark/noble.js", + "bench:compare": "node benchmark/compare.js", + "bench:install": "cd benchmark; npm install; npm install .. --install-links", + "build": "npm run build:clean; tsc && tsc -p tsconfig.cjs.json", + "build:release": "npx jsbt esbuild test/build", + "build:clean": "rm *.{js,d.ts,js.map,d.ts.map} esm/*.{js,d.ts,js.map,d.ts.map} 2> /dev/null", + "lint": "prettier --check 'src/**/*.{js,ts}' 'test/**/*.{js,ts,mjs}'", + "format": "prettier --write 'src/**/*.{js,ts}' 'test/**/*.{js,ts,mjs}'", + "test": "node --import ./test/esm-register.js test/index.js", + "test:bun": "bun test/index.js", + "test:deno": "deno --allow-env --allow-read --import-map=./test/import_map.json test/index.js", + "test:big": "node --import ./test/esm-register.js test/crosstest.test.js slow" + }, + "author": "Paul Miller (https://paulmillr.com)", + "homepage": "https://paulmillr.com/noble/", + "repository": { + "type": "git", + "url": "git+https://github.com/paulmillr/noble-ciphers.git" + }, + "license": "MIT", + "devDependencies": { + "@paulmillr/jsbt": "0.3.3", + "@scure/base": "1.2.5", + "fast-check": "3.0.0", + "micro-bmark": "0.4.1", + "micro-should": "0.5.2", + "prettier": "3.5.3", + "typescript": "5.8.3" + }, + "engines": { + "node": "^14.21.3 || >=16" + }, + "main": "index.js", + "exports": { + ".": { + "import": "./esm/index.js", + "require": "./index.js" + }, + "./_micro": { + "import": "./esm/_micro.js", + "require": "./_micro.js" + }, + "./_poly1305": { + "import": "./esm/_poly1305.js", + "require": "./_poly1305.js" + }, + "./_polyval": { + "import": "./esm/_polyval.js", + "require": "./_polyval.js" + }, + "./aes": { + "import": "./esm/aes.js", + "require": "./aes.js" + }, + "./chacha": { + "import": "./esm/chacha.js", + "require": "./chacha.js" + }, + "./crypto": { + "types": "./crypto.d.ts", + "node": { + "import": "./esm/cryptoNode.js", + "default": "./cryptoNode.js" + }, + "import": "./esm/crypto.js", + "default": "./crypto.js" + }, + "./ff1": { + "import": "./esm/ff1.js", + "require": "./ff1.js" + }, + "./index": { + "import": "./esm/index.js", + "require": "./index.js" + }, + "./salsa": { + "import": "./esm/salsa.js", + "require": "./salsa.js" + }, + "./utils": { + "import": "./esm/utils.js", + "require": "./utils.js" + }, + "./webcrypto": { + "import": "./esm/webcrypto.js", + "require": "./webcrypto.js" + }, + "./_micro.js": { + "import": "./esm/_micro.js", + "require": "./_micro.js" + }, + "./_poly1305.js": { + "import": "./esm/_poly1305.js", + "require": "./_poly1305.js" + }, + "./_polyval.js": { + "import": "./esm/_polyval.js", + "require": "./_polyval.js" + }, + "./aes.js": { + "import": "./esm/aes.js", + "require": "./aes.js" + }, + "./chacha.js": { + "import": "./esm/chacha.js", + "require": "./chacha.js" + }, + "./crypto.js": { + "types": "./crypto.d.ts", + "node": { + "import": "./esm/cryptoNode.js", + "default": "./cryptoNode.js" + }, + "import": "./esm/crypto.js", + "default": "./crypto.js" + }, + "./ff1.js": { + "import": "./esm/ff1.js", + "require": "./ff1.js" + }, + "./index.js": { + "import": "./esm/index.js", + "require": "./index.js" + }, + "./salsa.js": { + "import": "./esm/salsa.js", + "require": "./salsa.js" + }, + "./utils.js": { + "import": "./esm/utils.js", + "require": "./utils.js" + }, + "./webcrypto.js": { + "import": "./esm/webcrypto.js", + "require": "./webcrypto.js" + } + }, + "sideEffects": false, + "browser": { + "node:crypto": false, + "./crypto": "./crypto.js" + }, + "keywords": [ + "salsa20", + "chacha", + "aes", + "cryptography", + "crypto", + "noble", + "cipher", + "ciphers", + "xsalsa20", + "xchacha20", + "poly1305", + "xsalsa20poly1305", + "chacha20poly1305", + "xchacha20poly1305", + "secretbox", + "rijndael", + "siv", + "ff1" + ], + "funding": "https://paulmillr.com/funding/" +} diff --git a/node_modules/@noble/ciphers/salsa.d.ts b/node_modules/@noble/ciphers/salsa.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..dc5931c6878416bc1ac535784c6cd4ffbf441aee --- /dev/null +++ b/node_modules/@noble/ciphers/salsa.d.ts @@ -0,0 +1,33 @@ +import { type ARXCipher, type XorStream } from './utils.ts'; +/** + * hsalsa hashing function, used primarily in xsalsa, to hash + * key and nonce into key' and nonce'. + * Same as salsaCore, but there doesn't seem to be a way to move the block + * out without 25% performance hit. + */ +export declare function hsalsa(s: Uint32Array, k: Uint32Array, i: Uint32Array, o32: Uint32Array): void; +/** + * Salsa20 from original paper. + * Unsafe to use random nonces under the same key, due to collision chance. + * Prefer XSalsa instead. + */ +export declare const salsa20: XorStream; +/** + * xsalsa20 eXtended-nonce salsa. + * Can be safely used with random 24-byte nonces (CSPRNG). + */ +export declare const xsalsa20: XorStream; +/** + * xsalsa20-poly1305 eXtended-nonce salsa. + * Can be safely used with random 24-byte nonces (CSPRNG). + * Also known as secretbox from libsodium / nacl. + */ +export declare const xsalsa20poly1305: ARXCipher; +/** + * Alias to `xsalsa20poly1305`, for compatibility with libsodium / nacl + */ +export declare function secretbox(key: Uint8Array, nonce: Uint8Array): { + seal: (plaintext: Uint8Array, output?: Uint8Array) => Uint8Array; + open: (ciphertext: Uint8Array, output?: Uint8Array) => Uint8Array; +}; +//# sourceMappingURL=salsa.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/salsa.d.ts.map b/node_modules/@noble/ciphers/salsa.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..61c42f5d894fd9122b1cb04f1de3bfad1b31089e --- /dev/null +++ b/node_modules/@noble/ciphers/salsa.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"salsa.d.ts","sourceRoot":"","sources":["src/salsa.ts"],"names":[],"mappings":"AAiBA,OAAO,EAEL,KAAK,SAAS,EAMd,KAAK,SAAS,EACf,MAAM,YAAY,CAAC;AA+CpB;;;;;GAKG;AAEH,wBAAgB,MAAM,CACpB,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,EAAE,GAAG,EAAE,WAAW,GAC/D,IAAI,CA4BN;AAED;;;;GAIG;AACH,eAAO,MAAM,OAAO,EAAE,SAGpB,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,SAGrB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAsC9B,CAAC;AAEF;;GAEG;AACH,wBAAgB,SAAS,CACvB,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,UAAU,GAChB;IACD,IAAI,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,UAAU,KAAK,UAAU,CAAC;IACjE,IAAI,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,UAAU,KAAK,UAAU,CAAC;CACnE,CAGA"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/salsa.js b/node_modules/@noble/ciphers/salsa.js new file mode 100644 index 0000000000000000000000000000000000000000..df6048b314f3bc2b8e686576fa337c0de345381c --- /dev/null +++ b/node_modules/@noble/ciphers/salsa.js @@ -0,0 +1,206 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.xsalsa20poly1305 = exports.xsalsa20 = exports.salsa20 = void 0; +exports.hsalsa = hsalsa; +exports.secretbox = secretbox; +/** + * [Salsa20](https://cr.yp.to/snuffle.html) stream cipher, released in 2005. + * + * Salsa's goal was to implement AES replacement that does not rely on S-Boxes, + * which are hard to implement in a constant-time manner. + * Salsa20 is usually faster than AES, a big deal on slow, budget mobile phones. + * + * [XSalsa20](https://cr.yp.to/snuffle/xsalsa-20110204.pdf), extended-nonce + * variant was released in 2008. It switched nonces from 96-bit to 192-bit, + * and became safe to be picked at random. + * + * Check out [PDF](https://cr.yp.to/snuffle/salsafamily-20071225.pdf) and + * [wiki](https://en.wikipedia.org/wiki/Salsa20). + * @module + */ +const _arx_ts_1 = require("./_arx.js"); +const _poly1305_ts_1 = require("./_poly1305.js"); +const utils_ts_1 = require("./utils.js"); +/** Salsa20 core function. */ +// prettier-ignore +function salsaCore(s, k, n, out, cnt, rounds = 20) { + // Based on https://cr.yp.to/salsa20.html + let y00 = s[0], y01 = k[0], y02 = k[1], y03 = k[2], // "expa" Key Key Key + y04 = k[3], y05 = s[1], y06 = n[0], y07 = n[1], // Key "nd 3" Nonce Nonce + y08 = cnt, y09 = 0, y10 = s[2], y11 = k[4], // Pos. Pos. "2-by" Key + y12 = k[5], y13 = k[6], y14 = k[7], y15 = s[3]; // Key Key Key "te k" + // Save state to temporary variables + let x00 = y00, x01 = y01, x02 = y02, x03 = y03, x04 = y04, x05 = y05, x06 = y06, x07 = y07, x08 = y08, x09 = y09, x10 = y10, x11 = y11, x12 = y12, x13 = y13, x14 = y14, x15 = y15; + for (let r = 0; r < rounds; r += 2) { + x04 ^= (0, _arx_ts_1.rotl)(x00 + x12 | 0, 7); + x08 ^= (0, _arx_ts_1.rotl)(x04 + x00 | 0, 9); + x12 ^= (0, _arx_ts_1.rotl)(x08 + x04 | 0, 13); + x00 ^= (0, _arx_ts_1.rotl)(x12 + x08 | 0, 18); + x09 ^= (0, _arx_ts_1.rotl)(x05 + x01 | 0, 7); + x13 ^= (0, _arx_ts_1.rotl)(x09 + x05 | 0, 9); + x01 ^= (0, _arx_ts_1.rotl)(x13 + x09 | 0, 13); + x05 ^= (0, _arx_ts_1.rotl)(x01 + x13 | 0, 18); + x14 ^= (0, _arx_ts_1.rotl)(x10 + x06 | 0, 7); + x02 ^= (0, _arx_ts_1.rotl)(x14 + x10 | 0, 9); + x06 ^= (0, _arx_ts_1.rotl)(x02 + x14 | 0, 13); + x10 ^= (0, _arx_ts_1.rotl)(x06 + x02 | 0, 18); + x03 ^= (0, _arx_ts_1.rotl)(x15 + x11 | 0, 7); + x07 ^= (0, _arx_ts_1.rotl)(x03 + x15 | 0, 9); + x11 ^= (0, _arx_ts_1.rotl)(x07 + x03 | 0, 13); + x15 ^= (0, _arx_ts_1.rotl)(x11 + x07 | 0, 18); + x01 ^= (0, _arx_ts_1.rotl)(x00 + x03 | 0, 7); + x02 ^= (0, _arx_ts_1.rotl)(x01 + x00 | 0, 9); + x03 ^= (0, _arx_ts_1.rotl)(x02 + x01 | 0, 13); + x00 ^= (0, _arx_ts_1.rotl)(x03 + x02 | 0, 18); + x06 ^= (0, _arx_ts_1.rotl)(x05 + x04 | 0, 7); + x07 ^= (0, _arx_ts_1.rotl)(x06 + x05 | 0, 9); + x04 ^= (0, _arx_ts_1.rotl)(x07 + x06 | 0, 13); + x05 ^= (0, _arx_ts_1.rotl)(x04 + x07 | 0, 18); + x11 ^= (0, _arx_ts_1.rotl)(x10 + x09 | 0, 7); + x08 ^= (0, _arx_ts_1.rotl)(x11 + x10 | 0, 9); + x09 ^= (0, _arx_ts_1.rotl)(x08 + x11 | 0, 13); + x10 ^= (0, _arx_ts_1.rotl)(x09 + x08 | 0, 18); + x12 ^= (0, _arx_ts_1.rotl)(x15 + x14 | 0, 7); + x13 ^= (0, _arx_ts_1.rotl)(x12 + x15 | 0, 9); + x14 ^= (0, _arx_ts_1.rotl)(x13 + x12 | 0, 13); + x15 ^= (0, _arx_ts_1.rotl)(x14 + x13 | 0, 18); + } + // Write output + let oi = 0; + out[oi++] = (y00 + x00) | 0; + out[oi++] = (y01 + x01) | 0; + out[oi++] = (y02 + x02) | 0; + out[oi++] = (y03 + x03) | 0; + out[oi++] = (y04 + x04) | 0; + out[oi++] = (y05 + x05) | 0; + out[oi++] = (y06 + x06) | 0; + out[oi++] = (y07 + x07) | 0; + out[oi++] = (y08 + x08) | 0; + out[oi++] = (y09 + x09) | 0; + out[oi++] = (y10 + x10) | 0; + out[oi++] = (y11 + x11) | 0; + out[oi++] = (y12 + x12) | 0; + out[oi++] = (y13 + x13) | 0; + out[oi++] = (y14 + x14) | 0; + out[oi++] = (y15 + x15) | 0; +} +/** + * hsalsa hashing function, used primarily in xsalsa, to hash + * key and nonce into key' and nonce'. + * Same as salsaCore, but there doesn't seem to be a way to move the block + * out without 25% performance hit. + */ +// prettier-ignore +function hsalsa(s, k, i, o32) { + let x00 = s[0], x01 = k[0], x02 = k[1], x03 = k[2], x04 = k[3], x05 = s[1], x06 = i[0], x07 = i[1], x08 = i[2], x09 = i[3], x10 = s[2], x11 = k[4], x12 = k[5], x13 = k[6], x14 = k[7], x15 = s[3]; + for (let r = 0; r < 20; r += 2) { + x04 ^= (0, _arx_ts_1.rotl)(x00 + x12 | 0, 7); + x08 ^= (0, _arx_ts_1.rotl)(x04 + x00 | 0, 9); + x12 ^= (0, _arx_ts_1.rotl)(x08 + x04 | 0, 13); + x00 ^= (0, _arx_ts_1.rotl)(x12 + x08 | 0, 18); + x09 ^= (0, _arx_ts_1.rotl)(x05 + x01 | 0, 7); + x13 ^= (0, _arx_ts_1.rotl)(x09 + x05 | 0, 9); + x01 ^= (0, _arx_ts_1.rotl)(x13 + x09 | 0, 13); + x05 ^= (0, _arx_ts_1.rotl)(x01 + x13 | 0, 18); + x14 ^= (0, _arx_ts_1.rotl)(x10 + x06 | 0, 7); + x02 ^= (0, _arx_ts_1.rotl)(x14 + x10 | 0, 9); + x06 ^= (0, _arx_ts_1.rotl)(x02 + x14 | 0, 13); + x10 ^= (0, _arx_ts_1.rotl)(x06 + x02 | 0, 18); + x03 ^= (0, _arx_ts_1.rotl)(x15 + x11 | 0, 7); + x07 ^= (0, _arx_ts_1.rotl)(x03 + x15 | 0, 9); + x11 ^= (0, _arx_ts_1.rotl)(x07 + x03 | 0, 13); + x15 ^= (0, _arx_ts_1.rotl)(x11 + x07 | 0, 18); + x01 ^= (0, _arx_ts_1.rotl)(x00 + x03 | 0, 7); + x02 ^= (0, _arx_ts_1.rotl)(x01 + x00 | 0, 9); + x03 ^= (0, _arx_ts_1.rotl)(x02 + x01 | 0, 13); + x00 ^= (0, _arx_ts_1.rotl)(x03 + x02 | 0, 18); + x06 ^= (0, _arx_ts_1.rotl)(x05 + x04 | 0, 7); + x07 ^= (0, _arx_ts_1.rotl)(x06 + x05 | 0, 9); + x04 ^= (0, _arx_ts_1.rotl)(x07 + x06 | 0, 13); + x05 ^= (0, _arx_ts_1.rotl)(x04 + x07 | 0, 18); + x11 ^= (0, _arx_ts_1.rotl)(x10 + x09 | 0, 7); + x08 ^= (0, _arx_ts_1.rotl)(x11 + x10 | 0, 9); + x09 ^= (0, _arx_ts_1.rotl)(x08 + x11 | 0, 13); + x10 ^= (0, _arx_ts_1.rotl)(x09 + x08 | 0, 18); + x12 ^= (0, _arx_ts_1.rotl)(x15 + x14 | 0, 7); + x13 ^= (0, _arx_ts_1.rotl)(x12 + x15 | 0, 9); + x14 ^= (0, _arx_ts_1.rotl)(x13 + x12 | 0, 13); + x15 ^= (0, _arx_ts_1.rotl)(x14 + x13 | 0, 18); + } + let oi = 0; + o32[oi++] = x00; + o32[oi++] = x05; + o32[oi++] = x10; + o32[oi++] = x15; + o32[oi++] = x06; + o32[oi++] = x07; + o32[oi++] = x08; + o32[oi++] = x09; +} +/** + * Salsa20 from original paper. + * Unsafe to use random nonces under the same key, due to collision chance. + * Prefer XSalsa instead. + */ +exports.salsa20 = (0, _arx_ts_1.createCipher)(salsaCore, { + allowShortKeys: true, + counterRight: true, +}); +/** + * xsalsa20 eXtended-nonce salsa. + * Can be safely used with random 24-byte nonces (CSPRNG). + */ +exports.xsalsa20 = (0, _arx_ts_1.createCipher)(salsaCore, { + counterRight: true, + extendNonceFn: hsalsa, +}); +/** + * xsalsa20-poly1305 eXtended-nonce salsa. + * Can be safely used with random 24-byte nonces (CSPRNG). + * Also known as secretbox from libsodium / nacl. + */ +exports.xsalsa20poly1305 = (0, utils_ts_1.wrapCipher)({ blockSize: 64, nonceLength: 24, tagLength: 16 }, (key, nonce) => { + return { + encrypt(plaintext, output) { + // xsalsa20poly1305 optimizes by calculating auth key during the same call as encryption. + // Unfortunately, makes it hard to separate tag calculation & encryption itself, + // because 32 bytes is half-block of 64-byte salsa. + output = (0, utils_ts_1.getOutput)(plaintext.length + 32, output, false); // need 32 additional bytes, see above + const authKey = output.subarray(0, 32); // output[0..32] = poly1305 auth key + const ciphPlaintext = output.subarray(32); // output[32..] = plaintext, then ciphertext + output.set(plaintext, 32); + (0, utils_ts_1.clean)(authKey); // authKey is produced by xoring with zeros + (0, exports.xsalsa20)(key, nonce, output, output); // output = stream ^ output; authKey = stream ^ zeros(32) + const tag = (0, _poly1305_ts_1.poly1305)(ciphPlaintext, authKey); // calculate tag over ciphertext + output.set(tag, 16); // output[16..32] = tag + (0, utils_ts_1.clean)(output.subarray(0, 16), tag); // clean-up authKey remnants & copy of tag + return output.subarray(16); // return output[16..] + }, + decrypt(ciphertext, output) { + // tmp part passed tag ciphertext + // [0..32] [32..48] [48..] + (0, utils_ts_1.abytes)(ciphertext); + output = (0, utils_ts_1.getOutput)(ciphertext.length + 32, output, false); + const tmp = output.subarray(0, 32); // output[0..32] is used to calc authKey + const passedTag = output.subarray(32, 48); // output[32..48] = passed tag + const ciphPlaintext = output.subarray(48); // output[48..] = ciphertext, then plaintext + output.set(ciphertext, 32); // copy ciphertext into output + (0, utils_ts_1.clean)(tmp); // authKey is produced by xoring with zeros + const authKey = (0, exports.xsalsa20)(key, nonce, tmp, tmp); // authKey = stream ^ zeros(32) + const tag = (0, _poly1305_ts_1.poly1305)(ciphPlaintext, authKey); // calculate tag over ciphertext + if (!(0, utils_ts_1.equalBytes)(passedTag, tag)) + throw new Error('invalid tag'); + (0, exports.xsalsa20)(key, nonce, output.subarray(16), output.subarray(16)); // output = stream ^ output[16..] + (0, utils_ts_1.clean)(tmp, passedTag, tag); + return ciphPlaintext; // return output[48..], skipping zeroized output[0..48] + }, + }; +}); +/** + * Alias to `xsalsa20poly1305`, for compatibility with libsodium / nacl + */ +function secretbox(key, nonce) { + const xs = (0, exports.xsalsa20poly1305)(key, nonce); + return { seal: xs.encrypt, open: xs.decrypt }; +} +//# sourceMappingURL=salsa.js.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/salsa.js.map b/node_modules/@noble/ciphers/salsa.js.map new file mode 100644 index 0000000000000000000000000000000000000000..3aacd89abf56257e676fd760a6e5e0cdd899f286 --- /dev/null +++ b/node_modules/@noble/ciphers/salsa.js.map @@ -0,0 +1 @@ +{"version":3,"file":"salsa.js","sourceRoot":"","sources":["src/salsa.ts"],"names":[],"mappings":";;;AAgFA,wBA8BC;AAqED,8BASC;AA5LD;;;;;;;;;;;;;;GAcG;AACH,uCAA+C;AAC/C,iDAA0C;AAC1C,yCASoB;AAEpB,6BAA6B;AAC7B,kBAAkB;AAClB,SAAS,SAAS,CAChB,CAAc,EAAE,CAAc,EAAE,CAAc,EAAE,GAAgB,EAAE,GAAW,EAAE,MAAM,GAAG,EAAE;IAE1F,yCAAyC;IACzC,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,6BAA6B;IAC7E,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,+BAA+B;IAC/E,GAAG,GAAG,GAAG,EAAG,GAAG,GAAG,CAAC,EAAK,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,4BAA4B;IAC5E,GAAG,GAAG,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ble/ciphers/src/_arx.ts b/node_modules/@noble/ciphers/src/_arx.ts new file mode 100644 index 0000000000000000000000000000000000000000..79354bab9e787a4c4a040b55c7ccaaf84b81834f --- /dev/null +++ b/node_modules/@noble/ciphers/src/_arx.ts @@ -0,0 +1,224 @@ +/** + * Basic utils for ARX (add-rotate-xor) salsa and chacha ciphers. + +RFC8439 requires multi-step cipher stream, where +authKey starts with counter: 0, actual msg with counter: 1. + +For this, we need a way to re-use nonce / counter: + + const counter = new Uint8Array(4); + chacha(..., counter, ...); // counter is now 1 + chacha(..., counter, ...); // counter is now 2 + +This is complicated: + +- 32-bit counters are enough, no need for 64-bit: max ArrayBuffer size in JS is 4GB +- Original papers don't allow mutating counters +- Counter overflow is undefined [^1] +- Idea A: allow providing (nonce | counter) instead of just nonce, re-use it +- Caveat: Cannot be re-used through all cases: +- * chacha has (counter | nonce) +- * xchacha has (nonce16 | counter | nonce16) +- Idea B: separate nonce / counter and provide separate API for counter re-use +- Caveat: there are different counter sizes depending on an algorithm. +- salsa & chacha also differ in structures of key & sigma: + salsa20: s[0] | k(4) | s[1] | nonce(2) | ctr(2) | s[2] | k(4) | s[3] + chacha: s(4) | k(8) | ctr(1) | nonce(3) + chacha20orig: s(4) | k(8) | ctr(2) | nonce(2) +- Idea C: helper method such as `setSalsaState(key, nonce, sigma, data)` +- Caveat: we can't re-use counter array + +xchacha [^2] uses the subkey and remaining 8 byte nonce with ChaCha20 as normal +(prefixed by 4 NUL bytes, since [RFC8439] specifies a 12-byte nonce). + +[^1]: https://mailarchive.ietf.org/arch/msg/cfrg/gsOnTJzcbgG6OqD8Sc0GO5aR_tU/ +[^2]: https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha#appendix-A.2 + + * @module + */ +// prettier-ignore +import { + type XorStream, abool, abytes, anumber, checkOpts, clean, copyBytes, u32 +} from './utils.ts'; + +// We can't make top-level var depend on utils.utf8ToBytes +// because it's not present in all envs. Creating a similar fn here +const _utf8ToBytes = (str: string) => Uint8Array.from(str.split('').map((c) => c.charCodeAt(0))); +const sigma16 = _utf8ToBytes('expand 16-byte k'); +const sigma32 = _utf8ToBytes('expand 32-byte k'); +const sigma16_32 = u32(sigma16); +const sigma32_32 = u32(sigma32); + +export function rotl(a: number, b: number): number { + return (a << b) | (a >>> (32 - b)); +} + +/** Ciphers must use u32 for efficiency. */ +export type CipherCoreFn = ( + sigma: Uint32Array, + key: Uint32Array, + nonce: Uint32Array, + output: Uint32Array, + counter: number, + rounds?: number +) => void; + +/** Method which extends key + short nonce into larger nonce / diff key. */ +export type ExtendNonceFn = ( + sigma: Uint32Array, + key: Uint32Array, + input: Uint32Array, + output: Uint32Array +) => void; + +/** ARX cipher options. + * * `allowShortKeys` for 16-byte keys + * * `counterLength` in bytes + * * `counterRight`: right: `nonce|counter`; left: `counter|nonce` + * */ +export type CipherOpts = { + allowShortKeys?: boolean; // Original salsa / chacha allow 16-byte keys + extendNonceFn?: ExtendNonceFn; + counterLength?: number; + counterRight?: boolean; + rounds?: number; +}; + +// Is byte array aligned to 4 byte offset (u32)? +function isAligned32(b: Uint8Array) { + return b.byteOffset % 4 === 0; +} + +// Salsa and Chacha block length is always 512-bit +const BLOCK_LEN = 64; +const BLOCK_LEN32 = 16; + +// new Uint32Array([2**32]) // => Uint32Array(1) [ 0 ] +// new Uint32Array([2**32-1]) // => Uint32Array(1) [ 4294967295 ] +const MAX_COUNTER = 2 ** 32 - 1; + +const U32_EMPTY = new Uint32Array(); +function runCipher( + core: CipherCoreFn, + sigma: Uint32Array, + key: Uint32Array, + nonce: Uint32Array, + data: Uint8Array, + output: Uint8Array, + counter: number, + rounds: number +): void { + const len = data.length; + const block = new Uint8Array(BLOCK_LEN); + const b32 = u32(block); + // Make sure that buffers aligned to 4 bytes + const isAligned = isAligned32(data) && isAligned32(output); + const d32 = isAligned ? u32(data) : U32_EMPTY; + const o32 = isAligned ? u32(output) : U32_EMPTY; + for (let pos = 0; pos < len; counter++) { + core(sigma, key, nonce, b32, counter, rounds); + if (counter >= MAX_COUNTER) throw new Error('arx: counter overflow'); + const take = Math.min(BLOCK_LEN, len - pos); + // aligned to 4 bytes + if (isAligned && take === BLOCK_LEN) { + const pos32 = pos / 4; + if (pos % 4 !== 0) throw new Error('arx: invalid block position'); + for (let j = 0, posj: number; j < BLOCK_LEN32; j++) { + posj = pos32 + j; + o32[posj] = d32[posj] ^ b32[j]; + } + pos += BLOCK_LEN; + continue; + } + for (let j = 0, posj; j < take; j++) { + posj = pos + j; + output[posj] = data[posj] ^ block[j]; + } + pos += take; + } +} + +/** Creates ARX-like (ChaCha, Salsa) cipher stream from core function. */ +export function createCipher(core: CipherCoreFn, opts: CipherOpts): XorStream { + const { allowShortKeys, extendNonceFn, counterLength, counterRight, rounds } = checkOpts( + { allowShortKeys: false, counterLength: 8, counterRight: false, rounds: 20 }, + opts + ); + if (typeof core !== 'function') throw new Error('core must be a function'); + anumber(counterLength); + anumber(rounds); + abool(counterRight); + abool(allowShortKeys); + return ( + key: Uint8Array, + nonce: Uint8Array, + data: Uint8Array, + output?: Uint8Array, + counter = 0 + ): Uint8Array => { + abytes(key); + abytes(nonce); + abytes(data); + const len = data.length; + if (output === undefined) output = new Uint8Array(len); + abytes(output); + anumber(counter); + if (counter < 0 || counter >= MAX_COUNTER) throw new Error('arx: counter overflow'); + if (output.length < len) + throw new Error(`arx: output (${output.length}) is shorter than data (${len})`); + const toClean = []; + + // Key & sigma + // key=16 -> sigma16, k=key|key + // key=32 -> sigma32, k=key + let l = key.length; + let k: Uint8Array; + let sigma: Uint32Array; + if (l === 32) { + toClean.push((k = copyBytes(key))); + sigma = sigma32_32; + } else if (l === 16 && allowShortKeys) { + k = new Uint8Array(32); + k.set(key); + k.set(key, 16); + sigma = sigma16_32; + toClean.push(k); + } else { + throw new Error(`arx: invalid 32-byte key, got length=${l}`); + } + + // Nonce + // salsa20: 8 (8-byte counter) + // chacha20orig: 8 (8-byte counter) + // chacha20: 12 (4-byte counter) + // xsalsa20: 24 (16 -> hsalsa, 8 -> old nonce) + // xchacha20: 24 (16 -> hchacha, 8 -> old nonce) + // Align nonce to 4 bytes + if (!isAligned32(nonce)) toClean.push((nonce = copyBytes(nonce))); + + const k32 = u32(k); + // hsalsa & hchacha: handle extended nonce + if (extendNonceFn) { + if (nonce.length !== 24) throw new Error(`arx: extended nonce must be 24 bytes`); + extendNonceFn(sigma, k32, u32(nonce.subarray(0, 16)), k32); + nonce = nonce.subarray(16); + } + + // Handle nonce counter + const nonceNcLen = 16 - counterLength; + if (nonceNcLen !== nonce.length) + throw new Error(`arx: nonce must be ${nonceNcLen} or 16 bytes`); + + // Pad counter when nonce is 64 bit + if (nonceNcLen !== 12) { + const nc = new Uint8Array(12); + nc.set(nonce, counterRight ? 0 : 12 - nonce.length); + nonce = nc; + toClean.push(nonce); + } + const n32 = u32(nonce); + runCipher(core, sigma, k32, n32, data, output, counter, rounds); + clean(...toClean); + return output; + }; +} diff --git a/node_modules/@noble/ciphers/src/_assert.ts b/node_modules/@noble/ciphers/src/_assert.ts new file mode 100644 index 0000000000000000000000000000000000000000..cc0116782659224452f17576075f8ab797123b30 --- /dev/null +++ b/node_modules/@noble/ciphers/src/_assert.ts @@ -0,0 +1,25 @@ +/** + * Internal assertion helpers. + * @module + * @deprecated + */ +import { + abytes as ab, + abool as abool_, + aexists as ae, + anumber as an, + aoutput as ao, + type IHash as H, +} from './utils.ts'; +/** @deprecated Use import from `noble/hashes/utils` module */ +export const abool: typeof abool_ = abool_; +/** @deprecated Use import from `noble/hashes/utils` module */ +export const abytes: typeof ab = ab; +/** @deprecated Use import from `noble/hashes/utils` module */ +export const aexists: typeof ae = ae; +/** @deprecated Use import from `noble/hashes/utils` module */ +export const anumber: typeof an = an; +/** @deprecated Use import from `noble/hashes/utils` module */ +export const aoutput: typeof ao = ao; +/** @deprecated Use import from `noble/hashes/utils` module */ +export type Hash = H; diff --git a/node_modules/@noble/ciphers/src/_micro.ts b/node_modules/@noble/ciphers/src/_micro.ts new file mode 100644 index 0000000000000000000000000000000000000000..01e1dbb86ae4cbb467ad247a75984fcd4e806b09 --- /dev/null +++ b/node_modules/@noble/ciphers/src/_micro.ts @@ -0,0 +1,311 @@ +/** + * noble-ciphers-micro: more auditable, but 4x slower version of salsa20, chacha & poly1305. + * Implements the same algorithms that are present in other files, but without + * unrolled loops (https://en.wikipedia.org/wiki/Loop_unrolling). + * @module + */ +/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */ +// prettier-ignore +import { createCipher, rotl } from './_arx.ts'; +import { + type Cipher, + type XorStream, + abytes, + bytesToHex, + concatBytes, + equalBytes, + hexToNumber, + numberToBytesBE, + u64Lengths, + wrapCipher, +} from './utils.ts'; + +export type ARXCipherN = ((key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => Cipher) & { + blockSize: number; + nonceLength: number; + tagLength: number; +}; + +function bytesToNumberLE(bytes: Uint8Array): bigint { + abytes(bytes); + return hexToNumber(bytesToHex(Uint8Array.from(bytes).reverse())); +} + +function numberToBytesLE(n: number | bigint, len: number): Uint8Array { + return numberToBytesBE(n, len).reverse(); +} + +function salsaQR(x: Uint32Array, a: number, b: number, c: number, d: number) { + x[b] ^= rotl((x[a] + x[d]) | 0, 7); + x[c] ^= rotl((x[b] + x[a]) | 0, 9); + x[d] ^= rotl((x[c] + x[b]) | 0, 13); + x[a] ^= rotl((x[d] + x[c]) | 0, 18); +} +// prettier-ignore +function chachaQR(x: Uint32Array, a: number, b: number, c: number, d: number) { + x[a] = (x[a] + x[b]) | 0; x[d] = rotl(x[d] ^ x[a], 16); + x[c] = (x[c] + x[d]) | 0; x[b] = rotl(x[b] ^ x[c], 12); + x[a] = (x[a] + x[b]) | 0; x[d] = rotl(x[d] ^ x[a], 8); + x[c] = (x[c] + x[d]) | 0; x[b] = rotl(x[b] ^ x[c], 7); +} + +function salsaRound(x: Uint32Array, rounds = 20) { + for (let r = 0; r < rounds; r += 2) { + salsaQR(x, 0, 4, 8, 12); + salsaQR(x, 5, 9, 13, 1); + salsaQR(x, 10, 14, 2, 6); + salsaQR(x, 15, 3, 7, 11); + salsaQR(x, 0, 1, 2, 3); + salsaQR(x, 5, 6, 7, 4); + salsaQR(x, 10, 11, 8, 9); + salsaQR(x, 15, 12, 13, 14); + } +} + +function chachaRound(x: Uint32Array, rounds = 20) { + for (let r = 0; r < rounds; r += 2) { + chachaQR(x, 0, 4, 8, 12); + chachaQR(x, 1, 5, 9, 13); + chachaQR(x, 2, 6, 10, 14); + chachaQR(x, 3, 7, 11, 15); + chachaQR(x, 0, 5, 10, 15); + chachaQR(x, 1, 6, 11, 12); + chachaQR(x, 2, 7, 8, 13); + chachaQR(x, 3, 4, 9, 14); + } +} + +function salsaCore( + s: Uint32Array, + k: Uint32Array, + n: Uint32Array, + out: Uint32Array, + cnt: number, + rounds = 20 +): void { + // prettier-ignore + const y = new Uint32Array([ + s[0], k[0], k[1], k[2], // "expa" Key Key Key + k[3], s[1], n[0], n[1], // Key "nd 3" Nonce Nonce + cnt, 0, s[2], k[4], // Pos. Pos. "2-by" Key + k[5], k[6], k[7], s[3], // Key Key Key "te k" + ]); + const x = y.slice(); + salsaRound(x, rounds); + for (let i = 0; i < 16; i++) out[i] = (y[i] + x[i]) | 0; +} + +/** hsalsa hashes key and nonce into key' and nonce'. */ +// prettier-ignore +export function hsalsa(s: Uint32Array, k: Uint32Array, i: Uint32Array, o32: Uint32Array): void { + const x = new Uint32Array([ + s[0], k[0], k[1], k[2], + k[3], s[1], i[0], i[1], + i[2], i[3], s[2], k[4], + k[5], k[6], k[7], s[3] + ]); + salsaRound(x, 20); + let oi = 0; + o32[oi++] = x[0]; o32[oi++] = x[5]; + o32[oi++] = x[10]; o32[oi++] = x[15]; + o32[oi++] = x[6]; o32[oi++] = x[7]; + o32[oi++] = x[8]; o32[oi++] = x[9]; +} + +function chachaCore( + s: Uint32Array, + k: Uint32Array, + n: Uint32Array, + out: Uint32Array, + cnt: number, + rounds = 20 +): void { + // prettier-ignore + const y = new Uint32Array([ + s[0], s[1], s[2], s[3], // "expa" "nd 3" "2-by" "te k" + k[0], k[1], k[2], k[3], // Key Key Key Key + k[4], k[5], k[6], k[7], // Key Key Key Key + cnt, n[0], n[1], n[2], // Counter Counter Nonce Nonce + ]); + const x = y.slice(); + chachaRound(x, rounds); + for (let i = 0; i < 16; i++) out[i] = (y[i] + x[i]) | 0; +} + +/** hchacha hashes key and nonce into key' and nonce'. */ +// prettier-ignore +export function hchacha(s: Uint32Array, k: Uint32Array, i: Uint32Array, o32: Uint32Array): void { + const x = new Uint32Array([ + s[0], s[1], s[2], s[3], + k[0], k[1], k[2], k[3], + k[4], k[5], k[6], k[7], + i[0], i[1], i[2], i[3], + ]); + chachaRound(x, 20); + let oi = 0; + o32[oi++] = x[0]; o32[oi++] = x[1]; + o32[oi++] = x[2]; o32[oi++] = x[3]; + o32[oi++] = x[12]; o32[oi++] = x[13]; + o32[oi++] = x[14]; o32[oi++] = x[15]; +} + +/** salsa20, 12-byte nonce. */ +export const salsa20: XorStream = /* @__PURE__ */ createCipher(salsaCore, { + allowShortKeys: true, + counterRight: true, +}); + +/** xsalsa20, 24-byte nonce. */ +export const xsalsa20: XorStream = /* @__PURE__ */ createCipher(salsaCore, { + counterRight: true, + extendNonceFn: hsalsa, +}); + +/** chacha20 non-RFC, original version by djb. 8-byte nonce, 8-byte counter. */ +export const chacha20orig: XorStream = /* @__PURE__ */ createCipher(chachaCore, { + allowShortKeys: true, + counterRight: false, + counterLength: 8, +}); + +/** chacha20 RFC 8439 (IETF / TLS). 12-byte nonce, 4-byte counter. */ +export const chacha20: XorStream = /* @__PURE__ */ createCipher(chachaCore, { + counterRight: false, + counterLength: 4, +}); + +/** xchacha20 eXtended-nonce. https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha */ +export const xchacha20: XorStream = /* @__PURE__ */ createCipher(chachaCore, { + counterRight: false, + counterLength: 8, + extendNonceFn: hchacha, +}); + +/** 8-round chacha from the original paper. */ +export const chacha8: XorStream = /* @__PURE__ */ createCipher(chachaCore, { + counterRight: false, + counterLength: 4, + rounds: 8, +}); + +/** 12-round chacha from the original paper. */ +export const chacha12: XorStream = /* @__PURE__ */ createCipher(chachaCore, { + counterRight: false, + counterLength: 4, + rounds: 12, +}); + +const POW_2_130_5 = BigInt(2) ** BigInt(130) - BigInt(5); +const POW_2_128_1 = BigInt(2) ** BigInt(16 * 8) - BigInt(1); +const CLAMP_R = BigInt('0x0ffffffc0ffffffc0ffffffc0fffffff'); +const _0 = BigInt(0); +const _1 = BigInt(1); + +/** Poly1305 polynomial MAC. Can be speed-up using BigUint64Array, at the cost of complexity. */ +export function poly1305(msg: Uint8Array, key: Uint8Array): Uint8Array { + abytes(msg); + abytes(key, 32); + let acc = _0; + const r = bytesToNumberLE(key.subarray(0, 16)) & CLAMP_R; + const s = bytesToNumberLE(key.subarray(16)); + // Process by 16 byte chunks + for (let i = 0; i < msg.length; i += 16) { + const m = msg.subarray(i, i + 16); + const n = bytesToNumberLE(m) | (_1 << BigInt(8 * m.length)); + acc = ((acc + n) * r) % POW_2_130_5; + } + const res = (acc + s) & POW_2_128_1; + return numberToBytesLE(res, 16); +} + +function computeTag( + fn: XorStream, + key: Uint8Array, + nonce: Uint8Array, + ciphertext: Uint8Array, + AAD?: Uint8Array +): Uint8Array { + const res = []; + if (AAD) { + res.push(AAD); + const leftover = AAD.length % 16; + if (leftover > 0) res.push(new Uint8Array(16 - leftover)); + } + res.push(ciphertext); + const leftover = ciphertext.length % 16; + if (leftover > 0) res.push(new Uint8Array(16 - leftover)); + res.push(u64Lengths(ciphertext.length, AAD ? AAD.length : 0, true)); + const authKey = fn(key, nonce, new Uint8Array(32)); + return poly1305(concatBytes(...res), authKey); +} + +/** xsalsa20-poly1305 eXtended-nonce (24 bytes) salsa. */ +export const xsalsa20poly1305: ARXCipherN = /* @__PURE__ */ wrapCipher( + { blockSize: 64, nonceLength: 24, tagLength: 16 }, + function xsalsapoly(key: Uint8Array, nonce: Uint8Array) { + return { + encrypt(plaintext: Uint8Array) { + const m = concatBytes(new Uint8Array(32), plaintext); + const c = xsalsa20(key, nonce, m); + const authKey = c.subarray(0, 32); + const data = c.subarray(32); + const tag = poly1305(data, authKey); + return concatBytes(tag, data); + }, + decrypt(ciphertext: Uint8Array) { + const c = concatBytes(new Uint8Array(16), ciphertext); + const passedTag = c.subarray(16, 32); + const authKey = xsalsa20(key, nonce, new Uint8Array(32)); + const tag = poly1305(c.subarray(32), authKey); + if (!equalBytes(tag, passedTag)) throw new Error('invalid poly1305 tag'); + return xsalsa20(key, nonce, c).subarray(32); + }, + }; + } +); + +/** Alias to `xsalsa20poly1305`. */ +export function secretbox( + key: Uint8Array, + nonce: Uint8Array +): { + seal: (plaintext: Uint8Array) => Uint8Array; + open: (ciphertext: Uint8Array) => Uint8Array; +} { + const xs = xsalsa20poly1305(key, nonce); + return { seal: xs.encrypt, open: xs.decrypt }; +} + +export const _poly1305_aead = + (fn: XorStream) => + (key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array): Cipher => { + const tagLength = 16; + return { + encrypt(plaintext: Uint8Array) { + const data = fn(key, nonce, plaintext, undefined, 1); // stream from i=1 + const tag = computeTag(fn, key, nonce, data, AAD); + return concatBytes(data, tag); + }, + decrypt(ciphertext: Uint8Array) { + const passedTag = ciphertext.subarray(-tagLength); + const data = ciphertext.subarray(0, -tagLength); + const tag = computeTag(fn, key, nonce, data, AAD); + if (!equalBytes(tag, passedTag)) throw new Error('invalid poly1305 tag'); + return fn(key, nonce, data, undefined, 1); // stream from i=1 + }, + }; + }; + +/** chacha20-poly1305 12-byte-nonce chacha. */ +export const chacha20poly1305: ARXCipherN = /* @__PURE__ */ wrapCipher( + { blockSize: 64, nonceLength: 12, tagLength: 16 }, + _poly1305_aead(chacha20) +); + +/** + * XChaCha20-Poly1305 extended-nonce chacha. Can be safely used with random nonces (CSPRNG). + */ +export const xchacha20poly1305: ARXCipherN = /* @__PURE__ */ wrapCipher( + { blockSize: 64, nonceLength: 24, tagLength: 16 }, + _poly1305_aead(xchacha20) +); diff --git a/node_modules/@noble/ciphers/src/_poly1305.ts b/node_modules/@noble/ciphers/src/_poly1305.ts new file mode 100644 index 0000000000000000000000000000000000000000..110b4c32d411ac28d5b53fa64f3f2871617961ea --- /dev/null +++ b/node_modules/@noble/ciphers/src/_poly1305.ts @@ -0,0 +1,305 @@ +/** + * Poly1305 ([PDF](https://cr.yp.to/mac/poly1305-20050329.pdf), + * [wiki](https://en.wikipedia.org/wiki/Poly1305)) + * is a fast and parallel secret-key message-authentication code suitable for + * a wide variety of applications. It was standardized in + * [RFC 8439](https://datatracker.ietf.org/doc/html/rfc8439) and is now used in TLS 1.3. + * + * Polynomial MACs are not perfect for every situation: + * they lack Random Key Robustness: the MAC can be forged, and can't be used in PAKE schemes. + * See [invisible salamanders attack](https://keymaterial.net/2020/09/07/invisible-salamanders-in-aes-gcm-siv/). + * To combat invisible salamanders, `hash(key)` can be included in ciphertext, + * however, this would violate ciphertext indistinguishability: + * an attacker would know which key was used - so `HKDF(key, i)` + * could be used instead. + * + * Check out [original website](https://cr.yp.to/mac.html). + * @module + */ +import { Hash, type Input, abytes, aexists, aoutput, clean, toBytes } from './utils.ts'; + +// Based on Public Domain poly1305-donna https://github.com/floodyberry/poly1305-donna +const u8to16 = (a: Uint8Array, i: number) => (a[i++] & 0xff) | ((a[i++] & 0xff) << 8); +class Poly1305 implements Hash { + readonly blockLen = 16; + readonly outputLen = 16; + private buffer = new Uint8Array(16); + private r = new Uint16Array(10); + private h = new Uint16Array(10); + private pad = new Uint16Array(8); + private pos = 0; + protected finished = false; + + constructor(key: Input) { + key = toBytes(key); + abytes(key, 32); + const t0 = u8to16(key, 0); + const t1 = u8to16(key, 2); + const t2 = u8to16(key, 4); + const t3 = u8to16(key, 6); + const t4 = u8to16(key, 8); + const t5 = u8to16(key, 10); + const t6 = u8to16(key, 12); + const t7 = u8to16(key, 14); + + // https://github.com/floodyberry/poly1305-donna/blob/e6ad6e091d30d7f4ec2d4f978be1fcfcbce72781/poly1305-donna-16.h#L47 + this.r[0] = t0 & 0x1fff; + this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff; + this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03; + this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff; + this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff; + this.r[5] = (t4 >>> 1) & 0x1ffe; + this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff; + this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81; + this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff; + this.r[9] = (t7 >>> 5) & 0x007f; + for (let i = 0; i < 8; i++) this.pad[i] = u8to16(key, 16 + 2 * i); + } + + private process(data: Uint8Array, offset: number, isLast = false) { + const hibit = isLast ? 0 : 1 << 11; + const { h, r } = this; + const r0 = r[0]; + const r1 = r[1]; + const r2 = r[2]; + const r3 = r[3]; + const r4 = r[4]; + const r5 = r[5]; + const r6 = r[6]; + const r7 = r[7]; + const r8 = r[8]; + const r9 = r[9]; + + const t0 = u8to16(data, offset + 0); + const t1 = u8to16(data, offset + 2); + const t2 = u8to16(data, offset + 4); + const t3 = u8to16(data, offset + 6); + const t4 = u8to16(data, offset + 8); + const t5 = u8to16(data, offset + 10); + const t6 = u8to16(data, offset + 12); + const t7 = u8to16(data, offset + 14); + + let h0 = h[0] + (t0 & 0x1fff); + let h1 = h[1] + (((t0 >>> 13) | (t1 << 3)) & 0x1fff); + let h2 = h[2] + (((t1 >>> 10) | (t2 << 6)) & 0x1fff); + let h3 = h[3] + (((t2 >>> 7) | (t3 << 9)) & 0x1fff); + let h4 = h[4] + (((t3 >>> 4) | (t4 << 12)) & 0x1fff); + let h5 = h[5] + ((t4 >>> 1) & 0x1fff); + let h6 = h[6] + (((t4 >>> 14) | (t5 << 2)) & 0x1fff); + let h7 = h[7] + (((t5 >>> 11) | (t6 << 5)) & 0x1fff); + let h8 = h[8] + (((t6 >>> 8) | (t7 << 8)) & 0x1fff); + let h9 = h[9] + ((t7 >>> 5) | hibit); + + let c = 0; + + let d0 = c + h0 * r0 + h1 * (5 * r9) + h2 * (5 * r8) + h3 * (5 * r7) + h4 * (5 * r6); + c = d0 >>> 13; + d0 &= 0x1fff; + d0 += h5 * (5 * r5) + h6 * (5 * r4) + h7 * (5 * r3) + h8 * (5 * r2) + h9 * (5 * r1); + c += d0 >>> 13; + d0 &= 0x1fff; + + let d1 = c + h0 * r1 + h1 * r0 + h2 * (5 * r9) + h3 * (5 * r8) + h4 * (5 * r7); + c = d1 >>> 13; + d1 &= 0x1fff; + d1 += h5 * (5 * r6) + h6 * (5 * r5) + h7 * (5 * r4) + h8 * (5 * r3) + h9 * (5 * r2); + c += d1 >>> 13; + d1 &= 0x1fff; + + let d2 = c + h0 * r2 + h1 * r1 + h2 * r0 + h3 * (5 * r9) + h4 * (5 * r8); + c = d2 >>> 13; + d2 &= 0x1fff; + d2 += h5 * (5 * r7) + h6 * (5 * r6) + h7 * (5 * r5) + h8 * (5 * r4) + h9 * (5 * r3); + c += d2 >>> 13; + d2 &= 0x1fff; + + let d3 = c + h0 * r3 + h1 * r2 + h2 * r1 + h3 * r0 + h4 * (5 * r9); + c = d3 >>> 13; + d3 &= 0x1fff; + d3 += h5 * (5 * r8) + h6 * (5 * r7) + h7 * (5 * r6) + h8 * (5 * r5) + h9 * (5 * r4); + c += d3 >>> 13; + d3 &= 0x1fff; + + let d4 = c + h0 * r4 + h1 * r3 + h2 * r2 + h3 * r1 + h4 * r0; + c = d4 >>> 13; + d4 &= 0x1fff; + d4 += h5 * (5 * r9) + h6 * (5 * r8) + h7 * (5 * r7) + h8 * (5 * r6) + h9 * (5 * r5); + c += d4 >>> 13; + d4 &= 0x1fff; + + let d5 = c + h0 * r5 + h1 * r4 + h2 * r3 + h3 * r2 + h4 * r1; + c = d5 >>> 13; + d5 &= 0x1fff; + d5 += h5 * r0 + h6 * (5 * r9) + h7 * (5 * r8) + h8 * (5 * r7) + h9 * (5 * r6); + c += d5 >>> 13; + d5 &= 0x1fff; + + let d6 = c + h0 * r6 + h1 * r5 + h2 * r4 + h3 * r3 + h4 * r2; + c = d6 >>> 13; + d6 &= 0x1fff; + d6 += h5 * r1 + h6 * r0 + h7 * (5 * r9) + h8 * (5 * r8) + h9 * (5 * r7); + c += d6 >>> 13; + d6 &= 0x1fff; + + let d7 = c + h0 * r7 + h1 * r6 + h2 * r5 + h3 * r4 + h4 * r3; + c = d7 >>> 13; + d7 &= 0x1fff; + d7 += h5 * r2 + h6 * r1 + h7 * r0 + h8 * (5 * r9) + h9 * (5 * r8); + c += d7 >>> 13; + d7 &= 0x1fff; + + let d8 = c + h0 * r8 + h1 * r7 + h2 * r6 + h3 * r5 + h4 * r4; + c = d8 >>> 13; + d8 &= 0x1fff; + d8 += h5 * r3 + h6 * r2 + h7 * r1 + h8 * r0 + h9 * (5 * r9); + c += d8 >>> 13; + d8 &= 0x1fff; + + let d9 = c + h0 * r9 + h1 * r8 + h2 * r7 + h3 * r6 + h4 * r5; + c = d9 >>> 13; + d9 &= 0x1fff; + d9 += h5 * r4 + h6 * r3 + h7 * r2 + h8 * r1 + h9 * r0; + c += d9 >>> 13; + d9 &= 0x1fff; + + c = ((c << 2) + c) | 0; + c = (c + d0) | 0; + d0 = c & 0x1fff; + c = c >>> 13; + d1 += c; + + h[0] = d0; + h[1] = d1; + h[2] = d2; + h[3] = d3; + h[4] = d4; + h[5] = d5; + h[6] = d6; + h[7] = d7; + h[8] = d8; + h[9] = d9; + } + + private finalize() { + const { h, pad } = this; + const g = new Uint16Array(10); + let c = h[1] >>> 13; + h[1] &= 0x1fff; + for (let i = 2; i < 10; i++) { + h[i] += c; + c = h[i] >>> 13; + h[i] &= 0x1fff; + } + h[0] += c * 5; + c = h[0] >>> 13; + h[0] &= 0x1fff; + h[1] += c; + c = h[1] >>> 13; + h[1] &= 0x1fff; + h[2] += c; + + g[0] = h[0] + 5; + c = g[0] >>> 13; + g[0] &= 0x1fff; + for (let i = 1; i < 10; i++) { + g[i] = h[i] + c; + c = g[i] >>> 13; + g[i] &= 0x1fff; + } + g[9] -= 1 << 13; + + let mask = (c ^ 1) - 1; + for (let i = 0; i < 10; i++) g[i] &= mask; + mask = ~mask; + for (let i = 0; i < 10; i++) h[i] = (h[i] & mask) | g[i]; + h[0] = (h[0] | (h[1] << 13)) & 0xffff; + h[1] = ((h[1] >>> 3) | (h[2] << 10)) & 0xffff; + h[2] = ((h[2] >>> 6) | (h[3] << 7)) & 0xffff; + h[3] = ((h[3] >>> 9) | (h[4] << 4)) & 0xffff; + h[4] = ((h[4] >>> 12) | (h[5] << 1) | (h[6] << 14)) & 0xffff; + h[5] = ((h[6] >>> 2) | (h[7] << 11)) & 0xffff; + h[6] = ((h[7] >>> 5) | (h[8] << 8)) & 0xffff; + h[7] = ((h[8] >>> 8) | (h[9] << 5)) & 0xffff; + + let f = h[0] + pad[0]; + h[0] = f & 0xffff; + for (let i = 1; i < 8; i++) { + f = (((h[i] + pad[i]) | 0) + (f >>> 16)) | 0; + h[i] = f & 0xffff; + } + clean(g); + } + update(data: Input): this { + aexists(this); + data = toBytes(data); + abytes(data); + const { buffer, blockLen } = this; + const len = data.length; + + for (let pos = 0; pos < len; ) { + const take = Math.min(blockLen - this.pos, len - pos); + // Fast path: we have at least one block in input + if (take === blockLen) { + for (; blockLen <= len - pos; pos += blockLen) this.process(data, pos); + continue; + } + buffer.set(data.subarray(pos, pos + take), this.pos); + this.pos += take; + pos += take; + if (this.pos === blockLen) { + this.process(buffer, 0, false); + this.pos = 0; + } + } + return this; + } + destroy() { + clean(this.h, this.r, this.buffer, this.pad); + } + digestInto(out: Uint8Array) { + aexists(this); + aoutput(out, this); + this.finished = true; + const { buffer, h } = this; + let { pos } = this; + if (pos) { + buffer[pos++] = 1; + for (; pos < 16; pos++) buffer[pos] = 0; + this.process(buffer, 0, true); + } + this.finalize(); + let opos = 0; + for (let i = 0; i < 8; i++) { + out[opos++] = h[i] >>> 0; + out[opos++] = h[i] >>> 8; + } + return out; + } + digest(): Uint8Array { + const { buffer, outputLen } = this; + this.digestInto(buffer); + const res = buffer.slice(0, outputLen); + this.destroy(); + return res; + } +} + +export type CHash = ReturnType; +export function wrapConstructorWithKey>( + hashCons: (key: Input) => Hash +): { + (msg: Input, key: Input): Uint8Array; + outputLen: number; + blockLen: number; + create(key: Input): Hash; +} { + const hashC = (msg: Input, key: Input): Uint8Array => hashCons(key).update(toBytes(msg)).digest(); + const tmp = hashCons(new Uint8Array(32)); + hashC.outputLen = tmp.outputLen; + hashC.blockLen = tmp.blockLen; + hashC.create = (key: Input) => hashCons(key); + return hashC; +} + +/** Poly1305 MAC from RFC 8439. */ +export const poly1305: CHash = wrapConstructorWithKey((key) => new Poly1305(key)); diff --git a/node_modules/@noble/ciphers/src/_polyval.ts b/node_modules/@noble/ciphers/src/_polyval.ts new file mode 100644 index 0000000000000000000000000000000000000000..74774e9d6c1e6f82703dd26c9510c6b54b8c93cb --- /dev/null +++ b/node_modules/@noble/ciphers/src/_polyval.ts @@ -0,0 +1,267 @@ +/** + * GHash from AES-GCM and its little-endian "mirror image" Polyval from AES-SIV. + * + * Implemented in terms of GHash with conversion function for keys + * GCM GHASH from + * [NIST SP800-38d](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf), + * SIV from + * [RFC 8452](https://datatracker.ietf.org/doc/html/rfc8452). + * + * GHASH modulo: x^128 + x^7 + x^2 + x + 1 + * POLYVAL modulo: x^128 + x^127 + x^126 + x^121 + 1 + * + * @module + */ +// prettier-ignore +import { + abytes, aexists, aoutput, + clean, copyBytes, createView, Hash, type Input, toBytes, u32, +} from './utils.ts'; + +const BLOCK_SIZE = 16; +// TODO: rewrite +// temporary padding buffer +const ZEROS16 = /* @__PURE__ */ new Uint8Array(16); +const ZEROS32 = u32(ZEROS16); +const POLY = 0xe1; // v = 2*v % POLY + +// v = 2*v % POLY +// NOTE: because x + x = 0 (add/sub is same), mul2(x) != x+x +// We can multiply any number using montgomery ladder and this function (works as double, add is simple xor) +const mul2 = (s0: number, s1: number, s2: number, s3: number) => { + const hiBit = s3 & 1; + return { + s3: (s2 << 31) | (s3 >>> 1), + s2: (s1 << 31) | (s2 >>> 1), + s1: (s0 << 31) | (s1 >>> 1), + s0: (s0 >>> 1) ^ ((POLY << 24) & -(hiBit & 1)), // reduce % poly + }; +}; + +const swapLE = (n: number) => + (((n >>> 0) & 0xff) << 24) | + (((n >>> 8) & 0xff) << 16) | + (((n >>> 16) & 0xff) << 8) | + ((n >>> 24) & 0xff) | + 0; + +/** + * `mulX_POLYVAL(ByteReverse(H))` from spec + * @param k mutated in place + */ +export function _toGHASHKey(k: Uint8Array): Uint8Array { + k.reverse(); + const hiBit = k[15] & 1; + // k >>= 1 + let carry = 0; + for (let i = 0; i < k.length; i++) { + const t = k[i]; + k[i] = (t >>> 1) | carry; + carry = (t & 1) << 7; + } + k[0] ^= -hiBit & 0xe1; // if (hiBit) n ^= 0xe1000000000000000000000000000000; + return k; +} + +type Value = { s0: number; s1: number; s2: number; s3: number }; + +const estimateWindow = (bytes: number) => { + if (bytes > 64 * 1024) return 8; + if (bytes > 1024) return 4; + return 2; +}; + +class GHASH implements Hash { + readonly blockLen = BLOCK_SIZE; + readonly outputLen = BLOCK_SIZE; + protected s0 = 0; + protected s1 = 0; + protected s2 = 0; + protected s3 = 0; + protected finished = false; + protected t: Value[]; + private W: number; + private windowSize: number; + // We select bits per window adaptively based on expectedLength + constructor(key: Input, expectedLength?: number) { + key = toBytes(key); + abytes(key, 16); + const kView = createView(key); + let k0 = kView.getUint32(0, false); + let k1 = kView.getUint32(4, false); + let k2 = kView.getUint32(8, false); + let k3 = kView.getUint32(12, false); + // generate table of doubled keys (half of montgomery ladder) + const doubles: Value[] = []; + for (let i = 0; i < 128; i++) { + doubles.push({ s0: swapLE(k0), s1: swapLE(k1), s2: swapLE(k2), s3: swapLE(k3) }); + ({ s0: k0, s1: k1, s2: k2, s3: k3 } = mul2(k0, k1, k2, k3)); + } + const W = estimateWindow(expectedLength || 1024); + if (![1, 2, 4, 8].includes(W)) + throw new Error('ghash: invalid window size, expected 2, 4 or 8'); + this.W = W; + const bits = 128; // always 128 bits; + const windows = bits / W; + const windowSize = (this.windowSize = 2 ** W); + const items: Value[] = []; + // Create precompute table for window of W bits + for (let w = 0; w < windows; w++) { + // truth table: 00, 01, 10, 11 + for (let byte = 0; byte < windowSize; byte++) { + // prettier-ignore + let s0 = 0, s1 = 0, s2 = 0, s3 = 0; + for (let j = 0; j < W; j++) { + const bit = (byte >>> (W - j - 1)) & 1; + if (!bit) continue; + const { s0: d0, s1: d1, s2: d2, s3: d3 } = doubles[W * w + j]; + (s0 ^= d0), (s1 ^= d1), (s2 ^= d2), (s3 ^= d3); + } + items.push({ s0, s1, s2, s3 }); + } + } + this.t = items; + } + protected _updateBlock(s0: number, s1: number, s2: number, s3: number) { + (s0 ^= this.s0), (s1 ^= this.s1), (s2 ^= this.s2), (s3 ^= this.s3); + const { W, t, windowSize } = this; + // prettier-ignore + let o0 = 0, o1 = 0, o2 = 0, o3 = 0; + const mask = (1 << W) - 1; // 2**W will kill performance. + let w = 0; + for (const num of [s0, s1, s2, s3]) { + for (let bytePos = 0; bytePos < 4; bytePos++) { + const byte = (num >>> (8 * bytePos)) & 0xff; + for (let bitPos = 8 / W - 1; bitPos >= 0; bitPos--) { + const bit = (byte >>> (W * bitPos)) & mask; + const { s0: e0, s1: e1, s2: e2, s3: e3 } = t[w * windowSize + bit]; + (o0 ^= e0), (o1 ^= e1), (o2 ^= e2), (o3 ^= e3); + w += 1; + } + } + } + this.s0 = o0; + this.s1 = o1; + this.s2 = o2; + this.s3 = o3; + } + update(data: Input): this { + aexists(this); + data = toBytes(data); + abytes(data); + const b32 = u32(data); + const blocks = Math.floor(data.length / BLOCK_SIZE); + const left = data.length % BLOCK_SIZE; + for (let i = 0; i < blocks; i++) { + this._updateBlock(b32[i * 4 + 0], b32[i * 4 + 1], b32[i * 4 + 2], b32[i * 4 + 3]); + } + if (left) { + ZEROS16.set(data.subarray(blocks * BLOCK_SIZE)); + this._updateBlock(ZEROS32[0], ZEROS32[1], ZEROS32[2], ZEROS32[3]); + clean(ZEROS32); // clean tmp buffer + } + return this; + } + destroy() { + const { t } = this; + // clean precompute table + for (const elm of t) { + (elm.s0 = 0), (elm.s1 = 0), (elm.s2 = 0), (elm.s3 = 0); + } + } + digestInto(out: Uint8Array) { + aexists(this); + aoutput(out, this); + this.finished = true; + const { s0, s1, s2, s3 } = this; + const o32 = u32(out); + o32[0] = s0; + o32[1] = s1; + o32[2] = s2; + o32[3] = s3; + return out; + } + digest(): Uint8Array { + const res = new Uint8Array(BLOCK_SIZE); + this.digestInto(res); + this.destroy(); + return res; + } +} + +class Polyval extends GHASH { + constructor(key: Input, expectedLength?: number) { + key = toBytes(key); + abytes(key); + const ghKey = _toGHASHKey(copyBytes(key)); + super(ghKey, expectedLength); + clean(ghKey); + } + update(data: Input): this { + data = toBytes(data); + aexists(this); + const b32 = u32(data); + const left = data.length % BLOCK_SIZE; + const blocks = Math.floor(data.length / BLOCK_SIZE); + for (let i = 0; i < blocks; i++) { + this._updateBlock( + swapLE(b32[i * 4 + 3]), + swapLE(b32[i * 4 + 2]), + swapLE(b32[i * 4 + 1]), + swapLE(b32[i * 4 + 0]) + ); + } + if (left) { + ZEROS16.set(data.subarray(blocks * BLOCK_SIZE)); + this._updateBlock( + swapLE(ZEROS32[3]), + swapLE(ZEROS32[2]), + swapLE(ZEROS32[1]), + swapLE(ZEROS32[0]) + ); + clean(ZEROS32); + } + return this; + } + digestInto(out: Uint8Array) { + aexists(this); + aoutput(out, this); + this.finished = true; + // tmp ugly hack + const { s0, s1, s2, s3 } = this; + const o32 = u32(out); + o32[0] = s0; + o32[1] = s1; + o32[2] = s2; + o32[3] = s3; + return out.reverse(); + } +} + +export type CHashPV = ReturnType; +function wrapConstructorWithKey>( + hashCons: (key: Input, expectedLength?: number) => Hash +): { + (msg: Input, key: Input): Uint8Array; + outputLen: number; + blockLen: number; + create(key: Input, expectedLength?: number): Hash; +} { + const hashC = (msg: Input, key: Input): Uint8Array => + hashCons(key, msg.length).update(toBytes(msg)).digest(); + const tmp = hashCons(new Uint8Array(16), 0); + hashC.outputLen = tmp.outputLen; + hashC.blockLen = tmp.blockLen; + hashC.create = (key: Input, expectedLength?: number) => hashCons(key, expectedLength); + return hashC; +} + +/** GHash MAC for AES-GCM. */ +export const ghash: CHashPV = wrapConstructorWithKey( + (key, expectedLength) => new GHASH(key, expectedLength) +); + +/** Polyval MAC for AES-SIV. */ +export const polyval: CHashPV = wrapConstructorWithKey( + (key, expectedLength) => new Polyval(key, expectedLength) +); diff --git a/node_modules/@noble/ciphers/src/aes.ts b/node_modules/@noble/ciphers/src/aes.ts new file mode 100644 index 0000000000000000000000000000000000000000..ba89a24337dbaa863a1b3ab2bd1627bb9d214c5f --- /dev/null +++ b/node_modules/@noble/ciphers/src/aes.ts @@ -0,0 +1,1016 @@ +/** + * [AES](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard) + * a.k.a. Advanced Encryption Standard + * is a variant of Rijndael block cipher, standardized by NIST in 2001. + * We provide the fastest available pure JS implementation. + * + * Data is split into 128-bit blocks. Encrypted in 10/12/14 rounds (128/192/256 bits). In every round: + * 1. **S-box**, table substitution + * 2. **Shift rows**, cyclic shift left of all rows of data array + * 3. **Mix columns**, multiplying every column by fixed polynomial + * 4. **Add round key**, round_key xor i-th column of array + * + * Check out [FIPS-197](https://csrc.nist.gov/files/pubs/fips/197/final/docs/fips-197.pdf) + * and [original proposal](https://csrc.nist.gov/csrc/media/projects/cryptographic-standards-and-guidelines/documents/aes-development/rijndael-ammended.pdf) + * @module + */ +import { ghash, polyval } from './_polyval.ts'; +// prettier-ignore +import { + abytes, clean, complexOverlapBytes, concatBytes, + copyBytes, createView, equalBytes, getOutput, isAligned32, overlapBytes, + setBigUint64, u32, u64Lengths, u8, wrapCipher, + type Cipher, type CipherWithOutput, +} from './utils.ts'; + +const BLOCK_SIZE = 16; +const BLOCK_SIZE32 = 4; +const EMPTY_BLOCK = /* @__PURE__ */ new Uint8Array(BLOCK_SIZE); +const POLY = 0x11b; // 1 + x + x**3 + x**4 + x**8 + +// TODO: remove multiplication, binary ops only +function mul2(n: number) { + return (n << 1) ^ (POLY & -(n >> 7)); +} + +function mul(a: number, b: number) { + let res = 0; + for (; b > 0; b >>= 1) { + // Montgomery ladder + res ^= a & -(b & 1); // if (b&1) res ^=a (but const-time). + a = mul2(a); // a = 2*a + } + return res; +} + +// AES S-box is generated using finite field inversion, +// an affine transform, and xor of a constant 0x63. +const sbox = /* @__PURE__ */ (() => { + const t = new Uint8Array(256); + for (let i = 0, x = 1; i < 256; i++, x ^= mul2(x)) t[i] = x; + const box = new Uint8Array(256); + box[0] = 0x63; // first elm + for (let i = 0; i < 255; i++) { + let x = t[255 - i]; + x |= x << 8; + box[t[i]] = (x ^ (x >> 4) ^ (x >> 5) ^ (x >> 6) ^ (x >> 7) ^ 0x63) & 0xff; + } + clean(t); + return box; +})(); + +// Inverted S-box +const invSbox = /* @__PURE__ */ sbox.map((_, j) => sbox.indexOf(j)); + +// Rotate u32 by 8 +const rotr32_8 = (n: number) => (n << 24) | (n >>> 8); +const rotl32_8 = (n: number) => (n << 8) | (n >>> 24); +// The byte swap operation for uint32 (LE<->BE) +const byteSwap = (word: number) => + ((word << 24) & 0xff000000) | + ((word << 8) & 0xff0000) | + ((word >>> 8) & 0xff00) | + ((word >>> 24) & 0xff); + +// T-table is optimization suggested in 5.2 of original proposal (missed from FIPS-197). Changes: +// - LE instead of BE +// - bigger tables: T0 and T1 are merged into T01 table and T2 & T3 into T23; +// so index is u16, instead of u8. This speeds up things, unexpectedly +function genTtable(sbox: Uint8Array, fn: (n: number) => number) { + if (sbox.length !== 256) throw new Error('Wrong sbox length'); + const T0 = new Uint32Array(256).map((_, j) => fn(sbox[j])); + const T1 = T0.map(rotl32_8); + const T2 = T1.map(rotl32_8); + const T3 = T2.map(rotl32_8); + const T01 = new Uint32Array(256 * 256); + const T23 = new Uint32Array(256 * 256); + const sbox2 = new Uint16Array(256 * 256); + for (let i = 0; i < 256; i++) { + for (let j = 0; j < 256; j++) { + const idx = i * 256 + j; + T01[idx] = T0[i] ^ T1[j]; + T23[idx] = T2[i] ^ T3[j]; + sbox2[idx] = (sbox[i] << 8) | sbox[j]; + } + } + return { sbox, sbox2, T0, T1, T2, T3, T01, T23 }; +} + +const tableEncoding = /* @__PURE__ */ genTtable( + sbox, + (s: number) => (mul(s, 3) << 24) | (s << 16) | (s << 8) | mul(s, 2) +); +const tableDecoding = /* @__PURE__ */ genTtable( + invSbox, + (s) => (mul(s, 11) << 24) | (mul(s, 13) << 16) | (mul(s, 9) << 8) | mul(s, 14) +); + +const xPowers = /* @__PURE__ */ (() => { + const p = new Uint8Array(16); + for (let i = 0, x = 1; i < 16; i++, x = mul2(x)) p[i] = x; + return p; +})(); + +/** Key expansion used in CTR. */ +function expandKeyLE(key: Uint8Array): Uint32Array { + abytes(key); + const len = key.length; + if (![16, 24, 32].includes(len)) + throw new Error('aes: invalid key size, should be 16, 24 or 32, got ' + len); + const { sbox2 } = tableEncoding; + const toClean = []; + if (!isAligned32(key)) toClean.push((key = copyBytes(key))); + const k32 = u32(key); + const Nk = k32.length; + const subByte = (n: number) => applySbox(sbox2, n, n, n, n); + const xk = new Uint32Array(len + 28); // expanded key + xk.set(k32); + // 4.3.1 Key expansion + for (let i = Nk; i < xk.length; i++) { + let t = xk[i - 1]; + if (i % Nk === 0) t = subByte(rotr32_8(t)) ^ xPowers[i / Nk - 1]; + else if (Nk > 6 && i % Nk === 4) t = subByte(t); + xk[i] = xk[i - Nk] ^ t; + } + clean(...toClean); + return xk; +} + +function expandKeyDecLE(key: Uint8Array): Uint32Array { + const encKey = expandKeyLE(key); + const xk = encKey.slice(); + const Nk = encKey.length; + const { sbox2 } = tableEncoding; + const { T0, T1, T2, T3 } = tableDecoding; + // Inverse key by chunks of 4 (rounds) + for (let i = 0; i < Nk; i += 4) { + for (let j = 0; j < 4; j++) xk[i + j] = encKey[Nk - i - 4 + j]; + } + clean(encKey); + // apply InvMixColumn except first & last round + for (let i = 4; i < Nk - 4; i++) { + const x = xk[i]; + const w = applySbox(sbox2, x, x, x, x); + xk[i] = T0[w & 0xff] ^ T1[(w >>> 8) & 0xff] ^ T2[(w >>> 16) & 0xff] ^ T3[w >>> 24]; + } + return xk; +} + +// Apply tables +function apply0123( + T01: Uint32Array, + T23: Uint32Array, + s0: number, + s1: number, + s2: number, + s3: number +) { + return ( + T01[((s0 << 8) & 0xff00) | ((s1 >>> 8) & 0xff)] ^ + T23[((s2 >>> 8) & 0xff00) | ((s3 >>> 24) & 0xff)] + ); +} + +function applySbox(sbox2: Uint16Array, s0: number, s1: number, s2: number, s3: number) { + return ( + sbox2[(s0 & 0xff) | (s1 & 0xff00)] | + (sbox2[((s2 >>> 16) & 0xff) | ((s3 >>> 16) & 0xff00)] << 16) + ); +} + +function encrypt( + xk: Uint32Array, + s0: number, + s1: number, + s2: number, + s3: number +): { s0: number; s1: number; s2: number; s3: number } { + const { sbox2, T01, T23 } = tableEncoding; + let k = 0; + (s0 ^= xk[k++]), (s1 ^= xk[k++]), (s2 ^= xk[k++]), (s3 ^= xk[k++]); + const rounds = xk.length / 4 - 2; + for (let i = 0; i < rounds; i++) { + const t0 = xk[k++] ^ apply0123(T01, T23, s0, s1, s2, s3); + const t1 = xk[k++] ^ apply0123(T01, T23, s1, s2, s3, s0); + const t2 = xk[k++] ^ apply0123(T01, T23, s2, s3, s0, s1); + const t3 = xk[k++] ^ apply0123(T01, T23, s3, s0, s1, s2); + (s0 = t0), (s1 = t1), (s2 = t2), (s3 = t3); + } + // last round (without mixcolumns, so using SBOX2 table) + const t0 = xk[k++] ^ applySbox(sbox2, s0, s1, s2, s3); + const t1 = xk[k++] ^ applySbox(sbox2, s1, s2, s3, s0); + const t2 = xk[k++] ^ applySbox(sbox2, s2, s3, s0, s1); + const t3 = xk[k++] ^ applySbox(sbox2, s3, s0, s1, s2); + return { s0: t0, s1: t1, s2: t2, s3: t3 }; +} + +// Can't be merged with encrypt: arg positions for apply0123 / applySbox are different +function decrypt( + xk: Uint32Array, + s0: number, + s1: number, + s2: number, + s3: number +): { + s0: number; + s1: number; + s2: number; + s3: number; +} { + const { sbox2, T01, T23 } = tableDecoding; + let k = 0; + (s0 ^= xk[k++]), (s1 ^= xk[k++]), (s2 ^= xk[k++]), (s3 ^= xk[k++]); + const rounds = xk.length / 4 - 2; + for (let i = 0; i < rounds; i++) { + const t0 = xk[k++] ^ apply0123(T01, T23, s0, s3, s2, s1); + const t1 = xk[k++] ^ apply0123(T01, T23, s1, s0, s3, s2); + const t2 = xk[k++] ^ apply0123(T01, T23, s2, s1, s0, s3); + const t3 = xk[k++] ^ apply0123(T01, T23, s3, s2, s1, s0); + (s0 = t0), (s1 = t1), (s2 = t2), (s3 = t3); + } + // Last round + const t0: number = xk[k++] ^ applySbox(sbox2, s0, s3, s2, s1); + const t1: number = xk[k++] ^ applySbox(sbox2, s1, s0, s3, s2); + const t2: number = xk[k++] ^ applySbox(sbox2, s2, s1, s0, s3); + const t3: number = xk[k++] ^ applySbox(sbox2, s3, s2, s1, s0); + return { s0: t0, s1: t1, s2: t2, s3: t3 }; +} + +// TODO: investigate merging with ctr32 +function ctrCounter( + xk: Uint32Array, + nonce: Uint8Array, + src: Uint8Array, + dst?: Uint8Array +): Uint8Array { + abytes(nonce, BLOCK_SIZE); + abytes(src); + const srcLen = src.length; + dst = getOutput(srcLen, dst); + complexOverlapBytes(src, dst); + const ctr = nonce; + const c32 = u32(ctr); + // Fill block (empty, ctr=0) + let { s0, s1, s2, s3 } = encrypt(xk, c32[0], c32[1], c32[2], c32[3]); + const src32 = u32(src); + const dst32 = u32(dst); + // process blocks + for (let i = 0; i + 4 <= src32.length; i += 4) { + dst32[i + 0] = src32[i + 0] ^ s0; + dst32[i + 1] = src32[i + 1] ^ s1; + dst32[i + 2] = src32[i + 2] ^ s2; + dst32[i + 3] = src32[i + 3] ^ s3; + // Full 128 bit counter with wrap around + let carry = 1; + for (let i = ctr.length - 1; i >= 0; i--) { + carry = (carry + (ctr[i] & 0xff)) | 0; + ctr[i] = carry & 0xff; + carry >>>= 8; + } + ({ s0, s1, s2, s3 } = encrypt(xk, c32[0], c32[1], c32[2], c32[3])); + } + // leftovers (less than block) + // It's possible to handle > u32 fast, but is it worth it? + const start = BLOCK_SIZE * Math.floor(src32.length / BLOCK_SIZE32); + if (start < srcLen) { + const b32 = new Uint32Array([s0, s1, s2, s3]); + const buf = u8(b32); + for (let i = start, pos = 0; i < srcLen; i++, pos++) dst[i] = src[i] ^ buf[pos]; + clean(b32); + } + return dst; +} + +// AES CTR with overflowing 32 bit counter +// It's possible to do 32le significantly simpler (and probably faster) by using u32. +// But, we need both, and perf bottleneck is in ghash anyway. +function ctr32( + xk: Uint32Array, + isLE: boolean, + nonce: Uint8Array, + src: Uint8Array, + dst?: Uint8Array +): Uint8Array { + abytes(nonce, BLOCK_SIZE); + abytes(src); + dst = getOutput(src.length, dst); + const ctr = nonce; // write new value to nonce, so it can be re-used + const c32 = u32(ctr); + const view = createView(ctr); + const src32 = u32(src); + const dst32 = u32(dst); + const ctrPos = isLE ? 0 : 12; + const srcLen = src.length; + // Fill block (empty, ctr=0) + let ctrNum = view.getUint32(ctrPos, isLE); // read current counter value + let { s0, s1, s2, s3 } = encrypt(xk, c32[0], c32[1], c32[2], c32[3]); + // process blocks + for (let i = 0; i + 4 <= src32.length; i += 4) { + dst32[i + 0] = src32[i + 0] ^ s0; + dst32[i + 1] = src32[i + 1] ^ s1; + dst32[i + 2] = src32[i + 2] ^ s2; + dst32[i + 3] = src32[i + 3] ^ s3; + ctrNum = (ctrNum + 1) >>> 0; // u32 wrap + view.setUint32(ctrPos, ctrNum, isLE); + ({ s0, s1, s2, s3 } = encrypt(xk, c32[0], c32[1], c32[2], c32[3])); + } + // leftovers (less than a block) + const start = BLOCK_SIZE * Math.floor(src32.length / BLOCK_SIZE32); + if (start < srcLen) { + const b32 = new Uint32Array([s0, s1, s2, s3]); + const buf = u8(b32); + for (let i = start, pos = 0; i < srcLen; i++, pos++) dst[i] = src[i] ^ buf[pos]; + clean(b32); + } + return dst; +} + +/** + * CTR: counter mode. Creates stream cipher. + * Requires good IV. Parallelizable. OK, but no MAC. + */ +export const ctr: ((key: Uint8Array, nonce: Uint8Array) => CipherWithOutput) & { + blockSize: number; + nonceLength: number; +} = /* @__PURE__ */ wrapCipher( + { blockSize: 16, nonceLength: 16 }, + function aesctr(key: Uint8Array, nonce: Uint8Array): CipherWithOutput { + function processCtr(buf: Uint8Array, dst?: Uint8Array) { + abytes(buf); + if (dst !== undefined) { + abytes(dst); + if (!isAligned32(dst)) throw new Error('unaligned destination'); + } + const xk = expandKeyLE(key); + const n = copyBytes(nonce); // align + avoid changing + const toClean = [xk, n]; + if (!isAligned32(buf)) toClean.push((buf = copyBytes(buf))); + const out = ctrCounter(xk, n, buf, dst); + clean(...toClean); + return out; + } + return { + encrypt: (plaintext: Uint8Array, dst?: Uint8Array) => processCtr(plaintext, dst), + decrypt: (ciphertext: Uint8Array, dst?: Uint8Array) => processCtr(ciphertext, dst), + }; + } +); + +function validateBlockDecrypt(data: Uint8Array) { + abytes(data); + if (data.length % BLOCK_SIZE !== 0) { + throw new Error( + 'aes-(cbc/ecb).decrypt ciphertext should consist of blocks with size ' + BLOCK_SIZE + ); + } +} + +function validateBlockEncrypt(plaintext: Uint8Array, pcks5: boolean, dst?: Uint8Array) { + abytes(plaintext); + let outLen = plaintext.length; + const remaining = outLen % BLOCK_SIZE; + if (!pcks5 && remaining !== 0) + throw new Error('aec/(cbc-ecb): unpadded plaintext with disabled padding'); + if (!isAligned32(plaintext)) plaintext = copyBytes(plaintext); + const b = u32(plaintext); + if (pcks5) { + let left = BLOCK_SIZE - remaining; + if (!left) left = BLOCK_SIZE; // if no bytes left, create empty padding block + outLen = outLen + left; + } + dst = getOutput(outLen, dst); + complexOverlapBytes(plaintext, dst); + const o = u32(dst); + return { b, o, out: dst }; +} + +function validatePCKS(data: Uint8Array, pcks5: boolean) { + if (!pcks5) return data; + const len = data.length; + if (!len) throw new Error('aes/pcks5: empty ciphertext not allowed'); + const lastByte = data[len - 1]; + if (lastByte <= 0 || lastByte > 16) throw new Error('aes/pcks5: wrong padding'); + const out = data.subarray(0, -lastByte); + for (let i = 0; i < lastByte; i++) + if (data[len - i - 1] !== lastByte) throw new Error('aes/pcks5: wrong padding'); + return out; +} + +function padPCKS(left: Uint8Array) { + const tmp = new Uint8Array(16); + const tmp32 = u32(tmp); + tmp.set(left); + const paddingByte = BLOCK_SIZE - left.length; + for (let i = BLOCK_SIZE - paddingByte; i < BLOCK_SIZE; i++) tmp[i] = paddingByte; + return tmp32; +} + +/** Options for ECB and CBC. */ +export type BlockOpts = { disablePadding?: boolean }; + +/** + * ECB: Electronic CodeBook. Simple deterministic replacement. + * Dangerous: always map x to y. See [AES Penguin](https://words.filippo.io/the-ecb-penguin/). + */ +export const ecb: ((key: Uint8Array, opts?: BlockOpts) => CipherWithOutput) & { + blockSize: number; +} = /* @__PURE__ */ wrapCipher( + { blockSize: 16 }, + function aesecb(key: Uint8Array, opts: BlockOpts = {}): CipherWithOutput { + const pcks5 = !opts.disablePadding; + return { + encrypt(plaintext: Uint8Array, dst?: Uint8Array) { + const { b, o, out: _out } = validateBlockEncrypt(plaintext, pcks5, dst); + const xk = expandKeyLE(key); + let i = 0; + for (; i + 4 <= b.length; ) { + const { s0, s1, s2, s3 } = encrypt(xk, b[i + 0], b[i + 1], b[i + 2], b[i + 3]); + (o[i++] = s0), (o[i++] = s1), (o[i++] = s2), (o[i++] = s3); + } + if (pcks5) { + const tmp32 = padPCKS(plaintext.subarray(i * 4)); + const { s0, s1, s2, s3 } = encrypt(xk, tmp32[0], tmp32[1], tmp32[2], tmp32[3]); + (o[i++] = s0), (o[i++] = s1), (o[i++] = s2), (o[i++] = s3); + } + clean(xk); + return _out; + }, + decrypt(ciphertext: Uint8Array, dst?: Uint8Array) { + validateBlockDecrypt(ciphertext); + const xk = expandKeyDecLE(key); + dst = getOutput(ciphertext.length, dst); + const toClean: (Uint8Array | Uint32Array)[] = [xk]; + if (!isAligned32(ciphertext)) toClean.push((ciphertext = copyBytes(ciphertext))); + complexOverlapBytes(ciphertext, dst); + const b = u32(ciphertext); + const o = u32(dst); + for (let i = 0; i + 4 <= b.length; ) { + const { s0, s1, s2, s3 } = decrypt(xk, b[i + 0], b[i + 1], b[i + 2], b[i + 3]); + (o[i++] = s0), (o[i++] = s1), (o[i++] = s2), (o[i++] = s3); + } + clean(...toClean); + return validatePCKS(dst, pcks5); + }, + }; + } +); + +/** + * CBC: Cipher-Block-Chaining. Key is previous round’s block. + * Fragile: needs proper padding. Unauthenticated: needs MAC. + */ +export const cbc: ((key: Uint8Array, iv: Uint8Array, opts?: BlockOpts) => CipherWithOutput) & { + blockSize: number; + nonceLength: number; +} = /* @__PURE__ */ wrapCipher( + { blockSize: 16, nonceLength: 16 }, + function aescbc(key: Uint8Array, iv: Uint8Array, opts: BlockOpts = {}): CipherWithOutput { + const pcks5 = !opts.disablePadding; + return { + encrypt(plaintext: Uint8Array, dst?: Uint8Array) { + const xk = expandKeyLE(key); + const { b, o, out: _out } = validateBlockEncrypt(plaintext, pcks5, dst); + let _iv = iv; + const toClean: (Uint8Array | Uint32Array)[] = [xk]; + if (!isAligned32(_iv)) toClean.push((_iv = copyBytes(_iv))); + const n32 = u32(_iv); + // prettier-ignore + let s0 = n32[0], s1 = n32[1], s2 = n32[2], s3 = n32[3]; + let i = 0; + for (; i + 4 <= b.length; ) { + (s0 ^= b[i + 0]), (s1 ^= b[i + 1]), (s2 ^= b[i + 2]), (s3 ^= b[i + 3]); + ({ s0, s1, s2, s3 } = encrypt(xk, s0, s1, s2, s3)); + (o[i++] = s0), (o[i++] = s1), (o[i++] = s2), (o[i++] = s3); + } + if (pcks5) { + const tmp32 = padPCKS(plaintext.subarray(i * 4)); + (s0 ^= tmp32[0]), (s1 ^= tmp32[1]), (s2 ^= tmp32[2]), (s3 ^= tmp32[3]); + ({ s0, s1, s2, s3 } = encrypt(xk, s0, s1, s2, s3)); + (o[i++] = s0), (o[i++] = s1), (o[i++] = s2), (o[i++] = s3); + } + clean(...toClean); + return _out; + }, + decrypt(ciphertext: Uint8Array, dst?: Uint8Array) { + validateBlockDecrypt(ciphertext); + const xk = expandKeyDecLE(key); + let _iv = iv; + const toClean: (Uint8Array | Uint32Array)[] = [xk]; + if (!isAligned32(_iv)) toClean.push((_iv = copyBytes(_iv))); + const n32 = u32(_iv); + dst = getOutput(ciphertext.length, dst); + if (!isAligned32(ciphertext)) toClean.push((ciphertext = copyBytes(ciphertext))); + complexOverlapBytes(ciphertext, dst); + const b = u32(ciphertext); + const o = u32(dst); + // prettier-ignore + let s0 = n32[0], s1 = n32[1], s2 = n32[2], s3 = n32[3]; + for (let i = 0; i + 4 <= b.length; ) { + // prettier-ignore + const ps0 = s0, ps1 = s1, ps2 = s2, ps3 = s3; + (s0 = b[i + 0]), (s1 = b[i + 1]), (s2 = b[i + 2]), (s3 = b[i + 3]); + const { s0: o0, s1: o1, s2: o2, s3: o3 } = decrypt(xk, s0, s1, s2, s3); + (o[i++] = o0 ^ ps0), (o[i++] = o1 ^ ps1), (o[i++] = o2 ^ ps2), (o[i++] = o3 ^ ps3); + } + clean(...toClean); + return validatePCKS(dst, pcks5); + }, + }; + } +); + +/** + * CFB: Cipher Feedback Mode. The input for the block cipher is the previous cipher output. + * Unauthenticated: needs MAC. + */ +export const cfb: ((key: Uint8Array, iv: Uint8Array) => CipherWithOutput) & { + blockSize: number; + nonceLength: number; +} = /* @__PURE__ */ wrapCipher( + { blockSize: 16, nonceLength: 16 }, + function aescfb(key: Uint8Array, iv: Uint8Array): CipherWithOutput { + function processCfb(src: Uint8Array, isEncrypt: boolean, dst?: Uint8Array) { + abytes(src); + const srcLen = src.length; + dst = getOutput(srcLen, dst); + if (overlapBytes(src, dst)) throw new Error('overlapping src and dst not supported.'); + const xk = expandKeyLE(key); + let _iv = iv; + const toClean: (Uint8Array | Uint32Array)[] = [xk]; + if (!isAligned32(_iv)) toClean.push((_iv = copyBytes(_iv))); + if (!isAligned32(src)) toClean.push((src = copyBytes(src))); + const src32 = u32(src); + const dst32 = u32(dst); + const next32 = isEncrypt ? dst32 : src32; + const n32 = u32(_iv); + // prettier-ignore + let s0 = n32[0], s1 = n32[1], s2 = n32[2], s3 = n32[3]; + for (let i = 0; i + 4 <= src32.length; ) { + const { s0: e0, s1: e1, s2: e2, s3: e3 } = encrypt(xk, s0, s1, s2, s3); + dst32[i + 0] = src32[i + 0] ^ e0; + dst32[i + 1] = src32[i + 1] ^ e1; + dst32[i + 2] = src32[i + 2] ^ e2; + dst32[i + 3] = src32[i + 3] ^ e3; + (s0 = next32[i++]), (s1 = next32[i++]), (s2 = next32[i++]), (s3 = next32[i++]); + } + // leftovers (less than block) + const start = BLOCK_SIZE * Math.floor(src32.length / BLOCK_SIZE32); + if (start < srcLen) { + ({ s0, s1, s2, s3 } = encrypt(xk, s0, s1, s2, s3)); + const buf = u8(new Uint32Array([s0, s1, s2, s3])); + for (let i = start, pos = 0; i < srcLen; i++, pos++) dst[i] = src[i] ^ buf[pos]; + clean(buf); + } + clean(...toClean); + return dst; + } + return { + encrypt: (plaintext: Uint8Array, dst?: Uint8Array) => processCfb(plaintext, true, dst), + decrypt: (ciphertext: Uint8Array, dst?: Uint8Array) => processCfb(ciphertext, false, dst), + }; + } +); + +// TODO: merge with chacha, however gcm has bitLen while chacha has byteLen +function computeTag( + fn: typeof ghash, + isLE: boolean, + key: Uint8Array, + data: Uint8Array, + AAD?: Uint8Array +) { + const aadLength = AAD ? AAD.length : 0; + const h = fn.create(key, data.length + aadLength); + if (AAD) h.update(AAD); + const num = u64Lengths(8 * data.length, 8 * aadLength, isLE); + h.update(data); + h.update(num); + const res = h.digest(); + clean(num); + return res; +} + +/** + * GCM: Galois/Counter Mode. + * Modern, parallel version of CTR, with MAC. + * Be careful: MACs can be forged. + * Unsafe to use random nonces under the same key, due to collision chance. + * As for nonce size, prefer 12-byte, instead of 8-byte. + */ +export const gcm: ((key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => Cipher) & { + blockSize: number; + nonceLength: number; + tagLength: number; + varSizeNonce: true; +} = /* @__PURE__ */ wrapCipher( + { blockSize: 16, nonceLength: 12, tagLength: 16, varSizeNonce: true }, + function aesgcm(key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array): Cipher { + // NIST 800-38d doesn't enforce minimum nonce length. + // We enforce 8 bytes for compat with openssl. + // 12 bytes are recommended. More than 12 bytes would be converted into 12. + if (nonce.length < 8) throw new Error('aes/gcm: invalid nonce length'); + const tagLength = 16; + function _computeTag(authKey: Uint8Array, tagMask: Uint8Array, data: Uint8Array) { + const tag = computeTag(ghash, false, authKey, data, AAD); + for (let i = 0; i < tagMask.length; i++) tag[i] ^= tagMask[i]; + return tag; + } + function deriveKeys() { + const xk = expandKeyLE(key); + const authKey = EMPTY_BLOCK.slice(); + const counter = EMPTY_BLOCK.slice(); + ctr32(xk, false, counter, counter, authKey); + // NIST 800-38d, page 15: different behavior for 96-bit and non-96-bit nonces + if (nonce.length === 12) { + counter.set(nonce); + } else { + const nonceLen = EMPTY_BLOCK.slice(); + const view = createView(nonceLen); + setBigUint64(view, 8, BigInt(nonce.length * 8), false); + // ghash(nonce || u64be(0) || u64be(nonceLen*8)) + const g = ghash.create(authKey).update(nonce).update(nonceLen); + g.digestInto(counter); // digestInto doesn't trigger '.destroy' + g.destroy(); + } + const tagMask = ctr32(xk, false, counter, EMPTY_BLOCK); + return { xk, authKey, counter, tagMask }; + } + return { + encrypt(plaintext: Uint8Array) { + const { xk, authKey, counter, tagMask } = deriveKeys(); + const out = new Uint8Array(plaintext.length + tagLength); + const toClean: (Uint8Array | Uint32Array)[] = [xk, authKey, counter, tagMask]; + if (!isAligned32(plaintext)) toClean.push((plaintext = copyBytes(plaintext))); + ctr32(xk, false, counter, plaintext, out.subarray(0, plaintext.length)); + const tag = _computeTag(authKey, tagMask, out.subarray(0, out.length - tagLength)); + toClean.push(tag); + out.set(tag, plaintext.length); + clean(...toClean); + return out; + }, + decrypt(ciphertext: Uint8Array) { + const { xk, authKey, counter, tagMask } = deriveKeys(); + const toClean: (Uint8Array | Uint32Array)[] = [xk, authKey, tagMask, counter]; + if (!isAligned32(ciphertext)) toClean.push((ciphertext = copyBytes(ciphertext))); + const data = ciphertext.subarray(0, -tagLength); + const passedTag = ciphertext.subarray(-tagLength); + const tag = _computeTag(authKey, tagMask, data); + toClean.push(tag); + if (!equalBytes(tag, passedTag)) throw new Error('aes/gcm: invalid ghash tag'); + const out = ctr32(xk, false, counter, data); + clean(...toClean); + return out; + }, + }; + } +); + +const limit = (name: string, min: number, max: number) => (value: number) => { + if (!Number.isSafeInteger(value) || min > value || value > max) { + const minmax = '[' + min + '..' + max + ']'; + throw new Error('' + name + ': expected value in range ' + minmax + ', got ' + value); + } +}; + +/** + * AES-GCM-SIV: classic AES-GCM with nonce-misuse resistance. + * Guarantees that, when a nonce is repeated, the only security loss is that identical + * plaintexts will produce identical ciphertexts. + * RFC 8452, https://datatracker.ietf.org/doc/html/rfc8452 + */ +export const gcmsiv: ((key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => Cipher) & { + blockSize: number; + nonceLength: number; + tagLength: number; + varSizeNonce: true; +} = /* @__PURE__ */ wrapCipher( + { blockSize: 16, nonceLength: 12, tagLength: 16, varSizeNonce: true }, + function aessiv(key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array): Cipher { + const tagLength = 16; + // From RFC 8452: Section 6 + const AAD_LIMIT = limit('AAD', 0, 2 ** 36); + const PLAIN_LIMIT = limit('plaintext', 0, 2 ** 36); + const NONCE_LIMIT = limit('nonce', 12, 12); + const CIPHER_LIMIT = limit('ciphertext', 16, 2 ** 36 + 16); + abytes(key, 16, 24, 32); + NONCE_LIMIT(nonce.length); + if (AAD !== undefined) AAD_LIMIT(AAD.length); + function deriveKeys() { + const xk = expandKeyLE(key); + const encKey = new Uint8Array(key.length); + const authKey = new Uint8Array(16); + const toClean: (Uint8Array | Uint32Array)[] = [xk, encKey]; + let _nonce = nonce; + if (!isAligned32(_nonce)) toClean.push((_nonce = copyBytes(_nonce))); + const n32 = u32(_nonce); + // prettier-ignore + let s0 = 0, s1 = n32[0], s2 = n32[1], s3 = n32[2]; + let counter = 0; + for (const derivedKey of [authKey, encKey].map(u32)) { + const d32 = u32(derivedKey); + for (let i = 0; i < d32.length; i += 2) { + // aes(u32le(0) || nonce)[:8] || aes(u32le(1) || nonce)[:8] ... + const { s0: o0, s1: o1 } = encrypt(xk, s0, s1, s2, s3); + d32[i + 0] = o0; + d32[i + 1] = o1; + s0 = ++counter; // increment counter inside state + } + } + const res = { authKey, encKey: expandKeyLE(encKey) }; + // Cleanup + clean(...toClean); + return res; + } + function _computeTag(encKey: Uint32Array, authKey: Uint8Array, data: Uint8Array) { + const tag = computeTag(polyval, true, authKey, data, AAD); + // Compute the expected tag by XORing S_s and the nonce, clearing the + // most significant bit of the last byte and encrypting with the + // message-encryption key. + for (let i = 0; i < 12; i++) tag[i] ^= nonce[i]; + tag[15] &= 0x7f; // Clear the highest bit + // encrypt tag as block + const t32 = u32(tag); + // prettier-ignore + let s0 = t32[0], s1 = t32[1], s2 = t32[2], s3 = t32[3]; + ({ s0, s1, s2, s3 } = encrypt(encKey, s0, s1, s2, s3)); + (t32[0] = s0), (t32[1] = s1), (t32[2] = s2), (t32[3] = s3); + return tag; + } + // actual decrypt/encrypt of message. + function processSiv(encKey: Uint32Array, tag: Uint8Array, input: Uint8Array) { + let block = copyBytes(tag); + block[15] |= 0x80; // Force highest bit + const res = ctr32(encKey, true, block, input); + // Cleanup + clean(block); + return res; + } + return { + encrypt(plaintext: Uint8Array) { + PLAIN_LIMIT(plaintext.length); + const { encKey, authKey } = deriveKeys(); + const tag = _computeTag(encKey, authKey, plaintext); + const toClean: (Uint8Array | Uint32Array)[] = [encKey, authKey, tag]; + if (!isAligned32(plaintext)) toClean.push((plaintext = copyBytes(plaintext))); + const out = new Uint8Array(plaintext.length + tagLength); + out.set(tag, plaintext.length); + out.set(processSiv(encKey, tag, plaintext)); + // Cleanup + clean(...toClean); + return out; + }, + decrypt(ciphertext: Uint8Array) { + CIPHER_LIMIT(ciphertext.length); + const tag = ciphertext.subarray(-tagLength); + const { encKey, authKey } = deriveKeys(); + const toClean: (Uint8Array | Uint32Array)[] = [encKey, authKey]; + if (!isAligned32(ciphertext)) toClean.push((ciphertext = copyBytes(ciphertext))); + const plaintext = processSiv(encKey, tag, ciphertext.subarray(0, -tagLength)); + const expectedTag = _computeTag(encKey, authKey, plaintext); + toClean.push(expectedTag); + if (!equalBytes(tag, expectedTag)) { + clean(...toClean); + throw new Error('invalid polyval tag'); + } + // Cleanup + clean(...toClean); + return plaintext; + }, + }; + } +); + +/** + * AES-GCM-SIV, not AES-SIV. + * This is legace name, use `gcmsiv` export instead. + * @deprecated + */ +export const siv: typeof gcmsiv = gcmsiv; + +function isBytes32(a: unknown): a is Uint32Array { + return ( + a instanceof Uint32Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint32Array') + ); +} + +function encryptBlock(xk: Uint32Array, block: Uint8Array): Uint8Array { + abytes(block, 16); + if (!isBytes32(xk)) throw new Error('_encryptBlock accepts result of expandKeyLE'); + const b32 = u32(block); + let { s0, s1, s2, s3 } = encrypt(xk, b32[0], b32[1], b32[2], b32[3]); + (b32[0] = s0), (b32[1] = s1), (b32[2] = s2), (b32[3] = s3); + return block; +} + +function decryptBlock(xk: Uint32Array, block: Uint8Array): Uint8Array { + abytes(block, 16); + if (!isBytes32(xk)) throw new Error('_decryptBlock accepts result of expandKeyLE'); + const b32 = u32(block); + let { s0, s1, s2, s3 } = decrypt(xk, b32[0], b32[1], b32[2], b32[3]); + (b32[0] = s0), (b32[1] = s1), (b32[2] = s2), (b32[3] = s3); + return block; +} + +/** + * AES-W (base for AESKW/AESKWP). + * Specs: [SP800-38F](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38F.pdf), + * [RFC 3394](https://datatracker.ietf.org/doc/rfc3394/), + * [RFC 5649](https://datatracker.ietf.org/doc/rfc5649/). + */ +const AESW = { + /* + High-level pseudocode: + ``` + A: u64 = IV + out = [] + for (let i=0, ctr = 0; i<6; i++) { + for (const chunk of chunks(plaintext, 8)) { + A ^= swapEndianess(ctr++) + [A, res] = chunks(encrypt(A || chunk), 8); + out ||= res + } + } + out = A || out + ``` + Decrypt is the same, but reversed. + */ + encrypt(kek: Uint8Array, out: Uint8Array) { + // Size is limited to 4GB, otherwise ctr will overflow and we'll need to switch to bigints. + // If you need it larger, open an issue. + if (out.length >= 2 ** 32) throw new Error('plaintext should be less than 4gb'); + const xk = expandKeyLE(kek); + if (out.length === 16) encryptBlock(xk, out); + else { + const o32 = u32(out); + // prettier-ignore + let a0 = o32[0], a1 = o32[1]; // A + for (let j = 0, ctr = 1; j < 6; j++) { + for (let pos = 2; pos < o32.length; pos += 2, ctr++) { + const { s0, s1, s2, s3 } = encrypt(xk, a0, a1, o32[pos], o32[pos + 1]); + // A = MSB(64, B) ^ t where t = (n*j)+i + (a0 = s0), (a1 = s1 ^ byteSwap(ctr)), (o32[pos] = s2), (o32[pos + 1] = s3); + } + } + (o32[0] = a0), (o32[1] = a1); // out = A || out + } + xk.fill(0); + }, + decrypt(kek: Uint8Array, out: Uint8Array) { + if (out.length - 8 >= 2 ** 32) throw new Error('ciphertext should be less than 4gb'); + const xk = expandKeyDecLE(kek); + const chunks = out.length / 8 - 1; // first chunk is IV + if (chunks === 1) decryptBlock(xk, out); + else { + const o32 = u32(out); + // prettier-ignore + let a0 = o32[0], a1 = o32[1]; // A + for (let j = 0, ctr = chunks * 6; j < 6; j++) { + for (let pos = chunks * 2; pos >= 1; pos -= 2, ctr--) { + a1 ^= byteSwap(ctr); + const { s0, s1, s2, s3 } = decrypt(xk, a0, a1, o32[pos], o32[pos + 1]); + (a0 = s0), (a1 = s1), (o32[pos] = s2), (o32[pos + 1] = s3); + } + } + (o32[0] = a0), (o32[1] = a1); + } + xk.fill(0); + }, +}; + +const AESKW_IV = /* @__PURE__ */ new Uint8Array(8).fill(0xa6); // A6A6A6A6A6A6A6A6 + +/** + * AES-KW (key-wrap). Injects static IV into plaintext, adds counter, encrypts 6 times. + * Reduces block size from 16 to 8 bytes. + * For padded version, use aeskwp. + * [RFC 3394](https://datatracker.ietf.org/doc/rfc3394/), + * [NIST.SP.800-38F](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38F.pdf). + */ +export const aeskw: ((kek: Uint8Array) => Cipher) & { + blockSize: number; +} = /* @__PURE__ */ wrapCipher( + { blockSize: 8 }, + (kek: Uint8Array): Cipher => ({ + encrypt(plaintext: Uint8Array) { + if (!plaintext.length || plaintext.length % 8 !== 0) + throw new Error('invalid plaintext length'); + if (plaintext.length === 8) + throw new Error('8-byte keys not allowed in AESKW, use AESKWP instead'); + const out = concatBytes(AESKW_IV, plaintext); + AESW.encrypt(kek, out); + return out; + }, + decrypt(ciphertext: Uint8Array) { + // ciphertext must be at least 24 bytes and a multiple of 8 bytes + // 24 because should have at least two block (1 iv + 2). + // Replace with 16 to enable '8-byte keys' + if (ciphertext.length % 8 !== 0 || ciphertext.length < 3 * 8) + throw new Error('invalid ciphertext length'); + const out = copyBytes(ciphertext); + AESW.decrypt(kek, out); + if (!equalBytes(out.subarray(0, 8), AESKW_IV)) throw new Error('integrity check failed'); + out.subarray(0, 8).fill(0); // ciphertext.subarray(0, 8) === IV, but we clean it anyway + return out.subarray(8); + }, + }) +); + +/* +We don't support 8-byte keys. The rabbit hole: + +- Wycheproof says: "NIST SP 800-38F does not define the wrapping of 8 byte keys. + RFC 3394 Section 2 on the other hand specifies that 8 byte keys are wrapped + by directly encrypting one block with AES." + - https://github.com/C2SP/wycheproof/blob/master/doc/key_wrap.md + - "RFC 3394 specifies in Section 2, that the input for the key wrap + algorithm must be at least two blocks and otherwise the constant + field and key are simply encrypted with ECB as a single block" +- What RFC 3394 actually says (in Section 2): + - "Before being wrapped, the key data is parsed into n blocks of 64 bits. + The only restriction the key wrap algorithm places on n is that n be + at least two" + - "For key data with length less than or equal to 64 bits, the constant + field used in this specification and the key data form a single + 128-bit codebook input making this key wrap unnecessary." +- Which means "assert(n >= 2)" and "use something else for 8 byte keys" +- NIST SP800-38F actually prohibits 8-byte in "5.3.1 Mandatory Limits". + It states that plaintext for KW should be "2 to 2^54 -1 semiblocks". +- So, where does "directly encrypt single block with AES" come from? + - Not RFC 3394. Pseudocode of key wrap in 2.2 explicitly uses + loop of 6 for any code path + - There is a weird W3C spec: + https://www.w3.org/TR/2002/REC-xmlenc-core-20021210/Overview.html#kw-aes128 + - This spec is outdated, as admitted by Wycheproof authors + - There is RFC 5649 for padded key wrap, which is padding construction on + top of AESKW. In '4.1.2' it says: "If the padded plaintext contains exactly + eight octets, then prepend the AIV as defined in Section 3 above to P[1] and + encrypt the resulting 128-bit block using AES in ECB mode [Modes] with key + K (the KEK). In this case, the output is two 64-bit blocks C[0] and C[1]:" + - Browser subtle crypto is actually crashes on wrapping keys less than 16 bytes: + `Error: error:1C8000E6:Provider routines::invalid input length] { opensslErrorStack: [ 'error:030000BD:digital envelope routines::update error' ]` + +In the end, seems like a bug in Wycheproof. +The 8-byte check can be easily disabled inside of AES_W. +*/ + +const AESKWP_IV = 0xa65959a6; // single u32le value + +/** + * AES-KW, but with padding and allows random keys. + * Second u32 of IV is used as counter for length. + * [RFC 5649](https://www.rfc-editor.org/rfc/rfc5649) + */ +export const aeskwp: ((kek: Uint8Array) => Cipher) & { + blockSize: number; +} = /* @__PURE__ */ wrapCipher( + { blockSize: 8 }, + (kek: Uint8Array): Cipher => ({ + encrypt(plaintext: Uint8Array) { + if (!plaintext.length) throw new Error('invalid plaintext length'); + const padded = Math.ceil(plaintext.length / 8) * 8; + const out = new Uint8Array(8 + padded); + out.set(plaintext, 8); + const out32 = u32(out); + out32[0] = AESKWP_IV; + out32[1] = byteSwap(plaintext.length); + AESW.encrypt(kek, out); + return out; + }, + decrypt(ciphertext: Uint8Array) { + // 16 because should have at least one block + if (ciphertext.length < 16) throw new Error('invalid ciphertext length'); + const out = copyBytes(ciphertext); + const o32 = u32(out); + AESW.decrypt(kek, out); + const len = byteSwap(o32[1]) >>> 0; + const padded = Math.ceil(len / 8) * 8; + if (o32[0] !== AESKWP_IV || out.length - 8 !== padded) + throw new Error('integrity check failed'); + for (let i = len; i < padded; i++) + if (out[8 + i] !== 0) throw new Error('integrity check failed'); + out.subarray(0, 8).fill(0); // ciphertext.subarray(0, 8) === IV, but we clean it anyway + return out.subarray(8, 8 + len); + }, + }) +); + +/** Unsafe low-level internal methods. May change at any time. */ +export const unsafe: { + expandKeyLE: typeof expandKeyLE; + expandKeyDecLE: typeof expandKeyDecLE; + encrypt: typeof encrypt; + decrypt: typeof decrypt; + encryptBlock: typeof encryptBlock; + decryptBlock: typeof decryptBlock; + ctrCounter: typeof ctrCounter; + ctr32: typeof ctr32; +} = { + expandKeyLE, + expandKeyDecLE, + encrypt, + decrypt, + encryptBlock, + decryptBlock, + ctrCounter, + ctr32, +}; diff --git a/node_modules/@noble/ciphers/src/chacha.ts b/node_modules/@noble/ciphers/src/chacha.ts new file mode 100644 index 0000000000000000000000000000000000000000..7a0b88924cb74393000ba7254933145f0cd3e6ba --- /dev/null +++ b/node_modules/@noble/ciphers/src/chacha.ts @@ -0,0 +1,290 @@ +/** + * [ChaCha20](https://cr.yp.to/chacha.html) stream cipher, released + * in 2008. Developed after Salsa20, ChaCha aims to increase diffusion per round. + * It was standardized in [RFC 8439](https://datatracker.ietf.org/doc/html/rfc8439) and + * is now used in TLS 1.3. + * + * [XChaCha20](https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha) + * extended-nonce variant is also provided. Similar to XSalsa, it's safe to use with + * randomly-generated nonces. + * + * Check out [PDF](http://cr.yp.to/chacha/chacha-20080128.pdf) and + * [wiki](https://en.wikipedia.org/wiki/Salsa20). + * @module + */ +import { createCipher, rotl } from './_arx.ts'; +import { poly1305 } from './_poly1305.ts'; +import { + type ARXCipher, + type CipherWithOutput, + type XorStream, + clean, + equalBytes, + getOutput, + u64Lengths, + wrapCipher, +} from './utils.ts'; + +/** + * ChaCha core function. + */ +// prettier-ignore +function chachaCore( + s: Uint32Array, k: Uint32Array, n: Uint32Array, out: Uint32Array, cnt: number, rounds = 20 +): void { + let y00 = s[0], y01 = s[1], y02 = s[2], y03 = s[3], // "expa" "nd 3" "2-by" "te k" + y04 = k[0], y05 = k[1], y06 = k[2], y07 = k[3], // Key Key Key Key + y08 = k[4], y09 = k[5], y10 = k[6], y11 = k[7], // Key Key Key Key + y12 = cnt, y13 = n[0], y14 = n[1], y15 = n[2]; // Counter Counter Nonce Nonce + // Save state to temporary variables + let x00 = y00, x01 = y01, x02 = y02, x03 = y03, + x04 = y04, x05 = y05, x06 = y06, x07 = y07, + x08 = y08, x09 = y09, x10 = y10, x11 = y11, + x12 = y12, x13 = y13, x14 = y14, x15 = y15; + for (let r = 0; r < rounds; r += 2) { + x00 = (x00 + x04) | 0; x12 = rotl(x12 ^ x00, 16); + x08 = (x08 + x12) | 0; x04 = rotl(x04 ^ x08, 12); + x00 = (x00 + x04) | 0; x12 = rotl(x12 ^ x00, 8); + x08 = (x08 + x12) | 0; x04 = rotl(x04 ^ x08, 7); + + x01 = (x01 + x05) | 0; x13 = rotl(x13 ^ x01, 16); + x09 = (x09 + x13) | 0; x05 = rotl(x05 ^ x09, 12); + x01 = (x01 + x05) | 0; x13 = rotl(x13 ^ x01, 8); + x09 = (x09 + x13) | 0; x05 = rotl(x05 ^ x09, 7); + + x02 = (x02 + x06) | 0; x14 = rotl(x14 ^ x02, 16); + x10 = (x10 + x14) | 0; x06 = rotl(x06 ^ x10, 12); + x02 = (x02 + x06) | 0; x14 = rotl(x14 ^ x02, 8); + x10 = (x10 + x14) | 0; x06 = rotl(x06 ^ x10, 7); + + x03 = (x03 + x07) | 0; x15 = rotl(x15 ^ x03, 16); + x11 = (x11 + x15) | 0; x07 = rotl(x07 ^ x11, 12); + x03 = (x03 + x07) | 0; x15 = rotl(x15 ^ x03, 8) + x11 = (x11 + x15) | 0; x07 = rotl(x07 ^ x11, 7); + + x00 = (x00 + x05) | 0; x15 = rotl(x15 ^ x00, 16); + x10 = (x10 + x15) | 0; x05 = rotl(x05 ^ x10, 12); + x00 = (x00 + x05) | 0; x15 = rotl(x15 ^ x00, 8); + x10 = (x10 + x15) | 0; x05 = rotl(x05 ^ x10, 7); + + x01 = (x01 + x06) | 0; x12 = rotl(x12 ^ x01, 16); + x11 = (x11 + x12) | 0; x06 = rotl(x06 ^ x11, 12); + x01 = (x01 + x06) | 0; x12 = rotl(x12 ^ x01, 8); + x11 = (x11 + x12) | 0; x06 = rotl(x06 ^ x11, 7); + + x02 = (x02 + x07) | 0; x13 = rotl(x13 ^ x02, 16); + x08 = (x08 + x13) | 0; x07 = rotl(x07 ^ x08, 12); + x02 = (x02 + x07) | 0; x13 = rotl(x13 ^ x02, 8); + x08 = (x08 + x13) | 0; x07 = rotl(x07 ^ x08, 7); + + x03 = (x03 + x04) | 0; x14 = rotl(x14 ^ x03, 16) + x09 = (x09 + x14) | 0; x04 = rotl(x04 ^ x09, 12); + x03 = (x03 + x04) | 0; x14 = rotl(x14 ^ x03, 8); + x09 = (x09 + x14) | 0; x04 = rotl(x04 ^ x09, 7); + } + // Write output + let oi = 0; + out[oi++] = (y00 + x00) | 0; out[oi++] = (y01 + x01) | 0; + out[oi++] = (y02 + x02) | 0; out[oi++] = (y03 + x03) | 0; + out[oi++] = (y04 + x04) | 0; out[oi++] = (y05 + x05) | 0; + out[oi++] = (y06 + x06) | 0; out[oi++] = (y07 + x07) | 0; + out[oi++] = (y08 + x08) | 0; out[oi++] = (y09 + x09) | 0; + out[oi++] = (y10 + x10) | 0; out[oi++] = (y11 + x11) | 0; + out[oi++] = (y12 + x12) | 0; out[oi++] = (y13 + x13) | 0; + out[oi++] = (y14 + x14) | 0; out[oi++] = (y15 + x15) | 0; +} +/** + * hchacha helper method, used primarily in xchacha, to hash + * key and nonce into key' and nonce'. + * Same as chachaCore, but there doesn't seem to be a way to move the block + * out without 25% performance hit. + */ +// prettier-ignore +export function hchacha( + s: Uint32Array, k: Uint32Array, i: Uint32Array, o32: Uint32Array +): void { + let x00 = s[0], x01 = s[1], x02 = s[2], x03 = s[3], + x04 = k[0], x05 = k[1], x06 = k[2], x07 = k[3], + x08 = k[4], x09 = k[5], x10 = k[6], x11 = k[7], + x12 = i[0], x13 = i[1], x14 = i[2], x15 = i[3]; + for (let r = 0; r < 20; r += 2) { + x00 = (x00 + x04) | 0; x12 = rotl(x12 ^ x00, 16); + x08 = (x08 + x12) | 0; x04 = rotl(x04 ^ x08, 12); + x00 = (x00 + x04) | 0; x12 = rotl(x12 ^ x00, 8); + x08 = (x08 + x12) | 0; x04 = rotl(x04 ^ x08, 7); + + x01 = (x01 + x05) | 0; x13 = rotl(x13 ^ x01, 16); + x09 = (x09 + x13) | 0; x05 = rotl(x05 ^ x09, 12); + x01 = (x01 + x05) | 0; x13 = rotl(x13 ^ x01, 8); + x09 = (x09 + x13) | 0; x05 = rotl(x05 ^ x09, 7); + + x02 = (x02 + x06) | 0; x14 = rotl(x14 ^ x02, 16); + x10 = (x10 + x14) | 0; x06 = rotl(x06 ^ x10, 12); + x02 = (x02 + x06) | 0; x14 = rotl(x14 ^ x02, 8); + x10 = (x10 + x14) | 0; x06 = rotl(x06 ^ x10, 7); + + x03 = (x03 + x07) | 0; x15 = rotl(x15 ^ x03, 16); + x11 = (x11 + x15) | 0; x07 = rotl(x07 ^ x11, 12); + x03 = (x03 + x07) | 0; x15 = rotl(x15 ^ x03, 8) + x11 = (x11 + x15) | 0; x07 = rotl(x07 ^ x11, 7); + + x00 = (x00 + x05) | 0; x15 = rotl(x15 ^ x00, 16); + x10 = (x10 + x15) | 0; x05 = rotl(x05 ^ x10, 12); + x00 = (x00 + x05) | 0; x15 = rotl(x15 ^ x00, 8); + x10 = (x10 + x15) | 0; x05 = rotl(x05 ^ x10, 7); + + x01 = (x01 + x06) | 0; x12 = rotl(x12 ^ x01, 16); + x11 = (x11 + x12) | 0; x06 = rotl(x06 ^ x11, 12); + x01 = (x01 + x06) | 0; x12 = rotl(x12 ^ x01, 8); + x11 = (x11 + x12) | 0; x06 = rotl(x06 ^ x11, 7); + + x02 = (x02 + x07) | 0; x13 = rotl(x13 ^ x02, 16); + x08 = (x08 + x13) | 0; x07 = rotl(x07 ^ x08, 12); + x02 = (x02 + x07) | 0; x13 = rotl(x13 ^ x02, 8); + x08 = (x08 + x13) | 0; x07 = rotl(x07 ^ x08, 7); + + x03 = (x03 + x04) | 0; x14 = rotl(x14 ^ x03, 16) + x09 = (x09 + x14) | 0; x04 = rotl(x04 ^ x09, 12); + x03 = (x03 + x04) | 0; x14 = rotl(x14 ^ x03, 8); + x09 = (x09 + x14) | 0; x04 = rotl(x04 ^ x09, 7); + } + let oi = 0; + o32[oi++] = x00; o32[oi++] = x01; + o32[oi++] = x02; o32[oi++] = x03; + o32[oi++] = x12; o32[oi++] = x13; + o32[oi++] = x14; o32[oi++] = x15; +} +/** + * Original, non-RFC chacha20 from DJB. 8-byte nonce, 8-byte counter. + */ +export const chacha20orig: XorStream = /* @__PURE__ */ createCipher(chachaCore, { + counterRight: false, + counterLength: 8, + allowShortKeys: true, +}); +/** + * ChaCha stream cipher. Conforms to RFC 8439 (IETF, TLS). 12-byte nonce, 4-byte counter. + * With 12-byte nonce, it's not safe to use fill it with random (CSPRNG), due to collision chance. + */ +export const chacha20: XorStream = /* @__PURE__ */ createCipher(chachaCore, { + counterRight: false, + counterLength: 4, + allowShortKeys: false, +}); + +/** + * XChaCha eXtended-nonce ChaCha. 24-byte nonce. + * With 24-byte nonce, it's safe to use fill it with random (CSPRNG). + * https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha + */ +export const xchacha20: XorStream = /* @__PURE__ */ createCipher(chachaCore, { + counterRight: false, + counterLength: 8, + extendNonceFn: hchacha, + allowShortKeys: false, +}); + +/** + * Reduced 8-round chacha, described in original paper. + */ +export const chacha8: XorStream = /* @__PURE__ */ createCipher(chachaCore, { + counterRight: false, + counterLength: 4, + rounds: 8, +}); + +/** + * Reduced 12-round chacha, described in original paper. + */ +export const chacha12: XorStream = /* @__PURE__ */ createCipher(chachaCore, { + counterRight: false, + counterLength: 4, + rounds: 12, +}); + +const ZEROS16 = /* @__PURE__ */ new Uint8Array(16); +// Pad to digest size with zeros +const updatePadded = (h: ReturnType, msg: Uint8Array) => { + h.update(msg); + const left = msg.length % 16; + if (left) h.update(ZEROS16.subarray(left)); +}; + +const ZEROS32 = /* @__PURE__ */ new Uint8Array(32); +function computeTag( + fn: XorStream, + key: Uint8Array, + nonce: Uint8Array, + data: Uint8Array, + AAD?: Uint8Array +): Uint8Array { + const authKey = fn(key, nonce, ZEROS32); + const h = poly1305.create(authKey); + if (AAD) updatePadded(h, AAD); + updatePadded(h, data); + const num = u64Lengths(data.length, AAD ? AAD.length : 0, true); + h.update(num); + const res = h.digest(); + clean(authKey, num); + return res; +} + +/** + * AEAD algorithm from RFC 8439. + * Salsa20 and chacha (RFC 8439) use poly1305 differently. + * We could have composed them similar to: + * https://github.com/paulmillr/scure-base/blob/b266c73dde977b1dd7ef40ef7a23cc15aab526b3/index.ts#L250 + * But it's hard because of authKey: + * In salsa20, authKey changes position in salsa stream. + * In chacha, authKey can't be computed inside computeTag, it modifies the counter. + */ +export const _poly1305_aead = + (xorStream: XorStream) => + (key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array): CipherWithOutput => { + const tagLength = 16; + return { + encrypt(plaintext: Uint8Array, output?: Uint8Array) { + const plength = plaintext.length; + output = getOutput(plength + tagLength, output, false); + output.set(plaintext); + const oPlain = output.subarray(0, -tagLength); + xorStream(key, nonce, oPlain, oPlain, 1); + const tag = computeTag(xorStream, key, nonce, oPlain, AAD); + output.set(tag, plength); // append tag + clean(tag); + return output; + }, + decrypt(ciphertext: Uint8Array, output?: Uint8Array) { + output = getOutput(ciphertext.length - tagLength, output, false); + const data = ciphertext.subarray(0, -tagLength); + const passedTag = ciphertext.subarray(-tagLength); + const tag = computeTag(xorStream, key, nonce, data, AAD); + if (!equalBytes(passedTag, tag)) throw new Error('invalid tag'); + output.set(ciphertext.subarray(0, -tagLength)); + xorStream(key, nonce, output, output, 1); // start stream with i=1 + clean(tag); + return output; + }, + }; + }; + +/** + * ChaCha20-Poly1305 from RFC 8439. + * + * Unsafe to use random nonces under the same key, due to collision chance. + * Prefer XChaCha instead. + */ +export const chacha20poly1305: ARXCipher = /* @__PURE__ */ wrapCipher( + { blockSize: 64, nonceLength: 12, tagLength: 16 }, + _poly1305_aead(chacha20) +); +/** + * XChaCha20-Poly1305 extended-nonce chacha. + * + * Can be safely used with random nonces (CSPRNG). + * See [IRTF draft](https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha). + */ +export const xchacha20poly1305: ARXCipher = /* @__PURE__ */ wrapCipher( + { blockSize: 64, nonceLength: 24, tagLength: 16 }, + _poly1305_aead(xchacha20) +); diff --git a/node_modules/@noble/ciphers/src/crypto.ts b/node_modules/@noble/ciphers/src/crypto.ts new file mode 100644 index 0000000000000000000000000000000000000000..61a59cff3cb2f8c08a51b83cea29366fe59e7f41 --- /dev/null +++ b/node_modules/@noble/ciphers/src/crypto.ts @@ -0,0 +1,9 @@ +/** + * Internal webcrypto alias. + * We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+. + * See utils.ts for details. + * @module + */ +declare const globalThis: Record | undefined; +export const crypto: any = + typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined; diff --git a/node_modules/@noble/ciphers/src/cryptoNode.ts b/node_modules/@noble/ciphers/src/cryptoNode.ts new file mode 100644 index 0000000000000000000000000000000000000000..53a3cc71adc217e8090d77b0d8ac7bba5b08ff0d --- /dev/null +++ b/node_modules/@noble/ciphers/src/cryptoNode.ts @@ -0,0 +1,15 @@ +/** + * Internal webcrypto alias. + * We prefer WebCrypto aka globalThis.crypto, which exists in node.js 16+. + * Falls back to Node.js built-in crypto for Node.js <=v14. + * See utils.ts for details. + * @module + */ +// @ts-ignore +import * as nc from 'node:crypto'; +export const crypto: any = + nc && typeof nc === 'object' && 'webcrypto' in nc + ? (nc.webcrypto as any) + : nc && typeof nc === 'object' && 'randomBytes' in nc + ? nc + : undefined; diff --git a/node_modules/@noble/ciphers/src/ff1.ts b/node_modules/@noble/ciphers/src/ff1.ts new file mode 100644 index 0000000000000000000000000000000000000000..2d4e7772aedc01184886803cdfc96a7347fb9667 --- /dev/null +++ b/node_modules/@noble/ciphers/src/ff1.ts @@ -0,0 +1,162 @@ +/** + * FPE-FF1 (Format-preserving encryption algorithm) specified in + * [NIST 800-38G](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38G.pdf). + * @module + */ +import { unsafe } from './aes.ts'; +import { type Cipher, abytes, anumber, bytesToNumberBE, clean, numberToBytesBE } from './utils.ts'; + +// NOTE: no point in inlining encrypt instead of encryptBlock, since BigInt stuff will be slow +const { expandKeyLE, encryptBlock } = unsafe; + +// Format-preserving encryption algorithm (FPE-FF1) specified in NIST Special Publication 800-38G. +// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38G.pdf + +const BLOCK_LEN = 16; + +// Calculates a modulo b +function mod(a: number, b: number): number; +function mod(a: bigint, b: bigint): bigint; +function mod(a: any, b: any): number | bigint { + const result = a % b; + return result >= 0 ? result : b + result; +} + +function NUMradix(radix: number, data: number[]): bigint { + let res = BigInt(0); + for (let i of data) res = res * BigInt(radix) + BigInt(i); + return res; +} + +function getRound(radix: number, key: Uint8Array, tweak: Uint8Array, x: number[]) { + if (radix > 2 ** 16 - 1) throw new Error('invalid radix ' + radix); + // radix**minlen ≥ 100 + const minLen = Math.ceil(Math.log(100) / Math.log(radix)); + const maxLen = 2 ** 32 - 1; + // 2 ≤ minlen ≤ maxlen < 2**32 + if (2 > minLen || minLen > maxLen || maxLen >= 2 ** 32) + throw new Error('Invalid radix: 2 ≤ minlen ≤ maxlen < 2**32'); + if (!Array.isArray(x)) throw new Error('invalid X'); + if (x.length < minLen || x.length > maxLen) throw new Error('X is outside minLen..maxLen bounds'); + const u = Math.floor(x.length / 2); + const v = x.length - u; + const b = Math.ceil(Math.ceil(v * Math.log2(radix)) / 8); + const d = 4 * Math.ceil(b / 4) + 4; + const padding = mod(-tweak.length - b - 1, 16); + // P = [1]1 || [2]1 || [1]1 || [radix]3 || [10]1 || [u mod 256]1 || [n]4 || [t]4. + const P = Uint8Array.from([1, 2, 1, 0, 0, 0, 10, u, 0, 0, 0, 0, 0, 0, 0, 0]); + const view = new DataView(P.buffer); + view.setUint16(4, radix, false); + view.setUint32(8, x.length, false); + view.setUint32(12, tweak.length, false); + // Q = T || [0](−t−b−1) mod 16 || [i]1 || [NUMradix(B)]b. + const PQ = new Uint8Array(P.length + tweak.length + padding + 1 + b); + PQ.set(P); + clean(P); + PQ.set(tweak, P.length); + const xk = expandKeyLE(key); + const round = (A: number[], B: number[], i: number, decrypt = false) => { + // Q = ... || [i]1 || [NUMradix(B)]b. + PQ[PQ.length - b - 1] = i; + if (b) PQ.set(numberToBytesBE(NUMradix(radix, B), b), PQ.length - b); + // PRF + let r = new Uint8Array(16); + for (let j = 0; j < PQ.length / BLOCK_LEN; j++) { + for (let i = 0; i < BLOCK_LEN; i++) r[i] ^= PQ[j * BLOCK_LEN + i]; + encryptBlock(xk, r); + } + // Let S be the first d bytes of the following string of ⎡d/16⎤ blocks: + // R || CIPHK(R ⊕[1]16) || CIPHK(R ⊕[2]16) ...CIPHK(R ⊕[⎡d / 16⎤ – 1]16). + let s = Array.from(r); + for (let j = 1; s.length < d; j++) { + const block = numberToBytesBE(BigInt(j), 16); + for (let k = 0; k < BLOCK_LEN; k++) block[k] ^= r[k]; + s.push(...Array.from(encryptBlock(xk, block))); + } + let y = bytesToNumberBE(Uint8Array.from(s.slice(0, d))); + s.fill(0); + if (decrypt) y = -y; + const m = i % 2 === 0 ? u : v; + let c = mod(NUMradix(radix, A) + y, BigInt(radix) ** BigInt(m)); + // STR(radix, m, c) + const C = Array(m).fill(0); + for (let i = 0; i < m; i++, c /= BigInt(radix)) C[m - 1 - i] = Number(c % BigInt(radix)); + A.fill(0); + A = B; + B = C; + return [A, B]; + }; + const destroy = () => { + clean(xk, PQ); + }; + return { u, round, destroy }; +} + +const EMPTY_BUF = /* @__PURE__ */ Uint8Array.of(); + +/** FPE-FF1 format-preserving encryption */ +export function FF1( + radix: number, + key: Uint8Array, + tweak: Uint8Array = EMPTY_BUF +): { encrypt(x: number[]): number[]; decrypt(x: number[]): number[] } { + anumber(radix); + abytes(key); + abytes(tweak); + const PQ = getRound.bind(null, radix, key, tweak); + return { + encrypt(x: number[]): number[] { + const { u, round, destroy } = PQ(x); + let [A, B] = [x.slice(0, u), x.slice(u)]; + for (let i = 0; i < 10; i++) [A, B] = round(A, B, i); + destroy(); + const res = A.concat(B); + A.fill(0); + B.fill(0); + return res; + }, + decrypt(x: number[]): number[] { + const { u, round, destroy } = PQ(x); + // The FF1.Decrypt algorithm is similar to the FF1.Encrypt algorithm; + // the differences are in Step 6, where: + // 1) the order of the indices is reversed, + // 2) the roles of A and B are swapped + // 3) modular addition is replaced by modular subtraction, in Step 6vi. + let [B, A] = [x.slice(0, u), x.slice(u)]; + for (let i = 9; i >= 0; i--) [A, B] = round(A, B, i, true); + destroy(); + const res = B.concat(A); + A.fill(0); + B.fill(0); + return res; + }, + }; +} +// Binary string which encodes each byte in little-endian byte order +const binLE = { + encode(bytes: Uint8Array): number[] { + const x = []; + for (let i = 0; i < bytes.length; i++) { + for (let j = 0, tmp = bytes[i]; j < 8; j++, tmp >>= 1) x.push(tmp & 1); + } + return x; + }, + decode(b: number[]): Uint8Array { + if (!Array.isArray(b) || b.length % 8) throw new Error('Invalid binary string'); + const res = new Uint8Array(b.length / 8); + for (let i = 0, j = 0; i < res.length; i++) { + res[i] = b[j++] | (b[j++] << 1) | (b[j++] << 2) | (b[j++] << 3); + res[i] |= (b[j++] << 4) | (b[j++] << 5) | (b[j++] << 6) | (b[j++] << 7); + } + return res; + }, +}; + +/** Binary version of FPE-FF1 format-preserving encryption. */ +export function BinaryFF1(key: Uint8Array, tweak: Uint8Array = EMPTY_BUF): Cipher { + const ff1 = FF1(2, key, tweak); + return { + encrypt: (x: Uint8Array) => binLE.decode(ff1.encrypt(binLE.encode(x))), + decrypt: (x: Uint8Array) => binLE.decode(ff1.decrypt(binLE.encode(x))), + }; +} diff --git a/node_modules/@noble/ciphers/src/index.ts b/node_modules/@noble/ciphers/src/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..4919d69b6d26abfb00032c42eaeb271975c44482 --- /dev/null +++ b/node_modules/@noble/ciphers/src/index.ts @@ -0,0 +1,26 @@ +/** + * Audited & minimal JS implementation of Salsa20, ChaCha and AES. Check out individual modules. + * @example +```js +import { gcm, siv } from '@noble/ciphers/aes'; +import { xsalsa20poly1305 } from '@noble/ciphers/salsa'; +import { secretbox } from '@noble/ciphers/salsa'; // == xsalsa20poly1305 +import { chacha20poly1305, xchacha20poly1305 } from '@noble/ciphers/chacha'; + +// Unauthenticated encryption: make sure to use HMAC or similar +import { ctr, cfb, cbc, ecb } from '@noble/ciphers/aes'; +import { salsa20, xsalsa20 } from '@noble/ciphers/salsa'; +import { chacha20, xchacha20, chacha8, chacha12 } from '@noble/ciphers/chacha'; + +// KW +import { aeskw, aeskwp } from '@noble/ciphers/aes'; + +// Utilities +import { bytesToHex, hexToBytes, bytesToUtf8, utf8ToBytes } from '@noble/ciphers/utils'; +import { managedNonce, randomBytes } from '@noble/ciphers/webcrypto'; +import { poly1305 } from '@noble/ciphers/_poly1305'; +import { ghash, polyval } from '@noble/ciphers/_polyval'; +``` + * @module + */ +throw new Error('root module cannot be imported: import submodules instead. Check out README'); diff --git a/node_modules/@noble/ciphers/src/package.json b/node_modules/@noble/ciphers/src/package.json new file mode 100644 index 0000000000000000000000000000000000000000..3dbc1ca591c0557e35b6004aeba250e6a70b56e3 --- /dev/null +++ b/node_modules/@noble/ciphers/src/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/node_modules/@noble/ciphers/src/salsa.ts b/node_modules/@noble/ciphers/src/salsa.ts new file mode 100644 index 0000000000000000000000000000000000000000..02a568debc7d09c727d92dc98b48f697c30217ca --- /dev/null +++ b/node_modules/@noble/ciphers/src/salsa.ts @@ -0,0 +1,189 @@ +/** + * [Salsa20](https://cr.yp.to/snuffle.html) stream cipher, released in 2005. + * + * Salsa's goal was to implement AES replacement that does not rely on S-Boxes, + * which are hard to implement in a constant-time manner. + * Salsa20 is usually faster than AES, a big deal on slow, budget mobile phones. + * + * [XSalsa20](https://cr.yp.to/snuffle/xsalsa-20110204.pdf), extended-nonce + * variant was released in 2008. It switched nonces from 96-bit to 192-bit, + * and became safe to be picked at random. + * + * Check out [PDF](https://cr.yp.to/snuffle/salsafamily-20071225.pdf) and + * [wiki](https://en.wikipedia.org/wiki/Salsa20). + * @module + */ +import { createCipher, rotl } from './_arx.ts'; +import { poly1305 } from './_poly1305.ts'; +import { + abytes, + type ARXCipher, + type CipherWithOutput, + clean, + equalBytes, + getOutput, + wrapCipher, + type XorStream, +} from './utils.ts'; + +/** Salsa20 core function. */ +// prettier-ignore +function salsaCore( + s: Uint32Array, k: Uint32Array, n: Uint32Array, out: Uint32Array, cnt: number, rounds = 20 +): void { + // Based on https://cr.yp.to/salsa20.html + let y00 = s[0], y01 = k[0], y02 = k[1], y03 = k[2], // "expa" Key Key Key + y04 = k[3], y05 = s[1], y06 = n[0], y07 = n[1], // Key "nd 3" Nonce Nonce + y08 = cnt, y09 = 0, y10 = s[2], y11 = k[4], // Pos. Pos. "2-by" Key + y12 = k[5], y13 = k[6], y14 = k[7], y15 = s[3]; // Key Key Key "te k" + // Save state to temporary variables + let x00 = y00, x01 = y01, x02 = y02, x03 = y03, + x04 = y04, x05 = y05, x06 = y06, x07 = y07, + x08 = y08, x09 = y09, x10 = y10, x11 = y11, + x12 = y12, x13 = y13, x14 = y14, x15 = y15; + for (let r = 0; r < rounds; r += 2) { + x04 ^= rotl(x00 + x12 | 0, 7); x08 ^= rotl(x04 + x00 | 0, 9); + x12 ^= rotl(x08 + x04 | 0, 13); x00 ^= rotl(x12 + x08 | 0, 18); + x09 ^= rotl(x05 + x01 | 0, 7); x13 ^= rotl(x09 + x05 | 0, 9); + x01 ^= rotl(x13 + x09 | 0, 13); x05 ^= rotl(x01 + x13 | 0, 18); + x14 ^= rotl(x10 + x06 | 0, 7); x02 ^= rotl(x14 + x10 | 0, 9); + x06 ^= rotl(x02 + x14 | 0, 13); x10 ^= rotl(x06 + x02 | 0, 18); + x03 ^= rotl(x15 + x11 | 0, 7); x07 ^= rotl(x03 + x15 | 0, 9); + x11 ^= rotl(x07 + x03 | 0, 13); x15 ^= rotl(x11 + x07 | 0, 18); + x01 ^= rotl(x00 + x03 | 0, 7); x02 ^= rotl(x01 + x00 | 0, 9); + x03 ^= rotl(x02 + x01 | 0, 13); x00 ^= rotl(x03 + x02 | 0, 18); + x06 ^= rotl(x05 + x04 | 0, 7); x07 ^= rotl(x06 + x05 | 0, 9); + x04 ^= rotl(x07 + x06 | 0, 13); x05 ^= rotl(x04 + x07 | 0, 18); + x11 ^= rotl(x10 + x09 | 0, 7); x08 ^= rotl(x11 + x10 | 0, 9); + x09 ^= rotl(x08 + x11 | 0, 13); x10 ^= rotl(x09 + x08 | 0, 18); + x12 ^= rotl(x15 + x14 | 0, 7); x13 ^= rotl(x12 + x15 | 0, 9); + x14 ^= rotl(x13 + x12 | 0, 13); x15 ^= rotl(x14 + x13 | 0, 18); + } + // Write output + let oi = 0; + out[oi++] = (y00 + x00) | 0; out[oi++] = (y01 + x01) | 0; + out[oi++] = (y02 + x02) | 0; out[oi++] = (y03 + x03) | 0; + out[oi++] = (y04 + x04) | 0; out[oi++] = (y05 + x05) | 0; + out[oi++] = (y06 + x06) | 0; out[oi++] = (y07 + x07) | 0; + out[oi++] = (y08 + x08) | 0; out[oi++] = (y09 + x09) | 0; + out[oi++] = (y10 + x10) | 0; out[oi++] = (y11 + x11) | 0; + out[oi++] = (y12 + x12) | 0; out[oi++] = (y13 + x13) | 0; + out[oi++] = (y14 + x14) | 0; out[oi++] = (y15 + x15) | 0; +} + +/** + * hsalsa hashing function, used primarily in xsalsa, to hash + * key and nonce into key' and nonce'. + * Same as salsaCore, but there doesn't seem to be a way to move the block + * out without 25% performance hit. + */ +// prettier-ignore +export function hsalsa( + s: Uint32Array, k: Uint32Array, i: Uint32Array, o32: Uint32Array +): void { + let x00 = s[0], x01 = k[0], x02 = k[1], x03 = k[2], + x04 = k[3], x05 = s[1], x06 = i[0], x07 = i[1], + x08 = i[2], x09 = i[3], x10 = s[2], x11 = k[4], + x12 = k[5], x13 = k[6], x14 = k[7], x15 = s[3]; + for (let r = 0; r < 20; r += 2) { + x04 ^= rotl(x00 + x12 | 0, 7); x08 ^= rotl(x04 + x00 | 0, 9); + x12 ^= rotl(x08 + x04 | 0, 13); x00 ^= rotl(x12 + x08 | 0, 18); + x09 ^= rotl(x05 + x01 | 0, 7); x13 ^= rotl(x09 + x05 | 0, 9); + x01 ^= rotl(x13 + x09 | 0, 13); x05 ^= rotl(x01 + x13 | 0, 18); + x14 ^= rotl(x10 + x06 | 0, 7); x02 ^= rotl(x14 + x10 | 0, 9); + x06 ^= rotl(x02 + x14 | 0, 13); x10 ^= rotl(x06 + x02 | 0, 18); + x03 ^= rotl(x15 + x11 | 0, 7); x07 ^= rotl(x03 + x15 | 0, 9); + x11 ^= rotl(x07 + x03 | 0, 13); x15 ^= rotl(x11 + x07 | 0, 18); + x01 ^= rotl(x00 + x03 | 0, 7); x02 ^= rotl(x01 + x00 | 0, 9); + x03 ^= rotl(x02 + x01 | 0, 13); x00 ^= rotl(x03 + x02 | 0, 18); + x06 ^= rotl(x05 + x04 | 0, 7); x07 ^= rotl(x06 + x05 | 0, 9); + x04 ^= rotl(x07 + x06 | 0, 13); x05 ^= rotl(x04 + x07 | 0, 18); + x11 ^= rotl(x10 + x09 | 0, 7); x08 ^= rotl(x11 + x10 | 0, 9); + x09 ^= rotl(x08 + x11 | 0, 13); x10 ^= rotl(x09 + x08 | 0, 18); + x12 ^= rotl(x15 + x14 | 0, 7); x13 ^= rotl(x12 + x15 | 0, 9); + x14 ^= rotl(x13 + x12 | 0, 13); x15 ^= rotl(x14 + x13 | 0, 18); + } + let oi = 0; + o32[oi++] = x00; o32[oi++] = x05; + o32[oi++] = x10; o32[oi++] = x15; + o32[oi++] = x06; o32[oi++] = x07; + o32[oi++] = x08; o32[oi++] = x09; +} + +/** + * Salsa20 from original paper. + * Unsafe to use random nonces under the same key, due to collision chance. + * Prefer XSalsa instead. + */ +export const salsa20: XorStream = /* @__PURE__ */ createCipher(salsaCore, { + allowShortKeys: true, + counterRight: true, +}); + +/** + * xsalsa20 eXtended-nonce salsa. + * Can be safely used with random 24-byte nonces (CSPRNG). + */ +export const xsalsa20: XorStream = /* @__PURE__ */ createCipher(salsaCore, { + counterRight: true, + extendNonceFn: hsalsa, +}); + +/** + * xsalsa20-poly1305 eXtended-nonce salsa. + * Can be safely used with random 24-byte nonces (CSPRNG). + * Also known as secretbox from libsodium / nacl. + */ +export const xsalsa20poly1305: ARXCipher = /* @__PURE__ */ wrapCipher( + { blockSize: 64, nonceLength: 24, tagLength: 16 }, + (key: Uint8Array, nonce: Uint8Array): CipherWithOutput => { + return { + encrypt(plaintext: Uint8Array, output?: Uint8Array) { + // xsalsa20poly1305 optimizes by calculating auth key during the same call as encryption. + // Unfortunately, makes it hard to separate tag calculation & encryption itself, + // because 32 bytes is half-block of 64-byte salsa. + output = getOutput(plaintext.length + 32, output, false); // need 32 additional bytes, see above + const authKey = output.subarray(0, 32); // output[0..32] = poly1305 auth key + const ciphPlaintext = output.subarray(32); // output[32..] = plaintext, then ciphertext + output.set(plaintext, 32); + clean(authKey); // authKey is produced by xoring with zeros + xsalsa20(key, nonce, output, output); // output = stream ^ output; authKey = stream ^ zeros(32) + const tag = poly1305(ciphPlaintext, authKey); // calculate tag over ciphertext + output.set(tag, 16); // output[16..32] = tag + clean(output.subarray(0, 16), tag); // clean-up authKey remnants & copy of tag + return output.subarray(16); // return output[16..] + }, + decrypt(ciphertext: Uint8Array, output?: Uint8Array) { + // tmp part passed tag ciphertext + // [0..32] [32..48] [48..] + abytes(ciphertext); + output = getOutput(ciphertext.length + 32, output, false); + const tmp = output.subarray(0, 32); // output[0..32] is used to calc authKey + const passedTag = output.subarray(32, 48); // output[32..48] = passed tag + const ciphPlaintext = output.subarray(48); // output[48..] = ciphertext, then plaintext + output.set(ciphertext, 32); // copy ciphertext into output + clean(tmp); // authKey is produced by xoring with zeros + const authKey = xsalsa20(key, nonce, tmp, tmp); // authKey = stream ^ zeros(32) + const tag = poly1305(ciphPlaintext, authKey); // calculate tag over ciphertext + if (!equalBytes(passedTag, tag)) throw new Error('invalid tag'); + xsalsa20(key, nonce, output.subarray(16), output.subarray(16)); // output = stream ^ output[16..] + clean(tmp, passedTag, tag); + return ciphPlaintext; // return output[48..], skipping zeroized output[0..48] + }, + }; + } +); + +/** + * Alias to `xsalsa20poly1305`, for compatibility with libsodium / nacl + */ +export function secretbox( + key: Uint8Array, + nonce: Uint8Array +): { + seal: (plaintext: Uint8Array, output?: Uint8Array) => Uint8Array; + open: (ciphertext: Uint8Array, output?: Uint8Array) => Uint8Array; +} { + const xs = xsalsa20poly1305(key, nonce); + return { seal: xs.encrypt, open: xs.decrypt }; +} diff --git a/node_modules/@noble/ciphers/src/utils.ts b/node_modules/@noble/ciphers/src/utils.ts new file mode 100644 index 0000000000000000000000000000000000000000..37b65418c8a7790309c038087b7d7af369c1b277 --- /dev/null +++ b/node_modules/@noble/ciphers/src/utils.ts @@ -0,0 +1,453 @@ +/** + * Utilities for hex, bytes, CSPRNG. + * @module + */ +/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */ + +/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */ +export function isBytes(a: unknown): a is Uint8Array { + return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array'); +} + +/** Asserts something is boolean. */ +export function abool(b: boolean): void { + if (typeof b !== 'boolean') throw new Error(`boolean expected, not ${b}`); +} + +/** Asserts something is positive integer. */ +export function anumber(n: number): void { + if (!Number.isSafeInteger(n) || n < 0) throw new Error('positive integer expected, got ' + n); +} + +/** Asserts something is Uint8Array. */ +export function abytes(b: Uint8Array | undefined, ...lengths: number[]): void { + if (!isBytes(b)) throw new Error('Uint8Array expected'); + if (lengths.length > 0 && !lengths.includes(b.length)) + throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length); +} + +/** + * Asserts something is hash + * TODO: remove + * @deprecated + */ +export function ahash(h: IHash): void { + if (typeof h !== 'function' || typeof h.create !== 'function') + throw new Error('Hash should be wrapped by utils.createHasher'); + anumber(h.outputLen); + anumber(h.blockLen); +} + +/** Asserts a hash instance has not been destroyed / finished */ +export function aexists(instance: any, checkFinished = true): void { + if (instance.destroyed) throw new Error('Hash instance has been destroyed'); + if (checkFinished && instance.finished) throw new Error('Hash#digest() has already been called'); +} + +/** Asserts output is properly-sized byte array */ +export function aoutput(out: any, instance: any): void { + abytes(out); + const min = instance.outputLen; + if (out.length < min) { + throw new Error('digestInto() expects output buffer of length at least ' + min); + } +} + +export type IHash = { + (data: string | Uint8Array): Uint8Array; + blockLen: number; + outputLen: number; + create: any; +}; + +/** Generic type encompassing 8/16/32-byte arrays - but not 64-byte. */ +// prettier-ignore +export type TypedArray = Int8Array | Uint8ClampedArray | Uint8Array | + Uint16Array | Int16Array | Uint32Array | Int32Array; + +/** Cast u8 / u16 / u32 to u8. */ +export function u8(arr: TypedArray): Uint8Array { + return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength); +} + +/** Cast u8 / u16 / u32 to u32. */ +export function u32(arr: TypedArray): Uint32Array { + return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4)); +} + +/** Zeroize a byte array. Warning: JS provides no guarantees. */ +export function clean(...arrays: TypedArray[]): void { + for (let i = 0; i < arrays.length; i++) { + arrays[i].fill(0); + } +} + +/** Create DataView of an array for easy byte-level manipulation. */ +export function createView(arr: TypedArray): DataView { + return new DataView(arr.buffer, arr.byteOffset, arr.byteLength); +} + +/** Is current platform little-endian? Most are. Big-Endian platform: IBM */ +export const isLE: boolean = /* @__PURE__ */ (() => + new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)(); + +// Built-in hex conversion https://caniuse.com/mdn-javascript_builtins_uint8array_fromhex +const hasHexBuiltin: boolean = /* @__PURE__ */ (() => + // @ts-ignore + typeof Uint8Array.from([]).toHex === 'function' && typeof Uint8Array.fromHex === 'function')(); + +// Array where index 0xf0 (240) is mapped to string 'f0' +const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => + i.toString(16).padStart(2, '0') +); + +/** + * Convert byte array to hex string. Uses built-in function, when available. + * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123' + */ +export function bytesToHex(bytes: Uint8Array): string { + abytes(bytes); + // @ts-ignore + if (hasHexBuiltin) return bytes.toHex(); + // pre-caching improves the speed 6x + let hex = ''; + for (let i = 0; i < bytes.length; i++) { + hex += hexes[bytes[i]]; + } + return hex; +} + +// We use optimized technique to convert hex string to byte array +const asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 } as const; +function asciiToBase16(ch: number): number | undefined { + if (ch >= asciis._0 && ch <= asciis._9) return ch - asciis._0; // '2' => 50-48 + if (ch >= asciis.A && ch <= asciis.F) return ch - (asciis.A - 10); // 'B' => 66-(65-10) + if (ch >= asciis.a && ch <= asciis.f) return ch - (asciis.a - 10); // 'b' => 98-(97-10) + return; +} + +/** + * Convert hex string to byte array. Uses built-in function, when available. + * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23]) + */ +export function hexToBytes(hex: string): Uint8Array { + if (typeof hex !== 'string') throw new Error('hex string expected, got ' + typeof hex); + // @ts-ignore + if (hasHexBuiltin) return Uint8Array.fromHex(hex); + const hl = hex.length; + const al = hl / 2; + if (hl % 2) throw new Error('hex string expected, got unpadded hex of length ' + hl); + const array = new Uint8Array(al); + for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) { + const n1 = asciiToBase16(hex.charCodeAt(hi)); + const n2 = asciiToBase16(hex.charCodeAt(hi + 1)); + if (n1 === undefined || n2 === undefined) { + const char = hex[hi] + hex[hi + 1]; + throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi); + } + array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163 + } + return array; +} + +// Used in micro +export function hexToNumber(hex: string): bigint { + if (typeof hex !== 'string') throw new Error('hex string expected, got ' + typeof hex); + return BigInt(hex === '' ? '0' : '0x' + hex); // Big Endian +} + +// Used in ff1 +// BE: Big Endian, LE: Little Endian +export function bytesToNumberBE(bytes: Uint8Array): bigint { + return hexToNumber(bytesToHex(bytes)); +} + +// Used in micro, ff1 +export function numberToBytesBE(n: number | bigint, len: number): Uint8Array { + return hexToBytes(n.toString(16).padStart(len * 2, '0')); +} + +// TODO: remove +// There is no setImmediate in browser and setTimeout is slow. +// call of async fn will return Promise, which will be fullfiled only on +// next scheduler queue processing step and this is exactly what we need. +export const nextTick = async (): Promise => {}; + +// Global symbols, but ts doesn't see them: https://github.com/microsoft/TypeScript/issues/31535 +declare const TextEncoder: any; +declare const TextDecoder: any; + +/** + * Converts string to bytes using UTF8 encoding. + * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99]) + */ +export function utf8ToBytes(str: string): Uint8Array { + if (typeof str !== 'string') throw new Error('string expected'); + return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809 +} + +/** + * Converts bytes to string using UTF8 encoding. + * @example bytesToUtf8(new Uint8Array([97, 98, 99])) // 'abc' + */ +export function bytesToUtf8(bytes: Uint8Array): string { + return new TextDecoder().decode(bytes); +} + +// TODO: remove +export type Input = Uint8Array | string; +/** + * Normalizes (non-hex) string or Uint8Array to Uint8Array. + * Warning: when Uint8Array is passed, it would NOT get copied. + * Keep in mind for future mutable operations. + */ +export function toBytes(data: string | Uint8Array): Uint8Array { + if (typeof data === 'string') data = utf8ToBytes(data); + else if (isBytes(data)) data = copyBytes(data); + else throw new Error('Uint8Array expected, got ' + typeof data); + return data; +} + +/** + * Checks if two U8A use same underlying buffer and overlaps. + * This is invalid and can corrupt data. + */ +export function overlapBytes(a: Uint8Array, b: Uint8Array): boolean { + return ( + a.buffer === b.buffer && // best we can do, may fail with an obscure Proxy + a.byteOffset < b.byteOffset + b.byteLength && // a starts before b end + b.byteOffset < a.byteOffset + a.byteLength // b starts before a end + ); +} + +/** + * If input and output overlap and input starts before output, we will overwrite end of input before + * we start processing it, so this is not supported for most ciphers (except chacha/salse, which designed with this) + */ +export function complexOverlapBytes(input: Uint8Array, output: Uint8Array): void { + // This is very cursed. It works somehow, but I'm completely unsure, + // reasoning about overlapping aligned windows is very hard. + if (overlapBytes(input, output) && input.byteOffset < output.byteOffset) + throw new Error('complex overlap of input and output is not supported'); +} + +/** + * Copies several Uint8Arrays into one. + */ +export function concatBytes(...arrays: Uint8Array[]): Uint8Array { + let sum = 0; + for (let i = 0; i < arrays.length; i++) { + const a = arrays[i]; + abytes(a); + sum += a.length; + } + const res = new Uint8Array(sum); + for (let i = 0, pad = 0; i < arrays.length; i++) { + const a = arrays[i]; + res.set(a, pad); + pad += a.length; + } + return res; +} + +// Used in ARX only +type EmptyObj = {}; +export function checkOpts( + defaults: T1, + opts: T2 +): T1 & T2 { + if (opts == null || typeof opts !== 'object') throw new Error('options must be defined'); + const merged = Object.assign(defaults, opts); + return merged as T1 & T2; +} + +/** Compares 2 uint8array-s in kinda constant time. */ +export function equalBytes(a: Uint8Array, b: Uint8Array): boolean { + if (a.length !== b.length) return false; + let diff = 0; + for (let i = 0; i < a.length; i++) diff |= a[i] ^ b[i]; + return diff === 0; +} + +// TODO: remove +/** For runtime check if class implements interface. */ +export abstract class Hash> { + abstract blockLen: number; // Bytes per block + abstract outputLen: number; // Bytes in output + abstract update(buf: string | Uint8Array): this; + // Writes digest into buf + abstract digestInto(buf: Uint8Array): void; + abstract digest(): Uint8Array; + /** + * Resets internal state. Makes Hash instance unusable. + * Reset is impossible for keyed hashes if key is consumed into state. If digest is not consumed + * by user, they will need to manually call `destroy()` when zeroing is necessary. + */ + abstract destroy(): void; +} + +// This will allow to re-use with composable things like packed & base encoders +// Also, we probably can make tags composable + +/** Sync cipher: takes byte array and returns byte array. */ +export type Cipher = { + encrypt(plaintext: Uint8Array): Uint8Array; + decrypt(ciphertext: Uint8Array): Uint8Array; +}; + +/** Async cipher e.g. from built-in WebCrypto. */ +export type AsyncCipher = { + encrypt(plaintext: Uint8Array): Promise; + decrypt(ciphertext: Uint8Array): Promise; +}; + +/** Cipher with `output` argument which can optimize by doing 1 less allocation. */ +export type CipherWithOutput = Cipher & { + encrypt(plaintext: Uint8Array, output?: Uint8Array): Uint8Array; + decrypt(ciphertext: Uint8Array, output?: Uint8Array): Uint8Array; +}; + +/** + * Params are outside of return type, so it is accessible before calling constructor. + * If function support multiple nonceLength's, we return the best one. + */ +export type CipherParams = { + blockSize: number; + nonceLength?: number; + tagLength?: number; + varSizeNonce?: boolean; +}; +/** ARX cipher, like salsa or chacha. */ +export type ARXCipher = (( + key: Uint8Array, + nonce: Uint8Array, + AAD?: Uint8Array +) => CipherWithOutput) & { + blockSize: number; + nonceLength: number; + tagLength: number; +}; +export type CipherCons = (key: Uint8Array, ...args: T) => Cipher; +/** + * Wraps a cipher: validates args, ensures encrypt() can only be called once. + * @__NO_SIDE_EFFECTS__ + */ +export const wrapCipher = , P extends CipherParams>( + params: P, + constructor: C +): C & P => { + function wrappedCipher(key: Uint8Array, ...args: any[]): CipherWithOutput { + // Validate key + abytes(key); + + // Big-Endian hardware is rare. Just in case someone still decides to run ciphers: + if (!isLE) throw new Error('Non little-endian hardware is not yet supported'); + + // Validate nonce if nonceLength is present + if (params.nonceLength !== undefined) { + const nonce = args[0]; + if (!nonce) throw new Error('nonce / iv required'); + if (params.varSizeNonce) abytes(nonce); + else abytes(nonce, params.nonceLength); + } + + // Validate AAD if tagLength present + const tagl = params.tagLength; + if (tagl && args[1] !== undefined) { + abytes(args[1]); + } + + const cipher = constructor(key, ...args); + const checkOutput = (fnLength: number, output?: Uint8Array) => { + if (output !== undefined) { + if (fnLength !== 2) throw new Error('cipher output not supported'); + abytes(output); + } + }; + // Create wrapped cipher with validation and single-use encryption + let called = false; + const wrCipher = { + encrypt(data: Uint8Array, output?: Uint8Array) { + if (called) throw new Error('cannot encrypt() twice with same key + nonce'); + called = true; + abytes(data); + checkOutput(cipher.encrypt.length, output); + return (cipher as CipherWithOutput).encrypt(data, output); + }, + decrypt(data: Uint8Array, output?: Uint8Array) { + abytes(data); + if (tagl && data.length < tagl) + throw new Error('invalid ciphertext length: smaller than tagLength=' + tagl); + checkOutput(cipher.decrypt.length, output); + return (cipher as CipherWithOutput).decrypt(data, output); + }, + }; + + return wrCipher; + } + + Object.assign(wrappedCipher, params); + return wrappedCipher as C & P; +}; + +/** Represents salsa / chacha stream. */ +export type XorStream = ( + key: Uint8Array, + nonce: Uint8Array, + data: Uint8Array, + output?: Uint8Array, + counter?: number +) => Uint8Array; + +/** + * By default, returns u8a of length. + * When out is available, it checks it for validity and uses it. + */ +export function getOutput( + expectedLength: number, + out?: Uint8Array, + onlyAligned = true +): Uint8Array { + if (out === undefined) return new Uint8Array(expectedLength); + if (out.length !== expectedLength) + throw new Error('invalid output length, expected ' + expectedLength + ', got: ' + out.length); + if (onlyAligned && !isAligned32(out)) throw new Error('invalid output, must be aligned'); + return out; +} + +/** Polyfill for Safari 14. */ +export function setBigUint64( + view: DataView, + byteOffset: number, + value: bigint, + isLE: boolean +): void { + if (typeof view.setBigUint64 === 'function') return view.setBigUint64(byteOffset, value, isLE); + const _32n = BigInt(32); + const _u32_max = BigInt(0xffffffff); + const wh = Number((value >> _32n) & _u32_max); + const wl = Number(value & _u32_max); + const h = isLE ? 4 : 0; + const l = isLE ? 0 : 4; + view.setUint32(byteOffset + h, wh, isLE); + view.setUint32(byteOffset + l, wl, isLE); +} + +export function u64Lengths(dataLength: number, aadLength: number, isLE: boolean): Uint8Array { + abool(isLE); + const num = new Uint8Array(16); + const view = createView(num); + setBigUint64(view, 0, BigInt(aadLength), isLE); + setBigUint64(view, 8, BigInt(dataLength), isLE); + return num; +} + +// Is byte array aligned to 4 byte offset (u32)? +export function isAligned32(bytes: Uint8Array): boolean { + return bytes.byteOffset % 4 === 0; +} + +// copy bytes to new u8a (aligned). Because Buffer.slice is broken. +export function copyBytes(bytes: Uint8Array): Uint8Array { + return Uint8Array.from(bytes); +} diff --git a/node_modules/@noble/ciphers/src/webcrypto.ts b/node_modules/@noble/ciphers/src/webcrypto.ts new file mode 100644 index 0000000000000000000000000000000000000000..b82b4e7c3e2dd45ed5d89b98030148ae44e14645 --- /dev/null +++ b/node_modules/@noble/ciphers/src/webcrypto.ts @@ -0,0 +1,169 @@ +/** + * WebCrypto-based AES gcm/ctr/cbc, `managedNonce` and `randomBytes`. + * We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+. + * node.js versions earlier than v19 don't declare it in global scope. + * For node.js, package.js on#exports field mapping rewrites import + * from `crypto` to `cryptoNode`, which imports native module. + * Makes the utils un-importable in browsers without a bundler. + * Once node.js 18 is deprecated, we can just drop the import. + * @module + */ +// Use full path so that Node.js can rewrite it to `cryptoNode.js`. +import { crypto } from '@noble/ciphers/crypto'; +import { abytes, anumber, type AsyncCipher, type Cipher, concatBytes } from './utils.ts'; + +/** + * Secure PRNG. Uses `crypto.getRandomValues`, which defers to OS. + */ +export function randomBytes(bytesLength = 32): Uint8Array { + if (crypto && typeof crypto.getRandomValues === 'function') { + return crypto.getRandomValues(new Uint8Array(bytesLength)); + } + // Legacy Node.js compatibility + if (crypto && typeof crypto.randomBytes === 'function') { + return Uint8Array.from(crypto.randomBytes(bytesLength)); + } + throw new Error('crypto.getRandomValues must be defined'); +} + +export function getWebcryptoSubtle(): any { + if (crypto && typeof crypto.subtle === 'object' && crypto.subtle != null) return crypto.subtle; + throw new Error('crypto.subtle must be defined'); +} + +type RemoveNonceInner = ((...args: T) => Ret) extends ( + arg0: any, + arg1: any, + ...rest: infer R +) => any + ? (key: Uint8Array, ...args: R) => Ret + : never; + +type RemoveNonce any> = RemoveNonceInner, ReturnType>; +type CipherWithNonce = ((key: Uint8Array, nonce: Uint8Array, ...args: any[]) => Cipher) & { + nonceLength: number; +}; + +/** + * Uses CSPRG for nonce, nonce injected in ciphertext. + * @example + * const gcm = managedNonce(aes.gcm); + * const ciphr = gcm(key).encrypt(data); + * const plain = gcm(key).decrypt(ciph); + */ +export function managedNonce(fn: T): RemoveNonce { + const { nonceLength } = fn; + anumber(nonceLength); + return ((key: Uint8Array, ...args: any[]): any => ({ + encrypt(plaintext: Uint8Array, ...argsEnc: any[]) { + const nonce = randomBytes(nonceLength); + const ciphertext = (fn(key, nonce, ...args).encrypt as any)(plaintext, ...argsEnc); + const out = concatBytes(nonce, ciphertext); + ciphertext.fill(0); + return out; + }, + decrypt(ciphertext: Uint8Array, ...argsDec: any[]) { + const nonce = ciphertext.subarray(0, nonceLength); + const data = ciphertext.subarray(nonceLength); + return (fn(key, nonce, ...args).decrypt as any)(data, ...argsDec); + }, + })) as RemoveNonce; +} + +// Overridable +// @TODO +export const utils: { + encrypt: (key: Uint8Array, ...all: any[]) => Promise; + decrypt: (key: Uint8Array, ...all: any[]) => Promise; +} = { + async encrypt( + key: Uint8Array, + keyParams: any, + cryptParams: any, + plaintext: Uint8Array + ): Promise { + const cr = getWebcryptoSubtle(); + const iKey = await cr.importKey('raw', key, keyParams, true, ['encrypt']); + const ciphertext = await cr.encrypt(cryptParams, iKey, plaintext); + return new Uint8Array(ciphertext); + }, + async decrypt( + key: Uint8Array, + keyParams: any, + cryptParams: any, + ciphertext: Uint8Array + ): Promise { + const cr = getWebcryptoSubtle(); + const iKey = await cr.importKey('raw', key, keyParams, true, ['decrypt']); + const plaintext = await cr.decrypt(cryptParams, iKey, ciphertext); + return new Uint8Array(plaintext); + }, +}; + +const mode = { + CBC: 'AES-CBC', + CTR: 'AES-CTR', + GCM: 'AES-GCM', +} as const; +type BlockMode = (typeof mode)[keyof typeof mode]; + +function getCryptParams(algo: BlockMode, nonce: Uint8Array, AAD?: Uint8Array) { + if (algo === mode.CBC) return { name: mode.CBC, iv: nonce }; + if (algo === mode.CTR) return { name: mode.CTR, counter: nonce, length: 64 }; + if (algo === mode.GCM) { + if (AAD) return { name: mode.GCM, iv: nonce, additionalData: AAD }; + else return { name: mode.GCM, iv: nonce }; + } + + throw new Error('unknown aes block mode'); +} + +function generate(algo: BlockMode) { + return (key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array): AsyncCipher => { + abytes(key); + abytes(nonce); + const keyParams = { name: algo, length: key.length * 8 }; + const cryptParams = getCryptParams(algo, nonce, AAD); + let consumed = false; + return { + // keyLength, + encrypt(plaintext: Uint8Array) { + abytes(plaintext); + if (consumed) throw new Error('Cannot encrypt() twice with same key / nonce'); + consumed = true; + return utils.encrypt(key, keyParams, cryptParams, plaintext); + }, + decrypt(ciphertext: Uint8Array) { + abytes(ciphertext); + return utils.decrypt(key, keyParams, cryptParams, ciphertext); + }, + }; + }; +} + +/** AES-CBC, native webcrypto version */ +export const cbc: (key: Uint8Array, iv: Uint8Array) => AsyncCipher = /* @__PURE__ */ (() => + generate(mode.CBC))(); +/** AES-CTR, native webcrypto version */ +export const ctr: (key: Uint8Array, nonce: Uint8Array) => AsyncCipher = /* @__PURE__ */ (() => + generate(mode.CTR))(); +/** AES-GCM, native webcrypto version */ +export const gcm: (key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => AsyncCipher = + /* @__PURE__ */ (() => generate(mode.GCM))(); + +// // Type tests +// import { siv, gcm, ctr, ecb, cbc } from '../aes.ts'; +// import { xsalsa20poly1305 } from '../salsa.ts'; +// import { chacha20poly1305, xchacha20poly1305 } from '../chacha.ts'; + +// const wsiv = managedNonce(siv); +// const wgcm = managedNonce(gcm); +// const wctr = managedNonce(ctr); +// const wcbc = managedNonce(cbc); +// const wsalsapoly = managedNonce(xsalsa20poly1305); +// const wchacha = managedNonce(chacha20poly1305); +// const wxchacha = managedNonce(xchacha20poly1305); + +// // should fail +// const wcbc2 = managedNonce(managedNonce(cbc)); +// const wctr = managedNonce(ctr); diff --git a/node_modules/@noble/ciphers/utils.d.ts b/node_modules/@noble/ciphers/utils.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5194ed083312db0e8d719f84264b51693eb28fe7 --- /dev/null +++ b/node_modules/@noble/ciphers/utils.d.ts @@ -0,0 +1,155 @@ +/** + * Utilities for hex, bytes, CSPRNG. + * @module + */ +/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */ +/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */ +export declare function isBytes(a: unknown): a is Uint8Array; +/** Asserts something is boolean. */ +export declare function abool(b: boolean): void; +/** Asserts something is positive integer. */ +export declare function anumber(n: number): void; +/** Asserts something is Uint8Array. */ +export declare function abytes(b: Uint8Array | undefined, ...lengths: number[]): void; +/** + * Asserts something is hash + * TODO: remove + * @deprecated + */ +export declare function ahash(h: IHash): void; +/** Asserts a hash instance has not been destroyed / finished */ +export declare function aexists(instance: any, checkFinished?: boolean): void; +/** Asserts output is properly-sized byte array */ +export declare function aoutput(out: any, instance: any): void; +export type IHash = { + (data: string | Uint8Array): Uint8Array; + blockLen: number; + outputLen: number; + create: any; +}; +/** Generic type encompassing 8/16/32-byte arrays - but not 64-byte. */ +export type TypedArray = Int8Array | Uint8ClampedArray | Uint8Array | Uint16Array | Int16Array | Uint32Array | Int32Array; +/** Cast u8 / u16 / u32 to u8. */ +export declare function u8(arr: TypedArray): Uint8Array; +/** Cast u8 / u16 / u32 to u32. */ +export declare function u32(arr: TypedArray): Uint32Array; +/** Zeroize a byte array. Warning: JS provides no guarantees. */ +export declare function clean(...arrays: TypedArray[]): void; +/** Create DataView of an array for easy byte-level manipulation. */ +export declare function createView(arr: TypedArray): DataView; +/** Is current platform little-endian? Most are. Big-Endian platform: IBM */ +export declare const isLE: boolean; +/** + * Convert byte array to hex string. Uses built-in function, when available. + * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123' + */ +export declare function bytesToHex(bytes: Uint8Array): string; +/** + * Convert hex string to byte array. Uses built-in function, when available. + * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23]) + */ +export declare function hexToBytes(hex: string): Uint8Array; +export declare function hexToNumber(hex: string): bigint; +export declare function bytesToNumberBE(bytes: Uint8Array): bigint; +export declare function numberToBytesBE(n: number | bigint, len: number): Uint8Array; +export declare const nextTick: () => Promise; +/** + * Converts string to bytes using UTF8 encoding. + * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99]) + */ +export declare function utf8ToBytes(str: string): Uint8Array; +/** + * Converts bytes to string using UTF8 encoding. + * @example bytesToUtf8(new Uint8Array([97, 98, 99])) // 'abc' + */ +export declare function bytesToUtf8(bytes: Uint8Array): string; +export type Input = Uint8Array | string; +/** + * Normalizes (non-hex) string or Uint8Array to Uint8Array. + * Warning: when Uint8Array is passed, it would NOT get copied. + * Keep in mind for future mutable operations. + */ +export declare function toBytes(data: string | Uint8Array): Uint8Array; +/** + * Checks if two U8A use same underlying buffer and overlaps. + * This is invalid and can corrupt data. + */ +export declare function overlapBytes(a: Uint8Array, b: Uint8Array): boolean; +/** + * If input and output overlap and input starts before output, we will overwrite end of input before + * we start processing it, so this is not supported for most ciphers (except chacha/salse, which designed with this) + */ +export declare function complexOverlapBytes(input: Uint8Array, output: Uint8Array): void; +/** + * Copies several Uint8Arrays into one. + */ +export declare function concatBytes(...arrays: Uint8Array[]): Uint8Array; +type EmptyObj = {}; +export declare function checkOpts(defaults: T1, opts: T2): T1 & T2; +/** Compares 2 uint8array-s in kinda constant time. */ +export declare function equalBytes(a: Uint8Array, b: Uint8Array): boolean; +/** For runtime check if class implements interface. */ +export declare abstract class Hash> { + abstract blockLen: number; + abstract outputLen: number; + abstract update(buf: string | Uint8Array): this; + abstract digestInto(buf: Uint8Array): void; + abstract digest(): Uint8Array; + /** + * Resets internal state. Makes Hash instance unusable. + * Reset is impossible for keyed hashes if key is consumed into state. If digest is not consumed + * by user, they will need to manually call `destroy()` when zeroing is necessary. + */ + abstract destroy(): void; +} +/** Sync cipher: takes byte array and returns byte array. */ +export type Cipher = { + encrypt(plaintext: Uint8Array): Uint8Array; + decrypt(ciphertext: Uint8Array): Uint8Array; +}; +/** Async cipher e.g. from built-in WebCrypto. */ +export type AsyncCipher = { + encrypt(plaintext: Uint8Array): Promise; + decrypt(ciphertext: Uint8Array): Promise; +}; +/** Cipher with `output` argument which can optimize by doing 1 less allocation. */ +export type CipherWithOutput = Cipher & { + encrypt(plaintext: Uint8Array, output?: Uint8Array): Uint8Array; + decrypt(ciphertext: Uint8Array, output?: Uint8Array): Uint8Array; +}; +/** + * Params are outside of return type, so it is accessible before calling constructor. + * If function support multiple nonceLength's, we return the best one. + */ +export type CipherParams = { + blockSize: number; + nonceLength?: number; + tagLength?: number; + varSizeNonce?: boolean; +}; +/** ARX cipher, like salsa or chacha. */ +export type ARXCipher = ((key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => CipherWithOutput) & { + blockSize: number; + nonceLength: number; + tagLength: number; +}; +export type CipherCons = (key: Uint8Array, ...args: T) => Cipher; +/** + * Wraps a cipher: validates args, ensures encrypt() can only be called once. + * @__NO_SIDE_EFFECTS__ + */ +export declare const wrapCipher: , P extends CipherParams>(params: P, constructor: C) => C & P; +/** Represents salsa / chacha stream. */ +export type XorStream = (key: Uint8Array, nonce: Uint8Array, data: Uint8Array, output?: Uint8Array, counter?: number) => Uint8Array; +/** + * By default, returns u8a of length. + * When out is available, it checks it for validity and uses it. + */ +export declare function getOutput(expectedLength: number, out?: Uint8Array, onlyAligned?: boolean): Uint8Array; +/** Polyfill for Safari 14. */ +export declare function setBigUint64(view: DataView, byteOffset: number, value: bigint, isLE: boolean): void; +export declare function u64Lengths(dataLength: number, aadLength: number, isLE: boolean): Uint8Array; +export declare function isAligned32(bytes: Uint8Array): boolean; +export declare function copyBytes(bytes: Uint8Array): Uint8Array; +export {}; +//# sourceMappingURL=utils.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/utils.d.ts.map b/node_modules/@noble/ciphers/utils.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..69f34f029cc0bc4cf673fc6aa9a4855e9c4b4a7e --- /dev/null +++ b/node_modules/@noble/ciphers/utils.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,uEAAuE;AAEvE,qFAAqF;AACrF,wBAAgB,OAAO,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,UAAU,CAEnD;AAED,oCAAoC;AACpC,wBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,GAAG,IAAI,CAEtC;AAED,6CAA6C;AAC7C,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAEvC;AAED,uCAAuC;AACvC,wBAAgB,MAAM,CAAC,CAAC,EAAE,UAAU,GAAG,SAAS,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAI5E;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAKpC;AAED,gEAAgE;AAChE,wBAAgB,OAAO,CAAC,QAAQ,EAAE,GAAG,EAAE,aAAa,UAAO,GAAG,IAAI,CAGjE;AAED,kDAAkD;AAClD,wBAAgB,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,GAAG,IAAI,CAMrD;AAED,MAAM,MAAM,KAAK,GAAG;IAClB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,UAAU,CAAC;IACxC,QA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;AACxC,MAAM,MAAM,SAAS,GAAG,CACtB,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,UAAU,EACjB,IAAI,EAAE,UAAU,EAChB,MAAM,CAAC,EAAE,UAAU,EACnB,OAAO,CAAC,EAAE,MAAM,KACb,UAAU,CAAC;AAEhB;;;GAGG;AACH,wBAAgB,SAAS,CACvB,cAAc,EAAE,MAAM,EACtB,GAAG,CAAC,EAAE,UAAU,EAChB,WAAW,UAAO,GACjB,UAAU,CAMZ;AAED,8BAA8B;AAC9B,wBAAgB,YAAY,CAC1B,IAAI,EAAE,QAAQ,EACd,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,OAAO,GACZ,IAAI,CAUN;AAED,wBAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,UAAU,CAO3F;AAGD,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAEtD;AAGD,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAEvD"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/utils.js b/node_modules/@noble/ciphers/utils.js new file mode 100644 index 0000000000000000000000000000000000000000..d6c8cd6f287c975853a9d843ab66907de597545b --- /dev/null +++ b/node_modules/@noble/ciphers/utils.js @@ -0,0 +1,374 @@ +"use strict"; +/** + * Utilities for hex, bytes, CSPRNG. + * @module + */ +/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.wrapCipher = exports.Hash = exports.nextTick = exports.isLE = void 0; +exports.isBytes = isBytes; +exports.abool = abool; +exports.anumber = anumber; +exports.abytes = abytes; +exports.ahash = ahash; +exports.aexists = aexists; +exports.aoutput = aoutput; +exports.u8 = u8; +exports.u32 = u32; +exports.clean = clean; +exports.createView = createView; +exports.bytesToHex = bytesToHex; +exports.hexToBytes = hexToBytes; +exports.hexToNumber = hexToNumber; +exports.bytesToNumberBE = bytesToNumberBE; +exports.numberToBytesBE = numberToBytesBE; +exports.utf8ToBytes = utf8ToBytes; +exports.bytesToUtf8 = bytesToUtf8; +exports.toBytes = toBytes; +exports.overlapBytes = overlapBytes; +exports.complexOverlapBytes = complexOverlapBytes; +exports.concatBytes = concatBytes; +exports.checkOpts = checkOpts; +exports.equalBytes = equalBytes; +exports.getOutput = getOutput; +exports.setBigUint64 = setBigUint64; +exports.u64Lengths = u64Lengths; +exports.isAligned32 = isAligned32; +exports.copyBytes = copyBytes; +/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */ +function isBytes(a) { + return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array'); +} +/** Asserts something is boolean. */ +function abool(b) { + if (typeof b !== 'boolean') + throw new Error(`boolean expected, not ${b}`); +} +/** Asserts something is positive integer. */ +function anumber(n) { + if (!Number.isSafeInteger(n) || n < 0) + throw new Error('positive integer expected, got ' + n); +} +/** Asserts something is Uint8Array. */ +function abytes(b, ...lengths) { + if (!isBytes(b)) + throw new Error('Uint8Array expected'); + if (lengths.length > 0 && !lengths.includes(b.length)) + throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length); +} +/** + * Asserts something is hash + * TODO: remove + * @deprecated + */ +function ahash(h) { + if (typeof h !== 'function' || typeof h.create !== 'function') + throw new Error('Hash should be wrapped by utils.createHasher'); + anumber(h.outputLen); + anumber(h.blockLen); +} +/** Asserts a hash instance has not been destroyed / finished */ +function aexists(instance, checkFinished = true) { + if (instance.destroyed) + throw new Error('Hash instance has been destroyed'); + if (checkFinished && instance.finished) + throw new Error('Hash#digest() has already been called'); +} +/** Asserts output is properly-sized byte array */ +function aoutput(out, instance) { + abytes(out); + const min = instance.outputLen; + if (out.length < min) { + throw new Error('digestInto() expects output buffer of length at least ' + min); + } +} +/** Cast u8 / u16 / u32 to u8. */ +function u8(arr) { + return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength); +} +/** Cast u8 / u16 / u32 to u32. */ +function u32(arr) { + return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4)); +} +/** Zeroize a byte array. Warning: JS provides no guarantees. */ +function clean(...arrays) { + for (let i = 0; i < arrays.length; i++) { + arrays[i].fill(0); + } +} +/** Create DataView of an array for easy byte-level manipulation. */ +function createView(arr) { + return new DataView(arr.buffer, arr.byteOffset, arr.byteLength); +} +/** Is current platform little-endian? Most are. Big-Endian platform: IBM */ +exports.isLE = (() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)(); +// Built-in hex conversion https://caniuse.com/mdn-javascript_builtins_uint8array_fromhex +const hasHexBuiltin = /* @__PURE__ */ (() => +// @ts-ignore +typeof Uint8Array.from([]).toHex === 'function' && typeof Uint8Array.fromHex === 'function')(); +// Array where index 0xf0 (240) is mapped to string 'f0' +const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0')); +/** + * Convert byte array to hex string. Uses built-in function, when available. + * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123' + */ +function bytesToHex(bytes) { + abytes(bytes); + // @ts-ignore + if (hasHexBuiltin) + return bytes.toHex(); + // pre-caching improves the speed 6x + let hex = ''; + for (let i = 0; i < bytes.length; i++) { + hex += hexes[bytes[i]]; + } + return hex; +} +// We use optimized technique to convert hex string to byte array +const asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 }; +function asciiToBase16(ch) { + if (ch >= asciis._0 && ch <= asciis._9) + return ch - asciis._0; // '2' => 50-48 + if (ch >= asciis.A && ch <= asciis.F) + return ch - (asciis.A - 10); // 'B' => 66-(65-10) + if (ch >= asciis.a && ch <= asciis.f) + return ch - (asciis.a - 10); // 'b' => 98-(97-10) + return; +} +/** + * Convert hex string to byte array. Uses built-in function, when available. + * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23]) + */ +function hexToBytes(hex) { + if (typeof hex !== 'string') + throw new Error('hex string expected, got ' + typeof hex); + // @ts-ignore + if (hasHexBuiltin) + return Uint8Array.fromHex(hex); + const hl = hex.length; + const al = hl / 2; + if (hl % 2) + throw new Error('hex string expected, got unpadded hex of length ' + hl); + const array = new Uint8Array(al); + for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) { + const n1 = asciiToBase16(hex.charCodeAt(hi)); + const n2 = asciiToBase16(hex.charCodeAt(hi + 1)); + if (n1 === undefined || n2 === undefined) { + const char = hex[hi] + hex[hi + 1]; + throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi); + } + array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163 + } + return array; +} +// Used in micro +function hexToNumber(hex) { + if (typeof hex !== 'string') + throw new Error('hex string expected, got ' + typeof hex); + return BigInt(hex === '' ? '0' : '0x' + hex); // Big Endian +} +// Used in ff1 +// BE: Big Endian, LE: Little Endian +function bytesToNumberBE(bytes) { + return hexToNumber(bytesToHex(bytes)); +} +// Used in micro, ff1 +function numberToBytesBE(n, len) { + return hexToBytes(n.toString(16).padStart(len * 2, '0')); +} +// TODO: remove +// There is no setImmediate in browser and setTimeout is slow. +// call of async fn will return Promise, which will be fullfiled only on +// next scheduler queue processing step and this is exactly what we need. +const nextTick = async () => { }; +exports.nextTick = nextTick; +/** + * Converts string to bytes using UTF8 encoding. + * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99]) + */ +function utf8ToBytes(str) { + if (typeof str !== 'string') + throw new Error('string expected'); + return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809 +} +/** + * Converts bytes to string using UTF8 encoding. + * @example bytesToUtf8(new Uint8Array([97, 98, 99])) // 'abc' + */ +function bytesToUtf8(bytes) { + return new TextDecoder().decode(bytes); +} +/** + * Normalizes (non-hex) string or Uint8Array to Uint8Array. + * Warning: when Uint8Array is passed, it would NOT get copied. + * Keep in mind for future mutable operations. + */ +function toBytes(data) { + if (typeof data === 'string') + data = utf8ToBytes(data); + else if (isBytes(data)) + data = copyBytes(data); + else + throw new Error('Uint8Array expected, got ' + typeof data); + return data; +} +/** + * Checks if two U8A use same underlying buffer and overlaps. + * This is invalid and can corrupt data. + */ +function overlapBytes(a, b) { + return (a.buffer === b.buffer && // best we can do, may fail with an obscure Proxy + a.byteOffset < b.byteOffset + b.byteLength && // a starts before b end + b.byteOffset < a.byteOffset + a.byteLength // b starts before a end + ); +} +/** + * If input and output overlap and input starts before output, we will overwrite end of input before + * we start processing it, so this is not supported for most ciphers (except chacha/salse, which designed with this) + */ +function complexOverlapBytes(input, output) { + // This is very cursed. It works somehow, but I'm completely unsure, + // reasoning about overlapping aligned windows is very hard. + if (overlapBytes(input, output) && input.byteOffset < output.byteOffset) + throw new Error('complex overlap of input and output is not supported'); +} +/** + * Copies several Uint8Arrays into one. + */ +function concatBytes(...arrays) { + let sum = 0; + for (let i = 0; i < arrays.length; i++) { + const a = arrays[i]; + abytes(a); + sum += a.length; + } + const res = new Uint8Array(sum); + for (let i = 0, pad = 0; i < arrays.length; i++) { + const a = arrays[i]; + res.set(a, pad); + pad += a.length; + } + return res; +} +function checkOpts(defaults, opts) { + if (opts == null || typeof opts !== 'object') + throw new Error('options must be defined'); + const merged = Object.assign(defaults, opts); + return merged; +} +/** Compares 2 uint8array-s in kinda constant time. */ +function equalBytes(a, b) { + if (a.length !== b.length) + return false; + let diff = 0; + for (let i = 0; i < a.length; i++) + diff |= a[i] ^ b[i]; + return diff === 0; +} +// TODO: remove +/** For runtime check if class implements interface. */ +class Hash { +} +exports.Hash = Hash; +/** + * Wraps a cipher: validates args, ensures encrypt() can only be called once. + * @__NO_SIDE_EFFECTS__ + */ +const wrapCipher = (params, constructor) => { + function wrappedCipher(key, ...args) { + // Validate key + abytes(key); + // Big-Endian hardware is rare. Just in case someone still decides to run ciphers: + if (!exports.isLE) + throw new Error('Non little-endian hardware is not yet supported'); + // Validate nonce if nonceLength is present + if (params.nonceLength !== undefined) { + const nonce = args[0]; + if (!nonce) + throw new Error('nonce / iv required'); + if (params.varSizeNonce) + abytes(nonce); + else + abytes(nonce, params.nonceLength); + } + // Validate AAD if tagLength present + const tagl = params.tagLength; + if (tagl && args[1] !== undefined) { + abytes(args[1]); + } + const cipher = constructor(key, ...args); + const checkOutput = (fnLength, output) => { + if (output !== undefined) { + if (fnLength !== 2) + throw new Error('cipher output not supported'); + abytes(output); + } + }; + // Create wrapped cipher with validation and single-use encryption + let called = false; + const wrCipher = { + encrypt(data, output) { + if (called) + throw new Error('cannot encrypt() twice with same key + nonce'); + called = true; + abytes(data); + checkOutput(cipher.encrypt.length, output); + return cipher.encrypt(data, output); + }, + decrypt(data, output) { + abytes(data); + if (tagl && data.length < tagl) + throw new Error('invalid ciphertext length: smaller than tagLength=' + tagl); + checkOutput(cipher.decrypt.length, output); + return cipher.decrypt(data, output); + }, + }; + return wrCipher; + } + Object.assign(wrappedCipher, params); + return wrappedCipher; +}; +exports.wrapCipher = wrapCipher; +/** + * By default, returns u8a of length. + * When out is available, it checks it for validity and uses it. + */ +function getOutput(expectedLength, out, onlyAligned = true) { + if (out === undefined) + return new Uint8Array(expectedLength); + if (out.length !== expectedLength) + throw new Error('invalid output length, expected ' + expectedLength + ', got: ' + out.length); + if (onlyAligned && !isAligned32(out)) + throw new Error('invalid output, must be aligned'); + return out; +} +/** Polyfill for Safari 14. */ +function setBigUint64(view, byteOffset, value, isLE) { + if (typeof view.setBigUint64 === 'function') + return view.setBigUint64(byteOffset, value, isLE); + const _32n = BigInt(32); + const _u32_max = BigInt(0xffffffff); + const wh = Number((value >> _32n) & _u32_max); + const wl = Number(value & _u32_max); + const h = isLE ? 4 : 0; + const l = isLE ? 0 : 4; + view.setUint32(byteOffset + h, wh, isLE); + view.setUint32(byteOffset + l, wl, isLE); +} +function u64Lengths(dataLength, aadLength, isLE) { + abool(isLE); + const num = new Uint8Array(16); + const view = createView(num); + setBigUint64(view, 0, BigInt(aadLength), isLE); + setBigUint64(view, 8, BigInt(dataLength), isLE); + return num; +} +// Is byte array aligned to 4 byte offset (u32)? +function isAligned32(bytes) { + return bytes.byteOffset % 4 === 0; +} +// copy bytes to new u8a (aligned). Because Buffer.slice is broken. +function copyBytes(bytes) { + return Uint8Array.from(bytes); +} +//# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/utils.js.map b/node_modules/@noble/ciphers/utils.js.map new file mode 100644 index 0000000000000000000000000000000000000000..7ceeae0239f9855cfae6920756f4a3beb2e575d0 --- /dev/null +++ b/node_modules/@noble/ciphers/utils.js.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.js","sourceRoot":"","sources":["src/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;AACH,uEAAuE;;;AAGvE,0BAEC;AAGD,sBAEC;AAGD,0BAEC;AAGD,wBAIC;AAOD,sBAKC;AAGD,0BAGC;AAGD,0BAMC;AAeD,gBAEC;AAGD,kBAEC;AAGD,sBAIC;AAGD,gCAEC;AAoBD,gCAUC;AAeD,gCAkBC;AAGD,kCAGC;AAID,0CAEC;AAGD,0CAEC;AAgBD,kCAGC;AAMD,kCAEC;AASD,0BAKC;AAMD,oCAMC;AAMD,kDAKC;AAKD,kCAcC;AAID,8BAOC;AAGD,gCAKC;AAwID,8BAUC;AAGD,oCAeC;AAED,gCAOC;AAGD,kCAEC;AAGD,8BAEC;AA9bD,qFAAqF;AACrF,SAAgB,OAAO,CAAC,CAAU;IAChC,OAAO,CAAC,YAAY,UAAU,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC;AACnG,CAAC;AAED,oCAAoC;AACpC,SAAgB,KAAK,CAAC,CAAU;IAC9B,IAAI,OAAO,CAAC,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,EAAE,CAAC,CAAC;AAC5E,CAAC;AAED,6C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E,MAAM,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC,CAAC;IAChD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,gDAAgD;AAChD,SAAgB,WAAW,CAAC,KAAiB;IAC3C,OAAO,KAAK,CAAC,UAAU,GAAG,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC;AAED,mEAAmE;AACnE,SAAgB,SAAS,CAAC,KAAiB;IACzC,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/webcrypto.d.ts b/node_modules/@noble/ciphers/webcrypto.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e79d0e4a6bd8a82e8ad27b5ac240fc3db960b4b1 --- /dev/null +++ b/node_modules/@noble/ciphers/webcrypto.d.ts @@ -0,0 +1,31 @@ +import { type AsyncCipher, type Cipher } from './utils.ts'; +/** + * Secure PRNG. Uses `crypto.getRandomValues`, which defers to OS. + */ +export declare function randomBytes(bytesLength?: number): Uint8Array; +export declare function getWebcryptoSubtle(): any; +type RemoveNonceInner = ((...args: T) => Ret) extends (arg0: any, arg1: any, ...rest: infer R) => any ? (key: Uint8Array, ...args: R) => Ret : never; +type RemoveNonce any> = RemoveNonceInner, ReturnType>; +type CipherWithNonce = ((key: Uint8Array, nonce: Uint8Array, ...args: any[]) => Cipher) & { + nonceLength: number; +}; +/** + * Uses CSPRG for nonce, nonce injected in ciphertext. + * @example + * const gcm = managedNonce(aes.gcm); + * const ciphr = gcm(key).encrypt(data); + * const plain = gcm(key).decrypt(ciph); + */ +export declare function managedNonce(fn: T): RemoveNonce; +export declare const utils: { + encrypt: (key: Uint8Array, ...all: any[]) => Promise; + decrypt: (key: Uint8Array, ...all: any[]) => Promise; +}; +/** AES-CBC, native webcrypto version */ +export declare const cbc: (key: Uint8Array, iv: Uint8Array) => AsyncCipher; +/** AES-CTR, native webcrypto version */ +export declare const ctr: (key: Uint8Array, nonce: Uint8Array) => AsyncCipher; +/** AES-GCM, native webcrypto version */ +export declare const gcm: (key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => AsyncCipher; +export {}; +//# sourceMappingURL=webcrypto.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/webcrypto.d.ts.map b/node_modules/@noble/ciphers/webcrypto.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..cb8f8b974fbd3b92f1f17dfcf0d9b2d497bcb2d5 --- /dev/null +++ b/node_modules/@noble/ciphers/webcrypto.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"webcrypto.d.ts","sourceRoot":"","sources":["src/webcrypto.ts"],"names":[],"mappings":"AAYA,OAAO,EAAmB,KAAK,WAAW,EAAE,KAAK,MAAM,EAAe,MAAM,YAAY,CAAC;AAEzF;;GAEG;AACH,wBAAgB,WAAW,CAAC,WAAW,SAAK,GAAG,UAAU,CASxD;AAED,wBAAgB,kBAAkB,IAAI,GAAG,CAGxC;AAED,KAAK,gBAAgB,CAAC,CAAC,SAAS,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,GAAG,CAAC,SAAS,CAC1E,IAAI,EAAE,GAAG,EACT,IAAI,EAAE,GAAG,EACT,GAAG,IAAI,EAAE,MAAM,CAAC,KACb,GAAG,GACJ,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,CAAC,KAAK,GAAG,GACpC,KAAK,CAAC;AAEV,KAAK,WAAW,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,IAAI,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AACnG,KAAK,eAAe,GAAG,CAAC,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,MAAM,CAAC,GAAG;IACxF,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,eAAe,EAAE,EAAE,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAiB7E;AAID,eAAO,MAAM,KAAK,EAAE;IAClB,OAAO,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,GAAG,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IACjE,OAAO,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,GAAG,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;CAwBlE,CAAC;AA2CF,wCAAwC;AACxC,eAAO,MAAM,GAAG,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU,KAAK,WAChC,CAAC;AACxB,wCAAwC;AACxC,eAAO,MAAM,GAAG,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,KAAK,WACnC,CAAC;AACxB,wCAAwC;AACxC,eAAO,MAAM,GAAG,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,CAAC,EAAE,UAAU,KAAK,WAC9B,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/ciphers/webcrypto.js b/node_modules/@noble/ciphers/webcrypto.js new file mode 100644 index 0000000000000000000000000000000000000000..8848e7cfde06fb4c21ce78254f4b235a48ae1d17 --- /dev/null +++ b/node_modules/@noble/ciphers/webcrypto.js @@ -0,0 +1,141 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.gcm = exports.ctr = exports.cbc = exports.utils = void 0; +exports.randomBytes = randomBytes; +exports.getWebcryptoSubtle = getWebcryptoSubtle; +exports.managedNonce = managedNonce; +/** + * WebCrypto-based AES gcm/ctr/cbc, `managedNonce` and `randomBytes`. + * We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+. + * node.js versions earlier than v19 don't declare it in global scope. + * For node.js, package.js on#exports field mapping rewrites import + * from `crypto` to `cryptoNode`, which imports native module. + * Makes the utils un-importable in browsers without a bundler. + * Once node.js 18 is deprecated, we can just drop the import. + * @module + */ +// Use full path so that Node.js can rewrite it to `cryptoNode.js`. +const crypto_1 = require("@noble/ciphers/crypto"); +const utils_ts_1 = require("./utils.js"); +/** + * Secure PRNG. Uses `crypto.getRandomValues`, which defers to OS. + */ +function randomBytes(bytesLength = 32) { + if (crypto_1.crypto && typeof crypto_1.crypto.getRandomValues === 'function') { + return crypto_1.crypto.getRandomValues(new Uint8Array(bytesLength)); + } + // Legacy Node.js compatibility + if (crypto_1.crypto && typeof crypto_1.crypto.randomBytes === 'function') { + return Uint8Array.from(crypto_1.crypto.randomBytes(bytesLength)); + } + throw new Error('crypto.getRandomValues must be defined'); +} +function getWebcryptoSubtle() { + if (crypto_1.crypto && typeof crypto_1.crypto.subtle === 'object' && crypto_1.crypto.subtle != null) + return crypto_1.crypto.subtle; + throw new Error('crypto.subtle must be defined'); +} +/** + * Uses CSPRG for nonce, nonce injected in ciphertext. + * @example + * const gcm = managedNonce(aes.gcm); + * const ciphr = gcm(key).encrypt(data); + * const plain = gcm(key).decrypt(ciph); + */ +function managedNonce(fn) { + const { nonceLength } = fn; + (0, utils_ts_1.anumber)(nonceLength); + return ((key, ...args) => ({ + encrypt(plaintext, ...argsEnc) { + const nonce = randomBytes(nonceLength); + const ciphertext = fn(key, nonce, ...args).encrypt(plaintext, ...argsEnc); + const out = (0, utils_ts_1.concatBytes)(nonce, ciphertext); + ciphertext.fill(0); + return out; + }, + decrypt(ciphertext, ...argsDec) { + const nonce = ciphertext.subarray(0, nonceLength); + const data = ciphertext.subarray(nonceLength); + return fn(key, nonce, ...args).decrypt(data, ...argsDec); + }, + })); +} +// Overridable +// @TODO +exports.utils = { + async encrypt(key, keyParams, cryptParams, plaintext) { + const cr = getWebcryptoSubtle(); + const iKey = await cr.importKey('raw', key, keyParams, true, ['encrypt']); + const ciphertext = await cr.encrypt(cryptParams, iKey, plaintext); + return new Uint8Array(ciphertext); + }, + async decrypt(key, keyParams, cryptParams, ciphertext) { + const cr = getWebcryptoSubtle(); + const iKey = await cr.importKey('raw', key, keyParams, true, ['decrypt']); + const plaintext = await cr.decrypt(cryptParams, iKey, ciphertext); + return new Uint8Array(plaintext); + }, +}; +const mode = { + CBC: 'AES-CBC', + CTR: 'AES-CTR', + GCM: 'AES-GCM', +}; +function getCryptParams(algo, nonce, AAD) { + if (algo === mode.CBC) + return { name: mode.CBC, iv: nonce }; + if (algo === mode.CTR) + return { name: mode.CTR, counter: nonce, length: 64 }; + if (algo === mode.GCM) { + if (AAD) + return { name: mode.GCM, iv: nonce, additionalData: AAD }; + else + return { name: mode.GCM, iv: nonce }; + } + throw new Error('unknown aes block mode'); +} +function generate(algo) { + return (key, nonce, AAD) => { + (0, utils_ts_1.abytes)(key); + (0, utils_ts_1.abytes)(nonce); + const keyParams = { name: algo, length: key.length * 8 }; + const cryptParams = getCryptParams(algo, nonce, AAD); + let consumed = false; + return { + // keyLength, + encrypt(plaintext) { + (0, utils_ts_1.abytes)(plaintext); + if (consumed) + throw new Error('Cannot encrypt() twice with same key / nonce'); + consumed = true; + return exports.utils.encrypt(key, keyParams, cryptParams, plaintext); + }, + decrypt(ciphertext) { + (0, utils_ts_1.abytes)(ciphertext); + return exports.utils.decrypt(key, keyParams, cryptParams, ciphertext); + }, + }; + }; +} +/** AES-CBC, native webcrypto version */ +exports.cbc = (() => generate(mode.CBC))(); +/** AES-CTR, native webcrypto version */ +exports.ctr = (() => generate(mode.CTR))(); +/** AES-GCM, native webcrypto version */ +exports.gcm = +/* @__PURE__ */ (() => generate(mode.GCM))(); +// // Type tests +// import { siv, gcm, ctr, ecb, cbc } from '../aes.ts'; +// import { xsalsa20poly1305 } from '../salsa.ts'; +// import { chacha20poly1305, xchacha20poly1305 } from '../chacha.ts'; +// const wsiv = managedNonce(siv); +// const wgcm = managedNonce(gcm); +// const wctr = managedNonce(ctr); +// const wcbc = managedNonce(cbc); +// const wsalsapoly = managedNonce(xsalsa20poly1305); +// const wchacha = managedNonce(chacha20poly1305); +// const wxchacha = managedNonce(xchacha20poly1305); +// // should fail +// const wcbc2 = managedNonce(managedNonce(cbc)); +// const wctr = managedNonce(ctr); +//# sourceMappingURL=webcrypto.js.map \ No newline at end of file diff --git a/node_modules/@noble/ciphers/webcrypto.js.map b/node_modules/@noble/ciphers/webcrypto.js.map new file mode 100644 index 0000000000000000000000000000000000000000..758e137f48606ac456ff99831cc7dcdd304c0547 --- /dev/null +++ b/node_modules/@noble/ciphers/webcrypto.js.map @@ -0,0 +1 @@ +{"version":3,"file":"webcrypto.js","sourceRoot":"","sources":["src/webcrypto.ts"],"names":[],"mappings":";;;AAiBA,kCASC;AAED,gDAGC;AAsBD,oCAiBC;AAtED;;;;;;;;;GASG;AACH,mEAAmE;AACnE,kDAA+C;AAC/C,yCAAyF;AAEzF;;GAEG;AACH,SAAgB,WAAW,CAAC,WAAW,GAAG,EAAE;IAC1C,IAAI,eAAM,IAAI,OAAO,eAAM,CAAC,eAAe,KAAK,UAAU,EAAE,CAAC;QAC3D,OAAO,eAAM,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC;IAC7D,CAAC;IACD,+BAA+B;IAC/B,IAAI,eAAM,IAAI,OAAO,eAAM,CAAC,WAAW,KAAK,UAAU,EAAE,CAAC;QACvD,OAAO,UAAU,CAAC,IAAI,CAAC,eAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC;IAC1D,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;AAC5D,CAAC;AAED,SAAgB,kBAAkB;IAChC,IAAI,eAAM,IAAI,OAAO,eAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,eAAM,CAAC,MAAM,IAAI,IAAI;QAAE,OAAO,eAAM,CAAC,MAAM,CAAC;IAC/F,MAAM,IAAI,KAAK,CAAC,+BA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C;AAC3B,QAAA,GAAG,GAAwE,CAAC,GAAG,EAAE,CAC5F,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;AACxB,wCAAwC;AAC3B,QAAA,GAAG;AACd,eAAe,CAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;AAE/C,gBAAgB;AAChB,uDAAuD;AACvD,kDAAkD;AAClD,sEAAsE;AAEtE,kCAAkC;AAClC,kCAAkC;AAClC,kCAAkC;AAClC,kCAAkC;AAClC,qDAAqD;AACrD,kDAAkD;AAClD,oDAAoD;AAEpD,iBAAiB;AACjB,iDAAiD;AACjD,kCAAkC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/LICENSE b/node_modules/@noble/hashes/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..9297a046d01cf521f93679535be51a8e5b736c0d --- /dev/null +++ b/node_modules/@noble/hashes/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2022 Paul Miller (https://paulmillr.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the “Software”), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/node_modules/@noble/hashes/README.md b/node_modules/@noble/hashes/README.md new file mode 100644 index 0000000000000000000000000000000000000000..759d34bfaa049d7683e051580169740b438891c9 --- /dev/null +++ b/node_modules/@noble/hashes/README.md @@ -0,0 +1,521 @@ +# noble-hashes + +Audited & minimal JS implementation of hash functions, MACs and KDFs. + +- 🔒 [**Audited**](#security) by an independent security firm +- 🔻 Tree-shakeable: unused code is excluded from your builds +- 🏎 Fast: hand-optimized for caveats of JS engines +- 🔍 Reliable: chained / sliding window / DoS tests and fuzzing ensure correctness +- 🔁 No unrolled loops: makes it easier to verify and reduces source code size up to 5x +- 🦘 Includes SHA, RIPEMD, BLAKE, HMAC, HKDF, PBKDF, Scrypt, Argon2 & KangarooTwelve +- 🪶 48KB for everything, 4.8KB (2.36KB gzipped) for single-hash build + +Take a glance at [GitHub Discussions](https://github.com/paulmillr/noble-hashes/discussions) for questions and support. +The library's initial development was funded by [Ethereum Foundation](https://ethereum.org/). + +### This library belongs to _noble_ cryptography + +> **noble cryptography** — high-security, easily auditable set of contained cryptographic libraries and tools. + +- Zero or minimal dependencies +- Highly readable TypeScript / JS code +- PGP-signed releases and transparent NPM builds +- All libraries: + [ciphers](https://github.com/paulmillr/noble-ciphers), + [curves](https://github.com/paulmillr/noble-curves), + [hashes](https://github.com/paulmillr/noble-hashes), + [post-quantum](https://github.com/paulmillr/noble-post-quantum), + 4kb [secp256k1](https://github.com/paulmillr/noble-secp256k1) / + [ed25519](https://github.com/paulmillr/noble-ed25519) +- [Check out homepage](https://paulmillr.com/noble/) + for reading resources, documentation and apps built with noble + +## Usage + +> `npm install @noble/hashes` + +> `deno add jsr:@noble/hashes` + +> `deno doc jsr:@noble/hashes` # command-line documentation + +We support all major platforms and runtimes. +For React Native, you may need a [polyfill for getRandomValues](https://github.com/LinusU/react-native-get-random-values). +A standalone file [noble-hashes.js](https://github.com/paulmillr/noble-hashes/releases) is also available. + +```js +// import * from '@noble/hashes'; // Error: use sub-imports, to ensure small app size +import { sha256 } from '@noble/hashes/sha2.js'; // ESM & Common.js +sha256(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])); // returns Uint8Array + +// Available modules +import { sha256, sha384, sha512, sha224, sha512_224, sha512_256 } from '@noble/hashes/sha2.js'; +import { sha3_256, sha3_512, keccak_256, keccak_512, shake128, shake256 } from '@noble/hashes/sha3.js'; +import { cshake256, turboshake256, kmac256, tuplehash256, k12, m14, keccakprg } from '@noble/hashes/sha3-addons.js'; +import { blake3 } from '@noble/hashes/blake3.js'; +import { blake2b, blake2s } from '@noble/hashes/blake2.js'; +import { blake256, blake512 } from '@noble/hashes/blake1.js'; +import { sha1, md5, ripemd160 } from '@noble/hashes/legacy.js'; +import { hmac } from '@noble/hashes/hmac.js'; +import { hkdf } from '@noble/hashes/hkdf.js'; +import { pbkdf2, pbkdf2Async } from '@noble/hashes/pbkdf2.js'; +import { scrypt, scryptAsync } from '@noble/hashes/scrypt.js'; +import { argon2d, argon2i, argon2id } from '@noble/hashes/argon2.js'; +import * as utils from '@noble/hashes/utils'; // bytesToHex, bytesToUtf8, concatBytes... +``` + +- [sha2: sha256, sha384, sha512](#sha2-sha256-sha384-sha512-and-others) +- [sha3: FIPS, SHAKE, Keccak](#sha3-fips-shake-keccak) +- [sha3-addons: cSHAKE, KMAC, K12, M14, TurboSHAKE](#sha3-addons-cshake-kmac-k12-m14-turboshake) +- [blake, blake2, blake3](#blake-blake2-blake3) | [legacy: sha1, md5, ripemd160](#legacy-sha1-md5-ripemd160) +- MACs: [hmac](#hmac) | [sha3-addons kmac](#sha3-addons-cshake-kmac-k12-m14-turboshake) | [blake3 key mode](#blake2b-blake2s-blake3) +- KDFs: [hkdf](#hkdf) | [pbkdf2](#pbkdf2) | [scrypt](#scrypt) | [argon2](#argon2) +- [utils](#utils) +- [Security](#security) | [Speed](#speed) | [Contributing & testing](#contributing--testing) | [License](#license) + +### Implementations + +Hash functions: + +- `sha256()`: receive & return `Uint8Array` +- `sha256.create().update(a).update(b).digest()`: support partial updates +- `blake3.create({ context: 'e', dkLen: 32 })`: sometimes have options +- support little-endian architecture; also experimentally big-endian +- can hash up to 4GB per chunk, with any amount of chunks + +#### sha2: sha256, sha384, sha512 and others + +```typescript +import { sha224, sha256, sha384, sha512, sha512_224, sha512_256 } from '@noble/hashes/sha2.js'; +const res = sha256(Uint8Array.from([0xbc])); // basic +for (let hash of [sha256, sha384, sha512, sha224, sha512_224, sha512_256]) { + const arr = Uint8Array.from([0x10, 0x20, 0x30]); + const a = hash(arr); + const b = hash.create().update(arr).digest(); +} +``` + +See [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and +[the paper on truncated SHA512/256](https://eprint.iacr.org/2010/548.pdf). + +#### sha3: FIPS, SHAKE, Keccak + +```typescript +import { + keccak_224, keccak_256, keccak_384, keccak_512, + sha3_224, sha3_256, sha3_384, sha3_512, + shake128, shake256, +} from '@noble/hashes/sha3.js'; +for (let hash of [ + sha3_224, sha3_256, sha3_384, sha3_512, + keccak_224, keccak_256, keccak_384, keccak_512, +]) { + const arr = Uint8Array.from([0x10, 0x20, 0x30]); + const a = hash(arr); + const b = hash.create().update(arr).digest(); +} +const shka = shake128(Uint8Array.from([0x10]), { dkLen: 512 }); +const shkb = shake256(Uint8Array.from([0x30]), { dkLen: 512 }); +``` + +See [FIPS-202](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf), +[Website](https://keccak.team/keccak.html). + +Check out [the differences between SHA-3 and Keccak](https://crypto.stackexchange.com/questions/15727/what-are-the-key-differences-between-the-draft-sha-3-standard-and-the-keccak-sub) + +#### sha3-addons: cSHAKE, KMAC, K12, M14, TurboSHAKE + +```typescript +import { + cshake128, cshake256, + k12, + keccakprg, + kmac128, kmac256, + m14, + parallelhash256, + tuplehash256, + turboshake128, turboshake256 +} from '@noble/hashes/sha3-addons.js'; +const data = Uint8Array.from([0x10, 0x20, 0x30]); +const ec1 = cshake128(data, { personalization: 'def' }); +const ec2 = cshake256(data, { personalization: 'def' }); +const et1 = turboshake128(data); +const et2 = turboshake256(data, { D: 0x05 }); + // tuplehash(['ab', 'c']) !== tuplehash(['a', 'bc']) !== tuplehash([data]) +const et3 = tuplehash256([utf8ToBytes('ab'), utf8ToBytes('c')]); +// Not parallel in JS (similar to blake3 / k12), added for compat +const ep1 = parallelhash256(data, { blockLen: 8 }); +const kk = Uint8Array.from([0xca]); +const ek10 = kmac128(kk, data); +const ek11 = kmac256(kk, data); +const ek12 = k12(data); +const ek13 = m14(data); +// pseudo-random generator, first argument is capacity. XKCP recommends 254 bits capacity for 128-bit security strength. +// * with a capacity of 254 bits. +const p = keccakprg(254); +p.feed('test'); +const rand1b = p.fetch(1); +``` + +- Full [NIST SP 800-185](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-185.pdf): + cSHAKE, KMAC, TupleHash, ParallelHash + XOF variants +- [Reduced-round Keccak](https://datatracker.ietf.org/doc/draft-irtf-cfrg-kangarootwelve/): + - 🦘 K12 aka KangarooTwelve + - M14 aka MarsupilamiFourteen + - TurboSHAKE +- [KeccakPRG](https://keccak.team/files/CSF-0.1.pdf): Pseudo-random generator based on Keccak + +#### blake, blake2, blake3 + +```typescript +import { blake224, blake256, blake384, blake512 } from '@noble/hashes/blake1.js'; +import { blake2b, blake2s } from '@noble/hashes/blake2.js'; +import { blake3 } from '@noble/hashes/blake3.js'; + +for (let hash of [ + blake224, blake256, blake384, blake512, + blake2b, blake2s, blake3 +]) { + const arr = Uint8Array.from([0x10, 0x20, 0x30]); + const a = hash(arr); + const b = hash.create().update(arr).digest(); +} + +// blake2 advanced usage +const ab = Uint8Array.from([0x01]); +blake2s(ab); +blake2s(ab, { key: new Uint8Array(32) }); +blake2s(ab, { personalization: 'pers1234' }); +blake2s(ab, { salt: 'salt1234' }); +blake2b(ab); +blake2b(ab, { key: new Uint8Array(64) }); +blake2b(ab, { personalization: 'pers1234pers1234' }); +blake2b(ab, { salt: 'salt1234salt1234' }); + +// blake3 advanced usage +blake3(ab); +blake3(ab, { dkLen: 256 }); +blake3(ab, { key: new Uint8Array(32) }); +blake3(ab, { context: 'application-name' }); +``` + +- Blake1 is legacy hash, one of SHA3 proposals. It is rarely used anywhere. See [pdf](https://www.aumasson.jp/blake/blake.pdf). +- Blake2 is popular fast hash. blake2b focuses on 64-bit platforms while blake2s is for 8-bit to 32-bit ones. See [RFC 7693](https://datatracker.ietf.org/doc/html/rfc7693), [Website](https://www.blake2.net) +- Blake3 is faster, reduced-round blake2. See [Website & specs](https://blake3.io) + +#### legacy: sha1, md5, ripemd160 + +SHA1 (RFC 3174), MD5 (RFC 1321) and RIPEMD160 (RFC 2286) legacy, weak hash functions. +Don't use them in a new protocol. What "weak" means: + +- Collisions can be made with 2^18 effort in MD5, 2^60 in SHA1, 2^80 in RIPEMD160. +- No practical pre-image attacks (only theoretical, 2^123.4) +- HMAC seems kinda ok: https://datatracker.ietf.org/doc/html/rfc6151 + +```typescript +import { md5, ripemd160, sha1 } from '@noble/hashes/legacy.js'; +for (let hash of [md5, ripemd160, sha1]) { + const arr = Uint8Array.from([0x10, 0x20, 0x30]); + const a = hash(arr); + const b = hash.create().update(arr).digest(); +} +``` + +#### hmac + +```typescript +import { hmac } from '@noble/hashes/hmac.js'; +import { sha256 } from '@noble/hashes/sha2.js'; +const key = new Uint8Array(32).fill(1); +const msg = new Uint8Array(32).fill(2); +const mac1 = hmac(sha256, key, msg); +const mac2 = hmac.create(sha256, key).update(msg).digest(); +``` + +Matches [RFC 2104](https://datatracker.ietf.org/doc/html/rfc2104). + +#### hkdf + +```typescript +import { hkdf } from '@noble/hashes/hkdf.js'; +import { randomBytes } from '@noble/hashes/utils.js'; +import { sha256 } from '@noble/hashes/sha2.js'; +const inputKey = randomBytes(32); +const salt = randomBytes(32); +const info = 'application-key'; +const hk1 = hkdf(sha256, inputKey, salt, info, 32); + +// == same as +import { extract, expand } from '@noble/hashes/hkdf.js'; +import { sha256 } from '@noble/hashes/sha2.js'; +const prk = extract(sha256, inputKey, salt); +const hk2 = expand(sha256, prk, info, 32); +``` + +Matches [RFC 5869](https://datatracker.ietf.org/doc/html/rfc5869). + +#### pbkdf2 + +```typescript +import { pbkdf2, pbkdf2Async } from '@noble/hashes/pbkdf2.js'; +import { sha256 } from '@noble/hashes/sha2.js'; +const pbkey1 = pbkdf2(sha256, 'password', 'salt', { c: 32, dkLen: 32 }); +const pbkey2 = await pbkdf2Async(sha256, 'password', 'salt', { c: 32, dkLen: 32 }); +const pbkey3 = await pbkdf2Async(sha256, Uint8Array.from([1, 2, 3]), Uint8Array.from([4, 5, 6]), { + c: 32, + dkLen: 32, +}); +``` + +Matches [RFC 2898](https://datatracker.ietf.org/doc/html/rfc2898). + +#### scrypt + +```typescript +import { scrypt, scryptAsync } from '@noble/hashes/scrypt.js'; +const scr1 = scrypt('password', 'salt', { N: 2 ** 16, r: 8, p: 1, dkLen: 32 }); +const scr2 = await scryptAsync('password', 'salt', { N: 2 ** 16, r: 8, p: 1, dkLen: 32 }); +const scr3 = await scryptAsync(Uint8Array.from([1, 2, 3]), Uint8Array.from([4, 5, 6]), { + N: 2 ** 17, + r: 8, + p: 1, + dkLen: 32, + onProgress(percentage) { + console.log('progress', percentage); + }, + maxmem: 2 ** 32 + 128 * 8 * 1, // N * r * p * 128 + (128*r*p) +}); +``` + +Conforms to [RFC 7914](https://datatracker.ietf.org/doc/html/rfc7914), +[Website](https://www.tarsnap.com/scrypt.html) + +- `N, r, p` are work factors. To understand them, see [the blog post](https://blog.filippo.io/the-scrypt-parameters/). + `r: 8, p: 1` are common. JS doesn't support parallelization, making increasing p meaningless. +- `dkLen` is the length of output bytes e.g. `32` or `64` +- `onProgress` can be used with async version of the function to report progress to a user. +- `maxmem` prevents DoS and is limited to `1GB + 1KB` (`2**30 + 2**10`), but can be adjusted using formula: `N * r * p * 128 + (128 * r * p)` + +Time it takes to derive Scrypt key under different values of N (2\*\*N) on Apple M4 (mobile phones can be 1x-4x slower): + +| N pow | Time | RAM | +| ----- | ---- | ----- | +| 16 | 0.1s | 64MB | +| 17 | 0.2s | 128MB | +| 18 | 0.4s | 256MB | +| 19 | 0.8s | 512MB | +| 20 | 1.5s | 1GB | +| 21 | 3.1s | 2GB | +| 22 | 6.2s | 4GB | +| 23 | 13s | 8GB | +| 24 | 27s | 16GB | + +> [!NOTE] +> We support N larger than `2**20` where available, however, +> not all JS engines support >= 2GB ArrayBuffer-s. +> When using such N, you'll need to manually adjust `maxmem`, using formula above. +> Other JS implementations don't support large N-s. + +#### argon2 + +```ts +import { argon2d, argon2i, argon2id } from '@noble/hashes/argon2.js'; +const arg1 = argon2id('password', 'saltsalt', { t: 2, m: 65536, p: 1, maxmem: 2 ** 32 - 1 }); +``` + +Argon2 [RFC 9106](https://datatracker.ietf.org/doc/html/rfc9106) implementation. + +> [!WARNING] +> Argon2 can't be fast in JS, because there is no fast Uint64Array. +> It is suggested to use [Scrypt](#scrypt) instead. +> Being 5x slower than native code means brute-forcing attackers have bigger advantage. + +#### utils + +```typescript +import { bytesToHex as toHex, randomBytes } from '@noble/hashes/utils'; +console.log(toHex(randomBytes(32))); +``` + +- `bytesToHex` will convert `Uint8Array` to a hex string +- `randomBytes(bytes)` will produce cryptographically secure random `Uint8Array` of length `bytes` + +## Security + +The library has been independently audited: + +- at version 1.0.0, in Jan 2022, by [Cure53](https://cure53.de) + - PDFs: [website](https://cure53.de/pentest-report_hashing-libs.pdf), [in-repo](./audit/2022-01-05-cure53-audit-nbl2.pdf) + - [Changes since audit](https://github.com/paulmillr/noble-hashes/compare/1.0.0..main). + - Scope: everything, besides `blake3`, `sha3-addons`, `sha1` and `argon2`, which have not been audited + - The audit has been funded by [Ethereum Foundation](https://ethereum.org/en/) with help of [Nomic Labs](https://nomiclabs.io) + +It is tested against property-based, cross-library and Wycheproof vectors, +and is being fuzzed in [the separate repo](https://github.com/paulmillr/fuzzing). + +If you see anything unusual: investigate and report. + +### Constant-timeness + +We're targetting algorithmic constant time. _JIT-compiler_ and _Garbage Collector_ make "constant time" +extremely hard to achieve [timing attack](https://en.wikipedia.org/wiki/Timing_attack) resistance +in a scripting language. Which means _any other JS library can't have +constant-timeness_. Even statically typed Rust, a language without GC, +[makes it harder to achieve constant-time](https://www.chosenplaintext.ca/open-source/rust-timing-shield/security) +for some cases. If your goal is absolute security, don't use any JS lib — including bindings to native ones. +Use low-level libraries & languages. + +### Memory dumping + +The library shares state buffers between hash +function calls. The buffers are zeroed-out after each call. However, if an attacker +can read application memory, you are doomed in any case: + +- At some point, input will be a string and strings are immutable in JS: + there is no way to overwrite them with zeros. For example: deriving + key from `scrypt(password, salt)` where password and salt are strings +- Input from a file will stay in file buffers +- Input / output will be re-used multiple times in application which means it could stay in memory +- `await anything()` will always write all internal variables (including numbers) + to memory. With async functions / Promises there are no guarantees when the code + chunk would be executed. Which means attacker can have plenty of time to read data from memory +- There is no way to guarantee anything about zeroing sensitive data without + complex tests-suite which will dump process memory and verify that there is + no sensitive data left. For JS it means testing all browsers (incl. mobile), + which is complex. And of course it will be useless without using the same + test-suite in the actual application that consumes the library + +### Supply chain security + +- **Commits** are signed with PGP keys, to prevent forgery. Make sure to verify commit signatures +- **Releases** are transparent and built on GitHub CI. Make sure to verify [provenance](https://docs.npmjs.com/generating-provenance-statements) logs + - Use GitHub CLI to verify single-file builds: + `gh attestation verify --owner paulmillr noble-hashes.js` +- **Rare releasing** is followed to ensure less re-audit need for end-users +- **Dependencies** are minimized and locked-down: any dependency could get hacked and users will be downloading malware with every install. + - We make sure to use as few dependencies as possible + - Automatic dep updates are prevented by locking-down version ranges; diffs are checked with `npm-diff` +- **Dev Dependencies** are disabled for end-users; they are only used to develop / build the source code + +For this package, there are 0 dependencies; and a few dev dependencies: + +- micro-bmark, micro-should and jsbt are used for benchmarking / testing / build tooling and developed by the same author +- prettier, fast-check and typescript are used for code quality / test generation / ts compilation. It's hard to audit their source code thoroughly and fully because of their size + +### Randomness + +We're deferring to built-in +[crypto.getRandomValues](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues) +which is considered cryptographically secure (CSPRNG). + +In the past, browsers had bugs that made it weak: it may happen again. +Implementing a userspace CSPRNG to get resilient to the weakness +is even worse: there is no reliable userspace source of quality entropy. + +### Quantum computers + +Cryptographically relevant quantum computer, if built, will allow to +utilize Grover's algorithm to break hashes in 2^n/2 operations, instead of 2^n. + +This means SHA256 should be replaced with SHA512, SHA3-256 with SHA3-512, SHAKE128 with SHAKE256 etc. + +Australian ASD prohibits SHA256 and similar hashes [after 2030](https://www.cyber.gov.au/resources-business-and-government/essential-cyber-security/ism/cyber-security-guidelines/guidelines-cryptography). + +## Speed + +```sh +npm run bench:install && npm run bench +``` + +Benchmarks measured on Apple M4. + +``` +# 32B +sha256 x 1,968,503 ops/sec @ 508ns/op +sha512 x 740,740 ops/sec @ 1μs/op +sha3_256 x 287,686 ops/sec @ 3μs/op +sha3_512 x 288,267 ops/sec @ 3μs/op +k12 x 476,190 ops/sec @ 2μs/op +m14 x 423,190 ops/sec @ 2μs/op +blake2b x 464,252 ops/sec @ 2μs/op +blake2s x 766,871 ops/sec @ 1μs/op +blake3 x 879,507 ops/sec @ 1μs/op + +# 1MB +sha256 x 331 ops/sec @ 3ms/op +sha512 x 129 ops/sec @ 7ms/op +sha3_256 x 38 ops/sec @ 25ms/op +sha3_512 x 20 ops/sec @ 47ms/op +k12 x 88 ops/sec @ 11ms/op +m14 x 62 ops/sec @ 15ms/op +blake2b x 69 ops/sec @ 14ms/op +blake2s x 57 ops/sec @ 17ms/op +blake3 x 72 ops/sec @ 13ms/op + +# MAC +hmac(sha256) x 599,880 ops/sec @ 1μs/op +hmac(sha512) x 197,122 ops/sec @ 5μs/op +kmac256 x 87,981 ops/sec @ 11μs/op +blake3(key) x 796,812 ops/sec @ 1μs/op + +# KDF +hkdf(sha256) x 259,942 ops/sec @ 3μs/op +blake3(context) x 424,808 ops/sec @ 2μs/op +pbkdf2(sha256, c: 2 ** 18) x 5 ops/sec @ 197ms/op +pbkdf2(sha512, c: 2 ** 18) x 1 ops/sec @ 630ms/op +scrypt(n: 2 ** 18, r: 8, p: 1) x 2 ops/sec @ 400ms/op +argon2id(t: 1, m: 256MB) 2881ms +``` + +Compare to native node.js implementation that uses C bindings instead of pure-js code: + +``` +# native (node) 32B +sha256 x 2,267,573 ops/sec +sha512 x 983,284 ops/sec +sha3_256 x 1,522,070 ops/sec +blake2b x 1,512,859 ops/sec +blake2s x 1,821,493 ops/sec +hmac(sha256) x 1,085,776 ops/sec +hkdf(sha256) x 312,109 ops/sec +# native (node) KDF +pbkdf2(sha256, c: 2 ** 18) x 5 ops/sec @ 197ms/op +pbkdf2(sha512, c: 2 ** 18) x 1 ops/sec @ 630ms/op +scrypt(n: 2 ** 18, r: 8, p: 1) x 2 ops/sec @ 378ms/op +``` + +It is possible to [make this library 4x+ faster](./benchmark/README.md) by +_doing code generation of full loop unrolls_. We've decided against it. Reasons: + +- the library must be auditable, with minimum amount of code, and zero dependencies +- most method invocations with the lib are going to be something like hashing 32b to 64kb of data +- hashing big inputs is 10x faster with low-level languages, which means you should probably pick 'em instead + +The current performance is good enough when compared to other projects; SHA256 takes only 900 nanoseconds to run. + +## Contributing & testing + +`test/misc` directory contains implementations of loop unrolling and md5. + +- `npm install && npm run build && npm test` will build the code and run tests. +- `npm run lint` / `npm run format` will run linter / fix linter issues. +- `npm run bench` will run benchmarks, which may need their deps first (`npm run bench:install`) +- `npm run build:release` will build single file +- There is **additional** 20-min DoS test `npm run test:dos` and 2-hour "big" multicore test `npm run test:big`. + See [our approach to testing](./test/README.md) + +Additional resources: + +- NTT hashes are outside of scope of the library. You can view some of them in different repos: + - [Pedersen in micro-zk-proofs](https://github.com/paulmillr/micro-zk-proofs/blob/1ed5ce1253583b2e540eef7f3477fb52bf5344ff/src/pedersen.ts) + - [Poseidon in noble-curves](https://github.com/paulmillr/noble-curves/blob/3d124dd3ecec8b6634cc0b2ba1c183aded5304f9/src/abstract/poseidon.ts) +- Check out [guidelines](https://github.com/paulmillr/guidelines) for coding practices +- See [paulmillr.com/noble](https://paulmillr.com/noble/) for useful resources, articles, documentation and demos +related to the library. + +## License + +The MIT License (MIT) + +Copyright (c) 2022 Paul Miller [(https://paulmillr.com)](https://paulmillr.com) + +See LICENSE file. diff --git a/node_modules/@noble/hashes/_assert.d.ts b/node_modules/@noble/hashes/_assert.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5d62f87bafd7400c86a79394ad86b67c8ed792e9 --- /dev/null +++ b/node_modules/@noble/hashes/_assert.d.ts @@ -0,0 +1,17 @@ +/** + * Internal assertion helpers. + * @module + * @deprecated + */ +import { abytes as ab, aexists as ae, anumber as an, aoutput as ao, type IHash as H } from './utils.ts'; +/** @deprecated Use import from `noble/hashes/utils` module */ +export declare const abytes: typeof ab; +/** @deprecated Use import from `noble/hashes/utils` module */ +export declare const aexists: typeof ae; +/** @deprecated Use import from `noble/hashes/utils` module */ +export declare const anumber: typeof an; +/** @deprecated Use import from `noble/hashes/utils` module */ +export declare const aoutput: typeof ao; +/** @deprecated Use import from `noble/hashes/utils` module */ +export type Hash = H; +//# sourceMappingURL=_assert.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/_assert.d.ts.map b/node_modules/@noble/hashes/_assert.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..0ba0e4c856173f9901fc2a41c5228d109af14d86 --- /dev/null +++ b/node_modules/@noble/hashes/_assert.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"_assert.d.ts","sourceRoot":"","sources":["src/_assert.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,MAAM,IAAI,EAAE,EACZ,OAAO,IAAI,EAAE,EACb,OAAO,IAAI,EAAE,EACb,OAAO,IAAI,EAAE,EACb,KAAK,KAAK,IAAI,CAAC,EAChB,MAAM,YAAY,CAAC;AACpB,8DAA8D;AAC9D,eAAO,MAAM,MAAM,EAAE,OAAO,EAAO,CAAC;AACpC,8DAA8D;AAC9D,eAAO,MAAM,OAAO,EAAE,OAAO,EAAO,CAAC;AACrC,8DAA8D;AAC9D,eAAO,MAAM,OAAO,EAAE,OAAO,EAAO,CAAC;AACrC,8DAA8D;AAC9D,eAAO,MAAM,OAAO,EAAE,OAAO,EAAO,CAAC;AACrC,8DAA8D;AAC9D,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/_assert.js b/node_modules/@noble/hashes/_assert.js new file mode 100644 index 0000000000000000000000000000000000000000..b54da64a127fded1631d6a013d8a8cc19c204428 --- /dev/null +++ b/node_modules/@noble/hashes/_assert.js @@ -0,0 +1,18 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.aoutput = exports.anumber = exports.aexists = exports.abytes = void 0; +/** + * Internal assertion helpers. + * @module + * @deprecated + */ +const utils_ts_1 = require("./utils.js"); +/** @deprecated Use import from `noble/hashes/utils` module */ +exports.abytes = utils_ts_1.abytes; +/** @deprecated Use import from `noble/hashes/utils` module */ +exports.aexists = utils_ts_1.aexists; +/** @deprecated Use import from `noble/hashes/utils` module */ +exports.anumber = utils_ts_1.anumber; +/** @deprecated Use import from `noble/hashes/utils` module */ +exports.aoutput = utils_ts_1.aoutput; +//# sourceMappingURL=_assert.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/_assert.js.map b/node_modules/@noble/hashes/_assert.js.map new file mode 100644 index 0000000000000000000000000000000000000000..caf8b659e43e070da3470d3e840e0796587cfc44 --- /dev/null +++ b/node_modules/@noble/hashes/_assert.js.map @@ -0,0 +1 @@ +{"version":3,"file":"_assert.js","sourceRoot":"","sources":["src/_assert.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,yCAMoB;AACpB,8DAA8D;AACjD,QAAA,MAAM,GAAc,iBAAE,CAAC;AACpC,8DAA8D;AACjD,QAAA,OAAO,GAAc,kBAAE,CAAC;AACrC,8DAA8D;AACjD,QAAA,OAAO,GAAc,kBAAE,CAAC;AACrC,8DAA8D;AACjD,QAAA,OAAO,GAAc,kBAAE,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/_blake.d.ts b/node_modules/@noble/hashes/_blake.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..71ed85f9787ddb7b31acfa0c01dd910f87800f3a --- /dev/null +++ b/node_modules/@noble/hashes/_blake.d.ts @@ -0,0 +1,14 @@ +/** + * Internal blake variable. + * For BLAKE2b, the two extra permutations for rounds 10 and 11 are SIGMA[10..11] = SIGMA[0..1]. + */ +export declare const BSIGMA: Uint8Array; +export type Num4 = { + a: number; + b: number; + c: number; + d: number; +}; +export declare function G1s(a: number, b: number, c: number, d: number, x: number): Num4; +export declare function G2s(a: number, b: number, c: number, d: number, x: number): Num4; +//# sourceMappingURL=_blake.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/_blake.d.ts.map b/node_modules/@noble/hashes/_blake.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..7b11ac1f5ee3cbe7d69b1b4e3b44ef0f70f33a7f --- /dev/null +++ b/node_modules/@noble/hashes/_blake.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"_blake.d.ts","sourceRoot":"","sources":["src/_blake.ts"],"names":[],"mappings":"AAMA;;;GAGG;AAEH,eAAO,MAAM,MAAM,EAAE,UAkBnB,CAAC;AAGH,MAAM,MAAM,IAAI,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;CAAE,CAAC;AAGnE,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAM/E;AAED,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAM/E"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/_blake.js b/node_modules/@noble/hashes/_blake.js new file mode 100644 index 0000000000000000000000000000000000000000..a0b2cb16e759ac5e8b0c01bff3f643d23ac1f856 --- /dev/null +++ b/node_modules/@noble/hashes/_blake.js @@ -0,0 +1,50 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.BSIGMA = void 0; +exports.G1s = G1s; +exports.G2s = G2s; +/** + * Internal helpers for blake hash. + * @module + */ +const utils_ts_1 = require("./utils.js"); +/** + * Internal blake variable. + * For BLAKE2b, the two extra permutations for rounds 10 and 11 are SIGMA[10..11] = SIGMA[0..1]. + */ +// prettier-ignore +exports.BSIGMA = Uint8Array.from([ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, + 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, + 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, + 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, + 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, + 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, + 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, + 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5, + 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, + // Blake1, unused in others + 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, + 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, + 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, + 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, +]); +// Mixing function G splitted in two halfs +function G1s(a, b, c, d, x) { + a = (a + b + x) | 0; + d = (0, utils_ts_1.rotr)(d ^ a, 16); + c = (c + d) | 0; + b = (0, utils_ts_1.rotr)(b ^ c, 12); + return { a, b, c, d }; +} +function G2s(a, b, c, d, x) { + a = (a + b + x) | 0; + d = (0, utils_ts_1.rotr)(d ^ a, 8); + c = (c + d) | 0; + b = (0, utils_ts_1.rotr)(b ^ c, 7); + return { a, b, c, d }; +} +//# sourceMappingURL=_blake.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/_blake.js.map b/node_modules/@noble/hashes/_blake.js.map new file mode 100644 index 0000000000000000000000000000000000000000..b081eb6b599c48288bcac521adbe5f0fe04a6802 --- /dev/null +++ b/node_modules/@noble/hashes/_blake.js.map @@ -0,0 +1 @@ +{"version":3,"file":"_blake.js","sourceRoot":"","sources":["src/_blake.ts"],"names":[],"mappings":";;;AAmCA,kBAMC;AAED,kBAMC;AAjDD;;;GAGG;AACH,yCAAkC;AAElC;;;GAGG;AACH,kBAAkB;AACL,QAAA,MAAM,GAA+B,UAAU,CAAC,IAAI,CAAC;IAChE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;IACpD,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE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,CAAC,EAAE,CAAC,EAAE,CAAC;AACxB,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/_md.d.ts b/node_modules/@noble/hashes/_md.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ae184df9cc47efe9a7da09b601f8edf652eb801c --- /dev/null +++ b/node_modules/@noble/hashes/_md.d.ts @@ -0,0 +1,51 @@ +/** + * Internal Merkle-Damgard hash utils. + * @module + */ +import { type Input, Hash } from './utils.ts'; +/** Polyfill for Safari 14. https://caniuse.com/mdn-javascript_builtins_dataview_setbiguint64 */ +export declare function setBigUint64(view: DataView, byteOffset: number, value: bigint, isLE: boolean): void; +/** Choice: a ? b : c */ +export declare function Chi(a: number, b: number, c: number): number; +/** Majority function, true if any two inputs is true. */ +export declare function Maj(a: number, b: number, c: number): number; +/** + * Merkle-Damgard hash construction base class. + * Could be used to create MD5, RIPEMD, SHA1, SHA2. + */ +export declare abstract class HashMD> extends Hash { + protected abstract process(buf: DataView, offset: number): void; + protected abstract get(): number[]; + protected abstract set(...args: number[]): void; + abstract destroy(): void; + protected abstract roundClean(): void; + readonly blockLen: number; + readonly outputLen: number; + readonly padOffset: number; + readonly isLE: boolean; + protected buffer: Uint8Array; + protected view: DataView; + protected finished: boolean; + protected length: number; + protected pos: number; + protected destroyed: boolean; + constructor(blockLen: number, outputLen: number, padOffset: number, isLE: boolean); + update(data: Input): this; + digestInto(out: Uint8Array): void; + digest(): Uint8Array; + _cloneInto(to?: T): T; + clone(): T; +} +/** + * Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53. + * Check out `test/misc/sha2-gen-iv.js` for recomputation guide. + */ +/** Initial SHA256 state. Bits 0..32 of frac part of sqrt of primes 2..19 */ +export declare const SHA256_IV: Uint32Array; +/** Initial SHA224 state. Bits 32..64 of frac part of sqrt of primes 23..53 */ +export declare const SHA224_IV: Uint32Array; +/** Initial SHA384 state. Bits 0..64 of frac part of sqrt of primes 23..53 */ +export declare const SHA384_IV: Uint32Array; +/** Initial SHA512 state. Bits 0..64 of frac part of sqrt of primes 2..19 */ +export declare const SHA512_IV: Uint32Array; +//# sourceMappingURL=_md.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/_md.d.ts.map b/node_modules/@noble/hashes/_md.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..0f653d1ca460e7eb0dfb51a70cc1b7a531b27106 --- /dev/null +++ b/node_modules/@noble/hashes/_md.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"_md.d.ts","sourceRoot":"","sources":["src/_md.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,KAAK,EAAE,IAAI,EAAwD,MAAM,YAAY,CAAC;AAEpG,gGAAgG;AAChG,wBAAgB,YAAY,CAC1B,IAAI,EAAE,QAAQ,EACd,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,OAAO,GACZ,IAAI,CAUN;AAED,wBAAwB;AACxB,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED,yDAAyD;AACzD,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED;;;GAGG;AACH,8BAAsB,MAAM,CAAC,CAAC,SAAS,MAAM,CAAC,CAAC,CAAC,CAAE,SAAQ,IAAI,CAAC,CAAC,CAAC;IAC/D,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,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAGvB,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC;IAC7B,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC;IACzB,SAAS,CAAC,QAAQ,UAAS;IAC3B,SAAS,CAAC,MAAM,SAAK;IACrB,SAAS,CAAC,GAAG,SAAK;IAClB,SAAS,CAAC,SAAS,UAAS;gBAEhB,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;IASjF,MAAM,CAAC,IAAI,EAAE,KAAK,GAAG,IAAI;IA0BzB,UAAU,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI;IAkCjC,MAAM,IAAI,UAAU;IAOpB,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC;IAWrB,KAAK,IAAI,CAAC;CAGX;AAED;;;GAGG;AAEH,4EAA4E;AAC5E,eAAO,MAAM,SAAS,EAAE,WAEtB,CAAC;AAEH,8EAA8E;AAC9E,eAAO,MAAM,SAAS,EAAE,WAEtB,CAAC;AAEH,6EAA6E;AAC7E,eAAO,MAAM,SAAS,EAAE,WAGtB,CAAC;AAEH,4EAA4E;AAC5E,eAAO,MAAM,SAAS,EAAE,WAGtB,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/_md.js b/node_modules/@noble/hashes/_md.js new file mode 100644 index 0000000000000000000000000000000000000000..53047f3a244b232f63b417cd84b6a8bbdec10107 --- /dev/null +++ b/node_modules/@noble/hashes/_md.js @@ -0,0 +1,162 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SHA512_IV = exports.SHA384_IV = exports.SHA224_IV = exports.SHA256_IV = exports.HashMD = void 0; +exports.setBigUint64 = setBigUint64; +exports.Chi = Chi; +exports.Maj = Maj; +/** + * Internal Merkle-Damgard hash utils. + * @module + */ +const utils_ts_1 = require("./utils.js"); +/** Polyfill for Safari 14. https://caniuse.com/mdn-javascript_builtins_dataview_setbiguint64 */ +function setBigUint64(view, byteOffset, value, isLE) { + if (typeof view.setBigUint64 === 'function') + return view.setBigUint64(byteOffset, value, isLE); + const _32n = BigInt(32); + const _u32_max = BigInt(0xffffffff); + const wh = Number((value >> _32n) & _u32_max); + const wl = Number(value & _u32_max); + const h = isLE ? 4 : 0; + const l = isLE ? 0 : 4; + view.setUint32(byteOffset + h, wh, isLE); + view.setUint32(byteOffset + l, wl, isLE); +} +/** Choice: a ? b : c */ +function Chi(a, b, c) { + return (a & b) ^ (~a & c); +} +/** Majority function, true if any two inputs is true. */ +function Maj(a, b, c) { + return (a & b) ^ (a & c) ^ (b & c); +} +/** + * Merkle-Damgard hash construction base class. + * Could be used to create MD5, RIPEMD, SHA1, SHA2. + */ +class HashMD extends utils_ts_1.Hash { + constructor(blockLen, outputLen, padOffset, isLE) { + super(); + this.finished = false; + this.length = 0; + this.pos = 0; + this.destroyed = false; + this.blockLen = blockLen; + this.outputLen = outputLen; + this.padOffset = padOffset; + this.isLE = isLE; + this.buffer = new Uint8Array(blockLen); + this.view = (0, utils_ts_1.createView)(this.buffer); + } + update(data) { + (0, utils_ts_1.aexists)(this); + data = (0, utils_ts_1.toBytes)(data); + (0, utils_ts_1.abytes)(data); + const { view, buffer, blockLen } = this; + const len = data.length; + for (let pos = 0; pos < len;) { + const take = Math.min(blockLen - this.pos, len - pos); + // Fast path: we have at least one block in input, cast it to view and process + if (take === blockLen) { + const dataView = (0, utils_ts_1.createView)(data); + for (; blockLen <= len - pos; pos += blockLen) + this.process(dataView, pos); + continue; + } + buffer.set(data.subarray(pos, pos + take), this.pos); + this.pos += take; + pos += take; + if (this.pos === blockLen) { + this.process(view, 0); + this.pos = 0; + } + } + this.length += data.length; + this.roundClean(); + return this; + } + digestInto(out) { + (0, utils_ts_1.aexists)(this); + (0, utils_ts_1.aoutput)(out, this); + this.finished = true; + // Padding + // We can avoid allocation of buffer for padding completely if it + // was previously not allocated here. But it won't change performance. + const { buffer, view, blockLen, isLE } = this; + let { pos } = this; + // append the bit '1' to the message + buffer[pos++] = 0b10000000; + (0, utils_ts_1.clean)(this.buffer.subarray(pos)); + // we have less than padOffset left in buffer, so we cannot put length in + // current block, need process it and pad again + if (this.padOffset > blockLen - pos) { + this.process(view, 0); + pos = 0; + } + // Pad until full block byte with zeros + for (let i = pos; i < blockLen; i++) + buffer[i] = 0; + // Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that + // You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen. + // So we just write lowest 64 bits of that value. + setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE); + this.process(view, 0); + const oview = (0, utils_ts_1.createView)(out); + const len = this.outputLen; + // NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT + if (len % 4) + throw new Error('_sha2: outputLen should be aligned to 32bit'); + const outLen = len / 4; + const state = this.get(); + if (outLen > state.length) + throw new Error('_sha2: outputLen bigger than state'); + for (let i = 0; i < outLen; i++) + oview.setUint32(4 * i, state[i], isLE); + } + digest() { + const { buffer, outputLen } = this; + this.digestInto(buffer); + const res = buffer.slice(0, outputLen); + this.destroy(); + return res; + } + _cloneInto(to) { + to || (to = new this.constructor()); + to.set(...this.get()); + const { blockLen, buffer, length, finished, destroyed, pos } = this; + to.destroyed = destroyed; + to.finished = finished; + to.length = length; + to.pos = pos; + if (length % blockLen) + to.buffer.set(buffer); + return to; + } + clone() { + return this._cloneInto(); + } +} +exports.HashMD = HashMD; +/** + * Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53. + * Check out `test/misc/sha2-gen-iv.js` for recomputation guide. + */ +/** Initial SHA256 state. Bits 0..32 of frac part of sqrt of primes 2..19 */ +exports.SHA256_IV = Uint32Array.from([ + 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19, +]); +/** Initial SHA224 state. Bits 32..64 of frac part of sqrt of primes 23..53 */ +exports.SHA224_IV = Uint32Array.from([ + 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4, +]); +/** Initial SHA384 state. Bits 0..64 of frac part of sqrt of primes 23..53 */ +exports.SHA384_IV = Uint32Array.from([ + 0xcbbb9d5d, 0xc1059ed8, 0x629a292a, 0x367cd507, 0x9159015a, 0x3070dd17, 0x152fecd8, 0xf70e5939, + 0x67332667, 0xffc00b31, 0x8eb44a87, 0x68581511, 0xdb0c2e0d, 0x64f98fa7, 0x47b5481d, 0xbefa4fa4, +]); +/** Initial SHA512 state. Bits 0..64 of frac part of sqrt of primes 2..19 */ +exports.SHA512_IV = Uint32Array.from([ + 0x6a09e667, 0xf3bcc908, 0xbb67ae85, 0x84caa73b, 0x3c6ef372, 0xfe94f82b, 0xa54ff53a, 0x5f1d36f1, + 0x510e527f, 0xade682d1, 0x9b05688c, 0x2b3e6c1f, 0x1f83d9ab, 0xfb41bd6b, 0x5be0cd19, 0x137e2179, +]); +//# sourceMappingURL=_md.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/_md.js.map b/node_modules/@noble/hashes/_md.js.map new file mode 100644 index 0000000000000000000000000000000000000000..07270e0a50d0d2ab94efb129864f2ba94d479d3c --- /dev/null +++ b/node_modules/@noble/hashes/_md.js.map @@ -0,0 +1 @@ +{"version":3,"file":"_md.js","sourceRoot":"","sources":["src/_md.ts"],"names":[],"mappings":";;;AAOA,oCAeC;AAGD,kBAEC;AAGD,kBAEC;AAhCD;;;GAGG;AACH,yCAAoG;AAEpG,gGAAgG;AAChG,SAAgB,YAAY,CAC1B,IAAc,EACd,UAAkB,EAClB,KAAa,EACb,IAAa;IAEb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,EAAE,UAAU;CAC/F,CAAC,CAAC;AAEH,4EAA4E;AAC/D,QAAA,SAAS,GAAgC,WAAW,CAAC,IAAI,CAAC;IACrE,UAAU,EAAE,UAAU,EAAE,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"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/_u64.d.ts b/node_modules/@noble/hashes/_u64.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ac5523a329e78222c6e8898f97a2eaf339780fad --- /dev/null +++ b/node_modules/@noble/hashes/_u64.d.ts @@ -0,0 +1,55 @@ +declare function fromBig(n: bigint, le?: boolean): { + h: number; + l: number; +}; +declare function split(lst: bigint[], le?: boolean): Uint32Array[]; +declare const toBig: (h: number, l: number) => bigint; +declare const shrSH: (h: number, _l: number, s: number) => number; +declare const shrSL: (h: number, l: number, s: number) => number; +declare const rotrSH: (h: number, l: number, s: number) => number; +declare const rotrSL: (h: number, l: number, s: number) => number; +declare const rotrBH: (h: number, l: number, s: number) => number; +declare const rotrBL: (h: number, l: number, s: number) => number; +declare const rotr32H: (_h: number, l: number) => number; +declare const rotr32L: (h: number, _l: number) => number; +declare const rotlSH: (h: number, l: number, s: number) => number; +declare const rotlSL: (h: number, l: number, s: number) => number; +declare const rotlBH: (h: number, l: number, s: number) => number; +declare const rotlBL: (h: number, l: number, s: number) => number; +declare function add(Ah: number, Al: number, Bh: number, Bl: number): { + h: number; + l: number; +}; +declare const add3L: (Al: number, Bl: number, Cl: number) => number; +declare const add3H: (low: number, Ah: number, Bh: number, Ch: number) => number; +declare const add4L: (Al: number, Bl: number, Cl: number, Dl: number) => number; +declare const add4H: (low: number, Ah: number, Bh: number, Ch: number, Dh: number) => number; +declare const add5L: (Al: number, Bl: number, Cl: number, Dl: number, El: number) => number; +declare const add5H: (low: number, Ah: number, Bh: number, Ch: number, Dh: number, Eh: number) => number; +export { add, add3H, add3L, add4H, add4L, add5H, add5L, fromBig, rotlBH, rotlBL, rotlSH, rotlSL, rotr32H, rotr32L, rotrBH, rotrBL, rotrSH, rotrSL, shrSH, shrSL, split, toBig }; +declare const u64: { + fromBig: typeof fromBig; + split: typeof split; + toBig: (h: number, l: number) => bigint; + shrSH: (h: number, _l: number, s: number) => number; + shrSL: (h: number, l: number, s: number) => number; + rotrSH: (h: number, l: number, s: number) => number; + rotrSL: (h: number, l: number, s: number) => number; + rotrBH: (h: number, l: number, s: number) => number; + rotrBL: (h: number, l: number, s: number) => number; + rotr32H: (_h: number, l: number) => number; + rotr32L: (h: number, _l: number) => number; + rotlSH: (h: number, l: number, s: number) => number; + rotlSL: (h: number, l: number, s: number) => number; + rotlBH: (h: number, l: number, s: number) => number; + rotlBL: (h: number, l: number, s: number) => number; + add: typeof add; + add3L: (Al: number, Bl: number, Cl: number) => number; + add3H: (low: number, Ah: number, Bh: number, Ch: number) => number; + add4L: (Al: number, Bl: number, Cl: number, Dl: number) => number; + add4H: (low: number, Ah: number, Bh: number, Ch: number, Dh: number) => number; + add5H: (low: number, Ah: number, Bh: number, Ch: number, Dh: number, Eh: number) => number; + add5L: (Al: number, Bl: number, Cl: number, Dl: number, El: number) => number; +}; +export default u64; +//# sourceMappingURL=_u64.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/_u64.d.ts.map b/node_modules/@noble/hashes/_u64.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..211a4c691318fed673b7a60dc5db5bc3969739c2 --- /dev/null +++ b/node_modules/@noble/hashes/_u64.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"_u64.d.ts","sourceRoot":"","sources":["src/_u64.ts"],"names":[],"mappings":"AAQA,iBAAS,OAAO,CACd,CAAC,EAAE,MAAM,EACT,EAAE,UAAQ,GACT;IACD,CAAC,EAAE,MAAM,CAAC;IACV,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CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/_u64.js b/node_modules/@noble/hashes/_u64.js new file mode 100644 index 0000000000000000000000000000000000000000..3232f4dd507a0a795ff0f9a8bc0afebf376c3602 --- /dev/null +++ b/node_modules/@noble/hashes/_u64.js @@ -0,0 +1,90 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.toBig = exports.shrSL = exports.shrSH = exports.rotrSL = exports.rotrSH = exports.rotrBL = exports.rotrBH = exports.rotr32L = exports.rotr32H = exports.rotlSL = exports.rotlSH = exports.rotlBL = exports.rotlBH = exports.add5L = exports.add5H = exports.add4L = exports.add4H = exports.add3L = exports.add3H = void 0; +exports.add = add; +exports.fromBig = fromBig; +exports.split = split; +/** + * Internal helpers for u64. BigUint64Array is too slow as per 2025, so we implement it using Uint32Array. + * @todo re-check https://issues.chromium.org/issues/42212588 + * @module + */ +const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1); +const _32n = /* @__PURE__ */ BigInt(32); +function fromBig(n, le = false) { + if (le) + return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) }; + return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 }; +} +function split(lst, le = false) { + const len = lst.length; + let Ah = new Uint32Array(len); + let Al = new Uint32Array(len); + for (let i = 0; i < len; i++) { + const { h, l } = fromBig(lst[i], le); + [Ah[i], Al[i]] = [h, l]; + } + return [Ah, Al]; +} +const toBig = (h, l) => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0); +exports.toBig = toBig; +// for Shift in [0, 32) +const shrSH = (h, _l, s) => h >>> s; +exports.shrSH = shrSH; +const shrSL = (h, l, s) => (h << (32 - s)) | (l >>> s); +exports.shrSL = shrSL; +// Right rotate for Shift in [1, 32) +const rotrSH = (h, l, s) => (h >>> s) | (l << (32 - s)); +exports.rotrSH = rotrSH; +const rotrSL = (h, l, s) => (h << (32 - s)) | (l >>> s); +exports.rotrSL = rotrSL; +// Right rotate for Shift in (32, 64), NOTE: 32 is special case. +const rotrBH = (h, l, s) => (h << (64 - s)) | (l >>> (s - 32)); +exports.rotrBH = rotrBH; +const rotrBL = (h, l, s) => (h >>> (s - 32)) | (l << (64 - s)); +exports.rotrBL = rotrBL; +// Right rotate for shift===32 (just swaps l&h) +const rotr32H = (_h, l) => l; +exports.rotr32H = rotr32H; +const rotr32L = (h, _l) => h; +exports.rotr32L = rotr32L; +// Left rotate for Shift in [1, 32) +const rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s)); +exports.rotlSH = rotlSH; +const rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s)); +exports.rotlSL = rotlSL; +// Left rotate for Shift in (32, 64), NOTE: 32 is special case. +const rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s)); +exports.rotlBH = rotlBH; +const rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s)); +exports.rotlBL = rotlBL; +// JS uses 32-bit signed integers for bitwise operations which means we cannot +// simple take carry out of low bit sum by shift, we need to use division. +function add(Ah, Al, Bh, Bl) { + const l = (Al >>> 0) + (Bl >>> 0); + return { h: (Ah + Bh + ((l / 2 ** 32) | 0)) | 0, l: l | 0 }; +} +// Addition with more than 2 elements +const add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0); +exports.add3L = add3L; +const add3H = (low, Ah, Bh, Ch) => (Ah + Bh + Ch + ((low / 2 ** 32) | 0)) | 0; +exports.add3H = add3H; +const add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0); +exports.add4L = add4L; +const add4H = (low, Ah, Bh, Ch, Dh) => (Ah + Bh + Ch + Dh + ((low / 2 ** 32) | 0)) | 0; +exports.add4H = add4H; +const add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0); +exports.add5L = add5L; +const add5H = (low, Ah, Bh, Ch, Dh, Eh) => (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0; +exports.add5H = add5H; +// prettier-ignore +const u64 = { + fromBig, split, toBig, + shrSH, shrSL, + rotrSH, rotrSL, rotrBH, rotrBL, + rotr32H, rotr32L, + rotlSH, rotlSL, rotlBH, rotlBL, + add, add3L, add3H, add4L, add4H, add5H, add5L, +}; +exports.default = u64; +//# sourceMappingURL=_u64.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/_u64.js.map b/node_modules/@noble/hashes/_u64.js.map new file mode 100644 index 0000000000000000000000000000000000000000..49ffb25ec317fa31f459b9376297b4f8d4f07b54 --- /dev/null +++ b/node_modules/@noble/hashes/_u64.js.map @@ -0,0 +1 @@ +{"version":3,"file":"_u64.js","sourceRoot":"","sources":["src/_u64.ts"],"names":[],"mappings":";;;AA+EE,kBAAG;AAA4C,0BAAO;AAAkG,sBAAK;AA/E/J;;;;GAIG;AACH,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,SAAS,OAAO,CACd,CAAS,EACT,EAAE,GAAG,KAAK;IAKV,IAAI,EAAE;QAAE,OAAO,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,UAAU,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,GAAG,UAAU,CAAC,EAAE,CAAC;IAClF,OAAO,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;AACpF,CAAC;AAED,SAAS,KAAK,CAAC,GAAa,EAAE,EAAE,GAAG,KAAK;IACtC,MAAM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AAM,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,kBAAe,GAAG,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/argon2.d.ts b/node_modules/@noble/hashes/argon2.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..67cb8f6b76ef76f2657fd14855397b1da12ac6f6 --- /dev/null +++ b/node_modules/@noble/hashes/argon2.d.ts @@ -0,0 +1,32 @@ +import { type KDFInput } from './utils.ts'; +/** + * Argon2 options. + * * t: time cost, m: mem cost in kb, p: parallelization. + * * key: optional key. personalization: arbitrary extra data. + * * dkLen: desired number of output bytes. + */ +export type ArgonOpts = { + t: number; + m: number; + p: number; + version?: number; + key?: KDFInput; + personalization?: KDFInput; + dkLen?: number; + asyncTick?: number; + maxmem?: number; + onProgress?: (progress: number) => void; +}; +/** argon2d GPU-resistant version. */ +export declare const argon2d: (password: KDFInput, salt: KDFInput, opts: ArgonOpts) => Uint8Array; +/** argon2i side-channel-resistant version. */ +export declare const argon2i: (password: KDFInput, salt: KDFInput, opts: ArgonOpts) => Uint8Array; +/** argon2id, combining i+d, the most popular version from RFC 9106 */ +export declare const argon2id: (password: KDFInput, salt: KDFInput, opts: ArgonOpts) => Uint8Array; +/** argon2d async GPU-resistant version. */ +export declare const argon2dAsync: (password: KDFInput, salt: KDFInput, opts: ArgonOpts) => Promise; +/** argon2i async side-channel-resistant version. */ +export declare const argon2iAsync: (password: KDFInput, salt: KDFInput, opts: ArgonOpts) => Promise; +/** argon2id async, combining i+d, the most popular version from RFC 9106 */ +export declare const argon2idAsync: (password: KDFInput, salt: KDFInput, opts: ArgonOpts) => Promise; +//# sourceMappingURL=argon2.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/argon2.d.ts.map b/node_modules/@noble/hashes/argon2.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..0928c343491a2a029ba549081abec0fec72c5313 --- /dev/null +++ b/node_modules/@noble/hashes/argon2.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"argon2.d.ts","sourceRoot":"","sources":["src/argon2.ts"],"names":[],"mappings":"AAYA,OAAO,EAAqD,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAkK9F;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,QAAQ,CAAC;IACf,eAAe,CAAC,EAAE,QAAQ,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC,CAAC;AAuNF,qCAAqC;AACrC,eAAO,MAAM,OAAO,GAAI,UAAU,QAAQ,EAAE,MAAM,QAAQ,EAAE,MAAM,SAAS,KAAG,UACnC,CAAC;AAC5C,8CAA8C;AAC9C,eAAO,MAAM,OAAO,GAAI,UAAU,QAAQ,EAAE,MAAM,QAAQ,EAAE,MAAM,SAAS,KAAG,UACpC,CAAC;AAC3C,sEAAsE;AACtE,eAAO,MAAM,QAAQ,GAAI,UAAU,QAAQ,EAAE,MAAM,QAAQ,EAAE,MAAM,SAAS,KAAG,UACpC,CAAC;AAiE5C,2CAA2C;AAC3C,eAAO,MAAM,YAAY,GACvB,UAAU,QAAQ,EAClB,MAAM,QAAQ,EACd,MAAM,SAAS,KACd,OAAO,CAAC,UAAU,CAAmD,CAAC;AACzE,oDAAoD;AACpD,eAAO,MAAM,YAAY,GACvB,UAAU,QAAQ,EAClB,MAAM,QAAQ,EACd,MAAM,SAAS,KACd,OAAO,CAAC,UAAU,CAAkD,CAAC;AACxE,4EAA4E;AAC5E,eAAO,MAAM,aAAa,GACxB,UAAU,QAAQ,EAClB,MAAM,QAAQ,EACd,MAAM,SAAS,KACd,OAAO,CAAC,UAAU,CAAmD,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/argon2.js b/node_modules/@noble/hashes/argon2.js new file mode 100644 index 0000000000000000000000000000000000000000..44488ac8127025cdcb62fd54b52d0284ab0f50b8 --- /dev/null +++ b/node_modules/@noble/hashes/argon2.js @@ -0,0 +1,401 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.argon2idAsync = exports.argon2iAsync = exports.argon2dAsync = exports.argon2id = exports.argon2i = exports.argon2d = void 0; +/** + * Argon2 KDF from RFC 9106. Can be used to create a key from password and salt. + * We suggest to use Scrypt. JS Argon is 2-10x slower than native code because of 64-bitness: + * * argon uses uint64, but JS doesn't have fast uint64array + * * uint64 multiplication is 1/3 of time + * * `P` function would be very nice with u64, because most of value will be in registers, + * hovewer with u32 it will require 32 registers, which is too much. + * * JS arrays do slow bound checks, so reading from `A2_BUF` slows it down + * @module + */ +const _u64_ts_1 = require("./_u64.js"); +const blake2_ts_1 = require("./blake2.js"); +const utils_ts_1 = require("./utils.js"); +const AT = { Argond2d: 0, Argon2i: 1, Argon2id: 2 }; +const ARGON2_SYNC_POINTS = 4; +const abytesOrZero = (buf) => { + if (buf === undefined) + return Uint8Array.of(); + return (0, utils_ts_1.kdfInputToBytes)(buf); +}; +// u32 * u32 = u64 +function mul(a, b) { + const aL = a & 0xffff; + const aH = a >>> 16; + const bL = b & 0xffff; + const bH = b >>> 16; + const ll = Math.imul(aL, bL); + const hl = Math.imul(aH, bL); + const lh = Math.imul(aL, bH); + const hh = Math.imul(aH, bH); + const carry = (ll >>> 16) + (hl & 0xffff) + lh; + const high = (hh + (hl >>> 16) + (carry >>> 16)) | 0; + const low = (carry << 16) | (ll & 0xffff); + return { h: high, l: low }; +} +function mul2(a, b) { + // 2 * a * b (via shifts) + const { h, l } = mul(a, b); + return { h: ((h << 1) | (l >>> 31)) & 4294967295, l: (l << 1) & 4294967295 }; +} +// BlaMka permutation for Argon2 +// A + B + (2 * u32(A) * u32(B)) +function blamka(Ah, Al, Bh, Bl) { + const { h: Ch, l: Cl } = mul2(Al, Bl); + // A + B + (2 * A * B) + const Rll = (0, _u64_ts_1.add3L)(Al, Bl, Cl); + return { h: (0, _u64_ts_1.add3H)(Rll, Ah, Bh, Ch), l: Rll | 0 }; +} +// Temporary block buffer +const A2_BUF = new Uint32Array(256); // 1024 bytes (matrix 16x16) +function G(a, b, c, d) { + let Al = A2_BUF[2 * a], Ah = A2_BUF[2 * a + 1]; // prettier-ignore + let Bl = A2_BUF[2 * b], Bh = A2_BUF[2 * b + 1]; // prettier-ignore + let Cl = A2_BUF[2 * c], Ch = A2_BUF[2 * c + 1]; // prettier-ignore + let Dl = A2_BUF[2 * d], Dh = A2_BUF[2 * d + 1]; // prettier-ignore + ({ h: Ah, l: Al } = blamka(Ah, Al, Bh, Bl)); + ({ Dh, Dl } = { Dh: Dh ^ Ah, Dl: Dl ^ Al }); + ({ Dh, Dl } = { Dh: (0, _u64_ts_1.rotr32H)(Dh, Dl), Dl: (0, _u64_ts_1.rotr32L)(Dh, Dl) }); + ({ h: Ch, l: Cl } = blamka(Ch, Cl, Dh, Dl)); + ({ Bh, Bl } = { Bh: Bh ^ Ch, Bl: Bl ^ Cl }); + ({ Bh, Bl } = { Bh: (0, _u64_ts_1.rotrSH)(Bh, Bl, 24), Bl: (0, _u64_ts_1.rotrSL)(Bh, Bl, 24) }); + ({ h: Ah, l: Al } = blamka(Ah, Al, Bh, Bl)); + ({ Dh, Dl } = { Dh: Dh ^ Ah, Dl: Dl ^ Al }); + ({ Dh, Dl } = { Dh: (0, _u64_ts_1.rotrSH)(Dh, Dl, 16), Dl: (0, _u64_ts_1.rotrSL)(Dh, Dl, 16) }); + ({ h: Ch, l: Cl } = blamka(Ch, Cl, Dh, Dl)); + ({ Bh, Bl } = { Bh: Bh ^ Ch, Bl: Bl ^ Cl }); + ({ Bh, Bl } = { Bh: (0, _u64_ts_1.rotrBH)(Bh, Bl, 63), Bl: (0, _u64_ts_1.rotrBL)(Bh, Bl, 63) }); + (A2_BUF[2 * a] = Al), (A2_BUF[2 * a + 1] = Ah); + (A2_BUF[2 * b] = Bl), (A2_BUF[2 * b + 1] = Bh); + (A2_BUF[2 * c] = Cl), (A2_BUF[2 * c + 1] = Ch); + (A2_BUF[2 * d] = Dl), (A2_BUF[2 * d + 1] = Dh); +} +// prettier-ignore +function P(v00, v01, v02, v03, v04, v05, v06, v07, v08, v09, v10, v11, v12, v13, v14, v15) { + G(v00, v04, v08, v12); + G(v01, v05, v09, v13); + G(v02, v06, v10, v14); + G(v03, v07, v11, v15); + G(v00, v05, v10, v15); + G(v01, v06, v11, v12); + G(v02, v07, v08, v13); + G(v03, v04, v09, v14); +} +function block(x, xPos, yPos, outPos, needXor) { + for (let i = 0; i < 256; i++) + A2_BUF[i] = x[xPos + i] ^ x[yPos + i]; + // columns (8) + for (let i = 0; i < 128; i += 16) { + // prettier-ignore + P(i, i + 1, i + 2, i + 3, i + 4, i + 5, i + 6, i + 7, i + 8, i + 9, i + 10, i + 11, i + 12, i + 13, i + 14, i + 15); + } + // rows (8) + for (let i = 0; i < 16; i += 2) { + // prettier-ignore + P(i, i + 1, i + 16, i + 17, i + 32, i + 33, i + 48, i + 49, i + 64, i + 65, i + 80, i + 81, i + 96, i + 97, i + 112, i + 113); + } + if (needXor) + for (let i = 0; i < 256; i++) + x[outPos + i] ^= A2_BUF[i] ^ x[xPos + i] ^ x[yPos + i]; + else + for (let i = 0; i < 256; i++) + x[outPos + i] = A2_BUF[i] ^ x[xPos + i] ^ x[yPos + i]; + (0, utils_ts_1.clean)(A2_BUF); +} +// Variable-Length Hash Function H' +function Hp(A, dkLen) { + const A8 = (0, utils_ts_1.u8)(A); + const T = new Uint32Array(1); + const T8 = (0, utils_ts_1.u8)(T); + T[0] = dkLen; + // Fast path + if (dkLen <= 64) + return blake2_ts_1.blake2b.create({ dkLen }).update(T8).update(A8).digest(); + const out = new Uint8Array(dkLen); + let V = blake2_ts_1.blake2b.create({}).update(T8).update(A8).digest(); + let pos = 0; + // First block + out.set(V.subarray(0, 32)); + pos += 32; + // Rest blocks + for (; dkLen - pos > 64; pos += 32) { + const Vh = blake2_ts_1.blake2b.create({}).update(V); + Vh.digestInto(V); + Vh.destroy(); + out.set(V.subarray(0, 32), pos); + } + // Last block + out.set((0, blake2_ts_1.blake2b)(V, { dkLen: dkLen - pos }), pos); + (0, utils_ts_1.clean)(V, T); + return (0, utils_ts_1.u32)(out); +} +// Used only inside process block! +function indexAlpha(r, s, laneLen, segmentLen, index, randL, sameLane = false) { + // This is ugly, but close enough to reference implementation. + let area; + if (r === 0) { + if (s === 0) + area = index - 1; + else if (sameLane) + area = s * segmentLen + index - 1; + else + area = s * segmentLen + (index == 0 ? -1 : 0); + } + else if (sameLane) + area = laneLen - segmentLen + index - 1; + else + area = laneLen - segmentLen + (index == 0 ? -1 : 0); + const startPos = r !== 0 && s !== ARGON2_SYNC_POINTS - 1 ? (s + 1) * segmentLen : 0; + const rel = area - 1 - mul(area, mul(randL, randL).h).h; + return (startPos + rel) % laneLen; +} +const maxUint32 = Math.pow(2, 32); +function isU32(num) { + return Number.isSafeInteger(num) && num >= 0 && num < maxUint32; +} +function argon2Opts(opts) { + const merged = { + version: 0x13, + dkLen: 32, + maxmem: maxUint32 - 1, + asyncTick: 10, + }; + for (let [k, v] of Object.entries(opts)) + if (v != null) + merged[k] = v; + const { dkLen, p, m, t, version, onProgress } = merged; + if (!isU32(dkLen) || dkLen < 4) + throw new Error('dkLen should be at least 4 bytes'); + if (!isU32(p) || p < 1 || p >= Math.pow(2, 24)) + throw new Error('p should be 1 <= p < 2^24'); + if (!isU32(m)) + throw new Error('m should be 0 <= m < 2^32'); + if (!isU32(t) || t < 1) + throw new Error('t (iterations) should be 1 <= t < 2^32'); + if (onProgress !== undefined && typeof onProgress !== 'function') + throw new Error('progressCb should be function'); + /* + Memory size m MUST be an integer number of kibibytes from 8*p to 2^(32)-1. The actual number of blocks is m', which is m rounded down to the nearest multiple of 4*p. + */ + if (!isU32(m) || m < 8 * p) + throw new Error('memory should be at least 8*p bytes'); + if (version !== 0x10 && version !== 0x13) + throw new Error('unknown version=' + version); + return merged; +} +function argon2Init(password, salt, type, opts) { + password = (0, utils_ts_1.kdfInputToBytes)(password); + salt = (0, utils_ts_1.kdfInputToBytes)(salt); + (0, utils_ts_1.abytes)(password); + (0, utils_ts_1.abytes)(salt); + if (!isU32(password.length)) + throw new Error('password should be less than 4 GB'); + if (!isU32(salt.length) || salt.length < 8) + throw new Error('salt should be at least 8 bytes and less than 4 GB'); + if (!Object.values(AT).includes(type)) + throw new Error('invalid type'); + let { p, dkLen, m, t, version, key, personalization, maxmem, onProgress, asyncTick } = argon2Opts(opts); + // Validation + key = abytesOrZero(key); + personalization = abytesOrZero(personalization); + // H_0 = H^(64)(LE32(p) || LE32(T) || LE32(m) || LE32(t) || + // LE32(v) || LE32(y) || LE32(length(P)) || P || + // LE32(length(S)) || S || LE32(length(K)) || K || + // LE32(length(X)) || X) + const h = blake2_ts_1.blake2b.create({}); + const BUF = new Uint32Array(1); + const BUF8 = (0, utils_ts_1.u8)(BUF); + for (let item of [p, dkLen, m, t, version, type]) { + BUF[0] = item; + h.update(BUF8); + } + for (let i of [password, salt, key, personalization]) { + BUF[0] = i.length; // BUF is u32 array, this is valid + h.update(BUF8).update(i); + } + const H0 = new Uint32Array(18); + const H0_8 = (0, utils_ts_1.u8)(H0); + h.digestInto(H0_8); + // 256 u32 = 1024 (BLOCK_SIZE), fills A2_BUF on processing + // Params + const lanes = p; + // m' = 4 * p * floor (m / 4p) + const mP = 4 * p * Math.floor(m / (ARGON2_SYNC_POINTS * p)); + //q = m' / p columns + const laneLen = Math.floor(mP / p); + const segmentLen = Math.floor(laneLen / ARGON2_SYNC_POINTS); + const memUsed = mP * 256; + if (!isU32(maxmem) || memUsed > maxmem) + throw new Error('mem should be less than 2**32, got: maxmem=' + maxmem + ', memused=' + memUsed); + const B = new Uint32Array(memUsed); + // Fill first blocks + for (let l = 0; l < p; l++) { + const i = 256 * laneLen * l; + // B[i][0] = H'^(1024)(H_0 || LE32(0) || LE32(i)) + H0[17] = l; + H0[16] = 0; + B.set(Hp(H0, 1024), i); + // B[i][1] = H'^(1024)(H_0 || LE32(1) || LE32(i)) + H0[16] = 1; + B.set(Hp(H0, 1024), i + 256); + } + let perBlock = () => { }; + if (onProgress) { + const totalBlock = t * ARGON2_SYNC_POINTS * p * segmentLen; + // Invoke callback if progress changes from 10.01 to 10.02 + // Allows to draw smooth progress bar on up to 8K screen + const callbackPer = Math.max(Math.floor(totalBlock / 10000), 1); + let blockCnt = 0; + perBlock = () => { + blockCnt++; + if (onProgress && (!(blockCnt % callbackPer) || blockCnt === totalBlock)) + onProgress(blockCnt / totalBlock); + }; + } + (0, utils_ts_1.clean)(BUF, H0); + return { type, mP, p, t, version, B, laneLen, lanes, segmentLen, dkLen, perBlock, asyncTick }; +} +function argon2Output(B, p, laneLen, dkLen) { + const B_final = new Uint32Array(256); + for (let l = 0; l < p; l++) + for (let j = 0; j < 256; j++) + B_final[j] ^= B[256 * (laneLen * l + laneLen - 1) + j]; + const res = (0, utils_ts_1.u8)(Hp(B_final, dkLen)); + (0, utils_ts_1.clean)(B_final); + return res; +} +function processBlock(B, address, l, r, s, index, laneLen, segmentLen, lanes, offset, prev, dataIndependent, needXor) { + if (offset % laneLen) + prev = offset - 1; + let randL, randH; + if (dataIndependent) { + let i128 = index % 128; + if (i128 === 0) { + address[256 + 12]++; + block(address, 256, 2 * 256, 0, false); + block(address, 0, 2 * 256, 0, false); + } + randL = address[2 * i128]; + randH = address[2 * i128 + 1]; + } + else { + const T = 256 * prev; + randL = B[T]; + randH = B[T + 1]; + } + // address block + const refLane = r === 0 && s === 0 ? l : randH % lanes; + const refPos = indexAlpha(r, s, laneLen, segmentLen, index, randL, refLane == l); + const refBlock = laneLen * refLane + refPos; + // B[i][j] = G(B[i][j-1], B[l][z]) + block(B, 256 * prev, 256 * refBlock, offset * 256, needXor); +} +function argon2(type, password, salt, opts) { + const { mP, p, t, version, B, laneLen, lanes, segmentLen, dkLen, perBlock } = argon2Init(password, salt, type, opts); + // Pre-loop setup + // [address, input, zero_block] format so we can pass single U32 to block function + const address = new Uint32Array(3 * 256); + address[256 + 6] = mP; + address[256 + 8] = t; + address[256 + 10] = type; + for (let r = 0; r < t; r++) { + const needXor = r !== 0 && version === 0x13; + address[256 + 0] = r; + for (let s = 0; s < ARGON2_SYNC_POINTS; s++) { + address[256 + 4] = s; + const dataIndependent = type == AT.Argon2i || (type == AT.Argon2id && r === 0 && s < 2); + for (let l = 0; l < p; l++) { + address[256 + 2] = l; + address[256 + 12] = 0; + let startPos = 0; + if (r === 0 && s === 0) { + startPos = 2; + if (dataIndependent) { + address[256 + 12]++; + block(address, 256, 2 * 256, 0, false); + block(address, 0, 2 * 256, 0, false); + } + } + // current block postion + let offset = l * laneLen + s * segmentLen + startPos; + // previous block position + let prev = offset % laneLen ? offset - 1 : offset + laneLen - 1; + for (let index = startPos; index < segmentLen; index++, offset++, prev++) { + perBlock(); + processBlock(B, address, l, r, s, index, laneLen, segmentLen, lanes, offset, prev, dataIndependent, needXor); + } + } + } + } + (0, utils_ts_1.clean)(address); + return argon2Output(B, p, laneLen, dkLen); +} +/** argon2d GPU-resistant version. */ +const argon2d = (password, salt, opts) => argon2(AT.Argond2d, password, salt, opts); +exports.argon2d = argon2d; +/** argon2i side-channel-resistant version. */ +const argon2i = (password, salt, opts) => argon2(AT.Argon2i, password, salt, opts); +exports.argon2i = argon2i; +/** argon2id, combining i+d, the most popular version from RFC 9106 */ +const argon2id = (password, salt, opts) => argon2(AT.Argon2id, password, salt, opts); +exports.argon2id = argon2id; +async function argon2Async(type, password, salt, opts) { + const { mP, p, t, version, B, laneLen, lanes, segmentLen, dkLen, perBlock, asyncTick } = argon2Init(password, salt, type, opts); + // Pre-loop setup + // [address, input, zero_block] format so we can pass single U32 to block function + const address = new Uint32Array(3 * 256); + address[256 + 6] = mP; + address[256 + 8] = t; + address[256 + 10] = type; + let ts = Date.now(); + for (let r = 0; r < t; r++) { + const needXor = r !== 0 && version === 0x13; + address[256 + 0] = r; + for (let s = 0; s < ARGON2_SYNC_POINTS; s++) { + address[256 + 4] = s; + const dataIndependent = type == AT.Argon2i || (type == AT.Argon2id && r === 0 && s < 2); + for (let l = 0; l < p; l++) { + address[256 + 2] = l; + address[256 + 12] = 0; + let startPos = 0; + if (r === 0 && s === 0) { + startPos = 2; + if (dataIndependent) { + address[256 + 12]++; + block(address, 256, 2 * 256, 0, false); + block(address, 0, 2 * 256, 0, false); + } + } + // current block postion + let offset = l * laneLen + s * segmentLen + startPos; + // previous block position + let prev = offset % laneLen ? offset - 1 : offset + laneLen - 1; + for (let index = startPos; index < segmentLen; index++, offset++, prev++) { + perBlock(); + processBlock(B, address, l, r, s, index, laneLen, segmentLen, lanes, offset, prev, dataIndependent, needXor); + // Date.now() is not monotonic, so in case if clock goes backwards we return return control too + const diff = Date.now() - ts; + if (!(diff >= 0 && diff < asyncTick)) { + await (0, utils_ts_1.nextTick)(); + ts += diff; + } + } + } + } + } + (0, utils_ts_1.clean)(address); + return argon2Output(B, p, laneLen, dkLen); +} +/** argon2d async GPU-resistant version. */ +const argon2dAsync = (password, salt, opts) => argon2Async(AT.Argond2d, password, salt, opts); +exports.argon2dAsync = argon2dAsync; +/** argon2i async side-channel-resistant version. */ +const argon2iAsync = (password, salt, opts) => argon2Async(AT.Argon2i, password, salt, opts); +exports.argon2iAsync = argon2iAsync; +/** argon2id async, combining i+d, the most popular version from RFC 9106 */ +const argon2idAsync = (password, salt, opts) => argon2Async(AT.Argon2id, password, salt, opts); +exports.argon2idAsync = argon2idAsync; +//# sourceMappingURL=argon2.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/argon2.js.map b/node_modules/@noble/hashes/argon2.js.map new file mode 100644 index 0000000000000000000000000000000000000000..74bde80fd27fe58c02c72505ccb6211e87b5bc2d --- /dev/null +++ b/node_modules/@noble/hashes/argon2.js.map @@ -0,0 +1 @@ +{"version":3,"file":"argon2.js","sourceRoot":"","sources":["src/argon2.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,uCAA2F;AAC3F,2CAAsC;AACtC,yCAA8F;AAE9F,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAW,CAAC;AAG7D,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAC7B,MAAM,YAAY,GAAG,CAAC,GAAc,EAAE,EAAE;IACtC,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,UAAU,CAAC,EAAE,EAAE,CAAC;IAC9C,OAAO,IAAA,0BAAe,EAAC,GAAG,CAAC,CAAC;AAC9B,CAAC,CAAC;AAEF,kBAAkB;AAClB,SAAS,GAAG,CAAC,CAAS,EAAE,CAAS;IAC/B,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC;IACtB,MAAM,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC;IACpB,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC;IACtB,MAAM,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC;IACpB,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAC7B,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAC7B,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC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A2C;AACpC,MAAM,YAAY,GAAG,CAC1B,QAAkB,EAClB,IAAc,EACd,IAAe,EACM,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAJ5D,QAAA,YAAY,gBAIgD;AACzE,oDAAoD;AAC7C,MAAM,YAAY,GAAG,CAC1B,QAAkB,EAClB,IAAc,EACd,IAAe,EACM,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAJ3D,QAAA,YAAY,gBAI+C;AACxE,4EAA4E;AACrE,MAAM,aAAa,GAAG,CAC3B,QAAkB,EAClB,IAAc,EACd,IAAe,EACM,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAJ5D,QAAA,aAAa,iBAI+C"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/blake1.d.ts b/node_modules/@noble/hashes/blake1.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..62d576f248d21abd41e95c98bb4b4699de0065c1 --- /dev/null +++ b/node_modules/@noble/hashes/blake1.d.ts @@ -0,0 +1,106 @@ +import { Hash, type CHashO, type Input } from './utils.ts'; +/** Blake1 options. Basically just "salt" */ +export type BlakeOpts = { + salt?: Uint8Array; +}; +declare abstract class BLAKE1> extends Hash { + protected finished: boolean; + protected length: number; + protected pos: number; + protected destroyed: boolean; + protected buffer: Uint8Array; + protected view: DataView; + protected salt: Uint32Array; + abstract compress(view: DataView, offset: number, withLength?: boolean): void; + protected abstract get(): number[]; + protected abstract set(...args: number[]): void; + readonly blockLen: number; + readonly outputLen: number; + private lengthFlag; + private counterLen; + protected constants: Uint32Array; + constructor(blockLen: number, outputLen: number, lengthFlag: number, counterLen: number, saltLen: number, constants: Uint32Array, opts?: BlakeOpts); + update(data: Input): this; + destroy(): void; + _cloneInto(to?: T): T; + clone(): T; + digestInto(out: Uint8Array): void; + digest(): Uint8Array; +} +declare class Blake1_32 extends BLAKE1 { + private v0; + private v1; + private v2; + private v3; + private v4; + private v5; + private v6; + private v7; + constructor(outputLen: number, IV: Uint32Array, lengthFlag: number, opts?: BlakeOpts); + protected get(): [number, number, number, number, number, number, number, number]; + protected set(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number): void; + destroy(): void; + compress(view: DataView, offset: number, withLength?: boolean): void; +} +declare class Blake1_64 extends BLAKE1 { + private v0l; + private v0h; + private v1l; + private v1h; + private v2l; + private v2h; + private v3l; + private v3h; + private v4l; + private v4h; + private v5l; + private v5h; + private v6l; + private v6h; + private v7l; + private v7h; + constructor(outputLen: number, IV: Uint32Array, lengthFlag: number, opts?: BlakeOpts); + protected get(): [ + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number + ]; + protected set(v0l: number, v0h: number, v1l: number, v1h: number, v2l: number, v2h: number, v3l: number, v3h: number, v4l: number, v4h: number, v5l: number, v5h: number, v6l: number, v6h: number, v7l: number, v7h: number): void; + destroy(): void; + compress(view: DataView, offset: number, withLength?: boolean): void; +} +export declare class BLAKE224 extends Blake1_32 { + constructor(opts?: BlakeOpts); +} +export declare class BLAKE256 extends Blake1_32 { + constructor(opts?: BlakeOpts); +} +export declare class BLAKE384 extends Blake1_64 { + constructor(opts?: BlakeOpts); +} +export declare class BLAKE512 extends Blake1_64 { + constructor(opts?: BlakeOpts); +} +/** blake1-224 hash function */ +export declare const blake224: CHashO; +/** blake1-256 hash function */ +export declare const blake256: CHashO; +/** blake1-384 hash function */ +export declare const blake384: CHashO; +/** blake1-512 hash function */ +export declare const blake512: CHashO; +export {}; +//# sourceMappingURL=blake1.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/blake1.d.ts.map b/node_modules/@noble/hashes/blake1.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..cecd4dfbb12ecc2560fdbe682ca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OAAO,IAAI,IAAI;IAIf,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,UAAO,GAAG,IAAI;CAiDlE;AAED,qBAAa,QAAS,SAAQ,SAAS;gBACzB,IAAI,GAAE,SAAc;CAGjC;AACD,qBAAa,QAAS,SAAQ,SAAS;gBACzB,IAAI,GAAE,SAAc;CAGjC;AACD,qBAAa,QAAS,SAAQ,SAAS;gBACzB,IAAI,GAAE,SAAc;CAGjC;AACD,qBAAa,QAAS,SAAQ,SAAS;gBACzB,IAAI,GAAE,SAAc;CAGjC;AACD,+BAA+B;AAC/B,eAAO,MAAM,QAAQ,EAAE,MAEtB,CAAC;AACF,+BAA+B;AAC/B,eAAO,MAAM,QAAQ,EAAE,MAEtB,CAAC;AACF,+BAA+B;AAC/B,eAAO,MAAM,QAAQ,EAAE,MAEtB,CAAC;AACF,+BAA+B;AAC/B,eAAO,MAAM,QAAQ,EAAE,MAEtB,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/blake1.js b/node_modules/@noble/hashes/blake1.js new file mode 100644 index 0000000000000000000000000000000000000000..a877fcbd4a7ab5ef90ce3aae46c52b35e25caea9 --- /dev/null +++ b/node_modules/@noble/hashes/blake1.js @@ -0,0 +1,459 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.blake512 = exports.blake384 = exports.blake256 = exports.blake224 = exports.BLAKE512 = exports.BLAKE384 = exports.BLAKE256 = exports.BLAKE224 = void 0; +/** + * Blake1 legacy hash function, one of SHA3 proposals. + * Rarely used. Check out blake2 or blake3 instead. + * https://www.aumasson.jp/blake/blake.pdf + * + * In the best case, there are 0 allocations. + * + * Differences from blake2: + * + * - BE instead of LE + * - Paddings, similar to MD5, RIPEMD, SHA1, SHA2, but: + * - length flag is located before actual length + * - padding block is compressed differently (no lengths) + * Instead of msg[sigma[k]], we have `msg[sigma[k]] ^ constants[sigma[k-1]]` + * (-1 for g1, g2 without -1) + * - Salt is XOR-ed into constants instead of state + * - Salt is XOR-ed with output in `compress` + * - Additional rows (+64 bytes) in SIGMA for new rounds + * - Different round count: + * - 14 / 10 rounds in blake256 / blake2s + * - 16 / 12 rounds in blake512 / blake2b + * - blake512: G1b: rotr 24 -> 25, G2b: rotr 63 -> 11 + * @module + */ +const _blake_ts_1 = require("./_blake.js"); +const _md_ts_1 = require("./_md.js"); +const u64 = require("./_u64.js"); +// prettier-ignore +const utils_ts_1 = require("./utils.js"); +// Empty zero-filled salt +const EMPTY_SALT = /* @__PURE__ */ new Uint32Array(8); +class BLAKE1 extends utils_ts_1.Hash { + constructor(blockLen, outputLen, lengthFlag, counterLen, saltLen, constants, opts = {}) { + super(); + this.finished = false; + this.length = 0; + this.pos = 0; + this.destroyed = false; + const { salt } = opts; + this.blockLen = blockLen; + this.outputLen = outputLen; + this.lengthFlag = lengthFlag; + this.counterLen = counterLen; + this.buffer = new Uint8Array(blockLen); + this.view = (0, utils_ts_1.createView)(this.buffer); + if (salt) { + let slt = salt; + slt = (0, utils_ts_1.toBytes)(slt); + (0, utils_ts_1.abytes)(slt); + if (slt.length !== 4 * saltLen) + throw new Error('wrong salt length'); + const salt32 = (this.salt = new Uint32Array(saltLen)); + const sv = (0, utils_ts_1.createView)(slt); + this.constants = constants.slice(); + for (let i = 0, offset = 0; i < salt32.length; i++, offset += 4) { + salt32[i] = sv.getUint32(offset, false); + this.constants[i] ^= salt32[i]; + } + } + else { + this.salt = EMPTY_SALT; + this.constants = constants; + } + } + update(data) { + (0, utils_ts_1.aexists)(this); + data = (0, utils_ts_1.toBytes)(data); + (0, utils_ts_1.abytes)(data); + // From _md, but update length before each compress + const { view, buffer, blockLen } = this; + const len = data.length; + let dataView; + for (let pos = 0; pos < len;) { + const take = Math.min(blockLen - this.pos, len - pos); + // Fast path: we have at least one block in input, cast it to view and process + if (take === blockLen) { + if (!dataView) + dataView = (0, utils_ts_1.createView)(data); + for (; blockLen <= len - pos; pos += blockLen) { + this.length += blockLen; + this.compress(dataView, pos); + } + continue; + } + buffer.set(data.subarray(pos, pos + take), this.pos); + this.pos += take; + pos += take; + if (this.pos === blockLen) { + this.length += blockLen; + this.compress(view, 0, true); + this.pos = 0; + } + } + return this; + } + destroy() { + this.destroyed = true; + if (this.salt !== EMPTY_SALT) { + (0, utils_ts_1.clean)(this.salt, this.constants); + } + } + _cloneInto(to) { + to || (to = new this.constructor()); + to.set(...this.get()); + const { buffer, length, finished, destroyed, constants, salt, pos } = this; + to.buffer.set(buffer); + to.constants = constants.slice(); + to.destroyed = destroyed; + to.finished = finished; + to.length = length; + to.pos = pos; + to.salt = salt.slice(); + return to; + } + clone() { + return this._cloneInto(); + } + digestInto(out) { + (0, utils_ts_1.aexists)(this); + (0, utils_ts_1.aoutput)(out, this); + this.finished = true; + // Padding + const { buffer, blockLen, counterLen, lengthFlag, view } = this; + (0, utils_ts_1.clean)(buffer.subarray(this.pos)); // clean buf + const counter = BigInt((this.length + this.pos) * 8); + const counterPos = blockLen - counterLen - 1; + buffer[this.pos] |= 128; // End block flag + this.length += this.pos; // add unwritten length + // Not enough in buffer for length: write what we have. + if (this.pos > counterPos) { + this.compress(view, 0); + (0, utils_ts_1.clean)(buffer); + this.pos = 0; + } + // Difference with md: here we have lengthFlag! + buffer[counterPos] |= lengthFlag; // Length flag + // We always set 8 byte length flag. Because length will overflow significantly sooner. + (0, _md_ts_1.setBigUint64)(view, blockLen - 8, counter, false); + this.compress(view, 0, this.pos !== 0); // don't add length if length is not empty block? + // Write output + (0, utils_ts_1.clean)(buffer); + const v = (0, utils_ts_1.createView)(out); + const state = this.get(); + for (let i = 0; i < this.outputLen / 4; ++i) + v.setUint32(i * 4, state[i]); + } + digest() { + const { buffer, outputLen } = this; + this.digestInto(buffer); + const res = buffer.slice(0, outputLen); + this.destroy(); + return res; + } +} +// Constants +const B64C = /* @__PURE__ */ Uint32Array.from([ + 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, + 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, + 0x9216d5d9, 0x8979fb1b, 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, 0xb8e1afed, 0x6a267e96, + 0xba7c9045, 0xf12c7f99, 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16, 0x636920d8, 0x71574e69, +]); +// first half of C512 +const B32C = B64C.slice(0, 16); +const B256_IV = _md_ts_1.SHA256_IV.slice(); +const B224_IV = _md_ts_1.SHA224_IV.slice(); +const B384_IV = _md_ts_1.SHA384_IV.slice(); +const B512_IV = _md_ts_1.SHA512_IV.slice(); +function generateTBL256() { + const TBL = []; + for (let i = 0, j = 0; i < 14; i++, j += 16) { + for (let offset = 1; offset < 16; offset += 2) { + TBL.push(B32C[_blake_ts_1.BSIGMA[j + offset]]); + TBL.push(B32C[_blake_ts_1.BSIGMA[j + offset - 1]]); + } + } + return new Uint32Array(TBL); +} +const TBL256 = /* @__PURE__ */ generateTBL256(); // C256[SIGMA[X]] precompute +// Reusable temporary buffer +const BLAKE256_W = /* @__PURE__ */ new Uint32Array(16); +class Blake1_32 extends BLAKE1 { + constructor(outputLen, IV, lengthFlag, opts = {}) { + super(64, outputLen, lengthFlag, 8, 4, B32C, opts); + this.v0 = IV[0] | 0; + this.v1 = IV[1] | 0; + this.v2 = IV[2] | 0; + this.v3 = IV[3] | 0; + this.v4 = IV[4] | 0; + this.v5 = IV[5] | 0; + this.v6 = IV[6] | 0; + this.v7 = IV[7] | 0; + } + get() { + const { v0, v1, v2, v3, v4, v5, v6, v7 } = this; + return [v0, v1, v2, v3, v4, v5, v6, v7]; + } + // prettier-ignore + set(v0, v1, v2, v3, v4, v5, v6, v7) { + this.v0 = v0 | 0; + this.v1 = v1 | 0; + this.v2 = v2 | 0; + this.v3 = v3 | 0; + this.v4 = v4 | 0; + this.v5 = v5 | 0; + this.v6 = v6 | 0; + this.v7 = v7 | 0; + } + destroy() { + super.destroy(); + this.set(0, 0, 0, 0, 0, 0, 0, 0); + } + compress(view, offset, withLength = true) { + for (let i = 0; i < 16; i++, offset += 4) + BLAKE256_W[i] = view.getUint32(offset, false); + // NOTE: we cannot re-use compress from blake2s, since there is additional xor over u256[SIGMA[e]] + let v00 = this.v0 | 0; + let v01 = this.v1 | 0; + let v02 = this.v2 | 0; + let v03 = this.v3 | 0; + let v04 = this.v4 | 0; + let v05 = this.v5 | 0; + let v06 = this.v6 | 0; + let v07 = this.v7 | 0; + let v08 = this.constants[0] | 0; + let v09 = this.constants[1] | 0; + let v10 = this.constants[2] | 0; + let v11 = this.constants[3] | 0; + const { h, l } = u64.fromBig(BigInt(withLength ? this.length * 8 : 0)); + let v12 = (this.constants[4] ^ l) >>> 0; + let v13 = (this.constants[5] ^ l) >>> 0; + let v14 = (this.constants[6] ^ h) >>> 0; + let v15 = (this.constants[7] ^ h) >>> 0; + // prettier-ignore + for (let i = 0, k = 0, j = 0; i < 14; i++) { + ({ a: v00, b: v04, c: v08, d: v12 } = (0, _blake_ts_1.G1s)(v00, v04, v08, v12, BLAKE256_W[_blake_ts_1.BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v00, b: v04, c: v08, d: v12 } = (0, _blake_ts_1.G2s)(v00, v04, v08, v12, BLAKE256_W[_blake_ts_1.BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v01, b: v05, c: v09, d: v13 } = (0, _blake_ts_1.G1s)(v01, v05, v09, v13, BLAKE256_W[_blake_ts_1.BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v01, b: v05, c: v09, d: v13 } = (0, _blake_ts_1.G2s)(v01, v05, v09, v13, BLAKE256_W[_blake_ts_1.BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v02, b: v06, c: v10, d: v14 } = (0, _blake_ts_1.G1s)(v02, v06, v10, v14, BLAKE256_W[_blake_ts_1.BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v02, b: v06, c: v10, d: v14 } = (0, _blake_ts_1.G2s)(v02, v06, v10, v14, BLAKE256_W[_blake_ts_1.BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v03, b: v07, c: v11, d: v15 } = (0, _blake_ts_1.G1s)(v03, v07, v11, v15, BLAKE256_W[_blake_ts_1.BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v03, b: v07, c: v11, d: v15 } = (0, _blake_ts_1.G2s)(v03, v07, v11, v15, BLAKE256_W[_blake_ts_1.BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v00, b: v05, c: v10, d: v15 } = (0, _blake_ts_1.G1s)(v00, v05, v10, v15, BLAKE256_W[_blake_ts_1.BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v00, b: v05, c: v10, d: v15 } = (0, _blake_ts_1.G2s)(v00, v05, v10, v15, BLAKE256_W[_blake_ts_1.BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v01, b: v06, c: v11, d: v12 } = (0, _blake_ts_1.G1s)(v01, v06, v11, v12, BLAKE256_W[_blake_ts_1.BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v01, b: v06, c: v11, d: v12 } = (0, _blake_ts_1.G2s)(v01, v06, v11, v12, BLAKE256_W[_blake_ts_1.BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v02, b: v07, c: v08, d: v13 } = (0, _blake_ts_1.G1s)(v02, v07, v08, v13, BLAKE256_W[_blake_ts_1.BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v02, b: v07, c: v08, d: v13 } = (0, _blake_ts_1.G2s)(v02, v07, v08, v13, BLAKE256_W[_blake_ts_1.BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v03, b: v04, c: v09, d: v14 } = (0, _blake_ts_1.G1s)(v03, v04, v09, v14, BLAKE256_W[_blake_ts_1.BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v03, b: v04, c: v09, d: v14 } = (0, _blake_ts_1.G2s)(v03, v04, v09, v14, BLAKE256_W[_blake_ts_1.BSIGMA[k++]] ^ TBL256[j++])); + } + this.v0 = (this.v0 ^ v00 ^ v08 ^ this.salt[0]) >>> 0; + this.v1 = (this.v1 ^ v01 ^ v09 ^ this.salt[1]) >>> 0; + this.v2 = (this.v2 ^ v02 ^ v10 ^ this.salt[2]) >>> 0; + this.v3 = (this.v3 ^ v03 ^ v11 ^ this.salt[3]) >>> 0; + this.v4 = (this.v4 ^ v04 ^ v12 ^ this.salt[0]) >>> 0; + this.v5 = (this.v5 ^ v05 ^ v13 ^ this.salt[1]) >>> 0; + this.v6 = (this.v6 ^ v06 ^ v14 ^ this.salt[2]) >>> 0; + this.v7 = (this.v7 ^ v07 ^ v15 ^ this.salt[3]) >>> 0; + (0, utils_ts_1.clean)(BLAKE256_W); + } +} +const BBUF = /* @__PURE__ */ new Uint32Array(32); +const BLAKE512_W = /* @__PURE__ */ new Uint32Array(32); +function generateTBL512() { + const TBL = []; + for (let r = 0, k = 0; r < 16; r++, k += 16) { + for (let offset = 1; offset < 16; offset += 2) { + TBL.push(B64C[_blake_ts_1.BSIGMA[k + offset] * 2 + 0]); + TBL.push(B64C[_blake_ts_1.BSIGMA[k + offset] * 2 + 1]); + TBL.push(B64C[_blake_ts_1.BSIGMA[k + offset - 1] * 2 + 0]); + TBL.push(B64C[_blake_ts_1.BSIGMA[k + offset - 1] * 2 + 1]); + } + } + return new Uint32Array(TBL); +} +const TBL512 = /* @__PURE__ */ generateTBL512(); // C512[SIGMA[X]] precompute +// Mixing function G splitted in two halfs +function G1b(a, b, c, d, msg, k) { + const Xpos = 2 * _blake_ts_1.BSIGMA[k]; + const Xl = msg[Xpos + 1] ^ TBL512[k * 2 + 1], Xh = msg[Xpos] ^ TBL512[k * 2]; // prettier-ignore + let Al = BBUF[2 * a + 1], Ah = BBUF[2 * a]; // prettier-ignore + let Bl = BBUF[2 * b + 1], Bh = BBUF[2 * b]; // prettier-ignore + let Cl = BBUF[2 * c + 1], Ch = BBUF[2 * c]; // prettier-ignore + let Dl = BBUF[2 * d + 1], Dh = BBUF[2 * d]; // prettier-ignore + // v[a] = (v[a] + v[b] + x) | 0; + let ll = u64.add3L(Al, Bl, Xl); + Ah = u64.add3H(ll, Ah, Bh, Xh) >>> 0; + Al = (ll | 0) >>> 0; + // v[d] = rotr(v[d] ^ v[a], 32) + ({ Dh, Dl } = { Dh: Dh ^ Ah, Dl: Dl ^ Al }); + ({ Dh, Dl } = { Dh: u64.rotr32H(Dh, Dl), Dl: u64.rotr32L(Dh, Dl) }); + // v[c] = (v[c] + v[d]) | 0; + ({ h: Ch, l: Cl } = u64.add(Ch, Cl, Dh, Dl)); + // v[b] = rotr(v[b] ^ v[c], 25) + ({ Bh, Bl } = { Bh: Bh ^ Ch, Bl: Bl ^ Cl }); + ({ Bh, Bl } = { Bh: u64.rotrSH(Bh, Bl, 25), Bl: u64.rotrSL(Bh, Bl, 25) }); + (BBUF[2 * a + 1] = Al), (BBUF[2 * a] = Ah); + (BBUF[2 * b + 1] = Bl), (BBUF[2 * b] = Bh); + (BBUF[2 * c + 1] = Cl), (BBUF[2 * c] = Ch); + (BBUF[2 * d + 1] = Dl), (BBUF[2 * d] = Dh); +} +function G2b(a, b, c, d, msg, k) { + const Xpos = 2 * _blake_ts_1.BSIGMA[k]; + const Xl = msg[Xpos + 1] ^ TBL512[k * 2 + 1], Xh = msg[Xpos] ^ TBL512[k * 2]; // prettier-ignore + let Al = BBUF[2 * a + 1], Ah = BBUF[2 * a]; // prettier-ignore + let Bl = BBUF[2 * b + 1], Bh = BBUF[2 * b]; // prettier-ignore + let Cl = BBUF[2 * c + 1], Ch = BBUF[2 * c]; // prettier-ignore + let Dl = BBUF[2 * d + 1], Dh = BBUF[2 * d]; // prettier-ignore + // v[a] = (v[a] + v[b] + x) | 0; + let ll = u64.add3L(Al, Bl, Xl); + Ah = u64.add3H(ll, Ah, Bh, Xh); + Al = ll | 0; + // v[d] = rotr(v[d] ^ v[a], 16) + ({ Dh, Dl } = { Dh: Dh ^ Ah, Dl: Dl ^ Al }); + ({ Dh, Dl } = { Dh: u64.rotrSH(Dh, Dl, 16), Dl: u64.rotrSL(Dh, Dl, 16) }); + // v[c] = (v[c] + v[d]) | 0; + ({ h: Ch, l: Cl } = u64.add(Ch, Cl, Dh, Dl)); + // v[b] = rotr(v[b] ^ v[c], 11) + ({ Bh, Bl } = { Bh: Bh ^ Ch, Bl: Bl ^ Cl }); + ({ Bh, Bl } = { Bh: u64.rotrSH(Bh, Bl, 11), Bl: u64.rotrSL(Bh, Bl, 11) }); + (BBUF[2 * a + 1] = Al), (BBUF[2 * a] = Ah); + (BBUF[2 * b + 1] = Bl), (BBUF[2 * b] = Bh); + (BBUF[2 * c + 1] = Cl), (BBUF[2 * c] = Ch); + (BBUF[2 * d + 1] = Dl), (BBUF[2 * d] = Dh); +} +class Blake1_64 extends BLAKE1 { + constructor(outputLen, IV, lengthFlag, opts = {}) { + super(128, outputLen, lengthFlag, 16, 8, B64C, opts); + this.v0l = IV[0] | 0; + this.v0h = IV[1] | 0; + this.v1l = IV[2] | 0; + this.v1h = IV[3] | 0; + this.v2l = IV[4] | 0; + this.v2h = IV[5] | 0; + this.v3l = IV[6] | 0; + this.v3h = IV[7] | 0; + this.v4l = IV[8] | 0; + this.v4h = IV[9] | 0; + this.v5l = IV[10] | 0; + this.v5h = IV[11] | 0; + this.v6l = IV[12] | 0; + this.v6h = IV[13] | 0; + this.v7l = IV[14] | 0; + this.v7h = IV[15] | 0; + } + // prettier-ignore + get() { + let { v0l, v0h, v1l, v1h, v2l, v2h, v3l, v3h, v4l, v4h, v5l, v5h, v6l, v6h, v7l, v7h } = this; + return [v0l, v0h, v1l, v1h, v2l, v2h, v3l, v3h, v4l, v4h, v5l, v5h, v6l, v6h, v7l, v7h]; + } + // prettier-ignore + set(v0l, v0h, v1l, v1h, v2l, v2h, v3l, v3h, v4l, v4h, v5l, v5h, v6l, v6h, v7l, v7h) { + this.v0l = v0l | 0; + this.v0h = v0h | 0; + this.v1l = v1l | 0; + this.v1h = v1h | 0; + this.v2l = v2l | 0; + this.v2h = v2h | 0; + this.v3l = v3l | 0; + this.v3h = v3h | 0; + this.v4l = v4l | 0; + this.v4h = v4h | 0; + this.v5l = v5l | 0; + this.v5h = v5h | 0; + this.v6l = v6l | 0; + this.v6h = v6h | 0; + this.v7l = v7l | 0; + this.v7h = v7h | 0; + } + destroy() { + super.destroy(); + this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + } + compress(view, offset, withLength = true) { + for (let i = 0; i < 32; i++, offset += 4) + BLAKE512_W[i] = view.getUint32(offset, false); + this.get().forEach((v, i) => (BBUF[i] = v)); // First half from state. + BBUF.set(this.constants.subarray(0, 16), 16); + if (withLength) { + const { h, l } = u64.fromBig(BigInt(this.length * 8)); + BBUF[24] = (BBUF[24] ^ h) >>> 0; + BBUF[25] = (BBUF[25] ^ l) >>> 0; + BBUF[26] = (BBUF[26] ^ h) >>> 0; + BBUF[27] = (BBUF[27] ^ l) >>> 0; + } + for (let i = 0, k = 0; i < 16; i++) { + G1b(0, 4, 8, 12, BLAKE512_W, k++); + G2b(0, 4, 8, 12, BLAKE512_W, k++); + G1b(1, 5, 9, 13, BLAKE512_W, k++); + G2b(1, 5, 9, 13, BLAKE512_W, k++); + G1b(2, 6, 10, 14, BLAKE512_W, k++); + G2b(2, 6, 10, 14, BLAKE512_W, k++); + G1b(3, 7, 11, 15, BLAKE512_W, k++); + G2b(3, 7, 11, 15, BLAKE512_W, k++); + G1b(0, 5, 10, 15, BLAKE512_W, k++); + G2b(0, 5, 10, 15, BLAKE512_W, k++); + G1b(1, 6, 11, 12, BLAKE512_W, k++); + G2b(1, 6, 11, 12, BLAKE512_W, k++); + G1b(2, 7, 8, 13, BLAKE512_W, k++); + G2b(2, 7, 8, 13, BLAKE512_W, k++); + G1b(3, 4, 9, 14, BLAKE512_W, k++); + G2b(3, 4, 9, 14, BLAKE512_W, k++); + } + this.v0l ^= BBUF[0] ^ BBUF[16] ^ this.salt[0]; + this.v0h ^= BBUF[1] ^ BBUF[17] ^ this.salt[1]; + this.v1l ^= BBUF[2] ^ BBUF[18] ^ this.salt[2]; + this.v1h ^= BBUF[3] ^ BBUF[19] ^ this.salt[3]; + this.v2l ^= BBUF[4] ^ BBUF[20] ^ this.salt[4]; + this.v2h ^= BBUF[5] ^ BBUF[21] ^ this.salt[5]; + this.v3l ^= BBUF[6] ^ BBUF[22] ^ this.salt[6]; + this.v3h ^= BBUF[7] ^ BBUF[23] ^ this.salt[7]; + this.v4l ^= BBUF[8] ^ BBUF[24] ^ this.salt[0]; + this.v4h ^= BBUF[9] ^ BBUF[25] ^ this.salt[1]; + this.v5l ^= BBUF[10] ^ BBUF[26] ^ this.salt[2]; + this.v5h ^= BBUF[11] ^ BBUF[27] ^ this.salt[3]; + this.v6l ^= BBUF[12] ^ BBUF[28] ^ this.salt[4]; + this.v6h ^= BBUF[13] ^ BBUF[29] ^ this.salt[5]; + this.v7l ^= BBUF[14] ^ BBUF[30] ^ this.salt[6]; + this.v7h ^= BBUF[15] ^ BBUF[31] ^ this.salt[7]; + (0, utils_ts_1.clean)(BBUF, BLAKE512_W); + } +} +class BLAKE224 extends Blake1_32 { + constructor(opts = {}) { + super(28, B224_IV, 0, opts); + } +} +exports.BLAKE224 = BLAKE224; +class BLAKE256 extends Blake1_32 { + constructor(opts = {}) { + super(32, B256_IV, 1, opts); + } +} +exports.BLAKE256 = BLAKE256; +class BLAKE384 extends Blake1_64 { + constructor(opts = {}) { + super(48, B384_IV, 0, opts); + } +} +exports.BLAKE384 = BLAKE384; +class BLAKE512 extends Blake1_64 { + constructor(opts = {}) { + super(64, B512_IV, 1, opts); + } +} +exports.BLAKE512 = BLAKE512; +/** blake1-224 hash function */ +exports.blake224 = (0, utils_ts_1.createOptHasher)((opts) => new BLAKE224(opts)); +/** blake1-256 hash function */ +exports.blake256 = (0, utils_ts_1.createOptHasher)((opts) => new BLAKE256(opts)); +/** blake1-384 hash function */ +exports.blake384 = (0, utils_ts_1.createOptHasher)((opts) => new BLAKE384(opts)); +/** blake1-512 hash function */ +exports.blake512 = (0, utils_ts_1.createOptHasher)((opts) => new BLAKE512(opts)); +//# sourceMappingURL=blake1.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/blake1.js.map b/node_modules/@noble/hashes/blake1.js.map new file mode 100644 index 0000000000000000000000000000000000000000..314f7a8a54bedd3cbb5ae7368fd5b3de7e6b64a8 --- /dev/null +++ b/node_modules/@noble/hashes/blake1.js.map @@ -0,0 +1 @@ +{"version":3,"file":"blake1.js","sourceRoot":"","sources":["src/blake1.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,2CAA+C;AAC/C,qCAAoF;AACpF,iCAAiC;AACjC,kBAAkB;AAClB,yCAKoB;AAOpB,yBAAyB;AACzB,MAAM,UAAU,GAAG,eAAe,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;AAEtD,MAAe,MAA4B,SAAQ,eAAO;IAmBxD,YACE,QAAgB,EAChB,SAAiB,EACjB,UAAkB,EAClB,UAAkB,EAClB,OAAe,EACf,SAAsB,EACtB,OAAkB,EAAE;QAEpB,KAAK,EAAE,CAAC;QA3BA,aAAQ,GAAG,KAAK,CAAC;QACjB,WAAM,GAAG,CAAC,CAAC;QACX,QAAG,GAAG,CAAC,CAAC;QACR,cAAS,GAAG,KAAK,CAAC;QAyB1B,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,UAAU,CAAC,QAAQ,CAAC,CAAC;QACvC,IAAI,CAAC,IAAI,GAAG,IAAA,qBAAU,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACpC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B;AAClB,QAAA,QAAQ,GAA2B,IAAA,0BAAe,EAC7D,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAC7B,CAAC;AACF,+BAA+B;AAClB,QAAA,QAAQ,GAA2B,IAAA,0BAAe,EAC7D,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAC7B,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/blake2.d.ts b/node_modules/@noble/hashes/blake2.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ea6ae419f21cb3526cbb335fba7044a39542b975 --- /dev/null +++ b/node_modules/@noble/hashes/blake2.d.ts @@ -0,0 +1,116 @@ +import { Hash, type CHashO, type Input } from './utils.ts'; +/** Blake hash options. dkLen is output length. key is used in MAC mode. salt is used in KDF mode. */ +export type Blake2Opts = { + dkLen?: number; + key?: Input; + salt?: Input; + personalization?: Input; +}; +/** Class, from which others are subclassed. */ +export declare abstract class BLAKE2> extends Hash { + protected abstract compress(msg: Uint32Array, offset: number, isLast: boolean): void; + protected abstract get(): number[]; + protected abstract set(...args: number[]): void; + abstract destroy(): void; + protected buffer: Uint8Array; + protected buffer32: Uint32Array; + protected finished: boolean; + protected destroyed: boolean; + protected length: number; + protected pos: number; + readonly blockLen: number; + readonly outputLen: number; + constructor(blockLen: number, outputLen: number); + update(data: Input): this; + digestInto(out: Uint8Array): void; + digest(): Uint8Array; + _cloneInto(to?: T): T; + clone(): T; +} +export declare class BLAKE2b extends BLAKE2 { + private v0l; + private v0h; + private v1l; + private v1h; + private v2l; + private v2h; + private v3l; + private v3h; + private v4l; + private v4h; + private v5l; + private v5h; + private v6l; + private v6h; + private v7l; + private v7h; + constructor(opts?: Blake2Opts); + protected get(): [ + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number + ]; + protected set(v0l: number, v0h: number, v1l: number, v1h: number, v2l: number, v2h: number, v3l: number, v3h: number, v4l: number, v4h: number, v5l: number, v5h: number, v6l: number, v6h: number, v7l: number, v7h: number): void; + protected compress(msg: Uint32Array, offset: number, isLast: boolean): void; + destroy(): void; +} +/** + * Blake2b hash function. 64-bit. 1.5x slower than blake2s in JS. + * @param msg - message that would be hashed + * @param opts - dkLen output length, key for MAC mode, salt, personalization + */ +export declare const blake2b: CHashO; +export type Num16 = { + v0: number; + v1: number; + v2: number; + v3: number; + v4: number; + v5: number; + v6: number; + v7: number; + v8: number; + v9: number; + v10: number; + v11: number; + v12: number; + v13: number; + v14: number; + v15: number; +}; +export declare function compress(s: Uint8Array, offset: number, msg: Uint32Array, rounds: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number): Num16; +export declare class BLAKE2s extends BLAKE2 { + private v0; + private v1; + private v2; + private v3; + private v4; + private v5; + private v6; + private v7; + constructor(opts?: Blake2Opts); + protected get(): [number, number, number, number, number, number, number, number]; + protected set(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number): void; + protected compress(msg: Uint32Array, offset: number, isLast: boolean): void; + destroy(): void; +} +/** + * Blake2s hash function. Focuses on 8-bit to 32-bit platforms. 1.5x faster than blake2b in JS. + * @param msg - message that would be hashed + * @param opts - dkLen output length, key for MAC mode, salt, personalization + */ +export declare const blake2s: CHashO; +//# sourceMappingURL=blake2.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/blake2.d.ts.map b/node_modules/@noble/hashes/blake2.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..f7d88d1b77c821e82a85857a40e6a9979ccc273f --- /dev/null +++ b/node_modules/@noble/hashes/blake2.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"blake2.d.ts","sourceRoot":"","sources":["src/blake2.ts"],"names":[],"mappings":"AASA,OAAO,EAEmB,IAAI,EAC5B,KAAK,MAAM,EAAE,KAAK,KAAK,EACxB,MAAM,YAAY,CAAC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,CAsBP;AAGD,qBAAa,OAAQ,SAAQ,MAAM,CAAC,OAAO,CAAC;IAE1C,OAAO,CAAC,EAAE,CAAiB;IAC3B,OAAO,CAAC,EAAE,CAAiB;IAC3B,OAAO,CAAC,EAAE,CAAiB;IAC3B,OAAO,CAAC,EAAE,CAAiB;IAC3B,OAAO,CAAC,EAAE,CAAiB;IAC3B,OAAO,CAAC,EAAE,CAAiB;IAC3B,OAAO,CAAC,EAAE,CAAiB;IAC3B,OAAO,CAAC,EAAE,CAAiB;gBAEf,IAAI,GAAE,UAAe;IA+BjC,SAAS,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;IAKjF,SAAS,CAAC,GAAG,CACX,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAC7F,IAAI;IAUP,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI;IAkB3E,OAAO,IAAI,IAAI;CAKhB;AAED;;;;GAIG;AACH,eAAO,MAAM,OAAO,EAAE,MAErB,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/blake2.js b/node_modules/@noble/hashes/blake2.js new file mode 100644 index 0000000000000000000000000000000000000000..3b2a0484ff32d46452e9a70be76326566e90a376 --- /dev/null +++ b/node_modules/@noble/hashes/blake2.js @@ -0,0 +1,420 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.blake2s = exports.BLAKE2s = exports.blake2b = exports.BLAKE2b = exports.BLAKE2 = void 0; +exports.compress = compress; +/** + * blake2b (64-bit) & blake2s (8 to 32-bit) hash functions. + * b could have been faster, but there is no fast u64 in js, so s is 1.5x faster. + * @module + */ +const _blake_ts_1 = require("./_blake.js"); +const _md_ts_1 = require("./_md.js"); +const u64 = require("./_u64.js"); +// prettier-ignore +const utils_ts_1 = require("./utils.js"); +// Same as SHA512_IV, but swapped endianness: LE instead of BE. iv[1] is iv[0], etc. +const B2B_IV = /* @__PURE__ */ Uint32Array.from([ + 0xf3bcc908, 0x6a09e667, 0x84caa73b, 0xbb67ae85, 0xfe94f82b, 0x3c6ef372, 0x5f1d36f1, 0xa54ff53a, + 0xade682d1, 0x510e527f, 0x2b3e6c1f, 0x9b05688c, 0xfb41bd6b, 0x1f83d9ab, 0x137e2179, 0x5be0cd19, +]); +// Temporary buffer +const BBUF = /* @__PURE__ */ new Uint32Array(32); +// Mixing function G splitted in two halfs +function G1b(a, b, c, d, msg, x) { + // NOTE: V is LE here + const Xl = msg[x], Xh = msg[x + 1]; // prettier-ignore + let Al = BBUF[2 * a], Ah = BBUF[2 * a + 1]; // prettier-ignore + let Bl = BBUF[2 * b], Bh = BBUF[2 * b + 1]; // prettier-ignore + let Cl = BBUF[2 * c], Ch = BBUF[2 * c + 1]; // prettier-ignore + let Dl = BBUF[2 * d], Dh = BBUF[2 * d + 1]; // prettier-ignore + // v[a] = (v[a] + v[b] + x) | 0; + let ll = u64.add3L(Al, Bl, Xl); + Ah = u64.add3H(ll, Ah, Bh, Xh); + Al = ll | 0; + // v[d] = rotr(v[d] ^ v[a], 32) + ({ Dh, Dl } = { Dh: Dh ^ Ah, Dl: Dl ^ Al }); + ({ Dh, Dl } = { Dh: u64.rotr32H(Dh, Dl), Dl: u64.rotr32L(Dh, Dl) }); + // v[c] = (v[c] + v[d]) | 0; + ({ h: Ch, l: Cl } = u64.add(Ch, Cl, Dh, Dl)); + // v[b] = rotr(v[b] ^ v[c], 24) + ({ Bh, Bl } = { Bh: Bh ^ Ch, Bl: Bl ^ Cl }); + ({ Bh, Bl } = { Bh: u64.rotrSH(Bh, Bl, 24), Bl: u64.rotrSL(Bh, Bl, 24) }); + (BBUF[2 * a] = Al), (BBUF[2 * a + 1] = Ah); + (BBUF[2 * b] = Bl), (BBUF[2 * b + 1] = Bh); + (BBUF[2 * c] = Cl), (BBUF[2 * c + 1] = Ch); + (BBUF[2 * d] = Dl), (BBUF[2 * d + 1] = Dh); +} +function G2b(a, b, c, d, msg, x) { + // NOTE: V is LE here + const Xl = msg[x], Xh = msg[x + 1]; // prettier-ignore + let Al = BBUF[2 * a], Ah = BBUF[2 * a + 1]; // prettier-ignore + let Bl = BBUF[2 * b], Bh = BBUF[2 * b + 1]; // prettier-ignore + let Cl = BBUF[2 * c], Ch = BBUF[2 * c + 1]; // prettier-ignore + let Dl = BBUF[2 * d], Dh = BBUF[2 * d + 1]; // prettier-ignore + // v[a] = (v[a] + v[b] + x) | 0; + let ll = u64.add3L(Al, Bl, Xl); + Ah = u64.add3H(ll, Ah, Bh, Xh); + Al = ll | 0; + // v[d] = rotr(v[d] ^ v[a], 16) + ({ Dh, Dl } = { Dh: Dh ^ Ah, Dl: Dl ^ Al }); + ({ Dh, Dl } = { Dh: u64.rotrSH(Dh, Dl, 16), Dl: u64.rotrSL(Dh, Dl, 16) }); + // v[c] = (v[c] + v[d]) | 0; + ({ h: Ch, l: Cl } = u64.add(Ch, Cl, Dh, Dl)); + // v[b] = rotr(v[b] ^ v[c], 63) + ({ Bh, Bl } = { Bh: Bh ^ Ch, Bl: Bl ^ Cl }); + ({ Bh, Bl } = { Bh: u64.rotrBH(Bh, Bl, 63), Bl: u64.rotrBL(Bh, Bl, 63) }); + (BBUF[2 * a] = Al), (BBUF[2 * a + 1] = Ah); + (BBUF[2 * b] = Bl), (BBUF[2 * b + 1] = Bh); + (BBUF[2 * c] = Cl), (BBUF[2 * c + 1] = Ch); + (BBUF[2 * d] = Dl), (BBUF[2 * d + 1] = Dh); +} +function checkBlake2Opts(outputLen, opts = {}, keyLen, saltLen, persLen) { + (0, utils_ts_1.anumber)(keyLen); + if (outputLen < 0 || outputLen > keyLen) + throw new Error('outputLen bigger than keyLen'); + const { key, salt, personalization } = opts; + if (key !== undefined && (key.length < 1 || key.length > keyLen)) + throw new Error('key length must be undefined or 1..' + keyLen); + if (salt !== undefined && salt.length !== saltLen) + throw new Error('salt must be undefined or ' + saltLen); + if (personalization !== undefined && personalization.length !== persLen) + throw new Error('personalization must be undefined or ' + persLen); +} +/** Class, from which others are subclassed. */ +class BLAKE2 extends utils_ts_1.Hash { + constructor(blockLen, outputLen) { + super(); + this.finished = false; + this.destroyed = false; + this.length = 0; + this.pos = 0; + (0, utils_ts_1.anumber)(blockLen); + (0, utils_ts_1.anumber)(outputLen); + this.blockLen = blockLen; + this.outputLen = outputLen; + this.buffer = new Uint8Array(blockLen); + this.buffer32 = (0, utils_ts_1.u32)(this.buffer); + } + update(data) { + (0, utils_ts_1.aexists)(this); + data = (0, utils_ts_1.toBytes)(data); + (0, utils_ts_1.abytes)(data); + // Main difference with other hashes: there is flag for last block, + // so we cannot process current block before we know that there + // is the next one. This significantly complicates logic and reduces ability + // to do zero-copy processing + const { blockLen, buffer, buffer32 } = this; + const len = data.length; + const offset = data.byteOffset; + const buf = data.buffer; + for (let pos = 0; pos < len;) { + // If buffer is full and we still have input (don't process last block, same as blake2s) + if (this.pos === blockLen) { + (0, utils_ts_1.swap32IfBE)(buffer32); + this.compress(buffer32, 0, false); + (0, utils_ts_1.swap32IfBE)(buffer32); + this.pos = 0; + } + const take = Math.min(blockLen - this.pos, len - pos); + const dataOffset = offset + pos; + // full block && aligned to 4 bytes && not last in input + if (take === blockLen && !(dataOffset % 4) && pos + take < len) { + const data32 = new Uint32Array(buf, dataOffset, Math.floor((len - pos) / 4)); + (0, utils_ts_1.swap32IfBE)(data32); + for (let pos32 = 0; pos + blockLen < len; pos32 += buffer32.length, pos += blockLen) { + this.length += blockLen; + this.compress(data32, pos32, false); + } + (0, utils_ts_1.swap32IfBE)(data32); + continue; + } + buffer.set(data.subarray(pos, pos + take), this.pos); + this.pos += take; + this.length += take; + pos += take; + } + return this; + } + digestInto(out) { + (0, utils_ts_1.aexists)(this); + (0, utils_ts_1.aoutput)(out, this); + const { pos, buffer32 } = this; + this.finished = true; + // Padding + (0, utils_ts_1.clean)(this.buffer.subarray(pos)); + (0, utils_ts_1.swap32IfBE)(buffer32); + this.compress(buffer32, 0, true); + (0, utils_ts_1.swap32IfBE)(buffer32); + const out32 = (0, utils_ts_1.u32)(out); + this.get().forEach((v, i) => (out32[i] = (0, utils_ts_1.swap8IfBE)(v))); + } + digest() { + const { buffer, outputLen } = this; + this.digestInto(buffer); + const res = buffer.slice(0, outputLen); + this.destroy(); + return res; + } + _cloneInto(to) { + const { buffer, length, finished, destroyed, outputLen, pos } = this; + to || (to = new this.constructor({ dkLen: outputLen })); + to.set(...this.get()); + to.buffer.set(buffer); + to.destroyed = destroyed; + to.finished = finished; + to.length = length; + to.pos = pos; + // @ts-ignore + to.outputLen = outputLen; + return to; + } + clone() { + return this._cloneInto(); + } +} +exports.BLAKE2 = BLAKE2; +class BLAKE2b extends BLAKE2 { + constructor(opts = {}) { + const olen = opts.dkLen === undefined ? 64 : opts.dkLen; + super(128, olen); + // Same as SHA-512, but LE + this.v0l = B2B_IV[0] | 0; + this.v0h = B2B_IV[1] | 0; + this.v1l = B2B_IV[2] | 0; + this.v1h = B2B_IV[3] | 0; + this.v2l = B2B_IV[4] | 0; + this.v2h = B2B_IV[5] | 0; + this.v3l = B2B_IV[6] | 0; + this.v3h = B2B_IV[7] | 0; + this.v4l = B2B_IV[8] | 0; + this.v4h = B2B_IV[9] | 0; + this.v5l = B2B_IV[10] | 0; + this.v5h = B2B_IV[11] | 0; + this.v6l = B2B_IV[12] | 0; + this.v6h = B2B_IV[13] | 0; + this.v7l = B2B_IV[14] | 0; + this.v7h = B2B_IV[15] | 0; + checkBlake2Opts(olen, opts, 64, 16, 16); + let { key, personalization, salt } = opts; + let keyLength = 0; + if (key !== undefined) { + key = (0, utils_ts_1.toBytes)(key); + keyLength = key.length; + } + this.v0l ^= this.outputLen | (keyLength << 8) | (0x01 << 16) | (0x01 << 24); + if (salt !== undefined) { + salt = (0, utils_ts_1.toBytes)(salt); + const slt = (0, utils_ts_1.u32)(salt); + this.v4l ^= (0, utils_ts_1.swap8IfBE)(slt[0]); + this.v4h ^= (0, utils_ts_1.swap8IfBE)(slt[1]); + this.v5l ^= (0, utils_ts_1.swap8IfBE)(slt[2]); + this.v5h ^= (0, utils_ts_1.swap8IfBE)(slt[3]); + } + if (personalization !== undefined) { + personalization = (0, utils_ts_1.toBytes)(personalization); + const pers = (0, utils_ts_1.u32)(personalization); + this.v6l ^= (0, utils_ts_1.swap8IfBE)(pers[0]); + this.v6h ^= (0, utils_ts_1.swap8IfBE)(pers[1]); + this.v7l ^= (0, utils_ts_1.swap8IfBE)(pers[2]); + this.v7h ^= (0, utils_ts_1.swap8IfBE)(pers[3]); + } + if (key !== undefined) { + // Pad to blockLen and update + const tmp = new Uint8Array(this.blockLen); + tmp.set(key); + this.update(tmp); + } + } + // prettier-ignore + get() { + let { v0l, v0h, v1l, v1h, v2l, v2h, v3l, v3h, v4l, v4h, v5l, v5h, v6l, v6h, v7l, v7h } = this; + return [v0l, v0h, v1l, v1h, v2l, v2h, v3l, v3h, v4l, v4h, v5l, v5h, v6l, v6h, v7l, v7h]; + } + // prettier-ignore + set(v0l, v0h, v1l, v1h, v2l, v2h, v3l, v3h, v4l, v4h, v5l, v5h, v6l, v6h, v7l, v7h) { + this.v0l = v0l | 0; + this.v0h = v0h | 0; + this.v1l = v1l | 0; + this.v1h = v1h | 0; + this.v2l = v2l | 0; + this.v2h = v2h | 0; + this.v3l = v3l | 0; + this.v3h = v3h | 0; + this.v4l = v4l | 0; + this.v4h = v4h | 0; + this.v5l = v5l | 0; + this.v5h = v5h | 0; + this.v6l = v6l | 0; + this.v6h = v6h | 0; + this.v7l = v7l | 0; + this.v7h = v7h | 0; + } + compress(msg, offset, isLast) { + this.get().forEach((v, i) => (BBUF[i] = v)); // First half from state. + BBUF.set(B2B_IV, 16); // Second half from IV. + let { h, l } = u64.fromBig(BigInt(this.length)); + BBUF[24] = B2B_IV[8] ^ l; // Low word of the offset. + BBUF[25] = B2B_IV[9] ^ h; // High word. + // Invert all bits for last block + if (isLast) { + BBUF[28] = ~BBUF[28]; + BBUF[29] = ~BBUF[29]; + } + let j = 0; + const s = _blake_ts_1.BSIGMA; + for (let i = 0; i < 12; i++) { + G1b(0, 4, 8, 12, msg, offset + 2 * s[j++]); + G2b(0, 4, 8, 12, msg, offset + 2 * s[j++]); + G1b(1, 5, 9, 13, msg, offset + 2 * s[j++]); + G2b(1, 5, 9, 13, msg, offset + 2 * s[j++]); + G1b(2, 6, 10, 14, msg, offset + 2 * s[j++]); + G2b(2, 6, 10, 14, msg, offset + 2 * s[j++]); + G1b(3, 7, 11, 15, msg, offset + 2 * s[j++]); + G2b(3, 7, 11, 15, msg, offset + 2 * s[j++]); + G1b(0, 5, 10, 15, msg, offset + 2 * s[j++]); + G2b(0, 5, 10, 15, msg, offset + 2 * s[j++]); + G1b(1, 6, 11, 12, msg, offset + 2 * s[j++]); + G2b(1, 6, 11, 12, msg, offset + 2 * s[j++]); + G1b(2, 7, 8, 13, msg, offset + 2 * s[j++]); + G2b(2, 7, 8, 13, msg, offset + 2 * s[j++]); + G1b(3, 4, 9, 14, msg, offset + 2 * s[j++]); + G2b(3, 4, 9, 14, msg, offset + 2 * s[j++]); + } + this.v0l ^= BBUF[0] ^ BBUF[16]; + this.v0h ^= BBUF[1] ^ BBUF[17]; + this.v1l ^= BBUF[2] ^ BBUF[18]; + this.v1h ^= BBUF[3] ^ BBUF[19]; + this.v2l ^= BBUF[4] ^ BBUF[20]; + this.v2h ^= BBUF[5] ^ BBUF[21]; + this.v3l ^= BBUF[6] ^ BBUF[22]; + this.v3h ^= BBUF[7] ^ BBUF[23]; + this.v4l ^= BBUF[8] ^ BBUF[24]; + this.v4h ^= BBUF[9] ^ BBUF[25]; + this.v5l ^= BBUF[10] ^ BBUF[26]; + this.v5h ^= BBUF[11] ^ BBUF[27]; + this.v6l ^= BBUF[12] ^ BBUF[28]; + this.v6h ^= BBUF[13] ^ BBUF[29]; + this.v7l ^= BBUF[14] ^ BBUF[30]; + this.v7h ^= BBUF[15] ^ BBUF[31]; + (0, utils_ts_1.clean)(BBUF); + } + destroy() { + this.destroyed = true; + (0, utils_ts_1.clean)(this.buffer32); + this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + } +} +exports.BLAKE2b = BLAKE2b; +/** + * Blake2b hash function. 64-bit. 1.5x slower than blake2s in JS. + * @param msg - message that would be hashed + * @param opts - dkLen output length, key for MAC mode, salt, personalization + */ +exports.blake2b = (0, utils_ts_1.createOptHasher)((opts) => new BLAKE2b(opts)); +// prettier-ignore +function compress(s, offset, msg, rounds, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) { + let j = 0; + for (let i = 0; i < rounds; i++) { + ({ a: v0, b: v4, c: v8, d: v12 } = (0, _blake_ts_1.G1s)(v0, v4, v8, v12, msg[offset + s[j++]])); + ({ a: v0, b: v4, c: v8, d: v12 } = (0, _blake_ts_1.G2s)(v0, v4, v8, v12, msg[offset + s[j++]])); + ({ a: v1, b: v5, c: v9, d: v13 } = (0, _blake_ts_1.G1s)(v1, v5, v9, v13, msg[offset + s[j++]])); + ({ a: v1, b: v5, c: v9, d: v13 } = (0, _blake_ts_1.G2s)(v1, v5, v9, v13, msg[offset + s[j++]])); + ({ a: v2, b: v6, c: v10, d: v14 } = (0, _blake_ts_1.G1s)(v2, v6, v10, v14, msg[offset + s[j++]])); + ({ a: v2, b: v6, c: v10, d: v14 } = (0, _blake_ts_1.G2s)(v2, v6, v10, v14, msg[offset + s[j++]])); + ({ a: v3, b: v7, c: v11, d: v15 } = (0, _blake_ts_1.G1s)(v3, v7, v11, v15, msg[offset + s[j++]])); + ({ a: v3, b: v7, c: v11, d: v15 } = (0, _blake_ts_1.G2s)(v3, v7, v11, v15, msg[offset + s[j++]])); + ({ a: v0, b: v5, c: v10, d: v15 } = (0, _blake_ts_1.G1s)(v0, v5, v10, v15, msg[offset + s[j++]])); + ({ a: v0, b: v5, c: v10, d: v15 } = (0, _blake_ts_1.G2s)(v0, v5, v10, v15, msg[offset + s[j++]])); + ({ a: v1, b: v6, c: v11, d: v12 } = (0, _blake_ts_1.G1s)(v1, v6, v11, v12, msg[offset + s[j++]])); + ({ a: v1, b: v6, c: v11, d: v12 } = (0, _blake_ts_1.G2s)(v1, v6, v11, v12, msg[offset + s[j++]])); + ({ a: v2, b: v7, c: v8, d: v13 } = (0, _blake_ts_1.G1s)(v2, v7, v8, v13, msg[offset + s[j++]])); + ({ a: v2, b: v7, c: v8, d: v13 } = (0, _blake_ts_1.G2s)(v2, v7, v8, v13, msg[offset + s[j++]])); + ({ a: v3, b: v4, c: v9, d: v14 } = (0, _blake_ts_1.G1s)(v3, v4, v9, v14, msg[offset + s[j++]])); + ({ a: v3, b: v4, c: v9, d: v14 } = (0, _blake_ts_1.G2s)(v3, v4, v9, v14, msg[offset + s[j++]])); + } + return { v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15 }; +} +const B2S_IV = _md_ts_1.SHA256_IV; +class BLAKE2s extends BLAKE2 { + constructor(opts = {}) { + const olen = opts.dkLen === undefined ? 32 : opts.dkLen; + super(64, olen); + // Internal state, same as SHA-256 + this.v0 = B2S_IV[0] | 0; + this.v1 = B2S_IV[1] | 0; + this.v2 = B2S_IV[2] | 0; + this.v3 = B2S_IV[3] | 0; + this.v4 = B2S_IV[4] | 0; + this.v5 = B2S_IV[5] | 0; + this.v6 = B2S_IV[6] | 0; + this.v7 = B2S_IV[7] | 0; + checkBlake2Opts(olen, opts, 32, 8, 8); + let { key, personalization, salt } = opts; + let keyLength = 0; + if (key !== undefined) { + key = (0, utils_ts_1.toBytes)(key); + keyLength = key.length; + } + this.v0 ^= this.outputLen | (keyLength << 8) | (0x01 << 16) | (0x01 << 24); + if (salt !== undefined) { + salt = (0, utils_ts_1.toBytes)(salt); + const slt = (0, utils_ts_1.u32)(salt); + this.v4 ^= (0, utils_ts_1.swap8IfBE)(slt[0]); + this.v5 ^= (0, utils_ts_1.swap8IfBE)(slt[1]); + } + if (personalization !== undefined) { + personalization = (0, utils_ts_1.toBytes)(personalization); + const pers = (0, utils_ts_1.u32)(personalization); + this.v6 ^= (0, utils_ts_1.swap8IfBE)(pers[0]); + this.v7 ^= (0, utils_ts_1.swap8IfBE)(pers[1]); + } + if (key !== undefined) { + // Pad to blockLen and update + (0, utils_ts_1.abytes)(key); + const tmp = new Uint8Array(this.blockLen); + tmp.set(key); + this.update(tmp); + } + } + get() { + const { v0, v1, v2, v3, v4, v5, v6, v7 } = this; + return [v0, v1, v2, v3, v4, v5, v6, v7]; + } + // prettier-ignore + set(v0, v1, v2, v3, v4, v5, v6, v7) { + this.v0 = v0 | 0; + this.v1 = v1 | 0; + this.v2 = v2 | 0; + this.v3 = v3 | 0; + this.v4 = v4 | 0; + this.v5 = v5 | 0; + this.v6 = v6 | 0; + this.v7 = v7 | 0; + } + compress(msg, offset, isLast) { + const { h, l } = u64.fromBig(BigInt(this.length)); + // prettier-ignore + const { v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15 } = compress(_blake_ts_1.BSIGMA, offset, msg, 10, this.v0, this.v1, this.v2, this.v3, this.v4, this.v5, this.v6, this.v7, B2S_IV[0], B2S_IV[1], B2S_IV[2], B2S_IV[3], l ^ B2S_IV[4], h ^ B2S_IV[5], isLast ? ~B2S_IV[6] : B2S_IV[6], B2S_IV[7]); + this.v0 ^= v0 ^ v8; + this.v1 ^= v1 ^ v9; + this.v2 ^= v2 ^ v10; + this.v3 ^= v3 ^ v11; + this.v4 ^= v4 ^ v12; + this.v5 ^= v5 ^ v13; + this.v6 ^= v6 ^ v14; + this.v7 ^= v7 ^ v15; + } + destroy() { + this.destroyed = true; + (0, utils_ts_1.clean)(this.buffer32); + this.set(0, 0, 0, 0, 0, 0, 0, 0); + } +} +exports.BLAKE2s = BLAKE2s; +/** + * Blake2s hash function. Focuses on 8-bit to 32-bit platforms. 1.5x faster than blake2b in JS. + * @param msg - message that would be hashed + * @param opts - dkLen output length, key for MAC mode, salt, personalization + */ +exports.blake2s = (0, utils_ts_1.createOptHasher)((opts) => new BLAKE2s(opts)); +//# sourceMappingURL=blake2.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/blake2.js.map b/node_modules/@noble/hashes/blake2.js.map new file mode 100644 index 0000000000000000000000000000000000000000..8849793d0a0859a3b831bd618a61c870d7826960 --- /dev/null +++ b/node_modules/@noble/hashes/blake2.js.map @@ -0,0 +1 @@ +{"version":3,"file":"blake2.js","sourceRoot":"","sources":["src/blake2.ts"],"names":[],"mappings":";;;AA8WA,4BAyBC;AAvYD;;;;GAIG;AACH,2CAA+C;AAC/C,qCAAqC;AACrC,iCAAiC;AACjC,kBAAkB;AAClB,yCAIoB;AAUpB,oFAAoF;AACpF,MAAM,MAAM,GAAG,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC;IAC9C,UAAU,EAAE,UAAU,EAAE,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;AACH,mBAAmB;AACnB,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,WAAW,CAAC,EAAE,CAAC,CAAC;AAEjD,0CAA0C;AAC1C,SAAS,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,GAAgB,EAAE,CAAS;IAClF,qBAAqB;IACrB,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,kBA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B,IAAA,0BAAe,EAC5D,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAC5B,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/blake2b.d.ts b/node_modules/@noble/hashes/blake2b.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a9ea37ec437c520846dcf44433920e68d25a173b --- /dev/null +++ b/node_modules/@noble/hashes/blake2b.d.ts @@ -0,0 +1,11 @@ +/** + * Blake2b hash function. Focuses on 64-bit platforms, but in JS speed different from Blake2s is negligible. + * @module + * @deprecated + */ +import { BLAKE2b as B2B, blake2b as b2b } from './blake2.ts'; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export declare const BLAKE2b: typeof B2B; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export declare const blake2b: typeof b2b; +//# sourceMappingURL=blake2b.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/blake2b.d.ts.map b/node_modules/@noble/hashes/blake2b.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..3b1ad51d5a1f09e0b1a365b4fa93a0a97dee101d --- /dev/null +++ b/node_modules/@noble/hashes/blake2b.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"blake2b.d.ts","sourceRoot":"","sources":["src/blake2b.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,aAAa,CAAC;AAC7D,+DAA+D;AAC/D,eAAO,MAAM,OAAO,EAAE,OAAO,GAAS,CAAC;AACvC,+DAA+D;AAC/D,eAAO,MAAM,OAAO,EAAE,OAAO,GAAS,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/blake2b.js b/node_modules/@noble/hashes/blake2b.js new file mode 100644 index 0000000000000000000000000000000000000000..18cdcca1a4bce760b0e15bfabf5252f18bbe7e4d --- /dev/null +++ b/node_modules/@noble/hashes/blake2b.js @@ -0,0 +1,14 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.blake2b = exports.BLAKE2b = void 0; +/** + * Blake2b hash function. Focuses on 64-bit platforms, but in JS speed different from Blake2s is negligible. + * @module + * @deprecated + */ +const blake2_ts_1 = require("./blake2.js"); +/** @deprecated Use import from `noble/hashes/blake2` module */ +exports.BLAKE2b = blake2_ts_1.BLAKE2b; +/** @deprecated Use import from `noble/hashes/blake2` module */ +exports.blake2b = blake2_ts_1.blake2b; +//# sourceMappingURL=blake2b.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/blake2b.js.map b/node_modules/@noble/hashes/blake2b.js.map new file mode 100644 index 0000000000000000000000000000000000000000..65282add92173d0034a70e0ff7b953fb8e7ce1af --- /dev/null +++ b/node_modules/@noble/hashes/blake2b.js.map @@ -0,0 +1 @@ +{"version":3,"file":"blake2b.js","sourceRoot":"","sources":["src/blake2b.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,2CAA6D;AAC7D,+DAA+D;AAClD,QAAA,OAAO,GAAe,mBAAG,CAAC;AACvC,+DAA+D;AAClD,QAAA,OAAO,GAAe,mBAAG,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/blake2s.d.ts b/node_modules/@noble/hashes/blake2s.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6720f358763e288d3d4c00d5920dd4210bb59ada --- /dev/null +++ b/node_modules/@noble/hashes/blake2s.d.ts @@ -0,0 +1,20 @@ +/** + * Blake2s hash function. Focuses on 8-bit to 32-bit platforms. blake2b for 64-bit, but in JS it is slower. + * @module + * @deprecated + */ +import { G1s as G1s_n, G2s as G2s_n } from './_blake.ts'; +import { BLAKE2s as B2S, blake2s as b2s, compress as compress_n } from './blake2.ts'; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export declare const B2S_IV: Uint32Array; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export declare const G1s: typeof G1s_n; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export declare const G2s: typeof G2s_n; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export declare const compress: typeof compress_n; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export declare const BLAKE2s: typeof B2S; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export declare const blake2s: typeof b2s; +//# sourceMappingURL=blake2s.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/blake2s.d.ts.map b/node_modules/@noble/hashes/blake2s.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..9a54568e6d1f2c5f1b4d86cf4798e2d0fbbebbe5 --- /dev/null +++ b/node_modules/@noble/hashes/blake2s.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"blake2s.d.ts","sourceRoot":"","sources":["src/blake2s.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,GAAG,IAAI,KAAK,EAAE,GAAG,IAAI,KAAK,EAAE,MAAM,aAAa,CAAC;AAEzD,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,OAAO,IAAI,GAAG,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC;AACrF,+DAA+D;AAC/D,eAAO,MAAM,MAAM,EAAE,WAAuB,CAAC;AAC7C,+DAA+D;AAC/D,eAAO,MAAM,GAAG,EAAE,OAAO,KAAa,CAAC;AACvC,+DAA+D;AAC/D,eAAO,MAAM,GAAG,EAAE,OAAO,KAAa,CAAC;AACvC,+DAA+D;AAC/D,eAAO,MAAM,QAAQ,EAAE,OAAO,UAAuB,CAAC;AACtD,+DAA+D;AAC/D,eAAO,MAAM,OAAO,EAAE,OAAO,GAAS,CAAC;AACvC,+DAA+D;AAC/D,eAAO,MAAM,OAAO,EAAE,OAAO,GAAS,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/blake2s.js b/node_modules/@noble/hashes/blake2s.js new file mode 100644 index 0000000000000000000000000000000000000000..3d4f42b2d422b9f4a797a74b47285ef9d30634ae --- /dev/null +++ b/node_modules/@noble/hashes/blake2s.js @@ -0,0 +1,24 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.blake2s = exports.BLAKE2s = exports.compress = exports.G2s = exports.G1s = exports.B2S_IV = void 0; +/** + * Blake2s hash function. Focuses on 8-bit to 32-bit platforms. blake2b for 64-bit, but in JS it is slower. + * @module + * @deprecated + */ +const _blake_ts_1 = require("./_blake.js"); +const _md_ts_1 = require("./_md.js"); +const blake2_ts_1 = require("./blake2.js"); +/** @deprecated Use import from `noble/hashes/blake2` module */ +exports.B2S_IV = _md_ts_1.SHA256_IV; +/** @deprecated Use import from `noble/hashes/blake2` module */ +exports.G1s = _blake_ts_1.G1s; +/** @deprecated Use import from `noble/hashes/blake2` module */ +exports.G2s = _blake_ts_1.G2s; +/** @deprecated Use import from `noble/hashes/blake2` module */ +exports.compress = blake2_ts_1.compress; +/** @deprecated Use import from `noble/hashes/blake2` module */ +exports.BLAKE2s = blake2_ts_1.BLAKE2s; +/** @deprecated Use import from `noble/hashes/blake2` module */ +exports.blake2s = blake2_ts_1.blake2s; +//# sourceMappingURL=blake2s.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/blake2s.js.map b/node_modules/@noble/hashes/blake2s.js.map new file mode 100644 index 0000000000000000000000000000000000000000..84f0312f08a74127f6a9bbb99df7505f17ea9eed --- /dev/null +++ b/node_modules/@noble/hashes/blake2s.js.map @@ -0,0 +1 @@ +{"version":3,"file":"blake2s.js","sourceRoot":"","sources":["src/blake2s.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,2CAAyD;AACzD,qCAAqC;AACrC,2CAAqF;AACrF,+DAA+D;AAClD,QAAA,MAAM,GAAgB,kBAAS,CAAC;AAC7C,+DAA+D;AAClD,QAAA,GAAG,GAAiB,eAAK,CAAC;AACvC,+DAA+D;AAClD,QAAA,GAAG,GAAiB,eAAK,CAAC;AACvC,+DAA+D;AAClD,QAAA,QAAQ,GAAsB,oBAAU,CAAC;AACtD,+DAA+D;AAClD,QAAA,OAAO,GAAe,mBAAG,CAAC;AACvC,+DAA+D;AAClD,QAAA,OAAO,GAAe,mBAAG,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/blake3.d.ts b/node_modules/@noble/hashes/blake3.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..234fa87f32a94530cb2713ca98d6ccb45a648d9a --- /dev/null +++ b/node_modules/@noble/hashes/blake3.d.ts @@ -0,0 +1,54 @@ +import { BLAKE2 } from './blake2.ts'; +import { type CHashXO, type HashXOF, type Input } from './utils.ts'; +/** + * Ensure to use EITHER `key` OR `context`, not both. + * + * * `key`: 32-byte MAC key. + * * `context`: string for KDF. Should be hardcoded, globally unique, and application - specific. + * A good default format for the context string is "[application] [commit timestamp] [purpose]". + */ +export type Blake3Opts = { + dkLen?: number; + key?: Input; + context?: Input; +}; +/** Blake3 hash. Can be used as MAC and KDF. */ +export declare class BLAKE3 extends BLAKE2 implements HashXOF { + private chunkPos; + private chunksDone; + private flags; + private IV; + private state; + private stack; + private posOut; + private bufferOut32; + private bufferOut; + private chunkOut; + private enableXOF; + constructor(opts?: Blake3Opts, flags?: number); + protected get(): []; + protected set(): void; + private b2Compress; + protected compress(buf: Uint32Array, bufPos?: number, isLast?: boolean): void; + _cloneInto(to?: BLAKE3): BLAKE3; + destroy(): void; + private b2CompressOut; + protected finish(): void; + private writeInto; + xofInto(out: Uint8Array): Uint8Array; + xof(bytes: number): Uint8Array; + digestInto(out: Uint8Array): Uint8Array; + digest(): Uint8Array; +} +/** + * BLAKE3 hash function. Can be used as MAC and KDF. + * @param msg - message that would be hashed + * @param opts - `dkLen` for output length, `key` for MAC mode, `context` for KDF mode + * @example + * const data = new Uint8Array(32); + * const hash = blake3(data); + * const mac = blake3(data, { key: new Uint8Array(32) }); + * const kdf = blake3(data, { context: 'application name' }); + */ +export declare const blake3: CHashXO; +//# sourceMappingURL=blake3.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/blake3.d.ts.map b/node_modules/@noble/hashes/blake3.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..f951d3d541dc5991c0efe41a0309860330fdf3d2 --- /dev/null +++ b/node_modules/@noble/hashes/blake3.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"blake3.d.ts","sourceRoot":"","sources":["src/blake3.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,MAAM,EAAY,MAAM,aAAa,CAAC;AAE/C,OAAO,EAGL,KAAK,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,KAAK,EACvC,MAAM,YAAY,CAAC;AAwBpB;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,KAAK,CAAC;IAAC,OAAO,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAE1E,+CAA+C;AAC/C,qBAAa,MAAO,SAAQ,MAAM,CAAC,MAAM,CAAE,YAAW,OAAO,CAAC,MAAM,CAAC;IACnE,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,EAAE,CAAc;IACxB,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,KAAK,CAAqB;IAElC,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,SAAS,CAAQ;gBAEb,IAAI,GAAE,UAAe,EAAE,KAAK,SAAI;IA2B5C,SAAS,CAAC,GAAG,IAAI,EAAE;IAGnB,SAAS,CAAC,GAAG,IAAI,IAAI;IACrB,OAAO,CAAC,UAAU;IAmBlB,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,GAAE,MAAU,EAAE,MAAM,GAAE,OAAe,GAAG,IAAI;IAiCvF,UAAU,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM;IAe/B,OAAO,IAAI,IAAI;IAMf,OAAO,CAAC,aAAa;IA+BrB,SAAS,CAAC,MAAM,IAAI,IAAI;IAoBxB,OAAO,CAAC,SAAS;IAcjB,OAAO,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU;IAIpC,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU;IAI9B,UAAU,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU;IAQvC,MAAM,IAAI,UAAU;CAGrB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,MAAM,EAAE,OAEpB,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/blake3.js b/node_modules/@noble/hashes/blake3.js new file mode 100644 index 0000000000000000000000000000000000000000..860234209bc51647d26a18266bea094b7aca6953 --- /dev/null +++ b/node_modules/@noble/hashes/blake3.js @@ -0,0 +1,255 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.blake3 = exports.BLAKE3 = void 0; +/** + * Blake3 fast hash is Blake2 with reduced security (round count). Can also be used as MAC & KDF. + * + * It is advertised as "the fastest cryptographic hash". However, it isn't true in JS. + * Why is this so slow? While it should be 6x faster than blake2b, perf diff is only 20%: + * + * * There is only 30% reduction in number of rounds from blake2s + * * Speed-up comes from tree structure, which is parallelized using SIMD & threading. + * These features are not present in JS, so we only get overhead from trees. + * * Parallelization only happens on 1024-byte chunks: there is no benefit for small inputs. + * * It is still possible to make it faster using: a) loop unrolling b) web workers c) wasm + * @module + */ +const _md_ts_1 = require("./_md.js"); +const _u64_ts_1 = require("./_u64.js"); +const blake2_ts_1 = require("./blake2.js"); +// prettier-ignore +const utils_ts_1 = require("./utils.js"); +// Flag bitset +const B3_Flags = { + CHUNK_START: 0b1, + CHUNK_END: 0b10, + PARENT: 0b100, + ROOT: 0b1000, + KEYED_HASH: 0b10000, + DERIVE_KEY_CONTEXT: 0b100000, + DERIVE_KEY_MATERIAL: 0b1000000, +}; +const B3_IV = _md_ts_1.SHA256_IV.slice(); +const B3_SIGMA = /* @__PURE__ */ (() => { + const Id = Array.from({ length: 16 }, (_, i) => i); + const permute = (arr) => [2, 6, 3, 10, 7, 0, 4, 13, 1, 11, 12, 5, 9, 14, 15, 8].map((i) => arr[i]); + const res = []; + for (let i = 0, v = Id; i < 7; i++, v = permute(v)) + res.push(...v); + return Uint8Array.from(res); +})(); +/** Blake3 hash. Can be used as MAC and KDF. */ +class BLAKE3 extends blake2_ts_1.BLAKE2 { + constructor(opts = {}, flags = 0) { + super(64, opts.dkLen === undefined ? 32 : opts.dkLen); + this.chunkPos = 0; // Position of current block in chunk + this.chunksDone = 0; // How many chunks we already have + this.flags = 0 | 0; + this.stack = []; + // Output + this.posOut = 0; + this.bufferOut32 = new Uint32Array(16); + this.chunkOut = 0; // index of output chunk + this.enableXOF = true; + const { key, context } = opts; + const hasContext = context !== undefined; + if (key !== undefined) { + if (hasContext) + throw new Error('Only "key" or "context" can be specified at same time'); + const k = (0, utils_ts_1.toBytes)(key).slice(); + (0, utils_ts_1.abytes)(k, 32); + this.IV = (0, utils_ts_1.u32)(k); + (0, utils_ts_1.swap32IfBE)(this.IV); + this.flags = flags | B3_Flags.KEYED_HASH; + } + else if (hasContext) { + const ctx = (0, utils_ts_1.toBytes)(context); + const contextKey = new BLAKE3({ dkLen: 32 }, B3_Flags.DERIVE_KEY_CONTEXT) + .update(ctx) + .digest(); + this.IV = (0, utils_ts_1.u32)(contextKey); + (0, utils_ts_1.swap32IfBE)(this.IV); + this.flags = flags | B3_Flags.DERIVE_KEY_MATERIAL; + } + else { + this.IV = B3_IV.slice(); + this.flags = flags; + } + this.state = this.IV.slice(); + this.bufferOut = (0, utils_ts_1.u8)(this.bufferOut32); + } + // Unused + get() { + return []; + } + set() { } + b2Compress(counter, flags, buf, bufPos = 0) { + const { state: s, pos } = this; + const { h, l } = (0, _u64_ts_1.fromBig)(BigInt(counter), true); + // prettier-ignore + const { v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15 } = (0, blake2_ts_1.compress)(B3_SIGMA, bufPos, buf, 7, s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], B3_IV[0], B3_IV[1], B3_IV[2], B3_IV[3], h, l, pos, flags); + s[0] = v0 ^ v8; + s[1] = v1 ^ v9; + s[2] = v2 ^ v10; + s[3] = v3 ^ v11; + s[4] = v4 ^ v12; + s[5] = v5 ^ v13; + s[6] = v6 ^ v14; + s[7] = v7 ^ v15; + } + compress(buf, bufPos = 0, isLast = false) { + // Compress last block + let flags = this.flags; + if (!this.chunkPos) + flags |= B3_Flags.CHUNK_START; + if (this.chunkPos === 15 || isLast) + flags |= B3_Flags.CHUNK_END; + if (!isLast) + this.pos = this.blockLen; + this.b2Compress(this.chunksDone, flags, buf, bufPos); + this.chunkPos += 1; + // If current block is last in chunk (16 blocks), then compress chunks + if (this.chunkPos === 16 || isLast) { + let chunk = this.state; + this.state = this.IV.slice(); + // If not the last one, compress only when there are trailing zeros in chunk counter + // chunks used as binary tree where current stack is path. Zero means current leaf is finished and can be compressed. + // 1 (001) - leaf not finished (just push current chunk to stack) + // 2 (010) - leaf finished at depth=1 (merge with last elm on stack and push back) + // 3 (011) - last leaf not finished + // 4 (100) - leafs finished at depth=1 and depth=2 + for (let last, chunks = this.chunksDone + 1; isLast || !(chunks & 1); chunks >>= 1) { + if (!(last = this.stack.pop())) + break; + this.buffer32.set(last, 0); + this.buffer32.set(chunk, 8); + this.pos = this.blockLen; + this.b2Compress(0, this.flags | B3_Flags.PARENT, this.buffer32, 0); + chunk = this.state; + this.state = this.IV.slice(); + } + this.chunksDone++; + this.chunkPos = 0; + this.stack.push(chunk); + } + this.pos = 0; + } + _cloneInto(to) { + to = super._cloneInto(to); + const { IV, flags, state, chunkPos, posOut, chunkOut, stack, chunksDone } = this; + to.state.set(state.slice()); + to.stack = stack.map((i) => Uint32Array.from(i)); + to.IV.set(IV); + to.flags = flags; + to.chunkPos = chunkPos; + to.chunksDone = chunksDone; + to.posOut = posOut; + to.chunkOut = chunkOut; + to.enableXOF = this.enableXOF; + to.bufferOut32.set(this.bufferOut32); + return to; + } + destroy() { + this.destroyed = true; + (0, utils_ts_1.clean)(this.state, this.buffer32, this.IV, this.bufferOut32); + (0, utils_ts_1.clean)(...this.stack); + } + // Same as b2Compress, but doesn't modify state and returns 16 u32 array (instead of 8) + b2CompressOut() { + const { state: s, pos, flags, buffer32, bufferOut32: out32 } = this; + const { h, l } = (0, _u64_ts_1.fromBig)(BigInt(this.chunkOut++)); + (0, utils_ts_1.swap32IfBE)(buffer32); + // prettier-ignore + const { v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15 } = (0, blake2_ts_1.compress)(B3_SIGMA, 0, buffer32, 7, s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], B3_IV[0], B3_IV[1], B3_IV[2], B3_IV[3], l, h, pos, flags); + out32[0] = v0 ^ v8; + out32[1] = v1 ^ v9; + out32[2] = v2 ^ v10; + out32[3] = v3 ^ v11; + out32[4] = v4 ^ v12; + out32[5] = v5 ^ v13; + out32[6] = v6 ^ v14; + out32[7] = v7 ^ v15; + out32[8] = s[0] ^ v8; + out32[9] = s[1] ^ v9; + out32[10] = s[2] ^ v10; + out32[11] = s[3] ^ v11; + out32[12] = s[4] ^ v12; + out32[13] = s[5] ^ v13; + out32[14] = s[6] ^ v14; + out32[15] = s[7] ^ v15; + (0, utils_ts_1.swap32IfBE)(buffer32); + (0, utils_ts_1.swap32IfBE)(out32); + this.posOut = 0; + } + finish() { + if (this.finished) + return; + this.finished = true; + // Padding + (0, utils_ts_1.clean)(this.buffer.subarray(this.pos)); + // Process last chunk + let flags = this.flags | B3_Flags.ROOT; + if (this.stack.length) { + flags |= B3_Flags.PARENT; + (0, utils_ts_1.swap32IfBE)(this.buffer32); + this.compress(this.buffer32, 0, true); + (0, utils_ts_1.swap32IfBE)(this.buffer32); + this.chunksDone = 0; + this.pos = this.blockLen; + } + else { + flags |= (!this.chunkPos ? B3_Flags.CHUNK_START : 0) | B3_Flags.CHUNK_END; + } + this.flags = flags; + this.b2CompressOut(); + } + writeInto(out) { + (0, utils_ts_1.aexists)(this, false); + (0, utils_ts_1.abytes)(out); + this.finish(); + const { blockLen, bufferOut } = this; + for (let pos = 0, len = out.length; pos < len;) { + if (this.posOut >= blockLen) + this.b2CompressOut(); + const take = Math.min(blockLen - this.posOut, len - pos); + out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos); + this.posOut += take; + pos += take; + } + return out; + } + xofInto(out) { + if (!this.enableXOF) + throw new Error('XOF is not possible after digest call'); + return this.writeInto(out); + } + xof(bytes) { + (0, utils_ts_1.anumber)(bytes); + return this.xofInto(new Uint8Array(bytes)); + } + digestInto(out) { + (0, utils_ts_1.aoutput)(out, this); + if (this.finished) + throw new Error('digest() was already called'); + this.enableXOF = false; + this.writeInto(out); + this.destroy(); + return out; + } + digest() { + return this.digestInto(new Uint8Array(this.outputLen)); + } +} +exports.BLAKE3 = BLAKE3; +/** + * BLAKE3 hash function. Can be used as MAC and KDF. + * @param msg - message that would be hashed + * @param opts - `dkLen` for output length, `key` for MAC mode, `context` for KDF mode + * @example + * const data = new Uint8Array(32); + * const hash = blake3(data); + * const mac = blake3(data, { key: new Uint8Array(32) }); + * const kdf = blake3(data, { context: 'application name' }); + */ +exports.blake3 = (0, utils_ts_1.createXOFer)((opts) => new BLAKE3(opts)); +//# sourceMappingURL=blake3.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/blake3.js.map b/node_modules/@noble/hashes/blake3.js.map new file mode 100644 index 0000000000000000000000000000000000000000..6c06019e2fe6001c1c58fa542e841bc53396a60f --- /dev/null +++ b/node_modules/@noble/hashes/blake3.js.map @@ -0,0 +1 @@ +{"version":3,"file":"blake3.js","sourceRoot":"","sources":["src/blake3.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;GAYG;AACH,qCAAqC;AACrC,uCAAoC;AACpC,2CAA+C;AAC/C,kBAAkB;AAClB,yCAIoB;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EAAE,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,CAC3B,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/crypto.d.ts b/node_modules/@noble/hashes/crypto.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ac181a0247597021010e0d9821dd2fdf4eb077c3 --- /dev/null +++ b/node_modules/@noble/hashes/crypto.d.ts @@ -0,0 +1,2 @@ +export declare const crypto: any; +//# sourceMappingURL=crypto.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/crypto.d.ts.map b/node_modules/@noble/hashes/crypto.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..4ecc6bca7aa42a3b588a191f90e89f1cc427a8dc --- /dev/null +++ b/node_modules/@noble/hashes/crypto.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["src/crypto.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,MAAM,EAAE,GACqE,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/crypto.js b/node_modules/@noble/hashes/crypto.js new file mode 100644 index 0000000000000000000000000000000000000000..8226391ffa9676473580dabd38450b050349eff0 --- /dev/null +++ b/node_modules/@noble/hashes/crypto.js @@ -0,0 +1,5 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.crypto = void 0; +exports.crypto = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined; +//# sourceMappingURL=crypto.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/crypto.js.map b/node_modules/@noble/hashes/crypto.js.map new file mode 100644 index 0000000000000000000000000000000000000000..0bb417ce63082bc8f1d4b29f2f7f1315668e5b44 --- /dev/null +++ b/node_modules/@noble/hashes/crypto.js.map @@ -0,0 +1 @@ +{"version":3,"file":"crypto.js","sourceRoot":"","sources":["src/crypto.ts"],"names":[],"mappings":";;;AAOa,QAAA,MAAM,GACjB,OAAO,UAAU,KAAK,QAAQ,IAAI,QAAQ,IAAI,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/cryptoNode.d.ts b/node_modules/@noble/hashes/cryptoNode.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..98bda7be4ddd7d83a758d97d502e691c6be18fc9 --- /dev/null +++ b/node_modules/@noble/hashes/cryptoNode.d.ts @@ -0,0 +1,2 @@ +export declare const crypto: any; +//# sourceMappingURL=cryptoNode.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/cryptoNode.d.ts.map b/node_modules/@noble/hashes/cryptoNode.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..4303dc76185976300b6741ae57c7a5475d91c85c --- /dev/null +++ b/node_modules/@noble/hashes/cryptoNode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"cryptoNode.d.ts","sourceRoot":"","sources":["src/cryptoNode.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,MAAM,EAAE,GAKJ,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/cryptoNode.js b/node_modules/@noble/hashes/cryptoNode.js new file mode 100644 index 0000000000000000000000000000000000000000..eba1a1ffb613251dad55ca8edb8f70308fc17ad9 --- /dev/null +++ b/node_modules/@noble/hashes/cryptoNode.js @@ -0,0 +1,18 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.crypto = void 0; +/** + * Internal webcrypto alias. + * We prefer WebCrypto aka globalThis.crypto, which exists in node.js 16+. + * Falls back to Node.js built-in crypto for Node.js <=v14. + * See utils.ts for details. + * @module + */ +// @ts-ignore +const nc = require("node:crypto"); +exports.crypto = nc && typeof nc === 'object' && 'webcrypto' in nc + ? nc.webcrypto + : nc && typeof nc === 'object' && 'randomBytes' in nc + ? nc + : undefined; +//# sourceMappingURL=cryptoNode.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/cryptoNode.js.map b/node_modules/@noble/hashes/cryptoNode.js.map new file mode 100644 index 0000000000000000000000000000000000000000..14983d52454d30f7ab7f9b28b7cd8972b3278e2d --- /dev/null +++ b/node_modules/@noble/hashes/cryptoNode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"cryptoNode.js","sourceRoot":"","sources":["src/cryptoNode.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,aAAa;AACb,kCAAkC;AACrB,QAAA,MAAM,GACjB,EAAE,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,WAAW,IAAI,EAAE;IAC/C,CAAC,CAAE,EAAE,CAAC,SAAiB;IACvB,CAAC,CAAC,EAAE,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,aAAa,IAAI,EAAE;QACnD,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,SAAS,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/eskdf.d.ts b/node_modules/@noble/hashes/eskdf.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..66721eb52becd414746ee0fb67666cf146996e07 --- /dev/null +++ b/node_modules/@noble/hashes/eskdf.d.ts @@ -0,0 +1,47 @@ +export declare function scrypt(password: string, salt: string): Uint8Array; +export declare function pbkdf2(password: string, salt: string): Uint8Array; +/** + * Derives main seed. Takes a lot of time. Prefer `eskdf` method instead. + */ +export declare function deriveMainSeed(username: string, password: string): Uint8Array; +type AccountID = number | string; +type OptsLength = { + keyLength: number; +}; +type OptsMod = { + modulus: bigint; +}; +type KeyOpts = undefined | OptsLength | OptsMod; +export interface ESKDF { + /** + * Derives a child key. Child key will not be associated with any + * other child key because of properties of underlying KDF. + * + * @param protocol - 3-15 character protocol name + * @param accountId - numeric identifier of account + * @param options - `keyLength: 64` or `modulus: 41920438n` + * @example deriveChildKey('aes', 0) + */ + deriveChildKey: (protocol: string, accountId: AccountID, options?: KeyOpts) => Uint8Array; + /** + * Deletes the main seed from eskdf instance + */ + expire: () => void; + /** + * Account fingerprint + */ + fingerprint: string; +} +/** + * ESKDF + * @param username - username, email, or identifier, min: 8 characters, should have enough entropy + * @param password - password, min: 8 characters, should have enough entropy + * @example + * const kdf = await eskdf('example-university', 'beginning-new-example'); + * const key = kdf.deriveChildKey('aes', 0); + * console.log(kdf.fingerprint); + * kdf.expire(); + */ +export declare function eskdf(username: string, password: string): Promise; +export {}; +//# sourceMappingURL=eskdf.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/eskdf.d.ts.map b/node_modules/@noble/hashes/eskdf.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..131451350868535e8d73042a130ef567daf6ff85 --- /dev/null +++ b/node_modules/@noble/hashes/eskdf.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"eskdf.d.ts","sourceRoot":"","sources":["src/eskdf.ts"],"names":[],"mappings":"AAiBA,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,CAEjE;AAGD,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,CAEjE;AAiBD;;GAEG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,CAY7E;AAED,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAgCjC,KAAK,UAAU,GAAG;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AACxC,KAAK,OAAO,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AACnC,KAAK,OAAO,GAAG,SAAS,GAAG,UAAU,GAAG,OAAO,CAAC;AAwChD,MAAM,WAAW,KAAK;IACpB;;;;;;;;OAQG;IACH,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,UAAU,CAAC;IAC1F;;OAEG;IACH,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;GASG;AACH,wBAAsB,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAuB9E"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/eskdf.js b/node_modules/@noble/hashes/eskdf.js new file mode 100644 index 0000000000000000000000000000000000000000..ac23290e590bd43fe7b0e71f0f8223fe09c87d72 --- /dev/null +++ b/node_modules/@noble/hashes/eskdf.js @@ -0,0 +1,166 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.scrypt = scrypt; +exports.pbkdf2 = pbkdf2; +exports.deriveMainSeed = deriveMainSeed; +exports.eskdf = eskdf; +/** + * Experimental KDF for AES. + */ +const hkdf_ts_1 = require("./hkdf.js"); +const pbkdf2_ts_1 = require("./pbkdf2.js"); +const scrypt_ts_1 = require("./scrypt.js"); +const sha256_ts_1 = require("./sha256.js"); +const utils_ts_1 = require("./utils.js"); +// A tiny KDF for various applications like AES key-gen. +// Uses HKDF in a non-standard way, so it's not "KDF-secure", only "PRF-secure". +// Which is good enough: assume sha2-256 retained preimage resistance. +const SCRYPT_FACTOR = 2 ** 19; +const PBKDF2_FACTOR = 2 ** 17; +// Scrypt KDF +function scrypt(password, salt) { + return (0, scrypt_ts_1.scrypt)(password, salt, { N: SCRYPT_FACTOR, r: 8, p: 1, dkLen: 32 }); +} +// PBKDF2-HMAC-SHA256 +function pbkdf2(password, salt) { + return (0, pbkdf2_ts_1.pbkdf2)(sha256_ts_1.sha256, password, salt, { c: PBKDF2_FACTOR, dkLen: 32 }); +} +// Combines two 32-byte byte arrays +function xor32(a, b) { + (0, utils_ts_1.abytes)(a, 32); + (0, utils_ts_1.abytes)(b, 32); + const arr = new Uint8Array(32); + for (let i = 0; i < 32; i++) { + arr[i] = a[i] ^ b[i]; + } + return arr; +} +function strHasLength(str, min, max) { + return typeof str === 'string' && str.length >= min && str.length <= max; +} +/** + * Derives main seed. Takes a lot of time. Prefer `eskdf` method instead. + */ +function deriveMainSeed(username, password) { + if (!strHasLength(username, 8, 255)) + throw new Error('invalid username'); + if (!strHasLength(password, 8, 255)) + throw new Error('invalid password'); + // Declared like this to throw off minifiers which auto-convert .fromCharCode(1) to actual string. + // String with non-ascii may be problematic in some envs + const codes = { _1: 1, _2: 2 }; + const sep = { s: String.fromCharCode(codes._1), p: String.fromCharCode(codes._2) }; + const scr = scrypt(password + sep.s, username + sep.s); + const pbk = pbkdf2(password + sep.p, username + sep.p); + const res = xor32(scr, pbk); + (0, utils_ts_1.clean)(scr, pbk); + return res; +} +/** + * Converts protocol & accountId pair to HKDF salt & info params. + */ +function getSaltInfo(protocol, accountId = 0) { + // Note that length here also repeats two lines below + // We do an additional length check here to reduce the scope of DoS attacks + if (!(strHasLength(protocol, 3, 15) && /^[a-z0-9]{3,15}$/.test(protocol))) { + throw new Error('invalid protocol'); + } + // Allow string account ids for some protocols + const allowsStr = /^password\d{0,3}|ssh|tor|file$/.test(protocol); + let salt; // Extract salt. Default is undefined. + if (typeof accountId === 'string') { + if (!allowsStr) + throw new Error('accountId must be a number'); + if (!strHasLength(accountId, 1, 255)) + throw new Error('accountId must be string of length 1..255'); + salt = (0, utils_ts_1.kdfInputToBytes)(accountId); + } + else if (Number.isSafeInteger(accountId)) { + if (accountId < 0 || accountId > Math.pow(2, 32) - 1) + throw new Error('invalid accountId'); + // Convert to Big Endian Uint32 + salt = new Uint8Array(4); + (0, utils_ts_1.createView)(salt).setUint32(0, accountId, false); + } + else { + throw new Error('accountId must be a number' + (allowsStr ? ' or string' : '')); + } + const info = (0, utils_ts_1.kdfInputToBytes)(protocol); + return { salt, info }; +} +function countBytes(num) { + if (typeof num !== 'bigint' || num <= BigInt(128)) + throw new Error('invalid number'); + return Math.ceil(num.toString(2).length / 8); +} +/** + * Parses keyLength and modulus options to extract length of result key. + * If modulus is used, adds 64 bits to it as per FIPS 186 B.4.1 to combat modulo bias. + */ +function getKeyLength(options) { + if (!options || typeof options !== 'object') + return 32; + const hasLen = 'keyLength' in options; + const hasMod = 'modulus' in options; + if (hasLen && hasMod) + throw new Error('cannot combine keyLength and modulus options'); + if (!hasLen && !hasMod) + throw new Error('must have either keyLength or modulus option'); + // FIPS 186 B.4.1 requires at least 64 more bits + const l = hasMod ? countBytes(options.modulus) + 8 : options.keyLength; + if (!(typeof l === 'number' && l >= 16 && l <= 8192)) + throw new Error('invalid keyLength'); + return l; +} +/** + * Converts key to bigint and divides it by modulus. Big Endian. + * Implements FIPS 186 B.4.1, which removes 0 and modulo bias from output. + */ +function modReduceKey(key, modulus) { + const _1 = BigInt(1); + const num = BigInt('0x' + (0, utils_ts_1.bytesToHex)(key)); // check for ui8a, then bytesToNumber() + const res = (num % (modulus - _1)) + _1; // Remove 0 from output + if (res < _1) + throw new Error('expected positive number'); // Guard against bad values + const len = key.length - 8; // FIPS requires 64 more bits = 8 bytes + const hex = res.toString(16).padStart(len * 2, '0'); // numberToHex() + const bytes = (0, utils_ts_1.hexToBytes)(hex); + if (bytes.length !== len) + throw new Error('invalid length of result key'); + return bytes; +} +/** + * ESKDF + * @param username - username, email, or identifier, min: 8 characters, should have enough entropy + * @param password - password, min: 8 characters, should have enough entropy + * @example + * const kdf = await eskdf('example-university', 'beginning-new-example'); + * const key = kdf.deriveChildKey('aes', 0); + * console.log(kdf.fingerprint); + * kdf.expire(); + */ +async function eskdf(username, password) { + // We are using closure + object instead of class because + // we want to make `seed` non-accessible for any external function. + let seed = deriveMainSeed(username, password); + function deriveCK(protocol, accountId = 0, options) { + (0, utils_ts_1.abytes)(seed, 32); + const { salt, info } = getSaltInfo(protocol, accountId); // validate protocol & accountId + const keyLength = getKeyLength(options); // validate options + const key = (0, hkdf_ts_1.hkdf)(sha256_ts_1.sha256, seed, salt, info, keyLength); + // Modulus has already been validated + return options && 'modulus' in options ? modReduceKey(key, options.modulus) : key; + } + function expire() { + if (seed) + seed.fill(1); + seed = undefined; + } + // prettier-ignore + const fingerprint = Array.from(deriveCK('fingerprint', 0)) + .slice(0, 6) + .map((char) => char.toString(16).padStart(2, '0').toUpperCase()) + .join(':'); + return Object.freeze({ deriveChildKey: deriveCK, expire, fingerprint }); +} +//# sourceMappingURL=eskdf.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/eskdf.js.map b/node_modules/@noble/hashes/eskdf.js.map new file mode 100644 index 0000000000000000000000000000000000000000..c5204447e23a78a2c22795b6189e104e8d512bc2 --- /dev/null +++ b/node_modules/@noble/hashes/eskdf.js.map @@ -0,0 +1 @@ +{"version":3,"file":"eskdf.js","sourceRoot":"","sources":["src/eskdf.ts"],"names":[],"mappings":";;AAiBA,wBAEC;AAGD,wBAEC;AAoBD,wCAYC;AA2GD,sBAuBC;AA1LD;;GAEG;AACH,uCAAiC;AACjC,2CAAgD;AAChD,2CAAgD;AAChD,2CAAqC;AACrC,yCAAgG;AAEhG,wDAAwD;AACxD,gFAAgF;AAChF,sEAAsE;AAEtE,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,CAAC;AAC9B,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,CAAC;AAE9B,aAAa;AACb,SAAgB,MAAM,CAAC,QAAgB,EAAE,IAAY;IACnD,OAAO,IAAA,kBAAO,EAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;AAC9E,CAAC;AAED,qBAAqB;AACrB,SAAgB,MAAM,CAAC,QAAgB,EAAE,IAAY;IACnD,OAAO,IAAA,kBAAO,EAAC,kBAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;AAC1E,CAAC;AAED,mCAAmC;AACnC,SAAS,KAAK,CAAC,CAAa,EAAE,CAAa;IACzC,IAAA,iBAAM,EAAC,CAAC,EAAE,EAAE,C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000000000000000000000000000000000..5d62f87bafd7400c86a79394ad86b67c8ed792e9 --- /dev/null +++ b/node_modules/@noble/hashes/esm/_assert.d.ts @@ -0,0 +1,17 @@ +/** + * Internal assertion helpers. + * @module + * @deprecated + */ +import { abytes as ab, aexists as ae, anumber as an, aoutput as ao, type IHash as H } from './utils.ts'; +/** @deprecated Use import from `noble/hashes/utils` module */ +export declare const abytes: typeof ab; +/** @deprecated Use import from `noble/hashes/utils` module */ +export declare const aexists: typeof ae; +/** @deprecated Use import from `noble/hashes/utils` module */ +export declare const anumber: typeof an; +/** @deprecated Use import from `noble/hashes/utils` module */ +export declare const aoutput: typeof ao; +/** @deprecated Use import from `noble/hashes/utils` module */ +export type Hash = H; +//# sourceMappingURL=_assert.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/_assert.d.ts.map b/node_modules/@noble/hashes/esm/_assert.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..8e49f0690c8dc16da1ac99c141759ed19eeea928 --- /dev/null +++ b/node_modules/@noble/hashes/esm/_assert.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"_assert.d.ts","sourceRoot":"","sources":["../src/_assert.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,MAAM,IAAI,EAAE,EACZ,OAAO,IAAI,EAAE,EACb,OAAO,IAAI,EAAE,EACb,OAAO,IAAI,EAAE,EACb,KAAK,KAAK,IAAI,CAAC,EAChB,MAAM,YAAY,CAAC;AACpB,8DAA8D;AAC9D,eAAO,MAAM,MAAM,EAAE,OAAO,EAAO,CAAC;AACpC,8DAA8D;AAC9D,eAAO,MAAM,OAAO,EAAE,OAAO,EAAO,CAAC;AACrC,8DAA8D;AAC9D,eAAO,MAAM,OAAO,EAAE,OAAO,EAAO,CAAC;AACrC,8DAA8D;AAC9D,eAAO,MAAM,OAAO,EAAE,OAAO,EAAO,CAAC;AACrC,8DAA8D;AAC9D,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/_assert.js b/node_modules/@noble/hashes/esm/_assert.js new file mode 100644 index 0000000000000000000000000000000000000000..91286fdfdd9ba911f0c26427022226477fba0331 --- /dev/null +++ b/node_modules/@noble/hashes/esm/_assert.js @@ -0,0 +1,15 @@ +/** + * Internal assertion helpers. + * @module + * @deprecated + */ +import { abytes as ab, aexists as ae, anumber as an, aoutput as ao, } from "./utils.js"; +/** @deprecated Use import from `noble/hashes/utils` module */ +export const abytes = ab; +/** @deprecated Use import from `noble/hashes/utils` module */ +export const aexists = ae; +/** @deprecated Use import from `noble/hashes/utils` module */ +export const anumber = an; +/** @deprecated Use import from `noble/hashes/utils` module */ +export const aoutput = ao; +//# sourceMappingURL=_assert.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/_assert.js.map b/node_modules/@noble/hashes/esm/_assert.js.map new file mode 100644 index 0000000000000000000000000000000000000000..a64fcf56cca6103a6c1a5de8741456cb5edbcade --- /dev/null +++ b/node_modules/@noble/hashes/esm/_assert.js.map @@ -0,0 +1 @@ +{"version":3,"file":"_assert.js","sourceRoot":"","sources":["../src/_assert.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,MAAM,IAAI,EAAE,EACZ,OAAO,IAAI,EAAE,EACb,OAAO,IAAI,EAAE,EACb,OAAO,IAAI,EAAE,GAEd,MAAM,YAAY,CAAC;AACpB,8DAA8D;AAC9D,MAAM,CAAC,MAAM,MAAM,GAAc,EAAE,CAAC;AACpC,8DAA8D;AAC9D,MAAM,CAAC,MAAM,OAAO,GAAc,EAAE,CAAC;AACrC,8DAA8D;AAC9D,MAAM,CAAC,MAAM,OAAO,GAAc,EAAE,CAAC;AACrC,8DAA8D;AAC9D,MAAM,CAAC,MAAM,OAAO,GAAc,EAAE,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/_blake.d.ts b/node_modules/@noble/hashes/esm/_blake.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..71ed85f9787ddb7b31acfa0c01dd910f87800f3a --- /dev/null +++ b/node_modules/@noble/hashes/esm/_blake.d.ts @@ -0,0 +1,14 @@ +/** + * Internal blake variable. + * For BLAKE2b, the two extra permutations for rounds 10 and 11 are SIGMA[10..11] = SIGMA[0..1]. + */ +export declare const BSIGMA: Uint8Array; +export type Num4 = { + a: number; + b: number; + c: number; + d: number; +}; +export declare function G1s(a: number, b: number, c: number, d: number, x: number): Num4; +export declare function G2s(a: number, b: number, c: number, d: number, x: number): Num4; +//# sourceMappingURL=_blake.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/_blake.d.ts.map b/node_modules/@noble/hashes/esm/_blake.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..c945f9d14a0cc207df9ecd52d084de82e43bdb1b --- /dev/null +++ b/node_modules/@noble/hashes/esm/_blake.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"_blake.d.ts","sourceRoot":"","sources":["../src/_blake.ts"],"names":[],"mappings":"AAMA;;;GAGG;AAEH,eAAO,MAAM,MAAM,EAAE,UAkBnB,CAAC;AAGH,MAAM,MAAM,IAAI,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;CAAE,CAAC;AAGnE,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAM/E;AAED,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAM/E"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/_blake.js b/node_modules/@noble/hashes/esm/_blake.js new file mode 100644 index 0000000000000000000000000000000000000000..3573ee9642b86a4797f63eb9500665a34a4490ea --- /dev/null +++ b/node_modules/@noble/hashes/esm/_blake.js @@ -0,0 +1,45 @@ +/** + * Internal helpers for blake hash. + * @module + */ +import { rotr } from "./utils.js"; +/** + * Internal blake variable. + * For BLAKE2b, the two extra permutations for rounds 10 and 11 are SIGMA[10..11] = SIGMA[0..1]. + */ +// prettier-ignore +export const BSIGMA = /* @__PURE__ */ Uint8Array.from([ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, + 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, + 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, + 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, + 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, + 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, + 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, + 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5, + 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, + // Blake1, unused in others + 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, + 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, + 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, + 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, +]); +// Mixing function G splitted in two halfs +export function G1s(a, b, c, d, x) { + a = (a + b + x) | 0; + d = rotr(d ^ a, 16); + c = (c + d) | 0; + b = rotr(b ^ c, 12); + return { a, b, c, d }; +} +export function G2s(a, b, c, d, x) { + a = (a + b + x) | 0; + d = rotr(d ^ a, 8); + c = (c + d) | 0; + b = rotr(b ^ c, 7); + return { a, b, c, d }; +} +//# sourceMappingURL=_blake.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/_blake.js.map b/node_modules/@noble/hashes/esm/_blake.js.map new file mode 100644 index 0000000000000000000000000000000000000000..c8cdaaaf6ed4ba01714b9c0e356c64d0f882807e --- /dev/null +++ b/node_modules/@noble/hashes/esm/_blake.js.map @@ -0,0 +1 @@ +{"version":3,"file":"_blake.js","sourceRoot":"","sources":["../src/_blake.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC;;;GAGG;AACH,kBAAkB;AAClB,MAAM,CAAC,MAAM,MAAM,GAAe,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC;IAChE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;IACpD,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IACpD,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EA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AC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC;CACrD,CAAC,CAAC;AAKH,0CAA0C;AAC1C,MAAM,UAAU,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS;IACvE,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;IACpB,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IAChB,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;IACpB,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS;IACvE,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACnB,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IAChB,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACnB,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AACxB,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/_md.d.ts b/node_modules/@noble/hashes/esm/_md.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ae184df9cc47efe9a7da09b601f8edf652eb801c --- /dev/null +++ b/node_modules/@noble/hashes/esm/_md.d.ts @@ -0,0 +1,51 @@ +/** + * Internal Merkle-Damgard hash utils. + * @module + */ +import { type Input, Hash } from './utils.ts'; +/** Polyfill for Safari 14. https://caniuse.com/mdn-javascript_builtins_dataview_setbiguint64 */ +export declare function setBigUint64(view: DataView, byteOffset: number, value: bigint, isLE: boolean): void; +/** Choice: a ? b : c */ +export declare function Chi(a: number, b: number, c: number): number; +/** Majority function, true if any two inputs is true. */ +export declare function Maj(a: number, b: number, c: number): number; +/** + * Merkle-Damgard hash construction base class. + * Could be used to create MD5, RIPEMD, SHA1, SHA2. + */ +export declare abstract class HashMD> extends Hash { + protected abstract process(buf: DataView, offset: number): void; + protected abstract get(): number[]; + protected abstract set(...args: number[]): void; + abstract destroy(): void; + protected abstract roundClean(): void; + readonly blockLen: number; + readonly outputLen: number; + readonly padOffset: number; + readonly isLE: boolean; + protected buffer: Uint8Array; + protected view: DataView; + protected finished: boolean; + protected length: number; + protected pos: number; + protected destroyed: boolean; + constructor(blockLen: number, outputLen: number, padOffset: number, isLE: boolean); + update(data: Input): this; + digestInto(out: Uint8Array): void; + digest(): Uint8Array; + _cloneInto(to?: T): T; + clone(): T; +} +/** + * Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53. + * Check out `test/misc/sha2-gen-iv.js` for recomputation guide. + */ +/** Initial SHA256 state. Bits 0..32 of frac part of sqrt of primes 2..19 */ +export declare const SHA256_IV: Uint32Array; +/** Initial SHA224 state. Bits 32..64 of frac part of sqrt of primes 23..53 */ +export declare const SHA224_IV: Uint32Array; +/** Initial SHA384 state. Bits 0..64 of frac part of sqrt of primes 23..53 */ +export declare const SHA384_IV: Uint32Array; +/** Initial SHA512 state. Bits 0..64 of frac part of sqrt of primes 2..19 */ +export declare const SHA512_IV: Uint32Array; +//# sourceMappingURL=_md.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/_md.d.ts.map b/node_modules/@noble/hashes/esm/_md.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..d67c97026db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AI,EAAE,OAAO,CAAC;IAGvB,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC;IAC7B,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC;IACzB,SAAS,CAAC,QAAQ,UAAS;IAC3B,SAAS,CAAC,MAAM,SAAK;IACrB,SAAS,CAAC,GAAG,SAAK;IAClB,SAAS,CAAC,SAAS,UAAS;gBAEhB,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;IASjF,MAAM,CAAC,IAAI,EAAE,KAAK,GAAG,IAAI;IA0BzB,UAAU,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI;IAkCjC,MAAM,IAAI,UAAU;IAOpB,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC;IAWrB,KAAK,IAAI,CAAC;CAGX;AAED;;;GAGG;AAEH,4EAA4E;AAC5E,eAAO,MAAM,SAAS,EAAE,WAEtB,CAAC;AAEH,8EAA8E;AAC9E,eAAO,MAAM,SAAS,EAAE,WAEtB,CAAC;AAEH,6EAA6E;AAC7E,eAAO,MAAM,SAAS,EAAE,WAGtB,CAAC;AAEH,4EAA4E;AAC5E,eAAO,MAAM,SAAS,EAAE,WAGtB,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/_md.js b/node_modules/@noble/hashes/esm/_md.js new file mode 100644 index 0000000000000000000000000000000000000000..3cf023d9f7d9160ff5c10264725b68148668d168 --- /dev/null +++ b/node_modules/@noble/hashes/esm/_md.js @@ -0,0 +1,155 @@ +/** + * Internal Merkle-Damgard hash utils. + * @module + */ +import { Hash, abytes, aexists, aoutput, clean, createView, toBytes } from "./utils.js"; +/** Polyfill for Safari 14. https://caniuse.com/mdn-javascript_builtins_dataview_setbiguint64 */ +export function setBigUint64(view, byteOffset, value, isLE) { + if (typeof view.setBigUint64 === 'function') + return view.setBigUint64(byteOffset, value, isLE); + const _32n = BigInt(32); + const _u32_max = BigInt(0xffffffff); + const wh = Number((value >> _32n) & _u32_max); + const wl = Number(value & _u32_max); + const h = isLE ? 4 : 0; + const l = isLE ? 0 : 4; + view.setUint32(byteOffset + h, wh, isLE); + view.setUint32(byteOffset + l, wl, isLE); +} +/** Choice: a ? b : c */ +export function Chi(a, b, c) { + return (a & b) ^ (~a & c); +} +/** Majority function, true if any two inputs is true. */ +export function Maj(a, b, c) { + return (a & b) ^ (a & c) ^ (b & c); +} +/** + * Merkle-Damgard hash construction base class. + * Could be used to create MD5, RIPEMD, SHA1, SHA2. + */ +export class HashMD extends Hash { + constructor(blockLen, outputLen, padOffset, isLE) { + super(); + this.finished = false; + this.length = 0; + this.pos = 0; + this.destroyed = false; + this.blockLen = blockLen; + this.outputLen = outputLen; + this.padOffset = padOffset; + this.isLE = isLE; + this.buffer = new Uint8Array(blockLen); + this.view = createView(this.buffer); + } + update(data) { + aexists(this); + data = toBytes(data); + abytes(data); + const { view, buffer, blockLen } = this; + const len = data.length; + for (let pos = 0; pos < len;) { + const take = Math.min(blockLen - this.pos, len - pos); + // Fast path: we have at least one block in input, cast it to view and process + if (take === blockLen) { + const dataView = createView(data); + for (; blockLen <= len - pos; pos += blockLen) + this.process(dataView, pos); + continue; + } + buffer.set(data.subarray(pos, pos + take), this.pos); + this.pos += take; + pos += take; + if (this.pos === blockLen) { + this.process(view, 0); + this.pos = 0; + } + } + this.length += data.length; + this.roundClean(); + return this; + } + digestInto(out) { + aexists(this); + aoutput(out, this); + this.finished = true; + // Padding + // We can avoid allocation of buffer for padding completely if it + // was previously not allocated here. But it won't change performance. + const { buffer, view, blockLen, isLE } = this; + let { pos } = this; + // append the bit '1' to the message + buffer[pos++] = 0b10000000; + clean(this.buffer.subarray(pos)); + // we have less than padOffset left in buffer, so we cannot put length in + // current block, need process it and pad again + if (this.padOffset > blockLen - pos) { + this.process(view, 0); + pos = 0; + } + // Pad until full block byte with zeros + for (let i = pos; i < blockLen; i++) + buffer[i] = 0; + // Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that + // You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen. + // So we just write lowest 64 bits of that value. + setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE); + this.process(view, 0); + const oview = createView(out); + const len = this.outputLen; + // NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT + if (len % 4) + throw new Error('_sha2: outputLen should be aligned to 32bit'); + const outLen = len / 4; + const state = this.get(); + if (outLen > state.length) + throw new Error('_sha2: outputLen bigger than state'); + for (let i = 0; i < outLen; i++) + oview.setUint32(4 * i, state[i], isLE); + } + digest() { + const { buffer, outputLen } = this; + this.digestInto(buffer); + const res = buffer.slice(0, outputLen); + this.destroy(); + return res; + } + _cloneInto(to) { + to || (to = new this.constructor()); + to.set(...this.get()); + const { blockLen, buffer, length, finished, destroyed, pos } = this; + to.destroyed = destroyed; + to.finished = finished; + to.length = length; + to.pos = pos; + if (length % blockLen) + to.buffer.set(buffer); + return to; + } + clone() { + return this._cloneInto(); + } +} +/** + * Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53. + * Check out `test/misc/sha2-gen-iv.js` for recomputation guide. + */ +/** Initial SHA256 state. Bits 0..32 of frac part of sqrt of primes 2..19 */ +export const SHA256_IV = /* @__PURE__ */ Uint32Array.from([ + 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19, +]); +/** Initial SHA224 state. Bits 32..64 of frac part of sqrt of primes 23..53 */ +export const SHA224_IV = /* @__PURE__ */ Uint32Array.from([ + 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4, +]); +/** Initial SHA384 state. Bits 0..64 of frac part of sqrt of primes 23..53 */ +export const SHA384_IV = /* @__PURE__ */ Uint32Array.from([ + 0xcbbb9d5d, 0xc1059ed8, 0x629a292a, 0x367cd507, 0x9159015a, 0x3070dd17, 0x152fecd8, 0xf70e5939, + 0x67332667, 0xffc00b31, 0x8eb44a87, 0x68581511, 0xdb0c2e0d, 0x64f98fa7, 0x47b5481d, 0xbefa4fa4, +]); +/** Initial SHA512 state. Bits 0..64 of frac part of sqrt of primes 2..19 */ +export const SHA512_IV = /* @__PURE__ */ Uint32Array.from([ + 0x6a09e667, 0xf3bcc908, 0xbb67ae85, 0x84caa73b, 0x3c6ef372, 0xfe94f82b, 0xa54ff53a, 0x5f1d36f1, + 0x510e527f, 0xade682d1, 0x9b05688c, 0x2b3e6c1f, 0x1f83d9ab, 0xfb41bd6b, 0x5be0cd19, 0x137e2179, +]); +//# sourceMappingURL=_md.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/_md.js.map b/node_modules/@noble/hashes/esm/_md.js.map new file mode 100644 index 0000000000000000000000000000000000000000..4b3da57eb294466b66178c51964670bb9100657f --- /dev/null +++ b/node_modules/@noble/hashes/esm/_md.js.map @@ -0,0 +1 @@ +{"version":3,"file":"_md.js","sourceRoot":"","sources":["../src/_md.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAc,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEpG,gGAAgG;AAChG,MAAM,UAAU,YAAY,CAC1B,IAAc,EACd,UAAkB,EAClB,KAAa,EACb,IAAa;IAEb,IAAI,OAAO,IAAI,CAAC,YAAY,KAAK,UAAU;QAAE,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IAC/F,MAAM,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;IACxB,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;IACpC,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC;IAC9C,MAAM,EAAE,GAAG,M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line at end of file diff --git a/node_modules/@noble/hashes/esm/_u64.d.ts b/node_modules/@noble/hashes/esm/_u64.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ac5523a329e78222c6e8898f97a2eaf339780fad --- /dev/null +++ b/node_modules/@noble/hashes/esm/_u64.d.ts @@ -0,0 +1,55 @@ +declare function fromBig(n: bigint, le?: boolean): { + h: number; + l: number; +}; +declare function split(lst: bigint[], le?: boolean): Uint32Array[]; +declare const toBig: (h: number, l: number) => bigint; +declare const shrSH: (h: number, _l: number, s: number) => number; +declare const shrSL: (h: number, l: number, s: number) => number; +declare const rotrSH: (h: number, l: number, s: number) => number; +declare const rotrSL: (h: number, l: number, s: number) => number; +declare const rotrBH: (h: number, l: number, s: number) => number; +declare const rotrBL: (h: number, l: number, s: number) => number; +declare const rotr32H: (_h: number, l: number) => number; +declare const rotr32L: (h: number, _l: number) => number; +declare const rotlSH: (h: number, l: number, s: number) => number; +declare const rotlSL: (h: number, l: number, s: number) => number; +declare const rotlBH: (h: number, l: number, s: number) => number; +declare const rotlBL: (h: number, l: number, s: number) => number; +declare function add(Ah: number, Al: number, Bh: number, Bl: number): { + h: number; + l: number; +}; +declare const add3L: (Al: number, Bl: number, Cl: number) => number; +declare const add3H: (low: number, Ah: number, Bh: number, Ch: number) => number; +declare const add4L: (Al: number, Bl: number, Cl: number, Dl: number) => number; +declare const add4H: (low: number, Ah: number, Bh: number, Ch: number, Dh: number) => number; +declare const add5L: (Al: number, Bl: number, Cl: number, Dl: number, El: number) => number; +declare const add5H: (low: number, Ah: number, Bh: number, Ch: number, Dh: number, Eh: number) => number; +export { add, add3H, add3L, add4H, add4L, add5H, add5L, fromBig, rotlBH, rotlBL, rotlSH, rotlSL, rotr32H, rotr32L, rotrBH, rotrBL, rotrSH, rotrSL, shrSH, shrSL, split, toBig }; +declare const u64: { + fromBig: typeof fromBig; + split: typeof split; + toBig: (h: number, l: number) => bigint; + shrSH: (h: number, _l: number, s: number) => number; + shrSL: (h: number, l: number, s: number) => number; + rotrSH: (h: number, l: number, s: number) => number; + rotrSL: (h: number, l: number, s: number) => number; + rotrBH: (h: number, l: number, s: number) => number; + rotrBL: (h: number, l: number, s: number) => number; + rotr32H: (_h: number, l: number) => number; + rotr32L: (h: number, _l: number) => number; + rotlSH: (h: number, l: number, s: number) => number; + rotlSL: (h: number, l: number, s: number) => number; + rotlBH: (h: number, l: number, s: number) => number; + rotlBL: (h: number, l: number, s: number) => number; + add: typeof add; + add3L: (Al: number, Bl: number, Cl: number) => number; + add3H: (low: number, Ah: number, Bh: number, Ch: number) => number; + add4L: (Al: number, Bl: number, Cl: number, Dl: number) => number; + add4H: (low: number, Ah: number, Bh: number, Ch: number, Dh: number) => number; + add5H: (low: number, Ah: number, Bh: number, Ch: number, Dh: number, Eh: number) => number; + add5L: (Al: number, Bl: number, Cl: number, Dl: number, El: number) => number; +}; +export default u64; +//# sourceMappingURL=_u64.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/_u64.d.ts.map b/node_modules/@noble/hashes/esm/_u64.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..b1e0a4efbbe6ed4baf896be5400d2034b07859ad --- /dev/null +++ b/node_modules/@noble/hashes/esm/_u64.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"_u64.d.ts","sourceRoot":"","sources":["../src/_u64.ts"],"names":[],"mappings":"AAQA,iBAAS,OAAO,CACd,CAAC,EAAE,MAAM,EACT,EAAE,UAAQ,GACT;IACD,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAGA;AAED,iBAAS,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,UAAQ,GAAG,WAAW,EAAE,CASvD;AAED,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,M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,CAAC;IAAC,GAAG,EAAE,OAAO,GAAG,CAAC;IAAC,KAAK,EAAE,CAAC,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,KAAK,MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,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,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;AACF,eAAe,GAAG,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/_u64.js b/node_modules/@noble/hashes/esm/_u64.js new file mode 100644 index 0000000000000000000000000000000000000000..65193543fa83f2c88a38c250f1dad719564d4004 --- /dev/null +++ b/node_modules/@noble/hashes/esm/_u64.js @@ -0,0 +1,67 @@ +/** + * Internal helpers for u64. BigUint64Array is too slow as per 2025, so we implement it using Uint32Array. + * @todo re-check https://issues.chromium.org/issues/42212588 + * @module + */ +const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1); +const _32n = /* @__PURE__ */ BigInt(32); +function fromBig(n, le = false) { + if (le) + return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) }; + return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 }; +} +function split(lst, le = false) { + const len = lst.length; + let Ah = new Uint32Array(len); + let Al = new Uint32Array(len); + for (let i = 0; i < len; i++) { + const { h, l } = fromBig(lst[i], le); + [Ah[i], Al[i]] = [h, l]; + } + return [Ah, Al]; +} +const toBig = (h, l) => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0); +// for Shift in [0, 32) +const shrSH = (h, _l, s) => h >>> s; +const shrSL = (h, l, s) => (h << (32 - s)) | (l >>> s); +// Right rotate for Shift in [1, 32) +const rotrSH = (h, l, s) => (h >>> s) | (l << (32 - s)); +const rotrSL = (h, l, s) => (h << (32 - s)) | (l >>> s); +// Right rotate for Shift in (32, 64), NOTE: 32 is special case. +const rotrBH = (h, l, s) => (h << (64 - s)) | (l >>> (s - 32)); +const rotrBL = (h, l, s) => (h >>> (s - 32)) | (l << (64 - s)); +// Right rotate for shift===32 (just swaps l&h) +const rotr32H = (_h, l) => l; +const rotr32L = (h, _l) => h; +// Left rotate for Shift in [1, 32) +const rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s)); +const rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s)); +// Left rotate for Shift in (32, 64), NOTE: 32 is special case. +const rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s)); +const rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s)); +// JS uses 32-bit signed integers for bitwise operations which means we cannot +// simple take carry out of low bit sum by shift, we need to use division. +function add(Ah, Al, Bh, Bl) { + const l = (Al >>> 0) + (Bl >>> 0); + return { h: (Ah + Bh + ((l / 2 ** 32) | 0)) | 0, l: l | 0 }; +} +// Addition with more than 2 elements +const add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0); +const add3H = (low, Ah, Bh, Ch) => (Ah + Bh + Ch + ((low / 2 ** 32) | 0)) | 0; +const add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0); +const add4H = (low, Ah, Bh, Ch, Dh) => (Ah + Bh + Ch + Dh + ((low / 2 ** 32) | 0)) | 0; +const add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0); +const add5H = (low, Ah, Bh, Ch, Dh, Eh) => (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0; +// prettier-ignore +export { add, add3H, add3L, add4H, add4L, add5H, add5L, fromBig, rotlBH, rotlBL, rotlSH, rotlSL, rotr32H, rotr32L, rotrBH, rotrBL, rotrSH, rotrSL, shrSH, shrSL, split, toBig }; +// prettier-ignore +const u64 = { + fromBig, split, toBig, + shrSH, shrSL, + rotrSH, rotrSL, rotrBH, rotrBL, + rotr32H, rotr32L, + rotlSH, rotlSL, rotlBH, rotlBL, + add, add3L, add3H, add4L, add4H, add5H, add5L, +}; +export default u64; +//# sourceMappingURL=_u64.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/_u64.js.map b/node_modules/@noble/hashes/esm/_u64.js.map new file mode 100644 index 0000000000000000000000000000000000000000..36261865c6cdd223fba5e560c0c311d9bd444157 --- /dev/null +++ b/node_modules/@noble/hashes/esm/_u64.js.map @@ -0,0 +1 @@ +{"version":3,"file":"_u64.js","sourceRoot":"","sources":["../src/_u64.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,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,SAAS,OAAO,CACd,CAAS,E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G,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,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,eAAe,GAAG,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/argon2.d.ts b/node_modules/@noble/hashes/esm/argon2.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..67cb8f6b76ef76f2657fd14855397b1da12ac6f6 --- /dev/null +++ b/node_modules/@noble/hashes/esm/argon2.d.ts @@ -0,0 +1,32 @@ +import { type KDFInput } from './utils.ts'; +/** + * Argon2 options. + * * t: time cost, m: mem cost in kb, p: parallelization. + * * key: optional key. personalization: arbitrary extra data. + * * dkLen: desired number of output bytes. + */ +export type ArgonOpts = { + t: number; + m: number; + p: number; + version?: number; + key?: KDFInput; + personalization?: KDFInput; + dkLen?: number; + asyncTick?: number; + maxmem?: number; + onProgress?: (progress: number) => void; +}; +/** argon2d GPU-resistant version. */ +export declare const argon2d: (password: KDFInput, salt: KDFInput, opts: ArgonOpts) => Uint8Array; +/** argon2i side-channel-resistant version. */ +export declare const argon2i: (password: KDFInput, salt: KDFInput, opts: ArgonOpts) => Uint8Array; +/** argon2id, combining i+d, the most popular version from RFC 9106 */ +export declare const argon2id: (password: KDFInput, salt: KDFInput, opts: ArgonOpts) => Uint8Array; +/** argon2d async GPU-resistant version. */ +export declare const argon2dAsync: (password: KDFInput, salt: KDFInput, opts: ArgonOpts) => Promise; +/** argon2i async side-channel-resistant version. */ +export declare const argon2iAsync: (password: KDFInput, salt: KDFInput, opts: ArgonOpts) => Promise; +/** argon2id async, combining i+d, the most popular version from RFC 9106 */ +export declare const argon2idAsync: (password: KDFInput, salt: KDFInput, opts: ArgonOpts) => Promise; +//# sourceMappingURL=argon2.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/argon2.d.ts.map b/node_modules/@noble/hashes/esm/argon2.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..65b1e4cbba711065d89a07ac954bbe6f111c5c71 --- /dev/null +++ b/node_modules/@noble/hashes/esm/argon2.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"argon2.d.ts","sourceRoot":"","sources":["../src/argon2.ts"],"names":[],"mappings":"AAYA,OAAO,EAAqD,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAkK9F;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,QAAQ,CAAC;IACf,eAAe,CAAC,EAAE,QAAQ,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC,CAAC;AAuNF,qCAAqC;AACrC,eAAO,MAAM,OAAO,GAAI,UAAU,QAAQ,EAAE,MAAM,QAAQ,EAAE,MAAM,SAAS,KAAG,UACnC,CAAC;AAC5C,8CAA8C;AAC9C,eAAO,MAAM,OAAO,GAAI,UAAU,QAAQ,EAAE,MAAM,QAAQ,EAAE,MAAM,SAAS,KAAG,UACpC,CAAC;AAC3C,sEAAsE;AACtE,eAAO,MAAM,QAAQ,GAAI,UAAU,QAAQ,EAAE,MAAM,QAAQ,EAAE,MAAM,SAAS,KAAG,UACpC,CAAC;AAiE5C,2CAA2C;AAC3C,eAAO,MAAM,YAAY,GACvB,UAAU,QAAQ,EAClB,MAAM,QAAQ,EACd,MAAM,SAAS,KACd,OAAO,CAAC,UAAU,CAAmD,CAAC;AACzE,oDAAoD;AACpD,eAAO,MAAM,YAAY,GACvB,UAAU,QAAQ,EAClB,MAAM,QAAQ,EACd,MAAM,SAAS,KACd,OAAO,CAAC,UAAU,CAAkD,CAAC;AACxE,4EAA4E;AAC5E,eAAO,MAAM,aAAa,GACxB,UAAU,QAAQ,EAClB,MAAM,QAAQ,EACd,MAAM,SAAS,KACd,OAAO,CAAC,UAAU,CAAmD,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/argon2.js b/node_modules/@noble/hashes/esm/argon2.js new file mode 100644 index 0000000000000000000000000000000000000000..3ba860f8fc97936c8648997e735b29dbdad2b027 --- /dev/null +++ b/node_modules/@noble/hashes/esm/argon2.js @@ -0,0 +1,392 @@ +/** + * Argon2 KDF from RFC 9106. Can be used to create a key from password and salt. + * We suggest to use Scrypt. JS Argon is 2-10x slower than native code because of 64-bitness: + * * argon uses uint64, but JS doesn't have fast uint64array + * * uint64 multiplication is 1/3 of time + * * `P` function would be very nice with u64, because most of value will be in registers, + * hovewer with u32 it will require 32 registers, which is too much. + * * JS arrays do slow bound checks, so reading from `A2_BUF` slows it down + * @module + */ +import { add3H, add3L, rotr32H, rotr32L, rotrBH, rotrBL, rotrSH, rotrSL } from "./_u64.js"; +import { blake2b } from "./blake2.js"; +import { abytes, clean, kdfInputToBytes, nextTick, u32, u8 } from "./utils.js"; +const AT = { Argond2d: 0, Argon2i: 1, Argon2id: 2 }; +const ARGON2_SYNC_POINTS = 4; +const abytesOrZero = (buf) => { + if (buf === undefined) + return Uint8Array.of(); + return kdfInputToBytes(buf); +}; +// u32 * u32 = u64 +function mul(a, b) { + const aL = a & 0xffff; + const aH = a >>> 16; + const bL = b & 0xffff; + const bH = b >>> 16; + const ll = Math.imul(aL, bL); + const hl = Math.imul(aH, bL); + const lh = Math.imul(aL, bH); + const hh = Math.imul(aH, bH); + const carry = (ll >>> 16) + (hl & 0xffff) + lh; + const high = (hh + (hl >>> 16) + (carry >>> 16)) | 0; + const low = (carry << 16) | (ll & 0xffff); + return { h: high, l: low }; +} +function mul2(a, b) { + // 2 * a * b (via shifts) + const { h, l } = mul(a, b); + return { h: ((h << 1) | (l >>> 31)) & 4294967295, l: (l << 1) & 4294967295 }; +} +// BlaMka permutation for Argon2 +// A + B + (2 * u32(A) * u32(B)) +function blamka(Ah, Al, Bh, Bl) { + const { h: Ch, l: Cl } = mul2(Al, Bl); + // A + B + (2 * A * B) + const Rll = add3L(Al, Bl, Cl); + return { h: add3H(Rll, Ah, Bh, Ch), l: Rll | 0 }; +} +// Temporary block buffer +const A2_BUF = new Uint32Array(256); // 1024 bytes (matrix 16x16) +function G(a, b, c, d) { + let Al = A2_BUF[2 * a], Ah = A2_BUF[2 * a + 1]; // prettier-ignore + let Bl = A2_BUF[2 * b], Bh = A2_BUF[2 * b + 1]; // prettier-ignore + let Cl = A2_BUF[2 * c], Ch = A2_BUF[2 * c + 1]; // prettier-ignore + let Dl = A2_BUF[2 * d], Dh = A2_BUF[2 * d + 1]; // prettier-ignore + ({ h: Ah, l: Al } = blamka(Ah, Al, Bh, Bl)); + ({ Dh, Dl } = { Dh: Dh ^ Ah, Dl: Dl ^ Al }); + ({ Dh, Dl } = { Dh: rotr32H(Dh, Dl), Dl: rotr32L(Dh, Dl) }); + ({ h: Ch, l: Cl } = blamka(Ch, Cl, Dh, Dl)); + ({ Bh, Bl } = { Bh: Bh ^ Ch, Bl: Bl ^ Cl }); + ({ Bh, Bl } = { Bh: rotrSH(Bh, Bl, 24), Bl: rotrSL(Bh, Bl, 24) }); + ({ h: Ah, l: Al } = blamka(Ah, Al, Bh, Bl)); + ({ Dh, Dl } = { Dh: Dh ^ Ah, Dl: Dl ^ Al }); + ({ Dh, Dl } = { Dh: rotrSH(Dh, Dl, 16), Dl: rotrSL(Dh, Dl, 16) }); + ({ h: Ch, l: Cl } = blamka(Ch, Cl, Dh, Dl)); + ({ Bh, Bl } = { Bh: Bh ^ Ch, Bl: Bl ^ Cl }); + ({ Bh, Bl } = { Bh: rotrBH(Bh, Bl, 63), Bl: rotrBL(Bh, Bl, 63) }); + (A2_BUF[2 * a] = Al), (A2_BUF[2 * a + 1] = Ah); + (A2_BUF[2 * b] = Bl), (A2_BUF[2 * b + 1] = Bh); + (A2_BUF[2 * c] = Cl), (A2_BUF[2 * c + 1] = Ch); + (A2_BUF[2 * d] = Dl), (A2_BUF[2 * d + 1] = Dh); +} +// prettier-ignore +function P(v00, v01, v02, v03, v04, v05, v06, v07, v08, v09, v10, v11, v12, v13, v14, v15) { + G(v00, v04, v08, v12); + G(v01, v05, v09, v13); + G(v02, v06, v10, v14); + G(v03, v07, v11, v15); + G(v00, v05, v10, v15); + G(v01, v06, v11, v12); + G(v02, v07, v08, v13); + G(v03, v04, v09, v14); +} +function block(x, xPos, yPos, outPos, needXor) { + for (let i = 0; i < 256; i++) + A2_BUF[i] = x[xPos + i] ^ x[yPos + i]; + // columns (8) + for (let i = 0; i < 128; i += 16) { + // prettier-ignore + P(i, i + 1, i + 2, i + 3, i + 4, i + 5, i + 6, i + 7, i + 8, i + 9, i + 10, i + 11, i + 12, i + 13, i + 14, i + 15); + } + // rows (8) + for (let i = 0; i < 16; i += 2) { + // prettier-ignore + P(i, i + 1, i + 16, i + 17, i + 32, i + 33, i + 48, i + 49, i + 64, i + 65, i + 80, i + 81, i + 96, i + 97, i + 112, i + 113); + } + if (needXor) + for (let i = 0; i < 256; i++) + x[outPos + i] ^= A2_BUF[i] ^ x[xPos + i] ^ x[yPos + i]; + else + for (let i = 0; i < 256; i++) + x[outPos + i] = A2_BUF[i] ^ x[xPos + i] ^ x[yPos + i]; + clean(A2_BUF); +} +// Variable-Length Hash Function H' +function Hp(A, dkLen) { + const A8 = u8(A); + const T = new Uint32Array(1); + const T8 = u8(T); + T[0] = dkLen; + // Fast path + if (dkLen <= 64) + return blake2b.create({ dkLen }).update(T8).update(A8).digest(); + const out = new Uint8Array(dkLen); + let V = blake2b.create({}).update(T8).update(A8).digest(); + let pos = 0; + // First block + out.set(V.subarray(0, 32)); + pos += 32; + // Rest blocks + for (; dkLen - pos > 64; pos += 32) { + const Vh = blake2b.create({}).update(V); + Vh.digestInto(V); + Vh.destroy(); + out.set(V.subarray(0, 32), pos); + } + // Last block + out.set(blake2b(V, { dkLen: dkLen - pos }), pos); + clean(V, T); + return u32(out); +} +// Used only inside process block! +function indexAlpha(r, s, laneLen, segmentLen, index, randL, sameLane = false) { + // This is ugly, but close enough to reference implementation. + let area; + if (r === 0) { + if (s === 0) + area = index - 1; + else if (sameLane) + area = s * segmentLen + index - 1; + else + area = s * segmentLen + (index == 0 ? -1 : 0); + } + else if (sameLane) + area = laneLen - segmentLen + index - 1; + else + area = laneLen - segmentLen + (index == 0 ? -1 : 0); + const startPos = r !== 0 && s !== ARGON2_SYNC_POINTS - 1 ? (s + 1) * segmentLen : 0; + const rel = area - 1 - mul(area, mul(randL, randL).h).h; + return (startPos + rel) % laneLen; +} +const maxUint32 = Math.pow(2, 32); +function isU32(num) { + return Number.isSafeInteger(num) && num >= 0 && num < maxUint32; +} +function argon2Opts(opts) { + const merged = { + version: 0x13, + dkLen: 32, + maxmem: maxUint32 - 1, + asyncTick: 10, + }; + for (let [k, v] of Object.entries(opts)) + if (v != null) + merged[k] = v; + const { dkLen, p, m, t, version, onProgress } = merged; + if (!isU32(dkLen) || dkLen < 4) + throw new Error('dkLen should be at least 4 bytes'); + if (!isU32(p) || p < 1 || p >= Math.pow(2, 24)) + throw new Error('p should be 1 <= p < 2^24'); + if (!isU32(m)) + throw new Error('m should be 0 <= m < 2^32'); + if (!isU32(t) || t < 1) + throw new Error('t (iterations) should be 1 <= t < 2^32'); + if (onProgress !== undefined && typeof onProgress !== 'function') + throw new Error('progressCb should be function'); + /* + Memory size m MUST be an integer number of kibibytes from 8*p to 2^(32)-1. The actual number of blocks is m', which is m rounded down to the nearest multiple of 4*p. + */ + if (!isU32(m) || m < 8 * p) + throw new Error('memory should be at least 8*p bytes'); + if (version !== 0x10 && version !== 0x13) + throw new Error('unknown version=' + version); + return merged; +} +function argon2Init(password, salt, type, opts) { + password = kdfInputToBytes(password); + salt = kdfInputToBytes(salt); + abytes(password); + abytes(salt); + if (!isU32(password.length)) + throw new Error('password should be less than 4 GB'); + if (!isU32(salt.length) || salt.length < 8) + throw new Error('salt should be at least 8 bytes and less than 4 GB'); + if (!Object.values(AT).includes(type)) + throw new Error('invalid type'); + let { p, dkLen, m, t, version, key, personalization, maxmem, onProgress, asyncTick } = argon2Opts(opts); + // Validation + key = abytesOrZero(key); + personalization = abytesOrZero(personalization); + // H_0 = H^(64)(LE32(p) || LE32(T) || LE32(m) || LE32(t) || + // LE32(v) || LE32(y) || LE32(length(P)) || P || + // LE32(length(S)) || S || LE32(length(K)) || K || + // LE32(length(X)) || X) + const h = blake2b.create({}); + const BUF = new Uint32Array(1); + const BUF8 = u8(BUF); + for (let item of [p, dkLen, m, t, version, type]) { + BUF[0] = item; + h.update(BUF8); + } + for (let i of [password, salt, key, personalization]) { + BUF[0] = i.length; // BUF is u32 array, this is valid + h.update(BUF8).update(i); + } + const H0 = new Uint32Array(18); + const H0_8 = u8(H0); + h.digestInto(H0_8); + // 256 u32 = 1024 (BLOCK_SIZE), fills A2_BUF on processing + // Params + const lanes = p; + // m' = 4 * p * floor (m / 4p) + const mP = 4 * p * Math.floor(m / (ARGON2_SYNC_POINTS * p)); + //q = m' / p columns + const laneLen = Math.floor(mP / p); + const segmentLen = Math.floor(laneLen / ARGON2_SYNC_POINTS); + const memUsed = mP * 256; + if (!isU32(maxmem) || memUsed > maxmem) + throw new Error('mem should be less than 2**32, got: maxmem=' + maxmem + ', memused=' + memUsed); + const B = new Uint32Array(memUsed); + // Fill first blocks + for (let l = 0; l < p; l++) { + const i = 256 * laneLen * l; + // B[i][0] = H'^(1024)(H_0 || LE32(0) || LE32(i)) + H0[17] = l; + H0[16] = 0; + B.set(Hp(H0, 1024), i); + // B[i][1] = H'^(1024)(H_0 || LE32(1) || LE32(i)) + H0[16] = 1; + B.set(Hp(H0, 1024), i + 256); + } + let perBlock = () => { }; + if (onProgress) { + const totalBlock = t * ARGON2_SYNC_POINTS * p * segmentLen; + // Invoke callback if progress changes from 10.01 to 10.02 + // Allows to draw smooth progress bar on up to 8K screen + const callbackPer = Math.max(Math.floor(totalBlock / 10000), 1); + let blockCnt = 0; + perBlock = () => { + blockCnt++; + if (onProgress && (!(blockCnt % callbackPer) || blockCnt === totalBlock)) + onProgress(blockCnt / totalBlock); + }; + } + clean(BUF, H0); + return { type, mP, p, t, version, B, laneLen, lanes, segmentLen, dkLen, perBlock, asyncTick }; +} +function argon2Output(B, p, laneLen, dkLen) { + const B_final = new Uint32Array(256); + for (let l = 0; l < p; l++) + for (let j = 0; j < 256; j++) + B_final[j] ^= B[256 * (laneLen * l + laneLen - 1) + j]; + const res = u8(Hp(B_final, dkLen)); + clean(B_final); + return res; +} +function processBlock(B, address, l, r, s, index, laneLen, segmentLen, lanes, offset, prev, dataIndependent, needXor) { + if (offset % laneLen) + prev = offset - 1; + let randL, randH; + if (dataIndependent) { + let i128 = index % 128; + if (i128 === 0) { + address[256 + 12]++; + block(address, 256, 2 * 256, 0, false); + block(address, 0, 2 * 256, 0, false); + } + randL = address[2 * i128]; + randH = address[2 * i128 + 1]; + } + else { + const T = 256 * prev; + randL = B[T]; + randH = B[T + 1]; + } + // address block + const refLane = r === 0 && s === 0 ? l : randH % lanes; + const refPos = indexAlpha(r, s, laneLen, segmentLen, index, randL, refLane == l); + const refBlock = laneLen * refLane + refPos; + // B[i][j] = G(B[i][j-1], B[l][z]) + block(B, 256 * prev, 256 * refBlock, offset * 256, needXor); +} +function argon2(type, password, salt, opts) { + const { mP, p, t, version, B, laneLen, lanes, segmentLen, dkLen, perBlock } = argon2Init(password, salt, type, opts); + // Pre-loop setup + // [address, input, zero_block] format so we can pass single U32 to block function + const address = new Uint32Array(3 * 256); + address[256 + 6] = mP; + address[256 + 8] = t; + address[256 + 10] = type; + for (let r = 0; r < t; r++) { + const needXor = r !== 0 && version === 0x13; + address[256 + 0] = r; + for (let s = 0; s < ARGON2_SYNC_POINTS; s++) { + address[256 + 4] = s; + const dataIndependent = type == AT.Argon2i || (type == AT.Argon2id && r === 0 && s < 2); + for (let l = 0; l < p; l++) { + address[256 + 2] = l; + address[256 + 12] = 0; + let startPos = 0; + if (r === 0 && s === 0) { + startPos = 2; + if (dataIndependent) { + address[256 + 12]++; + block(address, 256, 2 * 256, 0, false); + block(address, 0, 2 * 256, 0, false); + } + } + // current block postion + let offset = l * laneLen + s * segmentLen + startPos; + // previous block position + let prev = offset % laneLen ? offset - 1 : offset + laneLen - 1; + for (let index = startPos; index < segmentLen; index++, offset++, prev++) { + perBlock(); + processBlock(B, address, l, r, s, index, laneLen, segmentLen, lanes, offset, prev, dataIndependent, needXor); + } + } + } + } + clean(address); + return argon2Output(B, p, laneLen, dkLen); +} +/** argon2d GPU-resistant version. */ +export const argon2d = (password, salt, opts) => argon2(AT.Argond2d, password, salt, opts); +/** argon2i side-channel-resistant version. */ +export const argon2i = (password, salt, opts) => argon2(AT.Argon2i, password, salt, opts); +/** argon2id, combining i+d, the most popular version from RFC 9106 */ +export const argon2id = (password, salt, opts) => argon2(AT.Argon2id, password, salt, opts); +async function argon2Async(type, password, salt, opts) { + const { mP, p, t, version, B, laneLen, lanes, segmentLen, dkLen, perBlock, asyncTick } = argon2Init(password, salt, type, opts); + // Pre-loop setup + // [address, input, zero_block] format so we can pass single U32 to block function + const address = new Uint32Array(3 * 256); + address[256 + 6] = mP; + address[256 + 8] = t; + address[256 + 10] = type; + let ts = Date.now(); + for (let r = 0; r < t; r++) { + const needXor = r !== 0 && version === 0x13; + address[256 + 0] = r; + for (let s = 0; s < ARGON2_SYNC_POINTS; s++) { + address[256 + 4] = s; + const dataIndependent = type == AT.Argon2i || (type == AT.Argon2id && r === 0 && s < 2); + for (let l = 0; l < p; l++) { + address[256 + 2] = l; + address[256 + 12] = 0; + let startPos = 0; + if (r === 0 && s === 0) { + startPos = 2; + if (dataIndependent) { + address[256 + 12]++; + block(address, 256, 2 * 256, 0, false); + block(address, 0, 2 * 256, 0, false); + } + } + // current block postion + let offset = l * laneLen + s * segmentLen + startPos; + // previous block position + let prev = offset % laneLen ? offset - 1 : offset + laneLen - 1; + for (let index = startPos; index < segmentLen; index++, offset++, prev++) { + perBlock(); + processBlock(B, address, l, r, s, index, laneLen, segmentLen, lanes, offset, prev, dataIndependent, needXor); + // Date.now() is not monotonic, so in case if clock goes backwards we return return control too + const diff = Date.now() - ts; + if (!(diff >= 0 && diff < asyncTick)) { + await nextTick(); + ts += diff; + } + } + } + } + } + clean(address); + return argon2Output(B, p, laneLen, dkLen); +} +/** argon2d async GPU-resistant version. */ +export const argon2dAsync = (password, salt, opts) => argon2Async(AT.Argond2d, password, salt, opts); +/** argon2i async side-channel-resistant version. */ +export const argon2iAsync = (password, salt, opts) => argon2Async(AT.Argon2i, password, salt, opts); +/** argon2id async, combining i+d, the most popular version from RFC 9106 */ +export const argon2idAsync = (password, salt, opts) => argon2Async(AT.Argon2id, password, salt, opts); +//# sourceMappingURL=argon2.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/argon2.js.map b/node_modules/@noble/hashes/esm/argon2.js.map new file mode 100644 index 0000000000000000000000000000000000000000..401685694e07efd492200e3414081ab641bd34f1 --- /dev/null +++ b/node_modules/@noble/hashes/esm/argon2.js.map @@ -0,0 +1 @@ +{"version":3,"file":"argon2.js","sourceRoot":"","sources":["../src/argon2.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC3F,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,EAAiB,MAAM,YAAY,CAAC;AAE9F,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAW,CAAC;AAG7D,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAC7B,MAAM,YAAY,GAAG,CAAC,GAAc,EAAE,EAAE;IACtC,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,UAAU,CAAC,EAAE,EAAE,CAAC;IAC9C,OAAO,eAAe,CAAC,GAAG,CAAC,CAAC;AAC9B,CAAC,CAAC;AAEF,kBAAkB;AAClB,SAAS,GAAG,CAAC,CAAS,EAAE,CAAS;IAC/B,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC;IACtB,MAAM,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC;IACpB,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC;IACtB,MAAM,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC;IACpB,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAC7B,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC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AAI,CAAC,CAAC;AACzE,oDAAoD;AACpD,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,QAAkB,EAClB,IAAc,EACd,IAAe,EACM,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACxE,4EAA4E;AAC5E,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,QAAkB,EAClB,IAAc,EACd,IAAe,EACM,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/blake1.d.ts b/node_modules/@noble/hashes/esm/blake1.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..62d576f248d21abd41e95c98bb4b4699de0065c1 --- /dev/null +++ b/node_modules/@noble/hashes/esm/blake1.d.ts @@ -0,0 +1,106 @@ +import { Hash, type CHashO, type Input } from './utils.ts'; +/** Blake1 options. Basically just "salt" */ +export type BlakeOpts = { + salt?: Uint8Array; +}; +declare abstract class BLAKE1> extends Hash { + protected finished: boolean; + protected length: number; + protected pos: number; + protected destroyed: boolean; + protected buffer: Uint8Array; + protected view: DataView; + protected salt: Uint32Array; + abstract compress(view: DataView, offset: number, withLength?: boolean): void; + protected abstract get(): number[]; + protected abstract set(...args: number[]): void; + readonly blockLen: number; + readonly outputLen: number; + private lengthFlag; + private counterLen; + protected constants: Uint32Array; + constructor(blockLen: number, outputLen: number, lengthFlag: number, counterLen: number, saltLen: number, constants: Uint32Array, opts?: BlakeOpts); + update(data: Input): this; + destroy(): void; + _cloneInto(to?: T): T; + clone(): T; + digestInto(out: Uint8Array): void; + digest(): Uint8Array; +} +declare class Blake1_32 extends BLAKE1 { + private v0; + private v1; + private v2; + private v3; + private v4; + private v5; + private v6; + private v7; + constructor(outputLen: number, IV: Uint32Array, lengthFlag: number, opts?: BlakeOpts); + protected get(): [number, number, number, number, number, number, number, number]; + protected set(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number): void; + destroy(): void; + compress(view: DataView, offset: number, withLength?: boolean): void; +} +declare class Blake1_64 extends BLAKE1 { + private v0l; + private v0h; + private v1l; + private v1h; + private v2l; + private v2h; + private v3l; + private v3h; + private v4l; + private v4h; + private v5l; + private v5h; + private v6l; + private v6h; + private v7l; + private v7h; + constructor(outputLen: number, IV: Uint32Array, lengthFlag: number, opts?: BlakeOpts); + protected get(): [ + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number + ]; + protected set(v0l: number, v0h: number, v1l: number, v1h: number, v2l: number, v2h: number, v3l: number, v3h: number, v4l: number, v4h: number, v5l: number, v5h: number, v6l: number, v6h: number, v7l: number, v7h: number): void; + destroy(): void; + compress(view: DataView, offset: number, withLength?: boolean): void; +} +export declare class BLAKE224 extends Blake1_32 { + constructor(opts?: BlakeOpts); +} +export declare class BLAKE256 extends Blake1_32 { + constructor(opts?: BlakeOpts); +} +export declare class BLAKE384 extends Blake1_64 { + constructor(opts?: BlakeOpts); +} +export declare class BLAKE512 extends Blake1_64 { + constructor(opts?: BlakeOpts); +} +/** blake1-224 hash function */ +export declare const blake224: CHashO; +/** blake1-256 hash function */ +export declare const blake256: CHashO; +/** blake1-384 hash function */ +export declare const blake384: CHashO; +/** blake1-512 hash function */ +export declare const blake512: CHashO; +export {}; +//# sourceMappingURL=blake1.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/blake1.d.ts.map b/node_modules/@noble/hashes/esm/blake1.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..93d9bcf87a69bd1c2c2fa6917b19bf570de46f0f --- /dev/null +++ b/node_modules/@noble/hashes/esm/blake1.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"blake1.d.ts","sourceRoot":"","sources":["../src/blake1.ts"],"names":[],"mappings":"AA4BA,OAAO,EAGO,IAAI,EAChB,KAAK,MAAM,EAAE,KA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BAAa,QAAS,SAAQ,SAAS;gBACzB,IAAI,GAAE,SAAc;CAGjC;AACD,qBAAa,QAAS,SAAQ,SAAS;gBACzB,IAAI,GAAE,SAAc;CAGjC;AACD,qBAAa,QAAS,SAAQ,SAAS;gBACzB,IAAI,GAAE,SAAc;CAGjC;AACD,+BAA+B;AAC/B,eAAO,MAAM,QAAQ,EAAE,MAEtB,CAAC;AACF,+BAA+B;AAC/B,eAAO,MAAM,QAAQ,EAAE,MAEtB,CAAC;AACF,+BAA+B;AAC/B,eAAO,MAAM,QAAQ,EAAE,MAEtB,CAAC;AACF,+BAA+B;AAC/B,eAAO,MAAM,QAAQ,EAAE,MAEtB,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/blake1.js b/node_modules/@noble/hashes/esm/blake1.js new file mode 100644 index 0000000000000000000000000000000000000000..549d49dd2df4ac8f29106ceacfacbc4222b0dfa0 --- /dev/null +++ b/node_modules/@noble/hashes/esm/blake1.js @@ -0,0 +1,452 @@ +/** + * Blake1 legacy hash function, one of SHA3 proposals. + * Rarely used. Check out blake2 or blake3 instead. + * https://www.aumasson.jp/blake/blake.pdf + * + * In the best case, there are 0 allocations. + * + * Differences from blake2: + * + * - BE instead of LE + * - Paddings, similar to MD5, RIPEMD, SHA1, SHA2, but: + * - length flag is located before actual length + * - padding block is compressed differently (no lengths) + * Instead of msg[sigma[k]], we have `msg[sigma[k]] ^ constants[sigma[k-1]]` + * (-1 for g1, g2 without -1) + * - Salt is XOR-ed into constants instead of state + * - Salt is XOR-ed with output in `compress` + * - Additional rows (+64 bytes) in SIGMA for new rounds + * - Different round count: + * - 14 / 10 rounds in blake256 / blake2s + * - 16 / 12 rounds in blake512 / blake2b + * - blake512: G1b: rotr 24 -> 25, G2b: rotr 63 -> 11 + * @module + */ +import { BSIGMA, G1s, G2s } from "./_blake.js"; +import { setBigUint64, SHA224_IV, SHA256_IV, SHA384_IV, SHA512_IV } from "./_md.js"; +import * as u64 from "./_u64.js"; +// prettier-ignore +import { abytes, aexists, aoutput, clean, createOptHasher, createView, Hash, toBytes, } from "./utils.js"; +// Empty zero-filled salt +const EMPTY_SALT = /* @__PURE__ */ new Uint32Array(8); +class BLAKE1 extends Hash { + constructor(blockLen, outputLen, lengthFlag, counterLen, saltLen, constants, opts = {}) { + super(); + this.finished = false; + this.length = 0; + this.pos = 0; + this.destroyed = false; + const { salt } = opts; + this.blockLen = blockLen; + this.outputLen = outputLen; + this.lengthFlag = lengthFlag; + this.counterLen = counterLen; + this.buffer = new Uint8Array(blockLen); + this.view = createView(this.buffer); + if (salt) { + let slt = salt; + slt = toBytes(slt); + abytes(slt); + if (slt.length !== 4 * saltLen) + throw new Error('wrong salt length'); + const salt32 = (this.salt = new Uint32Array(saltLen)); + const sv = createView(slt); + this.constants = constants.slice(); + for (let i = 0, offset = 0; i < salt32.length; i++, offset += 4) { + salt32[i] = sv.getUint32(offset, false); + this.constants[i] ^= salt32[i]; + } + } + else { + this.salt = EMPTY_SALT; + this.constants = constants; + } + } + update(data) { + aexists(this); + data = toBytes(data); + abytes(data); + // From _md, but update length before each compress + const { view, buffer, blockLen } = this; + const len = data.length; + let dataView; + for (let pos = 0; pos < len;) { + const take = Math.min(blockLen - this.pos, len - pos); + // Fast path: we have at least one block in input, cast it to view and process + if (take === blockLen) { + if (!dataView) + dataView = createView(data); + for (; blockLen <= len - pos; pos += blockLen) { + this.length += blockLen; + this.compress(dataView, pos); + } + continue; + } + buffer.set(data.subarray(pos, pos + take), this.pos); + this.pos += take; + pos += take; + if (this.pos === blockLen) { + this.length += blockLen; + this.compress(view, 0, true); + this.pos = 0; + } + } + return this; + } + destroy() { + this.destroyed = true; + if (this.salt !== EMPTY_SALT) { + clean(this.salt, this.constants); + } + } + _cloneInto(to) { + to || (to = new this.constructor()); + to.set(...this.get()); + const { buffer, length, finished, destroyed, constants, salt, pos } = this; + to.buffer.set(buffer); + to.constants = constants.slice(); + to.destroyed = destroyed; + to.finished = finished; + to.length = length; + to.pos = pos; + to.salt = salt.slice(); + return to; + } + clone() { + return this._cloneInto(); + } + digestInto(out) { + aexists(this); + aoutput(out, this); + this.finished = true; + // Padding + const { buffer, blockLen, counterLen, lengthFlag, view } = this; + clean(buffer.subarray(this.pos)); // clean buf + const counter = BigInt((this.length + this.pos) * 8); + const counterPos = blockLen - counterLen - 1; + buffer[this.pos] |= 128; // End block flag + this.length += this.pos; // add unwritten length + // Not enough in buffer for length: write what we have. + if (this.pos > counterPos) { + this.compress(view, 0); + clean(buffer); + this.pos = 0; + } + // Difference with md: here we have lengthFlag! + buffer[counterPos] |= lengthFlag; // Length flag + // We always set 8 byte length flag. Because length will overflow significantly sooner. + setBigUint64(view, blockLen - 8, counter, false); + this.compress(view, 0, this.pos !== 0); // don't add length if length is not empty block? + // Write output + clean(buffer); + const v = createView(out); + const state = this.get(); + for (let i = 0; i < this.outputLen / 4; ++i) + v.setUint32(i * 4, state[i]); + } + digest() { + const { buffer, outputLen } = this; + this.digestInto(buffer); + const res = buffer.slice(0, outputLen); + this.destroy(); + return res; + } +} +// Constants +const B64C = /* @__PURE__ */ Uint32Array.from([ + 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, + 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, + 0x9216d5d9, 0x8979fb1b, 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, 0xb8e1afed, 0x6a267e96, + 0xba7c9045, 0xf12c7f99, 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16, 0x636920d8, 0x71574e69, +]); +// first half of C512 +const B32C = B64C.slice(0, 16); +const B256_IV = SHA256_IV.slice(); +const B224_IV = SHA224_IV.slice(); +const B384_IV = SHA384_IV.slice(); +const B512_IV = SHA512_IV.slice(); +function generateTBL256() { + const TBL = []; + for (let i = 0, j = 0; i < 14; i++, j += 16) { + for (let offset = 1; offset < 16; offset += 2) { + TBL.push(B32C[BSIGMA[j + offset]]); + TBL.push(B32C[BSIGMA[j + offset - 1]]); + } + } + return new Uint32Array(TBL); +} +const TBL256 = /* @__PURE__ */ generateTBL256(); // C256[SIGMA[X]] precompute +// Reusable temporary buffer +const BLAKE256_W = /* @__PURE__ */ new Uint32Array(16); +class Blake1_32 extends BLAKE1 { + constructor(outputLen, IV, lengthFlag, opts = {}) { + super(64, outputLen, lengthFlag, 8, 4, B32C, opts); + this.v0 = IV[0] | 0; + this.v1 = IV[1] | 0; + this.v2 = IV[2] | 0; + this.v3 = IV[3] | 0; + this.v4 = IV[4] | 0; + this.v5 = IV[5] | 0; + this.v6 = IV[6] | 0; + this.v7 = IV[7] | 0; + } + get() { + const { v0, v1, v2, v3, v4, v5, v6, v7 } = this; + return [v0, v1, v2, v3, v4, v5, v6, v7]; + } + // prettier-ignore + set(v0, v1, v2, v3, v4, v5, v6, v7) { + this.v0 = v0 | 0; + this.v1 = v1 | 0; + this.v2 = v2 | 0; + this.v3 = v3 | 0; + this.v4 = v4 | 0; + this.v5 = v5 | 0; + this.v6 = v6 | 0; + this.v7 = v7 | 0; + } + destroy() { + super.destroy(); + this.set(0, 0, 0, 0, 0, 0, 0, 0); + } + compress(view, offset, withLength = true) { + for (let i = 0; i < 16; i++, offset += 4) + BLAKE256_W[i] = view.getUint32(offset, false); + // NOTE: we cannot re-use compress from blake2s, since there is additional xor over u256[SIGMA[e]] + let v00 = this.v0 | 0; + let v01 = this.v1 | 0; + let v02 = this.v2 | 0; + let v03 = this.v3 | 0; + let v04 = this.v4 | 0; + let v05 = this.v5 | 0; + let v06 = this.v6 | 0; + let v07 = this.v7 | 0; + let v08 = this.constants[0] | 0; + let v09 = this.constants[1] | 0; + let v10 = this.constants[2] | 0; + let v11 = this.constants[3] | 0; + const { h, l } = u64.fromBig(BigInt(withLength ? this.length * 8 : 0)); + let v12 = (this.constants[4] ^ l) >>> 0; + let v13 = (this.constants[5] ^ l) >>> 0; + let v14 = (this.constants[6] ^ h) >>> 0; + let v15 = (this.constants[7] ^ h) >>> 0; + // prettier-ignore + for (let i = 0, k = 0, j = 0; i < 14; i++) { + ({ a: v00, b: v04, c: v08, d: v12 } = G1s(v00, v04, v08, v12, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v00, b: v04, c: v08, d: v12 } = G2s(v00, v04, v08, v12, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v01, b: v05, c: v09, d: v13 } = G1s(v01, v05, v09, v13, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v01, b: v05, c: v09, d: v13 } = G2s(v01, v05, v09, v13, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v02, b: v06, c: v10, d: v14 } = G1s(v02, v06, v10, v14, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v02, b: v06, c: v10, d: v14 } = G2s(v02, v06, v10, v14, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v03, b: v07, c: v11, d: v15 } = G1s(v03, v07, v11, v15, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v03, b: v07, c: v11, d: v15 } = G2s(v03, v07, v11, v15, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v00, b: v05, c: v10, d: v15 } = G1s(v00, v05, v10, v15, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v00, b: v05, c: v10, d: v15 } = G2s(v00, v05, v10, v15, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v01, b: v06, c: v11, d: v12 } = G1s(v01, v06, v11, v12, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v01, b: v06, c: v11, d: v12 } = G2s(v01, v06, v11, v12, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v02, b: v07, c: v08, d: v13 } = G1s(v02, v07, v08, v13, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v02, b: v07, c: v08, d: v13 } = G2s(v02, v07, v08, v13, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v03, b: v04, c: v09, d: v14 } = G1s(v03, v04, v09, v14, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v03, b: v04, c: v09, d: v14 } = G2s(v03, v04, v09, v14, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + } + this.v0 = (this.v0 ^ v00 ^ v08 ^ this.salt[0]) >>> 0; + this.v1 = (this.v1 ^ v01 ^ v09 ^ this.salt[1]) >>> 0; + this.v2 = (this.v2 ^ v02 ^ v10 ^ this.salt[2]) >>> 0; + this.v3 = (this.v3 ^ v03 ^ v11 ^ this.salt[3]) >>> 0; + this.v4 = (this.v4 ^ v04 ^ v12 ^ this.salt[0]) >>> 0; + this.v5 = (this.v5 ^ v05 ^ v13 ^ this.salt[1]) >>> 0; + this.v6 = (this.v6 ^ v06 ^ v14 ^ this.salt[2]) >>> 0; + this.v7 = (this.v7 ^ v07 ^ v15 ^ this.salt[3]) >>> 0; + clean(BLAKE256_W); + } +} +const BBUF = /* @__PURE__ */ new Uint32Array(32); +const BLAKE512_W = /* @__PURE__ */ new Uint32Array(32); +function generateTBL512() { + const TBL = []; + for (let r = 0, k = 0; r < 16; r++, k += 16) { + for (let offset = 1; offset < 16; offset += 2) { + TBL.push(B64C[BSIGMA[k + offset] * 2 + 0]); + TBL.push(B64C[BSIGMA[k + offset] * 2 + 1]); + TBL.push(B64C[BSIGMA[k + offset - 1] * 2 + 0]); + TBL.push(B64C[BSIGMA[k + offset - 1] * 2 + 1]); + } + } + return new Uint32Array(TBL); +} +const TBL512 = /* @__PURE__ */ generateTBL512(); // C512[SIGMA[X]] precompute +// Mixing function G splitted in two halfs +function G1b(a, b, c, d, msg, k) { + const Xpos = 2 * BSIGMA[k]; + const Xl = msg[Xpos + 1] ^ TBL512[k * 2 + 1], Xh = msg[Xpos] ^ TBL512[k * 2]; // prettier-ignore + let Al = BBUF[2 * a + 1], Ah = BBUF[2 * a]; // prettier-ignore + let Bl = BBUF[2 * b + 1], Bh = BBUF[2 * b]; // prettier-ignore + let Cl = BBUF[2 * c + 1], Ch = BBUF[2 * c]; // prettier-ignore + let Dl = BBUF[2 * d + 1], Dh = BBUF[2 * d]; // prettier-ignore + // v[a] = (v[a] + v[b] + x) | 0; + let ll = u64.add3L(Al, Bl, Xl); + Ah = u64.add3H(ll, Ah, Bh, Xh) >>> 0; + Al = (ll | 0) >>> 0; + // v[d] = rotr(v[d] ^ v[a], 32) + ({ Dh, Dl } = { Dh: Dh ^ Ah, Dl: Dl ^ Al }); + ({ Dh, Dl } = { Dh: u64.rotr32H(Dh, Dl), Dl: u64.rotr32L(Dh, Dl) }); + // v[c] = (v[c] + v[d]) | 0; + ({ h: Ch, l: Cl } = u64.add(Ch, Cl, Dh, Dl)); + // v[b] = rotr(v[b] ^ v[c], 25) + ({ Bh, Bl } = { Bh: Bh ^ Ch, Bl: Bl ^ Cl }); + ({ Bh, Bl } = { Bh: u64.rotrSH(Bh, Bl, 25), Bl: u64.rotrSL(Bh, Bl, 25) }); + (BBUF[2 * a + 1] = Al), (BBUF[2 * a] = Ah); + (BBUF[2 * b + 1] = Bl), (BBUF[2 * b] = Bh); + (BBUF[2 * c + 1] = Cl), (BBUF[2 * c] = Ch); + (BBUF[2 * d + 1] = Dl), (BBUF[2 * d] = Dh); +} +function G2b(a, b, c, d, msg, k) { + const Xpos = 2 * BSIGMA[k]; + const Xl = msg[Xpos + 1] ^ TBL512[k * 2 + 1], Xh = msg[Xpos] ^ TBL512[k * 2]; // prettier-ignore + let Al = BBUF[2 * a + 1], Ah = BBUF[2 * a]; // prettier-ignore + let Bl = BBUF[2 * b + 1], Bh = BBUF[2 * b]; // prettier-ignore + let Cl = BBUF[2 * c + 1], Ch = BBUF[2 * c]; // prettier-ignore + let Dl = BBUF[2 * d + 1], Dh = BBUF[2 * d]; // prettier-ignore + // v[a] = (v[a] + v[b] + x) | 0; + let ll = u64.add3L(Al, Bl, Xl); + Ah = u64.add3H(ll, Ah, Bh, Xh); + Al = ll | 0; + // v[d] = rotr(v[d] ^ v[a], 16) + ({ Dh, Dl } = { Dh: Dh ^ Ah, Dl: Dl ^ Al }); + ({ Dh, Dl } = { Dh: u64.rotrSH(Dh, Dl, 16), Dl: u64.rotrSL(Dh, Dl, 16) }); + // v[c] = (v[c] + v[d]) | 0; + ({ h: Ch, l: Cl } = u64.add(Ch, Cl, Dh, Dl)); + // v[b] = rotr(v[b] ^ v[c], 11) + ({ Bh, Bl } = { Bh: Bh ^ Ch, Bl: Bl ^ Cl }); + ({ Bh, Bl } = { Bh: u64.rotrSH(Bh, Bl, 11), Bl: u64.rotrSL(Bh, Bl, 11) }); + (BBUF[2 * a + 1] = Al), (BBUF[2 * a] = Ah); + (BBUF[2 * b + 1] = Bl), (BBUF[2 * b] = Bh); + (BBUF[2 * c + 1] = Cl), (BBUF[2 * c] = Ch); + (BBUF[2 * d + 1] = Dl), (BBUF[2 * d] = Dh); +} +class Blake1_64 extends BLAKE1 { + constructor(outputLen, IV, lengthFlag, opts = {}) { + super(128, outputLen, lengthFlag, 16, 8, B64C, opts); + this.v0l = IV[0] | 0; + this.v0h = IV[1] | 0; + this.v1l = IV[2] | 0; + this.v1h = IV[3] | 0; + this.v2l = IV[4] | 0; + this.v2h = IV[5] | 0; + this.v3l = IV[6] | 0; + this.v3h = IV[7] | 0; + this.v4l = IV[8] | 0; + this.v4h = IV[9] | 0; + this.v5l = IV[10] | 0; + this.v5h = IV[11] | 0; + this.v6l = IV[12] | 0; + this.v6h = IV[13] | 0; + this.v7l = IV[14] | 0; + this.v7h = IV[15] | 0; + } + // prettier-ignore + get() { + let { v0l, v0h, v1l, v1h, v2l, v2h, v3l, v3h, v4l, v4h, v5l, v5h, v6l, v6h, v7l, v7h } = this; + return [v0l, v0h, v1l, v1h, v2l, v2h, v3l, v3h, v4l, v4h, v5l, v5h, v6l, v6h, v7l, v7h]; + } + // prettier-ignore + set(v0l, v0h, v1l, v1h, v2l, v2h, v3l, v3h, v4l, v4h, v5l, v5h, v6l, v6h, v7l, v7h) { + this.v0l = v0l | 0; + this.v0h = v0h | 0; + this.v1l = v1l | 0; + this.v1h = v1h | 0; + this.v2l = v2l | 0; + this.v2h = v2h | 0; + this.v3l = v3l | 0; + this.v3h = v3h | 0; + this.v4l = v4l | 0; + this.v4h = v4h | 0; + this.v5l = v5l | 0; + this.v5h = v5h | 0; + this.v6l = v6l | 0; + this.v6h = v6h | 0; + this.v7l = v7l | 0; + this.v7h = v7h | 0; + } + destroy() { + super.destroy(); + this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + } + compress(view, offset, withLength = true) { + for (let i = 0; i < 32; i++, offset += 4) + BLAKE512_W[i] = view.getUint32(offset, false); + this.get().forEach((v, i) => (BBUF[i] = v)); // First half from state. + BBUF.set(this.constants.subarray(0, 16), 16); + if (withLength) { + const { h, l } = u64.fromBig(BigInt(this.length * 8)); + BBUF[24] = (BBUF[24] ^ h) >>> 0; + BBUF[25] = (BBUF[25] ^ l) >>> 0; + BBUF[26] = (BBUF[26] ^ h) >>> 0; + BBUF[27] = (BBUF[27] ^ l) >>> 0; + } + for (let i = 0, k = 0; i < 16; i++) { + G1b(0, 4, 8, 12, BLAKE512_W, k++); + G2b(0, 4, 8, 12, BLAKE512_W, k++); + G1b(1, 5, 9, 13, BLAKE512_W, k++); + G2b(1, 5, 9, 13, BLAKE512_W, k++); + G1b(2, 6, 10, 14, BLAKE512_W, k++); + G2b(2, 6, 10, 14, BLAKE512_W, k++); + G1b(3, 7, 11, 15, BLAKE512_W, k++); + G2b(3, 7, 11, 15, BLAKE512_W, k++); + G1b(0, 5, 10, 15, BLAKE512_W, k++); + G2b(0, 5, 10, 15, BLAKE512_W, k++); + G1b(1, 6, 11, 12, BLAKE512_W, k++); + G2b(1, 6, 11, 12, BLAKE512_W, k++); + G1b(2, 7, 8, 13, BLAKE512_W, k++); + G2b(2, 7, 8, 13, BLAKE512_W, k++); + G1b(3, 4, 9, 14, BLAKE512_W, k++); + G2b(3, 4, 9, 14, BLAKE512_W, k++); + } + this.v0l ^= BBUF[0] ^ BBUF[16] ^ this.salt[0]; + this.v0h ^= BBUF[1] ^ BBUF[17] ^ this.salt[1]; + this.v1l ^= BBUF[2] ^ BBUF[18] ^ this.salt[2]; + this.v1h ^= BBUF[3] ^ BBUF[19] ^ this.salt[3]; + this.v2l ^= BBUF[4] ^ BBUF[20] ^ this.salt[4]; + this.v2h ^= BBUF[5] ^ BBUF[21] ^ this.salt[5]; + this.v3l ^= BBUF[6] ^ BBUF[22] ^ this.salt[6]; + this.v3h ^= BBUF[7] ^ BBUF[23] ^ this.salt[7]; + this.v4l ^= BBUF[8] ^ BBUF[24] ^ this.salt[0]; + this.v4h ^= BBUF[9] ^ BBUF[25] ^ this.salt[1]; + this.v5l ^= BBUF[10] ^ BBUF[26] ^ this.salt[2]; + this.v5h ^= BBUF[11] ^ BBUF[27] ^ this.salt[3]; + this.v6l ^= BBUF[12] ^ BBUF[28] ^ this.salt[4]; + this.v6h ^= BBUF[13] ^ BBUF[29] ^ this.salt[5]; + this.v7l ^= BBUF[14] ^ BBUF[30] ^ this.salt[6]; + this.v7h ^= BBUF[15] ^ BBUF[31] ^ this.salt[7]; + clean(BBUF, BLAKE512_W); + } +} +export class BLAKE224 extends Blake1_32 { + constructor(opts = {}) { + super(28, B224_IV, 0, opts); + } +} +export class BLAKE256 extends Blake1_32 { + constructor(opts = {}) { + super(32, B256_IV, 1, opts); + } +} +export class BLAKE384 extends Blake1_64 { + constructor(opts = {}) { + super(48, B384_IV, 0, opts); + } +} +export class BLAKE512 extends Blake1_64 { + constructor(opts = {}) { + super(64, B512_IV, 1, opts); + } +} +/** blake1-224 hash function */ +export const blake224 = /* @__PURE__ */ createOptHasher((opts) => new BLAKE224(opts)); +/** blake1-256 hash function */ +export const blake256 = /* @__PURE__ */ createOptHasher((opts) => new BLAKE256(opts)); +/** blake1-384 hash function */ +export const blake384 = /* @__PURE__ */ createOptHasher((opts) => new BLAKE384(opts)); +/** blake1-512 hash function */ +export const blake512 = /* @__PURE__ */ createOptHasher((opts) => new BLAKE512(opts)); +//# sourceMappingURL=blake1.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/blake1.js.map b/node_modules/@noble/hashes/esm/blake1.js.map new file mode 100644 index 0000000000000000000000000000000000000000..65325b8c9b39d8e82e1514090c4a5654b8da742a --- /dev/null +++ b/node_modules/@noble/hashes/esm/blake1.js.map @@ -0,0 +1 @@ +{"version":3,"file":"blake1.js","sourceRoot":"","sources":["../src/blake1.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACpF,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AACjC,kBAAkB;AAClB,OAAO,EACL,MAAM,EAAE,OAAO,EAAE,OAAO,EACxB,KAAK,EAAE,eAAe,EACtB,UAAU,EAAE,IAAI,EAAE,OAAO,GAE1B,MAAM,YAAY,CAAC;AAOpB,yBAAyB;AACzB,MAAM,UAAU,GAAG,eAAe,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;AAEtD,MAAe,MAA4B,SAAQ,IAAO;IAmBxD,YACE,QAAgB,EAChB,SAAiB,EACjB,UAAkB,EAClB,UAAkB,EAClB,OAAe,EACf,SAAsB,EACtB,OAAkB,EAAE;QAEpB,KAAK,EAAE,CAAC;QA3BA,aAAQ,GAAG,KAAK,CAAC;QACjB,WAAM,GAAG,CAAC,CAAC;QACX,QAAG,GAAG,CAAC,CAAC;QACR,cAAS,GAAG,KAAK,CAAC;QAyB1B,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W,eAAe,CAAC,eAAe,CAC7D,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAC7B,CAAC;AACF,+BAA+B;AAC/B,MAAM,CAAC,MAAM,QAAQ,GAAW,eAAe,CAAC,eAAe,CAC7D,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAC7B,CAAC;AACF,+BAA+B;AAC/B,MAAM,CAAC,MAAM,QAAQ,GAAW,eAAe,CAAC,eAAe,CAC7D,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAC7B,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/blake2.d.ts b/node_modules/@noble/hashes/esm/blake2.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ea6ae419f21cb3526cbb335fba7044a39542b975 --- /dev/null +++ b/node_modules/@noble/hashes/esm/blake2.d.ts @@ -0,0 +1,116 @@ +import { Hash, type CHashO, type Input } from './utils.ts'; +/** Blake hash options. dkLen is output length. key is used in MAC mode. salt is used in KDF mode. */ +export type Blake2Opts = { + dkLen?: number; + key?: Input; + salt?: Input; + personalization?: Input; +}; +/** Class, from which others are subclassed. */ +export declare abstract class BLAKE2> extends Hash { + protected abstract compress(msg: Uint32Array, offset: number, isLast: boolean): void; + protected abstract get(): number[]; + protected abstract set(...args: number[]): void; + abstract destroy(): void; + protected buffer: Uint8Array; + protected buffer32: Uint32Array; + protected finished: boolean; + protected destroyed: boolean; + protected length: number; + protected pos: number; + readonly blockLen: number; + readonly outputLen: number; + constructor(blockLen: number, outputLen: number); + update(data: Input): this; + digestInto(out: Uint8Array): void; + digest(): Uint8Array; + _cloneInto(to?: T): T; + clone(): T; +} +export declare class BLAKE2b extends BLAKE2 { + private v0l; + private v0h; + private v1l; + private v1h; + private v2l; + private v2h; + private v3l; + private v3h; + private v4l; + private v4h; + private v5l; + private v5h; + private v6l; + private v6h; + private v7l; + private v7h; + constructor(opts?: Blake2Opts); + protected get(): [ + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number + ]; + protected set(v0l: number, v0h: number, v1l: number, v1h: number, v2l: number, v2h: number, v3l: number, v3h: number, v4l: number, v4h: number, v5l: number, v5h: number, v6l: number, v6h: number, v7l: number, v7h: number): void; + protected compress(msg: Uint32Array, offset: number, isLast: boolean): void; + destroy(): void; +} +/** + * Blake2b hash function. 64-bit. 1.5x slower than blake2s in JS. + * @param msg - message that would be hashed + * @param opts - dkLen output length, key for MAC mode, salt, personalization + */ +export declare const blake2b: CHashO; +export type Num16 = { + v0: number; + v1: number; + v2: number; + v3: number; + v4: number; + v5: number; + v6: number; + v7: number; + v8: number; + v9: number; + v10: number; + v11: number; + v12: number; + v13: number; + v14: number; + v15: number; +}; +export declare function compress(s: Uint8Array, offset: number, msg: Uint32Array, rounds: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number): Num16; +export declare class BLAKE2s extends BLAKE2 { + private v0; + private v1; + private v2; + private v3; + private v4; + private v5; + private v6; + private v7; + constructor(opts?: Blake2Opts); + protected get(): [number, number, number, number, number, number, number, number]; + protected set(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number): void; + protected compress(msg: Uint32Array, offset: number, isLast: boolean): void; + destroy(): void; +} +/** + * Blake2s hash function. Focuses on 8-bit to 32-bit platforms. 1.5x faster than blake2b in JS. + * @param msg - message that would be hashed + * @param opts - dkLen output length, key for MAC mode, salt, personalization + */ +export declare const blake2s: CHashO; +//# sourceMappingURL=blake2.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/blake2.d.ts.map b/node_modules/@noble/hashes/esm/blake2.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..2d531225f1b08f69d93d63bee6a6a1e13864840e --- /dev/null +++ b/node_modules/@noble/hashes/esm/blake2.d.ts.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,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GACnG,KAAK,CAsBP;AAGD,qBAAa,OAAQ,SAAQ,MAAM,CAAC,OAAO,CAAC;IAE1C,OAAO,CAAC,EAAE,CAAiB;IAC3B,OAAO,CAAC,EAAE,CAAiB;IAC3B,OAAO,CAAC,EAAE,CAAiB;IAC3B,OAAO,CAAC,EAAE,CAAiB;IAC3B,OAAO,CAAC,EAAE,CAAiB;IAC3B,OAAO,CAAC,EAAE,CAAiB;IAC3B,OAAO,CAAC,EAAE,CAAiB;IAC3B,OAAO,CAAC,EAAE,CAAiB;gBAEf,IAAI,GAAE,UAAe;IA+BjC,SAAS,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;IAKjF,SAAS,CAAC,GAAG,CACX,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAC7F,IAAI;IAUP,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI;IAkB3E,OAAO,IAAI,IAAI;CAKhB;AAED;;;;GAIG;AACH,eAAO,MAAM,OAAO,EAAE,MAErB,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/blake2.js b/node_modules/@noble/hashes/esm/blake2.js new file mode 100644 index 0000000000000000000000000000000000000000..69b3c415af199ed41283dc2e8d0e764181deeb6c --- /dev/null +++ b/node_modules/@noble/hashes/esm/blake2.js @@ -0,0 +1,413 @@ +/** + * blake2b (64-bit) & blake2s (8 to 32-bit) hash functions. + * b could have been faster, but there is no fast u64 in js, so s is 1.5x faster. + * @module + */ +import { BSIGMA, G1s, G2s } from "./_blake.js"; +import { SHA256_IV } from "./_md.js"; +import * as u64 from "./_u64.js"; +// prettier-ignore +import { abytes, aexists, anumber, aoutput, clean, createOptHasher, Hash, swap32IfBE, swap8IfBE, toBytes, u32 } from "./utils.js"; +// Same as SHA512_IV, but swapped endianness: LE instead of BE. iv[1] is iv[0], etc. +const B2B_IV = /* @__PURE__ */ Uint32Array.from([ + 0xf3bcc908, 0x6a09e667, 0x84caa73b, 0xbb67ae85, 0xfe94f82b, 0x3c6ef372, 0x5f1d36f1, 0xa54ff53a, + 0xade682d1, 0x510e527f, 0x2b3e6c1f, 0x9b05688c, 0xfb41bd6b, 0x1f83d9ab, 0x137e2179, 0x5be0cd19, +]); +// Temporary buffer +const BBUF = /* @__PURE__ */ new Uint32Array(32); +// Mixing function G splitted in two halfs +function G1b(a, b, c, d, msg, x) { + // NOTE: V is LE here + const Xl = msg[x], Xh = msg[x + 1]; // prettier-ignore + let Al = BBUF[2 * a], Ah = BBUF[2 * a + 1]; // prettier-ignore + let Bl = BBUF[2 * b], Bh = BBUF[2 * b + 1]; // prettier-ignore + let Cl = BBUF[2 * c], Ch = BBUF[2 * c + 1]; // prettier-ignore + let Dl = BBUF[2 * d], Dh = BBUF[2 * d + 1]; // prettier-ignore + // v[a] = (v[a] + v[b] + x) | 0; + let ll = u64.add3L(Al, Bl, Xl); + Ah = u64.add3H(ll, Ah, Bh, Xh); + Al = ll | 0; + // v[d] = rotr(v[d] ^ v[a], 32) + ({ Dh, Dl } = { Dh: Dh ^ Ah, Dl: Dl ^ Al }); + ({ Dh, Dl } = { Dh: u64.rotr32H(Dh, Dl), Dl: u64.rotr32L(Dh, Dl) }); + // v[c] = (v[c] + v[d]) | 0; + ({ h: Ch, l: Cl } = u64.add(Ch, Cl, Dh, Dl)); + // v[b] = rotr(v[b] ^ v[c], 24) + ({ Bh, Bl } = { Bh: Bh ^ Ch, Bl: Bl ^ Cl }); + ({ Bh, Bl } = { Bh: u64.rotrSH(Bh, Bl, 24), Bl: u64.rotrSL(Bh, Bl, 24) }); + (BBUF[2 * a] = Al), (BBUF[2 * a + 1] = Ah); + (BBUF[2 * b] = Bl), (BBUF[2 * b + 1] = Bh); + (BBUF[2 * c] = Cl), (BBUF[2 * c + 1] = Ch); + (BBUF[2 * d] = Dl), (BBUF[2 * d + 1] = Dh); +} +function G2b(a, b, c, d, msg, x) { + // NOTE: V is LE here + const Xl = msg[x], Xh = msg[x + 1]; // prettier-ignore + let Al = BBUF[2 * a], Ah = BBUF[2 * a + 1]; // prettier-ignore + let Bl = BBUF[2 * b], Bh = BBUF[2 * b + 1]; // prettier-ignore + let Cl = BBUF[2 * c], Ch = BBUF[2 * c + 1]; // prettier-ignore + let Dl = BBUF[2 * d], Dh = BBUF[2 * d + 1]; // prettier-ignore + // v[a] = (v[a] + v[b] + x) | 0; + let ll = u64.add3L(Al, Bl, Xl); + Ah = u64.add3H(ll, Ah, Bh, Xh); + Al = ll | 0; + // v[d] = rotr(v[d] ^ v[a], 16) + ({ Dh, Dl } = { Dh: Dh ^ Ah, Dl: Dl ^ Al }); + ({ Dh, Dl } = { Dh: u64.rotrSH(Dh, Dl, 16), Dl: u64.rotrSL(Dh, Dl, 16) }); + // v[c] = (v[c] + v[d]) | 0; + ({ h: Ch, l: Cl } = u64.add(Ch, Cl, Dh, Dl)); + // v[b] = rotr(v[b] ^ v[c], 63) + ({ Bh, Bl } = { Bh: Bh ^ Ch, Bl: Bl ^ Cl }); + ({ Bh, Bl } = { Bh: u64.rotrBH(Bh, Bl, 63), Bl: u64.rotrBL(Bh, Bl, 63) }); + (BBUF[2 * a] = Al), (BBUF[2 * a + 1] = Ah); + (BBUF[2 * b] = Bl), (BBUF[2 * b + 1] = Bh); + (BBUF[2 * c] = Cl), (BBUF[2 * c + 1] = Ch); + (BBUF[2 * d] = Dl), (BBUF[2 * d + 1] = Dh); +} +function checkBlake2Opts(outputLen, opts = {}, keyLen, saltLen, persLen) { + anumber(keyLen); + if (outputLen < 0 || outputLen > keyLen) + throw new Error('outputLen bigger than keyLen'); + const { key, salt, personalization } = opts; + if (key !== undefined && (key.length < 1 || key.length > keyLen)) + throw new Error('key length must be undefined or 1..' + keyLen); + if (salt !== undefined && salt.length !== saltLen) + throw new Error('salt must be undefined or ' + saltLen); + if (personalization !== undefined && personalization.length !== persLen) + throw new Error('personalization must be undefined or ' + persLen); +} +/** Class, from which others are subclassed. */ +export class BLAKE2 extends Hash { + constructor(blockLen, outputLen) { + super(); + this.finished = false; + this.destroyed = false; + this.length = 0; + this.pos = 0; + anumber(blockLen); + anumber(outputLen); + this.blockLen = blockLen; + this.outputLen = outputLen; + this.buffer = new Uint8Array(blockLen); + this.buffer32 = u32(this.buffer); + } + update(data) { + aexists(this); + data = toBytes(data); + abytes(data); + // Main difference with other hashes: there is flag for last block, + // so we cannot process current block before we know that there + // is the next one. This significantly complicates logic and reduces ability + // to do zero-copy processing + const { blockLen, buffer, buffer32 } = this; + const len = data.length; + const offset = data.byteOffset; + const buf = data.buffer; + for (let pos = 0; pos < len;) { + // If buffer is full and we still have input (don't process last block, same as blake2s) + if (this.pos === blockLen) { + swap32IfBE(buffer32); + this.compress(buffer32, 0, false); + swap32IfBE(buffer32); + this.pos = 0; + } + const take = Math.min(blockLen - this.pos, len - pos); + const dataOffset = offset + pos; + // full block && aligned to 4 bytes && not last in input + if (take === blockLen && !(dataOffset % 4) && pos + take < len) { + const data32 = new Uint32Array(buf, dataOffset, Math.floor((len - pos) / 4)); + swap32IfBE(data32); + for (let pos32 = 0; pos + blockLen < len; pos32 += buffer32.length, pos += blockLen) { + this.length += blockLen; + this.compress(data32, pos32, false); + } + swap32IfBE(data32); + continue; + } + buffer.set(data.subarray(pos, pos + take), this.pos); + this.pos += take; + this.length += take; + pos += take; + } + return this; + } + digestInto(out) { + aexists(this); + aoutput(out, this); + const { pos, buffer32 } = this; + this.finished = true; + // Padding + clean(this.buffer.subarray(pos)); + swap32IfBE(buffer32); + this.compress(buffer32, 0, true); + swap32IfBE(buffer32); + const out32 = u32(out); + this.get().forEach((v, i) => (out32[i] = swap8IfBE(v))); + } + digest() { + const { buffer, outputLen } = this; + this.digestInto(buffer); + const res = buffer.slice(0, outputLen); + this.destroy(); + return res; + } + _cloneInto(to) { + const { buffer, length, finished, destroyed, outputLen, pos } = this; + to || (to = new this.constructor({ dkLen: outputLen })); + to.set(...this.get()); + to.buffer.set(buffer); + to.destroyed = destroyed; + to.finished = finished; + to.length = length; + to.pos = pos; + // @ts-ignore + to.outputLen = outputLen; + return to; + } + clone() { + return this._cloneInto(); + } +} +export class BLAKE2b extends BLAKE2 { + constructor(opts = {}) { + const olen = opts.dkLen === undefined ? 64 : opts.dkLen; + super(128, olen); + // Same as SHA-512, but LE + this.v0l = B2B_IV[0] | 0; + this.v0h = B2B_IV[1] | 0; + this.v1l = B2B_IV[2] | 0; + this.v1h = B2B_IV[3] | 0; + this.v2l = B2B_IV[4] | 0; + this.v2h = B2B_IV[5] | 0; + this.v3l = B2B_IV[6] | 0; + this.v3h = B2B_IV[7] | 0; + this.v4l = B2B_IV[8] | 0; + this.v4h = B2B_IV[9] | 0; + this.v5l = B2B_IV[10] | 0; + this.v5h = B2B_IV[11] | 0; + this.v6l = B2B_IV[12] | 0; + this.v6h = B2B_IV[13] | 0; + this.v7l = B2B_IV[14] | 0; + this.v7h = B2B_IV[15] | 0; + checkBlake2Opts(olen, opts, 64, 16, 16); + let { key, personalization, salt } = opts; + let keyLength = 0; + if (key !== undefined) { + key = toBytes(key); + keyLength = key.length; + } + this.v0l ^= this.outputLen | (keyLength << 8) | (0x01 << 16) | (0x01 << 24); + if (salt !== undefined) { + salt = toBytes(salt); + const slt = u32(salt); + this.v4l ^= swap8IfBE(slt[0]); + this.v4h ^= swap8IfBE(slt[1]); + this.v5l ^= swap8IfBE(slt[2]); + this.v5h ^= swap8IfBE(slt[3]); + } + if (personalization !== undefined) { + personalization = toBytes(personalization); + const pers = u32(personalization); + this.v6l ^= swap8IfBE(pers[0]); + this.v6h ^= swap8IfBE(pers[1]); + this.v7l ^= swap8IfBE(pers[2]); + this.v7h ^= swap8IfBE(pers[3]); + } + if (key !== undefined) { + // Pad to blockLen and update + const tmp = new Uint8Array(this.blockLen); + tmp.set(key); + this.update(tmp); + } + } + // prettier-ignore + get() { + let { v0l, v0h, v1l, v1h, v2l, v2h, v3l, v3h, v4l, v4h, v5l, v5h, v6l, v6h, v7l, v7h } = this; + return [v0l, v0h, v1l, v1h, v2l, v2h, v3l, v3h, v4l, v4h, v5l, v5h, v6l, v6h, v7l, v7h]; + } + // prettier-ignore + set(v0l, v0h, v1l, v1h, v2l, v2h, v3l, v3h, v4l, v4h, v5l, v5h, v6l, v6h, v7l, v7h) { + this.v0l = v0l | 0; + this.v0h = v0h | 0; + this.v1l = v1l | 0; + this.v1h = v1h | 0; + this.v2l = v2l | 0; + this.v2h = v2h | 0; + this.v3l = v3l | 0; + this.v3h = v3h | 0; + this.v4l = v4l | 0; + this.v4h = v4h | 0; + this.v5l = v5l | 0; + this.v5h = v5h | 0; + this.v6l = v6l | 0; + this.v6h = v6h | 0; + this.v7l = v7l | 0; + this.v7h = v7h | 0; + } + compress(msg, offset, isLast) { + this.get().forEach((v, i) => (BBUF[i] = v)); // First half from state. + BBUF.set(B2B_IV, 16); // Second half from IV. + let { h, l } = u64.fromBig(BigInt(this.length)); + BBUF[24] = B2B_IV[8] ^ l; // Low word of the offset. + BBUF[25] = B2B_IV[9] ^ h; // High word. + // Invert all bits for last block + if (isLast) { + BBUF[28] = ~BBUF[28]; + BBUF[29] = ~BBUF[29]; + } + let j = 0; + const s = BSIGMA; + for (let i = 0; i < 12; i++) { + G1b(0, 4, 8, 12, msg, offset + 2 * s[j++]); + G2b(0, 4, 8, 12, msg, offset + 2 * s[j++]); + G1b(1, 5, 9, 13, msg, offset + 2 * s[j++]); + G2b(1, 5, 9, 13, msg, offset + 2 * s[j++]); + G1b(2, 6, 10, 14, msg, offset + 2 * s[j++]); + G2b(2, 6, 10, 14, msg, offset + 2 * s[j++]); + G1b(3, 7, 11, 15, msg, offset + 2 * s[j++]); + G2b(3, 7, 11, 15, msg, offset + 2 * s[j++]); + G1b(0, 5, 10, 15, msg, offset + 2 * s[j++]); + G2b(0, 5, 10, 15, msg, offset + 2 * s[j++]); + G1b(1, 6, 11, 12, msg, offset + 2 * s[j++]); + G2b(1, 6, 11, 12, msg, offset + 2 * s[j++]); + G1b(2, 7, 8, 13, msg, offset + 2 * s[j++]); + G2b(2, 7, 8, 13, msg, offset + 2 * s[j++]); + G1b(3, 4, 9, 14, msg, offset + 2 * s[j++]); + G2b(3, 4, 9, 14, msg, offset + 2 * s[j++]); + } + this.v0l ^= BBUF[0] ^ BBUF[16]; + this.v0h ^= BBUF[1] ^ BBUF[17]; + this.v1l ^= BBUF[2] ^ BBUF[18]; + this.v1h ^= BBUF[3] ^ BBUF[19]; + this.v2l ^= BBUF[4] ^ BBUF[20]; + this.v2h ^= BBUF[5] ^ BBUF[21]; + this.v3l ^= BBUF[6] ^ BBUF[22]; + this.v3h ^= BBUF[7] ^ BBUF[23]; + this.v4l ^= BBUF[8] ^ BBUF[24]; + this.v4h ^= BBUF[9] ^ BBUF[25]; + this.v5l ^= BBUF[10] ^ BBUF[26]; + this.v5h ^= BBUF[11] ^ BBUF[27]; + this.v6l ^= BBUF[12] ^ BBUF[28]; + this.v6h ^= BBUF[13] ^ BBUF[29]; + this.v7l ^= BBUF[14] ^ BBUF[30]; + this.v7h ^= BBUF[15] ^ BBUF[31]; + clean(BBUF); + } + destroy() { + this.destroyed = true; + clean(this.buffer32); + this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + } +} +/** + * Blake2b hash function. 64-bit. 1.5x slower than blake2s in JS. + * @param msg - message that would be hashed + * @param opts - dkLen output length, key for MAC mode, salt, personalization + */ +export const blake2b = /* @__PURE__ */ createOptHasher((opts) => new BLAKE2b(opts)); +// prettier-ignore +export function compress(s, offset, msg, rounds, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) { + let j = 0; + for (let i = 0; i < rounds; i++) { + ({ a: v0, b: v4, c: v8, d: v12 } = G1s(v0, v4, v8, v12, msg[offset + s[j++]])); + ({ a: v0, b: v4, c: v8, d: v12 } = G2s(v0, v4, v8, v12, msg[offset + s[j++]])); + ({ a: v1, b: v5, c: v9, d: v13 } = G1s(v1, v5, v9, v13, msg[offset + s[j++]])); + ({ a: v1, b: v5, c: v9, d: v13 } = G2s(v1, v5, v9, v13, msg[offset + s[j++]])); + ({ a: v2, b: v6, c: v10, d: v14 } = G1s(v2, v6, v10, v14, msg[offset + s[j++]])); + ({ a: v2, b: v6, c: v10, d: v14 } = G2s(v2, v6, v10, v14, msg[offset + s[j++]])); + ({ a: v3, b: v7, c: v11, d: v15 } = G1s(v3, v7, v11, v15, msg[offset + s[j++]])); + ({ a: v3, b: v7, c: v11, d: v15 } = G2s(v3, v7, v11, v15, msg[offset + s[j++]])); + ({ a: v0, b: v5, c: v10, d: v15 } = G1s(v0, v5, v10, v15, msg[offset + s[j++]])); + ({ a: v0, b: v5, c: v10, d: v15 } = G2s(v0, v5, v10, v15, msg[offset + s[j++]])); + ({ a: v1, b: v6, c: v11, d: v12 } = G1s(v1, v6, v11, v12, msg[offset + s[j++]])); + ({ a: v1, b: v6, c: v11, d: v12 } = G2s(v1, v6, v11, v12, msg[offset + s[j++]])); + ({ a: v2, b: v7, c: v8, d: v13 } = G1s(v2, v7, v8, v13, msg[offset + s[j++]])); + ({ a: v2, b: v7, c: v8, d: v13 } = G2s(v2, v7, v8, v13, msg[offset + s[j++]])); + ({ a: v3, b: v4, c: v9, d: v14 } = G1s(v3, v4, v9, v14, msg[offset + s[j++]])); + ({ a: v3, b: v4, c: v9, d: v14 } = G2s(v3, v4, v9, v14, msg[offset + s[j++]])); + } + return { v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15 }; +} +const B2S_IV = SHA256_IV; +export class BLAKE2s extends BLAKE2 { + constructor(opts = {}) { + const olen = opts.dkLen === undefined ? 32 : opts.dkLen; + super(64, olen); + // Internal state, same as SHA-256 + this.v0 = B2S_IV[0] | 0; + this.v1 = B2S_IV[1] | 0; + this.v2 = B2S_IV[2] | 0; + this.v3 = B2S_IV[3] | 0; + this.v4 = B2S_IV[4] | 0; + this.v5 = B2S_IV[5] | 0; + this.v6 = B2S_IV[6] | 0; + this.v7 = B2S_IV[7] | 0; + checkBlake2Opts(olen, opts, 32, 8, 8); + let { key, personalization, salt } = opts; + let keyLength = 0; + if (key !== undefined) { + key = toBytes(key); + keyLength = key.length; + } + this.v0 ^= this.outputLen | (keyLength << 8) | (0x01 << 16) | (0x01 << 24); + if (salt !== undefined) { + salt = toBytes(salt); + const slt = u32(salt); + this.v4 ^= swap8IfBE(slt[0]); + this.v5 ^= swap8IfBE(slt[1]); + } + if (personalization !== undefined) { + personalization = toBytes(personalization); + const pers = u32(personalization); + this.v6 ^= swap8IfBE(pers[0]); + this.v7 ^= swap8IfBE(pers[1]); + } + if (key !== undefined) { + // Pad to blockLen and update + abytes(key); + const tmp = new Uint8Array(this.blockLen); + tmp.set(key); + this.update(tmp); + } + } + get() { + const { v0, v1, v2, v3, v4, v5, v6, v7 } = this; + return [v0, v1, v2, v3, v4, v5, v6, v7]; + } + // prettier-ignore + set(v0, v1, v2, v3, v4, v5, v6, v7) { + this.v0 = v0 | 0; + this.v1 = v1 | 0; + this.v2 = v2 | 0; + this.v3 = v3 | 0; + this.v4 = v4 | 0; + this.v5 = v5 | 0; + this.v6 = v6 | 0; + this.v7 = v7 | 0; + } + compress(msg, offset, isLast) { + const { h, l } = u64.fromBig(BigInt(this.length)); + // prettier-ignore + const { v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15 } = compress(BSIGMA, offset, msg, 10, this.v0, this.v1, this.v2, this.v3, this.v4, this.v5, this.v6, this.v7, B2S_IV[0], B2S_IV[1], B2S_IV[2], B2S_IV[3], l ^ B2S_IV[4], h ^ B2S_IV[5], isLast ? ~B2S_IV[6] : B2S_IV[6], B2S_IV[7]); + this.v0 ^= v0 ^ v8; + this.v1 ^= v1 ^ v9; + this.v2 ^= v2 ^ v10; + this.v3 ^= v3 ^ v11; + this.v4 ^= v4 ^ v12; + this.v5 ^= v5 ^ v13; + this.v6 ^= v6 ^ v14; + this.v7 ^= v7 ^ v15; + } + destroy() { + this.destroyed = true; + clean(this.buffer32); + this.set(0, 0, 0, 0, 0, 0, 0, 0); + } +} +/** + * Blake2s hash function. Focuses on 8-bit to 32-bit platforms. 1.5x faster than blake2b in JS. + * @param msg - message that would be hashed + * @param opts - dkLen output length, key for MAC mode, salt, personalization + */ +export const blake2s = /* @__PURE__ */ createOptHasher((opts) => new BLAKE2s(opts)); +//# sourceMappingURL=blake2.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/blake2.js.map b/node_modules/@noble/hashes/esm/blake2.js.map new file mode 100644 index 0000000000000000000000000000000000000000..6289763eabe0387e59e56e5f493dbd79d1dbf716 --- /dev/null +++ b/node_modules/@noble/hashes/esm/blake2.js.map @@ -0,0 +1 @@ +{"version":3,"file":"blake2.js","sourceRoot":"","sources":["../src/blake2.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AACjC,kBAAkB;AAClB,OAAO,EACL,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EACjC,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,EAElE,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AAI,CAAC,QAAQ,CAAC,CAAC;QACrB,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACnC,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAW,eAAe,CAAC,eAAe,CAC5D,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAC5B,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/blake2b.d.ts b/node_modules/@noble/hashes/esm/blake2b.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a9ea37ec437c520846dcf44433920e68d25a173b --- /dev/null +++ b/node_modules/@noble/hashes/esm/blake2b.d.ts @@ -0,0 +1,11 @@ +/** + * Blake2b hash function. Focuses on 64-bit platforms, but in JS speed different from Blake2s is negligible. + * @module + * @deprecated + */ +import { BLAKE2b as B2B, blake2b as b2b } from './blake2.ts'; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export declare const BLAKE2b: typeof B2B; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export declare const blake2b: typeof b2b; +//# sourceMappingURL=blake2b.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/blake2b.d.ts.map b/node_modules/@noble/hashes/esm/blake2b.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..0307e9001dce0e767d71cb8c2da0fafeba78c977 --- /dev/null +++ b/node_modules/@noble/hashes/esm/blake2b.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"blake2b.d.ts","sourceRoot":"","sources":["../src/blake2b.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,aAAa,CAAC;AAC7D,+DAA+D;AAC/D,eAAO,MAAM,OAAO,EAAE,OAAO,GAAS,CAAC;AACvC,+DAA+D;AAC/D,eAAO,MAAM,OAAO,EAAE,OAAO,GAAS,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/blake2b.js b/node_modules/@noble/hashes/esm/blake2b.js new file mode 100644 index 0000000000000000000000000000000000000000..2a7fa3541c095d4f2094434872cb342fa2c22d19 --- /dev/null +++ b/node_modules/@noble/hashes/esm/blake2b.js @@ -0,0 +1,11 @@ +/** + * Blake2b hash function. Focuses on 64-bit platforms, but in JS speed different from Blake2s is negligible. + * @module + * @deprecated + */ +import { BLAKE2b as B2B, blake2b as b2b } from "./blake2.js"; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export const BLAKE2b = B2B; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export const blake2b = b2b; +//# sourceMappingURL=blake2b.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/blake2b.js.map b/node_modules/@noble/hashes/esm/blake2b.js.map new file mode 100644 index 0000000000000000000000000000000000000000..8450afa4ceb5788c5ee351c3115df5f00931a764 --- /dev/null +++ b/node_modules/@noble/hashes/esm/blake2b.js.map @@ -0,0 +1 @@ +{"version":3,"file":"blake2b.js","sourceRoot":"","sources":["../src/blake2b.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,aAAa,CAAC;AAC7D,+DAA+D;AAC/D,MAAM,CAAC,MAAM,OAAO,GAAe,GAAG,CAAC;AACvC,+DAA+D;AAC/D,MAAM,CAAC,MAAM,OAAO,GAAe,GAAG,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/blake2s.d.ts b/node_modules/@noble/hashes/esm/blake2s.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6720f358763e288d3d4c00d5920dd4210bb59ada --- /dev/null +++ b/node_modules/@noble/hashes/esm/blake2s.d.ts @@ -0,0 +1,20 @@ +/** + * Blake2s hash function. Focuses on 8-bit to 32-bit platforms. blake2b for 64-bit, but in JS it is slower. + * @module + * @deprecated + */ +import { G1s as G1s_n, G2s as G2s_n } from './_blake.ts'; +import { BLAKE2s as B2S, blake2s as b2s, compress as compress_n } from './blake2.ts'; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export declare const B2S_IV: Uint32Array; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export declare const G1s: typeof G1s_n; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export declare const G2s: typeof G2s_n; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export declare const compress: typeof compress_n; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export declare const BLAKE2s: typeof B2S; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export declare const blake2s: typeof b2s; +//# sourceMappingURL=blake2s.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/blake2s.d.ts.map b/node_modules/@noble/hashes/esm/blake2s.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..ced6ec76c0d8149360aeeeb744550178fcf6b1be --- /dev/null +++ b/node_modules/@noble/hashes/esm/blake2s.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"blake2s.d.ts","sourceRoot":"","sources":["../src/blake2s.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,GAAG,IAAI,KAAK,EAAE,GAAG,IAAI,KAAK,EAAE,MAAM,aAAa,CAAC;AAEzD,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,OAAO,IAAI,GAAG,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC;AACrF,+DAA+D;AAC/D,eAAO,MAAM,MAAM,EAAE,WAAuB,CAAC;AAC7C,+DAA+D;AAC/D,eAAO,MAAM,GAAG,EAAE,OAAO,KAAa,CAAC;AACvC,+DAA+D;AAC/D,eAAO,MAAM,GAAG,EAAE,OAAO,KAAa,CAAC;AACvC,+DAA+D;AAC/D,eAAO,MAAM,QAAQ,EAAE,OAAO,UAAuB,CAAC;AACtD,+DAA+D;AAC/D,eAAO,MAAM,OAAO,EAAE,OAAO,GAAS,CAAC;AACvC,+DAA+D;AAC/D,eAAO,MAAM,OAAO,EAAE,OAAO,GAAS,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/blake2s.js b/node_modules/@noble/hashes/esm/blake2s.js new file mode 100644 index 0000000000000000000000000000000000000000..a4d3337819021b960fdb727217f07b18cecacc82 --- /dev/null +++ b/node_modules/@noble/hashes/esm/blake2s.js @@ -0,0 +1,21 @@ +/** + * Blake2s hash function. Focuses on 8-bit to 32-bit platforms. blake2b for 64-bit, but in JS it is slower. + * @module + * @deprecated + */ +import { G1s as G1s_n, G2s as G2s_n } from "./_blake.js"; +import { SHA256_IV } from "./_md.js"; +import { BLAKE2s as B2S, blake2s as b2s, compress as compress_n } from "./blake2.js"; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export const B2S_IV = SHA256_IV; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export const G1s = G1s_n; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export const G2s = G2s_n; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export const compress = compress_n; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export const BLAKE2s = B2S; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export const blake2s = b2s; +//# sourceMappingURL=blake2s.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/blake2s.js.map b/node_modules/@noble/hashes/esm/blake2s.js.map new file mode 100644 index 0000000000000000000000000000000000000000..c0572b2a4dd5787252cd8ed159a45b5c0c194da9 --- /dev/null +++ b/node_modules/@noble/hashes/esm/blake2s.js.map @@ -0,0 +1 @@ +{"version":3,"file":"blake2s.js","sourceRoot":"","sources":["../src/blake2s.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,GAAG,IAAI,KAAK,EAAE,GAAG,IAAI,KAAK,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,OAAO,IAAI,GAAG,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC;AACrF,+DAA+D;AAC/D,MAAM,CAAC,MAAM,MAAM,GAAgB,SAAS,CAAC;AAC7C,+DAA+D;AAC/D,MAAM,CAAC,MAAM,GAAG,GAAiB,KAAK,CAAC;AACvC,+DAA+D;AAC/D,MAAM,CAAC,MAAM,GAAG,GAAiB,KAAK,CAAC;AACvC,+DAA+D;AAC/D,MAAM,CAAC,MAAM,QAAQ,GAAsB,UAAU,CAAC;AACtD,+DAA+D;AAC/D,MAAM,CAAC,MAAM,OAAO,GAAe,GAAG,CAAC;AACvC,+DAA+D;AAC/D,MAAM,CAAC,MAAM,OAAO,GAAe,GAAG,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/blake3.d.ts b/node_modules/@noble/hashes/esm/blake3.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..234fa87f32a94530cb2713ca98d6ccb45a648d9a --- /dev/null +++ b/node_modules/@noble/hashes/esm/blake3.d.ts @@ -0,0 +1,54 @@ +import { BLAKE2 } from './blake2.ts'; +import { type CHashXO, type HashXOF, type Input } from './utils.ts'; +/** + * Ensure to use EITHER `key` OR `context`, not both. + * + * * `key`: 32-byte MAC key. + * * `context`: string for KDF. Should be hardcoded, globally unique, and application - specific. + * A good default format for the context string is "[application] [commit timestamp] [purpose]". + */ +export type Blake3Opts = { + dkLen?: number; + key?: Input; + context?: Input; +}; +/** Blake3 hash. Can be used as MAC and KDF. */ +export declare class BLAKE3 extends BLAKE2 implements HashXOF { + private chunkPos; + private chunksDone; + private flags; + private IV; + private state; + private stack; + private posOut; + private bufferOut32; + private bufferOut; + private chunkOut; + private enableXOF; + constructor(opts?: Blake3Opts, flags?: number); + protected get(): []; + protected set(): void; + private b2Compress; + protected compress(buf: Uint32Array, bufPos?: number, isLast?: boolean): void; + _cloneInto(to?: BLAKE3): BLAKE3; + destroy(): void; + private b2CompressOut; + protected finish(): void; + private writeInto; + xofInto(out: Uint8Array): Uint8Array; + xof(bytes: number): Uint8Array; + digestInto(out: Uint8Array): Uint8Array; + digest(): Uint8Array; +} +/** + * BLAKE3 hash function. Can be used as MAC and KDF. + * @param msg - message that would be hashed + * @param opts - `dkLen` for output length, `key` for MAC mode, `context` for KDF mode + * @example + * const data = new Uint8Array(32); + * const hash = blake3(data); + * const mac = blake3(data, { key: new Uint8Array(32) }); + * const kdf = blake3(data, { context: 'application name' }); + */ +export declare const blake3: CHashXO; +//# sourceMappingURL=blake3.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/blake3.d.ts.map b/node_modules/@noble/hashes/esm/blake3.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..4335e424954aff1d151df30c465e6869d28fea95 --- /dev/null +++ b/node_modules/@noble/hashes/esm/blake3.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"blake3.d.ts","sourceRoot":"","sources":["../src/blake3.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,MAAM,EAAY,MAAM,aAAa,CAAC;AAE/C,OAAO,EAGL,KAAK,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,KAAK,EACvC,MAAM,YAAY,CAAC;AAwBpB;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,KAAK,CAAC;IAAC,OAAO,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAE1E,+CAA+C;AAC/C,qBAAa,MAAO,SAAQ,MAAM,CAAC,MAAM,CAAE,YAAW,OAAO,CAAC,MAAM,CAAC;IACnE,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,EAAE,CAAc;IACxB,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,KAAK,CAAqB;IAElC,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,SAAS,CAAQ;gBAEb,IAAI,GAAE,UAAe,EAAE,KAAK,SAAI;IA2B5C,SAAS,CAAC,GAAG,IAAI,EAAE;IAGnB,SAAS,CAAC,GAAG,IAAI,IAAI;IACrB,OAAO,CAAC,UAAU;IAmBlB,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,GAAE,MAAU,EAAE,MAAM,GAAE,OAAe,GAAG,IAAI;IAiCvF,UAAU,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM;IAe/B,OAAO,IAAI,IAAI;IAMf,OAAO,CAAC,aAAa;IA+BrB,SAAS,CAAC,MAAM,IAAI,IAAI;IAoBxB,OAAO,CAAC,SAAS;IAcjB,OAAO,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU;IAIpC,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU;IAI9B,UAAU,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU;IAQvC,MAAM,IAAI,UAAU;CAGrB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,MAAM,EAAE,OAEpB,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/blake3.js b/node_modules/@noble/hashes/esm/blake3.js new file mode 100644 index 0000000000000000000000000000000000000000..e7e6e48d27b478ca2287ce424dfd7e8531eb11c3 --- /dev/null +++ b/node_modules/@noble/hashes/esm/blake3.js @@ -0,0 +1,251 @@ +/** + * Blake3 fast hash is Blake2 with reduced security (round count). Can also be used as MAC & KDF. + * + * It is advertised as "the fastest cryptographic hash". However, it isn't true in JS. + * Why is this so slow? While it should be 6x faster than blake2b, perf diff is only 20%: + * + * * There is only 30% reduction in number of rounds from blake2s + * * Speed-up comes from tree structure, which is parallelized using SIMD & threading. + * These features are not present in JS, so we only get overhead from trees. + * * Parallelization only happens on 1024-byte chunks: there is no benefit for small inputs. + * * It is still possible to make it faster using: a) loop unrolling b) web workers c) wasm + * @module + */ +import { SHA256_IV } from "./_md.js"; +import { fromBig } from "./_u64.js"; +import { BLAKE2, compress } from "./blake2.js"; +// prettier-ignore +import { abytes, aexists, anumber, aoutput, clean, createXOFer, swap32IfBE, toBytes, u32, u8 } from "./utils.js"; +// Flag bitset +const B3_Flags = { + CHUNK_START: 0b1, + CHUNK_END: 0b10, + PARENT: 0b100, + ROOT: 0b1000, + KEYED_HASH: 0b10000, + DERIVE_KEY_CONTEXT: 0b100000, + DERIVE_KEY_MATERIAL: 0b1000000, +}; +const B3_IV = SHA256_IV.slice(); +const B3_SIGMA = /* @__PURE__ */ (() => { + const Id = Array.from({ length: 16 }, (_, i) => i); + const permute = (arr) => [2, 6, 3, 10, 7, 0, 4, 13, 1, 11, 12, 5, 9, 14, 15, 8].map((i) => arr[i]); + const res = []; + for (let i = 0, v = Id; i < 7; i++, v = permute(v)) + res.push(...v); + return Uint8Array.from(res); +})(); +/** Blake3 hash. Can be used as MAC and KDF. */ +export class BLAKE3 extends BLAKE2 { + constructor(opts = {}, flags = 0) { + super(64, opts.dkLen === undefined ? 32 : opts.dkLen); + this.chunkPos = 0; // Position of current block in chunk + this.chunksDone = 0; // How many chunks we already have + this.flags = 0 | 0; + this.stack = []; + // Output + this.posOut = 0; + this.bufferOut32 = new Uint32Array(16); + this.chunkOut = 0; // index of output chunk + this.enableXOF = true; + const { key, context } = opts; + const hasContext = context !== undefined; + if (key !== undefined) { + if (hasContext) + throw new Error('Only "key" or "context" can be specified at same time'); + const k = toBytes(key).slice(); + abytes(k, 32); + this.IV = u32(k); + swap32IfBE(this.IV); + this.flags = flags | B3_Flags.KEYED_HASH; + } + else if (hasContext) { + const ctx = toBytes(context); + const contextKey = new BLAKE3({ dkLen: 32 }, B3_Flags.DERIVE_KEY_CONTEXT) + .update(ctx) + .digest(); + this.IV = u32(contextKey); + swap32IfBE(this.IV); + this.flags = flags | B3_Flags.DERIVE_KEY_MATERIAL; + } + else { + this.IV = B3_IV.slice(); + this.flags = flags; + } + this.state = this.IV.slice(); + this.bufferOut = u8(this.bufferOut32); + } + // Unused + get() { + return []; + } + set() { } + b2Compress(counter, flags, buf, bufPos = 0) { + const { state: s, pos } = this; + const { h, l } = fromBig(BigInt(counter), true); + // prettier-ignore + const { v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15 } = compress(B3_SIGMA, bufPos, buf, 7, s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], B3_IV[0], B3_IV[1], B3_IV[2], B3_IV[3], h, l, pos, flags); + s[0] = v0 ^ v8; + s[1] = v1 ^ v9; + s[2] = v2 ^ v10; + s[3] = v3 ^ v11; + s[4] = v4 ^ v12; + s[5] = v5 ^ v13; + s[6] = v6 ^ v14; + s[7] = v7 ^ v15; + } + compress(buf, bufPos = 0, isLast = false) { + // Compress last block + let flags = this.flags; + if (!this.chunkPos) + flags |= B3_Flags.CHUNK_START; + if (this.chunkPos === 15 || isLast) + flags |= B3_Flags.CHUNK_END; + if (!isLast) + this.pos = this.blockLen; + this.b2Compress(this.chunksDone, flags, buf, bufPos); + this.chunkPos += 1; + // If current block is last in chunk (16 blocks), then compress chunks + if (this.chunkPos === 16 || isLast) { + let chunk = this.state; + this.state = this.IV.slice(); + // If not the last one, compress only when there are trailing zeros in chunk counter + // chunks used as binary tree where current stack is path. Zero means current leaf is finished and can be compressed. + // 1 (001) - leaf not finished (just push current chunk to stack) + // 2 (010) - leaf finished at depth=1 (merge with last elm on stack and push back) + // 3 (011) - last leaf not finished + // 4 (100) - leafs finished at depth=1 and depth=2 + for (let last, chunks = this.chunksDone + 1; isLast || !(chunks & 1); chunks >>= 1) { + if (!(last = this.stack.pop())) + break; + this.buffer32.set(last, 0); + this.buffer32.set(chunk, 8); + this.pos = this.blockLen; + this.b2Compress(0, this.flags | B3_Flags.PARENT, this.buffer32, 0); + chunk = this.state; + this.state = this.IV.slice(); + } + this.chunksDone++; + this.chunkPos = 0; + this.stack.push(chunk); + } + this.pos = 0; + } + _cloneInto(to) { + to = super._cloneInto(to); + const { IV, flags, state, chunkPos, posOut, chunkOut, stack, chunksDone } = this; + to.state.set(state.slice()); + to.stack = stack.map((i) => Uint32Array.from(i)); + to.IV.set(IV); + to.flags = flags; + to.chunkPos = chunkPos; + to.chunksDone = chunksDone; + to.posOut = posOut; + to.chunkOut = chunkOut; + to.enableXOF = this.enableXOF; + to.bufferOut32.set(this.bufferOut32); + return to; + } + destroy() { + this.destroyed = true; + clean(this.state, this.buffer32, this.IV, this.bufferOut32); + clean(...this.stack); + } + // Same as b2Compress, but doesn't modify state and returns 16 u32 array (instead of 8) + b2CompressOut() { + const { state: s, pos, flags, buffer32, bufferOut32: out32 } = this; + const { h, l } = fromBig(BigInt(this.chunkOut++)); + swap32IfBE(buffer32); + // prettier-ignore + const { v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15 } = compress(B3_SIGMA, 0, buffer32, 7, s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], B3_IV[0], B3_IV[1], B3_IV[2], B3_IV[3], l, h, pos, flags); + out32[0] = v0 ^ v8; + out32[1] = v1 ^ v9; + out32[2] = v2 ^ v10; + out32[3] = v3 ^ v11; + out32[4] = v4 ^ v12; + out32[5] = v5 ^ v13; + out32[6] = v6 ^ v14; + out32[7] = v7 ^ v15; + out32[8] = s[0] ^ v8; + out32[9] = s[1] ^ v9; + out32[10] = s[2] ^ v10; + out32[11] = s[3] ^ v11; + out32[12] = s[4] ^ v12; + out32[13] = s[5] ^ v13; + out32[14] = s[6] ^ v14; + out32[15] = s[7] ^ v15; + swap32IfBE(buffer32); + swap32IfBE(out32); + this.posOut = 0; + } + finish() { + if (this.finished) + return; + this.finished = true; + // Padding + clean(this.buffer.subarray(this.pos)); + // Process last chunk + let flags = this.flags | B3_Flags.ROOT; + if (this.stack.length) { + flags |= B3_Flags.PARENT; + swap32IfBE(this.buffer32); + this.compress(this.buffer32, 0, true); + swap32IfBE(this.buffer32); + this.chunksDone = 0; + this.pos = this.blockLen; + } + else { + flags |= (!this.chunkPos ? B3_Flags.CHUNK_START : 0) | B3_Flags.CHUNK_END; + } + this.flags = flags; + this.b2CompressOut(); + } + writeInto(out) { + aexists(this, false); + abytes(out); + this.finish(); + const { blockLen, bufferOut } = this; + for (let pos = 0, len = out.length; pos < len;) { + if (this.posOut >= blockLen) + this.b2CompressOut(); + const take = Math.min(blockLen - this.posOut, len - pos); + out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos); + this.posOut += take; + pos += take; + } + return out; + } + xofInto(out) { + if (!this.enableXOF) + throw new Error('XOF is not possible after digest call'); + return this.writeInto(out); + } + xof(bytes) { + anumber(bytes); + return this.xofInto(new Uint8Array(bytes)); + } + digestInto(out) { + aoutput(out, this); + if (this.finished) + throw new Error('digest() was already called'); + this.enableXOF = false; + this.writeInto(out); + this.destroy(); + return out; + } + digest() { + return this.digestInto(new Uint8Array(this.outputLen)); + } +} +/** + * BLAKE3 hash function. Can be used as MAC and KDF. + * @param msg - message that would be hashed + * @param opts - `dkLen` for output length, `key` for MAC mode, `context` for KDF mode + * @example + * const data = new Uint8Array(32); + * const hash = blake3(data); + * const mac = blake3(data, { key: new Uint8Array(32) }); + * const kdf = blake3(data, { context: 'application name' }); + */ +export const blake3 = /* @__PURE__ */ createXOFer((opts) => new BLAKE3(opts)); +//# sourceMappingURL=blake3.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/blake3.js.map b/node_modules/@noble/hashes/esm/blake3.js.map new file mode 100644 index 0000000000000000000000000000000000000000..91f5a7981babd4047d5349251045d27b50a63c46 --- /dev/null +++ b/node_modules/@noble/hashes/esm/blake3.js.map @@ -0,0 +1 @@ +{"version":3,"file":"blake3.js","sourceRoot":"","sources":["../src/blake3.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;A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UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IACzD,CAAC;CACF;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,MAAM,GAAY,eAAe,CAAC,WAAW,CACxD,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,CAC3B,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/crypto.d.ts b/node_modules/@noble/hashes/esm/crypto.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ac181a0247597021010e0d9821dd2fdf4eb077c3 --- /dev/null +++ b/node_modules/@noble/hashes/esm/crypto.d.ts @@ -0,0 +1,2 @@ +export declare const crypto: any; +//# sourceMappingURL=crypto.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/crypto.d.ts.map b/node_modules/@noble/hashes/esm/crypto.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..756d98203d7e40877c0d4eb89191cbab9dacc8ee --- /dev/null +++ b/node_modules/@noble/hashes/esm/crypto.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../src/crypto.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,MAAM,EAAE,GACqE,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/crypto.js b/node_modules/@noble/hashes/esm/crypto.js new file mode 100644 index 0000000000000000000000000000000000000000..8d499a088aaab5bdf5b46ba4f4fbd2e91c083010 --- /dev/null +++ b/node_modules/@noble/hashes/esm/crypto.js @@ -0,0 +1,2 @@ +export const crypto = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined; +//# sourceMappingURL=crypto.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/crypto.js.map b/node_modules/@noble/hashes/esm/crypto.js.map new file mode 100644 index 0000000000000000000000000000000000000000..9ad4f45bd5e01672d8281d144d474ebd0380ca3d --- /dev/null +++ b/node_modules/@noble/hashes/esm/crypto.js.map @@ -0,0 +1 @@ +{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../src/crypto.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,MAAM,GACjB,OAAO,UAAU,KAAK,QAAQ,IAAI,QAAQ,IAAI,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/cryptoNode.d.ts b/node_modules/@noble/hashes/esm/cryptoNode.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..98bda7be4ddd7d83a758d97d502e691c6be18fc9 --- /dev/null +++ b/node_modules/@noble/hashes/esm/cryptoNode.d.ts @@ -0,0 +1,2 @@ +export declare const crypto: any; +//# sourceMappingURL=cryptoNode.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/cryptoNode.d.ts.map b/node_modules/@noble/hashes/esm/cryptoNode.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..90dcc4441615525ae383030b2b6938b5092ae519 --- /dev/null +++ b/node_modules/@noble/hashes/esm/cryptoNode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"cryptoNode.d.ts","sourceRoot":"","sources":["../src/cryptoNode.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,MAAM,EAAE,GAKJ,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/cryptoNode.js b/node_modules/@noble/hashes/esm/cryptoNode.js new file mode 100644 index 0000000000000000000000000000000000000000..4f77e8f46c5e242e1e3cb92712dc65e95a8b8eb0 --- /dev/null +++ b/node_modules/@noble/hashes/esm/cryptoNode.js @@ -0,0 +1,15 @@ +/** + * Internal webcrypto alias. + * We prefer WebCrypto aka globalThis.crypto, which exists in node.js 16+. + * Falls back to Node.js built-in crypto for Node.js <=v14. + * See utils.ts for details. + * @module + */ +// @ts-ignore +import * as nc from 'node:crypto'; +export const crypto = nc && typeof nc === 'object' && 'webcrypto' in nc + ? nc.webcrypto + : nc && typeof nc === 'object' && 'randomBytes' in nc + ? nc + : undefined; +//# sourceMappingURL=cryptoNode.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/cryptoNode.js.map b/node_modules/@noble/hashes/esm/cryptoNode.js.map new file mode 100644 index 0000000000000000000000000000000000000000..6b07d8a6bf77b8edf6e3b373cf4ca2ba2a61d3ec --- /dev/null +++ b/node_modules/@noble/hashes/esm/cryptoNode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"cryptoNode.js","sourceRoot":"","sources":["../src/cryptoNode.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,aAAa;AACb,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,MAAM,CAAC,MAAM,MAAM,GACjB,EAAE,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,WAAW,IAAI,EAAE;IAC/C,CAAC,CAAE,EAAE,CAAC,SAAiB;IACvB,CAAC,CAAC,EAAE,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,aAAa,IAAI,EAAE;QACnD,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,SAAS,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/eskdf.d.ts b/node_modules/@noble/hashes/esm/eskdf.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..66721eb52becd414746ee0fb67666cf146996e07 --- /dev/null +++ b/node_modules/@noble/hashes/esm/eskdf.d.ts @@ -0,0 +1,47 @@ +export declare function scrypt(password: string, salt: string): Uint8Array; +export declare function pbkdf2(password: string, salt: string): Uint8Array; +/** + * Derives main seed. Takes a lot of time. Prefer `eskdf` method instead. + */ +export declare function deriveMainSeed(username: string, password: string): Uint8Array; +type AccountID = number | string; +type OptsLength = { + keyLength: number; +}; +type OptsMod = { + modulus: bigint; +}; +type KeyOpts = undefined | OptsLength | OptsMod; +export interface ESKDF { + /** + * Derives a child key. Child key will not be associated with any + * other child key because of properties of underlying KDF. + * + * @param protocol - 3-15 character protocol name + * @param accountId - numeric identifier of account + * @param options - `keyLength: 64` or `modulus: 41920438n` + * @example deriveChildKey('aes', 0) + */ + deriveChildKey: (protocol: string, accountId: AccountID, options?: KeyOpts) => Uint8Array; + /** + * Deletes the main seed from eskdf instance + */ + expire: () => void; + /** + * Account fingerprint + */ + fingerprint: string; +} +/** + * ESKDF + * @param username - username, email, or identifier, min: 8 characters, should have enough entropy + * @param password - password, min: 8 characters, should have enough entropy + * @example + * const kdf = await eskdf('example-university', 'beginning-new-example'); + * const key = kdf.deriveChildKey('aes', 0); + * console.log(kdf.fingerprint); + * kdf.expire(); + */ +export declare function eskdf(username: string, password: string): Promise; +export {}; +//# sourceMappingURL=eskdf.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/eskdf.d.ts.map b/node_modules/@noble/hashes/esm/eskdf.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..f05732c0b78e391ca7403ee7b96a9634f111d277 --- /dev/null +++ b/node_modules/@noble/hashes/esm/eskdf.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"eskdf.d.ts","sourceRoot":"","sources":["../src/eskdf.ts"],"names":[],"mappings":"AAiBA,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,CAEjE;AAGD,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,CAEjE;AAiBD;;GAEG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,CAY7E;AAED,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAgCjC,KAAK,UAAU,GAAG;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AACxC,KAAK,OAAO,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AACnC,KAAK,OAAO,GAAG,SAAS,GAAG,UAAU,GAAG,OAAO,CAAC;AAwChD,MAAM,WAAW,KAAK;IACpB;;;;;;;;OAQG;IACH,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,UAAU,CAAC;IAC1F;;OAEG;IACH,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;GASG;AACH,wBAAsB,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAuB9E"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/eskdf.js b/node_modules/@noble/hashes/esm/eskdf.js new file mode 100644 index 0000000000000000000000000000000000000000..96d7a500455f509436e8631c2e534c7956eaaa6e --- /dev/null +++ b/node_modules/@noble/hashes/esm/eskdf.js @@ -0,0 +1,160 @@ +/** + * Experimental KDF for AES. + */ +import { hkdf } from "./hkdf.js"; +import { pbkdf2 as _pbkdf2 } from "./pbkdf2.js"; +import { scrypt as _scrypt } from "./scrypt.js"; +import { sha256 } from "./sha256.js"; +import { abytes, bytesToHex, clean, createView, hexToBytes, kdfInputToBytes } from "./utils.js"; +// A tiny KDF for various applications like AES key-gen. +// Uses HKDF in a non-standard way, so it's not "KDF-secure", only "PRF-secure". +// Which is good enough: assume sha2-256 retained preimage resistance. +const SCRYPT_FACTOR = 2 ** 19; +const PBKDF2_FACTOR = 2 ** 17; +// Scrypt KDF +export function scrypt(password, salt) { + return _scrypt(password, salt, { N: SCRYPT_FACTOR, r: 8, p: 1, dkLen: 32 }); +} +// PBKDF2-HMAC-SHA256 +export function pbkdf2(password, salt) { + return _pbkdf2(sha256, password, salt, { c: PBKDF2_FACTOR, dkLen: 32 }); +} +// Combines two 32-byte byte arrays +function xor32(a, b) { + abytes(a, 32); + abytes(b, 32); + const arr = new Uint8Array(32); + for (let i = 0; i < 32; i++) { + arr[i] = a[i] ^ b[i]; + } + return arr; +} +function strHasLength(str, min, max) { + return typeof str === 'string' && str.length >= min && str.length <= max; +} +/** + * Derives main seed. Takes a lot of time. Prefer `eskdf` method instead. + */ +export function deriveMainSeed(username, password) { + if (!strHasLength(username, 8, 255)) + throw new Error('invalid username'); + if (!strHasLength(password, 8, 255)) + throw new Error('invalid password'); + // Declared like this to throw off minifiers which auto-convert .fromCharCode(1) to actual string. + // String with non-ascii may be problematic in some envs + const codes = { _1: 1, _2: 2 }; + const sep = { s: String.fromCharCode(codes._1), p: String.fromCharCode(codes._2) }; + const scr = scrypt(password + sep.s, username + sep.s); + const pbk = pbkdf2(password + sep.p, username + sep.p); + const res = xor32(scr, pbk); + clean(scr, pbk); + return res; +} +/** + * Converts protocol & accountId pair to HKDF salt & info params. + */ +function getSaltInfo(protocol, accountId = 0) { + // Note that length here also repeats two lines below + // We do an additional length check here to reduce the scope of DoS attacks + if (!(strHasLength(protocol, 3, 15) && /^[a-z0-9]{3,15}$/.test(protocol))) { + throw new Error('invalid protocol'); + } + // Allow string account ids for some protocols + const allowsStr = /^password\d{0,3}|ssh|tor|file$/.test(protocol); + let salt; // Extract salt. Default is undefined. + if (typeof accountId === 'string') { + if (!allowsStr) + throw new Error('accountId must be a number'); + if (!strHasLength(accountId, 1, 255)) + throw new Error('accountId must be string of length 1..255'); + salt = kdfInputToBytes(accountId); + } + else if (Number.isSafeInteger(accountId)) { + if (accountId < 0 || accountId > Math.pow(2, 32) - 1) + throw new Error('invalid accountId'); + // Convert to Big Endian Uint32 + salt = new Uint8Array(4); + createView(salt).setUint32(0, accountId, false); + } + else { + throw new Error('accountId must be a number' + (allowsStr ? ' or string' : '')); + } + const info = kdfInputToBytes(protocol); + return { salt, info }; +} +function countBytes(num) { + if (typeof num !== 'bigint' || num <= BigInt(128)) + throw new Error('invalid number'); + return Math.ceil(num.toString(2).length / 8); +} +/** + * Parses keyLength and modulus options to extract length of result key. + * If modulus is used, adds 64 bits to it as per FIPS 186 B.4.1 to combat modulo bias. + */ +function getKeyLength(options) { + if (!options || typeof options !== 'object') + return 32; + const hasLen = 'keyLength' in options; + const hasMod = 'modulus' in options; + if (hasLen && hasMod) + throw new Error('cannot combine keyLength and modulus options'); + if (!hasLen && !hasMod) + throw new Error('must have either keyLength or modulus option'); + // FIPS 186 B.4.1 requires at least 64 more bits + const l = hasMod ? countBytes(options.modulus) + 8 : options.keyLength; + if (!(typeof l === 'number' && l >= 16 && l <= 8192)) + throw new Error('invalid keyLength'); + return l; +} +/** + * Converts key to bigint and divides it by modulus. Big Endian. + * Implements FIPS 186 B.4.1, which removes 0 and modulo bias from output. + */ +function modReduceKey(key, modulus) { + const _1 = BigInt(1); + const num = BigInt('0x' + bytesToHex(key)); // check for ui8a, then bytesToNumber() + const res = (num % (modulus - _1)) + _1; // Remove 0 from output + if (res < _1) + throw new Error('expected positive number'); // Guard against bad values + const len = key.length - 8; // FIPS requires 64 more bits = 8 bytes + const hex = res.toString(16).padStart(len * 2, '0'); // numberToHex() + const bytes = hexToBytes(hex); + if (bytes.length !== len) + throw new Error('invalid length of result key'); + return bytes; +} +/** + * ESKDF + * @param username - username, email, or identifier, min: 8 characters, should have enough entropy + * @param password - password, min: 8 characters, should have enough entropy + * @example + * const kdf = await eskdf('example-university', 'beginning-new-example'); + * const key = kdf.deriveChildKey('aes', 0); + * console.log(kdf.fingerprint); + * kdf.expire(); + */ +export async function eskdf(username, password) { + // We are using closure + object instead of class because + // we want to make `seed` non-accessible for any external function. + let seed = deriveMainSeed(username, password); + function deriveCK(protocol, accountId = 0, options) { + abytes(seed, 32); + const { salt, info } = getSaltInfo(protocol, accountId); // validate protocol & accountId + const keyLength = getKeyLength(options); // validate options + const key = hkdf(sha256, seed, salt, info, keyLength); + // Modulus has already been validated + return options && 'modulus' in options ? modReduceKey(key, options.modulus) : key; + } + function expire() { + if (seed) + seed.fill(1); + seed = undefined; + } + // prettier-ignore + const fingerprint = Array.from(deriveCK('fingerprint', 0)) + .slice(0, 6) + .map((char) => char.toString(16).padStart(2, '0').toUpperCase()) + .join(':'); + return Object.freeze({ deriveChildKey: deriveCK, expire, fingerprint }); +} +//# sourceMappingURL=eskdf.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/eskdf.js.map b/node_modules/@noble/hashes/esm/eskdf.js.map new file mode 100644 index 0000000000000000000000000000000000000000..578d3f49fb40070e4653c29ef3994ca6ba3c98e3 --- /dev/null +++ b/node_modules/@noble/hashes/esm/eskdf.js.map @@ -0,0 +1 @@ +{"version":3,"file":"eskdf.js","sourceRoot":"","sources":["../src/eskdf.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEhG,wDAAwD;AACxD,gFAAgF;AAChF,sEAAsE;AAEtE,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,CAAC;AAC9B,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,CAAC;AAE9B,aAAa;AACb,MAAM,UAAU,MAAM,CAAC,QAAgB,EAAE,IAAY;IACnD,OAAO,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;AAC9E,CAAC;AAED,qBAAqB;AACrB,MAAM,UAAU,MAAM,CAAC,QAAgB,EAAE,IAAY;IACnD,OAAO,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,aAAa,EA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C"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/hkdf.d.ts b/node_modules/@noble/hashes/esm/hkdf.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c54c4ab2f79656aff84d089556c5052c3f4508c4 --- /dev/null +++ b/node_modules/@noble/hashes/esm/hkdf.d.ts @@ -0,0 +1,36 @@ +import { type CHash, type Input } from './utils.ts'; +/** + * HKDF-extract from spec. Less important part. `HKDF-Extract(IKM, salt) -> PRK` + * Arguments position differs from spec (IKM is first one, since it is not optional) + * @param hash - hash function that would be used (e.g. sha256) + * @param ikm - input keying material, the initial key + * @param salt - optional salt value (a non-secret random value) + */ +export declare function extract(hash: CHash, ikm: Input, salt?: Input): Uint8Array; +/** + * HKDF-expand from the spec. The most important part. `HKDF-Expand(PRK, info, L) -> OKM` + * @param hash - hash function that would be used (e.g. sha256) + * @param prk - a pseudorandom key of at least HashLen octets (usually, the output from the extract step) + * @param info - optional context and application specific information (can be a zero-length string) + * @param length - length of output keying material in bytes + */ +export declare function expand(hash: CHash, prk: Input, info?: Input, length?: number): Uint8Array; +/** + * HKDF (RFC 5869): derive keys from an initial input. + * Combines hkdf_extract + hkdf_expand in one step + * @param hash - hash function that would be used (e.g. sha256) + * @param ikm - input keying material, the initial key + * @param salt - optional salt value (a non-secret random value) + * @param info - optional context and application specific information (can be a zero-length string) + * @param length - length of output keying material in bytes + * @example + * import { hkdf } from '@noble/hashes/hkdf'; + * import { sha256 } from '@noble/hashes/sha2'; + * import { randomBytes } from '@noble/hashes/utils'; + * const inputKey = randomBytes(32); + * const salt = randomBytes(32); + * const info = 'application-key'; + * const hk1 = hkdf(sha256, inputKey, salt, info, 32); + */ +export declare const hkdf: (hash: CHash, ikm: Input, salt: Input | undefined, info: Input | undefined, length: number) => Uint8Array; +//# sourceMappingURL=hkdf.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/hkdf.d.ts.map b/node_modules/@noble/hashes/esm/hkdf.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..675ea9e9a269101e2f1c6f8b19129780653263a9 --- /dev/null +++ b/node_modules/@noble/hashes/esm/hkdf.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"hkdf.d.ts","sourceRoot":"","sources":["../src/hkdf.ts"],"names":[],"mappings":"AAMA,OAAO,EAAkB,KAAK,KAAK,EAAS,KAAK,KAAK,EAAW,MAAM,YAAY,CAAC;AAEpF;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,KAAK,GAAG,UAAU,CAOzE;AAKD;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,GAAE,MAAW,GAAG,UAAU,CA4B7F;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,IAAI,GACf,MAAM,KAAK,EACX,KAAK,KAAK,EACV,MAAM,KAAK,GAAG,SAAS,EACvB,MAAM,KAAK,GAAG,SAAS,EACvB,QAAQ,MAAM,KACb,UAAkE,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/hkdf.js b/node_modules/@noble/hashes/esm/hkdf.js new file mode 100644 index 0000000000000000000000000000000000000000..a306a9bf1131071864459a6cf614d671a9c7a2e8 --- /dev/null +++ b/node_modules/@noble/hashes/esm/hkdf.js @@ -0,0 +1,82 @@ +/** + * HKDF (RFC 5869): extract + expand in one step. + * See https://soatok.blog/2021/11/17/understanding-hkdf/. + * @module + */ +import { hmac } from "./hmac.js"; +import { ahash, anumber, clean, toBytes } from "./utils.js"; +/** + * HKDF-extract from spec. Less important part. `HKDF-Extract(IKM, salt) -> PRK` + * Arguments position differs from spec (IKM is first one, since it is not optional) + * @param hash - hash function that would be used (e.g. sha256) + * @param ikm - input keying material, the initial key + * @param salt - optional salt value (a non-secret random value) + */ +export function extract(hash, ikm, salt) { + ahash(hash); + // NOTE: some libraries treat zero-length array as 'not provided'; + // we don't, since we have undefined as 'not provided' + // https://github.com/RustCrypto/KDFs/issues/15 + if (salt === undefined) + salt = new Uint8Array(hash.outputLen); + return hmac(hash, toBytes(salt), toBytes(ikm)); +} +const HKDF_COUNTER = /* @__PURE__ */ Uint8Array.from([0]); +const EMPTY_BUFFER = /* @__PURE__ */ Uint8Array.of(); +/** + * HKDF-expand from the spec. The most important part. `HKDF-Expand(PRK, info, L) -> OKM` + * @param hash - hash function that would be used (e.g. sha256) + * @param prk - a pseudorandom key of at least HashLen octets (usually, the output from the extract step) + * @param info - optional context and application specific information (can be a zero-length string) + * @param length - length of output keying material in bytes + */ +export function expand(hash, prk, info, length = 32) { + ahash(hash); + anumber(length); + const olen = hash.outputLen; + if (length > 255 * olen) + throw new Error('Length should be <= 255*HashLen'); + const blocks = Math.ceil(length / olen); + if (info === undefined) + info = EMPTY_BUFFER; + // first L(ength) octets of T + const okm = new Uint8Array(blocks * olen); + // Re-use HMAC instance between blocks + const HMAC = hmac.create(hash, prk); + const HMACTmp = HMAC._cloneInto(); + const T = new Uint8Array(HMAC.outputLen); + for (let counter = 0; counter < blocks; counter++) { + HKDF_COUNTER[0] = counter + 1; + // T(0) = empty string (zero length) + // T(N) = HMAC-Hash(PRK, T(N-1) | info | N) + HMACTmp.update(counter === 0 ? EMPTY_BUFFER : T) + .update(info) + .update(HKDF_COUNTER) + .digestInto(T); + okm.set(T, olen * counter); + HMAC._cloneInto(HMACTmp); + } + HMAC.destroy(); + HMACTmp.destroy(); + clean(T, HKDF_COUNTER); + return okm.slice(0, length); +} +/** + * HKDF (RFC 5869): derive keys from an initial input. + * Combines hkdf_extract + hkdf_expand in one step + * @param hash - hash function that would be used (e.g. sha256) + * @param ikm - input keying material, the initial key + * @param salt - optional salt value (a non-secret random value) + * @param info - optional context and application specific information (can be a zero-length string) + * @param length - length of output keying material in bytes + * @example + * import { hkdf } from '@noble/hashes/hkdf'; + * import { sha256 } from '@noble/hashes/sha2'; + * import { randomBytes } from '@noble/hashes/utils'; + * const inputKey = randomBytes(32); + * const salt = randomBytes(32); + * const info = 'application-key'; + * const hk1 = hkdf(sha256, inputKey, salt, info, 32); + */ +export const hkdf = (hash, ikm, salt, info, length) => expand(hash, extract(hash, ikm, salt), info, length); +//# sourceMappingURL=hkdf.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/hkdf.js.map b/node_modules/@noble/hashes/esm/hkdf.js.map new file mode 100644 index 0000000000000000000000000000000000000000..8984004f3fad94c75a037ec0ebbf567eb6dc9b87 --- /dev/null +++ b/node_modules/@noble/hashes/esm/hkdf.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hkdf.js","sourceRoot":"","sources":["../src/hkdf.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAc,KAAK,EAAc,OAAO,EAAE,MAAM,YAAY,CAAC;AAEpF;;;;;;GAMG;AACH,MAAM,UAAU,OAAO,CAAC,IAAW,EAAE,GAAU,EAAE,IAAY;IAC3D,KAAK,CAAC,IAAI,CAAC,CAAC;IACZ,kEAAkE;IAClE,sDAAsD;IACtD,+CAA+C;IAC/C,IAAI,IAAI,KAAK,SAAS;QAAE,IAAI,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC9D,OAAO,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,YAAY,GAAG,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1D,MAAM,YAAY,GAAG,eAAe,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC;AAErD;;;;;;GAMG;AACH,MAAM,UAAU,MAAM,CAAC,IAAW,EAAE,GAAU,EAAE,IA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CAAC;IACf,OAAO,CAAC,OAAO,EAAE,CAAC;IAClB,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;IACvB,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AAC9B,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAClB,IAAW,EACX,GAAU,EACV,IAAuB,EACvB,IAAuB,EACvB,MAAc,EACF,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/hmac.d.ts b/node_modules/@noble/hashes/esm/hmac.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..86525f937c0880b7424dd47bd431dcb8cc60b279 --- /dev/null +++ b/node_modules/@noble/hashes/esm/hmac.d.ts @@ -0,0 +1,35 @@ +/** + * HMAC: RFC2104 message authentication code. + * @module + */ +import { Hash, type CHash, type Input } from './utils.ts'; +export declare class HMAC> extends Hash> { + oHash: T; + iHash: T; + blockLen: number; + outputLen: number; + private finished; + private destroyed; + constructor(hash: CHash, _key: Input); + update(buf: Input): this; + digestInto(out: Uint8Array): void; + digest(): Uint8Array; + _cloneInto(to?: HMAC): HMAC; + clone(): HMAC; + destroy(): void; +} +/** + * HMAC: RFC2104 message authentication code. + * @param hash - function that would be used e.g. sha256 + * @param key - message key + * @param message - message data + * @example + * import { hmac } from '@noble/hashes/hmac'; + * import { sha256 } from '@noble/hashes/sha2'; + * const mac1 = hmac(sha256, 'key', 'message'); + */ +export declare const hmac: { + (hash: CHash, key: Input, message: Input): Uint8Array; + create(hash: CHash, key: Input): HMAC; +}; +//# sourceMappingURL=hmac.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/hmac.d.ts.map b/node_modules/@noble/hashes/esm/hmac.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..7cea37dfd15501660ed66734d74fe460ee4656bb --- /dev/null +++ b/node_modules/@noble/hashes/esm/hmac.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"hmac.d.ts","sourceRoot":"","sources":["../src/hmac.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAiC,IAAI,EAAW,KAAK,KAAK,EAAE,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAElG,qBAAa,IAAI,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC,CAAE,SAAQ,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACxD,KAAK,EAAE,CAAC,CAAC;IACT,KAAK,EAAE,CAAC,CAAC;IACT,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,SAAS,CAAS;gBAEd,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK;IAsBpC,MAAM,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI;IAKxB,UAAU,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI;IASjC,MAAM,IAAI,UAAU;IAKpB,UAAU,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IAajC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC;IAGhB,OAAO,IAAI,IAAI;CAKhB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,IAAI,EAAE;IACjB,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,GAAG,UAAU,CAAC;IACtD,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;CAEM,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/hmac.js b/node_modules/@noble/hashes/esm/hmac.js new file mode 100644 index 0000000000000000000000000000000000000000..4636246b1cce8d2e894f70b577891fc36474a2b7 --- /dev/null +++ b/node_modules/@noble/hashes/esm/hmac.js @@ -0,0 +1,86 @@ +/** + * HMAC: RFC2104 message authentication code. + * @module + */ +import { abytes, aexists, ahash, clean, Hash, toBytes } from "./utils.js"; +export class HMAC extends Hash { + constructor(hash, _key) { + super(); + this.finished = false; + this.destroyed = false; + ahash(hash); + const key = toBytes(_key); + this.iHash = hash.create(); + if (typeof this.iHash.update !== 'function') + throw new Error('Expected instance of class which extends utils.Hash'); + this.blockLen = this.iHash.blockLen; + this.outputLen = this.iHash.outputLen; + const blockLen = this.blockLen; + const pad = new Uint8Array(blockLen); + // blockLen can be bigger than outputLen + pad.set(key.length > blockLen ? hash.create().update(key).digest() : key); + for (let i = 0; i < pad.length; i++) + pad[i] ^= 0x36; + this.iHash.update(pad); + // By doing update (processing of first block) of outer hash here we can re-use it between multiple calls via clone + this.oHash = hash.create(); + // Undo internal XOR && apply outer XOR + for (let i = 0; i < pad.length; i++) + pad[i] ^= 0x36 ^ 0x5c; + this.oHash.update(pad); + clean(pad); + } + update(buf) { + aexists(this); + this.iHash.update(buf); + return this; + } + digestInto(out) { + aexists(this); + abytes(out, this.outputLen); + this.finished = true; + this.iHash.digestInto(out); + this.oHash.update(out); + this.oHash.digestInto(out); + this.destroy(); + } + digest() { + const out = new Uint8Array(this.oHash.outputLen); + this.digestInto(out); + return out; + } + _cloneInto(to) { + // Create new instance without calling constructor since key already in state and we don't know it. + to || (to = Object.create(Object.getPrototypeOf(this), {})); + const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this; + to = to; + to.finished = finished; + to.destroyed = destroyed; + to.blockLen = blockLen; + to.outputLen = outputLen; + to.oHash = oHash._cloneInto(to.oHash); + to.iHash = iHash._cloneInto(to.iHash); + return to; + } + clone() { + return this._cloneInto(); + } + destroy() { + this.destroyed = true; + this.oHash.destroy(); + this.iHash.destroy(); + } +} +/** + * HMAC: RFC2104 message authentication code. + * @param hash - function that would be used e.g. sha256 + * @param key - message key + * @param message - message data + * @example + * import { hmac } from '@noble/hashes/hmac'; + * import { sha256 } from '@noble/hashes/sha2'; + * const mac1 = hmac(sha256, 'key', 'message'); + */ +export const hmac = (hash, key, message) => new HMAC(hash, key).update(message).digest(); +hmac.create = (hash, key) => new HMAC(hash, key); +//# sourceMappingURL=hmac.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/hmac.js.map b/node_modules/@noble/hashes/esm/hmac.js.map new file mode 100644 index 0000000000000000000000000000000000000000..dc621aa9a708e5804657e7b9045862cfaafa5ee3 --- /dev/null +++ b/node_modules/@noble/hashes/esm/hmac.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hmac.js","sourceRoot":"","sources":["../src/hmac.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAA0B,MAAM,YAAY,CAAC;AAElG,MAAM,OAAO,IAAwB,SAAQ,IAAa;IAQxD,YAAY,IAAW,EAAE,IAAW;QAClC,KAAK,EAAE,CAAC;QAJF,aAAQ,GAAG,KAAK,CAAC;QACjB,cAAS,GAAG,KAAK,CAAC;QAIxB,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,EAAO,CAAC;QAChC,IAAI,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,UAAU;YACzC,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;QACzE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;QACpC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;QACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;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,CAAC,MAAM,IAAI,GAGb,CAAC,IAAW,EAAE,GAAU,EAAE,OAAc,EAAc,EAAE,CAC1D,IAAI,IAAI,CAAM,IAAI,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC;AACpD,IAAI,CAAC,MAAM,GAAG,CAAC,IAAW,EAAE,GAAU,EAAE,EAAE,CAAC,IAAI,IAAI,CAAM,IAAI,EAAE,GAAG,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/index.d.ts b/node_modules/@noble/hashes/esm/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e26a57a8ca84c682b2b77b57b9d6e340ffd33436 --- /dev/null +++ b/node_modules/@noble/hashes/esm/index.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/index.d.ts.map b/node_modules/@noble/hashes/esm/index.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..535b86d29365e19067ae1813e023ccfdf008734a --- /dev/null +++ b/node_modules/@noble/hashes/esm/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/index.js b/node_modules/@noble/hashes/esm/index.js new file mode 100644 index 0000000000000000000000000000000000000000..3a2f1758ce87566e5d3e5fe30be299868d1bc99d --- /dev/null +++ b/node_modules/@noble/hashes/esm/index.js @@ -0,0 +1,33 @@ +/** + * Audited & minimal JS implementation of hash functions, MACs and KDFs. Check out individual modules. + * @module + * @example +```js +import { + sha256, sha384, sha512, sha224, sha512_224, sha512_256 +} from '@noble/hashes/sha2'; +import { + sha3_224, sha3_256, sha3_384, sha3_512, + keccak_224, keccak_256, keccak_384, keccak_512, + shake128, shake256 +} from '@noble/hashes/sha3'; +import { + cshake128, cshake256, + turboshake128, turboshake256, + kmac128, kmac256, + tuplehash256, parallelhash256, + k12, m14, keccakprg +} from '@noble/hashes/sha3-addons'; +import { blake3 } from '@noble/hashes/blake3'; +import { blake2b, blake2s } from '@noble/hashes/blake2'; +import { hmac } from '@noble/hashes/hmac'; +import { hkdf } from '@noble/hashes/hkdf'; +import { pbkdf2, pbkdf2Async } from '@noble/hashes/pbkdf2'; +import { scrypt, scryptAsync } from '@noble/hashes/scrypt'; +import { md5, ripemd160, sha1 } from '@noble/hashes/legacy'; +import * as utils from '@noble/hashes/utils'; +``` + */ +throw new Error('root module cannot be imported: import submodules instead. Check out README'); +export {}; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/index.js.map b/node_modules/@noble/hashes/esm/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..2b0c4cad271ab21a2dcff20899ca2887139f501a --- /dev/null +++ b/node_modules/@noble/hashes/esm/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,IAAI,KAAK,CAAC,6EAA6E,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/legacy.d.ts b/node_modules/@noble/hashes/esm/legacy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..39c2632d9a3396496304101fefa7fe4abc745490 --- /dev/null +++ b/node_modules/@noble/hashes/esm/legacy.d.ts @@ -0,0 +1,71 @@ +/** + +SHA1 (RFC 3174), MD5 (RFC 1321) and RIPEMD160 (RFC 2286) legacy, weak hash functions. +Don't use them in a new protocol. What "weak" means: + +- Collisions can be made with 2^18 effort in MD5, 2^60 in SHA1, 2^80 in RIPEMD160. +- No practical pre-image attacks (only theoretical, 2^123.4) +- HMAC seems kinda ok: https://datatracker.ietf.org/doc/html/rfc6151 + * @module + */ +import { HashMD } from './_md.ts'; +import { type CHash } from './utils.ts'; +/** SHA1 legacy hash class. */ +export declare class SHA1 extends HashMD { + private A; + private B; + private C; + private D; + private E; + constructor(); + protected get(): [number, number, number, number, number]; + protected set(A: number, B: number, C: number, D: number, E: number): void; + protected process(view: DataView, offset: number): void; + protected roundClean(): void; + destroy(): void; +} +/** SHA1 (RFC 3174) legacy hash function. It was cryptographically broken. */ +export declare const sha1: CHash; +/** MD5 legacy hash class. */ +export declare class MD5 extends HashMD { + private A; + private B; + private C; + private D; + constructor(); + protected get(): [number, number, number, number]; + protected set(A: number, B: number, C: number, D: number): void; + protected process(view: DataView, offset: number): void; + protected roundClean(): void; + destroy(): void; +} +/** + * MD5 (RFC 1321) legacy hash function. It was cryptographically broken. + * MD5 architecture is similar to SHA1, with some differences: + * - Reduced output length: 16 bytes (128 bit) instead of 20 + * - 64 rounds, instead of 80 + * - Little-endian: could be faster, but will require more code + * - Non-linear index selection: huge speed-up for unroll + * - Per round constants: more memory accesses, additional speed-up for unroll + */ +export declare const md5: CHash; +export declare class RIPEMD160 extends HashMD { + private h0; + private h1; + private h2; + private h3; + private h4; + constructor(); + protected get(): [number, number, number, number, number]; + protected set(h0: number, h1: number, h2: number, h3: number, h4: number): void; + protected process(view: DataView, offset: number): void; + protected roundClean(): void; + destroy(): void; +} +/** + * RIPEMD-160 - a legacy hash function from 1990s. + * * https://homes.esat.kuleuven.be/~bosselae/ripemd160.html + * * https://homes.esat.kuleuven.be/~bosselae/ripemd160/pdf/AB-9601/AB-9601.pdf + */ +export declare const ripemd160: CHash; +//# sourceMappingURL=legacy.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/legacy.d.ts.map b/node_modules/@noble/hashes/esm/legacy.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..68a8353f8b08b28cbd6d0d461ae48712aba09c52 --- /dev/null +++ b/node_modules/@noble/hashes/esm/legacy.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"legacy.d.ts","sourceRoot":"","sources":["../src/legacy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;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,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAoCvD,SAAS,CAAC,UAAU,IAAI,IAAI;IAG5B,OAAO,IAAI,IAAI;CAIhB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,GAAG,EAAE,KAAqD,CAAC;AA6CxE,qBAAa,SAAU,SAAQ,MAAM,CAAC,SAAS,CAAC;IAC9C,OAAO,CAAC,EAAE,CAAkB;IAC5B,OAAO,CAAC,EAAE,CAAkB;IAC5B,OAAO,CAAC,EAAE,CAAkB;IAC5B,OAAO,CAAC,EAAE,CAAkB;IAC5B,OAAO,CAAC,EAAE,CAAkB;;IAK5B,SAAS,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;IAIzD,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI;IAO/E,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAmCvD,SAAS,CAAC,UAAU,IAAI,IAAI;IAG5B,OAAO,IAAI,IAAI;CAKhB;AAED;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,KAA2D,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/legacy.js b/node_modules/@noble/hashes/esm/legacy.js new file mode 100644 index 0000000000000000000000000000000000000000..7067dca1b3ad3bccedf7dd0e14212fd8c1efbb0b --- /dev/null +++ b/node_modules/@noble/hashes/esm/legacy.js @@ -0,0 +1,281 @@ +/** + +SHA1 (RFC 3174), MD5 (RFC 1321) and RIPEMD160 (RFC 2286) legacy, weak hash functions. +Don't use them in a new protocol. What "weak" means: + +- Collisions can be made with 2^18 effort in MD5, 2^60 in SHA1, 2^80 in RIPEMD160. +- No practical pre-image attacks (only theoretical, 2^123.4) +- HMAC seems kinda ok: https://datatracker.ietf.org/doc/html/rfc6151 + * @module + */ +import { Chi, HashMD, Maj } from "./_md.js"; +import { clean, createHasher, rotl } from "./utils.js"; +/** Initial SHA1 state */ +const SHA1_IV = /* @__PURE__ */ Uint32Array.from([ + 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0, +]); +// Reusable temporary buffer +const SHA1_W = /* @__PURE__ */ new Uint32Array(80); +/** SHA1 legacy hash class. */ +export class SHA1 extends HashMD { + constructor() { + super(64, 20, 8, false); + this.A = SHA1_IV[0] | 0; + this.B = SHA1_IV[1] | 0; + this.C = SHA1_IV[2] | 0; + this.D = SHA1_IV[3] | 0; + this.E = SHA1_IV[4] | 0; + } + get() { + const { A, B, C, D, E } = this; + return [A, B, C, D, E]; + } + set(A, B, C, D, E) { + this.A = A | 0; + this.B = B | 0; + this.C = C | 0; + this.D = D | 0; + this.E = E | 0; + } + process(view, offset) { + for (let i = 0; i < 16; i++, offset += 4) + SHA1_W[i] = view.getUint32(offset, false); + for (let i = 16; i < 80; i++) + SHA1_W[i] = rotl(SHA1_W[i - 3] ^ SHA1_W[i - 8] ^ SHA1_W[i - 14] ^ SHA1_W[i - 16], 1); + // Compression function main loop, 80 rounds + let { A, B, C, D, E } = this; + for (let i = 0; i < 80; i++) { + let F, K; + if (i < 20) { + F = Chi(B, C, D); + K = 0x5a827999; + } + else if (i < 40) { + F = B ^ C ^ D; + K = 0x6ed9eba1; + } + else if (i < 60) { + F = Maj(B, C, D); + K = 0x8f1bbcdc; + } + else { + F = B ^ C ^ D; + K = 0xca62c1d6; + } + const T = (rotl(A, 5) + F + E + K + SHA1_W[i]) | 0; + E = D; + D = C; + C = rotl(B, 30); + B = A; + A = T; + } + // Add the compressed chunk to the current hash value + A = (A + this.A) | 0; + B = (B + this.B) | 0; + C = (C + this.C) | 0; + D = (D + this.D) | 0; + E = (E + this.E) | 0; + this.set(A, B, C, D, E); + } + roundClean() { + clean(SHA1_W); + } + destroy() { + this.set(0, 0, 0, 0, 0); + clean(this.buffer); + } +} +/** SHA1 (RFC 3174) legacy hash function. It was cryptographically broken. */ +export const sha1 = /* @__PURE__ */ createHasher(() => new SHA1()); +/** Per-round constants */ +const p32 = /* @__PURE__ */ Math.pow(2, 32); +const K = /* @__PURE__ */ Array.from({ length: 64 }, (_, i) => Math.floor(p32 * Math.abs(Math.sin(i + 1)))); +/** md5 initial state: same as sha1, but 4 u32 instead of 5. */ +const MD5_IV = /* @__PURE__ */ SHA1_IV.slice(0, 4); +// Reusable temporary buffer +const MD5_W = /* @__PURE__ */ new Uint32Array(16); +/** MD5 legacy hash class. */ +export class MD5 extends HashMD { + constructor() { + super(64, 16, 8, true); + this.A = MD5_IV[0] | 0; + this.B = MD5_IV[1] | 0; + this.C = MD5_IV[2] | 0; + this.D = MD5_IV[3] | 0; + } + get() { + const { A, B, C, D } = this; + return [A, B, C, D]; + } + set(A, B, C, D) { + this.A = A | 0; + this.B = B | 0; + this.C = C | 0; + this.D = D | 0; + } + process(view, offset) { + for (let i = 0; i < 16; i++, offset += 4) + MD5_W[i] = view.getUint32(offset, true); + // Compression function main loop, 64 rounds + let { A, B, C, D } = this; + for (let i = 0; i < 64; i++) { + let F, g, s; + if (i < 16) { + F = Chi(B, C, D); + g = i; + s = [7, 12, 17, 22]; + } + else if (i < 32) { + F = Chi(D, B, C); + g = (5 * i + 1) % 16; + s = [5, 9, 14, 20]; + } + else if (i < 48) { + F = B ^ C ^ D; + g = (3 * i + 5) % 16; + s = [4, 11, 16, 23]; + } + else { + F = C ^ (B | ~D); + g = (7 * i) % 16; + s = [6, 10, 15, 21]; + } + F = F + A + K[i] + MD5_W[g]; + A = D; + D = C; + C = B; + B = B + rotl(F, s[i % 4]); + } + // Add the compressed chunk to the current hash value + A = (A + this.A) | 0; + B = (B + this.B) | 0; + C = (C + this.C) | 0; + D = (D + this.D) | 0; + this.set(A, B, C, D); + } + roundClean() { + clean(MD5_W); + } + destroy() { + this.set(0, 0, 0, 0); + clean(this.buffer); + } +} +/** + * MD5 (RFC 1321) legacy hash function. It was cryptographically broken. + * MD5 architecture is similar to SHA1, with some differences: + * - Reduced output length: 16 bytes (128 bit) instead of 20 + * - 64 rounds, instead of 80 + * - Little-endian: could be faster, but will require more code + * - Non-linear index selection: huge speed-up for unroll + * - Per round constants: more memory accesses, additional speed-up for unroll + */ +export const md5 = /* @__PURE__ */ createHasher(() => new MD5()); +// RIPEMD-160 +const Rho160 = /* @__PURE__ */ Uint8Array.from([ + 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, +]); +const Id160 = /* @__PURE__ */ (() => Uint8Array.from(new Array(16).fill(0).map((_, i) => i)))(); +const Pi160 = /* @__PURE__ */ (() => Id160.map((i) => (9 * i + 5) % 16))(); +const idxLR = /* @__PURE__ */ (() => { + const L = [Id160]; + const R = [Pi160]; + const res = [L, R]; + for (let i = 0; i < 4; i++) + for (let j of res) + j.push(j[i].map((k) => Rho160[k])); + return res; +})(); +const idxL = /* @__PURE__ */ (() => idxLR[0])(); +const idxR = /* @__PURE__ */ (() => idxLR[1])(); +// const [idxL, idxR] = idxLR; +const shifts160 = /* @__PURE__ */ [ + [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8], + [12, 13, 11, 15, 6, 9, 9, 7, 12, 15, 11, 13, 7, 8, 7, 7], + [13, 15, 14, 11, 7, 7, 6, 8, 13, 14, 13, 12, 5, 5, 6, 9], + [14, 11, 12, 14, 8, 6, 5, 5, 15, 12, 15, 14, 9, 9, 8, 6], + [15, 12, 13, 13, 9, 5, 8, 6, 14, 11, 12, 11, 8, 6, 5, 5], +].map((i) => Uint8Array.from(i)); +const shiftsL160 = /* @__PURE__ */ idxL.map((idx, i) => idx.map((j) => shifts160[i][j])); +const shiftsR160 = /* @__PURE__ */ idxR.map((idx, i) => idx.map((j) => shifts160[i][j])); +const Kl160 = /* @__PURE__ */ Uint32Array.from([ + 0x00000000, 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xa953fd4e, +]); +const Kr160 = /* @__PURE__ */ Uint32Array.from([ + 0x50a28be6, 0x5c4dd124, 0x6d703ef3, 0x7a6d76e9, 0x00000000, +]); +// It's called f() in spec. +function ripemd_f(group, x, y, z) { + if (group === 0) + return x ^ y ^ z; + if (group === 1) + return (x & y) | (~x & z); + if (group === 2) + return (x | ~y) ^ z; + if (group === 3) + return (x & z) | (y & ~z); + return x ^ (y | ~z); +} +// Reusable temporary buffer +const BUF_160 = /* @__PURE__ */ new Uint32Array(16); +export class RIPEMD160 extends HashMD { + constructor() { + super(64, 20, 8, true); + this.h0 = 0x67452301 | 0; + this.h1 = 0xefcdab89 | 0; + this.h2 = 0x98badcfe | 0; + this.h3 = 0x10325476 | 0; + this.h4 = 0xc3d2e1f0 | 0; + } + get() { + const { h0, h1, h2, h3, h4 } = this; + return [h0, h1, h2, h3, h4]; + } + set(h0, h1, h2, h3, h4) { + this.h0 = h0 | 0; + this.h1 = h1 | 0; + this.h2 = h2 | 0; + this.h3 = h3 | 0; + this.h4 = h4 | 0; + } + process(view, offset) { + for (let i = 0; i < 16; i++, offset += 4) + BUF_160[i] = view.getUint32(offset, true); + // prettier-ignore + let al = this.h0 | 0, ar = al, bl = this.h1 | 0, br = bl, cl = this.h2 | 0, cr = cl, dl = this.h3 | 0, dr = dl, el = this.h4 | 0, er = el; + // Instead of iterating 0 to 80, we split it into 5 groups + // And use the groups in constants, functions, etc. Much simpler + for (let group = 0; group < 5; group++) { + const rGroup = 4 - group; + const hbl = Kl160[group], hbr = Kr160[group]; // prettier-ignore + const rl = idxL[group], rr = idxR[group]; // prettier-ignore + const sl = shiftsL160[group], sr = shiftsR160[group]; // prettier-ignore + for (let i = 0; i < 16; i++) { + const tl = (rotl(al + ripemd_f(group, bl, cl, dl) + BUF_160[rl[i]] + hbl, sl[i]) + el) | 0; + al = el, el = dl, dl = rotl(cl, 10) | 0, cl = bl, bl = tl; // prettier-ignore + } + // 2 loops are 10% faster + for (let i = 0; i < 16; i++) { + const tr = (rotl(ar + ripemd_f(rGroup, br, cr, dr) + BUF_160[rr[i]] + hbr, sr[i]) + er) | 0; + ar = er, er = dr, dr = rotl(cr, 10) | 0, cr = br, br = tr; // prettier-ignore + } + } + // Add the compressed chunk to the current hash value + this.set((this.h1 + cl + dr) | 0, (this.h2 + dl + er) | 0, (this.h3 + el + ar) | 0, (this.h4 + al + br) | 0, (this.h0 + bl + cr) | 0); + } + roundClean() { + clean(BUF_160); + } + destroy() { + this.destroyed = true; + clean(this.buffer); + this.set(0, 0, 0, 0, 0); + } +} +/** + * RIPEMD-160 - a legacy hash function from 1990s. + * * https://homes.esat.kuleuven.be/~bosselae/ripemd160.html + * * https://homes.esat.kuleuven.be/~bosselae/ripemd160/pdf/AB-9601/AB-9601.pdf + */ +export const ripemd160 = /* @__PURE__ */ createHasher(() => new RIPEMD160()); +//# sourceMappingURL=legacy.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/legacy.js.map b/node_modules/@noble/hashes/esm/legacy.js.map new file mode 100644 index 0000000000000000000000000000000000000000..c47bea78d4011367e01d0b9190713be9c6257f34 --- /dev/null +++ b/node_modules/@noble/hashes/esm/legacy.js.map @@ -0,0 +1 @@ +{"version":3,"file":"legacy.js","sourceRoot":"","sources":["../src/legacy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAc,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEnE,yBAAyB;AACzB,MAAM,OAAO,GAAG,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC;IAC/C,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU;CAC3D,CAAC,CAAC;AAEH,4BAA4B;AAC5B,MAAM,MAAM,G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AAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EACvB,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EACvB,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EACvB,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EACvB,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CACxB,CAAC;IACJ,CAAC;IACS,UAAU;QAClB,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IACD,OAAO;QACL,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnB,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1B,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAU,eAAe,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,IAAI,SAAS,EAAE,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/package.json b/node_modules/@noble/hashes/esm/package.json new file mode 100644 index 0000000000000000000000000000000000000000..f42e46b18130a0a55bf784034da6d890ba966f2f --- /dev/null +++ b/node_modules/@noble/hashes/esm/package.json @@ -0,0 +1,10 @@ +{ + "type": "module", + "sideEffects": false, + "browser": { + "node:crypto": false + }, + "node": { + "./crypto": "./esm/cryptoNode.js" + } +} diff --git a/node_modules/@noble/hashes/esm/pbkdf2.d.ts b/node_modules/@noble/hashes/esm/pbkdf2.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0697c694b668b50382e78fed007c39ec3b44f095 --- /dev/null +++ b/node_modules/@noble/hashes/esm/pbkdf2.d.ts @@ -0,0 +1,23 @@ +import { type CHash, type KDFInput } from './utils.ts'; +export type Pbkdf2Opt = { + c: number; + dkLen?: number; + asyncTick?: number; +}; +/** + * PBKDF2-HMAC: RFC 2898 key derivation function + * @param hash - hash function that would be used e.g. sha256 + * @param password - password from which a derived key is generated + * @param salt - cryptographic salt + * @param opts - {c, dkLen} where c is work factor and dkLen is output message size + * @example + * const key = pbkdf2(sha256, 'password', 'salt', { dkLen: 32, c: Math.pow(2, 18) }); + */ +export declare function pbkdf2(hash: CHash, password: KDFInput, salt: KDFInput, opts: Pbkdf2Opt): Uint8Array; +/** + * PBKDF2-HMAC: RFC 2898 key derivation function. Async version. + * @example + * await pbkdf2Async(sha256, 'password', 'salt', { dkLen: 32, c: 500_000 }); + */ +export declare function pbkdf2Async(hash: CHash, password: KDFInput, salt: KDFInput, opts: Pbkdf2Opt): Promise; +//# sourceMappingURL=pbkdf2.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/pbkdf2.d.ts.map b/node_modules/@noble/hashes/esm/pbkdf2.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..033d374f2e5fc5667588ab458d3af465bdf969f4 --- /dev/null +++ b/node_modules/@noble/hashes/esm/pbkdf2.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"pbkdf2.d.ts","sourceRoot":"","sources":["../src/pbkdf2.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,KAAK,EACV,KAAK,QAAQ,EACd,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,SAAS,GAAG;IACtB,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAkCF;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CACpB,IAAI,EAAE,KAAK,EACX,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,SAAS,GACd,UAAU,CAsBZ;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAC/B,IAAI,EAAE,KAAK,EACX,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,SAAS,GACd,OAAO,CAAC,UAAU,CAAC,CAsBrB"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/pbkdf2.js b/node_modules/@noble/hashes/esm/pbkdf2.js new file mode 100644 index 0000000000000000000000000000000000000000..42e78dc8d96c9ce13f7deeeeba32ec0e6bb19d99 --- /dev/null +++ b/node_modules/@noble/hashes/esm/pbkdf2.js @@ -0,0 +1,97 @@ +/** + * PBKDF (RFC 2898). Can be used to create a key from password and salt. + * @module + */ +import { hmac } from "./hmac.js"; +// prettier-ignore +import { ahash, anumber, asyncLoop, checkOpts, clean, createView, Hash, kdfInputToBytes } from "./utils.js"; +// Common prologue and epilogue for sync/async functions +function pbkdf2Init(hash, _password, _salt, _opts) { + ahash(hash); + const opts = checkOpts({ dkLen: 32, asyncTick: 10 }, _opts); + const { c, dkLen, asyncTick } = opts; + anumber(c); + anumber(dkLen); + anumber(asyncTick); + if (c < 1) + throw new Error('iterations (c) should be >= 1'); + const password = kdfInputToBytes(_password); + const salt = kdfInputToBytes(_salt); + // DK = PBKDF2(PRF, Password, Salt, c, dkLen); + const DK = new Uint8Array(dkLen); + // U1 = PRF(Password, Salt + INT_32_BE(i)) + const PRF = hmac.create(hash, password); + const PRFSalt = PRF._cloneInto().update(salt); + return { c, dkLen, asyncTick, DK, PRF, PRFSalt }; +} +function pbkdf2Output(PRF, PRFSalt, DK, prfW, u) { + PRF.destroy(); + PRFSalt.destroy(); + if (prfW) + prfW.destroy(); + clean(u); + return DK; +} +/** + * PBKDF2-HMAC: RFC 2898 key derivation function + * @param hash - hash function that would be used e.g. sha256 + * @param password - password from which a derived key is generated + * @param salt - cryptographic salt + * @param opts - {c, dkLen} where c is work factor and dkLen is output message size + * @example + * const key = pbkdf2(sha256, 'password', 'salt', { dkLen: 32, c: Math.pow(2, 18) }); + */ +export function pbkdf2(hash, password, salt, opts) { + const { c, dkLen, DK, PRF, PRFSalt } = pbkdf2Init(hash, password, salt, opts); + let prfW; // Working copy + const arr = new Uint8Array(4); + const view = createView(arr); + const u = new Uint8Array(PRF.outputLen); + // DK = T1 + T2 + ⋯ + Tdklen/hlen + for (let ti = 1, pos = 0; pos < dkLen; ti++, pos += PRF.outputLen) { + // Ti = F(Password, Salt, c, i) + const Ti = DK.subarray(pos, pos + PRF.outputLen); + view.setInt32(0, ti, false); + // F(Password, Salt, c, i) = U1 ^ U2 ^ ⋯ ^ Uc + // U1 = PRF(Password, Salt + INT_32_BE(i)) + (prfW = PRFSalt._cloneInto(prfW)).update(arr).digestInto(u); + Ti.set(u.subarray(0, Ti.length)); + for (let ui = 1; ui < c; ui++) { + // Uc = PRF(Password, Uc−1) + PRF._cloneInto(prfW).update(u).digestInto(u); + for (let i = 0; i < Ti.length; i++) + Ti[i] ^= u[i]; + } + } + return pbkdf2Output(PRF, PRFSalt, DK, prfW, u); +} +/** + * PBKDF2-HMAC: RFC 2898 key derivation function. Async version. + * @example + * await pbkdf2Async(sha256, 'password', 'salt', { dkLen: 32, c: 500_000 }); + */ +export async function pbkdf2Async(hash, password, salt, opts) { + const { c, dkLen, asyncTick, DK, PRF, PRFSalt } = pbkdf2Init(hash, password, salt, opts); + let prfW; // Working copy + const arr = new Uint8Array(4); + const view = createView(arr); + const u = new Uint8Array(PRF.outputLen); + // DK = T1 + T2 + ⋯ + Tdklen/hlen + for (let ti = 1, pos = 0; pos < dkLen; ti++, pos += PRF.outputLen) { + // Ti = F(Password, Salt, c, i) + const Ti = DK.subarray(pos, pos + PRF.outputLen); + view.setInt32(0, ti, false); + // F(Password, Salt, c, i) = U1 ^ U2 ^ ⋯ ^ Uc + // U1 = PRF(Password, Salt + INT_32_BE(i)) + (prfW = PRFSalt._cloneInto(prfW)).update(arr).digestInto(u); + Ti.set(u.subarray(0, Ti.length)); + await asyncLoop(c - 1, asyncTick, () => { + // Uc = PRF(Password, Uc−1) + PRF._cloneInto(prfW).update(u).digestInto(u); + for (let i = 0; i < Ti.length; i++) + Ti[i] ^= u[i]; + }); + } + return pbkdf2Output(PRF, PRFSalt, DK, prfW, u); +} +//# sourceMappingURL=pbkdf2.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/pbkdf2.js.map b/node_modules/@noble/hashes/esm/pbkdf2.js.map new file mode 100644 index 0000000000000000000000000000000000000000..01ffaed85ec8c9078ab2d70c2e8083c775e95b2d --- /dev/null +++ b/node_modules/@noble/hashes/esm/pbkdf2.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pbkdf2.js","sourceRoot":"","sources":["../src/pbkdf2.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,kBAAkB;AAClB,OAAO,EACL,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,eAAe,EAG/D,MAAM,YAAY,CAAC;AAOpB,wDAAwD;AACxD,SAAS,UAAU,CAAC,IAAW,EAAE,SAAmB,EAAE,KAAe,EAAE,KAAgB;IACrF,KAAK,CAAC,IAAI,CAAC,CAAC;IACZ,MAAM,IAAI,GAAG,SAAS,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;IAC5D,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IACrC,OAAO,CAAC,CAAC,CAAC,CAAC;IACX,OAAO,CAAC,KAAK,CAAC,CAAC;IACf,OAAO,CAAC,SAAS,CAAC,CAAC;IACnB,IAAI,CAAC,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAC5D,MAAM,QAAQ,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;IAC5C,MAAM,IAAI,GAAG,eAAe,CAAC,KAAK,CAAC,C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,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACjD,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/ripemd160.d.ts b/node_modules/@noble/hashes/esm/ripemd160.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2fb0fa7acfd41e8c706bb2e411137f30df2ae82d --- /dev/null +++ b/node_modules/@noble/hashes/esm/ripemd160.d.ts @@ -0,0 +1,13 @@ +/** + * RIPEMD-160 legacy hash function. + * https://homes.esat.kuleuven.be/~bosselae/ripemd160.html + * https://homes.esat.kuleuven.be/~bosselae/ripemd160/pdf/AB-9601/AB-9601.pdf + * @module + * @deprecated + */ +import { RIPEMD160 as RIPEMD160n, ripemd160 as ripemd160n } from './legacy.ts'; +/** @deprecated Use import from `noble/hashes/legacy` module */ +export declare const RIPEMD160: typeof RIPEMD160n; +/** @deprecated Use import from `noble/hashes/legacy` module */ +export declare const ripemd160: typeof ripemd160n; +//# sourceMappingURL=ripemd160.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/ripemd160.d.ts.map b/node_modules/@noble/hashes/esm/ripemd160.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..a04f75b5bab3553bb09d53f63c8870679a28a048 --- /dev/null +++ b/node_modules/@noble/hashes/esm/ripemd160.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ripemd160.d.ts","sourceRoot":"","sources":["../src/ripemd160.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,SAAS,IAAI,UAAU,EAAE,SAAS,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC;AAC/E,+DAA+D;AAC/D,eAAO,MAAM,SAAS,EAAE,OAAO,UAAuB,CAAC;AACvD,+DAA+D;AAC/D,eAAO,MAAM,SAAS,EAAE,OAAO,UAAuB,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/ripemd160.js b/node_modules/@noble/hashes/esm/ripemd160.js new file mode 100644 index 0000000000000000000000000000000000000000..cdcac9b9556294744a694eea7457b361e9fd4bb2 --- /dev/null +++ b/node_modules/@noble/hashes/esm/ripemd160.js @@ -0,0 +1,13 @@ +/** + * RIPEMD-160 legacy hash function. + * https://homes.esat.kuleuven.be/~bosselae/ripemd160.html + * https://homes.esat.kuleuven.be/~bosselae/ripemd160/pdf/AB-9601/AB-9601.pdf + * @module + * @deprecated + */ +import { RIPEMD160 as RIPEMD160n, ripemd160 as ripemd160n } from "./legacy.js"; +/** @deprecated Use import from `noble/hashes/legacy` module */ +export const RIPEMD160 = RIPEMD160n; +/** @deprecated Use import from `noble/hashes/legacy` module */ +export const ripemd160 = ripemd160n; +//# sourceMappingURL=ripemd160.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/ripemd160.js.map b/node_modules/@noble/hashes/esm/ripemd160.js.map new file mode 100644 index 0000000000000000000000000000000000000000..82324f441a62a4f6819ed811f5019af5b33be366 --- /dev/null +++ b/node_modules/@noble/hashes/esm/ripemd160.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ripemd160.js","sourceRoot":"","sources":["../src/ripemd160.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,SAAS,IAAI,UAAU,EAAE,SAAS,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC;AAC/E,+DAA+D;AAC/D,MAAM,CAAC,MAAM,SAAS,GAAsB,UAAU,CAAC;AACvD,+DAA+D;AAC/D,MAAM,CAAC,MAAM,SAAS,GAAsB,UAAU,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/scrypt.d.ts b/node_modules/@noble/hashes/esm/scrypt.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..38d0ef9714e90bbf342af1c8ae40cebff8f5dca2 --- /dev/null +++ b/node_modules/@noble/hashes/esm/scrypt.d.ts @@ -0,0 +1,34 @@ +import { type KDFInput } from './utils.ts'; +export type ScryptOpts = { + N: number; + r: number; + p: number; + dkLen?: number; + asyncTick?: number; + maxmem?: number; + onProgress?: (progress: number) => void; +}; +/** + * Scrypt KDF from RFC 7914. + * @param password - pass + * @param salt - salt + * @param opts - parameters + * - `N` is cpu/mem work factor (power of 2 e.g. 2**18) + * - `r` is block size (8 is common), fine-tunes sequential memory read size and performance + * - `p` is parallelization factor (1 is common) + * - `dkLen` is output key length in bytes e.g. 32. + * - `asyncTick` - (default: 10) max time in ms for which async function can block execution + * - `maxmem` - (default: `1024 ** 3 + 1024` aka 1GB+1KB). A limit that the app could use for scrypt + * - `onProgress` - callback function that would be executed for progress report + * @returns Derived key + * @example + * scrypt('password', 'salt', { N: 2**18, r: 8, p: 1, dkLen: 32 }); + */ +export declare function scrypt(password: KDFInput, salt: KDFInput, opts: ScryptOpts): Uint8Array; +/** + * Scrypt KDF from RFC 7914. Async version. + * @example + * await scryptAsync('password', 'salt', { N: 2**18, r: 8, p: 1, dkLen: 32 }); + */ +export declare function scryptAsync(password: KDFInput, salt: KDFInput, opts: ScryptOpts): Promise; +//# sourceMappingURL=scrypt.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/scrypt.d.ts.map b/node_modules/@noble/hashes/esm/scrypt.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..b47cc92ad64b370769ed18af5719ee0da0bf1fd2 --- /dev/null +++ b/node_modules/@noble/hashes/esm/scrypt.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"scrypt.d.ts","sourceRoot":"","sources":["../src/scrypt.ts"],"names":[],"mappings":"AAOA,OAAO,EAGL,KAAK,QAAQ,EAGd,MAAM,YAAY,CAAC;AAuEpB,MAAM,MAAM,UAAU,GAAG;IACvB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC,CAAC;AAoFF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,GAAG,UAAU,CA0BvF;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,UAAU,CAAC,CA2BrB"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/scrypt.js b/node_modules/@noble/hashes/esm/scrypt.js new file mode 100644 index 0000000000000000000000000000000000000000..9b7e9a00d1ae6b8fbf76f9f6201ffaf57a131fe9 --- /dev/null +++ b/node_modules/@noble/hashes/esm/scrypt.js @@ -0,0 +1,228 @@ +/** + * RFC 7914 Scrypt KDF. Can be used to create a key from password and salt. + * @module + */ +import { pbkdf2 } from "./pbkdf2.js"; +import { sha256 } from "./sha2.js"; +// prettier-ignore +import { anumber, asyncLoop, checkOpts, clean, rotl, swap32IfBE, u32 } from "./utils.js"; +// The main Scrypt loop: uses Salsa extensively. +// Six versions of the function were tried, this is the fastest one. +// prettier-ignore +function XorAndSalsa(prev, pi, input, ii, out, oi) { + // Based on https://cr.yp.to/salsa20.html + // Xor blocks + let y00 = prev[pi++] ^ input[ii++], y01 = prev[pi++] ^ input[ii++]; + let y02 = prev[pi++] ^ input[ii++], y03 = prev[pi++] ^ input[ii++]; + let y04 = prev[pi++] ^ input[ii++], y05 = prev[pi++] ^ input[ii++]; + let y06 = prev[pi++] ^ input[ii++], y07 = prev[pi++] ^ input[ii++]; + let y08 = prev[pi++] ^ input[ii++], y09 = prev[pi++] ^ input[ii++]; + let y10 = prev[pi++] ^ input[ii++], y11 = prev[pi++] ^ input[ii++]; + let y12 = prev[pi++] ^ input[ii++], y13 = prev[pi++] ^ input[ii++]; + let y14 = prev[pi++] ^ input[ii++], y15 = prev[pi++] ^ input[ii++]; + // Save state to temporary variables (salsa) + let x00 = y00, x01 = y01, x02 = y02, x03 = y03, x04 = y04, x05 = y05, x06 = y06, x07 = y07, x08 = y08, x09 = y09, x10 = y10, x11 = y11, x12 = y12, x13 = y13, x14 = y14, x15 = y15; + // Main loop (salsa) + for (let i = 0; i < 8; i += 2) { + x04 ^= rotl(x00 + x12 | 0, 7); + x08 ^= rotl(x04 + x00 | 0, 9); + x12 ^= rotl(x08 + x04 | 0, 13); + x00 ^= rotl(x12 + x08 | 0, 18); + x09 ^= rotl(x05 + x01 | 0, 7); + x13 ^= rotl(x09 + x05 | 0, 9); + x01 ^= rotl(x13 + x09 | 0, 13); + x05 ^= rotl(x01 + x13 | 0, 18); + x14 ^= rotl(x10 + x06 | 0, 7); + x02 ^= rotl(x14 + x10 | 0, 9); + x06 ^= rotl(x02 + x14 | 0, 13); + x10 ^= rotl(x06 + x02 | 0, 18); + x03 ^= rotl(x15 + x11 | 0, 7); + x07 ^= rotl(x03 + x15 | 0, 9); + x11 ^= rotl(x07 + x03 | 0, 13); + x15 ^= rotl(x11 + x07 | 0, 18); + x01 ^= rotl(x00 + x03 | 0, 7); + x02 ^= rotl(x01 + x00 | 0, 9); + x03 ^= rotl(x02 + x01 | 0, 13); + x00 ^= rotl(x03 + x02 | 0, 18); + x06 ^= rotl(x05 + x04 | 0, 7); + x07 ^= rotl(x06 + x05 | 0, 9); + x04 ^= rotl(x07 + x06 | 0, 13); + x05 ^= rotl(x04 + x07 | 0, 18); + x11 ^= rotl(x10 + x09 | 0, 7); + x08 ^= rotl(x11 + x10 | 0, 9); + x09 ^= rotl(x08 + x11 | 0, 13); + x10 ^= rotl(x09 + x08 | 0, 18); + x12 ^= rotl(x15 + x14 | 0, 7); + x13 ^= rotl(x12 + x15 | 0, 9); + x14 ^= rotl(x13 + x12 | 0, 13); + x15 ^= rotl(x14 + x13 | 0, 18); + } + // Write output (salsa) + out[oi++] = (y00 + x00) | 0; + out[oi++] = (y01 + x01) | 0; + out[oi++] = (y02 + x02) | 0; + out[oi++] = (y03 + x03) | 0; + out[oi++] = (y04 + x04) | 0; + out[oi++] = (y05 + x05) | 0; + out[oi++] = (y06 + x06) | 0; + out[oi++] = (y07 + x07) | 0; + out[oi++] = (y08 + x08) | 0; + out[oi++] = (y09 + x09) | 0; + out[oi++] = (y10 + x10) | 0; + out[oi++] = (y11 + x11) | 0; + out[oi++] = (y12 + x12) | 0; + out[oi++] = (y13 + x13) | 0; + out[oi++] = (y14 + x14) | 0; + out[oi++] = (y15 + x15) | 0; +} +function BlockMix(input, ii, out, oi, r) { + // The block B is r 128-byte chunks (which is equivalent of 2r 64-byte chunks) + let head = oi + 0; + let tail = oi + 16 * r; + for (let i = 0; i < 16; i++) + out[tail + i] = input[ii + (2 * r - 1) * 16 + i]; // X ← B[2r−1] + for (let i = 0; i < r; i++, head += 16, ii += 16) { + // We write odd & even Yi at same time. Even: 0bXXXXX0 Odd: 0bXXXXX1 + XorAndSalsa(out, tail, input, ii, out, head); // head[i] = Salsa(blockIn[2*i] ^ tail[i-1]) + if (i > 0) + tail += 16; // First iteration overwrites tmp value in tail + XorAndSalsa(out, head, input, (ii += 16), out, tail); // tail[i] = Salsa(blockIn[2*i+1] ^ head[i]) + } +} +// Common prologue and epilogue for sync/async functions +function scryptInit(password, salt, _opts) { + // Maxmem - 1GB+1KB by default + const opts = checkOpts({ + dkLen: 32, + asyncTick: 10, + maxmem: 1024 ** 3 + 1024, + }, _opts); + const { N, r, p, dkLen, asyncTick, maxmem, onProgress } = opts; + anumber(N); + anumber(r); + anumber(p); + anumber(dkLen); + anumber(asyncTick); + anumber(maxmem); + if (onProgress !== undefined && typeof onProgress !== 'function') + throw new Error('progressCb should be function'); + const blockSize = 128 * r; + const blockSize32 = blockSize / 4; + // Max N is 2^32 (Integrify is 32-bit). Real limit is 2^22: JS engines Uint8Array limit is 4GB in 2024. + // Spec check `N >= 2^(blockSize / 8)` is not done for compat with popular libs, + // which used incorrect r: 1, p: 8. Also, the check seems to be a spec error: + // https://www.rfc-editor.org/errata_search.php?rfc=7914 + const pow32 = Math.pow(2, 32); + if (N <= 1 || (N & (N - 1)) !== 0 || N > pow32) { + throw new Error('Scrypt: N must be larger than 1, a power of 2, and less than 2^32'); + } + if (p < 0 || p > ((pow32 - 1) * 32) / blockSize) { + throw new Error('Scrypt: p must be a positive integer less than or equal to ((2^32 - 1) * 32) / (128 * r)'); + } + if (dkLen < 0 || dkLen > (pow32 - 1) * 32) { + throw new Error('Scrypt: dkLen should be positive integer less than or equal to (2^32 - 1) * 32'); + } + const memUsed = blockSize * (N + p); + if (memUsed > maxmem) { + throw new Error('Scrypt: memused is bigger than maxMem. Expected 128 * r * (N + p) > maxmem of ' + maxmem); + } + // [B0...Bp−1] ← PBKDF2HMAC-SHA256(Passphrase, Salt, 1, blockSize*ParallelizationFactor) + // Since it has only one iteration there is no reason to use async variant + const B = pbkdf2(sha256, password, salt, { c: 1, dkLen: blockSize * p }); + const B32 = u32(B); + // Re-used between parallel iterations. Array(iterations) of B + const V = u32(new Uint8Array(blockSize * N)); + const tmp = u32(new Uint8Array(blockSize)); + let blockMixCb = () => { }; + if (onProgress) { + const totalBlockMix = 2 * N * p; + // Invoke callback if progress changes from 10.01 to 10.02 + // Allows to draw smooth progress bar on up to 8K screen + const callbackPer = Math.max(Math.floor(totalBlockMix / 10000), 1); + let blockMixCnt = 0; + blockMixCb = () => { + blockMixCnt++; + if (onProgress && (!(blockMixCnt % callbackPer) || blockMixCnt === totalBlockMix)) + onProgress(blockMixCnt / totalBlockMix); + }; + } + return { N, r, p, dkLen, blockSize32, V, B32, B, tmp, blockMixCb, asyncTick }; +} +function scryptOutput(password, dkLen, B, V, tmp) { + const res = pbkdf2(sha256, password, B, { c: 1, dkLen }); + clean(B, V, tmp); + return res; +} +/** + * Scrypt KDF from RFC 7914. + * @param password - pass + * @param salt - salt + * @param opts - parameters + * - `N` is cpu/mem work factor (power of 2 e.g. 2**18) + * - `r` is block size (8 is common), fine-tunes sequential memory read size and performance + * - `p` is parallelization factor (1 is common) + * - `dkLen` is output key length in bytes e.g. 32. + * - `asyncTick` - (default: 10) max time in ms for which async function can block execution + * - `maxmem` - (default: `1024 ** 3 + 1024` aka 1GB+1KB). A limit that the app could use for scrypt + * - `onProgress` - callback function that would be executed for progress report + * @returns Derived key + * @example + * scrypt('password', 'salt', { N: 2**18, r: 8, p: 1, dkLen: 32 }); + */ +export function scrypt(password, salt, opts) { + const { N, r, p, dkLen, blockSize32, V, B32, B, tmp, blockMixCb } = scryptInit(password, salt, opts); + swap32IfBE(B32); + for (let pi = 0; pi < p; pi++) { + const Pi = blockSize32 * pi; + for (let i = 0; i < blockSize32; i++) + V[i] = B32[Pi + i]; // V[0] = B[i] + for (let i = 0, pos = 0; i < N - 1; i++) { + BlockMix(V, pos, V, (pos += blockSize32), r); // V[i] = BlockMix(V[i-1]); + blockMixCb(); + } + BlockMix(V, (N - 1) * blockSize32, B32, Pi, r); // Process last element + blockMixCb(); + for (let i = 0; i < N; i++) { + // First u32 of the last 64-byte block (u32 is LE) + const j = B32[Pi + blockSize32 - 16] % N; // j = Integrify(X) % iterations + for (let k = 0; k < blockSize32; k++) + tmp[k] = B32[Pi + k] ^ V[j * blockSize32 + k]; // tmp = B ^ V[j] + BlockMix(tmp, 0, B32, Pi, r); // B = BlockMix(B ^ V[j]) + blockMixCb(); + } + } + swap32IfBE(B32); + return scryptOutput(password, dkLen, B, V, tmp); +} +/** + * Scrypt KDF from RFC 7914. Async version. + * @example + * await scryptAsync('password', 'salt', { N: 2**18, r: 8, p: 1, dkLen: 32 }); + */ +export async function scryptAsync(password, salt, opts) { + const { N, r, p, dkLen, blockSize32, V, B32, B, tmp, blockMixCb, asyncTick } = scryptInit(password, salt, opts); + swap32IfBE(B32); + for (let pi = 0; pi < p; pi++) { + const Pi = blockSize32 * pi; + for (let i = 0; i < blockSize32; i++) + V[i] = B32[Pi + i]; // V[0] = B[i] + let pos = 0; + await asyncLoop(N - 1, asyncTick, () => { + BlockMix(V, pos, V, (pos += blockSize32), r); // V[i] = BlockMix(V[i-1]); + blockMixCb(); + }); + BlockMix(V, (N - 1) * blockSize32, B32, Pi, r); // Process last element + blockMixCb(); + await asyncLoop(N, asyncTick, () => { + // First u32 of the last 64-byte block (u32 is LE) + const j = B32[Pi + blockSize32 - 16] % N; // j = Integrify(X) % iterations + for (let k = 0; k < blockSize32; k++) + tmp[k] = B32[Pi + k] ^ V[j * blockSize32 + k]; // tmp = B ^ V[j] + BlockMix(tmp, 0, B32, Pi, r); // B = BlockMix(B ^ V[j]) + blockMixCb(); + }); + } + swap32IfBE(B32); + return scryptOutput(password, dkLen, B, V, tmp); +} +//# sourceMappingURL=scrypt.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/scrypt.js.map b/node_modules/@noble/hashes/esm/scrypt.js.map new file mode 100644 index 0000000000000000000000000000000000000000..cb5628bd4d3da286ff0b307cf6f351f393ade0f9 --- /dev/null +++ b/node_modules/@noble/hashes/esm/scrypt.js.map @@ -0,0 +1 @@ +{"version":3,"file":"scrypt.js","sourceRoot":"","sources":["../src/scrypt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,kBAAkB;AAClB,OAAO,EACL,OAAO,EAAE,SAAS,EAClB,SAAS,EAAE,KAAK,EACD,IAAI,EACnB,UAAU,EACV,GAAG,EACJ,MAAM,YAAY,CAAC;AAEpB,gDAAgD;AAChD,oEAAoE;AACpE,kBAAkB;AAClB,SAAS,WAAW,CAClB,IAAiB,EACjB,EAAU,EACV,KAAkB,EAClB,EAAU,EACV,GAAgB,EAChB,EAAU;IAEV,yCAAyC;IACzC,aAAa;IACb,IAAI,GAAG,GAAG,IAAI,CAAC,EAAE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CAAC,yBAAyB;YACvD,UAAU,EAAE,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;IACD,UAAU,CAAC,GAAG,CAAC,CAAC;IAChB,OAAO,YAAY,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;AAClD,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/sha1.d.ts b/node_modules/@noble/hashes/esm/sha1.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7c36b9f988754516c9311659fff67161afd75d49 --- /dev/null +++ b/node_modules/@noble/hashes/esm/sha1.d.ts @@ -0,0 +1,11 @@ +/** + * SHA1 (RFC 3174) legacy hash function. + * @module + * @deprecated + */ +import { SHA1 as SHA1n, sha1 as sha1n } from './legacy.ts'; +/** @deprecated Use import from `noble/hashes/legacy` module */ +export declare const SHA1: typeof SHA1n; +/** @deprecated Use import from `noble/hashes/legacy` module */ +export declare const sha1: typeof sha1n; +//# sourceMappingURL=sha1.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/sha1.d.ts.map b/node_modules/@noble/hashes/esm/sha1.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..908753db7067d4d372c572daee15832b0e533084 --- /dev/null +++ b/node_modules/@noble/hashes/esm/sha1.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"sha1.d.ts","sourceRoot":"","sources":["../src/sha1.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,IAAI,IAAI,KAAK,EAAE,IAAI,IAAI,KAAK,EAAE,MAAM,aAAa,CAAC;AAC3D,+DAA+D;AAC/D,eAAO,MAAM,IAAI,EAAE,OAAO,KAAa,CAAC;AACxC,+DAA+D;AAC/D,eAAO,MAAM,IAAI,EAAE,OAAO,KAAa,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/sha1.js b/node_modules/@noble/hashes/esm/sha1.js new file mode 100644 index 0000000000000000000000000000000000000000..c8451df504668e371d2598e7e50cb802018e4076 --- /dev/null +++ b/node_modules/@noble/hashes/esm/sha1.js @@ -0,0 +1,11 @@ +/** + * SHA1 (RFC 3174) legacy hash function. + * @module + * @deprecated + */ +import { SHA1 as SHA1n, sha1 as sha1n } from "./legacy.js"; +/** @deprecated Use import from `noble/hashes/legacy` module */ +export const SHA1 = SHA1n; +/** @deprecated Use import from `noble/hashes/legacy` module */ +export const sha1 = sha1n; +//# sourceMappingURL=sha1.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/sha1.js.map b/node_modules/@noble/hashes/esm/sha1.js.map new file mode 100644 index 0000000000000000000000000000000000000000..2e28aab219a955d2f37d3d9358bad3d5c4921ecd --- /dev/null +++ b/node_modules/@noble/hashes/esm/sha1.js.map @@ -0,0 +1 @@ +{"version":3,"file":"sha1.js","sourceRoot":"","sources":["../src/sha1.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,IAAI,IAAI,KAAK,EAAE,IAAI,IAAI,KAAK,EAAE,MAAM,aAAa,CAAC;AAC3D,+DAA+D;AAC/D,MAAM,CAAC,MAAM,IAAI,GAAiB,KAAK,CAAC;AACxC,+DAA+D;AAC/D,MAAM,CAAC,MAAM,IAAI,GAAiB,KAAK,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/sha2.d.ts b/node_modules/@noble/hashes/esm/sha2.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..33f2f7f89de4d053bf2ef0266c76132daca5b23d --- /dev/null +++ b/node_modules/@noble/hashes/esm/sha2.d.ts @@ -0,0 +1,159 @@ +/** + * SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256. + * SHA256 is the fastest hash implementable in JS, even faster than Blake3. + * Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and + * [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf). + * @module + */ +import { HashMD } from './_md.ts'; +import { type CHash } from './utils.ts'; +export declare class SHA256 extends HashMD { + protected A: number; + protected B: number; + protected C: number; + protected D: number; + protected E: number; + protected F: number; + protected G: number; + protected H: number; + constructor(outputLen?: number); + protected get(): [number, number, number, number, number, number, number, number]; + protected set(A: number, B: number, C: number, D: number, E: number, F: number, G: number, H: number): void; + protected process(view: DataView, offset: number): void; + protected roundClean(): void; + destroy(): void; +} +export declare class SHA224 extends SHA256 { + protected A: number; + protected B: number; + protected C: number; + protected D: number; + protected E: number; + protected F: number; + protected G: number; + protected H: number; + constructor(); +} +export declare class SHA512 extends HashMD { + protected Ah: number; + protected Al: number; + protected Bh: number; + protected Bl: number; + protected Ch: number; + protected Cl: number; + protected Dh: number; + protected Dl: number; + protected Eh: number; + protected El: number; + protected Fh: number; + protected Fl: number; + protected Gh: number; + protected Gl: number; + protected Hh: number; + protected Hl: number; + constructor(outputLen?: number); + protected get(): [ + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number + ]; + protected set(Ah: number, Al: number, Bh: number, Bl: number, Ch: number, Cl: number, Dh: number, Dl: number, Eh: number, El: number, Fh: number, Fl: number, Gh: number, Gl: number, Hh: number, Hl: number): void; + protected process(view: DataView, offset: number): void; + protected roundClean(): void; + destroy(): void; +} +export declare class SHA384 extends SHA512 { + protected Ah: number; + protected Al: number; + protected Bh: number; + protected Bl: number; + protected Ch: number; + protected Cl: number; + protected Dh: number; + protected Dl: number; + protected Eh: number; + protected El: number; + protected Fh: number; + protected Fl: number; + protected Gh: number; + protected Gl: number; + protected Hh: number; + protected Hl: number; + constructor(); +} +export declare class SHA512_224 extends SHA512 { + protected Ah: number; + protected Al: number; + protected Bh: number; + protected Bl: number; + protected Ch: number; + protected Cl: number; + protected Dh: number; + protected Dl: number; + protected Eh: number; + protected El: number; + protected Fh: number; + protected Fl: number; + protected Gh: number; + protected Gl: number; + protected Hh: number; + protected Hl: number; + constructor(); +} +export declare class SHA512_256 extends SHA512 { + protected Ah: number; + protected Al: number; + protected Bh: number; + protected Bl: number; + protected Ch: number; + protected Cl: number; + protected Dh: number; + protected Dl: number; + protected Eh: number; + protected El: number; + protected Fh: number; + protected Fl: number; + protected Gh: number; + protected Gl: number; + protected Hh: number; + protected Hl: number; + constructor(); +} +/** + * SHA2-256 hash function from RFC 4634. + * + * It is the fastest JS hash, even faster than Blake3. + * To break sha256 using birthday attack, attackers need to try 2^128 hashes. + * BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025. + */ +export declare const sha256: CHash; +/** SHA2-224 hash function from RFC 4634 */ +export declare const sha224: CHash; +/** SHA2-512 hash function from RFC 4634. */ +export declare const sha512: CHash; +/** SHA2-384 hash function from RFC 4634. */ +export declare const sha384: CHash; +/** + * SHA2-512/256 "truncated" hash function, with improved resistance to length extension attacks. + * See the paper on [truncated SHA512](https://eprint.iacr.org/2010/548.pdf). + */ +export declare const sha512_256: CHash; +/** + * SHA2-512/224 "truncated" hash function, with improved resistance to length extension attacks. + * See the paper on [truncated SHA512](https://eprint.iacr.org/2010/548.pdf). + */ +export declare const sha512_224: CHash; +//# sourceMappingURL=sha2.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/sha2.d.ts.map b/node_modules/@noble/hashes/esm/sha2.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..4be58812d1da36f2da0b8088d1a7d012fb19fb72 --- /dev/null +++ b/node_modules/@noble/hashes/esm/sha2.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"sha2.d.ts","sourceRoot":"","sources":["../src/sha2.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAO,MAAM,EAAmD,MAAM,UAAU,CAAC;AAExF,OAAO,EAAE,KAAK,KAAK,EAA6B,MAAM,YAAY,CAAC;AAoBnE,qBAAa,MAAO,SAAQ,MAAM,CAAC,MAAM,CAAC;IAGxC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAoB;IACvC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAoB;IACvC,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,CAAC,EAAE,EAAE,MAAM,CAAmB;;CAKxC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,EAAE,KAAwD,CAAC;AAC9E,2CAA2C;AAC3C,eAAO,MAAM,MAAM,EAAE,KAAwD,CAAC;AAE9E,4CAA4C;AAC5C,eAAO,MAAM,MAAM,EAAE,KAAwD,CAAC;AAC9E,4CAA4C;AAC5C,eAAO,MAAM,MAAM,EAAE,KAAwD,CAAC;AAE9E;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,KAA4D,CAAC;AACtF;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,KAA4D,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/sha2.js b/node_modules/@noble/hashes/esm/sha2.js new file mode 100644 index 0000000000000000000000000000000000000000..9795cc5ef98a8afcb0ae1aae966a1b2b9d16e170 --- /dev/null +++ b/node_modules/@noble/hashes/esm/sha2.js @@ -0,0 +1,375 @@ +/** + * SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256. + * SHA256 is the fastest hash implementable in JS, even faster than Blake3. + * Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and + * [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf). + * @module + */ +import { Chi, HashMD, Maj, SHA224_IV, SHA256_IV, SHA384_IV, SHA512_IV } from "./_md.js"; +import * as u64 from "./_u64.js"; +import { clean, createHasher, rotr } from "./utils.js"; +/** + * Round constants: + * First 32 bits of fractional parts of the cube roots of the first 64 primes 2..311) + */ +// prettier-ignore +const SHA256_K = /* @__PURE__ */ Uint32Array.from([ + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, + 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, + 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, + 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 +]); +/** Reusable temporary buffer. "W" comes straight from spec. */ +const SHA256_W = /* @__PURE__ */ new Uint32Array(64); +export class SHA256 extends HashMD { + constructor(outputLen = 32) { + super(64, outputLen, 8, false); + // We cannot use array here since array allows indexing by variable + // which means optimizer/compiler cannot use registers. + this.A = SHA256_IV[0] | 0; + this.B = SHA256_IV[1] | 0; + this.C = SHA256_IV[2] | 0; + this.D = SHA256_IV[3] | 0; + this.E = SHA256_IV[4] | 0; + this.F = SHA256_IV[5] | 0; + this.G = SHA256_IV[6] | 0; + this.H = SHA256_IV[7] | 0; + } + get() { + const { A, B, C, D, E, F, G, H } = this; + return [A, B, C, D, E, F, G, H]; + } + // prettier-ignore + set(A, B, C, D, E, F, G, H) { + this.A = A | 0; + this.B = B | 0; + this.C = C | 0; + this.D = D | 0; + this.E = E | 0; + this.F = F | 0; + this.G = G | 0; + this.H = H | 0; + } + process(view, offset) { + // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array + for (let i = 0; i < 16; i++, offset += 4) + SHA256_W[i] = view.getUint32(offset, false); + for (let i = 16; i < 64; i++) { + const W15 = SHA256_W[i - 15]; + const W2 = SHA256_W[i - 2]; + const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3); + const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10); + SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0; + } + // Compression function main loop, 64 rounds + let { A, B, C, D, E, F, G, H } = this; + for (let i = 0; i < 64; i++) { + const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25); + const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0; + const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22); + const T2 = (sigma0 + Maj(A, B, C)) | 0; + H = G; + G = F; + F = E; + E = (D + T1) | 0; + D = C; + C = B; + B = A; + A = (T1 + T2) | 0; + } + // Add the compressed chunk to the current hash value + A = (A + this.A) | 0; + B = (B + this.B) | 0; + C = (C + this.C) | 0; + D = (D + this.D) | 0; + E = (E + this.E) | 0; + F = (F + this.F) | 0; + G = (G + this.G) | 0; + H = (H + this.H) | 0; + this.set(A, B, C, D, E, F, G, H); + } + roundClean() { + clean(SHA256_W); + } + destroy() { + this.set(0, 0, 0, 0, 0, 0, 0, 0); + clean(this.buffer); + } +} +export class SHA224 extends SHA256 { + constructor() { + super(28); + this.A = SHA224_IV[0] | 0; + this.B = SHA224_IV[1] | 0; + this.C = SHA224_IV[2] | 0; + this.D = SHA224_IV[3] | 0; + this.E = SHA224_IV[4] | 0; + this.F = SHA224_IV[5] | 0; + this.G = SHA224_IV[6] | 0; + this.H = SHA224_IV[7] | 0; + } +} +// SHA2-512 is slower than sha256 in js because u64 operations are slow. +// Round contants +// First 32 bits of the fractional parts of the cube roots of the first 80 primes 2..409 +// prettier-ignore +const K512 = /* @__PURE__ */ (() => u64.split([ + '0x428a2f98d728ae22', '0x7137449123ef65cd', '0xb5c0fbcfec4d3b2f', '0xe9b5dba58189dbbc', + '0x3956c25bf348b538', '0x59f111f1b605d019', '0x923f82a4af194f9b', '0xab1c5ed5da6d8118', + '0xd807aa98a3030242', '0x12835b0145706fbe', '0x243185be4ee4b28c', '0x550c7dc3d5ffb4e2', + '0x72be5d74f27b896f', '0x80deb1fe3b1696b1', '0x9bdc06a725c71235', '0xc19bf174cf692694', + '0xe49b69c19ef14ad2', '0xefbe4786384f25e3', '0x0fc19dc68b8cd5b5', '0x240ca1cc77ac9c65', + '0x2de92c6f592b0275', '0x4a7484aa6ea6e483', '0x5cb0a9dcbd41fbd4', '0x76f988da831153b5', + '0x983e5152ee66dfab', '0xa831c66d2db43210', '0xb00327c898fb213f', '0xbf597fc7beef0ee4', + '0xc6e00bf33da88fc2', '0xd5a79147930aa725', '0x06ca6351e003826f', '0x142929670a0e6e70', + '0x27b70a8546d22ffc', '0x2e1b21385c26c926', '0x4d2c6dfc5ac42aed', '0x53380d139d95b3df', + '0x650a73548baf63de', '0x766a0abb3c77b2a8', '0x81c2c92e47edaee6', '0x92722c851482353b', + '0xa2bfe8a14cf10364', '0xa81a664bbc423001', '0xc24b8b70d0f89791', '0xc76c51a30654be30', + '0xd192e819d6ef5218', '0xd69906245565a910', '0xf40e35855771202a', '0x106aa07032bbd1b8', + '0x19a4c116b8d2d0c8', '0x1e376c085141ab53', '0x2748774cdf8eeb99', '0x34b0bcb5e19b48a8', + '0x391c0cb3c5c95a63', '0x4ed8aa4ae3418acb', '0x5b9cca4f7763e373', '0x682e6ff3d6b2b8a3', + '0x748f82ee5defb2fc', '0x78a5636f43172f60', '0x84c87814a1f0ab72', '0x8cc702081a6439ec', + '0x90befffa23631e28', '0xa4506cebde82bde9', '0xbef9a3f7b2c67915', '0xc67178f2e372532b', + '0xca273eceea26619c', '0xd186b8c721c0c207', '0xeada7dd6cde0eb1e', '0xf57d4f7fee6ed178', + '0x06f067aa72176fba', '0x0a637dc5a2c898a6', '0x113f9804bef90dae', '0x1b710b35131c471b', + '0x28db77f523047d84', '0x32caab7b40c72493', '0x3c9ebe0a15c9bebc', '0x431d67c49c100d4c', + '0x4cc5d4becb3e42b6', '0x597f299cfc657e2a', '0x5fcb6fab3ad6faec', '0x6c44198c4a475817' +].map(n => BigInt(n))))(); +const SHA512_Kh = /* @__PURE__ */ (() => K512[0])(); +const SHA512_Kl = /* @__PURE__ */ (() => K512[1])(); +// Reusable temporary buffers +const SHA512_W_H = /* @__PURE__ */ new Uint32Array(80); +const SHA512_W_L = /* @__PURE__ */ new Uint32Array(80); +export class SHA512 extends HashMD { + constructor(outputLen = 64) { + super(128, outputLen, 16, false); + // We cannot use array here since array allows indexing by variable + // which means optimizer/compiler cannot use registers. + // h -- high 32 bits, l -- low 32 bits + this.Ah = SHA512_IV[0] | 0; + this.Al = SHA512_IV[1] | 0; + this.Bh = SHA512_IV[2] | 0; + this.Bl = SHA512_IV[3] | 0; + this.Ch = SHA512_IV[4] | 0; + this.Cl = SHA512_IV[5] | 0; + this.Dh = SHA512_IV[6] | 0; + this.Dl = SHA512_IV[7] | 0; + this.Eh = SHA512_IV[8] | 0; + this.El = SHA512_IV[9] | 0; + this.Fh = SHA512_IV[10] | 0; + this.Fl = SHA512_IV[11] | 0; + this.Gh = SHA512_IV[12] | 0; + this.Gl = SHA512_IV[13] | 0; + this.Hh = SHA512_IV[14] | 0; + this.Hl = SHA512_IV[15] | 0; + } + // prettier-ignore + get() { + const { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this; + return [Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl]; + } + // prettier-ignore + set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl) { + this.Ah = Ah | 0; + this.Al = Al | 0; + this.Bh = Bh | 0; + this.Bl = Bl | 0; + this.Ch = Ch | 0; + this.Cl = Cl | 0; + this.Dh = Dh | 0; + this.Dl = Dl | 0; + this.Eh = Eh | 0; + this.El = El | 0; + this.Fh = Fh | 0; + this.Fl = Fl | 0; + this.Gh = Gh | 0; + this.Gl = Gl | 0; + this.Hh = Hh | 0; + this.Hl = Hl | 0; + } + process(view, offset) { + // Extend the first 16 words into the remaining 64 words w[16..79] of the message schedule array + for (let i = 0; i < 16; i++, offset += 4) { + SHA512_W_H[i] = view.getUint32(offset); + SHA512_W_L[i] = view.getUint32((offset += 4)); + } + for (let i = 16; i < 80; i++) { + // s0 := (w[i-15] rightrotate 1) xor (w[i-15] rightrotate 8) xor (w[i-15] rightshift 7) + const W15h = SHA512_W_H[i - 15] | 0; + const W15l = SHA512_W_L[i - 15] | 0; + const s0h = u64.rotrSH(W15h, W15l, 1) ^ u64.rotrSH(W15h, W15l, 8) ^ u64.shrSH(W15h, W15l, 7); + const s0l = u64.rotrSL(W15h, W15l, 1) ^ u64.rotrSL(W15h, W15l, 8) ^ u64.shrSL(W15h, W15l, 7); + // s1 := (w[i-2] rightrotate 19) xor (w[i-2] rightrotate 61) xor (w[i-2] rightshift 6) + const W2h = SHA512_W_H[i - 2] | 0; + const W2l = SHA512_W_L[i - 2] | 0; + const s1h = u64.rotrSH(W2h, W2l, 19) ^ u64.rotrBH(W2h, W2l, 61) ^ u64.shrSH(W2h, W2l, 6); + const s1l = u64.rotrSL(W2h, W2l, 19) ^ u64.rotrBL(W2h, W2l, 61) ^ u64.shrSL(W2h, W2l, 6); + // SHA256_W[i] = s0 + s1 + SHA256_W[i - 7] + SHA256_W[i - 16]; + const SUMl = u64.add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16]); + const SUMh = u64.add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]); + SHA512_W_H[i] = SUMh | 0; + SHA512_W_L[i] = SUMl | 0; + } + let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this; + // Compression function main loop, 80 rounds + for (let i = 0; i < 80; i++) { + // S1 := (e rightrotate 14) xor (e rightrotate 18) xor (e rightrotate 41) + const sigma1h = u64.rotrSH(Eh, El, 14) ^ u64.rotrSH(Eh, El, 18) ^ u64.rotrBH(Eh, El, 41); + const sigma1l = u64.rotrSL(Eh, El, 14) ^ u64.rotrSL(Eh, El, 18) ^ u64.rotrBL(Eh, El, 41); + //const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0; + const CHIh = (Eh & Fh) ^ (~Eh & Gh); + const CHIl = (El & Fl) ^ (~El & Gl); + // T1 = H + sigma1 + Chi(E, F, G) + SHA512_K[i] + SHA512_W[i] + // prettier-ignore + const T1ll = u64.add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]); + const T1h = u64.add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]); + const T1l = T1ll | 0; + // S0 := (a rightrotate 28) xor (a rightrotate 34) xor (a rightrotate 39) + const sigma0h = u64.rotrSH(Ah, Al, 28) ^ u64.rotrBH(Ah, Al, 34) ^ u64.rotrBH(Ah, Al, 39); + const sigma0l = u64.rotrSL(Ah, Al, 28) ^ u64.rotrBL(Ah, Al, 34) ^ u64.rotrBL(Ah, Al, 39); + const MAJh = (Ah & Bh) ^ (Ah & Ch) ^ (Bh & Ch); + const MAJl = (Al & Bl) ^ (Al & Cl) ^ (Bl & Cl); + Hh = Gh | 0; + Hl = Gl | 0; + Gh = Fh | 0; + Gl = Fl | 0; + Fh = Eh | 0; + Fl = El | 0; + ({ h: Eh, l: El } = u64.add(Dh | 0, Dl | 0, T1h | 0, T1l | 0)); + Dh = Ch | 0; + Dl = Cl | 0; + Ch = Bh | 0; + Cl = Bl | 0; + Bh = Ah | 0; + Bl = Al | 0; + const All = u64.add3L(T1l, sigma0l, MAJl); + Ah = u64.add3H(All, T1h, sigma0h, MAJh); + Al = All | 0; + } + // Add the compressed chunk to the current hash value + ({ h: Ah, l: Al } = u64.add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0)); + ({ h: Bh, l: Bl } = u64.add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0)); + ({ h: Ch, l: Cl } = u64.add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0)); + ({ h: Dh, l: Dl } = u64.add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0)); + ({ h: Eh, l: El } = u64.add(this.Eh | 0, this.El | 0, Eh | 0, El | 0)); + ({ h: Fh, l: Fl } = u64.add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0)); + ({ h: Gh, l: Gl } = u64.add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0)); + ({ h: Hh, l: Hl } = u64.add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0)); + this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl); + } + roundClean() { + clean(SHA512_W_H, SHA512_W_L); + } + destroy() { + clean(this.buffer); + this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + } +} +export class SHA384 extends SHA512 { + constructor() { + super(48); + this.Ah = SHA384_IV[0] | 0; + this.Al = SHA384_IV[1] | 0; + this.Bh = SHA384_IV[2] | 0; + this.Bl = SHA384_IV[3] | 0; + this.Ch = SHA384_IV[4] | 0; + this.Cl = SHA384_IV[5] | 0; + this.Dh = SHA384_IV[6] | 0; + this.Dl = SHA384_IV[7] | 0; + this.Eh = SHA384_IV[8] | 0; + this.El = SHA384_IV[9] | 0; + this.Fh = SHA384_IV[10] | 0; + this.Fl = SHA384_IV[11] | 0; + this.Gh = SHA384_IV[12] | 0; + this.Gl = SHA384_IV[13] | 0; + this.Hh = SHA384_IV[14] | 0; + this.Hl = SHA384_IV[15] | 0; + } +} +/** + * Truncated SHA512/256 and SHA512/224. + * SHA512_IV is XORed with 0xa5a5a5a5a5a5a5a5, then used as "intermediary" IV of SHA512/t. + * Then t hashes string to produce result IV. + * See `test/misc/sha2-gen-iv.js`. + */ +/** SHA512/224 IV */ +const T224_IV = /* @__PURE__ */ Uint32Array.from([ + 0x8c3d37c8, 0x19544da2, 0x73e19966, 0x89dcd4d6, 0x1dfab7ae, 0x32ff9c82, 0x679dd514, 0x582f9fcf, + 0x0f6d2b69, 0x7bd44da8, 0x77e36f73, 0x04c48942, 0x3f9d85a8, 0x6a1d36c8, 0x1112e6ad, 0x91d692a1, +]); +/** SHA512/256 IV */ +const T256_IV = /* @__PURE__ */ Uint32Array.from([ + 0x22312194, 0xfc2bf72c, 0x9f555fa3, 0xc84c64c2, 0x2393b86b, 0x6f53b151, 0x96387719, 0x5940eabd, + 0x96283ee2, 0xa88effe3, 0xbe5e1e25, 0x53863992, 0x2b0199fc, 0x2c85b8aa, 0x0eb72ddc, 0x81c52ca2, +]); +export class SHA512_224 extends SHA512 { + constructor() { + super(28); + this.Ah = T224_IV[0] | 0; + this.Al = T224_IV[1] | 0; + this.Bh = T224_IV[2] | 0; + this.Bl = T224_IV[3] | 0; + this.Ch = T224_IV[4] | 0; + this.Cl = T224_IV[5] | 0; + this.Dh = T224_IV[6] | 0; + this.Dl = T224_IV[7] | 0; + this.Eh = T224_IV[8] | 0; + this.El = T224_IV[9] | 0; + this.Fh = T224_IV[10] | 0; + this.Fl = T224_IV[11] | 0; + this.Gh = T224_IV[12] | 0; + this.Gl = T224_IV[13] | 0; + this.Hh = T224_IV[14] | 0; + this.Hl = T224_IV[15] | 0; + } +} +export class SHA512_256 extends SHA512 { + constructor() { + super(32); + this.Ah = T256_IV[0] | 0; + this.Al = T256_IV[1] | 0; + this.Bh = T256_IV[2] | 0; + this.Bl = T256_IV[3] | 0; + this.Ch = T256_IV[4] | 0; + this.Cl = T256_IV[5] | 0; + this.Dh = T256_IV[6] | 0; + this.Dl = T256_IV[7] | 0; + this.Eh = T256_IV[8] | 0; + this.El = T256_IV[9] | 0; + this.Fh = T256_IV[10] | 0; + this.Fl = T256_IV[11] | 0; + this.Gh = T256_IV[12] | 0; + this.Gl = T256_IV[13] | 0; + this.Hh = T256_IV[14] | 0; + this.Hl = T256_IV[15] | 0; + } +} +/** + * SHA2-256 hash function from RFC 4634. + * + * It is the fastest JS hash, even faster than Blake3. + * To break sha256 using birthday attack, attackers need to try 2^128 hashes. + * BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025. + */ +export const sha256 = /* @__PURE__ */ createHasher(() => new SHA256()); +/** SHA2-224 hash function from RFC 4634 */ +export const sha224 = /* @__PURE__ */ createHasher(() => new SHA224()); +/** SHA2-512 hash function from RFC 4634. */ +export const sha512 = /* @__PURE__ */ createHasher(() => new SHA512()); +/** SHA2-384 hash function from RFC 4634. */ +export const sha384 = /* @__PURE__ */ createHasher(() => new SHA384()); +/** + * SHA2-512/256 "truncated" hash function, with improved resistance to length extension attacks. + * See the paper on [truncated SHA512](https://eprint.iacr.org/2010/548.pdf). + */ +export const sha512_256 = /* @__PURE__ */ createHasher(() => new SHA512_256()); +/** + * SHA2-512/224 "truncated" hash function, with improved resistance to length extension attacks. + * See the paper on [truncated SHA512](https://eprint.iacr.org/2010/548.pdf). + */ +export const sha512_224 = /* @__PURE__ */ createHasher(() => new SHA512_224()); +//# sourceMappingURL=sha2.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/sha2.js.map b/node_modules/@noble/hashes/esm/sha2.js.map new file mode 100644 index 0000000000000000000000000000000000000000..f3fc03233ed5ff0bdeab850a9372ba4767c4eb90 --- /dev/null +++ b/node_modules/@noble/hashes/esm/sha2.js.map @@ -0,0 +1 @@ +{"version":3,"file":"sha2.js","sourceRoot":"","sources":["../src/sha2.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACxF,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AACjC,OAAO,EAAc,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE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,GAAW,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;QAC7B,OAAE,GAAW,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAIvC,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,MAAM,GAAU,eAAe,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC;AAC9E,2CAA2C;AAC3C,MAAM,CAAC,MAAM,MAAM,GAAU,eAAe,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC;AAE9E,4CAA4C;AAC5C,MAAM,CAAC,MAAM,MAAM,GAAU,eAAe,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC;AAC9E,4CAA4C;AAC5C,MAAM,CAAC,MAAM,MAAM,GAAU,eAAe,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC;AAE9E;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAU,eAAe,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,IAAI,UAAU,EAAE,CAAC,CAAC;AACtF;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAU,eAAe,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,IAAI,UAAU,EAAE,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/sha256.d.ts b/node_modules/@noble/hashes/esm/sha256.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ed04fe88f27481e2b4ce5b770b14549d3024e986 --- /dev/null +++ b/node_modules/@noble/hashes/esm/sha256.d.ts @@ -0,0 +1,20 @@ +/** + * SHA2-256 a.k.a. sha256. In JS, it is the fastest hash, even faster than Blake3. + * + * To break sha256 using birthday attack, attackers need to try 2^128 hashes. + * BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025. + * + * Check out [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf). + * @module + * @deprecated + */ +import { SHA224 as SHA224n, sha224 as sha224n, SHA256 as SHA256n, sha256 as sha256n } from './sha2.ts'; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export declare const SHA256: typeof SHA256n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export declare const sha256: typeof sha256n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export declare const SHA224: typeof SHA224n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export declare const sha224: typeof sha224n; +//# sourceMappingURL=sha256.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/sha256.d.ts.map b/node_modules/@noble/hashes/esm/sha256.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..2912e85bf2f4e2da552c3ca957d03f6193518599 --- /dev/null +++ b/node_modules/@noble/hashes/esm/sha256.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"sha256.d.ts","sourceRoot":"","sources":["../src/sha256.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,MAAM,IAAI,OAAO,EACjB,MAAM,IAAI,OAAO,EACjB,MAAM,IAAI,OAAO,EACjB,MAAM,IAAI,OAAO,EAClB,MAAM,WAAW,CAAC;AACnB,6DAA6D;AAC7D,eAAO,MAAM,MAAM,EAAE,OAAO,OAAiB,CAAC;AAC9C,6DAA6D;AAC7D,eAAO,MAAM,MAAM,EAAE,OAAO,OAAiB,CAAC;AAC9C,6DAA6D;AAC7D,eAAO,MAAM,MAAM,EAAE,OAAO,OAAiB,CAAC;AAC9C,6DAA6D;AAC7D,eAAO,MAAM,MAAM,EAAE,OAAO,OAAiB,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/sha256.js b/node_modules/@noble/hashes/esm/sha256.js new file mode 100644 index 0000000000000000000000000000000000000000..6bdee7ce8639667f6e6a0bb56795ed8b8c1d6f86 --- /dev/null +++ b/node_modules/@noble/hashes/esm/sha256.js @@ -0,0 +1,20 @@ +/** + * SHA2-256 a.k.a. sha256. In JS, it is the fastest hash, even faster than Blake3. + * + * To break sha256 using birthday attack, attackers need to try 2^128 hashes. + * BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025. + * + * Check out [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf). + * @module + * @deprecated + */ +import { SHA224 as SHA224n, sha224 as sha224n, SHA256 as SHA256n, sha256 as sha256n, } from "./sha2.js"; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export const SHA256 = SHA256n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export const sha256 = sha256n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export const SHA224 = SHA224n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export const sha224 = sha224n; +//# sourceMappingURL=sha256.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/sha256.js.map b/node_modules/@noble/hashes/esm/sha256.js.map new file mode 100644 index 0000000000000000000000000000000000000000..6df7235b16060b7da3193658e2c53b2482440da6 --- /dev/null +++ b/node_modules/@noble/hashes/esm/sha256.js.map @@ -0,0 +1 @@ +{"version":3,"file":"sha256.js","sourceRoot":"","sources":["../src/sha256.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,MAAM,IAAI,OAAO,EACjB,MAAM,IAAI,OAAO,EACjB,MAAM,IAAI,OAAO,EACjB,MAAM,IAAI,OAAO,GAClB,MAAM,WAAW,CAAC;AACnB,6DAA6D;AAC7D,MAAM,CAAC,MAAM,MAAM,GAAmB,OAAO,CAAC;AAC9C,6DAA6D;AAC7D,MAAM,CAAC,MAAM,MAAM,GAAmB,OAAO,CAAC;AAC9C,6DAA6D;AAC7D,MAAM,CAAC,MAAM,MAAM,GAAmB,OAAO,CAAC;AAC9C,6DAA6D;AAC7D,MAAM,CAAC,MAAM,MAAM,GAAmB,OAAO,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/sha3-addons.d.ts b/node_modules/@noble/hashes/esm/sha3-addons.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5bd2fe62d0467909adccaf08f4961d2135d7a083 --- /dev/null +++ b/node_modules/@noble/hashes/esm/sha3-addons.d.ts @@ -0,0 +1,142 @@ +/** + * SHA3 (keccak) addons. + * + * * Full [NIST SP 800-185](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-185.pdf): + * cSHAKE, KMAC, TupleHash, ParallelHash + XOF variants + * * Reduced-round Keccak [(draft)](https://datatracker.ietf.org/doc/draft-irtf-cfrg-kangarootwelve/): + * * 🦘 K12 aka KangarooTwelve + * * M14 aka MarsupilamiFourteen + * * TurboSHAKE + * * KeccakPRG: Pseudo-random generator based on Keccak [(pdf)](https://keccak.team/files/CSF-0.1.pdf) + * @module + */ +import { Keccak, type ShakeOpts } from './sha3.ts'; +import { type CHashO, type CHashXO, Hash, type HashXOF, type Input } from './utils.ts'; +export type cShakeOpts = ShakeOpts & { + personalization?: Input; + NISTfn?: Input; +}; +export type ICShake = { + (msg: Input, opts?: cShakeOpts): Uint8Array; + outputLen: number; + blockLen: number; + create(opts: cShakeOpts): HashXOF; +}; +export type ITupleHash = { + (messages: Input[], opts?: cShakeOpts): Uint8Array; + create(opts?: cShakeOpts): TupleHash; +}; +export type IParHash = { + (message: Input, opts?: ParallelOpts): Uint8Array; + create(opts?: ParallelOpts): ParallelHash; +}; +export declare const cshake128: ICShake; +export declare const cshake256: ICShake; +export declare class KMAC extends Keccak implements HashXOF { + constructor(blockLen: number, outputLen: number, enableXOF: boolean, key: Input, opts?: cShakeOpts); + protected finish(): void; + _cloneInto(to?: KMAC): KMAC; + clone(): KMAC; +} +export declare const kmac128: { + (key: Input, message: Input, opts?: cShakeOpts): Uint8Array; + create(key: Input, opts?: cShakeOpts): KMAC; +}; +export declare const kmac256: { + (key: Input, message: Input, opts?: cShakeOpts): Uint8Array; + create(key: Input, opts?: cShakeOpts): KMAC; +}; +export declare const kmac128xof: { + (key: Input, message: Input, opts?: cShakeOpts): Uint8Array; + create(key: Input, opts?: cShakeOpts): KMAC; +}; +export declare const kmac256xof: { + (key: Input, message: Input, opts?: cShakeOpts): Uint8Array; + create(key: Input, opts?: cShakeOpts): KMAC; +}; +export declare class TupleHash extends Keccak implements HashXOF { + constructor(blockLen: number, outputLen: number, enableXOF: boolean, opts?: cShakeOpts); + protected finish(): void; + _cloneInto(to?: TupleHash): TupleHash; + clone(): TupleHash; +} +/** 128-bit TupleHASH. */ +export declare const tuplehash128: ITupleHash; +/** 256-bit TupleHASH. */ +export declare const tuplehash256: ITupleHash; +/** 128-bit TupleHASH XOF. */ +export declare const tuplehash128xof: ITupleHash; +/** 256-bit TupleHASH XOF. */ +export declare const tuplehash256xof: ITupleHash; +type ParallelOpts = cShakeOpts & { + blockLen?: number; +}; +export declare class ParallelHash extends Keccak implements HashXOF { + private leafHash?; + protected leafCons: () => Hash; + private chunkPos; + private chunksDone; + private chunkLen; + constructor(blockLen: number, outputLen: number, leafCons: () => Hash, enableXOF: boolean, opts?: ParallelOpts); + protected finish(): void; + _cloneInto(to?: ParallelHash): ParallelHash; + destroy(): void; + clone(): ParallelHash; +} +/** 128-bit ParallelHash. In JS, it is not parallel. */ +export declare const parallelhash128: IParHash; +/** 256-bit ParallelHash. In JS, it is not parallel. */ +export declare const parallelhash256: IParHash; +/** 128-bit ParallelHash XOF. In JS, it is not parallel. */ +export declare const parallelhash128xof: IParHash; +/** 256-bit ParallelHash. In JS, it is not parallel. */ +export declare const parallelhash256xof: IParHash; +export type TurboshakeOpts = ShakeOpts & { + D?: number; +}; +/** TurboSHAKE 128-bit: reduced 12-round keccak. */ +export declare const turboshake128: CHashXO; +/** TurboSHAKE 256-bit: reduced 12-round keccak. */ +export declare const turboshake256: CHashXO; +export type KangarooOpts = { + dkLen?: number; + personalization?: Input; +}; +export declare class KangarooTwelve extends Keccak implements HashXOF { + readonly chunkLen = 8192; + private leafHash?; + protected leafLen: number; + private personalization; + private chunkPos; + private chunksDone; + constructor(blockLen: number, leafLen: number, outputLen: number, rounds: number, opts: KangarooOpts); + update(data: Input): this; + protected finish(): void; + destroy(): void; + _cloneInto(to?: KangarooTwelve): KangarooTwelve; + clone(): KangarooTwelve; +} +/** KangarooTwelve: reduced 12-round keccak. */ +export declare const k12: CHashO; +/** MarsupilamiFourteen: reduced 14-round keccak. */ +export declare const m14: CHashO; +/** + * More at https://github.com/XKCP/XKCP/tree/master/lib/high/Keccak/PRG. + */ +export declare class KeccakPRG extends Keccak { + protected rate: number; + constructor(capacity: number); + keccak(): void; + update(data: Input): this; + feed(data: Input): this; + protected finish(): void; + digestInto(_out: Uint8Array): Uint8Array; + fetch(bytes: number): Uint8Array; + forget(): void; + _cloneInto(to?: KeccakPRG): KeccakPRG; + clone(): KeccakPRG; +} +/** KeccakPRG: Pseudo-random generator based on Keccak. https://keccak.team/files/CSF-0.1.pdf */ +export declare const keccakprg: (capacity?: number) => KeccakPRG; +export {}; +//# sourceMappingURL=sha3-addons.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/sha3-addons.d.ts.map b/node_modules/@noble/hashes/esm/sha3-addons.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..4f4b11b654b88a7a4d699419f99abdd07e2cb40d --- /dev/null +++ b/node_modules/@noble/hashes/esm/sha3-addons.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"sha3-addons.d.ts","sourceRoot":"","sources":["../src/sha3-addons.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,MAAM,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAGL,KAAK,MAAM,EACX,KAAK,OAAO,EAGZ,IAAI,EACJ,KAAK,OAAO,EACZ,KAAK,KAAK,EAGX,MAAM,YAAY,CAAC;AAoCpB,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG;IAAE,eAAe,CAAC,EAAE,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AChG,eAAO,MAAM,SAAS,GAAI,iBAAc,KAAG,SAAoC,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/sha3-addons.js b/node_modules/@noble/hashes/esm/sha3-addons.js new file mode 100644 index 0000000000000000000000000000000000000000..ec9c664cfce365b05449a7c7c6180e143fd015dc --- /dev/null +++ b/node_modules/@noble/hashes/esm/sha3-addons.js @@ -0,0 +1,393 @@ +/** + * SHA3 (keccak) addons. + * + * * Full [NIST SP 800-185](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-185.pdf): + * cSHAKE, KMAC, TupleHash, ParallelHash + XOF variants + * * Reduced-round Keccak [(draft)](https://datatracker.ietf.org/doc/draft-irtf-cfrg-kangarootwelve/): + * * 🦘 K12 aka KangarooTwelve + * * M14 aka MarsupilamiFourteen + * * TurboSHAKE + * * KeccakPRG: Pseudo-random generator based on Keccak [(pdf)](https://keccak.team/files/CSF-0.1.pdf) + * @module + */ +import { Keccak } from "./sha3.js"; +import { abytes, anumber, createOptHasher, createXOFer, Hash, toBytes, u32, } from "./utils.js"; +// cSHAKE && KMAC (NIST SP800-185) +const _8n = BigInt(8); +const _ffn = BigInt(0xff); +// NOTE: it is safe to use bigints here, since they used only for length encoding (not actual data). +// We use bigints in sha256 for lengths too. +function leftEncode(n) { + n = BigInt(n); + const res = [Number(n & _ffn)]; + n >>= _8n; + for (; n > 0; n >>= _8n) + res.unshift(Number(n & _ffn)); + res.unshift(res.length); + return new Uint8Array(res); +} +function rightEncode(n) { + n = BigInt(n); + const res = [Number(n & _ffn)]; + n >>= _8n; + for (; n > 0; n >>= _8n) + res.unshift(Number(n & _ffn)); + res.push(res.length); + return new Uint8Array(res); +} +function chooseLen(opts, outputLen) { + return opts.dkLen === undefined ? outputLen : opts.dkLen; +} +const abytesOrZero = (buf) => { + if (buf === undefined) + return Uint8Array.of(); + return toBytes(buf); +}; +// NOTE: second modulo is necessary since we don't need to add padding if current element takes whole block +const getPadding = (len, block) => new Uint8Array((block - (len % block)) % block); +// Personalization +function cshakePers(hash, opts = {}) { + if (!opts || (!opts.personalization && !opts.NISTfn)) + return hash; + // Encode and pad inplace to avoid unneccesary memory copies/slices (so we don't need to zero them later) + // bytepad(encode_string(N) || encode_string(S), 168) + const blockLenBytes = leftEncode(hash.blockLen); + const fn = abytesOrZero(opts.NISTfn); + const fnLen = leftEncode(_8n * BigInt(fn.length)); // length in bits + const pers = abytesOrZero(opts.personalization); + const persLen = leftEncode(_8n * BigInt(pers.length)); // length in bits + if (!fn.length && !pers.length) + return hash; + hash.suffix = 0x04; + hash.update(blockLenBytes).update(fnLen).update(fn).update(persLen).update(pers); + let totalLen = blockLenBytes.length + fnLen.length + fn.length + persLen.length + pers.length; + hash.update(getPadding(totalLen, hash.blockLen)); + return hash; +} +const gencShake = (suffix, blockLen, outputLen) => createXOFer((opts = {}) => cshakePers(new Keccak(blockLen, suffix, chooseLen(opts, outputLen), true), opts)); +export const cshake128 = /* @__PURE__ */ (() => gencShake(0x1f, 168, 128 / 8))(); +export const cshake256 = /* @__PURE__ */ (() => gencShake(0x1f, 136, 256 / 8))(); +export class KMAC extends Keccak { + constructor(blockLen, outputLen, enableXOF, key, opts = {}) { + super(blockLen, 0x1f, outputLen, enableXOF); + cshakePers(this, { NISTfn: 'KMAC', personalization: opts.personalization }); + key = toBytes(key); + abytes(key); + // 1. newX = bytepad(encode_string(K), 168) || X || right_encode(L). + const blockLenBytes = leftEncode(this.blockLen); + const keyLen = leftEncode(_8n * BigInt(key.length)); + this.update(blockLenBytes).update(keyLen).update(key); + const totalLen = blockLenBytes.length + keyLen.length + key.length; + this.update(getPadding(totalLen, this.blockLen)); + } + finish() { + if (!this.finished) + this.update(rightEncode(this.enableXOF ? 0 : _8n * BigInt(this.outputLen))); // outputLen in bits + super.finish(); + } + _cloneInto(to) { + // Create new instance without calling constructor since key already in state and we don't know it. + // Force "to" to be instance of KMAC instead of Sha3. + if (!to) { + to = Object.create(Object.getPrototypeOf(this), {}); + to.state = this.state.slice(); + to.blockLen = this.blockLen; + to.state32 = u32(to.state); + } + return super._cloneInto(to); + } + clone() { + return this._cloneInto(); + } +} +function genKmac(blockLen, outputLen, xof = false) { + const kmac = (key, message, opts) => kmac.create(key, opts).update(message).digest(); + kmac.create = (key, opts = {}) => new KMAC(blockLen, chooseLen(opts, outputLen), xof, key, opts); + return kmac; +} +export const kmac128 = /* @__PURE__ */ (() => genKmac(168, 128 / 8))(); +export const kmac256 = /* @__PURE__ */ (() => genKmac(136, 256 / 8))(); +export const kmac128xof = /* @__PURE__ */ (() => genKmac(168, 128 / 8, true))(); +export const kmac256xof = /* @__PURE__ */ (() => genKmac(136, 256 / 8, true))(); +// TupleHash +// Usage: tuple(['ab', 'cd']) != tuple(['a', 'bcd']) +export class TupleHash extends Keccak { + constructor(blockLen, outputLen, enableXOF, opts = {}) { + super(blockLen, 0x1f, outputLen, enableXOF); + cshakePers(this, { NISTfn: 'TupleHash', personalization: opts.personalization }); + // Change update after cshake processed + this.update = (data) => { + data = toBytes(data); + abytes(data); + super.update(leftEncode(_8n * BigInt(data.length))); + super.update(data); + return this; + }; + } + finish() { + if (!this.finished) + super.update(rightEncode(this.enableXOF ? 0 : _8n * BigInt(this.outputLen))); // outputLen in bits + super.finish(); + } + _cloneInto(to) { + to || (to = new TupleHash(this.blockLen, this.outputLen, this.enableXOF)); + return super._cloneInto(to); + } + clone() { + return this._cloneInto(); + } +} +function genTuple(blockLen, outputLen, xof = false) { + const tuple = (messages, opts) => { + const h = tuple.create(opts); + for (const msg of messages) + h.update(msg); + return h.digest(); + }; + tuple.create = (opts = {}) => new TupleHash(blockLen, chooseLen(opts, outputLen), xof, opts); + return tuple; +} +/** 128-bit TupleHASH. */ +export const tuplehash128 = /* @__PURE__ */ (() => genTuple(168, 128 / 8))(); +/** 256-bit TupleHASH. */ +export const tuplehash256 = /* @__PURE__ */ (() => genTuple(136, 256 / 8))(); +/** 128-bit TupleHASH XOF. */ +export const tuplehash128xof = /* @__PURE__ */ (() => genTuple(168, 128 / 8, true))(); +/** 256-bit TupleHASH XOF. */ +export const tuplehash256xof = /* @__PURE__ */ (() => genTuple(136, 256 / 8, true))(); +export class ParallelHash extends Keccak { + constructor(blockLen, outputLen, leafCons, enableXOF, opts = {}) { + super(blockLen, 0x1f, outputLen, enableXOF); + this.chunkPos = 0; // Position of current block in chunk + this.chunksDone = 0; // How many chunks we already have + cshakePers(this, { NISTfn: 'ParallelHash', personalization: opts.personalization }); + this.leafCons = leafCons; + let { blockLen: B } = opts; + B || (B = 8); + anumber(B); + this.chunkLen = B; + super.update(leftEncode(B)); + // Change update after cshake processed + this.update = (data) => { + data = toBytes(data); + abytes(data); + const { chunkLen, leafCons } = this; + for (let pos = 0, len = data.length; pos < len;) { + if (this.chunkPos == chunkLen || !this.leafHash) { + if (this.leafHash) { + super.update(this.leafHash.digest()); + this.chunksDone++; + } + this.leafHash = leafCons(); + this.chunkPos = 0; + } + const take = Math.min(chunkLen - this.chunkPos, len - pos); + this.leafHash.update(data.subarray(pos, pos + take)); + this.chunkPos += take; + pos += take; + } + return this; + }; + } + finish() { + if (this.finished) + return; + if (this.leafHash) { + super.update(this.leafHash.digest()); + this.chunksDone++; + } + super.update(rightEncode(this.chunksDone)); + super.update(rightEncode(this.enableXOF ? 0 : _8n * BigInt(this.outputLen))); // outputLen in bits + super.finish(); + } + _cloneInto(to) { + to || (to = new ParallelHash(this.blockLen, this.outputLen, this.leafCons, this.enableXOF)); + if (this.leafHash) + to.leafHash = this.leafHash._cloneInto(to.leafHash); + to.chunkPos = this.chunkPos; + to.chunkLen = this.chunkLen; + to.chunksDone = this.chunksDone; + return super._cloneInto(to); + } + destroy() { + super.destroy.call(this); + if (this.leafHash) + this.leafHash.destroy(); + } + clone() { + return this._cloneInto(); + } +} +function genPrl(blockLen, outputLen, leaf, xof = false) { + const parallel = (message, opts) => parallel.create(opts).update(message).digest(); + parallel.create = (opts = {}) => new ParallelHash(blockLen, chooseLen(opts, outputLen), () => leaf.create({ dkLen: 2 * outputLen }), xof, opts); + return parallel; +} +/** 128-bit ParallelHash. In JS, it is not parallel. */ +export const parallelhash128 = /* @__PURE__ */ (() => genPrl(168, 128 / 8, cshake128))(); +/** 256-bit ParallelHash. In JS, it is not parallel. */ +export const parallelhash256 = /* @__PURE__ */ (() => genPrl(136, 256 / 8, cshake256))(); +/** 128-bit ParallelHash XOF. In JS, it is not parallel. */ +export const parallelhash128xof = /* @__PURE__ */ (() => genPrl(168, 128 / 8, cshake128, true))(); +/** 256-bit ParallelHash. In JS, it is not parallel. */ +export const parallelhash256xof = /* @__PURE__ */ (() => genPrl(136, 256 / 8, cshake256, true))(); +const genTurboshake = (blockLen, outputLen) => createXOFer((opts = {}) => { + const D = opts.D === undefined ? 0x1f : opts.D; + // Section 2.1 of https://datatracker.ietf.org/doc/draft-irtf-cfrg-kangarootwelve/ + if (!Number.isSafeInteger(D) || D < 0x01 || D > 0x7f) + throw new Error('invalid domain separation byte must be 0x01..0x7f, got: ' + D); + return new Keccak(blockLen, D, opts.dkLen === undefined ? outputLen : opts.dkLen, true, 12); +}); +/** TurboSHAKE 128-bit: reduced 12-round keccak. */ +export const turboshake128 = /* @__PURE__ */ genTurboshake(168, 256 / 8); +/** TurboSHAKE 256-bit: reduced 12-round keccak. */ +export const turboshake256 = /* @__PURE__ */ genTurboshake(136, 512 / 8); +// Kangaroo +// Same as NIST rightEncode, but returns [0] for zero string +function rightEncodeK12(n) { + n = BigInt(n); + const res = []; + for (; n > 0; n >>= _8n) + res.unshift(Number(n & _ffn)); + res.push(res.length); + return Uint8Array.from(res); +} +const EMPTY_BUFFER = /* @__PURE__ */ Uint8Array.of(); +export class KangarooTwelve extends Keccak { + constructor(blockLen, leafLen, outputLen, rounds, opts) { + super(blockLen, 0x07, outputLen, true, rounds); + this.chunkLen = 8192; + this.chunkPos = 0; // Position of current block in chunk + this.chunksDone = 0; // How many chunks we already have + this.leafLen = leafLen; + this.personalization = abytesOrZero(opts.personalization); + } + update(data) { + data = toBytes(data); + abytes(data); + const { chunkLen, blockLen, leafLen, rounds } = this; + for (let pos = 0, len = data.length; pos < len;) { + if (this.chunkPos == chunkLen) { + if (this.leafHash) + super.update(this.leafHash.digest()); + else { + this.suffix = 0x06; // Its safe to change suffix here since its used only in digest() + super.update(Uint8Array.from([3, 0, 0, 0, 0, 0, 0, 0])); + } + this.leafHash = new Keccak(blockLen, 0x0b, leafLen, false, rounds); + this.chunksDone++; + this.chunkPos = 0; + } + const take = Math.min(chunkLen - this.chunkPos, len - pos); + const chunk = data.subarray(pos, pos + take); + if (this.leafHash) + this.leafHash.update(chunk); + else + super.update(chunk); + this.chunkPos += take; + pos += take; + } + return this; + } + finish() { + if (this.finished) + return; + const { personalization } = this; + this.update(personalization).update(rightEncodeK12(personalization.length)); + // Leaf hash + if (this.leafHash) { + super.update(this.leafHash.digest()); + super.update(rightEncodeK12(this.chunksDone)); + super.update(Uint8Array.from([0xff, 0xff])); + } + super.finish.call(this); + } + destroy() { + super.destroy.call(this); + if (this.leafHash) + this.leafHash.destroy(); + // We cannot zero personalization buffer since it is user provided and we don't want to mutate user input + this.personalization = EMPTY_BUFFER; + } + _cloneInto(to) { + const { blockLen, leafLen, leafHash, outputLen, rounds } = this; + to || (to = new KangarooTwelve(blockLen, leafLen, outputLen, rounds, {})); + super._cloneInto(to); + if (leafHash) + to.leafHash = leafHash._cloneInto(to.leafHash); + to.personalization.set(this.personalization); + to.leafLen = this.leafLen; + to.chunkPos = this.chunkPos; + to.chunksDone = this.chunksDone; + return to; + } + clone() { + return this._cloneInto(); + } +} +/** KangarooTwelve: reduced 12-round keccak. */ +export const k12 = /* @__PURE__ */ (() => createOptHasher((opts = {}) => new KangarooTwelve(168, 32, chooseLen(opts, 32), 12, opts)))(); +/** MarsupilamiFourteen: reduced 14-round keccak. */ +export const m14 = /* @__PURE__ */ (() => createOptHasher((opts = {}) => new KangarooTwelve(136, 64, chooseLen(opts, 64), 14, opts)))(); +/** + * More at https://github.com/XKCP/XKCP/tree/master/lib/high/Keccak/PRG. + */ +export class KeccakPRG extends Keccak { + constructor(capacity) { + anumber(capacity); + // Rho should be full bytes + if (capacity < 0 || capacity > 1600 - 10 || (1600 - capacity - 2) % 8) + throw new Error('invalid capacity'); + // blockLen = rho in bytes + super((1600 - capacity - 2) / 8, 0, 0, true); + this.rate = 1600 - capacity; + this.posOut = Math.floor((this.rate + 7) / 8); + } + keccak() { + // Duplex padding + this.state[this.pos] ^= 0x01; + this.state[this.blockLen] ^= 0x02; // Rho is full bytes + super.keccak(); + this.pos = 0; + this.posOut = 0; + } + update(data) { + super.update(data); + this.posOut = this.blockLen; + return this; + } + feed(data) { + return this.update(data); + } + finish() { } + digestInto(_out) { + throw new Error('digest is not allowed, use .fetch instead'); + } + fetch(bytes) { + return this.xof(bytes); + } + // Ensure irreversibility (even if state leaked previous outputs cannot be computed) + forget() { + if (this.rate < 1600 / 2 + 1) + throw new Error('rate is too low to use .forget()'); + this.keccak(); + for (let i = 0; i < this.blockLen; i++) + this.state[i] = 0; + this.pos = this.blockLen; + this.keccak(); + this.posOut = this.blockLen; + } + _cloneInto(to) { + const { rate } = this; + to || (to = new KeccakPRG(1600 - rate)); + super._cloneInto(to); + to.rate = rate; + return to; + } + clone() { + return this._cloneInto(); + } +} +/** KeccakPRG: Pseudo-random generator based on Keccak. https://keccak.team/files/CSF-0.1.pdf */ +export const keccakprg = (capacity = 254) => new KeccakPRG(capacity); +//# sourceMappingURL=sha3-addons.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/sha3-addons.js.map b/node_modules/@noble/hashes/esm/sha3-addons.js.map new file mode 100644 index 0000000000000000000000000000000000000000..6587b0bb4a3910ec1d0eb27cf0470ba284b36ac2 --- /dev/null +++ b/node_modules/@noble/hashes/esm/sha3-addons.js.map @@ -0,0 +1 @@ +{"version":3,"file":"sha3-addons.js","sourceRoot":"","sources":["../src/sha3-addons.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,MAAM,EAAkB,MA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,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;QAClF,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,EAAE;YAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAC1D,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC;IAC9B,CAAC;IACD,UAAU,CAAC,EAAc;QACvB,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QACtB,EAAE,KAAF,EAAE,GAAK,IAAI,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC,EAAC;QAClC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QACrB,EAAE,CAAC,IAAI,GAAG,IAAI,CAAC;QACf,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,KAAK;QACH,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;IAC3B,CAAC;CACF;AAED,gGAAgG;AAChG,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,QAAQ,GAAG,GAAG,EAAa,EAAE,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/sha3.d.ts b/node_modules/@noble/hashes/esm/sha3.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9df47b19f9f2f343ee7edf5c2b1e2cc6ed5d542d --- /dev/null +++ b/node_modules/@noble/hashes/esm/sha3.d.ts @@ -0,0 +1,53 @@ +import { Hash, type CHash, type CHashXO, type HashXOF, type Input } from './utils.ts'; +/** `keccakf1600` internal function, additionally allows to adjust round count. */ +export declare function keccakP(s: Uint32Array, rounds?: number): void; +/** Keccak sponge function. */ +export declare class Keccak extends Hash implements HashXOF { + protected state: Uint8Array; + protected pos: number; + protected posOut: number; + protected finished: boolean; + protected state32: Uint32Array; + protected destroyed: boolean; + blockLen: number; + suffix: number; + outputLen: number; + protected enableXOF: boolean; + protected rounds: number; + constructor(blockLen: number, suffix: number, outputLen: number, enableXOF?: boolean, rounds?: number); + clone(): Keccak; + protected keccak(): void; + update(data: Input): this; + protected finish(): void; + protected writeInto(out: Uint8Array): Uint8Array; + xofInto(out: Uint8Array): Uint8Array; + xof(bytes: number): Uint8Array; + digestInto(out: Uint8Array): Uint8Array; + digest(): Uint8Array; + destroy(): void; + _cloneInto(to?: Keccak): Keccak; +} +/** SHA3-224 hash function. */ +export declare const sha3_224: CHash; +/** SHA3-256 hash function. Different from keccak-256. */ +export declare const sha3_256: CHash; +/** SHA3-384 hash function. */ +export declare const sha3_384: CHash; +/** SHA3-512 hash function. */ +export declare const sha3_512: CHash; +/** keccak-224 hash function. */ +export declare const keccak_224: CHash; +/** keccak-256 hash function. Different from SHA3-256. */ +export declare const keccak_256: CHash; +/** keccak-384 hash function. */ +export declare const keccak_384: CHash; +/** keccak-512 hash function. */ +export declare const keccak_512: CHash; +export type ShakeOpts = { + dkLen?: number; +}; +/** SHAKE128 XOF with 128-bit security. */ +export declare const shake128: CHashXO; +/** SHAKE256 XOF with 256-bit security. */ +export declare const shake256: CHashXO; +//# sourceMappingURL=sha3.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/sha3.d.ts.map b/node_modules/@noble/hashes/esm/sha3.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..602413383ec4cf9ddafadb1660897e6c9e35b5d8 --- /dev/null +++ b/node_modules/@noble/hashes/esm/sha3.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"sha3.d.ts","sourceRoot":"","sources":["../src/sha3.ts"],"names":[],"mappings":"AAaA,OAAO,EAE6B,IAAI,EAGtC,KAAK,KAAK,EAAE,KAAK,OAAO,E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AAC9B,eAAO,MAAM,QAAQ,EAAE,KAAyD,CAAC;AACjF,yDAAyD;AACzD,eAAO,MAAM,QAAQ,EAAE,KAAyD,CAAC;AACjF,8BAA8B;AAC9B,eAAO,MAAM,QAAQ,EAAE,KAAyD,CAAC;AACjF,8BAA8B;AAC9B,eAAO,MAAM,QAAQ,EAAE,KAAwD,CAAC;AAEhF,gCAAgC;AAChC,eAAO,MAAM,UAAU,EAAE,KAAyD,CAAC;AACnF,yDAAyD;AACzD,eAAO,MAAM,UAAU,EAAE,KAAyD,CAAC;AACnF,gCAAgC;AAChC,eAAO,MAAM,UAAU,EAAE,KAAyD,CAAC;AACnF,gCAAgC;AAChC,eAAO,MAAM,UAAU,EAAE,KAAwD,CAAC;AAElF,MAAM,MAAM,SAAS,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAQ3C,0CAA0C;AAC1C,eAAO,MAAM,QAAQ,EAAE,OAAgE,CAAC;AACxF,0CAA0C;AAC1C,eAAO,MAAM,QAAQ,EAAE,OAAgE,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/sha3.js b/node_modules/@noble/hashes/esm/sha3.js new file mode 100644 index 0000000000000000000000000000000000000000..ed813d18d695d86d2b03783f08532daf6c6a6a7c --- /dev/null +++ b/node_modules/@noble/hashes/esm/sha3.js @@ -0,0 +1,234 @@ +/** + * SHA3 (keccak) hash function, based on a new "Sponge function" design. + * Different from older hashes, the internal state is bigger than output size. + * + * Check out [FIPS-202](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf), + * [Website](https://keccak.team/keccak.html), + * [the differences between SHA-3 and Keccak](https://crypto.stackexchange.com/questions/15727/what-are-the-key-differences-between-the-draft-sha-3-standard-and-the-keccak-sub). + * + * Check out `sha3-addons` module for cSHAKE, k12, and others. + * @module + */ +import { rotlBH, rotlBL, rotlSH, rotlSL, split } from "./_u64.js"; +// prettier-ignore +import { abytes, aexists, anumber, aoutput, clean, createHasher, createXOFer, Hash, swap32IfBE, toBytes, u32 } from "./utils.js"; +// No __PURE__ annotations in sha3 header: +// EVERYTHING is in fact used on every export. +// Various per round constants calculations +const _0n = BigInt(0); +const _1n = BigInt(1); +const _2n = BigInt(2); +const _7n = BigInt(7); +const _256n = BigInt(256); +const _0x71n = BigInt(0x71); +const SHA3_PI = []; +const SHA3_ROTL = []; +const _SHA3_IOTA = []; +for (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) { + // Pi + [x, y] = [y, (2 * x + 3 * y) % 5]; + SHA3_PI.push(2 * (5 * y + x)); + // Rotational + SHA3_ROTL.push((((round + 1) * (round + 2)) / 2) % 64); + // Iota + let t = _0n; + for (let j = 0; j < 7; j++) { + R = ((R << _1n) ^ ((R >> _7n) * _0x71n)) % _256n; + if (R & _2n) + t ^= _1n << ((_1n << /* @__PURE__ */ BigInt(j)) - _1n); + } + _SHA3_IOTA.push(t); +} +const IOTAS = split(_SHA3_IOTA, true); +const SHA3_IOTA_H = IOTAS[0]; +const SHA3_IOTA_L = IOTAS[1]; +// Left rotation (without 0, 32, 64) +const rotlH = (h, l, s) => (s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s)); +const rotlL = (h, l, s) => (s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s)); +/** `keccakf1600` internal function, additionally allows to adjust round count. */ +export function keccakP(s, rounds = 24) { + const B = new Uint32Array(5 * 2); + // NOTE: all indices are x2 since we store state as u32 instead of u64 (bigints to slow in js) + for (let round = 24 - rounds; round < 24; round++) { + // Theta θ + for (let x = 0; x < 10; x++) + B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40]; + for (let x = 0; x < 10; x += 2) { + const idx1 = (x + 8) % 10; + const idx0 = (x + 2) % 10; + const B0 = B[idx0]; + const B1 = B[idx0 + 1]; + const Th = rotlH(B0, B1, 1) ^ B[idx1]; + const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1]; + for (let y = 0; y < 50; y += 10) { + s[x + y] ^= Th; + s[x + y + 1] ^= Tl; + } + } + // Rho (ρ) and Pi (π) + let curH = s[2]; + let curL = s[3]; + for (let t = 0; t < 24; t++) { + const shift = SHA3_ROTL[t]; + const Th = rotlH(curH, curL, shift); + const Tl = rotlL(curH, curL, shift); + const PI = SHA3_PI[t]; + curH = s[PI]; + curL = s[PI + 1]; + s[PI] = Th; + s[PI + 1] = Tl; + } + // Chi (χ) + for (let y = 0; y < 50; y += 10) { + for (let x = 0; x < 10; x++) + B[x] = s[y + x]; + for (let x = 0; x < 10; x++) + s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10]; + } + // Iota (ι) + s[0] ^= SHA3_IOTA_H[round]; + s[1] ^= SHA3_IOTA_L[round]; + } + clean(B); +} +/** Keccak sponge function. */ +export class Keccak extends Hash { + // NOTE: we accept arguments in bytes instead of bits here. + constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) { + super(); + this.pos = 0; + this.posOut = 0; + this.finished = false; + this.destroyed = false; + this.enableXOF = false; + this.blockLen = blockLen; + this.suffix = suffix; + this.outputLen = outputLen; + this.enableXOF = enableXOF; + this.rounds = rounds; + // Can be passed from user as dkLen + anumber(outputLen); + // 1600 = 5x5 matrix of 64bit. 1600 bits === 200 bytes + // 0 < blockLen < 200 + if (!(0 < blockLen && blockLen < 200)) + throw new Error('only keccak-f1600 function is supported'); + this.state = new Uint8Array(200); + this.state32 = u32(this.state); + } + clone() { + return this._cloneInto(); + } + keccak() { + swap32IfBE(this.state32); + keccakP(this.state32, this.rounds); + swap32IfBE(this.state32); + this.posOut = 0; + this.pos = 0; + } + update(data) { + aexists(this); + data = toBytes(data); + abytes(data); + const { blockLen, state } = this; + const len = data.length; + for (let pos = 0; pos < len;) { + const take = Math.min(blockLen - this.pos, len - pos); + for (let i = 0; i < take; i++) + state[this.pos++] ^= data[pos++]; + if (this.pos === blockLen) + this.keccak(); + } + return this; + } + finish() { + if (this.finished) + return; + this.finished = true; + const { state, suffix, pos, blockLen } = this; + // Do the padding + state[pos] ^= suffix; + if ((suffix & 0x80) !== 0 && pos === blockLen - 1) + this.keccak(); + state[blockLen - 1] ^= 0x80; + this.keccak(); + } + writeInto(out) { + aexists(this, false); + abytes(out); + this.finish(); + const bufferOut = this.state; + const { blockLen } = this; + for (let pos = 0, len = out.length; pos < len;) { + if (this.posOut >= blockLen) + this.keccak(); + const take = Math.min(blockLen - this.posOut, len - pos); + out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos); + this.posOut += take; + pos += take; + } + return out; + } + xofInto(out) { + // Sha3/Keccak usage with XOF is probably mistake, only SHAKE instances can do XOF + if (!this.enableXOF) + throw new Error('XOF is not possible for this instance'); + return this.writeInto(out); + } + xof(bytes) { + anumber(bytes); + return this.xofInto(new Uint8Array(bytes)); + } + digestInto(out) { + aoutput(out, this); + if (this.finished) + throw new Error('digest() was already called'); + this.writeInto(out); + this.destroy(); + return out; + } + digest() { + return this.digestInto(new Uint8Array(this.outputLen)); + } + destroy() { + this.destroyed = true; + clean(this.state); + } + _cloneInto(to) { + const { blockLen, suffix, outputLen, rounds, enableXOF } = this; + to || (to = new Keccak(blockLen, suffix, outputLen, enableXOF, rounds)); + to.state32.set(this.state32); + to.pos = this.pos; + to.posOut = this.posOut; + to.finished = this.finished; + to.rounds = rounds; + // Suffix can change in cSHAKE + to.suffix = suffix; + to.outputLen = outputLen; + to.enableXOF = enableXOF; + to.destroyed = this.destroyed; + return to; + } +} +const gen = (suffix, blockLen, outputLen) => createHasher(() => new Keccak(blockLen, suffix, outputLen)); +/** SHA3-224 hash function. */ +export const sha3_224 = /* @__PURE__ */ (() => gen(0x06, 144, 224 / 8))(); +/** SHA3-256 hash function. Different from keccak-256. */ +export const sha3_256 = /* @__PURE__ */ (() => gen(0x06, 136, 256 / 8))(); +/** SHA3-384 hash function. */ +export const sha3_384 = /* @__PURE__ */ (() => gen(0x06, 104, 384 / 8))(); +/** SHA3-512 hash function. */ +export const sha3_512 = /* @__PURE__ */ (() => gen(0x06, 72, 512 / 8))(); +/** keccak-224 hash function. */ +export const keccak_224 = /* @__PURE__ */ (() => gen(0x01, 144, 224 / 8))(); +/** keccak-256 hash function. Different from SHA3-256. */ +export const keccak_256 = /* @__PURE__ */ (() => gen(0x01, 136, 256 / 8))(); +/** keccak-384 hash function. */ +export const keccak_384 = /* @__PURE__ */ (() => gen(0x01, 104, 384 / 8))(); +/** keccak-512 hash function. */ +export const keccak_512 = /* @__PURE__ */ (() => gen(0x01, 72, 512 / 8))(); +const genShake = (suffix, blockLen, outputLen) => createXOFer((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen === undefined ? outputLen : opts.dkLen, true)); +/** SHAKE128 XOF with 128-bit security. */ +export const shake128 = /* @__PURE__ */ (() => genShake(0x1f, 168, 128 / 8))(); +/** SHAKE256 XOF with 256-bit security. */ +export const shake256 = /* @__PURE__ */ (() => genShake(0x1f, 136, 256 / 8))(); +//# sourceMappingURL=sha3.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/sha3.js.map b/node_modules/@noble/hashes/esm/sha3.js.map new file mode 100644 index 0000000000000000000000000000000000000000..a0adf0ea4a837c736c86d028e0fdcade51daf45d --- /dev/null +++ b/node_modules/@noble/hashes/esm/sha3.js.map @@ -0,0 +1 @@ +{"version":3,"file":"sha3.js","sourceRoot":"","sources":["../src/sha3.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClE,kBAAkB;AAClB,OAAO,EACL,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EACjC,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,IAAI,EACtC,UAAU,EACV,OAAO,EAAE,GAAG,EAEb,MAAM,YAAY,CAAC;AAEpB,0CAA0C;AAC1C,8CAA8C;AAC9C,2CAA2C;AAC3C,MAAM,GAAG,GAAG,MAAM,CAAC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gC;AAChC,MAAM,CAAC,MAAM,UAAU,GAAU,eAAe,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;AACnF,gCAAgC;AAChC,MAAM,CAAC,MAAM,UAAU,GAAU,eAAe,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;AAIlF,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAE,QAAgB,EAAE,SAAiB,EAAE,EAAE,CACvE,WAAW,CACT,CAAC,OAAkB,EAAE,EAAE,EAAE,CACvB,IAAI,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CACxF,CAAC;AAEJ,0CAA0C;AAC1C,MAAM,CAAC,MAAM,QAAQ,GAAY,eAAe,CAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;AACxF,0CAA0C;AAC1C,MAAM,CAAC,MAAM,QAAQ,GAAY,eAAe,CAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/sha512.d.ts b/node_modules/@noble/hashes/esm/sha512.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..46a27d021990fce25bd3a64b1ad52b5750272170 --- /dev/null +++ b/node_modules/@noble/hashes/esm/sha512.d.ts @@ -0,0 +1,26 @@ +/** + * SHA2-512 a.k.a. sha512 and sha384. It is slower than sha256 in js because u64 operations are slow. + * + * Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and + * [the paper on truncated SHA512/256](https://eprint.iacr.org/2010/548.pdf). + * @module + * @deprecated + */ +import { SHA384 as SHA384n, sha384 as sha384n, sha512_224 as sha512_224n, SHA512_224 as SHA512_224n, sha512_256 as sha512_256n, SHA512_256 as SHA512_256n, SHA512 as SHA512n, sha512 as sha512n } from './sha2.ts'; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export declare const SHA512: typeof SHA512n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export declare const sha512: typeof sha512n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export declare const SHA384: typeof SHA384n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export declare const sha384: typeof sha384n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export declare const SHA512_224: typeof SHA512_224n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export declare const sha512_224: typeof sha512_224n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export declare const SHA512_256: typeof SHA512_256n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export declare const sha512_256: typeof sha512_256n; +//# sourceMappingURL=sha512.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/sha512.d.ts.map b/node_modules/@noble/hashes/esm/sha512.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..3886bc81daa03e00d7bcb519ab8934dd5f822c2d --- /dev/null +++ b/node_modules/@noble/hashes/esm/sha512.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"sha512.d.ts","sourceRoot":"","sources":["../src/sha512.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,MAAM,IAAI,OAAO,EACjB,MAAM,IAAI,OAAO,EACjB,UAAU,IAAI,WAAW,EACzB,UAAU,IAAI,WAAW,EACzB,UAAU,IAAI,WAAW,EACzB,UAAU,IAAI,WAAW,EACzB,MAAM,IAAI,OAAO,EACjB,MAAM,IAAI,OAAO,EAClB,MAAM,WAAW,CAAC;AACnB,6DAA6D;AAC7D,eAAO,MAAM,MAAM,EAAE,OAAO,OAAiB,CAAC;AAC9C,6DAA6D;AAC7D,eAAO,MAAM,MAAM,EAAE,OAAO,OAAiB,CAAC;AAC9C,6DAA6D;AAC7D,eAAO,MAAM,MAAM,EAAE,OAAO,OAAiB,CAAC;AAC9C,6DAA6D;AAC7D,eAAO,MAAM,MAAM,EAAE,OAAO,OAAiB,CAAC;AAC9C,6DAA6D;AAC7D,eAAO,MAAM,UAAU,EAAE,OAAO,WAAyB,CAAC;AAC1D,6DAA6D;AAC7D,eAAO,MAAM,UAAU,EAAE,OAAO,WAAyB,CAAC;AAC1D,6DAA6D;AAC7D,eAAO,MAAM,UAAU,EAAE,OAAO,WAAyB,CAAC;AAC1D,6DAA6D;AAC7D,eAAO,MAAM,UAAU,EAAE,OAAO,WAAyB,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/sha512.js b/node_modules/@noble/hashes/esm/sha512.js new file mode 100644 index 0000000000000000000000000000000000000000..d5f6910601313a48e43643f3b6b78bb029e03d20 --- /dev/null +++ b/node_modules/@noble/hashes/esm/sha512.js @@ -0,0 +1,26 @@ +/** + * SHA2-512 a.k.a. sha512 and sha384. It is slower than sha256 in js because u64 operations are slow. + * + * Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and + * [the paper on truncated SHA512/256](https://eprint.iacr.org/2010/548.pdf). + * @module + * @deprecated + */ +import { SHA384 as SHA384n, sha384 as sha384n, sha512_224 as sha512_224n, SHA512_224 as SHA512_224n, sha512_256 as sha512_256n, SHA512_256 as SHA512_256n, SHA512 as SHA512n, sha512 as sha512n, } from "./sha2.js"; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export const SHA512 = SHA512n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export const sha512 = sha512n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export const SHA384 = SHA384n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export const sha384 = sha384n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export const SHA512_224 = SHA512_224n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export const sha512_224 = sha512_224n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export const SHA512_256 = SHA512_256n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export const sha512_256 = sha512_256n; +//# sourceMappingURL=sha512.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/sha512.js.map b/node_modules/@noble/hashes/esm/sha512.js.map new file mode 100644 index 0000000000000000000000000000000000000000..0371655573e4368f0ed17c578723a3a3a8b2c577 --- /dev/null +++ b/node_modules/@noble/hashes/esm/sha512.js.map @@ -0,0 +1 @@ +{"version":3,"file":"sha512.js","sourceRoot":"","sources":["../src/sha512.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,MAAM,IAAI,OAAO,EACjB,MAAM,IAAI,OAAO,EACjB,UAAU,IAAI,WAAW,EACzB,UAAU,IAAI,WAAW,EACzB,UAAU,IAAI,WAAW,EACzB,UAAU,IAAI,WAAW,EACzB,MAAM,IAAI,OAAO,EACjB,MAAM,IAAI,OAAO,GAClB,MAAM,WAAW,CAAC;AACnB,6DAA6D;AAC7D,MAAM,CAAC,MAAM,MAAM,GAAmB,OAAO,CAAC;AAC9C,6DAA6D;AAC7D,MAAM,CAAC,MAAM,MAAM,GAAmB,OAAO,CAAC;AAC9C,6DAA6D;AAC7D,MAAM,CAAC,MAAM,MAAM,GAAmB,OAAO,CAAC;AAC9C,6DAA6D;AAC7D,MAAM,CAAC,MAAM,MAAM,GAAmB,OAAO,CAAC;AAC9C,6DAA6D;AAC7D,MAAM,CAAC,MAAM,UAAU,GAAuB,WAAW,CAAC;AAC1D,6DAA6D;AAC7D,MAAM,CAAC,MAAM,UAAU,GAAuB,WAAW,CAAC;AAC1D,6DAA6D;AAC7D,MAAM,CAAC,MAAM,UAAU,GAAuB,WAAW,CAAC;AAC1D,6DAA6D;AAC7D,MAAM,CAAC,MAAM,UAAU,GAAuB,WAAW,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/utils.d.ts b/node_modules/@noble/hashes/esm/utils.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..90b8439bddcad7f8db983ac6a243219c56b8ebe2 --- /dev/null +++ b/node_modules/@noble/hashes/esm/utils.d.ts @@ -0,0 +1,161 @@ +/** + * Utilities for hex, bytes, CSPRNG. + * @module + */ +/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */ +/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */ +export declare function isBytes(a: unknown): a is Uint8Array; +/** Asserts something is positive integer. */ +export declare function anumber(n: number): void; +/** Asserts something is Uint8Array. */ +export declare function abytes(b: Uint8Array | undefined, ...lengths: number[]): void; +/** Asserts something is hash */ +export declare function ahash(h: IHash): void; +/** Asserts a hash instance has not been destroyed / finished */ +export declare function aexists(instance: any, checkFinished?: boolean): void; +/** Asserts output is properly-sized byte array */ +export declare function aoutput(out: any, instance: any): void; +/** Generic type encompassing 8/16/32-byte arrays - but not 64-byte. */ +export type TypedArray = Int8Array | Uint8ClampedArray | Uint8Array | Uint16Array | Int16Array | Uint32Array | Int32Array; +/** Cast u8 / u16 / u32 to u8. */ +export declare function u8(arr: TypedArray): Uint8Array; +/** Cast u8 / u16 / u32 to u32. */ +export declare function u32(arr: TypedArray): Uint32Array; +/** Zeroize a byte array. Warning: JS provides no guarantees. */ +export declare function clean(...arrays: TypedArray[]): void; +/** Create DataView of an array for easy byte-level manipulation. */ +export declare function createView(arr: TypedArray): DataView; +/** The rotate right (circular right shift) operation for uint32 */ +export declare function rotr(word: number, shift: number): number; +/** The rotate left (circular left shift) operation for uint32 */ +export declare function rotl(word: number, shift: number): number; +/** Is current platform little-endian? Most are. Big-Endian platform: IBM */ +export declare const isLE: boolean; +/** The byte swap operation for uint32 */ +export declare function byteSwap(word: number): number; +/** Conditionally byte swap if on a big-endian platform */ +export declare const swap8IfBE: (n: number) => number; +/** @deprecated */ +export declare const byteSwapIfBE: typeof swap8IfBE; +/** In place byte swap for Uint32Array */ +export declare function byteSwap32(arr: Uint32Array): Uint32Array; +export declare const swap32IfBE: (u: Uint32Array) => Uint32Array; +/** + * Convert byte array to hex string. Uses built-in function, when available. + * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123' + */ +export declare function bytesToHex(bytes: Uint8Array): string; +/** + * Convert hex string to byte array. Uses built-in function, when available. + * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23]) + */ +export declare function hexToBytes(hex: string): Uint8Array; +/** + * There is no setImmediate in browser and setTimeout is slow. + * Call of async fn will return Promise, which will be fullfiled only on + * next scheduler queue processing step and this is exactly what we need. + */ +export declare const nextTick: () => Promise; +/** Returns control to thread each 'tick' ms to avoid blocking. */ +export declare function asyncLoop(iters: number, tick: number, cb: (i: number) => void): Promise; +/** + * Converts string to bytes using UTF8 encoding. + * @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99]) + */ +export declare function utf8ToBytes(str: string): Uint8Array; +/** + * Converts bytes to string using UTF8 encoding. + * @example bytesToUtf8(Uint8Array.from([97, 98, 99])) // 'abc' + */ +export declare function bytesToUtf8(bytes: Uint8Array): string; +/** Accepted input of hash functions. Strings are converted to byte arrays. */ +export type Input = string | Uint8Array; +/** + * Normalizes (non-hex) string or Uint8Array to Uint8Array. + * Warning: when Uint8Array is passed, it would NOT get copied. + * Keep in mind for future mutable operations. + */ +export declare function toBytes(data: Input): Uint8Array; +/** KDFs can accept string or Uint8Array for user convenience. */ +export type KDFInput = string | Uint8Array; +/** + * Helper for KDFs: consumes uint8array or string. + * When string is passed, does utf8 decoding, using TextDecoder. + */ +export declare function kdfInputToBytes(data: KDFInput): Uint8Array; +/** Copies several Uint8Arrays into one. */ +export declare function concatBytes(...arrays: Uint8Array[]): Uint8Array; +type EmptyObj = {}; +export declare function checkOpts(defaults: T1, opts?: T2): T1 & T2; +/** Hash interface. */ +export type IHash = { + (data: Uint8Array): Uint8Array; + blockLen: number; + outputLen: number; + create: any; +}; +/** For runtime check if class implements interface */ +export declare abstract class Hash> { + abstract blockLen: number; + abstract outputLen: number; + abstract update(buf: Input): this; + abstract digestInto(buf: Uint8Array): void; + abstract digest(): Uint8Array; + /** + * Resets internal state. Makes Hash instance unusable. + * Reset is impossible for keyed hashes if key is consumed into state. If digest is not consumed + * by user, they will need to manually call `destroy()` when zeroing is necessary. + */ + abstract destroy(): void; + /** + * Clones hash instance. Unsafe: doesn't check whether `to` is valid. Can be used as `clone()` + * when no options are passed. + * Reasons to use `_cloneInto` instead of clone: 1) performance 2) reuse instance => all internal + * buffers are overwritten => causes buffer overwrite which is used for digest in some cases. + * There are no guarantees for clean-up because it's impossible in JS. + */ + abstract _cloneInto(to?: T): T; + abstract clone(): T; +} +/** + * XOF: streaming API to read digest in chunks. + * Same as 'squeeze' in keccak/k12 and 'seek' in blake3, but more generic name. + * When hash used in XOF mode it is up to user to call '.destroy' afterwards, since we cannot + * destroy state, next call can require more bytes. + */ +export type HashXOF> = Hash & { + xof(bytes: number): Uint8Array; + xofInto(buf: Uint8Array): Uint8Array; +}; +/** Hash function */ +export type CHash = ReturnType; +/** Hash function with output */ +export type CHashO = ReturnType; +/** XOF with output */ +export type CHashXO = ReturnType; +/** Wraps hash function, creating an interface on top of it */ +export declare function createHasher>(hashCons: () => Hash): { + (msg: Input): Uint8Array; + outputLen: number; + blockLen: number; + create(): Hash; +}; +export declare function createOptHasher, T extends Object>(hashCons: (opts?: T) => Hash): { + (msg: Input, opts?: T): Uint8Array; + outputLen: number; + blockLen: number; + create(opts?: T): Hash; +}; +export declare function createXOFer, T extends Object>(hashCons: (opts?: T) => HashXOF): { + (msg: Input, opts?: T): Uint8Array; + outputLen: number; + blockLen: number; + create(opts?: T): HashXOF; +}; +export declare const wrapConstructor: typeof createHasher; +export declare const wrapConstructorWithOpts: typeof createOptHasher; +export declare const wrapXOFConstructorWithOpts: typeof createXOFer; +/** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */ +export declare function randomBytes(bytesLength?: number): Uint8Array; +export {}; +//# sourceMappingURL=utils.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/utils.d.ts.map b/node_modules/@noble/hashes/esm/utils.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..8ab65703ba38bb5c2c975f52f1e96f762feb2672 --- /dev/null +++ b/node_modules/@noble/hashes/esm/utils.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,sEAAsE;AAUtE,qFAAqF;AACrF,wBAAgB,OAAO,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,UAAU,CAEnD;AAED,6CAA6C;AAC7C,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAEvC;AAED,uCAAuC;AACvC,wBAAgB,MAAM,CAAC,CAAC,EAAE,UAAU,GAAG,SAAS,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAI5E;AAED,gCAAgC;AAChC,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAKpC;AAED,gEAAgE;AAChE,wBAAgB,OAAO,CAAC,QAAQ,EAAE,GAAG,EAAE,aAAa,UAAO,GAAG,IAAI,CAGjE;AAED,kDAAkD;AAClD,wBAAgB,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,GAAG,IAAI,CAMrD;AAED,uEAAuE;AAEvE,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,iBAAiB,GAAG,UAAU,GACjE,WAAW,GAAG,UAAU,GAAG,WAAW,GAAG,UAAU,CAAC;AAEtD,iCAAiC;AACjC,wBAAgB,EAAE,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,CAE9C;AAED,kCAAkC;AAClC,wBAAgB,GAAG,CAA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,GAAG,UAAU,CAAC;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;CAC3B,CAOA;AAED,wBAAgB,WAAW,CAAC,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,EAChE,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,GACjC;IACD,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CAC9B,CAOA;AACD,eAAO,MAAM,eAAe,EAAE,OAAO,YAA2B,CAAC;AACjE,eAAO,MAAM,uBAAuB,EAAE,OAAO,eAAiC,CAAC;AAC/E,eAAO,MAAM,0BAA0B,EAAE,OAAO,WAAyB,CAAC;AAE1E,sFAAsF;AACtF,wBAAgB,WAAW,CAAC,WAAW,SAAK,GAAG,UAAU,CASxD"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/utils.js b/node_modules/@noble/hashes/esm/utils.js new file mode 100644 index 0000000000000000000000000000000000000000..9614c8e5754cc1e94e26a81e9517f20499696b4e --- /dev/null +++ b/node_modules/@noble/hashes/esm/utils.js @@ -0,0 +1,281 @@ +/** + * Utilities for hex, bytes, CSPRNG. + * @module + */ +/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */ +// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+. +// node.js versions earlier than v19 don't declare it in global scope. +// For node.js, package.json#exports field mapping rewrites import +// from `crypto` to `cryptoNode`, which imports native module. +// Makes the utils un-importable in browsers without a bundler. +// Once node.js 18 is deprecated (2025-04-30), we can just drop the import. +import { crypto } from '@noble/hashes/crypto'; +/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */ +export function isBytes(a) { + return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array'); +} +/** Asserts something is positive integer. */ +export function anumber(n) { + if (!Number.isSafeInteger(n) || n < 0) + throw new Error('positive integer expected, got ' + n); +} +/** Asserts something is Uint8Array. */ +export function abytes(b, ...lengths) { + if (!isBytes(b)) + throw new Error('Uint8Array expected'); + if (lengths.length > 0 && !lengths.includes(b.length)) + throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length); +} +/** Asserts something is hash */ +export function ahash(h) { + if (typeof h !== 'function' || typeof h.create !== 'function') + throw new Error('Hash should be wrapped by utils.createHasher'); + anumber(h.outputLen); + anumber(h.blockLen); +} +/** Asserts a hash instance has not been destroyed / finished */ +export function aexists(instance, checkFinished = true) { + if (instance.destroyed) + throw new Error('Hash instance has been destroyed'); + if (checkFinished && instance.finished) + throw new Error('Hash#digest() has already been called'); +} +/** Asserts output is properly-sized byte array */ +export function aoutput(out, instance) { + abytes(out); + const min = instance.outputLen; + if (out.length < min) { + throw new Error('digestInto() expects output buffer of length at least ' + min); + } +} +/** Cast u8 / u16 / u32 to u8. */ +export function u8(arr) { + return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength); +} +/** Cast u8 / u16 / u32 to u32. */ +export function u32(arr) { + return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4)); +} +/** Zeroize a byte array. Warning: JS provides no guarantees. */ +export function clean(...arrays) { + for (let i = 0; i < arrays.length; i++) { + arrays[i].fill(0); + } +} +/** Create DataView of an array for easy byte-level manipulation. */ +export function createView(arr) { + return new DataView(arr.buffer, arr.byteOffset, arr.byteLength); +} +/** The rotate right (circular right shift) operation for uint32 */ +export function rotr(word, shift) { + return (word << (32 - shift)) | (word >>> shift); +} +/** The rotate left (circular left shift) operation for uint32 */ +export function rotl(word, shift) { + return (word << shift) | ((word >>> (32 - shift)) >>> 0); +} +/** Is current platform little-endian? Most are. Big-Endian platform: IBM */ +export const isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)(); +/** The byte swap operation for uint32 */ +export function byteSwap(word) { + return (((word << 24) & 0xff000000) | + ((word << 8) & 0xff0000) | + ((word >>> 8) & 0xff00) | + ((word >>> 24) & 0xff)); +} +/** Conditionally byte swap if on a big-endian platform */ +export const swap8IfBE = isLE + ? (n) => n + : (n) => byteSwap(n); +/** @deprecated */ +export const byteSwapIfBE = swap8IfBE; +/** In place byte swap for Uint32Array */ +export function byteSwap32(arr) { + for (let i = 0; i < arr.length; i++) { + arr[i] = byteSwap(arr[i]); + } + return arr; +} +export const swap32IfBE = isLE + ? (u) => u + : byteSwap32; +// Built-in hex conversion https://caniuse.com/mdn-javascript_builtins_uint8array_fromhex +const hasHexBuiltin = /* @__PURE__ */ (() => +// @ts-ignore +typeof Uint8Array.from([]).toHex === 'function' && typeof Uint8Array.fromHex === 'function')(); +// Array where index 0xf0 (240) is mapped to string 'f0' +const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0')); +/** + * Convert byte array to hex string. Uses built-in function, when available. + * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123' + */ +export function bytesToHex(bytes) { + abytes(bytes); + // @ts-ignore + if (hasHexBuiltin) + return bytes.toHex(); + // pre-caching improves the speed 6x + let hex = ''; + for (let i = 0; i < bytes.length; i++) { + hex += hexes[bytes[i]]; + } + return hex; +} +// We use optimized technique to convert hex string to byte array +const asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 }; +function asciiToBase16(ch) { + if (ch >= asciis._0 && ch <= asciis._9) + return ch - asciis._0; // '2' => 50-48 + if (ch >= asciis.A && ch <= asciis.F) + return ch - (asciis.A - 10); // 'B' => 66-(65-10) + if (ch >= asciis.a && ch <= asciis.f) + return ch - (asciis.a - 10); // 'b' => 98-(97-10) + return; +} +/** + * Convert hex string to byte array. Uses built-in function, when available. + * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23]) + */ +export function hexToBytes(hex) { + if (typeof hex !== 'string') + throw new Error('hex string expected, got ' + typeof hex); + // @ts-ignore + if (hasHexBuiltin) + return Uint8Array.fromHex(hex); + const hl = hex.length; + const al = hl / 2; + if (hl % 2) + throw new Error('hex string expected, got unpadded hex of length ' + hl); + const array = new Uint8Array(al); + for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) { + const n1 = asciiToBase16(hex.charCodeAt(hi)); + const n2 = asciiToBase16(hex.charCodeAt(hi + 1)); + if (n1 === undefined || n2 === undefined) { + const char = hex[hi] + hex[hi + 1]; + throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi); + } + array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163 + } + return array; +} +/** + * There is no setImmediate in browser and setTimeout is slow. + * Call of async fn will return Promise, which will be fullfiled only on + * next scheduler queue processing step and this is exactly what we need. + */ +export const nextTick = async () => { }; +/** Returns control to thread each 'tick' ms to avoid blocking. */ +export async function asyncLoop(iters, tick, cb) { + let ts = Date.now(); + for (let i = 0; i < iters; i++) { + cb(i); + // Date.now() is not monotonic, so in case if clock goes backwards we return return control too + const diff = Date.now() - ts; + if (diff >= 0 && diff < tick) + continue; + await nextTick(); + ts += diff; + } +} +/** + * Converts string to bytes using UTF8 encoding. + * @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99]) + */ +export function utf8ToBytes(str) { + if (typeof str !== 'string') + throw new Error('string expected'); + return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809 +} +/** + * Converts bytes to string using UTF8 encoding. + * @example bytesToUtf8(Uint8Array.from([97, 98, 99])) // 'abc' + */ +export function bytesToUtf8(bytes) { + return new TextDecoder().decode(bytes); +} +/** + * Normalizes (non-hex) string or Uint8Array to Uint8Array. + * Warning: when Uint8Array is passed, it would NOT get copied. + * Keep in mind for future mutable operations. + */ +export function toBytes(data) { + if (typeof data === 'string') + data = utf8ToBytes(data); + abytes(data); + return data; +} +/** + * Helper for KDFs: consumes uint8array or string. + * When string is passed, does utf8 decoding, using TextDecoder. + */ +export function kdfInputToBytes(data) { + if (typeof data === 'string') + data = utf8ToBytes(data); + abytes(data); + return data; +} +/** Copies several Uint8Arrays into one. */ +export function concatBytes(...arrays) { + let sum = 0; + for (let i = 0; i < arrays.length; i++) { + const a = arrays[i]; + abytes(a); + sum += a.length; + } + const res = new Uint8Array(sum); + for (let i = 0, pad = 0; i < arrays.length; i++) { + const a = arrays[i]; + res.set(a, pad); + pad += a.length; + } + return res; +} +export function checkOpts(defaults, opts) { + if (opts !== undefined && {}.toString.call(opts) !== '[object Object]') + throw new Error('options should be object or undefined'); + const merged = Object.assign(defaults, opts); + return merged; +} +/** For runtime check if class implements interface */ +export class Hash { +} +/** Wraps hash function, creating an interface on top of it */ +export function createHasher(hashCons) { + const hashC = (msg) => hashCons().update(toBytes(msg)).digest(); + const tmp = hashCons(); + hashC.outputLen = tmp.outputLen; + hashC.blockLen = tmp.blockLen; + hashC.create = () => hashCons(); + return hashC; +} +export function createOptHasher(hashCons) { + const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest(); + const tmp = hashCons({}); + hashC.outputLen = tmp.outputLen; + hashC.blockLen = tmp.blockLen; + hashC.create = (opts) => hashCons(opts); + return hashC; +} +export function createXOFer(hashCons) { + const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest(); + const tmp = hashCons({}); + hashC.outputLen = tmp.outputLen; + hashC.blockLen = tmp.blockLen; + hashC.create = (opts) => hashCons(opts); + return hashC; +} +export const wrapConstructor = createHasher; +export const wrapConstructorWithOpts = createOptHasher; +export const wrapXOFConstructorWithOpts = createXOFer; +/** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */ +export function randomBytes(bytesLength = 32) { + if (crypto && typeof crypto.getRandomValues === 'function') { + return crypto.getRandomValues(new Uint8Array(bytesLength)); + } + // Legacy Node.js compatibility + if (crypto && typeof crypto.randomBytes === 'function') { + return Uint8Array.from(crypto.randomBytes(bytesLength)); + } + throw new Error('crypto.getRandomValues must be defined'); +} +//# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/esm/utils.js.map b/node_modules/@noble/hashes/esm/utils.js.map new file mode 100644 index 0000000000000000000000000000000000000000..8a068c084f5f54193ec93c9a39e68361fa58b392 --- /dev/null +++ b/node_modules/@noble/hashes/esm/utils.js.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,sEAAsE;AAEtE,oFAAoF;AACpF,sEAAsE;AACtE,kEAAkE;AAClE,8DAA8D;AAC9D,+DAA+D;AAC/D,2EAA2E;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,qFAAqF;AACrF,MAAM,UAAU,OAAO,CAAC,CAAU;IAChC,OAAO,CAAC,YAAY,UAAU,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC;AACnG,CAAC;AAED,6CAA6C;AAC7C,MAAM,UAAU,OAAO,CAAC,CAAS;IAC/B,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,GAAG,CAAC,CAAC,CAAC;AAChG,CAAC;AAED,uCAAuC;AACvC,MAAM,UAAU,MAAM,CAAC,CAAyB,EAAE,GAAG,OAAiB;IACpE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACxD,IAAI,OAAO,CAAC,M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M,EAAE,CAAC;IACjG,MAAM,GAAG,GAAG,QAAQ,CAAC,EAAO,CAAC,CAAC;IAC9B,KAAK,CAAC,SAAS,GAAG,GAAG,CAAC,SAAS,CAAC;IAChC,KAAK,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;IAC9B,KAAK,CAAC,MAAM,GAAG,CAAC,IAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC5C,OAAO,KAAK,CAAC;AACf,CAAC;AACD,MAAM,CAAC,MAAM,eAAe,GAAwB,YAAY,CAAC;AACjE,MAAM,CAAC,MAAM,uBAAuB,GAA2B,eAAe,CAAC;AAC/E,MAAM,CAAC,MAAM,0BAA0B,GAAuB,WAAW,CAAC;AAE1E,sFAAsF;AACtF,MAAM,UAAU,WAAW,CAAC,WAAW,GAAG,EAAE;IAC1C,IAAI,MAAM,IAAI,OAAO,MAAM,CAAC,eAAe,KAAK,UAAU,EAAE,CAAC;QAC3D,OAAO,MAAM,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC;IAC7D,CAAC;IACD,+BAA+B;IAC/B,IAAI,MAAM,IAAI,OAAO,MAAM,CAAC,WAAW,KAAK,UAAU,EAAE,CAAC;QACvD,OAAO,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC;IAC1D,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;AAC5D,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/hkdf.d.ts b/node_modules/@noble/hashes/hkdf.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c54c4ab2f79656aff84d089556c5052c3f4508c4 --- /dev/null +++ b/node_modules/@noble/hashes/hkdf.d.ts @@ -0,0 +1,36 @@ +import { type CHash, type Input } from './utils.ts'; +/** + * HKDF-extract from spec. Less important part. `HKDF-Extract(IKM, salt) -> PRK` + * Arguments position differs from spec (IKM is first one, since it is not optional) + * @param hash - hash function that would be used (e.g. sha256) + * @param ikm - input keying material, the initial key + * @param salt - optional salt value (a non-secret random value) + */ +export declare function extract(hash: CHash, ikm: Input, salt?: Input): Uint8Array; +/** + * HKDF-expand from the spec. The most important part. `HKDF-Expand(PRK, info, L) -> OKM` + * @param hash - hash function that would be used (e.g. sha256) + * @param prk - a pseudorandom key of at least HashLen octets (usually, the output from the extract step) + * @param info - optional context and application specific information (can be a zero-length string) + * @param length - length of output keying material in bytes + */ +export declare function expand(hash: CHash, prk: Input, info?: Input, length?: number): Uint8Array; +/** + * HKDF (RFC 5869): derive keys from an initial input. + * Combines hkdf_extract + hkdf_expand in one step + * @param hash - hash function that would be used (e.g. sha256) + * @param ikm - input keying material, the initial key + * @param salt - optional salt value (a non-secret random value) + * @param info - optional context and application specific information (can be a zero-length string) + * @param length - length of output keying material in bytes + * @example + * import { hkdf } from '@noble/hashes/hkdf'; + * import { sha256 } from '@noble/hashes/sha2'; + * import { randomBytes } from '@noble/hashes/utils'; + * const inputKey = randomBytes(32); + * const salt = randomBytes(32); + * const info = 'application-key'; + * const hk1 = hkdf(sha256, inputKey, salt, info, 32); + */ +export declare const hkdf: (hash: CHash, ikm: Input, salt: Input | undefined, info: Input | undefined, length: number) => Uint8Array; +//# sourceMappingURL=hkdf.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/hkdf.d.ts.map b/node_modules/@noble/hashes/hkdf.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..76b0ebb01c07b9a12b76221b7aa161deb3313d7a --- /dev/null +++ b/node_modules/@noble/hashes/hkdf.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"hkdf.d.ts","sourceRoot":"","sources":["src/hkdf.ts"],"names":[],"mappings":"AAMA,OAAO,EAAkB,KAAK,KAAK,EAAS,KAAK,KAAK,EAAW,MAAM,YAAY,CAAC;AAEpF;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,KAAK,GAAG,UAAU,CAOzE;AAKD;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,GAAE,MAAW,GAAG,UAAU,CA4B7F;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,IAAI,GACf,MAAM,KAAK,EACX,KAAK,KAAK,EACV,MAAM,KAAK,GAAG,SAAS,EACvB,MAAM,KAAK,GAAG,SAAS,EACvB,QAAQ,MAAM,KACb,UAAkE,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/hkdf.js b/node_modules/@noble/hashes/hkdf.js new file mode 100644 index 0000000000000000000000000000000000000000..aca1674945a1348851573d2db6cc752bc7d8a4d1 --- /dev/null +++ b/node_modules/@noble/hashes/hkdf.js @@ -0,0 +1,88 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.hkdf = void 0; +exports.extract = extract; +exports.expand = expand; +/** + * HKDF (RFC 5869): extract + expand in one step. + * See https://soatok.blog/2021/11/17/understanding-hkdf/. + * @module + */ +const hmac_ts_1 = require("./hmac.js"); +const utils_ts_1 = require("./utils.js"); +/** + * HKDF-extract from spec. Less important part. `HKDF-Extract(IKM, salt) -> PRK` + * Arguments position differs from spec (IKM is first one, since it is not optional) + * @param hash - hash function that would be used (e.g. sha256) + * @param ikm - input keying material, the initial key + * @param salt - optional salt value (a non-secret random value) + */ +function extract(hash, ikm, salt) { + (0, utils_ts_1.ahash)(hash); + // NOTE: some libraries treat zero-length array as 'not provided'; + // we don't, since we have undefined as 'not provided' + // https://github.com/RustCrypto/KDFs/issues/15 + if (salt === undefined) + salt = new Uint8Array(hash.outputLen); + return (0, hmac_ts_1.hmac)(hash, (0, utils_ts_1.toBytes)(salt), (0, utils_ts_1.toBytes)(ikm)); +} +const HKDF_COUNTER = /* @__PURE__ */ Uint8Array.from([0]); +const EMPTY_BUFFER = /* @__PURE__ */ Uint8Array.of(); +/** + * HKDF-expand from the spec. The most important part. `HKDF-Expand(PRK, info, L) -> OKM` + * @param hash - hash function that would be used (e.g. sha256) + * @param prk - a pseudorandom key of at least HashLen octets (usually, the output from the extract step) + * @param info - optional context and application specific information (can be a zero-length string) + * @param length - length of output keying material in bytes + */ +function expand(hash, prk, info, length = 32) { + (0, utils_ts_1.ahash)(hash); + (0, utils_ts_1.anumber)(length); + const olen = hash.outputLen; + if (length > 255 * olen) + throw new Error('Length should be <= 255*HashLen'); + const blocks = Math.ceil(length / olen); + if (info === undefined) + info = EMPTY_BUFFER; + // first L(ength) octets of T + const okm = new Uint8Array(blocks * olen); + // Re-use HMAC instance between blocks + const HMAC = hmac_ts_1.hmac.create(hash, prk); + const HMACTmp = HMAC._cloneInto(); + const T = new Uint8Array(HMAC.outputLen); + for (let counter = 0; counter < blocks; counter++) { + HKDF_COUNTER[0] = counter + 1; + // T(0) = empty string (zero length) + // T(N) = HMAC-Hash(PRK, T(N-1) | info | N) + HMACTmp.update(counter === 0 ? EMPTY_BUFFER : T) + .update(info) + .update(HKDF_COUNTER) + .digestInto(T); + okm.set(T, olen * counter); + HMAC._cloneInto(HMACTmp); + } + HMAC.destroy(); + HMACTmp.destroy(); + (0, utils_ts_1.clean)(T, HKDF_COUNTER); + return okm.slice(0, length); +} +/** + * HKDF (RFC 5869): derive keys from an initial input. + * Combines hkdf_extract + hkdf_expand in one step + * @param hash - hash function that would be used (e.g. sha256) + * @param ikm - input keying material, the initial key + * @param salt - optional salt value (a non-secret random value) + * @param info - optional context and application specific information (can be a zero-length string) + * @param length - length of output keying material in bytes + * @example + * import { hkdf } from '@noble/hashes/hkdf'; + * import { sha256 } from '@noble/hashes/sha2'; + * import { randomBytes } from '@noble/hashes/utils'; + * const inputKey = randomBytes(32); + * const salt = randomBytes(32); + * const info = 'application-key'; + * const hk1 = hkdf(sha256, inputKey, salt, info, 32); + */ +const hkdf = (hash, ikm, salt, info, length) => expand(hash, extract(hash, ikm, salt), info, length); +exports.hkdf = hkdf; +//# sourceMappingURL=hkdf.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/hkdf.js.map b/node_modules/@noble/hashes/hkdf.js.map new file mode 100644 index 0000000000000000000000000000000000000000..3d6d405565e559d31e22d651b1c20a2d7b67eff0 --- /dev/null +++ b/node_modules/@noble/hashes/hkdf.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hkdf.js","sourceRoot":"","sources":["src/hkdf.ts"],"names":[],"mappings":";;;AAeA,0BAOC;AAYD,wBA4BC;AA9DD;;;;GAIG;AACH,uCAAiC;AACjC,yCAAoF;AAEpF;;;;;;GAMG;AACH,SAAgB,OAAO,CAAC,IAAW,EAAE,GAAU,EAAE,IAAY;IAC3D,IAAA,gBAAK,EAAC,IAAI,CAAC,CAAC;IACZ,kEAAkE;IAClE,sDAAsD;IACtD,+CAA+C;IAC/C,IAAI,IAAI,KAAK,SAAS;QAAE,IAAI,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC9D,OAAO,IAAA,cAAI,EAAC,IAAI,EAAE,IAAA,kBAAO,EAAC,IAAI,CAAC,EAAE,IAAA,kBAAO,EAAC,GAAG,CAAC,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,YAAY,GAAG,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1D,MAAM,YAAY,GAAG,eAAe,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC;AAErD;;;;;;GAMG;AACH,SAAgB,MAAM,CAAC,IAAW,EAAE,GAAU,EAAE,IAAY,EAAE,SAAiB,EAAE;IAC/E,IAAA,gBAAK,EAAC,IAAI,CAAC,CAAC;IACZ,IAAA,kBAAO,EAAC,MAAM,CAAC,CAAC;IAChB,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC;IAC5B,IAAI,MAAM,GAAG,GAAG,G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AED;;;;;;;;;;;;;;;;GAgBG;AACI,MAAM,IAAI,GAAG,CAClB,IAAW,EACX,GAAU,EACV,IAAuB,EACvB,IAAuB,EACvB,MAAc,EACF,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AANzD,QAAA,IAAI,QAMqD"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/hmac.d.ts b/node_modules/@noble/hashes/hmac.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..86525f937c0880b7424dd47bd431dcb8cc60b279 --- /dev/null +++ b/node_modules/@noble/hashes/hmac.d.ts @@ -0,0 +1,35 @@ +/** + * HMAC: RFC2104 message authentication code. + * @module + */ +import { Hash, type CHash, type Input } from './utils.ts'; +export declare class HMAC> extends Hash> { + oHash: T; + iHash: T; + blockLen: number; + outputLen: number; + private finished; + private destroyed; + constructor(hash: CHash, _key: Input); + update(buf: Input): this; + digestInto(out: Uint8Array): void; + digest(): Uint8Array; + _cloneInto(to?: HMAC): HMAC; + clone(): HMAC; + destroy(): void; +} +/** + * HMAC: RFC2104 message authentication code. + * @param hash - function that would be used e.g. sha256 + * @param key - message key + * @param message - message data + * @example + * import { hmac } from '@noble/hashes/hmac'; + * import { sha256 } from '@noble/hashes/sha2'; + * const mac1 = hmac(sha256, 'key', 'message'); + */ +export declare const hmac: { + (hash: CHash, key: Input, message: Input): Uint8Array; + create(hash: CHash, key: Input): HMAC; +}; +//# sourceMappingURL=hmac.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/hmac.d.ts.map b/node_modules/@noble/hashes/hmac.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..5a7f0f3a5b809d306d48396b4586f3245d957fa0 --- /dev/null +++ b/node_modules/@noble/hashes/hmac.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"hmac.d.ts","sourceRoot":"","sources":["src/hmac.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAiC,IAAI,EAAW,KAAK,KAAK,EAAE,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAElG,qBAAa,IAAI,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC,CAAE,SAAQ,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACxD,KAAK,EAAE,CAAC,CAAC;IACT,KAAK,EAAE,CAAC,CAAC;IACT,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,SAAS,CAAS;gBAEd,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK;IAsBpC,MAAM,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI;IAKxB,UAAU,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI;IASjC,MAAM,IAAI,UAAU;IAKpB,UAAU,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IAajC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC;IAGhB,OAAO,IAAI,IAAI;CAKhB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,IAAI,EAAE;IACjB,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,GAAG,UAAU,CAAC;IACtD,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;CAEM,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/hmac.js b/node_modules/@noble/hashes/hmac.js new file mode 100644 index 0000000000000000000000000000000000000000..060cf57d0b1f75e40e651acd89a990e4c4395075 --- /dev/null +++ b/node_modules/@noble/hashes/hmac.js @@ -0,0 +1,91 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.hmac = exports.HMAC = void 0; +/** + * HMAC: RFC2104 message authentication code. + * @module + */ +const utils_ts_1 = require("./utils.js"); +class HMAC extends utils_ts_1.Hash { + constructor(hash, _key) { + super(); + this.finished = false; + this.destroyed = false; + (0, utils_ts_1.ahash)(hash); + const key = (0, utils_ts_1.toBytes)(_key); + this.iHash = hash.create(); + if (typeof this.iHash.update !== 'function') + throw new Error('Expected instance of class which extends utils.Hash'); + this.blockLen = this.iHash.blockLen; + this.outputLen = this.iHash.outputLen; + const blockLen = this.blockLen; + const pad = new Uint8Array(blockLen); + // blockLen can be bigger than outputLen + pad.set(key.length > blockLen ? hash.create().update(key).digest() : key); + for (let i = 0; i < pad.length; i++) + pad[i] ^= 0x36; + this.iHash.update(pad); + // By doing update (processing of first block) of outer hash here we can re-use it between multiple calls via clone + this.oHash = hash.create(); + // Undo internal XOR && apply outer XOR + for (let i = 0; i < pad.length; i++) + pad[i] ^= 0x36 ^ 0x5c; + this.oHash.update(pad); + (0, utils_ts_1.clean)(pad); + } + update(buf) { + (0, utils_ts_1.aexists)(this); + this.iHash.update(buf); + return this; + } + digestInto(out) { + (0, utils_ts_1.aexists)(this); + (0, utils_ts_1.abytes)(out, this.outputLen); + this.finished = true; + this.iHash.digestInto(out); + this.oHash.update(out); + this.oHash.digestInto(out); + this.destroy(); + } + digest() { + const out = new Uint8Array(this.oHash.outputLen); + this.digestInto(out); + return out; + } + _cloneInto(to) { + // Create new instance without calling constructor since key already in state and we don't know it. + to || (to = Object.create(Object.getPrototypeOf(this), {})); + const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this; + to = to; + to.finished = finished; + to.destroyed = destroyed; + to.blockLen = blockLen; + to.outputLen = outputLen; + to.oHash = oHash._cloneInto(to.oHash); + to.iHash = iHash._cloneInto(to.iHash); + return to; + } + clone() { + return this._cloneInto(); + } + destroy() { + this.destroyed = true; + this.oHash.destroy(); + this.iHash.destroy(); + } +} +exports.HMAC = HMAC; +/** + * HMAC: RFC2104 message authentication code. + * @param hash - function that would be used e.g. sha256 + * @param key - message key + * @param message - message data + * @example + * import { hmac } from '@noble/hashes/hmac'; + * import { sha256 } from '@noble/hashes/sha2'; + * const mac1 = hmac(sha256, 'key', 'message'); + */ +const hmac = (hash, key, message) => new HMAC(hash, key).update(message).digest(); +exports.hmac = hmac; +exports.hmac.create = (hash, key) => new HMAC(hash, key); +//# sourceMappingURL=hmac.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/hmac.js.map b/node_modules/@noble/hashes/hmac.js.map new file mode 100644 index 0000000000000000000000000000000000000000..b99d61aded9a93e9a63b4b347990c4baa22ef7a5 --- /dev/null +++ b/node_modules/@noble/hashes/hmac.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hmac.js","sourceRoot":"","sources":["src/hmac.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,yCAAkG;AAElG,MAAa,IAAwB,SAAQ,eAAa;IAQxD,YAAY,IAAW,EAAE,IAAW;QAClC,KAAK,EAAE,CAAC;QAJF,aAAQ,GAAG,KAAK,CAAC;QACjB,cAAS,GAAG,KAAK,CAAC;QAIxB,IAAA,gBAAK,EAAC,IAAI,CAAC,CAAC;QACZ,MAAM,GAAG,GAAG,IAAA,kBAAO,EAAC,IAAI,CAAC,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,EAAO,CAAC;QAChC,IAAI,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,UAAU;YACzC,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;QACzE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;QACpC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;QACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC/B,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,QAAQ,CAAC,CAAC;QACrC,wCAAwC;QACxC,GAAG,CAAC,GAAG,CAAC,GA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D,IAAI,IAAI,CAAM,IAAI,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC;AAJvC,QAAA,IAAI,QAImC;AACpD,YAAI,CAAC,MAAM,GAAG,CAAC,IAAW,EAAE,GAAU,EAAE,EAAE,CAAC,IAAI,IAAI,CAAM,IAAI,EAAE,GAAG,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/index.d.ts b/node_modules/@noble/hashes/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f36479a733bbeb24edff9b891531da88194073b7 --- /dev/null +++ b/node_modules/@noble/hashes/index.d.ts @@ -0,0 +1 @@ +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/index.d.ts.map b/node_modules/@noble/hashes/index.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..4e8c5816b41ae88c764eefae33e5eb965d87148b --- /dev/null +++ b/node_modules/@noble/hashes/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/node_modules/@noble/hashes/index.js b/node_modules/@noble/hashes/index.js new file mode 100644 index 0000000000000000000000000000000000000000..b6a9fe71c697a873b14a83623a31d7b38fd6e25a --- /dev/null +++ b/node_modules/@noble/hashes/index.js @@ -0,0 +1,33 @@ +"use strict"; +/** + * Audited & minimal JS implementation of hash functions, MACs and KDFs. Check out individual modules. + * @module + * @example +```js +import { + sha256, sha384, sha512, sha224, sha512_224, sha512_256 +} from '@noble/hashes/sha2'; +import { + sha3_224, sha3_256, sha3_384, sha3_512, + keccak_224, keccak_256, keccak_384, keccak_512, + shake128, shake256 +} from '@noble/hashes/sha3'; +import { + cshake128, cshake256, + turboshake128, turboshake256, + kmac128, kmac256, + tuplehash256, parallelhash256, + k12, m14, keccakprg +} from '@noble/hashes/sha3-addons'; +import { blake3 } from '@noble/hashes/blake3'; +import { blake2b, blake2s } from '@noble/hashes/blake2'; +import { hmac } from '@noble/hashes/hmac'; +import { hkdf } from '@noble/hashes/hkdf'; +import { pbkdf2, pbkdf2Async } from '@noble/hashes/pbkdf2'; +import { scrypt, scryptAsync } from '@noble/hashes/scrypt'; +import { md5, ripemd160, sha1 } from '@noble/hashes/legacy'; +import * as utils from '@noble/hashes/utils'; +``` + */ +throw new Error('root module cannot be imported: import submodules instead. Check out README'); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/index.js.map b/node_modules/@noble/hashes/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..1759fc616f41c10fbf5a01348a0a0b1fcb7db129 --- /dev/null +++ b/node_modules/@noble/hashes/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,IAAI,KAAK,CAAC,6EAA6E,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/legacy.d.ts b/node_modules/@noble/hashes/legacy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..39c2632d9a3396496304101fefa7fe4abc745490 --- /dev/null +++ b/node_modules/@noble/hashes/legacy.d.ts @@ -0,0 +1,71 @@ +/** + +SHA1 (RFC 3174), MD5 (RFC 1321) and RIPEMD160 (RFC 2286) legacy, weak hash functions. +Don't use them in a new protocol. What "weak" means: + +- Collisions can be made with 2^18 effort in MD5, 2^60 in SHA1, 2^80 in RIPEMD160. +- No practical pre-image attacks (only theoretical, 2^123.4) +- HMAC seems kinda ok: https://datatracker.ietf.org/doc/html/rfc6151 + * @module + */ +import { HashMD } from './_md.ts'; +import { type CHash } from './utils.ts'; +/** SHA1 legacy hash class. */ +export declare class SHA1 extends HashMD { + private A; + private B; + private C; + private D; + private E; + constructor(); + protected get(): [number, number, number, number, number]; + protected set(A: number, B: number, C: number, D: number, E: number): void; + protected process(view: DataView, offset: number): void; + protected roundClean(): void; + destroy(): void; +} +/** SHA1 (RFC 3174) legacy hash function. It was cryptographically broken. */ +export declare const sha1: CHash; +/** MD5 legacy hash class. */ +export declare class MD5 extends HashMD { + private A; + private B; + private C; + private D; + constructor(); + protected get(): [number, number, number, number]; + protected set(A: number, B: number, C: number, D: number): void; + protected process(view: DataView, offset: number): void; + protected roundClean(): void; + destroy(): void; +} +/** + * MD5 (RFC 1321) legacy hash function. It was cryptographically broken. + * MD5 architecture is similar to SHA1, with some differences: + * - Reduced output length: 16 bytes (128 bit) instead of 20 + * - 64 rounds, instead of 80 + * - Little-endian: could be faster, but will require more code + * - Non-linear index selection: huge speed-up for unroll + * - Per round constants: more memory accesses, additional speed-up for unroll + */ +export declare const md5: CHash; +export declare class RIPEMD160 extends HashMD { + private h0; + private h1; + private h2; + private h3; + private h4; + constructor(); + protected get(): [number, number, number, number, number]; + protected set(h0: number, h1: number, h2: number, h3: number, h4: number): void; + protected process(view: DataView, offset: number): void; + protected roundClean(): void; + destroy(): void; +} +/** + * RIPEMD-160 - a legacy hash function from 1990s. + * * https://homes.esat.kuleuven.be/~bosselae/ripemd160.html + * * https://homes.esat.kuleuven.be/~bosselae/ripemd160/pdf/AB-9601/AB-9601.pdf + */ +export declare const ripemd160: CHash; +//# sourceMappingURL=legacy.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/legacy.d.ts.map b/node_modules/@noble/hashes/legacy.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..0401f7855ad03982e0ea1de4c9ff102de7bf4dc3 --- /dev/null +++ b/node_modules/@noble/hashes/legacy.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"legacy.d.ts","sourceRoot":"","sources":["src/legacy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAO,MAAM,EAAO,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,KAAK,KAAK,EAA6B,MAAM,YAAY,CAAC;AAUnE,8BAA8B;AAC9B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,IAAI,IAAI;CAIhB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,GAAG,EAAE,KAAqD,CAAC;AA6CxE,qBAAa,SAAU,SAAQ,MAAM,CAAC,SAAS,CAAC;IAC9C,OAAO,CAAC,EAAE,CAAkB;IAC5B,OAAO,CAAC,EAAE,CAAkB;IAC5B,OAAO,CAAC,EAAE,CAAkB;IAC5B,OAAO,CAAC,EAAE,CAAkB;IAC5B,OAAO,CAAC,EAAE,CAAkB;;IAK5B,SAAS,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;IAIzD,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI;IAO/E,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAmCvD,SAAS,CAAC,UAAU,IAAI,IAAI;IAG5B,OAAO,IAAI,IAAI;CAKhB;AAED;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,KAA2D,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/legacy.js b/node_modules/@noble/hashes/legacy.js new file mode 100644 index 0000000000000000000000000000000000000000..2f8f9c631628a71dec625c9534d1eaf5c5b10b8c --- /dev/null +++ b/node_modules/@noble/hashes/legacy.js @@ -0,0 +1,287 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ripemd160 = exports.RIPEMD160 = exports.md5 = exports.MD5 = exports.sha1 = exports.SHA1 = void 0; +/** + +SHA1 (RFC 3174), MD5 (RFC 1321) and RIPEMD160 (RFC 2286) legacy, weak hash functions. +Don't use them in a new protocol. What "weak" means: + +- Collisions can be made with 2^18 effort in MD5, 2^60 in SHA1, 2^80 in RIPEMD160. +- No practical pre-image attacks (only theoretical, 2^123.4) +- HMAC seems kinda ok: https://datatracker.ietf.org/doc/html/rfc6151 + * @module + */ +const _md_ts_1 = require("./_md.js"); +const utils_ts_1 = require("./utils.js"); +/** Initial SHA1 state */ +const SHA1_IV = /* @__PURE__ */ Uint32Array.from([ + 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0, +]); +// Reusable temporary buffer +const SHA1_W = /* @__PURE__ */ new Uint32Array(80); +/** SHA1 legacy hash class. */ +class SHA1 extends _md_ts_1.HashMD { + constructor() { + super(64, 20, 8, false); + this.A = SHA1_IV[0] | 0; + this.B = SHA1_IV[1] | 0; + this.C = SHA1_IV[2] | 0; + this.D = SHA1_IV[3] | 0; + this.E = SHA1_IV[4] | 0; + } + get() { + const { A, B, C, D, E } = this; + return [A, B, C, D, E]; + } + set(A, B, C, D, E) { + this.A = A | 0; + this.B = B | 0; + this.C = C | 0; + this.D = D | 0; + this.E = E | 0; + } + process(view, offset) { + for (let i = 0; i < 16; i++, offset += 4) + SHA1_W[i] = view.getUint32(offset, false); + for (let i = 16; i < 80; i++) + SHA1_W[i] = (0, utils_ts_1.rotl)(SHA1_W[i - 3] ^ SHA1_W[i - 8] ^ SHA1_W[i - 14] ^ SHA1_W[i - 16], 1); + // Compression function main loop, 80 rounds + let { A, B, C, D, E } = this; + for (let i = 0; i < 80; i++) { + let F, K; + if (i < 20) { + F = (0, _md_ts_1.Chi)(B, C, D); + K = 0x5a827999; + } + else if (i < 40) { + F = B ^ C ^ D; + K = 0x6ed9eba1; + } + else if (i < 60) { + F = (0, _md_ts_1.Maj)(B, C, D); + K = 0x8f1bbcdc; + } + else { + F = B ^ C ^ D; + K = 0xca62c1d6; + } + const T = ((0, utils_ts_1.rotl)(A, 5) + F + E + K + SHA1_W[i]) | 0; + E = D; + D = C; + C = (0, utils_ts_1.rotl)(B, 30); + B = A; + A = T; + } + // Add the compressed chunk to the current hash value + A = (A + this.A) | 0; + B = (B + this.B) | 0; + C = (C + this.C) | 0; + D = (D + this.D) | 0; + E = (E + this.E) | 0; + this.set(A, B, C, D, E); + } + roundClean() { + (0, utils_ts_1.clean)(SHA1_W); + } + destroy() { + this.set(0, 0, 0, 0, 0); + (0, utils_ts_1.clean)(this.buffer); + } +} +exports.SHA1 = SHA1; +/** SHA1 (RFC 3174) legacy hash function. It was cryptographically broken. */ +exports.sha1 = (0, utils_ts_1.createHasher)(() => new SHA1()); +/** Per-round constants */ +const p32 = /* @__PURE__ */ Math.pow(2, 32); +const K = /* @__PURE__ */ Array.from({ length: 64 }, (_, i) => Math.floor(p32 * Math.abs(Math.sin(i + 1)))); +/** md5 initial state: same as sha1, but 4 u32 instead of 5. */ +const MD5_IV = /* @__PURE__ */ SHA1_IV.slice(0, 4); +// Reusable temporary buffer +const MD5_W = /* @__PURE__ */ new Uint32Array(16); +/** MD5 legacy hash class. */ +class MD5 extends _md_ts_1.HashMD { + constructor() { + super(64, 16, 8, true); + this.A = MD5_IV[0] | 0; + this.B = MD5_IV[1] | 0; + this.C = MD5_IV[2] | 0; + this.D = MD5_IV[3] | 0; + } + get() { + const { A, B, C, D } = this; + return [A, B, C, D]; + } + set(A, B, C, D) { + this.A = A | 0; + this.B = B | 0; + this.C = C | 0; + this.D = D | 0; + } + process(view, offset) { + for (let i = 0; i < 16; i++, offset += 4) + MD5_W[i] = view.getUint32(offset, true); + // Compression function main loop, 64 rounds + let { A, B, C, D } = this; + for (let i = 0; i < 64; i++) { + let F, g, s; + if (i < 16) { + F = (0, _md_ts_1.Chi)(B, C, D); + g = i; + s = [7, 12, 17, 22]; + } + else if (i < 32) { + F = (0, _md_ts_1.Chi)(D, B, C); + g = (5 * i + 1) % 16; + s = [5, 9, 14, 20]; + } + else if (i < 48) { + F = B ^ C ^ D; + g = (3 * i + 5) % 16; + s = [4, 11, 16, 23]; + } + else { + F = C ^ (B | ~D); + g = (7 * i) % 16; + s = [6, 10, 15, 21]; + } + F = F + A + K[i] + MD5_W[g]; + A = D; + D = C; + C = B; + B = B + (0, utils_ts_1.rotl)(F, s[i % 4]); + } + // Add the compressed chunk to the current hash value + A = (A + this.A) | 0; + B = (B + this.B) | 0; + C = (C + this.C) | 0; + D = (D + this.D) | 0; + this.set(A, B, C, D); + } + roundClean() { + (0, utils_ts_1.clean)(MD5_W); + } + destroy() { + this.set(0, 0, 0, 0); + (0, utils_ts_1.clean)(this.buffer); + } +} +exports.MD5 = MD5; +/** + * MD5 (RFC 1321) legacy hash function. It was cryptographically broken. + * MD5 architecture is similar to SHA1, with some differences: + * - Reduced output length: 16 bytes (128 bit) instead of 20 + * - 64 rounds, instead of 80 + * - Little-endian: could be faster, but will require more code + * - Non-linear index selection: huge speed-up for unroll + * - Per round constants: more memory accesses, additional speed-up for unroll + */ +exports.md5 = (0, utils_ts_1.createHasher)(() => new MD5()); +// RIPEMD-160 +const Rho160 = /* @__PURE__ */ Uint8Array.from([ + 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, +]); +const Id160 = /* @__PURE__ */ (() => Uint8Array.from(new Array(16).fill(0).map((_, i) => i)))(); +const Pi160 = /* @__PURE__ */ (() => Id160.map((i) => (9 * i + 5) % 16))(); +const idxLR = /* @__PURE__ */ (() => { + const L = [Id160]; + const R = [Pi160]; + const res = [L, R]; + for (let i = 0; i < 4; i++) + for (let j of res) + j.push(j[i].map((k) => Rho160[k])); + return res; +})(); +const idxL = /* @__PURE__ */ (() => idxLR[0])(); +const idxR = /* @__PURE__ */ (() => idxLR[1])(); +// const [idxL, idxR] = idxLR; +const shifts160 = /* @__PURE__ */ [ + [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8], + [12, 13, 11, 15, 6, 9, 9, 7, 12, 15, 11, 13, 7, 8, 7, 7], + [13, 15, 14, 11, 7, 7, 6, 8, 13, 14, 13, 12, 5, 5, 6, 9], + [14, 11, 12, 14, 8, 6, 5, 5, 15, 12, 15, 14, 9, 9, 8, 6], + [15, 12, 13, 13, 9, 5, 8, 6, 14, 11, 12, 11, 8, 6, 5, 5], +].map((i) => Uint8Array.from(i)); +const shiftsL160 = /* @__PURE__ */ idxL.map((idx, i) => idx.map((j) => shifts160[i][j])); +const shiftsR160 = /* @__PURE__ */ idxR.map((idx, i) => idx.map((j) => shifts160[i][j])); +const Kl160 = /* @__PURE__ */ Uint32Array.from([ + 0x00000000, 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xa953fd4e, +]); +const Kr160 = /* @__PURE__ */ Uint32Array.from([ + 0x50a28be6, 0x5c4dd124, 0x6d703ef3, 0x7a6d76e9, 0x00000000, +]); +// It's called f() in spec. +function ripemd_f(group, x, y, z) { + if (group === 0) + return x ^ y ^ z; + if (group === 1) + return (x & y) | (~x & z); + if (group === 2) + return (x | ~y) ^ z; + if (group === 3) + return (x & z) | (y & ~z); + return x ^ (y | ~z); +} +// Reusable temporary buffer +const BUF_160 = /* @__PURE__ */ new Uint32Array(16); +class RIPEMD160 extends _md_ts_1.HashMD { + constructor() { + super(64, 20, 8, true); + this.h0 = 0x67452301 | 0; + this.h1 = 0xefcdab89 | 0; + this.h2 = 0x98badcfe | 0; + this.h3 = 0x10325476 | 0; + this.h4 = 0xc3d2e1f0 | 0; + } + get() { + const { h0, h1, h2, h3, h4 } = this; + return [h0, h1, h2, h3, h4]; + } + set(h0, h1, h2, h3, h4) { + this.h0 = h0 | 0; + this.h1 = h1 | 0; + this.h2 = h2 | 0; + this.h3 = h3 | 0; + this.h4 = h4 | 0; + } + process(view, offset) { + for (let i = 0; i < 16; i++, offset += 4) + BUF_160[i] = view.getUint32(offset, true); + // prettier-ignore + let al = this.h0 | 0, ar = al, bl = this.h1 | 0, br = bl, cl = this.h2 | 0, cr = cl, dl = this.h3 | 0, dr = dl, el = this.h4 | 0, er = el; + // Instead of iterating 0 to 80, we split it into 5 groups + // And use the groups in constants, functions, etc. Much simpler + for (let group = 0; group < 5; group++) { + const rGroup = 4 - group; + const hbl = Kl160[group], hbr = Kr160[group]; // prettier-ignore + const rl = idxL[group], rr = idxR[group]; // prettier-ignore + const sl = shiftsL160[group], sr = shiftsR160[group]; // prettier-ignore + for (let i = 0; i < 16; i++) { + const tl = ((0, utils_ts_1.rotl)(al + ripemd_f(group, bl, cl, dl) + BUF_160[rl[i]] + hbl, sl[i]) + el) | 0; + al = el, el = dl, dl = (0, utils_ts_1.rotl)(cl, 10) | 0, cl = bl, bl = tl; // prettier-ignore + } + // 2 loops are 10% faster + for (let i = 0; i < 16; i++) { + const tr = ((0, utils_ts_1.rotl)(ar + ripemd_f(rGroup, br, cr, dr) + BUF_160[rr[i]] + hbr, sr[i]) + er) | 0; + ar = er, er = dr, dr = (0, utils_ts_1.rotl)(cr, 10) | 0, cr = br, br = tr; // prettier-ignore + } + } + // Add the compressed chunk to the current hash value + this.set((this.h1 + cl + dr) | 0, (this.h2 + dl + er) | 0, (this.h3 + el + ar) | 0, (this.h4 + al + br) | 0, (this.h0 + bl + cr) | 0); + } + roundClean() { + (0, utils_ts_1.clean)(BUF_160); + } + destroy() { + this.destroyed = true; + (0, utils_ts_1.clean)(this.buffer); + this.set(0, 0, 0, 0, 0); + } +} +exports.RIPEMD160 = RIPEMD160; +/** + * RIPEMD-160 - a legacy hash function from 1990s. + * * https://homes.esat.kuleuven.be/~bosselae/ripemd160.html + * * https://homes.esat.kuleuven.be/~bosselae/ripemd160/pdf/AB-9601/AB-9601.pdf + */ +exports.ripemd160 = (0, utils_ts_1.createHasher)(() => new RIPEMD160()); +//# sourceMappingURL=legacy.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/legacy.js.map b/node_modules/@noble/hashes/legacy.js.map new file mode 100644 index 0000000000000000000000000000000000000000..f1c3a81a903231a7dd9f774d1a453b89b63a80c0 --- /dev/null +++ b/node_modules/@noble/hashes/legacy.js.map @@ -0,0 +1 @@ +{"version":3,"file":"legacy.js","sourceRoot":"","sources":["src/legacy.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,qCAA4C;AAC5C,yCAAmE;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;gBAC5F,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,IAAA,eAAI,EAAC,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,kBAAkB;YAC/E,CAAC;QACH,CAAC;QACD,qDAAqD;QACrD,IAAI,CAAC,GAAG,CACN,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EACvB,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EACvB,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EACvB,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EACvB,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CACxB,CAAC;IACJ,CAAC;IACS,UAAU;QAClB,IAAA,gBAAK,EAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IACD,OAAO;QACL,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAA,gBAAK,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnB,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1B,CAAC;CACF;AAhED,8BAgEC;AAED;;;;GAIG;AACU,QAAA,SAAS,GAA0B,IAAA,uBAAY,EAAC,GAAG,EAAE,CAAC,IAAI,SAAS,EAAE,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/package.json b/node_modules/@noble/hashes/package.json new file mode 100644 index 0000000000000000000000000000000000000000..4d2fc73b40c26ffdb4f6a2e3cb59520f608ded4f --- /dev/null +++ b/node_modules/@noble/hashes/package.json @@ -0,0 +1,266 @@ +{ + "name": "@noble/hashes", + "version": "1.8.0", + "description": "Audited & minimal 0-dependency JS implementation of SHA, RIPEMD, BLAKE, HMAC, HKDF, PBKDF & Scrypt", + "files": [ + "/*.js", + "/*.js.map", + "/*.d.ts", + "/*.d.ts.map", + "esm", + "src/*.ts" + ], + "scripts": { + "bench": "node benchmark/noble.js", + "bench:compare": "MBENCH_DIMS='algorithm,buffer,library' node benchmark/hashes.js", + "bench:compare-hkdf": "MBENCH_DIMS='algorithm,length,library' node benchmark/hkdf.js", + "bench:compare-scrypt": "MBENCH_DIMS='iters,library' MBENCH_FILTER='async' node benchmark/scrypt.js", + "bench:install": "cd benchmark; npm install; npm install .. --install-links", + "build": "npm run build:clean; tsc && tsc -p tsconfig.cjs.json", + "build:clean": "rm -f *.{js,d.ts,js.map,d.ts.map} esm/*.{js,js.map,d.ts.map}", + "build:release": "npx jsbt esbuild test/build", + "lint": "prettier --check 'src/**/*.{js,ts}' 'test/**/*.{js,ts}'", + "format": "prettier --write 'src/**/*.{js,ts}' 'test/**/*.{js,ts}'", + "test": "node --import ./test/esm-register.js test/index.js", + "test:bun": "bun test/index.js", + "test:deno": "deno --allow-env --allow-read --import-map=./test/import_map.json test/index.js", + "test:dos": "node --import ./test/esm-register.js test/slow-dos.test.js", + "test:big": "node --import ./test/esm-register.js test/slow-big.test.js", + "test:kdf": "node --import ./test/esm-register.js test/slow-kdf.test.js" + }, + "author": "Paul Miller (https://paulmillr.com)", + "homepage": "https://paulmillr.com/noble/", + "repository": { + "type": "git", + "url": "git+https://github.com/paulmillr/noble-hashes.git" + }, + "license": "MIT", + "devDependencies": { + "@paulmillr/jsbt": "0.3.3", + "fast-check": "3.0.0", + "micro-bmark": "0.4.1", + "micro-should": "0.5.2", + "prettier": "3.5.3", + "typescript": "5.8.3" + }, + "engines": { + "node": "^14.21.3 || >=16" + }, + "exports": { + ".": { + "import": "./esm/index.js", + "require": "./index.js" + }, + "./crypto": { + "node": { + "import": "./esm/cryptoNode.js", + "default": "./cryptoNode.js" + }, + "import": "./esm/crypto.js", + "default": "./crypto.js" + }, + "./_assert": { + "import": "./esm/_assert.js", + "require": "./_assert.js" + }, + "./_md": { + "import": "./esm/_md.js", + "require": "./_md.js" + }, + "./argon2": { + "import": "./esm/argon2.js", + "require": "./argon2.js" + }, + "./blake1": { + "import": "./esm/blake1.js", + "require": "./blake1.js" + }, + "./blake2": { + "import": "./esm/blake2.js", + "require": "./blake2.js" + }, + "./blake2b": { + "import": "./esm/blake2b.js", + "require": "./blake2b.js" + }, + "./blake2s": { + "import": "./esm/blake2s.js", + "require": "./blake2s.js" + }, + "./blake3": { + "import": "./esm/blake3.js", + "require": "./blake3.js" + }, + "./eskdf": { + "import": "./esm/eskdf.js", + "require": "./eskdf.js" + }, + "./hkdf": { + "import": "./esm/hkdf.js", + "require": "./hkdf.js" + }, + "./hmac": { + "import": "./esm/hmac.js", + "require": "./hmac.js" + }, + "./legacy": { + "import": "./esm/legacy.js", + "require": "./legacy.js" + }, + "./pbkdf2": { + "import": "./esm/pbkdf2.js", + "require": "./pbkdf2.js" + }, + "./ripemd160": { + "import": "./esm/ripemd160.js", + "require": "./ripemd160.js" + }, + "./scrypt": { + "import": "./esm/scrypt.js", + "require": "./scrypt.js" + }, + "./sha1": { + "import": "./esm/sha1.js", + "require": "./sha1.js" + }, + "./sha2": { + "import": "./esm/sha2.js", + "require": "./sha2.js" + }, + "./sha3-addons": { + "import": "./esm/sha3-addons.js", + "require": "./sha3-addons.js" + }, + "./sha3": { + "import": "./esm/sha3.js", + "require": "./sha3.js" + }, + "./sha256": { + "import": "./esm/sha256.js", + "require": "./sha256.js" + }, + "./sha512": { + "import": "./esm/sha512.js", + "require": "./sha512.js" + }, + "./utils": { + "import": "./esm/utils.js", + "require": "./utils.js" + }, + "./_assert.js": { + "import": "./esm/_assert.js", + "require": "./_assert.js" + }, + "./_md.js": { + "import": "./esm/_md.js", + "require": "./_md.js" + }, + "./argon2.js": { + "import": "./esm/argon2.js", + "require": "./argon2.js" + }, + "./blake1.js": { + "import": "./esm/blake1.js", + "require": "./blake1.js" + }, + "./blake2.js": { + "import": "./esm/blake2.js", + "require": "./blake2.js" + }, + "./blake2b.js": { + "import": "./esm/blake2b.js", + "require": "./blake2b.js" + }, + "./blake2s.js": { + "import": "./esm/blake2s.js", + "require": "./blake2s.js" + }, + "./blake3.js": { + "import": "./esm/blake3.js", + "require": "./blake3.js" + }, + "./eskdf.js": { + "import": "./esm/eskdf.js", + "require": "./eskdf.js" + }, + "./hkdf.js": { + "import": "./esm/hkdf.js", + "require": "./hkdf.js" + }, + "./hmac.js": { + "import": "./esm/hmac.js", + "require": "./hmac.js" + }, + "./legacy.js": { + "import": "./esm/legacy.js", + "require": "./legacy.js" + }, + "./pbkdf2.js": { + "import": "./esm/pbkdf2.js", + "require": "./pbkdf2.js" + }, + "./ripemd160.js": { + "import": "./esm/ripemd160.js", + "require": "./ripemd160.js" + }, + "./scrypt.js": { + "import": "./esm/scrypt.js", + "require": "./scrypt.js" + }, + "./sha1.js": { + "import": "./esm/sha1.js", + "require": "./sha1.js" + }, + "./sha2.js": { + "import": "./esm/sha2.js", + "require": "./sha2.js" + }, + "./sha3-addons.js": { + "import": "./esm/sha3-addons.js", + "require": "./sha3-addons.js" + }, + "./sha3.js": { + "import": "./esm/sha3.js", + "require": "./sha3.js" + }, + "./sha256.js": { + "import": "./esm/sha256.js", + "require": "./sha256.js" + }, + "./sha512.js": { + "import": "./esm/sha512.js", + "require": "./sha512.js" + }, + "./utils.js": { + "import": "./esm/utils.js", + "require": "./utils.js" + } + }, + "sideEffects": false, + "browser": { + "node:crypto": false, + "./crypto": "./crypto.js" + }, + "keywords": [ + "sha", + "sha2", + "sha3", + "sha256", + "sha512", + "keccak", + "kangarootwelve", + "ripemd160", + "blake2", + "blake3", + "hmac", + "hkdf", + "pbkdf2", + "scrypt", + "kdf", + "hash", + "cryptography", + "security", + "noble" + ], + "funding": "https://paulmillr.com/funding/" +} diff --git a/node_modules/@noble/hashes/pbkdf2.d.ts b/node_modules/@noble/hashes/pbkdf2.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0697c694b668b50382e78fed007c39ec3b44f095 --- /dev/null +++ b/node_modules/@noble/hashes/pbkdf2.d.ts @@ -0,0 +1,23 @@ +import { type CHash, type KDFInput } from './utils.ts'; +export type Pbkdf2Opt = { + c: number; + dkLen?: number; + asyncTick?: number; +}; +/** + * PBKDF2-HMAC: RFC 2898 key derivation function + * @param hash - hash function that would be used e.g. sha256 + * @param password - password from which a derived key is generated + * @param salt - cryptographic salt + * @param opts - {c, dkLen} where c is work factor and dkLen is output message size + * @example + * const key = pbkdf2(sha256, 'password', 'salt', { dkLen: 32, c: Math.pow(2, 18) }); + */ +export declare function pbkdf2(hash: CHash, password: KDFInput, salt: KDFInput, opts: Pbkdf2Opt): Uint8Array; +/** + * PBKDF2-HMAC: RFC 2898 key derivation function. Async version. + * @example + * await pbkdf2Async(sha256, 'password', 'salt', { dkLen: 32, c: 500_000 }); + */ +export declare function pbkdf2Async(hash: CHash, password: KDFInput, salt: KDFInput, opts: Pbkdf2Opt): Promise; +//# sourceMappingURL=pbkdf2.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/pbkdf2.d.ts.map b/node_modules/@noble/hashes/pbkdf2.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..a4d30f3bad39e1bb00d85f9ff616984966346cd7 --- /dev/null +++ b/node_modules/@noble/hashes/pbkdf2.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"pbkdf2.d.ts","sourceRoot":"","sources":["src/pbkdf2.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,KAAK,EACV,KAAK,QAAQ,EACd,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,SAAS,GAAG;IACtB,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAkCF;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CACpB,IAAI,EAAE,KAAK,EACX,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,SAAS,GACd,UAAU,CAsBZ;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAC/B,IAAI,EAAE,KAAK,EACX,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,SAAS,GACd,OAAO,CAAC,UAAU,CAAC,CAsBrB"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/pbkdf2.js b/node_modules/@noble/hashes/pbkdf2.js new file mode 100644 index 0000000000000000000000000000000000000000..0d8cab0e2d79c33b22aade0ac778506677f0f678 --- /dev/null +++ b/node_modules/@noble/hashes/pbkdf2.js @@ -0,0 +1,101 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.pbkdf2 = pbkdf2; +exports.pbkdf2Async = pbkdf2Async; +/** + * PBKDF (RFC 2898). Can be used to create a key from password and salt. + * @module + */ +const hmac_ts_1 = require("./hmac.js"); +// prettier-ignore +const utils_ts_1 = require("./utils.js"); +// Common prologue and epilogue for sync/async functions +function pbkdf2Init(hash, _password, _salt, _opts) { + (0, utils_ts_1.ahash)(hash); + const opts = (0, utils_ts_1.checkOpts)({ dkLen: 32, asyncTick: 10 }, _opts); + const { c, dkLen, asyncTick } = opts; + (0, utils_ts_1.anumber)(c); + (0, utils_ts_1.anumber)(dkLen); + (0, utils_ts_1.anumber)(asyncTick); + if (c < 1) + throw new Error('iterations (c) should be >= 1'); + const password = (0, utils_ts_1.kdfInputToBytes)(_password); + const salt = (0, utils_ts_1.kdfInputToBytes)(_salt); + // DK = PBKDF2(PRF, Password, Salt, c, dkLen); + const DK = new Uint8Array(dkLen); + // U1 = PRF(Password, Salt + INT_32_BE(i)) + const PRF = hmac_ts_1.hmac.create(hash, password); + const PRFSalt = PRF._cloneInto().update(salt); + return { c, dkLen, asyncTick, DK, PRF, PRFSalt }; +} +function pbkdf2Output(PRF, PRFSalt, DK, prfW, u) { + PRF.destroy(); + PRFSalt.destroy(); + if (prfW) + prfW.destroy(); + (0, utils_ts_1.clean)(u); + return DK; +} +/** + * PBKDF2-HMAC: RFC 2898 key derivation function + * @param hash - hash function that would be used e.g. sha256 + * @param password - password from which a derived key is generated + * @param salt - cryptographic salt + * @param opts - {c, dkLen} where c is work factor and dkLen is output message size + * @example + * const key = pbkdf2(sha256, 'password', 'salt', { dkLen: 32, c: Math.pow(2, 18) }); + */ +function pbkdf2(hash, password, salt, opts) { + const { c, dkLen, DK, PRF, PRFSalt } = pbkdf2Init(hash, password, salt, opts); + let prfW; // Working copy + const arr = new Uint8Array(4); + const view = (0, utils_ts_1.createView)(arr); + const u = new Uint8Array(PRF.outputLen); + // DK = T1 + T2 + ⋯ + Tdklen/hlen + for (let ti = 1, pos = 0; pos < dkLen; ti++, pos += PRF.outputLen) { + // Ti = F(Password, Salt, c, i) + const Ti = DK.subarray(pos, pos + PRF.outputLen); + view.setInt32(0, ti, false); + // F(Password, Salt, c, i) = U1 ^ U2 ^ ⋯ ^ Uc + // U1 = PRF(Password, Salt + INT_32_BE(i)) + (prfW = PRFSalt._cloneInto(prfW)).update(arr).digestInto(u); + Ti.set(u.subarray(0, Ti.length)); + for (let ui = 1; ui < c; ui++) { + // Uc = PRF(Password, Uc−1) + PRF._cloneInto(prfW).update(u).digestInto(u); + for (let i = 0; i < Ti.length; i++) + Ti[i] ^= u[i]; + } + } + return pbkdf2Output(PRF, PRFSalt, DK, prfW, u); +} +/** + * PBKDF2-HMAC: RFC 2898 key derivation function. Async version. + * @example + * await pbkdf2Async(sha256, 'password', 'salt', { dkLen: 32, c: 500_000 }); + */ +async function pbkdf2Async(hash, password, salt, opts) { + const { c, dkLen, asyncTick, DK, PRF, PRFSalt } = pbkdf2Init(hash, password, salt, opts); + let prfW; // Working copy + const arr = new Uint8Array(4); + const view = (0, utils_ts_1.createView)(arr); + const u = new Uint8Array(PRF.outputLen); + // DK = T1 + T2 + ⋯ + Tdklen/hlen + for (let ti = 1, pos = 0; pos < dkLen; ti++, pos += PRF.outputLen) { + // Ti = F(Password, Salt, c, i) + const Ti = DK.subarray(pos, pos + PRF.outputLen); + view.setInt32(0, ti, false); + // F(Password, Salt, c, i) = U1 ^ U2 ^ ⋯ ^ Uc + // U1 = PRF(Password, Salt + INT_32_BE(i)) + (prfW = PRFSalt._cloneInto(prfW)).update(arr).digestInto(u); + Ti.set(u.subarray(0, Ti.length)); + await (0, utils_ts_1.asyncLoop)(c - 1, asyncTick, () => { + // Uc = PRF(Password, Uc−1) + PRF._cloneInto(prfW).update(u).digestInto(u); + for (let i = 0; i < Ti.length; i++) + Ti[i] ^= u[i]; + }); + } + return pbkdf2Output(PRF, PRFSalt, DK, prfW, u); +} +//# sourceMappingURL=pbkdf2.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/pbkdf2.js.map b/node_modules/@noble/hashes/pbkdf2.js.map new file mode 100644 index 0000000000000000000000000000000000000000..4579c9f89c6dc5a6ddeb091bd12460cfd2be1b20 --- /dev/null +++ b/node_modules/@noble/hashes/pbkdf2.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pbkdf2.js","sourceRoot":"","sources":["src/pbkdf2.ts"],"names":[],"mappings":";;AA4DA,wBA2BC;AAOD,kCA2BC;AAzHD;;;GAGG;AACH,uCAAiC;AACjC,kBAAkB;AAClB,yCAKoB;AAOpB,wDAAwD;AACxD,SAAS,UAAU,CAAC,IAAW,EAAE,SAAmB,EAAE,KAAe,EAAE,KAAgB;IACrF,IAAA,gBAAK,EAAC,IAAI,CAAC,CAAC;IACZ,MAAM,IAAI,GAAG,IAAA,oBAAS,EAAC,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;IAC5D,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IACrC,IAAA,kBAAO,EAAC,CAAC,CAAC,CAAC;IACX,IAAA,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GAAG,EAAE;YACrC,2BAA2B;YAC3B,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YAC7C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE;gBAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACjD,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/ripemd160.d.ts b/node_modules/@noble/hashes/ripemd160.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2fb0fa7acfd41e8c706bb2e411137f30df2ae82d --- /dev/null +++ b/node_modules/@noble/hashes/ripemd160.d.ts @@ -0,0 +1,13 @@ +/** + * RIPEMD-160 legacy hash function. + * https://homes.esat.kuleuven.be/~bosselae/ripemd160.html + * https://homes.esat.kuleuven.be/~bosselae/ripemd160/pdf/AB-9601/AB-9601.pdf + * @module + * @deprecated + */ +import { RIPEMD160 as RIPEMD160n, ripemd160 as ripemd160n } from './legacy.ts'; +/** @deprecated Use import from `noble/hashes/legacy` module */ +export declare const RIPEMD160: typeof RIPEMD160n; +/** @deprecated Use import from `noble/hashes/legacy` module */ +export declare const ripemd160: typeof ripemd160n; +//# sourceMappingURL=ripemd160.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/ripemd160.d.ts.map b/node_modules/@noble/hashes/ripemd160.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..f2050f4bb99879e0a57990aa1e6b2a184443d7fb --- /dev/null +++ b/node_modules/@noble/hashes/ripemd160.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ripemd160.d.ts","sourceRoot":"","sources":["src/ripemd160.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,SAAS,IAAI,UAAU,EAAE,SAAS,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC;AAC/E,+DAA+D;AAC/D,eAAO,MAAM,SAAS,EAAE,OAAO,UAAuB,CAAC;AACvD,+DAA+D;AAC/D,eAAO,MAAM,SAAS,EAAE,OAAO,UAAuB,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/ripemd160.js b/node_modules/@noble/hashes/ripemd160.js new file mode 100644 index 0000000000000000000000000000000000000000..9561e7bb23f679cca0e7af59d91aed1241ab4e00 --- /dev/null +++ b/node_modules/@noble/hashes/ripemd160.js @@ -0,0 +1,16 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ripemd160 = exports.RIPEMD160 = void 0; +/** + * RIPEMD-160 legacy hash function. + * https://homes.esat.kuleuven.be/~bosselae/ripemd160.html + * https://homes.esat.kuleuven.be/~bosselae/ripemd160/pdf/AB-9601/AB-9601.pdf + * @module + * @deprecated + */ +const legacy_ts_1 = require("./legacy.js"); +/** @deprecated Use import from `noble/hashes/legacy` module */ +exports.RIPEMD160 = legacy_ts_1.RIPEMD160; +/** @deprecated Use import from `noble/hashes/legacy` module */ +exports.ripemd160 = legacy_ts_1.ripemd160; +//# sourceMappingURL=ripemd160.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/ripemd160.js.map b/node_modules/@noble/hashes/ripemd160.js.map new file mode 100644 index 0000000000000000000000000000000000000000..5dc975ed727ef2747ca6a1519b05c2f22b18d30a --- /dev/null +++ b/node_modules/@noble/hashes/ripemd160.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ripemd160.js","sourceRoot":"","sources":["src/ripemd160.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,2CAA+E;AAC/E,+DAA+D;AAClD,QAAA,SAAS,GAAsB,qBAAU,CAAC;AACvD,+DAA+D;AAClD,QAAA,SAAS,GAAsB,qBAAU,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/scrypt.d.ts b/node_modules/@noble/hashes/scrypt.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..38d0ef9714e90bbf342af1c8ae40cebff8f5dca2 --- /dev/null +++ b/node_modules/@noble/hashes/scrypt.d.ts @@ -0,0 +1,34 @@ +import { type KDFInput } from './utils.ts'; +export type ScryptOpts = { + N: number; + r: number; + p: number; + dkLen?: number; + asyncTick?: number; + maxmem?: number; + onProgress?: (progress: number) => void; +}; +/** + * Scrypt KDF from RFC 7914. + * @param password - pass + * @param salt - salt + * @param opts - parameters + * - `N` is cpu/mem work factor (power of 2 e.g. 2**18) + * - `r` is block size (8 is common), fine-tunes sequential memory read size and performance + * - `p` is parallelization factor (1 is common) + * - `dkLen` is output key length in bytes e.g. 32. + * - `asyncTick` - (default: 10) max time in ms for which async function can block execution + * - `maxmem` - (default: `1024 ** 3 + 1024` aka 1GB+1KB). A limit that the app could use for scrypt + * - `onProgress` - callback function that would be executed for progress report + * @returns Derived key + * @example + * scrypt('password', 'salt', { N: 2**18, r: 8, p: 1, dkLen: 32 }); + */ +export declare function scrypt(password: KDFInput, salt: KDFInput, opts: ScryptOpts): Uint8Array; +/** + * Scrypt KDF from RFC 7914. Async version. + * @example + * await scryptAsync('password', 'salt', { N: 2**18, r: 8, p: 1, dkLen: 32 }); + */ +export declare function scryptAsync(password: KDFInput, salt: KDFInput, opts: ScryptOpts): Promise; +//# sourceMappingURL=scrypt.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/scrypt.d.ts.map b/node_modules/@noble/hashes/scrypt.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..49860bc05fe820ec673f0fb0a599136202527d27 --- /dev/null +++ b/node_modules/@noble/hashes/scrypt.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"scrypt.d.ts","sourceRoot":"","sources":["src/scrypt.ts"],"names":[],"mappings":"AAOA,OAAO,EAGL,KAAK,QAAQ,EAGd,MAAM,YAAY,CAAC;AAuEpB,MAAM,MAAM,UAAU,GAAG;IACvB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC,CAAC;AAoFF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,GAAG,UAAU,CA0BvF;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,UAAU,CAAC,CA2BrB"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/scrypt.js b/node_modules/@noble/hashes/scrypt.js new file mode 100644 index 0000000000000000000000000000000000000000..18605c8c8e189b7e1635c13fa692f2cdec197eca --- /dev/null +++ b/node_modules/@noble/hashes/scrypt.js @@ -0,0 +1,232 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.scrypt = scrypt; +exports.scryptAsync = scryptAsync; +/** + * RFC 7914 Scrypt KDF. Can be used to create a key from password and salt. + * @module + */ +const pbkdf2_ts_1 = require("./pbkdf2.js"); +const sha2_ts_1 = require("./sha2.js"); +// prettier-ignore +const utils_ts_1 = require("./utils.js"); +// The main Scrypt loop: uses Salsa extensively. +// Six versions of the function were tried, this is the fastest one. +// prettier-ignore +function XorAndSalsa(prev, pi, input, ii, out, oi) { + // Based on https://cr.yp.to/salsa20.html + // Xor blocks + let y00 = prev[pi++] ^ input[ii++], y01 = prev[pi++] ^ input[ii++]; + let y02 = prev[pi++] ^ input[ii++], y03 = prev[pi++] ^ input[ii++]; + let y04 = prev[pi++] ^ input[ii++], y05 = prev[pi++] ^ input[ii++]; + let y06 = prev[pi++] ^ input[ii++], y07 = prev[pi++] ^ input[ii++]; + let y08 = prev[pi++] ^ input[ii++], y09 = prev[pi++] ^ input[ii++]; + let y10 = prev[pi++] ^ input[ii++], y11 = prev[pi++] ^ input[ii++]; + let y12 = prev[pi++] ^ input[ii++], y13 = prev[pi++] ^ input[ii++]; + let y14 = prev[pi++] ^ input[ii++], y15 = prev[pi++] ^ input[ii++]; + // Save state to temporary variables (salsa) + let x00 = y00, x01 = y01, x02 = y02, x03 = y03, x04 = y04, x05 = y05, x06 = y06, x07 = y07, x08 = y08, x09 = y09, x10 = y10, x11 = y11, x12 = y12, x13 = y13, x14 = y14, x15 = y15; + // Main loop (salsa) + for (let i = 0; i < 8; i += 2) { + x04 ^= (0, utils_ts_1.rotl)(x00 + x12 | 0, 7); + x08 ^= (0, utils_ts_1.rotl)(x04 + x00 | 0, 9); + x12 ^= (0, utils_ts_1.rotl)(x08 + x04 | 0, 13); + x00 ^= (0, utils_ts_1.rotl)(x12 + x08 | 0, 18); + x09 ^= (0, utils_ts_1.rotl)(x05 + x01 | 0, 7); + x13 ^= (0, utils_ts_1.rotl)(x09 + x05 | 0, 9); + x01 ^= (0, utils_ts_1.rotl)(x13 + x09 | 0, 13); + x05 ^= (0, utils_ts_1.rotl)(x01 + x13 | 0, 18); + x14 ^= (0, utils_ts_1.rotl)(x10 + x06 | 0, 7); + x02 ^= (0, utils_ts_1.rotl)(x14 + x10 | 0, 9); + x06 ^= (0, utils_ts_1.rotl)(x02 + x14 | 0, 13); + x10 ^= (0, utils_ts_1.rotl)(x06 + x02 | 0, 18); + x03 ^= (0, utils_ts_1.rotl)(x15 + x11 | 0, 7); + x07 ^= (0, utils_ts_1.rotl)(x03 + x15 | 0, 9); + x11 ^= (0, utils_ts_1.rotl)(x07 + x03 | 0, 13); + x15 ^= (0, utils_ts_1.rotl)(x11 + x07 | 0, 18); + x01 ^= (0, utils_ts_1.rotl)(x00 + x03 | 0, 7); + x02 ^= (0, utils_ts_1.rotl)(x01 + x00 | 0, 9); + x03 ^= (0, utils_ts_1.rotl)(x02 + x01 | 0, 13); + x00 ^= (0, utils_ts_1.rotl)(x03 + x02 | 0, 18); + x06 ^= (0, utils_ts_1.rotl)(x05 + x04 | 0, 7); + x07 ^= (0, utils_ts_1.rotl)(x06 + x05 | 0, 9); + x04 ^= (0, utils_ts_1.rotl)(x07 + x06 | 0, 13); + x05 ^= (0, utils_ts_1.rotl)(x04 + x07 | 0, 18); + x11 ^= (0, utils_ts_1.rotl)(x10 + x09 | 0, 7); + x08 ^= (0, utils_ts_1.rotl)(x11 + x10 | 0, 9); + x09 ^= (0, utils_ts_1.rotl)(x08 + x11 | 0, 13); + x10 ^= (0, utils_ts_1.rotl)(x09 + x08 | 0, 18); + x12 ^= (0, utils_ts_1.rotl)(x15 + x14 | 0, 7); + x13 ^= (0, utils_ts_1.rotl)(x12 + x15 | 0, 9); + x14 ^= (0, utils_ts_1.rotl)(x13 + x12 | 0, 13); + x15 ^= (0, utils_ts_1.rotl)(x14 + x13 | 0, 18); + } + // Write output (salsa) + out[oi++] = (y00 + x00) | 0; + out[oi++] = (y01 + x01) | 0; + out[oi++] = (y02 + x02) | 0; + out[oi++] = (y03 + x03) | 0; + out[oi++] = (y04 + x04) | 0; + out[oi++] = (y05 + x05) | 0; + out[oi++] = (y06 + x06) | 0; + out[oi++] = (y07 + x07) | 0; + out[oi++] = (y08 + x08) | 0; + out[oi++] = (y09 + x09) | 0; + out[oi++] = (y10 + x10) | 0; + out[oi++] = (y11 + x11) | 0; + out[oi++] = (y12 + x12) | 0; + out[oi++] = (y13 + x13) | 0; + out[oi++] = (y14 + x14) | 0; + out[oi++] = (y15 + x15) | 0; +} +function BlockMix(input, ii, out, oi, r) { + // The block B is r 128-byte chunks (which is equivalent of 2r 64-byte chunks) + let head = oi + 0; + let tail = oi + 16 * r; + for (let i = 0; i < 16; i++) + out[tail + i] = input[ii + (2 * r - 1) * 16 + i]; // X ← B[2r−1] + for (let i = 0; i < r; i++, head += 16, ii += 16) { + // We write odd & even Yi at same time. Even: 0bXXXXX0 Odd: 0bXXXXX1 + XorAndSalsa(out, tail, input, ii, out, head); // head[i] = Salsa(blockIn[2*i] ^ tail[i-1]) + if (i > 0) + tail += 16; // First iteration overwrites tmp value in tail + XorAndSalsa(out, head, input, (ii += 16), out, tail); // tail[i] = Salsa(blockIn[2*i+1] ^ head[i]) + } +} +// Common prologue and epilogue for sync/async functions +function scryptInit(password, salt, _opts) { + // Maxmem - 1GB+1KB by default + const opts = (0, utils_ts_1.checkOpts)({ + dkLen: 32, + asyncTick: 10, + maxmem: 1024 ** 3 + 1024, + }, _opts); + const { N, r, p, dkLen, asyncTick, maxmem, onProgress } = opts; + (0, utils_ts_1.anumber)(N); + (0, utils_ts_1.anumber)(r); + (0, utils_ts_1.anumber)(p); + (0, utils_ts_1.anumber)(dkLen); + (0, utils_ts_1.anumber)(asyncTick); + (0, utils_ts_1.anumber)(maxmem); + if (onProgress !== undefined && typeof onProgress !== 'function') + throw new Error('progressCb should be function'); + const blockSize = 128 * r; + const blockSize32 = blockSize / 4; + // Max N is 2^32 (Integrify is 32-bit). Real limit is 2^22: JS engines Uint8Array limit is 4GB in 2024. + // Spec check `N >= 2^(blockSize / 8)` is not done for compat with popular libs, + // which used incorrect r: 1, p: 8. Also, the check seems to be a spec error: + // https://www.rfc-editor.org/errata_search.php?rfc=7914 + const pow32 = Math.pow(2, 32); + if (N <= 1 || (N & (N - 1)) !== 0 || N > pow32) { + throw new Error('Scrypt: N must be larger than 1, a power of 2, and less than 2^32'); + } + if (p < 0 || p > ((pow32 - 1) * 32) / blockSize) { + throw new Error('Scrypt: p must be a positive integer less than or equal to ((2^32 - 1) * 32) / (128 * r)'); + } + if (dkLen < 0 || dkLen > (pow32 - 1) * 32) { + throw new Error('Scrypt: dkLen should be positive integer less than or equal to (2^32 - 1) * 32'); + } + const memUsed = blockSize * (N + p); + if (memUsed > maxmem) { + throw new Error('Scrypt: memused is bigger than maxMem. Expected 128 * r * (N + p) > maxmem of ' + maxmem); + } + // [B0...Bp−1] ← PBKDF2HMAC-SHA256(Passphrase, Salt, 1, blockSize*ParallelizationFactor) + // Since it has only one iteration there is no reason to use async variant + const B = (0, pbkdf2_ts_1.pbkdf2)(sha2_ts_1.sha256, password, salt, { c: 1, dkLen: blockSize * p }); + const B32 = (0, utils_ts_1.u32)(B); + // Re-used between parallel iterations. Array(iterations) of B + const V = (0, utils_ts_1.u32)(new Uint8Array(blockSize * N)); + const tmp = (0, utils_ts_1.u32)(new Uint8Array(blockSize)); + let blockMixCb = () => { }; + if (onProgress) { + const totalBlockMix = 2 * N * p; + // Invoke callback if progress changes from 10.01 to 10.02 + // Allows to draw smooth progress bar on up to 8K screen + const callbackPer = Math.max(Math.floor(totalBlockMix / 10000), 1); + let blockMixCnt = 0; + blockMixCb = () => { + blockMixCnt++; + if (onProgress && (!(blockMixCnt % callbackPer) || blockMixCnt === totalBlockMix)) + onProgress(blockMixCnt / totalBlockMix); + }; + } + return { N, r, p, dkLen, blockSize32, V, B32, B, tmp, blockMixCb, asyncTick }; +} +function scryptOutput(password, dkLen, B, V, tmp) { + const res = (0, pbkdf2_ts_1.pbkdf2)(sha2_ts_1.sha256, password, B, { c: 1, dkLen }); + (0, utils_ts_1.clean)(B, V, tmp); + return res; +} +/** + * Scrypt KDF from RFC 7914. + * @param password - pass + * @param salt - salt + * @param opts - parameters + * - `N` is cpu/mem work factor (power of 2 e.g. 2**18) + * - `r` is block size (8 is common), fine-tunes sequential memory read size and performance + * - `p` is parallelization factor (1 is common) + * - `dkLen` is output key length in bytes e.g. 32. + * - `asyncTick` - (default: 10) max time in ms for which async function can block execution + * - `maxmem` - (default: `1024 ** 3 + 1024` aka 1GB+1KB). A limit that the app could use for scrypt + * - `onProgress` - callback function that would be executed for progress report + * @returns Derived key + * @example + * scrypt('password', 'salt', { N: 2**18, r: 8, p: 1, dkLen: 32 }); + */ +function scrypt(password, salt, opts) { + const { N, r, p, dkLen, blockSize32, V, B32, B, tmp, blockMixCb } = scryptInit(password, salt, opts); + (0, utils_ts_1.swap32IfBE)(B32); + for (let pi = 0; pi < p; pi++) { + const Pi = blockSize32 * pi; + for (let i = 0; i < blockSize32; i++) + V[i] = B32[Pi + i]; // V[0] = B[i] + for (let i = 0, pos = 0; i < N - 1; i++) { + BlockMix(V, pos, V, (pos += blockSize32), r); // V[i] = BlockMix(V[i-1]); + blockMixCb(); + } + BlockMix(V, (N - 1) * blockSize32, B32, Pi, r); // Process last element + blockMixCb(); + for (let i = 0; i < N; i++) { + // First u32 of the last 64-byte block (u32 is LE) + const j = B32[Pi + blockSize32 - 16] % N; // j = Integrify(X) % iterations + for (let k = 0; k < blockSize32; k++) + tmp[k] = B32[Pi + k] ^ V[j * blockSize32 + k]; // tmp = B ^ V[j] + BlockMix(tmp, 0, B32, Pi, r); // B = BlockMix(B ^ V[j]) + blockMixCb(); + } + } + (0, utils_ts_1.swap32IfBE)(B32); + return scryptOutput(password, dkLen, B, V, tmp); +} +/** + * Scrypt KDF from RFC 7914. Async version. + * @example + * await scryptAsync('password', 'salt', { N: 2**18, r: 8, p: 1, dkLen: 32 }); + */ +async function scryptAsync(password, salt, opts) { + const { N, r, p, dkLen, blockSize32, V, B32, B, tmp, blockMixCb, asyncTick } = scryptInit(password, salt, opts); + (0, utils_ts_1.swap32IfBE)(B32); + for (let pi = 0; pi < p; pi++) { + const Pi = blockSize32 * pi; + for (let i = 0; i < blockSize32; i++) + V[i] = B32[Pi + i]; // V[0] = B[i] + let pos = 0; + await (0, utils_ts_1.asyncLoop)(N - 1, asyncTick, () => { + BlockMix(V, pos, V, (pos += blockSize32), r); // V[i] = BlockMix(V[i-1]); + blockMixCb(); + }); + BlockMix(V, (N - 1) * blockSize32, B32, Pi, r); // Process last element + blockMixCb(); + await (0, utils_ts_1.asyncLoop)(N, asyncTick, () => { + // First u32 of the last 64-byte block (u32 is LE) + const j = B32[Pi + blockSize32 - 16] % N; // j = Integrify(X) % iterations + for (let k = 0; k < blockSize32; k++) + tmp[k] = B32[Pi + k] ^ V[j * blockSize32 + k]; // tmp = B ^ V[j] + BlockMix(tmp, 0, B32, Pi, r); // B = BlockMix(B ^ V[j]) + blockMixCb(); + }); + } + (0, utils_ts_1.swap32IfBE)(B32); + return scryptOutput(password, dkLen, B, V, tmp); +} +//# sourceMappingURL=scrypt.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/scrypt.js.map b/node_modules/@noble/hashes/scrypt.js.map new file mode 100644 index 0000000000000000000000000000000000000000..ded97a097656d699d7fe48d84a3780a1ac04e918 --- /dev/null +++ b/node_modules/@noble/hashes/scrypt.js.map @@ -0,0 +1 @@ +{"version":3,"file":"scrypt.js","sourceRoot":"","sources":["src/scrypt.ts"],"names":[],"mappings":";;AAgMA,wBA0BC;AAOD,kCA+BC;AAhQD;;;GAGG;AACH,2CAAqC;AACrC,uCAAmC;AACnC,kBAAkB;AAClB,yCAMoB;AAEpB,gDAAgD;AAChD,oEAAoE;AACpE,kBAAkB;AAClB,SAAS,WAAW,CAClB,IAAiB,EACjB,EAAU,EACV,KAAkB,EAClB,EAAU,EACV,GAAgB,EAChB,EAAU;IAEV,yCAAyC;IACzC,aAAa;IACb,IAAI,GAAG,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;IACnE,IAAI,GAAG,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;IACnE,IAAI,GAAG,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,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U,EAAC,GAAG,CAAC,CAAC;IAChB,OAAO,YAAY,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;AAClD,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/sha1.d.ts b/node_modules/@noble/hashes/sha1.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7c36b9f988754516c9311659fff67161afd75d49 --- /dev/null +++ b/node_modules/@noble/hashes/sha1.d.ts @@ -0,0 +1,11 @@ +/** + * SHA1 (RFC 3174) legacy hash function. + * @module + * @deprecated + */ +import { SHA1 as SHA1n, sha1 as sha1n } from './legacy.ts'; +/** @deprecated Use import from `noble/hashes/legacy` module */ +export declare const SHA1: typeof SHA1n; +/** @deprecated Use import from `noble/hashes/legacy` module */ +export declare const sha1: typeof sha1n; +//# sourceMappingURL=sha1.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/sha1.d.ts.map b/node_modules/@noble/hashes/sha1.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..f590e009a1a7a586acb20a77f5c33460f58ff526 --- /dev/null +++ b/node_modules/@noble/hashes/sha1.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"sha1.d.ts","sourceRoot":"","sources":["src/sha1.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,IAAI,IAAI,KAAK,EAAE,IAAI,IAAI,KAAK,EAAE,MAAM,aAAa,CAAC;AAC3D,+DAA+D;AAC/D,eAAO,MAAM,IAAI,EAAE,OAAO,KAAa,CAAC;AACxC,+DAA+D;AAC/D,eAAO,MAAM,IAAI,EAAE,OAAO,KAAa,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/sha1.js b/node_modules/@noble/hashes/sha1.js new file mode 100644 index 0000000000000000000000000000000000000000..f881be163af7689adef9688ec0c786c52f63ee47 --- /dev/null +++ b/node_modules/@noble/hashes/sha1.js @@ -0,0 +1,14 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.sha1 = exports.SHA1 = void 0; +/** + * SHA1 (RFC 3174) legacy hash function. + * @module + * @deprecated + */ +const legacy_ts_1 = require("./legacy.js"); +/** @deprecated Use import from `noble/hashes/legacy` module */ +exports.SHA1 = legacy_ts_1.SHA1; +/** @deprecated Use import from `noble/hashes/legacy` module */ +exports.sha1 = legacy_ts_1.sha1; +//# sourceMappingURL=sha1.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/sha1.js.map b/node_modules/@noble/hashes/sha1.js.map new file mode 100644 index 0000000000000000000000000000000000000000..de5634aff30889f18a174b92e2f046b971bba284 --- /dev/null +++ b/node_modules/@noble/hashes/sha1.js.map @@ -0,0 +1 @@ +{"version":3,"file":"sha1.js","sourceRoot":"","sources":["src/sha1.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,2CAA2D;AAC3D,+DAA+D;AAClD,QAAA,IAAI,GAAiB,gBAAK,CAAC;AACxC,+DAA+D;AAClD,QAAA,IAAI,GAAiB,gBAAK,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/sha2.d.ts b/node_modules/@noble/hashes/sha2.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..33f2f7f89de4d053bf2ef0266c76132daca5b23d --- /dev/null +++ b/node_modules/@noble/hashes/sha2.d.ts @@ -0,0 +1,159 @@ +/** + * SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256. + * SHA256 is the fastest hash implementable in JS, even faster than Blake3. + * Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and + * [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf). + * @module + */ +import { HashMD } from './_md.ts'; +import { type CHash } from './utils.ts'; +export declare class SHA256 extends HashMD { + protected A: number; + protected B: number; + protected C: number; + protected D: number; + protected E: number; + protected F: number; + protected G: number; + protected H: number; + constructor(outputLen?: number); + protected get(): [number, number, number, number, number, number, number, number]; + protected set(A: number, B: number, C: number, D: number, E: number, F: number, G: number, H: number): void; + protected process(view: DataView, offset: number): void; + protected roundClean(): void; + destroy(): void; +} +export declare class SHA224 extends SHA256 { + protected A: number; + protected B: number; + protected C: number; + protected D: number; + protected E: number; + protected F: number; + protected G: number; + protected H: number; + constructor(); +} +export declare class SHA512 extends HashMD { + protected Ah: number; + protected Al: number; + protected Bh: number; + protected Bl: number; + protected Ch: number; + protected Cl: number; + protected Dh: number; + protected Dl: number; + protected Eh: number; + protected El: number; + protected Fh: number; + protected Fl: number; + protected Gh: number; + protected Gl: number; + protected Hh: number; + protected Hl: number; + constructor(outputLen?: number); + protected get(): [ + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number + ]; + protected set(Ah: number, Al: number, Bh: number, Bl: number, Ch: number, Cl: number, Dh: number, Dl: number, Eh: number, El: number, Fh: number, Fl: number, Gh: number, Gl: number, Hh: number, Hl: number): void; + protected process(view: DataView, offset: number): void; + protected roundClean(): void; + destroy(): void; +} +export declare class SHA384 extends SHA512 { + protected Ah: number; + protected Al: number; + protected Bh: number; + protected Bl: number; + protected Ch: number; + protected Cl: number; + protected Dh: number; + protected Dl: number; + protected Eh: number; + protected El: number; + protected Fh: number; + protected Fl: number; + protected Gh: number; + protected Gl: number; + protected Hh: number; + protected Hl: number; + constructor(); +} +export declare class SHA512_224 extends SHA512 { + protected Ah: number; + protected Al: number; + protected Bh: number; + protected Bl: number; + protected Ch: number; + protected Cl: number; + protected Dh: number; + protected Dl: number; + protected Eh: number; + protected El: number; + protected Fh: number; + protected Fl: number; + protected Gh: number; + protected Gl: number; + protected Hh: number; + protected Hl: number; + constructor(); +} +export declare class SHA512_256 extends SHA512 { + protected Ah: number; + protected Al: number; + protected Bh: number; + protected Bl: number; + protected Ch: number; + protected Cl: number; + protected Dh: number; + protected Dl: number; + protected Eh: number; + protected El: number; + protected Fh: number; + protected Fl: number; + protected Gh: number; + protected Gl: number; + protected Hh: number; + protected Hl: number; + constructor(); +} +/** + * SHA2-256 hash function from RFC 4634. + * + * It is the fastest JS hash, even faster than Blake3. + * To break sha256 using birthday attack, attackers need to try 2^128 hashes. + * BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025. + */ +export declare const sha256: CHash; +/** SHA2-224 hash function from RFC 4634 */ +export declare const sha224: CHash; +/** SHA2-512 hash function from RFC 4634. */ +export declare const sha512: CHash; +/** SHA2-384 hash function from RFC 4634. */ +export declare const sha384: CHash; +/** + * SHA2-512/256 "truncated" hash function, with improved resistance to length extension attacks. + * See the paper on [truncated SHA512](https://eprint.iacr.org/2010/548.pdf). + */ +export declare const sha512_256: CHash; +/** + * SHA2-512/224 "truncated" hash function, with improved resistance to length extension attacks. + * See the paper on [truncated SHA512](https://eprint.iacr.org/2010/548.pdf). + */ +export declare const sha512_224: CHash; +//# sourceMappingURL=sha2.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/sha2.d.ts.map b/node_modules/@noble/hashes/sha2.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..310e81307c0b3910a2c3b5a21c4160827cba687f --- /dev/null +++ b/node_modules/@noble/hashes/sha2.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"sha2.d.ts","sourceRoot":"","sources":["src/sha2.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAO,MAAM,EAAmD,MAAM,UAAU,CAAC;AAExF,OAAO,EAAE,KAAK,KAAK,EAA6B,MAAM,YAAY,CAAC;AAoBnE,qBAAa,MAAO,SAAQ,MAAM,CAAC,MAAM,CAAC;IAGxC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAoB;IACvC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAoB;IACvC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAoB;IACvC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAoB;IACvC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAoB;IACvC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAoB;IACvC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4C;AAC5C,eAAO,MAAM,MAAM,EAAE,KAAwD,CAAC;AAC9E,4CAA4C;AAC5C,eAAO,MAAM,MAAM,EAAE,KAAwD,CAAC;AAE9E;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,KAA4D,CAAC;AACtF;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,KAA4D,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/sha2.js b/node_modules/@noble/hashes/sha2.js new file mode 100644 index 0000000000000000000000000000000000000000..962a9ac6179fa480f007bbed1b466b72085d1dda --- /dev/null +++ b/node_modules/@noble/hashes/sha2.js @@ -0,0 +1,384 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.sha512_224 = exports.sha512_256 = exports.sha384 = exports.sha512 = exports.sha224 = exports.sha256 = exports.SHA512_256 = exports.SHA512_224 = exports.SHA384 = exports.SHA512 = exports.SHA224 = exports.SHA256 = void 0; +/** + * SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256. + * SHA256 is the fastest hash implementable in JS, even faster than Blake3. + * Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and + * [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf). + * @module + */ +const _md_ts_1 = require("./_md.js"); +const u64 = require("./_u64.js"); +const utils_ts_1 = require("./utils.js"); +/** + * Round constants: + * First 32 bits of fractional parts of the cube roots of the first 64 primes 2..311) + */ +// prettier-ignore +const SHA256_K = /* @__PURE__ */ Uint32Array.from([ + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, + 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, + 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, + 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 +]); +/** Reusable temporary buffer. "W" comes straight from spec. */ +const SHA256_W = /* @__PURE__ */ new Uint32Array(64); +class SHA256 extends _md_ts_1.HashMD { + constructor(outputLen = 32) { + super(64, outputLen, 8, false); + // We cannot use array here since array allows indexing by variable + // which means optimizer/compiler cannot use registers. + this.A = _md_ts_1.SHA256_IV[0] | 0; + this.B = _md_ts_1.SHA256_IV[1] | 0; + this.C = _md_ts_1.SHA256_IV[2] | 0; + this.D = _md_ts_1.SHA256_IV[3] | 0; + this.E = _md_ts_1.SHA256_IV[4] | 0; + this.F = _md_ts_1.SHA256_IV[5] | 0; + this.G = _md_ts_1.SHA256_IV[6] | 0; + this.H = _md_ts_1.SHA256_IV[7] | 0; + } + get() { + const { A, B, C, D, E, F, G, H } = this; + return [A, B, C, D, E, F, G, H]; + } + // prettier-ignore + set(A, B, C, D, E, F, G, H) { + this.A = A | 0; + this.B = B | 0; + this.C = C | 0; + this.D = D | 0; + this.E = E | 0; + this.F = F | 0; + this.G = G | 0; + this.H = H | 0; + } + process(view, offset) { + // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array + for (let i = 0; i < 16; i++, offset += 4) + SHA256_W[i] = view.getUint32(offset, false); + for (let i = 16; i < 64; i++) { + const W15 = SHA256_W[i - 15]; + const W2 = SHA256_W[i - 2]; + const s0 = (0, utils_ts_1.rotr)(W15, 7) ^ (0, utils_ts_1.rotr)(W15, 18) ^ (W15 >>> 3); + const s1 = (0, utils_ts_1.rotr)(W2, 17) ^ (0, utils_ts_1.rotr)(W2, 19) ^ (W2 >>> 10); + SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0; + } + // Compression function main loop, 64 rounds + let { A, B, C, D, E, F, G, H } = this; + for (let i = 0; i < 64; i++) { + const sigma1 = (0, utils_ts_1.rotr)(E, 6) ^ (0, utils_ts_1.rotr)(E, 11) ^ (0, utils_ts_1.rotr)(E, 25); + const T1 = (H + sigma1 + (0, _md_ts_1.Chi)(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0; + const sigma0 = (0, utils_ts_1.rotr)(A, 2) ^ (0, utils_ts_1.rotr)(A, 13) ^ (0, utils_ts_1.rotr)(A, 22); + const T2 = (sigma0 + (0, _md_ts_1.Maj)(A, B, C)) | 0; + H = G; + G = F; + F = E; + E = (D + T1) | 0; + D = C; + C = B; + B = A; + A = (T1 + T2) | 0; + } + // Add the compressed chunk to the current hash value + A = (A + this.A) | 0; + B = (B + this.B) | 0; + C = (C + this.C) | 0; + D = (D + this.D) | 0; + E = (E + this.E) | 0; + F = (F + this.F) | 0; + G = (G + this.G) | 0; + H = (H + this.H) | 0; + this.set(A, B, C, D, E, F, G, H); + } + roundClean() { + (0, utils_ts_1.clean)(SHA256_W); + } + destroy() { + this.set(0, 0, 0, 0, 0, 0, 0, 0); + (0, utils_ts_1.clean)(this.buffer); + } +} +exports.SHA256 = SHA256; +class SHA224 extends SHA256 { + constructor() { + super(28); + this.A = _md_ts_1.SHA224_IV[0] | 0; + this.B = _md_ts_1.SHA224_IV[1] | 0; + this.C = _md_ts_1.SHA224_IV[2] | 0; + this.D = _md_ts_1.SHA224_IV[3] | 0; + this.E = _md_ts_1.SHA224_IV[4] | 0; + this.F = _md_ts_1.SHA224_IV[5] | 0; + this.G = _md_ts_1.SHA224_IV[6] | 0; + this.H = _md_ts_1.SHA224_IV[7] | 0; + } +} +exports.SHA224 = SHA224; +// SHA2-512 is slower than sha256 in js because u64 operations are slow. +// Round contants +// First 32 bits of the fractional parts of the cube roots of the first 80 primes 2..409 +// prettier-ignore +const K512 = /* @__PURE__ */ (() => u64.split([ + '0x428a2f98d728ae22', '0x7137449123ef65cd', '0xb5c0fbcfec4d3b2f', '0xe9b5dba58189dbbc', + '0x3956c25bf348b538', '0x59f111f1b605d019', '0x923f82a4af194f9b', '0xab1c5ed5da6d8118', + '0xd807aa98a3030242', '0x12835b0145706fbe', '0x243185be4ee4b28c', '0x550c7dc3d5ffb4e2', + '0x72be5d74f27b896f', '0x80deb1fe3b1696b1', '0x9bdc06a725c71235', '0xc19bf174cf692694', + '0xe49b69c19ef14ad2', '0xefbe4786384f25e3', '0x0fc19dc68b8cd5b5', '0x240ca1cc77ac9c65', + '0x2de92c6f592b0275', '0x4a7484aa6ea6e483', '0x5cb0a9dcbd41fbd4', '0x76f988da831153b5', + '0x983e5152ee66dfab', '0xa831c66d2db43210', '0xb00327c898fb213f', '0xbf597fc7beef0ee4', + '0xc6e00bf33da88fc2', '0xd5a79147930aa725', '0x06ca6351e003826f', '0x142929670a0e6e70', + '0x27b70a8546d22ffc', '0x2e1b21385c26c926', '0x4d2c6dfc5ac42aed', '0x53380d139d95b3df', + '0x650a73548baf63de', '0x766a0abb3c77b2a8', '0x81c2c92e47edaee6', '0x92722c851482353b', + '0xa2bfe8a14cf10364', '0xa81a664bbc423001', '0xc24b8b70d0f89791', '0xc76c51a30654be30', + '0xd192e819d6ef5218', '0xd69906245565a910', '0xf40e35855771202a', '0x106aa07032bbd1b8', + '0x19a4c116b8d2d0c8', '0x1e376c085141ab53', '0x2748774cdf8eeb99', '0x34b0bcb5e19b48a8', + '0x391c0cb3c5c95a63', '0x4ed8aa4ae3418acb', '0x5b9cca4f7763e373', '0x682e6ff3d6b2b8a3', + '0x748f82ee5defb2fc', '0x78a5636f43172f60', '0x84c87814a1f0ab72', '0x8cc702081a6439ec', + '0x90befffa23631e28', '0xa4506cebde82bde9', '0xbef9a3f7b2c67915', '0xc67178f2e372532b', + '0xca273eceea26619c', '0xd186b8c721c0c207', '0xeada7dd6cde0eb1e', '0xf57d4f7fee6ed178', + '0x06f067aa72176fba', '0x0a637dc5a2c898a6', '0x113f9804bef90dae', '0x1b710b35131c471b', + '0x28db77f523047d84', '0x32caab7b40c72493', '0x3c9ebe0a15c9bebc', '0x431d67c49c100d4c', + '0x4cc5d4becb3e42b6', '0x597f299cfc657e2a', '0x5fcb6fab3ad6faec', '0x6c44198c4a475817' +].map(n => BigInt(n))))(); +const SHA512_Kh = /* @__PURE__ */ (() => K512[0])(); +const SHA512_Kl = /* @__PURE__ */ (() => K512[1])(); +// Reusable temporary buffers +const SHA512_W_H = /* @__PURE__ */ new Uint32Array(80); +const SHA512_W_L = /* @__PURE__ */ new Uint32Array(80); +class SHA512 extends _md_ts_1.HashMD { + constructor(outputLen = 64) { + super(128, outputLen, 16, false); + // We cannot use array here since array allows indexing by variable + // which means optimizer/compiler cannot use registers. + // h -- high 32 bits, l -- low 32 bits + this.Ah = _md_ts_1.SHA512_IV[0] | 0; + this.Al = _md_ts_1.SHA512_IV[1] | 0; + this.Bh = _md_ts_1.SHA512_IV[2] | 0; + this.Bl = _md_ts_1.SHA512_IV[3] | 0; + this.Ch = _md_ts_1.SHA512_IV[4] | 0; + this.Cl = _md_ts_1.SHA512_IV[5] | 0; + this.Dh = _md_ts_1.SHA512_IV[6] | 0; + this.Dl = _md_ts_1.SHA512_IV[7] | 0; + this.Eh = _md_ts_1.SHA512_IV[8] | 0; + this.El = _md_ts_1.SHA512_IV[9] | 0; + this.Fh = _md_ts_1.SHA512_IV[10] | 0; + this.Fl = _md_ts_1.SHA512_IV[11] | 0; + this.Gh = _md_ts_1.SHA512_IV[12] | 0; + this.Gl = _md_ts_1.SHA512_IV[13] | 0; + this.Hh = _md_ts_1.SHA512_IV[14] | 0; + this.Hl = _md_ts_1.SHA512_IV[15] | 0; + } + // prettier-ignore + get() { + const { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this; + return [Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl]; + } + // prettier-ignore + set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl) { + this.Ah = Ah | 0; + this.Al = Al | 0; + this.Bh = Bh | 0; + this.Bl = Bl | 0; + this.Ch = Ch | 0; + this.Cl = Cl | 0; + this.Dh = Dh | 0; + this.Dl = Dl | 0; + this.Eh = Eh | 0; + this.El = El | 0; + this.Fh = Fh | 0; + this.Fl = Fl | 0; + this.Gh = Gh | 0; + this.Gl = Gl | 0; + this.Hh = Hh | 0; + this.Hl = Hl | 0; + } + process(view, offset) { + // Extend the first 16 words into the remaining 64 words w[16..79] of the message schedule array + for (let i = 0; i < 16; i++, offset += 4) { + SHA512_W_H[i] = view.getUint32(offset); + SHA512_W_L[i] = view.getUint32((offset += 4)); + } + for (let i = 16; i < 80; i++) { + // s0 := (w[i-15] rightrotate 1) xor (w[i-15] rightrotate 8) xor (w[i-15] rightshift 7) + const W15h = SHA512_W_H[i - 15] | 0; + const W15l = SHA512_W_L[i - 15] | 0; + const s0h = u64.rotrSH(W15h, W15l, 1) ^ u64.rotrSH(W15h, W15l, 8) ^ u64.shrSH(W15h, W15l, 7); + const s0l = u64.rotrSL(W15h, W15l, 1) ^ u64.rotrSL(W15h, W15l, 8) ^ u64.shrSL(W15h, W15l, 7); + // s1 := (w[i-2] rightrotate 19) xor (w[i-2] rightrotate 61) xor (w[i-2] rightshift 6) + const W2h = SHA512_W_H[i - 2] | 0; + const W2l = SHA512_W_L[i - 2] | 0; + const s1h = u64.rotrSH(W2h, W2l, 19) ^ u64.rotrBH(W2h, W2l, 61) ^ u64.shrSH(W2h, W2l, 6); + const s1l = u64.rotrSL(W2h, W2l, 19) ^ u64.rotrBL(W2h, W2l, 61) ^ u64.shrSL(W2h, W2l, 6); + // SHA256_W[i] = s0 + s1 + SHA256_W[i - 7] + SHA256_W[i - 16]; + const SUMl = u64.add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16]); + const SUMh = u64.add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]); + SHA512_W_H[i] = SUMh | 0; + SHA512_W_L[i] = SUMl | 0; + } + let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this; + // Compression function main loop, 80 rounds + for (let i = 0; i < 80; i++) { + // S1 := (e rightrotate 14) xor (e rightrotate 18) xor (e rightrotate 41) + const sigma1h = u64.rotrSH(Eh, El, 14) ^ u64.rotrSH(Eh, El, 18) ^ u64.rotrBH(Eh, El, 41); + const sigma1l = u64.rotrSL(Eh, El, 14) ^ u64.rotrSL(Eh, El, 18) ^ u64.rotrBL(Eh, El, 41); + //const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0; + const CHIh = (Eh & Fh) ^ (~Eh & Gh); + const CHIl = (El & Fl) ^ (~El & Gl); + // T1 = H + sigma1 + Chi(E, F, G) + SHA512_K[i] + SHA512_W[i] + // prettier-ignore + const T1ll = u64.add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]); + const T1h = u64.add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]); + const T1l = T1ll | 0; + // S0 := (a rightrotate 28) xor (a rightrotate 34) xor (a rightrotate 39) + const sigma0h = u64.rotrSH(Ah, Al, 28) ^ u64.rotrBH(Ah, Al, 34) ^ u64.rotrBH(Ah, Al, 39); + const sigma0l = u64.rotrSL(Ah, Al, 28) ^ u64.rotrBL(Ah, Al, 34) ^ u64.rotrBL(Ah, Al, 39); + const MAJh = (Ah & Bh) ^ (Ah & Ch) ^ (Bh & Ch); + const MAJl = (Al & Bl) ^ (Al & Cl) ^ (Bl & Cl); + Hh = Gh | 0; + Hl = Gl | 0; + Gh = Fh | 0; + Gl = Fl | 0; + Fh = Eh | 0; + Fl = El | 0; + ({ h: Eh, l: El } = u64.add(Dh | 0, Dl | 0, T1h | 0, T1l | 0)); + Dh = Ch | 0; + Dl = Cl | 0; + Ch = Bh | 0; + Cl = Bl | 0; + Bh = Ah | 0; + Bl = Al | 0; + const All = u64.add3L(T1l, sigma0l, MAJl); + Ah = u64.add3H(All, T1h, sigma0h, MAJh); + Al = All | 0; + } + // Add the compressed chunk to the current hash value + ({ h: Ah, l: Al } = u64.add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0)); + ({ h: Bh, l: Bl } = u64.add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0)); + ({ h: Ch, l: Cl } = u64.add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0)); + ({ h: Dh, l: Dl } = u64.add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0)); + ({ h: Eh, l: El } = u64.add(this.Eh | 0, this.El | 0, Eh | 0, El | 0)); + ({ h: Fh, l: Fl } = u64.add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0)); + ({ h: Gh, l: Gl } = u64.add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0)); + ({ h: Hh, l: Hl } = u64.add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0)); + this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl); + } + roundClean() { + (0, utils_ts_1.clean)(SHA512_W_H, SHA512_W_L); + } + destroy() { + (0, utils_ts_1.clean)(this.buffer); + this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + } +} +exports.SHA512 = SHA512; +class SHA384 extends SHA512 { + constructor() { + super(48); + this.Ah = _md_ts_1.SHA384_IV[0] | 0; + this.Al = _md_ts_1.SHA384_IV[1] | 0; + this.Bh = _md_ts_1.SHA384_IV[2] | 0; + this.Bl = _md_ts_1.SHA384_IV[3] | 0; + this.Ch = _md_ts_1.SHA384_IV[4] | 0; + this.Cl = _md_ts_1.SHA384_IV[5] | 0; + this.Dh = _md_ts_1.SHA384_IV[6] | 0; + this.Dl = _md_ts_1.SHA384_IV[7] | 0; + this.Eh = _md_ts_1.SHA384_IV[8] | 0; + this.El = _md_ts_1.SHA384_IV[9] | 0; + this.Fh = _md_ts_1.SHA384_IV[10] | 0; + this.Fl = _md_ts_1.SHA384_IV[11] | 0; + this.Gh = _md_ts_1.SHA384_IV[12] | 0; + this.Gl = _md_ts_1.SHA384_IV[13] | 0; + this.Hh = _md_ts_1.SHA384_IV[14] | 0; + this.Hl = _md_ts_1.SHA384_IV[15] | 0; + } +} +exports.SHA384 = SHA384; +/** + * Truncated SHA512/256 and SHA512/224. + * SHA512_IV is XORed with 0xa5a5a5a5a5a5a5a5, then used as "intermediary" IV of SHA512/t. + * Then t hashes string to produce result IV. + * See `test/misc/sha2-gen-iv.js`. + */ +/** SHA512/224 IV */ +const T224_IV = /* @__PURE__ */ Uint32Array.from([ + 0x8c3d37c8, 0x19544da2, 0x73e19966, 0x89dcd4d6, 0x1dfab7ae, 0x32ff9c82, 0x679dd514, 0x582f9fcf, + 0x0f6d2b69, 0x7bd44da8, 0x77e36f73, 0x04c48942, 0x3f9d85a8, 0x6a1d36c8, 0x1112e6ad, 0x91d692a1, +]); +/** SHA512/256 IV */ +const T256_IV = /* @__PURE__ */ Uint32Array.from([ + 0x22312194, 0xfc2bf72c, 0x9f555fa3, 0xc84c64c2, 0x2393b86b, 0x6f53b151, 0x96387719, 0x5940eabd, + 0x96283ee2, 0xa88effe3, 0xbe5e1e25, 0x53863992, 0x2b0199fc, 0x2c85b8aa, 0x0eb72ddc, 0x81c52ca2, +]); +class SHA512_224 extends SHA512 { + constructor() { + super(28); + this.Ah = T224_IV[0] | 0; + this.Al = T224_IV[1] | 0; + this.Bh = T224_IV[2] | 0; + this.Bl = T224_IV[3] | 0; + this.Ch = T224_IV[4] | 0; + this.Cl = T224_IV[5] | 0; + this.Dh = T224_IV[6] | 0; + this.Dl = T224_IV[7] | 0; + this.Eh = T224_IV[8] | 0; + this.El = T224_IV[9] | 0; + this.Fh = T224_IV[10] | 0; + this.Fl = T224_IV[11] | 0; + this.Gh = T224_IV[12] | 0; + this.Gl = T224_IV[13] | 0; + this.Hh = T224_IV[14] | 0; + this.Hl = T224_IV[15] | 0; + } +} +exports.SHA512_224 = SHA512_224; +class SHA512_256 extends SHA512 { + constructor() { + super(32); + this.Ah = T256_IV[0] | 0; + this.Al = T256_IV[1] | 0; + this.Bh = T256_IV[2] | 0; + this.Bl = T256_IV[3] | 0; + this.Ch = T256_IV[4] | 0; + this.Cl = T256_IV[5] | 0; + this.Dh = T256_IV[6] | 0; + this.Dl = T256_IV[7] | 0; + this.Eh = T256_IV[8] | 0; + this.El = T256_IV[9] | 0; + this.Fh = T256_IV[10] | 0; + this.Fl = T256_IV[11] | 0; + this.Gh = T256_IV[12] | 0; + this.Gl = T256_IV[13] | 0; + this.Hh = T256_IV[14] | 0; + this.Hl = T256_IV[15] | 0; + } +} +exports.SHA512_256 = SHA512_256; +/** + * SHA2-256 hash function from RFC 4634. + * + * It is the fastest JS hash, even faster than Blake3. + * To break sha256 using birthday attack, attackers need to try 2^128 hashes. + * BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025. + */ +exports.sha256 = (0, utils_ts_1.createHasher)(() => new SHA256()); +/** SHA2-224 hash function from RFC 4634 */ +exports.sha224 = (0, utils_ts_1.createHasher)(() => new SHA224()); +/** SHA2-512 hash function from RFC 4634. */ +exports.sha512 = (0, utils_ts_1.createHasher)(() => new SHA512()); +/** SHA2-384 hash function from RFC 4634. */ +exports.sha384 = (0, utils_ts_1.createHasher)(() => new SHA384()); +/** + * SHA2-512/256 "truncated" hash function, with improved resistance to length extension attacks. + * See the paper on [truncated SHA512](https://eprint.iacr.org/2010/548.pdf). + */ +exports.sha512_256 = (0, utils_ts_1.createHasher)(() => new SHA512_256()); +/** + * SHA2-512/224 "truncated" hash function, with improved resistance to length extension attacks. + * See the paper on [truncated SHA512](https://eprint.iacr.org/2010/548.pdf). + */ +exports.sha512_224 = (0, utils_ts_1.createHasher)(() => new SHA512_224()); +//# sourceMappingURL=sha2.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/sha2.js.map b/node_modules/@noble/hashes/sha2.js.map new file mode 100644 index 0000000000000000000000000000000000000000..b5cfb67021927cf5826c723a5c019fdf5c0ffa77 --- /dev/null +++ b/node_modules/@noble/hashes/sha2.js.map @@ -0,0 +1 @@ +{"version":3,"file":"sha2.js","sourceRoot":"","sources":["src/sha2.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,qCAAwF;AACxF,iCAAiC;AACjC,yCAAmE;AAEnE;;;GAGG;AACH,kBAAkB;AAClB,MAAM,QAAQ,GAAG,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC;IAChD,UAAU,EAAE,UAAU,EAAE,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;IAC9F,UAAU,EAAE,UAAU,EAAE,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;IAC9F,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU;IAC9F,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAA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AAC;AAC9E,4CAA4C;AAC/B,QAAA,MAAM,GAA0B,IAAA,uBAAY,EAAC,GAAG,EAAE,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC;AAE9E;;;GAGG;AACU,QAAA,UAAU,GAA0B,IAAA,uBAAY,EAAC,GAAG,EAAE,CAAC,IAAI,UAAU,EAAE,CAAC,CAAC;AACtF;;;GAGG;AACU,QAAA,UAAU,GAA0B,IAAA,uBAAY,EAAC,GAAG,EAAE,CAAC,IAAI,UAAU,EAAE,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/sha256.d.ts b/node_modules/@noble/hashes/sha256.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ed04fe88f27481e2b4ce5b770b14549d3024e986 --- /dev/null +++ b/node_modules/@noble/hashes/sha256.d.ts @@ -0,0 +1,20 @@ +/** + * SHA2-256 a.k.a. sha256. In JS, it is the fastest hash, even faster than Blake3. + * + * To break sha256 using birthday attack, attackers need to try 2^128 hashes. + * BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025. + * + * Check out [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf). + * @module + * @deprecated + */ +import { SHA224 as SHA224n, sha224 as sha224n, SHA256 as SHA256n, sha256 as sha256n } from './sha2.ts'; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export declare const SHA256: typeof SHA256n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export declare const sha256: typeof sha256n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export declare const SHA224: typeof SHA224n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export declare const sha224: typeof sha224n; +//# sourceMappingURL=sha256.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/sha256.d.ts.map b/node_modules/@noble/hashes/sha256.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..15911baa10e3b8b8dc6f28d4ddb9e6e9a3965cc0 --- /dev/null +++ b/node_modules/@noble/hashes/sha256.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"sha256.d.ts","sourceRoot":"","sources":["src/sha256.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,MAAM,IAAI,OAAO,EACjB,MAAM,IAAI,OAAO,EACjB,MAAM,IAAI,OAAO,EACjB,MAAM,IAAI,OAAO,EAClB,MAAM,WAAW,CAAC;AACnB,6DAA6D;AAC7D,eAAO,MAAM,MAAM,EAAE,OAAO,OAAiB,CAAC;AAC9C,6DAA6D;AAC7D,eAAO,MAAM,MAAM,EAAE,OAAO,OAAiB,CAAC;AAC9C,6DAA6D;AAC7D,eAAO,MAAM,MAAM,EAAE,OAAO,OAAiB,CAAC;AAC9C,6DAA6D;AAC7D,eAAO,MAAM,MAAM,EAAE,OAAO,OAAiB,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/sha256.js b/node_modules/@noble/hashes/sha256.js new file mode 100644 index 0000000000000000000000000000000000000000..573bda9413c7a475ad8715801d41acc8f099de54 --- /dev/null +++ b/node_modules/@noble/hashes/sha256.js @@ -0,0 +1,23 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.sha224 = exports.SHA224 = exports.sha256 = exports.SHA256 = void 0; +/** + * SHA2-256 a.k.a. sha256. In JS, it is the fastest hash, even faster than Blake3. + * + * To break sha256 using birthday attack, attackers need to try 2^128 hashes. + * BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025. + * + * Check out [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf). + * @module + * @deprecated + */ +const sha2_ts_1 = require("./sha2.js"); +/** @deprecated Use import from `noble/hashes/sha2` module */ +exports.SHA256 = sha2_ts_1.SHA256; +/** @deprecated Use import from `noble/hashes/sha2` module */ +exports.sha256 = sha2_ts_1.sha256; +/** @deprecated Use import from `noble/hashes/sha2` module */ +exports.SHA224 = sha2_ts_1.SHA224; +/** @deprecated Use import from `noble/hashes/sha2` module */ +exports.sha224 = sha2_ts_1.sha224; +//# sourceMappingURL=sha256.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/sha256.js.map b/node_modules/@noble/hashes/sha256.js.map new file mode 100644 index 0000000000000000000000000000000000000000..69c5821d4e54903655b7748bb33691fbb0a2ec82 --- /dev/null +++ b/node_modules/@noble/hashes/sha256.js.map @@ -0,0 +1 @@ +{"version":3,"file":"sha256.js","sourceRoot":"","sources":["src/sha256.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,uCAKmB;AACnB,6DAA6D;AAChD,QAAA,MAAM,GAAmB,gBAAO,CAAC;AAC9C,6DAA6D;AAChD,QAAA,MAAM,GAAmB,gBAAO,CAAC;AAC9C,6DAA6D;AAChD,QAAA,MAAM,GAAmB,gBAAO,CAAC;AAC9C,6DAA6D;AAChD,QAAA,MAAM,GAAmB,gBAAO,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/sha3-addons.d.ts b/node_modules/@noble/hashes/sha3-addons.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5bd2fe62d0467909adccaf08f4961d2135d7a083 --- /dev/null +++ b/node_modules/@noble/hashes/sha3-addons.d.ts @@ -0,0 +1,142 @@ +/** + * SHA3 (keccak) addons. + * + * * Full [NIST SP 800-185](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-185.pdf): + * cSHAKE, KMAC, TupleHash, ParallelHash + XOF variants + * * Reduced-round Keccak [(draft)](https://datatracker.ietf.org/doc/draft-irtf-cfrg-kangarootwelve/): + * * 🦘 K12 aka KangarooTwelve + * * M14 aka MarsupilamiFourteen + * * TurboSHAKE + * * KeccakPRG: Pseudo-random generator based on Keccak [(pdf)](https://keccak.team/files/CSF-0.1.pdf) + * @module + */ +import { Keccak, type ShakeOpts } from './sha3.ts'; +import { type CHashO, type CHashXO, Hash, type HashXOF, type Input } from './utils.ts'; +export type cShakeOpts = ShakeOpts & { + personalization?: Input; + NISTfn?: Input; +}; +export type ICShake = { + (msg: Input, opts?: cShakeOpts): Uint8Array; + outputLen: number; + blockLen: number; + create(opts: cShakeOpts): HashXOF; +}; +export type ITupleHash = { + (messages: Input[], opts?: cShakeOpts): Uint8Array; + create(opts?: cShakeOpts): TupleHash; +}; +export type IParHash = { + (message: Input, opts?: ParallelOpts): Uint8Array; + create(opts?: ParallelOpts): ParallelHash; +}; +export declare const cshake128: ICShake; +export declare const cshake256: ICShake; +export declare class KMAC extends Keccak implements HashXOF { + constructor(blockLen: number, outputLen: number, enableXOF: boolean, key: Input, opts?: cShakeOpts); + protected finish(): void; + _cloneInto(to?: KMAC): KMAC; + clone(): KMAC; +} +export declare const kmac128: { + (key: Input, message: Input, opts?: cShakeOpts): Uint8Array; + create(key: Input, opts?: cShakeOpts): KMAC; +}; +export declare const kmac256: { + (key: Input, message: Input, opts?: cShakeOpts): Uint8Array; + create(key: Input, opts?: cShakeOpts): KMAC; +}; +export declare const kmac128xof: { + (key: Input, message: Input, opts?: cShakeOpts): Uint8Array; + create(key: Input, opts?: cShakeOpts): KMAC; +}; +export declare const kmac256xof: { + (key: Input, message: Input, opts?: cShakeOpts): Uint8Array; + create(key: Input, opts?: cShakeOpts): KMAC; +}; +export declare class TupleHash extends Keccak implements HashXOF { + constructor(blockLen: number, outputLen: number, enableXOF: boolean, opts?: cShakeOpts); + protected finish(): void; + _cloneInto(to?: TupleHash): TupleHash; + clone(): TupleHash; +} +/** 128-bit TupleHASH. */ +export declare const tuplehash128: ITupleHash; +/** 256-bit TupleHASH. */ +export declare const tuplehash256: ITupleHash; +/** 128-bit TupleHASH XOF. */ +export declare const tuplehash128xof: ITupleHash; +/** 256-bit TupleHASH XOF. */ +export declare const tuplehash256xof: ITupleHash; +type ParallelOpts = cShakeOpts & { + blockLen?: number; +}; +export declare class ParallelHash extends Keccak implements HashXOF { + private leafHash?; + protected leafCons: () => Hash; + private chunkPos; + private chunksDone; + private chunkLen; + constructor(blockLen: number, outputLen: number, leafCons: () => Hash, enableXOF: boolean, opts?: ParallelOpts); + protected finish(): void; + _cloneInto(to?: ParallelHash): ParallelHash; + destroy(): void; + clone(): ParallelHash; +} +/** 128-bit ParallelHash. In JS, it is not parallel. */ +export declare const parallelhash128: IParHash; +/** 256-bit ParallelHash. In JS, it is not parallel. */ +export declare const parallelhash256: IParHash; +/** 128-bit ParallelHash XOF. In JS, it is not parallel. */ +export declare const parallelhash128xof: IParHash; +/** 256-bit ParallelHash. In JS, it is not parallel. */ +export declare const parallelhash256xof: IParHash; +export type TurboshakeOpts = ShakeOpts & { + D?: number; +}; +/** TurboSHAKE 128-bit: reduced 12-round keccak. */ +export declare const turboshake128: CHashXO; +/** TurboSHAKE 256-bit: reduced 12-round keccak. */ +export declare const turboshake256: CHashXO; +export type KangarooOpts = { + dkLen?: number; + personalization?: Input; +}; +export declare class KangarooTwelve extends Keccak implements HashXOF { + readonly chunkLen = 8192; + private leafHash?; + protected leafLen: number; + private personalization; + private chunkPos; + private chunksDone; + constructor(blockLen: number, leafLen: number, outputLen: number, rounds: number, opts: KangarooOpts); + update(data: Input): this; + protected finish(): void; + destroy(): void; + _cloneInto(to?: KangarooTwelve): KangarooTwelve; + clone(): KangarooTwelve; +} +/** KangarooTwelve: reduced 12-round keccak. */ +export declare const k12: CHashO; +/** MarsupilamiFourteen: reduced 14-round keccak. */ +export declare const m14: CHashO; +/** + * More at https://github.com/XKCP/XKCP/tree/master/lib/high/Keccak/PRG. + */ +export declare class KeccakPRG extends Keccak { + protected rate: number; + constructor(capacity: number); + keccak(): void; + update(data: Input): this; + feed(data: Input): this; + protected finish(): void; + digestInto(_out: Uint8Array): Uint8Array; + fetch(bytes: number): Uint8Array; + forget(): void; + _cloneInto(to?: KeccakPRG): KeccakPRG; + clone(): KeccakPRG; +} +/** KeccakPRG: Pseudo-random generator based on Keccak. https://keccak.team/files/CSF-0.1.pdf */ +export declare const keccakprg: (capacity?: number) => KeccakPRG; +export {}; +//# sourceMappingURL=sha3-addons.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/sha3-addons.d.ts.map b/node_modules/@noble/hashes/sha3-addons.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..7c2bee2828cbfcb882348532dbb26234a1434407 --- /dev/null +++ b/node_modules/@noble/hashes/sha3-addons.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"sha3-addons.d.ts","sourceRoot":"","sources":["src/sha3-addons.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,MAAM,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAGL,KAAK,MAAM,EACX,KAAK,OAAO,EAGZ,IAAI,EACJ,KAAK,OAAO,EACZ,KAAK,KAAK,EAGX,MAAM,YAAY,CAAC;AAoCpB,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG;IAAE,eAAe,CAAC,EAAE,KAAK,CAAC;IAAC,MAAM,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AA0BjF,MAAM,MAAM,OAAO,GAAG;IACpB,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC3C,CAAC;AACF,MAAM,MAAM,UAAU,GAAG;IACvB,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;IACnD,MAAM,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;CACtC,CAAC;AACF,MAAM,MAAM,QAAQ,GAAG;IACrB,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;IAClD,MAAM,CAAC,IAAI,CAAC,EAAE,YAAY,GAAG,YAAY,CAAC;CAC3C,CAAC;AACF,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;AACpD,eAAO,MAAM,GAAG,EAAE,MAGZ,CAAC;AAEP;;GAEG;AACH,qBAAa,SAAU,SAAQ,MAAM;IACnC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC;gBACX,QAAQ,EAAE,MAAM;IAU5B,MAAM,IAAI,IAAI;IAQd,MAAM,CAAC,IAAI,EAAE,KAAK,GAAG,IAAI;IAKzB,IAAI,CAAC,IAAI,EAAE,KAAK,GAAG,IAAI;IAGvB,SAAS,CAAC,MAAM,IAAI,IAAI;IACxB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU;IAGxC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU;IAIhC,MAAM,IAAI,IAAI;IAQd,UAAU,CAAC,EAAE,CAAC,EAAE,SAAS,GAAG,SAAS;IAOrC,KAAK,IAAI,SAAS;CAGnB;AAED,gGAAgG;AAChG,eAAO,MAAM,SAAS,GAAI,iBAAc,KAAG,SAAoC,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/sha3-addons.js b/node_modules/@noble/hashes/sha3-addons.js new file mode 100644 index 0000000000000000000000000000000000000000..ad75d78c256f01c4d23607dbd568a08553d8b20d --- /dev/null +++ b/node_modules/@noble/hashes/sha3-addons.js @@ -0,0 +1,402 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.keccakprg = exports.KeccakPRG = exports.m14 = exports.k12 = exports.KangarooTwelve = exports.turboshake256 = exports.turboshake128 = exports.parallelhash256xof = exports.parallelhash128xof = exports.parallelhash256 = exports.parallelhash128 = exports.ParallelHash = exports.tuplehash256xof = exports.tuplehash128xof = exports.tuplehash256 = exports.tuplehash128 = exports.TupleHash = exports.kmac256xof = exports.kmac128xof = exports.kmac256 = exports.kmac128 = exports.KMAC = exports.cshake256 = exports.cshake128 = void 0; +/** + * SHA3 (keccak) addons. + * + * * Full [NIST SP 800-185](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-185.pdf): + * cSHAKE, KMAC, TupleHash, ParallelHash + XOF variants + * * Reduced-round Keccak [(draft)](https://datatracker.ietf.org/doc/draft-irtf-cfrg-kangarootwelve/): + * * 🦘 K12 aka KangarooTwelve + * * M14 aka MarsupilamiFourteen + * * TurboSHAKE + * * KeccakPRG: Pseudo-random generator based on Keccak [(pdf)](https://keccak.team/files/CSF-0.1.pdf) + * @module + */ +const sha3_ts_1 = require("./sha3.js"); +const utils_ts_1 = require("./utils.js"); +// cSHAKE && KMAC (NIST SP800-185) +const _8n = BigInt(8); +const _ffn = BigInt(0xff); +// NOTE: it is safe to use bigints here, since they used only for length encoding (not actual data). +// We use bigints in sha256 for lengths too. +function leftEncode(n) { + n = BigInt(n); + const res = [Number(n & _ffn)]; + n >>= _8n; + for (; n > 0; n >>= _8n) + res.unshift(Number(n & _ffn)); + res.unshift(res.length); + return new Uint8Array(res); +} +function rightEncode(n) { + n = BigInt(n); + const res = [Number(n & _ffn)]; + n >>= _8n; + for (; n > 0; n >>= _8n) + res.unshift(Number(n & _ffn)); + res.push(res.length); + return new Uint8Array(res); +} +function chooseLen(opts, outputLen) { + return opts.dkLen === undefined ? outputLen : opts.dkLen; +} +const abytesOrZero = (buf) => { + if (buf === undefined) + return Uint8Array.of(); + return (0, utils_ts_1.toBytes)(buf); +}; +// NOTE: second modulo is necessary since we don't need to add padding if current element takes whole block +const getPadding = (len, block) => new Uint8Array((block - (len % block)) % block); +// Personalization +function cshakePers(hash, opts = {}) { + if (!opts || (!opts.personalization && !opts.NISTfn)) + return hash; + // Encode and pad inplace to avoid unneccesary memory copies/slices (so we don't need to zero them later) + // bytepad(encode_string(N) || encode_string(S), 168) + const blockLenBytes = leftEncode(hash.blockLen); + const fn = abytesOrZero(opts.NISTfn); + const fnLen = leftEncode(_8n * BigInt(fn.length)); // length in bits + const pers = abytesOrZero(opts.personalization); + const persLen = leftEncode(_8n * BigInt(pers.length)); // length in bits + if (!fn.length && !pers.length) + return hash; + hash.suffix = 0x04; + hash.update(blockLenBytes).update(fnLen).update(fn).update(persLen).update(pers); + let totalLen = blockLenBytes.length + fnLen.length + fn.length + persLen.length + pers.length; + hash.update(getPadding(totalLen, hash.blockLen)); + return hash; +} +const gencShake = (suffix, blockLen, outputLen) => (0, utils_ts_1.createXOFer)((opts = {}) => cshakePers(new sha3_ts_1.Keccak(blockLen, suffix, chooseLen(opts, outputLen), true), opts)); +exports.cshake128 = (() => gencShake(0x1f, 168, 128 / 8))(); +exports.cshake256 = (() => gencShake(0x1f, 136, 256 / 8))(); +class KMAC extends sha3_ts_1.Keccak { + constructor(blockLen, outputLen, enableXOF, key, opts = {}) { + super(blockLen, 0x1f, outputLen, enableXOF); + cshakePers(this, { NISTfn: 'KMAC', personalization: opts.personalization }); + key = (0, utils_ts_1.toBytes)(key); + (0, utils_ts_1.abytes)(key); + // 1. newX = bytepad(encode_string(K), 168) || X || right_encode(L). + const blockLenBytes = leftEncode(this.blockLen); + const keyLen = leftEncode(_8n * BigInt(key.length)); + this.update(blockLenBytes).update(keyLen).update(key); + const totalLen = blockLenBytes.length + keyLen.length + key.length; + this.update(getPadding(totalLen, this.blockLen)); + } + finish() { + if (!this.finished) + this.update(rightEncode(this.enableXOF ? 0 : _8n * BigInt(this.outputLen))); // outputLen in bits + super.finish(); + } + _cloneInto(to) { + // Create new instance without calling constructor since key already in state and we don't know it. + // Force "to" to be instance of KMAC instead of Sha3. + if (!to) { + to = Object.create(Object.getPrototypeOf(this), {}); + to.state = this.state.slice(); + to.blockLen = this.blockLen; + to.state32 = (0, utils_ts_1.u32)(to.state); + } + return super._cloneInto(to); + } + clone() { + return this._cloneInto(); + } +} +exports.KMAC = KMAC; +function genKmac(blockLen, outputLen, xof = false) { + const kmac = (key, message, opts) => kmac.create(key, opts).update(message).digest(); + kmac.create = (key, opts = {}) => new KMAC(blockLen, chooseLen(opts, outputLen), xof, key, opts); + return kmac; +} +exports.kmac128 = (() => genKmac(168, 128 / 8))(); +exports.kmac256 = (() => genKmac(136, 256 / 8))(); +exports.kmac128xof = (() => genKmac(168, 128 / 8, true))(); +exports.kmac256xof = (() => genKmac(136, 256 / 8, true))(); +// TupleHash +// Usage: tuple(['ab', 'cd']) != tuple(['a', 'bcd']) +class TupleHash extends sha3_ts_1.Keccak { + constructor(blockLen, outputLen, enableXOF, opts = {}) { + super(blockLen, 0x1f, outputLen, enableXOF); + cshakePers(this, { NISTfn: 'TupleHash', personalization: opts.personalization }); + // Change update after cshake processed + this.update = (data) => { + data = (0, utils_ts_1.toBytes)(data); + (0, utils_ts_1.abytes)(data); + super.update(leftEncode(_8n * BigInt(data.length))); + super.update(data); + return this; + }; + } + finish() { + if (!this.finished) + super.update(rightEncode(this.enableXOF ? 0 : _8n * BigInt(this.outputLen))); // outputLen in bits + super.finish(); + } + _cloneInto(to) { + to || (to = new TupleHash(this.blockLen, this.outputLen, this.enableXOF)); + return super._cloneInto(to); + } + clone() { + return this._cloneInto(); + } +} +exports.TupleHash = TupleHash; +function genTuple(blockLen, outputLen, xof = false) { + const tuple = (messages, opts) => { + const h = tuple.create(opts); + for (const msg of messages) + h.update(msg); + return h.digest(); + }; + tuple.create = (opts = {}) => new TupleHash(blockLen, chooseLen(opts, outputLen), xof, opts); + return tuple; +} +/** 128-bit TupleHASH. */ +exports.tuplehash128 = (() => genTuple(168, 128 / 8))(); +/** 256-bit TupleHASH. */ +exports.tuplehash256 = (() => genTuple(136, 256 / 8))(); +/** 128-bit TupleHASH XOF. */ +exports.tuplehash128xof = (() => genTuple(168, 128 / 8, true))(); +/** 256-bit TupleHASH XOF. */ +exports.tuplehash256xof = (() => genTuple(136, 256 / 8, true))(); +class ParallelHash extends sha3_ts_1.Keccak { + constructor(blockLen, outputLen, leafCons, enableXOF, opts = {}) { + super(blockLen, 0x1f, outputLen, enableXOF); + this.chunkPos = 0; // Position of current block in chunk + this.chunksDone = 0; // How many chunks we already have + cshakePers(this, { NISTfn: 'ParallelHash', personalization: opts.personalization }); + this.leafCons = leafCons; + let { blockLen: B } = opts; + B || (B = 8); + (0, utils_ts_1.anumber)(B); + this.chunkLen = B; + super.update(leftEncode(B)); + // Change update after cshake processed + this.update = (data) => { + data = (0, utils_ts_1.toBytes)(data); + (0, utils_ts_1.abytes)(data); + const { chunkLen, leafCons } = this; + for (let pos = 0, len = data.length; pos < len;) { + if (this.chunkPos == chunkLen || !this.leafHash) { + if (this.leafHash) { + super.update(this.leafHash.digest()); + this.chunksDone++; + } + this.leafHash = leafCons(); + this.chunkPos = 0; + } + const take = Math.min(chunkLen - this.chunkPos, len - pos); + this.leafHash.update(data.subarray(pos, pos + take)); + this.chunkPos += take; + pos += take; + } + return this; + }; + } + finish() { + if (this.finished) + return; + if (this.leafHash) { + super.update(this.leafHash.digest()); + this.chunksDone++; + } + super.update(rightEncode(this.chunksDone)); + super.update(rightEncode(this.enableXOF ? 0 : _8n * BigInt(this.outputLen))); // outputLen in bits + super.finish(); + } + _cloneInto(to) { + to || (to = new ParallelHash(this.blockLen, this.outputLen, this.leafCons, this.enableXOF)); + if (this.leafHash) + to.leafHash = this.leafHash._cloneInto(to.leafHash); + to.chunkPos = this.chunkPos; + to.chunkLen = this.chunkLen; + to.chunksDone = this.chunksDone; + return super._cloneInto(to); + } + destroy() { + super.destroy.call(this); + if (this.leafHash) + this.leafHash.destroy(); + } + clone() { + return this._cloneInto(); + } +} +exports.ParallelHash = ParallelHash; +function genPrl(blockLen, outputLen, leaf, xof = false) { + const parallel = (message, opts) => parallel.create(opts).update(message).digest(); + parallel.create = (opts = {}) => new ParallelHash(blockLen, chooseLen(opts, outputLen), () => leaf.create({ dkLen: 2 * outputLen }), xof, opts); + return parallel; +} +/** 128-bit ParallelHash. In JS, it is not parallel. */ +exports.parallelhash128 = (() => genPrl(168, 128 / 8, exports.cshake128))(); +/** 256-bit ParallelHash. In JS, it is not parallel. */ +exports.parallelhash256 = (() => genPrl(136, 256 / 8, exports.cshake256))(); +/** 128-bit ParallelHash XOF. In JS, it is not parallel. */ +exports.parallelhash128xof = (() => genPrl(168, 128 / 8, exports.cshake128, true))(); +/** 256-bit ParallelHash. In JS, it is not parallel. */ +exports.parallelhash256xof = (() => genPrl(136, 256 / 8, exports.cshake256, true))(); +const genTurboshake = (blockLen, outputLen) => (0, utils_ts_1.createXOFer)((opts = {}) => { + const D = opts.D === undefined ? 0x1f : opts.D; + // Section 2.1 of https://datatracker.ietf.org/doc/draft-irtf-cfrg-kangarootwelve/ + if (!Number.isSafeInteger(D) || D < 0x01 || D > 0x7f) + throw new Error('invalid domain separation byte must be 0x01..0x7f, got: ' + D); + return new sha3_ts_1.Keccak(blockLen, D, opts.dkLen === undefined ? outputLen : opts.dkLen, true, 12); +}); +/** TurboSHAKE 128-bit: reduced 12-round keccak. */ +exports.turboshake128 = genTurboshake(168, 256 / 8); +/** TurboSHAKE 256-bit: reduced 12-round keccak. */ +exports.turboshake256 = genTurboshake(136, 512 / 8); +// Kangaroo +// Same as NIST rightEncode, but returns [0] for zero string +function rightEncodeK12(n) { + n = BigInt(n); + const res = []; + for (; n > 0; n >>= _8n) + res.unshift(Number(n & _ffn)); + res.push(res.length); + return Uint8Array.from(res); +} +const EMPTY_BUFFER = /* @__PURE__ */ Uint8Array.of(); +class KangarooTwelve extends sha3_ts_1.Keccak { + constructor(blockLen, leafLen, outputLen, rounds, opts) { + super(blockLen, 0x07, outputLen, true, rounds); + this.chunkLen = 8192; + this.chunkPos = 0; // Position of current block in chunk + this.chunksDone = 0; // How many chunks we already have + this.leafLen = leafLen; + this.personalization = abytesOrZero(opts.personalization); + } + update(data) { + data = (0, utils_ts_1.toBytes)(data); + (0, utils_ts_1.abytes)(data); + const { chunkLen, blockLen, leafLen, rounds } = this; + for (let pos = 0, len = data.length; pos < len;) { + if (this.chunkPos == chunkLen) { + if (this.leafHash) + super.update(this.leafHash.digest()); + else { + this.suffix = 0x06; // Its safe to change suffix here since its used only in digest() + super.update(Uint8Array.from([3, 0, 0, 0, 0, 0, 0, 0])); + } + this.leafHash = new sha3_ts_1.Keccak(blockLen, 0x0b, leafLen, false, rounds); + this.chunksDone++; + this.chunkPos = 0; + } + const take = Math.min(chunkLen - this.chunkPos, len - pos); + const chunk = data.subarray(pos, pos + take); + if (this.leafHash) + this.leafHash.update(chunk); + else + super.update(chunk); + this.chunkPos += take; + pos += take; + } + return this; + } + finish() { + if (this.finished) + return; + const { personalization } = this; + this.update(personalization).update(rightEncodeK12(personalization.length)); + // Leaf hash + if (this.leafHash) { + super.update(this.leafHash.digest()); + super.update(rightEncodeK12(this.chunksDone)); + super.update(Uint8Array.from([0xff, 0xff])); + } + super.finish.call(this); + } + destroy() { + super.destroy.call(this); + if (this.leafHash) + this.leafHash.destroy(); + // We cannot zero personalization buffer since it is user provided and we don't want to mutate user input + this.personalization = EMPTY_BUFFER; + } + _cloneInto(to) { + const { blockLen, leafLen, leafHash, outputLen, rounds } = this; + to || (to = new KangarooTwelve(blockLen, leafLen, outputLen, rounds, {})); + super._cloneInto(to); + if (leafHash) + to.leafHash = leafHash._cloneInto(to.leafHash); + to.personalization.set(this.personalization); + to.leafLen = this.leafLen; + to.chunkPos = this.chunkPos; + to.chunksDone = this.chunksDone; + return to; + } + clone() { + return this._cloneInto(); + } +} +exports.KangarooTwelve = KangarooTwelve; +/** KangarooTwelve: reduced 12-round keccak. */ +exports.k12 = (() => (0, utils_ts_1.createOptHasher)((opts = {}) => new KangarooTwelve(168, 32, chooseLen(opts, 32), 12, opts)))(); +/** MarsupilamiFourteen: reduced 14-round keccak. */ +exports.m14 = (() => (0, utils_ts_1.createOptHasher)((opts = {}) => new KangarooTwelve(136, 64, chooseLen(opts, 64), 14, opts)))(); +/** + * More at https://github.com/XKCP/XKCP/tree/master/lib/high/Keccak/PRG. + */ +class KeccakPRG extends sha3_ts_1.Keccak { + constructor(capacity) { + (0, utils_ts_1.anumber)(capacity); + // Rho should be full bytes + if (capacity < 0 || capacity > 1600 - 10 || (1600 - capacity - 2) % 8) + throw new Error('invalid capacity'); + // blockLen = rho in bytes + super((1600 - capacity - 2) / 8, 0, 0, true); + this.rate = 1600 - capacity; + this.posOut = Math.floor((this.rate + 7) / 8); + } + keccak() { + // Duplex padding + this.state[this.pos] ^= 0x01; + this.state[this.blockLen] ^= 0x02; // Rho is full bytes + super.keccak(); + this.pos = 0; + this.posOut = 0; + } + update(data) { + super.update(data); + this.posOut = this.blockLen; + return this; + } + feed(data) { + return this.update(data); + } + finish() { } + digestInto(_out) { + throw new Error('digest is not allowed, use .fetch instead'); + } + fetch(bytes) { + return this.xof(bytes); + } + // Ensure irreversibility (even if state leaked previous outputs cannot be computed) + forget() { + if (this.rate < 1600 / 2 + 1) + throw new Error('rate is too low to use .forget()'); + this.keccak(); + for (let i = 0; i < this.blockLen; i++) + this.state[i] = 0; + this.pos = this.blockLen; + this.keccak(); + this.posOut = this.blockLen; + } + _cloneInto(to) { + const { rate } = this; + to || (to = new KeccakPRG(1600 - rate)); + super._cloneInto(to); + to.rate = rate; + return to; + } + clone() { + return this._cloneInto(); + } +} +exports.KeccakPRG = KeccakPRG; +/** KeccakPRG: Pseudo-random generator based on Keccak. https://keccak.team/files/CSF-0.1.pdf */ +const keccakprg = (capacity = 254) => new KeccakPRG(capacity); +exports.keccakprg = keccakprg; +//# sourceMappingURL=sha3-addons.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/sha3-addons.js.map b/node_modules/@noble/hashes/sha3-addons.js.map new file mode 100644 index 0000000000000000000000000000000000000000..b37cd1962477b37fdc40a6c06089f520ee2c0898 --- /dev/null +++ b/node_modules/@noble/hashes/sha3-addons.js.map @@ -0,0 +1 @@ +{"version":3,"file":"sha3-addons.js","sourceRoot":"","sources":["src/sha3-addons.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;GAWG;AACH,uCAAmD;AACnD,yCAYoB;AAEpB,kCAAkC;AAClC,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACtB,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;AAE1B,oGAAoG;AACpG,4CAA4C;AAC5C,SAAS,UAAU,CAAC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AAC,EAAC;QAClC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QACrB,EAAE,CAAC,IAAI,GAAG,IAAI,CAAC;QACf,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,KAAK;QACH,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;IAC3B,CAAC;CACF;AAtDD,8BAsDC;AAED,gGAAgG;AACzF,MAAM,SAAS,GAAG,CAAC,QAAQ,GAAG,GAAG,EAAa,EAAE,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,CAAC;AAAnE,QAAA,SAAS,aAA0D"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/sha3.d.ts b/node_modules/@noble/hashes/sha3.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9df47b19f9f2f343ee7edf5c2b1e2cc6ed5d542d --- /dev/null +++ b/node_modules/@noble/hashes/sha3.d.ts @@ -0,0 +1,53 @@ +import { Hash, type CHash, type CHashXO, type HashXOF, type Input } from './utils.ts'; +/** `keccakf1600` internal function, additionally allows to adjust round count. */ +export declare function keccakP(s: Uint32Array, rounds?: number): void; +/** Keccak sponge function. */ +export declare class Keccak extends Hash implements HashXOF { + protected state: Uint8Array; + protected pos: number; + protected posOut: number; + protected finished: boolean; + protected state32: Uint32Array; + protected destroyed: boolean; + blockLen: number; + suffix: number; + outputLen: number; + protected enableXOF: boolean; + protected rounds: number; + constructor(blockLen: number, suffix: number, outputLen: number, enableXOF?: boolean, rounds?: number); + clone(): Keccak; + protected keccak(): void; + update(data: Input): this; + protected finish(): void; + protected writeInto(out: Uint8Array): Uint8Array; + xofInto(out: Uint8Array): Uint8Array; + xof(bytes: number): Uint8Array; + digestInto(out: Uint8Array): Uint8Array; + digest(): Uint8Array; + destroy(): void; + _cloneInto(to?: Keccak): Keccak; +} +/** SHA3-224 hash function. */ +export declare const sha3_224: CHash; +/** SHA3-256 hash function. Different from keccak-256. */ +export declare const sha3_256: CHash; +/** SHA3-384 hash function. */ +export declare const sha3_384: CHash; +/** SHA3-512 hash function. */ +export declare const sha3_512: CHash; +/** keccak-224 hash function. */ +export declare const keccak_224: CHash; +/** keccak-256 hash function. Different from SHA3-256. */ +export declare const keccak_256: CHash; +/** keccak-384 hash function. */ +export declare const keccak_384: CHash; +/** keccak-512 hash function. */ +export declare const keccak_512: CHash; +export type ShakeOpts = { + dkLen?: number; +}; +/** SHAKE128 XOF with 128-bit security. */ +export declare const shake128: CHashXO; +/** SHAKE256 XOF with 256-bit security. */ +export declare const shake256: CHashXO; +//# sourceMappingURL=sha3.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/sha3.d.ts.map b/node_modules/@noble/hashes/sha3.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..979f89d4cad0605143dfb0722a9d29d0911e5395 --- /dev/null +++ b/node_modules/@noble/hashes/sha3.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"sha3.d.ts","sourceRoot":"","sources":["src/sha3.ts"],"names":[],"mappings":"AAaA,OAAO,EAE6B,IAAI,EAGtC,KAAK,KAAK,EAAE,KAAK,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,KAAK,EACnD,MAAM,YAAY,CAAC;AAoCpB,kFAAkF;AAClF,wBAAgB,OAAO,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,GAAE,MAAW,GAAG,IAAI,CAyCjE;AAED,8BAA8B;AAC9B,qBAAa,MAAO,SAAQ,IAAI,CAAC,MAAM,CAAE,YAAW,OAAO,CAAC,MAAM,CAAC;IACjE,SAAS,CAAC,KAAK,EAAE,UAAU,CAAC;IAC5B,SAAS,CAAC,GAAG,SAAK;IAClB,SAAS,CAAC,MAAM,SAAK;IACrB,SAAS,CAAC,QAAQ,UAAS;IAC3B,SAAS,CAAC,OAAO,EAAE,WAAW,CAAC;IAC/B,SAAS,CAAC,SAAS,UAAS;IAErB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IACzB,SA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AM,QAAQ,EAAE,OAAgE,CAAC;AACxF,0CAA0C;AAC1C,eAAO,MAAM,QAAQ,EAAE,OAAgE,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/sha3.js b/node_modules/@noble/hashes/sha3.js new file mode 100644 index 0000000000000000000000000000000000000000..bc612280a9726b9987530914a75c2155495d2476 --- /dev/null +++ b/node_modules/@noble/hashes/sha3.js @@ -0,0 +1,239 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.shake256 = exports.shake128 = exports.keccak_512 = exports.keccak_384 = exports.keccak_256 = exports.keccak_224 = exports.sha3_512 = exports.sha3_384 = exports.sha3_256 = exports.sha3_224 = exports.Keccak = void 0; +exports.keccakP = keccakP; +/** + * SHA3 (keccak) hash function, based on a new "Sponge function" design. + * Different from older hashes, the internal state is bigger than output size. + * + * Check out [FIPS-202](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf), + * [Website](https://keccak.team/keccak.html), + * [the differences between SHA-3 and Keccak](https://crypto.stackexchange.com/questions/15727/what-are-the-key-differences-between-the-draft-sha-3-standard-and-the-keccak-sub). + * + * Check out `sha3-addons` module for cSHAKE, k12, and others. + * @module + */ +const _u64_ts_1 = require("./_u64.js"); +// prettier-ignore +const utils_ts_1 = require("./utils.js"); +// No __PURE__ annotations in sha3 header: +// EVERYTHING is in fact used on every export. +// Various per round constants calculations +const _0n = BigInt(0); +const _1n = BigInt(1); +const _2n = BigInt(2); +const _7n = BigInt(7); +const _256n = BigInt(256); +const _0x71n = BigInt(0x71); +const SHA3_PI = []; +const SHA3_ROTL = []; +const _SHA3_IOTA = []; +for (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) { + // Pi + [x, y] = [y, (2 * x + 3 * y) % 5]; + SHA3_PI.push(2 * (5 * y + x)); + // Rotational + SHA3_ROTL.push((((round + 1) * (round + 2)) / 2) % 64); + // Iota + let t = _0n; + for (let j = 0; j < 7; j++) { + R = ((R << _1n) ^ ((R >> _7n) * _0x71n)) % _256n; + if (R & _2n) + t ^= _1n << ((_1n << /* @__PURE__ */ BigInt(j)) - _1n); + } + _SHA3_IOTA.push(t); +} +const IOTAS = (0, _u64_ts_1.split)(_SHA3_IOTA, true); +const SHA3_IOTA_H = IOTAS[0]; +const SHA3_IOTA_L = IOTAS[1]; +// Left rotation (without 0, 32, 64) +const rotlH = (h, l, s) => (s > 32 ? (0, _u64_ts_1.rotlBH)(h, l, s) : (0, _u64_ts_1.rotlSH)(h, l, s)); +const rotlL = (h, l, s) => (s > 32 ? (0, _u64_ts_1.rotlBL)(h, l, s) : (0, _u64_ts_1.rotlSL)(h, l, s)); +/** `keccakf1600` internal function, additionally allows to adjust round count. */ +function keccakP(s, rounds = 24) { + const B = new Uint32Array(5 * 2); + // NOTE: all indices are x2 since we store state as u32 instead of u64 (bigints to slow in js) + for (let round = 24 - rounds; round < 24; round++) { + // Theta θ + for (let x = 0; x < 10; x++) + B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40]; + for (let x = 0; x < 10; x += 2) { + const idx1 = (x + 8) % 10; + const idx0 = (x + 2) % 10; + const B0 = B[idx0]; + const B1 = B[idx0 + 1]; + const Th = rotlH(B0, B1, 1) ^ B[idx1]; + const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1]; + for (let y = 0; y < 50; y += 10) { + s[x + y] ^= Th; + s[x + y + 1] ^= Tl; + } + } + // Rho (ρ) and Pi (π) + let curH = s[2]; + let curL = s[3]; + for (let t = 0; t < 24; t++) { + const shift = SHA3_ROTL[t]; + const Th = rotlH(curH, curL, shift); + const Tl = rotlL(curH, curL, shift); + const PI = SHA3_PI[t]; + curH = s[PI]; + curL = s[PI + 1]; + s[PI] = Th; + s[PI + 1] = Tl; + } + // Chi (χ) + for (let y = 0; y < 50; y += 10) { + for (let x = 0; x < 10; x++) + B[x] = s[y + x]; + for (let x = 0; x < 10; x++) + s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10]; + } + // Iota (ι) + s[0] ^= SHA3_IOTA_H[round]; + s[1] ^= SHA3_IOTA_L[round]; + } + (0, utils_ts_1.clean)(B); +} +/** Keccak sponge function. */ +class Keccak extends utils_ts_1.Hash { + // NOTE: we accept arguments in bytes instead of bits here. + constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) { + super(); + this.pos = 0; + this.posOut = 0; + this.finished = false; + this.destroyed = false; + this.enableXOF = false; + this.blockLen = blockLen; + this.suffix = suffix; + this.outputLen = outputLen; + this.enableXOF = enableXOF; + this.rounds = rounds; + // Can be passed from user as dkLen + (0, utils_ts_1.anumber)(outputLen); + // 1600 = 5x5 matrix of 64bit. 1600 bits === 200 bytes + // 0 < blockLen < 200 + if (!(0 < blockLen && blockLen < 200)) + throw new Error('only keccak-f1600 function is supported'); + this.state = new Uint8Array(200); + this.state32 = (0, utils_ts_1.u32)(this.state); + } + clone() { + return this._cloneInto(); + } + keccak() { + (0, utils_ts_1.swap32IfBE)(this.state32); + keccakP(this.state32, this.rounds); + (0, utils_ts_1.swap32IfBE)(this.state32); + this.posOut = 0; + this.pos = 0; + } + update(data) { + (0, utils_ts_1.aexists)(this); + data = (0, utils_ts_1.toBytes)(data); + (0, utils_ts_1.abytes)(data); + const { blockLen, state } = this; + const len = data.length; + for (let pos = 0; pos < len;) { + const take = Math.min(blockLen - this.pos, len - pos); + for (let i = 0; i < take; i++) + state[this.pos++] ^= data[pos++]; + if (this.pos === blockLen) + this.keccak(); + } + return this; + } + finish() { + if (this.finished) + return; + this.finished = true; + const { state, suffix, pos, blockLen } = this; + // Do the padding + state[pos] ^= suffix; + if ((suffix & 0x80) !== 0 && pos === blockLen - 1) + this.keccak(); + state[blockLen - 1] ^= 0x80; + this.keccak(); + } + writeInto(out) { + (0, utils_ts_1.aexists)(this, false); + (0, utils_ts_1.abytes)(out); + this.finish(); + const bufferOut = this.state; + const { blockLen } = this; + for (let pos = 0, len = out.length; pos < len;) { + if (this.posOut >= blockLen) + this.keccak(); + const take = Math.min(blockLen - this.posOut, len - pos); + out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos); + this.posOut += take; + pos += take; + } + return out; + } + xofInto(out) { + // Sha3/Keccak usage with XOF is probably mistake, only SHAKE instances can do XOF + if (!this.enableXOF) + throw new Error('XOF is not possible for this instance'); + return this.writeInto(out); + } + xof(bytes) { + (0, utils_ts_1.anumber)(bytes); + return this.xofInto(new Uint8Array(bytes)); + } + digestInto(out) { + (0, utils_ts_1.aoutput)(out, this); + if (this.finished) + throw new Error('digest() was already called'); + this.writeInto(out); + this.destroy(); + return out; + } + digest() { + return this.digestInto(new Uint8Array(this.outputLen)); + } + destroy() { + this.destroyed = true; + (0, utils_ts_1.clean)(this.state); + } + _cloneInto(to) { + const { blockLen, suffix, outputLen, rounds, enableXOF } = this; + to || (to = new Keccak(blockLen, suffix, outputLen, enableXOF, rounds)); + to.state32.set(this.state32); + to.pos = this.pos; + to.posOut = this.posOut; + to.finished = this.finished; + to.rounds = rounds; + // Suffix can change in cSHAKE + to.suffix = suffix; + to.outputLen = outputLen; + to.enableXOF = enableXOF; + to.destroyed = this.destroyed; + return to; + } +} +exports.Keccak = Keccak; +const gen = (suffix, blockLen, outputLen) => (0, utils_ts_1.createHasher)(() => new Keccak(blockLen, suffix, outputLen)); +/** SHA3-224 hash function. */ +exports.sha3_224 = (() => gen(0x06, 144, 224 / 8))(); +/** SHA3-256 hash function. Different from keccak-256. */ +exports.sha3_256 = (() => gen(0x06, 136, 256 / 8))(); +/** SHA3-384 hash function. */ +exports.sha3_384 = (() => gen(0x06, 104, 384 / 8))(); +/** SHA3-512 hash function. */ +exports.sha3_512 = (() => gen(0x06, 72, 512 / 8))(); +/** keccak-224 hash function. */ +exports.keccak_224 = (() => gen(0x01, 144, 224 / 8))(); +/** keccak-256 hash function. Different from SHA3-256. */ +exports.keccak_256 = (() => gen(0x01, 136, 256 / 8))(); +/** keccak-384 hash function. */ +exports.keccak_384 = (() => gen(0x01, 104, 384 / 8))(); +/** keccak-512 hash function. */ +exports.keccak_512 = (() => gen(0x01, 72, 512 / 8))(); +const genShake = (suffix, blockLen, outputLen) => (0, utils_ts_1.createXOFer)((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen === undefined ? outputLen : opts.dkLen, true)); +/** SHAKE128 XOF with 128-bit security. */ +exports.shake128 = (() => genShake(0x1f, 168, 128 / 8))(); +/** SHAKE256 XOF with 256-bit security. */ +exports.shake256 = (() => genShake(0x1f, 136, 256 / 8))(); +//# sourceMappingURL=sha3.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/sha3.js.map b/node_modules/@noble/hashes/sha3.js.map new file mode 100644 index 0000000000000000000000000000000000000000..42b47f32316635c43ad34aa28a7439651061ac5f --- /dev/null +++ b/node_modules/@noble/hashes/sha3.js.map @@ -0,0 +1 @@ +{"version":3,"file":"sha3.js","sourceRoot":"","sources":["src/sha3.ts"],"names":[],"mappings":";;;AAwDA,0BAyCC;AAjGD;;;;;;;;;;GAUG;AACH,uCAAkE;AAClE,kBAAkB;AAClB,yCAMoB;AAEpB,0CAA0C;AAC1C,8CAA8C;AAC9C,2CAA2C;AAC3C,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACtB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACtB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACtB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACtB,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;AAC1B,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;AAC5B,MAAM,OAAO,GAAa,EAAE,CAAC;AAC7B,MAAM,SAAS,GAAa,EAAE,CAAC;AAC/B,MAAM,UAAU,GAAa,EAAE,CAAC;AAChC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAA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,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CACxF,CAAC;AAEJ,0CAA0C;AAC7B,QAAA,QAAQ,GAA4B,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;AACxF,0CAA0C;AAC7B,QAAA,QAAQ,GAA4B,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/sha512.d.ts b/node_modules/@noble/hashes/sha512.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..46a27d021990fce25bd3a64b1ad52b5750272170 --- /dev/null +++ b/node_modules/@noble/hashes/sha512.d.ts @@ -0,0 +1,26 @@ +/** + * SHA2-512 a.k.a. sha512 and sha384. It is slower than sha256 in js because u64 operations are slow. + * + * Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and + * [the paper on truncated SHA512/256](https://eprint.iacr.org/2010/548.pdf). + * @module + * @deprecated + */ +import { SHA384 as SHA384n, sha384 as sha384n, sha512_224 as sha512_224n, SHA512_224 as SHA512_224n, sha512_256 as sha512_256n, SHA512_256 as SHA512_256n, SHA512 as SHA512n, sha512 as sha512n } from './sha2.ts'; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export declare const SHA512: typeof SHA512n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export declare const sha512: typeof sha512n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export declare const SHA384: typeof SHA384n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export declare const sha384: typeof sha384n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export declare const SHA512_224: typeof SHA512_224n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export declare const sha512_224: typeof sha512_224n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export declare const SHA512_256: typeof SHA512_256n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export declare const sha512_256: typeof sha512_256n; +//# sourceMappingURL=sha512.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/sha512.d.ts.map b/node_modules/@noble/hashes/sha512.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..4ed35ec3ea0e23d5893bc37816123e5dbbdee4da --- /dev/null +++ b/node_modules/@noble/hashes/sha512.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"sha512.d.ts","sourceRoot":"","sources":["src/sha512.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,MAAM,IAAI,OAAO,EACjB,MAAM,IAAI,OAAO,EACjB,UAAU,IAAI,WAAW,EACzB,UAAU,IAAI,WAAW,EACzB,UAAU,IAAI,WAAW,EACzB,UAAU,IAAI,WAAW,EACzB,MAAM,IAAI,OAAO,EACjB,MAAM,IAAI,OAAO,EAClB,MAAM,WAAW,CAAC;AACnB,6DAA6D;AAC7D,eAAO,MAAM,MAAM,EAAE,OAAO,OAAiB,CAAC;AAC9C,6DAA6D;AAC7D,eAAO,MAAM,MAAM,EAAE,OAAO,OAAiB,CAAC;AAC9C,6DAA6D;AAC7D,eAAO,MAAM,MAAM,EAAE,OAAO,OAAiB,CAAC;AAC9C,6DAA6D;AAC7D,eAAO,MAAM,MAAM,EAAE,OAAO,OAAiB,CAAC;AAC9C,6DAA6D;AAC7D,eAAO,MAAM,UAAU,EAAE,OAAO,WAAyB,CAAC;AAC1D,6DAA6D;AAC7D,eAAO,MAAM,UAAU,EAAE,OAAO,WAAyB,CAAC;AAC1D,6DAA6D;AAC7D,eAAO,MAAM,UAAU,EAAE,OAAO,WAAyB,CAAC;AAC1D,6DAA6D;AAC7D,eAAO,MAAM,UAAU,EAAE,OAAO,WAAyB,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/sha512.js b/node_modules/@noble/hashes/sha512.js new file mode 100644 index 0000000000000000000000000000000000000000..31cbbca3d624c9b7c47efcb0f610e69f41e44498 --- /dev/null +++ b/node_modules/@noble/hashes/sha512.js @@ -0,0 +1,29 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.sha512_256 = exports.SHA512_256 = exports.sha512_224 = exports.SHA512_224 = exports.sha384 = exports.SHA384 = exports.sha512 = exports.SHA512 = void 0; +/** + * SHA2-512 a.k.a. sha512 and sha384. It is slower than sha256 in js because u64 operations are slow. + * + * Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and + * [the paper on truncated SHA512/256](https://eprint.iacr.org/2010/548.pdf). + * @module + * @deprecated + */ +const sha2_ts_1 = require("./sha2.js"); +/** @deprecated Use import from `noble/hashes/sha2` module */ +exports.SHA512 = sha2_ts_1.SHA512; +/** @deprecated Use import from `noble/hashes/sha2` module */ +exports.sha512 = sha2_ts_1.sha512; +/** @deprecated Use import from `noble/hashes/sha2` module */ +exports.SHA384 = sha2_ts_1.SHA384; +/** @deprecated Use import from `noble/hashes/sha2` module */ +exports.sha384 = sha2_ts_1.sha384; +/** @deprecated Use import from `noble/hashes/sha2` module */ +exports.SHA512_224 = sha2_ts_1.SHA512_224; +/** @deprecated Use import from `noble/hashes/sha2` module */ +exports.sha512_224 = sha2_ts_1.sha512_224; +/** @deprecated Use import from `noble/hashes/sha2` module */ +exports.SHA512_256 = sha2_ts_1.SHA512_256; +/** @deprecated Use import from `noble/hashes/sha2` module */ +exports.sha512_256 = sha2_ts_1.sha512_256; +//# sourceMappingURL=sha512.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/sha512.js.map b/node_modules/@noble/hashes/sha512.js.map new file mode 100644 index 0000000000000000000000000000000000000000..e685b2063e1e4ee3908535a20845c0a334fb3021 --- /dev/null +++ b/node_modules/@noble/hashes/sha512.js.map @@ -0,0 +1 @@ +{"version":3,"file":"sha512.js","sourceRoot":"","sources":["src/sha512.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACH,uCASmB;AACnB,6DAA6D;AAChD,QAAA,MAAM,GAAmB,gBAAO,CAAC;AAC9C,6DAA6D;AAChD,QAAA,MAAM,GAAmB,gBAAO,CAAC;AAC9C,6DAA6D;AAChD,QAAA,MAAM,GAAmB,gBAAO,CAAC;AAC9C,6DAA6D;AAChD,QAAA,MAAM,GAAmB,gBAAO,CAAC;AAC9C,6DAA6D;AAChD,QAAA,UAAU,GAAuB,oBAAW,CAAC;AAC1D,6DAA6D;AAChD,QAAA,UAAU,GAAuB,oBAAW,CAAC;AAC1D,6DAA6D;AAChD,QAAA,UAAU,GAAuB,oBAAW,CAAC;AAC1D,6DAA6D;AAChD,QAAA,UAAU,GAAuB,oBAAW,CAAC"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/src/_assert.ts b/node_modules/@noble/hashes/src/_assert.ts new file mode 100644 index 0000000000000000000000000000000000000000..3da1eb1e5b4644e875f22cb8d7c8e25baa29984b --- /dev/null +++ b/node_modules/@noble/hashes/src/_assert.ts @@ -0,0 +1,22 @@ +/** + * Internal assertion helpers. + * @module + * @deprecated + */ +import { + abytes as ab, + aexists as ae, + anumber as an, + aoutput as ao, + type IHash as H, +} from './utils.ts'; +/** @deprecated Use import from `noble/hashes/utils` module */ +export const abytes: typeof ab = ab; +/** @deprecated Use import from `noble/hashes/utils` module */ +export const aexists: typeof ae = ae; +/** @deprecated Use import from `noble/hashes/utils` module */ +export const anumber: typeof an = an; +/** @deprecated Use import from `noble/hashes/utils` module */ +export const aoutput: typeof ao = ao; +/** @deprecated Use import from `noble/hashes/utils` module */ +export type Hash = H; diff --git a/node_modules/@noble/hashes/src/_blake.ts b/node_modules/@noble/hashes/src/_blake.ts new file mode 100644 index 0000000000000000000000000000000000000000..2df27be0247ae43f70977b5ead6a9b750fbfa1cf --- /dev/null +++ b/node_modules/@noble/hashes/src/_blake.ts @@ -0,0 +1,50 @@ +/** + * Internal helpers for blake hash. + * @module + */ +import { rotr } from './utils.ts'; + +/** + * Internal blake variable. + * For BLAKE2b, the two extra permutations for rounds 10 and 11 are SIGMA[10..11] = SIGMA[0..1]. + */ +// prettier-ignore +export const BSIGMA: Uint8Array = /* @__PURE__ */ Uint8Array.from([ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, + 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, + 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, + 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, + 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, + 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, + 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, + 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5, + 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, + // Blake1, unused in others + 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, + 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, + 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, + 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, +]); + +// prettier-ignore +export type Num4 = { a: number; b: number; c: number; d: number; }; + +// Mixing function G splitted in two halfs +export function G1s(a: number, b: number, c: number, d: number, x: number): Num4 { + a = (a + b + x) | 0; + d = rotr(d ^ a, 16); + c = (c + d) | 0; + b = rotr(b ^ c, 12); + return { a, b, c, d }; +} + +export function G2s(a: number, b: number, c: number, d: number, x: number): Num4 { + a = (a + b + x) | 0; + d = rotr(d ^ a, 8); + c = (c + d) | 0; + b = rotr(b ^ c, 7); + return { a, b, c, d }; +} diff --git a/node_modules/@noble/hashes/src/_md.ts b/node_modules/@noble/hashes/src/_md.ts new file mode 100644 index 0000000000000000000000000000000000000000..469b781553a2235c5fe613f119f46eb3f75a44e4 --- /dev/null +++ b/node_modules/@noble/hashes/src/_md.ts @@ -0,0 +1,176 @@ +/** + * Internal Merkle-Damgard hash utils. + * @module + */ +import { type Input, Hash, abytes, aexists, aoutput, clean, createView, toBytes } from './utils.ts'; + +/** Polyfill for Safari 14. https://caniuse.com/mdn-javascript_builtins_dataview_setbiguint64 */ +export function setBigUint64( + view: DataView, + byteOffset: number, + value: bigint, + isLE: boolean +): void { + if (typeof view.setBigUint64 === 'function') return view.setBigUint64(byteOffset, value, isLE); + const _32n = BigInt(32); + const _u32_max = BigInt(0xffffffff); + const wh = Number((value >> _32n) & _u32_max); + const wl = Number(value & _u32_max); + const h = isLE ? 4 : 0; + const l = isLE ? 0 : 4; + view.setUint32(byteOffset + h, wh, isLE); + view.setUint32(byteOffset + l, wl, isLE); +} + +/** Choice: a ? b : c */ +export function Chi(a: number, b: number, c: number): number { + return (a & b) ^ (~a & c); +} + +/** Majority function, true if any two inputs is true. */ +export function Maj(a: number, b: number, c: number): number { + return (a & b) ^ (a & c) ^ (b & c); +} + +/** + * Merkle-Damgard hash construction base class. + * Could be used to create MD5, RIPEMD, SHA1, SHA2. + */ +export abstract class HashMD> extends Hash { + protected abstract process(buf: DataView, offset: number): void; + protected abstract get(): number[]; + protected abstract set(...args: number[]): void; + abstract destroy(): void; + protected abstract roundClean(): void; + + readonly blockLen: number; + readonly outputLen: number; + readonly padOffset: number; + readonly isLE: boolean; + + // For partial updates less than block size + protected buffer: Uint8Array; + protected view: DataView; + protected finished = false; + protected length = 0; + protected pos = 0; + protected destroyed = false; + + constructor(blockLen: number, outputLen: number, padOffset: number, isLE: boolean) { + super(); + this.blockLen = blockLen; + this.outputLen = outputLen; + this.padOffset = padOffset; + this.isLE = isLE; + this.buffer = new Uint8Array(blockLen); + this.view = createView(this.buffer); + } + update(data: Input): this { + aexists(this); + data = toBytes(data); + abytes(data); + const { view, buffer, blockLen } = this; + const len = data.length; + for (let pos = 0; pos < len; ) { + const take = Math.min(blockLen - this.pos, len - pos); + // Fast path: we have at least one block in input, cast it to view and process + if (take === blockLen) { + const dataView = createView(data); + for (; blockLen <= len - pos; pos += blockLen) this.process(dataView, pos); + continue; + } + buffer.set(data.subarray(pos, pos + take), this.pos); + this.pos += take; + pos += take; + if (this.pos === blockLen) { + this.process(view, 0); + this.pos = 0; + } + } + this.length += data.length; + this.roundClean(); + return this; + } + digestInto(out: Uint8Array): void { + aexists(this); + aoutput(out, this); + this.finished = true; + // Padding + // We can avoid allocation of buffer for padding completely if it + // was previously not allocated here. But it won't change performance. + const { buffer, view, blockLen, isLE } = this; + let { pos } = this; + // append the bit '1' to the message + buffer[pos++] = 0b10000000; + clean(this.buffer.subarray(pos)); + // we have less than padOffset left in buffer, so we cannot put length in + // current block, need process it and pad again + if (this.padOffset > blockLen - pos) { + this.process(view, 0); + pos = 0; + } + // Pad until full block byte with zeros + for (let i = pos; i < blockLen; i++) buffer[i] = 0; + // Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that + // You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen. + // So we just write lowest 64 bits of that value. + setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE); + this.process(view, 0); + const oview = createView(out); + const len = this.outputLen; + // NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT + if (len % 4) throw new Error('_sha2: outputLen should be aligned to 32bit'); + const outLen = len / 4; + const state = this.get(); + if (outLen > state.length) throw new Error('_sha2: outputLen bigger than state'); + for (let i = 0; i < outLen; i++) oview.setUint32(4 * i, state[i], isLE); + } + digest(): Uint8Array { + const { buffer, outputLen } = this; + this.digestInto(buffer); + const res = buffer.slice(0, outputLen); + this.destroy(); + return res; + } + _cloneInto(to?: T): T { + to ||= new (this.constructor as any)() as T; + to.set(...this.get()); + const { blockLen, buffer, length, finished, destroyed, pos } = this; + to.destroyed = destroyed; + to.finished = finished; + to.length = length; + to.pos = pos; + if (length % blockLen) to.buffer.set(buffer); + return to; + } + clone(): T { + return this._cloneInto(); + } +} + +/** + * Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53. + * Check out `test/misc/sha2-gen-iv.js` for recomputation guide. + */ + +/** Initial SHA256 state. Bits 0..32 of frac part of sqrt of primes 2..19 */ +export const SHA256_IV: Uint32Array = /* @__PURE__ */ Uint32Array.from([ + 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19, +]); + +/** Initial SHA224 state. Bits 32..64 of frac part of sqrt of primes 23..53 */ +export const SHA224_IV: Uint32Array = /* @__PURE__ */ Uint32Array.from([ + 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4, +]); + +/** Initial SHA384 state. Bits 0..64 of frac part of sqrt of primes 23..53 */ +export const SHA384_IV: Uint32Array = /* @__PURE__ */ Uint32Array.from([ + 0xcbbb9d5d, 0xc1059ed8, 0x629a292a, 0x367cd507, 0x9159015a, 0x3070dd17, 0x152fecd8, 0xf70e5939, + 0x67332667, 0xffc00b31, 0x8eb44a87, 0x68581511, 0xdb0c2e0d, 0x64f98fa7, 0x47b5481d, 0xbefa4fa4, +]); + +/** Initial SHA512 state. Bits 0..64 of frac part of sqrt of primes 2..19 */ +export const SHA512_IV: Uint32Array = /* @__PURE__ */ Uint32Array.from([ + 0x6a09e667, 0xf3bcc908, 0xbb67ae85, 0x84caa73b, 0x3c6ef372, 0xfe94f82b, 0xa54ff53a, 0x5f1d36f1, + 0x510e527f, 0xade682d1, 0x9b05688c, 0x2b3e6c1f, 0x1f83d9ab, 0xfb41bd6b, 0x5be0cd19, 0x137e2179, +]); diff --git a/node_modules/@noble/hashes/src/_u64.ts b/node_modules/@noble/hashes/src/_u64.ts new file mode 100644 index 0000000000000000000000000000000000000000..703c7da573daebb603fcd6f7137fd2451395d289 --- /dev/null +++ b/node_modules/@noble/hashes/src/_u64.ts @@ -0,0 +1,91 @@ +/** + * Internal helpers for u64. BigUint64Array is too slow as per 2025, so we implement it using Uint32Array. + * @todo re-check https://issues.chromium.org/issues/42212588 + * @module + */ +const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1); +const _32n = /* @__PURE__ */ BigInt(32); + +function fromBig( + n: bigint, + le = false +): { + h: number; + l: number; +} { + if (le) return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) }; + return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 }; +} + +function split(lst: bigint[], le = false): Uint32Array[] { + const len = lst.length; + let Ah = new Uint32Array(len); + let Al = new Uint32Array(len); + for (let i = 0; i < len; i++) { + const { h, l } = fromBig(lst[i], le); + [Ah[i], Al[i]] = [h, l]; + } + return [Ah, Al]; +} + +const toBig = (h: number, l: number): bigint => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0); +// for Shift in [0, 32) +const shrSH = (h: number, _l: number, s: number): number => h >>> s; +const shrSL = (h: number, l: number, s: number): number => (h << (32 - s)) | (l >>> s); +// Right rotate for Shift in [1, 32) +const rotrSH = (h: number, l: number, s: number): number => (h >>> s) | (l << (32 - s)); +const rotrSL = (h: number, l: number, s: number): number => (h << (32 - s)) | (l >>> s); +// Right rotate for Shift in (32, 64), NOTE: 32 is special case. +const rotrBH = (h: number, l: number, s: number): number => (h << (64 - s)) | (l >>> (s - 32)); +const rotrBL = (h: number, l: number, s: number): number => (h >>> (s - 32)) | (l << (64 - s)); +// Right rotate for shift===32 (just swaps l&h) +const rotr32H = (_h: number, l: number): number => l; +const rotr32L = (h: number, _l: number): number => h; +// Left rotate for Shift in [1, 32) +const rotlSH = (h: number, l: number, s: number): number => (h << s) | (l >>> (32 - s)); +const rotlSL = (h: number, l: number, s: number): number => (l << s) | (h >>> (32 - s)); +// Left rotate for Shift in (32, 64), NOTE: 32 is special case. +const rotlBH = (h: number, l: number, s: number): number => (l << (s - 32)) | (h >>> (64 - s)); +const rotlBL = (h: number, l: number, s: number): number => (h << (s - 32)) | (l >>> (64 - s)); + +// JS uses 32-bit signed integers for bitwise operations which means we cannot +// simple take carry out of low bit sum by shift, we need to use division. +function add( + Ah: number, + Al: number, + Bh: number, + Bl: number +): { + h: number; + l: number; +} { + const l = (Al >>> 0) + (Bl >>> 0); + return { h: (Ah + Bh + ((l / 2 ** 32) | 0)) | 0, l: l | 0 }; +} +// Addition with more than 2 elements +const add3L = (Al: number, Bl: number, Cl: number): number => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0); +const add3H = (low: number, Ah: number, Bh: number, Ch: number): number => + (Ah + Bh + Ch + ((low / 2 ** 32) | 0)) | 0; +const add4L = (Al: number, Bl: number, Cl: number, Dl: number): number => + (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0); +const add4H = (low: number, Ah: number, Bh: number, Ch: number, Dh: number): number => + (Ah + Bh + Ch + Dh + ((low / 2 ** 32) | 0)) | 0; +const add5L = (Al: number, Bl: number, Cl: number, Dl: number, El: number): number => + (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0); +const add5H = (low: number, Ah: number, Bh: number, Ch: number, Dh: number, Eh: number): number => + (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0; + +// prettier-ignore +export { + add, add3H, add3L, add4H, add4L, add5H, add5L, fromBig, rotlBH, rotlBL, rotlSH, rotlSL, rotr32H, rotr32L, rotrBH, rotrBL, rotrSH, rotrSL, shrSH, shrSL, split, toBig +}; +// prettier-ignore +const u64: { fromBig: typeof fromBig; split: typeof split; toBig: (h: number, l: number) => bigint; shrSH: (h: number, _l: number, s: number) => number; shrSL: (h: number, l: number, s: number) => number; rotrSH: (h: number, l: number, s: number) => number; rotrSL: (h: number, l: number, s: number) => number; rotrBH: (h: number, l: number, s: number) => number; rotrBL: (h: number, l: number, s: number) => number; rotr32H: (_h: number, l: number) => number; rotr32L: (h: number, _l: number) => number; rotlSH: (h: number, l: number, s: number) => number; rotlSL: (h: number, l: number, s: number) => number; rotlBH: (h: number, l: number, s: number) => number; rotlBL: (h: number, l: number, s: number) => number; add: typeof add; add3L: (Al: number, Bl: number, Cl: number) => number; add3H: (low: number, Ah: number, Bh: number, Ch: number) => number; add4L: (Al: number, Bl: number, Cl: number, Dl: number) => number; add4H: (low: number, Ah: number, Bh: number, Ch: number, Dh: number) => number; add5H: (low: number, Ah: number, Bh: number, Ch: number, Dh: number, Eh: number) => number; add5L: (Al: number, Bl: number, Cl: number, Dl: number, El: number) => number; } = { + fromBig, split, toBig, + shrSH, shrSL, + rotrSH, rotrSL, rotrBH, rotrBL, + rotr32H, rotr32L, + rotlSH, rotlSL, rotlBH, rotlBL, + add, add3L, add3H, add4L, add4H, add5H, add5L, +}; +export default u64; diff --git a/node_modules/@noble/hashes/src/argon2.ts b/node_modules/@noble/hashes/src/argon2.ts new file mode 100644 index 0000000000000000000000000000000000000000..9bf7a7ec21ff430361a0fe225c2ee12aa3556b54 --- /dev/null +++ b/node_modules/@noble/hashes/src/argon2.ts @@ -0,0 +1,497 @@ +/** + * Argon2 KDF from RFC 9106. Can be used to create a key from password and salt. + * We suggest to use Scrypt. JS Argon is 2-10x slower than native code because of 64-bitness: + * * argon uses uint64, but JS doesn't have fast uint64array + * * uint64 multiplication is 1/3 of time + * * `P` function would be very nice with u64, because most of value will be in registers, + * hovewer with u32 it will require 32 registers, which is too much. + * * JS arrays do slow bound checks, so reading from `A2_BUF` slows it down + * @module + */ +import { add3H, add3L, rotr32H, rotr32L, rotrBH, rotrBL, rotrSH, rotrSL } from './_u64.ts'; +import { blake2b } from './blake2.ts'; +import { abytes, clean, kdfInputToBytes, nextTick, u32, u8, type KDFInput } from './utils.ts'; + +const AT = { Argond2d: 0, Argon2i: 1, Argon2id: 2 } as const; +type Types = (typeof AT)[keyof typeof AT]; + +const ARGON2_SYNC_POINTS = 4; +const abytesOrZero = (buf?: KDFInput) => { + if (buf === undefined) return Uint8Array.of(); + return kdfInputToBytes(buf); +}; + +// u32 * u32 = u64 +function mul(a: number, b: number) { + const aL = a & 0xffff; + const aH = a >>> 16; + const bL = b & 0xffff; + const bH = b >>> 16; + const ll = Math.imul(aL, bL); + const hl = Math.imul(aH, bL); + const lh = Math.imul(aL, bH); + const hh = Math.imul(aH, bH); + const carry = (ll >>> 16) + (hl & 0xffff) + lh; + const high = (hh + (hl >>> 16) + (carry >>> 16)) | 0; + const low = (carry << 16) | (ll & 0xffff); + return { h: high, l: low }; +} + +function mul2(a: number, b: number) { + // 2 * a * b (via shifts) + const { h, l } = mul(a, b); + return { h: ((h << 1) | (l >>> 31)) & 0xffff_ffff, l: (l << 1) & 0xffff_ffff }; +} + +// BlaMka permutation for Argon2 +// A + B + (2 * u32(A) * u32(B)) +function blamka(Ah: number, Al: number, Bh: number, Bl: number) { + const { h: Ch, l: Cl } = mul2(Al, Bl); + // A + B + (2 * A * B) + const Rll = add3L(Al, Bl, Cl); + return { h: add3H(Rll, Ah, Bh, Ch), l: Rll | 0 }; +} + +// Temporary block buffer +const A2_BUF = new Uint32Array(256); // 1024 bytes (matrix 16x16) + +function G(a: number, b: number, c: number, d: number) { + let Al = A2_BUF[2*a], Ah = A2_BUF[2*a + 1]; // prettier-ignore + let Bl = A2_BUF[2*b], Bh = A2_BUF[2*b + 1]; // prettier-ignore + let Cl = A2_BUF[2*c], Ch = A2_BUF[2*c + 1]; // prettier-ignore + let Dl = A2_BUF[2*d], Dh = A2_BUF[2*d + 1]; // prettier-ignore + + ({ h: Ah, l: Al } = blamka(Ah, Al, Bh, Bl)); + ({ Dh, Dl } = { Dh: Dh ^ Ah, Dl: Dl ^ Al }); + ({ Dh, Dl } = { Dh: rotr32H(Dh, Dl), Dl: rotr32L(Dh, Dl) }); + + ({ h: Ch, l: Cl } = blamka(Ch, Cl, Dh, Dl)); + ({ Bh, Bl } = { Bh: Bh ^ Ch, Bl: Bl ^ Cl }); + ({ Bh, Bl } = { Bh: rotrSH(Bh, Bl, 24), Bl: rotrSL(Bh, Bl, 24) }); + + ({ h: Ah, l: Al } = blamka(Ah, Al, Bh, Bl)); + ({ Dh, Dl } = { Dh: Dh ^ Ah, Dl: Dl ^ Al }); + ({ Dh, Dl } = { Dh: rotrSH(Dh, Dl, 16), Dl: rotrSL(Dh, Dl, 16) }); + + ({ h: Ch, l: Cl } = blamka(Ch, Cl, Dh, Dl)); + ({ Bh, Bl } = { Bh: Bh ^ Ch, Bl: Bl ^ Cl }); + ({ Bh, Bl } = { Bh: rotrBH(Bh, Bl, 63), Bl: rotrBL(Bh, Bl, 63) }); + + (A2_BUF[2 * a] = Al), (A2_BUF[2 * a + 1] = Ah); + (A2_BUF[2 * b] = Bl), (A2_BUF[2 * b + 1] = Bh); + (A2_BUF[2 * c] = Cl), (A2_BUF[2 * c + 1] = Ch); + (A2_BUF[2 * d] = Dl), (A2_BUF[2 * d + 1] = Dh); +} + +// prettier-ignore +function P( + v00: number, v01: number, v02: number, v03: number, v04: number, v05: number, v06: number, v07: number, + v08: number, v09: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, +) { + G(v00, v04, v08, v12); + G(v01, v05, v09, v13); + G(v02, v06, v10, v14); + G(v03, v07, v11, v15); + G(v00, v05, v10, v15); + G(v01, v06, v11, v12); + G(v02, v07, v08, v13); + G(v03, v04, v09, v14); +} + +function block(x: Uint32Array, xPos: number, yPos: number, outPos: number, needXor: boolean) { + for (let i = 0; i < 256; i++) A2_BUF[i] = x[xPos + i] ^ x[yPos + i]; + // columns (8) + for (let i = 0; i < 128; i += 16) { + // prettier-ignore + P( + i, i + 1, i + 2, i + 3, i + 4, i + 5, i + 6, i + 7, + i + 8, i + 9, i + 10, i + 11, i + 12, i + 13, i + 14, i + 15 + ); + } + // rows (8) + for (let i = 0; i < 16; i += 2) { + // prettier-ignore + P( + i, i + 1, i + 16, i + 17, i + 32, i + 33, i + 48, i + 49, + i + 64, i + 65, i + 80, i + 81, i + 96, i + 97, i + 112, i + 113 + ); + } + + if (needXor) for (let i = 0; i < 256; i++) x[outPos + i] ^= A2_BUF[i] ^ x[xPos + i] ^ x[yPos + i]; + else for (let i = 0; i < 256; i++) x[outPos + i] = A2_BUF[i] ^ x[xPos + i] ^ x[yPos + i]; + clean(A2_BUF); +} + +// Variable-Length Hash Function H' +function Hp(A: Uint32Array, dkLen: number) { + const A8 = u8(A); + const T = new Uint32Array(1); + const T8 = u8(T); + T[0] = dkLen; + // Fast path + if (dkLen <= 64) return blake2b.create({ dkLen }).update(T8).update(A8).digest(); + const out = new Uint8Array(dkLen); + let V = blake2b.create({}).update(T8).update(A8).digest(); + let pos = 0; + // First block + out.set(V.subarray(0, 32)); + pos += 32; + // Rest blocks + for (; dkLen - pos > 64; pos += 32) { + const Vh = blake2b.create({}).update(V); + Vh.digestInto(V); + Vh.destroy(); + out.set(V.subarray(0, 32), pos); + } + // Last block + out.set(blake2b(V, { dkLen: dkLen - pos }), pos); + clean(V, T); + return u32(out); +} + +// Used only inside process block! +function indexAlpha( + r: number, + s: number, + laneLen: number, + segmentLen: number, + index: number, + randL: number, + sameLane: boolean = false +) { + // This is ugly, but close enough to reference implementation. + let area: number; + if (r === 0) { + if (s === 0) area = index - 1; + else if (sameLane) area = s * segmentLen + index - 1; + else area = s * segmentLen + (index == 0 ? -1 : 0); + } else if (sameLane) area = laneLen - segmentLen + index - 1; + else area = laneLen - segmentLen + (index == 0 ? -1 : 0); + const startPos = r !== 0 && s !== ARGON2_SYNC_POINTS - 1 ? (s + 1) * segmentLen : 0; + const rel = area - 1 - mul(area, mul(randL, randL).h).h; + return (startPos + rel) % laneLen; +} + +/** + * Argon2 options. + * * t: time cost, m: mem cost in kb, p: parallelization. + * * key: optional key. personalization: arbitrary extra data. + * * dkLen: desired number of output bytes. + */ +export type ArgonOpts = { + t: number; // Time cost, iterations count + m: number; // Memory cost (in KB) + p: number; // Parallelization parameter + version?: number; // Default: 0x13 (19) + key?: KDFInput; // Optional key + personalization?: KDFInput; // Optional arbitrary extra data + dkLen?: number; // Desired number of returned bytes + asyncTick?: number; // Maximum time in ms for which async function can block execution + maxmem?: number; + onProgress?: (progress: number) => void; +}; + +const maxUint32 = Math.pow(2, 32); +function isU32(num: number) { + return Number.isSafeInteger(num) && num >= 0 && num < maxUint32; +} + +function argon2Opts(opts: ArgonOpts) { + const merged: any = { + version: 0x13, + dkLen: 32, + maxmem: maxUint32 - 1, + asyncTick: 10, + }; + for (let [k, v] of Object.entries(opts)) if (v != null) merged[k] = v; + + const { dkLen, p, m, t, version, onProgress } = merged; + if (!isU32(dkLen) || dkLen < 4) throw new Error('dkLen should be at least 4 bytes'); + if (!isU32(p) || p < 1 || p >= Math.pow(2, 24)) throw new Error('p should be 1 <= p < 2^24'); + if (!isU32(m)) throw new Error('m should be 0 <= m < 2^32'); + if (!isU32(t) || t < 1) throw new Error('t (iterations) should be 1 <= t < 2^32'); + if (onProgress !== undefined && typeof onProgress !== 'function') + throw new Error('progressCb should be function'); + /* + Memory size m MUST be an integer number of kibibytes from 8*p to 2^(32)-1. The actual number of blocks is m', which is m rounded down to the nearest multiple of 4*p. + */ + if (!isU32(m) || m < 8 * p) throw new Error('memory should be at least 8*p bytes'); + if (version !== 0x10 && version !== 0x13) throw new Error('unknown version=' + version); + return merged; +} + +function argon2Init(password: KDFInput, salt: KDFInput, type: Types, opts: ArgonOpts) { + password = kdfInputToBytes(password); + salt = kdfInputToBytes(salt); + abytes(password); + abytes(salt); + if (!isU32(password.length)) throw new Error('password should be less than 4 GB'); + if (!isU32(salt.length) || salt.length < 8) + throw new Error('salt should be at least 8 bytes and less than 4 GB'); + if (!Object.values(AT).includes(type)) throw new Error('invalid type'); + let { p, dkLen, m, t, version, key, personalization, maxmem, onProgress, asyncTick } = + argon2Opts(opts); + + // Validation + key = abytesOrZero(key); + personalization = abytesOrZero(personalization); + // H_0 = H^(64)(LE32(p) || LE32(T) || LE32(m) || LE32(t) || + // LE32(v) || LE32(y) || LE32(length(P)) || P || + // LE32(length(S)) || S || LE32(length(K)) || K || + // LE32(length(X)) || X) + const h = blake2b.create({}); + const BUF = new Uint32Array(1); + const BUF8 = u8(BUF); + for (let item of [p, dkLen, m, t, version, type]) { + BUF[0] = item; + h.update(BUF8); + } + for (let i of [password, salt, key, personalization]) { + BUF[0] = i.length; // BUF is u32 array, this is valid + h.update(BUF8).update(i); + } + const H0 = new Uint32Array(18); + const H0_8 = u8(H0); + h.digestInto(H0_8); + // 256 u32 = 1024 (BLOCK_SIZE), fills A2_BUF on processing + + // Params + const lanes = p; + // m' = 4 * p * floor (m / 4p) + const mP = 4 * p * Math.floor(m / (ARGON2_SYNC_POINTS * p)); + //q = m' / p columns + const laneLen = Math.floor(mP / p); + const segmentLen = Math.floor(laneLen / ARGON2_SYNC_POINTS); + const memUsed = mP * 256; + if (!isU32(maxmem) || memUsed > maxmem) + throw new Error( + 'mem should be less than 2**32, got: maxmem=' + maxmem + ', memused=' + memUsed + ); + const B = new Uint32Array(memUsed); + // Fill first blocks + for (let l = 0; l < p; l++) { + const i = 256 * laneLen * l; + // B[i][0] = H'^(1024)(H_0 || LE32(0) || LE32(i)) + H0[17] = l; + H0[16] = 0; + B.set(Hp(H0, 1024), i); + // B[i][1] = H'^(1024)(H_0 || LE32(1) || LE32(i)) + H0[16] = 1; + B.set(Hp(H0, 1024), i + 256); + } + let perBlock = () => {}; + if (onProgress) { + const totalBlock = t * ARGON2_SYNC_POINTS * p * segmentLen; + // Invoke callback if progress changes from 10.01 to 10.02 + // Allows to draw smooth progress bar on up to 8K screen + const callbackPer = Math.max(Math.floor(totalBlock / 10000), 1); + let blockCnt = 0; + perBlock = () => { + blockCnt++; + if (onProgress && (!(blockCnt % callbackPer) || blockCnt === totalBlock)) + onProgress(blockCnt / totalBlock); + }; + } + clean(BUF, H0); + return { type, mP, p, t, version, B, laneLen, lanes, segmentLen, dkLen, perBlock, asyncTick }; +} + +function argon2Output(B: Uint32Array, p: number, laneLen: number, dkLen: number) { + const B_final = new Uint32Array(256); + for (let l = 0; l < p; l++) + for (let j = 0; j < 256; j++) B_final[j] ^= B[256 * (laneLen * l + laneLen - 1) + j]; + const res = u8(Hp(B_final, dkLen)); + clean(B_final); + return res; +} + +function processBlock( + B: Uint32Array, + address: Uint32Array, + l: number, + r: number, + s: number, + index: number, + laneLen: number, + segmentLen: number, + lanes: number, + offset: number, + prev: number, + dataIndependent: boolean, + needXor: boolean +) { + if (offset % laneLen) prev = offset - 1; + let randL, randH; + if (dataIndependent) { + let i128 = index % 128; + if (i128 === 0) { + address[256 + 12]++; + block(address, 256, 2 * 256, 0, false); + block(address, 0, 2 * 256, 0, false); + } + randL = address[2 * i128]; + randH = address[2 * i128 + 1]; + } else { + const T = 256 * prev; + randL = B[T]; + randH = B[T + 1]; + } + // address block + const refLane = r === 0 && s === 0 ? l : randH % lanes; + const refPos = indexAlpha(r, s, laneLen, segmentLen, index, randL, refLane == l); + const refBlock = laneLen * refLane + refPos; + // B[i][j] = G(B[i][j-1], B[l][z]) + block(B, 256 * prev, 256 * refBlock, offset * 256, needXor); +} + +function argon2(type: Types, password: KDFInput, salt: KDFInput, opts: ArgonOpts) { + const { mP, p, t, version, B, laneLen, lanes, segmentLen, dkLen, perBlock } = argon2Init( + password, + salt, + type, + opts + ); + // Pre-loop setup + // [address, input, zero_block] format so we can pass single U32 to block function + const address = new Uint32Array(3 * 256); + address[256 + 6] = mP; + address[256 + 8] = t; + address[256 + 10] = type; + for (let r = 0; r < t; r++) { + const needXor = r !== 0 && version === 0x13; + address[256 + 0] = r; + for (let s = 0; s < ARGON2_SYNC_POINTS; s++) { + address[256 + 4] = s; + const dataIndependent = type == AT.Argon2i || (type == AT.Argon2id && r === 0 && s < 2); + for (let l = 0; l < p; l++) { + address[256 + 2] = l; + address[256 + 12] = 0; + let startPos = 0; + if (r === 0 && s === 0) { + startPos = 2; + if (dataIndependent) { + address[256 + 12]++; + block(address, 256, 2 * 256, 0, false); + block(address, 0, 2 * 256, 0, false); + } + } + // current block postion + let offset = l * laneLen + s * segmentLen + startPos; + // previous block position + let prev = offset % laneLen ? offset - 1 : offset + laneLen - 1; + for (let index = startPos; index < segmentLen; index++, offset++, prev++) { + perBlock(); + processBlock( + B, + address, + l, + r, + s, + index, + laneLen, + segmentLen, + lanes, + offset, + prev, + dataIndependent, + needXor + ); + } + } + } + } + clean(address); + return argon2Output(B, p, laneLen, dkLen); +} + +/** argon2d GPU-resistant version. */ +export const argon2d = (password: KDFInput, salt: KDFInput, opts: ArgonOpts): Uint8Array => + argon2(AT.Argond2d, password, salt, opts); +/** argon2i side-channel-resistant version. */ +export const argon2i = (password: KDFInput, salt: KDFInput, opts: ArgonOpts): Uint8Array => + argon2(AT.Argon2i, password, salt, opts); +/** argon2id, combining i+d, the most popular version from RFC 9106 */ +export const argon2id = (password: KDFInput, salt: KDFInput, opts: ArgonOpts): Uint8Array => + argon2(AT.Argon2id, password, salt, opts); + +async function argon2Async(type: Types, password: KDFInput, salt: KDFInput, opts: ArgonOpts) { + const { mP, p, t, version, B, laneLen, lanes, segmentLen, dkLen, perBlock, asyncTick } = + argon2Init(password, salt, type, opts); + // Pre-loop setup + // [address, input, zero_block] format so we can pass single U32 to block function + const address = new Uint32Array(3 * 256); + address[256 + 6] = mP; + address[256 + 8] = t; + address[256 + 10] = type; + let ts = Date.now(); + for (let r = 0; r < t; r++) { + const needXor = r !== 0 && version === 0x13; + address[256 + 0] = r; + for (let s = 0; s < ARGON2_SYNC_POINTS; s++) { + address[256 + 4] = s; + const dataIndependent = type == AT.Argon2i || (type == AT.Argon2id && r === 0 && s < 2); + for (let l = 0; l < p; l++) { + address[256 + 2] = l; + address[256 + 12] = 0; + let startPos = 0; + if (r === 0 && s === 0) { + startPos = 2; + if (dataIndependent) { + address[256 + 12]++; + block(address, 256, 2 * 256, 0, false); + block(address, 0, 2 * 256, 0, false); + } + } + // current block postion + let offset = l * laneLen + s * segmentLen + startPos; + // previous block position + let prev = offset % laneLen ? offset - 1 : offset + laneLen - 1; + for (let index = startPos; index < segmentLen; index++, offset++, prev++) { + perBlock(); + processBlock( + B, + address, + l, + r, + s, + index, + laneLen, + segmentLen, + lanes, + offset, + prev, + dataIndependent, + needXor + ); + // Date.now() is not monotonic, so in case if clock goes backwards we return return control too + const diff = Date.now() - ts; + if (!(diff >= 0 && diff < asyncTick)) { + await nextTick(); + ts += diff; + } + } + } + } + } + clean(address); + return argon2Output(B, p, laneLen, dkLen); +} + +/** argon2d async GPU-resistant version. */ +export const argon2dAsync = ( + password: KDFInput, + salt: KDFInput, + opts: ArgonOpts +): Promise => argon2Async(AT.Argond2d, password, salt, opts); +/** argon2i async side-channel-resistant version. */ +export const argon2iAsync = ( + password: KDFInput, + salt: KDFInput, + opts: ArgonOpts +): Promise => argon2Async(AT.Argon2i, password, salt, opts); +/** argon2id async, combining i+d, the most popular version from RFC 9106 */ +export const argon2idAsync = ( + password: KDFInput, + salt: KDFInput, + opts: ArgonOpts +): Promise => argon2Async(AT.Argon2id, password, salt, opts); diff --git a/node_modules/@noble/hashes/src/blake1.ts b/node_modules/@noble/hashes/src/blake1.ts new file mode 100644 index 0000000000000000000000000000000000000000..d43ad268ff0340f247e4d827edf01bace8c8daf0 --- /dev/null +++ b/node_modules/@noble/hashes/src/blake1.ts @@ -0,0 +1,534 @@ +/** + * Blake1 legacy hash function, one of SHA3 proposals. + * Rarely used. Check out blake2 or blake3 instead. + * https://www.aumasson.jp/blake/blake.pdf + * + * In the best case, there are 0 allocations. + * + * Differences from blake2: + * + * - BE instead of LE + * - Paddings, similar to MD5, RIPEMD, SHA1, SHA2, but: + * - length flag is located before actual length + * - padding block is compressed differently (no lengths) + * Instead of msg[sigma[k]], we have `msg[sigma[k]] ^ constants[sigma[k-1]]` + * (-1 for g1, g2 without -1) + * - Salt is XOR-ed into constants instead of state + * - Salt is XOR-ed with output in `compress` + * - Additional rows (+64 bytes) in SIGMA for new rounds + * - Different round count: + * - 14 / 10 rounds in blake256 / blake2s + * - 16 / 12 rounds in blake512 / blake2b + * - blake512: G1b: rotr 24 -> 25, G2b: rotr 63 -> 11 + * @module + */ +import { BSIGMA, G1s, G2s } from './_blake.ts'; +import { setBigUint64, SHA224_IV, SHA256_IV, SHA384_IV, SHA512_IV } from './_md.ts'; +import * as u64 from './_u64.ts'; +// prettier-ignore +import { + abytes, aexists, aoutput, + clean, createOptHasher, + createView, Hash, toBytes, + type CHashO, type Input, +} from './utils.ts'; + +/** Blake1 options. Basically just "salt" */ +export type BlakeOpts = { + salt?: Uint8Array; +}; + +// Empty zero-filled salt +const EMPTY_SALT = /* @__PURE__ */ new Uint32Array(8); + +abstract class BLAKE1> extends Hash { + protected finished = false; + protected length = 0; + protected pos = 0; + protected destroyed = false; + // For partial updates less than block size + protected buffer: Uint8Array; + protected view: DataView; + protected salt: Uint32Array; + abstract compress(view: DataView, offset: number, withLength?: boolean): void; + protected abstract get(): number[]; + protected abstract set(...args: number[]): void; + + readonly blockLen: number; + readonly outputLen: number; + private lengthFlag: number; + private counterLen: number; + protected constants: Uint32Array; + + constructor( + blockLen: number, + outputLen: number, + lengthFlag: number, + counterLen: number, + saltLen: number, + constants: Uint32Array, + opts: BlakeOpts = {} + ) { + super(); + const { salt } = opts; + this.blockLen = blockLen; + this.outputLen = outputLen; + this.lengthFlag = lengthFlag; + this.counterLen = counterLen; + this.buffer = new Uint8Array(blockLen); + this.view = createView(this.buffer); + if (salt) { + let slt = salt; + slt = toBytes(slt); + abytes(slt); + if (slt.length !== 4 * saltLen) throw new Error('wrong salt length'); + const salt32 = (this.salt = new Uint32Array(saltLen)); + const sv = createView(slt); + this.constants = constants.slice(); + for (let i = 0, offset = 0; i < salt32.length; i++, offset += 4) { + salt32[i] = sv.getUint32(offset, false); + this.constants[i] ^= salt32[i]; + } + } else { + this.salt = EMPTY_SALT; + this.constants = constants; + } + } + update(data: Input): this { + aexists(this); + data = toBytes(data); + abytes(data); + // From _md, but update length before each compress + const { view, buffer, blockLen } = this; + const len = data.length; + let dataView; + for (let pos = 0; pos < len; ) { + const take = Math.min(blockLen - this.pos, len - pos); + // Fast path: we have at least one block in input, cast it to view and process + if (take === blockLen) { + if (!dataView) dataView = createView(data); + for (; blockLen <= len - pos; pos += blockLen) { + this.length += blockLen; + this.compress(dataView, pos); + } + continue; + } + buffer.set(data.subarray(pos, pos + take), this.pos); + this.pos += take; + pos += take; + if (this.pos === blockLen) { + this.length += blockLen; + this.compress(view, 0, true); + this.pos = 0; + } + } + return this; + } + destroy(): void { + this.destroyed = true; + if (this.salt !== EMPTY_SALT) { + clean(this.salt, this.constants); + } + } + _cloneInto(to?: T): T { + to ||= new (this.constructor as any)() as T; + to.set(...this.get()); + const { buffer, length, finished, destroyed, constants, salt, pos } = this; + to.buffer.set(buffer); + to.constants = constants.slice(); + to.destroyed = destroyed; + to.finished = finished; + to.length = length; + to.pos = pos; + to.salt = salt.slice(); + return to; + } + clone(): T { + return this._cloneInto(); + } + digestInto(out: Uint8Array): void { + aexists(this); + aoutput(out, this); + this.finished = true; + // Padding + const { buffer, blockLen, counterLen, lengthFlag, view } = this; + clean(buffer.subarray(this.pos)); // clean buf + const counter = BigInt((this.length + this.pos) * 8); + const counterPos = blockLen - counterLen - 1; + buffer[this.pos] |= 0b1000_0000; // End block flag + this.length += this.pos; // add unwritten length + // Not enough in buffer for length: write what we have. + if (this.pos > counterPos) { + this.compress(view, 0); + clean(buffer); + this.pos = 0; + } + // Difference with md: here we have lengthFlag! + buffer[counterPos] |= lengthFlag; // Length flag + // We always set 8 byte length flag. Because length will overflow significantly sooner. + setBigUint64(view, blockLen - 8, counter, false); + this.compress(view, 0, this.pos !== 0); // don't add length if length is not empty block? + // Write output + clean(buffer); + const v = createView(out); + const state = this.get(); + for (let i = 0; i < this.outputLen / 4; ++i) v.setUint32(i * 4, state[i]); + } + digest(): Uint8Array { + const { buffer, outputLen } = this; + this.digestInto(buffer); + const res = buffer.slice(0, outputLen); + this.destroy(); + return res; + } +} + +// Constants +const B64C = /* @__PURE__ */ Uint32Array.from([ + 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, + 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, + 0x9216d5d9, 0x8979fb1b, 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, 0xb8e1afed, 0x6a267e96, + 0xba7c9045, 0xf12c7f99, 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16, 0x636920d8, 0x71574e69, +]); +// first half of C512 +const B32C = B64C.slice(0, 16); + +const B256_IV = SHA256_IV.slice(); +const B224_IV = SHA224_IV.slice(); +const B384_IV = SHA384_IV.slice(); +const B512_IV = SHA512_IV.slice(); + +function generateTBL256() { + const TBL = []; + for (let i = 0, j = 0; i < 14; i++, j += 16) { + for (let offset = 1; offset < 16; offset += 2) { + TBL.push(B32C[BSIGMA[j + offset]]); + TBL.push(B32C[BSIGMA[j + offset - 1]]); + } + } + return new Uint32Array(TBL); +} +const TBL256 = /* @__PURE__ */ generateTBL256(); // C256[SIGMA[X]] precompute + +// Reusable temporary buffer +const BLAKE256_W = /* @__PURE__ */ new Uint32Array(16); + +class Blake1_32 extends BLAKE1 { + private v0: number; + private v1: number; + private v2: number; + private v3: number; + private v4: number; + private v5: number; + private v6: number; + private v7: number; + constructor(outputLen: number, IV: Uint32Array, lengthFlag: number, opts: BlakeOpts = {}) { + super(64, outputLen, lengthFlag, 8, 4, B32C, opts); + this.v0 = IV[0] | 0; + this.v1 = IV[1] | 0; + this.v2 = IV[2] | 0; + this.v3 = IV[3] | 0; + this.v4 = IV[4] | 0; + this.v5 = IV[5] | 0; + this.v6 = IV[6] | 0; + this.v7 = IV[7] | 0; + } + protected get(): [number, number, number, number, number, number, number, number] { + const { v0, v1, v2, v3, v4, v5, v6, v7 } = this; + return [v0, v1, v2, v3, v4, v5, v6, v7]; + } + // prettier-ignore + protected set( + v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number + ): void { + this.v0 = v0 | 0; + this.v1 = v1 | 0; + this.v2 = v2 | 0; + this.v3 = v3 | 0; + this.v4 = v4 | 0; + this.v5 = v5 | 0; + this.v6 = v6 | 0; + this.v7 = v7 | 0; + } + destroy(): void { + super.destroy(); + this.set(0, 0, 0, 0, 0, 0, 0, 0); + } + compress(view: DataView, offset: number, withLength = true): void { + for (let i = 0; i < 16; i++, offset += 4) BLAKE256_W[i] = view.getUint32(offset, false); + // NOTE: we cannot re-use compress from blake2s, since there is additional xor over u256[SIGMA[e]] + let v00 = this.v0 | 0; + let v01 = this.v1 | 0; + let v02 = this.v2 | 0; + let v03 = this.v3 | 0; + let v04 = this.v4 | 0; + let v05 = this.v5 | 0; + let v06 = this.v6 | 0; + let v07 = this.v7 | 0; + let v08 = this.constants[0] | 0; + let v09 = this.constants[1] | 0; + let v10 = this.constants[2] | 0; + let v11 = this.constants[3] | 0; + const { h, l } = u64.fromBig(BigInt(withLength ? this.length * 8 : 0)); + let v12 = (this.constants[4] ^ l) >>> 0; + let v13 = (this.constants[5] ^ l) >>> 0; + let v14 = (this.constants[6] ^ h) >>> 0; + let v15 = (this.constants[7] ^ h) >>> 0; + // prettier-ignore + for (let i = 0, k = 0, j = 0; i < 14; i++) { + ({ a: v00, b: v04, c: v08, d: v12 } = G1s(v00, v04, v08, v12, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v00, b: v04, c: v08, d: v12 } = G2s(v00, v04, v08, v12, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v01, b: v05, c: v09, d: v13 } = G1s(v01, v05, v09, v13, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v01, b: v05, c: v09, d: v13 } = G2s(v01, v05, v09, v13, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v02, b: v06, c: v10, d: v14 } = G1s(v02, v06, v10, v14, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v02, b: v06, c: v10, d: v14 } = G2s(v02, v06, v10, v14, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v03, b: v07, c: v11, d: v15 } = G1s(v03, v07, v11, v15, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v03, b: v07, c: v11, d: v15 } = G2s(v03, v07, v11, v15, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v00, b: v05, c: v10, d: v15 } = G1s(v00, v05, v10, v15, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v00, b: v05, c: v10, d: v15 } = G2s(v00, v05, v10, v15, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v01, b: v06, c: v11, d: v12 } = G1s(v01, v06, v11, v12, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v01, b: v06, c: v11, d: v12 } = G2s(v01, v06, v11, v12, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v02, b: v07, c: v08, d: v13 } = G1s(v02, v07, v08, v13, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v02, b: v07, c: v08, d: v13 } = G2s(v02, v07, v08, v13, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v03, b: v04, c: v09, d: v14 } = G1s(v03, v04, v09, v14, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + ({ a: v03, b: v04, c: v09, d: v14 } = G2s(v03, v04, v09, v14, BLAKE256_W[BSIGMA[k++]] ^ TBL256[j++])); + } + this.v0 = (this.v0 ^ v00 ^ v08 ^ this.salt[0]) >>> 0; + this.v1 = (this.v1 ^ v01 ^ v09 ^ this.salt[1]) >>> 0; + this.v2 = (this.v2 ^ v02 ^ v10 ^ this.salt[2]) >>> 0; + this.v3 = (this.v3 ^ v03 ^ v11 ^ this.salt[3]) >>> 0; + this.v4 = (this.v4 ^ v04 ^ v12 ^ this.salt[0]) >>> 0; + this.v5 = (this.v5 ^ v05 ^ v13 ^ this.salt[1]) >>> 0; + this.v6 = (this.v6 ^ v06 ^ v14 ^ this.salt[2]) >>> 0; + this.v7 = (this.v7 ^ v07 ^ v15 ^ this.salt[3]) >>> 0; + clean(BLAKE256_W); + } +} + +const BBUF = /* @__PURE__ */ new Uint32Array(32); +const BLAKE512_W = /* @__PURE__ */ new Uint32Array(32); + +function generateTBL512() { + const TBL = []; + for (let r = 0, k = 0; r < 16; r++, k += 16) { + for (let offset = 1; offset < 16; offset += 2) { + TBL.push(B64C[BSIGMA[k + offset] * 2 + 0]); + TBL.push(B64C[BSIGMA[k + offset] * 2 + 1]); + TBL.push(B64C[BSIGMA[k + offset - 1] * 2 + 0]); + TBL.push(B64C[BSIGMA[k + offset - 1] * 2 + 1]); + } + } + return new Uint32Array(TBL); +} +const TBL512 = /* @__PURE__ */ generateTBL512(); // C512[SIGMA[X]] precompute + +// Mixing function G splitted in two halfs +function G1b(a: number, b: number, c: number, d: number, msg: Uint32Array, k: number) { + const Xpos = 2 * BSIGMA[k]; + const Xl = msg[Xpos + 1] ^ TBL512[k * 2 + 1], Xh = msg[Xpos] ^ TBL512[k * 2]; // prettier-ignore + let Al = BBUF[2 * a + 1], Ah = BBUF[2 * a]; // prettier-ignore + let Bl = BBUF[2 * b + 1], Bh = BBUF[2 * b]; // prettier-ignore + let Cl = BBUF[2 * c + 1], Ch = BBUF[2 * c]; // prettier-ignore + let Dl = BBUF[2 * d + 1], Dh = BBUF[2 * d]; // prettier-ignore + // v[a] = (v[a] + v[b] + x) | 0; + let ll = u64.add3L(Al, Bl, Xl); + Ah = u64.add3H(ll, Ah, Bh, Xh) >>> 0; + Al = (ll | 0) >>> 0; + // v[d] = rotr(v[d] ^ v[a], 32) + ({ Dh, Dl } = { Dh: Dh ^ Ah, Dl: Dl ^ Al }); + ({ Dh, Dl } = { Dh: u64.rotr32H(Dh, Dl), Dl: u64.rotr32L(Dh, Dl) }); + // v[c] = (v[c] + v[d]) | 0; + ({ h: Ch, l: Cl } = u64.add(Ch, Cl, Dh, Dl)); + // v[b] = rotr(v[b] ^ v[c], 25) + ({ Bh, Bl } = { Bh: Bh ^ Ch, Bl: Bl ^ Cl }); + ({ Bh, Bl } = { Bh: u64.rotrSH(Bh, Bl, 25), Bl: u64.rotrSL(Bh, Bl, 25) }); + (BBUF[2 * a + 1] = Al), (BBUF[2 * a] = Ah); + (BBUF[2 * b + 1] = Bl), (BBUF[2 * b] = Bh); + (BBUF[2 * c + 1] = Cl), (BBUF[2 * c] = Ch); + (BBUF[2 * d + 1] = Dl), (BBUF[2 * d] = Dh); +} + +function G2b(a: number, b: number, c: number, d: number, msg: Uint32Array, k: number) { + const Xpos = 2 * BSIGMA[k]; + const Xl = msg[Xpos + 1] ^ TBL512[k * 2 + 1], Xh = msg[Xpos] ^ TBL512[k * 2]; // prettier-ignore + let Al = BBUF[2 * a + 1], Ah = BBUF[2 * a]; // prettier-ignore + let Bl = BBUF[2 * b + 1], Bh = BBUF[2 * b]; // prettier-ignore + let Cl = BBUF[2 * c + 1], Ch = BBUF[2 * c]; // prettier-ignore + let Dl = BBUF[2 * d + 1], Dh = BBUF[2 * d]; // prettier-ignore + // v[a] = (v[a] + v[b] + x) | 0; + let ll = u64.add3L(Al, Bl, Xl); + Ah = u64.add3H(ll, Ah, Bh, Xh); + Al = ll | 0; + // v[d] = rotr(v[d] ^ v[a], 16) + ({ Dh, Dl } = { Dh: Dh ^ Ah, Dl: Dl ^ Al }); + ({ Dh, Dl } = { Dh: u64.rotrSH(Dh, Dl, 16), Dl: u64.rotrSL(Dh, Dl, 16) }); + // v[c] = (v[c] + v[d]) | 0; + ({ h: Ch, l: Cl } = u64.add(Ch, Cl, Dh, Dl)); + // v[b] = rotr(v[b] ^ v[c], 11) + ({ Bh, Bl } = { Bh: Bh ^ Ch, Bl: Bl ^ Cl }); + ({ Bh, Bl } = { Bh: u64.rotrSH(Bh, Bl, 11), Bl: u64.rotrSL(Bh, Bl, 11) }); + (BBUF[2 * a + 1] = Al), (BBUF[2 * a] = Ah); + (BBUF[2 * b + 1] = Bl), (BBUF[2 * b] = Bh); + (BBUF[2 * c + 1] = Cl), (BBUF[2 * c] = Ch); + (BBUF[2 * d + 1] = Dl), (BBUF[2 * d] = Dh); +} + +class Blake1_64 extends BLAKE1 { + private v0l: number; + private v0h: number; + private v1l: number; + private v1h: number; + private v2l: number; + private v2h: number; + private v3l: number; + private v3h: number; + private v4l: number; + private v4h: number; + private v5l: number; + private v5h: number; + private v6l: number; + private v6h: number; + private v7l: number; + private v7h: number; + constructor(outputLen: number, IV: Uint32Array, lengthFlag: number, opts: BlakeOpts = {}) { + super(128, outputLen, lengthFlag, 16, 8, B64C, opts); + this.v0l = IV[0] | 0; + this.v0h = IV[1] | 0; + this.v1l = IV[2] | 0; + this.v1h = IV[3] | 0; + this.v2l = IV[4] | 0; + this.v2h = IV[5] | 0; + this.v3l = IV[6] | 0; + this.v3h = IV[7] | 0; + this.v4l = IV[8] | 0; + this.v4h = IV[9] | 0; + this.v5l = IV[10] | 0; + this.v5h = IV[11] | 0; + this.v6l = IV[12] | 0; + this.v6h = IV[13] | 0; + this.v7l = IV[14] | 0; + this.v7h = IV[15] | 0; + } + // prettier-ignore + protected get(): [ + number, number, number, number, number, number, number, number, + number, number, number, number, number, number, number, number + ] { + let { v0l, v0h, v1l, v1h, v2l, v2h, v3l, v3h, v4l, v4h, v5l, v5h, v6l, v6h, v7l, v7h } = this; + return [v0l, v0h, v1l, v1h, v2l, v2h, v3l, v3h, v4l, v4h, v5l, v5h, v6l, v6h, v7l, v7h]; + } + // prettier-ignore + protected set( + v0l: number, v0h: number, v1l: number, v1h: number, + v2l: number, v2h: number, v3l: number, v3h: number, + v4l: number, v4h: number, v5l: number, v5h: number, + v6l: number, v6h: number, v7l: number, v7h: number + ): void { + this.v0l = v0l | 0; + this.v0h = v0h | 0; + this.v1l = v1l | 0; + this.v1h = v1h | 0; + this.v2l = v2l | 0; + this.v2h = v2h | 0; + this.v3l = v3l | 0; + this.v3h = v3h | 0; + this.v4l = v4l | 0; + this.v4h = v4h | 0; + this.v5l = v5l | 0; + this.v5h = v5h | 0; + this.v6l = v6l | 0; + this.v6h = v6h | 0; + this.v7l = v7l | 0; + this.v7h = v7h | 0; + } + destroy(): void { + super.destroy(); + this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + } + compress(view: DataView, offset: number, withLength = true): void { + for (let i = 0; i < 32; i++, offset += 4) BLAKE512_W[i] = view.getUint32(offset, false); + + this.get().forEach((v, i) => (BBUF[i] = v)); // First half from state. + BBUF.set(this.constants.subarray(0, 16), 16); + if (withLength) { + const { h, l } = u64.fromBig(BigInt(this.length * 8)); + BBUF[24] = (BBUF[24] ^ h) >>> 0; + BBUF[25] = (BBUF[25] ^ l) >>> 0; + BBUF[26] = (BBUF[26] ^ h) >>> 0; + BBUF[27] = (BBUF[27] ^ l) >>> 0; + } + for (let i = 0, k = 0; i < 16; i++) { + G1b(0, 4, 8, 12, BLAKE512_W, k++); + G2b(0, 4, 8, 12, BLAKE512_W, k++); + G1b(1, 5, 9, 13, BLAKE512_W, k++); + G2b(1, 5, 9, 13, BLAKE512_W, k++); + G1b(2, 6, 10, 14, BLAKE512_W, k++); + G2b(2, 6, 10, 14, BLAKE512_W, k++); + G1b(3, 7, 11, 15, BLAKE512_W, k++); + G2b(3, 7, 11, 15, BLAKE512_W, k++); + + G1b(0, 5, 10, 15, BLAKE512_W, k++); + G2b(0, 5, 10, 15, BLAKE512_W, k++); + G1b(1, 6, 11, 12, BLAKE512_W, k++); + G2b(1, 6, 11, 12, BLAKE512_W, k++); + G1b(2, 7, 8, 13, BLAKE512_W, k++); + G2b(2, 7, 8, 13, BLAKE512_W, k++); + G1b(3, 4, 9, 14, BLAKE512_W, k++); + G2b(3, 4, 9, 14, BLAKE512_W, k++); + } + this.v0l ^= BBUF[0] ^ BBUF[16] ^ this.salt[0]; + this.v0h ^= BBUF[1] ^ BBUF[17] ^ this.salt[1]; + this.v1l ^= BBUF[2] ^ BBUF[18] ^ this.salt[2]; + this.v1h ^= BBUF[3] ^ BBUF[19] ^ this.salt[3]; + this.v2l ^= BBUF[4] ^ BBUF[20] ^ this.salt[4]; + this.v2h ^= BBUF[5] ^ BBUF[21] ^ this.salt[5]; + this.v3l ^= BBUF[6] ^ BBUF[22] ^ this.salt[6]; + this.v3h ^= BBUF[7] ^ BBUF[23] ^ this.salt[7]; + this.v4l ^= BBUF[8] ^ BBUF[24] ^ this.salt[0]; + this.v4h ^= BBUF[9] ^ BBUF[25] ^ this.salt[1]; + this.v5l ^= BBUF[10] ^ BBUF[26] ^ this.salt[2]; + this.v5h ^= BBUF[11] ^ BBUF[27] ^ this.salt[3]; + this.v6l ^= BBUF[12] ^ BBUF[28] ^ this.salt[4]; + this.v6h ^= BBUF[13] ^ BBUF[29] ^ this.salt[5]; + this.v7l ^= BBUF[14] ^ BBUF[30] ^ this.salt[6]; + this.v7h ^= BBUF[15] ^ BBUF[31] ^ this.salt[7]; + clean(BBUF, BLAKE512_W); + } +} + +export class BLAKE224 extends Blake1_32 { + constructor(opts: BlakeOpts = {}) { + super(28, B224_IV, 0b0000_0000, opts); + } +} +export class BLAKE256 extends Blake1_32 { + constructor(opts: BlakeOpts = {}) { + super(32, B256_IV, 0b0000_0001, opts); + } +} +export class BLAKE384 extends Blake1_64 { + constructor(opts: BlakeOpts = {}) { + super(48, B384_IV, 0b0000_0000, opts); + } +} +export class BLAKE512 extends Blake1_64 { + constructor(opts: BlakeOpts = {}) { + super(64, B512_IV, 0b0000_0001, opts); + } +} +/** blake1-224 hash function */ +export const blake224: CHashO = /* @__PURE__ */ createOptHasher( + (opts) => new BLAKE224(opts) +); +/** blake1-256 hash function */ +export const blake256: CHashO = /* @__PURE__ */ createOptHasher( + (opts) => new BLAKE256(opts) +); +/** blake1-384 hash function */ +export const blake384: CHashO = /* @__PURE__ */ createOptHasher( + (opts) => new BLAKE384(opts) +); +/** blake1-512 hash function */ +export const blake512: CHashO = /* @__PURE__ */ createOptHasher( + (opts) => new BLAKE512(opts) +); diff --git a/node_modules/@noble/hashes/src/blake2.ts b/node_modules/@noble/hashes/src/blake2.ts new file mode 100644 index 0000000000000000000000000000000000000000..3f8509fa5cc11599cc051e341ad2bb8db8070bea --- /dev/null +++ b/node_modules/@noble/hashes/src/blake2.ts @@ -0,0 +1,486 @@ +/** + * blake2b (64-bit) & blake2s (8 to 32-bit) hash functions. + * b could have been faster, but there is no fast u64 in js, so s is 1.5x faster. + * @module + */ +import { BSIGMA, G1s, G2s } from './_blake.ts'; +import { SHA256_IV } from './_md.ts'; +import * as u64 from './_u64.ts'; +// prettier-ignore +import { + abytes, aexists, anumber, aoutput, + clean, createOptHasher, Hash, swap32IfBE, swap8IfBE, toBytes, u32, + type CHashO, type Input +} from './utils.ts'; + +/** Blake hash options. dkLen is output length. key is used in MAC mode. salt is used in KDF mode. */ +export type Blake2Opts = { + dkLen?: number; + key?: Input; + salt?: Input; + personalization?: Input; +}; + +// Same as SHA512_IV, but swapped endianness: LE instead of BE. iv[1] is iv[0], etc. +const B2B_IV = /* @__PURE__ */ Uint32Array.from([ + 0xf3bcc908, 0x6a09e667, 0x84caa73b, 0xbb67ae85, 0xfe94f82b, 0x3c6ef372, 0x5f1d36f1, 0xa54ff53a, + 0xade682d1, 0x510e527f, 0x2b3e6c1f, 0x9b05688c, 0xfb41bd6b, 0x1f83d9ab, 0x137e2179, 0x5be0cd19, +]); +// Temporary buffer +const BBUF = /* @__PURE__ */ new Uint32Array(32); + +// Mixing function G splitted in two halfs +function G1b(a: number, b: number, c: number, d: number, msg: Uint32Array, x: number) { + // NOTE: V is LE here + const Xl = msg[x], Xh = msg[x + 1]; // prettier-ignore + let Al = BBUF[2 * a], Ah = BBUF[2 * a + 1]; // prettier-ignore + let Bl = BBUF[2 * b], Bh = BBUF[2 * b + 1]; // prettier-ignore + let Cl = BBUF[2 * c], Ch = BBUF[2 * c + 1]; // prettier-ignore + let Dl = BBUF[2 * d], Dh = BBUF[2 * d + 1]; // prettier-ignore + // v[a] = (v[a] + v[b] + x) | 0; + let ll = u64.add3L(Al, Bl, Xl); + Ah = u64.add3H(ll, Ah, Bh, Xh); + Al = ll | 0; + // v[d] = rotr(v[d] ^ v[a], 32) + ({ Dh, Dl } = { Dh: Dh ^ Ah, Dl: Dl ^ Al }); + ({ Dh, Dl } = { Dh: u64.rotr32H(Dh, Dl), Dl: u64.rotr32L(Dh, Dl) }); + // v[c] = (v[c] + v[d]) | 0; + ({ h: Ch, l: Cl } = u64.add(Ch, Cl, Dh, Dl)); + // v[b] = rotr(v[b] ^ v[c], 24) + ({ Bh, Bl } = { Bh: Bh ^ Ch, Bl: Bl ^ Cl }); + ({ Bh, Bl } = { Bh: u64.rotrSH(Bh, Bl, 24), Bl: u64.rotrSL(Bh, Bl, 24) }); + (BBUF[2 * a] = Al), (BBUF[2 * a + 1] = Ah); + (BBUF[2 * b] = Bl), (BBUF[2 * b + 1] = Bh); + (BBUF[2 * c] = Cl), (BBUF[2 * c + 1] = Ch); + (BBUF[2 * d] = Dl), (BBUF[2 * d + 1] = Dh); +} + +function G2b(a: number, b: number, c: number, d: number, msg: Uint32Array, x: number) { + // NOTE: V is LE here + const Xl = msg[x], Xh = msg[x + 1]; // prettier-ignore + let Al = BBUF[2 * a], Ah = BBUF[2 * a + 1]; // prettier-ignore + let Bl = BBUF[2 * b], Bh = BBUF[2 * b + 1]; // prettier-ignore + let Cl = BBUF[2 * c], Ch = BBUF[2 * c + 1]; // prettier-ignore + let Dl = BBUF[2 * d], Dh = BBUF[2 * d + 1]; // prettier-ignore + // v[a] = (v[a] + v[b] + x) | 0; + let ll = u64.add3L(Al, Bl, Xl); + Ah = u64.add3H(ll, Ah, Bh, Xh); + Al = ll | 0; + // v[d] = rotr(v[d] ^ v[a], 16) + ({ Dh, Dl } = { Dh: Dh ^ Ah, Dl: Dl ^ Al }); + ({ Dh, Dl } = { Dh: u64.rotrSH(Dh, Dl, 16), Dl: u64.rotrSL(Dh, Dl, 16) }); + // v[c] = (v[c] + v[d]) | 0; + ({ h: Ch, l: Cl } = u64.add(Ch, Cl, Dh, Dl)); + // v[b] = rotr(v[b] ^ v[c], 63) + ({ Bh, Bl } = { Bh: Bh ^ Ch, Bl: Bl ^ Cl }); + ({ Bh, Bl } = { Bh: u64.rotrBH(Bh, Bl, 63), Bl: u64.rotrBL(Bh, Bl, 63) }); + (BBUF[2 * a] = Al), (BBUF[2 * a + 1] = Ah); + (BBUF[2 * b] = Bl), (BBUF[2 * b + 1] = Bh); + (BBUF[2 * c] = Cl), (BBUF[2 * c + 1] = Ch); + (BBUF[2 * d] = Dl), (BBUF[2 * d + 1] = Dh); +} + +function checkBlake2Opts( + outputLen: number, + opts: Blake2Opts | undefined = {}, + keyLen: number, + saltLen: number, + persLen: number +) { + anumber(keyLen); + if (outputLen < 0 || outputLen > keyLen) throw new Error('outputLen bigger than keyLen'); + const { key, salt, personalization } = opts; + if (key !== undefined && (key.length < 1 || key.length > keyLen)) + throw new Error('key length must be undefined or 1..' + keyLen); + if (salt !== undefined && salt.length !== saltLen) + throw new Error('salt must be undefined or ' + saltLen); + if (personalization !== undefined && personalization.length !== persLen) + throw new Error('personalization must be undefined or ' + persLen); +} + +/** Class, from which others are subclassed. */ +export abstract class BLAKE2> extends Hash { + protected abstract compress(msg: Uint32Array, offset: number, isLast: boolean): void; + protected abstract get(): number[]; + protected abstract set(...args: number[]): void; + abstract destroy(): void; + protected buffer: Uint8Array; + protected buffer32: Uint32Array; + protected finished = false; + protected destroyed = false; + protected length: number = 0; + protected pos: number = 0; + readonly blockLen: number; + readonly outputLen: number; + + constructor(blockLen: number, outputLen: number) { + super(); + anumber(blockLen); + anumber(outputLen); + this.blockLen = blockLen; + this.outputLen = outputLen; + this.buffer = new Uint8Array(blockLen); + this.buffer32 = u32(this.buffer); + } + update(data: Input): this { + aexists(this); + data = toBytes(data); + abytes(data); + // Main difference with other hashes: there is flag for last block, + // so we cannot process current block before we know that there + // is the next one. This significantly complicates logic and reduces ability + // to do zero-copy processing + const { blockLen, buffer, buffer32 } = this; + const len = data.length; + const offset = data.byteOffset; + const buf = data.buffer; + for (let pos = 0; pos < len; ) { + // If buffer is full and we still have input (don't process last block, same as blake2s) + if (this.pos === blockLen) { + swap32IfBE(buffer32); + this.compress(buffer32, 0, false); + swap32IfBE(buffer32); + this.pos = 0; + } + const take = Math.min(blockLen - this.pos, len - pos); + const dataOffset = offset + pos; + // full block && aligned to 4 bytes && not last in input + if (take === blockLen && !(dataOffset % 4) && pos + take < len) { + const data32 = new Uint32Array(buf, dataOffset, Math.floor((len - pos) / 4)); + swap32IfBE(data32); + for (let pos32 = 0; pos + blockLen < len; pos32 += buffer32.length, pos += blockLen) { + this.length += blockLen; + this.compress(data32, pos32, false); + } + swap32IfBE(data32); + continue; + } + buffer.set(data.subarray(pos, pos + take), this.pos); + this.pos += take; + this.length += take; + pos += take; + } + return this; + } + digestInto(out: Uint8Array): void { + aexists(this); + aoutput(out, this); + const { pos, buffer32 } = this; + this.finished = true; + // Padding + clean(this.buffer.subarray(pos)); + swap32IfBE(buffer32); + this.compress(buffer32, 0, true); + swap32IfBE(buffer32); + const out32 = u32(out); + this.get().forEach((v, i) => (out32[i] = swap8IfBE(v))); + } + digest(): Uint8Array { + const { buffer, outputLen } = this; + this.digestInto(buffer); + const res = buffer.slice(0, outputLen); + this.destroy(); + return res; + } + _cloneInto(to?: T): T { + const { buffer, length, finished, destroyed, outputLen, pos } = this; + to ||= new (this.constructor as any)({ dkLen: outputLen }) as T; + to.set(...this.get()); + to.buffer.set(buffer); + to.destroyed = destroyed; + to.finished = finished; + to.length = length; + to.pos = pos; + // @ts-ignore + to.outputLen = outputLen; + return to; + } + clone(): T { + return this._cloneInto(); + } +} + +export class BLAKE2b extends BLAKE2 { + // Same as SHA-512, but LE + private v0l = B2B_IV[0] | 0; + private v0h = B2B_IV[1] | 0; + private v1l = B2B_IV[2] | 0; + private v1h = B2B_IV[3] | 0; + private v2l = B2B_IV[4] | 0; + private v2h = B2B_IV[5] | 0; + private v3l = B2B_IV[6] | 0; + private v3h = B2B_IV[7] | 0; + private v4l = B2B_IV[8] | 0; + private v4h = B2B_IV[9] | 0; + private v5l = B2B_IV[10] | 0; + private v5h = B2B_IV[11] | 0; + private v6l = B2B_IV[12] | 0; + private v6h = B2B_IV[13] | 0; + private v7l = B2B_IV[14] | 0; + private v7h = B2B_IV[15] | 0; + + constructor(opts: Blake2Opts = {}) { + const olen = opts.dkLen === undefined ? 64 : opts.dkLen; + super(128, olen); + checkBlake2Opts(olen, opts, 64, 16, 16); + let { key, personalization, salt } = opts; + let keyLength = 0; + if (key !== undefined) { + key = toBytes(key); + keyLength = key.length; + } + this.v0l ^= this.outputLen | (keyLength << 8) | (0x01 << 16) | (0x01 << 24); + if (salt !== undefined) { + salt = toBytes(salt); + const slt = u32(salt); + this.v4l ^= swap8IfBE(slt[0]); + this.v4h ^= swap8IfBE(slt[1]); + this.v5l ^= swap8IfBE(slt[2]); + this.v5h ^= swap8IfBE(slt[3]); + } + if (personalization !== undefined) { + personalization = toBytes(personalization); + const pers = u32(personalization); + this.v6l ^= swap8IfBE(pers[0]); + this.v6h ^= swap8IfBE(pers[1]); + this.v7l ^= swap8IfBE(pers[2]); + this.v7h ^= swap8IfBE(pers[3]); + } + if (key !== undefined) { + // Pad to blockLen and update + const tmp = new Uint8Array(this.blockLen); + tmp.set(key); + this.update(tmp); + } + } + // prettier-ignore + protected get(): [ + number, number, number, number, number, number, number, number, + number, number, number, number, number, number, number, number + ] { + let { v0l, v0h, v1l, v1h, v2l, v2h, v3l, v3h, v4l, v4h, v5l, v5h, v6l, v6h, v7l, v7h } = this; + return [v0l, v0h, v1l, v1h, v2l, v2h, v3l, v3h, v4l, v4h, v5l, v5h, v6l, v6h, v7l, v7h]; + } + // prettier-ignore + protected set( + v0l: number, v0h: number, v1l: number, v1h: number, + v2l: number, v2h: number, v3l: number, v3h: number, + v4l: number, v4h: number, v5l: number, v5h: number, + v6l: number, v6h: number, v7l: number, v7h: number + ): void { + this.v0l = v0l | 0; + this.v0h = v0h | 0; + this.v1l = v1l | 0; + this.v1h = v1h | 0; + this.v2l = v2l | 0; + this.v2h = v2h | 0; + this.v3l = v3l | 0; + this.v3h = v3h | 0; + this.v4l = v4l | 0; + this.v4h = v4h | 0; + this.v5l = v5l | 0; + this.v5h = v5h | 0; + this.v6l = v6l | 0; + this.v6h = v6h | 0; + this.v7l = v7l | 0; + this.v7h = v7h | 0; + } + protected compress(msg: Uint32Array, offset: number, isLast: boolean): void { + this.get().forEach((v, i) => (BBUF[i] = v)); // First half from state. + BBUF.set(B2B_IV, 16); // Second half from IV. + let { h, l } = u64.fromBig(BigInt(this.length)); + BBUF[24] = B2B_IV[8] ^ l; // Low word of the offset. + BBUF[25] = B2B_IV[9] ^ h; // High word. + // Invert all bits for last block + if (isLast) { + BBUF[28] = ~BBUF[28]; + BBUF[29] = ~BBUF[29]; + } + let j = 0; + const s = BSIGMA; + for (let i = 0; i < 12; i++) { + G1b(0, 4, 8, 12, msg, offset + 2 * s[j++]); + G2b(0, 4, 8, 12, msg, offset + 2 * s[j++]); + G1b(1, 5, 9, 13, msg, offset + 2 * s[j++]); + G2b(1, 5, 9, 13, msg, offset + 2 * s[j++]); + G1b(2, 6, 10, 14, msg, offset + 2 * s[j++]); + G2b(2, 6, 10, 14, msg, offset + 2 * s[j++]); + G1b(3, 7, 11, 15, msg, offset + 2 * s[j++]); + G2b(3, 7, 11, 15, msg, offset + 2 * s[j++]); + + G1b(0, 5, 10, 15, msg, offset + 2 * s[j++]); + G2b(0, 5, 10, 15, msg, offset + 2 * s[j++]); + G1b(1, 6, 11, 12, msg, offset + 2 * s[j++]); + G2b(1, 6, 11, 12, msg, offset + 2 * s[j++]); + G1b(2, 7, 8, 13, msg, offset + 2 * s[j++]); + G2b(2, 7, 8, 13, msg, offset + 2 * s[j++]); + G1b(3, 4, 9, 14, msg, offset + 2 * s[j++]); + G2b(3, 4, 9, 14, msg, offset + 2 * s[j++]); + } + this.v0l ^= BBUF[0] ^ BBUF[16]; + this.v0h ^= BBUF[1] ^ BBUF[17]; + this.v1l ^= BBUF[2] ^ BBUF[18]; + this.v1h ^= BBUF[3] ^ BBUF[19]; + this.v2l ^= BBUF[4] ^ BBUF[20]; + this.v2h ^= BBUF[5] ^ BBUF[21]; + this.v3l ^= BBUF[6] ^ BBUF[22]; + this.v3h ^= BBUF[7] ^ BBUF[23]; + this.v4l ^= BBUF[8] ^ BBUF[24]; + this.v4h ^= BBUF[9] ^ BBUF[25]; + this.v5l ^= BBUF[10] ^ BBUF[26]; + this.v5h ^= BBUF[11] ^ BBUF[27]; + this.v6l ^= BBUF[12] ^ BBUF[28]; + this.v6h ^= BBUF[13] ^ BBUF[29]; + this.v7l ^= BBUF[14] ^ BBUF[30]; + this.v7h ^= BBUF[15] ^ BBUF[31]; + clean(BBUF); + } + destroy(): void { + this.destroyed = true; + clean(this.buffer32); + this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + } +} + +/** + * Blake2b hash function. 64-bit. 1.5x slower than blake2s in JS. + * @param msg - message that would be hashed + * @param opts - dkLen output length, key for MAC mode, salt, personalization + */ +export const blake2b: CHashO = /* @__PURE__ */ createOptHasher( + (opts) => new BLAKE2b(opts) +); + +// ================= +// Blake2S +// ================= + +// prettier-ignore +export type Num16 = { + v0: number; v1: number; v2: number; v3: number; + v4: number; v5: number; v6: number; v7: number; + v8: number; v9: number; v10: number; v11: number; + v12: number; v13: number; v14: number; v15: number; +}; + +// prettier-ignore +export function compress(s: Uint8Array, offset: number, msg: Uint32Array, rounds: number, + v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, + v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, +): Num16 { + let j = 0; + for (let i = 0; i < rounds; i++) { + ({ a: v0, b: v4, c: v8, d: v12 } = G1s(v0, v4, v8, v12, msg[offset + s[j++]])); + ({ a: v0, b: v4, c: v8, d: v12 } = G2s(v0, v4, v8, v12, msg[offset + s[j++]])); + ({ a: v1, b: v5, c: v9, d: v13 } = G1s(v1, v5, v9, v13, msg[offset + s[j++]])); + ({ a: v1, b: v5, c: v9, d: v13 } = G2s(v1, v5, v9, v13, msg[offset + s[j++]])); + ({ a: v2, b: v6, c: v10, d: v14 } = G1s(v2, v6, v10, v14, msg[offset + s[j++]])); + ({ a: v2, b: v6, c: v10, d: v14 } = G2s(v2, v6, v10, v14, msg[offset + s[j++]])); + ({ a: v3, b: v7, c: v11, d: v15 } = G1s(v3, v7, v11, v15, msg[offset + s[j++]])); + ({ a: v3, b: v7, c: v11, d: v15 } = G2s(v3, v7, v11, v15, msg[offset + s[j++]])); + + ({ a: v0, b: v5, c: v10, d: v15 } = G1s(v0, v5, v10, v15, msg[offset + s[j++]])); + ({ a: v0, b: v5, c: v10, d: v15 } = G2s(v0, v5, v10, v15, msg[offset + s[j++]])); + ({ a: v1, b: v6, c: v11, d: v12 } = G1s(v1, v6, v11, v12, msg[offset + s[j++]])); + ({ a: v1, b: v6, c: v11, d: v12 } = G2s(v1, v6, v11, v12, msg[offset + s[j++]])); + ({ a: v2, b: v7, c: v8, d: v13 } = G1s(v2, v7, v8, v13, msg[offset + s[j++]])); + ({ a: v2, b: v7, c: v8, d: v13 } = G2s(v2, v7, v8, v13, msg[offset + s[j++]])); + ({ a: v3, b: v4, c: v9, d: v14 } = G1s(v3, v4, v9, v14, msg[offset + s[j++]])); + ({ a: v3, b: v4, c: v9, d: v14 } = G2s(v3, v4, v9, v14, msg[offset + s[j++]])); + } + return { v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15 }; +} + +const B2S_IV = SHA256_IV; +export class BLAKE2s extends BLAKE2 { + // Internal state, same as SHA-256 + private v0 = B2S_IV[0] | 0; + private v1 = B2S_IV[1] | 0; + private v2 = B2S_IV[2] | 0; + private v3 = B2S_IV[3] | 0; + private v4 = B2S_IV[4] | 0; + private v5 = B2S_IV[5] | 0; + private v6 = B2S_IV[6] | 0; + private v7 = B2S_IV[7] | 0; + + constructor(opts: Blake2Opts = {}) { + const olen = opts.dkLen === undefined ? 32 : opts.dkLen; + super(64, olen); + checkBlake2Opts(olen, opts, 32, 8, 8); + let { key, personalization, salt } = opts; + let keyLength = 0; + if (key !== undefined) { + key = toBytes(key); + keyLength = key.length; + } + this.v0 ^= this.outputLen | (keyLength << 8) | (0x01 << 16) | (0x01 << 24); + if (salt !== undefined) { + salt = toBytes(salt); + const slt = u32(salt as Uint8Array); + this.v4 ^= swap8IfBE(slt[0]); + this.v5 ^= swap8IfBE(slt[1]); + } + if (personalization !== undefined) { + personalization = toBytes(personalization); + const pers = u32(personalization as Uint8Array); + this.v6 ^= swap8IfBE(pers[0]); + this.v7 ^= swap8IfBE(pers[1]); + } + if (key !== undefined) { + // Pad to blockLen and update + abytes(key); + const tmp = new Uint8Array(this.blockLen); + tmp.set(key); + this.update(tmp); + } + } + protected get(): [number, number, number, number, number, number, number, number] { + const { v0, v1, v2, v3, v4, v5, v6, v7 } = this; + return [v0, v1, v2, v3, v4, v5, v6, v7]; + } + // prettier-ignore + protected set( + v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number + ): void { + this.v0 = v0 | 0; + this.v1 = v1 | 0; + this.v2 = v2 | 0; + this.v3 = v3 | 0; + this.v4 = v4 | 0; + this.v5 = v5 | 0; + this.v6 = v6 | 0; + this.v7 = v7 | 0; + } + protected compress(msg: Uint32Array, offset: number, isLast: boolean): void { + const { h, l } = u64.fromBig(BigInt(this.length)); + // prettier-ignore + const { v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15 } = + compress( + BSIGMA, offset, msg, 10, + this.v0, this.v1, this.v2, this.v3, this.v4, this.v5, this.v6, this.v7, + B2S_IV[0], B2S_IV[1], B2S_IV[2], B2S_IV[3], l ^ B2S_IV[4], h ^ B2S_IV[5], isLast ? ~B2S_IV[6] : B2S_IV[6], B2S_IV[7] + ); + this.v0 ^= v0 ^ v8; + this.v1 ^= v1 ^ v9; + this.v2 ^= v2 ^ v10; + this.v3 ^= v3 ^ v11; + this.v4 ^= v4 ^ v12; + this.v5 ^= v5 ^ v13; + this.v6 ^= v6 ^ v14; + this.v7 ^= v7 ^ v15; + } + destroy(): void { + this.destroyed = true; + clean(this.buffer32); + this.set(0, 0, 0, 0, 0, 0, 0, 0); + } +} + +/** + * Blake2s hash function. Focuses on 8-bit to 32-bit platforms. 1.5x faster than blake2b in JS. + * @param msg - message that would be hashed + * @param opts - dkLen output length, key for MAC mode, salt, personalization + */ +export const blake2s: CHashO = /* @__PURE__ */ createOptHasher( + (opts) => new BLAKE2s(opts) +); diff --git a/node_modules/@noble/hashes/src/blake2b.ts b/node_modules/@noble/hashes/src/blake2b.ts new file mode 100644 index 0000000000000000000000000000000000000000..ddfeadfdc5f9914b756ca34be24a0a6452276e3d --- /dev/null +++ b/node_modules/@noble/hashes/src/blake2b.ts @@ -0,0 +1,10 @@ +/** + * Blake2b hash function. Focuses on 64-bit platforms, but in JS speed different from Blake2s is negligible. + * @module + * @deprecated + */ +import { BLAKE2b as B2B, blake2b as b2b } from './blake2.ts'; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export const BLAKE2b: typeof B2B = B2B; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export const blake2b: typeof b2b = b2b; diff --git a/node_modules/@noble/hashes/src/blake2s.ts b/node_modules/@noble/hashes/src/blake2s.ts new file mode 100644 index 0000000000000000000000000000000000000000..7c753b705e436dabe35bb0fe58cc9fd3eda630e3 --- /dev/null +++ b/node_modules/@noble/hashes/src/blake2s.ts @@ -0,0 +1,20 @@ +/** + * Blake2s hash function. Focuses on 8-bit to 32-bit platforms. blake2b for 64-bit, but in JS it is slower. + * @module + * @deprecated + */ +import { G1s as G1s_n, G2s as G2s_n } from './_blake.ts'; +import { SHA256_IV } from './_md.ts'; +import { BLAKE2s as B2S, blake2s as b2s, compress as compress_n } from './blake2.ts'; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export const B2S_IV: Uint32Array = SHA256_IV; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export const G1s: typeof G1s_n = G1s_n; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export const G2s: typeof G2s_n = G2s_n; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export const compress: typeof compress_n = compress_n; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export const BLAKE2s: typeof B2S = B2S; +/** @deprecated Use import from `noble/hashes/blake2` module */ +export const blake2s: typeof b2s = b2s; diff --git a/node_modules/@noble/hashes/src/blake3.ts b/node_modules/@noble/hashes/src/blake3.ts new file mode 100644 index 0000000000000000000000000000000000000000..e08395b9a3605dca4119c556f37561c53b6ee8d3 --- /dev/null +++ b/node_modules/@noble/hashes/src/blake3.ts @@ -0,0 +1,272 @@ +/** + * Blake3 fast hash is Blake2 with reduced security (round count). Can also be used as MAC & KDF. + * + * It is advertised as "the fastest cryptographic hash". However, it isn't true in JS. + * Why is this so slow? While it should be 6x faster than blake2b, perf diff is only 20%: + * + * * There is only 30% reduction in number of rounds from blake2s + * * Speed-up comes from tree structure, which is parallelized using SIMD & threading. + * These features are not present in JS, so we only get overhead from trees. + * * Parallelization only happens on 1024-byte chunks: there is no benefit for small inputs. + * * It is still possible to make it faster using: a) loop unrolling b) web workers c) wasm + * @module + */ +import { SHA256_IV } from './_md.ts'; +import { fromBig } from './_u64.ts'; +import { BLAKE2, compress } from './blake2.ts'; +// prettier-ignore +import { + abytes, aexists, anumber, aoutput, + clean, createXOFer, swap32IfBE, toBytes, u32, u8, + type CHashXO, type HashXOF, type Input +} from './utils.ts'; + +// Flag bitset +const B3_Flags = { + CHUNK_START: 0b1, + CHUNK_END: 0b10, + PARENT: 0b100, + ROOT: 0b1000, + KEYED_HASH: 0b10000, + DERIVE_KEY_CONTEXT: 0b100000, + DERIVE_KEY_MATERIAL: 0b1000000, +} as const; + +const B3_IV = SHA256_IV.slice(); + +const B3_SIGMA: Uint8Array = /* @__PURE__ */ (() => { + const Id = Array.from({ length: 16 }, (_, i) => i); + const permute = (arr: number[]) => + [2, 6, 3, 10, 7, 0, 4, 13, 1, 11, 12, 5, 9, 14, 15, 8].map((i) => arr[i]); + const res: number[] = []; + for (let i = 0, v = Id; i < 7; i++, v = permute(v)) res.push(...v); + return Uint8Array.from(res); +})(); + +/** + * Ensure to use EITHER `key` OR `context`, not both. + * + * * `key`: 32-byte MAC key. + * * `context`: string for KDF. Should be hardcoded, globally unique, and application - specific. + * A good default format for the context string is "[application] [commit timestamp] [purpose]". + */ +export type Blake3Opts = { dkLen?: number; key?: Input; context?: Input }; + +/** Blake3 hash. Can be used as MAC and KDF. */ +export class BLAKE3 extends BLAKE2 implements HashXOF { + private chunkPos = 0; // Position of current block in chunk + private chunksDone = 0; // How many chunks we already have + private flags = 0 | 0; + private IV: Uint32Array; + private state: Uint32Array; + private stack: Uint32Array[] = []; + // Output + private posOut = 0; + private bufferOut32 = new Uint32Array(16); + private bufferOut: Uint8Array; + private chunkOut = 0; // index of output chunk + private enableXOF = true; + + constructor(opts: Blake3Opts = {}, flags = 0) { + super(64, opts.dkLen === undefined ? 32 : opts.dkLen); + const { key, context } = opts; + const hasContext = context !== undefined; + if (key !== undefined) { + if (hasContext) throw new Error('Only "key" or "context" can be specified at same time'); + const k = toBytes(key).slice(); + abytes(k, 32); + this.IV = u32(k); + swap32IfBE(this.IV); + this.flags = flags | B3_Flags.KEYED_HASH; + } else if (hasContext) { + const ctx = toBytes(context); + const contextKey = new BLAKE3({ dkLen: 32 }, B3_Flags.DERIVE_KEY_CONTEXT) + .update(ctx) + .digest(); + this.IV = u32(contextKey); + swap32IfBE(this.IV); + this.flags = flags | B3_Flags.DERIVE_KEY_MATERIAL; + } else { + this.IV = B3_IV.slice(); + this.flags = flags; + } + this.state = this.IV.slice(); + this.bufferOut = u8(this.bufferOut32); + } + // Unused + protected get(): [] { + return []; + } + protected set(): void {} + private b2Compress(counter: number, flags: number, buf: Uint32Array, bufPos: number = 0) { + const { state: s, pos } = this; + const { h, l } = fromBig(BigInt(counter), true); + // prettier-ignore + const { v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15 } = + compress( + B3_SIGMA, bufPos, buf, 7, + s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], + B3_IV[0], B3_IV[1], B3_IV[2], B3_IV[3], h, l, pos, flags + ); + s[0] = v0 ^ v8; + s[1] = v1 ^ v9; + s[2] = v2 ^ v10; + s[3] = v3 ^ v11; + s[4] = v4 ^ v12; + s[5] = v5 ^ v13; + s[6] = v6 ^ v14; + s[7] = v7 ^ v15; + } + protected compress(buf: Uint32Array, bufPos: number = 0, isLast: boolean = false): void { + // Compress last block + let flags = this.flags; + if (!this.chunkPos) flags |= B3_Flags.CHUNK_START; + if (this.chunkPos === 15 || isLast) flags |= B3_Flags.CHUNK_END; + if (!isLast) this.pos = this.blockLen; + this.b2Compress(this.chunksDone, flags, buf, bufPos); + this.chunkPos += 1; + // If current block is last in chunk (16 blocks), then compress chunks + if (this.chunkPos === 16 || isLast) { + let chunk = this.state; + this.state = this.IV.slice(); + // If not the last one, compress only when there are trailing zeros in chunk counter + // chunks used as binary tree where current stack is path. Zero means current leaf is finished and can be compressed. + // 1 (001) - leaf not finished (just push current chunk to stack) + // 2 (010) - leaf finished at depth=1 (merge with last elm on stack and push back) + // 3 (011) - last leaf not finished + // 4 (100) - leafs finished at depth=1 and depth=2 + for (let last, chunks = this.chunksDone + 1; isLast || !(chunks & 1); chunks >>= 1) { + if (!(last = this.stack.pop())) break; + this.buffer32.set(last, 0); + this.buffer32.set(chunk, 8); + this.pos = this.blockLen; + this.b2Compress(0, this.flags | B3_Flags.PARENT, this.buffer32, 0); + chunk = this.state; + this.state = this.IV.slice(); + } + this.chunksDone++; + this.chunkPos = 0; + this.stack.push(chunk); + } + this.pos = 0; + } + _cloneInto(to?: BLAKE3): BLAKE3 { + to = super._cloneInto(to) as BLAKE3; + const { IV, flags, state, chunkPos, posOut, chunkOut, stack, chunksDone } = this; + to.state.set(state.slice()); + to.stack = stack.map((i) => Uint32Array.from(i)); + to.IV.set(IV); + to.flags = flags; + to.chunkPos = chunkPos; + to.chunksDone = chunksDone; + to.posOut = posOut; + to.chunkOut = chunkOut; + to.enableXOF = this.enableXOF; + to.bufferOut32.set(this.bufferOut32); + return to; + } + destroy(): void { + this.destroyed = true; + clean(this.state, this.buffer32, this.IV, this.bufferOut32); + clean(...this.stack); + } + // Same as b2Compress, but doesn't modify state and returns 16 u32 array (instead of 8) + private b2CompressOut() { + const { state: s, pos, flags, buffer32, bufferOut32: out32 } = this; + const { h, l } = fromBig(BigInt(this.chunkOut++)); + swap32IfBE(buffer32); + // prettier-ignore + const { v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15 } = + compress( + B3_SIGMA, 0, buffer32, 7, + s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], + B3_IV[0], B3_IV[1], B3_IV[2], B3_IV[3], l, h, pos, flags + ); + out32[0] = v0 ^ v8; + out32[1] = v1 ^ v9; + out32[2] = v2 ^ v10; + out32[3] = v3 ^ v11; + out32[4] = v4 ^ v12; + out32[5] = v5 ^ v13; + out32[6] = v6 ^ v14; + out32[7] = v7 ^ v15; + out32[8] = s[0] ^ v8; + out32[9] = s[1] ^ v9; + out32[10] = s[2] ^ v10; + out32[11] = s[3] ^ v11; + out32[12] = s[4] ^ v12; + out32[13] = s[5] ^ v13; + out32[14] = s[6] ^ v14; + out32[15] = s[7] ^ v15; + swap32IfBE(buffer32); + swap32IfBE(out32); + this.posOut = 0; + } + protected finish(): void { + if (this.finished) return; + this.finished = true; + // Padding + clean(this.buffer.subarray(this.pos)); + // Process last chunk + let flags = this.flags | B3_Flags.ROOT; + if (this.stack.length) { + flags |= B3_Flags.PARENT; + swap32IfBE(this.buffer32); + this.compress(this.buffer32, 0, true); + swap32IfBE(this.buffer32); + this.chunksDone = 0; + this.pos = this.blockLen; + } else { + flags |= (!this.chunkPos ? B3_Flags.CHUNK_START : 0) | B3_Flags.CHUNK_END; + } + this.flags = flags; + this.b2CompressOut(); + } + private writeInto(out: Uint8Array) { + aexists(this, false); + abytes(out); + this.finish(); + const { blockLen, bufferOut } = this; + for (let pos = 0, len = out.length; pos < len; ) { + if (this.posOut >= blockLen) this.b2CompressOut(); + const take = Math.min(blockLen - this.posOut, len - pos); + out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos); + this.posOut += take; + pos += take; + } + return out; + } + xofInto(out: Uint8Array): Uint8Array { + if (!this.enableXOF) throw new Error('XOF is not possible after digest call'); + return this.writeInto(out); + } + xof(bytes: number): Uint8Array { + anumber(bytes); + return this.xofInto(new Uint8Array(bytes)); + } + digestInto(out: Uint8Array): Uint8Array { + aoutput(out, this); + if (this.finished) throw new Error('digest() was already called'); + this.enableXOF = false; + this.writeInto(out); + this.destroy(); + return out; + } + digest(): Uint8Array { + return this.digestInto(new Uint8Array(this.outputLen)); + } +} + +/** + * BLAKE3 hash function. Can be used as MAC and KDF. + * @param msg - message that would be hashed + * @param opts - `dkLen` for output length, `key` for MAC mode, `context` for KDF mode + * @example + * const data = new Uint8Array(32); + * const hash = blake3(data); + * const mac = blake3(data, { key: new Uint8Array(32) }); + * const kdf = blake3(data, { context: 'application name' }); + */ +export const blake3: CHashXO = /* @__PURE__ */ createXOFer( + (opts) => new BLAKE3(opts) +); diff --git a/node_modules/@noble/hashes/src/crypto.ts b/node_modules/@noble/hashes/src/crypto.ts new file mode 100644 index 0000000000000000000000000000000000000000..61a59cff3cb2f8c08a51b83cea29366fe59e7f41 --- /dev/null +++ b/node_modules/@noble/hashes/src/crypto.ts @@ -0,0 +1,9 @@ +/** + * Internal webcrypto alias. + * We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+. + * See utils.ts for details. + * @module + */ +declare const globalThis: Record | undefined; +export const crypto: any = + typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined; diff --git a/node_modules/@noble/hashes/src/cryptoNode.ts b/node_modules/@noble/hashes/src/cryptoNode.ts new file mode 100644 index 0000000000000000000000000000000000000000..53a3cc71adc217e8090d77b0d8ac7bba5b08ff0d --- /dev/null +++ b/node_modules/@noble/hashes/src/cryptoNode.ts @@ -0,0 +1,15 @@ +/** + * Internal webcrypto alias. + * We prefer WebCrypto aka globalThis.crypto, which exists in node.js 16+. + * Falls back to Node.js built-in crypto for Node.js <=v14. + * See utils.ts for details. + * @module + */ +// @ts-ignore +import * as nc from 'node:crypto'; +export const crypto: any = + nc && typeof nc === 'object' && 'webcrypto' in nc + ? (nc.webcrypto as any) + : nc && typeof nc === 'object' && 'randomBytes' in nc + ? nc + : undefined; diff --git a/node_modules/@noble/hashes/src/eskdf.ts b/node_modules/@noble/hashes/src/eskdf.ts new file mode 100644 index 0000000000000000000000000000000000000000..58707d159bbb0b845ff7bc4fa10816ca5b1e948c --- /dev/null +++ b/node_modules/@noble/hashes/src/eskdf.ts @@ -0,0 +1,187 @@ +/** + * Experimental KDF for AES. + */ +import { hkdf } from './hkdf.ts'; +import { pbkdf2 as _pbkdf2 } from './pbkdf2.ts'; +import { scrypt as _scrypt } from './scrypt.ts'; +import { sha256 } from './sha256.ts'; +import { abytes, bytesToHex, clean, createView, hexToBytes, kdfInputToBytes } from './utils.ts'; + +// A tiny KDF for various applications like AES key-gen. +// Uses HKDF in a non-standard way, so it's not "KDF-secure", only "PRF-secure". +// Which is good enough: assume sha2-256 retained preimage resistance. + +const SCRYPT_FACTOR = 2 ** 19; +const PBKDF2_FACTOR = 2 ** 17; + +// Scrypt KDF +export function scrypt(password: string, salt: string): Uint8Array { + return _scrypt(password, salt, { N: SCRYPT_FACTOR, r: 8, p: 1, dkLen: 32 }); +} + +// PBKDF2-HMAC-SHA256 +export function pbkdf2(password: string, salt: string): Uint8Array { + return _pbkdf2(sha256, password, salt, { c: PBKDF2_FACTOR, dkLen: 32 }); +} + +// Combines two 32-byte byte arrays +function xor32(a: Uint8Array, b: Uint8Array): Uint8Array { + abytes(a, 32); + abytes(b, 32); + const arr = new Uint8Array(32); + for (let i = 0; i < 32; i++) { + arr[i] = a[i] ^ b[i]; + } + return arr; +} + +function strHasLength(str: string, min: number, max: number): boolean { + return typeof str === 'string' && str.length >= min && str.length <= max; +} + +/** + * Derives main seed. Takes a lot of time. Prefer `eskdf` method instead. + */ +export function deriveMainSeed(username: string, password: string): Uint8Array { + if (!strHasLength(username, 8, 255)) throw new Error('invalid username'); + if (!strHasLength(password, 8, 255)) throw new Error('invalid password'); + // Declared like this to throw off minifiers which auto-convert .fromCharCode(1) to actual string. + // String with non-ascii may be problematic in some envs + const codes = { _1: 1, _2: 2 }; + const sep = { s: String.fromCharCode(codes._1), p: String.fromCharCode(codes._2) }; + const scr = scrypt(password + sep.s, username + sep.s); + const pbk = pbkdf2(password + sep.p, username + sep.p); + const res = xor32(scr, pbk); + clean(scr, pbk); + return res; +} + +type AccountID = number | string; + +/** + * Converts protocol & accountId pair to HKDF salt & info params. + */ +function getSaltInfo(protocol: string, accountId: AccountID = 0) { + // Note that length here also repeats two lines below + // We do an additional length check here to reduce the scope of DoS attacks + if (!(strHasLength(protocol, 3, 15) && /^[a-z0-9]{3,15}$/.test(protocol))) { + throw new Error('invalid protocol'); + } + + // Allow string account ids for some protocols + const allowsStr = /^password\d{0,3}|ssh|tor|file$/.test(protocol); + let salt: Uint8Array; // Extract salt. Default is undefined. + if (typeof accountId === 'string') { + if (!allowsStr) throw new Error('accountId must be a number'); + if (!strHasLength(accountId, 1, 255)) + throw new Error('accountId must be string of length 1..255'); + salt = kdfInputToBytes(accountId); + } else if (Number.isSafeInteger(accountId)) { + if (accountId < 0 || accountId > Math.pow(2, 32) - 1) throw new Error('invalid accountId'); + // Convert to Big Endian Uint32 + salt = new Uint8Array(4); + createView(salt).setUint32(0, accountId, false); + } else { + throw new Error('accountId must be a number' + (allowsStr ? ' or string' : '')); + } + const info = kdfInputToBytes(protocol); + return { salt, info }; +} + +type OptsLength = { keyLength: number }; +type OptsMod = { modulus: bigint }; +type KeyOpts = undefined | OptsLength | OptsMod; + +function countBytes(num: bigint): number { + if (typeof num !== 'bigint' || num <= BigInt(128)) throw new Error('invalid number'); + return Math.ceil(num.toString(2).length / 8); +} + +/** + * Parses keyLength and modulus options to extract length of result key. + * If modulus is used, adds 64 bits to it as per FIPS 186 B.4.1 to combat modulo bias. + */ +function getKeyLength(options: KeyOpts): number { + if (!options || typeof options !== 'object') return 32; + const hasLen = 'keyLength' in options; + const hasMod = 'modulus' in options; + if (hasLen && hasMod) throw new Error('cannot combine keyLength and modulus options'); + if (!hasLen && !hasMod) throw new Error('must have either keyLength or modulus option'); + // FIPS 186 B.4.1 requires at least 64 more bits + const l = hasMod ? countBytes(options.modulus) + 8 : options.keyLength; + if (!(typeof l === 'number' && l >= 16 && l <= 8192)) throw new Error('invalid keyLength'); + return l; +} + +/** + * Converts key to bigint and divides it by modulus. Big Endian. + * Implements FIPS 186 B.4.1, which removes 0 and modulo bias from output. + */ +function modReduceKey(key: Uint8Array, modulus: bigint): Uint8Array { + const _1 = BigInt(1); + const num = BigInt('0x' + bytesToHex(key)); // check for ui8a, then bytesToNumber() + const res = (num % (modulus - _1)) + _1; // Remove 0 from output + if (res < _1) throw new Error('expected positive number'); // Guard against bad values + const len = key.length - 8; // FIPS requires 64 more bits = 8 bytes + const hex = res.toString(16).padStart(len * 2, '0'); // numberToHex() + const bytes = hexToBytes(hex); + if (bytes.length !== len) throw new Error('invalid length of result key'); + return bytes; +} + +// We are not using classes because constructor cannot be async +export interface ESKDF { + /** + * Derives a child key. Child key will not be associated with any + * other child key because of properties of underlying KDF. + * + * @param protocol - 3-15 character protocol name + * @param accountId - numeric identifier of account + * @param options - `keyLength: 64` or `modulus: 41920438n` + * @example deriveChildKey('aes', 0) + */ + deriveChildKey: (protocol: string, accountId: AccountID, options?: KeyOpts) => Uint8Array; + /** + * Deletes the main seed from eskdf instance + */ + expire: () => void; + /** + * Account fingerprint + */ + fingerprint: string; +} + +/** + * ESKDF + * @param username - username, email, or identifier, min: 8 characters, should have enough entropy + * @param password - password, min: 8 characters, should have enough entropy + * @example + * const kdf = await eskdf('example-university', 'beginning-new-example'); + * const key = kdf.deriveChildKey('aes', 0); + * console.log(kdf.fingerprint); + * kdf.expire(); + */ +export async function eskdf(username: string, password: string): Promise { + // We are using closure + object instead of class because + // we want to make `seed` non-accessible for any external function. + let seed: Uint8Array | undefined = deriveMainSeed(username, password); + + function deriveCK(protocol: string, accountId: AccountID = 0, options?: KeyOpts): Uint8Array { + abytes(seed, 32); + const { salt, info } = getSaltInfo(protocol, accountId); // validate protocol & accountId + const keyLength = getKeyLength(options); // validate options + const key = hkdf(sha256, seed!, salt, info, keyLength); + // Modulus has already been validated + return options && 'modulus' in options ? modReduceKey(key, options.modulus) : key; + } + function expire() { + if (seed) seed.fill(1); + seed = undefined; + } + // prettier-ignore + const fingerprint = Array.from(deriveCK('fingerprint', 0)) + .slice(0, 6) + .map((char) => char.toString(16).padStart(2, '0').toUpperCase()) + .join(':'); + return Object.freeze({ deriveChildKey: deriveCK, expire, fingerprint }); +} diff --git a/node_modules/@noble/hashes/src/hkdf.ts b/node_modules/@noble/hashes/src/hkdf.ts new file mode 100644 index 0000000000000000000000000000000000000000..acdc24e2a7c30c569a454f7a4bc891f434aa6bc7 --- /dev/null +++ b/node_modules/@noble/hashes/src/hkdf.ts @@ -0,0 +1,88 @@ +/** + * HKDF (RFC 5869): extract + expand in one step. + * See https://soatok.blog/2021/11/17/understanding-hkdf/. + * @module + */ +import { hmac } from './hmac.ts'; +import { ahash, anumber, type CHash, clean, type Input, toBytes } from './utils.ts'; + +/** + * HKDF-extract from spec. Less important part. `HKDF-Extract(IKM, salt) -> PRK` + * Arguments position differs from spec (IKM is first one, since it is not optional) + * @param hash - hash function that would be used (e.g. sha256) + * @param ikm - input keying material, the initial key + * @param salt - optional salt value (a non-secret random value) + */ +export function extract(hash: CHash, ikm: Input, salt?: Input): Uint8Array { + ahash(hash); + // NOTE: some libraries treat zero-length array as 'not provided'; + // we don't, since we have undefined as 'not provided' + // https://github.com/RustCrypto/KDFs/issues/15 + if (salt === undefined) salt = new Uint8Array(hash.outputLen); + return hmac(hash, toBytes(salt), toBytes(ikm)); +} + +const HKDF_COUNTER = /* @__PURE__ */ Uint8Array.from([0]); +const EMPTY_BUFFER = /* @__PURE__ */ Uint8Array.of(); + +/** + * HKDF-expand from the spec. The most important part. `HKDF-Expand(PRK, info, L) -> OKM` + * @param hash - hash function that would be used (e.g. sha256) + * @param prk - a pseudorandom key of at least HashLen octets (usually, the output from the extract step) + * @param info - optional context and application specific information (can be a zero-length string) + * @param length - length of output keying material in bytes + */ +export function expand(hash: CHash, prk: Input, info?: Input, length: number = 32): Uint8Array { + ahash(hash); + anumber(length); + const olen = hash.outputLen; + if (length > 255 * olen) throw new Error('Length should be <= 255*HashLen'); + const blocks = Math.ceil(length / olen); + if (info === undefined) info = EMPTY_BUFFER; + // first L(ength) octets of T + const okm = new Uint8Array(blocks * olen); + // Re-use HMAC instance between blocks + const HMAC = hmac.create(hash, prk); + const HMACTmp = HMAC._cloneInto(); + const T = new Uint8Array(HMAC.outputLen); + for (let counter = 0; counter < blocks; counter++) { + HKDF_COUNTER[0] = counter + 1; + // T(0) = empty string (zero length) + // T(N) = HMAC-Hash(PRK, T(N-1) | info | N) + HMACTmp.update(counter === 0 ? EMPTY_BUFFER : T) + .update(info) + .update(HKDF_COUNTER) + .digestInto(T); + okm.set(T, olen * counter); + HMAC._cloneInto(HMACTmp); + } + HMAC.destroy(); + HMACTmp.destroy(); + clean(T, HKDF_COUNTER); + return okm.slice(0, length); +} + +/** + * HKDF (RFC 5869): derive keys from an initial input. + * Combines hkdf_extract + hkdf_expand in one step + * @param hash - hash function that would be used (e.g. sha256) + * @param ikm - input keying material, the initial key + * @param salt - optional salt value (a non-secret random value) + * @param info - optional context and application specific information (can be a zero-length string) + * @param length - length of output keying material in bytes + * @example + * import { hkdf } from '@noble/hashes/hkdf'; + * import { sha256 } from '@noble/hashes/sha2'; + * import { randomBytes } from '@noble/hashes/utils'; + * const inputKey = randomBytes(32); + * const salt = randomBytes(32); + * const info = 'application-key'; + * const hk1 = hkdf(sha256, inputKey, salt, info, 32); + */ +export const hkdf = ( + hash: CHash, + ikm: Input, + salt: Input | undefined, + info: Input | undefined, + length: number +): Uint8Array => expand(hash, extract(hash, ikm, salt), info, length); diff --git a/node_modules/@noble/hashes/src/hmac.ts b/node_modules/@noble/hashes/src/hmac.ts new file mode 100644 index 0000000000000000000000000000000000000000..7cf028aac6b31492608e165981e879ef65971022 --- /dev/null +++ b/node_modules/@noble/hashes/src/hmac.ts @@ -0,0 +1,94 @@ +/** + * HMAC: RFC2104 message authentication code. + * @module + */ +import { abytes, aexists, ahash, clean, Hash, toBytes, type CHash, type Input } from './utils.ts'; + +export class HMAC> extends Hash> { + oHash: T; + iHash: T; + blockLen: number; + outputLen: number; + private finished = false; + private destroyed = false; + + constructor(hash: CHash, _key: Input) { + super(); + ahash(hash); + const key = toBytes(_key); + this.iHash = hash.create() as T; + if (typeof this.iHash.update !== 'function') + throw new Error('Expected instance of class which extends utils.Hash'); + this.blockLen = this.iHash.blockLen; + this.outputLen = this.iHash.outputLen; + const blockLen = this.blockLen; + const pad = new Uint8Array(blockLen); + // blockLen can be bigger than outputLen + pad.set(key.length > blockLen ? hash.create().update(key).digest() : key); + for (let i = 0; i < pad.length; i++) pad[i] ^= 0x36; + this.iHash.update(pad); + // By doing update (processing of first block) of outer hash here we can re-use it between multiple calls via clone + this.oHash = hash.create() as T; + // Undo internal XOR && apply outer XOR + for (let i = 0; i < pad.length; i++) pad[i] ^= 0x36 ^ 0x5c; + this.oHash.update(pad); + clean(pad); + } + update(buf: Input): this { + aexists(this); + this.iHash.update(buf); + return this; + } + digestInto(out: Uint8Array): void { + aexists(this); + abytes(out, this.outputLen); + this.finished = true; + this.iHash.digestInto(out); + this.oHash.update(out); + this.oHash.digestInto(out); + this.destroy(); + } + digest(): Uint8Array { + const out = new Uint8Array(this.oHash.outputLen); + this.digestInto(out); + return out; + } + _cloneInto(to?: HMAC): HMAC { + // Create new instance without calling constructor since key already in state and we don't know it. + to ||= Object.create(Object.getPrototypeOf(this), {}); + const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this; + to = to as this; + to.finished = finished; + to.destroyed = destroyed; + to.blockLen = blockLen; + to.outputLen = outputLen; + to.oHash = oHash._cloneInto(to.oHash); + to.iHash = iHash._cloneInto(to.iHash); + return to; + } + clone(): HMAC { + return this._cloneInto(); + } + destroy(): void { + this.destroyed = true; + this.oHash.destroy(); + this.iHash.destroy(); + } +} + +/** + * HMAC: RFC2104 message authentication code. + * @param hash - function that would be used e.g. sha256 + * @param key - message key + * @param message - message data + * @example + * import { hmac } from '@noble/hashes/hmac'; + * import { sha256 } from '@noble/hashes/sha2'; + * const mac1 = hmac(sha256, 'key', 'message'); + */ +export const hmac: { + (hash: CHash, key: Input, message: Input): Uint8Array; + create(hash: CHash, key: Input): HMAC; +} = (hash: CHash, key: Input, message: Input): Uint8Array => + new HMAC(hash, key).update(message).digest(); +hmac.create = (hash: CHash, key: Input) => new HMAC(hash, key); diff --git a/node_modules/@noble/hashes/src/index.ts b/node_modules/@noble/hashes/src/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..485d7627480ab829fa9fe8149d3e97775adbee6b --- /dev/null +++ b/node_modules/@noble/hashes/src/index.ts @@ -0,0 +1,31 @@ +/** + * Audited & minimal JS implementation of hash functions, MACs and KDFs. Check out individual modules. + * @module + * @example +```js +import { + sha256, sha384, sha512, sha224, sha512_224, sha512_256 +} from '@noble/hashes/sha2'; +import { + sha3_224, sha3_256, sha3_384, sha3_512, + keccak_224, keccak_256, keccak_384, keccak_512, + shake128, shake256 +} from '@noble/hashes/sha3'; +import { + cshake128, cshake256, + turboshake128, turboshake256, + kmac128, kmac256, + tuplehash256, parallelhash256, + k12, m14, keccakprg +} from '@noble/hashes/sha3-addons'; +import { blake3 } from '@noble/hashes/blake3'; +import { blake2b, blake2s } from '@noble/hashes/blake2'; +import { hmac } from '@noble/hashes/hmac'; +import { hkdf } from '@noble/hashes/hkdf'; +import { pbkdf2, pbkdf2Async } from '@noble/hashes/pbkdf2'; +import { scrypt, scryptAsync } from '@noble/hashes/scrypt'; +import { md5, ripemd160, sha1 } from '@noble/hashes/legacy'; +import * as utils from '@noble/hashes/utils'; +``` + */ +throw new Error('root module cannot be imported: import submodules instead. Check out README'); diff --git a/node_modules/@noble/hashes/src/legacy.ts b/node_modules/@noble/hashes/src/legacy.ts new file mode 100644 index 0000000000000000000000000000000000000000..47eaddc79491f5bee5764c5a6c1ee8a1186ca34e --- /dev/null +++ b/node_modules/@noble/hashes/src/legacy.ts @@ -0,0 +1,293 @@ +/** + +SHA1 (RFC 3174), MD5 (RFC 1321) and RIPEMD160 (RFC 2286) legacy, weak hash functions. +Don't use them in a new protocol. What "weak" means: + +- Collisions can be made with 2^18 effort in MD5, 2^60 in SHA1, 2^80 in RIPEMD160. +- No practical pre-image attacks (only theoretical, 2^123.4) +- HMAC seems kinda ok: https://datatracker.ietf.org/doc/html/rfc6151 + * @module + */ +import { Chi, HashMD, Maj } from './_md.ts'; +import { type CHash, clean, createHasher, rotl } from './utils.ts'; + +/** Initial SHA1 state */ +const SHA1_IV = /* @__PURE__ */ Uint32Array.from([ + 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0, +]); + +// Reusable temporary buffer +const SHA1_W = /* @__PURE__ */ new Uint32Array(80); + +/** SHA1 legacy hash class. */ +export class SHA1 extends HashMD { + private A = SHA1_IV[0] | 0; + private B = SHA1_IV[1] | 0; + private C = SHA1_IV[2] | 0; + private D = SHA1_IV[3] | 0; + private E = SHA1_IV[4] | 0; + + constructor() { + super(64, 20, 8, false); + } + protected get(): [number, number, number, number, number] { + const { A, B, C, D, E } = this; + return [A, B, C, D, E]; + } + protected set(A: number, B: number, C: number, D: number, E: number): void { + this.A = A | 0; + this.B = B | 0; + this.C = C | 0; + this.D = D | 0; + this.E = E | 0; + } + protected process(view: DataView, offset: number): void { + for (let i = 0; i < 16; i++, offset += 4) SHA1_W[i] = view.getUint32(offset, false); + for (let i = 16; i < 80; i++) + SHA1_W[i] = rotl(SHA1_W[i - 3] ^ SHA1_W[i - 8] ^ SHA1_W[i - 14] ^ SHA1_W[i - 16], 1); + // Compression function main loop, 80 rounds + let { A, B, C, D, E } = this; + for (let i = 0; i < 80; i++) { + let F, K; + if (i < 20) { + F = Chi(B, C, D); + K = 0x5a827999; + } else if (i < 40) { + F = B ^ C ^ D; + K = 0x6ed9eba1; + } else if (i < 60) { + F = Maj(B, C, D); + K = 0x8f1bbcdc; + } else { + F = B ^ C ^ D; + K = 0xca62c1d6; + } + const T = (rotl(A, 5) + F + E + K + SHA1_W[i]) | 0; + E = D; + D = C; + C = rotl(B, 30); + B = A; + A = T; + } + // Add the compressed chunk to the current hash value + A = (A + this.A) | 0; + B = (B + this.B) | 0; + C = (C + this.C) | 0; + D = (D + this.D) | 0; + E = (E + this.E) | 0; + this.set(A, B, C, D, E); + } + protected roundClean(): void { + clean(SHA1_W); + } + destroy(): void { + this.set(0, 0, 0, 0, 0); + clean(this.buffer); + } +} + +/** SHA1 (RFC 3174) legacy hash function. It was cryptographically broken. */ +export const sha1: CHash = /* @__PURE__ */ createHasher(() => new SHA1()); + +/** Per-round constants */ +const p32 = /* @__PURE__ */ Math.pow(2, 32); +const K = /* @__PURE__ */ Array.from({ length: 64 }, (_, i) => + Math.floor(p32 * Math.abs(Math.sin(i + 1))) +); + +/** md5 initial state: same as sha1, but 4 u32 instead of 5. */ +const MD5_IV = /* @__PURE__ */ SHA1_IV.slice(0, 4); + +// Reusable temporary buffer +const MD5_W = /* @__PURE__ */ new Uint32Array(16); +/** MD5 legacy hash class. */ +export class MD5 extends HashMD { + private A = MD5_IV[0] | 0; + private B = MD5_IV[1] | 0; + private C = MD5_IV[2] | 0; + private D = MD5_IV[3] | 0; + + constructor() { + super(64, 16, 8, true); + } + protected get(): [number, number, number, number] { + const { A, B, C, D } = this; + return [A, B, C, D]; + } + protected set(A: number, B: number, C: number, D: number): void { + this.A = A | 0; + this.B = B | 0; + this.C = C | 0; + this.D = D | 0; + } + protected process(view: DataView, offset: number): void { + for (let i = 0; i < 16; i++, offset += 4) MD5_W[i] = view.getUint32(offset, true); + // Compression function main loop, 64 rounds + let { A, B, C, D } = this; + for (let i = 0; i < 64; i++) { + let F, g, s; + if (i < 16) { + F = Chi(B, C, D); + g = i; + s = [7, 12, 17, 22]; + } else if (i < 32) { + F = Chi(D, B, C); + g = (5 * i + 1) % 16; + s = [5, 9, 14, 20]; + } else if (i < 48) { + F = B ^ C ^ D; + g = (3 * i + 5) % 16; + s = [4, 11, 16, 23]; + } else { + F = C ^ (B | ~D); + g = (7 * i) % 16; + s = [6, 10, 15, 21]; + } + F = F + A + K[i] + MD5_W[g]; + A = D; + D = C; + C = B; + B = B + rotl(F, s[i % 4]); + } + // Add the compressed chunk to the current hash value + A = (A + this.A) | 0; + B = (B + this.B) | 0; + C = (C + this.C) | 0; + D = (D + this.D) | 0; + this.set(A, B, C, D); + } + protected roundClean(): void { + clean(MD5_W); + } + destroy(): void { + this.set(0, 0, 0, 0); + clean(this.buffer); + } +} + +/** + * MD5 (RFC 1321) legacy hash function. It was cryptographically broken. + * MD5 architecture is similar to SHA1, with some differences: + * - Reduced output length: 16 bytes (128 bit) instead of 20 + * - 64 rounds, instead of 80 + * - Little-endian: could be faster, but will require more code + * - Non-linear index selection: huge speed-up for unroll + * - Per round constants: more memory accesses, additional speed-up for unroll + */ +export const md5: CHash = /* @__PURE__ */ createHasher(() => new MD5()); + +// RIPEMD-160 + +const Rho160 = /* @__PURE__ */ Uint8Array.from([ + 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, +]); +const Id160 = /* @__PURE__ */ (() => Uint8Array.from(new Array(16).fill(0).map((_, i) => i)))(); +const Pi160 = /* @__PURE__ */ (() => Id160.map((i) => (9 * i + 5) % 16))(); +const idxLR = /* @__PURE__ */ (() => { + const L = [Id160]; + const R = [Pi160]; + const res = [L, R]; + for (let i = 0; i < 4; i++) for (let j of res) j.push(j[i].map((k) => Rho160[k])); + return res; +})(); +const idxL = /* @__PURE__ */ (() => idxLR[0])(); +const idxR = /* @__PURE__ */ (() => idxLR[1])(); +// const [idxL, idxR] = idxLR; + +const shifts160 = /* @__PURE__ */ [ + [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8], + [12, 13, 11, 15, 6, 9, 9, 7, 12, 15, 11, 13, 7, 8, 7, 7], + [13, 15, 14, 11, 7, 7, 6, 8, 13, 14, 13, 12, 5, 5, 6, 9], + [14, 11, 12, 14, 8, 6, 5, 5, 15, 12, 15, 14, 9, 9, 8, 6], + [15, 12, 13, 13, 9, 5, 8, 6, 14, 11, 12, 11, 8, 6, 5, 5], +].map((i) => Uint8Array.from(i)); +const shiftsL160 = /* @__PURE__ */ idxL.map((idx, i) => idx.map((j) => shifts160[i][j])); +const shiftsR160 = /* @__PURE__ */ idxR.map((idx, i) => idx.map((j) => shifts160[i][j])); +const Kl160 = /* @__PURE__ */ Uint32Array.from([ + 0x00000000, 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xa953fd4e, +]); +const Kr160 = /* @__PURE__ */ Uint32Array.from([ + 0x50a28be6, 0x5c4dd124, 0x6d703ef3, 0x7a6d76e9, 0x00000000, +]); +// It's called f() in spec. +function ripemd_f(group: number, x: number, y: number, z: number): number { + if (group === 0) return x ^ y ^ z; + if (group === 1) return (x & y) | (~x & z); + if (group === 2) return (x | ~y) ^ z; + if (group === 3) return (x & z) | (y & ~z); + return x ^ (y | ~z); +} +// Reusable temporary buffer +const BUF_160 = /* @__PURE__ */ new Uint32Array(16); +export class RIPEMD160 extends HashMD { + private h0 = 0x67452301 | 0; + private h1 = 0xefcdab89 | 0; + private h2 = 0x98badcfe | 0; + private h3 = 0x10325476 | 0; + private h4 = 0xc3d2e1f0 | 0; + + constructor() { + super(64, 20, 8, true); + } + protected get(): [number, number, number, number, number] { + const { h0, h1, h2, h3, h4 } = this; + return [h0, h1, h2, h3, h4]; + } + protected set(h0: number, h1: number, h2: number, h3: number, h4: number): void { + this.h0 = h0 | 0; + this.h1 = h1 | 0; + this.h2 = h2 | 0; + this.h3 = h3 | 0; + this.h4 = h4 | 0; + } + protected process(view: DataView, offset: number): void { + for (let i = 0; i < 16; i++, offset += 4) BUF_160[i] = view.getUint32(offset, true); + // prettier-ignore + let al = this.h0 | 0, ar = al, + bl = this.h1 | 0, br = bl, + cl = this.h2 | 0, cr = cl, + dl = this.h3 | 0, dr = dl, + el = this.h4 | 0, er = el; + + // Instead of iterating 0 to 80, we split it into 5 groups + // And use the groups in constants, functions, etc. Much simpler + for (let group = 0; group < 5; group++) { + const rGroup = 4 - group; + const hbl = Kl160[group], hbr = Kr160[group]; // prettier-ignore + const rl = idxL[group], rr = idxR[group]; // prettier-ignore + const sl = shiftsL160[group], sr = shiftsR160[group]; // prettier-ignore + for (let i = 0; i < 16; i++) { + const tl = (rotl(al + ripemd_f(group, bl, cl, dl) + BUF_160[rl[i]] + hbl, sl[i]) + el) | 0; + al = el, el = dl, dl = rotl(cl, 10) | 0, cl = bl, bl = tl; // prettier-ignore + } + // 2 loops are 10% faster + for (let i = 0; i < 16; i++) { + const tr = (rotl(ar + ripemd_f(rGroup, br, cr, dr) + BUF_160[rr[i]] + hbr, sr[i]) + er) | 0; + ar = er, er = dr, dr = rotl(cr, 10) | 0, cr = br, br = tr; // prettier-ignore + } + } + // Add the compressed chunk to the current hash value + this.set( + (this.h1 + cl + dr) | 0, + (this.h2 + dl + er) | 0, + (this.h3 + el + ar) | 0, + (this.h4 + al + br) | 0, + (this.h0 + bl + cr) | 0 + ); + } + protected roundClean(): void { + clean(BUF_160); + } + destroy(): void { + this.destroyed = true; + clean(this.buffer); + this.set(0, 0, 0, 0, 0); + } +} + +/** + * RIPEMD-160 - a legacy hash function from 1990s. + * * https://homes.esat.kuleuven.be/~bosselae/ripemd160.html + * * https://homes.esat.kuleuven.be/~bosselae/ripemd160/pdf/AB-9601/AB-9601.pdf + */ +export const ripemd160: CHash = /* @__PURE__ */ createHasher(() => new RIPEMD160()); diff --git a/node_modules/@noble/hashes/src/pbkdf2.ts b/node_modules/@noble/hashes/src/pbkdf2.ts new file mode 100644 index 0000000000000000000000000000000000000000..ba2007c61b23dcaeb7790f89f4e4e484b6621bd5 --- /dev/null +++ b/node_modules/@noble/hashes/src/pbkdf2.ts @@ -0,0 +1,122 @@ +/** + * PBKDF (RFC 2898). Can be used to create a key from password and salt. + * @module + */ +import { hmac } from './hmac.ts'; +// prettier-ignore +import { + ahash, anumber, + asyncLoop, checkOpts, clean, createView, Hash, kdfInputToBytes, + type CHash, + type KDFInput +} from './utils.ts'; + +export type Pbkdf2Opt = { + c: number; // Iterations + dkLen?: number; // Desired key length in bytes (Intended output length in octets of the derived key + asyncTick?: number; // Maximum time in ms for which async function can block execution +}; +// Common prologue and epilogue for sync/async functions +function pbkdf2Init(hash: CHash, _password: KDFInput, _salt: KDFInput, _opts: Pbkdf2Opt) { + ahash(hash); + const opts = checkOpts({ dkLen: 32, asyncTick: 10 }, _opts); + const { c, dkLen, asyncTick } = opts; + anumber(c); + anumber(dkLen); + anumber(asyncTick); + if (c < 1) throw new Error('iterations (c) should be >= 1'); + const password = kdfInputToBytes(_password); + const salt = kdfInputToBytes(_salt); + // DK = PBKDF2(PRF, Password, Salt, c, dkLen); + const DK = new Uint8Array(dkLen); + // U1 = PRF(Password, Salt + INT_32_BE(i)) + const PRF = hmac.create(hash, password); + const PRFSalt = PRF._cloneInto().update(salt); + return { c, dkLen, asyncTick, DK, PRF, PRFSalt }; +} + +function pbkdf2Output>( + PRF: Hash, + PRFSalt: Hash, + DK: Uint8Array, + prfW: Hash, + u: Uint8Array +) { + PRF.destroy(); + PRFSalt.destroy(); + if (prfW) prfW.destroy(); + clean(u); + return DK; +} + +/** + * PBKDF2-HMAC: RFC 2898 key derivation function + * @param hash - hash function that would be used e.g. sha256 + * @param password - password from which a derived key is generated + * @param salt - cryptographic salt + * @param opts - {c, dkLen} where c is work factor and dkLen is output message size + * @example + * const key = pbkdf2(sha256, 'password', 'salt', { dkLen: 32, c: Math.pow(2, 18) }); + */ +export function pbkdf2( + hash: CHash, + password: KDFInput, + salt: KDFInput, + opts: Pbkdf2Opt +): Uint8Array { + const { c, dkLen, DK, PRF, PRFSalt } = pbkdf2Init(hash, password, salt, opts); + let prfW: any; // Working copy + const arr = new Uint8Array(4); + const view = createView(arr); + const u = new Uint8Array(PRF.outputLen); + // DK = T1 + T2 + ⋯ + Tdklen/hlen + for (let ti = 1, pos = 0; pos < dkLen; ti++, pos += PRF.outputLen) { + // Ti = F(Password, Salt, c, i) + const Ti = DK.subarray(pos, pos + PRF.outputLen); + view.setInt32(0, ti, false); + // F(Password, Salt, c, i) = U1 ^ U2 ^ ⋯ ^ Uc + // U1 = PRF(Password, Salt + INT_32_BE(i)) + (prfW = PRFSalt._cloneInto(prfW)).update(arr).digestInto(u); + Ti.set(u.subarray(0, Ti.length)); + for (let ui = 1; ui < c; ui++) { + // Uc = PRF(Password, Uc−1) + PRF._cloneInto(prfW).update(u).digestInto(u); + for (let i = 0; i < Ti.length; i++) Ti[i] ^= u[i]; + } + } + return pbkdf2Output(PRF, PRFSalt, DK, prfW, u); +} + +/** + * PBKDF2-HMAC: RFC 2898 key derivation function. Async version. + * @example + * await pbkdf2Async(sha256, 'password', 'salt', { dkLen: 32, c: 500_000 }); + */ +export async function pbkdf2Async( + hash: CHash, + password: KDFInput, + salt: KDFInput, + opts: Pbkdf2Opt +): Promise { + const { c, dkLen, asyncTick, DK, PRF, PRFSalt } = pbkdf2Init(hash, password, salt, opts); + let prfW: any; // Working copy + const arr = new Uint8Array(4); + const view = createView(arr); + const u = new Uint8Array(PRF.outputLen); + // DK = T1 + T2 + ⋯ + Tdklen/hlen + for (let ti = 1, pos = 0; pos < dkLen; ti++, pos += PRF.outputLen) { + // Ti = F(Password, Salt, c, i) + const Ti = DK.subarray(pos, pos + PRF.outputLen); + view.setInt32(0, ti, false); + // F(Password, Salt, c, i) = U1 ^ U2 ^ ⋯ ^ Uc + // U1 = PRF(Password, Salt + INT_32_BE(i)) + (prfW = PRFSalt._cloneInto(prfW)).update(arr).digestInto(u); + Ti.set(u.subarray(0, Ti.length)); + await asyncLoop(c - 1, asyncTick, () => { + // Uc = PRF(Password, Uc−1) + PRF._cloneInto(prfW).update(u).digestInto(u); + for (let i = 0; i < Ti.length; i++) Ti[i] ^= u[i]; + }); + } + return pbkdf2Output(PRF, PRFSalt, DK, prfW, u); +} diff --git a/node_modules/@noble/hashes/src/ripemd160.ts b/node_modules/@noble/hashes/src/ripemd160.ts new file mode 100644 index 0000000000000000000000000000000000000000..73f72a5b8d6819922076794b733b545f97fbe996 --- /dev/null +++ b/node_modules/@noble/hashes/src/ripemd160.ts @@ -0,0 +1,12 @@ +/** + * RIPEMD-160 legacy hash function. + * https://homes.esat.kuleuven.be/~bosselae/ripemd160.html + * https://homes.esat.kuleuven.be/~bosselae/ripemd160/pdf/AB-9601/AB-9601.pdf + * @module + * @deprecated + */ +import { RIPEMD160 as RIPEMD160n, ripemd160 as ripemd160n } from './legacy.ts'; +/** @deprecated Use import from `noble/hashes/legacy` module */ +export const RIPEMD160: typeof RIPEMD160n = RIPEMD160n; +/** @deprecated Use import from `noble/hashes/legacy` module */ +export const ripemd160: typeof ripemd160n = ripemd160n; diff --git a/node_modules/@noble/hashes/src/scrypt.ts b/node_modules/@noble/hashes/src/scrypt.ts new file mode 100644 index 0000000000000000000000000000000000000000..143054e3720cccf4c845057b748a2708a1aec427 --- /dev/null +++ b/node_modules/@noble/hashes/src/scrypt.ts @@ -0,0 +1,257 @@ +/** + * RFC 7914 Scrypt KDF. Can be used to create a key from password and salt. + * @module + */ +import { pbkdf2 } from './pbkdf2.ts'; +import { sha256 } from './sha2.ts'; +// prettier-ignore +import { + anumber, asyncLoop, + checkOpts, clean, + type KDFInput, rotl, + swap32IfBE, + u32 +} from './utils.ts'; + +// The main Scrypt loop: uses Salsa extensively. +// Six versions of the function were tried, this is the fastest one. +// prettier-ignore +function XorAndSalsa( + prev: Uint32Array, + pi: number, + input: Uint32Array, + ii: number, + out: Uint32Array, + oi: number +) { + // Based on https://cr.yp.to/salsa20.html + // Xor blocks + let y00 = prev[pi++] ^ input[ii++], y01 = prev[pi++] ^ input[ii++]; + let y02 = prev[pi++] ^ input[ii++], y03 = prev[pi++] ^ input[ii++]; + let y04 = prev[pi++] ^ input[ii++], y05 = prev[pi++] ^ input[ii++]; + let y06 = prev[pi++] ^ input[ii++], y07 = prev[pi++] ^ input[ii++]; + let y08 = prev[pi++] ^ input[ii++], y09 = prev[pi++] ^ input[ii++]; + let y10 = prev[pi++] ^ input[ii++], y11 = prev[pi++] ^ input[ii++]; + let y12 = prev[pi++] ^ input[ii++], y13 = prev[pi++] ^ input[ii++]; + let y14 = prev[pi++] ^ input[ii++], y15 = prev[pi++] ^ input[ii++]; + // Save state to temporary variables (salsa) + let x00 = y00, x01 = y01, x02 = y02, x03 = y03, + x04 = y04, x05 = y05, x06 = y06, x07 = y07, + x08 = y08, x09 = y09, x10 = y10, x11 = y11, + x12 = y12, x13 = y13, x14 = y14, x15 = y15; + // Main loop (salsa) + for (let i = 0; i < 8; i += 2) { + x04 ^= rotl(x00 + x12 | 0, 7); x08 ^= rotl(x04 + x00 | 0, 9); + x12 ^= rotl(x08 + x04 | 0, 13); x00 ^= rotl(x12 + x08 | 0, 18); + x09 ^= rotl(x05 + x01 | 0, 7); x13 ^= rotl(x09 + x05 | 0, 9); + x01 ^= rotl(x13 + x09 | 0, 13); x05 ^= rotl(x01 + x13 | 0, 18); + x14 ^= rotl(x10 + x06 | 0, 7); x02 ^= rotl(x14 + x10 | 0, 9); + x06 ^= rotl(x02 + x14 | 0, 13); x10 ^= rotl(x06 + x02 | 0, 18); + x03 ^= rotl(x15 + x11 | 0, 7); x07 ^= rotl(x03 + x15 | 0, 9); + x11 ^= rotl(x07 + x03 | 0, 13); x15 ^= rotl(x11 + x07 | 0, 18); + x01 ^= rotl(x00 + x03 | 0, 7); x02 ^= rotl(x01 + x00 | 0, 9); + x03 ^= rotl(x02 + x01 | 0, 13); x00 ^= rotl(x03 + x02 | 0, 18); + x06 ^= rotl(x05 + x04 | 0, 7); x07 ^= rotl(x06 + x05 | 0, 9); + x04 ^= rotl(x07 + x06 | 0, 13); x05 ^= rotl(x04 + x07 | 0, 18); + x11 ^= rotl(x10 + x09 | 0, 7); x08 ^= rotl(x11 + x10 | 0, 9); + x09 ^= rotl(x08 + x11 | 0, 13); x10 ^= rotl(x09 + x08 | 0, 18); + x12 ^= rotl(x15 + x14 | 0, 7); x13 ^= rotl(x12 + x15 | 0, 9); + x14 ^= rotl(x13 + x12 | 0, 13); x15 ^= rotl(x14 + x13 | 0, 18); + } + // Write output (salsa) + out[oi++] = (y00 + x00) | 0; out[oi++] = (y01 + x01) | 0; + out[oi++] = (y02 + x02) | 0; out[oi++] = (y03 + x03) | 0; + out[oi++] = (y04 + x04) | 0; out[oi++] = (y05 + x05) | 0; + out[oi++] = (y06 + x06) | 0; out[oi++] = (y07 + x07) | 0; + out[oi++] = (y08 + x08) | 0; out[oi++] = (y09 + x09) | 0; + out[oi++] = (y10 + x10) | 0; out[oi++] = (y11 + x11) | 0; + out[oi++] = (y12 + x12) | 0; out[oi++] = (y13 + x13) | 0; + out[oi++] = (y14 + x14) | 0; out[oi++] = (y15 + x15) | 0; +} + +function BlockMix(input: Uint32Array, ii: number, out: Uint32Array, oi: number, r: number) { + // The block B is r 128-byte chunks (which is equivalent of 2r 64-byte chunks) + let head = oi + 0; + let tail = oi + 16 * r; + for (let i = 0; i < 16; i++) out[tail + i] = input[ii + (2 * r - 1) * 16 + i]; // X ← B[2r−1] + for (let i = 0; i < r; i++, head += 16, ii += 16) { + // We write odd & even Yi at same time. Even: 0bXXXXX0 Odd: 0bXXXXX1 + XorAndSalsa(out, tail, input, ii, out, head); // head[i] = Salsa(blockIn[2*i] ^ tail[i-1]) + if (i > 0) tail += 16; // First iteration overwrites tmp value in tail + XorAndSalsa(out, head, input, (ii += 16), out, tail); // tail[i] = Salsa(blockIn[2*i+1] ^ head[i]) + } +} + +export type ScryptOpts = { + N: number; // cost factor + r: number; // block size + p: number; // parallelization + dkLen?: number; // key length + asyncTick?: number; // block execution max time + maxmem?: number; + onProgress?: (progress: number) => void; +}; + +// Common prologue and epilogue for sync/async functions +function scryptInit(password: KDFInput, salt: KDFInput, _opts?: ScryptOpts) { + // Maxmem - 1GB+1KB by default + const opts = checkOpts( + { + dkLen: 32, + asyncTick: 10, + maxmem: 1024 ** 3 + 1024, + }, + _opts + ); + const { N, r, p, dkLen, asyncTick, maxmem, onProgress } = opts; + anumber(N); + anumber(r); + anumber(p); + anumber(dkLen); + anumber(asyncTick); + anumber(maxmem); + if (onProgress !== undefined && typeof onProgress !== 'function') + throw new Error('progressCb should be function'); + const blockSize = 128 * r; + const blockSize32 = blockSize / 4; + + // Max N is 2^32 (Integrify is 32-bit). Real limit is 2^22: JS engines Uint8Array limit is 4GB in 2024. + // Spec check `N >= 2^(blockSize / 8)` is not done for compat with popular libs, + // which used incorrect r: 1, p: 8. Also, the check seems to be a spec error: + // https://www.rfc-editor.org/errata_search.php?rfc=7914 + const pow32 = Math.pow(2, 32); + if (N <= 1 || (N & (N - 1)) !== 0 || N > pow32) { + throw new Error('Scrypt: N must be larger than 1, a power of 2, and less than 2^32'); + } + if (p < 0 || p > ((pow32 - 1) * 32) / blockSize) { + throw new Error( + 'Scrypt: p must be a positive integer less than or equal to ((2^32 - 1) * 32) / (128 * r)' + ); + } + if (dkLen < 0 || dkLen > (pow32 - 1) * 32) { + throw new Error( + 'Scrypt: dkLen should be positive integer less than or equal to (2^32 - 1) * 32' + ); + } + const memUsed = blockSize * (N + p); + if (memUsed > maxmem) { + throw new Error( + 'Scrypt: memused is bigger than maxMem. Expected 128 * r * (N + p) > maxmem of ' + maxmem + ); + } + // [B0...Bp−1] ← PBKDF2HMAC-SHA256(Passphrase, Salt, 1, blockSize*ParallelizationFactor) + // Since it has only one iteration there is no reason to use async variant + const B = pbkdf2(sha256, password, salt, { c: 1, dkLen: blockSize * p }); + const B32 = u32(B); + // Re-used between parallel iterations. Array(iterations) of B + const V = u32(new Uint8Array(blockSize * N)); + const tmp = u32(new Uint8Array(blockSize)); + let blockMixCb = () => {}; + if (onProgress) { + const totalBlockMix = 2 * N * p; + // Invoke callback if progress changes from 10.01 to 10.02 + // Allows to draw smooth progress bar on up to 8K screen + const callbackPer = Math.max(Math.floor(totalBlockMix / 10000), 1); + let blockMixCnt = 0; + blockMixCb = () => { + blockMixCnt++; + if (onProgress && (!(blockMixCnt % callbackPer) || blockMixCnt === totalBlockMix)) + onProgress(blockMixCnt / totalBlockMix); + }; + } + return { N, r, p, dkLen, blockSize32, V, B32, B, tmp, blockMixCb, asyncTick }; +} + +function scryptOutput( + password: KDFInput, + dkLen: number, + B: Uint8Array, + V: Uint32Array, + tmp: Uint32Array +) { + const res = pbkdf2(sha256, password, B, { c: 1, dkLen }); + clean(B, V, tmp); + return res; +} + +/** + * Scrypt KDF from RFC 7914. + * @param password - pass + * @param salt - salt + * @param opts - parameters + * - `N` is cpu/mem work factor (power of 2 e.g. 2**18) + * - `r` is block size (8 is common), fine-tunes sequential memory read size and performance + * - `p` is parallelization factor (1 is common) + * - `dkLen` is output key length in bytes e.g. 32. + * - `asyncTick` - (default: 10) max time in ms for which async function can block execution + * - `maxmem` - (default: `1024 ** 3 + 1024` aka 1GB+1KB). A limit that the app could use for scrypt + * - `onProgress` - callback function that would be executed for progress report + * @returns Derived key + * @example + * scrypt('password', 'salt', { N: 2**18, r: 8, p: 1, dkLen: 32 }); + */ +export function scrypt(password: KDFInput, salt: KDFInput, opts: ScryptOpts): Uint8Array { + const { N, r, p, dkLen, blockSize32, V, B32, B, tmp, blockMixCb } = scryptInit( + password, + salt, + opts + ); + swap32IfBE(B32); + for (let pi = 0; pi < p; pi++) { + const Pi = blockSize32 * pi; + for (let i = 0; i < blockSize32; i++) V[i] = B32[Pi + i]; // V[0] = B[i] + for (let i = 0, pos = 0; i < N - 1; i++) { + BlockMix(V, pos, V, (pos += blockSize32), r); // V[i] = BlockMix(V[i-1]); + blockMixCb(); + } + BlockMix(V, (N - 1) * blockSize32, B32, Pi, r); // Process last element + blockMixCb(); + for (let i = 0; i < N; i++) { + // First u32 of the last 64-byte block (u32 is LE) + const j = B32[Pi + blockSize32 - 16] % N; // j = Integrify(X) % iterations + for (let k = 0; k < blockSize32; k++) tmp[k] = B32[Pi + k] ^ V[j * blockSize32 + k]; // tmp = B ^ V[j] + BlockMix(tmp, 0, B32, Pi, r); // B = BlockMix(B ^ V[j]) + blockMixCb(); + } + } + swap32IfBE(B32); + return scryptOutput(password, dkLen, B, V, tmp); +} + +/** + * Scrypt KDF from RFC 7914. Async version. + * @example + * await scryptAsync('password', 'salt', { N: 2**18, r: 8, p: 1, dkLen: 32 }); + */ +export async function scryptAsync( + password: KDFInput, + salt: KDFInput, + opts: ScryptOpts +): Promise { + const { N, r, p, dkLen, blockSize32, V, B32, B, tmp, blockMixCb, asyncTick } = scryptInit( + password, + salt, + opts + ); + swap32IfBE(B32); + for (let pi = 0; pi < p; pi++) { + const Pi = blockSize32 * pi; + for (let i = 0; i < blockSize32; i++) V[i] = B32[Pi + i]; // V[0] = B[i] + let pos = 0; + await asyncLoop(N - 1, asyncTick, () => { + BlockMix(V, pos, V, (pos += blockSize32), r); // V[i] = BlockMix(V[i-1]); + blockMixCb(); + }); + BlockMix(V, (N - 1) * blockSize32, B32, Pi, r); // Process last element + blockMixCb(); + await asyncLoop(N, asyncTick, () => { + // First u32 of the last 64-byte block (u32 is LE) + const j = B32[Pi + blockSize32 - 16] % N; // j = Integrify(X) % iterations + for (let k = 0; k < blockSize32; k++) tmp[k] = B32[Pi + k] ^ V[j * blockSize32 + k]; // tmp = B ^ V[j] + BlockMix(tmp, 0, B32, Pi, r); // B = BlockMix(B ^ V[j]) + blockMixCb(); + }); + } + swap32IfBE(B32); + return scryptOutput(password, dkLen, B, V, tmp); +} diff --git a/node_modules/@noble/hashes/src/sha1.ts b/node_modules/@noble/hashes/src/sha1.ts new file mode 100644 index 0000000000000000000000000000000000000000..9a18822ca2e83045e9acdc7e154197a6bf8cd408 --- /dev/null +++ b/node_modules/@noble/hashes/src/sha1.ts @@ -0,0 +1,10 @@ +/** + * SHA1 (RFC 3174) legacy hash function. + * @module + * @deprecated + */ +import { SHA1 as SHA1n, sha1 as sha1n } from './legacy.ts'; +/** @deprecated Use import from `noble/hashes/legacy` module */ +export const SHA1: typeof SHA1n = SHA1n; +/** @deprecated Use import from `noble/hashes/legacy` module */ +export const sha1: typeof sha1n = sha1n; diff --git a/node_modules/@noble/hashes/src/sha2.ts b/node_modules/@noble/hashes/src/sha2.ts new file mode 100644 index 0000000000000000000000000000000000000000..7f1e722eac6a9030a92c6b01f9d28709f5042588 --- /dev/null +++ b/node_modules/@noble/hashes/src/sha2.ts @@ -0,0 +1,402 @@ +/** + * SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256. + * SHA256 is the fastest hash implementable in JS, even faster than Blake3. + * Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and + * [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf). + * @module + */ +import { Chi, HashMD, Maj, SHA224_IV, SHA256_IV, SHA384_IV, SHA512_IV } from './_md.ts'; +import * as u64 from './_u64.ts'; +import { type CHash, clean, createHasher, rotr } from './utils.ts'; + +/** + * Round constants: + * First 32 bits of fractional parts of the cube roots of the first 64 primes 2..311) + */ +// prettier-ignore +const SHA256_K = /* @__PURE__ */ Uint32Array.from([ + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, + 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, + 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, + 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 +]); + +/** Reusable temporary buffer. "W" comes straight from spec. */ +const SHA256_W = /* @__PURE__ */ new Uint32Array(64); +export class SHA256 extends HashMD { + // We cannot use array here since array allows indexing by variable + // which means optimizer/compiler cannot use registers. + protected A: number = SHA256_IV[0] | 0; + protected B: number = SHA256_IV[1] | 0; + protected C: number = SHA256_IV[2] | 0; + protected D: number = SHA256_IV[3] | 0; + protected E: number = SHA256_IV[4] | 0; + protected F: number = SHA256_IV[5] | 0; + protected G: number = SHA256_IV[6] | 0; + protected H: number = SHA256_IV[7] | 0; + + constructor(outputLen: number = 32) { + super(64, outputLen, 8, false); + } + protected get(): [number, number, number, number, number, number, number, number] { + const { A, B, C, D, E, F, G, H } = this; + return [A, B, C, D, E, F, G, H]; + } + // prettier-ignore + protected set( + A: number, B: number, C: number, D: number, E: number, F: number, G: number, H: number + ): void { + this.A = A | 0; + this.B = B | 0; + this.C = C | 0; + this.D = D | 0; + this.E = E | 0; + this.F = F | 0; + this.G = G | 0; + this.H = H | 0; + } + protected process(view: DataView, offset: number): void { + // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array + for (let i = 0; i < 16; i++, offset += 4) SHA256_W[i] = view.getUint32(offset, false); + for (let i = 16; i < 64; i++) { + const W15 = SHA256_W[i - 15]; + const W2 = SHA256_W[i - 2]; + const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3); + const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10); + SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0; + } + // Compression function main loop, 64 rounds + let { A, B, C, D, E, F, G, H } = this; + for (let i = 0; i < 64; i++) { + const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25); + const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0; + const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22); + const T2 = (sigma0 + Maj(A, B, C)) | 0; + H = G; + G = F; + F = E; + E = (D + T1) | 0; + D = C; + C = B; + B = A; + A = (T1 + T2) | 0; + } + // Add the compressed chunk to the current hash value + A = (A + this.A) | 0; + B = (B + this.B) | 0; + C = (C + this.C) | 0; + D = (D + this.D) | 0; + E = (E + this.E) | 0; + F = (F + this.F) | 0; + G = (G + this.G) | 0; + H = (H + this.H) | 0; + this.set(A, B, C, D, E, F, G, H); + } + protected roundClean(): void { + clean(SHA256_W); + } + destroy(): void { + this.set(0, 0, 0, 0, 0, 0, 0, 0); + clean(this.buffer); + } +} + +export class SHA224 extends SHA256 { + protected A: number = SHA224_IV[0] | 0; + protected B: number = SHA224_IV[1] | 0; + protected C: number = SHA224_IV[2] | 0; + protected D: number = SHA224_IV[3] | 0; + protected E: number = SHA224_IV[4] | 0; + protected F: number = SHA224_IV[5] | 0; + protected G: number = SHA224_IV[6] | 0; + protected H: number = SHA224_IV[7] | 0; + constructor() { + super(28); + } +} + +// SHA2-512 is slower than sha256 in js because u64 operations are slow. + +// Round contants +// First 32 bits of the fractional parts of the cube roots of the first 80 primes 2..409 +// prettier-ignore +const K512 = /* @__PURE__ */ (() => u64.split([ + '0x428a2f98d728ae22', '0x7137449123ef65cd', '0xb5c0fbcfec4d3b2f', '0xe9b5dba58189dbbc', + '0x3956c25bf348b538', '0x59f111f1b605d019', '0x923f82a4af194f9b', '0xab1c5ed5da6d8118', + '0xd807aa98a3030242', '0x12835b0145706fbe', '0x243185be4ee4b28c', '0x550c7dc3d5ffb4e2', + '0x72be5d74f27b896f', '0x80deb1fe3b1696b1', '0x9bdc06a725c71235', '0xc19bf174cf692694', + '0xe49b69c19ef14ad2', '0xefbe4786384f25e3', '0x0fc19dc68b8cd5b5', '0x240ca1cc77ac9c65', + '0x2de92c6f592b0275', '0x4a7484aa6ea6e483', '0x5cb0a9dcbd41fbd4', '0x76f988da831153b5', + '0x983e5152ee66dfab', '0xa831c66d2db43210', '0xb00327c898fb213f', '0xbf597fc7beef0ee4', + '0xc6e00bf33da88fc2', '0xd5a79147930aa725', '0x06ca6351e003826f', '0x142929670a0e6e70', + '0x27b70a8546d22ffc', '0x2e1b21385c26c926', '0x4d2c6dfc5ac42aed', '0x53380d139d95b3df', + '0x650a73548baf63de', '0x766a0abb3c77b2a8', '0x81c2c92e47edaee6', '0x92722c851482353b', + '0xa2bfe8a14cf10364', '0xa81a664bbc423001', '0xc24b8b70d0f89791', '0xc76c51a30654be30', + '0xd192e819d6ef5218', '0xd69906245565a910', '0xf40e35855771202a', '0x106aa07032bbd1b8', + '0x19a4c116b8d2d0c8', '0x1e376c085141ab53', '0x2748774cdf8eeb99', '0x34b0bcb5e19b48a8', + '0x391c0cb3c5c95a63', '0x4ed8aa4ae3418acb', '0x5b9cca4f7763e373', '0x682e6ff3d6b2b8a3', + '0x748f82ee5defb2fc', '0x78a5636f43172f60', '0x84c87814a1f0ab72', '0x8cc702081a6439ec', + '0x90befffa23631e28', '0xa4506cebde82bde9', '0xbef9a3f7b2c67915', '0xc67178f2e372532b', + '0xca273eceea26619c', '0xd186b8c721c0c207', '0xeada7dd6cde0eb1e', '0xf57d4f7fee6ed178', + '0x06f067aa72176fba', '0x0a637dc5a2c898a6', '0x113f9804bef90dae', '0x1b710b35131c471b', + '0x28db77f523047d84', '0x32caab7b40c72493', '0x3c9ebe0a15c9bebc', '0x431d67c49c100d4c', + '0x4cc5d4becb3e42b6', '0x597f299cfc657e2a', '0x5fcb6fab3ad6faec', '0x6c44198c4a475817' +].map(n => BigInt(n))))(); +const SHA512_Kh = /* @__PURE__ */ (() => K512[0])(); +const SHA512_Kl = /* @__PURE__ */ (() => K512[1])(); + +// Reusable temporary buffers +const SHA512_W_H = /* @__PURE__ */ new Uint32Array(80); +const SHA512_W_L = /* @__PURE__ */ new Uint32Array(80); + +export class SHA512 extends HashMD { + // We cannot use array here since array allows indexing by variable + // which means optimizer/compiler cannot use registers. + // h -- high 32 bits, l -- low 32 bits + protected Ah: number = SHA512_IV[0] | 0; + protected Al: number = SHA512_IV[1] | 0; + protected Bh: number = SHA512_IV[2] | 0; + protected Bl: number = SHA512_IV[3] | 0; + protected Ch: number = SHA512_IV[4] | 0; + protected Cl: number = SHA512_IV[5] | 0; + protected Dh: number = SHA512_IV[6] | 0; + protected Dl: number = SHA512_IV[7] | 0; + protected Eh: number = SHA512_IV[8] | 0; + protected El: number = SHA512_IV[9] | 0; + protected Fh: number = SHA512_IV[10] | 0; + protected Fl: number = SHA512_IV[11] | 0; + protected Gh: number = SHA512_IV[12] | 0; + protected Gl: number = SHA512_IV[13] | 0; + protected Hh: number = SHA512_IV[14] | 0; + protected Hl: number = SHA512_IV[15] | 0; + + constructor(outputLen: number = 64) { + super(128, outputLen, 16, false); + } + // prettier-ignore + protected get(): [ + number, number, number, number, number, number, number, number, + number, number, number, number, number, number, number, number + ] { + const { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this; + return [Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl]; + } + // prettier-ignore + protected set( + Ah: number, Al: number, Bh: number, Bl: number, Ch: number, Cl: number, Dh: number, Dl: number, + Eh: number, El: number, Fh: number, Fl: number, Gh: number, Gl: number, Hh: number, Hl: number + ): void { + this.Ah = Ah | 0; + this.Al = Al | 0; + this.Bh = Bh | 0; + this.Bl = Bl | 0; + this.Ch = Ch | 0; + this.Cl = Cl | 0; + this.Dh = Dh | 0; + this.Dl = Dl | 0; + this.Eh = Eh | 0; + this.El = El | 0; + this.Fh = Fh | 0; + this.Fl = Fl | 0; + this.Gh = Gh | 0; + this.Gl = Gl | 0; + this.Hh = Hh | 0; + this.Hl = Hl | 0; + } + protected process(view: DataView, offset: number): void { + // Extend the first 16 words into the remaining 64 words w[16..79] of the message schedule array + for (let i = 0; i < 16; i++, offset += 4) { + SHA512_W_H[i] = view.getUint32(offset); + SHA512_W_L[i] = view.getUint32((offset += 4)); + } + for (let i = 16; i < 80; i++) { + // s0 := (w[i-15] rightrotate 1) xor (w[i-15] rightrotate 8) xor (w[i-15] rightshift 7) + const W15h = SHA512_W_H[i - 15] | 0; + const W15l = SHA512_W_L[i - 15] | 0; + const s0h = u64.rotrSH(W15h, W15l, 1) ^ u64.rotrSH(W15h, W15l, 8) ^ u64.shrSH(W15h, W15l, 7); + const s0l = u64.rotrSL(W15h, W15l, 1) ^ u64.rotrSL(W15h, W15l, 8) ^ u64.shrSL(W15h, W15l, 7); + // s1 := (w[i-2] rightrotate 19) xor (w[i-2] rightrotate 61) xor (w[i-2] rightshift 6) + const W2h = SHA512_W_H[i - 2] | 0; + const W2l = SHA512_W_L[i - 2] | 0; + const s1h = u64.rotrSH(W2h, W2l, 19) ^ u64.rotrBH(W2h, W2l, 61) ^ u64.shrSH(W2h, W2l, 6); + const s1l = u64.rotrSL(W2h, W2l, 19) ^ u64.rotrBL(W2h, W2l, 61) ^ u64.shrSL(W2h, W2l, 6); + // SHA256_W[i] = s0 + s1 + SHA256_W[i - 7] + SHA256_W[i - 16]; + const SUMl = u64.add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16]); + const SUMh = u64.add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]); + SHA512_W_H[i] = SUMh | 0; + SHA512_W_L[i] = SUMl | 0; + } + let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this; + // Compression function main loop, 80 rounds + for (let i = 0; i < 80; i++) { + // S1 := (e rightrotate 14) xor (e rightrotate 18) xor (e rightrotate 41) + const sigma1h = u64.rotrSH(Eh, El, 14) ^ u64.rotrSH(Eh, El, 18) ^ u64.rotrBH(Eh, El, 41); + const sigma1l = u64.rotrSL(Eh, El, 14) ^ u64.rotrSL(Eh, El, 18) ^ u64.rotrBL(Eh, El, 41); + //const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0; + const CHIh = (Eh & Fh) ^ (~Eh & Gh); + const CHIl = (El & Fl) ^ (~El & Gl); + // T1 = H + sigma1 + Chi(E, F, G) + SHA512_K[i] + SHA512_W[i] + // prettier-ignore + const T1ll = u64.add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]); + const T1h = u64.add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]); + const T1l = T1ll | 0; + // S0 := (a rightrotate 28) xor (a rightrotate 34) xor (a rightrotate 39) + const sigma0h = u64.rotrSH(Ah, Al, 28) ^ u64.rotrBH(Ah, Al, 34) ^ u64.rotrBH(Ah, Al, 39); + const sigma0l = u64.rotrSL(Ah, Al, 28) ^ u64.rotrBL(Ah, Al, 34) ^ u64.rotrBL(Ah, Al, 39); + const MAJh = (Ah & Bh) ^ (Ah & Ch) ^ (Bh & Ch); + const MAJl = (Al & Bl) ^ (Al & Cl) ^ (Bl & Cl); + Hh = Gh | 0; + Hl = Gl | 0; + Gh = Fh | 0; + Gl = Fl | 0; + Fh = Eh | 0; + Fl = El | 0; + ({ h: Eh, l: El } = u64.add(Dh | 0, Dl | 0, T1h | 0, T1l | 0)); + Dh = Ch | 0; + Dl = Cl | 0; + Ch = Bh | 0; + Cl = Bl | 0; + Bh = Ah | 0; + Bl = Al | 0; + const All = u64.add3L(T1l, sigma0l, MAJl); + Ah = u64.add3H(All, T1h, sigma0h, MAJh); + Al = All | 0; + } + // Add the compressed chunk to the current hash value + ({ h: Ah, l: Al } = u64.add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0)); + ({ h: Bh, l: Bl } = u64.add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0)); + ({ h: Ch, l: Cl } = u64.add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0)); + ({ h: Dh, l: Dl } = u64.add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0)); + ({ h: Eh, l: El } = u64.add(this.Eh | 0, this.El | 0, Eh | 0, El | 0)); + ({ h: Fh, l: Fl } = u64.add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0)); + ({ h: Gh, l: Gl } = u64.add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0)); + ({ h: Hh, l: Hl } = u64.add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0)); + this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl); + } + protected roundClean(): void { + clean(SHA512_W_H, SHA512_W_L); + } + destroy(): void { + clean(this.buffer); + this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + } +} + +export class SHA384 extends SHA512 { + protected Ah: number = SHA384_IV[0] | 0; + protected Al: number = SHA384_IV[1] | 0; + protected Bh: number = SHA384_IV[2] | 0; + protected Bl: number = SHA384_IV[3] | 0; + protected Ch: number = SHA384_IV[4] | 0; + protected Cl: number = SHA384_IV[5] | 0; + protected Dh: number = SHA384_IV[6] | 0; + protected Dl: number = SHA384_IV[7] | 0; + protected Eh: number = SHA384_IV[8] | 0; + protected El: number = SHA384_IV[9] | 0; + protected Fh: number = SHA384_IV[10] | 0; + protected Fl: number = SHA384_IV[11] | 0; + protected Gh: number = SHA384_IV[12] | 0; + protected Gl: number = SHA384_IV[13] | 0; + protected Hh: number = SHA384_IV[14] | 0; + protected Hl: number = SHA384_IV[15] | 0; + + constructor() { + super(48); + } +} + +/** + * Truncated SHA512/256 and SHA512/224. + * SHA512_IV is XORed with 0xa5a5a5a5a5a5a5a5, then used as "intermediary" IV of SHA512/t. + * Then t hashes string to produce result IV. + * See `test/misc/sha2-gen-iv.js`. + */ + +/** SHA512/224 IV */ +const T224_IV = /* @__PURE__ */ Uint32Array.from([ + 0x8c3d37c8, 0x19544da2, 0x73e19966, 0x89dcd4d6, 0x1dfab7ae, 0x32ff9c82, 0x679dd514, 0x582f9fcf, + 0x0f6d2b69, 0x7bd44da8, 0x77e36f73, 0x04c48942, 0x3f9d85a8, 0x6a1d36c8, 0x1112e6ad, 0x91d692a1, +]); + +/** SHA512/256 IV */ +const T256_IV = /* @__PURE__ */ Uint32Array.from([ + 0x22312194, 0xfc2bf72c, 0x9f555fa3, 0xc84c64c2, 0x2393b86b, 0x6f53b151, 0x96387719, 0x5940eabd, + 0x96283ee2, 0xa88effe3, 0xbe5e1e25, 0x53863992, 0x2b0199fc, 0x2c85b8aa, 0x0eb72ddc, 0x81c52ca2, +]); + +export class SHA512_224 extends SHA512 { + protected Ah: number = T224_IV[0] | 0; + protected Al: number = T224_IV[1] | 0; + protected Bh: number = T224_IV[2] | 0; + protected Bl: number = T224_IV[3] | 0; + protected Ch: number = T224_IV[4] | 0; + protected Cl: number = T224_IV[5] | 0; + protected Dh: number = T224_IV[6] | 0; + protected Dl: number = T224_IV[7] | 0; + protected Eh: number = T224_IV[8] | 0; + protected El: number = T224_IV[9] | 0; + protected Fh: number = T224_IV[10] | 0; + protected Fl: number = T224_IV[11] | 0; + protected Gh: number = T224_IV[12] | 0; + protected Gl: number = T224_IV[13] | 0; + protected Hh: number = T224_IV[14] | 0; + protected Hl: number = T224_IV[15] | 0; + + constructor() { + super(28); + } +} + +export class SHA512_256 extends SHA512 { + protected Ah: number = T256_IV[0] | 0; + protected Al: number = T256_IV[1] | 0; + protected Bh: number = T256_IV[2] | 0; + protected Bl: number = T256_IV[3] | 0; + protected Ch: number = T256_IV[4] | 0; + protected Cl: number = T256_IV[5] | 0; + protected Dh: number = T256_IV[6] | 0; + protected Dl: number = T256_IV[7] | 0; + protected Eh: number = T256_IV[8] | 0; + protected El: number = T256_IV[9] | 0; + protected Fh: number = T256_IV[10] | 0; + protected Fl: number = T256_IV[11] | 0; + protected Gh: number = T256_IV[12] | 0; + protected Gl: number = T256_IV[13] | 0; + protected Hh: number = T256_IV[14] | 0; + protected Hl: number = T256_IV[15] | 0; + + constructor() { + super(32); + } +} + +/** + * SHA2-256 hash function from RFC 4634. + * + * It is the fastest JS hash, even faster than Blake3. + * To break sha256 using birthday attack, attackers need to try 2^128 hashes. + * BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025. + */ +export const sha256: CHash = /* @__PURE__ */ createHasher(() => new SHA256()); +/** SHA2-224 hash function from RFC 4634 */ +export const sha224: CHash = /* @__PURE__ */ createHasher(() => new SHA224()); + +/** SHA2-512 hash function from RFC 4634. */ +export const sha512: CHash = /* @__PURE__ */ createHasher(() => new SHA512()); +/** SHA2-384 hash function from RFC 4634. */ +export const sha384: CHash = /* @__PURE__ */ createHasher(() => new SHA384()); + +/** + * SHA2-512/256 "truncated" hash function, with improved resistance to length extension attacks. + * See the paper on [truncated SHA512](https://eprint.iacr.org/2010/548.pdf). + */ +export const sha512_256: CHash = /* @__PURE__ */ createHasher(() => new SHA512_256()); +/** + * SHA2-512/224 "truncated" hash function, with improved resistance to length extension attacks. + * See the paper on [truncated SHA512](https://eprint.iacr.org/2010/548.pdf). + */ +export const sha512_224: CHash = /* @__PURE__ */ createHasher(() => new SHA512_224()); diff --git a/node_modules/@noble/hashes/src/sha256.ts b/node_modules/@noble/hashes/src/sha256.ts new file mode 100644 index 0000000000000000000000000000000000000000..61ea0eb282df16308e690feb11f985289ff29889 --- /dev/null +++ b/node_modules/@noble/hashes/src/sha256.ts @@ -0,0 +1,24 @@ +/** + * SHA2-256 a.k.a. sha256. In JS, it is the fastest hash, even faster than Blake3. + * + * To break sha256 using birthday attack, attackers need to try 2^128 hashes. + * BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025. + * + * Check out [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf). + * @module + * @deprecated + */ +import { + SHA224 as SHA224n, + sha224 as sha224n, + SHA256 as SHA256n, + sha256 as sha256n, +} from './sha2.ts'; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export const SHA256: typeof SHA256n = SHA256n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export const sha256: typeof sha256n = sha256n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export const SHA224: typeof SHA224n = SHA224n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export const sha224: typeof sha224n = sha224n; diff --git a/node_modules/@noble/hashes/src/sha3-addons.ts b/node_modules/@noble/hashes/src/sha3-addons.ts new file mode 100644 index 0000000000000000000000000000000000000000..724a769c57939c356395aeb65a255ee8082afd05 --- /dev/null +++ b/node_modules/@noble/hashes/src/sha3-addons.ts @@ -0,0 +1,499 @@ +/** + * SHA3 (keccak) addons. + * + * * Full [NIST SP 800-185](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-185.pdf): + * cSHAKE, KMAC, TupleHash, ParallelHash + XOF variants + * * Reduced-round Keccak [(draft)](https://datatracker.ietf.org/doc/draft-irtf-cfrg-kangarootwelve/): + * * 🦘 K12 aka KangarooTwelve + * * M14 aka MarsupilamiFourteen + * * TurboSHAKE + * * KeccakPRG: Pseudo-random generator based on Keccak [(pdf)](https://keccak.team/files/CSF-0.1.pdf) + * @module + */ +import { Keccak, type ShakeOpts } from './sha3.ts'; +import { + abytes, + anumber, + type CHashO, + type CHashXO, + createOptHasher, + createXOFer, + Hash, + type HashXOF, + type Input, + toBytes, + u32, +} from './utils.ts'; + +// cSHAKE && KMAC (NIST SP800-185) +const _8n = BigInt(8); +const _ffn = BigInt(0xff); + +// NOTE: it is safe to use bigints here, since they used only for length encoding (not actual data). +// We use bigints in sha256 for lengths too. +function leftEncode(n: number | bigint): Uint8Array { + n = BigInt(n); + const res = [Number(n & _ffn)]; + n >>= _8n; + for (; n > 0; n >>= _8n) res.unshift(Number(n & _ffn)); + res.unshift(res.length); + return new Uint8Array(res); +} + +function rightEncode(n: number | bigint): Uint8Array { + n = BigInt(n); + const res = [Number(n & _ffn)]; + n >>= _8n; + for (; n > 0; n >>= _8n) res.unshift(Number(n & _ffn)); + res.push(res.length); + return new Uint8Array(res); +} + +function chooseLen(opts: ShakeOpts, outputLen: number): number { + return opts.dkLen === undefined ? outputLen : opts.dkLen; +} + +const abytesOrZero = (buf?: Input) => { + if (buf === undefined) return Uint8Array.of(); + return toBytes(buf); +}; +// NOTE: second modulo is necessary since we don't need to add padding if current element takes whole block +const getPadding = (len: number, block: number) => new Uint8Array((block - (len % block)) % block); +export type cShakeOpts = ShakeOpts & { personalization?: Input; NISTfn?: Input }; + +// Personalization +function cshakePers(hash: Keccak, opts: cShakeOpts = {}): Keccak { + if (!opts || (!opts.personalization && !opts.NISTfn)) return hash; + // Encode and pad inplace to avoid unneccesary memory copies/slices (so we don't need to zero them later) + // bytepad(encode_string(N) || encode_string(S), 168) + const blockLenBytes = leftEncode(hash.blockLen); + const fn = abytesOrZero(opts.NISTfn); + const fnLen = leftEncode(_8n * BigInt(fn.length)); // length in bits + const pers = abytesOrZero(opts.personalization); + const persLen = leftEncode(_8n * BigInt(pers.length)); // length in bits + if (!fn.length && !pers.length) return hash; + hash.suffix = 0x04; + hash.update(blockLenBytes).update(fnLen).update(fn).update(persLen).update(pers); + let totalLen = blockLenBytes.length + fnLen.length + fn.length + persLen.length + pers.length; + hash.update(getPadding(totalLen, hash.blockLen)); + return hash; +} + +const gencShake = (suffix: number, blockLen: number, outputLen: number) => + createXOFer((opts: cShakeOpts = {}) => + cshakePers(new Keccak(blockLen, suffix, chooseLen(opts, outputLen), true), opts) + ); + +// TODO: refactor +export type ICShake = { + (msg: Input, opts?: cShakeOpts): Uint8Array; + outputLen: number; + blockLen: number; + create(opts: cShakeOpts): HashXOF; +}; +export type ITupleHash = { + (messages: Input[], opts?: cShakeOpts): Uint8Array; + create(opts?: cShakeOpts): TupleHash; +}; +export type IParHash = { + (message: Input, opts?: ParallelOpts): Uint8Array; + create(opts?: ParallelOpts): ParallelHash; +}; +export const cshake128: ICShake = /* @__PURE__ */ (() => gencShake(0x1f, 168, 128 / 8))(); +export const cshake256: ICShake = /* @__PURE__ */ (() => gencShake(0x1f, 136, 256 / 8))(); + +export class KMAC extends Keccak implements HashXOF { + constructor( + blockLen: number, + outputLen: number, + enableXOF: boolean, + key: Input, + opts: cShakeOpts = {} + ) { + super(blockLen, 0x1f, outputLen, enableXOF); + cshakePers(this, { NISTfn: 'KMAC', personalization: opts.personalization }); + key = toBytes(key); + abytes(key); + // 1. newX = bytepad(encode_string(K), 168) || X || right_encode(L). + const blockLenBytes = leftEncode(this.blockLen); + const keyLen = leftEncode(_8n * BigInt(key.length)); + this.update(blockLenBytes).update(keyLen).update(key); + const totalLen = blockLenBytes.length + keyLen.length + key.length; + this.update(getPadding(totalLen, this.blockLen)); + } + protected finish(): void { + if (!this.finished) this.update(rightEncode(this.enableXOF ? 0 : _8n * BigInt(this.outputLen))); // outputLen in bits + super.finish(); + } + _cloneInto(to?: KMAC): KMAC { + // Create new instance without calling constructor since key already in state and we don't know it. + // Force "to" to be instance of KMAC instead of Sha3. + if (!to) { + to = Object.create(Object.getPrototypeOf(this), {}) as KMAC; + to.state = this.state.slice(); + to.blockLen = this.blockLen; + to.state32 = u32(to.state); + } + return super._cloneInto(to) as KMAC; + } + clone(): KMAC { + return this._cloneInto(); + } +} + +function genKmac(blockLen: number, outputLen: number, xof = false) { + const kmac = (key: Input, message: Input, opts?: cShakeOpts): Uint8Array => + kmac.create(key, opts).update(message).digest(); + kmac.create = (key: Input, opts: cShakeOpts = {}) => + new KMAC(blockLen, chooseLen(opts, outputLen), xof, key, opts); + return kmac; +} + +export const kmac128: { + (key: Input, message: Input, opts?: cShakeOpts): Uint8Array; + create(key: Input, opts?: cShakeOpts): KMAC; +} = /* @__PURE__ */ (() => genKmac(168, 128 / 8))(); +export const kmac256: { + (key: Input, message: Input, opts?: cShakeOpts): Uint8Array; + create(key: Input, opts?: cShakeOpts): KMAC; +} = /* @__PURE__ */ (() => genKmac(136, 256 / 8))(); +export const kmac128xof: { + (key: Input, message: Input, opts?: cShakeOpts): Uint8Array; + create(key: Input, opts?: cShakeOpts): KMAC; +} = /* @__PURE__ */ (() => genKmac(168, 128 / 8, true))(); +export const kmac256xof: { + (key: Input, message: Input, opts?: cShakeOpts): Uint8Array; + create(key: Input, opts?: cShakeOpts): KMAC; +} = /* @__PURE__ */ (() => genKmac(136, 256 / 8, true))(); + +// TupleHash +// Usage: tuple(['ab', 'cd']) != tuple(['a', 'bcd']) +export class TupleHash extends Keccak implements HashXOF { + constructor(blockLen: number, outputLen: number, enableXOF: boolean, opts: cShakeOpts = {}) { + super(blockLen, 0x1f, outputLen, enableXOF); + cshakePers(this, { NISTfn: 'TupleHash', personalization: opts.personalization }); + // Change update after cshake processed + this.update = (data: Input) => { + data = toBytes(data); + abytes(data); + super.update(leftEncode(_8n * BigInt(data.length))); + super.update(data); + return this; + }; + } + protected finish(): void { + if (!this.finished) + super.update(rightEncode(this.enableXOF ? 0 : _8n * BigInt(this.outputLen))); // outputLen in bits + super.finish(); + } + _cloneInto(to?: TupleHash): TupleHash { + to ||= new TupleHash(this.blockLen, this.outputLen, this.enableXOF); + return super._cloneInto(to) as TupleHash; + } + clone(): TupleHash { + return this._cloneInto(); + } +} + +function genTuple(blockLen: number, outputLen: number, xof = false) { + const tuple = (messages: Input[], opts?: cShakeOpts): Uint8Array => { + const h = tuple.create(opts); + for (const msg of messages) h.update(msg); + return h.digest(); + }; + tuple.create = (opts: cShakeOpts = {}) => + new TupleHash(blockLen, chooseLen(opts, outputLen), xof, opts); + return tuple; +} + +/** 128-bit TupleHASH. */ +export const tuplehash128: ITupleHash = /* @__PURE__ */ (() => genTuple(168, 128 / 8))(); +/** 256-bit TupleHASH. */ +export const tuplehash256: ITupleHash = /* @__PURE__ */ (() => genTuple(136, 256 / 8))(); +/** 128-bit TupleHASH XOF. */ +export const tuplehash128xof: ITupleHash = /* @__PURE__ */ (() => genTuple(168, 128 / 8, true))(); +/** 256-bit TupleHASH XOF. */ +export const tuplehash256xof: ITupleHash = /* @__PURE__ */ (() => genTuple(136, 256 / 8, true))(); + +// ParallelHash (same as K12/M14, but without speedup for inputs less 8kb, reduced number of rounds and more simple) +type ParallelOpts = cShakeOpts & { blockLen?: number }; + +export class ParallelHash extends Keccak implements HashXOF { + private leafHash?: Hash; + protected leafCons: () => Hash; + private chunkPos = 0; // Position of current block in chunk + private chunksDone = 0; // How many chunks we already have + private chunkLen: number; + constructor( + blockLen: number, + outputLen: number, + leafCons: () => Hash, + enableXOF: boolean, + opts: ParallelOpts = {} + ) { + super(blockLen, 0x1f, outputLen, enableXOF); + cshakePers(this, { NISTfn: 'ParallelHash', personalization: opts.personalization }); + this.leafCons = leafCons; + let { blockLen: B } = opts; + B ||= 8; + anumber(B); + this.chunkLen = B; + super.update(leftEncode(B)); + // Change update after cshake processed + this.update = (data: Input) => { + data = toBytes(data); + abytes(data); + const { chunkLen, leafCons } = this; + for (let pos = 0, len = data.length; pos < len; ) { + if (this.chunkPos == chunkLen || !this.leafHash) { + if (this.leafHash) { + super.update(this.leafHash.digest()); + this.chunksDone++; + } + this.leafHash = leafCons(); + this.chunkPos = 0; + } + const take = Math.min(chunkLen - this.chunkPos, len - pos); + this.leafHash.update(data.subarray(pos, pos + take)); + this.chunkPos += take; + pos += take; + } + return this; + }; + } + protected finish(): void { + if (this.finished) return; + if (this.leafHash) { + super.update(this.leafHash.digest()); + this.chunksDone++; + } + super.update(rightEncode(this.chunksDone)); + super.update(rightEncode(this.enableXOF ? 0 : _8n * BigInt(this.outputLen))); // outputLen in bits + super.finish(); + } + _cloneInto(to?: ParallelHash): ParallelHash { + to ||= new ParallelHash(this.blockLen, this.outputLen, this.leafCons, this.enableXOF); + if (this.leafHash) to.leafHash = this.leafHash._cloneInto(to.leafHash as Keccak); + to.chunkPos = this.chunkPos; + to.chunkLen = this.chunkLen; + to.chunksDone = this.chunksDone; + return super._cloneInto(to) as ParallelHash; + } + destroy(): void { + super.destroy.call(this); + if (this.leafHash) this.leafHash.destroy(); + } + clone(): ParallelHash { + return this._cloneInto(); + } +} + +function genPrl( + blockLen: number, + outputLen: number, + leaf: ReturnType, + xof = false +) { + const parallel = (message: Input, opts?: ParallelOpts): Uint8Array => + parallel.create(opts).update(message).digest(); + parallel.create = (opts: ParallelOpts = {}) => + new ParallelHash( + blockLen, + chooseLen(opts, outputLen), + () => leaf.create({ dkLen: 2 * outputLen }), + xof, + opts + ); + return parallel; +} + +/** 128-bit ParallelHash. In JS, it is not parallel. */ +export const parallelhash128: IParHash = /* @__PURE__ */ (() => genPrl(168, 128 / 8, cshake128))(); +/** 256-bit ParallelHash. In JS, it is not parallel. */ +export const parallelhash256: IParHash = /* @__PURE__ */ (() => genPrl(136, 256 / 8, cshake256))(); +/** 128-bit ParallelHash XOF. In JS, it is not parallel. */ +export const parallelhash128xof: IParHash = /* @__PURE__ */ (() => + genPrl(168, 128 / 8, cshake128, true))(); +/** 256-bit ParallelHash. In JS, it is not parallel. */ +export const parallelhash256xof: IParHash = /* @__PURE__ */ (() => + genPrl(136, 256 / 8, cshake256, true))(); + +// Should be simple 'shake with 12 rounds', but no, we got whole new spec about Turbo SHAKE Pro MAX. +export type TurboshakeOpts = ShakeOpts & { + D?: number; // Domain separation byte +}; + +const genTurboshake = (blockLen: number, outputLen: number) => + createXOFer, TurboshakeOpts>((opts: TurboshakeOpts = {}) => { + const D = opts.D === undefined ? 0x1f : opts.D; + // Section 2.1 of https://datatracker.ietf.org/doc/draft-irtf-cfrg-kangarootwelve/ + if (!Number.isSafeInteger(D) || D < 0x01 || D > 0x7f) + throw new Error('invalid domain separation byte must be 0x01..0x7f, got: ' + D); + return new Keccak(blockLen, D, opts.dkLen === undefined ? outputLen : opts.dkLen, true, 12); + }); + +/** TurboSHAKE 128-bit: reduced 12-round keccak. */ +export const turboshake128: CHashXO = /* @__PURE__ */ genTurboshake(168, 256 / 8); +/** TurboSHAKE 256-bit: reduced 12-round keccak. */ +export const turboshake256: CHashXO = /* @__PURE__ */ genTurboshake(136, 512 / 8); + +// Kangaroo +// Same as NIST rightEncode, but returns [0] for zero string +function rightEncodeK12(n: number | bigint): Uint8Array { + n = BigInt(n); + const res: number[] = []; + for (; n > 0; n >>= _8n) res.unshift(Number(n & _ffn)); + res.push(res.length); + return Uint8Array.from(res); +} + +export type KangarooOpts = { dkLen?: number; personalization?: Input }; +const EMPTY_BUFFER = /* @__PURE__ */ Uint8Array.of(); + +export class KangarooTwelve extends Keccak implements HashXOF { + readonly chunkLen = 8192; + private leafHash?: Keccak; + protected leafLen: number; + private personalization: Uint8Array; + private chunkPos = 0; // Position of current block in chunk + private chunksDone = 0; // How many chunks we already have + constructor( + blockLen: number, + leafLen: number, + outputLen: number, + rounds: number, + opts: KangarooOpts + ) { + super(blockLen, 0x07, outputLen, true, rounds); + this.leafLen = leafLen; + this.personalization = abytesOrZero(opts.personalization); + } + update(data: Input): this { + data = toBytes(data); + abytes(data); + const { chunkLen, blockLen, leafLen, rounds } = this; + for (let pos = 0, len = data.length; pos < len; ) { + if (this.chunkPos == chunkLen) { + if (this.leafHash) super.update(this.leafHash.digest()); + else { + this.suffix = 0x06; // Its safe to change suffix here since its used only in digest() + super.update(Uint8Array.from([3, 0, 0, 0, 0, 0, 0, 0])); + } + this.leafHash = new Keccak(blockLen, 0x0b, leafLen, false, rounds); + this.chunksDone++; + this.chunkPos = 0; + } + const take = Math.min(chunkLen - this.chunkPos, len - pos); + const chunk = data.subarray(pos, pos + take); + if (this.leafHash) this.leafHash.update(chunk); + else super.update(chunk); + this.chunkPos += take; + pos += take; + } + return this; + } + protected finish(): void { + if (this.finished) return; + const { personalization } = this; + this.update(personalization).update(rightEncodeK12(personalization.length)); + // Leaf hash + if (this.leafHash) { + super.update(this.leafHash.digest()); + super.update(rightEncodeK12(this.chunksDone)); + super.update(Uint8Array.from([0xff, 0xff])); + } + super.finish.call(this); + } + destroy(): void { + super.destroy.call(this); + if (this.leafHash) this.leafHash.destroy(); + // We cannot zero personalization buffer since it is user provided and we don't want to mutate user input + this.personalization = EMPTY_BUFFER; + } + _cloneInto(to?: KangarooTwelve): KangarooTwelve { + const { blockLen, leafLen, leafHash, outputLen, rounds } = this; + to ||= new KangarooTwelve(blockLen, leafLen, outputLen, rounds, {}); + super._cloneInto(to); + if (leafHash) to.leafHash = leafHash._cloneInto(to.leafHash); + to.personalization.set(this.personalization); + to.leafLen = this.leafLen; + to.chunkPos = this.chunkPos; + to.chunksDone = this.chunksDone; + return to; + } + clone(): KangarooTwelve { + return this._cloneInto(); + } +} +/** KangarooTwelve: reduced 12-round keccak. */ +export const k12: CHashO = /* @__PURE__ */ (() => + createOptHasher( + (opts: KangarooOpts = {}) => new KangarooTwelve(168, 32, chooseLen(opts, 32), 12, opts) + ))(); +/** MarsupilamiFourteen: reduced 14-round keccak. */ +export const m14: CHashO = /* @__PURE__ */ (() => + createOptHasher( + (opts: KangarooOpts = {}) => new KangarooTwelve(136, 64, chooseLen(opts, 64), 14, opts) + ))(); + +/** + * More at https://github.com/XKCP/XKCP/tree/master/lib/high/Keccak/PRG. + */ +export class KeccakPRG extends Keccak { + protected rate: number; + constructor(capacity: number) { + anumber(capacity); + // Rho should be full bytes + if (capacity < 0 || capacity > 1600 - 10 || (1600 - capacity - 2) % 8) + throw new Error('invalid capacity'); + // blockLen = rho in bytes + super((1600 - capacity - 2) / 8, 0, 0, true); + this.rate = 1600 - capacity; + this.posOut = Math.floor((this.rate + 7) / 8); + } + keccak(): void { + // Duplex padding + this.state[this.pos] ^= 0x01; + this.state[this.blockLen] ^= 0x02; // Rho is full bytes + super.keccak(); + this.pos = 0; + this.posOut = 0; + } + update(data: Input): this { + super.update(data); + this.posOut = this.blockLen; + return this; + } + feed(data: Input): this { + return this.update(data); + } + protected finish(): void {} + digestInto(_out: Uint8Array): Uint8Array { + throw new Error('digest is not allowed, use .fetch instead'); + } + fetch(bytes: number): Uint8Array { + return this.xof(bytes); + } + // Ensure irreversibility (even if state leaked previous outputs cannot be computed) + forget(): void { + if (this.rate < 1600 / 2 + 1) throw new Error('rate is too low to use .forget()'); + this.keccak(); + for (let i = 0; i < this.blockLen; i++) this.state[i] = 0; + this.pos = this.blockLen; + this.keccak(); + this.posOut = this.blockLen; + } + _cloneInto(to?: KeccakPRG): KeccakPRG { + const { rate } = this; + to ||= new KeccakPRG(1600 - rate); + super._cloneInto(to); + to.rate = rate; + return to; + } + clone(): KeccakPRG { + return this._cloneInto(); + } +} + +/** KeccakPRG: Pseudo-random generator based on Keccak. https://keccak.team/files/CSF-0.1.pdf */ +export const keccakprg = (capacity = 254): KeccakPRG => new KeccakPRG(capacity); diff --git a/node_modules/@noble/hashes/src/sha3.ts b/node_modules/@noble/hashes/src/sha3.ts new file mode 100644 index 0000000000000000000000000000000000000000..bb7b67631cbf629bdb4d4f986f833043b69e8a93 --- /dev/null +++ b/node_modules/@noble/hashes/src/sha3.ts @@ -0,0 +1,258 @@ +/** + * SHA3 (keccak) hash function, based on a new "Sponge function" design. + * Different from older hashes, the internal state is bigger than output size. + * + * Check out [FIPS-202](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf), + * [Website](https://keccak.team/keccak.html), + * [the differences between SHA-3 and Keccak](https://crypto.stackexchange.com/questions/15727/what-are-the-key-differences-between-the-draft-sha-3-standard-and-the-keccak-sub). + * + * Check out `sha3-addons` module for cSHAKE, k12, and others. + * @module + */ +import { rotlBH, rotlBL, rotlSH, rotlSL, split } from './_u64.ts'; +// prettier-ignore +import { + abytes, aexists, anumber, aoutput, + clean, createHasher, createXOFer, Hash, + swap32IfBE, + toBytes, u32, + type CHash, type CHashXO, type HashXOF, type Input +} from './utils.ts'; + +// No __PURE__ annotations in sha3 header: +// EVERYTHING is in fact used on every export. +// Various per round constants calculations +const _0n = BigInt(0); +const _1n = BigInt(1); +const _2n = BigInt(2); +const _7n = BigInt(7); +const _256n = BigInt(256); +const _0x71n = BigInt(0x71); +const SHA3_PI: number[] = []; +const SHA3_ROTL: number[] = []; +const _SHA3_IOTA: bigint[] = []; +for (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) { + // Pi + [x, y] = [y, (2 * x + 3 * y) % 5]; + SHA3_PI.push(2 * (5 * y + x)); + // Rotational + SHA3_ROTL.push((((round + 1) * (round + 2)) / 2) % 64); + // Iota + let t = _0n; + for (let j = 0; j < 7; j++) { + R = ((R << _1n) ^ ((R >> _7n) * _0x71n)) % _256n; + if (R & _2n) t ^= _1n << ((_1n << /* @__PURE__ */ BigInt(j)) - _1n); + } + _SHA3_IOTA.push(t); +} +const IOTAS = split(_SHA3_IOTA, true); +const SHA3_IOTA_H = IOTAS[0]; +const SHA3_IOTA_L = IOTAS[1]; + +// Left rotation (without 0, 32, 64) +const rotlH = (h: number, l: number, s: number) => (s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s)); +const rotlL = (h: number, l: number, s: number) => (s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s)); + +/** `keccakf1600` internal function, additionally allows to adjust round count. */ +export function keccakP(s: Uint32Array, rounds: number = 24): void { + const B = new Uint32Array(5 * 2); + // NOTE: all indices are x2 since we store state as u32 instead of u64 (bigints to slow in js) + for (let round = 24 - rounds; round < 24; round++) { + // Theta θ + for (let x = 0; x < 10; x++) B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40]; + for (let x = 0; x < 10; x += 2) { + const idx1 = (x + 8) % 10; + const idx0 = (x + 2) % 10; + const B0 = B[idx0]; + const B1 = B[idx0 + 1]; + const Th = rotlH(B0, B1, 1) ^ B[idx1]; + const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1]; + for (let y = 0; y < 50; y += 10) { + s[x + y] ^= Th; + s[x + y + 1] ^= Tl; + } + } + // Rho (ρ) and Pi (π) + let curH = s[2]; + let curL = s[3]; + for (let t = 0; t < 24; t++) { + const shift = SHA3_ROTL[t]; + const Th = rotlH(curH, curL, shift); + const Tl = rotlL(curH, curL, shift); + const PI = SHA3_PI[t]; + curH = s[PI]; + curL = s[PI + 1]; + s[PI] = Th; + s[PI + 1] = Tl; + } + // Chi (χ) + for (let y = 0; y < 50; y += 10) { + for (let x = 0; x < 10; x++) B[x] = s[y + x]; + for (let x = 0; x < 10; x++) s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10]; + } + // Iota (ι) + s[0] ^= SHA3_IOTA_H[round]; + s[1] ^= SHA3_IOTA_L[round]; + } + clean(B); +} + +/** Keccak sponge function. */ +export class Keccak extends Hash implements HashXOF { + protected state: Uint8Array; + protected pos = 0; + protected posOut = 0; + protected finished = false; + protected state32: Uint32Array; + protected destroyed = false; + + public blockLen: number; + public suffix: number; + public outputLen: number; + protected enableXOF = false; + protected rounds: number; + + // NOTE: we accept arguments in bytes instead of bits here. + constructor( + blockLen: number, + suffix: number, + outputLen: number, + enableXOF = false, + rounds: number = 24 + ) { + super(); + this.blockLen = blockLen; + this.suffix = suffix; + this.outputLen = outputLen; + this.enableXOF = enableXOF; + this.rounds = rounds; + // Can be passed from user as dkLen + anumber(outputLen); + // 1600 = 5x5 matrix of 64bit. 1600 bits === 200 bytes + // 0 < blockLen < 200 + if (!(0 < blockLen && blockLen < 200)) + throw new Error('only keccak-f1600 function is supported'); + this.state = new Uint8Array(200); + this.state32 = u32(this.state); + } + clone(): Keccak { + return this._cloneInto(); + } + protected keccak(): void { + swap32IfBE(this.state32); + keccakP(this.state32, this.rounds); + swap32IfBE(this.state32); + this.posOut = 0; + this.pos = 0; + } + update(data: Input): this { + aexists(this); + data = toBytes(data); + abytes(data); + const { blockLen, state } = this; + const len = data.length; + for (let pos = 0; pos < len; ) { + const take = Math.min(blockLen - this.pos, len - pos); + for (let i = 0; i < take; i++) state[this.pos++] ^= data[pos++]; + if (this.pos === blockLen) this.keccak(); + } + return this; + } + protected finish(): void { + if (this.finished) return; + this.finished = true; + const { state, suffix, pos, blockLen } = this; + // Do the padding + state[pos] ^= suffix; + if ((suffix & 0x80) !== 0 && pos === blockLen - 1) this.keccak(); + state[blockLen - 1] ^= 0x80; + this.keccak(); + } + protected writeInto(out: Uint8Array): Uint8Array { + aexists(this, false); + abytes(out); + this.finish(); + const bufferOut = this.state; + const { blockLen } = this; + for (let pos = 0, len = out.length; pos < len; ) { + if (this.posOut >= blockLen) this.keccak(); + const take = Math.min(blockLen - this.posOut, len - pos); + out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos); + this.posOut += take; + pos += take; + } + return out; + } + xofInto(out: Uint8Array): Uint8Array { + // Sha3/Keccak usage with XOF is probably mistake, only SHAKE instances can do XOF + if (!this.enableXOF) throw new Error('XOF is not possible for this instance'); + return this.writeInto(out); + } + xof(bytes: number): Uint8Array { + anumber(bytes); + return this.xofInto(new Uint8Array(bytes)); + } + digestInto(out: Uint8Array): Uint8Array { + aoutput(out, this); + if (this.finished) throw new Error('digest() was already called'); + this.writeInto(out); + this.destroy(); + return out; + } + digest(): Uint8Array { + return this.digestInto(new Uint8Array(this.outputLen)); + } + destroy(): void { + this.destroyed = true; + clean(this.state); + } + _cloneInto(to?: Keccak): Keccak { + const { blockLen, suffix, outputLen, rounds, enableXOF } = this; + to ||= new Keccak(blockLen, suffix, outputLen, enableXOF, rounds); + to.state32.set(this.state32); + to.pos = this.pos; + to.posOut = this.posOut; + to.finished = this.finished; + to.rounds = rounds; + // Suffix can change in cSHAKE + to.suffix = suffix; + to.outputLen = outputLen; + to.enableXOF = enableXOF; + to.destroyed = this.destroyed; + return to; + } +} + +const gen = (suffix: number, blockLen: number, outputLen: number) => + createHasher(() => new Keccak(blockLen, suffix, outputLen)); + +/** SHA3-224 hash function. */ +export const sha3_224: CHash = /* @__PURE__ */ (() => gen(0x06, 144, 224 / 8))(); +/** SHA3-256 hash function. Different from keccak-256. */ +export const sha3_256: CHash = /* @__PURE__ */ (() => gen(0x06, 136, 256 / 8))(); +/** SHA3-384 hash function. */ +export const sha3_384: CHash = /* @__PURE__ */ (() => gen(0x06, 104, 384 / 8))(); +/** SHA3-512 hash function. */ +export const sha3_512: CHash = /* @__PURE__ */ (() => gen(0x06, 72, 512 / 8))(); + +/** keccak-224 hash function. */ +export const keccak_224: CHash = /* @__PURE__ */ (() => gen(0x01, 144, 224 / 8))(); +/** keccak-256 hash function. Different from SHA3-256. */ +export const keccak_256: CHash = /* @__PURE__ */ (() => gen(0x01, 136, 256 / 8))(); +/** keccak-384 hash function. */ +export const keccak_384: CHash = /* @__PURE__ */ (() => gen(0x01, 104, 384 / 8))(); +/** keccak-512 hash function. */ +export const keccak_512: CHash = /* @__PURE__ */ (() => gen(0x01, 72, 512 / 8))(); + +export type ShakeOpts = { dkLen?: number }; + +const genShake = (suffix: number, blockLen: number, outputLen: number) => + createXOFer, ShakeOpts>( + (opts: ShakeOpts = {}) => + new Keccak(blockLen, suffix, opts.dkLen === undefined ? outputLen : opts.dkLen, true) + ); + +/** SHAKE128 XOF with 128-bit security. */ +export const shake128: CHashXO = /* @__PURE__ */ (() => genShake(0x1f, 168, 128 / 8))(); +/** SHAKE256 XOF with 256-bit security. */ +export const shake256: CHashXO = /* @__PURE__ */ (() => genShake(0x1f, 136, 256 / 8))(); diff --git a/node_modules/@noble/hashes/src/sha512.ts b/node_modules/@noble/hashes/src/sha512.ts new file mode 100644 index 0000000000000000000000000000000000000000..15bd2523acf6cf76ac2f40c97a4f5b66c7101ea8 --- /dev/null +++ b/node_modules/@noble/hashes/src/sha512.ts @@ -0,0 +1,34 @@ +/** + * SHA2-512 a.k.a. sha512 and sha384. It is slower than sha256 in js because u64 operations are slow. + * + * Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and + * [the paper on truncated SHA512/256](https://eprint.iacr.org/2010/548.pdf). + * @module + * @deprecated + */ +import { + SHA384 as SHA384n, + sha384 as sha384n, + sha512_224 as sha512_224n, + SHA512_224 as SHA512_224n, + sha512_256 as sha512_256n, + SHA512_256 as SHA512_256n, + SHA512 as SHA512n, + sha512 as sha512n, +} from './sha2.ts'; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export const SHA512: typeof SHA512n = SHA512n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export const sha512: typeof sha512n = sha512n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export const SHA384: typeof SHA384n = SHA384n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export const sha384: typeof sha384n = sha384n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export const SHA512_224: typeof SHA512_224n = SHA512_224n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export const sha512_224: typeof sha512_224n = sha512_224n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export const SHA512_256: typeof SHA512_256n = SHA512_256n; +/** @deprecated Use import from `noble/hashes/sha2` module */ +export const sha512_256: typeof sha512_256n = sha512_256n; diff --git a/node_modules/@noble/hashes/src/utils.ts b/node_modules/@noble/hashes/src/utils.ts new file mode 100644 index 0000000000000000000000000000000000000000..4c8a67985ada92bdbce46460c95e6a697c432f58 --- /dev/null +++ b/node_modules/@noble/hashes/src/utils.ts @@ -0,0 +1,395 @@ +/** + * Utilities for hex, bytes, CSPRNG. + * @module + */ +/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */ + +// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+. +// node.js versions earlier than v19 don't declare it in global scope. +// For node.js, package.json#exports field mapping rewrites import +// from `crypto` to `cryptoNode`, which imports native module. +// Makes the utils un-importable in browsers without a bundler. +// Once node.js 18 is deprecated (2025-04-30), we can just drop the import. +import { crypto } from '@noble/hashes/crypto'; + +/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */ +export function isBytes(a: unknown): a is Uint8Array { + return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array'); +} + +/** Asserts something is positive integer. */ +export function anumber(n: number): void { + if (!Number.isSafeInteger(n) || n < 0) throw new Error('positive integer expected, got ' + n); +} + +/** Asserts something is Uint8Array. */ +export function abytes(b: Uint8Array | undefined, ...lengths: number[]): void { + if (!isBytes(b)) throw new Error('Uint8Array expected'); + if (lengths.length > 0 && !lengths.includes(b.length)) + throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length); +} + +/** Asserts something is hash */ +export function ahash(h: IHash): void { + if (typeof h !== 'function' || typeof h.create !== 'function') + throw new Error('Hash should be wrapped by utils.createHasher'); + anumber(h.outputLen); + anumber(h.blockLen); +} + +/** Asserts a hash instance has not been destroyed / finished */ +export function aexists(instance: any, checkFinished = true): void { + if (instance.destroyed) throw new Error('Hash instance has been destroyed'); + if (checkFinished && instance.finished) throw new Error('Hash#digest() has already been called'); +} + +/** Asserts output is properly-sized byte array */ +export function aoutput(out: any, instance: any): void { + abytes(out); + const min = instance.outputLen; + if (out.length < min) { + throw new Error('digestInto() expects output buffer of length at least ' + min); + } +} + +/** Generic type encompassing 8/16/32-byte arrays - but not 64-byte. */ +// prettier-ignore +export type TypedArray = Int8Array | Uint8ClampedArray | Uint8Array | + Uint16Array | Int16Array | Uint32Array | Int32Array; + +/** Cast u8 / u16 / u32 to u8. */ +export function u8(arr: TypedArray): Uint8Array { + return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength); +} + +/** Cast u8 / u16 / u32 to u32. */ +export function u32(arr: TypedArray): Uint32Array { + return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4)); +} + +/** Zeroize a byte array. Warning: JS provides no guarantees. */ +export function clean(...arrays: TypedArray[]): void { + for (let i = 0; i < arrays.length; i++) { + arrays[i].fill(0); + } +} + +/** Create DataView of an array for easy byte-level manipulation. */ +export function createView(arr: TypedArray): DataView { + return new DataView(arr.buffer, arr.byteOffset, arr.byteLength); +} + +/** The rotate right (circular right shift) operation for uint32 */ +export function rotr(word: number, shift: number): number { + return (word << (32 - shift)) | (word >>> shift); +} + +/** The rotate left (circular left shift) operation for uint32 */ +export function rotl(word: number, shift: number): number { + return (word << shift) | ((word >>> (32 - shift)) >>> 0); +} + +/** Is current platform little-endian? Most are. Big-Endian platform: IBM */ +export const isLE: boolean = /* @__PURE__ */ (() => + new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)(); + +/** The byte swap operation for uint32 */ +export function byteSwap(word: number): number { + return ( + ((word << 24) & 0xff000000) | + ((word << 8) & 0xff0000) | + ((word >>> 8) & 0xff00) | + ((word >>> 24) & 0xff) + ); +} +/** Conditionally byte swap if on a big-endian platform */ +export const swap8IfBE: (n: number) => number = isLE + ? (n: number) => n + : (n: number) => byteSwap(n); + +/** @deprecated */ +export const byteSwapIfBE: typeof swap8IfBE = swap8IfBE; +/** In place byte swap for Uint32Array */ +export function byteSwap32(arr: Uint32Array): Uint32Array { + for (let i = 0; i < arr.length; i++) { + arr[i] = byteSwap(arr[i]); + } + return arr; +} + +export const swap32IfBE: (u: Uint32Array) => Uint32Array = isLE + ? (u: Uint32Array) => u + : byteSwap32; + +// Built-in hex conversion https://caniuse.com/mdn-javascript_builtins_uint8array_fromhex +const hasHexBuiltin: boolean = /* @__PURE__ */ (() => + // @ts-ignore + typeof Uint8Array.from([]).toHex === 'function' && typeof Uint8Array.fromHex === 'function')(); + +// Array where index 0xf0 (240) is mapped to string 'f0' +const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => + i.toString(16).padStart(2, '0') +); + +/** + * Convert byte array to hex string. Uses built-in function, when available. + * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123' + */ +export function bytesToHex(bytes: Uint8Array): string { + abytes(bytes); + // @ts-ignore + if (hasHexBuiltin) return bytes.toHex(); + // pre-caching improves the speed 6x + let hex = ''; + for (let i = 0; i < bytes.length; i++) { + hex += hexes[bytes[i]]; + } + return hex; +} + +// We use optimized technique to convert hex string to byte array +const asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 } as const; +function asciiToBase16(ch: number): number | undefined { + if (ch >= asciis._0 && ch <= asciis._9) return ch - asciis._0; // '2' => 50-48 + if (ch >= asciis.A && ch <= asciis.F) return ch - (asciis.A - 10); // 'B' => 66-(65-10) + if (ch >= asciis.a && ch <= asciis.f) return ch - (asciis.a - 10); // 'b' => 98-(97-10) + return; +} + +/** + * Convert hex string to byte array. Uses built-in function, when available. + * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23]) + */ +export function hexToBytes(hex: string): Uint8Array { + if (typeof hex !== 'string') throw new Error('hex string expected, got ' + typeof hex); + // @ts-ignore + if (hasHexBuiltin) return Uint8Array.fromHex(hex); + const hl = hex.length; + const al = hl / 2; + if (hl % 2) throw new Error('hex string expected, got unpadded hex of length ' + hl); + const array = new Uint8Array(al); + for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) { + const n1 = asciiToBase16(hex.charCodeAt(hi)); + const n2 = asciiToBase16(hex.charCodeAt(hi + 1)); + if (n1 === undefined || n2 === undefined) { + const char = hex[hi] + hex[hi + 1]; + throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi); + } + array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163 + } + return array; +} + +/** + * There is no setImmediate in browser and setTimeout is slow. + * Call of async fn will return Promise, which will be fullfiled only on + * next scheduler queue processing step and this is exactly what we need. + */ +export const nextTick = async (): Promise => {}; + +/** Returns control to thread each 'tick' ms to avoid blocking. */ +export async function asyncLoop( + iters: number, + tick: number, + cb: (i: number) => void +): Promise { + let ts = Date.now(); + for (let i = 0; i < iters; i++) { + cb(i); + // Date.now() is not monotonic, so in case if clock goes backwards we return return control too + const diff = Date.now() - ts; + if (diff >= 0 && diff < tick) continue; + await nextTick(); + ts += diff; + } +} + +// Global symbols, but ts doesn't see them: https://github.com/microsoft/TypeScript/issues/31535 +declare const TextEncoder: any; +declare const TextDecoder: any; + +/** + * Converts string to bytes using UTF8 encoding. + * @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99]) + */ +export function utf8ToBytes(str: string): Uint8Array { + if (typeof str !== 'string') throw new Error('string expected'); + return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809 +} + +/** + * Converts bytes to string using UTF8 encoding. + * @example bytesToUtf8(Uint8Array.from([97, 98, 99])) // 'abc' + */ +export function bytesToUtf8(bytes: Uint8Array): string { + return new TextDecoder().decode(bytes); +} + +/** Accepted input of hash functions. Strings are converted to byte arrays. */ +export type Input = string | Uint8Array; +/** + * Normalizes (non-hex) string or Uint8Array to Uint8Array. + * Warning: when Uint8Array is passed, it would NOT get copied. + * Keep in mind for future mutable operations. + */ +export function toBytes(data: Input): Uint8Array { + if (typeof data === 'string') data = utf8ToBytes(data); + abytes(data); + return data; +} + +/** KDFs can accept string or Uint8Array for user convenience. */ +export type KDFInput = string | Uint8Array; +/** + * Helper for KDFs: consumes uint8array or string. + * When string is passed, does utf8 decoding, using TextDecoder. + */ +export function kdfInputToBytes(data: KDFInput): Uint8Array { + if (typeof data === 'string') data = utf8ToBytes(data); + abytes(data); + return data; +} + +/** Copies several Uint8Arrays into one. */ +export function concatBytes(...arrays: Uint8Array[]): Uint8Array { + let sum = 0; + for (let i = 0; i < arrays.length; i++) { + const a = arrays[i]; + abytes(a); + sum += a.length; + } + const res = new Uint8Array(sum); + for (let i = 0, pad = 0; i < arrays.length; i++) { + const a = arrays[i]; + res.set(a, pad); + pad += a.length; + } + return res; +} + +type EmptyObj = {}; +export function checkOpts( + defaults: T1, + opts?: T2 +): T1 & T2 { + if (opts !== undefined && {}.toString.call(opts) !== '[object Object]') + throw new Error('options should be object or undefined'); + const merged = Object.assign(defaults, opts); + return merged as T1 & T2; +} + +/** Hash interface. */ +export type IHash = { + (data: Uint8Array): Uint8Array; + blockLen: number; + outputLen: number; + create: any; +}; + +/** For runtime check if class implements interface */ +export abstract class Hash> { + abstract blockLen: number; // Bytes per block + abstract outputLen: number; // Bytes in output + abstract update(buf: Input): this; + // Writes digest into buf + abstract digestInto(buf: Uint8Array): void; + abstract digest(): Uint8Array; + /** + * Resets internal state. Makes Hash instance unusable. + * Reset is impossible for keyed hashes if key is consumed into state. If digest is not consumed + * by user, they will need to manually call `destroy()` when zeroing is necessary. + */ + abstract destroy(): void; + /** + * Clones hash instance. Unsafe: doesn't check whether `to` is valid. Can be used as `clone()` + * when no options are passed. + * Reasons to use `_cloneInto` instead of clone: 1) performance 2) reuse instance => all internal + * buffers are overwritten => causes buffer overwrite which is used for digest in some cases. + * There are no guarantees for clean-up because it's impossible in JS. + */ + abstract _cloneInto(to?: T): T; + // Safe version that clones internal state + abstract clone(): T; +} + +/** + * XOF: streaming API to read digest in chunks. + * Same as 'squeeze' in keccak/k12 and 'seek' in blake3, but more generic name. + * When hash used in XOF mode it is up to user to call '.destroy' afterwards, since we cannot + * destroy state, next call can require more bytes. + */ +export type HashXOF> = Hash & { + xof(bytes: number): Uint8Array; // Read 'bytes' bytes from digest stream + xofInto(buf: Uint8Array): Uint8Array; // read buf.length bytes from digest stream into buf +}; + +/** Hash function */ +export type CHash = ReturnType; +/** Hash function with output */ +export type CHashO = ReturnType; +/** XOF with output */ +export type CHashXO = ReturnType; + +/** Wraps hash function, creating an interface on top of it */ +export function createHasher>( + hashCons: () => Hash +): { + (msg: Input): Uint8Array; + outputLen: number; + blockLen: number; + create(): Hash; +} { + const hashC = (msg: Input): Uint8Array => hashCons().update(toBytes(msg)).digest(); + const tmp = hashCons(); + hashC.outputLen = tmp.outputLen; + hashC.blockLen = tmp.blockLen; + hashC.create = () => hashCons(); + return hashC; +} + +export function createOptHasher, T extends Object>( + hashCons: (opts?: T) => Hash +): { + (msg: Input, opts?: T): Uint8Array; + outputLen: number; + blockLen: number; + create(opts?: T): Hash; +} { + const hashC = (msg: Input, opts?: T): Uint8Array => hashCons(opts).update(toBytes(msg)).digest(); + const tmp = hashCons({} as T); + hashC.outputLen = tmp.outputLen; + hashC.blockLen = tmp.blockLen; + hashC.create = (opts?: T) => hashCons(opts); + return hashC; +} + +export function createXOFer, T extends Object>( + hashCons: (opts?: T) => HashXOF +): { + (msg: Input, opts?: T): Uint8Array; + outputLen: number; + blockLen: number; + create(opts?: T): HashXOF; +} { + const hashC = (msg: Input, opts?: T): Uint8Array => hashCons(opts).update(toBytes(msg)).digest(); + const tmp = hashCons({} as T); + hashC.outputLen = tmp.outputLen; + hashC.blockLen = tmp.blockLen; + hashC.create = (opts?: T) => hashCons(opts); + return hashC; +} +export const wrapConstructor: typeof createHasher = createHasher; +export const wrapConstructorWithOpts: typeof createOptHasher = createOptHasher; +export const wrapXOFConstructorWithOpts: typeof createXOFer = createXOFer; + +/** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */ +export function randomBytes(bytesLength = 32): Uint8Array { + if (crypto && typeof crypto.getRandomValues === 'function') { + return crypto.getRandomValues(new Uint8Array(bytesLength)); + } + // Legacy Node.js compatibility + if (crypto && typeof crypto.randomBytes === 'function') { + return Uint8Array.from(crypto.randomBytes(bytesLength)); + } + throw new Error('crypto.getRandomValues must be defined'); +} diff --git a/node_modules/@noble/hashes/utils.d.ts b/node_modules/@noble/hashes/utils.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..90b8439bddcad7f8db983ac6a243219c56b8ebe2 --- /dev/null +++ b/node_modules/@noble/hashes/utils.d.ts @@ -0,0 +1,161 @@ +/** + * Utilities for hex, bytes, CSPRNG. + * @module + */ +/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */ +/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */ +export declare function isBytes(a: unknown): a is Uint8Array; +/** Asserts something is positive integer. */ +export declare function anumber(n: number): void; +/** Asserts something is Uint8Array. */ +export declare function abytes(b: Uint8Array | undefined, ...lengths: number[]): void; +/** Asserts something is hash */ +export declare function ahash(h: IHash): void; +/** Asserts a hash instance has not been destroyed / finished */ +export declare function aexists(instance: any, checkFinished?: boolean): void; +/** Asserts output is properly-sized byte array */ +export declare function aoutput(out: any, instance: any): void; +/** Generic type encompassing 8/16/32-byte arrays - but not 64-byte. */ +export type TypedArray = Int8Array | Uint8ClampedArray | Uint8Array | Uint16Array | Int16Array | Uint32Array | Int32Array; +/** Cast u8 / u16 / u32 to u8. */ +export declare function u8(arr: TypedArray): Uint8Array; +/** Cast u8 / u16 / u32 to u32. */ +export declare function u32(arr: TypedArray): Uint32Array; +/** Zeroize a byte array. Warning: JS provides no guarantees. */ +export declare function clean(...arrays: TypedArray[]): void; +/** Create DataView of an array for easy byte-level manipulation. */ +export declare function createView(arr: TypedArray): DataView; +/** The rotate right (circular right shift) operation for uint32 */ +export declare function rotr(word: number, shift: number): number; +/** The rotate left (circular left shift) operation for uint32 */ +export declare function rotl(word: number, shift: number): number; +/** Is current platform little-endian? Most are. Big-Endian platform: IBM */ +export declare const isLE: boolean; +/** The byte swap operation for uint32 */ +export declare function byteSwap(word: number): number; +/** Conditionally byte swap if on a big-endian platform */ +export declare const swap8IfBE: (n: number) => number; +/** @deprecated */ +export declare const byteSwapIfBE: typeof swap8IfBE; +/** In place byte swap for Uint32Array */ +export declare function byteSwap32(arr: Uint32Array): Uint32Array; +export declare const swap32IfBE: (u: Uint32Array) => Uint32Array; +/** + * Convert byte array to hex string. Uses built-in function, when available. + * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123' + */ +export declare function bytesToHex(bytes: Uint8Array): string; +/** + * Convert hex string to byte array. Uses built-in function, when available. + * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23]) + */ +export declare function hexToBytes(hex: string): Uint8Array; +/** + * There is no setImmediate in browser and setTimeout is slow. + * Call of async fn will return Promise, which will be fullfiled only on + * next scheduler queue processing step and this is exactly what we need. + */ +export declare const nextTick: () => Promise; +/** Returns control to thread each 'tick' ms to avoid blocking. */ +export declare function asyncLoop(iters: number, tick: number, cb: (i: number) => void): Promise; +/** + * Converts string to bytes using UTF8 encoding. + * @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99]) + */ +export declare function utf8ToBytes(str: string): Uint8Array; +/** + * Converts bytes to string using UTF8 encoding. + * @example bytesToUtf8(Uint8Array.from([97, 98, 99])) // 'abc' + */ +export declare function bytesToUtf8(bytes: Uint8Array): string; +/** Accepted input of hash functions. Strings are converted to byte arrays. */ +export type Input = string | Uint8Array; +/** + * Normalizes (non-hex) string or Uint8Array to Uint8Array. + * Warning: when Uint8Array is passed, it would NOT get copied. + * Keep in mind for future mutable operations. + */ +export declare function toBytes(data: Input): Uint8Array; +/** KDFs can accept string or Uint8Array for user convenience. */ +export type KDFInput = string | Uint8Array; +/** + * Helper for KDFs: consumes uint8array or string. + * When string is passed, does utf8 decoding, using TextDecoder. + */ +export declare function kdfInputToBytes(data: KDFInput): Uint8Array; +/** Copies several Uint8Arrays into one. */ +export declare function concatBytes(...arrays: Uint8Array[]): Uint8Array; +type EmptyObj = {}; +export declare function checkOpts(defaults: T1, opts?: T2): T1 & T2; +/** Hash interface. */ +export type IHash = { + (data: Uint8Array): Uint8Array; + blockLen: number; + outputLen: number; + create: any; +}; +/** For runtime check if class implements interface */ +export declare abstract class Hash> { + abstract blockLen: number; + abstract outputLen: number; + abstract update(buf: Input): this; + abstract digestInto(buf: Uint8Array): void; + abstract digest(): Uint8Array; + /** + * Resets internal state. Makes Hash instance unusable. + * Reset is impossible for keyed hashes if key is consumed into state. If digest is not consumed + * by user, they will need to manually call `destroy()` when zeroing is necessary. + */ + abstract destroy(): void; + /** + * Clones hash instance. Unsafe: doesn't check whether `to` is valid. Can be used as `clone()` + * when no options are passed. + * Reasons to use `_cloneInto` instead of clone: 1) performance 2) reuse instance => all internal + * buffers are overwritten => causes buffer overwrite which is used for digest in some cases. + * There are no guarantees for clean-up because it's impossible in JS. + */ + abstract _cloneInto(to?: T): T; + abstract clone(): T; +} +/** + * XOF: streaming API to read digest in chunks. + * Same as 'squeeze' in keccak/k12 and 'seek' in blake3, but more generic name. + * When hash used in XOF mode it is up to user to call '.destroy' afterwards, since we cannot + * destroy state, next call can require more bytes. + */ +export type HashXOF> = Hash & { + xof(bytes: number): Uint8Array; + xofInto(buf: Uint8Array): Uint8Array; +}; +/** Hash function */ +export type CHash = ReturnType; +/** Hash function with output */ +export type CHashO = ReturnType; +/** XOF with output */ +export type CHashXO = ReturnType; +/** Wraps hash function, creating an interface on top of it */ +export declare function createHasher>(hashCons: () => Hash): { + (msg: Input): Uint8Array; + outputLen: number; + blockLen: number; + create(): Hash; +}; +export declare function createOptHasher, T extends Object>(hashCons: (opts?: T) => Hash): { + (msg: Input, opts?: T): Uint8Array; + outputLen: number; + blockLen: number; + create(opts?: T): Hash; +}; +export declare function createXOFer, T extends Object>(hashCons: (opts?: T) => HashXOF): { + (msg: Input, opts?: T): Uint8Array; + outputLen: number; + blockLen: number; + create(opts?: T): HashXOF; +}; +export declare const wrapConstructor: typeof createHasher; +export declare const wrapConstructorWithOpts: typeof createOptHasher; +export declare const wrapXOFConstructorWithOpts: typeof createXOFer; +/** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */ +export declare function randomBytes(bytesLength?: number): Uint8Array; +export {}; +//# sourceMappingURL=utils.d.ts.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/utils.d.ts.map b/node_modules/@noble/hashes/utils.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..dd08975d333c17f91de993fe3281938ac95a244a --- /dev/null +++ b/node_modules/@noble/hashes/utils.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,sEAAsE;AAUtE,qFAAqF;AACrF,wBAAgB,OAAO,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,UAAU,CAEnD;AAED,6CAA6C;AAC7C,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAEvC;AAED,uCAAuC;AACvC,wBAAgB,MAAM,CAAC,CAAC,EAAE,UAAU,GAAG,SAAS,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAI5E;AAED,gCAAgC;AAChC,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAKpC;AAED,gEAAgE;AAChE,wBAAgB,OAAO,CAAC,QAAQ,EAAE,GAAG,EAAE,aAAa,UAAO,GAAG,IAAI,CAGjE;AAED,kDAAkD;AAClD,wBAAgB,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,GAAG,IAAI,CAMrD;AAED,uEAAuE;AAEvE,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,iBAAiB,GAAG,UAAU,GACjE,WAAW,GAAG,UAAU,GAAG,WAAW,GAAG,UAAU,CAAC;AAEtD,iCAAiC;AACjC,wBAAgB,EAAE,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,CAE9C;AAED,kCAAkC;AAClC,wBAAgB,GAAG,CAAC,GAAG,EAAE,UAAU,GAAG,WAAW,CAEhD;AAED,gEAAgE;AAChE,wBAAgB,KAAK,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAInD;AAED,oEAAoE;AACpE,wBAAgB,UAAU,CAAC,GAAG,EAAE,UAAU,GAAG,QAAQ,CAEpD;AAED,mEAA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CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,EAChE,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,GACjC;IACD,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CAC9B,CAOA;AACD,eAAO,MAAM,eAAe,EAAE,OAAO,YAA2B,CAAC;AACjE,eAAO,MAAM,uBAAuB,EAAE,OAAO,eAAiC,CAAC;AAC/E,eAAO,MAAM,0BAA0B,EAAE,OAAO,WAAyB,CAAC;AAE1E,sFAAsF;AACtF,wBAAgB,WAAW,CAAC,WAAW,SAAK,GAAG,UAAU,CASxD"} \ No newline at end of file diff --git a/node_modules/@noble/hashes/utils.js b/node_modules/@noble/hashes/utils.js new file mode 100644 index 0000000000000000000000000000000000000000..aed9199852dc91ae3a1a149a64fe806bf697a3ab --- /dev/null +++ b/node_modules/@noble/hashes/utils.js @@ -0,0 +1,313 @@ +"use strict"; +/** + * Utilities for hex, bytes, CSPRNG. + * @module + */ +/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.wrapXOFConstructorWithOpts = exports.wrapConstructorWithOpts = exports.wrapConstructor = exports.Hash = exports.nextTick = exports.swap32IfBE = exports.byteSwapIfBE = exports.swap8IfBE = exports.isLE = void 0; +exports.isBytes = isBytes; +exports.anumber = anumber; +exports.abytes = abytes; +exports.ahash = ahash; +exports.aexists = aexists; +exports.aoutput = aoutput; +exports.u8 = u8; +exports.u32 = u32; +exports.clean = clean; +exports.createView = createView; +exports.rotr = rotr; +exports.rotl = rotl; +exports.byteSwap = byteSwap; +exports.byteSwap32 = byteSwap32; +exports.bytesToHex = bytesToHex; +exports.hexToBytes = hexToBytes; +exports.asyncLoop = asyncLoop; +exports.utf8ToBytes = utf8ToBytes; +exports.bytesToUtf8 = bytesToUtf8; +exports.toBytes = toBytes; +exports.kdfInputToBytes = kdfInputToBytes; +exports.concatBytes = concatBytes; +exports.checkOpts = checkOpts; +exports.createHasher = createHasher; +exports.createOptHasher = createOptHasher; +exports.createXOFer = createXOFer; +exports.randomBytes = randomBytes; +// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+. +// node.js versions earlier than v19 don't declare it in global scope. +// For node.js, package.json#exports field mapping rewrites import +// from `crypto` to `cryptoNode`, which imports native module. +// Makes the utils un-importable in browsers without a bundler. +// Once node.js 18 is deprecated (2025-04-30), we can just drop the import. +const crypto_1 = require("@noble/hashes/crypto"); +/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */ +function isBytes(a) { + return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array'); +} +/** Asserts something is positive integer. */ +function anumber(n) { + if (!Number.isSafeInteger(n) || n < 0) + throw new Error('positive integer expected, got ' + n); +} +/** Asserts something is Uint8Array. */ +function abytes(b, ...lengths) { + if (!isBytes(b)) + throw new Error('Uint8Array expected'); + if (lengths.length > 0 && !lengths.includes(b.length)) + throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length); +} +/** Asserts something is hash */ +function ahash(h) { + if (typeof h !== 'function' || typeof h.create !== 'function') + throw new Error('Hash should be wrapped by utils.createHasher'); + anumber(h.outputLen); + anumber(h.blockLen); +} +/** Asserts a hash instance has not been destroyed / finished */ +function aexists(instance, checkFinished = true) { + if (instance.destroyed) + throw new Error('Hash instance has been destroyed'); + if (checkFinished && instance.finished) + throw new Error('Hash#digest() has already been called'); +} +/** Asserts output is properly-sized byte array */ +function aoutput(out, instance) { + abytes(out); + const min = instance.outputLen; + if (out.length < min) { + throw new Error('digestInto() expects output buffer of length at least ' + min); + } +} +/** Cast u8 / u16 / u32 to u8. */ +function u8(arr) { + return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength); +} +/** Cast u8 / u16 / u32 to u32. */ +function u32(arr) { + return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4)); +} +/** Zeroize a byte array. Warning: JS provides no guarantees. */ +function clean(...arrays) { + for (let i = 0; i < arrays.length; i++) { + arrays[i].fill(0); + } +} +/** Create DataView of an array for easy byte-level manipulation. */ +function createView(arr) { + return new DataView(arr.buffer, arr.byteOffset, arr.byteLength); +} +/** The rotate right (circular right shift) operation for uint32 */ +function rotr(word, shift) { + return (word << (32 - shift)) | (word >>> shift); +} +/** The rotate left (circular left shift) operation for uint32 */ +function rotl(word, shift) { + return (word << shift) | ((word >>> (32 - shift)) >>> 0); +} +/** Is current platform little-endian? Most are. Big-Endian platform: IBM */ +exports.isLE = (() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)(); +/** The byte swap operation for uint32 */ +function byteSwap(word) { + return (((word << 24) & 0xff000000) | + ((word << 8) & 0xff0000) | + ((word >>> 8) & 0xff00) | + ((word >>> 24) & 0xff)); +} +/** Conditionally byte swap if on a big-endian platform */ +exports.swap8IfBE = exports.isLE + ? (n) => n + : (n) => byteSwap(n); +/** @deprecated */ +exports.byteSwapIfBE = exports.swap8IfBE; +/** In place byte swap for Uint32Array */ +function byteSwap32(arr) { + for (let i = 0; i < arr.length; i++) { + arr[i] = byteSwap(arr[i]); + } + return arr; +} +exports.swap32IfBE = exports.isLE + ? (u) => u + : byteSwap32; +// Built-in hex conversion https://caniuse.com/mdn-javascript_builtins_uint8array_fromhex +const hasHexBuiltin = /* @__PURE__ */ (() => +// @ts-ignore +typeof Uint8Array.from([]).toHex === 'function' && typeof Uint8Array.fromHex === 'function')(); +// Array where index 0xf0 (240) is mapped to string 'f0' +const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0')); +/** + * Convert byte array to hex string. Uses built-in function, when available. + * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123' + */ +function bytesToHex(bytes) { + abytes(bytes); + // @ts-ignore + if (hasHexBuiltin) + return bytes.toHex(); + // pre-caching improves the speed 6x + let hex = ''; + for (let i = 0; i < bytes.length; i++) { + hex += hexes[bytes[i]]; + } + return hex; +} +// We use optimized technique to convert hex string to byte array +const asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 }; +function asciiToBase16(ch) { + if (ch >= asciis._0 && ch <= asciis._9) + return ch - asciis._0; // '2' => 50-48 + if (ch >= asciis.A && ch <= asciis.F) + return ch - (asciis.A - 10); // 'B' => 66-(65-10) + if (ch >= asciis.a && ch <= asciis.f) + return ch - (asciis.a - 10); // 'b' => 98-(97-10) + return; +} +/** + * Convert hex string to byte array. Uses built-in function, when available. + * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23]) + */ +function hexToBytes(hex) { + if (typeof hex !== 'string') + throw new Error('hex string expected, got ' + typeof hex); + // @ts-ignore + if (hasHexBuiltin) + return Uint8Array.fromHex(hex); + const hl = hex.length; + const al = hl / 2; + if (hl % 2) + throw new Error('hex string expected, got unpadded hex of length ' + hl); + const array = new Uint8Array(al); + for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) { + const n1 = asciiToBase16(hex.charCodeAt(hi)); + const n2 = asciiToBase16(hex.charCodeAt(hi + 1)); + if (n1 === undefined || n2 === undefined) { + const char = hex[hi] + hex[hi + 1]; + throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi); + } + array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163 + } + return array; +} +/** + * There is no setImmediate in browser and setTimeout is slow. + * Call of async fn will return Promise, which will be fullfiled only on + * next scheduler queue processing step and this is exactly what we need. + */ +const nextTick = async () => { }; +exports.nextTick = nextTick; +/** Returns control to thread each 'tick' ms to avoid blocking. */ +async function asyncLoop(iters, tick, cb) { + let ts = Date.now(); + for (let i = 0; i < iters; i++) { + cb(i); + // Date.now() is not monotonic, so in case if clock goes backwards we return return control too + const diff = Date.now() - ts; + if (diff >= 0 && diff < tick) + continue; + await (0, exports.nextTick)(); + ts += diff; + } +} +/** + * Converts string to bytes using UTF8 encoding. + * @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99]) + */ +function utf8ToBytes(str) { + if (typeof str !== 'string') + throw new Error('string expected'); + return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809 +} +/** + * Converts bytes to string using UTF8 encoding. + * @example bytesToUtf8(Uint8Array.from([97, 98, 99])) // 'abc' + */ +function bytesToUtf8(bytes) { + return new TextDecoder().decode(bytes); +} +/** + * Normalizes (non-hex) string or Uint8Array to Uint8Array. + * Warning: when Uint8Array is passed, it would NOT get copied. + * Keep in mind for future mutable operations. + */ +function toBytes(data) { + if (typeof data === 'string') + data = utf8ToBytes(data); + abytes(data); + return data; +} +/** + * Helper for KDFs: consumes uint8array or string. + * When string is passed, does utf8 decoding, using TextDecoder. + */ +function kdfInputToBytes(data) { + if (typeof data === 'string') + data = utf8ToBytes(data); + abytes(data); + return data; +} +/** Copies several Uint8Arrays into one. */ +function concatBytes(...arrays) { + let sum = 0; + for (let i = 0; i < arrays.length; i++) { + const a = arrays[i]; + abytes(a); + sum += a.length; + } + const res = new Uint8Array(sum); + for (let i = 0, pad = 0; i < arrays.length; i++) { + const a = arrays[i]; + res.set(a, pad); + pad += a.length; + } + return res; +} +function checkOpts(defaults, opts) { + if (opts !== undefined && {}.toString.call(opts) !== '[object Object]') + throw new Error('options should be object or undefined'); + const merged = Object.assign(defaults, opts); + return merged; +} +/** For runtime check if class implements interface */ +class Hash { +} +exports.Hash = Hash; +/** Wraps hash function, creating an interface on top of it */ +function createHasher(hashCons) { + const hashC = (msg) => hashCons().update(toBytes(msg)).digest(); + const tmp = hashCons(); + hashC.outputLen = tmp.outputLen; + hashC.blockLen = tmp.blockLen; + hashC.create = () => hashCons(); + return hashC; +} +function createOptHasher(hashCons) { + const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest(); + const tmp = hashCons({}); + hashC.outputLen = tmp.outputLen; + hashC.blockLen = tmp.blockLen; + hashC.create = (opts) => hashCons(opts); + return hashC; +} +function createXOFer(hashCons) { + const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest(); + const tmp = hashCons({}); + hashC.outputLen = tmp.outputLen; + hashC.blockLen = tmp.blockLen; + hashC.create = (opts) => hashCons(opts); + return hashC; +} +exports.wrapConstructor = createHasher; +exports.wrapConstructorWithOpts = createOptHasher; +exports.wrapXOFConstructorWithOpts = createXOFer; +/** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */ +function randomBytes(bytesLength = 32) { + if (crypto_1.crypto && typeof crypto_1.crypto.getRandomValues === 'function') { + return crypto_1.crypto.getRandomValues(new Uint8Array(bytesLength)); + } + // Legacy Node.js compatibility + if (crypto_1.crypto && typeof crypto_1.crypto.randomBytes === 'function') { + return Uint8Array.from(crypto_1.crypto.randomBytes(bytesLength)); + } + throw new Error('crypto.getRandomValues must be defined'); +} +//# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/node_modules/@noble/hashes/utils.js.map b/node_modules/@noble/hashes/utils.js.map new file mode 100644 index 0000000000000000000000000000000000000000..9e5e2f7459b2fd7077601c38301beedc3cb9623f --- /dev/null +++ b/node_modules/@noble/hashes/utils.js.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.js","sourceRoot":"","sources":["src/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;AACH,sEAAsE;;;AAWtE,0BAEC;AAGD,0BAEC;AAGD,wBAIC;AAGD,sBAKC;AAGD,0BAGC;AAGD,0BAMC;AAQD,gBAEC;AAGD,kBAEC;AAGD,sBAIC;AAGD,gCAEC;AAGD,oBAEC;AAGD,oBAEC;AAOD,4BAOC;AASD,gCAKC;AAoBD,gCAUC;AAeD,gCAkBC;AAUD,8BAcC;AAUD,kCAGC;AAMD,kCAE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eAAe,CAAC,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC;IAC7D,CAAC;IACD,+BAA+B;IAC/B,IAAI,eAAM,IAAI,OAAO,eAAM,CAAC,WAAW,KAAK,UAAU,EAAE,CAAC;QACvD,OAAO,UAAU,CAAC,IAAI,CAAC,eAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC;IAC1D,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;AAC5D,CAAC"} \ No newline at end of file diff --git a/node_modules/@nodable/entities/README.md b/node_modules/@nodable/entities/README.md new file mode 100644 index 0000000000000000000000000000000000000000..18a7fb6bffc6163e33ea3e41758be21bacfb4cf8 --- /dev/null +++ b/node_modules/@nodable/entities/README.md @@ -0,0 +1,41 @@ +# @nodable/entities + +Fast, zero-dependency XML/HTML entity encoder and decoder for Node.js. + +## Install + +```bash +npm install @nodable/entities +``` + +## Quick start + +```js +import { EntityEncoder, EntityDecoder, ALL_ENTITIES } from '@nodable/entities'; + +// Encode: plain text → entity references +const enc = new EntityEncoder(); +enc.encode('Hello © 2024 & '); +// → 'Hello © 2024 & <stuff>' + +// Decode: entity references → plain text +const dec = new EntityDecoder({ namedEntities: ALL_ENTITIES }); +dec.decode('Hello © 2024 & <stuff>'); +// → 'Hello © 2024 & ' +``` + +## Performance + +| | encode | decode | +|---|---|---| +| `entities` (npm) | 3.65 M req/s | 1.76 M req/s | +| `@nodable/entities` | 3.33 M req/s | **5.19 M req/s** | + +## Documentation + +- [EntityEncoder](docs/EntityEncoder.md) — options, API, recipes +- [EntityDecoder](docs/EntityDecoder.md) — options, API, security limits, entity sets + +## License + +MIT \ No newline at end of file diff --git a/node_modules/@nodable/entities/package.json b/node_modules/@nodable/entities/package.json new file mode 100644 index 0000000000000000000000000000000000000000..9c02c3425a41e1a103b2802409608df4bf099991 --- /dev/null +++ b/node_modules/@nodable/entities/package.json @@ -0,0 +1,57 @@ +{ + "name": "@nodable/entities", + "version": "2.2.0", + "description": "Entity parser for XML, HTML, External entites with security and NCR control", + "main": "./src/index.js", + "type": "module", + "sideEffects": false, + "types": "./src/index.d.ts", + "scripts": { + "test": "node --experimental-vm-modules node_modules/.bin/jest", + "test:watch": "node --experimental-vm-modules node_modules/.bin/jest --watch", + "test:coverage": "node --experimental-vm-modules node_modules/.bin/jest --coverage", + "lint": "eslint src/ test/" + }, + "files": [ + "src", + "README.md" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/nodable/val-parsers.git" + }, + "keywords": [ + "fast", + "xml", + "html", + "entity", + "entities", + "stringify", + "encode", + "decode", + "ncr", + "security", + "safe", + "performance" + ], + "author": "Amit Gupta (https://solothought.com)", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "devDependencies": { + "jest": "^29.7.0" + }, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/nodable" + } + ], + "jest": { + "testMatch": [ + "**/?(*.)+(spec|test).[jt]s?(x)", + "**/*_spec.[jt]s?(x)" + ] + } +} \ No newline at end of file diff --git a/node_modules/@nodable/entities/src/EntityDecoder.js b/node_modules/@nodable/entities/src/EntityDecoder.js new file mode 100644 index 0000000000000000000000000000000000000000..71f9180d1c9ad2d106ca376b5d734ce30e50b16a --- /dev/null +++ b/node_modules/@nodable/entities/src/EntityDecoder.js @@ -0,0 +1,644 @@ +// --------------------------------------------------------------------------- +// Built-in named entity map (name → replacement string) +// No regex, no {regex,val} objects — just flat key/value pairs. +// --------------------------------------------------------------------------- + +import { XML as DEFAULT_XML_ENTITIES } from "./entities.js" + +// --------------------------------------------------------------------------- +// Entity hook action constants +// --------------------------------------------------------------------------- + +/** + * Action constants for `onExternalEntity` and `onInputEntity` hooks. + * + * Use these instead of raw strings to avoid typos: + * + * @example + * import EntityDecoder, { ENTITY_ACTION } from './EntityDecoder.js'; + * const dec = new EntityDecoder({ + * onInputEntity: (name, value) => ENTITY_ACTION.BLOCK, + * }); + */ +export const ENTITY_ACTION = Object.freeze({ + /** Resolve and expand the entity normally. */ + ALLOW: 'allow', + /** Silently skip this entity — it will not be registered. */ + BLOCK: 'block', + /** Throw an error, aborting entity registration entirely. */ + THROW: 'throw', +}); + +// --------------------------------------------------------------------------- +// Helpers +// --------------------------------------------------------------------------- + +const SPECIAL_CHARS = new Set('!?\\\\/[]$%{}^&*()<>|+'); + +/** + * Validate that an entity name contains no dangerous characters. + * @param {string} name + * @returns {string} the name, unchanged + * @throws {Error} on invalid characters + */ +function validateEntityName(name) { + if (name[0] === '#') { + throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${name}"`); + } + for (const ch of name) { + if (SPECIAL_CHARS.has(ch)) { + throw new Error(`[EntityReplacer] Invalid character '${ch}' in entity name: "${name}"`); + } + } + return name; +} + +/** + * Merge one or more entity maps into a flat name→string map. + * Accepts either: + * - plain string values: { amp: '&' } + * - legacy {regex,val} / {regx,val}: { lt: { regex: /.../, val: '<' } } + * + * Values containing '&' are skipped (recursive expansion risk). + * + * @param {...object} maps + * @returns {Record} + */ +function mergeEntityMaps(...maps) { + const out = Object.create(null); + for (const map of maps) { + if (!map) continue; + for (const key of Object.keys(map)) { + const raw = map[key]; + if (typeof raw === 'string') { + out[key] = raw; + } else if (raw && typeof raw === 'object' && raw.val !== undefined) { + // Legacy {regex,val} or {regx,val} — extract the string val only + const val = raw.val; + if (typeof val === 'string') { + out[key] = val; + } + // function vals are not supported in the scanner — skip + } + } + } + return out; +} + +// --------------------------------------------------------------------------- +// applyLimitsTo helpers +// --------------------------------------------------------------------------- + +const LIMIT_TIER_EXTERNAL = 'external'; // input/runtime + persistent external maps +const LIMIT_TIER_BASE = 'base'; // DEFAULT_XML_ENTITIES + namedEntities (system) maps +const LIMIT_TIER_ALL = 'all'; // every entity regardless of tier + +/** + * Resolve `applyLimitsTo` option into a normalised Set of tier strings. + * Accepted values: 'external' | 'base' | 'all' | string[] + * Default: 'external' (only untrusted injected entities are counted). + * @param {string|string[]|undefined} raw + * @returns {Set} + */ +function parseLimitTiers(raw) { + if (!raw || raw === LIMIT_TIER_EXTERNAL) return new Set([LIMIT_TIER_EXTERNAL]); + if (raw === LIMIT_TIER_ALL) return new Set([LIMIT_TIER_ALL]); + if (raw === LIMIT_TIER_BASE) return new Set([LIMIT_TIER_BASE]); + if (Array.isArray(raw)) return new Set(raw); + return new Set([LIMIT_TIER_EXTERNAL]); // safe default for unrecognised values +} + +// --------------------------------------------------------------------------- +// NCR (Numeric Character Reference) classification +// --------------------------------------------------------------------------- + +// Severity order — higher number = stricter action. +// Used to enforce minimum action levels for specific codepoint ranges. +const NCR_LEVEL = Object.freeze({ allow: 0, leave: 1, remove: 2, throw: 3 }); + +// XML 1.0 §2.2: allowed chars are #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] +// Restricted C0: U+0001–U+001F excluding U+0009, U+000A, U+000D +const XML10_ALLOWED_C0 = new Set([0x09, 0x0A, 0x0D]); + +/** + * Parse the `ncr` constructor option into flat, hot-path-friendly fields. + * @param {object|undefined} ncr + * @returns {{ xmlVersion: number, onLevel: number, nullLevel: number }} + */ +function parseNCRConfig(ncr) { + if (!ncr) { + return { xmlVersion: 1.0, onLevel: NCR_LEVEL.allow, nullLevel: NCR_LEVEL.remove }; + } + const xmlVersion = ncr.xmlVersion === 1.1 ? 1.1 : 1.0; + const onLevel = NCR_LEVEL[ncr.onNCR] ?? NCR_LEVEL.allow; + const nullLevel = NCR_LEVEL[ncr.nullNCR] ?? NCR_LEVEL.remove; + // 'allow' is not meaningful for null — clamp to at least 'remove' + const clampedNull = Math.max(nullLevel, NCR_LEVEL.remove); + return { xmlVersion, onLevel, nullLevel: clampedNull }; +} + +// --------------------------------------------------------------------------- +// EntityReplacer +// --------------------------------------------------------------------------- + +/** + * Single-pass, zero-regex entity replacer for XML/HTML content. + * + * Algorithm: scan the string once for '&', read to ';', resolve via map + * or direct codepoint conversion, build output chunks, join once at the end. + * + * Entity lookup priority (highest → lowest): + * 1. input / runtime (DOCTYPE entities for current document) + * 2. persistent external (survive across documents) + * 3. base named map (DEFAULT_XML_ENTITIES + user-supplied namedEntities) + * + * Both input and external resolve as the 'external' tier for limit purposes. + * Base map entities resolve as the 'base' tier. + * + * Numeric / hex references (&#NNN; / &#xHH;) are resolved directly via + * String.fromCodePoint() — no map needed. They count as 'base' tier. + * + * @example + * const replacer = new EntityReplacer({ namedEntities: COMMON_HTML }); + * replacer.setExternalEntities({ brand: 'Acme' }); + * + * const instance = replacer.reset(); + * instance.addInputEntities({ version: '1.0' }); + * instance.encode('&brand; v&version; <'); // 'Acme v1.0 <' + */ +export default class EntityDecoder { + /** + * @param {object} [options] + * @param {object|null} [options.namedEntities] — extra named entities merged into base map + * @param {object} [options.limit] — security limits + * @param {number} [options.limit.maxTotalExpansions=0] — 0 = unlimited + * @param {number} [options.limit.maxExpandedLength=0] — 0 = unlimited + * @param {'external'|'base'|'all'|string[]} [options.limit.applyLimitsTo='external'] + * Which entity tiers count against the security limits: + * - 'external' (default) — only input/runtime + persistent external entities + * - 'base' — only DEFAULT_XML_ENTITIES + namedEntities + * - 'all' — every entity regardless of tier + * - string[] — explicit combination, e.g. ['external', 'base'] + * @param {((resolved: string, original: string) => string)|null} [options.postCheck=null] + * @param {string[]} [options.remove=[]] — entity names (e.g. ['nbsp', '#13']) to delete (replace with empty string) + * @param {string[]} [options.leave=[]] — entity names to keep as literal (unchanged in output) + * @param {object} [options.ncr] — Numeric Character Reference controls + * @param {1.0|1.1} [options.ncr.xmlVersion=1.0] + * XML version governing which codepoint ranges are restricted: + * - 1.0 — C0 controls U+0001–U+001F (except U+0009/000A/000D) are prohibited + * - 1.1 — C0 controls are allowed when written as NCRs; C1 (U+007F–U+009F) decoded as-is + * @param {'allow'|'leave'|'remove'|'throw'} [options.ncr.onNCR='allow'] + * Base action for numeric references. Severity order: allow < leave < remove < throw. + * For codepoint ranges that carry a minimum level (surrogates → remove, XML 1.0 C0 → remove), + * the effective action is max(onNCR, rangeMinimum). + * @param {'remove'|'throw'} [options.ncr.nullNCR='remove'] + * Action for U+0000 (null). 'allow' and 'leave' are clamped to 'remove' since null is never safe. + * @param {((name: string, value: string) => 'allow'|'block'|'throw')|null} [options.onExternalEntity=null] + * Hook called when an external entity is registered via `setExternalEntities()` or + * `addExternalEntity()`. Return `ENTITY_ACTION.ALLOW` to accept the entity, + * `ENTITY_ACTION.BLOCK` to silently skip it, or `ENTITY_ACTION.THROW` to abort with an error. + * @param {((name: string, value: string) => 'allow'|'block'|'throw')|null} [options.onInputEntity=null] + * Hook called when an input entity is registered via `addInputEntities()`. Return + * `ENTITY_ACTION.ALLOW` to accept, `ENTITY_ACTION.BLOCK` to silently skip, or + * `ENTITY_ACTION.THROW` to abort with an error. + */ + constructor(options = {}) { + this._limit = options.limit || {}; + this._maxTotalExpansions = this._limit.maxTotalExpansions || 0; + this._maxExpandedLength = this._limit.maxExpandedLength || 0; + this._postCheck = typeof options.postCheck === 'function' ? options.postCheck : r => r; + this._limitTiers = parseLimitTiers(this._limit.applyLimitsTo ?? LIMIT_TIER_EXTERNAL); + this._numericAllowed = options.numericAllowed ?? true; + // Base map: DEFAULT_XML_ENTITIES + user-supplied extras. Immutable after construction. + this._baseMap = mergeEntityMaps(DEFAULT_XML_ENTITIES, options.namedEntities || null); + + // Persistent external entities — survive across documents. + // Stored as a separate map so reset() never touches them. + /** @type {Record} */ + this._externalMap = Object.create(null); + + // Input / runtime entities — current document only, wiped on reset(). + /** @type {Record} */ + this._inputMap = Object.create(null); + + // Per-document counters + this._totalExpansions = 0; + this._expandedLength = 0; + + // --- New: remove / leave sets --- + /** @type {Set} */ + this._removeSet = new Set(options.remove && Array.isArray(options.remove) ? options.remove : []); + /** @type {Set} */ + this._leaveSet = new Set(options.leave && Array.isArray(options.leave) ? options.leave : []); + + // --- NCR config (parsed into flat fields for hot-path speed) --- + const ncrCfg = parseNCRConfig(options.ncr); + this._ncrXmlVersion = ncrCfg.xmlVersion; + this._ncrOnLevel = ncrCfg.onLevel; + this._ncrNullLevel = ncrCfg.nullLevel; + + // --- Registration hooks --- + /** @type {((name: string, value: string) => 'allow'|'block'|'throw')|null} */ + this._onExternalEntity = typeof options.onExternalEntity === 'function' + ? options.onExternalEntity + : null; + /** @type {((name: string, value: string) => 'allow'|'block'|'throw')|null} */ + this._onInputEntity = typeof options.onInputEntity === 'function' + ? options.onInputEntity + : null; + } + + // ------------------------------------------------------------------------- + // Private: registration hook dispatch + // ------------------------------------------------------------------------- + + /** + * Invoke a registration hook for a single entity name/value pair. + * Returns true when the entity should be accepted, false when it should be + * silently skipped (BLOCK), and throws when the hook returns THROW. + * + * @param {((name: string, value: string) => 'allow'|'block'|'throw')|null} hook + * @param {string} name + * @param {string} value + * @param {string} context — used in error messages ('external' | 'input') + * @returns {boolean} true = accept, false = skip + */ + _applyRegistrationHook(hook, name, value, context) { + if (!hook) return true; // no hook → always accept + const action = hook(name, value); + if (action === ENTITY_ACTION.BLOCK) return false; + if (action === ENTITY_ACTION.THROW) { + throw new Error( + `[EntityDecoder] Registration of ${context} entity "&${name};" was rejected by hook` + ); + } + return true; // ALLOW or any unknown return value → accept + } + + // ------------------------------------------------------------------------- + // Persistent external entity registration + // ------------------------------------------------------------------------- + + /** + * Replace the full set of persistent external entities. + * All keys are validated — throws on invalid characters. + * If `onExternalEntity` is set, it is called once per entry; entries that + * return `ENTITY_ACTION.BLOCK` are silently omitted, `ENTITY_ACTION.THROW` + * aborts the whole call. + * @param {Record} map + */ + setExternalEntities(map) { + if (map) { + for (const key of Object.keys(map)) { + validateEntityName(key); + } + } + if (!this._onExternalEntity) { + this._externalMap = mergeEntityMaps(map); + return; + } + // Hook present — resolve values first, then filter + const flat = mergeEntityMaps(map); + const filtered = Object.create(null); + for (const [name, value] of Object.entries(flat)) { + if (this._applyRegistrationHook(this._onExternalEntity, name, value, 'external')) { + filtered[name] = value; + } + } + this._externalMap = filtered; + } + + /** + * Add a single persistent external entity. + * If `onExternalEntity` is set it is called before the entity is stored; + * `ENTITY_ACTION.BLOCK` silently skips storage, `ENTITY_ACTION.THROW` raises. + * @param {string} key + * @param {string} value + */ + addExternalEntity(key, value) { + validateEntityName(key); + if (typeof value === 'string' && value.indexOf('&') === -1) { + if (this._applyRegistrationHook(this._onExternalEntity, key, value, 'external')) { + this._externalMap[key] = value; + } + } + } + + // ------------------------------------------------------------------------- + // Input / runtime entity registration (per document) + // ------------------------------------------------------------------------- + + /** + * Inject DOCTYPE entities for the current document. + * Also resets per-document expansion counters. + * If `onInputEntity` is set it is called once per entry; entries returning + * `ENTITY_ACTION.BLOCK` are silently omitted, `ENTITY_ACTION.THROW` aborts. + * @param {Record} map + */ + addInputEntities(map) { + this._totalExpansions = 0; + this._expandedLength = 0; + if (!this._onInputEntity) { + this._inputMap = mergeEntityMaps(map); + return; + } + const flat = mergeEntityMaps(map); + const filtered = Object.create(null); + for (const [name, value] of Object.entries(flat)) { + if (this._applyRegistrationHook(this._onInputEntity, name, value, 'input')) { + filtered[name] = value; + } + } + this._inputMap = filtered; + } + + // ------------------------------------------------------------------------- + // Per-document reset + // ------------------------------------------------------------------------- + + /** + * Wipe input/runtime entities and reset counters. + * Call this before processing each new document. + * @returns {this} + */ + reset() { + this._inputMap = Object.create(null); + this._totalExpansions = 0; + this._expandedLength = 0; + return this; + } + + // ------------------------------------------------------------------------- + // XML version (can be set after construction, e.g. once parser reads ) + // ------------------------------------------------------------------------- + + /** + * Update the XML version used for NCR classification. + * Call this as soon as the document's `` declaration is parsed. + * @param {1.0|1.1|number} version + */ + setXmlVersion(version) { + this._ncrXmlVersion = version === 1.1 ? 1.1 : 1.0; + } + + // ------------------------------------------------------------------------- + // Primary API + // ------------------------------------------------------------------------- + + /** + * Replace all entity references in `str` in a single pass. + * + * @param {string} str + * @returns {string} + */ + decode(str) { + if (typeof str !== 'string' || str.length === 0) return str; + //TODO: check if needed + if (str.indexOf('&') === -1) return str; // fast path — no entities at all + + const original = str; + const chunks = []; + const len = str.length; + let last = 0; // start of next unprocessed literal chunk + let i = 0; + + const limitExpansions = this._maxTotalExpansions > 0; + const limitLength = this._maxExpandedLength > 0; + const checkLimits = limitExpansions || limitLength; + + while (i < len) { + // Scan forward to next '&' + if (str.charCodeAt(i) !== 38 /* '&' */) { i++; continue; } + + // --- Found '&' at position i --- + + // Scan forward to ';' + let j = i + 1; + while (j < len && str.charCodeAt(j) !== 59 /* ';' */ && (j - i) <= 32) j++; + + if (j >= len || str.charCodeAt(j) !== 59) { + // No closing ';' within window — treat '&' as literal + i++; + continue; + } + + // Raw token between '&' and ';' (exclusive) + const token = str.slice(i + 1, j); + if (token.length === 0) { i++; continue; } + + let replacement; + let tier; // which limit tier this entity belongs to + + if (this._removeSet.has(token)) { + // Remove entity: replace with empty string + replacement = ''; + // If entity was unknown (replacement undefined), we still need a tier for limits. + // Treat as external tier because it's user-directed removal of an unknown reference. + if (tier === undefined) { + tier = LIMIT_TIER_EXTERNAL; + } + } else if (this._leaveSet.has(token)) { + // Do not replace — keep original &token; as literal + i++; + continue; + } else if (token.charCodeAt(0) === 35 /* '#' */) { + // ---- Numeric / NCR reference ---- + // NCR classification always runs first — prohibited codepoints must be + // caught regardless of numericAllowed. + const ncrResult = this._resolveNCR(token); + if (ncrResult === undefined) { + // 'leave' action — keep original &token; as-is + i++; + continue; + } + replacement = ncrResult; // '' for remove, char string for allow + tier = LIMIT_TIER_BASE; + } else { + // ---- Named reference ---- + const resolved = this._resolveName(token); + replacement = resolved?.value; + tier = resolved?.tier; + } + + if (replacement === undefined) { + // Unknown entity — leave as-is, advance past '&' only + i++; + continue; + } + + // Flush literal chunk before this entity + if (i > last) chunks.push(str.slice(last, i)); + chunks.push(replacement); + last = j + 1; // skip past ';' + i = last; + + // Apply expansion limits only if this tier is being tracked + if (checkLimits && this._tierCounts(tier)) { + if (limitExpansions) { + this._totalExpansions++; + if (this._totalExpansions > this._maxTotalExpansions) { + throw new Error( + `[EntityReplacer] Entity expansion count limit exceeded: ` + + `${this._totalExpansions} > ${this._maxTotalExpansions}` + ); + } + } + if (limitLength) { + // delta: replacement.length minus the raw &token; length (token.length + 2 for '&' and ';') + const delta = replacement.length - (token.length + 2); + if (delta > 0) { + this._expandedLength += delta; + if (this._expandedLength > this._maxExpandedLength) { + throw new Error( + `[EntityReplacer] Expanded content length limit exceeded: ` + + `${this._expandedLength} > ${this._maxExpandedLength}` + ); + } + } + } + } + } + + // Flush trailing literal + if (last < len) chunks.push(str.slice(last)); + + // If nothing was replaced, chunks is empty — return original + const result = chunks.length === 0 ? str : chunks.join(''); + + return this._postCheck(result, original); + } + + // ------------------------------------------------------------------------- + // Private: limit tier check + // ------------------------------------------------------------------------- + + /** + * Returns true if a resolved entity of the given tier should count + * against the expansion/length limits. + * @param {string} tier — LIMIT_TIER_EXTERNAL | LIMIT_TIER_BASE + * @returns {boolean} + */ + _tierCounts(tier) { + if (this._limitTiers.has(LIMIT_TIER_ALL)) return true; + return this._limitTiers.has(tier); + } + + // ------------------------------------------------------------------------- + // Private: entity resolution + // ------------------------------------------------------------------------- + + /** + * Resolve a named entity token (without & and ;). + * Priority: inputMap > externalMap > baseMap + * Returns the resolved value tagged with its limit tier. + * + * @param {string} name + * @returns {{ value: string, tier: string }|undefined} + */ + _resolveName(name) { + // input and external both count as 'external' tier for limit purposes — + // they are injected at runtime and are the untrusted surface. + if (name in this._inputMap) return { value: this._inputMap[name], tier: LIMIT_TIER_EXTERNAL }; + if (name in this._externalMap) return { value: this._externalMap[name], tier: LIMIT_TIER_EXTERNAL }; + if (name in this._baseMap) return { value: this._baseMap[name], tier: LIMIT_TIER_BASE }; + return undefined; + } + + /** + * Classify a codepoint and return the minimum action level that must be applied. + * Returns -1 when no minimum is imposed (normal allow path). + * + * Ranges checked (in priority order): + * 1. U+0000 — null, governed by nullNCR (always ≥ remove) + * 2. U+D800–U+DFFF — surrogates, always prohibited (min: remove) + * 3. U+0001–U+001F \ {0x09,0x0A,0x0D} — XML 1.0 restricted C0 (min: remove) + * (skipped in XML 1.1 — C0 controls are allowed when written as NCRs) + * + * @param {number} cp — codepoint + * @returns {number} — minimum NCR_LEVEL value, or -1 for no restriction + */ + _classifyNCR(cp) { + // 1. Null + if (cp === 0) return this._ncrNullLevel; + + // 2. Surrogates — always prohibited, minimum 'remove' + if (cp >= 0xD800 && cp <= 0xDFFF) return NCR_LEVEL.remove; + + // 3. XML 1.0 restricted C0 controls + if (this._ncrXmlVersion === 1.0) { + if (cp >= 0x01 && cp <= 0x1F && !XML10_ALLOWED_C0.has(cp)) return NCR_LEVEL.remove; + } + + return -1; // no restriction + } + + /** + * Execute a resolved NCR action. + * + * @param {number} action — NCR_LEVEL value + * @param {string} token — raw token (e.g. '#38') for error messages + * @param {number} cp — codepoint, used only for error messages + * @returns {string|undefined} + * - decoded character string → 'allow' + * - '' → 'remove' + * - undefined → 'leave' (caller must skip past '&' only) + * - throws Error → 'throw' + */ + _applyNCRAction(action, token, cp) { + switch (action) { + case NCR_LEVEL.allow: return String.fromCodePoint(cp); + case NCR_LEVEL.remove: return ''; + case NCR_LEVEL.leave: return undefined; // signal: keep literal + case NCR_LEVEL.throw: + throw new Error( + `[EntityDecoder] Prohibited numeric character reference ` + + `&${token}; (U+${cp.toString(16).toUpperCase().padStart(4, '0')})` + ); + default: return String.fromCodePoint(cp); + } + } + + /** + * Full NCR resolution pipeline for a numeric token. + * + * Steps: + * 1. Parse the codepoint (decimal or hex). + * 2. Validate the raw codepoint range (NaN, <0, >0x10FFFF). + * 3. If numericAllowed is false and no minimum restriction applies → leave as-is. + * 4. Classify the codepoint to find the minimum required action level. + * 5. Resolve effective action = max(onNCR, minimum). + * 6. Apply and return. + * + * @param {string} token — e.g. '#38', '#x26', '#X26' + * @returns {string|undefined} + * - string (incl. '') — replacement ('' = remove) + * - undefined — leave original &token; as-is + */ + _resolveNCR(token) { + // Step 1: parse codepoint + const second = token.charCodeAt(1); + let cp; + if (second === 120 /* x */ || second === 88 /* X */) { + cp = parseInt(token.slice(2), 16); + } else { + cp = parseInt(token.slice(1), 10); + } + + // Step 2: out-of-range → leave as-is unconditionally + if (Number.isNaN(cp) || cp < 0 || cp > 0x10FFFF) return undefined; + + // Step 3: classify to get minimum action level + const minimum = this._classifyNCR(cp); + + // Step 4: if numericAllowed is false and no hard minimum → leave + if (!this._numericAllowed && minimum < NCR_LEVEL.remove) return undefined; + + // Step 5: effective action = max(configured onNCR, range minimum) + const effective = minimum === -1 + ? this._ncrOnLevel + : Math.max(this._ncrOnLevel, minimum); + + // Step 6: apply + return this._applyNCRAction(effective, token, cp); + } +} \ No newline at end of file diff --git a/node_modules/@nodable/entities/src/EntityEncoder.js b/node_modules/@nodable/entities/src/EntityEncoder.js new file mode 100644 index 0000000000000000000000000000000000000000..a53f5a32073dc9416789e1e2fe0f4e5afb88a71e --- /dev/null +++ b/node_modules/@nodable/entities/src/EntityEncoder.js @@ -0,0 +1,194 @@ +// EntityDecoder.js +import { trie1, trie2, trie3 } from './entityTries.js'; + +// Replacement strings indexed by char code — direct array access, no hashing +const XML_UNSAFE_REPLACEMENT = new Array(128); +XML_UNSAFE_REPLACEMENT[38] = '&'; // & +XML_UNSAFE_REPLACEMENT[60] = '<'; // < +XML_UNSAFE_REPLACEMENT[62] = '>'; // > +XML_UNSAFE_REPLACEMENT[34] = '"'; // " +XML_UNSAFE_REPLACEMENT[39] = '''; // ' + +// Typed bitmask for O(1) "is this ASCII code XML-unsafe?" check +const IS_XML_UNSAFE = new Uint8Array(128); +IS_XML_UNSAFE[38] = 1; +IS_XML_UNSAFE[60] = 1; +IS_XML_UNSAFE[62] = 1; +IS_XML_UNSAFE[34] = 1; +IS_XML_UNSAFE[39] = 1; + +// Fast pre-scan: bail out immediately if nothing needs encoding +const NEEDS_PROCESSING = /[&<>"'\u0080-\uFFFF]/; + +export default class EntityEncoder { + constructor(options = {}) { + this.encodeXmlSafe = options.encodeXmlSafe !== false; + this.encodeAllNamed = options.encodeAllNamed !== false; + this.maxReplacements = options.maxReplacements || 0; + this.replacementsCount = 0; + } + + encode(str) { + if (typeof str !== 'string' || str.length === 0) return str; + if (!NEEDS_PROCESSING.test(str)) return str; + + const maxRep = this.maxReplacements; + if (maxRep > 0 && this.replacementsCount >= maxRep) return str; + + // Hoist to locals — avoids `this` property lookup inside the hot loop + const encodeXmlSafe = this.encodeXmlSafe; + const encodeAllNamed = this.encodeAllNamed; + + const len = str.length; + + let result = ''; + let last = 0; + let i = 0; + let limitReached = false; + + // ── Main loop: runs to len-2 so trie3 never needs a bounds check ──────── + // The last 2 characters are handled by the tail block below. + const mainEnd = len - 2; // i <= mainEnd guarantees i+1 and i+2 are valid + + while (i <= mainEnd && !limitReached) { + const c0 = str.charCodeAt(i); + + // ── ASCII branch ─────────────────────────────────────────────────── + if (c0 < 128) { + if (encodeXmlSafe && IS_XML_UNSAFE[c0] === 1) { + result += str.substring(last, i) + XML_UNSAFE_REPLACEMENT[c0]; + last = ++i; + if (maxRep > 0) { + this.replacementsCount++; + if (this.replacementsCount >= maxRep) { + limitReached = true; + break; + } + } + } else { + // Bulk-skip: advance to the next interesting position without + // touching the outer loop overhead on every safe character + i++; + while (i <= mainEnd && !limitReached) { + const c = str.charCodeAt(i); + if (c >= 128 || (encodeXmlSafe && IS_XML_UNSAFE[c] === 1)) break; + i++; + } + } + continue; + } + + // ── Non-ASCII: integer-keyed trie lookup ─────────────────────────── + // No bounds checks needed for c1/c2 because i <= mainEnd guarantees + // i+1 and i+2 are both within the string. + let matchedEntity = null; + let advance = 1; + + // Try 3-char match first (longest wins) + const mid3 = trie3.get(c0); + if (mid3 !== undefined) { + const c1 = str.charCodeAt(i + 1); + const inner3 = mid3.get(c1); + if (inner3 !== undefined) { + const c2 = str.charCodeAt(i + 2); + const candidate = inner3.get(c2); + if (candidate !== undefined) { matchedEntity = candidate; advance = 3; } + } + } + + // Try 2-char match + if (matchedEntity === null) { + const inner2 = trie2.get(c0); + if (inner2 !== undefined) { + const c1 = str.charCodeAt(i + 1); + const candidate = inner2.get(c1); + if (candidate !== undefined) { matchedEntity = candidate; advance = 2; } + } + } + + // Try 1-char match + if (matchedEntity === null && encodeAllNamed) { + const candidate = trie1.get(c0); + if (candidate !== undefined) { matchedEntity = candidate; } + } + + if (matchedEntity !== null) { + result += str.substring(last, i) + matchedEntity; + i += advance; + last = i; + if (maxRep > 0) { + this.replacementsCount++; + if (this.replacementsCount >= maxRep) { + limitReached = true; + break; + } + } + } else { + i++; + } + } + + // ── Tail: handle the last 1-2 characters (no 3-char match possible) ──── + while (i < len && !limitReached) { + const c0 = str.charCodeAt(i); + + if (c0 < 128) { + if (encodeXmlSafe && IS_XML_UNSAFE[c0] === 1) { + result += str.substring(last, i) + XML_UNSAFE_REPLACEMENT[c0]; + last = ++i; + if (maxRep > 0) { + this.replacementsCount++; + if (this.replacementsCount >= maxRep) { + limitReached = true; + break; + } + } + } else { + i++; + } + continue; + } + + // Non-ASCII tail — only 2-char and 1-char matches are possible here + let matchedEntity = null; + let advance = 1; + + if (i + 1 < len) { + const inner2 = trie2.get(c0); + if (inner2 !== undefined) { + const c1 = str.charCodeAt(i + 1); + const candidate = inner2.get(c1); + if (candidate !== undefined) { matchedEntity = candidate; advance = 2; } + } + } + + if (matchedEntity === null && encodeAllNamed) { + const candidate = trie1.get(c0); + if (candidate !== undefined) { matchedEntity = candidate; } + } + + if (matchedEntity !== null) { + result += str.substring(last, i) + matchedEntity; + i += advance; + last = i; + if (maxRep > 0) { + this.replacementsCount++; + if (this.replacementsCount >= maxRep) { + limitReached = true; + break; + } + } + } else { + i++; + } + } + + // ── Flush any remaining literal suffix ──────────────────────────────── + if (last < len) result += str.substring(last); + return result; + } + + reset() { + this.replacementsCount = 0; + } +} \ No newline at end of file diff --git a/node_modules/@nodable/entities/src/entities.js b/node_modules/@nodable/entities/src/entities.js new file mode 100644 index 0000000000000000000000000000000000000000..dd2c27831d8f33ef148d149dd1394fe83e9056ed --- /dev/null +++ b/node_modules/@nodable/entities/src/entities.js @@ -0,0 +1,1159 @@ +// --------------------------------------------------------------------------- +// Complete HTML5 named entity reference +// Organized by logical categories for easy maintenance and selective importing +// --------------------------------------------------------------------------- + +/** + * Basic Latin & Special Characters + * @type {Record} + */ +export const BASIC_LATIN = { + amp: '&', + AMP: '&', + lt: '<', + LT: '<', + gt: '>', + GT: '>', + quot: '"', + QUOT: '"', + apos: "'", + lsquo: '‘', + rsquo: '’', + ldquo: '“', + rdquo: '”', + lsquor: '‚', + rsquor: '’', + ldquor: '„', + bdquo: '„', + comma: ',', + period: '.', + colon: ':', + semi: ';', + excl: '!', + quest: '?', + num: '#', + dollar: '$', + percent: '%', + ast: '*', + commat: '@', + lowbar: '_', + verbar: '|', + vert: '|', + sol: '/', + bsol: '\\', + lbrace: '{', + rbrace: '}', + lbrack: '[', + rbrack: ']', + lpar: '(', + rpar: ')', + nbsp: '\u00a0', + iexcl: '¡', + cent: '¢', + pound: '£', + curren: '¤', + yen: '¥', + brvbar: '¦', + sect: '§', + uml: '¨', + copy: '©', + COPY: '©', + ordf: 'ª', + laquo: '«', + not: '¬', + shy: '\u00ad', + reg: '®', + REG: '®', + macr: '¯', + deg: '°', + plusmn: '±', + sup2: '²', + sup3: '³', + acute: '´', + micro: 'µ', + para: '¶', + middot: '·', + cedil: '¸', + sup1: '¹', + ordm: 'º', + raquo: '»', + frac14: '¼', + frac12: '½', + half: '½', + frac34: '¾', + iquest: '¿', + times: '×', + div: '÷', + divide: '÷', +}; + +/** + * Latin Extended & Accented Letters (A-Z) + * @type {Record} + */ +export const LATIN_ACCENTS = { + Agrave: 'À', + agrave: 'à', + Aacute: 'Á', + aacute: 'á', + Acirc: 'Â', + acirc: 'â', + Atilde: 'Ã', + atilde: 'ã', + Auml: 'Ä', + auml: 'ä', + Aring: 'Å', + aring: 'å', + AElig: 'Æ', + aelig: 'æ', + Ccedil: 'Ç', + ccedil: 'ç', + Egrave: 'È', + egrave: 'è', + Eacute: 'É', + eacute: 'é', + Ecirc: 'Ê', + ecirc: 'ê', + Euml: 'Ë', + euml: 'ë', + Igrave: 'Ì', + igrave: 'ì', + Iacute: 'Í', + iacute: 'í', + Icirc: 'Î', + icirc: 'î', + Iuml: 'Ï', + iuml: 'ï', + ETH: 'Ð', + eth: 'ð', + Ntilde: 'Ñ', + ntilde: 'ñ', + Ograve: 'Ò', + ograve: 'ò', + Oacute: 'Ó', + oacute: 'ó', + Ocirc: 'Ô', + ocirc: 'ô', + Otilde: 'Õ', + otilde: 'õ', + Ouml: 'Ö', + ouml: 'ö', + Oslash: 'Ø', + oslash: 'ø', + Ugrave: 'Ù', + ugrave: 'ù', + Uacute: 'Ú', + uacute: 'ú', + Ucirc: 'Û', + ucirc: 'û', + Uuml: 'Ü', + uuml: 'ü', + Yacute: 'Ý', + yacute: 'ý', + THORN: 'Þ', + thorn: 'þ', + szlig: 'ß', + yuml: 'ÿ', + Yuml: 'Ÿ', +}; + +/** + * Latin Extended (Letters with diacritics) + * @type {Record} + */ +export const LATIN_EXTENDED = { + Amacr: 'Ā', + amacr: 'ā', + Abreve: 'Ă', + abreve: 'ă', + Aogon: 'Ą', + aogon: 'ą', + Cacute: 'Ć', + cacute: 'ć', + Ccirc: 'Ĉ', + ccirc: 'ĉ', + Cdot: 'Ċ', + cdot: 'ċ', + Ccaron: 'Č', + ccaron: 'č', + Dcaron: 'Ď', + dcaron: 'ď', + Dstrok: 'Đ', + dstrok: 'đ', + Emacr: 'Ē', + emacr: 'ē', + Ecaron: 'Ě', + ecaron: 'ě', + Edot: 'Ė', + edot: 'ė', + Eogon: 'Ę', + eogon: 'ę', + Gcirc: 'Ĝ', + gcirc: 'ĝ', + Gbreve: 'Ğ', + gbreve: 'ğ', + Gdot: 'Ġ', + gdot: 'ġ', + Gcedil: 'Ģ', + Hcirc: 'Ĥ', + hcirc: 'ĥ', + Hstrok: 'Ħ', + hstrok: 'ħ', + Itilde: 'Ĩ', + itilde: 'ĩ', + Imacr: 'Ī', + imacr: 'ī', + Iogon: 'Į', + iogon: 'į', + Idot: 'İ', + IJlig: 'IJ', + ijlig: 'ij', + Jcirc: 'Ĵ', + jcirc: 'ĵ', + Kcedil: 'Ķ', + kcedil: 'ķ', + kgreen: 'ĸ', + Lacute: 'Ĺ', + lacute: 'ĺ', + Lcedil: 'Ļ', + lcedil: 'ļ', + Lcaron: 'Ľ', + lcaron: 'ľ', + Lmidot: 'Ŀ', + lmidot: 'ŀ', + Lstrok: 'Ł', + lstrok: 'ł', + Nacute: 'Ń', + nacute: 'ń', + Ncaron: 'Ň', + ncaron: 'ň', + Ncedil: 'Ņ', + ncedil: 'ņ', + ENG: 'Ŋ', + eng: 'ŋ', + Omacr: 'Ō', + omacr: 'ō', + Odblac: 'Ő', + odblac: 'ő', + OElig: 'Œ', + oelig: 'œ', + Racute: 'Ŕ', + racute: 'ŕ', + Rcaron: 'Ř', + rcaron: 'ř', + Rcedil: 'Ŗ', + rcedil: 'ŗ', + Sacute: 'Ś', + sacute: 'ś', + Scirc: 'Ŝ', + scirc: 'ŝ', + Scedil: 'Ş', + scedil: 'ş', + Scaron: 'Š', + scaron: 'š', + Tcedil: 'Ţ', + tcedil: 'ţ', + Tcaron: 'Ť', + tcaron: 'ť', + Tstrok: 'Ŧ', + tstrok: 'ŧ', + Utilde: 'Ũ', + utilde: 'ũ', + Umacr: 'Ū', + umacr: 'ū', + Ubreve: 'Ŭ', + ubreve: 'ŭ', + Uring: 'Ů', + uring: 'ů', + Udblac: 'Ű', + udblac: 'ű', + Uogon: 'Ų', + uogon: 'ų', + Wcirc: 'Ŵ', + wcirc: 'ŵ', + Ycirc: 'Ŷ', + ycirc: 'ŷ', + Zacute: 'Ź', + zacute: 'ź', + Zdot: 'Ż', + zdot: 'ż', + Zcaron: 'Ž', + zcaron: 'ž', +}; + +/** + * Greek Letters + * @type {Record} + */ +export const GREEK = { + Alpha: 'Α', + alpha: 'α', + Beta: 'Β', + beta: 'β', + Gamma: 'Γ', + gamma: 'γ', + Delta: 'Δ', + delta: 'δ', + Epsilon: 'Ε', + epsilon: 'ε', + epsiv: 'ϵ', + varepsilon: 'ϵ', + Zeta: 'Ζ', + zeta: 'ζ', + Eta: 'Η', + eta: 'η', + Theta: 'Θ', + theta: 'θ', + thetasym: 'ϑ', + vartheta: 'ϑ', + Iota: 'Ι', + iota: 'ι', + Kappa: 'Κ', + kappa: 'κ', + kappav: 'ϰ', + varkappa: 'ϰ', + Lambda: 'Λ', + lambda: 'λ', + Mu: 'Μ', + mu: 'μ', + Nu: 'Ν', + nu: 'ν', + Xi: 'Ξ', + xi: 'ξ', + Omicron: 'Ο', + omicron: 'ο', + Pi: 'Π', + pi: 'π', + piv: 'ϖ', + varpi: 'ϖ', + Rho: 'Ρ', + rho: 'ρ', + rhov: 'ϱ', + varrho: 'ϱ', + Sigma: 'Σ', + sigma: 'σ', + sigmaf: 'ς', + sigmav: 'ς', + varsigma: 'ς', + Tau: 'Τ', + tau: 'τ', + Upsilon: 'Υ', + upsilon: 'υ', + upsi: 'υ', + Upsi: 'ϒ', + upsih: 'ϒ', + Phi: 'Φ', + phi: 'φ', + phiv: 'ϕ', + varphi: 'ϕ', + Chi: 'Χ', + chi: 'χ', + Psi: 'Ψ', + psi: 'ψ', + Omega: 'Ω', + omega: 'ω', + ohm: 'Ω', + Gammad: 'Ϝ', + gammad: 'ϝ', + digamma: 'ϝ', +}; + +/** + * Cyrillic Letters + * @type {Record} + */ +export const CYRILLIC = { + Afr: '𝔄', + afr: '𝔞', + Acy: 'А', + acy: 'а', + Bcy: 'Б', + bcy: 'б', + Vcy: 'В', + vcy: 'в', + Gcy: 'Г', + gcy: 'г', + Dcy: 'Д', + dcy: 'д', + IEcy: 'Е', + iecy: 'е', + IOcy: 'Ё', + iocy: 'ё', + ZHcy: 'Ж', + zhcy: 'ж', + Zcy: 'З', + zcy: 'з', + Icy: 'И', + icy: 'и', + Jcy: 'Й', + jcy: 'й', + Kcy: 'К', + kcy: 'к', + Lcy: 'Л', + lcy: 'л', + Mcy: 'М', + mcy: 'м', + Ncy: 'Н', + ncy: 'н', + Ocy: 'О', + ocy: 'о', + Pcy: 'П', + pcy: 'п', + Rcy: 'Р', + rcy: 'р', + Scy: 'С', + scy: 'с', + Tcy: 'Т', + tcy: 'т', + Ucy: 'У', + ucy: 'у', + Fcy: 'Ф', + fcy: 'ф', + KHcy: 'Х', + khcy: 'х', + TScy: 'Ц', + tscy: 'ц', + CHcy: 'Ч', + chcy: 'ч', + SHcy: 'Ш', + shcy: 'ш', + SHCHcy: 'Щ', + shchcy: 'щ', + HARDcy: 'Ъ', + hardcy: 'ъ', + Ycy: 'Ы', + ycy: 'ы', + SOFTcy: 'Ь', + softcy: 'ь', + Ecy: 'Э', + ecy: 'э', + YUcy: 'Ю', + yucy: 'ю', + YAcy: 'Я', + yacy: 'я', + DJcy: 'Ђ', + djcy: 'ђ', + GJcy: 'Ѓ', + gjcy: 'ѓ', + Jukcy: 'Є', + jukcy: 'є', + DScy: 'Ѕ', + dscy: 'ѕ', + Iukcy: 'І', + iukcy: 'і', + YIcy: 'Ї', + yicy: 'ї', + Jsercy: 'Ј', + jsercy: 'ј', + LJcy: 'Љ', + ljcy: 'љ', + NJcy: 'Њ', + njcy: 'њ', + TSHcy: 'Ћ', + tshcy: 'ћ', + KJcy: 'Ќ', + kjcy: 'ќ', + Ubrcy: 'Ў', + ubrcy: 'ў', + DZcy: 'Џ', + dzcy: 'џ', +}; + +/** + * Mathematical Operators & Relations + * @type {Record} + */ +export const MATH = { + plus: '+', + pm: '±', + times: '×', + div: '÷', + divide: '÷', + sdot: '⋅', + star: '☆', + starf: '★', + bigstar: '★', + lowast: '∗', + ast: '*', + midast: '*', + compfn: '∘', + smallcircle: '∘', + bullet: '•', + bull: '•', + nbsp: '\u00a0', + hellip: '…', + mldr: '…', + prime: '′', + Prime: '″', + tprime: '‴', + bprime: '‵', + backprime: '‵', + minus: '−', + minusd: '∸', + dotminus: '∸', + plusdo: '∔', + dotplus: '∔', + plusmn: '±', + minusplus: '∓', + mnplus: '∓', + mp: '∓', + setminus: '∖', + smallsetminus: '∖', + Backslash: '∖', + setmn: '∖', + ssetmn: '∖', + lowbar: '_', + verbar: '|', + vert: '|', + VerticalLine: '|', + colon: ':', + Colon: '∷', + Proportion: '∷', + ratio: '∶', + equals: '=', + ne: '≠', + nequiv: '≢', + equiv: '≡', + Congruent: '≡', + sim: '∼', + thicksim: '∼', + thksim: '∼', + sime: '≃', + simeq: '≃', + TildeEqual: '≃', + asymp: '≈', + approx: '≈', + thickapprox: '≈', + thkap: '≈', + TildeTilde: '≈', + ncong: '≇', + cong: '≅', + TildeFullEqual: '≅', + asympeq: '≍', + CupCap: '≍', + bump: '≎', + Bumpeq: '≎', + HumpDownHump: '≎', + bumpe: '≏', + bumpeq: '≏', + HumpEqual: '≏', + le: '≤', + LessEqual: '≤', + ge: '≥', + GreaterEqual: '≥', + lesseqgtr: '⋚', + lesseqqgtr: '⪋', + greater: '>', + less: '<', +}; + +/** + * Mathematical Operators (Advanced) + * @type {Record} + */ +export const MATH_ADVANCED = { + alefsym: 'ℵ', + aleph: 'ℵ', + beth: 'ℶ', + gimel: 'ℷ', + daleth: 'ℸ', + forall: '∀', + ForAll: '∀', + part: '∂', + PartialD: '∂', + exist: '∃', + Exists: '∃', + nexist: '∄', + nexists: '∄', + empty: '∅', + emptyset: '∅', + emptyv: '∅', + varnothing: '∅', + nabla: '∇', + Del: '∇', + isin: '∈', + isinv: '∈', + in: '∈', + Element: '∈', + notin: '∉', + notinva: '∉', + ni: '∋', + niv: '∋', + SuchThat: '∋', + ReverseElement: '∋', + notni: '∌', + notniva: '∌', + prod: '∏', + Product: '∏', + coprod: '∐', + Coproduct: '∐', + sum: '∑', + Sum: '∑', + minus: '−', + mp: '∓', + plusdo: '∔', + dotplus: '∔', + setminus: '∖', + lowast: '∗', + radic: '√', + Sqrt: '√', + prop: '∝', + propto: '∝', + Proportional: '∝', + varpropto: '∝', + infin: '∞', + infintie: '⧝', + ang: '∠', + angle: '∠', + angmsd: '∡', + measuredangle: '∡', + angsph: '∢', + mid: '∣', + VerticalBar: '∣', + nmid: '∤', + nsmid: '∤', + npar: '∦', + parallel: '∥', + spar: '∥', + nparallel: '∦', + nspar: '∦', + and: '∧', + wedge: '∧', + or: '∨', + vee: '∨', + cap: '∩', + cup: '∪', + int: '∫', + Integral: '∫', + conint: '∮', + ContourIntegral: '∮', + Conint: '∯', + DoubleContourIntegral: '∯', + Cconint: '∰', + there4: '∴', + therefore: '∴', + Therefore: '∴', + becaus: '∵', + because: '∵', + Because: '∵', + ratio: '∶', + Proportion: '∷', + minusd: '∸', + dotminus: '∸', + mDDot: '∺', + homtht: '∻', + sim: '∼', + bsimg: '∽', + backsim: '∽', + ac: '∾', + mstpos: '∾', + acd: '∿', + VerticalTilde: '≀', + wr: '≀', + wreath: '≀', + nsime: '≄', + nsimeq: '≄', + ncong: '≇', + simne: '≆', + ncongdot: '⩭̸', + ngsim: '≵', + nsim: '≁', + napprox: '≉', + nap: '≉', + ngeq: '≱', + nge: '≱', + nleq: '≰', + nle: '≰', + ngtr: '≯', + ngt: '≯', + nless: '≮', + nlt: '≮', + nprec: '⊀', + npr: '⊀', + nsucc: '⊁', + nsc: '⊁', +}; + +/** + * Arrows + * @type {Record} + */ +export const ARROWS = { + larr: '←', + leftarrow: '←', + LeftArrow: '←', + uarr: '↑', + uparrow: '↑', + UpArrow: '↑', + rarr: '→', + rightarrow: '→', + RightArrow: '→', + darr: '↓', + downarrow: '↓', + DownArrow: '↓', + harr: '↔', + leftrightarrow: '↔', + LeftRightArrow: '↔', + varr: '↕', + updownarrow: '↕', + UpDownArrow: '↕', + nwarr: '↖', + nwarrow: '↖', + UpperLeftArrow: '↖', + nearr: '↗', + nearrow: '↗', + UpperRightArrow: '↗', + searr: '↘', + searrow: '↘', + LowerRightArrow: '↘', + swarr: '↙', + swarrow: '↙', + LowerLeftArrow: '↙', + lArr: '⇐', + Leftarrow: '⇐', + uArr: '⇑', + Uparrow: '⇑', + rArr: '⇒', + Rightarrow: '⇒', + dArr: '⇓', + Downarrow: '⇓', + hArr: '⇔', + Leftrightarrow: '⇔', + iff: '⇔', + vArr: '⇕', + Updownarrow: '⇕', + lAarr: '⇚', + Lleftarrow: '⇚', + rAarr: '⇛', + Rrightarrow: '⇛', + lrarr: '⇆', + leftrightarrows: '⇆', + rlarr: '⇄', + rightleftarrows: '⇄', + lrhar: '⇋', + leftrightharpoons: '⇋', + ReverseEquilibrium: '⇋', + rlhar: '⇌', + rightleftharpoons: '⇌', + Equilibrium: '⇌', + udarr: '⇅', + UpArrowDownArrow: '⇅', + duarr: '⇵', + DownArrowUpArrow: '⇵', + llarr: '⇇', + leftleftarrows: '⇇', + rrarr: '⇉', + rightrightarrows: '⇉', + ddarr: '⇊', + downdownarrows: '⇊', + har: '↽', + lhard: '↽', + leftharpoondown: '↽', + lharu: '↼', + leftharpoonup: '↼', + rhard: '⇁', + rightharpoondown: '⇁', + rharu: '⇀', + rightharpoonup: '⇀', + lsh: '↰', + Lsh: '↰', + rsh: '↱', + Rsh: '↱', + ldsh: '↲', + rdsh: '↳', + hookleftarrow: '↩', + hookrightarrow: '↪', + mapstoleft: '↤', + mapstoup: '↥', + map: '↦', + mapsto: '↦', + mapstodown: '↧', + crarr: '↵', + nleftarrow: '↚', + nleftrightarrow: '↮', + nrightarrow: '↛', + nrarr: '↛', + larrtl: '↢', + rarrtl: '↣', + leftarrowtail: '↢', + rightarrowtail: '↣', + twoheadleftarrow: '↞', + twoheadrightarrow: '↠', + Larr: '↞', + Rarr: '↠', + larrhk: '↩', + rarrhk: '↪', + larrlp: '↫', + looparrowleft: '↫', + rarrlp: '↬', + looparrowright: '↬', + harrw: '↭', + leftrightsquigarrow: '↭', + nrarrw: '↝̸', + rarrw: '↝', + rightsquigarrow: '↝', + larrbfs: '⤟', + rarrbfs: '⤠', + nvHarr: '⤄', + nvlArr: '⤂', + nvrArr: '⤃', + larrfs: '⤝', + rarrfs: '⤞', + Map: '⤅', + larrsim: '⥳', + rarrsim: '⥴', + harrcir: '⥈', + Uarrocir: '⥉', + lurdshar: '⥊', + ldrdhar: '⥧', + ldrushar: '⥋', + rdldhar: '⥩', + lrhard: '⥭', + uharr: '↾', + uharl: '↿', + dharr: '⇂', + dharl: '⇃', + Uarr: '↟', + Darr: '↡', + zigrarr: '⇝', + nwArr: '⇖', + neArr: '⇗', + seArr: '⇘', + swArr: '⇙', + nharr: '↮', + nhArr: '⇎', + nlarr: '↚', + nlArr: '⇍', + nrArr: '⇏', + larrb: '⇤', + LeftArrowBar: '⇤', + rarrb: '⇥', + RightArrowBar: '⇥', +}; + +/** + * Geometric Shapes + * @type {Record} + */ +export const SHAPES = { + square: '□', + Square: '□', + squ: '□', + squf: '▪', + squarf: '▪', + blacksquar: '▪', + blacksquare: '▪', + FilledVerySmallSquare: '▪', + blk34: '▓', + blk12: '▒', + blk14: '░', + block: '█', + srect: '▭', + rect: '▭', + sdot: '⋅', + sdotb: '⊡', + dotsquare: '⊡', + triangle: '▵', + tri: '▵', + trine: '▵', + utri: '▵', + triangledown: '▿', + dtri: '▿', + tridown: '▿', + triangleleft: '◃', + ltri: '◃', + triangleright: '▹', + rtri: '▹', + blacktriangle: '▴', + utrif: '▴', + blacktriangledown: '▾', + dtrif: '▾', + blacktriangleleft: '◂', + ltrif: '◂', + blacktriangleright: '▸', + rtrif: '▸', + loz: '◊', + lozenge: '◊', + blacklozenge: '⧫', + lozf: '⧫', + bigcirc: '◯', + xcirc: '◯', + circ: 'ˆ', + Circle: '○', + cir: '○', + o: '○', + bullet: '•', + bull: '•', + hellip: '…', + mldr: '…', + nldr: '‥', + boxh: '─', + HorizontalLine: '─', + boxv: '│', + boxdr: '┌', + boxdl: '┐', + boxur: '└', + boxul: '┘', + boxvr: '├', + boxvl: '┤', + boxhd: '┬', + boxhu: '┴', + boxvh: '┼', + boxH: '═', + boxV: '║', + boxdR: '╒', + boxDr: '╓', + boxDR: '╔', + boxDl: '╕', + boxdL: '╖', + boxDL: '╗', + boxuR: '╘', + boxUr: '╙', + boxUR: '╚', + boxUl: '╜', + boxuL: '╛', + boxUL: '╝', + boxvR: '╞', + boxVr: '╟', + boxVR: '╠', + boxVl: '╢', + boxvL: '╡', + boxVL: '╣', + boxHd: '╤', + boxhD: '╥', + boxHD: '╦', + boxHu: '╧', + boxhU: '╨', + boxHU: '╩', + boxvH: '╪', + boxVh: '╫', + boxVH: '╬', +}; + +/** + * Punctuation & Diacritics + * @type {Record} + */ +export const PUNCTUATION = { + excl: '!', + iexcl: '¡', + brvbar: '¦', + sect: '§', + uml: '¨', + copy: '©', + ordf: 'ª', + laquo: '«', + not: '¬', + shy: '\u00ad', + reg: '®', + macr: '¯', + deg: '°', + plusmn: '±', + sup2: '²', + sup3: '³', + acute: '´', + micro: 'µ', + para: '¶', + middot: '·', + cedil: '¸', + sup1: '¹', + ordm: 'º', + raquo: '»', + frac14: '¼', + frac12: '½', + frac34: '¾', + iquest: '¿', + nbsp: '\u00a0', + comma: ',', + period: '.', + colon: ':', + semi: ';', + vert: '|', + Verbar: '‖', + verbar: '|', + dblac: '˝', + circ: 'ˆ', + caron: 'ˇ', + breve: '˘', + dot: '˙', + ring: '˚', + ogon: '˛', + tilde: '˜', + DiacriticalGrave: '`', + DiacriticalAcute: '´', + DiacriticalTilde: '˜', + DiacriticalDot: '˙', + DiacriticalDoubleAcute: '˝', + grave: '`', +}; + +/** + * Currency Symbols + * @type {Record} + */ +export const CURRENCY = { + cent: '¢', + pound: '£', + curren: '¤', + yen: '¥', + euro: '€', + dollar: '$', + fnof: 'ƒ', + inr: '₹', + af: '؋', + birr: 'ብር', + peso: '₱', + rub: '₽', + won: '₩', + yuan: '¥', + cedil: '¸', +}; + +/** + * Fractions + * @type {Record} + */ +export const FRACTIONS = { + frac12: '½', + half: '½', + frac13: '⅓', + frac14: '¼', + frac15: '⅕', + frac16: '⅙', + frac18: '⅛', + frac23: '⅔', + frac25: '⅖', + frac34: '¾', + frac35: '⅗', + frac38: '⅜', + frac45: '⅘', + frac56: '⅚', + frac58: '⅝', + frac78: '⅞', + frasl: '⁄', +}; + +/** + * Miscellaneous Symbols + * @type {Record} + */ +export const MISC_SYMBOLS = { + trade: '™', + TRADE: '™', + telrec: '⌕', + target: '⌖', + ulcorn: '⌜', + ulcorner: '⌜', + urcorn: '⌝', + urcorner: '⌝', + dlcorn: '⌞', + llcorner: '⌞', + drcorn: '⌟', + lrcorner: '⌟', + intercal: '⊺', + intcal: '⊺', + oplus: '⊕', + CirclePlus: '⊕', + ominus: '⊖', + CircleMinus: '⊖', + otimes: '⊗', + CircleTimes: '⊗', + osol: '⊘', + odot: '⊙', + CircleDot: '⊙', + oast: '⊛', + circledast: '⊛', + odash: '⊝', + circleddash: '⊝', + ocirc: '⊚', + circledcirc: '⊚', + boxplus: '⊞', + plusb: '⊞', + boxminus: '⊟', + minusb: '⊟', + boxtimes: '⊠', + timesb: '⊠', + boxdot: '⊡', + sdotb: '⊡', + veebar: '⊻', + vee: '∨', + barvee: '⊽', + and: '∧', + wedge: '∧', + Cap: '⋒', + Cup: '⋓', + Fork: '⋔', + pitchfork: '⋔', + epar: '⋕', + ltlarr: '⥶', + nvap: '≍⃒', + nvsim: '∼⃒', + nvge: '≥⃒', + nvle: '≤⃒', + nvlt: '<⃒', + nvgt: '>⃒', + nvltrie: '⊴⃒', + nvrtrie: '⊵⃒', + Vdash: '⊩', + dashv: '⊣', + vDash: '⊨', + Vvdash: '⊪', + nvdash: '⊬', + nvDash: '⊭', + nVdash: '⊮', + nVDash: '⊯', +}; + +/** + * All entities combined (if you need everything) + * @type {Record} + */ +export const ALL_ENTITIES = { + ...BASIC_LATIN, + ...LATIN_ACCENTS, + ...LATIN_EXTENDED, + ...GREEK, + ...CYRILLIC, + ...MATH, + ...MATH_ADVANCED, + ...ARROWS, + ...SHAPES, + ...PUNCTUATION, + ...CURRENCY, + ...FRACTIONS, + ...MISC_SYMBOLS, +}; + +export const XML = { + amp: "&", + apos: "'", + gt: ">", + lt: "<", + quot: "\"" +} +export const COMMON_HTML = { + nbsp: '\u00a0', + copy: '\u00a9', + reg: '\u00ae', + trade: '\u2122', + mdash: '\u2014', + ndash: '\u2013', + hellip: '\u2026', + laquo: '\u00ab', + raquo: '\u00bb', + lsquo: '\u2018', + rsquo: '\u2019', + ldquo: '\u201c', + rdquo: '\u201d', + bull: '\u2022', + para: '\u00b6', + sect: '\u00a7', + deg: '\u00b0', + frac12: '\u00bd', + frac14: '\u00bc', + frac34: '\u00be', +} +// --------------------------------------------------------------------------- +// Note: NUMERIC_ENTITIES (&#NNN; / &#xHH;) are handled by the scanner directly +// via String.fromCodePoint() without any map lookup. +// --------------------------------------------------------------------------- \ No newline at end of file diff --git a/node_modules/@nodable/entities/src/entityTries.js b/node_modules/@nodable/entities/src/entityTries.js new file mode 100644 index 0000000000000000000000000000000000000000..9565ebdda0343391f2a4c57b5a537c79f6c226ce --- /dev/null +++ b/node_modules/@nodable/entities/src/entityTries.js @@ -0,0 +1,49 @@ +// entityTries.js +// Builds integer-keyed tries so the decoder never allocates a string object +// during lookup — every key is a plain charCode number. +// +// trie1: Map +// trie2: Map> +// trie3: Map>> + +import { ALL_ENTITIES } from './entities.js'; + +// Reverse map: character sequence → "&name;" +const CHAR_TO_ENTITY = new Map(); +for (const [name, chars] of Object.entries(ALL_ENTITIES)) { + CHAR_TO_ENTITY.set(chars, `&${name};`); +} + +export const trie1 = new Map(); // code0 → entity string +export const trie2 = new Map(); // code0 → Map → entity string +export const trie3 = new Map(); // code0 → Map → Map → entity string + +for (const [chars, entity] of CHAR_TO_ENTITY) { + const len = chars.length; + + if (len === 1) { + const c0 = chars.charCodeAt(0); + // Keep shortest match only if no longer match already claimed this code + // (longer matches are inserted in the same pass so we just overwrite — + // trie1 is only consulted after trie2/trie3 both miss, so no conflict) + trie1.set(c0, entity); + + } else if (len === 2) { + const c0 = chars.charCodeAt(0); + const c1 = chars.charCodeAt(1); + let inner = trie2.get(c0); + if (inner === undefined) { inner = new Map(); trie2.set(c0, inner); } + inner.set(c1, entity); + + } else if (len === 3) { + const c0 = chars.charCodeAt(0); + const c1 = chars.charCodeAt(1); + const c2 = chars.charCodeAt(2); + let mid = trie3.get(c0); + if (mid === undefined) { mid = new Map(); trie3.set(c0, mid); } + let inner = mid.get(c1); + if (inner === undefined) { inner = new Map(); mid.set(c1, inner); } + inner.set(c2, entity); + } + // HTML5 has no named entity whose character sequence is longer than 3 chars +} \ No newline at end of file diff --git a/node_modules/@nodable/entities/src/index.d.ts b/node_modules/@nodable/entities/src/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..130a38daf3d4f1083142f4cd7fe2f45a67277b48 --- /dev/null +++ b/node_modules/@nodable/entities/src/index.d.ts @@ -0,0 +1,341 @@ +// --------------------------------------------------------------------------- +// @nodable/entities — TypeScript declarations +// --------------------------------------------------------------------------- + +/** A function-based entity replacement value (used for numeric refs). */ +export type EntityValFn = (match: string, captured: string, ...rest: unknown[]) => string; + +// --------------------------------------------------------------------------- +// Entity registration hook +// --------------------------------------------------------------------------- + +/** + * Actions returned by `onExternalEntity` / `onInputEntity` hooks. + * Use the `ENTITY_ACTION` constant object instead of raw strings to avoid typos. + * + * - `'allow'` — register and expand the entity normally + * - `'block'` — silently skip the entity (not registered, treated as unknown) + * - `'throw'` — abort registration with an error + */ +export type EntityHookAction = 'allow' | 'block' | 'throw'; + +/** + * Immutable constant bag for entity registration hook return values. + * + * @example + * import { ENTITY_ACTION } from '@nodable/entities'; + * const dec = new EntityDecoder({ + * onInputEntity: (_name, _value) => ENTITY_ACTION.BLOCK, + * }); + */ +export const ENTITY_ACTION: Readonly<{ + /** Register and expand the entity normally. */ + ALLOW: 'allow'; + /** Silently skip this entity — it will not be registered. */ + BLOCK: 'block'; + /** Throw an error, aborting entity registration. */ + THROW: 'throw'; +}>; + +/** + * Callback signature for `onExternalEntity` and `onInputEntity` hooks. + * + * Called once per entity **at registration time** (not at decode time). + * Return `ENTITY_ACTION.ALLOW` (or `'allow'`) to accept, `ENTITY_ACTION.BLOCK` + * to silently skip, or `ENTITY_ACTION.THROW` to raise an error. + * + * @param name — the entity name without `&` / `;`, e.g. `"brand"` + * @param value — the resolved string value after any `{regex,val}` unwrapping + */ +export type EntityRegistrationHook = (name: string, value: string) => EntityHookAction; + +// --------------------------------------------------------------------------- +// Encoder options +// --------------------------------------------------------------------------- + +export interface EntityEncoderOptions { + /** + * Whether to encode XML unsafe characters: `&`, `<`, `>`, `"`, `'`. + * @default true + */ + encodeXmlSafe?: boolean; + + /** + * Whether to encode non‑ASCII characters (e.g. `é` → `é`) using the + * built‑in named entity trie. + * @default true + */ + encodeAllNamed?: boolean; + + /** + * Maximum number of replacements performed **cumulatively** across all + * `encode()` calls. `0` means unlimited. + * + * Use `reset()` to reset the internal counter. + * @default 0 + */ + maxReplacements?: number; +} + +// --------------------------------------------------------------------------- +// EntityEncoder class +// --------------------------------------------------------------------------- + +/** + * High‑performance encoder that replaces characters with XML/HTML entities. + * + * - Escapes XML unsafe characters (`&`, `<`, `>`, `"`, `'`) when `encodeXmlSafe` is true. + * - Replaces non‑ASCII characters (e.g. `é`, `©`) with named entities using + * a compact trie‑based lookup when `encodeAllNamed` is true. + * - Supports a cumulative replacement limit (`maxReplacements`) that persists + * across multiple `encode()` calls until `reset()` is called. + * + * @example + * const encoder = new EntityEncoder({ encodeXmlSafe: true, encodeAllNamed: true }); + * encoder.encode(''); // "<foo>" + * encoder.encode('© 2025'); // "© 2025" + * + * // With limit + * const limited = new EntityEncoder({ maxReplacements: 2 }); + * limited.encode('<>&'); // "<>&" (third replacement omitted) + * limited.reset(); // reset counter + */ +export class EntityEncoder { + constructor(options?: EntityEncoderOptions); + + /** + * Encode a string by replacing XML‑unsafe characters and (optionally) + * non‑ASCII characters with named entities. + * + * If `maxReplacements` is set and the cumulative limit has been reached, + * the input string is returned unchanged. + * + * @returns Encoded string (may be identical to input if no replacements needed + * or the limit has been exhausted). + */ + encode(str: string): string; + + /** + * Reset the internal replacement counter. + * Does **not** change `encodeXmlSafe`, `encodeAllNamed`, or `maxReplacements`. + */ + reset(): void; +} + +// --------------------------------------------------------------------------- +// Constructor options for EntityDecoder (existing) +// --------------------------------------------------------------------------- + +/** + * Controls which entity categories count toward the expansion limits. + * + * - `'external'` — only untrusted / injected entities (default) + * - `'base'` — only built‑in XML entities + user‑supplied `namedEntities` + * - `'all'` — all entities regardless of tier + * - `string[]` — explicit combination, e.g. `['external', 'base']` + */ +export type ApplyLimitsTo = 'external' | 'base' | 'all' | Array<'external' | 'base'>; + +export interface EntityDecoderLimitOptions { + /** + * Maximum number of entity references expanded **per document**. + * `0` means unlimited. + * @default 0 + */ + maxTotalExpansions?: number; + + /** + * Maximum number of characters **added** by entity expansion per document. + * `0` means unlimited. + * @default 0 + */ + maxExpandedLength?: number; + + /** + * Which entity tiers count toward the expansion limits. + * + * - `'external'` (default) – only input/runtime + persistent external entities + * - `'base'` – only built‑in XML + `namedEntities` + * - `'all'` – every entity regardless of tier + * - `string[]` – explicit combination, e.g. `['external', 'base']` + * + * @default 'external' + */ + applyLimitsTo?: ApplyLimitsTo; +} + +export interface EntityDecoderNCROptions { + /** + * XML version used for NCR classification. + * @default 1.0 + */ + xmlVersion?: 1.0 | 1.1; + + /** + * Base action for all numeric references. + * @default 'allow' + */ + onNCR?: 'allow' | 'leave' | 'remove' | 'throw'; + + /** + * Action for null NCR (U+0000). + * @default 'remove' + */ + nullNCR?: 'remove' | 'throw'; +} + +export interface EntityDecoderOptions { + /** + * Extra named entities merged into the **base map** (trusted, counts as `'base'` tier). + * These are combined with the built‑in XML entities (`lt`, `gt`, `quot`, `apos`). + * Values containing `&` are silently skipped to prevent recursive expansion. + * + * @default null + */ + namedEntities?: Record | null; + + + /** + * Hook called once on the fully decoded string (after all replacements). + * + * - Receives `(resolved, original)` and **must return a string**. + * - To reject expansion, return `original`. + * - To sanitize, return a cleaned version of `resolved`. + * + * @example + * postCheck: (resolved, original) => + * /<[a-z]/i.test(resolved) ? original : resolved + */ + postCheck?: ((resolved: string, original: string) => string) | null; + + /** + * Whether numeric character references (`&#NNN;`, `&#xHH;`) are allowed. + * @default true + */ + numericAllowed?: boolean; + + /** + * Array of entity names or numeric references to leave unexpanded. + * @default [] + */ + leave?: string[]; + + /** + * Array of entity names or numeric references to remove. + * @default [] + */ + remove?: string[]; + + /** + * Security limits for entity expansion. + */ + limit?: EntityDecoderLimitOptions; + + /** + * Numeric Character Reference (NCR) policy. + */ + ncr?: EntityDecoderNCROptions; + + /** + * Hook called once **at registration time** for each entity passed to + * `setExternalEntities()` or `addExternalEntity()`. + * + * - `'allow'` (or `ENTITY_ACTION.ALLOW`) — register the entity normally (default) + * - `'block'` (or `ENTITY_ACTION.BLOCK`) — silently skip; the entity is not stored + * - `'throw'` (or `ENTITY_ACTION.THROW`) — abort registration with an `Error` + * + * The hook receives the entity name (without `&`/`;`) and the resolved string + * value. It is **not** called during `decode()` — only when entities are added. + * + * @example + * const dec = new EntityDecoder({ + * onExternalEntity: (name, value) => + * DANGEROUS_NAMES.has(name) ? ENTITY_ACTION.BLOCK : ENTITY_ACTION.ALLOW, + * }); + */ + onExternalEntity?: EntityRegistrationHook | null; + + /** + * Hook called once **at registration time** for each entity passed to + * `addInputEntities()`. + * + * Follows the same `'allow' | 'block' | 'throw'` contract as `onExternalEntity`. + * + * @example + * const dec = new EntityDecoder({ + * // Block all input / DOCTYPE entities unconditionally + * onInputEntity: () => ENTITY_ACTION.BLOCK, + * }); + */ + onInputEntity?: EntityRegistrationHook | null; +} + +// --------------------------------------------------------------------------- +// EntityDecoder class (default export) +// --------------------------------------------------------------------------- + +/** + * Single‑pass, zero‑regex entity decoder for XML/HTML content. + * + * ## Entity lookup priority (highest → lowest) + * 1. **input / runtime** – injected via `addInputEntities()` (DOCTYPE per document) + * 2. **persistent external** – set via `setExternalEntities()` / `addExternalEntity()` + * 3. **base map** – built‑in XML entities + user‑supplied `namedEntities` + * + * Numeric references (`&#NNN;`, `&#xHH;`) are resolved directly and count as the `'base'` tier. + * + * @example + * const decoder = new EntityDecoder({ + * namedEntities: COMMON_HTML, + * maxTotalExpansions: 100 + * }); + * decoder.setExternalEntities({ brand: 'Acme' }); + * + * decoder.addInputEntities({ version: '1.0' }); + * decoder.decode('&brand; v&version; <'); // 'Acme v1.0 <' + * + * decoder.reset(); // clears input entities + counters, keeps external entities + */ +export default class EntityDecoder { + constructor(options?: EntityDecoderOptions); + + setExternalEntities( + map: Record + ): void; + + addExternalEntity(key: string, value: string): void; + + addInputEntities( + map: Record< + string, + | string + | { regx: RegExp; val: string | EntityValFn } + | { regex: RegExp; val: string | EntityValFn } + > + ): void; + + reset(): this; + + decode(str: string): string; +} + +// --------------------------------------------------------------------------- +// Named entity group exports (for use with `namedEntities` option) +// --------------------------------------------------------------------------- + +export const COMMON_HTML: Record; +export const ALL_ENTITIES: Record; +export const XML: Record; +export const BASIC_LATIN: Record; +export const LATIN_ACCENTS: Record; +export const LATIN_EXTENDED: Record; +export const GREEK: Record; +export const CYRILLIC: Record; +export const MATH: Record; +export const MATH_ADVANCED: Record; +export const ARROWS: Record; +export const SHAPES: Record; +export const PUNCTUATION: Record; +export const CURRENCY: Record; +export const FRACTIONS: Record; +export const MISC_SYMBOLS: Record; \ No newline at end of file diff --git a/node_modules/@nodable/entities/src/index.js b/node_modules/@nodable/entities/src/index.js new file mode 100644 index 0000000000000000000000000000000000000000..4707b8b71cb06b54423802eac5c009349d3db8a4 --- /dev/null +++ b/node_modules/@nodable/entities/src/index.js @@ -0,0 +1,29 @@ +/** + * @nodable/entities + * + * Standalone, zero-dependency XML/HTML entity replacement. + * + + */ + +export { default as EntityDecoder, ENTITY_ACTION } from './EntityDecoder.js'; +export { + COMMON_HTML, + XML, + ALL_ENTITIES, + ARROWS, + BASIC_LATIN, + CURRENCY, + MATH, + MATH_ADVANCED, + CYRILLIC, + FRACTIONS, + GREEK, + LATIN_ACCENTS, + LATIN_EXTENDED, + MISC_SYMBOLS, + PUNCTUATION, + SHAPES, +} from './entities.js'; + +export { default as EntityEncoder } from './EntityEncoder.js'; \ No newline at end of file diff --git a/node_modules/@nodelib/fs.scandir/LICENSE b/node_modules/@nodelib/fs.scandir/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..65a999460170355f6383b8f122da09e66e485165 --- /dev/null +++ b/node_modules/@nodelib/fs.scandir/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Denis Malinochkin + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@nodelib/fs.scandir/README.md b/node_modules/@nodelib/fs.scandir/README.md new file mode 100644 index 0000000000000000000000000000000000000000..e0b218b9f090cbf38b4a75f1f6b83b46bf8e4476 --- /dev/null +++ b/node_modules/@nodelib/fs.scandir/README.md @@ -0,0 +1,171 @@ +# @nodelib/fs.scandir + +> List files and directories inside the specified directory. + +## :bulb: Highlights + +The package is aimed at obtaining information about entries in the directory. + +* :moneybag: Returns useful information: `name`, `path`, `dirent` and `stats` (optional). +* :gear: On Node.js 10.10+ uses the mechanism without additional calls to determine the entry type. See [`old` and `modern` mode](#old-and-modern-mode). +* :link: Can safely work with broken symbolic links. + +## Install + +```console +npm install @nodelib/fs.scandir +``` + +## Usage + +```ts +import * as fsScandir from '@nodelib/fs.scandir'; + +fsScandir.scandir('path', (error, stats) => { /* … */ }); +``` + +## API + +### .scandir(path, [optionsOrSettings], callback) + +Returns an array of plain objects ([`Entry`](#entry)) with information about entry for provided path with standard callback-style. + +```ts +fsScandir.scandir('path', (error, entries) => { /* … */ }); +fsScandir.scandir('path', {}, (error, entries) => { /* … */ }); +fsScandir.scandir('path', new fsScandir.Settings(), (error, entries) => { /* … */ }); +``` + +### .scandirSync(path, [optionsOrSettings]) + +Returns an array of plain objects ([`Entry`](#entry)) with information about entry for provided path. + +```ts +const entries = fsScandir.scandirSync('path'); +const entries = fsScandir.scandirSync('path', {}); +const entries = fsScandir.scandirSync(('path', new fsScandir.Settings()); +``` + +#### path + +* Required: `true` +* Type: `string | Buffer | URL` + +A path to a file. If a URL is provided, it must use the `file:` protocol. + +#### optionsOrSettings + +* Required: `false` +* Type: `Options | Settings` +* Default: An instance of `Settings` class + +An [`Options`](#options) object or an instance of [`Settings`](#settingsoptions) class. + +> :book: When you pass a plain object, an instance of the `Settings` class will be created automatically. If you plan to call the method frequently, use a pre-created instance of the `Settings` class. + +### Settings([options]) + +A class of full settings of the package. + +```ts +const settings = new fsScandir.Settings({ followSymbolicLinks: false }); + +const entries = fsScandir.scandirSync('path', settings); +``` + +## Entry + +* `name` — The name of the entry (`unknown.txt`). +* `path` — The path of the entry relative to call directory (`root/unknown.txt`). +* `dirent` — An instance of [`fs.Dirent`](./src/types/index.ts) class. On Node.js below 10.10 will be emulated by [`DirentFromStats`](./src/utils/fs.ts) class. +* `stats` (optional) — An instance of `fs.Stats` class. + +For example, the `scandir` call for `tools` directory with one directory inside: + +```ts +{ + dirent: Dirent { name: 'typedoc', /* … */ }, + name: 'typedoc', + path: 'tools/typedoc' +} +``` + +## Options + +### stats + +* Type: `boolean` +* Default: `false` + +Adds an instance of `fs.Stats` class to the [`Entry`](#entry). + +> :book: Always use `fs.readdir` without the `withFileTypes` option. ??TODO?? + +### followSymbolicLinks + +* Type: `boolean` +* Default: `false` + +Follow symbolic links or not. Call `fs.stat` on symbolic link if `true`. + +### `throwErrorOnBrokenSymbolicLink` + +* Type: `boolean` +* Default: `true` + +Throw an error when symbolic link is broken if `true` or safely use `lstat` call if `false`. + +### `pathSegmentSeparator` + +* Type: `string` +* Default: `path.sep` + +By default, this package uses the correct path separator for your OS (`\` on Windows, `/` on Unix-like systems). But you can set this option to any separator character(s) that you want to use instead. + +### `fs` + +* Type: [`FileSystemAdapter`](./src/adapters/fs.ts) +* Default: A default FS methods + +By default, the built-in Node.js module (`fs`) is used to work with the file system. You can replace any method with your own. + +```ts +interface FileSystemAdapter { + lstat?: typeof fs.lstat; + stat?: typeof fs.stat; + lstatSync?: typeof fs.lstatSync; + statSync?: typeof fs.statSync; + readdir?: typeof fs.readdir; + readdirSync?: typeof fs.readdirSync; +} + +const settings = new fsScandir.Settings({ + fs: { lstat: fakeLstat } +}); +``` + +## `old` and `modern` mode + +This package has two modes that are used depending on the environment and parameters of use. + +### old + +* Node.js below `10.10` or when the `stats` option is enabled + +When working in the old mode, the directory is read first (`fs.readdir`), then the type of entries is determined (`fs.lstat` and/or `fs.stat` for symbolic links). + +### modern + +* Node.js 10.10+ and the `stats` option is disabled + +In the modern mode, reading the directory (`fs.readdir` with the `withFileTypes` option) is combined with obtaining information about its entries. An additional call for symbolic links (`fs.stat`) is still present. + +This mode makes fewer calls to the file system. It's faster. + +## Changelog + +See the [Releases section of our GitHub project](https://github.com/nodelib/nodelib/releases) for changelog for each release version. + +## License + +This software is released under the terms of the MIT license. diff --git a/node_modules/@nodelib/fs.scandir/out/adapters/fs.d.ts b/node_modules/@nodelib/fs.scandir/out/adapters/fs.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..827f1db09aac5d9f6b2e63d56a509ae67faaf0e6 --- /dev/null +++ b/node_modules/@nodelib/fs.scandir/out/adapters/fs.d.ts @@ -0,0 +1,20 @@ +import type * as fsStat from '@nodelib/fs.stat'; +import type { Dirent, ErrnoException } from '../types'; +export interface ReaddirAsynchronousMethod { + (filepath: string, options: { + withFileTypes: true; + }, callback: (error: ErrnoException | null, files: Dirent[]) => void): void; + (filepath: string, callback: (error: ErrnoException | null, files: string[]) => void): void; +} +export interface ReaddirSynchronousMethod { + (filepath: string, options: { + withFileTypes: true; + }): Dirent[]; + (filepath: string): string[]; +} +export declare type FileSystemAdapter = fsStat.FileSystemAdapter & { + readdir: ReaddirAsynchronousMethod; + readdirSync: ReaddirSynchronousMethod; +}; +export declare const FILE_SYSTEM_ADAPTER: FileSystemAdapter; +export declare function createFileSystemAdapter(fsMethods?: Partial): FileSystemAdapter; diff --git a/node_modules/@nodelib/fs.scandir/out/adapters/fs.js b/node_modules/@nodelib/fs.scandir/out/adapters/fs.js new file mode 100644 index 0000000000000000000000000000000000000000..f0fe022023e6dfd5b56c33f2bac6d2d3b180e1c5 --- /dev/null +++ b/node_modules/@nodelib/fs.scandir/out/adapters/fs.js @@ -0,0 +1,19 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0; +const fs = require("fs"); +exports.FILE_SYSTEM_ADAPTER = { + lstat: fs.lstat, + stat: fs.stat, + lstatSync: fs.lstatSync, + statSync: fs.statSync, + readdir: fs.readdir, + readdirSync: fs.readdirSync +}; +function createFileSystemAdapter(fsMethods) { + if (fsMethods === undefined) { + return exports.FILE_SYSTEM_ADAPTER; + } + return Object.assign(Object.assign({}, exports.FILE_SYSTEM_ADAPTER), fsMethods); +} +exports.createFileSystemAdapter = createFileSystemAdapter; diff --git a/node_modules/@nodelib/fs.scandir/out/constants.d.ts b/node_modules/@nodelib/fs.scandir/out/constants.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..33f17497d43b391287e2c9fc65d1c7cb4668ea50 --- /dev/null +++ b/node_modules/@nodelib/fs.scandir/out/constants.d.ts @@ -0,0 +1,4 @@ +/** + * IS `true` for Node.js 10.10 and greater. + */ +export declare const IS_SUPPORT_READDIR_WITH_FILE_TYPES: boolean; diff --git a/node_modules/@nodelib/fs.scandir/out/constants.js b/node_modules/@nodelib/fs.scandir/out/constants.js new file mode 100644 index 0000000000000000000000000000000000000000..7e3d4411f751e190be8794b687e9fa60ef5fae06 --- /dev/null +++ b/node_modules/@nodelib/fs.scandir/out/constants.js @@ -0,0 +1,17 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.IS_SUPPORT_READDIR_WITH_FILE_TYPES = void 0; +const NODE_PROCESS_VERSION_PARTS = process.versions.node.split('.'); +if (NODE_PROCESS_VERSION_PARTS[0] === undefined || NODE_PROCESS_VERSION_PARTS[1] === undefined) { + throw new Error(`Unexpected behavior. The 'process.versions.node' variable has invalid value: ${process.versions.node}`); +} +const MAJOR_VERSION = Number.parseInt(NODE_PROCESS_VERSION_PARTS[0], 10); +const MINOR_VERSION = Number.parseInt(NODE_PROCESS_VERSION_PARTS[1], 10); +const SUPPORTED_MAJOR_VERSION = 10; +const SUPPORTED_MINOR_VERSION = 10; +const IS_MATCHED_BY_MAJOR = MAJOR_VERSION > SUPPORTED_MAJOR_VERSION; +const IS_MATCHED_BY_MAJOR_AND_MINOR = MAJOR_VERSION === SUPPORTED_MAJOR_VERSION && MINOR_VERSION >= SUPPORTED_MINOR_VERSION; +/** + * IS `true` for Node.js 10.10 and greater. + */ +exports.IS_SUPPORT_READDIR_WITH_FILE_TYPES = IS_MATCHED_BY_MAJOR || IS_MATCHED_BY_MAJOR_AND_MINOR; diff --git a/node_modules/@nodelib/fs.scandir/out/index.d.ts b/node_modules/@nodelib/fs.scandir/out/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b9da83ed172315106269d96bb9043c922af68cc5 --- /dev/null +++ b/node_modules/@nodelib/fs.scandir/out/index.d.ts @@ -0,0 +1,12 @@ +import type { FileSystemAdapter, ReaddirAsynchronousMethod, ReaddirSynchronousMethod } from './adapters/fs'; +import * as async from './providers/async'; +import Settings, { Options } from './settings'; +import type { Dirent, Entry } from './types'; +declare type AsyncCallback = async.AsyncCallback; +declare function scandir(path: string, callback: AsyncCallback): void; +declare function scandir(path: string, optionsOrSettings: Options | Settings, callback: AsyncCallback): void; +declare namespace scandir { + function __promisify__(path: string, optionsOrSettings?: Options | Settings): Promise; +} +declare function scandirSync(path: string, optionsOrSettings?: Options | Settings): Entry[]; +export { scandir, scandirSync, Settings, AsyncCallback, Dirent, Entry, FileSystemAdapter, ReaddirAsynchronousMethod, ReaddirSynchronousMethod, Options }; diff --git a/node_modules/@nodelib/fs.scandir/out/index.js b/node_modules/@nodelib/fs.scandir/out/index.js new file mode 100644 index 0000000000000000000000000000000000000000..99c70d3d635f73d2704b02695933770401b14d37 --- /dev/null +++ b/node_modules/@nodelib/fs.scandir/out/index.js @@ -0,0 +1,26 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Settings = exports.scandirSync = exports.scandir = void 0; +const async = require("./providers/async"); +const sync = require("./providers/sync"); +const settings_1 = require("./settings"); +exports.Settings = settings_1.default; +function scandir(path, optionsOrSettingsOrCallback, callback) { + if (typeof optionsOrSettingsOrCallback === 'function') { + async.read(path, getSettings(), optionsOrSettingsOrCallback); + return; + } + async.read(path, getSettings(optionsOrSettingsOrCallback), callback); +} +exports.scandir = scandir; +function scandirSync(path, optionsOrSettings) { + const settings = getSettings(optionsOrSettings); + return sync.read(path, settings); +} +exports.scandirSync = scandirSync; +function getSettings(settingsOrOptions = {}) { + if (settingsOrOptions instanceof settings_1.default) { + return settingsOrOptions; + } + return new settings_1.default(settingsOrOptions); +} diff --git a/node_modules/@nodelib/fs.scandir/out/providers/async.d.ts b/node_modules/@nodelib/fs.scandir/out/providers/async.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5829676df7e302e14b87edf2d99c04b58384d0af --- /dev/null +++ b/node_modules/@nodelib/fs.scandir/out/providers/async.d.ts @@ -0,0 +1,7 @@ +/// +import type Settings from '../settings'; +import type { Entry } from '../types'; +export declare type AsyncCallback = (error: NodeJS.ErrnoException, entries: Entry[]) => void; +export declare function read(directory: string, settings: Settings, callback: AsyncCallback): void; +export declare function readdirWithFileTypes(directory: string, settings: Settings, callback: AsyncCallback): void; +export declare function readdir(directory: string, settings: Settings, callback: AsyncCallback): void; diff --git a/node_modules/@nodelib/fs.scandir/out/providers/async.js b/node_modules/@nodelib/fs.scandir/out/providers/async.js new file mode 100644 index 0000000000000000000000000000000000000000..e8e2f0a9cba94ed06b7762f2846ab88330aaa44e --- /dev/null +++ b/node_modules/@nodelib/fs.scandir/out/providers/async.js @@ -0,0 +1,104 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.readdir = exports.readdirWithFileTypes = exports.read = void 0; +const fsStat = require("@nodelib/fs.stat"); +const rpl = require("run-parallel"); +const constants_1 = require("../constants"); +const utils = require("../utils"); +const common = require("./common"); +function read(directory, settings, callback) { + if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) { + readdirWithFileTypes(directory, settings, callback); + return; + } + readdir(directory, settings, callback); +} +exports.read = read; +function readdirWithFileTypes(directory, settings, callback) { + settings.fs.readdir(directory, { withFileTypes: true }, (readdirError, dirents) => { + if (readdirError !== null) { + callFailureCallback(callback, readdirError); + return; + } + const entries = dirents.map((dirent) => ({ + dirent, + name: dirent.name, + path: common.joinPathSegments(directory, dirent.name, settings.pathSegmentSeparator) + })); + if (!settings.followSymbolicLinks) { + callSuccessCallback(callback, entries); + return; + } + const tasks = entries.map((entry) => makeRplTaskEntry(entry, settings)); + rpl(tasks, (rplError, rplEntries) => { + if (rplError !== null) { + callFailureCallback(callback, rplError); + return; + } + callSuccessCallback(callback, rplEntries); + }); + }); +} +exports.readdirWithFileTypes = readdirWithFileTypes; +function makeRplTaskEntry(entry, settings) { + return (done) => { + if (!entry.dirent.isSymbolicLink()) { + done(null, entry); + return; + } + settings.fs.stat(entry.path, (statError, stats) => { + if (statError !== null) { + if (settings.throwErrorOnBrokenSymbolicLink) { + done(statError); + return; + } + done(null, entry); + return; + } + entry.dirent = utils.fs.createDirentFromStats(entry.name, stats); + done(null, entry); + }); + }; +} +function readdir(directory, settings, callback) { + settings.fs.readdir(directory, (readdirError, names) => { + if (readdirError !== null) { + callFailureCallback(callback, readdirError); + return; + } + const tasks = names.map((name) => { + const path = common.joinPathSegments(directory, name, settings.pathSegmentSeparator); + return (done) => { + fsStat.stat(path, settings.fsStatSettings, (error, stats) => { + if (error !== null) { + done(error); + return; + } + const entry = { + name, + path, + dirent: utils.fs.createDirentFromStats(name, stats) + }; + if (settings.stats) { + entry.stats = stats; + } + done(null, entry); + }); + }; + }); + rpl(tasks, (rplError, entries) => { + if (rplError !== null) { + callFailureCallback(callback, rplError); + return; + } + callSuccessCallback(callback, entries); + }); + }); +} +exports.readdir = readdir; +function callFailureCallback(callback, error) { + callback(error); +} +function callSuccessCallback(callback, result) { + callback(null, result); +} diff --git a/node_modules/@nodelib/fs.scandir/out/providers/common.d.ts b/node_modules/@nodelib/fs.scandir/out/providers/common.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2b4d08b57a0de23a030b494abbb236239638b122 --- /dev/null +++ b/node_modules/@nodelib/fs.scandir/out/providers/common.d.ts @@ -0,0 +1 @@ +export declare function joinPathSegments(a: string, b: string, separator: string): string; diff --git a/node_modules/@nodelib/fs.scandir/out/providers/common.js b/node_modules/@nodelib/fs.scandir/out/providers/common.js new file mode 100644 index 0000000000000000000000000000000000000000..8724cb59afe97cdfebdf6b50bdf36534537e781c --- /dev/null +++ b/node_modules/@nodelib/fs.scandir/out/providers/common.js @@ -0,0 +1,13 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.joinPathSegments = void 0; +function joinPathSegments(a, b, separator) { + /** + * The correct handling of cases when the first segment is a root (`/`, `C:/`) or UNC path (`//?/C:/`). + */ + if (a.endsWith(separator)) { + return a + b; + } + return a + separator + b; +} +exports.joinPathSegments = joinPathSegments; diff --git a/node_modules/@nodelib/fs.scandir/out/providers/sync.d.ts b/node_modules/@nodelib/fs.scandir/out/providers/sync.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e05c8f072cb5766844c31f6d8424c692f0caacac --- /dev/null +++ b/node_modules/@nodelib/fs.scandir/out/providers/sync.d.ts @@ -0,0 +1,5 @@ +import type Settings from '../settings'; +import type { Entry } from '../types'; +export declare function read(directory: string, settings: Settings): Entry[]; +export declare function readdirWithFileTypes(directory: string, settings: Settings): Entry[]; +export declare function readdir(directory: string, settings: Settings): Entry[]; diff --git a/node_modules/@nodelib/fs.scandir/out/providers/sync.js b/node_modules/@nodelib/fs.scandir/out/providers/sync.js new file mode 100644 index 0000000000000000000000000000000000000000..146db3434f42252e4071db1624074a666fe21b4a --- /dev/null +++ b/node_modules/@nodelib/fs.scandir/out/providers/sync.js @@ -0,0 +1,54 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.readdir = exports.readdirWithFileTypes = exports.read = void 0; +const fsStat = require("@nodelib/fs.stat"); +const constants_1 = require("../constants"); +const utils = require("../utils"); +const common = require("./common"); +function read(directory, settings) { + if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) { + return readdirWithFileTypes(directory, settings); + } + return readdir(directory, settings); +} +exports.read = read; +function readdirWithFileTypes(directory, settings) { + const dirents = settings.fs.readdirSync(directory, { withFileTypes: true }); + return dirents.map((dirent) => { + const entry = { + dirent, + name: dirent.name, + path: common.joinPathSegments(directory, dirent.name, settings.pathSegmentSeparator) + }; + if (entry.dirent.isSymbolicLink() && settings.followSymbolicLinks) { + try { + const stats = settings.fs.statSync(entry.path); + entry.dirent = utils.fs.createDirentFromStats(entry.name, stats); + } + catch (error) { + if (settings.throwErrorOnBrokenSymbolicLink) { + throw error; + } + } + } + return entry; + }); +} +exports.readdirWithFileTypes = readdirWithFileTypes; +function readdir(directory, settings) { + const names = settings.fs.readdirSync(directory); + return names.map((name) => { + const entryPath = common.joinPathSegments(directory, name, settings.pathSegmentSeparator); + const stats = fsStat.statSync(entryPath, settings.fsStatSettings); + const entry = { + name, + path: entryPath, + dirent: utils.fs.createDirentFromStats(name, stats) + }; + if (settings.stats) { + entry.stats = stats; + } + return entry; + }); +} +exports.readdir = readdir; diff --git a/node_modules/@nodelib/fs.scandir/out/settings.d.ts b/node_modules/@nodelib/fs.scandir/out/settings.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a0db11559914a553d8e2da52b612bf48f2d5dd74 --- /dev/null +++ b/node_modules/@nodelib/fs.scandir/out/settings.d.ts @@ -0,0 +1,20 @@ +import * as fsStat from '@nodelib/fs.stat'; +import * as fs from './adapters/fs'; +export interface Options { + followSymbolicLinks?: boolean; + fs?: Partial; + pathSegmentSeparator?: string; + stats?: boolean; + throwErrorOnBrokenSymbolicLink?: boolean; +} +export default class Settings { + private readonly _options; + readonly followSymbolicLinks: boolean; + readonly fs: fs.FileSystemAdapter; + readonly pathSegmentSeparator: string; + readonly stats: boolean; + readonly throwErrorOnBrokenSymbolicLink: boolean; + readonly fsStatSettings: fsStat.Settings; + constructor(_options?: Options); + private _getValue; +} diff --git a/node_modules/@nodelib/fs.scandir/out/settings.js b/node_modules/@nodelib/fs.scandir/out/settings.js new file mode 100644 index 0000000000000000000000000000000000000000..15a3e8cde7704afdc4d66723ac440c2acb7e3519 --- /dev/null +++ b/node_modules/@nodelib/fs.scandir/out/settings.js @@ -0,0 +1,24 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const path = require("path"); +const fsStat = require("@nodelib/fs.stat"); +const fs = require("./adapters/fs"); +class Settings { + constructor(_options = {}) { + this._options = _options; + this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, false); + this.fs = fs.createFileSystemAdapter(this._options.fs); + this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path.sep); + this.stats = this._getValue(this._options.stats, false); + this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true); + this.fsStatSettings = new fsStat.Settings({ + followSymbolicLink: this.followSymbolicLinks, + fs: this.fs, + throwErrorOnBrokenSymbolicLink: this.throwErrorOnBrokenSymbolicLink + }); + } + _getValue(option, value) { + return option !== null && option !== void 0 ? option : value; + } +} +exports.default = Settings; diff --git a/node_modules/@nodelib/fs.scandir/out/types/index.d.ts b/node_modules/@nodelib/fs.scandir/out/types/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f326c5e5e41f3288779c97c777e782e5642aed1f --- /dev/null +++ b/node_modules/@nodelib/fs.scandir/out/types/index.d.ts @@ -0,0 +1,20 @@ +/// +import type * as fs from 'fs'; +export interface Entry { + dirent: Dirent; + name: string; + path: string; + stats?: Stats; +} +export declare type Stats = fs.Stats; +export declare type ErrnoException = NodeJS.ErrnoException; +export interface Dirent { + isBlockDevice: () => boolean; + isCharacterDevice: () => boolean; + isDirectory: () => boolean; + isFIFO: () => boolean; + isFile: () => boolean; + isSocket: () => boolean; + isSymbolicLink: () => boolean; + name: string; +} diff --git a/node_modules/@nodelib/fs.scandir/out/types/index.js b/node_modules/@nodelib/fs.scandir/out/types/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c8ad2e549bdc6801e0d1c80b0308d4b9bd4985ce --- /dev/null +++ b/node_modules/@nodelib/fs.scandir/out/types/index.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/node_modules/@nodelib/fs.scandir/out/utils/fs.d.ts b/node_modules/@nodelib/fs.scandir/out/utils/fs.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bb863f1573e99fe2fe287dcdd8d22c075dd014e1 --- /dev/null +++ b/node_modules/@nodelib/fs.scandir/out/utils/fs.d.ts @@ -0,0 +1,2 @@ +import type { Dirent, Stats } from '../types'; +export declare function createDirentFromStats(name: string, stats: Stats): Dirent; diff --git a/node_modules/@nodelib/fs.scandir/out/utils/fs.js b/node_modules/@nodelib/fs.scandir/out/utils/fs.js new file mode 100644 index 0000000000000000000000000000000000000000..ace7c74d63f6da763b2711a4119d6005f5c3b187 --- /dev/null +++ b/node_modules/@nodelib/fs.scandir/out/utils/fs.js @@ -0,0 +1,19 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createDirentFromStats = void 0; +class DirentFromStats { + constructor(name, stats) { + this.name = name; + this.isBlockDevice = stats.isBlockDevice.bind(stats); + this.isCharacterDevice = stats.isCharacterDevice.bind(stats); + this.isDirectory = stats.isDirectory.bind(stats); + this.isFIFO = stats.isFIFO.bind(stats); + this.isFile = stats.isFile.bind(stats); + this.isSocket = stats.isSocket.bind(stats); + this.isSymbolicLink = stats.isSymbolicLink.bind(stats); + } +} +function createDirentFromStats(name, stats) { + return new DirentFromStats(name, stats); +} +exports.createDirentFromStats = createDirentFromStats; diff --git a/node_modules/@nodelib/fs.scandir/out/utils/index.d.ts b/node_modules/@nodelib/fs.scandir/out/utils/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1b41954e79d847e0f085ce4235b8ee62fddb1977 --- /dev/null +++ b/node_modules/@nodelib/fs.scandir/out/utils/index.d.ts @@ -0,0 +1,2 @@ +import * as fs from './fs'; +export { fs }; diff --git a/node_modules/@nodelib/fs.scandir/out/utils/index.js b/node_modules/@nodelib/fs.scandir/out/utils/index.js new file mode 100644 index 0000000000000000000000000000000000000000..f5de129f47b80353304d3219c96f73f59a390397 --- /dev/null +++ b/node_modules/@nodelib/fs.scandir/out/utils/index.js @@ -0,0 +1,5 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.fs = void 0; +const fs = require("./fs"); +exports.fs = fs; diff --git a/node_modules/@nodelib/fs.scandir/package.json b/node_modules/@nodelib/fs.scandir/package.json new file mode 100644 index 0000000000000000000000000000000000000000..d3a89241b3c1891339651dfdeb9495813587e289 --- /dev/null +++ b/node_modules/@nodelib/fs.scandir/package.json @@ -0,0 +1,44 @@ +{ + "name": "@nodelib/fs.scandir", + "version": "2.1.5", + "description": "List files and directories inside the specified directory", + "license": "MIT", + "repository": "https://github.com/nodelib/nodelib/tree/master/packages/fs/fs.scandir", + "keywords": [ + "NodeLib", + "fs", + "FileSystem", + "file system", + "scandir", + "readdir", + "dirent" + ], + "engines": { + "node": ">= 8" + }, + "files": [ + "out/**", + "!out/**/*.map", + "!out/**/*.spec.*" + ], + "main": "out/index.js", + "typings": "out/index.d.ts", + "scripts": { + "clean": "rimraf {tsconfig.tsbuildinfo,out}", + "lint": "eslint \"src/**/*.ts\" --cache", + "compile": "tsc -b .", + "compile:watch": "tsc -p . --watch --sourceMap", + "test": "mocha \"out/**/*.spec.js\" -s 0", + "build": "npm run clean && npm run compile && npm run lint && npm test", + "watch": "npm run clean && npm run compile:watch" + }, + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "devDependencies": { + "@nodelib/fs.macchiato": "1.0.4", + "@types/run-parallel": "^1.1.0" + }, + "gitHead": "d6a7960d5281d3dd5f8e2efba49bb552d090f562" +} diff --git a/node_modules/@nodelib/fs.stat/LICENSE b/node_modules/@nodelib/fs.stat/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..65a999460170355f6383b8f122da09e66e485165 --- /dev/null +++ b/node_modules/@nodelib/fs.stat/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Denis Malinochkin + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@nodelib/fs.stat/README.md b/node_modules/@nodelib/fs.stat/README.md new file mode 100644 index 0000000000000000000000000000000000000000..686f0471d40f2f522e53db44f5a5b7a73a65e9df --- /dev/null +++ b/node_modules/@nodelib/fs.stat/README.md @@ -0,0 +1,126 @@ +# @nodelib/fs.stat + +> Get the status of a file with some features. + +## :bulb: Highlights + +Wrapper around standard method `fs.lstat` and `fs.stat` with some features. + +* :beginner: Normally follows symbolic link. +* :gear: Can safely work with broken symbolic link. + +## Install + +```console +npm install @nodelib/fs.stat +``` + +## Usage + +```ts +import * as fsStat from '@nodelib/fs.stat'; + +fsStat.stat('path', (error, stats) => { /* … */ }); +``` + +## API + +### .stat(path, [optionsOrSettings], callback) + +Returns an instance of `fs.Stats` class for provided path with standard callback-style. + +```ts +fsStat.stat('path', (error, stats) => { /* … */ }); +fsStat.stat('path', {}, (error, stats) => { /* … */ }); +fsStat.stat('path', new fsStat.Settings(), (error, stats) => { /* … */ }); +``` + +### .statSync(path, [optionsOrSettings]) + +Returns an instance of `fs.Stats` class for provided path. + +```ts +const stats = fsStat.stat('path'); +const stats = fsStat.stat('path', {}); +const stats = fsStat.stat('path', new fsStat.Settings()); +``` + +#### path + +* Required: `true` +* Type: `string | Buffer | URL` + +A path to a file. If a URL is provided, it must use the `file:` protocol. + +#### optionsOrSettings + +* Required: `false` +* Type: `Options | Settings` +* Default: An instance of `Settings` class + +An [`Options`](#options) object or an instance of [`Settings`](#settings) class. + +> :book: When you pass a plain object, an instance of the `Settings` class will be created automatically. If you plan to call the method frequently, use a pre-created instance of the `Settings` class. + +### Settings([options]) + +A class of full settings of the package. + +```ts +const settings = new fsStat.Settings({ followSymbolicLink: false }); + +const stats = fsStat.stat('path', settings); +``` + +## Options + +### `followSymbolicLink` + +* Type: `boolean` +* Default: `true` + +Follow symbolic link or not. Call `fs.stat` on symbolic link if `true`. + +### `markSymbolicLink` + +* Type: `boolean` +* Default: `false` + +Mark symbolic link by setting the return value of `isSymbolicLink` function to always `true` (even after `fs.stat`). + +> :book: Can be used if you want to know what is hidden behind a symbolic link, but still continue to know that it is a symbolic link. + +### `throwErrorOnBrokenSymbolicLink` + +* Type: `boolean` +* Default: `true` + +Throw an error when symbolic link is broken if `true` or safely return `lstat` call if `false`. + +### `fs` + +* Type: [`FileSystemAdapter`](./src/adapters/fs.ts) +* Default: A default FS methods + +By default, the built-in Node.js module (`fs`) is used to work with the file system. You can replace any method with your own. + +```ts +interface FileSystemAdapter { + lstat?: typeof fs.lstat; + stat?: typeof fs.stat; + lstatSync?: typeof fs.lstatSync; + statSync?: typeof fs.statSync; +} + +const settings = new fsStat.Settings({ + fs: { lstat: fakeLstat } +}); +``` + +## Changelog + +See the [Releases section of our GitHub project](https://github.com/nodelib/nodelib/releases) for changelog for each release version. + +## License + +This software is released under the terms of the MIT license. diff --git a/node_modules/@nodelib/fs.stat/out/adapters/fs.d.ts b/node_modules/@nodelib/fs.stat/out/adapters/fs.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3af759c95fb85c927bc8204a49c5eaca37d691d2 --- /dev/null +++ b/node_modules/@nodelib/fs.stat/out/adapters/fs.d.ts @@ -0,0 +1,13 @@ +/// +import * as fs from 'fs'; +import type { ErrnoException } from '../types'; +export declare type StatAsynchronousMethod = (path: string, callback: (error: ErrnoException | null, stats: fs.Stats) => void) => void; +export declare type StatSynchronousMethod = (path: string) => fs.Stats; +export interface FileSystemAdapter { + lstat: StatAsynchronousMethod; + stat: StatAsynchronousMethod; + lstatSync: StatSynchronousMethod; + statSync: StatSynchronousMethod; +} +export declare const FILE_SYSTEM_ADAPTER: FileSystemAdapter; +export declare function createFileSystemAdapter(fsMethods?: Partial): FileSystemAdapter; diff --git a/node_modules/@nodelib/fs.stat/out/adapters/fs.js b/node_modules/@nodelib/fs.stat/out/adapters/fs.js new file mode 100644 index 0000000000000000000000000000000000000000..8dc08c8ca1f1c72aa9622352ca5d55f65198767d --- /dev/null +++ b/node_modules/@nodelib/fs.stat/out/adapters/fs.js @@ -0,0 +1,17 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0; +const fs = require("fs"); +exports.FILE_SYSTEM_ADAPTER = { + lstat: fs.lstat, + stat: fs.stat, + lstatSync: fs.lstatSync, + statSync: fs.statSync +}; +function createFileSystemAdapter(fsMethods) { + if (fsMethods === undefined) { + return exports.FILE_SYSTEM_ADAPTER; + } + return Object.assign(Object.assign({}, exports.FILE_SYSTEM_ADAPTER), fsMethods); +} +exports.createFileSystemAdapter = createFileSystemAdapter; diff --git a/node_modules/@nodelib/fs.stat/out/index.d.ts b/node_modules/@nodelib/fs.stat/out/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f95db995c7f8fd07939359f4885835eebcd9e0fc --- /dev/null +++ b/node_modules/@nodelib/fs.stat/out/index.d.ts @@ -0,0 +1,12 @@ +import type { FileSystemAdapter, StatAsynchronousMethod, StatSynchronousMethod } from './adapters/fs'; +import * as async from './providers/async'; +import Settings, { Options } from './settings'; +import type { Stats } from './types'; +declare type AsyncCallback = async.AsyncCallback; +declare function stat(path: string, callback: AsyncCallback): void; +declare function stat(path: string, optionsOrSettings: Options | Settings, callback: AsyncCallback): void; +declare namespace stat { + function __promisify__(path: string, optionsOrSettings?: Options | Settings): Promise; +} +declare function statSync(path: string, optionsOrSettings?: Options | Settings): Stats; +export { Settings, stat, statSync, AsyncCallback, FileSystemAdapter, StatAsynchronousMethod, StatSynchronousMethod, Options, Stats }; diff --git a/node_modules/@nodelib/fs.stat/out/index.js b/node_modules/@nodelib/fs.stat/out/index.js new file mode 100644 index 0000000000000000000000000000000000000000..b23f7510d050fe830d40765ad49fe72b21ebef5b --- /dev/null +++ b/node_modules/@nodelib/fs.stat/out/index.js @@ -0,0 +1,26 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.statSync = exports.stat = exports.Settings = void 0; +const async = require("./providers/async"); +const sync = require("./providers/sync"); +const settings_1 = require("./settings"); +exports.Settings = settings_1.default; +function stat(path, optionsOrSettingsOrCallback, callback) { + if (typeof optionsOrSettingsOrCallback === 'function') { + async.read(path, getSettings(), optionsOrSettingsOrCallback); + return; + } + async.read(path, getSettings(optionsOrSettingsOrCallback), callback); +} +exports.stat = stat; +function statSync(path, optionsOrSettings) { + const settings = getSettings(optionsOrSettings); + return sync.read(path, settings); +} +exports.statSync = statSync; +function getSettings(settingsOrOptions = {}) { + if (settingsOrOptions instanceof settings_1.default) { + return settingsOrOptions; + } + return new settings_1.default(settingsOrOptions); +} diff --git a/node_modules/@nodelib/fs.stat/out/providers/async.d.ts b/node_modules/@nodelib/fs.stat/out/providers/async.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..85423ce11e2efb74a86e9477405e1976fec6b7c5 --- /dev/null +++ b/node_modules/@nodelib/fs.stat/out/providers/async.d.ts @@ -0,0 +1,4 @@ +import type Settings from '../settings'; +import type { ErrnoException, Stats } from '../types'; +export declare type AsyncCallback = (error: ErrnoException, stats: Stats) => void; +export declare function read(path: string, settings: Settings, callback: AsyncCallback): void; diff --git a/node_modules/@nodelib/fs.stat/out/providers/async.js b/node_modules/@nodelib/fs.stat/out/providers/async.js new file mode 100644 index 0000000000000000000000000000000000000000..983ff0e6cb79f6e4442be70c43e79c6b406dd9bb --- /dev/null +++ b/node_modules/@nodelib/fs.stat/out/providers/async.js @@ -0,0 +1,36 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.read = void 0; +function read(path, settings, callback) { + settings.fs.lstat(path, (lstatError, lstat) => { + if (lstatError !== null) { + callFailureCallback(callback, lstatError); + return; + } + if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) { + callSuccessCallback(callback, lstat); + return; + } + settings.fs.stat(path, (statError, stat) => { + if (statError !== null) { + if (settings.throwErrorOnBrokenSymbolicLink) { + callFailureCallback(callback, statError); + return; + } + callSuccessCallback(callback, lstat); + return; + } + if (settings.markSymbolicLink) { + stat.isSymbolicLink = () => true; + } + callSuccessCallback(callback, stat); + }); + }); +} +exports.read = read; +function callFailureCallback(callback, error) { + callback(error); +} +function callSuccessCallback(callback, result) { + callback(null, result); +} diff --git a/node_modules/@nodelib/fs.stat/out/providers/sync.d.ts b/node_modules/@nodelib/fs.stat/out/providers/sync.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..428c3d792b385664fe3fe4770c46e558d7ca5285 --- /dev/null +++ b/node_modules/@nodelib/fs.stat/out/providers/sync.d.ts @@ -0,0 +1,3 @@ +import type Settings from '../settings'; +import type { Stats } from '../types'; +export declare function read(path: string, settings: Settings): Stats; diff --git a/node_modules/@nodelib/fs.stat/out/providers/sync.js b/node_modules/@nodelib/fs.stat/out/providers/sync.js new file mode 100644 index 0000000000000000000000000000000000000000..1521c3616eaee4439c5cd1a855c97d029d4dab38 --- /dev/null +++ b/node_modules/@nodelib/fs.stat/out/providers/sync.js @@ -0,0 +1,23 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.read = void 0; +function read(path, settings) { + const lstat = settings.fs.lstatSync(path); + if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) { + return lstat; + } + try { + const stat = settings.fs.statSync(path); + if (settings.markSymbolicLink) { + stat.isSymbolicLink = () => true; + } + return stat; + } + catch (error) { + if (!settings.throwErrorOnBrokenSymbolicLink) { + return lstat; + } + throw error; + } +} +exports.read = read; diff --git a/node_modules/@nodelib/fs.stat/out/settings.d.ts b/node_modules/@nodelib/fs.stat/out/settings.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f4b3d444302ff6b5715a79341156f61350bd0a1b --- /dev/null +++ b/node_modules/@nodelib/fs.stat/out/settings.d.ts @@ -0,0 +1,16 @@ +import * as fs from './adapters/fs'; +export interface Options { + followSymbolicLink?: boolean; + fs?: Partial; + markSymbolicLink?: boolean; + throwErrorOnBrokenSymbolicLink?: boolean; +} +export default class Settings { + private readonly _options; + readonly followSymbolicLink: boolean; + readonly fs: fs.FileSystemAdapter; + readonly markSymbolicLink: boolean; + readonly throwErrorOnBrokenSymbolicLink: boolean; + constructor(_options?: Options); + private _getValue; +} diff --git a/node_modules/@nodelib/fs.stat/out/settings.js b/node_modules/@nodelib/fs.stat/out/settings.js new file mode 100644 index 0000000000000000000000000000000000000000..111ec09ca6491ae6d8d9a9c9bdcb32c8408afcc4 --- /dev/null +++ b/node_modules/@nodelib/fs.stat/out/settings.js @@ -0,0 +1,16 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const fs = require("./adapters/fs"); +class Settings { + constructor(_options = {}) { + this._options = _options; + this.followSymbolicLink = this._getValue(this._options.followSymbolicLink, true); + this.fs = fs.createFileSystemAdapter(this._options.fs); + this.markSymbolicLink = this._getValue(this._options.markSymbolicLink, false); + this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true); + } + _getValue(option, value) { + return option !== null && option !== void 0 ? option : value; + } +} +exports.default = Settings; diff --git a/node_modules/@nodelib/fs.stat/out/types/index.d.ts b/node_modules/@nodelib/fs.stat/out/types/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..74c08ed2f7a1201d2e28453602b83241d83ade82 --- /dev/null +++ b/node_modules/@nodelib/fs.stat/out/types/index.d.ts @@ -0,0 +1,4 @@ +/// +import type * as fs from 'fs'; +export declare type Stats = fs.Stats; +export declare type ErrnoException = NodeJS.ErrnoException; diff --git a/node_modules/@nodelib/fs.stat/out/types/index.js b/node_modules/@nodelib/fs.stat/out/types/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c8ad2e549bdc6801e0d1c80b0308d4b9bd4985ce --- /dev/null +++ b/node_modules/@nodelib/fs.stat/out/types/index.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/node_modules/@nodelib/fs.stat/package.json b/node_modules/@nodelib/fs.stat/package.json new file mode 100644 index 0000000000000000000000000000000000000000..f2540c2894ea9181f73274a493df0dc3789d6128 --- /dev/null +++ b/node_modules/@nodelib/fs.stat/package.json @@ -0,0 +1,37 @@ +{ + "name": "@nodelib/fs.stat", + "version": "2.0.5", + "description": "Get the status of a file with some features", + "license": "MIT", + "repository": "https://github.com/nodelib/nodelib/tree/master/packages/fs/fs.stat", + "keywords": [ + "NodeLib", + "fs", + "FileSystem", + "file system", + "stat" + ], + "engines": { + "node": ">= 8" + }, + "files": [ + "out/**", + "!out/**/*.map", + "!out/**/*.spec.*" + ], + "main": "out/index.js", + "typings": "out/index.d.ts", + "scripts": { + "clean": "rimraf {tsconfig.tsbuildinfo,out}", + "lint": "eslint \"src/**/*.ts\" --cache", + "compile": "tsc -b .", + "compile:watch": "tsc -p . --watch --sourceMap", + "test": "mocha \"out/**/*.spec.js\" -s 0", + "build": "npm run clean && npm run compile && npm run lint && npm test", + "watch": "npm run clean && npm run compile:watch" + }, + "devDependencies": { + "@nodelib/fs.macchiato": "1.0.4" + }, + "gitHead": "d6a7960d5281d3dd5f8e2efba49bb552d090f562" +} diff --git a/node_modules/@nodelib/fs.walk/LICENSE b/node_modules/@nodelib/fs.walk/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..65a999460170355f6383b8f122da09e66e485165 --- /dev/null +++ b/node_modules/@nodelib/fs.walk/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Denis Malinochkin + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@nodelib/fs.walk/README.md b/node_modules/@nodelib/fs.walk/README.md new file mode 100644 index 0000000000000000000000000000000000000000..6ccc08db4a10bca492f2db7b547b98a7f22a4e8c --- /dev/null +++ b/node_modules/@nodelib/fs.walk/README.md @@ -0,0 +1,215 @@ +# @nodelib/fs.walk + +> A library for efficiently walking a directory recursively. + +## :bulb: Highlights + +* :moneybag: Returns useful information: `name`, `path`, `dirent` and `stats` (optional). +* :rocket: On Node.js 10.10+ uses the mechanism without additional calls to determine the entry type for performance reasons. See [`old` and `modern` mode](https://github.com/nodelib/nodelib/blob/master/packages/fs/fs.scandir/README.md#old-and-modern-mode). +* :gear: Built-in directories/files and error filtering system. +* :link: Can safely work with broken symbolic links. + +## Install + +```console +npm install @nodelib/fs.walk +``` + +## Usage + +```ts +import * as fsWalk from '@nodelib/fs.walk'; + +fsWalk.walk('path', (error, entries) => { /* … */ }); +``` + +## API + +### .walk(path, [optionsOrSettings], callback) + +Reads the directory recursively and asynchronously. Requires a callback function. + +> :book: If you want to use the Promise API, use `util.promisify`. + +```ts +fsWalk.walk('path', (error, entries) => { /* … */ }); +fsWalk.walk('path', {}, (error, entries) => { /* … */ }); +fsWalk.walk('path', new fsWalk.Settings(), (error, entries) => { /* … */ }); +``` + +### .walkStream(path, [optionsOrSettings]) + +Reads the directory recursively and asynchronously. [Readable Stream](https://nodejs.org/dist/latest-v12.x/docs/api/stream.html#stream_readable_streams) is used as a provider. + +```ts +const stream = fsWalk.walkStream('path'); +const stream = fsWalk.walkStream('path', {}); +const stream = fsWalk.walkStream('path', new fsWalk.Settings()); +``` + +### .walkSync(path, [optionsOrSettings]) + +Reads the directory recursively and synchronously. Returns an array of entries. + +```ts +const entries = fsWalk.walkSync('path'); +const entries = fsWalk.walkSync('path', {}); +const entries = fsWalk.walkSync('path', new fsWalk.Settings()); +``` + +#### path + +* Required: `true` +* Type: `string | Buffer | URL` + +A path to a file. If a URL is provided, it must use the `file:` protocol. + +#### optionsOrSettings + +* Required: `false` +* Type: `Options | Settings` +* Default: An instance of `Settings` class + +An [`Options`](#options) object or an instance of [`Settings`](#settings) class. + +> :book: When you pass a plain object, an instance of the `Settings` class will be created automatically. If you plan to call the method frequently, use a pre-created instance of the `Settings` class. + +### Settings([options]) + +A class of full settings of the package. + +```ts +const settings = new fsWalk.Settings({ followSymbolicLinks: true }); + +const entries = fsWalk.walkSync('path', settings); +``` + +## Entry + +* `name` — The name of the entry (`unknown.txt`). +* `path` — The path of the entry relative to call directory (`root/unknown.txt`). +* `dirent` — An instance of [`fs.Dirent`](./src/types/index.ts) class. +* [`stats`] — An instance of `fs.Stats` class. + +## Options + +### basePath + +* Type: `string` +* Default: `undefined` + +By default, all paths are built relative to the root path. You can use this option to set custom root path. + +In the example below we read the files from the `root` directory, but in the results the root path will be `custom`. + +```ts +fsWalk.walkSync('root'); // → ['root/file.txt'] +fsWalk.walkSync('root', { basePath: 'custom' }); // → ['custom/file.txt'] +``` + +### concurrency + +* Type: `number` +* Default: `Infinity` + +The maximum number of concurrent calls to `fs.readdir`. + +> :book: The higher the number, the higher performance and the load on the File System. If you want to read in quiet mode, set the value to `4 * os.cpus().length` (4 is default size of [thread pool work scheduling](http://docs.libuv.org/en/v1.x/threadpool.html#thread-pool-work-scheduling)). + +### deepFilter + +* Type: [`DeepFilterFunction`](./src/settings.ts) +* Default: `undefined` + +A function that indicates whether the directory will be read deep or not. + +```ts +// Skip all directories that starts with `node_modules` +const filter: DeepFilterFunction = (entry) => !entry.path.startsWith('node_modules'); +``` + +### entryFilter + +* Type: [`EntryFilterFunction`](./src/settings.ts) +* Default: `undefined` + +A function that indicates whether the entry will be included to results or not. + +```ts +// Exclude all `.js` files from results +const filter: EntryFilterFunction = (entry) => !entry.name.endsWith('.js'); +``` + +### errorFilter + +* Type: [`ErrorFilterFunction`](./src/settings.ts) +* Default: `undefined` + +A function that allows you to skip errors that occur when reading directories. + +For example, you can skip `ENOENT` errors if required: + +```ts +// Skip all ENOENT errors +const filter: ErrorFilterFunction = (error) => error.code == 'ENOENT'; +``` + +### stats + +* Type: `boolean` +* Default: `false` + +Adds an instance of `fs.Stats` class to the [`Entry`](#entry). + +> :book: Always use `fs.readdir` with additional `fs.lstat/fs.stat` calls to determine the entry type. + +### followSymbolicLinks + +* Type: `boolean` +* Default: `false` + +Follow symbolic links or not. Call `fs.stat` on symbolic link if `true`. + +### `throwErrorOnBrokenSymbolicLink` + +* Type: `boolean` +* Default: `true` + +Throw an error when symbolic link is broken if `true` or safely return `lstat` call if `false`. + +### `pathSegmentSeparator` + +* Type: `string` +* Default: `path.sep` + +By default, this package uses the correct path separator for your OS (`\` on Windows, `/` on Unix-like systems). But you can set this option to any separator character(s) that you want to use instead. + +### `fs` + +* Type: `FileSystemAdapter` +* Default: A default FS methods + +By default, the built-in Node.js module (`fs`) is used to work with the file system. You can replace any method with your own. + +```ts +interface FileSystemAdapter { + lstat: typeof fs.lstat; + stat: typeof fs.stat; + lstatSync: typeof fs.lstatSync; + statSync: typeof fs.statSync; + readdir: typeof fs.readdir; + readdirSync: typeof fs.readdirSync; +} + +const settings = new fsWalk.Settings({ + fs: { lstat: fakeLstat } +}); +``` + +## Changelog + +See the [Releases section of our GitHub project](https://github.com/nodelib/nodelib/releases) for changelog for each release version. + +## License + +This software is released under the terms of the MIT license. diff --git a/node_modules/@nodelib/fs.walk/out/index.d.ts b/node_modules/@nodelib/fs.walk/out/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8864c7bff5d8cb4a3db399a957f5eb49031d3248 --- /dev/null +++ b/node_modules/@nodelib/fs.walk/out/index.d.ts @@ -0,0 +1,14 @@ +/// +import type { Readable } from 'stream'; +import type { Dirent, FileSystemAdapter } from '@nodelib/fs.scandir'; +import { AsyncCallback } from './providers/async'; +import Settings, { DeepFilterFunction, EntryFilterFunction, ErrorFilterFunction, Options } from './settings'; +import type { Entry } from './types'; +declare function walk(directory: string, callback: AsyncCallback): void; +declare function walk(directory: string, optionsOrSettings: Options | Settings, callback: AsyncCallback): void; +declare namespace walk { + function __promisify__(directory: string, optionsOrSettings?: Options | Settings): Promise; +} +declare function walkSync(directory: string, optionsOrSettings?: Options | Settings): Entry[]; +declare function walkStream(directory: string, optionsOrSettings?: Options | Settings): Readable; +export { walk, walkSync, walkStream, Settings, AsyncCallback, Dirent, Entry, FileSystemAdapter, Options, DeepFilterFunction, EntryFilterFunction, ErrorFilterFunction }; diff --git a/node_modules/@nodelib/fs.walk/out/index.js b/node_modules/@nodelib/fs.walk/out/index.js new file mode 100644 index 0000000000000000000000000000000000000000..15207874afa1dadac7f7655545b4b1f75ee87a78 --- /dev/null +++ b/node_modules/@nodelib/fs.walk/out/index.js @@ -0,0 +1,34 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Settings = exports.walkStream = exports.walkSync = exports.walk = void 0; +const async_1 = require("./providers/async"); +const stream_1 = require("./providers/stream"); +const sync_1 = require("./providers/sync"); +const settings_1 = require("./settings"); +exports.Settings = settings_1.default; +function walk(directory, optionsOrSettingsOrCallback, callback) { + if (typeof optionsOrSettingsOrCallback === 'function') { + new async_1.default(directory, getSettings()).read(optionsOrSettingsOrCallback); + return; + } + new async_1.default(directory, getSettings(optionsOrSettingsOrCallback)).read(callback); +} +exports.walk = walk; +function walkSync(directory, optionsOrSettings) { + const settings = getSettings(optionsOrSettings); + const provider = new sync_1.default(directory, settings); + return provider.read(); +} +exports.walkSync = walkSync; +function walkStream(directory, optionsOrSettings) { + const settings = getSettings(optionsOrSettings); + const provider = new stream_1.default(directory, settings); + return provider.read(); +} +exports.walkStream = walkStream; +function getSettings(settingsOrOptions = {}) { + if (settingsOrOptions instanceof settings_1.default) { + return settingsOrOptions; + } + return new settings_1.default(settingsOrOptions); +} diff --git a/node_modules/@nodelib/fs.walk/out/providers/async.d.ts b/node_modules/@nodelib/fs.walk/out/providers/async.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0f6717d780f64fd49f31ba1cfccabb40eb5aafea --- /dev/null +++ b/node_modules/@nodelib/fs.walk/out/providers/async.d.ts @@ -0,0 +1,12 @@ +import AsyncReader from '../readers/async'; +import type Settings from '../settings'; +import type { Entry, Errno } from '../types'; +export declare type AsyncCallback = (error: Errno, entries: Entry[]) => void; +export default class AsyncProvider { + private readonly _root; + private readonly _settings; + protected readonly _reader: AsyncReader; + private readonly _storage; + constructor(_root: string, _settings: Settings); + read(callback: AsyncCallback): void; +} diff --git a/node_modules/@nodelib/fs.walk/out/providers/async.js b/node_modules/@nodelib/fs.walk/out/providers/async.js new file mode 100644 index 0000000000000000000000000000000000000000..51d3be51a85d46c5ab53f5b7d92675996d02887c --- /dev/null +++ b/node_modules/@nodelib/fs.walk/out/providers/async.js @@ -0,0 +1,30 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const async_1 = require("../readers/async"); +class AsyncProvider { + constructor(_root, _settings) { + this._root = _root; + this._settings = _settings; + this._reader = new async_1.default(this._root, this._settings); + this._storage = []; + } + read(callback) { + this._reader.onError((error) => { + callFailureCallback(callback, error); + }); + this._reader.onEntry((entry) => { + this._storage.push(entry); + }); + this._reader.onEnd(() => { + callSuccessCallback(callback, this._storage); + }); + this._reader.read(); + } +} +exports.default = AsyncProvider; +function callFailureCallback(callback, error) { + callback(error); +} +function callSuccessCallback(callback, entries) { + callback(null, entries); +} diff --git a/node_modules/@nodelib/fs.walk/out/providers/index.d.ts b/node_modules/@nodelib/fs.walk/out/providers/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..874f60c5a10b2f8fdfca1725fc1e8ff335e7549c --- /dev/null +++ b/node_modules/@nodelib/fs.walk/out/providers/index.d.ts @@ -0,0 +1,4 @@ +import AsyncProvider from './async'; +import StreamProvider from './stream'; +import SyncProvider from './sync'; +export { AsyncProvider, StreamProvider, SyncProvider }; diff --git a/node_modules/@nodelib/fs.walk/out/providers/index.js b/node_modules/@nodelib/fs.walk/out/providers/index.js new file mode 100644 index 0000000000000000000000000000000000000000..4c2529ce8a385a0215ddf188b8a46163b2e18842 --- /dev/null +++ b/node_modules/@nodelib/fs.walk/out/providers/index.js @@ -0,0 +1,9 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SyncProvider = exports.StreamProvider = exports.AsyncProvider = void 0; +const async_1 = require("./async"); +exports.AsyncProvider = async_1.default; +const stream_1 = require("./stream"); +exports.StreamProvider = stream_1.default; +const sync_1 = require("./sync"); +exports.SyncProvider = sync_1.default; diff --git a/node_modules/@nodelib/fs.walk/out/providers/stream.d.ts b/node_modules/@nodelib/fs.walk/out/providers/stream.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..294185f85dc59d2a40eec8b0fea2d87958e41cdf --- /dev/null +++ b/node_modules/@nodelib/fs.walk/out/providers/stream.d.ts @@ -0,0 +1,12 @@ +/// +import { Readable } from 'stream'; +import AsyncReader from '../readers/async'; +import type Settings from '../settings'; +export default class StreamProvider { + private readonly _root; + private readonly _settings; + protected readonly _reader: AsyncReader; + protected readonly _stream: Readable; + constructor(_root: string, _settings: Settings); + read(): Readable; +} diff --git a/node_modules/@nodelib/fs.walk/out/providers/stream.js b/node_modules/@nodelib/fs.walk/out/providers/stream.js new file mode 100644 index 0000000000000000000000000000000000000000..51298b0f58f14b0c9b9f36061cdd0c0b950ba2f3 --- /dev/null +++ b/node_modules/@nodelib/fs.walk/out/providers/stream.js @@ -0,0 +1,34 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const stream_1 = require("stream"); +const async_1 = require("../readers/async"); +class StreamProvider { + constructor(_root, _settings) { + this._root = _root; + this._settings = _settings; + this._reader = new async_1.default(this._root, this._settings); + this._stream = new stream_1.Readable({ + objectMode: true, + read: () => { }, + destroy: () => { + if (!this._reader.isDestroyed) { + this._reader.destroy(); + } + } + }); + } + read() { + this._reader.onError((error) => { + this._stream.emit('error', error); + }); + this._reader.onEntry((entry) => { + this._stream.push(entry); + }); + this._reader.onEnd(() => { + this._stream.push(null); + }); + this._reader.read(); + return this._stream; + } +} +exports.default = StreamProvider; diff --git a/node_modules/@nodelib/fs.walk/out/providers/sync.d.ts b/node_modules/@nodelib/fs.walk/out/providers/sync.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..551c42e41293756691160855d122f365710ac007 --- /dev/null +++ b/node_modules/@nodelib/fs.walk/out/providers/sync.d.ts @@ -0,0 +1,10 @@ +import SyncReader from '../readers/sync'; +import type Settings from '../settings'; +import type { Entry } from '../types'; +export default class SyncProvider { + private readonly _root; + private readonly _settings; + protected readonly _reader: SyncReader; + constructor(_root: string, _settings: Settings); + read(): Entry[]; +} diff --git a/node_modules/@nodelib/fs.walk/out/providers/sync.js b/node_modules/@nodelib/fs.walk/out/providers/sync.js new file mode 100644 index 0000000000000000000000000000000000000000..faab6ca2ad4262e2d9d5539b8c6ce0017090fd29 --- /dev/null +++ b/node_modules/@nodelib/fs.walk/out/providers/sync.js @@ -0,0 +1,14 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const sync_1 = require("../readers/sync"); +class SyncProvider { + constructor(_root, _settings) { + this._root = _root; + this._settings = _settings; + this._reader = new sync_1.default(this._root, this._settings); + } + read() { + return this._reader.read(); + } +} +exports.default = SyncProvider; diff --git a/node_modules/@nodelib/fs.walk/out/readers/async.d.ts b/node_modules/@nodelib/fs.walk/out/readers/async.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9acf4e6c25f383ab22f55ff79a7f2022f6238773 --- /dev/null +++ b/node_modules/@nodelib/fs.walk/out/readers/async.d.ts @@ -0,0 +1,30 @@ +/// +import { EventEmitter } from 'events'; +import * as fsScandir from '@nodelib/fs.scandir'; +import type Settings from '../settings'; +import type { Entry, Errno } from '../types'; +import Reader from './reader'; +declare type EntryEventCallback = (entry: Entry) => void; +declare type ErrorEventCallback = (error: Errno) => void; +declare type EndEventCallback = () => void; +export default class AsyncReader extends Reader { + protected readonly _settings: Settings; + protected readonly _scandir: typeof fsScandir.scandir; + protected readonly _emitter: EventEmitter; + private readonly _queue; + private _isFatalError; + private _isDestroyed; + constructor(_root: string, _settings: Settings); + read(): EventEmitter; + get isDestroyed(): boolean; + destroy(): void; + onEntry(callback: EntryEventCallback): void; + onError(callback: ErrorEventCallback): void; + onEnd(callback: EndEventCallback): void; + private _pushToQueue; + private _worker; + private _handleError; + private _handleEntry; + private _emitEntry; +} +export {}; diff --git a/node_modules/@nodelib/fs.walk/out/readers/async.js b/node_modules/@nodelib/fs.walk/out/readers/async.js new file mode 100644 index 0000000000000000000000000000000000000000..ebe8dd5735858b58c0d6a38cdb925c85c7c03651 --- /dev/null +++ b/node_modules/@nodelib/fs.walk/out/readers/async.js @@ -0,0 +1,97 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const events_1 = require("events"); +const fsScandir = require("@nodelib/fs.scandir"); +const fastq = require("fastq"); +const common = require("./common"); +const reader_1 = require("./reader"); +class AsyncReader extends reader_1.default { + constructor(_root, _settings) { + super(_root, _settings); + this._settings = _settings; + this._scandir = fsScandir.scandir; + this._emitter = new events_1.EventEmitter(); + this._queue = fastq(this._worker.bind(this), this._settings.concurrency); + this._isFatalError = false; + this._isDestroyed = false; + this._queue.drain = () => { + if (!this._isFatalError) { + this._emitter.emit('end'); + } + }; + } + read() { + this._isFatalError = false; + this._isDestroyed = false; + setImmediate(() => { + this._pushToQueue(this._root, this._settings.basePath); + }); + return this._emitter; + } + get isDestroyed() { + return this._isDestroyed; + } + destroy() { + if (this._isDestroyed) { + throw new Error('The reader is already destroyed'); + } + this._isDestroyed = true; + this._queue.killAndDrain(); + } + onEntry(callback) { + this._emitter.on('entry', callback); + } + onError(callback) { + this._emitter.once('error', callback); + } + onEnd(callback) { + this._emitter.once('end', callback); + } + _pushToQueue(directory, base) { + const queueItem = { directory, base }; + this._queue.push(queueItem, (error) => { + if (error !== null) { + this._handleError(error); + } + }); + } + _worker(item, done) { + this._scandir(item.directory, this._settings.fsScandirSettings, (error, entries) => { + if (error !== null) { + done(error, undefined); + return; + } + for (const entry of entries) { + this._handleEntry(entry, item.base); + } + done(null, undefined); + }); + } + _handleError(error) { + if (this._isDestroyed || !common.isFatalError(this._settings, error)) { + return; + } + this._isFatalError = true; + this._isDestroyed = true; + this._emitter.emit('error', error); + } + _handleEntry(entry, base) { + if (this._isDestroyed || this._isFatalError) { + return; + } + const fullpath = entry.path; + if (base !== undefined) { + entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator); + } + if (common.isAppliedFilter(this._settings.entryFilter, entry)) { + this._emitEntry(entry); + } + if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) { + this._pushToQueue(fullpath, base === undefined ? undefined : entry.path); + } + } + _emitEntry(entry) { + this._emitter.emit('entry', entry); + } +} +exports.default = AsyncReader; diff --git a/node_modules/@nodelib/fs.walk/out/readers/common.d.ts b/node_modules/@nodelib/fs.walk/out/readers/common.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5985f97c402e5a92edf987d791821650c9b66f3b --- /dev/null +++ b/node_modules/@nodelib/fs.walk/out/readers/common.d.ts @@ -0,0 +1,7 @@ +import type { FilterFunction } from '../settings'; +import type Settings from '../settings'; +import type { Errno } from '../types'; +export declare function isFatalError(settings: Settings, error: Errno): boolean; +export declare function isAppliedFilter(filter: FilterFunction | null, value: T): boolean; +export declare function replacePathSegmentSeparator(filepath: string, separator: string): string; +export declare function joinPathSegments(a: string, b: string, separator: string): string; diff --git a/node_modules/@nodelib/fs.walk/out/readers/common.js b/node_modules/@nodelib/fs.walk/out/readers/common.js new file mode 100644 index 0000000000000000000000000000000000000000..a93572f48a79ecd394339f6b27768a3b49332912 --- /dev/null +++ b/node_modules/@nodelib/fs.walk/out/readers/common.js @@ -0,0 +1,31 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.joinPathSegments = exports.replacePathSegmentSeparator = exports.isAppliedFilter = exports.isFatalError = void 0; +function isFatalError(settings, error) { + if (settings.errorFilter === null) { + return true; + } + return !settings.errorFilter(error); +} +exports.isFatalError = isFatalError; +function isAppliedFilter(filter, value) { + return filter === null || filter(value); +} +exports.isAppliedFilter = isAppliedFilter; +function replacePathSegmentSeparator(filepath, separator) { + return filepath.split(/[/\\]/).join(separator); +} +exports.replacePathSegmentSeparator = replacePathSegmentSeparator; +function joinPathSegments(a, b, separator) { + if (a === '') { + return b; + } + /** + * The correct handling of cases when the first segment is a root (`/`, `C:/`) or UNC path (`//?/C:/`). + */ + if (a.endsWith(separator)) { + return a + b; + } + return a + separator + b; +} +exports.joinPathSegments = joinPathSegments; diff --git a/node_modules/@nodelib/fs.walk/out/readers/reader.d.ts b/node_modules/@nodelib/fs.walk/out/readers/reader.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e1f383b25192216249d67456b437f7ea0ae5db24 --- /dev/null +++ b/node_modules/@nodelib/fs.walk/out/readers/reader.d.ts @@ -0,0 +1,6 @@ +import type Settings from '../settings'; +export default class Reader { + protected readonly _root: string; + protected readonly _settings: Settings; + constructor(_root: string, _settings: Settings); +} diff --git a/node_modules/@nodelib/fs.walk/out/readers/reader.js b/node_modules/@nodelib/fs.walk/out/readers/reader.js new file mode 100644 index 0000000000000000000000000000000000000000..782f07cbfab62ff2469f26b2fc98050a38b21f27 --- /dev/null +++ b/node_modules/@nodelib/fs.walk/out/readers/reader.js @@ -0,0 +1,11 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const common = require("./common"); +class Reader { + constructor(_root, _settings) { + this._root = _root; + this._settings = _settings; + this._root = common.replacePathSegmentSeparator(_root, _settings.pathSegmentSeparator); + } +} +exports.default = Reader; diff --git a/node_modules/@nodelib/fs.walk/out/readers/sync.d.ts b/node_modules/@nodelib/fs.walk/out/readers/sync.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..af410335363f14e3d0bdd44054917e08c6ba57ad --- /dev/null +++ b/node_modules/@nodelib/fs.walk/out/readers/sync.d.ts @@ -0,0 +1,15 @@ +import * as fsScandir from '@nodelib/fs.scandir'; +import type { Entry } from '../types'; +import Reader from './reader'; +export default class SyncReader extends Reader { + protected readonly _scandir: typeof fsScandir.scandirSync; + private readonly _storage; + private readonly _queue; + read(): Entry[]; + private _pushToQueue; + private _handleQueue; + private _handleDirectory; + private _handleError; + private _handleEntry; + private _pushToStorage; +} diff --git a/node_modules/@nodelib/fs.walk/out/readers/sync.js b/node_modules/@nodelib/fs.walk/out/readers/sync.js new file mode 100644 index 0000000000000000000000000000000000000000..9a8d5a6f1e18e826bc8930d03b5ef9e05b8738b3 --- /dev/null +++ b/node_modules/@nodelib/fs.walk/out/readers/sync.js @@ -0,0 +1,59 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const fsScandir = require("@nodelib/fs.scandir"); +const common = require("./common"); +const reader_1 = require("./reader"); +class SyncReader extends reader_1.default { + constructor() { + super(...arguments); + this._scandir = fsScandir.scandirSync; + this._storage = []; + this._queue = new Set(); + } + read() { + this._pushToQueue(this._root, this._settings.basePath); + this._handleQueue(); + return this._storage; + } + _pushToQueue(directory, base) { + this._queue.add({ directory, base }); + } + _handleQueue() { + for (const item of this._queue.values()) { + this._handleDirectory(item.directory, item.base); + } + } + _handleDirectory(directory, base) { + try { + const entries = this._scandir(directory, this._settings.fsScandirSettings); + for (const entry of entries) { + this._handleEntry(entry, base); + } + } + catch (error) { + this._handleError(error); + } + } + _handleError(error) { + if (!common.isFatalError(this._settings, error)) { + return; + } + throw error; + } + _handleEntry(entry, base) { + const fullpath = entry.path; + if (base !== undefined) { + entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator); + } + if (common.isAppliedFilter(this._settings.entryFilter, entry)) { + this._pushToStorage(entry); + } + if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) { + this._pushToQueue(fullpath, base === undefined ? undefined : entry.path); + } + } + _pushToStorage(entry) { + this._storage.push(entry); + } +} +exports.default = SyncReader; diff --git a/node_modules/@nodelib/fs.walk/out/settings.d.ts b/node_modules/@nodelib/fs.walk/out/settings.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d1c4b45f6b52bd167482312568a4ba7f4b9bba74 --- /dev/null +++ b/node_modules/@nodelib/fs.walk/out/settings.d.ts @@ -0,0 +1,30 @@ +import * as fsScandir from '@nodelib/fs.scandir'; +import type { Entry, Errno } from './types'; +export declare type FilterFunction = (value: T) => boolean; +export declare type DeepFilterFunction = FilterFunction; +export declare type EntryFilterFunction = FilterFunction; +export declare type ErrorFilterFunction = FilterFunction; +export interface Options { + basePath?: string; + concurrency?: number; + deepFilter?: DeepFilterFunction; + entryFilter?: EntryFilterFunction; + errorFilter?: ErrorFilterFunction; + followSymbolicLinks?: boolean; + fs?: Partial; + pathSegmentSeparator?: string; + stats?: boolean; + throwErrorOnBrokenSymbolicLink?: boolean; +} +export default class Settings { + private readonly _options; + readonly basePath?: string; + readonly concurrency: number; + readonly deepFilter: DeepFilterFunction | null; + readonly entryFilter: EntryFilterFunction | null; + readonly errorFilter: ErrorFilterFunction | null; + readonly pathSegmentSeparator: string; + readonly fsScandirSettings: fsScandir.Settings; + constructor(_options?: Options); + private _getValue; +} diff --git a/node_modules/@nodelib/fs.walk/out/settings.js b/node_modules/@nodelib/fs.walk/out/settings.js new file mode 100644 index 0000000000000000000000000000000000000000..d7a85c81eeecf8fd230e6fecedc9550bddb2ff93 --- /dev/null +++ b/node_modules/@nodelib/fs.walk/out/settings.js @@ -0,0 +1,26 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const path = require("path"); +const fsScandir = require("@nodelib/fs.scandir"); +class Settings { + constructor(_options = {}) { + this._options = _options; + this.basePath = this._getValue(this._options.basePath, undefined); + this.concurrency = this._getValue(this._options.concurrency, Number.POSITIVE_INFINITY); + this.deepFilter = this._getValue(this._options.deepFilter, null); + this.entryFilter = this._getValue(this._options.entryFilter, null); + this.errorFilter = this._getValue(this._options.errorFilter, null); + this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path.sep); + this.fsScandirSettings = new fsScandir.Settings({ + followSymbolicLinks: this._options.followSymbolicLinks, + fs: this._options.fs, + pathSegmentSeparator: this._options.pathSegmentSeparator, + stats: this._options.stats, + throwErrorOnBrokenSymbolicLink: this._options.throwErrorOnBrokenSymbolicLink + }); + } + _getValue(option, value) { + return option !== null && option !== void 0 ? option : value; + } +} +exports.default = Settings; diff --git a/node_modules/@nodelib/fs.walk/out/types/index.d.ts b/node_modules/@nodelib/fs.walk/out/types/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6ee9bd3f9bf81ccaf9abde0f329e38b075344056 --- /dev/null +++ b/node_modules/@nodelib/fs.walk/out/types/index.d.ts @@ -0,0 +1,8 @@ +/// +import type * as scandir from '@nodelib/fs.scandir'; +export declare type Entry = scandir.Entry; +export declare type Errno = NodeJS.ErrnoException; +export interface QueueItem { + directory: string; + base?: string; +} diff --git a/node_modules/@nodelib/fs.walk/out/types/index.js b/node_modules/@nodelib/fs.walk/out/types/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c8ad2e549bdc6801e0d1c80b0308d4b9bd4985ce --- /dev/null +++ b/node_modules/@nodelib/fs.walk/out/types/index.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/node_modules/@nodelib/fs.walk/package.json b/node_modules/@nodelib/fs.walk/package.json new file mode 100644 index 0000000000000000000000000000000000000000..86bfce48b59e41fa4985ac837c5ba8a9dacabe37 --- /dev/null +++ b/node_modules/@nodelib/fs.walk/package.json @@ -0,0 +1,44 @@ +{ + "name": "@nodelib/fs.walk", + "version": "1.2.8", + "description": "A library for efficiently walking a directory recursively", + "license": "MIT", + "repository": "https://github.com/nodelib/nodelib/tree/master/packages/fs/fs.walk", + "keywords": [ + "NodeLib", + "fs", + "FileSystem", + "file system", + "walk", + "scanner", + "crawler" + ], + "engines": { + "node": ">= 8" + }, + "files": [ + "out/**", + "!out/**/*.map", + "!out/**/*.spec.*", + "!out/**/tests/**" + ], + "main": "out/index.js", + "typings": "out/index.d.ts", + "scripts": { + "clean": "rimraf {tsconfig.tsbuildinfo,out}", + "lint": "eslint \"src/**/*.ts\" --cache", + "compile": "tsc -b .", + "compile:watch": "tsc -p . --watch --sourceMap", + "test": "mocha \"out/**/*.spec.js\" -s 0", + "build": "npm run clean && npm run compile && npm run lint && npm test", + "watch": "npm run clean && npm run compile:watch" + }, + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "devDependencies": { + "@nodelib/fs.macchiato": "1.0.4" + }, + "gitHead": "1e5bad48565da2b06b8600e744324ea240bf49d8" +} diff --git a/node_modules/@open-draft/deferred-promise/LICENSE.md b/node_modules/@open-draft/deferred-promise/LICENSE.md new file mode 100644 index 0000000000000000000000000000000000000000..824de2b52fc95955b35a7bdbe41242f18c739c9e --- /dev/null +++ b/node_modules/@open-draft/deferred-promise/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022–present Artem Zakharchenko + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@open-draft/deferred-promise/README.md b/node_modules/@open-draft/deferred-promise/README.md new file mode 100644 index 0000000000000000000000000000000000000000..15c9c62922592361f786f9ff776bb98a9e3bbc86 --- /dev/null +++ b/node_modules/@open-draft/deferred-promise/README.md @@ -0,0 +1,191 @@ +# Deferred Promise + +The `DeferredPromise` class is a Promise-compatible abstraction that defers resolving/rejecting promises to another closure. This class is primarily useful when one part of your system establishes as promise but another part of your system fulfills it. + +> This class is conceptually inspired by the [`createDeferredPromise()`](https://github.com/nodejs/node/blob/696fd4b14fc34cc2d01497a3abd9bb441b89be50/lib/internal/util.js#L468-L477) internal utility in Node.js. Unlike the Node.js implementation, however, `DeferredProimse` _extends_ a native `Promise`, allowing the consumer to handle deferred promises like regular promises (no `.promise` instance nesting). + +## Getting started + +```sh +npm install @open-draft/deferred-promise +``` + +## Documentation + +- [**`createDeferredExecutor()`**](#createdeferredexecutor) + - [`DeferredExecutor.state`](#deferredexecutorstate) + - [`DeferredExecutor.resolve()`](#deferredexecutorresolve) + - [`DeferredExecutor.reject()`](#deferredexecutorreject) + - [`DeferredExecutor.rejectionReason`](#deferredexecutorrejectionreason) +- [**Class: `DeferredPromise`**](#class-deferredpromise) + - [`new DeferredPromise()`](#new-deferredpromise) + - [`deferredPromise.state`](#deferredpromisestate) + - [`deferredPromise.resolve()`](#deferredpromiseresolve) + - [`deferredPromise.reject()`](#deferredpromisereject) + - [`deferredPromise.rejectionReason`](#deferredpromiserejectionreason) + +--- + +## `createDeferredExecutor()` + +Creates a Promise executor function that delegates its resolution to the current scope. + +```js +import { createDeferredExecutor } from '@open-draft/deferred-promise' + +const executor = createDeferredExecutor() +const promise = new Promise(executor) + +executor.resolve('hello') +// executor.reject(new Error('Reason')) +``` + +Deferred executor allows you to control any promise remotely and doesn't affect the Promise instance in any way. Similar to the [`DeferredPromise`](#class-deferredpromise) instance, the deferred executor exposes additional promise properties like `state`, `rejectionReason`, `resolve`, and `reject`. In fact, the `DeferredPromise` class is implemented on top of the deferred executor. + +```js +const executor = createDeferredExecutor() +const promise = new Promise(executor) + +executor.reject('reason') + +nextTick(() => { + console.log(executor.rejectionReason) // "reason" +}) +``` + +### `DeferredExecutor.state` + +- `<"pending" | "fulfilled" | "rejected">` **Default:** `"pending"` + +```js +const executor = createDeferredExecutor() +const promise = new Promise(executor) + +console.log(executor.state) // "pending" +``` + +Calling [`resolve()`](#deferredexecutorresolve) and [`reject()`](#deferredexecutorreject) methods of the executor transitions the state to "fulfilled" and "rejected" respectively. + +### `DeferredExecutor.resolve()` + +Resolves the promise with a given value. + +```js +const executor = createDeferredExecutor() +const promise = new Promise(executor) + +console.log(executor.state) // "pending" + +executor.resolve() + +// The promise state is still "pending" +// because promises are settled in the next microtask. +console.log(executor.state) // "pending" + +nextTick(() => { + // In the next microtask, the promise's state is resolved. + console.log(executor.state) // "fulfilled" +}) +``` + +### `DeferredExecutor.reject()` + +Rejects the promise with a given reason. + +```js +const executor = createDeferredExecutor() +const promise = new Promise(executor) + +executor.reject(new Error('Failed to fetch')) + +nextTick(() => { + console.log(executor.state) // "rejected" + console.log(executor.rejectionReason) // Error("Failed to fetch") +}) +``` + +You can access the rejection reason of the promise at any time by the [`rejectionReason`](#deferredexecutorrejectionreason) property of the deferred executor. + +### `DeferredExecutor.rejectionReason` + +Returns the reason of the promise rejection. If no reason has been provided to the `reject()` call, `undefined` is returned instead. + +```js +const executor = createDeferredExecutor() +const promise = new Promise(executor) + +executor.reject(new Error('Internal Server Error')) + +nextTick(() => { + console.log(executor.rejectionReason) // Error("Internal Server Error") +}) +``` + +--- + +## Class: `DeferredPromise` + +### `new DeferredPromise()` + +Creates a new instance of a deferred promise. + +```js +import { DeferredPromise } from '@open-draft/deferred-promise' + +const promise = new DeferredPromise() +``` + +A deferred promise is a Promise-compatible class that constructs a regular Promise instance under the hood, controlling it via the [deferred executor](#createdeferredexecutor). + +A deferred promise is fully compatible with the regular Promise, both type- and runtime-wise, e.g. a deferred promise can be chained and awaited normally. + +```js +const promise = new DeferredPromise() + .then((value) => value.toUpperCase()) + .then((value) => value.substring(0, 2)) + .catch((error) => console.error(error)) + +await promise +``` + +Unlike the regular Promise, however, a deferred promise doesn't accept the `executor` function as the constructor argument. Instead, the resolution of the deferred promise is deferred to the current scope (thus the name). + +```js +function getPort() { + // Notice that you don't provide any executor function + // when constructing a deferred promise. + const portPromise = new DeferredPromise() + + port.on('open', (port) => { + // Resolve the deferred promise whenever necessary. + portPromise.resolve(port) + }) + + // Return the deferred promise immediately. + return portPromise +} +``` + +Use the [`resolve()`](#deferredpromiseresolve) and [`reject()`](#deferredpromisereject) methods of the deferred promise instance to resolve and reject that promise respectively. + +### `deferredPromise.state` + +See [`DeferredExecutor.state`](#deferredexecutorstate) + +### `deferredPromise.resolve()` + +See [`DeferredExecutor.resolve()`](#deferredexecutorresolve) + +### `deferredPromise.reject()` + +See [`DeferredExecutor.reject()`](#deferredexecutorreject) + +### `deferredPromise.rejectionReason` + +See [`DeferredExecutor.rejectionReason`](#deferredexecutorrejectionreason) + +--- + +## Mentions + +- [Jonas Kuske](https://github.com/jonaskuske) for the phenomenal work around improving Promise-compliance. diff --git a/node_modules/@open-draft/deferred-promise/build/index.d.mts b/node_modules/@open-draft/deferred-promise/build/index.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..6896a61e6513139ce00e7aed6b19c656f421445c --- /dev/null +++ b/node_modules/@open-draft/deferred-promise/build/index.d.mts @@ -0,0 +1,30 @@ +//#region src/create-deferred-executor.d.ts +type PromiseState = 'pending' | 'fulfilled' | 'rejected'; +type Executor = ConstructorParameters>[0]; +type ResolveFunction = Parameters>[0]; +type RejectFunction = Parameters>[1]; +type DeferredPromiseExecutor = { + (resolve?: ResolveFunction, reject?: RejectFunction): void; + resolve: ResolveFunction; + reject: RejectFunction; + result?: Output; + state: PromiseState; + rejectionReason?: unknown; +}; +declare function createDeferredExecutor(): DeferredPromiseExecutor; +//#endregion +//#region src/deferred-promise.d.ts +declare class DeferredPromise extends Promise { + #private; + resolve: ResolveFunction; + reject: RejectFunction; + constructor(executor?: Executor | null); + get state(): PromiseState; + get rejectionReason(): unknown; + then(onFulfilled?: (value: Input) => ThenResult | PromiseLike, onRejected?: (reason: any) => CatchResult | PromiseLike): DeferredPromise; + catch(onRejected?: (reason: any) => CatchResult | PromiseLike): DeferredPromise; + finally(onfinally?: () => void | Promise): DeferredPromise; +} +//#endregion +export { DeferredPromise, type DeferredPromiseExecutor, type Executor, type PromiseState, type RejectFunction, type ResolveFunction, createDeferredExecutor }; +//# sourceMappingURL=index.d.mts.map \ No newline at end of file diff --git a/node_modules/@open-draft/deferred-promise/build/index.mjs b/node_modules/@open-draft/deferred-promise/build/index.mjs new file mode 100644 index 0000000000000000000000000000000000000000..a5fd70ca61a7fa61fa00585c2f4a816010ce65a0 --- /dev/null +++ b/node_modules/@open-draft/deferred-promise/build/index.mjs @@ -0,0 +1,71 @@ +//#region src/create-deferred-executor.ts +function createDeferredExecutor() { + const executor = ((resolve, reject) => { + executor.state = "pending"; + executor.resolve = (data) => { + if (executor.state !== "pending") return; + executor.result = data; + const onFulfilled = (value) => { + executor.state = "fulfilled"; + return value; + }; + return resolve(data instanceof Promise ? data : Promise.resolve(data).then(onFulfilled)); + }; + executor.reject = (reason) => { + if (executor.state !== "pending") return; + queueMicrotask(() => { + executor.state = "rejected"; + }); + return reject(executor.rejectionReason = reason); + }; + }); + return executor; +} +//#endregion +//#region src/deferred-promise.ts +var DeferredPromise = class extends Promise { + #executor; + resolve; + reject; + constructor(executor = null) { + const deferredExecutor = createDeferredExecutor(); + super((originalResolve, originalReject) => { + deferredExecutor(originalResolve, originalReject); + executor?.(deferredExecutor.resolve, deferredExecutor.reject); + }); + this.#executor = deferredExecutor; + this.resolve = this.#executor.resolve; + this.reject = this.#executor.reject; + } + get state() { + return this.#executor.state; + } + get rejectionReason() { + return this.#executor.rejectionReason; + } + then(onFulfilled, onRejected) { + return this.#decorate(super.then(onFulfilled, onRejected)); + } + catch(onRejected) { + return this.#decorate(super.catch(onRejected)); + } + finally(onfinally) { + return this.#decorate(super.finally(onfinally)); + } + #decorate(promise) { + return Object.defineProperties(promise, { + resolve: { + configurable: true, + value: this.resolve + }, + reject: { + configurable: true, + value: this.reject + } + }); + } +}; +//#endregion +export { DeferredPromise, createDeferredExecutor }; + +//# sourceMappingURL=index.mjs.map \ No newline at end of file diff --git a/node_modules/@open-draft/deferred-promise/build/index.mjs.map b/node_modules/@open-draft/deferred-promise/build/index.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..7176eb468fd3cac47e9ff9e126dd6084dc7f981f --- /dev/null +++ b/node_modules/@open-draft/deferred-promise/build/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","names":["#executor","#decorate"],"sources":["../src/create-deferred-executor.ts","../src/deferred-promise.ts"],"sourcesContent":["export type PromiseState = 'pending' | 'fulfilled' | 'rejected'\n\nexport type Executor = ConstructorParameters>[0]\nexport type ResolveFunction = Parameters>[0]\nexport type RejectFunction = Parameters>[1]\n\nexport type DeferredPromiseExecutor = {\n (resolve?: ResolveFunction, reject?: RejectFunction): void\n\n resolve: ResolveFunction\n reject: RejectFunction\n result?: Output\n state: PromiseState\n rejectionReason?: unknown\n}\nexport function createDeferredExecutor<\n Input = never,\n Output = Input\n>(): DeferredPromiseExecutor {\n const executor = >((\n resolve,\n reject\n ) => {\n executor.state = 'pending'\n\n executor.resolve = (data) => {\n if (executor.state !== 'pending') {\n return\n }\n\n executor.result = data as Output\n\n const onFulfilled = (value: Value) => {\n executor.state = 'fulfilled'\n return value\n }\n\n return resolve(\n data instanceof Promise ? data : Promise.resolve(data).then(onFulfilled)\n )\n }\n\n executor.reject = (reason) => {\n if (executor.state !== 'pending') {\n return\n }\n\n queueMicrotask(() => {\n executor.state = 'rejected'\n })\n\n return reject((executor.rejectionReason = reason))\n }\n })\n\n return executor\n}\n","import {\n type Executor,\n type RejectFunction,\n type ResolveFunction,\n type DeferredPromiseExecutor,\n createDeferredExecutor,\n} from './create-deferred-executor'\n\nexport class DeferredPromise extends Promise {\n #executor: DeferredPromiseExecutor\n\n public resolve: ResolveFunction\n public reject: RejectFunction\n\n constructor(executor: Executor | null = null) {\n const deferredExecutor = createDeferredExecutor()\n super((originalResolve, originalReject) => {\n deferredExecutor(originalResolve, originalReject)\n executor?.(deferredExecutor.resolve, deferredExecutor.reject)\n })\n\n this.#executor = deferredExecutor\n this.resolve = this.#executor.resolve\n this.reject = this.#executor.reject\n }\n\n public get state() {\n return this.#executor.state\n }\n\n public get rejectionReason() {\n return this.#executor.rejectionReason\n }\n\n public then(\n onFulfilled?: (value: Input) => ThenResult | PromiseLike,\n onRejected?: (reason: any) => CatchResult | PromiseLike,\n ) {\n return this.#decorate(super.then(onFulfilled, onRejected))\n }\n\n public catch(\n onRejected?: (reason: any) => CatchResult | PromiseLike,\n ) {\n return this.#decorate(super.catch(onRejected))\n }\n\n public finally(onfinally?: () => void | Promise) {\n return this.#decorate(super.finally(onfinally))\n }\n\n #decorate(\n promise: Promise,\n ): DeferredPromise {\n return Object.defineProperties(promise, {\n resolve: { configurable: true, value: this.resolve },\n reject: { configurable: true, value: this.reject },\n }) as DeferredPromise\n }\n}\n"],"mappings":";AAeA,SAAgB,yBAG4B;CAC1C,MAAM,aACJ,SACA,WACG;AACH,WAAS,QAAQ;AAEjB,WAAS,WAAW,SAAS;AAC3B,OAAI,SAAS,UAAU,UACrB;AAGF,YAAS,SAAS;GAElB,MAAM,eAAsB,UAAiB;AAC3C,aAAS,QAAQ;AACjB,WAAO;;AAGT,UAAO,QACL,gBAAgB,UAAU,OAAO,QAAQ,QAAQ,KAAK,CAAC,KAAK,YAAY,CACzE;;AAGH,WAAS,UAAU,WAAW;AAC5B,OAAI,SAAS,UAAU,UACrB;AAGF,wBAAqB;AACnB,aAAS,QAAQ;KACjB;AAEF,UAAO,OAAQ,SAAS,kBAAkB,OAAQ;;;AAItD,QAAO;;;;AC/CT,IAAa,kBAAb,cAA4D,QAAe;CACzE;CAEA;CACA;CAEA,YAAY,WAAmC,MAAM;EACnD,MAAM,mBAAmB,wBAAwB;AACjD,SAAO,iBAAiB,mBAAmB;AACzC,oBAAiB,iBAAiB,eAAe;AACjD,cAAW,iBAAiB,SAAS,iBAAiB,OAAO;IAC7D;AAEF,QAAA,WAAiB;AACjB,OAAK,UAAU,MAAA,SAAe;AAC9B,OAAK,SAAS,MAAA,SAAe;;CAG/B,IAAW,QAAQ;AACjB,SAAO,MAAA,SAAe;;CAGxB,IAAW,kBAAkB;AAC3B,SAAO,MAAA,SAAe;;CAGxB,KACE,aACA,YACA;AACA,SAAO,MAAA,SAAe,MAAM,KAAK,aAAa,WAAW,CAAC;;CAG5D,MACE,YACA;AACA,SAAO,MAAA,SAAe,MAAM,MAAM,WAAW,CAAC;;CAGhD,QAAe,WAAuC;AACpD,SAAO,MAAA,SAAe,MAAM,QAAQ,UAAU,CAAC;;CAGjD,UACE,SACqC;AACrC,SAAO,OAAO,iBAAiB,SAAS;GACtC,SAAS;IAAE,cAAc;IAAM,OAAO,KAAK;IAAS;GACpD,QAAQ;IAAE,cAAc;IAAM,OAAO,KAAK;IAAQ;GACnD,CAAC"} \ No newline at end of file diff --git a/node_modules/@open-draft/deferred-promise/package.json b/node_modules/@open-draft/deferred-promise/package.json new file mode 100644 index 0000000000000000000000000000000000000000..4363f58ea1401356577e03b6a95f15b1fd97db87 --- /dev/null +++ b/node_modules/@open-draft/deferred-promise/package.json @@ -0,0 +1,41 @@ +{ + "type": "module", + "name": "@open-draft/deferred-promise", + "version": "3.0.0", + "description": "A Promise-compatible abstraction that defers resolving/rejecting promises to another closure.", + "exports": { + ".": "./build/index.mjs" + }, + "scripts": { + "start": "tsdown -w", + "lint": "publint", + "test": "vitest", + "test:compliance": "export NODE_OPTIONS=--import=tsx || set NODE_OPTIONS=--import=tsx&& npx -y promises-aplus-tests ./test/aplus-tests-adapter.ts", + "build": "tsdown", + "release": "release publish" + }, + "files": [ + "./build" + ], + "keywords": [ + "promise", + "defer", + "deferred", + "resolve", + "reject", + "executor" + ], + "author": "Artem Zakharchenko", + "license": "MIT", + "repository": { + "url": "https://github.com/open-draft/deferred-promise" + }, + "devDependencies": { + "@ossjs/release": "^0.10.1", + "publint": "^0.3.18", + "tsdown": "^0.21.4", + "tsx": "^4.21.0", + "typescript": "^5.9.3", + "vitest": "^4.1.1" + } +} \ No newline at end of file diff --git a/node_modules/@open-draft/logger/LICENSE b/node_modules/@open-draft/logger/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..7868ade175ae9284aadfba31049213f58147960e --- /dev/null +++ b/node_modules/@open-draft/logger/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2023—present Artem Zakharchenko + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/@open-draft/logger/README.md b/node_modules/@open-draft/logger/README.md new file mode 100644 index 0000000000000000000000000000000000000000..2da7455957610e71785ad3d5885b512eeed52e8a --- /dev/null +++ b/node_modules/@open-draft/logger/README.md @@ -0,0 +1,225 @@ +# Logger + +Environment-agnostic, ESM-friendly logger for simple needs. + +## Why does this exist? + +I've been using `debug` for quite some time but wanted to migrate my projects to better ESM support. Alas, `debug` doesn't ship as ESM so I went and wrote this little logger just for my needs. You will likely see it printing useful data in Mock Service Worker and beyond. + +## Installation + +```sh +npm install @open-draft/logger +``` + +## Usage + +This package has the same API for both browser and Node.js and can run in those environments out of the box. + +```js +// app.js +import { Logger } from '@open-draft/logger' + +const logger = new Logger('parser') + +logger.info('starting parsing...') +logger.warning('found legacy document format') +logger.success('parsed 120 documents!') +``` + +Logging is disabled by default. To enable logging, provide the `DEBUG` environment variable: + +```sh +DEBUG=1 node ./app.js +``` + +> You can also use `true` instead of `1`. You can also use a specific logger's name to enable [logger filtering](#logger-filtering). + +## API + +- Class: `Logger` + - [`new Logger(name)`](#new-loggername) + - [`logger.debug(message, ...positionals)`](#loggerdebugmessage-positionals) + - [`logger.info(message, ...positionals)`](#loggerinfomessage-positionals) + - [`logger.success(message, ...positionals)`](#loggersuccessmessage-positionals) + - [`logger.warning(message, ...positionals)`](#loggerwarningmessage-positionals) + - [`logger.error(message, ...positionals)`](#loggererrormessage-positionals) + - [`logger.extend(name)`](#loggerextendprefix) + - [`logger.only(callback)`](#loggeronlycallback) + +### `new Logger(name)` + +- `name` `string` the name of the logger. + +Creates a new instance of the logger. Each message printed by the logger will be prefixed with the given `name`. You can have multiple loggers with different names for different areas of your system. + +```js +const logger = new Logger('parser') +``` + +> You can nest loggers via [`logger.extend()`](#loggerextendprefix). + +### `logger.debug(message, ...positionals)` + +- `message` `string` +- `positionals` `unknown[]` + +Prints a debug message. + +```js +logger.debug('no duplicates found, skipping...') +``` + +``` +12:34:56:789 [parser] no duplicates found, skipping... +``` + +### `logger.info(message, ...positionals)` + +- `message` `string` +- `positionals` `unknown[]` + +Prints an info message. + +```js +logger.info('new parse request') +``` + +``` +12:34:56:789 [parser] new parse request +``` + +### `logger.success(message, ...positionals)` + +- `message` `string` +- `positionals` `unknown[]` + +Prints a success message. + +```js +logger.success('prased 123 documents!') +``` + +``` +12:34:56:789 ✔ [parser] prased 123 documents! +``` + +### `logger.warning(message, ...positionals)` + +- `message` `string` +- `positionals` `unknown[]` + +Prints a warning. In Node.js, prints it to `process.stderr`. + +```js +logger.warning('found legacy document format') +``` + +``` +12:34:56:789 ⚠ [parser] found legacy document format +``` + +### `logger.error(message, ...positionals)` + +- `message` `string` +- `positionals` `unknown[]` + +Prints an error. In Node.js, prints it to `process.stderr`. + +```js +logger.error('failed to parse document') +``` + +``` +12:34:56:789 ✖ [parser] failed to parse document +``` + +### `logger.extend(prefix)` + +- `prefix` `string` Additional prefix to append to the logger's name. + +Creates a new logger out of the current one. + +```js +const logger = new Logger('parser') + +function parseRequest(request) { + const requestLogger = logger.extend(`${request.method} ${request.url}`) + requestLogger.info('start parsing...') +} +``` + +``` +12:34:56:789 [parser] [GET https://example.com] start parsing... +``` + +### `logger.only(callback)` + +Executes a given callback only when the logging is activated. Useful for computing additional information for logs. + +```js +logger.only(() => { + const documentSize = getSizeBytes(document) + logger.debug(`document size: ${documentSize}`) +}) +``` + +> You can nest `logger.*` methods in the callback to `logger.only()`. + +## Log levels + +You can specify the log levels to print using the `LOG_LEVEL` environment variable. + +There are the following log levels: + +- `debug` +- `info` +- `success` +- `warning` +- `error` + +> Providing no log level will print all the messages. + +Here's an example of how to print only warnings: + +```js +// app.js +import { Logger } from '@open-draft/logger' + +const logger = new Logger('parser') + +logger.info('some info') +logger.warning('some warning') +logger.error('some error') +``` + +```js +LOG_LEVEL=warning node ./app.js +``` + +``` +12:34:56:789 ⚠ [parser] some warning +``` + +## Logger filtering + +You can only print a specific logger by providing its name as the `DEBUG` environment variable. + +```js +// app.js +import { Logger } from '@open-draft/logger' + +const appLogger = new Logger('app') +const parserLogger = new Logger('parser') + +appLogger.info('starting app...') +parserLogger.info('creating a new parser...') +``` + +```sh +DEBUG=app node ./app.js +``` + +``` +12:34:56:789 [app] starting app... +``` diff --git a/node_modules/@open-draft/logger/lib/index.d.ts b/node_modules/@open-draft/logger/lib/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..547acfcd0c5271fd882e66c908996e5e6c71485c --- /dev/null +++ b/node_modules/@open-draft/logger/lib/index.d.ts @@ -0,0 +1,83 @@ +type ColorFunction = (text: string) => void; +declare function yellow(text: string): string; +declare function blue(text: string): string; +declare function gray(text: string): string; +declare function red(text: string): string; +declare function green(text: string): string; + +type colors_ColorFunction = ColorFunction; +declare const colors_blue: typeof blue; +declare const colors_gray: typeof gray; +declare const colors_green: typeof green; +declare const colors_red: typeof red; +declare const colors_yellow: typeof yellow; +declare namespace colors { + export { + colors_ColorFunction as ColorFunction, + colors_blue as blue, + colors_gray as gray, + colors_green as green, + colors_red as red, + colors_yellow as yellow, + }; +} + +type LogLevel = 'debug' | 'info' | 'success' | 'warning' | 'error'; +type LogColors = keyof typeof colors; +interface LogEntry { + timestamp: Date; + level: LogLevel; + message: any; +} +declare class Logger { + private readonly name; + private prefix; + constructor(name: string); + extend(domain: string): Logger; + /** + * Print a debug message. + * @example + * logger.debug('no duplicates found, creating a document...') + */ + debug(message: any, ...positionals: Array): void; + /** + * Print an info message. + * @example + * logger.info('start parsing...') + */ + info(message: any, ...positionals: Array): (message: any, ...positionals: Array) => void; + /** + * Print a success message. + * @example + * logger.success('successfully created document') + */ + success(message: any, ...positionals: Array): void; + /** + * Print a warning. + * @example + * logger.warning('found legacy document format') + */ + warning(message: any, ...positionals: Array): void; + /** + * Print an error message. + * @example + * logger.error('something went wrong') + */ + error(message: any, ...positionals: Array): void; + /** + * Execute the given callback only when the logging is enabled. + * This is skipped in its entirety and has no runtime cost otherwise. + * This executes regardless of the log level. + * @example + * logger.only(() => { + * logger.info('additional info') + * }) + */ + only(callback: () => void): void; + private createEntry; + private logEntry; + private formatTimestamp; + private getWriter; +} + +export { LogColors, LogEntry, LogLevel, Logger }; diff --git a/node_modules/@open-draft/logger/lib/index.js b/node_modules/@open-draft/logger/lib/index.js new file mode 100644 index 0000000000000000000000000000000000000000..ac101aec651bcc45a2cffffcb8e7242a649ce87b --- /dev/null +++ b/node_modules/@open-draft/logger/lib/index.js @@ -0,0 +1,295 @@ +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/index.ts +var src_exports = {}; +__export(src_exports, { + Logger: () => Logger +}); +module.exports = __toCommonJS(src_exports); +var import_is_node_process = require("is-node-process"); +var import_outvariant = require("outvariant"); + +// src/colors.ts +var colors_exports = {}; +__export(colors_exports, { + blue: () => blue, + gray: () => gray, + green: () => green, + red: () => red, + yellow: () => yellow +}); +function yellow(text) { + return `\x1B[33m${text}\x1B[0m`; +} +function blue(text) { + return `\x1B[34m${text}\x1B[0m`; +} +function gray(text) { + return `\x1B[90m${text}\x1B[0m`; +} +function red(text) { + return `\x1B[31m${text}\x1B[0m`; +} +function green(text) { + return `\x1B[32m${text}\x1B[0m`; +} + +// src/index.ts +var IS_NODE = (0, import_is_node_process.isNodeProcess)(); +var Logger = class { + constructor(name) { + this.name = name; + this.prefix = `[${this.name}]`; + const LOGGER_NAME = getVariable("DEBUG"); + const LOGGER_LEVEL = getVariable("LOG_LEVEL"); + const isLoggingEnabled = LOGGER_NAME === "1" || LOGGER_NAME === "true" || typeof LOGGER_NAME !== "undefined" && this.name.startsWith(LOGGER_NAME); + if (isLoggingEnabled) { + this.debug = isDefinedAndNotEquals(LOGGER_LEVEL, "debug") ? noop : this.debug; + this.info = isDefinedAndNotEquals(LOGGER_LEVEL, "info") ? noop : this.info; + this.success = isDefinedAndNotEquals(LOGGER_LEVEL, "success") ? noop : this.success; + this.warning = isDefinedAndNotEquals(LOGGER_LEVEL, "warning") ? noop : this.warning; + this.error = isDefinedAndNotEquals(LOGGER_LEVEL, "error") ? noop : this.error; + } else { + this.info = noop; + this.success = noop; + this.warning = noop; + this.error = noop; + this.only = noop; + } + } + prefix; + extend(domain) { + return new Logger(`${this.name}:${domain}`); + } + /** + * Print a debug message. + * @example + * logger.debug('no duplicates found, creating a document...') + */ + debug(message, ...positionals) { + this.logEntry({ + level: "debug", + message: gray(message), + positionals, + prefix: this.prefix, + colors: { + prefix: "gray" + } + }); + } + /** + * Print an info message. + * @example + * logger.info('start parsing...') + */ + info(message, ...positionals) { + this.logEntry({ + level: "info", + message, + positionals, + prefix: this.prefix, + colors: { + prefix: "blue" + } + }); + const performance2 = new PerformanceEntry(); + return (message2, ...positionals2) => { + performance2.measure(); + this.logEntry({ + level: "info", + message: `${message2} ${gray(`${performance2.deltaTime}ms`)}`, + positionals: positionals2, + prefix: this.prefix, + colors: { + prefix: "blue" + } + }); + }; + } + /** + * Print a success message. + * @example + * logger.success('successfully created document') + */ + success(message, ...positionals) { + this.logEntry({ + level: "info", + message, + positionals, + prefix: `\u2714 ${this.prefix}`, + colors: { + timestamp: "green", + prefix: "green" + } + }); + } + /** + * Print a warning. + * @example + * logger.warning('found legacy document format') + */ + warning(message, ...positionals) { + this.logEntry({ + level: "warning", + message, + positionals, + prefix: `\u26A0 ${this.prefix}`, + colors: { + timestamp: "yellow", + prefix: "yellow" + } + }); + } + /** + * Print an error message. + * @example + * logger.error('something went wrong') + */ + error(message, ...positionals) { + this.logEntry({ + level: "error", + message, + positionals, + prefix: `\u2716 ${this.prefix}`, + colors: { + timestamp: "red", + prefix: "red" + } + }); + } + /** + * Execute the given callback only when the logging is enabled. + * This is skipped in its entirety and has no runtime cost otherwise. + * This executes regardless of the log level. + * @example + * logger.only(() => { + * logger.info('additional info') + * }) + */ + only(callback) { + callback(); + } + createEntry(level, message) { + return { + timestamp: /* @__PURE__ */ new Date(), + level, + message + }; + } + logEntry(args) { + const { + level, + message, + prefix, + colors: customColors, + positionals = [] + } = args; + const entry = this.createEntry(level, message); + const timestampColor = customColors?.timestamp || "gray"; + const prefixColor = customColors?.prefix || "gray"; + const colorize = { + timestamp: colors_exports[timestampColor], + prefix: colors_exports[prefixColor] + }; + const write = this.getWriter(level); + write( + [colorize.timestamp(this.formatTimestamp(entry.timestamp))].concat(prefix != null ? colorize.prefix(prefix) : []).concat(serializeInput(message)).join(" "), + ...positionals.map(serializeInput) + ); + } + formatTimestamp(timestamp) { + return `${timestamp.toLocaleTimeString( + "en-GB" + )}:${timestamp.getMilliseconds()}`; + } + getWriter(level) { + switch (level) { + case "debug": + case "success": + case "info": { + return log; + } + case "warning": { + return warn; + } + case "error": { + return error; + } + } + } +}; +var PerformanceEntry = class { + startTime; + endTime; + deltaTime; + constructor() { + this.startTime = performance.now(); + } + measure() { + this.endTime = performance.now(); + const deltaTime = this.endTime - this.startTime; + this.deltaTime = deltaTime.toFixed(2); + } +}; +var noop = () => void 0; +function log(message, ...positionals) { + if (IS_NODE) { + process.stdout.write((0, import_outvariant.format)(message, ...positionals) + "\n"); + return; + } + console.log(message, ...positionals); +} +function warn(message, ...positionals) { + if (IS_NODE) { + process.stderr.write((0, import_outvariant.format)(message, ...positionals) + "\n"); + return; + } + console.warn(message, ...positionals); +} +function error(message, ...positionals) { + if (IS_NODE) { + process.stderr.write((0, import_outvariant.format)(message, ...positionals) + "\n"); + return; + } + console.error(message, ...positionals); +} +function getVariable(variableName) { + if (IS_NODE) { + return process.env[variableName]; + } + return globalThis[variableName]?.toString(); +} +function isDefinedAndNotEquals(value, expected) { + return value !== void 0 && value !== expected; +} +function serializeInput(message) { + if (typeof message === "undefined") { + return "undefined"; + } + if (message === null) { + return "null"; + } + if (typeof message === "string") { + return message; + } + if (typeof message === "object") { + return JSON.stringify(message); + } + return message.toString(); +} diff --git a/node_modules/@open-draft/logger/lib/index.mjs b/node_modules/@open-draft/logger/lib/index.mjs new file mode 100644 index 0000000000000000000000000000000000000000..ffb0b88b7a0ccc22ed7cb106b3b48a10b085df0e --- /dev/null +++ b/node_modules/@open-draft/logger/lib/index.mjs @@ -0,0 +1,281 @@ +var __defProp = Object.defineProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; + +// src/index.ts +import { isNodeProcess } from "is-node-process"; +import { format } from "outvariant"; + +// src/colors.ts +var colors_exports = {}; +__export(colors_exports, { + blue: () => blue, + gray: () => gray, + green: () => green, + red: () => red, + yellow: () => yellow +}); +function yellow(text) { + return `\x1B[33m${text}\x1B[0m`; +} +function blue(text) { + return `\x1B[34m${text}\x1B[0m`; +} +function gray(text) { + return `\x1B[90m${text}\x1B[0m`; +} +function red(text) { + return `\x1B[31m${text}\x1B[0m`; +} +function green(text) { + return `\x1B[32m${text}\x1B[0m`; +} + +// src/index.ts +var IS_NODE = isNodeProcess(); +var Logger = class { + constructor(name) { + this.name = name; + this.prefix = `[${this.name}]`; + const LOGGER_NAME = getVariable("DEBUG"); + const LOGGER_LEVEL = getVariable("LOG_LEVEL"); + const isLoggingEnabled = LOGGER_NAME === "1" || LOGGER_NAME === "true" || typeof LOGGER_NAME !== "undefined" && this.name.startsWith(LOGGER_NAME); + if (isLoggingEnabled) { + this.debug = isDefinedAndNotEquals(LOGGER_LEVEL, "debug") ? noop : this.debug; + this.info = isDefinedAndNotEquals(LOGGER_LEVEL, "info") ? noop : this.info; + this.success = isDefinedAndNotEquals(LOGGER_LEVEL, "success") ? noop : this.success; + this.warning = isDefinedAndNotEquals(LOGGER_LEVEL, "warning") ? noop : this.warning; + this.error = isDefinedAndNotEquals(LOGGER_LEVEL, "error") ? noop : this.error; + } else { + this.info = noop; + this.success = noop; + this.warning = noop; + this.error = noop; + this.only = noop; + } + } + prefix; + extend(domain) { + return new Logger(`${this.name}:${domain}`); + } + /** + * Print a debug message. + * @example + * logger.debug('no duplicates found, creating a document...') + */ + debug(message, ...positionals) { + this.logEntry({ + level: "debug", + message: gray(message), + positionals, + prefix: this.prefix, + colors: { + prefix: "gray" + } + }); + } + /** + * Print an info message. + * @example + * logger.info('start parsing...') + */ + info(message, ...positionals) { + this.logEntry({ + level: "info", + message, + positionals, + prefix: this.prefix, + colors: { + prefix: "blue" + } + }); + const performance2 = new PerformanceEntry(); + return (message2, ...positionals2) => { + performance2.measure(); + this.logEntry({ + level: "info", + message: `${message2} ${gray(`${performance2.deltaTime}ms`)}`, + positionals: positionals2, + prefix: this.prefix, + colors: { + prefix: "blue" + } + }); + }; + } + /** + * Print a success message. + * @example + * logger.success('successfully created document') + */ + success(message, ...positionals) { + this.logEntry({ + level: "info", + message, + positionals, + prefix: `\u2714 ${this.prefix}`, + colors: { + timestamp: "green", + prefix: "green" + } + }); + } + /** + * Print a warning. + * @example + * logger.warning('found legacy document format') + */ + warning(message, ...positionals) { + this.logEntry({ + level: "warning", + message, + positionals, + prefix: `\u26A0 ${this.prefix}`, + colors: { + timestamp: "yellow", + prefix: "yellow" + } + }); + } + /** + * Print an error message. + * @example + * logger.error('something went wrong') + */ + error(message, ...positionals) { + this.logEntry({ + level: "error", + message, + positionals, + prefix: `\u2716 ${this.prefix}`, + colors: { + timestamp: "red", + prefix: "red" + } + }); + } + /** + * Execute the given callback only when the logging is enabled. + * This is skipped in its entirety and has no runtime cost otherwise. + * This executes regardless of the log level. + * @example + * logger.only(() => { + * logger.info('additional info') + * }) + */ + only(callback) { + callback(); + } + createEntry(level, message) { + return { + timestamp: /* @__PURE__ */ new Date(), + level, + message + }; + } + logEntry(args) { + const { + level, + message, + prefix, + colors: customColors, + positionals = [] + } = args; + const entry = this.createEntry(level, message); + const timestampColor = customColors?.timestamp || "gray"; + const prefixColor = customColors?.prefix || "gray"; + const colorize = { + timestamp: colors_exports[timestampColor], + prefix: colors_exports[prefixColor] + }; + const write = this.getWriter(level); + write( + [colorize.timestamp(this.formatTimestamp(entry.timestamp))].concat(prefix != null ? colorize.prefix(prefix) : []).concat(serializeInput(message)).join(" "), + ...positionals.map(serializeInput) + ); + } + formatTimestamp(timestamp) { + return `${timestamp.toLocaleTimeString( + "en-GB" + )}:${timestamp.getMilliseconds()}`; + } + getWriter(level) { + switch (level) { + case "debug": + case "success": + case "info": { + return log; + } + case "warning": { + return warn; + } + case "error": { + return error; + } + } + } +}; +var PerformanceEntry = class { + startTime; + endTime; + deltaTime; + constructor() { + this.startTime = performance.now(); + } + measure() { + this.endTime = performance.now(); + const deltaTime = this.endTime - this.startTime; + this.deltaTime = deltaTime.toFixed(2); + } +}; +var noop = () => void 0; +function log(message, ...positionals) { + if (IS_NODE) { + process.stdout.write(format(message, ...positionals) + "\n"); + return; + } + console.log(message, ...positionals); +} +function warn(message, ...positionals) { + if (IS_NODE) { + process.stderr.write(format(message, ...positionals) + "\n"); + return; + } + console.warn(message, ...positionals); +} +function error(message, ...positionals) { + if (IS_NODE) { + process.stderr.write(format(message, ...positionals) + "\n"); + return; + } + console.error(message, ...positionals); +} +function getVariable(variableName) { + if (IS_NODE) { + return process.env[variableName]; + } + return globalThis[variableName]?.toString(); +} +function isDefinedAndNotEquals(value, expected) { + return value !== void 0 && value !== expected; +} +function serializeInput(message) { + if (typeof message === "undefined") { + return "undefined"; + } + if (message === null) { + return "null"; + } + if (typeof message === "string") { + return message; + } + if (typeof message === "object") { + return JSON.stringify(message); + } + return message.toString(); +} +export { + Logger +}; diff --git a/node_modules/@open-draft/logger/package.json b/node_modules/@open-draft/logger/package.json new file mode 100644 index 0000000000000000000000000000000000000000..796aafc8d7bb912f571bf41ce39fcd8656cb62c9 --- /dev/null +++ b/node_modules/@open-draft/logger/package.json @@ -0,0 +1,56 @@ +{ + "name": "@open-draft/logger", + "version": "0.3.0", + "description": "Environment-agnostic, ESM-friendly logger for simple needs.", + "main": "./lib/index.js", + "module": "./lib/index.mjs", + "types": "./lib/index.d.ts", + "exports": { + ".": { + "types": "./lib/index.d.ts", + "require": "./lib/index.js", + "import": "./lib/index.mjs", + "default": "./lib/index.js" + }, + "./package.json": "./package.json" + }, + "keywords": [ + "log", + "logger", + "logging", + "universal", + "tiny" + ], + "files": [ + "lib", + "LICENSE", + "README.md" + ], + "author": "Artem Zakharchenko", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/open-draft/logger" + }, + "devDependencies": { + "@ossjs/release": "^0.5.1", + "@playwright/test": "^1.32.3", + "@types/node": "^18.15.11", + "playwright": "^1.32.3", + "tsup": "^6.7.0", + "typescript": "^5.0.3", + "vitest": "^0.29.8", + "webpack-http-server": "^0.5.0" + }, + "dependencies": { + "is-node-process": "^1.2.0", + "outvariant": "^1.4.0" + }, + "scripts": { + "build": "tsup", + "test": "pnpm test:node && pnpm test:browser", + "test:node": "vitest run", + "test:browser": "playwright test", + "release": "release publish" + } +} \ No newline at end of file diff --git a/node_modules/@open-draft/until/LICENSE b/node_modules/@open-draft/until/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..8a1c628e5112fbb284d8e1cd9988c44d6599ddd5 --- /dev/null +++ b/node_modules/@open-draft/until/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Artem Zakharchenko + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@open-draft/until/README.md b/node_modules/@open-draft/until/README.md new file mode 100644 index 0000000000000000000000000000000000000000..be49a5049f72c28529ce0bb6c8d48080b067ca9a --- /dev/null +++ b/node_modules/@open-draft/until/README.md @@ -0,0 +1,150 @@ +[![Latest release](https://img.shields.io/npm/v/@open-draft/until.svg)](https://www.npmjs.com/package/@open-draft/until) + +# `until` + +Gracefully handle a Promise using `async`/`await`. + +## Why? + +With the addition of `async`/`await` keywords in ECMAScript 2017 the handling of Promises became much easier. However, one must keep in mind that the `await` keyword provides no standard error handling API. Consider this usage: + +```js +function getUser(id) { + const data = await fetchUser(id) + // Work with "data"... +} +``` + +In case `fetchUser()` throws an error, the entire `getUser()` function's scope will terminate. Because of this, it's recommended to implement error handling using `try`/`catch` block wrapping `await` expressions: + +```js +function getUser(id) + let data = null + + try { + data = await asyncAction() + } catch (error) { + console.error(error) + } + + // Work with "data"... +} +``` + +While this is a semantically valid approach, constructing `try`/`catch` around each awaited operation may be tedious and get overlooked at times. Such error handling also introduces separate closures for execution and error scenarios of an asynchronous operation. + +This library encapsulates the `try`/`catch` error handling in a utility function that does not create a separate closure and exposes a NodeJS-friendly API to work with errors and resolved data. + +## Getting started + +### Install + +```bash +npm install @open-draft/until +``` + +### Usage + +```js +import { until } from '@open-draft/until' + +async function(id) { + const { error, data } = await until(() => fetchUser(id)) + + if (error) { + return handleError(error) + } + + return data +} +``` + +### Usage with TypeScript + +```ts +import { until } from '@open-draft/until' + +interface User { + firstName: string + age: number +} + +interface UserFetchError { + type: 'FORBIDDEN' | 'NOT_FOUND' + message?: string +} + +async function(id: string) { + const { error, data } = await until(() => fetchUser(id)) + + if (error) { + handleError(error.type, error.message) + } + + return data.firstName +} +``` + +## Frequently asked questions + +### Why does `until` accept a function and not a `Promise` directly? + +This has been intentionally introduced to await a single logical unit as opposed to a single `Promise`. + +```js +// Notice how a single "until" invocation can handle +// a rather complex piece of logic. This way any rejections +// or exceptions happening within the given function +// can be handled via the same "error". +const { error, data } = until(async () => { + const user = await fetchUser() + const nextUser = normalizeUser(user) + const transaction = await saveModel('user', user) + + invariant(transaction.status === 'OK', 'Saving user failed') + + return transaction.result +}) + +if (error) { + // Handle any exceptions happened within the function. +} +``` + +### Why does `until` return an object and not an array? + +The `until` function used to return an array of shape `[error, data]` prior to `2.0.0`. That has been changed, however, to get proper type-safety using discriminated union type. + +Compare these two examples: + +```ts +const [error, data] = await until(() => action()) + +if (error) { + return null +} + +// Data still has ambiguous "DataType | null" type here +// even after you've checked and handled the "error" above. +console.log(data) +``` + +```ts +const result = await until(() => action()) + +// At this point, "data" is ambiguous "DataType | null" +// which is correct, as you haven't checked nor handled the "error". + +if (result.error) { + return null +} + +// Data is strict "DataType" since you've handled the "error" above. +console.log(result.data) +``` + +> It's crucial to keep the entire result of the `Promise` in a single variable and not destructure it. TypeScript will always keep the type of `error` and `data` as it was upon destructuring, ignoring any type guards you may perform later on. + +## Special thanks + +- [giuseppegurgone](https://twitter.com/giuseppegurgone) for the discussion about the original `until` API. diff --git a/node_modules/@open-draft/until/lib/index.d.ts b/node_modules/@open-draft/until/lib/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..19544f40af2d8200543b3de66a7440515b412fcf --- /dev/null +++ b/node_modules/@open-draft/until/lib/index.d.ts @@ -0,0 +1,15 @@ +type AsyncTuple = { + error: ErrorType; + data: null; +} | { + error: null; + data: DataType; +}; +/** + * Gracefully handles a given Promise factory. + * @example + * const { error, data } = await until(() => asyncAction()) + */ +declare const until: (promise: () => Promise) => Promise>; + +export { until }; diff --git a/node_modules/@open-draft/until/lib/index.js b/node_modules/@open-draft/until/lib/index.js new file mode 100644 index 0000000000000000000000000000000000000000..3944d95acf437053955fb9693ab1c5a1846e547f --- /dev/null +++ b/node_modules/@open-draft/until/lib/index.js @@ -0,0 +1,41 @@ +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/index.ts +var src_exports = {}; +__export(src_exports, { + until: () => until +}); +module.exports = __toCommonJS(src_exports); + +// src/until.ts +var until = async (promise) => { + try { + const data = await promise().catch((error) => { + throw error; + }); + return { error: null, data }; + } catch (error) { + return { error, data: null }; + } +}; +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + until +}); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/@open-draft/until/lib/index.js.map b/node_modules/@open-draft/until/lib/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..71429109f0c6a5f3b4d9ec7cc23e46daa40d58cc --- /dev/null +++ b/node_modules/@open-draft/until/lib/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/index.ts","../src/until.ts"],"sourcesContent":["export { until } from './until'","export type AsyncTuple<\n ErrorType extends any = Error,\n DataType extends any = unknown,\n> =\n | {\n error: ErrorType\n data: null\n }\n | { error: null; data: DataType }\n\n/**\n * Gracefully handles a given Promise factory.\n * @example\n * const { error, data } = await until(() => asyncAction())\n */\nexport const until = async <\n ErrorType extends any = Error,\n DataType extends any = unknown,\n>(\n promise: () => Promise,\n): Promise> => {\n try {\n const data = await promise().catch((error) => {\n throw error\n })\n return { error: null, data }\n } catch (error) {\n return { error, data: null }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACeO,IAAM,QAAQ,OAInB,YAC6C;AAC7C,MAAI;AACF,UAAM,OAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,UAAU;AAC5C,YAAM;AAAA,IACR,CAAC;AACD,WAAO,EAAE,OAAO,MAAM,KAAK;AAAA,EAC7B,SAAS,OAAP;AACA,WAAO,EAAE,OAAO,MAAM,KAAK;AAAA,EAC7B;AACF;","names":[]} \ No newline at end of file diff --git a/node_modules/@open-draft/until/lib/index.mjs b/node_modules/@open-draft/until/lib/index.mjs new file mode 100644 index 0000000000000000000000000000000000000000..12be84c8d15c8e5850d2b16a5f8cc26e69731a30 --- /dev/null +++ b/node_modules/@open-draft/until/lib/index.mjs @@ -0,0 +1,15 @@ +// src/until.ts +var until = async (promise) => { + try { + const data = await promise().catch((error) => { + throw error; + }); + return { error: null, data }; + } catch (error) { + return { error, data: null }; + } +}; +export { + until +}; +//# sourceMappingURL=index.mjs.map \ No newline at end of file diff --git a/node_modules/@open-draft/until/lib/index.mjs.map b/node_modules/@open-draft/until/lib/index.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..6c246974fcda2bf89d775d88ecc5ddbd27706f4d --- /dev/null +++ b/node_modules/@open-draft/until/lib/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/until.ts"],"sourcesContent":["export type AsyncTuple<\n ErrorType extends any = Error,\n DataType extends any = unknown,\n> =\n | {\n error: ErrorType\n data: null\n }\n | { error: null; data: DataType }\n\n/**\n * Gracefully handles a given Promise factory.\n * @example\n * const { error, data } = await until(() => asyncAction())\n */\nexport const until = async <\n ErrorType extends any = Error,\n DataType extends any = unknown,\n>(\n promise: () => Promise,\n): Promise> => {\n try {\n const data = await promise().catch((error) => {\n throw error\n })\n return { error: null, data }\n } catch (error) {\n return { error, data: null }\n }\n}\n"],"mappings":";AAeO,IAAM,QAAQ,OAInB,YAC6C;AAC7C,MAAI;AACF,UAAM,OAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,UAAU;AAC5C,YAAM;AAAA,IACR,CAAC;AACD,WAAO,EAAE,OAAO,MAAM,KAAK;AAAA,EAC7B,SAAS,OAAP;AACA,WAAO,EAAE,OAAO,MAAM,KAAK;AAAA,EAC7B;AACF;","names":[]} \ No newline at end of file diff --git a/node_modules/@open-draft/until/package.json b/node_modules/@open-draft/until/package.json new file mode 100644 index 0000000000000000000000000000000000000000..a640d6031c60ddbfedea90b5729d498fd37bb873 --- /dev/null +++ b/node_modules/@open-draft/until/package.json @@ -0,0 +1,37 @@ +{ + "name": "@open-draft/until", + "version": "2.1.0", + "description": "Gracefully handle a Promise using async/await.", + "main": "./lib/index.js", + "module": "./lib/index.mjs", + "types": "./lib/index.d.ts", + "exports": { + ".": { + "types": "./lib/index.d.ts", + "require": "./lib/index.js", + "import": "./lib/index.mjs", + "default": "./lib/index.mjs" + } + }, + "repository": "open-draft/until", + "author": "Artem Zakharchenko ", + "license": "MIT", + "files": [ + "README.md", + "lib" + ], + "devDependencies": { + "@ossjs/release": "^0.5.1", + "@types/jest": "^26.0.22", + "jest": "^26.6.3", + "ts-jest": "^26.5.4", + "tsup": "^6.2.3", + "typescript": "^4.2.4" + }, + "scripts": { + "start": "tsc -w", + "test": "jest", + "build": "tsup", + "release": "release publish" + } +} \ No newline at end of file diff --git a/node_modules/@otplib/core/LICENSE b/node_modules/@otplib/core/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..506fdcf21878a5f086dca33b24014f67314cc1fd --- /dev/null +++ b/node_modules/@otplib/core/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Gerald Yeo + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@otplib/core/README.md b/node_modules/@otplib/core/README.md new file mode 100644 index 0000000000000000000000000000000000000000..20bea30a6e6938daebe99bd9f06d9d99eb8a2580 --- /dev/null +++ b/node_modules/@otplib/core/README.md @@ -0,0 +1,131 @@ +# @otplib/core + +> Provides core methods for hotp, totp and authenticator. + + + +- [Getting Started](#getting-started) + - [Install the Package](#install-the-package) + - [Choose Your Plugins](#choose-your-plugins) + - [Adding Crypto](#adding-crypto) + - [Adding Base32](#adding-base32) + - [Initialise your Instance](#initialise-your-instance) + - [Using Classes](#using-classes) + - [Using Functions](#using-functions) +- [Available Options](#available-options) +- [License](#license) + + + +## Getting Started + +This is the full setup guide for installing, configuring and customising +your dependencies for the library. + +> Check out the [Quick Start Guide][docs-quick-start] instead for easier +> setup especially if you do not need to use any custom base32 / crypto libraries. + +### Install the Package + +```bash +npm install @otplib/core +``` + +### Choose Your Plugins + +#### Adding Crypto + +The crypto modules are used to generate the digest used to derive the OTP tokens from. +By default, Node.js has inbuilt `crypto` functionality, but you might want to replace it +for certain environments that do not support it. + +Currently there are a few crypto plugins available from this project. +Install one of them. eg: `npm install @otplib/plugin-crypto` + +Refer to the [crypto plugins list][docs-plugins-crypto], +or search for [otplib-plugin crypto][link-npm-search-crypto] on `npm`. + +#### Adding Base32 + +If you're using `Google Authenticator`, you'll need a base32 module for +encoding and decoding your secrets. + +Currently, there are a few base32 plugins available from this project. +Install one of them. eg: `npm install @otplib/plugin-thirty-two` + +Refer to the [base32 plugin list][docs-plugins-base32], +or search for [otplib-plugin base32][link-npm-search-base32] on `npm`. + +### Initialise your Instance + +#### Using Classes + +```js +import { HOTP, TOTP, Authenticator } from '@otplib/core'; + +import { keyDecoder, keyEncoder } from '@otplib/plugin-thirty-two'; // use your chosen base32 plugin +import { createDigest, createRandomBytes } from '@otplib/plugin-crypto'; // use your chosen crypto plugin + +// Setup an OTP instance which you need +const hotp = new HOTP({ createDigest }); +const totp = new TOTP({ createDigest }); +const authenticator = new Authenticator({ + createDigest, + createRandomBytes, + keyDecoder, + keyEncoder +}); + +// Go forth and generate tokens +const token = hotp.generate(YOUR_SECRET, 0); +const token = totp.generate(YOUR_SECRET); +const token = authenticator.generate(YOUR_SECRET); +``` + +#### Using Functions + +Alternatively, if you are using the functions directly instead of the classes, +pass these as options into the functions. + +```js +import { + hotpOptions, + hotpToken, + totpOptions, + totpToken, + authenticatorOptions, + authenticatorToken +} from 'otplib/core'; + +// As with classes, import your desired Base32 Plugin and Crypto Plugin. +// import ... + +// Go forth and generate tokens +const token = hotpToken(YOUR_SECRET, 0, hotpOptions({ createDigest })); +const token = totpToken(YOUR_SECRET, totpOptions({ createDigest })); +const token = authenticatorToken( + YOUR_SECRET, + authenticatorOptions({ + createDigest, + createRandomBytes, + keyDecoder, + keyEncoder + }) +); +``` + +## Available Options + +Please refer to the [Options Guide][docs-options]. + +## License + +`@otplib/core` is [MIT licensed][project-license] + +[link-npm-search-base32]: https://www.npmjs.com/search?q=otplib-plugin%20base32 +[link-npm-search-crypto]: https://www.npmjs.com/search?q=otplib-plugin%20crypto +[docs-options]: https://github.com/yeojz/otplib/blob/master/README.md#available-options +[docs-plugins-base32]: https://github.com/yeojz/otplib/blob/master/packages/README.md#plugins---base32 +[docs-plugins-crypto]: https://github.com/yeojz/otplib/blob/master/packages/README.md#plugins---crypto +[docs-quick-start]: https://github.com/yeojz/otplib/blob/master/README.md#quick-start +[project-license]: https://github.com/yeojz/otplib/blob/master/LICENSE diff --git a/node_modules/@otplib/core/authenticator.d.ts b/node_modules/@otplib/core/authenticator.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6f8ddc0d7c2662d786b94721942467661bc6f809 --- /dev/null +++ b/node_modules/@otplib/core/authenticator.d.ts @@ -0,0 +1,145 @@ +import { KeyEncodings, SecretKey } from './utils'; +import { TOTP, TOTPOptions } from './totp'; +/** + * RFC4648 / RFC3548 Base32 String. + * + * Other Base32 encoding methods like Crockford's Base32 + * will not be compatible with Google Authenticator. + */ +export declare type Base32SecretKey = SecretKey; +/** + * Interface method for [[AuthenticatorOptions.keyEncoder]]. + */ +export interface KeyEncoder { + (secret: SecretKey, encoding: KeyEncodings): T; +} +/** + * Interface method for [[AuthenticatorOptions.keyDecoder]]. + */ +export interface KeyDecoder { + (encodedSecret: Base32SecretKey, encoding: KeyEncodings): T; +} +/** + * Interface method for [[AuthenticatorOptions.createRandomBytes]]. + */ +export interface CreateRandomBytes { + (size: number, encoding: KeyEncodings): T; +} +/** + * Interface for options used in Authenticator. + * + * Contains additional options in addition to + * those within TOTP. + */ +export interface AuthenticatorOptions extends TOTPOptions { + /** + * Encodes a secret key into a Base32 string before it is + * sent to the user (in QR Code etc). + */ + keyEncoder: KeyEncoder; + /** + * Decodes the Base32 string given by the user into a secret. + * */ + keyDecoder: KeyDecoder; + /** + * Creates a random string containing the defined number of + * bytes to be used in generating a secret key. + */ + createRandomBytes: CreateRandomBytes; +} +/** + * Validates the given [[AuthenticatorOptions]]. + */ +export declare function authenticatorOptionValidator = AuthenticatorOptions>(options: Partial): void; +/** + * Returns a set of default options for authenticator at the current epoch. + */ +export declare function authenticatorDefaultOptions = AuthenticatorOptions>(): Partial; +/** + * Takes an Authenticator Option object and provides presets for + * some of the missing required Authenticator option fields and validates + * the resultant options. + */ +export declare function authenticatorOptions = AuthenticatorOptions>(opt: Partial): Readonly; +/** + * Encodes a given secret key into a Base32 secret + * using a [[KeyEncoder]] method set in the options. + * + * @param secret - The [[SecretKey]] to encode into a [[Base32SecretKey]] + * @param options - An [[AuthenticatorOptions]] object + */ +export declare function authenticatorEncoder = AuthenticatorOptions>(secret: SecretKey, options: Pick): ReturnType; +/** + * Decodes a given Base32 secret to a secret key + * using a [[KeyDecoder]] method set in the options. + * + * @param secret - The [[Base32SecretKey]] to decode + * @param options - An [[AuthenticatorOptions]] object + */ +export declare function authenticatorDecoder = AuthenticatorOptions>(secret: Base32SecretKey, options: Pick): ReturnType; +/** + * Generates a random Base32 Secret Key. + * + * @param numberOfBytes - Number of bytes per secret key + * @param options.createRandomBytes + * @param options.encoding + * @param options.keyEncoder + */ +export declare function authenticatorGenerateSecret(numberOfBytes: number, options: Pick): Base32SecretKey; +/** + * Generates the Authenticator based token. + * + * tl;dr: Authenticator = TOTP + Base32 Secret + * + * **References** + * + * - https://en.wikipedia.org/wiki/Google_Authenticator + * + * @param secret - [[Base32SecretKey]] + * @param options - An [[AuthenticatorOptions]] object. + */ +export declare function authenticatorToken(secret: Base32SecretKey, options: Readonly): string; +/** + * Decodes the encodedSecret and passes it to [[totpCheckWithWindow]] + * + * @param token - The token to check + * @param secret - The [[Base32SecretKey]] + * @param options - An [[AuthenticatorOptions]] object. + */ +export declare function authenticatorCheckWithWindow(token: string, secret: Base32SecretKey, options: Readonly): number | null; +/** + * A class wrapper containing all Authenticator methods. + */ +export declare class Authenticator = AuthenticatorOptions> extends TOTP { + /** + * Creates a new instance with all defaultOptions and options reset. + */ + create(defaultOptions?: Partial): Authenticator; + /** + * Returns a set of options at the current moment, + * polyfilled with some of the missing required options. + * + * Refer to [[authenticatorOptions]] + */ + allOptions(): Readonly; + /** + * Reference: [[authenticatorToken]] + */ + generate(secret: Base32SecretKey): string; + /** + * Reference: [[authenticatorCheckWithWindow]] + */ + checkDelta(token: string, secret: Base32SecretKey): number | null; + /** + * Reference: [[authenticatorEncoder]] + */ + encode(secret: SecretKey): Base32SecretKey; + /** + * Reference: [[authenticatorDecoder]] + */ + decode(secret: Base32SecretKey): SecretKey; + /** + * Reference: [[authenticatorGenerateSecret]] + */ + generateSecret(numberOfBytes?: number): Base32SecretKey; +} diff --git a/node_modules/@otplib/core/hotp.d.ts b/node_modules/@otplib/core/hotp.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e0a73b2ff0b0dda6041f32717d1b09f87d9f9c08 --- /dev/null +++ b/node_modules/@otplib/core/hotp.d.ts @@ -0,0 +1,128 @@ +import { CreateDigest, CreateHmacKey, HashAlgorithms, HexString, KeyEncodings, OTP, OTPOptions, SecretKey } from './utils'; +/** + * Interface for options used in HOTP. + */ +export interface HOTPOptions extends OTPOptions { + /** + * Creates the digest which token is derived from. + */ + createDigest: CreateDigest; + /** + * Formats the secret into a HMAC key, applying transformations (like padding) where needed + */ + createHmacKey: CreateHmacKey; + /** + * The algorithm used for calculating the HMAC. + */ + algorithm: HashAlgorithms; + /** + * **USE WITH CAUTION:** Given the same digest, the same token will be received. + * + * This is provided for unique use cases. For example, digest generation might + * depend on an async API. + */ + digest?: HexString; + /** + * The number of digits a token will have. Usually 6 or 8. + */ + digits: number; + /** + * The encoding that was used on the secret. + */ + encoding: KeyEncodings; +} +/** + * Validates the given [[HOTPOptions]] + */ +export declare function hotpOptionsValidator = HOTPOptions>(options: Readonly>): void; +/** + * Takes a HOTP secret and derives the HMAC key + * for use in token generation. + * + * @param algorithm - Reference: [[HOTPOptions.algorithm]] + * @param secret + * @param encoding - Reference: [[HOTPOptions.encoding]] + */ +export declare const hotpCreateHmacKey: CreateHmacKey; +/** + * Returns the default options for HOTP + */ +export declare function hotpDefaultOptions = HOTPOptions>(): Partial; +/** + * Takes an HOTP Option object and provides presets for + * some of the missing required HOTP option fields and validates + * the resultant options. + */ +export declare function hotpOptions = HOTPOptions>(opt: Readonly>): Readonly; +/** + * Formats a given counter into a string counter. + */ +export declare function hotpCounter(counter: number): HexString; +/** + * Converts a digest to a token of a specified length. + */ +export declare function hotpDigestToToken(hexDigest: HexString, digits: number): string; +/** + * Generates a HMAC-based One-time Token (HOTP) + * + * **References** + * + * - http://en.wikipedia.org/wiki/HMAC-based_One-time_Password_Algorithm + * - http://tools.ietf.org/html/rfc4226 + * + * **Note**: If options.digest is provided, it will skip digest generation. + * Use options.digest with caution. Same digest = Same token. + * + * @param secret - Your secret key. + * @param counter - the OTP counter (usually it's an incremental count) + * @param options - A HOTPOptions object. + */ +export declare function hotpToken = HOTPOptions>(secret: SecretKey, counter: number, options: Readonly): string; +/** + * Checks the given token against the system generated token. + * + * **Note**: Token is valid only if it is a number string + */ +export declare function hotpCheck = HOTPOptions>(token: string, secret: SecretKey, counter: number, options: Readonly): boolean; +/** + * Generates a [keyuri](../#keyuri) from options provided + * and it's type set to HOTP. + */ +export declare function hotpKeyuri = HOTPOptions>(accountName: string, issuer: string, secret: SecretKey, counter: number, options: Readonly): string; +/** + * A class wrapper containing all HOTP methods. + */ +export declare class HOTP extends OTP { + /** + * Creates a new instance with all defaultOptions and options reset. + */ + create(defaultOptions?: Partial): HOTP; + /** + * Returns class options polyfilled with some of + * the missing required options. + * + * Reference: [[hotpOptions]] + */ + allOptions(): Readonly; + /** + * Reference: [[hotpToken]] + */ + generate(secret: SecretKey, counter: number): string; + /** + * Reference: [[hotpCheck]] + */ + check(token: string, secret: SecretKey, counter: number): boolean; + /** + * Same as [[check]] but accepts a single object based argument. + */ + verify(opts: { + token: string; + secret: SecretKey; + counter: number; + }): boolean; + /** + * Calls [keyuri](../#keyuri) with class options and type + * set to HOTP. + */ + keyuri(accountName: string, issuer: string, secret: SecretKey, counter: number): string; +} diff --git a/node_modules/@otplib/core/index.d.ts b/node_modules/@otplib/core/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5c1db3e00321bcb7291e33cc072828aebf20fb7e --- /dev/null +++ b/node_modules/@otplib/core/index.d.ts @@ -0,0 +1,4 @@ +export * from './utils'; +export * from './hotp'; +export * from './totp'; +export * from './authenticator'; diff --git a/node_modules/@otplib/core/index.js b/node_modules/@otplib/core/index.js new file mode 100644 index 0000000000000000000000000000000000000000..38517b9511e2dbc8a7f1bd3b8850bbaafac5bafe --- /dev/null +++ b/node_modules/@otplib/core/index.js @@ -0,0 +1,491 @@ +/** + * @otplib/core + * + * @author Gerald Yeo + * @version: 12.0.1 + * @license: MIT + **/ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +function objectValues(value) { + return Object.keys(value).map(key => value[key]); +} +(function (HashAlgorithms) { + HashAlgorithms["SHA1"] = "sha1"; + HashAlgorithms["SHA256"] = "sha256"; + HashAlgorithms["SHA512"] = "sha512"; +})(exports.HashAlgorithms || (exports.HashAlgorithms = {})); +const HASH_ALGORITHMS = objectValues(exports.HashAlgorithms); +(function (KeyEncodings) { + KeyEncodings["ASCII"] = "ascii"; + KeyEncodings["BASE64"] = "base64"; + KeyEncodings["HEX"] = "hex"; + KeyEncodings["LATIN1"] = "latin1"; + KeyEncodings["UTF8"] = "utf8"; +})(exports.KeyEncodings || (exports.KeyEncodings = {})); +const KEY_ENCODINGS = objectValues(exports.KeyEncodings); +(function (Strategy) { + Strategy["HOTP"] = "hotp"; + Strategy["TOTP"] = "totp"; +})(exports.Strategy || (exports.Strategy = {})); +const STRATEGY = objectValues(exports.Strategy); +const createDigestPlaceholder = () => { + throw new Error('Please provide an options.createDigest implementation.'); +}; +function isTokenValid(value) { + return /^(\d+)$/.test(value); +} +function padStart(value, maxLength, fillString) { + if (value.length >= maxLength) { + return value; + } + const padding = Array(maxLength + 1).join(fillString); + return `${padding}${value}`.slice(-1 * maxLength); +} +function keyuri(options) { + const tmpl = `otpauth://${options.type}/{labelPrefix}:{accountName}?secret={secret}{query}`; + const params = []; + if (STRATEGY.indexOf(options.type) < 0) { + throw new Error(`Expecting options.type to be one of ${STRATEGY.join(', ')}. Received ${options.type}.`); + } + if (options.type === 'hotp') { + if (options.counter == null || typeof options.counter !== 'number') { + throw new Error('Expecting options.counter to be a number when options.type is "hotp".'); + } + params.push(`&counter=${options.counter}`); + } + if (options.type === 'totp' && options.step) { + params.push(`&period=${options.step}`); + } + if (options.digits) { + params.push(`&digits=${options.digits}`); + } + if (options.algorithm) { + params.push(`&algorithm=${options.algorithm.toUpperCase()}`); + } + if (options.issuer) { + params.push(`&issuer=${encodeURIComponent(options.issuer)}`); + } + return tmpl.replace('{labelPrefix}', encodeURIComponent(options.issuer || options.accountName)).replace('{accountName}', encodeURIComponent(options.accountName)).replace('{secret}', options.secret).replace('{query}', params.join('')); +} +class OTP { + constructor(defaultOptions = {}) { + this._defaultOptions = Object.freeze({ ...defaultOptions + }); + this._options = Object.freeze({}); + } + create(defaultOptions = {}) { + return new OTP(defaultOptions); + } + clone(defaultOptions = {}) { + const instance = this.create({ ...this._defaultOptions, + ...defaultOptions + }); + instance.options = this._options; + return instance; + } + get options() { + return Object.freeze({ ...this._defaultOptions, + ...this._options + }); + } + set options(options) { + this._options = Object.freeze({ ...this._options, + ...options + }); + } + allOptions() { + return this.options; + } + resetOptions() { + this._options = Object.freeze({}); + } +} + +function hotpOptionsValidator(options) { + if (typeof options.createDigest !== 'function') { + throw new Error('Expecting options.createDigest to be a function.'); + } + if (typeof options.createHmacKey !== 'function') { + throw new Error('Expecting options.createHmacKey to be a function.'); + } + if (typeof options.digits !== 'number') { + throw new Error('Expecting options.digits to be a number.'); + } + if (!options.algorithm || HASH_ALGORITHMS.indexOf(options.algorithm) < 0) { + throw new Error(`Expecting options.algorithm to be one of ${HASH_ALGORITHMS.join(', ')}. Received ${options.algorithm}.`); + } + if (!options.encoding || KEY_ENCODINGS.indexOf(options.encoding) < 0) { + throw new Error(`Expecting options.encoding to be one of ${KEY_ENCODINGS.join(', ')}. Received ${options.encoding}.`); + } +} +const hotpCreateHmacKey = (algorithm, secret, encoding) => { + return Buffer.from(secret, encoding).toString('hex'); +}; +function hotpDefaultOptions() { + const options = { + algorithm: exports.HashAlgorithms.SHA1, + createHmacKey: hotpCreateHmacKey, + createDigest: createDigestPlaceholder, + digits: 6, + encoding: exports.KeyEncodings.ASCII + }; + return options; +} +function hotpOptions(opt) { + const options = { ...hotpDefaultOptions(), + ...opt + }; + hotpOptionsValidator(options); + return Object.freeze(options); +} +function hotpCounter(counter) { + const hexCounter = counter.toString(16); + return padStart(hexCounter, 16, '0'); +} +function hotpDigestToToken(hexDigest, digits) { + const digest = Buffer.from(hexDigest, 'hex'); + const offset = digest[digest.length - 1] & 0xf; + const binary = (digest[offset] & 0x7f) << 24 | (digest[offset + 1] & 0xff) << 16 | (digest[offset + 2] & 0xff) << 8 | digest[offset + 3] & 0xff; + const token = binary % Math.pow(10, digits); + return padStart(String(token), digits, '0'); +} +function hotpDigest(secret, counter, options) { + const hexCounter = hotpCounter(counter); + const hmacKey = options.createHmacKey(options.algorithm, secret, options.encoding); + return options.createDigest(options.algorithm, hmacKey, hexCounter); +} +function hotpToken(secret, counter, options) { + const hexDigest = options.digest || hotpDigest(secret, counter, options); + return hotpDigestToToken(hexDigest, options.digits); +} +function hotpCheck(token, secret, counter, options) { + if (!isTokenValid(token)) { + return false; + } + const systemToken = hotpToken(secret, counter, options); + return token === systemToken; +} +function hotpKeyuri(accountName, issuer, secret, counter, options) { + return keyuri({ + algorithm: options.algorithm, + digits: options.digits, + type: exports.Strategy.HOTP, + accountName, + counter, + issuer, + secret + }); +} +class HOTP extends OTP { + create(defaultOptions = {}) { + return new HOTP(defaultOptions); + } + allOptions() { + return hotpOptions(this.options); + } + generate(secret, counter) { + return hotpToken(secret, counter, this.allOptions()); + } + check(token, secret, counter) { + return hotpCheck(token, secret, counter, this.allOptions()); + } + verify(opts) { + if (typeof opts !== 'object') { + throw new Error('Expecting argument 0 of verify to be an object'); + } + return this.check(opts.token, opts.secret, opts.counter); + } + keyuri(accountName, issuer, secret, counter) { + return hotpKeyuri(accountName, issuer, secret, counter, this.allOptions()); + } +} + +function parseWindowBounds(win) { + if (typeof win === 'number') { + return [Math.abs(win), Math.abs(win)]; + } + if (Array.isArray(win)) { + const [past, future] = win; + if (typeof past === 'number' && typeof future === 'number') { + return [Math.abs(past), Math.abs(future)]; + } + } + throw new Error('Expecting options.window to be an number or [number, number].'); +} +function totpOptionsValidator(options) { + hotpOptionsValidator(options); + parseWindowBounds(options.window); + if (typeof options.epoch !== 'number') { + throw new Error('Expecting options.epoch to be a number.'); + } + if (typeof options.step !== 'number') { + throw new Error('Expecting options.step to be a number.'); + } +} +const totpPadSecret = (secret, encoding, minLength) => { + const currentLength = secret.length; + const hexSecret = Buffer.from(secret, encoding).toString('hex'); + if (currentLength < minLength) { + const newSecret = new Array(minLength - currentLength + 1).join(hexSecret); + return Buffer.from(newSecret, 'hex').slice(0, minLength).toString('hex'); + } + return hexSecret; +}; +const totpCreateHmacKey = (algorithm, secret, encoding) => { + switch (algorithm) { + case exports.HashAlgorithms.SHA1: + return totpPadSecret(secret, encoding, 20); + case exports.HashAlgorithms.SHA256: + return totpPadSecret(secret, encoding, 32); + case exports.HashAlgorithms.SHA512: + return totpPadSecret(secret, encoding, 64); + default: + throw new Error(`Expecting algorithm to be one of ${HASH_ALGORITHMS.join(', ')}. Received ${algorithm}.`); + } +}; +function totpDefaultOptions() { + const options = { + algorithm: exports.HashAlgorithms.SHA1, + createDigest: createDigestPlaceholder, + createHmacKey: totpCreateHmacKey, + digits: 6, + encoding: exports.KeyEncodings.ASCII, + epoch: Date.now(), + step: 30, + window: 0 + }; + return options; +} +function totpOptions(opt) { + const options = { ...totpDefaultOptions(), + ...opt + }; + totpOptionsValidator(options); + return Object.freeze(options); +} +function totpCounter(epoch, step) { + return Math.floor(epoch / step / 1000); +} +function totpToken(secret, options) { + const counter = totpCounter(options.epoch, options.step); + return hotpToken(secret, counter, options); +} +function totpEpochsInWindow(epoch, direction, deltaPerEpoch, numOfEpoches) { + const result = []; + if (numOfEpoches === 0) { + return result; + } + for (let i = 1; i <= numOfEpoches; i++) { + const delta = direction * i * deltaPerEpoch; + result.push(epoch + delta); + } + return result; +} +function totpEpochAvailable(epoch, step, win) { + const bounds = parseWindowBounds(win); + const delta = step * 1000; + return { + current: epoch, + past: totpEpochsInWindow(epoch, -1, delta, bounds[0]), + future: totpEpochsInWindow(epoch, 1, delta, bounds[1]) + }; +} +function totpCheck(token, secret, options) { + if (!isTokenValid(token)) { + return false; + } + const systemToken = totpToken(secret, options); + return token === systemToken; +} +function totpCheckByEpoch(epochs, token, secret, options) { + let position = null; + epochs.some((epoch, idx) => { + if (totpCheck(token, secret, { ...options, + epoch + })) { + position = idx + 1; + return true; + } + return false; + }); + return position; +} +function totpCheckWithWindow(token, secret, options) { + if (totpCheck(token, secret, options)) { + return 0; + } + const epochs = totpEpochAvailable(options.epoch, options.step, options.window); + const backward = totpCheckByEpoch(epochs.past, token, secret, options); + if (backward !== null) { + return backward * -1; + } + return totpCheckByEpoch(epochs.future, token, secret, options); +} +function totpTimeUsed(epoch, step) { + return Math.floor(epoch / 1000) % step; +} +function totpTimeRemaining(epoch, step) { + return step - totpTimeUsed(epoch, step); +} +function totpKeyuri(accountName, issuer, secret, options) { + return keyuri({ + algorithm: options.algorithm, + digits: options.digits, + step: options.step, + type: exports.Strategy.TOTP, + accountName, + issuer, + secret + }); +} +class TOTP extends HOTP { + create(defaultOptions = {}) { + return new TOTP(defaultOptions); + } + allOptions() { + return totpOptions(this.options); + } + generate(secret) { + return totpToken(secret, this.allOptions()); + } + checkDelta(token, secret) { + return totpCheckWithWindow(token, secret, this.allOptions()); + } + check(token, secret) { + const delta = this.checkDelta(token, secret); + return typeof delta === 'number'; + } + verify(opts) { + if (typeof opts !== 'object') { + throw new Error('Expecting argument 0 of verify to be an object'); + } + return this.check(opts.token, opts.secret); + } + timeRemaining() { + const options = this.allOptions(); + return totpTimeRemaining(options.epoch, options.step); + } + timeUsed() { + const options = this.allOptions(); + return totpTimeUsed(options.epoch, options.step); + } + keyuri(accountName, issuer, secret) { + return totpKeyuri(accountName, issuer, secret, this.allOptions()); + } +} + +function authenticatorOptionValidator(options) { + totpOptionsValidator(options); + if (typeof options.keyDecoder !== 'function') { + throw new Error('Expecting options.keyDecoder to be a function.'); + } + if (options.keyEncoder && typeof options.keyEncoder !== 'function') { + throw new Error('Expecting options.keyEncoder to be a function.'); + } +} +function authenticatorDefaultOptions() { + const options = { + algorithm: exports.HashAlgorithms.SHA1, + createDigest: createDigestPlaceholder, + createHmacKey: totpCreateHmacKey, + digits: 6, + encoding: exports.KeyEncodings.HEX, + epoch: Date.now(), + step: 30, + window: 0 + }; + return options; +} +function authenticatorOptions(opt) { + const options = { ...authenticatorDefaultOptions(), + ...opt + }; + authenticatorOptionValidator(options); + return Object.freeze(options); +} +function authenticatorEncoder(secret, options) { + return options.keyEncoder(secret, options.encoding); +} +function authenticatorDecoder(secret, options) { + return options.keyDecoder(secret, options.encoding); +} +function authenticatorGenerateSecret(numberOfBytes, options) { + const key = options.createRandomBytes(numberOfBytes, options.encoding); + return authenticatorEncoder(key, options); +} +function authenticatorToken(secret, options) { + return totpToken(authenticatorDecoder(secret, options), options); +} +function authenticatorCheckWithWindow(token, secret, options) { + return totpCheckWithWindow(token, authenticatorDecoder(secret, options), options); +} +class Authenticator extends TOTP { + create(defaultOptions = {}) { + return new Authenticator(defaultOptions); + } + allOptions() { + return authenticatorOptions(this.options); + } + generate(secret) { + return authenticatorToken(secret, this.allOptions()); + } + checkDelta(token, secret) { + return authenticatorCheckWithWindow(token, secret, this.allOptions()); + } + encode(secret) { + return authenticatorEncoder(secret, this.allOptions()); + } + decode(secret) { + return authenticatorDecoder(secret, this.allOptions()); + } + generateSecret(numberOfBytes = 10) { + return authenticatorGenerateSecret(numberOfBytes, this.allOptions()); + } +} + +exports.Authenticator = Authenticator; +exports.HASH_ALGORITHMS = HASH_ALGORITHMS; +exports.HOTP = HOTP; +exports.KEY_ENCODINGS = KEY_ENCODINGS; +exports.OTP = OTP; +exports.STRATEGY = STRATEGY; +exports.TOTP = TOTP; +exports.authenticatorCheckWithWindow = authenticatorCheckWithWindow; +exports.authenticatorDecoder = authenticatorDecoder; +exports.authenticatorDefaultOptions = authenticatorDefaultOptions; +exports.authenticatorEncoder = authenticatorEncoder; +exports.authenticatorGenerateSecret = authenticatorGenerateSecret; +exports.authenticatorOptionValidator = authenticatorOptionValidator; +exports.authenticatorOptions = authenticatorOptions; +exports.authenticatorToken = authenticatorToken; +exports.createDigestPlaceholder = createDigestPlaceholder; +exports.hotpCheck = hotpCheck; +exports.hotpCounter = hotpCounter; +exports.hotpCreateHmacKey = hotpCreateHmacKey; +exports.hotpDefaultOptions = hotpDefaultOptions; +exports.hotpDigestToToken = hotpDigestToToken; +exports.hotpKeyuri = hotpKeyuri; +exports.hotpOptions = hotpOptions; +exports.hotpOptionsValidator = hotpOptionsValidator; +exports.hotpToken = hotpToken; +exports.isTokenValid = isTokenValid; +exports.keyuri = keyuri; +exports.objectValues = objectValues; +exports.padStart = padStart; +exports.totpCheck = totpCheck; +exports.totpCheckByEpoch = totpCheckByEpoch; +exports.totpCheckWithWindow = totpCheckWithWindow; +exports.totpCounter = totpCounter; +exports.totpCreateHmacKey = totpCreateHmacKey; +exports.totpDefaultOptions = totpDefaultOptions; +exports.totpEpochAvailable = totpEpochAvailable; +exports.totpKeyuri = totpKeyuri; +exports.totpOptions = totpOptions; +exports.totpOptionsValidator = totpOptionsValidator; +exports.totpPadSecret = totpPadSecret; +exports.totpTimeRemaining = totpTimeRemaining; +exports.totpTimeUsed = totpTimeUsed; +exports.totpToken = totpToken; diff --git a/node_modules/@otplib/core/package.json b/node_modules/@otplib/core/package.json new file mode 100644 index 0000000000000000000000000000000000000000..e947f0d3c0d1496ef219dcfb57d438d947ec81f7 --- /dev/null +++ b/node_modules/@otplib/core/package.json @@ -0,0 +1,19 @@ +{ + "name": "@otplib/core", + "description": "core method for otplib", + "version": "12.0.1", + "main": "./index.js", + "publishConfig": { + "access": "public" + }, + "scripts": {}, + "keywords": [ + "otplib-core" + ], + "otplib": {}, + "author": "Gerald Yeo ", + "license": "MIT", + "homepage": "https://yeojz.otplib.dev", + "repository": "https://github.com/yeojz/otplib/tree/master/packages/otplib-core", + "types": "./index.d.ts" +} \ No newline at end of file diff --git a/node_modules/@otplib/core/totp.d.ts b/node_modules/@otplib/core/totp.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fcca4ca5b34d10760b9f42265b6cab27e22ad2d6 --- /dev/null +++ b/node_modules/@otplib/core/totp.d.ts @@ -0,0 +1,202 @@ +import { CreateHmacKey, KeyEncodings, SecretKey } from './utils'; +import { HOTP, HOTPOptions } from './hotp'; +/** + * Interface for options used in TOTP. + * + * Contains additional options in addition to + * those within HOTP. + */ +export interface TOTPOptions extends HOTPOptions { + /** + * The starting time since the JavasSript epoch (seconds) (UNIX epoch * 1000). + */ + epoch: number; + /** + * Time step (seconds). + */ + step: number; + /** + * How many windows (x * step) past and future do we consider as valid during check. + */ + window: number | [number, number]; +} +/** + * Interface for available epoches derived from + * the current epoch. + */ +export interface EpochAvailable { + current: number; + future: number[]; + past: number[]; +} +/** + * Validates the given [[TOTPOptions]]. + */ +export declare function totpOptionsValidator = TOTPOptions>(options: Readonly>): void; +/** + * Pads the secret to the expected minimum length + * and returns a hex representation of the string. + */ +export declare const totpPadSecret: (secret: string, encoding: KeyEncodings, minLength: number) => string; +/** + * Takes a TOTP secret and derives the HMAC key + * for use in token generation. + * + * In RFC 6238, the secret / seed length for different algorithms + * are predefined. + * + * - HMAC-SHA1 (20 bytes) + * - HMAC-SHA256 (32 bytes) + * - HMAC-SHA512 (64 bytes) + * + * @param algorithm - Reference: [[TOTPOptions.algorithm]] + * @param secret + * @param encoding - Reference: [[TOTPOptions.encoding]] + */ +export declare const totpCreateHmacKey: CreateHmacKey; +/** + * Returns a set of default options for TOTP at the current epoch. + */ +export declare function totpDefaultOptions = TOTPOptions>(): Partial; +/** + * Takes an TOTP Option object and provides presets for + * some of the missing required TOTP option fields and validates + * the resultant options. + */ +export declare function totpOptions = TOTPOptions>(opt: Partial): Readonly; +/** + * Generates the counter based on the current epoch and step. + * This dynamic counter is used in the HOTP algorithm. + * + * @param epoch - Reference: [[TOTPOptions.epoch]] + * @param step - Reference: [[TOTPOptions.step]] + */ +export declare function totpCounter(epoch: number, step: number): number; +/** + * Generates a Time-based One-time Token (TOTP) + * + * tl;dr: TOTP = HOTP + counter based on current time. + * + * **References** + * + * - http://tools.ietf.org/html/rfc6238 + * - http://en.wikipedia.org/wiki/Time-based_One-time_Password_Algorithm + * + */ +export declare function totpToken = TOTPOptions>(secret: SecretKey, options: Readonly): string; +/** + * Gets a set of epoches derived from + * the current epoch and the acceptable window. + * + * @param epoch - Reference: [[TOTPOptions.epoch]] + * @param step - Reference: [[TOTPOptions.step]] + * @param win - Reference: [[TOTPOptions.window]] + */ +export declare function totpEpochAvailable(epoch: number, step: number, win: number | [number, number]): EpochAvailable; +/** + * Checks the given token against the system generated token. + * + * **Note**: Token is valid only if it is a number string. + */ +export declare function totpCheck = TOTPOptions>(token: string, secret: SecretKey, options: Readonly): boolean; +/** + * Checks if there is a valid TOTP token in a given list of epoches. + * Returns the (index + 1) of a valid epoch in the list. + * + * @param epochs - List of epochs to check token against + * @param token - The token to check + * @param secret - Your secret key. + * @param options - A TOTPOptions object. + */ +export declare function totpCheckByEpoch(epochs: number[], token: string, secret: SecretKey, options: Readonly): number | null; +/** + * Checks the provided OTP token against system generated token + * with support for checking past or future x * step windows. + * + * Return values: + * + * - null = check failed + * - positive number = token at future x * step + * - negative number = token at past x * step + * + * @param token - The token to check + * @param secret - Your secret key. + * @param options - A TOTPOptions object. + */ +export declare function totpCheckWithWindow(token: string, secret: SecretKey, options: Readonly): number | null; +/** + * Calculates the number of seconds used in the current tick for TOTP. + * + * The start of a new token: `timeUsed() === 0` + * + * @param epoch - Reference: [[TOTPOptions.epoch]] + * @param step - Reference: [[TOTPOptions.step]] + */ +export declare function totpTimeUsed(epoch: number, step: number): number; +/** + * Calculates the number of seconds till next tick for TOTP. + * + * The start of a new token: `timeRemaining() === step` + * + * @param epoch - Reference: [[TOTPOptions.epoch]] + * @param step - Reference: [[TOTPOptions.step]] + */ +export declare function totpTimeRemaining(epoch: number, step: number): number; +/** + * Generates a [keyuri](../#keyuri) from options provided + * and it's type set to TOTP. + */ +export declare function totpKeyuri = TOTPOptions>(accountName: string, issuer: string, secret: SecretKey, options: Readonly): string; +/** + * A class wrapper containing all TOTP methods. + */ +export declare class TOTP extends HOTP { + /** + * Creates a new instance with all defaultOptions and options reset. + */ + create(defaultOptions?: Partial): TOTP; + /** + * Returns class options polyfilled with some of + * the missing required options. + * + * Reference: [[totpOptions]] + */ + allOptions(): Readonly; + /** + * Reference: [[totpToken]] + */ + generate(secret: SecretKey): string; + /** + * Reference: [[totpCheckWithWindow]] + */ + checkDelta(token: string, secret: SecretKey): number | null; + /** + * Checks if a given TOTP token matches the generated + * token at the given epoch (default to current time). + * + * This method will return true as long as the token is + * still within the acceptable time window defined. + * + * i.e when [[checkDelta]] returns a number. + */ + check(token: string, secret: SecretKey): boolean; + /** + * Same as [[check]] but accepts a single object based argument. + */ + verify(opts: { + token: string; + secret: SecretKey; + }): boolean; + /** + * Reference: [[totpTimeRemaining]] + */ + timeRemaining(): number; + /** + * Reference: [[totpTimeUsed]] + */ + timeUsed(): number; + /** + * Reference: [[totpKeyuri]] + */ + keyuri(accountName: string, issuer: string, secret: SecretKey): string; +} diff --git a/node_modules/@otplib/core/utils.d.ts b/node_modules/@otplib/core/utils.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..729e584f8aa5433cbb283a651602e99a471751c0 --- /dev/null +++ b/node_modules/@otplib/core/utils.d.ts @@ -0,0 +1,209 @@ +/** + * Secret Key used for OTP generation. + */ +export declare type SecretKey = string; +/** + * A hex encoded string. + */ +export declare type HexString = string; +/** + * Base interface for all option interfaces. + * eg: [[HOTPOptions]]. + */ +export interface OTPOptions { + [key: string]: unknown; +} +/** + * Returns an array of values of the enumerable properties of an object. + * This is used in place of Object.values for wider platform support. + * + * @ignore + * + * @param value Object that contains the properties and methods. + */ +export declare function objectValues(value: T): string[]; +/** + * Algorithms that are available to be used for + * calculating the HMAC value + */ +export declare enum HashAlgorithms { + 'SHA1' = "sha1", + 'SHA256' = "sha256", + 'SHA512' = "sha512" +} +/** + * Array of [[HashAlgorithms]] enum values + * + * @ignore + */ +export declare const HASH_ALGORITHMS: string[]; +/** + * The encoding format for the [[SecretKey]]. + * This is mostly used for converting the + * provided secret into a Buffer. + */ +export declare enum KeyEncodings { + 'ASCII' = "ascii", + 'BASE64' = "base64", + 'HEX' = "hex", + 'LATIN1' = "latin1", + 'UTF8' = "utf8" +} +/** + * Array of [[KeyEncodings]] enum values + * + * @ignore + */ +export declare const KEY_ENCODINGS: string[]; +/** + * The OTP generation strategies. + * Either HMAC or Time based. + */ +export declare enum Strategy { + 'HOTP' = "hotp", + 'TOTP' = "totp" +} +/** + * Array of [[Strategy]] enum values + * + * @ignore + */ +export declare const STRATEGY: string[]; +/** + * Interface method for formatting the [[SecretKey]] with + * the algorithm constraints before it is given to [[CreateDigest]]. + */ +export interface CreateHmacKey { + (algorithm: HashAlgorithms, secret: SecretKey, encoding: KeyEncodings): T; +} +/** + * Interface method for generating a HMAC digest + * which is then used to generate the token. + */ +export interface CreateDigest { + (algorithm: HashAlgorithms, hmacKey: HexString, counter: HexString): T; +} +/** + * Inteface for options accepted by keyuri + */ +export interface KeyURIOptions { + accountName: string; + algorithm?: HashAlgorithms; + counter?: number; + digits?: number; + issuer?: string; + label?: string; + secret: SecretKey; + step?: number; + type: Strategy; +} +/** + * createDigest placholder function which throws an error + * when it is not replaced with an actual implementation. + * + * @ignore + */ +export declare const createDigestPlaceholder: CreateDigest; +/** + * Checks if a string contains a valid token format. + * + * @param value - a number string. + */ +export declare function isTokenValid(value: string): boolean; +/** + * Left pad the current string with a given string to a given length. + * + * This behaves similarly to String.prototype.padStart + * + * @ignore + * + * @param value The string to pad. + * @param maxLength The length of the resulting string once the current string has been padded. + * If this parameter is smaller than the current string's length, the current + * string will be returned as it is. + * @param fillString The string to pad the current string with. + */ +export declare function padStart(value: string, maxLength: number, fillString: string): string; +/** + * Generates an otpauth uri which can be used in a QR Code. + * + * Reference: https://github.com/google/google-authenticator/wiki/Key-Uri-Format + * + * Sample Output: otpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Example + * + * **Example** + * + * ```js + * import qrcode from 'qrcode'; + * + * const otpauth = keyuri({ ... }) + * + * qrcode.toDataURL(otpauth, (err, imageUrl) => { + * if (err) { + * console.log('Error with QR'); + * return; + * } + * console.log(imageUrl); + * }); + * ``` + */ +export declare function keyuri(options: KeyURIOptions): string; +/** + * Base OTP class which provides options management + * All OTP classes should be extended from this class. + */ +export declare class OTP { + /** + * Default options for an instance. + * + * These options **WILL PERSIST** even when [[resetOptions]] is called. + */ + protected _defaultOptions: Readonly>; + /** + * Transient options for an instance. + * + * Values set here will take precedence over the same options that + * are set in [[_defaultOptions]]. + * + * These options **WILL NOT PERSIST** upon calling [[resetOptions]]. + */ + protected _options: Readonly>; + /** + * Constructs the class with defaultOptions set. + * + * @param defaultOptions used to override or add existing defaultOptions. + */ + constructor(defaultOptions?: Partial); + /** + * Creates a new instance with all defaultOptions and options reset. + */ + create(defaultOptions?: Partial): OTP; + /** + * Copies the defaultOptions and options from the current + * instance and applies the provided defaultOptions. + */ + clone(defaultOptions?: Partial): ReturnType; + /** + * - The options **getter** will return all [[_options]], + * including those set into [[_defaultOptions]]. + */ + get options(): Partial; + /** + * - The options **setter** sets values into [[_options]]. + */ + set options(options: Partial); + /** + * Returns class options polyfilled with some of + * the missing required options. + * + * Reference: [[hotpOptions]] + */ + allOptions(): Readonly; + /** + * Resets the current options. Does not reset default options. + * + * Default options are those that are specified during class + * inititialisation, when calling [[clone]] or when calling [[create]] + */ + resetOptions(): void; +} diff --git a/node_modules/@otplib/plugin-crypto/LICENSE b/node_modules/@otplib/plugin-crypto/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..506fdcf21878a5f086dca33b24014f67314cc1fd --- /dev/null +++ b/node_modules/@otplib/plugin-crypto/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Gerald Yeo + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@otplib/plugin-crypto/README.md b/node_modules/@otplib/plugin-crypto/README.md new file mode 100644 index 0000000000000000000000000000000000000000..f853c5ce65949f9be3f71c6a52478f62ff5d4224 --- /dev/null +++ b/node_modules/@otplib/plugin-crypto/README.md @@ -0,0 +1,20 @@ +# @otplib/plugin-crypto + +> node native crypto adapter for otplib + +See our [project readme][project-v-readme] for more information +or visit the [demo website][project-v-site]. + +## Install + +```bash +npm install --save @otplib/plugin-crypto +``` + +## License + +`@otplib/plugin-crypto` is [MIT licensed][project-license] + +[project-license]: https://github.com/yeojz/otplib/blob/master/LICENSE +[project-v-readme]: https://github.com/yeojz/otplib/blob/master/README.md +[project-v-site]: https://otplib.yeojz.dev diff --git a/node_modules/@otplib/plugin-crypto/index.d.ts b/node_modules/@otplib/plugin-crypto/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..48c74ece141f917950cd61680e665aa8ac5e0c6e --- /dev/null +++ b/node_modules/@otplib/plugin-crypto/index.d.ts @@ -0,0 +1,3 @@ +import { CreateDigest, CreateRandomBytes } from '@otplib/core'; +export declare const createDigest: CreateDigest; +export declare const createRandomBytes: CreateRandomBytes; diff --git a/node_modules/@otplib/plugin-crypto/index.js b/node_modules/@otplib/plugin-crypto/index.js new file mode 100644 index 0000000000000000000000000000000000000000..0f8707ef8f8ace0d9fbef553d3161efdf3bb1b28 --- /dev/null +++ b/node_modules/@otplib/plugin-crypto/index.js @@ -0,0 +1,26 @@ +/** + * @otplib/plugin-crypto + * + * @author Gerald Yeo + * @version: 12.0.1 + * @license: MIT + **/ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } + +var crypto = _interopDefault(require('crypto')); + +const createDigest = (algorithm, hmacKey, counter) => { + const hmac = crypto.createHmac(algorithm, Buffer.from(hmacKey, 'hex')); + const digest = hmac.update(Buffer.from(counter, 'hex')).digest(); + return digest.toString('hex'); +}; +const createRandomBytes = (size, encoding) => { + return crypto.randomBytes(size).toString(encoding); +}; + +exports.createDigest = createDigest; +exports.createRandomBytes = createRandomBytes; diff --git a/node_modules/@otplib/plugin-crypto/package.json b/node_modules/@otplib/plugin-crypto/package.json new file mode 100644 index 0000000000000000000000000000000000000000..1d5574d004a85d6808e19476850e06e2c13eb153 --- /dev/null +++ b/node_modules/@otplib/plugin-crypto/package.json @@ -0,0 +1,26 @@ +{ + "name": "@otplib/plugin-crypto", + "description": "node crypto plugin for otplib", + "version": "12.0.1", + "main": "./index.js", + "publishConfig": { + "access": "public" + }, + "scripts": {}, + "keywords": [ + "otplib-plugin", + "crypto" + ], + "dependencies": { + "@otplib/core": "^12.0.1" + }, + "devDependencies": { + "@types/node": "^12.7.2" + }, + "otplib": {}, + "author": "Gerald Yeo ", + "license": "MIT", + "homepage": "https://yeojz.otplib.dev", + "repository": "https://github.com/yeojz/otplib/tree/master/packages/otplib-plugin-crypto", + "types": "./index.d.ts" +} \ No newline at end of file diff --git a/node_modules/@otplib/plugin-thirty-two/LICENSE b/node_modules/@otplib/plugin-thirty-two/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..506fdcf21878a5f086dca33b24014f67314cc1fd --- /dev/null +++ b/node_modules/@otplib/plugin-thirty-two/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Gerald Yeo + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@otplib/plugin-thirty-two/README.md b/node_modules/@otplib/plugin-thirty-two/README.md new file mode 100644 index 0000000000000000000000000000000000000000..25850eef8ce68a26c6b34079660b3dce913839c3 --- /dev/null +++ b/node_modules/@otplib/plugin-thirty-two/README.md @@ -0,0 +1,20 @@ +# @otplib/plugin-thirty-two + +> thirty-two adapter for otplib + +See our [project readme][project-v-readme] for more information +or visit the [demo website][project-v-site]. + +## Install + +```bash +npm install --save @otplib/plugin-thirty-two +``` + +## License + +`@otplib/plugin-thirty-two` is [MIT licensed][project-license] + +[project-license]: https://github.com/yeojz/otplib/blob/master/LICENSE +[project-v-readme]: https://github.com/yeojz/otplib/blob/master/README.md +[project-v-site]: https://otplib.yeojz.dev diff --git a/node_modules/@otplib/plugin-thirty-two/index.d.ts b/node_modules/@otplib/plugin-thirty-two/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2a7d07c95bfad9653520dbe5694ea1150705e2d6 --- /dev/null +++ b/node_modules/@otplib/plugin-thirty-two/index.d.ts @@ -0,0 +1,9 @@ +import { KeyDecoder, KeyEncoder } from '@otplib/core'; +/** + * - Key decoder using npm `thirty-two` + */ +export declare const keyDecoder: KeyDecoder; +/** + * - Key encoder using npm `thirty-two` + */ +export declare const keyEncoder: KeyEncoder; diff --git a/node_modules/@otplib/plugin-thirty-two/index.js b/node_modules/@otplib/plugin-thirty-two/index.js new file mode 100644 index 0000000000000000000000000000000000000000..68dc6d7f5e54d468f845bd2fc95924cb8f68652f --- /dev/null +++ b/node_modules/@otplib/plugin-thirty-two/index.js @@ -0,0 +1,24 @@ +/** + * @otplib/plugin-thirty-two + * + * @author Gerald Yeo + * @version: 12.0.1 + * @license: MIT + **/ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } + +var thirtyTwo = _interopDefault(require('thirty-two')); + +const keyDecoder = (encodedSecret, encoding) => { + return thirtyTwo.decode(encodedSecret).toString(encoding); +}; +const keyEncoder = (secret, encoding) => { + return thirtyTwo.encode(Buffer.from(secret, encoding).toString('ascii')).toString().replace(/=/g, ''); +}; + +exports.keyDecoder = keyDecoder; +exports.keyEncoder = keyEncoder; diff --git a/node_modules/@otplib/plugin-thirty-two/package.json b/node_modules/@otplib/plugin-thirty-two/package.json new file mode 100644 index 0000000000000000000000000000000000000000..fd901e30b1aa7ceae183a09f7f670577e2b8884e --- /dev/null +++ b/node_modules/@otplib/plugin-thirty-two/package.json @@ -0,0 +1,24 @@ +{ + "name": "@otplib/plugin-thirty-two", + "description": "thirty-two plugin for otplib", + "version": "12.0.1", + "main": "./index.js", + "publishConfig": { + "access": "public" + }, + "scripts": {}, + "keywords": [ + "otplib-plugin", + "base32" + ], + "dependencies": { + "@otplib/core": "^12.0.1", + "thirty-two": "^1.0.2" + }, + "otplib": {}, + "author": "Gerald Yeo ", + "license": "MIT", + "homepage": "https://yeojz.otplib.dev", + "repository": "https://github.com/yeojz/otplib/tree/master/packages/otplib-plugin-thirty-two", + "types": "./index.d.ts" +} \ No newline at end of file diff --git a/node_modules/@otplib/preset-default/LICENSE b/node_modules/@otplib/preset-default/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..506fdcf21878a5f086dca33b24014f67314cc1fd --- /dev/null +++ b/node_modules/@otplib/preset-default/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Gerald Yeo + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@otplib/preset-default/README.md b/node_modules/@otplib/preset-default/README.md new file mode 100644 index 0000000000000000000000000000000000000000..4d90bd401f71de5fa72047167b91458567151b19 --- /dev/null +++ b/node_modules/@otplib/preset-default/README.md @@ -0,0 +1,20 @@ +# @otplib/preset-default + +> otplib node bundle with pre-configured plugins to get started quickly. + +See our [project readme][project-v-readme] for more information +or visit the [demo website][project-v-site]. + +## Install + +```bash +npm install --save @otplib/preset-default +``` + +## License + +`@otplib/preset-default` is [MIT licensed][project-license] + +[project-license]: https://github.com/yeojz/otplib/blob/master/LICENSE +[project-v-readme]: https://github.com/yeojz/otplib/blob/master/README.md +[project-v-site]: https://otplib.yeojz.dev diff --git a/node_modules/@otplib/preset-default/index.d.ts b/node_modules/@otplib/preset-default/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1dae4265548f6749d050559de147530dce5971c7 --- /dev/null +++ b/node_modules/@otplib/preset-default/index.d.ts @@ -0,0 +1,4 @@ +import { Authenticator, AuthenticatorOptions, HOTP, HOTPOptions, TOTP, TOTPOptions } from '@otplib/core'; +export declare const hotp: HOTP>; +export declare const totp: TOTP>; +export declare const authenticator: Authenticator>; diff --git a/node_modules/@otplib/preset-default/index.js b/node_modules/@otplib/preset-default/index.js new file mode 100644 index 0000000000000000000000000000000000000000..9ff96790f3939c8a2156907a0aebb0dc48e96c6e --- /dev/null +++ b/node_modules/@otplib/preset-default/index.js @@ -0,0 +1,31 @@ +/** + * @otplib/preset-default + * + * @author Gerald Yeo + * @version: 12.0.1 + * @license: MIT + **/ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var pluginCrypto = require('@otplib/plugin-crypto'); +var pluginThirtyTwo = require('@otplib/plugin-thirty-two'); +var core = require('@otplib/core'); + +const hotp = new core.HOTP({ + createDigest: pluginCrypto.createDigest +}); +const totp = new core.TOTP({ + createDigest: pluginCrypto.createDigest +}); +const authenticator = new core.Authenticator({ + createDigest: pluginCrypto.createDigest, + createRandomBytes: pluginCrypto.createRandomBytes, + keyDecoder: pluginThirtyTwo.keyDecoder, + keyEncoder: pluginThirtyTwo.keyEncoder +}); + +exports.authenticator = authenticator; +exports.hotp = hotp; +exports.totp = totp; diff --git a/node_modules/@otplib/preset-default/package.json b/node_modules/@otplib/preset-default/package.json new file mode 100644 index 0000000000000000000000000000000000000000..bfa9fc1c5675f7a87f07cd2e5ecb57921dfcb9f2 --- /dev/null +++ b/node_modules/@otplib/preset-default/package.json @@ -0,0 +1,25 @@ +{ + "name": "@otplib/preset-default", + "description": "basic preset for otplib", + "version": "12.0.1", + "main": "./index.js", + "publishConfig": { + "access": "public" + }, + "scripts": {}, + "keywords": [ + "otplib-preset", + "node" + ], + "dependencies": { + "@otplib/core": "^12.0.1", + "@otplib/plugin-crypto": "^12.0.1", + "@otplib/plugin-thirty-two": "^12.0.1" + }, + "otplib": {}, + "author": "Gerald Yeo ", + "license": "MIT", + "homepage": "https://yeojz.otplib.dev", + "repository": "https://github.com/yeojz/otplib/tree/master/packages/otplib-preset-default", + "types": "./index.d.ts" +} \ No newline at end of file diff --git a/node_modules/@otplib/preset-v11/LICENSE b/node_modules/@otplib/preset-v11/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..506fdcf21878a5f086dca33b24014f67314cc1fd --- /dev/null +++ b/node_modules/@otplib/preset-v11/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Gerald Yeo + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@otplib/preset-v11/README.md b/node_modules/@otplib/preset-v11/README.md new file mode 100644 index 0000000000000000000000000000000000000000..f8f0dee38fc006775bcaf241d3b0f888f8412938 --- /dev/null +++ b/node_modules/@otplib/preset-v11/README.md @@ -0,0 +1,20 @@ +# @otplib/preset-v11 + +> Preset with v11.x compatibility adapter for otplib@v12.x + +See our [project readme][project-v-readme] for more information +or visit the [demo website][project-v-site]. + +## Install + +```bash +npm install --save @otplib/preset-v11 +``` + +## License + +`@otplib/preset-v11` is [MIT licensed][project-license] + +[project-license]: https://github.com/yeojz/otplib/blob/master/LICENSE +[project-v-readme]: https://github.com/yeojz/otplib/blob/master/README.md +[project-v-site]: https://otplib.yeojz.dev diff --git a/node_modules/@otplib/preset-v11/index.d.ts b/node_modules/@otplib/preset-v11/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9a2bf59f68ea714c65b5b54c22e100b9e7ef5940 --- /dev/null +++ b/node_modules/@otplib/preset-v11/index.d.ts @@ -0,0 +1,126 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +interface HmacOptions { + algorithm?: string; + encoding?: string; +} + +type createHmacSecret = (secret: string, options: HmacOptions) => Buffer; + +interface HotpOptionsInterface extends HmacOptions { + createHmacSecret?: createHmacSecret; + crypto?: any; + digits?: number; +} + +interface HotpVerifyOptionsInterface { + token?: string; + secret?: string; + counter?: number; +} + +type hotpCheck = ( + token: string, + secret: string, + counter: number, + options: HotpOptionsInterface +) => boolean; + +type hotpCounter = (counter: number) => string; + +type hotpDigest = ( + secret: string, + counter: number, + options: HotpOptionsInterface +) => string; + +type hotpOptions = (options: any) => HotpOptionsInterface; + +type hotpSecret = createHmacSecret; + +type hotpToken = ( + secret: string, + counter: number, + options: HotpOptionsInterface +) => string; + +interface TotpOptionsInterface extends HotpOptionsInterface { + epoch?: any; + step?: number; + window?: number | number[]; +} + +interface TotpVerifyOptionsInterface { + token?: string; + secret?: string; +} + +type totpCheck = ( + token: string, + secret: string, + options: TotpOptionsInterface +) => boolean; + +type totpCheckWithWindow = ( + token: string, + secret: string, + options: TotpOptionsInterface +) => number | null; + +type totpCounter = (epoch: number, step: number) => number; + +type totpOptions = (options: any) => TotpOptionsInterface; + +type totpSecret = createHmacSecret; + +type totpTimeRemaining = (epoch: number, step: number) => number; + +type totpTimeUsed = (epoch: number, step: number) => number; + +type totpToken = (secret: string, options: TotpOptionsInterface) => string; + +declare class HOTP { + HOTP: typeof HOTP; + getClass(): typeof HOTP; + + defaultOptions: HotpOptionsInterface; + options: HotpOptionsInterface; + optionsAll: HotpOptionsInterface; + resetOptions(): this; + generate(secret: string, counter: number): string; + check(token: string, secret: string, counter: number): boolean; + verify(opts: HotpVerifyOptionsInterface): boolean; +} + +declare class TOTP extends HOTP { + TOTP: typeof TOTP; + getClass(): typeof TOTP; + + defaultOptions: TotpOptionsInterface; + options: TotpOptionsInterface; + optionsAll: TotpOptionsInterface; + generate(secret: string): string; + check(token: string, secret: string): boolean; + checkDelta(token: string, secret: string): number | null; + verify(opts: TotpVerifyOptionsInterface): boolean; + timeUsed(): number; + timeRemaining(): number; +} + +declare class Authenticator extends TOTP { + Authenticator: typeof Authenticator; + getClass(): typeof Authenticator; + + check(token: string, secret: string): boolean; + checkDelta(token: string, secret: string): number | null; + decode(encodedKey: string): string; + encode(secret: string): string; + generate(secret: string): string; + generateSecret(len?: number): string; + keyuri(user: string, service: string, secret: string): string; +} + +declare module '@otplib/preset-v11' { + const authenticator: Authenticator; + const hotp: HOTP; + const totp: TOTP; +} diff --git a/node_modules/@otplib/preset-v11/index.js b/node_modules/@otplib/preset-v11/index.js new file mode 100644 index 0000000000000000000000000000000000000000..974281b16910dab4146368e752dbce3d6a220683 --- /dev/null +++ b/node_modules/@otplib/preset-v11/index.js @@ -0,0 +1,133 @@ +/** + * @otplib/preset-v11 + * + * @author Gerald Yeo + * @version: 12.0.1 + * @license: MIT + **/ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var pluginCrypto = require('@otplib/plugin-crypto'); +var pluginThirtyTwo = require('@otplib/plugin-thirty-two'); +var core = require('@otplib/core'); + +function epochUnixToJS(opt = {}) { + if (!opt || typeof opt !== 'object') { + return {}; + } + const { + epoch, + ...others + } = opt; + if (epoch === null) { + return others; + } + if (typeof epoch === 'number') { + return { ...opt, + epoch: opt.epoch * 1000 + }; + } + return opt; +} +function epochJSToUnix(opt = {}) { + if (!opt || typeof opt !== 'object') { + return {}; + } + const { + epoch, + ...others + } = opt; + if (epoch === null) { + return others; + } + if (typeof epoch === 'number') { + return { ...opt, + epoch: epoch / 1000 + }; + } + return opt; +} +function createV11(Base, legacyOptions) { + class Legacy extends Base { + constructor(defaultOptions = {}) { + super(epochUnixToJS({ ...legacyOptions, + ...defaultOptions + })); + console.warn(Base.name, 'initialised with v11.x adapter'); + } + static get name() { + return Base.name; + } + set options(opt = {}) { + console.warn(Base.name, '.options setter will remove UNIX epoch if it is set to null.' + '\n Do note that library versions above v11.x uses JavaScript epoch.'); + super.options = epochUnixToJS(opt); + } + get options() { + console.warn(Base.name, '.options getter will remove epoch if it is set to null' + '\n Do note that library versions above v11.x uses JavaScript epoch.'); + return epochJSToUnix(super.options); + } + get defaultOptions() { + console.warn(Base.name, '.defaultOptions getter has been deprecated in favour of the .options getter' + '\n\n The .options getter now returns the combined defaultOptions and options values' + 'instead of setting options when adding defaultOptions.'); + return Object.freeze(epochJSToUnix(this._defaultOptions)); + } + set defaultOptions(opt) { + console.warn(Base.name, '.defaultOptions setter has been deprecated in favour of the .clone(defaultOptions) method'); + this._defaultOptions = Object.freeze({ ...this._defaultOptions, + ...epochUnixToJS(opt) + }); + } + get optionsAll() { + console.warn(Base.name, '.optionsAll getter has been deprecated in favour of the .allOptions() method.' + '\n That epoch returned here will be in Unix Epoch, while .allOptions()' + ' will return JavaScript epoch.' + '\n Do note that library versions above v11.x uses JavaScript epoch.'); + return epochJSToUnix(this.allOptions()); + } + allOptions() { + return epochUnixToJS(super.allOptions()); + } + getClass() { + return Legacy; + } + verify(opts) { + if (!opts || typeof opts !== 'object') { + return false; + } + try { + return super.verify(opts); + } catch (err) { + return false; + } + } + } + Legacy.prototype[Base.name] = Legacy; + return Legacy; +} +const HOTP = createV11(core.HOTP, {}); +const TOTP = createV11(core.TOTP, { + epoch: null, + step: 30, + window: 0 +}); +const Authenticator = createV11(core.Authenticator, { + encoding: 'hex', + epoch: null, + step: 30, + window: 0 +}); + +const hotp = new HOTP({ + createDigest: pluginCrypto.createDigest +}); +const totp = new TOTP({ + createDigest: pluginCrypto.createDigest +}); +const authenticator = new Authenticator({ + createDigest: pluginCrypto.createDigest, + createRandomBytes: pluginCrypto.createRandomBytes, + keyEncoder: pluginThirtyTwo.keyEncoder, + keyDecoder: pluginThirtyTwo.keyDecoder +}); + +exports.authenticator = authenticator; +exports.hotp = hotp; +exports.totp = totp; diff --git a/node_modules/@otplib/preset-v11/package.json b/node_modules/@otplib/preset-v11/package.json new file mode 100644 index 0000000000000000000000000000000000000000..3e79d62d96af5d9dc61a8a4b42840c3d2aff1951 --- /dev/null +++ b/node_modules/@otplib/preset-v11/package.json @@ -0,0 +1,25 @@ +{ + "name": "@otplib/preset-v11", + "description": "v11.x compatible interface preset for otplib", + "version": "12.0.1", + "main": "./index.js", + "publishConfig": { + "access": "public" + }, + "scripts": {}, + "keywords": [ + "otplib-preset", + "node" + ], + "dependencies": { + "@otplib/core": "^12.0.1", + "@otplib/plugin-crypto": "^12.0.1", + "@otplib/plugin-thirty-two": "^12.0.1" + }, + "otplib": {}, + "author": "Gerald Yeo ", + "license": "MIT", + "homepage": "https://yeojz.otplib.dev", + "repository": "https://github.com/yeojz/otplib/tree/master/packages/otplib-preset-v11", + "types": "./index.d.ts" +} \ No newline at end of file diff --git a/node_modules/@oxc-project/types/LICENSE b/node_modules/@oxc-project/types/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..444bffc00e5190817c0092e5e6fde787102977d2 --- /dev/null +++ b/node_modules/@oxc-project/types/LICENSE @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2024-present VoidZero Inc. & Contributors +Copyright (c) 2023 Boshen + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@oxc-project/types/README.md b/node_modules/@oxc-project/types/README.md new file mode 100644 index 0000000000000000000000000000000000000000..d5b248ac3fc1e8673b6fc55bda1c04e9a0464d02 --- /dev/null +++ b/node_modules/@oxc-project/types/README.md @@ -0,0 +1,3 @@ +# Oxc Types + +Typescript definitions for Oxc AST nodes. diff --git a/node_modules/@oxc-project/types/package.json b/node_modules/@oxc-project/types/package.json new file mode 100644 index 0000000000000000000000000000000000000000..e7f33b1554f4ac0e16ed01c555c02d2dbe87a5ec --- /dev/null +++ b/node_modules/@oxc-project/types/package.json @@ -0,0 +1,26 @@ +{ + "name": "@oxc-project/types", + "version": "0.133.0", + "description": "Types for Oxc AST nodes", + "keywords": [ + "AST", + "Parser" + ], + "homepage": "https://oxc.rs", + "bugs": "https://github.com/oxc-project/oxc/issues", + "license": "MIT", + "author": "Boshen and oxc contributors", + "repository": { + "type": "git", + "url": "git+https://github.com/oxc-project/oxc.git", + "directory": "npm/oxc-types" + }, + "funding": { + "url": "https://github.com/sponsors/Boshen" + }, + "files": [ + "types.d.ts" + ], + "type": "module", + "types": "types.d.ts" +} \ No newline at end of file diff --git a/node_modules/@oxc-project/types/types.d.ts b/node_modules/@oxc-project/types/types.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c94c1159e6302de98254582d9f3aeea5514bdd71 --- /dev/null +++ b/node_modules/@oxc-project/types/types.d.ts @@ -0,0 +1,1912 @@ +// Auto-generated code, DO NOT EDIT DIRECTLY! +// To edit this generated file you have to edit `tasks/ast_tools/src/generators/typescript.rs`. + +export interface Program extends Span { + type: "Program"; + body: Array; + sourceType: ModuleKind; + hashbang: Hashbang | null; + parent?: null; +} + +export type Expression = + | BooleanLiteral + | NullLiteral + | NumericLiteral + | BigIntLiteral + | RegExpLiteral + | StringLiteral + | TemplateLiteral + | IdentifierReference + | MetaProperty + | Super + | ArrayExpression + | ArrowFunctionExpression + | AssignmentExpression + | AwaitExpression + | BinaryExpression + | CallExpression + | ChainExpression + | Class + | ConditionalExpression + | Function + | ImportExpression + | LogicalExpression + | NewExpression + | ObjectExpression + | ParenthesizedExpression + | SequenceExpression + | TaggedTemplateExpression + | ThisExpression + | UnaryExpression + | UpdateExpression + | YieldExpression + | PrivateInExpression + | JSXElement + | JSXFragment + | TSAsExpression + | TSSatisfiesExpression + | TSTypeAssertion + | TSNonNullExpression + | TSInstantiationExpression + | V8IntrinsicExpression + | MemberExpression; + +export interface IdentifierName extends Span { + type: "Identifier"; + decorators?: []; + name: string; + optional?: false; + typeAnnotation?: null; + parent?: Node; +} + +export interface IdentifierReference extends Span { + type: "Identifier"; + decorators?: []; + name: string; + optional?: false; + typeAnnotation?: null; + parent?: Node; +} + +export interface BindingIdentifier extends Span { + type: "Identifier"; + decorators?: []; + name: string; + optional?: false; + typeAnnotation?: null; + parent?: Node; +} + +export interface LabelIdentifier extends Span { + type: "Identifier"; + decorators?: []; + name: string; + optional?: false; + typeAnnotation?: null; + parent?: Node; +} + +export interface ThisExpression extends Span { + type: "ThisExpression"; + parent?: Node; +} + +export interface ArrayExpression extends Span { + type: "ArrayExpression"; + elements: Array; + parent?: Node; +} + +export type ArrayExpressionElement = SpreadElement | null | Expression; + +export interface ObjectExpression extends Span { + type: "ObjectExpression"; + properties: Array; + parent?: Node; +} + +export type ObjectPropertyKind = ObjectProperty | SpreadElement; + +export interface ObjectProperty extends Span { + type: "Property"; + kind: PropertyKind; + key: PropertyKey; + value: Expression; + method: boolean; + shorthand: boolean; + computed: boolean; + optional?: false; + parent?: Node; +} + +export type PropertyKey = IdentifierName | PrivateIdentifier | Expression; + +export type PropertyKind = "init" | "get" | "set"; + +export interface TemplateLiteral extends Span { + type: "TemplateLiteral"; + quasis: Array; + expressions: Array; + parent?: Node; +} + +export interface TaggedTemplateExpression extends Span { + type: "TaggedTemplateExpression"; + tag: Expression; + typeArguments?: TSTypeParameterInstantiation | null; + quasi: TemplateLiteral; + parent?: Node; +} + +export interface TemplateElement extends Span { + type: "TemplateElement"; + value: TemplateElementValue; + tail: boolean; + parent?: Node; +} + +export interface TemplateElementValue { + raw: string; + cooked: string | null; +} + +export type MemberExpression = + | ComputedMemberExpression + | StaticMemberExpression + | PrivateFieldExpression; + +export interface ComputedMemberExpression extends Span { + type: "MemberExpression"; + object: Expression; + property: Expression; + optional: boolean; + computed: true; + parent?: Node; +} + +export interface StaticMemberExpression extends Span { + type: "MemberExpression"; + object: Expression; + property: IdentifierName; + optional: boolean; + computed: false; + parent?: Node; +} + +export interface PrivateFieldExpression extends Span { + type: "MemberExpression"; + object: Expression; + property: PrivateIdentifier; + optional: boolean; + computed: false; + parent?: Node; +} + +export interface CallExpression extends Span { + type: "CallExpression"; + callee: Expression; + typeArguments?: TSTypeParameterInstantiation | null; + arguments: Array; + optional: boolean; + parent?: Node; +} + +export interface NewExpression extends Span { + type: "NewExpression"; + callee: Expression; + typeArguments?: TSTypeParameterInstantiation | null; + arguments: Array; + parent?: Node; +} + +export interface MetaProperty extends Span { + type: "MetaProperty"; + meta: IdentifierName; + property: IdentifierName; + parent?: Node; +} + +export interface SpreadElement extends Span { + type: "SpreadElement"; + argument: Expression; + parent?: Node; +} + +export type Argument = SpreadElement | Expression; + +export interface UpdateExpression extends Span { + type: "UpdateExpression"; + operator: UpdateOperator; + prefix: boolean; + argument: SimpleAssignmentTarget; + parent?: Node; +} + +export interface UnaryExpression extends Span { + type: "UnaryExpression"; + operator: UnaryOperator; + argument: Expression; + prefix: true; + parent?: Node; +} + +export interface BinaryExpression extends Span { + type: "BinaryExpression"; + left: Expression; + operator: BinaryOperator; + right: Expression; + parent?: Node; +} + +export interface PrivateInExpression extends Span { + type: "BinaryExpression"; + left: PrivateIdentifier; + operator: "in"; + right: Expression; + parent?: Node; +} + +export interface LogicalExpression extends Span { + type: "LogicalExpression"; + left: Expression; + operator: LogicalOperator; + right: Expression; + parent?: Node; +} + +export interface ConditionalExpression extends Span { + type: "ConditionalExpression"; + test: Expression; + consequent: Expression; + alternate: Expression; + parent?: Node; +} + +export interface AssignmentExpression extends Span { + type: "AssignmentExpression"; + operator: AssignmentOperator; + left: AssignmentTarget; + right: Expression; + parent?: Node; +} + +export type AssignmentTarget = SimpleAssignmentTarget | AssignmentTargetPattern; + +export type SimpleAssignmentTarget = + | IdentifierReference + | TSAsExpression + | TSSatisfiesExpression + | TSNonNullExpression + | TSTypeAssertion + | MemberExpression; + +export type AssignmentTargetPattern = ArrayAssignmentTarget | ObjectAssignmentTarget; + +export interface ArrayAssignmentTarget extends Span { + type: "ArrayPattern"; + decorators?: []; + elements: Array; + optional?: false; + typeAnnotation?: null; + parent?: Node; +} + +export interface ObjectAssignmentTarget extends Span { + type: "ObjectPattern"; + decorators?: []; + properties: Array; + optional?: false; + typeAnnotation?: null; + parent?: Node; +} + +export interface AssignmentTargetRest extends Span { + type: "RestElement"; + decorators?: []; + argument: AssignmentTarget; + optional?: false; + typeAnnotation?: null; + value?: null; + parent?: Node; +} + +export type AssignmentTargetMaybeDefault = AssignmentTargetWithDefault | AssignmentTarget; + +export interface AssignmentTargetWithDefault extends Span { + type: "AssignmentPattern"; + decorators?: []; + left: AssignmentTarget; + right: Expression; + optional?: false; + typeAnnotation?: null; + parent?: Node; +} + +export type AssignmentTargetProperty = + | AssignmentTargetPropertyIdentifier + | AssignmentTargetPropertyProperty; + +export interface AssignmentTargetPropertyIdentifier extends Span { + type: "Property"; + kind: "init"; + key: IdentifierReference; + value: IdentifierReference | AssignmentTargetWithDefault; + method: false; + shorthand: true; + computed: false; + optional?: false; + parent?: Node; +} + +export interface AssignmentTargetPropertyProperty extends Span { + type: "Property"; + kind: "init"; + key: PropertyKey; + value: AssignmentTargetMaybeDefault; + method: false; + shorthand: false; + computed: boolean; + optional?: false; + parent?: Node; +} + +export interface SequenceExpression extends Span { + type: "SequenceExpression"; + expressions: Array; + parent?: Node; +} + +export interface Super extends Span { + type: "Super"; + parent?: Node; +} + +export interface AwaitExpression extends Span { + type: "AwaitExpression"; + argument: Expression; + parent?: Node; +} + +export interface ChainExpression extends Span { + type: "ChainExpression"; + expression: ChainElement; + parent?: Node; +} + +export type ChainElement = CallExpression | TSNonNullExpression | MemberExpression; + +export interface ParenthesizedExpression extends Span { + type: "ParenthesizedExpression"; + expression: Expression; + parent?: Node; +} + +export type Statement = + | BlockStatement + | BreakStatement + | ContinueStatement + | DebuggerStatement + | DoWhileStatement + | EmptyStatement + | ExpressionStatement + | ForInStatement + | ForOfStatement + | ForStatement + | IfStatement + | LabeledStatement + | ReturnStatement + | SwitchStatement + | ThrowStatement + | TryStatement + | WhileStatement + | WithStatement + | Declaration + | ModuleDeclaration; + +export interface Directive extends Span { + type: "ExpressionStatement"; + expression: StringLiteral; + directive: string; + parent?: Node; +} + +export interface Hashbang extends Span { + type: "Hashbang"; + value: string; + parent?: Node; +} + +export interface BlockStatement extends Span { + type: "BlockStatement"; + body: Array; + parent?: Node; +} + +export type Declaration = + | VariableDeclaration + | Function + | Class + | TSTypeAliasDeclaration + | TSInterfaceDeclaration + | TSEnumDeclaration + | TSModuleDeclaration + | TSGlobalDeclaration + | TSImportEqualsDeclaration; + +export interface VariableDeclaration extends Span { + type: "VariableDeclaration"; + kind: VariableDeclarationKind; + declarations: Array; + declare?: boolean; + parent?: Node; +} + +export type VariableDeclarationKind = "var" | "let" | "const" | "using" | "await using"; + +export interface VariableDeclarator extends Span { + type: "VariableDeclarator"; + id: BindingPattern; + init: Expression | null; + definite?: boolean; + parent?: Node; +} + +export interface EmptyStatement extends Span { + type: "EmptyStatement"; + parent?: Node; +} + +export interface ExpressionStatement extends Span { + type: "ExpressionStatement"; + expression: Expression; + directive?: string | null; + parent?: Node; +} + +export interface IfStatement extends Span { + type: "IfStatement"; + test: Expression; + consequent: Statement; + alternate: Statement | null; + parent?: Node; +} + +export interface DoWhileStatement extends Span { + type: "DoWhileStatement"; + body: Statement; + test: Expression; + parent?: Node; +} + +export interface WhileStatement extends Span { + type: "WhileStatement"; + test: Expression; + body: Statement; + parent?: Node; +} + +export interface ForStatement extends Span { + type: "ForStatement"; + init: ForStatementInit | null; + test: Expression | null; + update: Expression | null; + body: Statement; + parent?: Node; +} + +export type ForStatementInit = VariableDeclaration | Expression; + +export interface ForInStatement extends Span { + type: "ForInStatement"; + left: ForStatementLeft; + right: Expression; + body: Statement; + parent?: Node; +} + +export type ForStatementLeft = VariableDeclaration | AssignmentTarget; + +export interface ForOfStatement extends Span { + type: "ForOfStatement"; + await: boolean; + left: ForStatementLeft; + right: Expression; + body: Statement; + parent?: Node; +} + +export interface ContinueStatement extends Span { + type: "ContinueStatement"; + label: LabelIdentifier | null; + parent?: Node; +} + +export interface BreakStatement extends Span { + type: "BreakStatement"; + label: LabelIdentifier | null; + parent?: Node; +} + +export interface ReturnStatement extends Span { + type: "ReturnStatement"; + argument: Expression | null; + parent?: Node; +} + +export interface WithStatement extends Span { + type: "WithStatement"; + object: Expression; + body: Statement; + parent?: Node; +} + +export interface SwitchStatement extends Span { + type: "SwitchStatement"; + discriminant: Expression; + cases: Array; + parent?: Node; +} + +export interface SwitchCase extends Span { + type: "SwitchCase"; + test: Expression | null; + consequent: Array; + parent?: Node; +} + +export interface LabeledStatement extends Span { + type: "LabeledStatement"; + label: LabelIdentifier; + body: Statement; + parent?: Node; +} + +export interface ThrowStatement extends Span { + type: "ThrowStatement"; + argument: Expression; + parent?: Node; +} + +export interface TryStatement extends Span { + type: "TryStatement"; + block: BlockStatement; + handler: CatchClause | null; + finalizer: BlockStatement | null; + parent?: Node; +} + +export interface CatchClause extends Span { + type: "CatchClause"; + param: BindingPattern | null; + body: BlockStatement; + parent?: Node; +} + +export interface DebuggerStatement extends Span { + type: "DebuggerStatement"; + parent?: Node; +} + +export type BindingPattern = BindingIdentifier | ObjectPattern | ArrayPattern | AssignmentPattern; + +export interface AssignmentPattern extends Span { + type: "AssignmentPattern"; + decorators?: []; + left: BindingPattern; + right: Expression; + optional?: false; + typeAnnotation?: null; + parent?: Node; +} + +export interface ObjectPattern extends Span { + type: "ObjectPattern"; + decorators?: []; + properties: Array; + optional?: false; + typeAnnotation?: null; + parent?: Node; +} + +export interface BindingProperty extends Span { + type: "Property"; + kind: "init"; + key: PropertyKey; + value: BindingPattern; + method: false; + shorthand: boolean; + computed: boolean; + optional?: false; + parent?: Node; +} + +export interface ArrayPattern extends Span { + type: "ArrayPattern"; + decorators?: []; + elements: Array; + optional?: false; + typeAnnotation?: null; + parent?: Node; +} + +export interface BindingRestElement extends Span { + type: "RestElement"; + decorators?: []; + argument: BindingPattern; + optional?: false; + typeAnnotation?: null; + value?: null; + parent?: Node; +} + +export interface Function extends Span { + type: FunctionType; + id: BindingIdentifier | null; + generator: boolean; + async: boolean; + declare?: boolean; + typeParameters?: TSTypeParameterDeclaration | null; + params: ParamPattern[]; + returnType?: TSTypeAnnotation | null; + body: FunctionBody | null; + expression: false; + parent?: Node; +} + +export type ParamPattern = FormalParameter | TSParameterProperty | FormalParameterRest; + +export type FunctionType = + | "FunctionDeclaration" + | "FunctionExpression" + | "TSDeclareFunction" + | "TSEmptyBodyFunctionExpression"; + +export interface FormalParameterRest extends Span { + type: "RestElement"; + argument: BindingPattern; + decorators?: []; + optional?: boolean; + typeAnnotation?: TSTypeAnnotation | null; + value?: null; + parent?: Node; +} + +export type FormalParameter = { + decorators?: Array; +} & BindingPattern; + +export interface TSParameterProperty extends Span { + type: "TSParameterProperty"; + accessibility: TSAccessibility | null; + decorators: Array; + override: boolean; + parameter: FormalParameter; + readonly: boolean; + static: boolean; + parent?: Node; +} + +export interface FunctionBody extends Span { + type: "BlockStatement"; + body: Array; + parent?: Node; +} + +export interface ArrowFunctionExpression extends Span { + type: "ArrowFunctionExpression"; + expression: boolean; + async: boolean; + typeParameters?: TSTypeParameterDeclaration | null; + params: ParamPattern[]; + returnType?: TSTypeAnnotation | null; + body: FunctionBody | Expression; + id: null; + generator: false; + parent?: Node; +} + +export interface YieldExpression extends Span { + type: "YieldExpression"; + delegate: boolean; + argument: Expression | null; + parent?: Node; +} + +export interface Class extends Span { + type: ClassType; + decorators: Array; + id: BindingIdentifier | null; + typeParameters?: TSTypeParameterDeclaration | null; + superClass: Expression | null; + superTypeArguments?: TSTypeParameterInstantiation | null; + implements?: Array; + body: ClassBody; + abstract?: boolean; + declare?: boolean; + parent?: Node; +} + +export type ClassType = "ClassDeclaration" | "ClassExpression"; + +export interface ClassBody extends Span { + type: "ClassBody"; + body: Array; + parent?: Node; +} + +export type ClassElement = + | StaticBlock + | MethodDefinition + | PropertyDefinition + | AccessorProperty + | TSIndexSignature; + +export interface MethodDefinition extends Span { + type: MethodDefinitionType; + decorators: Array; + key: PropertyKey; + value: Function; + kind: MethodDefinitionKind; + computed: boolean; + static: boolean; + override?: boolean; + optional?: boolean; + accessibility?: TSAccessibility | null; + parent?: Node; +} + +export type MethodDefinitionType = "MethodDefinition" | "TSAbstractMethodDefinition"; + +export interface PropertyDefinition extends Span { + type: PropertyDefinitionType; + decorators: Array; + key: PropertyKey; + typeAnnotation?: TSTypeAnnotation | null; + value: Expression | null; + computed: boolean; + static: boolean; + declare?: boolean; + override?: boolean; + optional?: boolean; + definite?: boolean; + readonly?: boolean; + accessibility?: TSAccessibility | null; + parent?: Node; +} + +export type PropertyDefinitionType = "PropertyDefinition" | "TSAbstractPropertyDefinition"; + +export type MethodDefinitionKind = "constructor" | "method" | "get" | "set"; + +export interface PrivateIdentifier extends Span { + type: "PrivateIdentifier"; + name: string; + parent?: Node; +} + +export interface StaticBlock extends Span { + type: "StaticBlock"; + body: Array; + parent?: Node; +} + +export type ModuleDeclaration = + | ImportDeclaration + | ExportAllDeclaration + | ExportDefaultDeclaration + | ExportNamedDeclaration + | TSExportAssignment + | TSNamespaceExportDeclaration; + +export type AccessorPropertyType = "AccessorProperty" | "TSAbstractAccessorProperty"; + +export interface AccessorProperty extends Span { + type: AccessorPropertyType; + decorators: Array; + key: PropertyKey; + typeAnnotation?: TSTypeAnnotation | null; + value: Expression | null; + computed: boolean; + static: boolean; + override?: boolean; + definite?: boolean; + accessibility?: TSAccessibility | null; + declare?: false; + optional?: false; + readonly?: false; + parent?: Node; +} + +export interface ImportExpression extends Span { + type: "ImportExpression"; + source: Expression; + options: Expression | null; + phase: ImportPhase | null; + parent?: Node; +} + +export interface ImportDeclaration extends Span { + type: "ImportDeclaration"; + specifiers: Array; + source: StringLiteral; + phase: ImportPhase | null; + attributes: Array; + importKind?: ImportOrExportKind; + parent?: Node; +} + +export type ImportPhase = "source" | "defer"; + +export type ImportDeclarationSpecifier = + | ImportSpecifier + | ImportDefaultSpecifier + | ImportNamespaceSpecifier; + +export interface ImportSpecifier extends Span { + type: "ImportSpecifier"; + imported: ModuleExportName; + local: BindingIdentifier; + importKind?: ImportOrExportKind; + parent?: Node; +} + +export interface ImportDefaultSpecifier extends Span { + type: "ImportDefaultSpecifier"; + local: BindingIdentifier; + parent?: Node; +} + +export interface ImportNamespaceSpecifier extends Span { + type: "ImportNamespaceSpecifier"; + local: BindingIdentifier; + parent?: Node; +} + +export interface ImportAttribute extends Span { + type: "ImportAttribute"; + key: ImportAttributeKey; + value: StringLiteral; + parent?: Node; +} + +export type ImportAttributeKey = IdentifierName | StringLiteral; + +export interface ExportNamedDeclaration extends Span { + type: "ExportNamedDeclaration"; + declaration: Declaration | null; + specifiers: Array; + source: StringLiteral | null; + exportKind?: ImportOrExportKind; + attributes: Array; + parent?: Node; +} + +export interface ExportDefaultDeclaration extends Span { + type: "ExportDefaultDeclaration"; + declaration: ExportDefaultDeclarationKind; + exportKind?: "value"; + parent?: Node; +} + +export interface ExportAllDeclaration extends Span { + type: "ExportAllDeclaration"; + exported: ModuleExportName | null; + source: StringLiteral; + attributes: Array; + exportKind?: ImportOrExportKind; + parent?: Node; +} + +export interface ExportSpecifier extends Span { + type: "ExportSpecifier"; + local: ModuleExportName; + exported: ModuleExportName; + exportKind?: ImportOrExportKind; + parent?: Node; +} + +export type ExportDefaultDeclarationKind = Function | Class | TSInterfaceDeclaration | Expression; + +export type ModuleExportName = IdentifierName | IdentifierReference | StringLiteral; + +export interface V8IntrinsicExpression extends Span { + type: "V8IntrinsicExpression"; + name: IdentifierName; + arguments: Array; + parent?: Node; +} + +export interface BooleanLiteral extends Span { + type: "Literal"; + value: boolean; + raw: string | null; + parent?: Node; +} + +export interface NullLiteral extends Span { + type: "Literal"; + value: null; + raw: "null" | null; + parent?: Node; +} + +export interface NumericLiteral extends Span { + type: "Literal"; + value: number; + raw: string | null; + parent?: Node; +} + +export interface StringLiteral extends Span { + type: "Literal"; + value: string; + raw: string | null; + parent?: Node; +} + +export interface BigIntLiteral extends Span { + type: "Literal"; + value: bigint; + raw: string | null; + bigint: string; + parent?: Node; +} + +export interface RegExpLiteral extends Span { + type: "Literal"; + value: RegExp | null; + raw: string | null; + regex: { pattern: string; flags: string }; + parent?: Node; +} + +export interface JSXElement extends Span { + type: "JSXElement"; + openingElement: JSXOpeningElement; + children: Array; + closingElement: JSXClosingElement | null; + parent?: Node; +} + +export interface JSXOpeningElement extends Span { + type: "JSXOpeningElement"; + name: JSXElementName; + typeArguments?: TSTypeParameterInstantiation | null; + attributes: Array; + selfClosing: boolean; + parent?: Node; +} + +export interface JSXClosingElement extends Span { + type: "JSXClosingElement"; + name: JSXElementName; + parent?: Node; +} + +export interface JSXFragment extends Span { + type: "JSXFragment"; + openingFragment: JSXOpeningFragment; + children: Array; + closingFragment: JSXClosingFragment; + parent?: Node; +} + +export interface JSXOpeningFragment extends Span { + type: "JSXOpeningFragment"; + attributes?: []; + selfClosing?: false; + parent?: Node; +} + +export interface JSXClosingFragment extends Span { + type: "JSXClosingFragment"; + parent?: Node; +} + +export type JSXElementName = JSXIdentifier | JSXNamespacedName | JSXMemberExpression; + +export interface JSXNamespacedName extends Span { + type: "JSXNamespacedName"; + namespace: JSXIdentifier; + name: JSXIdentifier; + parent?: Node; +} + +export interface JSXMemberExpression extends Span { + type: "JSXMemberExpression"; + object: JSXMemberExpressionObject; + property: JSXIdentifier; + parent?: Node; +} + +export type JSXMemberExpressionObject = JSXIdentifier | JSXMemberExpression; + +export interface JSXExpressionContainer extends Span { + type: "JSXExpressionContainer"; + expression: JSXExpression; + parent?: Node; +} + +export type JSXExpression = JSXEmptyExpression | Expression; + +export interface JSXEmptyExpression extends Span { + type: "JSXEmptyExpression"; + parent?: Node; +} + +export type JSXAttributeItem = JSXAttribute | JSXSpreadAttribute; + +export interface JSXAttribute extends Span { + type: "JSXAttribute"; + name: JSXAttributeName; + value: JSXAttributeValue | null; + parent?: Node; +} + +export interface JSXSpreadAttribute extends Span { + type: "JSXSpreadAttribute"; + argument: Expression; + parent?: Node; +} + +export type JSXAttributeName = JSXIdentifier | JSXNamespacedName; + +export type JSXAttributeValue = StringLiteral | JSXExpressionContainer | JSXElement | JSXFragment; + +export interface JSXIdentifier extends Span { + type: "JSXIdentifier"; + name: string; + parent?: Node; +} + +export type JSXChild = JSXText | JSXElement | JSXFragment | JSXExpressionContainer | JSXSpreadChild; + +export interface JSXSpreadChild extends Span { + type: "JSXSpreadChild"; + expression: Expression; + parent?: Node; +} + +export interface JSXText extends Span { + type: "JSXText"; + value: string; + raw: string | null; + parent?: Node; +} + +export interface TSThisParameter extends Span { + type: "Identifier"; + decorators: []; + name: "this"; + optional: false; + typeAnnotation: TSTypeAnnotation | null; + parent?: Node; +} + +export interface TSEnumDeclaration extends Span { + type: "TSEnumDeclaration"; + id: BindingIdentifier; + body: TSEnumBody; + const: boolean; + declare: boolean; + parent?: Node; +} + +export interface TSEnumBody extends Span { + type: "TSEnumBody"; + members: Array; + parent?: Node; +} + +export interface TSEnumMember extends Span { + type: "TSEnumMember"; + id: TSEnumMemberName; + initializer: Expression | null; + computed: boolean; + parent?: Node; +} + +export type TSEnumMemberName = IdentifierName | StringLiteral | TemplateLiteral; + +export interface TSTypeAnnotation extends Span { + type: "TSTypeAnnotation"; + typeAnnotation: TSType; + parent?: Node; +} + +export interface TSLiteralType extends Span { + type: "TSLiteralType"; + literal: TSLiteral; + parent?: Node; +} + +export type TSLiteral = + | BooleanLiteral + | NumericLiteral + | BigIntLiteral + | StringLiteral + | TemplateLiteral + | UnaryExpression; + +export type TSType = + | TSAnyKeyword + | TSBigIntKeyword + | TSBooleanKeyword + | TSIntrinsicKeyword + | TSNeverKeyword + | TSNullKeyword + | TSNumberKeyword + | TSObjectKeyword + | TSStringKeyword + | TSSymbolKeyword + | TSUndefinedKeyword + | TSUnknownKeyword + | TSVoidKeyword + | TSArrayType + | TSConditionalType + | TSConstructorType + | TSFunctionType + | TSImportType + | TSIndexedAccessType + | TSInferType + | TSIntersectionType + | TSLiteralType + | TSMappedType + | TSNamedTupleMember + | TSTemplateLiteralType + | TSThisType + | TSTupleType + | TSTypeLiteral + | TSTypeOperator + | TSTypePredicate + | TSTypeQuery + | TSTypeReference + | TSUnionType + | TSParenthesizedType + | JSDocNullableType + | JSDocNonNullableType + | JSDocUnknownType; + +export interface TSConditionalType extends Span { + type: "TSConditionalType"; + checkType: TSType; + extendsType: TSType; + trueType: TSType; + falseType: TSType; + parent?: Node; +} + +export interface TSUnionType extends Span { + type: "TSUnionType"; + types: Array; + parent?: Node; +} + +export interface TSIntersectionType extends Span { + type: "TSIntersectionType"; + types: Array; + parent?: Node; +} + +export interface TSParenthesizedType extends Span { + type: "TSParenthesizedType"; + typeAnnotation: TSType; + parent?: Node; +} + +export interface TSTypeOperator extends Span { + type: "TSTypeOperator"; + operator: TSTypeOperatorOperator; + typeAnnotation: TSType; + parent?: Node; +} + +export type TSTypeOperatorOperator = "keyof" | "unique" | "readonly"; + +export interface TSArrayType extends Span { + type: "TSArrayType"; + elementType: TSType; + parent?: Node; +} + +export interface TSIndexedAccessType extends Span { + type: "TSIndexedAccessType"; + objectType: TSType; + indexType: TSType; + parent?: Node; +} + +export interface TSTupleType extends Span { + type: "TSTupleType"; + elementTypes: Array; + parent?: Node; +} + +export interface TSNamedTupleMember extends Span { + type: "TSNamedTupleMember"; + label: IdentifierName; + elementType: TSTupleElement; + optional: boolean; + parent?: Node; +} + +export interface TSOptionalType extends Span { + type: "TSOptionalType"; + typeAnnotation: TSType; + parent?: Node; +} + +export interface TSRestType extends Span { + type: "TSRestType"; + typeAnnotation: TSType; + parent?: Node; +} + +export type TSTupleElement = TSOptionalType | TSRestType | TSType; + +export interface TSAnyKeyword extends Span { + type: "TSAnyKeyword"; + parent?: Node; +} + +export interface TSStringKeyword extends Span { + type: "TSStringKeyword"; + parent?: Node; +} + +export interface TSBooleanKeyword extends Span { + type: "TSBooleanKeyword"; + parent?: Node; +} + +export interface TSNumberKeyword extends Span { + type: "TSNumberKeyword"; + parent?: Node; +} + +export interface TSNeverKeyword extends Span { + type: "TSNeverKeyword"; + parent?: Node; +} + +export interface TSIntrinsicKeyword extends Span { + type: "TSIntrinsicKeyword"; + parent?: Node; +} + +export interface TSUnknownKeyword extends Span { + type: "TSUnknownKeyword"; + parent?: Node; +} + +export interface TSNullKeyword extends Span { + type: "TSNullKeyword"; + parent?: Node; +} + +export interface TSUndefinedKeyword extends Span { + type: "TSUndefinedKeyword"; + parent?: Node; +} + +export interface TSVoidKeyword extends Span { + type: "TSVoidKeyword"; + parent?: Node; +} + +export interface TSSymbolKeyword extends Span { + type: "TSSymbolKeyword"; + parent?: Node; +} + +export interface TSThisType extends Span { + type: "TSThisType"; + parent?: Node; +} + +export interface TSObjectKeyword extends Span { + type: "TSObjectKeyword"; + parent?: Node; +} + +export interface TSBigIntKeyword extends Span { + type: "TSBigIntKeyword"; + parent?: Node; +} + +export interface TSTypeReference extends Span { + type: "TSTypeReference"; + typeName: TSTypeName; + typeArguments: TSTypeParameterInstantiation | null; + parent?: Node; +} + +export type TSTypeName = IdentifierReference | TSQualifiedName | ThisExpression; + +export interface TSQualifiedName extends Span { + type: "TSQualifiedName"; + left: TSTypeName; + right: IdentifierName; + parent?: Node; +} + +export interface TSTypeParameterInstantiation extends Span { + type: "TSTypeParameterInstantiation"; + params: Array; + parent?: Node; +} + +export interface TSTypeParameter extends Span { + type: "TSTypeParameter"; + name: BindingIdentifier; + constraint: TSType | null; + default: TSType | null; + in: boolean; + out: boolean; + const: boolean; + parent?: Node; +} + +export interface TSTypeParameterDeclaration extends Span { + type: "TSTypeParameterDeclaration"; + params: Array; + parent?: Node; +} + +export interface TSTypeAliasDeclaration extends Span { + type: "TSTypeAliasDeclaration"; + id: BindingIdentifier; + typeParameters: TSTypeParameterDeclaration | null; + typeAnnotation: TSType; + declare: boolean; + parent?: Node; +} + +export type TSAccessibility = "private" | "protected" | "public"; + +export interface TSClassImplements extends Span { + type: "TSClassImplements"; + expression: IdentifierReference | ThisExpression | MemberExpression; + typeArguments: TSTypeParameterInstantiation | null; + parent?: Node; +} + +export interface TSInterfaceDeclaration extends Span { + type: "TSInterfaceDeclaration"; + id: BindingIdentifier; + typeParameters: TSTypeParameterDeclaration | null; + extends: Array; + body: TSInterfaceBody; + declare: boolean; + parent?: Node; +} + +export interface TSInterfaceBody extends Span { + type: "TSInterfaceBody"; + body: Array; + parent?: Node; +} + +export interface TSPropertySignature extends Span { + type: "TSPropertySignature"; + computed: boolean; + optional: boolean; + readonly: boolean; + key: PropertyKey; + typeAnnotation: TSTypeAnnotation | null; + accessibility: null; + static: false; + parent?: Node; +} + +export type TSSignature = + | TSIndexSignature + | TSPropertySignature + | TSCallSignatureDeclaration + | TSConstructSignatureDeclaration + | TSMethodSignature; + +export interface TSIndexSignature extends Span { + type: "TSIndexSignature"; + parameters: Array; + typeAnnotation: TSTypeAnnotation; + readonly: boolean; + static: boolean; + accessibility: null; + parent?: Node; +} + +export interface TSCallSignatureDeclaration extends Span { + type: "TSCallSignatureDeclaration"; + typeParameters: TSTypeParameterDeclaration | null; + params: ParamPattern[]; + returnType: TSTypeAnnotation | null; + parent?: Node; +} + +export type TSMethodSignatureKind = "method" | "get" | "set"; + +export interface TSMethodSignature extends Span { + type: "TSMethodSignature"; + key: PropertyKey; + computed: boolean; + optional: boolean; + kind: TSMethodSignatureKind; + typeParameters: TSTypeParameterDeclaration | null; + params: ParamPattern[]; + returnType: TSTypeAnnotation | null; + accessibility: null; + readonly: false; + static: false; + parent?: Node; +} + +export interface TSConstructSignatureDeclaration extends Span { + type: "TSConstructSignatureDeclaration"; + typeParameters: TSTypeParameterDeclaration | null; + params: ParamPattern[]; + returnType: TSTypeAnnotation | null; + parent?: Node; +} + +export interface TSIndexSignatureName extends Span { + type: "Identifier"; + decorators: []; + name: string; + optional: false; + typeAnnotation: TSTypeAnnotation; + parent?: Node; +} + +export interface TSInterfaceHeritage extends Span { + type: "TSInterfaceHeritage"; + expression: Expression; + typeArguments: TSTypeParameterInstantiation | null; + parent?: Node; +} + +export interface TSTypePredicate extends Span { + type: "TSTypePredicate"; + parameterName: TSTypePredicateName; + asserts: boolean; + typeAnnotation: TSTypeAnnotation | null; + parent?: Node; +} + +export type TSTypePredicateName = IdentifierName | TSThisType; + +export interface TSModuleDeclaration extends Span { + type: "TSModuleDeclaration"; + id: BindingIdentifier | StringLiteral | TSQualifiedName; + body: TSModuleBlock | null; + kind: TSModuleDeclarationKind; + declare: boolean; + global: false; + parent?: Node; +} + +export type TSModuleDeclarationKind = "module" | "namespace"; + +export interface TSGlobalDeclaration extends Span { + type: "TSModuleDeclaration"; + id: IdentifierName; + body: TSModuleBlock; + kind: "global"; + declare: boolean; + global: true; + parent?: Node; +} + +export interface TSModuleBlock extends Span { + type: "TSModuleBlock"; + body: Array; + parent?: Node; +} + +export interface TSTypeLiteral extends Span { + type: "TSTypeLiteral"; + members: Array; + parent?: Node; +} + +export interface TSInferType extends Span { + type: "TSInferType"; + typeParameter: TSTypeParameter; + parent?: Node; +} + +export interface TSTypeQuery extends Span { + type: "TSTypeQuery"; + exprName: TSTypeQueryExprName; + typeArguments: TSTypeParameterInstantiation | null; + parent?: Node; +} + +export type TSTypeQueryExprName = TSImportType | TSTypeName; + +export interface TSImportType extends Span { + type: "TSImportType"; + source: StringLiteral; + options: ObjectExpression | null; + qualifier: TSImportTypeQualifier | null; + typeArguments: TSTypeParameterInstantiation | null; + parent?: Node; +} + +export type TSImportTypeQualifier = IdentifierName | TSImportTypeQualifiedName; + +export interface TSImportTypeQualifiedName extends Span { + type: "TSQualifiedName"; + left: TSImportTypeQualifier; + right: IdentifierName; + parent?: Node; +} + +export interface TSFunctionType extends Span { + type: "TSFunctionType"; + typeParameters: TSTypeParameterDeclaration | null; + params: ParamPattern[]; + returnType: TSTypeAnnotation; + parent?: Node; +} + +export interface TSConstructorType extends Span { + type: "TSConstructorType"; + abstract: boolean; + typeParameters: TSTypeParameterDeclaration | null; + params: ParamPattern[]; + returnType: TSTypeAnnotation; + parent?: Node; +} + +export interface TSMappedType extends Span { + type: "TSMappedType"; + key: BindingIdentifier; + constraint: TSType; + nameType: TSType | null; + typeAnnotation: TSType | null; + optional: TSMappedTypeModifierOperator | false; + readonly: TSMappedTypeModifierOperator | null; + parent?: Node; +} + +export type TSMappedTypeModifierOperator = true | "+" | "-"; + +export interface TSTemplateLiteralType extends Span { + type: "TSTemplateLiteralType"; + quasis: Array; + types: Array; + parent?: Node; +} + +export interface TSAsExpression extends Span { + type: "TSAsExpression"; + expression: Expression; + typeAnnotation: TSType; + parent?: Node; +} + +export interface TSSatisfiesExpression extends Span { + type: "TSSatisfiesExpression"; + expression: Expression; + typeAnnotation: TSType; + parent?: Node; +} + +export interface TSTypeAssertion extends Span { + type: "TSTypeAssertion"; + typeAnnotation: TSType; + expression: Expression; + parent?: Node; +} + +export interface TSImportEqualsDeclaration extends Span { + type: "TSImportEqualsDeclaration"; + id: BindingIdentifier; + moduleReference: TSModuleReference; + importKind: ImportOrExportKind; + parent?: Node; +} + +export type TSModuleReference = TSExternalModuleReference | IdentifierReference | TSQualifiedName; + +export interface TSExternalModuleReference extends Span { + type: "TSExternalModuleReference"; + expression: StringLiteral; + parent?: Node; +} + +export interface TSNonNullExpression extends Span { + type: "TSNonNullExpression"; + expression: Expression; + parent?: Node; +} + +export interface Decorator extends Span { + type: "Decorator"; + expression: Expression; + parent?: Node; +} + +export interface TSExportAssignment extends Span { + type: "TSExportAssignment"; + expression: Expression; + parent?: Node; +} + +export interface TSNamespaceExportDeclaration extends Span { + type: "TSNamespaceExportDeclaration"; + id: IdentifierName; + parent?: Node; +} + +export interface TSInstantiationExpression extends Span { + type: "TSInstantiationExpression"; + expression: Expression; + typeArguments: TSTypeParameterInstantiation; + parent?: Node; +} + +export type ImportOrExportKind = "value" | "type"; + +export interface JSDocNullableType extends Span { + type: "TSJSDocNullableType"; + typeAnnotation: TSType; + postfix: boolean; + parent?: Node; +} + +export interface JSDocNonNullableType extends Span { + type: "TSJSDocNonNullableType"; + typeAnnotation: TSType; + postfix: boolean; + parent?: Node; +} + +export interface JSDocUnknownType extends Span { + type: "TSJSDocUnknownType"; + parent?: Node; +} + +export type ModuleKind = "script" | "module" | "commonjs"; + +export interface Span { + start: number; + end: number; + range?: [number, number]; +} + +export type AssignmentOperator = + | "=" + | "+=" + | "-=" + | "*=" + | "/=" + | "%=" + | "**=" + | "<<=" + | ">>=" + | ">>>=" + | "|=" + | "^=" + | "&=" + | "||=" + | "&&=" + | "??="; + +export type BinaryOperator = + | "==" + | "!=" + | "===" + | "!==" + | "<" + | "<=" + | ">" + | ">=" + | "+" + | "-" + | "*" + | "/" + | "%" + | "**" + | "<<" + | ">>" + | ">>>" + | "|" + | "^" + | "&" + | "in" + | "instanceof"; + +export type LogicalOperator = "||" | "&&" | "??"; + +export type UnaryOperator = "+" | "-" | "!" | "~" | "typeof" | "void" | "delete"; + +export type UpdateOperator = "++" | "--"; + +export type Node = + | Program + | IdentifierName + | IdentifierReference + | BindingIdentifier + | LabelIdentifier + | ThisExpression + | ArrayExpression + | ObjectExpression + | ObjectProperty + | TemplateLiteral + | TaggedTemplateExpression + | TemplateElement + | ComputedMemberExpression + | StaticMemberExpression + | PrivateFieldExpression + | CallExpression + | NewExpression + | MetaProperty + | SpreadElement + | UpdateExpression + | UnaryExpression + | BinaryExpression + | PrivateInExpression + | LogicalExpression + | ConditionalExpression + | AssignmentExpression + | ArrayAssignmentTarget + | ObjectAssignmentTarget + | AssignmentTargetRest + | AssignmentTargetWithDefault + | AssignmentTargetPropertyIdentifier + | AssignmentTargetPropertyProperty + | SequenceExpression + | Super + | AwaitExpression + | ChainExpression + | ParenthesizedExpression + | Directive + | Hashbang + | BlockStatement + | VariableDeclaration + | VariableDeclarator + | EmptyStatement + | ExpressionStatement + | IfStatement + | DoWhileStatement + | WhileStatement + | ForStatement + | ForInStatement + | ForOfStatement + | ContinueStatement + | BreakStatement + | ReturnStatement + | WithStatement + | SwitchStatement + | SwitchCase + | LabeledStatement + | ThrowStatement + | TryStatement + | CatchClause + | DebuggerStatement + | AssignmentPattern + | ObjectPattern + | BindingProperty + | ArrayPattern + | BindingRestElement + | Function + | FunctionBody + | ArrowFunctionExpression + | YieldExpression + | Class + | ClassBody + | MethodDefinition + | PropertyDefinition + | PrivateIdentifier + | StaticBlock + | AccessorProperty + | ImportExpression + | ImportDeclaration + | ImportSpecifier + | ImportDefaultSpecifier + | ImportNamespaceSpecifier + | ImportAttribute + | ExportNamedDeclaration + | ExportDefaultDeclaration + | ExportAllDeclaration + | ExportSpecifier + | V8IntrinsicExpression + | BooleanLiteral + | NullLiteral + | NumericLiteral + | StringLiteral + | BigIntLiteral + | RegExpLiteral + | JSXElement + | JSXOpeningElement + | JSXClosingElement + | JSXFragment + | JSXOpeningFragment + | JSXClosingFragment + | JSXNamespacedName + | JSXMemberExpression + | JSXExpressionContainer + | JSXEmptyExpression + | JSXAttribute + | JSXSpreadAttribute + | JSXIdentifier + | JSXSpreadChild + | JSXText + | TSThisParameter + | TSEnumDeclaration + | TSEnumBody + | TSEnumMember + | TSTypeAnnotation + | TSLiteralType + | TSConditionalType + | TSUnionType + | TSIntersectionType + | TSParenthesizedType + | TSTypeOperator + | TSArrayType + | TSIndexedAccessType + | TSTupleType + | TSNamedTupleMember + | TSOptionalType + | TSRestType + | TSAnyKeyword + | TSStringKeyword + | TSBooleanKeyword + | TSNumberKeyword + | TSNeverKeyword + | TSIntrinsicKeyword + | TSUnknownKeyword + | TSNullKeyword + | TSUndefinedKeyword + | TSVoidKeyword + | TSSymbolKeyword + | TSThisType + | TSObjectKeyword + | TSBigIntKeyword + | TSTypeReference + | TSQualifiedName + | TSTypeParameterInstantiation + | TSTypeParameter + | TSTypeParameterDeclaration + | TSTypeAliasDeclaration + | TSClassImplements + | TSInterfaceDeclaration + | TSInterfaceBody + | TSPropertySignature + | TSIndexSignature + | TSCallSignatureDeclaration + | TSMethodSignature + | TSConstructSignatureDeclaration + | TSIndexSignatureName + | TSInterfaceHeritage + | TSTypePredicate + | TSModuleDeclaration + | TSGlobalDeclaration + | TSModuleBlock + | TSTypeLiteral + | TSInferType + | TSTypeQuery + | TSImportType + | TSImportTypeQualifiedName + | TSFunctionType + | TSConstructorType + | TSMappedType + | TSTemplateLiteralType + | TSAsExpression + | TSSatisfiesExpression + | TSTypeAssertion + | TSImportEqualsDeclaration + | TSExternalModuleReference + | TSNonNullExpression + | Decorator + | TSExportAssignment + | TSNamespaceExportDeclaration + | TSInstantiationExpression + | JSDocNullableType + | JSDocNonNullableType + | JSDocUnknownType + | ParamPattern; diff --git a/node_modules/@paralleldrive/cuid2/LICENSE b/node_modules/@paralleldrive/cuid2/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..030c5373672e69ee79decfb994887d14e8186ee8 --- /dev/null +++ b/node_modules/@paralleldrive/cuid2/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Eric Elliott + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@paralleldrive/cuid2/README.md b/node_modules/@paralleldrive/cuid2/README.md new file mode 100644 index 0000000000000000000000000000000000000000..be5503d7adeb95798a2ab1921faf968269ac2bde --- /dev/null +++ b/node_modules/@paralleldrive/cuid2/README.md @@ -0,0 +1,397 @@ +# Cuid2 + +Secure, collision-resistant ids optimized for horizontal scaling and performance. Next generation UUIDs. + +Need unique ids in your app? Forget UUIDs and GUIDs which often collide in large apps. Use Cuid2, instead. + +**Cuid2 is:** + +* **Secure:** It's not feasible to guess the next id, existing valid ids, or learn anything about the referenced data from the id. Cuid2 uses multiple, independent entropy sources and hashes them with a security-audited, NIST-standard cryptographically secure hashing algorithm (Sha3). +* **Collision resistant:** It's extremely unlikely to generate the same id twice (by default, you'd need to generate roughly 4,000,000,000,000,000,000 ids ([`sqrt(36^(24-1) * 26) = 4.0268498e+18`](https://en.wikipedia.org/wiki/Birthday_problem#Square_approximation)) to reach 50% chance of collision.) +* **Horizontally scalable:** Generate ids on multiple machines without coordination. +* **Offline-compatible:** Generate ids without a network connection. +* **URL and name-friendly:** No special characters. +* **Fast and convenient:** No async operations. Won't introduce user-noticeable delays. Less than 5k, gzipped. +* **But not *too fast*:** If you can hash too quickly you can launch parallel attacks to find duplicates or break entropy-hiding. For unique ids, the fastest runner loses the security race. + + +**Cuid2 is not good for:** + +* Sequential ids (see the [note on K-sortable ids](https://github.com/paralleldrive/cuid2#note-on-k-sortablesequentialmonotonically-increasing-ids), below) +* High performance tight loops, such as render loops (if you don't need cross-host unique ids or security, consider a simple counter for this use-case, or try [Ulid](https://github.com/ulid/javascript) or [NanoId](https://github.com/ai/nanoid)). + + +## Getting Started + +``` +npm install --save @paralleldrive/cuid2 +``` + +Or + +``` +yarn add @paralleldrive/cuid2 +``` + +```js +import { createId } from '@paralleldrive/cuid2'; + +const ids = [ + createId(), // 'tz4a98xxat96iws9zmbrgj3a' + createId(), // 'pfh0haxfpzowht3oi213cqos' + createId(), // 'nc6bzmkmd014706rfda898to' +]; +``` + +Using Jest? Jump to [Using with Jest](#using-in-jest). + +### Configuration + +```js +import { init } from '@paralleldrive/cuid2'; + +// The init function returns a custom createId function with the specified +// configuration. All configuration properties are optional. +const createId = init({ + // A custom random function with the same API as Math.random. + // You can use this to pass a cryptographically secure random function. + random: Math.random, + // the length of the id + length: 10, + // A custom fingerprint for the host environment. This is used to help + // prevent collisions when generating ids in a distributed system. + fingerprint: 'a-custom-host-fingerprint', +}); + +console.log( + createId(), // wjfazn7qnd + createId(), // cerhuy9499 + createId(), // itp2u4ozr4 +); +``` + + +### Validation + +```js +import { createId, isCuid } from '@paralleldrive/cuid2'; + + +console.log( + isCuid(createId()), // true + isCuid('not a cuid'), // false +); +``` + + +## Trusted By + +* [Greenruhm](https://twitter.com/greenruhm) +* [Typebot](https://typebot.io/) +* [Submit my project](https://github.com/paralleldrive/cuid2/issues/new?title=Social+proof) + +## Why? + +Ids should be secure by default for the same reason that browser sessions should be secure by default. There are too many things that can go wrong when they're not, and insecure ids can cause problems in unexpected ways, including [unauthorized user](https://www.intruder.io/research/in-guid-we-trust) [account access](https://infosecwriteups.com/bugbounty-how-i-was-able-to-compromise-any-user-account-via-reset-password-functionality-a11bb5f863b3), [unauthorized access to user data](https://infosecwriteups.com/how-this-easy-vulnerability-resulted-in-a-20-000-bug-bounty-from-gitlab-d9dc9312c10a), and accidental leaks of user's personal data which can lead to catastrophic effects, even in innocent-sounding applications like fitness run trackers (see the [2018 Strava Pentagon breach](https://www.engadget.com/2018-02-02-strava-s-fitness-heatmaps-are-a-potential-catastrophe.html) and [PleaseRobMe](https://pleaserobme.com/why)). + +Not all security measures should be considered equal. For example, it's not a good idea to trust your browser's "Cryptographically Secure" Psuedo Random Number Generator (CSPRNG) (used in tools like `uuid` and `nanoid`). For example, there may be [bugs in browser CSPRNGs](https://bugs.chromium.org/p/chromium/issues/detail?id=552749). For many years, Chromium's `Math.random()` [wasn't very random at all](https://thenextweb.com/news/google-chromes-javascript-engine-finally-returns-actual-random-numbers). Cuid was created to solve the issue of untrustworthy entropy in id generators that led to frequent id collisions and related problems in production applications. Instead of trusting a single source of entropy, Cuid2 combines several sources of entropy to provide stronger security and collision-resistance guarantees than are available in other solutions. + +Modern web applications have different requirements than applications written in the early days of GUID (globally unique identifiers) and UUIDs (universally unique identifiers). In particular, Cuid2 aims to provide stronger uniqueness guarantees than any existing GUID or UUID implementation and protect against leaking any information about the data being referenced, or the system that generated the id. + +Cuid2 is the next generation of Cuid, which has been used in thousands of applications for over a decade with no confirmed collision reports. The changes in Cuid2 are significant and could potentially disrupt the many projects that rely on Cuid, so we decided to create a replacement library and id standard, instead. Cuid is now deprecated in favor of Cuid2. + +Entropy is a measure of the total information in a system. In the context of unique ids, a higher entropy will lead to fewer collisions, and can also make it more difficult for an attacker to guess a valid id. + +Cuid2 is made up of the following entropy sources: + +* An initial letter to make the id a usable identifier in JavaScript and HTML/CSS +* The current system time +* Pseudorandom values +* A session counter +* A host fingerprint + +The string is Base36 encoded, which means it contains only lowercase letters and the numbers: 0 - 9, with no special symbols. + + +### Horizontal scalability + +Today's applications don't run on any single machine. + +Applications might need to support online / offline capability, which means we need a way for clients on different hosts to generate ids that won't collide with ids generated by other hosts -- even if they're not connected to the network. + +Most pseudo-random algorithms use time in ms as a random seed. Random IDs lack sufficient entropy when running in separate processes (such as cloned virtual machines or client browsers) to guarantee against collisions. Application developers report v4 UUID collisions causing problems in their applications when the ID generation is distributed between lots of machines such that lots of IDs are generated in the same millisecond. + +Each new client exponentially increases the chance of collision in the same way that each new character in a random string exponentially reduces the chance of collision. Successful apps scale at hundreds or thousands of new clients per day, so fighting the lack of entropy by adding random characters is a recipe for ridiculously long identifiers. + +Because of the nature of this problem, it's possible to build an app from the ground up and scale it to a million users before this problem is detected. By the time you notice the problem (when your peak hour use requires dozens of ids to be created per ms), if your db doesn't have unique constraints on the id because you thought your guids were safe, you're in a world of hurt. Your users start to see data that doesn't belong to them because the db just returns the first ID match it finds. + +Alternatively, you've played it safe and you only let your database create ids. Writes only happen on a master database, and load is spread out over read replicas. But with this kind of strain, you have to start scaling your database writes horizontally, too, and suddenly your application starts to crawl (if the db is smart enough to guarantee unique ids between write hosts), or you start getting id collisions between different db hosts, so your write hosts don't agree about which ids represent which data. + + +### Performance + +Id generation should be fast enough that humans won't notice a delay, but too slow to feasibly brute force (even in parallel). That means no waiting around for asynchronous entropy pool requests, or cross-process/cross-network communication. Performance slows to impracticality in the browser. All sources of entropy need to be fast enough for synchronous access. + +Even worse, when the database is the only guarantee that ids are unique, that means that clients are forced to send incomplete records to the database, and wait for a network round-trip before they can use the ids in any algorithm. Forget about fast client performance. It simply isn't possible. + +That situation has caused some clients to create ids that are only usable in a single client session (such as an in-memory counter). When the database returns the real id, the client has to do some juggling logic to swap out the id being used, adding complexity to the client implementation code. + +If client side ID generation were stronger, the chances of collision would be much smaller, and the client could send complete records to the db for insertion without waiting for a full round-trip request to finish before using the ID. + + +#### Tiny + +Page loads need to be FAST, and that means we can't waste a lot of JavaScript on a complex algorithm. Cuid2 is tiny. This is especially important for thick-client JavaScript applications. + + +### Secure + +Client-visible ids often need to have sufficient random data and entropy to make it practically impossible to try to guess valid IDs based on an existing, known id. That makes simple sequential ids unusable in the context of client-side generated database keys. Additionally, using V4 UUIDs is also not safe, because there are known attacks on several id generating algorithms that a sophisticated attacker can use to predict next ids. Cuid2 has been audited by security experts and artificial intelligence, and is considered safe to use for use-cases like secret sharing links. + + +### Portable + +Most stronger forms of the UUID / GUID algorithms require access to OS services that are not available in browsers, meaning that they are impossible to implement as specified. Further, our id standard needs to be portable to many languages (the original cuid has 22 different language implementations). + +#### Ports + +* [Cuid2 for Clojure](https://github.com/hden/cuid2) - [Haokang Den](https://github.com/hden) +* [Cuid2 for ColdFusion](https://github.com/bennadel/CUID2-For-ColdFusion) - [Ben Nadel](https://github.com/bennadel) +* [Cuid2 for Dart](https://github.com/obsidiaHQ/cuid2) - [George Mamar](https://github.com/obsidiaHQ) +* [Cuid2 for Java](https://github.com/thibaultmeyer/cuid-java) - [Thibault Meyer](https://github.com/thibaultmeyer) +* [Cuid2 for .NET](https://github.com/visus-io/cuid.net) - [Visus](https://github.com/xaevik) +* [Cuid2 for PHP](https://github.com/visus-io/php-cuid2) - [Visus](https://github.com/xaevik) +* [Cuid2 for Python](https://github.com/gordon-code/cuid2) - [Gordon Code](https://github.com/gordon-code) +* [Cuid2 for Ruby](https://github.com/stulzer/cuid2/blob/main/lib/cuid2.rb) - [Rubens Stulzer](https://github.com/stulzer) +* [Cuid2 for Rust](https://github.com/mplanchard/cuid-rust) - [Matthew Planchard](https://github.com/mplanchard) + +## Improvements Over Cuid + +The original Cuid served us well for more than a decade. We used it across 2 different social networks, and to generate ids for Adobe Creative Cloud. We never had a problem with collisions in production systems using it. But there was room for improvement. + +### Better Collision Resistance + +Available entropy is the maximum number of unique ids that can be generated. Generally more entropy leads to lower probability of collision. For simplicity, we will assume a perfectly random distribution in the following discussion. + +The original Cuid ran for more than 10 years in across thousands of software implementations with zero confirmed collision reports, in some cases with more than 100 million users generating ids. + +The original Cuid had a maximum available entropy of about `3.71319E+29` (assuming 1 id per session). That's already a really big number, but the maximum recommended entropy in Cuid2 is `4.57458E+49`. For reference, that's about the same entropy difference as the size of a mosquito compared to the distance from earth to the nearest star. Cuid2 has a default entropy of `1.62155E+37`, which is a significant increase from the original Cuid and is comparable to the difference between the size of a baseball and the size of the moon. + +The hashing function mixes all the sources of entropy together into a single value, so it's important we use a high quality hashing algorithm. We have tested billions of ids with Cuid2 with zero collisions detected to-date. + + +### More Portable + +The original Cuid used different methods to generate fingerprints across different kinds of hosts, including browsers, Node, and React Native. Unfortunately, this caused several compatability problems across the cuid user ecosystem. + +In Node, each production host was slightly different, and we could reliable grab process ids and such to differentiate between hosts. Our early assumptions about different hosts generating different PIDs in Node proved to be false when we started deploying on cloud virtual hosts using identical containers and micro-container architectures. The result was that host fingerprint entropy was low in Node, limiting their ability to provide good collision resistance for horizontal server scaling in environments like cloud workers and micro-containers. + +It was also not possible to customize your fingerprint function if you had different fingerprinting needs using Cuid, e.g., if both `global` and `window` are `undefined`. + +Cuid2 uses a list of all global names in the JavaScript environment. Hashing it produces a very good host fingerprint, but we intentionally did not include a hash function in the original Cuid because all the secure ones we could find would bloat the bundle, so the original Cuid was unable to take full advantage of all of that unique host entropy. + +In Cuid2, we use a tiny, fast, security-audited, NIST-standardized hash function and we seed it with random entropy, so on production environments where the globals are all identical, we lose the unique fingerprint, but still get random entropy to replace it, strengthening collision resistance. + + +### Deterministic Length + +Length was non-deterministic in Cuid. This worked fine in almost all cases, but proved to be problematic for some data structure uses, forcing some users to create wrapper code to pad the output. We recommend sticking to the defaults for most cases, but if you don't need strong uniqueness guarantees, (e.g., your use-case is something like username or URL disambiguation), it can be fine to use a shorter version. + + +### More Efficient Session Counter Entropy + +The original Cuid wasted entropy on session counters that were not always used, rarely filled, and sometimes rolled over, meaning they could collide with each other if you generate enough ids in a tight loop, reducing their effectiveness. Cuid2 initializes the counter with a random number so the entropy is never wasted. It also uses the full precision of the native JS number type. If you only generate a single id, the counter just extends the random entropy, rather than wasting digits, providing even stronger anti-collision protection. + + +### Parameterized Length + +Different use-cases have different needs for entropy resistance. Sometimes, a short disambiguating series of random digits is enough: for example, it's common to use short slugs to disambiguate similar names, e.g. usernames or URL slugs. Since the original cuid did not hash its output, we had to make some seriously limiting entropy decisions to produce a short slug. In the new version, all sources of entropy are mixed with the hash function, and you can safely grab a substring of any length shorter than 32 digits. You can roughly estimate how many ids you can generate before reaching 50% chance of collision with: [`sqrt(36^(n-1)*26)`](https://en.wikipedia.org/wiki/Birthday_problem#Square_approximation), so if you use `4` digits, you'll reach 50% chance of collision after generating only `~1101` ids. That might be fine for username disambiguation. Are there more than 1k people who want to share the same username? + +By default, you'd need to generate `~4.0268498e+18` ids to reach a 50% chance of collision, and at maximum length, you'd need to generate `~6.7635614e+24` ids to reach 50% odds of collision. To use a custom length, import the `init` function, which takes configuration options: + +```js +import { init } from '@paralleldrive/cuid2'; +const length = 10; // 50% odds of collision after ~51,386,368 ids +const cuid = init({ length }); +console.log(cuid()); // nw8zzfaa4v +``` + + +### Enhanced Security + +The original Cuid leaked details about the id, including very limited data from the host environment (via the host fingerprint), and the exact time that the id was created. The new Cuid2 hashes all sources of entropy into a random-looking string. + +Due to the hashing algorithm, it should not be practically possible to recover any of the entropy sources from the generated ids. Cuid used roughly monotonically increasing ids for database performance reasons. Some people abused them to select data by creation date. If you want to be able to sort items by creation date, we recommend making a separate, indexed `createdAt` field in your database instead of using monotonic ids because: + +* It's easy to trick a client system to generate ids in the past or future. +* Order is not guaranteed across multiple hosts generating ids at nearly the same time. +* Deterministically monotic resolution was never guaranteed. + +In Cuid2, the hashing algorithm uses a salt. The salt is a random string which is added to the input entropy sources before the hashing function is applied. This makes it much more difficult for an attacker to guess valid ids, as the salt changes with each id, meaning the attacker is unable to use any existing ids as a basis for guessing others. + + +## Comparisons + +Security was the primary motivation for creating Cuid2. Our ids should be default-secure for the same reason we use https instead of http. The problem is, all our current id specifications are based on decades-old standards that were never designed with security in mind, optimizing for database performance charactaristics which are no longer relevant in modern, distributed applications. Almost all of the popular ids today optimize for being k-sortable, which was important 10 years ago. Here's what k-sortable means, and why it's no longer as important is it was when we created the Cuid specification which [helped inspire current standards like UUID v6 - v8](https://www.ietf.org/archive/id/draft-ietf-uuidrev-rfc4122bis-00.html#section-11.2): + + +### Note on K-Sortable/Sequential/Monotonically Increasing Ids + +TL;DR: Stop worrying about K-Sortable ids. They're not a big deal anymore. Use `createdAt` fields instead. + +**The performance impact of using sequential keys in modern systems is often exaggerated.** If your database is too small to use cloud-native solutions, it's also too small to worry about the performance impact of sequential vs random ids unless you're living in the distant past (i.e. you're using hardware from 2010). If it's large enough to worry, random ids may still be faster. + +In the past, sequential keys could potentially have a significant impact on performance, but this is no longer the case in modern systems. + +One reason for using sequential keys is to avoid id fragmentation, which can require a large amount of disk space for databases with billions of records. However, at such a large scale, modern systems often use cloud-native databases that are designed to handle terabytes of data efficiently and at a low cost. Additionally, the entire database may be stored in memory, providing fast random-access lookup performance. Therefore, the impact of fragmented keys on performance is minimal. + +Worse, K-Sortable ids are not always a good thing for performance anyway, because they can cause hotspots in the database. If you have a system that generates a large number of ids in a short period of time, the ids will be generated in a sequential order, causing the tree to become unbalanced, which will lead to frequent rebalancing. This can cause a significant performance impact. + +So what kinds of operations suffer from a non-sequential id? Paged, sorted operations. Stuff like "fetch me 100000 records, sorted by id". That would be noticeably impacted, but how often do you need to sort by id if your id is opaque? I have never needed to. Modern cloud databases allow you to create indexes on `createdAt` fields which perform extremely well. + +The worst part of K-Sortable ids is their impact on security. K-Sortable = insecure. + + +### The Contenders + +We're unaware of any standard or library in the space that adequately meets all of our requirements. We'll use the following criteria to filter a list of commonly used alternatives. Let's start with the contenders: + +Database increment (Int, BigInt, AutoIncrement), [UUID v1 - v8](https://www.ietf.org/archive/id/draft-ietf-UUIDrev-rfc4122bis-00.html), [NanoId](https://github.com/ai/nanoid), [Ulid](https://github.com/ulid/javascript), [Sony Snowflake](https://github.com/sony/sonyflake) (inspired by Twitter Snowflake), [ShardingID](https://instagram-engineering.com/sharding-ids-at-instagram-1cf5a71e5a5c) (Instagram), [KSUID](https://github.com/segmentio/ksuid), [PushId](https://firebase.blog/posts/2015/02/the-2120-ways-to-ensure-unique_68) (Google), [XID](https://github.com/rs/xid), [ObjectId](https://www.mongodb.com/docs/manual/reference/method/ObjectId/) (MongoDB). + +Here are the disqualifiers we care about: + +* **Leaks information:** Database auto-increment, all UUIDs (except V4 and including V6 - V8), Ulid, Snowflake, ShardingId, pushId, ObjectId, KSUID +* **Collision Prone:** Database auto-increment, v4 UUID +* **Not cryptographically secure random output:** Database auto-increment, UUID v1, UUID v4 +* **Requires distributed coordination:** Snowflake, ShardingID, database increment +* **Not URL or name friendly:** UUID (too long, dashes), Ulid (too long), UUID v7 (too long) - anything else that supports special characters like dashes, spaces, underscores, #$%^&, etc. +* **Too fast:** UUID v1, UUID v4, NanoId, Ulid, Xid + + +Here are the qualifiers we care about: + +* **Secure - No leaked info, attack-resistant:** Cuid2, NanoId (Medium - trusts web crypto API entropy). +* **Collision resistant:** Cuid2, Cuid v1, NanoId, Snowflake, KSUID, XID, Ulid, ShardingId, ObjectId, UUID v6 - v8. +* **Horizontally scalable:** Cuid2, Cuid v1, NanoId, ObjectId, Ulid, KSUID, Xid, ShardingId, ObjectId, UUID v6 - v8. +* **Offline-compatible:** Cuid2, Cuid v1, NanoId, Ulid, UUID v6 - v8. +* **URL and name-friendly:** Cuid2, Cuid v1, NanoId (with custom alphabet). +* **Fast and convenient:** Cuid2, Cuid v1, NanoId, Ulid, KSUID, Xid, UUID v4, UUID v7. +* **But not *too fast*:** Cuid2, Cuid v1, UUID v7, Snowflake, ShardingId, ObjectId. + +Cuid2 is the only solution that passed all of our tests. + + +### NanoId and Ulid + +Overall, NanoId and Ulid seem to hit most of our requirements, Ulid leaks timestamps, and they both trust the random entropy from the Web Crypto API too much. The Web Crypto API trusts 2 untrustworthy things: The [random entropy source](https://docs.rs/bug/0.2.0/bug/rand/index.html#cryptographic-security), and the hashing algorithm used to stretch the entropy into random-looking data. Some implementations have had [serious bugs that made them vulnerable to attack](https://bugs.chromium.org/p/chromium/issues/detail?id=552749). + +Along with using cryptographically secure methods, Cuid2 supplies its own known entropy from a diverse pool and uses a security audited, NIST-standard cryptographically secure hashing algorithm. + +**Too fast:** NanoId and Ulid are also very fast. But that's not a good thing. The faster you can generate ids, the faster you can run collision attacks. Bad guys looking for statistical anomalies in the distribution of ids can use the speed of NanoId to their advantage. Cuid2 is fast enough to be convenient, but not so fast that it's a security risk. + + +#### Entropy Security Comparison + +* NanoId Entropy: Web Crypto. +* Ulid Entropy: Web Crypto + time stamp (leaked). +* Cuid2 Entropy: Web Crypto + time stamp + counter + host fingerprint + hashing algorithm. + + +## Testing + +Before each commit, we test over 10 million ids generated in parallel across 7 different CPU cores. With each batch of tests, we run a histogram analysis to ensure an even, random distribution across the entire entropy range. Any bias would make it more likely for ids to collide, so our tests will automatically fail if it finds any. + +Screen Shot 2022-12-30 at 6 19 15 PM + + +We also generate randograms and do spot visual inspections. + +![randogram](public/randogram.png) + +## Troubleshooting + +Some React Native environments may be missing TextEncoding features, which will need to be polyfilled. The following have both worked for users who have encountered this issue: + +``` +npm install --save fast-text-encoding +``` + +Then, before importing Cuid2: + +```js +import "fast-text-encoding"; +``` + +Alternatively, if that doesn't work: + +``` +npm install --save text-encoding-polyfill +``` + +Then, before importing Cuid2: + +```js +import "text-encoding-polyfill"; +``` + +### Using in Jest + +Jest uses jsdom, which builds a global object which doesn't comply with current standards. There is a known issue in Jest when jsdom environment is used. The results of `new TextEncoder().encode()` and `new Uint8Array()` are different, refer to [jestjs/jest#9983](https://github.com/jestjs/jest/issues/9983). + +To work around this limitation on jsdom (and by extension, Jest), you'll need to use custom environment which overwrites Uint8Array provided by jsdom: + +Install jest-environment-jsdom. Make sure to use the same version as your jest. See [this answer on Stackoverflow for reference](https://stackoverflow.com/a/72124554). + +``` +❯ npm i jest-environment-jsdom@27 +``` + +Create `jsdom-env.js` file in the root: + +```js +const JSDOMEnvironmentBase = require('jest-environment-jsdom'); + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +class JSDOMEnvironment extends JSDOMEnvironmentBase { + constructor(...args) { + const { global } = super(...args); + + global.Uint8Array = Uint8Array; + } +} + +exports.default = JSDOMEnvironment; +exports.TestEnvironment = JSDOMEnvironment; +``` + +Update scripts to use the custom environment: + +```js +{ + // ... + "scripts": { + // ... + "test": "react-scripts test --env=./jsdom-env.js", + // ... + }, +} +``` + +#### JSDOM is Missing Features + +JSDOM doesn't support TextEncoder and TextDecoder, refer jsdom/jsdom#2524. + +In Jest, features like Uint8Array/TextEncoder/TextDecoder may be available in the jsdom environment but may produce results different from the platform standards. These are known bugs which may be resolved by jsdom at some point, but there is no clear ETA. + +Note that this issue may impact any package that relies on the TextEncoder or TextDecorder standards. If you would like to use a simple test runner that just works, try [Riteway](https://github.com/paralleldrive/riteway). + + +## Sponsors + +This project is made possible by: + +* [DevAnywhere](https://devanywhere.io) - Expert mentorship for software builders, from junior developers to software leaders like VPE, CTO, and CEO. +* [EricElliottJS.com](https://ericelliottjs.com) - Learn JavaScript on demand with videos and interactive lessons. diff --git a/node_modules/@paralleldrive/cuid2/index.d.ts b/node_modules/@paralleldrive/cuid2/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fccc626519357c83170051e719c2d4346991b57e --- /dev/null +++ b/node_modules/@paralleldrive/cuid2/index.d.ts @@ -0,0 +1,19 @@ +declare namespace cuid2 { + export function getConstants(): { + defaultLength: number + bigLength: number + } + + export function init(options?: { + random?: () => number + counter?: () => number + length?: number + fingerprint?: string + }): () => string + + export function isCuid(id: string): boolean + + export function createId(): string +} + +export = cuid2; diff --git a/node_modules/@paralleldrive/cuid2/index.js b/node_modules/@paralleldrive/cuid2/index.js new file mode 100644 index 0000000000000000000000000000000000000000..88dff605c96df92952974ad7d3a55ac91fe208aa --- /dev/null +++ b/node_modules/@paralleldrive/cuid2/index.js @@ -0,0 +1,6 @@ +const { createId, init, getConstants, isCuid } = require("./src/index"); + +module.exports.createId = createId; +module.exports.init = init; +module.exports.getConstants = getConstants; +module.exports.isCuid = isCuid; diff --git a/node_modules/@paralleldrive/cuid2/package.json b/node_modules/@paralleldrive/cuid2/package.json new file mode 100644 index 0000000000000000000000000000000000000000..871daa0f954f58306bbfc697bf65049177d4406b --- /dev/null +++ b/node_modules/@paralleldrive/cuid2/package.json @@ -0,0 +1,69 @@ +{ + "name": "@paralleldrive/cuid2", + "private": false, + "types": "index.d.ts", + "files": [ + "src/index.js", + "index.js", + "index.d.ts" + ], + "scripts": { + "dev": "next dev", + "build": "next build", + "start": "next start", + "lint": "next lint --fix", + "typescript": "npx -p typescript tsc --esModuleInterop --rootDir . src/index-test.js --noEmit --allowJs --checkJs --target es2020 --moduleResolution node && echo 'TypeScript Complete.'", + "test": "NODE_ENV=test node src/index-test.js", + "test-color": "NODE_ENV=test node src/index-test.js | tap-nirvana", + "collision-test": "NODE_ENV=test node src/collision-test.js | tap-nirvana", + "histogram": "NODE_ENV=test node src/histogram.js | tap-nirvana", + "watch": "watch 'npm run -s test | tap-nirvana && npm run -s lint && npm run -s typescript' src", + "update": "updtr", + "release": "release-it" + }, + "pre-commit": [ + "lint", + "test-color", + "collision-test" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/ericelliott/cuid2.git" + }, + "keywords": [ + "uuid", + "guid", + "cuid", + "unique", + "id", + "ids", + "identifier", + "identifiers" + ], + "author": "Eric Elliott", + "license": "MIT", + "bugs": { + "url": "https://github.com/ericelliott/cuid2/issues" + }, + "homepage": "https://github.com/ericelliott/cuid2#readme", + "devDependencies": { + "eslint": "8.30.0", + "eslint-config-next": "13.1.1", + "eslint-config-prettier": "8.5.0", + "eslint-plugin-prettier": "4.2.1", + "next": "13.1.1", + "pre-commit": "1.2.2", + "prettier": "2.8.1", + "react": "18.2.0", + "react-dom": "18.2.0", + "release-it": "15.5.1", + "riteway": "7.0.0", + "tap-nirvana": "1.1.0", + "updtr": "4.0.0", + "watch": "1.0.2" + }, + "dependencies": { + "@noble/hashes": "^1.1.5" + }, + "version": "2.3.1" +} diff --git a/node_modules/@paralleldrive/cuid2/src/index.js b/node_modules/@paralleldrive/cuid2/src/index.js new file mode 100644 index 0000000000000000000000000000000000000000..db29ad34bfb2d50d050673bf276c8bdb1068a222 --- /dev/null +++ b/node_modules/@paralleldrive/cuid2/src/index.js @@ -0,0 +1,127 @@ +/* global global, window, module */ +const { sha3_512: sha3 } = require("@noble/hashes/sha3"); + +const defaultLength = 24; +const bigLength = 32; + +const createEntropy = (length = 4, random = Math.random) => { + let entropy = ""; + + while (entropy.length < length) { + entropy = entropy + Math.floor(random() * 36).toString(36); + } + return entropy; +}; + +/* + * Adapted from https://github.com/juanelas/bigint-conversion + * MIT License Copyright (c) 2018 Juan Hernández Serrano + */ +function bufToBigInt(buf) { + let bits = 8n; + + let value = 0n; + for (const i of buf.values()) { + const bi = BigInt(i); + value = (value << bits) + bi; + } + return value; +} + +const hash = (input = "") => { + // Drop the first character because it will bias the histogram + // to the left. + return bufToBigInt(sha3(input)).toString(36).slice(1); +}; + +const alphabet = Array.from({ length: 26 }, (x, i) => + String.fromCharCode(i + 97) +); + +const randomLetter = (random) => + alphabet[Math.floor(random() * alphabet.length)]; + +/* +This is a fingerprint of the host environment. It is used to help +prevent collisions when generating ids in a distributed system. +If no global object is available, you can pass in your own, or fall back +on a random string. +*/ +const createFingerprint = ({ + globalObj = typeof global !== "undefined" + ? global + : typeof window !== "undefined" + ? window + : {}, + random = Math.random, +} = {}) => { + const globals = Object.keys(globalObj).toString(); + const sourceString = globals.length + ? globals + createEntropy(bigLength, random) + : createEntropy(bigLength, random); + + return hash(sourceString).substring(0, bigLength); +}; + +const createCounter = (count) => () => { + return count++; +}; + +// ~22k hosts before 50% chance of initial counter collision +// with a remaining counter range of 9.0e+15 in JavaScript. +const initialCountMax = 476782367; + +const init = ({ + // Fallback if the user does not pass in a CSPRNG. This should be OK + // because we don't rely solely on the random number generator for entropy. + // We also use the host fingerprint, current time, and a session counter. + random = Math.random, + counter = createCounter(Math.floor(random() * initialCountMax)), + length = defaultLength, + fingerprint = createFingerprint({ random }), +} = {}) => { + return function cuid2() { + const firstLetter = randomLetter(random); + + // If we're lucky, the `.toString(36)` calls may reduce hashing rounds + // by shortening the input to the hash function a little. + const time = Date.now().toString(36); + const count = counter().toString(36); + + // The salt should be long enough to be globally unique across the full + // length of the hash. For simplicity, we use the same length as the + // intended id output. + const salt = createEntropy(length, random); + const hashInput = `${time + salt + count + fingerprint}`; + + return `${firstLetter + hash(hashInput).substring(1, length)}`; + }; +}; + +const createId = init(); + +const isCuid = (id, { minLength = 2, maxLength = bigLength } = {}) => { + const length = id.length; + const regex = /^[0-9a-z]+$/; + + try { + if ( + typeof id === "string" && + length >= minLength && + length <= maxLength && + regex.test(id) + ) + return true; + } finally { + } + + return false; +}; + +module.exports.getConstants = () => ({ defaultLength, bigLength }); +module.exports.init = init; +module.exports.createId = createId; +module.exports.bufToBigInt = bufToBigInt; +module.exports.createCounter = createCounter; +module.exports.createFingerprint = createFingerprint; +module.exports.isCuid = isCuid; diff --git a/node_modules/@peculiar/asn1-android/LICENSE b/node_modules/@peculiar/asn1-android/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..81f990d60e3f91b8ecd127724ba7443acd379b49 --- /dev/null +++ b/node_modules/@peculiar/asn1-android/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@peculiar/asn1-android/README.md b/node_modules/@peculiar/asn1-android/README.md new file mode 100644 index 0000000000000000000000000000000000000000..3cc212a83febb1e7fa293cdc0d893686a90cc69c --- /dev/null +++ b/node_modules/@peculiar/asn1-android/README.md @@ -0,0 +1,120 @@ +# `@peculiar/asn1-android` + +[![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/PeculiarVentures/asn1-schema/blob/master/packages/android/LICENSE) +[![npm version](https://badge.fury.io/js/%40peculiar%2Fasn1-android.svg)](https://badge.fury.io/js/%40peculiar%2Fasn1-android) + +[![NPM](https://nodei.co/npm/@peculiar/asn1-android.png)](https://nodei.co/npm/@peculiar/asn1-android/) + +ASN.1 schema for Android key attestation extensions, including legacy Keymaster and newer KeyMint structures. + +Use the exported classes with `@peculiar/asn1-schema` helpers such as `AsnConvert`, `AsnParser`, and `AsnSerializer` to parse or serialize DER-encoded data defined by the referenced specification. + +## Installation + +```bash +npm install @peculiar/asn1-android +``` + +## Specifications + +- [Android key attestation schema](https://source.android.com/security/keystore/attestation#schema) +- [Key attestation extension data schema](https://developer.android.com/privacy-and-security/security-key-attestation#key_attestation_ext_schema) +- [AttestationApplicationId](https://developer.android.com/privacy-and-security/security-key-attestation#key_attestation_ext_schema_attestationid) + +## KeyDescription and NonStandardKeyDescription + +The `KeyDescription` class in this library represents the ASN.1 schema for the Android Keystore Key Description structure. However, in practice, there are cases where the `AuthorizationList` fields in the `softwareEnforced` and `teeEnforced` fields are not strictly ordered, which can lead to ASN.1 structure reading errors. + +Starting with version 300, the schema has been updated to use `keyMintVersion` instead of `keymasterVersion`, `keyMintSecurityLevel` instead of `keymasterSecurityLevel`, and `hardwareEnforced` instead of `teeEnforced`. To support this, we've added the `KeyMintKeyDescription` class which works for both v300 and v400. + +To address the non-strict ordering issue, this library provides `NonStandardKeyDescription` and `NonStandardKeyMintKeyDescription` classes that can read such structures. However, when creating extensions, it is recommended to use `KeyDescription` or `KeyMintKeyDescription`, as they guarantee the order of object fields according to the specification. + +Here are simplified TypeScript examples: + +Example of creating a `KeyDescription` object in TypeScript for the Android Keystore system + +```typescript +const attestation = new android.AttestationApplicationId({ + packageInfos: [ + new android.AttestationPackageInfo({ + packageName: new OctetString(Buffer.from("123", "utf8")), + version: 1, + }), + ], + signatureDigests: [new OctetString(Buffer.from("123", "utf8"))], +}); + +// Legacy KeyDescription +const keyDescription = new KeyDescription({ + attestationVersion: android.Version.keyMint2, + attestationSecurityLevel: android.SecurityLevel.software, + keymasterVersion: 1, + keymasterSecurityLevel: android.SecurityLevel.software, + attestationChallenge: new OctetString(Buffer.from("123", "utf8")), + uniqueId: new OctetString(Buffer.from("123", "utf8")), + softwareEnforced: new android.AuthorizationList({ + creationDateTime: 1506793476000, + attestationApplicationId: new OctetString(AsnConvert.serialize(attestation)), + }), + teeEnforced: new android.AuthorizationList({ + purpose: new android.IntegerSet([1]), + algorithm: 1, + keySize: 1, + digest: new android.IntegerSet([1]), + ecCurve: 1, + userAuthType: 1, + origin: 1, + rollbackResistant: null, + }), +}); + +// KeyMint KeyDescription (works for both v300 and v400) +const keyMintDescription = new KeyMintKeyDescription({ + attestationVersion: android.Version.keyMint4, // Use Version.keyMint3 for v300 + attestationSecurityLevel: android.SecurityLevel.software, + keyMintVersion: 1, + keyMintSecurityLevel: android.SecurityLevel.trustedEnvironment, + attestationChallenge: new OctetString(Buffer.from("challenge-data", "utf8")), + uniqueId: new OctetString(Buffer.from("unique-id-data", "utf8")), + softwareEnforced: new android.AuthorizationList({ + creationDateTime: 1684321765000, + }), + hardwareEnforced: new android.AuthorizationList({ + purpose: new android.IntegerSet([1, 2]), + algorithm: 3, // EC + keySize: 256, + attestationIdSecondImei: new OctetString(Buffer.from("second-imei", "utf8")), + moduleHash: new OctetString(Buffer.from("module-hash-value", "utf8")), // Available in v400 + rootOfTrust: new android.RootOfTrust({ + verifiedBootKey: new OctetString(Buffer.from("boot-key-data", "utf8")), + deviceLocked: true, + verifiedBootState: android.VerifiedBootState.verified, + verifiedBootHash: new OctetString(Buffer.from("boot-hash-data", "utf8")), // Required in v300 and above + }), + }), +}); + +const raw = AsnConvert.serialize(keyDescription); +const rawKeyMint = AsnConvert.serialize(keyMintDescription); +``` + +Example of reading a non-standard KeyDescription: + +```typescript +// Parse with appropriate class based on version +const keyDescription = AsnConvert.parse(raw, NonStandardKeyDescription); +const keyMintDescription = AsnConvert.parse(rawKeyMint, NonStandardKeyMintKeyDescription); // Works for both v300 and v400 + +// All versions support both old and new property names +console.log(keyMintDescription.keyMintVersion); // 1 +console.log(keyMintDescription.keymasterVersion); // Same as keyMintVersion (1) +console.log(keyMintDescription.hardwareEnforced === keyMintDescription.teeEnforced); // true + +// Check v400 specific fields +const moduleHash = keyMintDescription.hardwareEnforced.findProperty("moduleHash"); +console.log(moduleHash && Buffer.from(moduleHash).toString("utf8")); // "module-hash-value" + +// Converting between versions +const legacyFromKeyMint = keyMintDescription.toLegacyKeyDescription(); +const keyMintFromLegacy = KeyMintKeyDescription.fromLegacyKeyDescription(legacyFromKeyMint); +``` diff --git a/node_modules/@peculiar/asn1-android/build/cjs/attestation.js b/node_modules/@peculiar/asn1-android/build/cjs/attestation.js new file mode 100644 index 0000000000000000000000000000000000000000..97c67bd97943a2e3274f6c4af708b05dca0cbe9a --- /dev/null +++ b/node_modules/@peculiar/asn1-android/build/cjs/attestation.js @@ -0,0 +1,37 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AttestationApplicationId = exports.AttestationPackageInfo = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +class AttestationPackageInfo { + packageName; + version; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.AttestationPackageInfo = AttestationPackageInfo; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.OctetString }) +], AttestationPackageInfo.prototype, "packageName", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer }) +], AttestationPackageInfo.prototype, "version", void 0); +class AttestationApplicationId { + packageInfos; + signatureDigests; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.AttestationApplicationId = AttestationApplicationId; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: AttestationPackageInfo, repeated: "set", + }) +], AttestationApplicationId.prototype, "packageInfos", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.OctetString, repeated: "set", + }) +], AttestationApplicationId.prototype, "signatureDigests", void 0); diff --git a/node_modules/@peculiar/asn1-android/build/cjs/index.js b/node_modules/@peculiar/asn1-android/build/cjs/index.js new file mode 100644 index 0000000000000000000000000000000000000000..e13851a3da293ffca079ed8f2358c2548267656c --- /dev/null +++ b/node_modules/@peculiar/asn1-android/build/cjs/index.js @@ -0,0 +1,6 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +tslib_1.__exportStar(require("./key_description"), exports); +tslib_1.__exportStar(require("./nonstandard"), exports); +tslib_1.__exportStar(require("./attestation"), exports); diff --git a/node_modules/@peculiar/asn1-android/build/cjs/key_description.js b/node_modules/@peculiar/asn1-android/build/cjs/key_description.js new file mode 100644 index 0000000000000000000000000000000000000000..e70785e70ae4f4ed0ae59784e2d548c22f9698bf --- /dev/null +++ b/node_modules/@peculiar/asn1-android/build/cjs/key_description.js @@ -0,0 +1,431 @@ +"use strict"; +var IntegerSet_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KeyMintKeyDescription = exports.KeyDescription = exports.Version = exports.SecurityLevel = exports.AuthorizationList = exports.IntegerSet = exports.RootOfTrust = exports.VerifiedBootState = exports.id_ce_keyDescription = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +exports.id_ce_keyDescription = "1.3.6.1.4.1.11129.2.1.17"; +var VerifiedBootState; +(function (VerifiedBootState) { + VerifiedBootState[VerifiedBootState["verified"] = 0] = "verified"; + VerifiedBootState[VerifiedBootState["selfSigned"] = 1] = "selfSigned"; + VerifiedBootState[VerifiedBootState["unverified"] = 2] = "unverified"; + VerifiedBootState[VerifiedBootState["failed"] = 3] = "failed"; +})(VerifiedBootState || (exports.VerifiedBootState = VerifiedBootState = {})); +class RootOfTrust { + verifiedBootKey = new asn1_schema_1.OctetString(); + deviceLocked = false; + verifiedBootState = VerifiedBootState.verified; + verifiedBootHash; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.RootOfTrust = RootOfTrust; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.OctetString }) +], RootOfTrust.prototype, "verifiedBootKey", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Boolean }) +], RootOfTrust.prototype, "deviceLocked", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Enumerated }) +], RootOfTrust.prototype, "verifiedBootState", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.OctetString, optional: true, + }) +], RootOfTrust.prototype, "verifiedBootHash", void 0); +let IntegerSet = IntegerSet_1 = class IntegerSet extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, IntegerSet_1.prototype); + } +}; +exports.IntegerSet = IntegerSet; +exports.IntegerSet = IntegerSet = IntegerSet_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Set, itemType: asn1_schema_1.AsnPropTypes.Integer, + }) +], IntegerSet); +class AuthorizationList { + purpose; + algorithm; + keySize; + digest; + padding; + ecCurve; + rsaPublicExponent; + mgfDigest; + rollbackResistance; + earlyBootOnly; + activeDateTime; + originationExpireDateTime; + usageExpireDateTime; + usageCountLimit; + noAuthRequired; + userAuthType; + authTimeout; + allowWhileOnBody; + trustedUserPresenceRequired; + trustedConfirmationRequired; + unlockedDeviceRequired; + allApplications; + applicationId; + creationDateTime; + origin; + rollbackResistant; + rootOfTrust; + osVersion; + osPatchLevel; + attestationApplicationId; + attestationIdBrand; + attestationIdDevice; + attestationIdProduct; + attestationIdSerial; + attestationIdImei; + attestationIdMeid; + attestationIdManufacturer; + attestationIdModel; + vendorPatchLevel; + bootPatchLevel; + deviceUniqueAttestation; + attestationIdSecondImei; + moduleHash; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.AuthorizationList = AuthorizationList; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 1, type: IntegerSet, optional: true, + }) +], AuthorizationList.prototype, "purpose", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 2, type: asn1_schema_1.AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "algorithm", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 3, type: asn1_schema_1.AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "keySize", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 5, type: IntegerSet, optional: true, + }) +], AuthorizationList.prototype, "digest", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 6, type: IntegerSet, optional: true, + }) +], AuthorizationList.prototype, "padding", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 10, type: asn1_schema_1.AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "ecCurve", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 200, type: asn1_schema_1.AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "rsaPublicExponent", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 203, type: IntegerSet, optional: true, + }) +], AuthorizationList.prototype, "mgfDigest", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 303, type: asn1_schema_1.AsnPropTypes.Null, optional: true, + }) +], AuthorizationList.prototype, "rollbackResistance", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 305, type: asn1_schema_1.AsnPropTypes.Null, optional: true, + }) +], AuthorizationList.prototype, "earlyBootOnly", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 400, type: asn1_schema_1.AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "activeDateTime", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 401, type: asn1_schema_1.AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "originationExpireDateTime", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 402, type: asn1_schema_1.AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "usageExpireDateTime", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 405, type: asn1_schema_1.AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "usageCountLimit", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 503, type: asn1_schema_1.AsnPropTypes.Null, optional: true, + }) +], AuthorizationList.prototype, "noAuthRequired", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 504, type: asn1_schema_1.AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "userAuthType", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 505, type: asn1_schema_1.AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "authTimeout", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 506, type: asn1_schema_1.AsnPropTypes.Null, optional: true, + }) +], AuthorizationList.prototype, "allowWhileOnBody", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 507, type: asn1_schema_1.AsnPropTypes.Null, optional: true, + }) +], AuthorizationList.prototype, "trustedUserPresenceRequired", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 508, type: asn1_schema_1.AsnPropTypes.Null, optional: true, + }) +], AuthorizationList.prototype, "trustedConfirmationRequired", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 509, type: asn1_schema_1.AsnPropTypes.Null, optional: true, + }) +], AuthorizationList.prototype, "unlockedDeviceRequired", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 600, type: asn1_schema_1.AsnPropTypes.Null, optional: true, + }) +], AuthorizationList.prototype, "allApplications", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 601, type: asn1_schema_1.OctetString, optional: true, + }) +], AuthorizationList.prototype, "applicationId", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 701, type: asn1_schema_1.AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "creationDateTime", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 702, type: asn1_schema_1.AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "origin", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 703, type: asn1_schema_1.AsnPropTypes.Null, optional: true, + }) +], AuthorizationList.prototype, "rollbackResistant", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 704, type: RootOfTrust, optional: true, + }) +], AuthorizationList.prototype, "rootOfTrust", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 705, type: asn1_schema_1.AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "osVersion", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 706, type: asn1_schema_1.AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "osPatchLevel", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 709, type: asn1_schema_1.OctetString, optional: true, + }) +], AuthorizationList.prototype, "attestationApplicationId", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 710, type: asn1_schema_1.OctetString, optional: true, + }) +], AuthorizationList.prototype, "attestationIdBrand", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 711, type: asn1_schema_1.OctetString, optional: true, + }) +], AuthorizationList.prototype, "attestationIdDevice", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 712, type: asn1_schema_1.OctetString, optional: true, + }) +], AuthorizationList.prototype, "attestationIdProduct", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 713, type: asn1_schema_1.OctetString, optional: true, + }) +], AuthorizationList.prototype, "attestationIdSerial", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 714, type: asn1_schema_1.OctetString, optional: true, + }) +], AuthorizationList.prototype, "attestationIdImei", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 715, type: asn1_schema_1.OctetString, optional: true, + }) +], AuthorizationList.prototype, "attestationIdMeid", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 716, type: asn1_schema_1.OctetString, optional: true, + }) +], AuthorizationList.prototype, "attestationIdManufacturer", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 717, type: asn1_schema_1.OctetString, optional: true, + }) +], AuthorizationList.prototype, "attestationIdModel", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 718, type: asn1_schema_1.AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "vendorPatchLevel", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 719, type: asn1_schema_1.AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "bootPatchLevel", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 720, type: asn1_schema_1.AsnPropTypes.Null, optional: true, + }) +], AuthorizationList.prototype, "deviceUniqueAttestation", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 723, type: asn1_schema_1.OctetString, optional: true, + }) +], AuthorizationList.prototype, "attestationIdSecondImei", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + context: 724, type: asn1_schema_1.OctetString, optional: true, + }) +], AuthorizationList.prototype, "moduleHash", void 0); +var SecurityLevel; +(function (SecurityLevel) { + SecurityLevel[SecurityLevel["software"] = 0] = "software"; + SecurityLevel[SecurityLevel["trustedEnvironment"] = 1] = "trustedEnvironment"; + SecurityLevel[SecurityLevel["strongBox"] = 2] = "strongBox"; +})(SecurityLevel || (exports.SecurityLevel = SecurityLevel = {})); +var Version; +(function (Version) { + Version[Version["KM2"] = 1] = "KM2"; + Version[Version["KM3"] = 2] = "KM3"; + Version[Version["KM4"] = 3] = "KM4"; + Version[Version["KM4_1"] = 4] = "KM4_1"; + Version[Version["keyMint1"] = 100] = "keyMint1"; + Version[Version["keyMint2"] = 200] = "keyMint2"; + Version[Version["keyMint3"] = 300] = "keyMint3"; + Version[Version["keyMint4"] = 400] = "keyMint4"; +})(Version || (exports.Version = Version = {})); +class KeyDescription { + attestationVersion = Version.KM4; + attestationSecurityLevel = SecurityLevel.software; + keymasterVersion = 0; + keymasterSecurityLevel = SecurityLevel.software; + attestationChallenge = new asn1_schema_1.OctetString(); + uniqueId = new asn1_schema_1.OctetString(); + softwareEnforced = new AuthorizationList(); + teeEnforced = new AuthorizationList(); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.KeyDescription = KeyDescription; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer }) +], KeyDescription.prototype, "attestationVersion", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Enumerated }) +], KeyDescription.prototype, "attestationSecurityLevel", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer }) +], KeyDescription.prototype, "keymasterVersion", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Enumerated }) +], KeyDescription.prototype, "keymasterSecurityLevel", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.OctetString }) +], KeyDescription.prototype, "attestationChallenge", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.OctetString }) +], KeyDescription.prototype, "uniqueId", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: AuthorizationList }) +], KeyDescription.prototype, "softwareEnforced", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: AuthorizationList }) +], KeyDescription.prototype, "teeEnforced", void 0); +class KeyMintKeyDescription { + attestationVersion = Version.keyMint4; + attestationSecurityLevel = SecurityLevel.software; + keyMintVersion = 0; + keyMintSecurityLevel = SecurityLevel.software; + attestationChallenge = new asn1_schema_1.OctetString(); + uniqueId = new asn1_schema_1.OctetString(); + softwareEnforced = new AuthorizationList(); + hardwareEnforced = new AuthorizationList(); + constructor(params = {}) { + Object.assign(this, params); + } + toLegacyKeyDescription() { + return new KeyDescription({ + attestationVersion: this.attestationVersion, + attestationSecurityLevel: this.attestationSecurityLevel, + keymasterVersion: this.keyMintVersion, + keymasterSecurityLevel: this.keyMintSecurityLevel, + attestationChallenge: this.attestationChallenge, + uniqueId: this.uniqueId, + softwareEnforced: this.softwareEnforced, + teeEnforced: this.hardwareEnforced, + }); + } + static fromLegacyKeyDescription(keyDesc) { + return new KeyMintKeyDescription({ + attestationVersion: keyDesc.attestationVersion, + attestationSecurityLevel: keyDesc.attestationSecurityLevel, + keyMintVersion: keyDesc.keymasterVersion, + keyMintSecurityLevel: keyDesc.keymasterSecurityLevel, + attestationChallenge: keyDesc.attestationChallenge, + uniqueId: keyDesc.uniqueId, + softwareEnforced: keyDesc.softwareEnforced, + hardwareEnforced: keyDesc.teeEnforced, + }); + } +} +exports.KeyMintKeyDescription = KeyMintKeyDescription; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer }) +], KeyMintKeyDescription.prototype, "attestationVersion", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Enumerated }) +], KeyMintKeyDescription.prototype, "attestationSecurityLevel", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer }) +], KeyMintKeyDescription.prototype, "keyMintVersion", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Enumerated }) +], KeyMintKeyDescription.prototype, "keyMintSecurityLevel", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.OctetString }) +], KeyMintKeyDescription.prototype, "attestationChallenge", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.OctetString }) +], KeyMintKeyDescription.prototype, "uniqueId", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: AuthorizationList }) +], KeyMintKeyDescription.prototype, "softwareEnforced", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: AuthorizationList }) +], KeyMintKeyDescription.prototype, "hardwareEnforced", void 0); diff --git a/node_modules/@peculiar/asn1-android/build/cjs/nonstandard.js b/node_modules/@peculiar/asn1-android/build/cjs/nonstandard.js new file mode 100644 index 0000000000000000000000000000000000000000..27d80ff75ed23135a57a4adbe658d2cbd68102b3 --- /dev/null +++ b/node_modules/@peculiar/asn1-android/build/cjs/nonstandard.js @@ -0,0 +1,106 @@ +"use strict"; +var NonStandardAuthorizationList_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.NonStandardKeyMintKeyDescription = exports.NonStandardKeyDescription = exports.NonStandardAuthorizationList = exports.NonStandardAuthorization = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const key_description_1 = require("./key_description"); +let NonStandardAuthorization = class NonStandardAuthorization extends key_description_1.AuthorizationList { +}; +exports.NonStandardAuthorization = NonStandardAuthorization; +exports.NonStandardAuthorization = NonStandardAuthorization = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], NonStandardAuthorization); +let NonStandardAuthorizationList = NonStandardAuthorizationList_1 = class NonStandardAuthorizationList extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, NonStandardAuthorizationList_1.prototype); + } + findProperty(key) { + const prop = this.find((o) => o[key] !== undefined); + if (prop) { + return prop[key]; + } + return undefined; + } +}; +exports.NonStandardAuthorizationList = NonStandardAuthorizationList; +exports.NonStandardAuthorizationList = NonStandardAuthorizationList = NonStandardAuthorizationList_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Sequence, itemType: NonStandardAuthorization, + }) +], NonStandardAuthorizationList); +class NonStandardKeyDescription { + attestationVersion = key_description_1.Version.KM4; + attestationSecurityLevel = key_description_1.SecurityLevel.software; + keymasterVersion = 0; + keymasterSecurityLevel = key_description_1.SecurityLevel.software; + attestationChallenge = new asn1_schema_1.OctetString(); + uniqueId = new asn1_schema_1.OctetString(); + softwareEnforced = new NonStandardAuthorizationList(); + teeEnforced = new NonStandardAuthorizationList(); + get keyMintVersion() { + return this.keymasterVersion; + } + set keyMintVersion(value) { + this.keymasterVersion = value; + } + get keyMintSecurityLevel() { + return this.keymasterSecurityLevel; + } + set keyMintSecurityLevel(value) { + this.keymasterSecurityLevel = value; + } + get hardwareEnforced() { + return this.teeEnforced; + } + set hardwareEnforced(value) { + this.teeEnforced = value; + } + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.NonStandardKeyDescription = NonStandardKeyDescription; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer }) +], NonStandardKeyDescription.prototype, "attestationVersion", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Enumerated }) +], NonStandardKeyDescription.prototype, "attestationSecurityLevel", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer }) +], NonStandardKeyDescription.prototype, "keymasterVersion", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Enumerated }) +], NonStandardKeyDescription.prototype, "keymasterSecurityLevel", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.OctetString }) +], NonStandardKeyDescription.prototype, "attestationChallenge", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.OctetString }) +], NonStandardKeyDescription.prototype, "uniqueId", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: NonStandardAuthorizationList }) +], NonStandardKeyDescription.prototype, "softwareEnforced", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: NonStandardAuthorizationList }) +], NonStandardKeyDescription.prototype, "teeEnforced", void 0); +let NonStandardKeyMintKeyDescription = class NonStandardKeyMintKeyDescription extends NonStandardKeyDescription { + constructor(params = {}) { + if ("keymasterVersion" in params && !("keyMintVersion" in params)) { + params.keyMintVersion = params.keymasterVersion; + } + if ("keymasterSecurityLevel" in params && !("keyMintSecurityLevel" in params)) { + params.keyMintSecurityLevel = params.keymasterSecurityLevel; + } + if ("teeEnforced" in params && !("hardwareEnforced" in params)) { + params.hardwareEnforced = params.teeEnforced; + } + super(params); + } +}; +exports.NonStandardKeyMintKeyDescription = NonStandardKeyMintKeyDescription; +exports.NonStandardKeyMintKeyDescription = NonStandardKeyMintKeyDescription = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Sequence }) +], NonStandardKeyMintKeyDescription); diff --git a/node_modules/@peculiar/asn1-android/build/es2015/attestation.js b/node_modules/@peculiar/asn1-android/build/es2015/attestation.js new file mode 100644 index 0000000000000000000000000000000000000000..b39b1c484a0981f2affe558fca4f3368b88a3a18 --- /dev/null +++ b/node_modules/@peculiar/asn1-android/build/es2015/attestation.js @@ -0,0 +1,32 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, } from "@peculiar/asn1-schema"; +export class AttestationPackageInfo { + packageName; + version; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.OctetString }) +], AttestationPackageInfo.prototype, "packageName", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.Integer }) +], AttestationPackageInfo.prototype, "version", void 0); +export class AttestationApplicationId { + packageInfos; + signatureDigests; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ + type: AttestationPackageInfo, repeated: "set", + }) +], AttestationApplicationId.prototype, "packageInfos", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.OctetString, repeated: "set", + }) +], AttestationApplicationId.prototype, "signatureDigests", void 0); diff --git a/node_modules/@peculiar/asn1-android/build/es2015/index.js b/node_modules/@peculiar/asn1-android/build/es2015/index.js new file mode 100644 index 0000000000000000000000000000000000000000..42fb6f6a02ccc11e2e07eaf005a7f23c872f0255 --- /dev/null +++ b/node_modules/@peculiar/asn1-android/build/es2015/index.js @@ -0,0 +1,3 @@ +export * from "./key_description.js"; +export * from "./nonstandard.js"; +export * from "./attestation.js"; diff --git a/node_modules/@peculiar/asn1-android/build/es2015/key_description.js b/node_modules/@peculiar/asn1-android/build/es2015/key_description.js new file mode 100644 index 0000000000000000000000000000000000000000..b1bf46533113279293ae88c0792e91d8a9acb3ad --- /dev/null +++ b/node_modules/@peculiar/asn1-android/build/es2015/key_description.js @@ -0,0 +1,424 @@ +var IntegerSet_1; +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnArray, AsnType, AsnTypeTypes, OctetString, } from "@peculiar/asn1-schema"; +export const id_ce_keyDescription = "1.3.6.1.4.1.11129.2.1.17"; +export var VerifiedBootState; +(function (VerifiedBootState) { + VerifiedBootState[VerifiedBootState["verified"] = 0] = "verified"; + VerifiedBootState[VerifiedBootState["selfSigned"] = 1] = "selfSigned"; + VerifiedBootState[VerifiedBootState["unverified"] = 2] = "unverified"; + VerifiedBootState[VerifiedBootState["failed"] = 3] = "failed"; +})(VerifiedBootState || (VerifiedBootState = {})); +export class RootOfTrust { + verifiedBootKey = new OctetString(); + deviceLocked = false; + verifiedBootState = VerifiedBootState.verified; + verifiedBootHash; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: OctetString }) +], RootOfTrust.prototype, "verifiedBootKey", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.Boolean }) +], RootOfTrust.prototype, "deviceLocked", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.Enumerated }) +], RootOfTrust.prototype, "verifiedBootState", void 0); +__decorate([ + AsnProp({ + type: OctetString, optional: true, + }) +], RootOfTrust.prototype, "verifiedBootHash", void 0); +let IntegerSet = IntegerSet_1 = class IntegerSet extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, IntegerSet_1.prototype); + } +}; +IntegerSet = IntegerSet_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Set, itemType: AsnPropTypes.Integer, + }) +], IntegerSet); +export { IntegerSet }; +export class AuthorizationList { + purpose; + algorithm; + keySize; + digest; + padding; + ecCurve; + rsaPublicExponent; + mgfDigest; + rollbackResistance; + earlyBootOnly; + activeDateTime; + originationExpireDateTime; + usageExpireDateTime; + usageCountLimit; + noAuthRequired; + userAuthType; + authTimeout; + allowWhileOnBody; + trustedUserPresenceRequired; + trustedConfirmationRequired; + unlockedDeviceRequired; + allApplications; + applicationId; + creationDateTime; + origin; + rollbackResistant; + rootOfTrust; + osVersion; + osPatchLevel; + attestationApplicationId; + attestationIdBrand; + attestationIdDevice; + attestationIdProduct; + attestationIdSerial; + attestationIdImei; + attestationIdMeid; + attestationIdManufacturer; + attestationIdModel; + vendorPatchLevel; + bootPatchLevel; + deviceUniqueAttestation; + attestationIdSecondImei; + moduleHash; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ + context: 1, type: IntegerSet, optional: true, + }) +], AuthorizationList.prototype, "purpose", void 0); +__decorate([ + AsnProp({ + context: 2, type: AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "algorithm", void 0); +__decorate([ + AsnProp({ + context: 3, type: AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "keySize", void 0); +__decorate([ + AsnProp({ + context: 5, type: IntegerSet, optional: true, + }) +], AuthorizationList.prototype, "digest", void 0); +__decorate([ + AsnProp({ + context: 6, type: IntegerSet, optional: true, + }) +], AuthorizationList.prototype, "padding", void 0); +__decorate([ + AsnProp({ + context: 10, type: AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "ecCurve", void 0); +__decorate([ + AsnProp({ + context: 200, type: AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "rsaPublicExponent", void 0); +__decorate([ + AsnProp({ + context: 203, type: IntegerSet, optional: true, + }) +], AuthorizationList.prototype, "mgfDigest", void 0); +__decorate([ + AsnProp({ + context: 303, type: AsnPropTypes.Null, optional: true, + }) +], AuthorizationList.prototype, "rollbackResistance", void 0); +__decorate([ + AsnProp({ + context: 305, type: AsnPropTypes.Null, optional: true, + }) +], AuthorizationList.prototype, "earlyBootOnly", void 0); +__decorate([ + AsnProp({ + context: 400, type: AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "activeDateTime", void 0); +__decorate([ + AsnProp({ + context: 401, type: AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "originationExpireDateTime", void 0); +__decorate([ + AsnProp({ + context: 402, type: AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "usageExpireDateTime", void 0); +__decorate([ + AsnProp({ + context: 405, type: AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "usageCountLimit", void 0); +__decorate([ + AsnProp({ + context: 503, type: AsnPropTypes.Null, optional: true, + }) +], AuthorizationList.prototype, "noAuthRequired", void 0); +__decorate([ + AsnProp({ + context: 504, type: AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "userAuthType", void 0); +__decorate([ + AsnProp({ + context: 505, type: AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "authTimeout", void 0); +__decorate([ + AsnProp({ + context: 506, type: AsnPropTypes.Null, optional: true, + }) +], AuthorizationList.prototype, "allowWhileOnBody", void 0); +__decorate([ + AsnProp({ + context: 507, type: AsnPropTypes.Null, optional: true, + }) +], AuthorizationList.prototype, "trustedUserPresenceRequired", void 0); +__decorate([ + AsnProp({ + context: 508, type: AsnPropTypes.Null, optional: true, + }) +], AuthorizationList.prototype, "trustedConfirmationRequired", void 0); +__decorate([ + AsnProp({ + context: 509, type: AsnPropTypes.Null, optional: true, + }) +], AuthorizationList.prototype, "unlockedDeviceRequired", void 0); +__decorate([ + AsnProp({ + context: 600, type: AsnPropTypes.Null, optional: true, + }) +], AuthorizationList.prototype, "allApplications", void 0); +__decorate([ + AsnProp({ + context: 601, type: OctetString, optional: true, + }) +], AuthorizationList.prototype, "applicationId", void 0); +__decorate([ + AsnProp({ + context: 701, type: AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "creationDateTime", void 0); +__decorate([ + AsnProp({ + context: 702, type: AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "origin", void 0); +__decorate([ + AsnProp({ + context: 703, type: AsnPropTypes.Null, optional: true, + }) +], AuthorizationList.prototype, "rollbackResistant", void 0); +__decorate([ + AsnProp({ + context: 704, type: RootOfTrust, optional: true, + }) +], AuthorizationList.prototype, "rootOfTrust", void 0); +__decorate([ + AsnProp({ + context: 705, type: AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "osVersion", void 0); +__decorate([ + AsnProp({ + context: 706, type: AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "osPatchLevel", void 0); +__decorate([ + AsnProp({ + context: 709, type: OctetString, optional: true, + }) +], AuthorizationList.prototype, "attestationApplicationId", void 0); +__decorate([ + AsnProp({ + context: 710, type: OctetString, optional: true, + }) +], AuthorizationList.prototype, "attestationIdBrand", void 0); +__decorate([ + AsnProp({ + context: 711, type: OctetString, optional: true, + }) +], AuthorizationList.prototype, "attestationIdDevice", void 0); +__decorate([ + AsnProp({ + context: 712, type: OctetString, optional: true, + }) +], AuthorizationList.prototype, "attestationIdProduct", void 0); +__decorate([ + AsnProp({ + context: 713, type: OctetString, optional: true, + }) +], AuthorizationList.prototype, "attestationIdSerial", void 0); +__decorate([ + AsnProp({ + context: 714, type: OctetString, optional: true, + }) +], AuthorizationList.prototype, "attestationIdImei", void 0); +__decorate([ + AsnProp({ + context: 715, type: OctetString, optional: true, + }) +], AuthorizationList.prototype, "attestationIdMeid", void 0); +__decorate([ + AsnProp({ + context: 716, type: OctetString, optional: true, + }) +], AuthorizationList.prototype, "attestationIdManufacturer", void 0); +__decorate([ + AsnProp({ + context: 717, type: OctetString, optional: true, + }) +], AuthorizationList.prototype, "attestationIdModel", void 0); +__decorate([ + AsnProp({ + context: 718, type: AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "vendorPatchLevel", void 0); +__decorate([ + AsnProp({ + context: 719, type: AsnPropTypes.Integer, optional: true, + }) +], AuthorizationList.prototype, "bootPatchLevel", void 0); +__decorate([ + AsnProp({ + context: 720, type: AsnPropTypes.Null, optional: true, + }) +], AuthorizationList.prototype, "deviceUniqueAttestation", void 0); +__decorate([ + AsnProp({ + context: 723, type: OctetString, optional: true, + }) +], AuthorizationList.prototype, "attestationIdSecondImei", void 0); +__decorate([ + AsnProp({ + context: 724, type: OctetString, optional: true, + }) +], AuthorizationList.prototype, "moduleHash", void 0); +export var SecurityLevel; +(function (SecurityLevel) { + SecurityLevel[SecurityLevel["software"] = 0] = "software"; + SecurityLevel[SecurityLevel["trustedEnvironment"] = 1] = "trustedEnvironment"; + SecurityLevel[SecurityLevel["strongBox"] = 2] = "strongBox"; +})(SecurityLevel || (SecurityLevel = {})); +export var Version; +(function (Version) { + Version[Version["KM2"] = 1] = "KM2"; + Version[Version["KM3"] = 2] = "KM3"; + Version[Version["KM4"] = 3] = "KM4"; + Version[Version["KM4_1"] = 4] = "KM4_1"; + Version[Version["keyMint1"] = 100] = "keyMint1"; + Version[Version["keyMint2"] = 200] = "keyMint2"; + Version[Version["keyMint3"] = 300] = "keyMint3"; + Version[Version["keyMint4"] = 400] = "keyMint4"; +})(Version || (Version = {})); +export class KeyDescription { + attestationVersion = Version.KM4; + attestationSecurityLevel = SecurityLevel.software; + keymasterVersion = 0; + keymasterSecurityLevel = SecurityLevel.software; + attestationChallenge = new OctetString(); + uniqueId = new OctetString(); + softwareEnforced = new AuthorizationList(); + teeEnforced = new AuthorizationList(); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.Integer }) +], KeyDescription.prototype, "attestationVersion", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.Enumerated }) +], KeyDescription.prototype, "attestationSecurityLevel", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.Integer }) +], KeyDescription.prototype, "keymasterVersion", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.Enumerated }) +], KeyDescription.prototype, "keymasterSecurityLevel", void 0); +__decorate([ + AsnProp({ type: OctetString }) +], KeyDescription.prototype, "attestationChallenge", void 0); +__decorate([ + AsnProp({ type: OctetString }) +], KeyDescription.prototype, "uniqueId", void 0); +__decorate([ + AsnProp({ type: AuthorizationList }) +], KeyDescription.prototype, "softwareEnforced", void 0); +__decorate([ + AsnProp({ type: AuthorizationList }) +], KeyDescription.prototype, "teeEnforced", void 0); +export class KeyMintKeyDescription { + attestationVersion = Version.keyMint4; + attestationSecurityLevel = SecurityLevel.software; + keyMintVersion = 0; + keyMintSecurityLevel = SecurityLevel.software; + attestationChallenge = new OctetString(); + uniqueId = new OctetString(); + softwareEnforced = new AuthorizationList(); + hardwareEnforced = new AuthorizationList(); + constructor(params = {}) { + Object.assign(this, params); + } + toLegacyKeyDescription() { + return new KeyDescription({ + attestationVersion: this.attestationVersion, + attestationSecurityLevel: this.attestationSecurityLevel, + keymasterVersion: this.keyMintVersion, + keymasterSecurityLevel: this.keyMintSecurityLevel, + attestationChallenge: this.attestationChallenge, + uniqueId: this.uniqueId, + softwareEnforced: this.softwareEnforced, + teeEnforced: this.hardwareEnforced, + }); + } + static fromLegacyKeyDescription(keyDesc) { + return new KeyMintKeyDescription({ + attestationVersion: keyDesc.attestationVersion, + attestationSecurityLevel: keyDesc.attestationSecurityLevel, + keyMintVersion: keyDesc.keymasterVersion, + keyMintSecurityLevel: keyDesc.keymasterSecurityLevel, + attestationChallenge: keyDesc.attestationChallenge, + uniqueId: keyDesc.uniqueId, + softwareEnforced: keyDesc.softwareEnforced, + hardwareEnforced: keyDesc.teeEnforced, + }); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.Integer }) +], KeyMintKeyDescription.prototype, "attestationVersion", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.Enumerated }) +], KeyMintKeyDescription.prototype, "attestationSecurityLevel", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.Integer }) +], KeyMintKeyDescription.prototype, "keyMintVersion", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.Enumerated }) +], KeyMintKeyDescription.prototype, "keyMintSecurityLevel", void 0); +__decorate([ + AsnProp({ type: OctetString }) +], KeyMintKeyDescription.prototype, "attestationChallenge", void 0); +__decorate([ + AsnProp({ type: OctetString }) +], KeyMintKeyDescription.prototype, "uniqueId", void 0); +__decorate([ + AsnProp({ type: AuthorizationList }) +], KeyMintKeyDescription.prototype, "softwareEnforced", void 0); +__decorate([ + AsnProp({ type: AuthorizationList }) +], KeyMintKeyDescription.prototype, "hardwareEnforced", void 0); diff --git a/node_modules/@peculiar/asn1-android/build/es2015/nonstandard.js b/node_modules/@peculiar/asn1-android/build/es2015/nonstandard.js new file mode 100644 index 0000000000000000000000000000000000000000..740af5b7a0dc493c028889a29f4dacaa9fc62595 --- /dev/null +++ b/node_modules/@peculiar/asn1-android/build/es2015/nonstandard.js @@ -0,0 +1,102 @@ +var NonStandardAuthorizationList_1; +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnArray, AsnType, AsnTypeTypes, OctetString, } from "@peculiar/asn1-schema"; +import { AuthorizationList, SecurityLevel, Version, } from "./key_description.js"; +let NonStandardAuthorization = class NonStandardAuthorization extends AuthorizationList { +}; +NonStandardAuthorization = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], NonStandardAuthorization); +export { NonStandardAuthorization }; +let NonStandardAuthorizationList = NonStandardAuthorizationList_1 = class NonStandardAuthorizationList extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, NonStandardAuthorizationList_1.prototype); + } + findProperty(key) { + const prop = this.find((o) => o[key] !== undefined); + if (prop) { + return prop[key]; + } + return undefined; + } +}; +NonStandardAuthorizationList = NonStandardAuthorizationList_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Sequence, itemType: NonStandardAuthorization, + }) +], NonStandardAuthorizationList); +export { NonStandardAuthorizationList }; +export class NonStandardKeyDescription { + attestationVersion = Version.KM4; + attestationSecurityLevel = SecurityLevel.software; + keymasterVersion = 0; + keymasterSecurityLevel = SecurityLevel.software; + attestationChallenge = new OctetString(); + uniqueId = new OctetString(); + softwareEnforced = new NonStandardAuthorizationList(); + teeEnforced = new NonStandardAuthorizationList(); + get keyMintVersion() { + return this.keymasterVersion; + } + set keyMintVersion(value) { + this.keymasterVersion = value; + } + get keyMintSecurityLevel() { + return this.keymasterSecurityLevel; + } + set keyMintSecurityLevel(value) { + this.keymasterSecurityLevel = value; + } + get hardwareEnforced() { + return this.teeEnforced; + } + set hardwareEnforced(value) { + this.teeEnforced = value; + } + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.Integer }) +], NonStandardKeyDescription.prototype, "attestationVersion", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.Enumerated }) +], NonStandardKeyDescription.prototype, "attestationSecurityLevel", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.Integer }) +], NonStandardKeyDescription.prototype, "keymasterVersion", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.Enumerated }) +], NonStandardKeyDescription.prototype, "keymasterSecurityLevel", void 0); +__decorate([ + AsnProp({ type: OctetString }) +], NonStandardKeyDescription.prototype, "attestationChallenge", void 0); +__decorate([ + AsnProp({ type: OctetString }) +], NonStandardKeyDescription.prototype, "uniqueId", void 0); +__decorate([ + AsnProp({ type: NonStandardAuthorizationList }) +], NonStandardKeyDescription.prototype, "softwareEnforced", void 0); +__decorate([ + AsnProp({ type: NonStandardAuthorizationList }) +], NonStandardKeyDescription.prototype, "teeEnforced", void 0); +let NonStandardKeyMintKeyDescription = class NonStandardKeyMintKeyDescription extends NonStandardKeyDescription { + constructor(params = {}) { + if ("keymasterVersion" in params && !("keyMintVersion" in params)) { + params.keyMintVersion = params.keymasterVersion; + } + if ("keymasterSecurityLevel" in params && !("keyMintSecurityLevel" in params)) { + params.keyMintSecurityLevel = params.keymasterSecurityLevel; + } + if ("teeEnforced" in params && !("hardwareEnforced" in params)) { + params.hardwareEnforced = params.teeEnforced; + } + super(params); + } +}; +NonStandardKeyMintKeyDescription = __decorate([ + AsnType({ type: AsnTypeTypes.Sequence }) +], NonStandardKeyMintKeyDescription); +export { NonStandardKeyMintKeyDescription }; diff --git a/node_modules/@peculiar/asn1-android/build/es2015/package.json b/node_modules/@peculiar/asn1-android/build/es2015/package.json new file mode 100644 index 0000000000000000000000000000000000000000..3dbc1ca591c0557e35b6004aeba250e6a70b56e3 --- /dev/null +++ b/node_modules/@peculiar/asn1-android/build/es2015/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/node_modules/@peculiar/asn1-android/build/types/attestation.d.ts b/node_modules/@peculiar/asn1-android/build/types/attestation.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..43d4a7d45cd93d6ca55ce2e53f49d78e7871647f --- /dev/null +++ b/node_modules/@peculiar/asn1-android/build/types/attestation.d.ts @@ -0,0 +1,31 @@ +import { OctetString } from "@peculiar/asn1-schema"; +/** + * Implements ASN.1 structure for attestation package info. + * + * ```asn + * AttestationPackageInfo ::= SEQUENCE { + * package_name OCTET_STRING, + * version INTEGER, + * } + * ``` + */ +export declare class AttestationPackageInfo { + packageName: OctetString; + version: number; + constructor(params?: Partial); +} +/** + * Implements ASN.1 structure for attestation application id. + * + * ```asn + * AttestationApplicationId ::= SEQUENCE { + * package_infos SET OF AttestationPackageInfo, + * signature_digests SET OF OCTET_STRING, + * } + * ``` + */ +export declare class AttestationApplicationId { + packageInfos: AttestationPackageInfo[]; + signatureDigests: OctetString[]; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-android/build/types/index.d.ts b/node_modules/@peculiar/asn1-android/build/types/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3d27a1485388293757659db695b2a447814fd99 --- /dev/null +++ b/node_modules/@peculiar/asn1-android/build/types/index.d.ts @@ -0,0 +1,3 @@ +export * from "./key_description"; +export * from "./nonstandard"; +export * from "./attestation"; diff --git a/node_modules/@peculiar/asn1-android/build/types/key_description.d.ts b/node_modules/@peculiar/asn1-android/build/types/key_description.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..02fc62277620293668f5f5310f1d0d8815bc77bb --- /dev/null +++ b/node_modules/@peculiar/asn1-android/build/types/key_description.d.ts @@ -0,0 +1,244 @@ +import { AsnArray, OctetString } from "@peculiar/asn1-schema"; +/** + * Extension OID for key description. + * + * ```asn + * id-ce-keyDescription OBJECT IDENTIFIER ::= { 1 3 6 1 4 1 11129 2 1 17 } + * ``` + */ +export declare const id_ce_keyDescription = "1.3.6.1.4.1.11129.2.1.17"; +/** + * Implements ASN.1 enumeration for verified boot state. + * + * ```asn + * VerifiedBootState ::= ENUMERATED { + * Verified (0), + * SelfSigned (1), + * Unverified (2), + * Failed (3), + * } + * ``` + */ +export declare enum VerifiedBootState { + verified = 0, + selfSigned = 1, + unverified = 2, + failed = 3 +} +/** + * Implements ASN.1 structure for root of trust. + * + * ```asn + * RootOfTrust ::= SEQUENCE { + * verifiedBootKey OCTET_STRING, + * deviceLocked BOOLEAN, + * verifiedBootState VerifiedBootState, + * verifiedBootHash OCTET_STRING, # KM4 + * } + * ``` + */ +export declare class RootOfTrust { + verifiedBootKey: OctetString; + deviceLocked: boolean; + verifiedBootState: VerifiedBootState; + /** + * `verifiedBootHash` must present in `KeyDescription` version 3 + */ + verifiedBootHash?: OctetString; + constructor(params?: Partial); +} +/** + * Implements ASN.1 structure for set of integers. + * + * ```asn + * IntegerSet ::= SET OF INTEGER + * ``` + */ +export declare class IntegerSet extends AsnArray { + constructor(items?: number[]); +} +/** + * Implements ASN.1 structure for authorization list. + * + * ```asn + * AuthorizationList ::= SEQUENCE { + * purpose [1] EXPLICIT SET OF INTEGER OPTIONAL, + * algorithm [2] EXPLICIT INTEGER OPTIONAL, + * keySize [3] EXPLICIT INTEGER OPTIONAL. + * digest [5] EXPLICIT SET OF INTEGER OPTIONAL, + * padding [6] EXPLICIT SET OF INTEGER OPTIONAL, + * ecCurve [10] EXPLICIT INTEGER OPTIONAL, + * rsaPublicExponent [200] EXPLICIT INTEGER OPTIONAL, + * mgfDigest [203] EXPLICIT SET OF INTEGER OPTIONAL, + * rollbackResistance [303] EXPLICIT NULL OPTIONAL, # KM4 + * earlyBootOnly [305] EXPLICIT NULL OPTIONAL, # version 4 + * activeDateTime [400] EXPLICIT INTEGER OPTIONAL + * originationExpireDateTime [401] EXPLICIT INTEGER OPTIONAL + * usageExpireDateTime [402] EXPLICIT INTEGER OPTIONAL + * usageCountLimit [405] EXPLICIT INTEGER OPTIONAL, + * noAuthRequired [503] EXPLICIT NULL OPTIONAL, + * userAuthType [504] EXPLICIT INTEGER OPTIONAL, + * authTimeout [505] EXPLICIT INTEGER OPTIONAL, + * allowWhileOnBody [506] EXPLICIT NULL OPTIONAL, + * trustedUserPresenceRequired [507] EXPLICIT NULL OPTIONAL, # KM4 + * trustedConfirmationRequired [508] EXPLICIT NULL OPTIONAL, # KM4 + * unlockedDeviceRequired [509] EXPLICIT NULL OPTIONAL, # KM4 + * allApplications [600] EXPLICIT NULL OPTIONAL, + * applicationId [601] EXPLICIT OCTET_STRING OPTIONAL, + * creationDateTime [701] EXPLICIT INTEGER OPTIONAL, + * origin [702] EXPLICIT INTEGER OPTIONAL, + * rollbackResistant [703] EXPLICIT NULL OPTIONAL, # KM2 and KM3 only. + * rootOfTrust [704] EXPLICIT RootOfTrust OPTIONAL, + * osVersion [705] EXPLICIT INTEGER OPTIONAL, + * osPatchLevel [706] EXPLICIT INTEGER OPTIONAL, + * attestationApplicationId [709] EXPLICIT OCTET_STRING OPTIONAL, # KM3 + * attestationIdBrand [710] EXPLICIT OCTET_STRING OPTIONAL, # KM3 + * attestationIdDevice [711] EXPLICIT OCTET_STRING OPTIONAL, # KM3 + * attestationIdProduct [712] EXPLICIT OCTET_STRING OPTIONAL, # KM3 + * attestationIdSerial [713] EXPLICIT OCTET_STRING OPTIONAL, # KM3 + * attestationIdImei [714] EXPLICIT OCTET_STRING OPTIONAL, # KM3 + * attestationIdMeid [715] EXPLICIT OCTET_STRING OPTIONAL, # KM3 + * attestationIdManufacturer [716] EXPLICIT OCTET_STRING OPTIONAL, # KM3 + * attestationIdModel [717] EXPLICIT OCTET_STRING OPTIONAL, # KM3 + * vendorPatchLevel [718] EXPLICIT INTEGER OPTIONAL, # KM4 + * bootPatchLevel [719] EXPLICIT INTEGER OPTIONAL, # KM4 + * deviceUniqueAttestation [720] EXPLICIT NULL OPTIONAL, # version 4 + * attestationIdSecondImei [723] EXPLICIT OCTET_STRING OPTIONAL, + * moduleHash [724] EXPLICIT OCTET_STRING OPTIONAL, + * } + * ``` + */ +export declare class AuthorizationList { + purpose?: IntegerSet; + algorithm?: number; + keySize?: number; + digest?: IntegerSet; + padding?: IntegerSet; + ecCurve?: number; + rsaPublicExponent?: number; + mgfDigest?: IntegerSet; + rollbackResistance?: null; + earlyBootOnly?: null; + activeDateTime?: number; + originationExpireDateTime?: number; + usageExpireDateTime?: number; + usageCountLimit?: number; + noAuthRequired?: null; + userAuthType?: number; + authTimeout?: number; + allowWhileOnBody?: null; + trustedUserPresenceRequired?: null; + trustedConfirmationRequired?: null; + unlockedDeviceRequired?: null; + allApplications?: null; + applicationId?: OctetString; + creationDateTime?: number; + origin?: number; + rollbackResistant?: null; + rootOfTrust?: RootOfTrust; + osVersion?: number; + osPatchLevel?: number; + attestationApplicationId?: OctetString; + attestationIdBrand?: OctetString; + attestationIdDevice?: OctetString; + attestationIdProduct?: OctetString; + attestationIdSerial?: OctetString; + attestationIdImei?: OctetString; + attestationIdMeid?: OctetString; + attestationIdManufacturer?: OctetString; + attestationIdModel?: OctetString; + vendorPatchLevel?: number; + bootPatchLevel?: number; + deviceUniqueAttestation?: null; + attestationIdSecondImei?: OctetString; + moduleHash?: OctetString; + constructor(params?: Partial); +} +/** + * Implements ASN.1 structure for security level. + * + * ```asn + * SecurityLevel ::= ENUMERATED { + * Software (0), + * TrustedEnvironment (1), + * StrongBox (2), + * } + * ``` + */ +export declare enum SecurityLevel { + software = 0, + trustedEnvironment = 1, + strongBox = 2 +} +export declare enum Version { + KM2 = 1, + KM3 = 2, + KM4 = 3, + KM4_1 = 4, + keyMint1 = 100, + keyMint2 = 200, + keyMint3 = 300, + keyMint4 = 400 +} +/** + * Implements ASN.1 structure for key description. + * + * ```asn + * KeyDescription ::= SEQUENCE { + * attestationVersion INTEGER, # versions 1, 2, 3, 4, 100, and 200 + * attestationSecurityLevel SecurityLevel, + * keymasterVersion INTEGER, + * keymasterSecurityLevel SecurityLevel, + * attestationChallenge OCTET_STRING, + * uniqueId OCTET_STRING, + * softwareEnforced AuthorizationList, + * teeEnforced AuthorizationList, + * } + * ``` + */ +export declare class KeyDescription { + attestationVersion: number | Version; + attestationSecurityLevel: SecurityLevel; + keymasterVersion: number; + keymasterSecurityLevel: SecurityLevel; + attestationChallenge: OctetString; + uniqueId: OctetString; + softwareEnforced: AuthorizationList; + teeEnforced: AuthorizationList; + constructor(params?: Partial); +} +/** + * Implements ASN.1 structure for KeyMint key description (v300 and v400). + * + * ```asn + * KeyDescription ::= SEQUENCE { + * attestationVersion INTEGER, # versions 300 and 400 + * attestationSecurityLevel SecurityLevel, + * keyMintVersion INTEGER, + * keyMintSecurityLevel SecurityLevel, + * attestationChallenge OCTET_STRING, + * uniqueId OCTET_STRING, + * softwareEnforced AuthorizationList, + * hardwareEnforced AuthorizationList, + * } + * ``` + */ +export declare class KeyMintKeyDescription { + attestationVersion: number | Version; + attestationSecurityLevel: SecurityLevel; + keyMintVersion: number; + keyMintSecurityLevel: SecurityLevel; + attestationChallenge: OctetString; + uniqueId: OctetString; + softwareEnforced: AuthorizationList; + hardwareEnforced: AuthorizationList; + constructor(params?: Partial); + /** + * Convert to legacy KeyDescription for backwards compatibility + */ + toLegacyKeyDescription(): KeyDescription; + /** + * Create from legacy KeyDescription for backwards compatibility + */ + static fromLegacyKeyDescription(keyDesc: KeyDescription): KeyMintKeyDescription; +} diff --git a/node_modules/@peculiar/asn1-android/build/types/nonstandard.d.ts b/node_modules/@peculiar/asn1-android/build/types/nonstandard.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c2cc1373b8040394d1451e80ff93b847ed34bd79 --- /dev/null +++ b/node_modules/@peculiar/asn1-android/build/types/nonstandard.d.ts @@ -0,0 +1,83 @@ +import { AsnArray, OctetString } from "@peculiar/asn1-schema"; +import { AuthorizationList, SecurityLevel, Version } from "./key_description"; +/** + * This file contains classes to handle non-standard key descriptions and authorizations. + * + * Due to an issue with the asn1-schema library, referenced at https://github.com/PeculiarVentures/asn1-schema/issues/98#issuecomment-1764345351, + * the standard key description does not allow for a non-strict order of fields in the `softwareEnforced` and `teeEnforced` attributes. + * + * To address this and provide greater flexibility, the `NonStandardKeyDescription` and + * `NonStandardAuthorizationList` classes were created, allowing for the use of non-standard authorizations and a flexible field order. + * + * The purpose of these modifications is to ensure compatibility with specific requirements and standards, as well as to offer + * more convenient tools for working with key descriptions and authorizations. + * + * Please refer to the documentation and class comments before using or modifying them. + */ +/** + * Represents a non-standard authorization for NonStandardAuthorizationList. It uses the same + * structure as AuthorizationList, but it is a CHOICE instead of a SEQUENCE, that allows for + * non-strict ordering of fields. + */ +export declare class NonStandardAuthorization extends AuthorizationList { +} +/** + * Represents a list of non-standard authorizations. + * ```asn + * NonStandardAuthorizationList ::= SEQUENCE OF NonStandardAuthorization + * ``` + */ +export declare class NonStandardAuthorizationList extends AsnArray { + constructor(items?: NonStandardAuthorization[]); + /** + * Finds the first authorization that contains the specified key. + * @param key The key to search for. + * @returns The first authorization that contains the specified key, or `undefined` if not found. + */ + findProperty(key: K): AuthorizationList[K] | undefined; +} +/** + * The AuthorizationList class allows for non-strict ordering of fields in the + * softwareEnforced and teeEnforced/hardwareEnforced fields. + * + * This behavior is due to an issue with the asn1-schema library, which is + * documented here: https://github.com/PeculiarVentures/asn1-schema/issues/98#issuecomment-1764345351 + * + * ```asn + * KeyDescription ::= SEQUENCE { + * attestationVersion INTEGER, # versions 1, 2, 3, 4, 100, 200, 300, and 400 + * attestationSecurityLevel SecurityLevel, + * keymasterVersion/keyMintVersion INTEGER, + * keymasterSecurityLevel/keyMintSecurityLevel SecurityLevel, + * attestationChallenge OCTET_STRING, + * uniqueId OCTET_STRING, + * softwareEnforced NonStandardAuthorizationList, + * teeEnforced/hardwareEnforced NonStandardAuthorizationList, + * } + * ``` + */ +export declare class NonStandardKeyDescription { + attestationVersion: number | Version; + attestationSecurityLevel: SecurityLevel; + keymasterVersion: number; + keymasterSecurityLevel: SecurityLevel; + attestationChallenge: OctetString; + uniqueId: OctetString; + softwareEnforced: NonStandardAuthorizationList; + teeEnforced: NonStandardAuthorizationList; + get keyMintVersion(): number; + set keyMintVersion(value: number); + get keyMintSecurityLevel(): SecurityLevel; + set keyMintSecurityLevel(value: SecurityLevel); + get hardwareEnforced(): NonStandardAuthorizationList; + set hardwareEnforced(value: NonStandardAuthorizationList); + constructor(params?: Partial); +} +/** + * New class for v300 and v400 KeyMint non-standard key description. + * This uses the same underlying structure as NonStandardKeyDescription, + * but with renamed properties to match the updated specification. + */ +export declare class NonStandardKeyMintKeyDescription extends NonStandardKeyDescription { + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-android/package.json b/node_modules/@peculiar/asn1-android/package.json new file mode 100644 index 0000000000000000000000000000000000000000..72bf9d4b2e19ae11f601c1e064106a1420de908e --- /dev/null +++ b/node_modules/@peculiar/asn1-android/package.json @@ -0,0 +1,61 @@ +{ + "name": "@peculiar/asn1-android", + "version": "2.8.0", + "description": "ASN.1 schema for Android key attestation extensions, including legacy Keymaster and newer KeyMint structures.", + "keywords": [ + "asn", + "asn1", + "android", + "attestation", + "keystore", + "keymint", + "keymaster" + ], + "author": "PeculiarVentures, LLC", + "license": "MIT", + "files": [ + "build/**/*.{js,d.ts}", + "build/es2015/package.json", + "LICENSE", + "README.md" + ], + "main": "build/cjs/index.js", + "module": "build/es2015/index.js", + "types": "build/types/index.d.ts", + "exports": { + ".": { + "types": "./build/types/index.d.ts", + "import": "./build/es2015/index.js", + "require": "./build/cjs/index.js" + }, + "./package.json": "./package.json" + }, + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "https://github.com/PeculiarVentures/asn1-schema", + "directory": "packages/android" + }, + "bugs": { + "url": "https://github.com/PeculiarVentures/asn1-schema/issues" + }, + "homepage": "https://github.com/PeculiarVentures/asn1-schema/tree/master/packages/android#readme", + "scripts": { + "clear": "rimraf build", + "build": "npm run build:module && npm run build:types", + "build:module": "npm run build:cjs && npm run build:es2015", + "build:cjs": "tsc -p tsconfig.compile.json --removeComments --module commonjs --outDir build/cjs", + "build:es2015": "tsc -p tsconfig.compile.json --removeComments --module ES2015 --outDir build/es2015", + "postbuild:es2015": "node ../../scripts/prepare_esm_package.mjs build/es2015", + "prebuild:types": "rimraf build/types", + "build:types": "tsc -p tsconfig.compile.json --outDir build/types --declaration --emitDeclarationOnly", + "rebuild": "npm run clear && npm run build" + }, + "dependencies": { + "@peculiar/asn1-schema": "^2.8.0", + "asn1js": "^3.0.10", + "tslib": "^2.8.1" + } +} diff --git a/node_modules/@peculiar/asn1-cms/LICENSE b/node_modules/@peculiar/asn1-cms/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..6f9ec1352ea499d3f26a898c37ea4a0cd2a740fb --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@peculiar/asn1-cms/README.md b/node_modules/@peculiar/asn1-cms/README.md new file mode 100644 index 0000000000000000000000000000000000000000..069e33bdf59c16ad1291163a101cdb3da860dbca --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/README.md @@ -0,0 +1,20 @@ +# `@peculiar/asn1-cms` + +[![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/PeculiarVentures/asn1-schema/blob/master/packages/cms/LICENSE) +[![npm version](https://badge.fury.io/js/%40peculiar%2Fasn1-cms.svg)](https://badge.fury.io/js/%40peculiar%2Fasn1-cms) + +[![NPM](https://nodei.co/npm/@peculiar/asn1-cms.png)](https://nodei.co/npm/@peculiar/asn1-cms/) + +ASN.1 schema for Cryptographic Message Syntax (CMS) defined in RFC 5652. + +Use the exported classes with `@peculiar/asn1-schema` helpers such as `AsnConvert`, `AsnParser`, and `AsnSerializer` to parse or serialize DER-encoded data defined by the referenced specification. + +## Installation + +```bash +npm install @peculiar/asn1-cms +``` + +## Specifications + +- [RFC 5652: Cryptographic Message Syntax (CMS)](https://datatracker.ietf.org/doc/html/rfc5652) diff --git a/node_modules/@peculiar/asn1-cms/build/cjs/attribute.js b/node_modules/@peculiar/asn1-cms/build/cjs/attribute.js new file mode 100644 index 0000000000000000000000000000000000000000..89f9f71f094de604cec82af83dda5adb12af6541 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/cjs/attribute.js @@ -0,0 +1,21 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Attribute = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +class Attribute { + attrType = ""; + attrValues = []; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.Attribute = Attribute; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.ObjectIdentifier }) +], Attribute.prototype, "attrType", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Any, repeated: "set", + }) +], Attribute.prototype, "attrValues", void 0); diff --git a/node_modules/@peculiar/asn1-cms/build/cjs/attributes/counter_signature.js b/node_modules/@peculiar/asn1-cms/build/cjs/attributes/counter_signature.js new file mode 100644 index 0000000000000000000000000000000000000000..bdc65ea78e9c6be2d3d054242c550365a27ce839 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/cjs/attributes/counter_signature.js @@ -0,0 +1,13 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CounterSignature = exports.id_counterSignature = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const signer_info_1 = require("../signer_info"); +exports.id_counterSignature = "1.2.840.113549.1.9.6"; +let CounterSignature = class CounterSignature extends signer_info_1.SignerInfo { +}; +exports.CounterSignature = CounterSignature; +exports.CounterSignature = CounterSignature = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Sequence }) +], CounterSignature); diff --git a/node_modules/@peculiar/asn1-cms/build/cjs/attributes/index.js b/node_modules/@peculiar/asn1-cms/build/cjs/attributes/index.js new file mode 100644 index 0000000000000000000000000000000000000000..e52d86c88347a4ed496de8292ce0a6339fcb06e0 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/cjs/attributes/index.js @@ -0,0 +1,8 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.id_contentType = void 0; +const tslib_1 = require("tslib"); +tslib_1.__exportStar(require("./counter_signature"), exports); +tslib_1.__exportStar(require("./message_digest"), exports); +tslib_1.__exportStar(require("./signing_time"), exports); +exports.id_contentType = "1.2.840.113549.1.9.3"; diff --git a/node_modules/@peculiar/asn1-cms/build/cjs/attributes/message_digest.js b/node_modules/@peculiar/asn1-cms/build/cjs/attributes/message_digest.js new file mode 100644 index 0000000000000000000000000000000000000000..200397c6faf5f987b43c995129626fe55c6ce066 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/cjs/attributes/message_digest.js @@ -0,0 +1,8 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.MessageDigest = exports.id_messageDigest = void 0; +const asn1_schema_1 = require("@peculiar/asn1-schema"); +exports.id_messageDigest = "1.2.840.113549.1.9.4"; +class MessageDigest extends asn1_schema_1.OctetString { +} +exports.MessageDigest = MessageDigest; diff --git a/node_modules/@peculiar/asn1-cms/build/cjs/attributes/signing_time.js b/node_modules/@peculiar/asn1-cms/build/cjs/attributes/signing_time.js new file mode 100644 index 0000000000000000000000000000000000000000..e82581cd410e9212204958a4eab01ef427189295 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/cjs/attributes/signing_time.js @@ -0,0 +1,13 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SigningTime = exports.id_signingTime = void 0; +const tslib_1 = require("tslib"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +exports.id_signingTime = "1.2.840.113549.1.9.5"; +let SigningTime = class SigningTime extends asn1_x509_1.Time { +}; +exports.SigningTime = SigningTime; +exports.SigningTime = SigningTime = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], SigningTime); diff --git a/node_modules/@peculiar/asn1-cms/build/cjs/certificate_choices.js b/node_modules/@peculiar/asn1-cms/build/cjs/certificate_choices.js new file mode 100644 index 0000000000000000000000000000000000000000..6a4b654edcca628d41b3f1f01b310e145443e655 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/cjs/certificate_choices.js @@ -0,0 +1,59 @@ +"use strict"; +var CertificateSet_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CertificateSet = exports.CertificateChoices = exports.OtherCertificateFormat = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +const asn1_x509_attr_1 = require("@peculiar/asn1-x509-attr"); +class OtherCertificateFormat { + otherCertFormat = ""; + otherCert = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.OtherCertificateFormat = OtherCertificateFormat; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.ObjectIdentifier }) +], OtherCertificateFormat.prototype, "otherCertFormat", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Any }) +], OtherCertificateFormat.prototype, "otherCert", void 0); +let CertificateChoices = class CertificateChoices { + certificate; + v2AttrCert; + other; + constructor(params = {}) { + Object.assign(this, params); + } +}; +exports.CertificateChoices = CertificateChoices; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_x509_1.Certificate }) +], CertificateChoices.prototype, "certificate", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_x509_attr_1.AttributeCertificate, context: 2, implicit: true, + }) +], CertificateChoices.prototype, "v2AttrCert", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: OtherCertificateFormat, context: 3, implicit: true, + }) +], CertificateChoices.prototype, "other", void 0); +exports.CertificateChoices = CertificateChoices = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], CertificateChoices); +let CertificateSet = CertificateSet_1 = class CertificateSet extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, CertificateSet_1.prototype); + } +}; +exports.CertificateSet = CertificateSet; +exports.CertificateSet = CertificateSet = CertificateSet_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Set, itemType: CertificateChoices, + }) +], CertificateSet); diff --git a/node_modules/@peculiar/asn1-cms/build/cjs/content_info.js b/node_modules/@peculiar/asn1-cms/build/cjs/content_info.js new file mode 100644 index 0000000000000000000000000000000000000000..f6f614fc187b73fad5bcaaaa6592f8251383c062 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/cjs/content_info.js @@ -0,0 +1,21 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ContentInfo = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +class ContentInfo { + contentType = ""; + content = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.ContentInfo = ContentInfo; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.ObjectIdentifier }) +], ContentInfo.prototype, "contentType", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Any, context: 0, + }) +], ContentInfo.prototype, "content", void 0); diff --git a/node_modules/@peculiar/asn1-cms/build/cjs/encapsulated_content_info.js b/node_modules/@peculiar/asn1-cms/build/cjs/encapsulated_content_info.js new file mode 100644 index 0000000000000000000000000000000000000000..8f3b27322c2c88707b03390572f632febbed8c74 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/cjs/encapsulated_content_info.js @@ -0,0 +1,38 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.EncapsulatedContentInfo = exports.EncapsulatedContent = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +let EncapsulatedContent = class EncapsulatedContent { + single; + any; + constructor(params = {}) { + Object.assign(this, params); + } +}; +exports.EncapsulatedContent = EncapsulatedContent; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.OctetString }) +], EncapsulatedContent.prototype, "single", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Any }) +], EncapsulatedContent.prototype, "any", void 0); +exports.EncapsulatedContent = EncapsulatedContent = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], EncapsulatedContent); +class EncapsulatedContentInfo { + eContentType = ""; + eContent; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.EncapsulatedContentInfo = EncapsulatedContentInfo; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.ObjectIdentifier }) +], EncapsulatedContentInfo.prototype, "eContentType", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: EncapsulatedContent, context: 0, optional: true, + }) +], EncapsulatedContentInfo.prototype, "eContent", void 0); diff --git a/node_modules/@peculiar/asn1-cms/build/cjs/encrypted_content_info.js b/node_modules/@peculiar/asn1-cms/build/cjs/encrypted_content_info.js new file mode 100644 index 0000000000000000000000000000000000000000..8a63ae2ba2c51404b9f3ba1868d1de535f0bb690 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/cjs/encrypted_content_info.js @@ -0,0 +1,52 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.EncryptedContentInfo = exports.EncryptedContent = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const types_1 = require("./types"); +let EncryptedContent = class EncryptedContent { + value; + constructedValue; + constructor(params = {}) { + Object.assign(this, params); + } +}; +exports.EncryptedContent = EncryptedContent; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.OctetString, context: 0, implicit: true, optional: true, + }) +], EncryptedContent.prototype, "value", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.OctetString, + converter: asn1_schema_1.AsnConstructedOctetStringConverter, + context: 0, + implicit: true, + optional: true, + repeated: "sequence", + }) +], EncryptedContent.prototype, "constructedValue", void 0); +exports.EncryptedContent = EncryptedContent = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], EncryptedContent); +class EncryptedContentInfo { + contentType = ""; + contentEncryptionAlgorithm = new types_1.ContentEncryptionAlgorithmIdentifier(); + encryptedContent; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.EncryptedContentInfo = EncryptedContentInfo; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.ObjectIdentifier }) +], EncryptedContentInfo.prototype, "contentType", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: types_1.ContentEncryptionAlgorithmIdentifier }) +], EncryptedContentInfo.prototype, "contentEncryptionAlgorithm", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: EncryptedContent, optional: true, + }) +], EncryptedContentInfo.prototype, "encryptedContent", void 0); diff --git a/node_modules/@peculiar/asn1-cms/build/cjs/enveloped_data.js b/node_modules/@peculiar/asn1-cms/build/cjs/enveloped_data.js new file mode 100644 index 0000000000000000000000000000000000000000..a66cc10f8968780d62119359ef3aad9267d9b6ef --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/cjs/enveloped_data.js @@ -0,0 +1,53 @@ +"use strict"; +var UnprotectedAttributes_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.EnvelopedData = exports.UnprotectedAttributes = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const types_1 = require("./types"); +const attribute_1 = require("./attribute"); +const recipient_infos_1 = require("./recipient_infos"); +const originator_info_1 = require("./originator_info"); +const encrypted_content_info_1 = require("./encrypted_content_info"); +let UnprotectedAttributes = UnprotectedAttributes_1 = class UnprotectedAttributes extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, UnprotectedAttributes_1.prototype); + } +}; +exports.UnprotectedAttributes = UnprotectedAttributes; +exports.UnprotectedAttributes = UnprotectedAttributes = UnprotectedAttributes_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Set, itemType: attribute_1.Attribute, + }) +], UnprotectedAttributes); +class EnvelopedData { + version = types_1.CMSVersion.v0; + originatorInfo; + recipientInfos = new recipient_infos_1.RecipientInfos(); + encryptedContentInfo = new encrypted_content_info_1.EncryptedContentInfo(); + unprotectedAttrs; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.EnvelopedData = EnvelopedData; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer }) +], EnvelopedData.prototype, "version", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: originator_info_1.OriginatorInfo, context: 0, implicit: true, optional: true, + }) +], EnvelopedData.prototype, "originatorInfo", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: recipient_infos_1.RecipientInfos }) +], EnvelopedData.prototype, "recipientInfos", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: encrypted_content_info_1.EncryptedContentInfo }) +], EnvelopedData.prototype, "encryptedContentInfo", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: UnprotectedAttributes, context: 1, implicit: true, optional: true, + }) +], EnvelopedData.prototype, "unprotectedAttrs", void 0); diff --git a/node_modules/@peculiar/asn1-cms/build/cjs/index.js b/node_modules/@peculiar/asn1-cms/build/cjs/index.js new file mode 100644 index 0000000000000000000000000000000000000000..693c506a0a76b00da751a9041572847cdba498ec --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/cjs/index.js @@ -0,0 +1,24 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +tslib_1.__exportStar(require("./attributes"), exports); +tslib_1.__exportStar(require("./attribute"), exports); +tslib_1.__exportStar(require("./certificate_choices"), exports); +tslib_1.__exportStar(require("./content_info"), exports); +tslib_1.__exportStar(require("./encapsulated_content_info"), exports); +tslib_1.__exportStar(require("./encrypted_content_info"), exports); +tslib_1.__exportStar(require("./enveloped_data"), exports); +tslib_1.__exportStar(require("./issuer_and_serial_number"), exports); +tslib_1.__exportStar(require("./kek_recipient_info"), exports); +tslib_1.__exportStar(require("./key_agree_recipient_info"), exports); +tslib_1.__exportStar(require("./key_trans_recipient_info"), exports); +tslib_1.__exportStar(require("./object_identifiers"), exports); +tslib_1.__exportStar(require("./originator_info"), exports); +tslib_1.__exportStar(require("./password_recipient_info"), exports); +tslib_1.__exportStar(require("./recipient_info"), exports); +tslib_1.__exportStar(require("./recipient_infos"), exports); +tslib_1.__exportStar(require("./revocation_info_choice"), exports); +tslib_1.__exportStar(require("./signed_data"), exports); +tslib_1.__exportStar(require("./signer_identifier"), exports); +tslib_1.__exportStar(require("./signer_info"), exports); +tslib_1.__exportStar(require("./types"), exports); diff --git a/node_modules/@peculiar/asn1-cms/build/cjs/issuer_and_serial_number.js b/node_modules/@peculiar/asn1-cms/build/cjs/issuer_and_serial_number.js new file mode 100644 index 0000000000000000000000000000000000000000..7bdeea2b1410da6278920b43bc7d8e6ec7d1421e --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/cjs/issuer_and_serial_number.js @@ -0,0 +1,22 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.IssuerAndSerialNumber = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +class IssuerAndSerialNumber { + issuer = new asn1_x509_1.Name(); + serialNumber = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.IssuerAndSerialNumber = IssuerAndSerialNumber; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_x509_1.Name }) +], IssuerAndSerialNumber.prototype, "issuer", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter, + }) +], IssuerAndSerialNumber.prototype, "serialNumber", void 0); diff --git a/node_modules/@peculiar/asn1-cms/build/cjs/kek_recipient_info.js b/node_modules/@peculiar/asn1-cms/build/cjs/kek_recipient_info.js new file mode 100644 index 0000000000000000000000000000000000000000..dc6e87c7cfe8e995c0a4f9e7d427e262de86ea8f --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/cjs/kek_recipient_info.js @@ -0,0 +1,51 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KEKRecipientInfo = exports.KEKIdentifier = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const other_key_attribute_1 = require("./other_key_attribute"); +const types_1 = require("./types"); +class KEKIdentifier { + keyIdentifier = new asn1_schema_1.OctetString(); + date; + other; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.KEKIdentifier = KEKIdentifier; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.OctetString }) +], KEKIdentifier.prototype, "keyIdentifier", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.GeneralizedTime, optional: true, + }) +], KEKIdentifier.prototype, "date", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: other_key_attribute_1.OtherKeyAttribute, optional: true, + }) +], KEKIdentifier.prototype, "other", void 0); +class KEKRecipientInfo { + version = types_1.CMSVersion.v4; + kekid = new KEKIdentifier(); + keyEncryptionAlgorithm = new types_1.KeyEncryptionAlgorithmIdentifier(); + encryptedKey = new asn1_schema_1.OctetString(); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.KEKRecipientInfo = KEKRecipientInfo; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer }) +], KEKRecipientInfo.prototype, "version", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: KEKIdentifier }) +], KEKRecipientInfo.prototype, "kekid", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: types_1.KeyEncryptionAlgorithmIdentifier }) +], KEKRecipientInfo.prototype, "keyEncryptionAlgorithm", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.OctetString }) +], KEKRecipientInfo.prototype, "encryptedKey", void 0); diff --git a/node_modules/@peculiar/asn1-cms/build/cjs/key_agree_recipient_info.js b/node_modules/@peculiar/asn1-cms/build/cjs/key_agree_recipient_info.js new file mode 100644 index 0000000000000000000000000000000000000000..24c4d40d8b66c8a8f247855619db56826045e57c --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/cjs/key_agree_recipient_info.js @@ -0,0 +1,150 @@ +"use strict"; +var RecipientEncryptedKeys_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KeyAgreeRecipientInfo = exports.OriginatorIdentifierOrKey = exports.OriginatorPublicKey = exports.RecipientEncryptedKeys = exports.RecipientEncryptedKey = exports.KeyAgreeRecipientIdentifier = exports.RecipientKeyIdentifier = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +const types_1 = require("./types"); +const issuer_and_serial_number_1 = require("./issuer_and_serial_number"); +const other_key_attribute_1 = require("./other_key_attribute"); +class RecipientKeyIdentifier { + subjectKeyIdentifier = new asn1_x509_1.SubjectKeyIdentifier(); + date; + other; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.RecipientKeyIdentifier = RecipientKeyIdentifier; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_x509_1.SubjectKeyIdentifier }) +], RecipientKeyIdentifier.prototype, "subjectKeyIdentifier", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.GeneralizedTime, optional: true, + }) +], RecipientKeyIdentifier.prototype, "date", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: other_key_attribute_1.OtherKeyAttribute, optional: true, + }) +], RecipientKeyIdentifier.prototype, "other", void 0); +let KeyAgreeRecipientIdentifier = class KeyAgreeRecipientIdentifier { + rKeyId; + issuerAndSerialNumber; + constructor(params = {}) { + Object.assign(this, params); + } +}; +exports.KeyAgreeRecipientIdentifier = KeyAgreeRecipientIdentifier; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: RecipientKeyIdentifier, context: 0, implicit: true, optional: true, + }) +], KeyAgreeRecipientIdentifier.prototype, "rKeyId", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: issuer_and_serial_number_1.IssuerAndSerialNumber, optional: true, + }) +], KeyAgreeRecipientIdentifier.prototype, "issuerAndSerialNumber", void 0); +exports.KeyAgreeRecipientIdentifier = KeyAgreeRecipientIdentifier = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], KeyAgreeRecipientIdentifier); +class RecipientEncryptedKey { + rid = new KeyAgreeRecipientIdentifier(); + encryptedKey = new asn1_schema_1.OctetString(); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.RecipientEncryptedKey = RecipientEncryptedKey; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: KeyAgreeRecipientIdentifier }) +], RecipientEncryptedKey.prototype, "rid", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.OctetString }) +], RecipientEncryptedKey.prototype, "encryptedKey", void 0); +let RecipientEncryptedKeys = RecipientEncryptedKeys_1 = class RecipientEncryptedKeys extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, RecipientEncryptedKeys_1.prototype); + } +}; +exports.RecipientEncryptedKeys = RecipientEncryptedKeys; +exports.RecipientEncryptedKeys = RecipientEncryptedKeys = RecipientEncryptedKeys_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Sequence, itemType: RecipientEncryptedKey, + }) +], RecipientEncryptedKeys); +class OriginatorPublicKey { + algorithm = new asn1_x509_1.AlgorithmIdentifier(); + publicKey = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.OriginatorPublicKey = OriginatorPublicKey; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_x509_1.AlgorithmIdentifier }) +], OriginatorPublicKey.prototype, "algorithm", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.BitString }) +], OriginatorPublicKey.prototype, "publicKey", void 0); +let OriginatorIdentifierOrKey = class OriginatorIdentifierOrKey { + subjectKeyIdentifier; + originatorKey; + issuerAndSerialNumber; + constructor(params = {}) { + Object.assign(this, params); + } +}; +exports.OriginatorIdentifierOrKey = OriginatorIdentifierOrKey; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_x509_1.SubjectKeyIdentifier, context: 0, implicit: true, optional: true, + }) +], OriginatorIdentifierOrKey.prototype, "subjectKeyIdentifier", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: OriginatorPublicKey, context: 1, implicit: true, optional: true, + }) +], OriginatorIdentifierOrKey.prototype, "originatorKey", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: issuer_and_serial_number_1.IssuerAndSerialNumber, optional: true, + }) +], OriginatorIdentifierOrKey.prototype, "issuerAndSerialNumber", void 0); +exports.OriginatorIdentifierOrKey = OriginatorIdentifierOrKey = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], OriginatorIdentifierOrKey); +class KeyAgreeRecipientInfo { + version = types_1.CMSVersion.v3; + originator = new OriginatorIdentifierOrKey(); + ukm; + keyEncryptionAlgorithm = new types_1.KeyEncryptionAlgorithmIdentifier(); + recipientEncryptedKeys = new RecipientEncryptedKeys(); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.KeyAgreeRecipientInfo = KeyAgreeRecipientInfo; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer }) +], KeyAgreeRecipientInfo.prototype, "version", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: OriginatorIdentifierOrKey, context: 0, + }) +], KeyAgreeRecipientInfo.prototype, "originator", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.OctetString, context: 1, optional: true, + }) +], KeyAgreeRecipientInfo.prototype, "ukm", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: types_1.KeyEncryptionAlgorithmIdentifier }) +], KeyAgreeRecipientInfo.prototype, "keyEncryptionAlgorithm", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: RecipientEncryptedKeys }) +], KeyAgreeRecipientInfo.prototype, "recipientEncryptedKeys", void 0); diff --git a/node_modules/@peculiar/asn1-cms/build/cjs/key_trans_recipient_info.js b/node_modules/@peculiar/asn1-cms/build/cjs/key_trans_recipient_info.js new file mode 100644 index 0000000000000000000000000000000000000000..95b0d82b703f65e2cd0c13021676cc39ff56a1fd --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/cjs/key_trans_recipient_info.js @@ -0,0 +1,49 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KeyTransRecipientInfo = exports.RecipientIdentifier = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +const types_1 = require("./types"); +const issuer_and_serial_number_1 = require("./issuer_and_serial_number"); +let RecipientIdentifier = class RecipientIdentifier { + subjectKeyIdentifier; + issuerAndSerialNumber; + constructor(params = {}) { + Object.assign(this, params); + } +}; +exports.RecipientIdentifier = RecipientIdentifier; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_x509_1.SubjectKeyIdentifier, context: 0, implicit: true, + }) +], RecipientIdentifier.prototype, "subjectKeyIdentifier", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: issuer_and_serial_number_1.IssuerAndSerialNumber }) +], RecipientIdentifier.prototype, "issuerAndSerialNumber", void 0); +exports.RecipientIdentifier = RecipientIdentifier = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], RecipientIdentifier); +class KeyTransRecipientInfo { + version = types_1.CMSVersion.v0; + rid = new RecipientIdentifier(); + keyEncryptionAlgorithm = new types_1.KeyEncryptionAlgorithmIdentifier(); + encryptedKey = new asn1_schema_1.OctetString(); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.KeyTransRecipientInfo = KeyTransRecipientInfo; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer }) +], KeyTransRecipientInfo.prototype, "version", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: RecipientIdentifier }) +], KeyTransRecipientInfo.prototype, "rid", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: types_1.KeyEncryptionAlgorithmIdentifier }) +], KeyTransRecipientInfo.prototype, "keyEncryptionAlgorithm", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.OctetString }) +], KeyTransRecipientInfo.prototype, "encryptedKey", void 0); diff --git a/node_modules/@peculiar/asn1-cms/build/cjs/object_identifiers.js b/node_modules/@peculiar/asn1-cms/build/cjs/object_identifiers.js new file mode 100644 index 0000000000000000000000000000000000000000..1f710e26933a5a99975536401cb0763cee70debc --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/cjs/object_identifiers.js @@ -0,0 +1,10 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.id_authData = exports.id_encryptedData = exports.id_digestedData = exports.id_envelopedData = exports.id_signedData = exports.id_data = exports.id_ct_contentInfo = void 0; +exports.id_ct_contentInfo = "1.2.840.113549.1.9.16.1.6"; +exports.id_data = "1.2.840.113549.1.7.1"; +exports.id_signedData = "1.2.840.113549.1.7.2"; +exports.id_envelopedData = "1.2.840.113549.1.7.3"; +exports.id_digestedData = "1.2.840.113549.1.7.5"; +exports.id_encryptedData = "1.2.840.113549.1.7.6"; +exports.id_authData = "1.2.840.113549.1.9.16.1.2"; diff --git a/node_modules/@peculiar/asn1-cms/build/cjs/originator_info.js b/node_modules/@peculiar/asn1-cms/build/cjs/originator_info.js new file mode 100644 index 0000000000000000000000000000000000000000..86d9d3db3c3842eb2a1ed4a5f5afdbb25ac21a9e --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/cjs/originator_info.js @@ -0,0 +1,25 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.OriginatorInfo = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const certificate_choices_1 = require("./certificate_choices"); +const revocation_info_choice_1 = require("./revocation_info_choice"); +class OriginatorInfo { + certs; + crls; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.OriginatorInfo = OriginatorInfo; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: certificate_choices_1.CertificateSet, context: 0, implicit: true, optional: true, + }) +], OriginatorInfo.prototype, "certs", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: revocation_info_choice_1.RevocationInfoChoices, context: 1, implicit: true, optional: true, + }) +], OriginatorInfo.prototype, "crls", void 0); diff --git a/node_modules/@peculiar/asn1-cms/build/cjs/other_key_attribute.js b/node_modules/@peculiar/asn1-cms/build/cjs/other_key_attribute.js new file mode 100644 index 0000000000000000000000000000000000000000..3dee0696e01982f07f202c0a43e217d291e95483 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/cjs/other_key_attribute.js @@ -0,0 +1,21 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.OtherKeyAttribute = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +class OtherKeyAttribute { + keyAttrId = ""; + keyAttr; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.OtherKeyAttribute = OtherKeyAttribute; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.ObjectIdentifier }) +], OtherKeyAttribute.prototype, "keyAttrId", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Any, optional: true, + }) +], OtherKeyAttribute.prototype, "keyAttr", void 0); diff --git a/node_modules/@peculiar/asn1-cms/build/cjs/password_recipient_info.js b/node_modules/@peculiar/asn1-cms/build/cjs/password_recipient_info.js new file mode 100644 index 0000000000000000000000000000000000000000..95f724e7798b797302465ffd2b95bc0c5b30505e --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/cjs/password_recipient_info.js @@ -0,0 +1,30 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.PasswordRecipientInfo = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const types_1 = require("./types"); +class PasswordRecipientInfo { + version = types_1.CMSVersion.v0; + keyDerivationAlgorithm; + keyEncryptionAlgorithm = new types_1.KeyEncryptionAlgorithmIdentifier(); + encryptedKey = new asn1_schema_1.OctetString(); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.PasswordRecipientInfo = PasswordRecipientInfo; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer }) +], PasswordRecipientInfo.prototype, "version", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: types_1.KeyDerivationAlgorithmIdentifier, context: 0, optional: true, + }) +], PasswordRecipientInfo.prototype, "keyDerivationAlgorithm", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: types_1.KeyEncryptionAlgorithmIdentifier }) +], PasswordRecipientInfo.prototype, "keyEncryptionAlgorithm", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.OctetString }) +], PasswordRecipientInfo.prototype, "encryptedKey", void 0); diff --git a/node_modules/@peculiar/asn1-cms/build/cjs/recipient_info.js b/node_modules/@peculiar/asn1-cms/build/cjs/recipient_info.js new file mode 100644 index 0000000000000000000000000000000000000000..28c0b11dd32d9b21185c1774a95348913e60b73e --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/cjs/recipient_info.js @@ -0,0 +1,62 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.RecipientInfo = exports.OtherRecipientInfo = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const key_agree_recipient_info_1 = require("./key_agree_recipient_info"); +const key_trans_recipient_info_1 = require("./key_trans_recipient_info"); +const kek_recipient_info_1 = require("./kek_recipient_info"); +const password_recipient_info_1 = require("./password_recipient_info"); +class OtherRecipientInfo { + oriType = ""; + oriValue = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.OtherRecipientInfo = OtherRecipientInfo; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.ObjectIdentifier }) +], OtherRecipientInfo.prototype, "oriType", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Any }) +], OtherRecipientInfo.prototype, "oriValue", void 0); +let RecipientInfo = class RecipientInfo { + ktri; + kari; + kekri; + pwri; + ori; + constructor(params = {}) { + Object.assign(this, params); + } +}; +exports.RecipientInfo = RecipientInfo; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: key_trans_recipient_info_1.KeyTransRecipientInfo, optional: true, + }) +], RecipientInfo.prototype, "ktri", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: key_agree_recipient_info_1.KeyAgreeRecipientInfo, context: 1, implicit: true, optional: true, + }) +], RecipientInfo.prototype, "kari", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: kek_recipient_info_1.KEKRecipientInfo, context: 2, implicit: true, optional: true, + }) +], RecipientInfo.prototype, "kekri", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: password_recipient_info_1.PasswordRecipientInfo, context: 3, implicit: true, optional: true, + }) +], RecipientInfo.prototype, "pwri", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: OtherRecipientInfo, context: 4, implicit: true, optional: true, + }) +], RecipientInfo.prototype, "ori", void 0); +exports.RecipientInfo = RecipientInfo = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], RecipientInfo); diff --git a/node_modules/@peculiar/asn1-cms/build/cjs/recipient_infos.js b/node_modules/@peculiar/asn1-cms/build/cjs/recipient_infos.js new file mode 100644 index 0000000000000000000000000000000000000000..1fddaa10aeb504bfcdaa4ee90782475effe5907d --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/cjs/recipient_infos.js @@ -0,0 +1,19 @@ +"use strict"; +var RecipientInfos_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.RecipientInfos = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const recipient_info_1 = require("./recipient_info"); +let RecipientInfos = RecipientInfos_1 = class RecipientInfos extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, RecipientInfos_1.prototype); + } +}; +exports.RecipientInfos = RecipientInfos; +exports.RecipientInfos = RecipientInfos = RecipientInfos_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Set, itemType: recipient_info_1.RecipientInfo, + }) +], RecipientInfos); diff --git a/node_modules/@peculiar/asn1-cms/build/cjs/revocation_info_choice.js b/node_modules/@peculiar/asn1-cms/build/cjs/revocation_info_choice.js new file mode 100644 index 0000000000000000000000000000000000000000..b62797d02d94c5ba39f6594f56bc1bc68acbaf00 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/cjs/revocation_info_choice.js @@ -0,0 +1,51 @@ +"use strict"; +var RevocationInfoChoices_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.RevocationInfoChoices = exports.RevocationInfoChoice = exports.OtherRevocationInfoFormat = exports.id_ri_scvp = exports.id_ri_ocsp_response = exports.id_ri = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +exports.id_ri = `${asn1_x509_1.id_pkix}.16`; +exports.id_ri_ocsp_response = `${exports.id_ri}.2`; +exports.id_ri_scvp = `${exports.id_ri}.4`; +class OtherRevocationInfoFormat { + otherRevInfoFormat = ""; + otherRevInfo = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.OtherRevocationInfoFormat = OtherRevocationInfoFormat; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.ObjectIdentifier }) +], OtherRevocationInfoFormat.prototype, "otherRevInfoFormat", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Any }) +], OtherRevocationInfoFormat.prototype, "otherRevInfo", void 0); +let RevocationInfoChoice = class RevocationInfoChoice { + other = new OtherRevocationInfoFormat(); + constructor(params = {}) { + Object.assign(this, params); + } +}; +exports.RevocationInfoChoice = RevocationInfoChoice; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: OtherRevocationInfoFormat, context: 1, implicit: true, + }) +], RevocationInfoChoice.prototype, "other", void 0); +exports.RevocationInfoChoice = RevocationInfoChoice = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], RevocationInfoChoice); +let RevocationInfoChoices = RevocationInfoChoices_1 = class RevocationInfoChoices extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, RevocationInfoChoices_1.prototype); + } +}; +exports.RevocationInfoChoices = RevocationInfoChoices; +exports.RevocationInfoChoices = RevocationInfoChoices = RevocationInfoChoices_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Set, itemType: RevocationInfoChoice, + }) +], RevocationInfoChoices); diff --git a/node_modules/@peculiar/asn1-cms/build/cjs/signed_data.js b/node_modules/@peculiar/asn1-cms/build/cjs/signed_data.js new file mode 100644 index 0000000000000000000000000000000000000000..5ea04e7a7872fd240160d0e3029395361da3f653 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/cjs/signed_data.js @@ -0,0 +1,57 @@ +"use strict"; +var DigestAlgorithmIdentifiers_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SignedData = exports.DigestAlgorithmIdentifiers = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const certificate_choices_1 = require("./certificate_choices"); +const types_1 = require("./types"); +const encapsulated_content_info_1 = require("./encapsulated_content_info"); +const revocation_info_choice_1 = require("./revocation_info_choice"); +const signer_info_1 = require("./signer_info"); +let DigestAlgorithmIdentifiers = DigestAlgorithmIdentifiers_1 = class DigestAlgorithmIdentifiers extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, DigestAlgorithmIdentifiers_1.prototype); + } +}; +exports.DigestAlgorithmIdentifiers = DigestAlgorithmIdentifiers; +exports.DigestAlgorithmIdentifiers = DigestAlgorithmIdentifiers = DigestAlgorithmIdentifiers_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Set, itemType: types_1.DigestAlgorithmIdentifier, + }) +], DigestAlgorithmIdentifiers); +class SignedData { + version = types_1.CMSVersion.v0; + digestAlgorithms = new DigestAlgorithmIdentifiers(); + encapContentInfo = new encapsulated_content_info_1.EncapsulatedContentInfo(); + certificates; + crls; + signerInfos = new signer_info_1.SignerInfos(); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.SignedData = SignedData; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer }) +], SignedData.prototype, "version", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: DigestAlgorithmIdentifiers }) +], SignedData.prototype, "digestAlgorithms", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: encapsulated_content_info_1.EncapsulatedContentInfo }) +], SignedData.prototype, "encapContentInfo", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: certificate_choices_1.CertificateSet, context: 0, implicit: true, optional: true, + }) +], SignedData.prototype, "certificates", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: revocation_info_choice_1.RevocationInfoChoices, context: 1, implicit: true, optional: true, + }) +], SignedData.prototype, "crls", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: signer_info_1.SignerInfos }) +], SignedData.prototype, "signerInfos", void 0); diff --git a/node_modules/@peculiar/asn1-cms/build/cjs/signer_identifier.js b/node_modules/@peculiar/asn1-cms/build/cjs/signer_identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..19d8173975df6ac5dcfec8953692c70880db623b --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/cjs/signer_identifier.js @@ -0,0 +1,26 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SignerIdentifier = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +const issuer_and_serial_number_1 = require("./issuer_and_serial_number"); +let SignerIdentifier = class SignerIdentifier { + subjectKeyIdentifier; + issuerAndSerialNumber; + constructor(params = {}) { + Object.assign(this, params); + } +}; +exports.SignerIdentifier = SignerIdentifier; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_x509_1.SubjectKeyIdentifier, context: 0, implicit: true, + }) +], SignerIdentifier.prototype, "subjectKeyIdentifier", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: issuer_and_serial_number_1.IssuerAndSerialNumber }) +], SignerIdentifier.prototype, "issuerAndSerialNumber", void 0); +exports.SignerIdentifier = SignerIdentifier = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], SignerIdentifier); diff --git a/node_modules/@peculiar/asn1-cms/build/cjs/signer_info.js b/node_modules/@peculiar/asn1-cms/build/cjs/signer_info.js new file mode 100644 index 0000000000000000000000000000000000000000..5238a24c569e0332b50c552728ff8120b82b2559 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/cjs/signer_info.js @@ -0,0 +1,65 @@ +"use strict"; +var SignerInfos_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SignerInfos = exports.SignerInfo = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const signer_identifier_1 = require("./signer_identifier"); +const types_1 = require("./types"); +const attribute_1 = require("./attribute"); +class SignerInfo { + version = types_1.CMSVersion.v0; + sid = new signer_identifier_1.SignerIdentifier(); + digestAlgorithm = new types_1.DigestAlgorithmIdentifier(); + signedAttrs; + signedAttrsRaw; + signatureAlgorithm = new types_1.SignatureAlgorithmIdentifier(); + signature = new asn1_schema_1.OctetString(); + unsignedAttrs; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.SignerInfo = SignerInfo; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer }) +], SignerInfo.prototype, "version", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: signer_identifier_1.SignerIdentifier }) +], SignerInfo.prototype, "sid", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: types_1.DigestAlgorithmIdentifier }) +], SignerInfo.prototype, "digestAlgorithm", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: attribute_1.Attribute, + repeated: "set", + context: 0, + implicit: true, + optional: true, + raw: true, + }) +], SignerInfo.prototype, "signedAttrs", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: types_1.SignatureAlgorithmIdentifier }) +], SignerInfo.prototype, "signatureAlgorithm", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.OctetString }) +], SignerInfo.prototype, "signature", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: attribute_1.Attribute, repeated: "set", context: 1, implicit: true, optional: true, + }) +], SignerInfo.prototype, "unsignedAttrs", void 0); +let SignerInfos = SignerInfos_1 = class SignerInfos extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, SignerInfos_1.prototype); + } +}; +exports.SignerInfos = SignerInfos; +exports.SignerInfos = SignerInfos = SignerInfos_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Set, itemType: SignerInfo, + }) +], SignerInfos); diff --git a/node_modules/@peculiar/asn1-cms/build/cjs/types.js b/node_modules/@peculiar/asn1-cms/build/cjs/types.js new file mode 100644 index 0000000000000000000000000000000000000000..12b17b5690652429dfb1cb98b77e5e2f3b85315a --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/cjs/types.js @@ -0,0 +1,51 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KeyDerivationAlgorithmIdentifier = exports.MessageAuthenticationCodeAlgorithm = exports.ContentEncryptionAlgorithmIdentifier = exports.KeyEncryptionAlgorithmIdentifier = exports.SignatureAlgorithmIdentifier = exports.DigestAlgorithmIdentifier = exports.CMSVersion = void 0; +const tslib_1 = require("tslib"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +var CMSVersion; +(function (CMSVersion) { + CMSVersion[CMSVersion["v0"] = 0] = "v0"; + CMSVersion[CMSVersion["v1"] = 1] = "v1"; + CMSVersion[CMSVersion["v2"] = 2] = "v2"; + CMSVersion[CMSVersion["v3"] = 3] = "v3"; + CMSVersion[CMSVersion["v4"] = 4] = "v4"; + CMSVersion[CMSVersion["v5"] = 5] = "v5"; +})(CMSVersion || (exports.CMSVersion = CMSVersion = {})); +let DigestAlgorithmIdentifier = class DigestAlgorithmIdentifier extends asn1_x509_1.AlgorithmIdentifier { +}; +exports.DigestAlgorithmIdentifier = DigestAlgorithmIdentifier; +exports.DigestAlgorithmIdentifier = DigestAlgorithmIdentifier = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Sequence }) +], DigestAlgorithmIdentifier); +let SignatureAlgorithmIdentifier = class SignatureAlgorithmIdentifier extends asn1_x509_1.AlgorithmIdentifier { +}; +exports.SignatureAlgorithmIdentifier = SignatureAlgorithmIdentifier; +exports.SignatureAlgorithmIdentifier = SignatureAlgorithmIdentifier = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Sequence }) +], SignatureAlgorithmIdentifier); +let KeyEncryptionAlgorithmIdentifier = class KeyEncryptionAlgorithmIdentifier extends asn1_x509_1.AlgorithmIdentifier { +}; +exports.KeyEncryptionAlgorithmIdentifier = KeyEncryptionAlgorithmIdentifier; +exports.KeyEncryptionAlgorithmIdentifier = KeyEncryptionAlgorithmIdentifier = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Sequence }) +], KeyEncryptionAlgorithmIdentifier); +let ContentEncryptionAlgorithmIdentifier = class ContentEncryptionAlgorithmIdentifier extends asn1_x509_1.AlgorithmIdentifier { +}; +exports.ContentEncryptionAlgorithmIdentifier = ContentEncryptionAlgorithmIdentifier; +exports.ContentEncryptionAlgorithmIdentifier = ContentEncryptionAlgorithmIdentifier = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Sequence }) +], ContentEncryptionAlgorithmIdentifier); +let MessageAuthenticationCodeAlgorithm = class MessageAuthenticationCodeAlgorithm extends asn1_x509_1.AlgorithmIdentifier { +}; +exports.MessageAuthenticationCodeAlgorithm = MessageAuthenticationCodeAlgorithm; +exports.MessageAuthenticationCodeAlgorithm = MessageAuthenticationCodeAlgorithm = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Sequence }) +], MessageAuthenticationCodeAlgorithm); +let KeyDerivationAlgorithmIdentifier = class KeyDerivationAlgorithmIdentifier extends asn1_x509_1.AlgorithmIdentifier { +}; +exports.KeyDerivationAlgorithmIdentifier = KeyDerivationAlgorithmIdentifier; +exports.KeyDerivationAlgorithmIdentifier = KeyDerivationAlgorithmIdentifier = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Sequence }) +], KeyDerivationAlgorithmIdentifier); diff --git a/node_modules/@peculiar/asn1-cms/build/es2015/attribute.js b/node_modules/@peculiar/asn1-cms/build/es2015/attribute.js new file mode 100644 index 0000000000000000000000000000000000000000..ffacd0810d83a89e564572f3eacaf17687881c94 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/es2015/attribute.js @@ -0,0 +1,17 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes } from "@peculiar/asn1-schema"; +export class Attribute { + attrType = ""; + attrValues = []; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.ObjectIdentifier }) +], Attribute.prototype, "attrType", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Any, repeated: "set", + }) +], Attribute.prototype, "attrValues", void 0); diff --git a/node_modules/@peculiar/asn1-cms/build/es2015/attributes/counter_signature.js b/node_modules/@peculiar/asn1-cms/build/es2015/attributes/counter_signature.js new file mode 100644 index 0000000000000000000000000000000000000000..ef6a8a45fd66857c5cb1cd6cf3aa49ecb41c92ac --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/es2015/attributes/counter_signature.js @@ -0,0 +1,10 @@ +import { __decorate } from "tslib"; +import { AsnType, AsnTypeTypes } from "@peculiar/asn1-schema"; +import { SignerInfo } from "../signer_info.js"; +export const id_counterSignature = "1.2.840.113549.1.9.6"; +let CounterSignature = class CounterSignature extends SignerInfo { +}; +CounterSignature = __decorate([ + AsnType({ type: AsnTypeTypes.Sequence }) +], CounterSignature); +export { CounterSignature }; diff --git a/node_modules/@peculiar/asn1-cms/build/es2015/attributes/index.js b/node_modules/@peculiar/asn1-cms/build/es2015/attributes/index.js new file mode 100644 index 0000000000000000000000000000000000000000..747e17cb3c16ca17ce2ef2933b8df303085c3f67 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/es2015/attributes/index.js @@ -0,0 +1,4 @@ +export * from "./counter_signature.js"; +export * from "./message_digest.js"; +export * from "./signing_time.js"; +export const id_contentType = "1.2.840.113549.1.9.3"; diff --git a/node_modules/@peculiar/asn1-cms/build/es2015/attributes/message_digest.js b/node_modules/@peculiar/asn1-cms/build/es2015/attributes/message_digest.js new file mode 100644 index 0000000000000000000000000000000000000000..6fd0fa425f1ffd0e96e926dc70c1ad7543a88bfc --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/es2015/attributes/message_digest.js @@ -0,0 +1,4 @@ +import { OctetString } from "@peculiar/asn1-schema"; +export const id_messageDigest = "1.2.840.113549.1.9.4"; +export class MessageDigest extends OctetString { +} diff --git a/node_modules/@peculiar/asn1-cms/build/es2015/attributes/signing_time.js b/node_modules/@peculiar/asn1-cms/build/es2015/attributes/signing_time.js new file mode 100644 index 0000000000000000000000000000000000000000..ba7cbc1c278fd4777d3bb549b96cd4fb4ac84a54 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/es2015/attributes/signing_time.js @@ -0,0 +1,10 @@ +import { __decorate } from "tslib"; +import { Time } from "@peculiar/asn1-x509"; +import { AsnTypeTypes, AsnType } from "@peculiar/asn1-schema"; +export const id_signingTime = "1.2.840.113549.1.9.5"; +let SigningTime = class SigningTime extends Time { +}; +SigningTime = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], SigningTime); +export { SigningTime }; diff --git a/node_modules/@peculiar/asn1-cms/build/es2015/certificate_choices.js b/node_modules/@peculiar/asn1-cms/build/es2015/certificate_choices.js new file mode 100644 index 0000000000000000000000000000000000000000..0dfcd0cf2846af6c8a52453e6b2bc6a01075722a --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/es2015/certificate_choices.js @@ -0,0 +1,55 @@ +var CertificateSet_1; +import { __decorate } from "tslib"; +import { AsnType, AsnTypeTypes, AsnProp, AsnPropTypes, AsnArray, } from "@peculiar/asn1-schema"; +import { Certificate } from "@peculiar/asn1-x509"; +import { AttributeCertificate } from "@peculiar/asn1-x509-attr"; +export class OtherCertificateFormat { + otherCertFormat = ""; + otherCert = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.ObjectIdentifier }) +], OtherCertificateFormat.prototype, "otherCertFormat", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.Any }) +], OtherCertificateFormat.prototype, "otherCert", void 0); +let CertificateChoices = class CertificateChoices { + certificate; + v2AttrCert; + other; + constructor(params = {}) { + Object.assign(this, params); + } +}; +__decorate([ + AsnProp({ type: Certificate }) +], CertificateChoices.prototype, "certificate", void 0); +__decorate([ + AsnProp({ + type: AttributeCertificate, context: 2, implicit: true, + }) +], CertificateChoices.prototype, "v2AttrCert", void 0); +__decorate([ + AsnProp({ + type: OtherCertificateFormat, context: 3, implicit: true, + }) +], CertificateChoices.prototype, "other", void 0); +CertificateChoices = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], CertificateChoices); +export { CertificateChoices }; +let CertificateSet = CertificateSet_1 = class CertificateSet extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, CertificateSet_1.prototype); + } +}; +CertificateSet = CertificateSet_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Set, itemType: CertificateChoices, + }) +], CertificateSet); +export { CertificateSet }; diff --git a/node_modules/@peculiar/asn1-cms/build/es2015/content_info.js b/node_modules/@peculiar/asn1-cms/build/es2015/content_info.js new file mode 100644 index 0000000000000000000000000000000000000000..8fd98fee8138a3e9f17a1010a2b75f8f2ca1ea0b --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/es2015/content_info.js @@ -0,0 +1,17 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes } from "@peculiar/asn1-schema"; +export class ContentInfo { + contentType = ""; + content = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.ObjectIdentifier }) +], ContentInfo.prototype, "contentType", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Any, context: 0, + }) +], ContentInfo.prototype, "content", void 0); diff --git a/node_modules/@peculiar/asn1-cms/build/es2015/encapsulated_content_info.js b/node_modules/@peculiar/asn1-cms/build/es2015/encapsulated_content_info.js new file mode 100644 index 0000000000000000000000000000000000000000..5fbb57ebbf57d6fd2b3b790819521c91c08b7fd7 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/es2015/encapsulated_content_info.js @@ -0,0 +1,34 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnType, AsnTypeTypes, OctetString, } from "@peculiar/asn1-schema"; +let EncapsulatedContent = class EncapsulatedContent { + single; + any; + constructor(params = {}) { + Object.assign(this, params); + } +}; +__decorate([ + AsnProp({ type: OctetString }) +], EncapsulatedContent.prototype, "single", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.Any }) +], EncapsulatedContent.prototype, "any", void 0); +EncapsulatedContent = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], EncapsulatedContent); +export { EncapsulatedContent }; +export class EncapsulatedContentInfo { + eContentType = ""; + eContent; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.ObjectIdentifier }) +], EncapsulatedContentInfo.prototype, "eContentType", void 0); +__decorate([ + AsnProp({ + type: EncapsulatedContent, context: 0, optional: true, + }) +], EncapsulatedContentInfo.prototype, "eContent", void 0); diff --git a/node_modules/@peculiar/asn1-cms/build/es2015/encrypted_content_info.js b/node_modules/@peculiar/asn1-cms/build/es2015/encrypted_content_info.js new file mode 100644 index 0000000000000000000000000000000000000000..9da3afe12bf6be71705ff9d3d6bde0092f378c8d --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/es2015/encrypted_content_info.js @@ -0,0 +1,48 @@ +import { __decorate } from "tslib"; +import { AsnConstructedOctetStringConverter, AsnProp, AsnPropTypes, AsnType, AsnTypeTypes, OctetString, } from "@peculiar/asn1-schema"; +import { ContentEncryptionAlgorithmIdentifier } from "./types.js"; +let EncryptedContent = class EncryptedContent { + value; + constructedValue; + constructor(params = {}) { + Object.assign(this, params); + } +}; +__decorate([ + AsnProp({ + type: OctetString, context: 0, implicit: true, optional: true, + }) +], EncryptedContent.prototype, "value", void 0); +__decorate([ + AsnProp({ + type: OctetString, + converter: AsnConstructedOctetStringConverter, + context: 0, + implicit: true, + optional: true, + repeated: "sequence", + }) +], EncryptedContent.prototype, "constructedValue", void 0); +EncryptedContent = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], EncryptedContent); +export { EncryptedContent }; +export class EncryptedContentInfo { + contentType = ""; + contentEncryptionAlgorithm = new ContentEncryptionAlgorithmIdentifier(); + encryptedContent; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.ObjectIdentifier }) +], EncryptedContentInfo.prototype, "contentType", void 0); +__decorate([ + AsnProp({ type: ContentEncryptionAlgorithmIdentifier }) +], EncryptedContentInfo.prototype, "contentEncryptionAlgorithm", void 0); +__decorate([ + AsnProp({ + type: EncryptedContent, optional: true, + }) +], EncryptedContentInfo.prototype, "encryptedContent", void 0); diff --git a/node_modules/@peculiar/asn1-cms/build/es2015/enveloped_data.js b/node_modules/@peculiar/asn1-cms/build/es2015/enveloped_data.js new file mode 100644 index 0000000000000000000000000000000000000000..ac0783c35d230ec02a2b4b9f4af838e64f27bc64 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/es2015/enveloped_data.js @@ -0,0 +1,49 @@ +var UnprotectedAttributes_1; +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnArray, AsnType, AsnTypeTypes, } from "@peculiar/asn1-schema"; +import { CMSVersion } from "./types.js"; +import { Attribute } from "./attribute.js"; +import { RecipientInfos } from "./recipient_infos.js"; +import { OriginatorInfo } from "./originator_info.js"; +import { EncryptedContentInfo } from "./encrypted_content_info.js"; +let UnprotectedAttributes = UnprotectedAttributes_1 = class UnprotectedAttributes extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, UnprotectedAttributes_1.prototype); + } +}; +UnprotectedAttributes = UnprotectedAttributes_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Set, itemType: Attribute, + }) +], UnprotectedAttributes); +export { UnprotectedAttributes }; +export class EnvelopedData { + version = CMSVersion.v0; + originatorInfo; + recipientInfos = new RecipientInfos(); + encryptedContentInfo = new EncryptedContentInfo(); + unprotectedAttrs; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.Integer }) +], EnvelopedData.prototype, "version", void 0); +__decorate([ + AsnProp({ + type: OriginatorInfo, context: 0, implicit: true, optional: true, + }) +], EnvelopedData.prototype, "originatorInfo", void 0); +__decorate([ + AsnProp({ type: RecipientInfos }) +], EnvelopedData.prototype, "recipientInfos", void 0); +__decorate([ + AsnProp({ type: EncryptedContentInfo }) +], EnvelopedData.prototype, "encryptedContentInfo", void 0); +__decorate([ + AsnProp({ + type: UnprotectedAttributes, context: 1, implicit: true, optional: true, + }) +], EnvelopedData.prototype, "unprotectedAttrs", void 0); diff --git a/node_modules/@peculiar/asn1-cms/build/es2015/index.js b/node_modules/@peculiar/asn1-cms/build/es2015/index.js new file mode 100644 index 0000000000000000000000000000000000000000..43aa80f7bfad71a5ad93a0d1badf5d5f24fceb9f --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/es2015/index.js @@ -0,0 +1,21 @@ +export * from "./attributes/index.js"; +export * from "./attribute.js"; +export * from "./certificate_choices.js"; +export * from "./content_info.js"; +export * from "./encapsulated_content_info.js"; +export * from "./encrypted_content_info.js"; +export * from "./enveloped_data.js"; +export * from "./issuer_and_serial_number.js"; +export * from "./kek_recipient_info.js"; +export * from "./key_agree_recipient_info.js"; +export * from "./key_trans_recipient_info.js"; +export * from "./object_identifiers.js"; +export * from "./originator_info.js"; +export * from "./password_recipient_info.js"; +export * from "./recipient_info.js"; +export * from "./recipient_infos.js"; +export * from "./revocation_info_choice.js"; +export * from "./signed_data.js"; +export * from "./signer_identifier.js"; +export * from "./signer_info.js"; +export * from "./types.js"; diff --git a/node_modules/@peculiar/asn1-cms/build/es2015/issuer_and_serial_number.js b/node_modules/@peculiar/asn1-cms/build/es2015/issuer_and_serial_number.js new file mode 100644 index 0000000000000000000000000000000000000000..471e119316962fc625d4746c2b62fb2cabdfd235 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/es2015/issuer_and_serial_number.js @@ -0,0 +1,18 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnIntegerArrayBufferConverter, } from "@peculiar/asn1-schema"; +import { Name } from "@peculiar/asn1-x509"; +export class IssuerAndSerialNumber { + issuer = new Name(); + serialNumber = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: Name }) +], IssuerAndSerialNumber.prototype, "issuer", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter, + }) +], IssuerAndSerialNumber.prototype, "serialNumber", void 0); diff --git a/node_modules/@peculiar/asn1-cms/build/es2015/kek_recipient_info.js b/node_modules/@peculiar/asn1-cms/build/es2015/kek_recipient_info.js new file mode 100644 index 0000000000000000000000000000000000000000..8f26c37404d9041f55e8cb29a9a99562a26e0d8c --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/es2015/kek_recipient_info.js @@ -0,0 +1,46 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, OctetString, } from "@peculiar/asn1-schema"; +import { OtherKeyAttribute } from "./other_key_attribute.js"; +import { CMSVersion, KeyEncryptionAlgorithmIdentifier, } from "./types.js"; +export class KEKIdentifier { + keyIdentifier = new OctetString(); + date; + other; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: OctetString }) +], KEKIdentifier.prototype, "keyIdentifier", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.GeneralizedTime, optional: true, + }) +], KEKIdentifier.prototype, "date", void 0); +__decorate([ + AsnProp({ + type: OtherKeyAttribute, optional: true, + }) +], KEKIdentifier.prototype, "other", void 0); +export class KEKRecipientInfo { + version = CMSVersion.v4; + kekid = new KEKIdentifier(); + keyEncryptionAlgorithm = new KeyEncryptionAlgorithmIdentifier(); + encryptedKey = new OctetString(); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.Integer }) +], KEKRecipientInfo.prototype, "version", void 0); +__decorate([ + AsnProp({ type: KEKIdentifier }) +], KEKRecipientInfo.prototype, "kekid", void 0); +__decorate([ + AsnProp({ type: KeyEncryptionAlgorithmIdentifier }) +], KEKRecipientInfo.prototype, "keyEncryptionAlgorithm", void 0); +__decorate([ + AsnProp({ type: OctetString }) +], KEKRecipientInfo.prototype, "encryptedKey", void 0); diff --git a/node_modules/@peculiar/asn1-cms/build/es2015/key_agree_recipient_info.js b/node_modules/@peculiar/asn1-cms/build/es2015/key_agree_recipient_info.js new file mode 100644 index 0000000000000000000000000000000000000000..43274116711dc59949de6f84df69bbe8e4d58400 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/es2015/key_agree_recipient_info.js @@ -0,0 +1,143 @@ +var RecipientEncryptedKeys_1; +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnArray, AsnType, AsnTypeTypes, OctetString, } from "@peculiar/asn1-schema"; +import { AlgorithmIdentifier, SubjectKeyIdentifier } from "@peculiar/asn1-x509"; +import { CMSVersion, KeyEncryptionAlgorithmIdentifier, } from "./types.js"; +import { IssuerAndSerialNumber } from "./issuer_and_serial_number.js"; +import { OtherKeyAttribute } from "./other_key_attribute.js"; +export class RecipientKeyIdentifier { + subjectKeyIdentifier = new SubjectKeyIdentifier(); + date; + other; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: SubjectKeyIdentifier }) +], RecipientKeyIdentifier.prototype, "subjectKeyIdentifier", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.GeneralizedTime, optional: true, + }) +], RecipientKeyIdentifier.prototype, "date", void 0); +__decorate([ + AsnProp({ + type: OtherKeyAttribute, optional: true, + }) +], RecipientKeyIdentifier.prototype, "other", void 0); +let KeyAgreeRecipientIdentifier = class KeyAgreeRecipientIdentifier { + rKeyId; + issuerAndSerialNumber; + constructor(params = {}) { + Object.assign(this, params); + } +}; +__decorate([ + AsnProp({ + type: RecipientKeyIdentifier, context: 0, implicit: true, optional: true, + }) +], KeyAgreeRecipientIdentifier.prototype, "rKeyId", void 0); +__decorate([ + AsnProp({ + type: IssuerAndSerialNumber, optional: true, + }) +], KeyAgreeRecipientIdentifier.prototype, "issuerAndSerialNumber", void 0); +KeyAgreeRecipientIdentifier = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], KeyAgreeRecipientIdentifier); +export { KeyAgreeRecipientIdentifier }; +export class RecipientEncryptedKey { + rid = new KeyAgreeRecipientIdentifier(); + encryptedKey = new OctetString(); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: KeyAgreeRecipientIdentifier }) +], RecipientEncryptedKey.prototype, "rid", void 0); +__decorate([ + AsnProp({ type: OctetString }) +], RecipientEncryptedKey.prototype, "encryptedKey", void 0); +let RecipientEncryptedKeys = RecipientEncryptedKeys_1 = class RecipientEncryptedKeys extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, RecipientEncryptedKeys_1.prototype); + } +}; +RecipientEncryptedKeys = RecipientEncryptedKeys_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Sequence, itemType: RecipientEncryptedKey, + }) +], RecipientEncryptedKeys); +export { RecipientEncryptedKeys }; +export class OriginatorPublicKey { + algorithm = new AlgorithmIdentifier(); + publicKey = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AlgorithmIdentifier }) +], OriginatorPublicKey.prototype, "algorithm", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.BitString }) +], OriginatorPublicKey.prototype, "publicKey", void 0); +let OriginatorIdentifierOrKey = class OriginatorIdentifierOrKey { + subjectKeyIdentifier; + originatorKey; + issuerAndSerialNumber; + constructor(params = {}) { + Object.assign(this, params); + } +}; +__decorate([ + AsnProp({ + type: SubjectKeyIdentifier, context: 0, implicit: true, optional: true, + }) +], OriginatorIdentifierOrKey.prototype, "subjectKeyIdentifier", void 0); +__decorate([ + AsnProp({ + type: OriginatorPublicKey, context: 1, implicit: true, optional: true, + }) +], OriginatorIdentifierOrKey.prototype, "originatorKey", void 0); +__decorate([ + AsnProp({ + type: IssuerAndSerialNumber, optional: true, + }) +], OriginatorIdentifierOrKey.prototype, "issuerAndSerialNumber", void 0); +OriginatorIdentifierOrKey = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], OriginatorIdentifierOrKey); +export { OriginatorIdentifierOrKey }; +export class KeyAgreeRecipientInfo { + version = CMSVersion.v3; + originator = new OriginatorIdentifierOrKey(); + ukm; + keyEncryptionAlgorithm = new KeyEncryptionAlgorithmIdentifier(); + recipientEncryptedKeys = new RecipientEncryptedKeys(); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.Integer }) +], KeyAgreeRecipientInfo.prototype, "version", void 0); +__decorate([ + AsnProp({ + type: OriginatorIdentifierOrKey, context: 0, + }) +], KeyAgreeRecipientInfo.prototype, "originator", void 0); +__decorate([ + AsnProp({ + type: OctetString, context: 1, optional: true, + }) +], KeyAgreeRecipientInfo.prototype, "ukm", void 0); +__decorate([ + AsnProp({ type: KeyEncryptionAlgorithmIdentifier }) +], KeyAgreeRecipientInfo.prototype, "keyEncryptionAlgorithm", void 0); +__decorate([ + AsnProp({ type: RecipientEncryptedKeys }) +], KeyAgreeRecipientInfo.prototype, "recipientEncryptedKeys", void 0); diff --git a/node_modules/@peculiar/asn1-cms/build/es2015/key_trans_recipient_info.js b/node_modules/@peculiar/asn1-cms/build/es2015/key_trans_recipient_info.js new file mode 100644 index 0000000000000000000000000000000000000000..465a85f55ad654c2e9f63631a40d339d16db2c5f --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/es2015/key_trans_recipient_info.js @@ -0,0 +1,45 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnType, AsnTypeTypes, OctetString, } from "@peculiar/asn1-schema"; +import { SubjectKeyIdentifier } from "@peculiar/asn1-x509"; +import { CMSVersion, KeyEncryptionAlgorithmIdentifier, } from "./types.js"; +import { IssuerAndSerialNumber } from "./issuer_and_serial_number.js"; +let RecipientIdentifier = class RecipientIdentifier { + subjectKeyIdentifier; + issuerAndSerialNumber; + constructor(params = {}) { + Object.assign(this, params); + } +}; +__decorate([ + AsnProp({ + type: SubjectKeyIdentifier, context: 0, implicit: true, + }) +], RecipientIdentifier.prototype, "subjectKeyIdentifier", void 0); +__decorate([ + AsnProp({ type: IssuerAndSerialNumber }) +], RecipientIdentifier.prototype, "issuerAndSerialNumber", void 0); +RecipientIdentifier = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], RecipientIdentifier); +export { RecipientIdentifier }; +export class KeyTransRecipientInfo { + version = CMSVersion.v0; + rid = new RecipientIdentifier(); + keyEncryptionAlgorithm = new KeyEncryptionAlgorithmIdentifier(); + encryptedKey = new OctetString(); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.Integer }) +], KeyTransRecipientInfo.prototype, "version", void 0); +__decorate([ + AsnProp({ type: RecipientIdentifier }) +], KeyTransRecipientInfo.prototype, "rid", void 0); +__decorate([ + AsnProp({ type: KeyEncryptionAlgorithmIdentifier }) +], KeyTransRecipientInfo.prototype, "keyEncryptionAlgorithm", void 0); +__decorate([ + AsnProp({ type: OctetString }) +], KeyTransRecipientInfo.prototype, "encryptedKey", void 0); diff --git a/node_modules/@peculiar/asn1-cms/build/es2015/object_identifiers.js b/node_modules/@peculiar/asn1-cms/build/es2015/object_identifiers.js new file mode 100644 index 0000000000000000000000000000000000000000..3a1254e891b98fb6c0afd24e680d987f2785a4b3 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/es2015/object_identifiers.js @@ -0,0 +1,7 @@ +export const id_ct_contentInfo = "1.2.840.113549.1.9.16.1.6"; +export const id_data = "1.2.840.113549.1.7.1"; +export const id_signedData = "1.2.840.113549.1.7.2"; +export const id_envelopedData = "1.2.840.113549.1.7.3"; +export const id_digestedData = "1.2.840.113549.1.7.5"; +export const id_encryptedData = "1.2.840.113549.1.7.6"; +export const id_authData = "1.2.840.113549.1.9.16.1.2"; diff --git a/node_modules/@peculiar/asn1-cms/build/es2015/originator_info.js b/node_modules/@peculiar/asn1-cms/build/es2015/originator_info.js new file mode 100644 index 0000000000000000000000000000000000000000..82d18055ad2bafb72b69be60b8636a96720af4f8 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/es2015/originator_info.js @@ -0,0 +1,21 @@ +import { __decorate } from "tslib"; +import { AsnProp } from "@peculiar/asn1-schema"; +import { CertificateSet } from "./certificate_choices.js"; +import { RevocationInfoChoices } from "./revocation_info_choice.js"; +export class OriginatorInfo { + certs; + crls; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ + type: CertificateSet, context: 0, implicit: true, optional: true, + }) +], OriginatorInfo.prototype, "certs", void 0); +__decorate([ + AsnProp({ + type: RevocationInfoChoices, context: 1, implicit: true, optional: true, + }) +], OriginatorInfo.prototype, "crls", void 0); diff --git a/node_modules/@peculiar/asn1-cms/build/es2015/other_key_attribute.js b/node_modules/@peculiar/asn1-cms/build/es2015/other_key_attribute.js new file mode 100644 index 0000000000000000000000000000000000000000..006c36af44738987ce9945e593cd7bdc7dfd4292 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/es2015/other_key_attribute.js @@ -0,0 +1,17 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes } from "@peculiar/asn1-schema"; +export class OtherKeyAttribute { + keyAttrId = ""; + keyAttr; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.ObjectIdentifier }) +], OtherKeyAttribute.prototype, "keyAttrId", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Any, optional: true, + }) +], OtherKeyAttribute.prototype, "keyAttr", void 0); diff --git a/node_modules/@peculiar/asn1-cms/build/es2015/package.json b/node_modules/@peculiar/asn1-cms/build/es2015/package.json new file mode 100644 index 0000000000000000000000000000000000000000..3dbc1ca591c0557e35b6004aeba250e6a70b56e3 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/es2015/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/node_modules/@peculiar/asn1-cms/build/es2015/password_recipient_info.js b/node_modules/@peculiar/asn1-cms/build/es2015/password_recipient_info.js new file mode 100644 index 0000000000000000000000000000000000000000..3ecc889141377816a6d4b0e8581c21a261ed3acd --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/es2015/password_recipient_info.js @@ -0,0 +1,26 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, OctetString, } from "@peculiar/asn1-schema"; +import { CMSVersion, KeyDerivationAlgorithmIdentifier, KeyEncryptionAlgorithmIdentifier, } from "./types.js"; +export class PasswordRecipientInfo { + version = CMSVersion.v0; + keyDerivationAlgorithm; + keyEncryptionAlgorithm = new KeyEncryptionAlgorithmIdentifier(); + encryptedKey = new OctetString(); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.Integer }) +], PasswordRecipientInfo.prototype, "version", void 0); +__decorate([ + AsnProp({ + type: KeyDerivationAlgorithmIdentifier, context: 0, optional: true, + }) +], PasswordRecipientInfo.prototype, "keyDerivationAlgorithm", void 0); +__decorate([ + AsnProp({ type: KeyEncryptionAlgorithmIdentifier }) +], PasswordRecipientInfo.prototype, "keyEncryptionAlgorithm", void 0); +__decorate([ + AsnProp({ type: OctetString }) +], PasswordRecipientInfo.prototype, "encryptedKey", void 0); diff --git a/node_modules/@peculiar/asn1-cms/build/es2015/recipient_info.js b/node_modules/@peculiar/asn1-cms/build/es2015/recipient_info.js new file mode 100644 index 0000000000000000000000000000000000000000..4dd3274aa2df1a14fe1d7109d6c81ba872bd8ce0 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/es2015/recipient_info.js @@ -0,0 +1,58 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnType, AsnTypeTypes, } from "@peculiar/asn1-schema"; +import { KeyAgreeRecipientInfo } from "./key_agree_recipient_info.js"; +import { KeyTransRecipientInfo } from "./key_trans_recipient_info.js"; +import { KEKRecipientInfo } from "./kek_recipient_info.js"; +import { PasswordRecipientInfo } from "./password_recipient_info.js"; +export class OtherRecipientInfo { + oriType = ""; + oriValue = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.ObjectIdentifier }) +], OtherRecipientInfo.prototype, "oriType", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.Any }) +], OtherRecipientInfo.prototype, "oriValue", void 0); +let RecipientInfo = class RecipientInfo { + ktri; + kari; + kekri; + pwri; + ori; + constructor(params = {}) { + Object.assign(this, params); + } +}; +__decorate([ + AsnProp({ + type: KeyTransRecipientInfo, optional: true, + }) +], RecipientInfo.prototype, "ktri", void 0); +__decorate([ + AsnProp({ + type: KeyAgreeRecipientInfo, context: 1, implicit: true, optional: true, + }) +], RecipientInfo.prototype, "kari", void 0); +__decorate([ + AsnProp({ + type: KEKRecipientInfo, context: 2, implicit: true, optional: true, + }) +], RecipientInfo.prototype, "kekri", void 0); +__decorate([ + AsnProp({ + type: PasswordRecipientInfo, context: 3, implicit: true, optional: true, + }) +], RecipientInfo.prototype, "pwri", void 0); +__decorate([ + AsnProp({ + type: OtherRecipientInfo, context: 4, implicit: true, optional: true, + }) +], RecipientInfo.prototype, "ori", void 0); +RecipientInfo = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], RecipientInfo); +export { RecipientInfo }; diff --git a/node_modules/@peculiar/asn1-cms/build/es2015/recipient_infos.js b/node_modules/@peculiar/asn1-cms/build/es2015/recipient_infos.js new file mode 100644 index 0000000000000000000000000000000000000000..eefd00da14b0fe7ad313bef3409cfec10fb24c34 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/es2015/recipient_infos.js @@ -0,0 +1,16 @@ +var RecipientInfos_1; +import { __decorate } from "tslib"; +import { AsnArray, AsnType, AsnTypeTypes, } from "@peculiar/asn1-schema"; +import { RecipientInfo } from "./recipient_info.js"; +let RecipientInfos = RecipientInfos_1 = class RecipientInfos extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, RecipientInfos_1.prototype); + } +}; +RecipientInfos = RecipientInfos_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Set, itemType: RecipientInfo, + }) +], RecipientInfos); +export { RecipientInfos }; diff --git a/node_modules/@peculiar/asn1-cms/build/es2015/revocation_info_choice.js b/node_modules/@peculiar/asn1-cms/build/es2015/revocation_info_choice.js new file mode 100644 index 0000000000000000000000000000000000000000..646dfb4ba50d25a2ff44548b5abdf8fbb8e8494d --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/es2015/revocation_info_choice.js @@ -0,0 +1,47 @@ +var RevocationInfoChoices_1; +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnType, AsnTypeTypes, AsnArray, } from "@peculiar/asn1-schema"; +import { id_pkix } from "@peculiar/asn1-x509"; +export const id_ri = `${id_pkix}.16`; +export const id_ri_ocsp_response = `${id_ri}.2`; +export const id_ri_scvp = `${id_ri}.4`; +export class OtherRevocationInfoFormat { + otherRevInfoFormat = ""; + otherRevInfo = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.ObjectIdentifier }) +], OtherRevocationInfoFormat.prototype, "otherRevInfoFormat", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.Any }) +], OtherRevocationInfoFormat.prototype, "otherRevInfo", void 0); +let RevocationInfoChoice = class RevocationInfoChoice { + other = new OtherRevocationInfoFormat(); + constructor(params = {}) { + Object.assign(this, params); + } +}; +__decorate([ + AsnProp({ + type: OtherRevocationInfoFormat, context: 1, implicit: true, + }) +], RevocationInfoChoice.prototype, "other", void 0); +RevocationInfoChoice = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], RevocationInfoChoice); +export { RevocationInfoChoice }; +let RevocationInfoChoices = RevocationInfoChoices_1 = class RevocationInfoChoices extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, RevocationInfoChoices_1.prototype); + } +}; +RevocationInfoChoices = RevocationInfoChoices_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Set, itemType: RevocationInfoChoice, + }) +], RevocationInfoChoices); +export { RevocationInfoChoices }; diff --git a/node_modules/@peculiar/asn1-cms/build/es2015/signed_data.js b/node_modules/@peculiar/asn1-cms/build/es2015/signed_data.js new file mode 100644 index 0000000000000000000000000000000000000000..9c655da6dd8a4655671dba36b85ecd1b1df656a4 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/es2015/signed_data.js @@ -0,0 +1,53 @@ +var DigestAlgorithmIdentifiers_1; +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnArray, AsnType, AsnTypeTypes, } from "@peculiar/asn1-schema"; +import { CertificateSet } from "./certificate_choices.js"; +import { CMSVersion, DigestAlgorithmIdentifier } from "./types.js"; +import { EncapsulatedContentInfo } from "./encapsulated_content_info.js"; +import { RevocationInfoChoices } from "./revocation_info_choice.js"; +import { SignerInfos } from "./signer_info.js"; +let DigestAlgorithmIdentifiers = DigestAlgorithmIdentifiers_1 = class DigestAlgorithmIdentifiers extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, DigestAlgorithmIdentifiers_1.prototype); + } +}; +DigestAlgorithmIdentifiers = DigestAlgorithmIdentifiers_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Set, itemType: DigestAlgorithmIdentifier, + }) +], DigestAlgorithmIdentifiers); +export { DigestAlgorithmIdentifiers }; +export class SignedData { + version = CMSVersion.v0; + digestAlgorithms = new DigestAlgorithmIdentifiers(); + encapContentInfo = new EncapsulatedContentInfo(); + certificates; + crls; + signerInfos = new SignerInfos(); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.Integer }) +], SignedData.prototype, "version", void 0); +__decorate([ + AsnProp({ type: DigestAlgorithmIdentifiers }) +], SignedData.prototype, "digestAlgorithms", void 0); +__decorate([ + AsnProp({ type: EncapsulatedContentInfo }) +], SignedData.prototype, "encapContentInfo", void 0); +__decorate([ + AsnProp({ + type: CertificateSet, context: 0, implicit: true, optional: true, + }) +], SignedData.prototype, "certificates", void 0); +__decorate([ + AsnProp({ + type: RevocationInfoChoices, context: 1, implicit: true, optional: true, + }) +], SignedData.prototype, "crls", void 0); +__decorate([ + AsnProp({ type: SignerInfos }) +], SignedData.prototype, "signerInfos", void 0); diff --git a/node_modules/@peculiar/asn1-cms/build/es2015/signer_identifier.js b/node_modules/@peculiar/asn1-cms/build/es2015/signer_identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..e3c763f89eb3045f5e602ab4344769b9cc4fd6ca --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/es2015/signer_identifier.js @@ -0,0 +1,23 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnType, AsnTypeTypes, } from "@peculiar/asn1-schema"; +import { SubjectKeyIdentifier } from "@peculiar/asn1-x509"; +import { IssuerAndSerialNumber } from "./issuer_and_serial_number.js"; +let SignerIdentifier = class SignerIdentifier { + subjectKeyIdentifier; + issuerAndSerialNumber; + constructor(params = {}) { + Object.assign(this, params); + } +}; +__decorate([ + AsnProp({ + type: SubjectKeyIdentifier, context: 0, implicit: true, + }) +], SignerIdentifier.prototype, "subjectKeyIdentifier", void 0); +__decorate([ + AsnProp({ type: IssuerAndSerialNumber }) +], SignerIdentifier.prototype, "issuerAndSerialNumber", void 0); +SignerIdentifier = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], SignerIdentifier); +export { SignerIdentifier }; diff --git a/node_modules/@peculiar/asn1-cms/build/es2015/signer_info.js b/node_modules/@peculiar/asn1-cms/build/es2015/signer_info.js new file mode 100644 index 0000000000000000000000000000000000000000..b6f7623c8811cb7a0cfab7b6ba2ec9f0806f8806 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/es2015/signer_info.js @@ -0,0 +1,61 @@ +var SignerInfos_1; +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnArray, AsnType, AsnTypeTypes, OctetString, } from "@peculiar/asn1-schema"; +import { SignerIdentifier } from "./signer_identifier.js"; +import { CMSVersion, SignatureAlgorithmIdentifier, DigestAlgorithmIdentifier, } from "./types.js"; +import { Attribute } from "./attribute.js"; +export class SignerInfo { + version = CMSVersion.v0; + sid = new SignerIdentifier(); + digestAlgorithm = new DigestAlgorithmIdentifier(); + signedAttrs; + signedAttrsRaw; + signatureAlgorithm = new SignatureAlgorithmIdentifier(); + signature = new OctetString(); + unsignedAttrs; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.Integer }) +], SignerInfo.prototype, "version", void 0); +__decorate([ + AsnProp({ type: SignerIdentifier }) +], SignerInfo.prototype, "sid", void 0); +__decorate([ + AsnProp({ type: DigestAlgorithmIdentifier }) +], SignerInfo.prototype, "digestAlgorithm", void 0); +__decorate([ + AsnProp({ + type: Attribute, + repeated: "set", + context: 0, + implicit: true, + optional: true, + raw: true, + }) +], SignerInfo.prototype, "signedAttrs", void 0); +__decorate([ + AsnProp({ type: SignatureAlgorithmIdentifier }) +], SignerInfo.prototype, "signatureAlgorithm", void 0); +__decorate([ + AsnProp({ type: OctetString }) +], SignerInfo.prototype, "signature", void 0); +__decorate([ + AsnProp({ + type: Attribute, repeated: "set", context: 1, implicit: true, optional: true, + }) +], SignerInfo.prototype, "unsignedAttrs", void 0); +let SignerInfos = SignerInfos_1 = class SignerInfos extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, SignerInfos_1.prototype); + } +}; +SignerInfos = SignerInfos_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Set, itemType: SignerInfo, + }) +], SignerInfos); +export { SignerInfos }; diff --git a/node_modules/@peculiar/asn1-cms/build/es2015/types.js b/node_modules/@peculiar/asn1-cms/build/es2015/types.js new file mode 100644 index 0000000000000000000000000000000000000000..0b0032cefddbe60fe1c8f2b1067d94974d1c4c2a --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/es2015/types.js @@ -0,0 +1,48 @@ +import { __decorate } from "tslib"; +import { AlgorithmIdentifier } from "@peculiar/asn1-x509"; +import { AsnTypeTypes, AsnType, } from "@peculiar/asn1-schema"; +export var CMSVersion; +(function (CMSVersion) { + CMSVersion[CMSVersion["v0"] = 0] = "v0"; + CMSVersion[CMSVersion["v1"] = 1] = "v1"; + CMSVersion[CMSVersion["v2"] = 2] = "v2"; + CMSVersion[CMSVersion["v3"] = 3] = "v3"; + CMSVersion[CMSVersion["v4"] = 4] = "v4"; + CMSVersion[CMSVersion["v5"] = 5] = "v5"; +})(CMSVersion || (CMSVersion = {})); +let DigestAlgorithmIdentifier = class DigestAlgorithmIdentifier extends AlgorithmIdentifier { +}; +DigestAlgorithmIdentifier = __decorate([ + AsnType({ type: AsnTypeTypes.Sequence }) +], DigestAlgorithmIdentifier); +export { DigestAlgorithmIdentifier }; +let SignatureAlgorithmIdentifier = class SignatureAlgorithmIdentifier extends AlgorithmIdentifier { +}; +SignatureAlgorithmIdentifier = __decorate([ + AsnType({ type: AsnTypeTypes.Sequence }) +], SignatureAlgorithmIdentifier); +export { SignatureAlgorithmIdentifier }; +let KeyEncryptionAlgorithmIdentifier = class KeyEncryptionAlgorithmIdentifier extends AlgorithmIdentifier { +}; +KeyEncryptionAlgorithmIdentifier = __decorate([ + AsnType({ type: AsnTypeTypes.Sequence }) +], KeyEncryptionAlgorithmIdentifier); +export { KeyEncryptionAlgorithmIdentifier }; +let ContentEncryptionAlgorithmIdentifier = class ContentEncryptionAlgorithmIdentifier extends AlgorithmIdentifier { +}; +ContentEncryptionAlgorithmIdentifier = __decorate([ + AsnType({ type: AsnTypeTypes.Sequence }) +], ContentEncryptionAlgorithmIdentifier); +export { ContentEncryptionAlgorithmIdentifier }; +let MessageAuthenticationCodeAlgorithm = class MessageAuthenticationCodeAlgorithm extends AlgorithmIdentifier { +}; +MessageAuthenticationCodeAlgorithm = __decorate([ + AsnType({ type: AsnTypeTypes.Sequence }) +], MessageAuthenticationCodeAlgorithm); +export { MessageAuthenticationCodeAlgorithm }; +let KeyDerivationAlgorithmIdentifier = class KeyDerivationAlgorithmIdentifier extends AlgorithmIdentifier { +}; +KeyDerivationAlgorithmIdentifier = __decorate([ + AsnType({ type: AsnTypeTypes.Sequence }) +], KeyDerivationAlgorithmIdentifier); +export { KeyDerivationAlgorithmIdentifier }; diff --git a/node_modules/@peculiar/asn1-cms/build/types/attribute.d.ts b/node_modules/@peculiar/asn1-cms/build/types/attribute.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2c48cd189eb9cfd8ef615156654773d74eae5c1d --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/types/attribute.d.ts @@ -0,0 +1,18 @@ +/** + * ```asn + * AttributeValue ::= ANY + * ``` + */ +export type AttributeValue = ArrayBuffer; +/** + * ```asn + * Attribute ::= SEQUENCE { + * attrType OBJECT IDENTIFIER, + * attrValues SET OF AttributeValue } + * ``` + */ +export declare class Attribute { + attrType: string; + attrValues: AttributeValue[]; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-cms/build/types/attributes/counter_signature.d.ts b/node_modules/@peculiar/asn1-cms/build/types/attributes/counter_signature.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bde59c2dbc17c8453f47fe844054432ede6389c8 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/types/attributes/counter_signature.d.ts @@ -0,0 +1,15 @@ +import { SignerInfo } from "../signer_info"; +/** + * ```asn + * id-countersignature OBJECT IDENTIFIER ::= { iso(1) member-body(2) + * us(840) rsadsi(113549) pkcs(1) pkcs9(9) 6 } + * ``` + */ +export declare const id_counterSignature = "1.2.840.113549.1.9.6"; +/** + * ```asn + * SigningTime ::= Time + * ``` + */ +export declare class CounterSignature extends SignerInfo { +} diff --git a/node_modules/@peculiar/asn1-cms/build/types/attributes/index.d.ts b/node_modules/@peculiar/asn1-cms/build/types/attributes/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ee5129c2a5bdc87de795a5ed7c745654d60cfc4c --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/types/attributes/index.d.ts @@ -0,0 +1,10 @@ +export * from "./counter_signature"; +export * from "./message_digest"; +export * from "./signing_time"; +/** + * ```asn + * id-contentType OBJECT IDENTIFIER ::= { iso(1) member-body(2) + * us(840) rsadsi(113549) pkcs(1) pkcs9(9) 3 } + * ``` + */ +export declare const id_contentType = "1.2.840.113549.1.9.3"; diff --git a/node_modules/@peculiar/asn1-cms/build/types/attributes/message_digest.d.ts b/node_modules/@peculiar/asn1-cms/build/types/attributes/message_digest.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..224e507752f4e7c858e3b8254874833e07e9e714 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/types/attributes/message_digest.d.ts @@ -0,0 +1,15 @@ +import { OctetString } from "@peculiar/asn1-schema"; +/** + * ```asn + * id-messageDigest OBJECT IDENTIFIER ::= { iso(1) member-body(2) + * us(840) rsadsi(113549) pkcs(1) pkcs9(9) 4 } + * ``` + */ +export declare const id_messageDigest = "1.2.840.113549.1.9.4"; +/** + * ```asn + * MessageDigest ::= OCTET STRING + * ``` + */ +export declare class MessageDigest extends OctetString { +} diff --git a/node_modules/@peculiar/asn1-cms/build/types/attributes/signing_time.d.ts b/node_modules/@peculiar/asn1-cms/build/types/attributes/signing_time.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b2b1cb4193dc9e0693fb5a6330ad11f5e108a04d --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/types/attributes/signing_time.d.ts @@ -0,0 +1,15 @@ +import { Time } from "@peculiar/asn1-x509"; +/** + * ```asn + * id-signingTime OBJECT IDENTIFIER ::= { iso(1) member-body(2) + * us(840) rsadsi(113549) pkcs(1) pkcs9(9) 5 } + * ``` + */ +export declare const id_signingTime = "1.2.840.113549.1.9.5"; +/** + * ```asn + * SigningTime ::= Time + * ``` + */ +export declare class SigningTime extends Time { +} diff --git a/node_modules/@peculiar/asn1-cms/build/types/certificate_choices.d.ts b/node_modules/@peculiar/asn1-cms/build/types/certificate_choices.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..83ac148bf169fb25b6b26e345348f8cc4d9e9595 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/types/certificate_choices.d.ts @@ -0,0 +1,39 @@ +import { AsnArray } from "@peculiar/asn1-schema"; +import { Certificate } from "@peculiar/asn1-x509"; +import { AttributeCertificate } from "@peculiar/asn1-x509-attr"; +/** + * ```asn + * OtherCertificateFormat ::= SEQUENCE { + * otherCertFormat OBJECT IDENTIFIER, + * otherCert ANY DEFINED BY otherCertFormat } + * ``` + */ +export declare class OtherCertificateFormat { + otherCertFormat: string; + otherCert: ArrayBuffer; + constructor(params?: Partial); +} +/** + * ```asn + * CertificateChoices ::= CHOICE { + * certificate Certificate, + * extendedCertificate [0] IMPLICIT ExtendedCertificate, -- Obsolete + * v1AttrCert [1] IMPLICIT AttributeCertificateV1, -- Obsolete + * v2AttrCert [2] IMPLICIT AttributeCertificateV2, + * other [3] IMPLICIT OtherCertificateFormat } + * ``` + */ +export declare class CertificateChoices { + certificate?: Certificate; + v2AttrCert?: AttributeCertificate; + other?: OtherCertificateFormat; + constructor(params?: Partial); +} +/** + * ```asn + * CertificateSet ::= SET OF CertificateChoices + * ``` + */ +export declare class CertificateSet extends AsnArray { + constructor(items?: CertificateChoices[]); +} diff --git a/node_modules/@peculiar/asn1-cms/build/types/content_info.d.ts b/node_modules/@peculiar/asn1-cms/build/types/content_info.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..247d5aa929a5c6724a6bb7325b2fcd3dc565c3e6 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/types/content_info.d.ts @@ -0,0 +1,13 @@ +import { ContentType } from "./types"; +/** + * ```asn + * ContentInfo ::= SEQUENCE { + * contentType ContentType, + * content [0] EXPLICIT ANY DEFINED BY contentType } + * ``` + */ +export declare class ContentInfo { + contentType: ContentType; + content: ArrayBuffer; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-cms/build/types/encapsulated_content_info.d.ts b/node_modules/@peculiar/asn1-cms/build/types/encapsulated_content_info.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ba5abc520a56c1a01a1471effcbe0fb086bd0413 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/types/encapsulated_content_info.d.ts @@ -0,0 +1,19 @@ +import { OctetString } from "@peculiar/asn1-schema"; +import { ContentType } from "./types"; +export declare class EncapsulatedContent { + single?: OctetString; + any?: ArrayBuffer; + constructor(params?: Partial); +} +/** + * ```asn + * EncapsulatedContentInfo ::= SEQUENCE { + * eContentType ContentType, + * eContent [0] EXPLICIT OCTET STRING OPTIONAL } + * ``` + */ +export declare class EncapsulatedContentInfo { + eContentType: ContentType; + eContent?: EncapsulatedContent; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-cms/build/types/encrypted_content_info.d.ts b/node_modules/@peculiar/asn1-cms/build/types/encrypted_content_info.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4348fc08575b7d3559a90d35fbbeda53003c3d5c --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/types/encrypted_content_info.d.ts @@ -0,0 +1,26 @@ +import { OctetString } from "@peculiar/asn1-schema"; +import { ContentType, ContentEncryptionAlgorithmIdentifier } from "./types"; +/** + * ```asn + * EncryptedContent ::= OCTET STRING + * ``` + */ +export declare class EncryptedContent { + value?: OctetString; + constructedValue?: OctetString[]; + constructor(params?: Partial); +} +/** + * ```asn + * EncryptedContentInfo ::= SEQUENCE { + * contentType ContentType, + * contentEncryptionAlgorithm ContentEncryptionAlgorithmIdentifier, + * encryptedContent [0] IMPLICIT EncryptedContent OPTIONAL } + * ``` + */ +export declare class EncryptedContentInfo { + contentType: ContentType; + contentEncryptionAlgorithm: ContentEncryptionAlgorithmIdentifier; + encryptedContent?: EncryptedContent; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-cms/build/types/enveloped_data.d.ts b/node_modules/@peculiar/asn1-cms/build/types/enveloped_data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..70f4541968f5206c735c0a54b79b2014c119b87b --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/types/enveloped_data.d.ts @@ -0,0 +1,32 @@ +import { AsnArray } from "@peculiar/asn1-schema"; +import { CMSVersion } from "./types"; +import { Attribute } from "./attribute"; +import { RecipientInfos } from "./recipient_infos"; +import { OriginatorInfo } from "./originator_info"; +import { EncryptedContentInfo } from "./encrypted_content_info"; +/** + * ```asn + * UnprotectedAttributes ::= SET SIZE (1..MAX) OF Attribute + * ``` + */ +export declare class UnprotectedAttributes extends AsnArray { + constructor(items?: Attribute[]); +} +/** + * ```asn + * EnvelopedData ::= SEQUENCE { + * version CMSVersion, + * originatorInfo [0] IMPLICIT OriginatorInfo OPTIONAL, + * recipientInfos RecipientInfos, + * encryptedContentInfo EncryptedContentInfo, + * unprotectedAttrs [1] IMPLICIT UnprotectedAttributes OPTIONAL } + * ``` + */ +export declare class EnvelopedData { + version: CMSVersion; + originatorInfo?: OriginatorInfo; + recipientInfos: RecipientInfos; + encryptedContentInfo: EncryptedContentInfo; + unprotectedAttrs?: UnprotectedAttributes; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-cms/build/types/index.d.ts b/node_modules/@peculiar/asn1-cms/build/types/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d3500bfcfc361ee6974f52cb75efdbfd6a2b9fed --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/types/index.d.ts @@ -0,0 +1,21 @@ +export * from "./attributes"; +export * from "./attribute"; +export * from "./certificate_choices"; +export * from "./content_info"; +export * from "./encapsulated_content_info"; +export * from "./encrypted_content_info"; +export * from "./enveloped_data"; +export * from "./issuer_and_serial_number"; +export * from "./kek_recipient_info"; +export * from "./key_agree_recipient_info"; +export * from "./key_trans_recipient_info"; +export * from "./object_identifiers"; +export * from "./originator_info"; +export * from "./password_recipient_info"; +export * from "./recipient_info"; +export * from "./recipient_infos"; +export * from "./revocation_info_choice"; +export * from "./signed_data"; +export * from "./signer_identifier"; +export * from "./signer_info"; +export * from "./types"; diff --git a/node_modules/@peculiar/asn1-cms/build/types/issuer_and_serial_number.d.ts b/node_modules/@peculiar/asn1-cms/build/types/issuer_and_serial_number.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..50a909ccc1de7311746764b5748725a80af6cd13 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/types/issuer_and_serial_number.d.ts @@ -0,0 +1,19 @@ +import { Name } from "@peculiar/asn1-x509"; +/** + * ```asn + * IssuerAndSerialNumber ::= SEQUENCE { + * issuer Name, + * serialNumber CertificateSerialNumber } + * ``` + */ +export declare class IssuerAndSerialNumber { + issuer: Name; + serialNumber: ArrayBuffer; + constructor(params?: Partial); +} +/** + * ```asn + * CertificateSerialNumber ::= INTEGER + * ``` + */ +export type CertificateSerialNumber = ArrayBuffer; diff --git a/node_modules/@peculiar/asn1-cms/build/types/kek_recipient_info.d.ts b/node_modules/@peculiar/asn1-cms/build/types/kek_recipient_info.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4c53c0cb3dfa38568add303a930e56727a2ef6e0 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/types/kek_recipient_info.d.ts @@ -0,0 +1,33 @@ +import { OctetString } from "@peculiar/asn1-schema"; +import { OtherKeyAttribute } from "./other_key_attribute"; +import { CMSVersion, EncryptedKey, KeyEncryptionAlgorithmIdentifier } from "./types"; +/** + * ```asn + * KEKIdentifier ::= SEQUENCE { + * keyIdentifier OCTET STRING, + * date GeneralizedTime OPTIONAL, + * other OtherKeyAttribute OPTIONAL } + * ``` + */ +export declare class KEKIdentifier { + keyIdentifier: OctetString; + date?: Date; + other?: OtherKeyAttribute; + constructor(params?: Partial); +} +/** + * ```asn + * KEKRecipientInfo ::= SEQUENCE { + * version CMSVersion, -- always set to 4 + * kekid KEKIdentifier, + * keyEncryptionAlgorithm KeyEncryptionAlgorithmIdentifier, + * encryptedKey EncryptedKey } + * ``` + */ +export declare class KEKRecipientInfo { + version: CMSVersion; + kekid: KEKIdentifier; + keyEncryptionAlgorithm: KeyEncryptionAlgorithmIdentifier; + encryptedKey: EncryptedKey; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-cms/build/types/key_agree_recipient_info.d.ts b/node_modules/@peculiar/asn1-cms/build/types/key_agree_recipient_info.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e5df6bfc29e72e3fa04847415324d1d0c8679364 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/types/key_agree_recipient_info.d.ts @@ -0,0 +1,101 @@ +import { AsnArray, OctetString } from "@peculiar/asn1-schema"; +import { AlgorithmIdentifier, SubjectKeyIdentifier } from "@peculiar/asn1-x509"; +import { CMSVersion, KeyEncryptionAlgorithmIdentifier, EncryptedKey } from "./types"; +import { IssuerAndSerialNumber } from "./issuer_and_serial_number"; +import { OtherKeyAttribute } from "./other_key_attribute"; +/** + * ```asn + * UserKeyingMaterial ::= OCTET STRING + * ``` + */ +export type UserKeyingMaterial = OctetString; +/** + * ```asn + * RecipientKeyIdentifier ::= SEQUENCE { + * subjectKeyIdentifier SubjectKeyIdentifier, + * date GeneralizedTime OPTIONAL, + * other OtherKeyAttribute OPTIONAL } + * ``` + */ +export declare class RecipientKeyIdentifier { + subjectKeyIdentifier: SubjectKeyIdentifier; + date?: Date; + other?: OtherKeyAttribute; + constructor(params?: Partial); +} +/** + * ```asn + * KeyAgreeRecipientIdentifier ::= CHOICE { + * issuerAndSerialNumber IssuerAndSerialNumber, + * rKeyId [0] IMPLICIT RecipientKeyIdentifier } + * ``` + */ +export declare class KeyAgreeRecipientIdentifier { + rKeyId?: RecipientKeyIdentifier; + issuerAndSerialNumber?: IssuerAndSerialNumber; + constructor(params?: Partial); +} +/** + * ```asn + * RecipientEncryptedKey ::= SEQUENCE { + * rid KeyAgreeRecipientIdentifier, + * encryptedKey EncryptedKey } + * ``` + */ +export declare class RecipientEncryptedKey { + rid: KeyAgreeRecipientIdentifier; + encryptedKey: EncryptedKey; + constructor(params?: Partial); +} +/** + * ```asn + * RecipientEncryptedKeys ::= SEQUENCE OF RecipientEncryptedKey + * ``` + */ +export declare class RecipientEncryptedKeys extends AsnArray { + constructor(items?: RecipientEncryptedKey[]); +} +/** + * ```asn + * OriginatorPublicKey ::= SEQUENCE { + * algorithm AlgorithmIdentifier, + * publicKey BIT STRING } + * ``` + */ +export declare class OriginatorPublicKey { + algorithm: AlgorithmIdentifier; + publicKey: ArrayBuffer; + constructor(params?: Partial); +} +/** + * ```asn + * OriginatorIdentifierOrKey ::= CHOICE { + * issuerAndSerialNumber IssuerAndSerialNumber, + * subjectKeyIdentifier [0] SubjectKeyIdentifier, + * originatorKey [1] OriginatorPublicKey } + * ``` + */ +export declare class OriginatorIdentifierOrKey { + subjectKeyIdentifier?: SubjectKeyIdentifier; + originatorKey?: OriginatorPublicKey; + issuerAndSerialNumber?: IssuerAndSerialNumber; + constructor(params?: Partial); +} +/** + * ```asn + * KeyAgreeRecipientInfo ::= SEQUENCE { + * version CMSVersion, -- always set to 3 + * originator [0] EXPLICIT OriginatorIdentifierOrKey, + * ukm [1] EXPLICIT UserKeyingMaterial OPTIONAL, + * keyEncryptionAlgorithm KeyEncryptionAlgorithmIdentifier, + * recipientEncryptedKeys RecipientEncryptedKeys } + * ``` + */ +export declare class KeyAgreeRecipientInfo { + version: CMSVersion; + originator: OriginatorIdentifierOrKey; + ukm?: UserKeyingMaterial; + keyEncryptionAlgorithm: KeyEncryptionAlgorithmIdentifier; + recipientEncryptedKeys: RecipientEncryptedKeys; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-cms/build/types/key_trans_recipient_info.d.ts b/node_modules/@peculiar/asn1-cms/build/types/key_trans_recipient_info.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b3218f0e84b062d5d5020b2dd40c5c4e12eaa40f --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/types/key_trans_recipient_info.d.ts @@ -0,0 +1,31 @@ +import { SubjectKeyIdentifier } from "@peculiar/asn1-x509"; +import { CMSVersion, KeyEncryptionAlgorithmIdentifier, EncryptedKey } from "./types"; +import { IssuerAndSerialNumber } from "./issuer_and_serial_number"; +/** + * ```asn + * RecipientIdentifier ::= CHOICE { + * issuerAndSerialNumber IssuerAndSerialNumber, + * subjectKeyIdentifier [0] SubjectKeyIdentifier } + * ``` + */ +export declare class RecipientIdentifier { + subjectKeyIdentifier?: SubjectKeyIdentifier; + issuerAndSerialNumber?: IssuerAndSerialNumber; + constructor(params?: Partial); +} +/** + * ```asn + * KeyTransRecipientInfo ::= SEQUENCE { + * version CMSVersion, -- always set to 0 or 2 + * rid RecipientIdentifier, + * keyEncryptionAlgorithm KeyEncryptionAlgorithmIdentifier, + * encryptedKey EncryptedKey } + * ``` + */ +export declare class KeyTransRecipientInfo { + version: CMSVersion; + rid: RecipientIdentifier; + keyEncryptionAlgorithm: KeyEncryptionAlgorithmIdentifier; + encryptedKey: EncryptedKey; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-cms/build/types/object_identifiers.d.ts b/node_modules/@peculiar/asn1-cms/build/types/object_identifiers.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..725a49d08baddf3020baba678df5544e95b92fe9 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/types/object_identifiers.d.ts @@ -0,0 +1,49 @@ +/** + * ```asn + * id-ct-contentInfo OBJECT IDENTIFIER ::= { iso(1) member-body(2) + * us(840) rsadsi(113549) pkcs(1) pkcs9(9) smime(16) ct(1) 6 } + * ``` + */ +export declare const id_ct_contentInfo = "1.2.840.113549.1.9.16.1.6"; +/** + * ```asn + * id-data OBJECT IDENTIFIER ::= { iso(1) member-body(2) + * us(840) rsadsi(113549) pkcs(1) pkcs7(7) 1 } + * ``` + */ +export declare const id_data = "1.2.840.113549.1.7.1"; +/** + * ```asn + * id-signedData OBJECT IDENTIFIER ::= { iso(1) member-body(2) + * us(840) rsadsi(113549) pkcs(1) pkcs7(7) 2 } + * ``` + */ +export declare const id_signedData = "1.2.840.113549.1.7.2"; +/** + * ```asn + * id-envelopedData OBJECT IDENTIFIER ::= { iso(1) member-body(2) + * us(840) rsadsi(113549) pkcs(1) pkcs7(7) 3 } + * ``` + */ +export declare const id_envelopedData = "1.2.840.113549.1.7.3"; +/** + * ```asn + * id-digestedData OBJECT IDENTIFIER ::= { iso(1) member-body(2) + * us(840) rsadsi(113549) pkcs(1) pkcs7(7) 5 } + * ``` + */ +export declare const id_digestedData = "1.2.840.113549.1.7.5"; +/** + * ```asn + * id-encryptedData OBJECT IDENTIFIER ::= { iso(1) member-body(2) + * us(840) rsadsi(113549) pkcs(1) pkcs7(7) 6 } + * ``` + */ +export declare const id_encryptedData = "1.2.840.113549.1.7.6"; +/** + * ```asn + * id-ct-authData OBJECT IDENTIFIER ::= { iso(1) member-body(2) + * us(840) rsadsi(113549) pkcs(1) pkcs-9(9) smime(16) ct(1) 2 } + * ``` + */ +export declare const id_authData = "1.2.840.113549.1.9.16.1.2"; diff --git a/node_modules/@peculiar/asn1-cms/build/types/originator_info.d.ts b/node_modules/@peculiar/asn1-cms/build/types/originator_info.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2433f8820739aa286b1199e618d5a3fae90b0437 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/types/originator_info.d.ts @@ -0,0 +1,14 @@ +import { CertificateSet } from "./certificate_choices"; +import { RevocationInfoChoices } from "./revocation_info_choice"; +/** + * ```asn + * OriginatorInfo ::= SEQUENCE { + * certs [0] IMPLICIT CertificateSet OPTIONAL, + * crls [1] IMPLICIT RevocationInfoChoices OPTIONAL } + * ``` + */ +export declare class OriginatorInfo { + certs?: CertificateSet; + crls?: RevocationInfoChoices; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-cms/build/types/other_key_attribute.d.ts b/node_modules/@peculiar/asn1-cms/build/types/other_key_attribute.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..dd858d1c5da0260e3500e42b15411384074a1fee --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/types/other_key_attribute.d.ts @@ -0,0 +1,12 @@ +/** + * ```asn + * OtherKeyAttribute ::= SEQUENCE { + * keyAttrId OBJECT IDENTIFIER, + * keyAttr ANY DEFINED BY keyAttrId OPTIONAL } + * ``` + */ +export declare class OtherKeyAttribute { + keyAttrId: string; + keyAttr?: ArrayBuffer; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-cms/build/types/password_recipient_info.d.ts b/node_modules/@peculiar/asn1-cms/build/types/password_recipient_info.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c9384078ef7100fbe612b0db74bb3ac3f4c31f77 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/types/password_recipient_info.d.ts @@ -0,0 +1,17 @@ +import { CMSVersion, KeyDerivationAlgorithmIdentifier, KeyEncryptionAlgorithmIdentifier, EncryptedKey } from "./types"; +/** + * ```asn + * PasswordRecipientInfo ::= SEQUENCE { + * version CMSVersion, -- Always set to 0 + * keyDerivationAlgorithm [0] KeyDerivationAlgorithmIdentifier OPTIONAL, + * keyEncryptionAlgorithm KeyEncryptionAlgorithmIdentifier, + * encryptedKey EncryptedKey } + * ``` + */ +export declare class PasswordRecipientInfo { + version: CMSVersion; + keyDerivationAlgorithm?: KeyDerivationAlgorithmIdentifier; + keyEncryptionAlgorithm: KeyEncryptionAlgorithmIdentifier; + encryptedKey: EncryptedKey; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-cms/build/types/recipient_info.d.ts b/node_modules/@peculiar/asn1-cms/build/types/recipient_info.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3610de681b803689a9406c8742f243503295d45 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/types/recipient_info.d.ts @@ -0,0 +1,34 @@ +import { KeyAgreeRecipientInfo } from "./key_agree_recipient_info"; +import { KeyTransRecipientInfo } from "./key_trans_recipient_info"; +import { KEKRecipientInfo } from "./kek_recipient_info"; +import { PasswordRecipientInfo } from "./password_recipient_info"; +/** + * ```asn + * OtherRecipientInfo ::= SEQUENCE { + * oriType OBJECT IDENTIFIER, + * oriValue ANY DEFINED BY oriType } + * ``` + */ +export declare class OtherRecipientInfo { + oriType: string; + oriValue: ArrayBuffer; + constructor(params?: Partial); +} +/** + * ```asn + * RecipientInfo ::= CHOICE { + * ktri KeyTransRecipientInfo, + * kari [1] KeyAgreeRecipientInfo, + * kekri [2] KEKRecipientInfo, + * pwri [3] PasswordRecipientInfo, + * ori [4] OtherRecipientInfo } + * ``` + */ +export declare class RecipientInfo { + ktri?: KeyTransRecipientInfo; + kari?: KeyAgreeRecipientInfo; + kekri?: KEKRecipientInfo; + pwri?: PasswordRecipientInfo; + ori?: OtherRecipientInfo; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-cms/build/types/recipient_infos.d.ts b/node_modules/@peculiar/asn1-cms/build/types/recipient_infos.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a973a33f760b94d5eb3a960dffb300adea3a7b47 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/types/recipient_infos.d.ts @@ -0,0 +1,10 @@ +import { AsnArray } from "@peculiar/asn1-schema"; +import { RecipientInfo } from "./recipient_info"; +/** + * ```asn + * RecipientInfos ::= SET SIZE (1..MAX) OF RecipientInfo + * ``` + */ +export declare class RecipientInfos extends AsnArray { + constructor(items?: RecipientInfo[]); +} diff --git a/node_modules/@peculiar/asn1-cms/build/types/revocation_info_choice.d.ts b/node_modules/@peculiar/asn1-cms/build/types/revocation_info_choice.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fa1af83da955b3e567298a86e6da8ba74e000632 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/types/revocation_info_choice.d.ts @@ -0,0 +1,52 @@ +import { AsnArray } from "@peculiar/asn1-schema"; +/** + * ```asn + * id-ri OBJECT IDENTIFIER ::= + * { iso(1) identified-organization(3) + dod(6) internet(1) security(5) mechanisms(5) pkix(7) ri(16) } + * ``` + */ +export declare const id_ri = "1.3.6.1.5.5.7.16"; +/** + * ```asn + * id-ri-ocsp-response OBJECT IDENTIFIER ::= { id-ri 2 } + * ``` + */ +export declare const id_ri_ocsp_response = "1.3.6.1.5.5.7.16.2"; +/** + * ```asn + * id-ri-scvp OBJECT IDENTIFIER ::= { id-ri 4 } + * ``` + */ +export declare const id_ri_scvp = "1.3.6.1.5.5.7.16.4"; +/** + * ```asn + * OtherRevocationInfoFormat ::= SEQUENCE { + * otherRevInfoFormat OBJECT IDENTIFIER, + * otherRevInfo ANY DEFINED BY otherRevInfoFormat } + * ``` + */ +export declare class OtherRevocationInfoFormat { + otherRevInfoFormat: string; + otherRevInfo: ArrayBuffer; + constructor(params?: Partial); +} +/** + * ```asn + * RevocationInfoChoice ::= CHOICE { + * crl CertificateList, + * other [1] IMPLICIT OtherRevocationInfoFormat } + * ``` + */ +export declare class RevocationInfoChoice { + other: OtherRevocationInfoFormat; + constructor(params?: Partial); +} +/** + * ```asn + * RevocationInfoChoices ::= SET OF RevocationInfoChoice + * ``` + */ +export declare class RevocationInfoChoices extends AsnArray { + constructor(items?: RevocationInfoChoice[]); +} diff --git a/node_modules/@peculiar/asn1-cms/build/types/signed_data.d.ts b/node_modules/@peculiar/asn1-cms/build/types/signed_data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7f05a4b4e961207da51975a3e72094ee8a98339f --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/types/signed_data.d.ts @@ -0,0 +1,34 @@ +import { AsnArray } from "@peculiar/asn1-schema"; +import { CertificateSet } from "./certificate_choices"; +import { CMSVersion, DigestAlgorithmIdentifier } from "./types"; +import { EncapsulatedContentInfo } from "./encapsulated_content_info"; +import { RevocationInfoChoices } from "./revocation_info_choice"; +import { SignerInfos } from "./signer_info"; +/** + * ```asn + * DigestAlgorithmIdentifiers ::= SET OF DigestAlgorithmIdentifier + * ``` + */ +export declare class DigestAlgorithmIdentifiers extends AsnArray { + constructor(items?: DigestAlgorithmIdentifier[]); +} +/** + * ```asn + * SignedData ::= SEQUENCE { + * version CMSVersion, + * digestAlgorithms DigestAlgorithmIdentifiers, + * encapContentInfo EncapsulatedContentInfo, + * certificates [0] IMPLICIT CertificateSet OPTIONAL, + * crls [1] IMPLICIT RevocationInfoChoices OPTIONAL, + * signerInfos SignerInfos } + * ``` + */ +export declare class SignedData { + version: CMSVersion; + digestAlgorithms: DigestAlgorithmIdentifiers; + encapContentInfo: EncapsulatedContentInfo; + certificates?: CertificateSet; + crls?: RevocationInfoChoices; + signerInfos: SignerInfos; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-cms/build/types/signer_identifier.d.ts b/node_modules/@peculiar/asn1-cms/build/types/signer_identifier.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..427f68a8c0b7fb1d0ffbc7269be95365aa69a28c --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/types/signer_identifier.d.ts @@ -0,0 +1,14 @@ +import { SubjectKeyIdentifier } from "@peculiar/asn1-x509"; +import { IssuerAndSerialNumber } from "./issuer_and_serial_number"; +/** + * ```asn + * SignerIdentifier ::= CHOICE { + * issuerAndSerialNumber IssuerAndSerialNumber, + * subjectKeyIdentifier [0] SubjectKeyIdentifier } + * ``` + */ +export declare class SignerIdentifier { + subjectKeyIdentifier?: SubjectKeyIdentifier; + issuerAndSerialNumber?: IssuerAndSerialNumber; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-cms/build/types/signer_info.d.ts b/node_modules/@peculiar/asn1-cms/build/types/signer_info.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e5124b5e8fea370ba7ff87df6112e11d20c4b1a0 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/types/signer_info.d.ts @@ -0,0 +1,53 @@ +import { AsnArray, OctetString } from "@peculiar/asn1-schema"; +import { SignerIdentifier } from "./signer_identifier"; +import { CMSVersion, SignatureAlgorithmIdentifier, DigestAlgorithmIdentifier } from "./types"; +import { Attribute } from "./attribute"; +/** + * ```asn + * SignedAttributes ::= SET SIZE (1..MAX) OF Attribute + * ``` + */ +export type SignedAttributes = Attribute[]; +/** + * ```asn + * UnsignedAttributes ::= SET SIZE (1..MAX) OF Attribute + * ``` + */ +export type UnsignedAttributes = Attribute[]; +/** + * ```asn + * SignatureValue ::= OCTET STRING + * ``` + */ +export type SignatureValue = OctetString; +/** + * ```asn + * SignerInfo ::= SEQUENCE { + * version CMSVersion, + * sid SignerIdentifier, + * digestAlgorithm DigestAlgorithmIdentifier, + * signedAttrs [0] IMPLICIT SignedAttributes OPTIONAL, + * signatureAlgorithm SignatureAlgorithmIdentifier, + * signature SignatureValue, + * unsignedAttrs [1] IMPLICIT UnsignedAttributes OPTIONAL } + * ``` + */ +export declare class SignerInfo { + version: CMSVersion; + sid: SignerIdentifier; + digestAlgorithm: DigestAlgorithmIdentifier; + signedAttrs?: SignedAttributes; + signedAttrsRaw?: ArrayBuffer; + signatureAlgorithm: SignatureAlgorithmIdentifier; + signature: SignatureValue; + unsignedAttrs?: UnsignedAttributes; + constructor(params?: Partial); +} +/** + * ```asn + * SignerInfos ::= SET OF SignerInfo + * ``` + */ +export declare class SignerInfos extends AsnArray { + constructor(items?: SignerInfo[]); +} diff --git a/node_modules/@peculiar/asn1-cms/build/types/types.d.ts b/node_modules/@peculiar/asn1-cms/build/types/types.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d67f225c1570b9c02bfdbe005cc909c1bde04354 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/build/types/types.d.ts @@ -0,0 +1,69 @@ +import { AlgorithmIdentifier } from "@peculiar/asn1-x509"; +import { OctetString } from "@peculiar/asn1-schema"; +/** + * ```asn + * ContentType ::= OBJECT IDENTIFIER + * ``` + */ +export type ContentType = string; +/** + * ```asn + * CMSVersion ::= INTEGER { v0(0), v1(1), v2(2), v3(3), v4(4), v5(5) } + * ``` + */ +export declare enum CMSVersion { + v0 = 0, + v1 = 1, + v2 = 2, + v3 = 3, + v4 = 4, + v5 = 5 +} +/** + * ```asn + * EncryptedKey ::= OCTET STRING + * ``` + */ +export type EncryptedKey = OctetString; +/** + * ```asn + * DigestAlgorithmIdentifier ::= AlgorithmIdentifier + * ``` + */ +export declare class DigestAlgorithmIdentifier extends AlgorithmIdentifier { +} +/** + * ```asn + * SignatureAlgorithmIdentifier ::= AlgorithmIdentifier + * ``` + */ +export declare class SignatureAlgorithmIdentifier extends AlgorithmIdentifier { +} +/** + * ```asn + * KeyEncryptionAlgorithmIdentifier ::= AlgorithmIdentifier + * ``` + */ +export declare class KeyEncryptionAlgorithmIdentifier extends AlgorithmIdentifier { +} +/** + * ```asn + * ContentEncryptionAlgorithmIdentifier ::= AlgorithmIdentifier + * ``` + */ +export declare class ContentEncryptionAlgorithmIdentifier extends AlgorithmIdentifier { +} +/** + * ```asn + * MessageAuthenticationCodeAlgorithm ::= AlgorithmIdentifier + * ``` + */ +export declare class MessageAuthenticationCodeAlgorithm extends AlgorithmIdentifier { +} +/** + * ```asn + * KeyDerivationAlgorithmIdentifier ::= AlgorithmIdentifier + * ``` + */ +export declare class KeyDerivationAlgorithmIdentifier extends AlgorithmIdentifier { +} diff --git a/node_modules/@peculiar/asn1-cms/package.json b/node_modules/@peculiar/asn1-cms/package.json new file mode 100644 index 0000000000000000000000000000000000000000..f7492b628d3aa5d1b48dff33ad2e1df54ca5f850 --- /dev/null +++ b/node_modules/@peculiar/asn1-cms/package.json @@ -0,0 +1,62 @@ +{ + "name": "@peculiar/asn1-cms", + "version": "2.8.0", + "description": "ASN.1 schema for Cryptographic Message Syntax (CMS) defined in RFC 5652.", + "keywords": [ + "asn", + "asn1", + "cms", + "pkcs7", + "cryptography", + "rfc5652" + ], + "author": "PeculiarVentures, LLC", + "license": "MIT", + "files": [ + "build/**/*.{js,d.ts}", + "build/es2015/package.json", + "LICENSE", + "README.md" + ], + "main": "build/cjs/index.js", + "module": "build/es2015/index.js", + "types": "build/types/index.d.ts", + "exports": { + ".": { + "types": "./build/types/index.d.ts", + "import": "./build/es2015/index.js", + "require": "./build/cjs/index.js" + }, + "./package.json": "./package.json" + }, + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "https://github.com/PeculiarVentures/asn1-schema", + "directory": "packages/cms" + }, + "bugs": { + "url": "https://github.com/PeculiarVentures/asn1-schema/issues" + }, + "homepage": "https://github.com/PeculiarVentures/asn1-schema/tree/master/packages/cms#readme", + "scripts": { + "clear": "rimraf build", + "build": "npm run build:module && npm run build:types", + "build:module": "npm run build:cjs && npm run build:es2015", + "build:cjs": "tsc -p tsconfig.compile.json --removeComments --module commonjs --outDir build/cjs", + "build:es2015": "tsc -p tsconfig.compile.json --removeComments --module ES2015 --outDir build/es2015", + "postbuild:es2015": "node ../../scripts/prepare_esm_package.mjs build/es2015", + "prebuild:types": "rimraf build/types", + "build:types": "tsc -p tsconfig.compile.json --outDir build/types --declaration --emitDeclarationOnly", + "rebuild": "npm run clear && npm run build" + }, + "dependencies": { + "@peculiar/asn1-schema": "^2.8.0", + "@peculiar/asn1-x509": "^2.8.0", + "@peculiar/asn1-x509-attr": "^2.8.0", + "asn1js": "^3.0.10", + "tslib": "^2.8.1" + } +} diff --git a/node_modules/@peculiar/asn1-csr/LICENSE b/node_modules/@peculiar/asn1-csr/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..43675934676182bb2368abb1a371722a830453eb --- /dev/null +++ b/node_modules/@peculiar/asn1-csr/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@peculiar/asn1-csr/README.md b/node_modules/@peculiar/asn1-csr/README.md new file mode 100644 index 0000000000000000000000000000000000000000..a8ce83216ffb38db994dc05a299fb0acfc7a051f --- /dev/null +++ b/node_modules/@peculiar/asn1-csr/README.md @@ -0,0 +1,20 @@ +# `@peculiar/asn1-csr` + +[![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/PeculiarVentures/asn1-schema/blob/master/packages/csr/LICENSE) +[![npm version](https://badge.fury.io/js/%40peculiar%2Fasn1-csr.svg)](https://badge.fury.io/js/%40peculiar%2Fasn1-csr) + +[![NPM](https://nodei.co/npm/@peculiar/asn1-csr.png)](https://nodei.co/npm/@peculiar/asn1-csr/) + +ASN.1 schema for PKCS #10 certificate signing requests defined in RFC 2986. + +Use the exported classes with `@peculiar/asn1-schema` helpers such as `AsnConvert`, `AsnParser`, and `AsnSerializer` to parse or serialize DER-encoded data defined by the referenced specification. + +## Installation + +```bash +npm install @peculiar/asn1-csr +``` + +## Specifications + +- [RFC 2986: PKCS #10 Certification Request Syntax Specification](https://datatracker.ietf.org/doc/html/rfc2986) diff --git a/node_modules/@peculiar/asn1-csr/build/cjs/attributes.js b/node_modules/@peculiar/asn1-csr/build/cjs/attributes.js new file mode 100644 index 0000000000000000000000000000000000000000..1dc882c0fcdb6eec725fd344162d62b00292a3c1 --- /dev/null +++ b/node_modules/@peculiar/asn1-csr/build/cjs/attributes.js @@ -0,0 +1,19 @@ +"use strict"; +var Attributes_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Attributes = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +let Attributes = Attributes_1 = class Attributes extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, Attributes_1.prototype); + } +}; +exports.Attributes = Attributes; +exports.Attributes = Attributes = Attributes_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Sequence, itemType: asn1_x509_1.Attribute, + }) +], Attributes); diff --git a/node_modules/@peculiar/asn1-csr/build/cjs/certification_request.js b/node_modules/@peculiar/asn1-csr/build/cjs/certification_request.js new file mode 100644 index 0000000000000000000000000000000000000000..7f2573ad39c2452effbd4eba9f23ef450b12f51e --- /dev/null +++ b/node_modules/@peculiar/asn1-csr/build/cjs/certification_request.js @@ -0,0 +1,28 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CertificationRequest = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +const certification_request_info_1 = require("./certification_request_info"); +class CertificationRequest { + certificationRequestInfo = new certification_request_info_1.CertificationRequestInfo(); + certificationRequestInfoRaw; + signatureAlgorithm = new asn1_x509_1.AlgorithmIdentifier(); + signature = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.CertificationRequest = CertificationRequest; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: certification_request_info_1.CertificationRequestInfo, raw: true, + }) +], CertificationRequest.prototype, "certificationRequestInfo", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_x509_1.AlgorithmIdentifier }) +], CertificationRequest.prototype, "signatureAlgorithm", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.BitString }) +], CertificationRequest.prototype, "signature", void 0); diff --git a/node_modules/@peculiar/asn1-csr/build/cjs/certification_request_info.js b/node_modules/@peculiar/asn1-csr/build/cjs/certification_request_info.js new file mode 100644 index 0000000000000000000000000000000000000000..bcc8d0ece62d6195e4be668e98311f9bad8f2f27 --- /dev/null +++ b/node_modules/@peculiar/asn1-csr/build/cjs/certification_request_info.js @@ -0,0 +1,31 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CertificationRequestInfo = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +const attributes_1 = require("./attributes"); +class CertificationRequestInfo { + version = 0; + subject = new asn1_x509_1.Name(); + subjectPKInfo = new asn1_x509_1.SubjectPublicKeyInfo(); + attributes = new attributes_1.Attributes(); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.CertificationRequestInfo = CertificationRequestInfo; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer }) +], CertificationRequestInfo.prototype, "version", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_x509_1.Name }) +], CertificationRequestInfo.prototype, "subject", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_x509_1.SubjectPublicKeyInfo }) +], CertificationRequestInfo.prototype, "subjectPKInfo", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: attributes_1.Attributes, implicit: true, context: 0, optional: true, + }) +], CertificationRequestInfo.prototype, "attributes", void 0); diff --git a/node_modules/@peculiar/asn1-csr/build/cjs/index.js b/node_modules/@peculiar/asn1-csr/build/cjs/index.js new file mode 100644 index 0000000000000000000000000000000000000000..001149e91f7179047c5f1f4e425be3b712064b43 --- /dev/null +++ b/node_modules/@peculiar/asn1-csr/build/cjs/index.js @@ -0,0 +1,6 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +tslib_1.__exportStar(require("./attributes"), exports); +tslib_1.__exportStar(require("./certification_request"), exports); +tslib_1.__exportStar(require("./certification_request_info"), exports); diff --git a/node_modules/@peculiar/asn1-csr/build/es2015/attributes.js b/node_modules/@peculiar/asn1-csr/build/es2015/attributes.js new file mode 100644 index 0000000000000000000000000000000000000000..488ccd195e9e99926063e5f131d42fe0ae9d9c58 --- /dev/null +++ b/node_modules/@peculiar/asn1-csr/build/es2015/attributes.js @@ -0,0 +1,16 @@ +var Attributes_1; +import { __decorate } from "tslib"; +import { AsnArray, AsnType, AsnTypeTypes, } from "@peculiar/asn1-schema"; +import { Attribute } from "@peculiar/asn1-x509"; +let Attributes = Attributes_1 = class Attributes extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, Attributes_1.prototype); + } +}; +Attributes = Attributes_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Sequence, itemType: Attribute, + }) +], Attributes); +export { Attributes }; diff --git a/node_modules/@peculiar/asn1-csr/build/es2015/certification_request.js b/node_modules/@peculiar/asn1-csr/build/es2015/certification_request.js new file mode 100644 index 0000000000000000000000000000000000000000..e27c26da6ed4d9e883b0ea6c4e3b5d98a9db447e --- /dev/null +++ b/node_modules/@peculiar/asn1-csr/build/es2015/certification_request.js @@ -0,0 +1,24 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes } from "@peculiar/asn1-schema"; +import { AlgorithmIdentifier } from "@peculiar/asn1-x509"; +import { CertificationRequestInfo } from "./certification_request_info.js"; +export class CertificationRequest { + certificationRequestInfo = new CertificationRequestInfo(); + certificationRequestInfoRaw; + signatureAlgorithm = new AlgorithmIdentifier(); + signature = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ + type: CertificationRequestInfo, raw: true, + }) +], CertificationRequest.prototype, "certificationRequestInfo", void 0); +__decorate([ + AsnProp({ type: AlgorithmIdentifier }) +], CertificationRequest.prototype, "signatureAlgorithm", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.BitString }) +], CertificationRequest.prototype, "signature", void 0); diff --git a/node_modules/@peculiar/asn1-csr/build/es2015/certification_request_info.js b/node_modules/@peculiar/asn1-csr/build/es2015/certification_request_info.js new file mode 100644 index 0000000000000000000000000000000000000000..791c7b3af32b9302f264b32216c114c9dfd28b69 --- /dev/null +++ b/node_modules/@peculiar/asn1-csr/build/es2015/certification_request_info.js @@ -0,0 +1,27 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes } from "@peculiar/asn1-schema"; +import { Name, SubjectPublicKeyInfo } from "@peculiar/asn1-x509"; +import { Attributes } from "./attributes.js"; +export class CertificationRequestInfo { + version = 0; + subject = new Name(); + subjectPKInfo = new SubjectPublicKeyInfo(); + attributes = new Attributes(); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.Integer }) +], CertificationRequestInfo.prototype, "version", void 0); +__decorate([ + AsnProp({ type: Name }) +], CertificationRequestInfo.prototype, "subject", void 0); +__decorate([ + AsnProp({ type: SubjectPublicKeyInfo }) +], CertificationRequestInfo.prototype, "subjectPKInfo", void 0); +__decorate([ + AsnProp({ + type: Attributes, implicit: true, context: 0, optional: true, + }) +], CertificationRequestInfo.prototype, "attributes", void 0); diff --git a/node_modules/@peculiar/asn1-csr/build/es2015/index.js b/node_modules/@peculiar/asn1-csr/build/es2015/index.js new file mode 100644 index 0000000000000000000000000000000000000000..a0432f7f98869ff32ad23c52be67b5e54655fa9c --- /dev/null +++ b/node_modules/@peculiar/asn1-csr/build/es2015/index.js @@ -0,0 +1,3 @@ +export * from "./attributes.js"; +export * from "./certification_request.js"; +export * from "./certification_request_info.js"; diff --git a/node_modules/@peculiar/asn1-csr/build/es2015/package.json b/node_modules/@peculiar/asn1-csr/build/es2015/package.json new file mode 100644 index 0000000000000000000000000000000000000000..3dbc1ca591c0557e35b6004aeba250e6a70b56e3 --- /dev/null +++ b/node_modules/@peculiar/asn1-csr/build/es2015/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/node_modules/@peculiar/asn1-csr/build/types/attributes.d.ts b/node_modules/@peculiar/asn1-csr/build/types/attributes.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..72eefbf0c9b176b55ed43e1c65fe246048c7b2e8 --- /dev/null +++ b/node_modules/@peculiar/asn1-csr/build/types/attributes.d.ts @@ -0,0 +1,10 @@ +import { AsnArray } from "@peculiar/asn1-schema"; +import { Attribute } from "@peculiar/asn1-x509"; +/** + * ```asn1 + * Attributes { ATTRIBUTE:IOSet } ::= SET OF Attribute{{ IOSet }} + * ``` + */ +export declare class Attributes extends AsnArray { + constructor(items?: Attribute[]); +} diff --git a/node_modules/@peculiar/asn1-csr/build/types/certification_request.d.ts b/node_modules/@peculiar/asn1-csr/build/types/certification_request.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..03b68d06d97a59b756e2186cded1f0c5b872b20a --- /dev/null +++ b/node_modules/@peculiar/asn1-csr/build/types/certification_request.d.ts @@ -0,0 +1,18 @@ +import { AlgorithmIdentifier } from "@peculiar/asn1-x509"; +import { CertificationRequestInfo } from "./certification_request_info"; +/** + * ```asn1 + * CertificationRequest ::= SEQUENCE { + * certificationRequestInfo CertificationRequestInfo, + * signatureAlgorithm AlgorithmIdentifier{{ SignatureAlgorithms }}, + * signature BIT STRING + * } + * ``` + */ +export declare class CertificationRequest { + certificationRequestInfo: CertificationRequestInfo; + certificationRequestInfoRaw?: ArrayBuffer; + signatureAlgorithm: AlgorithmIdentifier; + signature: ArrayBuffer; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-csr/build/types/certification_request_info.d.ts b/node_modules/@peculiar/asn1-csr/build/types/certification_request_info.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b29efda52e553d88350e208725443123727ae2fd --- /dev/null +++ b/node_modules/@peculiar/asn1-csr/build/types/certification_request_info.d.ts @@ -0,0 +1,37 @@ +import { Name, SubjectPublicKeyInfo } from "@peculiar/asn1-x509"; +import { Attributes } from "./attributes"; +/** + * ```asn1 + * CertificationRequestInfo ::= SEQUENCE { + * version INTEGER { v1(0) } (v1,...), + * subject Name, + * subjectPKInfo SubjectPublicKeyInfo{{ PKInfoAlgorithms }}, + * attributes [0] Attributes{{ CRIAttributes }} + * } + * ``` + */ +export declare class CertificationRequestInfo { + version: number; + subject: Name; + subjectPKInfo: SubjectPublicKeyInfo; + /** + * List of attributes providing additional information about the + * subject of the certification request. + * + * @remarks + * The textual description in RFC 2986 (see https://datatracker.ietf.org/doc/rfc2986/) + * indicates that a certification request contains "optionally a set of attributes". + * The ASN.1 module in appendix A does not include the `OPTIONAL` keyword for this + * component, which is a formal inconsistency. In practice, popular implementations + * (for example OpenSSL) are tolerant and accept both forms: + * - the attributes field present as an empty context-specific element (A0 00), + * - the attributes field completely omitted. + * + * To be compatible with real-world CSR encodings, this property is marked + * `optional: true` in the decorator. Consumers should therefore treat + * `certificationRequestInfo.attributes` as possibly `undefined` and + * handle that case (for example, treat `undefined` as an empty set of attributes). + */ + attributes: Attributes; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-csr/build/types/index.d.ts b/node_modules/@peculiar/asn1-csr/build/types/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5d0d2b32805c8267c4af4524b7c363826f1a63cb --- /dev/null +++ b/node_modules/@peculiar/asn1-csr/build/types/index.d.ts @@ -0,0 +1,3 @@ +export * from "./attributes"; +export * from "./certification_request"; +export * from "./certification_request_info"; diff --git a/node_modules/@peculiar/asn1-csr/package.json b/node_modules/@peculiar/asn1-csr/package.json new file mode 100644 index 0000000000000000000000000000000000000000..789371b0c3f8dcbb97608e4e1f3c03c6382219e6 --- /dev/null +++ b/node_modules/@peculiar/asn1-csr/package.json @@ -0,0 +1,62 @@ +{ + "name": "@peculiar/asn1-csr", + "version": "2.8.0", + "description": "ASN.1 schema for PKCS #10 certificate signing requests defined in RFC 2986.", + "keywords": [ + "asn", + "asn1", + "csr", + "pkcs10", + "certificate-request", + "rfc2986" + ], + "author": "PeculiarVentures, LLC", + "license": "MIT", + "files": [ + "build/**/*.{js,d.ts}", + "build/es2015/package.json", + "LICENSE", + "README.md" + ], + "main": "build/cjs/index.js", + "module": "build/es2015/index.js", + "types": "build/types/index.d.ts", + "exports": { + ".": { + "types": "./build/types/index.d.ts", + "import": "./build/es2015/index.js", + "require": "./build/cjs/index.js" + }, + "./package.json": "./package.json" + }, + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "https://github.com/PeculiarVentures/asn1-schema", + "directory": "packages/csr" + }, + "bugs": { + "url": "https://github.com/PeculiarVentures/asn1-schema/issues" + }, + "homepage": "https://github.com/PeculiarVentures/asn1-schema/tree/master/packages/csr#readme", + "scripts": { + "clear": "rimraf build", + "build": "npm run build:module && npm run build:types", + "build:module": "npm run build:cjs && npm run build:es2015", + "build:cjs": "tsc -p tsconfig.compile.json --removeComments --module commonjs --outDir build/cjs", + "build:es2015": "tsc -p tsconfig.compile.json --removeComments --module ES2015 --outDir build/es2015", + "postbuild:es2015": "node ../../scripts/prepare_esm_package.mjs build/es2015", + "prebuild:types": "rimraf build/types", + "build:types": "tsc -p tsconfig.compile.json --outDir build/types --declaration --emitDeclarationOnly", + "rebuild": "npm run clear && npm run build", + "test": "mocha" + }, + "dependencies": { + "@peculiar/asn1-schema": "^2.8.0", + "@peculiar/asn1-x509": "^2.8.0", + "asn1js": "^3.0.10", + "tslib": "^2.8.1" + } +} diff --git a/node_modules/@peculiar/asn1-ecc/LICENSE b/node_modules/@peculiar/asn1-ecc/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..43675934676182bb2368abb1a371722a830453eb --- /dev/null +++ b/node_modules/@peculiar/asn1-ecc/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@peculiar/asn1-ecc/README.md b/node_modules/@peculiar/asn1-ecc/README.md new file mode 100644 index 0000000000000000000000000000000000000000..45d1f45b16a29b1e99319a2ae3b2b395a6b4d7f2 --- /dev/null +++ b/node_modules/@peculiar/asn1-ecc/README.md @@ -0,0 +1,22 @@ +# `@peculiar/asn1-ecc` + +[![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/PeculiarVentures/asn1-schema/blob/master/packages/ecc/LICENSE) +[![npm version](https://badge.fury.io/js/%40peculiar%2Fasn1-ecc.svg)](https://badge.fury.io/js/%40peculiar%2Fasn1-ecc) + +[![NPM](https://nodei.co/npm/@peculiar/asn1-ecc.png)](https://nodei.co/npm/@peculiar/asn1-ecc/) + +ASN.1 schema for elliptic-curve private keys and related identifiers defined in RFC 5915, RFC 5480, and RFC 3279. + +Use the exported classes with `@peculiar/asn1-schema` helpers such as `AsnConvert`, `AsnParser`, and `AsnSerializer` to parse or serialize DER-encoded data defined by the referenced specification. + +## Installation + +```bash +npm install @peculiar/asn1-ecc +``` + +## Specifications + +- [RFC 5915: Elliptic Curve Private Key Structure](https://datatracker.ietf.org/doc/html/rfc5915) +- [RFC 5480: Elliptic Curve Cryptography Subject Public Key Information](https://datatracker.ietf.org/doc/html/rfc5480) +- [RFC 3279: Algorithms and Identifiers for the Internet X.509 Public Key Infrastructure Certificate and CRL Profile](https://datatracker.ietf.org/doc/html/rfc3279#section-2.3.5) diff --git a/node_modules/@peculiar/asn1-ecc/build/cjs/algorithms.js b/node_modules/@peculiar/asn1-ecc/build/cjs/algorithms.js new file mode 100644 index 0000000000000000000000000000000000000000..c3eba059bb23ee19b2b1fece36a55d1b3e866b98 --- /dev/null +++ b/node_modules/@peculiar/asn1-ecc/build/cjs/algorithms.js @@ -0,0 +1,14 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ecdsaWithSHA512 = exports.ecdsaWithSHA384 = exports.ecdsaWithSHA256 = exports.ecdsaWithSHA224 = exports.ecdsaWithSHA1 = void 0; +const tslib_1 = require("tslib"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +const oid = tslib_1.__importStar(require("./object_identifiers")); +function create(algorithm) { + return new asn1_x509_1.AlgorithmIdentifier({ algorithm }); +} +exports.ecdsaWithSHA1 = create(oid.id_ecdsaWithSHA1); +exports.ecdsaWithSHA224 = create(oid.id_ecdsaWithSHA224); +exports.ecdsaWithSHA256 = create(oid.id_ecdsaWithSHA256); +exports.ecdsaWithSHA384 = create(oid.id_ecdsaWithSHA384); +exports.ecdsaWithSHA512 = create(oid.id_ecdsaWithSHA512); diff --git a/node_modules/@peculiar/asn1-ecc/build/cjs/ec_parameters.js b/node_modules/@peculiar/asn1-ecc/build/cjs/ec_parameters.js new file mode 100644 index 0000000000000000000000000000000000000000..9652b3628844fc09e90da963983fdd6d278181cb --- /dev/null +++ b/node_modules/@peculiar/asn1-ecc/build/cjs/ec_parameters.js @@ -0,0 +1,27 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ECParameters = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const rfc3279_1 = require("./rfc3279"); +let ECParameters = class ECParameters { + namedCurve; + implicitCurve; + specifiedCurve; + constructor(params = {}) { + Object.assign(this, params); + } +}; +exports.ECParameters = ECParameters; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.ObjectIdentifier }) +], ECParameters.prototype, "namedCurve", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Null }) +], ECParameters.prototype, "implicitCurve", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: rfc3279_1.SpecifiedECDomain }) +], ECParameters.prototype, "specifiedCurve", void 0); +exports.ECParameters = ECParameters = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], ECParameters); diff --git a/node_modules/@peculiar/asn1-ecc/build/cjs/ec_private_key.js b/node_modules/@peculiar/asn1-ecc/build/cjs/ec_private_key.js new file mode 100644 index 0000000000000000000000000000000000000000..75d9ad7256371a2d87e71337b481c5d4bb2eea06 --- /dev/null +++ b/node_modules/@peculiar/asn1-ecc/build/cjs/ec_private_key.js @@ -0,0 +1,32 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ECPrivateKey = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const ec_parameters_1 = require("./ec_parameters"); +class ECPrivateKey { + version = 1; + privateKey = new asn1_schema_1.OctetString(); + parameters; + publicKey; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.ECPrivateKey = ECPrivateKey; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer }) +], ECPrivateKey.prototype, "version", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.OctetString }) +], ECPrivateKey.prototype, "privateKey", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: ec_parameters_1.ECParameters, context: 0, optional: true, + }) +], ECPrivateKey.prototype, "parameters", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.BitString, context: 1, optional: true, + }) +], ECPrivateKey.prototype, "publicKey", void 0); diff --git a/node_modules/@peculiar/asn1-ecc/build/cjs/ec_signature_value.js b/node_modules/@peculiar/asn1-ecc/build/cjs/ec_signature_value.js new file mode 100644 index 0000000000000000000000000000000000000000..c36f6c5f97e656afbf1cb95b2315833dea7d92dd --- /dev/null +++ b/node_modules/@peculiar/asn1-ecc/build/cjs/ec_signature_value.js @@ -0,0 +1,23 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ECDSASigValue = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +class ECDSASigValue { + r = new ArrayBuffer(0); + s = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.ECDSASigValue = ECDSASigValue; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter, + }) +], ECDSASigValue.prototype, "r", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter, + }) +], ECDSASigValue.prototype, "s", void 0); diff --git a/node_modules/@peculiar/asn1-ecc/build/cjs/index.js b/node_modules/@peculiar/asn1-ecc/build/cjs/index.js new file mode 100644 index 0000000000000000000000000000000000000000..916de2b4252f7f020dd11ffbfa6d57a367d7b29e --- /dev/null +++ b/node_modules/@peculiar/asn1-ecc/build/cjs/index.js @@ -0,0 +1,9 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +tslib_1.__exportStar(require("./algorithms"), exports); +tslib_1.__exportStar(require("./ec_parameters"), exports); +tslib_1.__exportStar(require("./ec_private_key"), exports); +tslib_1.__exportStar(require("./ec_signature_value"), exports); +tslib_1.__exportStar(require("./object_identifiers"), exports); +tslib_1.__exportStar(require("./rfc3279"), exports); diff --git a/node_modules/@peculiar/asn1-ecc/build/cjs/object_identifiers.js b/node_modules/@peculiar/asn1-ecc/build/cjs/object_identifiers.js new file mode 100644 index 0000000000000000000000000000000000000000..78717a320b1c9913c2a3bc51671b17009ccbb024 --- /dev/null +++ b/node_modules/@peculiar/asn1-ecc/build/cjs/object_identifiers.js @@ -0,0 +1,26 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.id_sect571r1 = exports.id_sect571k1 = exports.id_secp521r1 = exports.id_sect409r1 = exports.id_sect409k1 = exports.id_secp384r1 = exports.id_sect283r1 = exports.id_sect283k1 = exports.id_secp256r1 = exports.id_sect233r1 = exports.id_sect233k1 = exports.id_secp224r1 = exports.id_sect163r2 = exports.id_sect163k1 = exports.id_secp192r1 = exports.id_ecdsaWithSHA512 = exports.id_ecdsaWithSHA384 = exports.id_ecdsaWithSHA256 = exports.id_ecdsaWithSHA224 = exports.id_ecdsaWithSHA1 = exports.id_ecMQV = exports.id_ecDH = exports.id_ecPublicKey = void 0; +exports.id_ecPublicKey = "1.2.840.10045.2.1"; +exports.id_ecDH = "1.3.132.1.12"; +exports.id_ecMQV = "1.3.132.1.13"; +exports.id_ecdsaWithSHA1 = "1.2.840.10045.4.1"; +exports.id_ecdsaWithSHA224 = "1.2.840.10045.4.3.1"; +exports.id_ecdsaWithSHA256 = "1.2.840.10045.4.3.2"; +exports.id_ecdsaWithSHA384 = "1.2.840.10045.4.3.3"; +exports.id_ecdsaWithSHA512 = "1.2.840.10045.4.3.4"; +exports.id_secp192r1 = "1.2.840.10045.3.1.1"; +exports.id_sect163k1 = "1.3.132.0.1"; +exports.id_sect163r2 = "1.3.132.0.15"; +exports.id_secp224r1 = "1.3.132.0.33"; +exports.id_sect233k1 = "1.3.132.0.26"; +exports.id_sect233r1 = "1.3.132.0.27"; +exports.id_secp256r1 = "1.2.840.10045.3.1.7"; +exports.id_sect283k1 = "1.3.132.0.16"; +exports.id_sect283r1 = "1.3.132.0.17"; +exports.id_secp384r1 = "1.3.132.0.34"; +exports.id_sect409k1 = "1.3.132.0.36"; +exports.id_sect409r1 = "1.3.132.0.37"; +exports.id_secp521r1 = "1.3.132.0.35"; +exports.id_sect571k1 = "1.3.132.0.38"; +exports.id_sect571r1 = "1.3.132.0.39"; diff --git a/node_modules/@peculiar/asn1-ecc/build/cjs/rfc3279.js b/node_modules/@peculiar/asn1-ecc/build/cjs/rfc3279.js new file mode 100644 index 0000000000000000000000000000000000000000..72f7db4820ca3484c766e3ddbca2515617c3d454 --- /dev/null +++ b/node_modules/@peculiar/asn1-ecc/build/cjs/rfc3279.js @@ -0,0 +1,92 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SpecifiedECDomain = exports.ECPVer = exports.Curve = exports.FieldElement = exports.ECPoint = exports.FieldID = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +let FieldID = class FieldID { + fieldType; + parameters; + constructor(params = {}) { + Object.assign(this, params); + } +}; +exports.FieldID = FieldID; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.ObjectIdentifier }) +], FieldID.prototype, "fieldType", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Any }) +], FieldID.prototype, "parameters", void 0); +exports.FieldID = FieldID = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Sequence }) +], FieldID); +class ECPoint extends asn1_schema_1.OctetString { +} +exports.ECPoint = ECPoint; +class FieldElement extends asn1_schema_1.OctetString { +} +exports.FieldElement = FieldElement; +let Curve = class Curve { + a; + b; + seed; + constructor(params = {}) { + Object.assign(this, params); + } +}; +exports.Curve = Curve; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.OctetString }) +], Curve.prototype, "a", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.OctetString }) +], Curve.prototype, "b", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.BitString, optional: true, + }) +], Curve.prototype, "seed", void 0); +exports.Curve = Curve = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Sequence }) +], Curve); +var ECPVer; +(function (ECPVer) { + ECPVer[ECPVer["ecpVer1"] = 1] = "ecpVer1"; +})(ECPVer || (exports.ECPVer = ECPVer = {})); +let SpecifiedECDomain = class SpecifiedECDomain { + version = ECPVer.ecpVer1; + fieldID; + curve; + base; + order; + cofactor; + constructor(params = {}) { + Object.assign(this, params); + } +}; +exports.SpecifiedECDomain = SpecifiedECDomain; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer }) +], SpecifiedECDomain.prototype, "version", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: FieldID }) +], SpecifiedECDomain.prototype, "fieldID", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: Curve }) +], SpecifiedECDomain.prototype, "curve", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: ECPoint }) +], SpecifiedECDomain.prototype, "base", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter, + }) +], SpecifiedECDomain.prototype, "order", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, optional: true, + }) +], SpecifiedECDomain.prototype, "cofactor", void 0); +exports.SpecifiedECDomain = SpecifiedECDomain = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Sequence }) +], SpecifiedECDomain); diff --git a/node_modules/@peculiar/asn1-ecc/build/es2015/algorithms.js b/node_modules/@peculiar/asn1-ecc/build/es2015/algorithms.js new file mode 100644 index 0000000000000000000000000000000000000000..4946ce4d4d82953a56fdeb7c697933e2a15f8ed8 --- /dev/null +++ b/node_modules/@peculiar/asn1-ecc/build/es2015/algorithms.js @@ -0,0 +1,10 @@ +import { AlgorithmIdentifier } from "@peculiar/asn1-x509"; +import * as oid from "./object_identifiers.js"; +function create(algorithm) { + return new AlgorithmIdentifier({ algorithm }); +} +export const ecdsaWithSHA1 = create(oid.id_ecdsaWithSHA1); +export const ecdsaWithSHA224 = create(oid.id_ecdsaWithSHA224); +export const ecdsaWithSHA256 = create(oid.id_ecdsaWithSHA256); +export const ecdsaWithSHA384 = create(oid.id_ecdsaWithSHA384); +export const ecdsaWithSHA512 = create(oid.id_ecdsaWithSHA512); diff --git a/node_modules/@peculiar/asn1-ecc/build/es2015/ec_parameters.js b/node_modules/@peculiar/asn1-ecc/build/es2015/ec_parameters.js new file mode 100644 index 0000000000000000000000000000000000000000..1f65dc13cb8d6ce7a3dec6dddfa46d436ee610e5 --- /dev/null +++ b/node_modules/@peculiar/asn1-ecc/build/es2015/ec_parameters.js @@ -0,0 +1,24 @@ +import { __decorate } from "tslib"; +import { AsnType, AsnTypeTypes, AsnProp, AsnPropTypes, } from "@peculiar/asn1-schema"; +import { SpecifiedECDomain } from "./rfc3279.js"; +let ECParameters = class ECParameters { + namedCurve; + implicitCurve; + specifiedCurve; + constructor(params = {}) { + Object.assign(this, params); + } +}; +__decorate([ + AsnProp({ type: AsnPropTypes.ObjectIdentifier }) +], ECParameters.prototype, "namedCurve", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.Null }) +], ECParameters.prototype, "implicitCurve", void 0); +__decorate([ + AsnProp({ type: SpecifiedECDomain }) +], ECParameters.prototype, "specifiedCurve", void 0); +ECParameters = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], ECParameters); +export { ECParameters }; diff --git a/node_modules/@peculiar/asn1-ecc/build/es2015/ec_private_key.js b/node_modules/@peculiar/asn1-ecc/build/es2015/ec_private_key.js new file mode 100644 index 0000000000000000000000000000000000000000..8bc42b32420a206df39b2ef13dd60497d79ceede --- /dev/null +++ b/node_modules/@peculiar/asn1-ecc/build/es2015/ec_private_key.js @@ -0,0 +1,28 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, OctetString, } from "@peculiar/asn1-schema"; +import { ECParameters } from "./ec_parameters.js"; +export class ECPrivateKey { + version = 1; + privateKey = new OctetString(); + parameters; + publicKey; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.Integer }) +], ECPrivateKey.prototype, "version", void 0); +__decorate([ + AsnProp({ type: OctetString }) +], ECPrivateKey.prototype, "privateKey", void 0); +__decorate([ + AsnProp({ + type: ECParameters, context: 0, optional: true, + }) +], ECPrivateKey.prototype, "parameters", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.BitString, context: 1, optional: true, + }) +], ECPrivateKey.prototype, "publicKey", void 0); diff --git a/node_modules/@peculiar/asn1-ecc/build/es2015/ec_signature_value.js b/node_modules/@peculiar/asn1-ecc/build/es2015/ec_signature_value.js new file mode 100644 index 0000000000000000000000000000000000000000..4dd09d2e4d660c9f7391d4ba377e6d74ac56ee77 --- /dev/null +++ b/node_modules/@peculiar/asn1-ecc/build/es2015/ec_signature_value.js @@ -0,0 +1,19 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnIntegerArrayBufferConverter, } from "@peculiar/asn1-schema"; +export class ECDSASigValue { + r = new ArrayBuffer(0); + s = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter, + }) +], ECDSASigValue.prototype, "r", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter, + }) +], ECDSASigValue.prototype, "s", void 0); diff --git a/node_modules/@peculiar/asn1-ecc/build/es2015/index.js b/node_modules/@peculiar/asn1-ecc/build/es2015/index.js new file mode 100644 index 0000000000000000000000000000000000000000..fec9ad56a8c9d3cdee97d15a88595d70f2f2b9b9 --- /dev/null +++ b/node_modules/@peculiar/asn1-ecc/build/es2015/index.js @@ -0,0 +1,6 @@ +export * from "./algorithms.js"; +export * from "./ec_parameters.js"; +export * from "./ec_private_key.js"; +export * from "./ec_signature_value.js"; +export * from "./object_identifiers.js"; +export * from "./rfc3279.js"; diff --git a/node_modules/@peculiar/asn1-ecc/build/es2015/object_identifiers.js b/node_modules/@peculiar/asn1-ecc/build/es2015/object_identifiers.js new file mode 100644 index 0000000000000000000000000000000000000000..5caace84b2cbede8974720c35942fe583a0f1646 --- /dev/null +++ b/node_modules/@peculiar/asn1-ecc/build/es2015/object_identifiers.js @@ -0,0 +1,23 @@ +export const id_ecPublicKey = "1.2.840.10045.2.1"; +export const id_ecDH = "1.3.132.1.12"; +export const id_ecMQV = "1.3.132.1.13"; +export const id_ecdsaWithSHA1 = "1.2.840.10045.4.1"; +export const id_ecdsaWithSHA224 = "1.2.840.10045.4.3.1"; +export const id_ecdsaWithSHA256 = "1.2.840.10045.4.3.2"; +export const id_ecdsaWithSHA384 = "1.2.840.10045.4.3.3"; +export const id_ecdsaWithSHA512 = "1.2.840.10045.4.3.4"; +export const id_secp192r1 = "1.2.840.10045.3.1.1"; +export const id_sect163k1 = "1.3.132.0.1"; +export const id_sect163r2 = "1.3.132.0.15"; +export const id_secp224r1 = "1.3.132.0.33"; +export const id_sect233k1 = "1.3.132.0.26"; +export const id_sect233r1 = "1.3.132.0.27"; +export const id_secp256r1 = "1.2.840.10045.3.1.7"; +export const id_sect283k1 = "1.3.132.0.16"; +export const id_sect283r1 = "1.3.132.0.17"; +export const id_secp384r1 = "1.3.132.0.34"; +export const id_sect409k1 = "1.3.132.0.36"; +export const id_sect409r1 = "1.3.132.0.37"; +export const id_secp521r1 = "1.3.132.0.35"; +export const id_sect571k1 = "1.3.132.0.38"; +export const id_sect571r1 = "1.3.132.0.39"; diff --git a/node_modules/@peculiar/asn1-ecc/build/es2015/package.json b/node_modules/@peculiar/asn1-ecc/build/es2015/package.json new file mode 100644 index 0000000000000000000000000000000000000000..3dbc1ca591c0557e35b6004aeba250e6a70b56e3 --- /dev/null +++ b/node_modules/@peculiar/asn1-ecc/build/es2015/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/node_modules/@peculiar/asn1-ecc/build/es2015/rfc3279.js b/node_modules/@peculiar/asn1-ecc/build/es2015/rfc3279.js new file mode 100644 index 0000000000000000000000000000000000000000..fc87128907407c5e9beb32195181f41b40dbbe30 --- /dev/null +++ b/node_modules/@peculiar/asn1-ecc/build/es2015/rfc3279.js @@ -0,0 +1,87 @@ +import { __decorate } from "tslib"; +import { AsnType, AsnTypeTypes, AsnProp, AsnPropTypes, OctetString, AsnIntegerArrayBufferConverter, } from "@peculiar/asn1-schema"; +let FieldID = class FieldID { + fieldType; + parameters; + constructor(params = {}) { + Object.assign(this, params); + } +}; +__decorate([ + AsnProp({ type: AsnPropTypes.ObjectIdentifier }) +], FieldID.prototype, "fieldType", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.Any }) +], FieldID.prototype, "parameters", void 0); +FieldID = __decorate([ + AsnType({ type: AsnTypeTypes.Sequence }) +], FieldID); +export { FieldID }; +export class ECPoint extends OctetString { +} +export class FieldElement extends OctetString { +} +let Curve = class Curve { + a; + b; + seed; + constructor(params = {}) { + Object.assign(this, params); + } +}; +__decorate([ + AsnProp({ type: AsnPropTypes.OctetString }) +], Curve.prototype, "a", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.OctetString }) +], Curve.prototype, "b", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.BitString, optional: true, + }) +], Curve.prototype, "seed", void 0); +Curve = __decorate([ + AsnType({ type: AsnTypeTypes.Sequence }) +], Curve); +export { Curve }; +export var ECPVer; +(function (ECPVer) { + ECPVer[ECPVer["ecpVer1"] = 1] = "ecpVer1"; +})(ECPVer || (ECPVer = {})); +let SpecifiedECDomain = class SpecifiedECDomain { + version = ECPVer.ecpVer1; + fieldID; + curve; + base; + order; + cofactor; + constructor(params = {}) { + Object.assign(this, params); + } +}; +__decorate([ + AsnProp({ type: AsnPropTypes.Integer }) +], SpecifiedECDomain.prototype, "version", void 0); +__decorate([ + AsnProp({ type: FieldID }) +], SpecifiedECDomain.prototype, "fieldID", void 0); +__decorate([ + AsnProp({ type: Curve }) +], SpecifiedECDomain.prototype, "curve", void 0); +__decorate([ + AsnProp({ type: ECPoint }) +], SpecifiedECDomain.prototype, "base", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter, + }) +], SpecifiedECDomain.prototype, "order", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, optional: true, + }) +], SpecifiedECDomain.prototype, "cofactor", void 0); +SpecifiedECDomain = __decorate([ + AsnType({ type: AsnTypeTypes.Sequence }) +], SpecifiedECDomain); +export { SpecifiedECDomain }; diff --git a/node_modules/@peculiar/asn1-ecc/build/types/algorithms.d.ts b/node_modules/@peculiar/asn1-ecc/build/types/algorithms.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..214fe803818b6e822913d2002103ea6bd406b4a8 --- /dev/null +++ b/node_modules/@peculiar/asn1-ecc/build/types/algorithms.d.ts @@ -0,0 +1,22 @@ +import { AlgorithmIdentifier } from "@peculiar/asn1-x509"; +/** + * ECDSA with SHA-1 + * Parameters are ABSENT + */ +export declare const ecdsaWithSHA1: AlgorithmIdentifier; +/** + * ECDSA with SHA-224. Parameters are ABSENT + */ +export declare const ecdsaWithSHA224: AlgorithmIdentifier; +/** + * ECDSA with SHA-256. Parameters are ABSENT + */ +export declare const ecdsaWithSHA256: AlgorithmIdentifier; +/** + * ECDSA with SHA-384. Parameters are ABSENT + */ +export declare const ecdsaWithSHA384: AlgorithmIdentifier; +/** + * ECDSA with SHA-512. Parameters are ABSENT + */ +export declare const ecdsaWithSHA512: AlgorithmIdentifier; diff --git a/node_modules/@peculiar/asn1-ecc/build/types/ec_parameters.d.ts b/node_modules/@peculiar/asn1-ecc/build/types/ec_parameters.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8a3664f78a3ec39386ebd22b390dc5a331a17bdd --- /dev/null +++ b/node_modules/@peculiar/asn1-ecc/build/types/ec_parameters.d.ts @@ -0,0 +1,20 @@ +import { SpecifiedECDomain } from "./rfc3279"; +/** + * ```asn1 + * ECParameters ::= CHOICE { + * namedCurve OBJECT IDENTIFIER + * implicitCurve NULL + * specifiedCurve SpecifiedECDomain + * } + * -- implicitCurve and specifiedCurve MUST NOT be used in PKIX. + * -- Details for SpecifiedECDomain can be found in [X9.62]. + * -- Any future additions to this CHOICE should be coordinated + * -- with ANSI X9. + * ``` + */ +export declare class ECParameters { + namedCurve?: string; + implicitCurve?: null; + specifiedCurve?: SpecifiedECDomain; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-ecc/build/types/ec_private_key.d.ts b/node_modules/@peculiar/asn1-ecc/build/types/ec_private_key.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a8253af5d9610a5935bbd568c5eb84d49392af12 --- /dev/null +++ b/node_modules/@peculiar/asn1-ecc/build/types/ec_private_key.d.ts @@ -0,0 +1,19 @@ +import { OctetString } from "@peculiar/asn1-schema"; +import { ECParameters } from "./ec_parameters"; +/** + * ```asn1 + * ECPrivateKey ::= SEQUENCE { + * version INTEGER { ecPrivkeyVer1(1) } (ecPrivkeyVer1), + * privateKey OCTET STRING, + * parameters [0] ECParameters {{ NamedCurve }} OPTIONAL, + * publicKey [1] BIT STRING OPTIONAL + * } + * ``` + */ +export declare class ECPrivateKey { + version: number; + privateKey: OctetString; + parameters?: ECParameters; + publicKey?: ArrayBuffer; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-ecc/build/types/ec_signature_value.d.ts b/node_modules/@peculiar/asn1-ecc/build/types/ec_signature_value.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..038ed3322d6fabdd2d703a387471dd5d71f537ea --- /dev/null +++ b/node_modules/@peculiar/asn1-ecc/build/types/ec_signature_value.d.ts @@ -0,0 +1,13 @@ +/** + * ```asn1 + * ECDSA-Sig-Value ::= SEQUENCE { + * r INTEGER, + * s INTEGER + * } + * ``` + */ +export declare class ECDSASigValue { + r: ArrayBuffer; + s: ArrayBuffer; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-ecc/build/types/index.d.ts b/node_modules/@peculiar/asn1-ecc/build/types/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..123a6354d26259bd6d267ba3c586538396e791af --- /dev/null +++ b/node_modules/@peculiar/asn1-ecc/build/types/index.d.ts @@ -0,0 +1,6 @@ +export * from "./algorithms"; +export * from "./ec_parameters"; +export * from "./ec_private_key"; +export * from "./ec_signature_value"; +export * from "./object_identifiers"; +export * from "./rfc3279"; diff --git a/node_modules/@peculiar/asn1-ecc/build/types/object_identifiers.d.ts b/node_modules/@peculiar/asn1-ecc/build/types/object_identifiers.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a9c0641b4018c03e15ce0b01aa825eba18ad7473 --- /dev/null +++ b/node_modules/@peculiar/asn1-ecc/build/types/object_identifiers.d.ts @@ -0,0 +1,169 @@ +/** + * ```asn1 + * id-ecPublicKey OBJECT IDENTIFIER ::= { + * iso(1) member-body(2) us(840) ansi-X9-62(10045) keyType(2) 1 } + * ``` + */ +export declare const id_ecPublicKey = "1.2.840.10045.2.1"; +/** + * ```asn1 + * id-ecDH OBJECT IDENTIFIER ::= { + * iso(1) identified-organization(3) certicom(132) schemes(1) + * ecdh(12) } + * ``` + */ +export declare const id_ecDH = "1.3.132.1.12"; +/** + * ```asn1 + * id-ecMQV OBJECT IDENTIFIER ::= { + * iso(1) identified-organization(3) certicom(132) schemes(1) + * ecmqv(13) } + * ``` + */ +export declare const id_ecMQV = "1.3.132.1.13"; +/** + * ```asn1 + * ecdsa-with-SHA1 OBJECT IDENTIFIER ::= { + * iso(1) member-body(2) us(840) ansi-X9-62(10045) signatures(4) 1 } + * ``` + */ +export declare const id_ecdsaWithSHA1 = "1.2.840.10045.4.1"; +/** + * ```asn1 + * ecdsa-with-SHA224 OBJECT IDENTIFIER ::= { + * iso(1) member-body(2) us(840) ansi-X9-62(10045) signatures(4) + * ecdsa-with-SHA2(3) 1 } + * ``` + */ +export declare const id_ecdsaWithSHA224 = "1.2.840.10045.4.3.1"; +/** + * ```asn1 + * ecdsa-with-SHA256 OBJECT IDENTIFIER ::= { + * iso(1) member-body(2) us(840) ansi-X9-62(10045) signatures(4) + * ecdsa-with-SHA2(3) 2 } + * ``` + */ +export declare const id_ecdsaWithSHA256 = "1.2.840.10045.4.3.2"; +/** + * ```asn1 + * ecdsa-with-SHA384 OBJECT IDENTIFIER ::= { + * iso(1) member-body(2) us(840) ansi-X9-62(10045) signatures(4) + * ecdsa-with-SHA2(3) 3 } + * ``` + */ +export declare const id_ecdsaWithSHA384 = "1.2.840.10045.4.3.3"; +/** + * ```asn1 + * ecdsa-with-SHA512 OBJECT IDENTIFIER ::= { + * iso(1) member-body(2) us(840) ansi-X9-62(10045) signatures(4) + * ecdsa-with-SHA2(3) 4 } + * ``` + */ +export declare const id_ecdsaWithSHA512 = "1.2.840.10045.4.3.4"; +/** + * ```asn1 + * secp192r1 OBJECT IDENTIFIER ::= { + * iso(1) member-body(2) us(840) ansi-X9-62(10045) curves(3) + * prime(1) 1 } + * ``` + */ +export declare const id_secp192r1 = "1.2.840.10045.3.1.1"; +/** + * ```asn1 + * sect163k1 OBJECT IDENTIFIER ::= { + * iso(1) identified-organization(3) certicom(132) curve(0) 1 } + * ``` + */ +export declare const id_sect163k1 = "1.3.132.0.1"; +/** + * ```asn1 + * sect163r2 OBJECT IDENTIFIER ::= { + * iso(1) identified-organization(3) certicom(132) curve(0) 15 } + * ``` + */ +export declare const id_sect163r2 = "1.3.132.0.15"; +/** + * ```asn1 + * secp224r1 OBJECT IDENTIFIER ::= { + * iso(1) identified-organization(3) certicom(132) curve(0) 33 } + * ``` + */ +export declare const id_secp224r1 = "1.3.132.0.33"; +/** + * ```asn1 + * sect233k1 OBJECT IDENTIFIER ::= { + * iso(1) identified-organization(3) certicom(132) curve(0) 26 } + * ``` + */ +export declare const id_sect233k1 = "1.3.132.0.26"; +/** + * ```asn1 + * sect233r1 OBJECT IDENTIFIER ::= { + * iso(1) identified-organization(3) certicom(132) curve(0) 27 } + * ``` + */ +export declare const id_sect233r1 = "1.3.132.0.27"; +/** + * ```asn1 + * secp256r1 OBJECT IDENTIFIER ::= { + * iso(1) member-body(2) us(840) ansi-X9-62(10045) curves(3) + * prime(1) 7 } + * ``` + */ +export declare const id_secp256r1 = "1.2.840.10045.3.1.7"; +/** + * ```asn1 + * sect283k1 OBJECT IDENTIFIER ::= { + * iso(1) identified-organization(3) certicom(132) curve(0) 16 } + * ``` + */ +export declare const id_sect283k1 = "1.3.132.0.16"; +/** + * ```asn1 + * sect283r1 OBJECT IDENTIFIER ::= { + * iso(1) identified-organization(3) certicom(132) curve(0) 17 } + * ``` + */ +export declare const id_sect283r1 = "1.3.132.0.17"; +/** + * ```asn1 + * secp384r1 OBJECT IDENTIFIER ::= { + * iso(1) identified-organization(3) certicom(132) curve(0) 34 } + * ``` + */ +export declare const id_secp384r1 = "1.3.132.0.34"; +/** + * ```asn1 + * sect409k1 OBJECT IDENTIFIER ::= { + * iso(1) identified-organization(3) certicom(132) curve(0) 36 } + * ``` + */ +export declare const id_sect409k1 = "1.3.132.0.36"; +/** + * ```asn1 + * sect409r1 OBJECT IDENTIFIER ::= { + * iso(1) identified-organization(3) certicom(132) curve(0) 37 } + * ``` + */ +export declare const id_sect409r1 = "1.3.132.0.37"; +/** + * ```asn1 + * secp521r1 OBJECT IDENTIFIER ::= { + * iso(1) identified-organization(3) certicom(132) curve(0) 35 } + * ``` + */ +export declare const id_secp521r1 = "1.3.132.0.35"; +/** + * ```asn1 + * sect571k1 OBJECT IDENTIFIER ::= { + * iso(1) identified-organization(3) certicom(132) curve(0) 38 } + * ``` + */ +export declare const id_sect571k1 = "1.3.132.0.38"; +/** + * ```asn1 + * sect571r1 OBJECT IDENTIFIER ::= { + * iso(1) identified-organization(3) certicom(132) curve(0) 39 } + * ``` + */ +export declare const id_sect571r1 = "1.3.132.0.39"; diff --git a/node_modules/@peculiar/asn1-ecc/build/types/rfc3279.d.ts b/node_modules/@peculiar/asn1-ecc/build/types/rfc3279.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..838fda25373cf6dce17cd8bbbcea30392551a023 --- /dev/null +++ b/node_modules/@peculiar/asn1-ecc/build/types/rfc3279.d.ts @@ -0,0 +1,73 @@ +import { OctetString } from "@peculiar/asn1-schema"; +/** + * ```asn1 + * FieldID ::= SEQUENCE { + * fieldType OBJECT IDENTIFIER, + * parameters ANY DEFINED BY fieldType } + * ``` + */ +export declare class FieldID { + fieldType: string; + parameters: ArrayBuffer; + constructor(params?: Partial); +} +/** + * ```asn1 + * ECPoint ::= OCTET STRING + * ``` + */ +export declare class ECPoint extends OctetString { +} +/** + * ```asn1 + * FieldElement ::= OCTET STRING + * ``` + */ +export declare class FieldElement extends OctetString { +} +/** + * ```asn1 + * Curve ::= SEQUENCE { + * a FieldElement, + * b FieldElement, + * seed BIT STRING OPTIONAL } + * ``` + */ +export declare class Curve { + a: ArrayBuffer; + b: ArrayBuffer; + seed?: ArrayBuffer; + constructor(params?: Partial); +} +/** + * ```asn1 + * ECPVer ::= INTEGER {ecpVer1(1)} + * ``` + */ +export declare enum ECPVer { + ecpVer1 = 1 +} +/** + * ```asn1 + * SpecifiedECDomain ::= SEQUENCE { + * version ECPVer, -- version is always 1 + * fieldID FieldID, -- identifies the finite field over + * -- which the curve is defined + * curve Curve, -- coefficients a and b of the + * -- elliptic curve + * base ECPoint, -- specifies the base point P + * -- on the elliptic curve + * order INTEGER, -- the order n of the base point + * cofactor INTEGER OPTIONAL -- The integer h = #E(Fq)/n + * } + * ``` + */ +export declare class SpecifiedECDomain { + version: ECPVer; + fieldID: FieldID; + curve: Curve; + base: ECPoint; + order: ArrayBuffer; + cofactor?: ArrayBuffer; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-ecc/package.json b/node_modules/@peculiar/asn1-ecc/package.json new file mode 100644 index 0000000000000000000000000000000000000000..d53604f493b4672b003d1f69f2a3b0d35f79cb03 --- /dev/null +++ b/node_modules/@peculiar/asn1-ecc/package.json @@ -0,0 +1,63 @@ +{ + "name": "@peculiar/asn1-ecc", + "version": "2.8.0", + "description": "ASN.1 schema for elliptic-curve private keys and related identifiers defined in RFC 5915, RFC 5480, and RFC 3279.", + "keywords": [ + "asn", + "asn1", + "ecc", + "ec", + "elliptic-curve", + "rfc5915", + "rfc5480", + "rfc3279" + ], + "author": "PeculiarVentures, LLC", + "license": "MIT", + "files": [ + "build/**/*.{js,d.ts}", + "build/es2015/package.json", + "LICENSE", + "README.md" + ], + "main": "build/cjs/index.js", + "module": "build/es2015/index.js", + "types": "build/types/index.d.ts", + "exports": { + ".": { + "types": "./build/types/index.d.ts", + "import": "./build/es2015/index.js", + "require": "./build/cjs/index.js" + }, + "./package.json": "./package.json" + }, + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "https://github.com/PeculiarVentures/asn1-schema", + "directory": "packages/ecc" + }, + "bugs": { + "url": "https://github.com/PeculiarVentures/asn1-schema/issues" + }, + "homepage": "https://github.com/PeculiarVentures/asn1-schema/tree/master/packages/ecc#readme", + "scripts": { + "clear": "rimraf build", + "build": "npm run build:module && npm run build:types", + "build:module": "npm run build:cjs && npm run build:es2015", + "build:cjs": "tsc -p tsconfig.compile.json --removeComments --module commonjs --outDir build/cjs", + "build:es2015": "tsc -p tsconfig.compile.json --removeComments --module ES2015 --outDir build/es2015", + "postbuild:es2015": "node ../../scripts/prepare_esm_package.mjs build/es2015", + "prebuild:types": "rimraf build/types", + "build:types": "tsc -p tsconfig.compile.json --outDir build/types --declaration --emitDeclarationOnly", + "rebuild": "npm run clear && npm run build" + }, + "dependencies": { + "@peculiar/asn1-schema": "^2.8.0", + "@peculiar/asn1-x509": "^2.8.0", + "asn1js": "^3.0.10", + "tslib": "^2.8.1" + } +} diff --git a/node_modules/@peculiar/asn1-pfx/LICENSE b/node_modules/@peculiar/asn1-pfx/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..43675934676182bb2368abb1a371722a830453eb --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@peculiar/asn1-pfx/README.md b/node_modules/@peculiar/asn1-pfx/README.md new file mode 100644 index 0000000000000000000000000000000000000000..6dbf9458e3bec6d69dfa6b517df51ca0253c0683 --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/README.md @@ -0,0 +1,20 @@ +# `@peculiar/asn1-pfx` + +[![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/PeculiarVentures/asn1-schema/blob/master/packages/pfx/LICENSE) +[![npm version](https://badge.fury.io/js/%40peculiar%2Fasn1-pfx.svg)](https://badge.fury.io/js/%40peculiar%2Fasn1-pfx) + +[![NPM](https://nodei.co/npm/@peculiar/asn1-pfx.png)](https://nodei.co/npm/@peculiar/asn1-pfx/) + +ASN.1 schema for PKCS #12 personal information exchange structures defined in RFC 7292. + +Use the exported classes with `@peculiar/asn1-schema` helpers such as `AsnConvert`, `AsnParser`, and `AsnSerializer` to parse or serialize DER-encoded data defined by the referenced specification. + +## Installation + +```bash +npm install @peculiar/asn1-pfx +``` + +## Specifications + +- [RFC 7292: PKCS #12: Personal Information Exchange Syntax](https://datatracker.ietf.org/doc/html/rfc7292) diff --git a/node_modules/@peculiar/asn1-pfx/build/cjs/attribute.js b/node_modules/@peculiar/asn1-pfx/build/cjs/attribute.js new file mode 100644 index 0000000000000000000000000000000000000000..4b55d9565d8600e236c41b195f9749aa4c8181f4 --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/cjs/attribute.js @@ -0,0 +1,34 @@ +"use strict"; +var PKCS12AttrSet_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.PKCS12AttrSet = exports.PKCS12Attribute = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +class PKCS12Attribute { + attrId = ""; + attrValues = []; + constructor(params = {}) { + Object.assign(params); + } +} +exports.PKCS12Attribute = PKCS12Attribute; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.ObjectIdentifier }) +], PKCS12Attribute.prototype, "attrId", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Any, repeated: "set", + }) +], PKCS12Attribute.prototype, "attrValues", void 0); +let PKCS12AttrSet = PKCS12AttrSet_1 = class PKCS12AttrSet extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, PKCS12AttrSet_1.prototype); + } +}; +exports.PKCS12AttrSet = PKCS12AttrSet; +exports.PKCS12AttrSet = PKCS12AttrSet = PKCS12AttrSet_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Sequence, itemType: PKCS12Attribute, + }) +], PKCS12AttrSet); diff --git a/node_modules/@peculiar/asn1-pfx/build/cjs/authenticated_safe.js b/node_modules/@peculiar/asn1-pfx/build/cjs/authenticated_safe.js new file mode 100644 index 0000000000000000000000000000000000000000..a727c7999668936e6242d13d8866a35d6dd78152 --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/cjs/authenticated_safe.js @@ -0,0 +1,19 @@ +"use strict"; +var AuthenticatedSafe_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AuthenticatedSafe = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_cms_1 = require("@peculiar/asn1-cms"); +let AuthenticatedSafe = AuthenticatedSafe_1 = class AuthenticatedSafe extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, AuthenticatedSafe_1.prototype); + } +}; +exports.AuthenticatedSafe = AuthenticatedSafe; +exports.AuthenticatedSafe = AuthenticatedSafe = AuthenticatedSafe_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Sequence, itemType: asn1_cms_1.ContentInfo, + }) +], AuthenticatedSafe); diff --git a/node_modules/@peculiar/asn1-pfx/build/cjs/bags/cert_bag.js b/node_modules/@peculiar/asn1-pfx/build/cjs/bags/cert_bag.js new file mode 100644 index 0000000000000000000000000000000000000000..e1406d5d09189e77f158480eeba0dd9e4c664d02 --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/cjs/bags/cert_bag.js @@ -0,0 +1,25 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.id_sdsiCertificate = exports.id_x509Certificate = exports.id_certTypes = exports.CertBag = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const types_1 = require("./types"); +class CertBag { + certId = ""; + certValue = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.CertBag = CertBag; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.ObjectIdentifier }) +], CertBag.prototype, "certId", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Any, context: 0, + }) +], CertBag.prototype, "certValue", void 0); +exports.id_certTypes = `${types_1.id_pkcs_9}.22`; +exports.id_x509Certificate = `${exports.id_certTypes}.1`; +exports.id_sdsiCertificate = `${exports.id_certTypes}.2`; diff --git a/node_modules/@peculiar/asn1-pfx/build/cjs/bags/crl_bag.js b/node_modules/@peculiar/asn1-pfx/build/cjs/bags/crl_bag.js new file mode 100644 index 0000000000000000000000000000000000000000..1ef7ed0008eb3b854033bbbaf5402dfeeea3bae6 --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/cjs/bags/crl_bag.js @@ -0,0 +1,24 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.id_x509CRL = exports.id_crlTypes = exports.CRLBag = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const types_1 = require("./types"); +class CRLBag { + crlId = ""; + crltValue = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.CRLBag = CRLBag; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.ObjectIdentifier }) +], CRLBag.prototype, "crlId", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Any, context: 0, + }) +], CRLBag.prototype, "crltValue", void 0); +exports.id_crlTypes = `${types_1.id_pkcs_9}.23`; +exports.id_x509CRL = `${exports.id_crlTypes}.1`; diff --git a/node_modules/@peculiar/asn1-pfx/build/cjs/bags/index.js b/node_modules/@peculiar/asn1-pfx/build/cjs/bags/index.js new file mode 100644 index 0000000000000000000000000000000000000000..9f80ef831032673d07f65f225637a647845a0777 --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/cjs/bags/index.js @@ -0,0 +1,9 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +tslib_1.__exportStar(require("./cert_bag"), exports); +tslib_1.__exportStar(require("./crl_bag"), exports); +tslib_1.__exportStar(require("./key_bag"), exports); +tslib_1.__exportStar(require("./pkcs8_shrouded_key_bag"), exports); +tslib_1.__exportStar(require("./secret_bag"), exports); +tslib_1.__exportStar(require("./types"), exports); diff --git a/node_modules/@peculiar/asn1-pfx/build/cjs/bags/key_bag.js b/node_modules/@peculiar/asn1-pfx/build/cjs/bags/key_bag.js new file mode 100644 index 0000000000000000000000000000000000000000..d82443fcee9b4f7d4a63a78e93c187941b141ea6 --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/cjs/bags/key_bag.js @@ -0,0 +1,12 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KeyBag = void 0; +const tslib_1 = require("tslib"); +const asn1_pkcs8_1 = require("@peculiar/asn1-pkcs8"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +let KeyBag = class KeyBag extends asn1_pkcs8_1.PrivateKeyInfo { +}; +exports.KeyBag = KeyBag; +exports.KeyBag = KeyBag = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Sequence }) +], KeyBag); diff --git a/node_modules/@peculiar/asn1-pfx/build/cjs/bags/pkcs8_shrouded_key_bag.js b/node_modules/@peculiar/asn1-pfx/build/cjs/bags/pkcs8_shrouded_key_bag.js new file mode 100644 index 0000000000000000000000000000000000000000..69f1558f5bb11b8091db71da5093dcff1a192c5f --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/cjs/bags/pkcs8_shrouded_key_bag.js @@ -0,0 +1,12 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.PKCS8ShroudedKeyBag = void 0; +const tslib_1 = require("tslib"); +const asn1_pkcs8_1 = require("@peculiar/asn1-pkcs8"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +let PKCS8ShroudedKeyBag = class PKCS8ShroudedKeyBag extends asn1_pkcs8_1.EncryptedPrivateKeyInfo { +}; +exports.PKCS8ShroudedKeyBag = PKCS8ShroudedKeyBag; +exports.PKCS8ShroudedKeyBag = PKCS8ShroudedKeyBag = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Sequence }) +], PKCS8ShroudedKeyBag); diff --git a/node_modules/@peculiar/asn1-pfx/build/cjs/bags/secret_bag.js b/node_modules/@peculiar/asn1-pfx/build/cjs/bags/secret_bag.js new file mode 100644 index 0000000000000000000000000000000000000000..a21bf6ec288e8c3c80a4478a2fa337d84638d87b --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/cjs/bags/secret_bag.js @@ -0,0 +1,21 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SecretBag = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +class SecretBag { + secretTypeId = ""; + secretValue = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.SecretBag = SecretBag; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.ObjectIdentifier }) +], SecretBag.prototype, "secretTypeId", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Any, context: 0, + }) +], SecretBag.prototype, "secretValue", void 0); diff --git a/node_modules/@peculiar/asn1-pfx/build/cjs/bags/types.js b/node_modules/@peculiar/asn1-pfx/build/cjs/bags/types.js new file mode 100644 index 0000000000000000000000000000000000000000..5dd2746132f13bc227fcc1b371455895e9d95228 --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/cjs/bags/types.js @@ -0,0 +1,11 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.id_pkcs_9 = exports.id_SafeContents = exports.id_SecretBag = exports.id_CRLBag = exports.id_certBag = exports.id_pkcs8ShroudedKeyBag = exports.id_keyBag = void 0; +const object_identifiers_1 = require("../object_identifiers"); +exports.id_keyBag = `${object_identifiers_1.id_bagtypes}.1`; +exports.id_pkcs8ShroudedKeyBag = `${object_identifiers_1.id_bagtypes}.2`; +exports.id_certBag = `${object_identifiers_1.id_bagtypes}.3`; +exports.id_CRLBag = `${object_identifiers_1.id_bagtypes}.4`; +exports.id_SecretBag = `${object_identifiers_1.id_bagtypes}.5`; +exports.id_SafeContents = `${object_identifiers_1.id_bagtypes}.6`; +exports.id_pkcs_9 = "1.2.840.113549.1.9"; diff --git a/node_modules/@peculiar/asn1-pfx/build/cjs/index.js b/node_modules/@peculiar/asn1-pfx/build/cjs/index.js new file mode 100644 index 0000000000000000000000000000000000000000..64aa715f175e51202efe1cb50092b443567b5462 --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/cjs/index.js @@ -0,0 +1,10 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +tslib_1.__exportStar(require("./attribute"), exports); +tslib_1.__exportStar(require("./authenticated_safe"), exports); +tslib_1.__exportStar(require("./bags"), exports); +tslib_1.__exportStar(require("./mac_data"), exports); +tslib_1.__exportStar(require("./object_identifiers"), exports); +tslib_1.__exportStar(require("./pfx"), exports); +tslib_1.__exportStar(require("./safe_bag"), exports); diff --git a/node_modules/@peculiar/asn1-pfx/build/cjs/mac_data.js b/node_modules/@peculiar/asn1-pfx/build/cjs/mac_data.js new file mode 100644 index 0000000000000000000000000000000000000000..50b19fac2c985a726ab904745d68f06bcb1c2367 --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/cjs/mac_data.js @@ -0,0 +1,26 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.MacData = void 0; +const tslib_1 = require("tslib"); +const asn1_rsa_1 = require("@peculiar/asn1-rsa"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +class MacData { + mac = new asn1_rsa_1.DigestInfo(); + macSalt = new asn1_schema_1.OctetString(); + iterations = 1; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.MacData = MacData; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_rsa_1.DigestInfo }) +], MacData.prototype, "mac", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.OctetString }) +], MacData.prototype, "macSalt", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, defaultValue: 1, + }) +], MacData.prototype, "iterations", void 0); diff --git a/node_modules/@peculiar/asn1-pfx/build/cjs/object_identifiers.js b/node_modules/@peculiar/asn1-pfx/build/cjs/object_identifiers.js new file mode 100644 index 0000000000000000000000000000000000000000..8f86666d7e2298bc4fa83a27cca0493b22862a51 --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/cjs/object_identifiers.js @@ -0,0 +1,14 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.id_bagtypes = exports.id_pbewithSHAAnd40BitRC2_CBC = exports.id_pbeWithSHAAnd128BitRC2_CBC = exports.id_pbeWithSHAAnd2_KeyTripleDES_CBC = exports.id_pbeWithSHAAnd3_KeyTripleDES_CBC = exports.id_pbeWithSHAAnd40BitRC4 = exports.id_pbeWithSHAAnd128BitRC4 = exports.id_pkcs_12PbeIds = exports.id_pkcs_12 = exports.id_pkcs = exports.id_rsadsi = void 0; +exports.id_rsadsi = "1.2.840.113549"; +exports.id_pkcs = `${exports.id_rsadsi}.1`; +exports.id_pkcs_12 = `${exports.id_pkcs}.12`; +exports.id_pkcs_12PbeIds = `${exports.id_pkcs_12}.1`; +exports.id_pbeWithSHAAnd128BitRC4 = `${exports.id_pkcs_12PbeIds}.1`; +exports.id_pbeWithSHAAnd40BitRC4 = `${exports.id_pkcs_12PbeIds}.2`; +exports.id_pbeWithSHAAnd3_KeyTripleDES_CBC = `${exports.id_pkcs_12PbeIds}.3`; +exports.id_pbeWithSHAAnd2_KeyTripleDES_CBC = `${exports.id_pkcs_12PbeIds}.4`; +exports.id_pbeWithSHAAnd128BitRC2_CBC = `${exports.id_pkcs_12PbeIds}.5`; +exports.id_pbewithSHAAnd40BitRC2_CBC = `${exports.id_pkcs_12PbeIds}.6`; +exports.id_bagtypes = `${exports.id_pkcs_12}.10.1`; diff --git a/node_modules/@peculiar/asn1-pfx/build/cjs/pfx.js b/node_modules/@peculiar/asn1-pfx/build/cjs/pfx.js new file mode 100644 index 0000000000000000000000000000000000000000..74f1a8f0c9f9c229b77a276a32e3fcdd45592993 --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/cjs/pfx.js @@ -0,0 +1,27 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.PFX = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_cms_1 = require("@peculiar/asn1-cms"); +const mac_data_1 = require("./mac_data"); +class PFX { + version = 3; + authSafe = new asn1_cms_1.ContentInfo(); + macData = new mac_data_1.MacData(); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.PFX = PFX; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer }) +], PFX.prototype, "version", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_cms_1.ContentInfo }) +], PFX.prototype, "authSafe", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: mac_data_1.MacData, optional: true, + }) +], PFX.prototype, "macData", void 0); diff --git a/node_modules/@peculiar/asn1-pfx/build/cjs/safe_bag.js b/node_modules/@peculiar/asn1-pfx/build/cjs/safe_bag.js new file mode 100644 index 0000000000000000000000000000000000000000..07e566306f8dc32c7937ecfbf431d58b01e4415a --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/cjs/safe_bag.js @@ -0,0 +1,41 @@ +"use strict"; +var SafeContents_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SafeContents = exports.SafeBag = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const attribute_1 = require("./attribute"); +class SafeBag { + bagId = ""; + bagValue = new ArrayBuffer(0); + bagAttributes; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.SafeBag = SafeBag; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.ObjectIdentifier }) +], SafeBag.prototype, "bagId", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Any, context: 0, + }) +], SafeBag.prototype, "bagValue", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: attribute_1.PKCS12Attribute, repeated: "set", optional: true, + }) +], SafeBag.prototype, "bagAttributes", void 0); +let SafeContents = SafeContents_1 = class SafeContents extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, SafeContents_1.prototype); + } +}; +exports.SafeContents = SafeContents; +exports.SafeContents = SafeContents = SafeContents_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Sequence, itemType: SafeBag, + }) +], SafeContents); diff --git a/node_modules/@peculiar/asn1-pfx/build/es2015/attribute.js b/node_modules/@peculiar/asn1-pfx/build/es2015/attribute.js new file mode 100644 index 0000000000000000000000000000000000000000..6e67c60d38c4aac95a64fb65a2fe47870c8f57de --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/es2015/attribute.js @@ -0,0 +1,30 @@ +var PKCS12AttrSet_1; +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnArray, AsnType, AsnTypeTypes, } from "@peculiar/asn1-schema"; +export class PKCS12Attribute { + attrId = ""; + attrValues = []; + constructor(params = {}) { + Object.assign(params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.ObjectIdentifier }) +], PKCS12Attribute.prototype, "attrId", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Any, repeated: "set", + }) +], PKCS12Attribute.prototype, "attrValues", void 0); +let PKCS12AttrSet = PKCS12AttrSet_1 = class PKCS12AttrSet extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, PKCS12AttrSet_1.prototype); + } +}; +PKCS12AttrSet = PKCS12AttrSet_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Sequence, itemType: PKCS12Attribute, + }) +], PKCS12AttrSet); +export { PKCS12AttrSet }; diff --git a/node_modules/@peculiar/asn1-pfx/build/es2015/authenticated_safe.js b/node_modules/@peculiar/asn1-pfx/build/es2015/authenticated_safe.js new file mode 100644 index 0000000000000000000000000000000000000000..00e048012f251465cb021d539b3c19d55c87858f --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/es2015/authenticated_safe.js @@ -0,0 +1,16 @@ +var AuthenticatedSafe_1; +import { __decorate } from "tslib"; +import { AsnArray, AsnType, AsnTypeTypes, } from "@peculiar/asn1-schema"; +import { ContentInfo } from "@peculiar/asn1-cms"; +let AuthenticatedSafe = AuthenticatedSafe_1 = class AuthenticatedSafe extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, AuthenticatedSafe_1.prototype); + } +}; +AuthenticatedSafe = AuthenticatedSafe_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Sequence, itemType: ContentInfo, + }) +], AuthenticatedSafe); +export { AuthenticatedSafe }; diff --git a/node_modules/@peculiar/asn1-pfx/build/es2015/bags/cert_bag.js b/node_modules/@peculiar/asn1-pfx/build/es2015/bags/cert_bag.js new file mode 100644 index 0000000000000000000000000000000000000000..822bf7bf29ab1d15d1476482508b0f06ad80fbe6 --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/es2015/bags/cert_bag.js @@ -0,0 +1,21 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes } from "@peculiar/asn1-schema"; +import { id_pkcs_9 } from "./types.js"; +export class CertBag { + certId = ""; + certValue = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.ObjectIdentifier }) +], CertBag.prototype, "certId", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Any, context: 0, + }) +], CertBag.prototype, "certValue", void 0); +export const id_certTypes = `${id_pkcs_9}.22`; +export const id_x509Certificate = `${id_certTypes}.1`; +export const id_sdsiCertificate = `${id_certTypes}.2`; diff --git a/node_modules/@peculiar/asn1-pfx/build/es2015/bags/crl_bag.js b/node_modules/@peculiar/asn1-pfx/build/es2015/bags/crl_bag.js new file mode 100644 index 0000000000000000000000000000000000000000..68a37573ef1c26abec353b88a71db39d5607d10f --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/es2015/bags/crl_bag.js @@ -0,0 +1,20 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes } from "@peculiar/asn1-schema"; +import { id_pkcs_9 } from "./types.js"; +export class CRLBag { + crlId = ""; + crltValue = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.ObjectIdentifier }) +], CRLBag.prototype, "crlId", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Any, context: 0, + }) +], CRLBag.prototype, "crltValue", void 0); +export const id_crlTypes = `${id_pkcs_9}.23`; +export const id_x509CRL = `${id_crlTypes}.1`; diff --git a/node_modules/@peculiar/asn1-pfx/build/es2015/bags/index.js b/node_modules/@peculiar/asn1-pfx/build/es2015/bags/index.js new file mode 100644 index 0000000000000000000000000000000000000000..8e56b757e79fa1b5b162ca95bffbb0d9b7ded154 --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/es2015/bags/index.js @@ -0,0 +1,6 @@ +export * from "./cert_bag.js"; +export * from "./crl_bag.js"; +export * from "./key_bag.js"; +export * from "./pkcs8_shrouded_key_bag.js"; +export * from "./secret_bag.js"; +export * from "./types.js"; diff --git a/node_modules/@peculiar/asn1-pfx/build/es2015/bags/key_bag.js b/node_modules/@peculiar/asn1-pfx/build/es2015/bags/key_bag.js new file mode 100644 index 0000000000000000000000000000000000000000..f811018985c828e5472385cb7616aa8af8f27094 --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/es2015/bags/key_bag.js @@ -0,0 +1,9 @@ +import { __decorate } from "tslib"; +import { PrivateKeyInfo } from "@peculiar/asn1-pkcs8"; +import { AsnType, AsnTypeTypes } from "@peculiar/asn1-schema"; +let KeyBag = class KeyBag extends PrivateKeyInfo { +}; +KeyBag = __decorate([ + AsnType({ type: AsnTypeTypes.Sequence }) +], KeyBag); +export { KeyBag }; diff --git a/node_modules/@peculiar/asn1-pfx/build/es2015/bags/pkcs8_shrouded_key_bag.js b/node_modules/@peculiar/asn1-pfx/build/es2015/bags/pkcs8_shrouded_key_bag.js new file mode 100644 index 0000000000000000000000000000000000000000..139369c318e7613ed9bd34b8635d4686a4b4d521 --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/es2015/bags/pkcs8_shrouded_key_bag.js @@ -0,0 +1,9 @@ +import { __decorate } from "tslib"; +import { EncryptedPrivateKeyInfo } from "@peculiar/asn1-pkcs8"; +import { AsnType, AsnTypeTypes } from "@peculiar/asn1-schema"; +let PKCS8ShroudedKeyBag = class PKCS8ShroudedKeyBag extends EncryptedPrivateKeyInfo { +}; +PKCS8ShroudedKeyBag = __decorate([ + AsnType({ type: AsnTypeTypes.Sequence }) +], PKCS8ShroudedKeyBag); +export { PKCS8ShroudedKeyBag }; diff --git a/node_modules/@peculiar/asn1-pfx/build/es2015/bags/secret_bag.js b/node_modules/@peculiar/asn1-pfx/build/es2015/bags/secret_bag.js new file mode 100644 index 0000000000000000000000000000000000000000..6b0d45c063c1acdddd537fc5666ee7f1929e361a --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/es2015/bags/secret_bag.js @@ -0,0 +1,17 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes } from "@peculiar/asn1-schema"; +export class SecretBag { + secretTypeId = ""; + secretValue = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.ObjectIdentifier }) +], SecretBag.prototype, "secretTypeId", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Any, context: 0, + }) +], SecretBag.prototype, "secretValue", void 0); diff --git a/node_modules/@peculiar/asn1-pfx/build/es2015/bags/types.js b/node_modules/@peculiar/asn1-pfx/build/es2015/bags/types.js new file mode 100644 index 0000000000000000000000000000000000000000..1a6e26513877cd9c74e5fd84e94baaa443e7e043 --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/es2015/bags/types.js @@ -0,0 +1,8 @@ +import { id_bagtypes } from "../object_identifiers.js"; +export const id_keyBag = `${id_bagtypes}.1`; +export const id_pkcs8ShroudedKeyBag = `${id_bagtypes}.2`; +export const id_certBag = `${id_bagtypes}.3`; +export const id_CRLBag = `${id_bagtypes}.4`; +export const id_SecretBag = `${id_bagtypes}.5`; +export const id_SafeContents = `${id_bagtypes}.6`; +export const id_pkcs_9 = "1.2.840.113549.1.9"; diff --git a/node_modules/@peculiar/asn1-pfx/build/es2015/index.js b/node_modules/@peculiar/asn1-pfx/build/es2015/index.js new file mode 100644 index 0000000000000000000000000000000000000000..14ba7d52e627d4831a0848b8157ef0ce512abfb8 --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/es2015/index.js @@ -0,0 +1,7 @@ +export * from "./attribute.js"; +export * from "./authenticated_safe.js"; +export * from "./bags/index.js"; +export * from "./mac_data.js"; +export * from "./object_identifiers.js"; +export * from "./pfx.js"; +export * from "./safe_bag.js"; diff --git a/node_modules/@peculiar/asn1-pfx/build/es2015/mac_data.js b/node_modules/@peculiar/asn1-pfx/build/es2015/mac_data.js new file mode 100644 index 0000000000000000000000000000000000000000..65637e484a06d7b4a25e343cf66a63314cb19270 --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/es2015/mac_data.js @@ -0,0 +1,22 @@ +import { __decorate } from "tslib"; +import { DigestInfo } from "@peculiar/asn1-rsa"; +import { AsnProp, AsnPropTypes, OctetString, } from "@peculiar/asn1-schema"; +export class MacData { + mac = new DigestInfo(); + macSalt = new OctetString(); + iterations = 1; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: DigestInfo }) +], MacData.prototype, "mac", void 0); +__decorate([ + AsnProp({ type: OctetString }) +], MacData.prototype, "macSalt", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, defaultValue: 1, + }) +], MacData.prototype, "iterations", void 0); diff --git a/node_modules/@peculiar/asn1-pfx/build/es2015/object_identifiers.js b/node_modules/@peculiar/asn1-pfx/build/es2015/object_identifiers.js new file mode 100644 index 0000000000000000000000000000000000000000..1c5d3da3799a373040a03c6be611067630b0f4c8 --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/es2015/object_identifiers.js @@ -0,0 +1,11 @@ +export const id_rsadsi = "1.2.840.113549"; +export const id_pkcs = `${id_rsadsi}.1`; +export const id_pkcs_12 = `${id_pkcs}.12`; +export const id_pkcs_12PbeIds = `${id_pkcs_12}.1`; +export const id_pbeWithSHAAnd128BitRC4 = `${id_pkcs_12PbeIds}.1`; +export const id_pbeWithSHAAnd40BitRC4 = `${id_pkcs_12PbeIds}.2`; +export const id_pbeWithSHAAnd3_KeyTripleDES_CBC = `${id_pkcs_12PbeIds}.3`; +export const id_pbeWithSHAAnd2_KeyTripleDES_CBC = `${id_pkcs_12PbeIds}.4`; +export const id_pbeWithSHAAnd128BitRC2_CBC = `${id_pkcs_12PbeIds}.5`; +export const id_pbewithSHAAnd40BitRC2_CBC = `${id_pkcs_12PbeIds}.6`; +export const id_bagtypes = `${id_pkcs_12}.10.1`; diff --git a/node_modules/@peculiar/asn1-pfx/build/es2015/package.json b/node_modules/@peculiar/asn1-pfx/build/es2015/package.json new file mode 100644 index 0000000000000000000000000000000000000000..3dbc1ca591c0557e35b6004aeba250e6a70b56e3 --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/es2015/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/node_modules/@peculiar/asn1-pfx/build/es2015/pfx.js b/node_modules/@peculiar/asn1-pfx/build/es2015/pfx.js new file mode 100644 index 0000000000000000000000000000000000000000..2795d936e0e1e408d53f5eecbc80d0e16dc5d6a5 --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/es2015/pfx.js @@ -0,0 +1,23 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes } from "@peculiar/asn1-schema"; +import { ContentInfo } from "@peculiar/asn1-cms"; +import { MacData } from "./mac_data.js"; +export class PFX { + version = 3; + authSafe = new ContentInfo(); + macData = new MacData(); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.Integer }) +], PFX.prototype, "version", void 0); +__decorate([ + AsnProp({ type: ContentInfo }) +], PFX.prototype, "authSafe", void 0); +__decorate([ + AsnProp({ + type: MacData, optional: true, + }) +], PFX.prototype, "macData", void 0); diff --git a/node_modules/@peculiar/asn1-pfx/build/es2015/safe_bag.js b/node_modules/@peculiar/asn1-pfx/build/es2015/safe_bag.js new file mode 100644 index 0000000000000000000000000000000000000000..a4d42329781e78318fc21b9168abaf1cd31b7d33 --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/es2015/safe_bag.js @@ -0,0 +1,37 @@ +var SafeContents_1; +import { __decorate } from "tslib"; +import { AsnArray, AsnType, AsnTypeTypes, AsnProp, AsnPropTypes, } from "@peculiar/asn1-schema"; +import { PKCS12Attribute } from "./attribute.js"; +export class SafeBag { + bagId = ""; + bagValue = new ArrayBuffer(0); + bagAttributes; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.ObjectIdentifier }) +], SafeBag.prototype, "bagId", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Any, context: 0, + }) +], SafeBag.prototype, "bagValue", void 0); +__decorate([ + AsnProp({ + type: PKCS12Attribute, repeated: "set", optional: true, + }) +], SafeBag.prototype, "bagAttributes", void 0); +let SafeContents = SafeContents_1 = class SafeContents extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, SafeContents_1.prototype); + } +}; +SafeContents = SafeContents_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Sequence, itemType: SafeBag, + }) +], SafeContents); +export { SafeContents }; diff --git a/node_modules/@peculiar/asn1-pfx/build/types/attribute.d.ts b/node_modules/@peculiar/asn1-pfx/build/types/attribute.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..131befda0240e4bb01776ad71d6880b464866570 --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/types/attribute.d.ts @@ -0,0 +1,26 @@ +import { AsnArray } from "@peculiar/asn1-schema"; +/** + * ```asn1 + * PKCS12Attribute ::= SEQUENCE { + * attrId ATTRIBUTE.&id ({PKCS12AttrSet}), + * attrValues SET OF ATTRIBUTE.&Type ({PKCS12AttrSet}{@attrId}) + * } -- This type is compatible with the X.500 type 'Attribute' + * ``` + */ +export declare class PKCS12Attribute { + attrId: string; + attrValues: ArrayBuffer[]; + constructor(params?: Partial); +} +/** + * ```asn1 + * PKCS12AttrSet ATTRIBUTE ::= { + * friendlyName | + * localKeyId, + * ... -- Other attributes are allowed + * } + * ``` + */ +export declare class PKCS12AttrSet extends AsnArray { + constructor(items?: PKCS12Attribute[]); +} diff --git a/node_modules/@peculiar/asn1-pfx/build/types/authenticated_safe.d.ts b/node_modules/@peculiar/asn1-pfx/build/types/authenticated_safe.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3da62289d86eb4835bc26ad330ab11168549dc27 --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/types/authenticated_safe.d.ts @@ -0,0 +1,13 @@ +import { AsnArray } from "@peculiar/asn1-schema"; +import { ContentInfo } from "@peculiar/asn1-cms"; +/** + * ```asn1 + * AuthenticatedSafe ::= SEQUENCE OF ContentInfo + * -- Data if unencrypted + * -- EncryptedData if password-encrypted + * -- EnvelopedData if public key-encrypted + * ``` + */ +export declare class AuthenticatedSafe extends AsnArray { + constructor(items?: ContentInfo[]); +} diff --git a/node_modules/@peculiar/asn1-pfx/build/types/bags/cert_bag.d.ts b/node_modules/@peculiar/asn1-pfx/build/types/bags/cert_bag.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4db519e649474cdc382c6f39f73f189d92002483 --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/types/bags/cert_bag.d.ts @@ -0,0 +1,35 @@ +/** + * ```asn1 + * CertBag ::= SEQUENCE { + * certId BAG-TYPE.&id ({CertTypes}), + * certValue [0] EXPLICIT BAG-TYPE.&Type ({CertTypes}{@certId}) + * } + * ``` + */ +export declare class CertBag { + certId: string; + certValue: ArrayBuffer; + constructor(params?: Partial); +} +/** + * ```asn1 + * certTypes OBJECT IDENTIFIER ::= {pkcs-9 22} + * ``` + */ +export declare const id_certTypes = "1.2.840.113549.1.9.22"; +/** + * ```asn1 + * x509Certificate BAG-TYPE ::= + * {OCTET STRING IDENTIFIED BY {certTypes 1}} + * -- DER-encoded X.509 certificate stored in OCTET STRING + * ``` + */ +export declare const id_x509Certificate = "1.2.840.113549.1.9.22.1"; +/** + * ```asn1 + * sdsiCertificate BAG-TYPE ::= + * {IA5String IDENTIFIED BY {certTypes 2}} + * -- Base64-encoded SDSI certificate stored in IA5String + * ``` + */ +export declare const id_sdsiCertificate = "1.2.840.113549.1.9.22.2"; diff --git a/node_modules/@peculiar/asn1-pfx/build/types/bags/crl_bag.d.ts b/node_modules/@peculiar/asn1-pfx/build/types/bags/crl_bag.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7a2c828e282750cac78319de07d8c22a4154530a --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/types/bags/crl_bag.d.ts @@ -0,0 +1,27 @@ +/** + * ```asn1 + * CRLBag ::= SEQUENCE { + * crlId BAG-TYPE.&id ({CRLTypes}), + * crltValue [0] EXPLICIT BAG-TYPE.&Type ({CRLTypes}{@crlId}) + * } + * ``` + */ +export declare class CRLBag { + crlId: string; + crltValue: ArrayBuffer; + constructor(params?: Partial); +} +/** + * ```asn1 + * crlTypes OBJECT IDENTIFIER ::= {pkcs-9 23} + * ``` + */ +export declare const id_crlTypes = "1.2.840.113549.1.9.23"; +/** + * ```asn1 + * x509CRL BAG-TYPE ::= + * {OCTET STRING IDENTIFIED BY {crlTypes 1}} + * -- DER-encoded X.509 CRL stored in OCTET STRING + * ``` + */ +export declare const id_x509CRL = "1.2.840.113549.1.9.23.1"; diff --git a/node_modules/@peculiar/asn1-pfx/build/types/bags/index.d.ts b/node_modules/@peculiar/asn1-pfx/build/types/bags/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1d0fefccff191293b3c6762bca723fbbac36671b --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/types/bags/index.d.ts @@ -0,0 +1,6 @@ +export * from "./cert_bag"; +export * from "./crl_bag"; +export * from "./key_bag"; +export * from "./pkcs8_shrouded_key_bag"; +export * from "./secret_bag"; +export * from "./types"; diff --git a/node_modules/@peculiar/asn1-pfx/build/types/bags/key_bag.d.ts b/node_modules/@peculiar/asn1-pfx/build/types/bags/key_bag.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cdc68dfe70efb3a8e44a5d4cba99c97ce7782cbd --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/types/bags/key_bag.d.ts @@ -0,0 +1,8 @@ +import { PrivateKeyInfo } from "@peculiar/asn1-pkcs8"; +/** + * ```asn1 + * KeyBag ::= PrivateKeyInfo + * ``` + */ +export declare class KeyBag extends PrivateKeyInfo { +} diff --git a/node_modules/@peculiar/asn1-pfx/build/types/bags/pkcs8_shrouded_key_bag.d.ts b/node_modules/@peculiar/asn1-pfx/build/types/bags/pkcs8_shrouded_key_bag.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..74b2b05b6b88a113ec4e089ff148fd9394a7106e --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/types/bags/pkcs8_shrouded_key_bag.d.ts @@ -0,0 +1,8 @@ +import { EncryptedPrivateKeyInfo } from "@peculiar/asn1-pkcs8"; +/** + * ```asn1 + * PKCS8ShroudedKeyBag ::= EncryptedPrivateKeyInfo + * ``` + */ +export declare class PKCS8ShroudedKeyBag extends EncryptedPrivateKeyInfo { +} diff --git a/node_modules/@peculiar/asn1-pfx/build/types/bags/secret_bag.d.ts b/node_modules/@peculiar/asn1-pfx/build/types/bags/secret_bag.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9b4e51fe1071c9d92734ee1389b595784998e293 --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/types/bags/secret_bag.d.ts @@ -0,0 +1,14 @@ +/** + * ```asn1 + * SecretBag ::= SEQUENCE { + * secretTypeId BAG-TYPE.&id ({SecretTypes}), + * secretValue [0] EXPLICIT BAG-TYPE.&Type ({SecretTypes} + * {@secretTypeId}) + * } + * ``` + */ +export declare class SecretBag { + secretTypeId: string; + secretValue: ArrayBuffer; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-pfx/build/types/bags/types.d.ts b/node_modules/@peculiar/asn1-pfx/build/types/bags/types.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9be018700a35cf003f16f78fce9d2552f5cdbad0 --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/types/bags/types.d.ts @@ -0,0 +1,49 @@ +/** + * ```asn1 + * keyBag BAG-TYPE ::= + * {KeyBag IDENTIFIED BY {bagtypes 1}} + * ``` + */ +export declare const id_keyBag = "1.2.840.113549.1.12.10.1.1"; +/** + * ```asn1 + * pkcs8ShroudedKeyBag BAG-TYPE ::= + * {PKCS8ShroudedKeyBag IDENTIFIED BY {bagtypes 2}} + * ``` + */ +export declare const id_pkcs8ShroudedKeyBag = "1.2.840.113549.1.12.10.1.2"; +/** + * ```asn1 + * certBag BAG-TYPE ::= + * {CertBag IDENTIFIED BY {bagtypes 3}} + * ``` + */ +export declare const id_certBag = "1.2.840.113549.1.12.10.1.3"; +/** + * ```asn1 + * crlBag BAG-TYPE ::= + * {CRLBag IDENTIFIED BY {bagtypes 4}} + * ``` + */ +export declare const id_CRLBag = "1.2.840.113549.1.12.10.1.4"; +/** + * ```asn1 + * secretBag BAG-TYPE ::= + * {SecretBag IDENTIFIED BY {bagtypes 5}} + * ``` + */ +export declare const id_SecretBag = "1.2.840.113549.1.12.10.1.5"; +/** + * ```asn1 + * safeContentsBag BAG-TYPE ::= + * {SafeContents IDENTIFIED BY {bagtypes 6}} + * ``` + */ +export declare const id_SafeContents = "1.2.840.113549.1.12.10.1.6"; +/** + * ```asn1 + * pkcs-9 OBJECT IDENTIFIER ::= {iso(1) member-body(2) us(840) + * rsadsi(113549) pkcs(1) 9} + * ``` + */ +export declare const id_pkcs_9 = "1.2.840.113549.1.9"; diff --git a/node_modules/@peculiar/asn1-pfx/build/types/index.d.ts b/node_modules/@peculiar/asn1-pfx/build/types/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..39d24b5ee1ac28278e45f3824404afc5cdca9d2e --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/types/index.d.ts @@ -0,0 +1,7 @@ +export * from "./attribute"; +export * from "./authenticated_safe"; +export * from "./bags"; +export * from "./mac_data"; +export * from "./object_identifiers"; +export * from "./pfx"; +export * from "./safe_bag"; diff --git a/node_modules/@peculiar/asn1-pfx/build/types/mac_data.d.ts b/node_modules/@peculiar/asn1-pfx/build/types/mac_data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9f4a76432a1291991d4f90febc5ff4d7443a44b9 --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/types/mac_data.d.ts @@ -0,0 +1,19 @@ +import { DigestInfo } from "@peculiar/asn1-rsa"; +import { OctetString } from "@peculiar/asn1-schema"; +/** + * ```asn1 + * MacData ::= SEQUENCE { + * mac DigestInfo, + * macSalt OCTET STRING, + * iterations INTEGER DEFAULT 1 + * -- Note: The default is for historical reasons and its use is + * -- deprecated. + * } + * ``` + */ +export declare class MacData { + mac: DigestInfo; + macSalt: OctetString; + iterations: number; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-pfx/build/types/object_identifiers.d.ts b/node_modules/@peculiar/asn1-pfx/build/types/object_identifiers.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1f52aa0dc79a3f4afe07efa6d22e122b7730fecb --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/types/object_identifiers.d.ts @@ -0,0 +1,67 @@ +/** + * ```asn1 + * rsadsi OBJECT IDENTIFIER ::= {iso(1) member-body(2) us(840) + * rsadsi(113549)} + * ``` + */ +export declare const id_rsadsi = "1.2.840.113549"; +/** + * ```asn1 + * pkcs OBJECT IDENTIFIER ::= {rsadsi pkcs(1)} + * ``` + */ +export declare const id_pkcs = "1.2.840.113549.1"; +/** + * ```asn1 + * pkcs-12 OBJECT IDENTIFIER ::= {pkcs 12} + * ``` + */ +export declare const id_pkcs_12 = "1.2.840.113549.1.12"; +/** + * ```asn1 + * pkcs-12PbeIds OBJECT IDENTIFIER ::= {pkcs-12 1} + * ``` + */ +export declare const id_pkcs_12PbeIds = "1.2.840.113549.1.12.1"; +/** + * ```asn1 + * pbeWithSHAAnd128BitRC4 OBJECT IDENTIFIER ::= {pkcs-12PbeIds 1} + * ``` + */ +export declare const id_pbeWithSHAAnd128BitRC4 = "1.2.840.113549.1.12.1.1"; +/** + * ```asn1 + * pbeWithSHAAnd40BitRC4 OBJECT IDENTIFIER ::= {pkcs-12PbeIds 2} + * ``` + */ +export declare const id_pbeWithSHAAnd40BitRC4 = "1.2.840.113549.1.12.1.2"; +/** + * ```asn1 + * pbeWithSHAAnd3-KeyTripleDES-CBC OBJECT IDENTIFIER ::= {pkcs-12PbeIds 3} + * ``` + */ +export declare const id_pbeWithSHAAnd3_KeyTripleDES_CBC = "1.2.840.113549.1.12.1.3"; +/** + * ```asn1 + * pbeWithSHAAnd2-KeyTripleDES-CBC OBJECT IDENTIFIER ::= {pkcs-12PbeIds 4} + * ``` + */ +export declare const id_pbeWithSHAAnd2_KeyTripleDES_CBC = "1.2.840.113549.1.12.1.4"; +/** + * ```asn1 + * pbeWithSHAAnd128BitRC2-CBC OBJECT IDENTIFIER ::= {pkcs-12PbeIds 5} + * ``` + */ +export declare const id_pbeWithSHAAnd128BitRC2_CBC = "1.2.840.113549.1.12.1.5"; +/** + * ```asn1 + * pbewithSHAAnd40BitRC2-CBC OBJECT IDENTIFIER ::= {pkcs-12PbeIds 6} + * ``` + */ +export declare const id_pbewithSHAAnd40BitRC2_CBC = "1.2.840.113549.1.12.1.6"; +/** + * ```asn1 + * bagtypes OBJECT IDENTIFIER ::= {pkcs-12 10 1} + * ``` + */ +export declare const id_bagtypes = "1.2.840.113549.1.12.10.1"; diff --git a/node_modules/@peculiar/asn1-pfx/build/types/pfx.d.ts b/node_modules/@peculiar/asn1-pfx/build/types/pfx.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c72d89d7f775c5456f59baa22bd41be146f878bf --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/types/pfx.d.ts @@ -0,0 +1,17 @@ +import { ContentInfo } from "@peculiar/asn1-cms"; +import { MacData } from "./mac_data"; +/** + * ```asn1 + * PFX ::= SEQUENCE { + * version INTEGER {v3(3)}(v3,...), + * authSafe ContentInfo, + * macData MacData OPTIONAL + * } + * ``` + */ +export declare class PFX { + version: number; + authSafe: ContentInfo; + macData: MacData; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-pfx/build/types/safe_bag.d.ts b/node_modules/@peculiar/asn1-pfx/build/types/safe_bag.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ea278a7c0b0aec7aeb25084b4c172935104cd2c3 --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/build/types/safe_bag.d.ts @@ -0,0 +1,25 @@ +import { AsnArray } from "@peculiar/asn1-schema"; +import { PKCS12Attribute } from "./attribute"; +/** + * ```asn1 + * SafeBag ::= SEQUENCE { + * bagId BAG-TYPE.&id ({PKCS12BagSet}), + * bagValue [0] EXPLICIT BAG-TYPE.&Type({PKCS12BagSet}{@bagId}), + * bagAttributes SET OF PKCS12Attribute OPTIONAL + * } + * ``` + */ +export declare class SafeBag { + bagId: string; + bagValue: ArrayBuffer; + bagAttributes?: PKCS12Attribute[]; + constructor(params?: Partial); +} +/** + * ```asn1 + * SafeContents ::= SEQUENCE OF SafeBag + * ``` + */ +export declare class SafeContents extends AsnArray { + constructor(items?: SafeBag[]); +} diff --git a/node_modules/@peculiar/asn1-pfx/package.json b/node_modules/@peculiar/asn1-pfx/package.json new file mode 100644 index 0000000000000000000000000000000000000000..5197a9baaf9ec6684ea06040b013fe4525f74e21 --- /dev/null +++ b/node_modules/@peculiar/asn1-pfx/package.json @@ -0,0 +1,64 @@ +{ + "name": "@peculiar/asn1-pfx", + "version": "2.8.0", + "description": "ASN.1 schema for PKCS #12 personal information exchange structures defined in RFC 7292.", + "keywords": [ + "asn", + "asn1", + "pfx", + "pkcs12", + "p12", + "rfc7292" + ], + "author": "PeculiarVentures, LLC", + "license": "MIT", + "files": [ + "build/**/*.{js,d.ts}", + "build/es2015/package.json", + "LICENSE", + "README.md" + ], + "main": "build/cjs/index.js", + "module": "build/es2015/index.js", + "types": "build/types/index.d.ts", + "exports": { + ".": { + "types": "./build/types/index.d.ts", + "import": "./build/es2015/index.js", + "require": "./build/cjs/index.js" + }, + "./package.json": "./package.json" + }, + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "https://github.com/PeculiarVentures/asn1-schema", + "directory": "packages/pfx" + }, + "bugs": { + "url": "https://github.com/PeculiarVentures/asn1-schema/issues" + }, + "homepage": "https://github.com/PeculiarVentures/asn1-schema/tree/master/packages/pfx#readme", + "scripts": { + "clear": "rimraf build", + "build": "npm run build:module && npm run build:types", + "build:module": "npm run build:cjs && npm run build:es2015", + "build:cjs": "tsc -p tsconfig.compile.json --removeComments --module commonjs --outDir build/cjs", + "build:es2015": "tsc -p tsconfig.compile.json --removeComments --module ES2015 --outDir build/es2015", + "postbuild:es2015": "node ../../scripts/prepare_esm_package.mjs build/es2015", + "prebuild:types": "rimraf build/types", + "build:types": "tsc -p tsconfig.compile.json --outDir build/types --declaration --emitDeclarationOnly", + "rebuild": "npm run clear && npm run build", + "test": "mocha" + }, + "dependencies": { + "@peculiar/asn1-cms": "^2.8.0", + "@peculiar/asn1-pkcs8": "^2.8.0", + "@peculiar/asn1-rsa": "^2.8.0", + "@peculiar/asn1-schema": "^2.8.0", + "asn1js": "^3.0.10", + "tslib": "^2.8.1" + } +} diff --git a/node_modules/@peculiar/asn1-pkcs8/LICENSE b/node_modules/@peculiar/asn1-pkcs8/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..43675934676182bb2368abb1a371722a830453eb --- /dev/null +++ b/node_modules/@peculiar/asn1-pkcs8/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@peculiar/asn1-pkcs8/README.md b/node_modules/@peculiar/asn1-pkcs8/README.md new file mode 100644 index 0000000000000000000000000000000000000000..dd5ca8c5120ea08c48bbd516b34b2f617c73e4ff --- /dev/null +++ b/node_modules/@peculiar/asn1-pkcs8/README.md @@ -0,0 +1,20 @@ +# `@peculiar/asn1-pkcs8` + +[![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/PeculiarVentures/asn1-schema/blob/master/packages/pkcs8/LICENSE) +[![npm version](https://badge.fury.io/js/%40peculiar%2Fasn1-pkcs8.svg)](https://badge.fury.io/js/%40peculiar%2Fasn1-pkcs8) + +[![NPM](https://nodei.co/npm/@peculiar/asn1-pkcs8.png)](https://nodei.co/npm/@peculiar/asn1-pkcs8/) + +ASN.1 schema for PKCS #8 private key information structures defined in RFC 5208. + +Use the exported classes with `@peculiar/asn1-schema` helpers such as `AsnConvert`, `AsnParser`, and `AsnSerializer` to parse or serialize DER-encoded data defined by the referenced specification. + +## Installation + +```bash +npm install @peculiar/asn1-pkcs8 +``` + +## Specifications + +- [RFC 5208: PKCS #8 Private-Key Information Syntax Specification](https://datatracker.ietf.org/doc/html/rfc5208) diff --git a/node_modules/@peculiar/asn1-pkcs8/build/cjs/encrypted_private_key_info.js b/node_modules/@peculiar/asn1-pkcs8/build/cjs/encrypted_private_key_info.js new file mode 100644 index 0000000000000000000000000000000000000000..704c72bf9ddbbfca47812a0b744858b4474b24f5 --- /dev/null +++ b/node_modules/@peculiar/asn1-pkcs8/build/cjs/encrypted_private_key_info.js @@ -0,0 +1,23 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.EncryptedPrivateKeyInfo = exports.EncryptedData = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +class EncryptedData extends asn1_schema_1.OctetString { +} +exports.EncryptedData = EncryptedData; +class EncryptedPrivateKeyInfo { + encryptionAlgorithm = new asn1_x509_1.AlgorithmIdentifier(); + encryptedData = new EncryptedData(); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.EncryptedPrivateKeyInfo = EncryptedPrivateKeyInfo; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_x509_1.AlgorithmIdentifier }) +], EncryptedPrivateKeyInfo.prototype, "encryptionAlgorithm", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: EncryptedData }) +], EncryptedPrivateKeyInfo.prototype, "encryptedData", void 0); diff --git a/node_modules/@peculiar/asn1-pkcs8/build/cjs/index.js b/node_modules/@peculiar/asn1-pkcs8/build/cjs/index.js new file mode 100644 index 0000000000000000000000000000000000000000..07bc49789fd3c10a84cd812a4943a5676553e095 --- /dev/null +++ b/node_modules/@peculiar/asn1-pkcs8/build/cjs/index.js @@ -0,0 +1,5 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +tslib_1.__exportStar(require("./encrypted_private_key_info"), exports); +tslib_1.__exportStar(require("./private_key_info"), exports); diff --git a/node_modules/@peculiar/asn1-pkcs8/build/cjs/private_key_info.js b/node_modules/@peculiar/asn1-pkcs8/build/cjs/private_key_info.js new file mode 100644 index 0000000000000000000000000000000000000000..804b5bbc8aabd452df043b14f9299adf3a610fa0 --- /dev/null +++ b/node_modules/@peculiar/asn1-pkcs8/build/cjs/private_key_info.js @@ -0,0 +1,50 @@ +"use strict"; +var Attributes_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.PrivateKeyInfo = exports.Attributes = exports.PrivateKey = exports.Version = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +var Version; +(function (Version) { + Version[Version["v1"] = 0] = "v1"; +})(Version || (exports.Version = Version = {})); +class PrivateKey extends asn1_schema_1.OctetString { +} +exports.PrivateKey = PrivateKey; +let Attributes = Attributes_1 = class Attributes extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, Attributes_1.prototype); + } +}; +exports.Attributes = Attributes; +exports.Attributes = Attributes = Attributes_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Sequence, itemType: asn1_x509_1.Attribute, + }) +], Attributes); +class PrivateKeyInfo { + version = Version.v1; + privateKeyAlgorithm = new asn1_x509_1.AlgorithmIdentifier(); + privateKey = new PrivateKey(); + attributes; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.PrivateKeyInfo = PrivateKeyInfo; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer }) +], PrivateKeyInfo.prototype, "version", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_x509_1.AlgorithmIdentifier }) +], PrivateKeyInfo.prototype, "privateKeyAlgorithm", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: PrivateKey }) +], PrivateKeyInfo.prototype, "privateKey", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: Attributes, implicit: true, context: 0, optional: true, + }) +], PrivateKeyInfo.prototype, "attributes", void 0); diff --git a/node_modules/@peculiar/asn1-pkcs8/build/es2015/encrypted_private_key_info.js b/node_modules/@peculiar/asn1-pkcs8/build/es2015/encrypted_private_key_info.js new file mode 100644 index 0000000000000000000000000000000000000000..018a5ae7139dfac0ae9db517447a84c15799a389 --- /dev/null +++ b/node_modules/@peculiar/asn1-pkcs8/build/es2015/encrypted_private_key_info.js @@ -0,0 +1,18 @@ +import { __decorate } from "tslib"; +import { AsnProp, OctetString } from "@peculiar/asn1-schema"; +import { AlgorithmIdentifier } from "@peculiar/asn1-x509"; +export class EncryptedData extends OctetString { +} +export class EncryptedPrivateKeyInfo { + encryptionAlgorithm = new AlgorithmIdentifier(); + encryptedData = new EncryptedData(); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AlgorithmIdentifier }) +], EncryptedPrivateKeyInfo.prototype, "encryptionAlgorithm", void 0); +__decorate([ + AsnProp({ type: EncryptedData }) +], EncryptedPrivateKeyInfo.prototype, "encryptedData", void 0); diff --git a/node_modules/@peculiar/asn1-pkcs8/build/es2015/index.js b/node_modules/@peculiar/asn1-pkcs8/build/es2015/index.js new file mode 100644 index 0000000000000000000000000000000000000000..29fd9dea409db091692a39f60ea74d24cafe97bf --- /dev/null +++ b/node_modules/@peculiar/asn1-pkcs8/build/es2015/index.js @@ -0,0 +1,2 @@ +export * from "./encrypted_private_key_info.js"; +export * from "./private_key_info.js"; diff --git a/node_modules/@peculiar/asn1-pkcs8/build/es2015/package.json b/node_modules/@peculiar/asn1-pkcs8/build/es2015/package.json new file mode 100644 index 0000000000000000000000000000000000000000..3dbc1ca591c0557e35b6004aeba250e6a70b56e3 --- /dev/null +++ b/node_modules/@peculiar/asn1-pkcs8/build/es2015/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/node_modules/@peculiar/asn1-pkcs8/build/es2015/private_key_info.js b/node_modules/@peculiar/asn1-pkcs8/build/es2015/private_key_info.js new file mode 100644 index 0000000000000000000000000000000000000000..9965dc4aa5018f19a21be9a48c65a288ceb9258b --- /dev/null +++ b/node_modules/@peculiar/asn1-pkcs8/build/es2015/private_key_info.js @@ -0,0 +1,45 @@ +var Attributes_1; +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnArray, AsnType, AsnTypeTypes, OctetString, } from "@peculiar/asn1-schema"; +import { AlgorithmIdentifier, Attribute } from "@peculiar/asn1-x509"; +export var Version; +(function (Version) { + Version[Version["v1"] = 0] = "v1"; +})(Version || (Version = {})); +export class PrivateKey extends OctetString { +} +let Attributes = Attributes_1 = class Attributes extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, Attributes_1.prototype); + } +}; +Attributes = Attributes_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Sequence, itemType: Attribute, + }) +], Attributes); +export { Attributes }; +export class PrivateKeyInfo { + version = Version.v1; + privateKeyAlgorithm = new AlgorithmIdentifier(); + privateKey = new PrivateKey(); + attributes; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.Integer }) +], PrivateKeyInfo.prototype, "version", void 0); +__decorate([ + AsnProp({ type: AlgorithmIdentifier }) +], PrivateKeyInfo.prototype, "privateKeyAlgorithm", void 0); +__decorate([ + AsnProp({ type: PrivateKey }) +], PrivateKeyInfo.prototype, "privateKey", void 0); +__decorate([ + AsnProp({ + type: Attributes, implicit: true, context: 0, optional: true, + }) +], PrivateKeyInfo.prototype, "attributes", void 0); diff --git a/node_modules/@peculiar/asn1-pkcs8/build/types/encrypted_private_key_info.d.ts b/node_modules/@peculiar/asn1-pkcs8/build/types/encrypted_private_key_info.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5ebedd49f455ebd38d72b685b0fba5ec62463ffa --- /dev/null +++ b/node_modules/@peculiar/asn1-pkcs8/build/types/encrypted_private_key_info.d.ts @@ -0,0 +1,22 @@ +import { OctetString } from "@peculiar/asn1-schema"; +import { AlgorithmIdentifier } from "@peculiar/asn1-x509"; +/** + * ```asn1 + * EncryptedData ::= OCTET STRING + * ``` + */ +export declare class EncryptedData extends OctetString { +} +/** + * ```asn1 + * EncryptedPrivateKeyInfo ::= SEQUENCE { + * encryptionAlgorithm AlgorithmIdentifier {{KeyEncryptionAlgorithms}}, + * encryptedData EncryptedData + * } + * ``` + */ +export declare class EncryptedPrivateKeyInfo { + encryptionAlgorithm: AlgorithmIdentifier; + encryptedData: EncryptedData; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-pkcs8/build/types/index.d.ts b/node_modules/@peculiar/asn1-pkcs8/build/types/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5c3b12fdeaf8277283df1c321eba68b086fb9d65 --- /dev/null +++ b/node_modules/@peculiar/asn1-pkcs8/build/types/index.d.ts @@ -0,0 +1,2 @@ +export * from "./encrypted_private_key_info"; +export * from "./private_key_info"; diff --git a/node_modules/@peculiar/asn1-pkcs8/build/types/private_key_info.d.ts b/node_modules/@peculiar/asn1-pkcs8/build/types/private_key_info.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8e1f116379d66f43433b53334add6bec6d7c2ce9 --- /dev/null +++ b/node_modules/@peculiar/asn1-pkcs8/build/types/private_key_info.d.ts @@ -0,0 +1,41 @@ +import { AsnArray, OctetString } from "@peculiar/asn1-schema"; +import { AlgorithmIdentifier, Attribute } from "@peculiar/asn1-x509"; +/** + * ```asn1 + * Version ::= INTEGER {v1(0)} (v1,...) + * ``` + */ +export declare enum Version { + v1 = 0 +} +/** + * ```asn1 + * PrivateKey ::= OCTET STRING + * ``` + */ +export declare class PrivateKey extends OctetString { +} +/** + * ```asn1 + * Attributes ::= SET OF Attribute + * ``` + */ +export declare class Attributes extends AsnArray { + constructor(items?: Attribute[]); +} +/** + * ```asn1 + * PrivateKeyInfo ::= SEQUENCE { + * version Version, + * privateKeyAlgorithm AlgorithmIdentifier {{PrivateKeyAlgorithms}}, + * privateKey PrivateKey, + * attributes [0] Attributes OPTIONAL } + * ``` + */ +export declare class PrivateKeyInfo { + version: Version; + privateKeyAlgorithm: AlgorithmIdentifier; + privateKey: PrivateKey; + attributes?: Attributes; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-pkcs8/package.json b/node_modules/@peculiar/asn1-pkcs8/package.json new file mode 100644 index 0000000000000000000000000000000000000000..a04f9028377c6394703a57e2f94909f730bc57dc --- /dev/null +++ b/node_modules/@peculiar/asn1-pkcs8/package.json @@ -0,0 +1,60 @@ +{ + "name": "@peculiar/asn1-pkcs8", + "version": "2.8.0", + "description": "ASN.1 schema for PKCS #8 private key information structures defined in RFC 5208.", + "keywords": [ + "asn", + "asn1", + "pkcs8", + "private-key", + "rfc5208" + ], + "author": "PeculiarVentures, LLC", + "license": "MIT", + "files": [ + "build/**/*.{js,d.ts}", + "build/es2015/package.json", + "LICENSE", + "README.md" + ], + "main": "build/cjs/index.js", + "module": "build/es2015/index.js", + "types": "build/types/index.d.ts", + "exports": { + ".": { + "types": "./build/types/index.d.ts", + "import": "./build/es2015/index.js", + "require": "./build/cjs/index.js" + }, + "./package.json": "./package.json" + }, + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "https://github.com/PeculiarVentures/asn1-schema", + "directory": "packages/pkcs8" + }, + "bugs": { + "url": "https://github.com/PeculiarVentures/asn1-schema/issues" + }, + "homepage": "https://github.com/PeculiarVentures/asn1-schema/tree/master/packages/pkcs8#readme", + "scripts": { + "clear": "rimraf build", + "build": "npm run build:module && npm run build:types", + "build:module": "npm run build:cjs && npm run build:es2015", + "build:cjs": "tsc -p tsconfig.compile.json --removeComments --module commonjs --outDir build/cjs", + "build:es2015": "tsc -p tsconfig.compile.json --removeComments --module ES2015 --outDir build/es2015", + "postbuild:es2015": "node ../../scripts/prepare_esm_package.mjs build/es2015", + "prebuild:types": "rimraf build/types", + "build:types": "tsc -p tsconfig.compile.json --outDir build/types --declaration --emitDeclarationOnly", + "rebuild": "npm run clear && npm run build" + }, + "dependencies": { + "@peculiar/asn1-schema": "^2.8.0", + "@peculiar/asn1-x509": "^2.8.0", + "asn1js": "^3.0.10", + "tslib": "^2.8.1" + } +} diff --git a/node_modules/@peculiar/asn1-pkcs9/LICENSE b/node_modules/@peculiar/asn1-pkcs9/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..81f990d60e3f91b8ecd127724ba7443acd379b49 --- /dev/null +++ b/node_modules/@peculiar/asn1-pkcs9/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@peculiar/asn1-pkcs9/README.md b/node_modules/@peculiar/asn1-pkcs9/README.md new file mode 100644 index 0000000000000000000000000000000000000000..f5eed380d6e606302961f8138478c8a15e6a65f1 --- /dev/null +++ b/node_modules/@peculiar/asn1-pkcs9/README.md @@ -0,0 +1,20 @@ +# `@peculiar/asn1-pkcs9` + +[![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/PeculiarVentures/asn1-schema/blob/master/packages/pkcs9/LICENSE) +[![npm version](https://badge.fury.io/js/%40peculiar%2Fasn1-pkcs9.svg)](https://badge.fury.io/js/%40peculiar%2Fasn1-pkcs9) + +[![NPM](https://nodei.co/npm/@peculiar/asn1-pkcs9.png)](https://nodei.co/npm/@peculiar/asn1-pkcs9/) + +ASN.1 schema for PKCS #9 selected attribute types defined in RFC 2985. + +Use the exported classes with `@peculiar/asn1-schema` helpers such as `AsnConvert`, `AsnParser`, and `AsnSerializer` to parse or serialize DER-encoded data defined by the referenced specification. + +## Installation + +```bash +npm install @peculiar/asn1-pkcs9 +``` + +## Specifications + +- [RFC 2985: PKCS #9: Selected Object Classes and Attribute Types](https://datatracker.ietf.org/doc/html/rfc2985) diff --git a/node_modules/@peculiar/asn1-pkcs9/build/cjs/index.js b/node_modules/@peculiar/asn1-pkcs9/build/cjs/index.js new file mode 100644 index 0000000000000000000000000000000000000000..9406e1a4ea95f7eeb04e5460c83991aa7cb46de9 --- /dev/null +++ b/node_modules/@peculiar/asn1-pkcs9/build/cjs/index.js @@ -0,0 +1,299 @@ +"use strict"; +var ExtensionRequest_1, ExtendedCertificateAttributes_1, SMIMECapabilities_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DateOfBirth = exports.UnstructuredAddress = exports.UnstructuredName = exports.EmailAddress = exports.EncryptedPrivateKeyInfo = exports.UserPKCS12 = exports.Pkcs7PDU = exports.PKCS9String = exports.id_at_pseudonym = exports.crlTypes = exports.id_certTypes = exports.id_smime = exports.id_pkcs9_mr_signingTimeMatch = exports.id_pkcs9_mr_caseIgnoreMatch = exports.id_pkcs9_sx_signingTime = exports.id_pkcs9_sx_pkcs9String = exports.id_pkcs9_at_countryOfResidence = exports.id_pkcs9_at_countryOfCitizenship = exports.id_pkcs9_at_gender = exports.id_pkcs9_at_placeOfBirth = exports.id_pkcs9_at_dateOfBirth = exports.id_ietf_at = exports.id_pkcs9_at_pkcs7PDU = exports.id_pkcs9_at_sequenceNumber = exports.id_pkcs9_at_randomNonce = exports.id_pkcs9_at_encryptedPrivateKeyInfo = exports.id_pkcs9_at_pkcs15Token = exports.id_pkcs9_at_userPKCS12 = exports.id_pkcs9_at_localKeyId = exports.id_pkcs9_at_friendlyName = exports.id_pkcs9_at_smimeCapabilities = exports.id_pkcs9_at_extensionRequest = exports.id_pkcs9_at_signingDescription = exports.id_pkcs9_at_extendedCertificateAttributes = exports.id_pkcs9_at_unstructuredAddress = exports.id_pkcs9_at_challengePassword = exports.id_pkcs9_at_counterSignature = exports.id_pkcs9_at_signingTime = exports.id_pkcs9_at_messageDigest = exports.id_pkcs9_at_contentType = exports.id_pkcs9_at_unstructuredName = exports.id_pkcs9_at_emailAddress = exports.id_pkcs9_oc_naturalPerson = exports.id_pkcs9_oc_pkcsEntity = exports.id_pkcs9_mr = exports.id_pkcs9_sx = exports.id_pkcs9_at = exports.id_pkcs9_oc = exports.id_pkcs9_mo = exports.id_pkcs9 = void 0; +exports.SMIMECapabilities = exports.SMIMECapability = exports.SigningDescription = exports.LocalKeyId = exports.FriendlyName = exports.ExtendedCertificateAttributes = exports.ExtensionRequest = exports.ChallengePassword = exports.CounterSignature = exports.SequenceNumber = exports.RandomNonce = exports.SigningTime = exports.MessageDigest = exports.ContentType = exports.Pseudonym = exports.CountryOfResidence = exports.CountryOfCitizenship = exports.Gender = exports.PlaceOfBirth = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const cms = tslib_1.__importStar(require("@peculiar/asn1-cms")); +const pfx = tslib_1.__importStar(require("@peculiar/asn1-pfx")); +const pkcs8 = tslib_1.__importStar(require("@peculiar/asn1-pkcs8")); +const x509 = tslib_1.__importStar(require("@peculiar/asn1-x509")); +const attr = tslib_1.__importStar(require("@peculiar/asn1-x509-attr")); +exports.id_pkcs9 = "1.2.840.113549.1.9"; +exports.id_pkcs9_mo = `${exports.id_pkcs9}.0`; +exports.id_pkcs9_oc = `${exports.id_pkcs9}.24`; +exports.id_pkcs9_at = `${exports.id_pkcs9}.25`; +exports.id_pkcs9_sx = `${exports.id_pkcs9}.26`; +exports.id_pkcs9_mr = `${exports.id_pkcs9}.27`; +exports.id_pkcs9_oc_pkcsEntity = `${exports.id_pkcs9_oc}.1`; +exports.id_pkcs9_oc_naturalPerson = `${exports.id_pkcs9_oc}.2`; +exports.id_pkcs9_at_emailAddress = `${exports.id_pkcs9}.1`; +exports.id_pkcs9_at_unstructuredName = `${exports.id_pkcs9}.2`; +exports.id_pkcs9_at_contentType = `${exports.id_pkcs9}.3`; +exports.id_pkcs9_at_messageDigest = `${exports.id_pkcs9}.4`; +exports.id_pkcs9_at_signingTime = `${exports.id_pkcs9}.5`; +exports.id_pkcs9_at_counterSignature = `${exports.id_pkcs9}.6`; +exports.id_pkcs9_at_challengePassword = `${exports.id_pkcs9}.7`; +exports.id_pkcs9_at_unstructuredAddress = `${exports.id_pkcs9}.8`; +exports.id_pkcs9_at_extendedCertificateAttributes = `${exports.id_pkcs9}.9`; +exports.id_pkcs9_at_signingDescription = `${exports.id_pkcs9}.13`; +exports.id_pkcs9_at_extensionRequest = `${exports.id_pkcs9}.14`; +exports.id_pkcs9_at_smimeCapabilities = `${exports.id_pkcs9}.15`; +exports.id_pkcs9_at_friendlyName = `${exports.id_pkcs9}.20`; +exports.id_pkcs9_at_localKeyId = `${exports.id_pkcs9}.21`; +exports.id_pkcs9_at_userPKCS12 = "2.16.840.1.113730.3.1.216"; +exports.id_pkcs9_at_pkcs15Token = `${exports.id_pkcs9_at}.1`; +exports.id_pkcs9_at_encryptedPrivateKeyInfo = `${exports.id_pkcs9_at}.2`; +exports.id_pkcs9_at_randomNonce = `${exports.id_pkcs9_at}.3`; +exports.id_pkcs9_at_sequenceNumber = `${exports.id_pkcs9_at}.4`; +exports.id_pkcs9_at_pkcs7PDU = `${exports.id_pkcs9_at}.5`; +exports.id_ietf_at = "1.3.6.1.5.5.7.9"; +exports.id_pkcs9_at_dateOfBirth = `${exports.id_ietf_at}.1`; +exports.id_pkcs9_at_placeOfBirth = `${exports.id_ietf_at}.2`; +exports.id_pkcs9_at_gender = `${exports.id_ietf_at}.3`; +exports.id_pkcs9_at_countryOfCitizenship = `${exports.id_ietf_at}.4`; +exports.id_pkcs9_at_countryOfResidence = `${exports.id_ietf_at}.5`; +exports.id_pkcs9_sx_pkcs9String = `${exports.id_pkcs9_sx}.1`; +exports.id_pkcs9_sx_signingTime = `${exports.id_pkcs9_sx}.2`; +exports.id_pkcs9_mr_caseIgnoreMatch = `${exports.id_pkcs9_mr}.1`; +exports.id_pkcs9_mr_signingTimeMatch = `${exports.id_pkcs9_mr}.2`; +exports.id_smime = `${exports.id_pkcs9}.16`; +exports.id_certTypes = `${exports.id_pkcs9}.22`; +exports.crlTypes = `${exports.id_pkcs9}.23`; +exports.id_at_pseudonym = `${attr.id_at}.65`; +let PKCS9String = class PKCS9String extends x509.DirectoryString { + ia5String; + constructor(params = {}) { + super(params); + } + toString() { + const o = {}; + o.toString(); + return this.ia5String || super.toString(); + } +}; +exports.PKCS9String = PKCS9String; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.IA5String }) +], PKCS9String.prototype, "ia5String", void 0); +exports.PKCS9String = PKCS9String = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], PKCS9String); +let Pkcs7PDU = class Pkcs7PDU extends cms.ContentInfo { +}; +exports.Pkcs7PDU = Pkcs7PDU; +exports.Pkcs7PDU = Pkcs7PDU = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Sequence }) +], Pkcs7PDU); +let UserPKCS12 = class UserPKCS12 extends pfx.PFX { +}; +exports.UserPKCS12 = UserPKCS12; +exports.UserPKCS12 = UserPKCS12 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Sequence }) +], UserPKCS12); +let EncryptedPrivateKeyInfo = class EncryptedPrivateKeyInfo extends pkcs8.EncryptedPrivateKeyInfo { +}; +exports.EncryptedPrivateKeyInfo = EncryptedPrivateKeyInfo; +exports.EncryptedPrivateKeyInfo = EncryptedPrivateKeyInfo = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Sequence }) +], EncryptedPrivateKeyInfo); +let EmailAddress = class EmailAddress { + value; + constructor(value = "") { + this.value = value; + } + toString() { + return this.value; + } +}; +exports.EmailAddress = EmailAddress; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.IA5String }) +], EmailAddress.prototype, "value", void 0); +exports.EmailAddress = EmailAddress = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], EmailAddress); +let UnstructuredName = class UnstructuredName extends PKCS9String { +}; +exports.UnstructuredName = UnstructuredName; +exports.UnstructuredName = UnstructuredName = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], UnstructuredName); +let UnstructuredAddress = class UnstructuredAddress extends x509.DirectoryString { +}; +exports.UnstructuredAddress = UnstructuredAddress; +exports.UnstructuredAddress = UnstructuredAddress = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], UnstructuredAddress); +let DateOfBirth = class DateOfBirth { + value; + constructor(value = new Date()) { + this.value = value; + } +}; +exports.DateOfBirth = DateOfBirth; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.GeneralizedTime }) +], DateOfBirth.prototype, "value", void 0); +exports.DateOfBirth = DateOfBirth = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], DateOfBirth); +let PlaceOfBirth = class PlaceOfBirth extends x509.DirectoryString { +}; +exports.PlaceOfBirth = PlaceOfBirth; +exports.PlaceOfBirth = PlaceOfBirth = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], PlaceOfBirth); +let Gender = class Gender { + value; + constructor(value = "M") { + this.value = value; + } + toString() { + return this.value; + } +}; +exports.Gender = Gender; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.PrintableString }) +], Gender.prototype, "value", void 0); +exports.Gender = Gender = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], Gender); +let CountryOfCitizenship = class CountryOfCitizenship { + value; + constructor(value = "") { + this.value = value; + } + toString() { + return this.value; + } +}; +exports.CountryOfCitizenship = CountryOfCitizenship; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.PrintableString }) +], CountryOfCitizenship.prototype, "value", void 0); +exports.CountryOfCitizenship = CountryOfCitizenship = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], CountryOfCitizenship); +let CountryOfResidence = class CountryOfResidence extends CountryOfCitizenship { +}; +exports.CountryOfResidence = CountryOfResidence; +exports.CountryOfResidence = CountryOfResidence = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], CountryOfResidence); +let Pseudonym = class Pseudonym extends x509.DirectoryString { +}; +exports.Pseudonym = Pseudonym; +exports.Pseudonym = Pseudonym = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], Pseudonym); +let ContentType = class ContentType { + value; + constructor(value = "") { + this.value = value; + } + toString() { + return this.value; + } +}; +exports.ContentType = ContentType; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.ObjectIdentifier }) +], ContentType.prototype, "value", void 0); +exports.ContentType = ContentType = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], ContentType); +class MessageDigest extends asn1_schema_1.OctetString { +} +exports.MessageDigest = MessageDigest; +let SigningTime = class SigningTime extends x509.Time { +}; +exports.SigningTime = SigningTime; +exports.SigningTime = SigningTime = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], SigningTime); +class RandomNonce extends asn1_schema_1.OctetString { +} +exports.RandomNonce = RandomNonce; +let SequenceNumber = class SequenceNumber { + value; + constructor(value = 0) { + this.value = value; + } + toString() { + return this.value.toString(); + } +}; +exports.SequenceNumber = SequenceNumber; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer }) +], SequenceNumber.prototype, "value", void 0); +exports.SequenceNumber = SequenceNumber = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], SequenceNumber); +let CounterSignature = class CounterSignature extends cms.SignerInfo { +}; +exports.CounterSignature = CounterSignature; +exports.CounterSignature = CounterSignature = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Sequence }) +], CounterSignature); +let ChallengePassword = class ChallengePassword extends x509.DirectoryString { +}; +exports.ChallengePassword = ChallengePassword; +exports.ChallengePassword = ChallengePassword = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], ChallengePassword); +let ExtensionRequest = ExtensionRequest_1 = class ExtensionRequest extends x509.Extensions { + constructor(items) { + super(items); + Object.setPrototypeOf(this, ExtensionRequest_1.prototype); + } +}; +exports.ExtensionRequest = ExtensionRequest; +exports.ExtensionRequest = ExtensionRequest = ExtensionRequest_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Sequence }) +], ExtensionRequest); +let ExtendedCertificateAttributes = ExtendedCertificateAttributes_1 = class ExtendedCertificateAttributes extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, ExtendedCertificateAttributes_1.prototype); + } +}; +exports.ExtendedCertificateAttributes = ExtendedCertificateAttributes; +exports.ExtendedCertificateAttributes = ExtendedCertificateAttributes = ExtendedCertificateAttributes_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Set, itemType: cms.Attribute, + }) +], ExtendedCertificateAttributes); +let FriendlyName = class FriendlyName { + value; + constructor(value = "") { + this.value = value; + } + toString() { + return this.value; + } +}; +exports.FriendlyName = FriendlyName; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.BmpString }) +], FriendlyName.prototype, "value", void 0); +exports.FriendlyName = FriendlyName = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], FriendlyName); +class LocalKeyId extends asn1_schema_1.OctetString { +} +exports.LocalKeyId = LocalKeyId; +class SigningDescription extends x509.DirectoryString { +} +exports.SigningDescription = SigningDescription; +let SMIMECapability = class SMIMECapability extends x509.AlgorithmIdentifier { +}; +exports.SMIMECapability = SMIMECapability; +exports.SMIMECapability = SMIMECapability = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Sequence }) +], SMIMECapability); +let SMIMECapabilities = SMIMECapabilities_1 = class SMIMECapabilities extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, SMIMECapabilities_1.prototype); + } +}; +exports.SMIMECapabilities = SMIMECapabilities; +exports.SMIMECapabilities = SMIMECapabilities = SMIMECapabilities_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Sequence, itemType: SMIMECapability, + }) +], SMIMECapabilities); diff --git a/node_modules/@peculiar/asn1-pkcs9/build/es2015/index.js b/node_modules/@peculiar/asn1-pkcs9/build/es2015/index.js new file mode 100644 index 0000000000000000000000000000000000000000..7353f4980f8cc002f4bdb7598676fbc61a9ee356 --- /dev/null +++ b/node_modules/@peculiar/asn1-pkcs9/build/es2015/index.js @@ -0,0 +1,291 @@ +var ExtensionRequest_1, ExtendedCertificateAttributes_1, SMIMECapabilities_1; +import { __decorate } from "tslib"; +import { AsnType, AsnTypeTypes, AsnPropTypes, AsnProp, OctetString, AsnArray, } from "@peculiar/asn1-schema"; +import * as cms from "@peculiar/asn1-cms"; +import * as pfx from "@peculiar/asn1-pfx"; +import * as pkcs8 from "@peculiar/asn1-pkcs8"; +import * as x509 from "@peculiar/asn1-x509"; +import * as attr from "@peculiar/asn1-x509-attr"; +export const id_pkcs9 = "1.2.840.113549.1.9"; +export const id_pkcs9_mo = `${id_pkcs9}.0`; +export const id_pkcs9_oc = `${id_pkcs9}.24`; +export const id_pkcs9_at = `${id_pkcs9}.25`; +export const id_pkcs9_sx = `${id_pkcs9}.26`; +export const id_pkcs9_mr = `${id_pkcs9}.27`; +export const id_pkcs9_oc_pkcsEntity = `${id_pkcs9_oc}.1`; +export const id_pkcs9_oc_naturalPerson = `${id_pkcs9_oc}.2`; +export const id_pkcs9_at_emailAddress = `${id_pkcs9}.1`; +export const id_pkcs9_at_unstructuredName = `${id_pkcs9}.2`; +export const id_pkcs9_at_contentType = `${id_pkcs9}.3`; +export const id_pkcs9_at_messageDigest = `${id_pkcs9}.4`; +export const id_pkcs9_at_signingTime = `${id_pkcs9}.5`; +export const id_pkcs9_at_counterSignature = `${id_pkcs9}.6`; +export const id_pkcs9_at_challengePassword = `${id_pkcs9}.7`; +export const id_pkcs9_at_unstructuredAddress = `${id_pkcs9}.8`; +export const id_pkcs9_at_extendedCertificateAttributes = `${id_pkcs9}.9`; +export const id_pkcs9_at_signingDescription = `${id_pkcs9}.13`; +export const id_pkcs9_at_extensionRequest = `${id_pkcs9}.14`; +export const id_pkcs9_at_smimeCapabilities = `${id_pkcs9}.15`; +export const id_pkcs9_at_friendlyName = `${id_pkcs9}.20`; +export const id_pkcs9_at_localKeyId = `${id_pkcs9}.21`; +export const id_pkcs9_at_userPKCS12 = "2.16.840.1.113730.3.1.216"; +export const id_pkcs9_at_pkcs15Token = `${id_pkcs9_at}.1`; +export const id_pkcs9_at_encryptedPrivateKeyInfo = `${id_pkcs9_at}.2`; +export const id_pkcs9_at_randomNonce = `${id_pkcs9_at}.3`; +export const id_pkcs9_at_sequenceNumber = `${id_pkcs9_at}.4`; +export const id_pkcs9_at_pkcs7PDU = `${id_pkcs9_at}.5`; +export const id_ietf_at = "1.3.6.1.5.5.7.9"; +export const id_pkcs9_at_dateOfBirth = `${id_ietf_at}.1`; +export const id_pkcs9_at_placeOfBirth = `${id_ietf_at}.2`; +export const id_pkcs9_at_gender = `${id_ietf_at}.3`; +export const id_pkcs9_at_countryOfCitizenship = `${id_ietf_at}.4`; +export const id_pkcs9_at_countryOfResidence = `${id_ietf_at}.5`; +export const id_pkcs9_sx_pkcs9String = `${id_pkcs9_sx}.1`; +export const id_pkcs9_sx_signingTime = `${id_pkcs9_sx}.2`; +export const id_pkcs9_mr_caseIgnoreMatch = `${id_pkcs9_mr}.1`; +export const id_pkcs9_mr_signingTimeMatch = `${id_pkcs9_mr}.2`; +export const id_smime = `${id_pkcs9}.16`; +export const id_certTypes = `${id_pkcs9}.22`; +export const crlTypes = `${id_pkcs9}.23`; +export const id_at_pseudonym = `${attr.id_at}.65`; +let PKCS9String = class PKCS9String extends x509.DirectoryString { + ia5String; + constructor(params = {}) { + super(params); + } + toString() { + const o = {}; + o.toString(); + return this.ia5String || super.toString(); + } +}; +__decorate([ + AsnProp({ type: AsnPropTypes.IA5String }) +], PKCS9String.prototype, "ia5String", void 0); +PKCS9String = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], PKCS9String); +export { PKCS9String }; +let Pkcs7PDU = class Pkcs7PDU extends cms.ContentInfo { +}; +Pkcs7PDU = __decorate([ + AsnType({ type: AsnTypeTypes.Sequence }) +], Pkcs7PDU); +export { Pkcs7PDU }; +let UserPKCS12 = class UserPKCS12 extends pfx.PFX { +}; +UserPKCS12 = __decorate([ + AsnType({ type: AsnTypeTypes.Sequence }) +], UserPKCS12); +export { UserPKCS12 }; +let EncryptedPrivateKeyInfo = class EncryptedPrivateKeyInfo extends pkcs8.EncryptedPrivateKeyInfo { +}; +EncryptedPrivateKeyInfo = __decorate([ + AsnType({ type: AsnTypeTypes.Sequence }) +], EncryptedPrivateKeyInfo); +export { EncryptedPrivateKeyInfo }; +let EmailAddress = class EmailAddress { + value; + constructor(value = "") { + this.value = value; + } + toString() { + return this.value; + } +}; +__decorate([ + AsnProp({ type: AsnPropTypes.IA5String }) +], EmailAddress.prototype, "value", void 0); +EmailAddress = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], EmailAddress); +export { EmailAddress }; +let UnstructuredName = class UnstructuredName extends PKCS9String { +}; +UnstructuredName = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], UnstructuredName); +export { UnstructuredName }; +let UnstructuredAddress = class UnstructuredAddress extends x509.DirectoryString { +}; +UnstructuredAddress = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], UnstructuredAddress); +export { UnstructuredAddress }; +let DateOfBirth = class DateOfBirth { + value; + constructor(value = new Date()) { + this.value = value; + } +}; +__decorate([ + AsnProp({ type: AsnPropTypes.GeneralizedTime }) +], DateOfBirth.prototype, "value", void 0); +DateOfBirth = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], DateOfBirth); +export { DateOfBirth }; +let PlaceOfBirth = class PlaceOfBirth extends x509.DirectoryString { +}; +PlaceOfBirth = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], PlaceOfBirth); +export { PlaceOfBirth }; +let Gender = class Gender { + value; + constructor(value = "M") { + this.value = value; + } + toString() { + return this.value; + } +}; +__decorate([ + AsnProp({ type: AsnPropTypes.PrintableString }) +], Gender.prototype, "value", void 0); +Gender = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], Gender); +export { Gender }; +let CountryOfCitizenship = class CountryOfCitizenship { + value; + constructor(value = "") { + this.value = value; + } + toString() { + return this.value; + } +}; +__decorate([ + AsnProp({ type: AsnPropTypes.PrintableString }) +], CountryOfCitizenship.prototype, "value", void 0); +CountryOfCitizenship = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], CountryOfCitizenship); +export { CountryOfCitizenship }; +let CountryOfResidence = class CountryOfResidence extends CountryOfCitizenship { +}; +CountryOfResidence = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], CountryOfResidence); +export { CountryOfResidence }; +let Pseudonym = class Pseudonym extends x509.DirectoryString { +}; +Pseudonym = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], Pseudonym); +export { Pseudonym }; +let ContentType = class ContentType { + value; + constructor(value = "") { + this.value = value; + } + toString() { + return this.value; + } +}; +__decorate([ + AsnProp({ type: AsnPropTypes.ObjectIdentifier }) +], ContentType.prototype, "value", void 0); +ContentType = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], ContentType); +export { ContentType }; +export class MessageDigest extends OctetString { +} +let SigningTime = class SigningTime extends x509.Time { +}; +SigningTime = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], SigningTime); +export { SigningTime }; +export class RandomNonce extends OctetString { +} +let SequenceNumber = class SequenceNumber { + value; + constructor(value = 0) { + this.value = value; + } + toString() { + return this.value.toString(); + } +}; +__decorate([ + AsnProp({ type: AsnPropTypes.Integer }) +], SequenceNumber.prototype, "value", void 0); +SequenceNumber = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], SequenceNumber); +export { SequenceNumber }; +let CounterSignature = class CounterSignature extends cms.SignerInfo { +}; +CounterSignature = __decorate([ + AsnType({ type: AsnTypeTypes.Sequence }) +], CounterSignature); +export { CounterSignature }; +let ChallengePassword = class ChallengePassword extends x509.DirectoryString { +}; +ChallengePassword = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], ChallengePassword); +export { ChallengePassword }; +let ExtensionRequest = ExtensionRequest_1 = class ExtensionRequest extends x509.Extensions { + constructor(items) { + super(items); + Object.setPrototypeOf(this, ExtensionRequest_1.prototype); + } +}; +ExtensionRequest = ExtensionRequest_1 = __decorate([ + AsnType({ type: AsnTypeTypes.Sequence }) +], ExtensionRequest); +export { ExtensionRequest }; +let ExtendedCertificateAttributes = ExtendedCertificateAttributes_1 = class ExtendedCertificateAttributes extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, ExtendedCertificateAttributes_1.prototype); + } +}; +ExtendedCertificateAttributes = ExtendedCertificateAttributes_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Set, itemType: cms.Attribute, + }) +], ExtendedCertificateAttributes); +export { ExtendedCertificateAttributes }; +let FriendlyName = class FriendlyName { + value; + constructor(value = "") { + this.value = value; + } + toString() { + return this.value; + } +}; +__decorate([ + AsnProp({ type: AsnPropTypes.BmpString }) +], FriendlyName.prototype, "value", void 0); +FriendlyName = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], FriendlyName); +export { FriendlyName }; +export class LocalKeyId extends OctetString { +} +export class SigningDescription extends x509.DirectoryString { +} +let SMIMECapability = class SMIMECapability extends x509.AlgorithmIdentifier { +}; +SMIMECapability = __decorate([ + AsnType({ type: AsnTypeTypes.Sequence }) +], SMIMECapability); +export { SMIMECapability }; +let SMIMECapabilities = SMIMECapabilities_1 = class SMIMECapabilities extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, SMIMECapabilities_1.prototype); + } +}; +SMIMECapabilities = SMIMECapabilities_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Sequence, itemType: SMIMECapability, + }) +], SMIMECapabilities); +export { SMIMECapabilities }; diff --git a/node_modules/@peculiar/asn1-pkcs9/build/es2015/package.json b/node_modules/@peculiar/asn1-pkcs9/build/es2015/package.json new file mode 100644 index 0000000000000000000000000000000000000000..3dbc1ca591c0557e35b6004aeba250e6a70b56e3 --- /dev/null +++ b/node_modules/@peculiar/asn1-pkcs9/build/es2015/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/node_modules/@peculiar/asn1-pkcs9/build/types/index.d.ts b/node_modules/@peculiar/asn1-pkcs9/build/types/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e9248669c538745b9c4070ae0e386f5b936ec6ed --- /dev/null +++ b/node_modules/@peculiar/asn1-pkcs9/build/types/index.d.ts @@ -0,0 +1,661 @@ +import { OctetString, AsnArray } from "@peculiar/asn1-schema"; +import * as cms from "@peculiar/asn1-cms"; +import * as pfx from "@peculiar/asn1-pfx"; +import * as pkcs8 from "@peculiar/asn1-pkcs8"; +import * as x509 from "@peculiar/asn1-x509"; +/** + * ASN.1 module + * + * This appendix includes all of the ASN.1 type and value definitions + * contained in this document in the form of the ASN.1 module PKCS-9. + * + * PKCS-9 {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) + * pkcs-9(9) modules(0) pkcs-9(1)} + * DEFINITIONS IMPLICIT TAGS ::= + * + * BEGIN + * + * -- EXPORTS All -- + * -- All types and values defined in this module is exported for use + * -- in other ASN.1 modules. + * + * IMPORTS + * + * informationFramework, authenticationFramework, + * selectedAttributeTypes, upperBounds , id-at + * FROM UsefulDefinitions {joint-iso-itu-t ds(5) module(1) + * usefulDefinitions(0) 3} + * + * ub-name + * FROM UpperBounds upperBounds + * + * OBJECT-CLASS, ATTRIBUTE, MATCHING-RULE, Attribute, top, + * objectIdentifierMatch + * FROM InformationFramework informationFramework + * + * ALGORITHM, Extensions, Time + * FROM AuthenticationFramework authenticationFramework + * + * DirectoryString, octetStringMatch, caseIgnoreMatch, caseExactMatch, + * generalizedTimeMatch, integerMatch, serialNumber + * FROM SelectedAttributeTypes selectedAttributeTypes + * + * ContentInfo, SignerInfo + * FROM CryptographicMessageSyntax {iso(1) member-body(2) us(840) + * rsadsi(113549) pkcs(1) pkcs-9(9) smime(16) modules(0) cms(1)} + * + * EncryptedPrivateKeyInfo + * FROM PKCS-8 {iso(1) member-body(2) us(840) rsadsi(113549) + * pkcs(1) pkcs-8(8) modules(1) pkcs-8(1)} + * + * PFX + * FROM PKCS-12 {iso(1) member-body(2) us(840) rsadsi(113549) + * pkcs(1) pkcs-12(12) modules(0) pkcs-12(1)} + * + * PKCS15Token + * FROM PKCS-15 {iso(1) member-body(2) us(840) rsadsi(113549) + * pkcs(1) pkcs-15(15) modules(1) pkcs-15(1)}; + * + * -- Upper bounds + * + * pkcs-9-ub-pkcs9String INTEGER ::= 255 + * pkcs-9-ub-emailAddress INTEGER ::= pkcs-9-ub-pkcs9String + * pkcs-9-ub-unstructuredName INTEGER ::= pkcs-9-ub-pkcs9String + * pkcs-9-ub-unstructuredAddress INTEGER ::= pkcs-9-ub-pkcs9String + * pkcs-9-ub-challengePassword INTEGER ::= pkcs-9-ub-pkcs9String + * pkcs-9-ub-friendlyName INTEGER ::= pkcs-9-ub-pkcs9String + * pkcs-9-ub-signingDescription INTEGER ::= pkcs-9-ub-pkcs9String + * pkcs-9-ub-match INTEGER ::= pkcs-9-ub-pkcs9String + * pkcs-9-ub-pseudonym INTEGER ::= ub-name + * pkcs-9-ub-placeOfBirth INTEGER ::= ub-name + * + * -- Object Identifiers + */ +/** + * pkcs-9 OBJECT IDENTIFIER ::= {iso(1) member-body(2) us(840) + * rsadsi(113549) pkcs(1) 9} + */ +export declare const id_pkcs9 = "1.2.840.113549.1.9"; +/** + * pkcs-9-mo OBJECT IDENTIFIER ::= {pkcs-9 0} -- Modules branch + */ +export declare const id_pkcs9_mo = "1.2.840.113549.1.9.0"; +/** + * pkcs-9-oc OBJECT IDENTIFIER ::= {pkcs-9 24} -- Object class branch + */ +export declare const id_pkcs9_oc = "1.2.840.113549.1.9.24"; +/** + * pkcs-9-at OBJECT IDENTIFIER ::= {pkcs-9 25} -- Attribute branch, for + * -- new attributes + */ +export declare const id_pkcs9_at = "1.2.840.113549.1.9.25"; +/** + * pkcs-9-sx OBJECT IDENTIFIER ::= {pkcs-9 26} -- For syntaxes (RFC 2252) + */ +export declare const id_pkcs9_sx = "1.2.840.113549.1.9.26"; +/** + * pkcs-9-mr OBJECT IDENTIFIER ::= {pkcs-9 27} -- Matching rules + */ +export declare const id_pkcs9_mr = "1.2.840.113549.1.9.27"; +/** + * pkcs-9-oc-pkcsEntity OBJECT IDENTIFIER ::= {pkcs-9-oc 1} + */ +export declare const id_pkcs9_oc_pkcsEntity = "1.2.840.113549.1.9.24.1"; +/** + * pkcs-9-oc-naturalPerson OBJECT IDENTIFIER ::= {pkcs-9-oc 2} + */ +export declare const id_pkcs9_oc_naturalPerson = "1.2.840.113549.1.9.24.2"; +/** + * pkcs-9-at-emailAddress OBJECT IDENTIFIER ::= {pkcs-9 1} + */ +export declare const id_pkcs9_at_emailAddress = "1.2.840.113549.1.9.1"; +/** + * pkcs-9-at-unstructuredName OBJECT IDENTIFIER ::= {pkcs-9 2} + */ +export declare const id_pkcs9_at_unstructuredName = "1.2.840.113549.1.9.2"; +/** + * pkcs-9-at-contentType OBJECT IDENTIFIER ::= {pkcs-9 3} + */ +export declare const id_pkcs9_at_contentType = "1.2.840.113549.1.9.3"; +/** + * pkcs-9-at-messageDigest OBJECT IDENTIFIER ::= {pkcs-9 4} + */ +export declare const id_pkcs9_at_messageDigest = "1.2.840.113549.1.9.4"; +/** + * pkcs-9-at-signingTime OBJECT IDENTIFIER ::= {pkcs-9 5} + */ +export declare const id_pkcs9_at_signingTime = "1.2.840.113549.1.9.5"; +/** + * pkcs-9-at-counterSignature OBJECT IDENTIFIER ::= {pkcs-9 6} + */ +export declare const id_pkcs9_at_counterSignature = "1.2.840.113549.1.9.6"; +/** + * pkcs-9-at-challengePassword OBJECT IDENTIFIER ::= {pkcs-9 7} + */ +export declare const id_pkcs9_at_challengePassword = "1.2.840.113549.1.9.7"; +/** + * pkcs-9-at-unstructuredAddress OBJECT IDENTIFIER ::= {pkcs-9 8} + */ +export declare const id_pkcs9_at_unstructuredAddress = "1.2.840.113549.1.9.8"; +/** + * pkcs-9-at-extendedCertificateAttributes + * OBJECT IDENTIFIER ::= {pkcs-9 9} + */ +export declare const id_pkcs9_at_extendedCertificateAttributes = "1.2.840.113549.1.9.9"; +/** + * -- Obsolete (?) attribute identifiers, purportedly from "tentative + * -- PKCS #9 draft" + * -- pkcs-9-at-issuerAndSerialNumber OBJECT IDENTIFIER ::= {pkcs-9 10} + * -- pkcs-9-at-passwordCheck OBJECT IDENTIFIER ::= {pkcs-9 11} + * -- pkcs-9-at-publicKey OBJECT IDENTIFIER ::= {pkcs-9 12} + */ +/** + * pkcs-9-at-signingDescription OBJECT IDENTIFIER ::= {pkcs-9 13} + */ +export declare const id_pkcs9_at_signingDescription = "1.2.840.113549.1.9.13"; +/** + * pkcs-9-at-extensionRequest OBJECT IDENTIFIER ::= {pkcs-9 14} + */ +export declare const id_pkcs9_at_extensionRequest = "1.2.840.113549.1.9.14"; +/** + * pkcs-9-at-smimeCapabilities OBJECT IDENTIFIER ::= {pkcs-9 15} + */ +export declare const id_pkcs9_at_smimeCapabilities = "1.2.840.113549.1.9.15"; +/** + * -- Unused (?) + * -- pkcs-9-at-? OBJECT IDENTIFIER ::= {pkcs-9 17} + * -- pkcs-9-at-? OBJECT IDENTIFIER ::= {pkcs-9 18} + * -- pkcs-9-at-? OBJECT IDENTIFIER ::= {pkcs-9 19} + */ +/** + * pkcs-9-at-friendlyName OBJECT IDENTIFIER ::= {pkcs-9 20} + */ +export declare const id_pkcs9_at_friendlyName = "1.2.840.113549.1.9.20"; +/** + * pkcs-9-at-localKeyId OBJECT IDENTIFIER ::= {pkcs-9 21} + */ +export declare const id_pkcs9_at_localKeyId = "1.2.840.113549.1.9.21"; +/** + * pkcs-9-at-userPKCS12 OBJECT IDENTIFIER ::= + * {2 16 840 1 113730 3 1 216} + */ +export declare const id_pkcs9_at_userPKCS12 = "2.16.840.1.113730.3.1.216"; +/** + * pkcs-9-at-pkcs15Token OBJECT IDENTIFIER ::= {pkcs-9-at 1} + */ +export declare const id_pkcs9_at_pkcs15Token = "1.2.840.113549.1.9.25.1"; +/** + * pkcs-9-at-encryptedPrivateKeyInfo OBJECT IDENTIFIER ::= {pkcs-9-at 2} + */ +export declare const id_pkcs9_at_encryptedPrivateKeyInfo = "1.2.840.113549.1.9.25.2"; +/** + * pkcs-9-at-randomNonce OBJECT IDENTIFIER ::= {pkcs-9-at 3} + */ +export declare const id_pkcs9_at_randomNonce = "1.2.840.113549.1.9.25.3"; +/** + * pkcs-9-at-sequenceNumber OBJECT IDENTIFIER ::= {pkcs-9-at 4} + */ +export declare const id_pkcs9_at_sequenceNumber = "1.2.840.113549.1.9.25.4"; +/** + * pkcs-9-at-pkcs7PDU OBJECT IDENTIFIER ::= {pkcs-9-at 5} + */ +export declare const id_pkcs9_at_pkcs7PDU = "1.2.840.113549.1.9.25.5"; +/** + * ietf-at OBJECT IDENTIFIER ::= + * {1 3 6 1 5 5 7 9} + */ +export declare const id_ietf_at = "1.3.6.1.5.5.7.9"; +/** + * pkcs-9-at-dateOfBirth OBJECT IDENTIFIER ::= {ietf-at 1} + */ +export declare const id_pkcs9_at_dateOfBirth = "1.3.6.1.5.5.7.9.1"; +/** + * pkcs-9-at-placeOfBirth OBJECT IDENTIFIER ::= {ietf-at 2} + */ +export declare const id_pkcs9_at_placeOfBirth = "1.3.6.1.5.5.7.9.2"; +/** + * pkcs-9-at-gender OBJECT IDENTIFIER ::= {ietf-at 3} + */ +export declare const id_pkcs9_at_gender = "1.3.6.1.5.5.7.9.3"; +/** + * pkcs-9-at-countryOfCitizenship OBJECT IDENTIFIER ::= {ietf-at 4} + */ +export declare const id_pkcs9_at_countryOfCitizenship = "1.3.6.1.5.5.7.9.4"; +/** + * pkcs-9-at-countryOfResidence OBJECT IDENTIFIER ::= {ietf-at 5} + */ +export declare const id_pkcs9_at_countryOfResidence = "1.3.6.1.5.5.7.9.5"; +/** + * pkcs-9-sx-pkcs9String OBJECT IDENTIFIER ::= {pkcs-9-sx 1} + */ +export declare const id_pkcs9_sx_pkcs9String = "1.2.840.113549.1.9.26.1"; +/** + * pkcs-9-sx-signingTime OBJECT IDENTIFIER ::= {pkcs-9-sx 2} + */ +export declare const id_pkcs9_sx_signingTime = "1.2.840.113549.1.9.26.2"; +/** + * pkcs-9-mr-caseIgnoreMatch OBJECT IDENTIFIER ::= {pkcs-9-mr 1} + */ +export declare const id_pkcs9_mr_caseIgnoreMatch = "1.2.840.113549.1.9.27.1"; +/** + * pkcs-9-mr-signingTimeMatch OBJECT IDENTIFIER ::= {pkcs-9-mr 2} + */ +export declare const id_pkcs9_mr_signingTimeMatch = "1.2.840.113549.1.9.27.2"; +/** + * -- Arcs with attributes defined elsewhere + */ +/** + * smime OBJECT IDENTIFIER ::= {pkcs-9 16} + */ +export declare const id_smime = "1.2.840.113549.1.9.16"; +/** + * -- Main arc for S/MIME (RFC 2633) + */ +/** + * certTypes OBJECT IDENTIFIER ::= {pkcs-9 22} + */ +export declare const id_certTypes = "1.2.840.113549.1.9.22"; +/** + * -- Main arc for certificate types defined in PKCS #12 + * crlTypes OBJECT IDENTIFIER ::= {pkcs-9 23} + */ +export declare const crlTypes = "1.2.840.113549.1.9.23"; +/** + * -- Main arc for crl types defined in PKCS #12 + * + * -- Other object identifiers + */ +/** + * id-at-pseudonym OBJECT IDENTIFIER ::= {id-at 65} + */ +export declare const id_at_pseudonym = "2.5.4.65"; +/** + * -- Useful types + */ +/** + * PKCS9String {INTEGER : maxSize} ::= CHOICE { + * ia5String IA5String (SIZE(1..maxSize)), + * directoryString DirectoryString {maxSize} + * } + */ +export declare class PKCS9String extends x509.DirectoryString { + ia5String?: string; + constructor(params?: Partial); + toString(): string; +} +/** + * + * -- Object classes + */ +/** + * pkcsEntity OBJECT-CLASS ::= { + * SUBCLASS OF { top } + * KIND auxiliary + * MAY CONTAIN { PKCSEntityAttributeSet } + * ID pkcs-9-oc-pkcsEntity + * } + * + * naturalPerson OBJECT-CLASS ::= { + * SUBCLASS OF { top } + * KIND auxiliary + * MAY CONTAIN { NaturalPersonAttributeSet } + * ID pkcs-9-oc-naturalPerson + * } + * + * -- Attribute sets + * + * PKCSEntityAttributeSet ATTRIBUTE ::= { + * pKCS7PDU | + * userPKCS12 | + * pKCS15Token | + * encryptedPrivateKeyInfo, + * ... -- For future extensions + * } + * + * NaturalPersonAttributeSet ATTRIBUTE ::= { + * emailAddress | + * unstructuredName | + * unstructuredAddress | + * dateOfBirth | + * placeOfBirth | + * gender | + * countryOfCitizenship | + * countryOfResidence | + * pseudonym | + * serialNumber, + * ... -- For future extensions + * } + * + * -- Attributes + */ +/** + * pKCS7PDU ATTRIBUTE ::= { + * WITH SYNTAX ContentInfo + * ID pkcs-9-at-pkcs7PDU + * } + */ +export declare class Pkcs7PDU extends cms.ContentInfo { +} +/** + * userPKCS12 ATTRIBUTE ::= { + * WITH SYNTAX PFX + * ID pkcs-9-at-userPKCS12 + * } + */ +export declare class UserPKCS12 extends pfx.PFX { +} +/** + * pKCS15Token ATTRIBUTE ::= { + * WITH SYNTAX PKCS15Token + * ID pkcs-9-at-pkcs15Token + * } + */ +/** + * encryptedPrivateKeyInfo ATTRIBUTE ::= { + * WITH SYNTAX EncryptedPrivateKeyInfo + * ID pkcs-9-at-encryptedPrivateKeyInfo + * } + */ +export declare class EncryptedPrivateKeyInfo extends pkcs8.EncryptedPrivateKeyInfo { +} +/** + * emailAddress ATTRIBUTE ::= { + * WITH SYNTAX IA5String (SIZE(1..pkcs-9-ub-emailAddress)) + * EQUALITY MATCHING RULE pkcs9CaseIgnoreMatch + * ID pkcs-9-at-emailAddress + * } + */ +export declare class EmailAddress { + value: string; + constructor(value?: string); + /** + * Returns a string representation of an object. + */ + toString(): string; +} +/** + * unstructuredName ATTRIBUTE ::= { + * WITH SYNTAX PKCS9String {pkcs-9-ub-unstructuredName} + * EQUALITY MATCHING RULE pkcs9CaseIgnoreMatch + * ID pkcs-9-at-unstructuredName + * } + */ +export declare class UnstructuredName extends PKCS9String { +} +/** + * unstructuredAddress ATTRIBUTE ::= { + * WITH SYNTAX DirectoryString {pkcs-9-ub-unstructuredAddress} + * EQUALITY MATCHING RULE caseIgnoreMatch + * ID pkcs-9-at-unstructuredAddress + * } + */ +export declare class UnstructuredAddress extends x509.DirectoryString { +} +/** + * dateOfBirth ATTRIBUTE ::= { + * WITH SYNTAX GeneralizedTime + * EQUALITY MATCHING RULE generalizedTimeMatch + * SINGLE VALUE TRUE + * ID pkcs-9-at-dateOfBirth + * } + */ +export declare class DateOfBirth { + value: Date; + constructor(value?: Date); +} +/** + * placeOfBirth ATTRIBUTE ::= { + * WITH SYNTAX DirectoryString {pkcs-9-ub-placeOfBirth} + * EQUALITY MATCHING RULE caseExactMatch + * SINGLE VALUE TRUE + * ID pkcs-9-at-placeOfBirth + * } + */ +export declare class PlaceOfBirth extends x509.DirectoryString { +} +export type GenderType = "M" | "F" | "m" | "f"; +/** + * gender ATTRIBUTE ::= { + * WITH SYNTAX PrintableString (SIZE(1) ^ + * FROM ("M" | "F" | "m" | "f")) + * EQUALITY MATCHING RULE caseIgnoreMatch + * SINGLE VALUE TRUE + * ID pkcs-9-at-gender + * } + */ +export declare class Gender { + value: GenderType; + /** + * Initialize Gender object + * @param value Gender object value. Default value is 'M'. + */ + constructor(value?: GenderType); + /** + * Returns a string representation of an object. + */ + toString(): string; +} +/** + * countryOfCitizenship ATTRIBUTE ::= { + * WITH SYNTAX PrintableString (SIZE(2))(CONSTRAINED BY { + * -- Must be a two-letter country acronym in accordance with + * -- ISO/IEC 3166 --}) + * EQUALITY MATCHING RULE caseIgnoreMatch + * ID pkcs-9-at-countryOfCitizenship + * } + */ +export declare class CountryOfCitizenship { + /** + * Country name. Must be a two-letter country acronym in accordance with ISO/IEC 3166 + */ + value: string; + constructor(value?: string); + /** + * Returns a string representation of an object. + */ + toString(): string; +} +/** + * countryOfResidence ATTRIBUTE ::= { + * WITH SYNTAX PrintableString (SIZE(2))(CONSTRAINED BY { + * -- Must be a two-letter country acronym in accordance with + * -- ISO/IEC 3166 --}) + * EQUALITY MATCHING RULE caseIgnoreMatch + * ID pkcs-9-at-countryOfResidence + * } + */ +export declare class CountryOfResidence extends CountryOfCitizenship { +} +/** + * pseudonym ATTRIBUTE ::= { + * WITH SYNTAX DirectoryString {pkcs-9-ub-pseudonym} + * EQUALITY MATCHING RULE caseExactMatch + * ID id-at-pseudonym + * } + */ +export declare class Pseudonym extends x509.DirectoryString { +} +/** + * contentType ATTRIBUTE ::= { + * WITH SYNTAX ContentType + * EQUALITY MATCHING RULE objectIdentifierMatch + * SINGLE VALUE TRUE + * ID pkcs-9-at-contentType + * } + */ +export declare class ContentType { + value: string; + constructor(value?: string); + /** + * Returns a string representation of an object. + */ + toString(): string; +} +/** + * MessageDigest ::= OCTET STRING + * + * messageDigest ATTRIBUTE ::= { + * WITH SYNTAX MessageDigest + * EQUALITY MATCHING RULE octetStringMatch + * SINGLE VALUE TRUE + * ID pkcs-9-at-messageDigest + * } + */ +export declare class MessageDigest extends OctetString { +} +/** + * SigningTime ::= Time -- imported from ISO/IEC 9594-8 + * + * signingTime ATTRIBUTE ::= { + * WITH SYNTAX SigningTime + * EQUALITY MATCHING RULE signingTimeMatch + * SINGLE VALUE TRUE + * ID pkcs-9-at-signingTime + * } + */ +export declare class SigningTime extends x509.Time { +} +/** + * RandomNonce ::= OCTET STRING (SIZE(4..MAX)) + * -- At least four bytes long + * + * randomNonce ATTRIBUTE ::= { + * WITH SYNTAX RandomNonce + * EQUALITY MATCHING RULE octetStringMatch + * SINGLE VALUE TRUE + * ID pkcs-9-at-randomNonce + * } + */ +export declare class RandomNonce extends OctetString { +} +/** + * SequenceNumber ::= INTEGER (1..MAX) + * + * sequenceNumber ATTRIBUTE ::= { + * WITH SYNTAX SequenceNumber + * EQUALITY MATCHING RULE integerMatch + * SINGLE VALUE TRUE + * ID pkcs-9-at-sequenceNumber + * } + */ +export declare class SequenceNumber { + value: number; + constructor(value?: number); + /** + * Returns a string representation of an object. + */ + toString(): string; +} +/** + * counterSignature ATTRIBUTE ::= { + * WITH SYNTAX SignerInfo + * ID pkcs-9-at-counterSignature + * } + */ +export declare class CounterSignature extends cms.SignerInfo { +} +/** + * challengePassword ATTRIBUTE ::= { + * WITH SYNTAX DirectoryString {pkcs-9-ub-challengePassword} + * EQUALITY MATCHING RULE caseExactMatch + * SINGLE VALUE TRUE + * ID pkcs-9-at-challengePassword + * } + */ +export declare class ChallengePassword extends x509.DirectoryString { +} +/** + * ExtensionRequest ::= Extensions + * + * extensionRequest ATTRIBUTE ::= { + * WITH SYNTAX ExtensionRequest + * SINGLE VALUE TRUE + * ID pkcs-9-at-extensionRequest + * } + */ +export declare class ExtensionRequest extends x509.Extensions { + constructor(items?: x509.Extension[]); +} +/** + * extendedCertificateAttributes ATTRIBUTE ::= { + * WITH SYNTAX SET OF Attribute + * SINGLE VALUE TRUE + * ID pkcs-9-at-extendedCertificateAttributes + * } + */ +export declare class ExtendedCertificateAttributes extends AsnArray { + constructor(items?: cms.Attribute[]); +} +/** + * friendlyName ATTRIBUTE ::= { + * WITH SYNTAX BMPString (SIZE(1..pkcs-9-ub-friendlyName)) + * EQUALITY MATCHING RULE caseIgnoreMatch + * SINGLE VALUE TRUE + * ID pkcs-9-at-friendlyName + * } + */ +export declare class FriendlyName { + value: string; + constructor(value?: string); + /** + * Returns a string representation of an object. + */ + toString(): string; +} +/** + * localKeyId ATTRIBUTE ::= { + * WITH SYNTAX OCTET STRING + * EQUALITY MATCHING RULE octetStringMatch + * SINGLE VALUE TRUE + * ID pkcs-9-at-localKeyId + * } + */ +export declare class LocalKeyId extends OctetString { +} +/** + * signingDescription ATTRIBUTE ::= { + * WITH SYNTAX DirectoryString {pkcs-9-ub-signingDescription} + * EQUALITY MATCHING RULE caseIgnoreMatch + * SINGLE VALUE TRUE + * ID pkcs-9-at-signingDescription + * } + */ +export declare class SigningDescription extends x509.DirectoryString { +} +/** + * SMIMECapability ::= SEQUENCE { + * algorithm ALGORITHM.&id ({SMIMEv3Algorithms}), + * parameters ALGORITHM.&Type ({SMIMEv3Algorithms}{@algorithm}) + * } + * + * SMIMEv3Algorithms ALGORITHM ::= {...-- See RFC 2633 --} + */ +export declare class SMIMECapability extends x509.AlgorithmIdentifier { +} +/** + * SMIMECapabilities ::= SEQUENCE OF SMIMECapability + * + * smimeCapabilities ATTRIBUTE ::= { + * WITH SYNTAX SMIMECapabilities + * SINGLE VALUE TRUE + * ID pkcs-9-at-smimeCapabilities + * } + */ +export declare class SMIMECapabilities extends AsnArray { + constructor(items?: SMIMECapability[]); +} +/** + * -- Matching rules + * + * pkcs9CaseIgnoreMatch MATCHING-RULE ::= { + * SYNTAX PKCS9String {pkcs-9-ub-match} + * ID pkcs-9-mr-caseIgnoreMatch + * } + * + * signingTimeMatch MATCHING-RULE ::= { + * SYNTAX SigningTime + * ID pkcs-9-mr-signingTimeMatch + * } + * + * END + */ diff --git a/node_modules/@peculiar/asn1-pkcs9/package.json b/node_modules/@peculiar/asn1-pkcs9/package.json new file mode 100644 index 0000000000000000000000000000000000000000..bd62f21f34ab78187ea2ac2a09f8438b1f74487b --- /dev/null +++ b/node_modules/@peculiar/asn1-pkcs9/package.json @@ -0,0 +1,64 @@ +{ + "name": "@peculiar/asn1-pkcs9", + "version": "2.8.0", + "description": "ASN.1 schema for PKCS #9 selected attribute types defined in RFC 2985.", + "keywords": [ + "asn", + "asn1", + "pkcs9", + "attribute", + "rfc2985" + ], + "author": "PeculiarVentures, LLC", + "license": "MIT", + "files": [ + "build/**/*.{js,d.ts}", + "build/es2015/package.json", + "LICENSE", + "README.md" + ], + "main": "build/cjs/index.js", + "module": "build/es2015/index.js", + "types": "build/types/index.d.ts", + "exports": { + ".": { + "types": "./build/types/index.d.ts", + "import": "./build/es2015/index.js", + "require": "./build/cjs/index.js" + }, + "./package.json": "./package.json" + }, + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "https://github.com/PeculiarVentures/asn1-schema", + "directory": "packages/pkcs9" + }, + "bugs": { + "url": "https://github.com/PeculiarVentures/asn1-schema/issues" + }, + "homepage": "https://github.com/PeculiarVentures/asn1-schema/tree/master/packages/pkcs9#readme", + "scripts": { + "clear": "rimraf build", + "build": "npm run build:module && npm run build:types", + "build:module": "npm run build:cjs && npm run build:es2015", + "build:cjs": "tsc -p tsconfig.compile.json --removeComments --module commonjs --outDir build/cjs", + "build:es2015": "tsc -p tsconfig.compile.json --removeComments --module ES2015 --outDir build/es2015", + "postbuild:es2015": "node ../../scripts/prepare_esm_package.mjs build/es2015", + "prebuild:types": "rimraf build/types", + "build:types": "tsc -p tsconfig.compile.json --outDir build/types --declaration --emitDeclarationOnly", + "rebuild": "npm run clear && npm run build" + }, + "dependencies": { + "@peculiar/asn1-cms": "^2.8.0", + "@peculiar/asn1-pfx": "^2.8.0", + "@peculiar/asn1-pkcs8": "^2.8.0", + "@peculiar/asn1-schema": "^2.8.0", + "@peculiar/asn1-x509": "^2.8.0", + "@peculiar/asn1-x509-attr": "^2.8.0", + "asn1js": "^3.0.10", + "tslib": "^2.8.1" + } +} diff --git a/node_modules/@peculiar/asn1-rsa/LICENSE b/node_modules/@peculiar/asn1-rsa/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..43675934676182bb2368abb1a371722a830453eb --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@peculiar/asn1-rsa/README.md b/node_modules/@peculiar/asn1-rsa/README.md new file mode 100644 index 0000000000000000000000000000000000000000..020f8f48b8aa2b5eb0bb3a889b7decd498232033 --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/README.md @@ -0,0 +1,20 @@ +# `@peculiar/asn1-rsa` + +[![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/PeculiarVentures/asn1-schema/blob/master/packages/rsa/LICENSE) +[![npm version](https://badge.fury.io/js/%40peculiar%2Fasn1-rsa.svg)](https://badge.fury.io/js/%40peculiar%2Fasn1-rsa) + +[![NPM](https://nodei.co/npm/@peculiar/asn1-rsa.png)](https://nodei.co/npm/@peculiar/asn1-rsa/) + +ASN.1 schema for RSA keys and algorithms defined in RFC 8017. + +Use the exported classes with `@peculiar/asn1-schema` helpers such as `AsnConvert`, `AsnParser`, and `AsnSerializer` to parse or serialize DER-encoded data defined by the referenced specification. + +## Installation + +```bash +npm install @peculiar/asn1-rsa +``` + +## Specifications + +- [RFC 8017: PKCS #1 v2.2: RSA Cryptography Specifications](https://datatracker.ietf.org/doc/html/rfc8017) diff --git a/node_modules/@peculiar/asn1-rsa/build/cjs/algorithms.js b/node_modules/@peculiar/asn1-rsa/build/cjs/algorithms.js new file mode 100644 index 0000000000000000000000000000000000000000..f3930bef02f6296cd2bb7be44dcab025212962d6 --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/build/cjs/algorithms.js @@ -0,0 +1,42 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.sha512_256WithRSAEncryption = exports.sha512_224WithRSAEncryption = exports.sha512WithRSAEncryption = exports.sha384WithRSAEncryption = exports.sha256WithRSAEncryption = exports.sha224WithRSAEncryption = exports.sha1WithRSAEncryption = exports.md5WithRSAEncryption = exports.md2WithRSAEncryption = exports.rsaEncryption = exports.pSpecifiedEmpty = exports.mgf1SHA1 = exports.sha512_256 = exports.sha512_224 = exports.sha512 = exports.sha384 = exports.sha256 = exports.sha224 = exports.sha1 = exports.md4 = exports.md2 = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +const oid = tslib_1.__importStar(require("./object_identifiers")); +function create(algorithm) { + return new asn1_x509_1.AlgorithmIdentifier({ + algorithm, parameters: null, + }); +} +exports.md2 = create(oid.id_md2); +exports.md4 = create(oid.id_md5); +exports.sha1 = create(oid.id_sha1); +exports.sha224 = create(oid.id_sha224); +exports.sha256 = create(oid.id_sha256); +exports.sha384 = create(oid.id_sha384); +exports.sha512 = create(oid.id_sha512); +exports.sha512_224 = create(oid.id_sha512_224); +exports.sha512_256 = create(oid.id_sha512_256); +exports.mgf1SHA1 = new asn1_x509_1.AlgorithmIdentifier({ + algorithm: oid.id_mgf1, + parameters: asn1_schema_1.AsnConvert.serialize(exports.sha1), +}); +exports.pSpecifiedEmpty = new asn1_x509_1.AlgorithmIdentifier({ + algorithm: oid.id_pSpecified, + parameters: asn1_schema_1.AsnConvert.serialize(asn1_schema_1.AsnOctetStringConverter.toASN(new Uint8Array([ + 0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, 0x0d, 0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18, + 0x90, 0xaf, 0xd8, 0x07, 0x09, + ]).buffer)), +}); +exports.rsaEncryption = create(oid.id_rsaEncryption); +exports.md2WithRSAEncryption = create(oid.id_md2WithRSAEncryption); +exports.md5WithRSAEncryption = create(oid.id_md5WithRSAEncryption); +exports.sha1WithRSAEncryption = create(oid.id_sha1WithRSAEncryption); +exports.sha224WithRSAEncryption = create(oid.id_sha512_224WithRSAEncryption); +exports.sha256WithRSAEncryption = create(oid.id_sha512_256WithRSAEncryption); +exports.sha384WithRSAEncryption = create(oid.id_sha384WithRSAEncryption); +exports.sha512WithRSAEncryption = create(oid.id_sha512WithRSAEncryption); +exports.sha512_224WithRSAEncryption = create(oid.id_sha512_224WithRSAEncryption); +exports.sha512_256WithRSAEncryption = create(oid.id_sha512_256WithRSAEncryption); diff --git a/node_modules/@peculiar/asn1-rsa/build/cjs/index.js b/node_modules/@peculiar/asn1-rsa/build/cjs/index.js new file mode 100644 index 0000000000000000000000000000000000000000..b1c92a2275ff2b3184e1486910b45452b28b978b --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/build/cjs/index.js @@ -0,0 +1,9 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +tslib_1.__exportStar(require("./parameters"), exports); +tslib_1.__exportStar(require("./algorithms"), exports); +tslib_1.__exportStar(require("./object_identifiers"), exports); +tslib_1.__exportStar(require("./other_prime_info"), exports); +tslib_1.__exportStar(require("./rsa_private_key"), exports); +tslib_1.__exportStar(require("./rsa_public_key"), exports); diff --git a/node_modules/@peculiar/asn1-rsa/build/cjs/object_identifiers.js b/node_modules/@peculiar/asn1-rsa/build/cjs/object_identifiers.js new file mode 100644 index 0000000000000000000000000000000000000000..06defadcac56972bdb1365c493482a84ee5b4c46 --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/build/cjs/object_identifiers.js @@ -0,0 +1,28 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.id_mgf1 = exports.id_md5 = exports.id_md2 = exports.id_sha512_256 = exports.id_sha512_224 = exports.id_sha512 = exports.id_sha384 = exports.id_sha256 = exports.id_sha224 = exports.id_sha1 = exports.id_sha512_256WithRSAEncryption = exports.id_sha512_224WithRSAEncryption = exports.id_sha512WithRSAEncryption = exports.id_sha384WithRSAEncryption = exports.id_sha256WithRSAEncryption = exports.id_ssha224WithRSAEncryption = exports.id_sha224WithRSAEncryption = exports.id_sha1WithRSAEncryption = exports.id_md5WithRSAEncryption = exports.id_md2WithRSAEncryption = exports.id_RSASSA_PSS = exports.id_pSpecified = exports.id_RSAES_OAEP = exports.id_rsaEncryption = exports.id_pkcs_1 = void 0; +exports.id_pkcs_1 = "1.2.840.113549.1.1"; +exports.id_rsaEncryption = `${exports.id_pkcs_1}.1`; +exports.id_RSAES_OAEP = `${exports.id_pkcs_1}.7`; +exports.id_pSpecified = `${exports.id_pkcs_1}.9`; +exports.id_RSASSA_PSS = `${exports.id_pkcs_1}.10`; +exports.id_md2WithRSAEncryption = `${exports.id_pkcs_1}.2`; +exports.id_md5WithRSAEncryption = `${exports.id_pkcs_1}.4`; +exports.id_sha1WithRSAEncryption = `${exports.id_pkcs_1}.5`; +exports.id_sha224WithRSAEncryption = `${exports.id_pkcs_1}.14`; +exports.id_ssha224WithRSAEncryption = exports.id_sha224WithRSAEncryption; +exports.id_sha256WithRSAEncryption = `${exports.id_pkcs_1}.11`; +exports.id_sha384WithRSAEncryption = `${exports.id_pkcs_1}.12`; +exports.id_sha512WithRSAEncryption = `${exports.id_pkcs_1}.13`; +exports.id_sha512_224WithRSAEncryption = `${exports.id_pkcs_1}.15`; +exports.id_sha512_256WithRSAEncryption = `${exports.id_pkcs_1}.16`; +exports.id_sha1 = "1.3.14.3.2.26"; +exports.id_sha224 = "2.16.840.1.101.3.4.2.4"; +exports.id_sha256 = "2.16.840.1.101.3.4.2.1"; +exports.id_sha384 = "2.16.840.1.101.3.4.2.2"; +exports.id_sha512 = "2.16.840.1.101.3.4.2.3"; +exports.id_sha512_224 = "2.16.840.1.101.3.4.2.5"; +exports.id_sha512_256 = "2.16.840.1.101.3.4.2.6"; +exports.id_md2 = "1.2.840.113549.2.2"; +exports.id_md5 = "1.2.840.113549.2.5"; +exports.id_mgf1 = `${exports.id_pkcs_1}.8`; diff --git a/node_modules/@peculiar/asn1-rsa/build/cjs/other_prime_info.js b/node_modules/@peculiar/asn1-rsa/build/cjs/other_prime_info.js new file mode 100644 index 0000000000000000000000000000000000000000..7724aaccae204d8806a64368984072343e852643 --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/build/cjs/other_prime_info.js @@ -0,0 +1,42 @@ +"use strict"; +var OtherPrimeInfos_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.OtherPrimeInfos = exports.OtherPrimeInfo = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +class OtherPrimeInfo { + prime = new ArrayBuffer(0); + exponent = new ArrayBuffer(0); + coefficient = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.OtherPrimeInfo = OtherPrimeInfo; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter, + }) +], OtherPrimeInfo.prototype, "prime", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter, + }) +], OtherPrimeInfo.prototype, "exponent", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter, + }) +], OtherPrimeInfo.prototype, "coefficient", void 0); +let OtherPrimeInfos = OtherPrimeInfos_1 = class OtherPrimeInfos extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, OtherPrimeInfos_1.prototype); + } +}; +exports.OtherPrimeInfos = OtherPrimeInfos; +exports.OtherPrimeInfos = OtherPrimeInfos = OtherPrimeInfos_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Sequence, itemType: OtherPrimeInfo, + }) +], OtherPrimeInfos); diff --git a/node_modules/@peculiar/asn1-rsa/build/cjs/parameters/index.js b/node_modules/@peculiar/asn1-rsa/build/cjs/parameters/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c624684bafaeabfd9b519e82c34c32d9a7162b1f --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/build/cjs/parameters/index.js @@ -0,0 +1,6 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +tslib_1.__exportStar(require("./rsaes_oaep"), exports); +tslib_1.__exportStar(require("./rsassa_pss"), exports); +tslib_1.__exportStar(require("./rsassa_pkcs1_v1_5"), exports); diff --git a/node_modules/@peculiar/asn1-rsa/build/cjs/parameters/rsaes_oaep.js b/node_modules/@peculiar/asn1-rsa/build/cjs/parameters/rsaes_oaep.js new file mode 100644 index 0000000000000000000000000000000000000000..5d9e79f76fb5612fbdd91724fd5a107d5d49ad9d --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/build/cjs/parameters/rsaes_oaep.js @@ -0,0 +1,39 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.RSAES_OAEP = exports.RsaEsOaepParams = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +const object_identifiers_1 = require("../object_identifiers"); +const algorithms_1 = require("../algorithms"); +class RsaEsOaepParams { + hashAlgorithm = new asn1_x509_1.AlgorithmIdentifier(algorithms_1.sha1); + maskGenAlgorithm = new asn1_x509_1.AlgorithmIdentifier({ + algorithm: object_identifiers_1.id_mgf1, + parameters: asn1_schema_1.AsnConvert.serialize(algorithms_1.sha1), + }); + pSourceAlgorithm = new asn1_x509_1.AlgorithmIdentifier(algorithms_1.pSpecifiedEmpty); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.RsaEsOaepParams = RsaEsOaepParams; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_x509_1.AlgorithmIdentifier, context: 0, defaultValue: algorithms_1.sha1, + }) +], RsaEsOaepParams.prototype, "hashAlgorithm", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_x509_1.AlgorithmIdentifier, context: 1, defaultValue: algorithms_1.mgf1SHA1, + }) +], RsaEsOaepParams.prototype, "maskGenAlgorithm", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_x509_1.AlgorithmIdentifier, context: 2, defaultValue: algorithms_1.pSpecifiedEmpty, + }) +], RsaEsOaepParams.prototype, "pSourceAlgorithm", void 0); +exports.RSAES_OAEP = new asn1_x509_1.AlgorithmIdentifier({ + algorithm: object_identifiers_1.id_RSAES_OAEP, + parameters: asn1_schema_1.AsnConvert.serialize(new RsaEsOaepParams()), +}); diff --git a/node_modules/@peculiar/asn1-rsa/build/cjs/parameters/rsassa_pkcs1_v1_5.js b/node_modules/@peculiar/asn1-rsa/build/cjs/parameters/rsassa_pkcs1_v1_5.js new file mode 100644 index 0000000000000000000000000000000000000000..b51f3e02e33906a9628103c0da49344a17b7707a --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/build/cjs/parameters/rsassa_pkcs1_v1_5.js @@ -0,0 +1,20 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DigestInfo = void 0; +const tslib_1 = require("tslib"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +class DigestInfo { + digestAlgorithm = new asn1_x509_1.AlgorithmIdentifier(); + digest = new asn1_schema_1.OctetString(); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.DigestInfo = DigestInfo; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_x509_1.AlgorithmIdentifier }) +], DigestInfo.prototype, "digestAlgorithm", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.OctetString }) +], DigestInfo.prototype, "digest", void 0); diff --git a/node_modules/@peculiar/asn1-rsa/build/cjs/parameters/rsassa_pss.js b/node_modules/@peculiar/asn1-rsa/build/cjs/parameters/rsassa_pss.js new file mode 100644 index 0000000000000000000000000000000000000000..efb2f141ef2eb81685130ae0c1f45c4f14c5caf8 --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/build/cjs/parameters/rsassa_pss.js @@ -0,0 +1,45 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.RSASSA_PSS = exports.RsaSaPssParams = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +const object_identifiers_1 = require("../object_identifiers"); +const algorithms_1 = require("../algorithms"); +class RsaSaPssParams { + hashAlgorithm = new asn1_x509_1.AlgorithmIdentifier(algorithms_1.sha1); + maskGenAlgorithm = new asn1_x509_1.AlgorithmIdentifier({ + algorithm: object_identifiers_1.id_mgf1, + parameters: asn1_schema_1.AsnConvert.serialize(algorithms_1.sha1), + }); + saltLength = 20; + trailerField = 1; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.RsaSaPssParams = RsaSaPssParams; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_x509_1.AlgorithmIdentifier, context: 0, defaultValue: algorithms_1.sha1, + }) +], RsaSaPssParams.prototype, "hashAlgorithm", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_x509_1.AlgorithmIdentifier, context: 1, defaultValue: algorithms_1.mgf1SHA1, + }) +], RsaSaPssParams.prototype, "maskGenAlgorithm", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, context: 2, defaultValue: 20, + }) +], RsaSaPssParams.prototype, "saltLength", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, context: 3, defaultValue: 1, + }) +], RsaSaPssParams.prototype, "trailerField", void 0); +exports.RSASSA_PSS = new asn1_x509_1.AlgorithmIdentifier({ + algorithm: object_identifiers_1.id_RSASSA_PSS, + parameters: asn1_schema_1.AsnConvert.serialize(new RsaSaPssParams()), +}); diff --git a/node_modules/@peculiar/asn1-rsa/build/cjs/rsa_private_key.js b/node_modules/@peculiar/asn1-rsa/build/cjs/rsa_private_key.js new file mode 100644 index 0000000000000000000000000000000000000000..582edc50d3b9f5c5e4ebd830518932730b63005c --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/build/cjs/rsa_private_key.js @@ -0,0 +1,70 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.RSAPrivateKey = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const other_prime_info_1 = require("./other_prime_info"); +class RSAPrivateKey { + version = 0; + modulus = new ArrayBuffer(0); + publicExponent = new ArrayBuffer(0); + privateExponent = new ArrayBuffer(0); + prime1 = new ArrayBuffer(0); + prime2 = new ArrayBuffer(0); + exponent1 = new ArrayBuffer(0); + exponent2 = new ArrayBuffer(0); + coefficient = new ArrayBuffer(0); + otherPrimeInfos; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.RSAPrivateKey = RSAPrivateKey; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer }) +], RSAPrivateKey.prototype, "version", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter, + }) +], RSAPrivateKey.prototype, "modulus", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter, + }) +], RSAPrivateKey.prototype, "publicExponent", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter, + }) +], RSAPrivateKey.prototype, "privateExponent", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter, + }) +], RSAPrivateKey.prototype, "prime1", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter, + }) +], RSAPrivateKey.prototype, "prime2", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter, + }) +], RSAPrivateKey.prototype, "exponent1", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter, + }) +], RSAPrivateKey.prototype, "exponent2", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter, + }) +], RSAPrivateKey.prototype, "coefficient", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: other_prime_info_1.OtherPrimeInfos, optional: true, + }) +], RSAPrivateKey.prototype, "otherPrimeInfos", void 0); diff --git a/node_modules/@peculiar/asn1-rsa/build/cjs/rsa_public_key.js b/node_modules/@peculiar/asn1-rsa/build/cjs/rsa_public_key.js new file mode 100644 index 0000000000000000000000000000000000000000..acc1374002e9f8e5bbb50bd8fae8d95e3479832b --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/build/cjs/rsa_public_key.js @@ -0,0 +1,23 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.RSAPublicKey = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +class RSAPublicKey { + modulus = new ArrayBuffer(0); + publicExponent = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.RSAPublicKey = RSAPublicKey; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter, + }) +], RSAPublicKey.prototype, "modulus", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter, + }) +], RSAPublicKey.prototype, "publicExponent", void 0); diff --git a/node_modules/@peculiar/asn1-rsa/build/es2015/algorithms.js b/node_modules/@peculiar/asn1-rsa/build/es2015/algorithms.js new file mode 100644 index 0000000000000000000000000000000000000000..2e6a5acef2d556f2d0d6edf6e35bd601a24fcb6c --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/build/es2015/algorithms.js @@ -0,0 +1,38 @@ +import { AsnConvert, AsnOctetStringConverter } from "@peculiar/asn1-schema"; +import { AlgorithmIdentifier } from "@peculiar/asn1-x509"; +import * as oid from "./object_identifiers.js"; +function create(algorithm) { + return new AlgorithmIdentifier({ + algorithm, parameters: null, + }); +} +export const md2 = create(oid.id_md2); +export const md4 = create(oid.id_md5); +export const sha1 = create(oid.id_sha1); +export const sha224 = create(oid.id_sha224); +export const sha256 = create(oid.id_sha256); +export const sha384 = create(oid.id_sha384); +export const sha512 = create(oid.id_sha512); +export const sha512_224 = create(oid.id_sha512_224); +export const sha512_256 = create(oid.id_sha512_256); +export const mgf1SHA1 = new AlgorithmIdentifier({ + algorithm: oid.id_mgf1, + parameters: AsnConvert.serialize(sha1), +}); +export const pSpecifiedEmpty = new AlgorithmIdentifier({ + algorithm: oid.id_pSpecified, + parameters: AsnConvert.serialize(AsnOctetStringConverter.toASN(new Uint8Array([ + 0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, 0x0d, 0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18, + 0x90, 0xaf, 0xd8, 0x07, 0x09, + ]).buffer)), +}); +export const rsaEncryption = create(oid.id_rsaEncryption); +export const md2WithRSAEncryption = create(oid.id_md2WithRSAEncryption); +export const md5WithRSAEncryption = create(oid.id_md5WithRSAEncryption); +export const sha1WithRSAEncryption = create(oid.id_sha1WithRSAEncryption); +export const sha224WithRSAEncryption = create(oid.id_sha512_224WithRSAEncryption); +export const sha256WithRSAEncryption = create(oid.id_sha512_256WithRSAEncryption); +export const sha384WithRSAEncryption = create(oid.id_sha384WithRSAEncryption); +export const sha512WithRSAEncryption = create(oid.id_sha512WithRSAEncryption); +export const sha512_224WithRSAEncryption = create(oid.id_sha512_224WithRSAEncryption); +export const sha512_256WithRSAEncryption = create(oid.id_sha512_256WithRSAEncryption); diff --git a/node_modules/@peculiar/asn1-rsa/build/es2015/index.js b/node_modules/@peculiar/asn1-rsa/build/es2015/index.js new file mode 100644 index 0000000000000000000000000000000000000000..357ec69d916c320a63fe9454786a2157945922b9 --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/build/es2015/index.js @@ -0,0 +1,6 @@ +export * from "./parameters/index.js"; +export * from "./algorithms.js"; +export * from "./object_identifiers.js"; +export * from "./other_prime_info.js"; +export * from "./rsa_private_key.js"; +export * from "./rsa_public_key.js"; diff --git a/node_modules/@peculiar/asn1-rsa/build/es2015/object_identifiers.js b/node_modules/@peculiar/asn1-rsa/build/es2015/object_identifiers.js new file mode 100644 index 0000000000000000000000000000000000000000..f0ca2041639f2c56880e633d312c9fecb9191288 --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/build/es2015/object_identifiers.js @@ -0,0 +1,25 @@ +export const id_pkcs_1 = "1.2.840.113549.1.1"; +export const id_rsaEncryption = `${id_pkcs_1}.1`; +export const id_RSAES_OAEP = `${id_pkcs_1}.7`; +export const id_pSpecified = `${id_pkcs_1}.9`; +export const id_RSASSA_PSS = `${id_pkcs_1}.10`; +export const id_md2WithRSAEncryption = `${id_pkcs_1}.2`; +export const id_md5WithRSAEncryption = `${id_pkcs_1}.4`; +export const id_sha1WithRSAEncryption = `${id_pkcs_1}.5`; +export const id_sha224WithRSAEncryption = `${id_pkcs_1}.14`; +export const id_ssha224WithRSAEncryption = id_sha224WithRSAEncryption; +export const id_sha256WithRSAEncryption = `${id_pkcs_1}.11`; +export const id_sha384WithRSAEncryption = `${id_pkcs_1}.12`; +export const id_sha512WithRSAEncryption = `${id_pkcs_1}.13`; +export const id_sha512_224WithRSAEncryption = `${id_pkcs_1}.15`; +export const id_sha512_256WithRSAEncryption = `${id_pkcs_1}.16`; +export const id_sha1 = "1.3.14.3.2.26"; +export const id_sha224 = "2.16.840.1.101.3.4.2.4"; +export const id_sha256 = "2.16.840.1.101.3.4.2.1"; +export const id_sha384 = "2.16.840.1.101.3.4.2.2"; +export const id_sha512 = "2.16.840.1.101.3.4.2.3"; +export const id_sha512_224 = "2.16.840.1.101.3.4.2.5"; +export const id_sha512_256 = "2.16.840.1.101.3.4.2.6"; +export const id_md2 = "1.2.840.113549.2.2"; +export const id_md5 = "1.2.840.113549.2.5"; +export const id_mgf1 = `${id_pkcs_1}.8`; diff --git a/node_modules/@peculiar/asn1-rsa/build/es2015/other_prime_info.js b/node_modules/@peculiar/asn1-rsa/build/es2015/other_prime_info.js new file mode 100644 index 0000000000000000000000000000000000000000..ab507186fdf9f8633dd3e6053fc76cedd410d433 --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/build/es2015/other_prime_info.js @@ -0,0 +1,38 @@ +var OtherPrimeInfos_1; +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnIntegerArrayBufferConverter, AsnArray, AsnType, AsnTypeTypes, } from "@peculiar/asn1-schema"; +export class OtherPrimeInfo { + prime = new ArrayBuffer(0); + exponent = new ArrayBuffer(0); + coefficient = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter, + }) +], OtherPrimeInfo.prototype, "prime", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter, + }) +], OtherPrimeInfo.prototype, "exponent", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter, + }) +], OtherPrimeInfo.prototype, "coefficient", void 0); +let OtherPrimeInfos = OtherPrimeInfos_1 = class OtherPrimeInfos extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, OtherPrimeInfos_1.prototype); + } +}; +OtherPrimeInfos = OtherPrimeInfos_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Sequence, itemType: OtherPrimeInfo, + }) +], OtherPrimeInfos); +export { OtherPrimeInfos }; diff --git a/node_modules/@peculiar/asn1-rsa/build/es2015/package.json b/node_modules/@peculiar/asn1-rsa/build/es2015/package.json new file mode 100644 index 0000000000000000000000000000000000000000..3dbc1ca591c0557e35b6004aeba250e6a70b56e3 --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/build/es2015/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/node_modules/@peculiar/asn1-rsa/build/es2015/parameters/index.js b/node_modules/@peculiar/asn1-rsa/build/es2015/parameters/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c88b607e29bef8889f493e98a157a5f47d3192a9 --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/build/es2015/parameters/index.js @@ -0,0 +1,3 @@ +export * from "./rsaes_oaep.js"; +export * from "./rsassa_pss.js"; +export * from "./rsassa_pkcs1_v1_5.js"; diff --git a/node_modules/@peculiar/asn1-rsa/build/es2015/parameters/rsaes_oaep.js b/node_modules/@peculiar/asn1-rsa/build/es2015/parameters/rsaes_oaep.js new file mode 100644 index 0000000000000000000000000000000000000000..56125accd236c700a110e9932cc91539ad81494c --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/build/es2015/parameters/rsaes_oaep.js @@ -0,0 +1,35 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnConvert } from "@peculiar/asn1-schema"; +import { AlgorithmIdentifier } from "@peculiar/asn1-x509"; +import { id_mgf1, id_RSAES_OAEP } from "../object_identifiers.js"; +import { sha1, mgf1SHA1, pSpecifiedEmpty, } from "../algorithms.js"; +export class RsaEsOaepParams { + hashAlgorithm = new AlgorithmIdentifier(sha1); + maskGenAlgorithm = new AlgorithmIdentifier({ + algorithm: id_mgf1, + parameters: AsnConvert.serialize(sha1), + }); + pSourceAlgorithm = new AlgorithmIdentifier(pSpecifiedEmpty); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ + type: AlgorithmIdentifier, context: 0, defaultValue: sha1, + }) +], RsaEsOaepParams.prototype, "hashAlgorithm", void 0); +__decorate([ + AsnProp({ + type: AlgorithmIdentifier, context: 1, defaultValue: mgf1SHA1, + }) +], RsaEsOaepParams.prototype, "maskGenAlgorithm", void 0); +__decorate([ + AsnProp({ + type: AlgorithmIdentifier, context: 2, defaultValue: pSpecifiedEmpty, + }) +], RsaEsOaepParams.prototype, "pSourceAlgorithm", void 0); +export const RSAES_OAEP = new AlgorithmIdentifier({ + algorithm: id_RSAES_OAEP, + parameters: AsnConvert.serialize(new RsaEsOaepParams()), +}); diff --git a/node_modules/@peculiar/asn1-rsa/build/es2015/parameters/rsassa_pkcs1_v1_5.js b/node_modules/@peculiar/asn1-rsa/build/es2015/parameters/rsassa_pkcs1_v1_5.js new file mode 100644 index 0000000000000000000000000000000000000000..4b89dcd4109ee88049f3363b57243be8993beb41 --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/build/es2015/parameters/rsassa_pkcs1_v1_5.js @@ -0,0 +1,16 @@ +import { __decorate } from "tslib"; +import { AlgorithmIdentifier } from "@peculiar/asn1-x509"; +import { AsnProp, OctetString } from "@peculiar/asn1-schema"; +export class DigestInfo { + digestAlgorithm = new AlgorithmIdentifier(); + digest = new OctetString(); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AlgorithmIdentifier }) +], DigestInfo.prototype, "digestAlgorithm", void 0); +__decorate([ + AsnProp({ type: OctetString }) +], DigestInfo.prototype, "digest", void 0); diff --git a/node_modules/@peculiar/asn1-rsa/build/es2015/parameters/rsassa_pss.js b/node_modules/@peculiar/asn1-rsa/build/es2015/parameters/rsassa_pss.js new file mode 100644 index 0000000000000000000000000000000000000000..05617d519a204771d0f3a175e365dc8077048067 --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/build/es2015/parameters/rsassa_pss.js @@ -0,0 +1,41 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnConvert, AsnPropTypes, } from "@peculiar/asn1-schema"; +import { AlgorithmIdentifier } from "@peculiar/asn1-x509"; +import { id_mgf1, id_RSASSA_PSS } from "../object_identifiers.js"; +import { sha1, mgf1SHA1 } from "../algorithms.js"; +export class RsaSaPssParams { + hashAlgorithm = new AlgorithmIdentifier(sha1); + maskGenAlgorithm = new AlgorithmIdentifier({ + algorithm: id_mgf1, + parameters: AsnConvert.serialize(sha1), + }); + saltLength = 20; + trailerField = 1; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ + type: AlgorithmIdentifier, context: 0, defaultValue: sha1, + }) +], RsaSaPssParams.prototype, "hashAlgorithm", void 0); +__decorate([ + AsnProp({ + type: AlgorithmIdentifier, context: 1, defaultValue: mgf1SHA1, + }) +], RsaSaPssParams.prototype, "maskGenAlgorithm", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, context: 2, defaultValue: 20, + }) +], RsaSaPssParams.prototype, "saltLength", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, context: 3, defaultValue: 1, + }) +], RsaSaPssParams.prototype, "trailerField", void 0); +export const RSASSA_PSS = new AlgorithmIdentifier({ + algorithm: id_RSASSA_PSS, + parameters: AsnConvert.serialize(new RsaSaPssParams()), +}); diff --git a/node_modules/@peculiar/asn1-rsa/build/es2015/rsa_private_key.js b/node_modules/@peculiar/asn1-rsa/build/es2015/rsa_private_key.js new file mode 100644 index 0000000000000000000000000000000000000000..9b5c236be399c57b7f805802ab7014427cbbc858 --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/build/es2015/rsa_private_key.js @@ -0,0 +1,66 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnIntegerArrayBufferConverter, } from "@peculiar/asn1-schema"; +import { OtherPrimeInfos } from "./other_prime_info.js"; +export class RSAPrivateKey { + version = 0; + modulus = new ArrayBuffer(0); + publicExponent = new ArrayBuffer(0); + privateExponent = new ArrayBuffer(0); + prime1 = new ArrayBuffer(0); + prime2 = new ArrayBuffer(0); + exponent1 = new ArrayBuffer(0); + exponent2 = new ArrayBuffer(0); + coefficient = new ArrayBuffer(0); + otherPrimeInfos; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.Integer }) +], RSAPrivateKey.prototype, "version", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter, + }) +], RSAPrivateKey.prototype, "modulus", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter, + }) +], RSAPrivateKey.prototype, "publicExponent", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter, + }) +], RSAPrivateKey.prototype, "privateExponent", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter, + }) +], RSAPrivateKey.prototype, "prime1", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter, + }) +], RSAPrivateKey.prototype, "prime2", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter, + }) +], RSAPrivateKey.prototype, "exponent1", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter, + }) +], RSAPrivateKey.prototype, "exponent2", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter, + }) +], RSAPrivateKey.prototype, "coefficient", void 0); +__decorate([ + AsnProp({ + type: OtherPrimeInfos, optional: true, + }) +], RSAPrivateKey.prototype, "otherPrimeInfos", void 0); diff --git a/node_modules/@peculiar/asn1-rsa/build/es2015/rsa_public_key.js b/node_modules/@peculiar/asn1-rsa/build/es2015/rsa_public_key.js new file mode 100644 index 0000000000000000000000000000000000000000..54211384aa69839229aa87ab367b8a3ae88841d5 --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/build/es2015/rsa_public_key.js @@ -0,0 +1,19 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnIntegerArrayBufferConverter, } from "@peculiar/asn1-schema"; +export class RSAPublicKey { + modulus = new ArrayBuffer(0); + publicExponent = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter, + }) +], RSAPublicKey.prototype, "modulus", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter, + }) +], RSAPublicKey.prototype, "publicExponent", void 0); diff --git a/node_modules/@peculiar/asn1-rsa/build/types/algorithms.d.ts b/node_modules/@peculiar/asn1-rsa/build/types/algorithms.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cce8e93b047b62e2baa8ed9e313a123dde498af6 --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/build/types/algorithms.d.ts @@ -0,0 +1,22 @@ +import { AlgorithmIdentifier } from "@peculiar/asn1-x509"; +export declare const md2: AlgorithmIdentifier; +export declare const md4: AlgorithmIdentifier; +export declare const sha1: AlgorithmIdentifier; +export declare const sha224: AlgorithmIdentifier; +export declare const sha256: AlgorithmIdentifier; +export declare const sha384: AlgorithmIdentifier; +export declare const sha512: AlgorithmIdentifier; +export declare const sha512_224: AlgorithmIdentifier; +export declare const sha512_256: AlgorithmIdentifier; +export declare const mgf1SHA1: AlgorithmIdentifier; +export declare const pSpecifiedEmpty: AlgorithmIdentifier; +export declare const rsaEncryption: AlgorithmIdentifier; +export declare const md2WithRSAEncryption: AlgorithmIdentifier; +export declare const md5WithRSAEncryption: AlgorithmIdentifier; +export declare const sha1WithRSAEncryption: AlgorithmIdentifier; +export declare const sha224WithRSAEncryption: AlgorithmIdentifier; +export declare const sha256WithRSAEncryption: AlgorithmIdentifier; +export declare const sha384WithRSAEncryption: AlgorithmIdentifier; +export declare const sha512WithRSAEncryption: AlgorithmIdentifier; +export declare const sha512_224WithRSAEncryption: AlgorithmIdentifier; +export declare const sha512_256WithRSAEncryption: AlgorithmIdentifier; diff --git a/node_modules/@peculiar/asn1-rsa/build/types/index.d.ts b/node_modules/@peculiar/asn1-rsa/build/types/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..77e3add28304272f0a20c703a4f355955613c8bc --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/build/types/index.d.ts @@ -0,0 +1,6 @@ +export * from "./parameters"; +export * from "./algorithms"; +export * from "./object_identifiers"; +export * from "./other_prime_info"; +export * from "./rsa_private_key"; +export * from "./rsa_public_key"; diff --git a/node_modules/@peculiar/asn1-rsa/build/types/object_identifiers.d.ts b/node_modules/@peculiar/asn1-rsa/build/types/object_identifiers.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d5f0c2bdedd9636afcd7621d305bf6e1357ff9ae --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/build/types/object_identifiers.d.ts @@ -0,0 +1,176 @@ +/** + * ```asn1 + * pkcs-1 OBJECT IDENTIFIER ::= { + iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 1 + * ``` + */ +export declare const id_pkcs_1 = "1.2.840.113549.1.1"; +/** + * ```asn1 + * rsaEncryption OBJECT IDENTIFIER ::= { pkcs-1 1 } + * ``` + */ +export declare const id_rsaEncryption = "1.2.840.113549.1.1.1"; +/** + * ```asn1 + * id-RSAES-OAEP OBJECT IDENTIFIER ::= { pkcs-1 7 } + * ``` + */ +export declare const id_RSAES_OAEP = "1.2.840.113549.1.1.7"; +/** + * ```asn1 + * id-pSpecified OBJECT IDENTIFIER ::= { pkcs-1 9 } + * ``` + */ +export declare const id_pSpecified = "1.2.840.113549.1.1.9"; +/** + * ```asn1 + * id-RSASSA-PSS OBJECT IDENTIFIER ::= { pkcs-1 10 } + * ``` + */ +export declare const id_RSASSA_PSS = "1.2.840.113549.1.1.10"; +/** + * ```asn1 + * md2WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 2 } + * ``` + */ +export declare const id_md2WithRSAEncryption = "1.2.840.113549.1.1.2"; +/** + * ```asn1 + * md5WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 4 } + * ``` + */ +export declare const id_md5WithRSAEncryption = "1.2.840.113549.1.1.4"; +/** + * ```asn1 + * sha1WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 5 } + * ``` + */ +export declare const id_sha1WithRSAEncryption = "1.2.840.113549.1.1.5"; +/** + * ```asn1 + * sha224WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 14 } + * ``` + */ +export declare const id_sha224WithRSAEncryption = "1.2.840.113549.1.1.14"; +/** + * ```asn1 + * sha224WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 14 } + * ``` + * @deprecated Should be removed later + */ +export declare const id_ssha224WithRSAEncryption = "1.2.840.113549.1.1.14"; +/** + * ```asn1 + * sha256WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 11 } + * ``` + */ +export declare const id_sha256WithRSAEncryption = "1.2.840.113549.1.1.11"; +/** + * ```asn1 + * sha384WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 12 } + * ``` + */ +export declare const id_sha384WithRSAEncryption = "1.2.840.113549.1.1.12"; +/** + * ```asn1 + * sha512WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 13 } + * ``` + */ +export declare const id_sha512WithRSAEncryption = "1.2.840.113549.1.1.13"; +/** + * ```asn1 + * sha512-224WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 15 } + * ``` + */ +export declare const id_sha512_224WithRSAEncryption = "1.2.840.113549.1.1.15"; +/** + * ```asn1 + * sha512-256WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 16 } + * ``` + */ +export declare const id_sha512_256WithRSAEncryption = "1.2.840.113549.1.1.16"; +/** + * ```asn1 + * id-sha1 OBJECT IDENTIFIER ::= { + * iso(1) identified-organization(3) oiw(14) secsig(3) algorithms(2) + * 26 + * ``` + */ +export declare const id_sha1 = "1.3.14.3.2.26"; +/** + * ```asn1 + * id-sha224 OBJECT IDENTIFIER ::= { + * joint-iso-itu-t (2) country (16) us (840) organization (1) + * gov (101) csor (3) nistalgorithm (4) hashalgs (2) 4 + * } + * ``` + */ +export declare const id_sha224 = "2.16.840.1.101.3.4.2.4"; +/** + * ```asn1 + * id-sha256 OBJECT IDENTIFIER ::= { + * joint-iso-itu-t (2) country (16) us (840) organization (1) + * gov (101) csor (3) nistalgorithm (4) hashalgs (2) 1 + * } + * ``` + */ +export declare const id_sha256 = "2.16.840.1.101.3.4.2.1"; +/** + * ```asn1 + * id-sha384 OBJECT IDENTIFIER ::= { + * joint-iso-itu-t (2) country (16) us (840) organization (1) + * gov (101) csor (3) nistalgorithm (4) hashalgs (2) 2 + * } + * ``` + */ +export declare const id_sha384 = "2.16.840.1.101.3.4.2.2"; +/** + * ```asn1 + * id-sha512 OBJECT IDENTIFIER ::= { + * joint-iso-itu-t (2) country (16) us (840) organization (1) + * gov (101) csor (3) nistalgorithm (4) hashalgs (2) 3 + * } + * ``` + */ +export declare const id_sha512 = "2.16.840.1.101.3.4.2.3"; +/** + * ```asn1 + * id-sha512-224 OBJECT IDENTIFIER ::= { + * joint-iso-itu-t (2) country (16) us (840) organization (1) + * gov (101) csor (3) nistalgorithm (4) hashalgs (2) 5 + * } + * ``` + */ +export declare const id_sha512_224 = "2.16.840.1.101.3.4.2.5"; +/** + * ```asn1 + * id-sha512-256 OBJECT IDENTIFIER ::= { + * joint-iso-itu-t (2) country (16) us (840) organization (1) + * gov (101) csor (3) nistalgorithm (4) hashalgs (2) 6 + * } + * ``` + */ +export declare const id_sha512_256 = "2.16.840.1.101.3.4.2.6"; +/** + * ```asn1 + * id-md2 OBJECT IDENTIFIER ::= { + * iso(1) member-body(2) us(840) rsadsi(113549) digestAlgorithm(2) 2 + * } + * ``` + */ +export declare const id_md2 = "1.2.840.113549.2.2"; +/** + * ```asn1 + * id-md5 OBJECT IDENTIFIER ::= { + * iso(1) member-body(2) us(840) rsadsi(113549) digestAlgorithm(2) 5 + * } + * ``` + */ +export declare const id_md5 = "1.2.840.113549.2.5"; +/** + * ```asn1 + * id-mgf1 OBJECT IDENTIFIER ::= { pkcs-1 8 } + * ``` + */ +export declare const id_mgf1 = "1.2.840.113549.1.1.8"; diff --git a/node_modules/@peculiar/asn1-rsa/build/types/other_prime_info.d.ts b/node_modules/@peculiar/asn1-rsa/build/types/other_prime_info.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..abd3c3c988067564a0f04ae0430ef44a16449834 --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/build/types/other_prime_info.d.ts @@ -0,0 +1,24 @@ +import { AsnArray } from "@peculiar/asn1-schema"; +/** + * ```asn1 + * OtherPrimeInfo ::= SEQUENCE { + * prime INTEGER, -- ri + * exponent INTEGER, -- di + * coefficient INTEGER -- ti + * } + * ``` + */ +export declare class OtherPrimeInfo { + prime: ArrayBuffer; + exponent: ArrayBuffer; + coefficient: ArrayBuffer; + constructor(params?: Partial); +} +/** + * ```asn1 + * OtherPrimeInfos ::= SEQUENCE SIZE(1..MAX) OF OtherPrimeInfo + * ``` + */ +export declare class OtherPrimeInfos extends AsnArray { + constructor(items?: OtherPrimeInfo[]); +} diff --git a/node_modules/@peculiar/asn1-rsa/build/types/parameters/index.d.ts b/node_modules/@peculiar/asn1-rsa/build/types/parameters/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3d8e90e6b9f41defdb1fe1e3c8efa52d7817c4de --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/build/types/parameters/index.d.ts @@ -0,0 +1,3 @@ +export * from "./rsaes_oaep"; +export * from "./rsassa_pss"; +export * from "./rsassa_pkcs1_v1_5"; diff --git a/node_modules/@peculiar/asn1-rsa/build/types/parameters/rsaes_oaep.d.ts b/node_modules/@peculiar/asn1-rsa/build/types/parameters/rsaes_oaep.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7a8e99dcb9cd274fa17a0f5733559ba8f868ec29 --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/build/types/parameters/rsaes_oaep.d.ts @@ -0,0 +1,22 @@ +import { AlgorithmIdentifier } from "@peculiar/asn1-x509"; +/** + * ```asn1 + * RSAES-OAEP-params ::= SEQUENCE { + * hashAlgorithm [0] HashAlgorithm DEFAULT sha1, + * maskGenAlgorithm [1] MaskGenAlgorithm DEFAULT mgf1SHA1, + * pSourceAlgorithm [2] PSourceAlgorithm DEFAULT pSpecifiedEmpty + * } + * ``` + */ +export declare class RsaEsOaepParams { + hashAlgorithm: AlgorithmIdentifier; + maskGenAlgorithm: AlgorithmIdentifier; + pSourceAlgorithm: AlgorithmIdentifier; + constructor(params?: Partial); +} +/** + * ```asn1 + * { OID id-RSAES-OAEP PARAMETERS RSAES-OAEP-params } | + * ``` + */ +export declare const RSAES_OAEP: AlgorithmIdentifier; diff --git a/node_modules/@peculiar/asn1-rsa/build/types/parameters/rsassa_pkcs1_v1_5.d.ts b/node_modules/@peculiar/asn1-rsa/build/types/parameters/rsassa_pkcs1_v1_5.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..be5d632d1c54e9d330f1b9feedac5cede37a1c6d --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/build/types/parameters/rsassa_pkcs1_v1_5.d.ts @@ -0,0 +1,15 @@ +import { AlgorithmIdentifier } from "@peculiar/asn1-x509"; +import { OctetString } from "@peculiar/asn1-schema"; +/** + * ```asn1 + * DigestInfo ::= SEQUENCE { + * digestAlgorithm DigestAlgorithm, + * digest OCTET STRING + * } + * ``` + */ +export declare class DigestInfo { + digestAlgorithm: AlgorithmIdentifier; + digest: OctetString; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-rsa/build/types/parameters/rsassa_pss.d.ts b/node_modules/@peculiar/asn1-rsa/build/types/parameters/rsassa_pss.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3ab66d1430a9d61f3ab74e6428bf612cb7f86cf4 --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/build/types/parameters/rsassa_pss.d.ts @@ -0,0 +1,30 @@ +import { AlgorithmIdentifier } from "@peculiar/asn1-x509"; +/** + * ```asn1 + * TrailerField ::= INTEGER { trailerFieldBC(1) } + * ``` + */ +export type TrailerField = number; +/** + * ```asn1 + * RSASSA-PSS-params ::= SEQUENCE { + * hashAlgorithm [0] HashAlgorithm DEFAULT sha1, + * maskGenAlgorithm [1] MaskGenAlgorithm DEFAULT mgf1SHA1, + * saltLength [2] INTEGER DEFAULT 20, + * trailerField [3] TrailerField DEFAULT trailerFieldBC + * } + * ``` + */ +export declare class RsaSaPssParams { + hashAlgorithm: AlgorithmIdentifier; + maskGenAlgorithm: AlgorithmIdentifier; + saltLength: number; + trailerField: TrailerField; + constructor(params?: Partial); +} +/** + * ```asn1 + * { OID id-RSASSA-PSS PARAMETERS RSASSA-PSS-params } + * ``` + */ +export declare const RSASSA_PSS: AlgorithmIdentifier; diff --git a/node_modules/@peculiar/asn1-rsa/build/types/rsa_private_key.d.ts b/node_modules/@peculiar/asn1-rsa/build/types/rsa_private_key.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..26844c6b9b3f0ff900bc8092471d506e2eba4cd3 --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/build/types/rsa_private_key.d.ts @@ -0,0 +1,39 @@ +import { OtherPrimeInfos } from "./other_prime_info"; +/** + * ```asn1 + * Version ::= INTEGER { two-prime(0), multi(1) } + * (CONSTRAINED BY + * {-- version MUST + * be multi if otherPrimeInfos present --}) + * ``` + */ +export type Version = number; +/** + * ```asn1 + * RSAPrivateKey ::= SEQUENCE { + * version Version, + * modulus INTEGER, -- n + * publicExponent INTEGER, -- e + * privateExponent INTEGER, -- d + * prime1 INTEGER, -- p + * prime2 INTEGER, -- q + * exponent1 INTEGER, -- d mod (p-1) + * exponent2 INTEGER, -- d mod (q-1) + * coefficient INTEGER, -- (inverse of q) mod p + * otherPrimeInfos OtherPrimeInfos OPTIONAL + * } + * ``` + */ +export declare class RSAPrivateKey { + version: Version; + modulus: ArrayBuffer; + publicExponent: ArrayBuffer; + privateExponent: ArrayBuffer; + prime1: ArrayBuffer; + prime2: ArrayBuffer; + exponent1: ArrayBuffer; + exponent2: ArrayBuffer; + coefficient: ArrayBuffer; + otherPrimeInfos?: OtherPrimeInfos; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-rsa/build/types/rsa_public_key.d.ts b/node_modules/@peculiar/asn1-rsa/build/types/rsa_public_key.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3a6ea9939b44a52b0e56aaf68146f1a58a74ba87 --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/build/types/rsa_public_key.d.ts @@ -0,0 +1,13 @@ +/** + * ```asn1 + * RSAPublicKey ::= SEQUENCE { + * modulus INTEGER, -- n + * publicExponent INTEGER -- e + * } + * ``` + */ +export declare class RSAPublicKey { + modulus: ArrayBuffer; + publicExponent: ArrayBuffer; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-rsa/package.json b/node_modules/@peculiar/asn1-rsa/package.json new file mode 100644 index 0000000000000000000000000000000000000000..2a19742dfff05739212c06daf64b51517a9cdaa7 --- /dev/null +++ b/node_modules/@peculiar/asn1-rsa/package.json @@ -0,0 +1,61 @@ +{ + "name": "@peculiar/asn1-rsa", + "version": "2.8.0", + "description": "ASN.1 schema for RSA keys and algorithms defined in RFC 8017.", + "keywords": [ + "asn", + "asn1", + "rsa", + "public-key", + "private-key", + "rfc8017" + ], + "author": "PeculiarVentures, LLC", + "license": "MIT", + "files": [ + "build/**/*.{js,d.ts}", + "build/es2015/package.json", + "LICENSE", + "README.md" + ], + "main": "build/cjs/index.js", + "module": "build/es2015/index.js", + "types": "build/types/index.d.ts", + "exports": { + ".": { + "types": "./build/types/index.d.ts", + "import": "./build/es2015/index.js", + "require": "./build/cjs/index.js" + }, + "./package.json": "./package.json" + }, + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "https://github.com/PeculiarVentures/asn1-schema", + "directory": "packages/rsa" + }, + "bugs": { + "url": "https://github.com/PeculiarVentures/asn1-schema/issues" + }, + "homepage": "https://github.com/PeculiarVentures/asn1-schema/tree/master/packages/rsa#readme", + "scripts": { + "clear": "rimraf build", + "build": "npm run build:module && npm run build:types", + "build:module": "npm run build:cjs && npm run build:es2015", + "build:cjs": "tsc -p tsconfig.compile.json --removeComments --module commonjs --outDir build/cjs", + "build:es2015": "tsc -p tsconfig.compile.json --removeComments --module ES2015 --outDir build/es2015", + "postbuild:es2015": "node ../../scripts/prepare_esm_package.mjs build/es2015", + "prebuild:types": "rimraf build/types", + "build:types": "tsc -p tsconfig.compile.json --outDir build/types --declaration --emitDeclarationOnly", + "rebuild": "npm run clear && npm run build" + }, + "dependencies": { + "@peculiar/asn1-schema": "^2.8.0", + "@peculiar/asn1-x509": "^2.8.0", + "asn1js": "^3.0.10", + "tslib": "^2.8.1" + } +} diff --git a/node_modules/@peculiar/asn1-schema/LICENSE b/node_modules/@peculiar/asn1-schema/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..6f9ec1352ea499d3f26a898c37ea4a0cd2a740fb --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@peculiar/asn1-schema/README.md b/node_modules/@peculiar/asn1-schema/README.md new file mode 100644 index 0000000000000000000000000000000000000000..c19c9778beade838fcc65c7e64fe04a5d2c7d1f1 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/README.md @@ -0,0 +1,51 @@ +# `@peculiar/asn1-schema` + +[![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/PeculiarVentures/asn1-schema/blob/master/packages/schema/LICENSE) +[![npm version](https://badge.fury.io/js/%40peculiar%2Fasn1-schema.svg)](https://badge.fury.io/js/%40peculiar%2Fasn1-schema) + +[![NPM](https://nodei.co/npm/@peculiar/asn1-schema.png)](https://nodei.co/npm/@peculiar/asn1-schema/) + +Decorators and helper APIs for declaring ASN.1 schemas in TypeScript. + +This is the core package used by the schema modules in this repository. It lets you describe DER structures with decorators and convert them with `AsnConvert`, `AsnParser`, and `AsnSerializer`. + +## Installation + +```bash +npm install @peculiar/asn1-schema +``` + +## Overview + +Abstract Syntax Notation One (ASN.1) is widely used across X.509, PKCS, CMS, OCSP, and related standards. This package keeps those mappings declarative and type-friendly by attaching schema metadata directly to classes. + +## TypeScript Example + +```ts +import { + AsnConvert, + AsnProp, + AsnPropTypes, + AsnType, + AsnTypeTypes, +} from "@peculiar/asn1-schema"; + +@AsnType({ type: AsnTypeTypes.Sequence }) +class BasicConstraints { + @AsnProp({ type: AsnPropTypes.Boolean, defaultValue: false }) + public cA = false; +} + +const basicConstraints = new BasicConstraints(); +basicConstraints.cA = true; + +const encoded = AsnConvert.serialize(basicConstraints); +const decoded = AsnConvert.parse(encoded, BasicConstraints); + +console.log(decoded.cA); +``` + +## Related Links + +- [Decorators overview](https://medium.com/google-developers/exploring-es7-decorators-76ecb65fb841) +- [ASN.1 playground](http://lapo.it/asn1js/) diff --git a/node_modules/@peculiar/asn1-schema/build/cjs/convert.js b/node_modules/@peculiar/asn1-schema/build/cjs/convert.js new file mode 100644 index 0000000000000000000000000000000000000000..b8ad96ee31eda77c53ea5e484903ad9b268d1a83 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/cjs/convert.js @@ -0,0 +1,27 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AsnConvert = void 0; +const tslib_1 = require("tslib"); +const asn1js = tslib_1.__importStar(require("asn1js")); +const bytes_1 = require("@peculiar/utils/bytes"); +const parser_1 = require("./parser"); +const serializer_1 = require("./serializer"); +class AsnConvert { + static serialize(obj) { + return serializer_1.AsnSerializer.serialize(obj); + } + static parse(data, target, options) { + return parser_1.AsnParser.parse(data, target, options); + } + static toString(data, options) { + const buf = (0, bytes_1.isBufferSource)(data) + ? (0, bytes_1.toArrayBuffer)(data) + : AsnConvert.serialize(data); + const asn = asn1js.fromBER(buf, options?.berOptions); + if (asn.offset === -1) { + throw new Error(`Cannot decode ASN.1 data. ${asn.result.error}`); + } + return asn.result.toString(); + } +} +exports.AsnConvert = AsnConvert; diff --git a/node_modules/@peculiar/asn1-schema/build/cjs/converters.js b/node_modules/@peculiar/asn1-schema/build/cjs/converters.js new file mode 100644 index 0000000000000000000000000000000000000000..ff8abcf34ae4f15f42d4e5ab43b5b9662cc1bbd6 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/cjs/converters.js @@ -0,0 +1,144 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AsnNullConverter = exports.AsnGeneralizedTimeConverter = exports.AsnUTCTimeConverter = exports.AsnCharacterStringConverter = exports.AsnGeneralStringConverter = exports.AsnVisibleStringConverter = exports.AsnGraphicStringConverter = exports.AsnIA5StringConverter = exports.AsnVideotexStringConverter = exports.AsnTeletexStringConverter = exports.AsnPrintableStringConverter = exports.AsnNumericStringConverter = exports.AsnUniversalStringConverter = exports.AsnBmpStringConverter = exports.AsnUtf8StringConverter = exports.AsnConstructedOctetStringConverter = exports.AsnOctetStringConverter = exports.AsnBooleanConverter = exports.AsnObjectIdentifierConverter = exports.AsnBitStringConverter = exports.AsnIntegerBigIntConverter = exports.AsnIntegerArrayBufferConverter = exports.AsnEnumeratedConverter = exports.AsnIntegerConverter = exports.AsnAnyConverter = void 0; +exports.defaultConverter = defaultConverter; +const tslib_1 = require("tslib"); +const asn1js = tslib_1.__importStar(require("asn1js")); +const bytes_1 = require("@peculiar/utils/bytes"); +const enums_1 = require("./enums"); +const index_1 = require("./types/index"); +exports.AsnAnyConverter = { + fromASN: (value) => value instanceof asn1js.Null + ? null + : (0, bytes_1.toArrayBuffer)(value.valueBeforeDecodeView), + toASN: (value) => { + if (value === null) { + return new asn1js.Null(); + } + const schema = asn1js.fromBER(value); + if (schema.result.error) { + throw new Error(schema.result.error); + } + return schema.result; + }, +}; +exports.AsnIntegerConverter = { + fromASN: (value) => value.valueBlock.valueHexView.byteLength >= 4 + ? value.valueBlock.toString() + : value.valueBlock.valueDec, + toASN: (value) => new asn1js.Integer({ value: +value }), +}; +exports.AsnEnumeratedConverter = { + fromASN: (value) => value.valueBlock.valueDec, + toASN: (value) => new asn1js.Enumerated({ value }), +}; +exports.AsnIntegerArrayBufferConverter = { + fromASN: (value) => (0, bytes_1.toArrayBuffer)(value.valueBlock.valueHexView), + toASN: (value) => new asn1js.Integer({ valueHex: value }), +}; +exports.AsnIntegerBigIntConverter = { + fromASN: (value) => value.toBigInt(), + toASN: (value) => asn1js.Integer.fromBigInt(value), +}; +exports.AsnBitStringConverter = { + fromASN: (value) => (0, bytes_1.toArrayBuffer)(value.valueBlock.valueHexView), + toASN: (value) => new asn1js.BitString({ valueHex: value }), +}; +exports.AsnObjectIdentifierConverter = { + fromASN: (value) => value.valueBlock.toString(), + toASN: (value) => new asn1js.ObjectIdentifier({ value }), +}; +exports.AsnBooleanConverter = { + fromASN: (value) => value.valueBlock.value, + toASN: (value) => new asn1js.Boolean({ value }), +}; +exports.AsnOctetStringConverter = { + fromASN: (value) => (0, bytes_1.toArrayBuffer)(value.valueBlock.valueHexView), + toASN: (value) => new asn1js.OctetString({ valueHex: value }), +}; +exports.AsnConstructedOctetStringConverter = { + fromASN: (value) => new index_1.OctetString(value.getValue()), + toASN: (value) => value.toASN(), +}; +function createStringConverter(Asn1Type) { + return { + fromASN: (value) => value.valueBlock.value, + toASN: (value) => new Asn1Type({ value }), + }; +} +exports.AsnUtf8StringConverter = createStringConverter(asn1js.Utf8String); +exports.AsnBmpStringConverter = createStringConverter(asn1js.BmpString); +exports.AsnUniversalStringConverter = createStringConverter(asn1js.UniversalString); +exports.AsnNumericStringConverter = createStringConverter(asn1js.NumericString); +exports.AsnPrintableStringConverter = createStringConverter(asn1js.PrintableString); +exports.AsnTeletexStringConverter = createStringConverter(asn1js.TeletexString); +exports.AsnVideotexStringConverter = createStringConverter(asn1js.VideotexString); +exports.AsnIA5StringConverter = createStringConverter(asn1js.IA5String); +exports.AsnGraphicStringConverter = createStringConverter(asn1js.GraphicString); +exports.AsnVisibleStringConverter = createStringConverter(asn1js.VisibleString); +exports.AsnGeneralStringConverter = createStringConverter(asn1js.GeneralString); +exports.AsnCharacterStringConverter = createStringConverter(asn1js.CharacterString); +exports.AsnUTCTimeConverter = { + fromASN: (value) => value.toDate(), + toASN: (value) => new asn1js.UTCTime({ valueDate: value }), +}; +exports.AsnGeneralizedTimeConverter = { + fromASN: (value) => value.toDate(), + toASN: (value) => new asn1js.GeneralizedTime({ valueDate: value }), +}; +exports.AsnNullConverter = { + fromASN: () => null, + toASN: () => { + return new asn1js.Null(); + }, +}; +function defaultConverter(type) { + switch (type) { + case enums_1.AsnPropTypes.Any: + return exports.AsnAnyConverter; + case enums_1.AsnPropTypes.BitString: + return exports.AsnBitStringConverter; + case enums_1.AsnPropTypes.BmpString: + return exports.AsnBmpStringConverter; + case enums_1.AsnPropTypes.Boolean: + return exports.AsnBooleanConverter; + case enums_1.AsnPropTypes.CharacterString: + return exports.AsnCharacterStringConverter; + case enums_1.AsnPropTypes.Enumerated: + return exports.AsnEnumeratedConverter; + case enums_1.AsnPropTypes.GeneralString: + return exports.AsnGeneralStringConverter; + case enums_1.AsnPropTypes.GeneralizedTime: + return exports.AsnGeneralizedTimeConverter; + case enums_1.AsnPropTypes.GraphicString: + return exports.AsnGraphicStringConverter; + case enums_1.AsnPropTypes.IA5String: + return exports.AsnIA5StringConverter; + case enums_1.AsnPropTypes.Integer: + return exports.AsnIntegerConverter; + case enums_1.AsnPropTypes.Null: + return exports.AsnNullConverter; + case enums_1.AsnPropTypes.NumericString: + return exports.AsnNumericStringConverter; + case enums_1.AsnPropTypes.ObjectIdentifier: + return exports.AsnObjectIdentifierConverter; + case enums_1.AsnPropTypes.OctetString: + return exports.AsnOctetStringConverter; + case enums_1.AsnPropTypes.PrintableString: + return exports.AsnPrintableStringConverter; + case enums_1.AsnPropTypes.TeletexString: + return exports.AsnTeletexStringConverter; + case enums_1.AsnPropTypes.UTCTime: + return exports.AsnUTCTimeConverter; + case enums_1.AsnPropTypes.UniversalString: + return exports.AsnUniversalStringConverter; + case enums_1.AsnPropTypes.Utf8String: + return exports.AsnUtf8StringConverter; + case enums_1.AsnPropTypes.VideotexString: + return exports.AsnVideotexStringConverter; + case enums_1.AsnPropTypes.VisibleString: + return exports.AsnVisibleStringConverter; + default: + return null; + } +} diff --git a/node_modules/@peculiar/asn1-schema/build/cjs/decorators.js b/node_modules/@peculiar/asn1-schema/build/cjs/decorators.js new file mode 100644 index 0000000000000000000000000000000000000000..e731cd73ab9b39a826532d66b752a254d3589a0e --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/cjs/decorators.js @@ -0,0 +1,50 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AsnProp = exports.AsnSequenceType = exports.AsnSetType = exports.AsnChoiceType = exports.AsnType = void 0; +const tslib_1 = require("tslib"); +const converters = tslib_1.__importStar(require("./converters")); +const enums_1 = require("./enums"); +const storage_1 = require("./storage"); +const AsnType = (options) => (target) => { + let schema; + if (!storage_1.schemaStorage.has(target)) { + schema = storage_1.schemaStorage.createDefault(target); + storage_1.schemaStorage.set(target, schema); + } + else { + schema = storage_1.schemaStorage.get(target); + } + Object.assign(schema, options); +}; +exports.AsnType = AsnType; +const AsnChoiceType = () => (0, exports.AsnType)({ type: enums_1.AsnTypeTypes.Choice }); +exports.AsnChoiceType = AsnChoiceType; +const AsnSetType = (options) => (0, exports.AsnType)({ + type: enums_1.AsnTypeTypes.Set, ...options, +}); +exports.AsnSetType = AsnSetType; +const AsnSequenceType = (options) => (0, exports.AsnType)({ + type: enums_1.AsnTypeTypes.Sequence, ...options, +}); +exports.AsnSequenceType = AsnSequenceType; +const AsnProp = (options) => (target, propertyKey) => { + let schema; + if (!storage_1.schemaStorage.has(target.constructor)) { + schema = storage_1.schemaStorage.createDefault(target.constructor); + storage_1.schemaStorage.set(target.constructor, schema); + } + else { + schema = storage_1.schemaStorage.get(target.constructor); + } + const copyOptions = Object.assign({}, options); + if (typeof copyOptions.type === "number" && !copyOptions.converter) { + const defaultConverter = converters.defaultConverter(options.type); + if (!defaultConverter) { + throw new Error(`Cannot get default converter for property '${propertyKey}' of ${target.constructor.name}`); + } + copyOptions.converter = defaultConverter; + } + copyOptions.raw = options.raw; + schema.items[propertyKey] = copyOptions; +}; +exports.AsnProp = AsnProp; diff --git a/node_modules/@peculiar/asn1-schema/build/cjs/enums.js b/node_modules/@peculiar/asn1-schema/build/cjs/enums.js new file mode 100644 index 0000000000000000000000000000000000000000..f9ba8eb38b2c38b415772a1da59b82106d31e484 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/cjs/enums.js @@ -0,0 +1,39 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AsnPropTypes = exports.AsnTypeTypes = void 0; +var AsnTypeTypes; +(function (AsnTypeTypes) { + AsnTypeTypes[AsnTypeTypes["Sequence"] = 0] = "Sequence"; + AsnTypeTypes[AsnTypeTypes["Set"] = 1] = "Set"; + AsnTypeTypes[AsnTypeTypes["Choice"] = 2] = "Choice"; +})(AsnTypeTypes || (exports.AsnTypeTypes = AsnTypeTypes = {})); +var AsnPropTypes; +(function (AsnPropTypes) { + AsnPropTypes[AsnPropTypes["Any"] = 1] = "Any"; + AsnPropTypes[AsnPropTypes["Boolean"] = 2] = "Boolean"; + AsnPropTypes[AsnPropTypes["OctetString"] = 3] = "OctetString"; + AsnPropTypes[AsnPropTypes["BitString"] = 4] = "BitString"; + AsnPropTypes[AsnPropTypes["Integer"] = 5] = "Integer"; + AsnPropTypes[AsnPropTypes["Enumerated"] = 6] = "Enumerated"; + AsnPropTypes[AsnPropTypes["ObjectIdentifier"] = 7] = "ObjectIdentifier"; + AsnPropTypes[AsnPropTypes["Utf8String"] = 8] = "Utf8String"; + AsnPropTypes[AsnPropTypes["BmpString"] = 9] = "BmpString"; + AsnPropTypes[AsnPropTypes["UniversalString"] = 10] = "UniversalString"; + AsnPropTypes[AsnPropTypes["NumericString"] = 11] = "NumericString"; + AsnPropTypes[AsnPropTypes["PrintableString"] = 12] = "PrintableString"; + AsnPropTypes[AsnPropTypes["TeletexString"] = 13] = "TeletexString"; + AsnPropTypes[AsnPropTypes["VideotexString"] = 14] = "VideotexString"; + AsnPropTypes[AsnPropTypes["IA5String"] = 15] = "IA5String"; + AsnPropTypes[AsnPropTypes["GraphicString"] = 16] = "GraphicString"; + AsnPropTypes[AsnPropTypes["VisibleString"] = 17] = "VisibleString"; + AsnPropTypes[AsnPropTypes["GeneralString"] = 18] = "GeneralString"; + AsnPropTypes[AsnPropTypes["CharacterString"] = 19] = "CharacterString"; + AsnPropTypes[AsnPropTypes["UTCTime"] = 20] = "UTCTime"; + AsnPropTypes[AsnPropTypes["GeneralizedTime"] = 21] = "GeneralizedTime"; + AsnPropTypes[AsnPropTypes["DATE"] = 22] = "DATE"; + AsnPropTypes[AsnPropTypes["TimeOfDay"] = 23] = "TimeOfDay"; + AsnPropTypes[AsnPropTypes["DateTime"] = 24] = "DateTime"; + AsnPropTypes[AsnPropTypes["Duration"] = 25] = "Duration"; + AsnPropTypes[AsnPropTypes["TIME"] = 26] = "TIME"; + AsnPropTypes[AsnPropTypes["Null"] = 27] = "Null"; +})(AsnPropTypes || (exports.AsnPropTypes = AsnPropTypes = {})); diff --git a/node_modules/@peculiar/asn1-schema/build/cjs/errors/index.js b/node_modules/@peculiar/asn1-schema/build/cjs/errors/index.js new file mode 100644 index 0000000000000000000000000000000000000000..63a58bb934a422bca2b2258cf2ba7f5c154f7c57 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/cjs/errors/index.js @@ -0,0 +1,4 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +tslib_1.__exportStar(require("./schema_validation"), exports); diff --git a/node_modules/@peculiar/asn1-schema/build/cjs/errors/schema_validation.js b/node_modules/@peculiar/asn1-schema/build/cjs/errors/schema_validation.js new file mode 100644 index 0000000000000000000000000000000000000000..4ca0ed377a9553a926d78d1d799a193c30b3aa6a --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/cjs/errors/schema_validation.js @@ -0,0 +1,7 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AsnSchemaValidationError = void 0; +class AsnSchemaValidationError extends Error { + schemas = []; +} +exports.AsnSchemaValidationError = AsnSchemaValidationError; diff --git a/node_modules/@peculiar/asn1-schema/build/cjs/helper.js b/node_modules/@peculiar/asn1-schema/build/cjs/helper.js new file mode 100644 index 0000000000000000000000000000000000000000..bcc2f82878f4e0605f4aba3d69d263d5763d07a5 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/cjs/helper.js @@ -0,0 +1,44 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.isConvertible = isConvertible; +exports.isTypeOfArray = isTypeOfArray; +exports.isArrayEqual = isArrayEqual; +function isConvertible(target) { + if (typeof target === "function" && target.prototype) { + if (target.prototype.toASN && target.prototype.fromASN) { + return true; + } + else { + return isConvertible(target.prototype); + } + } + else { + return !!(target && typeof target === "object" && "toASN" in target && "fromASN" in target); + } +} +function isTypeOfArray(target) { + if (target) { + const proto = Object.getPrototypeOf(target); + if (proto?.prototype?.constructor === Array) { + return true; + } + return isTypeOfArray(proto); + } + return false; +} +function isArrayEqual(bytes1, bytes2) { + if (!(bytes1 && bytes2)) { + return false; + } + if (bytes1.byteLength !== bytes2.byteLength) { + return false; + } + const b1 = new Uint8Array(bytes1); + const b2 = new Uint8Array(bytes2); + for (let i = 0; i < bytes1.byteLength; i++) { + if (b1[i] !== b2[i]) { + return false; + } + } + return true; +} diff --git a/node_modules/@peculiar/asn1-schema/build/cjs/index.js b/node_modules/@peculiar/asn1-schema/build/cjs/index.js new file mode 100644 index 0000000000000000000000000000000000000000..9a04496c1aaf30a5334da9296b27dc5614e5aba7 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/cjs/index.js @@ -0,0 +1,22 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AsnSerializer = exports.AsnParser = exports.AsnPropTypes = exports.AsnTypeTypes = exports.AsnSetType = exports.AsnSequenceType = exports.AsnChoiceType = exports.AsnType = exports.AsnProp = void 0; +const tslib_1 = require("tslib"); +tslib_1.__exportStar(require("./converters"), exports); +tslib_1.__exportStar(require("./types/index"), exports); +var decorators_1 = require("./decorators"); +Object.defineProperty(exports, "AsnProp", { enumerable: true, get: function () { return decorators_1.AsnProp; } }); +Object.defineProperty(exports, "AsnType", { enumerable: true, get: function () { return decorators_1.AsnType; } }); +Object.defineProperty(exports, "AsnChoiceType", { enumerable: true, get: function () { return decorators_1.AsnChoiceType; } }); +Object.defineProperty(exports, "AsnSequenceType", { enumerable: true, get: function () { return decorators_1.AsnSequenceType; } }); +Object.defineProperty(exports, "AsnSetType", { enumerable: true, get: function () { return decorators_1.AsnSetType; } }); +var enums_1 = require("./enums"); +Object.defineProperty(exports, "AsnTypeTypes", { enumerable: true, get: function () { return enums_1.AsnTypeTypes; } }); +Object.defineProperty(exports, "AsnPropTypes", { enumerable: true, get: function () { return enums_1.AsnPropTypes; } }); +var parser_1 = require("./parser"); +Object.defineProperty(exports, "AsnParser", { enumerable: true, get: function () { return parser_1.AsnParser; } }); +var serializer_1 = require("./serializer"); +Object.defineProperty(exports, "AsnSerializer", { enumerable: true, get: function () { return serializer_1.AsnSerializer; } }); +tslib_1.__exportStar(require("./errors"), exports); +tslib_1.__exportStar(require("./objects"), exports); +tslib_1.__exportStar(require("./convert"), exports); diff --git a/node_modules/@peculiar/asn1-schema/build/cjs/objects.js b/node_modules/@peculiar/asn1-schema/build/cjs/objects.js new file mode 100644 index 0000000000000000000000000000000000000000..a787c28326ac6c7f4aee1f68864d1b39b94aaa27 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/cjs/objects.js @@ -0,0 +1,17 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AsnArray = void 0; +class AsnArray extends Array { + constructor(items = []) { + if (typeof items === "number") { + super(items); + } + else { + super(); + for (const item of items) { + this.push(item); + } + } + } +} +exports.AsnArray = AsnArray; diff --git a/node_modules/@peculiar/asn1-schema/build/cjs/parser.js b/node_modules/@peculiar/asn1-schema/build/cjs/parser.js new file mode 100644 index 0000000000000000000000000000000000000000..b922ef97fe381b4c96e7c745d0093e45c01abe05 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/cjs/parser.js @@ -0,0 +1,331 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AsnParser = void 0; +const tslib_1 = require("tslib"); +const asn1js = tslib_1.__importStar(require("asn1js")); +const bytes_1 = require("@peculiar/utils/bytes"); +const enums_1 = require("./enums"); +const converters = tslib_1.__importStar(require("./converters")); +const errors_1 = require("./errors"); +const helper_1 = require("./helper"); +const storage_1 = require("./storage"); +class AsnParser { + static parse(data, target, options) { + const asn1Parsed = asn1js.fromBER((0, bytes_1.toArrayBuffer)(data), options?.berOptions); + if (asn1Parsed.result.error) { + throw new Error(asn1Parsed.result.error); + } + const res = this.fromASN(asn1Parsed.result, target, options); + return res; + } + static fromASN(asn1Schema, target, options) { + try { + if ((0, helper_1.isConvertible)(target)) { + const value = new target(); + return value.fromASN(asn1Schema); + } + const schema = storage_1.schemaStorage.get(target); + storage_1.schemaStorage.cache(target); + let targetSchema = schema.schema; + const choiceResult = this.handleChoiceTypes(asn1Schema, schema, target, targetSchema, options); + if (choiceResult?.result) { + return choiceResult.result; + } + if (choiceResult?.targetSchema) { + targetSchema = choiceResult.targetSchema; + } + const sequenceResult = this.handleSequenceTypes(asn1Schema, schema, target, targetSchema); + const res = new target(); + if ((0, helper_1.isTypeOfArray)(target)) { + return this.handleArrayTypes(asn1Schema, schema, target, options); + } + this.processSchemaItems(schema, sequenceResult, res, options); + return res; + } + catch (error) { + if (error instanceof errors_1.AsnSchemaValidationError) { + error.schemas.push(target.name); + } + throw error; + } + } + static handleChoiceTypes(asn1Schema, schema, target, targetSchema, options) { + if (asn1Schema.constructor === asn1js.Constructed + && schema.type === enums_1.AsnTypeTypes.Choice + && asn1Schema.idBlock.tagClass === 3) { + for (const key in schema.items) { + const schemaItem = schema.items[key]; + if (schemaItem.context === asn1Schema.idBlock.tagNumber && schemaItem.implicit) { + if (typeof schemaItem.type === "function" + && storage_1.schemaStorage.has(schemaItem.type)) { + const fieldSchema = storage_1.schemaStorage.get(schemaItem.type); + if (fieldSchema && fieldSchema.type === enums_1.AsnTypeTypes.Sequence) { + const newSeq = new asn1js.Sequence(); + if ("value" in asn1Schema.valueBlock + && Array.isArray(asn1Schema.valueBlock.value) + && "value" in newSeq.valueBlock) { + newSeq.valueBlock.value = asn1Schema.valueBlock.value; + const fieldValue = this.fromASN(newSeq, schemaItem.type, options); + const res = new target(); + res[key] = fieldValue; + return { result: res }; + } + } + } + } + } + } + else if (asn1Schema.constructor === asn1js.Constructed + && schema.type !== enums_1.AsnTypeTypes.Choice) { + const newTargetSchema = new asn1js.Constructed({ + idBlock: { + tagClass: 3, + tagNumber: asn1Schema.idBlock.tagNumber, + }, + value: schema.schema.valueBlock.value, + }); + for (const key in schema.items) { + delete asn1Schema[key]; + } + return { targetSchema: newTargetSchema }; + } + return null; + } + static handleSequenceTypes(asn1Schema, schema, target, targetSchema) { + if (schema.type === enums_1.AsnTypeTypes.Sequence) { + const asn1ComparedSchema = asn1js.compareSchema({}, asn1Schema, targetSchema); + if (!asn1ComparedSchema.verified) { + throw new errors_1.AsnSchemaValidationError(`Data does not match to ${target.name} ASN1 schema.${asn1ComparedSchema.result.error ? ` ${asn1ComparedSchema.result.error}` : ""}`); + } + return asn1ComparedSchema; + } + else { + const asn1ComparedSchema = asn1js.compareSchema({}, asn1Schema, targetSchema); + if (!asn1ComparedSchema.verified) { + throw new errors_1.AsnSchemaValidationError(`Data does not match to ${target.name} ASN1 schema.${asn1ComparedSchema.result.error ? ` ${asn1ComparedSchema.result.error}` : ""}`); + } + return asn1ComparedSchema; + } + } + static processRepeatedField(asn1Elements, asn1Index, schemaItem) { + let elementsToProcess = asn1Elements.slice(asn1Index); + if (elementsToProcess.length === 1 && elementsToProcess[0].constructor.name === "Sequence") { + const seq = elementsToProcess[0]; + if (seq.valueBlock && seq.valueBlock.value && Array.isArray(seq.valueBlock.value)) { + elementsToProcess = seq.valueBlock.value; + } + } + if (typeof schemaItem.type === "number") { + const converter = converters.defaultConverter(schemaItem.type); + if (!converter) + throw new Error(`No converter for ASN.1 type ${schemaItem.type}`); + return elementsToProcess + .filter((el) => el && el.valueBlock) + .map((el) => { + try { + return converter.fromASN(el); + } + catch { + return undefined; + } + }) + .filter((v) => v !== undefined); + } + else { + return elementsToProcess + .filter((el) => el && el.valueBlock) + .map((el) => { + try { + return this.fromASN(el, schemaItem.type); + } + catch { + return undefined; + } + }) + .filter((v) => v !== undefined); + } + } + static processPrimitiveField(asn1Element, schemaItem) { + const converter = converters.defaultConverter(schemaItem.type); + if (!converter) + throw new Error(`No converter for ASN.1 type ${schemaItem.type}`); + return converter.fromASN(asn1Element); + } + static isOptionalChoiceField(schemaItem) { + return (schemaItem.optional + && typeof schemaItem.type === "function" + && storage_1.schemaStorage.has(schemaItem.type) + && storage_1.schemaStorage.get(schemaItem.type).type === enums_1.AsnTypeTypes.Choice); + } + static processOptionalChoiceField(asn1Element, schemaItem) { + try { + const value = this.fromASN(asn1Element, schemaItem.type); + return { + processed: true, value, + }; + } + catch (err) { + if (err instanceof errors_1.AsnSchemaValidationError + && /Wrong values for Choice type/.test(err.message)) { + return { processed: false }; + } + throw err; + } + } + static handleArrayTypes(asn1Schema, schema, target, options) { + if (!("value" in asn1Schema.valueBlock && Array.isArray(asn1Schema.valueBlock.value))) { + throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed."); + } + const itemType = schema.itemType; + if (typeof itemType === "number") { + const converter = converters.defaultConverter(itemType); + if (!converter) { + throw new Error(`Cannot get default converter for array item of ${target.name} ASN1 schema`); + } + return target.from(asn1Schema.valueBlock.value, (element) => converter.fromASN(element)); + } + else { + return target.from(asn1Schema.valueBlock.value, (element) => this.fromASN(element, itemType, options)); + } + } + static processSchemaItems(schema, asn1ComparedSchema, res, options) { + for (const key in schema.items) { + const asn1SchemaValue = asn1ComparedSchema.result[key]; + if (!asn1SchemaValue) { + continue; + } + const schemaItem = schema.items[key]; + const schemaItemType = schemaItem.type; + let parsedValue; + if (typeof schemaItemType === "number" || (0, helper_1.isConvertible)(schemaItemType)) { + parsedValue = this.processPrimitiveSchemaItem(asn1SchemaValue, schemaItem, schemaItemType, options); + } + else { + parsedValue = this.processComplexSchemaItem(asn1SchemaValue, schemaItem, schemaItemType, options); + } + if (parsedValue + && typeof parsedValue === "object" + && "value" in parsedValue + && "raw" in parsedValue) { + res[key] = parsedValue.value; + res[`${key}Raw`] = parsedValue.raw; + } + else { + res[key] = parsedValue; + } + } + } + static processPrimitiveSchemaItem(asn1SchemaValue, schemaItem, schemaItemType, options) { + const converter = schemaItem.converter + ?? ((0, helper_1.isConvertible)(schemaItemType) + ? new schemaItemType() + : null); + if (!converter) { + throw new Error("Converter is empty"); + } + if (schemaItem.repeated) { + return this.processRepeatedPrimitiveItem(asn1SchemaValue, schemaItem, converter, options); + } + else { + return this.processSinglePrimitiveItem(asn1SchemaValue, schemaItem, schemaItemType, converter, options); + } + } + static processRepeatedPrimitiveItem(asn1SchemaValue, schemaItem, converter, options) { + if (schemaItem.implicit) { + const Container = schemaItem.repeated === "sequence" ? asn1js.Sequence : asn1js.Set; + const newItem = new Container(); + newItem.valueBlock = asn1SchemaValue.valueBlock; + const newItemAsn = asn1js.fromBER(newItem.toBER(false), options?.berOptions); + if (newItemAsn.offset === -1) { + throw new Error(`Cannot parse the child item. ${newItemAsn.result.error}`); + } + if (!("value" in newItemAsn.result.valueBlock + && Array.isArray(newItemAsn.result.valueBlock.value))) { + throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed."); + } + const value = newItemAsn.result.valueBlock.value; + return Array.from(value, (element) => converter.fromASN(element)); + } + else { + return Array.from(asn1SchemaValue, (element) => converter.fromASN(element)); + } + } + static processSinglePrimitiveItem(asn1SchemaValue, schemaItem, schemaItemType, converter, options) { + let value = asn1SchemaValue; + if (schemaItem.implicit) { + let newItem; + if ((0, helper_1.isConvertible)(schemaItemType)) { + newItem = new schemaItemType().toSchema(""); + } + else { + const Asn1TypeName = enums_1.AsnPropTypes[schemaItemType]; + const Asn1Type = asn1js[Asn1TypeName]; + if (!Asn1Type) { + throw new Error(`Cannot get '${Asn1TypeName}' class from asn1js module`); + } + newItem = new Asn1Type(); + } + newItem.valueBlock = value.valueBlock; + value = asn1js.fromBER(newItem.toBER(false), options?.berOptions).result; + } + return converter.fromASN(value); + } + static processComplexSchemaItem(asn1SchemaValue, schemaItem, schemaItemType, options) { + if (schemaItem.repeated) { + if (!Array.isArray(asn1SchemaValue)) { + throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable."); + } + return Array.from(asn1SchemaValue, (element) => this.fromASN(element, schemaItemType, options)); + } + else { + const valueToProcess = this.handleImplicitTagging(asn1SchemaValue, schemaItem, schemaItemType); + if (this.isOptionalChoiceField(schemaItem)) { + try { + return this.fromASN(valueToProcess, schemaItemType, options); + } + catch (err) { + if (err instanceof errors_1.AsnSchemaValidationError + && /Wrong values for Choice type/.test(err.message)) { + return undefined; + } + throw err; + } + } + else { + const parsedValue = this.fromASN(valueToProcess, schemaItemType, options); + if (schemaItem.raw) { + return { + value: parsedValue, + raw: asn1SchemaValue.valueBeforeDecodeView, + }; + } + return parsedValue; + } + } + } + static handleImplicitTagging(asn1SchemaValue, schemaItem, schemaItemType) { + if (schemaItem.implicit && typeof schemaItem.context === "number") { + const schema = storage_1.schemaStorage.get(schemaItemType); + if (schema.type === enums_1.AsnTypeTypes.Sequence) { + const newSeq = new asn1js.Sequence(); + if ("value" in asn1SchemaValue.valueBlock + && Array.isArray(asn1SchemaValue.valueBlock.value) + && "value" in newSeq.valueBlock) { + newSeq.valueBlock.value = asn1SchemaValue.valueBlock.value; + return newSeq; + } + } + else if (schema.type === enums_1.AsnTypeTypes.Set) { + const newSet = new asn1js.Set(); + if ("value" in asn1SchemaValue.valueBlock + && Array.isArray(asn1SchemaValue.valueBlock.value) + && "value" in newSet.valueBlock) { + newSet.valueBlock.value = asn1SchemaValue.valueBlock.value; + return newSet; + } + } + } + return asn1SchemaValue; + } +} +exports.AsnParser = AsnParser; diff --git a/node_modules/@peculiar/asn1-schema/build/cjs/schema.js b/node_modules/@peculiar/asn1-schema/build/cjs/schema.js new file mode 100644 index 0000000000000000000000000000000000000000..e017d2762b20a61fff5e7c574d4f73467a9a33a6 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/cjs/schema.js @@ -0,0 +1,156 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AsnSchemaStorage = void 0; +const tslib_1 = require("tslib"); +const asn1js = tslib_1.__importStar(require("asn1js")); +const enums_1 = require("./enums"); +const helper_1 = require("./helper"); +class AsnSchemaStorage { + items = new WeakMap(); + has(target) { + return this.items.has(target); + } + get(target, checkSchema = false) { + const schema = this.items.get(target); + if (!schema) { + throw new Error(`Cannot get schema for '${target.prototype.constructor.name}' target`); + } + if (checkSchema && !schema.schema) { + throw new Error(`Schema '${target.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`); + } + return schema; + } + cache(target) { + const schema = this.get(target); + if (!schema.schema) { + schema.schema = this.create(target, true); + } + } + createDefault(target) { + const schema = { + type: enums_1.AsnTypeTypes.Sequence, items: {}, + }; + const parentSchema = this.findParentSchema(target); + if (parentSchema) { + Object.assign(schema, parentSchema); + schema.items = Object.assign({}, schema.items, parentSchema.items); + } + return schema; + } + create(target, useNames) { + const schema = this.items.get(target) || this.createDefault(target); + const asn1Value = []; + for (const key in schema.items) { + const item = schema.items[key]; + const name = useNames ? key : ""; + let asn1Item; + if (typeof item.type === "number") { + const Asn1TypeName = enums_1.AsnPropTypes[item.type]; + const Asn1Type = asn1js[Asn1TypeName]; + if (!Asn1Type) { + throw new Error(`Cannot get ASN1 class by name '${Asn1TypeName}'`); + } + asn1Item = new Asn1Type({ name }); + } + else if ((0, helper_1.isConvertible)(item.type)) { + const instance = new item.type(); + asn1Item = instance.toSchema(name); + } + else if (item.optional) { + const itemSchema = this.get(item.type); + if (itemSchema.type === enums_1.AsnTypeTypes.Choice) { + asn1Item = new asn1js.Any({ name }); + } + else { + asn1Item = this.create(item.type, false); + asn1Item.name = name; + } + } + else { + asn1Item = new asn1js.Any({ name }); + } + const optional = !!item.optional || item.defaultValue !== undefined; + if (item.repeated) { + asn1Item.name = ""; + const Container = item.repeated === "set" ? asn1js.Set : asn1js.Sequence; + asn1Item = new Container({ + name: "", + value: [new asn1js.Repeated({ + name, value: asn1Item, + })], + }); + } + if (item.context !== null && item.context !== undefined) { + if (item.implicit) { + if (typeof item.type === "number" || (0, helper_1.isConvertible)(item.type)) { + const Container = item.repeated ? asn1js.Constructed : asn1js.Primitive; + asn1Value.push(new Container({ + name, optional, idBlock: { + tagClass: 3, tagNumber: item.context, + }, + })); + } + else { + this.cache(item.type); + const isRepeated = !!item.repeated; + let value = !isRepeated ? this.get(item.type, true).schema : asn1Item; + value + = "valueBlock" in value + ? value.valueBlock.value + : value.value; + asn1Value.push(new asn1js.Constructed({ + name: !isRepeated ? name : "", + optional, + idBlock: { + tagClass: 3, tagNumber: item.context, + }, + value: value, + })); + } + } + else { + asn1Value.push(new asn1js.Constructed({ + optional, + idBlock: { + tagClass: 3, tagNumber: item.context, + }, + value: [asn1Item], + })); + } + } + else { + asn1Item.optional = optional; + asn1Value.push(asn1Item); + } + } + switch (schema.type) { + case enums_1.AsnTypeTypes.Sequence: + return new asn1js.Sequence({ + value: asn1Value, name: "", + }); + case enums_1.AsnTypeTypes.Set: + return new asn1js.Set({ + value: asn1Value, name: "", + }); + case enums_1.AsnTypeTypes.Choice: + return new asn1js.Choice({ + value: asn1Value, name: "", + }); + default: + throw new Error("Unsupported ASN1 type in use"); + } + } + set(target, schema) { + this.items.set(target, schema); + return this; + } + findParentSchema(target) { + const parent = Object.getPrototypeOf(target); + if (parent) { + const schema = this.items.get(parent); + return schema || this.findParentSchema(parent); + } + return null; + } +} +exports.AsnSchemaStorage = AsnSchemaStorage; diff --git a/node_modules/@peculiar/asn1-schema/build/cjs/serializer.js b/node_modules/@peculiar/asn1-schema/build/cjs/serializer.js new file mode 100644 index 0000000000000000000000000000000000000000..eb0224398838de61013e2604519d3bd97e784129 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/cjs/serializer.js @@ -0,0 +1,156 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AsnSerializer = void 0; +const tslib_1 = require("tslib"); +const asn1js = tslib_1.__importStar(require("asn1js")); +const bytes_1 = require("@peculiar/utils/bytes"); +const converters = tslib_1.__importStar(require("./converters")); +const enums_1 = require("./enums"); +const helper_1 = require("./helper"); +const storage_1 = require("./storage"); +class AsnSerializer { + static serialize(obj) { + if (obj instanceof asn1js.BaseBlock) { + return obj.toBER(false); + } + return this.toASN(obj).toBER(false); + } + static toASN(obj) { + if (obj && typeof obj === "object" && (0, helper_1.isConvertible)(obj)) { + return obj.toASN(); + } + if (!(obj && typeof obj === "object")) { + throw new TypeError("Parameter 1 should be type of Object."); + } + const target = obj.constructor; + const schema = storage_1.schemaStorage.get(target); + storage_1.schemaStorage.cache(target); + let asn1Value = []; + if (schema.itemType) { + if (!Array.isArray(obj)) { + throw new TypeError("Parameter 1 should be type of Array."); + } + if (typeof schema.itemType === "number") { + const converter = converters.defaultConverter(schema.itemType); + if (!converter) { + throw new Error(`Cannot get default converter for array item of ${target.name} ASN1 schema`); + } + asn1Value = obj.map((o) => converter.toASN(o)); + } + else { + asn1Value = obj.map((o) => this.toAsnItem({ type: schema.itemType }, "[]", target, o)); + } + } + else { + for (const key in schema.items) { + const schemaItem = schema.items[key]; + const objProp = obj[key]; + if (objProp === undefined + || schemaItem.defaultValue === objProp + || (typeof schemaItem.defaultValue === "object" + && typeof objProp === "object" + && (0, helper_1.isArrayEqual)(this.serialize(schemaItem.defaultValue), this.serialize(objProp)))) { + continue; + } + const asn1Item = AsnSerializer.toAsnItem(schemaItem, key, target, objProp); + if (typeof schemaItem.context === "number") { + if (schemaItem.implicit) { + if (!schemaItem.repeated + && (typeof schemaItem.type === "number" || (0, helper_1.isConvertible)(schemaItem.type))) { + const value = {}; + value.valueHex + = asn1Item instanceof asn1js.Null + ? (0, bytes_1.toArrayBuffer)(asn1Item.valueBeforeDecodeView) + : asn1Item.valueBlock.toBER(); + asn1Value.push(new asn1js.Primitive({ + optional: schemaItem.optional, + idBlock: { + tagClass: 3, + tagNumber: schemaItem.context, + }, + ...value, + })); + } + else { + asn1Value.push(new asn1js.Constructed({ + optional: schemaItem.optional, + idBlock: { + tagClass: 3, + tagNumber: schemaItem.context, + }, + value: asn1Item.valueBlock.value, + })); + } + } + else { + asn1Value.push(new asn1js.Constructed({ + optional: schemaItem.optional, + idBlock: { + tagClass: 3, + tagNumber: schemaItem.context, + }, + value: [asn1Item], + })); + } + } + else if (schemaItem.repeated) { + asn1Value = asn1Value.concat(asn1Item); + } + else { + asn1Value.push(asn1Item); + } + } + } + let asnSchema; + switch (schema.type) { + case enums_1.AsnTypeTypes.Sequence: + asnSchema = new asn1js.Sequence({ value: asn1Value }); + break; + case enums_1.AsnTypeTypes.Set: + asnSchema = new asn1js.Set({ value: asn1Value }); + break; + case enums_1.AsnTypeTypes.Choice: + if (!asn1Value[0]) { + throw new Error(`Schema '${target.name}' has wrong data. Choice cannot be empty.`); + } + asnSchema = asn1Value[0]; + break; + } + return asnSchema; + } + static toAsnItem(schemaItem, key, target, objProp) { + let asn1Item; + if (typeof schemaItem.type === "number") { + const converter = schemaItem.converter; + if (!converter) { + throw new Error(`Property '${key}' doesn't have converter for type ${enums_1.AsnPropTypes[schemaItem.type]} in schema '${target.name}'`); + } + if (schemaItem.repeated) { + if (!Array.isArray(objProp)) { + throw new TypeError("Parameter 'objProp' should be type of Array."); + } + const items = Array.from(objProp, (element) => converter.toASN(element)); + const Container = schemaItem.repeated === "sequence" ? asn1js.Sequence : asn1js.Set; + asn1Item = new Container({ value: items }); + } + else { + asn1Item = converter.toASN(objProp); + } + } + else { + if (schemaItem.repeated) { + if (!Array.isArray(objProp)) { + throw new TypeError("Parameter 'objProp' should be type of Array."); + } + const items = Array.from(objProp, (element) => this.toASN(element)); + const Container = schemaItem.repeated === "sequence" ? asn1js.Sequence : asn1js.Set; + asn1Item = new Container({ value: items }); + } + else { + asn1Item = this.toASN(objProp); + } + } + return asn1Item; + } +} +exports.AsnSerializer = AsnSerializer; diff --git a/node_modules/@peculiar/asn1-schema/build/cjs/storage.js b/node_modules/@peculiar/asn1-schema/build/cjs/storage.js new file mode 100644 index 0000000000000000000000000000000000000000..368009e84c860a00bd14e5e8a051aaa7084c5d42 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/cjs/storage.js @@ -0,0 +1,5 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.schemaStorage = void 0; +const schema_1 = require("./schema"); +exports.schemaStorage = new schema_1.AsnSchemaStorage(); diff --git a/node_modules/@peculiar/asn1-schema/build/cjs/types.js b/node_modules/@peculiar/asn1-schema/build/cjs/types.js new file mode 100644 index 0000000000000000000000000000000000000000..c8ad2e549bdc6801e0d1c80b0308d4b9bd4985ce --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/cjs/types.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/node_modules/@peculiar/asn1-schema/build/cjs/types/bit_string.js b/node_modules/@peculiar/asn1-schema/build/cjs/types/bit_string.js new file mode 100644 index 0000000000000000000000000000000000000000..63094dc960b93e5df10f58e32877222114e1de67 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/cjs/types/bit_string.js @@ -0,0 +1,70 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.BitString = void 0; +const tslib_1 = require("tslib"); +const asn1js = tslib_1.__importStar(require("asn1js")); +const bytes_1 = require("@peculiar/utils/bytes"); +class BitString { + unusedBits = 0; + value = new ArrayBuffer(0); + constructor(params, unusedBits = 0) { + if (params) { + if (typeof params === "number") { + this.fromNumber(params); + } + else if ((0, bytes_1.isBufferSource)(params)) { + this.unusedBits = unusedBits; + this.value = (0, bytes_1.toArrayBuffer)(params); + } + else { + throw TypeError("Unsupported type of 'params' argument for BitString"); + } + } + } + fromASN(asn) { + if (!(asn instanceof asn1js.BitString)) { + throw new TypeError("Argument 'asn' is not instance of ASN.1 BitString"); + } + this.unusedBits = asn.valueBlock.unusedBits; + this.value = (0, bytes_1.toArrayBuffer)(asn.valueBlock.valueHex); + return this; + } + toASN() { + return new asn1js.BitString({ + unusedBits: this.unusedBits, valueHex: this.value, + }); + } + toSchema(name) { + return new asn1js.BitString({ name }); + } + toNumber() { + let res = ""; + const uintArray = new Uint8Array(this.value); + for (const octet of uintArray) { + res += octet.toString(2).padStart(8, "0"); + } + res = res.split("").reverse().join(""); + if (this.unusedBits) { + res = res.slice(this.unusedBits).padStart(this.unusedBits, "0"); + } + return parseInt(res, 2); + } + fromNumber(value) { + let bits = value.toString(2); + const octetSize = (bits.length + 7) >> 3; + this.unusedBits = (octetSize << 3) - bits.length; + const octets = new Uint8Array(octetSize); + bits = bits + .padStart(octetSize << 3, "0") + .split("") + .reverse() + .join(""); + let index = 0; + while (index < octetSize) { + octets[index] = parseInt(bits.slice(index << 3, (index << 3) + 8), 2); + index++; + } + this.value = octets.buffer; + } +} +exports.BitString = BitString; diff --git a/node_modules/@peculiar/asn1-schema/build/cjs/types/index.js b/node_modules/@peculiar/asn1-schema/build/cjs/types/index.js new file mode 100644 index 0000000000000000000000000000000000000000..cd5fccf2721d6c1bd5e417261a96731c88c2d140 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/cjs/types/index.js @@ -0,0 +1,5 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +tslib_1.__exportStar(require("./bit_string"), exports); +tslib_1.__exportStar(require("./octet_string"), exports); diff --git a/node_modules/@peculiar/asn1-schema/build/cjs/types/octet_string.js b/node_modules/@peculiar/asn1-schema/build/cjs/types/octet_string.js new file mode 100644 index 0000000000000000000000000000000000000000..7c1be4e4aa5b8caec3851343e49065f3a3f0579b --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/cjs/types/octet_string.js @@ -0,0 +1,45 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.OctetString = void 0; +const tslib_1 = require("tslib"); +const asn1js = tslib_1.__importStar(require("asn1js")); +const bytes_1 = require("@peculiar/utils/bytes"); +class OctetString { + buffer; + get byteLength() { + return this.buffer.byteLength; + } + get byteOffset() { + return 0; + } + constructor(param) { + if (typeof param === "number") { + this.buffer = new ArrayBuffer(param); + } + else { + if ((0, bytes_1.isBufferSource)(param)) { + this.buffer = (0, bytes_1.toArrayBuffer)(param); + } + else if (Array.isArray(param)) { + this.buffer = new Uint8Array(param).buffer; + } + else { + this.buffer = new ArrayBuffer(0); + } + } + } + fromASN(asn) { + if (!(asn instanceof asn1js.OctetString)) { + throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString"); + } + this.buffer = (0, bytes_1.toArrayBuffer)(asn.valueBlock.valueHex); + return this; + } + toASN() { + return new asn1js.OctetString({ valueHex: this.buffer }); + } + toSchema(name) { + return new asn1js.OctetString({ name }); + } +} +exports.OctetString = OctetString; diff --git a/node_modules/@peculiar/asn1-schema/build/es2015/convert.js b/node_modules/@peculiar/asn1-schema/build/es2015/convert.js new file mode 100644 index 0000000000000000000000000000000000000000..5efb3838aa87f717f1c2345900f3a17e4e361b58 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/es2015/convert.js @@ -0,0 +1,22 @@ +import * as asn1js from "asn1js"; +import { isBufferSource, toArrayBuffer, } from "@peculiar/utils/bytes"; +import { AsnParser } from "./parser.js"; +import { AsnSerializer } from "./serializer.js"; +export class AsnConvert { + static serialize(obj) { + return AsnSerializer.serialize(obj); + } + static parse(data, target, options) { + return AsnParser.parse(data, target, options); + } + static toString(data, options) { + const buf = isBufferSource(data) + ? toArrayBuffer(data) + : AsnConvert.serialize(data); + const asn = asn1js.fromBER(buf, options?.berOptions); + if (asn.offset === -1) { + throw new Error(`Cannot decode ASN.1 data. ${asn.result.error}`); + } + return asn.result.toString(); + } +} diff --git a/node_modules/@peculiar/asn1-schema/build/es2015/converters.js b/node_modules/@peculiar/asn1-schema/build/es2015/converters.js new file mode 100644 index 0000000000000000000000000000000000000000..86c498ef8bbb0f67f9ff68bd00e0b8db89855c40 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/es2015/converters.js @@ -0,0 +1,139 @@ +import * as asn1js from "asn1js"; +import { toArrayBuffer } from "@peculiar/utils/bytes"; +import { AsnPropTypes } from "./enums.js"; +import { OctetString } from "./types/index.js"; +export const AsnAnyConverter = { + fromASN: (value) => value instanceof asn1js.Null + ? null + : toArrayBuffer(value.valueBeforeDecodeView), + toASN: (value) => { + if (value === null) { + return new asn1js.Null(); + } + const schema = asn1js.fromBER(value); + if (schema.result.error) { + throw new Error(schema.result.error); + } + return schema.result; + }, +}; +export const AsnIntegerConverter = { + fromASN: (value) => value.valueBlock.valueHexView.byteLength >= 4 + ? value.valueBlock.toString() + : value.valueBlock.valueDec, + toASN: (value) => new asn1js.Integer({ value: +value }), +}; +export const AsnEnumeratedConverter = { + fromASN: (value) => value.valueBlock.valueDec, + toASN: (value) => new asn1js.Enumerated({ value }), +}; +export const AsnIntegerArrayBufferConverter = { + fromASN: (value) => toArrayBuffer(value.valueBlock.valueHexView), + toASN: (value) => new asn1js.Integer({ valueHex: value }), +}; +export const AsnIntegerBigIntConverter = { + fromASN: (value) => value.toBigInt(), + toASN: (value) => asn1js.Integer.fromBigInt(value), +}; +export const AsnBitStringConverter = { + fromASN: (value) => toArrayBuffer(value.valueBlock.valueHexView), + toASN: (value) => new asn1js.BitString({ valueHex: value }), +}; +export const AsnObjectIdentifierConverter = { + fromASN: (value) => value.valueBlock.toString(), + toASN: (value) => new asn1js.ObjectIdentifier({ value }), +}; +export const AsnBooleanConverter = { + fromASN: (value) => value.valueBlock.value, + toASN: (value) => new asn1js.Boolean({ value }), +}; +export const AsnOctetStringConverter = { + fromASN: (value) => toArrayBuffer(value.valueBlock.valueHexView), + toASN: (value) => new asn1js.OctetString({ valueHex: value }), +}; +export const AsnConstructedOctetStringConverter = { + fromASN: (value) => new OctetString(value.getValue()), + toASN: (value) => value.toASN(), +}; +function createStringConverter(Asn1Type) { + return { + fromASN: (value) => value.valueBlock.value, + toASN: (value) => new Asn1Type({ value }), + }; +} +export const AsnUtf8StringConverter = createStringConverter(asn1js.Utf8String); +export const AsnBmpStringConverter = createStringConverter(asn1js.BmpString); +export const AsnUniversalStringConverter = createStringConverter(asn1js.UniversalString); +export const AsnNumericStringConverter = createStringConverter(asn1js.NumericString); +export const AsnPrintableStringConverter = createStringConverter(asn1js.PrintableString); +export const AsnTeletexStringConverter = createStringConverter(asn1js.TeletexString); +export const AsnVideotexStringConverter = createStringConverter(asn1js.VideotexString); +export const AsnIA5StringConverter = createStringConverter(asn1js.IA5String); +export const AsnGraphicStringConverter = createStringConverter(asn1js.GraphicString); +export const AsnVisibleStringConverter = createStringConverter(asn1js.VisibleString); +export const AsnGeneralStringConverter = createStringConverter(asn1js.GeneralString); +export const AsnCharacterStringConverter = createStringConverter(asn1js.CharacterString); +export const AsnUTCTimeConverter = { + fromASN: (value) => value.toDate(), + toASN: (value) => new asn1js.UTCTime({ valueDate: value }), +}; +export const AsnGeneralizedTimeConverter = { + fromASN: (value) => value.toDate(), + toASN: (value) => new asn1js.GeneralizedTime({ valueDate: value }), +}; +export const AsnNullConverter = { + fromASN: () => null, + toASN: () => { + return new asn1js.Null(); + }, +}; +export function defaultConverter(type) { + switch (type) { + case AsnPropTypes.Any: + return AsnAnyConverter; + case AsnPropTypes.BitString: + return AsnBitStringConverter; + case AsnPropTypes.BmpString: + return AsnBmpStringConverter; + case AsnPropTypes.Boolean: + return AsnBooleanConverter; + case AsnPropTypes.CharacterString: + return AsnCharacterStringConverter; + case AsnPropTypes.Enumerated: + return AsnEnumeratedConverter; + case AsnPropTypes.GeneralString: + return AsnGeneralStringConverter; + case AsnPropTypes.GeneralizedTime: + return AsnGeneralizedTimeConverter; + case AsnPropTypes.GraphicString: + return AsnGraphicStringConverter; + case AsnPropTypes.IA5String: + return AsnIA5StringConverter; + case AsnPropTypes.Integer: + return AsnIntegerConverter; + case AsnPropTypes.Null: + return AsnNullConverter; + case AsnPropTypes.NumericString: + return AsnNumericStringConverter; + case AsnPropTypes.ObjectIdentifier: + return AsnObjectIdentifierConverter; + case AsnPropTypes.OctetString: + return AsnOctetStringConverter; + case AsnPropTypes.PrintableString: + return AsnPrintableStringConverter; + case AsnPropTypes.TeletexString: + return AsnTeletexStringConverter; + case AsnPropTypes.UTCTime: + return AsnUTCTimeConverter; + case AsnPropTypes.UniversalString: + return AsnUniversalStringConverter; + case AsnPropTypes.Utf8String: + return AsnUtf8StringConverter; + case AsnPropTypes.VideotexString: + return AsnVideotexStringConverter; + case AsnPropTypes.VisibleString: + return AsnVisibleStringConverter; + default: + return null; + } +} diff --git a/node_modules/@peculiar/asn1-schema/build/es2015/decorators.js b/node_modules/@peculiar/asn1-schema/build/es2015/decorators.js new file mode 100644 index 0000000000000000000000000000000000000000..f219e149ca3dcb42d7d0d5baa35257f745352dd6 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/es2015/decorators.js @@ -0,0 +1,41 @@ +import * as converters from "./converters.js"; +import { AsnTypeTypes } from "./enums.js"; +import { schemaStorage } from "./storage.js"; +export const AsnType = (options) => (target) => { + let schema; + if (!schemaStorage.has(target)) { + schema = schemaStorage.createDefault(target); + schemaStorage.set(target, schema); + } + else { + schema = schemaStorage.get(target); + } + Object.assign(schema, options); +}; +export const AsnChoiceType = () => AsnType({ type: AsnTypeTypes.Choice }); +export const AsnSetType = (options) => AsnType({ + type: AsnTypeTypes.Set, ...options, +}); +export const AsnSequenceType = (options) => AsnType({ + type: AsnTypeTypes.Sequence, ...options, +}); +export const AsnProp = (options) => (target, propertyKey) => { + let schema; + if (!schemaStorage.has(target.constructor)) { + schema = schemaStorage.createDefault(target.constructor); + schemaStorage.set(target.constructor, schema); + } + else { + schema = schemaStorage.get(target.constructor); + } + const copyOptions = Object.assign({}, options); + if (typeof copyOptions.type === "number" && !copyOptions.converter) { + const defaultConverter = converters.defaultConverter(options.type); + if (!defaultConverter) { + throw new Error(`Cannot get default converter for property '${propertyKey}' of ${target.constructor.name}`); + } + copyOptions.converter = defaultConverter; + } + copyOptions.raw = options.raw; + schema.items[propertyKey] = copyOptions; +}; diff --git a/node_modules/@peculiar/asn1-schema/build/es2015/enums.js b/node_modules/@peculiar/asn1-schema/build/es2015/enums.js new file mode 100644 index 0000000000000000000000000000000000000000..e681c3cb528c20f20e8961f857115befd163bd71 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/es2015/enums.js @@ -0,0 +1,36 @@ +export var AsnTypeTypes; +(function (AsnTypeTypes) { + AsnTypeTypes[AsnTypeTypes["Sequence"] = 0] = "Sequence"; + AsnTypeTypes[AsnTypeTypes["Set"] = 1] = "Set"; + AsnTypeTypes[AsnTypeTypes["Choice"] = 2] = "Choice"; +})(AsnTypeTypes || (AsnTypeTypes = {})); +export var AsnPropTypes; +(function (AsnPropTypes) { + AsnPropTypes[AsnPropTypes["Any"] = 1] = "Any"; + AsnPropTypes[AsnPropTypes["Boolean"] = 2] = "Boolean"; + AsnPropTypes[AsnPropTypes["OctetString"] = 3] = "OctetString"; + AsnPropTypes[AsnPropTypes["BitString"] = 4] = "BitString"; + AsnPropTypes[AsnPropTypes["Integer"] = 5] = "Integer"; + AsnPropTypes[AsnPropTypes["Enumerated"] = 6] = "Enumerated"; + AsnPropTypes[AsnPropTypes["ObjectIdentifier"] = 7] = "ObjectIdentifier"; + AsnPropTypes[AsnPropTypes["Utf8String"] = 8] = "Utf8String"; + AsnPropTypes[AsnPropTypes["BmpString"] = 9] = "BmpString"; + AsnPropTypes[AsnPropTypes["UniversalString"] = 10] = "UniversalString"; + AsnPropTypes[AsnPropTypes["NumericString"] = 11] = "NumericString"; + AsnPropTypes[AsnPropTypes["PrintableString"] = 12] = "PrintableString"; + AsnPropTypes[AsnPropTypes["TeletexString"] = 13] = "TeletexString"; + AsnPropTypes[AsnPropTypes["VideotexString"] = 14] = "VideotexString"; + AsnPropTypes[AsnPropTypes["IA5String"] = 15] = "IA5String"; + AsnPropTypes[AsnPropTypes["GraphicString"] = 16] = "GraphicString"; + AsnPropTypes[AsnPropTypes["VisibleString"] = 17] = "VisibleString"; + AsnPropTypes[AsnPropTypes["GeneralString"] = 18] = "GeneralString"; + AsnPropTypes[AsnPropTypes["CharacterString"] = 19] = "CharacterString"; + AsnPropTypes[AsnPropTypes["UTCTime"] = 20] = "UTCTime"; + AsnPropTypes[AsnPropTypes["GeneralizedTime"] = 21] = "GeneralizedTime"; + AsnPropTypes[AsnPropTypes["DATE"] = 22] = "DATE"; + AsnPropTypes[AsnPropTypes["TimeOfDay"] = 23] = "TimeOfDay"; + AsnPropTypes[AsnPropTypes["DateTime"] = 24] = "DateTime"; + AsnPropTypes[AsnPropTypes["Duration"] = 25] = "Duration"; + AsnPropTypes[AsnPropTypes["TIME"] = 26] = "TIME"; + AsnPropTypes[AsnPropTypes["Null"] = 27] = "Null"; +})(AsnPropTypes || (AsnPropTypes = {})); diff --git a/node_modules/@peculiar/asn1-schema/build/es2015/errors/index.js b/node_modules/@peculiar/asn1-schema/build/es2015/errors/index.js new file mode 100644 index 0000000000000000000000000000000000000000..3178a91367d8a2f1e870bcae64f33ccacafa7098 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/es2015/errors/index.js @@ -0,0 +1 @@ +export * from "./schema_validation.js"; diff --git a/node_modules/@peculiar/asn1-schema/build/es2015/errors/schema_validation.js b/node_modules/@peculiar/asn1-schema/build/es2015/errors/schema_validation.js new file mode 100644 index 0000000000000000000000000000000000000000..e56df8581df2c9c68f6942000e42b8a642dc9895 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/es2015/errors/schema_validation.js @@ -0,0 +1,3 @@ +export class AsnSchemaValidationError extends Error { + schemas = []; +} diff --git a/node_modules/@peculiar/asn1-schema/build/es2015/helper.js b/node_modules/@peculiar/asn1-schema/build/es2015/helper.js new file mode 100644 index 0000000000000000000000000000000000000000..0916f24c84234394529050d89427f57a7fa7b5c8 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/es2015/helper.js @@ -0,0 +1,39 @@ +export function isConvertible(target) { + if (typeof target === "function" && target.prototype) { + if (target.prototype.toASN && target.prototype.fromASN) { + return true; + } + else { + return isConvertible(target.prototype); + } + } + else { + return !!(target && typeof target === "object" && "toASN" in target && "fromASN" in target); + } +} +export function isTypeOfArray(target) { + if (target) { + const proto = Object.getPrototypeOf(target); + if (proto?.prototype?.constructor === Array) { + return true; + } + return isTypeOfArray(proto); + } + return false; +} +export function isArrayEqual(bytes1, bytes2) { + if (!(bytes1 && bytes2)) { + return false; + } + if (bytes1.byteLength !== bytes2.byteLength) { + return false; + } + const b1 = new Uint8Array(bytes1); + const b2 = new Uint8Array(bytes2); + for (let i = 0; i < bytes1.byteLength; i++) { + if (b1[i] !== b2[i]) { + return false; + } + } + return true; +} diff --git a/node_modules/@peculiar/asn1-schema/build/es2015/index.js b/node_modules/@peculiar/asn1-schema/build/es2015/index.js new file mode 100644 index 0000000000000000000000000000000000000000..eb7d5e78f342660abcc6fed6bd5cc584938ba357 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/es2015/index.js @@ -0,0 +1,9 @@ +export * from "./converters.js"; +export * from "./types/index.js"; +export { AsnProp, AsnType, AsnChoiceType, AsnSequenceType, AsnSetType, } from "./decorators.js"; +export { AsnTypeTypes, AsnPropTypes } from "./enums.js"; +export { AsnParser } from "./parser.js"; +export { AsnSerializer } from "./serializer.js"; +export * from "./errors/index.js"; +export * from "./objects.js"; +export * from "./convert.js"; diff --git a/node_modules/@peculiar/asn1-schema/build/es2015/objects.js b/node_modules/@peculiar/asn1-schema/build/es2015/objects.js new file mode 100644 index 0000000000000000000000000000000000000000..b858c74f28ebd2728b4f5cb2c2bbf1ce84310eb7 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/es2015/objects.js @@ -0,0 +1,13 @@ +export class AsnArray extends Array { + constructor(items = []) { + if (typeof items === "number") { + super(items); + } + else { + super(); + for (const item of items) { + this.push(item); + } + } + } +} diff --git a/node_modules/@peculiar/asn1-schema/build/es2015/package.json b/node_modules/@peculiar/asn1-schema/build/es2015/package.json new file mode 100644 index 0000000000000000000000000000000000000000..3dbc1ca591c0557e35b6004aeba250e6a70b56e3 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/es2015/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/node_modules/@peculiar/asn1-schema/build/es2015/parser.js b/node_modules/@peculiar/asn1-schema/build/es2015/parser.js new file mode 100644 index 0000000000000000000000000000000000000000..58589b5f1893d071d8a36f8fa41b4b5713d44de8 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/es2015/parser.js @@ -0,0 +1,326 @@ +import * as asn1js from "asn1js"; +import { toArrayBuffer } from "@peculiar/utils/bytes"; +import { AsnPropTypes, AsnTypeTypes } from "./enums.js"; +import * as converters from "./converters.js"; +import { AsnSchemaValidationError } from "./errors/index.js"; +import { isConvertible, isTypeOfArray } from "./helper.js"; +import { schemaStorage } from "./storage.js"; +export class AsnParser { + static parse(data, target, options) { + const asn1Parsed = asn1js.fromBER(toArrayBuffer(data), options?.berOptions); + if (asn1Parsed.result.error) { + throw new Error(asn1Parsed.result.error); + } + const res = this.fromASN(asn1Parsed.result, target, options); + return res; + } + static fromASN(asn1Schema, target, options) { + try { + if (isConvertible(target)) { + const value = new target(); + return value.fromASN(asn1Schema); + } + const schema = schemaStorage.get(target); + schemaStorage.cache(target); + let targetSchema = schema.schema; + const choiceResult = this.handleChoiceTypes(asn1Schema, schema, target, targetSchema, options); + if (choiceResult?.result) { + return choiceResult.result; + } + if (choiceResult?.targetSchema) { + targetSchema = choiceResult.targetSchema; + } + const sequenceResult = this.handleSequenceTypes(asn1Schema, schema, target, targetSchema); + const res = new target(); + if (isTypeOfArray(target)) { + return this.handleArrayTypes(asn1Schema, schema, target, options); + } + this.processSchemaItems(schema, sequenceResult, res, options); + return res; + } + catch (error) { + if (error instanceof AsnSchemaValidationError) { + error.schemas.push(target.name); + } + throw error; + } + } + static handleChoiceTypes(asn1Schema, schema, target, targetSchema, options) { + if (asn1Schema.constructor === asn1js.Constructed + && schema.type === AsnTypeTypes.Choice + && asn1Schema.idBlock.tagClass === 3) { + for (const key in schema.items) { + const schemaItem = schema.items[key]; + if (schemaItem.context === asn1Schema.idBlock.tagNumber && schemaItem.implicit) { + if (typeof schemaItem.type === "function" + && schemaStorage.has(schemaItem.type)) { + const fieldSchema = schemaStorage.get(schemaItem.type); + if (fieldSchema && fieldSchema.type === AsnTypeTypes.Sequence) { + const newSeq = new asn1js.Sequence(); + if ("value" in asn1Schema.valueBlock + && Array.isArray(asn1Schema.valueBlock.value) + && "value" in newSeq.valueBlock) { + newSeq.valueBlock.value = asn1Schema.valueBlock.value; + const fieldValue = this.fromASN(newSeq, schemaItem.type, options); + const res = new target(); + res[key] = fieldValue; + return { result: res }; + } + } + } + } + } + } + else if (asn1Schema.constructor === asn1js.Constructed + && schema.type !== AsnTypeTypes.Choice) { + const newTargetSchema = new asn1js.Constructed({ + idBlock: { + tagClass: 3, + tagNumber: asn1Schema.idBlock.tagNumber, + }, + value: schema.schema.valueBlock.value, + }); + for (const key in schema.items) { + delete asn1Schema[key]; + } + return { targetSchema: newTargetSchema }; + } + return null; + } + static handleSequenceTypes(asn1Schema, schema, target, targetSchema) { + if (schema.type === AsnTypeTypes.Sequence) { + const asn1ComparedSchema = asn1js.compareSchema({}, asn1Schema, targetSchema); + if (!asn1ComparedSchema.verified) { + throw new AsnSchemaValidationError(`Data does not match to ${target.name} ASN1 schema.${asn1ComparedSchema.result.error ? ` ${asn1ComparedSchema.result.error}` : ""}`); + } + return asn1ComparedSchema; + } + else { + const asn1ComparedSchema = asn1js.compareSchema({}, asn1Schema, targetSchema); + if (!asn1ComparedSchema.verified) { + throw new AsnSchemaValidationError(`Data does not match to ${target.name} ASN1 schema.${asn1ComparedSchema.result.error ? ` ${asn1ComparedSchema.result.error}` : ""}`); + } + return asn1ComparedSchema; + } + } + static processRepeatedField(asn1Elements, asn1Index, schemaItem) { + let elementsToProcess = asn1Elements.slice(asn1Index); + if (elementsToProcess.length === 1 && elementsToProcess[0].constructor.name === "Sequence") { + const seq = elementsToProcess[0]; + if (seq.valueBlock && seq.valueBlock.value && Array.isArray(seq.valueBlock.value)) { + elementsToProcess = seq.valueBlock.value; + } + } + if (typeof schemaItem.type === "number") { + const converter = converters.defaultConverter(schemaItem.type); + if (!converter) + throw new Error(`No converter for ASN.1 type ${schemaItem.type}`); + return elementsToProcess + .filter((el) => el && el.valueBlock) + .map((el) => { + try { + return converter.fromASN(el); + } + catch { + return undefined; + } + }) + .filter((v) => v !== undefined); + } + else { + return elementsToProcess + .filter((el) => el && el.valueBlock) + .map((el) => { + try { + return this.fromASN(el, schemaItem.type); + } + catch { + return undefined; + } + }) + .filter((v) => v !== undefined); + } + } + static processPrimitiveField(asn1Element, schemaItem) { + const converter = converters.defaultConverter(schemaItem.type); + if (!converter) + throw new Error(`No converter for ASN.1 type ${schemaItem.type}`); + return converter.fromASN(asn1Element); + } + static isOptionalChoiceField(schemaItem) { + return (schemaItem.optional + && typeof schemaItem.type === "function" + && schemaStorage.has(schemaItem.type) + && schemaStorage.get(schemaItem.type).type === AsnTypeTypes.Choice); + } + static processOptionalChoiceField(asn1Element, schemaItem) { + try { + const value = this.fromASN(asn1Element, schemaItem.type); + return { + processed: true, value, + }; + } + catch (err) { + if (err instanceof AsnSchemaValidationError + && /Wrong values for Choice type/.test(err.message)) { + return { processed: false }; + } + throw err; + } + } + static handleArrayTypes(asn1Schema, schema, target, options) { + if (!("value" in asn1Schema.valueBlock && Array.isArray(asn1Schema.valueBlock.value))) { + throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed."); + } + const itemType = schema.itemType; + if (typeof itemType === "number") { + const converter = converters.defaultConverter(itemType); + if (!converter) { + throw new Error(`Cannot get default converter for array item of ${target.name} ASN1 schema`); + } + return target.from(asn1Schema.valueBlock.value, (element) => converter.fromASN(element)); + } + else { + return target.from(asn1Schema.valueBlock.value, (element) => this.fromASN(element, itemType, options)); + } + } + static processSchemaItems(schema, asn1ComparedSchema, res, options) { + for (const key in schema.items) { + const asn1SchemaValue = asn1ComparedSchema.result[key]; + if (!asn1SchemaValue) { + continue; + } + const schemaItem = schema.items[key]; + const schemaItemType = schemaItem.type; + let parsedValue; + if (typeof schemaItemType === "number" || isConvertible(schemaItemType)) { + parsedValue = this.processPrimitiveSchemaItem(asn1SchemaValue, schemaItem, schemaItemType, options); + } + else { + parsedValue = this.processComplexSchemaItem(asn1SchemaValue, schemaItem, schemaItemType, options); + } + if (parsedValue + && typeof parsedValue === "object" + && "value" in parsedValue + && "raw" in parsedValue) { + res[key] = parsedValue.value; + res[`${key}Raw`] = parsedValue.raw; + } + else { + res[key] = parsedValue; + } + } + } + static processPrimitiveSchemaItem(asn1SchemaValue, schemaItem, schemaItemType, options) { + const converter = schemaItem.converter + ?? (isConvertible(schemaItemType) + ? new schemaItemType() + : null); + if (!converter) { + throw new Error("Converter is empty"); + } + if (schemaItem.repeated) { + return this.processRepeatedPrimitiveItem(asn1SchemaValue, schemaItem, converter, options); + } + else { + return this.processSinglePrimitiveItem(asn1SchemaValue, schemaItem, schemaItemType, converter, options); + } + } + static processRepeatedPrimitiveItem(asn1SchemaValue, schemaItem, converter, options) { + if (schemaItem.implicit) { + const Container = schemaItem.repeated === "sequence" ? asn1js.Sequence : asn1js.Set; + const newItem = new Container(); + newItem.valueBlock = asn1SchemaValue.valueBlock; + const newItemAsn = asn1js.fromBER(newItem.toBER(false), options?.berOptions); + if (newItemAsn.offset === -1) { + throw new Error(`Cannot parse the child item. ${newItemAsn.result.error}`); + } + if (!("value" in newItemAsn.result.valueBlock + && Array.isArray(newItemAsn.result.valueBlock.value))) { + throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed."); + } + const value = newItemAsn.result.valueBlock.value; + return Array.from(value, (element) => converter.fromASN(element)); + } + else { + return Array.from(asn1SchemaValue, (element) => converter.fromASN(element)); + } + } + static processSinglePrimitiveItem(asn1SchemaValue, schemaItem, schemaItemType, converter, options) { + let value = asn1SchemaValue; + if (schemaItem.implicit) { + let newItem; + if (isConvertible(schemaItemType)) { + newItem = new schemaItemType().toSchema(""); + } + else { + const Asn1TypeName = AsnPropTypes[schemaItemType]; + const Asn1Type = asn1js[Asn1TypeName]; + if (!Asn1Type) { + throw new Error(`Cannot get '${Asn1TypeName}' class from asn1js module`); + } + newItem = new Asn1Type(); + } + newItem.valueBlock = value.valueBlock; + value = asn1js.fromBER(newItem.toBER(false), options?.berOptions).result; + } + return converter.fromASN(value); + } + static processComplexSchemaItem(asn1SchemaValue, schemaItem, schemaItemType, options) { + if (schemaItem.repeated) { + if (!Array.isArray(asn1SchemaValue)) { + throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable."); + } + return Array.from(asn1SchemaValue, (element) => this.fromASN(element, schemaItemType, options)); + } + else { + const valueToProcess = this.handleImplicitTagging(asn1SchemaValue, schemaItem, schemaItemType); + if (this.isOptionalChoiceField(schemaItem)) { + try { + return this.fromASN(valueToProcess, schemaItemType, options); + } + catch (err) { + if (err instanceof AsnSchemaValidationError + && /Wrong values for Choice type/.test(err.message)) { + return undefined; + } + throw err; + } + } + else { + const parsedValue = this.fromASN(valueToProcess, schemaItemType, options); + if (schemaItem.raw) { + return { + value: parsedValue, + raw: asn1SchemaValue.valueBeforeDecodeView, + }; + } + return parsedValue; + } + } + } + static handleImplicitTagging(asn1SchemaValue, schemaItem, schemaItemType) { + if (schemaItem.implicit && typeof schemaItem.context === "number") { + const schema = schemaStorage.get(schemaItemType); + if (schema.type === AsnTypeTypes.Sequence) { + const newSeq = new asn1js.Sequence(); + if ("value" in asn1SchemaValue.valueBlock + && Array.isArray(asn1SchemaValue.valueBlock.value) + && "value" in newSeq.valueBlock) { + newSeq.valueBlock.value = asn1SchemaValue.valueBlock.value; + return newSeq; + } + } + else if (schema.type === AsnTypeTypes.Set) { + const newSet = new asn1js.Set(); + if ("value" in asn1SchemaValue.valueBlock + && Array.isArray(asn1SchemaValue.valueBlock.value) + && "value" in newSet.valueBlock) { + newSet.valueBlock.value = asn1SchemaValue.valueBlock.value; + return newSet; + } + } + } + return asn1SchemaValue; + } +} diff --git a/node_modules/@peculiar/asn1-schema/build/es2015/schema.js b/node_modules/@peculiar/asn1-schema/build/es2015/schema.js new file mode 100644 index 0000000000000000000000000000000000000000..f618775f36fe8ea333f84284e00ef1a114b4246a --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/es2015/schema.js @@ -0,0 +1,151 @@ +import * as asn1js from "asn1js"; +import { AsnPropTypes, AsnTypeTypes } from "./enums.js"; +import { isConvertible } from "./helper.js"; +export class AsnSchemaStorage { + items = new WeakMap(); + has(target) { + return this.items.has(target); + } + get(target, checkSchema = false) { + const schema = this.items.get(target); + if (!schema) { + throw new Error(`Cannot get schema for '${target.prototype.constructor.name}' target`); + } + if (checkSchema && !schema.schema) { + throw new Error(`Schema '${target.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`); + } + return schema; + } + cache(target) { + const schema = this.get(target); + if (!schema.schema) { + schema.schema = this.create(target, true); + } + } + createDefault(target) { + const schema = { + type: AsnTypeTypes.Sequence, items: {}, + }; + const parentSchema = this.findParentSchema(target); + if (parentSchema) { + Object.assign(schema, parentSchema); + schema.items = Object.assign({}, schema.items, parentSchema.items); + } + return schema; + } + create(target, useNames) { + const schema = this.items.get(target) || this.createDefault(target); + const asn1Value = []; + for (const key in schema.items) { + const item = schema.items[key]; + const name = useNames ? key : ""; + let asn1Item; + if (typeof item.type === "number") { + const Asn1TypeName = AsnPropTypes[item.type]; + const Asn1Type = asn1js[Asn1TypeName]; + if (!Asn1Type) { + throw new Error(`Cannot get ASN1 class by name '${Asn1TypeName}'`); + } + asn1Item = new Asn1Type({ name }); + } + else if (isConvertible(item.type)) { + const instance = new item.type(); + asn1Item = instance.toSchema(name); + } + else if (item.optional) { + const itemSchema = this.get(item.type); + if (itemSchema.type === AsnTypeTypes.Choice) { + asn1Item = new asn1js.Any({ name }); + } + else { + asn1Item = this.create(item.type, false); + asn1Item.name = name; + } + } + else { + asn1Item = new asn1js.Any({ name }); + } + const optional = !!item.optional || item.defaultValue !== undefined; + if (item.repeated) { + asn1Item.name = ""; + const Container = item.repeated === "set" ? asn1js.Set : asn1js.Sequence; + asn1Item = new Container({ + name: "", + value: [new asn1js.Repeated({ + name, value: asn1Item, + })], + }); + } + if (item.context !== null && item.context !== undefined) { + if (item.implicit) { + if (typeof item.type === "number" || isConvertible(item.type)) { + const Container = item.repeated ? asn1js.Constructed : asn1js.Primitive; + asn1Value.push(new Container({ + name, optional, idBlock: { + tagClass: 3, tagNumber: item.context, + }, + })); + } + else { + this.cache(item.type); + const isRepeated = !!item.repeated; + let value = !isRepeated ? this.get(item.type, true).schema : asn1Item; + value + = "valueBlock" in value + ? value.valueBlock.value + : value.value; + asn1Value.push(new asn1js.Constructed({ + name: !isRepeated ? name : "", + optional, + idBlock: { + tagClass: 3, tagNumber: item.context, + }, + value: value, + })); + } + } + else { + asn1Value.push(new asn1js.Constructed({ + optional, + idBlock: { + tagClass: 3, tagNumber: item.context, + }, + value: [asn1Item], + })); + } + } + else { + asn1Item.optional = optional; + asn1Value.push(asn1Item); + } + } + switch (schema.type) { + case AsnTypeTypes.Sequence: + return new asn1js.Sequence({ + value: asn1Value, name: "", + }); + case AsnTypeTypes.Set: + return new asn1js.Set({ + value: asn1Value, name: "", + }); + case AsnTypeTypes.Choice: + return new asn1js.Choice({ + value: asn1Value, name: "", + }); + default: + throw new Error("Unsupported ASN1 type in use"); + } + } + set(target, schema) { + this.items.set(target, schema); + return this; + } + findParentSchema(target) { + const parent = Object.getPrototypeOf(target); + if (parent) { + const schema = this.items.get(parent); + return schema || this.findParentSchema(parent); + } + return null; + } +} diff --git a/node_modules/@peculiar/asn1-schema/build/es2015/serializer.js b/node_modules/@peculiar/asn1-schema/build/es2015/serializer.js new file mode 100644 index 0000000000000000000000000000000000000000..d536c60b90fa97eae6d4bc4a2c11b571e9adfd62 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/es2015/serializer.js @@ -0,0 +1,151 @@ +import * as asn1js from "asn1js"; +import { toArrayBuffer } from "@peculiar/utils/bytes"; +import * as converters from "./converters.js"; +import { AsnPropTypes, AsnTypeTypes } from "./enums.js"; +import { isConvertible, isArrayEqual } from "./helper.js"; +import { schemaStorage } from "./storage.js"; +export class AsnSerializer { + static serialize(obj) { + if (obj instanceof asn1js.BaseBlock) { + return obj.toBER(false); + } + return this.toASN(obj).toBER(false); + } + static toASN(obj) { + if (obj && typeof obj === "object" && isConvertible(obj)) { + return obj.toASN(); + } + if (!(obj && typeof obj === "object")) { + throw new TypeError("Parameter 1 should be type of Object."); + } + const target = obj.constructor; + const schema = schemaStorage.get(target); + schemaStorage.cache(target); + let asn1Value = []; + if (schema.itemType) { + if (!Array.isArray(obj)) { + throw new TypeError("Parameter 1 should be type of Array."); + } + if (typeof schema.itemType === "number") { + const converter = converters.defaultConverter(schema.itemType); + if (!converter) { + throw new Error(`Cannot get default converter for array item of ${target.name} ASN1 schema`); + } + asn1Value = obj.map((o) => converter.toASN(o)); + } + else { + asn1Value = obj.map((o) => this.toAsnItem({ type: schema.itemType }, "[]", target, o)); + } + } + else { + for (const key in schema.items) { + const schemaItem = schema.items[key]; + const objProp = obj[key]; + if (objProp === undefined + || schemaItem.defaultValue === objProp + || (typeof schemaItem.defaultValue === "object" + && typeof objProp === "object" + && isArrayEqual(this.serialize(schemaItem.defaultValue), this.serialize(objProp)))) { + continue; + } + const asn1Item = AsnSerializer.toAsnItem(schemaItem, key, target, objProp); + if (typeof schemaItem.context === "number") { + if (schemaItem.implicit) { + if (!schemaItem.repeated + && (typeof schemaItem.type === "number" || isConvertible(schemaItem.type))) { + const value = {}; + value.valueHex + = asn1Item instanceof asn1js.Null + ? toArrayBuffer(asn1Item.valueBeforeDecodeView) + : asn1Item.valueBlock.toBER(); + asn1Value.push(new asn1js.Primitive({ + optional: schemaItem.optional, + idBlock: { + tagClass: 3, + tagNumber: schemaItem.context, + }, + ...value, + })); + } + else { + asn1Value.push(new asn1js.Constructed({ + optional: schemaItem.optional, + idBlock: { + tagClass: 3, + tagNumber: schemaItem.context, + }, + value: asn1Item.valueBlock.value, + })); + } + } + else { + asn1Value.push(new asn1js.Constructed({ + optional: schemaItem.optional, + idBlock: { + tagClass: 3, + tagNumber: schemaItem.context, + }, + value: [asn1Item], + })); + } + } + else if (schemaItem.repeated) { + asn1Value = asn1Value.concat(asn1Item); + } + else { + asn1Value.push(asn1Item); + } + } + } + let asnSchema; + switch (schema.type) { + case AsnTypeTypes.Sequence: + asnSchema = new asn1js.Sequence({ value: asn1Value }); + break; + case AsnTypeTypes.Set: + asnSchema = new asn1js.Set({ value: asn1Value }); + break; + case AsnTypeTypes.Choice: + if (!asn1Value[0]) { + throw new Error(`Schema '${target.name}' has wrong data. Choice cannot be empty.`); + } + asnSchema = asn1Value[0]; + break; + } + return asnSchema; + } + static toAsnItem(schemaItem, key, target, objProp) { + let asn1Item; + if (typeof schemaItem.type === "number") { + const converter = schemaItem.converter; + if (!converter) { + throw new Error(`Property '${key}' doesn't have converter for type ${AsnPropTypes[schemaItem.type]} in schema '${target.name}'`); + } + if (schemaItem.repeated) { + if (!Array.isArray(objProp)) { + throw new TypeError("Parameter 'objProp' should be type of Array."); + } + const items = Array.from(objProp, (element) => converter.toASN(element)); + const Container = schemaItem.repeated === "sequence" ? asn1js.Sequence : asn1js.Set; + asn1Item = new Container({ value: items }); + } + else { + asn1Item = converter.toASN(objProp); + } + } + else { + if (schemaItem.repeated) { + if (!Array.isArray(objProp)) { + throw new TypeError("Parameter 'objProp' should be type of Array."); + } + const items = Array.from(objProp, (element) => this.toASN(element)); + const Container = schemaItem.repeated === "sequence" ? asn1js.Sequence : asn1js.Set; + asn1Item = new Container({ value: items }); + } + else { + asn1Item = this.toASN(objProp); + } + } + return asn1Item; + } +} diff --git a/node_modules/@peculiar/asn1-schema/build/es2015/storage.js b/node_modules/@peculiar/asn1-schema/build/es2015/storage.js new file mode 100644 index 0000000000000000000000000000000000000000..28f98e3bffa4c630f5fbb34b38d100d6e46bb408 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/es2015/storage.js @@ -0,0 +1,2 @@ +import { AsnSchemaStorage } from "./schema.js"; +export const schemaStorage = new AsnSchemaStorage(); diff --git a/node_modules/@peculiar/asn1-schema/build/es2015/types.js b/node_modules/@peculiar/asn1-schema/build/es2015/types.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/es2015/types.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@peculiar/asn1-schema/build/es2015/types/bit_string.js b/node_modules/@peculiar/asn1-schema/build/es2015/types/bit_string.js new file mode 100644 index 0000000000000000000000000000000000000000..b421407888e8f5f9df4f6d1128351d47fdf59e71 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/es2015/types/bit_string.js @@ -0,0 +1,65 @@ +import * as asn1js from "asn1js"; +import { isBufferSource, toArrayBuffer, } from "@peculiar/utils/bytes"; +export class BitString { + unusedBits = 0; + value = new ArrayBuffer(0); + constructor(params, unusedBits = 0) { + if (params) { + if (typeof params === "number") { + this.fromNumber(params); + } + else if (isBufferSource(params)) { + this.unusedBits = unusedBits; + this.value = toArrayBuffer(params); + } + else { + throw TypeError("Unsupported type of 'params' argument for BitString"); + } + } + } + fromASN(asn) { + if (!(asn instanceof asn1js.BitString)) { + throw new TypeError("Argument 'asn' is not instance of ASN.1 BitString"); + } + this.unusedBits = asn.valueBlock.unusedBits; + this.value = toArrayBuffer(asn.valueBlock.valueHex); + return this; + } + toASN() { + return new asn1js.BitString({ + unusedBits: this.unusedBits, valueHex: this.value, + }); + } + toSchema(name) { + return new asn1js.BitString({ name }); + } + toNumber() { + let res = ""; + const uintArray = new Uint8Array(this.value); + for (const octet of uintArray) { + res += octet.toString(2).padStart(8, "0"); + } + res = res.split("").reverse().join(""); + if (this.unusedBits) { + res = res.slice(this.unusedBits).padStart(this.unusedBits, "0"); + } + return parseInt(res, 2); + } + fromNumber(value) { + let bits = value.toString(2); + const octetSize = (bits.length + 7) >> 3; + this.unusedBits = (octetSize << 3) - bits.length; + const octets = new Uint8Array(octetSize); + bits = bits + .padStart(octetSize << 3, "0") + .split("") + .reverse() + .join(""); + let index = 0; + while (index < octetSize) { + octets[index] = parseInt(bits.slice(index << 3, (index << 3) + 8), 2); + index++; + } + this.value = octets.buffer; + } +} diff --git a/node_modules/@peculiar/asn1-schema/build/es2015/types/index.js b/node_modules/@peculiar/asn1-schema/build/es2015/types/index.js new file mode 100644 index 0000000000000000000000000000000000000000..d99c7f06366dac4b01d0eeffaf9e4dbb895c093f --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/es2015/types/index.js @@ -0,0 +1,2 @@ +export * from "./bit_string.js"; +export * from "./octet_string.js"; diff --git a/node_modules/@peculiar/asn1-schema/build/es2015/types/octet_string.js b/node_modules/@peculiar/asn1-schema/build/es2015/types/octet_string.js new file mode 100644 index 0000000000000000000000000000000000000000..786150c091ffa2a9dcf7077e5951542a70614d7d --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/es2015/types/octet_string.js @@ -0,0 +1,40 @@ +import * as asn1js from "asn1js"; +import { isBufferSource, toArrayBuffer, } from "@peculiar/utils/bytes"; +export class OctetString { + buffer; + get byteLength() { + return this.buffer.byteLength; + } + get byteOffset() { + return 0; + } + constructor(param) { + if (typeof param === "number") { + this.buffer = new ArrayBuffer(param); + } + else { + if (isBufferSource(param)) { + this.buffer = toArrayBuffer(param); + } + else if (Array.isArray(param)) { + this.buffer = new Uint8Array(param).buffer; + } + else { + this.buffer = new ArrayBuffer(0); + } + } + } + fromASN(asn) { + if (!(asn instanceof asn1js.OctetString)) { + throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString"); + } + this.buffer = toArrayBuffer(asn.valueBlock.valueHex); + return this; + } + toASN() { + return new asn1js.OctetString({ valueHex: this.buffer }); + } + toSchema(name) { + return new asn1js.OctetString({ name }); + } +} diff --git a/node_modules/@peculiar/asn1-schema/build/types/convert.d.ts b/node_modules/@peculiar/asn1-schema/build/types/convert.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..aab8a0918a41ad5b47e85e47eb8190394ee4a02c --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/types/convert.d.ts @@ -0,0 +1,20 @@ +import { type BufferSourceLike } from "@peculiar/utils/bytes"; +import { IEmptyConstructor, IAsnParseOptions } from "./types"; +export declare class AsnConvert { + static serialize(obj: unknown): ArrayBuffer; + static parse(data: BufferSourceLike, target: IEmptyConstructor, options?: IAsnParseOptions): T; + /** + * Returns a string representation of an ASN.1 encoded data + * @param data ASN.1 encoded buffer source + * @param options Optional parsing options forwarded to `asn1js.fromBER` + * @returns String representation of ASN.1 structure + */ + static toString(data: BufferSourceLike, options?: IAsnParseOptions): string; + /** + * Returns a string representation of an ASN.1 schema + * @param obj Object which can be serialized to ASN.1 schema + * @param options Optional parsing options forwarded to `asn1js.fromBER` + * @returns String representation of ASN.1 structure + */ + static toString(obj: unknown, options?: IAsnParseOptions): string; +} diff --git a/node_modules/@peculiar/asn1-schema/build/types/converters.d.ts b/node_modules/@peculiar/asn1-schema/build/types/converters.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5f24d7352c537a1627d94df7849dbf87ddce198a --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/types/converters.d.ts @@ -0,0 +1,113 @@ +import * as asn1js from "asn1js"; +import { AnyConverterType, IAsnConverter, IntegerConverterType } from "./types"; +import { AsnPropTypes } from "./enums"; +import { OctetString } from "./types/index"; +/** + * NOTE: Converter MUST have name AsnConverter. + * Asn1Prop decorator link custom converters by name of the Asn1PropType + */ +/** + * ASN.1 ANY converter + */ +export declare const AsnAnyConverter: IAsnConverter; +/** + * ASN.1 INTEGER to Number/String converter + */ +export declare const AsnIntegerConverter: IAsnConverter; +/** + * ASN.1 ENUMERATED converter + */ +export declare const AsnEnumeratedConverter: IAsnConverter; +/** + * ASN.1 INTEGER to ArrayBuffer converter + */ +export declare const AsnIntegerArrayBufferConverter: IAsnConverter; +/** + * ASN.1 INTEGER to BigInt converter + */ +export declare const AsnIntegerBigIntConverter: IAsnConverter; +/** + * ASN.1 BIT STRING converter + */ +export declare const AsnBitStringConverter: IAsnConverter; +/** + * ASN.1 OBJECT IDENTIFIER converter + */ +export declare const AsnObjectIdentifierConverter: IAsnConverter; +/** + * ASN.1 BOOLEAN converter + */ +export declare const AsnBooleanConverter: IAsnConverter; +/** + * ASN.1 OCTET_STRING converter + */ +export declare const AsnOctetStringConverter: IAsnConverter; +/** + * ASN.1 OCTET_STRING converter to OctetString class + */ +export declare const AsnConstructedOctetStringConverter: IAsnConverter; +/** + * ASN.1 UTF8_STRING converter + */ +export declare const AsnUtf8StringConverter: IAsnConverter; +/** + * ASN.1 BPM STRING converter + */ +export declare const AsnBmpStringConverter: IAsnConverter; +/** + * ASN.1 UNIVERSAL STRING converter + */ +export declare const AsnUniversalStringConverter: IAsnConverter; +/** + * ASN.1 NUMERIC STRING converter + */ +export declare const AsnNumericStringConverter: IAsnConverter; +/** + * ASN.1 PRINTABLE STRING converter + */ +export declare const AsnPrintableStringConverter: IAsnConverter; +/** + * ASN.1 TELETEX STRING converter + */ +export declare const AsnTeletexStringConverter: IAsnConverter; +/** + * ASN.1 VIDEOTEX STRING converter + */ +export declare const AsnVideotexStringConverter: IAsnConverter; +/** + * ASN.1 IA5 STRING converter + */ +export declare const AsnIA5StringConverter: IAsnConverter; +/** + * ASN.1 GRAPHIC STRING converter + */ +export declare const AsnGraphicStringConverter: IAsnConverter; +/** + * ASN.1 VISIBLE STRING converter + */ +export declare const AsnVisibleStringConverter: IAsnConverter; +/** + * ASN.1 GENERAL STRING converter + */ +export declare const AsnGeneralStringConverter: IAsnConverter; +/** + * ASN.1 CHARACTER STRING converter + */ +export declare const AsnCharacterStringConverter: IAsnConverter; +/** + * ASN.1 UTCTime converter + */ +export declare const AsnUTCTimeConverter: IAsnConverter; +/** + * ASN.1 GeneralizedTime converter + */ +export declare const AsnGeneralizedTimeConverter: IAsnConverter; +/** + * ASN.1 ANY converter + */ +export declare const AsnNullConverter: IAsnConverter; +/** + * Returns default converter for specified type + * @param type + */ +export declare function defaultConverter(type: AsnPropTypes): IAsnConverter | null; diff --git a/node_modules/@peculiar/asn1-schema/build/types/decorators.d.ts b/node_modules/@peculiar/asn1-schema/build/types/decorators.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b5193de694e2ce1c3c7a49d481c118c1905b87bd --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/types/decorators.d.ts @@ -0,0 +1,36 @@ +import { AsnPropTypes, AsnTypeTypes } from "./enums"; +import { IAsnConverter, IEmptyConstructor } from "./types"; +export type AsnItemType = AsnPropTypes | IEmptyConstructor; +export interface IAsn1TypeOptions { + type: AsnTypeTypes; + itemType?: AsnItemType; +} +export type AsnRepeatTypeString = "sequence" | "set"; +export type AsnRepeatType = AsnRepeatTypeString; +export interface IAsn1PropOptions { + type: AsnItemType; + optional?: boolean; + defaultValue?: unknown; + context?: number; + implicit?: boolean; + converter?: IAsnConverter; + repeated?: AsnRepeatType; + /** + * If true, the raw ASN.1 encoded bytes of the property will be stored in a separate property + * with 'Raw' suffix. + */ + raw?: boolean; +} +export type AsnTypeDecorator = (target: IEmptyConstructor) => void; +export declare const AsnType: (options: IAsn1TypeOptions) => AsnTypeDecorator; +export declare const AsnChoiceType: () => AsnTypeDecorator; +export interface IAsn1SetOptions { + itemType: AsnItemType; +} +export declare const AsnSetType: (options: IAsn1SetOptions) => AsnTypeDecorator; +export interface IAsn1SequenceOptions { + itemType?: AsnItemType; +} +export declare const AsnSequenceType: (options: IAsn1SequenceOptions) => AsnTypeDecorator; +export type AsnPropDecorator = (target: object, propertyKey: string) => void; +export declare const AsnProp: (options: IAsn1PropOptions) => AsnPropDecorator; diff --git a/node_modules/@peculiar/asn1-schema/build/types/enums.d.ts b/node_modules/@peculiar/asn1-schema/build/types/enums.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1312d2553e26527d5835fddc200c2e16cbaded86 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/types/enums.d.ts @@ -0,0 +1,40 @@ +/** + * ASN.1 types for classes + */ +export declare enum AsnTypeTypes { + Sequence = 0, + Set = 1, + Choice = 2 +} +/** + * ASN.1 types for properties + */ +export declare enum AsnPropTypes { + Any = 1, + Boolean = 2, + OctetString = 3, + BitString = 4, + Integer = 5, + Enumerated = 6, + ObjectIdentifier = 7, + Utf8String = 8, + BmpString = 9, + UniversalString = 10, + NumericString = 11, + PrintableString = 12, + TeletexString = 13, + VideotexString = 14, + IA5String = 15, + GraphicString = 16, + VisibleString = 17, + GeneralString = 18, + CharacterString = 19, + UTCTime = 20, + GeneralizedTime = 21, + DATE = 22, + TimeOfDay = 23, + DateTime = 24, + Duration = 25, + TIME = 26, + Null = 27 +} diff --git a/node_modules/@peculiar/asn1-schema/build/types/errors/index.d.ts b/node_modules/@peculiar/asn1-schema/build/types/errors/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6edc5380f7053e60cfe54b94159f745c949095f1 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/types/errors/index.d.ts @@ -0,0 +1 @@ +export * from "./schema_validation"; diff --git a/node_modules/@peculiar/asn1-schema/build/types/errors/schema_validation.d.ts b/node_modules/@peculiar/asn1-schema/build/types/errors/schema_validation.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..81de5ad8fbd7e4d30715fa520c819e114a9b4f8a --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/types/errors/schema_validation.d.ts @@ -0,0 +1,3 @@ +export declare class AsnSchemaValidationError extends Error { + schemas: string[]; +} diff --git a/node_modules/@peculiar/asn1-schema/build/types/helper.d.ts b/node_modules/@peculiar/asn1-schema/build/types/helper.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4cf2baf2a3b013195cbfb93e1e592c6cc959c3d9 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/types/helper.d.ts @@ -0,0 +1,5 @@ +import { IAsnConvertible, IEmptyConstructor } from "./types"; +export declare function isConvertible(target: IEmptyConstructor): target is new () => IAsnConvertible; +export declare function isConvertible(target: unknown): target is IAsnConvertible; +export declare function isTypeOfArray(target: unknown): target is typeof Array; +export declare function isArrayEqual(bytes1: ArrayBuffer, bytes2: ArrayBuffer): boolean; diff --git a/node_modules/@peculiar/asn1-schema/build/types/index.d.ts b/node_modules/@peculiar/asn1-schema/build/types/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6f79b4d3bce6994c51b021117da4debcf05e6ad1 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/types/index.d.ts @@ -0,0 +1,10 @@ +export * from "./converters"; +export * from "./types/index"; +export { AsnProp, AsnType, AsnChoiceType, AsnSequenceType, AsnSetType, } from "./decorators"; +export { AsnTypeTypes, AsnPropTypes } from "./enums"; +export { AsnParser } from "./parser"; +export { AsnSerializer } from "./serializer"; +export { IAsnConverter, IAsnConvertible, IAsnParseOptions, } from "./types"; +export * from "./errors"; +export * from "./objects"; +export * from "./convert"; diff --git a/node_modules/@peculiar/asn1-schema/build/types/objects.d.ts b/node_modules/@peculiar/asn1-schema/build/types/objects.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f57d9f34b9a3593f6a343249af95708622348c8b --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/types/objects.d.ts @@ -0,0 +1,3 @@ +export declare abstract class AsnArray extends Array { + constructor(items?: T[]); +} diff --git a/node_modules/@peculiar/asn1-schema/build/types/parser.d.ts b/node_modules/@peculiar/asn1-schema/build/types/parser.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3bdefe4b92da488f1fdb960aa41135fad2686414 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/types/parser.d.ts @@ -0,0 +1,72 @@ +import * as asn1js from "asn1js"; +import { type BufferSourceLike } from "@peculiar/utils/bytes"; +import { IEmptyConstructor, IAsnParseOptions } from "./types"; +/** + * Deserializes objects from ASN.1 encoded data + */ +export declare class AsnParser { + /** + * Deserializes an object from the ASN.1 encoded buffer + * @param data ASN.1 encoded buffer + * @param target Target schema for object deserialization + */ + static parse(data: BufferSourceLike, target: IEmptyConstructor, options?: IAsnParseOptions): T; + /** + * Deserializes an object from the asn1js object + * @param asn1Schema asn1js object + * @param target Target schema for object deserialization + */ + static fromASN(asn1Schema: asn1js.AsnType, target: IEmptyConstructor, options?: IAsnParseOptions): T; + /** + * Handles Choice types with context tags (IMPLICIT) and IMPLICIT tagging + */ + private static handleChoiceTypes; + /** + * Handles SEQUENCE types with optional CHOICE fields and schema comparison + */ + private static handleSequenceTypes; + /** + * Processes repeated fields in manual mapping + */ + private static processRepeatedField; + /** + * Processes primitive fields in manual mapping + */ + private static processPrimitiveField; + /** + * Checks if a schema item is an optional CHOICE field + */ + private static isOptionalChoiceField; + /** + * Processes optional CHOICE fields in manual mapping + */ + private static processOptionalChoiceField; + /** + * Handles array types + */ + private static handleArrayTypes; + /** + * Processes all schema items + */ + private static processSchemaItems; + /** + * Processes primitive schema items + */ + private static processPrimitiveSchemaItem; + /** + * Processes repeated primitive items + */ + private static processRepeatedPrimitiveItem; + /** + * Processes single primitive items + */ + private static processSinglePrimitiveItem; + /** + * Processes complex schema items (SEQUENCE, SET, CHOICE) + */ + private static processComplexSchemaItem; + /** + * Handles IMPLICIT tagging for complex types + */ + private static handleImplicitTagging; +} diff --git a/node_modules/@peculiar/asn1-schema/build/types/schema.d.ts b/node_modules/@peculiar/asn1-schema/build/types/schema.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d73c30d23ba02f831c20321d256cfdae36b9bbd9 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/types/schema.d.ts @@ -0,0 +1,32 @@ +import * as asn1js from "asn1js"; +import { AsnRepeatType } from "./decorators"; +import { AsnPropTypes, AsnTypeTypes } from "./enums"; +import { IAsnConverter, IEmptyConstructor } from "./types"; +export interface IAsnSchemaItem { + type: AsnPropTypes | IEmptyConstructor; + optional?: boolean; + defaultValue?: unknown; + context?: number; + implicit?: boolean; + converter?: IAsnConverter; + repeated?: AsnRepeatType; + raw?: boolean; +} +export interface IAsnSchema { + type: AsnTypeTypes; + itemType: AsnPropTypes | IEmptyConstructor; + items: Record; + schema?: AsnSchemaType; +} +export type AsnSchemaType = asn1js.Sequence | asn1js.Set | asn1js.Choice; +export declare class AsnSchemaStorage { + protected items: WeakMap; + has(target: object): boolean; + get(target: IEmptyConstructor, checkSchema: true): IAsnSchema & Required>; + get(target: IEmptyConstructor, checkSchema?: false): IAsnSchema; + cache(target: IEmptyConstructor): void; + createDefault(target: object): IAsnSchema; + create(target: object, useNames: boolean): AsnSchemaType; + set(target: object, schema: IAsnSchema): this; + protected findParentSchema(target: object): IAsnSchema | null; +} diff --git a/node_modules/@peculiar/asn1-schema/build/types/serializer.d.ts b/node_modules/@peculiar/asn1-schema/build/types/serializer.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9405252ce214d68e07061626f549ccd77f8f6b52 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/types/serializer.d.ts @@ -0,0 +1,17 @@ +import * as asn1js from "asn1js"; +/** + * Serializes objects into ASN.1 encoded data + */ +export declare class AsnSerializer { + /** + * Serializes an object to the ASN.1 encoded buffer + * @param obj The object to serialize + */ + static serialize(obj: unknown): ArrayBuffer; + /** + * Serialize an object to the asn1js object + * @param obj The object to serialize + */ + static toASN(obj: unknown): asn1js.AsnType; + private static toAsnItem; +} diff --git a/node_modules/@peculiar/asn1-schema/build/types/storage.d.ts b/node_modules/@peculiar/asn1-schema/build/types/storage.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4be1aa4d334aa4ea0cc125406656077032b7c765 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/types/storage.d.ts @@ -0,0 +1,2 @@ +import { AsnSchemaStorage } from "./schema"; +export declare const schemaStorage: AsnSchemaStorage; diff --git a/node_modules/@peculiar/asn1-schema/build/types/types.d.ts b/node_modules/@peculiar/asn1-schema/build/types/types.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d5eae256a6a38aed6838a299d3010a7b5e3a91f7 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/types/types.d.ts @@ -0,0 +1,42 @@ +/** + * ASN1 type + */ +import * as asn1js from "asn1js"; +export type IEmptyConstructor = new () => T; +/** + * Options for parsing ASN.1 encoded data + */ +export interface IAsnParseOptions { + /** + * Resource limits forwarded to `asn1js.fromBER` for untrusted input + * (`maxDepth`, `maxNodes`, `maxContentLength`). When omitted, the asn1js + * defaults apply (maxDepth: 100, maxNodes: 10000, maxContentLength: 16MB). + */ + berOptions?: asn1js.FromBerOptions; +} +/** + * Allows to convert ASN.1 object to JS value and back + */ +export interface IAsnConverter { + /** + * Returns JS value from ASN.1 object + * @param value ASN.1 object from asn1js module + */ + fromASN(value: AsnType): T; + /** + * Returns ASN.1 object from JS value + * @param value JS value + */ + toASN(value: T): AsnType; +} +export type IntegerConverterType = string | number; +export type AnyConverterType = ArrayBuffer | null; +/** + * Allows an object to control its own ASN.1 serialization and deserialization + */ +export interface IAsnConvertible { + fromASN(asn: T): this; + toASN(): T; + toSchema(name: string): asn1js.BaseBlock; +} +export type IAsnConvertibleConstructor = new () => IAsnConvertible; diff --git a/node_modules/@peculiar/asn1-schema/build/types/types/bit_string.d.ts b/node_modules/@peculiar/asn1-schema/build/types/types/bit_string.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c253b96bffa13a17cb7a978abefb3577e84e704b --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/types/types/bit_string.d.ts @@ -0,0 +1,15 @@ +import * as asn1js from "asn1js"; +import { type BufferSourceLike } from "@peculiar/utils/bytes"; +import { IAsnConvertible } from "../types"; +export declare class BitString implements IAsnConvertible { + unusedBits: number; + value: ArrayBuffer; + constructor(); + constructor(value: T); + constructor(value: BufferSourceLike, unusedBits?: number); + fromASN(asn: asn1js.BitString): this; + toASN(): asn1js.BitString; + toSchema(name: string): asn1js.BitString; + toNumber(): T; + fromNumber(value: T): void; +} diff --git a/node_modules/@peculiar/asn1-schema/build/types/types/index.d.ts b/node_modules/@peculiar/asn1-schema/build/types/types/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..28ceb718e496eba2e7be43f95ac2fe541796da78 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/types/types/index.d.ts @@ -0,0 +1,2 @@ +export * from "./bit_string"; +export * from "./octet_string"; diff --git a/node_modules/@peculiar/asn1-schema/build/types/types/octet_string.d.ts b/node_modules/@peculiar/asn1-schema/build/types/types/octet_string.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2b6feb0daa45111d70e3bbbeadbe16325bad83ab --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/build/types/types/octet_string.d.ts @@ -0,0 +1,15 @@ +import * as asn1js from "asn1js"; +import { BufferSourceLike } from "@peculiar/utils/bytes"; +import { IAsnConvertible } from "../types"; +export declare class OctetString implements IAsnConvertible, ArrayBufferView { + buffer: ArrayBuffer; + get byteLength(): number; + get byteOffset(): number; + constructor(); + constructor(byteLength: number); + constructor(bytes: number[]); + constructor(bytes: BufferSourceLike); + fromASN(asn: asn1js.OctetString): this; + toASN(): asn1js.OctetString; + toSchema(name: string): asn1js.OctetString; +} diff --git a/node_modules/@peculiar/asn1-schema/package.json b/node_modules/@peculiar/asn1-schema/package.json new file mode 100644 index 0000000000000000000000000000000000000000..e072a98c5720694ec1b4bf53776eff7593a53952 --- /dev/null +++ b/node_modules/@peculiar/asn1-schema/package.json @@ -0,0 +1,71 @@ +{ + "name": "@peculiar/asn1-schema", + "version": "2.8.0", + "description": "Decorators and helper APIs for declaring ASN.1 schemas in TypeScript.", + "keywords": [ + "asn", + "asn1", + "schema", + "serialize", + "parse", + "decorator", + "der" + ], + "author": "PeculiarVentures, LLC", + "license": "MIT", + "files": [ + "build/**/*.{js,d.ts}", + "build/es2015/package.json", + "LICENSE", + "README.md" + ], + "main": "build/cjs/index.js", + "module": "build/es2015/index.js", + "types": "build/types/index.d.ts", + "exports": { + ".": { + "types": "./build/types/index.d.ts", + "import": "./build/es2015/index.js", + "require": "./build/cjs/index.js" + }, + "./package.json": "./package.json" + }, + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "https://github.com/PeculiarVentures/asn1-schema", + "directory": "packages/schema" + }, + "bugs": { + "url": "https://github.com/PeculiarVentures/asn1-schema/issues" + }, + "homepage": "https://github.com/PeculiarVentures/asn1-schema/tree/master/packages/schema#readme", + "scripts": { + "clear": "rimraf build", + "build": "npm run build:module && npm run build:types", + "build:module": "npm run build:cjs && npm run build:es2015", + "build:cjs": "tsc -p tsconfig.compile.json --removeComments --module commonjs --outDir build/cjs", + "build:es2015": "tsc -p tsconfig.compile.json --removeComments --module ES2015 --outDir build/es2015", + "postbuild:es2015": "node ../../scripts/prepare_esm_package.mjs build/es2015", + "prebuild:types": "rimraf build/types", + "build:types": "tsc -p tsconfig.compile.json --outDir build/types --declaration --emitDeclarationOnly", + "rebuild": "npm run clear && npm run build" + }, + "dependencies": { + "@peculiar/utils": "^2.0.2", + "asn1js": "^3.0.10", + "tslib": "^2.8.1" + }, + "contributors": [ + { + "email": "rmh@unmitigatedrisk.com", + "name": "Ryan Hurst" + }, + { + "email": "microshine@mail.ru", + "name": "Miroshin Stepan" + } + ] +} diff --git a/node_modules/@peculiar/asn1-x509-attr/LICENSE b/node_modules/@peculiar/asn1-x509-attr/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..43675934676182bb2368abb1a371722a830453eb --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@peculiar/asn1-x509-attr/README.md b/node_modules/@peculiar/asn1-x509-attr/README.md new file mode 100644 index 0000000000000000000000000000000000000000..33f1bfd83eacbd141c10d33f59af88e0e97475cf --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/README.md @@ -0,0 +1,20 @@ +# `@peculiar/asn1-x509-attr` + +[![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/PeculiarVentures/asn1-schema/blob/master/packages/x509-attr/LICENSE) +[![npm version](https://badge.fury.io/js/%40peculiar%2Fasn1-x509-attr.svg)](https://badge.fury.io/js/%40peculiar%2Fasn1-x509-attr) + +[![NPM](https://nodei.co/npm/@peculiar/asn1-x509-attr.png)](https://nodei.co/npm/@peculiar/asn1-x509-attr/) + +ASN.1 schema for X.509 attribute certificates defined in RFC 5755. + +Use the exported classes with `@peculiar/asn1-schema` helpers such as `AsnConvert`, `AsnParser`, and `AsnSerializer` to parse or serialize DER-encoded data defined by the referenced specification. + +## Installation + +```bash +npm install @peculiar/asn1-x509-attr +``` + +## Specifications + +- [RFC 5755: An Internet Attribute Certificate Profile for Authorization](https://datatracker.ietf.org/doc/html/rfc5755) diff --git a/node_modules/@peculiar/asn1-x509-attr/build/cjs/aa_clear_attrs.js b/node_modules/@peculiar/asn1-x509-attr/build/cjs/aa_clear_attrs.js new file mode 100644 index 0000000000000000000000000000000000000000..8de5fb4a1154841598deb1e3cf6cd689413c24dd --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/cjs/aa_clear_attrs.js @@ -0,0 +1,26 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ACClearAttrs = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +class ACClearAttrs { + acIssuer = new asn1_x509_1.GeneralName(); + acSerial = 0; + attrs = []; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.ACClearAttrs = ACClearAttrs; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_x509_1.GeneralName }) +], ACClearAttrs.prototype, "acIssuer", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer }) +], ACClearAttrs.prototype, "acSerial", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_x509_1.Attribute, repeated: "sequence", + }) +], ACClearAttrs.prototype, "attrs", void 0); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/cjs/aa_controls.js b/node_modules/@peculiar/asn1-x509-attr/build/cjs/aa_controls.js new file mode 100644 index 0000000000000000000000000000000000000000..a26d66ca055c090826a36139155919504368136e --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/cjs/aa_controls.js @@ -0,0 +1,36 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AAControls = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const attr_spec_1 = require("./attr_spec"); +class AAControls { + pathLenConstraint; + permittedAttrs; + excludedAttrs; + permitUnSpecified = true; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.AAControls = AAControls; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, optional: true, + }) +], AAControls.prototype, "pathLenConstraint", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: attr_spec_1.AttrSpec, implicit: true, context: 0, optional: true, + }) +], AAControls.prototype, "permittedAttrs", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: attr_spec_1.AttrSpec, implicit: true, context: 1, optional: true, + }) +], AAControls.prototype, "excludedAttrs", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Boolean, defaultValue: true, + }) +], AAControls.prototype, "permitUnSpecified", void 0); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/cjs/attr_cert_issuer.js b/node_modules/@peculiar/asn1-x509-attr/build/cjs/attr_cert_issuer.js new file mode 100644 index 0000000000000000000000000000000000000000..ea43bbf955b657e8d1224ed9ba71b592ac2d3ef7 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/cjs/attr_cert_issuer.js @@ -0,0 +1,28 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AttCertIssuer = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +const v2_form_1 = require("./v2_form"); +let AttCertIssuer = class AttCertIssuer { + v1Form; + v2Form; + constructor(params = {}) { + Object.assign(this, params); + } +}; +exports.AttCertIssuer = AttCertIssuer; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_x509_1.GeneralName, repeated: "sequence", + }) +], AttCertIssuer.prototype, "v1Form", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: v2_form_1.V2Form, context: 0, implicit: true, + }) +], AttCertIssuer.prototype, "v2Form", void 0); +exports.AttCertIssuer = AttCertIssuer = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], AttCertIssuer); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/cjs/attr_cert_validity_period.js b/node_modules/@peculiar/asn1-x509-attr/build/cjs/attr_cert_validity_period.js new file mode 100644 index 0000000000000000000000000000000000000000..a640dd402fc196161d6d014eb5ef6b180b0c2b04 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/cjs/attr_cert_validity_period.js @@ -0,0 +1,19 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AttCertValidityPeriod = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +class AttCertValidityPeriod { + notBeforeTime = new Date(); + notAfterTime = new Date(); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.AttCertValidityPeriod = AttCertValidityPeriod; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.GeneralizedTime }) +], AttCertValidityPeriod.prototype, "notBeforeTime", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.GeneralizedTime }) +], AttCertValidityPeriod.prototype, "notAfterTime", void 0); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/cjs/attr_spec.js b/node_modules/@peculiar/asn1-x509-attr/build/cjs/attr_spec.js new file mode 100644 index 0000000000000000000000000000000000000000..27bff3ce6581520bef859b2bcedf0471442a5702 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/cjs/attr_spec.js @@ -0,0 +1,18 @@ +"use strict"; +var AttrSpec_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AttrSpec = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +let AttrSpec = AttrSpec_1 = class AttrSpec extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, AttrSpec_1.prototype); + } +}; +exports.AttrSpec = AttrSpec; +exports.AttrSpec = AttrSpec = AttrSpec_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Sequence, itemType: asn1_schema_1.AsnPropTypes.ObjectIdentifier, + }) +], AttrSpec); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/cjs/attribute_certificate.js b/node_modules/@peculiar/asn1-x509-attr/build/cjs/attribute_certificate.js new file mode 100644 index 0000000000000000000000000000000000000000..9686fdd112cb8f3ea403228b12ef6e3ac6101a32 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/cjs/attribute_certificate.js @@ -0,0 +1,25 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AttributeCertificate = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +const attribute_certificate_info_1 = require("./attribute_certificate_info"); +class AttributeCertificate { + acinfo = new attribute_certificate_info_1.AttributeCertificateInfo(); + signatureAlgorithm = new asn1_x509_1.AlgorithmIdentifier(); + signatureValue = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.AttributeCertificate = AttributeCertificate; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: attribute_certificate_info_1.AttributeCertificateInfo }) +], AttributeCertificate.prototype, "acinfo", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_x509_1.AlgorithmIdentifier }) +], AttributeCertificate.prototype, "signatureAlgorithm", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.BitString }) +], AttributeCertificate.prototype, "signatureValue", void 0); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/cjs/attribute_certificate_info.js b/node_modules/@peculiar/asn1-x509-attr/build/cjs/attribute_certificate_info.js new file mode 100644 index 0000000000000000000000000000000000000000..b5ccd748312f16a0de9b21941f89417c4e8ef861 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/cjs/attribute_certificate_info.js @@ -0,0 +1,63 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AttributeCertificateInfo = exports.AttCertVersion = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +const holder_1 = require("./holder"); +const attr_cert_issuer_1 = require("./attr_cert_issuer"); +const attr_cert_validity_period_1 = require("./attr_cert_validity_period"); +var AttCertVersion; +(function (AttCertVersion) { + AttCertVersion[AttCertVersion["v2"] = 1] = "v2"; +})(AttCertVersion || (exports.AttCertVersion = AttCertVersion = {})); +class AttributeCertificateInfo { + version = AttCertVersion.v2; + holder = new holder_1.Holder(); + issuer = new attr_cert_issuer_1.AttCertIssuer(); + signature = new asn1_x509_1.AlgorithmIdentifier(); + serialNumber = new ArrayBuffer(0); + attrCertValidityPeriod = new attr_cert_validity_period_1.AttCertValidityPeriod(); + attributes = []; + issuerUniqueID; + extensions; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.AttributeCertificateInfo = AttributeCertificateInfo; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer }) +], AttributeCertificateInfo.prototype, "version", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: holder_1.Holder }) +], AttributeCertificateInfo.prototype, "holder", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: attr_cert_issuer_1.AttCertIssuer }) +], AttributeCertificateInfo.prototype, "issuer", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_x509_1.AlgorithmIdentifier }) +], AttributeCertificateInfo.prototype, "signature", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter, + }) +], AttributeCertificateInfo.prototype, "serialNumber", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: attr_cert_validity_period_1.AttCertValidityPeriod }) +], AttributeCertificateInfo.prototype, "attrCertValidityPeriod", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_x509_1.Attribute, repeated: "sequence", + }) +], AttributeCertificateInfo.prototype, "attributes", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.BitString, optional: true, + }) +], AttributeCertificateInfo.prototype, "issuerUniqueID", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_x509_1.Extensions, optional: true, + }) +], AttributeCertificateInfo.prototype, "extensions", void 0); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/cjs/class_list.js b/node_modules/@peculiar/asn1-x509-attr/build/cjs/class_list.js new file mode 100644 index 0000000000000000000000000000000000000000..708778bfe44a5726fb8631d093374587a2a8e37b --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/cjs/class_list.js @@ -0,0 +1,16 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ClassList = exports.ClassListFlags = void 0; +const asn1_schema_1 = require("@peculiar/asn1-schema"); +var ClassListFlags; +(function (ClassListFlags) { + ClassListFlags[ClassListFlags["unmarked"] = 1] = "unmarked"; + ClassListFlags[ClassListFlags["unclassified"] = 2] = "unclassified"; + ClassListFlags[ClassListFlags["restricted"] = 4] = "restricted"; + ClassListFlags[ClassListFlags["confidential"] = 8] = "confidential"; + ClassListFlags[ClassListFlags["secret"] = 16] = "secret"; + ClassListFlags[ClassListFlags["topSecret"] = 32] = "topSecret"; +})(ClassListFlags || (exports.ClassListFlags = ClassListFlags = {})); +class ClassList extends asn1_schema_1.BitString { +} +exports.ClassList = ClassList; diff --git a/node_modules/@peculiar/asn1-x509-attr/build/cjs/clearance.js b/node_modules/@peculiar/asn1-x509-attr/build/cjs/clearance.js new file mode 100644 index 0000000000000000000000000000000000000000..bbe5c7a960da7c9afe36a9990dd29e053ccc2998 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/cjs/clearance.js @@ -0,0 +1,29 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Clearance = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const class_list_1 = require("./class_list"); +const security_category_1 = require("./security_category"); +class Clearance { + policyId = ""; + classList = new class_list_1.ClassList(class_list_1.ClassListFlags.unclassified); + securityCategories; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.Clearance = Clearance; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.ObjectIdentifier }) +], Clearance.prototype, "policyId", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: class_list_1.ClassList, defaultValue: new class_list_1.ClassList(class_list_1.ClassListFlags.unclassified), + }) +], Clearance.prototype, "classList", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: security_category_1.SecurityCategory, repeated: "set", + }) +], Clearance.prototype, "securityCategories", void 0); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/cjs/holder.js b/node_modules/@peculiar/asn1-x509-attr/build/cjs/holder.js new file mode 100644 index 0000000000000000000000000000000000000000..f1dbbd87af5296b8d12c81c67a814450f347b7ce --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/cjs/holder.js @@ -0,0 +1,32 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Holder = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +const issuer_serial_1 = require("./issuer_serial"); +const object_digest_info_1 = require("./object_digest_info"); +class Holder { + baseCertificateID; + entityName; + objectDigestInfo; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.Holder = Holder; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: issuer_serial_1.IssuerSerial, implicit: true, context: 0, optional: true, + }) +], Holder.prototype, "baseCertificateID", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_x509_1.GeneralNames, implicit: true, context: 1, optional: true, + }) +], Holder.prototype, "entityName", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: object_digest_info_1.ObjectDigestInfo, implicit: true, context: 2, optional: true, + }) +], Holder.prototype, "objectDigestInfo", void 0); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/cjs/ietf_attr_syntax.js b/node_modules/@peculiar/asn1-x509-attr/build/cjs/ietf_attr_syntax.js new file mode 100644 index 0000000000000000000000000000000000000000..fabeaaea299596881af703f01d040f5456ac2eb9 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/cjs/ietf_attr_syntax.js @@ -0,0 +1,42 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.IetfAttrSyntax = exports.IetfAttrSyntaxValueChoices = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +class IetfAttrSyntaxValueChoices { + cotets; + oid; + string; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.IetfAttrSyntaxValueChoices = IetfAttrSyntaxValueChoices; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.OctetString }) +], IetfAttrSyntaxValueChoices.prototype, "cotets", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.ObjectIdentifier }) +], IetfAttrSyntaxValueChoices.prototype, "oid", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Utf8String }) +], IetfAttrSyntaxValueChoices.prototype, "string", void 0); +class IetfAttrSyntax { + policyAuthority; + values = []; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.IetfAttrSyntax = IetfAttrSyntax; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_x509_1.GeneralNames, implicit: true, context: 0, optional: true, + }) +], IetfAttrSyntax.prototype, "policyAuthority", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: IetfAttrSyntaxValueChoices, repeated: "sequence", + }) +], IetfAttrSyntax.prototype, "values", void 0); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/cjs/index.js b/node_modules/@peculiar/asn1-x509-attr/build/cjs/index.js new file mode 100644 index 0000000000000000000000000000000000000000..70a4b771151790b7d83779958559b7d2e48eb0c3 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/cjs/index.js @@ -0,0 +1,23 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +tslib_1.__exportStar(require("./aa_clear_attrs"), exports); +tslib_1.__exportStar(require("./aa_controls"), exports); +tslib_1.__exportStar(require("./attr_cert_issuer"), exports); +tslib_1.__exportStar(require("./attr_cert_validity_period"), exports); +tslib_1.__exportStar(require("./attr_spec"), exports); +tslib_1.__exportStar(require("./attribute_certificate"), exports); +tslib_1.__exportStar(require("./attribute_certificate_info"), exports); +tslib_1.__exportStar(require("./class_list"), exports); +tslib_1.__exportStar(require("./clearance"), exports); +tslib_1.__exportStar(require("./holder"), exports); +tslib_1.__exportStar(require("./ietf_attr_syntax"), exports); +tslib_1.__exportStar(require("./issuer_serial"), exports); +tslib_1.__exportStar(require("./object_digest_info"), exports); +tslib_1.__exportStar(require("./object_identifiers"), exports); +tslib_1.__exportStar(require("./proxy_info"), exports); +tslib_1.__exportStar(require("./role_syntax"), exports); +tslib_1.__exportStar(require("./security_category"), exports); +tslib_1.__exportStar(require("./svce_auth_info"), exports); +tslib_1.__exportStar(require("./target"), exports); +tslib_1.__exportStar(require("./v2_form"), exports); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/cjs/issuer_serial.js b/node_modules/@peculiar/asn1-x509-attr/build/cjs/issuer_serial.js new file mode 100644 index 0000000000000000000000000000000000000000..be3af81be034008276fb9520654a55127073c191 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/cjs/issuer_serial.js @@ -0,0 +1,28 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.IssuerSerial = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +class IssuerSerial { + issuer = new asn1_x509_1.GeneralNames(); + serial = new ArrayBuffer(0); + issuerUID = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.IssuerSerial = IssuerSerial; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_x509_1.GeneralNames }) +], IssuerSerial.prototype, "issuer", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter, + }) +], IssuerSerial.prototype, "serial", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.BitString, optional: true, + }) +], IssuerSerial.prototype, "issuerUID", void 0); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/cjs/object_digest_info.js b/node_modules/@peculiar/asn1-x509-attr/build/cjs/object_digest_info.js new file mode 100644 index 0000000000000000000000000000000000000000..68544a6e0b9a81eb422aa0f09c3878bbf3b49574 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/cjs/object_digest_info.js @@ -0,0 +1,36 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ObjectDigestInfo = exports.DigestedObjectType = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +var DigestedObjectType; +(function (DigestedObjectType) { + DigestedObjectType[DigestedObjectType["publicKey"] = 0] = "publicKey"; + DigestedObjectType[DigestedObjectType["publicKeyCert"] = 1] = "publicKeyCert"; + DigestedObjectType[DigestedObjectType["otherObjectTypes"] = 2] = "otherObjectTypes"; +})(DigestedObjectType || (exports.DigestedObjectType = DigestedObjectType = {})); +class ObjectDigestInfo { + digestedObjectType = DigestedObjectType.publicKey; + otherObjectTypeID; + digestAlgorithm = new asn1_x509_1.AlgorithmIdentifier(); + objectDigest = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.ObjectDigestInfo = ObjectDigestInfo; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Enumerated }) +], ObjectDigestInfo.prototype, "digestedObjectType", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.ObjectIdentifier, optional: true, + }) +], ObjectDigestInfo.prototype, "otherObjectTypeID", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_x509_1.AlgorithmIdentifier }) +], ObjectDigestInfo.prototype, "digestAlgorithm", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.BitString }) +], ObjectDigestInfo.prototype, "objectDigest", void 0); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/cjs/object_identifiers.js b/node_modules/@peculiar/asn1-x509-attr/build/cjs/object_identifiers.js new file mode 100644 index 0000000000000000000000000000000000000000..1f6d8543e9e751dc4ce13ab7a4fe22960e377227 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/cjs/object_identifiers.js @@ -0,0 +1,17 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.id_at_clearance = exports.id_at_role = exports.id_at = exports.id_aca_encAttrs = exports.id_aca_group = exports.id_aca_chargingIdentity = exports.id_aca_accessIdentity = exports.id_aca_authenticationInfo = exports.id_aca = exports.id_ce_targetInformation = exports.id_pe_ac_proxying = exports.id_pe_aaControls = exports.id_pe_ac_auditIdentity = void 0; +const asn1_x509_1 = require("@peculiar/asn1-x509"); +exports.id_pe_ac_auditIdentity = `${asn1_x509_1.id_pe}.4`; +exports.id_pe_aaControls = `${asn1_x509_1.id_pe}.6`; +exports.id_pe_ac_proxying = `${asn1_x509_1.id_pe}.10`; +exports.id_ce_targetInformation = `${asn1_x509_1.id_ce}.55`; +exports.id_aca = `${asn1_x509_1.id_pkix}.10`; +exports.id_aca_authenticationInfo = `${exports.id_aca}.1`; +exports.id_aca_accessIdentity = `${exports.id_aca}.2`; +exports.id_aca_chargingIdentity = `${exports.id_aca}.3`; +exports.id_aca_group = `${exports.id_aca}.4`; +exports.id_aca_encAttrs = `${exports.id_aca}.6`; +exports.id_at = "2.5.4"; +exports.id_at_role = `${exports.id_at}.72`; +exports.id_at_clearance = "2.5.1.5.55"; diff --git a/node_modules/@peculiar/asn1-x509-attr/build/cjs/proxy_info.js b/node_modules/@peculiar/asn1-x509-attr/build/cjs/proxy_info.js new file mode 100644 index 0000000000000000000000000000000000000000..18a678fe79dc9bda6e77210a566b6b6c8682b515 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/cjs/proxy_info.js @@ -0,0 +1,19 @@ +"use strict"; +var ProxyInfo_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ProxyInfo = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const target_1 = require("./target"); +let ProxyInfo = ProxyInfo_1 = class ProxyInfo extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, ProxyInfo_1.prototype); + } +}; +exports.ProxyInfo = ProxyInfo; +exports.ProxyInfo = ProxyInfo = ProxyInfo_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Sequence, itemType: target_1.Targets, + }) +], ProxyInfo); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/cjs/role_syntax.js b/node_modules/@peculiar/asn1-x509-attr/build/cjs/role_syntax.js new file mode 100644 index 0000000000000000000000000000000000000000..51924f65cc1e17530de462ddbb45921631167bf3 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/cjs/role_syntax.js @@ -0,0 +1,24 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.RoleSyntax = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +class RoleSyntax { + roleAuthority; + roleName; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.RoleSyntax = RoleSyntax; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_x509_1.GeneralNames, implicit: true, context: 0, optional: true, + }) +], RoleSyntax.prototype, "roleAuthority", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_x509_1.GeneralName, implicit: true, context: 1, + }) +], RoleSyntax.prototype, "roleName", void 0); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/cjs/security_category.js b/node_modules/@peculiar/asn1-x509-attr/build/cjs/security_category.js new file mode 100644 index 0000000000000000000000000000000000000000..0ff5e46aa5e7bfcc1c9a7ee0e18397d073d62787 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/cjs/security_category.js @@ -0,0 +1,23 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SecurityCategory = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +class SecurityCategory { + type = ""; + value = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.SecurityCategory = SecurityCategory; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.ObjectIdentifier, implicit: true, context: 0, + }) +], SecurityCategory.prototype, "type", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Any, implicit: true, context: 1, + }) +], SecurityCategory.prototype, "value", void 0); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/cjs/svce_auth_info.js b/node_modules/@peculiar/asn1-x509-attr/build/cjs/svce_auth_info.js new file mode 100644 index 0000000000000000000000000000000000000000..9606dcbb133423298d98fb222b223075ae253600 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/cjs/svce_auth_info.js @@ -0,0 +1,26 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SvceAuthInfo = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +class SvceAuthInfo { + service = new asn1_x509_1.GeneralName(); + ident = new asn1_x509_1.GeneralName(); + authInfo; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.SvceAuthInfo = SvceAuthInfo; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_x509_1.GeneralName }) +], SvceAuthInfo.prototype, "service", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_x509_1.GeneralName }) +], SvceAuthInfo.prototype, "ident", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.OctetString, optional: true, + }) +], SvceAuthInfo.prototype, "authInfo", void 0); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/cjs/target.js b/node_modules/@peculiar/asn1-x509-attr/build/cjs/target.js new file mode 100644 index 0000000000000000000000000000000000000000..d0d5742836061861c45dcf2d0faec046a259cd01 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/cjs/target.js @@ -0,0 +1,70 @@ +"use strict"; +var Targets_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Targets = exports.Target = exports.TargetCert = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +const issuer_serial_1 = require("./issuer_serial"); +const object_digest_info_1 = require("./object_digest_info"); +class TargetCert { + targetCertificate = new issuer_serial_1.IssuerSerial(); + targetName; + certDigestInfo; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.TargetCert = TargetCert; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: issuer_serial_1.IssuerSerial }) +], TargetCert.prototype, "targetCertificate", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_x509_1.GeneralName, optional: true, + }) +], TargetCert.prototype, "targetName", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: object_digest_info_1.ObjectDigestInfo, optional: true, + }) +], TargetCert.prototype, "certDigestInfo", void 0); +let Target = class Target { + targetName; + targetGroup; + targetCert; + constructor(params = {}) { + Object.assign(this, params); + } +}; +exports.Target = Target; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_x509_1.GeneralName, context: 0, implicit: true, + }) +], Target.prototype, "targetName", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_x509_1.GeneralName, context: 1, implicit: true, + }) +], Target.prototype, "targetGroup", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: TargetCert, context: 2, implicit: true, + }) +], Target.prototype, "targetCert", void 0); +exports.Target = Target = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], Target); +let Targets = Targets_1 = class Targets extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, Targets_1.prototype); + } +}; +exports.Targets = Targets; +exports.Targets = Targets = Targets_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Sequence, itemType: Target, + }) +], Targets); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/cjs/v2_form.js b/node_modules/@peculiar/asn1-x509-attr/build/cjs/v2_form.js new file mode 100644 index 0000000000000000000000000000000000000000..96bb81070d7f3added666c5007a288b286b83c84 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/cjs/v2_form.js @@ -0,0 +1,32 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.V2Form = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +const issuer_serial_1 = require("./issuer_serial"); +const object_digest_info_1 = require("./object_digest_info"); +class V2Form { + issuerName; + baseCertificateID; + objectDigestInfo; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.V2Form = V2Form; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_x509_1.GeneralNames, optional: true, + }) +], V2Form.prototype, "issuerName", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: issuer_serial_1.IssuerSerial, context: 0, implicit: true, optional: true, + }) +], V2Form.prototype, "baseCertificateID", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: object_digest_info_1.ObjectDigestInfo, context: 1, implicit: true, optional: true, + }) +], V2Form.prototype, "objectDigestInfo", void 0); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/es2015/aa_clear_attrs.js b/node_modules/@peculiar/asn1-x509-attr/build/es2015/aa_clear_attrs.js new file mode 100644 index 0000000000000000000000000000000000000000..94b01a5e450a20684a65cbb07dccd401c4de9a0b --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/es2015/aa_clear_attrs.js @@ -0,0 +1,22 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes } from "@peculiar/asn1-schema"; +import { GeneralName, Attribute } from "@peculiar/asn1-x509"; +export class ACClearAttrs { + acIssuer = new GeneralName(); + acSerial = 0; + attrs = []; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: GeneralName }) +], ACClearAttrs.prototype, "acIssuer", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.Integer }) +], ACClearAttrs.prototype, "acSerial", void 0); +__decorate([ + AsnProp({ + type: Attribute, repeated: "sequence", + }) +], ACClearAttrs.prototype, "attrs", void 0); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/es2015/aa_controls.js b/node_modules/@peculiar/asn1-x509-attr/build/es2015/aa_controls.js new file mode 100644 index 0000000000000000000000000000000000000000..cc56f6aea9c50da7b948ab1a4a61ad6447facbe3 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/es2015/aa_controls.js @@ -0,0 +1,32 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes } from "@peculiar/asn1-schema"; +import { AttrSpec } from "./attr_spec.js"; +export class AAControls { + pathLenConstraint; + permittedAttrs; + excludedAttrs; + permitUnSpecified = true; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, optional: true, + }) +], AAControls.prototype, "pathLenConstraint", void 0); +__decorate([ + AsnProp({ + type: AttrSpec, implicit: true, context: 0, optional: true, + }) +], AAControls.prototype, "permittedAttrs", void 0); +__decorate([ + AsnProp({ + type: AttrSpec, implicit: true, context: 1, optional: true, + }) +], AAControls.prototype, "excludedAttrs", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Boolean, defaultValue: true, + }) +], AAControls.prototype, "permitUnSpecified", void 0); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/es2015/attr_cert_issuer.js b/node_modules/@peculiar/asn1-x509-attr/build/es2015/attr_cert_issuer.js new file mode 100644 index 0000000000000000000000000000000000000000..309b45cc6d2dcf1fa3576a61bad9ef3c370201f0 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/es2015/attr_cert_issuer.js @@ -0,0 +1,25 @@ +import { __decorate } from "tslib"; +import { AsnType, AsnTypeTypes, AsnProp, } from "@peculiar/asn1-schema"; +import { GeneralName } from "@peculiar/asn1-x509"; +import { V2Form } from "./v2_form.js"; +let AttCertIssuer = class AttCertIssuer { + v1Form; + v2Form; + constructor(params = {}) { + Object.assign(this, params); + } +}; +__decorate([ + AsnProp({ + type: GeneralName, repeated: "sequence", + }) +], AttCertIssuer.prototype, "v1Form", void 0); +__decorate([ + AsnProp({ + type: V2Form, context: 0, implicit: true, + }) +], AttCertIssuer.prototype, "v2Form", void 0); +AttCertIssuer = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], AttCertIssuer); +export { AttCertIssuer }; diff --git a/node_modules/@peculiar/asn1-x509-attr/build/es2015/attr_cert_validity_period.js b/node_modules/@peculiar/asn1-x509-attr/build/es2015/attr_cert_validity_period.js new file mode 100644 index 0000000000000000000000000000000000000000..9e50c484264279115f9630c4ae32507f3ab0298a --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/es2015/attr_cert_validity_period.js @@ -0,0 +1,15 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes } from "@peculiar/asn1-schema"; +export class AttCertValidityPeriod { + notBeforeTime = new Date(); + notAfterTime = new Date(); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.GeneralizedTime }) +], AttCertValidityPeriod.prototype, "notBeforeTime", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.GeneralizedTime }) +], AttCertValidityPeriod.prototype, "notAfterTime", void 0); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/es2015/attr_spec.js b/node_modules/@peculiar/asn1-x509-attr/build/es2015/attr_spec.js new file mode 100644 index 0000000000000000000000000000000000000000..61325bb731b573c6e634c9e8a1f01f8bf1fd486e --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/es2015/attr_spec.js @@ -0,0 +1,15 @@ +var AttrSpec_1; +import { __decorate } from "tslib"; +import { AsnType, AsnTypeTypes, AsnPropTypes, AsnArray, } from "@peculiar/asn1-schema"; +let AttrSpec = AttrSpec_1 = class AttrSpec extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, AttrSpec_1.prototype); + } +}; +AttrSpec = AttrSpec_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Sequence, itemType: AsnPropTypes.ObjectIdentifier, + }) +], AttrSpec); +export { AttrSpec }; diff --git a/node_modules/@peculiar/asn1-x509-attr/build/es2015/attribute_certificate.js b/node_modules/@peculiar/asn1-x509-attr/build/es2015/attribute_certificate.js new file mode 100644 index 0000000000000000000000000000000000000000..83b65fc75a5a407ee3c206519bfc5b942b736f86 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/es2015/attribute_certificate.js @@ -0,0 +1,21 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes } from "@peculiar/asn1-schema"; +import { AlgorithmIdentifier } from "@peculiar/asn1-x509"; +import { AttributeCertificateInfo } from "./attribute_certificate_info.js"; +export class AttributeCertificate { + acinfo = new AttributeCertificateInfo(); + signatureAlgorithm = new AlgorithmIdentifier(); + signatureValue = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AttributeCertificateInfo }) +], AttributeCertificate.prototype, "acinfo", void 0); +__decorate([ + AsnProp({ type: AlgorithmIdentifier }) +], AttributeCertificate.prototype, "signatureAlgorithm", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.BitString }) +], AttributeCertificate.prototype, "signatureValue", void 0); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/es2015/attribute_certificate_info.js b/node_modules/@peculiar/asn1-x509-attr/build/es2015/attribute_certificate_info.js new file mode 100644 index 0000000000000000000000000000000000000000..df38ab735ce37d0f0b8bdb8525c927ab1108829b --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/es2015/attribute_certificate_info.js @@ -0,0 +1,59 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnIntegerArrayBufferConverter, } from "@peculiar/asn1-schema"; +import { AlgorithmIdentifier, Attribute, Extensions, } from "@peculiar/asn1-x509"; +import { Holder } from "./holder.js"; +import { AttCertIssuer } from "./attr_cert_issuer.js"; +import { AttCertValidityPeriod } from "./attr_cert_validity_period.js"; +export var AttCertVersion; +(function (AttCertVersion) { + AttCertVersion[AttCertVersion["v2"] = 1] = "v2"; +})(AttCertVersion || (AttCertVersion = {})); +export class AttributeCertificateInfo { + version = AttCertVersion.v2; + holder = new Holder(); + issuer = new AttCertIssuer(); + signature = new AlgorithmIdentifier(); + serialNumber = new ArrayBuffer(0); + attrCertValidityPeriod = new AttCertValidityPeriod(); + attributes = []; + issuerUniqueID; + extensions; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.Integer }) +], AttributeCertificateInfo.prototype, "version", void 0); +__decorate([ + AsnProp({ type: Holder }) +], AttributeCertificateInfo.prototype, "holder", void 0); +__decorate([ + AsnProp({ type: AttCertIssuer }) +], AttributeCertificateInfo.prototype, "issuer", void 0); +__decorate([ + AsnProp({ type: AlgorithmIdentifier }) +], AttributeCertificateInfo.prototype, "signature", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter, + }) +], AttributeCertificateInfo.prototype, "serialNumber", void 0); +__decorate([ + AsnProp({ type: AttCertValidityPeriod }) +], AttributeCertificateInfo.prototype, "attrCertValidityPeriod", void 0); +__decorate([ + AsnProp({ + type: Attribute, repeated: "sequence", + }) +], AttributeCertificateInfo.prototype, "attributes", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.BitString, optional: true, + }) +], AttributeCertificateInfo.prototype, "issuerUniqueID", void 0); +__decorate([ + AsnProp({ + type: Extensions, optional: true, + }) +], AttributeCertificateInfo.prototype, "extensions", void 0); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/es2015/class_list.js b/node_modules/@peculiar/asn1-x509-attr/build/es2015/class_list.js new file mode 100644 index 0000000000000000000000000000000000000000..476e36931b7edb701bbc77128773ef539df5a687 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/es2015/class_list.js @@ -0,0 +1,12 @@ +import { BitString } from "@peculiar/asn1-schema"; +export var ClassListFlags; +(function (ClassListFlags) { + ClassListFlags[ClassListFlags["unmarked"] = 1] = "unmarked"; + ClassListFlags[ClassListFlags["unclassified"] = 2] = "unclassified"; + ClassListFlags[ClassListFlags["restricted"] = 4] = "restricted"; + ClassListFlags[ClassListFlags["confidential"] = 8] = "confidential"; + ClassListFlags[ClassListFlags["secret"] = 16] = "secret"; + ClassListFlags[ClassListFlags["topSecret"] = 32] = "topSecret"; +})(ClassListFlags || (ClassListFlags = {})); +export class ClassList extends BitString { +} diff --git a/node_modules/@peculiar/asn1-x509-attr/build/es2015/clearance.js b/node_modules/@peculiar/asn1-x509-attr/build/es2015/clearance.js new file mode 100644 index 0000000000000000000000000000000000000000..9fe16127544d00e81c310517bc5e7765f03387b9 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/es2015/clearance.js @@ -0,0 +1,25 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes } from "@peculiar/asn1-schema"; +import { ClassList, ClassListFlags } from "./class_list.js"; +import { SecurityCategory } from "./security_category.js"; +export class Clearance { + policyId = ""; + classList = new ClassList(ClassListFlags.unclassified); + securityCategories; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.ObjectIdentifier }) +], Clearance.prototype, "policyId", void 0); +__decorate([ + AsnProp({ + type: ClassList, defaultValue: new ClassList(ClassListFlags.unclassified), + }) +], Clearance.prototype, "classList", void 0); +__decorate([ + AsnProp({ + type: SecurityCategory, repeated: "set", + }) +], Clearance.prototype, "securityCategories", void 0); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/es2015/holder.js b/node_modules/@peculiar/asn1-x509-attr/build/es2015/holder.js new file mode 100644 index 0000000000000000000000000000000000000000..6cfef419c98fce530382c9087117f718b1c00538 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/es2015/holder.js @@ -0,0 +1,28 @@ +import { __decorate } from "tslib"; +import { AsnProp } from "@peculiar/asn1-schema"; +import { GeneralNames } from "@peculiar/asn1-x509"; +import { IssuerSerial } from "./issuer_serial.js"; +import { ObjectDigestInfo } from "./object_digest_info.js"; +export class Holder { + baseCertificateID; + entityName; + objectDigestInfo; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ + type: IssuerSerial, implicit: true, context: 0, optional: true, + }) +], Holder.prototype, "baseCertificateID", void 0); +__decorate([ + AsnProp({ + type: GeneralNames, implicit: true, context: 1, optional: true, + }) +], Holder.prototype, "entityName", void 0); +__decorate([ + AsnProp({ + type: ObjectDigestInfo, implicit: true, context: 2, optional: true, + }) +], Holder.prototype, "objectDigestInfo", void 0); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/es2015/ietf_attr_syntax.js b/node_modules/@peculiar/asn1-x509-attr/build/es2015/ietf_attr_syntax.js new file mode 100644 index 0000000000000000000000000000000000000000..51402c8d5c694366935b9968fc875a97ca71b73f --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/es2015/ietf_attr_syntax.js @@ -0,0 +1,37 @@ +import { __decorate } from "tslib"; +import { AsnProp, OctetString, AsnPropTypes, } from "@peculiar/asn1-schema"; +import { GeneralNames } from "@peculiar/asn1-x509"; +export class IetfAttrSyntaxValueChoices { + cotets; + oid; + string; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: OctetString }) +], IetfAttrSyntaxValueChoices.prototype, "cotets", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.ObjectIdentifier }) +], IetfAttrSyntaxValueChoices.prototype, "oid", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.Utf8String }) +], IetfAttrSyntaxValueChoices.prototype, "string", void 0); +export class IetfAttrSyntax { + policyAuthority; + values = []; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ + type: GeneralNames, implicit: true, context: 0, optional: true, + }) +], IetfAttrSyntax.prototype, "policyAuthority", void 0); +__decorate([ + AsnProp({ + type: IetfAttrSyntaxValueChoices, repeated: "sequence", + }) +], IetfAttrSyntax.prototype, "values", void 0); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/es2015/index.js b/node_modules/@peculiar/asn1-x509-attr/build/es2015/index.js new file mode 100644 index 0000000000000000000000000000000000000000..9d07afd2814651ca3b2dfac4f2cbc625877cce13 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/es2015/index.js @@ -0,0 +1,20 @@ +export * from "./aa_clear_attrs.js"; +export * from "./aa_controls.js"; +export * from "./attr_cert_issuer.js"; +export * from "./attr_cert_validity_period.js"; +export * from "./attr_spec.js"; +export * from "./attribute_certificate.js"; +export * from "./attribute_certificate_info.js"; +export * from "./class_list.js"; +export * from "./clearance.js"; +export * from "./holder.js"; +export * from "./ietf_attr_syntax.js"; +export * from "./issuer_serial.js"; +export * from "./object_digest_info.js"; +export * from "./object_identifiers.js"; +export * from "./proxy_info.js"; +export * from "./role_syntax.js"; +export * from "./security_category.js"; +export * from "./svce_auth_info.js"; +export * from "./target.js"; +export * from "./v2_form.js"; diff --git a/node_modules/@peculiar/asn1-x509-attr/build/es2015/issuer_serial.js b/node_modules/@peculiar/asn1-x509-attr/build/es2015/issuer_serial.js new file mode 100644 index 0000000000000000000000000000000000000000..09e7a0d8f0813f6d2a2276c057c2118e2152058a --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/es2015/issuer_serial.js @@ -0,0 +1,24 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnIntegerArrayBufferConverter, } from "@peculiar/asn1-schema"; +import { GeneralNames, } from "@peculiar/asn1-x509"; +export class IssuerSerial { + issuer = new GeneralNames(); + serial = new ArrayBuffer(0); + issuerUID = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: GeneralNames }) +], IssuerSerial.prototype, "issuer", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter, + }) +], IssuerSerial.prototype, "serial", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.BitString, optional: true, + }) +], IssuerSerial.prototype, "issuerUID", void 0); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/es2015/object_digest_info.js b/node_modules/@peculiar/asn1-x509-attr/build/es2015/object_digest_info.js new file mode 100644 index 0000000000000000000000000000000000000000..ee4eef70476b0dd6d6b179e9331e0e6627f68933 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/es2015/object_digest_info.js @@ -0,0 +1,32 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes } from "@peculiar/asn1-schema"; +import { AlgorithmIdentifier } from "@peculiar/asn1-x509"; +export var DigestedObjectType; +(function (DigestedObjectType) { + DigestedObjectType[DigestedObjectType["publicKey"] = 0] = "publicKey"; + DigestedObjectType[DigestedObjectType["publicKeyCert"] = 1] = "publicKeyCert"; + DigestedObjectType[DigestedObjectType["otherObjectTypes"] = 2] = "otherObjectTypes"; +})(DigestedObjectType || (DigestedObjectType = {})); +export class ObjectDigestInfo { + digestedObjectType = DigestedObjectType.publicKey; + otherObjectTypeID; + digestAlgorithm = new AlgorithmIdentifier(); + objectDigest = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.Enumerated }) +], ObjectDigestInfo.prototype, "digestedObjectType", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.ObjectIdentifier, optional: true, + }) +], ObjectDigestInfo.prototype, "otherObjectTypeID", void 0); +__decorate([ + AsnProp({ type: AlgorithmIdentifier }) +], ObjectDigestInfo.prototype, "digestAlgorithm", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.BitString }) +], ObjectDigestInfo.prototype, "objectDigest", void 0); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/es2015/object_identifiers.js b/node_modules/@peculiar/asn1-x509-attr/build/es2015/object_identifiers.js new file mode 100644 index 0000000000000000000000000000000000000000..63200c0261d9b220a5f290dd80af81d10f3dbfe8 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/es2015/object_identifiers.js @@ -0,0 +1,14 @@ +import { id_pe, id_ce, id_pkix, } from "@peculiar/asn1-x509"; +export const id_pe_ac_auditIdentity = `${id_pe}.4`; +export const id_pe_aaControls = `${id_pe}.6`; +export const id_pe_ac_proxying = `${id_pe}.10`; +export const id_ce_targetInformation = `${id_ce}.55`; +export const id_aca = `${id_pkix}.10`; +export const id_aca_authenticationInfo = `${id_aca}.1`; +export const id_aca_accessIdentity = `${id_aca}.2`; +export const id_aca_chargingIdentity = `${id_aca}.3`; +export const id_aca_group = `${id_aca}.4`; +export const id_aca_encAttrs = `${id_aca}.6`; +export const id_at = "2.5.4"; +export const id_at_role = `${id_at}.72`; +export const id_at_clearance = "2.5.1.5.55"; diff --git a/node_modules/@peculiar/asn1-x509-attr/build/es2015/package.json b/node_modules/@peculiar/asn1-x509-attr/build/es2015/package.json new file mode 100644 index 0000000000000000000000000000000000000000..3dbc1ca591c0557e35b6004aeba250e6a70b56e3 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/es2015/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/node_modules/@peculiar/asn1-x509-attr/build/es2015/proxy_info.js b/node_modules/@peculiar/asn1-x509-attr/build/es2015/proxy_info.js new file mode 100644 index 0000000000000000000000000000000000000000..c46f02903b5dd07401546db4e9a86bc39b8df1a1 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/es2015/proxy_info.js @@ -0,0 +1,16 @@ +var ProxyInfo_1; +import { __decorate } from "tslib"; +import { AsnType, AsnTypeTypes, AsnArray, } from "@peculiar/asn1-schema"; +import { Targets } from "./target.js"; +let ProxyInfo = ProxyInfo_1 = class ProxyInfo extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, ProxyInfo_1.prototype); + } +}; +ProxyInfo = ProxyInfo_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Sequence, itemType: Targets, + }) +], ProxyInfo); +export { ProxyInfo }; diff --git a/node_modules/@peculiar/asn1-x509-attr/build/es2015/role_syntax.js b/node_modules/@peculiar/asn1-x509-attr/build/es2015/role_syntax.js new file mode 100644 index 0000000000000000000000000000000000000000..a95c78e334f394d2f01aba147dd4cfcadabc39d1 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/es2015/role_syntax.js @@ -0,0 +1,20 @@ +import { __decorate } from "tslib"; +import { AsnProp } from "@peculiar/asn1-schema"; +import { GeneralNames, GeneralName } from "@peculiar/asn1-x509"; +export class RoleSyntax { + roleAuthority; + roleName; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ + type: GeneralNames, implicit: true, context: 0, optional: true, + }) +], RoleSyntax.prototype, "roleAuthority", void 0); +__decorate([ + AsnProp({ + type: GeneralName, implicit: true, context: 1, + }) +], RoleSyntax.prototype, "roleName", void 0); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/es2015/security_category.js b/node_modules/@peculiar/asn1-x509-attr/build/es2015/security_category.js new file mode 100644 index 0000000000000000000000000000000000000000..abc1690ca1aa6fafe6548789a71f96888771359f --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/es2015/security_category.js @@ -0,0 +1,19 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes } from "@peculiar/asn1-schema"; +export class SecurityCategory { + type = ""; + value = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ + type: AsnPropTypes.ObjectIdentifier, implicit: true, context: 0, + }) +], SecurityCategory.prototype, "type", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Any, implicit: true, context: 1, + }) +], SecurityCategory.prototype, "value", void 0); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/es2015/svce_auth_info.js b/node_modules/@peculiar/asn1-x509-attr/build/es2015/svce_auth_info.js new file mode 100644 index 0000000000000000000000000000000000000000..6e6836e1a4013bb5cbe435483149485b463c16ba --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/es2015/svce_auth_info.js @@ -0,0 +1,22 @@ +import { __decorate } from "tslib"; +import { AsnProp, OctetString } from "@peculiar/asn1-schema"; +import { GeneralName } from "@peculiar/asn1-x509"; +export class SvceAuthInfo { + service = new GeneralName(); + ident = new GeneralName(); + authInfo; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: GeneralName }) +], SvceAuthInfo.prototype, "service", void 0); +__decorate([ + AsnProp({ type: GeneralName }) +], SvceAuthInfo.prototype, "ident", void 0); +__decorate([ + AsnProp({ + type: OctetString, optional: true, + }) +], SvceAuthInfo.prototype, "authInfo", void 0); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/es2015/target.js b/node_modules/@peculiar/asn1-x509-attr/build/es2015/target.js new file mode 100644 index 0000000000000000000000000000000000000000..2d20016e899cdc1cd3b26cf4e533b3141723a1ab --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/es2015/target.js @@ -0,0 +1,66 @@ +var Targets_1; +import { __decorate } from "tslib"; +import { AsnProp, AsnType, AsnTypeTypes, AsnArray, } from "@peculiar/asn1-schema"; +import { GeneralName } from "@peculiar/asn1-x509"; +import { IssuerSerial } from "./issuer_serial.js"; +import { ObjectDigestInfo } from "./object_digest_info.js"; +export class TargetCert { + targetCertificate = new IssuerSerial(); + targetName; + certDigestInfo; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: IssuerSerial }) +], TargetCert.prototype, "targetCertificate", void 0); +__decorate([ + AsnProp({ + type: GeneralName, optional: true, + }) +], TargetCert.prototype, "targetName", void 0); +__decorate([ + AsnProp({ + type: ObjectDigestInfo, optional: true, + }) +], TargetCert.prototype, "certDigestInfo", void 0); +let Target = class Target { + targetName; + targetGroup; + targetCert; + constructor(params = {}) { + Object.assign(this, params); + } +}; +__decorate([ + AsnProp({ + type: GeneralName, context: 0, implicit: true, + }) +], Target.prototype, "targetName", void 0); +__decorate([ + AsnProp({ + type: GeneralName, context: 1, implicit: true, + }) +], Target.prototype, "targetGroup", void 0); +__decorate([ + AsnProp({ + type: TargetCert, context: 2, implicit: true, + }) +], Target.prototype, "targetCert", void 0); +Target = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], Target); +export { Target }; +let Targets = Targets_1 = class Targets extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, Targets_1.prototype); + } +}; +Targets = Targets_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Sequence, itemType: Target, + }) +], Targets); +export { Targets }; diff --git a/node_modules/@peculiar/asn1-x509-attr/build/es2015/v2_form.js b/node_modules/@peculiar/asn1-x509-attr/build/es2015/v2_form.js new file mode 100644 index 0000000000000000000000000000000000000000..af984538316d5d1907cb5901e5ae00b2b1fc2231 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/es2015/v2_form.js @@ -0,0 +1,28 @@ +import { __decorate } from "tslib"; +import { AsnProp } from "@peculiar/asn1-schema"; +import { GeneralNames } from "@peculiar/asn1-x509"; +import { IssuerSerial } from "./issuer_serial.js"; +import { ObjectDigestInfo } from "./object_digest_info.js"; +export class V2Form { + issuerName; + baseCertificateID; + objectDigestInfo; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ + type: GeneralNames, optional: true, + }) +], V2Form.prototype, "issuerName", void 0); +__decorate([ + AsnProp({ + type: IssuerSerial, context: 0, implicit: true, optional: true, + }) +], V2Form.prototype, "baseCertificateID", void 0); +__decorate([ + AsnProp({ + type: ObjectDigestInfo, context: 1, implicit: true, optional: true, + }) +], V2Form.prototype, "objectDigestInfo", void 0); diff --git a/node_modules/@peculiar/asn1-x509-attr/build/types/aa_clear_attrs.d.ts b/node_modules/@peculiar/asn1-x509-attr/build/types/aa_clear_attrs.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..17f2bb834f352811714077686f26d213d9cbd6dc --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/types/aa_clear_attrs.d.ts @@ -0,0 +1,16 @@ +import { GeneralName, Attribute } from "@peculiar/asn1-x509"; +/** + * ```asn1 + * ACClearAttrs ::= SEQUENCE { + * acIssuer GeneralName, + * acSerial INTEGER, + * attrs SEQUENCE OF Attribute + * } + * ``` + */ +export declare class ACClearAttrs { + acIssuer: GeneralName; + acSerial: number; + attrs: Attribute[]; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-x509-attr/build/types/aa_controls.d.ts b/node_modules/@peculiar/asn1-x509-attr/build/types/aa_controls.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..649e222343bb10be3547aaa94ec423f8baab248a --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/types/aa_controls.d.ts @@ -0,0 +1,18 @@ +import { AttrSpec } from "./attr_spec"; +/** + * ```asn1 + * AAControls ::= SEQUENCE { + * pathLenConstraint INTEGER (0..MAX) OPTIONAL, + * permittedAttrs [0] AttrSpec OPTIONAL, + * excludedAttrs [1] AttrSpec OPTIONAL, + * permitUnSpecified BOOLEAN DEFAULT TRUE + * } + * ``` + */ +export declare class AAControls { + pathLenConstraint?: number; + permittedAttrs?: AttrSpec; + excludedAttrs?: AttrSpec; + permitUnSpecified: boolean; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-x509-attr/build/types/attr_cert_issuer.d.ts b/node_modules/@peculiar/asn1-x509-attr/build/types/attr_cert_issuer.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..184ad1955f4523425d00eb2934bb74bf199f87d0 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/types/attr_cert_issuer.d.ts @@ -0,0 +1,16 @@ +import { GeneralName } from "@peculiar/asn1-x509"; +import { V2Form } from "./v2_form"; +/** + * ```asn1 + * AttCertIssuer ::= CHOICE { + * v1Form GeneralNames, -- MUST NOT be used in this + * -- profile + * v2Form [0] V2Form -- v2 only + * } + * ``` + */ +export declare class AttCertIssuer { + v1Form?: GeneralName[]; + v2Form?: V2Form; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-x509-attr/build/types/attr_cert_validity_period.d.ts b/node_modules/@peculiar/asn1-x509-attr/build/types/attr_cert_validity_period.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..03e8e44f193951b28c4b3a41f80a9cb009270e6b --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/types/attr_cert_validity_period.d.ts @@ -0,0 +1,13 @@ +/** + * ```asn1 + * AttCertValidityPeriod ::= SEQUENCE { + * notBeforeTime GeneralizedTime, + * notAfterTime GeneralizedTime + * } + * ``` + */ +export declare class AttCertValidityPeriod { + notBeforeTime: Date; + notAfterTime: Date; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-x509-attr/build/types/attr_spec.d.ts b/node_modules/@peculiar/asn1-x509-attr/build/types/attr_spec.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6dcb354adb4897f55471b375647c46c977121d12 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/types/attr_spec.d.ts @@ -0,0 +1,9 @@ +import { AsnArray } from "@peculiar/asn1-schema"; +/** + * ```asn1 + * AttrSpec ::= SEQUENCE OF OBJECT IDENTIFIER + * ``` + */ +export declare class AttrSpec extends AsnArray { + constructor(items?: string[]); +} diff --git a/node_modules/@peculiar/asn1-x509-attr/build/types/attribute_certificate.d.ts b/node_modules/@peculiar/asn1-x509-attr/build/types/attribute_certificate.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..25adbaab05d5ab32afba9a81f97520d767f84344 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/types/attribute_certificate.d.ts @@ -0,0 +1,17 @@ +import { AlgorithmIdentifier } from "@peculiar/asn1-x509"; +import { AttributeCertificateInfo } from "./attribute_certificate_info"; +/** + * ```asn1 + * AttributeCertificate ::= SEQUENCE { + * acinfo AttributeCertificateInfo, + * signatureAlgorithm AlgorithmIdentifier, + * signatureValue BIT STRING + * } + * ``` + */ +export declare class AttributeCertificate { + acinfo: AttributeCertificateInfo; + signatureAlgorithm: AlgorithmIdentifier; + signatureValue: ArrayBuffer; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-x509-attr/build/types/attribute_certificate_info.d.ts b/node_modules/@peculiar/asn1-x509-attr/build/types/attribute_certificate_info.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..13d3450b9fb1c24d7664a994cc56763657b2d806 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/types/attribute_certificate_info.d.ts @@ -0,0 +1,39 @@ +import { AlgorithmIdentifier, Attribute, UniqueIdentifier, Extensions, CertificateSerialNumber } from "@peculiar/asn1-x509"; +import { Holder } from "./holder"; +import { AttCertIssuer } from "./attr_cert_issuer"; +import { AttCertValidityPeriod } from "./attr_cert_validity_period"; +/** + * ```asn1 + * AttCertVersion ::= INTEGER { v2(1) } + * ``` + */ +export declare enum AttCertVersion { + v2 = 1 +} +/** + * ```asn1 + * AttributeCertificateInfo ::= SEQUENCE { + * version AttCertVersion -- version is v2, + * holder Holder, + * issuer AttCertIssuer, + * signature AlgorithmIdentifier, + * serialNumber CertificateSerialNumber, + * attrCertValidityPeriod AttCertValidityPeriod, + * attributes SEQUENCE OF Attribute, + * issuerUniqueID UniqueIdentifier OPTIONAL, + * extensions Extensions OPTIONAL + * } + * ``` + */ +export declare class AttributeCertificateInfo { + version: AttCertVersion; + holder: Holder; + issuer: AttCertIssuer; + signature: AlgorithmIdentifier; + serialNumber: CertificateSerialNumber; + attrCertValidityPeriod: AttCertValidityPeriod; + attributes: Attribute[]; + issuerUniqueID?: UniqueIdentifier; + extensions?: Extensions; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-x509-attr/build/types/class_list.d.ts b/node_modules/@peculiar/asn1-x509-attr/build/types/class_list.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..53b4b5e041897652d0e38fbb5108e10f55f84c78 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509-attr/build/types/class_list.d.ts @@ -0,0 +1,23 @@ +import { BitString } from "@peculiar/asn1-schema"; +export declare enum ClassListFlags { + unmarked = 1, + unclassified = 2, + restricted = 4, + confidential = 8, + secret = 16, + topSecret = 32 +} +/** + * ```asn1 + * ClassList ::= BIT STRING { + * unmarked (0), + * unclassified (1), + * restricted (2), + * confidential (3), + * secret (4), + * topSecret (5) + * } + * ``` + */ +export declare class ClassList extends BitString { +} diff --git a/node_modules/@peculiar/asn1-x509/LICENSE b/node_modules/@peculiar/asn1-x509/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..6f9ec1352ea499d3f26a898c37ea4a0cd2a740fb --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@peculiar/asn1-x509/README.md b/node_modules/@peculiar/asn1-x509/README.md new file mode 100644 index 0000000000000000000000000000000000000000..0c2a23f2e1de1346db27de1bcd3993f3e7027fc8 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/README.md @@ -0,0 +1,21 @@ +# `@peculiar/asn1-x509` + +[![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/PeculiarVentures/asn1-schema/blob/master/packages/x509/LICENSE) +[![npm version](https://badge.fury.io/js/%40peculiar%2Fasn1-x509.svg)](https://badge.fury.io/js/%40peculiar%2Fasn1-x509) + +[![NPM](https://nodei.co/npm/@peculiar/asn1-x509.png)](https://nodei.co/npm/@peculiar/asn1-x509/) + +ASN.1 schema for X.509 certificates, certificate revocation lists, and related profile structures defined in RFC 5280. + +Use the exported classes with `@peculiar/asn1-schema` helpers such as `AsnConvert`, `AsnParser`, and `AsnSerializer` to parse or serialize DER-encoded data defined by the referenced specification. + +## Installation + +```bash +npm install @peculiar/asn1-x509 +``` + +## Specifications + +- [RFC 5280: Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile](https://datatracker.ietf.org/doc/html/rfc5280) +- [EntrustVersionInfo extension reference](http://ftp.gnome.org/mirror/archive/ftp.sunet.se/pub/security/dfnpca/docs/misc/Entrust/directory.pdf) diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/algorithm_identifier.js b/node_modules/@peculiar/asn1-x509/build/cjs/algorithm_identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..7894c8b40e87c67ce786a5570f67c9a025623f4c --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/algorithm_identifier.js @@ -0,0 +1,31 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AlgorithmIdentifier = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const bytes_1 = require("@peculiar/utils/bytes"); +class AlgorithmIdentifier { + algorithm = ""; + parameters; + constructor(params = {}) { + Object.assign(this, params); + } + isEqual(data) { + return (data instanceof AlgorithmIdentifier + && data.algorithm == this.algorithm + && ((data.parameters + && this.parameters + && (0, bytes_1.equal)(data.parameters, this.parameters)) + || data.parameters === this.parameters)); + } +} +exports.AlgorithmIdentifier = AlgorithmIdentifier; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.ObjectIdentifier }) +], AlgorithmIdentifier.prototype, "algorithm", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Any, + optional: true, + }) +], AlgorithmIdentifier.prototype, "parameters", void 0); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/attribute.js b/node_modules/@peculiar/asn1-x509/build/cjs/attribute.js new file mode 100644 index 0000000000000000000000000000000000000000..e8df4961da0822750c58943d6b30efa3656fbdb0 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/attribute.js @@ -0,0 +1,21 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Attribute = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +class Attribute { + type = ""; + values = []; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.Attribute = Attribute; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.ObjectIdentifier }) +], Attribute.prototype, "type", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Any, repeated: "set", + }) +], Attribute.prototype, "values", void 0); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/certificate.js b/node_modules/@peculiar/asn1-x509/build/cjs/certificate.js new file mode 100644 index 0000000000000000000000000000000000000000..f6a760cdfdd51a78ac3c421d5315bcc919bf1b01 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/certificate.js @@ -0,0 +1,28 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Certificate = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const algorithm_identifier_1 = require("./algorithm_identifier"); +const tbs_certificate_1 = require("./tbs_certificate"); +class Certificate { + tbsCertificate = new tbs_certificate_1.TBSCertificate(); + tbsCertificateRaw; + signatureAlgorithm = new algorithm_identifier_1.AlgorithmIdentifier(); + signatureValue = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.Certificate = Certificate; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: tbs_certificate_1.TBSCertificate, raw: true, + }) +], Certificate.prototype, "tbsCertificate", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: algorithm_identifier_1.AlgorithmIdentifier }) +], Certificate.prototype, "signatureAlgorithm", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.BitString }) +], Certificate.prototype, "signatureValue", void 0); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/certificate_list.js b/node_modules/@peculiar/asn1-x509/build/cjs/certificate_list.js new file mode 100644 index 0000000000000000000000000000000000000000..0a2f972cbfd563ae8a51949fcaea41eed418d356 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/certificate_list.js @@ -0,0 +1,28 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CertificateList = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const algorithm_identifier_1 = require("./algorithm_identifier"); +const tbs_cert_list_1 = require("./tbs_cert_list"); +class CertificateList { + tbsCertList = new tbs_cert_list_1.TBSCertList(); + tbsCertListRaw; + signatureAlgorithm = new algorithm_identifier_1.AlgorithmIdentifier(); + signature = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.CertificateList = CertificateList; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: tbs_cert_list_1.TBSCertList, raw: true, + }) +], CertificateList.prototype, "tbsCertList", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: algorithm_identifier_1.AlgorithmIdentifier }) +], CertificateList.prototype, "signatureAlgorithm", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.BitString }) +], CertificateList.prototype, "signature", void 0); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/extension.js b/node_modules/@peculiar/asn1-x509/build/cjs/extension.js new file mode 100644 index 0000000000000000000000000000000000000000..91a46c7d2d3d162f8a4675646dad3d1cbb37bae6 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/extension.js @@ -0,0 +1,40 @@ +"use strict"; +var Extensions_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Extensions = exports.Extension = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +class Extension { + static CRITICAL = false; + extnID = ""; + critical = Extension.CRITICAL; + extnValue = new asn1_schema_1.OctetString(); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.Extension = Extension; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.ObjectIdentifier }) +], Extension.prototype, "extnID", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Boolean, + defaultValue: Extension.CRITICAL, + }) +], Extension.prototype, "critical", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.OctetString }) +], Extension.prototype, "extnValue", void 0); +let Extensions = Extensions_1 = class Extensions extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, Extensions_1.prototype); + } +}; +exports.Extensions = Extensions; +exports.Extensions = Extensions = Extensions_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Sequence, itemType: Extension, + }) +], Extensions); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/extensions/authority_information_access.js b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/authority_information_access.js new file mode 100644 index 0000000000000000000000000000000000000000..2d3637335fe337fafc76ab084d80ec42c77ce360 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/authority_information_access.js @@ -0,0 +1,35 @@ +"use strict"; +var AuthorityInfoAccessSyntax_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AuthorityInfoAccessSyntax = exports.AccessDescription = exports.id_pe_authorityInfoAccess = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const general_name_1 = require("../general_name"); +const object_identifiers_1 = require("../object_identifiers"); +exports.id_pe_authorityInfoAccess = `${object_identifiers_1.id_pe}.1`; +class AccessDescription { + accessMethod = ""; + accessLocation = new general_name_1.GeneralName(); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.AccessDescription = AccessDescription; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.ObjectIdentifier }) +], AccessDescription.prototype, "accessMethod", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: general_name_1.GeneralName }) +], AccessDescription.prototype, "accessLocation", void 0); +let AuthorityInfoAccessSyntax = AuthorityInfoAccessSyntax_1 = class AuthorityInfoAccessSyntax extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, AuthorityInfoAccessSyntax_1.prototype); + } +}; +exports.AuthorityInfoAccessSyntax = AuthorityInfoAccessSyntax; +exports.AuthorityInfoAccessSyntax = AuthorityInfoAccessSyntax = AuthorityInfoAccessSyntax_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Sequence, itemType: AccessDescription, + }) +], AuthorityInfoAccessSyntax); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/extensions/authority_key_identifier.js b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/authority_key_identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..3f256d0150737abb044a196c59dfd69f00dbb54f --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/authority_key_identifier.js @@ -0,0 +1,41 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AuthorityKeyIdentifier = exports.KeyIdentifier = exports.id_ce_authorityKeyIdentifier = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const general_name_1 = require("../general_name"); +const object_identifiers_1 = require("../object_identifiers"); +exports.id_ce_authorityKeyIdentifier = `${object_identifiers_1.id_ce}.35`; +class KeyIdentifier extends asn1_schema_1.OctetString { +} +exports.KeyIdentifier = KeyIdentifier; +class AuthorityKeyIdentifier { + keyIdentifier; + authorityCertIssuer; + authorityCertSerialNumber; + constructor(params = {}) { + if (params) { + Object.assign(this, params); + } + } +} +exports.AuthorityKeyIdentifier = AuthorityKeyIdentifier; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: KeyIdentifier, context: 0, optional: true, implicit: true, + }) +], AuthorityKeyIdentifier.prototype, "keyIdentifier", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: general_name_1.GeneralName, context: 1, optional: true, implicit: true, repeated: "sequence", + }) +], AuthorityKeyIdentifier.prototype, "authorityCertIssuer", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, + context: 2, + optional: true, + implicit: true, + converter: asn1_schema_1.AsnIntegerArrayBufferConverter, + }) +], AuthorityKeyIdentifier.prototype, "authorityCertSerialNumber", void 0); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/extensions/basic_constraints.js b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/basic_constraints.js new file mode 100644 index 0000000000000000000000000000000000000000..792af36bbd48f45e1e3c1535976187ca83cca37a --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/basic_constraints.js @@ -0,0 +1,25 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.BasicConstraints = exports.id_ce_basicConstraints = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const object_identifiers_1 = require("../object_identifiers"); +exports.id_ce_basicConstraints = `${object_identifiers_1.id_ce}.19`; +class BasicConstraints { + cA = false; + pathLenConstraint; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.BasicConstraints = BasicConstraints; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Boolean, defaultValue: false, + }) +], BasicConstraints.prototype, "cA", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, optional: true, + }) +], BasicConstraints.prototype, "pathLenConstraint", void 0); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/extensions/certificate_issuer.js b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/certificate_issuer.js new file mode 100644 index 0000000000000000000000000000000000000000..6b61edc67e51f4ddf7462ed9cd993c02c9b06f40 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/certificate_issuer.js @@ -0,0 +1,19 @@ +"use strict"; +var CertificateIssuer_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CertificateIssuer = exports.id_ce_certificateIssuer = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const general_names_1 = require("../general_names"); +const object_identifiers_1 = require("../object_identifiers"); +exports.id_ce_certificateIssuer = `${object_identifiers_1.id_ce}.29`; +let CertificateIssuer = CertificateIssuer_1 = class CertificateIssuer extends general_names_1.GeneralNames { + constructor(items) { + super(items); + Object.setPrototypeOf(this, CertificateIssuer_1.prototype); + } +}; +exports.CertificateIssuer = CertificateIssuer; +exports.CertificateIssuer = CertificateIssuer = CertificateIssuer_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Sequence }) +], CertificateIssuer); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/extensions/certificate_policies.js b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/certificate_policies.js new file mode 100644 index 0000000000000000000000000000000000000000..00b0970a342cf05f14f85bd7223829071bd2831f --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/certificate_policies.js @@ -0,0 +1,130 @@ +"use strict"; +var CertificatePolicies_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CertificatePolicies = exports.PolicyInformation = exports.PolicyQualifierInfo = exports.Qualifier = exports.UserNotice = exports.NoticeReference = exports.DisplayText = exports.id_ce_certificatePolicies_anyPolicy = exports.id_ce_certificatePolicies = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const object_identifiers_1 = require("../object_identifiers"); +exports.id_ce_certificatePolicies = `${object_identifiers_1.id_ce}.32`; +exports.id_ce_certificatePolicies_anyPolicy = `${exports.id_ce_certificatePolicies}.0`; +let DisplayText = class DisplayText { + ia5String; + visibleString; + bmpString; + utf8String; + constructor(params = {}) { + Object.assign(this, params); + } + toString() { + return this.ia5String || this.visibleString || this.bmpString || this.utf8String || ""; + } +}; +exports.DisplayText = DisplayText; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.IA5String }) +], DisplayText.prototype, "ia5String", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.VisibleString }) +], DisplayText.prototype, "visibleString", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.BmpString }) +], DisplayText.prototype, "bmpString", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Utf8String }) +], DisplayText.prototype, "utf8String", void 0); +exports.DisplayText = DisplayText = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], DisplayText); +class NoticeReference { + organization = new DisplayText(); + noticeNumbers = []; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.NoticeReference = NoticeReference; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: DisplayText }) +], NoticeReference.prototype, "organization", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, repeated: "sequence", + }) +], NoticeReference.prototype, "noticeNumbers", void 0); +class UserNotice { + noticeRef; + explicitText; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.UserNotice = UserNotice; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: NoticeReference, optional: true, + }) +], UserNotice.prototype, "noticeRef", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: DisplayText, optional: true, + }) +], UserNotice.prototype, "explicitText", void 0); +let Qualifier = class Qualifier { + cPSuri; + userNotice; + constructor(params = {}) { + Object.assign(this, params); + } +}; +exports.Qualifier = Qualifier; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.IA5String }) +], Qualifier.prototype, "cPSuri", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: UserNotice }) +], Qualifier.prototype, "userNotice", void 0); +exports.Qualifier = Qualifier = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], Qualifier); +class PolicyQualifierInfo { + policyQualifierId = ""; + qualifier = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.PolicyQualifierInfo = PolicyQualifierInfo; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.ObjectIdentifier }) +], PolicyQualifierInfo.prototype, "policyQualifierId", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Any }) +], PolicyQualifierInfo.prototype, "qualifier", void 0); +class PolicyInformation { + policyIdentifier = ""; + policyQualifiers; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.PolicyInformation = PolicyInformation; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.ObjectIdentifier }) +], PolicyInformation.prototype, "policyIdentifier", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: PolicyQualifierInfo, repeated: "sequence", optional: true, + }) +], PolicyInformation.prototype, "policyQualifiers", void 0); +let CertificatePolicies = CertificatePolicies_1 = class CertificatePolicies extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, CertificatePolicies_1.prototype); + } +}; +exports.CertificatePolicies = CertificatePolicies; +exports.CertificatePolicies = CertificatePolicies = CertificatePolicies_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Sequence, itemType: PolicyInformation, + }) +], CertificatePolicies); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/extensions/crl_delta_indicator.js b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/crl_delta_indicator.js new file mode 100644 index 0000000000000000000000000000000000000000..88aeb7aff64c7f87448a8884fba0577a177d72ce --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/crl_delta_indicator.js @@ -0,0 +1,14 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.BaseCRLNumber = exports.id_ce_deltaCRLIndicator = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const object_identifiers_1 = require("../object_identifiers"); +const crl_number_1 = require("./crl_number"); +exports.id_ce_deltaCRLIndicator = `${object_identifiers_1.id_ce}.27`; +let BaseCRLNumber = class BaseCRLNumber extends crl_number_1.CRLNumber { +}; +exports.BaseCRLNumber = BaseCRLNumber; +exports.BaseCRLNumber = BaseCRLNumber = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], BaseCRLNumber); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/extensions/crl_distribution_points.js b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/crl_distribution_points.js new file mode 100644 index 0000000000000000000000000000000000000000..96d2f3f1799be0e406e2cfc04fe7fcfd28fe374f --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/crl_distribution_points.js @@ -0,0 +1,117 @@ +"use strict"; +var CRLDistributionPoints_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CRLDistributionPoints = exports.DistributionPoint = exports.DistributionPointName = exports.Reason = exports.ReasonFlags = exports.id_ce_cRLDistributionPoints = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const name_1 = require("../name"); +const general_name_1 = require("../general_name"); +const object_identifiers_1 = require("../object_identifiers"); +exports.id_ce_cRLDistributionPoints = `${object_identifiers_1.id_ce}.31`; +var ReasonFlags; +(function (ReasonFlags) { + ReasonFlags[ReasonFlags["unused"] = 1] = "unused"; + ReasonFlags[ReasonFlags["keyCompromise"] = 2] = "keyCompromise"; + ReasonFlags[ReasonFlags["cACompromise"] = 4] = "cACompromise"; + ReasonFlags[ReasonFlags["affiliationChanged"] = 8] = "affiliationChanged"; + ReasonFlags[ReasonFlags["superseded"] = 16] = "superseded"; + ReasonFlags[ReasonFlags["cessationOfOperation"] = 32] = "cessationOfOperation"; + ReasonFlags[ReasonFlags["certificateHold"] = 64] = "certificateHold"; + ReasonFlags[ReasonFlags["privilegeWithdrawn"] = 128] = "privilegeWithdrawn"; + ReasonFlags[ReasonFlags["aACompromise"] = 256] = "aACompromise"; +})(ReasonFlags || (exports.ReasonFlags = ReasonFlags = {})); +class Reason extends asn1_schema_1.BitString { + toJSON() { + const res = []; + const flags = this.toNumber(); + if (flags & ReasonFlags.aACompromise) { + res.push("aACompromise"); + } + if (flags & ReasonFlags.affiliationChanged) { + res.push("affiliationChanged"); + } + if (flags & ReasonFlags.cACompromise) { + res.push("cACompromise"); + } + if (flags & ReasonFlags.certificateHold) { + res.push("certificateHold"); + } + if (flags & ReasonFlags.cessationOfOperation) { + res.push("cessationOfOperation"); + } + if (flags & ReasonFlags.keyCompromise) { + res.push("keyCompromise"); + } + if (flags & ReasonFlags.privilegeWithdrawn) { + res.push("privilegeWithdrawn"); + } + if (flags & ReasonFlags.superseded) { + res.push("superseded"); + } + if (flags & ReasonFlags.unused) { + res.push("unused"); + } + return res; + } + toString() { + return `[${this.toJSON().join(", ")}]`; + } +} +exports.Reason = Reason; +let DistributionPointName = class DistributionPointName { + fullName; + nameRelativeToCRLIssuer; + constructor(params = {}) { + Object.assign(this, params); + } +}; +exports.DistributionPointName = DistributionPointName; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: general_name_1.GeneralName, context: 0, repeated: "sequence", implicit: true, + }) +], DistributionPointName.prototype, "fullName", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: name_1.RelativeDistinguishedName, context: 1, implicit: true, + }) +], DistributionPointName.prototype, "nameRelativeToCRLIssuer", void 0); +exports.DistributionPointName = DistributionPointName = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], DistributionPointName); +class DistributionPoint { + distributionPoint; + reasons; + cRLIssuer; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.DistributionPoint = DistributionPoint; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: DistributionPointName, context: 0, optional: true, + }) +], DistributionPoint.prototype, "distributionPoint", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: Reason, context: 1, optional: true, implicit: true, + }) +], DistributionPoint.prototype, "reasons", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: general_name_1.GeneralName, context: 2, optional: true, repeated: "sequence", implicit: true, + }) +], DistributionPoint.prototype, "cRLIssuer", void 0); +let CRLDistributionPoints = CRLDistributionPoints_1 = class CRLDistributionPoints extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, CRLDistributionPoints_1.prototype); + } +}; +exports.CRLDistributionPoints = CRLDistributionPoints; +exports.CRLDistributionPoints = CRLDistributionPoints = CRLDistributionPoints_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Sequence, itemType: DistributionPoint, + }) +], CRLDistributionPoints); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/extensions/crl_freshest.js b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/crl_freshest.js new file mode 100644 index 0000000000000000000000000000000000000000..f0336a41994965f89451f982585772b8341060dd --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/crl_freshest.js @@ -0,0 +1,21 @@ +"use strict"; +var FreshestCRL_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.FreshestCRL = exports.id_ce_freshestCRL = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const object_identifiers_1 = require("../object_identifiers"); +const crl_distribution_points_1 = require("./crl_distribution_points"); +exports.id_ce_freshestCRL = `${object_identifiers_1.id_ce}.46`; +let FreshestCRL = FreshestCRL_1 = class FreshestCRL extends crl_distribution_points_1.CRLDistributionPoints { + constructor(items) { + super(items); + Object.setPrototypeOf(this, FreshestCRL_1.prototype); + } +}; +exports.FreshestCRL = FreshestCRL; +exports.FreshestCRL = FreshestCRL = FreshestCRL_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Sequence, itemType: crl_distribution_points_1.DistributionPoint, + }) +], FreshestCRL); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/extensions/crl_issuing_distribution_point.js b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/crl_issuing_distribution_point.js new file mode 100644 index 0000000000000000000000000000000000000000..0b80c955bfff4fc8d297d785a2b8626ba807becb --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/crl_issuing_distribution_point.js @@ -0,0 +1,63 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.IssuingDistributionPoint = exports.id_ce_issuingDistributionPoint = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const object_identifiers_1 = require("../object_identifiers"); +const crl_distribution_points_1 = require("./crl_distribution_points"); +exports.id_ce_issuingDistributionPoint = `${object_identifiers_1.id_ce}.28`; +class IssuingDistributionPoint { + static ONLY = false; + distributionPoint; + onlyContainsUserCerts = IssuingDistributionPoint.ONLY; + onlyContainsCACerts = IssuingDistributionPoint.ONLY; + onlySomeReasons; + indirectCRL = IssuingDistributionPoint.ONLY; + onlyContainsAttributeCerts = IssuingDistributionPoint.ONLY; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.IssuingDistributionPoint = IssuingDistributionPoint; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: crl_distribution_points_1.DistributionPointName, context: 0, optional: true, + }) +], IssuingDistributionPoint.prototype, "distributionPoint", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Boolean, + context: 1, + defaultValue: IssuingDistributionPoint.ONLY, + implicit: true, + }) +], IssuingDistributionPoint.prototype, "onlyContainsUserCerts", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Boolean, + context: 2, + defaultValue: IssuingDistributionPoint.ONLY, + implicit: true, + }) +], IssuingDistributionPoint.prototype, "onlyContainsCACerts", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: crl_distribution_points_1.Reason, context: 3, optional: true, implicit: true, + }) +], IssuingDistributionPoint.prototype, "onlySomeReasons", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Boolean, + context: 4, + defaultValue: IssuingDistributionPoint.ONLY, + implicit: true, + }) +], IssuingDistributionPoint.prototype, "indirectCRL", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Boolean, + context: 5, + defaultValue: IssuingDistributionPoint.ONLY, + implicit: true, + }) +], IssuingDistributionPoint.prototype, "onlyContainsAttributeCerts", void 0); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/extensions/crl_number.js b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/crl_number.js new file mode 100644 index 0000000000000000000000000000000000000000..3320512ef37d7f096cd335336f779fdc8881e9ea --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/crl_number.js @@ -0,0 +1,20 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CRLNumber = exports.id_ce_cRLNumber = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const object_identifiers_1 = require("../object_identifiers"); +exports.id_ce_cRLNumber = `${object_identifiers_1.id_ce}.20`; +let CRLNumber = class CRLNumber { + value; + constructor(value = 0) { + this.value = value; + } +}; +exports.CRLNumber = CRLNumber; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer }) +], CRLNumber.prototype, "value", void 0); +exports.CRLNumber = CRLNumber = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], CRLNumber); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/extensions/crl_reason.js b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/crl_reason.js new file mode 100644 index 0000000000000000000000000000000000000000..c0748c34648a09d256e7d15282be0846f66bb637 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/crl_reason.js @@ -0,0 +1,39 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CRLReason = exports.CRLReasons = exports.id_ce_cRLReasons = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const object_identifiers_1 = require("../object_identifiers"); +exports.id_ce_cRLReasons = `${object_identifiers_1.id_ce}.21`; +var CRLReasons; +(function (CRLReasons) { + CRLReasons[CRLReasons["unspecified"] = 0] = "unspecified"; + CRLReasons[CRLReasons["keyCompromise"] = 1] = "keyCompromise"; + CRLReasons[CRLReasons["cACompromise"] = 2] = "cACompromise"; + CRLReasons[CRLReasons["affiliationChanged"] = 3] = "affiliationChanged"; + CRLReasons[CRLReasons["superseded"] = 4] = "superseded"; + CRLReasons[CRLReasons["cessationOfOperation"] = 5] = "cessationOfOperation"; + CRLReasons[CRLReasons["certificateHold"] = 6] = "certificateHold"; + CRLReasons[CRLReasons["removeFromCRL"] = 8] = "removeFromCRL"; + CRLReasons[CRLReasons["privilegeWithdrawn"] = 9] = "privilegeWithdrawn"; + CRLReasons[CRLReasons["aACompromise"] = 10] = "aACompromise"; +})(CRLReasons || (exports.CRLReasons = CRLReasons = {})); +let CRLReason = class CRLReason { + reason = CRLReasons.unspecified; + constructor(reason = CRLReasons.unspecified) { + this.reason = reason; + } + toJSON() { + return CRLReasons[this.reason]; + } + toString() { + return this.toJSON(); + } +}; +exports.CRLReason = CRLReason; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Enumerated }) +], CRLReason.prototype, "reason", void 0); +exports.CRLReason = CRLReason = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], CRLReason); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/extensions/entrust_version_info.js b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/entrust_version_info.js new file mode 100644 index 0000000000000000000000000000000000000000..a4765db891a88d787df387ad766cf8f8f21fd29b --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/entrust_version_info.js @@ -0,0 +1,46 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.EntrustVersionInfo = exports.EntrustInfo = exports.EntrustInfoFlags = exports.id_entrust_entrustVersInfo = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +exports.id_entrust_entrustVersInfo = "1.2.840.113533.7.65.0"; +var EntrustInfoFlags; +(function (EntrustInfoFlags) { + EntrustInfoFlags[EntrustInfoFlags["keyUpdateAllowed"] = 1] = "keyUpdateAllowed"; + EntrustInfoFlags[EntrustInfoFlags["newExtensions"] = 2] = "newExtensions"; + EntrustInfoFlags[EntrustInfoFlags["pKIXCertificate"] = 4] = "pKIXCertificate"; +})(EntrustInfoFlags || (exports.EntrustInfoFlags = EntrustInfoFlags = {})); +class EntrustInfo extends asn1_schema_1.BitString { + toJSON() { + const res = []; + const flags = this.toNumber(); + if (flags & EntrustInfoFlags.pKIXCertificate) { + res.push("pKIXCertificate"); + } + if (flags & EntrustInfoFlags.newExtensions) { + res.push("newExtensions"); + } + if (flags & EntrustInfoFlags.keyUpdateAllowed) { + res.push("keyUpdateAllowed"); + } + return res; + } + toString() { + return `[${this.toJSON().join(", ")}]`; + } +} +exports.EntrustInfo = EntrustInfo; +class EntrustVersionInfo { + entrustVers = ""; + entrustInfoFlags = new EntrustInfo(); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.EntrustVersionInfo = EntrustVersionInfo; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.GeneralString }) +], EntrustVersionInfo.prototype, "entrustVers", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: EntrustInfo }) +], EntrustVersionInfo.prototype, "entrustInfoFlags", void 0); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/extensions/extended_key_usage.js b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/extended_key_usage.js new file mode 100644 index 0000000000000000000000000000000000000000..23a044bb4d0305cd2d11f428db639f74139250a9 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/extended_key_usage.js @@ -0,0 +1,27 @@ +"use strict"; +var ExtendedKeyUsage_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.id_kp_OCSPSigning = exports.id_kp_timeStamping = exports.id_kp_emailProtection = exports.id_kp_codeSigning = exports.id_kp_clientAuth = exports.id_kp_serverAuth = exports.anyExtendedKeyUsage = exports.ExtendedKeyUsage = exports.id_ce_extKeyUsage = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const object_identifiers_1 = require("../object_identifiers"); +exports.id_ce_extKeyUsage = `${object_identifiers_1.id_ce}.37`; +let ExtendedKeyUsage = ExtendedKeyUsage_1 = class ExtendedKeyUsage extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, ExtendedKeyUsage_1.prototype); + } +}; +exports.ExtendedKeyUsage = ExtendedKeyUsage; +exports.ExtendedKeyUsage = ExtendedKeyUsage = ExtendedKeyUsage_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Sequence, itemType: asn1_schema_1.AsnPropTypes.ObjectIdentifier, + }) +], ExtendedKeyUsage); +exports.anyExtendedKeyUsage = `${exports.id_ce_extKeyUsage}.0`; +exports.id_kp_serverAuth = `${object_identifiers_1.id_kp}.1`; +exports.id_kp_clientAuth = `${object_identifiers_1.id_kp}.2`; +exports.id_kp_codeSigning = `${object_identifiers_1.id_kp}.3`; +exports.id_kp_emailProtection = `${object_identifiers_1.id_kp}.4`; +exports.id_kp_timeStamping = `${object_identifiers_1.id_kp}.8`; +exports.id_kp_OCSPSigning = `${object_identifiers_1.id_kp}.9`; diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/extensions/index.js b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/index.js new file mode 100644 index 0000000000000000000000000000000000000000..9ac3d997745b70abcaa0ffa45d8e2a61a7e2b225 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/index.js @@ -0,0 +1,28 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +tslib_1.__exportStar(require("./authority_information_access"), exports); +tslib_1.__exportStar(require("./authority_key_identifier"), exports); +tslib_1.__exportStar(require("./basic_constraints"), exports); +tslib_1.__exportStar(require("./certificate_issuer"), exports); +tslib_1.__exportStar(require("./certificate_policies"), exports); +tslib_1.__exportStar(require("./crl_delta_indicator"), exports); +tslib_1.__exportStar(require("./crl_distribution_points"), exports); +tslib_1.__exportStar(require("./crl_freshest"), exports); +tslib_1.__exportStar(require("./crl_issuing_distribution_point"), exports); +tslib_1.__exportStar(require("./crl_number"), exports); +tslib_1.__exportStar(require("./crl_reason"), exports); +tslib_1.__exportStar(require("./extended_key_usage"), exports); +tslib_1.__exportStar(require("./inhibit_any_policy"), exports); +tslib_1.__exportStar(require("./invalidity_date"), exports); +tslib_1.__exportStar(require("./issuer_alternative_name"), exports); +tslib_1.__exportStar(require("./key_usage"), exports); +tslib_1.__exportStar(require("./name_constraints"), exports); +tslib_1.__exportStar(require("./policy_constraints"), exports); +tslib_1.__exportStar(require("./policy_mappings"), exports); +tslib_1.__exportStar(require("./subject_alternative_name"), exports); +tslib_1.__exportStar(require("./subject_directory_attributes"), exports); +tslib_1.__exportStar(require("./subject_key_identifier"), exports); +tslib_1.__exportStar(require("./private_key_usage_period"), exports); +tslib_1.__exportStar(require("./entrust_version_info"), exports); +tslib_1.__exportStar(require("./subject_info_access"), exports); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/extensions/inhibit_any_policy.js b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/inhibit_any_policy.js new file mode 100644 index 0000000000000000000000000000000000000000..28b4d757b8252b613930d3688ff0cd235eb5a432 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/inhibit_any_policy.js @@ -0,0 +1,22 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.InhibitAnyPolicy = exports.id_ce_inhibitAnyPolicy = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const object_identifiers_1 = require("../object_identifiers"); +exports.id_ce_inhibitAnyPolicy = `${object_identifiers_1.id_ce}.54`; +let InhibitAnyPolicy = class InhibitAnyPolicy { + value; + constructor(value = new ArrayBuffer(0)) { + this.value = value; + } +}; +exports.InhibitAnyPolicy = InhibitAnyPolicy; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter, + }) +], InhibitAnyPolicy.prototype, "value", void 0); +exports.InhibitAnyPolicy = InhibitAnyPolicy = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], InhibitAnyPolicy); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/extensions/invalidity_date.js b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/invalidity_date.js new file mode 100644 index 0000000000000000000000000000000000000000..6cac1b4c98d06f63944cc40d7da5c0a79ce0c41f --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/invalidity_date.js @@ -0,0 +1,22 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.InvalidityDate = exports.id_ce_invalidityDate = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const object_identifiers_1 = require("../object_identifiers"); +exports.id_ce_invalidityDate = `${object_identifiers_1.id_ce}.24`; +let InvalidityDate = class InvalidityDate { + value = new Date(); + constructor(value) { + if (value) { + this.value = value; + } + } +}; +exports.InvalidityDate = InvalidityDate; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.GeneralizedTime }) +], InvalidityDate.prototype, "value", void 0); +exports.InvalidityDate = InvalidityDate = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], InvalidityDate); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/extensions/issuer_alternative_name.js b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/issuer_alternative_name.js new file mode 100644 index 0000000000000000000000000000000000000000..8d0691c8e842cdda2d6dabd3ca9eb4ae06f351ca --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/issuer_alternative_name.js @@ -0,0 +1,19 @@ +"use strict"; +var IssueAlternativeName_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.IssueAlternativeName = exports.id_ce_issuerAltName = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const general_names_1 = require("../general_names"); +const object_identifiers_1 = require("../object_identifiers"); +exports.id_ce_issuerAltName = `${object_identifiers_1.id_ce}.18`; +let IssueAlternativeName = IssueAlternativeName_1 = class IssueAlternativeName extends general_names_1.GeneralNames { + constructor(items) { + super(items); + Object.setPrototypeOf(this, IssueAlternativeName_1.prototype); + } +}; +exports.IssueAlternativeName = IssueAlternativeName; +exports.IssueAlternativeName = IssueAlternativeName = IssueAlternativeName_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Sequence }) +], IssueAlternativeName); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/extensions/key_usage.js b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/key_usage.js new file mode 100644 index 0000000000000000000000000000000000000000..3b42d58e59a5d29d242bb8d3866d9856acda6375 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/key_usage.js @@ -0,0 +1,56 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KeyUsage = exports.KeyUsageFlags = exports.id_ce_keyUsage = void 0; +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const object_identifiers_1 = require("../object_identifiers"); +exports.id_ce_keyUsage = `${object_identifiers_1.id_ce}.15`; +var KeyUsageFlags; +(function (KeyUsageFlags) { + KeyUsageFlags[KeyUsageFlags["digitalSignature"] = 1] = "digitalSignature"; + KeyUsageFlags[KeyUsageFlags["nonRepudiation"] = 2] = "nonRepudiation"; + KeyUsageFlags[KeyUsageFlags["keyEncipherment"] = 4] = "keyEncipherment"; + KeyUsageFlags[KeyUsageFlags["dataEncipherment"] = 8] = "dataEncipherment"; + KeyUsageFlags[KeyUsageFlags["keyAgreement"] = 16] = "keyAgreement"; + KeyUsageFlags[KeyUsageFlags["keyCertSign"] = 32] = "keyCertSign"; + KeyUsageFlags[KeyUsageFlags["cRLSign"] = 64] = "cRLSign"; + KeyUsageFlags[KeyUsageFlags["encipherOnly"] = 128] = "encipherOnly"; + KeyUsageFlags[KeyUsageFlags["decipherOnly"] = 256] = "decipherOnly"; +})(KeyUsageFlags || (exports.KeyUsageFlags = KeyUsageFlags = {})); +class KeyUsage extends asn1_schema_1.BitString { + toJSON() { + const flag = this.toNumber(); + const res = []; + if (flag & KeyUsageFlags.cRLSign) { + res.push("crlSign"); + } + if (flag & KeyUsageFlags.dataEncipherment) { + res.push("dataEncipherment"); + } + if (flag & KeyUsageFlags.decipherOnly) { + res.push("decipherOnly"); + } + if (flag & KeyUsageFlags.digitalSignature) { + res.push("digitalSignature"); + } + if (flag & KeyUsageFlags.encipherOnly) { + res.push("encipherOnly"); + } + if (flag & KeyUsageFlags.keyAgreement) { + res.push("keyAgreement"); + } + if (flag & KeyUsageFlags.keyCertSign) { + res.push("keyCertSign"); + } + if (flag & KeyUsageFlags.keyEncipherment) { + res.push("keyEncipherment"); + } + if (flag & KeyUsageFlags.nonRepudiation) { + res.push("nonRepudiation"); + } + return res; + } + toString() { + return `[${this.toJSON().join(", ")}]`; + } +} +exports.KeyUsage = KeyUsage; diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/extensions/name_constraints.js b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/name_constraints.js new file mode 100644 index 0000000000000000000000000000000000000000..7ce54639a9ef674d8beae8558f61e7aa403a27c9 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/name_constraints.js @@ -0,0 +1,61 @@ +"use strict"; +var GeneralSubtrees_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.NameConstraints = exports.GeneralSubtrees = exports.GeneralSubtree = exports.id_ce_nameConstraints = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const general_name_1 = require("../general_name"); +const object_identifiers_1 = require("../object_identifiers"); +exports.id_ce_nameConstraints = `${object_identifiers_1.id_ce}.30`; +class GeneralSubtree { + base = new general_name_1.GeneralName(); + minimum = 0; + maximum; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.GeneralSubtree = GeneralSubtree; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: general_name_1.GeneralName }) +], GeneralSubtree.prototype, "base", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, context: 0, defaultValue: 0, implicit: true, + }) +], GeneralSubtree.prototype, "minimum", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, context: 1, optional: true, implicit: true, + }) +], GeneralSubtree.prototype, "maximum", void 0); +let GeneralSubtrees = GeneralSubtrees_1 = class GeneralSubtrees extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, GeneralSubtrees_1.prototype); + } +}; +exports.GeneralSubtrees = GeneralSubtrees; +exports.GeneralSubtrees = GeneralSubtrees = GeneralSubtrees_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Sequence, itemType: GeneralSubtree, + }) +], GeneralSubtrees); +class NameConstraints { + permittedSubtrees; + excludedSubtrees; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.NameConstraints = NameConstraints; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: GeneralSubtrees, context: 0, optional: true, implicit: true, + }) +], NameConstraints.prototype, "permittedSubtrees", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: GeneralSubtrees, context: 1, optional: true, implicit: true, + }) +], NameConstraints.prototype, "excludedSubtrees", void 0); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/extensions/policy_constraints.js b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/policy_constraints.js new file mode 100644 index 0000000000000000000000000000000000000000..7cd2f354a9160904bf0e11c1008bfacc03e6ef57 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/policy_constraints.js @@ -0,0 +1,33 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.PolicyConstraints = exports.id_ce_policyConstraints = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const object_identifiers_1 = require("../object_identifiers"); +exports.id_ce_policyConstraints = `${object_identifiers_1.id_ce}.36`; +class PolicyConstraints { + requireExplicitPolicy; + inhibitPolicyMapping; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.PolicyConstraints = PolicyConstraints; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, + context: 0, + implicit: true, + optional: true, + converter: asn1_schema_1.AsnIntegerArrayBufferConverter, + }) +], PolicyConstraints.prototype, "requireExplicitPolicy", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, + context: 1, + implicit: true, + optional: true, + converter: asn1_schema_1.AsnIntegerArrayBufferConverter, + }) +], PolicyConstraints.prototype, "inhibitPolicyMapping", void 0); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/extensions/policy_mappings.js b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/policy_mappings.js new file mode 100644 index 0000000000000000000000000000000000000000..9b926dcbd7dadc03db3c991e169e66929d4a5097 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/policy_mappings.js @@ -0,0 +1,34 @@ +"use strict"; +var PolicyMappings_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.PolicyMappings = exports.PolicyMapping = exports.id_ce_policyMappings = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const object_identifiers_1 = require("../object_identifiers"); +exports.id_ce_policyMappings = `${object_identifiers_1.id_ce}.33`; +class PolicyMapping { + issuerDomainPolicy = ""; + subjectDomainPolicy = ""; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.PolicyMapping = PolicyMapping; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.ObjectIdentifier }) +], PolicyMapping.prototype, "issuerDomainPolicy", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.ObjectIdentifier }) +], PolicyMapping.prototype, "subjectDomainPolicy", void 0); +let PolicyMappings = PolicyMappings_1 = class PolicyMappings extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, PolicyMappings_1.prototype); + } +}; +exports.PolicyMappings = PolicyMappings; +exports.PolicyMappings = PolicyMappings = PolicyMappings_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Sequence, itemType: PolicyMapping, + }) +], PolicyMappings); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/extensions/private_key_usage_period.js b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/private_key_usage_period.js new file mode 100644 index 0000000000000000000000000000000000000000..75447e8f922e006c7e98da3a2f534a70c0c718ae --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/private_key_usage_period.js @@ -0,0 +1,25 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.PrivateKeyUsagePeriod = exports.id_ce_privateKeyUsagePeriod = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const object_identifiers_1 = require("../object_identifiers"); +exports.id_ce_privateKeyUsagePeriod = `${object_identifiers_1.id_ce}.16`; +class PrivateKeyUsagePeriod { + notBefore; + notAfter; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.PrivateKeyUsagePeriod = PrivateKeyUsagePeriod; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.GeneralizedTime, context: 0, implicit: true, optional: true, + }) +], PrivateKeyUsagePeriod.prototype, "notBefore", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.GeneralizedTime, context: 1, implicit: true, optional: true, + }) +], PrivateKeyUsagePeriod.prototype, "notAfter", void 0); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/extensions/subject_alternative_name.js b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/subject_alternative_name.js new file mode 100644 index 0000000000000000000000000000000000000000..cb9a54ec56f74a55bb6085aaaa7003cf4b8736ac --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/subject_alternative_name.js @@ -0,0 +1,19 @@ +"use strict"; +var SubjectAlternativeName_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SubjectAlternativeName = exports.id_ce_subjectAltName = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const general_names_1 = require("../general_names"); +const object_identifiers_1 = require("../object_identifiers"); +exports.id_ce_subjectAltName = `${object_identifiers_1.id_ce}.17`; +let SubjectAlternativeName = SubjectAlternativeName_1 = class SubjectAlternativeName extends general_names_1.GeneralNames { + constructor(items) { + super(items); + Object.setPrototypeOf(this, SubjectAlternativeName_1.prototype); + } +}; +exports.SubjectAlternativeName = SubjectAlternativeName; +exports.SubjectAlternativeName = SubjectAlternativeName = SubjectAlternativeName_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Sequence }) +], SubjectAlternativeName); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/extensions/subject_directory_attributes.js b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/subject_directory_attributes.js new file mode 100644 index 0000000000000000000000000000000000000000..545a7b21a27693bcf63811d00bdc3a8545135e38 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/subject_directory_attributes.js @@ -0,0 +1,21 @@ +"use strict"; +var SubjectDirectoryAttributes_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SubjectDirectoryAttributes = exports.id_ce_subjectDirectoryAttributes = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const attribute_1 = require("../attribute"); +const object_identifiers_1 = require("../object_identifiers"); +exports.id_ce_subjectDirectoryAttributes = `${object_identifiers_1.id_ce}.9`; +let SubjectDirectoryAttributes = SubjectDirectoryAttributes_1 = class SubjectDirectoryAttributes extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, SubjectDirectoryAttributes_1.prototype); + } +}; +exports.SubjectDirectoryAttributes = SubjectDirectoryAttributes; +exports.SubjectDirectoryAttributes = SubjectDirectoryAttributes = SubjectDirectoryAttributes_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Sequence, itemType: attribute_1.Attribute, + }) +], SubjectDirectoryAttributes); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/extensions/subject_info_access.js b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/subject_info_access.js new file mode 100644 index 0000000000000000000000000000000000000000..4a268aca484089a308a343afd568e6d5690993ad --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/subject_info_access.js @@ -0,0 +1,21 @@ +"use strict"; +var SubjectInfoAccessSyntax_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SubjectInfoAccessSyntax = exports.id_pe_subjectInfoAccess = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const object_identifiers_1 = require("../object_identifiers"); +const authority_information_access_1 = require("./authority_information_access"); +exports.id_pe_subjectInfoAccess = `${object_identifiers_1.id_pe}.11`; +let SubjectInfoAccessSyntax = SubjectInfoAccessSyntax_1 = class SubjectInfoAccessSyntax extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, SubjectInfoAccessSyntax_1.prototype); + } +}; +exports.SubjectInfoAccessSyntax = SubjectInfoAccessSyntax; +exports.SubjectInfoAccessSyntax = SubjectInfoAccessSyntax = SubjectInfoAccessSyntax_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Sequence, itemType: authority_information_access_1.AccessDescription, + }) +], SubjectInfoAccessSyntax); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/extensions/subject_key_identifier.js b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/subject_key_identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..407042105bd09b7b9bcd05f356ce590dc317498d --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/extensions/subject_key_identifier.js @@ -0,0 +1,9 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SubjectKeyIdentifier = exports.id_ce_subjectKeyIdentifier = void 0; +const object_identifiers_1 = require("../object_identifiers"); +const authority_key_identifier_1 = require("./authority_key_identifier"); +exports.id_ce_subjectKeyIdentifier = `${object_identifiers_1.id_ce}.14`; +class SubjectKeyIdentifier extends authority_key_identifier_1.KeyIdentifier { +} +exports.SubjectKeyIdentifier = SubjectKeyIdentifier; diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/general_name.js b/node_modules/@peculiar/asn1-x509/build/cjs/general_name.js new file mode 100644 index 0000000000000000000000000000000000000000..35432bf4a145a3c96b2927091babaded25c46f5b --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/general_name.js @@ -0,0 +1,111 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.GeneralName = exports.EDIPartyName = exports.OtherName = exports.AsnIpConverter = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const ip_converter_1 = require("./ip_converter"); +const name_1 = require("./name"); +exports.AsnIpConverter = { + fromASN: (value) => ip_converter_1.IpConverter.toString(asn1_schema_1.AsnOctetStringConverter.fromASN(value)), + toASN: (value) => asn1_schema_1.AsnOctetStringConverter.toASN(ip_converter_1.IpConverter.fromString(value)), +}; +class OtherName { + typeId = ""; + value = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.OtherName = OtherName; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.ObjectIdentifier }) +], OtherName.prototype, "typeId", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Any, context: 0, + }) +], OtherName.prototype, "value", void 0); +class EDIPartyName { + nameAssigner; + partyName = new name_1.DirectoryString(); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.EDIPartyName = EDIPartyName; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: name_1.DirectoryString, optional: true, context: 0, implicit: true, + }) +], EDIPartyName.prototype, "nameAssigner", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: name_1.DirectoryString, context: 1, implicit: true, + }) +], EDIPartyName.prototype, "partyName", void 0); +let GeneralName = class GeneralName { + otherName; + rfc822Name; + dNSName; + x400Address; + directoryName; + ediPartyName; + uniformResourceIdentifier; + iPAddress; + registeredID; + constructor(params = {}) { + Object.assign(this, params); + } +}; +exports.GeneralName = GeneralName; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: OtherName, context: 0, implicit: true, + }) +], GeneralName.prototype, "otherName", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.IA5String, context: 1, implicit: true, + }) +], GeneralName.prototype, "rfc822Name", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.IA5String, context: 2, implicit: true, + }) +], GeneralName.prototype, "dNSName", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Any, context: 3, implicit: true, + }) +], GeneralName.prototype, "x400Address", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: name_1.Name, context: 4, implicit: false, + }) +], GeneralName.prototype, "directoryName", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: EDIPartyName, context: 5, + }) +], GeneralName.prototype, "ediPartyName", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.IA5String, context: 6, implicit: true, + }) +], GeneralName.prototype, "uniformResourceIdentifier", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.OctetString, + context: 7, + implicit: true, + converter: exports.AsnIpConverter, + }) +], GeneralName.prototype, "iPAddress", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.ObjectIdentifier, context: 8, implicit: true, + }) +], GeneralName.prototype, "registeredID", void 0); +exports.GeneralName = GeneralName = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], GeneralName); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/general_names.js b/node_modules/@peculiar/asn1-x509/build/cjs/general_names.js new file mode 100644 index 0000000000000000000000000000000000000000..110ec4d3dfb1c1464b13db7dd209dfdad4315657 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/general_names.js @@ -0,0 +1,19 @@ +"use strict"; +var GeneralNames_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.GeneralNames = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const general_name_1 = require("./general_name"); +let GeneralNames = GeneralNames_1 = class GeneralNames extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, GeneralNames_1.prototype); + } +}; +exports.GeneralNames = GeneralNames; +exports.GeneralNames = GeneralNames = GeneralNames_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Sequence, itemType: general_name_1.GeneralName, + }) +], GeneralNames); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/index.js b/node_modules/@peculiar/asn1-x509/build/cjs/index.js new file mode 100644 index 0000000000000000000000000000000000000000..03e6cb57434e13e9a31c10c2f12e5285e600c821 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/index.js @@ -0,0 +1,19 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +tslib_1.__exportStar(require("./extensions"), exports); +tslib_1.__exportStar(require("./algorithm_identifier"), exports); +tslib_1.__exportStar(require("./attribute"), exports); +tslib_1.__exportStar(require("./certificate"), exports); +tslib_1.__exportStar(require("./certificate_list"), exports); +tslib_1.__exportStar(require("./extension"), exports); +tslib_1.__exportStar(require("./general_name"), exports); +tslib_1.__exportStar(require("./general_names"), exports); +tslib_1.__exportStar(require("./name"), exports); +tslib_1.__exportStar(require("./object_identifiers"), exports); +tslib_1.__exportStar(require("./subject_public_key_info"), exports); +tslib_1.__exportStar(require("./tbs_cert_list"), exports); +tslib_1.__exportStar(require("./tbs_certificate"), exports); +tslib_1.__exportStar(require("./time"), exports); +tslib_1.__exportStar(require("./types"), exports); +tslib_1.__exportStar(require("./validity"), exports); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/ip_converter.js b/node_modules/@peculiar/asn1-x509/build/cjs/ip_converter.js new file mode 100644 index 0000000000000000000000000000000000000000..e47ec613a4ce1344ba71be038965c865d4e25daa --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/ip_converter.js @@ -0,0 +1,177 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.IpConverter = void 0; +const encoding_1 = require("@peculiar/utils/encoding"); +class IpConverter { + static isIPv4(ip) { + return /^(\d{1,3}\.){3}\d{1,3}$/.test(ip); + } + static parseIPv4(ip) { + const parts = ip.split("."); + if (parts.length !== 4) { + throw new Error("Invalid IPv4 address"); + } + return parts.map((part) => { + const num = parseInt(part, 10); + if (isNaN(num) || num < 0 || num > 255) { + throw new Error("Invalid IPv4 address part"); + } + return num; + }); + } + static parseIPv6(ip) { + const expandedIP = this.expandIPv6(ip); + const parts = expandedIP.split(":"); + if (parts.length !== 8) { + throw new Error("Invalid IPv6 address"); + } + return parts.reduce((bytes, part) => { + const num = parseInt(part, 16); + if (isNaN(num) || num < 0 || num > 0xffff) { + throw new Error("Invalid IPv6 address part"); + } + bytes.push((num >> 8) & 0xff); + bytes.push(num & 0xff); + return bytes; + }, []); + } + static expandIPv6(ip) { + if (!ip.includes("::")) { + return ip; + } + const parts = ip.split("::"); + if (parts.length > 2) { + throw new Error("Invalid IPv6 address"); + } + const left = parts[0] ? parts[0].split(":") : []; + const right = parts[1] ? parts[1].split(":") : []; + const missing = 8 - (left.length + right.length); + if (missing < 0) { + throw new Error("Invalid IPv6 address"); + } + return [...left, ...Array(missing).fill("0"), ...right].join(":"); + } + static formatIPv6(bytes) { + const parts = []; + for (let i = 0; i < 16; i += 2) { + parts.push(((bytes[i] << 8) | bytes[i + 1]).toString(16)); + } + return this.compressIPv6(parts.join(":")); + } + static compressIPv6(ip) { + const parts = ip.split(":"); + let longestZeroStart = -1; + let longestZeroLength = 0; + let currentZeroStart = -1; + let currentZeroLength = 0; + for (let i = 0; i < parts.length; i++) { + if (parts[i] === "0") { + if (currentZeroStart === -1) { + currentZeroStart = i; + } + currentZeroLength++; + } + else { + if (currentZeroLength > longestZeroLength) { + longestZeroStart = currentZeroStart; + longestZeroLength = currentZeroLength; + } + currentZeroStart = -1; + currentZeroLength = 0; + } + } + if (currentZeroLength > longestZeroLength) { + longestZeroStart = currentZeroStart; + longestZeroLength = currentZeroLength; + } + if (longestZeroLength > 1) { + const before = parts.slice(0, longestZeroStart).join(":"); + const after = parts.slice(longestZeroStart + longestZeroLength).join(":"); + return `${before}::${after}`; + } + return ip; + } + static parseCIDR(text) { + const [addr, prefixStr] = text.split("/"); + const prefix = parseInt(prefixStr, 10); + if (this.isIPv4(addr)) { + if (prefix < 0 || prefix > 32) { + throw new Error("Invalid IPv4 prefix length"); + } + return [this.parseIPv4(addr), prefix]; + } + else { + if (prefix < 0 || prefix > 128) { + throw new Error("Invalid IPv6 prefix length"); + } + return [this.parseIPv6(addr), prefix]; + } + } + static decodeIP(value) { + if (value.length === 64 && parseInt(value, 16) === 0) { + return "::/0"; + } + if (value.length !== 16) { + return value; + } + const mask = parseInt(value.slice(8), 16) + .toString(2) + .split("") + .reduce((a, k) => a + +k, 0); + let ip = value.slice(0, 8).replace(/(.{2})/g, (match) => `${parseInt(match, 16)}.`); + ip = ip.slice(0, -1); + return `${ip}/${mask}`; + } + static toString(buf) { + const uint8 = new Uint8Array(buf); + if (uint8.length === 4) { + return Array.from(uint8).join("."); + } + if (uint8.length === 16) { + return this.formatIPv6(uint8); + } + if (uint8.length === 8 || uint8.length === 32) { + const half = uint8.length / 2; + const addrBytes = uint8.slice(0, half); + const maskBytes = uint8.slice(half); + const isAllZeros = uint8.every((byte) => byte === 0); + if (isAllZeros) { + return uint8.length === 8 ? "0.0.0.0/0" : "::/0"; + } + const prefixLen = maskBytes.reduce((a, b) => a + (b.toString(2).match(/1/g) || []).length, 0); + if (uint8.length === 8) { + const addrStr = Array.from(addrBytes).join("."); + return `${addrStr}/${prefixLen}`; + } + else { + const addrStr = this.formatIPv6(addrBytes); + return `${addrStr}/${prefixLen}`; + } + } + return this.decodeIP(encoding_1.hex.encode(buf)); + } + static fromString(text) { + if (text.includes("/")) { + const [addr, prefix] = this.parseCIDR(text); + const maskBytes = new Uint8Array(addr.length); + let bitsLeft = prefix; + for (let i = 0; i < maskBytes.length; i++) { + if (bitsLeft >= 8) { + maskBytes[i] = 0xff; + bitsLeft -= 8; + } + else if (bitsLeft > 0) { + maskBytes[i] = 0xff << (8 - bitsLeft); + bitsLeft = 0; + } + } + const out = new Uint8Array(addr.length * 2); + out.set(addr, 0); + out.set(maskBytes, addr.length); + return out.buffer; + } + const bytes = this.isIPv4(text) ? this.parseIPv4(text) : this.parseIPv6(text); + return new Uint8Array(bytes).buffer; + } +} +exports.IpConverter = IpConverter; diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/name.js b/node_modules/@peculiar/asn1-x509/build/cjs/name.js new file mode 100644 index 0000000000000000000000000000000000000000..f39e77768e9209db9f2257de931e67c18a6859fb --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/name.js @@ -0,0 +1,113 @@ +"use strict"; +var RelativeDistinguishedName_1, RDNSequence_1, Name_1; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Name = exports.RDNSequence = exports.RelativeDistinguishedName = exports.AttributeTypeAndValue = exports.AttributeValue = exports.DirectoryString = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const encoding_1 = require("@peculiar/utils/encoding"); +let DirectoryString = class DirectoryString { + teletexString; + printableString; + universalString; + utf8String; + bmpString; + constructor(params = {}) { + Object.assign(this, params); + } + toString() { + return (this.bmpString + || this.printableString + || this.teletexString + || this.universalString + || this.utf8String + || ""); + } +}; +exports.DirectoryString = DirectoryString; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.TeletexString }) +], DirectoryString.prototype, "teletexString", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.PrintableString }) +], DirectoryString.prototype, "printableString", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.UniversalString }) +], DirectoryString.prototype, "universalString", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Utf8String }) +], DirectoryString.prototype, "utf8String", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.BmpString }) +], DirectoryString.prototype, "bmpString", void 0); +exports.DirectoryString = DirectoryString = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], DirectoryString); +let AttributeValue = class AttributeValue extends DirectoryString { + ia5String; + anyValue; + constructor(params = {}) { + super(params); + Object.assign(this, params); + } + toString() { + return this.ia5String || (this.anyValue ? encoding_1.hex.encode(this.anyValue) : super.toString()); + } +}; +exports.AttributeValue = AttributeValue; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.IA5String }) +], AttributeValue.prototype, "ia5String", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Any }) +], AttributeValue.prototype, "anyValue", void 0); +exports.AttributeValue = AttributeValue = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], AttributeValue); +class AttributeTypeAndValue { + type = ""; + value = new AttributeValue(); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.AttributeTypeAndValue = AttributeTypeAndValue; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.ObjectIdentifier }) +], AttributeTypeAndValue.prototype, "type", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: AttributeValue }) +], AttributeTypeAndValue.prototype, "value", void 0); +let RelativeDistinguishedName = RelativeDistinguishedName_1 = class RelativeDistinguishedName extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, RelativeDistinguishedName_1.prototype); + } +}; +exports.RelativeDistinguishedName = RelativeDistinguishedName; +exports.RelativeDistinguishedName = RelativeDistinguishedName = RelativeDistinguishedName_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Set, itemType: AttributeTypeAndValue, + }) +], RelativeDistinguishedName); +let RDNSequence = RDNSequence_1 = class RDNSequence extends asn1_schema_1.AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, RDNSequence_1.prototype); + } +}; +exports.RDNSequence = RDNSequence; +exports.RDNSequence = RDNSequence = RDNSequence_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ + type: asn1_schema_1.AsnTypeTypes.Sequence, itemType: RelativeDistinguishedName, + }) +], RDNSequence); +let Name = Name_1 = class Name extends RDNSequence { + constructor(items) { + super(items); + Object.setPrototypeOf(this, Name_1.prototype); + } +}; +exports.Name = Name; +exports.Name = Name = Name_1 = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Sequence }) +], Name); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/object_identifiers.js b/node_modules/@peculiar/asn1-x509/build/cjs/object_identifiers.js new file mode 100644 index 0000000000000000000000000000000000000000..d850ceafa26b3bd12d9682fa9c417759362d9ac7 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/object_identifiers.js @@ -0,0 +1,15 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.id_ce = exports.id_ad_caRepository = exports.id_ad_timeStamping = exports.id_ad_caIssuers = exports.id_ad_ocsp = exports.id_qt_unotice = exports.id_qt_csp = exports.id_ad = exports.id_kp = exports.id_qt = exports.id_pe = exports.id_pkix = void 0; +exports.id_pkix = "1.3.6.1.5.5.7"; +exports.id_pe = `${exports.id_pkix}.1`; +exports.id_qt = `${exports.id_pkix}.2`; +exports.id_kp = `${exports.id_pkix}.3`; +exports.id_ad = `${exports.id_pkix}.48`; +exports.id_qt_csp = `${exports.id_qt}.1`; +exports.id_qt_unotice = `${exports.id_qt}.2`; +exports.id_ad_ocsp = `${exports.id_ad}.1`; +exports.id_ad_caIssuers = `${exports.id_ad}.2`; +exports.id_ad_timeStamping = `${exports.id_ad}.3`; +exports.id_ad_caRepository = `${exports.id_ad}.5`; +exports.id_ce = "2.5.29"; diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/subject_public_key_info.js b/node_modules/@peculiar/asn1-x509/build/cjs/subject_public_key_info.js new file mode 100644 index 0000000000000000000000000000000000000000..77a5152e1680057471aa0e206b40e94d9be3f17c --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/subject_public_key_info.js @@ -0,0 +1,20 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SubjectPublicKeyInfo = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const algorithm_identifier_1 = require("./algorithm_identifier"); +class SubjectPublicKeyInfo { + algorithm = new algorithm_identifier_1.AlgorithmIdentifier(); + subjectPublicKey = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.SubjectPublicKeyInfo = SubjectPublicKeyInfo; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: algorithm_identifier_1.AlgorithmIdentifier }) +], SubjectPublicKeyInfo.prototype, "algorithm", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.BitString }) +], SubjectPublicKeyInfo.prototype, "subjectPublicKey", void 0); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/tbs_cert_list.js b/node_modules/@peculiar/asn1-x509/build/cjs/tbs_cert_list.js new file mode 100644 index 0000000000000000000000000000000000000000..b6ccfdca16f316b776e6b078d646c873dedea614 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/tbs_cert_list.js @@ -0,0 +1,73 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.TBSCertList = exports.RevokedCertificate = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const algorithm_identifier_1 = require("./algorithm_identifier"); +const name_1 = require("./name"); +const time_1 = require("./time"); +const extension_1 = require("./extension"); +class RevokedCertificate { + userCertificate = new ArrayBuffer(0); + revocationDate = new time_1.Time(); + crlEntryExtensions; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.RevokedCertificate = RevokedCertificate; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter, + }) +], RevokedCertificate.prototype, "userCertificate", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: time_1.Time }) +], RevokedCertificate.prototype, "revocationDate", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: extension_1.Extension, optional: true, repeated: "sequence", + }) +], RevokedCertificate.prototype, "crlEntryExtensions", void 0); +class TBSCertList { + version; + signature = new algorithm_identifier_1.AlgorithmIdentifier(); + issuer = new name_1.Name(); + thisUpdate = new time_1.Time(); + nextUpdate; + revokedCertificates; + crlExtensions; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.TBSCertList = TBSCertList; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, optional: true, + }) +], TBSCertList.prototype, "version", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: algorithm_identifier_1.AlgorithmIdentifier }) +], TBSCertList.prototype, "signature", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: name_1.Name }) +], TBSCertList.prototype, "issuer", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: time_1.Time }) +], TBSCertList.prototype, "thisUpdate", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: time_1.Time, optional: true, + }) +], TBSCertList.prototype, "nextUpdate", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: RevokedCertificate, repeated: "sequence", optional: true, + }) +], TBSCertList.prototype, "revokedCertificates", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: extension_1.Extension, optional: true, context: 0, repeated: "sequence", + }) +], TBSCertList.prototype, "crlExtensions", void 0); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/tbs_certificate.js b/node_modules/@peculiar/asn1-x509/build/cjs/tbs_certificate.js new file mode 100644 index 0000000000000000000000000000000000000000..6a5f78d0e3c547c5644f6cf20ac84209d4637ab6 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/tbs_certificate.js @@ -0,0 +1,73 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.TBSCertificate = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const algorithm_identifier_1 = require("./algorithm_identifier"); +const name_1 = require("./name"); +const subject_public_key_info_1 = require("./subject_public_key_info"); +const validity_1 = require("./validity"); +const extension_1 = require("./extension"); +const types_1 = require("./types"); +class TBSCertificate { + version = types_1.Version.v1; + serialNumber = new ArrayBuffer(0); + signature = new algorithm_identifier_1.AlgorithmIdentifier(); + issuer = new name_1.Name(); + validity = new validity_1.Validity(); + subject = new name_1.Name(); + subjectPublicKeyInfo = new subject_public_key_info_1.SubjectPublicKeyInfo(); + issuerUniqueID; + subjectUniqueID; + extensions; + constructor(params = {}) { + Object.assign(this, params); + } +} +exports.TBSCertificate = TBSCertificate; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, + context: 0, + defaultValue: types_1.Version.v1, + }) +], TBSCertificate.prototype, "version", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.Integer, + converter: asn1_schema_1.AsnIntegerArrayBufferConverter, + }) +], TBSCertificate.prototype, "serialNumber", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: algorithm_identifier_1.AlgorithmIdentifier }) +], TBSCertificate.prototype, "signature", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: name_1.Name }) +], TBSCertificate.prototype, "issuer", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: validity_1.Validity }) +], TBSCertificate.prototype, "validity", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: name_1.Name }) +], TBSCertificate.prototype, "subject", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: subject_public_key_info_1.SubjectPublicKeyInfo }) +], TBSCertificate.prototype, "subjectPublicKeyInfo", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.BitString, + context: 1, + implicit: true, + optional: true, + }) +], TBSCertificate.prototype, "issuerUniqueID", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: asn1_schema_1.AsnPropTypes.BitString, context: 2, implicit: true, optional: true, + }) +], TBSCertificate.prototype, "subjectUniqueID", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ + type: extension_1.Extensions, context: 3, optional: true, + }) +], TBSCertificate.prototype, "extensions", void 0); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/time.js b/node_modules/@peculiar/asn1-x509/build/cjs/time.js new file mode 100644 index 0000000000000000000000000000000000000000..dac705edbe81f4551689db6e0746379a48fdea8b --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/time.js @@ -0,0 +1,43 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Time = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +let Time = class Time { + utcTime; + generalTime; + constructor(time) { + if (time) { + if (typeof time === "string" || typeof time === "number" || time instanceof Date) { + const date = new Date(time); + date.setMilliseconds(0); + if (date.getUTCFullYear() > 2049) { + this.generalTime = date; + } + else { + this.utcTime = date; + } + } + else { + Object.assign(this, time); + } + } + } + getTime() { + const time = this.utcTime || this.generalTime; + if (!time) { + throw new Error("Cannot get time from CHOICE object"); + } + return time; + } +}; +exports.Time = Time; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.UTCTime }) +], Time.prototype, "utcTime", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.GeneralizedTime }) +], Time.prototype, "generalTime", void 0); +exports.Time = Time = tslib_1.__decorate([ + (0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice }) +], Time); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/types.js b/node_modules/@peculiar/asn1-x509/build/cjs/types.js new file mode 100644 index 0000000000000000000000000000000000000000..d820e8b7cc241c2b1acb60187ff75544a1399091 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/types.js @@ -0,0 +1,9 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Version = void 0; +var Version; +(function (Version) { + Version[Version["v1"] = 0] = "v1"; + Version[Version["v2"] = 1] = "v2"; + Version[Version["v3"] = 2] = "v3"; +})(Version || (exports.Version = Version = {})); diff --git a/node_modules/@peculiar/asn1-x509/build/cjs/validity.js b/node_modules/@peculiar/asn1-x509/build/cjs/validity.js new file mode 100644 index 0000000000000000000000000000000000000000..344479f107656f0b1d5b31b2bd8411cc470f7ceb --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/cjs/validity.js @@ -0,0 +1,23 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Validity = void 0; +const tslib_1 = require("tslib"); +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const time_1 = require("./time"); +class Validity { + notBefore = new time_1.Time(new Date()); + notAfter = new time_1.Time(new Date()); + constructor(params) { + if (params) { + this.notBefore = new time_1.Time(params.notBefore); + this.notAfter = new time_1.Time(params.notAfter); + } + } +} +exports.Validity = Validity; +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: time_1.Time }) +], Validity.prototype, "notBefore", void 0); +tslib_1.__decorate([ + (0, asn1_schema_1.AsnProp)({ type: time_1.Time }) +], Validity.prototype, "notAfter", void 0); diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/algorithm_identifier.js b/node_modules/@peculiar/asn1-x509/build/es2015/algorithm_identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..24d8dcd0c6cd0a543627fe9c79e817e79c840ab6 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/algorithm_identifier.js @@ -0,0 +1,27 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes } from "@peculiar/asn1-schema"; +import { equal } from "@peculiar/utils/bytes"; +export class AlgorithmIdentifier { + algorithm = ""; + parameters; + constructor(params = {}) { + Object.assign(this, params); + } + isEqual(data) { + return (data instanceof AlgorithmIdentifier + && data.algorithm == this.algorithm + && ((data.parameters + && this.parameters + && equal(data.parameters, this.parameters)) + || data.parameters === this.parameters)); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.ObjectIdentifier }) +], AlgorithmIdentifier.prototype, "algorithm", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Any, + optional: true, + }) +], AlgorithmIdentifier.prototype, "parameters", void 0); diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/attribute.js b/node_modules/@peculiar/asn1-x509/build/es2015/attribute.js new file mode 100644 index 0000000000000000000000000000000000000000..909333ee551e952b2bfd1465f4e52f95620270f7 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/attribute.js @@ -0,0 +1,17 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes } from "@peculiar/asn1-schema"; +export class Attribute { + type = ""; + values = []; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.ObjectIdentifier }) +], Attribute.prototype, "type", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Any, repeated: "set", + }) +], Attribute.prototype, "values", void 0); diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/certificate.js b/node_modules/@peculiar/asn1-x509/build/es2015/certificate.js new file mode 100644 index 0000000000000000000000000000000000000000..3481247a617cf8b1c17e2149d1b18497cf9a9334 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/certificate.js @@ -0,0 +1,24 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes } from "@peculiar/asn1-schema"; +import { AlgorithmIdentifier } from "./algorithm_identifier.js"; +import { TBSCertificate } from "./tbs_certificate.js"; +export class Certificate { + tbsCertificate = new TBSCertificate(); + tbsCertificateRaw; + signatureAlgorithm = new AlgorithmIdentifier(); + signatureValue = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ + type: TBSCertificate, raw: true, + }) +], Certificate.prototype, "tbsCertificate", void 0); +__decorate([ + AsnProp({ type: AlgorithmIdentifier }) +], Certificate.prototype, "signatureAlgorithm", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.BitString }) +], Certificate.prototype, "signatureValue", void 0); diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/certificate_list.js b/node_modules/@peculiar/asn1-x509/build/es2015/certificate_list.js new file mode 100644 index 0000000000000000000000000000000000000000..99825e3bb68ea4cdd3d6a88798194e6ce186e2b6 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/certificate_list.js @@ -0,0 +1,24 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes } from "@peculiar/asn1-schema"; +import { AlgorithmIdentifier } from "./algorithm_identifier.js"; +import { TBSCertList } from "./tbs_cert_list.js"; +export class CertificateList { + tbsCertList = new TBSCertList(); + tbsCertListRaw; + signatureAlgorithm = new AlgorithmIdentifier(); + signature = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ + type: TBSCertList, raw: true, + }) +], CertificateList.prototype, "tbsCertList", void 0); +__decorate([ + AsnProp({ type: AlgorithmIdentifier }) +], CertificateList.prototype, "signatureAlgorithm", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.BitString }) +], CertificateList.prototype, "signature", void 0); diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/extension.js b/node_modules/@peculiar/asn1-x509/build/es2015/extension.js new file mode 100644 index 0000000000000000000000000000000000000000..2386dc460b5544003040e535036442ca2faea533 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/extension.js @@ -0,0 +1,36 @@ +var Extensions_1; +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnArray, AsnType, AsnTypeTypes, OctetString, } from "@peculiar/asn1-schema"; +export class Extension { + static CRITICAL = false; + extnID = ""; + critical = Extension.CRITICAL; + extnValue = new OctetString(); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.ObjectIdentifier }) +], Extension.prototype, "extnID", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Boolean, + defaultValue: Extension.CRITICAL, + }) +], Extension.prototype, "critical", void 0); +__decorate([ + AsnProp({ type: OctetString }) +], Extension.prototype, "extnValue", void 0); +let Extensions = Extensions_1 = class Extensions extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, Extensions_1.prototype); + } +}; +Extensions = Extensions_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Sequence, itemType: Extension, + }) +], Extensions); +export { Extensions }; diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/extensions/authority_information_access.js b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/authority_information_access.js new file mode 100644 index 0000000000000000000000000000000000000000..2681302bc50d42b5584a7f7b413624c0a7b21ac1 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/authority_information_access.js @@ -0,0 +1,31 @@ +var AuthorityInfoAccessSyntax_1; +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnArray, AsnType, AsnTypeTypes, } from "@peculiar/asn1-schema"; +import { GeneralName } from "../general_name.js"; +import { id_pe } from "../object_identifiers.js"; +export const id_pe_authorityInfoAccess = `${id_pe}.1`; +export class AccessDescription { + accessMethod = ""; + accessLocation = new GeneralName(); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.ObjectIdentifier }) +], AccessDescription.prototype, "accessMethod", void 0); +__decorate([ + AsnProp({ type: GeneralName }) +], AccessDescription.prototype, "accessLocation", void 0); +let AuthorityInfoAccessSyntax = AuthorityInfoAccessSyntax_1 = class AuthorityInfoAccessSyntax extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, AuthorityInfoAccessSyntax_1.prototype); + } +}; +AuthorityInfoAccessSyntax = AuthorityInfoAccessSyntax_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Sequence, itemType: AccessDescription, + }) +], AuthorityInfoAccessSyntax); +export { AuthorityInfoAccessSyntax }; diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/extensions/authority_key_identifier.js b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/authority_key_identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..11f4c656ac84f69cd27ec23006377f3ecc95e507 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/authority_key_identifier.js @@ -0,0 +1,36 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnIntegerArrayBufferConverter, OctetString, } from "@peculiar/asn1-schema"; +import { GeneralName } from "../general_name.js"; +import { id_ce } from "../object_identifiers.js"; +export const id_ce_authorityKeyIdentifier = `${id_ce}.35`; +export class KeyIdentifier extends OctetString { +} +export class AuthorityKeyIdentifier { + keyIdentifier; + authorityCertIssuer; + authorityCertSerialNumber; + constructor(params = {}) { + if (params) { + Object.assign(this, params); + } + } +} +__decorate([ + AsnProp({ + type: KeyIdentifier, context: 0, optional: true, implicit: true, + }) +], AuthorityKeyIdentifier.prototype, "keyIdentifier", void 0); +__decorate([ + AsnProp({ + type: GeneralName, context: 1, optional: true, implicit: true, repeated: "sequence", + }) +], AuthorityKeyIdentifier.prototype, "authorityCertIssuer", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, + context: 2, + optional: true, + implicit: true, + converter: AsnIntegerArrayBufferConverter, + }) +], AuthorityKeyIdentifier.prototype, "authorityCertSerialNumber", void 0); diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/extensions/basic_constraints.js b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/basic_constraints.js new file mode 100644 index 0000000000000000000000000000000000000000..1e8178162e6bb40d78d6f51cd4fe2c45b4e10eaa --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/basic_constraints.js @@ -0,0 +1,21 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes } from "@peculiar/asn1-schema"; +import { id_ce } from "../object_identifiers.js"; +export const id_ce_basicConstraints = `${id_ce}.19`; +export class BasicConstraints { + cA = false; + pathLenConstraint; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ + type: AsnPropTypes.Boolean, defaultValue: false, + }) +], BasicConstraints.prototype, "cA", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, optional: true, + }) +], BasicConstraints.prototype, "pathLenConstraint", void 0); diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/extensions/certificate_issuer.js b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/certificate_issuer.js new file mode 100644 index 0000000000000000000000000000000000000000..5d131ba6b858a9ec0e76a4ffc4cfee893c8445c4 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/certificate_issuer.js @@ -0,0 +1,16 @@ +var CertificateIssuer_1; +import { __decorate } from "tslib"; +import { AsnType, AsnTypeTypes } from "@peculiar/asn1-schema"; +import { GeneralNames } from "../general_names.js"; +import { id_ce } from "../object_identifiers.js"; +export const id_ce_certificateIssuer = `${id_ce}.29`; +let CertificateIssuer = CertificateIssuer_1 = class CertificateIssuer extends GeneralNames { + constructor(items) { + super(items); + Object.setPrototypeOf(this, CertificateIssuer_1.prototype); + } +}; +CertificateIssuer = CertificateIssuer_1 = __decorate([ + AsnType({ type: AsnTypeTypes.Sequence }) +], CertificateIssuer); +export { CertificateIssuer }; diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/extensions/certificate_policies.js b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/certificate_policies.js new file mode 100644 index 0000000000000000000000000000000000000000..ae278de9e7dfc7787f5be27c84c5e2bea038675b --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/certificate_policies.js @@ -0,0 +1,123 @@ +var CertificatePolicies_1; +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnType, AsnTypeTypes, AsnArray, } from "@peculiar/asn1-schema"; +import { id_ce } from "../object_identifiers.js"; +export const id_ce_certificatePolicies = `${id_ce}.32`; +export const id_ce_certificatePolicies_anyPolicy = `${id_ce_certificatePolicies}.0`; +let DisplayText = class DisplayText { + ia5String; + visibleString; + bmpString; + utf8String; + constructor(params = {}) { + Object.assign(this, params); + } + toString() { + return this.ia5String || this.visibleString || this.bmpString || this.utf8String || ""; + } +}; +__decorate([ + AsnProp({ type: AsnPropTypes.IA5String }) +], DisplayText.prototype, "ia5String", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.VisibleString }) +], DisplayText.prototype, "visibleString", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.BmpString }) +], DisplayText.prototype, "bmpString", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.Utf8String }) +], DisplayText.prototype, "utf8String", void 0); +DisplayText = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], DisplayText); +export { DisplayText }; +export class NoticeReference { + organization = new DisplayText(); + noticeNumbers = []; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: DisplayText }) +], NoticeReference.prototype, "organization", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, repeated: "sequence", + }) +], NoticeReference.prototype, "noticeNumbers", void 0); +export class UserNotice { + noticeRef; + explicitText; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ + type: NoticeReference, optional: true, + }) +], UserNotice.prototype, "noticeRef", void 0); +__decorate([ + AsnProp({ + type: DisplayText, optional: true, + }) +], UserNotice.prototype, "explicitText", void 0); +let Qualifier = class Qualifier { + cPSuri; + userNotice; + constructor(params = {}) { + Object.assign(this, params); + } +}; +__decorate([ + AsnProp({ type: AsnPropTypes.IA5String }) +], Qualifier.prototype, "cPSuri", void 0); +__decorate([ + AsnProp({ type: UserNotice }) +], Qualifier.prototype, "userNotice", void 0); +Qualifier = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], Qualifier); +export { Qualifier }; +export class PolicyQualifierInfo { + policyQualifierId = ""; + qualifier = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.ObjectIdentifier }) +], PolicyQualifierInfo.prototype, "policyQualifierId", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.Any }) +], PolicyQualifierInfo.prototype, "qualifier", void 0); +export class PolicyInformation { + policyIdentifier = ""; + policyQualifiers; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.ObjectIdentifier }) +], PolicyInformation.prototype, "policyIdentifier", void 0); +__decorate([ + AsnProp({ + type: PolicyQualifierInfo, repeated: "sequence", optional: true, + }) +], PolicyInformation.prototype, "policyQualifiers", void 0); +let CertificatePolicies = CertificatePolicies_1 = class CertificatePolicies extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, CertificatePolicies_1.prototype); + } +}; +CertificatePolicies = CertificatePolicies_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Sequence, itemType: PolicyInformation, + }) +], CertificatePolicies); +export { CertificatePolicies }; diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/extensions/crl_delta_indicator.js b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/crl_delta_indicator.js new file mode 100644 index 0000000000000000000000000000000000000000..1f4b7df2dba9c521a81ae4ac27870471e329866b --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/crl_delta_indicator.js @@ -0,0 +1,11 @@ +import { __decorate } from "tslib"; +import { AsnType, AsnTypeTypes } from "@peculiar/asn1-schema"; +import { id_ce } from "../object_identifiers.js"; +import { CRLNumber } from "./crl_number.js"; +export const id_ce_deltaCRLIndicator = `${id_ce}.27`; +let BaseCRLNumber = class BaseCRLNumber extends CRLNumber { +}; +BaseCRLNumber = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], BaseCRLNumber); +export { BaseCRLNumber }; diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/extensions/crl_distribution_points.js b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/crl_distribution_points.js new file mode 100644 index 0000000000000000000000000000000000000000..4a4446f78e1854d70e96036c9a0575cc152ce287 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/crl_distribution_points.js @@ -0,0 +1,112 @@ +var CRLDistributionPoints_1; +import { __decorate } from "tslib"; +import { AsnProp, AsnType, AsnTypeTypes, AsnArray, BitString, } from "@peculiar/asn1-schema"; +import { RelativeDistinguishedName } from "../name.js"; +import { GeneralName } from "../general_name.js"; +import { id_ce } from "../object_identifiers.js"; +export const id_ce_cRLDistributionPoints = `${id_ce}.31`; +export var ReasonFlags; +(function (ReasonFlags) { + ReasonFlags[ReasonFlags["unused"] = 1] = "unused"; + ReasonFlags[ReasonFlags["keyCompromise"] = 2] = "keyCompromise"; + ReasonFlags[ReasonFlags["cACompromise"] = 4] = "cACompromise"; + ReasonFlags[ReasonFlags["affiliationChanged"] = 8] = "affiliationChanged"; + ReasonFlags[ReasonFlags["superseded"] = 16] = "superseded"; + ReasonFlags[ReasonFlags["cessationOfOperation"] = 32] = "cessationOfOperation"; + ReasonFlags[ReasonFlags["certificateHold"] = 64] = "certificateHold"; + ReasonFlags[ReasonFlags["privilegeWithdrawn"] = 128] = "privilegeWithdrawn"; + ReasonFlags[ReasonFlags["aACompromise"] = 256] = "aACompromise"; +})(ReasonFlags || (ReasonFlags = {})); +export class Reason extends BitString { + toJSON() { + const res = []; + const flags = this.toNumber(); + if (flags & ReasonFlags.aACompromise) { + res.push("aACompromise"); + } + if (flags & ReasonFlags.affiliationChanged) { + res.push("affiliationChanged"); + } + if (flags & ReasonFlags.cACompromise) { + res.push("cACompromise"); + } + if (flags & ReasonFlags.certificateHold) { + res.push("certificateHold"); + } + if (flags & ReasonFlags.cessationOfOperation) { + res.push("cessationOfOperation"); + } + if (flags & ReasonFlags.keyCompromise) { + res.push("keyCompromise"); + } + if (flags & ReasonFlags.privilegeWithdrawn) { + res.push("privilegeWithdrawn"); + } + if (flags & ReasonFlags.superseded) { + res.push("superseded"); + } + if (flags & ReasonFlags.unused) { + res.push("unused"); + } + return res; + } + toString() { + return `[${this.toJSON().join(", ")}]`; + } +} +let DistributionPointName = class DistributionPointName { + fullName; + nameRelativeToCRLIssuer; + constructor(params = {}) { + Object.assign(this, params); + } +}; +__decorate([ + AsnProp({ + type: GeneralName, context: 0, repeated: "sequence", implicit: true, + }) +], DistributionPointName.prototype, "fullName", void 0); +__decorate([ + AsnProp({ + type: RelativeDistinguishedName, context: 1, implicit: true, + }) +], DistributionPointName.prototype, "nameRelativeToCRLIssuer", void 0); +DistributionPointName = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], DistributionPointName); +export { DistributionPointName }; +export class DistributionPoint { + distributionPoint; + reasons; + cRLIssuer; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ + type: DistributionPointName, context: 0, optional: true, + }) +], DistributionPoint.prototype, "distributionPoint", void 0); +__decorate([ + AsnProp({ + type: Reason, context: 1, optional: true, implicit: true, + }) +], DistributionPoint.prototype, "reasons", void 0); +__decorate([ + AsnProp({ + type: GeneralName, context: 2, optional: true, repeated: "sequence", implicit: true, + }) +], DistributionPoint.prototype, "cRLIssuer", void 0); +let CRLDistributionPoints = CRLDistributionPoints_1 = class CRLDistributionPoints extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, CRLDistributionPoints_1.prototype); + } +}; +CRLDistributionPoints = CRLDistributionPoints_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Sequence, itemType: DistributionPoint, + }) +], CRLDistributionPoints); +export { CRLDistributionPoints }; diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/extensions/crl_freshest.js b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/crl_freshest.js new file mode 100644 index 0000000000000000000000000000000000000000..2b05e4827f08782bb472929db4e3f16c76aa3e66 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/crl_freshest.js @@ -0,0 +1,18 @@ +var FreshestCRL_1; +import { __decorate } from "tslib"; +import { AsnType, AsnTypeTypes } from "@peculiar/asn1-schema"; +import { id_ce } from "../object_identifiers.js"; +import { CRLDistributionPoints, DistributionPoint } from "./crl_distribution_points.js"; +export const id_ce_freshestCRL = `${id_ce}.46`; +let FreshestCRL = FreshestCRL_1 = class FreshestCRL extends CRLDistributionPoints { + constructor(items) { + super(items); + Object.setPrototypeOf(this, FreshestCRL_1.prototype); + } +}; +FreshestCRL = FreshestCRL_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Sequence, itemType: DistributionPoint, + }) +], FreshestCRL); +export { FreshestCRL }; diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/extensions/crl_issuing_distribution_point.js b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/crl_issuing_distribution_point.js new file mode 100644 index 0000000000000000000000000000000000000000..fdce57286bc4ca199d33b4c27ee25f7bb85fe929 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/crl_issuing_distribution_point.js @@ -0,0 +1,59 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes } from "@peculiar/asn1-schema"; +import { id_ce } from "../object_identifiers.js"; +import { DistributionPointName, Reason } from "./crl_distribution_points.js"; +export const id_ce_issuingDistributionPoint = `${id_ce}.28`; +export class IssuingDistributionPoint { + static ONLY = false; + distributionPoint; + onlyContainsUserCerts = IssuingDistributionPoint.ONLY; + onlyContainsCACerts = IssuingDistributionPoint.ONLY; + onlySomeReasons; + indirectCRL = IssuingDistributionPoint.ONLY; + onlyContainsAttributeCerts = IssuingDistributionPoint.ONLY; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ + type: DistributionPointName, context: 0, optional: true, + }) +], IssuingDistributionPoint.prototype, "distributionPoint", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Boolean, + context: 1, + defaultValue: IssuingDistributionPoint.ONLY, + implicit: true, + }) +], IssuingDistributionPoint.prototype, "onlyContainsUserCerts", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Boolean, + context: 2, + defaultValue: IssuingDistributionPoint.ONLY, + implicit: true, + }) +], IssuingDistributionPoint.prototype, "onlyContainsCACerts", void 0); +__decorate([ + AsnProp({ + type: Reason, context: 3, optional: true, implicit: true, + }) +], IssuingDistributionPoint.prototype, "onlySomeReasons", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Boolean, + context: 4, + defaultValue: IssuingDistributionPoint.ONLY, + implicit: true, + }) +], IssuingDistributionPoint.prototype, "indirectCRL", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Boolean, + context: 5, + defaultValue: IssuingDistributionPoint.ONLY, + implicit: true, + }) +], IssuingDistributionPoint.prototype, "onlyContainsAttributeCerts", void 0); diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/extensions/crl_number.js b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/crl_number.js new file mode 100644 index 0000000000000000000000000000000000000000..eb7c7b6ec8cc76028395c2e22ea5811a666a56a9 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/crl_number.js @@ -0,0 +1,17 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnType, AsnTypeTypes, } from "@peculiar/asn1-schema"; +import { id_ce } from "../object_identifiers.js"; +export const id_ce_cRLNumber = `${id_ce}.20`; +let CRLNumber = class CRLNumber { + value; + constructor(value = 0) { + this.value = value; + } +}; +__decorate([ + AsnProp({ type: AsnPropTypes.Integer }) +], CRLNumber.prototype, "value", void 0); +CRLNumber = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], CRLNumber); +export { CRLNumber }; diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/extensions/crl_reason.js b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/crl_reason.js new file mode 100644 index 0000000000000000000000000000000000000000..92a1130c9ea7465a55867e203441332c2587a3e7 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/crl_reason.js @@ -0,0 +1,36 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnType, AsnTypeTypes, } from "@peculiar/asn1-schema"; +import { id_ce } from "../object_identifiers.js"; +export const id_ce_cRLReasons = `${id_ce}.21`; +export var CRLReasons; +(function (CRLReasons) { + CRLReasons[CRLReasons["unspecified"] = 0] = "unspecified"; + CRLReasons[CRLReasons["keyCompromise"] = 1] = "keyCompromise"; + CRLReasons[CRLReasons["cACompromise"] = 2] = "cACompromise"; + CRLReasons[CRLReasons["affiliationChanged"] = 3] = "affiliationChanged"; + CRLReasons[CRLReasons["superseded"] = 4] = "superseded"; + CRLReasons[CRLReasons["cessationOfOperation"] = 5] = "cessationOfOperation"; + CRLReasons[CRLReasons["certificateHold"] = 6] = "certificateHold"; + CRLReasons[CRLReasons["removeFromCRL"] = 8] = "removeFromCRL"; + CRLReasons[CRLReasons["privilegeWithdrawn"] = 9] = "privilegeWithdrawn"; + CRLReasons[CRLReasons["aACompromise"] = 10] = "aACompromise"; +})(CRLReasons || (CRLReasons = {})); +let CRLReason = class CRLReason { + reason = CRLReasons.unspecified; + constructor(reason = CRLReasons.unspecified) { + this.reason = reason; + } + toJSON() { + return CRLReasons[this.reason]; + } + toString() { + return this.toJSON(); + } +}; +__decorate([ + AsnProp({ type: AsnPropTypes.Enumerated }) +], CRLReason.prototype, "reason", void 0); +CRLReason = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], CRLReason); +export { CRLReason }; diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/extensions/entrust_version_info.js b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/entrust_version_info.js new file mode 100644 index 0000000000000000000000000000000000000000..3dc5b568966e9ac23a46fa6f903181e133be9acd --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/entrust_version_info.js @@ -0,0 +1,41 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, BitString, } from "@peculiar/asn1-schema"; +export const id_entrust_entrustVersInfo = "1.2.840.113533.7.65.0"; +export var EntrustInfoFlags; +(function (EntrustInfoFlags) { + EntrustInfoFlags[EntrustInfoFlags["keyUpdateAllowed"] = 1] = "keyUpdateAllowed"; + EntrustInfoFlags[EntrustInfoFlags["newExtensions"] = 2] = "newExtensions"; + EntrustInfoFlags[EntrustInfoFlags["pKIXCertificate"] = 4] = "pKIXCertificate"; +})(EntrustInfoFlags || (EntrustInfoFlags = {})); +export class EntrustInfo extends BitString { + toJSON() { + const res = []; + const flags = this.toNumber(); + if (flags & EntrustInfoFlags.pKIXCertificate) { + res.push("pKIXCertificate"); + } + if (flags & EntrustInfoFlags.newExtensions) { + res.push("newExtensions"); + } + if (flags & EntrustInfoFlags.keyUpdateAllowed) { + res.push("keyUpdateAllowed"); + } + return res; + } + toString() { + return `[${this.toJSON().join(", ")}]`; + } +} +export class EntrustVersionInfo { + entrustVers = ""; + entrustInfoFlags = new EntrustInfo(); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.GeneralString }) +], EntrustVersionInfo.prototype, "entrustVers", void 0); +__decorate([ + AsnProp({ type: EntrustInfo }) +], EntrustVersionInfo.prototype, "entrustInfoFlags", void 0); diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/extensions/extended_key_usage.js b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/extended_key_usage.js new file mode 100644 index 0000000000000000000000000000000000000000..1f4df86c43b26c2842521dbfc15cdf854587971c --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/extended_key_usage.js @@ -0,0 +1,24 @@ +var ExtendedKeyUsage_1; +import { __decorate } from "tslib"; +import { AsnPropTypes, AsnArray, AsnType, AsnTypeTypes, } from "@peculiar/asn1-schema"; +import { id_ce, id_kp } from "../object_identifiers.js"; +export const id_ce_extKeyUsage = `${id_ce}.37`; +let ExtendedKeyUsage = ExtendedKeyUsage_1 = class ExtendedKeyUsage extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, ExtendedKeyUsage_1.prototype); + } +}; +ExtendedKeyUsage = ExtendedKeyUsage_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Sequence, itemType: AsnPropTypes.ObjectIdentifier, + }) +], ExtendedKeyUsage); +export { ExtendedKeyUsage }; +export const anyExtendedKeyUsage = `${id_ce_extKeyUsage}.0`; +export const id_kp_serverAuth = `${id_kp}.1`; +export const id_kp_clientAuth = `${id_kp}.2`; +export const id_kp_codeSigning = `${id_kp}.3`; +export const id_kp_emailProtection = `${id_kp}.4`; +export const id_kp_timeStamping = `${id_kp}.8`; +export const id_kp_OCSPSigning = `${id_kp}.9`; diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/extensions/index.js b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/index.js new file mode 100644 index 0000000000000000000000000000000000000000..6ca4766726a3925a55daa4b266039822615b373f --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/index.js @@ -0,0 +1,25 @@ +export * from "./authority_information_access.js"; +export * from "./authority_key_identifier.js"; +export * from "./basic_constraints.js"; +export * from "./certificate_issuer.js"; +export * from "./certificate_policies.js"; +export * from "./crl_delta_indicator.js"; +export * from "./crl_distribution_points.js"; +export * from "./crl_freshest.js"; +export * from "./crl_issuing_distribution_point.js"; +export * from "./crl_number.js"; +export * from "./crl_reason.js"; +export * from "./extended_key_usage.js"; +export * from "./inhibit_any_policy.js"; +export * from "./invalidity_date.js"; +export * from "./issuer_alternative_name.js"; +export * from "./key_usage.js"; +export * from "./name_constraints.js"; +export * from "./policy_constraints.js"; +export * from "./policy_mappings.js"; +export * from "./subject_alternative_name.js"; +export * from "./subject_directory_attributes.js"; +export * from "./subject_key_identifier.js"; +export * from "./private_key_usage_period.js"; +export * from "./entrust_version_info.js"; +export * from "./subject_info_access.js"; diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/extensions/inhibit_any_policy.js b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/inhibit_any_policy.js new file mode 100644 index 0000000000000000000000000000000000000000..99f9ecdc2d70d0157462683ab2f73f7ad0ab6492 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/inhibit_any_policy.js @@ -0,0 +1,19 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnType, AsnTypeTypes, AsnIntegerArrayBufferConverter, } from "@peculiar/asn1-schema"; +import { id_ce } from "../object_identifiers.js"; +export const id_ce_inhibitAnyPolicy = `${id_ce}.54`; +let InhibitAnyPolicy = class InhibitAnyPolicy { + value; + constructor(value = new ArrayBuffer(0)) { + this.value = value; + } +}; +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter, + }) +], InhibitAnyPolicy.prototype, "value", void 0); +InhibitAnyPolicy = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], InhibitAnyPolicy); +export { InhibitAnyPolicy }; diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/extensions/invalidity_date.js b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/invalidity_date.js new file mode 100644 index 0000000000000000000000000000000000000000..06e502e31248848ded7d72fc25169f37d4b84e01 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/invalidity_date.js @@ -0,0 +1,19 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnType, AsnTypeTypes, } from "@peculiar/asn1-schema"; +import { id_ce } from "../object_identifiers.js"; +export const id_ce_invalidityDate = `${id_ce}.24`; +let InvalidityDate = class InvalidityDate { + value = new Date(); + constructor(value) { + if (value) { + this.value = value; + } + } +}; +__decorate([ + AsnProp({ type: AsnPropTypes.GeneralizedTime }) +], InvalidityDate.prototype, "value", void 0); +InvalidityDate = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], InvalidityDate); +export { InvalidityDate }; diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/extensions/issuer_alternative_name.js b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/issuer_alternative_name.js new file mode 100644 index 0000000000000000000000000000000000000000..c383fb6476a51ba191a6a798d4a804649fd00a92 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/issuer_alternative_name.js @@ -0,0 +1,16 @@ +var IssueAlternativeName_1; +import { __decorate } from "tslib"; +import { AsnType, AsnTypeTypes } from "@peculiar/asn1-schema"; +import { GeneralNames } from "../general_names.js"; +import { id_ce } from "../object_identifiers.js"; +export const id_ce_issuerAltName = `${id_ce}.18`; +let IssueAlternativeName = IssueAlternativeName_1 = class IssueAlternativeName extends GeneralNames { + constructor(items) { + super(items); + Object.setPrototypeOf(this, IssueAlternativeName_1.prototype); + } +}; +IssueAlternativeName = IssueAlternativeName_1 = __decorate([ + AsnType({ type: AsnTypeTypes.Sequence }) +], IssueAlternativeName); +export { IssueAlternativeName }; diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/extensions/key_usage.js b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/key_usage.js new file mode 100644 index 0000000000000000000000000000000000000000..e2fcf918528ef16ea4acc781ee619c3611a4ef53 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/key_usage.js @@ -0,0 +1,52 @@ +import { BitString } from "@peculiar/asn1-schema"; +import { id_ce } from "../object_identifiers.js"; +export const id_ce_keyUsage = `${id_ce}.15`; +export var KeyUsageFlags; +(function (KeyUsageFlags) { + KeyUsageFlags[KeyUsageFlags["digitalSignature"] = 1] = "digitalSignature"; + KeyUsageFlags[KeyUsageFlags["nonRepudiation"] = 2] = "nonRepudiation"; + KeyUsageFlags[KeyUsageFlags["keyEncipherment"] = 4] = "keyEncipherment"; + KeyUsageFlags[KeyUsageFlags["dataEncipherment"] = 8] = "dataEncipherment"; + KeyUsageFlags[KeyUsageFlags["keyAgreement"] = 16] = "keyAgreement"; + KeyUsageFlags[KeyUsageFlags["keyCertSign"] = 32] = "keyCertSign"; + KeyUsageFlags[KeyUsageFlags["cRLSign"] = 64] = "cRLSign"; + KeyUsageFlags[KeyUsageFlags["encipherOnly"] = 128] = "encipherOnly"; + KeyUsageFlags[KeyUsageFlags["decipherOnly"] = 256] = "decipherOnly"; +})(KeyUsageFlags || (KeyUsageFlags = {})); +export class KeyUsage extends BitString { + toJSON() { + const flag = this.toNumber(); + const res = []; + if (flag & KeyUsageFlags.cRLSign) { + res.push("crlSign"); + } + if (flag & KeyUsageFlags.dataEncipherment) { + res.push("dataEncipherment"); + } + if (flag & KeyUsageFlags.decipherOnly) { + res.push("decipherOnly"); + } + if (flag & KeyUsageFlags.digitalSignature) { + res.push("digitalSignature"); + } + if (flag & KeyUsageFlags.encipherOnly) { + res.push("encipherOnly"); + } + if (flag & KeyUsageFlags.keyAgreement) { + res.push("keyAgreement"); + } + if (flag & KeyUsageFlags.keyCertSign) { + res.push("keyCertSign"); + } + if (flag & KeyUsageFlags.keyEncipherment) { + res.push("keyEncipherment"); + } + if (flag & KeyUsageFlags.nonRepudiation) { + res.push("nonRepudiation"); + } + return res; + } + toString() { + return `[${this.toJSON().join(", ")}]`; + } +} diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/extensions/name_constraints.js b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/name_constraints.js new file mode 100644 index 0000000000000000000000000000000000000000..286911aa44de1c369f6f3fd9b085aea5027cb86d --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/name_constraints.js @@ -0,0 +1,56 @@ +var GeneralSubtrees_1; +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnArray, AsnType, AsnTypeTypes, } from "@peculiar/asn1-schema"; +import { GeneralName } from "../general_name.js"; +import { id_ce } from "../object_identifiers.js"; +export const id_ce_nameConstraints = `${id_ce}.30`; +export class GeneralSubtree { + base = new GeneralName(); + minimum = 0; + maximum; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: GeneralName }) +], GeneralSubtree.prototype, "base", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, context: 0, defaultValue: 0, implicit: true, + }) +], GeneralSubtree.prototype, "minimum", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, context: 1, optional: true, implicit: true, + }) +], GeneralSubtree.prototype, "maximum", void 0); +let GeneralSubtrees = GeneralSubtrees_1 = class GeneralSubtrees extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, GeneralSubtrees_1.prototype); + } +}; +GeneralSubtrees = GeneralSubtrees_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Sequence, itemType: GeneralSubtree, + }) +], GeneralSubtrees); +export { GeneralSubtrees }; +export class NameConstraints { + permittedSubtrees; + excludedSubtrees; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ + type: GeneralSubtrees, context: 0, optional: true, implicit: true, + }) +], NameConstraints.prototype, "permittedSubtrees", void 0); +__decorate([ + AsnProp({ + type: GeneralSubtrees, context: 1, optional: true, implicit: true, + }) +], NameConstraints.prototype, "excludedSubtrees", void 0); diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/extensions/policy_constraints.js b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/policy_constraints.js new file mode 100644 index 0000000000000000000000000000000000000000..be9d5ccfa9ecc726cca31d72df3e43e1ecd2394a --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/policy_constraints.js @@ -0,0 +1,29 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnIntegerArrayBufferConverter, } from "@peculiar/asn1-schema"; +import { id_ce } from "../object_identifiers.js"; +export const id_ce_policyConstraints = `${id_ce}.36`; +export class PolicyConstraints { + requireExplicitPolicy; + inhibitPolicyMapping; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, + context: 0, + implicit: true, + optional: true, + converter: AsnIntegerArrayBufferConverter, + }) +], PolicyConstraints.prototype, "requireExplicitPolicy", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, + context: 1, + implicit: true, + optional: true, + converter: AsnIntegerArrayBufferConverter, + }) +], PolicyConstraints.prototype, "inhibitPolicyMapping", void 0); diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/extensions/policy_mappings.js b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/policy_mappings.js new file mode 100644 index 0000000000000000000000000000000000000000..d4c109808841388c9a5959ed25f8fc1c46db7e56 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/policy_mappings.js @@ -0,0 +1,30 @@ +var PolicyMappings_1; +import { __decorate } from "tslib"; +import { AsnArray, AsnProp, AsnPropTypes, AsnType, AsnTypeTypes, } from "@peculiar/asn1-schema"; +import { id_ce } from "../object_identifiers.js"; +export const id_ce_policyMappings = `${id_ce}.33`; +export class PolicyMapping { + issuerDomainPolicy = ""; + subjectDomainPolicy = ""; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.ObjectIdentifier }) +], PolicyMapping.prototype, "issuerDomainPolicy", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.ObjectIdentifier }) +], PolicyMapping.prototype, "subjectDomainPolicy", void 0); +let PolicyMappings = PolicyMappings_1 = class PolicyMappings extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, PolicyMappings_1.prototype); + } +}; +PolicyMappings = PolicyMappings_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Sequence, itemType: PolicyMapping, + }) +], PolicyMappings); +export { PolicyMappings }; diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/extensions/private_key_usage_period.js b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/private_key_usage_period.js new file mode 100644 index 0000000000000000000000000000000000000000..12f91aac0b38cab7bc78519eec6a0f6fdc3db377 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/private_key_usage_period.js @@ -0,0 +1,21 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes } from "@peculiar/asn1-schema"; +import { id_ce } from "../object_identifiers.js"; +export const id_ce_privateKeyUsagePeriod = `${id_ce}.16`; +export class PrivateKeyUsagePeriod { + notBefore; + notAfter; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ + type: AsnPropTypes.GeneralizedTime, context: 0, implicit: true, optional: true, + }) +], PrivateKeyUsagePeriod.prototype, "notBefore", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.GeneralizedTime, context: 1, implicit: true, optional: true, + }) +], PrivateKeyUsagePeriod.prototype, "notAfter", void 0); diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/extensions/subject_alternative_name.js b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/subject_alternative_name.js new file mode 100644 index 0000000000000000000000000000000000000000..47fc20f7c966556ad525e8551f2d8e693571d135 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/subject_alternative_name.js @@ -0,0 +1,16 @@ +var SubjectAlternativeName_1; +import { __decorate } from "tslib"; +import { AsnType, AsnTypeTypes } from "@peculiar/asn1-schema"; +import { GeneralNames } from "../general_names.js"; +import { id_ce } from "../object_identifiers.js"; +export const id_ce_subjectAltName = `${id_ce}.17`; +let SubjectAlternativeName = SubjectAlternativeName_1 = class SubjectAlternativeName extends GeneralNames { + constructor(items) { + super(items); + Object.setPrototypeOf(this, SubjectAlternativeName_1.prototype); + } +}; +SubjectAlternativeName = SubjectAlternativeName_1 = __decorate([ + AsnType({ type: AsnTypeTypes.Sequence }) +], SubjectAlternativeName); +export { SubjectAlternativeName }; diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/extensions/subject_directory_attributes.js b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/subject_directory_attributes.js new file mode 100644 index 0000000000000000000000000000000000000000..57310d6da1c75b14c1d28b208388a6be5383b8ea --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/subject_directory_attributes.js @@ -0,0 +1,18 @@ +var SubjectDirectoryAttributes_1; +import { __decorate } from "tslib"; +import { AsnArray, AsnType, AsnTypeTypes, } from "@peculiar/asn1-schema"; +import { Attribute } from "../attribute.js"; +import { id_ce } from "../object_identifiers.js"; +export const id_ce_subjectDirectoryAttributes = `${id_ce}.9`; +let SubjectDirectoryAttributes = SubjectDirectoryAttributes_1 = class SubjectDirectoryAttributes extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, SubjectDirectoryAttributes_1.prototype); + } +}; +SubjectDirectoryAttributes = SubjectDirectoryAttributes_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Sequence, itemType: Attribute, + }) +], SubjectDirectoryAttributes); +export { SubjectDirectoryAttributes }; diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/extensions/subject_info_access.js b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/subject_info_access.js new file mode 100644 index 0000000000000000000000000000000000000000..c224a942b5be27e43d5f183dec2a92126faa9c31 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/subject_info_access.js @@ -0,0 +1,18 @@ +var SubjectInfoAccessSyntax_1; +import { __decorate } from "tslib"; +import { AsnArray, AsnType, AsnTypeTypes, } from "@peculiar/asn1-schema"; +import { id_pe } from "../object_identifiers.js"; +import { AccessDescription } from "./authority_information_access.js"; +export const id_pe_subjectInfoAccess = `${id_pe}.11`; +let SubjectInfoAccessSyntax = SubjectInfoAccessSyntax_1 = class SubjectInfoAccessSyntax extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, SubjectInfoAccessSyntax_1.prototype); + } +}; +SubjectInfoAccessSyntax = SubjectInfoAccessSyntax_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Sequence, itemType: AccessDescription, + }) +], SubjectInfoAccessSyntax); +export { SubjectInfoAccessSyntax }; diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/extensions/subject_key_identifier.js b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/subject_key_identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..5afd58be469f0fbb279ceb632cb77c47e8f3be9c --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/extensions/subject_key_identifier.js @@ -0,0 +1,5 @@ +import { id_ce } from "../object_identifiers.js"; +import { KeyIdentifier } from "./authority_key_identifier.js"; +export const id_ce_subjectKeyIdentifier = `${id_ce}.14`; +export class SubjectKeyIdentifier extends KeyIdentifier { +} diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/general_name.js b/node_modules/@peculiar/asn1-x509/build/es2015/general_name.js new file mode 100644 index 0000000000000000000000000000000000000000..8cb5430ffd69e8c96be863634264304c95c13ba8 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/general_name.js @@ -0,0 +1,106 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnType, AsnTypeTypes, AsnOctetStringConverter, } from "@peculiar/asn1-schema"; +import { IpConverter } from "./ip_converter.js"; +import { DirectoryString, Name } from "./name.js"; +export const AsnIpConverter = { + fromASN: (value) => IpConverter.toString(AsnOctetStringConverter.fromASN(value)), + toASN: (value) => AsnOctetStringConverter.toASN(IpConverter.fromString(value)), +}; +export class OtherName { + typeId = ""; + value = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.ObjectIdentifier }) +], OtherName.prototype, "typeId", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Any, context: 0, + }) +], OtherName.prototype, "value", void 0); +export class EDIPartyName { + nameAssigner; + partyName = new DirectoryString(); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ + type: DirectoryString, optional: true, context: 0, implicit: true, + }) +], EDIPartyName.prototype, "nameAssigner", void 0); +__decorate([ + AsnProp({ + type: DirectoryString, context: 1, implicit: true, + }) +], EDIPartyName.prototype, "partyName", void 0); +let GeneralName = class GeneralName { + otherName; + rfc822Name; + dNSName; + x400Address; + directoryName; + ediPartyName; + uniformResourceIdentifier; + iPAddress; + registeredID; + constructor(params = {}) { + Object.assign(this, params); + } +}; +__decorate([ + AsnProp({ + type: OtherName, context: 0, implicit: true, + }) +], GeneralName.prototype, "otherName", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.IA5String, context: 1, implicit: true, + }) +], GeneralName.prototype, "rfc822Name", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.IA5String, context: 2, implicit: true, + }) +], GeneralName.prototype, "dNSName", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Any, context: 3, implicit: true, + }) +], GeneralName.prototype, "x400Address", void 0); +__decorate([ + AsnProp({ + type: Name, context: 4, implicit: false, + }) +], GeneralName.prototype, "directoryName", void 0); +__decorate([ + AsnProp({ + type: EDIPartyName, context: 5, + }) +], GeneralName.prototype, "ediPartyName", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.IA5String, context: 6, implicit: true, + }) +], GeneralName.prototype, "uniformResourceIdentifier", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.OctetString, + context: 7, + implicit: true, + converter: AsnIpConverter, + }) +], GeneralName.prototype, "iPAddress", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.ObjectIdentifier, context: 8, implicit: true, + }) +], GeneralName.prototype, "registeredID", void 0); +GeneralName = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], GeneralName); +export { GeneralName }; diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/general_names.js b/node_modules/@peculiar/asn1-x509/build/es2015/general_names.js new file mode 100644 index 0000000000000000000000000000000000000000..37e135693e175ac63a2897bf828d1a101ee51517 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/general_names.js @@ -0,0 +1,16 @@ +var GeneralNames_1; +import { __decorate } from "tslib"; +import { AsnType, AsnTypeTypes, AsnArray, } from "@peculiar/asn1-schema"; +import { GeneralName } from "./general_name.js"; +let GeneralNames = GeneralNames_1 = class GeneralNames extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, GeneralNames_1.prototype); + } +}; +GeneralNames = GeneralNames_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Sequence, itemType: GeneralName, + }) +], GeneralNames); +export { GeneralNames }; diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/index.js b/node_modules/@peculiar/asn1-x509/build/es2015/index.js new file mode 100644 index 0000000000000000000000000000000000000000..2d4db38392000bb6f1d1a232f007e2ea6f0c1195 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/index.js @@ -0,0 +1,16 @@ +export * from "./extensions/index.js"; +export * from "./algorithm_identifier.js"; +export * from "./attribute.js"; +export * from "./certificate.js"; +export * from "./certificate_list.js"; +export * from "./extension.js"; +export * from "./general_name.js"; +export * from "./general_names.js"; +export * from "./name.js"; +export * from "./object_identifiers.js"; +export * from "./subject_public_key_info.js"; +export * from "./tbs_cert_list.js"; +export * from "./tbs_certificate.js"; +export * from "./time.js"; +export * from "./types.js"; +export * from "./validity.js"; diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/ip_converter.js b/node_modules/@peculiar/asn1-x509/build/es2015/ip_converter.js new file mode 100644 index 0000000000000000000000000000000000000000..bdb48e51ba690d74c0ade747f67944de51111f80 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/ip_converter.js @@ -0,0 +1,173 @@ +import { hex } from "@peculiar/utils/encoding"; +export class IpConverter { + static isIPv4(ip) { + return /^(\d{1,3}\.){3}\d{1,3}$/.test(ip); + } + static parseIPv4(ip) { + const parts = ip.split("."); + if (parts.length !== 4) { + throw new Error("Invalid IPv4 address"); + } + return parts.map((part) => { + const num = parseInt(part, 10); + if (isNaN(num) || num < 0 || num > 255) { + throw new Error("Invalid IPv4 address part"); + } + return num; + }); + } + static parseIPv6(ip) { + const expandedIP = this.expandIPv6(ip); + const parts = expandedIP.split(":"); + if (parts.length !== 8) { + throw new Error("Invalid IPv6 address"); + } + return parts.reduce((bytes, part) => { + const num = parseInt(part, 16); + if (isNaN(num) || num < 0 || num > 0xffff) { + throw new Error("Invalid IPv6 address part"); + } + bytes.push((num >> 8) & 0xff); + bytes.push(num & 0xff); + return bytes; + }, []); + } + static expandIPv6(ip) { + if (!ip.includes("::")) { + return ip; + } + const parts = ip.split("::"); + if (parts.length > 2) { + throw new Error("Invalid IPv6 address"); + } + const left = parts[0] ? parts[0].split(":") : []; + const right = parts[1] ? parts[1].split(":") : []; + const missing = 8 - (left.length + right.length); + if (missing < 0) { + throw new Error("Invalid IPv6 address"); + } + return [...left, ...Array(missing).fill("0"), ...right].join(":"); + } + static formatIPv6(bytes) { + const parts = []; + for (let i = 0; i < 16; i += 2) { + parts.push(((bytes[i] << 8) | bytes[i + 1]).toString(16)); + } + return this.compressIPv6(parts.join(":")); + } + static compressIPv6(ip) { + const parts = ip.split(":"); + let longestZeroStart = -1; + let longestZeroLength = 0; + let currentZeroStart = -1; + let currentZeroLength = 0; + for (let i = 0; i < parts.length; i++) { + if (parts[i] === "0") { + if (currentZeroStart === -1) { + currentZeroStart = i; + } + currentZeroLength++; + } + else { + if (currentZeroLength > longestZeroLength) { + longestZeroStart = currentZeroStart; + longestZeroLength = currentZeroLength; + } + currentZeroStart = -1; + currentZeroLength = 0; + } + } + if (currentZeroLength > longestZeroLength) { + longestZeroStart = currentZeroStart; + longestZeroLength = currentZeroLength; + } + if (longestZeroLength > 1) { + const before = parts.slice(0, longestZeroStart).join(":"); + const after = parts.slice(longestZeroStart + longestZeroLength).join(":"); + return `${before}::${after}`; + } + return ip; + } + static parseCIDR(text) { + const [addr, prefixStr] = text.split("/"); + const prefix = parseInt(prefixStr, 10); + if (this.isIPv4(addr)) { + if (prefix < 0 || prefix > 32) { + throw new Error("Invalid IPv4 prefix length"); + } + return [this.parseIPv4(addr), prefix]; + } + else { + if (prefix < 0 || prefix > 128) { + throw new Error("Invalid IPv6 prefix length"); + } + return [this.parseIPv6(addr), prefix]; + } + } + static decodeIP(value) { + if (value.length === 64 && parseInt(value, 16) === 0) { + return "::/0"; + } + if (value.length !== 16) { + return value; + } + const mask = parseInt(value.slice(8), 16) + .toString(2) + .split("") + .reduce((a, k) => a + +k, 0); + let ip = value.slice(0, 8).replace(/(.{2})/g, (match) => `${parseInt(match, 16)}.`); + ip = ip.slice(0, -1); + return `${ip}/${mask}`; + } + static toString(buf) { + const uint8 = new Uint8Array(buf); + if (uint8.length === 4) { + return Array.from(uint8).join("."); + } + if (uint8.length === 16) { + return this.formatIPv6(uint8); + } + if (uint8.length === 8 || uint8.length === 32) { + const half = uint8.length / 2; + const addrBytes = uint8.slice(0, half); + const maskBytes = uint8.slice(half); + const isAllZeros = uint8.every((byte) => byte === 0); + if (isAllZeros) { + return uint8.length === 8 ? "0.0.0.0/0" : "::/0"; + } + const prefixLen = maskBytes.reduce((a, b) => a + (b.toString(2).match(/1/g) || []).length, 0); + if (uint8.length === 8) { + const addrStr = Array.from(addrBytes).join("."); + return `${addrStr}/${prefixLen}`; + } + else { + const addrStr = this.formatIPv6(addrBytes); + return `${addrStr}/${prefixLen}`; + } + } + return this.decodeIP(hex.encode(buf)); + } + static fromString(text) { + if (text.includes("/")) { + const [addr, prefix] = this.parseCIDR(text); + const maskBytes = new Uint8Array(addr.length); + let bitsLeft = prefix; + for (let i = 0; i < maskBytes.length; i++) { + if (bitsLeft >= 8) { + maskBytes[i] = 0xff; + bitsLeft -= 8; + } + else if (bitsLeft > 0) { + maskBytes[i] = 0xff << (8 - bitsLeft); + bitsLeft = 0; + } + } + const out = new Uint8Array(addr.length * 2); + out.set(addr, 0); + out.set(maskBytes, addr.length); + return out.buffer; + } + const bytes = this.isIPv4(text) ? this.parseIPv4(text) : this.parseIPv6(text); + return new Uint8Array(bytes).buffer; + } +} diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/name.js b/node_modules/@peculiar/asn1-x509/build/es2015/name.js new file mode 100644 index 0000000000000000000000000000000000000000..58681186c868ba3539b022af9bc924bf2b96c683 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/name.js @@ -0,0 +1,109 @@ +var RelativeDistinguishedName_1, RDNSequence_1, Name_1; +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnType, AsnTypeTypes, AsnArray, } from "@peculiar/asn1-schema"; +import { hex } from "@peculiar/utils/encoding"; +let DirectoryString = class DirectoryString { + teletexString; + printableString; + universalString; + utf8String; + bmpString; + constructor(params = {}) { + Object.assign(this, params); + } + toString() { + return (this.bmpString + || this.printableString + || this.teletexString + || this.universalString + || this.utf8String + || ""); + } +}; +__decorate([ + AsnProp({ type: AsnPropTypes.TeletexString }) +], DirectoryString.prototype, "teletexString", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.PrintableString }) +], DirectoryString.prototype, "printableString", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.UniversalString }) +], DirectoryString.prototype, "universalString", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.Utf8String }) +], DirectoryString.prototype, "utf8String", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.BmpString }) +], DirectoryString.prototype, "bmpString", void 0); +DirectoryString = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], DirectoryString); +export { DirectoryString }; +let AttributeValue = class AttributeValue extends DirectoryString { + ia5String; + anyValue; + constructor(params = {}) { + super(params); + Object.assign(this, params); + } + toString() { + return this.ia5String || (this.anyValue ? hex.encode(this.anyValue) : super.toString()); + } +}; +__decorate([ + AsnProp({ type: AsnPropTypes.IA5String }) +], AttributeValue.prototype, "ia5String", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.Any }) +], AttributeValue.prototype, "anyValue", void 0); +AttributeValue = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], AttributeValue); +export { AttributeValue }; +export class AttributeTypeAndValue { + type = ""; + value = new AttributeValue(); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AsnPropTypes.ObjectIdentifier }) +], AttributeTypeAndValue.prototype, "type", void 0); +__decorate([ + AsnProp({ type: AttributeValue }) +], AttributeTypeAndValue.prototype, "value", void 0); +let RelativeDistinguishedName = RelativeDistinguishedName_1 = class RelativeDistinguishedName extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, RelativeDistinguishedName_1.prototype); + } +}; +RelativeDistinguishedName = RelativeDistinguishedName_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Set, itemType: AttributeTypeAndValue, + }) +], RelativeDistinguishedName); +export { RelativeDistinguishedName }; +let RDNSequence = RDNSequence_1 = class RDNSequence extends AsnArray { + constructor(items) { + super(items); + Object.setPrototypeOf(this, RDNSequence_1.prototype); + } +}; +RDNSequence = RDNSequence_1 = __decorate([ + AsnType({ + type: AsnTypeTypes.Sequence, itemType: RelativeDistinguishedName, + }) +], RDNSequence); +export { RDNSequence }; +let Name = Name_1 = class Name extends RDNSequence { + constructor(items) { + super(items); + Object.setPrototypeOf(this, Name_1.prototype); + } +}; +Name = Name_1 = __decorate([ + AsnType({ type: AsnTypeTypes.Sequence }) +], Name); +export { Name }; diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/object_identifiers.js b/node_modules/@peculiar/asn1-x509/build/es2015/object_identifiers.js new file mode 100644 index 0000000000000000000000000000000000000000..f0a824684629a55224ede92df1a0b3d0e5216533 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/object_identifiers.js @@ -0,0 +1,12 @@ +export const id_pkix = "1.3.6.1.5.5.7"; +export const id_pe = `${id_pkix}.1`; +export const id_qt = `${id_pkix}.2`; +export const id_kp = `${id_pkix}.3`; +export const id_ad = `${id_pkix}.48`; +export const id_qt_csp = `${id_qt}.1`; +export const id_qt_unotice = `${id_qt}.2`; +export const id_ad_ocsp = `${id_ad}.1`; +export const id_ad_caIssuers = `${id_ad}.2`; +export const id_ad_timeStamping = `${id_ad}.3`; +export const id_ad_caRepository = `${id_ad}.5`; +export const id_ce = "2.5.29"; diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/package.json b/node_modules/@peculiar/asn1-x509/build/es2015/package.json new file mode 100644 index 0000000000000000000000000000000000000000..3dbc1ca591c0557e35b6004aeba250e6a70b56e3 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/subject_public_key_info.js b/node_modules/@peculiar/asn1-x509/build/es2015/subject_public_key_info.js new file mode 100644 index 0000000000000000000000000000000000000000..23e9d03d3a961d023e2691487eb40def590ffd9d --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/subject_public_key_info.js @@ -0,0 +1,16 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes } from "@peculiar/asn1-schema"; +import { AlgorithmIdentifier } from "./algorithm_identifier.js"; +export class SubjectPublicKeyInfo { + algorithm = new AlgorithmIdentifier(); + subjectPublicKey = new ArrayBuffer(0); + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ type: AlgorithmIdentifier }) +], SubjectPublicKeyInfo.prototype, "algorithm", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.BitString }) +], SubjectPublicKeyInfo.prototype, "subjectPublicKey", void 0); diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/tbs_cert_list.js b/node_modules/@peculiar/asn1-x509/build/es2015/tbs_cert_list.js new file mode 100644 index 0000000000000000000000000000000000000000..16ea4af8361a69fa59656f98d5e2b0ca957156e6 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/tbs_cert_list.js @@ -0,0 +1,68 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnIntegerArrayBufferConverter, } from "@peculiar/asn1-schema"; +import { AlgorithmIdentifier } from "./algorithm_identifier.js"; +import { Name } from "./name.js"; +import { Time } from "./time.js"; +import { Extension } from "./extension.js"; +export class RevokedCertificate { + userCertificate = new ArrayBuffer(0); + revocationDate = new Time(); + crlEntryExtensions; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter, + }) +], RevokedCertificate.prototype, "userCertificate", void 0); +__decorate([ + AsnProp({ type: Time }) +], RevokedCertificate.prototype, "revocationDate", void 0); +__decorate([ + AsnProp({ + type: Extension, optional: true, repeated: "sequence", + }) +], RevokedCertificate.prototype, "crlEntryExtensions", void 0); +export class TBSCertList { + version; + signature = new AlgorithmIdentifier(); + issuer = new Name(); + thisUpdate = new Time(); + nextUpdate; + revokedCertificates; + crlExtensions; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, optional: true, + }) +], TBSCertList.prototype, "version", void 0); +__decorate([ + AsnProp({ type: AlgorithmIdentifier }) +], TBSCertList.prototype, "signature", void 0); +__decorate([ + AsnProp({ type: Name }) +], TBSCertList.prototype, "issuer", void 0); +__decorate([ + AsnProp({ type: Time }) +], TBSCertList.prototype, "thisUpdate", void 0); +__decorate([ + AsnProp({ + type: Time, optional: true, + }) +], TBSCertList.prototype, "nextUpdate", void 0); +__decorate([ + AsnProp({ + type: RevokedCertificate, repeated: "sequence", optional: true, + }) +], TBSCertList.prototype, "revokedCertificates", void 0); +__decorate([ + AsnProp({ + type: Extension, optional: true, context: 0, repeated: "sequence", + }) +], TBSCertList.prototype, "crlExtensions", void 0); diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/tbs_certificate.js b/node_modules/@peculiar/asn1-x509/build/es2015/tbs_certificate.js new file mode 100644 index 0000000000000000000000000000000000000000..16484d1d2d432dd99aa0a23d3c6ba546dafa33d6 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/tbs_certificate.js @@ -0,0 +1,69 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnIntegerArrayBufferConverter, } from "@peculiar/asn1-schema"; +import { AlgorithmIdentifier } from "./algorithm_identifier.js"; +import { Name } from "./name.js"; +import { SubjectPublicKeyInfo } from "./subject_public_key_info.js"; +import { Validity } from "./validity.js"; +import { Extensions } from "./extension.js"; +import { Version, } from "./types.js"; +export class TBSCertificate { + version = Version.v1; + serialNumber = new ArrayBuffer(0); + signature = new AlgorithmIdentifier(); + issuer = new Name(); + validity = new Validity(); + subject = new Name(); + subjectPublicKeyInfo = new SubjectPublicKeyInfo(); + issuerUniqueID; + subjectUniqueID; + extensions; + constructor(params = {}) { + Object.assign(this, params); + } +} +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, + context: 0, + defaultValue: Version.v1, + }) +], TBSCertificate.prototype, "version", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.Integer, + converter: AsnIntegerArrayBufferConverter, + }) +], TBSCertificate.prototype, "serialNumber", void 0); +__decorate([ + AsnProp({ type: AlgorithmIdentifier }) +], TBSCertificate.prototype, "signature", void 0); +__decorate([ + AsnProp({ type: Name }) +], TBSCertificate.prototype, "issuer", void 0); +__decorate([ + AsnProp({ type: Validity }) +], TBSCertificate.prototype, "validity", void 0); +__decorate([ + AsnProp({ type: Name }) +], TBSCertificate.prototype, "subject", void 0); +__decorate([ + AsnProp({ type: SubjectPublicKeyInfo }) +], TBSCertificate.prototype, "subjectPublicKeyInfo", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.BitString, + context: 1, + implicit: true, + optional: true, + }) +], TBSCertificate.prototype, "issuerUniqueID", void 0); +__decorate([ + AsnProp({ + type: AsnPropTypes.BitString, context: 2, implicit: true, optional: true, + }) +], TBSCertificate.prototype, "subjectUniqueID", void 0); +__decorate([ + AsnProp({ + type: Extensions, context: 3, optional: true, + }) +], TBSCertificate.prototype, "extensions", void 0); diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/time.js b/node_modules/@peculiar/asn1-x509/build/es2015/time.js new file mode 100644 index 0000000000000000000000000000000000000000..adf4d8f885a9464e8238b51057f6c893db678373 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/time.js @@ -0,0 +1,40 @@ +import { __decorate } from "tslib"; +import { AsnProp, AsnPropTypes, AsnType, AsnTypeTypes, } from "@peculiar/asn1-schema"; +let Time = class Time { + utcTime; + generalTime; + constructor(time) { + if (time) { + if (typeof time === "string" || typeof time === "number" || time instanceof Date) { + const date = new Date(time); + date.setMilliseconds(0); + if (date.getUTCFullYear() > 2049) { + this.generalTime = date; + } + else { + this.utcTime = date; + } + } + else { + Object.assign(this, time); + } + } + } + getTime() { + const time = this.utcTime || this.generalTime; + if (!time) { + throw new Error("Cannot get time from CHOICE object"); + } + return time; + } +}; +__decorate([ + AsnProp({ type: AsnPropTypes.UTCTime }) +], Time.prototype, "utcTime", void 0); +__decorate([ + AsnProp({ type: AsnPropTypes.GeneralizedTime }) +], Time.prototype, "generalTime", void 0); +Time = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) +], Time); +export { Time }; diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/types.js b/node_modules/@peculiar/asn1-x509/build/es2015/types.js new file mode 100644 index 0000000000000000000000000000000000000000..569d9a291609a55c0e653f594adb6a45fe29ea72 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/types.js @@ -0,0 +1,6 @@ +export var Version; +(function (Version) { + Version[Version["v1"] = 0] = "v1"; + Version[Version["v2"] = 1] = "v2"; + Version[Version["v3"] = 2] = "v3"; +})(Version || (Version = {})); diff --git a/node_modules/@peculiar/asn1-x509/build/es2015/validity.js b/node_modules/@peculiar/asn1-x509/build/es2015/validity.js new file mode 100644 index 0000000000000000000000000000000000000000..78e09100e440f3a106c897adcc83597955a55133 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/es2015/validity.js @@ -0,0 +1,19 @@ +import { __decorate } from "tslib"; +import { AsnProp } from "@peculiar/asn1-schema"; +import { Time } from "./time.js"; +export class Validity { + notBefore = new Time(new Date()); + notAfter = new Time(new Date()); + constructor(params) { + if (params) { + this.notBefore = new Time(params.notBefore); + this.notAfter = new Time(params.notAfter); + } + } +} +__decorate([ + AsnProp({ type: Time }) +], Validity.prototype, "notBefore", void 0); +__decorate([ + AsnProp({ type: Time }) +], Validity.prototype, "notAfter", void 0); diff --git a/node_modules/@peculiar/asn1-x509/build/types/algorithm_identifier.d.ts b/node_modules/@peculiar/asn1-x509/build/types/algorithm_identifier.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e30cbfa3f7bdfd32c343b995643823ab42606efb --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/algorithm_identifier.d.ts @@ -0,0 +1,17 @@ +export type ParametersType = ArrayBuffer | null; +/** + * ```asn1 + * AlgorithmIdentifier ::= SEQUENCE { + * algorithm OBJECT IDENTIFIER, + * parameters ANY DEFINED BY algorithm OPTIONAL } + * -- contains a value of the type + * -- registered for use with the + * -- algorithm object identifier value + * ``` + */ +export declare class AlgorithmIdentifier { + algorithm: string; + parameters?: ParametersType; + constructor(params?: Partial>); + isEqual(data: unknown): data is this; +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/attribute.d.ts b/node_modules/@peculiar/asn1-x509/build/types/attribute.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..eab16a4fc449f8c9ce8698ef1206be6cecf6a737 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/attribute.d.ts @@ -0,0 +1,13 @@ +/** + * ```asn1 + * Attribute ::= SEQUENCE { + * type AttributeType, + * values SET OF AttributeValue } + * -- at least one value is required + * ``` + */ +export declare class Attribute { + type: string; + values: ArrayBuffer[]; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/certificate.d.ts b/node_modules/@peculiar/asn1-x509/build/types/certificate.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5061fb1dc701cdbee899007081b3ceea068ee858 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/certificate.d.ts @@ -0,0 +1,17 @@ +import { AlgorithmIdentifier } from "./algorithm_identifier"; +import { TBSCertificate } from "./tbs_certificate"; +/** + * ```asn1 + * Certificate ::= SEQUENCE { + * tbsCertificate TBSCertificate, + * signatureAlgorithm AlgorithmIdentifier, + * signatureValue BIT STRING } + * ``` + */ +export declare class Certificate { + tbsCertificate: TBSCertificate; + tbsCertificateRaw?: ArrayBuffer; + signatureAlgorithm: AlgorithmIdentifier; + signatureValue: ArrayBuffer; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/certificate_list.d.ts b/node_modules/@peculiar/asn1-x509/build/types/certificate_list.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d0a9d4a3ce99af859a97562c00dce5505a8e7a82 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/certificate_list.d.ts @@ -0,0 +1,17 @@ +import { AlgorithmIdentifier } from "./algorithm_identifier"; +import { TBSCertList } from "./tbs_cert_list"; +/** + * ```asn1 + * CertificateList ::= SEQUENCE { + * tbsCertList TBSCertList, + * signatureAlgorithm AlgorithmIdentifier, + * signature BIT STRING } + * ``` + */ +export declare class CertificateList { + tbsCertList: TBSCertList; + tbsCertListRaw?: ArrayBuffer; + signatureAlgorithm: AlgorithmIdentifier; + signature: ArrayBuffer; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/extension.d.ts b/node_modules/@peculiar/asn1-x509/build/types/extension.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0a6a136beea18b7d61bf4da8513275a0e82e0cd3 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/extension.d.ts @@ -0,0 +1,28 @@ +import { AsnArray, OctetString } from "@peculiar/asn1-schema"; +/** + * ```asn1 + * Extension ::= SEQUENCE { + * extnID OBJECT IDENTIFIER, + * critical BOOLEAN DEFAULT FALSE, + * extnValue OCTET STRING + * -- contains the DER encoding of an ASN.1 value + * -- corresponding to the extension type identified + * -- by extnID + * } + * ``` + */ +export declare class Extension { + static CRITICAL: boolean; + extnID: string; + critical: boolean; + extnValue: OctetString; + constructor(params?: Partial); +} +/** + * ```asn1 + * Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension + * ``` + */ +export declare class Extensions extends AsnArray { + constructor(items?: Extension[]); +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/extensions/authority_information_access.d.ts b/node_modules/@peculiar/asn1-x509/build/types/extensions/authority_information_access.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5c3b18bbec77b5029f31d8d80a5e9d48bf110288 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/extensions/authority_information_access.d.ts @@ -0,0 +1,29 @@ +import { AsnArray } from "@peculiar/asn1-schema"; +import { GeneralName } from "../general_name"; +/*** + * ```asn1 + * id-pe-authorityInfoAccess OBJECT IDENTIFIER ::= { id-pe 1 } + * ``` + */ +export declare const id_pe_authorityInfoAccess = "1.3.6.1.5.5.7.1.1"; +/** + * ```asn1 + * AccessDescription ::= SEQUENCE { + * accessMethod OBJECT IDENTIFIER, + * accessLocation GeneralName } + * ``` + */ +export declare class AccessDescription { + accessMethod: string; + accessLocation: GeneralName; + constructor(params?: Partial); +} +/** + * ```asn1 + * AuthorityInfoAccessSyntax ::= + * SEQUENCE SIZE (1..MAX) OF AccessDescription + * ``` + */ +export declare class AuthorityInfoAccessSyntax extends AsnArray { + constructor(items?: AccessDescription[]); +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/extensions/authority_key_identifier.d.ts b/node_modules/@peculiar/asn1-x509/build/types/extensions/authority_key_identifier.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c225fbfb085aea38194d1c60e709bad917e31866 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/extensions/authority_key_identifier.d.ts @@ -0,0 +1,30 @@ +import { OctetString } from "@peculiar/asn1-schema"; +import { GeneralName } from "../general_name"; +import { CertificateSerialNumber } from "../types"; +/** + * ```asn1 + * id-ce-authorityKeyIdentifier OBJECT IDENTIFIER ::= { id-ce 35 } + * ``` + */ +export declare const id_ce_authorityKeyIdentifier = "2.5.29.35"; +/** + * ```asn1 + * KeyIdentifier ::= OCTET STRING + * ``` + */ +export declare class KeyIdentifier extends OctetString { +} +/** + * ```asn1 + * AuthorityKeyIdentifier ::= SEQUENCE { + * keyIdentifier [0] KeyIdentifier OPTIONAL, + * authorityCertIssuer [1] GeneralNames OPTIONAL, + * authorityCertSerialNumber [2] CertificateSerialNumber OPTIONAL } + * ``` + */ +export declare class AuthorityKeyIdentifier { + keyIdentifier?: KeyIdentifier; + authorityCertIssuer?: GeneralName[]; + authorityCertSerialNumber?: CertificateSerialNumber; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/extensions/basic_constraints.d.ts b/node_modules/@peculiar/asn1-x509/build/types/extensions/basic_constraints.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c2fb2d41fe0921122b5abf1a170500777a0581ef --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/extensions/basic_constraints.d.ts @@ -0,0 +1,18 @@ +/** + * ```asn1 + * id-ce-basicConstraints OBJECT IDENTIFIER ::= { id-ce 19 } + * ``` + */ +export declare const id_ce_basicConstraints = "2.5.29.19"; +/** + * ```asn1 + * BasicConstraints ::= SEQUENCE { + * cA BOOLEAN DEFAULT FALSE, + * pathLenConstraint INTEGER (0..MAX) OPTIONAL } + * ``` + */ +export declare class BasicConstraints { + cA: boolean; + pathLenConstraint?: number; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/extensions/certificate_issuer.d.ts b/node_modules/@peculiar/asn1-x509/build/types/extensions/certificate_issuer.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1ecf27fa2f9eaa1f182beabfab04535fba24e826 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/extensions/certificate_issuer.d.ts @@ -0,0 +1,16 @@ +import { GeneralNames } from "../general_names"; +import { GeneralName } from "../general_name"; +/** + * ```asn1 + * id-ce-certificateIssuer OBJECT IDENTIFIER ::= { id-ce 29 } + * ``` + */ +export declare const id_ce_certificateIssuer = "2.5.29.29"; +/** + * ```asn1 + * CertificateIssuer ::= GeneralNames + * ``` + */ +export declare class CertificateIssuer extends GeneralNames { + constructor(items?: GeneralName[]); +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/extensions/certificate_policies.d.ts b/node_modules/@peculiar/asn1-x509/build/types/extensions/certificate_policies.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3fce9482e8d99239ba57d96d40f1a31c559c1152 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/extensions/certificate_policies.d.ts @@ -0,0 +1,117 @@ +import { AsnArray } from "@peculiar/asn1-schema"; +/** + * ```asn1 + * id-ce-certificatePolicies OBJECT IDENTIFIER ::= { id-ce 32 } + * ``` + */ +export declare const id_ce_certificatePolicies = "2.5.29.32"; +/** + * ```asn1 + * anyPolicy OBJECT IDENTIFIER ::= { id-ce-certificatePolicies 0 } + * ``` + */ +export declare const id_ce_certificatePolicies_anyPolicy = "2.5.29.32.0"; +/** + * ```asn1 + * DisplayText ::= CHOICE { + * ia5String IA5String (SIZE (1..200)), + * visibleString VisibleString (SIZE (1..200)), + * bmpString BMPString (SIZE (1..200)), + * utf8String UTF8String (SIZE (1..200)) } + * ``` + */ +export declare class DisplayText { + ia5String?: string; + visibleString?: string; + bmpString?: string; + utf8String?: string; + constructor(params?: Partial); + toString(): string; +} +/** + * ```asn1 + * NoticeReference ::= SEQUENCE { + * organization DisplayText, + * noticeNumbers SEQUENCE OF INTEGER } + * ``` + */ +export declare class NoticeReference { + organization: DisplayText; + noticeNumbers: number[]; + constructor(params?: Partial); +} +/** + * ```asn1 + * UserNotice ::= SEQUENCE { + * noticeRef NoticeReference OPTIONAL, + * explicitText DisplayText OPTIONAL } + * ``` + */ +export declare class UserNotice { + noticeRef?: NoticeReference; + explicitText?: DisplayText; + constructor(params?: Partial); +} +/** + * ```asn1 + * CPSuri ::= IA5String + * ``` + */ +export type CPSuri = string; +/** + * ```asn1 + * Qualifier ::= CHOICE { + * cPSuri CPSuri, + * userNotice UserNotice } + * ``` + */ +export declare class Qualifier { + cPSuri?: CPSuri; + userNotice?: UserNotice; + constructor(params?: Partial); +} +/** + * ```asn1 + * PolicyQualifierId ::= OBJECT IDENTIFIER ( id-qt-cps | id-qt-unotice ) + * ``` + */ +export type PolicyQualifierId = string; +/** + * ```asn1 + * PolicyQualifierInfo ::= SEQUENCE { + * policyQualifierId PolicyQualifierId, + * qualifier ANY DEFINED BY policyQualifierId } + * ``` + */ +export declare class PolicyQualifierInfo { + policyQualifierId: PolicyQualifierId; + qualifier: ArrayBuffer; + constructor(params?: Partial); +} +/** + * ```asn1 + * CertPolicyId ::= OBJECT IDENTIFIER + * ``` + */ +export type CertPolicyId = string; +/** + * ```asn1 + * PolicyInformation ::= SEQUENCE { + * policyIdentifier CertPolicyId, + * policyQualifiers SEQUENCE SIZE (1..MAX) OF + * PolicyQualifierInfo OPTIONAL } + * ``` + */ +export declare class PolicyInformation { + policyIdentifier: CertPolicyId; + policyQualifiers?: PolicyQualifierInfo[]; + constructor(params?: Partial); +} +/** + * ```asn1 + * CertificatePolicies ::= SEQUENCE SIZE (1..MAX) OF PolicyInformation + * ``` + */ +export declare class CertificatePolicies extends AsnArray { + constructor(items?: PolicyInformation[]); +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/extensions/crl_delta_indicator.d.ts b/node_modules/@peculiar/asn1-x509/build/types/extensions/crl_delta_indicator.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..660b3aeb0b4a5f34200cff6f058faa63d60d84a5 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/extensions/crl_delta_indicator.d.ts @@ -0,0 +1,14 @@ +import { CRLNumber } from "./crl_number"; +/** + * ```asn1 + * id-ce-deltaCRLIndicator OBJECT IDENTIFIER ::= { id-ce 27 } + * ``` + */ +export declare const id_ce_deltaCRLIndicator = "2.5.29.27"; +/** + * ```asn1 + * BaseCRLNumber ::= CRLNumber + * ``` + */ +export declare class BaseCRLNumber extends CRLNumber { +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/extensions/crl_distribution_points.d.ts b/node_modules/@peculiar/asn1-x509/build/types/extensions/crl_distribution_points.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..14f55f527fce0aaa052775a925e10e8d1eea5327 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/extensions/crl_distribution_points.d.ts @@ -0,0 +1,73 @@ +import { AsnArray, BitString } from "@peculiar/asn1-schema"; +import { RelativeDistinguishedName } from "../name"; +import { GeneralName } from "../general_name"; +/** + * ```asn1 + * id-ce-cRLDistributionPoints OBJECT IDENTIFIER ::= { id-ce 31 } + * ``` + */ +export declare const id_ce_cRLDistributionPoints = "2.5.29.31"; +export type ReasonType = "unused" | "keyCompromise" | "cACompromise" | "affiliationChanged" | "superseded" | "cessationOfOperation" | "certificateHold" | "privilegeWithdrawn" | "aACompromise"; +export declare enum ReasonFlags { + unused = 1, + keyCompromise = 2, + cACompromise = 4, + affiliationChanged = 8, + superseded = 16, + cessationOfOperation = 32, + certificateHold = 64, + privilegeWithdrawn = 128, + aACompromise = 256 +} +/** + * ```asn1 + * ReasonFlags ::= BIT STRING { + * unused (0), + * keyCompromise (1), + * cACompromise (2), + * affiliationChanged (3), + * superseded (4), + * cessationOfOperation (5), + * certificateHold (6), + * privilegeWithdrawn (7), + * aACompromise (8) } + * ``` + */ +export declare class Reason extends BitString { + toJSON(): ReasonType[]; + toString(): string; +} +/** + * ```asn1 + * DistributionPointName ::= CHOICE { + * fullName [0] GeneralNames, + * nameRelativeToCRLIssuer [1] RelativeDistinguishedName } + * ``` + */ +export declare class DistributionPointName { + fullName?: GeneralName[]; + nameRelativeToCRLIssuer?: RelativeDistinguishedName; + constructor(params?: Partial); +} +/** + * ```asn1 + * DistributionPoint ::= SEQUENCE { + * distributionPoint [0] DistributionPointName OPTIONAL, + * reasons [1] ReasonFlags OPTIONAL, + * cRLIssuer [2] GeneralNames OPTIONAL } + * ``` + */ +export declare class DistributionPoint { + distributionPoint?: DistributionPointName; + reasons?: Reason; + cRLIssuer?: GeneralName[]; + constructor(params?: Partial); +} +/** + * ```asn1 + * CRLDistributionPoints ::= SEQUENCE SIZE (1..MAX) OF DistributionPoint + * ``` + */ +export declare class CRLDistributionPoints extends AsnArray { + constructor(items?: DistributionPoint[]); +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/extensions/crl_freshest.d.ts b/node_modules/@peculiar/asn1-x509/build/types/extensions/crl_freshest.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8c4bc3f93b80eef92b41c26255239c2e07477b64 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/extensions/crl_freshest.d.ts @@ -0,0 +1,15 @@ +import { CRLDistributionPoints, DistributionPoint } from "./crl_distribution_points"; +/** + * ```asn1 + * id-ce-freshestCRL OBJECT IDENTIFIER ::= { id-ce 46 } + * ``` + */ +export declare const id_ce_freshestCRL = "2.5.29.46"; +/** + * ```asn1 + * FreshestCRL ::= CRLDistributionPoints + * ``` + */ +export declare class FreshestCRL extends CRLDistributionPoints { + constructor(items?: DistributionPoint[]); +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/extensions/crl_issuing_distribution_point.d.ts b/node_modules/@peculiar/asn1-x509/build/types/extensions/crl_issuing_distribution_point.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1b2fd2a293daf31a7a4ed732255d29b9c3904272 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/extensions/crl_issuing_distribution_point.d.ts @@ -0,0 +1,31 @@ +import { DistributionPointName, Reason } from "./crl_distribution_points"; +/** + * ```asn1 + * id-ce-issuingDistributionPoint OBJECT IDENTIFIER ::= { id-ce 28 } + * ``` + */ +export declare const id_ce_issuingDistributionPoint = "2.5.29.28"; +/** + * ```asn1 + * IssuingDistributionPoint ::= SEQUENCE { + * distributionPoint [0] DistributionPointName OPTIONAL, + * onlyContainsUserCerts [1] BOOLEAN DEFAULT FALSE, + * onlyContainsCACerts [2] BOOLEAN DEFAULT FALSE, + * onlySomeReasons [3] ReasonFlags OPTIONAL, + * indirectCRL [4] BOOLEAN DEFAULT FALSE, + * onlyContainsAttributeCerts [5] BOOLEAN DEFAULT FALSE } + * + * -- at most one of onlyContainsUserCerts, onlyContainsCACerts, + * -- and onlyContainsAttributeCerts may be set to TRUE. + * ``` + */ +export declare class IssuingDistributionPoint { + static readonly ONLY = false; + distributionPoint?: DistributionPointName; + onlyContainsUserCerts: boolean; + onlyContainsCACerts: boolean; + onlySomeReasons?: Reason; + indirectCRL: boolean; + onlyContainsAttributeCerts: boolean; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/extensions/crl_number.d.ts b/node_modules/@peculiar/asn1-x509/build/types/extensions/crl_number.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..37d7e88e500477c6e1fbce1e04f4c7ad19d547c0 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/extensions/crl_number.d.ts @@ -0,0 +1,15 @@ +/** + * ```asn1 + * id-ce-cRLNumber OBJECT IDENTIFIER ::= { id-ce 20 } + * ``` + */ +export declare const id_ce_cRLNumber = "2.5.29.20"; +/** + * ```asn1 + * CRLNumber ::= INTEGER (0..MAX) + * ``` + */ +export declare class CRLNumber { + value: number; + constructor(value?: number); +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/extensions/crl_reason.d.ts b/node_modules/@peculiar/asn1-x509/build/types/extensions/crl_reason.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0449fa8ba49047e01c2d249ea9263be9e4252437 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/extensions/crl_reason.d.ts @@ -0,0 +1,40 @@ +/** + * ```asn1 + * id-ce-cRLReasons OBJECT IDENTIFIER ::= { id-ce 21 } + * ``` + */ +export declare const id_ce_cRLReasons = "2.5.29.21"; +export declare enum CRLReasons { + unspecified = 0, + keyCompromise = 1, + cACompromise = 2, + affiliationChanged = 3, + superseded = 4, + cessationOfOperation = 5, + certificateHold = 6, + removeFromCRL = 8, + privilegeWithdrawn = 9, + aACompromise = 10 +} +/** + * ```asn1 + * CRLReason ::= ENUMERATED { + * unspecified (0), + * keyCompromise (1), + * cACompromise (2), + * affiliationChanged (3), + * superseded (4), + * cessationOfOperation (5), + * certificateHold (6), + * -- value 7 is not used + * removeFromCRL (8), + * privilegeWithdrawn (9), + * aACompromise (10) } + * ``` + */ +export declare class CRLReason { + reason: CRLReasons; + constructor(reason?: CRLReasons); + toJSON(): string; + toString(): string; +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/extensions/entrust_version_info.d.ts b/node_modules/@peculiar/asn1-x509/build/types/extensions/entrust_version_info.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8f790e1bc7aa864353c4a4431080bf0ee562e55c --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/extensions/entrust_version_info.d.ts @@ -0,0 +1,39 @@ +import { BitString } from "@peculiar/asn1-schema"; +/** + * ```asn1 + * id-entrust-entrustVersInfo OBJECT IDENTIFIER ::= {iso(1) + * member-body(2) us(840) nortelnetworks(113533) entrust(7) + * nsn-ce(65) 0} + * ``` + */ +export declare const id_entrust_entrustVersInfo = "1.2.840.113533.7.65.0"; +export type EntrustInfoType = "keyUpdateAllowed" | "newExtensions" | "pKIXCertificate"; +export declare enum EntrustInfoFlags { + keyUpdateAllowed = 1, + newExtensions = 2, + pKIXCertificate = 4 +} +/** + * ```asn1 + * EntrustInfoFlags ::= BIT STRING { + * keyUpdateAllowed (0), + * newExtensions (1), -- not used + * pKIXCertificate (2) } -- certificate created by pkix + * ``` + */ +export declare class EntrustInfo extends BitString { + toJSON(): EntrustInfoType[]; + toString(): string; +} +/** + * ```asn1 + * EntrustVersionInfo ::= SEQUENCE { + * entrustVers GeneralString, + * entrustInfoFlags EntrustInfoFlags } + * ``` + */ +export declare class EntrustVersionInfo { + entrustVers: string; + entrustInfoFlags: EntrustInfo; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/extensions/extended_key_usage.d.ts b/node_modules/@peculiar/asn1-x509/build/types/extensions/extended_key_usage.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2faa9b225d8cfe93d1377c33117cdb9725a26ac1 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/extensions/extended_key_usage.d.ts @@ -0,0 +1,80 @@ +import { AsnArray } from "@peculiar/asn1-schema"; +/** + * ```asn1 + * id-ce-extKeyUsage OBJECT IDENTIFIER ::= { id-ce 37 } + * ``` + */ +export declare const id_ce_extKeyUsage = "2.5.29.37"; +/** + * ```asn1 + * KeyPurposeId ::= OBJECT IDENTIFIER + * ``` + */ +export type KeyPurposeId = string; +/** + * ```asn1 + * ExtKeyUsageSyntax ::= SEQUENCE SIZE (1..MAX) OF KeyPurposeId + * ``` + */ +export declare class ExtendedKeyUsage extends AsnArray { + constructor(items?: string[]); +} +/** + * ```asn1 + * anyExtendedKeyUsage OBJECT IDENTIFIER ::= { id-ce-extKeyUsage 0 } + * ``` + */ +export declare const anyExtendedKeyUsage = "2.5.29.37.0"; +/** + * ```asn1 + * id-kp-serverAuth OBJECT IDENTIFIER ::= { id-kp 1 } + * -- TLS WWW server authentication + * -- Key usage bits that may be consistent: digitalSignature, + * -- keyEncipherment or keyAgreement + * ``` + */ +export declare const id_kp_serverAuth = "1.3.6.1.5.5.7.3.1"; +/** + * ```asn1 + * id-kp-clientAuth OBJECT IDENTIFIER ::= { id-kp 2 } + * -- TLS WWW client authentication + * -- Key usage bits that may be consistent: digitalSignature + * -- and/or keyAgreement + * ``` + */ +export declare const id_kp_clientAuth = "1.3.6.1.5.5.7.3.2"; +/** + * ```asn1 + * id-kp-codeSigning OBJECT IDENTIFIER ::= { id-kp 3 } + * -- Signing of downloadable executable code + * -- Key usage bits that may be consistent: digitalSignature + * ``` + */ +export declare const id_kp_codeSigning = "1.3.6.1.5.5.7.3.3"; +/** + * ```asn1 + * id-kp-emailProtection OBJECT IDENTIFIER ::= { id-kp 4 } + * -- Email protection + * -- Key usage bits that may be consistent: digitalSignature, + * -- nonRepudiation, and/or (keyEncipherment or keyAgreement) + * ``` + */ +export declare const id_kp_emailProtection = "1.3.6.1.5.5.7.3.4"; +/** + * ```asn1 + * id-kp-timeStamping OBJECT IDENTIFIER ::= { id-kp 8 } + * -- Binding the hash of an object to a time + * -- Key usage bits that may be consistent: digitalSignature + * -- and/or nonRepudiation + * ``` + */ +export declare const id_kp_timeStamping = "1.3.6.1.5.5.7.3.8"; +/** + * ```asn1 + * id-kp-OCSPSigning OBJECT IDENTIFIER ::= { id-kp 9 } + * -- Signing OCSP responses + * -- Key usage bits that may be consistent: digitalSignature + * -- and/or nonRepudiation + * ``` + */ +export declare const id_kp_OCSPSigning = "1.3.6.1.5.5.7.3.9"; diff --git a/node_modules/@peculiar/asn1-x509/build/types/extensions/index.d.ts b/node_modules/@peculiar/asn1-x509/build/types/extensions/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..21a5d10a170b8de8da1267f2751d483007fda14d --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/extensions/index.d.ts @@ -0,0 +1,25 @@ +export * from "./authority_information_access"; +export * from "./authority_key_identifier"; +export * from "./basic_constraints"; +export * from "./certificate_issuer"; +export * from "./certificate_policies"; +export * from "./crl_delta_indicator"; +export * from "./crl_distribution_points"; +export * from "./crl_freshest"; +export * from "./crl_issuing_distribution_point"; +export * from "./crl_number"; +export * from "./crl_reason"; +export * from "./extended_key_usage"; +export * from "./inhibit_any_policy"; +export * from "./invalidity_date"; +export * from "./issuer_alternative_name"; +export * from "./key_usage"; +export * from "./name_constraints"; +export * from "./policy_constraints"; +export * from "./policy_mappings"; +export * from "./subject_alternative_name"; +export * from "./subject_directory_attributes"; +export * from "./subject_key_identifier"; +export * from "./private_key_usage_period"; +export * from "./entrust_version_info"; +export * from "./subject_info_access"; diff --git a/node_modules/@peculiar/asn1-x509/build/types/extensions/inhibit_any_policy.d.ts b/node_modules/@peculiar/asn1-x509/build/types/extensions/inhibit_any_policy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..27c1441e6f68eea9d5f300102d6eb15b2dd687a8 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/extensions/inhibit_any_policy.d.ts @@ -0,0 +1,15 @@ +/** + * ```asn1 + * id-ce-inhibitAnyPolicy OBJECT IDENTIFIER ::= { id-ce 54 } + * ``` + */ +export declare const id_ce_inhibitAnyPolicy = "2.5.29.54"; +/** + * ```asn1 + * InhibitAnyPolicy ::= SkipCerts + * ``` + */ +export declare class InhibitAnyPolicy { + value: ArrayBuffer; + constructor(value?: ArrayBuffer); +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/extensions/invalidity_date.d.ts b/node_modules/@peculiar/asn1-x509/build/types/extensions/invalidity_date.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e79588b5d763220a837d5b622b6baa84561bf684 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/extensions/invalidity_date.d.ts @@ -0,0 +1,15 @@ +/** + * ```asn1 + * id-ce-invalidityDate OBJECT IDENTIFIER ::= { id-ce 24 } + * ``` + */ +export declare const id_ce_invalidityDate = "2.5.29.24"; +/** + * ```asn1 + * InvalidityDate ::= GeneralizedTime + * ``` + */ +export declare class InvalidityDate { + value: Date; + constructor(value?: Date); +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/extensions/issuer_alternative_name.d.ts b/node_modules/@peculiar/asn1-x509/build/types/extensions/issuer_alternative_name.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2d8021229874e19b8db6e6ac6c3c8cdb076fb66e --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/extensions/issuer_alternative_name.d.ts @@ -0,0 +1,16 @@ +import { GeneralNames } from "../general_names"; +import { GeneralName } from "../general_name"; +/** + * ```asn1 + * id-ce-issuerAltName OBJECT IDENTIFIER ::= { id-ce 18 } + * ``` + */ +export declare const id_ce_issuerAltName = "2.5.29.18"; +/** + * ```asn1 + * IssuerAltName ::= GeneralNames + * ``` + */ +export declare class IssueAlternativeName extends GeneralNames { + constructor(items?: GeneralName[]); +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/extensions/key_usage.d.ts b/node_modules/@peculiar/asn1-x509/build/types/extensions/key_usage.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..94369c39624602c6b893ce3ab6057059586ebb36 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/extensions/key_usage.d.ts @@ -0,0 +1,38 @@ +import { BitString } from "@peculiar/asn1-schema"; +/** + * ```asn1 + * id-ce-keyUsage OBJECT IDENTIFIER ::= { id-ce 15 } + * ``` + */ +export declare const id_ce_keyUsage = "2.5.29.15"; +export type KeyUsageType = "digitalSignature" | "nonRepudiation" | "keyEncipherment" | "dataEncipherment" | "keyAgreement" | "keyCertSign" | "crlSign" | "encipherOnly" | "decipherOnly"; +export declare enum KeyUsageFlags { + digitalSignature = 1, + nonRepudiation = 2, + keyEncipherment = 4, + dataEncipherment = 8, + keyAgreement = 16, + keyCertSign = 32, + cRLSign = 64, + encipherOnly = 128, + decipherOnly = 256 +} +/** + * ```asn1 + * KeyUsage ::= BIT STRING { + * digitalSignature (0), + * nonRepudiation (1), -- recent editions of X.509 have + * -- renamed this bit to contentCommitment + * keyEncipherment (2), + * dataEncipherment (3), + * keyAgreement (4), + * keyCertSign (5), + * cRLSign (6), + * encipherOnly (7), + * decipherOnly (8) } + * ``` + */ +export declare class KeyUsage extends BitString { + toJSON(): KeyUsageType[]; + toString(): string; +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/extensions/name_constraints.d.ts b/node_modules/@peculiar/asn1-x509/build/types/extensions/name_constraints.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3a81daf9621dcc98856b9887dbc368e4300b3c38 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/extensions/name_constraints.d.ts @@ -0,0 +1,48 @@ +import { AsnArray } from "@peculiar/asn1-schema"; +import { GeneralName } from "../general_name"; +/** + * ```asn1 + * id-ce-nameConstraints OBJECT IDENTIFIER ::= { id-ce 30 } + * ``` + */ +export declare const id_ce_nameConstraints = "2.5.29.30"; +/** + * ```asn1 + * BaseDistance ::= INTEGER (0..MAX) + * ``` + */ +export type BaseDistance = number; +/** + * ```asn1 + * GeneralSubtree ::= SEQUENCE { + * base GeneralName, + * minimum [0] BaseDistance DEFAULT 0, + * maximum [1] BaseDistance OPTIONAL } + * ``` + */ +export declare class GeneralSubtree { + base: GeneralName; + minimum: BaseDistance; + maximum?: BaseDistance; + constructor(params?: Partial); +} +/** + * ```asn1 + * GeneralSubtrees ::= SEQUENCE SIZE (1..MAX) OF GeneralSubtree + * ``` + */ +export declare class GeneralSubtrees extends AsnArray { + constructor(items?: GeneralSubtree[]); +} +/** + * ```asn1 + * NameConstraints ::= SEQUENCE { + * permittedSubtrees [0] GeneralSubtrees OPTIONAL, + * excludedSubtrees [1] GeneralSubtrees OPTIONAL } + * ``` + */ +export declare class NameConstraints { + permittedSubtrees?: GeneralSubtrees; + excludedSubtrees?: GeneralSubtrees; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/extensions/policy_constraints.d.ts b/node_modules/@peculiar/asn1-x509/build/types/extensions/policy_constraints.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..44daea1a56032c5e99c3d1457f0eaf899a32f5d0 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/extensions/policy_constraints.d.ts @@ -0,0 +1,24 @@ +/** + * ```asn1 + * id-ce-policyConstraints OBJECT IDENTIFIER ::= { id-ce 36 } + * ``` + */ +export declare const id_ce_policyConstraints = "2.5.29.36"; +/** + * ```asn1 + * SkipCerts ::= INTEGER (0..MAX) + * ``` + */ +export type SkipCerts = ArrayBuffer; +/** + * ```asn1 + * PolicyConstraints ::= SEQUENCE { + * requireExplicitPolicy [0] SkipCerts OPTIONAL, + * inhibitPolicyMapping [1] SkipCerts OPTIONAL } + * ``` + */ +export declare class PolicyConstraints { + requireExplicitPolicy?: SkipCerts; + inhibitPolicyMapping?: SkipCerts; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/extensions/policy_mappings.d.ts b/node_modules/@peculiar/asn1-x509/build/types/extensions/policy_mappings.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b867993d3ab62e5eddc8e7ef8a132e387a8bfc68 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/extensions/policy_mappings.d.ts @@ -0,0 +1,28 @@ +import { AsnArray } from "@peculiar/asn1-schema"; +import { CertPolicyId } from "./certificate_policies"; +/** + * ```asn1 + * id-ce-policyMappings OBJECT IDENTIFIER ::= { id-ce 33 } + * ``` + */ +export declare const id_ce_policyMappings = "2.5.29.33"; +/** + * ```asn1 + * PolicyMapping ::= SEQUENCE { + * issuerDomainPolicy CertPolicyId, + * subjectDomainPolicy CertPolicyId } + * ``` + */ +export declare class PolicyMapping { + issuerDomainPolicy: CertPolicyId; + subjectDomainPolicy: CertPolicyId; + constructor(params?: Partial); +} +/** + * ```asn1 + * PolicyMappings ::= SEQUENCE SIZE (1..MAX) OF PolicyMapping + * ``` + */ +export declare class PolicyMappings extends AsnArray { + constructor(items?: PolicyMapping[]); +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/extensions/private_key_usage_period.d.ts b/node_modules/@peculiar/asn1-x509/build/types/extensions/private_key_usage_period.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..86e840d3ad6ef43f17b334d7f8ec887abe11a357 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/extensions/private_key_usage_period.d.ts @@ -0,0 +1,18 @@ +/** + * ```asn1 + * id-ce-privateKeyUsagePeriod OBJECT IDENTIFIER ::= { id-ce 16 } + * ``` + */ +export declare const id_ce_privateKeyUsagePeriod = "2.5.29.16"; +/** + * ```asn1 + * PrivateKeyUsagePeriod ::= SEQUENCE { + * notBefore [0] GeneralizedTime OPTIONAL, + * notAfter [1] GeneralizedTime OPTIONAL } + * ``` + */ +export declare class PrivateKeyUsagePeriod { + notBefore?: Date; + notAfter?: Date; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/extensions/subject_alternative_name.d.ts b/node_modules/@peculiar/asn1-x509/build/types/extensions/subject_alternative_name.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0da8aa913bacc300f48c90d7f6ae5879e138c43c --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/extensions/subject_alternative_name.d.ts @@ -0,0 +1,16 @@ +import { GeneralNames } from "../general_names"; +import { GeneralName } from "../general_name"; +/** + * ```asn1 + * id-ce-subjectAltName OBJECT IDENTIFIER ::= { id-ce 17 } + * ``` + */ +export declare const id_ce_subjectAltName = "2.5.29.17"; +/** + * ```asn1 + * SubjectAltName ::= GeneralNames + * ``` + */ +export declare class SubjectAlternativeName extends GeneralNames { + constructor(items?: GeneralName[]); +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/extensions/subject_directory_attributes.d.ts b/node_modules/@peculiar/asn1-x509/build/types/extensions/subject_directory_attributes.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b6904f899de395da21b6c724374b835291982451 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/extensions/subject_directory_attributes.d.ts @@ -0,0 +1,16 @@ +import { AsnArray } from "@peculiar/asn1-schema"; +import { Attribute } from "../attribute"; +/** + * ```asn1 + * id-ce-subjectDirectoryAttributes OBJECT IDENTIFIER ::= { id-ce 9 } + * ``` + */ +export declare const id_ce_subjectDirectoryAttributes = "2.5.29.9"; +/** + * ```asn1 + * SubjectDirectoryAttributes ::= SEQUENCE SIZE (1..MAX) OF Attribute + * ``` + */ +export declare class SubjectDirectoryAttributes extends AsnArray { + constructor(items?: Attribute[]); +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/extensions/subject_info_access.d.ts b/node_modules/@peculiar/asn1-x509/build/types/extensions/subject_info_access.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bbcd93709879fec0faaca21b858d1594645b7c8e --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/extensions/subject_info_access.d.ts @@ -0,0 +1,17 @@ +import { AsnArray } from "@peculiar/asn1-schema"; +import { AccessDescription } from "./authority_information_access"; +/** + * ```asn1 + * id-pe-subjectInfoAccess OBJECT IDENTIFIER ::= { id-pe 11 } + * ``` + */ +export declare const id_pe_subjectInfoAccess = "1.3.6.1.5.5.7.1.11"; +/** + * ```asn1 + * SubjectInfoAccessSyntax ::= + * SEQUENCE SIZE (1..MAX) OF AccessDescription + * ``` + */ +export declare class SubjectInfoAccessSyntax extends AsnArray { + constructor(items?: AccessDescription[]); +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/extensions/subject_key_identifier.d.ts b/node_modules/@peculiar/asn1-x509/build/types/extensions/subject_key_identifier.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..955a15d47fb47eb35aae984bef211e3917b80996 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/extensions/subject_key_identifier.d.ts @@ -0,0 +1,14 @@ +import { KeyIdentifier } from "./authority_key_identifier"; +/** + * ```asn1 + * id-ce-subjectKeyIdentifier OBJECT IDENTIFIER ::= { id-ce 14 } + * ``` + */ +export declare const id_ce_subjectKeyIdentifier = "2.5.29.14"; +/** + * ```asn1 + * SubjectKeyIdentifier ::= KeyIdentifier + * ``` + */ +export declare class SubjectKeyIdentifier extends KeyIdentifier { +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/general_name.d.ts b/node_modules/@peculiar/asn1-x509/build/types/general_name.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..abf626beb52b6d74c7d1309ef9b250877ed13171 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/general_name.d.ts @@ -0,0 +1,57 @@ +import { IAsnConverter } from "@peculiar/asn1-schema"; +import { DirectoryString, Name } from "./name"; +export declare const AsnIpConverter: IAsnConverter; +/** + * ```asn1 + * OtherName ::= SEQUENCE { + * type-id OBJECT IDENTIFIER, + * value [0] EXPLICIT ANY DEFINED BY type-id } + * ``` + */ +export declare class OtherName { + typeId: string; + value: ArrayBuffer; + constructor(params?: Partial); +} +/** + * ```asn1 + * EDIPartyName ::= SEQUENCE { + * nameAssigner [0] DirectoryString OPTIONAL, + * partyName [1] DirectoryString } + * ``` + */ +export declare class EDIPartyName { + nameAssigner?: DirectoryString; + partyName: DirectoryString; + constructor(params?: Partial); +} +/** + * ```asn1 + * GeneralName ::= CHOICE { + * otherName [0] OtherName, + * rfc822Name [1] IA5String, + * dNSName [2] IA5String, + * x400Address [3] ORAddress, + * directoryName [4] Name, + * ediPartyName [5] EDIPartyName, + * uniformResourceIdentifier [6] IA5String, + * iPAddress [7] OCTET STRING, + * registeredID [8] OBJECT IDENTIFIER } + * ``` + */ +export declare class GeneralName { + otherName?: OtherName; + rfc822Name?: string; + dNSName?: string; + x400Address?: ArrayBuffer; + directoryName?: Name; + ediPartyName?: EDIPartyName; + uniformResourceIdentifier?: string; + iPAddress?: string; + registeredID?: string; + /** + * + * @param params + */ + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/general_names.d.ts b/node_modules/@peculiar/asn1-x509/build/types/general_names.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5782cc92c6aca36ec2b305995bcdfcf363b94ee7 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/general_names.d.ts @@ -0,0 +1,10 @@ +import { AsnArray } from "@peculiar/asn1-schema"; +import { GeneralName } from "./general_name"; +/** + * ```asn1 + * GeneralNames ::= SEQUENCE SIZE (1..MAX) OF GeneralName + * ``` + */ +export declare class GeneralNames extends AsnArray { + constructor(items?: GeneralName[]); +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/index.d.ts b/node_modules/@peculiar/asn1-x509/build/types/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1f29197077fbfff848d9af63d68e67ea1a9b09bd --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/index.d.ts @@ -0,0 +1,16 @@ +export * from "./extensions"; +export * from "./algorithm_identifier"; +export * from "./attribute"; +export * from "./certificate"; +export * from "./certificate_list"; +export * from "./extension"; +export * from "./general_name"; +export * from "./general_names"; +export * from "./name"; +export * from "./object_identifiers"; +export * from "./subject_public_key_info"; +export * from "./tbs_cert_list"; +export * from "./tbs_certificate"; +export * from "./time"; +export * from "./types"; +export * from "./validity"; diff --git a/node_modules/@peculiar/asn1-x509/build/types/ip_converter.d.ts b/node_modules/@peculiar/asn1-x509/build/types/ip_converter.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8195c3888eef4464bb3f63e98ccf40492b141150 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/ip_converter.d.ts @@ -0,0 +1,12 @@ +export declare class IpConverter { + private static isIPv4; + private static parseIPv4; + private static parseIPv6; + private static expandIPv6; + private static formatIPv6; + private static compressIPv6; + private static parseCIDR; + private static decodeIP; + static toString(buf: ArrayBuffer): string; + static fromString(text: string): ArrayBuffer; +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/name.d.ts b/node_modules/@peculiar/asn1-x509/build/types/name.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..eb90ae5c7fb482ddfb2ca9b2e86587c5e5e48627 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/name.d.ts @@ -0,0 +1,78 @@ +import { AsnArray } from "@peculiar/asn1-schema"; +/** + * ```asn1 + * AttributeType ::= OBJECT IDENTIFIER + * ``` + */ +export type AttributeType = string; +/** + * ```asn1 + * DirectoryString ::= CHOICE { + * teletexString TeletexString (SIZE (1..MAX)), + * printableString PrintableString (SIZE (1..MAX)), + * universalString UniversalString (SIZE (1..MAX)), + * utf8String UTF8String (SIZE (1..MAX)), + * bmpString BMPString (SIZE (1..MAX)) } + * ``` + */ +export declare class DirectoryString { + teletexString?: string; + printableString?: string; + universalString?: string; + utf8String?: string; + bmpString?: string; + constructor(params?: Partial); + /** + * Returns a string representation of an object. + */ + toString(): string; +} +/** + * ```asn1 + * AttributeValue ::= ANY -- DEFINED BY AttributeType + * in general it will be a DirectoryString + * ``` + */ +export declare class AttributeValue extends DirectoryString { + ia5String?: string; + anyValue?: ArrayBuffer; + constructor(params?: Partial); + toString(): string; +} +/** + * ```asn1 + * AttributeTypeAndValue ::= SEQUENCE { + * type AttributeType, + * value AttributeValue } + * ``` + */ +export declare class AttributeTypeAndValue { + type: string; + value: AttributeValue; + constructor(params?: Partial); +} +/** + * ```asn1 + * RelativeDistinguishedName ::= SET SIZE (1..MAX) OF AttributeTypeAndValue + * ``` + */ +export declare class RelativeDistinguishedName extends AsnArray { + constructor(items?: AttributeTypeAndValue[]); +} +/** + * ```asn1 + * RDNSequence ::= SEQUENCE OF RelativeDistinguishedName + * ``` + */ +export declare class RDNSequence extends AsnArray { + constructor(items?: RelativeDistinguishedName[]); +} +/** + * ```asn1 + * Name ::= CHOICE { -- only one possibility for now -- + * rdnSequence RDNSequence } + * ``` + */ +export declare class Name extends RDNSequence { + constructor(items?: RelativeDistinguishedName[]); +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/object_identifiers.d.ts b/node_modules/@peculiar/asn1-x509/build/types/object_identifiers.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c14603c5641f4d2a029561db273bfae40d132a83 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/object_identifiers.d.ts @@ -0,0 +1,80 @@ +/** + * ```asn1 + * id-pkix OBJECT IDENTIFIER ::= + * { iso(1) identified-organization(3) dod(6) internet(1) + * security(5) mechanisms(5) pkix(7) } + * ``` + */ +export declare const id_pkix = "1.3.6.1.5.5.7"; +/** + * ```asn1 + * id-pe OBJECT IDENTIFIER ::= { id-pkix 1 } + * -- arc for private certificate extensions + * ``` + */ +export declare const id_pe = "1.3.6.1.5.5.7.1"; +/** + * ```asn1 + * id-qt OBJECT IDENTIFIER ::= { id-pkix 2 } + * -- arc for policy qualifier types + * ``` + */ +export declare const id_qt = "1.3.6.1.5.5.7.2"; +/** + * ```asn1 + * id-kp OBJECT IDENTIFIER ::= { id-pkix 3 } + * -- arc for extended key purpose OIDS + * ``` + */ +export declare const id_kp = "1.3.6.1.5.5.7.3"; +/** + * ```asn1 + * id-ad OBJECT IDENTIFIER ::= { id-pkix 48 } + * -- arc for access descriptors + * ``` + */ +export declare const id_ad = "1.3.6.1.5.5.7.48"; +/** + * ```asn1 + * id-qt-cps OBJECT IDENTIFIER ::= { id-qt 1 } + * -- OID for CPS qualifier + * ``` + */ +export declare const id_qt_csp = "1.3.6.1.5.5.7.2.1"; +/** + * ```asn1 + * id-qt-unotice OBJECT IDENTIFIER ::= { id-qt 2 } + * -- OID for user notice qualifier + * ``` + */ +export declare const id_qt_unotice = "1.3.6.1.5.5.7.2.2"; +/** + * ```asn1 + * id-ad-ocsp OBJECT IDENTIFIER ::= { id-ad 1 } + * ``` + */ +export declare const id_ad_ocsp = "1.3.6.1.5.5.7.48.1"; +/** + * ```asn1 + * id-ad-caIssuers OBJECT IDENTIFIER ::= { id-ad 2 } + * ``` + */ +export declare const id_ad_caIssuers = "1.3.6.1.5.5.7.48.2"; +/** + * ```asn1 + * id-ad-timeStamping OBJECT IDENTIFIER ::= { id-ad 3 } + * ``` + */ +export declare const id_ad_timeStamping = "1.3.6.1.5.5.7.48.3"; +/** + * ```asn1 + * id-ad-caRepository OBJECT IDENTIFIER ::= { id-ad 5 } + * ``` + */ +export declare const id_ad_caRepository = "1.3.6.1.5.5.7.48.5"; +/** + * ```asn1 + * id-ce OBJECT IDENTIFIER ::= {joint-iso-ccitt(2) ds(5) 29} + * ``` + */ +export declare const id_ce = "2.5.29"; diff --git a/node_modules/@peculiar/asn1-x509/build/types/subject_public_key_info.d.ts b/node_modules/@peculiar/asn1-x509/build/types/subject_public_key_info.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fd99abc1699b721cfd969ba59c69d7e152e90fa8 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/subject_public_key_info.d.ts @@ -0,0 +1,13 @@ +import { AlgorithmIdentifier } from "./algorithm_identifier"; +/** + * ```asn1 + * SubjectPublicKeyInfo ::= SEQUENCE { + * algorithm AlgorithmIdentifier, + * subjectPublicKey BIT STRING } + * ``` + */ +export declare class SubjectPublicKeyInfo { + algorithm: AlgorithmIdentifier; + subjectPublicKey: ArrayBuffer; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/tbs_cert_list.d.ts b/node_modules/@peculiar/asn1-x509/build/types/tbs_cert_list.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bbb6184ce2c2b01401d1741b91e71ce7b83454f3 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/tbs_cert_list.d.ts @@ -0,0 +1,57 @@ +import { AlgorithmIdentifier } from "./algorithm_identifier"; +import { Name } from "./name"; +import { Time } from "./time"; +import { Extension } from "./extension"; +import { Version } from "./types"; +/** + * Revoked certificate + * ```asn1 + * SEQUENCE { + * userCertificate CertificateSerialNumber, + * revocationDate Time, + * crlEntryExtensions Extensions OPTIONAL + * -- if present, version MUST be v2 + * } + * ``` + */ +export declare class RevokedCertificate { + /** + * Serial number of the certificate + */ + userCertificate: ArrayBuffer; + /** + * Revocation date + */ + revocationDate: Time; + crlEntryExtensions?: Extension[]; + constructor(params?: Partial); +} +/** + * ```asn1 + * TBSCertList ::= SEQUENCE { + * version Version OPTIONAL, + * -- if present, MUST be v2 + * signature AlgorithmIdentifier, + * issuer Name, + * thisUpdate Time, + * nextUpdate Time OPTIONAL, + * revokedCertificates SEQUENCE OF SEQUENCE { + * userCertificate CertificateSerialNumber, + * revocationDate Time, + * crlEntryExtensions Extensions OPTIONAL + * -- if present, version MUST be v2 + * } OPTIONAL, + * crlExtensions [0] Extensions OPTIONAL } + * -- if present, version MUST be v2 + * ``` + */ +export declare class TBSCertList { + version?: Version; + signature: AlgorithmIdentifier; + issuer: Name; + thisUpdate: Time; + nextUpdate?: Time; + revokedCertificates?: RevokedCertificate[]; + crlExtensions?: Extension[]; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/tbs_certificate.d.ts b/node_modules/@peculiar/asn1-x509/build/types/tbs_certificate.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2bd228a5c8f4d2c0d82cee9134276522722d5ff4 --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/tbs_certificate.d.ts @@ -0,0 +1,37 @@ +import { AlgorithmIdentifier } from "./algorithm_identifier"; +import { Name } from "./name"; +import { SubjectPublicKeyInfo } from "./subject_public_key_info"; +import { Validity } from "./validity"; +import { Extensions } from "./extension"; +import { Version, CertificateSerialNumber, UniqueIdentifier } from "./types"; +/** + * ```asn1 + * TBSCertificate ::= SEQUENCE { + * version [0] Version DEFAULT v1, + * serialNumber CertificateSerialNumber, + * signature AlgorithmIdentifier, + * issuer Name, + * validity Validity, + * subject Name, + * subjectPublicKeyInfo SubjectPublicKeyInfo, + * issuerUniqueID [1] IMPLICIT UniqueIdentifier OPTIONAL, + * -- If present, version MUST be v2 or v3 + * subjectUniqueID [2] IMPLICIT UniqueIdentifier OPTIONAL, + * -- If present, version MUST be v2 or v3 + * extensions [3] Extensions OPTIONAL + * -- If present, version MUST be v3 -- } + * ``` + */ +export declare class TBSCertificate { + version: Version; + serialNumber: CertificateSerialNumber; + signature: AlgorithmIdentifier; + issuer: Name; + validity: Validity; + subject: Name; + subjectPublicKeyInfo: SubjectPublicKeyInfo; + issuerUniqueID?: UniqueIdentifier; + subjectUniqueID?: UniqueIdentifier; + extensions?: Extensions; + constructor(params?: Partial); +} diff --git a/node_modules/@peculiar/asn1-x509/build/types/time.d.ts b/node_modules/@peculiar/asn1-x509/build/types/time.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3b2bf757370131b71014fe56fb65a304ae81eb4f --- /dev/null +++ b/node_modules/@peculiar/asn1-x509/build/types/time.d.ts @@ -0,0 +1,13 @@ +/** + * ```asn1 + * Time ::= CHOICE { + * utcTime UTCTime, + * generalTime GeneralizedTime } + * ``` + */ +export declare class Time { + utcTime?: Date; + generalTime?: Date; + constructor(time?: Date | string | number | Partial