zh-web-sdk 2.16.1 → 2.17.0

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.
Files changed (51) hide show
  1. package/README.md +225 -32
  2. package/package.json +6 -1
  3. package/.eslintrc.js +0 -12
  4. package/.github/CHANGELOG_TEMPLATE.md +0 -73
  5. package/.github/PULL_REQUEST_TEMPLATE.md +0 -10
  6. package/.github/backup/publish-tag.yaml +0 -14
  7. package/.github/workflows/build.yaml +0 -13
  8. package/.github/workflows/pr.yaml +0 -14
  9. package/.github/workflows/publish.yaml +0 -13
  10. package/.github/workflows/security.yml +0 -15
  11. package/.github/workflows/tag.yaml +0 -14
  12. package/RELEASING.md +0 -39
  13. package/jest.config.js +0 -8
  14. package/jest.setup.js +0 -24
  15. package/scripts/build.js +0 -34
  16. package/scripts/zip.js +0 -49
  17. package/src/__tests__/jwt-auth-detection.test.ts +0 -96
  18. package/src/api/convert-token.ts +0 -23
  19. package/src/constants.ts +0 -2
  20. package/src/hooks/__tests__/use-window-size.test.tsx +0 -26
  21. package/src/hooks/use-window-size.ts +0 -19
  22. package/src/iframe-container/AppContainer.tsx +0 -495
  23. package/src/iframe-container/__tests__/AppContainer.test.tsx +0 -300
  24. package/src/iframe-container/hooks/__tests__/use-style-updates.test.ts +0 -430
  25. package/src/iframe-container/hooks/use-style-updates.ts +0 -82
  26. package/src/index.tsx +0 -645
  27. package/src/redux/actions/index.ts +0 -27
  28. package/src/redux/reducers/constants.ts +0 -10
  29. package/src/redux/reducers/crypto-account-link-payouts.ts +0 -60
  30. package/src/redux/reducers/crypto-account-link.ts +0 -60
  31. package/src/redux/reducers/crypto-buy.ts +0 -75
  32. package/src/redux/reducers/crypto-sell.ts +0 -64
  33. package/src/redux/reducers/crypto-withdrawals.ts +0 -64
  34. package/src/redux/reducers/fiat-account-link.ts +0 -60
  35. package/src/redux/reducers/fiat-deposits.ts +0 -64
  36. package/src/redux/reducers/fiat-withdrawals.ts +0 -64
  37. package/src/redux/reducers/fund.ts +0 -75
  38. package/src/redux/reducers/index.ts +0 -35
  39. package/src/redux/reducers/onboarding.ts +0 -74
  40. package/src/redux/reducers/pay.ts +0 -64
  41. package/src/redux/reducers/payouts.ts +0 -64
  42. package/src/redux/reducers/profile.ts +0 -63
  43. package/src/redux/store/index.ts +0 -10
  44. package/src/styles.ts +0 -108
  45. package/src/types.ts +0 -578
  46. package/src/utils/auth-to-fund-mapper.ts +0 -174
  47. package/src/utils/strings.ts +0 -19
  48. package/src/utils/test-utils.tsx +0 -36
  49. package/src/utils/world-app-utils.ts +0 -8
  50. package/src/utils.ts +0 -27
  51. package/tsconfig.json +0 -26
