diff --git a/types/lib/condition.d.ts b/types/lib/condition.d.ts index 6672987..680d4b1 100644 --- a/types/lib/condition.d.ts +++ b/types/lib/condition.d.ts @@ -1,4 +1,4 @@ -import { Asn1Json, TypeAsn1Condition } from '../types'; +import { TypeAsn1Condition } from '../types'; export interface ConditionAsn1Json { type: TypeAsn1Condition; @@ -54,7 +54,7 @@ export default class Condition { serializeBinary(): Buffer; - getAsn1Json(): Asn1Json; + getAsn1Json(): ConditionAsn1Json; validate(): boolean; } diff --git a/types/lib/fulfillment.d.ts b/types/lib/fulfillment.d.ts index 4c20375..9b02095 100644 --- a/types/lib/fulfillment.d.ts +++ b/types/lib/fulfillment.d.ts @@ -6,7 +6,9 @@ import { ThresholdSha256Json, TypeAsn1Fulfillment, TypeName, + TypeId, } from '../types'; +import Condition from './condition'; interface FulfillmentAsn1JsonValueMap { [TypeAsn1Fulfillment.PreimageSha256]: PreimageSha256Json; @@ -32,7 +34,7 @@ export default class Fulfillment { json: PreimageSha256Json | PrefixSha256Json | ThresholdSha256Json | RsaSha256Json | Ed25519Sha256Json ): Fulfillment; - getTypeId(): TypeIds; + getTypeId(): TypeId; getTypeName(): TypeName; @@ -60,5 +62,5 @@ export default class Fulfillment { serializeBase64Url(): string; - validate(): boolean; + validate(message?: Buffer): boolean; } diff --git a/types/types/ed25519-sha256.d.ts b/types/types/ed25519-sha256.d.ts index 901b28a..832132d 100644 --- a/types/types/ed25519-sha256.d.ts +++ b/types/types/ed25519-sha256.d.ts @@ -9,17 +9,25 @@ import type { } from '.'; import type BaseSha256 from './base-sha256'; +export const TYPE_ID: TypeId.Ed25519Sha256; +export const TYPE_NAME: TypeName.Ed25519Sha256; +export const TYPE_ASN1_CONDITION: TypeAsn1Condition.Ed25519Sha256; +export const TYPE_ASN1_FULFILLMENT: TypeAsn1Fulfillment.Ed25519Sha256; +export const TYPE_CATEGORY: TypeCategory.Ed25519Sha256; + +export const TYPE_ID = TypeId.Ed25519Sha256; +export const CONSTANT_COST = 131072; export default class Ed25519Sha256 extends BaseSha256 { private publicKey: Buffer; private signature: Buffer; - static TYPE_ID = TypeId.Ed25519Sha256; - static TYPE_NAME = TypeName.Ed25519Sha256; - static TYPE_ASN1_CONDITION = TypeAsn1Condition.Ed25519Sha256; - static TYPE_ASN1_FULFILLMENT = TypeAsn1Fulfillment.Ed25519Sha256; - static TYPE_CATEGORY = TypeCategory.Ed25519Sha256; + static TYPE_ID: TypeId.Ed25519Sha256; + static TYPE_NAME: TypeName.Ed25519Sha256; + static TYPE_ASN1_CONDITION: TypeAsn1Condition.Ed25519Sha256; + static TYPE_ASN1_FULFILLMENT: TypeAsn1Fulfillment.Ed25519Sha256; + static TYPE_CATEGORY: TypeCategory.Ed25519Sha256; - static CONSTANT_COST = 131072; + static CONSTANT_COST: number; constructor(); diff --git a/types/types/prefix-sha256.d.ts b/types/types/prefix-sha256.d.ts index 8602d1f..91f8eb4 100644 --- a/types/types/prefix-sha256.d.ts +++ b/types/types/prefix-sha256.d.ts @@ -11,19 +11,28 @@ import type Condition from '../lib/condition'; import type Fulfillment from '../lib/fulfillment'; import type BaseSha256 from './base-sha256'; +export const TYPE_ID = TypeId.PrefixSha256; +export const TYPE_NAME: TypeName.PrefixSha256; +export const TYPE_ASN1_CONDITION: TypeAsn1Condition.PrefixSha256; +export const TYPE_ASN1_FULFILLMENT: TypeAsn1Fulfillment.PrefixSha256; +export const TYPE_CATEGORY: TypeCategory.PrefixSha256; + +export const CONSTANT_BASE_COST = 16384; +export const CONSTANT_COST_DIVISOR = 256; + export default class PrefixSha256 extends BaseSha256 { private prefix: Buffer; private subcondition: Condition | Fulfillment; private maxMessageLength: number; - static TYPE_ID = TypeId.PrefixSha256; - static TYPE_NAME = TypeName.PrefixSha256; - static TYPE_ASN1_CONDITION = TypeAsn1Condition.PrefixSha256; - static TYPE_ASN1_FULFILLMENT = TypeAsn1Fulfillment.PrefixSha256; - static TYPE_CATEGORY = TypeCategory.PrefixSha256; + static TYPE_ID: TypeId.PrefixSha256; + static TYPE_NAME: TypeName.PrefixSha256; + static TYPE_ASN1_CONDITION: TypeAsn1Condition.PrefixSha256; + static TYPE_ASN1_FULFILLMENT: TypeAsn1Fulfillment.PrefixSha256; + static TYPE_CATEGORY: TypeCategory.PrefixSha256; - static CONSTANT_BASE_COST = 16384; - static CONSTANT_COST_DIVISOR = 256; + static CONSTANT_BASE_COST: number; + static CONSTANT_COST_DIVISOR: number; constructor(); diff --git a/types/types/preimage-sha256.d.ts b/types/types/preimage-sha256.d.ts index 2b5a341..98d994d 100644 --- a/types/types/preimage-sha256.d.ts +++ b/types/types/preimage-sha256.d.ts @@ -9,14 +9,20 @@ import type { } from '.'; import type BaseSha256 from './base-sha256'; +export const TYPE_ID = TypeId.PreimageSha256; +export const TYPE_NAME = TypeName.PreimageSha256; +export const TYPE_ASN1_CONDITION = TypeAsn1Condition.PreimageSha256; +export const TYPE_ASN1_FULFILLMENT = TypeAsn1Fulfillment.PreimageSha256; +export const TYPE_CATEGORY = TypeCategory.PreimageSha256; + export default class PreimageSha256 extends BaseSha256 { private preimage: Buffer; - static TYPE_ID = TypeId.PreimageSha256; - static TYPE_NAME = TypeName.PreimageSha256; - static TYPE_ASN1_CONDITION = TypeAsn1Condition.PreimageSha256; - static TYPE_ASN1_FULFILLMENT = TypeAsn1Fulfillment.PreimageSha256; - static TYPE_CATEGORY = TypeCategory.PreimageSha256; + static TYPE_ID: TypeId.PreimageSha256; + static TYPE_NAME: TypeName.PreimageSha256; + static TYPE_ASN1_CONDITION: TypeAsn1Condition.PreimageSha256; + static TYPE_ASN1_FULFILLMENT: TypeAsn1Fulfillment.PreimageSha256; + static TYPE_CATEGORY: TypeCategory.PreimageSha256; private getFingerprintContents(): Buffer; diff --git a/types/types/rsa-sha256.d.ts b/types/types/rsa-sha256.d.ts index 2a4c669..9e0209e 100644 --- a/types/types/rsa-sha256.d.ts +++ b/types/types/rsa-sha256.d.ts @@ -8,17 +8,25 @@ import type { } from '.'; import type BaseSha256 from './base-sha256'; +export const TYPE_ID = TypeId.RsaSha256; +export const TYPE_NAME = TypeName.RsaSha256; +export const TYPE_ASN1_CONDITION = TypeAsn1Condition.RsaSha256; +export const TYPE_ASN1_FULFILLMENT = TypeAsn1Fulfillment.RsaSha256; +export const TYPE_CATEGORY = TypeCategory.RsaSha256; + +export const COST_RIGHT_SHIFT = 6; // 2^6 = 64 + export default class RsaSha256 extends BaseSha256 { private modulus: Buffer; private signature: Buffer; - static TYPE_ID = TypeId.RsaSha256; - static TYPE_NAME = TypeName.RsaSha256; - static TYPE_ASN1_CONDITION = TypeAsn1Condition.RsaSha256; - static TYPE_ASN1_FULFILLMENT = TypeAsn1Fulfillment.RsaSha256; - static TYPE_CATEGORY = TypeCategory.RsaSha256; + static TYPE_ID: TypeId.RsaSha256; + static TYPE_NAME: TypeName.RsaSha256; + static TYPE_ASN1_CONDITION: TypeAsn1Condition.RsaSha256; + static TYPE_ASN1_FULFILLMENT: TypeAsn1Fulfillment.RsaSha256; + static TYPE_CATEGORY: TypeCategory.RsaSha256; - static COST_RIGHT_SHIFT = 6; // 2^6 = 64 + static COST_RIGHT_SHIFT: number; constructor(); diff --git a/types/types/threshold-sha256.d.ts b/types/types/threshold-sha256.d.ts index cd93593..35a0831 100644 --- a/types/types/threshold-sha256.d.ts +++ b/types/types/threshold-sha256.d.ts @@ -11,8 +11,8 @@ import type Condition from '../lib/condition'; import type Fulfillment from '../lib/fulfillment'; import type BaseSha256 from './base-sha256'; -declare const CONDITION = 'condition'; -declare const FULFILLMENT = 'fulfillment'; +export const CONDITION = 'condition'; +export const FULFILLMENT = 'fulfillment'; interface SubConditionBodyMap { condition: Condition; @@ -24,15 +24,21 @@ export type SubCondition = { body: SubConditionBodyMap[T]; }; +export const TYPE_ID = TypeId.ThresholdSha256; +export const TYPE_NAME = TypeName.ThresholdSha256; +export const TYPE_ASN1_CONDITION = TypeAsn1Condition.ThresholdSha256; +export const TYPE_ASN1_FULFILLMENT = TypeAsn1Fulfillment.ThresholdSha256; +export const TYPE_CATEGORY = TypeCategory.ThresholdSha256; + export default class ThresholdSha256 extends BaseSha256 { private threshold: number; private subconditions: SubCondition[]; - static TYPE_ID = TypeId.ThresholdSha256; - static TYPE_NAME = TypeName.ThresholdSha256; - static TYPE_ASN1_CONDITION = TypeAsn1Condition.ThresholdSha256; - static TYPE_ASN1_FULFILLMENT = TypeAsn1Fulfillment.ThresholdSha256; - static TYPE_CATEGORY = TypeCategory.ThresholdSha256; + static TYPE_ID: TypeId.ThresholdSha256; + static TYPE_NAME: TypeName.ThresholdSha256; + static TYPE_ASN1_CONDITION: TypeAsn1Condition.ThresholdSha256; + static TYPE_ASN1_FULFILLMENT: TypeAsn1Fulfillment.ThresholdSha256; + static TYPE_CATEGORY: TypeCategory.ThresholdSha256; constructor();