Skip to content

Commit

Permalink
Add Typescript typings
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Woodcock committed Jun 23, 2020
1 parent dc05961 commit b93493e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ an error and the second being the successfully validated SNS message.
The message validator checks the `SigningCertURL`, `SignatureVersion`, and
`Signature` to make sure they are valid and consistent with the message data.

#### Javascript
```javascript
var MessageValidator = require('sns-validator'),
validator = new MessageValidator();
Expand All @@ -47,6 +48,21 @@ validator.validate(message, function (err, message) {
});
```

#### Typescript
```typescript
import { MessageValidator } from "sns-validator"
const validator = new MessageValidator();

validator.validate(message, function (err, message) {
if (err) {
// Your message could not be validated.
return;
}

// message has been validated and its signature checked.
});
```

## Installation

The SNS Message Validator relies on the Node crypto module and is only designed
Expand Down
4 changes: 4 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export declare class MessageValidator {
encoding: string;
validate(hash: any, cb: (err: string, message: string) => any);
}
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,6 @@ MessageValidator.prototype.validate = function (hash, cb) {
validateSignature(hash, cb, this.encoding);
};

MessageValidator.MessageValidator = MessageValidator;

module.exports = MessageValidator;

0 comments on commit b93493e

Please sign in to comment.