New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@relaycorp/relaynet-core

Package Overview
Dependencies
Maintainers
2
Versions
293
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@relaycorp/relaynet-core - npm Package Compare versions

Comparing version 1.27.0 to 1.27.1

71

build/main/lib/ramf/serialization.js

@@ -16,2 +16,4 @@ "use strict";

const buffer_to_arraybuffer_1 = __importDefault(require("buffer-to-arraybuffer"));
const moment_1 = __importDefault(require("moment"));
const util_1 = require("util");
const cmsSignedData = __importStar(require("../crypto_wrappers/cms/signedData"));

@@ -37,10 +39,7 @@ const formatSignature_1 = require("../messages/formatSignature");

name: 'RAMFMessage',
// @ts-ignore
value: [
new asn1js.VisibleString({ name: 'recipientAddress' }),
new asn1js.VisibleString({ name: 'id' }),
new asn1js.DateTime({ name: 'date' }),
new asn1js.Integer({ name: 'ttl' }),
new asn1js.OctetString({ name: 'payload' }),
],
value: ['recipientAddress', 'id', 'date', 'ttl', 'payload'].map((name, tagNumber) => new asn1js.Primitive({
idBlock: { tagClass: 3, tagNumber },
name,
optional: false,
})),
});

@@ -64,16 +63,32 @@ /**

const formatSignature = formatSignature_1.generateFormatSignature(concreteMessageTypeOctet, concreteMessageVersionOctet);
const serializationBeforeSignature = new asn1js.Sequence({
const utcDateString = moment_1.default.utc(message.date).format('YYYYMMDDHHmmss');
const ttlBlock = new asn1js.Integer({ value: message.ttl });
const textEncoder = new util_1.TextEncoder();
const fieldSetSerialized = new asn1js.Sequence({
// @ts-ignore
value: [
new asn1js.VisibleString({ value: message.recipientAddress }),
new asn1js.VisibleString({ value: message.id }),
new asn1js.DateTime(
// @ts-ignore
{ value: message.date }),
new asn1js.Integer({ value: message.ttl }),
new asn1js.OctetString({ valueHex: buffer_to_arraybuffer_1.default(message.payloadSerialized) }),
new asn1js.Primitive({
idBlock: { tagClass: 3, tagNumber: 0 },
valueHex: textEncoder.encode(message.recipientAddress),
}),
new asn1js.Primitive({
idBlock: { tagClass: 3, tagNumber: 1 },
valueHex: textEncoder.encode(message.id),
}),
new asn1js.Primitive({
idBlock: { tagClass: 3, tagNumber: 2 },
valueHex: textEncoder.encode(utcDateString),
}),
new asn1js.Primitive({
idBlock: { tagClass: 3, tagNumber: 3 },
valueHex: ttlBlock.valueBlock.valueHex,
}),
new asn1js.Primitive({
idBlock: { tagClass: 3, tagNumber: 4 },
valueHex: buffer_to_arraybuffer_1.default(message.payloadSerialized),
}),
],
}).toBER(false);
//region Signature
const signature = await cmsSignedData.sign(serializationBeforeSignature, senderPrivateKey, message.senderCertificate, message.senderCaCertificateChain, signatureOptions);
const signature = await cmsSignedData.sign(fieldSetSerialized, senderPrivateKey, message.senderCertificate, message.senderCaCertificateChain, signatureOptions);
//endregion

@@ -178,11 +193,23 @@ // There doesn't seem to be an efficient way to concatenate ArrayBuffer instances, so we'll have

const messageBlock = result.result.RAMFMessage;
const textDecoder = new util_1.TextDecoder();
return {
date: new Date(messageBlock.date.valueBlock.value),
id: messageBlock.id.valueBlock.value,
date: getDateFromPrimitiveBlock(messageBlock.date),
id: textDecoder.decode(messageBlock.id.valueBlock.valueHex),
payload: Buffer.from(messageBlock.payload.valueBlock.valueHex),
recipientAddress: messageBlock.recipientAddress.valueBlock.value,
ttl: get32UIntFromIntegerBlock(messageBlock.ttl),
recipientAddress: textDecoder.decode(messageBlock.recipientAddress.valueBlock.valueHex),
ttl: getIntegerFromPrimitiveBlock(messageBlock.ttl),
};
}
function get32UIntFromIntegerBlock(integerBlock) {
function getDateFromPrimitiveBlock(block) {
const dateString = new util_1.TextDecoder().decode(block.valueBlock.valueHex) + 'Z';
try {
const generalizedTimeBlock = new asn1js.GeneralizedTime({ value: dateString });
return generalizedTimeBlock.toDate();
}
catch (error) {
throw new RAMFValidationError_1.default(error, 'Message date is not serialized as an ASN.1 DATE-TIME');
}
}
function getIntegerFromPrimitiveBlock(block) {
const integerBlock = new asn1js.Integer({ valueHex: block.valueBlock.valueHex });
if (!integerBlock.valueBlock.isHexOnly) {

@@ -189,0 +216,0 @@ return integerBlock.valueBlock.valueDec;

import * as asn1js from 'asn1js';
import { Parser } from 'binary-parser';
import bufferToArray from 'buffer-to-arraybuffer';
import moment from 'moment';
import { TextDecoder, TextEncoder } from 'util';
import * as cmsSignedData from '../crypto_wrappers/cms/signedData';

@@ -24,10 +26,7 @@ import { generateFormatSignature } from '../messages/formatSignature';

name: 'RAMFMessage',
// @ts-ignore
value: [
new asn1js.VisibleString({ name: 'recipientAddress' }),
new asn1js.VisibleString({ name: 'id' }),
new asn1js.DateTime({ name: 'date' }),
new asn1js.Integer({ name: 'ttl' }),
new asn1js.OctetString({ name: 'payload' }),
],
value: ['recipientAddress', 'id', 'date', 'ttl', 'payload'].map((name, tagNumber) => new asn1js.Primitive({
idBlock: { tagClass: 3, tagNumber },
name,
optional: false,
})),
});

@@ -51,16 +50,32 @@ /**

const formatSignature = generateFormatSignature(concreteMessageTypeOctet, concreteMessageVersionOctet);
const serializationBeforeSignature = new asn1js.Sequence({
const utcDateString = moment.utc(message.date).format('YYYYMMDDHHmmss');
const ttlBlock = new asn1js.Integer({ value: message.ttl });
const textEncoder = new TextEncoder();
const fieldSetSerialized = new asn1js.Sequence({
// @ts-ignore
value: [
new asn1js.VisibleString({ value: message.recipientAddress }),
new asn1js.VisibleString({ value: message.id }),
new asn1js.DateTime(
// @ts-ignore
{ value: message.date }),
new asn1js.Integer({ value: message.ttl }),
new asn1js.OctetString({ valueHex: bufferToArray(message.payloadSerialized) }),
new asn1js.Primitive({
idBlock: { tagClass: 3, tagNumber: 0 },
valueHex: textEncoder.encode(message.recipientAddress),
}),
new asn1js.Primitive({
idBlock: { tagClass: 3, tagNumber: 1 },
valueHex: textEncoder.encode(message.id),
}),
new asn1js.Primitive({
idBlock: { tagClass: 3, tagNumber: 2 },
valueHex: textEncoder.encode(utcDateString),
}),
new asn1js.Primitive({
idBlock: { tagClass: 3, tagNumber: 3 },
valueHex: ttlBlock.valueBlock.valueHex,
}),
new asn1js.Primitive({
idBlock: { tagClass: 3, tagNumber: 4 },
valueHex: bufferToArray(message.payloadSerialized),
}),
],
}).toBER(false);
//region Signature
const signature = await cmsSignedData.sign(serializationBeforeSignature, senderPrivateKey, message.senderCertificate, message.senderCaCertificateChain, signatureOptions);
const signature = await cmsSignedData.sign(fieldSetSerialized, senderPrivateKey, message.senderCertificate, message.senderCaCertificateChain, signatureOptions);
//endregion

@@ -163,11 +178,23 @@ // There doesn't seem to be an efficient way to concatenate ArrayBuffer instances, so we'll have

const messageBlock = result.result.RAMFMessage;
const textDecoder = new TextDecoder();
return {
date: new Date(messageBlock.date.valueBlock.value),
id: messageBlock.id.valueBlock.value,
date: getDateFromPrimitiveBlock(messageBlock.date),
id: textDecoder.decode(messageBlock.id.valueBlock.valueHex),
payload: Buffer.from(messageBlock.payload.valueBlock.valueHex),
recipientAddress: messageBlock.recipientAddress.valueBlock.value,
ttl: get32UIntFromIntegerBlock(messageBlock.ttl),
recipientAddress: textDecoder.decode(messageBlock.recipientAddress.valueBlock.valueHex),
ttl: getIntegerFromPrimitiveBlock(messageBlock.ttl),
};
}
function get32UIntFromIntegerBlock(integerBlock) {
function getDateFromPrimitiveBlock(block) {
const dateString = new TextDecoder().decode(block.valueBlock.valueHex) + 'Z';
try {
const generalizedTimeBlock = new asn1js.GeneralizedTime({ value: dateString });
return generalizedTimeBlock.toDate();
}
catch (error) {
throw new RAMFValidationError(error, 'Message date is not serialized as an ASN.1 DATE-TIME');
}
}
function getIntegerFromPrimitiveBlock(block) {
const integerBlock = new asn1js.Integer({ valueHex: block.valueBlock.valueHex });
if (!integerBlock.valueBlock.isHexOnly) {

@@ -174,0 +201,0 @@ return integerBlock.valueBlock.valueDec;

{
"name": "@relaycorp/relaynet-core",
"version": "1.27.0",
"version": "1.27.1",
"author": {

@@ -47,2 +47,3 @@ "email": "no-reply@relaycorp.tech",

"buffer-to-arraybuffer": "0.0.5",
"moment": "^2.25.3",
"pkijs": "^2.1.84",

@@ -49,0 +50,0 @@ "smart-buffer": "^4.1.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc