Skip to content

Commit 8623584

Browse files
authored
fix: support Node.js type stripping by importing from .ts files (#3448)
* fix: support Node.js type stripping by importing from .ts files To (for example) run tests without prior typescript compilation, use the .ts extension for relative imports. This is just to speed local development in a future aegir release, the built output of the project does not change.
1 parent 05ad8f9 commit 8623584

306 files changed

Lines changed: 752 additions & 752 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

interop/test/dialer.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable no-console */
22
import { multiaddr } from '@multiformats/multiaddr'
3-
import { getLibp2p } from './fixtures/get-libp2p.js'
4-
import { redisProxy } from './fixtures/redis-proxy.js'
3+
import { getLibp2p } from './fixtures/get-libp2p.ts'
4+
import { redisProxy } from './fixtures/redis-proxy.ts'
55
import type { Libp2p } from '@libp2p/interface'
66
import type { Ping } from '@libp2p/ping'
77

interop/test/listener.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable no-console */
22
import { multiaddr } from '@multiformats/multiaddr'
3-
import { getLibp2p } from './fixtures/get-libp2p.js'
4-
import { redisProxy } from './fixtures/redis-proxy.js'
3+
import { getLibp2p } from './fixtures/get-libp2p.ts'
4+
import { redisProxy } from './fixtures/redis-proxy.ts'
55
import type { Libp2p } from '@libp2p/interface'
66
import type { Ping } from '@libp2p/ping'
77
import type { Multiaddr } from '@multiformats/multiaddr'

packages/config/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@
3737
* ```
3838
*/
3939

40-
export { loadOrCreateSelfKey } from './load-private-key.js'
41-
export type { LoadOrCreateSelfKeyOptions } from './load-private-key.js'
40+
export { loadOrCreateSelfKey } from './load-private-key.ts'
41+
export type { LoadOrCreateSelfKeyOptions } from './load-private-key.ts'

packages/connection-encrypter-plaintext/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { UnexpectedPeerError, InvalidCryptoExchangeError, serviceCapabilities, P
2626
import { peerIdFromPublicKey } from '@libp2p/peer-id'
2727
import { pbStream } from '@libp2p/utils'
2828
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
29-
import { Exchange, KeyType } from './pb/proto.js'
29+
import { Exchange, KeyType } from './pb/proto.ts'
3030
import type { ComponentLogger, Logger, ConnectionEncrypter, SecuredConnection, PrivateKey, SecureConnectionOptions, MessageStream } from '@libp2p/interface'
3131

3232
const PROTOCOL = '/plaintext/2.0.0'

packages/connection-encrypter-tls/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* ```
1919
*/
2020

21-
import { TLS } from './tls.js'
21+
import { TLS } from './tls.ts'
2222
import type { ComponentLogger, ConnectionEncrypter, Metrics, PrivateKey, Upgrader } from '@libp2p/interface'
2323

2424
export const PROTOCOL = '/tls/1.0.0'

packages/connection-encrypter-tls/src/tls.browser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { serviceCapabilities } from '@libp2p/interface'
2-
import { PROTOCOL } from './index.js'
2+
import { PROTOCOL } from './index.ts'
33
import type { MultiaddrConnection, ConnectionEncrypter, SecuredConnection, SecureConnectionOptions, MessageStream } from '@libp2p/interface'
44

55
export class TLS implements ConnectionEncrypter {

packages/connection-encrypter-tls/src/tls.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020

2121
import { TLSSocket, connect } from 'node:tls'
2222
import { InvalidCryptoExchangeError, serviceCapabilities } from '@libp2p/interface'
23-
import { HandshakeTimeoutError } from './errors.js'
24-
import { generateCertificate, verifyPeerCertificate, toNodeDuplex, toMessageStream } from './utils.js'
25-
import { PROTOCOL } from './index.js'
26-
import type { TLSComponents } from './index.js'
23+
import { HandshakeTimeoutError } from './errors.ts'
24+
import { PROTOCOL } from './index.ts'
25+
import { generateCertificate, verifyPeerCertificate, toNodeDuplex, toMessageStream } from './utils.ts'
26+
import type { TLSComponents } from './index.ts'
2727
import type { ConnectionEncrypter, SecuredConnection, Logger, SecureConnectionOptions, CounterGroup, StreamMuxerFactory, MessageStream } from '@libp2p/interface'
2828
import type { TLSSocketOptions } from 'node:tls'
2929

packages/connection-encrypter-tls/src/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import { Uint8ArrayList } from 'uint8arraylist'
1616
import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
1717
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
1818
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
19-
import { InvalidCertificateError } from './errors.js'
20-
import { KeyType, PublicKey } from './pb/index.js'
19+
import { InvalidCertificateError } from './errors.ts'
20+
import { KeyType, PublicKey } from './pb/index.ts'
2121
import type { PeerId, PublicKey as Libp2pPublicKey, Logger, PrivateKey, AbortOptions, MessageStream, StreamCloseEvent } from '@libp2p/interface'
2222
import type { SendResult } from '@libp2p/utils'
2323

packages/connection-encrypter-tls/test/utils.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { pEvent } from 'p-event'
99
import { stubInterface } from 'sinon-ts'
1010
import { Uint8ArrayList } from 'uint8arraylist'
1111
import { toMessageStream, toNodeDuplex, verifyPeerCertificate } from '../src/utils.js'
12-
import * as testVectors from './fixtures/test-vectors.js'
12+
import * as testVectors from './fixtures/test-vectors.ts'
1313

1414
const crypto = new Crypto()
1515
x509.cryptoProvider.set(crypto)

packages/crypto/src/ciphers/aes-gcm.browser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { concat } from 'uint8arrays/concat'
22
import { fromString } from 'uint8arrays/from-string'
33
import webcrypto from '../webcrypto/index.js'
4-
import type { CreateAESCipherOptions, AESCipher } from './interface.js'
4+
import type { CreateAESCipherOptions, AESCipher } from './interface.ts'
55

66
// WebKit on Linux does not support deriving a key from an empty PBKDF2 key.
77
// So, as a workaround, we provide the generated key as a constant. We test that

0 commit comments

Comments
 (0)