diff --git a/.prettierrc.cjs b/.prettierrc.cjs index 8b7eda62e..eeedeb8c0 100644 --- a/.prettierrc.cjs +++ b/.prettierrc.cjs @@ -4,5 +4,17 @@ module.exports = { trailingComma: 'es5', arrowParens: 'always', printWidth: 80, - plugins: ['prettier-plugin-packagejson'], + plugins: [ + 'prettier-plugin-packagejson', + '@ianvs/prettier-plugin-sort-imports', + ], + importOrder: [ + '', + '', + '^@(/.*)$', + '^@test(/.*)$', + '^@bench(/.*)$', + '^[.]', + ], + importOrderTypeScriptVersion: '5.4.2', } diff --git a/.vscode/settings.json b/.vscode/settings.json index 34fc55e9b..dba7b13a1 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,6 +6,12 @@ "[typescript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, + "[javascript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[json]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, "editor.tabSize": 2, "editor.detectIndentation": false, "files.insertFinalNewline": true, diff --git a/README.md b/README.md index 46675d946..cd2e4144c 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,7 @@ A client is created with `Client.create(wallet: Signer): Promise` that r ```ts import { Client } from '@xmtp/xmtp-js' + // Create the client with a `Signer` from your application const xmtp = await Client.create(wallet) ``` @@ -124,6 +125,7 @@ Most of the time, when interacting with the network, you'll want to do it throug ```ts import { Client } from '@xmtp/xmtp-js' + // Create the client with a `Signer` from your application const xmtp = await Client.create(wallet) const conversations = xmtp.conversations @@ -341,6 +343,7 @@ Additional codecs can be configured through the `ClientOptions` parameter of `Cl ```ts // Adding support for `xmtp.org/composite` content type import { CompositeCodec } from '@xmtp/xmtp-js' + const xmtp = Client.create(wallet, { codecs: [new CompositeCodec()] }) ``` @@ -370,6 +373,7 @@ You can export the unencrypted key bundle using the static method `Client.getKey ```ts import { Client } from '@xmtp/xmtp-js' + // Get the keys using a valid Signer. Save them somewhere secure. const keys = await Client.getKeys(wallet) // Create a client using keys returned from getKeys diff --git a/bench/decode.ts b/bench/decode.ts index 598bcf1af..4cda96231 100644 --- a/bench/decode.ts +++ b/bench/decode.ts @@ -1,5 +1,9 @@ +import { fetcher } from '@xmtp/proto' +import { add } from 'benny' import { ConversationV1, ConversationV2 } from '@/conversations/Conversation' +import { SignedPublicKeyBundle } from '@/crypto/PublicKeyBundle' import { MessageV1 } from '@/Message' +import { dateToNs } from '@/utils/date' import { newLocalHostClient } from '@test/helpers' import { MESSAGE_SIZES, @@ -7,10 +11,6 @@ import { randomBytes, wrapSuite, } from './helpers' -import { add } from 'benny' -import { fetcher } from '@xmtp/proto' -import { dateToNs } from '@/utils/date' -import { SignedPublicKeyBundle } from '@/crypto/PublicKeyBundle' const decodeV1 = () => { return MESSAGE_SIZES.map((size) => diff --git a/bench/encode.ts b/bench/encode.ts index 4d37849fd..3b1da38d7 100644 --- a/bench/encode.ts +++ b/bench/encode.ts @@ -1,16 +1,16 @@ +import { add } from 'benny' +import Client from '@/Client' import { ConversationV2 } from '@/conversations/Conversation' +import { SignedPublicKeyBundle } from '@/crypto/PublicKeyBundle' import { MessageV1 } from '@/Message' -import { add } from 'benny' -import { newWallet, newLocalHostClient } from '@test/helpers' +import { dateToNs } from '@/utils/date' +import { newLocalHostClient, newWallet } from '@test/helpers' import { MESSAGE_SIZES, newPrivateKeyBundle, randomBytes, wrapSuite, } from './helpers' -import Client from '@/Client' -import { dateToNs } from '@/utils/date' -import { SignedPublicKeyBundle } from '@/crypto/PublicKeyBundle' const encodeV1 = () => { return MESSAGE_SIZES.map((size) => diff --git a/bench/helpers.ts b/bench/helpers.ts index 467b03ca7..abad46c2d 100644 --- a/bench/helpers.ts +++ b/bench/helpers.ts @@ -1,5 +1,5 @@ import type Benchmark from 'benchmark' -import { suite, save, cycle } from 'benny' +import { cycle, save, suite } from 'benny' import type { Config } from 'benny/lib/internal/common-types' import crypto from '@/crypto/crypto' import { PrivateKeyBundleV1 } from '@/crypto/PrivateKeyBundle' diff --git a/bench/index.ts b/bench/index.ts index fce2bbbc3..1fc4f5672 100644 --- a/bench/index.ts +++ b/bench/index.ts @@ -1,5 +1,5 @@ -import encodeSuite from './encode' import decodeSuite from './decode' +import encodeSuite from './encode' const main = async () => { await encodeSuite() diff --git a/package.json b/package.json index 2a76f8ce8..35859b40b 100644 --- a/package.json +++ b/package.json @@ -108,6 +108,7 @@ "devDependencies": { "@commitlint/cli": "19.0.3", "@commitlint/config-conventional": "19.0.3", + "@ianvs/prettier-plugin-sort-imports": "^4.2.0", "@metamask/providers": "^14.0.2", "@rollup/plugin-json": "^6.1.0", "@rollup/plugin-terser": "^0.4.4", diff --git a/rollup.config.bench.js b/rollup.config.bench.js index b43fdd26a..a485194b6 100644 --- a/rollup.config.bench.js +++ b/rollup.config.bench.js @@ -1,6 +1,6 @@ -import { defineConfig } from 'rollup' -import typescript from '@rollup/plugin-typescript' import json from '@rollup/plugin-json' +import typescript from '@rollup/plugin-typescript' +import { defineConfig } from 'rollup' import tsConfigPaths from 'rollup-plugin-tsconfig-paths' const external = [ diff --git a/rollup.config.js b/rollup.config.js index 692cd147b..58cc23295 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,10 +1,10 @@ -import { defineConfig } from 'rollup' -import typescript from '@rollup/plugin-typescript' -import { dts } from 'rollup-plugin-dts' -import filesize from 'rollup-plugin-filesize' import json from '@rollup/plugin-json' import terser from '@rollup/plugin-terser' +import typescript from '@rollup/plugin-typescript' import { resolveExtensions } from '@xmtp/rollup-plugin-resolve-extensions' +import { defineConfig } from 'rollup' +import { dts } from 'rollup-plugin-dts' +import filesize from 'rollup-plugin-filesize' import tsConfigPaths from 'rollup-plugin-tsconfig-paths' const external = [ diff --git a/src/ApiClient.ts b/src/ApiClient.ts index 562af03d7..fe9d23006 100644 --- a/src/ApiClient.ts +++ b/src/ApiClient.ts @@ -1,14 +1,15 @@ import { messageApi } from '@xmtp/proto' import type { NotifyStreamEntityArrival } from '@xmtp/proto/ts/dist/types/fetch.pb' -import AuthCache from './authn/AuthCache' import type { Authenticator } from '@/authn/interfaces' +import { retry, sleep } from '@/utils/async' +import { b64Decode } from '@/utils/bytes' +import { toNanoString } from '@/utils/date' // eslint-disable-next-line no-restricted-syntax import { version } from '../package.json' +import AuthCache from './authn/AuthCache' import { XMTP_DEV_WARNING } from './constants' import type { Flatten } from './utils/typedefs' -import { b64Decode } from '@/utils/bytes' -import { retry, sleep } from '@/utils/async' -import { toNanoString } from '@/utils/date' + export const { MessageApi, SortDirection } = messageApi const RETRY_SLEEP_TIME = 100 diff --git a/src/Client.ts b/src/Client.ts index 7e817fdec..1f15a6066 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -1,47 +1,55 @@ -import { PrivateKeyBundleV1 } from './crypto/PrivateKeyBundle' -import type { Signer } from './types/Signer' +import { messageApi, content as proto } from '@xmtp/proto' +import { getAddress, type WalletClient } from 'viem' +import KeystoreAuthenticator from '@/authn/KeystoreAuthenticator' import Conversations from '@/conversations/Conversations' +import { + PublicKeyBundle, + SignedPublicKeyBundle, +} from '@/crypto/PublicKeyBundle' +import BrowserStoragePersistence from '@/keystore/persistence/BrowserStoragePersistence' +import InMemoryPersistence from '@/keystore/persistence/InMemoryPersistence' +import type { Persistence } from '@/keystore/persistence/interface' +import { KeystoreProviderUnavailableError } from '@/keystore/providers/errors' +import KeyGeneratorKeystoreProvider from '@/keystore/providers/KeyGeneratorKeystoreProvider' +import NetworkKeystoreProvider from '@/keystore/providers/NetworkKeystoreProvider' +import SnapProvider from '@/keystore/providers/SnapProvider' +import StaticKeystoreProvider from '@/keystore/providers/StaticKeystoreProvider' +import { + mapPaginatedStream, + type EnvelopeMapper, + type EnvelopeMapperWithMessage, + type EnvelopeWithMessage, +} from '@/utils/async' +import { isBrowser } from '@/utils/browser' +import { buildUserContactTopic, buildUserInviteTopic } from '@/utils/topic' +import { getSigner } from '@/utils/viem' +import HttpApiClient, { + ApiUrls, + SortDirection, + type ApiClient, + type PublishParams, +} from './ApiClient' import { ContentTypeText, TextCodec } from './codecs/Text' -import type { ContentCodec, EncodedContent } from './MessageContent' -import { ContentTypeId } from './MessageContent' import { compress, decompress } from './Compression' -import { content as proto, messageApi } from '@xmtp/proto' import { decodeContactBundle, encodeContactBundle } from './ContactBundle' -import type { ApiClient, PublishParams } from './ApiClient' -import HttpApiClient, { ApiUrls, SortDirection } from './ApiClient' -import KeystoreAuthenticator from '@/authn/KeystoreAuthenticator' -import type { Flatten } from './utils/typedefs' +import { Contacts } from './Contacts' +import { PrivateKeyBundleV1 } from './crypto/PrivateKeyBundle' +import type { KeystoreProvider } from './keystore/providers/interfaces' +import type { KeystoreInterfaces } from './keystore/rpcDefinitions' +import { hasMetamaskWithSnaps } from './keystore/snapHelpers' import type BackupClient from './message-backup/BackupClient' import { BackupType } from './message-backup/BackupClient' import { createBackupClient } from './message-backup/BackupClientFactory' -import type { KeystoreProvider } from './keystore/providers/interfaces' -import { hasMetamaskWithSnaps } from './keystore/snapHelpers' +import { + ContentTypeId, + type ContentCodec, + type EncodedContent, +} from './MessageContent' import { packageName, version } from './snapInfo.json' import type { ExtractDecodedType } from './types/client' -import { getAddress, type WalletClient } from 'viem' -import { Contacts } from './Contacts' -import type { KeystoreInterfaces } from './keystore/rpcDefinitions' -import { isBrowser } from '@/utils/browser' -import { getSigner } from '@/utils/viem' -import { buildUserContactTopic, buildUserInviteTopic } from '@/utils/topic' -import { mapPaginatedStream } from '@/utils/async' -import type { - EnvelopeMapperWithMessage, - EnvelopeMapper, - EnvelopeWithMessage, -} from '@/utils/async' -import type { Persistence } from '@/keystore/persistence/interface' -import BrowserStoragePersistence from '@/keystore/persistence/BrowserStoragePersistence' -import InMemoryPersistence from '@/keystore/persistence/InMemoryPersistence' -import SnapProvider from '@/keystore/providers/SnapProvider' -import StaticKeystoreProvider from '@/keystore/providers/StaticKeystoreProvider' -import NetworkKeystoreProvider from '@/keystore/providers/NetworkKeystoreProvider' -import KeyGeneratorKeystoreProvider from '@/keystore/providers/KeyGeneratorKeystoreProvider' -import { KeystoreProviderUnavailableError } from '@/keystore/providers/errors' -import { - PublicKeyBundle, - SignedPublicKeyBundle, -} from '@/crypto/PublicKeyBundle' +import type { Signer } from './types/Signer' +import type { Flatten } from './utils/typedefs' + const { Compression } = proto // eslint-disable @typescript-eslint/explicit-module-boundary-types diff --git a/src/ContactBundle.ts b/src/ContactBundle.ts index ba2913400..3d2648a1b 100644 --- a/src/ContactBundle.ts +++ b/src/ContactBundle.ts @@ -1,8 +1,8 @@ +import { contact, publicKey } from '@xmtp/proto' import { PublicKeyBundle, SignedPublicKeyBundle, } from '@/crypto/PublicKeyBundle' -import { contact, publicKey } from '@xmtp/proto' // Decodes contact bundles from the contact topic. export function decodeContactBundle( diff --git a/src/Contacts.ts b/src/Contacts.ts index fab40d378..ed8b3e450 100644 --- a/src/Contacts.ts +++ b/src/Contacts.ts @@ -1,11 +1,11 @@ -import type Client from './Client' import { privatePreferences } from '@xmtp/proto' -import Stream from './Stream' -import type { OnConnectionLostCallback } from './ApiClient' -import JobRunner from './conversations/JobRunner' import type { EnvelopeWithMessage } from '@/utils/async' import { fromNanoString } from '@/utils/date' import { buildUserPrivatePreferencesTopic } from '@/utils/topic' +import type { OnConnectionLostCallback } from './ApiClient' +import type Client from './Client' +import JobRunner from './conversations/JobRunner' +import Stream from './Stream' export type ConsentState = 'allowed' | 'denied' | 'unknown' diff --git a/src/Invitation.ts b/src/Invitation.ts index 18c0f46d3..c2889c3b2 100644 --- a/src/Invitation.ts +++ b/src/Invitation.ts @@ -1,13 +1,12 @@ +import { invitation, type messageApi } from '@xmtp/proto' import Long from 'long' -import { SignedPublicKeyBundle } from './crypto/PublicKeyBundle' -import type { messageApi } from '@xmtp/proto' -import { invitation } from '@xmtp/proto' -import crypto from './crypto/crypto' +import { dateToNs } from '@/utils/date' +import { buildDirectMessageTopicV2 } from '@/utils/topic' import Ciphertext from './crypto/Ciphertext' +import crypto from './crypto/crypto' import { decrypt, encrypt } from './crypto/encryption' import type { PrivateKeyBundleV2 } from './crypto/PrivateKeyBundle' -import { buildDirectMessageTopicV2 } from '@/utils/topic' -import { dateToNs } from '@/utils/date' +import { SignedPublicKeyBundle } from './crypto/PublicKeyBundle' export type InvitationContext = { conversationId: string diff --git a/src/Message.ts b/src/Message.ts index 485616241..7ee3e2b2f 100644 --- a/src/Message.ts +++ b/src/Message.ts @@ -1,18 +1,20 @@ -import type { Conversation } from './conversations/Conversation' -import { ConversationV1, ConversationV2 } from './conversations/Conversation' -import type Client from './Client' -import type { conversationReference } from '@xmtp/proto' -import { message as proto } from '@xmtp/proto' +import { message as proto, type conversationReference } from '@xmtp/proto' import Long from 'long' +import { PublicKey } from '@/crypto/PublicKey' +import { PublicKeyBundle } from '@/crypto/PublicKeyBundle' +import type Client from './Client' +import { + ConversationV1, + ConversationV2, + type Conversation, +} from './conversations/Conversation' import Ciphertext from './crypto/Ciphertext' -import { bytesToHex } from './crypto/utils' import { sha256 } from './crypto/encryption' +import { bytesToHex } from './crypto/utils' +import type { KeystoreInterfaces } from './keystore/rpcDefinitions' import type { ContentTypeId } from './MessageContent' import { dateToNs, nsToDate } from './utils/date' import { buildDecryptV1Request, getResultOrThrow } from './utils/keystore' -import type { KeystoreInterfaces } from './keystore/rpcDefinitions' -import { PublicKeyBundle } from '@/crypto/PublicKeyBundle' -import { PublicKey } from '@/crypto/PublicKey' const headerBytesAndCiphertext = ( msg: proto.Message diff --git a/src/PreparedMessage.ts b/src/PreparedMessage.ts index 3b6141bc1..3d0b8cae0 100644 --- a/src/PreparedMessage.ts +++ b/src/PreparedMessage.ts @@ -1,6 +1,6 @@ import type { Envelope } from '@xmtp/proto/ts/dist/types/message_api/v1/message_api.pb' -import { bytesToHex } from './crypto/utils' import { sha256 } from './crypto/encryption' +import { bytesToHex } from './crypto/utils' import type { DecodedMessage } from './Message' export class PreparedMessage { diff --git a/src/Stream.ts b/src/Stream.ts index f210ea961..e7bbff50c 100644 --- a/src/Stream.ts +++ b/src/Stream.ts @@ -1,6 +1,6 @@ +import type { messageApi } from '@xmtp/proto' import type { OnConnectionLostCallback, SubscriptionManager } from './ApiClient' import type Client from './Client' -import type { messageApi } from '@xmtp/proto' export type MessageDecoder = ( env: messageApi.Envelope diff --git a/src/authn/KeystoreAuthenticator.ts b/src/authn/KeystoreAuthenticator.ts index d93cec06f..c8c62bed1 100644 --- a/src/authn/KeystoreAuthenticator.ts +++ b/src/authn/KeystoreAuthenticator.ts @@ -1,10 +1,10 @@ import type { authn } from '@xmtp/proto' -import { dateToNs } from '@/utils/date' -import Token from './Token' import type { KeystoreInterface, KeystoreInterfaces, } from '@/keystore/rpcDefinitions' +import { dateToNs } from '@/utils/date' +import Token from './Token' const wrapToken = (token: authn.Token): Token => { if (token instanceof Token) { diff --git a/src/authn/LocalAuthenticator.ts b/src/authn/LocalAuthenticator.ts index 42f44e20d..6072834a7 100644 --- a/src/authn/LocalAuthenticator.ts +++ b/src/authn/LocalAuthenticator.ts @@ -1,8 +1,8 @@ -import { authn, signature, publicKey } from '@xmtp/proto' -import AuthData from './AuthData' -import Token from './Token' +import { authn, publicKey, signature } from '@xmtp/proto' import { hexToBytes, keccak256 } from 'viem' import type { PrivateKey } from '@/crypto/PrivateKey' +import AuthData from './AuthData' +import Token from './Token' export default class LocalAuthenticator { private identityKey: PrivateKey diff --git a/src/authn/Token.ts b/src/authn/Token.ts index f53ac5324..a133e25e3 100644 --- a/src/authn/Token.ts +++ b/src/authn/Token.ts @@ -1,5 +1,4 @@ -import type { signature, publicKey } from '@xmtp/proto' -import { authn } from '@xmtp/proto' +import { authn, type publicKey, type signature } from '@xmtp/proto' import AuthData from './AuthData' export default class Token implements authn.Token { diff --git a/src/codecs/Composite.ts b/src/codecs/Composite.ts index 4fb3c9fb5..e5a115e6f 100644 --- a/src/codecs/Composite.ts +++ b/src/codecs/Composite.ts @@ -1,10 +1,10 @@ -import type { - ContentCodec, - EncodedContent, - CodecRegistry, -} from '@/MessageContent' -import { ContentTypeId } from '@/MessageContent' import { composite as proto } from '@xmtp/proto' +import { + ContentTypeId, + type CodecRegistry, + type ContentCodec, + type EncodedContent, +} from '@/MessageContent' // xmtp.org/composite // diff --git a/src/codecs/Text.ts b/src/codecs/Text.ts index 2cec5668d..af1ecb461 100644 --- a/src/codecs/Text.ts +++ b/src/codecs/Text.ts @@ -1,5 +1,8 @@ -import type { ContentCodec, EncodedContent } from '@/MessageContent' -import { ContentTypeId } from '@/MessageContent' +import { + ContentTypeId, + type ContentCodec, + type EncodedContent, +} from '@/MessageContent' // xmtp.org/text // diff --git a/src/conversations/Conversation.ts b/src/conversations/Conversation.ts index 7186da781..38f3a6b4d 100644 --- a/src/conversations/Conversation.ts +++ b/src/conversations/Conversation.ts @@ -1,30 +1,34 @@ +import { + message, + content as proto, + type keystore, + type messageApi, +} from '@xmtp/proto' +import { getAddress } from 'viem' import type { OnConnectionLostCallback } from '@/ApiClient' -import Stream from '@/Stream' import type { ListMessagesOptions, ListMessagesPaginatedOptions, SendOptions, } from '@/Client' import type Client from '@/Client' -import type { InvitationContext } from '@/Invitation' -import { DecodedMessage, MessageV1, MessageV2 } from '@/Message' -import type { messageApi, keystore } from '@xmtp/proto' -import { message, content as proto } from '@xmtp/proto' -import { PreparedMessage } from '@/PreparedMessage' -import { sha256 } from '@/crypto/encryption' -import { buildDecryptV1Request, getResultOrThrow } from '@/utils/keystore' import { ContentTypeText } from '@/codecs/Text' import type { ConsentState } from '@/Contacts' -import { getAddress } from 'viem' -import { buildDirectMessageTopic, buildUserIntroTopic } from '@/utils/topic' -import { dateToNs, toNanoString } from '@/utils/date' -import { concat } from '@/utils/bytes' +import { sha256 } from '@/crypto/encryption' +import { SignedPublicKey } from '@/crypto/PublicKey' import { PublicKeyBundle, SignedPublicKeyBundle, } from '@/crypto/PublicKeyBundle' -import { SignedPublicKey } from '@/crypto/PublicKey' import Signature from '@/crypto/Signature' +import type { InvitationContext } from '@/Invitation' +import { DecodedMessage, MessageV1, MessageV2 } from '@/Message' +import { PreparedMessage } from '@/PreparedMessage' +import Stream from '@/Stream' +import { concat } from '@/utils/bytes' +import { dateToNs, toNanoString } from '@/utils/date' +import { buildDecryptV1Request, getResultOrThrow } from '@/utils/keystore' +import { buildDirectMessageTopic, buildUserIntroTopic } from '@/utils/topic' /** * Conversation represents either a V1 or V2 conversation with a common set of methods. diff --git a/src/conversations/Conversations.ts b/src/conversations/Conversations.ts index f74cef0ea..b5ff3f065 100644 --- a/src/conversations/Conversations.ts +++ b/src/conversations/Conversations.ts @@ -1,19 +1,15 @@ -import type { OnConnectionLostCallback } from '@/ApiClient' -import type { messageApi, keystore, conversationReference } from '@xmtp/proto' +import type { conversationReference, keystore, messageApi } from '@xmtp/proto' +import Long from 'long' +import { SortDirection, type OnConnectionLostCallback } from '@/ApiClient' +import type { ListMessagesOptions } from '@/Client' +import type Client from '@/Client' import { PublicKeyBundle, SignedPublicKeyBundle, } from '@/crypto/PublicKeyBundle' -import type { ListMessagesOptions } from '@/Client' import type { InvitationContext } from '@/Invitation' -import type { Conversation } from './Conversation' -import { ConversationV1, ConversationV2 } from './Conversation' -import { MessageV1, DecodedMessage } from '@/Message' +import { DecodedMessage, MessageV1 } from '@/Message' import Stream from '@/Stream' -import type Client from '@/Client' -import { SortDirection } from '@/ApiClient' -import Long from 'long' -import JobRunner from './JobRunner' import { dateToNs, nsToDate } from '@/utils/date' import { buildDirectMessageTopic, @@ -21,6 +17,12 @@ import { buildUserInviteTopic, isValidTopic, } from '@/utils/topic' +import { + ConversationV1, + ConversationV2, + type Conversation, +} from './Conversation' +import JobRunner from './JobRunner' const messageHasHeaders = (msg: MessageV1): boolean => { return Boolean(msg.recipientAddress && msg.senderAddress) diff --git a/src/conversations/JobRunner.ts b/src/conversations/JobRunner.ts index 37592116f..af5abe1af 100644 --- a/src/conversations/JobRunner.ts +++ b/src/conversations/JobRunner.ts @@ -1,8 +1,8 @@ import { keystore } from '@xmtp/proto' import { Mutex } from 'async-mutex' import Long from 'long' -import { dateToNs, nsToDate } from '@/utils/date' import type { KeystoreInterfaces } from '@/keystore/rpcDefinitions' +import { dateToNs, nsToDate } from '@/utils/date' const CLOCK_SKEW_OFFSET_MS = 10000 diff --git a/src/crypto/PrivateKey.ts b/src/crypto/PrivateKey.ts index be2a88724..0c6ba5ed1 100644 --- a/src/crypto/PrivateKey.ts +++ b/src/crypto/PrivateKey.ts @@ -1,11 +1,14 @@ -import { privateKey } from '@xmtp/proto' import * as secp from '@noble/secp256k1' +import { privateKey } from '@xmtp/proto' import Long from 'long' -import type { ECDSACompactWithRecovery, KeySigner } from './Signature' -import Signature, { ecdsaSignerKey } from './Signature' -import { PublicKey, SignedPublicKey, UnsignedPublicKey } from './PublicKey' import type Ciphertext from './Ciphertext' import { decrypt, encrypt, sha256 } from './encryption' +import { PublicKey, SignedPublicKey, UnsignedPublicKey } from './PublicKey' +import Signature, { + ecdsaSignerKey, + type ECDSACompactWithRecovery, + type KeySigner, +} from './Signature' import { equalBytes } from './utils' // SECP256k1 private key diff --git a/src/crypto/PrivateKeyBundle.ts b/src/crypto/PrivateKeyBundle.ts index f2ea25113..0bb16f625 100644 --- a/src/crypto/PrivateKeyBundle.ts +++ b/src/crypto/PrivateKeyBundle.ts @@ -1,10 +1,10 @@ import { privateKey as proto } from '@xmtp/proto' +import type { Signer } from '@/types/Signer' +import { NoMatchingPreKeyError } from './errors' import { PrivateKey, SignedPrivateKey } from './PrivateKey' -import { WalletSigner } from './Signature' import type { PublicKey, SignedPublicKey } from './PublicKey' import { PublicKeyBundle, SignedPublicKeyBundle } from './PublicKeyBundle' -import type { Signer } from '@/types/Signer' -import { NoMatchingPreKeyError } from './errors' +import { WalletSigner } from './Signature' // PrivateKeyBundle bundles the private keys corresponding to a PublicKeyBundle for convenience. // This bundle must not be shared with anyone, although will have to be persisted diff --git a/src/crypto/PublicKey.ts b/src/crypto/PublicKey.ts index 3383de4ec..84f61e6a9 100644 --- a/src/crypto/PublicKey.ts +++ b/src/crypto/PublicKey.ts @@ -1,12 +1,11 @@ -import { publicKey } from '@xmtp/proto' import * as secp from '@noble/secp256k1' +import { publicKey } from '@xmtp/proto' import Long from 'long' -import Signature, { WalletSigner } from './Signature' -import { computeAddress, equalBytes, splitSignature } from './utils' +import { hashMessage, hexToBytes, type Hex } from 'viem' import type { Signer } from '@/types/Signer' import { sha256 } from './encryption' -import type { Hex } from 'viem' -import { hashMessage, hexToBytes } from 'viem' +import Signature, { WalletSigner } from './Signature' +import { computeAddress, equalBytes, splitSignature } from './utils' // SECP256k1 public key in uncompressed format with prefix type secp256k1Uncompressed = { diff --git a/src/crypto/Signature.ts b/src/crypto/Signature.ts index 2beeeef92..f83601df0 100644 --- a/src/crypto/Signature.ts +++ b/src/crypto/Signature.ts @@ -1,12 +1,11 @@ +import * as secp from '@noble/secp256k1' import { signature } from '@xmtp/proto' import Long from 'long' -import * as secp from '@noble/secp256k1' -import { PublicKey, UnsignedPublicKey, SignedPublicKey } from './PublicKey' -import { SignedPrivateKey } from './PrivateKey' +import { hashMessage, hexToBytes, type Hex } from 'viem' import type { Signer } from '@/types/Signer' +import { SignedPrivateKey } from './PrivateKey' +import { PublicKey, SignedPublicKey, UnsignedPublicKey } from './PublicKey' import { bytesToHex, equalBytes, splitSignature } from './utils' -import type { Hex } from 'viem' -import { hashMessage, hexToBytes } from 'viem' // ECDSA signature with recovery bit. export type ECDSACompactWithRecovery = { diff --git a/src/crypto/crypto.ts b/src/crypto/crypto.ts index 862a098a1..8447a2446 100644 --- a/src/crypto/crypto.ts +++ b/src/crypto/crypto.ts @@ -1,4 +1,5 @@ // eslint-disable-next-line no-restricted-syntax import { webcrypto } from 'crypto' + const crypto = webcrypto export default crypto diff --git a/src/crypto/ecies.ts b/src/crypto/ecies.ts index 57d448f06..fb234696d 100644 --- a/src/crypto/ecies.ts +++ b/src/crypto/ecies.ts @@ -5,6 +5,7 @@ */ import elliptic from 'elliptic' import crypto from './crypto' + const EC = elliptic.ec const ec = new EC('secp256k1') diff --git a/src/crypto/selfEncryption.ts b/src/crypto/selfEncryption.ts index dbf13f333..743078c37 100644 --- a/src/crypto/selfEncryption.ts +++ b/src/crypto/selfEncryption.ts @@ -1,4 +1,3 @@ -import type { PrivateKey } from '@/crypto/PrivateKey' import { // eslint-disable-next-line camelcase generate_private_preferences_topic, @@ -7,6 +6,7 @@ import { // eslint-disable-next-line camelcase user_preferences_encrypt, } from '@xmtp/user-preferences-bindings-wasm' +import type { PrivateKey } from '@/crypto/PrivateKey' export async function userPreferencesEncrypt( identityKey: PrivateKey, diff --git a/src/crypto/utils.ts b/src/crypto/utils.ts index c44039f8e..4161eab06 100644 --- a/src/crypto/utils.ts +++ b/src/crypto/utils.ts @@ -1,11 +1,11 @@ import * as secp from '@noble/secp256k1' -import type { Hex } from 'viem' import { getAddress, + hexToBytes, hexToSignature, keccak256, - hexToBytes, bytesToHex as viemBytesToHex, + type Hex, } from 'viem' export const bytesToHex = secp.utils.bytesToHex diff --git a/src/keystore/InMemoryKeystore.ts b/src/keystore/InMemoryKeystore.ts index ac2cd8616..5d8853153 100644 --- a/src/keystore/InMemoryKeystore.ts +++ b/src/keystore/InMemoryKeystore.ts @@ -1,46 +1,51 @@ -import type { authn, privateKey, signature } from '@xmtp/proto' -import { keystore } from '@xmtp/proto' -import type { PrivateKeyBundleV1 } from '@/crypto/PrivateKeyBundle' -import { PrivateKeyBundleV2 } from '@/crypto/PrivateKeyBundle' -import { InvitationV1, SealedInvitation } from '@/Invitation' -import type { TopicData } from './interfaces' -import { decryptV1, encryptV1, encryptV2, decryptV2 } from './encryption' -import { KeystoreError } from './errors' import { - convertError, - mapAndConvertErrors, - toPublicKeyBundle, - toSignedPublicKeyBundle, - validateObject, - getKeyMaterial, - topicDataToV2ConversationReference, -} from './utils' -import type { AddRequest } from './conversationStores' -import { V1Store, V2Store } from './conversationStores' -import type { Persistence } from './persistence/interface' + keystore, + type authn, + type privateKey, + type signature, +} from '@xmtp/proto' +import Long from 'long' import LocalAuthenticator from '@/authn/LocalAuthenticator' -import { hmacSha256Sign } from '@/crypto/ecies' import crypto from '@/crypto/crypto' -import { bytesToHex } from '@/crypto/utils' -import Long from 'long' +import { hmacSha256Sign } from '@/crypto/ecies' +import { + exportHmacKey, + generateHmacSignature, + hkdfHmacKey, +} from '@/crypto/encryption' +import type { PrivateKey } from '@/crypto/PrivateKey' import { + PrivateKeyBundleV2, + type PrivateKeyBundleV1, +} from '@/crypto/PrivateKeyBundle' +import type { PublicKeyBundle } from '@/crypto/PublicKeyBundle' +import { + generateUserPreferencesTopic, userPreferencesDecrypt, userPreferencesEncrypt, - generateUserPreferencesTopic, } from '@/crypto/selfEncryption' +import { bytesToHex } from '@/crypto/utils' +import { InvitationV1, SealedInvitation } from '@/Invitation' import type { KeystoreInterface } from '@/keystore/rpcDefinitions' import { nsToDate } from '@/utils/date' import { buildDirectMessageTopic, buildDirectMessageTopicV2, } from '@/utils/topic' -import type { PrivateKey } from '@/crypto/PrivateKey' -import type { PublicKeyBundle } from '@/crypto/PublicKeyBundle' +import { V1Store, V2Store, type AddRequest } from './conversationStores' +import { decryptV1, decryptV2, encryptV1, encryptV2 } from './encryption' +import { KeystoreError } from './errors' +import type { TopicData } from './interfaces' +import type { Persistence } from './persistence/interface' import { - exportHmacKey, - generateHmacSignature, - hkdfHmacKey, -} from '@/crypto/encryption' + convertError, + getKeyMaterial, + mapAndConvertErrors, + topicDataToV2ConversationReference, + toPublicKeyBundle, + toSignedPublicKeyBundle, + validateObject, +} from './utils' const { ErrorCode } = keystore diff --git a/src/keystore/SnapKeystore.ts b/src/keystore/SnapKeystore.ts index 96c024e61..b4aab996b 100644 --- a/src/keystore/SnapKeystore.ts +++ b/src/keystore/SnapKeystore.ts @@ -1,12 +1,11 @@ -import type { SnapMeta } from './snapHelpers' -import { snapRPC } from './snapHelpers' import type { XmtpEnv } from '@/Client' -import type { - SnapKeystoreApiEntries, - SnapKeystoreApiRequestValues, - SnapKeystoreInterface, +import { + snapApiDefs, + type SnapKeystoreApiEntries, + type SnapKeystoreApiRequestValues, + type SnapKeystoreInterface, } from './rpcDefinitions' -import { snapApiDefs } from './rpcDefinitions' +import { snapRPC, type SnapMeta } from './snapHelpers' export function SnapKeystore( walletAddress: string, diff --git a/src/keystore/conversationStores.ts b/src/keystore/conversationStores.ts index c2b6a3ced..c28d69bc6 100644 --- a/src/keystore/conversationStores.ts +++ b/src/keystore/conversationStores.ts @@ -1,10 +1,9 @@ +import { keystore, type invitation } from '@xmtp/proto' +import { Mutex } from 'async-mutex' import type Long from 'long' -import type { invitation } from '@xmtp/proto' -import { keystore } from '@xmtp/proto' +import { numberToUint8Array, uint8ArrayToNumber } from '@/utils/bytes' import type { Persistence } from './persistence/interface' -import { Mutex } from 'async-mutex' import { isCompleteTopicData, topicDataToMap } from './utils' -import { numberToUint8Array, uint8ArrayToNumber } from '@/utils/bytes' export type AddRequest = { topic: string diff --git a/src/keystore/encryption.ts b/src/keystore/encryption.ts index fa68bf662..e461f729a 100644 --- a/src/keystore/encryption.ts +++ b/src/keystore/encryption.ts @@ -1,7 +1,7 @@ +import type { ciphertext } from '@xmtp/proto' +import { decrypt, encrypt } from '@/crypto/encryption' import type { PrivateKeyBundleV1 } from '@/crypto/PrivateKeyBundle' import type { PublicKeyBundle } from '@/crypto/PublicKeyBundle' -import { encrypt, decrypt } from '@/crypto/encryption' -import type { ciphertext } from '@xmtp/proto' export const decryptV1 = async ( myKeys: PrivateKeyBundleV1, diff --git a/src/keystore/interfaces.ts b/src/keystore/interfaces.ts index 9ab3d3c78..6817d224c 100644 --- a/src/keystore/interfaces.ts +++ b/src/keystore/interfaces.ts @@ -1,8 +1,8 @@ import type { - keystore, - publicKey, authn, + keystore, privateKey, + publicKey, signature, } from '@xmtp/proto' import type { WithoutUndefined } from '@/utils/typedefs' diff --git a/src/keystore/persistence/EncryptedPersistence.ts b/src/keystore/persistence/EncryptedPersistence.ts index f26465052..917b429ef 100644 --- a/src/keystore/persistence/EncryptedPersistence.ts +++ b/src/keystore/persistence/EncryptedPersistence.ts @@ -1,8 +1,7 @@ +import { decrypt, encrypt, getPublic, type Ecies } from '@/crypto/ecies' import type { PrivateKey, SignedPrivateKey } from '@/crypto/PrivateKey' -import type { Persistence } from './interface' -import type { Ecies } from '@/crypto/ecies' -import { getPublic, encrypt, decrypt } from '@/crypto/ecies' import SignedEciesCiphertext from '@/crypto/SignedEciesCiphertext' +import type { Persistence } from './interface' /** * EncryptedPersistence is a Persistence implementation that uses ECIES to encrypt all values diff --git a/src/keystore/providers/KeyGeneratorKeystoreProvider.ts b/src/keystore/providers/KeyGeneratorKeystoreProvider.ts index 955d9e54d..08f6633ca 100644 --- a/src/keystore/providers/KeyGeneratorKeystoreProvider.ts +++ b/src/keystore/providers/KeyGeneratorKeystoreProvider.ts @@ -1,13 +1,13 @@ import type { ApiClient } from '@/ApiClient' +import { PrivateKeyBundleV1 } from '@/crypto/PrivateKeyBundle' import InMemoryKeystore from '@/keystore/InMemoryKeystore' import TopicPersistence from '@/keystore/persistence/TopicPersistence' +import type { KeystoreInterface } from '@/keystore/rpcDefinitions' +import type { Signer } from '@/types/Signer' import { KeystoreProviderUnavailableError } from './errors' import { buildPersistenceFromOptions } from './helpers' -import NetworkKeyManager from './NetworkKeyManager' -import type { Signer } from '@/types/Signer' import type { KeystoreProvider, KeystoreProviderOptions } from './interfaces' -import type { KeystoreInterface } from '@/keystore/rpcDefinitions' -import { PrivateKeyBundleV1 } from '@/crypto/PrivateKeyBundle' +import NetworkKeyManager from './NetworkKeyManager' /** * KeyGeneratorKeystoreProvider will create a new XMTP `PrivateKeyBundle` and persist it to the network diff --git a/src/keystore/providers/NetworkKeyManager.ts b/src/keystore/providers/NetworkKeyManager.ts index 65efa5a8c..4918149e5 100644 --- a/src/keystore/providers/NetworkKeyManager.ts +++ b/src/keystore/providers/NetworkKeyManager.ts @@ -1,19 +1,18 @@ -import type { Signer } from '@/types/Signer' -import crypto from '@/crypto/crypto' -import type { PreEventCallback } from '@/Client' +import { privateKey as proto } from '@xmtp/proto' +import { getAddress, hexToBytes, verifyMessage, type Hex } from 'viem' import LocalAuthenticator from '@/authn/LocalAuthenticator' -import { bytesToHex } from '@/crypto/utils' +import type { PreEventCallback } from '@/Client' import Ciphertext from '@/crypto/Ciphertext' -import { privateKey as proto } from '@xmtp/proto' -import type TopicPersistence from '@/keystore/persistence/TopicPersistence' -import type { Hex } from 'viem' -import { getAddress, hexToBytes, verifyMessage } from 'viem' +import crypto from '@/crypto/crypto' +import { decrypt, encrypt } from '@/crypto/encryption' import { + decodePrivateKeyBundle, PrivateKeyBundleV1, PrivateKeyBundleV2, - decodePrivateKeyBundle, } from '@/crypto/PrivateKeyBundle' -import { decrypt, encrypt } from '@/crypto/encryption' +import { bytesToHex } from '@/crypto/utils' +import type TopicPersistence from '@/keystore/persistence/TopicPersistence' +import type { Signer } from '@/types/Signer' const KEY_BUNDLE_NAME = 'key_bundle' /** diff --git a/src/keystore/providers/NetworkKeystoreProvider.ts b/src/keystore/providers/NetworkKeystoreProvider.ts index 68bacaee1..91051a14b 100644 --- a/src/keystore/providers/NetworkKeystoreProvider.ts +++ b/src/keystore/providers/NetworkKeystoreProvider.ts @@ -1,12 +1,12 @@ -import type { Signer } from '@/types/Signer' import type { ApiClient } from '@/ApiClient' -import type { KeystoreProvider, KeystoreProviderOptions } from './interfaces' -import NetworkKeyLoader from './NetworkKeyManager' -import { KeystoreProviderUnavailableError } from './errors' -import TopicPersistence from '@/keystore/persistence/TopicPersistence' import InMemoryKeystore from '@/keystore/InMemoryKeystore' -import { buildPersistenceFromOptions } from './helpers' +import TopicPersistence from '@/keystore/persistence/TopicPersistence' import type { KeystoreInterface } from '@/keystore/rpcDefinitions' +import type { Signer } from '@/types/Signer' +import { KeystoreProviderUnavailableError } from './errors' +import { buildPersistenceFromOptions } from './helpers' +import type { KeystoreProvider, KeystoreProviderOptions } from './interfaces' +import NetworkKeyLoader from './NetworkKeyManager' /** * NetworkKeystoreProvider will look on the XMTP network for an `EncryptedPrivateKeyBundle` diff --git a/src/keystore/providers/SnapProvider.ts b/src/keystore/providers/SnapProvider.ts index 099885078..ff2d78db9 100644 --- a/src/keystore/providers/SnapProvider.ts +++ b/src/keystore/providers/SnapProvider.ts @@ -1,6 +1,11 @@ -import { KeystoreProviderUnavailableError } from './errors' -import type { KeystoreProvider, KeystoreProviderOptions } from './interfaces' -import { SnapKeystore } from '@/keystore/SnapKeystore' +import { keystore } from '@xmtp/proto' +import type { ApiClient } from '@/ApiClient' +import type { XmtpEnv } from '@/Client' +import { + decodePrivateKeyBundle, + PrivateKeyBundleV1, +} from '@/crypto/PrivateKeyBundle' +import type { SnapKeystoreInterface } from '@/keystore/rpcDefinitions' import { connectSnap, getSnap, @@ -8,18 +13,14 @@ import { hasMetamaskWithSnaps, initSnap, } from '@/keystore/snapHelpers' -import { keystore } from '@xmtp/proto' +import { SnapKeystore } from '@/keystore/SnapKeystore' import type { Signer } from '@/types/Signer' -import type { ApiClient } from '@/ApiClient' -import NetworkKeystoreProvider from './NetworkKeystoreProvider' -import KeyGeneratorKeystoreProvider from './KeyGeneratorKeystoreProvider' -import type { XmtpEnv } from '@/Client' import { semverGreaterThan } from '@/utils/semver' -import type { SnapKeystoreInterface } from '@/keystore/rpcDefinitions' -import { - PrivateKeyBundleV1, - decodePrivateKeyBundle, -} from '@/crypto/PrivateKeyBundle' +import { KeystoreProviderUnavailableError } from './errors' +import type { KeystoreProvider, KeystoreProviderOptions } from './interfaces' +import KeyGeneratorKeystoreProvider from './KeyGeneratorKeystoreProvider' +import NetworkKeystoreProvider from './NetworkKeystoreProvider' + const { GetKeystoreStatusResponse_KeystoreStatus: KeystoreStatus } = keystore export const SNAP_LOCAL_ORIGIN = 'local:http://localhost:8080' diff --git a/src/keystore/providers/StaticKeystoreProvider.ts b/src/keystore/providers/StaticKeystoreProvider.ts index 24a3d9554..49f7e91c1 100644 --- a/src/keystore/providers/StaticKeystoreProvider.ts +++ b/src/keystore/providers/StaticKeystoreProvider.ts @@ -1,12 +1,12 @@ -import { KeystoreProviderUnavailableError } from './errors' -import type { KeystoreProvider, KeystoreProviderOptions } from './interfaces' -import InMemoryKeystore from '@/keystore/InMemoryKeystore' import { decodePrivateKeyBundle, PrivateKeyBundleV2, } from '@/crypto/PrivateKeyBundle' -import { buildPersistenceFromOptions } from './helpers' +import InMemoryKeystore from '@/keystore/InMemoryKeystore' import type { KeystoreInterface } from '@/keystore/rpcDefinitions' +import { KeystoreProviderUnavailableError } from './errors' +import { buildPersistenceFromOptions } from './helpers' +import type { KeystoreProvider, KeystoreProviderOptions } from './interfaces' /** * StaticKeystoreProvider will look for a `privateKeyOverride` in the provided options, diff --git a/src/keystore/providers/helpers.ts b/src/keystore/providers/helpers.ts index d08d0d530..071e93917 100644 --- a/src/keystore/providers/helpers.ts +++ b/src/keystore/providers/helpers.ts @@ -1,12 +1,12 @@ import type { - PrivateKeyBundleV2, PrivateKeyBundleV1, + PrivateKeyBundleV2, } from '@/crypto/PrivateKeyBundle' import EncryptedPersistence from '@/keystore/persistence/EncryptedPersistence' +import EphemeralPersistence from '@/keystore/persistence/InMemoryPersistence' import PrefixedPersistence from '@/keystore/persistence/PrefixedPersistence' -import type { KeystoreProviderOptions } from './interfaces' import { buildPersistenceKey } from '@/keystore/utils' -import EphemeralPersistence from '@/keystore/persistence/InMemoryPersistence' +import type { KeystoreProviderOptions } from './interfaces' export const buildPersistenceFromOptions = async ( opts: KeystoreProviderOptions, diff --git a/src/keystore/providers/interfaces.ts b/src/keystore/providers/interfaces.ts index 3bf814f2b..afe1d5ec7 100644 --- a/src/keystore/providers/interfaces.ts +++ b/src/keystore/providers/interfaces.ts @@ -1,11 +1,11 @@ -import type { XmtpEnv, PreEventCallbackOptions } from '@/Client' -import type { Signer } from '@/types/Signer' import type { ApiClient } from '@/ApiClient' +import type { PreEventCallbackOptions, XmtpEnv } from '@/Client' import type { Persistence } from '@/keystore/persistence/interface' import type { KeystoreInterface, KeystoreInterfaces, } from '@/keystore/rpcDefinitions' +import type { Signer } from '@/types/Signer' export type KeystoreProviderOptions = { env: XmtpEnv diff --git a/src/keystore/rpcDefinitions.ts b/src/keystore/rpcDefinitions.ts index 185522c7f..70b800e27 100644 --- a/src/keystore/rpcDefinitions.ts +++ b/src/keystore/rpcDefinitions.ts @@ -1,4 +1,4 @@ -import { keystore, authn, publicKey, privateKey, signature } from '@xmtp/proto' +import { authn, keystore, privateKey, publicKey, signature } from '@xmtp/proto' import type { Reader, Writer } from 'protobufjs/minimal' import type { Flatten } from '@/utils/typedefs' diff --git a/src/keystore/snapHelpers.ts b/src/keystore/snapHelpers.ts index b0c8b91ec..7fc8e819b 100644 --- a/src/keystore/snapHelpers.ts +++ b/src/keystore/snapHelpers.ts @@ -1,17 +1,18 @@ import { keystore } from '@xmtp/proto' +import type { XmtpEnv } from '@/Client' +import type { PrivateKeyBundleV1 } from '@/crypto/PrivateKeyBundle' +import { b64Decode, b64Encode } from '@/utils/bytes' +import { getEthereum } from '@/utils/ethereum' +import { isSameMajorVersion } from '@/utils/semver' +import { KeystoreError } from './errors' import type { SnapKeystoreApiDefs, SnapKeystoreApiMethods, - SnapKeystoreInterfaceRequestValues, SnapKeystoreApiRequestEncoders, SnapKeystoreApiResponseDecoders, + SnapKeystoreInterfaceRequestValues, } from './rpcDefinitions' -import { b64Decode, b64Encode } from '@/utils/bytes' -import { KeystoreError } from './errors' -import { getEthereum } from '@/utils/ethereum' -import type { XmtpEnv } from '@/Client' -import { isSameMajorVersion } from '@/utils/semver' -import type { PrivateKeyBundleV1 } from '@/crypto/PrivateKeyBundle' + const { GetKeystoreStatusResponse_KeystoreStatus: KeystoreStatus, InitKeystoreRequest, diff --git a/src/keystore/utils.ts b/src/keystore/utils.ts index a61e893dd..42d20462d 100644 --- a/src/keystore/utils.ts +++ b/src/keystore/utils.ts @@ -1,13 +1,17 @@ -import type { TopicData } from './interfaces' -import type { conversationReference, publicKey, invitation } from '@xmtp/proto' -import { keystore } from '@xmtp/proto' -import { KeystoreError } from './errors' -import type { WithoutUndefined } from '@/utils/typedefs' +import { + keystore, + type conversationReference, + type invitation, + type publicKey, +} from '@xmtp/proto' import type { XmtpEnv } from '@/Client' import { PublicKeyBundle, SignedPublicKeyBundle, } from '@/crypto/PublicKeyBundle' +import type { WithoutUndefined } from '@/utils/typedefs' +import { KeystoreError } from './errors' +import type { TopicData } from './interfaces' export const convertError = ( e: Error, diff --git a/src/message-backup/BackupClientFactory.ts b/src/message-backup/BackupClientFactory.ts index 4215a2080..bd46eac86 100644 --- a/src/message-backup/BackupClientFactory.ts +++ b/src/message-backup/BackupClientFactory.ts @@ -1,6 +1,9 @@ -import type { BackupConfiguration, SelectBackupProvider } from './BackupClient' import type BackupClient from './BackupClient' -import { BackupType } from './BackupClient' +import { + BackupType, + type BackupConfiguration, + type SelectBackupProvider, +} from './BackupClient' import NoBackupClient from './NoBackupClient' import TopicStoreBackupClient from './TopicStoreBackupClient' diff --git a/src/message-backup/NoBackupClient.ts b/src/message-backup/NoBackupClient.ts index 4550f36bf..df1567b2f 100644 --- a/src/message-backup/NoBackupClient.ts +++ b/src/message-backup/NoBackupClient.ts @@ -1,6 +1,5 @@ -import type { NoBackupConfiguration } from './BackupClient' import type BackupClient from './BackupClient' -import { BackupType } from './BackupClient' +import { BackupType, type NoBackupConfiguration } from './BackupClient' const BACKUP_TYPE = BackupType.none export default class NoBackupClient implements BackupClient { diff --git a/src/message-backup/TopicStoreBackupClient.ts b/src/message-backup/TopicStoreBackupClient.ts index 57867739b..d1ff14554 100644 --- a/src/message-backup/TopicStoreBackupClient.ts +++ b/src/message-backup/TopicStoreBackupClient.ts @@ -1,6 +1,5 @@ -import type { TopicStoreBackupConfiguration } from './BackupClient' import type BackupClient from './BackupClient' -import { BackupType } from './BackupClient' +import { BackupType, type TopicStoreBackupConfiguration } from './BackupClient' const BACKUP_TYPE = BackupType.xmtpTopicStore export default class TopicStoreBackupClient implements BackupClient { diff --git a/test/ApiClient.test.ts b/test/ApiClient.test.ts index 4d9d8b753..ed049078d 100644 --- a/test/ApiClient.test.ts +++ b/test/ApiClient.test.ts @@ -1,17 +1,20 @@ +import { messageApi } from '@xmtp/proto' import type { InitReq, NotifyStreamEntityArrival, } from '@xmtp/proto/ts/dist/types/fetch.pb' -import type { PublishParams } from '@/ApiClient' -import ApiClient, { GrpcError, GrpcStatus } from '@/ApiClient' -import { messageApi } from '@xmtp/proto' -import { sleep } from './helpers' +import { vi } from 'vitest' +import ApiClient, { + GrpcError, + GrpcStatus, + type PublishParams, +} from '@/ApiClient' import LocalAuthenticator from '@/authn/LocalAuthenticator' +import { PrivateKey } from '@/crypto/PrivateKey' +import { dateToNs } from '@/utils/date' // eslint-disable-next-line no-restricted-syntax import packageJson from '../package.json' -import { dateToNs } from '@/utils/date' -import { vi } from 'vitest' -import { PrivateKey } from '@/crypto/PrivateKey' +import { sleep } from './helpers' const { MessageApi } = messageApi diff --git a/test/ApiClientE2E.test.ts b/test/ApiClientE2E.test.ts index 6b692fb09..8ab304c78 100644 --- a/test/ApiClientE2E.test.ts +++ b/test/ApiClientE2E.test.ts @@ -1,9 +1,9 @@ +import type { Wallet } from 'ethers' import ApiClient, { ApiUrls, GrpcStatus } from '@/ApiClient' -import { newWallet } from './helpers' import LocalAuthenticator from '@/authn/LocalAuthenticator' -import { buildUserPrivateStoreTopic } from '@/utils/topic' -import type { Wallet } from 'ethers' import { PrivateKeyBundleV1 } from '@/crypto/PrivateKeyBundle' +import { buildUserPrivateStoreTopic } from '@/utils/topic' +import { newWallet } from './helpers' type TestCase = { name: string; api: string } diff --git a/test/BackupClient.test.ts b/test/BackupClient.test.ts index 22a57e67d..7c81ee36d 100644 --- a/test/BackupClient.test.ts +++ b/test/BackupClient.test.ts @@ -1,5 +1,5 @@ import { BackupType } from '@/message-backup/BackupClient' -import { newLocalHostClient, newDevClient } from './helpers' +import { newDevClient, newLocalHostClient } from './helpers' describe('Backup configuration', () => { it('Uses XMTP backup for localhost', async function () { diff --git a/test/Client.test.ts b/test/Client.test.ts index 59c35b2a7..21c38b40e 100644 --- a/test/Client.test.ts +++ b/test/Client.test.ts @@ -1,32 +1,31 @@ -import { - newWallet, - newLocalHostClient, - newDevClient, - waitForUserContact, - newLocalHostClientWithCustomWallet, -} from './helpers' -import { buildUserContactTopic } from '@/utils/topic' -import type { ClientOptions } from '@/Client' -import Client, { Compression } from '@/Client' -import NetworkKeyManager from '@/keystore/providers/NetworkKeyManager' -import TopicPersistence from '@/keystore/persistence/TopicPersistence' -import { Wallet } from 'ethers' -import NetworkKeystoreProvider from '@/keystore/providers/NetworkKeystoreProvider' +import { message } from '@xmtp/proto' import type { PublishResponse } from '@xmtp/proto/ts/dist/types/message_api/v1/message_api.pb' -import LocalStoragePonyfill from '@/keystore/persistence/LocalStoragePonyfill' +import { Wallet } from 'ethers' import { createWalletClient, http } from 'viem' -import { privateKeyToAccount, generatePrivateKey } from 'viem/accounts' +import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' -import { vi, assert } from 'vitest' -import { ContentTypeTestKey, TestKeyCodec } from './ContentTypeTestKey' -import type { EnvelopeWithMessage } from '@/utils/async' -import { ContentTypeText, TextCodec } from '@/codecs/Text' -import { CompositeCodec } from '@/codecs/Composite' +import { assert, vi } from 'vitest' import HttpApiClient, { ApiUrls } from '@/ApiClient' -import InMemoryPersistence from '@/keystore/persistence/InMemoryPersistence' -import { message } from '@xmtp/proto' -import { PrivateKeyBundleV1 } from '@/crypto/PrivateKeyBundle' +import Client, { Compression, type ClientOptions } from '@/Client' +import { CompositeCodec } from '@/codecs/Composite' +import { ContentTypeText, TextCodec } from '@/codecs/Text' import { PrivateKey } from '@/crypto/PrivateKey' +import { PrivateKeyBundleV1 } from '@/crypto/PrivateKeyBundle' +import InMemoryPersistence from '@/keystore/persistence/InMemoryPersistence' +import LocalStoragePonyfill from '@/keystore/persistence/LocalStoragePonyfill' +import TopicPersistence from '@/keystore/persistence/TopicPersistence' +import NetworkKeyManager from '@/keystore/providers/NetworkKeyManager' +import NetworkKeystoreProvider from '@/keystore/providers/NetworkKeystoreProvider' +import type { EnvelopeWithMessage } from '@/utils/async' +import { buildUserContactTopic } from '@/utils/topic' +import { ContentTypeTestKey, TestKeyCodec } from './ContentTypeTestKey' +import { + newDevClient, + newLocalHostClient, + newLocalHostClientWithCustomWallet, + newWallet, + waitForUserContact, +} from './helpers' type TestCase = { name: string diff --git a/test/Compression.test.ts b/test/Compression.test.ts index 054aabee6..e4da51914 100644 --- a/test/Compression.test.ts +++ b/test/Compression.test.ts @@ -1,11 +1,11 @@ import { content as proto } from '@xmtp/proto' +import { ContentTypeText } from '@/codecs/Text' import { compress, decompress, readStreamFromBytes, writeStreamToBytes, } from '@/Compression' -import { ContentTypeText } from '@/codecs/Text' describe('Compression', function () { it('can stream bytes from source to sink', async function () { diff --git a/test/ContactBundle.test.ts b/test/ContactBundle.test.ts index 4702b1869..8bc42d277 100644 --- a/test/ContactBundle.test.ts +++ b/test/ContactBundle.test.ts @@ -3,11 +3,11 @@ import { PrivateKeyBundleV1, PrivateKeyBundleV2, } from '@/crypto/PrivateKeyBundle' -import { newWallet } from './helpers' import { PublicKeyBundle, SignedPublicKeyBundle, } from '@/crypto/PublicKeyBundle' +import { newWallet } from './helpers' describe('ContactBundles', function () { it('roundtrip', async function () { diff --git a/test/ContentTypeTestKey.ts b/test/ContentTypeTestKey.ts index f31dff6ac..16fa87c01 100644 --- a/test/ContentTypeTestKey.ts +++ b/test/ContentTypeTestKey.ts @@ -1,7 +1,10 @@ -import type { ContentCodec, EncodedContent } from '@/MessageContent' -import { ContentTypeId } from '@/MessageContent' -import { PublicKey } from '@/crypto/PublicKey' import { publicKey } from '@xmtp/proto' +import { PublicKey } from '@/crypto/PublicKey' +import { + ContentTypeId, + type ContentCodec, + type EncodedContent, +} from '@/MessageContent' export const ContentTypeTestKey = new ContentTypeId({ authorityId: 'xmtp.test', diff --git a/test/Invitation.test.ts b/test/Invitation.test.ts index a96511849..780f617b3 100644 --- a/test/Invitation.test.ts +++ b/test/Invitation.test.ts @@ -1,15 +1,15 @@ +import Long from 'long' +import Ciphertext from '@/crypto/Ciphertext' import crypto from '@/crypto/crypto' +import { NoMatchingPreKeyError } from '@/crypto/errors' +import { PrivateKeyBundleV2 } from '@/crypto/PrivateKeyBundle' import { InvitationV1, SealedInvitation, - SealedInvitationV1, SealedInvitationHeaderV1, + SealedInvitationV1, } from '@/Invitation' -import { PrivateKeyBundleV2 } from '@/crypto/PrivateKeyBundle' import { newWallet } from './helpers' -import Long from 'long' -import Ciphertext from '@/crypto/Ciphertext' -import { NoMatchingPreKeyError } from '@/crypto/errors' const createInvitation = (): InvitationV1 => { return new InvitationV1({ diff --git a/test/Keygen.test.ts b/test/Keygen.test.ts index 807d3c191..81d897daf 100644 --- a/test/Keygen.test.ts +++ b/test/Keygen.test.ts @@ -1,11 +1,11 @@ -import { decodePrivateKeyBundle } from '@/crypto/PrivateKeyBundle' import ApiClient, { ApiUrls } from '@/ApiClient' -import { newWallet } from './helpers' import Client, { defaultOptions } from '@/Client' -import type { Signer } from '@/types/Signer' +import { decodePrivateKeyBundle } from '@/crypto/PrivateKeyBundle' import type { PublicKeyBundle } from '@/crypto/PublicKeyBundle' -import NetworkKeyManager from '@/keystore/providers/NetworkKeyManager' import TopicPersistence from '@/keystore/persistence/TopicPersistence' +import NetworkKeyManager from '@/keystore/providers/NetworkKeyManager' +import type { Signer } from '@/types/Signer' +import { newWallet } from './helpers' describe('Key Generation', () => { let wallet: Signer diff --git a/test/Message.test.ts b/test/Message.test.ts index 4f61c858a..99e999d77 100644 --- a/test/Message.test.ts +++ b/test/Message.test.ts @@ -1,19 +1,19 @@ -import { ConversationV1 } from '@/conversations/Conversation' -import { newWallet } from './helpers' -import { MessageV1, DecodedMessage } from '@/Message' -import { PrivateKeyBundleV1 } from '@/crypto/PrivateKeyBundle' -import { bytesToHex, equalBytes } from '@/crypto/utils' -import { sha256 } from '@/crypto/encryption' -import InMemoryKeystore from '@/keystore/InMemoryKeystore' import type { Wallet } from 'ethers' -import { ContentTypeTestKey, TestKeyCodec } from './ContentTypeTestKey' -import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts' import { createWalletClient, http } from 'viem' +import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' -import { KeystoreError } from '@/keystore/errors' -import InMemoryPersistence from '@/keystore/persistence/InMemoryPersistence' import Client from '@/Client' import { ContentTypeText } from '@/codecs/Text' +import { ConversationV1 } from '@/conversations/Conversation' +import { sha256 } from '@/crypto/encryption' +import { PrivateKeyBundleV1 } from '@/crypto/PrivateKeyBundle' +import { bytesToHex, equalBytes } from '@/crypto/utils' +import { KeystoreError } from '@/keystore/errors' +import InMemoryKeystore from '@/keystore/InMemoryKeystore' +import InMemoryPersistence from '@/keystore/persistence/InMemoryPersistence' +import { DecodedMessage, MessageV1 } from '@/Message' +import { ContentTypeTestKey, TestKeyCodec } from './ContentTypeTestKey' +import { newWallet } from './helpers' describe('Message', function () { let aliceWallet: Wallet diff --git a/test/authn/Authn.test.ts b/test/authn/Authn.test.ts index fc90dad1d..58b520d95 100644 --- a/test/authn/Authn.test.ts +++ b/test/authn/Authn.test.ts @@ -1,13 +1,13 @@ +import type { Wallet } from 'ethers' import Long from 'long' +import { hexToBytes, keccak256 } from 'viem' +import AuthCache from '@/authn/AuthCache' import Authenticator from '@/authn/LocalAuthenticator' import Token from '@/authn/Token' -import { newWallet, sleep } from '@test/helpers' -import type { Wallet } from 'ethers' -import AuthCache from '@/authn/AuthCache' -import { hexToBytes, keccak256 } from 'viem' import { PrivateKey } from '@/crypto/PrivateKey' import { PrivateKeyBundleV1 } from '@/crypto/PrivateKeyBundle' import Signature from '@/crypto/Signature' +import { newWallet, sleep } from '@test/helpers' describe('authn', () => { let authenticator: Authenticator diff --git a/test/codecs/Composite.test.ts b/test/codecs/Composite.test.ts index 0901f69b7..4790e524b 100644 --- a/test/codecs/Composite.test.ts +++ b/test/codecs/Composite.test.ts @@ -1,6 +1,6 @@ import { CompositeCodec, ContentTypeComposite } from '@/codecs/Composite' -import { CodecRegistry } from '@test/helpers' import { ContentTypeText } from '@/codecs/Text' +import { CodecRegistry } from '@test/helpers' describe('CompositeType', () => { const codecs = new CodecRegistry() diff --git a/test/codecs/Text.test.ts b/test/codecs/Text.test.ts index cca1fd80d..daca2fc45 100644 --- a/test/codecs/Text.test.ts +++ b/test/codecs/Text.test.ts @@ -1,5 +1,5 @@ -import { CodecRegistry } from '@test/helpers' import { ContentTypeText, Encoding } from '@/codecs/Text' +import { CodecRegistry } from '@test/helpers' describe('ContentTypeText', () => { const codecs = new CodecRegistry() diff --git a/test/conversations/Conversation.test.ts b/test/conversations/Conversation.test.ts index 7101301ff..41ded24be 100644 --- a/test/conversations/Conversation.test.ts +++ b/test/conversations/Conversation.test.ts @@ -1,19 +1,18 @@ -import type { MessageV2 } from '@/Message' -import { DecodedMessage, MessageV1 } from '@/Message' -import { buildDirectMessageTopic } from '@/utils/topic' -import { SortDirection } from '@/ApiClient' -import { sleep } from '@/utils/async' -import { newLocalHostClient, waitForUserContact } from '@test/helpers' -import { ConversationV2 } from '@/conversations/Conversation' import { content as proto } from '@xmtp/proto' import { assert, vi } from 'vitest' +import { SortDirection } from '@/ApiClient' import type Client from '@/Client' -import { ContentTypeText } from '@/codecs/Text' import { Compression } from '@/Client' -import { ContentTypeTestKey, TestKeyCodec } from '@test/ContentTypeTestKey' -import { ContentTypeId } from '@/MessageContent' +import { ContentTypeText } from '@/codecs/Text' +import { ConversationV2 } from '@/conversations/Conversation' import { PrivateKey } from '@/crypto/PrivateKey' import { SignedPublicKeyBundle } from '@/crypto/PublicKeyBundle' +import { DecodedMessage, MessageV1, type MessageV2 } from '@/Message' +import { ContentTypeId } from '@/MessageContent' +import { sleep } from '@/utils/async' +import { buildDirectMessageTopic } from '@/utils/topic' +import { ContentTypeTestKey, TestKeyCodec } from '@test/ContentTypeTestKey' +import { newLocalHostClient, waitForUserContact } from '@test/helpers' describe('conversation', () => { let alice: Client diff --git a/test/conversations/Conversations.test.ts b/test/conversations/Conversations.test.ts index 614c0ea5d..45a808835 100644 --- a/test/conversations/Conversations.test.ts +++ b/test/conversations/Conversations.test.ts @@ -1,8 +1,8 @@ +import type Client from '@/Client' import { ConversationV1, ConversationV2 } from '@/conversations/Conversation' -import { newLocalHostClient } from '@test/helpers' -import { buildDirectMessageTopic, buildUserIntroTopic } from '@/utils/topic' import { sleep } from '@/utils/async' -import type Client from '@/Client' +import { buildDirectMessageTopic, buildUserIntroTopic } from '@/utils/topic' +import { newLocalHostClient } from '@test/helpers' describe('conversations', () => { describe('listConversations', () => { diff --git a/test/conversations/JobRunner.test.ts b/test/conversations/JobRunner.test.ts index 6e3d51924..a004cdd35 100644 --- a/test/conversations/JobRunner.test.ts +++ b/test/conversations/JobRunner.test.ts @@ -1,11 +1,11 @@ import { keystore as keystoreProto } from '@xmtp/proto' import JobRunner from '@/conversations/JobRunner' -import { newWallet, sleep } from '@test/helpers' -import type { KeystoreInterface } from '@/keystore/rpcDefinitions' import { PrivateKeyBundleV1 } from '@/crypto/PrivateKeyBundle' import InMemoryKeystore from '@/keystore/InMemoryKeystore' import InMemoryPersistence from '@/keystore/persistence/InMemoryPersistence' +import type { KeystoreInterface } from '@/keystore/rpcDefinitions' import { nsToDate } from '@/utils/date' +import { newWallet, sleep } from '@test/helpers' describe('JobRunner', () => { let keystore: KeystoreInterface diff --git a/test/crypto/PrivateKeyBundle.test.ts b/test/crypto/PrivateKeyBundle.test.ts index 35c9a6005..69398158b 100644 --- a/test/crypto/PrivateKeyBundle.test.ts +++ b/test/crypto/PrivateKeyBundle.test.ts @@ -1,13 +1,13 @@ -import { newWallet } from '@test/helpers' -import { storageSigRequestText } from '@/keystore/providers/NetworkKeyManager' import { hexToBytes } from 'viem' +import { PrivateKey } from '@/crypto/PrivateKey' import { + decodePrivateKeyBundle, PrivateKeyBundleV1, PrivateKeyBundleV2, - decodePrivateKeyBundle, } from '@/crypto/PrivateKeyBundle' -import { PrivateKey } from '@/crypto/PrivateKey' import { SignedPublicKeyBundle } from '@/crypto/PublicKeyBundle' +import { storageSigRequestText } from '@/keystore/providers/NetworkKeyManager' +import { newWallet } from '@test/helpers' describe('Crypto', function () { describe('PrivateKeyBundle', function () { diff --git a/test/crypto/PublicKey.test.ts b/test/crypto/PublicKey.test.ts index 4797bf182..13a599048 100644 --- a/test/crypto/PublicKey.test.ts +++ b/test/crypto/PublicKey.test.ts @@ -1,11 +1,11 @@ -import Long from 'long' import { Wallet } from 'ethers' -import { equalBytes } from '@/crypto/utils' -import { newWallet } from '@test/helpers' +import Long from 'long' import { hexToBytes } from 'viem' -import Signature, { WalletSigner } from '@/crypto/Signature' import { PrivateKey, SignedPrivateKey } from '@/crypto/PrivateKey' import { PublicKey, SignedPublicKey } from '@/crypto/PublicKey' +import Signature, { WalletSigner } from '@/crypto/Signature' +import { equalBytes } from '@/crypto/utils' +import { newWallet } from '@test/helpers' describe('Crypto', function () { describe('Signed Keys', function () { diff --git a/test/crypto/SignedEciesCiphertext.test.ts b/test/crypto/SignedEciesCiphertext.test.ts index fbf17facb..bbc74417b 100644 --- a/test/crypto/SignedEciesCiphertext.test.ts +++ b/test/crypto/SignedEciesCiphertext.test.ts @@ -1,9 +1,9 @@ -import { newWallet } from '@test/helpers' -import { encrypt, getPublic } from '@/crypto/ecies' -import { equalBytes } from '@/crypto/utils' import crypto from '@/crypto/crypto' +import { encrypt, getPublic } from '@/crypto/ecies' import { PrivateKeyBundleV1 } from '@/crypto/PrivateKeyBundle' import SignedEciesCiphertext from '@/crypto/SignedEciesCiphertext' +import { equalBytes } from '@/crypto/utils' +import { newWallet } from '@test/helpers' describe('SignedEciesCiphertext', () => { let bundle: PrivateKeyBundleV1 diff --git a/test/crypto/encryption.test.ts b/test/crypto/encryption.test.ts index 9caf3519e..8b394f622 100644 --- a/test/crypto/encryption.test.ts +++ b/test/crypto/encryption.test.ts @@ -1,11 +1,11 @@ +import crypto from '@/crypto/crypto' import { - importHmacKey, exportHmacKey, + generateHmacSignature, hkdfHmacKey, + importHmacKey, verifyHmacSignature, - generateHmacSignature, } from '@/crypto/encryption' -import crypto from '@/crypto/crypto' describe('HMAC encryption', () => { it('generates and validates HMAC', async () => { diff --git a/test/crypto/index.test.ts b/test/crypto/index.test.ts index 450ddab0b..4a25e4352 100644 --- a/test/crypto/index.test.ts +++ b/test/crypto/index.test.ts @@ -1,9 +1,9 @@ +import { assert } from 'vitest' +import crypto from '@/crypto/crypto' +import { decrypt, encrypt } from '@/crypto/encryption' import { PrivateKey } from '@/crypto/PrivateKey' import { PrivateKeyBundleV1 } from '@/crypto/PrivateKeyBundle' import { PublicKeyBundle } from '@/crypto/PublicKeyBundle' -import crypto from '@/crypto/crypto' -import { decrypt, encrypt } from '@/crypto/encryption' -import { assert } from 'vitest' describe('Crypto', function () { it('signs keys and verifies signatures', async function () { diff --git a/test/helpers.ts b/test/helpers.ts index 7b4f10ce1..2f22ed1e7 100644 --- a/test/helpers.ts +++ b/test/helpers.ts @@ -1,19 +1,17 @@ -import { dateToNs, toNanoString } from '@/utils/date' +import { fetcher, type messageApi } from '@xmtp/proto' import { Wallet } from 'ethers' -import type { Signer } from '@/types/Signer' -import type Stream from '@/Stream' -import { promiseWithTimeout } from '@/utils/async' -import type { messageApi } from '@xmtp/proto' -import { fetcher } from '@xmtp/proto' -import type { ClientOptions } from '@/Client' -import Client from '@/Client' -import type { ContentCodec, ContentTypeId } from '@/MessageContent' +import Client, { type ClientOptions } from '@/Client' import { TextCodec } from '@/codecs/Text' +import { PrivateKey } from '@/crypto/PrivateKey' import type { PublicKeyBundle, SignedPublicKeyBundle, } from '@/crypto/PublicKeyBundle' -import { PrivateKey } from '@/crypto/PrivateKey' +import type { ContentCodec, ContentTypeId } from '@/MessageContent' +import type Stream from '@/Stream' +import type { Signer } from '@/types/Signer' +import { promiseWithTimeout } from '@/utils/async' +import { dateToNs, toNanoString } from '@/utils/date' const { b64Encode } = fetcher diff --git a/test/keystore/InMemoryKeystore.test.ts b/test/keystore/InMemoryKeystore.test.ts index cfe45c109..c5ce0f6df 100644 --- a/test/keystore/InMemoryKeystore.test.ts +++ b/test/keystore/InMemoryKeystore.test.ts @@ -1,32 +1,35 @@ import { keystore, privateKey } from '@xmtp/proto' -import { randomBytes } from '@bench/helpers' -import { InvitationV1, SealedInvitation } from '@/Invitation' -import type { InvitationContext } from '@/Invitation' -import { MessageV1 } from '@/Message' -import { decryptV1 } from '@/keystore/encryption' -import { KeystoreError } from '@/keystore/errors' -import InMemoryKeystore from '@/keystore/InMemoryKeystore' -import { equalBytes } from '@/crypto/utils' -import { buildProtoEnvelope, newWallet } from '@test/helpers' -import { dateToNs, nsToDate } from '@/utils/date' -import InMemoryPersistence from '@/keystore/persistence/InMemoryPersistence' -import Token from '@/authn/Token' -import Long from 'long' import type { CreateInviteResponse } from '@xmtp/proto/ts/dist/types/keystore_api/v1/keystore.pb' -import { assert } from 'vitest' +import Long from 'long' import { toBytes } from 'viem' -import { - PrivateKeyBundleV1, - PrivateKeyBundleV2, -} from '@/crypto/PrivateKeyBundle' -import { SignedPublicKeyBundle } from '@/crypto/PublicKeyBundle' -import { getKeyMaterial } from '@/keystore/utils' +import { assert } from 'vitest' +import Token from '@/authn/Token' import { generateHmacSignature, hkdfHmacKey, importHmacKey, verifyHmacSignature, } from '@/crypto/encryption' +import { + PrivateKeyBundleV1, + PrivateKeyBundleV2, +} from '@/crypto/PrivateKeyBundle' +import { SignedPublicKeyBundle } from '@/crypto/PublicKeyBundle' +import { equalBytes } from '@/crypto/utils' +import { + InvitationV1, + SealedInvitation, + type InvitationContext, +} from '@/Invitation' +import { decryptV1 } from '@/keystore/encryption' +import { KeystoreError } from '@/keystore/errors' +import InMemoryKeystore from '@/keystore/InMemoryKeystore' +import InMemoryPersistence from '@/keystore/persistence/InMemoryPersistence' +import { getKeyMaterial } from '@/keystore/utils' +import { MessageV1 } from '@/Message' +import { dateToNs, nsToDate } from '@/utils/date' +import { buildProtoEnvelope, newWallet } from '@test/helpers' +import { randomBytes } from '@bench/helpers' describe('InMemoryKeystore', () => { let aliceKeys: PrivateKeyBundleV1 diff --git a/test/keystore/conversationStores.test.ts b/test/keystore/conversationStores.test.ts index 815a0e336..7e76e530e 100644 --- a/test/keystore/conversationStores.test.ts +++ b/test/keystore/conversationStores.test.ts @@ -1,6 +1,9 @@ import crypto from '@/crypto/crypto' -import type { AddRequest } from '@/keystore/conversationStores' -import { V2Store, V1Store } from '@/keystore/conversationStores' +import { + V1Store, + V2Store, + type AddRequest, +} from '@/keystore/conversationStores' import InMemoryPersistence from '@/keystore/persistence/InMemoryPersistence' import { dateToNs } from '@/utils/date' diff --git a/test/keystore/encryption.test.ts b/test/keystore/encryption.test.ts index 5e848d435..0cc91e079 100644 --- a/test/keystore/encryption.test.ts +++ b/test/keystore/encryption.test.ts @@ -1,13 +1,13 @@ -import { PrivateKeyBundleV1 } from '@/crypto/PrivateKeyBundle' -import { decryptV1, encryptV1 } from '@/keystore/encryption' -import { MessageV1 } from '@/Message' import { Wallet } from 'ethers' +import Ciphertext from '@/crypto/Ciphertext' +import { PrivateKeyBundleV1 } from '@/crypto/PrivateKeyBundle' import { equalBytes } from '@/crypto/utils' -import { newWallet } from '@test/helpers' +import { decryptV1, encryptV1 } from '@/keystore/encryption' import InMemoryKeystore from '@/keystore/InMemoryKeystore' -import type { KeystoreInterface } from '@/keystore/rpcDefinitions' import InMemoryPersistence from '@/keystore/persistence/InMemoryPersistence' -import Ciphertext from '@/crypto/Ciphertext' +import type { KeystoreInterface } from '@/keystore/rpcDefinitions' +import { MessageV1 } from '@/Message' +import { newWallet } from '@test/helpers' describe('encryption primitives', () => { let aliceKeys: PrivateKeyBundleV1 diff --git a/test/keystore/persistence/EncryptedPersistence.test.ts b/test/keystore/persistence/EncryptedPersistence.test.ts index 1886fc000..9a25d8b15 100644 --- a/test/keystore/persistence/EncryptedPersistence.test.ts +++ b/test/keystore/persistence/EncryptedPersistence.test.ts @@ -1,9 +1,9 @@ import crypto from '@/crypto/crypto' -import { PrivateKeyBundleV1 } from '@/crypto/PrivateKeyBundle' -import InMemoryPersistence from '@/keystore/persistence/InMemoryPersistence' -import EncryptedPersistence from '@/keystore/persistence/EncryptedPersistence' import type { PrivateKey } from '@/crypto/PrivateKey' +import { PrivateKeyBundleV1 } from '@/crypto/PrivateKeyBundle' import SignedEciesCiphertext from '@/crypto/SignedEciesCiphertext' +import EncryptedPersistence from '@/keystore/persistence/EncryptedPersistence' +import InMemoryPersistence from '@/keystore/persistence/InMemoryPersistence' const TEST_KEY = 'test-key' const TEST_KEY_2 = 'test-key-2' diff --git a/test/keystore/persistence/LocalStoragePersistence.test.ts b/test/keystore/persistence/LocalStoragePersistence.test.ts index 9bb96108e..2c2140f77 100644 --- a/test/keystore/persistence/LocalStoragePersistence.test.ts +++ b/test/keystore/persistence/LocalStoragePersistence.test.ts @@ -1,6 +1,6 @@ import { - PrivateKeyBundleV1, decodePrivateKeyBundle, + PrivateKeyBundleV1, } from '@/crypto/PrivateKeyBundle' import InMemoryPersistence from '@/keystore/persistence/InMemoryPersistence' diff --git a/test/keystore/persistence/TopicPersistence.test.ts b/test/keystore/persistence/TopicPersistence.test.ts index 5013a995c..ecceb7f77 100644 --- a/test/keystore/persistence/TopicPersistence.test.ts +++ b/test/keystore/persistence/TopicPersistence.test.ts @@ -1,8 +1,8 @@ import ApiClient, { ApiUrls } from '@/ApiClient' -import { newWallet } from '@test/helpers' -import TopicPersistence from '@/keystore/persistence/TopicPersistence' import LocalAuthenticator from '@/authn/LocalAuthenticator' import { PrivateKeyBundleV1 } from '@/crypto/PrivateKeyBundle' +import TopicPersistence from '@/keystore/persistence/TopicPersistence' +import { newWallet } from '@test/helpers' // We restrict publishing to topics that do not match this pattern const buildValidKey = (walletAddress: string) => `${walletAddress}/key_bundle` diff --git a/test/keystore/providers/KeyGeneratorKeystoreProvider.test.ts b/test/keystore/providers/KeyGeneratorKeystoreProvider.test.ts index 7ee61a4bc..6d11b6c2a 100644 --- a/test/keystore/providers/KeyGeneratorKeystoreProvider.test.ts +++ b/test/keystore/providers/KeyGeneratorKeystoreProvider.test.ts @@ -1,10 +1,10 @@ -import KeyGeneratorKeystoreProvider from '@/keystore/providers/KeyGeneratorKeystoreProvider' +import { vi } from 'vitest' import ApiClient, { ApiUrls } from '@/ApiClient' +import { KeystoreProviderUnavailableError } from '@/keystore/providers/errors' +import KeyGeneratorKeystoreProvider from '@/keystore/providers/KeyGeneratorKeystoreProvider' import type { Signer } from '@/types/Signer' import { newWallet } from '@test/helpers' import { testProviderOptions } from './helpers' -import { vi } from 'vitest' -import { KeystoreProviderUnavailableError } from '@/keystore/providers/errors' describe('KeyGeneratorKeystoreProvider', () => { let wallet: Signer diff --git a/test/keystore/providers/NetworkKeyManager.test.ts b/test/keystore/providers/NetworkKeyManager.test.ts index 880f55441..c346266ca 100644 --- a/test/keystore/providers/NetworkKeyManager.test.ts +++ b/test/keystore/providers/NetworkKeyManager.test.ts @@ -1,14 +1,14 @@ +import { vi } from 'vitest' import ApiClient, { ApiUrls } from '@/ApiClient' import { PrivateKeyBundleV1 } from '@/crypto/PrivateKeyBundle' +import BrowserStoragePersistence from '@/keystore/persistence/BrowserStoragePersistence' +import PrefixedPersistence from '@/keystore/persistence/PrefixedPersistence' import TopicPersistence from '@/keystore/persistence/TopicPersistence' import { buildPersistenceFromOptions } from '@/keystore/providers/helpers' import NetworkKeyManager from '@/keystore/providers/NetworkKeyManager' import type { Signer } from '@/types/Signer' import { newWallet, pollFor, sleep, wrapAsLedgerWallet } from '@test/helpers' import { testProviderOptions } from './helpers' -import { vi } from 'vitest' -import BrowserStoragePersistence from '@/keystore/persistence/BrowserStoragePersistence' -import PrefixedPersistence from '@/keystore/persistence/PrefixedPersistence' describe('NetworkKeyManager', () => { let wallet: Signer diff --git a/test/keystore/providers/NetworkKeystoreProvider.test.ts b/test/keystore/providers/NetworkKeystoreProvider.test.ts index b0891e871..5b874e8a1 100644 --- a/test/keystore/providers/NetworkKeystoreProvider.test.ts +++ b/test/keystore/providers/NetworkKeystoreProvider.test.ts @@ -1,21 +1,20 @@ import { privateKey } from '@xmtp/proto' -import { KeystoreProviderUnavailableError } from '@/keystore/providers/errors' +import { hexToBytes, type Hex } from 'viem' +import { vi } from 'vitest' import ApiClient, { ApiUrls } from '@/ApiClient' +import LocalAuthenticator from '@/authn/LocalAuthenticator' +import crypto from '@/crypto/crypto' +import { encrypt } from '@/crypto/encryption' +import { PrivateKeyBundleV1 } from '@/crypto/PrivateKeyBundle' +import TopicPersistence from '@/keystore/persistence/TopicPersistence' +import { KeystoreProviderUnavailableError } from '@/keystore/providers/errors' +import NetworkKeyManager, { + storageSigRequestText, +} from '@/keystore/providers/NetworkKeyManager' import NetworkKeystoreProvider from '@/keystore/providers/NetworkKeystoreProvider' import type { Signer } from '@/types/Signer' import { newWallet } from '@test/helpers' import { testProviderOptions } from './helpers' -import NetworkKeyManager, { - storageSigRequestText, -} from '@/keystore/providers/NetworkKeyManager' -import TopicPersistence from '@/keystore/persistence/TopicPersistence' -import LocalAuthenticator from '@/authn/LocalAuthenticator' -import crypto from '@/crypto/crypto' -import { vi } from 'vitest' -import type { Hex } from 'viem' -import { hexToBytes } from 'viem' -import { PrivateKeyBundleV1 } from '@/crypto/PrivateKeyBundle' -import { encrypt } from '@/crypto/encryption' describe('NetworkKeystoreProvider', () => { let apiClient: ApiClient diff --git a/test/keystore/providers/SnapProvider.test.ts b/test/keystore/providers/SnapProvider.test.ts index 1e11c904d..bcddde258 100644 --- a/test/keystore/providers/SnapProvider.test.ts +++ b/test/keystore/providers/SnapProvider.test.ts @@ -1,6 +1,8 @@ -import type { ApiClient } from '@/ApiClient' -import HttpApiClient, { ApiUrls } from '@/ApiClient' -import { newWallet } from '@test/helpers' +import { keystore as keystoreProto } from '@xmtp/proto' +import { vi, type Mock } from 'vitest' +import HttpApiClient, { ApiUrls, type ApiClient } from '@/ApiClient' +import { KeystoreProviderUnavailableError } from '@/keystore/providers/errors' +import type { KeystoreProviderOptions } from '@/keystore/providers/interfaces' import SnapKeystoreProvider from '@/keystore/providers/SnapProvider' import { connectSnap, @@ -10,11 +12,7 @@ import { initSnap, } from '@/keystore/snapHelpers' import type { Signer } from '@/types/Signer' -import { keystore as keystoreProto } from '@xmtp/proto' -import type { Mock } from 'vitest' -import { vi } from 'vitest' -import type { KeystoreProviderOptions } from '@/keystore/providers/interfaces' -import { KeystoreProviderUnavailableError } from '@/keystore/providers/errors' +import { newWallet } from '@test/helpers' vi.mock('@/keystore/snapHelpers') diff --git a/test/keystore/providers/StaticKeystoreProvider.test.ts b/test/keystore/providers/StaticKeystoreProvider.test.ts index 95178e006..a14d1e9f6 100644 --- a/test/keystore/providers/StaticKeystoreProvider.test.ts +++ b/test/keystore/providers/StaticKeystoreProvider.test.ts @@ -1,9 +1,9 @@ import { privateKey } from '@xmtp/proto' +import { PrivateKeyBundleV1 } from '@/crypto/PrivateKeyBundle' +import { KeystoreProviderUnavailableError } from '@/keystore/providers/errors' +import StaticKeystoreProvider from '@/keystore/providers/StaticKeystoreProvider' import { newWallet } from '@test/helpers' import { testProviderOptions } from './helpers' -import StaticKeystoreProvider from '@/keystore/providers/StaticKeystoreProvider' -import { KeystoreProviderUnavailableError } from '@/keystore/providers/errors' -import { PrivateKeyBundleV1 } from '@/crypto/PrivateKeyBundle' const ENV = 'local' diff --git a/test/keystore/snapHelpers.test.ts b/test/keystore/snapHelpers.test.ts index 0ed9d66b5..f6b72fbf4 100644 --- a/test/keystore/snapHelpers.test.ts +++ b/test/keystore/snapHelpers.test.ts @@ -1,8 +1,9 @@ -import { getWalletStatus, hasMetamaskWithSnaps } from '@/keystore/snapHelpers' import { keystore } from '@xmtp/proto' -import { b64Encode } from '@/utils/bytes' -import { SNAP_LOCAL_ORIGIN } from '@/keystore/providers/SnapProvider' import { vi } from 'vitest' +import { SNAP_LOCAL_ORIGIN } from '@/keystore/providers/SnapProvider' +import { getWalletStatus, hasMetamaskWithSnaps } from '@/keystore/snapHelpers' +import { b64Encode } from '@/utils/bytes' + const { GetKeystoreStatusRequest, GetKeystoreStatusResponse, diff --git a/test/utils/topic.test.ts b/test/utils/topic.test.ts index 10143f748..d461a36a7 100644 --- a/test/utils/topic.test.ts +++ b/test/utils/topic.test.ts @@ -1,9 +1,9 @@ +import crypto from '@/crypto/crypto' import { buildContentTopic, buildDirectMessageTopicV2, isValidTopic, } from '@/utils/topic' -import crypto from '@/crypto/crypto' describe('topic utils', () => { describe('isValidTopic', () => { diff --git a/vitest.config.ts b/vitest.config.ts index da31aa1d6..b8b42adb3 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -1,7 +1,7 @@ /// import { defineConfig, mergeConfig } from 'vite' -import { defineConfig as defineVitestConfig } from 'vitest/config' import tsconfigPaths from 'vite-tsconfig-paths' +import { defineConfig as defineVitestConfig } from 'vitest/config' // https://vitejs.dev/config/ const viteConfig = defineConfig({ diff --git a/yarn.lock b/yarn.lock index 8c2b98a84..abebd02a5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -19,6 +19,16 @@ __metadata: languageName: node linkType: hard +"@ampproject/remapping@npm:^2.2.0": + version: 2.3.0 + resolution: "@ampproject/remapping@npm:2.3.0" + dependencies: + "@jridgewell/gen-mapping": "npm:^0.3.5" + "@jridgewell/trace-mapping": "npm:^0.3.24" + checksum: 10/f3451525379c68a73eb0a1e65247fbf28c0cccd126d93af21c75fceff77773d43c0d4a2d51978fb131aff25b5f2cb41a9fe48cc296e61ae65e679c4f6918b0ab + languageName: node + linkType: hard + "@ampproject/remapping@npm:^2.2.1": version: 2.2.1 resolution: "@ampproject/remapping@npm:2.2.1" @@ -73,7 +83,7 @@ __metadata: languageName: node linkType: hard -"@babel/code-frame@npm:^7.0.0, @babel/code-frame@npm:^7.21.4, @babel/code-frame@npm:^7.22.13": +"@babel/code-frame@npm:^7.0.0, @babel/code-frame@npm:^7.21.4, @babel/code-frame@npm:^7.22.13, @babel/code-frame@npm:^7.23.5": version: 7.23.5 resolution: "@babel/code-frame@npm:7.23.5" dependencies: @@ -83,6 +93,129 @@ __metadata: languageName: node linkType: hard +"@babel/compat-data@npm:^7.23.5": + version: 7.23.5 + resolution: "@babel/compat-data@npm:7.23.5" + checksum: 10/088f14f646ecbddd5ef89f120a60a1b3389a50a9705d44603dca77662707d0175a5e0e0da3943c3298f1907a4ab871468656fbbf74bb7842cd8b0686b2c19736 + languageName: node + linkType: hard + +"@babel/core@npm:^7.24.0": + version: 7.24.0 + resolution: "@babel/core@npm:7.24.0" + dependencies: + "@ampproject/remapping": "npm:^2.2.0" + "@babel/code-frame": "npm:^7.23.5" + "@babel/generator": "npm:^7.23.6" + "@babel/helper-compilation-targets": "npm:^7.23.6" + "@babel/helper-module-transforms": "npm:^7.23.3" + "@babel/helpers": "npm:^7.24.0" + "@babel/parser": "npm:^7.24.0" + "@babel/template": "npm:^7.24.0" + "@babel/traverse": "npm:^7.24.0" + "@babel/types": "npm:^7.24.0" + convert-source-map: "npm:^2.0.0" + debug: "npm:^4.1.0" + gensync: "npm:^1.0.0-beta.2" + json5: "npm:^2.2.3" + semver: "npm:^6.3.1" + checksum: 10/1e22215cc89e061e0cbfed72f265ad24d363f3e9b24b51e9c4cf3ccb9222260a29a1c1e62edb439cb7e2229a3fce924edd43300500416613236c13fc8d62a947 + languageName: node + linkType: hard + +"@babel/generator@npm:^7.23.6": + version: 7.23.6 + resolution: "@babel/generator@npm:7.23.6" + dependencies: + "@babel/types": "npm:^7.23.6" + "@jridgewell/gen-mapping": "npm:^0.3.2" + "@jridgewell/trace-mapping": "npm:^0.3.17" + jsesc: "npm:^2.5.1" + checksum: 10/864090d5122c0aa3074471fd7b79d8a880c1468480cbd28925020a3dcc7eb6e98bedcdb38983df299c12b44b166e30915b8085a7bc126e68fa7e2aadc7bd1ac5 + languageName: node + linkType: hard + +"@babel/helper-compilation-targets@npm:^7.23.6": + version: 7.23.6 + resolution: "@babel/helper-compilation-targets@npm:7.23.6" + dependencies: + "@babel/compat-data": "npm:^7.23.5" + "@babel/helper-validator-option": "npm:^7.23.5" + browserslist: "npm:^4.22.2" + lru-cache: "npm:^5.1.1" + semver: "npm:^6.3.1" + checksum: 10/05595cd73087ddcd81b82d2f3297aac0c0422858dfdded43d304786cf680ec33e846e2317e6992d2c964ee61d93945cbf1fa8ec80b55aee5bfb159227fb02cb9 + languageName: node + linkType: hard + +"@babel/helper-environment-visitor@npm:^7.22.20": + version: 7.22.20 + resolution: "@babel/helper-environment-visitor@npm:7.22.20" + checksum: 10/d80ee98ff66f41e233f36ca1921774c37e88a803b2f7dca3db7c057a5fea0473804db9fb6729e5dbfd07f4bed722d60f7852035c2c739382e84c335661590b69 + languageName: node + linkType: hard + +"@babel/helper-function-name@npm:^7.23.0": + version: 7.23.0 + resolution: "@babel/helper-function-name@npm:7.23.0" + dependencies: + "@babel/template": "npm:^7.22.15" + "@babel/types": "npm:^7.23.0" + checksum: 10/7b2ae024cd7a09f19817daf99e0153b3bf2bc4ab344e197e8d13623d5e36117ed0b110914bc248faa64e8ccd3e97971ec7b41cc6fd6163a2b980220c58dcdf6d + languageName: node + linkType: hard + +"@babel/helper-hoist-variables@npm:^7.22.5": + version: 7.22.5 + resolution: "@babel/helper-hoist-variables@npm:7.22.5" + dependencies: + "@babel/types": "npm:^7.22.5" + checksum: 10/394ca191b4ac908a76e7c50ab52102669efe3a1c277033e49467913c7ed6f7c64d7eacbeabf3bed39ea1f41731e22993f763b1edce0f74ff8563fd1f380d92cc + languageName: node + linkType: hard + +"@babel/helper-module-imports@npm:^7.22.15": + version: 7.22.15 + resolution: "@babel/helper-module-imports@npm:7.22.15" + dependencies: + "@babel/types": "npm:^7.22.15" + checksum: 10/5ecf9345a73b80c28677cfbe674b9f567bb0d079e37dcba9055e36cb337db24ae71992a58e1affa9d14a60d3c69907d30fe1f80aea105184501750a58d15c81c + languageName: node + linkType: hard + +"@babel/helper-module-transforms@npm:^7.23.3": + version: 7.23.3 + resolution: "@babel/helper-module-transforms@npm:7.23.3" + dependencies: + "@babel/helper-environment-visitor": "npm:^7.22.20" + "@babel/helper-module-imports": "npm:^7.22.15" + "@babel/helper-simple-access": "npm:^7.22.5" + "@babel/helper-split-export-declaration": "npm:^7.22.6" + "@babel/helper-validator-identifier": "npm:^7.22.20" + peerDependencies: + "@babel/core": ^7.0.0 + checksum: 10/583fa580f8e50e6f45c4f46aa76a8e49c2528deb84e25f634d66461b9a0e2420e13979b0a607b67aef67eaf8db8668eb9edc038b4514b16e3879fe09e8fd294b + languageName: node + linkType: hard + +"@babel/helper-simple-access@npm:^7.22.5": + version: 7.22.5 + resolution: "@babel/helper-simple-access@npm:7.22.5" + dependencies: + "@babel/types": "npm:^7.22.5" + checksum: 10/7d5430eecf880937c27d1aed14245003bd1c7383ae07d652b3932f450f60bfcf8f2c1270c593ab063add185108d26198c69d1aca0e6fb7c6fdada4bcf72ab5b7 + languageName: node + linkType: hard + +"@babel/helper-split-export-declaration@npm:^7.22.6": + version: 7.22.6 + resolution: "@babel/helper-split-export-declaration@npm:7.22.6" + dependencies: + "@babel/types": "npm:^7.22.5" + checksum: 10/e141cace583b19d9195f9c2b8e17a3ae913b7ee9b8120246d0f9ca349ca6f03cb2c001fd5ec57488c544347c0bb584afec66c936511e447fd20a360e591ac921 + languageName: node + linkType: hard + "@babel/helper-string-parser@npm:^7.23.4": version: 7.23.4 resolution: "@babel/helper-string-parser@npm:7.23.4" @@ -97,6 +230,24 @@ __metadata: languageName: node linkType: hard +"@babel/helper-validator-option@npm:^7.23.5": + version: 7.23.5 + resolution: "@babel/helper-validator-option@npm:7.23.5" + checksum: 10/537cde2330a8aede223552510e8a13e9c1c8798afee3757995a7d4acae564124fe2bf7e7c3d90d62d3657434a74340a274b3b3b1c6f17e9a2be1f48af29cb09e + languageName: node + linkType: hard + +"@babel/helpers@npm:^7.24.0": + version: 7.24.0 + resolution: "@babel/helpers@npm:7.24.0" + dependencies: + "@babel/template": "npm:^7.24.0" + "@babel/traverse": "npm:^7.24.0" + "@babel/types": "npm:^7.24.0" + checksum: 10/cc82012161b30185c2698da359c7311cf019f0932f8fcb805e985fec9e0053c354f0534dc9961f3170eee579df6724eecd34b0f5ffaa155cdd456af59fbff86e + languageName: node + linkType: hard + "@babel/highlight@npm:^7.23.4": version: 7.23.4 resolution: "@babel/highlight@npm:7.23.4" @@ -117,6 +268,15 @@ __metadata: languageName: node linkType: hard +"@babel/parser@npm:^7.24.0": + version: 7.24.0 + resolution: "@babel/parser@npm:7.24.0" + bin: + parser: ./bin/babel-parser.js + checksum: 10/3e5ebb903a6f71629a9d0226743e37fe3d961e79911d2698b243637f66c4df7e3e0a42c07838bc0e7cc9fcd585d9be8f4134a145b9459ee4a459420fb0d1360b + languageName: node + linkType: hard + "@babel/runtime@npm:^7.13.8": version: 7.23.9 resolution: "@babel/runtime@npm:7.23.9" @@ -126,6 +286,46 @@ __metadata: languageName: node linkType: hard +"@babel/template@npm:^7.22.15, @babel/template@npm:^7.24.0": + version: 7.24.0 + resolution: "@babel/template@npm:7.24.0" + dependencies: + "@babel/code-frame": "npm:^7.23.5" + "@babel/parser": "npm:^7.24.0" + "@babel/types": "npm:^7.24.0" + checksum: 10/8c538338c7de8fac8ada691a5a812bdcbd60bd4a4eb5adae2cc9ee19773e8fb1a724312a00af9e1ce49056ffd3c3475e7287b5668cf6360bfb3f8ac827a06ffe + languageName: node + linkType: hard + +"@babel/traverse@npm:^7.24.0": + version: 7.24.0 + resolution: "@babel/traverse@npm:7.24.0" + dependencies: + "@babel/code-frame": "npm:^7.23.5" + "@babel/generator": "npm:^7.23.6" + "@babel/helper-environment-visitor": "npm:^7.22.20" + "@babel/helper-function-name": "npm:^7.23.0" + "@babel/helper-hoist-variables": "npm:^7.22.5" + "@babel/helper-split-export-declaration": "npm:^7.22.6" + "@babel/parser": "npm:^7.24.0" + "@babel/types": "npm:^7.24.0" + debug: "npm:^4.3.1" + globals: "npm:^11.1.0" + checksum: 10/5cc482248ebb79adcbcf021aab4e0e95bafe2a1736ee4b46abe6f88b59848ad73e15e219db8f06c9a33a14c64257e5b47e53876601e998a8c596accb1b7f4996 + languageName: node + linkType: hard + +"@babel/types@npm:^7.22.15, @babel/types@npm:^7.22.5, @babel/types@npm:^7.23.0, @babel/types@npm:^7.24.0": + version: 7.24.0 + resolution: "@babel/types@npm:7.24.0" + dependencies: + "@babel/helper-string-parser": "npm:^7.23.4" + "@babel/helper-validator-identifier": "npm:^7.22.20" + to-fast-properties: "npm:^2.0.0" + checksum: 10/a0b4875ce2e132f9daff0d5b27c7f4c4fcc97f2b084bdc5834e92c9d32592778489029e65d99d00c406da612d87b72d7a236c0afccaa1435c028d0c94c9b6da4 + languageName: node + linkType: hard + "@babel/types@npm:^7.23.6, @babel/types@npm:^7.8.3": version: 7.23.9 resolution: "@babel/types@npm:7.23.9" @@ -1101,6 +1301,26 @@ __metadata: languageName: node linkType: hard +"@ianvs/prettier-plugin-sort-imports@npm:^4.2.0": + version: 4.2.0 + resolution: "@ianvs/prettier-plugin-sort-imports@npm:4.2.0" + dependencies: + "@babel/core": "npm:^7.24.0" + "@babel/generator": "npm:^7.23.6" + "@babel/parser": "npm:^7.24.0" + "@babel/traverse": "npm:^7.24.0" + "@babel/types": "npm:^7.24.0" + semver: "npm:^7.5.2" + peerDependencies: + "@vue/compiler-sfc": 2.7.x || 3.x + prettier: 2 || 3 + peerDependenciesMeta: + "@vue/compiler-sfc": + optional: true + checksum: 10/c52cc499ffe0c2e6b63307e4cf3e1934ac39b1fb1859d0646cff6a063f51ec1c83ac19452d572f20f9d6d0646cf24fd1962590e6a7ad5bf28948c550f00692c4 + languageName: node + linkType: hard + "@isaacs/cliui@npm:^8.0.2": version: 8.0.2 resolution: "@isaacs/cliui@npm:8.0.2" @@ -1149,6 +1369,17 @@ __metadata: languageName: node linkType: hard +"@jridgewell/gen-mapping@npm:^0.3.2, @jridgewell/gen-mapping@npm:^0.3.5": + version: 0.3.5 + resolution: "@jridgewell/gen-mapping@npm:0.3.5" + dependencies: + "@jridgewell/set-array": "npm:^1.2.1" + "@jridgewell/sourcemap-codec": "npm:^1.4.10" + "@jridgewell/trace-mapping": "npm:^0.3.24" + checksum: 10/81587b3c4dd8e6c60252122937cea0c637486311f4ed208b52b62aae2e7a87598f63ec330e6cd0984af494bfb16d3f0d60d3b21d7e5b4aedd2602ff3fe9d32e2 + languageName: node + linkType: hard + "@jridgewell/resolve-uri@npm:^3.1.0": version: 3.1.2 resolution: "@jridgewell/resolve-uri@npm:3.1.2" @@ -1163,6 +1394,13 @@ __metadata: languageName: node linkType: hard +"@jridgewell/set-array@npm:^1.2.1": + version: 1.2.1 + resolution: "@jridgewell/set-array@npm:1.2.1" + checksum: 10/832e513a85a588f8ed4f27d1279420d8547743cc37fcad5a5a76fc74bb895b013dfe614d0eed9cb860048e6546b798f8f2652020b4b2ba0561b05caa8c654b10 + languageName: node + linkType: hard + "@jridgewell/source-map@npm:^0.3.3": version: 0.3.5 resolution: "@jridgewell/source-map@npm:0.3.5" @@ -1190,6 +1428,16 @@ __metadata: languageName: node linkType: hard +"@jridgewell/trace-mapping@npm:^0.3.17, @jridgewell/trace-mapping@npm:^0.3.24": + version: 0.3.25 + resolution: "@jridgewell/trace-mapping@npm:0.3.25" + dependencies: + "@jridgewell/resolve-uri": "npm:^3.1.0" + "@jridgewell/sourcemap-codec": "npm:^1.4.14" + checksum: 10/dced32160a44b49d531b80a4a2159dceab6b3ddf0c8e95a0deae4b0e894b172defa63d5ac52a19c2068e1fe7d31ea4ba931fbeec103233ecb4208953967120fc + languageName: node + linkType: hard + "@jridgewell/trace-mapping@npm:^0.3.9": version: 0.3.22 resolution: "@jridgewell/trace-mapping@npm:0.3.22" @@ -2671,6 +2919,7 @@ __metadata: dependencies: "@commitlint/cli": "npm:19.0.3" "@commitlint/config-conventional": "npm:19.0.3" + "@ianvs/prettier-plugin-sort-imports": "npm:^4.2.0" "@metamask/providers": "npm:^14.0.2" "@noble/secp256k1": "npm:1.7.1" "@rollup/plugin-json": "npm:^6.1.0" @@ -3330,6 +3579,20 @@ __metadata: languageName: node linkType: hard +"browserslist@npm:^4.22.2": + version: 4.23.0 + resolution: "browserslist@npm:4.23.0" + dependencies: + caniuse-lite: "npm:^1.0.30001587" + electron-to-chromium: "npm:^1.4.668" + node-releases: "npm:^2.0.14" + update-browserslist-db: "npm:^1.0.13" + bin: + browserslist: cli.js + checksum: 10/496c3862df74565dd942b4ae65f502c575cbeba1fa4a3894dad7aa3b16130dc3033bc502d8848147f7b625154a284708253d9598bcdbef5a1e34cf11dc7bad8e + languageName: node + linkType: hard + "buffer-from@npm:^1.0.0": version: 1.1.2 resolution: "buffer-from@npm:1.1.2" @@ -3481,6 +3744,13 @@ __metadata: languageName: node linkType: hard +"caniuse-lite@npm:^1.0.30001587": + version: 1.0.30001597 + resolution: "caniuse-lite@npm:1.0.30001597" + checksum: 10/44a268113faeee51e249cbcb3924dc3765f26cd527a134e3bb720ed20d50abd8b9291500a88beee061cc03ae9f15ddc9045d57e30d25a98efeaff4f7bb8965c1 + languageName: node + linkType: hard + "cardinal@npm:^2.1.1": version: 2.1.1 resolution: "cardinal@npm:2.1.1" @@ -4007,7 +4277,7 @@ __metadata: languageName: node linkType: hard -"debug@npm:4, debug@npm:^4.0.0, debug@npm:^4.1.1, debug@npm:^4.3.1, debug@npm:^4.3.2, debug@npm:^4.3.3, debug@npm:^4.3.4": +"debug@npm:4, debug@npm:^4.0.0, debug@npm:^4.1.0, debug@npm:^4.1.1, debug@npm:^4.3.1, debug@npm:^4.3.2, debug@npm:^4.3.3, debug@npm:^4.3.4": version: 4.3.4 resolution: "debug@npm:4.3.4" dependencies: @@ -4228,6 +4498,13 @@ __metadata: languageName: node linkType: hard +"electron-to-chromium@npm:^1.4.668": + version: 1.4.703 + resolution: "electron-to-chromium@npm:1.4.703" + checksum: 10/e7927fbe75e56508dd0b4efeb0e69dfb8ee1e6e6aaf6f07c047b96ff530d8f49e1eaf51cae64c2d3c179e3932fb37661012ccaa4f36956dd96480219f3a23013 + languageName: node + linkType: hard + "elliptic@npm:6.5.4, elliptic@npm:^6.5.4": version: 6.5.4 resolution: "elliptic@npm:6.5.4" @@ -5319,6 +5596,13 @@ __metadata: languageName: node linkType: hard +"gensync@npm:^1.0.0-beta.2": + version: 1.0.0-beta.2 + resolution: "gensync@npm:1.0.0-beta.2" + checksum: 10/17d8333460204fbf1f9160d067e1e77f908a5447febb49424b8ab043026049835c9ef3974445c57dbd39161f4d2b04356d7de12b2eecaa27a7a7ea7d871cbedd + languageName: node + linkType: hard + "get-caller-file@npm:^2.0.5": version: 2.0.5 resolution: "get-caller-file@npm:2.0.5" @@ -5497,6 +5781,13 @@ __metadata: languageName: node linkType: hard +"globals@npm:^11.1.0": + version: 11.12.0 + resolution: "globals@npm:11.12.0" + checksum: 10/9f054fa38ff8de8fa356502eb9d2dae0c928217b8b5c8de1f09f5c9b6c8a96d8b9bd3afc49acbcd384a98a81fea713c859e1b09e214c60509517bb8fc2bc13c2 + languageName: node + linkType: hard + "globals@npm:^13.19.0, globals@npm:^13.24.0": version: 13.24.0 resolution: "globals@npm:13.24.0" @@ -6475,6 +6766,15 @@ __metadata: languageName: node linkType: hard +"jsesc@npm:^2.5.1": + version: 2.5.2 + resolution: "jsesc@npm:2.5.2" + bin: + jsesc: bin/jsesc + checksum: 10/d2096abdcdec56969764b40ffc91d4a23408aa2f351b4d1c13f736f25476643238c43fdbaf38a191c26b1b78fd856d965f5d4d0dde7b89459cd94025190cdf13 + languageName: node + linkType: hard + "json-buffer@npm:3.0.1": version: 3.0.1 resolution: "json-buffer@npm:3.0.1" @@ -6574,6 +6874,15 @@ __metadata: languageName: node linkType: hard +"json5@npm:^2.2.3": + version: 2.2.3 + resolution: "json5@npm:2.2.3" + bin: + json5: lib/cli.js + checksum: 10/1db67b853ff0de3534085d630691d3247de53a2ed1390ba0ddff681ea43e9b3e30ecbdb65c5e9aab49435e44059c23dbd6fee8ee619419ba37465bb0dd7135da + languageName: node + linkType: hard + "jsonc-parser@npm:^3.2.0": version: 3.2.1 resolution: "jsonc-parser@npm:3.2.1" @@ -7031,6 +7340,15 @@ __metadata: languageName: node linkType: hard +"lru-cache@npm:^5.1.1": + version: 5.1.1 + resolution: "lru-cache@npm:5.1.1" + dependencies: + yallist: "npm:^3.0.2" + checksum: 10/951d2673dcc64a7fb888bf3d13bc2fdf923faca97d89cdb405ba3dfff77e2b26e5798d405e78fcd7094c9e7b8b4dab2ddc5a4f8a11928af24a207b7c738ca3f8 + languageName: node + linkType: hard + "lru-cache@npm:^6.0.0": version: 6.0.0 resolution: "lru-cache@npm:6.0.0" @@ -7663,6 +7981,13 @@ __metadata: languageName: node linkType: hard +"node-releases@npm:^2.0.14": + version: 2.0.14 + resolution: "node-releases@npm:2.0.14" + checksum: 10/0f7607ec7db5ef1dc616899a5f24ae90c869b6a54c2d4f36ff6d84a282ab9343c7ff3ca3670fe4669171bb1e8a9b3e286e1ef1c131f09a83d70554f855d54f24 + languageName: node + linkType: hard + "nopt@npm:^6.0.0": version: 6.0.0 resolution: "nopt@npm:6.0.0" @@ -9240,7 +9565,7 @@ __metadata: languageName: node linkType: hard -"semver@npm:^7.0.0, semver@npm:^7.1.1, semver@npm:^7.1.2, semver@npm:^7.3.2, semver@npm:^7.3.4, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.5.3, semver@npm:^7.5.4, semver@npm:^7.6.0": +"semver@npm:^7.0.0, semver@npm:^7.1.1, semver@npm:^7.1.2, semver@npm:^7.3.2, semver@npm:^7.3.4, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.5.2, semver@npm:^7.5.3, semver@npm:^7.5.4, semver@npm:^7.6.0": version: 7.6.0 resolution: "semver@npm:7.6.0" dependencies: @@ -10371,6 +10696,20 @@ __metadata: languageName: node linkType: hard +"update-browserslist-db@npm:^1.0.13": + version: 1.0.13 + resolution: "update-browserslist-db@npm:1.0.13" + dependencies: + escalade: "npm:^3.1.1" + picocolors: "npm:^1.0.0" + peerDependencies: + browserslist: ">= 4.21.0" + bin: + update-browserslist-db: cli.js + checksum: 10/9074b4ef34d2ed931f27d390aafdd391ee7c45ad83c508e8fed6aaae1eb68f81999a768ed8525c6f88d4001a4fbf1b8c0268f099d0e8e72088ec5945ac796acf + languageName: node + linkType: hard + "uri-js@npm:^4.2.2": version: 4.4.1 resolution: "uri-js@npm:4.4.1" @@ -10807,6 +11146,13 @@ __metadata: languageName: node linkType: hard +"yallist@npm:^3.0.2": + version: 3.1.1 + resolution: "yallist@npm:3.1.1" + checksum: 10/9af0a4329c3c6b779ac4736c69fae4190ac03029fa27c1aef4e6bcc92119b73dea6fe5db5fe881fb0ce2a0e9539a42cdf60c7c21eda04d1a0b8c082e38509efb + languageName: node + linkType: hard + "yallist@npm:^4.0.0": version: 4.0.0 resolution: "yallist@npm:4.0.0"