@digiotech/react-native 1.0.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 (66) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +114 -0
  3. package/android/build.gradle +106 -0
  4. package/android/gradle.properties +5 -0
  5. package/android/src/main/AndroidManifest.xml +3 -0
  6. package/android/src/main/AndroidManifestNew.xml +2 -0
  7. package/android/src/main/java/com/digioreactnative/ArrayUtil.java +162 -0
  8. package/android/src/main/java/com/digioreactnative/DigioReactNativeModule.java +210 -0
  9. package/android/src/main/java/com/digioreactnative/DigioReactNativePackage.java +28 -0
  10. package/android/src/main/java/com/digioreactnative/JsonUtils.java +61 -0
  11. package/android/src/main/java/com/digioreactnative/MapUtil.java +179 -0
  12. package/digio-react-native.podspec +43 -0
  13. package/ios/DigioKycResponse.swift +18 -0
  14. package/ios/DigioReactNative-Bridging-Header.h +3 -0
  15. package/ios/DigioReactNative.mm +20 -0
  16. package/ios/DigioReactNative.swift +114 -0
  17. package/lib/commonjs/index.js +59 -0
  18. package/lib/commonjs/index.js.map +1 -0
  19. package/lib/commonjs/types/enums/environment.js +12 -0
  20. package/lib/commonjs/types/enums/environment.js.map +1 -0
  21. package/lib/commonjs/types/interfaces/digio_config.js +6 -0
  22. package/lib/commonjs/types/interfaces/digio_config.js.map +1 -0
  23. package/lib/commonjs/types/interfaces/digio_response.js +2 -0
  24. package/lib/commonjs/types/interfaces/digio_response.js.map +1 -0
  25. package/lib/commonjs/types/interfaces/error.js +2 -0
  26. package/lib/commonjs/types/interfaces/error.js.map +1 -0
  27. package/lib/commonjs/types/interfaces/gateway_event.js +6 -0
  28. package/lib/commonjs/types/interfaces/gateway_event.js.map +1 -0
  29. package/lib/commonjs/types/interfaces/theme.js +2 -0
  30. package/lib/commonjs/types/interfaces/theme.js.map +1 -0
  31. package/lib/module/index.js +46 -0
  32. package/lib/module/index.js.map +1 -0
  33. package/lib/module/types/enums/environment.js +6 -0
  34. package/lib/module/types/enums/environment.js.map +1 -0
  35. package/lib/module/types/interfaces/digio_config.js +2 -0
  36. package/lib/module/types/interfaces/digio_config.js.map +1 -0
  37. package/lib/module/types/interfaces/digio_response.js +2 -0
  38. package/lib/module/types/interfaces/digio_response.js.map +1 -0
  39. package/lib/module/types/interfaces/error.js +2 -0
  40. package/lib/module/types/interfaces/error.js.map +1 -0
  41. package/lib/module/types/interfaces/gateway_event.js +2 -0
  42. package/lib/module/types/interfaces/gateway_event.js.map +1 -0
  43. package/lib/module/types/interfaces/theme.js +2 -0
  44. package/lib/module/types/interfaces/theme.js.map +1 -0
  45. package/lib/typescript/src/index.d.ts +17 -0
  46. package/lib/typescript/src/index.d.ts.map +1 -0
  47. package/lib/typescript/src/types/enums/environment.d.ts +5 -0
  48. package/lib/typescript/src/types/enums/environment.d.ts.map +1 -0
  49. package/lib/typescript/src/types/interfaces/digio_config.d.ts +8 -0
  50. package/lib/typescript/src/types/interfaces/digio_config.d.ts.map +1 -0
  51. package/lib/typescript/src/types/interfaces/digio_response.d.ts +7 -0
  52. package/lib/typescript/src/types/interfaces/digio_response.d.ts.map +1 -0
  53. package/lib/typescript/src/types/interfaces/error.d.ts +5 -0
  54. package/lib/typescript/src/types/interfaces/error.d.ts.map +1 -0
  55. package/lib/typescript/src/types/interfaces/gateway_event.d.ts +17 -0
  56. package/lib/typescript/src/types/interfaces/gateway_event.d.ts.map +1 -0
  57. package/lib/typescript/src/types/interfaces/theme.d.ts +8 -0
  58. package/lib/typescript/src/types/interfaces/theme.d.ts.map +1 -0
  59. package/package.json +162 -0
  60. package/src/index.ts +91 -0
  61. package/src/types/enums/environment.ts +4 -0
  62. package/src/types/interfaces/digio_config.ts +8 -0
  63. package/src/types/interfaces/digio_response.ts +6 -0
  64. package/src/types/interfaces/error.ts +4 -0
  65. package/src/types/interfaces/gateway_event.ts +16 -0
  66. package/src/types/interfaces/theme.ts +7 -0
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../../src","sources":["types/interfaces/gateway_event.ts"],"mappings":""}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=theme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../../src","sources":["types/interfaces/theme.ts"],"mappings":""}
@@ -0,0 +1,17 @@
1
+ import type { EmitterSubscription } from 'react-native';
2
+ import type { DigioConfig } from './types/interfaces/digio_config';
3
+ import type { DigioResponse } from './types/interfaces/digio_response';
4
+ import type { GatewayEvent } from './types/interfaces/gateway_event';
5
+ export { Environment } from './types/enums/environment';
6
+ type GatewayEventCallbackFn = (data: GatewayEvent) => void;
7
+ export type { DigioConfig, DigioResponse, GatewayEvent, GatewayEventCallbackFn, };
8
+ export declare class Digio {
9
+ private readonly config;
10
+ constructor(config: DigioConfig);
11
+ addGatewayEventListener(callback: GatewayEventCallbackFn): EmitterSubscription;
12
+ start(documentId: string, identifier: string, tokenId?: string, additionalData?: {
13
+ [key: string]: string;
14
+ }): Promise<DigioResponse>;
15
+ private buildConfigParams;
16
+ }
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAErE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAmBxD,KAAK,sBAAsB,GAAG,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC;AAE3D,YAAY,EACV,WAAW,EACX,aAAa,EACb,YAAY,EACZ,sBAAsB,GACvB,CAAC;AAEF,qBAAa,KAAK;IAChB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;gBAEzB,MAAM,EAAE,WAAW;IAI/B,uBAAuB,CACrB,QAAQ,EAAE,sBAAsB,GAC/B,mBAAmB;IAmBhB,KAAK,CACT,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,MAAM,EAChB,cAAc,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GACzC,OAAO,CAAC,aAAa,CAAC;IAUzB,OAAO,CAAC,iBAAiB;CAQ1B"}
@@ -0,0 +1,5 @@
1
+ export declare enum Environment {
2
+ SANDBOX = "sandbox",
3
+ PRODUCTION = "production"
4
+ }
5
+ //# sourceMappingURL=environment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../../../../src/types/enums/environment.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACrB,OAAO,YAAY;IACnB,UAAU,eAAe;CAC1B"}
@@ -0,0 +1,8 @@
1
+ import { Environment } from '../enums/environment';
2
+ import type { Theme } from './theme';
3
+ export interface DigioConfig {
4
+ logo?: string;
5
+ environment?: Environment;
6
+ theme?: Theme;
7
+ }
8
+ //# sourceMappingURL=digio_config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"digio_config.d.ts","sourceRoot":"","sources":["../../../../../src/types/interfaces/digio_config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,KAAK,CAAC,EAAE,KAAK,CAAC;CACf"}
@@ -0,0 +1,7 @@
1
+ export interface DigioResponse {
2
+ code: number;
3
+ message?: string;
4
+ documentId?: string;
5
+ permissions?: Array<string>;
6
+ }
7
+ //# sourceMappingURL=digio_response.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"digio_response.d.ts","sourceRoot":"","sources":["../../../../../src/types/interfaces/digio_response.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CAC7B"}
@@ -0,0 +1,5 @@
1
+ export interface DigioError {
2
+ code?: string;
3
+ message?: string;
4
+ }
5
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../../../src/types/interfaces/error.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
@@ -0,0 +1,17 @@
1
+ import type { DigioError } from './error';
2
+ export interface Payload {
3
+ type?: string;
4
+ data?: {
5
+ [key: string]: any;
6
+ };
7
+ error?: DigioError;
8
+ }
9
+ export interface GatewayEvent {
10
+ documentId?: string;
11
+ txnId?: string;
12
+ entity?: string;
13
+ identifier?: string;
14
+ event?: string;
15
+ payload?: Payload;
16
+ }
17
+ //# sourceMappingURL=gateway_event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gateway_event.d.ts","sourceRoot":"","sources":["../../../../../src/types/interfaces/gateway_event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,WAAW,OAAO;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;IAC9B,KAAK,CAAC,EAAE,UAAU,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
@@ -0,0 +1,8 @@
1
+ export interface Theme {
2
+ primaryColor?: string;
3
+ secondaryColor?: string;
4
+ fontFamily?: string;
5
+ fontUrl?: string;
6
+ fontFormat?: string;
7
+ }
8
+ //# sourceMappingURL=theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../../src/types/interfaces/theme.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,KAAK;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
package/package.json ADDED
@@ -0,0 +1,162 @@
1
+ {
2
+ "name": "@digiotech/react-native",
3
+ "version": "1.0.0",
4
+ "description": "SDK for invoking client side journey for any of Digio request",
5
+ "main": "lib/commonjs/index",
6
+ "module": "lib/module/index",
7
+ "types": "lib/typescript/src/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
+ "!ios/build",
18
+ "!android/build",
19
+ "!android/gradle",
20
+ "!android/gradlew",
21
+ "!android/gradlew.bat",
22
+ "!android/local.properties",
23
+ "!**/__tests__",
24
+ "!**/__fixtures__",
25
+ "!**/__mocks__",
26
+ "!**/.*"
27
+ ],
28
+ "scripts": {
29
+ "example": "yarn workspace digio-react-native-example",
30
+ "test": "jest",
31
+ "typecheck": "tsc --noEmit",
32
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
33
+ "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
34
+ "prepare": "bob build",
35
+ "release": "release-it"
36
+ },
37
+ "keywords": [
38
+ "react-native",
39
+ "ios",
40
+ "android"
41
+ ],
42
+ "repository": "https://github.com/digio-tech/reactnative-sdk",
43
+ "author": "Digio <support@digio.in> (https://www.npmjs.com/org/support_digio)",
44
+ "license": "MIT",
45
+ "bugs": {
46
+ "url": "https://github.com/digio-tech/reactnative-sdk/issues"
47
+ },
48
+ "homepage": "https://github.com/digio-tech/reactnative-sdk#readme",
49
+ "publishConfig": {
50
+ "registry": "https://registry.npmjs.org/"
51
+ },
52
+ "devDependencies": {
53
+ "@commitlint/config-conventional": "^17.0.2",
54
+ "@evilmartians/lefthook": "^1.5.0",
55
+ "@react-native/eslint-config": "^0.72.2",
56
+ "@release-it/conventional-changelog": "^5.0.0",
57
+ "@types/jest": "^28.1.2",
58
+ "@types/react": "~17.0.21",
59
+ "@types/react-native": "0.70.0",
60
+ "commitlint": "^17.0.2",
61
+ "del-cli": "^5.0.0",
62
+ "eslint": "^8.4.1",
63
+ "eslint-config-prettier": "^8.5.0",
64
+ "eslint-plugin-prettier": "^4.0.0",
65
+ "jest": "^28.1.1",
66
+ "pod-install": "^0.1.0",
67
+ "prettier": "^2.0.5",
68
+ "react": "18.2.0",
69
+ "react-native": "0.72.6",
70
+ "react-native-builder-bob": "^0.20.0",
71
+ "release-it": "^15.0.0",
72
+ "turbo": "^1.10.7",
73
+ "typescript": "^5.0.2"
74
+ },
75
+ "resolutions": {
76
+ "@types/react": "17.0.21"
77
+ },
78
+ "peerDependencies": {
79
+ "react": "*",
80
+ "react-native": "*"
81
+ },
82
+ "workspaces": [
83
+ "example"
84
+ ],
85
+ "packageManager": "yarn@3.6.1",
86
+ "engines": {
87
+ "node": ">= 18.0.0"
88
+ },
89
+ "jest": {
90
+ "preset": "react-native",
91
+ "modulePathIgnorePatterns": [
92
+ "<rootDir>/example/node_modules",
93
+ "<rootDir>/lib/"
94
+ ]
95
+ },
96
+ "commitlint": {
97
+ "extends": [
98
+ "@commitlint/config-conventional"
99
+ ]
100
+ },
101
+ "release-it": {
102
+ "git": {
103
+ "commitMessage": "chore: release ${version}",
104
+ "tagName": "v${version}"
105
+ },
106
+ "npm": {
107
+ "publish": true
108
+ },
109
+ "github": {
110
+ "release": true
111
+ },
112
+ "plugins": {
113
+ "@release-it/conventional-changelog": {
114
+ "preset": "angular"
115
+ }
116
+ }
117
+ },
118
+ "eslintConfig": {
119
+ "root": true,
120
+ "extends": [
121
+ "@react-native",
122
+ "prettier"
123
+ ],
124
+ "rules": {
125
+ "prettier/prettier": [
126
+ "error",
127
+ {
128
+ "quoteProps": "consistent",
129
+ "singleQuote": true,
130
+ "tabWidth": 2,
131
+ "trailingComma": "es5",
132
+ "useTabs": false
133
+ }
134
+ ]
135
+ }
136
+ },
137
+ "eslintIgnore": [
138
+ "node_modules/",
139
+ "lib/"
140
+ ],
141
+ "prettier": {
142
+ "quoteProps": "consistent",
143
+ "singleQuote": true,
144
+ "tabWidth": 2,
145
+ "trailingComma": "es5",
146
+ "useTabs": false
147
+ },
148
+ "react-native-builder-bob": {
149
+ "source": "src",
150
+ "output": "lib",
151
+ "targets": [
152
+ "commonjs",
153
+ "module",
154
+ [
155
+ "typescript",
156
+ {
157
+ "project": "tsconfig.build.json"
158
+ }
159
+ ]
160
+ ]
161
+ }
162
+ }
package/src/index.ts ADDED
@@ -0,0 +1,91 @@
1
+ import {
2
+ DeviceEventEmitter,
3
+ NativeEventEmitter,
4
+ NativeModules,
5
+ Platform,
6
+ } from 'react-native';
7
+ import type { EmitterSubscription } from 'react-native';
8
+ import type { DigioConfig } from './types/interfaces/digio_config';
9
+ import type { DigioResponse } from './types/interfaces/digio_response';
10
+ import type { GatewayEvent } from './types/interfaces/gateway_event';
11
+
12
+ export { Environment } from './types/enums/environment';
13
+
14
+ const LINKING_ERROR =
15
+ `The package 'digio-react-native' doesn't seem to be linked. Make sure: \n\n` +
16
+ Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
17
+ '- You rebuilt the app after installing the package\n' +
18
+ '- You are not using Expo Go\n';
19
+
20
+ const DigioReactNative = NativeModules.DigioReactNative
21
+ ? NativeModules.DigioReactNative
22
+ : new Proxy(
23
+ {},
24
+ {
25
+ get() {
26
+ throw new Error(LINKING_ERROR);
27
+ },
28
+ }
29
+ );
30
+
31
+ type GatewayEventCallbackFn = (data: GatewayEvent) => void;
32
+
33
+ export type {
34
+ DigioConfig,
35
+ DigioResponse,
36
+ GatewayEvent,
37
+ GatewayEventCallbackFn,
38
+ };
39
+
40
+ export class Digio {
41
+ private readonly config: DigioConfig;
42
+
43
+ constructor(config: DigioConfig) {
44
+ this.config = config;
45
+ }
46
+
47
+ addGatewayEventListener(
48
+ callback: GatewayEventCallbackFn
49
+ ): EmitterSubscription {
50
+ if (Platform.OS === 'android') {
51
+ return DeviceEventEmitter.addListener('gatewayEvent', (data) => {
52
+ if (callback) {
53
+ callback(data);
54
+ }
55
+ });
56
+ }
57
+ if (Platform.OS === 'ios') {
58
+ const digioReactNativeEmitter = new NativeEventEmitter(DigioReactNative);
59
+ return digioReactNativeEmitter.addListener('gatewayEvent', (data) => {
60
+ if (callback) {
61
+ callback(data);
62
+ }
63
+ });
64
+ }
65
+ throw Error(`Platform ${Platform.OS} not supported`);
66
+ }
67
+
68
+ async start(
69
+ documentId: string,
70
+ identifier: string,
71
+ tokenId?: string,
72
+ additionalData?: { [key: string]: string }
73
+ ): Promise<DigioResponse> {
74
+ return DigioReactNative.start(
75
+ documentId,
76
+ identifier,
77
+ tokenId ?? null,
78
+ additionalData ?? null,
79
+ this.buildConfigParams() ?? null
80
+ );
81
+ }
82
+
83
+ private buildConfigParams() {
84
+ if (!this.config) return;
85
+ return {
86
+ environment: this.config.environment,
87
+ logo: this.config.logo,
88
+ ...this.config.theme,
89
+ };
90
+ }
91
+ }
@@ -0,0 +1,4 @@
1
+ export enum Environment {
2
+ SANDBOX = 'sandbox',
3
+ PRODUCTION = 'production',
4
+ }
@@ -0,0 +1,8 @@
1
+ import { Environment } from '../enums/environment';
2
+ import type { Theme } from './theme';
3
+
4
+ export interface DigioConfig {
5
+ logo?: string;
6
+ environment?: Environment;
7
+ theme?: Theme;
8
+ }
@@ -0,0 +1,6 @@
1
+ export interface DigioResponse {
2
+ code: number;
3
+ message?: string;
4
+ documentId?: string;
5
+ permissions?: Array<string>;
6
+ }
@@ -0,0 +1,4 @@
1
+ export interface DigioError {
2
+ code?: string;
3
+ message?: string;
4
+ }
@@ -0,0 +1,16 @@
1
+ import type { DigioError } from './error';
2
+
3
+ export interface Payload {
4
+ type?: string;
5
+ data?: { [key: string]: any };
6
+ error?: DigioError;
7
+ }
8
+
9
+ export interface GatewayEvent {
10
+ documentId?: string;
11
+ txnId?: string;
12
+ entity?: string;
13
+ identifier?: string;
14
+ event?: string;
15
+ payload?: Payload;
16
+ }
@@ -0,0 +1,7 @@
1
+ export interface Theme {
2
+ primaryColor?: string;
3
+ secondaryColor?: string;
4
+ fontFamily?: string;
5
+ fontUrl?: string;
6
+ fontFormat?: string;
7
+ }