Skip to content

Commit 92e401a

Browse files
committed
updated README
1 parent 12c7c75 commit 92e401a

File tree

1 file changed

+33
-28
lines changed

1 file changed

+33
-28
lines changed

README.md

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
- [References](#references)
1515
- [Usage](#usage)
1616
- [Prerequisites](#prerequisites)
17-
- [Adding the Libraries to Your Project](#adding-the-libraries-to-your-project)
17+
- [Adding the Library to Your Project](#adding-the-libraries-to-your-project)
1818
- [Performing Field Level Encryption and Decryption](#performing-field-level-encryption-and-decryption)
1919
- [Integrating with OpenAPI Generator API Client Libraries](#integrating-with-openapi-generator-api-client-libraries)
2020

@@ -97,22 +97,24 @@ const config = {
9797
path: "/resource",
9898
toEncrypt: [
9999
{
100-
/* path to element to be encrypted in request object */
100+
/* path to element to be encrypted in request json body */
101101
element: "path.to.foo",
102-
/* path to object where to store encryption fields in request object */
102+
/* path to object where to store encryption fields in request json body */
103103
obj: "path.to.encryptedFoo"
104104
}],
105105
toDecrypt: [
106106
{
107-
element: "path.to.foo",
108-
obj: "path.to.encryptedFoo"
107+
/* path to element with encryption fields in the response json body */
108+
element: "path.to.encryptedFoo",
109+
/* path to object where to store decrypted fields in response json body */
110+
obj: "path.to.foo"
109111
}
110112
]
111113
}
112114
],
113115
ivFieldName: 'iv',
114116
encryptedKeyFieldName: 'encryptedKey',
115-
encryptedValueFieldName: 'encryptedValue',
117+
encryptedValueFieldName: 'encryptedData',
116118
dataEncoding: 'hex',
117119
encryptionCertificate: "./path/to/public.cert"
118120
oaepPaddingDigestAlgorithm: 'SHA-256',
@@ -139,8 +141,8 @@ const string payload =
139141
"path": {
140142
"to": {
141143
"foo": {
142-
"sensitiveField1": "sensitiveValue1",
143-
"sensitiveField2": "sensitiveValue2"
144+
"sensitive": "this is a secret!",
145+
"sensitive2": "this is a super-secret!"
144146
}
145147
}
146148
}
@@ -153,15 +155,17 @@ Output:
153155

154156
```json
155157
{
156-
"path": {
157-
"to": {
158-
"encryptedFoo": {
159-
"iv": "7f1105fb0c684864a189fb3709ce3d28",
160-
"encryptedKey": "67f467d1b653d98411a0c6d3c(...)ffd4c09dd42f713a51bff2b48f937c8",
161-
"encryptedValue": "b73aabd267517fc09ed72455c2(...)dffb5fa04bf6e6ce9ade1ff514ed6141"
162-
}
163-
}
158+
"path": {
159+
"to": {
160+
"encryptedFoo": {
161+
"iv": "7f1105fb0c684864a189fb3709ce3d28",
162+
"encryptedKey": "67f467d1b653d98411a0c6d3c(...)ffd4c09dd42f713a51bff2b48f937c8",
163+
"encryptedData": "b73aabd267517fc09ed72455c2(...)dffb5fa04bf6e6ce9ade1ff514ed6141",
164+
"publicKeyFingerprint": "80810fc13a8319fcf0e2e(...)82cc3ce671176343cfe8160c2279",
165+
"oaepHashingAlgorithm": "SHA256"
166+
}
164167
}
168+
}
165169
}
166170
```
167171

@@ -186,28 +190,29 @@ response.body =
186190
"encryptedFoo": {
187191
"iv": "e5d313c056c411170bf07ac82ede78c9",
188192
"encryptedKey": "e3a56746c0f9109d18b3a2652b76(...)f16d8afeff36b2479652f5c24ae7bd",
189-
"encryptedValue": "809a09d78257af5379df0c454dcdf(...)353ed59fe72fd4a7735c69da4080e74f"
193+
"encryptedData": "809a09d78257af5379df0c454dcdf(...)353ed59fe72fd4a7735c69da4080e74f",
194+
"oaepHashingAlgorithm": "SHA256",
195+
"publicKeyFingerprint": "80810fc13a8319fcf0e2e(...)3ce671176343cfe8160c2279"
190196
}
191197
}
192198
}
193199
};
194200
const fle = new require('mastercard-client-encryption').FieldLevelEncryption(config);
195201
let responsePayload = fle.decrypt(response);
196-
console.log(responsePayload);
197202
```
198203

199204
Output:
200205

201206
```json
202207
{
203-
"path": {
204-
"to": {
205-
"foo": {
206-
"sensitiveField1": "sensitiveValue1",
207-
"sensitiveField2": "sensitiveValue2"
208-
}
209-
}
208+
"path": {
209+
"to": {
210+
"foo": {
211+
"sensitive": "this is a secret",
212+
"sensitive2": "this is a super secret!"
213+
}
210214
}
215+
}
211216
}
212217
```
213218

@@ -236,15 +241,15 @@ See also:
236241

237242
To use it:
238243

239-
1. Generate the OpenAPI client, as (above)[#openapi-generator]
244+
1. Generate the OpenAPI client, as [above](#openapi-generator)
240245

241246
2. Import the **mastercard-client-encryption** library
242247

243248
```js
244249
const mcapi = require('mastercard-client-encryption');
245250
```
246251

247-
3. Import the OpenAPI Client using our decorator object:
252+
3. Import the OpenAPI Client using the `Service` decorator object:
248253

249254
```js
250255
const openAPIClient = require('./path/to/generated/openapi/client');
@@ -262,7 +267,7 @@ To use it:
262267
let merchant = /* ... */
263268
api.createMerchants(merchant, (error, data, response) => {
264269
// requests and responses will be automatically encrypted and decrypted
265-
// accordingly to the configuration used to instantiate the mcapi.Service.
270+
// accordingly with the configuration used to instantiate the mcapi.Service.
266271

267272
/* use response/data object here */
268273
});

0 commit comments

Comments
 (0)