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

feat(commons): add fromBase64 helper function #2190

Merged
merged 3 commits into from
Mar 11, 2024
Merged

Conversation

dreamorosi
Copy link
Contributor

@dreamorosi dreamorosi commented Mar 8, 2024

Description of your changes

This PR introduces a new helper function in the common package dedicated to decoding a base64 encoded string to a byte array.

I am adding the utility here because it will be used by both the upcoming JMESPath utility as well as the existing Parameters one.

The helper function is exposed via subpath and dedicated export, so in most cases it will be tree shaken at bundle time when not used.

import { fromBase64 } from '@aws-lambda-powertools/commons/utils/base64';

const encodedValue = 'aGVsbG8gd29ybGQ=';

const decoded = fromBase64(encodedValue);
// new Uint8Array([ 97, 71, 86, 115, 98, 71, 56, 103, 100, 50, 57, 121, 98, 71, 81, 61 ]);

Related issues, RFCs

Issue number: #2188

Checklist

  • My changes meet the tenets criteria
  • I have performed a self-review of my own code
  • I have commented my code where necessary, particularly in areas that should be flagged with a TODO, or hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my change is effective and works
  • The PR title follows the conventional commit semantics

Breaking change checklist

Is it a breaking change?: NO

  • I have documented the migration process
  • I have added, implemented necessary warnings (if it can live side by side)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@dreamorosi dreamorosi self-assigned this Mar 8, 2024
@dreamorosi dreamorosi requested review from a team as code owners March 8, 2024 17:28
@boring-cyborg boring-cyborg bot added commons This item relates to the Commons Utility dependencies Changes that touch dependencies, e.g. Dependabot, etc. tests PRs that add or change tests labels Mar 8, 2024
@pull-request-size pull-request-size bot added the size/L PRs between 100-499 LOC label Mar 8, 2024
@dreamorosi dreamorosi linked an issue Mar 8, 2024 that may be closed by this pull request
2 tasks
@github-actions github-actions bot added the feature PRs that introduce new features or minor changes label Mar 8, 2024
@dreamorosi dreamorosi removed dependencies Changes that touch dependencies, e.g. Dependabot, etc. tests PRs that add or change tests labels Mar 8, 2024
Copy link
Contributor

@am29d am29d left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, I have only a minor question about the export path.

packages/commons/package.json Show resolved Hide resolved
@dreamorosi dreamorosi requested a review from am29d March 11, 2024 15:03
@boring-cyborg boring-cyborg bot added dependencies Changes that touch dependencies, e.g. Dependabot, etc. tests PRs that add or change tests labels Mar 11, 2024
Copy link

sonarcloud bot commented Mar 11, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@dreamorosi dreamorosi merged commit 133159b into main Mar 11, 2024
15 checks passed
@dreamorosi dreamorosi deleted the feat/commons/fromBase64 branch March 11, 2024 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commons This item relates to the Commons Utility dependencies Changes that touch dependencies, e.g. Dependabot, etc. feature PRs that introduce new features or minor changes size/L PRs between 100-499 LOC tests PRs that add or change tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: add helper function to decode base64 encoded strings
2 participants