Options
All
  • Public
  • Public/Protected
  • All
Menu

relaynet-core-js

Known Vulnerabilities npm

JavaScript library for the core of Relaynet. Read the docs online.

Index

Classes

Interfaces

Type aliases

Variables

Functions

Type aliases

CargoMessageSetItem

CargoMessageSetItem: Parcel | ParcelCollectionAck

CargoMessageStream

CargoMessageStream: AsyncIterable<{ expiryDate: Date; message: Buffer }>

ECDHCurveName

ECDHCurveName: "P-256" | "P-384" | "P-521"

FindIssuerSignature

FindIssuerSignature: (cert: pkijs.Certificate, engine: pkijs.CertificateChainValidationEngine) => Promise<keyof pkijs.Certificate[]>

Type declaration

    • (cert: pkijs.Certificate, engine: pkijs.CertificateChainValidationEngine): Promise<keyof pkijs.Certificate[]>
    • Parameters

      • cert: pkijs.Certificate
      • engine: pkijs.CertificateChainValidationEngine

      Returns Promise<keyof pkijs.Certificate[]>

LocalCargoId

LocalCargoId: string

The local id of the cargo to be delivered.

It can be a file name or DB primary key, for example.

PrivateKeyData

Variables

Const AES_KEY_SIZES

AES_KEY_SIZES: ReadonlyArray<number> = [128, 192, 256]

Const ASN1_SCHEMA

ASN1_SCHEMA: Sequence = new asn1js.Sequence({name: 'RAMFMessage',value: ['recipientAddress', 'id', 'date', 'ttl', 'payload'].map((name, tagNumber) =>new asn1js.Primitive({idBlock: { tagClass: 3, tagNumber },name,optional: false,} as any),),} as any)

Const AUTHORITY_KEY

AUTHORITY_KEY: "2.5.29.35" = "2.5.29.35"

Const BASIC_CONSTRAINTS

BASIC_CONSTRAINTS: "2.5.29.19" = "2.5.29.19"

Const CMS_ATTR_CONTENT_TYPE

CMS_ATTR_CONTENT_TYPE: "1.2.840.113549.1.9.3" = "1.2.840.113549.1.9.3"

Const CMS_ATTR_DIGEST

CMS_ATTR_DIGEST: "1.2.840.113549.1.9.4" = "1.2.840.113549.1.9.4"

Const CMS_DATA

CMS_DATA: "1.2.840.113549.1.7.1" = "1.2.840.113549.1.7.1"

Const CMS_ENVELOPED_DATA

CMS_ENVELOPED_DATA: "1.2.840.113549.1.7.3" = "1.2.840.113549.1.7.3"

Const CMS_SIGNED_DATA

CMS_SIGNED_DATA: "1.2.840.113549.1.7.2" = "1.2.840.113549.1.7.2"

Const COMMON_NAME

COMMON_NAME: "2.5.4.3" = "2.5.4.3"

ASN.1 Object Ids.

Const DEFAULT_TTL_SECONDS

DEFAULT_TTL_SECONDS: number = 5 * 60

Const DER_TL_OVERHEAD_OCTETS

DER_TL_OVERHEAD_OCTETS: 5 = 5

Number of octets needed to represent the type and length of an 8 MiB value in DER.

Const FORMAT_SIGNATURE_PARSER

FORMAT_SIGNATURE_PARSER: Parser<{} & {} & {}> = new Parser().endianess('little').string('magic', { length: 8, assert: 'Relaynet' }).uint8('concreteMessageType').uint8('concreteMessageVersion')

Const MAX_DH_CERT_LENGTH_DAYS

MAX_DH_CERT_LENGTH_DAYS: 60 = 60

Const MAX_DH_CERT_LENGTH_MS

MAX_DH_CERT_LENGTH_MS: number = MAX_DH_CERT_LENGTH_DAYS * SECONDS_PER_DAY * 1_000

Const MAX_ID_LENGTH

MAX_ID_LENGTH: 64 = 64

Const MAX_MESSAGE_LENGTH

MAX_MESSAGE_LENGTH: 9437184 = 9437184

Const MAX_PATH_LENGTH_CONSTRAINT

MAX_PATH_LENGTH_CONSTRAINT: 2 = 2

Const MAX_PAYLOAD_LENGTH

MAX_PAYLOAD_LENGTH: number = 2 ** 23 - 1

Const MAX_RECIPIENT_ADDRESS_LENGTH

MAX_RECIPIENT_ADDRESS_LENGTH: 1024 = 1024

Const MAX_SDU_PLAINTEXT_LENGTH

MAX_SDU_PLAINTEXT_LENGTH: 8322048 = 8322048

Maximum length of any SDU to be encapsulated in a CMS EnvelopedData value, per the RAMF spec.

Const MAX_TTL

MAX_TTL: 15552000 = 15552000

Const MAX_TYPE_LENGTH

