Skip to content

Commit cf35dfb

Browse files
author
Cory Thompson
committed
Fix formatting.
1 parent abcc7c4 commit cf35dfb

File tree

5 files changed

+74
-74
lines changed

5 files changed

+74
-74
lines changed

src/Util/ECKeyHelper.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ public static ECPrivateKeyParameters GetPrivateKey(byte[] privateKey)
1919
Asn1Object derEncodedKey = new DerOctetString(privateKey);
2020
Asn1Object keyTypeParameters = new DerTaggedObject(0, new DerObjectIdentifier(@"1.2.840.10045.3.1.7"));
2121

22-
Asn1Object derSequence = new DerSequence(version,derEncodedKey,keyTypeParameters);
22+
Asn1Object derSequence = new DerSequence(version, derEncodedKey, keyTypeParameters);
2323

2424
var base64EncodedDerSequence = Convert.ToBase64String(derSequence.GetDerEncoded());
2525
var pemKey = "-----BEGIN EC PRIVATE KEY-----\n";
2626
pemKey += base64EncodedDerSequence;
2727
pemKey += "\n-----END EC PRIVATE KEY----";
2828

29-
StringReader reader = new StringReader(pemKey);
29+
StringReader reader = new StringReader(pemKey);
3030
PemReader pemReader = new PemReader(reader);
3131
AsymmetricCipherKeyPair keyPair = (AsymmetricCipherKeyPair)pemReader.ReadObject();
3232

@@ -48,9 +48,9 @@ public static ECPublicKeyParameters GetPublicKey(byte[] publicKey)
4848
StringReader reader = new StringReader(pemKey);
4949
PemReader pemReader = new PemReader(reader);
5050
var keyPair = pemReader.ReadObject();
51-
return (ECPublicKeyParameters) keyPair;
51+
return (ECPublicKeyParameters)keyPair;
5252
}
53-
53+
5454
public static AsymmetricCipherKeyPair GenerateKeys()
5555
{
5656
X9ECParameters ecParameters = NistNamedCurves.GetByName("P-256");

src/Util/Encryptor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public static EncryptionResult Encrypt(byte[] userKey, byte[] userSecret, byte[]
3838
ECPublicKeyParameters userPublicKey = ECKeyHelper.GetPublicKey(userKey);
3939

4040
byte[] key = ecdhAgreement.CalculateAgreement(userPublicKey).ToByteArrayUnsigned();
41-
byte[] serverPublicKey = ((ECPublicKeyParameters) serverKeyPair.Public).Q.GetEncoded(false);
42-
41+
byte[] serverPublicKey = ((ECPublicKeyParameters)serverKeyPair.Public).Q.GetEncoded(false);
42+
4343
byte[] prk = HKDF(userSecret, key, Encoding.UTF8.GetBytes("Content-Encoding: auth\0"), 32);
4444
byte[] cek = HKDF(salt, prk, CreateInfoChunk("aesgcm", userKey, serverPublicKey), 16);
4545
byte[] nonce = HKDF(salt, prk, CreateInfoChunk("nonce", userKey, serverPublicKey), 12);

src/Util/JWSSigner.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class JWSSigner
1616

1717
public JWSSigner(ECPrivateKeyParameters privateKey)
1818
{
19-
_privateKey = privateKey;
19+
_privateKey = privateKey;
2020
}
2121

2222
/// <summary>
@@ -49,7 +49,7 @@ public string GenerateSignature(Dictionary<string, object> header, Dictionary<st
4949
a = ByteArrayPadLeft(a, largestLength);
5050
b = ByteArrayPadLeft(b, largestLength);
5151
}
52-
52+
5353
string signature = UrlBase64.Encode(a.Concat(b).ToArray());
5454
return String.Format("{0}.{1}", securedInput, signature);
5555
}

src/VapidHelper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public static VapidDetails GenerateVapidKeys()
2121
VapidDetails results = new VapidDetails();
2222

2323
AsymmetricCipherKeyPair keys = ECKeyHelper.GenerateKeys();
24-
byte[] publicKey = ((ECPublicKeyParameters) keys.Public).Q.GetEncoded(false);
25-
byte[] privateKey = ((ECPrivateKeyParameters) keys.Private).D.ToByteArrayUnsigned();
24+
byte[] publicKey = ((ECPublicKeyParameters)keys.Public).Q.GetEncoded(false);
25+
byte[] privateKey = ((ECPrivateKeyParameters)keys.Private).D.ToByteArrayUnsigned();
2626

2727
results.PublicKey = UrlBase64.Encode(publicKey);
2828
results.PrivateKey = UrlBase64.Encode(privateKey);
@@ -153,4 +153,4 @@ private static long UnixTimeNow()
153153
return (long)timeSpan.TotalSeconds;
154154
}
155155
}
156-
}
156+
}

