From 26051774464013a50c06f04ce22cd0dabd75431c Mon Sep 17 00:00:00 2001 From: Junxiao Shi Date: Thu, 30 Jan 2025 03:25:52 +0000 Subject: [PATCH] fix: put types in .d.ts --- index.d.ts | 48 ++++++++++++++++++++++++++++++++++++++++++++++- package-lock.json | 9 +-------- package.json | 3 +-- 3 files changed, 49 insertions(+), 11 deletions(-) diff --git a/index.d.ts b/index.d.ts index 05add9f..68d7bb5 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1 +1,47 @@ -export * from "@root/asn1"; +export {}; + +interface Element { + type: number; + lengthSize: number; + length: number; + value?: V | undefined; + children?: Array> | undefined; +} + +export type ElementHex = Element; + +export type ElementBuffer = Element; + +export interface ElementInput { + type: number; + value?: string | Uint8Array | undefined; + children?: ElementInput[] | undefined; +} + +export type ArrJson = [string, string | ArrJson[]]; + +export type ArrBuffer = [number, Uint8Array | ArrBuffer[]]; + +export type ArrInput = [string | number, string | Uint8Array | ArrInput[]]; + +export function parseVerbose(buf: Uint8Array, opts?: { json?: false | undefined }): ElementBuffer; + +export function parseVerbose(buf: Uint8Array, opts: { json: true }): ElementHex; + +export function parse(opts: { der: Uint8Array; verbose?: false | undefined; json?: true | undefined }): ArrJson; + +export function parse(opts: { der: Uint8Array; verbose?: false | undefined; json: false }): ArrBuffer; + +export function parse(opts: { der: Uint8Array; verbose: true; json?: true | undefined }): ElementHex; + +export function parse(opts: { der: Uint8Array; verbose: true; json: false }): ElementBuffer; + +export function pack(asn1: ElementInput | ArrInput, opts?: { json?: false | undefined }): Uint8Array; + +export function pack(asn1: ElementInput | ArrInput, opts: { json: true }): string; + +export function Any(hexType: string | number, ...hexBytes: string[]): string; + +export function UInt(hexBigInt: string): string; + +export function BitStr(hexBitStream: string): string; diff --git a/package-lock.json b/package-lock.json index 15dda6d..2815ac7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,8 +9,7 @@ "version": "1.0.2", "license": "MPL-2.0", "dependencies": { - "@root/encoding": "^1.0.1", - "@types/root__asn1": "^1.0.0" + "@root/encoding": "^1.0.1" }, "devDependencies": { "@root/pem": "^1.0.4" @@ -28,12 +27,6 @@ "integrity": "sha512-rEUDiUsHtild8GfIjFE9wXtcVxeS+ehCJQBwbQQ3IVfORKHK93CFnRtkr69R75lZFjcmKYVc+AXDB+AeRFOULA==", "dev": true, "license": "MPL-2.0" - }, - "node_modules/@types/root__asn1": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/@types/root__asn1/-/root__asn1-1.0.5.tgz", - "integrity": "sha512-halz3HrALf1N4pUJrtQrH6mdWPczXwshoWjuxmx49riKMJv2MZGKXnauk0RjlnRzM0rlwiAJRlMT9FtSjnF2kw==", - "license": "MIT" } } } diff --git a/package.json b/package.json index 0806ccf..da4a850 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,6 @@ "@root/pem": "^1.0.4" }, "dependencies": { - "@root/encoding": "^1.0.1", - "@types/root__asn1": "^1.0.0" + "@root/encoding": "^1.0.1" } }