Skip to content

Commit a0e1794

Browse files
authored
Added readme, license, code owners and contributing (#3)
1 parent 741c1ab commit a0e1794

File tree

4 files changed

+235
-2
lines changed

4 files changed

+235
-2
lines changed

CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Default owners of this repository:
2+
* @nagarjun @evanfuller

CONTRIBUTING.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Contributing
2+
3+
Thank you for considering contributing to the Nightfall Node.js SDK.
4+
5+
There are many ways to contribute, such as:
6+
7+
- Writing code samples
8+
- Suggesting documentation improvements
9+
- Submitting bug reports and feature requests
10+
- Writing code to improve the library itself.
11+
12+
Please, don't use the issue tracker for personal support questions. Feel free to reach out to [email protected] to address those issues.
13+
14+
## Responsibilities
15+
16+
- Declare TypeScript types for every change
17+
- Create issues for each major change and enhancement that you wish to make.
18+
- Discuss proposed changes transparently and collect community feedback.
19+
- Avoid introducing new external dependencies whenever possible. When absolutely required, validate the software
20+
licenses used by these dependencies (e.g. avoid unintentional copyleft requirements).
21+
22+
## How to report a bug
23+
24+
### Security Disclosures
25+
26+
If you find a security vulnerability, do NOT open an issue. Email [email protected] instead.
27+
28+
In order to determine whether you are dealing with a security issue, ask yourself the following questions:
29+
30+
- Can I access something that's not mine, or something I shouldn't have access to?
31+
- Can I disable something for other people?
32+
- Is there a potential vulnerability stemming from a library dependency?
33+
34+
If you answered yes to any of the above questions, then you're probably dealing with a security issue.
35+
Note that even if you answer "no" to all questions, you may still be dealing with a security issue, so if you're
36+
unsure, just email us at [email protected].
37+
38+
### Creating an Issue
39+
40+
When filing an issue, make sure to answer these questions:
41+
42+
1. What version of Node and NPM are you using?
43+
2. What version of TypeScript are you using?
44+
3. What operating system and processor architecture are you using?
45+
4. How did you discover the issue?
46+
5. Is the issue reproducible? What are the steps to reproduce?
47+
6. What did you expect to see?
48+
7. What did you see instead?
49+
50+
## Suggesting a New Feature
51+
52+
If you find yourself wishing for a feature that doesn't exist in this SDK, you are probably not alone.
53+
There are bound to be others out there with similar needs. Open an issue on our issues list on GitHub describing the
54+
feature you would like to see, why you need it, and how it should work.
55+
56+
## Code Review
57+
58+
The core team looks at open pull requests on a regular basis. In order for your pull request to be merged, it must meet the following requirements:
59+
60+
- It must include relevant TypeScript types
61+
- It must add unit tests to cover any new functionality
62+
- It must get approval from one of the code owners
63+
64+
If a pull request remains idle for more than two weeks, we may close it.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License
2+
3+
Copyright (c) 2021 Shoreline Labs, Inc.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 148 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,149 @@
1-
## Nightfall Node.js SDK
1+
# Nightfall Node.js SDK
22

3-
A Node.js SDK to call the Nightfall API.
3+
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/nightfallai/nightfall-nodejs-sdk/test)
4+
![GitHub](https://img.shields.io/github/license/nightfallai/nightfall-nodejs-sdk)
5+
6+
**Embed Nightfall scanning and detection functionality into Node.js applications**
7+
8+
## Features
9+
10+
This SDK provides JavaScript/TypeScript bindings for the Nightfall API. It allows you to add functionality to your applications to
11+
scan plain text and files in order to detect different categories of information. You can leverage any of
12+
the detectors in Nightfall's pre-built library, or you may programmatically define your own custom detectors.
13+
14+
Additionally, this library provides convenience features such as encapsulating the steps to chunk and upload files.
15+
16+
To obtain an API Key, login to the [Nightfall dashboard](https://app.nightfall.ai/) and click the section
17+
titled "Manage API Keys".
18+
19+
See our [developer documentation](https://docs.nightfall.ai/docs/entities-and-terms-to-know) for more details about
20+
integrating with the Nightfall API.
21+
22+
## Dependencies
23+
24+
The Nightfall Node.js SDK is compiled to ES2018 and supports Node.js v10.0.0 or later.
25+
26+
For a full list of external dependencies please consult `package.json`.
27+
28+
## Installation
29+
30+
### NPM
31+
32+
`npm install nightfall-node-sdk`
33+
34+
### Yarn
35+
36+
`yarn add nightfall-node-sdk`
37+
38+
### Building Locally
39+
40+
Alternatively, if you would like to build the project yourself:
41+
42+
1. Clone this git repository
43+
2. Run `npm install` from the top-level directory
44+
3. Run `npm run build` to compile the TypeScript codebase into the ./dist folder (in some cases, you may be required to manually create the ./dist folder before you run this command)
45+
4. Import the client like so: `import { Nightfall } from './dist'`
46+
47+
## Usage
48+
49+
### Scanning Plain Text
50+
51+
Nightfall provides pre-built detector types, covering data types ranging from PII to PHI to credentials. The following snippet shows an example of how to scan using pre-built detectors.
52+
53+
#### Sample Code
54+
55+
```typescript
56+
// By default, the client reads your API key from the environment variable NIGHTFALL_API_KEY
57+
const nfClient = new Nightfall();
58+
59+
const response = await nfClient.scanText(['My credit card number is 4242-4242-4242-4242'], {
60+
detectionRules: [
61+
{
62+
name: 'Secrets Scanner',
63+
logicalOp: 'ANY',
64+
detectors: [
65+
{
66+
minNumFindings: 1,
67+
minConfidence: Detector.Confidence.Possible,
68+
displayName: 'Credit Card Number',
69+
detectorType: Detector.Type.Nightfall,
70+
nightfallDetector: 'CREDIT_CARD_NUMBER',
71+
},
72+
],
73+
},
74+
],
75+
});
76+
77+
if (response.isError) {
78+
console.log(response.getError());
79+
} else {
80+
response.data.findings.forEach((finding) => {
81+
if (finding.length > 0) {
82+
finding.forEach((result) => {
83+
console.log(`Finding: ${result.finding}, Confidence: ${result.confidence}`);
84+
});
85+
}
86+
});
87+
}
88+
```
89+
90+
### Scanning Files
91+
92+
Scanning common file types like PDF's or office documents typically requires cumbersome text
93+
extraction methods like OCR.
94+
95+
Rather than implementing this functionality yourself, the Nightfall API allows you to upload the
96+
original files, and then we'll handle the heavy lifting.
97+
98+
The file upload process is implemented as a series of requests to upload the file in chunks. This library
99+
provides a single method that wraps the steps required to upload your file. Please refer to the
100+
[API Reference](https://docs.nightfall.ai/reference) for more details.
101+
102+
The file is uploaded synchronously, but as files can be arbitrarily large, the scan itself is conducted asynchronously.
103+
The results from the scan are delivered by webhook; for more information about setting up a webhook server, refer to
104+
[the docs](https://docs.nightfall.ai/docs/creating-a-webhook-server).
105+
106+
#### Sample Code
107+
108+
```typescript
109+
// By default, the client reads your API key from the environment variable NIGHTFALL_API_KEY
110+
const nfClient = new Nightfall();
111+
112+
const response = await nfClient.scanFile('./customer-details.txt', {
113+
detectionRules: [
114+
{
115+
name: 'Secrets Scanner',
116+
logicalOp: 'ANY',
117+
detectors: [
118+
{
119+
minNumFindings: 1,
120+
minConfidence: Detector.Confidence.Possible,
121+
displayName: 'Credit Card Number',
122+
detectorType: Detector.Type.Nightfall,
123+
nightfallDetector: 'CREDIT_CARD_NUMBER',
124+
},
125+
],
126+
},
127+
],
128+
webhookURL: 'https://my-service.com/nightfall/listener',
129+
});
130+
131+
if (response.isError) {
132+
console.log(response.getError());
133+
}
134+
135+
// Save this ID to check for findings when you receive a webhook event from us
136+
console.log(response.data.id);
137+
```
138+
139+
## Contributing
140+
141+
Contributions are welcome! Open a pull request to fix a bug, or open an issue to discuss a new feature
142+
or change.
143+
144+
Refer to `CONTRIBUTING.md` for the full details.
145+
146+
## License
147+
148+
This code is licensed under the terms of the MIT License. See [here](https://opensource.org/licenses/MIT)
149+
for more information.

0 commit comments

Comments
 (0)