npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

yousign-v3-client

v0.2.4

Published

TS Adapter for the YouSign V3 API

Downloads

143

Readme

yousign-v3-client

Installation

#npm
npm install yousign-v3-client

#yarn
yarn add yousign-v3-client

#pnpm
pnpm add yousign-v3-client

#bun
bun add yousign-v3-client

#deno
deno add @fischi20/yousign-v3-client

The package is also hosted on JSR. It's suggested to check it out even if it's just for the generated docs.

Runtimes

This package only has 2 dependencies, hookable and ofetch, both should be runtime agnostic, making this package also compatible to every runtime

Useful documentation

  • YouSign API is the main documentation for the YouSign API.
  • Hookable is the documentation for the hooks system to extend the client.
  • Ofetch library used to make the requests, you can use it to make calls to the API without needing to pass everything like baseUrl, auth headers etc every time.

Compatibility

The library is compatible with Node.js, Deno, Bun, browsers (not suggested) and Edge Runtime. For node esm and cjs are supported.

Basic Usage

   import { YouSignClient } from 'yousign-v3-client';

  const yousign = new YouSignClient(process.env.YOUSIGN_API_KEY, {environment: 'sandbox'});

  //1. Create a signature request
  const signatureRequest = await yousign.createSignatureRequest({ name: signatureName, delivery_mode: 'email' });
  //2. Add the files to the signature request
  await yousign.addDocument(signatureRequest.value!.id, {
   file,
   nature: "signable_document",
   parse_anchors: true,
  })
  //3.Add signers to the signature request
  await yousign.addSigner(signatureRequest.value!.id, {
   signature_level: 'electronic_signature',
   info: {
     first_name,
     last_name,
     email
       phone_number,
       locale
     },
     signature_authentication_mode: 'otp_sms',
     fields: [
       {
         type: 'signature',
         document_id: file.id,
         page: 1,
         x: 0,
         y: 0
       }
     ]
   })
  //4. Activate signature request
  await yousign.activateSignature(signatureRequest.id);

Hooks

Should be pretty self explanatory, but the hooks are overall structured as follows:

  • When an action is called, a hook is called with the arguments. The hook name starts with onBeforeActionName
  • When an action is completed, a hook is called with the response data from the API. The hook name starts with onAfterActionName
  • There is a general hook called onError which is called when an error occurs in any step of the process.

Hooks are implemented using the hookable library.

Fetch

If you want to make a request to the API without using the hooks, you can use the client.fetch member variable. The client.fetch has everything set up to make a request to the API with the correct headers and baseUrl already set up. The only thing you would need to do is passing the correct body/query params to the fetch function and the path to the API. the fetch function is based on the ofetch library.

IFrame

Yousign supports the usage of an iframe embeded to the website to sign the documents. This package reexports it as yousign-v3-client/iframe

import {Yousign} from "yousign-v3-client/iframe"

const yousign = new Yousign({
  signatureLink: 'signature_link',
  iframeContainerId: 'iframe-container',
  isSandbox: false,
});