use PDA identity across downstream loading checks
This commit is contained in:
@@ -37,7 +37,7 @@ async function ensureCompletionEvidence(context, chain, label) {
|
|||||||
const form = new FormData()
|
const form = new FormData()
|
||||||
form.append('file', new Blob([png], { type: 'image/png' }), `${label}-${evidenceType}.png`)
|
form.append('file', new Blob([png], { type: 'image/png' }), `${label}-${evidenceType}.png`)
|
||||||
const rawUpload = await fetch(`${context.options.gateway}${uploadPath}`, {
|
const rawUpload = await fetch(`${context.options.gateway}${uploadPath}`, {
|
||||||
method: 'POST', headers: { Accept: 'application/json', Authorization: `Bearer ${context.token}`,
|
method: 'POST', headers: { Accept: 'application/json', Authorization: `Bearer ${context.pdaToken || context.token}`,
|
||||||
'Idempotency-Key': operationId(context, `${label}-evidence-${evidenceType}`) },
|
'Idempotency-Key': operationId(context, `${label}-evidence-${evidenceType}`) },
|
||||||
body: form, signal: AbortSignal.timeout(60_000),
|
body: form, signal: AbortSignal.timeout(60_000),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ async function request(context, method, path, body, headers = {}) {
|
|||||||
try {
|
try {
|
||||||
const response = await fetch(`${context.options.gateway}${path}`, {
|
const response = await fetch(`${context.options.gateway}${path}`, {
|
||||||
method,
|
method,
|
||||||
headers: { Accept: 'application/json', Authorization: `Bearer ${context.token}`,
|
headers: { Accept: 'application/json', Authorization: `Bearer ${context.pdaToken && /\/pda-loading\/tasks\/\d+/.test(path) ? context.pdaToken : context.token}`,
|
||||||
...(body === undefined ? {} : { 'Content-Type': 'application/json; charset=utf-8' }), ...headers },
|
...(body === undefined ? {} : { 'Content-Type': 'application/json; charset=utf-8' }), ...headers },
|
||||||
body: body === undefined ? undefined : JSON.stringify(body), signal: AbortSignal.timeout(60_000),
|
body: body === undefined ? undefined : JSON.stringify(body), signal: AbortSignal.timeout(60_000),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -45,13 +45,13 @@ function sameBookingTransport(left, right) {
|
|||||||
return BOOKING_TRANSPORT_FIELDS.every((field) => left?.[field] === right?.[field])
|
return BOOKING_TRANSPORT_FIELDS.every((field) => left?.[field] === right?.[field])
|
||||||
}
|
}
|
||||||
|
|
||||||
async function request(context, method, path, body, headers = {}, token = context.token) {
|
async function request(context, method, path, body, headers = {}, token = undefined) {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${context.options.gateway}${path}`, {
|
const response = await fetch(`${context.options.gateway}${path}`, {
|
||||||
method,
|
method,
|
||||||
headers: {
|
headers: {
|
||||||
Accept: 'application/json',
|
Accept: 'application/json',
|
||||||
...(token ? { Authorization: `Bearer ${token}` } : {}),
|
...((token || (context.pdaToken && /\/pda-loading\/tasks\/\d+/.test(path) ? context.pdaToken : context.token)) ? { Authorization: `Bearer ${token || (context.pdaToken && /\/pda-loading\/tasks\/\d+/.test(path) ? context.pdaToken : context.token)}` } : {}),
|
||||||
...(body === undefined ? {} : { 'Content-Type': 'application/json; charset=utf-8' }),
|
...(body === undefined ? {} : { 'Content-Type': 'application/json; charset=utf-8' }),
|
||||||
...headers,
|
...headers,
|
||||||
},
|
},
|
||||||
@@ -81,7 +81,7 @@ async function ensureCompletionEvidence(context, taskId, warehouseId, keyBase) {
|
|||||||
const form = new FormData()
|
const form = new FormData()
|
||||||
form.append('file', new Blob([png], { type: 'image/png' }), `${keyBase}-${evidenceType}.png`)
|
form.append('file', new Blob([png], { type: 'image/png' }), `${keyBase}-${evidenceType}.png`)
|
||||||
const rawUpload = await fetch(`${context.options.gateway}${uploadPath}`, {
|
const rawUpload = await fetch(`${context.options.gateway}${uploadPath}`, {
|
||||||
method: 'POST', headers: { Accept: 'application/json', Authorization: `Bearer ${context.token}`,
|
method: 'POST', headers: { Accept: 'application/json', Authorization: `Bearer ${context.pdaToken || context.token}`,
|
||||||
'Idempotency-Key': `${keyBase}-evidence-${evidenceType}`.slice(0, 128) },
|
'Idempotency-Key': `${keyBase}-evidence-${evidenceType}`.slice(0, 128) },
|
||||||
body: form, signal: AbortSignal.timeout(60_000),
|
body: form, signal: AbortSignal.timeout(60_000),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export function buildPendingActions(task) {
|
|||||||
async function request(context, method, path, body, headers = {}) {
|
async function request(context, method, path, body, headers = {}) {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${context.options.gateway}${path}`, { method,
|
const response = await fetch(`${context.options.gateway}${path}`, { method,
|
||||||
headers: { Accept: 'application/json', Authorization: `Bearer ${context.token}`,
|
headers: { Accept: 'application/json', Authorization: `Bearer ${context.pdaToken && /\/pda-loading\/tasks\/\d+/.test(path) ? context.pdaToken : context.token}`,
|
||||||
...(body === undefined ? {} : { 'Content-Type': 'application/json; charset=utf-8' }), ...headers },
|
...(body === undefined ? {} : { 'Content-Type': 'application/json; charset=utf-8' }), ...headers },
|
||||||
body: body === undefined ? undefined : JSON.stringify(body), signal: AbortSignal.timeout(60_000) })
|
body: body === undefined ? undefined : JSON.stringify(body), signal: AbortSignal.timeout(60_000) })
|
||||||
const raw = await response.text(); let payload = null
|
const raw = await response.text(); let payload = null
|
||||||
|
|||||||
Reference in New Issue
Block a user