@adobe/aio-commerce-lib-auth 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @adobe/aio-commerce-lib-auth
2
2
 
3
+ ## 0.3.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#61](https://github.com/adobe/aio-commerce-sdk/pull/61) [`e2fb844`](https://github.com/adobe/aio-commerce-sdk/commit/e2fb8441fc1c3394bf2b197932bdc368511ab0ea) Thanks [@jnatherley](https://github.com/jnatherley)! - The ESM build of @adobe/aio-commerce-lib-auth fails when imported into ESM projects due to incompatible import statements for the CommonJS dependency @adobe/aio-lib-ims.
8
+
9
+ ```bash
10
+ file:///path/to/node_modules/@adobe/aio-commerce-lib-auth/dist/es/index.js:15
11
+ import { context, getToken } from "@adobe/aio-lib-ims";
12
+ ^^^^^^^^
13
+ SyntaxError: Named export 'getToken' not found. The requested module '@adobe/aio-lib-ims' is a CommonJS module, which may not support all module.exports as named exports.
14
+ ```
15
+
16
+ **Affected Versions**
17
+
18
+ @adobe/aio-commerce-lib-auth: All versions with ESM distribution
19
+ Occurs when using Node.js native ESM (projects with "type": "module" in package.json)
20
+
21
+ **Root Cause**
22
+
23
+ The library's ESM distribution (/dist/es/index.js) attempts to use named imports from @adobe/aio-lib-ims, which is a CommonJS module. Node.js ESM cannot directly import named exports from CommonJS modules, requiring the use of default imports instead.
24
+
3
25
  ## 0.3.3
4
26
 
5
27
  ### Patch Changes
