Skip to content

Commit

Permalink
Merge pull request #171 from skyflowapi/SK-1621-node-sdk-v2
Browse files Browse the repository at this point in the history
SK-1621: refactor samples
  • Loading branch information
amith-skyflow authored Dec 13, 2024
2 parents de61884 + 2ba38e0 commit 8f16d02
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 133 deletions.
2 changes: 1 addition & 1 deletion samples/vault-api/client-operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 14 additions & 1 deletion samples/vault-api/credentials-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: '<your-client-id>', // Client identifier
clientName: '<your-client-name>', // Client name
keyID: '<your-key-id>', // Key identifier
tokenURI: '<your-token-uri>', // Token URI
privateKey: '<your-pem-private-key>' // Private key for authentication
};

const skyflowCredentials: Credentials = {
credentialsString: JSON.stringify(cred), // Token credentials
};

const credentials: Credentials = {
token: '<your_bearer_token>', // Bearer token
// apiKey: '<your_api_key>', // Uncomment to use API key
Expand All @@ -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)
};

Expand Down
19 changes: 3 additions & 16 deletions samples/vault-api/data-residency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,15 @@ 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
* 5. Handle responses and errors
*/
async function transferDataBetweenVaults() {
try {
// Step 1: Configure Skyflow Credentials
const cred: Object = {
clientID: '<your-client-id>', // Client identifier
clientName: '<your-client-name>', // Client name
keyID: '<your-key-id>', // Key identifier
tokenURI: '<your-token-uri>', // Token URI
privateKey: '<your-pem-private-key>' // 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
};
Expand All @@ -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
};

Expand Down
15 changes: 1 addition & 14 deletions samples/vault-api/delete-records.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,14 @@ 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
*/
async function performDeletion() {
try {
// Step 1: Configure Credentials
const cred: object = {
clientID: '<your-client-id>', // Client identifier
clientName: '<your-client-name>', // Client name
keyID: '<your-key-id>', // Key identifier
tokenURI: '<your-token-uri>', // Token URI
privateKey: '<your-pem-private-key>' // 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
};
Expand All @@ -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
};

Expand Down
15 changes: 1 addition & 14 deletions samples/vault-api/detokenzie-records.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,14 @@ 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
*/
async function performDetokenization() {
try {
// Step 1: Configure Credentials
const cred: object = {
clientID: '<your-client-id>', // Client identifier
clientName: '<your-client-name>', // Client name
keyID: '<your-key-id>', // Key identifier
tokenURI: '<your-token-uri>', // Token URI
privateKey: '<your-pem-private-key>' // Private key for authentication
};

const skyflowCredentials: Credentials = {
credentialsString: JSON.stringify(cred), // Token credentials
};

const credentials: Credentials = {
token: 'token', // Bearer token for authentication
};
Expand All @@ -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
};

Expand Down
15 changes: 1 addition & 14 deletions samples/vault-api/file-upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,14 @@ 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
*/
async function performFileUpload() {
try {
// Step 1: Configure Credentials
const cred: object = {
clientID: '<your-client-id>', // Client identifier
clientName: '<your-client-name>', // Client name
keyID: '<your-key-id>', // Key identifier
tokenURI: '<your-token-uri>', // Token URI
privateKey: '<your-pem-private-key>' // 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
};
Expand All @@ -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
};

Expand Down
15 changes: 1 addition & 14 deletions samples/vault-api/get-column-values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,14 @@ 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
*/
async function performSecureColumnRetrieval() {
try {
// Step 1: Configure Credentials
const cred: object = {
clientID: '<your-client-id>', // Client identifier
clientName: '<your-client-name>', // Client name
keyID: '<your-key-id>', // Key identifier
tokenURI: '<your-token-uri>', // Token URI
privateKey: '<your-pem-private-key>' // 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
};
Expand All @@ -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
};

Expand Down
15 changes: 1 addition & 14 deletions samples/vault-api/get-records.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,14 @@ 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
*/
async function performSecureDataRetrieval() {
try {
// Step 1: Configure Credentials
const cred: object = {
clientID: '<your-client-id>', // Client identifier
clientName: '<your-client-name>', // Client name
keyID: '<your-key-id>', // Key identifier
tokenURI: '<your-token-uri>', // Token URI
privateKey: '<your-pem-private-key>' // 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
};
Expand All @@ -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
};

Expand Down
15 changes: 1 addition & 14 deletions samples/vault-api/insert-byot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,14 @@ 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
*/
async function performSecureDataInsertionWithBYOT() {
try {
// Step 1: Configure Credentials
const cred: object = {
clientID: '<your-client-id>', // Client identifier
clientName: '<your-client-name>', // Client name
keyID: '<your-key-id>', // Key identifier
tokenURI: '<your-token-uri>', // Token URI
privateKey: '<your-pem-private-key>' // Private key for authentication
};

const skyflowCredentials: Credentials = {
credentialsString: JSON.stringify(cred), // Token-based credentials
};

const credentials: Credentials = {
token: 'bearer', // Bearer token authentication
};
Expand All @@ -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
};

Expand Down
2 changes: 1 addition & 1 deletion samples/vault-api/insert-records.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion samples/vault-api/invoke-connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 1 addition & 14 deletions samples/vault-api/query-records.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,14 @@ 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
*/
async function executeQuery() {
try {
// Step 1: Configure Credentials
const cred: object = {
clientID: '<your-client-id>', // Client identifier
clientName: '<your-client-name>', // Client name
keyID: '<your-key-id>', // Key identifier
tokenURI: '<your-token-uri>', // Token URI
privateKey: '<your-pem-private-key>' // 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',
Expand All @@ -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
};

Expand Down
15 changes: 1 addition & 14 deletions samples/vault-api/tokenize-records.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,14 @@ 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
*/
async function executeTokenization() {
try {
// Step 1: Configure Credentials
const cred: object = {
clientID: '<your-client-id>', // Client identifier
clientName: '<your-client-name>', // Client name
keyID: '<your-key-id>', // Key identifier
tokenURI: '<your-token-uri>', // Token URI
privateKey: '<your-pem-private-key>' // Private key for authentication
};

const skyflowCredentials: Credentials = {
credentialsString: JSON.stringify(cred), // Token credentials
};

const credentials: Credentials = {
apiKey: '<your-api-key>', // API key for authentication
};
Expand All @@ -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
};

Expand Down
2 changes: 1 addition & 1 deletion samples/vault-api/update-record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8f16d02

Please sign in to comment.