Skip to content

Commit

Permalink
Merge branch 'master' into SK-704/add-tokens-options-get
Browse files Browse the repository at this point in the history
  • Loading branch information
skyflow-lipsa committed Oct 19, 2023
2 parents e0027fd + 6bd0726 commit df32078
Show file tree
Hide file tree
Showing 23 changed files with 3,081 additions and 2,247 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

All notable changes to this project will be documented in this file.

## [1.11.0] - 2023-07-19
### Added
- Added new `delete` interface.
## [1.10.0] - 2023-06-08
### Added
- `redaction` in detokenize interface.
### Changed
- Removed grace period logic for bearer token generation.
## [1.9.3] - 2023-03-17
### Changed
- Removed grace period logic for bearer token generation.
Expand Down
91 changes: 81 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@ skyflow-node is the Node.js version of Skyflow SDK for the JavaScript programmin
- [Requirements](#requirements)
- [Configuration](#configuration)
- [Usage](#usage)
- [Service Account Bearer Token Generation](#Service-Account-Bearer-Token-Generation)
- [Service Account Bearer Token Generation with Additional Context](#Service-Account-Bearer-Token-Generation-with-Additional-Context)
- [Service Account Scoped Bearer Token Generation](#Service-Account-Scoped-Bearer-Token-Generation)
- [Skyflow Signed Data Tokens Generation](#Skyflow-Signed-Data-Tokens-Generation)
- [Importing `skyflow-node`](#importing-skyflow-node)
- [Service Account Bearer Token Generation](#service-account-bearer-token-generation)
- [Service Account Bearer Token Generation with Additional Context](#service-account-bearer-token-generation-with-additional-context)
- [Service Account Scoped Bearer Token Generation](#service-account-scoped-bearer-token-generation)
- [Skyflow Signed Data Tokens Generation](#skyflow-signed-data-tokens-generation)
- [Vault APIs](#vault-apis)
- [Insert](#insert)
- [Detokenize](#detokenize)
- [Get By Id](#get-by-id)
- [Get](#get)
- [Update](#update)
- [Delete](#delete)
- [Invoke Connection](#invoke-connection)
- [Logging](#logging)
- [Reporting a Vulnerability](#reporting-a-vulnerability)
Expand Down Expand Up @@ -112,7 +114,7 @@ let bearerToken = '';
function getSkyflowBearerToken() {
return new Promise(async (resolve, reject) => {
try {
if (isExpired(bearerToken)) resolve(bearerToken);
if (!isExpired(bearerToken)) resolve(bearerToken);
else {
let response = await generateBearerTokenFromCreds(
JSON.stringify(credentials)
Expand Down Expand Up @@ -195,7 +197,7 @@ function getSkyflowBearerToken() {
const options = {
ctx: 'CONTEXT_ID',
}
if (isExpired(bearerToken)) resolve(bearerToken);
if (!isExpired(bearerToken)) resolve(bearerToken);
else {
let response = await generateBearerTokenFromCreds(
JSON.stringify(credentials),
Expand Down Expand Up @@ -279,7 +281,7 @@ function getSkyflowBearerToken() {
const options = {
roleIDs: ['ROLE_ID1', 'ROLE_ID2'],
};
if (isExpired(bearerToken)) resolve(bearerToken);
if (!isExpired(bearerToken)) resolve(bearerToken);
else {
let response = await generateBearerTokenFromCreds(
JSON.stringify(credentials),
Expand Down Expand Up @@ -577,18 +579,28 @@ In order to retrieve data from your vault using tokens that you have previously
```javascript
data = {
records: [{
// Token for the record to be fetched.
token: 'string'
token: 'string', // Required, token for the record to be fetched.
redaction: Skyflow.RedactionType // Optional, redaction type to be applied to retrieved data, ex: Skyflow.RedactionType.PLAIN_TEXT
}]
}
```
`Skyflow.RedactionType` accept four values:
* `PLAIN_TEXT`
* `MASKED`
* `REDACTED`
* `DEFAULT`

Note:
- `redaction` defaults to Skyflow.RedactionType.PLAIN_TEXT.

An [example](https://github.com/skyflowapi/skyflow-node/blob/master/samples/vault-api/Detokenize.ts) of a detokenize call:

```javascript
const result = client.detokenize({
records: [
{
token: '4017-f72b-4f5c-9b-8e719',
redaction: Skyflow.RedactionType.PLAIN_TEXT
},
],
});
Expand Down Expand Up @@ -629,7 +641,7 @@ data = {
}]
};
```
`Skyflow.RedactionTypes` accept four values:
`Skyflow.RedactionType` accept four values:
* `PLAIN_TEXT`
* `MASKED`
* `REDACTED`
Expand Down Expand Up @@ -899,6 +911,65 @@ Response:
]
}
```
#### Delete

To delete data from the vault, use the `delete(records, options?)` method of the Skyflow client. The `records` parameter takes an array of records to delete in the following format. The `options` parameter is optional and takes an object of deletion parameters. Currently, there are no supported deletion parameters.

Call schema:
```js
const deleteInput = {
records: [
{
id: "<SKYFLOW_ID_1>", // skyflow id of the record to delete
table: "<TABLE_NAME>" // Table from which the record is to be deleted
},
{
// ...additional records here
},
]
};

const options = {
// Optional
}
```

[Example](https://github.com/skyflowapi/skyflow-node/blob/master/samples/vault-api/Delete.ts) to delete by ID using `skyflow_ids`

```js
const deleteInput = {
records: [
{
id: "29ebda8d-5272-4063-af58-15cc674e332b",
table: "cards",
},
{
id: "d5f4b926-7b1a-41df-8fac-7950d2cbd923",
table: "cards",
}
],
};

const options = {};

const response = skyflowClient.delete(deleteInput, options);
console.log(response);
```
Response:
```json
{
"records": [
{
"skyflow_id": "29ebda8d-5272-4063-af58-15cc674e332b",
"deleted": true,
},
{
"skyflow_id": "29ebda8d-5272-4063-af58-15cc674e332b",
"deleted": true,
}
]
}
```
#### Invoke Connection

Using the InvokeConnection method, you can integrate their server-side application with third party APIs and services without directly handling sensitive data. Prior to invoking the InvokeConnection method, you must have created a connection and have a connectionURL already generated. Once you have the connectionURL, you can invoke a connection by using the `invokeConnection(config)` method. The config object must include a connectionURL and methodName. The other fields are optional.
Expand Down
Loading

0 comments on commit df32078

Please sign in to comment.