Skip to content

Commit 0fdabf4

Browse files
chore(parameters): replace base64 library to alternative (#2247)
* chore(deps): replace deprecated lib to alternative * chore: use `@aws-lambda-powertools/commons/utils/base64` * fix: using second parameter of fromBase64() --------- Co-authored-by: Andrea Amorosi <dreamorosi@gmail.com>
1 parent e04f3cd commit 0fdabf4

File tree

8 files changed

+11
-49
lines changed

8 files changed

+11
-49
lines changed

package-lock.json

Lines changed: 2 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/idempotency/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@
101101
},
102102
"dependencies": {
103103
"@aws-lambda-powertools/commons": "^2.0.3",
104-
"@aws-sdk/util-base64-node": "^3.209.0",
105104
"jmespath": "^0.16.0"
106105
},
107106
"peerDependencies": {

packages/parameters/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,12 @@
163163
"@aws-sdk/client-secrets-manager": "^3.535.0",
164164
"@aws-sdk/client-ssm": "^3.535.0",
165165
"@aws-sdk/util-dynamodb": "^3.538.0",
166+
"@smithy/util-base64": "^2.3.0",
166167
"aws-sdk-client-mock": "^4.0.0",
167168
"aws-sdk-client-mock-jest": "^4.0.0"
168169
},
169170
"dependencies": {
170-
"@aws-lambda-powertools/commons": "^2.0.3",
171-
"@aws-sdk/util-base64-node": "^3.209.0"
171+
"@aws-lambda-powertools/commons": "^2.0.3"
172172
},
173173
"peerDependencies": {
174174
"@aws-sdk/client-appconfigdata": ">=3.x",

packages/parameters/src/base/transformValue.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { JSONValue } from '@aws-lambda-powertools/commons/types';
22
import { isString } from '@aws-lambda-powertools/commons';
3-
import { fromBase64 } from '@aws-sdk/util-base64-node';
3+
import { fromBase64 } from '@aws-lambda-powertools/commons/utils/base64';
44
import {
55
TRANSFORM_METHOD_BINARY,
66
TRANSFORM_METHOD_JSON,
@@ -19,7 +19,7 @@ import type { TransformOptions } from '../types/BaseProvider.js';
1919
* the value will be parsed as JSON using the `JSON.parse` function.
2020
*
2121
* When the transform is `binary` or `auto` and the key ends with `.binary`, the value will be decoded from base64 using the `fromBase64` function
22-
* from the `@aws-sdk/util-base64-node` package.
22+
* from the `@aws-lambda-powertools/commons/utils/base64` package.
2323
*
2424
* If the transformation fails, the function will return the value as-is unless `throwOnTransformError` is set to `true`.
2525
*
@@ -67,7 +67,7 @@ const transformValue = (
6767
return JSON.parse(value) as JSONValue;
6868
// If the transform is `binary` or `auto` and the key ends with `.binary`, decode the value from base64
6969
} else if (isBinaryTransform || isAutoBinaryTransform) {
70-
return new TextDecoder('utf-8').decode(fromBase64(value));
70+
return new TextDecoder('utf-8').decode(fromBase64(value, 'base64'));
7171
}
7272
} catch (error) {
7373
if (throwOnTransformError)

packages/parameters/tests/e2e/appConfigProvider.class.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
TestStack,
1010
} from '@aws-lambda-powertools/testing-utils';
1111
import { TestNodejsFunction } from '@aws-lambda-powertools/testing-utils/resources/lambda';
12-
import { toBase64 } from '@aws-sdk/util-base64-node';
12+
import { toBase64 } from '@smithy/util-base64';
1313
import { join } from 'node:path';
1414
import { TestAppConfigWithProfiles } from '../helpers/resources.js';
1515
import {

packages/parameters/tests/unit/BaseProvider.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
TransformParameterError,
1818
clearCaches,
1919
} from '../../src/index.js';
20-
import { toBase64 } from '@aws-sdk/util-base64-node';
20+
import { toBase64 } from '@smithy/util-base64';
2121

2222
const encoder = new TextEncoder();
2323
jest.mock('@aws-lambda-powertools/commons', () => ({

packages/parameters/tests/unit/SSMProvider.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import type {
2121
SSMGetParametersByNameOutputInterface,
2222
} from '../../src/types/SSMProvider.js';
2323
import { ExpirableValue } from '../../src/base/ExpirableValue.js';
24-
import { toBase64 } from '@aws-sdk/util-base64-node';
24+
import { toBase64 } from '@smithy/util-base64';
2525
import { addUserAgentMiddleware } from '@aws-lambda-powertools/commons';
2626

2727
const encoder = new TextEncoder();

packages/parameters/tests/unit/getAppConfig.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
} from '@aws-sdk/client-appconfigdata';
1414
import { mockClient } from 'aws-sdk-client-mock';
1515
import 'aws-sdk-client-mock-jest';
16-
import { toBase64 } from '@aws-sdk/util-base64-node';
16+
import { toBase64 } from '@smithy/util-base64';
1717
import { Uint8ArrayBlobAdapter } from '@smithy/util-stream';
1818
import type { JSONValue } from '@aws-lambda-powertools/commons/types';
1919

0 commit comments

Comments
 (0)