@lana-commerce/core 13.1.0-alpha.13 → 13.1.0-alpha.15

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
@@ -16,6 +16,7 @@ This project adheres to [Semantic Versioning][semantic versioning].
16
16
  - Propagate new "meta" field for invoice line item descriptions.
17
17
  - Add "webauthn" logic to "customer" module.
18
18
  - Add webauthn related fields to customer/shop fragments.
19
+ - "Customer" modulde: now all signin forms share the custom error type. When custom error happens, it is set on all forms.
19
20
 
20
21
  ### Patch Changes
21
22
 
@@ -1736,6 +1736,11 @@ function createSigninPageGraph(binding) {
1736
1736
  const formOTPComplete = (0, form_js_1.createFormWithCustomError)({
1737
1737
  code: (0, form_js_1.createStringField)("code", "", [validator_js_1.validNonEmpty, validator_js_1.validMaxLength250]),
1738
1738
  }, null);
1739
+ const setErrorOnAllForms = (0, effector_1.createEvent)();
1740
+ (0, effector_1.forward)({
1741
+ from: setErrorOnAllForms,
1742
+ to: [form.setError, formOTPInit.setError, formOTPComplete.setError],
1743
+ });
1739
1744
  (0, effector_1.forward)({
1740
1745
  from: init.event,
1741
1746
  to: [form.reset, formOTPInit.reset, formOTPComplete.reset],
@@ -1804,8 +1809,8 @@ function createSigninPageGraph(binding) {
1804
1809
  to: binding.setJWT,
1805
1810
  });
1806
1811
  // failure
1807
- (0, split_js_1.splitMap)(signinFx.done)
1808
- .map((e) => (e.result.kind !== "system_error" ? "unauthorized_webauthn" : undefined), form.setError)
1812
+ (0, split_js_1.splitMap)(signInViaWebauthnFx.done)
1813
+ .map((e) => (e.result.kind !== "system_error" ? "unauthorized_webauthn" : undefined), setErrorOnAllForms)
1809
1814
  .map((e) => (e.result.kind !== "data" ? e.result : undefined), handleFormFailure({ form, unexpectedError: binding.unexpectedError }));
1810
1815
  }
1811
1816
  // email/password form
@@ -1825,7 +1830,7 @@ function createSigninPageGraph(binding) {
1825
1830
  ? "unauthorized"
1826
1831
  : "unauthorized_oauth"
1827
1832
  : undefined;
1828
- }, form.setError)
1833
+ }, setErrorOnAllForms)
1829
1834
  .map((e) => (e.result.kind !== "data" ? e.result : undefined), handleFormFailure({ form, unexpectedError: binding.unexpectedError }));
1830
1835
  }
1831
1836
  // OTP init form
@@ -1838,7 +1843,7 @@ function createSigninPageGraph(binding) {
1838
1843
  });
1839
1844
  // failure
1840
1845
  (0, split_js_1.splitMap)(error)
1841
- .map((e) => { var _a; return e.kind === "error" && ((_a = e.error.apiError) === null || _a === void 0 ? void 0 : _a.code) === codes_js_1.ErrorCode.TryAgainLater ? "try_again_later" : undefined; }, formOTPInit.setError)
1846
+ .map((e) => { var _a; return e.kind === "error" && ((_a = e.error.apiError) === null || _a === void 0 ? void 0 : _a.code) === codes_js_1.ErrorCode.TryAgainLater ? "try_again_later" : undefined; }, setErrorOnAllForms)
1842
1847
  .fallback(handleFormFailure({ form: formOTPInit, unexpectedError: binding.unexpectedError }));
1843
1848
  }
1844
1849
  // OTP complete form
@@ -1851,7 +1856,7 @@ function createSigninPageGraph(binding) {
1851
1856
  });
1852
1857
  // failure
1853
1858
  (0, split_js_1.splitMap)(error)
