Skip to content

Commit b93493e

Browse files
author
Josh Woodcock
committed
Add Typescript typings
1 parent dc05961 commit b93493e

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

README.md

+16
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ an error and the second being the successfully validated SNS message.
3333
The message validator checks the `SigningCertURL`, `SignatureVersion`, and
3434
`Signature` to make sure they are valid and consistent with the message data.
3535

36+
#### Javascript
3637
```javascript
3738
var MessageValidator = require('sns-validator'),
3839
validator = new MessageValidator();
@@ -47,6 +48,21 @@ validator.validate(message, function (err, message) {
4748
});
4849
```
4950

51+
#### Typescript
52+
```typescript
53+
import { MessageValidator } from "sns-validator"
54+
const validator = new MessageValidator();
55+
56+
validator.validate(message, function (err, message) {
57+
if (err) {
58+
// Your message could not be validated.
59+
return;
60+
}
61+
62+
// message has been validated and its signature checked.
63+
});
64+
```
65+
5066
## Installation
5167

5268
The SNS Message Validator relies on the Node crypto module and is only designed

index.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export declare class MessageValidator {
2+
encoding: string;
3+
validate(hash: any, cb: (err: string, message: string) => any);
4+
}

index.js

+2
Original file line numberDiff line numberDiff line change
@@ -213,4 +213,6 @@ MessageValidator.prototype.validate = function (hash, cb) {
213213
validateSignature(hash, cb, this.encoding);
214214
};
215215

216+
MessageValidator.MessageValidator = MessageValidator;
217+
216218
module.exports = MessageValidator;

0 commit comments

Comments
 (0)