Skip to content

Commit 305c8f4

Browse files
fix: add optional parameter token to CactusNode
add token to apiClient.ofLedger and PluginConsortiumManual getConsortiumJws method when property is setted relationed with hyperledger-cacti#1579 Signed-off-by: Elena Izaguirre <[email protected]>
1 parent 0e76bf6 commit 305c8f4

File tree

4 files changed

+41
-5
lines changed

4 files changed

+41
-5
lines changed

packages/cactus-api-client/src/main/typescript/api-client.ts

+12-3
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,18 @@ export class ApiClient extends BaseAPI {
130130

131131
const randomNode = nodes[randomIdx];
132132

133-
const configuration = new Configuration({
134-
basePath: randomNode.nodeApiHost,
135-
});
133+
const nodeToken = randomNode.token;
134+
let configuration: Configuration;
135+
if (nodeToken) {
136+
configuration = new Configuration({
137+
basePath: randomNode.nodeApiHost,
138+
baseOptions: { headers: { Authorization: `Bearer ${nodeToken}` } },
139+
});
140+
} else {
141+
configuration = new Configuration({
142+
basePath: randomNode.nodeApiHost,
143+
});
144+
}
136145

137146
return new ApiClient(configuration).extendWith(ctor);
138147
}

packages/cactus-core-api/src/main/json/openapi.json

+3
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,9 @@
344344
"items": {
345345
"$ref": "#/components/schemas/PluginInstanceId"
346346
}
347+
},
348+
"token": {
349+
"type": "string"
347350
}
348351
}
349352
}

packages/cactus-core-api/src/main/typescript/generated/openapi/typescript-axios/api.ts

+12
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ export interface CactusNode {
6969
* @memberof CactusNode
7070
*/
7171
pluginInstanceIds: Array<string>;
72+
/**
73+
*
74+
* @type {string}
75+
* @memberof CactusNode
76+
*/
77+
token?: string;
7278
}
7379
/**
7480
*
@@ -106,6 +112,12 @@ export interface CactusNodeAllOf {
106112
* @memberof CactusNodeAllOf
107113
*/
108114
pluginInstanceIds: Array<string>;
115+
/**
116+
*
117+
* @type {string}
118+
* @memberof CactusNodeAllOf
119+
*/
120+
token?: string;
109121
}
110122
/**
111123
* A Cactus node meta information

packages/cactus-plugin-consortium-manual/src/main/typescript/plugin-consortium-manual.ts

+14-2
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,20 @@ export class PluginConsortiumManual
218218
const nodes = this.repo.allNodes;
219219

220220
const requests = nodes
221-
.map((cnm) => cnm.nodeApiHost)
222-
.map((host) => new Configuration({ basePath: host }))
221+
.map((cnm) => [cnm.nodeApiHost, cnm.token])
222+
.map(function (nodeData) {
223+
// if node has token, add to the configuration
224+
if (nodeData[1]) {
225+
return new Configuration({
226+
basePath: nodeData[0],
227+
baseOptions: {
228+
headers: { Authorization: `Bearer ${nodeData[1]}` },
229+
},
230+
});
231+
} else {
232+
return new Configuration({ basePath: nodeData[0] });
233+
}
234+
})
223235
.map((configuration) => new DefaultApi(configuration))
224236
.map((apiClient) => apiClient.getNodeJwsV1());
225237

0 commit comments

Comments
 (0)