@stokr/components-library 3.0.20 → 3.0.22

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.
Files changed (36) hide show
  1. package/README.md +217 -11
  2. package/dist/analytics/index.js +8 -1
  3. package/dist/api/authenticationApi.js +13 -0
  4. package/dist/auth/index.js +4 -2
  5. package/dist/components/2FA/login-with-otp-flow.js +9 -4
  6. package/dist/components/Footer/FooterLayout.js +98 -95
  7. package/dist/components/Footer/FooterMenu.js +1 -1
  8. package/dist/components/Header/Header.js +102 -54
  9. package/dist/components/MainMenu/MainMenu.js +14 -4
  10. package/dist/components/Modal/NewVentureModal/NewVentureModal.js +6 -2
  11. package/dist/components/Payment/PaymentDetailsCard.js +1 -1
  12. package/dist/components/VerifyEmailModal/VerifyEmailModal.js +2 -1
  13. package/dist/components/headerHo/HeaderHo.js +8 -5
  14. package/dist/config.js +5 -21
  15. package/dist/constants/globalVariables.js +6 -4
  16. package/dist/context/Auth.js +5 -2
  17. package/dist/context/AuthContext.js +22 -8
  18. package/dist/firebase-config.js +3 -17
  19. package/dist/index.js +36 -5
  20. package/dist/model/axios.js +4 -3
  21. package/dist/model/axiosPublic.js +2 -2
  22. package/dist/routing/RouterWrapper.js +17 -0
  23. package/dist/routing/app-routes.js +22 -0
  24. package/dist/routing/navigate-app.js +36 -0
  25. package/dist/routing/resolve-app-href.js +149 -0
  26. package/dist/runtime-config.js +94 -0
  27. package/dist/utils/app-urls-analytics-backoffice.js +30 -0
  28. package/dist/utils/app-urls.js +28 -0
  29. package/dist/utils/checklistGenerator.js +6 -5
  30. package/dist/utils/customHooks.js +1 -1
  31. package/dist/utils/formatCurrencyValue.js +2 -1
  32. package/dist/utils/get-cookie-domain.js +4 -1
  33. package/dist/utils/set-redirect-cookie.js +4 -1
  34. package/dist/utils/withRouter.js +5 -3
  35. package/package.json +1 -1
  36. package/dist/api/auth.js +0 -15
package/dist/index.js CHANGED
@@ -22,7 +22,7 @@ import { ErrorMessage } from "./components/ErrorMessage/ErrorMessage.styles.js";
22
22
  import { FAQ } from "./components/FAQ/FAQ.js";
23
23
  import { default as default2 } from "./components/Footer/Footer.js";
24
24
  import { default as default3 } from "./components/Footer/FooterMenu.js";
25
- import { default as default4 } from "./components/Footer/FooterLayout.js";
25
+ import { default as default4, getFooterGroups } from "./components/Footer/FooterLayout.js";
26
26
  import { Newsletter } from "./components/Newsletter/Newsletter.js";
27
27
  import { ForgotPasswordModal } from "./components/ForgotPasswordModal/ForgotPasswordModal.js";
28
28
  import { Form } from "./components/Form/Form.js";
@@ -192,7 +192,13 @@ import { openFile, saveAs } from "./utils/saveAs.js";
192
192
  import { ScrollToTop, scrollToElement, useScrollActions } from "./utils/scrollUtils.js";
193
193
  import { useTimer } from "./hooks/useTimer.js";
194
194
  import { useTransactionPolling } from "./hooks/useTransactionPolling.js";
195
- import { configure, getConfig } from "./config.js";
195
+ import { configure } from "./config.js";
196
+ import { AppRoute, AppSurface } from "./routing/app-routes.js";
197
+ import { SURFACE_ROUTING_PATH_KEYS, getAppPublicOrigin, isAlreadyOnOnboardingFlow, isPathBasedRouting, isPathForSurface, resolveAppHref } from "./routing/resolve-app-href.js";
198
+ import { navigateApp, navigateToHref, pathnameIfSameOrigin } from "./routing/navigate-app.js";
199
+ import { RouterWrapper } from "./routing/RouterWrapper.js";
200
+ import { buildDashboardUrl, buildOnboardingUrl, getAdminAppUrl, getDashboardBaseUrl, getInvestorAppOrigin, getOnboardingAppBaseUrl, getRegisterEntryUrl } from "./utils/app-urls.js";
201
+ import { authenticationApi } from "./api/authenticationApi.js";
196
202
  import { default as default40 } from "./components/2FA/Connect2FA.js";
197
203
  import { default as default41 } from "./components/2FA/enable-2fa-flow.js";
198
204
  import { default as default42 } from "./components/2FA/EnterCode.js";
