@meshconnect/web-link-sdk 3.9.5 → 3.9.8
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 +12 -3
- package/README.md +22 -6
- package/index.d.ts +1 -0
- package/package.json +1 -1
- package/utils/popup.d.ts +1 -0
- package/utils/popup.js +4 -1
- package/utils/types.d.ts +5 -1
- package/utils/version.d.ts +1 -1
- package/utils/version.js +1 -1
package/Link.js
CHANGED
|
@@ -45,7 +45,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
45
45
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
-
import { addPopup, iframeId, removePopup } from './utils/popup';
|
|
48
|
+
import { addPopup, buildIframeAllowPolicy, iframeId, removePopup } from './utils/popup';
|
|
49
49
|
import { isLinkEventTypeKey } from './utils/event-types';
|
|
50
50
|
import { sdkSpecs } from './utils/sdk-specs';
|
|
51
51
|
import { appendQueryParam } from './utils/url';
|
|
@@ -195,7 +195,7 @@ export var createLink = function (options) {
|
|
|
195
195
|
if (customIframeId) {
|
|
196
196
|
var iframe_1 = document.getElementById(customIframeId);
|
|
197
197
|
if (iframe_1) {
|
|
198
|
-
iframe_1.allow =
|
|
198
|
+
iframe_1.allow = buildIframeAllowPolicy(linkTokenOrigin);
|
|
199
199
|
iframe_1.src = linkUrl;
|
|
200
200
|
currentIframeId = customIframeId;
|
|
201
201
|
}
|
|
@@ -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/popup.d.ts
CHANGED
package/utils/popup.js
CHANGED
|
@@ -5,6 +5,9 @@ var popupContentId = 'mesh-link-popup__popup-content';
|
|
|
5
5
|
var stylesId = 'mesh-link-popup__styles';
|
|
6
6
|
export var iframeId = 'mesh-link-popup__iframe';
|
|
7
7
|
var getStylesContent = function (style) { return "\n body {\n position: fixed;\n left: 0;\n top: 0;\n bottom: 0;\n right: 0;\n overflow: hidden;\n }\n\n #".concat(popupId, " {\n all: unset;\n position: fixed;\n left: 0;\n top: 0;\n bottom: 0;\n right: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n z-index: 10000;\n pointer-events: auto;\n }\n\n #").concat(backdropId, " {\n position: absolute;\n left: 0;\n top: 0;\n bottom: 0;\n right: 0;\n z-index: 10000;\n background: black;\n opacity: ").concat(getNumber(0.6, style === null || style === void 0 ? void 0 : style.io), ";\n }\n\n #").concat(popupContentId, " {\n position: absolute;\n height: 80%;\n max-height: 710px;\n min-height: 685px;\n margin: auto;\n z-index: 10001;\n width: 30%;\n max-width: 430px;\n min-width: 380px;\n display: flex;\n flex-direction: column;\n border-radius: ").concat(getNumber(24, style === null || style === void 0 ? void 0 : style.ir), "px;\n flex-grow: 1;\n }\n\n #").concat(popupContentId, " iframe {\n border: none;\n width: 100%;\n flex-grow: 1;\n border-radius: ").concat(getNumber(24, style === null || style === void 0 ? void 0 : style.ir), "px;\n }\n\n @media only screen and (max-width: 768px) {\n #").concat(popupContentId, " {\n height: 100vh;\n width: 100vw;\n max-width: 100%;\n min-width: 100%;\n max-height: 100%;\n min-height: 100%;\n border-radius: 0px;\n }\n\n #").concat(popupContentId, " iframe {\n border-radius: 0px;\n }\n }\n\n @media only screen and (max-height: 710px) {\n #").concat(popupContentId, " {\n max-height: 100%;\n min-height: 100%;\n }\n }\n"); };
|
|
8
|
+
export function buildIframeAllowPolicy(origin) {
|
|
9
|
+
return "clipboard-read *; clipboard-write *; camera ".concat(origin, "; microphone ").concat(origin);
|
|
10
|
+
}
|
|
8
11
|
export function removePopup() {
|
|
9
12
|
var _a, _b;
|
|
10
13
|
var existingPopup = window.document.getElementById(popupId);
|
|
@@ -29,7 +32,7 @@ export function addPopup(iframeLink) {
|
|
|
29
32
|
var iframeElement = document.createElement('iframe');
|
|
30
33
|
iframeElement.id = iframeId;
|
|
31
34
|
iframeElement.src = iframeLink;
|
|
32
|
-
iframeElement.allow =
|
|
35
|
+
iframeElement.allow = buildIframeAllowPolicy(new URL(iframeLink).origin);
|
|
33
36
|
popupContentElement.appendChild(iframeElement);
|
|
34
37
|
popupRootElement.appendChild(popupContentElement);
|
|
35
38
|
window.document.body.appendChild(popupRootElement);
|
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;
|
|
@@ -100,7 +104,7 @@ export interface IntegrationAccessToken {
|
|
|
100
104
|
}
|
|
101
105
|
export interface LinkOptions {
|
|
102
106
|
/**
|
|
103
|
-
*
|
|
107
|
+
* @deprecated This property is unused and will be removed in the next major version.
|
|
104
108
|
*/
|
|
105
109
|
clientId?: string;
|
|
106
110
|
/**
|
package/utils/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const sdkVersion = "3.9.
|
|
1
|
+
export declare const sdkVersion = "3.9.8";
|
package/utils/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export var sdkVersion = '3.9.
|
|
1
|
+
export var sdkVersion = '3.9.8';
|