Skip to content

Commit

Permalink
fix: use nullish coalescing for audience (#319)
Browse files Browse the repository at this point in the history
When explicitly passing `null` a default value is not set.
  • Loading branch information
Alan Shaw authored Jan 25, 2023
1 parent 7aae233 commit 7e90085
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
15 changes: 9 additions & 6 deletions packages/upload-client/src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { REQUEST_RETRIES } from './constants.js'
* @returns {Promise<import('./types').CARLink>}
*/
export async function add(
{ issuer, with: resource, proofs, audience = servicePrincipal },
{ issuer, with: resource, proofs, audience },
car,
options = {}
) {
Expand All @@ -42,7 +42,8 @@ export async function add(
return await StoreCapabilities.add
.invoke({
issuer,
audience,
/* c8 ignore next */
audience: audience ?? servicePrincipal,
with: resource,
nb: { link, size: car.size },
proofs,
Expand Down Expand Up @@ -120,15 +121,16 @@ export async function add(
* @returns {Promise<import('./types').ListResponse<import('./types').StoreListResult>>}
*/
export async function list(
{ issuer, with: resource, proofs, audience = servicePrincipal },
{ issuer, with: resource, proofs, audience },
options = {}
) {
/* c8 ignore next */
const conn = options.connection ?? connection
const result = await StoreCapabilities.list
.invoke({
issuer,
audience,
/* c8 ignore next */
audience: audience ?? servicePrincipal,
with: resource,
proofs,
nb: {
Expand Down Expand Up @@ -167,7 +169,7 @@ export async function list(
* @param {import('./types').RequestOptions} [options]
*/
export async function remove(
{ issuer, with: resource, proofs, audience = servicePrincipal },
{ issuer, with: resource, proofs, audience },
link,
options = {}
) {
Expand All @@ -176,7 +178,8 @@ export async function remove(
const result = await StoreCapabilities.remove
.invoke({
issuer,
audience,
/* c8 ignore next */
audience: audience ?? servicePrincipal,
with: resource,
nb: { link },
proofs,
Expand Down
15 changes: 9 additions & 6 deletions packages/upload-client/src/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { REQUEST_RETRIES } from './constants.js'
* @returns {Promise<import('./types').UploadAddResponse>}
*/
export async function add(
{ issuer, with: resource, proofs, audience = servicePrincipal },
{ issuer, with: resource, proofs, audience },
root,
shards,
options = {}
Expand All @@ -40,7 +40,8 @@ export async function add(
return await UploadCapabilities.add
.invoke({
issuer,
audience,
/* c8 ignore next */
audience: audience ?? servicePrincipal,
with: resource,
nb: { root, shards },
proofs,
Expand Down Expand Up @@ -82,7 +83,7 @@ export async function add(
* @returns {Promise<import('./types').ListResponse<import('./types').UploadListResult>>}
*/
export async function list(
{ issuer, with: resource, proofs, audience = servicePrincipal },
{ issuer, with: resource, proofs, audience },
options = {}
) {
/* c8 ignore next */
Expand All @@ -91,7 +92,8 @@ export async function list(
const result = await UploadCapabilities.list
.invoke({
issuer,
audience,
/* c8 ignore next */
audience: audience ?? servicePrincipal,
with: resource,
proofs,
nb: {
Expand Down Expand Up @@ -130,7 +132,7 @@ export async function list(
* @param {import('./types').RequestOptions} [options]
*/
export async function remove(
{ issuer, with: resource, proofs, audience = servicePrincipal },
{ issuer, with: resource, proofs, audience },
root,
options = {}
) {
Expand All @@ -139,7 +141,8 @@ export async function remove(
const result = await UploadCapabilities.remove
.invoke({
issuer,
audience,
/* c8 ignore next */
audience: audience ?? servicePrincipal,
with: resource,
nb: { root },
proofs,
Expand Down

0 comments on commit 7e90085

Please sign in to comment.