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

Add crypto utility function and use in BearerDid #430

Merged
merged 2 commits into from
Feb 27, 2024
Merged

Conversation

frankhinek
Copy link
Contributor

@frankhinek frankhinek commented Feb 23, 2024

This PR will:

  • Move a crypto utility function from within BearerDid to the @web5/crypto package.
  • Update BearerDid to use the utility function.
  • Update the docs for BearerDid to close Correct BearerDid documentation #418.

Note

The package versions for @web5/crypto and @web5/dids are not incremented in this PR as this change is rather minimal, has no immediate impact on external API consumers, and consequently, isn't worth publishing a new release.
A future PR will bump the versions and publish new releases as the utility function added to @web5/crypto is consumed in other packages in this monorepo (which is already the case for a branch that is still a WIP.

@frankhinek frankhinek added package: crypto @web5/crypto package package: dids @web5/dids package labels Feb 23, 2024
@frankhinek frankhinek self-assigned this Feb 23, 2024
Copy link
Contributor

github-actions bot commented Feb 23, 2024

TBDocs Report

🛑 Errors: 0
⚠️ Warnings: 118

@web5/api

  • Project entry file: packages/api/src/index.ts
📄 File: ./packages/api/src/protocol.ts
⚠️ extractor:typedoc:missing-reference: ProtocolMetadata is referenced by Protocol._metadata but not included in the documentation.
⚠️ extractor:typedoc:missing-docs: Protocol._agent (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: Protocol._metadata (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: Protocol._protocolsConfigureMessage (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: Protocol.send.__type.status (Property) does not have any documentation.
📄 File: ./packages/api/src/send-cache.ts
⚠️ extractor:typedoc:missing-reference: SendCache is referenced by Record._sendCache but not included in the documentation.
📄 File: ./packages/api/src/web5.ts
⚠️ extractor:typedoc:missing-reference: Web5Options is referenced by Web5.constructor.new Web5.options but not included in the documentation.
⚠️ extractor:typedoc:missing-docs: TechPreviewOptions.__type.dwnEndpoints (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: Web5ConnectOptions.__type.connectedDid (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: Web5.connect.__type.web5 (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: Web5.connect.__type.did (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: Web5.connectedDid (Property) does not have any documentation.
📄 File: ./packages/api/src/utils.ts
⚠️ extractor:typedoc:missing-docs: utils.dataToBlob.__type.dataBlob (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: utils.dataToBlob.__type.dataFormat (Property) does not have any documentation.
📄 File: ./packages/api/src/did-api.ts
⚠️ extractor:typedoc:missing-docs: DidApi.agent (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: DidApi.connectedDid (Property) does not have any documentation.
📄 File: ./packages/api/src/dwn-api.ts
⚠️ extractor:typedoc:missing-docs: ResponseStatus.__type.status (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: ResponseStatus.__type.status.__type.code (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: ResponseStatus.__type.status.__type.detail (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: ProtocolsConfigureRequest.__type.message (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: ProtocolsConfigureResponse.__type.protocol (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: ProtocolsQueryReplyEntry.__type.descriptor (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: ProtocolsQueryRequest.__type.from (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: ProtocolsQueryRequest.__type.message (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: ProtocolsQueryResponse.__type.protocols (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: RecordsCreateFromRequest.__type.author (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: RecordsCreateFromRequest.__type.data (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: RecordsCreateFromRequest.__type.message (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: RecordsCreateFromRequest.__type.record (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: RecordsDeleteRequest.__type.from (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: RecordsDeleteRequest.__type.message (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: RecordsQueryRequest.__type.message (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: RecordsQueryResponse.__type.records (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: RecordsReadRequest.__type.message (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: RecordsReadResponse.__type.record (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: RecordsWriteRequest.__type.data (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: RecordsWriteRequest.__type.message (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: RecordsWriteRequest.__type.store (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: RecordsWriteResponse.__type.record (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: DwnApi.agent (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: DwnApi.connectedDid (Property) does not have any documentation.
📄 File: ./packages/api/src/record.ts
⚠️ extractor:typedoc:missing-docs: RecordOptions.__type.author (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: RecordOptions.__type.connectedDid (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: RecordOptions.__type.encodedData (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: RecordOptions.__type.data (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: RecordOptions.__type.initialWrite (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: RecordOptions.__type.protocolRole (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: RecordOptions.__type.remoteOrigin (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: RecordModel.__type.author (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: RecordModel.__type.protocolRole (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: RecordModel.__type.recordId (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: RecordUpdateOptions.__type.data (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: RecordUpdateOptions.__type.dataCid (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: RecordUpdateOptions.__type.dataSize (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: RecordUpdateOptions.__type.dateModified (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: RecordUpdateOptions.__type.datePublished (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: RecordUpdateOptions.__type.published (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: RecordUpdateOptions.__type.protocolRole (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: Record._sendCache (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: Record._agent (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: Record._connectedDid (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: Record._encodedData (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: Record._readableStream (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: Record._remoteOrigin (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: Record._author (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: Record._attestation (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: Record._authorization (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: Record._contextId (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: Record._descriptor (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: Record._encryption (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: Record._initialWrite (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: Record._initialWriteStored (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: Record._initialWriteSigned (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: Record._recordId (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: Record._protocolRole (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: Record.data.__type.then (CallSignature) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: Record.data.__type.catch (CallSignature) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: Record.processRecord (CallSignature) does not have any documentation.
📄 File: ./packages/api/src/vc-api.ts
⚠️ extractor:typedoc:missing-docs: VcApi.agent (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: VcApi.connectedDid (Property) does not have any documentation.
🔀 Misc.
⚠️ extractor:typedoc:invalid-link: Failed to resolve link to "@web5/agent#Web5Agent" in comment for Web5ConnectOptions.__type.agent. You may have wanted "@web5/agent!Web5Agent"
⚠️ extractor:typedoc:invalid-link: Failed to resolve link to "@web5/user-agent#Web5UserAgent" in comment for Web5ConnectOptions.__type.agent. You may have wanted "@web5/user-agent!Web5UserAgent"
⚠️ extractor:typedoc:invalid-link: Failed to resolve link to "@web5/agent#AppDataStore" in comment for Web5ConnectOptions.__type.appData. You may have wanted "@web5/agent!AppDataStore"
⚠️ extractor:typedoc:invalid-link: Failed to resolve link to "@web5/agent#AppDataStore" in comment for Web5ConnectOptions.__type.appData. You may have wanted "@web5/agent!AppDataStore"
⚠️ extractor:typedoc:invalid-link: Failed to resolve link to "@web5/agent#Web5Agent" in comment for Web5.connect. You may have wanted "@web5/agent!Web5Agent"
⚠️ extractor:typedoc:invalid-link: Failed to resolve link to "@web5/user-agent#Web5UserAgent" in comment for Web5.connect. You may have wanted "@web5/user-agent!Web5UserAgent"

@web5/crypto

  • Project entry file: packages/crypto/src/index.ts

@web5/crypto-aws-kms

  • Project entry file: packages/crypto-aws-kms/src/index.ts
📄 File: ./packages/crypto-aws-kms/src/ecdsa.ts
⚠️ extractor:typedoc:missing-docs: EcdsaAlgorithm (Class) does not have any documentation.
📄 File: ./packages/crypto-aws-kms/src/key-manager.ts
⚠️ extractor:typedoc:missing-docs: AwsKeyManager (Class) does not have any documentation.
📄 File: ./packages/crypto-aws-kms/src/utils.ts
⚠️ extractor:typedoc:missing-docs: getKeySpec (CallSignature) does not have any documentation.
🔀 Misc.
⚠️ extractor:typedoc:invalid-link: Failed to resolve link to "@web5/crypto#Secp256k1.adjustSignatureToLowS | here" in comment for EcdsaAlgorithm.sign. You may have wanted "@web5/crypto!Secp256k1.adjustSignatureToLowS | here"

@web5/dids

  • Project entry file: packages/dids/src/index.ts

@web5/credentials

  • Project entry file: packages/credentials/src/index.ts
📄 File: ./packages/credentials/src/jwt.ts
⚠️ extractor:typedoc:missing-docs: JwtParseResult.__type.decoded (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: JwtParseResult.__type.encoded (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: JwtParseResult.__type.encoded.__type.header (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: JwtParseResult.__type.encoded.__type.payload (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: JwtParseResult.__type.encoded.__type.signature (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: ParseJwtOptions.__type.jwt (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: SignJwtOptions.__type.signerDid (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: SignJwtOptions.__type.payload (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: VerifyJwtOptions.__type.jwt (Property) does not have any documentation.
📄 File: ./packages/credentials/src/presentation-exchange.ts
⚠️ extractor:typedoc:missing-docs: PresentationDefinitionV2 (Interface) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: Validated (TypeAlias) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: PresentationExchange (Class) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: PresentationExchange.resetPex (CallSignature) does not have any documentation.
📄 File: ./packages/credentials/src/verifiable-credential.ts
⚠️ extractor:typedoc:missing-docs: DEFAULT_CONTEXT (Variable) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: DEFAULT_VC_TYPE (Variable) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: VerifiableCredentialCreateOptions.__type.type (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: VerifiableCredentialCreateOptions.__type.issuer (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: VerifiableCredentialCreateOptions.__type.subject (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: VerifiableCredentialCreateOptions.__type.data (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: VerifiableCredentialCreateOptions.__type.issuanceDate (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: VerifiableCredentialCreateOptions.__type.expirationDate (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: VerifiableCredentialSignOptions.__type.did (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: VerifiableCredential.verify.__type.issuer (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: VerifiableCredential.verify.__type.subject (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: VerifiableCredential.verify.__type.vc (Property) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: VerifiableCredential.type (GetSignature) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: VerifiableCredential.issuer (GetSignature) does not have any documentation.
⚠️ extractor:typedoc:missing-docs: VerifiableCredential.subject (GetSignature) does not have any documentation.

TBDocs Report Updated at 2024-02-27T01:11:17Z 0aa36d1

Copy link

codecov bot commented Feb 23, 2024

Codecov Report

Merging #430 (b4fa4ec) into main (2b90468) will increase coverage by 0.00%.
Report is 1 commits behind head on main.
The diff coverage is 100.00%.

❗ Current head b4fa4ec differs from pull request most recent head 0aa36d1. Consider uploading reports for the commit 0aa36d1 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #430   +/-   ##
=======================================
  Coverage   93.34%   93.35%           
=======================================
  Files          80       80           
  Lines       23804    23827   +23     
  Branches     1890     1891    +1     
=======================================
+ Hits        22220    22243   +23     
  Misses       1544     1544           
  Partials       40       40           
Components Coverage Δ
agent 88.72% <ø> (ø)
api 97.30% <ø> (ø)
common 98.68% <ø> (ø)
credentials 94.77% <ø> (ø)
crypto 93.80% <100.00%> (+0.04%) ⬆️
dids 97.51% <100.00%> (-0.02%) ⬇️
identity-agent 56.81% <ø> (ø)
crypto-aws-kms 100.00% <ø> (ø)
proxy-agent 58.43% <ø> (ø)
user-agent 55.22% <ø> (ø)

return curveToJoseAlgorithm[publicKey.crv];
}

throw new Error(`Unable to determine algorithm based on provided input: alg=${publicKey.alg}, crv=${publicKey.crv}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should include the curves we support here and/or in the docs?

Copy link
Contributor Author

@frankhinek frankhinek Feb 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @KendallWeihe. Added the list of supported algorithm identifiers and curve names to the error in 0aa36d1.

Copy link
Contributor

@KendallWeihe KendallWeihe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems right to me 👍

@KendallWeihe
Copy link
Contributor

Only nitpicky feedback item, so take it or leave it, would've been to do this one #418 is a separate PR. Reasoning being, it's a disparate matter to the other two items in this PR so caused a slight disruption when reviewing, but also it may just be because of my naivete to this code base.


// If the key contains an `alg` property that matches a JOSE registered algorithm identifier,
// return its value.
if (publicKey.alg && Object.values(curveToJoseAlgorithm).includes(publicKey.alg)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit clarification: Previously, we didn't check that the alg is in curveToJoseAlgorithm values. This seems correct to me, but also took me a second to notice while reviewing. Did we previously want to return "unsupported" algorithms or was that just an oversight that we're not correcting?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may be missing the question. Unsupported algorithms won't be returned and an error will be thrown.

Copy link

@diehuxx diehuxx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seems pretty innocuous since we're just moving the location of existing functionality. I added a question, but feel free to merge as-is.

Signed-off-by: Frank Hinek <[email protected]>
@frankhinek frankhinek merged commit 11d5cc0 into main Feb 27, 2024
12 checks passed
@frankhinek frankhinek deleted the crypto-jose-alg branch February 27, 2024 01:12
finn-block pushed a commit that referenced this pull request Mar 19, 2024
* Add crypto utility function and use in BearerDid
* Improve error message

---------

Signed-off-by: Frank Hinek <[email protected]>
finn-block pushed a commit that referenced this pull request Mar 19, 2024
* Add crypto utility function and use in BearerDid
* Improve error message

---------

Signed-off-by: Frank Hinek <[email protected]>
finn-block pushed a commit that referenced this pull request Mar 19, 2024
* Add crypto utility function and use in BearerDid
* Improve error message

---------

Signed-off-by: Frank Hinek <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: crypto @web5/crypto package package: dids @web5/dids package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Correct BearerDid documentation
4 participants