@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 +10 -1
- package/README.md +22 -6
- package/index.d.ts +1 -0
- package/package.json +1 -1
- package/utils/event-types.d.ts +2 -0
- package/utils/types.d.ts +7 -1
- package/utils/version.d.ts +1 -1
- package/utils/version.js +1 -1
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
|
|
113
|
-
|
|
|
114
|
-
| `openLink`
|
|
115
|
-
| `closeLink`
|
|
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
package/package.json
CHANGED
package/utils/event-types.d.ts
CHANGED
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
|
-
*
|
|
107
|
+
* @deprecated This property is unused and will be removed in the next major version.
|
|
102
108
|
*/
|
|
103
109
|
clientId?: string;
|
|
104
110
|
/**
|
package/utils/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const sdkVersion = "3.9.
|
|
1
|
+
export declare const sdkVersion = "3.9.7";
|
package/utils/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export var sdkVersion = '3.9.
|
|
1
|
+
export var sdkVersion = '3.9.7';
|