This project is designed to facilitate local testing of ICP's Internet Identity, focusing primarily on the interaction with alternative frontend origins.
This local server allows developers to test the integration with ICP's Internet Identity by simulating the behavior of a real-world environment. The server provides a static file serving capability and is secured with HTTPS using locally-generated certificates.
- Node.js
mkcert
tool for generating local certificates (Installation Guide).
- Clone the repository:
git clone https://github.com/uniot-io/icp-anonymous-canister.git
cd icp-anonymous-canister
- Install the required Node.js packages:
npm install
- Run the server:
node index.js
-
HTTPS Support: To mimic a real-world scenario, the server runs on HTTPS protocol. The server will automatically generate the necessary certificates if they do not exist.
-
CORS: This server has CORS enabled to allow cross-origin requests, which is essential when testing Internet Identity integrations.
-
Static File Serving: The server serves static files placed in the
./static
directory. This can be useful for testing frontend assets with Internet Identity. -
Domain Configuration: The server uses a domain pattern
${principal}.icp0.io
. Theprincipal
is a unique identifier generated by the@dfinity/principal
package. The anonymous2vxsx-fae
Principal ID is used by default. If the domain is not configured locally, the server will provide instructions on how to do so.
-
Permission denied error: If you encounter a permission denied error when starting the server, it means you need to grant Node.js the permissions to bind to port 443.
-
Linux:
sudo setcap 'cap_net_bind_service=+ep' $(which node)
To revoke this permission later:
sudo setcap -r $(which node)
-
macOS: You'll need to run your server with elevated privileges using
sudo
.
-
-
Local Domain not Configured: If you get an error indicating that the local domain is not configured, follow the instructions provided by the server output to configure the domain locally.