1854
- .map((e) => { var _a; return (e.kind === "error" && ((_a = e.error.apiError) === null || _a === void 0 ? void 0 : _a.code) === codes_js_1.ErrorCode.NotFound ? "unauthorized" : undefined); }, formOTPComplete.setError)
1859
+ .map((e) => { var _a; return (e.kind === "error" && ((_a = e.error.apiError) === null || _a === void 0 ? void 0 : _a.code) === codes_js_1.ErrorCode.NotFound ? "unauthorized" : undefined); }, setErrorOnAllForms)
1855
1860
  .fallback(handleFormFailure({ form: formOTPComplete, unexpectedError: binding.unexpectedError }));
1856
1861
  }
1857
1862
  // oauth flow
package/cjs/script.js CHANGED
@@ -45,6 +45,7 @@ function embedUI(config) {
45
45
  shopCurrencies: (0, arrayToDict_js_1.arrayToDict)(config.currencies, (c) => c.currency.code),
46
46
  tipsVariantID: config.shop.tips_enabled ? (_b = config.shop.tips_variant) === null || _b === void 0 ? void 0 : _b.id : undefined,
47
47
  oauth2Providers: config.shop.customer_oauth_providers,
48
+ customerWebauthn: config.shop.customer_webauthn,
48
49
  stripe: stripeGateway
49
50
  ? {
50
51
  accountID: stripeGateway.account_id,
@@ -1754,6 +1754,11 @@ function createSigninPageGraph(binding) {
1754
1754
  const formOTPComplete = createFormWithCustomError({
1755
1755
  code: createStringField("code", "", [validNonEmpty, validMaxLength250]),
1756
1756
  }, null);
1757
+ const setErrorOnAllForms = createEvent();
1758
+ forward({
1759
+ from: setErrorOnAllForms,
1760
+ to: [form.setError, formOTPInit.setError, formOTPComplete.setError],
1761
+ });
1757
1762
  forward({
1758
1763
  from: init.event,
1759
1764
  to: [form.reset, formOTPInit.reset, formOTPComplete.reset],
@@ -1822,8 +1827,8 @@ function createSigninPageGraph(binding) {
1822
1827
  to: binding.setJWT,
1823
1828
  });
1824
1829
  // failure
1825
- splitMap(signinFx.done)
1826
- .map((e) => (e.result.kind !== "system_error" ? "unauthorized_webauthn" : undefined), form.setError)
1830
+ splitMap(signInViaWebauthnFx.done)
1831
+ .map((e) => (e.result.kind !== "system_error" ? "unauthorized_webauthn" : undefined), setErrorOnAllForms)
1827
1832
  .map((e) => (e.result.kind !== "data" ? e.result : undefined), handleFormFailure({ form, unexpectedError: binding.unexpectedError }));
1828
1833
  }
1829
1834
  // email/password form
@@ -1840,7 +1845,7 @@ function createSigninPageGraph(binding) {
1840
1845
  ? e.params.data.email
1841
1846
  ? "unauthorized"
1842
1847
  : "unauthorized_oauth"
1843
- : undefined, form.setError)
1848
+ : undefined, setErrorOnAllForms)
1844
1849
  .map((e) => (e.result.kind !== "data" ? e.result : undefined), handleFormFailure({ form, unexpectedError: binding.unexpectedError }));
1845
1850
  }
1846
1851
  // OTP init form
@@ -1853,7 +1858,7 @@ function createSigninPageGraph(binding) {
1853
1858
  });
1854
1859
  // failure
1855
1860
  splitMap(error)
1856
- .map((e) => e.kind === "error" && e.error.apiError?.code === ErrorCode.TryAgainLater ? "try_again_later" : undefined, formOTPInit.setError)
1861
+ .map((e) => e.kind === "error" && e.error.apiError?.code === ErrorCode.TryAgainLater ? "try_again_later" : undefined, setErrorOnAllForms)
1857
1862
  .fallback(handleFormFailure({ form: formOTPInit, unexpectedError: binding.unexpectedError }));
