Document signing beta

Self allows you to request and manage digital signatures.

For example, you may need a user to digitally sign to indicate their agreement to your terms and conditions.

Plain text signatures

Self allows the signing of arbitrary text as demonstrated below:

@app.docs.request_signature ARGV[0], terms, [] do |resp|
    puts "Document signature : #{resp.status}"
end
res := client.DocsService().RequestSignature(os.Args[1], terms, []documents.InputObjects)
log.Println(res)
let resp = await sdk.docs().requestSignature(selfID, terms, [])
console.log(`Document signature : ${resp["status"]}`)

Object based signatures

Self allows the signing of BLOBs (like PDFs). The BLOBs are submitted in the request. The response will contain a list of signed objects.

objects = []
File.open('./sample.pdf') do |f|
    objects << {
        name: "Terms and conditions",
        data: f.read,
        mime: 'application/pdf'
    }
end
@app.docs.request_signature ARGV[0], terms, objects do |resp|
    if resp.status == 'accepted'
        puts "Document signed!".green
        puts ""
        puts "signed documents: "
        resp.signed_objects.each do |so|
            puts "- Name:  #{so[:name]}"
            puts "  Link:  #{so[:link]}"
            puts "  Hash:  #{so[:hash]}"
        end
        puts ""
        puts "full signature:"
        puts resp.input
    else
        puts "Document signature #{'rejected'.red}"
    end
    exit
end
# Check the full example on:
# https://github.com/joinself/self-ruby-sdk/examples/document_sign/app.rb
ds := client.DocsService()
content, err := ioutil.ReadFile("./sample.pdf")
if err != nil {
	log.Fatal(err)
}    
objects := make([]documents.InputObject, 0)
objects = append(objects, documents.InputObject{
	Name: "Terms and conditions",
	Data: content,
	Mime: "application/pdf",
})

log.Println("sending document sign request") resp, err := ds.RequestSignature(os.Args[1], "Read and sign this documents", objects) if err != nil { log.Println(err.Error()) } if resp.Status == "accepted" { fmt.Println("Document has been signed") fmt.Println("") fmt.Println("signed documents:") spew.Dump(resp.SignedObjects) for _, o := range resp.SignedObjects { fmt.Println("- Name: " + o.Name) fmt.Println(" Link: " + o.Link) fmt.Println(" Hash: " + o.Hash) } fmt.Println("") fmt.Println("full signature:") fmt.Println(resp.Signature) }

let resp = await sdk.docs().requestSignature(selfID, terms, docs)
if (resp["status"] == "accepted") {
  console.log("Document signed!")
  console.log("")
  console.log("signned documents: ")
  for (var i=0; i < resp["signed_objects"].length; i++) {
    console.log(`- Name : ${resp["signed_objects"]["name"]}`)
    console.log(`  Link : ${resp["signed_objects"]["link"]}`)
    console.log(`  Hash : ${resp["signed_objects"]["hash"]}`)
  }
  console.log("")
  console.log("full signature")
  console.log(resp["input"])
}

The signed response will contain a SHA256 hash of the original BLOB which can be used to verify the integrity of the document.