Skip to content

Commit 4972f0f

Browse files
committed
2 parents fb72b56 + 82329df commit 4972f0f

File tree

194 files changed

+4324
-2788
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

194 files changed

+4324
-2788
lines changed

.editorconfig

Lines changed: 495 additions & 0 deletions
Large diffs are not rendered by default.

DSHelper.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ namespace DocuSign.CodeExamples.Common
77
using System.IO;
88
using System.Runtime.InteropServices;
99

10-
internal class DSHelper
10+
internal class DsHelper
1111
{
1212
internal static string PrepareFullPrivateKeyFilePath(string fileName)
1313
{
14-
const string DefaultRSAPrivateKeyFileName = "private.key";
14+
const string defaultRsaPrivateKeyFileName = "private.key";
1515

1616
var fileNameOnly = Path.GetFileName(fileName);
1717
if (string.IsNullOrEmpty(fileNameOnly))
1818
{
19-
fileNameOnly = DefaultRSAPrivateKeyFileName;
19+
fileNameOnly = defaultRsaPrivateKeyFileName;
2020
}
2121

2222
var filePath = Path.GetDirectoryName(fileName);
@@ -27,7 +27,7 @@ internal static string PrepareFullPrivateKeyFilePath(string fileName)
2727

2828
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && Directory.GetCurrentDirectory().Contains("bin"))
2929
{
30-
fileNameOnly = DefaultRSAPrivateKeyFileName;
30+
fileNameOnly = defaultRsaPrivateKeyFileName;
3131
filePath = Path.GetFullPath(filePath);
3232
}
3333

ExamplesAPIType.cs

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,52 @@
22
// Copyright (c) DocuSign. All rights reserved.
33
// </copyright>
44

5-
using System.ComponentModel;
6-
75
namespace DocuSign.CodeExamples.Common
86
{
9-
public enum ExamplesAPIType
7+
using System.ComponentModel;
8+
9+
public enum ExamplesApiType
1010
{
11+
/// <summary>
12+
/// Rooms API
13+
/// </summary>
1114
[Description("reg")]
1215
Rooms = 0,
1316

17+
/// <summary>
18+
/// ESignature API
19+
/// </summary>
1420
[Description("eg")]
1521
ESignature = 1,
1622

23+
/// <summary>
24+
/// Click API
25+
/// </summary>
1726
[Description("ceg")]
1827
Click = 2,
1928

29+
/// <summary>
30+
/// Monitor API
31+
/// </summary>
2032
[Description("meg")]
2133
Monitor = 3,
2234

35+
/// <summary>
36+
/// Admin API
37+
/// </summary>
2338
[Description("aeg")]
2439
Admin = 4,
40+
41+
/// <summary>
42+
/// Connect API
43+
/// </summary>
44+
[Description("con")]
45+
Connect = 5,
2546
}
2647

27-
public static class ExamplesAPITypeExtensions
48+
public static class ExamplesApiTypeExtensions
2849
{
29-
public static string ToKeywordString(this ExamplesAPIType val)
50+
public static string ToKeywordString(this ExamplesApiType val)
3051
{
3152
DescriptionAttribute[] attributes = (DescriptionAttribute[])val
3253
.GetType()

ExamplesApiTypeExtensions.cs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// <copyright file="ExamplesApiTypeExtensions.cs" company="DocuSign">
2+
// Copyright (c) DocuSign. All rights reserved.
3+
// </copyright>
4+
5+
namespace DocuSign.CodeExamples.Common
6+
{
7+
using System.ComponentModel;
8+
9+
public enum ExamplesApiType
10+
{
11+
/// <summary>
12+
/// Rooms API
13+
/// </summary>
14+
[Description("reg")]
15+
Rooms = 0,
16+
17+
/// <summary>
18+
/// ESignature API
19+
/// </summary>
20+
[Description("eg")]
21+
ESignature = 1,
22+
23+
/// <summary>
24+
/// Click API
25+
/// </summary>
26+
[Description("ceg")]
27+
Click = 2,
28+
29+
/// <summary>
30+
/// Monitor API
31+
/// </summary>
32+
[Description("meg")]
33+
Monitor = 3,
34+
35+
/// <summary>
36+
/// Admin API
37+
/// </summary>
38+
[Description("aeg")]
39+
Admin = 4,
40+
41+
/// <summary>
42+
/// Connect API
43+
/// </summary>
44+
[Description("con")]
45+
Connect = 5,
46+
}
47+
48+
public static class ExamplesApiTypeExtensions
49+
{
50+
public static string ToKeywordString(this ExamplesApiType val)
51+
{
52+
DescriptionAttribute[] attributes = (DescriptionAttribute[])val
53+
.GetType()
54+
.GetField(val.ToString())
55+
.GetCustomAttributes(typeof(DescriptionAttribute), false);
56+
return attributes.Length > 0 ? attributes[0].Description : string.Empty;
57+
}
58+
}
59+
}

JWT-Console/App.config.Example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
<add key="ClientId" value="{INTEGRATION_KEY_JWT}"/>
55
<add key="AuthServer" value="account-d.docusign.com"/>
66
<add key="ImpersonatedUserID" value="{IMPERSONATED_USER_ID}"/>
7-
<add key="PrivateKeyFile" value="..\..\..\private.key"/>
7+
<add key="PrivateKeyFile" value="../../../private.key"/>
88
</appSettings>
99
</configuration>

JWT-Console/Program.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ static void Main(string[] args)
2424
OAuthToken accessToken = null;
2525
try
2626
{
27-
accessToken = JWTAuth.AuthenticateWithJWT("ESignature", ConfigurationManager.AppSettings["ClientId"], ConfigurationManager.AppSettings["ImpersonatedUserId"],
28-
ConfigurationManager.AppSettings["AuthServer"], DSHelper.ReadFileContent(ConfigurationManager.AppSettings["PrivateKeyFile"]));
27+
accessToken = JwtAuth.AuthenticateWithJwt("ESignature", ConfigurationManager.AppSettings["ClientId"], ConfigurationManager.AppSettings["ImpersonatedUserId"],
28+
ConfigurationManager.AppSettings["AuthServer"], DsHelper.ReadFileContent(ConfigurationManager.AppSettings["PrivateKeyFile"]));
2929
}
3030
catch (ApiException apiExp)
3131
{
@@ -42,7 +42,14 @@ static void Main(string[] args)
4242
// build a URL to provide consent for this Integration Key and this userId
4343
string url = "https://" + ConfigurationManager.AppSettings["AuthServer"] + "/oauth/auth?response_type=code" + caret + "&scope=impersonation%20signature" + caret +
4444
"&client_id=" + ConfigurationManager.AppSettings["ClientId"] + caret + "&redirect_uri=" + DevCenterPage;
45-
Console.WriteLine($"Consent is required - launching browser (URL is {url.Replace(caret, "")})");
45+
46+
string consentRequiredMessage = $"Consent is required - launching browser (URL is {url})";
47+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
48+
{
49+
consentRequiredMessage = consentRequiredMessage.Replace(caret, "");
50+
}
51+
52+
Console.WriteLine(consentRequiredMessage);
4653

4754
// Start new browser window for login and consent to this app by DocuSign user
4855
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))

JWTAuth.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@ namespace DocuSign.CodeExamples.Authentication
1010
using DocuSign.eSign.Client;
1111
using static DocuSign.eSign.Client.Auth.OAuth;
1212

13-
public static class JWTAuth
13+
public static class JwtAuth
1414
{
1515
/// <summary>
1616
/// Uses Json Web Token (JWT) Authentication Method to obtain the necessary information needed to make API calls.
1717
/// </summary>
1818
/// <returns>Auth token needed for API calls</returns>
19-
public static OAuthToken AuthenticateWithJWT(string api, string clientId, string impersonatedUserId, string authServer, byte[] privateKeyBytes)
19+
public static OAuthToken AuthenticateWithJwt(string api, string clientId, string impersonatedUserId, string authServer, byte[] privateKeyBytes)
2020
{
2121
var docuSignClient = new DocuSignClient();
22-
var apiType = Enum.Parse<ExamplesAPIType>(api);
22+
var apiType = Enum.Parse<ExamplesApiType>(api);
2323
var scopes = new List<string>
2424
{
2525
"signature",
2626
"impersonation",
2727
};
28-
if (apiType == ExamplesAPIType.Rooms)
28+
if (apiType == ExamplesApiType.Rooms)
2929
{
3030
scopes.AddRange(new List<string>
3131
{
@@ -41,7 +41,7 @@ public static OAuthToken AuthenticateWithJWT(string api, string clientId, string
4141
});
4242
}
4343

44-
if (apiType == ExamplesAPIType.Click)
44+
if (apiType == ExamplesApiType.Click)
4545
{
4646
scopes.AddRange(new List<string>
4747
{
@@ -50,7 +50,7 @@ public static OAuthToken AuthenticateWithJWT(string api, string clientId, string
5050
});
5151
}
5252

53-
if (apiType == ExamplesAPIType.Monitor)
53+
if (apiType == ExamplesApiType.Monitor)
5454
{
5555
scopes.AddRange(new List<string>
5656
{
@@ -59,7 +59,7 @@ public static OAuthToken AuthenticateWithJWT(string api, string clientId, string
5959
});
6060
}
6161

62-
if (apiType == ExamplesAPIType.Admin)
62+
if (apiType == ExamplesApiType.Admin)
6363
{
6464
scopes.AddRange(new List<string>
6565
{
@@ -75,7 +75,7 @@ public static OAuthToken AuthenticateWithJWT(string api, string clientId, string
7575
"asset_group_account_read",
7676
"asset_group_account_clone_write",
7777
"asset_group_account_clone_read",
78-
});
78+
});
7979
}
8080

8181
return docuSignClient.RequestJWTUserToken(

Quick_ACG/Common/RequestItemService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ public class RequestItemsService : IRequestItemsService
1313
private readonly IHttpContextAccessor _httpContextAccessor;
1414
private readonly IMemoryCache _cache;
1515
private readonly string _id;
16-
public DocuSignClient _docuSignClient { get; private set; }
16+
public DocuSignClient DocuSignClient { get; private set; }
1717

1818
public RequestItemsService(IHttpContextAccessor httpContextAccessor, IMemoryCache cache, IConfiguration configuration)
1919
{
2020
_httpContextAccessor = httpContextAccessor;
2121
_cache = cache;
2222
Status = "sent";
23-
_docuSignClient ??= new DocuSignClient();
23+
DocuSignClient ??= new DocuSignClient();
2424
var identity = httpContextAccessor.HttpContext.User.Identity as ClaimsIdentity;
2525

2626
if (identity != null && identity.IsAuthenticated)

Quick_ACG/Startup.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ public void ConfigureServices(IServiceCollection services)
4747
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
4848
options.CheckConsentNeeded = context => true;
4949
});
50-
DSConfiguration config = new DSConfiguration();
50+
DsConfiguration config = new DsConfiguration();
5151

5252
Configuration.Bind("DocuSign", config);
53-
config.QuickACG = "true";
53+
config.QuickAcg = "true";
5454

5555
services.AddSingleton(config);
5656
services.AddSingleton(new LauncherTexts(config, Configuration));

Quick_ACG/Views/Eg001EmbeddedSigning/quickEmbeddedSigning.cshtml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,23 @@
5151
<p>@Html.Raw(ViewBag.CodeExampleText.ExampleDescription)</p>
5252

5353
<p>
54-
@if(ViewBag.CodeExampleText.LinksToAPIMethod.Count == 1)
54+
@if(ViewBag.CodeExampleText.LinksToApiMethod.Count == 1)
5555
{
56-
<span>@Html.Raw(ViewBag.SupportingTexts.APIMethodUsed)</span>
56+
<span>@Html.Raw(ViewBag.SupportingTexts.ApiMethodUsed)</span>
5757
}
5858
else
5959
{
60-
<span>@Html.Raw(ViewBag.SupportingTexts.APIMethodUsedPlural)</span>
60+
<span>@Html.Raw(ViewBag.SupportingTexts.ApiMethodUsedPlural)</span>
6161
}
6262

63-
@for(int i = 0; i < ViewBag.CodeExampleText.LinksToAPIMethod.Count; ++i)
63+
@for(int i = 0; i < ViewBag.CodeExampleText.LinksToApiMethod.Count; ++i)
6464
{
65-
<a target='_blank' href="@ViewBag.CodeExampleText.LinksToAPIMethod[i].Path">@Html.Raw(ViewBag.CodeExampleText.LinksToAPIMethod[i].PathName)</a>
66-
@if(i + 1 == ViewBag.CodeExampleText.LinksToAPIMethod.Count)
65+
<a target='_blank' href="@ViewBag.CodeExampleText.LinksToApiMethod[i].Path">@Html.Raw(ViewBag.CodeExampleText.LinksToApiMethod[i].PathName)</a>
66+
@if(i + 1 == ViewBag.CodeExampleText.LinksToApiMethod.Count)
6767
{
6868
<span>.</span>
6969
}
70-
else if(i + 1 == ViewBag.CodeExampleText.LinksToAPIMethod.Count - 1)
70+
else if(i + 1 == ViewBag.CodeExampleText.LinksToApiMethod.Count - 1)
7171
{
7272
<span> and </span>
7373
}

0 commit comments

Comments
 (0)