
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
@redactive/redactive
Advanced tools
The Redactive Node SDK provides a robust and intuitive interface for interacting with the Redactive platform, enabling developers to seamlessly integrate powerful data redaction and anonymization capabilities into their Node applications.
In order to use the package to integrate with Redactive.ai, run:
npm install @redactive/redactive
There is no need to clone this repository.
If you would like to modify this package, clone the repo and install from source:
npm install ./sdks/node
The library has following components.
AuthClient needs to be configured with your account's API key which is available in the Apps page at Redactive Dashboard.
The AuthClient can be used to present users with the data providers' OAuth consent pages:
import { AuthClient } from "@redactive/redactive";
// Construct AuthClient using your Redactive API key
const client = new AuthClient("YOUR-API-KEY-HERE");
// Establish an connection to data source
// Possible data sources: confluence, sharepoint
const redirectUri = "YOUR-REDIRECT-URI";
const provider = "confluence";
const signInUrl = await client.beginConnection({ provider, redirectUri });
// Now redirect your user to signInUrl
The user will be redirected back to your app's configured redirect uri after they have completed the steps on
the data provider's OAuth consent page. There will be a signin code present in the code
parameter of the query string e.g.
https://your-redirect-page.com?code=abcde12345
.
This code may be exchanged for a user access token (which the user may use to issue queries against their data):
// Exchange signin code for a Redactive ID token
const response = await client.exchangeTokens({ code: "SIGNIN-CODE" });
const accessToken = response.idToken;
Once a user has completed the OAuth flow, the data source should show up in their connected data sources:
(await client.listConnections({ accessToken }).connections) === ["confluence"]; // ✅
Use the list_connections
method to keep your user's connection status up to date, and provide mechanisms to re-connect data sources.
With the Redactive access_token
, you can perform two types of search
Retrieve relevant chunks of information that are related to a user query.
import { SearchClient } from "@redactive/redactive";
const client = new SearchClient();
const accessToken = "REDACTIVE-ACCESS-TOKEN";
// Query-based Search: retrieve text extracts (chunks) from various documents pertaining to the user query
const query = "Tell me about AI";
await client.searchChunks({ accessToken, query });
Filters may be applied to query-based search operations. At present, the following fields may be provided as filter predicates:
message Filters {
// Scope of the query. This may either be the name of a provider, or a subspace of documents.
// Subspaces take the form of <provider>://<tenancy>/<path>
// e.g. for Confluence: 'confluence://redactiveai.atlassian.net/Engineering/Engineering Onboarding Guide'
// for Sharepoint: 'sharepoint://redactiveai.sharepoint.com/Shared Documents/Engineering/Onboarding Guide.pdf'
repeated string scope = 1;
// Timespan of response chunk's creation
optional TimeSpan created = 2;
// Timespan of response chunk's last modification
optional TimeSpan modified = 3;
// List of user emails associated with response chunk
repeated string user_emails = 4;
// Include content from documents in trash
optional bool include_content_in_trash = 5;
}
The query will only return results which match ALL filter predicates i.e. if multiple fields are populated in the filter object, the resulting filter is the logical 'AND' of all the fields. If a data source provider does not support a filter-type, then no results from that provider are returned.
Filters may be populated and provided to a query in the following way for the NodeJS SDK:
import { Filters } from "@redactive/redactive";
// Query chunks from Confluence only, that are from documents created before last week, modified since last week,
// and that are from documents associated with a user's email. Include chunks from trashed documents.
const lastWeek = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
const filters: Filters = {
scope: ["confluence"],
created: {
before: lastWeek
},
modified: {
after: lastWeek
},
userEmails: ["myEmail@example.com"],
includeContentInTrash: true
};
await client.searchChunks({ accessToken, semanticQuery, filters });
Obtain all the chunks from a specific document by specifying a unique reference (i.e. a URL).
import { SearchClient } from "@redactive/redactive";
const client = new SearchClient();
const accessToken = "REDACTIVE-ACCESS-TOKEN";
// URL-based Search: retrieve all chunks of the document at that URL
const url = "https://example.com/document";
await client.getDocument({ accessToken, url });
The MultiUserClient
class helps manage multiple users' authentication and access to the Redactive search service.
import { MultiUserClient } from "@redactive/redactive";
const multiUserClient = MultiUserClient(
"REDACTIVE-API-KEY",
"https://example.com/callback/",
readUserData,
multiUserClient
);
// Present `connection_url` in browser for user to interact with:
const userId = "myUserId";
const connectionUrl = await multiUserClient.getBeginConnectionUrl(userId, "confluence");
// On user return from OAuth connection flow:
let [signInCode, state] = ["", ""]; // from URL query parameters
const isConnectionSuccessful = await multiUserClient.handleConnectionCallback(userId, signInCode, state);
// User can now use Redactive search service via `MultiUserClient`'s other methods:
const query = "Tell me about the missing research vessel, the Borealis";
const chunks = await multiUserClient.searchChunks({ userId, query });
The Node SDK code can be found thesdks/node
directory in Redactive Github Repository.
In order to comply with the repository style guide, we recommend running the following tools.
To format your code, run:
pnpm format:fix
To lint your code, run:
pnpm lint:fix
To test changes, run:
pnpm test
To build Node SDK, run:
pnpm build
To install local version, run:
npm install ./sdks/node
Please check here
FAQs
Redactive AI Node SDK
The npm package @redactive/redactive receives a total of 29 weekly downloads. As such, @redactive/redactive popularity was classified as not popular.
We found that @redactive/redactive demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.