xml-fiesta-types 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/asn1hex.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ export declare const ASN1HEX: {
2
+ isASN1HEX(hex: string): boolean;
3
+ getPosArrayOfChildren_AtObj(hex: string, pos: number): number[];
4
+ getHexOfTLV_AtObj(hex: string, pos: number): string;
5
+ getHexOfV_AtObj(hex: string, pos: number): string;
6
+ getDecendantHexTLVByNthList(hex: string, pos: number, nthList: number[]): string;
7
+ getDecendantHexVByNthList(hex: string, pos: number, nthList: number[]): string;
8
+ };
@@ -0,0 +1,33 @@
1
+ import * as forge from "node-forge";
2
+ export default class Certificate {
3
+ binaryString: string | null;
4
+ pem: string;
5
+ certificate: forge.pki.Certificate;
6
+ subject: Record<string, string>;
7
+ hex: string;
8
+ pubKey: forge.pki.rsa.PublicKey | null;
9
+ constructor(binaryString: string | null, hexString?: string);
10
+ toBinaryString(): string;
11
+ toHex(): string;
12
+ toPem(): string;
13
+ getX509(): forge.pki.Certificate;
14
+ getSerialNumberHex(): string;
15
+ getSerialNumber(): string;
16
+ getSubject(): Record<string, string>;
17
+ email(): string;
18
+ owner(): string;
19
+ owner_id(): string;
20
+ getUniqueIdentifier(): string[];
21
+ getRSAPublicKey(): forge.pki.rsa.PublicKey;
22
+ verifyString(string: string, signedHexString: string, alg?: string): boolean;
23
+ verifyHexString(hexString: string, signedHexString: string, alg?: string): boolean;
24
+ getUniqueIdentifierString(joinVal: any): string;
25
+ hasExpired(): boolean;
26
+ isValidOn(date: any): boolean;
27
+ algorithm(): string;
28
+ tbsCertificate(): string;
29
+ signature(): string;
30
+ isCa(rootCaHex: any): boolean;
31
+ validParent(rootCaPem: any, rootCaHex?: any): boolean;
32
+ private buildSubjectObject;
33
+ }
package/common.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ declare function extend(object: any, properties: any): any;
2
+ declare function b64toHex(b64String: any): string;
3
+ declare function hextoB64(hexString: any): string;
4
+ declare function hextoAscii(hexString: any): string;
5
+ declare function b64toAscii(b64String: any): string;
6
+ declare function parseDate(date: any): Date;
7
+ declare function sha256(string: any): string;
8
+ declare function sha256hex(hex: any): string;
9
+ export { extend, b64toHex, hextoB64, hextoAscii, b64toAscii, parseDate, sha256, sha256hex, };
@@ -0,0 +1,26 @@
1
+ import Certificate from "./certificate";
2
+ export default class ConservancyRecord {
3
+ caCert: string;
4
+ userCert: string;
5
+ record: string;
6
+ timestamp: string;
7
+ signedHash: string;
8
+ caCertificate: Certificate;
9
+ userCertificate: Certificate;
10
+ recordHex: string;
11
+ positions: any;
12
+ constructor(caCert: string, userCert: string, record: string, timestamp: string, signedHash: string);
13
+ caName(): string;
14
+ userName(): string;
15
+ timestampHex(): string;
16
+ archiveHex(): string;
17
+ archiveSignature(): string;
18
+ archiveSignedHash(): string;
19
+ validArchiveHash(): boolean;
20
+ recordTimestamp(): Date;
21
+ equalTimestamps(): boolean;
22
+ signedData(): string;
23
+ signature(): string;
24
+ valid(): boolean;
25
+ validParent(caPemCert: any): boolean;
26
+ }
@@ -0,0 +1,31 @@
1
+ import Certificate from "./certificate";
2
+ export default class ConservancyRecordNom2016 {
3
+ caCert: string;
4
+ record: string;
5
+ timestamp: any;
6
+ signedHash: string;
7
+ recordHex: string;
8
+ rootCertificate: Certificate;
9
+ tsaCertificate: Certificate;
10
+ private positions;
11
+ constructor(caCert: string, record: string, timestamp?: any, signedHash?: string);
12
+ rootCertificateHex(): string;
13
+ caCertificateHex(): string;
14
+ certificatesHex(): string;
15
+ caName(): string;
16
+ rootName(): string;
17
+ messageDigest(): string;
18
+ signedTimeStamp(): Date;
19
+ signingCertificateV2(): string;
20
+ tSTInfoHex(): string;
21
+ contentAttributesHex(): string;
22
+ signedAttributesHex(): string;
23
+ archiveHex(): string;
24
+ archiveSignature(): string;
25
+ archiveSignedHash(): string;
26
+ validArchiveHash(): boolean;
27
+ recordTimestamp(): Date;
28
+ equalTimestamps(): boolean;
29
+ valid(): boolean;
30
+ validParent(caPemCert: any): boolean;
31
+ }
@@ -0,0 +1,3 @@
1
+ declare module 'xml-fiesta' {
2
+ export * from './xml-fiesta';
3
+ }
package/document.d.ts ADDED
@@ -0,0 +1,90 @@
1
+ /// <reference types="node" />
2
+ import ConservancyRecord from "./conservancyRecord";
3
+ import ConservancyRecordNom2016 from "./conservancyRecordNom2016";
4
+ import XML from "./patches/xmlPatch";
5
+ import { Network } from "./services/blockchain";
6
+ import { GetBlockchainTrackResult } from "./services/blockchain/liquid";
7
+ import { ValidateOptions, ValidateResult } from "./validations/types";
8
+ import Transfer from "./transfer";
9
+ export declare type AssetValidation = {
10
+ isValid: boolean;
11
+ error_code?: "integrity" | "inconsistent_with_blockchain" | "not_found";
12
+ };
13
+ export interface FromXMLResponse {
14
+ document: Document;
15
+ xmljs: any;
16
+ xmlOriginalHash: string;
17
+ xmlHash: string;
18
+ xml: XML;
19
+ validate: (options: ValidateOptions) => Promise<ValidateResult>;
20
+ }
21
+ export default class Document {
22
+ pdf_content: string;
23
+ signers: any;
24
+ errors: any;
25
+ conservancyRecord: ConservancyRecord | ConservancyRecordNom2016;
26
+ recordPresent: boolean;
27
+ contentType: string;
28
+ name: string;
29
+ version: string;
30
+ encrypted: boolean;
31
+ transfersXml: any;
32
+ originalHash: string;
33
+ originalXmlHash: string;
34
+ tracked: boolean;
35
+ destroyed: boolean;
36
+ blockchainTrack: GetBlockchainTrackResult;
37
+ blockchainBinding: any;
38
+ currentHolder: any;
39
+ prevHolder: any;
40
+ assetId: string;
41
+ network: Network;
42
+ electronicDocument: any;
43
+ constructor(file: any, options: any);
44
+ setConservancyRecord(data: any): void;
45
+ fileBuffer(): Buffer;
46
+ pdfBuffer(): Buffer;
47
+ file(format: any): string;
48
+ setFile(file: string): void;
49
+ toXML(eDocument: any): any;
50
+ pdf(format: any): string;
51
+ addSigner(signer: any): any;
52
+ signatures(): any;
53
+ validSignatures(): boolean;
54
+ transfers(): Promise<Transfer[]>;
55
+ isSimpleTrackedDocument(rootCertificates: any): any;
56
+ isValidHashInTrackedDocument(rootCertificates: any): {
57
+ isValid: boolean;
58
+ error_code: string;
59
+ } | {
60
+ isValid: boolean;
61
+ error_code?: undefined;
62
+ };
63
+ validHashInBlockchainBinding(rootCertificates: any, hash: string): boolean;
64
+ getStatusTrackedDocument(rootCertificates: any): "error" | "updated" | "not_updated";
65
+ isValidAssetId(rootCertificates: any): AssetValidation;
66
+ static getOptsToInitializeDocument: ({ xml, prevHolder, useTestnet, isOriginalDocument, }: {
67
+ xml: any;
68
+ prevHolder?: any;
69
+ useTestnet?: boolean;
70
+ isOriginalDocument?: boolean;
71
+ }) => Promise<{
72
+ electronicDocument: any;
73
+ signers: any;
74
+ version: any;
75
+ name: any;
76
+ encrypted: any;
77
+ contentType: any;
78
+ conservancyRecord: any;
79
+ blockchainTrack: any;
80
+ tracked: any;
81
+ destroyed: boolean;
82
+ transfersXml: any;
83
+ blockchainBinding: any;
84
+ currentHolder: any;
85
+ prevHolder: any;
86
+ assetId: any;
87
+ network: any;
88
+ }>;
89
+ static fromXml(xmlString: any, useTestnet?: boolean): Promise<FromXMLResponse>;
90
+ }
package/errors.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ export declare class InvalidSignerError extends Error {
2
+ constructor(...args: any[]);
3
+ }
4
+ export declare class CertificateError extends Error {
5
+ constructor(...args: any[]);
6
+ }
7
+ export declare class ArgumentError extends Error {
8
+ constructor(...args: any[]);
9
+ }
10
+ export declare class InvalidRecordError extends Error {
11
+ constructor(...args: any[]);
12
+ }
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "xml-fiesta-types",
3
+ "version": "1.8.0",
4
+ "description": "TypeScript definitions for xml-fiesta",
5
+ "types": "declare-module.d.ts",
6
+ "files": [
7
+ "**/*.d.ts"
8
+ ],
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/Mifiel/xml-fiesta-js.git"
12
+ },
13
+ "keywords": [
14
+ "xml-fiesta",
15
+ "typescript",
16
+ "types"
17
+ ],
18
+ "author": "Jesús López <alejandro@mifiel.com>",
19
+ "license": "MIT",
20
+ "bugs": {
21
+ "url": "https://github.com/Mifiel/xml-fiesta-js/issues"
22
+ },
23
+ "homepage": "https://github.com/Mifiel/xml-fiesta-js#readme"
24
+ }
@@ -0,0 +1,4 @@
1
+ import XML from "../xml";
2
+ export default class PatchedXML extends XML {
3
+ static removeGeolocation(xmljs: any): void;
4
+ }
@@ -0,0 +1,5 @@
1
+ import Liquid from "./liquid";
2
+ export declare type Network = "LBTC" | "LTC";
3
+ export declare class Blockchain {
4
+ static init: (network: Network) => Liquid;
5
+ }
@@ -0,0 +1,27 @@
1
+ declare type GetTxDataResult = {
2
+ index: number;
3
+ address: string;
4
+ };
5
+ declare type GetTxOutspentsResult = {
6
+ spent: boolean;
7
+ txid: string;
8
+ };
9
+ export declare type GetTransfersByTxIdResult = {
10
+ prevTxid: string;
11
+ txid: string;
12
+ prevAddress: string;
13
+ currentAddress: string;
14
+ };
15
+ export declare type GetBlockchainTrackResult = {
16
+ asset: string;
17
+ transfers: GetTransfersByTxIdResult[];
18
+ };
19
+ export default class Liquid {
20
+ private BASE_URL;
21
+ useTestnet(): void;
22
+ getTxData: (txid: string, asset: string) => Promise<GetTxDataResult>;
23
+ getTxtOutspents: (txid: string) => Promise<GetTxOutspentsResult[]>;
24
+ getTransfersByTxId: (asset: string, txid: string, prevAddress?: string, prevTxid?: string) => Promise<GetTransfersByTxIdResult[]>;
25
+ getBlockchainTrack: (asset: string) => Promise<GetBlockchainTrackResult>;
26
+ }
27
+ export {};
package/signature.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ import Certificate from "./certificate";
2
+ export default class Signature {
3
+ signature: string;
4
+ ePassInfo: any;
5
+ ePassContent: string;
6
+ signedAt: string;
7
+ email: string;
8
+ certificate: Certificate;
9
+ signer: {
10
+ id: string;
11
+ name: string;
12
+ email: string;
13
+ };
14
+ constructor(cer: any, signature: any, signedAt: any, email: any, ePassInfo: any, name?: string);
15
+ ePass(format: any): string;
16
+ sig(format: any): string;
17
+ valid(hash: any): boolean;
18
+ }
package/transfer.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ import Document, { AssetValidation } from "./document";
2
+ import { GetTransfersByTxIdResult } from "./services/blockchain/liquid";
3
+ import XML from "./xml";
4
+ export default class Transfer extends Document {
5
+ prevAddress: string;
6
+ currentAddress: string;
7
+ dataBlockchain: GetTransfersByTxIdResult;
8
+ xml: XML;
9
+ constructor(xml: any, options: any, transferData: any);
10
+ validEndorser(rootCertificates: any): AssetValidation;
11
+ validEndorsee(rootCertificates: any): AssetValidation;
12
+ validateHolderBinding(holder: any, rootCertificates: any): boolean;
13
+ }
@@ -0,0 +1,3 @@
1
+ import { RootCertificate, TrackedValidationResult } from "../types";
2
+ import { ParsedInstanceLike } from "../validate";
3
+ export declare const validateTrackedXml: (instance: ParsedInstanceLike, rootCertificates: RootCertificate[]) => Promise<TrackedValidationResult>;
@@ -0,0 +1,3 @@
1
+ import { RootCertificate, TransferValidationResult } from "../types";
2
+ import { ParsedInstanceLike } from "../validate";
3
+ export declare const validateTransfers: (instance: ParsedInstanceLike, rootCertificates: RootCertificate[]) => Promise<TransferValidationResult[]>;
@@ -0,0 +1,7 @@
1
+ export * from "./types";
2
+ export * from "./validate";
3
+ export * from "./standard/validate-document";
4
+ export * from "./standard/validate-signatures";
5
+ export * from "./standard/validate-standard-xml";
6
+ export * from "./endorsement/validate-tracked-xml";
7
+ export * from "./endorsement/validate-transfers";
@@ -0,0 +1,3 @@
1
+ import { DocumentValidationResult } from "../types";
2
+ import { ParsedInstanceLike } from "../validate";
3
+ export declare const validateDocument: (instance: ParsedInstanceLike) => Promise<DocumentValidationResult>;
@@ -0,0 +1,3 @@
1
+ import { RootCertificate, SignatureValidationResult } from "../types";
2
+ import Document from "../../document";
3
+ export declare const validateSignatures: (document: Document, rootCertificates: RootCertificate[]) => SignatureValidationResult[];
@@ -0,0 +1,3 @@
1
+ import { RootCertificate, StandardValidationResult } from "../types";
2
+ import { ParsedInstanceLike } from "../validate";
3
+ export declare const validateStandardXml: (instance: ParsedInstanceLike, rootCertificates: RootCertificate[]) => Promise<StandardValidationResult>;
@@ -0,0 +1,56 @@
1
+ import Transfer from "../transfer";
2
+ import Document from "../document";
3
+ import Signature from "../signature";
4
+ import { AssetValidation } from "../document";
5
+ export declare type RootCertificate = {
6
+ cer_hex: string;
7
+ };
8
+ export declare type SignatureValidationResult = {
9
+ certificateNumber: string;
10
+ certificateNumberIsValid: boolean;
11
+ fielIsValid: boolean;
12
+ isValid: boolean;
13
+ metadata: Signature;
14
+ };
15
+ export declare type DocumentValidationResult = {
16
+ isValid: boolean;
17
+ oHashValid: boolean;
18
+ conservancyRecordPresent: boolean;
19
+ timestampsMatch: boolean;
20
+ archiveHashValid: boolean;
21
+ metadata: Document;
22
+ };
23
+ export declare type StandardValidationResult = {
24
+ isValid: boolean;
25
+ document: DocumentValidationResult;
26
+ signatures: SignatureValidationResult[];
27
+ };
28
+ export declare type TransferValidationResult = {
29
+ transferIsValid: boolean;
30
+ transfer: Transfer;
31
+ endorser: AssetValidation;
32
+ endorsee: AssetValidation;
33
+ document: DocumentValidationResult;
34
+ signatures: SignatureValidationResult[];
35
+ };
36
+ export declare type TrackedValidationResult = {
37
+ isValid: boolean;
38
+ showLimitData: boolean;
39
+ oHashValid: boolean;
40
+ asset: AssetValidation;
41
+ document: DocumentValidationResult;
42
+ signatures: SignatureValidationResult[];
43
+ transfers?: TransferValidationResult[];
44
+ };
45
+ export declare type ValidateOptions = {
46
+ rootCertificates: RootCertificate[];
47
+ };
48
+ export declare type ValidateResult = {
49
+ mode: "standard";
50
+ isValid: boolean;
51
+ standard: StandardValidationResult;
52
+ } | {
53
+ mode: "tracked";
54
+ isValid: boolean;
55
+ tracked: TrackedValidationResult;
56
+ };
@@ -0,0 +1,9 @@
1
+ import { ValidateOptions, ValidateResult } from "./types";
2
+ import Document from "../document";
3
+ import XML from "../xml";
4
+ export declare type ParsedInstanceLike = {
5
+ xml?: XML;
6
+ document: Document;
7
+ xmlOriginalHash?: string;
8
+ };
9
+ export declare const validateParsedXml: (parsed: ParsedInstanceLike, options: ValidateOptions) => Promise<ValidateResult>;
@@ -0,0 +1,16 @@
1
+ import Certificate from "./certificate";
2
+ import Document from "./document";
3
+ import Signature from "./signature";
4
+ import ConservancyRecord from "./conservancyRecord";
5
+ import ConservancyRecordNom2016 from "./conservancyRecordNom2016";
6
+ import XML from "./xml";
7
+ import * as validations from "./validations";
8
+ import { InvalidSignerError, CertificateError, ArgumentError, InvalidRecordError } from "./errors";
9
+ declare const version: any;
10
+ declare const errors: {
11
+ InvalidSignerError: typeof InvalidSignerError;
12
+ CertificateError: typeof CertificateError;
13
+ ArgumentError: typeof ArgumentError;
14
+ InvalidRecordError: typeof InvalidRecordError;
15
+ };
16
+ export { Certificate, Document, Signature, ConservancyRecord, ConservancyRecordNom2016, XML, validations, errors, version, };
package/xml.d.ts ADDED
@@ -0,0 +1,40 @@
1
+ /// <reference types="node" />
2
+ export default class XML {
3
+ eDocument: any;
4
+ signed: boolean;
5
+ version: any;
6
+ version_int: any;
7
+ fileElementName: any;
8
+ encrypted: any;
9
+ name: any;
10
+ contentType: any;
11
+ originalHash: any;
12
+ tracked: boolean;
13
+ destroyed: boolean;
14
+ nameSpaces: any;
15
+ static parse(string: any): Promise<XML>;
16
+ static parseByElectronicDocument(electronicDocument: any): XML;
17
+ static toXML(eDocument: any, file: string): any;
18
+ static removeEncrypedData(xmljs: any): void;
19
+ static removeGeolocation(xmljs: any): void;
20
+ static removeBlockchain(xmljs: any): void;
21
+ static removeTransfer(xmljs: any): void;
22
+ static detectNamespacePrefix(xmlString: string): string | null;
23
+ static createAttrNameStripper(xmlString: string): (name: string) => string;
24
+ static removeSignersCertificate(xmljs: any): void;
25
+ parseByElectronicDocument(electronicDocument: any): XML;
26
+ parse(xml: any): Promise<XML>;
27
+ canonical(electronicDocumentAttributes?: {}): any;
28
+ getCanonicalBuffer(electronicDocumentAttributes: any): Buffer;
29
+ file(): any;
30
+ pdf(): any;
31
+ xmlSigners(): any[];
32
+ getConservancyRecord(): {
33
+ caCert: any;
34
+ userCert: any;
35
+ record: any;
36
+ timestamp: any;
37
+ originalXmlHash: string;
38
+ version: any;
39
+ };
40
+ }