Skip to content

Conversation

@B4nan
Copy link
Member

@B4nan B4nan commented Aug 9, 2023

Allows hashing of an Actor input together with some metadata into a shareable link for the "Run on Apify" button. Uses a common secret for checking the signatures.

The hash consists of 3 parts separated by a dot, as in ABC.DEF.GHI, each being a base64url encoded string:

  • meta object with the version and user properties.
  • data object (the one that gets encoded)
  • signature used for verification of the URL hash, computed from the meta and data objects
const manager = new CodeHashManager(secret);
const hash = manager.encode(input, '123'); // '123' is a user id

console.log(hash);

const { data, meta } = manager.decode(hash);

expect(input).toEqual(data);
expect(meta).toEqual({
    version: 1,
    user: '123',
    validSignature: true,
});

Closes #400

@B4nan B4nan marked this pull request as draft August 9, 2023 15:19
@B4nan B4nan force-pushed the input-encoding-v2 branch from e6b96ad to 6656e9c Compare August 9, 2023 17:01
@B4nan B4nan requested a review from valekjo August 9, 2023 17:02
@B4nan B4nan force-pushed the input-encoding-v2 branch from 6656e9c to 5c31cd3 Compare August 9, 2023 17:04
@B4nan B4nan marked this pull request as ready for review August 9, 2023 17:30
Copy link
Member

@valekjo valekjo left a comment

Choose a reason for hiding this comment

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

Nice, thanks.

@B4nan B4nan merged commit 14990f7 into master Aug 10, 2023
@B4nan B4nan deleted the input-encoding-v2 branch August 10, 2023 14:37
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

Successfully merging this pull request may close these issues.

Support signing/verifying in encodeInput and decodeInput (for run on apify button)

2 participants