@basiq/connect-auth 0.1.76 → 0.1.79

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 (98) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +159 -1
  3. package/dist/App.d.ts +3 -0
  4. package/dist/BasiqConnect.d.ts +3 -0
  5. package/dist/actions/actions.d.ts +22 -0
  6. package/dist/components/modals/LoadingModal.d.ts +8 -0
  7. package/dist/components/modals/index.d.ts +1 -0
  8. package/dist/components/pages/AuthScreen.d.ts +9 -0
  9. package/dist/components/pages/NotFound.d.ts +6 -0
  10. package/dist/components/pages/Page.d.ts +18 -0
  11. package/dist/components/pages/StartScreen.d.ts +10 -0
  12. package/dist/components/pages/index.d.ts +4 -0
  13. package/dist/components/ui/Button.d.ts +10 -0
  14. package/dist/components/ui/Modal.d.ts +9 -0
  15. package/dist/components/ui/icon.d.ts +7 -0
  16. package/dist/components/ui/index.d.ts +1 -0
  17. package/dist/connect-auth.cjs.development.js +1494 -0
  18. package/dist/connect-auth.cjs.development.js.map +1 -0
  19. package/dist/connect-auth.cjs.production.min.js +2 -0
  20. package/dist/connect-auth.cjs.production.min.js.map +1 -0
  21. package/dist/connect-auth.esm.js +1486 -0
  22. package/dist/connect-auth.esm.js.map +1 -0
  23. package/dist/helpers/constants.d.ts +1 -0
  24. package/dist/helpers/hookUtils.d.ts +2 -0
  25. package/dist/helpers/index.d.ts +3 -0
  26. package/dist/helpers/utils.d.ts +3 -0
  27. package/dist/index.d.ts +1 -0
  28. package/dist/index.js +8 -0
  29. package/dist/locales/i18n.d.ts +36 -0
  30. package/dist/setupTests.d.ts +1 -0
  31. package/dist/styledComponents/base.d.ts +4 -0
  32. package/dist/styledComponents/breakpoints.d.ts +15 -0
  33. package/dist/styledComponents/index.d.ts +4 -0
  34. package/dist/styledComponents/pages/auth.d.ts +10 -0
  35. package/dist/styledComponents/pages/basic.d.ts +23 -0
  36. package/dist/styledComponents/pages/index.d.ts +4 -0
  37. package/dist/styledComponents/pages/notFound.d.ts +9 -0
  38. package/dist/styledComponents/pages/start.d.ts +1 -0
  39. package/dist/styledComponents/styles.d.ts +2 -0
  40. package/dist/styledComponents/theme.d.ts +45 -0
  41. package/dist/styledComponents/ui/basic.d.ts +10 -0
  42. package/dist/styledComponents/ui/button.d.ts +9 -0
  43. package/dist/styledComponents/ui/index.d.ts +3 -0
  44. package/dist/styledComponents/ui/modals.d.ts +7 -0
  45. package/package.json +63 -99
  46. package/src/App.tsx +96 -0
  47. package/src/BasiqConnect.tsx +17 -0
  48. package/src/actions/actions.ts +72 -0
  49. package/src/components/modals/LoadingModal.tsx +28 -0
  50. package/src/components/modals/index.ts +1 -0
  51. package/src/components/pages/AuthScreen.tsx +96 -0
  52. package/src/components/pages/NotFound.tsx +44 -0
  53. package/src/components/pages/Page.tsx +46 -0
  54. package/src/components/pages/StartScreen.tsx +83 -0
  55. package/src/components/pages/index.ts +4 -0
  56. package/src/components/ui/Button.tsx +24 -0
  57. package/src/components/ui/Modal.tsx +29 -0
  58. package/src/components/ui/icon.tsx +18 -0
  59. package/src/components/ui/index.ts +1 -0
  60. package/src/custom.d.ts +9 -0
  61. package/{dist/25001c0659b6d43e86d2ee06256a7f63.otf → src/fonts/Mark-W1G-Bold.otf} +0 -0
  62. package/{dist/9763eea8f13903a473622431f7cb7c5c.otf → src/fonts/Mark-W1G-Book.otf} +0 -0
  63. package/src/fonts.d.ts +1 -0
  64. package/src/helpers/constants.ts +2 -0
  65. package/src/helpers/hookUtils.ts +8 -0
  66. package/src/helpers/index.ts +3 -0
  67. package/src/helpers/utils.ts +12 -0
  68. package/src/images/back.svg +8 -0
  69. package/src/images/error.svg +10 -0
  70. package/src/images/loading_indicator.svg +14 -0
  71. package/src/index.tsx +1 -0
  72. package/src/locales/en/translation.json +29 -0
  73. package/src/locales/i18n.ts +27 -0
  74. package/src/logo.svg +1 -0
  75. package/src/react-app-env.d.ts +1 -0
  76. package/src/react-i18next.d.ts +9 -0
  77. package/src/setupTests.ts +5 -0
  78. package/src/styled.d.ts +6 -0
  79. package/src/styledComponents/base.ts +73 -0
  80. package/src/styledComponents/breakpoints.ts +32 -0
  81. package/src/styledComponents/index.ts +4 -0
  82. package/src/styledComponents/pages/auth.ts +49 -0
  83. package/src/styledComponents/pages/basic.ts +126 -0
  84. package/src/styledComponents/pages/index.ts +4 -0
  85. package/src/styledComponents/pages/notFound.ts +70 -0
  86. package/src/styledComponents/pages/start.ts +6 -0
  87. package/src/styledComponents/styles.ts +25 -0
  88. package/src/styledComponents/theme.ts +58 -0
  89. package/src/styledComponents/ui/basic.ts +96 -0
  90. package/src/styledComponents/ui/button.ts +112 -0
  91. package/src/styledComponents/ui/index.ts +3 -0
  92. package/src/styledComponents/ui/modals.ts +48 -0
  93. package/.eslintignore +0 -1
  94. package/dist/60fda426a98e8c5b0470d694e2c66520.otf +0 -1
  95. package/dist/d4bd6e2e30a9c41422cecb85a045da71.otf +0 -1
  96. package/dist/main.js +0 -2
  97. package/dist/main.js.LICENSE.txt +0 -8
  98. package/tsconfig.json +0 -24
