Socket
Book a DemoInstallSign in
Socket

@ethsign/sign-sdk

Package Overview
Dependencies
Maintainers
0
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ethsign/sign-sdk

## Installation

latest
npmnpm
Version
0.1.9
Version published
Weekly downloads
27
285.71%
Maintainers
0
Weekly downloads
 
Created
Source

sign-sdk

Installation

npm install @ethsign/sign-sdk

Usage

server side

init
import { privateKeyToAccount } from 'viem/accounts';
import { SignClient } from '@ethsign/sign-sdk';
const privateKey = '0xxxxxx'; // eth private key
const tenantId = 'xxxx'; //sent us your publicKey to get it
const client = new SignClient({
  account: privateKeyToAccount(privateKey),
  tenantId: tenantId,
});

check contract status

const contractId = 'xxxx'; // main contract id
const userAddress = '0xxxxxx'; // eth address

const contractInfo = await client.checkContractStatus(contractId, userAddress);

generate webApiKey

const contractId = contractInfo.contractId; // come from checkContractStatus response
const webApiKey = await client.generateWebApiKey(contractId);

client side

init

import { SignWebClient } from '@ethsign/sign-sdk';

const webClient = new SignWebClient({
  getApiKey: async () => {
    return await getWebApiKey(); // request server side to get webApikey
  },
});
generate previewUrl
const contractId = contractInfo.contractId; // come from checkContractStatus response
const password = 'xxx'; //optional,if contract is password protected
const previewUrl = await webClient.generatePreviewUrl(contractId, password);
download contract
const contractId = contractInfo.contractId; // come from checkContractStatus response
const password = 'xxx'; //optional,if contract is password protected
const res = await webClient.downloadContract(contractId, password);
create contract
import { generateFileEncrypted,hashSha256 } from '@ethsign/sign-sdk';
import { createWalletClient, custom , privateKeyToAccount } from 'viem';
const file: File=;
const userAddress: string='0xabc';
const password: string='xxx';
const privateKey: string='0xabcxxx';
const fileEncrypted = await generateFileEncrypted({
  file,
  recipients: [
    {
      address: userAddress,
      chainType:'eth',
      email: '',
      x: 0,
      y: 0,
      page: 0,
      width: 100,
    },
  ],
  password,
});

const message = await hashSha256(fileEncrypted);
const account = privateKeyToAccount(privateKey);
const signature = await account.signMessage({ message });
const res = await client.createContract({
      creator: account.address,
      fileEncrypted,
      enableEncryption: !!password,
      enableExpiration: false,
      expireTime: 0,
      signature,
      title: file.name,
      recipients: [
        {
          address: account.address,
          email: '',
        },
      ],
 });
const timestamp = Date.now();
const account = privateKeyToAccount(privateKey); // owner of contract
const message = [contractId, timestamp].join(',');
const signature = await account.signMessage({ message });
const res = await client.createShareLink({
  contractId,
  timestamp,
  signature,
});
console.log(res, 'res');
get contract info
const timestamp = Date.now();
const account = privateKeyToAccount(privateKey);
const message = [contractId, timestamp].join(',');
const signature = await account.signMessage({ message });
const res = await client.getContractInfo({
  contractId,
  timestamp,
  signature,
});
console.log(res, 'res');

FAQs

Package last updated on 20 Feb 2025

Did you know?

Socket

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.

Install

Related posts