Security News
Research
Supply Chain Attack on Rspack npm Packages Injects Cryptojacking Malware
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
@truework/sdk
Advanced tools
The official Truework API Node.js SDK.
npm i @truework/sdk --save
const { truework } = require('@truework/sdk');
const client = truework({ token: TRUEWORK_ACCESS_TOKEN });
By default, the SDK will use the latest version of our API. To request a different version, pass it when configuring your client.
const client = truework({
token: TRUEWORK_ACCESS_TOKEN,
version: '2019-10-15',
});
To set a timeout on requests, pass in the timeout value in milliseconds when configuring the client. If a request times out, it will abort with got.TimeoutError. Most applicable when used in conjunction with synchronous creation of verifications.
const client = truework({
token: TRUEWORK_ACCESS_TOKEN,
timeout: 6000,
});
To use the SDK to call the Truework Sandbox, configure the client for the sandbox environment.
const { truework, ENVIRONMENT } = require('@truework/sdk');
const client = truework({
token: TRUEWORK_SANDBOX_TOKEN,
environment: ENVIRONMENT.SANDBOX,
});
Please review the API Documentation for all terminology. If you're using Typescript, have a look at the types.
All requests are made using got, and so responses implement a got response object.
const {
body: { count, results },
} = await client.verifications.get();
verifications.get([params])
Request
params
- object
- optional
state
- string
- requiredlimit
- number
offset
- number
Response
Returns a PaginatedResponse
containing an array of Verification
s.
Example
await client.verifications.get();
await client.verifications.get({ limit: 10 });
verifications.getOne(params)
Request
params
- object
- required
id
- string
- requiredResponse
Returns a Verification
object.
Example
await client.verifications.getOne({ id: 'abc123' });
verifications.create(params)
Request
params
- object
- required
type
- VerificationType
- requiredpermissible_purpose
- PermissiblePurpose
- requiredtarget
- Target
- requireddocuments
- Document
additional_information
- string
Response
Returns the full Verification
object.
Example
await client.verifications.create({
type: 'employment',
permissible_purpose: 'employment',
target: {
first_name: 'Megan',
last_name: 'Rapinoe',
social_security_number: '123121234',
company: {
name: 'USWNT',
},
},
additional_information: 'Lorem ipsum dolor...',
});
verifications.create(params, syncParams)
Executes the request synchronously, attempting to return the completed verification rather than sending a webhook on
completion. It is recommended to use the client timeout
param in conjunction with this method.
Request
params
- object
- required
type
- VerificationType
- requiredpermissible_purpose
- PermissiblePurpose
- requiredtarget
- Target
- requireddocuments
- Document
additional_information
- string
syncParams
- object
strategy
- RequestSyncStrategy
Response
Returns the full Verification
object, with reports
if successful.
Example
const {
truework,
REQUEST_SYNC_STRATEGIES,
VERIFICATION_TYPES,
PERMISSIBLE_PURPOSES,
} = require('@truework/sdk');
const client = truework({
token: TRUEWORK_ACCESS_TOKEN,
timeout: 6000,
});
const res = await client.verifications.create(
{
type: VERIFICATION_TYPES.EMPLOYMENT,
permissible_purpose: PERMISSIBLE_PURPOSES.EMPLOYMENT,
target: {
first_name: 'Megan',
last_name: 'Rapinoe',
social_security_number: '123121234',
date_of_birth: '1990-09-26',
},
additional_information: 'Lorem ipsum dolor...',
},
{
strategy: REQUEST_SYNC_STRATEGIES.SYNC,
}
);
if (res.body.reports?.length) {
// verification completed synchronously
}
verifications.cancel(params)
Request
params
- object
- required
id
- string
- requiredcancellationReason
- CancellationReason
- requiredcancellationDetails
- string
Response
Returns status code 200
on success.
Example
await client.verifications.cancel({
id: 'abc123',
cancellationReason: 'other',
});
verifications.reverify(params)
Request
params
- object
- required
id
- string
- requiredreport_id
- string
- requiredResponse
Returns the full Verification
object.
Example
await client.verifications.reverify({
id: 'abc123',
rerport_id: 'def123',
});
verifications.getReport(params)
Request
params
- object
- required
id
- string
- required, the ID of the VerificationResponse
Returns the full Report
object associated with the Verification.
Example
await client.verifications.getReport({ id: 'abc123' });
companies.get(params)
Request
params
- object
- required
query
- string
- requiredlimit
- number
offset
- number
Response
Returns a PaginatedResponse
containing an array of Company
s.
Example
await client.companies.get({ query: 'USWNT' });
credentials.createSession(params)
Request
params
- object
- required
type
- VerificationType
- requiredpermissible_purpose
- PermissiblePurpose
- requireduse_case
- UseCase
- requiredtarget
- Target
- requiredResponse
Returns a CredentialsSession
Example
await client.credentials.createSession({
type: 'employment',
permissible_purpose: 'employment',
use_case: 'mortgage',
target: {
first_name: 'Megan',
last_name: 'Rapinoe',
social_security_number: '123121234',
date_of_birth: '2020-02-02',
company: {
name: 'USWNT',
},
},
});
This SDK provides a naive "mock" mode that can be used for basic testing during CI, etc. It is stateless, meaning no data is persisted between API calls. When enabled, each SDK method will either return stub objects, or simple reflections of the data submitted.
To enable mock mode, initialize your SDK client like this:
const client = truework({
token: TRUEWORK_ACCESS_TOKEN,
mock: true,
});
verifications.get
Returns a stubbed array of verifications, respective of all query params.
const res = await client.verifications.get({ state: 'processing', limit: 5 });
res.body.results.length; // => 5
res.body.results[0].state; // => processing
verifications.getOne
Returns a stubbed verification object with the same id
as is passed to
getOne({ id })
.
Any id
value is valid, except "AAAA"
, which will trigger a 404
error
response.
try {
await client.verifications.getOne({ id: 'AAAA' });
} catch (e) {
console.log(e.response); // error response body
}
verifications.create
Returns a stubbed verification object.
To trigger an error response, do not pass a type
property.
try {
await client.verifications.create(
// type: 'employment',
permissible_purpose: 'employment',
target: {
first_name: 'Megan',
last_name: 'Rapinoe',
social_security_number: '123121234',
company: {
name: 'USWNT',
},
},
additional_information: 'Lorem ipsum dolor...',
})
} catch (e) {
console.log(e.response) // error response body
}
verifications.cancel
Returns 200
if successful.
Any id
value is valid, except "AAAA"
, which will trigger an error response.
try {
await client.verifications.cancel({ id: 'AAAA' });
} catch (e) {
console.log(e.response); // error response body
}
verifications.getReport
Returns a stubbed report object if successful.
Any id
value is valid, except "AAAA"
, which will trigger an error response.
try {
await client.verifications.getReport({ id: 'AAAA' });
} catch (e) {
console.log(e.response); // error response body
}
companies.get
Returns a stubbed array of companies, respective of limit
and offset
query
params.
const res = await client.companies.get({ limit: 5 });
res.body.results.length; // => 5
If you run into problems, or simply have a question, feel free to open an issue!
This repo uses commitizen to nicely
format commit messages. Upon making edits, stage your changes and simply run
git commit
to enter the commitizen UI in your terminal.
Note: if you are not prompted with the commitizen UI, run npm ci
to re-install
and run postinstall
hooks to set it up.
This project is versioned and published automatically using
semantic-release. Via a
GitHub Action, semantic-release
will use the commit message pattern provided
by commitizen
to automatically version the package. It will then publish to
npm, as well as create a new
release here in the
main repo.
Do not publish this library manually from the command line.
MIT License © Truework
FAQs
Official Truework Node.js SDK
The npm package @truework/sdk receives a total of 67 weekly downloads. As such, @truework/sdk popularity was classified as not popular.
We found that @truework/sdk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 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.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.
Security News
Sonar’s acquisition of Tidelift highlights a growing industry shift toward sustainable open source funding, addressing maintainer burnout and critical software dependencies.