Skip to content

Commit

Permalink
adrienne/chore: load Onfido through CDN (#10581)
Browse files Browse the repository at this point in the history
* chore: updated onfido test cases

* Update onfido-sdk-view-container.tsx

* Update index.html
  • Loading branch information
adrienne-deriv committed Oct 11, 2023
1 parent 1138070 commit cdf8c1c
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 1,575 deletions.
6 changes: 6 additions & 0 deletions __mocks__/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@
jest.mock('copy-anything', () => ({
copy: jest.fn(),
}));

const mock_onfido = {
init: jest.fn().mockResolvedValue({}),
};

window.Onfido = mock_onfido;
1,542 changes: 7 additions & 1,535 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion packages/account/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"js-cookie": "^2.2.1",
"mobx": "^6.6.1",
"mobx-react": "^7.5.1",
"onfido-sdk-ui": "^11.0.0",
"prop-types": "^15.7.2",
"qrcode.react": "^1.0.0",
"react": "^17.0.2",
Expand Down
4 changes: 0 additions & 4 deletions packages/account/src/Containers/__tests__/routes.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ jest.mock('Components/Routes', () => ({
BinaryRoutes: jest.fn(() => 'MockedBinaryRoutesComponent'),
}));

jest.mock('onfido-sdk-ui', () => ({
init: jest.fn().mockResolvedValue({}),
}));

jest.mock('@deriv/components', () => ({
...jest.requireActual('@deriv/components'),
PageError: jest.fn(() => 'MockedPageErrorComponent'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ jest.mock('@deriv/components', () => ({
Loading: jest.fn(() => 'mockedLoading'),
}));

jest.mock('onfido-sdk-ui', () => ({
init: jest.fn().mockResolvedValue({}),
}));

jest.mock('../../Helpers/verification.js', () => ({
populateVerificationStatus: jest.fn().mockReturnValue({
is_age_verified: false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useCallback } from 'react';
import countries from 'i18n-iso-countries';
import type { SdkHandle, SdkResponse, SupportedLanguages } from 'onfido-sdk-ui';
import { CSSTransition } from 'react-transition-group';
import { GetSettings, ResidenceList } from '@deriv/api-types';
import { Loading, ThemedScrollbars } from '@deriv/components';
Expand Down Expand Up @@ -35,6 +34,11 @@ type TOnfidoSdkViewContainer = {
is_default_enabled?: boolean;
};

// TODO: Update types for this later once bundle and CDN issue with Onfido is resolved
type SdkHandle = any;
type SupportedLanguages = any;
type SdkResponse = any;

const OnfidoSdkViewContainer = ({
account_settings,
country_code,
Expand Down Expand Up @@ -99,9 +103,7 @@ const OnfidoSdkViewContainer = ({
async (service_token: string) => {
if (!service_token) return;
try {
const onfido = await import('onfido-sdk-ui');

onfido_init.current = await onfido.init({
onfido_init.current = await window.Onfido.init({
containerId: 'onfido',
language: {
locale: (getLanguage().toLowerCase() as SupportedLanguages) || 'en',
Expand Down
27 changes: 0 additions & 27 deletions packages/appstore/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,33 +182,6 @@ module.exports = function (env) {
new CssMinimizerPlugin(),
]
: [],
splitChunks: {
chunks: 'all',
minChunks: 1,
cacheGroups: {
default: {
minChunks: 2,
minSize: 102400,
priority: -20,
reuseExistingChunk: true,
},
account: {
idHint: 'account',
test: /[\\/]account\//,
priority: -20,
},
onfido: {
idHint: 'onfido',
test: /[\\/]onfido\//,
priority: -10,
},
defaultVendors: {
idHint: 'vendors',
test: /[\\/]node_modules[\\/]/,
priority: -10,
},
},
},
},
devtool: is_release ? 'source-map' : 'eval-cheap-module-source-map',
externals: [
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@
</script>
<!-- End URL Handler -->

<!-- TODO: Find alternative solution for Onfido dependency -->
<script src="https://assets.onfido.com/web-sdk-releases/latest/onfido.min.js"></script>
<link href="https://assets.onfido.com/web-sdk-releases/latest/style.css" rel="stylesheet" />

<!-- Start Cookies script -->
<script src="https://static.deriv.com/scripts/cookie.js" async></script>
<!-- End Cookies script -->
Expand Down
3 changes: 3 additions & 0 deletions types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ declare global {
};
TrackJS: { console: { log: (arg0: unknown[]) => void }; track: (arg0: object) => void };
Blockly;
Onfido: {
init: (args: any) => any;
};
}
}

Expand Down

1 comment on commit cdf8c1c

@vercel
Copy link

@vercel vercel bot commented on cdf8c1c Oct 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

deriv-app – ./

deriv-app.vercel.app
deriv-app.binary.sx
binary.sx
deriv-app-git-master.binary.sx

Please sign in to comment.