Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export async function signCapabilityInvocation({
capabilityAction,
invocationSigner,
created = Math.floor(Date.now() / 1000),
authzHeaderName = 'authorization',
expires
}) {
try {
Expand All @@ -75,6 +76,9 @@ export async function signCapabilityInvocation({
'"capability" must be a string to invoke a root capability or an ' +
'object to invoke a delegated capability.');
}
if(!(authzHeaderName && typeof authzHeaderName === 'string')) {
throw new TypeError('"authzHeaderName" must be a string.');
}

// if capability is a root zcap, use just its ID
if(typeof capability === 'object' && !capability.parentCapability) {
Expand Down Expand Up @@ -135,7 +139,7 @@ export async function signCapabilityInvocation({
const data = new TextEncoder().encode(plaintext);
const signature = base64Encode(await invocationSigner.sign({data}));

signed.authorization = createAuthzHeader({
signed[authzHeaderName.toLowerCase()] = createAuthzHeader({
includeHeaders,
keyId,
signature,
Expand Down