Skip to content

Commit

Permalink
feat: update bruno collection
Browse files Browse the repository at this point in the history
  • Loading branch information
njlie committed Apr 16, 2024
1 parent 5474689 commit db0ea0b
Show file tree
Hide file tree
Showing 46 changed files with 242 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ post {
auth: none
}

headers {
Authorization: Bearer {{AdminApiToken}}
}

body:graphql {
mutation CreateReceiver($input: CreateReceiverInput!) {
createReceiver(input: $input) {
Expand Down Expand Up @@ -70,12 +66,13 @@ script:pre-request {

const body = req.getBody();

console.log(body);
//console.log(body);

const timestamp = Math.round(new Date().getTime() / 1000);
const version = bru.getEnvVar('apiSignatureVersion');
const payload = `${timestamp}.${canonicalize(body)}`;
const hmac = createHmac('sha256', bru.getEnvVar('apiSignatureSecret'));
const secret = bru.getEnvVar('apiSignatureSecret')
const hmac = createHmac('sha256', secret)
hmac.update(payload)
const digest = hmac.digest('hex')

Expand Down
26 changes: 3 additions & 23 deletions bruno/collections/Rafiki/Rafiki Admin APIs/Create Asset.bru
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ body:graphql {
body:graphql:vars {
{
"input": {
"code": "USD",
"code": "JPY",
"scale": 6,
"withdrawalThreshold": null,
"liquidityThreshold": "100000000"
Expand All @@ -40,29 +40,9 @@ body:graphql:vars {
}

script:pre-request {
const { createHmac } = require('crypto');
const { canonicalize } = require('json-canonicalize');
const { print } = require('graphql/language/printer')
const scripts = require('./scripts');

const body = req.getBody();
const { query, variables, operationName } = body;

//console.log(body);

const formattedBody = {
variables,
query: print(query),
operationName
};

const timestamp = Math.round(new Date().getTime() / 1000);
const version = bru.getEnvVar('apiSignatureVersion');
const payload = `${timestamp}.${canonicalize(formattedBody)}`;
const hmac = createHmac('sha256', bru.getEnvVar('apiSignatureSecret'));
hmac.update(payload)
const digest = hmac.digest('hex')

req.setHeader('signature', `t=${timestamp}, v${version}=${digest}`)
scripts.addApiSignatureHeader();
}

script:post-response {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ body:graphql:vars {
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}

script:post-response {
const body = res.getBody();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ body:graphql:vars {
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}

script:post-response {
const body = res.getBody();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ body:graphql:vars {
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}

script:post-response {
const body = res.getBody();

Expand Down
6 changes: 6 additions & 0 deletions bruno/collections/Rafiki/Rafiki Admin APIs/Create Peer.bru
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ body:graphql:vars {
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}

script:post-response {
const body = res.getBody();

Expand Down
5 changes: 4 additions & 1 deletion bruno/collections/Rafiki/Rafiki Admin APIs/Create Quote.bru
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ body:graphql:vars {
script:pre-request {
// Create an additional wallet address to represent the account that will be sending money

const fetch = require('node-fetch')
const fetch = require('node-fetch');
const scripts = require('./scripts');

const randomInt = Math.floor(Math.random() * (1001));

Expand All @@ -82,6 +83,8 @@ script:pre-request {
const response = await fetch(`${initialRequest.url}`, postRequest);
const body = await response.json();
bru.setEnvVar("secondWalletAddressId", body.data.createWalletAddress.walletAddress.id);

scripts.addApiSignatureHeader();
}

script:post-response {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ body:graphql:vars {
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}

script:post-response {
const body = res.getBody();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ body:graphql:vars {
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}

script:post-response {
const body = res.getBody();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,9 @@ body:graphql:vars {
}
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ body:graphql:vars {

script:pre-request {
const { nanoid } = require("nanoid");
const scripts = require('./scripts');

bru.setVar('randomId', nanoid());

scripts.addApiSignatureHeader();
}

script:post-response {
Expand Down
6 changes: 6 additions & 0 deletions bruno/collections/Rafiki/Rafiki Admin APIs/Delete Peer.bru
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,9 @@ body:graphql:vars {
}
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ body:graphql:vars {

script:pre-request {
const { v4: uuidv4 } = require('uuid');
const scripts = require('./scripts');

bru.setVar("transferId",uuidv4());
bru.setVar("idempotencyKey",uuidv4());

scripts.addApiSignatureHeader();
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,9 @@ body:graphql:vars {
}
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ body:graphql:vars {

script:pre-request {
const { v4: uuidv4 } = require('uuid');
const scripts = require('./scripts');

bru.setVar("idempotencyKey",uuidv4());

scripts.addApiSignatureHeader();
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ body:graphql:vars {

script:pre-request {
const { v4: uuidv4 } = require('uuid');
const scripts = require('./scripts');

bru.setVar("transferId",uuidv4());
bru.setVar("idempotencyKey",uuidv4());

scripts.addApiSignatureHeader();
}
6 changes: 6 additions & 0 deletions bruno/collections/Rafiki/Rafiki Admin APIs/Get Asset.bru
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,9 @@ body:graphql:vars {
"id": "{{assetId}}"
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}
6 changes: 6 additions & 0 deletions bruno/collections/Rafiki/Rafiki Admin APIs/Get Assets.bru
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ body:graphql:vars {
"last": null
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,9 @@ body:graphql:vars {
"id": "{{incomingPaymentId}}"
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,9 @@ body:graphql:vars {
"id": "{{outgoingPaymentId}}"
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}
6 changes: 6 additions & 0 deletions bruno/collections/Rafiki/Rafiki Admin APIs/Get Payments.bru
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,9 @@ body:graphql:vars {
}
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}
6 changes: 6 additions & 0 deletions bruno/collections/Rafiki/Rafiki Admin APIs/Get Peer.bru
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@ body:graphql {
}
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}
6 changes: 6 additions & 0 deletions bruno/collections/Rafiki/Rafiki Admin APIs/Get Peers.bru
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,9 @@ body:graphql {
}
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}
6 changes: 6 additions & 0 deletions bruno/collections/Rafiki/Rafiki Admin APIs/Get Quote.bru
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,9 @@ body:graphql:vars {
"id": "{{quoteId}}"
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,9 @@ body:graphql:vars {
"id": "{{receiverId}}"
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,9 @@ body:graphql:vars {
"id": "{{walletAddressId}}"
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ body:graphql {
}
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,9 @@ body:graphql:vars {
"last": null
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ body:graphql:vars {

script:pre-request {
const { v4: uuidv4 } = require('uuid');
const scripts = require('./scripts');

bru.setVar("idempotencyKey",uuidv4());

scripts.addApiSignatureHeader();
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,9 @@ body:graphql:vars {
}
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}
6 changes: 6 additions & 0 deletions bruno/collections/Rafiki/Rafiki Admin APIs/Set Fee.bru
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ body:graphql:vars {
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}

tests {
//
}
Loading

0 comments on commit db0ea0b

Please sign in to comment.