fix: add missing .js suffix in imports

This commit is contained in:
Richard Ramos 2022-12-06 22:36:03 -04:00
parent b60bc1af1e
commit 4c219c031a
No known key found for this signature in database
GPG Key ID: BD36D48BC9FFC88C
9 changed files with 36 additions and 35 deletions

View File

@ -38,6 +38,7 @@
"engines": {
"node": ">=16"
},
"moduleResolution": "node16",
"license": "Apache-2.0 OR MIT",
"publishConfig": {
"access": "public",

View File

@ -3,8 +3,8 @@ import { proto_message } from "js-waku";
import { Decoder, Encoder, Message, ProtoMessage } from "js-waku/lib/interfaces";
import { MessageV0 } from "js-waku/lib/waku_message/version_0";
import { HandshakeResult, HandshakeStepResult } from "./handshake";
import { PayloadV2 } from "./payload";
import { HandshakeResult, HandshakeStepResult } from "./handshake.js";
import { PayloadV2 } from "./payload.js";
const log = debug("waku:message:noise-encoder");

View File

@ -4,12 +4,12 @@ import { equals as uint8ArrayEquals } from "uint8arrays/equals";
import { bytes32 } from "./@types/basic";
import { KeyPair } from "./@types/keypair";
import { getHKDFRaw } from "./crypto";
import { HandshakeState, NoisePaddingBlockSize } from "./handshake_state";
import { CipherState } from "./noise";
import { HandshakePattern, PayloadV2ProtocolIDs } from "./patterns";
import { MessageNametagBuffer, PayloadV2, toMessageNametag } from "./payload";
import { NoisePublicKey } from "./publickey";
import { getHKDFRaw } from "./crypto.js";
import { HandshakeState, NoisePaddingBlockSize } from "./handshake_state.js";
import { CipherState } from "./noise.js";
import { HandshakePattern, PayloadV2ProtocolIDs } from "./patterns.js";
import { MessageNametagBuffer, PayloadV2, toMessageNametag } from "./payload.js";
import { NoisePublicKey } from "./publickey.js";
// Noise state machine

View File

@ -6,7 +6,7 @@ import { MessageNametag } from "./@types/handshake.js";
import type { KeyPair } from "./@types/keypair.js";
import { Curve25519KeySize, dh, generateX25519KeyPair, getHKDF, intoCurve25519Key } from "./crypto.js";
import { SymmetricState } from "./noise.js";
import { EmptyPreMessage, HandshakePattern, MessageDirection, NoiseTokens, PreMessagePattern } from "./patterns";
import { EmptyPreMessage, HandshakePattern, MessageDirection, NoiseTokens, PreMessagePattern } from "./patterns.js";
import { NoisePublicKey } from "./publickey.js";
// The padding blocksize of a transport message
@ -208,7 +208,7 @@ export class HandshakeState {
// If user is reading the "e" token
if (reading) {
console.trace("noise pre-message read e");
console.debug("noise pre-message read e");
// We check if current key is encrypted or not. We assume pre-message public keys are all unencrypted on users' end
if (currPK.flag == 0) {
@ -220,7 +220,7 @@ export class HandshakeState {
}
// If user is writing the "e" token
} else if (writing) {
console.trace("noise pre-message write e");
console.debug("noise pre-message write e");
// When writing, the user is sending a public key,
// We check that the public part corresponds to the set local key and we call MixHash(e.public_key).
@ -252,7 +252,7 @@ export class HandshakeState {
// If user is reading the "s" token
if (reading) {
console.trace("noise pre-message read s");
console.debug("noise pre-message read s");
// We check if current key is encrypted or not. We assume pre-message public keys are all unencrypted on users' end
if (currPK.flag == 0) {
@ -265,7 +265,7 @@ export class HandshakeState {
// If user is writing the "s" token
} else if (writing) {
console.trace("noise pre-message write s");
console.debug("noise pre-message write s");
// If writing, it means that the user is sending a public key,
// We check that the public part corresponds to the set local key and we call MixHash(s.public_key).
@ -345,7 +345,7 @@ export class HandshakeState {
case NoiseTokens.e:
// If user is reading the "s" token
if (reading) {
console.trace("noise read e");
console.debug("noise read e");
// We expect an ephemeral key, so we attempt to read it (next PK to process will always be at index 0 of preMessagePKs)
if (inHandshakeMessage.length > 0) {
@ -384,7 +384,7 @@ export class HandshakeState {
// If user is writing the "e" token
} else if (writing) {
console.trace("noise write e");
console.debug("noise write e");
// We generate a new ephemeral keypair
this.e = generateX25519KeyPair();
@ -408,7 +408,7 @@ export class HandshakeState {
case NoiseTokens.s:
// If user is reading the "s" token
if (reading) {
console.trace("noise read s");
console.debug("noise read s");
// We expect a static key, so we attempt to read it (next PK to process will always be at index 0 of preMessagePKs)
if (inHandshakeMessage.length > 0) {
@ -436,7 +436,7 @@ export class HandshakeState {
// If user is writing the "s" token
} else if (writing) {
console.trace("noise write s");
console.debug("noise write s");
// If the local static key is not set (the handshake state was not properly initialized), we raise an error
if (!this.s) {
@ -462,7 +462,7 @@ export class HandshakeState {
case NoiseTokens.psk:
// If user is reading the "psk" token
console.trace("noise psk");
console.debug("noise psk");
// Calls MixKeyAndHash(psk)
this.ss.mixKeyAndHash(this.psk);
@ -471,7 +471,7 @@ export class HandshakeState {
case NoiseTokens.ee:
// If user is reading the "ee" token
console.trace("noise dh ee");
console.debug("noise dh ee");
// If local and/or remote ephemeral keys are not set, we raise an error
if (!this.e || !this.re) {
@ -485,7 +485,7 @@ export class HandshakeState {
case NoiseTokens.es:
// If user is reading the "es" token
console.trace("noise dh es");
console.debug("noise dh es");
// We check if keys are correctly set.
// If both present, we call MixKey(DH(e, rs)) if initiator, MixKey(DH(s, re)) if responder.
@ -507,7 +507,7 @@ export class HandshakeState {
case NoiseTokens.se:
// If user is reading the "se" token
console.trace("noise dh se");
console.debug("noise dh se");
// We check if keys are correctly set.
// If both present, call MixKey(DH(s, re)) if initiator, MixKey(DH(e, rs)) if responder.
@ -529,7 +529,7 @@ export class HandshakeState {
case NoiseTokens.ss:
// If user is reading the "ss" token
console.trace("noise dh ss");
console.debug("noise dh ss");
// If local and/or remote static keys are not set, we raise an error
if (!this.s || !this.rs) {

View File

@ -83,7 +83,7 @@ export class CipherState {
this.n.increment();
this.n.assertValue();
console.trace("encryptWithAd", ciphertext, this.n.getUint64() - 1);
console.debug("encryptWithAd", ciphertext, this.n.getUint64() - 1);
} else {
// Otherwise we return the input plaintext according to specification http://www.noiseprotocol.org/noise.html#the-cipherstate-object
ciphertext = plaintext;
@ -191,7 +191,7 @@ export class SymmetricState {
// We update ck and the Cipher state's key k using the output of HDKF
this.cs = new CipherState(tempK);
this.ck = ck;
console.trace("mixKey", this.ck, this.cs.k);
console.debug("mixKey", this.ck, this.cs.k);
}
// MixHash as per Noise specification http://www.noiseprotocol.org/noise.html#the-symmetricstate-object
@ -199,7 +199,7 @@ export class SymmetricState {
mixHash(data: Uint8Array): void {
// We hash the previous handshake hash and input data and store the result in the Symmetric State's handshake hash value
this.h = hashSHA256(uint8ArrayConcat([this.h, data]));
console.trace("mixHash", this.h);
console.debug("mixHash", this.h);
}
// mixKeyAndHash as per Noise specification http://www.noiseprotocol.org/noise.html#the-symmetricstate-object

View File

@ -1,4 +1,4 @@
import type { bytes, uint64 } from "./@types/basic";
import type { bytes, uint64 } from "./@types/basic.js";
export const MIN_NONCE = 0;
// For performance reasons, the nonce is represented as a JS `number`

View File

@ -5,11 +5,11 @@
import { concat as uint8ArrayConcat } from "uint8arrays/concat";
import { equals as uint8ArrayEquals } from "uint8arrays/equals";
import { MessageNametag } from "./@types/handshake";
import { ChachaPolyTagLen, Curve25519KeySize, hashSHA256 } from "./crypto";
import { PayloadV2ProtocolIDs } from "./patterns";
import { NoisePublicKey } from "./publickey";
import { readUIntLE, writeUIntLE } from "./utils";
import { MessageNametag } from "./@types/handshake.js";
import { ChachaPolyTagLen, Curve25519KeySize, hashSHA256 } from "./crypto.js";
import { PayloadV2ProtocolIDs } from "./patterns.js";
import { NoisePublicKey } from "./publickey.js";
import { readUIntLE, writeUIntLE } from "./utils.js";
export const MessageNametagLength = 16;
export const MessageNametagBufferSize = 50;

View File

@ -1,9 +1,9 @@
import { concat as uint8ArrayConcat } from "uint8arrays/concat";
import { equals as uint8ArrayEquals } from "uint8arrays/equals";
import { bytes32 } from "./@types/basic";
import { chaCha20Poly1305Decrypt, chaCha20Poly1305Encrypt } from "./crypto";
import { isEmptyKey } from "./noise";
import { bytes32 } from "./@types/basic.js";
import { chaCha20Poly1305Decrypt, chaCha20Poly1305Encrypt } from "./crypto.js";
import { isEmptyKey } from "./noise.js";
// A ChaChaPoly Cipher State containing key (k), nonce (nonce) and associated data (ad)
export class ChaChaPolyCipherState {

View File

@ -1,6 +1,6 @@
import { decode, encode, fromUint8Array, toUint8Array } from "js-base64";
import { bytes32 } from "./@types/basic";
import { bytes32 } from "./@types/basic.js";
export class QR {
constructor(