MAX_TYPE_LENGTH: number = 2 ** 8 - 1

Const MAX_VALUE_LENGTH

MAX_VALUE_LENGTH: number = 2 ** 23 - 1

Const PARSER

PARSER: Parser<{} & {} & {} & {}> = new Parser().endianess('little').uint8('messageTypeLength').string('messageType', { length: 'messageTypeLength', encoding: 'utf8' }).uint32('messageLength').buffer('message', { length: 'messageLength' })

Const PRIVATE_ADDRESS_REGEX

PRIVATE_ADDRESS_REGEX: RegExp = /^[a-f0-9]+$/

Const RELAYNET_ORIGINATOR_EPHEMERAL_CERT_SERIAL_NUMBER

RELAYNET_ORIGINATOR_EPHEMERAL_CERT_SERIAL_NUMBER: "0.4.0.127.0.17.0.1.0" = "0.4.0.127.0.17.0.1.0"

Const SECONDS_PER_DAY

SECONDS_PER_DAY: 86400 = 86400

Const SIGNATURE_PREFIX

SIGNATURE_PREFIX: Buffer = Buffer.from('Relaynet')

Const SUBJECT_KEY

SUBJECT_KEY: "2.5.29.14" = "2.5.29.14"

Const concreteMessageTypeOctet

concreteMessageTypeOctet: 68 = 68

Const concreteMessageVersionOctet

concreteMessageVersionOctet: 0 = 0

Const crypto

crypto: Crypto = new Crypto()

Const cryptoEngine

cryptoEngine: any = new CryptoEngine({crypto,name: 'nodeEngine',subtle: crypto.subtle,})

Const pkijsCrypto

pkijsCrypto: SubtleCrypto = getPkijsCrypto()

Functions

cloneAsn1jsValue

computePrivateNodeAddress

  • computePrivateNodeAddress(publicKey: CryptoKey): Promise<string>

convertBufferMessagesToArrayBuffer

decimalToHex

  • decimalToHex(numberDecimal: number): string

derDeserialize

  • derDeserialize(derValue: ArrayBuffer): asn1js.LocalBaseBlock

derDeserializeECDHPrivateKey

  • derDeserializeECDHPrivateKey(privateKeyDer: Buffer, curveName?: NamedCurve): Promise<CryptoKey>
  • Parse DER-serialized ECDH private key.

    Parameters

    • privateKeyDer: Buffer
    • Default value curveName: NamedCurve = "P-256"

    Returns Promise<CryptoKey>

derDeserializeECDHPublicKey

  • derDeserializeECDHPublicKey(publicKeyDer: Buffer, curveName?: NamedCurve): Promise<CryptoKey>
  • Parse DER-serialized ECDH public key.

    Parameters

    • publicKeyDer: Buffer
    • Default value curveName: NamedCurve = "P-256"

    Returns Promise<CryptoKey>

derDeserializeRSAPrivateKey

  • derDeserializeRSAPrivateKey(privateKeyDer: Buffer, algorithmOptions: RsaHashedImportParams): Promise<CryptoKey>
  • Parse DER-serialized RSA private key.

    Parameters

    • privateKeyDer: Buffer
    • algorithmOptions: RsaHashedImportParams

    Returns Promise<CryptoKey>

derDeserializeRSAPublicKey

  • derDeserializeRSAPublicKey(publicKeyDer: Buffer, algorithmOptions: RsaHashedImportParams): Promise<CryptoKey>
  • Parse DER-serialized RSA public key.

    Parameters

    • publicKeyDer: Buffer
    • algorithmOptions: RsaHashedImportParams

    Returns Promise<CryptoKey>

derSerializePrivateKey

  • derSerializePrivateKey(privateKey: CryptoKey): Promise<Buffer>

derSerializePublicKey

  • derSerializePublicKey(publicKey: CryptoKey): Promise<Buffer>

deserialize

  • deserialize<M>(serialization: ArrayBuffer, concreteMessageTypeOctet: number, concreteMessageVersionOctet: number, messageClass: {}): Promise<M>
  • Type parameters

    Parameters

    • serialization: ArrayBuffer
    • concreteMessageTypeOctet: number
    • concreteMessageVersionOctet: number
    • messageClass: {}

    Returns Promise<M>

deserializeContentInfo

  • deserializeContentInfo(derValue: ArrayBuffer): pkijs.ContentInfo

extractOriginatorKeyId

  • extractOriginatorKeyId(envelopedData: pkijs.EnvelopedData): Buffer

extractSignedDataContent

  • extractSignedDataContent(encapContentInfo: pkijs.EncapsulatedContentInfo): ArrayBuffer

generateECDHKeyPair

  • generateECDHKeyPair(curveName?: ECDHCurveName): Promise<CryptoKeyPair>

generateFormatSignature

  • generateFormatSignature(concreteMessageType: number, concreteMessageVersion: number): Uint8Array