@@ -0,0 +1 @@
1
+ export declare const DASHBOARD_API_URL = "https://p4c8zn20r9.execute-api.ap-southeast-2.amazonaws.com/Production_v1/";
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const useFocus: () => (import("react").MutableRefObject<HTMLInputElement> | (() => void))[];
@@ -0,0 +1,3 @@
1
+ export * from './hookUtils';
2
+ export * from './utils';
3
+ export * from './constants';
@@ -0,0 +1,3 @@
1
+ import { SyntheticEvent } from 'react';
2
+ export declare function detectScrollToBottom(event: SyntheticEvent<HTMLDivElement>): boolean;
3
+ export declare const hexToRGBa: (hex: string, opacity: number) => string;
@@ -0,0 +1 @@
1
+ export { BasiqConnect } from './BasiqConnect';
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+
2
+ 'use strict'
3
+
4
+ if (process.env.NODE_ENV === 'production') {
5
+ module.exports = require('./connect-auth.cjs.production.min.js')
6
+ } else {
7
+ module.exports = require('./connect-auth.cjs.development.js')
8
+ }
@@ -0,0 +1,36 @@
1
+ import i18n from 'i18next';
2
+ export declare const defaultNS = "ns1";
3
+ export declare const resources: {
4
+ readonly en: {
5
+ readonly ns1: {
6
+ back: string;
7
+ error: string;
8
+ loading: string;
9
+ continue: string;
10
+ to_do_this_we_will_ask_you_to: string;
11
+ verify_your_mobile_number_bold: string;
12
+ verify_your_mobile_number: string;
13
+ consent_to_share_your_data_with_us: string;
14
+ share_your_financial_data: string;
15
+ things_you_should_know: string;
16
+ we_dont_share_your_data_without_your_consent: string;
17
+ you_can_easily_stop_sharing_your_data_at_any_time: string;
18
+ you_can_choose_to_delete_shared_data_when_we_no_longer_need_it: string;
19
+ by_proceeding_you_agree_to_the: string;
20
+ terms_of_service: string;
21
+ privacy_notice: string;
22
+ and: string;
23
+ use_basiq_to_connect_your_accounts: string;
24
+ we_use_basiq_to_connect_your_accounts: string;
25
+ please_enter_the_sms_code_sent_to_your_mobile_number: string;
26
+ new_sms_code_has_been_sent: string;
27
+ this_code_doesnt_appear_to_be_valid: string;
28
+ didnt_receive_the_code: string;
29
+ resend_sms: string;
30
+ failed_to_send_sms: string;
31
+ page_not_found: string;
32
+ missing_authentication_token: string;
33
+ };
34
+ };
35
+ };
36
+ export default i18n;
@@ -0,0 +1 @@
1
+ import '@testing-library/jest-dom';
@@ -0,0 +1,4 @@
1
+ export declare const Root: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
2
+ export declare const AppContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
3
+ export declare const AppContainerWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
4
+ export declare const AppContainerPage: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
@@ -0,0 +1,15 @@
1
+ export declare const devices: {
2
+ fold: string;
3
+ phoneXs: string;
4
+ phone: string;
5
+ phoneLandscape: string;
6
+ tabletOnly: string;
7
+ iPadProLandscape: string;
8
+ iPadProPortrait: string;
9
+ iPad: string;
10
+ tablet: string;
11
+ desktop: string;
12
+ laptop: string;
13
+ laptopRegularScreenWidth: string;
14
+ bigDesktop: string;
15
+ };
@@ -0,0 +1,4 @@
1
+ export * from './ui';
2
+ export * from './theme';
3
+ export * from './pages';
4
+ export * from './base';
@@ -0,0 +1,10 @@
1
+ interface IInputStyled {
2
+ filled: boolean;
3
+ error: boolean;
4
+ }
5
+ export declare const PageConnectFooterControl: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
6
+ export declare const PageConnectFooterText: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, {}, never>;
7
+ export declare const InputStyled: import("styled-components").StyledComponent<"input", import("styled-components").DefaultTheme, IInputStyled, never>;
8
+ export declare const InputContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
9
+ export declare const DivAsLink: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
10
+ export {};
@@ -0,0 +1,23 @@
1
+ interface IPageStyledProps {
2
+ buttonCount?: number;
3
+ horizontal?: boolean;
4
+ }
5
+ interface IStatusMessage {
6
+ error?: boolean;
7
+ }
8
+ interface IPageControlsSectionProps {
9
+ notEmpty: boolean;
10
+ }
11
+ interface IHorizontalProps {
12
+ horizontal?: boolean;
13
+ }
14
+ export declare const PageStyled: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, IPageStyledProps, never>;
15
+ export declare const PageSubtitle: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
16
+ export declare const PageMainContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
17
+ export declare const PageControlsSection: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, IPageControlsSectionProps, never>;
18
+ export declare const PageShadowWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, IHorizontalProps, never>;
19
+ export declare const PageShadow: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
20
+ export declare const PageHeader: import("styled-components").StyledComponent<"header", import("styled-components").DefaultTheme, {}, never>;
21
+ export declare const PageContent: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
22
+ export declare const StatusMessage: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, IStatusMessage, never>;
23
+ export {};
@@ -0,0 +1,4 @@
1
+ export * from './basic';
2
+ export * from './auth';
3
+ export * from './start';
4
+ export * from './notFound';
@@ -0,0 +1,9 @@
1
+ interface IStatusScreenCircleContainer {
2
+ type: 'success' | 'warning' | 'error';
3
+ }
4
+ export declare const PageStatusScreenMain: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
5
+ export declare const PageStatusScreenContent: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
6
+ export declare const StatusScreenCircleContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, IStatusScreenCircleContainer, never>;
7
+ export declare const StatusScreenErrorCode: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, {}, never>;
8
+ export declare const PageSuccessImgContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
9
+ export {};
@@ -0,0 +1 @@
1
+ export declare const InnerContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
@@ -0,0 +1,2 @@
1
+ declare const _default: import("styled-components").GlobalStyleComponent<{}, import("styled-components").DefaultTheme>;
2
+ export default _default;
@@ -0,0 +1,45 @@
1
+ export declare const theme: {
2
+ color: {
3
+ white: string;
4
+ porcelain: string;
5
+ porcelainSecond: string;
6
+ porcelainLight: string;
7
+ porcelainSecondLight: string;
8
+ iron: string;
9
+ ironSecond: string;
10
+ casper: string;
11
+ mercury: string;
12
+ dodgerBlue: string;
13
+ dodgerBlueLight: string;
14
+ royalBlue: string;
15
+ bostonBlue: string;
16
+ endeavour: string;
17
+ congressBlue: string;
18
+ brilliantBlue: string;
19
+ curiousBlue: string;
20
+ iceberg: string;
21
+ linkWater: string;
22
+ spindle: string;
23
+ cyprus: string;
24
+ gossamer: string;
25
+ emerald: string;
26
+ hokeyPokey: string;
27
+ hokeyPokeyLight: string;
28
+ anzac: string;
29
+ cerise: string;
30
+ sunsetOrange: string;
31
+ wePeep: string;
32
+ ebony: string;
33
+ abbey: string;
34
+ osloGrey: string;
35
+ loblolly: string;
36
+ jumbo: string;
37
+ blackPearl: string;
38
+ blueBayoux: string;
39
+ };
40
+ mixin: {
41
+ subtitle: () => string;
42
+ title: () => string;
43
+ };
44
+ };
45
+ export declare type ThemeType = typeof theme;
@@ -0,0 +1,10 @@
1
+ interface IIconWrapper {
2
+ rotating: boolean;
3
+ }
4
+ export declare const rotate: import("styled-components").Keyframes;
5
+ export declare const SimpleButton: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, {}, never>;
6
+ export declare const Input: import("styled-components").StyledComponent<"input", import("styled-components").DefaultTheme, {}, never>;
7
+ export declare const H4Styled: import("styled-components").StyledComponent<"h4", import("styled-components").DefaultTheme, {}, never>;
8
+ export declare const Spacer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
9
+ export declare const IconWrapper: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, IIconWrapper, never>;
10
+ export {};
@@ -0,0 +1,9 @@
1
+ import { ButtonType } from '../../components/ui/Button';
2
+ export declare const ButtonLabel: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, {}, never>;
3
+ interface IButtonStyled {
4
+ buttonType?: ButtonType;
5
+ disabled: boolean;
6
+ onClick: () => void;
7
+ }
8
+ export declare const ButtonStyled: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, IButtonStyled, never>;
9
+ export {};
@@ -0,0 +1,3 @@
1
+ export * from './basic';
2
+ export * from './button';
3
+ export * from './modals';
@@ -0,0 +1,7 @@
1
+ interface IModalStyled {
2
+ disableTransparency: boolean;
3
+ }
4
+ export declare const ModalStyled: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, IModalStyled, never>;
5
+ export declare const LoadingModalStyled: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, IModalStyled, never>;
6
+ export declare const LoadingModalText: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, {}, never>;
7
+ export {};
package/package.json CHANGED
@@ -1,100 +1,64 @@
1
1
  {
2
- "name": "@basiq/connect-auth",
3
- "version": "0.1.76",
4
- "dependencies": {
5
- "@testing-library/jest-dom": "^5.16.4",
6
- "@testing-library/react": "^13.2.0",
7
- "@testing-library/user-event": "^13.5.0",
8
- "@types/jest": "^27.5.0",
9
- "@types/node": "^16.11.33",
10
- "@types/react": "^18.0.9",
11
- "@types/react-dom": "^18.0.3",
12
- "@types/styled-components": "^5.1.25",
13
- "i18next": "^21.8.1",
14
- "react": "^18.1.0",
15
- "react-dom": "^18.1.0",
16
- "react-i18next": "^11.16.9",
17
- "react-router-dom": "^6.3.0",
18
- "react-scripts": "5.0.1",
19
- "styled-components": "^5.3.5",
20
- "ts-loader": "^9.3.0",
21
- "typescript": "^4.6.4",
22
- "web-vitals": "^2.1.4"
23
- },
24
- "peerDependencies": {
25
- "react": "^18.1.0",
26
- "react-dom": "^18.1.0"
27
- },
28
- "scripts": {
29
- "start": "react-scripts start",
30
- "build": "webpack --mode production",
31
- "test": "react-scripts test",
32
- "eject": "react-scripts eject",
33
- "lint": "eslint .",
34
- "lint:fix": "eslint --fix",
35
- "format": "prettier --write './**/*.{js,jsx,ts,tsx,css,scss,json}' --config ./.prettierrc"
36
- },
37
- "browserslist": {
38
- "production": [
39
- ">0.2%",
40
- "not dead",
41
- "not op_mini all"
42
- ],
43
- "development": [
44
- "last 1 chrome version",
45
- "last 1 firefox version",
46
- "last 1 safari version"
47
- ]
48
- },
49
- "resolutions": {
50
- "styled-components": "^5"
51
- },
52
- "devDependencies": {
53
- "@babel/cli": "^7.17.10",
54
- "@babel/core": "^7.18.2",
55
- "@babel/preset-env": "^7.18.2",
56
- "@babel/preset-typescript": "^7.16.7",
57
- "@typescript-eslint/eslint-plugin": "^5.26.0",
58
- "@typescript-eslint/parser": "^5.26.0",
59
- "babel-plugin-styled-components": "^2.0.7",
60
- "eslint": "^8.16.0",
61
- "eslint-config-airbnb": "^19.0.4",
62
- "eslint-config-prettier": "^8.5.0",
63
- "eslint-import-resolver-typescript": "^2.7.1",
64
- "eslint-plugin-import": "^2.26.0",
65
- "eslint-plugin-jsx-a11y": "^6.5.1",
66
- "eslint-plugin-prettier": "^4.0.0",
67
- "eslint-plugin-react": "^7.30.0",
68
- "eslint-plugin-react-hooks": "^4.5.0",
69
- "prettier": "^2.6.2",
70
- "url-loader": "^4.1.1",
71
- "webpack-cli": "^4.9.2"
72
- },
73
- "babel": {
74
- "presets": [
75
- "@babel/preset-typescript"
76
- ],
77
- "plugins": [
78
- "babel-plugin-styled-components"
79
- ]
80
- },
81
- "description": "Basiq sms auth for redirection to basiq consent ui",
82
- "main": "dist/main.js",
83
- "repository": {
84
- "type": "git",
85
- "url": "git+https://github.com/basiqio/connect-code-validaiton.git"
86
- },
87
- "keywords": [
88
- "sms",
89
- "code",
90
- "validation",
91
- "basiq",
92
- "connect"
93
- ],
94
- "author": "Basiq",
95
- "license": "ISC",
96
- "bugs": {
97
- "url": "https://github.com/basiqio/connect-code-validaiton/issues"
98
- },
99
- "homepage": "https://github.com/basiqio/connect-code-validaiton#readme"
100
- }
2
+ "version": "0.1.79",
3
+ "license": "MIT",
4
+ "main": "dist/index.js",
5
+ "typings": "dist/index.d.ts",
6
+ "files": ["dist", "src"],
7
+ "engines": {
8
+ "node": ">=10"
9
+ },
10
+ "scripts": {
11
+ "start": "tsdx watch",
12
+ "build": "tsdx build",
13
+ "test": "tsdx test --passWithNoTests",
14
+ "lint": "tsdx lint",
15
+ "prepare": "tsdx build",
16
+ "size": "size-limit",
17
+ "analyze": "size-limit --why"
18
+ },
19
+ "peerDependencies": {
20
+ "react": ">=16"
21
+ },
22
+ "husky": {
23
+ "hooks": {
24
+ "pre-commit": "tsdx lint"
25
+ }
26
+ },
27
+ "prettier": {
28
+ "printWidth": 80,
29
+ "semi": true,
30
+ "singleQuote": true,
31
+ "trailingComma": "es5"
32
+ },
33
+ "name": "@basiq/connect-auth",
34
+ "author": "Basiq",
35
+ "module": "dist/connect-auth.esm.js",
36
+ "size-limit": [{
37
+ "path": "dist/connect-auth.cjs.production.min.js",
38
+ "limit": "10 KB"
39
+ }, {
40
+ "path": "dist/connect-auth.esm.js",
41
+ "limit": "10 KB"
42
+ }],
43
+ "devDependencies": {
44
+ "@size-limit/preset-small-lib": "^7.0.8",
45
+ "@types/react": "^18.0.10",
46
+ "@types/react-dom": "^18.0.5",
47
+ "husky": "^8.0.1",
48
+ "react": "^18.1.0",
49
+ "react-dom": "^18.1.0",
50
+ "size-limit": "^7.0.8",
51
+ "tsdx": "^0.14.1",
52
+ "tslib": "^2.4.0",
53
+ "typescript": "^3.9.10",
54
+ "rollup-plugin-url": "^3.0.1",
55
+ "@rollup/plugin-image": "^2.1.1",
56
+ "@types/styled-components": "^5.1.25",
57
+ "i18next": "^21.8.1",
58
+ "react-i18next": "^11.16.9"
59
+
60
+ },
61
+ "dependencies": {
62
+ "styled-components": "^5.3.5"
63
+ }
64
+ }
package/src/App.tsx ADDED
@@ -0,0 +1,96 @@
1
+ import React, { createRef, SyntheticEvent, useEffect, useState } from 'react';
2
+ import { AppContainer, AppContainerPage, AppContainerWrapper, PageHeader, Root } from './styledComponents';
3
+ import GlobalStyles from './styledComponents/styles';
4
+ import { detectScrollToBottom } from './helpers';
5
+ import {AuthScreen, NotFound, Page, StartScreen} from './components/pages';
6
+ import { authUser } from './actions/actions';
7
+ import { LoadingModal } from './components/modals';
8
+
9
+ function App() {
10
+ const ref = createRef<HTMLDivElement>();
11
+ const [shadow, setShadow] = useState(false);
12
+ const [currentScreen, setCurrentScreen] = useState(0);
13
+ const [loading, setLoading] = useState(true);
14
+ const [authId, setAuthId] = useState('');
15
+ const [mobile, setMobile] = useState('');
16
+ const [logo, setLogo] = useState('');
17
+ const [appName, setAppName] = useState('');
18
+ const [errorCode, setErrorCode] = useState('');
19
+
20
+ const handleConnectionsScroll = (event: SyntheticEvent<HTMLDivElement>) => {
21
+ setShadow(detectScrollToBottom(event));
22
+ };
23
+
24
+ useEffect(() => {
25
+ const getData = async () => {
26
+ const id = window.location.pathname.substring(1);
27
+ if (id?.length > 0) {
28
+ setAuthId(id);
29
+ setLoading(true);
30
+ const response = await authUser(id, 'GET');
31
+ if (response?.data?.status === 'code-not-sent') {
32
+ setCurrentScreen(1);
33
+ setMobile(response?.data?.mobile);
34
+ if (response?.data?.appName) {
35
+ setAppName(response?.data?.appName);
36
+ }
37
+ if (response?.data?.partner?.logoUrl) {
38
+ setLogo(response?.data?.partner?.logoUrl);
39
+ }
40
+ } else {
41
+ showErrorScreen(response?.statusCode.toString());
42
+ }
43
+ setLoading(false);
44
+ } else {
45
+ showErrorScreen('404');
46
+ }
47
+ };
48
+ getData();
49
+ }, []);
50
+
51
+ const showErrorScreen = (code: string) => {
52
+ setErrorCode(code);
53
+ setCurrentScreen(3);
54
+ };
55
+
56
+ const getScreen = () => {
57
+ switch (currentScreen) {
58
+ case 0:
59
+ return <Page shadow={shadow}><LoadingModal isOpen={loading} disableTransparency /></Page>;
60
+ case 1:
61
+ return (
62
+ <StartScreen
63
+ appName={appName}
64
+ shadow={shadow}
65
+ showErrorScreen={showErrorScreen}
66
+ onContinue={() => setCurrentScreen(2)}
67
+ authId={authId}
68
+ />
69
+ );
70
+ case 2:
71
+ return <AuthScreen number={mobile} onBack={() => setCurrentScreen(1)} shadow={shadow} authId={authId} />;
72
+ case 3:
73
+ return <NotFound messageCode={errorCode} />;
74
+ default:
75
+ return <NotFound messageCode={errorCode} />;
76
+ }
77
+ };
78
+
79
+ return (
80
+ <Root>
81
+ <GlobalStyles />
82
+ <AppContainerWrapper>
83
+ <AppContainer onScroll={handleConnectionsScroll} ref={ref}>
84
+ {logo && (
85
+ <PageHeader>
86
+ <img src={logo} alt="logo" />
87
+ </PageHeader>
88
+ )}
89
+ <AppContainerPage>{getScreen()}</AppContainerPage>
90
+ </AppContainer>
91
+ </AppContainerWrapper>
92
+ </Root>
93
+ );
94
+ }
95
+
96
+ export default App;
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { ThemeProvider } from 'styled-components';
3
+ import App from './App';
4
+ import './locales/i18n';
5
+ import { theme } from './styledComponents';
6
+
7
+ export function BasiqConnect() {
8
+ return(
9
+ <React.StrictMode>
10
+ <ThemeProvider theme={theme}>
11
+ <App />
12
+ </ThemeProvider>
13
+ </React.StrictMode>
14
+ );
15
+
16
+ }
17
+
@@ -0,0 +1,72 @@
1
+ import { DASHBOARD_API_URL } from '../helpers';
2
+
3
+ export const verifySmsCode = async (authRequestId: string, smsCode: string) => {
4
+ const body = {
5
+ 'sms-code': smsCode
6
+ };
7
+
8
+ const reqData = {
9
+ headers: {
10
+ 'Content-Type': 'application/json',
11
+ Authorization: `Basic SMS_CODE:${authRequestId}`
12
+ },
13
+ method: 'POST',
14
+ body: JSON.stringify(body)
15
+ };
16
+
17
+ const result = await fetch(`${DASHBOARD_API_URL}client_auth/${authRequestId}/token`, reqData);
18
+
19
+ if (result.status >= 200 && result.status < 300) {
20
+ const json = result.status === 204 ? null : await result.json();
21
+ return {
22
+ data: json,
23
+ headers: result.headers,
24
+ statusCode: result.status
25
+ };
26
+ }
27
+ if (result.status >= 400) {
28
+ return {
29
+ headers: result.headers,
30
+ statusCode: result.status,
31
+ error: result.statusText || 'Something went wrong'
32
+ };
33
+ }
34
+ return {
35
+ headers: result.headers,
36
+ statusCode: result.status,
37
+ error: result.statusText || 'Something went wrong'
38
+ };
39
+ };
40
+
41
+ export const authUser = async (authRequestId: string, method: 'POST' | 'GET' = 'POST') => {
42
+ const reqData = {
43
+ headers: {
44
+ 'Content-Type': 'application/json'
45
+ },
46
+ method
47
+ };
48
+
49
+ const result = await fetch(`${DASHBOARD_API_URL}client_auth/${authRequestId}`, reqData);
50
+
51
+ if (result.status >= 200 && result.status < 300) {
52
+ const json = result.status === 204 ? null : await result.json();
53
+ return {
54
+ data: json,
55
+ headers: result.headers,
56
+ statusCode: result.status
57
+ };
58
+ }
59
+ if (result.status >= 400) {
60
+ const json = result.status === 403 ? null : await result.json();
61
+ return {
62
+ headers: result.headers,
63
+ statusCode: result.status,
64
+ error: json.message || result.statusText || 'Something went wrong'
65
+ };
66
+ }
67
+ return {
68
+ headers: result.headers,
69
+ statusCode: result.status,
70
+ error: result.statusText || 'Something went wrong'
71
+ };
72
+ };
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import Modal from '../ui/Modal';
4
+ import { LoadingModalStyled, LoadingModalText } from '../../styledComponents';
5
+ import Icon from '../ui/icon';
6
+ import loadingIndicator from '../../images/loading_indicator.svg';
7
+
8
+ interface IProps {
9
+ isOpen: boolean;
10
+ disableTransparency?: boolean;
11
+ loadingText?: string;
12
+ }
13
+
14
+ function LoadingModal(props: IProps) {
15
+ const { isOpen, disableTransparency, loadingText } = props;
16
+ const { t } = useTranslation();
17
+
18
+ return (
19
+ <Modal isOpen={isOpen} disableTransparency={!!disableTransparency}>
20
+ <LoadingModalStyled disableTransparency={!!disableTransparency}>
21
+ <Icon img={loadingIndicator} rotating />
22
+ <LoadingModalText>{loadingText || t<string>('loading')}</LoadingModalText>
23
+ </LoadingModalStyled>
24
+ </Modal>
25
+ );
26
+ }
27
+
28
+ export default LoadingModal;
@@ -0,0 +1 @@
1
+ export { default as LoadingModal } from './LoadingModal';