@@ -214,7 +220,7 @@ import { default as default52 } from "./styles/semanticUi.js";
214
220
  import { default as default53 } from "./styles/spacing.js";
215
221
  import { default as default54 } from "./styles/theme.js";
216
222
  import { BASE_COLOR_HEX, BASE_FONT_SIZE, BASE_MARGIN, BASE_MARGIN_2X_PX, BASE_MARGIN_PX, BLUE_BASE_HEX, BLUE_BASE_RELEASED_HEX, CAPITAL_ANIMATION_LENGTH, COLUMN, DESKTOP_MEDIA, GRAY_BASE_HEX, GRAY_DEEP_HEX, GRAY_SECONDARY_HEX, GREEN, MAX_WIDTH, PHONE_MEDIA, RED_BASE_HEX, RED_BASE_RELEASE_HEX, SLIDER_HEIGHT, SLIDER_MOBILE_HEIGHT, SLIDER_TABLET_HEIGHT, TABLET_MEDIA, WHITE_HEX } from "./constants/style.js";
217
- import { LoanActivityTypes, ProfessionalInvestorStatuses, ProjectStates, ProjectStatus, ProjectTypes, TransactionTypes, USInvestorAcreditationStatuses, UserTypes, emailRegex, platformDomain, platformURL, transactionTypeDisplayNames, walletTypes } from "./constants/globalVariables.js";
223
+ import { LoanActivityTypes, ProfessionalInvestorStatuses, ProjectStates, ProjectStatus, ProjectTypes, TransactionTypes, USInvestorAcreditationStatuses, UserTypes, emailRegex, getPlatformURL, transactionTypeDisplayNames, walletTypes } from "./constants/globalVariables.js";
218
224
  import { BackButtonIcon, StyledBackButton, StyledBackButtonExternal, StyledWindowBackButton } from "./components/BackButton/BackButton.styles.js";
219
225
  import { ContainerWithLine } from "./components/RegisterConfirmModal/RegisterConfirmModal.styles.js";
220
226
  import { CopyToClipboard } from "react-copy-to-clipboard";
@@ -230,6 +236,8 @@ import { StyledReactTable, Styles, TableWrap } from "./components/AdminDashboard
230
236
  import { Tab } from "./components/Tabs/Tabs.styles.js";
231
237
  import { default as default55 } from "./components/TabsNav/TabNav.js";
232
238
  import { format } from "date-fns";
239
+ import { getAnalyticsIngestUrl, getBackofficeAppUrl } from "./utils/app-urls-analytics-backoffice.js";
240
+ import { getConfig, resetRuntimeConfig } from "./runtime-config.js";
233
241
  import { learnMoreCategoryPropTypes, learnMorePostPropTypes } from "./components/LearnMorePage/LearnMore.propTypes.js";
