@smile_identity/react-native 10.0.0-beta01
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/LICENSE +20 -0
- package/README.md +78 -0
- package/android/build.gradle +155 -0
- package/android/gradle.properties +6 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/assets/smile_config.json +9 -0
- package/android/src/main/java/com/smileidentity/react/SmileIdModule.kt +97 -0
- package/android/src/main/java/com/smileidentity/react/SmileIdPackage.kt +50 -0
- package/android/src/main/java/com/smileidentity/react/utils/ReactUtils.kt +91 -0
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDBVNConsentViewManager.kt +42 -0
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDBiometricKYCViewManager.kt +42 -0
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDDocumentVerificationViewManager.kt +42 -0
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDSmartSelfieAuthenticationViewManager.kt +42 -0
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDSmartSelfieEnrollmentViewManager.kt +42 -0
- package/android/src/main/java/com/smileidentity/react/views/SmileIDBVNConsentScreen.kt +54 -0
- package/android/src/main/java/com/smileidentity/react/views/SmileIDBiometricKYC.kt +89 -0
- package/android/src/main/java/com/smileidentity/react/views/SmileIDDocumentVerification.kt +59 -0
- package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieAuthentication.kt +47 -0
- package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieEnrollment.kt +48 -0
- package/android/src/main/java/com/smileidentity/react/views/SmileIDView.kt +121 -0
- package/android/src/newarch/SmileIdSpec.kt +7 -0
- package/android/src/oldarch/SmileIdSpec.kt +13 -0
- package/ios/SmileId.h +12 -0
- package/ios/SmileId.mm +27 -0
- package/ios/SmileId.xcodeproj/project.pbxproj +274 -0
- package/ios/SmileId.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
- package/lib/commonjs/NativeSmileId.js +10 -0
- package/lib/commonjs/NativeSmileId.js.map +1 -0
- package/lib/commonjs/index.js +52 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/NativeSmileId.js +3 -0
- package/lib/module/NativeSmileId.js.map +1 -0
- package/lib/module/index.js +38 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/NativeSmileId.d.ts +9 -0
- package/lib/typescript/NativeSmileId.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +89 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/package.json +169 -0
- package/react-native-smile-id.podspec +42 -0
- package/src/NativeSmileId.ts +14 -0
- package/src/index.tsx +150 -0
package/package.json
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@smile_identity/react-native",
|
|
3
|
+
"version": "10.0.0-beta01",
|
|
4
|
+
"description": "Official wrapper for the Smile ID <v10 android and iOS SDKs",
|
|
5
|
+
"main": "lib/commonjs/index",
|
|
6
|
+
"module": "lib/module/index",
|
|
7
|
+
"types": "lib/typescript/index.d.ts",
|
|
8
|
+
"react-native": "src/index",
|
|
9
|
+
"source": "src/index",
|
|
10
|
+
"files": [
|
|
11
|
+
"src",
|
|
12
|
+
"lib",
|
|
13
|
+
"android",
|
|
14
|
+
"ios",
|
|
15
|
+
"cpp",
|
|
16
|
+
"*.podspec",
|
|
17
|
+
"!lib/typescript/example",
|
|
18
|
+
"!ios/build",
|
|
19
|
+
"!android/build",
|
|
20
|
+
"!android/gradle",
|
|
21
|
+
"!android/gradlew",
|
|
22
|
+
"!android/gradlew.bat",
|
|
23
|
+
"!android/local.properties",
|
|
24
|
+
"!**/__tests__",
|
|
25
|
+
"!**/__fixtures__",
|
|
26
|
+
"!**/__mocks__",
|
|
27
|
+
"!**/.*"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"test": "jest",
|
|
31
|
+
"typecheck": "tsc --noEmit",
|
|
32
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
33
|
+
"prepack": "bob build",
|
|
34
|
+
"release": "release-it",
|
|
35
|
+
"example": "yarn --cwd example",
|
|
36
|
+
"build:android": "cd example/android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a",
|
|
37
|
+
"build:ios": "cd example/ios && xcodebuild -workspace SmileIdExample.xcworkspace -scheme SmileIdExample -configuration Debug -sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO",
|
|
38
|
+
"bootstrap": "yarn example && yarn install && yarn example pods",
|
|
39
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build"
|
|
40
|
+
},
|
|
41
|
+
"keywords": [
|
|
42
|
+
"react-native",
|
|
43
|
+
"ios",
|
|
44
|
+
"android"
|
|
45
|
+
],
|
|
46
|
+
"repository": "https://docs.usesmileid.com/",
|
|
47
|
+
"author": "Smile ID <japhet@smileidentity.com> (https://docs.usesmileid.com/)",
|
|
48
|
+
"license": "MIT",
|
|
49
|
+
"bugs": {
|
|
50
|
+
"url": "https://docs.usesmileid.com//issues"
|
|
51
|
+
},
|
|
52
|
+
"homepage": "https://docs.usesmileid.com/#readme",
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"registry": "https://registry.npmjs.org/"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@commitlint/config-conventional": "^17.0.2",
|
|
58
|
+
"@evilmartians/lefthook": "^1.2.2",
|
|
59
|
+
"@react-native-community/eslint-config": "^3.0.2",
|
|
60
|
+
"@release-it/conventional-changelog": "^5.0.0",
|
|
61
|
+
"@types/jest": "^28.1.2",
|
|
62
|
+
"@types/react": "~17.0.21",
|
|
63
|
+
"@types/react-native": "0.70.0",
|
|
64
|
+
"commitlint": "^17.0.2",
|
|
65
|
+
"del-cli": "^5.0.0",
|
|
66
|
+
"eslint": "^8.4.1",
|
|
67
|
+
"eslint-config-prettier": "^8.5.0",
|
|
68
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
69
|
+
"generate-changelog": "^1.8.0",
|
|
70
|
+
"jest": "^28.1.1",
|
|
71
|
+
"pod-install": "^0.1.0",
|
|
72
|
+
"prettier": "^2.0.5",
|
|
73
|
+
"react": "18.2.0",
|
|
74
|
+
"react-native": "0.72.4",
|
|
75
|
+
"react-native-builder-bob": "^0.20.0",
|
|
76
|
+
"release-it": "^15.0.0",
|
|
77
|
+
"turbo": "^1.10.7",
|
|
78
|
+
"typescript": "^5.0.2"
|
|
79
|
+
},
|
|
80
|
+
"resolutions": {
|
|
81
|
+
"@types/react": "17.0.21"
|
|
82
|
+
},
|
|
83
|
+
"peerDependencies": {
|
|
84
|
+
"react": "*",
|
|
85
|
+
"react-native": "*"
|
|
86
|
+
},
|
|
87
|
+
"engines": {
|
|
88
|
+
"node": ">= 16.0.0"
|
|
89
|
+
},
|
|
90
|
+
"packageManager": "^yarn@1.22.15",
|
|
91
|
+
"jest": {
|
|
92
|
+
"preset": "react-native",
|
|
93
|
+
"modulePathIgnorePatterns": [
|
|
94
|
+
"<rootDir>/example/node_modules",
|
|
95
|
+
"<rootDir>/lib/"
|
|
96
|
+
]
|
|
97
|
+
},
|
|
98
|
+
"commitlint": {
|
|
99
|
+
"extends": [
|
|
100
|
+
"@commitlint/config-conventional"
|
|
101
|
+
]
|
|
102
|
+
},
|
|
103
|
+
"release-it": {
|
|
104
|
+
"git": {
|
|
105
|
+
"commitMessage": "chore: release ${version}",
|
|
106
|
+
"tagName": "v${version}"
|
|
107
|
+
},
|
|
108
|
+
"npm": {
|
|
109
|
+
"publish": true
|
|
110
|
+
},
|
|
111
|
+
"github": {
|
|
112
|
+
"release": true
|
|
113
|
+
},
|
|
114
|
+
"plugins": {
|
|
115
|
+
"@release-it/conventional-changelog": {
|
|
116
|
+
"preset": "angular"
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
"eslintConfig": {
|
|
121
|
+
"root": true,
|
|
122
|
+
"extends": [
|
|
123
|
+
"@react-native-community",
|
|
124
|
+
"prettier"
|
|
125
|
+
],
|
|
126
|
+
"rules": {
|
|
127
|
+
"prettier/prettier": [
|
|
128
|
+
"error",
|
|
129
|
+
{
|
|
130
|
+
"quoteProps": "consistent",
|
|
131
|
+
"singleQuote": true,
|
|
132
|
+
"tabWidth": 2,
|
|
133
|
+
"trailingComma": "es5",
|
|
134
|
+
"useTabs": false
|
|
135
|
+
}
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
"eslintIgnore": [
|
|
140
|
+
"node_modules/",
|
|
141
|
+
"lib/"
|
|
142
|
+
],
|
|
143
|
+
"prettier": {
|
|
144
|
+
"quoteProps": "consistent",
|
|
145
|
+
"singleQuote": true,
|
|
146
|
+
"tabWidth": 2,
|
|
147
|
+
"trailingComma": "es5",
|
|
148
|
+
"useTabs": false
|
|
149
|
+
},
|
|
150
|
+
"react-native-builder-bob": {
|
|
151
|
+
"source": "src",
|
|
152
|
+
"output": "lib",
|
|
153
|
+
"targets": [
|
|
154
|
+
"commonjs",
|
|
155
|
+
"module",
|
|
156
|
+
[
|
|
157
|
+
"typescript",
|
|
158
|
+
{
|
|
159
|
+
"project": "tsconfig.build.json"
|
|
160
|
+
}
|
|
161
|
+
]
|
|
162
|
+
]
|
|
163
|
+
},
|
|
164
|
+
"codegenConfig": {
|
|
165
|
+
"name": "RNSmileIdSpec",
|
|
166
|
+
"type": "modules",
|
|
167
|
+
"jsSrcsDir": "src"
|
|
168
|
+
}
|
|
169
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
|
|
5
|
+
|
|
6
|
+
Pod::Spec.new do |s|
|
|
7
|
+
s.name = "react-native-smile-id"
|
|
8
|
+
s.version = package["version"]
|
|
9
|
+
s.summary = package["description"]
|
|
10
|
+
s.homepage = package["homepage"]
|
|
11
|
+
s.license = package["license"]
|
|
12
|
+
s.authors = package["author"]
|
|
13
|
+
|
|
14
|
+
s.platforms = { :ios => "13.0" }
|
|
15
|
+
s.source = { :git => "https://docs.usesmileid.com/.git", :tag => "#{s.version}" }
|
|
16
|
+
|
|
17
|
+
s.source_files = "ios/**/*.{h,m,mm}"
|
|
18
|
+
s.dependency "SmileID","10.0.0-beta06"
|
|
19
|
+
|
|
20
|
+
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
21
|
+
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
|
22
|
+
if respond_to?(:install_modules_dependencies, true)
|
|
23
|
+
install_modules_dependencies(s)
|
|
24
|
+
else
|
|
25
|
+
s.dependency "React-Core"
|
|
26
|
+
|
|
27
|
+
# Don't install the dependencies when we run `pod install` in the old architecture.
|
|
28
|
+
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
|
|
29
|
+
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
|
|
30
|
+
s.pod_target_xcconfig = {
|
|
31
|
+
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
|
|
32
|
+
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
|
|
33
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
|
|
34
|
+
}
|
|
35
|
+
s.dependency "React-Codegen"
|
|
36
|
+
s.dependency "RCT-Folly"
|
|
37
|
+
s.dependency "RCTRequired"
|
|
38
|
+
s.dependency "RCTTypeSafety"
|
|
39
|
+
s.dependency "ReactCommon/turbomodule/core"
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
+
import type { EnhancedKycRequest } from './index';
|
|
4
|
+
|
|
5
|
+
export interface Spec extends TurboModule {
|
|
6
|
+
initialize: (
|
|
7
|
+
enableCrashReporting: boolean,
|
|
8
|
+
useSandBox: boolean
|
|
9
|
+
) => Promise<void>;
|
|
10
|
+
doEnhancedKycAsync: (
|
|
11
|
+
enhancedKYCRequest: EnhancedKycRequest
|
|
12
|
+
) => Promise<string>;
|
|
13
|
+
}
|
|
14
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('SmileID');
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import type { HostComponent, ViewProps } from 'react-native';
|
|
2
|
+
import { NativeModules, Platform } from 'react-native';
|
|
3
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
4
|
+
|
|
5
|
+
const LINKING_ERROR =
|
|
6
|
+
`The package 'react-native-smile-id' doesn't seem to be linked. Make sure: \n\n` +
|
|
7
|
+
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
8
|
+
'- You rebuilt the app after installing the package\n' +
|
|
9
|
+
'- You are not using Expo Go\n';
|
|
10
|
+
|
|
11
|
+
// @ts-expect-error
|
|
12
|
+
const isTurboModuleEnabled = global.__turboModuleProxy != null;
|
|
13
|
+
|
|
14
|
+
export type SmileIDViewProps = ViewProps & {
|
|
15
|
+
userId?: string;
|
|
16
|
+
jobId?: string;
|
|
17
|
+
partnerParams?: PartnerParams;
|
|
18
|
+
jobType: JobType;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type PartnerParams = {
|
|
22
|
+
jobType?: JobType;
|
|
23
|
+
jobId: string;
|
|
24
|
+
userId: string;
|
|
25
|
+
extras?: Map<string, string>;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
interface IdInfo {
|
|
29
|
+
country: string;
|
|
30
|
+
idType?: string;
|
|
31
|
+
idNumber?: string;
|
|
32
|
+
firstName?: string;
|
|
33
|
+
middleName?: string;
|
|
34
|
+
lastName?: string;
|
|
35
|
+
dob?: string;
|
|
36
|
+
bankCode?: string;
|
|
37
|
+
entered?: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type SmartSelfieRequest = SmileIDViewProps & {
|
|
41
|
+
allowAgentMode: boolean;
|
|
42
|
+
showInstructions?: boolean;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type BvnConsentRequest = SmileIDViewProps & {
|
|
46
|
+
partnerIcon: string;
|
|
47
|
+
partnerName: string;
|
|
48
|
+
showAttribution: boolean;
|
|
49
|
+
partnerPrivacyPolicy: string;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type EnhancedKycRequest = SmileIDViewProps & {
|
|
53
|
+
country: string;
|
|
54
|
+
idType: string;
|
|
55
|
+
idNumber: string;
|
|
56
|
+
firstName?: string;
|
|
57
|
+
middleName?: string;
|
|
58
|
+
lastName?: string;
|
|
59
|
+
dob?: string;
|
|
60
|
+
phoneNumber?: string;
|
|
61
|
+
bankCode?: string;
|
|
62
|
+
callbackUrl?: string;
|
|
63
|
+
partnerParams: PartnerParams;
|
|
64
|
+
timestamp: string;
|
|
65
|
+
signature: string;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export type DocumentVerificationRequest = SmartSelfieRequest & {
|
|
69
|
+
jobType: JobType.DocumentVerification;
|
|
70
|
+
countryCode: string;
|
|
71
|
+
documentType: string;
|
|
72
|
+
idAspectRatio?: number;
|
|
73
|
+
captureBothSides?: boolean;
|
|
74
|
+
showAttribution?: boolean;
|
|
75
|
+
allowGalleryUpload?: boolean;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export type BiometricKYCRequest = SmartSelfieRequest & {
|
|
79
|
+
idInfo: IdInfo;
|
|
80
|
+
jobType: JobType.BiometricKyc;
|
|
81
|
+
partnerIcon: string;
|
|
82
|
+
partnerName: string;
|
|
83
|
+
productName: string;
|
|
84
|
+
partnerPrivacyPolicy: string;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export enum JobType {
|
|
88
|
+
BiometricKyc = 1,
|
|
89
|
+
SmartSelfieAuthentication = 2,
|
|
90
|
+
SmartSelfieEnrollment = 4,
|
|
91
|
+
EnhancedKyc = 5,
|
|
92
|
+
DocumentVerification = 6,
|
|
93
|
+
BVN = 7,
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const SmileIdModule = isTurboModuleEnabled
|
|
97
|
+
? require('./NativeSmileId').default
|
|
98
|
+
: NativeModules.SmileID;
|
|
99
|
+
|
|
100
|
+
const _SmileID = SmileIdModule
|
|
101
|
+
? SmileIdModule
|
|
102
|
+
: new Proxy(
|
|
103
|
+
{},
|
|
104
|
+
{
|
|
105
|
+
get() {
|
|
106
|
+
throw new Error(LINKING_ERROR);
|
|
107
|
+
},
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
export interface NativeProps extends ViewProps {
|
|
112
|
+
product:
|
|
113
|
+
| SmartSelfieRequest
|
|
114
|
+
| DocumentVerificationRequest
|
|
115
|
+
| EnhancedKycRequest
|
|
116
|
+
| BvnConsentRequest;
|
|
117
|
+
onResult?: (event: any) => void;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export const SmileIDSmartSelfieEnrollmentView =
|
|
121
|
+
codegenNativeComponent<NativeProps>(
|
|
122
|
+
'SmileIDSmartSelfieEnrollmentView'
|
|
123
|
+
) as HostComponent<NativeProps>;
|
|
124
|
+
|
|
125
|
+
export const SmileIDSmartSelfieAuthenticationView =
|
|
126
|
+
codegenNativeComponent<NativeProps>(
|
|
127
|
+
'SmileIDSmartSelfieAuthenticationView'
|
|
128
|
+
) as HostComponent<NativeProps>;
|
|
129
|
+
|
|
130
|
+
export const SmileIDDocumentVerificationView =
|
|
131
|
+
codegenNativeComponent<NativeProps>(
|
|
132
|
+
'SmileIDDocumentVerificationView'
|
|
133
|
+
) as HostComponent<NativeProps>;
|
|
134
|
+
|
|
135
|
+
export const SmileIDBVNConsentScreenView = codegenNativeComponent<NativeProps>(
|
|
136
|
+
'SmileIDBVNConsentScreenView'
|
|
137
|
+
) as HostComponent<NativeProps>;
|
|
138
|
+
|
|
139
|
+
export const SmileIDBiometricKYCView = codegenNativeComponent<NativeProps>(
|
|
140
|
+
'SmileIDBiometricKYCView'
|
|
141
|
+
) as HostComponent<NativeProps>;
|
|
142
|
+
|
|
143
|
+
export const SmileID = {
|
|
144
|
+
initialize: (
|
|
145
|
+
enableCrashReporting: boolean = false,
|
|
146
|
+
useSandBox: boolean = false
|
|
147
|
+
) => _SmileID.initialize(enableCrashReporting, useSandBox),
|
|
148
|
+
doEnhancedKycAsync: (enhancedKYCRequest: EnhancedKycRequest) =>
|
|
149
|
+
_SmileID.doEnhancedKycAsync(enhancedKYCRequest),
|
|
150
|
+
};
|