@@ -1,64 +0,0 @@
1
- import { AppIdentifier } from "../../types";
2
- import { appIdentifierToActionPrefixMap } from "../../types";
3
- import {
4
- ACTION_SET_JWT,
5
- ACTION_SET_MODAL_STATE,
6
- ACTION_APP_LOADED
7
- } from "./constants";
8
-
9
- export interface IPayState {
10
- jwt: string;
11
- isAppLoaded: boolean;
12
- isAppActive: boolean;
13
- }
14
-
15
- export interface IPayAction {
16
- type: string;
17
- jwt?: string;
18
- isAppActive?: boolean;
19
- isAppLoaded?: boolean;
20
- }
21
-
22
- const INITIAL_STATE: IPayState = {
23
- jwt: "",
24
- isAppActive: false,
25
- isAppLoaded: false
26
- }
27
-
28
- const applySetIsAppActive = (state: IPayState, action: IPayAction) : IPayState => {
29
- return {
30
- ...state,
31
- isAppActive: !!action.isAppActive,
32
- }
33
- }
34
-
35
- const applySetSendJWTToApp = (state: IPayState, action: IPayAction) : IPayState => {
36
- return {
37
- ...state,
38
- isAppLoaded: !!action.isAppLoaded,
39
- }
40
- }
41
-
42
- const applySetJWT = (state: IPayState, action: IPayAction) : IPayState => {
43
- return {
44
- ...state,
45
- jwt: action.jwt as string,
46
- }
47
- }
48
-
49
- const reducerMap: { [actionType: string]: (state: IPayState, action: IPayAction) => IPayState } = {
50
- // Pay reducer
51
- [`${appIdentifierToActionPrefixMap.get(AppIdentifier.PAY)}${ACTION_SET_JWT}`]: applySetJWT,
52
- [`${appIdentifierToActionPrefixMap.get(AppIdentifier.PAY)}${ACTION_SET_MODAL_STATE}`]: applySetIsAppActive,
53
- [`${appIdentifierToActionPrefixMap.get(AppIdentifier.PAY)}${ACTION_APP_LOADED}`]: applySetSendJWTToApp,
54
- };
55
-
56
- const PayReducer = (state = INITIAL_STATE, action: IPayAction) => {
57
- if (!!action.type && !!reducerMap[action.type]) {
58
- return reducerMap[action.type](state, action);
59
- } else {
60
- return state;
61
- }
62
- }
63
-
64
- export default PayReducer;
@@ -1,64 +0,0 @@
1
- import { AppIdentifier } from "../../types";
2
- import { appIdentifierToActionPrefixMap } from "../../types";
3
- import {
4
- ACTION_SET_JWT,
5
- ACTION_SET_MODAL_STATE,
6
- ACTION_APP_LOADED
7
- } from "./constants";
8
-
9
- export interface IPayoutsState {
10
- jwt: string;
11
- isAppLoaded: boolean;
12
- isAppActive: boolean;
13
- }
14
-
15
- export interface IPayoutsAction {
16
- type: string;
17
- jwt?: string;
18
- isAppActive?: boolean;
19
- isAppLoaded?: boolean;
20
- }
21
-
22
- const INITIAL_STATE: IPayoutsState = {
23
- jwt: "",
24
- isAppActive: false,
25
- isAppLoaded: false
26
- }
27
-
28
- const applySetIsAppActive = (state: IPayoutsState, action: IPayoutsAction) : IPayoutsState => {
29
- return {
30
- ...state,
31
- isAppActive: !!action.isAppActive,
32
- }
33
- }
34
-
35
- const applySetSendJWTToApp = (state: IPayoutsState, action: IPayoutsAction) : IPayoutsState => {
36
- return {
37
- ...state,
38
- isAppLoaded: !!action.isAppLoaded,
39
- }
40
- }
41
-
42
- const applySetJWT = (state: IPayoutsState, action: IPayoutsAction) : IPayoutsState => {
43
- return {
44
- ...state,
45
- jwt: action.jwt as string,
46
- }
47
- }
48
-
49
- const reducerMap: { [actionType: string]: (state: IPayoutsState, action: IPayoutsAction) => IPayoutsState } = {
50
- // Payouts reducer
51
- [`${appIdentifierToActionPrefixMap.get(AppIdentifier.PAYOUTS)}${ACTION_SET_JWT}`]: applySetJWT,
52
- [`${appIdentifierToActionPrefixMap.get(AppIdentifier.PAYOUTS)}${ACTION_SET_MODAL_STATE}`]: applySetIsAppActive,
53
- [`${appIdentifierToActionPrefixMap.get(AppIdentifier.PAYOUTS)}${ACTION_APP_LOADED}`]: applySetSendJWTToApp,
54
- };
55
-
56
- const payoutsReducer = (state = INITIAL_STATE, action: IPayoutsAction) => {
57
- if (!!action.type && !!reducerMap[action.type]) {
58
- return reducerMap[action.type](state, action);
59
- } else {
60
- return state;
61
- }
62
- }
63
-
64
- export default payoutsReducer;
@@ -1,63 +0,0 @@
1
- import { AppIdentifier } from "../../types";
2
- import { appIdentifierToActionPrefixMap } from "../../types";
3
- import {
4
- ACTION_SET_JWT,
5
- ACTION_SET_MODAL_STATE,
6
- ACTION_APP_LOADED
7
- } from "./constants";
8
-
9
- export interface ProfileState {
10
- jwt: string;
11
- isAppLoaded: boolean;
12
- isAppActive: boolean;
13
- }
14
-
15
- export interface ProfileAction {
16
- type: string;
17
- jwt?: string;
18
- isAppActive?: boolean;
19
- isAppLoaded?: boolean;
20
- }
21
-
22
- const INITIAL_STATE: ProfileState = {
23
- jwt: "",
24
- isAppActive: false,
25
- isAppLoaded: false
26
- }
27
-
28
- const applySetIsAppActive = (state: ProfileState, action: ProfileAction) : ProfileState => {
29
- return {
30
- ...state,
31
- isAppActive: !!action.isAppActive,
32
- }
33
- }
34
-
35
- const applySetSendJWTToApp = (state: ProfileState, action: ProfileAction) : ProfileState => {
36
- return {
37
- ...state,
38
- isAppLoaded: !!action.isAppLoaded,
39
- }
40
- }
41
-
42
- const applySetJWT = (state: ProfileState, action: ProfileAction) : ProfileState => {
43
- return {
44
- ...state,
45
- jwt: action.jwt as string,
46
- }
47
- }
48
-
49
- const reducerMap: { [actionType: string]: (state: ProfileState, action: ProfileAction) => ProfileState } = {
50
- [`${appIdentifierToActionPrefixMap.get(AppIdentifier.PROFILE)}${ACTION_SET_JWT}`]: applySetJWT,
51
- [`${appIdentifierToActionPrefixMap.get(AppIdentifier.PROFILE)}${ACTION_SET_MODAL_STATE}`]: applySetIsAppActive,
52
- [`${appIdentifierToActionPrefixMap.get(AppIdentifier.PROFILE)}${ACTION_APP_LOADED}`]: applySetSendJWTToApp,
53
- };
54
-
55
- const profileReducer = (state = INITIAL_STATE, action: ProfileAction) => {
56
- if (!!action.type && !!reducerMap[action.type]) {
57
- return reducerMap[action.type](state, action);
58
- } else {
59
- return state;
60
- }
61
- }
62
-
63
- export default profileReducer;
@@ -1,10 +0,0 @@
1
- import {legacy_createStore as createStore} from "redux";
2
- import rootReducer from "../reducers";
3
-
4
- const store = createStore(rootReducer);
5
-
6
- export default store;
7
-
8
- export type RootState = ReturnType<typeof rootReducer>
9
- export type AppStore = ReturnType<typeof createStore>
10
- export type AppDispatch = AppStore['dispatch']
package/src/styles.ts DELETED
@@ -1,108 +0,0 @@
1
- import { CSSProperties } from "react";
2
-
3
- const MTE_SM = 480;
4
- const MTE_MD = 720;
5
-
6
- /**
7
- * Returns the modal border radius based on device type
8
- * Mobile devices: 0
9
- * Desktop/Laptop: 24
10
- */
11
- export const getBorderRadius = (): number => {
12
- const userAgent = navigator?.userAgent?.toLowerCase();
13
- const isMobileUA = /iphone|ipad|ipod|android|webos|blackberry|windows phone/i.test(userAgent);
14
- const hasTouchScreen = 'ontouchstart' in window || navigator?.maxTouchPoints > 0;
15
-
16
- const isMobile = isMobileUA || hasTouchScreen;
17
-
18
- return isMobile ? 0 : 24;
19
- }
20
-
21
- export const screenSizes: { id: string, size: number }[] = [
22
- {
23
- id: "MTE_SM",
24
- size: MTE_SM,
25
- },
26
- {
27
- id: "MTE_MD",
28
- size: MTE_MD,
29
- },
30
- ]
31
-
32
- /**
33
- * When the width is smaller than
34
- *
35
- */
36
- export const minWidthMatcher = (): string => {
37
- for (let i = 0; i < screenSizes.length; i++) {
38
- const { id, size } = screenSizes[i];
39
- if (window.matchMedia(`(min-width: ${size}px`).matches) {
40
- return id
41
- }
42
- }
43
- return "ANY"
44
- }
45
-
46
- export const containerStyle: CSSProperties = {
47
- paddingRight: 0,
48
- paddingLeft: 0,
49
- marginRight: "auto",
50
- marginLeft: "auto",
51
- maxHeight: 812
52
- }
53
-
54
- export const containerMediaStyles: { [id: string]: CSSProperties } = {
55
- MTE_SM: {
56
- width: 480
57
- },
58
- MTE_MD: {
59
- width: 720
60
- },
61
- ANY: {
62
- width: "100%",
63
- height: "100%",
64
- maxWidth: "100%",
65
- maxHeight: "100%"
66
- },
67
- }
68
-
69
- export const appWrapperStyle: CSSProperties = {
70
- position: "fixed",
71
- top: 0,
72
- left: 0,
73
- zIndex: 999999,
74
- display: "flex",
75
- justifyContent: "center",
76
- alignItems: "center",
77
- flexDirection: "column",
78
- width: "100vw",
79
- height: CSS.supports("height: 100dvh") ? "100dvh" : window.innerHeight + "px",
80
- maxHeight: CSS.supports("height: 100dvh") ? "100dvh" : window.innerHeight + "px",
81
- background: "rgba(0,0,0,0.5)",
82
- cursor: "pointer"
83
- }
84
-
85
- export const modalStyle: CSSProperties = {
86
- padding: 0,
87
- backgroundColor: "#FFF",
88
- height: "calc(100% - 100px)",
89
- maxWidth: "calc(100% - 30px)",
90
- borderRadius: getBorderRadius()
91
- }
92
-
93
- export const iframeWrapperStyle: CSSProperties = {
94
- width: "100%",
95
- height: "100%",
96
- border: "none",
97
- overflow: "hidden"
98
- };
99
-
100
- export const iframeStyle: CSSProperties = {
101
- width: "100%",
102
- height: "100%",
103
- border: "none",
104
- margin: 0,
105
- padding: 0,
106
- overflow: "hidden",
107
- borderRadius: getBorderRadius(),
108
- };