### Install @slide-computer/signer with npm Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-client/README.md This command installs the `@slide-computer/signer` package using npm. It adds the package as a dependency to your project, allowing you to import and use its functionalities. This is a prerequisite for using the `SignerClient` in your application. ```bash npm i --save @slide-computer/signer ``` -------------------------------- ### Install @slide-computer/signer-agent with npm Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-agent/README.md This snippet demonstrates how to install the `@slide-computer/signer-agent` package using npm. It adds the package as a dependency to your project, making it available for use in your application. ```npm npm i --save @slide-computer/signer-agent ``` -------------------------------- ### Install @slide-computer/signer-extension NPM Package Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-extension/README.md This snippet demonstrates how to install the `@slide-computer/signer-extension` library using npm. Executing this command adds the package as a dependency to your project, making its functionalities available for use. ```bash npm i --save @slide-computer/signer-extension ``` -------------------------------- ### Install @slide-computer/signer-web with npm Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-web/README.md This snippet demonstrates how to install the `@slide-computer/signer-web` library using npm. It adds the package as a dependency to your project, enabling communication with web signers on the Internet Computer. ```Shell npm i --save @slide-computer/signer-web ``` -------------------------------- ### Install AuthClientTransport with npm Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-transport-auth-client/README.md This snippet demonstrates how to install the `@slide-computer/signer-transport-auth-client` library using npm. It's a required dependency for integrating AuthClientTransport into your JavaScript or TypeScript project. ```Shell npm i --save @slide-computer/signer-transport-auth-client ``` -------------------------------- ### Setting Up signer-js Development Environment Source: https://github.com/slide-computer/signer-js/blob/main/README.md This snippet outlines the essential steps to prepare your local machine for developing with signer-js. It covers cloning the repository and installing all necessary dependencies using npm, ensuring the project is ready for development. ```bash git clone npm i -g npm npm install ``` -------------------------------- ### Install @slide-computer/signer-signatures with npm Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-signatures/README.md This snippet demonstrates how to install the @slide-computer/signer-signatures package using npm. It adds the package as a dependency to your project, allowing you to import and use its functionalities. ```bash npm i --save @slide-computer/signer-signatures ``` -------------------------------- ### Integrate PostMessageTransport with Signer Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-web/README.md This example demonstrates how to integrate the initialized `PostMessageTransport` with the `@slide-computer/signer` library. It creates a new `Signer` instance, enabling high-level signer operations. ```JavaScript const signer = new Signer({transport}); ``` -------------------------------- ### Install @slide-computer/signer with npm Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer/README.md This snippet demonstrates how to install the @slide-computer/signer library using npm, a package manager for JavaScript. It adds the library as a dependency to your project, making it available for use in your application. ```bash npm i --save @slide-computer/signer ``` -------------------------------- ### Install @slide-computer/signer-transport-stoic npm Package Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-transport-stoic/README.md This snippet demonstrates how to install the @slide-computer/signer-transport-stoic package using npm. It adds the library as a project dependency, enabling communication with Stoic Wallet. ```npm npm i --save @slide-computer/signer-transport-stoic ``` -------------------------------- ### Install @slide-computer/signer-storage with npm Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-storage/README.md This snippet demonstrates how to install the @slide-computer/signer-storage library using npm. This library is a crucial dependency for the signer library on the Internet Computer, providing robust storage implementations. It supports both ECDSAKeyIdentity (recommended for secure IdbStorage) and Ed25519KeyIdentity, along with DelegationChain storage. ```bash npm i --save @slide-computer/signer-storage ``` -------------------------------- ### Install @slide-computer/signer-test npm package Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-test/README.md Install the `@slide-computer/signer-test` library using npm. This package provides JavaScript and TypeScript functionalities for signer tests on the Internet Computer. It is a core dependency for using the library's features. ```bash npm i --save @slide-computer/signer-test ``` -------------------------------- ### Import SignerClient in JavaScript browser environments Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-client/README.md This JavaScript import statement allows you to use the `SignerClient` class in a browser environment. It assumes the `@slide-computer/signer-client` package is installed and available. This is the first step to instantiate the client for authentication. ```javascript import { SignerClient } from "@slide-computer/signer-client"; ``` -------------------------------- ### Discover and Select Available Browser Extension Signers Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-extension/README.md This snippet illustrates how to discover all installed browser extension signers on a user's system. It retrieves a list of `providerDetails`, allowing the application to present choices to the user and then instantiate a `BrowserExtensionTransport` for the selected signer. ```JavaScript const providerDetails = await BrowserExtensionTransport.discover(); const providerDetail = await askUserToChoose(providerDetails); const transport = new BrowserExtensionTransport({providerDetail}); ``` -------------------------------- ### Correct Channel Establishment in Click Handler Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-web/README.md This example demonstrates the correct way to establish a channel within a click handler. The `await` call for `icpActorSigner.transfer` is directly inside the `transfer` function, which is then called by the `onClick` handler, preventing popup blocking issues. ```JavaScript const transfer = async (amount) => { await icpActorSigner.transfer(targetAddress, amount); } transferButton.onClick = () => transfer(50000n); ``` -------------------------------- ### Manually Batch and Execute Multiple Calls with SignerAgent Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-agent/README.md This advanced example illustrates how to manually batch and execute multiple calls using `SignerAgent`'s `batch()` and `execute()` methods. It allows for scheduling several asynchronous operations, including ledger approvals and actor calls, to be executed together in a single batch transaction, with fallback to sequential execution if batching is not supported. ```javascript import {IcrcLedgerCanister} from "@dfinity/ledger-icrc"; const icpLedger = IcrcLedgerCanister.create({ agent, canisterId: ICP_LEDGER_CANISTER_ID, }); const ckBtcLedger = IcrcLedgerCanister.create({ agent, canisterId: CK_BTC_LEDGER_CANISTER_ID, }); agent.batch(); // Below execution of calls needs to be triggered manually const icpBlockIndexPromise = icpLedger.approve({ spender: TARGET_ACCOUNT, amount: 70_000_000 }); const ckBtcBlockIndexPromise = ckBtcLedger.approve({ spender: TARGET_ACCOUNT, amount: 1_000_000 }); agent.batch() // Indicate that below calls should be executed by the signer after the above const swapResultPromise = backendActor.swapTokens(swapId); // Trigger execution of all the above scheduled calls // // If a signer does not support batch calls, signerAgent will // automatically fallback to executing the calls one by one. await agent.execute(); // Get individual results const icpBlockIndex = await icpBlockIndexPromise; const ckBtcBlockIndex = await ckBtcBlockIndexPromise; const swapResult = await swapResultPromise; ``` -------------------------------- ### Automatically Batch Multiple Ledger Calls with SignerAgent Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-agent/README.md This example demonstrates how `SignerAgent` can automatically batch multiple ledger calls using `Promise.all`. It performs two separate `approve` operations on different ledger canisters, with the agent automatically handling batching or falling back to sequential execution if batching is not supported by the signer. ```javascript import {IcrcLedgerCanister} from "@dfinity/ledger-icrc"; const icpLedger = IcrcLedgerCanister.create({ agent, canisterId: ICP_LEDGER_CANISTER_ID, }); const ckBtcLedger = IcrcLedgerCanister.create({ agent, canisterId: CK_BTC_LEDGER_CANISTER_ID, }); // If a signer does not support batch calls, signerAgent will // automatically fallback to executing the calls one by one. const [icpBlockIndex, ckBtcBlockIndex] = await Promise.all([ icpLedger.approve({ spender: TARGET_ACCOUNT, amount: 70_000_000 }), ckBtcLedger.approve({ spender: TARGET_ACCOUNT, amount: 1_000_000 }) ]); ``` -------------------------------- ### Log in using SignerClient with options Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-client/README.md This code snippet shows how to initiate the login process using the `signerClient` instance. It accepts an options object, including `maxTimeToLive` for session duration and an `onSuccess` callback for post-authentication actions. The `onSuccess` callback is invoked upon successful authentication, typically to update UI or application state. ```javascript signerClient.login({ // 7 days in nanoseconds maxTimeToLive: BigInt(7 * 24 * 60 * 60 * 1000 * 1000 * 1000), onSuccess: async () => { handleAuthenticated(signerClient); } }); ``` -------------------------------- ### Create a SignerClient instance in JavaScript Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-client/README.md This JavaScript snippet demonstrates how to asynchronously create an instance of `SignerClient`. It requires a `signer` object as a dependency, which is used for cryptographic operations. The returned `signerClient` object is then used for subsequent authentication steps. ```javascript const signerClient = await SignerClient.create({signer}); ``` -------------------------------- ### Create a SignerAgent Instance for Transactions Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-agent/README.md This code demonstrates how to create an instance of `SignerAgent` using an existing signer and an account owner. The `SignerAgent` facilitates initiating transactions on the Internet Computer, linking a signer with a specific account. ```javascript const accounts = await signer.accounts(); const agent = await SignerAgent.create({ signer, account: accounts[0].owner }); ``` -------------------------------- ### Initialize Signer with BrowserExtensionTransport Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-extension/README.md This snippet demonstrates how to integrate the `BrowserExtensionTransport` with the `@slide-computer/signer` library. By passing the `transport` instance to the `Signer` constructor, you enable the `Signer` to communicate with the browser extension for cryptographic operations. ```JavaScript const signer = new Signer({transport}); ``` -------------------------------- ### Create AuthClientTransport Instance in JavaScript Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-transport-auth-client/README.md This snippet illustrates how to asynchronously create an instance of `AuthClientTransport`. This instance is fundamental for establishing secure communication channels with Internet Identity and managing authentication flows. ```JavaScript const transport = await AuthClientTransport.create(); ``` -------------------------------- ### Establish Direct Channel for Custom Implementation Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-extension/README.md This snippet shows how to establish a direct communication channel with the browser extension transport for custom implementations. It allows you to register a listener for incoming responses and send outgoing JSON-RPC requests, providing fine-grained control over the interaction. ```JavaScript const channel = await transport.establishChannel(); const listener = channel.registerListener((response) => { // Process incoming responses }); // Send outgoing requests channel.send(JSON_RPC_REQUEST); ``` -------------------------------- ### Initialize Signer Instance with a Transport Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer/README.md This snippet demonstrates how to create a new instance of the Signer class, which requires a transport object (e.g., from "@slide-computer/signer-web"). The transport is essential for facilitating communication between your application and the Internet Computer signer. ```javascript // Create transport with e.g. "@slide-computer/signer-web" const signer = new Signer({transport}); ``` -------------------------------- ### Available Signer Transports and Supported Wallets Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer/README.md This section lists the standardized and polyfill transport packages available for the @slide-computer/signer library, along with the Internet Computer signers they support. These transports enable interaction with various wallets and identity providers. ```APIDOC | Standardized packages | Supported signers | |------------------------------------|-------------------| | `@slide-computer/signer-web` | NFID, Oisy, Slide | | `@slide-computer/signer-extension` | PrimeVault | | Polyfill packages | Supported signers | |------------------------------------------------|-------------------| | `@slide-computer/signer-transport-plug` | Plug | | `@slide-computer/signer-transport-stoic` | Stoic | | `@slide-computer/signer-transport-auth-client` | Internet Identity | ``` -------------------------------- ### Initialize Signer with AgentTransport Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-test/README.md Initialize a new `Signer` instance from `@slide-computer/signer` using the previously created `transport` object. This configures the signer to use the established communication channel. The `Signer` object is then ready to perform cryptographic operations. ```javascript const signer = new Signer({transport}); ``` -------------------------------- ### Initialize ICRC-29 PostMessageTransport Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-web/README.md This snippet illustrates how to create an instance of `PostMessageTransport` for ICRC-29. It configures the transport to open a new window for signer interactions, specifying the RPC URL and window name. ```JavaScript const transport = new PostMessageTransport({ openWindow: () => window.open(SIGNER_RPC_URL, SIGNER_WINDOW_NAME) }); ``` -------------------------------- ### Create an Asynchronous StoicTransport Instance in JavaScript Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-transport-stoic/README.md This snippet illustrates how to asynchronously create an instance of StoicTransport. This instance serves as the primary interface for establishing and managing communication channels with the Stoic Wallet. ```JavaScript const transport = await StoicTransport.create(); ``` -------------------------------- ### Fetch Accounts Using the Signer Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer/README.md This snippet shows how to retrieve a list of accounts associated with the connected signer. The `accounts()` method asynchronously fetches the available accounts, providing access to the user's identities. ```javascript const accounts = await signer.accounts(); ``` -------------------------------- ### Import PostMessageTransport in Browser Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-web/README.md This code shows how to import the `PostMessageTransport` class from the `@slide-computer/signer-web` library for use in a browser environment. It's the first step to setting up communication with web signers. ```TypeScript import { PostMessageTransport } from "@slide-computer/signer-web"; ``` -------------------------------- ### Establish Signer Communication Channel with Relying Party Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-web/README.md This code demonstrates how a signer can establish a communication channel with a relying party using `HeartBeatServer`. It defines callbacks for channel establishment, timeout, and disconnection, allowing the signer to process requests and manage the connection lifecycle. ```JavaScript new HeartBeatServer({ onEstablish: (origin, source) => { // 1. Show origin to user to identify the relying party // 2. Use origin and source to communicate with relying party }, onEstablishTimeout: () => { // Wrong place // Seems you arrived here for approval, // but no service has requested it. }, onDisconnect: () => { // Connection closed // It seems like the connection with // the service closed unexpectedly. } }); ``` -------------------------------- ### Implement Custom Signer Interaction with Transport Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-web/README.md This code shows how to directly use the `PostMessageTransport` in a custom implementation. It establishes a communication channel within a click handler, registers a listener for responses, and sends requests, emphasizing the need for channel establishment within user interaction. ```JavaScript actionButton.onClick = async () => { // Must be established within a click handler // to avoid the signer popup from being blocked. const channel = await transport.establishChannel(); const listener = channel.registerListener((response) => { // Process incoming responses }); // Send outgoing requests channel.send(JSON_RPC_REQUEST); } ``` -------------------------------- ### Initiate a Single ICP Ledger Transfer with SignerAgent Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-agent/README.md This snippet shows how to perform a single ICP ledger transfer using the `SignerAgent`. It creates an `IcrcLedgerCanister` instance and then calls its `transfer` method to send a specified amount to a target account, returning the block index. ```javascript import {IcrcLedgerCanister} from "@dfinity/ledger-icrc"; const icpLedger = IcrcLedgerCanister.create({ agent, canisterId: ICP_LEDGER_CANISTER_ID, }); const blockIndex = await icpLedger.transfer({ to: TARGET_ACCOUNT, amount: 100_000_000 }); ``` -------------------------------- ### Request Account Permissions for Signer Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer/README.md This snippet demonstrates how to explicitly request permissions from the signer, specifically for accessing accounts. Requesting permissions beforehand can streamline subsequent operations and ensure the user's consent. ```javascript const permissions = await signer.requestPermissions([createAccountsPermissionScope()]); ``` -------------------------------- ### Integrate AuthClientTransport with @slide-computer/signer Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-transport-auth-client/README.md This snippet demonstrates how to integrate the created `AuthClientTransport` instance with the `@slide-computer/signer` library. The transport object is passed to the `Signer` constructor, enabling the signer to use this transport for its operations. ```JavaScript const signer = new Signer({transport}); ``` -------------------------------- ### Integrate StoicTransport with @slide-computer/signer Library Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-transport-stoic/README.md This snippet demonstrates how to integrate the StoicTransport instance with the @slide-computer/signer library. By passing the transport, you configure the signer to use Stoic Wallet for its underlying communication. ```JavaScript const signer = new Signer({transport}); ``` -------------------------------- ### Create BrowserExtensionTransport Instance by UUID Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-extension/README.md This snippet illustrates how to create a `BrowserExtensionTransport` instance by specifying a unique identifier (UUID) of a target browser extension wallet. This method directly connects to a known signer, facilitating secure communication for signing operations. ```JavaScript const transport = await BrowserExtensionTransport.findTransport({ // Globally unique identifier of the browser extension wallet you want to connect with uuid: 'b5ec333c-8854-47bd-be77-74059e0c64d6' }); ``` -------------------------------- ### Fix 2: Establish Channel Early in Click Handler Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-web/README.md This fix addresses the popup blocking by explicitly establishing the signer channel (`await signer.openChannel()`) as the very first asynchronous operation within the function called by the click handler. This ensures the channel is open before any subsequent `await` calls might shift context. ```JavaScript const transferFrom = async (amount) => { await signer.openChannel(); // or: await agent.signer.openChannel(); const allowance = await icpActorAnonymous.allowance(userAddress); if (allowance < amount) { await icpActorSigner.approve(amount - allowance); } await dappActor.transferWithAllowance(userAddress, amount); } swapButton.onClick = () => transferFrom(50000n); ``` -------------------------------- ### Import BrowserExtensionTransport in JavaScript/TypeScript Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-extension/README.md This snippet shows how to import the `BrowserExtensionTransport` class from the `@slide-computer/signer-extension` library. This import is essential for interacting with browser extension signers within your web application. ```JavaScript import { BrowserExtensionTransport } from "@slide-computer/signer-extension"; ``` -------------------------------- ### Use AuthClientTransport Directly for Custom Implementations Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-transport-auth-client/README.md This snippet shows how to use `AuthClientTransport` directly for custom communication implementations, bypassing the `@slide-computer/signer` library. It involves establishing a channel, registering a listener for incoming responses, and sending outgoing requests, providing fine-grained control over the communication flow. ```JavaScript const channel = await transport.establishChannel(); const listener = channel.registerListener((response) => { // Process incoming responses }); // Send outgoing requests channel.send(JSON_RPC_REQUEST); ``` -------------------------------- ### Implement custom channel with AgentTransport directly Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-test/README.md Demonstrate direct usage of `AgentTransport` for custom communication implementations. This involves establishing a channel, registering a listener for incoming responses, and sending outgoing JSON-RPC requests. This approach offers granular control over the communication flow, bypassing the higher-level `Signer` abstraction. ```javascript const channel = await transport.establishChannel(); const listener = channel.registerListener((response) => { // Process incoming responses }); // Send outgoing requests channel.send(JSON_RPC_REQUEST); ``` -------------------------------- ### Import SignerAgent in Browser Environments Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-agent/README.md This snippet shows how to import the `SignerAgent` class when working in a browser environment. It allows you to use the `SignerAgent` to interact with signers on the Internet Computer. ```javascript import { SignerAgent } from "@slide-computer/signer-agent"; ``` -------------------------------- ### Fix 1: Move Awaits Outside Click Handler Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-web/README.md This solution resolves the popup blocking issue by moving the initial `await` call (`allowance`) outside the function called by the click handler. This ensures that the channel establishment, if it occurs later, remains within the user interaction context. ```JavaScript const allowance = await icpActorAnonymous.allowance(userAddress); const transferFrom = async (amount) => { if (allowance < amount) { await icpActorSigner.approve(amount - allowance); } await dappActor.transferWithAllowance(userAddress, amount); } swapButton.onClick = () => transferFrom(50000n); ``` -------------------------------- ### Directly Establish and Use StoicTransport Communication Channel Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-transport-stoic/README.md This snippet shows how to directly establish a communication channel using StoicTransport for custom implementations. It includes registering a listener for incoming responses and sending outgoing JSON-RPC requests. ```JavaScript const channel = await transport.establishChannel(); const listener = channel.registerListener((response) => { // Process incoming responses }); // Send outgoing requests channel.send(JSON_RPC_REQUEST); ``` -------------------------------- ### Import AuthClientTransport in JavaScript/TypeScript for Browser Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-transport-auth-client/README.md This snippet shows how to import the `AuthClientTransport` class into your JavaScript or TypeScript project, typically for browser-based applications. Importing makes the class available for instantiation and use within your code. ```JavaScript import { AuthClientTransport } from "@slide-computer/signer-transport-auth-client"; ``` -------------------------------- ### Create an AgentTransport instance asynchronously Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-test/README.md Asynchronously create an instance of `AgentTransport`. This transport object serves as the communication layer for signer operations. It is a prerequisite for initializing a `Signer` or building custom communication channels. ```javascript const transport = await AgentTransport.create(); ``` -------------------------------- ### Import StoicTransport Class in Browser JavaScript Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-transport-stoic/README.md This snippet shows how to import the StoicTransport class into your browser-based JavaScript application. This import is necessary to utilize the Stoic Wallet transport functionality within your code. ```JavaScript import { StoicTransport } from "@slide-computer/signer-transport-stoic"; ``` -------------------------------- ### Import AgentTransport for browser usage Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-test/README.md Import the `AgentTransport` class from `@slide-computer/signer-test` for browser environments. This class is essential for creating a transport layer to interact with the Internet Computer. It enables the library's functionality in web applications. ```javascript import { AgentTransport } from "@slide-computer/signer-test"; ``` -------------------------------- ### Incorrect Channel Establishment (Causes Popup Block) Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer-web/README.md This snippet illustrates an incorrect pattern where an `await` call moves subsequent operations outside the click handler's context. This can lead to popups being blocked, especially in browsers like Safari, when the post message transport channel is established. ```JavaScript const transferFrom = async (amount) => { const allowance = await icpActorAnonymous.allowance(userAddress); // <- Issue if (allowance < amount) { await icpActorSigner.approve(amount - allowance); } await dappActor.transferWithAllowance(userAddress, amount); } swapButton.onClick = () => transferFrom(50000n); ``` -------------------------------- ### Import Signer Class in Browser JavaScript Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer/README.md This snippet shows how to import the Signer class from the @slide-computer/signer library when developing for browser environments. This makes the Signer class accessible for creating new signer instances within your browser-based application. ```javascript import { Signer } from "@slide-computer/signer"; ``` -------------------------------- ### Conditionally Connect Signer Transport Source: https://github.com/slide-computer/signer-js/blob/main/packages/signer/README.md This snippet illustrates how to conditionally connect the signer's transport if it requires an explicit connection and is not already connected. This step is crucial for transports that need to establish a connection before any operations can be performed. ```javascript if (transport.connection && !transport.connection.connected) { await transport.connection.connect(); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.