From 2ba38e0296ebd87303d22d5d4c21fbe230498ac2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Camith-skyflow=E2=80=9D?= <“amit@skyflow.com”> Date: Thu, 12 Dec 2024 21:04:25 +0530 Subject: [PATCH] SK-1621: refactor samples --- samples/vault-api/client-operations.ts | 2 +- samples/vault-api/credentials-options.ts | 15 ++++++++++++++- samples/vault-api/data-residency.ts | 19 +++---------------- samples/vault-api/delete-records.ts | 15 +-------------- samples/vault-api/detokenzie-records.ts | 15 +-------------- samples/vault-api/file-upload.ts | 15 +-------------- samples/vault-api/get-column-values.ts | 15 +-------------- samples/vault-api/get-records.ts | 15 +-------------- samples/vault-api/insert-byot.ts | 15 +-------------- samples/vault-api/insert-records.ts | 2 +- samples/vault-api/invoke-connection.ts | 2 +- samples/vault-api/query-records.ts | 15 +-------------- samples/vault-api/tokenize-records.ts | 15 +-------------- samples/vault-api/update-record.ts | 2 +- 14 files changed, 29 insertions(+), 133 deletions(-) diff --git a/samples/vault-api/client-operations.ts b/samples/vault-api/client-operations.ts index fa270c5..0f4799a 100644 --- a/samples/vault-api/client-operations.ts +++ b/samples/vault-api/client-operations.ts @@ -13,7 +13,7 @@ import { * Skyflow Secure Data Deletion Example * * This example demonstrates how to: - * 1. Configure Skyflow client credentials + * 1. Configure Bearer Token credentials * 2. Set up vault configuration * 3. Create a delete request * 4. Handle response and errors diff --git a/samples/vault-api/credentials-options.ts b/samples/vault-api/credentials-options.ts index c7ee92a..943c4bc 100644 --- a/samples/vault-api/credentials-options.ts +++ b/samples/vault-api/credentials-options.ts @@ -20,7 +20,19 @@ import { */ async function performSecureDataDeletion() { try { - // Step 1: Configure Bearer Token Credentials + // Step 1: Configure Skyflow client Credentials + const cred: object = { + clientID: '', // Client identifier + clientName: '', // Client name + keyID: '', // Key identifier + tokenURI: '', // Token URI + privateKey: '' // Private key for authentication + }; + + const skyflowCredentials: Credentials = { + credentialsString: JSON.stringify(cred), // Token credentials + }; + const credentials: Credentials = { token: '', // Bearer token // apiKey: '', // Uncomment to use API key @@ -45,6 +57,7 @@ async function performSecureDataDeletion() { // Step 3: Configure Skyflow Client const skyflowConfig: SkyflowConfig = { vaultConfigs: [primaryVaultConfig, secondaryVaultConfig], // Vault configurations + skyflowCredentials: skyflowCredentials, // Used if no individual credentials are passed logLevel: LogLevel.ERROR, // Set log level (ERROR in this case) }; diff --git a/samples/vault-api/data-residency.ts b/samples/vault-api/data-residency.ts index a6357d9..3e707b5 100644 --- a/samples/vault-api/data-residency.ts +++ b/samples/vault-api/data-residency.ts @@ -16,7 +16,7 @@ import { * Skyflow Vault Data Transfer Example * * This example demonstrates how to: - * 1. Configure Skyflow client credentials + * 1. Configure credentials * 2. Set up primary and secondary vault configurations * 3. Retrieve data from one vault * 4. Insert data into another vault @@ -24,19 +24,7 @@ import { */ async function transferDataBetweenVaults() { try { - // Step 1: Configure Skyflow Credentials - const cred: Object = { - clientID: '', // Client identifier - clientName: '', // Client name - keyID: '', // Key identifier - tokenURI: '', // Token URI - privateKey: '' // Private key for authentication - }; - - const skyflowCredentials: Credentials = { - credentialsString: JSON.stringify(cred), // Token credentials - }; - + // Step 1: Configure Credentials const credentials: Credentials = { token: 'BEARER_TOKEN', // Bearer token for authentication }; @@ -51,8 +39,7 @@ async function transferDataBetweenVaults() { // Step 3: Configure Skyflow Client const skyflowConfig: SkyflowConfig = { - vaultConfigs: [primaryVaultConfig], - skyflowCredentials: skyflowCredentials, // Skyflow credentials for fallback + vaultConfigs: [primaryVaultConfig], logLevel: LogLevel.ERROR, // Set log level to ERROR }; diff --git a/samples/vault-api/delete-records.ts b/samples/vault-api/delete-records.ts index 4b73d9e..85d384b 100644 --- a/samples/vault-api/delete-records.ts +++ b/samples/vault-api/delete-records.ts @@ -14,7 +14,7 @@ import { * Skyflow Delete Records Example * * This example demonstrates how to: - * 1. Configure Skyflow client credentials + * 1. Configure credentials * 2. Set up vault configuration * 3. Create a delete request * 4. Handle response and errors @@ -22,18 +22,6 @@ import { async function performDeletion() { try { // Step 1: Configure Credentials - const cred: object = { - clientID: '', // Client identifier - clientName: '', // Client name - keyID: '', // Key identifier - tokenURI: '', // Token URI - privateKey: '' // Private key for authentication - }; - - const skyflowCredentials: Credentials = { - credentialsString: JSON.stringify(cred), // Token credentials - }; - const credentials: Credentials = { apiKey: 'your-skyflow-api-key', // API key for authentication }; @@ -49,7 +37,6 @@ async function performDeletion() { // Step 3: Configure Skyflow Client const skyflowConfig: SkyflowConfig = { vaultConfigs: [primaryVaultConfig], - skyflowCredentials: skyflowCredentials, // Used if no individual credentials are passed logLevel: LogLevel.ERROR, // Logging verbosity }; diff --git a/samples/vault-api/detokenzie-records.ts b/samples/vault-api/detokenzie-records.ts index 9163c41..298f257 100644 --- a/samples/vault-api/detokenzie-records.ts +++ b/samples/vault-api/detokenzie-records.ts @@ -16,7 +16,7 @@ import { * Skyflow Detokenization Example * * This example demonstrates how to: - * 1. Configure Skyflow client credentials + * 1. Configure credentials * 2. Set up vault configuration * 3. Create a detokenization request * 4. Handle response and errors @@ -24,18 +24,6 @@ import { async function performDetokenization() { try { // Step 1: Configure Credentials - const cred: object = { - clientID: '', // Client identifier - clientName: '', // Client name - keyID: '', // Key identifier - tokenURI: '', // Token URI - privateKey: '' // Private key for authentication - }; - - const skyflowCredentials: Credentials = { - credentialsString: JSON.stringify(cred), // Token credentials - }; - const credentials: Credentials = { token: 'token', // Bearer token for authentication }; @@ -51,7 +39,6 @@ async function performDetokenization() { // Step 3: Configure Skyflow Client const skyflowConfig: SkyflowConfig = { vaultConfigs: [primaryVaultConfig], - skyflowCredentials: skyflowCredentials, // Used if no individual credentials are passed logLevel: LogLevel.ERROR, // Logging verbosity }; diff --git a/samples/vault-api/file-upload.ts b/samples/vault-api/file-upload.ts index 22ee7a5..ce417b5 100644 --- a/samples/vault-api/file-upload.ts +++ b/samples/vault-api/file-upload.ts @@ -14,7 +14,7 @@ import { * Skyflow File Upload Example * * This example demonstrates how to: - * 1. Configure Skyflow client credentials + * 1. Configure credentials * 2. Set up vault configuration * 3. Create a file upload request * 4. Handle response and errors @@ -22,18 +22,6 @@ import { async function performFileUpload() { try { // Step 1: Configure Credentials - const cred: object = { - clientID: '', // Client identifier - clientName: '', // Client name - keyID: '', // Key identifier - tokenURI: '', // Token URI - privateKey: '' // Private key for authentication - }; - - const skyflowCredentials: Credentials = { - credentialsString: JSON.stringify(cred), // Token credentials - }; - const credentials: Credentials = { path: 'path-to-credentials-json', // Path to credentials file }; @@ -49,7 +37,6 @@ async function performFileUpload() { // Step 3: Configure Skyflow Client const skyflowConfig: SkyflowConfig = { vaultConfigs: [primaryVaultConfig], - skyflowCredentials: skyflowCredentials, // Used if no individual credentials are passed logLevel: LogLevel.ERROR, // Logging verbosity }; diff --git a/samples/vault-api/get-column-values.ts b/samples/vault-api/get-column-values.ts index c31b354..01363ef 100644 --- a/samples/vault-api/get-column-values.ts +++ b/samples/vault-api/get-column-values.ts @@ -15,7 +15,7 @@ import { * Skyflow Secure Column-Based Retrieval Example * * This example demonstrates how to: - * 1. Configure Skyflow client credentials + * 1. Configure credentials * 2. Set up vault configuration * 3. Create a column-based get request * 4. Handle response and errors @@ -23,18 +23,6 @@ import { async function performSecureColumnRetrieval() { try { // Step 1: Configure Credentials - const cred: object = { - clientID: '', // Client identifier - clientName: '', // Client name - keyID: '', // Key identifier - tokenURI: '', // Token URI - privateKey: '' // Private key for authentication - }; - - const skyflowCredentials: Credentials = { - credentialsString: JSON.stringify(cred), // Token credentials - }; - const credentials: Credentials = { path: 'path-to-credentials-json', // Path to credentials file }; @@ -50,7 +38,6 @@ async function performSecureColumnRetrieval() { // Step 3: Configure Skyflow Client const skyflowConfig: SkyflowConfig = { vaultConfigs: [primaryVaultConfig], - skyflowCredentials: skyflowCredentials, // Used if no individual credentials are passed logLevel: LogLevel.ERROR, // Logging verbosity }; diff --git a/samples/vault-api/get-records.ts b/samples/vault-api/get-records.ts index b025797..901a154 100644 --- a/samples/vault-api/get-records.ts +++ b/samples/vault-api/get-records.ts @@ -15,7 +15,7 @@ import { * Skyflow Secure Data Retrieval Example * * This example demonstrates how to: - * 1. Configure Skyflow client credentials + * 1. Configure credentials * 2. Set up vault configuration * 3. Create a get request * 4. Handle response and errors @@ -23,18 +23,6 @@ import { async function performSecureDataRetrieval() { try { // Step 1: Configure Credentials - const cred: object = { - clientID: '', // Client identifier - clientName: '', // Client name - keyID: '', // Key identifier - tokenURI: '', // Token URI - privateKey: '' // Private key for authentication - }; - - const skyflowCredentials: Credentials = { - credentialsString: JSON.stringify(cred), // Token credentials - }; - const credentials: Credentials = { path: 'path-to-credentials-json', // Path to credentials file }; @@ -50,7 +38,6 @@ async function performSecureDataRetrieval() { // Step 3: Configure Skyflow Client const skyflowConfig: SkyflowConfig = { vaultConfigs: [primaryVaultConfig], - skyflowCredentials: skyflowCredentials, // Used if no individual credentials are passed logLevel: LogLevel.ERROR, // Logging verbosity }; diff --git a/samples/vault-api/insert-byot.ts b/samples/vault-api/insert-byot.ts index c4d472f..c29bb48 100644 --- a/samples/vault-api/insert-byot.ts +++ b/samples/vault-api/insert-byot.ts @@ -16,7 +16,7 @@ import { * Skyflow Insert with BYOT Example * * This example demonstrates: - * 1. Configuring Skyflow client credentials + * 1. Configuring credentials * 2. Setting up vault configuration * 3. Utilizing Bring Your Own Token (BYOT) during insertion * 4. Handling responses and errors @@ -24,18 +24,6 @@ import { async function performSecureDataInsertionWithBYOT() { try { // Step 1: Configure Credentials - const cred: object = { - clientID: '', // Client identifier - clientName: '', // Client name - keyID: '', // Key identifier - tokenURI: '', // Token URI - privateKey: '' // Private key for authentication - }; - - const skyflowCredentials: Credentials = { - credentialsString: JSON.stringify(cred), // Token-based credentials - }; - const credentials: Credentials = { token: 'bearer', // Bearer token authentication }; @@ -51,7 +39,6 @@ async function performSecureDataInsertionWithBYOT() { // Step 3: Configure Skyflow Client const skyflowConfig: SkyflowConfig = { vaultConfigs: [primaryVaultConfig], - skyflowCredentials: skyflowCredentials, // Used if no individual credentials are passed logLevel: LogLevel.INFO // Logging verbosity }; diff --git a/samples/vault-api/insert-records.ts b/samples/vault-api/insert-records.ts index 8a9dfce..8a642d3 100644 --- a/samples/vault-api/insert-records.ts +++ b/samples/vault-api/insert-records.ts @@ -15,7 +15,7 @@ import { * Skyflow Secure Data Insertion Example * * This example demonstrates how to: - * 1. Configure Skyflow client credentials + * 1. Configure credentials * 2. Set up vault configuration * 3. Create an insert request * 4. Handle response and errors diff --git a/samples/vault-api/invoke-connection.ts b/samples/vault-api/invoke-connection.ts index ac2b6a6..18e13fb 100644 --- a/samples/vault-api/invoke-connection.ts +++ b/samples/vault-api/invoke-connection.ts @@ -15,7 +15,7 @@ import { * Skyflow Connection Invocation Example * * This example demonstrates how to: - * 1. Configure Skyflow client credentials + * 1. Configure credentials * 2. Set up vault and connection configurations * 3. Invoke a connection * 4. Handle response and errors diff --git a/samples/vault-api/query-records.ts b/samples/vault-api/query-records.ts index 3efd701..8deeade 100644 --- a/samples/vault-api/query-records.ts +++ b/samples/vault-api/query-records.ts @@ -14,7 +14,7 @@ import { * Skyflow Query Example * * This example demonstrates how to: - * 1. Configure Skyflow client credentials + * 1. Configure credentials * 2. Set up vault configuration * 3. Execute a query on the vault * 4. Handle response and errors @@ -22,18 +22,6 @@ import { async function executeQuery() { try { // Step 1: Configure Credentials - const cred: object = { - clientID: '', // Client identifier - clientName: '', // Client name - keyID: '', // Key identifier - tokenURI: '', // Token URI - privateKey: '' // Private key for authentication - }; - - const skyflowCredentials: Credentials = { - credentialsString: JSON.stringify(cred), // Token credentials - }; - const credentials: Credentials = { // Using API Key authentication apiKey: 'your-skyflow-api-key', @@ -50,7 +38,6 @@ async function executeQuery() { // Step 3: Configure Skyflow Client const skyflowConfig: SkyflowConfig = { vaultConfigs: [primaryVaultConfig], - skyflowCredentials: skyflowCredentials, // Used if no individual credentials are passed logLevel: LogLevel.ERROR, // Logging verbosity }; diff --git a/samples/vault-api/tokenize-records.ts b/samples/vault-api/tokenize-records.ts index e11ed24..959fc8f 100644 --- a/samples/vault-api/tokenize-records.ts +++ b/samples/vault-api/tokenize-records.ts @@ -15,7 +15,7 @@ import { * Skyflow Tokenization Example * * This example demonstrates how to: - * 1. Configure Skyflow client credentials + * 1. Configure credentials * 2. Set up vault configuration * 3. Tokenize sensitive data * 4. Handle response and errors @@ -23,18 +23,6 @@ import { async function executeTokenization() { try { // Step 1: Configure Credentials - const cred: object = { - clientID: '', // Client identifier - clientName: '', // Client name - keyID: '', // Key identifier - tokenURI: '', // Token URI - privateKey: '' // Private key for authentication - }; - - const skyflowCredentials: Credentials = { - credentialsString: JSON.stringify(cred), // Token credentials - }; - const credentials: Credentials = { apiKey: '', // API key for authentication }; @@ -50,7 +38,6 @@ async function executeTokenization() { // Step 3: Configure Skyflow Client const skyflowConfig: SkyflowConfig = { vaultConfigs: [primaryVaultConfig], - skyflowCredentials: skyflowCredentials, // Used if no individual credentials are passed logLevel: LogLevel.ERROR, // Logging verbosity }; diff --git a/samples/vault-api/update-record.ts b/samples/vault-api/update-record.ts index 277a27f..839e240 100644 --- a/samples/vault-api/update-record.ts +++ b/samples/vault-api/update-record.ts @@ -15,7 +15,7 @@ import { * Skyflow Secure Data Update Example * * This example demonstrates how to: - * 1. Configure Skyflow client credentials + * 1. Configure credentials * 2. Set up vault configuration * 3. Create an update request * 4. Handle response and errors