@meshconnect/web-link-sdk 3.9.4 → 3.9.7

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
@@ -221,9 +221,18 @@ export var createLink = function (options) {
221
221
  window.removeEventListener('message', eventsListener);
222
222
  (_a = options.onExit) === null || _a === void 0 ? void 0 : _a.call(options);
223
223
  };
224
+ var closeLinkRequested = function () {
225
+ if ((currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.renderType) === 'embedded') {
226
+ sendMessageToIframe({ type: 'closeRequested' });
227
+ }
228
+ else {
229
+ closeLink();
230
+ }
231
+ };
224
232
  return {
225
233
  openLink: openLink,
226
- closeLink: closeLink
234
+ closeLink: closeLink,
235
+ closeLinkRequested: closeLinkRequested
227
236
  };
228
237
  };
229
238
  function addLanguage(linkUrl, language) {
package/README.md CHANGED
@@ -40,7 +40,6 @@ import { createLink } from '@meshconnect/web-link-sdk';
40
40
  // ...
41
41
 
42
42
  const linkConnection = createLink({
43
- clientId: '<Your Mesh Connect Client Id>',
44
43
  onIntegrationConnected: (data: LinkPayload) => {
45
44
  // use broker account data
46
45
  },
@@ -97,7 +96,6 @@ After successfull authentication on the Link session, the popup will be closed a
97
96
 
98
97
  | key | type | description |
99
98
  | ------------------------ | ------------------------------------------------------ | ------------------------------------------------------------------------------------ |
100
- | `clientId` | `string` | Keys from https://dashboard.meshconnect.com/company/keys page |
101
99
  | `onIntegrationConnected` | `(payload: LinkPayload) => void` | Callback called when users connects their accounts |
102
100
  | `onExit` | `((error?: string \| undefined) => void) \| undefined` | Called if connection not happened |
103
101
  | `onTransferFinished` | `(payload: TransferFinishedPayload) => void` | Callback called when a crypto transfer is executed |
@@ -106,13 +104,15 @@ After successfull authentication on the Link session, the popup will be closed a
106
104
  | `language` | `'en' \| undefined` | Link UI language |
107
105
  | `displayFiatCurrency` | `'USD' \| undefined` | A fiat currency to display fiat equivalent of a crypto amount |
108
106
  | `theme` | `'dark' \| 'light' \| 'system' \| undefined` | Color theme of Link UI interface |
107
+ | `renderType` | `'overlay' \| 'embedded' \| undefined` | `'overlay'` (default) renders a full-screen popup; `'embedded'` renders inside a client-supplied iframe (requires `customIframeId` in `openLink`) |
109
108
 
110
109
  #### `createLink` return value
111
110
 
112
- | key | type | description |
113
- | ----------- | -------------------------------------- | ------------------------ |
114
- | `openLink` | `(linkToken: string) => Promise<void>` | Opens the Link UI popup |
115
- | `closeLink` | `() => Promise<void>` | Closes the Link UI popup |
111
+ | key | type | description |
112
+ | -------------------- | ----------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
113
+ | `openLink` | `(linkToken: string, customIframeId?: string) => void` | Opens the Link UI popup. Optionally targets an existing iframe by ID instead of creating a new popup |
114
+ | `closeLink` | `() => void` | Closes the Link UI popup immediately |
115
+ | `closeLinkRequested` | `() => void` | Requests graceful close in `embedded` mode (sends `closeRequested` to iframe); closes immediately otherwise |
116
116
 
117
117
  ### Using tokens
118
118
 
@@ -121,3 +121,19 @@ You can use broker tokens to perform requests to get current balance, assets and
121
121
  ## Typescript support
122
122
 
123
123
  TypeScript definitions for `@meshconnect/web-link-sdk` are built into the npm package.
124
+
125
+ ### Exported types
126
+
127
+ | type | description |
128
+ | ------------------------- | --------------------------------------------------------------------------------------------- |
129
+ | `LinkPayload` | Payload passed to `onIntegrationConnected` |
130
+ | `AccessTokenPayload` | Broker access token details within `LinkPayload` |
131
+ | `DelayedAuthPayload` | Delayed auth details within `LinkPayload` |
132
+ | `IntegrationAccessToken` | Access token shape used in the `accessTokens` option |
133
+ | `TransferFinishedPayload` | Payload passed to `onTransferFinished` |
134
+ | `BrokerType` | Union of supported broker/integration type strings (re-exported from `@meshconnect/node-api`) |
135
+ | `LinkOptions` | Full options object passed to `createLink` |
136
+ | `Link` | Return type of `createLink` |
137
+ | `AccountToken` | Account token within `AccessTokenPayload` |
138
+ | `Account` | Account details within `AccountToken` |
139
+ | `BrandInfo` | Integration brand/logo info |
package/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './utils/types';
2
2
  export * from './utils/event-types';
3
3
  export { createLink } from './Link';
4
+ export type { BrokerType } from '@meshconnect/node-api';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshconnect/web-link-sdk",
3
- "version": "3.9.4",
3
+ "version": "3.9.7",
4
4
  "description": "A client-side JS library for integrating with Mesh Connect",
5
5
  "exports": "./index.js",
6
6
  "license": "MIT",
@@ -54,6 +54,8 @@ export interface TransferExecuted extends LinkEventBase {
54
54
  symbol: string;
55
55
  amount: number;
56
56
  networkId: string;
57
+ userId?: string;
58
+ clientTransactionId?: string;
57
59
  };
58
60
  }
59
61
  export interface TransferNoEligibleAssets extends LinkEventBase {
package/utils/types.d.ts CHANGED
@@ -12,6 +12,10 @@ export interface Link {
12
12
  * A function to close Link UI popup
13
13
  */
14
14
  closeLink: () => void;
15
+ /**
16
+ * A function to request Link UI to close gracefully in embedded mode.
17
+ */
18
+ closeLinkRequested: () => void;
15
19
  }
16
20
  export interface AccountToken {
17
21
  account: Account;
@@ -82,6 +86,8 @@ export interface TransferFinishedPayload {
82
86
  symbol: string;
83
87
  amount: number;
84
88
  networkId: string;
89
+ userId?: string;
90
+ clientTransactionId?: string;
85
91
  amountInFiat?: number;
86
92
  totalAmountInFiat?: number;
87
93
  networkName?: string;
@@ -98,7 +104,7 @@ export interface IntegrationAccessToken {
98
104
  }
99
105
  export interface LinkOptions {
100
106
  /**
101
- * Client ID that can be obtained at https://dashboard.meshconnect.com/company/keys
107
+ * @deprecated This property is unused and will be removed in the next major version.
102
108
  */
103
109
  clientId?: string;
104
110
  /**
@@ -1 +1 @@
1
- export declare const sdkVersion = "3.9.4";
1
+ export declare const sdkVersion = "3.9.7";
package/utils/version.js CHANGED
@@ -1 +1 @@
1
- export var sdkVersion = '3.9.4';
1
+ export var sdkVersion = '3.9.7';