e签宝是专业的全生态电子签名服务商。基于实名身份,为用户提供在线电子签章/签名服务的平台,并且为企业用户提供电子签名、电子合同管理、数据存证和法律维权等服务。
npm install esigntech --save
development https://smlopenapi.esign.cn/
product https://openapi.esign.cn/
const fs = require('fs')
let api = require('esigntech')
let eSignApi = new api('appid', 'app_secrect', async function () {
return new Promise(function (resovle, reject) {
fs.readFile('../access_token.txt', 'utf8', function (err, txt) {
if (err) { return reject(err); }
resovle(JSON.parse(txt));
});
})
}, async function (token) {
return new Promise(function (resovle, reject) {
fs.writeFile('../access_token.txt', JSON.stringify(token), function (err) {
if (err) reject(err)
resovle()
});
})
}, isdebug)
Account_Create
let data = {
"email": "[email protected]",
"idNumber": "111130199009161634",
"idType": "CRED_PSN_CH_IDCARD",
"mobile": "18011111111",
"name": "王小丫章",
"thirdPartyUserId": thirdPartyUserId
}
let rest = await eSignApi.Account_Create(data)
Account_Modfiy
let data = {
"email": "[email protected]",
"idNumber": "111130199009161634",
"idType": "CRED_PSN_CH_IDCARD",
"mobile": "18011111111",
"name": "messi",
"thirdPartyUserId": thirdPartyUserId
}
let rest = await eSignApi.Account_Modfiy(accountId,data)
Account_Get
let rest = await eSignApi.Account_Get(accountId)
Account_DeleteByThirdId
let rest = await eSignApi.Account_DeleteByThirdId(ThirdId)
Organizations_Create
let data = {
"creator": "ca49e5963314418796fb682473d79919",
"idNumber": "32083019900916xxxx",
"idType": "CRED_ORG_USCC",
"name": "colsoft1212",
"thirdPartyUserId": stringRandom()
}
let rest = await eSignApi.Organizations_Create(data)
Organizations_Modfiy
var data = {
"idNumber": "32083019900916xxxx",
"idType": "CRED_ORG_USCC",
"name": "esign"
}
let rest = await eSignApi.Organizations_Modfiy(orgId, data)
Organizations_Get
let rest = await eSignApi.Organizations_Get(orgId)
Organizations_DeleteByOrgId
let rest = await eSignApi.Organizations_DeleteByOrgId(orgId)
SignAuth_Setting
let accountId="969c282a943948afa199a75bc6c0c84b";
let data = {
"deadline": "2050-04-01 12:00:00"
}
let rest = await eSignApi.SignAuth_Setting(accountId,data)
SignAuth_Cancel
let accountId="969c282a943948afa199a75bc6c0c84b";
let rest = await eSignApi.SignAuth_Cancel(accountId)
Files_getUploadUrl
let fileurl = 'thirdpartdoc.pdf'
let indf = await eSignApi.readFileInfo(fileurl)
let contentMd5 = await eSignApi.readFileMd5(fileurl)
let data = {
"contentMd5": contentMd5,
"contentType": "application/octet-stream",
"convert2Pdf": false,
"fileName": "thirdpartdoc.pdf",
"fileSize": indf.size
}
let rest = await eSignApi.Files_getUploadUrl(data)
fileid = rest.data.fileId
uploadUrl = rest.data.uploadUrl
Files_Upload
let fileurl = 'thirdpartdoc.pdf'
var data = {
contentType: "application/octet-stream",
uploadUrl: uploadUrl,
contentMd5: contentMd5,
buffer: fs.createReadStream(fileurl)
}
let rest = await eSignApi.Files_Upload(data)
Fils_CreateByTemplate
let data={
"name":"模板文件ten",
"simpleFormFields":{
"甲方:":"测试甲方",
"乙方:":"测试乙方"
},
"templateId":"b470d1753cf94f57bb253655c4fc2f7c"
}
let rest = await eSignApi.Fils_CreateByTemplate(data)
Fils_BatchAddWatermark
var param = {
"files": [
{
"fileId": fileid,
"watermarkInfo": {
"contentType": 3,
"content": "水印文字",
"fontSize": 10,
"fontName": "simsun",
"vmModel": 1,
"lineWidths": 3,
"alpha": 100,
"strength": 250,
"imageHeight": 400,
"imageWidth": 400,
"scaling": 100,
"rotationAngle": 0
},
"posBean": {
"posPage": "1-10,20",
"posX": 11.5,
"posY": 200
}
}
],
"notifyUrl": "",
"thirdOrderNo": ""
}
let rest = await eSignApi.Fils_BatchAddWatermark(param)
Files_getAddress
let rest = await eSignApi.Files_getAddress(fileid)
DocTemplates_createByUploadUrl
let fileurl = '6666.pdf'
let contentMd5 = await eSignApi.readFileMd5(fileurl)
let data = {
"contentMd5": contentMd5,
"contentType": "application/octet-stream",
"convert2Pdf": true,
"fileName": "6666.pdf",
}
let rest = await eSignApi.DocTemplates_createByUploadUrl(data)
templateId = rest.data.templateId
uploadUrl = rest.data.uploadUrl
DocTemplates_CreateComponents
let templateId = '7bd12b7cb64f441ca5d71bc614ec899c'
var data={
"structComponents":[
{
"id":"",
"key":"key0021",
"type":1,
"context":{
"label":"身份证号码",
"limit":"yyyy-MM-dd",
"required":true,
"style":{
"font":1,
"fontSize":11,
"textColor":"#000000",
"width":11.11,
"height":11.11
},
"pos":{
"x":11.11,
"y":11.11,
"page":1
}
}
}
]
}
let rest = await eSignApi.DocTemplates_CreateComponents(templateId,data)
ids = rest.data.toString()
DocTemplates_DeleteComponents
let rest = await eSignApi.DocTemplates_DeleteComponents(templateId,ids)
DocTemplates_GetComponents
let rest = await eSignApi.DocTemplates_GetComponents(templateId)
let fileurl = 'thirdpartdoc.pdf'
var data = {
contentType: "application/octet-stream",
uploadUrl: uploadUrl,
contentMd5: contentMd5,
buffer: fs.createReadStream(fileurl)
}
let rest = await eSignApi.Files_Upload(data)
Account_SealsCreatePersonalTemplate
var data ={
"alias": "红色四方形印章",
"color": "RED",
"height": 100,
"type": "SQUARE",
"width": 100
}
let rest = await eSignApi.Account_SealsCreatePersonalTemplate(accountId,data)
sealId = rest.data.sealId
fileKey = rest.data.fileKey
Organizations_CreateOfficialTemplate
var data = {
"alias": "企业星型印章",
"central": "STAR",
"color": "RED",
"height": 100,
"width": 50,
"htext": "签宝",
"qtext": "杭州天谷信息科技有限公司",
"type": "TEMPLATE_ROUND"
}
let rest = await eSignApi.Organizations_CreateOfficialTemplate(orgId,data)
sealId = rest.data.sealId
Account_SealsGet
let rest = await eSignApi.Account_SealsGet(accountId OR orgId,1,10)
Account_SealsGet
let rest = await eSignApi.Account_SealsGet(accountId,1,10)
Organizations_SealsGet
let rest = await eSignApi.Organizations_SealsGet(orgId,1,10)
Account_SealsDeleteById
let rest = await eSignApi.Account_SealsDeleteById(accountId,sealId)
Organizations_SealsDeleteById
let rest = await eSignApi.Organizations_SealsDeleteById(orgId,sealId)
SignFlows_Create
var data = {
"autoArchive": false,
"businessScene": "合同名称",
"configInfo": {
"noticeDeveloperUrl": "http://127.0.0.1:9110/notice",
"noticeType": "1,2",
"redirectUrl": "http://127.0.0.1:8110/h5/forword",
"signPlatform": "1"
},
"contractRemind": 360,
"contractValidity": 1592386042000,
"signValidity": 1592386042000,
"initiatorAccountId":accountId,
"initiatorAuthorizedAccountId": accountId
}
let rest = await eSignApi.SignFlows_Create(data)
flowId = rest.data.flowId
SignFlows_Get
let rest = await eSignApi.SignFlows_Get(flowId)
SignFlows_Start
let rest = await eSignApi.SignFlows_Start(flowId, {})
var data = {
"revokeReason": "合同有误"
}
let rest = await eSignApi.SignFlows_Revoke(flowId, data)
SignFlows_Archive
let rest = await eSignApi.SignFlows_Archive(flowId, {})
SignFlows_CreateDocuments
var data = {
"docs": [
{
"encryption": 0,
"fileId": fileid,
"fileName": "第一份合同.pdf",
"filePassword": ""
}
]
}
let rest = await eSignApi.SignFlows_CreateDocuments(flowId, data)
let rest = await eSignApi.SignFlows_DeleteDocuments(flowId, fileIds)
SignFlows_GetDocuments
let rest = await eSignApi.SignFlows_GetDocuments(flowId)
SignFlows_GetAttachments
let rest = await eSignApi.SignFlows_GetAttachments(flowId)
SignFlows_CreateAttachments
var data = {
"attachments": [
{
"attachmentName": "第一份附件.pdf",
"fileId": fileid
}
]
}
let rest = await eSignApi.SignFlows_CreateAttachments(flowId, data)
SignFlows_DeteleAttachments
let rest = await eSignApi.SignFlows_DeteleAttachments(flowId, fileIds)
SignFlows_GetSignfields
let rest = await eSignApi.SignFlows_GetSignfields(flowId, accountId)
SignFlows_CreateSignfieldsPlatformSign
var data = {
"signfields": [
{
"fileId": fileid,
"order": 1,
"posBean": {
"posPage": "1",
"posX": 158.72531,
"posY": 431.05658
},
"sealId":sealId,
"signType": 1
}
]
}
let rest = await eSignApi.SignFlows_CreateSignfieldsPlatformSign(flowId, data)
SignFlows_CreateSignfieldsAutoSign
var data = {
"signfields": [
{
"fileId": fileid,
"authorizedAccountId": accountId,
"order": 1,
"posBean": {
"posPage": "1",
"posX": 158.72531,
"posY": 431.05658
},
"sealId": sealId,
"signType": 1
}
]
}
let rest = await eSignApi.SignFlows_CreateSignfieldsAutoSign(flowId, data)
SignFlows_CreateSignfieldsHandSign
var data ={
"signfields":[
{
"signerAccountId":accountId,
"authorizedAccountId":accountId,
"actorIndentityType":2,
"fileId":fileid,
"order":1,
"assignedPosbean":true,
"posBean":{
"posPage":"1",
"posX":158.72531,
"posY":431.05658
},
"sealType":"0",
"sealId":"0123",
"signType":1
}
]
}
let rest = await eSignApi.SignFlows_CreateSignfieldsHandSign(flowId, data)
let rest = await eSignApi.SignFlows_DeleteSignfields(flowId)
SignFlows_GetSigners
let rest = await eSignApi.SignFlows_GetSigners(flowId)
SignFlows_SignersRushsign
var data ={
"accountId": "",
"noticeTypes": "1,2",
"rushsignAccountId": accountId
}
let rest = await eSignApi.SignFlows_SignersRushsign(flowId, data)
let rest = await eSignApi.SignFlows_ExecuteUrl(flowId)
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.