Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signature Types #31

Merged
merged 6 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions certified-connectors/DocuSignDemo/apiDefinition.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2168,6 +2168,25 @@
"x-ms-visibility": "advanced",
"type": "integer"
},
{
"name": "signatureType",
"in": "query",
"description": "DocuSign standards-based-signature (SBS) types.",
"x-ms-summary": "Signature type",
"x-ms-visibility": "advanced",
"type": "string",
"enum": [
"DS Electronic (SES)",
"DS EU Advanced (AES)",
"DS EU Qualified (QES)"
],
"x-ms-dynamic-values": {
harshitav-docusign marked this conversation as resolved.
Show resolved Hide resolved
"operationId": "StaticResponseForSignatureTypes",
"value-collection": "signatureTypes",
"value-path": "type",
"value-title": "name"
}
},
{
"name": "additionalRecipientParams",
"in": "body",
Expand Down Expand Up @@ -2323,6 +2342,25 @@
"x-ms-summary": "Recipient id",
"type": "string"
},
{
"name": "signatureType",
"in": "query",
"description": "DocuSign standards-based-signature (SBS) types.",
"x-ms-summary": "Signature type",
"x-ms-visibility": "advanced",
"type": "string",
"enum": [
"DS Electronic (SES)",
"DS EU Advanced (AES)",
"DS EU Qualified (QES)"
],
"x-ms-dynamic-values": {
"operationId": "StaticResponseForSignatureTypes",
"value-collection": "signatureTypes",
"value-path": "type",
"value-title": "name"
}
},
{
"name": "recipientType",
"in": "query",
Expand Down Expand Up @@ -3529,6 +3567,25 @@
"x-ms-visibility": "internal"
}
},
"/signature_types": {
"get": {
"tags": [
"StaticResponse"
],
"description": "Get signature types.",
"operationId": "StaticResponseForSignatureTypes",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/SignatureTypesResponse"
}
}
},
"deprecated": false,
"x-ms-visibility": "internal"
}
},
"/anchortab_schema": {
"get": {
"tags": [
Expand Down Expand Up @@ -3571,6 +3628,13 @@
"required": true,
"type": "string",
"x-ms-summary": "recipient type"
},
{
"name": "signatureType",
"in": "query",
"required": false,
"type": "string",
"x-ms-summary": "signature type"
}
],
"responses": {
Expand Down Expand Up @@ -4323,6 +4387,9 @@
"parameters": {
"recipientType": {
"parameter": "recipientType"
},
"signatureType": {
"parameter": "signatureType"
}
},
"value-path": "Schema"
Expand Down Expand Up @@ -4833,6 +4900,19 @@
}
}
},
"SignatureTypesResponse":{
"type": "object",
"properties": {
"tabTypes": {
"description": "Signature types",
"type": "array",
"items": {
"$ref": "#/definitions/SignatureType"
},
"x-ms-summary": "Signature types"
}
}
},
"FontNamesResponse": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -4902,6 +4982,21 @@
}
}
},
"SignatureType": {
"type": "object",
"properties": {
"name": {
"description": "Display name of the signature type.",
"type": "string",
"x-ms-summary": "Name"
},
"type": {
"description": "Type of the signature.",
"type": "string",
"x-ms-summary": "Type"
}
}
},
"FontName": {
"type": "object",
"properties": {
Expand Down
77 changes: 77 additions & 0 deletions certified-connectors/DocuSignDemo/script.csx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,29 @@ public class Script : ScriptBase
response["recipientTypes"] = recipientTypesArray;
}

if (operationId.Equals("StaticResponseForSignatureTypes", StringComparison.OrdinalIgnoreCase))
{
var signatureTypesArray = new JArray();

string [,] signatureTypes = {
{ "UniversalSignaturePen_ImageOnly" , "DS Electronic (SES)" },
{ "UniversalSignaturePen_OpenTrust_Hash_TSP", "DS EU Advanced (AES)" },
{ "docusign_eu_qualified_idnow_tsp", "DS EU Qualified (QES)" }
};

for (var i = 0; i < signatureTypes.GetLength(0); i++)
{
var signatureTypeObject = new JObject()
{
["type"] = signatureTypes[i,0],
["name"] = signatureTypes[i,1]
};
signatureTypesArray.Add(signatureTypeObject);
}

response["signatureTypes"] = signatureTypesArray;
}

if (operationId.StartsWith("StaticResponseForFont", StringComparison.OrdinalIgnoreCase))
{
var fontNamesArray = new JArray();
Expand Down Expand Up @@ -403,6 +426,7 @@ public class Script : ScriptBase
{
var query = HttpUtility.ParseQueryString(context.Request.RequestUri.Query);
var recipientType = query.Get("recipientType");
var signatureType = query.Get("signatureType") ?? "";

response["name"] = "dynamicSchema";
response["title"] = "dynamicSchema";
Expand All @@ -412,6 +436,23 @@ public class Script : ScriptBase
["properties"] = new JObject()
};

if (signatureType.Equals("DS EU Advanced (AES)", StringComparison.OrdinalIgnoreCase))
{
response["schema"]["properties"]["aesMethod"] = new JObject
{
["type"] = "string",
["x-ms-summary"] = "* AES Method",
["description"] = "AES Method",
["enum"] = new JArray("Access Code", "SMS")
};
response["schema"]["properties"]["aesMethodValue"] = new JObject
{
["type"] = "string",
["x-ms-summary"] = "* AES Method Value",
["description"] = "AES Method Value"
};
}

if (recipientType.Equals("inPersonSigners", StringComparison.OrdinalIgnoreCase))
{
response["schema"]["properties"]["hostName"] = new JObject
Expand Down Expand Up @@ -1154,6 +1195,11 @@ public class Script : ScriptBase
AddCoreRecipientParams(signers, body);
AddParamsForSelectedRecipientType(signers, body);

if (!string.IsNullOrEmpty(query.Get("signatureType")))
{
AddParamsForSelectedSignatureType(signers, body);
}

body[recipientType] = signers;

var uriBuilder = new UriBuilder(this.Context.Request.RequestUri);
Expand Down Expand Up @@ -1398,6 +1444,37 @@ public class Script : ScriptBase
}
}

private void AddParamsForSelectedSignatureType(JArray signers, JObject body)
{
var query = HttpUtility.ParseQueryString(this.Context.Request.RequestUri.Query);

var signatureType = query.Get("signatureType");
var signatureTypeMap = new Dictionary<string, string>() {
{"DS Electronic (SES)", "UniversalSignaturePen_ImageOnly"},
{"DS EU Advanced (AES)", "UniversalSignaturePen_OpenTrust_Hash_TSP"},
{"DS EU Qualified (QES)", "idv_docusign_eu_qualified"},
};

var recipientSignatureProviders = new JArray
{
new JObject
{
["signatureProviderName"] = signatureTypeMap[signatureType]
}
};

if (signatureType.Equals("DS EU Advanced (AES)"))
{
var aesMethod = (body["aesMethod"].Equals("SMS")) ? "sms" : "oneTimePassword";
recipientSignatureProviders[0]["signatureProviderOptions"] = new JObject
{
[aesMethod] = body["aesMethodValue"]
};
}

signers[0]["recipientSignatureProviders"] = recipientSignatureProviders;
}

private int GenerateId()
{
DateTimeOffset now = DateTimeOffset.UtcNow;
Expand Down