Skip to content
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

HCX-806 : Javascript HCX Integrator SDK - Enhance SDK to integrate the user's API access token generation #75

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions javascript/src/hcx_integrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export class HCXIntegrator {
this.authBasePath = null;
this.username = null;
this.password = null;
this.secret = null;
this.encryptionPrivateKeyURL = null;
this.igURL = null;
this.validateConfig();
Expand All @@ -21,6 +22,7 @@ export class HCXIntegrator {
this.authBasePath = this.config.authBasePath;
this.username = this.config.username;
this.password = this.config.password;
this.secret = this.config.secret;
this.encryptionPrivateKeyURL = this.config.encryptionPrivateKeyURL;
this.igURL = this.config.igURL;
}
Expand All @@ -33,6 +35,7 @@ export class HCXIntegrator {
this.authBasePath,
this.username,
this.password,
this.secret,
this.encryptionPrivateKeyURL,
this.igURL
);
Expand All @@ -58,6 +61,7 @@ export class HCXIntegrator {
this.authBasePath,
this.username,
this.password,
this.secret,
this.encryptionPrivateKeyURL,
this.igURL
);
Expand All @@ -84,6 +88,7 @@ export class HCXIntegrator {
this.authBasePath,
this.username,
this.password,
this.secret,
this.encryptionPrivateKeyURL,
this.igURL
);
Expand Down
2 changes: 2 additions & 0 deletions javascript/src/impl/HCXIncomingRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export class HCXIncomingRequest {
authBasePath,
username,
password,
secret,
encryptionPrivateKeyURL,
igURL
) {
Expand All @@ -19,6 +20,7 @@ export class HCXIncomingRequest {
this.authBasePath = authBasePath;
this.username = username;
this.password = password;
this.secret = secret;
this.encryptionPrivateKeyURL = encryptionPrivateKeyURL;
this.igURL = igURL;
this.headers = null;
Expand Down
23 changes: 17 additions & 6 deletions javascript/src/impl/HCXOutgoingRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class HCXOutgoingRequest {
authBasePath,
username,
password,
secret,
encryptionPrivateKeyURL,
igURL
) {
Expand All @@ -20,6 +21,7 @@ export class HCXOutgoingRequest {
this.authBasePath = authBasePath;
this.username = username;
this.password = password;
this.secret = secret;
this.encryptionPrivateKeyURL = encryptionPrivateKeyURL; // not needed in outgoing
this.igURL = igURL;
this.hcxToken = null;
Expand Down Expand Up @@ -69,10 +71,14 @@ export class HCXOutgoingRequest {
throw new Error("Fhir payload must be an object");
}
if (!this.hcxToken) {
const payload = {}
if(this.username) payload[this.Constants.USERNAME] = this.username;
if(this.password) payload[this.Constants.PASSWORD] = this.password;
if(this.secret) payload[this.Constants.SECRET] = this.secret;
if(this.participantCode) payload["participant_code"] = this.participantCode;
this.hcxToken = await generateToken(
this.authBasePath,
this.username,
this.password
payload
);
}
const registryData = await searchRegistry(
Expand All @@ -89,6 +95,7 @@ export class HCXOutgoingRequest {
});
return encrypted;
} catch (error) {
console.log(error.response.data);
console.error(`Error in encryptPayload: ${error.message}\n${error.stack}`);
this.error = {
[ErrorCodes.ERR_INVALID_ENCRYPTION]: ResponseMessage.INVALID_PAYLOAD_VALUES_ERR_MSG
Expand All @@ -101,10 +108,14 @@ export class HCXOutgoingRequest {
try {
const url = `${this.protocolBasePath}${operation}`;
if (!this.hcxToken) {
this.hcxToken = await generateHcxToken(
const payload = {}
if(this.username) payload[this.Constants.USERNAME] = this.username;
if(this.password) payload[this.Constants.PASSWORD] = this.password;
if(this.secret) payload[this.Constants.SECRET] = this.secret;
if(this.participantCode) payload["participant_code"] = this.participantCode;
this.hcxToken = await generateToken(
this.authBasePath,
this.username,
this.password
payload
);
}
const payload = JSON.stringify({ payload: jwePayload, });
Expand All @@ -116,7 +127,7 @@ export class HCXOutgoingRequest {
const response = await axios.post(url, payload, { headers });
return response.data;
} catch (e) {
console.error(`Initialize HCX: ${e}`);
console.error(`Initialize HCX: ${e.response.data}`);
}
} catch (error) {
console.error(`Initialize HCX: ${error}`);
Expand Down
44 changes: 40 additions & 4 deletions javascript/src/outputDisplayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const config = {
igUrl: "https://ig.hcxprotocol.io/v0.7.1",
};


const config2 = {
participantCode: "testpayor1.swasthmock@swasth-hcx-staging",
authBasePath:
Expand All @@ -25,6 +26,30 @@ const config2 = {
igUrl: "https://ig.hcxprotocol.io/v0.7.1",
};

const config3 = {
participantCode: "testprovider1.swasthmock@swasth-hcx-staging",
authBasePath:
"http://staging-hcx.swasth.app/api/v0.8/participant/auth/token/generate",
protocolBasePath: "https://staging-hcx.swasth.app/api/v0.8",
encryptionPrivateKeyURL:
"https://raw.githubusercontent.com/Swasth-Digital-Health-Foundation/hcx-platform/main/hcx-apis/src/test/resources/examples/x509-private-key.pem",
username: "testprovider1@swasthmock.com",
secret: "Opensaber@123",
igUrl: "https://ig.hcxprotocol.io/v0.7.1",
};

const config4 = {
participantCode: "testpayor1.swasthmock@swasth-hcx-staging",
authBasePath:
"http://staging-hcx.swasth.app/api/v0.8/participant/auth/token/generate",
protocolBasePath: "https://staging-hcx.swasth.app/api/v0.8",
encryptionPrivateKeyURL:
"https://raw.githubusercontent.com/Swasth-Digital-Health-Foundation/hcx-platform/main/hcx-apis/src/test/resources/examples/x509-private-key.pem",
username: "testpayor1@swasthmock.com",
secret: "Opensaber@123",
igUrl: "https://ig.hcxprotocol.io/v0.7.1",
};

const fhirPayload = {
resourceType: "Bundle",
id: "98aa81af-7a49-4159-a8ed-35e721d6ae74",
Expand Down Expand Up @@ -510,18 +535,29 @@ const fhirPayload = {

const hcxIntegrator = new HCXIntegrator(config);
const hcxIntegrator2 = new HCXIntegrator(config2);
const hcxIntegrator3 = new HCXIntegrator(config3);
const hcxIntegrator4 = new HCXIntegrator(config4);

const operation = HcxOperations.CLAIM_SUBMIT;
const operation2 = HcxOperations.CLAIM_ON_SUBMIT;
const actionJwe = "eyJhbGciOiAiUlNBLU9BRVAiLCAiZW5jIjogIkEyNTZHQ00iLCAieC1oY3gtYXBpX2NhbGxfaWQiOiAiNWNiZTcxMjItYTFlNC00NTI4LWJiNGYtYjRjZWZkOWQwMzc0IiwgIngtaGN4LXRpbWVzdGFtcCI6ICIyMDIzLTA4LTE3VDE4OjQzOjQ4KzA1OjMwIiwgIngtaGN4LXNlbmRlcl9jb2RlIjogInRlc3Rwcm92aWRlcjEuc3dhc3RobW9ja0Bzd2FzdGgtaGN4LXN0YWdpbmciLCAieC1oY3gtcmVjaXBpZW50X2NvZGUiOiAidGVzdHBheW9yMS5zd2FzdGhtb2NrQHN3YXN0aC1oY3gtc3RhZ2luZyIsICJ4LWhjeC1jb3JyZWxhdGlvbl9pZCI6ICIyNzdmYjZkMC1hNjNlLTQ4ODUtYThkMC02NzY3MmY2ZWU2ZTkifQ.B_KdeKcU9-U9lunN9U85BMHRgS4J42kjGxCiX0iD69NJDaZLtCmOn_nqmEt_q7C1qJzuoDzOa9zzGUD7rVXh4aKahzdqiERBNoTVdeSHepalSS-e47HZ4me3-3A9kBaoyQGzS6qx7nplobWxfv8PlBNCzKQKMuXEZaGS88UAVCUAIBXHgExJYJgogRPpw56PsNXweV5xluV1JX51XJeHIAdOXghsLithY52gmnvYCNrjuTL_gO-XVl5wCltSlM9sIBRoCXBQinmcYJICpIOdhnTKcEmYtqUB70GSReUC4LTxnISWgQ0GeGFYqxvo97bX3dpZjIVG1fTvuIrUXPeE1w.WcoC73KvODQghMRX.tHWRPLtfhF_1U2tBqMOxyM3IHVTX5ZQAyiCwUxoeY597OpT9nI5x7Hd3yPubbg48li7i3N7pVbtAE-qa34vZwQ8q7eOJQmJgePH52yc_l7rKVEy3tH2ztYQoT0KyFg6ZgkETp7i9Vis6-6JwXvjH-Ha7qGGyzFM1R2xYreSzMEF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wgoQvR311jAR3SYOXN-dDb4NVgZorBRaByjzhyn0vPZ3TqMZyYkg4PYdzEsHvQc3VF2145UXzd8Z0X07XlbggMLXp8gHfp5aXoPH9AT84Fvuow9ewqEa7aUIwAfCpnsqznsUJr31ESm_emxD0J2sWB7X4WNzfOrLORtihFUaneOQVIuPkBFL8RLY2M2fTMx-0KXDAEICrZXCLFv0e56fYbziU0Xub6DKOGwz5XdOL-3bxUkLil4age4NgAC5GmMxJ6E_nBGmT0HIWOpmvgs41iK6G7i1ZDCWwmFq6J1d-Eo.hscCVcxL5wYYFO-QNJ4W-w";

const responseOutgoing = await hcxIntegrator.processOutgoingRequest(fhirPayload, "testpayor1.swasthmock@swasth-hcx-staging", operation);
const responseOutgoingCallback = await hcxIntegrator2.processOutgoingCallback(fhirPayload, "", operation2, actionJwe, "", "", "", "response.complete");
const responseOutgoingCallback = await hcxIntegrator2.processOutgoingCallback(fhirPayload, "", operation2, responseOutgoing.payload, "", "", "", "response.complete");
const responseIncoming = await hcxIntegrator.processIncoming(
responseOutgoing.payload,
operation
);

console.log(responseOutgoing);
console.log(responseIncoming);
console.log(responseOutgoingCallback)
console.log(responseOutgoingCallback)

const responseOutgoing1 = await hcxIntegrator3.processOutgoingRequest(fhirPayload, "testpayor1.swasthmock@swasth-hcx-staging", operation);
const responseOutgoingCallback1 = await hcxIntegrator4.processOutgoingCallback(fhirPayload, "", operation2, responseOutgoing1.payload, "", "", "", "response.complete");
const responseIncoming1 = await hcxIntegrator3.processIncoming(
responseOutgoing1.payload,
operation
);

console.log(responseOutgoing1);
console.log(responseIncoming1);
console.log(responseOutgoingCallback1);
1 change: 1 addition & 0 deletions javascript/src/utils/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export class Constants {
AUTH_BASE_PATH = "authBasePath";
USERNAME = "username";
PASSWORD = "password";
SECRET = "secret";
ENCRYPTION_PRIVATE_KEY = "encryptionPrivateKey";
HCX_IG_BASE_PATH = "hcxIGBasePath";
NRCES_IG_BASE_PATH = "nrcesIGBasePath";
Expand Down
7 changes: 2 additions & 5 deletions javascript/src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ import { stringify } from "qs";
import { base64url } from "jose";
import axios from "axios";

export async function generateToken(authBasePath, username, password) {
export async function generateToken(authBasePath, config) {
const url = authBasePath;
const payload = {
client_id: "registry-frontend",
username: username,
password: password,
grant_type: "password",
...config
};
const payloadUrlencoded = stringify(payload);
const headers = {
Expand Down
Loading