generated from IBM/template-graphql-typescript
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix credentials for CRA api call (#29)
Signed-off-by: Sean Sundberg <[email protected]>
- Loading branch information
Showing
10 changed files
with
345 additions
and
286 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
src/controllers/customer-risk-assessment/customer-risk-assessment.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/services/customer-risk-assessment/customer-risk-assessment.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import * as https from "https"; | ||
import {Configuration} from "./configuration"; | ||
|
||
let _instance: Configuration; | ||
export const customerRiskAssessmentConfig = (): Configuration => { | ||
if (_instance) { | ||
return _instance; | ||
} | ||
|
||
const username = process.env.CRA_USERNAME; | ||
const password = process.env.CRA_PASSWORD; | ||
const apiKey = process.env.CRA_API_KEY; | ||
|
||
const buildAuthorization = () => { | ||
if (username && apiKey) { | ||
const token = Buffer.from(`${username}:${apiKey}`).toString('base64') | ||
|
||
return `ZenApiKey ${token}` | ||
} | ||
|
||
const token = Buffer.from(`${username}:${password}`).toString('base64') | ||
|
||
return `Basic ${token}` | ||
} | ||
|
||
_instance = new Configuration({ | ||
username, | ||
password, | ||
apiKey, | ||
basePath: process.env.CRA_BASE_PATH, | ||
baseOptions: { | ||
httpsAgent: new https.Agent({ | ||
rejectUnauthorized: false | ||
}), | ||
headers: { | ||
'Authorization': buildAuthorization() | ||
} | ||
} | ||
}); | ||
|
||
if (!(_instance.username && _instance.password) && !_instance.apiKey) { | ||
throw new Error('CRA_USERNAME, CRA_PASSWORD, and/or CRA_API_KEY not set'); | ||
} | ||
|
||
return _instance; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/config/kyc-summary.config.ts → ...es/kyc-case-summary/kyc-summary.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.