Skip to content

feat: [EXT-2244] create signature#11

Merged
Manuel Spagnolo (shikaan) merged 28 commits intomasterfrom
feat/create-signature
Nov 2, 2020
Merged

feat: [EXT-2244] create signature#11
Manuel Spagnolo (shikaan) merged 28 commits intomasterfrom
feat/create-signature

Conversation

@shikaan
Copy link
Copy Markdown
Contributor

@shikaan Manuel Spagnolo (shikaan) commented Oct 26, 2020

Context

This method allows creating a hash of a Canonical Request (as in, an object representing only what concerns business logic), based on a secret and a timestamp.

In the inline documentation there's an example of how the method is expected to be used in a real world scenario, which should exemplify what are the secret and the timestamp for.


Edit

Given the confusion created by handling verification in another PR, I have done everything in here. Also added documentation for that (slightly less verbose than the one for create-signature because some ideas were overlapping).

Comment thread src/requests/create-signature.ts Outdated
Comment thread src/index.ts Outdated
Comment thread src/requests/typings.ts
Comment thread src/requests/typings.ts Outdated
Comment thread src/requests/create-signature.ts Outdated
Comment thread src/requests/create-signature.ts Outdated
Comment thread src/requests/utils.ts Outdated
Comment thread src/requests/create-signature.ts Outdated
Comment thread src/requests/typings.ts Outdated
Comment thread src/requests/is-verified-request.spec.ts Outdated
Comment thread src/requests/create-signature.ts Outdated
Comment thread src/requests/is-verified-request.ts Outdated
Comment thread src/requests/utils.ts Outdated
Comment thread src/requests/create-signature.ts Outdated
Comment thread src/requests/create-signature.ts Outdated
Comment thread src/requests/is-verified-request.ts Outdated
Comment thread src/requests/is-verified-request.ts Outdated
Comment thread src/requests/typings.ts
Comment thread src/requests/constants.ts Outdated
Comment thread src/requests/create-signature.ts Outdated
Comment thread src/requests/create-signature.ts Outdated
Comment thread src/requests/create-signature.ts Outdated
Comment thread src/requests/create-signature.ts Outdated
Comment thread src/requests/create-signature.ts Outdated
Comment thread src/requests/create-signature.ts Outdated
Comment thread src/requests/is-verified-request.ts Outdated
Comment thread src/requests/utils.ts
export const sortHeaderKeys = (keyA: string, keyB: string) => (keyA > keyB ? 1 : -1)

const normalizeHeaderKey = (key: string) => key.toLowerCase().trim()
const normalizeHeaderValue = (value: string) => value.trim()
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed the URI encoding because unnecessary according to the specification.

Plus, it's unstable (as in, you cannot compose encodings) which defeats the purpose of normalization.

Copy link
Copy Markdown

@jelz Jakub (jelz) left a comment

Choose a reason for hiding this comment

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

Really solid 👍

@shikaan Manuel Spagnolo (shikaan) merged commit 970df31 into master Nov 2, 2020
@shikaan Manuel Spagnolo (shikaan) deleted the feat/create-signature branch November 2, 2020 16:10
@ghost
Copy link
Copy Markdown

🎉 This PR is included in version 1.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@ghost ghost added the released label Nov 2, 2020
Comment thread src/requests/sign-request.ts
Comment thread src/requests/sign-request.ts
Comment thread src/requests/sign-request.ts
Comment thread src/requests/sign-request.ts
Comment thread src/requests/utils.ts
* Pass `rawTimeToLive = 0` to disable TTL checks.
*
* ~~~
* const {isVerifiedRequest} = require('contentful-node-apps-toolkit')

Choose a reason for hiding this comment

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

Should be verifyRequest

Comment thread src/requests/verify-request.ts
Comment thread src/requests/sign-request.ts
@hwartig Harald Wartig (hwartig) changed the title feat: create signature feat: [EXT-2244] create signature Nov 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants