From 59f3ac053a86f02db0571c117c237910939fc1e2 Mon Sep 17 00:00:00 2001 From: Paolo D'Amico Date: Tue, 28 Feb 2023 21:34:42 -0800 Subject: [PATCH] fix: remove a bunch of unused phone code (#83) --- example-nextjs/pages/index.tsx | 1 - example-react/src/App.tsx | 1 - idkit/package.json | 4 --- .../IDKitWidget/States/AboutState.tsx | 7 +++-- .../IDKitWidget/States/ErrorState.tsx | 2 -- .../IDKitWidget/States/PrivacyState.tsx | 14 +--------- .../Icons/DevicePhoneMobileIcon.tsx | 20 -------------- idkit/src/lib/telemetry.ts | 9 ------- idkit/src/store/idkit.ts | 7 +---- idkit/src/types/index.ts | 27 +++++-------------- yarn.lock | 20 -------------- 11 files changed, 11 insertions(+), 101 deletions(-) delete mode 100644 idkit/src/components/Icons/DevicePhoneMobileIcon.tsx diff --git a/example-nextjs/pages/index.tsx b/example-nextjs/pages/index.tsx index 7e3c0383..de93094c 100644 --- a/example-nextjs/pages/index.tsx +++ b/example-nextjs/pages/index.tsx @@ -8,7 +8,6 @@ export default function Home() { return new Promise((resolve) => { setTimeout(() => resolve(), 3000); // NOTE: Example of how to decline the verification request and show an error message to the user - //setTimeout(() => reject({ message: "This phone number has already been used!" }), 3000); }); }, []); diff --git a/example-react/src/App.tsx b/example-react/src/App.tsx index dfe54459..abe89aa6 100644 --- a/example-react/src/App.tsx +++ b/example-react/src/App.tsx @@ -5,7 +5,6 @@ function App() { return new Promise((resolve) => { setTimeout(() => resolve(), 3000); // NOTE: Example of how to decline the verification request and show an error message to the user - //setTimeout(() => reject({ message: "This phone number has already been used!" }), 3000); }); }; diff --git a/idkit/package.json b/idkit/package.json index f26226e2..2f906345 100644 --- a/idkit/package.json +++ b/idkit/package.json @@ -61,15 +61,12 @@ "@walletconnect/types": "^2.2.0", "@walletconnect/utils": "^2.2.1", "copy-to-clipboard": "^3.3.3", - "country-telephone-data": "^0.6.3", "framer-motion": "^7.6.7", "js-sha3": "^0.8.0", - "phone": "^3.1.30", "posthog-js-lite": "2.0.0", "qr-code-styling-new": "^1.6.1", "qrcode": "^1.5.1", "react-countdown": "^2.3.4", - "react-country-flag": "^3.0.2", "react-frame-component": "^5.2.3", "react-shadow": "^19.0.3", "zustand": "^4.3.3" @@ -78,7 +75,6 @@ "@babel/core": "^7.20.2", "@babel/plugin-syntax-typescript": "^7.20.0", "@esbuild-plugins/node-globals-polyfill": "^0.1.1", - "@types/country-telephone-data": "^0.6.1", "@types/node": "18.11.9", "@types/qrcode": "^1.5.0", "@types/react": "18.0.25", diff --git a/idkit/src/components/IDKitWidget/States/AboutState.tsx b/idkit/src/components/IDKitWidget/States/AboutState.tsx index b19676c0..2901e47e 100644 --- a/idkit/src/components/IDKitWidget/States/AboutState.tsx +++ b/idkit/src/components/IDKitWidget/States/AboutState.tsx @@ -13,12 +13,11 @@ const AboutState = () => { something once without revealing personal information.

- It currently supports verification through biometrics (using a device called an Orb), and through - phone numbers. Zero-Knowledge Proofs and other cryptographic mechanisms are used to preserve - privacy. + It currently supports verification through biometrics (using a device called an Orb). Zero-Knowledge + Proofs and other cryptographic mechanisms are used to preserve privacy.

-

Apps will never see your phone number or biometrics.

+

Apps will never see your biometrics.

({ retryFlow, error export const ERROR_TITLES: Record = { [ErrorCodes.GENERIC_ERROR]: 'Something went wrong', - [ErrorCodes.INVALID_CODE]: 'Invalid code', - [ErrorCodes.PHONE_OTP_REQUEST_ERROR]: 'We could not send you a code', [ErrorCodes.REJECTED_BY_HOST_APP]: 'Verification declined by app', } diff --git a/idkit/src/components/IDKitWidget/States/PrivacyState.tsx b/idkit/src/components/IDKitWidget/States/PrivacyState.tsx index f698da35..58513995 100644 --- a/idkit/src/components/IDKitWidget/States/PrivacyState.tsx +++ b/idkit/src/components/IDKitWidget/States/PrivacyState.tsx @@ -9,16 +9,6 @@ const PrivacyState = () => { IDKit and World ID are fully privacy preserving.

    -
  • - Phone numbers are never kept by anyone. IDKit and its phone carrier only uses your number to deliver - a one-time code. -
      -
    • - Apps only receive a hash-like nullifier which can't be reversed. Worldcoin or IDKit - don't store nullifier hashes. -
    • -
    -
  • Orb biometrics analyzed by the Orb are not stored. Orb credential is used with Zero-Knowledge Proofs which makes it cryptographically impossible to track persons across applications. @@ -38,9 +28,7 @@ const PrivacyState = () => {
-

- Apps will never see your phone number or biometrics. -

+

Apps will never see your biometrics.

) diff --git a/idkit/src/components/Icons/DevicePhoneMobileIcon.tsx b/idkit/src/components/Icons/DevicePhoneMobileIcon.tsx deleted file mode 100644 index 2b24d725..00000000 --- a/idkit/src/components/Icons/DevicePhoneMobileIcon.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import type { FC, HTMLAttributes } from 'react' - -const DevicePhoneMobileIcon: FC> = props => ( - - - -) - -export default DevicePhoneMobileIcon diff --git a/idkit/src/lib/telemetry.ts b/idkit/src/lib/telemetry.ts index 9aa37c05..6d2cc9fb 100644 --- a/idkit/src/lib/telemetry.ts +++ b/idkit/src/lib/telemetry.ts @@ -1,5 +1,4 @@ import { PostHog } from 'posthog-js-lite' -import type { PhoneVerificationChannel } from '@/types' // Set at build time declare const IDKitVersion: string @@ -50,11 +49,3 @@ export const initTelemetry = (enableTelemetry?: boolean): void => { export const telemetryModalOpened = (): void => { posthog?.capture('idkit opened', SUPER_PROPS) } - -export const telemetryPhoneTyped = (): void => { - posthog?.capture('idkit phone typed', SUPER_PROPS) -} - -export const telemetryRetryCode = (channel: PhoneVerificationChannel): void => { - posthog?.capture('idkit phone code retried', { ...SUPER_PROPS, channel }) -} diff --git a/idkit/src/store/idkit.ts b/idkit/src/store/idkit.ts index 140ed313..b783b640 100644 --- a/idkit/src/store/idkit.ts +++ b/idkit/src/store/idkit.ts @@ -15,7 +15,6 @@ export type IDKitStore = { open: boolean stage: IDKITStage autoClose: boolean - phoneNumber: string processing: boolean copy: Config['copy'] theme: Config['theme'] @@ -33,7 +32,6 @@ export type IDKitStore = { setStage: (stage: IDKITStage) => void onOpenChange: (open: boolean) => void setProcessing: (processing: boolean) => void - setPhoneNumber: (phoneNumber: string) => void handleVerify: (result: ISuccessResult) => void setErrorState: (state: IErrorState | null) => void setOptions: (options: Config, source: ConfigSource) => void @@ -54,14 +52,13 @@ const useIDKitStore = create()((set, get) => ({ theme: 'light', errorTitle: '', errorDetail: '', - phoneNumber: '', autoClose: false, errorState: null, processing: false, verifyCallbacks: {}, successCallbacks: {}, stringifiedActionId: '', - methods: ['orb', 'phone'], + methods: ['orb'], stage: IDKITStage.WORLD_ID, copy: {}, @@ -79,7 +76,6 @@ const useIDKitStore = create()((set, get) => ({ setCode: code => set({ code }), setStage: stage => set({ stage }), setErrorState: errorState => set({ errorState }), - setPhoneNumber: phoneNumber => set({ phoneNumber }), setProcessing: (processing: boolean) => set({ processing }), retryFlow: () => { set({ stage: IDKITStage.WORLD_ID, errorState: null }) @@ -166,7 +162,6 @@ const useIDKitStore = create()((set, get) => ({ open, code: '', result: null, - phoneNumber: '', errorState: null, processing: false, stage: IDKITStage.WORLD_ID, diff --git a/idkit/src/types/index.ts b/idkit/src/types/index.ts index b373554e..dd9fb0d9 100644 --- a/idkit/src/types/index.ts +++ b/idkit/src/types/index.ts @@ -14,7 +14,6 @@ export enum IDKITStage { export enum CredentialType { Orb = 'orb', - Phone = 'phone', } export interface ISuccessResult { @@ -26,32 +25,18 @@ export interface ISuccessResult { export type CallbackFn = (result: ISuccessResult) => Promise | void -export interface IErrorState { - code: ErrorCodes - message?: string -} - -export enum ErrorCodes { - GENERIC_ERROR = 'GENERIC_ERROR', - PHONE_OTP_REQUEST_ERROR = 'PHONE_OTP_REQUEST_ERROR', - INVALID_CODE = 'INVALID_CODE', // OTP code is invalid - REJECTED_BY_HOST_APP = 'REJECTED_BY_HOST_APP', // Host app rejected the verification request -} - // Error response received from World app through WalletConnect export interface ExpectedErrorResponse { message: string stack: string } -export enum PhoneVerificationChannel { - SMS = 'sms', - Call = 'call', +export interface IErrorState { + code: ErrorCodes + message?: string } -export enum PhoneRequestErrorCodes { - MAX_ATTEMPTS = 'max_attempts', - TIMEOUT = 'timeout', - UNSUPPORTED_COUNTRY = 'unsupported_country', - SERVER_ERROR = 'server_error', +export enum ErrorCodes { + GENERIC_ERROR = 'GENERIC_ERROR', + REJECTED_BY_HOST_APP = 'REJECTED_BY_HOST_APP', // Host app rejected the verification request } diff --git a/yarn.lock b/yarn.lock index dfcfdeb9..30686b03 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2952,11 +2952,6 @@ dependencies: "@types/node" "*" -"@types/country-telephone-data@^0.6.1": - version "0.6.1" - resolved "https://registry.npmjs.org/@types/country-telephone-data/-/country-telephone-data-0.6.1.tgz" - integrity sha512-GjrvfnS+mFyEj1wOr5L7KKWHAcFgNxilP/AnNdQj2EM0R7c9rlM8OC+Pf2H5KHiMDbH/XjApJgdnjN/WYbzWew== - "@types/eslint-scope@^3.7.3": version "3.7.4" resolved "https://registry.npmjs.org/@types/eslint-scope/-/eslint-scope-3.7.4.tgz" @@ -5406,11 +5401,6 @@ cosmiconfig@^8.0.0: parse-json "^5.0.0" path-type "^4.0.0" -country-telephone-data@^0.6.3: - version "0.6.3" - resolved "https://registry.npmjs.org/country-telephone-data/-/country-telephone-data-0.6.3.tgz" - integrity sha512-3tQLA0vec+NDVlcaHhXGqILq/oQRsv4fRi4EedCfJqUuJUjQGdcSPM8r2IJIT2kZ5yWbiOCkXMgy7YTo8FNS2w== - create-require@^1.1.0: version "1.1.1" resolved "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz" @@ -10542,11 +10532,6 @@ performance-now@^2.1.0: resolved "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz" integrity sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow== -phone@^3.1.30: - version "3.1.33" - resolved "https://registry.npmjs.org/phone/-/phone-3.1.33.tgz" - integrity sha512-mTDJ9NsXyRxxsnhEZpdNO6PFoPxSzEW0s5gjaxgTv8rqmIcyfbNBZpKxmdifr6jJVL/0oSwiHHvL2+SNL9BVFw== - picocolors@^0.2.1: version "0.2.1" resolved "https://registry.npmjs.org/picocolors/-/picocolors-0.2.1.tgz" @@ -11490,11 +11475,6 @@ react-countdown@^2.3.4: dependencies: prop-types "^15.7.2" -react-country-flag@^3.0.2: - version "3.0.2" - resolved "https://registry.npmjs.org/react-country-flag/-/react-country-flag-3.0.2.tgz" - integrity sha512-JPaz+q3QD0/nZtHBKj5x3O7r/SgSG9kxbymdaIU0RqlDAcorJIe4KV0DFhWIdKh69q5cPVkIVERcMYGZdvXgAA== - react-dev-utils@^12.0.1: version "12.0.1" resolved "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-12.0.1.tgz"