@adobe/aio-commerce-lib-auth 0.3.2 → 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,34 @@
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
+
25
+ ## 0.3.3
26
+
27
+ ### Patch Changes
28
+
29
+ - Updated dependencies [[`412af7a`](https://github.com/adobe/aio-commerce-sdk/commit/412af7a0b0a40f24b6fddafc7de76807de800724)]:
30
+ - @adobe/aio-commerce-lib-core@0.4.1
31
+
3
32
  ## 0.3.2
4
33
 
5
34
  ### 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.
@@ -12,7 +12,7 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
- import * as valibot0 from "valibot";
15
+ import * as valibot21 from "valibot";
16
16
  import { InferOutput } from "valibot";
17
17
 
18
18
  //#region source/lib/ims-auth/schema.d.ts
@@ -22,23 +22,23 @@ declare const IMS_AUTH_ENV: {
22
22
  readonly STAGE: "stage";
23
23
  };
24
24
  /** Validation schema for IMS auth environment values. */
25
- declare const ImsAuthEnvSchema: valibot0.EnumSchema<{
25
+ declare const ImsAuthEnvSchema: valibot21.EnumSchema<{
26
26
  readonly PROD: "prod";
27
27
  readonly STAGE: "stage";
28
28
  }, undefined>;
29
29
  /** Defines the schema to validate the necessary parameters for the IMS auth service. */
30
- declare const ImsAuthParamsSchema: valibot0.ObjectSchema<{
31
- readonly clientId: valibot0.SchemaWithPipe<readonly [valibot0.StringSchema<`Expected a string value for the IMS auth parameter ${string}`>, valibot0.NonEmptyAction<string, `Expected a non-empty string value for the IMS auth parameter ${string}`>]>;
32
- readonly clientSecrets: valibot0.SchemaWithPipe<readonly [valibot0.SchemaWithPipe<readonly [valibot0.ArraySchema<valibot0.StringSchema<undefined>, `Expected a string array value for the IMS auth parameter ${string}`>]>, valibot0.MinLengthAction<string[], 1, "Expected at least one client secret for IMS auth">]>;
33
- readonly technicalAccountId: valibot0.SchemaWithPipe<readonly [valibot0.StringSchema<`Expected a string value for the IMS auth parameter ${string}`>, valibot0.NonEmptyAction<string, `Expected a non-empty string value for the IMS auth parameter ${string}`>]>;
34
- readonly technicalAccountEmail: valibot0.SchemaWithPipe<readonly [valibot0.StringSchema<"Expected a string value for the IMS auth parameter technicalAccountEmail">, valibot0.EmailAction<string, "Expected a valid email format for technicalAccountEmail">]>;
35
- readonly imsOrgId: valibot0.SchemaWithPipe<readonly [valibot0.StringSchema<`Expected a string value for the IMS auth parameter ${string}`>, valibot0.NonEmptyAction<string, `Expected a non-empty string value for the IMS auth parameter ${string}`>]>;
36
- readonly environment: valibot0.SchemaWithPipe<readonly [valibot0.OptionalSchema<valibot0.EnumSchema<{
30
+ declare const ImsAuthParamsSchema: valibot21.ObjectSchema<{
31
+ readonly clientId: valibot21.SchemaWithPipe<readonly [valibot21.StringSchema<`Expected a string value for the IMS auth parameter ${string}`>, valibot21.NonEmptyAction<string, `Expected a non-empty string value for the IMS auth parameter ${string}`>]>;
32
+ readonly clientSecrets: valibot21.SchemaWithPipe<readonly [valibot21.SchemaWithPipe<readonly [valibot21.ArraySchema<valibot21.StringSchema<undefined>, `Expected a string array value for the IMS auth parameter ${string}`>]>, valibot21.MinLengthAction<string[], 1, "Expected at least one client secret for IMS auth">]>;
33
+ readonly technicalAccountId: valibot21.SchemaWithPipe<readonly [valibot21.StringSchema<`Expected a string value for the IMS auth parameter ${string}`>, valibot21.NonEmptyAction<string, `Expected a non-empty string value for the IMS auth parameter ${string}`>]>;
34
+ readonly technicalAccountEmail: valibot21.SchemaWithPipe<readonly [valibot21.StringSchema<"Expected a string value for the IMS auth parameter technicalAccountEmail">, valibot21.EmailAction<string, "Expected a valid email format for technicalAccountEmail">]>;
35
+ readonly imsOrgId: valibot21.SchemaWithPipe<readonly [valibot21.StringSchema<`Expected a string value for the IMS auth parameter ${string}`>, valibot21.NonEmptyAction<string, `Expected a non-empty string value for the IMS auth parameter ${string}`>]>;
36
+ readonly environment: valibot21.SchemaWithPipe<readonly [valibot21.OptionalSchema<valibot21.EnumSchema<{
37
37
  readonly PROD: "prod";
38
38
  readonly STAGE: "stage";
39
39
  }, undefined>, "prod">]>;
40
- readonly context: valibot0.SchemaWithPipe<readonly [valibot0.OptionalSchema<valibot0.StringSchema<undefined>, undefined>]>;
41
- readonly scopes: valibot0.SchemaWithPipe<readonly [valibot0.SchemaWithPipe<readonly [valibot0.ArraySchema<valibot0.StringSchema<undefined>, `Expected a string array value for the IMS auth parameter ${string}`>]>, valibot0.MinLengthAction<string[], 1, "Expected at least one scope for IMS auth">]>;
40
+ readonly context: valibot21.SchemaWithPipe<readonly [valibot21.OptionalSchema<valibot21.StringSchema<undefined>, undefined>]>;
41
+ readonly scopes: valibot21.SchemaWithPipe<readonly [valibot21.SchemaWithPipe<readonly [valibot21.ArraySchema<valibot21.StringSchema<undefined>, `Expected a string array value for the IMS auth parameter ${string}`>]>, valibot21.MinLengthAction<string[], 1, "Expected at least one scope for IMS auth">]>;
42
42
  }, undefined>;
43
43
  /** Defines the parameters for the IMS auth service. */
44
44
  type ImsAuthParams = InferOutput<typeof ImsAuthParamsSchema>;
@@ -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.
@@ -147,11 +147,11 @@ type HttpMethodInput = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
147
147
  * The schema for the Commerce Integration parameters.
148
148
  * This is used to validate the parameters passed to the Commerce Integration provider.
149
149
  */
150
- declare const IntegrationAuthParamsSchema: valibot0.NonOptionalSchema<valibot0.ObjectSchema<{
151
- readonly consumerKey: valibot0.SchemaWithPipe<readonly [valibot0.StringSchema<`Expected a string value for the Commerce Integration parameter ${string}`>, valibot0.NonEmptyAction<string, `Expected a non-empty string value for the Commerce Integration parameter ${string}`>]>;
152
- readonly consumerSecret: valibot0.SchemaWithPipe<readonly [valibot0.StringSchema<`Expected a string value for the Commerce Integration parameter ${string}`>, valibot0.NonEmptyAction<string, `Expected a non-empty string value for the Commerce Integration parameter ${string}`>]>;
153
- readonly accessToken: valibot0.SchemaWithPipe<readonly [valibot0.StringSchema<`Expected a string value for the Commerce Integration parameter ${string}`>, valibot0.NonEmptyAction<string, `Expected a non-empty string value for the Commerce Integration parameter ${string}`>]>;
154
- readonly accessTokenSecret: valibot0.SchemaWithPipe<readonly [valibot0.StringSchema<`Expected a string value for the Commerce Integration parameter ${string}`>, valibot0.NonEmptyAction<string, `Expected a non-empty string value for the Commerce Integration parameter ${string}`>]>;
150
+ declare const IntegrationAuthParamsSchema: valibot21.NonOptionalSchema<valibot21.ObjectSchema<{
151
+ readonly consumerKey: valibot21.SchemaWithPipe<readonly [valibot21.StringSchema<`Expected a string value for the Commerce Integration parameter ${string}`>, valibot21.NonEmptyAction<string, `Expected a non-empty string value for the Commerce Integration parameter ${string}`>]>;
152
+ readonly consumerSecret: valibot21.SchemaWithPipe<readonly [valibot21.StringSchema<`Expected a string value for the Commerce Integration parameter ${string}`>, valibot21.NonEmptyAction<string, `Expected a non-empty string value for the Commerce Integration parameter ${string}`>]>;
153
+ readonly accessToken: valibot21.SchemaWithPipe<readonly [valibot21.StringSchema<`Expected a string value for the Commerce Integration parameter ${string}`>, valibot21.NonEmptyAction<string, `Expected a non-empty string value for the Commerce Integration parameter ${string}`>]>;
154
+ readonly accessTokenSecret: valibot21.SchemaWithPipe<readonly [valibot21.StringSchema<`Expected a string value for the Commerce Integration parameter ${string}`>, valibot21.NonEmptyAction<string, `Expected a non-empty string value for the Commerce Integration parameter ${string}`>]>;
155
155
  }, undefined>, undefined>;
156
156
  /** Defines the parameters required for Commerce Integration authentication. */
157
157
  type IntegrationAuthParams = InferOutput<typeof IntegrationAuthParamsSchema>;
@@ -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.2",
5
+ "version": "0.3.4",
6
6
  "private": false,
7
7
  "engines": {
8
8
  "node": ">=20 <=24"
@@ -51,12 +51,12 @@
51
51
  "ansis": "^4.1.0",
52
52
  "oauth-1.0a": "^2.2.6",
53
53
  "valibot": "^1.1.0",
54
- "@adobe/aio-commerce-lib-core": "0.4.0"
54
+ "@adobe/aio-commerce-lib-core": "0.4.1"
55
55
  },
56
56
  "devDependencies": {
57
- "@aio-commerce-sdk/config-tsdown": "1.0.0",
58
57
  "@aio-commerce-sdk/config-typedoc": "1.0.0",
59
58
  "@aio-commerce-sdk/config-typescript": "1.0.0",
59
+ "@aio-commerce-sdk/config-tsdown": "1.0.0",
60
60
  "@aio-commerce-sdk/config-vitest": "1.0.0"
61
61
  },
62
62
  "sideEffects": false,