-
Notifications
You must be signed in to change notification settings - Fork 1
Node SDK intro updates - updates PLAT-1803 #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
egp415
wants to merge
4
commits into
main
Choose a base branch
from
EGP-docrevisions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -52,39 +52,46 @@ Nightfall provides pre-built detector types, covering data types ranging from PI | |||||
|
|
||||||
| #### Sample Code | ||||||
|
|
||||||
| ```typescript | ||||||
| // By default, the client reads your API key from the environment variable NIGHTFALL_API_KEY | ||||||
| const nfClient = new Nightfall(); | ||||||
| To run this sample script you must compile it as TypesScript. Save it as a `.tsc` file and run `tsc <yourfilename>.ts -lib ES2015,DOM ` | ||||||
|
|
||||||
| You can this run the resulting JavaScript file: | ||||||
|
|
||||||
| const response = await nfClient.scanText(['My credit card number is 4242-4242-4242-4242'], { | ||||||
| detectionRules: [ | ||||||
| { | ||||||
| name: 'Secrets Scanner', | ||||||
| logicalOp: 'ANY', | ||||||
| detectors: [ | ||||||
| { | ||||||
| minNumFindings: 1, | ||||||
| minConfidence: Detector.Confidence.Possible, | ||||||
| displayName: 'Credit Card Number', | ||||||
| detectorType: Detector.Type.Nightfall, | ||||||
| nightfallDetector: 'CREDIT_CARD_NUMBER', | ||||||
| }, | ||||||
| ], | ||||||
| }, | ||||||
| ], | ||||||
| }); | ||||||
|
|
||||||
| if (response.isError) { | ||||||
| console.log(response.getError()); | ||||||
| } else { | ||||||
| response.data.findings.forEach((finding) => { | ||||||
| if (finding.length > 0) { | ||||||
| finding.forEach((result) => { | ||||||
| console.log(`Finding: ${result.finding}, Confidence: ${result.confidence}`); | ||||||
| }); | ||||||
| } | ||||||
| `NIGHTFALL_API_KEY=<YourApiKey> node nodesdksample.js` | ||||||
|
|
||||||
| ```typescript | ||||||
| async function main() { | ||||||
| const response = await nfClient.scanText(['The customer social security number is 111-22-3333'], { | ||||||
| detectionRules: [ | ||||||
| { | ||||||
| name: 'Secrets Scanner', | ||||||
| logicalOp: 'ANY', | ||||||
| detectors: [ | ||||||
| { | ||||||
| minNumFindings: 1, | ||||||
| minConfidence: Detector.Confidence.Possible, //'POSSIBLE' | ||||||
| displayName: 'SSN Detector', | ||||||
| detectorType: Detector.Type.Nightfall, //'NIGHTFALL_DETECTOR' | ||||||
| nightfallDetector: 'US_SOCIAL_SECURITY_NUMBER', | ||||||
| }, | ||||||
| ], | ||||||
| }, | ||||||
| ], | ||||||
| }); | ||||||
|
|
||||||
| if (response.isError) { | ||||||
| console.log(response.getError()); | ||||||
| } else if (response.data) { | ||||||
| response.data.findings.forEach((finding) => { | ||||||
| if (finding.length > 0) { | ||||||
| finding.forEach((result) => { | ||||||
| console.log(`Finding: ${result.finding}, Confidence: ${result.confidence}`); | ||||||
| }); | ||||||
| } | ||||||
| }); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| main(); | ||||||
| ``` | ||||||
|
|
||||||
| ### Scanning Files | ||||||
|
|
@@ -99,41 +106,59 @@ The file upload process is implemented as a series of requests to upload the fil | |||||
| provides a single method that wraps the steps required to upload your file. Please refer to the | ||||||
| [API Reference](https://docs.nightfall.ai/reference) for more details. | ||||||
|
|
||||||
| This script assumes a file named `./customer-details.txt` local to where the script is executed. | ||||||
|
|
||||||
| The file is uploaded synchronously, but as files can be arbitrarily large, the scan itself is conducted asynchronously. | ||||||
| The results from the scan are delivered by webhook; for more information about setting up a webhook server, refer to | ||||||
| [the docs](https://docs.nightfall.ai/docs/creating-a-webhook-server). | ||||||
|
|
||||||
| This script assumes a webhook a the location `https://my-service.com/nightfall/listener`. Update this to your webhook server address. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| #### Sample Code | ||||||
|
|
||||||
| To run this sample script you must compile it as TypesScript. Save it as a `.tsc` file and run `tsc <yourfilename>.ts -lib ES2015,DOM ` | ||||||
|
|
||||||
| You can this run the resulting JavaScript file: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| `NIGHTFALL_API_KEY=<YourApiKey> node nodesdksample.js` | ||||||
|
|
||||||
| ```typescript | ||||||
| // By default, the client reads your API key from the environment variable NIGHTFALL_API_KEY | ||||||
| import { Nightfall } from "nightfall-js"; | ||||||
| import { Detector } from "nightfall-js/dist/types" | ||||||
|
|
||||||
| // By default, the client reads your API key from the environment variable NIGHTFALL_API_KEY | ||||||
| const nfClient = new Nightfall(); | ||||||
|
|
||||||
| const response = await nfClient.scanFile('./customer-details.txt', { | ||||||
| detectionRules: [ | ||||||
| { | ||||||
| name: 'Secrets Scanner', | ||||||
| logicalOp: 'ANY', | ||||||
| detectors: [ | ||||||
| { | ||||||
| minNumFindings: 1, | ||||||
| minConfidence: Detector.Confidence.Possible, | ||||||
| displayName: 'Credit Card Number', | ||||||
| detectorType: Detector.Type.Nightfall, | ||||||
| nightfallDetector: 'CREDIT_CARD_NUMBER', | ||||||
| }, | ||||||
| ], | ||||||
| }, | ||||||
| ], | ||||||
| webhookURL: 'https://my-service.com/nightfall/listener', | ||||||
| }); | ||||||
|
|
||||||
| if (response.isError) { | ||||||
| console.log(response.getError()); | ||||||
| async function main() { | ||||||
| const response = await nfClient.scanFile('./customer-details.txt', { | ||||||
| detectionRules: [ | ||||||
| { | ||||||
| name: 'Secrets Scanner', | ||||||
| logicalOp: 'ANY', | ||||||
| detectors: [ | ||||||
| { | ||||||
| minNumFindings: 1, | ||||||
| minConfidence: Detector.Confidence.Possible, | ||||||
| displayName: 'Credit Card Number', | ||||||
| detectorType: Detector.Type.Nightfall, | ||||||
| nightfallDetector: 'CREDIT_CARD_NUMBER', | ||||||
| }, | ||||||
| ], | ||||||
| }, | ||||||
| ], | ||||||
| webhookURL: 'https://my-service.com/nightfall/listener', | ||||||
| }); | ||||||
|
|
||||||
| if (response.isError) { | ||||||
| console.log(response.getError()); | ||||||
| } | ||||||
|
|
||||||
| // Save this ID to check for findings when you receive a webhook event from us | ||||||
| console.log(response.data.id); | ||||||
| } | ||||||
|
|
||||||
| // Save this ID to check for findings when you receive a webhook event from us | ||||||
| console.log(response.data.id); | ||||||
| main(); | ||||||
| ``` | ||||||
|
|
||||||
| ## Contributing | ||||||
|
|
||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.