@adobe/fetch
Advanced tools
Comparing version 0.1.6 to 0.1.7
@@ -42,6 +42,12 @@ /* | ||
function addAuthHeaders(token, options, authOptions) { | ||
let apiKey = authOptions.clientId; | ||
if (options.headers && options.headers['x-api-key']) { | ||
apiKey = options.headers['x-api-key']; | ||
} | ||
return merge(options, { | ||
headers: { | ||
authorization: `${token.token_type} ${token.access_token}`, | ||
'x-api-key': authOptions.clientId, | ||
'x-api-key': apiKey, | ||
'x-gw-ims-org-id': authOptions.orgId | ||
@@ -48,0 +54,0 @@ } |
{ | ||
"name": "@adobe/fetch", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "Call Adobe APIs", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -26,3 +26,3 @@ /* eslint-disable require-atomic-updates */ | ||
if (!cache.disableStorage) { | ||
cache.tokens = await cache.read() || {}; | ||
cache.tokens = (await cache.read()) || {}; | ||
cache.readOnce = true; | ||
@@ -29,0 +29,0 @@ } |
@@ -141,2 +141,18 @@ /* | ||
test('allows x-api-key override', async () => { | ||
expect.assertions(4); | ||
fetch.mockImplementation((url, options) => { | ||
expect(options.headers).toBeDefined(); | ||
expect(options.headers['authorization']).toBe( | ||
`${mockData.token2.token_type} ${mockData.token.access_token}` | ||
); | ||
expect(options.headers['x-api-key']).toBe('test-override'); | ||
expect(options.headers['x-gw-ims-org-id']).toBe(mockData.config.orgId); | ||
return Promise.resolve({ status: 200, url: url }); | ||
}); | ||
await testFetch(mockData.url, { | ||
headers: { 'x-api-key': 'test-override' } | ||
}); | ||
}); | ||
test('token stored in default storage', async () => { | ||
@@ -143,0 +159,0 @@ expect.assertions(6); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
94406
20858
834
14