@meshconnect/web-link-sdk 3.2.15 → 3.2.16
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.d.ts +2 -0
- package/Link.js +530 -0
- package/index.d.ts +3 -0
- package/index.js +3 -0
- package/package.json +8 -20
- package/utils/connectors/evm/chainConfigs.d.ts +2 -0
- package/utils/connectors/evm/chainConfigs.js +115 -0
- package/utils/connectors/evm/chainSwitching.d.ts +15 -0
- package/utils/connectors/evm/chainSwitching.js +242 -0
- package/utils/connectors/evm/index.d.ts +8 -0
- package/utils/connectors/evm/index.js +8 -0
- package/utils/connectors/evm/provider.d.ts +6 -0
- package/utils/connectors/evm/provider.js +13 -0
- package/utils/connectors/evm/signing.d.ts +1 -0
- package/utils/connectors/evm/signing.js +78 -0
- package/utils/connectors/evm/transactions.d.ts +28 -0
- package/utils/connectors/evm/transactions.js +381 -0
- package/utils/connectors/evm/types.d.ts +57 -0
- package/utils/connectors/evm/types.js +1 -0
- package/utils/connectors/evm/walletConnection.d.ts +20 -0
- package/utils/connectors/evm/walletConnection.js +160 -0
- package/utils/connectors/evm/walletDiscovery.d.ts +10 -0
- package/utils/connectors/evm/walletDiscovery.js +55 -0
- package/utils/connectors/solana/connection.d.ts +4 -0
- package/utils/connectors/solana/connection.js +108 -0
- package/utils/connectors/solana/index.d.ts +5 -0
- package/utils/connectors/solana/index.js +5 -0
- package/utils/connectors/solana/providerDiscovery.d.ts +3 -0
- package/utils/connectors/solana/providerDiscovery.js +127 -0
- package/utils/connectors/solana/signing.d.ts +1 -0
- package/utils/connectors/solana/signing.js +59 -0
- package/utils/connectors/solana/transaction.d.ts +17 -0
- package/utils/connectors/solana/transaction.js +362 -0
- package/utils/connectors/solana/types.d.ts +71 -0
- package/utils/connectors/solana/types.js +8 -0
- package/utils/event-types.d.ts +233 -0
- package/{src/utils/event-types.test.ts → utils/event-types.js} +5 -15
- package/utils/popup.d.ts +3 -0
- package/utils/popup.js +36 -0
- package/utils/sdk-specs.d.ts +5 -0
- package/utils/sdk-specs.js +6 -0
- package/utils/style.d.ts +3 -0
- package/utils/style.js +13 -0
- package/utils/types.d.ts +234 -0
- package/utils/types.js +1 -0
- package/utils/version.d.ts +1 -0
- package/utils/version.js +1 -0
- package/utils/wallet/EVMWalletStrategy.d.ts +31 -0
- package/utils/wallet/EVMWalletStrategy.js +265 -0
- package/utils/wallet/SolanaWalletStrategy.d.ts +33 -0
- package/utils/wallet/SolanaWalletStrategy.js +300 -0
- package/utils/wallet/WalletStrategy.d.ts +61 -0
- package/utils/wallet/WalletStrategy.js +25 -0
- package/utils/wallet/WalletStrategyFactory.d.ts +15 -0
- package/utils/wallet/WalletStrategyFactory.js +31 -0
- package/utils/wallet/index.d.ts +4 -0
- package/utils/wallet/index.js +4 -0
- package/utils/wallet-browser-event-types.d.ts +116 -0
- package/utils/wallet-browser-event-types.js +17 -0
- package/jest.setup.ts +0 -4
- package/src/Link.test.ts +0 -434
- package/src/Link.ts +0 -491
- package/src/index.ts +0 -3
- package/src/utils/__snapshots__/popup.test.ts.snap +0 -89
- package/src/utils/connectors/evm/chainConfigs.ts +0 -120
- package/src/utils/connectors/evm/chainSwitching.ts +0 -165
- package/src/utils/connectors/evm/index.ts +0 -8
- package/src/utils/connectors/evm/provider.ts +0 -22
- package/src/utils/connectors/evm/signing.ts +0 -39
- package/src/utils/connectors/evm/transactions.ts +0 -356
- package/src/utils/connectors/evm/types.ts +0 -63
- package/src/utils/connectors/evm/walletConnection.ts +0 -140
- package/src/utils/connectors/evm/walletDiscovery.ts +0 -67
- package/src/utils/connectors/solana/connection.ts +0 -69
- package/src/utils/connectors/solana/index.ts +0 -5
- package/src/utils/connectors/solana/providerDiscovery.ts +0 -153
- package/src/utils/connectors/solana/signing.ts +0 -18
- package/src/utils/connectors/solana/transaction.ts +0 -382
- package/src/utils/connectors/solana/types.ts +0 -66
- package/src/utils/event-types.ts +0 -350
- package/src/utils/popup.test.ts +0 -50
- package/src/utils/popup.ts +0 -123
- package/src/utils/sdk-specs.test.ts +0 -18
- package/src/utils/sdk-specs.ts +0 -7
- package/src/utils/style.test.ts +0 -33
- package/src/utils/style.ts +0 -15
- package/src/utils/types.ts +0 -270
- package/src/utils/version.ts +0 -1
- package/src/utils/wallet/EVMWalletStrategy.ts +0 -176
- package/src/utils/wallet/SolanaWalletStrategy.ts +0 -207
- package/src/utils/wallet/WalletStrategy.ts +0 -99
- package/src/utils/wallet/WalletStrategyFactory.ts +0 -46
- package/src/utils/wallet/__tests__/EVMWalletStrategy.test.ts +0 -233
- package/src/utils/wallet/__tests__/SolanaWalletStrategy.test.ts +0 -253
- package/src/utils/wallet/__tests__/WalletStrategy.test.ts +0 -77
- package/src/utils/wallet/__tests__/WalletStrategyFactory.test.ts +0 -65
- package/src/utils/wallet/index.ts +0 -4
- package/src/utils/wallet-browser-event-types.ts +0 -190
- package/tools/copy.js +0 -26
- package/tools/update-version.js +0 -10
- package/tsconfig.json +0 -14
package/src/utils/event-types.ts
DELETED
@@ -1,350 +0,0 @@
|
|
1
|
-
import { LinkPayload, TransferFinishedPayload } from './types'
|
2
|
-
|
3
|
-
export type LinkEventType =
|
4
|
-
| IntegrationConnected
|
5
|
-
| IntegrationConnectionError
|
6
|
-
| TransferCompleted
|
7
|
-
| IntegrationSelected
|
8
|
-
| CredentialsEntered
|
9
|
-
| TransferStarted
|
10
|
-
| TransferPreviewed
|
11
|
-
| TransferPreviewError
|
12
|
-
| TransferExecutionError
|
13
|
-
| PageLoaded
|
14
|
-
| IntegrationMfaRequired
|
15
|
-
| IntegrationMfaEntered
|
16
|
-
| IntegrationOAuthStarted
|
17
|
-
| IntegrationAccountSelectionRequired
|
18
|
-
| TransferAssetSelected
|
19
|
-
| TransferNetworkSelected
|
20
|
-
| TransferAmountEntered
|
21
|
-
| TransferMfaRequired
|
22
|
-
| TransferMfaEntered
|
23
|
-
| TransferKycRequired
|
24
|
-
| TransferInitiated
|
25
|
-
| TransferExecuted
|
26
|
-
| TransferNoEligibleAssets
|
27
|
-
| WalletMessageSigned
|
28
|
-
| DoneEvent
|
29
|
-
| CloseEvent
|
30
|
-
| VerifyWalletRejected
|
31
|
-
| VerifyDonePage
|
32
|
-
| SDKinjectedWalletProviders
|
33
|
-
| LegalTermsViewed
|
34
|
-
| SeeWhatHappenedClicked
|
35
|
-
| FundingOptionsUpdated
|
36
|
-
| FundingOptionsViewed
|
37
|
-
| GasIncreaseWarning
|
38
|
-
| ExecuteFundingStep
|
39
|
-
|
40
|
-
const LINK_EVENT_TYPE_KEYS = [
|
41
|
-
'integrationConnected',
|
42
|
-
'integrationConnectionError',
|
43
|
-
'integrationMfaRequired',
|
44
|
-
'integrationMfaEntered',
|
45
|
-
'integrationOAuthStarted',
|
46
|
-
'integrationAccountSelectionRequired',
|
47
|
-
'transferCompleted',
|
48
|
-
'integrationSelected',
|
49
|
-
'credentialsEntered',
|
50
|
-
'transferStarted',
|
51
|
-
'transferPreviewed',
|
52
|
-
'transferPreviewError',
|
53
|
-
'transferExecutionError',
|
54
|
-
'pageLoaded',
|
55
|
-
'transferAssetSelected',
|
56
|
-
'transferNetworkSelected',
|
57
|
-
'transferAmountEntered',
|
58
|
-
'transferMfaRequired',
|
59
|
-
'transferMfaEntered',
|
60
|
-
'transferKycRequired',
|
61
|
-
'transferExecuted',
|
62
|
-
'transferInitiated',
|
63
|
-
'transferNoEligibleAssets',
|
64
|
-
'walletMessageSigned',
|
65
|
-
'verifyDonePage',
|
66
|
-
'verifyWalletRejected',
|
67
|
-
'connectionDeclined',
|
68
|
-
'transferConfigureError',
|
69
|
-
'connectionUnavailable',
|
70
|
-
'transferDeclined',
|
71
|
-
'done',
|
72
|
-
'close',
|
73
|
-
'SDKinjectedWalletProviders',
|
74
|
-
'legalTermsViewed',
|
75
|
-
'seeWhatHappenedClicked',
|
76
|
-
'executeFundingStep',
|
77
|
-
'fundingOptionsUpdated',
|
78
|
-
'fundingOptionsViewed',
|
79
|
-
'gasIncreaseWarning'
|
80
|
-
] as const
|
81
|
-
|
82
|
-
export type LinkEventTypeKeys = (typeof LINK_EVENT_TYPE_KEYS)[number]
|
83
|
-
|
84
|
-
export function isLinkEventTypeKey(key: string): key is LinkEventTypeKeys {
|
85
|
-
return LINK_EVENT_TYPE_KEYS.includes(key as LinkEventTypeKeys)
|
86
|
-
}
|
87
|
-
|
88
|
-
interface LinkEventBase {
|
89
|
-
type: LinkEventTypeKeys
|
90
|
-
}
|
91
|
-
|
92
|
-
export interface PageLoaded {
|
93
|
-
type: 'pageLoaded'
|
94
|
-
}
|
95
|
-
|
96
|
-
export interface IntegrationConnected extends LinkEventBase {
|
97
|
-
type: 'integrationConnected'
|
98
|
-
payload: LinkPayload
|
99
|
-
}
|
100
|
-
|
101
|
-
export interface IntegrationConnectionError extends LinkEventBase {
|
102
|
-
type: 'integrationConnectionError'
|
103
|
-
payload: {
|
104
|
-
errorMessage: string
|
105
|
-
}
|
106
|
-
}
|
107
|
-
|
108
|
-
export interface TransferCompleted extends LinkEventBase {
|
109
|
-
type: 'transferCompleted'
|
110
|
-
payload: TransferFinishedPayload
|
111
|
-
}
|
112
|
-
|
113
|
-
export interface IntegrationSelected extends LinkEventBase {
|
114
|
-
type: 'integrationSelected'
|
115
|
-
payload: {
|
116
|
-
integrationType: string
|
117
|
-
integrationName: string
|
118
|
-
}
|
119
|
-
}
|
120
|
-
|
121
|
-
export interface CredentialsEntered extends LinkEventBase {
|
122
|
-
type: 'credentialsEntered'
|
123
|
-
}
|
124
|
-
|
125
|
-
export interface TransferStarted extends LinkEventBase {
|
126
|
-
type: 'transferStarted'
|
127
|
-
}
|
128
|
-
|
129
|
-
export interface TransferInitiated extends LinkEventBase {
|
130
|
-
type: 'transferInitiated'
|
131
|
-
payload: {
|
132
|
-
integrationType?: string
|
133
|
-
integrationName: string
|
134
|
-
status: 'pending'
|
135
|
-
}
|
136
|
-
}
|
137
|
-
|
138
|
-
export interface TransferExecuted extends LinkEventBase {
|
139
|
-
type: 'transferExecuted'
|
140
|
-
payload: {
|
141
|
-
status: 'success' | 'pending'
|
142
|
-
txId: string
|
143
|
-
fromAddress: string
|
144
|
-
toAddress: string
|
145
|
-
symbol: string
|
146
|
-
amount: number
|
147
|
-
networkId: string
|
148
|
-
}
|
149
|
-
}
|
150
|
-
|
151
|
-
export interface TransferNoEligibleAssets extends LinkEventBase {
|
152
|
-
type: 'transferNoEligibleAssets'
|
153
|
-
payload: {
|
154
|
-
integrationType?: string
|
155
|
-
integrationName: string
|
156
|
-
noAssetsType?: string
|
157
|
-
arrayOfTokensHeld: {
|
158
|
-
symbol: string
|
159
|
-
amount: number
|
160
|
-
amountInFiat?: number
|
161
|
-
ineligibilityReason?: string
|
162
|
-
}[]
|
163
|
-
}
|
164
|
-
}
|
165
|
-
|
166
|
-
export interface TransferPreviewed extends LinkEventBase {
|
167
|
-
type: 'transferPreviewed'
|
168
|
-
payload: {
|
169
|
-
amount: number
|
170
|
-
symbol: string
|
171
|
-
toAddress: string
|
172
|
-
networkId: string
|
173
|
-
previewId: string
|
174
|
-
networkName?: string
|
175
|
-
amountInFiat?: number
|
176
|
-
estimatedNetworkGasFee?: {
|
177
|
-
fee?: number
|
178
|
-
feeCurrency?: string
|
179
|
-
feeInFiat?: number
|
180
|
-
}
|
181
|
-
}
|
182
|
-
}
|
183
|
-
|
184
|
-
export interface TransferPreviewError extends LinkEventBase {
|
185
|
-
type: 'transferPreviewError'
|
186
|
-
payload: {
|
187
|
-
errorMessage: string
|
188
|
-
}
|
189
|
-
}
|
190
|
-
|
191
|
-
export interface TransferExecutionError extends LinkEventBase {
|
192
|
-
type: 'transferExecutionError'
|
193
|
-
payload: {
|
194
|
-
errorMessage: string
|
195
|
-
}
|
196
|
-
}
|
197
|
-
|
198
|
-
export interface IntegrationMfaRequired extends LinkEventBase {
|
199
|
-
type: 'integrationMfaRequired'
|
200
|
-
}
|
201
|
-
|
202
|
-
export interface IntegrationMfaEntered extends LinkEventBase {
|
203
|
-
type: 'integrationMfaEntered'
|
204
|
-
}
|
205
|
-
|
206
|
-
export interface IntegrationOAuthStarted extends LinkEventBase {
|
207
|
-
type: 'integrationOAuthStarted'
|
208
|
-
}
|
209
|
-
|
210
|
-
export interface IntegrationAccountSelectionRequired extends LinkEventBase {
|
211
|
-
type: 'integrationAccountSelectionRequired'
|
212
|
-
}
|
213
|
-
|
214
|
-
export interface TransferAssetSelected extends LinkEventBase {
|
215
|
-
type: 'transferAssetSelected'
|
216
|
-
payload: {
|
217
|
-
symbol: string
|
218
|
-
}
|
219
|
-
}
|
220
|
-
|
221
|
-
export interface TransferNetworkSelected extends LinkEventBase {
|
222
|
-
type: 'transferNetworkSelected'
|
223
|
-
payload: {
|
224
|
-
id: string
|
225
|
-
name: string
|
226
|
-
}
|
227
|
-
}
|
228
|
-
|
229
|
-
export interface TransferAmountEntered extends LinkEventBase {
|
230
|
-
type: 'transferAmountEntered'
|
231
|
-
}
|
232
|
-
|
233
|
-
export interface TransferMfaRequired extends LinkEventBase {
|
234
|
-
type: 'transferMfaRequired'
|
235
|
-
}
|
236
|
-
|
237
|
-
export interface TransferMfaEntered extends LinkEventBase {
|
238
|
-
type: 'transferMfaEntered'
|
239
|
-
}
|
240
|
-
|
241
|
-
export interface TransferKycRequired extends LinkEventBase {
|
242
|
-
type: 'transferKycRequired'
|
243
|
-
}
|
244
|
-
|
245
|
-
export interface DoneEvent extends LinkEventBase {
|
246
|
-
type: 'done'
|
247
|
-
payload: SessionSummary
|
248
|
-
}
|
249
|
-
|
250
|
-
export interface CloseEvent extends LinkEventBase {
|
251
|
-
type: 'close'
|
252
|
-
payload: SessionSummary
|
253
|
-
}
|
254
|
-
|
255
|
-
export interface WalletMessageSigned extends LinkEventBase {
|
256
|
-
type: 'walletMessageSigned'
|
257
|
-
payload: {
|
258
|
-
signedMessageHash: string | undefined
|
259
|
-
message: string | undefined
|
260
|
-
address: string
|
261
|
-
timeStamp: number
|
262
|
-
isVerified: boolean
|
263
|
-
}
|
264
|
-
}
|
265
|
-
|
266
|
-
export interface VerifyDonePage extends LinkEventBase {
|
267
|
-
type: 'verifyDonePage'
|
268
|
-
}
|
269
|
-
|
270
|
-
export interface VerifyWalletRejected extends LinkEventBase {
|
271
|
-
type: 'verifyWalletRejected'
|
272
|
-
}
|
273
|
-
|
274
|
-
export interface SessionSummary {
|
275
|
-
/**
|
276
|
-
* Current page of application. Possible values:
|
277
|
-
* `startPage`
|
278
|
-
* `integrationsCatalogPage`
|
279
|
-
* `integrationLoginPage`
|
280
|
-
* `integrationMfaPage`
|
281
|
-
* `integrationAccountSelectPage`
|
282
|
-
* `integrationConnectedPage`
|
283
|
-
* `errorPage`
|
284
|
-
* `transferKycPage`
|
285
|
-
* `transferHoldingSelectionPage`
|
286
|
-
* `transferNetworkSelectionPage`
|
287
|
-
* `transferAmountSelectionPage`
|
288
|
-
* `transferPreviewPage`
|
289
|
-
* `transferMfaPage`
|
290
|
-
* `transferFundingPage`
|
291
|
-
* `transferExecutedPage`
|
292
|
-
* `termsAndConditionPage`
|
293
|
-
*
|
294
|
-
* This list may change in future.
|
295
|
-
*/
|
296
|
-
page: string
|
297
|
-
/** Selected integration */
|
298
|
-
selectedIntegration?: {
|
299
|
-
id?: string
|
300
|
-
name?: string
|
301
|
-
}
|
302
|
-
/** Transfer information */
|
303
|
-
transfer?: {
|
304
|
-
previewId?: string
|
305
|
-
symbol?: string
|
306
|
-
amount?: number
|
307
|
-
amountInFiat?: number
|
308
|
-
transactionId?: string
|
309
|
-
networkId?: string
|
310
|
-
}
|
311
|
-
errorMessage?: string
|
312
|
-
}
|
313
|
-
|
314
|
-
export interface SDKinjectedWalletProviders extends LinkEventBase {
|
315
|
-
type: 'SDKinjectedWalletProviders'
|
316
|
-
payload: Array<{
|
317
|
-
icon?: string
|
318
|
-
id: string
|
319
|
-
name: string
|
320
|
-
}>
|
321
|
-
}
|
322
|
-
|
323
|
-
export interface LegalTermsViewed {
|
324
|
-
type: 'legalTermsViewed'
|
325
|
-
}
|
326
|
-
|
327
|
-
export interface SeeWhatHappenedClicked {
|
328
|
-
type: 'seeWhatHappenedClicked'
|
329
|
-
}
|
330
|
-
|
331
|
-
export interface FundingOptionsUpdated {
|
332
|
-
type: 'fundingOptionsUpdated'
|
333
|
-
}
|
334
|
-
|
335
|
-
export interface FundingOptionsViewed {
|
336
|
-
type: 'fundingOptionsViewed'
|
337
|
-
}
|
338
|
-
|
339
|
-
export interface GasIncreaseWarning {
|
340
|
-
type: 'gasIncreaseWarning'
|
341
|
-
}
|
342
|
-
|
343
|
-
export interface ExecuteFundingStep {
|
344
|
-
type: 'executeFundingStep'
|
345
|
-
payload: {
|
346
|
-
cryptocurrencyFundingOptionType: string
|
347
|
-
status: string
|
348
|
-
errorMessage?: string
|
349
|
-
}
|
350
|
-
}
|
package/src/utils/popup.test.ts
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
import { addPopup, removePopup } from './popup'
|
2
|
-
|
3
|
-
describe('Popup tests', () => {
|
4
|
-
test('addPopup should add correct popup', () => {
|
5
|
-
const link = 'https://some.domain?link_style=eyJpciI6IDIsICJpbyI6IDAuOH0='
|
6
|
-
addPopup(link)
|
7
|
-
|
8
|
-
const stylesElement = document.getElementById('mesh-link-popup__styles')
|
9
|
-
expect(stylesElement).toBeTruthy()
|
10
|
-
expect(stylesElement).toMatchSnapshot()
|
11
|
-
|
12
|
-
const popupElement = document.getElementById('mesh-link-popup')
|
13
|
-
expect(popupElement).toBeTruthy()
|
14
|
-
|
15
|
-
const iframeElement = document.getElementById('mesh-link-popup__iframe')
|
16
|
-
expect(iframeElement).toBeTruthy()
|
17
|
-
expect(iframeElement?.attributes.getNamedItem('src')?.nodeValue).toBe(link)
|
18
|
-
})
|
19
|
-
|
20
|
-
test('addPopup when popup already added should replace popup', () => {
|
21
|
-
addPopup('http://localhost/1')
|
22
|
-
addPopup('http://localhost/2')
|
23
|
-
|
24
|
-
const stylesElement = document.getElementById('mesh-link-popup__styles')
|
25
|
-
expect(stylesElement).toBeTruthy()
|
26
|
-
|
27
|
-
const popupElement = document.getElementById('mesh-link-popup')
|
28
|
-
expect(popupElement).toBeTruthy()
|
29
|
-
|
30
|
-
const iframeElement = document.getElementById('mesh-link-popup__iframe')
|
31
|
-
expect(iframeElement).toBeTruthy()
|
32
|
-
expect(iframeElement?.attributes.getNamedItem('src')?.nodeValue).toBe(
|
33
|
-
'http://localhost/2'
|
34
|
-
)
|
35
|
-
})
|
36
|
-
|
37
|
-
test('removePopup should remove popup', () => {
|
38
|
-
addPopup('http://localhost/1')
|
39
|
-
removePopup()
|
40
|
-
|
41
|
-
const stylesElement = document.getElementById('mesh-link-popup__styles')
|
42
|
-
expect(stylesElement).toBeFalsy()
|
43
|
-
|
44
|
-
const popupElement = document.getElementById('mesh-link-popup')
|
45
|
-
expect(popupElement).toBeFalsy()
|
46
|
-
|
47
|
-
const iframeElement = document.getElementById('mesh-link-popup__iframe')
|
48
|
-
expect(iframeElement).toBeFalsy()
|
49
|
-
})
|
50
|
-
})
|
package/src/utils/popup.ts
DELETED
@@ -1,123 +0,0 @@
|
|
1
|
-
import { LinkStyle } from './types'
|
2
|
-
import { getLinkStyle, getNumber } from './style'
|
3
|
-
|
4
|
-
const popupId = 'mesh-link-popup'
|
5
|
-
const backdropId = 'mesh-link-popup__backdrop'
|
6
|
-
const popupContentId = 'mesh-link-popup__popup-content'
|
7
|
-
const stylesId = 'mesh-link-popup__styles'
|
8
|
-
export const iframeId = 'mesh-link-popup__iframe'
|
9
|
-
|
10
|
-
const getStylesContent = (style?: LinkStyle) => `
|
11
|
-
body {
|
12
|
-
position: fixed;
|
13
|
-
left: 0;
|
14
|
-
top: 0;
|
15
|
-
bottom: 0;
|
16
|
-
right: 0;
|
17
|
-
overflow: hidden;
|
18
|
-
}
|
19
|
-
|
20
|
-
#${popupId} {
|
21
|
-
all: unset;
|
22
|
-
position: fixed;
|
23
|
-
left: 0;
|
24
|
-
top: 0;
|
25
|
-
bottom: 0;
|
26
|
-
right: 0;
|
27
|
-
display: flex;
|
28
|
-
flex-direction: column;
|
29
|
-
align-items: center;
|
30
|
-
justify-content: center;
|
31
|
-
z-index: 10000;
|
32
|
-
}
|
33
|
-
|
34
|
-
#${backdropId} {
|
35
|
-
position: absolute;
|
36
|
-
left: 0;
|
37
|
-
top: 0;
|
38
|
-
bottom: 0;
|
39
|
-
right: 0;
|
40
|
-
z-index: 10000;
|
41
|
-
background: black;
|
42
|
-
opacity: ${getNumber(0.6, style?.io)};
|
43
|
-
}
|
44
|
-
|
45
|
-
#${popupContentId} {
|
46
|
-
position: absolute;
|
47
|
-
height: 80%;
|
48
|
-
max-height: 710px;
|
49
|
-
min-height: 685px;
|
50
|
-
margin: auto;
|
51
|
-
z-index: 10001;
|
52
|
-
width: 30%;
|
53
|
-
max-width: 430px;
|
54
|
-
min-width: 380px;
|
55
|
-
display: flex;
|
56
|
-
flex-direction: column;
|
57
|
-
border-radius: ${getNumber(24, style?.ir)}px;
|
58
|
-
flex-grow: 1;
|
59
|
-
}
|
60
|
-
|
61
|
-
#${popupContentId} iframe {
|
62
|
-
border: none;
|
63
|
-
width: 100%;
|
64
|
-
flex-grow: 1;
|
65
|
-
border-radius: ${getNumber(24, style?.ir)}px;
|
66
|
-
}
|
67
|
-
|
68
|
-
@media only screen and (max-width: 768px) {
|
69
|
-
#${popupContentId} {
|
70
|
-
height: 100vh;
|
71
|
-
width: 100vw;
|
72
|
-
max-width: 100%;
|
73
|
-
min-width: 100%;
|
74
|
-
max-height: 100%;
|
75
|
-
min-height: 100%;
|
76
|
-
border-radius: 0px;
|
77
|
-
}
|
78
|
-
|
79
|
-
#${popupContentId} iframe {
|
80
|
-
border-radius: 0px;
|
81
|
-
}
|
82
|
-
}
|
83
|
-
|
84
|
-
@media only screen and (max-height: 710px) {
|
85
|
-
#${popupContentId} {
|
86
|
-
max-height: 100%;
|
87
|
-
min-height: 100%;
|
88
|
-
}
|
89
|
-
}
|
90
|
-
`
|
91
|
-
|
92
|
-
export function removePopup(): void {
|
93
|
-
const existingPopup = window.document.getElementById(popupId)
|
94
|
-
existingPopup?.parentElement?.removeChild(existingPopup)
|
95
|
-
|
96
|
-
const existingStyles = window.document.getElementById(stylesId)
|
97
|
-
existingStyles?.parentElement?.removeChild(existingStyles)
|
98
|
-
}
|
99
|
-
|
100
|
-
export function addPopup(iframeLink: string): void {
|
101
|
-
removePopup()
|
102
|
-
|
103
|
-
const styleElement = document.createElement('style')
|
104
|
-
styleElement.id = stylesId
|
105
|
-
const style = getLinkStyle(iframeLink)
|
106
|
-
styleElement.textContent = getStylesContent(style)
|
107
|
-
window.document.head.appendChild(styleElement)
|
108
|
-
|
109
|
-
const popupRootElement = document.createElement('div')
|
110
|
-
popupRootElement.id = popupId
|
111
|
-
const popupBackdropElement = document.createElement('div')
|
112
|
-
popupBackdropElement.id = backdropId
|
113
|
-
popupRootElement.appendChild(popupBackdropElement)
|
114
|
-
const popupContentElement = document.createElement('div')
|
115
|
-
popupContentElement.id = popupContentId
|
116
|
-
const iframeElement = document.createElement('iframe')
|
117
|
-
iframeElement.id = iframeId
|
118
|
-
iframeElement.src = iframeLink
|
119
|
-
iframeElement.allow = 'clipboard-read *; clipboard-write *'
|
120
|
-
popupContentElement.appendChild(iframeElement)
|
121
|
-
popupRootElement.appendChild(popupContentElement)
|
122
|
-
window.document.body.appendChild(popupRootElement)
|
123
|
-
}
|
@@ -1,18 +0,0 @@
|
|
1
|
-
import { sdkSpecs } from './sdk-specs'
|
2
|
-
|
3
|
-
const sdkType = sdkSpecs
|
4
|
-
|
5
|
-
describe('SDK Specs', () => {
|
6
|
-
test('should return the correct SDK type', () => {
|
7
|
-
const packageJSONContent = JSON.parse(
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
9
|
-
require('fs').readFileSync('package.json', 'utf8')
|
10
|
-
)
|
11
|
-
|
12
|
-
expect(sdkType).toEqual({
|
13
|
-
platform: 'web',
|
14
|
-
version: packageJSONContent.version,
|
15
|
-
origin: 'http://localhost'
|
16
|
-
})
|
17
|
-
})
|
18
|
-
})
|
package/src/utils/sdk-specs.ts
DELETED
package/src/utils/style.test.ts
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
import { getLinkStyle, getNumber } from './style'
|
2
|
-
|
3
|
-
describe('Test style utils', () => {
|
4
|
-
test('verify function returns a style object', () => {
|
5
|
-
const link = 'https://some.domain?link_style=eyJpciI6IDI0LCAiaW8iOiAwLjF9'
|
6
|
-
const received = getLinkStyle(link)
|
7
|
-
expect(received).toEqual({ ir: 24, io: 0.1 })
|
8
|
-
})
|
9
|
-
|
10
|
-
test('verify function returns nothing on missing query param', () => {
|
11
|
-
const link = 'https://some.domain?other=12'
|
12
|
-
const received = getLinkStyle(link)
|
13
|
-
expect(received).toBeNull()
|
14
|
-
})
|
15
|
-
|
16
|
-
test('verify function returns nothing on wrong encoded value', () => {
|
17
|
-
const link = 'https://some.domain?link_style=eyJpciI6IDI0LCAiaW8iOiAwL'
|
18
|
-
const received = getLinkStyle(link)
|
19
|
-
expect(received).toBeUndefined()
|
20
|
-
})
|
21
|
-
|
22
|
-
test('verify function returns nothing on empty link', () => {
|
23
|
-
const link = ''
|
24
|
-
const received = getLinkStyle(link)
|
25
|
-
expect(received).toBeUndefined()
|
26
|
-
})
|
27
|
-
|
28
|
-
test('verify function returns correct number', () => {
|
29
|
-
expect(getNumber(10, 11)).toBe(11)
|
30
|
-
expect(getNumber(10, undefined)).toBe(10)
|
31
|
-
expect(getNumber(1, 0)).toBe(0)
|
32
|
-
})
|
33
|
-
})
|
package/src/utils/style.ts
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
import { LinkStyle } from './types'
|
2
|
-
|
3
|
-
export function getLinkStyle(url: string): LinkStyle | undefined {
|
4
|
-
try {
|
5
|
-
const params = new URLSearchParams(new URL(url).search)
|
6
|
-
const style = params.get('link_style')
|
7
|
-
return style && JSON.parse(window.atob(style))
|
8
|
-
} catch (e) {
|
9
|
-
return undefined
|
10
|
-
}
|
11
|
-
}
|
12
|
-
|
13
|
-
export function getNumber(def: number, value?: number): number {
|
14
|
-
return value !== undefined ? value : def
|
15
|
-
}
|