234
242
  export {
235
243
  AccountBalance,
@@ -237,6 +245,8 @@ export {
237
245
  AgreementItem,
238
246
  AnimatedSpan,
239
247
  AnnouncementTitleMain,
248
+ AppRoute,
249
+ AppSurface,
240
250
  Arrow,
241
251
  ArrowSimple,
242
252
  Auth,
@@ -462,11 +472,13 @@ export {
462
472
  default47 as ResetCode,
463
473
  ResetConfirmModal,
464
474
  ResetPasswordModal,
475
+ RouterWrapper,
465
476
  Row,
466
477
  SEO,
467
478
  SLIDER_HEIGHT,
468
479
  SLIDER_MOBILE_HEIGHT,
469
480
  SLIDER_TABLET_HEIGHT,
481
+ SURFACE_ROUTING_PATH_KEYS,
470
482
  Scroll,
471
483
  ScrollToTop,
472
484
  SearchInput,
@@ -569,6 +581,9 @@ export {
569
581
  X,
570
582
  Youtube,
571
583
  alias,
584
+ authenticationApi,
585
+ buildDashboardUrl,
586
+ buildOnboardingUrl,
572
587
  checkSaleTimeLeft,
573
588
  checkTodoStatus,
574
589
  colors,
@@ -582,13 +597,23 @@ export {
582
597
  format,
583
598
  formatCurrencyValue,
584
599
  generateCoreChecklistTasks,
600
+ getAdminAppUrl,
585
601
  getAmountBucket,
602
+ getAnalyticsIngestUrl,
603
+ getAppPublicOrigin,
604
+ getBackofficeAppUrl,
586
605
  getConfig,
587
606
  getCurrencyIcon,
588
607
  getCurrencySymbol,
608
+ getDashboardBaseUrl,
609
+ getFooterGroups,
610
+ getInvestorAppOrigin,
589
611
  getLiquidAssetIcon,
590
612
  getMedia,
613
+ getOnboardingAppBaseUrl,
614
+ getPlatformURL,
591
615
  getProjectCurrencySign,
616
+ getRegisterEntryUrl,
592
617
  getTokenBucket,
593
618
  getVerifyIdentityChecklist,
594
619
  default49 as grid,
@@ -596,19 +621,25 @@ export {
596
621
  iconsMap,
597
622
  identify,
598
623
  initAnalytics,
624
+ isAlreadyOnOnboardingFlow,
625
+ isPathBasedRouting,
626
+ isPathForSurface,
599
627
  isUSInvestor,
600
628
  km_ify,
601
629
  learnMoreCategoryPropTypes,
602
630
  learnMorePostPropTypes,
603
631
  loaderGif,
604
632
  momentUtils,
633
+ navigateApp,
634
+ navigateToHref,
605
635
  openFile,
606
636
  optIn,
607
637
  optOut,
608
- platformDomain,
609
- platformURL,
638
+ pathnameIfSameOrigin,
610
639
  default50 as reactTippyStyle,
611
640
  reset,
641
+ resetRuntimeConfig,
642
+ resolveAppHref,
612
643
  default51 as rwd,
613
644
  rwdMax,
614
645
  saveAs,
@@ -1,8 +1,9 @@
1
1
  import axios from "axios";
2
- const BASE_URL = "https://platform-api.stokr.info/api/v1";
2
+ import { getConfig } from "../runtime-config.js";
3
+ if (!getConfig("apiUrl") && false) ;
3
4
  const axiosInstance = axios?.create({
4
- headers: { "Content-Type": "application/json", "Access-Control-Allow-Origin": "*" },
5
- baseURL: BASE_URL
5
+ headers: { "Content-Type": "application/json" },
6
+ baseURL: getConfig("apiUrl") || void 0
6
7
  });
7
8
  export {
8
9
  axiosInstance as default
@@ -1,8 +1,8 @@
1
1
  import axios from "axios";
2
- const BASE_URL = "https://platform-api-no-auth.stokr.info/api/v1";
2
+ import { getConfig } from "../runtime-config.js";
3
3
  const axiosInstance = axios?.create({
4
4
  headers: { "Content-Type": "application/json" },
5
- baseURL: BASE_URL
5
+ baseURL: getConfig("baseUrlPublic")
6
6
  });
7
7
  export {
8
8
  axiosInstance as default
@@ -0,0 +1,17 @@
1
+ import { jsx, Fragment } from "react/jsx-runtime";
2
+ import "react";
3
+ import PropTypes from "prop-types";
4
+ import { useInRouterContext, BrowserRouter } from "react-router-dom";
5
+ function RouterWrapper({ children }) {
6
+ const inRouter = useInRouterContext();
7
+ if (inRouter) {
8
+ return /* @__PURE__ */ jsx(Fragment, { children });
9
+ }
10
+ return /* @__PURE__ */ jsx(BrowserRouter, { future: { v7_relativeSplatPath: false, v7_startTransition: false }, children });
11
+ }
12
+ RouterWrapper.propTypes = {
13
+ children: PropTypes.node
14
+ };
15
+ export {
16
+ RouterWrapper
17
+ };
@@ -0,0 +1,22 @@
1
+ const AppSurface = Object.freeze({
2
+ ONBOARDING: "onboarding",
3
+ DASHBOARD: "dashboard",
4
+ ADMIN: "admin",
5
+ BACKOFFICE: "backoffice",
6
+ /** Apex / public app origin (`https://{websiteDomain}`; path mode uses the same base as {@link getPlatformURL}). */
7
+ INVESTOR_ROOT: "investorRoot",
8
+ /** Register / sign-up entry from login flows. */
9
+ REGISTER: "register",
10
+ /** Default Mixpanel proxy host (subdomain or path). */
11
+ ANALYTICS: "analytics"
12
+ });
13
+ const AppRoute = Object.freeze({
14
+ WELCOME: "/welcome",
15
+ RESEND_ACTIVATION: "/resend-activation-email",
16
+ CHECKLIST: "/checklist",
17
+ OVERVIEW: "/overview"
18
+ });
19
+ export {
20
+ AppRoute,
21
+ AppSurface
22
+ };
@@ -0,0 +1,36 @@
1
+ import { resolveAppHref } from "./resolve-app-href.js";
2
+ function pathnameIfSameOrigin(absoluteHref) {
3
+ if (typeof window === "undefined" || !absoluteHref) return null;
4
+ try {
5
+ const u = new URL(absoluteHref, window.location.href);
6
+ if (u.origin === window.location.origin) {
7
+ return `${u.pathname}${u.search}${u.hash}`;
8
+ }
9
+ } catch {
10
+ }
11
+ return null;
12
+ }
13
+ function navigateApp(navigate, surface, relativePath = "") {
14
+ const href = resolveAppHref(surface, relativePath);
15
+ if (!href) return;
16
+ const internal = pathnameIfSameOrigin(href);
17
+ if (internal != null && typeof navigate === "function") {
18
+ navigate(internal);
19
+ return;
20
+ }
21
+ window.location.assign(href);
22
+ }
23
+ function navigateToHref(navigate, href) {
24
+ if (!href) return;
25
+ const internal = pathnameIfSameOrigin(href);
26
+ if (internal != null && typeof navigate === "function") {
27
+ navigate(internal);
28
+ return;
29
+ }
30
+ window.location.assign(href);
31
+ }
32
+ export {
33
+ navigateApp,
34
+ navigateToHref,
35
+ pathnameIfSameOrigin
36
+ };
@@ -0,0 +1,149 @@
1
+ import { getPlatformURL } from "../constants/globalVariables.js";
2
+ import { getConfig } from "../runtime-config.js";
3
+ import { AppSurface } from "./app-routes.js";
4
+ import { getAnalyticsIngestUrl, getBackofficeAppUrl } from "../utils/app-urls-analytics-backoffice.js";
5
+ const DEFAULT_APP_PATHS = {
6
+ onboarding: "/signin",
7
+ registerEntry: "/signup",
8
+ dashboard: "/dashboard",
9
+ admin: "/admin"
10
+ };
11
+ const SURFACE_ROUTING_PATH_KEYS = Object.freeze([
12
+ "onboarding",
13
+ "dashboard",
14
+ "admin",
15
+ "registerEntry",
16
+ "investorRoot"
17
+ ]);
18
+ function routingModeRaw() {
19
+ const v = getConfig("routingMode");
20
+ return typeof v === "string" ? v.trim().toLowerCase() : "";
21
+ }
22
+ function isPathBasedRouting() {
23
+ return routingModeRaw() === "path";
24
+ }
25
+ function isPathForSurface(pathKey) {
26
+ const per = getConfig("surfaceRoutingMode");
27
+ if (!per || typeof per !== "object" || Array.isArray(per)) return isPathBasedRouting();
28
+ if (!Object.prototype.hasOwnProperty.call(per, pathKey)) return isPathBasedRouting();
29
+ const v = per[pathKey];
30
+ if (v === "path") return true;
31
+ if (v === "subdomain") return false;
32
+ return isPathBasedRouting();
33
+ }
34
+ function mergedPaths() {
35
+ const o = getConfig("appUrlPaths");
36
+ if (o && typeof o === "object" && !Array.isArray(o)) {
37
+ return { ...DEFAULT_APP_PATHS, ...o };
38
+ }
39
+ return { ...DEFAULT_APP_PATHS };
40
+ }
41
+ function stripTrailingSlash(s) {
42
+ return String(s).replace(/\/+$/, "");
43
+ }
44
+ function normalizeLeading(path) {
45
+ if (path == null || path === "") return "";
46
+ const p = String(path);
47
+ return p.startsWith("/") ? p : `/${p}`;
48
+ }
49
+ function isNonEmptyString(v) {
50
+ return v != null && String(v).trim() !== "";
51
+ }
52
+ function trimmedWebsiteDomain() {
53
+ const d = getConfig("websiteDomain");
54
+ return isNonEmptyString(d) ? String(d).trim() : "";
55
+ }
56
+ function getAppPublicOrigin() {
57
+ const u = getPlatformURL();
58
+ if (!isNonEmptyString(u)) return "";
59
+ return stripTrailingSlash(String(u).trim());
60
+ }
61
+ function subdomainOrigin(sub) {
62
+ const domain = trimmedWebsiteDomain();
63
+ if (!domain) return "";
64
+ return `https://${sub}.${domain}`;
65
+ }
66
+ function surfaceBase(pathKey, legacySubdomain) {
67
+ if (isPathForSurface(pathKey)) {
68
+ const origin = getAppPublicOrigin();
69
+ if (!origin) return "";
70
+ const seg = stripTrailingSlash(normalizeLeading(mergedPaths()[pathKey]));
71
+ return `${origin}${seg}`;
72
+ }
73
+ return subdomainOrigin(legacySubdomain);
74
+ }
75
+ function onboardingBase() {
76
+ return surfaceBase("onboarding", "signup");
77
+ }
78
+ function dashboardBase() {
79
+ return surfaceBase("dashboard", "dashboard");
80
+ }
81
+ function adminBase() {
82
+ return surfaceBase("admin", "admin");
83
+ }
84
+ function investorRootBase() {
85
+ if (isPathForSurface("investorRoot")) return getAppPublicOrigin() || "";
86
+ const domain = trimmedWebsiteDomain();
87
+ if (!domain) return "";
88
+ return `https://${domain}`;
89
+ }
90
+ function registerEntryHref() {
91
+ if (isPathForSurface("registerEntry")) {
92
+ const origin = getAppPublicOrigin();
93
+ if (!origin) return "";
94
+ const seg = stripTrailingSlash(normalizeLeading(mergedPaths().registerEntry));
95
+ return `${origin}${seg}`;
96
+ }
97
+ const domain = trimmedWebsiteDomain();
98
+ if (!domain) return "";
99
+ return `https://${domain}/signup`;
100
+ }
101
+ function resolveAppHref(surface, relativePath = "") {
102
+ let base = "";
103
+ switch (surface) {
104
+ case AppSurface.ONBOARDING:
105
+ base = onboardingBase();
106
+ break;
107
+ case AppSurface.DASHBOARD:
108
+ base = dashboardBase();
109
+ break;
110
+ case AppSurface.ADMIN:
111
+ base = adminBase();
112
+ break;
113
+ case AppSurface.BACKOFFICE:
114
+ base = getBackofficeAppUrl("");
115
+ break;
116
+ case AppSurface.INVESTOR_ROOT:
117
+ base = investorRootBase();
118
+ break;
119
+ case AppSurface.REGISTER:
120
+ return registerEntryHref();
121
+ case AppSurface.ANALYTICS:
122
+ return getAnalyticsIngestUrl();
123
+ default:
124
+ return "";
125
+ }
126
+ const p = normalizeLeading(relativePath);
127
+ if (!base) return "";
128
+ const root = stripTrailingSlash(base);
129
+ return p ? `${root}${p}` : root;
130
+ }
131
+ function isAlreadyOnOnboardingFlow() {
132
+ if (typeof window === "undefined") return false;
133
+ const { href, hostname } = window.location;
134
+ if (isPathForSurface("onboarding")) {
135
+ const base = onboardingBase();
136
+ if (base && href.startsWith(base)) return true;
137
+ const seg = mergedPaths().onboarding.replace(/^\//, "");
138
+ return href.includes(`/${seg}/`) || href.includes(`/${seg}?`) || href.endsWith(`/${seg}`);
139
+ }
140
+ return Boolean(hostname?.startsWith("signup.") || href.includes("signup."));
141
+ }
142
+ export {
143
+ SURFACE_ROUTING_PATH_KEYS,
144
+ getAppPublicOrigin,
145
+ isAlreadyOnOnboardingFlow,
146
+ isPathBasedRouting,
147
+ isPathForSurface,
148
+ resolveAppHref
149
+ };
@@ -0,0 +1,94 @@
1
+ const __vite_import_meta_env__ = { "BASE_URL": "/", "DEV": false, "MODE": "production", "PROD": true, "SSR": false, "VITE_API_URL": "https://platform-api.stokr.info/api/v1", "VITE_BASE_URL_PUBLIC": "https://platform-api-no-auth.stokr.info/api/v1", "VITE_COOKIE_DOMAIN": "stokr.info", "VITE_FIREBASE_API_KEY": "AIzaSyBBp_3Romnfv--YpUuV0mJgDymvSp3oq0c", "VITE_FIREBASE_APP_ID": "1:568229412804:web:2391857e3e2a0b02346e91", "VITE_FIREBASE_AUTH_DOMAIN": "stokr-development-env.firebaseapp.com", "VITE_FIREBASE_MEASUREMENT_ID": "G-CP53SZVSMN", "VITE_FIREBASE_MESSAGING_SENDER_ID": "568229412804", "VITE_FIREBASE_PROJECT_ID": "stokr-development-env", "VITE_FIREBASE_STORAGE_BUCKET": "stokr-development-env.appspot.com", "VITE_MIXPANEL_TOKEN": "a7bb1e881f9b2600762fded84d8ce0ea", "VITE_PHOTO_API_URL": "https://platform-api.stokr.info/api/v1", "VITE_WEBSITE_DOMAIN": "stokr.info" };
2
+ const _overrides = {};
3
+ const ENV_KEY_BY_CONFIG = {
4
+ apiUrl: "VITE_API_URL",
5
+ baseUrlPublic: "VITE_BASE_URL_PUBLIC",
6
+ cookieDomain: "VITE_COOKIE_DOMAIN",
7
+ websiteDomain: "VITE_WEBSITE_DOMAIN",
8
+ photoApiUrl: "VITE_PHOTO_API_URL",
9
+ /** `'path'` = single-origin URLs (`https://DOMAIN/dashboard`, …). Anything else = legacy subdomains (`dashboard.`, `signup.`, …). */
10
+ routingMode: "VITE_ROUTING_MODE"
11
+ };
12
+ const FIREBASE_ENV_VARS = [
13
+ "VITE_FIREBASE_API_KEY",
14
+ "VITE_FIREBASE_AUTH_DOMAIN",
15
+ "VITE_FIREBASE_PROJECT_ID",
16
+ "VITE_FIREBASE_STORAGE_BUCKET",
17
+ "VITE_FIREBASE_MESSAGING_SENDER_ID",
18
+ "VITE_FIREBASE_APP_ID"
19
+ ];
20
+ let hasWarnedMissingEnv = false;
21
+ function env(name) {
22
+ try {
23
+ return __vite_import_meta_env__?.[name];
24
+ } catch {
25
+ return void 0;
26
+ }
27
+ }
28
+ function isProvided(value) {
29
+ if (value == null) return false;
30
+ if (typeof value === "string") return value.trim() !== "";
31
+ return true;
32
+ }
33
+ function getMissingRuntimeEnvVarNames() {
34
+ const missing = [];
35
+ for (const [configKey, envName] of Object.entries(ENV_KEY_BY_CONFIG)) {
36
+ const resolved = _overrides[configKey] ?? env(envName);
37
+ if (!isProvided(resolved)) missing.push(envName);
38
+ }
39
+ if (!_overrides.firebase) {
40
+ for (const envName of FIREBASE_ENV_VARS) {
41
+ if (!isProvided(env(envName))) missing.push(envName);
42
+ }
43
+ }
44
+ return missing;
45
+ }
46
+ function warnMissingRuntimeEnvOnce() {
47
+ if (hasWarnedMissingEnv || typeof console === "undefined" || !console.warn) return;
48
+ const missing = getMissingRuntimeEnvVarNames();
49
+ if (missing.length === 0) return;
50
+ hasWarnedMissingEnv = true;
51
+ console.warn(
52
+ "[@stokr/components-library] Missing runtime configuration: no value from configure() / AuthProvider and no Vite env fallback for:\n - " + missing.join("\n - ")
53
+ );
54
+ }
55
+ function assignRuntimeConfig(config = {}) {
56
+ Object.assign(_overrides, config);
57
+ warnMissingRuntimeEnvOnce();
58
+ }
59
+ function resetRuntimeConfig() {
60
+ for (const k of Object.keys(_overrides)) {
61
+ delete _overrides[k];
62
+ }
63
+ hasWarnedMissingEnv = false;
64
+ }
65
+ function buildFirebaseConfigFromEnv() {
66
+ return {
67
+ apiKey: env("VITE_FIREBASE_API_KEY"),
68
+ authDomain: env("VITE_FIREBASE_AUTH_DOMAIN"),
69
+ projectId: env("VITE_FIREBASE_PROJECT_ID"),
70
+ storageBucket: env("VITE_FIREBASE_STORAGE_BUCKET"),
71
+ messagingSenderId: env("VITE_FIREBASE_MESSAGING_SENDER_ID"),
72
+ appId: env("VITE_FIREBASE_APP_ID"),
73
+ measurementId: env("VITE_FIREBASE_MEASUREMENT_ID")
74
+ };
75
+ }
76
+ function getConfig(key) {
77
+ if (key === "firebase") {
78
+ return _overrides.firebase ?? buildFirebaseConfigFromEnv();
79
+ }
80
+ if (key === "appUrlPaths") {
81
+ return _overrides.appUrlPaths;
82
+ }
83
+ const envName = ENV_KEY_BY_CONFIG[key];
84
+ if (envName) {
85
+ return _overrides[key] ?? env(envName);
86
+ }
87
+ return _overrides[key];
88
+ }
89
+ export {
90
+ assignRuntimeConfig,
91
+ getConfig,
92
+ getMissingRuntimeEnvVarNames,
93
+ resetRuntimeConfig
94
+ };
@@ -0,0 +1,30 @@
1
+ import { getConfig } from "../runtime-config.js";
2
+ function trimmedWebsiteDomain() {
3
+ const d = getConfig("websiteDomain");
4
+ return d != null && String(d).trim() !== "" ? String(d).trim() : "";
5
+ }
6
+ function normalizeLeading(path) {
7
+ if (path == null || path === "") return "";
8
+ const p = String(path);
9
+ return p.startsWith("/") ? p : `/${p}`;
10
+ }
11
+ function stripTrailingSlash(s) {
12
+ return String(s).replace(/\/+$/, "");
13
+ }
14
+ function getAnalyticsIngestUrl() {
15
+ const domain = trimmedWebsiteDomain();
16
+ if (!domain) return "";
17
+ return `https://analytics.${domain}`;
18
+ }
19
+ function getBackofficeAppUrl(relativePath = "") {
20
+ const domain = trimmedWebsiteDomain();
21
+ if (!domain) return "";
22
+ const root = `https://backoffice.${domain}`;
23
+ const p = normalizeLeading(relativePath);
24
+ if (!p) return root;
25
+ return `${stripTrailingSlash(root)}${p}`;
26
+ }
27
+ export {
28
+ getAnalyticsIngestUrl,
29
+ getBackofficeAppUrl
30
+ };
@@ -0,0 +1,28 @@
1
+ import { AppSurface } from "../routing/app-routes.js";
2
+ import { AppRoute } from "../routing/app-routes.js";
3
+ import { resolveAppHref } from "../routing/resolve-app-href.js";
4
+ import { SURFACE_ROUTING_PATH_KEYS, getAppPublicOrigin, isAlreadyOnOnboardingFlow, isPathBasedRouting, isPathForSurface } from "../routing/resolve-app-href.js";
5
+ const getOnboardingAppBaseUrl = () => resolveAppHref(AppSurface.ONBOARDING, "");
6
+ const buildOnboardingUrl = (path = "") => resolveAppHref(AppSurface.ONBOARDING, path);
7
+ const getDashboardBaseUrl = () => resolveAppHref(AppSurface.DASHBOARD, "");
8
+ const buildDashboardUrl = (path = "") => resolveAppHref(AppSurface.DASHBOARD, path);
9
+ const getAdminAppUrl = () => resolveAppHref(AppSurface.ADMIN, "");
10
+ const getInvestorAppOrigin = () => resolveAppHref(AppSurface.INVESTOR_ROOT, "");
11
+ const getRegisterEntryUrl = () => resolveAppHref(AppSurface.REGISTER, "");
12
+ export {
13
+ AppRoute,
14
+ AppSurface,
15
+ SURFACE_ROUTING_PATH_KEYS,
16
+ buildDashboardUrl,
17
+ buildOnboardingUrl,
18
+ getAdminAppUrl,
19
+ getAppPublicOrigin,
20
+ getDashboardBaseUrl,
21
+ getInvestorAppOrigin,
22
+ getOnboardingAppBaseUrl,
23
+ getRegisterEntryUrl,
24
+ isAlreadyOnOnboardingFlow,
25
+ isPathBasedRouting,
26
+ isPathForSurface,
27
+ resolveAppHref
28
+ };
@@ -1,5 +1,6 @@
1
1
  import { walletTypes, UserTypes } from "../constants/globalVariables.js";
2
- const websiteUrl = "stokr.info";
2
+ import { AppSurface } from "../routing/app-routes.js";
3
+ import { resolveAppHref } from "../routing/resolve-app-href.js";
3
4
  const TASK_COPY = {
4
5
  country: {
5
6
  title: {
@@ -132,7 +133,7 @@ function generateCoreChecklistTasks(user) {
132
133
  const liquidWallets = wallets.filter((wallet2) => wallet2.type === walletTypes.LIQUID) || [];
133
134
  const hasWallet = liquidWallets.length > 0;
134
135
  const isEntity = user_type === UserTypes.investor_entity;
135
- const platformURL = `https://signup.${websiteUrl}`;
136
+ const signupBase = resolveAppHref(AppSurface.ONBOARDING, "");
136
137
  const countryStatus = !country ? "missing" : !isFromAllowedCountry ? "not_available" : "done";
137
138
  const countryTask = {
138
139
  key: "country",
@@ -140,7 +141,7 @@ function generateCoreChecklistTasks(user) {
140
141
  description: getCountryDescription(user, isFromAllowedCountry),
141
142
  iconState: countryStatus,
142
143
  iconCopy: TASK_COPY.country.iconCopy[countryStatus],
143
- link: `${platformURL}/country-of-residence`,
144
+ link: signupBase ? `${signupBase}/country-of-residence` : "",
144
145
  isClickable: countryStatus !== "done"
145
146
  };
146
147
  const verifyIdentityChecklist = getVerifyIdentityChecklist(isFromAllowedCountry, user, isEntity);
@@ -150,7 +151,7 @@ function generateCoreChecklistTasks(user) {
150
151
  description: verifyIdentityChecklist.message,
151
152
  iconState: verifyIdentityChecklist.state,
152
153
  iconCopy: TASK_COPY.identity.iconCopy[verifyIdentityChecklist.state],
153
- link: `${platformURL}/verify-identity`,
154
+ link: signupBase ? `${signupBase}/verify-identity` : "",
154
155
  isClickable: verifyIdentityChecklist.hasLink
155
156
  };
156
157
  const walletStatus = hasWallet ? "done" : "missing";
@@ -161,7 +162,7 @@ function generateCoreChecklistTasks(user) {
161
162
  description: walletDescription,
162
163
  iconState: walletStatus,
163
164
  iconCopy: TASK_COPY.wallet.iconCopy[walletStatus],
164
- link: `${platformURL}/register-liquid-securities`,
165
+ link: signupBase ? `${signupBase}/register-liquid-securities` : "",
165
166
  isClickable: isFromAllowedCountry && walletStatus !== "done"
166
167
  };
167
168
  const taxStatus = taxId ? "done" : "missing";
@@ -1,5 +1,5 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import React__default, { useRef, useState, useEffect, useCallback } from "react";
2
+ import React__default, { useState, useRef, useCallback, useEffect } from "react";
3
3
  import { sizes } from "../styles/rwd.js";
4
4
  const useMobileView = (breakpoint = sizes.Medium) => {
5
5
  var breakpointNumber = breakpoint.match(/\d/g);
@@ -57,7 +57,8 @@ const getProjectCurrencySign = (tokenCurrency) => {
57
57
  const getCurrencyIcon = (currency, customIcon) => {
58
58
  if (customIcon) return customIcon;
59
59
  if (!currency) return null;
60
- switch (currency.toLowerCase()) {
60
+ const value = String(currency).toLowerCase();
61
+ switch (value) {
61
62
  case "btc":
62
63
  case "bitcoin":
63
64
  case "btc-fb":
@@ -1,4 +1,7 @@
1
- import { getConfig } from "../config.js";
1
+ import "../firebase-config.js";
2
+ import "../model/axios.js";
3
+ import "../model/axiosPublic.js";
4
+ import { getConfig } from "../runtime-config.js";
2
5
  const getCookieDomain = () => {
3
6
  const domain = getConfig("cookieDomain");
4
7
  const useDomain = domain && domain !== "localhost";
@@ -1,5 +1,8 @@
1
1
  import Cookies from "js-cookie";
2
- import { getConfig } from "../config.js";
2
+ import "../firebase-config.js";
3
+ import "../model/axios.js";
4
+ import "../model/axiosPublic.js";
5
+ import { getConfig } from "../runtime-config.js";
3
6
  const setRedirectCookie = (path = "") => {
4
7
  const inOneHour = 1 / 24;
5
8
  const cookieOptions = {
@@ -1,9 +1,11 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import "react";
3
3
  import { useInRouterContext, useNavigate, useLocation } from "react-router-dom";
4
- const noopNavigate = () => {
5
- };
6
4
  const fallbackLocation = { pathname: "/", search: "", hash: "", state: null, key: "default" };
5
+ const NAVIGATE_OUTSIDE_ROUTER_MSG = "[@stokr/components-library] Navigation requires a React Router context. Wrap the app root with BrowserRouter, or with RouterWrapper from this package (it adds BrowserRouter only when useInRouterContext() is false so you avoid duplicate routers in a host app).";
6
+ function navigateOutsideRouter() {
7
+ throw new Error(NAVIGATE_OUTSIDE_ROUTER_MSG);
8
+ }
7
9
  const withRouter = (Component) => {
8
10
  const InnerWithRouter = (props) => {
9
11
  const navigate = useNavigate();
@@ -15,7 +17,7 @@ const withRouter = (Component) => {
15
17
  if (inRouter) {
16
18
  return /* @__PURE__ */ jsx(InnerWithRouter, { ...props });
17
19
  }
18
- return /* @__PURE__ */ jsx(Component, { navigate: noopNavigate, location: fallbackLocation, ...props });
20
+ return /* @__PURE__ */ jsx(Component, { navigate: navigateOutsideRouter, location: fallbackLocation, ...props });
19
21
  };
20
22
  return Wrapper;
21
23
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stokr/components-library",
3
- "version": "3.0.20",
3
+ "version": "3.0.22",
4
4
  "description": "STOKR - Components Library",
5
5
  "author": "Bilal Hodzic <bilal@stokr.io>",
6
6
  "license": "MIT",
package/dist/api/auth.js DELETED
@@ -1,15 +0,0 @@
1
- import axiosInstance from "../model/axios.js";
2
- const authAPI = async (url, data) => {
3
- try {
4
- const result = await axiosInstance.post(`auth/${url}`, data);
5
- console.log("Success!");
6
- return result;
7
- } catch (error) {
8
- console.log(`Error: ${error}`);
9
- throw error;
10
- }
11
- };
12
- export {
13
- authAPI,
14
- authAPI as default
15
- };