@meshconnect/web-link-sdk 3.9.3 → 3.9.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/Link.js CHANGED
@@ -48,6 +48,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
48
48
  import { addPopup, iframeId, removePopup } from './utils/popup';
49
49
  import { isLinkEventTypeKey } from './utils/event-types';
50
50
  import { sdkSpecs } from './utils/sdk-specs';
51
+ import { appendQueryParam } from './utils/url';
51
52
  import { BridgeParent } from '@meshconnect/uwc-bridge-parent';
52
53
  import { createPrewarmIframe, removePrewarmIframe } from './utils/prewarm';
53
54
  var currentOptions;
@@ -166,22 +167,29 @@ function eventsListener(event) {
166
167
  }
167
168
  export var createLink = function (options) {
168
169
  var openLink = function (linkToken, customIframeId) {
169
- var _a, _b;
170
+ var _a, _b, _c;
170
171
  removePrewarmIframe();
171
172
  if (!linkToken) {
172
173
  (_a = options === null || options === void 0 ? void 0 : options.onExit) === null || _a === void 0 ? void 0 : _a.call(options, 'Invalid link token!');
173
174
  return;
174
175
  }
176
+ if ((options === null || options === void 0 ? void 0 : options.renderType) === 'embedded' && !customIframeId) {
177
+ var msg = 'Mesh SDK: Failed to open link - renderType "embedded" requires a customIframeId';
178
+ console.error(msg);
179
+ (_b = options === null || options === void 0 ? void 0 : options.onExit) === null || _b === void 0 ? void 0 : _b.call(options, msg);
180
+ return;
181
+ }
175
182
  currentOptions = options;
176
183
  var linkUrl = window.atob(linkToken);
177
184
  var isProtocolValid = linkUrl.startsWith('http://') || linkUrl.startsWith('https://');
178
185
  if (!isProtocolValid) {
179
- (_b = options === null || options === void 0 ? void 0 : options.onExit) === null || _b === void 0 ? void 0 : _b.call(options, 'Invalid link token!');
186
+ (_c = options === null || options === void 0 ? void 0 : options.onExit) === null || _c === void 0 ? void 0 : _c.call(options, 'Invalid link token!');
180
187
  return;
181
188
  }
182
189
  linkUrl = addLanguage(linkUrl, currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.language);
183
190
  linkUrl = addDisplayFiatCurrency(linkUrl, currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.displayFiatCurrency);
184
191
  linkUrl = addTheme(linkUrl, currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.theme);
192
+ linkUrl = addRenderType(linkUrl, currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.renderType);
185
193
  linkTokenOrigin = new URL(linkUrl).origin;
186
194
  window.removeEventListener('message', eventsListener);
187
195
  if (customIframeId) {
@@ -225,18 +233,23 @@ function addLanguage(linkUrl, language) {
225
233
  ? encodeURIComponent(navigator.language)
226
234
  : undefined;
227
235
  }
228
- return "".concat(linkUrl).concat(linkUrl.includes('?') ? '&' : '?', "lng=").concat(language || 'en');
236
+ return appendQueryParam(linkUrl, 'lng', language || 'en');
229
237
  }
230
238
  function addDisplayFiatCurrency(linkUrl, displayFiatCurrency) {
231
239
  if (displayFiatCurrency) {
232
- var queryString = linkUrl.includes('?') ? '&' : '?';
233
- return "".concat(linkUrl).concat(queryString, "fiatCur=").concat(displayFiatCurrency);
240
+ return appendQueryParam(linkUrl, 'fiatCur', displayFiatCurrency);
234
241
  }
235
242
  return linkUrl;
236
243
  }
237
244
  function addTheme(linkUrl, theme) {
238
245
  if (theme) {
239
- return "".concat(linkUrl).concat(linkUrl.includes('?') ? '&' : '?', "th=").concat(theme);
246
+ return appendQueryParam(linkUrl, 'th', theme);
247
+ }
248
+ return linkUrl;
249
+ }
250
+ function addRenderType(linkUrl, renderType) {
251
+ if (renderType === 'embedded') {
252
+ return appendQueryParam(linkUrl, 'rt', 'embedded');
240
253
  }
241
254
  return linkUrl;
242
255
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshconnect/web-link-sdk",
3
- "version": "3.9.3",
3
+ "version": "3.9.4",
4
4
  "description": "A client-side JS library for integrating with Mesh Connect",
5
5
  "exports": "./index.js",
6
6
  "license": "MIT",
package/utils/types.d.ts CHANGED
@@ -138,6 +138,12 @@ export interface LinkOptions {
138
138
  * Link UI theme. Possible values: 'dark', 'light' and 'system'.
139
139
  */
140
140
  theme?: 'dark' | 'light' | 'system';
141
+ /**
142
+ * Controls how the Link UI is rendered.
143
+ * - 'overlay' (default): renders as a full-screen popup managed by the SDK.
144
+ * - 'embedded': renders inside a client-supplied iframe for a more native UI experience. Requires `customIframeId` in `openLink`.
145
+ */
146
+ renderType?: 'overlay' | 'embedded';
141
147
  }
142
148
  export interface LinkStyle {
143
149
  ir: number;
package/utils/url.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function appendQueryParam(url: string, key: string, value: string): string;
package/utils/url.js ADDED
@@ -0,0 +1,3 @@
1
+ export function appendQueryParam(url, key, value) {
2
+ return "".concat(url).concat(url.includes('?') ? '&' : '?').concat(key, "=").concat(value);
3
+ }
@@ -1 +1 @@
1
- export declare const sdkVersion = "3.9.3";
1
+ export declare const sdkVersion = "3.9.4";
package/utils/version.js CHANGED
@@ -1 +1 @@
1
- export var sdkVersion = '3.9.3';
1
+ export var sdkVersion = '3.9.4';