Spaces:
Sleeping
Sleeping
Include updated package-lock.json (part 12)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +6 -0
- node_modules/@peculiar/asn1-x509-attr/build/types/clearance.d.ts +17 -0
- node_modules/@peculiar/asn1-x509-attr/build/types/holder.d.ts +23 -0
- node_modules/@peculiar/asn1-x509-attr/build/types/ietf_attr_syntax.d.ts +33 -0
- node_modules/@peculiar/asn1-x509-attr/build/types/index.d.ts +20 -0
- node_modules/@peculiar/asn1-x509-attr/build/types/issuer_serial.d.ts +16 -0
- node_modules/@peculiar/asn1-x509-attr/build/types/object_digest_info.d.ts +28 -0
- node_modules/@peculiar/asn1-x509-attr/build/types/object_identifiers.d.ts +80 -0
- node_modules/@peculiar/asn1-x509-attr/build/types/proxy_info.d.ts +10 -0
- node_modules/@peculiar/asn1-x509-attr/build/types/role_syntax.d.ts +14 -0
- node_modules/@peculiar/asn1-x509-attr/build/types/security_category.d.ts +13 -0
- node_modules/@peculiar/asn1-x509-attr/build/types/svce_auth_info.d.ts +17 -0
- node_modules/@peculiar/asn1-x509-attr/build/types/target.d.ts +42 -0
- node_modules/@peculiar/asn1-x509-attr/build/types/v2_form.d.ts +21 -0
- node_modules/@peculiar/asn1-x509-attr/package.json +61 -0
- node_modules/@peculiar/utils/LICENSE +21 -0
- node_modules/@peculiar/utils/README.md +299 -0
- node_modules/@peculiar/utils/build/cjs/bytes/buffer-source.js +115 -0
- node_modules/@peculiar/utils/build/cjs/bytes/concat.js +41 -0
- node_modules/@peculiar/utils/build/cjs/bytes/equal.js +17 -0
- node_modules/@peculiar/utils/build/cjs/bytes/index.js +31 -0
- node_modules/@peculiar/utils/build/cjs/bytes/sequence.js +161 -0
- node_modules/@peculiar/utils/build/cjs/bytes/types.js +2 -0
- node_modules/@peculiar/utils/build/cjs/converters/convert.js +74 -0
- node_modules/@peculiar/utils/build/cjs/converters/defaults.js +72 -0
- node_modules/@peculiar/utils/build/cjs/converters/index.js +18 -0
- node_modules/@peculiar/utils/build/cjs/converters/registry.js +188 -0
- node_modules/@peculiar/utils/build/cjs/converters/types.js +2 -0
- node_modules/@peculiar/utils/build/cjs/encoding/base64.js +48 -0
- node_modules/@peculiar/utils/build/cjs/encoding/base64url.js +26 -0
- node_modules/@peculiar/utils/build/cjs/encoding/binary.js +26 -0
- node_modules/@peculiar/utils/build/cjs/encoding/hex.js +229 -0
- node_modules/@peculiar/utils/build/cjs/encoding/index.js +10 -0
- node_modules/@peculiar/utils/build/cjs/encoding/utf16.js +24 -0
- node_modules/@peculiar/utils/build/cjs/encoding/utf8.js +13 -0
- node_modules/@peculiar/utils/build/cjs/index.js +10 -0
- node_modules/@peculiar/utils/build/cjs/legacy/buffer-source-converter.js +37 -0
- node_modules/@peculiar/utils/build/cjs/legacy/convert.js +72 -0
- node_modules/@peculiar/utils/build/cjs/legacy/functions.js +23 -0
- node_modules/@peculiar/utils/build/cjs/legacy/index.js +11 -0
- node_modules/@peculiar/utils/build/cjs/package.json +3 -0
- node_modules/@peculiar/utils/build/cjs/pem/index.js +14 -0
- node_modules/@peculiar/utils/build/cjs/pem/pem.js +140 -0
- node_modules/@peculiar/utils/build/cjs/pem/types.js +2 -0
- node_modules/@peculiar/utils/build/esm/bytes/buffer-source.js +101 -0
- node_modules/@peculiar/utils/build/esm/bytes/concat.js +37 -0
- node_modules/@peculiar/utils/build/esm/bytes/equal.js +14 -0
- node_modules/@peculiar/utils/build/esm/bytes/index.js +4 -0
- node_modules/@peculiar/utils/build/esm/bytes/sequence.js +150 -0
- node_modules/@peculiar/utils/build/esm/bytes/types.js +1 -0
.gitattributes
CHANGED
|
@@ -39,3 +39,9 @@ node_modules/@jimp/plugin-color/src/images/qr.jpg filter=lfs diff=lfs merge=lfs
|
|
| 39 |
node_modules/@jimp/plugin-print/fonts/open-sans/open-sans-128-black/open-sans-128-black.png filter=lfs diff=lfs merge=lfs -text
|
| 40 |
node_modules/@jimp/plugin-print/fonts/open-sans/open-sans-128-white/open-sans-128-white.png filter=lfs diff=lfs merge=lfs -text
|
| 41 |
node_modules/@jimp/plugin-threshold/src/__image_snapshots__/index-test-ts-src-index-test-ts-threshold-defines-default-threshold-for-lighter-backgrounds-1-snap.png filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
node_modules/@jimp/plugin-print/fonts/open-sans/open-sans-128-black/open-sans-128-black.png filter=lfs diff=lfs merge=lfs -text
|
| 40 |
node_modules/@jimp/plugin-print/fonts/open-sans/open-sans-128-white/open-sans-128-white.png filter=lfs diff=lfs merge=lfs -text
|
| 41 |
node_modules/@jimp/plugin-threshold/src/__image_snapshots__/index-test-ts-src-index-test-ts-threshold-defines-default-threshold-for-lighter-backgrounds-1-snap.png filter=lfs diff=lfs merge=lfs -text
|
| 42 |
+
node_modules/@rolldown/binding-linux-x64-gnu/rolldown-binding.linux-x64-gnu.node filter=lfs diff=lfs merge=lfs -text
|
| 43 |
+
node_modules/@rolldown/binding-linux-x64-musl/rolldown-binding.linux-x64-musl.node filter=lfs diff=lfs merge=lfs -text
|
| 44 |
+
node_modules/@rollup/rollup-linux-x64-gnu/rollup.linux-x64-gnu.node filter=lfs diff=lfs merge=lfs -text
|
| 45 |
+
node_modules/@rollup/rollup-linux-x64-musl/rollup.linux-x64-musl.node filter=lfs diff=lfs merge=lfs -text
|
| 46 |
+
node_modules/@swc/core-linux-x64-gnu/swc.linux-x64-gnu.node filter=lfs diff=lfs merge=lfs -text
|
| 47 |
+
node_modules/@swc/core-linux-x64-musl/swc.linux-x64-musl.node filter=lfs diff=lfs merge=lfs -text
|
node_modules/@peculiar/asn1-x509-attr/build/types/clearance.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { ClassList } from "./class_list";
|
| 2 |
+
import { SecurityCategory } from "./security_category";
|
| 3 |
+
/**
|
| 4 |
+
* ```asn1
|
| 5 |
+
* Clearance ::= SEQUENCE {
|
| 6 |
+
* policyId OBJECT IDENTIFIER,
|
| 7 |
+
* classList ClassList DEFAULT {unclassified},
|
| 8 |
+
* securityCategories SET OF SecurityCategory OPTIONAL
|
| 9 |
+
* }
|
| 10 |
+
* ```
|
| 11 |
+
*/
|
| 12 |
+
export declare class Clearance {
|
| 13 |
+
policyId: string;
|
| 14 |
+
classList: ClassList;
|
| 15 |
+
securityCategories?: SecurityCategory[];
|
| 16 |
+
constructor(params?: Partial<Clearance>);
|
| 17 |
+
}
|
node_modules/@peculiar/asn1-x509-attr/build/types/holder.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { GeneralNames } from "@peculiar/asn1-x509";
|
| 2 |
+
import { IssuerSerial } from "./issuer_serial";
|
| 3 |
+
import { ObjectDigestInfo } from "./object_digest_info";
|
| 4 |
+
/**
|
| 5 |
+
* ```asn1
|
| 6 |
+
* Holder ::= SEQUENCE {
|
| 7 |
+
* baseCertificateID [0] IssuerSerial OPTIONAL,
|
| 8 |
+
* -- the issuer and serial number of
|
| 9 |
+
* -- the holder's Public Key Certificate
|
| 10 |
+
* entityName [1] GeneralNames OPTIONAL,
|
| 11 |
+
* -- the name of the claimant or role
|
| 12 |
+
* objectDigestInfo [2] ObjectDigestInfo OPTIONAL
|
| 13 |
+
* -- used to directly authenticate the
|
| 14 |
+
* -- holder, for example, an executable
|
| 15 |
+
* }
|
| 16 |
+
* ```
|
| 17 |
+
*/
|
| 18 |
+
export declare class Holder {
|
| 19 |
+
baseCertificateID?: IssuerSerial;
|
| 20 |
+
entityName?: GeneralNames;
|
| 21 |
+
objectDigestInfo?: ObjectDigestInfo;
|
| 22 |
+
constructor(params?: Partial<Holder>);
|
| 23 |
+
}
|
node_modules/@peculiar/asn1-x509-attr/build/types/ietf_attr_syntax.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { OctetString } from "@peculiar/asn1-schema";
|
| 2 |
+
import { GeneralNames } from "@peculiar/asn1-x509";
|
| 3 |
+
/**
|
| 4 |
+
* ```asn1
|
| 5 |
+
* CHOICE {
|
| 6 |
+
* octets OCTET STRING,
|
| 7 |
+
* oid OBJECT IDENTIFIER,
|
| 8 |
+
* string UTF8String
|
| 9 |
+
* ```
|
| 10 |
+
*/
|
| 11 |
+
export declare class IetfAttrSyntaxValueChoices {
|
| 12 |
+
cotets?: OctetString;
|
| 13 |
+
oid?: string;
|
| 14 |
+
string?: string;
|
| 15 |
+
constructor(params?: Partial<IetfAttrSyntaxValueChoices>);
|
| 16 |
+
}
|
| 17 |
+
/**
|
| 18 |
+
* ```asn1
|
| 19 |
+
* IetfAttrSyntax ::= SEQUENCE {
|
| 20 |
+
* policyAuthority[0] GeneralNames OPTIONAL,
|
| 21 |
+
* values SEQUENCE OF CHOICE {
|
| 22 |
+
* octets OCTET STRING,
|
| 23 |
+
* oid OBJECT IDENTIFIER,
|
| 24 |
+
* string UTF8String
|
| 25 |
+
* }
|
| 26 |
+
* }
|
| 27 |
+
* ```
|
| 28 |
+
*/
|
| 29 |
+
export declare class IetfAttrSyntax {
|
| 30 |
+
policyAuthority?: GeneralNames;
|
| 31 |
+
values: IetfAttrSyntaxValueChoices[];
|
| 32 |
+
constructor(params?: Partial<IetfAttrSyntax>);
|
| 33 |
+
}
|
node_modules/@peculiar/asn1-x509-attr/build/types/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export * from "./aa_clear_attrs";
|
| 2 |
+
export * from "./aa_controls";
|
| 3 |
+
export * from "./attr_cert_issuer";
|
| 4 |
+
export * from "./attr_cert_validity_period";
|
| 5 |
+
export * from "./attr_spec";
|
| 6 |
+
export * from "./attribute_certificate";
|
| 7 |
+
export * from "./attribute_certificate_info";
|
| 8 |
+
export * from "./class_list";
|
| 9 |
+
export * from "./clearance";
|
| 10 |
+
export * from "./holder";
|
| 11 |
+
export * from "./ietf_attr_syntax";
|
| 12 |
+
export * from "./issuer_serial";
|
| 13 |
+
export * from "./object_digest_info";
|
| 14 |
+
export * from "./object_identifiers";
|
| 15 |
+
export * from "./proxy_info";
|
| 16 |
+
export * from "./role_syntax";
|
| 17 |
+
export * from "./security_category";
|
| 18 |
+
export * from "./svce_auth_info";
|
| 19 |
+
export * from "./target";
|
| 20 |
+
export * from "./v2_form";
|
node_modules/@peculiar/asn1-x509-attr/build/types/issuer_serial.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { GeneralNames, CertificateSerialNumber, UniqueIdentifier } from "@peculiar/asn1-x509";
|
| 2 |
+
/**
|
| 3 |
+
* ```asn1
|
| 4 |
+
* IssuerSerial ::= SEQUENCE {
|
| 5 |
+
* issuer GeneralNames,
|
| 6 |
+
* serial CertificateSerialNumber,
|
| 7 |
+
* issuerUID UniqueIdentifier OPTIONAL
|
| 8 |
+
* }
|
| 9 |
+
* ```
|
| 10 |
+
*/
|
| 11 |
+
export declare class IssuerSerial {
|
| 12 |
+
issuer: GeneralNames;
|
| 13 |
+
serial: CertificateSerialNumber;
|
| 14 |
+
issuerUID: UniqueIdentifier;
|
| 15 |
+
constructor(params?: Partial<IssuerSerial>);
|
| 16 |
+
}
|
node_modules/@peculiar/asn1-x509-attr/build/types/object_digest_info.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { AlgorithmIdentifier } from "@peculiar/asn1-x509";
|
| 2 |
+
export declare enum DigestedObjectType {
|
| 3 |
+
publicKey = 0,
|
| 4 |
+
publicKeyCert = 1,
|
| 5 |
+
otherObjectTypes = 2
|
| 6 |
+
}
|
| 7 |
+
/**
|
| 8 |
+
* ```asn1
|
| 9 |
+
* ObjectDigestInfo ::= SEQUENCE {
|
| 10 |
+
* digestedObjectType ENUMERATED {
|
| 11 |
+
* publicKey (0),
|
| 12 |
+
* publicKeyCert (1),
|
| 13 |
+
* otherObjectTypes (2) },
|
| 14 |
+
* -- otherObjectTypes MUST NOT
|
| 15 |
+
* -- MUST NOT be used in this profile
|
| 16 |
+
* otherObjectTypeID OBJECT IDENTIFIER OPTIONAL,
|
| 17 |
+
* digestAlgorithm AlgorithmIdentifier,
|
| 18 |
+
* objectDigest BIT STRING
|
| 19 |
+
* }
|
| 20 |
+
* ```
|
| 21 |
+
*/
|
| 22 |
+
export declare class ObjectDigestInfo {
|
| 23 |
+
digestedObjectType: DigestedObjectType;
|
| 24 |
+
otherObjectTypeID?: string;
|
| 25 |
+
digestAlgorithm: AlgorithmIdentifier;
|
| 26 |
+
objectDigest: ArrayBuffer;
|
| 27 |
+
constructor(params?: Partial<ObjectDigestInfo>);
|
| 28 |
+
}
|
node_modules/@peculiar/asn1-x509-attr/build/types/object_identifiers.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* ```asn1
|
| 3 |
+
* id-pe-ac-auditIdentity OBJECT IDENTIFIER ::= { id-pe 4 }
|
| 4 |
+
* ```
|
| 5 |
+
*/
|
| 6 |
+
export declare const id_pe_ac_auditIdentity = "1.3.6.1.5.5.7.1.4";
|
| 7 |
+
/**
|
| 8 |
+
* ```asn1
|
| 9 |
+
* id-pe-aaControls OBJECT IDENTIFIER ::= { id-pe 6 }
|
| 10 |
+
* ```
|
| 11 |
+
*/
|
| 12 |
+
export declare const id_pe_aaControls = "1.3.6.1.5.5.7.1.6";
|
| 13 |
+
/**
|
| 14 |
+
* ```asn1
|
| 15 |
+
* id-pe-ac-proxying OBJECT IDENTIFIER ::= { id-pe 10 }
|
| 16 |
+
* ```
|
| 17 |
+
*/
|
| 18 |
+
export declare const id_pe_ac_proxying = "1.3.6.1.5.5.7.1.10";
|
| 19 |
+
/**
|
| 20 |
+
* ```asn1
|
| 21 |
+
* id-ce-targetInformation OBJECT IDENTIFIER ::= { id-ce 55 }
|
| 22 |
+
* ```
|
| 23 |
+
*/
|
| 24 |
+
export declare const id_ce_targetInformation = "2.5.29.55";
|
| 25 |
+
/**
|
| 26 |
+
* ```asn1
|
| 27 |
+
* id-aca OBJECT IDENTIFIER ::= { id-pkix 10 }
|
| 28 |
+
* ```
|
| 29 |
+
*/
|
| 30 |
+
export declare const id_aca = "1.3.6.1.5.5.7.10";
|
| 31 |
+
/**
|
| 32 |
+
* ```asn1
|
| 33 |
+
* id-aca-authenticationInfo OBJECT IDENTIFIER ::= { id-aca 1 }
|
| 34 |
+
* ```
|
| 35 |
+
*/
|
| 36 |
+
export declare const id_aca_authenticationInfo = "1.3.6.1.5.5.7.10.1";
|
| 37 |
+
/**
|
| 38 |
+
* ```asn1
|
| 39 |
+
* id-aca-accessIdentity OBJECT IDENTIFIER ::= { id-aca 2 }
|
| 40 |
+
* ```
|
| 41 |
+
*/
|
| 42 |
+
export declare const id_aca_accessIdentity = "1.3.6.1.5.5.7.10.2";
|
| 43 |
+
/**
|
| 44 |
+
* ```asn1
|
| 45 |
+
* id-aca-chargingIdentity OBJECT IDENTIFIER ::= { id-aca 3 }
|
| 46 |
+
* ```
|
| 47 |
+
*/
|
| 48 |
+
export declare const id_aca_chargingIdentity = "1.3.6.1.5.5.7.10.3";
|
| 49 |
+
/**
|
| 50 |
+
* ```asn1
|
| 51 |
+
* id-aca-group OBJECT IDENTIFIER ::= { id-aca 4 }
|
| 52 |
+
* ```
|
| 53 |
+
*/
|
| 54 |
+
export declare const id_aca_group = "1.3.6.1.5.5.7.10.4";
|
| 55 |
+
/**
|
| 56 |
+
* ```asn1
|
| 57 |
+
* id-aca-encAttrs OBJECT IDENTIFIER ::= { id-aca 6 }
|
| 58 |
+
* ```
|
| 59 |
+
*/
|
| 60 |
+
export declare const id_aca_encAttrs = "1.3.6.1.5.5.7.10.6";
|
| 61 |
+
/**
|
| 62 |
+
* ```asn1
|
| 63 |
+
* id-at OBJECT IDENTIFIER ::= { joint-iso-ccitt(2) ds(5) 4 }
|
| 64 |
+
* ```
|
| 65 |
+
*/
|
| 66 |
+
export declare const id_at = "2.5.4";
|
| 67 |
+
/**
|
| 68 |
+
* ```asn1
|
| 69 |
+
* id-at-role OBJECT IDENTIFIER ::= { id-at 72}
|
| 70 |
+
* ```
|
| 71 |
+
*/
|
| 72 |
+
export declare const id_at_role = "2.5.4.72";
|
| 73 |
+
/**
|
| 74 |
+
* ```asn1
|
| 75 |
+
* id-at-clearance OBJECT IDENTIFIER ::=
|
| 76 |
+
* { joint-iso-ccitt(2) ds(5) module(1)
|
| 77 |
+
* selected-attribute-types(5) clearance (55) }
|
| 78 |
+
* ```
|
| 79 |
+
*/
|
| 80 |
+
export declare const id_at_clearance = "2.5.1.5.55";
|
node_modules/@peculiar/asn1-x509-attr/build/types/proxy_info.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { AsnArray } from "@peculiar/asn1-schema";
|
| 2 |
+
import { Targets } from "./target";
|
| 3 |
+
/**
|
| 4 |
+
* ```asn1
|
| 5 |
+
* ProxyInfo ::= SEQUENCE OF Targets
|
| 6 |
+
* ```
|
| 7 |
+
*/
|
| 8 |
+
export declare class ProxyInfo extends AsnArray<Targets> {
|
| 9 |
+
constructor(items?: Targets[]);
|
| 10 |
+
}
|
node_modules/@peculiar/asn1-x509-attr/build/types/role_syntax.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { GeneralNames, GeneralName } from "@peculiar/asn1-x509";
|
| 2 |
+
/**
|
| 3 |
+
* ```asn1
|
| 4 |
+
* RoleSyntax ::= SEQUENCE {
|
| 5 |
+
* roleAuthority [0] GeneralNames OPTIONAL,
|
| 6 |
+
* roleName [1] GeneralName
|
| 7 |
+
* }
|
| 8 |
+
* ```
|
| 9 |
+
*/
|
| 10 |
+
export declare class RoleSyntax {
|
| 11 |
+
roleAuthority?: GeneralNames;
|
| 12 |
+
roleName?: GeneralName;
|
| 13 |
+
constructor(params?: Partial<RoleSyntax>);
|
| 14 |
+
}
|
node_modules/@peculiar/asn1-x509-attr/build/types/security_category.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* ```asn1
|
| 3 |
+
* SecurityCategory ::= SEQUENCE {
|
| 4 |
+
* type [0] IMPLICIT OBJECT IDENTIFIER,
|
| 5 |
+
* value [1] ANY DEFINED BY type
|
| 6 |
+
* }
|
| 7 |
+
* ```
|
| 8 |
+
*/
|
| 9 |
+
export declare class SecurityCategory {
|
| 10 |
+
type: string;
|
| 11 |
+
value: ArrayBuffer;
|
| 12 |
+
constructor(params?: Partial<SecurityCategory>);
|
| 13 |
+
}
|
node_modules/@peculiar/asn1-x509-attr/build/types/svce_auth_info.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { OctetString } from "@peculiar/asn1-schema";
|
| 2 |
+
import { GeneralName } from "@peculiar/asn1-x509";
|
| 3 |
+
/**
|
| 4 |
+
* ```asn1
|
| 5 |
+
* SvceAuthInfo ::= SEQUENCE {
|
| 6 |
+
* service GeneralName,
|
| 7 |
+
* ident GeneralName,
|
| 8 |
+
* authInfo OCTET STRING OPTIONAL
|
| 9 |
+
* }
|
| 10 |
+
* ```
|
| 11 |
+
*/
|
| 12 |
+
export declare class SvceAuthInfo {
|
| 13 |
+
service: GeneralName;
|
| 14 |
+
ident: GeneralName;
|
| 15 |
+
authInfo?: OctetString;
|
| 16 |
+
constructor(params?: Partial<SvceAuthInfo>);
|
| 17 |
+
}
|
node_modules/@peculiar/asn1-x509-attr/build/types/target.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { AsnArray } from "@peculiar/asn1-schema";
|
| 2 |
+
import { GeneralName } from "@peculiar/asn1-x509";
|
| 3 |
+
import { IssuerSerial } from "./issuer_serial";
|
| 4 |
+
import { ObjectDigestInfo } from "./object_digest_info";
|
| 5 |
+
/**
|
| 6 |
+
* ```asn1
|
| 7 |
+
* TargetCert ::= SEQUENCE {
|
| 8 |
+
* targetCertificate IssuerSerial,
|
| 9 |
+
* targetName GeneralName OPTIONAL,
|
| 10 |
+
* certDigestInfo ObjectDigestInfo OPTIONAL
|
| 11 |
+
* }
|
| 12 |
+
* ```
|
| 13 |
+
*/
|
| 14 |
+
export declare class TargetCert {
|
| 15 |
+
targetCertificate: IssuerSerial;
|
| 16 |
+
targetName?: GeneralName;
|
| 17 |
+
certDigestInfo?: ObjectDigestInfo;
|
| 18 |
+
constructor(params?: Partial<TargetCert>);
|
| 19 |
+
}
|
| 20 |
+
/**
|
| 21 |
+
* ```asn1
|
| 22 |
+
* Target ::= CHOICE {
|
| 23 |
+
* targetName [0] GeneralName,
|
| 24 |
+
* targetGroup [1] GeneralName,
|
| 25 |
+
* targetCert [2] TargetCert
|
| 26 |
+
* }
|
| 27 |
+
* ```
|
| 28 |
+
*/
|
| 29 |
+
export declare class Target {
|
| 30 |
+
targetName?: GeneralName;
|
| 31 |
+
targetGroup?: GeneralName;
|
| 32 |
+
targetCert?: TargetCert;
|
| 33 |
+
constructor(params?: Partial<Target>);
|
| 34 |
+
}
|
| 35 |
+
/**
|
| 36 |
+
* ```asn1
|
| 37 |
+
* Targets ::= SEQUENCE OF Target
|
| 38 |
+
* ```
|
| 39 |
+
*/
|
| 40 |
+
export declare class Targets extends AsnArray<Target> {
|
| 41 |
+
constructor(items?: Target[]);
|
| 42 |
+
}
|
node_modules/@peculiar/asn1-x509-attr/build/types/v2_form.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { GeneralNames } from "@peculiar/asn1-x509";
|
| 2 |
+
import { IssuerSerial } from "./issuer_serial";
|
| 3 |
+
import { ObjectDigestInfo } from "./object_digest_info";
|
| 4 |
+
/**
|
| 5 |
+
* ```asn1
|
| 6 |
+
* V2Form ::= SEQUENCE {
|
| 7 |
+
* issuerName GeneralNames OPTIONAL,
|
| 8 |
+
* baseCertificateID [0] IssuerSerial OPTIONAL,
|
| 9 |
+
* objectDigestInfo [1] ObjectDigestInfo OPTIONAL
|
| 10 |
+
* -- issuerName MUST be present in this profile
|
| 11 |
+
* -- baseCertificateID and objectDigestInfo MUST
|
| 12 |
+
* -- NOT be present in this profile
|
| 13 |
+
* }
|
| 14 |
+
* ```
|
| 15 |
+
*/
|
| 16 |
+
export declare class V2Form {
|
| 17 |
+
issuerName?: GeneralNames;
|
| 18 |
+
baseCertificateID?: IssuerSerial;
|
| 19 |
+
objectDigestInfo?: ObjectDigestInfo;
|
| 20 |
+
constructor(params?: Partial<V2Form>);
|
| 21 |
+
}
|
node_modules/@peculiar/asn1-x509-attr/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@peculiar/asn1-x509-attr",
|
| 3 |
+
"version": "2.8.0",
|
| 4 |
+
"description": "ASN.1 schema for X.509 attribute certificates defined in RFC 5755.",
|
| 5 |
+
"keywords": [
|
| 6 |
+
"asn",
|
| 7 |
+
"asn1",
|
| 8 |
+
"x509",
|
| 9 |
+
"attribute-certificate",
|
| 10 |
+
"rfc5755"
|
| 11 |
+
],
|
| 12 |
+
"author": "PeculiarVentures, LLC",
|
| 13 |
+
"license": "MIT",
|
| 14 |
+
"files": [
|
| 15 |
+
"build/**/*.{js,d.ts}",
|
| 16 |
+
"build/es2015/package.json",
|
| 17 |
+
"LICENSE",
|
| 18 |
+
"README.md"
|
| 19 |
+
],
|
| 20 |
+
"main": "build/cjs/index.js",
|
| 21 |
+
"module": "build/es2015/index.js",
|
| 22 |
+
"types": "build/types/index.d.ts",
|
| 23 |
+
"exports": {
|
| 24 |
+
".": {
|
| 25 |
+
"types": "./build/types/index.d.ts",
|
| 26 |
+
"import": "./build/es2015/index.js",
|
| 27 |
+
"require": "./build/cjs/index.js"
|
| 28 |
+
},
|
| 29 |
+
"./package.json": "./package.json"
|
| 30 |
+
},
|
| 31 |
+
"publishConfig": {
|
| 32 |
+
"access": "public"
|
| 33 |
+
},
|
| 34 |
+
"repository": {
|
| 35 |
+
"type": "git",
|
| 36 |
+
"url": "https://github.com/PeculiarVentures/asn1-schema",
|
| 37 |
+
"directory": "packages/x509-attr"
|
| 38 |
+
},
|
| 39 |
+
"bugs": {
|
| 40 |
+
"url": "https://github.com/PeculiarVentures/asn1-schema/issues"
|
| 41 |
+
},
|
| 42 |
+
"homepage": "https://github.com/PeculiarVentures/asn1-schema/tree/master/packages/x509-attr#readme",
|
| 43 |
+
"scripts": {
|
| 44 |
+
"clear": "rimraf build",
|
| 45 |
+
"build": "npm run build:module && npm run build:types",
|
| 46 |
+
"build:module": "npm run build:cjs && npm run build:es2015",
|
| 47 |
+
"build:cjs": "tsc -p tsconfig.compile.json --removeComments --module commonjs --outDir build/cjs",
|
| 48 |
+
"build:es2015": "tsc -p tsconfig.compile.json --removeComments --module ES2015 --outDir build/es2015",
|
| 49 |
+
"postbuild:es2015": "node ../../scripts/prepare_esm_package.mjs build/es2015",
|
| 50 |
+
"prebuild:types": "rimraf build/types",
|
| 51 |
+
"build:types": "tsc -p tsconfig.compile.json --outDir build/types --declaration --emitDeclarationOnly",
|
| 52 |
+
"rebuild": "npm run clear && npm run build",
|
| 53 |
+
"test": "mocha"
|
| 54 |
+
},
|
| 55 |
+
"dependencies": {
|
| 56 |
+
"@peculiar/asn1-schema": "^2.8.0",
|
| 57 |
+
"@peculiar/asn1-x509": "^2.8.0",
|
| 58 |
+
"asn1js": "^3.0.10",
|
| 59 |
+
"tslib": "^2.8.1"
|
| 60 |
+
}
|
| 61 |
+
}
|
node_modules/@peculiar/utils/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2017-2026 Peculiar Ventures, LLC
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
node_modules/@peculiar/utils/README.md
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# @peculiar/utils
|
| 2 |
+
|
| 3 |
+
[](https://www.npmjs.com/package/@peculiar/utils)
|
| 4 |
+
[](https://github.com/PeculiarVentures/pvtsutils/actions/workflows/test.yml)
|
| 5 |
+
[](https://coveralls.io/github/PeculiarVentures/pvtsutils?branch=master)
|
| 6 |
+
[](https://github.com/PeculiarVentures/pvtsutils/blob/master/LICENSE)
|
| 7 |
+
|
| 8 |
+
Modern byte, text, converter registry, and PEM utilities for TypeScript projects.
|
| 9 |
+
|
| 10 |
+
The package is designed around a modular v2 API:
|
| 11 |
+
|
| 12 |
+
- multi-entry exports for tree-shake-friendly imports;
|
| 13 |
+
- `encode` and `decode` terminology;
|
| 14 |
+
- an extensible runtime converter registry;
|
| 15 |
+
- generic PEM helpers without PKI-specific parsing;
|
| 16 |
+
- a legacy compatibility layer for historical `pvtsutils` consumers.
|
| 17 |
+
|
| 18 |
+
## Install
|
| 19 |
+
|
| 20 |
+
```bash
|
| 21 |
+
npm install @peculiar/utils
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
+
## Entry Points
|
| 25 |
+
|
| 26 |
+
```ts
|
| 27 |
+
import { bytes } from "@peculiar/utils";
|
| 28 |
+
import { hex, base64, base64url } from "@peculiar/utils/encoding";
|
| 29 |
+
import { pem } from "@peculiar/utils/pem";
|
| 30 |
+
import { convert, createConverterRegistry, defaultConverters } from "@peculiar/utils/converters";
|
| 31 |
+
import { Convert } from "@peculiar/utils/legacy";
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
## Bytes Helpers
|
| 35 |
+
|
| 36 |
+
`@peculiar/utils/bytes` stays focused on stateless byte sequence utilities. It does not include stateful readers, writers, ASN.1 parsing, PDF parsing, or other structured binary readers. For structured binary parsing, use a dedicated binary reader package.
|
| 37 |
+
|
| 38 |
+
```ts
|
| 39 |
+
import { bytes } from "@peculiar/utils";
|
| 40 |
+
|
| 41 |
+
const offset = bytes.indexOf(new Uint8Array([0x25, 0x25, 0x45, 0x4f, 0x46]), "%%EOF", {
|
| 42 |
+
encoding: "ascii",
|
| 43 |
+
});
|
| 44 |
+
|
| 45 |
+
const suffix = bytes.endsWith(new Uint8Array([0x25, 0x25, 0x45, 0x4f, 0x46]), "%%EOF", {
|
| 46 |
+
encoding: "ascii",
|
| 47 |
+
});
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
### Find `startxref` In A PDF Tail
|
| 51 |
+
|
| 52 |
+
```ts
|
| 53 |
+
import { lastIndexOf } from "@peculiar/utils/bytes";
|
| 54 |
+
|
| 55 |
+
const tailStart = Math.max(0, pdf.byteLength - 4096);
|
| 56 |
+
|
| 57 |
+
const offset = lastIndexOf(pdf, "startxref", {
|
| 58 |
+
encoding: "ascii",
|
| 59 |
+
start: pdf.byteLength,
|
| 60 |
+
end: tailStart,
|
| 61 |
+
});
|
| 62 |
+
|
| 63 |
+
if (offset === -1) {
|
| 64 |
+
throw new Error("PDF startxref marker not found");
|
| 65 |
+
}
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
### Find `startxref` Via `tail`
|
| 69 |
+
|
| 70 |
+
```ts
|
| 71 |
+
import { lastIndexOf, tail } from "@peculiar/utils/bytes";
|
| 72 |
+
|
| 73 |
+
const pdfTail = tail(pdf, 4096);
|
| 74 |
+
|
| 75 |
+
const localOffset = lastIndexOf(pdfTail, "startxref", {
|
| 76 |
+
encoding: "ascii",
|
| 77 |
+
});
|
| 78 |
+
|
| 79 |
+
const offset =
|
| 80 |
+
localOffset === -1
|
| 81 |
+
? -1
|
| 82 |
+
: pdf.byteLength - pdfTail.byteLength + localOffset;
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
### Check Prefixes And Suffixes
|
| 86 |
+
|
| 87 |
+
```ts
|
| 88 |
+
import { bytes } from "@peculiar/utils";
|
| 89 |
+
|
| 90 |
+
bytes.startsWith(data, "-----BEGIN", { encoding: "ascii" });
|
| 91 |
+
bytes.endsWith(data, "%%EOF", { encoding: "ascii" });
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
+
### Compare Byte Sequences
|
| 95 |
+
|
| 96 |
+
```ts
|
| 97 |
+
import { bytes } from "@peculiar/utils";
|
| 98 |
+
|
| 99 |
+
const result = bytes.compare(a, b);
|
| 100 |
+
|
| 101 |
+
if (result === 0) {
|
| 102 |
+
console.log("equal");
|
| 103 |
+
}
|
| 104 |
+
```
|
| 105 |
+
|
| 106 |
+
## Convert API
|
| 107 |
+
|
| 108 |
+
The default `convert` facade is a convenience singleton backed by the built-in registry.
|
| 109 |
+
|
| 110 |
+
```ts
|
| 111 |
+
import { convert } from "@peculiar/utils/converters";
|
| 112 |
+
|
| 113 |
+
const bytes = convert.decode("base64", "AQID");
|
| 114 |
+
const text = convert.encode("hex", bytes, { case: "upper" });
|
| 115 |
+
```
|
| 116 |
+
|
| 117 |
+
Deprecated `convert.to(...)` and `convert.from(...)` aliases are still available for temporary migration, but the primary v2 API is `encode` and `decode`.
|
| 118 |
+
|
| 119 |
+
## Transcode
|
| 120 |
+
|
| 121 |
+
Direct text-to-text transcoding goes through the registry without a manual intermediate step.
|
| 122 |
+
|
| 123 |
+
```ts
|
| 124 |
+
import { convert } from "@peculiar/utils/converters";
|
| 125 |
+
import { hex } from "@peculiar/utils/encoding";
|
| 126 |
+
|
| 127 |
+
const pemText = convert.transcode("AQID", {
|
| 128 |
+
from: "base64",
|
| 129 |
+
to: "pem",
|
| 130 |
+
toOptions: {
|
| 131 |
+
label: "CERTIFICATE",
|
| 132 |
+
},
|
| 133 |
+
});
|
| 134 |
+
|
| 135 |
+
const hexText = convert.transcode(pemText, {
|
| 136 |
+
from: "pem",
|
| 137 |
+
fromOptions: { label: "CERTIFICATE" },
|
| 138 |
+
to: "hex",
|
| 139 |
+
toOptions: hex.formats.colonUpper,
|
| 140 |
+
});
|
| 141 |
+
```
|
| 142 |
+
|
| 143 |
+
There is intentionally no chain API.
|
| 144 |
+
|
| 145 |
+
## Hex Formatting
|
| 146 |
+
|
| 147 |
+
The `hex` codec accepts common input styles and can format output explicitly.
|
| 148 |
+
|
| 149 |
+
```ts
|
| 150 |
+
import { hex } from "@peculiar/utils/encoding";
|
| 151 |
+
|
| 152 |
+
hex.decode("0102030405060708090a0b0c");
|
| 153 |
+
hex.decode("01020304 05060708 090a0b0c");
|
| 154 |
+
hex.decode("01:02:03:04:05:06:07:08:09:0A:0B:0C");
|
| 155 |
+
hex.decode("0x0102030405060708090a0b0c");
|
| 156 |
+
|
| 157 |
+
hex.encode(new Uint8Array([1, 2, 3, 4]), hex.formats.colonUpper);
|
| 158 |
+
hex.encode(new Uint8Array([1, 2, 3, 4]), {
|
| 159 |
+
prefix: "0x",
|
| 160 |
+
group: {
|
| 161 |
+
size: 2,
|
| 162 |
+
separator: " ",
|
| 163 |
+
},
|
| 164 |
+
});
|
| 165 |
+
```
|
| 166 |
+
|
| 167 |
+
Available presets:
|
| 168 |
+
|
| 169 |
+
- `hex.formats.compact`
|
| 170 |
+
- `hex.formats.upper`
|
| 171 |
+
- `hex.formats.colon`
|
| 172 |
+
- `hex.formats.colonUpper`
|
| 173 |
+
- `hex.formats.groupsOf4`
|
| 174 |
+
- `hex.formats.prefixed`
|
| 175 |
+
|
| 176 |
+
## Preserve Formatting
|
| 177 |
+
|
| 178 |
+
Use `parse` and `format` when you want to keep the original visual style of a hex string.
|
| 179 |
+
|
| 180 |
+
```ts
|
| 181 |
+
import { hex } from "@peculiar/utils/encoding";
|
| 182 |
+
|
| 183 |
+
const parsed = hex.parse("01:02:03:04:05:06");
|
| 184 |
+
|
| 185 |
+
parsed.bytes;
|
| 186 |
+
parsed.format;
|
| 187 |
+
parsed.normalized;
|
| 188 |
+
|
| 189 |
+
const updated = hex.format(new Uint8Array([0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff]), parsed.format);
|
| 190 |
+
```
|
| 191 |
+
|
| 192 |
+
The same capabilities are available through the registry facade:
|
| 193 |
+
|
| 194 |
+
```ts
|
| 195 |
+
import { convert } from "@peculiar/utils/converters";
|
| 196 |
+
|
| 197 |
+
const parsed = convert.parse("hex", "01:02:03:04");
|
| 198 |
+
const formatted = convert.format("hex", new Uint8Array([0xaa, 0xbb, 0xcc, 0xdd]), parsed.format);
|
| 199 |
+
```
|
| 200 |
+
|
| 201 |
+
## PEM Helpers
|
| 202 |
+
|
| 203 |
+
PEM support stays generic. The package does not parse ASN.1, validate PKI semantics, or handle encrypted PEM containers.
|
| 204 |
+
|
| 205 |
+
```ts
|
| 206 |
+
import { pem } from "@peculiar/utils/pem";
|
| 207 |
+
|
| 208 |
+
const text = pem.encode("CERTIFICATE", new Uint8Array([1, 2, 3]));
|
| 209 |
+
const blocks = pem.decode(text);
|
| 210 |
+
const block = pem.find(text, "CERTIFICATE");
|
| 211 |
+
const matches = pem.findAll(text, "CERTIFICATE");
|
| 212 |
+
|
| 213 |
+
const bundle = pem.encodeMany([
|
| 214 |
+
{ label: "CERTIFICATE", data: new Uint8Array([1, 2, 3]) },
|
| 215 |
+
{ label: "PRIVATE KEY", data: new Uint8Array([4, 5, 6]) },
|
| 216 |
+
]);
|
| 217 |
+
```
|
| 218 |
+
|
| 219 |
+
## Safe Decode And Detection
|
| 220 |
+
|
| 221 |
+
```ts
|
| 222 |
+
import { convert } from "@peculiar/utils/converters";
|
| 223 |
+
|
| 224 |
+
const result = convert.tryDecode("hex", "01:02:03");
|
| 225 |
+
|
| 226 |
+
if (result.ok) {
|
| 227 |
+
console.log(result.bytes);
|
| 228 |
+
} else {
|
| 229 |
+
console.error(result.error);
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
const candidates = convert.detect("-----BEGIN DATA-----\nAQID\n-----END DATA-----\n", {
|
| 233 |
+
formats: ["pem", "base64", "hex"],
|
| 234 |
+
});
|
| 235 |
+
```
|
| 236 |
+
|
| 237 |
+
## Custom Registries
|
| 238 |
+
|
| 239 |
+
Applications can create isolated registries instead of mutating global state.
|
| 240 |
+
|
| 241 |
+
```ts
|
| 242 |
+
import { createConverterRegistry, defaultConverters } from "@peculiar/utils/converters";
|
| 243 |
+
|
| 244 |
+
const registry = createConverterRegistry(defaultConverters);
|
| 245 |
+
|
| 246 |
+
registry.register({
|
| 247 |
+
name: "base58btc",
|
| 248 |
+
aliases: ["b58"],
|
| 249 |
+
encode(data) {
|
| 250 |
+
return base58btcEncode(data);
|
| 251 |
+
},
|
| 252 |
+
decode(text) {
|
| 253 |
+
return base58btcDecode(text);
|
| 254 |
+
},
|
| 255 |
+
});
|
| 256 |
+
```
|
| 257 |
+
|
| 258 |
+
Name and alias conflicts throw by default. Use `{ override: true }` only when replacement is intentional.
|
| 259 |
+
|
| 260 |
+
## Typed Converter Options
|
| 261 |
+
|
| 262 |
+
Built-in converters expose typed options through the registry facade.
|
| 263 |
+
|
| 264 |
+
```ts
|
| 265 |
+
import { convert } from "@peculiar/utils/converters";
|
| 266 |
+
|
| 267 |
+
convert.encode("hex", new Uint8Array([1, 2, 3]), {
|
| 268 |
+
case: "upper",
|
| 269 |
+
});
|
| 270 |
+
```
|
| 271 |
+
|
| 272 |
+
Wrong options are rejected by TypeScript:
|
| 273 |
+
|
| 274 |
+
```ts
|
| 275 |
+
convert.encode("hex", new Uint8Array([1, 2, 3]), {
|
| 276 |
+
label: "CERTIFICATE",
|
| 277 |
+
});
|
| 278 |
+
```
|
| 279 |
+
|
| 280 |
+
Custom converters can extend the options map via module augmentation:
|
| 281 |
+
|
| 282 |
+
```ts
|
| 283 |
+
declare module "@peculiar/utils/converters" {
|
| 284 |
+
interface ConverterOptionsMap {
|
| 285 |
+
base58btc: {
|
| 286 |
+
encode: Base58EncodeOptions;
|
| 287 |
+
decode: Base58DecodeOptions;
|
| 288 |
+
};
|
| 289 |
+
}
|
| 290 |
+
}
|
| 291 |
+
```
|
| 292 |
+
|
| 293 |
+
## Legacy Compatibility
|
| 294 |
+
|
| 295 |
+
The old `pvtsutils`-style surface is preserved under the legacy entry point.
|
| 296 |
+
|
| 297 |
+
```ts
|
| 298 |
+
import { BufferSourceConverter, Convert, assign, combine, isEqual } from "@peculiar/utils/legacy";
|
| 299 |
+
```
|
node_modules/@peculiar/utils/build/cjs/bytes/buffer-source.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.isArrayBuffer = isArrayBuffer;
|
| 4 |
+
exports.isSharedArrayBuffer = isSharedArrayBuffer;
|
| 5 |
+
exports.isArrayBufferLike = isArrayBufferLike;
|
| 6 |
+
exports.isArrayBufferView = isArrayBufferView;
|
| 7 |
+
exports.isBufferSource = isBufferSource;
|
| 8 |
+
exports.assertBufferSource = assertBufferSource;
|
| 9 |
+
exports.toUint8Array = toUint8Array;
|
| 10 |
+
exports.toUint8ArrayCopy = toUint8ArrayCopy;
|
| 11 |
+
exports.toArrayBuffer = toArrayBuffer;
|
| 12 |
+
exports.toArrayBufferLike = toArrayBufferLike;
|
| 13 |
+
exports.toView = toView;
|
| 14 |
+
exports.toViewCopy = toViewCopy;
|
| 15 |
+
const ARRAY_BUFFER_TAG = "[object ArrayBuffer]";
|
| 16 |
+
const SHARED_ARRAY_BUFFER_TAG = "[object SharedArrayBuffer]";
|
| 17 |
+
function tagOf(value) {
|
| 18 |
+
return Object.prototype.toString.call(value);
|
| 19 |
+
}
|
| 20 |
+
function isDataViewConstructor(type) {
|
| 21 |
+
return type === DataView || type.prototype instanceof DataView;
|
| 22 |
+
}
|
| 23 |
+
function bytesPerElement(type) {
|
| 24 |
+
if (isDataViewConstructor(type)) {
|
| 25 |
+
return 1;
|
| 26 |
+
}
|
| 27 |
+
const value = type.BYTES_PER_ELEMENT;
|
| 28 |
+
return value ?? 1;
|
| 29 |
+
}
|
| 30 |
+
function isArrayBufferViewLike(value) {
|
| 31 |
+
if (ArrayBuffer.isView(value)) {
|
| 32 |
+
return true;
|
| 33 |
+
}
|
| 34 |
+
if (!value || typeof value !== "object") {
|
| 35 |
+
return false;
|
| 36 |
+
}
|
| 37 |
+
const view = value;
|
| 38 |
+
return typeof view.byteOffset === "number"
|
| 39 |
+
&& typeof view.byteLength === "number"
|
| 40 |
+
&& isArrayBufferLike(view.buffer);
|
| 41 |
+
}
|
| 42 |
+
function copyBytes(data) {
|
| 43 |
+
const view = toUint8Array(data);
|
| 44 |
+
const copy = new Uint8Array(view.byteLength);
|
| 45 |
+
copy.set(view);
|
| 46 |
+
return copy;
|
| 47 |
+
}
|
| 48 |
+
function isArrayBuffer(value) {
|
| 49 |
+
return tagOf(value) === ARRAY_BUFFER_TAG;
|
| 50 |
+
}
|
| 51 |
+
function isSharedArrayBuffer(value) {
|
| 52 |
+
return typeof SharedArrayBuffer !== "undefined" && tagOf(value) === SHARED_ARRAY_BUFFER_TAG;
|
| 53 |
+
}
|
| 54 |
+
function isArrayBufferLike(value) {
|
| 55 |
+
return isArrayBuffer(value) || isSharedArrayBuffer(value);
|
| 56 |
+
}
|
| 57 |
+
function isArrayBufferView(value) {
|
| 58 |
+
return isArrayBufferViewLike(value);
|
| 59 |
+
}
|
| 60 |
+
function isBufferSource(value) {
|
| 61 |
+
return isArrayBufferLike(value) || isArrayBufferView(value);
|
| 62 |
+
}
|
| 63 |
+
function assertBufferSource(value) {
|
| 64 |
+
if (!isBufferSource(value)) {
|
| 65 |
+
throw new TypeError("Expected ArrayBuffer, SharedArrayBuffer, or ArrayBufferView");
|
| 66 |
+
}
|
| 67 |
+
}
|
| 68 |
+
function toUint8Array(data) {
|
| 69 |
+
assertBufferSource(data);
|
| 70 |
+
if (isArrayBufferLike(data)) {
|
| 71 |
+
return new Uint8Array(data);
|
| 72 |
+
}
|
| 73 |
+
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
| 74 |
+
}
|
| 75 |
+
function toUint8ArrayCopy(data) {
|
| 76 |
+
return copyBytes(data);
|
| 77 |
+
}
|
| 78 |
+
function toArrayBuffer(data) {
|
| 79 |
+
assertBufferSource(data);
|
| 80 |
+
if (isArrayBuffer(data)) {
|
| 81 |
+
return data;
|
| 82 |
+
}
|
| 83 |
+
const buffer = new ArrayBuffer(data.byteLength);
|
| 84 |
+
new Uint8Array(buffer).set(toUint8Array(data));
|
| 85 |
+
return buffer;
|
| 86 |
+
}
|
| 87 |
+
function toArrayBufferLike(data) {
|
| 88 |
+
assertBufferSource(data);
|
| 89 |
+
if (isArrayBufferLike(data)) {
|
| 90 |
+
return data;
|
| 91 |
+
}
|
| 92 |
+
if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {
|
| 93 |
+
return data.buffer;
|
| 94 |
+
}
|
| 95 |
+
return copyBytes(data).buffer;
|
| 96 |
+
}
|
| 97 |
+
function toView(data, type) {
|
| 98 |
+
assertBufferSource(data);
|
| 99 |
+
if (ArrayBuffer.isView(data) && data.constructor === type) {
|
| 100 |
+
return data;
|
| 101 |
+
}
|
| 102 |
+
const view = toUint8Array(data);
|
| 103 |
+
const elementSize = bytesPerElement(type);
|
| 104 |
+
if (view.byteOffset % elementSize !== 0 || view.byteLength % elementSize !== 0) {
|
| 105 |
+
throw new RangeError(`Cannot create ${type.name} over unaligned byte range`);
|
| 106 |
+
}
|
| 107 |
+
if (isDataViewConstructor(type)) {
|
| 108 |
+
return new type(view.buffer, view.byteOffset, view.byteLength);
|
| 109 |
+
}
|
| 110 |
+
return new type(view.buffer, view.byteOffset, view.byteLength / elementSize);
|
| 111 |
+
}
|
| 112 |
+
function toViewCopy(data, type) {
|
| 113 |
+
const copy = toUint8ArrayCopy(data);
|
| 114 |
+
return toView(copy, type);
|
| 115 |
+
}
|
node_modules/@peculiar/utils/build/cjs/bytes/concat.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.concatToUint8Array = concatToUint8Array;
|
| 4 |
+
exports.concat = concat;
|
| 5 |
+
const buffer_source_js_1 = require("./buffer-source.js");
|
| 6 |
+
function concatToUint8Array(buffers) {
|
| 7 |
+
const views = [];
|
| 8 |
+
let length = 0;
|
| 9 |
+
for (const buffer of buffers) {
|
| 10 |
+
const view = (0, buffer_source_js_1.toUint8Array)(buffer);
|
| 11 |
+
views.push(view);
|
| 12 |
+
length += view.byteLength;
|
| 13 |
+
}
|
| 14 |
+
const result = new Uint8Array(length);
|
| 15 |
+
let offset = 0;
|
| 16 |
+
for (const view of views) {
|
| 17 |
+
result.set(view, offset);
|
| 18 |
+
offset += view.byteLength;
|
| 19 |
+
}
|
| 20 |
+
return result;
|
| 21 |
+
}
|
| 22 |
+
function concat(first, second, ...rest) {
|
| 23 |
+
let buffers;
|
| 24 |
+
let type;
|
| 25 |
+
if (typeof second === "function") {
|
| 26 |
+
buffers = Array.from(first);
|
| 27 |
+
type = second;
|
| 28 |
+
}
|
| 29 |
+
else if ((0, buffer_source_js_1.isBufferSource)(first)) {
|
| 30 |
+
buffers = [first, second, ...rest].filter(buffer_source_js_1.isBufferSource);
|
| 31 |
+
}
|
| 32 |
+
else {
|
| 33 |
+
buffers = Array.from(first);
|
| 34 |
+
if (second) {
|
| 35 |
+
buffers.push(second);
|
| 36 |
+
}
|
| 37 |
+
buffers.push(...rest);
|
| 38 |
+
}
|
| 39 |
+
const bytes = concatToUint8Array(buffers);
|
| 40 |
+
return type ? (0, buffer_source_js_1.toView)(bytes, type) : bytes.buffer;
|
| 41 |
+
}
|
node_modules/@peculiar/utils/build/cjs/bytes/equal.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.equal = equal;
|
| 4 |
+
const buffer_source_js_1 = require("./buffer-source.js");
|
| 5 |
+
function equal(a, b, options = {}) {
|
| 6 |
+
const left = (0, buffer_source_js_1.toUint8Array)(a);
|
| 7 |
+
const right = (0, buffer_source_js_1.toUint8Array)(b);
|
| 8 |
+
if (!options.constantTime && left.byteLength !== right.byteLength) {
|
| 9 |
+
return false;
|
| 10 |
+
}
|
| 11 |
+
const length = Math.max(left.byteLength, right.byteLength);
|
| 12 |
+
let diff = left.byteLength ^ right.byteLength;
|
| 13 |
+
for (let i = 0; i < length; i++) {
|
| 14 |
+
diff |= (left[i] ?? 0) ^ (right[i] ?? 0);
|
| 15 |
+
}
|
| 16 |
+
return diff === 0;
|
| 17 |
+
}
|
node_modules/@peculiar/utils/build/cjs/bytes/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.tail = exports.startsWith = exports.slice = exports.lastIndexOf = exports.indexOf = exports.includes = exports.endsWith = exports.copy = exports.compare = exports.equal = exports.concatToUint8Array = exports.concat = exports.toViewCopy = exports.toView = exports.toUint8ArrayCopy = exports.toUint8Array = exports.toArrayBufferLike = exports.toArrayBuffer = exports.isSharedArrayBuffer = exports.isBufferSource = exports.isArrayBufferView = exports.isArrayBufferLike = exports.isArrayBuffer = exports.assertBufferSource = void 0;
|
| 4 |
+
var buffer_source_js_1 = require("./buffer-source.js");
|
| 5 |
+
Object.defineProperty(exports, "assertBufferSource", { enumerable: true, get: function () { return buffer_source_js_1.assertBufferSource; } });
|
| 6 |
+
Object.defineProperty(exports, "isArrayBuffer", { enumerable: true, get: function () { return buffer_source_js_1.isArrayBuffer; } });
|
| 7 |
+
Object.defineProperty(exports, "isArrayBufferLike", { enumerable: true, get: function () { return buffer_source_js_1.isArrayBufferLike; } });
|
| 8 |
+
Object.defineProperty(exports, "isArrayBufferView", { enumerable: true, get: function () { return buffer_source_js_1.isArrayBufferView; } });
|
| 9 |
+
Object.defineProperty(exports, "isBufferSource", { enumerable: true, get: function () { return buffer_source_js_1.isBufferSource; } });
|
| 10 |
+
Object.defineProperty(exports, "isSharedArrayBuffer", { enumerable: true, get: function () { return buffer_source_js_1.isSharedArrayBuffer; } });
|
| 11 |
+
Object.defineProperty(exports, "toArrayBuffer", { enumerable: true, get: function () { return buffer_source_js_1.toArrayBuffer; } });
|
| 12 |
+
Object.defineProperty(exports, "toArrayBufferLike", { enumerable: true, get: function () { return buffer_source_js_1.toArrayBufferLike; } });
|
| 13 |
+
Object.defineProperty(exports, "toUint8Array", { enumerable: true, get: function () { return buffer_source_js_1.toUint8Array; } });
|
| 14 |
+
Object.defineProperty(exports, "toUint8ArrayCopy", { enumerable: true, get: function () { return buffer_source_js_1.toUint8ArrayCopy; } });
|
| 15 |
+
Object.defineProperty(exports, "toView", { enumerable: true, get: function () { return buffer_source_js_1.toView; } });
|
| 16 |
+
Object.defineProperty(exports, "toViewCopy", { enumerable: true, get: function () { return buffer_source_js_1.toViewCopy; } });
|
| 17 |
+
var concat_js_1 = require("./concat.js");
|
| 18 |
+
Object.defineProperty(exports, "concat", { enumerable: true, get: function () { return concat_js_1.concat; } });
|
| 19 |
+
Object.defineProperty(exports, "concatToUint8Array", { enumerable: true, get: function () { return concat_js_1.concatToUint8Array; } });
|
| 20 |
+
var equal_js_1 = require("./equal.js");
|
| 21 |
+
Object.defineProperty(exports, "equal", { enumerable: true, get: function () { return equal_js_1.equal; } });
|
| 22 |
+
var sequence_js_1 = require("./sequence.js");
|
| 23 |
+
Object.defineProperty(exports, "compare", { enumerable: true, get: function () { return sequence_js_1.compare; } });
|
| 24 |
+
Object.defineProperty(exports, "copy", { enumerable: true, get: function () { return sequence_js_1.copy; } });
|
| 25 |
+
Object.defineProperty(exports, "endsWith", { enumerable: true, get: function () { return sequence_js_1.endsWith; } });
|
| 26 |
+
Object.defineProperty(exports, "includes", { enumerable: true, get: function () { return sequence_js_1.includes; } });
|
| 27 |
+
Object.defineProperty(exports, "indexOf", { enumerable: true, get: function () { return sequence_js_1.indexOf; } });
|
| 28 |
+
Object.defineProperty(exports, "lastIndexOf", { enumerable: true, get: function () { return sequence_js_1.lastIndexOf; } });
|
| 29 |
+
Object.defineProperty(exports, "slice", { enumerable: true, get: function () { return sequence_js_1.slice; } });
|
| 30 |
+
Object.defineProperty(exports, "startsWith", { enumerable: true, get: function () { return sequence_js_1.startsWith; } });
|
| 31 |
+
Object.defineProperty(exports, "tail", { enumerable: true, get: function () { return sequence_js_1.tail; } });
|
node_modules/@peculiar/utils/build/cjs/bytes/sequence.js
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.indexOf = indexOf;
|
| 4 |
+
exports.lastIndexOf = lastIndexOf;
|
| 5 |
+
exports.includes = includes;
|
| 6 |
+
exports.startsWith = startsWith;
|
| 7 |
+
exports.endsWith = endsWith;
|
| 8 |
+
exports.slice = slice;
|
| 9 |
+
exports.tail = tail;
|
| 10 |
+
exports.copy = copy;
|
| 11 |
+
exports.compare = compare;
|
| 12 |
+
const buffer_source_js_1 = require("./buffer-source.js");
|
| 13 |
+
function clampIndex(value, fallback, length) {
|
| 14 |
+
const normalized = Number.isFinite(value) ? Math.trunc(value) : fallback;
|
| 15 |
+
if (normalized <= 0) {
|
| 16 |
+
return 0;
|
| 17 |
+
}
|
| 18 |
+
if (normalized >= length) {
|
| 19 |
+
return length;
|
| 20 |
+
}
|
| 21 |
+
return normalized;
|
| 22 |
+
}
|
| 23 |
+
function normalizeForwardRange(length, options) {
|
| 24 |
+
const start = clampIndex(options?.start, 0, length);
|
| 25 |
+
const end = clampIndex(options?.end, length, length);
|
| 26 |
+
return end >= start ? [start, end] : [start, start];
|
| 27 |
+
}
|
| 28 |
+
function normalizeReverseRange(length, options) {
|
| 29 |
+
const start = clampIndex(options?.start, length, length);
|
| 30 |
+
const end = clampIndex(options?.end, 0, length);
|
| 31 |
+
return start >= end ? [end, start] : [start, start];
|
| 32 |
+
}
|
| 33 |
+
function normalizeSliceIndex(value, fallback, length) {
|
| 34 |
+
const normalized = Number.isFinite(value) ? Math.trunc(value) : fallback;
|
| 35 |
+
if (normalized < 0) {
|
| 36 |
+
return Math.max(length + normalized, 0);
|
| 37 |
+
}
|
| 38 |
+
if (normalized > length) {
|
| 39 |
+
return length;
|
| 40 |
+
}
|
| 41 |
+
return normalized;
|
| 42 |
+
}
|
| 43 |
+
function encodeAscii(text) {
|
| 44 |
+
const bytes = new Uint8Array(text.length);
|
| 45 |
+
for (let i = 0; i < text.length; i++) {
|
| 46 |
+
bytes[i] = text.charCodeAt(i) & 0xff;
|
| 47 |
+
}
|
| 48 |
+
return bytes;
|
| 49 |
+
}
|
| 50 |
+
function encodeUtf8(text) {
|
| 51 |
+
return new TextEncoder().encode(text);
|
| 52 |
+
}
|
| 53 |
+
function toPatternBytes(pattern, options) {
|
| 54 |
+
if (typeof pattern === "string") {
|
| 55 |
+
return options?.encoding === "utf8" ? encodeUtf8(pattern) : encodeAscii(pattern);
|
| 56 |
+
}
|
| 57 |
+
return (0, buffer_source_js_1.toUint8Array)(pattern);
|
| 58 |
+
}
|
| 59 |
+
function bytesEqualAt(data, pattern, offset) {
|
| 60 |
+
for (let index = 0; index < pattern.byteLength; index++) {
|
| 61 |
+
if (data[offset + index] !== pattern[index]) {
|
| 62 |
+
return false;
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
return true;
|
| 66 |
+
}
|
| 67 |
+
function indexOf(data, pattern, options) {
|
| 68 |
+
const bytes = (0, buffer_source_js_1.toUint8Array)(data);
|
| 69 |
+
const needle = toPatternBytes(pattern, options);
|
| 70 |
+
const [start, end] = normalizeForwardRange(bytes.byteLength, options);
|
| 71 |
+
if (needle.byteLength === 0) {
|
| 72 |
+
return start;
|
| 73 |
+
}
|
| 74 |
+
const lastOffset = end - needle.byteLength;
|
| 75 |
+
if (lastOffset < start) {
|
| 76 |
+
return -1;
|
| 77 |
+
}
|
| 78 |
+
for (let offset = start; offset <= lastOffset; offset++) {
|
| 79 |
+
if (bytesEqualAt(bytes, needle, offset)) {
|
| 80 |
+
return offset;
|
| 81 |
+
}
|
| 82 |
+
}
|
| 83 |
+
return -1;
|
| 84 |
+
}
|
| 85 |
+
function lastIndexOf(data, pattern, options) {
|
| 86 |
+
const bytes = (0, buffer_source_js_1.toUint8Array)(data);
|
| 87 |
+
const needle = toPatternBytes(pattern, options);
|
| 88 |
+
const [end, start] = normalizeReverseRange(bytes.byteLength, options);
|
| 89 |
+
if (needle.byteLength === 0) {
|
| 90 |
+
return start;
|
| 91 |
+
}
|
| 92 |
+
const firstOffset = start - needle.byteLength;
|
| 93 |
+
if (firstOffset < end) {
|
| 94 |
+
return -1;
|
| 95 |
+
}
|
| 96 |
+
for (let offset = firstOffset; offset >= end; offset--) {
|
| 97 |
+
if (bytesEqualAt(bytes, needle, offset)) {
|
| 98 |
+
return offset;
|
| 99 |
+
}
|
| 100 |
+
}
|
| 101 |
+
return -1;
|
| 102 |
+
}
|
| 103 |
+
function includes(data, pattern, options) {
|
| 104 |
+
return indexOf(data, pattern, options) !== -1;
|
| 105 |
+
}
|
| 106 |
+
function startsWith(data, pattern, options) {
|
| 107 |
+
const bytes = (0, buffer_source_js_1.toUint8Array)(data);
|
| 108 |
+
const needle = toPatternBytes(pattern, options);
|
| 109 |
+
if (needle.byteLength > bytes.byteLength) {
|
| 110 |
+
return false;
|
| 111 |
+
}
|
| 112 |
+
return bytesEqualAt(bytes, needle, 0);
|
| 113 |
+
}
|
| 114 |
+
function endsWith(data, pattern, options) {
|
| 115 |
+
const bytes = (0, buffer_source_js_1.toUint8Array)(data);
|
| 116 |
+
const needle = toPatternBytes(pattern, options);
|
| 117 |
+
if (needle.byteLength > bytes.byteLength) {
|
| 118 |
+
return false;
|
| 119 |
+
}
|
| 120 |
+
return bytesEqualAt(bytes, needle, bytes.byteLength - needle.byteLength);
|
| 121 |
+
}
|
| 122 |
+
function slice(data, start, end) {
|
| 123 |
+
const bytes = (0, buffer_source_js_1.toUint8Array)(data);
|
| 124 |
+
const normalizedStart = normalizeSliceIndex(start, 0, bytes.byteLength);
|
| 125 |
+
const normalizedEnd = normalizeSliceIndex(end, bytes.byteLength, bytes.byteLength);
|
| 126 |
+
if (normalizedEnd <= normalizedStart) {
|
| 127 |
+
return bytes.subarray(normalizedStart, normalizedStart);
|
| 128 |
+
}
|
| 129 |
+
return bytes.subarray(normalizedStart, normalizedEnd);
|
| 130 |
+
}
|
| 131 |
+
function tail(data, length) {
|
| 132 |
+
const bytes = (0, buffer_source_js_1.toUint8Array)(data);
|
| 133 |
+
const normalizedLength = Number.isFinite(length) ? Math.max(0, Math.trunc(length)) : 0;
|
| 134 |
+
if (normalizedLength >= bytes.byteLength) {
|
| 135 |
+
return bytes;
|
| 136 |
+
}
|
| 137 |
+
return bytes.subarray(bytes.byteLength - normalizedLength);
|
| 138 |
+
}
|
| 139 |
+
function copy(data) {
|
| 140 |
+
return (0, buffer_source_js_1.toUint8ArrayCopy)(data);
|
| 141 |
+
}
|
| 142 |
+
function compare(a, b) {
|
| 143 |
+
const left = (0, buffer_source_js_1.toUint8Array)(a);
|
| 144 |
+
const right = (0, buffer_source_js_1.toUint8Array)(b);
|
| 145 |
+
const limit = Math.min(left.byteLength, right.byteLength);
|
| 146 |
+
for (let index = 0; index < limit; index++) {
|
| 147 |
+
if (left[index] < right[index]) {
|
| 148 |
+
return -1;
|
| 149 |
+
}
|
| 150 |
+
if (left[index] > right[index]) {
|
| 151 |
+
return 1;
|
| 152 |
+
}
|
| 153 |
+
}
|
| 154 |
+
if (left.byteLength < right.byteLength) {
|
| 155 |
+
return -1;
|
| 156 |
+
}
|
| 157 |
+
if (left.byteLength > right.byteLength) {
|
| 158 |
+
return 1;
|
| 159 |
+
}
|
| 160 |
+
return 0;
|
| 161 |
+
}
|
node_modules/@peculiar/utils/build/cjs/bytes/types.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
node_modules/@peculiar/utils/build/cjs/converters/convert.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.convert = void 0;
|
| 4 |
+
const index_js_1 = require("../bytes/index.js");
|
| 5 |
+
const index_js_2 = require("../encoding/index.js");
|
| 6 |
+
const defaults_js_1 = require("./defaults.js");
|
| 7 |
+
function encode(name, data, ...args) {
|
| 8 |
+
return defaults_js_1.defaultConverterRegistry.encode(name, data, ...args);
|
| 9 |
+
}
|
| 10 |
+
function decode(name, text, ...args) {
|
| 11 |
+
return defaults_js_1.defaultConverterRegistry.decode(name, text, ...args);
|
| 12 |
+
}
|
| 13 |
+
function tryDecode(name, text, ...args) {
|
| 14 |
+
return defaults_js_1.defaultConverterRegistry.tryDecode(name, text, ...args);
|
| 15 |
+
}
|
| 16 |
+
function normalize(name, text, ...args) {
|
| 17 |
+
return defaults_js_1.defaultConverterRegistry.normalize(name, text, ...args);
|
| 18 |
+
}
|
| 19 |
+
function parse(name, text, ...args) {
|
| 20 |
+
return defaults_js_1.defaultConverterRegistry.parse(name, text, ...args);
|
| 21 |
+
}
|
| 22 |
+
function format(name, data, value) {
|
| 23 |
+
return defaults_js_1.defaultConverterRegistry.format(name, data, value);
|
| 24 |
+
}
|
| 25 |
+
function transcode(text, options) {
|
| 26 |
+
return defaults_js_1.defaultConverterRegistry.transcode(text, options);
|
| 27 |
+
}
|
| 28 |
+
function detect(text, options) {
|
| 29 |
+
return defaults_js_1.defaultConverterRegistry.detect(text, options);
|
| 30 |
+
}
|
| 31 |
+
function normalizeEncodingName(encoding) {
|
| 32 |
+
return encoding.toLowerCase();
|
| 33 |
+
}
|
| 34 |
+
exports.convert = {
|
| 35 |
+
encode,
|
| 36 |
+
decode,
|
| 37 |
+
tryDecode,
|
| 38 |
+
normalize,
|
| 39 |
+
parse,
|
| 40 |
+
format,
|
| 41 |
+
transcode,
|
| 42 |
+
detect,
|
| 43 |
+
to(format, data, ...args) {
|
| 44 |
+
return encode(format, data, ...args);
|
| 45 |
+
},
|
| 46 |
+
from(format, text, ...args) {
|
| 47 |
+
return decode(format, text, ...args);
|
| 48 |
+
},
|
| 49 |
+
toString(data, encoding = "utf8") {
|
| 50 |
+
return encode(encoding, data);
|
| 51 |
+
},
|
| 52 |
+
fromString(text, encoding = "utf8") {
|
| 53 |
+
if (normalizeEncodingName(encoding) === "hex") {
|
| 54 |
+
return (0, index_js_1.toArrayBuffer)(index_js_2.hex.decode(text, { allowOddLength: true }));
|
| 55 |
+
}
|
| 56 |
+
return (0, index_js_1.toArrayBuffer)(decode(encoding, text));
|
| 57 |
+
},
|
| 58 |
+
toBase64: index_js_2.base64.encode,
|
| 59 |
+
fromBase64: (text) => (0, index_js_1.toArrayBuffer)(index_js_2.base64.decode(text)),
|
| 60 |
+
toBase64Url: index_js_2.base64url.encode,
|
| 61 |
+
fromBase64Url: (text) => (0, index_js_1.toArrayBuffer)(index_js_2.base64url.decode(text)),
|
| 62 |
+
toHex: index_js_2.hex.encode,
|
| 63 |
+
fromHex: (text) => (0, index_js_1.toArrayBuffer)(index_js_2.hex.decode(text, { allowOddLength: true })),
|
| 64 |
+
toBinary: index_js_2.binary.encode,
|
| 65 |
+
fromBinary: (text) => (0, index_js_1.toArrayBuffer)(index_js_2.binary.decode(text)),
|
| 66 |
+
toUtf8String: index_js_2.utf8.decode,
|
| 67 |
+
fromUtf8String: (text) => (0, index_js_1.toArrayBuffer)(index_js_2.utf8.encode(text)),
|
| 68 |
+
toUtf16String: (data, littleEndian = false) => index_js_2.utf16.decode(data, { littleEndian }),
|
| 69 |
+
fromUtf16String: (text, littleEndian = false) => (0, index_js_1.toArrayBuffer)(index_js_2.utf16.encode(text, { littleEndian })),
|
| 70 |
+
isHex: index_js_2.hex.is,
|
| 71 |
+
isBase64: index_js_2.base64.is,
|
| 72 |
+
isBase64Url: index_js_2.base64url.is,
|
| 73 |
+
formatString: index_js_2.base64.normalize,
|
| 74 |
+
};
|
node_modules/@peculiar/utils/build/cjs/converters/defaults.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.defaultConverterRegistry = exports.defaultConverters = exports.utf16leConverter = exports.utf16beConverter = exports.utf8Converter = exports.base64urlConverter = exports.base64Converter = exports.hexConverter = exports.binaryConverter = exports.pemConverter = void 0;
|
| 4 |
+
const index_js_1 = require("../encoding/index.js");
|
| 5 |
+
const index_js_2 = require("../pem/index.js");
|
| 6 |
+
var index_js_3 = require("../pem/index.js");
|
| 7 |
+
Object.defineProperty(exports, "pemConverter", { enumerable: true, get: function () { return index_js_3.pemConverter; } });
|
| 8 |
+
const registry_js_1 = require("./registry.js");
|
| 9 |
+
exports.binaryConverter = {
|
| 10 |
+
name: "binary",
|
| 11 |
+
aliases: ["latin1"],
|
| 12 |
+
encode: index_js_1.binary.encode,
|
| 13 |
+
decode: index_js_1.binary.decode,
|
| 14 |
+
is: index_js_1.binary.is,
|
| 15 |
+
};
|
| 16 |
+
exports.hexConverter = {
|
| 17 |
+
name: "hex",
|
| 18 |
+
encode: index_js_1.hex.encode,
|
| 19 |
+
decode: index_js_1.hex.decode,
|
| 20 |
+
format: index_js_1.hex.format,
|
| 21 |
+
is: index_js_1.hex.is,
|
| 22 |
+
normalize: index_js_1.hex.normalize,
|
| 23 |
+
parse: index_js_1.hex.parse,
|
| 24 |
+
};
|
| 25 |
+
exports.base64Converter = {
|
| 26 |
+
name: "base64",
|
| 27 |
+
aliases: ["b64"],
|
| 28 |
+
encode: index_js_1.base64.encode,
|
| 29 |
+
decode: index_js_1.base64.decode,
|
| 30 |
+
is: index_js_1.base64.is,
|
| 31 |
+
normalize: index_js_1.base64.normalize,
|
| 32 |
+
};
|
| 33 |
+
exports.base64urlConverter = {
|
| 34 |
+
name: "base64url",
|
| 35 |
+
aliases: ["base64-url", "b64url"],
|
| 36 |
+
encode: index_js_1.base64url.encode,
|
| 37 |
+
decode: index_js_1.base64url.decode,
|
| 38 |
+
is: index_js_1.base64url.is,
|
| 39 |
+
normalize: index_js_1.base64url.normalize,
|
| 40 |
+
};
|
| 41 |
+
exports.utf8Converter = {
|
| 42 |
+
name: "utf8",
|
| 43 |
+
aliases: ["utf-8"],
|
| 44 |
+
encode: (data) => index_js_1.utf8.decode(data),
|
| 45 |
+
decode: (text) => index_js_1.utf8.encode(text),
|
| 46 |
+
is: (text) => typeof text === "string",
|
| 47 |
+
};
|
| 48 |
+
exports.utf16beConverter = {
|
| 49 |
+
name: "utf16be",
|
| 50 |
+
aliases: ["utf16", "utf-16", "utf-16be"],
|
| 51 |
+
encode: (data) => index_js_1.utf16.decode(data),
|
| 52 |
+
decode: (text) => index_js_1.utf16.encode(text),
|
| 53 |
+
is: (text) => typeof text === "string",
|
| 54 |
+
};
|
| 55 |
+
exports.utf16leConverter = {
|
| 56 |
+
name: "utf16le",
|
| 57 |
+
aliases: ["utf-16le", "ucs2", "usc2"],
|
| 58 |
+
encode: (data) => index_js_1.utf16.decode(data, { littleEndian: true }),
|
| 59 |
+
decode: (text) => index_js_1.utf16.encode(text, { littleEndian: true }),
|
| 60 |
+
is: (text) => typeof text === "string",
|
| 61 |
+
};
|
| 62 |
+
exports.defaultConverters = [
|
| 63 |
+
exports.binaryConverter,
|
| 64 |
+
exports.hexConverter,
|
| 65 |
+
exports.base64Converter,
|
| 66 |
+
exports.base64urlConverter,
|
| 67 |
+
exports.utf8Converter,
|
| 68 |
+
exports.utf16beConverter,
|
| 69 |
+
exports.utf16leConverter,
|
| 70 |
+
index_js_2.pemConverter,
|
| 71 |
+
];
|
| 72 |
+
exports.defaultConverterRegistry = (0, registry_js_1.createConverterRegistry)(exports.defaultConverters);
|
node_modules/@peculiar/utils/build/cjs/converters/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.convert = exports.utf8Converter = exports.utf16leConverter = exports.utf16beConverter = exports.pemConverter = exports.hexConverter = exports.defaultConverters = exports.defaultConverterRegistry = exports.binaryConverter = exports.base64urlConverter = exports.base64Converter = exports.createConverterRegistry = void 0;
|
| 4 |
+
var registry_js_1 = require("./registry.js");
|
| 5 |
+
Object.defineProperty(exports, "createConverterRegistry", { enumerable: true, get: function () { return registry_js_1.createConverterRegistry; } });
|
| 6 |
+
var defaults_js_1 = require("./defaults.js");
|
| 7 |
+
Object.defineProperty(exports, "base64Converter", { enumerable: true, get: function () { return defaults_js_1.base64Converter; } });
|
| 8 |
+
Object.defineProperty(exports, "base64urlConverter", { enumerable: true, get: function () { return defaults_js_1.base64urlConverter; } });
|
| 9 |
+
Object.defineProperty(exports, "binaryConverter", { enumerable: true, get: function () { return defaults_js_1.binaryConverter; } });
|
| 10 |
+
Object.defineProperty(exports, "defaultConverterRegistry", { enumerable: true, get: function () { return defaults_js_1.defaultConverterRegistry; } });
|
| 11 |
+
Object.defineProperty(exports, "defaultConverters", { enumerable: true, get: function () { return defaults_js_1.defaultConverters; } });
|
| 12 |
+
Object.defineProperty(exports, "hexConverter", { enumerable: true, get: function () { return defaults_js_1.hexConverter; } });
|
| 13 |
+
Object.defineProperty(exports, "pemConverter", { enumerable: true, get: function () { return defaults_js_1.pemConverter; } });
|
| 14 |
+
Object.defineProperty(exports, "utf16beConverter", { enumerable: true, get: function () { return defaults_js_1.utf16beConverter; } });
|
| 15 |
+
Object.defineProperty(exports, "utf16leConverter", { enumerable: true, get: function () { return defaults_js_1.utf16leConverter; } });
|
| 16 |
+
Object.defineProperty(exports, "utf8Converter", { enumerable: true, get: function () { return defaults_js_1.utf8Converter; } });
|
| 17 |
+
var convert_js_1 = require("./convert.js");
|
| 18 |
+
Object.defineProperty(exports, "convert", { enumerable: true, get: function () { return convert_js_1.convert; } });
|
node_modules/@peculiar/utils/build/cjs/converters/registry.js
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.createConverterRegistry = createConverterRegistry;
|
| 4 |
+
function keyOf(name) {
|
| 5 |
+
return name.trim().toLowerCase();
|
| 6 |
+
}
|
| 7 |
+
function toError(error) {
|
| 8 |
+
return error instanceof Error ? error : new Error(String(error));
|
| 9 |
+
}
|
| 10 |
+
function removeConverter(converters, primaryNames, converter) {
|
| 11 |
+
for (const alias of [converter.name, ...(converter.aliases ?? [])]) {
|
| 12 |
+
converters.delete(keyOf(alias));
|
| 13 |
+
}
|
| 14 |
+
primaryNames.delete(keyOf(converter.name));
|
| 15 |
+
}
|
| 16 |
+
function requireCapability(converter, name, capability) {
|
| 17 |
+
const method = converter[capability];
|
| 18 |
+
if (typeof method !== "function") {
|
| 19 |
+
throw new Error(`Converter '${name}' does not support ${capability}()`);
|
| 20 |
+
}
|
| 21 |
+
return method;
|
| 22 |
+
}
|
| 23 |
+
function detectConfidence(name, text, converter) {
|
| 24 |
+
const normalizedName = keyOf(converter.name || name);
|
| 25 |
+
const trimmed = text.trim();
|
| 26 |
+
if (!trimmed) {
|
| 27 |
+
return 0;
|
| 28 |
+
}
|
| 29 |
+
let accepted = false;
|
| 30 |
+
if (converter.is) {
|
| 31 |
+
accepted = converter.is(text);
|
| 32 |
+
}
|
| 33 |
+
let decodable = false;
|
| 34 |
+
try {
|
| 35 |
+
converter.decode(text);
|
| 36 |
+
decodable = true;
|
| 37 |
+
}
|
| 38 |
+
catch {
|
| 39 |
+
decodable = false;
|
| 40 |
+
}
|
| 41 |
+
if (!accepted && !decodable) {
|
| 42 |
+
return 0;
|
| 43 |
+
}
|
| 44 |
+
switch (normalizedName) {
|
| 45 |
+
case "pem":
|
| 46 |
+
return /-----BEGIN [^-]+-----/.test(text) ? 1 : 0;
|
| 47 |
+
case "hex": {
|
| 48 |
+
const compact = trimmed.replace(/^0x/i, "").replace(/[\s:.-]/g, "");
|
| 49 |
+
if (!compact || /[^0-9a-f]/i.test(compact) || compact.length % 2 !== 0) {
|
| 50 |
+
return 0;
|
| 51 |
+
}
|
| 52 |
+
if (/^0x/i.test(trimmed) || /[:\s.-]/.test(trimmed)) {
|
| 53 |
+
return 0.95;
|
| 54 |
+
}
|
| 55 |
+
if (/[a-f]/.test(trimmed) || /[A-F]/.test(trimmed)) {
|
| 56 |
+
return 0.8;
|
| 57 |
+
}
|
| 58 |
+
return 0.45;
|
| 59 |
+
}
|
| 60 |
+
case "base64url":
|
| 61 |
+
if (/[-_]/.test(trimmed)) {
|
| 62 |
+
return 0.95;
|
| 63 |
+
}
|
| 64 |
+
if (/=/.test(trimmed)) {
|
| 65 |
+
return 0.1;
|
| 66 |
+
}
|
| 67 |
+
return 0.6;
|
| 68 |
+
case "base64":
|
| 69 |
+
if (/[+/=]/.test(trimmed)) {
|
| 70 |
+
return 0.9;
|
| 71 |
+
}
|
| 72 |
+
return 0.55;
|
| 73 |
+
case "binary":
|
| 74 |
+
case "utf8":
|
| 75 |
+
case "utf16be":
|
| 76 |
+
case "utf16le":
|
| 77 |
+
return 0;
|
| 78 |
+
default:
|
| 79 |
+
return accepted && decodable ? 0.75 : 0.5;
|
| 80 |
+
}
|
| 81 |
+
}
|
| 82 |
+
function createConverterRegistry(initialConverters = []) {
|
| 83 |
+
const converters = new Map();
|
| 84 |
+
const primaryNames = new Set();
|
| 85 |
+
const api = {
|
| 86 |
+
register(converter, options = {}) {
|
| 87 |
+
if (!converter.name || !keyOf(converter.name)) {
|
| 88 |
+
throw new TypeError("Converter name is required");
|
| 89 |
+
}
|
| 90 |
+
const names = [...new Set([converter.name, ...(converter.aliases ?? [])].map(keyOf))];
|
| 91 |
+
const conflicts = new Set();
|
| 92 |
+
for (const name of names) {
|
| 93 |
+
const existing = converters.get(name);
|
| 94 |
+
if (!existing) {
|
| 95 |
+
continue;
|
| 96 |
+
}
|
| 97 |
+
if (!options.override) {
|
| 98 |
+
throw new Error(`Converter '${name}' is already registered`);
|
| 99 |
+
}
|
| 100 |
+
conflicts.add(existing);
|
| 101 |
+
}
|
| 102 |
+
for (const conflicting of conflicts) {
|
| 103 |
+
removeConverter(converters, primaryNames, conflicting);
|
| 104 |
+
}
|
| 105 |
+
for (const name of names) {
|
| 106 |
+
converters.set(name, converter);
|
| 107 |
+
}
|
| 108 |
+
primaryNames.add(keyOf(converter.name));
|
| 109 |
+
return this;
|
| 110 |
+
},
|
| 111 |
+
unregister(name) {
|
| 112 |
+
const converter = converters.get(keyOf(name));
|
| 113 |
+
if (!converter) {
|
| 114 |
+
return false;
|
| 115 |
+
}
|
| 116 |
+
removeConverter(converters, primaryNames, converter);
|
| 117 |
+
return true;
|
| 118 |
+
},
|
| 119 |
+
has(name) {
|
| 120 |
+
return converters.has(keyOf(name));
|
| 121 |
+
},
|
| 122 |
+
get(name) {
|
| 123 |
+
const converter = converters.get(keyOf(name));
|
| 124 |
+
if (!converter) {
|
| 125 |
+
throw new Error(`Converter '${name}' is not registered`);
|
| 126 |
+
}
|
| 127 |
+
return converter;
|
| 128 |
+
},
|
| 129 |
+
list() {
|
| 130 |
+
return [...primaryNames].map((name) => this.get(name));
|
| 131 |
+
},
|
| 132 |
+
encode(name, data, options) {
|
| 133 |
+
return this.get(name).encode(data, options);
|
| 134 |
+
},
|
| 135 |
+
decode(name, text, options) {
|
| 136 |
+
return this.get(name).decode(text, options);
|
| 137 |
+
},
|
| 138 |
+
tryDecode(name, text, options) {
|
| 139 |
+
try {
|
| 140 |
+
return { ok: true, bytes: this.decode(name, text, options) };
|
| 141 |
+
}
|
| 142 |
+
catch (error) {
|
| 143 |
+
return { ok: false, error: toError(error) };
|
| 144 |
+
}
|
| 145 |
+
},
|
| 146 |
+
normalize(name, text, options) {
|
| 147 |
+
const converter = this.get(name);
|
| 148 |
+
return requireCapability(converter, name, "normalize").call(converter, text, options);
|
| 149 |
+
},
|
| 150 |
+
parse(name, text, options) {
|
| 151 |
+
const converter = this.get(name);
|
| 152 |
+
return requireCapability(converter, name, "parse").call(converter, text, options);
|
| 153 |
+
},
|
| 154 |
+
format(name, data, format) {
|
| 155 |
+
const converter = this.get(name);
|
| 156 |
+
return requireCapability(converter, name, "format").call(converter, data, format);
|
| 157 |
+
},
|
| 158 |
+
transcode(text, options) {
|
| 159 |
+
const bytes = this.decode(options.from, text, options.fromOptions);
|
| 160 |
+
return this.encode(options.to, bytes, options.toOptions);
|
| 161 |
+
},
|
| 162 |
+
detect(text, options = {}) {
|
| 163 |
+
const formatNames = options.formats?.length
|
| 164 |
+
? options.formats.map((name) => String(name))
|
| 165 |
+
: this.list()
|
| 166 |
+
.map((converter) => converter.name)
|
| 167 |
+
.filter((name) => !["binary", "utf8", "utf16be", "utf16le"].includes(keyOf(name)));
|
| 168 |
+
const detections = new Map();
|
| 169 |
+
for (const requestedName of formatNames) {
|
| 170 |
+
const converter = this.get(requestedName);
|
| 171 |
+
const confidence = detectConfidence(requestedName, text, converter);
|
| 172 |
+
if (confidence <= 0) {
|
| 173 |
+
continue;
|
| 174 |
+
}
|
| 175 |
+
const format = converter.name;
|
| 176 |
+
const current = detections.get(format);
|
| 177 |
+
if (!current || confidence > current.confidence) {
|
| 178 |
+
detections.set(format, { format, confidence });
|
| 179 |
+
}
|
| 180 |
+
}
|
| 181 |
+
return [...detections.values()].sort((left, right) => right.confidence - left.confidence);
|
| 182 |
+
},
|
| 183 |
+
};
|
| 184 |
+
for (const converter of initialConverters) {
|
| 185 |
+
api.register(converter);
|
| 186 |
+
}
|
| 187 |
+
return api;
|
| 188 |
+
}
|
node_modules/@peculiar/utils/build/cjs/converters/types.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
node_modules/@peculiar/utils/build/cjs/encoding/base64.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.base64 = void 0;
|
| 4 |
+
exports.normalize = normalize;
|
| 5 |
+
exports.pad = pad;
|
| 6 |
+
exports.is = is;
|
| 7 |
+
exports.encode = encode;
|
| 8 |
+
exports.decode = decode;
|
| 9 |
+
const index_js_1 = require("../bytes/index.js");
|
| 10 |
+
const binary_js_1 = require("./binary.js");
|
| 11 |
+
const BASE64_REGEX = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
|
| 12 |
+
function nodeBuffer() {
|
| 13 |
+
return globalThis.Buffer;
|
| 14 |
+
}
|
| 15 |
+
function normalize(text) {
|
| 16 |
+
return text.replace(/[\n\r\t ]/g, "");
|
| 17 |
+
}
|
| 18 |
+
function pad(text) {
|
| 19 |
+
const remainder = text.length % 4;
|
| 20 |
+
return remainder ? text + "=".repeat(4 - remainder) : text;
|
| 21 |
+
}
|
| 22 |
+
function is(text) {
|
| 23 |
+
if (typeof text !== "string") {
|
| 24 |
+
return false;
|
| 25 |
+
}
|
| 26 |
+
const normalized = normalize(text);
|
| 27 |
+
return normalized === "" || BASE64_REGEX.test(normalized);
|
| 28 |
+
}
|
| 29 |
+
function encode(data, _options) {
|
| 30 |
+
const bytes = (0, index_js_1.toUint8Array)(data);
|
| 31 |
+
const buffer = nodeBuffer();
|
| 32 |
+
if (buffer) {
|
| 33 |
+
return buffer.from(bytes).toString("base64");
|
| 34 |
+
}
|
| 35 |
+
return btoa((0, binary_js_1.encode)(bytes));
|
| 36 |
+
}
|
| 37 |
+
function decode(text, _options) {
|
| 38 |
+
const normalized = normalize(text);
|
| 39 |
+
if (!is(normalized)) {
|
| 40 |
+
throw new TypeError("Input is not valid Base64 text");
|
| 41 |
+
}
|
| 42 |
+
const buffer = nodeBuffer();
|
| 43 |
+
if (buffer) {
|
| 44 |
+
return new Uint8Array(buffer.from(normalized, "base64"));
|
| 45 |
+
}
|
| 46 |
+
return (0, binary_js_1.decode)(atob(normalized));
|
| 47 |
+
}
|
| 48 |
+
exports.base64 = { encode, decode, is, normalize, pad };
|
node_modules/@peculiar/utils/build/cjs/encoding/base64url.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.base64url = void 0;
|
| 4 |
+
exports.normalize = normalize;
|
| 5 |
+
exports.is = is;
|
| 6 |
+
exports.encode = encode;
|
| 7 |
+
exports.decode = decode;
|
| 8 |
+
const base64_js_1 = require("./base64.js");
|
| 9 |
+
const BASE64URL_REGEX = /^[A-Za-z0-9_-]*$/;
|
| 10 |
+
function normalize(text) {
|
| 11 |
+
return text.replace(/[\n\r\t ]/g, "");
|
| 12 |
+
}
|
| 13 |
+
function is(text) {
|
| 14 |
+
return typeof text === "string" && BASE64URL_REGEX.test(normalize(text));
|
| 15 |
+
}
|
| 16 |
+
function encode(data, _options) {
|
| 17 |
+
return base64_js_1.base64.encode(data).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
|
| 18 |
+
}
|
| 19 |
+
function decode(text, _options) {
|
| 20 |
+
const normalized = normalize(text);
|
| 21 |
+
if (!is(normalized)) {
|
| 22 |
+
throw new TypeError("Input is not valid Base64Url text");
|
| 23 |
+
}
|
| 24 |
+
return base64_js_1.base64.decode(base64_js_1.base64.pad(normalized.replace(/-/g, "+").replace(/_/g, "/")));
|
| 25 |
+
}
|
| 26 |
+
exports.base64url = { encode, decode, is, normalize };
|
node_modules/@peculiar/utils/build/cjs/encoding/binary.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.binary = void 0;
|
| 4 |
+
exports.encode = encode;
|
| 5 |
+
exports.decode = decode;
|
| 6 |
+
exports.is = is;
|
| 7 |
+
const index_js_1 = require("../bytes/index.js");
|
| 8 |
+
function encode(data) {
|
| 9 |
+
const bytes = (0, index_js_1.toUint8Array)(data);
|
| 10 |
+
let result = "";
|
| 11 |
+
for (const byte of bytes) {
|
| 12 |
+
result += String.fromCharCode(byte);
|
| 13 |
+
}
|
| 14 |
+
return result;
|
| 15 |
+
}
|
| 16 |
+
function decode(text) {
|
| 17 |
+
const result = new Uint8Array(text.length);
|
| 18 |
+
for (let i = 0; i < text.length; i++) {
|
| 19 |
+
result[i] = text.charCodeAt(i) & 0xff;
|
| 20 |
+
}
|
| 21 |
+
return result;
|
| 22 |
+
}
|
| 23 |
+
function is(text) {
|
| 24 |
+
return typeof text === "string";
|
| 25 |
+
}
|
| 26 |
+
exports.binary = { encode, decode, is };
|
node_modules/@peculiar/utils/build/cjs/encoding/hex.js
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.hex = exports.formats = void 0;
|
| 4 |
+
exports.normalize = normalize;
|
| 5 |
+
exports.is = is;
|
| 6 |
+
exports.encode = encode;
|
| 7 |
+
exports.decode = decode;
|
| 8 |
+
exports.parse = parse;
|
| 9 |
+
exports.format = format;
|
| 10 |
+
const index_js_1 = require("../bytes/index.js");
|
| 11 |
+
const HEX_CHARACTER_REGEX = /^[0-9a-f]$/i;
|
| 12 |
+
const COMMON_SEPARATORS = [" ", "\t", "\n", "\r", ":", "-", "."];
|
| 13 |
+
function resolveSeparators(options) {
|
| 14 |
+
if (options.separators === "none") {
|
| 15 |
+
return [];
|
| 16 |
+
}
|
| 17 |
+
if (!options.separators || options.separators === "common") {
|
| 18 |
+
return COMMON_SEPARATORS;
|
| 19 |
+
}
|
| 20 |
+
return options.separators;
|
| 21 |
+
}
|
| 22 |
+
function validateSeparator(separator) {
|
| 23 |
+
if (!separator) {
|
| 24 |
+
throw new TypeError("Hex separators must be non-empty strings");
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
+
function matchSeparator(text, index, separators) {
|
| 28 |
+
for (const separator of separators) {
|
| 29 |
+
if (text.startsWith(separator, index)) {
|
| 30 |
+
return separator;
|
| 31 |
+
}
|
| 32 |
+
}
|
| 33 |
+
return undefined;
|
| 34 |
+
}
|
| 35 |
+
function detectCase(text) {
|
| 36 |
+
const hasUpper = /[A-F]/.test(text);
|
| 37 |
+
const hasLower = /[a-f]/.test(text);
|
| 38 |
+
return hasUpper && !hasLower ? "upper" : "lower";
|
| 39 |
+
}
|
| 40 |
+
function detectLineSeparator(text) {
|
| 41 |
+
const match = /\r\n|\n/.exec(text);
|
| 42 |
+
if (!match) {
|
| 43 |
+
return undefined;
|
| 44 |
+
}
|
| 45 |
+
return match[0] === "\r\n" ? "\r\n" : "\n";
|
| 46 |
+
}
|
| 47 |
+
function compactForDetection(text) {
|
| 48 |
+
return text.replace(/[^0-9a-f]/gi, "");
|
| 49 |
+
}
|
| 50 |
+
function detectGroup(text) {
|
| 51 |
+
const segments = text.match(/[0-9A-Fa-f]+|[^0-9A-Fa-f]+/g) ?? [];
|
| 52 |
+
if (segments.length < 3) {
|
| 53 |
+
return undefined;
|
| 54 |
+
}
|
| 55 |
+
const hexSegments = segments.filter((_, index) => index % 2 === 0);
|
| 56 |
+
const separators = segments.filter((_, index) => index % 2 === 1);
|
| 57 |
+
const separator = separators[0];
|
| 58 |
+
if (!separator || separators.some((item) => item !== separator)) {
|
| 59 |
+
return undefined;
|
| 60 |
+
}
|
| 61 |
+
if (hexSegments.some((segment) => segment.length === 0 || segment.length % 2 !== 0)) {
|
| 62 |
+
return undefined;
|
| 63 |
+
}
|
| 64 |
+
const firstLength = hexSegments[0]?.length ?? 0;
|
| 65 |
+
if (!firstLength) {
|
| 66 |
+
return undefined;
|
| 67 |
+
}
|
| 68 |
+
if (hexSegments.slice(0, -1).some((segment) => segment.length !== firstLength)) {
|
| 69 |
+
return undefined;
|
| 70 |
+
}
|
| 71 |
+
if ((hexSegments[hexSegments.length - 1]?.length ?? 0) > firstLength) {
|
| 72 |
+
return undefined;
|
| 73 |
+
}
|
| 74 |
+
return {
|
| 75 |
+
size: firstLength / 2,
|
| 76 |
+
separator,
|
| 77 |
+
};
|
| 78 |
+
}
|
| 79 |
+
function detectFormat(text) {
|
| 80 |
+
const trimmed = text.trim();
|
| 81 |
+
const prefix = /^0x/i.test(trimmed) ? "0x" : "";
|
| 82 |
+
const body = prefix ? trimmed.slice(2) : trimmed;
|
| 83 |
+
const lineSeparator = detectLineSeparator(body);
|
| 84 |
+
const lines = body.split(/\r\n|\n/).filter((line) => line.length > 0);
|
| 85 |
+
const sampleLine = lines[0]?.trim() ?? "";
|
| 86 |
+
const group = detectGroup(sampleLine);
|
| 87 |
+
const format = {
|
| 88 |
+
case: detectCase(trimmed),
|
| 89 |
+
prefix,
|
| 90 |
+
};
|
| 91 |
+
if (group) {
|
| 92 |
+
format.group = group;
|
| 93 |
+
}
|
| 94 |
+
if (lineSeparator && lines.length > 1) {
|
| 95 |
+
const firstLineBytes = compactForDetection(lines[0] ?? "").length / 2;
|
| 96 |
+
if (firstLineBytes > 0 && lines.slice(0, -1).every((line) => compactForDetection(line).length / 2 === firstLineBytes)) {
|
| 97 |
+
format.line = {
|
| 98 |
+
bytesPerLine: firstLineBytes,
|
| 99 |
+
separator: lineSeparator,
|
| 100 |
+
};
|
| 101 |
+
}
|
| 102 |
+
}
|
| 103 |
+
return format;
|
| 104 |
+
}
|
| 105 |
+
function normalizeText(text, options) {
|
| 106 |
+
const allowPrefix = options.allowPrefix ?? true;
|
| 107 |
+
const separators = [...resolveSeparators(options)].sort((left, right) => right.length - left.length);
|
| 108 |
+
for (const separator of separators) {
|
| 109 |
+
validateSeparator(separator);
|
| 110 |
+
}
|
| 111 |
+
let working = text.trim();
|
| 112 |
+
if (/^0x/i.test(working)) {
|
| 113 |
+
if (!allowPrefix) {
|
| 114 |
+
throw new TypeError("Hexadecimal text must not include a 0x prefix");
|
| 115 |
+
}
|
| 116 |
+
working = working.slice(2);
|
| 117 |
+
}
|
| 118 |
+
let normalized = "";
|
| 119 |
+
let lastTokenWasSeparator = false;
|
| 120 |
+
for (let index = 0; index < working.length;) {
|
| 121 |
+
const character = working[index] ?? "";
|
| 122 |
+
if (HEX_CHARACTER_REGEX.test(character)) {
|
| 123 |
+
normalized += character;
|
| 124 |
+
lastTokenWasSeparator = false;
|
| 125 |
+
index += 1;
|
| 126 |
+
continue;
|
| 127 |
+
}
|
| 128 |
+
const separator = matchSeparator(working, index, separators);
|
| 129 |
+
if (!separator) {
|
| 130 |
+
throw new TypeError("Input is not valid hexadecimal text");
|
| 131 |
+
}
|
| 132 |
+
if (options.strict && (lastTokenWasSeparator || normalized.length === 0)) {
|
| 133 |
+
throw new TypeError("Hexadecimal text contains misplaced separators");
|
| 134 |
+
}
|
| 135 |
+
lastTokenWasSeparator = true;
|
| 136 |
+
index += separator.length;
|
| 137 |
+
}
|
| 138 |
+
if (options.strict && lastTokenWasSeparator && normalized.length > 0) {
|
| 139 |
+
throw new TypeError("Hexadecimal text must not end with a separator");
|
| 140 |
+
}
|
| 141 |
+
if (normalized.length % 2 !== 0) {
|
| 142 |
+
if (!options.allowOddLength) {
|
| 143 |
+
throw new TypeError("Hexadecimal text must contain an even number of characters");
|
| 144 |
+
}
|
| 145 |
+
normalized = `0${normalized}`;
|
| 146 |
+
}
|
| 147 |
+
return normalized.toLowerCase();
|
| 148 |
+
}
|
| 149 |
+
function groupPairs(pairs, group) {
|
| 150 |
+
if (!group) {
|
| 151 |
+
return pairs.join("");
|
| 152 |
+
}
|
| 153 |
+
if (!Number.isInteger(group.size) || group.size < 1) {
|
| 154 |
+
throw new RangeError("Hex group size must be a positive integer");
|
| 155 |
+
}
|
| 156 |
+
const chunks = [];
|
| 157 |
+
for (let index = 0; index < pairs.length; index += group.size) {
|
| 158 |
+
chunks.push(pairs.slice(index, index + group.size).join(""));
|
| 159 |
+
}
|
| 160 |
+
return chunks.join(group.separator);
|
| 161 |
+
}
|
| 162 |
+
function normalize(text, options = {}) {
|
| 163 |
+
return normalizeText(text, options);
|
| 164 |
+
}
|
| 165 |
+
function is(text, options = {}) {
|
| 166 |
+
if (typeof text !== "string") {
|
| 167 |
+
return false;
|
| 168 |
+
}
|
| 169 |
+
try {
|
| 170 |
+
normalize(text, options);
|
| 171 |
+
return true;
|
| 172 |
+
}
|
| 173 |
+
catch {
|
| 174 |
+
return false;
|
| 175 |
+
}
|
| 176 |
+
}
|
| 177 |
+
function encode(data, options = {}) {
|
| 178 |
+
const bytes = (0, index_js_1.toUint8Array)(data);
|
| 179 |
+
const casing = options.case ?? "lower";
|
| 180 |
+
const pairs = Array.from(bytes, (byte) => {
|
| 181 |
+
const text = byte.toString(16).padStart(2, "0");
|
| 182 |
+
return casing === "upper" ? text.toUpperCase() : text;
|
| 183 |
+
});
|
| 184 |
+
let body = "";
|
| 185 |
+
if (options.line) {
|
| 186 |
+
const bytesPerLine = options.line.bytesPerLine;
|
| 187 |
+
if (!Number.isInteger(bytesPerLine) || bytesPerLine < 1) {
|
| 188 |
+
throw new RangeError("Hex bytesPerLine must be a positive integer");
|
| 189 |
+
}
|
| 190 |
+
const separator = options.line.separator ?? "\n";
|
| 191 |
+
const lines = [];
|
| 192 |
+
for (let index = 0; index < pairs.length; index += bytesPerLine) {
|
| 193 |
+
lines.push(groupPairs(pairs.slice(index, index + bytesPerLine), options.group));
|
| 194 |
+
}
|
| 195 |
+
body = lines.join(separator);
|
| 196 |
+
}
|
| 197 |
+
else {
|
| 198 |
+
body = groupPairs(pairs, options.group);
|
| 199 |
+
}
|
| 200 |
+
return `${options.prefix ?? ""}${body}`;
|
| 201 |
+
}
|
| 202 |
+
function decode(text, options = {}) {
|
| 203 |
+
const normalized = normalize(text, options);
|
| 204 |
+
const result = new Uint8Array(normalized.length / 2);
|
| 205 |
+
for (let i = 0; i < normalized.length; i += 2) {
|
| 206 |
+
result[i / 2] = Number.parseInt(normalized.slice(i, i + 2), 16);
|
| 207 |
+
}
|
| 208 |
+
return result;
|
| 209 |
+
}
|
| 210 |
+
function parse(text, options = {}) {
|
| 211 |
+
const normalized = normalize(text, options);
|
| 212 |
+
return {
|
| 213 |
+
bytes: decode(normalized),
|
| 214 |
+
format: detectFormat(text),
|
| 215 |
+
normalized,
|
| 216 |
+
};
|
| 217 |
+
}
|
| 218 |
+
function format(data, value) {
|
| 219 |
+
return encode(data, value);
|
| 220 |
+
}
|
| 221 |
+
exports.formats = {
|
| 222 |
+
compact: Object.freeze({}),
|
| 223 |
+
upper: Object.freeze({ case: "upper" }),
|
| 224 |
+
colon: Object.freeze({ group: { size: 1, separator: ":" } }),
|
| 225 |
+
colonUpper: Object.freeze({ case: "upper", group: { size: 1, separator: ":" } }),
|
| 226 |
+
groupsOf4: Object.freeze({ group: { size: 4, separator: " " } }),
|
| 227 |
+
prefixed: Object.freeze({ prefix: "0x" }),
|
| 228 |
+
};
|
| 229 |
+
exports.hex = { encode, decode, format, formats: exports.formats, is, normalize, parse };
|
node_modules/@peculiar/utils/build/cjs/encoding/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.base64url = exports.base64 = exports.utf16 = exports.utf8 = exports.hex = exports.binary = void 0;
|
| 4 |
+
const tslib_1 = require("tslib");
|
| 5 |
+
exports.binary = tslib_1.__importStar(require("./binary.js"));
|
| 6 |
+
exports.hex = tslib_1.__importStar(require("./hex.js"));
|
| 7 |
+
exports.utf8 = tslib_1.__importStar(require("./utf8.js"));
|
| 8 |
+
exports.utf16 = tslib_1.__importStar(require("./utf16.js"));
|
| 9 |
+
exports.base64 = tslib_1.__importStar(require("./base64.js"));
|
| 10 |
+
exports.base64url = tslib_1.__importStar(require("./base64url.js"));
|
node_modules/@peculiar/utils/build/cjs/encoding/utf16.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.utf16 = void 0;
|
| 4 |
+
exports.encode = encode;
|
| 5 |
+
exports.decode = decode;
|
| 6 |
+
const index_js_1 = require("../bytes/index.js");
|
| 7 |
+
function encode(text, options = {}) {
|
| 8 |
+
const result = new ArrayBuffer(text.length * 2);
|
| 9 |
+
const view = new DataView(result);
|
| 10 |
+
for (let i = 0; i < text.length; i++) {
|
| 11 |
+
view.setUint16(i * 2, text.charCodeAt(i), options.littleEndian ?? false);
|
| 12 |
+
}
|
| 13 |
+
return new Uint8Array(result);
|
| 14 |
+
}
|
| 15 |
+
function decode(data, options = {}) {
|
| 16 |
+
const buffer = (0, index_js_1.toArrayBuffer)(data);
|
| 17 |
+
const view = new DataView(buffer);
|
| 18 |
+
let result = "";
|
| 19 |
+
for (let i = 0; i < buffer.byteLength; i += 2) {
|
| 20 |
+
result += String.fromCharCode(view.getUint16(i, options.littleEndian ?? false));
|
| 21 |
+
}
|
| 22 |
+
return result;
|
| 23 |
+
}
|
| 24 |
+
exports.utf16 = { encode, decode };
|
node_modules/@peculiar/utils/build/cjs/encoding/utf8.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.utf8 = void 0;
|
| 4 |
+
exports.encode = encode;
|
| 5 |
+
exports.decode = decode;
|
| 6 |
+
const index_js_1 = require("../bytes/index.js");
|
| 7 |
+
function encode(text) {
|
| 8 |
+
return new TextEncoder().encode(text);
|
| 9 |
+
}
|
| 10 |
+
function decode(data) {
|
| 11 |
+
return new TextDecoder("utf-8", { fatal: false }).decode((0, index_js_1.toUint8Array)(data));
|
| 12 |
+
}
|
| 13 |
+
exports.utf8 = { encode, decode };
|
node_modules/@peculiar/utils/build/cjs/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.bytes = void 0;
|
| 4 |
+
const tslib_1 = require("tslib");
|
| 5 |
+
tslib_1.__exportStar(require("./bytes/index.js"), exports);
|
| 6 |
+
exports.bytes = tslib_1.__importStar(require("./bytes/index.js"));
|
| 7 |
+
tslib_1.__exportStar(require("./encoding/index.js"), exports);
|
| 8 |
+
tslib_1.__exportStar(require("./pem/index.js"), exports);
|
| 9 |
+
tslib_1.__exportStar(require("./converters/index.js"), exports);
|
| 10 |
+
tslib_1.__exportStar(require("./legacy/index.js"), exports);
|
node_modules/@peculiar/utils/build/cjs/legacy/buffer-source-converter.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.BufferSourceConverter = void 0;
|
| 4 |
+
const index_js_1 = require("../bytes/index.js");
|
| 5 |
+
class BufferSourceConverter {
|
| 6 |
+
static isArrayBuffer(data) {
|
| 7 |
+
return (0, index_js_1.isArrayBuffer)(data);
|
| 8 |
+
}
|
| 9 |
+
static toArrayBuffer(data) {
|
| 10 |
+
return (0, index_js_1.toArrayBuffer)(data);
|
| 11 |
+
}
|
| 12 |
+
static toUint8Array(data) {
|
| 13 |
+
return (0, index_js_1.toUint8Array)(data);
|
| 14 |
+
}
|
| 15 |
+
static toView(data, type) {
|
| 16 |
+
return (0, index_js_1.toView)(data, type);
|
| 17 |
+
}
|
| 18 |
+
static isBufferSource(data) {
|
| 19 |
+
return (0, index_js_1.isBufferSource)(data);
|
| 20 |
+
}
|
| 21 |
+
static isArrayBufferView(data) {
|
| 22 |
+
return (0, index_js_1.isArrayBufferView)(data);
|
| 23 |
+
}
|
| 24 |
+
static isEqual(a, b) {
|
| 25 |
+
return (0, index_js_1.equal)(a, b);
|
| 26 |
+
}
|
| 27 |
+
static concat(first, second, ...rest) {
|
| 28 |
+
if (Array.isArray(first)) {
|
| 29 |
+
return typeof second === "function"
|
| 30 |
+
? (0, index_js_1.concat)(first, second)
|
| 31 |
+
: (0, index_js_1.concat)(first);
|
| 32 |
+
}
|
| 33 |
+
const buffers = [first, second, ...rest].filter(Boolean);
|
| 34 |
+
return (0, index_js_1.concat)(buffers);
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
exports.BufferSourceConverter = BufferSourceConverter;
|
node_modules/@peculiar/utils/build/cjs/legacy/convert.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.Convert = void 0;
|
| 4 |
+
const index_js_1 = require("../converters/index.js");
|
| 5 |
+
function normalizeTextEncoding(encoding) {
|
| 6 |
+
return encoding === "ascii" ? "binary" : encoding;
|
| 7 |
+
}
|
| 8 |
+
class Convert {
|
| 9 |
+
static DEFAULT_UTF8_ENCODING = "utf8";
|
| 10 |
+
static isHex(data) {
|
| 11 |
+
return index_js_1.convert.isHex(data);
|
| 12 |
+
}
|
| 13 |
+
static isBase64(data) {
|
| 14 |
+
return index_js_1.convert.isBase64(data);
|
| 15 |
+
}
|
| 16 |
+
static isBase64Url(data) {
|
| 17 |
+
return index_js_1.convert.isBase64Url(data);
|
| 18 |
+
}
|
| 19 |
+
static ToString(buffer, enc = "utf8") {
|
| 20 |
+
return index_js_1.convert.toString(buffer, enc);
|
| 21 |
+
}
|
| 22 |
+
static FromString(str, enc = "utf8") {
|
| 23 |
+
if (!str) {
|
| 24 |
+
return new ArrayBuffer(0);
|
| 25 |
+
}
|
| 26 |
+
return index_js_1.convert.fromString(str, enc);
|
| 27 |
+
}
|
| 28 |
+
static ToBase64(buffer) {
|
| 29 |
+
return index_js_1.convert.toBase64(buffer);
|
| 30 |
+
}
|
| 31 |
+
static FromBase64(base64) {
|
| 32 |
+
return index_js_1.convert.fromBase64(base64);
|
| 33 |
+
}
|
| 34 |
+
static FromBase64Url(base64url) {
|
| 35 |
+
return index_js_1.convert.fromBase64Url(base64url);
|
| 36 |
+
}
|
| 37 |
+
static ToBase64Url(data) {
|
| 38 |
+
return index_js_1.convert.toBase64Url(data);
|
| 39 |
+
}
|
| 40 |
+
static FromUtf8String(text, encoding = Convert.DEFAULT_UTF8_ENCODING) {
|
| 41 |
+
return index_js_1.convert.fromString(text, normalizeTextEncoding(encoding));
|
| 42 |
+
}
|
| 43 |
+
static ToUtf8String(buffer, encoding = Convert.DEFAULT_UTF8_ENCODING) {
|
| 44 |
+
return index_js_1.convert.toString(buffer, normalizeTextEncoding(encoding));
|
| 45 |
+
}
|
| 46 |
+
static FromBinary(text) {
|
| 47 |
+
return index_js_1.convert.fromBinary(text);
|
| 48 |
+
}
|
| 49 |
+
static ToBinary(buffer) {
|
| 50 |
+
return index_js_1.convert.toBinary(buffer);
|
| 51 |
+
}
|
| 52 |
+
static ToHex(buffer) {
|
| 53 |
+
return index_js_1.convert.toHex(buffer);
|
| 54 |
+
}
|
| 55 |
+
static FromHex(hexString) {
|
| 56 |
+
return index_js_1.convert.fromHex(hexString);
|
| 57 |
+
}
|
| 58 |
+
static ToUtf16String(buffer, littleEndian = false) {
|
| 59 |
+
return index_js_1.convert.toUtf16String(buffer, littleEndian);
|
| 60 |
+
}
|
| 61 |
+
static FromUtf16String(text, littleEndian = false) {
|
| 62 |
+
return index_js_1.convert.fromUtf16String(text, littleEndian);
|
| 63 |
+
}
|
| 64 |
+
static Base64Padding(base64) {
|
| 65 |
+
const padCount = 4 - (base64.length % 4);
|
| 66 |
+
return padCount < 4 ? base64 + "=".repeat(padCount) : base64;
|
| 67 |
+
}
|
| 68 |
+
static formatString(data) {
|
| 69 |
+
return index_js_1.convert.formatString(data);
|
| 70 |
+
}
|
| 71 |
+
}
|
| 72 |
+
exports.Convert = Convert;
|
node_modules/@peculiar/utils/build/cjs/legacy/functions.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.assign = assign;
|
| 4 |
+
exports.combine = combine;
|
| 5 |
+
exports.isEqual = isEqual;
|
| 6 |
+
const index_js_1 = require("../bytes/index.js");
|
| 7 |
+
function assign(target, ...sources) {
|
| 8 |
+
for (const source of sources) {
|
| 9 |
+
if (!source) {
|
| 10 |
+
continue;
|
| 11 |
+
}
|
| 12 |
+
for (const prop in source) {
|
| 13 |
+
target[prop] = source[prop];
|
| 14 |
+
}
|
| 15 |
+
}
|
| 16 |
+
return target;
|
| 17 |
+
}
|
| 18 |
+
function combine(...buf) {
|
| 19 |
+
return (0, index_js_1.concat)(buf);
|
| 20 |
+
}
|
| 21 |
+
function isEqual(bytes1, bytes2) {
|
| 22 |
+
return (0, index_js_1.equal)(bytes1, bytes2);
|
| 23 |
+
}
|
node_modules/@peculiar/utils/build/cjs/legacy/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.isEqual = exports.combine = exports.assign = exports.Convert = exports.BufferSourceConverter = void 0;
|
| 4 |
+
var buffer_source_converter_js_1 = require("./buffer-source-converter.js");
|
| 5 |
+
Object.defineProperty(exports, "BufferSourceConverter", { enumerable: true, get: function () { return buffer_source_converter_js_1.BufferSourceConverter; } });
|
| 6 |
+
var convert_js_1 = require("./convert.js");
|
| 7 |
+
Object.defineProperty(exports, "Convert", { enumerable: true, get: function () { return convert_js_1.Convert; } });
|
| 8 |
+
var functions_js_1 = require("./functions.js");
|
| 9 |
+
Object.defineProperty(exports, "assign", { enumerable: true, get: function () { return functions_js_1.assign; } });
|
| 10 |
+
Object.defineProperty(exports, "combine", { enumerable: true, get: function () { return functions_js_1.combine; } });
|
| 11 |
+
Object.defineProperty(exports, "isEqual", { enumerable: true, get: function () { return functions_js_1.isEqual; } });
|
node_modules/@peculiar/utils/build/cjs/package.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"type": "commonjs"
|
| 3 |
+
}
|
node_modules/@peculiar/utils/build/cjs/pem/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.pemConverter = exports.pem = exports.parse = exports.format = exports.findAll = exports.find = exports.encodeMany = exports.encode = exports.decodeFirst = exports.decode = void 0;
|
| 4 |
+
var pem_js_1 = require("./pem.js");
|
| 5 |
+
Object.defineProperty(exports, "decode", { enumerable: true, get: function () { return pem_js_1.decode; } });
|
| 6 |
+
Object.defineProperty(exports, "decodeFirst", { enumerable: true, get: function () { return pem_js_1.decodeFirst; } });
|
| 7 |
+
Object.defineProperty(exports, "encode", { enumerable: true, get: function () { return pem_js_1.encode; } });
|
| 8 |
+
Object.defineProperty(exports, "encodeMany", { enumerable: true, get: function () { return pem_js_1.encodeMany; } });
|
| 9 |
+
Object.defineProperty(exports, "find", { enumerable: true, get: function () { return pem_js_1.find; } });
|
| 10 |
+
Object.defineProperty(exports, "findAll", { enumerable: true, get: function () { return pem_js_1.findAll; } });
|
| 11 |
+
Object.defineProperty(exports, "format", { enumerable: true, get: function () { return pem_js_1.format; } });
|
| 12 |
+
Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return pem_js_1.parse; } });
|
| 13 |
+
Object.defineProperty(exports, "pem", { enumerable: true, get: function () { return pem_js_1.pem; } });
|
| 14 |
+
Object.defineProperty(exports, "pemConverter", { enumerable: true, get: function () { return pem_js_1.pemConverter; } });
|
node_modules/@peculiar/utils/build/cjs/pem/pem.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.pemConverter = exports.pem = void 0;
|
| 4 |
+
exports.encode = encode;
|
| 5 |
+
exports.encodeMany = encodeMany;
|
| 6 |
+
exports.decode = decode;
|
| 7 |
+
exports.find = find;
|
| 8 |
+
exports.findAll = findAll;
|
| 9 |
+
exports.decodeFirst = decodeFirst;
|
| 10 |
+
exports.parse = parse;
|
| 11 |
+
exports.format = format;
|
| 12 |
+
const base64_js_1 = require("../encoding/base64.js");
|
| 13 |
+
const LABEL_REGEX = /^[A-Z0-9][A-Z0-9 ._-]*[A-Z0-9]$/i;
|
| 14 |
+
const PEM_BLOCK_REGEX = /-----BEGIN ([^-]+)-----([\s\S]*?)-----END \1-----/g;
|
| 15 |
+
function assertLabel(label) {
|
| 16 |
+
if (!LABEL_REGEX.test(label)) {
|
| 17 |
+
throw new TypeError(`Invalid PEM label '${label}'`);
|
| 18 |
+
}
|
| 19 |
+
}
|
| 20 |
+
function wrap(text, lineLength) {
|
| 21 |
+
const result = [];
|
| 22 |
+
for (let i = 0; i < text.length; i += lineLength) {
|
| 23 |
+
result.push(text.slice(i, i + lineLength));
|
| 24 |
+
}
|
| 25 |
+
return result;
|
| 26 |
+
}
|
| 27 |
+
function parseBody(body) {
|
| 28 |
+
const normalized = body.trim().replace(/\r\n/g, "\n");
|
| 29 |
+
const lines = normalized.split("\n").map((line) => line.trim()).filter(Boolean);
|
| 30 |
+
const headers = {};
|
| 31 |
+
let index = 0;
|
| 32 |
+
for (; index < lines.length; index++) {
|
| 33 |
+
const line = lines[index];
|
| 34 |
+
const separator = line.indexOf(":");
|
| 35 |
+
if (separator <= 0) {
|
| 36 |
+
break;
|
| 37 |
+
}
|
| 38 |
+
headers[line.slice(0, separator).trim()] = line.slice(separator + 1).trim();
|
| 39 |
+
}
|
| 40 |
+
return {
|
| 41 |
+
headers: Object.keys(headers).length ? headers : undefined,
|
| 42 |
+
base64Lines: lines.slice(index),
|
| 43 |
+
base64Text: lines.slice(index).join(""),
|
| 44 |
+
};
|
| 45 |
+
}
|
| 46 |
+
function detectNewline(text) {
|
| 47 |
+
return /\r\n/.test(text) ? "\r\n" : "\n";
|
| 48 |
+
}
|
| 49 |
+
function collectBlocks(text, options = {}) {
|
| 50 |
+
const blocks = [];
|
| 51 |
+
const requestedLabel = options.label;
|
| 52 |
+
let match;
|
| 53 |
+
PEM_BLOCK_REGEX.lastIndex = 0;
|
| 54 |
+
while ((match = PEM_BLOCK_REGEX.exec(text))) {
|
| 55 |
+
const label = match[1].trim();
|
| 56 |
+
if (requestedLabel && label !== requestedLabel) {
|
| 57 |
+
continue;
|
| 58 |
+
}
|
| 59 |
+
assertLabel(label);
|
| 60 |
+
const parsed = parseBody(match[2]);
|
| 61 |
+
blocks.push({
|
| 62 |
+
label,
|
| 63 |
+
data: base64_js_1.base64.decode(parsed.base64Text),
|
| 64 |
+
headers: parsed.headers,
|
| 65 |
+
lineLength: parsed.base64Lines[0]?.length ?? 64,
|
| 66 |
+
newline: detectNewline(match[0]),
|
| 67 |
+
});
|
| 68 |
+
}
|
| 69 |
+
if (options.strict && blocks.length === 0) {
|
| 70 |
+
throw new TypeError(requestedLabel
|
| 71 |
+
? `No PEM block with label '${requestedLabel}' was found`
|
| 72 |
+
: "No PEM blocks were found");
|
| 73 |
+
}
|
| 74 |
+
return blocks;
|
| 75 |
+
}
|
| 76 |
+
function encode(label, data, options = {}) {
|
| 77 |
+
assertLabel(label);
|
| 78 |
+
const lineLength = options.lineLength ?? 64;
|
| 79 |
+
if (!Number.isInteger(lineLength) || lineLength < 1) {
|
| 80 |
+
throw new RangeError("PEM lineLength must be a positive integer");
|
| 81 |
+
}
|
| 82 |
+
const newline = options.newline ?? "\n";
|
| 83 |
+
const lines = [`-----BEGIN ${label}-----`];
|
| 84 |
+
if (options.headers) {
|
| 85 |
+
for (const [name, value] of Object.entries(options.headers)) {
|
| 86 |
+
lines.push(`${name}: ${value}`);
|
| 87 |
+
}
|
| 88 |
+
lines.push("");
|
| 89 |
+
}
|
| 90 |
+
lines.push(...wrap(base64_js_1.base64.encode(data), lineLength));
|
| 91 |
+
lines.push(`-----END ${label}-----`);
|
| 92 |
+
return `${lines.join(newline)}${newline}`;
|
| 93 |
+
}
|
| 94 |
+
function encodeMany(blocks, options = {}) {
|
| 95 |
+
return blocks.map((block) => encode(block.label, block.data, { ...options, headers: block.headers ?? options.headers })).join("");
|
| 96 |
+
}
|
| 97 |
+
function decode(text, options = {}) {
|
| 98 |
+
return collectBlocks(text, options).map(({ lineLength: _lineLength, newline: _newline, ...block }) => block);
|
| 99 |
+
}
|
| 100 |
+
function find(text, label) {
|
| 101 |
+
return decode(text, { label })[0];
|
| 102 |
+
}
|
| 103 |
+
function findAll(text, label) {
|
| 104 |
+
return decode(text, { label });
|
| 105 |
+
}
|
| 106 |
+
function decodeFirst(text, label) {
|
| 107 |
+
const [block] = decode(text, { label, strict: true });
|
| 108 |
+
return block.data;
|
| 109 |
+
}
|
| 110 |
+
function parse(text, options = {}) {
|
| 111 |
+
const [block] = collectBlocks(text, { ...options, strict: true });
|
| 112 |
+
const format = {
|
| 113 |
+
label: block.label,
|
| 114 |
+
headers: block.headers,
|
| 115 |
+
lineLength: block.lineLength,
|
| 116 |
+
newline: block.newline,
|
| 117 |
+
};
|
| 118 |
+
return {
|
| 119 |
+
bytes: block.data,
|
| 120 |
+
format,
|
| 121 |
+
normalized: encode(block.label, block.data, format),
|
| 122 |
+
};
|
| 123 |
+
}
|
| 124 |
+
function format(data, value) {
|
| 125 |
+
return encode(value.label, data, value);
|
| 126 |
+
}
|
| 127 |
+
exports.pem = { decode, decodeFirst, encode, encodeMany, find, findAll, format, parse };
|
| 128 |
+
exports.pemConverter = {
|
| 129 |
+
name: "pem",
|
| 130 |
+
encode: (data, options) => {
|
| 131 |
+
if (!options?.label) {
|
| 132 |
+
throw new TypeError("PEM label is required");
|
| 133 |
+
}
|
| 134 |
+
return encode(options.label, data, options);
|
| 135 |
+
},
|
| 136 |
+
decode: (text, options) => decodeFirst(text, options?.label),
|
| 137 |
+
format,
|
| 138 |
+
is: (text) => typeof text === "string" && /-----BEGIN [^-]+-----/.test(text),
|
| 139 |
+
parse,
|
| 140 |
+
};
|
node_modules/@peculiar/utils/build/cjs/pem/types.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
node_modules/@peculiar/utils/build/esm/bytes/buffer-source.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const ARRAY_BUFFER_TAG = "[object ArrayBuffer]";
|
| 2 |
+
const SHARED_ARRAY_BUFFER_TAG = "[object SharedArrayBuffer]";
|
| 3 |
+
function tagOf(value) {
|
| 4 |
+
return Object.prototype.toString.call(value);
|
| 5 |
+
}
|
| 6 |
+
function isDataViewConstructor(type) {
|
| 7 |
+
return type === DataView || type.prototype instanceof DataView;
|
| 8 |
+
}
|
| 9 |
+
function bytesPerElement(type) {
|
| 10 |
+
if (isDataViewConstructor(type)) {
|
| 11 |
+
return 1;
|
| 12 |
+
}
|
| 13 |
+
const value = type.BYTES_PER_ELEMENT;
|
| 14 |
+
return value ?? 1;
|
| 15 |
+
}
|
| 16 |
+
function isArrayBufferViewLike(value) {
|
| 17 |
+
if (ArrayBuffer.isView(value)) {
|
| 18 |
+
return true;
|
| 19 |
+
}
|
| 20 |
+
if (!value || typeof value !== "object") {
|
| 21 |
+
return false;
|
| 22 |
+
}
|
| 23 |
+
const view = value;
|
| 24 |
+
return typeof view.byteOffset === "number"
|
| 25 |
+
&& typeof view.byteLength === "number"
|
| 26 |
+
&& isArrayBufferLike(view.buffer);
|
| 27 |
+
}
|
| 28 |
+
function copyBytes(data) {
|
| 29 |
+
const view = toUint8Array(data);
|
| 30 |
+
const copy = new Uint8Array(view.byteLength);
|
| 31 |
+
copy.set(view);
|
| 32 |
+
return copy;
|
| 33 |
+
}
|
| 34 |
+
export function isArrayBuffer(value) {
|
| 35 |
+
return tagOf(value) === ARRAY_BUFFER_TAG;
|
| 36 |
+
}
|
| 37 |
+
export function isSharedArrayBuffer(value) {
|
| 38 |
+
return typeof SharedArrayBuffer !== "undefined" && tagOf(value) === SHARED_ARRAY_BUFFER_TAG;
|
| 39 |
+
}
|
| 40 |
+
export function isArrayBufferLike(value) {
|
| 41 |
+
return isArrayBuffer(value) || isSharedArrayBuffer(value);
|
| 42 |
+
}
|
| 43 |
+
export function isArrayBufferView(value) {
|
| 44 |
+
return isArrayBufferViewLike(value);
|
| 45 |
+
}
|
| 46 |
+
export function isBufferSource(value) {
|
| 47 |
+
return isArrayBufferLike(value) || isArrayBufferView(value);
|
| 48 |
+
}
|
| 49 |
+
export function assertBufferSource(value) {
|
| 50 |
+
if (!isBufferSource(value)) {
|
| 51 |
+
throw new TypeError("Expected ArrayBuffer, SharedArrayBuffer, or ArrayBufferView");
|
| 52 |
+
}
|
| 53 |
+
}
|
| 54 |
+
export function toUint8Array(data) {
|
| 55 |
+
assertBufferSource(data);
|
| 56 |
+
if (isArrayBufferLike(data)) {
|
| 57 |
+
return new Uint8Array(data);
|
| 58 |
+
}
|
| 59 |
+
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
| 60 |
+
}
|
| 61 |
+
export function toUint8ArrayCopy(data) {
|
| 62 |
+
return copyBytes(data);
|
| 63 |
+
}
|
| 64 |
+
export function toArrayBuffer(data) {
|
| 65 |
+
assertBufferSource(data);
|
| 66 |
+
if (isArrayBuffer(data)) {
|
| 67 |
+
return data;
|
| 68 |
+
}
|
| 69 |
+
const buffer = new ArrayBuffer(data.byteLength);
|
| 70 |
+
new Uint8Array(buffer).set(toUint8Array(data));
|
| 71 |
+
return buffer;
|
| 72 |
+
}
|
| 73 |
+
export function toArrayBufferLike(data) {
|
| 74 |
+
assertBufferSource(data);
|
| 75 |
+
if (isArrayBufferLike(data)) {
|
| 76 |
+
return data;
|
| 77 |
+
}
|
| 78 |
+
if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {
|
| 79 |
+
return data.buffer;
|
| 80 |
+
}
|
| 81 |
+
return copyBytes(data).buffer;
|
| 82 |
+
}
|
| 83 |
+
export function toView(data, type) {
|
| 84 |
+
assertBufferSource(data);
|
| 85 |
+
if (ArrayBuffer.isView(data) && data.constructor === type) {
|
| 86 |
+
return data;
|
| 87 |
+
}
|
| 88 |
+
const view = toUint8Array(data);
|
| 89 |
+
const elementSize = bytesPerElement(type);
|
| 90 |
+
if (view.byteOffset % elementSize !== 0 || view.byteLength % elementSize !== 0) {
|
| 91 |
+
throw new RangeError(`Cannot create ${type.name} over unaligned byte range`);
|
| 92 |
+
}
|
| 93 |
+
if (isDataViewConstructor(type)) {
|
| 94 |
+
return new type(view.buffer, view.byteOffset, view.byteLength);
|
| 95 |
+
}
|
| 96 |
+
return new type(view.buffer, view.byteOffset, view.byteLength / elementSize);
|
| 97 |
+
}
|
| 98 |
+
export function toViewCopy(data, type) {
|
| 99 |
+
const copy = toUint8ArrayCopy(data);
|
| 100 |
+
return toView(copy, type);
|
| 101 |
+
}
|
node_modules/@peculiar/utils/build/esm/bytes/concat.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { isBufferSource, toUint8Array, toView } from "./buffer-source.js";
|
| 2 |
+
export function concatToUint8Array(buffers) {
|
| 3 |
+
const views = [];
|
| 4 |
+
let length = 0;
|
| 5 |
+
for (const buffer of buffers) {
|
| 6 |
+
const view = toUint8Array(buffer);
|
| 7 |
+
views.push(view);
|
| 8 |
+
length += view.byteLength;
|
| 9 |
+
}
|
| 10 |
+
const result = new Uint8Array(length);
|
| 11 |
+
let offset = 0;
|
| 12 |
+
for (const view of views) {
|
| 13 |
+
result.set(view, offset);
|
| 14 |
+
offset += view.byteLength;
|
| 15 |
+
}
|
| 16 |
+
return result;
|
| 17 |
+
}
|
| 18 |
+
export function concat(first, second, ...rest) {
|
| 19 |
+
let buffers;
|
| 20 |
+
let type;
|
| 21 |
+
if (typeof second === "function") {
|
| 22 |
+
buffers = Array.from(first);
|
| 23 |
+
type = second;
|
| 24 |
+
}
|
| 25 |
+
else if (isBufferSource(first)) {
|
| 26 |
+
buffers = [first, second, ...rest].filter(isBufferSource);
|
| 27 |
+
}
|
| 28 |
+
else {
|
| 29 |
+
buffers = Array.from(first);
|
| 30 |
+
if (second) {
|
| 31 |
+
buffers.push(second);
|
| 32 |
+
}
|
| 33 |
+
buffers.push(...rest);
|
| 34 |
+
}
|
| 35 |
+
const bytes = concatToUint8Array(buffers);
|
| 36 |
+
return type ? toView(bytes, type) : bytes.buffer;
|
| 37 |
+
}
|
node_modules/@peculiar/utils/build/esm/bytes/equal.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { toUint8Array } from "./buffer-source.js";
|
| 2 |
+
export function equal(a, b, options = {}) {
|
| 3 |
+
const left = toUint8Array(a);
|
| 4 |
+
const right = toUint8Array(b);
|
| 5 |
+
if (!options.constantTime && left.byteLength !== right.byteLength) {
|
| 6 |
+
return false;
|
| 7 |
+
}
|
| 8 |
+
const length = Math.max(left.byteLength, right.byteLength);
|
| 9 |
+
let diff = left.byteLength ^ right.byteLength;
|
| 10 |
+
for (let i = 0; i < length; i++) {
|
| 11 |
+
diff |= (left[i] ?? 0) ^ (right[i] ?? 0);
|
| 12 |
+
}
|
| 13 |
+
return diff === 0;
|
| 14 |
+
}
|
node_modules/@peculiar/utils/build/esm/bytes/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export { assertBufferSource, isArrayBuffer, isArrayBufferLike, isArrayBufferView, isBufferSource, isSharedArrayBuffer, toArrayBuffer, toArrayBufferLike, toUint8Array, toUint8ArrayCopy, toView, toViewCopy, } from "./buffer-source.js";
|
| 2 |
+
export { concat, concatToUint8Array } from "./concat.js";
|
| 3 |
+
export { equal } from "./equal.js";
|
| 4 |
+
export { compare, copy, endsWith, includes, indexOf, lastIndexOf, slice, startsWith, tail, } from "./sequence.js";
|
node_modules/@peculiar/utils/build/esm/bytes/sequence.js
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { toUint8Array, toUint8ArrayCopy } from "./buffer-source.js";
|
| 2 |
+
function clampIndex(value, fallback, length) {
|
| 3 |
+
const normalized = Number.isFinite(value) ? Math.trunc(value) : fallback;
|
| 4 |
+
if (normalized <= 0) {
|
| 5 |
+
return 0;
|
| 6 |
+
}
|
| 7 |
+
if (normalized >= length) {
|
| 8 |
+
return length;
|
| 9 |
+
}
|
| 10 |
+
return normalized;
|
| 11 |
+
}
|
| 12 |
+
function normalizeForwardRange(length, options) {
|
| 13 |
+
const start = clampIndex(options?.start, 0, length);
|
| 14 |
+
const end = clampIndex(options?.end, length, length);
|
| 15 |
+
return end >= start ? [start, end] : [start, start];
|
| 16 |
+
}
|
| 17 |
+
function normalizeReverseRange(length, options) {
|
| 18 |
+
const start = clampIndex(options?.start, length, length);
|
| 19 |
+
const end = clampIndex(options?.end, 0, length);
|
| 20 |
+
return start >= end ? [end, start] : [start, start];
|
| 21 |
+
}
|
| 22 |
+
function normalizeSliceIndex(value, fallback, length) {
|
| 23 |
+
const normalized = Number.isFinite(value) ? Math.trunc(value) : fallback;
|
| 24 |
+
if (normalized < 0) {
|
| 25 |
+
return Math.max(length + normalized, 0);
|
| 26 |
+
}
|
| 27 |
+
if (normalized > length) {
|
| 28 |
+
return length;
|
| 29 |
+
}
|
| 30 |
+
return normalized;
|
| 31 |
+
}
|
| 32 |
+
function encodeAscii(text) {
|
| 33 |
+
const bytes = new Uint8Array(text.length);
|
| 34 |
+
for (let i = 0; i < text.length; i++) {
|
| 35 |
+
bytes[i] = text.charCodeAt(i) & 0xff;
|
| 36 |
+
}
|
| 37 |
+
return bytes;
|
| 38 |
+
}
|
| 39 |
+
function encodeUtf8(text) {
|
| 40 |
+
return new TextEncoder().encode(text);
|
| 41 |
+
}
|
| 42 |
+
function toPatternBytes(pattern, options) {
|
| 43 |
+
if (typeof pattern === "string") {
|
| 44 |
+
return options?.encoding === "utf8" ? encodeUtf8(pattern) : encodeAscii(pattern);
|
| 45 |
+
}
|
| 46 |
+
return toUint8Array(pattern);
|
| 47 |
+
}
|
| 48 |
+
function bytesEqualAt(data, pattern, offset) {
|
| 49 |
+
for (let index = 0; index < pattern.byteLength; index++) {
|
| 50 |
+
if (data[offset + index] !== pattern[index]) {
|
| 51 |
+
return false;
|
| 52 |
+
}
|
| 53 |
+
}
|
| 54 |
+
return true;
|
| 55 |
+
}
|
| 56 |
+
export function indexOf(data, pattern, options) {
|
| 57 |
+
const bytes = toUint8Array(data);
|
| 58 |
+
const needle = toPatternBytes(pattern, options);
|
| 59 |
+
const [start, end] = normalizeForwardRange(bytes.byteLength, options);
|
| 60 |
+
if (needle.byteLength === 0) {
|
| 61 |
+
return start;
|
| 62 |
+
}
|
| 63 |
+
const lastOffset = end - needle.byteLength;
|
| 64 |
+
if (lastOffset < start) {
|
| 65 |
+
return -1;
|
| 66 |
+
}
|
| 67 |
+
for (let offset = start; offset <= lastOffset; offset++) {
|
| 68 |
+
if (bytesEqualAt(bytes, needle, offset)) {
|
| 69 |
+
return offset;
|
| 70 |
+
}
|
| 71 |
+
}
|
| 72 |
+
return -1;
|
| 73 |
+
}
|
| 74 |
+
export function lastIndexOf(data, pattern, options) {
|
| 75 |
+
const bytes = toUint8Array(data);
|
| 76 |
+
const needle = toPatternBytes(pattern, options);
|
| 77 |
+
const [end, start] = normalizeReverseRange(bytes.byteLength, options);
|
| 78 |
+
if (needle.byteLength === 0) {
|
| 79 |
+
return start;
|
| 80 |
+
}
|
| 81 |
+
const firstOffset = start - needle.byteLength;
|
| 82 |
+
if (firstOffset < end) {
|
| 83 |
+
return -1;
|
| 84 |
+
}
|
| 85 |
+
for (let offset = firstOffset; offset >= end; offset--) {
|
| 86 |
+
if (bytesEqualAt(bytes, needle, offset)) {
|
| 87 |
+
return offset;
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
return -1;
|
| 91 |
+
}
|
| 92 |
+
export function includes(data, pattern, options) {
|
| 93 |
+
return indexOf(data, pattern, options) !== -1;
|
| 94 |
+
}
|
| 95 |
+
export function startsWith(data, pattern, options) {
|
| 96 |
+
const bytes = toUint8Array(data);
|
| 97 |
+
const needle = toPatternBytes(pattern, options);
|
| 98 |
+
if (needle.byteLength > bytes.byteLength) {
|
| 99 |
+
return false;
|
| 100 |
+
}
|
| 101 |
+
return bytesEqualAt(bytes, needle, 0);
|
| 102 |
+
}
|
| 103 |
+
export function endsWith(data, pattern, options) {
|
| 104 |
+
const bytes = toUint8Array(data);
|
| 105 |
+
const needle = toPatternBytes(pattern, options);
|
| 106 |
+
if (needle.byteLength > bytes.byteLength) {
|
| 107 |
+
return false;
|
| 108 |
+
}
|
| 109 |
+
return bytesEqualAt(bytes, needle, bytes.byteLength - needle.byteLength);
|
| 110 |
+
}
|
| 111 |
+
export function slice(data, start, end) {
|
| 112 |
+
const bytes = toUint8Array(data);
|
| 113 |
+
const normalizedStart = normalizeSliceIndex(start, 0, bytes.byteLength);
|
| 114 |
+
const normalizedEnd = normalizeSliceIndex(end, bytes.byteLength, bytes.byteLength);
|
| 115 |
+
if (normalizedEnd <= normalizedStart) {
|
| 116 |
+
return bytes.subarray(normalizedStart, normalizedStart);
|
| 117 |
+
}
|
| 118 |
+
return bytes.subarray(normalizedStart, normalizedEnd);
|
| 119 |
+
}
|
| 120 |
+
export function tail(data, length) {
|
| 121 |
+
const bytes = toUint8Array(data);
|
| 122 |
+
const normalizedLength = Number.isFinite(length) ? Math.max(0, Math.trunc(length)) : 0;
|
| 123 |
+
if (normalizedLength >= bytes.byteLength) {
|
| 124 |
+
return bytes;
|
| 125 |
+
}
|
| 126 |
+
return bytes.subarray(bytes.byteLength - normalizedLength);
|
| 127 |
+
}
|
| 128 |
+
export function copy(data) {
|
| 129 |
+
return toUint8ArrayCopy(data);
|
| 130 |
+
}
|
| 131 |
+
export function compare(a, b) {
|
| 132 |
+
const left = toUint8Array(a);
|
| 133 |
+
const right = toUint8Array(b);
|
| 134 |
+
const limit = Math.min(left.byteLength, right.byteLength);
|
| 135 |
+
for (let index = 0; index < limit; index++) {
|
| 136 |
+
if (left[index] < right[index]) {
|
| 137 |
+
return -1;
|
| 138 |
+
}
|
| 139 |
+
if (left[index] > right[index]) {
|
| 140 |
+
return 1;
|
| 141 |
+
}
|
| 142 |
+
}
|
| 143 |
+
if (left.byteLength < right.byteLength) {
|
| 144 |
+
return -1;
|
| 145 |
+
}
|
| 146 |
+
if (left.byteLength > right.byteLength) {
|
| 147 |
+
return 1;
|
| 148 |
+
}
|
| 149 |
+
return 0;
|
| 150 |
+
}
|
node_modules/@peculiar/utils/build/esm/bytes/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
export {};
|