generateRSAKeyPair

  • generateRSAKeyPair(__namedParameters?: { hashingAlgorithm: string; modulus: number }): Promise<CryptoKeyPair>
  • Generate an RSA key pair

    throws

    Error If the modulus or the hashing algorithm is disallowed by RS-018.

    Parameters

    • Default value __namedParameters: { hashingAlgorithm: string; modulus: number } = {}
      • hashingAlgorithm: string

        The hashing algorithm (e.g., SHA-256, SHA-384, SHA-512).

      • modulus: number

        The RSA modulus for the keys (2048 or greater).

    Returns Promise<CryptoKeyPair>

generateRandom64BitValue

  • generateRandom64BitValue(): ArrayBuffer

getAesKeySize

  • getAesKeySize(aesKeySize: number | undefined): number

getDateFromPrimitiveBlock

  • getDateFromPrimitiveBlock(block: asn1js.Primitive): Date

getIntegerFromPrimitiveBlock

  • getIntegerFromPrimitiveBlock(block: asn1js.Primitive): number

getOrMakePkijsCertificate

getPkijsCrypto

  • getPkijsCrypto(): SubtleCrypto

getPublicKeyDigest

  • getPublicKeyDigest(publicKey: CryptoKey): Promise<ArrayBuffer>

getPublicKeyDigestHex

  • getPublicKeyDigestHex(publicKey: CryptoKey): Promise<string>

getSecondsBetweenDates

  • getSecondsBetweenDates(date: Date, expiryDate: Date): number

initSignerInfo

  • initSignerInfo(signerCertificate: Certificate, digest: ArrayBuffer): pkijs.SignerInfo

isCertificateInArray

issueDeliveryAuthorization

issueEndpointCertificate

issueGatewayCertificate

issueInitialDHKeyCertificate

  • Issue an initial (EC)DH certificate to initiate a channel session.

    The subject must be the node initiating the session and the issue must be the recipient of the initial message.

    Parameters

    Returns Promise<Certificate>

issueNodeCertificate

makeAuthorityKeyIdExtension

  • makeAuthorityKeyIdExtension(publicKey: CryptoKey): Promise<pkijs.Extension>

makeBasicConstraintsExtension

  • makeBasicConstraintsExtension(cA: boolean, pathLenConstraint: number): pkijs.Extension

makeSubjectKeyIdExtension

  • makeSubjectKeyIdExtension(publicKey: CryptoKey): Promise<pkijs.Extension>

parseMessageFields

parseMessageFormatSignature

pkijsDecrypt

  • pkijsDecrypt(envelopedData: pkijs.EnvelopedData, privateKey: CryptoKey, dhCertificate?: pkijs.Certificate): Promise<ArrayBuffer>

serialize

  • serialize(message: RAMFMessage<any>, concreteMessageTypeOctet: number, concreteMessageVersionOctet: number, senderPrivateKey: CryptoKey, signatureOptions?: Partial<SignatureOptions>): Promise<ArrayBuffer>
  • Sign and encode the current message.

    Parameters

    • message: RAMFMessage<any>

      The message to serialize.

    • concreteMessageTypeOctet: number
    • concreteMessageVersionOctet: number
    • senderPrivateKey: CryptoKey

      The private key to sign the message.

    • Optional signatureOptions: Partial<SignatureOptions>

      Any signature options.

    Returns Promise<ArrayBuffer>

sign

  • Generate DER-encoded CMS SignedData signature for plaintext.

    throws

    CMSError when attempting to use SHA-1 as the hashing function

    Parameters

    Returns Promise<ArrayBuffer>

validateFileFormatSignature

  • validateFileFormatSignature(messageFields: MessageFormatSignature, concreteMessageTypeOctet: number, concreteMessageVersionOctet: number): void

validateIssuerCertificate

  • validateIssuerCertificate(issuerCertificate: Certificate): void

validateMessageIdLength

  • validateMessageIdLength(messageId: string): void

validateMessageLength

  • validateMessageLength(serialization: ArrayBuffer): void

validatePayloadLength

  • validatePayloadLength(payloadBuffer: ArrayBuffer): void

validateRecipientAddress

  • validateRecipientAddress(recipientAddress: string): void

validateRecipientAddressLength

  • validateRecipientAddressLength(recipientAddress: string): void

validateTtl

  • validateTtl(ttl: number): void

verifySignature

  • Verify CMS SignedData signature.

    The CMS SignedData value must have the signer's certificate attached. CA certificates may also be attached.

    throws

    {CMSError} If signature could not be decoded or verified.

    Parameters

    • cmsSignedDataSerialized: ArrayBuffer

      The CMS SignedData signature, DER-encoded.

    Returns Promise<SignatureVerification>

    Signer's certificate chain, starting with the signer's certificate

Legend

Generated using TypeDoc