Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attachInvocationProof takes both a key and a signer #70

Open
aljones15 opened this issue Jul 16, 2021 · 0 comments
Open

attachInvocationProof takes both a key and a signer #70

aljones15 opened this issue Jul 16, 2021 · 0 comments

Comments

@aljones15
Copy link
Contributor

aljones15 commented Jul 16, 2021

/**
* Adds a zcap-style invocation proof to an operation.
*
* @param {object} operation - WebLedger operation.
*
* @param {object} options - Options hashmap.
* @param {string} capability - Capability (DID) url.
* @param {string} capabilityAction - 'create' / 'update'.
*
* Either a key pair instance or a signer object (from a KMS) is required:
* @param {LDKeyPair} [options.key] - A capabilityInvocation
* public/private key pair instance.
* @param {{sign: Function, id: string}} [options.signer] - A signer-type object
* such as that provided by a KMS.
*
* @returns {Promise<object>}
*/
async function attachInvocationProof(operation, {
capability, capabilityAction, key, signer
} = {}) {
return jsigs.sign(operation, {
documentLoader,
suite: new Ed25519Signature2020({key, signer}),
purpose: new CapabilityInvocation({capability, capabilityAction})
});
}

Questions:

  1. Why do we need both a signer and a key?
  2. Can we just pass in one of them?

Answer:

  1. I believe we accommodate passing in either a key or signer. We might want to make sure you're only passing in one with a warning.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant