mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-02-03 23:42:50 +00:00
Add asn1
This commit is contained in:
parent
a689389e00
commit
4bdbccfedc
88
types/asn1/asn1-tests.ts
Normal file
88
types/asn1/asn1-tests.ts
Normal file
@ -0,0 +1,88 @@
|
||||
import { Ber, BerReader, BerWriter } from 'asn1';
|
||||
|
||||
let buf: Buffer = Buffer.alloc(0);
|
||||
let bool = false;
|
||||
let str = '';
|
||||
let num = 0;
|
||||
let numOrNull: number | null = 0;
|
||||
const roStrArray: ReadonlyArray<string> = [str];
|
||||
|
||||
const reader = new BerReader(buf);
|
||||
numOrNull = reader.peek();
|
||||
bool = reader.readBoolean();
|
||||
numOrNull = reader.readByte(bool);
|
||||
num = reader.readEnumeration();
|
||||
num = reader.readInt();
|
||||
num = reader.readLength();
|
||||
num = reader.readLength(num);
|
||||
str = reader.readOID();
|
||||
str = reader.readOID(num);
|
||||
numOrNull = reader.readSequence();
|
||||
numOrNull = reader.readSequence(num);
|
||||
str = reader.readString();
|
||||
str = reader.readString(num);
|
||||
buf = reader.readString(num, bool);
|
||||
num = reader._readTag();
|
||||
num = reader._readTag(num);
|
||||
|
||||
let writer = new BerWriter();
|
||||
writer = new BerWriter({
|
||||
size: num,
|
||||
growthFactor: num,
|
||||
});
|
||||
|
||||
buf = writer.buffer;
|
||||
buf = writer._buf;
|
||||
num = writer._size;
|
||||
num = writer._offset;
|
||||
|
||||
writer.endSequence();
|
||||
writer.startSequence();
|
||||
writer.startSequence(num);
|
||||
writer.writeBoolean(bool);
|
||||
writer.writeBoolean(bool, num);
|
||||
writer.writeBuffer(buf, num);
|
||||
writer.writeByte(num);
|
||||
writer.writeEnumeration(num);
|
||||
writer.writeEnumeration(num, num);
|
||||
writer.writeInt(num);
|
||||
writer.writeInt(num, num);
|
||||
writer.writeLength(num);
|
||||
writer.writeNull();
|
||||
writer.writeOID(str, num);
|
||||
writer.writeString(str);
|
||||
writer.writeString(str, num);
|
||||
writer.writeStringArray(roStrArray);
|
||||
writer._ensure(num);
|
||||
|
||||
num = Ber.BMPString;
|
||||
num = Ber.BitString;
|
||||
num = Ber.Boolean;
|
||||
num = Ber.CharacterString;
|
||||
num = Ber.Constructor;
|
||||
num = Ber.Context;
|
||||
num = Ber.EOC;
|
||||
num = Ber.Enumeration;
|
||||
num = Ber.External;
|
||||
num = Ber.GeneralString;
|
||||
num = Ber.GeneralizedTime;
|
||||
num = Ber.GraphicString;
|
||||
num = Ber.IA5String;
|
||||
num = Ber.Integer;
|
||||
num = Ber.Null;
|
||||
num = Ber.NumericString;
|
||||
num = Ber.OID;
|
||||
num = Ber.ObjectDescriptor;
|
||||
num = Ber.OctetString;
|
||||
num = Ber.PDV;
|
||||
num = Ber.PrintableString;
|
||||
num = Ber.Real;
|
||||
num = Ber.RelativeOID;
|
||||
num = Ber.Sequence;
|
||||
num = Ber.Set;
|
||||
num = Ber.T61String;
|
||||
num = Ber.UTCTime;
|
||||
num = Ber.UniversalString;
|
||||
num = Ber.Utf8String;
|
||||
num = Ber.VideotexString;
|
||||
num = Ber.VisibleString;
|
||||
126
types/asn1/index.d.ts
vendored
Normal file
126
types/asn1/index.d.ts
vendored
Normal file
@ -0,0 +1,126 @@
|
||||
// Type definitions for asn1 0.2
|
||||
// Project: https://github.com/joyent/node-asn1
|
||||
// Definitions by: Jim Geurts <https://github.com/jgeurts>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
/// <reference types="node" />
|
||||
|
||||
export class BerReader {
|
||||
readonly buffer: Buffer;
|
||||
readonly offset: number;
|
||||
readonly length: number;
|
||||
readonly remain: number;
|
||||
readonly _buf: Buffer;
|
||||
_size: number;
|
||||
_offset: number;
|
||||
|
||||
constructor(data: Buffer);
|
||||
|
||||
peek(): number | null;
|
||||
readBoolean(): boolean;
|
||||
readByte(peek: boolean): number | null;
|
||||
readEnumeration(): number;
|
||||
readInt(): number;
|
||||
readLength(offset?: number): number;
|
||||
readOID(tag?: number): string;
|
||||
readSequence(tag?: number): number | null;
|
||||
readString(tag?: number): string;
|
||||
readString(tag: number, retbuf: boolean): Buffer;
|
||||
_readTag(tag?: number): number;
|
||||
}
|
||||
|
||||
export class BerWriter {
|
||||
readonly buffer: Buffer;
|
||||
readonly _buf: Buffer;
|
||||
readonly _size: number;
|
||||
_offset: number;
|
||||
|
||||
constructor(options?: {
|
||||
size: number;
|
||||
growthFactor: number;
|
||||
});
|
||||
|
||||
endSequence(): void;
|
||||
startSequence(tag?: number): void;
|
||||
writeBoolean(b: boolean, tag?: number): void;
|
||||
writeBuffer(buf: Buffer, tag: number): void;
|
||||
writeByte(b: number): void;
|
||||
writeEnumeration(i: number, tag?: number): void;
|
||||
writeInt(i: number, tag?: number): void;
|
||||
writeLength(len: number): void;
|
||||
writeNull(): void;
|
||||
writeOID(s: string, tag: number): void;
|
||||
writeString(s: string, tag?: number): void;
|
||||
writeStringArray(strings: ReadonlyArray<string>): void;
|
||||
_ensure(length: number): void;
|
||||
}
|
||||
|
||||
export namespace Ber {
|
||||
const BMPString: number;
|
||||
const BitString: number;
|
||||
const Boolean: number;
|
||||
const CharacterString: number;
|
||||
const Constructor: number;
|
||||
const Context: number;
|
||||
const EOC: number;
|
||||
const Enumeration: number;
|
||||
const External: number;
|
||||
const GeneralString: number;
|
||||
const GeneralizedTime: number;
|
||||
const GraphicString: number;
|
||||
const IA5String: number;
|
||||
const Integer: number;
|
||||
const Null: number;
|
||||
const NumericString: number;
|
||||
const OID: number;
|
||||
const ObjectDescriptor: number;
|
||||
const OctetString: number;
|
||||
const PDV: number;
|
||||
const PrintableString: number;
|
||||
const Real: number;
|
||||
const RelativeOID: number;
|
||||
const Sequence: number;
|
||||
const Set: number;
|
||||
const T61String: number;
|
||||
const UTCTime: number;
|
||||
const UniversalString: number;
|
||||
const Utf8String: number;
|
||||
const VideotexString: number;
|
||||
const VisibleString: number;
|
||||
}
|
||||
/*
|
||||
declare enum BerType {
|
||||
EOC = 0,
|
||||
Boolean = 1,
|
||||
Integer = 2,
|
||||
BitString = 3,
|
||||
OctetString = 4,
|
||||
Null = 5,
|
||||
OID = 6,
|
||||
ObjectDescriptor = 7,
|
||||
External = 8,
|
||||
Real = 9, // float
|
||||
Enumeration = 10,
|
||||
PDV = 11,
|
||||
Utf8String = 12,
|
||||
RelativeOID = 13,
|
||||
Sequence = 16,
|
||||
Set = 17,
|
||||
NumericString = 18,
|
||||
PrintableString = 19,
|
||||
T61String = 20,
|
||||
VideotexString = 21,
|
||||
IA5String = 22,
|
||||
UTCTime = 23,
|
||||
GeneralizedTime = 24,
|
||||
GraphicString = 25,
|
||||
VisibleString = 26,
|
||||
GeneralString = 28,
|
||||
UniversalString = 29,
|
||||
CharacterString = 30,
|
||||
BMPString = 31,
|
||||
Constructor = 32,
|
||||
Context = 128,
|
||||
}
|
||||
|
||||
*/
|
||||
25
types/asn1/tsconfig.json
Normal file
25
types/asn1/tsconfig.json
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"noUnusedParameters": true,
|
||||
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"asn1-tests.ts"
|
||||
]
|
||||
}
|
||||
3
types/asn1/tslint.json
Normal file
3
types/asn1/tslint.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user