You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Samples/README.md
+52-64Lines changed: 52 additions & 64 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,98 +35,86 @@ Test the SDK by adding `VAULT-ID`, `VAULT-URL`, and `SERVICE-ACCOUNT` details in
35
35
4. Install `skyflow-node`
36
36
37
37
npm i skyflow-node
38
-
5. Create `index.js` file
39
-
6. Open `index.js` file
40
-
7. populate `index.js` file with below code snippet
38
+
5. Move the downloaded “credentials.json” file #Create a service account account into the bearer-token-generator directory.
39
+
6. Create `index.js` file
40
+
7. Open `index.js` file
41
+
8. populate `index.js` file with below code snippet
41
42
```javascript
42
-
constexpress=require('express')
43
-
constapp=express()
44
-
var cors =require('cors')
45
-
constport=3000
43
+
constexpress=require("express");
44
+
constapp=express();
45
+
constcors=require("cors");
46
+
constport=3000;
46
47
const {
47
-
generateBearerToken,
48
-
isExpired
49
-
} =require('skyflow-node');
48
+
generateBearerToken,
49
+
isExpired
50
+
} =require("skyflow-node");
50
51
51
-
app.use(cors())
52
+
app.use(cors());
52
53
53
-
let filepath ='cred.json';
54
+
let filepath ="credentials.json";
54
55
let bearerToken ="";
55
56
56
-
functiongetSkyflowBearerToken() {
57
-
returnnewPromise(async (resolve, reject) => {
58
-
try {
59
-
if (!isExpired(bearerToken)) resolve(bearerToken)
60
-
else {
61
-
let response =awaitgenerateBearerToken(filepath);
62
-
bearerToken =response.accessToken;
63
-
resolve(bearerToken);
64
-
}
65
-
} catch (e) {
66
-
reject(e);
67
-
}
68
-
});
57
+
constgetSkyflowBearerToken= () => {
58
+
returnnewPromise(async (resolve, reject) => {
59
+
try {
60
+
if (!isExpired(bearerToken)) {
61
+
resolve(bearerToken);
62
+
}
63
+
else {
64
+
let response =awaitgenerateBearerToken(filepath);
65
+
bearerToken =response.accessToken;
66
+
resolve(bearerToken);
67
+
}
68
+
} catch (e) {
69
+
reject(e);
70
+
}
71
+
});
69
72
}
70
-
71
-
app.get('/', async (req, res) => {
72
-
let bearerToken =awaitgetSkyflowBearerToken();
73
-
res.json({"accessToken": bearerToken});
74
-
})
73
+
app.get("/", async (req, res) => {
74
+
let bearerToken =awaitgetSkyflowBearerToken();
75
+
res.json({"accessToken": bearerToken});
76
+
});
75
77
76
78
app.listen(port, () => {
77
-
console.log(`Server is listening on port ${port}`)
79
+
console.log(`Server is listening on port ${port}`);
78
80
})
79
81
```
80
-
8. Start the server
82
+
9. Start the server
81
83
82
84
node index.js
83
85
server will start at `localhost:3000`
84
-
9. Your **<TOKEN_END_POINT_URL>** with `http://localhost:3000/`
86
+
10. Your **<TOKEN_END_POINT_URL>** with `http://localhost:3000/`
85
87
86
88
## The samples
87
89
### Collect and reveal
88
-
This sample illustrates how to use secure Skyflow elements to collect sensitive user information and reveal it to the user via tokens.
90
+
This sample demonstrates how to use Skyflow Elements to collect sensitive user information and reveal it to a user.
89
91
#### Configure
90
92
1. In `Skyflow.Configuration()` of [ViewController.swift](CollectAndRevealSample/CollectAndRevealSample/ViewController.swift), replace with the following fields:
91
-
- Replace the placeholder "<VAULT_ID>" with the correct vaultId you want to connect
92
-
- Replace the placeholder "<VAULT_URL>" with the correct vaultURL
93
-
2. Update `Fields` struct in [ResponseStructs.swift](CollectAndRevealSample/CollectAndRevealSample/ResponseStructs.swift) with field name of used vault. For ex:
94
-
95
-
```swift
96
-
struct Fields: Codable {
97
-
let name: NameField
98
-
let cvv: String
99
-
let cardExpiration: String
100
-
let cardNumber: String
101
-
let skyflow_id: String
102
-
}
103
-
```
104
-
105
-
The fields can be different depending upon the vault.
106
-
3. Update
107
-
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/`.
93
+
- The placeholder "<VAULT_ID>" with the vault ID you noted previously.
94
+
- The placeholder "<VAULT_URL>" with the vault URL you noted previously.
95
+
2. Replace the placeholder "<TOKEN_END_POINT_URL>" in [ExampleTokenProvider.swift](https://github.com/skyflowapi/skyflow-iOS/blob/SDK-753-update-sample-app-readme/Samples/CollectAndRevealSample/CollectAndRevealSample/ExampleTokenProvider.swift) with the service account bearer token endpoint.
108
96
109
97
#### Running the sample
110
98
1. Open CMD
111
-
2. Navigate to `CollectAndRevealSample`
99
+
2. Navigate to CollectAndRevealSample
112
100
3. Run
113
101
114
102
pod install
115
-
4. Open the `CollectAndRevealSample.xcworkspace` file using xcode
116
-
5. click on build and run
117
-
118
-
### Validations
119
-
This sample illustrates how to apply custom validation rules on secure Skyflow Collect elements to restrict the type of input a user can provide.
103
+
4. Open the CollectAndRevealSample.xcworkspace file using xcode.
104
+
5. Build and run using command + R.
105
+
106
+
### Custom validation
107
+
This sample demonstrates how to apply custom validation rules to Skyflow elements to restrict the type of input a user can provide.
120
108
#### Configure
121
-
1.In `Skyflow.Configuration()` of [ViewController.swift](Validations/Validations/ViewController.swift), replace with the following fields:
122
-
2. Replace the placeholder "<VAULT_ID>" in the configuration with the correct vaultId you want to connect
123
-
3. Replace the placeholder "<VAULT_URL>" with the correct vaultURL
124
-
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/`.
109
+
In `Skyflow.Configuration()` of [ViewController.swift](Validations/Validations/ViewController.swift), replace with the following fields:
110
+
1. Replace the placeholder "<VAULT_ID>" in the configuration with the vault ID previously noted. Replace the placeholder "<VAULT_URL>" with the vault URL previously noted.
111
+
2. Replace the placeholder "<TOKEN_END_POINT_URL>" in [ExampleTokenProvider.swift](https://github.com/skyflowapi/skyflow-iOS/blob/SDK-753-update-sample-app-readme/Samples/Validations/Validations/ExampleTokenProvider.swift)with the service account bearer token endpoint.
112
+
125
113
#### Running the sample
126
114
1. Open CMD
127
-
2. Navigate to `Validations`
115
+
2. Navigate to Validations
128
116
3. Run
129
117
130
118
pod install
131
-
4. Open the `Validations.xcworkspace` file using xcode
132
-
5. click on build and run
119
+
4. Open the Validations.xcworkspace file using xcode
0 commit comments