src/WebPushClient.cs

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ protected HttpClient httpClient
3232

3333
return _httpClient;
3434
}
35-
}
35+
}
3636

3737
/// <summary>
3838
/// When sending messages to a GCM endpoint you need to set the GCM API key
@@ -231,52 +231,52 @@ public HttpRequestMessage GenerateRequestDetails(PushSubscription subscription,
231231
return request;
232232
}
233233

234-
/// <summary>
235-
/// To send a push notification call this method with a subscription, optional payload and any options
236-
/// Will exception is unsuccessful
237-
/// </summary>
238-
/// <param name="subscription">The PushSubscription you wish to send the notification to.</param>
239-
/// <param name="payload">The payload you wish to send to the user</param>
240-
/// <param name="options">Options for the GCM API key and vapid keys can be passed in if they are unique for each notification.</param>
241-
public void SendNotification(PushSubscription subscription, string payload = null, Dictionary<string, object> options = null)
242-
{
243-
SendNotificationAsync(subscription, payload, options).Wait();
244-
}
245-
246-
/// <summary>
247-
/// To send a push notification call this method with a subscription, optional payload and any options
248-
/// Will exception is unsuccessful
249-
/// </summary>
250-
/// <param name="subscription">The PushSubscription you wish to send the notification to.</param>
251-
/// <param name="payload">The payload you wish to send to the user</param>
252-
/// <param name="vapidDetails">The vapid details for the notification.</param>
253-
public void SendNotification(PushSubscription subscription, string payload, VapidDetails vapidDetails)
254-
{
255-
SendNotificationAsync(subscription, payload, vapidDetails).Wait();
256-
}
257-
258-
/// <summary>
259-
/// To send a push notification call this method with a subscription, optional payload and any options
260-
/// Will exception is unsuccessful
261-
/// </summary>
262-
/// <param name="subscription">The PushSubscription you wish to send the notification to.</param>
263-
/// <param name="payload">The payload you wish to send to the user</param>
264-
/// <param name="gcmAPIKey">The GCM API key</param>
265-
public void SendNotification(PushSubscription subscription, string payload, string gcmAPIKey)
266-
{
267-
SendNotificationAsync(subscription, payload, gcmAPIKey).Wait();
268-
}
269-
270-
/// <summary>
271-
/// To send a push notification asyncronously call this method with a subscription, optional payload and any options
272-
/// Will exception is unsuccessful
273-
/// </summary>
274-
/// <param name="subscription">The PushSubscription you wish to send the notification to.</param>
275-
/// <param name="payload">The payload you wish to send to the user</param>
276-
/// <param name="options">Options for the GCM API key and vapid keys can be passed in if they are unique for each notification.</param>
277-
public async Task SendNotificationAsync(PushSubscription subscription, string payload = null, Dictionary<string, object> options = null)
234+
/// <summary>
235+
/// To send a push notification call this method with a subscription, optional payload and any options
236+
/// Will exception is unsuccessful
237+
/// </summary>
238+
/// <param name="subscription">The PushSubscription you wish to send the notification to.</param>
239+
/// <param name="payload">The payload you wish to send to the user</param>
240+
/// <param name="options">Options for the GCM API key and vapid keys can be passed in if they are unique for each notification.</param>
241+
public void SendNotification(PushSubscription subscription, string payload = null, Dictionary<string, object> options = null)
242+
{
243+
SendNotificationAsync(subscription, payload, options).Wait();
244+
}
245+
246+
/// <summary>
247+
/// To send a push notification call this method with a subscription, optional payload and any options
248+
/// Will exception is unsuccessful
249+
/// </summary>
250+
/// <param name="subscription">The PushSubscription you wish to send the notification to.</param>
251+
/// <param name="payload">The payload you wish to send to the user</param>
252+
/// <param name="vapidDetails">The vapid details for the notification.</param>
253+
public void SendNotification(PushSubscription subscription, string payload, VapidDetails vapidDetails)
254+
{
255+
SendNotificationAsync(subscription, payload, vapidDetails).Wait();
256+
}
257+
258+
/// <summary>
259+
/// To send a push notification call this method with a subscription, optional payload and any options
260+
/// Will exception is unsuccessful
261+
/// </summary>
262+
/// <param name="subscription">The PushSubscription you wish to send the notification to.</param>
263+
/// <param name="payload">The payload you wish to send to the user</param>
264+
/// <param name="gcmAPIKey">The GCM API key</param>
265+
public void SendNotification(PushSubscription subscription, string payload, string gcmAPIKey)
266+
{
267+
SendNotificationAsync(subscription, payload, gcmAPIKey).Wait();
268+
}
269+
270+
/// <summary>
271+
/// To send a push notification asyncronously call this method with a subscription, optional payload and any options
272+
/// Will exception is unsuccessful
273+
/// </summary>
274+
/// <param name="subscription">The PushSubscription you wish to send the notification to.</param>
275+
/// <param name="payload">The payload you wish to send to the user</param>
276+
/// <param name="options">Options for the GCM API key and vapid keys can be passed in if they are unique for each notification.</param>
277+
public async Task SendNotificationAsync(PushSubscription subscription, string payload = null, Dictionary<string, object> options = null)
278278
{
279-
279+
280280
HttpRequestMessage request = GenerateRequestDetails(subscription, payload, options);
281281

282282
HttpResponseMessage response = await httpClient.SendAsync(request);
@@ -285,31 +285,31 @@ public async Task SendNotificationAsync(PushSubscription subscription, string pa
285285
{
286286
throw new WebPushException(@"Received unexpected response code", response.StatusCode, response.Headers, subscription);
287287
}
288-
288+
289289
}
290290

291-
/// <summary>
292-
/// To send a push notification asyncronously call this method with a subscription, optional payload and any options
293-
/// Will exception is unsuccessful
294-
/// </summary>
295-
/// <param name="subscription">The PushSubscription you wish to send the notification to.</param>
296-
/// <param name="payload">The payload you wish to send to the user</param>
297-
/// <param name="vapidDetails">The vapid details for the notification.</param>
298-
public async Task SendNotificationAsync(PushSubscription subscription, string payload, VapidDetails vapidDetails)
291+
/// <summary>
292+
/// To send a push notification asyncronously call this method with a subscription, optional payload and any options
293+
/// Will exception is unsuccessful
294+
/// </summary>
295+
/// <param name="subscription">The PushSubscription you wish to send the notification to.</param>
296+
/// <param name="payload">The payload you wish to send to the user</param>
297+
/// <param name="vapidDetails">The vapid details for the notification.</param>
298+
public async Task SendNotificationAsync(PushSubscription subscription, string payload, VapidDetails vapidDetails)
299299
{
300300
Dictionary<string, object> options = new Dictionary<string, object>();
301301
options["vapidDetails"] = vapidDetails;
302302
await SendNotificationAsync(subscription, payload, options);
303303
}
304304

305-
/// <summary>
306-
/// To send a push notification asyncronously call this method with a subscription, optional payload and any options
307-
/// Will exception is unsuccessful
308-
/// </summary>
309-
/// <param name="subscription">The PushSubscription you wish to send the notification to.</param>
310-
/// <param name="payload">The payload you wish to send to the user</param>
311-
/// <param name="gcmAPIKey">The GCM API key</param>
312-
public async Task SendNotificationAsync(PushSubscription subscription, string payload, string gcmAPIKey)
305+
/// <summary>
306+
/// To send a push notification asyncronously call this method with a subscription, optional payload and any options
307+
/// Will exception is unsuccessful
308+
/// </summary>
309+
/// <param name="subscription">The PushSubscription you wish to send the notification to.</param>
310+
/// <param name="payload">The payload you wish to send to the user</param>
311+
/// <param name="gcmAPIKey">The GCM API key</param>
312+
public async Task SendNotificationAsync(PushSubscription subscription, string payload, string gcmAPIKey)
313313
{
314314
Dictionary<string, object> options = new Dictionary<string, object>();
315315
options["gcmAPIKey"] = gcmAPIKey;

0 commit comments

Comments
 (0)