![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
@civic/civic-sign
Advanced tools
The intention of this library is to provide an abstraction layer for retrieving a user’s DID and publicKey, as well as requesting proof by signing a message or transaction and finally verifying the proof is valid.
The following diagram can be used as reference in order to illustrate how the library will be used between the different Civic systems.
import { CivicSignProveFactory } from '@civic/civic-sign';
import { Keypair, Transaction } from '@solana/web3.js';
const keys = Keypair.generate();
const wallet: SolanaWalletAdapter = {
publicKey: keys.publicKey,
signTransaction: (transaction: Transaction) => {
transaction.sign(keys);
return Promise.resolve(transaction);
},
};
const { requestDid, requestProof, verify } = CivicSignProveFactory.createWithSolanaWallet(wallet);
const { did } = requestDid();
const signedProof = requestProof();
const verifiedProofResult = verifyProof(signedProof, did);
console.log(did, signedProof, verifiedProofResult);
import { CivicSignProveFactory } from '@civic/civic-sign';
import { Wallet } from 'ethers';
const wallet = Wallet.createRandom();
const walletAdapter = {
...wallet,
signTypedData: (domain: TypedDataDomain, types: Record<string, TypedDataField[]>, value: EthPowoMessage) => {
return wallet._signTypedData(domain, types, value);
},
verifierAddress: 'verifierAddress',
};
const { requestDid, requestProof, verify } = CivicSignProveFactory.createWithEthereumWallet(walletAdapter);
const { did } = requestDid();
const signedProof = requestProof();
const verifiedProofResult = verifyProof(signedProof);
console.log(did, signedProof, verifiedProofResult);
import { CivicSignProveFactory } from '@civic/civic-sign';
const wallet = {
principal:
"example-principal",
};
const { requestDid, requestProof, verify } = CivicSignProveFactory.createWithICPWallet(wallet);
const { did } = requestDid();
const signedProof = requestProof();
const verifiedProofResult = verifyProof(signedProof);
console.log(did, signedProof, verifiedProofResult);
CivicSign has the following public Api methods available. Please refer to the docs for additional information available in the project.
Method | Description | Returns |
---|---|---|
createWithSolanaWallet | create an instance of CivicSign with an instance of a SolanaWalletAdapter | CivicSignProve |
createWithEthereumWallet | create an instance of CivicSign with an instance of a EthereumGatewayWallet | CivicSignProve |
createWithSolanaInIframe | create an instance of CivicSign for communicating with a remote instance of a Solana Wallet | CivicSignProve |
createWithEthereumInIframe | create an instance of CivicSign for communicating with a remote instance of an Ethereum Wallet | CivicSignProve |
Method | Description | Returns |
---|---|---|
requestDid | requests a DID from a wallet instance or remotely | Promise |
requestProof | requests a proof to be signed either through a wallet instance or remotely | Promise |
signMessage | requests the user to sign a message | Promise |
Method | Description | Returns |
---|---|---|
verify | verify a proof that was returned from requestProof is valid | Promise |
To check whether a given wallet owns a given DID:
import { walletOwnsDID } from '@civic/civic-sign';
const walletAddress = '016752701213E0D5Ee093A355c4d8e16b15525177e3C97DB5F9E2AC7C69F5Bfd52';
const did = 'did:key:z6MkmQaws5ASXmntxzybdK4piNKTFQh17cJK3JEURfhbMX2Z';
const doesWalletOwnDid = await walletOwnsDID(walletAddress, did);
This will:
capabilityInvocations
or authentication
lists )The following commands are availabe when contriburing to the project.
yarn lint
Checks that the project lints successfully. This automatically gets run before building the project.
yarn test
Checks that all unit and integration tests pass. This automatically gets run before building the project.
yarn generateDocs
Generate docs based on the available types in the project.
yarn publish
Published a new version of the CivicSign library to NPM. Running the command will build the dist folder before continuing to publish.
The prove-icp-principal
library uses WASM which requires certain options to be configured in next.config.js in order to compile i.e.
/** @type {import('next').NextConfig} */
const nextConfig = {
webpack: (config, { isServer }) => {
// Enable WebAssembly support
config.experiments = {
asyncWebAssembly: true,
syncWebAssembly: true,
};
// Add rule for WebAssembly files
config.module.rules.push({
test: /\.wasm$/,
type: "webassembly/async",
});
return config;
},
};
module.exports = nextConfig;
FAQs
An abstraction around proof of ownership using DIDs
The npm package @civic/civic-sign receives a total of 0 weekly downloads. As such, @civic/civic-sign popularity was classified as not popular.
We found that @civic/civic-sign demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 13 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.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.