chayns-api 3.5.1 → 3.6.0-beta.1
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/dist/cjs/constants/trustedDomains.js +7 -0
- package/dist/cjs/hooks/index.js +7 -0
- package/dist/cjs/hooks/useFunctionsWithOverrides.js +74 -0
- package/dist/cjs/host/iframe/HostIframe.js +4 -0
- package/dist/cjs/wrapper/AppWrapper.js +29 -1
- package/dist/cjs/wrapper/FrameWrapper.js +8 -1
- package/dist/esm/constants/trustedDomains.js +1 -0
- package/dist/esm/hooks/index.js +1 -0
- package/dist/esm/hooks/useFunctionsWithOverrides.js +67 -0
- package/dist/esm/host/iframe/HostIframe.js +4 -0
- package/dist/esm/wrapper/AppWrapper.js +29 -1
- package/dist/esm/wrapper/FrameWrapper.js +8 -1
- package/dist/esm/wrapper/StaticChaynsApi.js +1 -0
- package/dist/types/constants/trustedDomains.d.ts +1 -0
- package/dist/types/hooks/index.d.ts +1 -0
- package/dist/types/hooks/useFunctionsWithOverrides.d.ts +4 -0
- package/dist/types/types/IChaynsReact.d.ts +2 -1
- package/dist/types/wrapper/AppWrapper.d.ts +2 -0
- package/dist/types/wrapper/FrameWrapper.d.ts +1 -0
- package/dist/types/wrapper/StaticChaynsApi.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DefaultTrustedDomains = void 0;
|
|
7
|
+
const DefaultTrustedDomains = exports.DefaultTrustedDomains = ['.tobit.com', '.chayns.net', '.tobit.cloud', '.chayns-static.space', '.az-chayns.space', '.tobit.ag', 'localhost', '127.0.0.1', '::1'];
|
package/dist/cjs/hooks/index.js
CHANGED
|
@@ -135,6 +135,12 @@ Object.defineProperty(exports, "useFunctions", {
|
|
|
135
135
|
return _useFunctions.useFunctions;
|
|
136
136
|
}
|
|
137
137
|
});
|
|
138
|
+
Object.defineProperty(exports, "useFunctionsWithOverrides", {
|
|
139
|
+
enumerable: true,
|
|
140
|
+
get: function () {
|
|
141
|
+
return _useFunctionsWithOverrides.useFunctionsWithOverrides;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
138
144
|
Object.defineProperty(exports, "useGeoLocation", {
|
|
139
145
|
enumerable: true,
|
|
140
146
|
get: function () {
|
|
@@ -270,6 +276,7 @@ var _useEnvironment = require("./useEnvironment");
|
|
|
270
276
|
var _useLanguage = require("./useLanguage");
|
|
271
277
|
var _useValues = require("./useValues");
|
|
272
278
|
var _useFunctions = require("./useFunctions");
|
|
279
|
+
var _useFunctionsWithOverrides = require("./useFunctionsWithOverrides");
|
|
273
280
|
var _useCurrentPage = require("./useCurrentPage");
|
|
274
281
|
var _useCustomData = require("./useCustomData");
|
|
275
282
|
var _useDialogState = require("./useDialogState");
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useFunctionsWithOverrides = void 0;
|
|
7
|
+
var _reactCompilerRuntime = require("react-compiler-runtime");
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _useFunctions = require("./useFunctions");
|
|
10
|
+
const useFunctionsWithOverrides = overrideFactory => {
|
|
11
|
+
const $ = (0, _reactCompilerRuntime.c)(12);
|
|
12
|
+
const base = (0, _useFunctions.useFunctions)();
|
|
13
|
+
let t0;
|
|
14
|
+
if ($[0] !== base || $[1] !== overrideFactory) {
|
|
15
|
+
t0 = overrideFactory(base);
|
|
16
|
+
$[0] = base;
|
|
17
|
+
$[1] = overrideFactory;
|
|
18
|
+
$[2] = t0;
|
|
19
|
+
} else {
|
|
20
|
+
t0 = $[2];
|
|
21
|
+
}
|
|
22
|
+
const overrides = t0;
|
|
23
|
+
let t1;
|
|
24
|
+
if ($[3] !== base || $[4] !== overrides) {
|
|
25
|
+
t1 = {
|
|
26
|
+
base,
|
|
27
|
+
overrides
|
|
28
|
+
};
|
|
29
|
+
$[3] = base;
|
|
30
|
+
$[4] = overrides;
|
|
31
|
+
$[5] = t1;
|
|
32
|
+
} else {
|
|
33
|
+
t1 = $[5];
|
|
34
|
+
}
|
|
35
|
+
const stateRef = (0, _react.useRef)(t1);
|
|
36
|
+
let t2;
|
|
37
|
+
let t3;
|
|
38
|
+
if ($[6] !== base || $[7] !== overrides) {
|
|
39
|
+
t2 = () => {
|
|
40
|
+
stateRef.current = {
|
|
41
|
+
base,
|
|
42
|
+
overrides
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
t3 = [base, overrides];
|
|
46
|
+
$[6] = base;
|
|
47
|
+
$[7] = overrides;
|
|
48
|
+
$[8] = t2;
|
|
49
|
+
$[9] = t3;
|
|
50
|
+
} else {
|
|
51
|
+
t2 = $[8];
|
|
52
|
+
t3 = $[9];
|
|
53
|
+
}
|
|
54
|
+
(0, _react.useEffect)(t2, t3);
|
|
55
|
+
let functions;
|
|
56
|
+
if ($[10] !== base) {
|
|
57
|
+
functions = {};
|
|
58
|
+
for (const key of Object.keys(base)) {
|
|
59
|
+
functions[key] = (...t4) => {
|
|
60
|
+
var _stateRef$current$ove;
|
|
61
|
+
const args = t4;
|
|
62
|
+
const functionKey = key;
|
|
63
|
+
const implementation = (_stateRef$current$ove = stateRef.current.overrides[functionKey]) !== null && _stateRef$current$ove !== void 0 ? _stateRef$current$ove : stateRef.current.base[functionKey];
|
|
64
|
+
return implementation(...args);
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
$[10] = base;
|
|
68
|
+
$[11] = functions;
|
|
69
|
+
} else {
|
|
70
|
+
functions = $[11];
|
|
71
|
+
}
|
|
72
|
+
return functions;
|
|
73
|
+
};
|
|
74
|
+
exports.useFunctionsWithOverrides = useFunctionsWithOverrides;
|
|
@@ -8,6 +8,7 @@ var _lodash = _interopRequireDefault(require("lodash.throttle"));
|
|
|
8
8
|
var _getUserInfo = _interopRequireDefault(require("../calls/getUserInfo"));
|
|
9
9
|
var _sendMessage = require("../calls/sendMessage");
|
|
10
10
|
var _constants = require("../constants");
|
|
11
|
+
var _trustedDomains = require("../constants/trustedDomains");
|
|
11
12
|
var _languages = require("../constants/languages");
|
|
12
13
|
var _DialogHandler = _interopRequireDefault(require("../handler/DialogHandler"));
|
|
13
14
|
var _apiListener = require("../utils/apiListener");
|
|
@@ -23,6 +24,7 @@ class AppWrapper {
|
|
|
23
24
|
history = null;
|
|
24
25
|
accessToken = '';
|
|
25
26
|
latestAppleSafeArea = null;
|
|
27
|
+
trustedDomains = _trustedDomains.DefaultTrustedDomains;
|
|
26
28
|
listeners = [];
|
|
27
29
|
customFunctions = {};
|
|
28
30
|
nextDialogEventId = 0;
|
|
@@ -41,6 +43,24 @@ class AppWrapper {
|
|
|
41
43
|
}
|
|
42
44
|
return undefined;
|
|
43
45
|
}
|
|
46
|
+
async loadTrustedDomains() {
|
|
47
|
+
try {
|
|
48
|
+
var _AbortSignal$timeout2, _AbortSignal2;
|
|
49
|
+
const res = await fetch('https://service-rpc.chayns.net/ConfigurationSettings/TrustedDomains', {
|
|
50
|
+
signal: (_AbortSignal$timeout2 = (_AbortSignal2 = AbortSignal).timeout) === null || _AbortSignal$timeout2 === void 0 ? void 0 : _AbortSignal$timeout2.call(_AbortSignal2, 5000)
|
|
51
|
+
});
|
|
52
|
+
if (res.status === 200) {
|
|
53
|
+
const {
|
|
54
|
+
trustedDomains
|
|
55
|
+
} = await res.json();
|
|
56
|
+
return trustedDomains;
|
|
57
|
+
}
|
|
58
|
+
console.error(`[chayns-api] failed to load trusted domains with status code: ${res.status}`);
|
|
59
|
+
} catch (ex) {
|
|
60
|
+
console.error('[chayns-api] failed to load trusted domains', ex);
|
|
61
|
+
}
|
|
62
|
+
return _trustedDomains.DefaultTrustedDomains;
|
|
63
|
+
}
|
|
44
64
|
mapOldApiToNew(retVal) {
|
|
45
65
|
var _window, _window2, _AppInfo$TappSelected;
|
|
46
66
|
const {
|
|
@@ -395,6 +415,14 @@ class AppWrapper {
|
|
|
395
415
|
};
|
|
396
416
|
(0, _appCall.default)(callObj);
|
|
397
417
|
},
|
|
418
|
+
isTrustedUrl: async url => {
|
|
419
|
+
try {
|
|
420
|
+
const parsedUrl = new URL(url);
|
|
421
|
+
return this.trustedDomains.some(domain => parsedUrl.hostname.endsWith(domain));
|
|
422
|
+
} catch {
|
|
423
|
+
return false;
|
|
424
|
+
}
|
|
425
|
+
},
|
|
398
426
|
login: async (value = {}, callback, closeCallback) => {
|
|
399
427
|
const {
|
|
400
428
|
result,
|
|
@@ -765,7 +793,7 @@ class AppWrapper {
|
|
|
765
793
|
dialogs = [];
|
|
766
794
|
async init() {
|
|
767
795
|
this.values = this.mapOldApiToNew(await this.appCall(18));
|
|
768
|
-
this.values.styleSettings = await this.loadStyleSettings(this.values.site.id);
|
|
796
|
+
[this.values.styleSettings, this.trustedDomains] = await Promise.all([this.loadStyleSettings(this.values.site.id), this.loadTrustedDomains()]);
|
|
769
797
|
document.documentElement.classList.add('chayns-api--app');
|
|
770
798
|
this.appCall(66, {
|
|
771
799
|
enabled: true
|
|
@@ -19,6 +19,7 @@ class FrameWrapper {
|
|
|
19
19
|
exposedFunctions = null;
|
|
20
20
|
exposedCustomFunctions = {};
|
|
21
21
|
exposedCustomFunctionNames = [];
|
|
22
|
+
exposedFunctionNames = [];
|
|
22
23
|
ready = new Promise(res => {
|
|
23
24
|
this.resolve = res;
|
|
24
25
|
});
|
|
@@ -107,6 +108,11 @@ class FrameWrapper {
|
|
|
107
108
|
if (!this.initialized) await this.ready;
|
|
108
109
|
return this.exposedFunctions.invokeDialogCall(value, callback && comlink.proxy(result => callback(result)));
|
|
109
110
|
},
|
|
111
|
+
isTrustedUrl: async url => {
|
|
112
|
+
if (!this.initialized) await this.ready;
|
|
113
|
+
if (!this.exposedFunctionNames.includes('isTrustedUrl')) return true;
|
|
114
|
+
return this.exposedFunctions.isTrustedUrl(url);
|
|
115
|
+
},
|
|
110
116
|
login: async (value, callback, closeCallback) => {
|
|
111
117
|
if (!this.initialized) await this.ready;
|
|
112
118
|
return this.exposedFunctions.login(value, callback && comlink.proxy(result => callback(result)), closeCallback && comlink.proxy(() => closeCallback()));
|
|
@@ -355,7 +361,7 @@ class FrameWrapper {
|
|
|
355
361
|
}
|
|
356
362
|
}
|
|
357
363
|
async init() {
|
|
358
|
-
var _await$exposed$_custo;
|
|
364
|
+
var _await$exposed$_funct, _await$exposed$_custo;
|
|
359
365
|
if (this.initialized) return;
|
|
360
366
|
const exposed = comlink.wrap(comlink.windowEndpoint(window.parent))[window.name];
|
|
361
367
|
const dataListener = () => exposed.addDataListener(comlink.proxy(({
|
|
@@ -386,6 +392,7 @@ class FrameWrapper {
|
|
|
386
392
|
if (hostReadyCallback) window.removeEventListener('message', hostReadyCallback);
|
|
387
393
|
this.values = await exposed.getInitialData();
|
|
388
394
|
this.exposedFunctions = exposed.functions;
|
|
395
|
+
this.exposedFunctionNames = (_await$exposed$_funct = await exposed._functionNames) !== null && _await$exposed$_funct !== void 0 ? _await$exposed$_funct : [];
|
|
389
396
|
this.exposedCustomFunctions = exposed.customFunctions;
|
|
390
397
|
this.exposedCustomFunctionNames = (_await$exposed$_custo = await exposed._customFunctionNames) !== null && _await$exposed$_custo !== void 0 ? _await$exposed$_custo : [];
|
|
391
398
|
this.customFunctions = this.exposedCustomFunctionNames.reduce((p, e) => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const DefaultTrustedDomains = ['.tobit.com', '.chayns.net', '.tobit.cloud', '.chayns-static.space', '.az-chayns.space', '.tobit.ag', 'localhost', '127.0.0.1', '::1'];
|
package/dist/esm/hooks/index.js
CHANGED
|
@@ -13,6 +13,7 @@ export { useEnvironment } from './useEnvironment';
|
|
|
13
13
|
export { useLanguage } from './useLanguage';
|
|
14
14
|
export { useValues } from './useValues';
|
|
15
15
|
export { useFunctions } from './useFunctions';
|
|
16
|
+
export { useFunctionsWithOverrides } from './useFunctionsWithOverrides';
|
|
16
17
|
export { useCurrentPage } from './useCurrentPage';
|
|
17
18
|
export { useCustomData } from './useCustomData';
|
|
18
19
|
export { useDialogState, useDialogData } from './useDialogState';
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { c as _c } from "react-compiler-runtime";
|
|
2
|
+
import { useEffect, useMemo, useRef } from 'react';
|
|
3
|
+
import { useFunctions } from './useFunctions';
|
|
4
|
+
export const useFunctionsWithOverrides = overrideFactory => {
|
|
5
|
+
const $ = _c(12);
|
|
6
|
+
const base = useFunctions();
|
|
7
|
+
let t0;
|
|
8
|
+
if ($[0] !== base || $[1] !== overrideFactory) {
|
|
9
|
+
t0 = overrideFactory(base);
|
|
10
|
+
$[0] = base;
|
|
11
|
+
$[1] = overrideFactory;
|
|
12
|
+
$[2] = t0;
|
|
13
|
+
} else {
|
|
14
|
+
t0 = $[2];
|
|
15
|
+
}
|
|
16
|
+
const overrides = t0;
|
|
17
|
+
let t1;
|
|
18
|
+
if ($[3] !== base || $[4] !== overrides) {
|
|
19
|
+
t1 = {
|
|
20
|
+
base,
|
|
21
|
+
overrides
|
|
22
|
+
};
|
|
23
|
+
$[3] = base;
|
|
24
|
+
$[4] = overrides;
|
|
25
|
+
$[5] = t1;
|
|
26
|
+
} else {
|
|
27
|
+
t1 = $[5];
|
|
28
|
+
}
|
|
29
|
+
const stateRef = useRef(t1);
|
|
30
|
+
let t2;
|
|
31
|
+
let t3;
|
|
32
|
+
if ($[6] !== base || $[7] !== overrides) {
|
|
33
|
+
t2 = () => {
|
|
34
|
+
stateRef.current = {
|
|
35
|
+
base,
|
|
36
|
+
overrides
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
t3 = [base, overrides];
|
|
40
|
+
$[6] = base;
|
|
41
|
+
$[7] = overrides;
|
|
42
|
+
$[8] = t2;
|
|
43
|
+
$[9] = t3;
|
|
44
|
+
} else {
|
|
45
|
+
t2 = $[8];
|
|
46
|
+
t3 = $[9];
|
|
47
|
+
}
|
|
48
|
+
useEffect(t2, t3);
|
|
49
|
+
let functions;
|
|
50
|
+
if ($[10] !== base) {
|
|
51
|
+
functions = {};
|
|
52
|
+
for (const key of Object.keys(base)) {
|
|
53
|
+
functions[key] = (...t4) => {
|
|
54
|
+
var _stateRef$current$ove;
|
|
55
|
+
const args = t4;
|
|
56
|
+
const functionKey = key;
|
|
57
|
+
const implementation = (_stateRef$current$ove = stateRef.current.overrides[functionKey]) !== null && _stateRef$current$ove !== void 0 ? _stateRef$current$ove : stateRef.current.base[functionKey];
|
|
58
|
+
return implementation(...args);
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
$[10] = base;
|
|
62
|
+
$[11] = functions;
|
|
63
|
+
} else {
|
|
64
|
+
functions = $[11];
|
|
65
|
+
}
|
|
66
|
+
return functions;
|
|
67
|
+
};
|
|
@@ -5,6 +5,7 @@ import throttle from 'lodash.throttle';
|
|
|
5
5
|
import getUserInfo from '../calls/getUserInfo';
|
|
6
6
|
import { sendMessageToGroup, sendMessageToPage, sendMessageToUser } from '../calls/sendMessage';
|
|
7
7
|
import { DefaultLoginDialogOptions } from '../constants';
|
|
8
|
+
import { DefaultTrustedDomains } from '../constants/trustedDomains';
|
|
8
9
|
import { DeviceLanguage } from '../constants/languages';
|
|
9
10
|
import DialogHandler from '../handler/DialogHandler';
|
|
10
11
|
import { addApiListener, dispatchApiEvent, removeApiListener } from '../utils/apiListener';
|
|
@@ -29,6 +30,24 @@ export class AppWrapper {
|
|
|
29
30
|
}
|
|
30
31
|
return undefined;
|
|
31
32
|
}
|
|
33
|
+
async loadTrustedDomains() {
|
|
34
|
+
try {
|
|
35
|
+
var _AbortSignal$timeout2, _AbortSignal2;
|
|
36
|
+
const res = await fetch('https://service-rpc.chayns.net/ConfigurationSettings/TrustedDomains', {
|
|
37
|
+
signal: (_AbortSignal$timeout2 = (_AbortSignal2 = AbortSignal).timeout) === null || _AbortSignal$timeout2 === void 0 ? void 0 : _AbortSignal$timeout2.call(_AbortSignal2, 5000)
|
|
38
|
+
});
|
|
39
|
+
if (res.status === 200) {
|
|
40
|
+
const {
|
|
41
|
+
trustedDomains
|
|
42
|
+
} = await res.json();
|
|
43
|
+
return trustedDomains;
|
|
44
|
+
}
|
|
45
|
+
console.error(`[chayns-api] failed to load trusted domains with status code: ${res.status}`);
|
|
46
|
+
} catch (ex) {
|
|
47
|
+
console.error('[chayns-api] failed to load trusted domains', ex);
|
|
48
|
+
}
|
|
49
|
+
return DefaultTrustedDomains;
|
|
50
|
+
}
|
|
32
51
|
mapOldApiToNew(retVal) {
|
|
33
52
|
var _window, _window2, _AppInfo$TappSelected;
|
|
34
53
|
const {
|
|
@@ -149,6 +168,7 @@ export class AppWrapper {
|
|
|
149
168
|
_defineProperty(this, "history", null);
|
|
150
169
|
_defineProperty(this, "accessToken", '');
|
|
151
170
|
_defineProperty(this, "latestAppleSafeArea", null);
|
|
171
|
+
_defineProperty(this, "trustedDomains", DefaultTrustedDomains);
|
|
152
172
|
_defineProperty(this, "listeners", []);
|
|
153
173
|
_defineProperty(this, "customFunctions", {});
|
|
154
174
|
_defineProperty(this, "nextDialogEventId", 0);
|
|
@@ -358,6 +378,14 @@ export class AppWrapper {
|
|
|
358
378
|
};
|
|
359
379
|
invokeAppCall(callObj);
|
|
360
380
|
},
|
|
381
|
+
isTrustedUrl: async url => {
|
|
382
|
+
try {
|
|
383
|
+
const parsedUrl = new URL(url);
|
|
384
|
+
return this.trustedDomains.some(domain => parsedUrl.hostname.endsWith(domain));
|
|
385
|
+
} catch {
|
|
386
|
+
return false;
|
|
387
|
+
}
|
|
388
|
+
},
|
|
361
389
|
login: async (value = {}, callback, closeCallback) => {
|
|
362
390
|
const {
|
|
363
391
|
result,
|
|
@@ -771,7 +799,7 @@ export class AppWrapper {
|
|
|
771
799
|
}
|
|
772
800
|
async init() {
|
|
773
801
|
this.values = this.mapOldApiToNew(await this.appCall(18));
|
|
774
|
-
this.values.styleSettings = await this.loadStyleSettings(this.values.site.id);
|
|
802
|
+
[this.values.styleSettings, this.trustedDomains] = await Promise.all([this.loadStyleSettings(this.values.site.id), this.loadTrustedDomains()]);
|
|
775
803
|
document.documentElement.classList.add('chayns-api--app');
|
|
776
804
|
this.appCall(66, {
|
|
777
805
|
enabled: true
|
|
@@ -15,6 +15,7 @@ export class FrameWrapper {
|
|
|
15
15
|
_defineProperty(this, "exposedFunctions", null);
|
|
16
16
|
_defineProperty(this, "exposedCustomFunctions", {});
|
|
17
17
|
_defineProperty(this, "exposedCustomFunctionNames", []);
|
|
18
|
+
_defineProperty(this, "exposedFunctionNames", []);
|
|
18
19
|
_defineProperty(this, "ready", new Promise(res => {
|
|
19
20
|
this.resolve = res;
|
|
20
21
|
}));
|
|
@@ -103,6 +104,11 @@ export class FrameWrapper {
|
|
|
103
104
|
if (!this.initialized) await this.ready;
|
|
104
105
|
return this.exposedFunctions.invokeDialogCall(value, callback && comlink.proxy(result => callback(result)));
|
|
105
106
|
},
|
|
107
|
+
isTrustedUrl: async url => {
|
|
108
|
+
if (!this.initialized) await this.ready;
|
|
109
|
+
if (!this.exposedFunctionNames.includes('isTrustedUrl')) return true;
|
|
110
|
+
return this.exposedFunctions.isTrustedUrl(url);
|
|
111
|
+
},
|
|
106
112
|
login: async (value, callback, closeCallback) => {
|
|
107
113
|
if (!this.initialized) await this.ready;
|
|
108
114
|
return this.exposedFunctions.login(value, callback && comlink.proxy(result => callback(result)), closeCallback && comlink.proxy(() => closeCallback()));
|
|
@@ -359,7 +365,7 @@ export class FrameWrapper {
|
|
|
359
365
|
}
|
|
360
366
|
}
|
|
361
367
|
async init() {
|
|
362
|
-
var _await$exposed$_custo;
|
|
368
|
+
var _await$exposed$_funct, _await$exposed$_custo;
|
|
363
369
|
if (this.initialized) return;
|
|
364
370
|
const exposed = comlink.wrap(comlink.windowEndpoint(window.parent))[window.name];
|
|
365
371
|
const dataListener = () => exposed.addDataListener(comlink.proxy(({
|
|
@@ -390,6 +396,7 @@ export class FrameWrapper {
|
|
|
390
396
|
if (hostReadyCallback) window.removeEventListener('message', hostReadyCallback);
|
|
391
397
|
this.values = await exposed.getInitialData();
|
|
392
398
|
this.exposedFunctions = exposed.functions;
|
|
399
|
+
this.exposedFunctionNames = (_await$exposed$_funct = await exposed._functionNames) !== null && _await$exposed$_funct !== void 0 ? _await$exposed$_funct : [];
|
|
393
400
|
this.exposedCustomFunctions = exposed.customFunctions;
|
|
394
401
|
this.exposedCustomFunctionNames = (_await$exposed$_custo = await exposed._customFunctionNames) !== null && _await$exposed$_custo !== void 0 ? _await$exposed$_custo : [];
|
|
395
402
|
this.customFunctions = this.exposedCustomFunctionNames.reduce((p, e) => {
|
|
@@ -28,6 +28,7 @@ class StaticChaynsApi {
|
|
|
28
28
|
_defineProperty(this, "invokeCall", void 0);
|
|
29
29
|
_defineProperty(this, "invokePaymentCall", void 0);
|
|
30
30
|
_defineProperty(this, "invokeDialogCall", void 0);
|
|
31
|
+
_defineProperty(this, "isTrustedUrl", void 0);
|
|
31
32
|
_defineProperty(this, "login", void 0);
|
|
32
33
|
_defineProperty(this, "logout", void 0);
|
|
33
34
|
_defineProperty(this, "navigateBack", void 0);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DefaultTrustedDomains: string[];
|
|
@@ -13,6 +13,7 @@ export { useEnvironment } from './useEnvironment';
|
|
|
13
13
|
export { useLanguage } from './useLanguage';
|
|
14
14
|
export { useValues } from './useValues';
|
|
15
15
|
export { useFunctions } from './useFunctions';
|
|
16
|
+
export { useFunctionsWithOverrides } from './useFunctionsWithOverrides';
|
|
16
17
|
export { useCurrentPage } from './useCurrentPage';
|
|
17
18
|
export { useCustomData } from './useCustomData';
|
|
18
19
|
export { useDialogState, useDialogData } from './useDialogState';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ChaynsReactFunctions } from '../types/IChaynsReact';
|
|
2
|
+
type FunctionsOverrideFactory = (base: ChaynsReactFunctions) => Partial<ChaynsReactFunctions>;
|
|
3
|
+
export declare const useFunctionsWithOverrides: (overrideFactory: FunctionsOverrideFactory) => ChaynsReactFunctions;
|
|
4
|
+
export {};
|
|
@@ -168,7 +168,7 @@ export interface DialogInput {
|
|
|
168
168
|
* Not supported in app environments due to security reasons.
|
|
169
169
|
* @param input
|
|
170
170
|
*/
|
|
171
|
-
formatter?: (input: string) => string;
|
|
171
|
+
formatter?: (input: string) => Promise<string> | string;
|
|
172
172
|
regex?: string;
|
|
173
173
|
autoComplete?: string;
|
|
174
174
|
inputMode?: HTMLAttributes<HTMLInputElement>["inputMode"];
|
|
@@ -446,6 +446,7 @@ export interface ChaynsReactFunctions {
|
|
|
446
446
|
invokeCall: (value: InvokeCall, callback?: (result: any) => void) => Promise<any>;
|
|
447
447
|
invokePaymentCall: <T>(value: InvokeCall, callback?: (result: T) => void) => Promise<T>;
|
|
448
448
|
invokeDialogCall: (value: InvokeCall, callback?: (result: any) => void) => Promise<any>;
|
|
449
|
+
isTrustedUrl: (url: string) => Promise<boolean>;
|
|
449
450
|
login: (value?: Login, callback?: (result: boolean) => void, closeCallback?: () => void) => Promise<LoginResult>;
|
|
450
451
|
logout: () => Promise<void>;
|
|
451
452
|
navigateBack: () => Promise<void>;
|
|
@@ -4,10 +4,12 @@ export declare class AppWrapper implements IChaynsReact {
|
|
|
4
4
|
history: IChaynsReact['history'];
|
|
5
5
|
accessToken: string;
|
|
6
6
|
latestAppleSafeArea: null;
|
|
7
|
+
private trustedDomains;
|
|
7
8
|
listeners: (() => void)[];
|
|
8
9
|
customFunctions: {};
|
|
9
10
|
nextDialogEventId: number;
|
|
10
11
|
loadStyleSettings(siteId: string): Promise<ChaynsStyleSettings | undefined>;
|
|
12
|
+
loadTrustedDomains(): Promise<string[]>;
|
|
11
13
|
mapOldApiToNew(retVal: any): ChaynsReactValues;
|
|
12
14
|
constructor();
|
|
13
15
|
chaynsApiId: string;
|
|
@@ -5,6 +5,7 @@ export declare class FrameWrapper implements IChaynsReact {
|
|
|
5
5
|
private exposedFunctions;
|
|
6
6
|
private exposedCustomFunctions;
|
|
7
7
|
private exposedCustomFunctionNames;
|
|
8
|
+
private exposedFunctionNames;
|
|
8
9
|
ready: Promise<unknown>;
|
|
9
10
|
values: ChaynsReactValues;
|
|
10
11
|
history: FrameHistoryLayer | null;
|
|
@@ -18,6 +18,7 @@ declare class StaticChaynsApi implements ChaynsReactFunctions {
|
|
|
18
18
|
invokeCall: ChaynsReactFunctions['invokeCall'];
|
|
19
19
|
invokePaymentCall: ChaynsReactFunctions['invokePaymentCall'];
|
|
20
20
|
invokeDialogCall: ChaynsReactFunctions['invokeDialogCall'];
|
|
21
|
+
isTrustedUrl: ChaynsReactFunctions['isTrustedUrl'];
|
|
21
22
|
login: ChaynsReactFunctions['login'];
|
|
22
23
|
logout: ChaynsReactFunctions['logout'];
|
|
23
24
|
navigateBack: ChaynsReactFunctions['navigateBack'];
|