@@ -33,7 +33,7 @@ const __adobe_aio_commerce_lib_core_error = __toESM(require("@adobe/aio-commerce
33
33
  environment: (0, valibot.pipe)((0, valibot.optional)(ImsAuthEnvSchema, IMS_AUTH_ENV.PROD)),
34
34
  context: (0, valibot.pipe)((0, valibot.optional)((0, valibot.string)())),
35
35
  scopes: (0, valibot.pipe)(stringArray("scopes"), (0, valibot.minLength)(1, "Expected at least one scope for IMS auth"))
36
- });
36
+ }), { context, getToken } = __adobe_aio_lib_ims.default;
37
37
  function toImsAuthConfig(config) {
38
38
  return {
39
39
  scopes: config.scopes,
@@ -53,7 +53,7 @@ function assertImsAuthParams(config) {
53
53
  function getImsAuthProvider(authParams) {
54
54
  let getAccessToken = async () => {
55
55
  let imsAuthConfig = toImsAuthConfig(authParams);
56
- return await __adobe_aio_lib_ims.context.set(imsAuthConfig.context, imsAuthConfig), (0, __adobe_aio_lib_ims.getToken)(imsAuthConfig.context, {});
56
+ return await context.set(imsAuthConfig.context, imsAuthConfig), getToken(imsAuthConfig.context, {});
57
57
  }, getHeaders = async () => {
58
58
  let accessToken = await getAccessToken();
59
59
  return {
@@ -51,10 +51,10 @@ type ImsAuthHeader = "Authorization" | "x-api-key";
51
51
  /** Defines the headers required for IMS authentication. */
52
52
  type ImsAuthHeaders = Record<ImsAuthHeader, string>;
53
53
  /** Defines an authentication provider for Adobe IMS. */
54
- interface ImsAuthProvider {
54
+ type ImsAuthProvider = {
55
55
  getAccessToken: () => Promise<string>;
56
56
  getHeaders: () => Promise<ImsAuthHeaders>;
57
- }
57
+ };
58
58
  /**
59
59
  * Asserts the provided configuration for an {@link ImsAuthProvider}.
60
60
  * @param config The configuration to validate.
@@ -164,9 +164,9 @@ type IntegrationAuthHeaders = Record<IntegrationAuthHeader, string>;
164
164
  /** Represents a URL for Adobe Commerce endpoints, accepting either string or URL object. */
165
165
  type AdobeCommerceUrl = string | URL;
166
166
  /** Defines an authentication provider for Adobe Commerce integrations. */
167
- interface IntegrationAuthProvider {
167
+ type IntegrationAuthProvider = {
168
168
  getHeaders: (method: HttpMethodInput, url: AdobeCommerceUrl) => IntegrationAuthHeaders;
169
- }
169
+ };
170
170
  /**
171
171
  * Asserts the provided configuration for an Adobe Commerce {@link IntegrationAuthProvider}.
172
172
  * @param config The configuration to validate.
@@ -51,10 +51,10 @@ type ImsAuthHeader = "Authorization" | "x-api-key";
51
51
  /** Defines the headers required for IMS authentication. */
52
52
  type ImsAuthHeaders = Record<ImsAuthHeader, string>;
53
53
  /** Defines an authentication provider for Adobe IMS. */
54
- interface ImsAuthProvider {
54
+ type ImsAuthProvider = {
55
55
  getAccessToken: () => Promise<string>;
56
56
  getHeaders: () => Promise<ImsAuthHeaders>;
57
- }
57
+ };
58
58
  /**
59
59
  * Asserts the provided configuration for an {@link ImsAuthProvider}.
60
60
  * @param config The configuration to validate.
@@ -164,9 +164,9 @@ type IntegrationAuthHeaders = Record<IntegrationAuthHeader, string>;
164
164
  /** Represents a URL for Adobe Commerce endpoints, accepting either string or URL object. */
165
165
  type AdobeCommerceUrl = string | URL;
166
166
  /** Defines an authentication provider for Adobe Commerce integrations. */
167
- interface IntegrationAuthProvider {
167
+ type IntegrationAuthProvider = {
168
168
  getHeaders: (method: HttpMethodInput, url: AdobeCommerceUrl) => IntegrationAuthHeaders;
169
- }
169
+ };
170
170
  /**
171
171
  * Asserts the provided configuration for an Adobe Commerce {@link IntegrationAuthProvider}.
172
172
  * @param config The configuration to validate.
package/dist/es/index.js CHANGED
@@ -12,7 +12,7 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
  import { CommerceSdkValidationError } from "@adobe/aio-commerce-lib-core/error";
15
- import { context, getToken } from "@adobe/aio-lib-ims";
15
+ import aioLibIms from "@adobe/aio-lib-ims";
16
16
  import { array, email, enum as enum$1, instance, minLength, nonEmpty, nonOptional, object, optional, pipe, safeParse, string, transform, union, url } from "valibot";
17
17
  import crypto from "crypto";
18
18
  import OAuth1a from "oauth-1.0a";
@@ -28,7 +28,7 @@ const imsAuthParameter = (name) => pipe(string(`Expected a string value for the
28
28
  environment: pipe(optional(ImsAuthEnvSchema, IMS_AUTH_ENV.PROD)),
29
29
  context: pipe(optional(string())),
30
30
  scopes: pipe(stringArray("scopes"), minLength(1, "Expected at least one scope for IMS auth"))
31
- });
31
+ }), { context, getToken } = aioLibIms;
32
32
  function toImsAuthConfig(config) {
33
33
  return {
34
34
  scopes: config.scopes,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@adobe/aio-commerce-lib-auth",
3
3
  "type": "module",
4
4
  "author": "Adobe Inc.",
5
- "version": "0.3.3",
5
+ "version": "0.3.4",
6
6
  "private": false,
7
7
  "engines": {
8
8
  "node": ">=20 <=24"
@@ -55,9 +55,9 @@
55
55
  },
56
56
  "devDependencies": {
57
57
  "@aio-commerce-sdk/config-typedoc": "1.0.0",
58
+ "@aio-commerce-sdk/config-typescript": "1.0.0",
58
59
  "@aio-commerce-sdk/config-tsdown": "1.0.0",
59
- "@aio-commerce-sdk/config-vitest": "1.0.0",
60
- "@aio-commerce-sdk/config-typescript": "1.0.0"
60
+ "@aio-commerce-sdk/config-vitest": "1.0.0"
61
61
  },
62
62
  "sideEffects": false,
63
63
  "scripts": {