-
Notifications
You must be signed in to change notification settings - Fork 2
[SDK-753] Update sample readme #176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,131 @@ | ||
| Please follow these below steps to run samples | ||
|
|
||
| - Navigate to the desired sample | ||
| - In CMD, run the command, pod install | ||
| - Open the .xcworkspace file using xcode | ||
| - Click on Build and run | ||
|
|
||
| `Note`: | ||
| In every sample, in Skyflow.Config(), replace with the following fields: | ||
| 1. Replace the placeholder "<VAULT_ID>" with the correct vaultId you want to connect | ||
| 2. Replace the placeholder "<VAULT_URL>" with the correct vaultURL | ||
| 3. Implement the bearer token endpoint using server side auth SDK and service account file. | ||
| Replace the placeholder "<TOKEN_END_POINT_URL>" with the bearer token endpoint which gives the bearerToken, implemented at your backend. | ||
| # iOS SDK samples | ||
| Test the SDK by adding `VAULT-ID`, `VAULT-URL`, and `SERVICE-ACCOUNT` details in the required places for each sample. | ||
|
|
||
| ### Prerequisites | ||
| - iOS 13.0.0 or higher | ||
| - [cocoapods](https://cocoapods.org) | ||
| - Xcode | ||
| - [Node.js](https://nodejs.org/en/) 10 or higher | ||
| - [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) 6.x.x or higher | ||
|
|
||
| - [express.js](http://expressjs.com/en/starter/hello-world.html) | ||
|
|
||
|
|
||
| ### Create the vault | ||
| 1. In a browser, sign in to Skyflow Studio. | ||
| 2. Create a vault by clicking **Create Vault** > **Start With a Template** > **PIIData**. | ||
| 3. Once the vault is ready, click the gear icon and select **Edit Vault Details**. | ||
| 4. Note your **Vault URL** and **Vault ID** values, then click Cancel. You'll need these later. | ||
|
|
||
| ### Create a service account | ||
| 1. In the side navigation click, **IAM** > **Service Accounts** > **New Service Account**. | ||
| 2. For **Name**, enter "SDK Samples". For Roles, choose **Vault Editor**. | ||
| 3. Click **Create**. Your browser downloads a **credentials.json** file. Keep this file secure. You'll need it to generate bearer tokens. | ||
|
|
||
| ### Create a bearer token generation endpoint | ||
| 1. Create a new directory named `bearer-token-generator`. | ||
|
|
||
| mkdir bearer-token-generator | ||
| 2. Navigate to `bearer-token-generator` directory. | ||
|
|
||
| cd bearer-token-generator | ||
| 3. Initialize npm | ||
|
|
||
| npm init | ||
| 4. Install `skyflow-node` | ||
|
|
||
| npm i skyflow-node | ||
| 5. Create `index.js` file | ||
| 6. Open `index.js` file | ||
| 7. populate `index.js` file with below code snippet | ||
| ```javascript | ||
| const express = require('express') | ||
| const app = express() | ||
| var cors = require('cors') | ||
| const port = 3000 | ||
| const { | ||
| generateBearerToken, | ||
| isExpired | ||
| } = require('skyflow-node'); | ||
|
|
||
| app.use(cors()) | ||
|
|
||
| let filepath = 'cred.json'; | ||
| let bearerToken = ""; | ||
|
|
||
| function getSkyflowBearerToken() { | ||
| return new Promise(async (resolve, reject) => { | ||
| try { | ||
| if (!isExpired(bearerToken)) resolve(bearerToken) | ||
| else { | ||
| let response = await generateBearerToken(filepath); | ||
| bearerToken = response.accessToken; | ||
| resolve(bearerToken); | ||
| } | ||
| } catch (e) { | ||
| reject(e); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| app.get('/', async (req, res) => { | ||
| let bearerToken = await getSkyflowBearerToken(); | ||
| res.json({"accessToken" : bearerToken}); | ||
| }) | ||
|
|
||
| app.listen(port, () => { | ||
| console.log(`Server is listening on port ${port}`) | ||
| }) | ||
| ``` | ||
| 8. Start the server | ||
|
|
||
| node index.js | ||
| server will start at `localhost:3000` | ||
|
skyflow-puneet marked this conversation as resolved.
|
||
| 9. Your **<TOKEN_END_POINT_URL>** with `http://localhost:3000/` | ||
|
|
||
| ## The samples | ||
| ### Collect and reveal | ||
| This sample illustrates how to use secure Skyflow elements to collect sensitive user information and reveal it to the user via tokens. | ||
| #### Configure | ||
| 1. In `Skyflow.Configuration()` of [ViewController.swift](CollectAndRevealSample/CollectAndRevealSample/ViewController.swift), replace with the following fields: | ||
| - Replace the placeholder "<VAULT_ID>" with the correct vaultId you want to connect | ||
| - Replace the placeholder "<VAULT_URL>" with the correct vaultURL | ||
| 2. Update `Fields` struct in [ResponseStructs.swift](CollectAndRevealSample/CollectAndRevealSample/ResponseStructs.swift) with field name of used vault. For ex: | ||
|
|
||
| ```swift | ||
| struct Fields: Codable { | ||
| let name: NameField | ||
| let cvv: String | ||
| let cardExpiration: String | ||
| let cardNumber: String | ||
| let skyflow_id: String | ||
| } | ||
| ``` | ||
|
|
||
| The fields can be different depending upon the vault. | ||
| 3. Update | ||
| 4. Replace the placeholder "<TOKEN_END_POINT_URL>" of [ExampleTokenProvider.swift](CollectAndRevealSample/CollectAndRevealSample/ExampleTokenProvider.swift) with the bearer token endpoint which gives the bearerToken, implemented at your backend or `http://localhost:3000/`. | ||
| 5. Running the sample | ||
| 1. Open CMD | ||
| 2. Navigate to `CollectAndRevealSample` | ||
| 3. Run | ||
|
|
||
| pod install | ||
| 4. Open the [`CollectAndRevealSample.xcworkspace](`CollectAndRevealSample/`CollectAndRevealSample.xcworkspace) file using xcode | ||
| 5. click on build and run | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I couldn't get this running. Also, Xcode doesn't have a button with the text "build and run" that I could find.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| ### Validations | ||
| This sample illustrates how to apply custom validation rules on secure Skyflow Collect elements to restrict the type of input a user can provide. | ||
| #### Configure | ||
| 1. In `Skyflow.Configuration()` of [ViewController.swift](Validations/Validations/ViewController.swift), replace with the following fields: | ||
| 2. Replace the placeholder "<VAULT_ID>" in the configuration with the correct vaultId you want to connect | ||
| 3. Replace the placeholder "<VAULT_URL>" with the correct vaultURL | ||
| 4. Replace the placeholder "<TOKEN_END_POINT_URL>" in [ExampleTokenProvider.swift](Validations/Validations/ExampleTokenProvider.swift) with the bearer token endpoint which gives the bearerToken, implemented at your backend or `http://localhost:3000/`. | ||
| 5. Running the sample | ||
| 1. Open CMD | ||
| 2. Navigate to `Validations` | ||
| 3. Run | ||
|
|
||
| pod install | ||
| 4. Open the [Validations.xcworkspace](Validations/Validations.xcworkspace) file using xcode | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file doesn't exist.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Validations.xcworkspace does not exists in github repo. It automatically comes when we clone the repo in our local. |
||
| 5. click on build and run | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we create and ship the files for this sample for them instead of forcing them to make the directory and files themselves?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because credentials file will not be in the
Samples folder. Here we are usingcredentials.jsonfile for generating bearer token. Which the user need to keep in the separate folder createdbearer-token-generatorand this folder will not be in this repo since it is completely node project which is used for generaton ofendpoint of token generator.