Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
ic-use-siwe-identity
Advanced tools
React hook and context provider for easy frontend integration with SIWE enabled Internet Computer canisters.
ic-use-siwe-identity
is a React hook and context provider for easy frontend integration with SIWE enabled Internet Computer canisters.
ic-use-siwe-identity
is part of the ic-siwe project that enables Ethereum wallet-based authentication for applications on the Internet Computer (IC) platform. The goal of the project is to enhance the interoperability between Ethereum and the Internet Computer platform, enabling developers to build applications that leverage the strengths of both platforms.
A SIWE enabled canister is a canister that integrates the ic_siwe library and exposes the SIWE login interface. The ic_siwe
library provides a set of functions for managing Internet Computer delegate identities created using Ethereum signatures.
ic_siwe
directly is using the prebuilt ic_siwe_provider canister. The provider canister can be added to your project as a dependency and used as a login provider for you project.On mount, the SiweIdentityProvider
component initializes by creating an anonymous actor and loading any existing identity from local storage.
The login process begins with the login
function. It requests a SIWE message from the backend, which the user signs using their Ethereum wallet.
Once the user signs the SIWE message, the library handles the authentication with the backend. It involves generating a session identity and establishing a delegation chain.
After successful backend authentication, the user's session identity and delegation chain are stored both locally and in the component's state, finalizing the login process.
In addition to ic-use-siwe-identity
, the following packages are required:
@dfinity/agent
@dfinity/identity
@dfinity/candid
wagmi
viem
npm install ic-use-siwe-identity @dfinity/agent @dfinity/identity @dfinity/candid wagmi viem
To use ic-use-siwe-identity
in your React application, follow these steps:
SiweIdentityProvider
componentWrap your application's root component with SiweIdentityProvider
to provide all child components access to the SIWE identity context. Provide the component with the _SERVICE
type argument, where _SERVICE
represents the canister service definition of a canister that implements the SIWE login interface.
// App.tsx
import { SiweIdentityProvider } from 'ic-use-siwe-identity';
import { _SERVICE } from "path-to/siwe-enabled-canister.did";
function App() {
return (
<SiweIdentityProvider<_SERVICE>
idlFactory={/* IDL Interface Factory */}
canisterId={/* Canister ID */}
// ...other props
>
{/* Your app components */}
</App>
);
}
useSiweIdentity
hookUse the useSiweIdentity hook in your components to access identity-related functionalities:
// Component.tsx
import { useSiweIdentity } from "ic-use-siwe-identity";
function MyComponent() {
const { login, clear, identity, ... } = useSiweIdentity();
// ...
}
{
/** Configuration options for the HTTP agent used to communicate with the Internet Computer network. */
httpAgentOptions?: HttpAgentOptions;
/** Configuration options for the actor. These options are passed to the actor upon its creation. */
actorOptions?: ActorConfig;
/** The Interface Description Language (IDL) factory for the canister. This factory is used to create an actor interface for the canister. */
idlFactory: IDL.InterfaceFactory;
/** The unique identifier of the canister on the Internet Computer network. This ID is used to establish a connection to the canister. */
canisterId: string;
/** The child components that the SiweIdentityProvider will wrap. This allows any child component to access the authentication context provided by the SiweIdentityProvider. */
children: ReactNode;
}
export type SiweIdentityContextType = {
/** Initiates the login process by requesting a SIWE message from the backend. */
login: () => void;
/** Clears the identity from the state and local storage. Effectively "logs the user out". */
clear: () => void;
/** Is set to `true` on mount until the identity is loaded from local storage. */
isLoading: boolean;
/** Is set to `true` while the login process is in progress. */
isLoggingIn: boolean;
/** Status of the SIWE message signing process. This is a re-export of the Wagmi
* signMessage / status type. */
signMessageStatus: "idle" | "pending" | "success" | "error";
/** The delegation chain is available after successfully loading the identity from local
* storage or completing the login process. */
delegationChain?: DelegationChain;
/** The identity is available after successfully loading the identity from local storage
* or completing the login process. */
identity?: DelegationIdentity;
/** The Ethereum address associated with current identity. This address is not necessarily
* the same as the address of the currently connected wallet - on wallet change, the addresses
* will differ. */
identityAddress?: string;
};
Contributions are welcome. Please submit your pull requests or open issues to propose changes or report bugs.
This project is licensed under the MIT License. See the LICENSE file for more details.
FAQs
React hook and context provider for easy frontend integration with SIWE enabled Internet Computer canisters.
We found that ic-use-siwe-identity demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.