1858
1863
  }
1859
1864
  // OTP complete form
@@ -1866,7 +1871,7 @@ function createSigninPageGraph(binding) {
1866
1871
  });
1867
1872
  // failure
1868
1873
  splitMap(error)
1869
- .map((e) => (e.kind === "error" && e.error.apiError?.code === ErrorCode.NotFound ? "unauthorized" : undefined), formOTPComplete.setError)
1874
+ .map((e) => (e.kind === "error" && e.error.apiError?.code === ErrorCode.NotFound ? "unauthorized" : undefined), setErrorOnAllForms)
1870
1875
  .fallback(handleFormFailure({ form: formOTPComplete, unexpectedError: binding.unexpectedError }));
1871
1876
  }
1872
1877
  // oauth flow
package/esm/script.js CHANGED
@@ -35,6 +35,7 @@ export async function embedUI(config) {
35
35
  shopCurrencies: arrayToDict(config.currencies, (c) => c.currency.code),
36
36
  tipsVariantID: config.shop.tips_enabled ? config.shop.tips_variant?.id : undefined,
37
37
  oauth2Providers: config.shop.customer_oauth_providers,
38
+ customerWebauthn: config.shop.customer_webauthn,
38
39
  stripe: stripeGateway
39
40
  ? {
40
41
  accountID: stripeGateway.account_id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lana-commerce/core",
3
- "version": "13.1.0-alpha.13",
3
+ "version": "13.1.0-alpha.15",
4
4
  "description": "Lana JS Core",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -188,7 +188,7 @@ export declare function createCustomer(config: CustomerConfig, init: CustomerIni
188
188
  } & {
189
189
  email: import("../effector/form.js").StringField<[Validator<"invalid_non_empty">, Validator<"invalid_email">, Validator<"max_length_exceeded">], string>;
190
190
  password: import("../effector/form.js").StringField<[Validator<"invalid_non_empty">], string>;
191
- } & import("../effector/form.js").CustomFormError<"unauthorized" | "unauthorized_oauth" | "unauthorized_webauthn" | null>;
191
+ } & import("../effector/form.js").CustomFormError<"try_again_later" | "unauthorized" | "unauthorized_oauth" | "unauthorized_webauthn" | null>;
192
192
  formOTPInit: {
193
193
  init: Event<Partial<{
194
194
  email: string;
@@ -206,7 +206,7 @@ export declare function createCustomer(config: CustomerConfig, init: CustomerIni
206
206
  errorPropagationFailed: Event<void>;
207
207
  } & {
208
208
  email: import("../effector/form.js").StringField<[Validator<"invalid_non_empty">, Validator<"invalid_email">, Validator<"max_length_exceeded">], string>;
209
- } & import("../effector/form.js").CustomFormError<"try_again_later" | null>;
209
+ } & import("../effector/form.js").CustomFormError<"try_again_later" | "unauthorized" | "unauthorized_oauth" | "unauthorized_webauthn" | null>;
210
210
  formOTPComplete: {
211
211
  init: Event<Partial<{
212
212
  code: string;
@@ -224,7 +224,7 @@ export declare function createCustomer(config: CustomerConfig, init: CustomerIni
224
224
  errorPropagationFailed: Event<void>;
225
225
  } & {
226
226
  code: import("../effector/form.js").StringField<[Validator<"invalid_non_empty">, Validator<"max_length_exceeded">], string>;
227
- } & import("../effector/form.js").CustomFormError<"unauthorized" | null>;
227
+ } & import("../effector/form.js").CustomFormError<"try_again_later" | "unauthorized" | "unauthorized_oauth" | "unauthorized_webauthn" | null>;
228
228
  signInMode: Store<"email-otp-init" | "email-otp-complete" | "email-password">;
229
229
  setSignInMode: Event<"email-otp-init" | "email-otp-complete" | "email-password">;
230
230
  oauth2Click: Event<CustomerOAuthProviderKind>;