Skip to content

Commit

Permalink
doc: updated readme, renamed key field
Browse files Browse the repository at this point in the history
  • Loading branch information
payetools committed Sep 11, 2024
1 parent 5fe0d21 commit c1c76f4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@
## Subhead
```csharp

var testEntity = new TestEntity
{
Id = 1,
Name = "Test Entity",
Description = "This is a test entity"
};

var webhook = new StandardWebhook(WEBHOOK_SIGNING_KEY);

var sendingTime = DateTimeOffset.UtcNow;

var webhookContent = webhook.MakeHttpContent(testEntity, DEFAULT_MSG_ID, sendingTime);

```

### Acknowledgements
Expand Down
26 changes: 12 additions & 14 deletions src/StandardWebhooks/StandardWebhook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
// see https://github.com/standard-webhooks/standard-webhooks/blob/main/libraries/LICENSE.

using StandardWebhooks.Diagnostics;
using System.Reflection.PortableExecutable;
using System.Security.Cryptography;
using System.Security.Cryptography.Xml;
using System.Text;
using System.Text.Json;

Expand All @@ -35,39 +33,39 @@ public sealed class StandardWebhook
/// <summary>
/// Initializes a new instance of the <see cref="StandardWebhook"/> class.
/// </summary>
/// <param name="key">Signing key, as string.</param>
public StandardWebhook(string key)
: this(key, WebhookConfigurationOptions.StandardWebhooks)
/// <param name="signingKey">Signing key, as string.</param>
public StandardWebhook(string signingKey)
: this(signingKey, WebhookConfigurationOptions.StandardWebhooks)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="StandardWebhook"/> class.
/// </summary>
/// <param name="key">Signing key, as byte array.</param>
public StandardWebhook(byte[] key)
: this(key, WebhookConfigurationOptions.StandardWebhooks)
/// <param name="signingKey">Signing key, as byte array.</param>
public StandardWebhook(byte[] signingKey)
: this(signingKey, WebhookConfigurationOptions.StandardWebhooks)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="StandardWebhook"/> class.
/// </summary>
/// <param name="key">Signing key, as byte array.</param>
/// <param name="signingKey">Signing key, as byte array.</param>
/// <param name="options">Options to set custom header keys.</param>
public StandardWebhook(string key, WebhookConfigurationOptions options)
: this(Convert.FromBase64String(key.StartsWith(PREFIX) ? key[PREFIX.Length..] : key), options)
public StandardWebhook(string signingKey, WebhookConfigurationOptions options)
: this(Convert.FromBase64String(signingKey.StartsWith(PREFIX) ? signingKey[PREFIX.Length..] : signingKey), options)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="StandardWebhook"/> class.
/// </summary>
/// <param name="key">Signing key, as byte array.</param>
/// <param name="signingKey">Signing key, as byte array.</param>
/// <param name="options">Options to set custom header keys.</param>
public StandardWebhook(byte[] key, WebhookConfigurationOptions options)
public StandardWebhook(byte[] signingKey, WebhookConfigurationOptions options)
{
_key = key;
_key = signingKey;

_idHeaderKey = options.IdHeaderKey;
_signatureHeaderKey = options.SignatureHeaderKey;
Expand Down

0 comments on commit c1c76f4

Please sign in to comment.