Skip to content

Commit

Permalink
v0.5.14
Browse files Browse the repository at this point in the history
  • Loading branch information
rjrodger committed Dec 15, 2023
1 parent e7cfd77 commit 550bf21
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 26 deletions.
40 changes: 28 additions & 12 deletions dist/bud-provider.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/bud-provider.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@seneca/bud-provider",
"version": "0.5.13",
"version": "0.5.14",
"main": "dist/bud-provider.js",
"type": "commonjs",
"types": "dist/bud-provider.d.ts",
Expand Down
46 changes: 34 additions & 12 deletions src/bud-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,27 @@ function BudProvider(this: any, options: FullBudProviderOptions) {
}))


const CustomerHeadersShape = Gubu({
'X-Customer-Id': String,
'X-Customer-Secret': String,
})

const CustomerHeadersIDOnlyShape = Gubu({
'X-Customer-Id': String,
})

const CustomerHeadersGatewayShape = Gubu({
'X-Client-Id': String,
'X-Customer-Id': String,
'X-Customer-Secret': String,
})

const SharedHeadersShape = Gubu({
'X-Client-Id': String,
Authorization: String,
})


// Shared config reference.
const config: any = {
headers: {}
Expand Down Expand Up @@ -195,9 +216,9 @@ function BudProvider(this: any, options: FullBudProviderOptions) {
let customerid = q.customerid

try {
let headers = {
let headers = CustomerHeadersIDOnlyShape({
'X-Customer-Id': customerid
}
})

let json = await get(makeUrl('v1/open-banking/connect', id), {
headers
Expand Down Expand Up @@ -229,10 +250,10 @@ function BudProvider(this: any, options: FullBudProviderOptions) {
let customersecret = q.customersecret

try {
let headers = {
let headers = CustomerHeadersShape({
'X-Customer-Id': customerid,
'X-Customer-Secret': customersecret,
}
})

await waitForRefreshToken('account.cmd.load')

Expand Down Expand Up @@ -268,10 +289,10 @@ function BudProvider(this: any, options: FullBudProviderOptions) {
delete q.customersecret

try {
let headers = {
let headers = CustomerHeadersShape({
'X-Customer-Id': customerid,
'X-Customer-Secret': customersecret,
}
})

await waitForRefreshToken('account.cmd.list')

Expand Down Expand Up @@ -312,10 +333,10 @@ function BudProvider(this: any, options: FullBudProviderOptions) {
delete q.customersecret

try {
let headers = {
let headers = CustomerHeadersShape({
'X-Customer-Id': customerid,
'X-Customer-Secret': customersecret,
}
})

let listdata: any[] = []
let paging = true
Expand Down Expand Up @@ -405,11 +426,12 @@ function BudProvider(this: any, options: FullBudProviderOptions) {
customerid: string
customersecret: string
}) {
let headers = {
let headers = CustomerHeadersGatewayShape({
'X-Client-Id': spec.clientid,
'X-Customer-Id': spec.customerid,
'X-Customer-Secret': spec.customersecret
}
})

let body = {
redirect_url: spec.redirect_url
}
Expand Down Expand Up @@ -583,10 +605,10 @@ function BudProvider(this: any, options: FullBudProviderOptions) {

// console.log('BASIC', basic, auth)

this.shared.headers = {
this.shared.headers = SharedHeadersShape({
'X-Client-Id': clientid,
Authorization: 'Basic ' + auth
}
})

})

Expand Down

0 comments on commit 550bf21

Please sign in to comment.