diff --git a/README.md b/README.md index 5f765097..4fbaaba9 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ The Skyflow SDK enables you to connect to your Skyflow Vault(s) to securely hand ## Installation -Requires Node v12.22.12 and above. +Requires Node.js v18 and above. File operations (`uploadFile`, `deidentifyFile`) require Node.js v20 and above. ```sh npm install skyflow-node @@ -293,7 +293,7 @@ For all `InsertOptions` setters and `TokenMode` values, see [InsertOptions](docs Convert tokens back into plaintext values (or masked values) using the `.detokenize()` method. Detokenization accepts tokens and returns values. -Create a detokenization request with the [`DetokenizeRequest`](docs/api_reference.md#detokenizerequest) class, which requires a list of tokens and column groups as input. +Create a detokenization request with the [`DetokenizeRequest`](docs/api_reference.md#detokenizerequest) class, which requires a list of tokens as input, each with an optional redaction type. Provide optional parameters such as the redaction type and the option to continue on error. @@ -304,6 +304,7 @@ import { DetokenizeOptions, DetokenizeRequest, DetokenizeResponse, + RedactionType, } from "skyflow-node"; const detokenizeRequest = new DetokenizeRequest([ @@ -733,15 +734,19 @@ De-identify files using the `deidentifyFile` method. Create a de-identify file r > File de-identification requires Node.js v20.x or above. ```typescript +import fs from 'fs'; import { DeidentifyFileRequest, DeidentifyFileOptions, - DeidentifyFileResponse + DeidentifyFileResponse, SkyflowError, DetectEntities, MaskingMethod, DetectOutputTranscription, - Bleep + Bleep, + FileInput, + TokenFormat, + TokenType, } from 'skyflow-node'; // Prepare the file to be deidentified @@ -765,8 +770,6 @@ options.setTokenFormat(tokenFormat); options.setOutputDirectory(''); // Output directory for saving the deidentified file. Not supported in Cloudflare workers. options.setWaitTime(64); // Wait time for polling (max 64 seconds; returns runId + status if exceeded) - -tifyFile const response: DeidentifyFileResponse = await skyflowClient .detect(primaryVaultConfig.vaultId) .deidentifyFile(fileReq, options); @@ -808,14 +811,11 @@ Retrieve the results of a previously started file de-identification operation (o import { GetDetectRunRequest, DeidentifyFileResponse, - DeidentifyFileResponse - SkyflowError + SkyflowError, } from 'skyflow-node'; // Prepare the GetDetectRunRequest with the runId from a previous deidentifyFile call -const request = new GetDetectRunRequest({ - runId: '', // Replace with the runId you received earlier -}); +const request = new GetDetectRunRequest(''); // Replace with the runId you received earlier // Step 2: Call getDetectRun const response: DeidentifyFileResponse = await skyflowClient @@ -837,7 +837,7 @@ Get Detect Run Response: { status: 'SUCCESS', runId: 'run-abc123', fileBase64: ' ## Connections -Securely send and receive data between your systems and first- or third-party services using Skyflow Connections, a gateway service that uses tokenization. The [connections](https://github.com/skyflowapi/skyflow-node/tree/v2/src/vault/controller/connections) module invokes both inbound and outbound connections. +Securely send and receive data between your systems and first- or third-party services using Skyflow Connections, a gateway service that uses tokenization. The [connections](https://github.com/skyflowapi/skyflow-node/tree/main/src/vault/controller/connections) module invokes both inbound and outbound connections. - **Inbound connections**: Act as intermediaries between your client and server, tokenizing sensitive data before it reaches your backend, ensuring downstream services handle only tokenized data. - **Outbound connections**: Enable secure extraction of data from the vault and transfer it to third-party services via your backend server, such as processing checkout or card issuance flows. @@ -900,7 +900,7 @@ Invoke connection response: { data: { status: 'success', transaction_id: 'txn_ab **pathParams, queryParams, header, body** are the JSON objects represented as dictionaries that will be sent through the connection integration url. > [!TIP] -> See the full example in the samples directory: [scoped-token-generation-example.ts](samples/vault-api/invoke-connection.ts) +> See the full example in the samples directory: [invoke-connection.ts](samples/vault-api/invoke-connection.ts) > See [docs.skyflow.com](https://docs.skyflow.com) for more details on integrations with Connections, Functions, and Pipelines. ## Authentication & authorization @@ -957,7 +957,7 @@ Generate and manage bearer tokens to authenticate API calls. This section covers #### Generate a bearer token -Generate service account tokens using the [Service Account](https://github.com/skyflowapi/skyflow-node/tree/v2/src/service-account) Node package with a service account credentials file provided when a service account is created. Tokens generated by this module are valid for 60 minutes and can be used to make API calls to the [Data](https://docs.skyflow.com/record/) and [Management](https://docs.skyflow.com/management/) APIs, depending on the permissions assigned to the service account. +Generate service account tokens using the [Service Account](https://github.com/skyflowapi/skyflow-node/tree/main/src/service-account) Node package with a service account credentials file provided when a service account is created. Tokens generated by this module are valid for 60 minutes and can be used to make API calls to the [Data](https://docs.skyflow.com/record/) and [Management](https://docs.skyflow.com/management/) APIs, depending on the permissions assigned to the service account. ##### `generateBearerToken(filepath)` @@ -1019,7 +1019,7 @@ if (expired) { ``` > [!TIP] -> See the full example in the samples directory: [token-generation-example.ts](http://github.com/skyflowapi/skyflow-node/blob/v2/samples/service-account/token-generation-example.ts) +> See the full example in the samples directory: [token-generation-example.ts](samples/service-account/token-generation-example.ts) #### Generate bearer tokens scoped to certain roles @@ -1278,7 +1278,7 @@ Most first-run problems come from configuration mismatches. Every error thrown b | Symptom | Likely cause | Fix | |---|---|---| -| `npm install skyflow-node` fails | Unsupported Node version | Requires Node v12.22.12 or above. | +| `npm install skyflow-node` fails | Unsupported Node version | Requires Node.js v18 or above. | | Connection/DNS failures, or 404 on every call | Wrong `clusterId` | `clusterId` is the first segment of your vault URL: `https://{clusterId}.vault.skyflowapis.com`. | | Requests hit the wrong host / unexpected auth failures | Wrong `env` | Match `env` to where your vault runs (`Env.PROD`, `Env.SANDBOX`, `Env.DEV`, `Env.STAGE`). | | `401 Unauthorized` | Invalid or expired credentials | Verify your API key or service-account credentials. Regenerate if needed. | diff --git a/docs/advanced_initialization.md b/docs/advanced_initialization.md index 98bfae63..ed8e6765 100644 --- a/docs/advanced_initialization.md +++ b/docs/advanced_initialization.md @@ -92,7 +92,7 @@ const tertiaryVaultConfig: VaultConfig = { const skyflowConfig: SkyflowConfig = { vaultConfigs: [primaryVaultConfig, secondaryVaultConfig, tertiaryVaultConfig], // Add the primary, secondary and tertiary vault configurations. - skyflowCredentials: skyflowCredentials, // Add JSON-formatted credentials if applicable. + skyflowCredentials: { credentialsString: credentialsString }, // Use the stringified JSON credentials as the shared fallback credentials. logLevel: LogLevel.INFO, // Recommended to use LogLevel.ERROR in production environment. }; diff --git a/docs/api_reference.md b/docs/api_reference.md index 92ac7ad3..0c30db4c 100644 --- a/docs/api_reference.md +++ b/docs/api_reference.md @@ -186,7 +186,7 @@ Passed to `detect().getDetectRun()`. | Constructor argument | Type | Description | |---|---|---| -| `options` | `{ runId: string }` | The `runId` returned by a prior `deidentifyFile` call. | +| `runId` | `string` | The `runId` returned by a prior `deidentifyFile` call. | ### `InvokeConnectionRequest` @@ -252,7 +252,7 @@ Provide **exactly one** file source: `setFileObject`, `setFilePath`, or `setBase | Setter | Type | Description | |---|---|---| -| `setSkyflowId(id)` | `string` | **Required.** Skyflow ID of the record to attach the file to. | +| `setSkyflowId(id)` | `string` | Skyflow ID of the record to attach the file to. Omit to upload the file to a new record. | | `setFileObject(file)` | `File` | In-memory `File` object. | | `setFilePath(path)` | `string` | Path to a file on disk. Requires Node.js v20+. | | `setBase64(data)` | `string` | Base64-encoded file content. Use with `setFileName`. | diff --git a/docs/migrate_to_v2.md b/docs/migrate_to_v2.md index 60a0f076..f8b2bfc3 100644 --- a/docs/migrate_to_v2.md +++ b/docs/migrate_to_v2.md @@ -2,6 +2,9 @@ This guide outlines the steps required to migrate the Skyflow Node SDK from version 1 (V1) to version 2 (V2). +> [!IMPORTANT] +> V1 is in maintenance mode and will reach End of Life on October 31, 2026. Migrate to V2 before that date. + ## Authentication In V2, multiple authentication options have been introduced. You can now provide credentials in the following ways: @@ -28,6 +31,8 @@ const auth = function () { #### v2 Authentication: Credentials object +**Option 1: API key** + ```typescript import { Credentials } from 'skyflow-node'; @@ -36,16 +41,17 @@ const credentials: Credentials = { }; ``` -// Option 2: Environment Variables (Recommended) -// Set SKYFLOW_CREDENTIALS in your environment +**Option 2: Environment variable (recommended)** + +Set `SKYFLOW_CREDENTIALS` in your environment. The SDK reads it automatically when no credentials are passed. -// Option 3: Credentials File +**Option 3: Credentials file** ```typescript const credentials: Credentials = { path: "" }; ``` -// Option 4: Stringified JSON +**Option 4: Stringified JSON** ```typescript const credentials: Credentials = { @@ -53,7 +59,7 @@ const credentials: Credentials = { }; ``` -// Option 5: Bearer Token +**Option 5: Bearer token** ```typescript const credentials: Credentials = { token: "" }; @@ -124,10 +130,10 @@ const skyflowClient: Skyflow = new Skyflow(skyflowConfig); ### Request and Response Structure -In v2, with the introduction of TypeScript support, you can now pass an **InsertRequest** of type **InsertRequest**. This request requires: +In v2, with the introduction of TypeScript support, you can now pass an **InsertRequest** of type **InsertRequest**. Its constructor takes two positional arguments: -- **`tableName`**: The name of the table. -- **`insertData`**: An array of objects containing the data to be inserted +- **`table`**: The name of the table. +- **`data`**: An array of objects containing the data to insert. The response will be of type InsertResponse, which contains insertedFields and errors. diff --git a/samples/README.md b/samples/README.md index 90f49e8a..bf6741b2 100644 --- a/samples/README.md +++ b/samples/README.md @@ -5,7 +5,7 @@ Explore working examples that demonstrate common SDK operations. Start with basi ## Prerequisites - A Skyflow account. If you don't have one, register for one on the [Try Skyflow](https://skyflow.com/try-skyflow) page. -- [Node 7.6.0](https://nodejs.org/en/) and above. +- [Node.js](https://nodejs.org/en/) v18 and above. File-upload and de-identify-file samples require Node.js v20 and above. ## Prepare