@evervault/react-native 2.5.1 → 2.6.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.
- package/README.md +0 -2
- package/build/cjs/Card/Cvc.js +29 -0
- package/build/cjs/Card/Expiry.js +12 -0
- package/build/cjs/Card/Holder.js +15 -0
- package/build/cjs/Card/Number.js +27 -0
- package/build/cjs/Card/Root.js +70 -0
- package/build/cjs/Card/index.js +20 -0
- package/build/cjs/Card/schema.js +32 -0
- package/build/cjs/Card/types.js +21 -0
- package/build/cjs/Card/utils.js +87 -0
- package/build/cjs/EvervaultProvider.js +17 -0
- package/build/cjs/Input.js +107 -0
- package/build/cjs/ThreeDSecure/Frame.js +37 -0
- package/build/cjs/ThreeDSecure/Root.js +14 -0
- package/build/cjs/ThreeDSecure/config.js +7 -0
- package/build/cjs/ThreeDSecure/context.js +7 -0
- package/build/cjs/ThreeDSecure/event.js +20 -0
- package/build/cjs/ThreeDSecure/index.js +12 -0
- package/build/cjs/ThreeDSecure/session.js +141 -0
- package/build/cjs/ThreeDSecure/types.js +2 -0
- package/build/cjs/ThreeDSecure/useThreeDSecure.js +44 -0
- package/build/cjs/__mocks__/NativeEvervault.js +14 -0
- package/build/cjs/__mocks__/react-native-webview.js +10 -0
- package/build/cjs/context.js +7 -0
- package/build/cjs/index.js +25 -0
- package/build/cjs/node_modules/@hookform/resolvers/dist/resolvers.js +8 -0
- package/build/cjs/node_modules/@hookform/resolvers/zod/dist/zod.js +8 -0
- package/build/cjs/node_modules/react-hook-form/dist/index.esm.js +2221 -0
- package/build/cjs/node_modules/react-native-mask-input/lib/module/MaskInput.js +60 -0
- package/build/cjs/node_modules/react-native-mask-input/lib/module/formatWithMask.js +92 -0
- package/build/cjs/node_modules/react-native-mask-input/lib/module/index.js +10 -0
- package/build/cjs/node_modules/react-native-mask-input/lib/module/useMaskedInputProps.js +93 -0
- package/build/{index.cjs.js → cjs/node_modules/zod/lib/index.js} +193 -3490
- package/build/cjs/packages/card-validator/dist/evervault-card-validator.main.js +349 -0
- package/build/cjs/sdk.js +53 -0
- package/build/cjs/specs/NativeEvervault.js +7 -0
- package/build/cjs/useEvervault.js +14 -0
- package/build/cjs/utils.js +34 -0
- package/build/{Card → esm/Card}/Cvc.d.ts +0 -1
- package/build/esm/Card/Cvc.js +27 -0
- package/build/{Card → esm/Card}/Expiry.d.ts +0 -1
- package/build/esm/Card/Expiry.js +10 -0
- package/build/{Card → esm/Card}/Holder.d.ts +0 -1
- package/build/esm/Card/Holder.js +13 -0
- package/build/{Card → esm/Card}/Number.d.ts +0 -1
- package/build/esm/Card/Number.js +25 -0
- package/build/{Card → esm/Card}/Root.d.ts +0 -1
- package/build/esm/Card/Root.js +68 -0
- package/build/{Card → esm/Card}/index.d.ts +0 -1
- package/build/esm/Card/index.js +14 -0
- package/build/{Card → esm/Card}/schema.d.ts +0 -1
- package/build/esm/Card/schema.js +30 -0
- package/build/{Card → esm/Card}/types.d.ts +0 -1
- package/build/esm/Card/types.js +19 -0
- package/build/{Card → esm/Card}/utils.d.ts +0 -1
- package/build/esm/Card/utils.js +82 -0
- package/build/{EvervaultProvider.d.ts → esm/EvervaultProvider.d.ts} +0 -1
- package/build/esm/EvervaultProvider.js +15 -0
- package/build/{Input.d.ts → esm/Input.d.ts} +0 -1
- package/build/esm/Input.js +103 -0
- package/build/{ThreeDSecure → esm/ThreeDSecure}/Frame.d.ts +0 -1
- package/build/esm/ThreeDSecure/Frame.js +35 -0
- package/build/{ThreeDSecure → esm/ThreeDSecure}/Root.d.ts +0 -1
- package/build/esm/ThreeDSecure/Root.js +12 -0
- package/build/{ThreeDSecure → esm/ThreeDSecure}/config.d.ts +0 -1
- package/build/esm/ThreeDSecure/config.js +4 -0
- package/build/{ThreeDSecure → esm/ThreeDSecure}/context.d.ts +0 -1
- package/build/esm/ThreeDSecure/context.js +5 -0
- package/build/{ThreeDSecure → esm/ThreeDSecure}/event.d.ts +0 -1
- package/build/esm/ThreeDSecure/event.js +18 -0
- package/build/{ThreeDSecure → esm/ThreeDSecure}/index.d.ts +0 -1
- package/build/esm/ThreeDSecure/index.js +9 -0
- package/build/{ThreeDSecure → esm/ThreeDSecure}/session.d.ts +0 -1
- package/build/esm/ThreeDSecure/session.js +136 -0
- package/build/{ThreeDSecure → esm/ThreeDSecure}/types.d.ts +0 -1
- package/build/esm/ThreeDSecure/types.js +1 -0
- package/build/{ThreeDSecure → esm/ThreeDSecure}/useThreeDSecure.d.ts +0 -1
- package/build/esm/ThreeDSecure/useThreeDSecure.js +42 -0
- package/build/{__mocks__ → esm/__mocks__}/NativeEvervault.d.ts +0 -1
- package/build/esm/__mocks__/NativeEvervault.js +11 -0
- package/build/{__mocks__ → esm/__mocks__}/react-native-webview.d.ts +0 -1
- package/build/esm/__mocks__/react-native-webview.js +8 -0
- package/build/{context.d.ts → esm/context.d.ts} +0 -1
- package/build/esm/context.js +5 -0
- package/build/{index.d.ts → esm/index.d.ts} +0 -1
- package/build/esm/index.js +14 -0
- package/build/esm/node_modules/@hookform/resolvers/dist/resolvers.js +5 -0
- package/build/esm/node_modules/@hookform/resolvers/zod/dist/zod.js +6 -0
- package/build/esm/node_modules/react-hook-form/dist/index.esm.js +2211 -0
- package/build/esm/node_modules/react-native-mask-input/lib/module/MaskInput.js +37 -0
- package/build/esm/node_modules/react-native-mask-input/lib/module/formatWithMask.js +88 -0
- package/build/esm/node_modules/react-native-mask-input/lib/module/index.js +6 -0
- package/build/esm/node_modules/react-native-mask-input/lib/module/useMaskedInputProps.js +70 -0
- package/build/{index.esm.js → esm/node_modules/zod/lib/index.js} +1 -3377
- package/build/esm/packages/card-validator/dist/evervault-card-validator.main.js +345 -0
- package/build/{sdk.d.ts → esm/sdk.d.ts} +0 -1
- package/build/esm/sdk.js +51 -0
- package/build/{specs → esm/specs}/NativeEvervault.d.ts +0 -1
- package/build/esm/specs/NativeEvervault.js +5 -0
- package/build/{useEvervault.d.ts → esm/useEvervault.d.ts} +0 -1
- package/build/esm/useEvervault.js +12 -0
- package/build/{utils.d.ts → esm/utils.d.ts} +0 -1
- package/build/esm/utils.js +31 -0
- package/package.json +9 -21
- package/build/Card/Cvc.d.ts.map +0 -1
- package/build/Card/Cvc.test.d.ts +0 -2
- package/build/Card/Cvc.test.d.ts.map +0 -1
- package/build/Card/Expiry.d.ts.map +0 -1
- package/build/Card/Holder.d.ts.map +0 -1
- package/build/Card/Number.d.ts.map +0 -1
- package/build/Card/Number.test.d.ts +0 -2
- package/build/Card/Number.test.d.ts.map +0 -1
- package/build/Card/Root.d.ts.map +0 -1
- package/build/Card/Root.test.d.ts +0 -2
- package/build/Card/Root.test.d.ts.map +0 -1
- package/build/Card/index.d.ts.map +0 -1
- package/build/Card/schema.d.ts.map +0 -1
- package/build/Card/types.d.ts.map +0 -1
- package/build/Card/utils.d.ts.map +0 -1
- package/build/Card/utils.test.d.ts +0 -2
- package/build/Card/utils.test.d.ts.map +0 -1
- package/build/EvervaultProvider.d.ts.map +0 -1
- package/build/EvervaultProvider.test.d.ts +0 -2
- package/build/EvervaultProvider.test.d.ts.map +0 -1
- package/build/Input.d.ts.map +0 -1
- package/build/Input.test.d.ts +0 -2
- package/build/Input.test.d.ts.map +0 -1
- package/build/ThreeDSecure/Frame.d.ts.map +0 -1
- package/build/ThreeDSecure/Frame.test.d.ts +0 -2
- package/build/ThreeDSecure/Frame.test.d.ts.map +0 -1
- package/build/ThreeDSecure/Root.d.ts.map +0 -1
- package/build/ThreeDSecure/Root.test.d.ts +0 -2
- package/build/ThreeDSecure/Root.test.d.ts.map +0 -1
- package/build/ThreeDSecure/config.d.ts.map +0 -1
- package/build/ThreeDSecure/context.d.ts.map +0 -1
- package/build/ThreeDSecure/event.d.ts.map +0 -1
- package/build/ThreeDSecure/index.d.ts.map +0 -1
- package/build/ThreeDSecure/session.d.ts.map +0 -1
- package/build/ThreeDSecure/session.test.d.ts +0 -2
- package/build/ThreeDSecure/session.test.d.ts.map +0 -1
- package/build/ThreeDSecure/types.d.ts.map +0 -1
- package/build/ThreeDSecure/useThreeDSecure.d.ts.map +0 -1
- package/build/ThreeDSecure/useThreeDSecure.test.d.ts +0 -2
- package/build/ThreeDSecure/useThreeDSecure.test.d.ts.map +0 -1
- package/build/__mocks__/NativeEvervault.d.ts.map +0 -1
- package/build/__mocks__/react-native-webview.d.ts.map +0 -1
- package/build/context.d.ts.map +0 -1
- package/build/index.cjs.js.map +0 -1
- package/build/index.d.ts.map +0 -1
- package/build/sdk.d.ts.map +0 -1
- package/build/sdk.test.d.ts +0 -2
- package/build/sdk.test.d.ts.map +0 -1
- package/build/specs/NativeEvervault.d.ts.map +0 -1
- package/build/useEvervault.d.ts.map +0 -1
- package/build/useEvervault.test.d.ts +0 -2
- package/build/useEvervault.test.d.ts.map +0 -1
- package/build/utils.d.ts.map +0 -1
- package/src/Card/Cvc.test.tsx +0 -41
- package/src/Card/Cvc.tsx +0 -58
- package/src/Card/Expiry.tsx +0 -26
- package/src/Card/Holder.tsx +0 -27
- package/src/Card/Number.test.tsx +0 -76
- package/src/Card/Number.tsx +0 -54
- package/src/Card/Root.test.tsx +0 -341
- package/src/Card/Root.tsx +0 -150
- package/src/Card/index.ts +0 -28
- package/src/Card/schema.ts +0 -41
- package/src/Card/types.ts +0 -57
- package/src/Card/utils.test.ts +0 -271
- package/src/Card/utils.ts +0 -129
- package/src/EvervaultProvider.test.tsx +0 -24
- package/src/EvervaultProvider.tsx +0 -43
- package/src/Input.test.tsx +0 -420
- package/src/Input.tsx +0 -182
- package/src/ThreeDSecure/Frame.test.tsx +0 -87
- package/src/ThreeDSecure/Frame.tsx +0 -50
- package/src/ThreeDSecure/Root.test.tsx +0 -67
- package/src/ThreeDSecure/Root.tsx +0 -23
- package/src/ThreeDSecure/config.ts +0 -3
- package/src/ThreeDSecure/context.ts +0 -6
- package/src/ThreeDSecure/event.ts +0 -19
- package/src/ThreeDSecure/index.ts +0 -17
- package/src/ThreeDSecure/session.test.ts +0 -524
- package/src/ThreeDSecure/session.ts +0 -184
- package/src/ThreeDSecure/types.ts +0 -80
- package/src/ThreeDSecure/useThreeDSecure.test.tsx +0 -244
- package/src/ThreeDSecure/useThreeDSecure.ts +0 -64
- package/src/__mocks__/NativeEvervault.ts +0 -13
- package/src/__mocks__/react-native-webview.tsx +0 -6
- package/src/context.ts +0 -14
- package/src/index.ts +0 -21
- package/src/sdk.test.ts +0 -122
- package/src/sdk.ts +0 -71
- package/src/specs/NativeEvervault.ts +0 -67
- package/src/useEvervault.test.tsx +0 -31
- package/src/useEvervault.ts +0 -14
- package/src/utils.ts +0 -41
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function g(e) {
|
|
4
|
+
let n = 0, t = false, s = e.length - 1, l;
|
|
5
|
+
for (; s >= 0; )
|
|
6
|
+
l = parseInt(e.charAt(s), 10), t && (l *= 2, l > 9 && (l = l % 10 + 1)), t = !t, n += l, s--;
|
|
7
|
+
return n % 10 === 0;
|
|
8
|
+
}
|
|
9
|
+
const h = [
|
|
10
|
+
{
|
|
11
|
+
name: "visa",
|
|
12
|
+
isLocal: false,
|
|
13
|
+
numberValidationRules: {
|
|
14
|
+
luhnCheck: true,
|
|
15
|
+
ranges: [4],
|
|
16
|
+
lengths: [16, 18, 19]
|
|
17
|
+
},
|
|
18
|
+
securityCodeValidationRules: {
|
|
19
|
+
lengths: [3]
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: "mastercard",
|
|
24
|
+
isLocal: false,
|
|
25
|
+
numberValidationRules: {
|
|
26
|
+
luhnCheck: true,
|
|
27
|
+
ranges: [[51, 55], [2221, 2229], [223, 229], [23, 26], [270, 271], 2720],
|
|
28
|
+
lengths: [16]
|
|
29
|
+
},
|
|
30
|
+
securityCodeValidationRules: {
|
|
31
|
+
lengths: [3]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: "american-express",
|
|
36
|
+
isLocal: false,
|
|
37
|
+
numberValidationRules: {
|
|
38
|
+
luhnCheck: true,
|
|
39
|
+
ranges: [34, 37],
|
|
40
|
+
lengths: [15]
|
|
41
|
+
},
|
|
42
|
+
securityCodeValidationRules: {
|
|
43
|
+
lengths: [3, 4]
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "diners-club",
|
|
48
|
+
isLocal: false,
|
|
49
|
+
numberValidationRules: {
|
|
50
|
+
luhnCheck: true,
|
|
51
|
+
ranges: [[300, 305], 3095, 36, 38, 39],
|
|
52
|
+
lengths: [14, 16, 19]
|
|
53
|
+
},
|
|
54
|
+
securityCodeValidationRules: {
|
|
55
|
+
lengths: [3]
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "discover",
|
|
60
|
+
isLocal: false,
|
|
61
|
+
numberValidationRules: {
|
|
62
|
+
luhnCheck: true,
|
|
63
|
+
ranges: [6011, [644, 649], [65e4, 651999], [653150, 659999], 622],
|
|
64
|
+
lengths: [16, 19]
|
|
65
|
+
},
|
|
66
|
+
securityCodeValidationRules: {
|
|
67
|
+
lengths: [3]
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: "jcb",
|
|
72
|
+
isLocal: false,
|
|
73
|
+
numberValidationRules: {
|
|
74
|
+
luhnCheck: true,
|
|
75
|
+
ranges: [
|
|
76
|
+
2131,
|
|
77
|
+
1800,
|
|
78
|
+
[3088, 3094],
|
|
79
|
+
[3096, 3102],
|
|
80
|
+
[3112, 3120],
|
|
81
|
+
[3158, 3159],
|
|
82
|
+
[3337, 3349],
|
|
83
|
+
[3528, 3589]
|
|
84
|
+
],
|
|
85
|
+
lengths: [16, 17, 18, 19]
|
|
86
|
+
},
|
|
87
|
+
securityCodeValidationRules: {
|
|
88
|
+
lengths: [3]
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: "unionpay",
|
|
93
|
+
isLocal: false,
|
|
94
|
+
numberValidationRules: {
|
|
95
|
+
luhnCheck: false,
|
|
96
|
+
ranges: [
|
|
97
|
+
620,
|
|
98
|
+
[62100, 62182],
|
|
99
|
+
[62184, 62187],
|
|
100
|
+
[62185, 62197],
|
|
101
|
+
[62200, 62205],
|
|
102
|
+
[622010, 622999],
|
|
103
|
+
622018,
|
|
104
|
+
[62207, 62209],
|
|
105
|
+
[623, 626],
|
|
106
|
+
6270,
|
|
107
|
+
6272,
|
|
108
|
+
6276,
|
|
109
|
+
[627700, 627779],
|
|
110
|
+
[627781, 627799],
|
|
111
|
+
[6282, 6289],
|
|
112
|
+
6291,
|
|
113
|
+
6292,
|
|
114
|
+
810,
|
|
115
|
+
[8110, 8131],
|
|
116
|
+
[8132, 8151],
|
|
117
|
+
[8152, 8163],
|
|
118
|
+
[8164, 8171]
|
|
119
|
+
],
|
|
120
|
+
lengths: [14, 15, 16, 17, 18, 19]
|
|
121
|
+
},
|
|
122
|
+
securityCodeValidationRules: {
|
|
123
|
+
lengths: [3]
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: "maestro",
|
|
128
|
+
isLocal: false,
|
|
129
|
+
numberValidationRules: {
|
|
130
|
+
luhnCheck: true,
|
|
131
|
+
ranges: [
|
|
132
|
+
5018,
|
|
133
|
+
5020,
|
|
134
|
+
5038,
|
|
135
|
+
5893,
|
|
136
|
+
6101,
|
|
137
|
+
6304,
|
|
138
|
+
6759,
|
|
139
|
+
6761,
|
|
140
|
+
6762,
|
|
141
|
+
6763,
|
|
142
|
+
493698,
|
|
143
|
+
[5e5, 504174],
|
|
144
|
+
[504176, 506698],
|
|
145
|
+
[506779, 508999],
|
|
146
|
+
69
|
|
147
|
+
],
|
|
148
|
+
lengths: [12, 13, 14, 15, 16, 17, 18, 19]
|
|
149
|
+
},
|
|
150
|
+
securityCodeValidationRules: {
|
|
151
|
+
lengths: [3]
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: "elo",
|
|
156
|
+
isLocal: true,
|
|
157
|
+
numberValidationRules: {
|
|
158
|
+
luhnCheck: true,
|
|
159
|
+
ranges: [
|
|
160
|
+
401178,
|
|
161
|
+
401179,
|
|
162
|
+
438935,
|
|
163
|
+
457631,
|
|
164
|
+
457632,
|
|
165
|
+
431274,
|
|
166
|
+
451416,
|
|
167
|
+
457393,
|
|
168
|
+
504175,
|
|
169
|
+
[506699, 506778],
|
|
170
|
+
[509e3, 509999],
|
|
171
|
+
627780,
|
|
172
|
+
636297,
|
|
173
|
+
636368,
|
|
174
|
+
[650031, 650033],
|
|
175
|
+
[650035, 650051],
|
|
176
|
+
[650405, 650439],
|
|
177
|
+
[650485, 650538],
|
|
178
|
+
[650541, 650598],
|
|
179
|
+
[650700, 650718],
|
|
180
|
+
[650720, 650727],
|
|
181
|
+
[650901, 650978],
|
|
182
|
+
[651652, 651679],
|
|
183
|
+
[655e3, 655019],
|
|
184
|
+
[655021, 655058]
|
|
185
|
+
],
|
|
186
|
+
lengths: [16]
|
|
187
|
+
},
|
|
188
|
+
securityCodeValidationRules: {
|
|
189
|
+
lengths: [3]
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
name: "mir",
|
|
194
|
+
isLocal: true,
|
|
195
|
+
numberValidationRules: {
|
|
196
|
+
luhnCheck: true,
|
|
197
|
+
ranges: [[2200, 2204]],
|
|
198
|
+
lengths: [16, 17, 18, 19]
|
|
199
|
+
},
|
|
200
|
+
securityCodeValidationRules: {
|
|
201
|
+
lengths: [3]
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
name: "hiper",
|
|
206
|
+
isLocal: true,
|
|
207
|
+
numberValidationRules: {
|
|
208
|
+
luhnCheck: true,
|
|
209
|
+
ranges: [637095, 63737423, 63743358, 637568, 637599, 637609, 637612],
|
|
210
|
+
lengths: [16]
|
|
211
|
+
},
|
|
212
|
+
securityCodeValidationRules: {
|
|
213
|
+
lengths: [3]
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
name: "hipercard",
|
|
218
|
+
isLocal: true,
|
|
219
|
+
numberValidationRules: {
|
|
220
|
+
luhnCheck: true,
|
|
221
|
+
ranges: [606282],
|
|
222
|
+
lengths: [16]
|
|
223
|
+
},
|
|
224
|
+
securityCodeValidationRules: {
|
|
225
|
+
lengths: [3]
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
name: "szep",
|
|
230
|
+
isLocal: true,
|
|
231
|
+
numberValidationRules: {
|
|
232
|
+
luhnCheck: true,
|
|
233
|
+
ranges: [30867825, 61013170, 61013242],
|
|
234
|
+
lengths: [16]
|
|
235
|
+
},
|
|
236
|
+
securityCodeValidationRules: {
|
|
237
|
+
lengths: [3]
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
name: "uatp",
|
|
242
|
+
isLocal: false,
|
|
243
|
+
numberValidationRules: {
|
|
244
|
+
luhnCheck: true,
|
|
245
|
+
ranges: [1],
|
|
246
|
+
lengths: [15]
|
|
247
|
+
},
|
|
248
|
+
securityCodeValidationRules: {
|
|
249
|
+
lengths: [0]
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
name: "rupay",
|
|
254
|
+
isLocal: false,
|
|
255
|
+
numberValidationRules: {
|
|
256
|
+
luhnCheck: true,
|
|
257
|
+
ranges: [60, 81, 82, 508, [652100, 653149], [817200, 819899]],
|
|
258
|
+
lengths: [16]
|
|
259
|
+
},
|
|
260
|
+
securityCodeValidationRules: {
|
|
261
|
+
lengths: [3]
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
];
|
|
265
|
+
function m(e, n, t) {
|
|
266
|
+
const s = String(n).length, l = e.substring(0, s), a = parseInt(l, 10);
|
|
267
|
+
return l.length < s ? false : (n = parseInt(String(n).substring(0, l.length), 10), t = parseInt(String(t).substring(0, l.length), 10), a >= n && a <= t);
|
|
268
|
+
}
|
|
269
|
+
function V(e, n) {
|
|
270
|
+
return e.startsWith(String(n));
|
|
271
|
+
}
|
|
272
|
+
function f(e) {
|
|
273
|
+
return e.length < 16 ? e.substring(0, 6) : e.substring(0, 8);
|
|
274
|
+
}
|
|
275
|
+
function C(e) {
|
|
276
|
+
const n = String(e).replace(/\s/g, "");
|
|
277
|
+
if (!/^\d*$/.test(n))
|
|
278
|
+
return {
|
|
279
|
+
brand: null,
|
|
280
|
+
localBrands: [],
|
|
281
|
+
bin: null,
|
|
282
|
+
lastFour: null,
|
|
283
|
+
isValid: false
|
|
284
|
+
};
|
|
285
|
+
const t = h.filter((i) => i.numberValidationRules.ranges.some((r) => {
|
|
286
|
+
if (Array.isArray(r)) {
|
|
287
|
+
if (r[0] && r[1])
|
|
288
|
+
return m(n, r[0], r[1]);
|
|
289
|
+
} else
|
|
290
|
+
return V(n, r);
|
|
291
|
+
return false;
|
|
292
|
+
})), s = t.filter((i) => !i.isLocal), l = t.filter((i) => i.isLocal), a = t.length > 0 && t.every((i) => {
|
|
293
|
+
const { lengths: r, luhnCheck: o } = i.numberValidationRules, c = r.includes(n.length), d = !o || g(n);
|
|
294
|
+
return c && d;
|
|
295
|
+
}), u = e.length > 5;
|
|
296
|
+
return {
|
|
297
|
+
brand: s.length > 0 ? s[0].name : null,
|
|
298
|
+
localBrands: l.map((i) => i.name),
|
|
299
|
+
bin: u ? f(e) : null,
|
|
300
|
+
lastFour: a ? n.substring(n.length - 4) : null,
|
|
301
|
+
isValid: a
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
function R(e, n) {
|
|
305
|
+
if (!/^\d{3,4}$/.test(e))
|
|
306
|
+
return {
|
|
307
|
+
cvc: null,
|
|
308
|
+
isValid: false
|
|
309
|
+
};
|
|
310
|
+
if (!n)
|
|
311
|
+
return {
|
|
312
|
+
cvc: e,
|
|
313
|
+
isValid: true
|
|
314
|
+
};
|
|
315
|
+
const t = C(n);
|
|
316
|
+
if (!t.isValid)
|
|
317
|
+
return {
|
|
318
|
+
cvc: null,
|
|
319
|
+
isValid: false
|
|
320
|
+
};
|
|
321
|
+
const s = [];
|
|
322
|
+
t.brand && s.push(t.brand), t.localBrands && s.push(...t.localBrands);
|
|
323
|
+
const l = h.filter((a) => s.includes(a.name)).some((a) => a.securityCodeValidationRules.lengths.includes(e.length));
|
|
324
|
+
return {
|
|
325
|
+
cvc: l ? e : null,
|
|
326
|
+
isValid: l
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
function b(e) {
|
|
330
|
+
var i;
|
|
331
|
+
const n = /^(0[1-9]|1[[0-2]).*$/, t = e.match(n), s = t ? parseInt(t[1].toString(), 10) : null, l = /^(0[1-9]|1[[0-2])(\d{2})$/, a = e.match(l), u = a ? parseInt(a[2].toString(), 10) : null;
|
|
332
|
+
if (s) {
|
|
333
|
+
const r = (/* @__PURE__ */ new Date()).getFullYear() % 100, o = (/* @__PURE__ */ new Date()).getMonth() + 1, c = !u || u < r || u === r && s < o;
|
|
334
|
+
return {
|
|
335
|
+
month: s.toString().padStart(2, "0"),
|
|
336
|
+
year: ((i = u == null ? void 0 : u.toString()) == null ? void 0 : i.padStart(2, "0")) ?? null,
|
|
337
|
+
isValid: !c
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
return {
|
|
341
|
+
month: null,
|
|
342
|
+
year: null,
|
|
343
|
+
isValid: false
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
exports.validateCVC = R;
|
|
348
|
+
exports.validateExpiry = b;
|
|
349
|
+
exports.validateNumber = C;
|
package/build/cjs/sdk.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var NativeEvervault = require('./specs/NativeEvervault.js');
|
|
4
|
+
|
|
5
|
+
function getModule() {
|
|
6
|
+
if (!NativeEvervault.NativeEvervault) {
|
|
7
|
+
throw new Error("NativeEvervault is not available.");
|
|
8
|
+
}
|
|
9
|
+
return NativeEvervault.NativeEvervault;
|
|
10
|
+
}
|
|
11
|
+
const sdk = {
|
|
12
|
+
verify() {
|
|
13
|
+
getModule();
|
|
14
|
+
return true;
|
|
15
|
+
},
|
|
16
|
+
initialize(teamId, appId) {
|
|
17
|
+
const evervault = getModule();
|
|
18
|
+
if (!teamId) {
|
|
19
|
+
throw new Error("Team ID is required.");
|
|
20
|
+
}
|
|
21
|
+
if (!appId) {
|
|
22
|
+
throw new Error("App ID is required.");
|
|
23
|
+
}
|
|
24
|
+
return evervault.initialize(teamId, appId);
|
|
25
|
+
},
|
|
26
|
+
async encrypt(instanceId, data) {
|
|
27
|
+
const evervault = getModule();
|
|
28
|
+
if (data === undefined) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
else if (data === null) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
else if (typeof data === "string") {
|
|
35
|
+
return (await evervault.encryptString(instanceId, data));
|
|
36
|
+
}
|
|
37
|
+
else if (typeof data === "number") {
|
|
38
|
+
return (await evervault.encryptNumber(instanceId, data));
|
|
39
|
+
}
|
|
40
|
+
else if (typeof data === "boolean") {
|
|
41
|
+
return (await evervault.encryptBoolean(instanceId, data));
|
|
42
|
+
}
|
|
43
|
+
else if (Array.isArray(data)) {
|
|
44
|
+
return (await evervault.encryptArray(instanceId, data));
|
|
45
|
+
}
|
|
46
|
+
else if (typeof data === "object") {
|
|
47
|
+
return (await evervault.encryptObject(instanceId, data));
|
|
48
|
+
}
|
|
49
|
+
throw new Error("Unsupported data type.");
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
exports.sdk = sdk;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var context = require('./context.js');
|
|
5
|
+
|
|
6
|
+
function useEvervault() {
|
|
7
|
+
const context$1 = React.useContext(context.EvervaultContext);
|
|
8
|
+
if (!context$1) {
|
|
9
|
+
throw new Error("`useEvervault` must be used within an `EvervaultProvider`.");
|
|
10
|
+
}
|
|
11
|
+
return context$1;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
exports.useEvervault = useEvervault;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
// Taken from https://github.com/gregberge/react-merge-refs
|
|
6
|
+
function mergeRefs(...refs) {
|
|
7
|
+
return (value) => {
|
|
8
|
+
refs.forEach((ref) => {
|
|
9
|
+
if (typeof ref === "function") {
|
|
10
|
+
ref(value);
|
|
11
|
+
}
|
|
12
|
+
else if (ref != null) {
|
|
13
|
+
ref.current = value;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
class ErrorBoundary extends React.Component {
|
|
19
|
+
state = { hasError: false };
|
|
20
|
+
static getDerivedStateFromError() {
|
|
21
|
+
return { hasError: true };
|
|
22
|
+
}
|
|
23
|
+
componentDidCatch(error) {
|
|
24
|
+
this.props.onError?.(error);
|
|
25
|
+
}
|
|
26
|
+
render() {
|
|
27
|
+
if (this.state.hasError)
|
|
28
|
+
return null;
|
|
29
|
+
return this.props.children;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
exports.ErrorBoundary = ErrorBoundary;
|
|
34
|
+
exports.mergeRefs = mergeRefs;
|
|
@@ -9,4 +9,3 @@ export interface CardCvcProps extends BaseEvervaultInputProps {
|
|
|
9
9
|
}
|
|
10
10
|
export type CardCvc = EvervaultInput;
|
|
11
11
|
export declare const CardCvc: import("react").ForwardRefExoticComponent<CardCvcProps & import("react").RefAttributes<EvervaultInput>>;
|
|
12
|
-
//# sourceMappingURL=Cvc.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef, useMemo } from 'react';
|
|
3
|
+
import { mask, EvervaultInput } from '../Input.js';
|
|
4
|
+
import { validateNumber as C } from '../packages/card-validator/dist/evervault-card-validator.main.js';
|
|
5
|
+
import { useFormContext } from '../node_modules/react-hook-form/dist/index.esm.js';
|
|
6
|
+
|
|
7
|
+
const DEFAULT_CARD_CVC_MASK = mask("[999]");
|
|
8
|
+
const CARD_CVC_MASKS = {
|
|
9
|
+
"american-express": mask("[9999]"),
|
|
10
|
+
};
|
|
11
|
+
const CardCvc = forwardRef(function CardCvc(props, ref) {
|
|
12
|
+
const methods = useFormContext();
|
|
13
|
+
const number = methods.watch("number");
|
|
14
|
+
const mask = useMemo(() => {
|
|
15
|
+
if (!number) {
|
|
16
|
+
return DEFAULT_CARD_CVC_MASK;
|
|
17
|
+
}
|
|
18
|
+
const brand = C(number).brand;
|
|
19
|
+
if (brand && CARD_CVC_MASKS[brand]) {
|
|
20
|
+
return CARD_CVC_MASKS[brand];
|
|
21
|
+
}
|
|
22
|
+
return DEFAULT_CARD_CVC_MASK;
|
|
23
|
+
}, [number]);
|
|
24
|
+
return (jsx(EvervaultInput, { placeholder: "CVC", ...props, ref: ref, name: "cvc", mask: mask, inputMode: "numeric", autoComplete: "cc-csc", keyboardType: "number-pad" }));
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export { CardCvc };
|
|
@@ -2,4 +2,3 @@ import { BaseEvervaultInputProps, EvervaultInput } from "../Input";
|
|
|
2
2
|
export type CardExpiryProps = BaseEvervaultInputProps;
|
|
3
3
|
export type CardExpiry = EvervaultInput;
|
|
4
4
|
export declare const CardExpiry: import("react").ForwardRefExoticComponent<BaseEvervaultInputProps & import("react").RefAttributes<EvervaultInput>>;
|
|
5
|
-
//# sourceMappingURL=Expiry.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { mask, EvervaultInput } from '../Input.js';
|
|
4
|
+
|
|
5
|
+
const CARD_EXPIRY_MASK = mask("99 / 99");
|
|
6
|
+
const CardExpiry = forwardRef(function CardExpiry(props, ref) {
|
|
7
|
+
return (jsx(EvervaultInput, { placeholder: "MM / YY", ...props, ref: ref, name: "expiry", mask: CARD_EXPIRY_MASK, inputMode: "numeric", autoComplete: "cc-exp", keyboardType: "number-pad" }));
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export { CardExpiry };
|
|
@@ -2,4 +2,3 @@ import { BaseEvervaultInputProps, EvervaultInput } from "../Input";
|
|
|
2
2
|
export type CardHolderProps = BaseEvervaultInputProps;
|
|
3
3
|
export type CardHolder = EvervaultInput;
|
|
4
4
|
export declare const CardHolder: import("react").ForwardRefExoticComponent<BaseEvervaultInputProps & import("react").RefAttributes<EvervaultInput>>;
|
|
5
|
-
//# sourceMappingURL=Holder.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Platform } from 'react-native';
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import { EvervaultInput } from '../Input.js';
|
|
5
|
+
|
|
6
|
+
const CardHolder = forwardRef(function CardHolder(props, ref) {
|
|
7
|
+
return (jsx(EvervaultInput, { placeholder: "Johnny Appleseed", ...props, ref: ref, name: "name", inputMode: "text", autoComplete: Platform.select({
|
|
8
|
+
ios: "cc-name",
|
|
9
|
+
default: "name",
|
|
10
|
+
}), keyboardType: "default" }));
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export { CardHolder };
|
|
@@ -9,4 +9,3 @@ export interface CardNumberProps extends BaseEvervaultInputProps {
|
|
|
9
9
|
}
|
|
10
10
|
export type CardNumber = EvervaultInput;
|
|
11
11
|
export declare const CardNumber: import("react").ForwardRefExoticComponent<CardNumberProps & import("react").RefAttributes<EvervaultInput>>;
|
|
12
|
-
//# sourceMappingURL=Number.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef, useCallback } from 'react';
|
|
3
|
+
import { mask, EvervaultInput } from '../Input.js';
|
|
4
|
+
import { validateNumber as C } from '../packages/card-validator/dist/evervault-card-validator.main.js';
|
|
5
|
+
|
|
6
|
+
const DEFAULT_CARD_NUMBER_MASK = mask("9999 99[99 9999 9999]");
|
|
7
|
+
const CARD_NUMBER_MASKS = {
|
|
8
|
+
unionpay: mask("9999 99[99 9999 9999 999]"),
|
|
9
|
+
"american-express": mask("9999 99[9999 99999]"),
|
|
10
|
+
};
|
|
11
|
+
const CardNumber = forwardRef(function CardNumber(props, ref) {
|
|
12
|
+
const mask = useCallback((text) => {
|
|
13
|
+
if (!text) {
|
|
14
|
+
return DEFAULT_CARD_NUMBER_MASK;
|
|
15
|
+
}
|
|
16
|
+
const brand = C(text).brand;
|
|
17
|
+
if (brand && CARD_NUMBER_MASKS[brand]) {
|
|
18
|
+
return CARD_NUMBER_MASKS[brand];
|
|
19
|
+
}
|
|
20
|
+
return DEFAULT_CARD_NUMBER_MASK;
|
|
21
|
+
}, []);
|
|
22
|
+
return (jsx(EvervaultInput, { placeholder: "1234 1234 1234 1234", ...props, ref: ref, name: "number", mask: mask, inputMode: "numeric", autoComplete: "cc-number", keyboardType: "number-pad" }));
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export { CardNumber };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef, useMemo, useRef, useEffect, useImperativeHandle, useCallback } from 'react';
|
|
3
|
+
import { useForm, FormProvider } from '../node_modules/react-hook-form/dist/index.esm.js';
|
|
4
|
+
import { getCardFormSchema } from './schema.js';
|
|
5
|
+
import { zodResolver as s } from '../node_modules/@hookform/resolvers/zod/dist/zod.js';
|
|
6
|
+
import { useEvervault } from '../useEvervault.js';
|
|
7
|
+
import { formatPayload } from './utils.js';
|
|
8
|
+
import { EvervaultInputContext } from '../Input.js';
|
|
9
|
+
|
|
10
|
+
const DEFAULT_ACCEPTED_BRANDS = [];
|
|
11
|
+
const Card = forwardRef(function Card({ children, defaultValues, onChange, onError, acceptedBrands = DEFAULT_ACCEPTED_BRANDS, validationMode = "all", }, ref) {
|
|
12
|
+
const evervault = useEvervault();
|
|
13
|
+
const resolver = useMemo(() => {
|
|
14
|
+
const schema = getCardFormSchema(acceptedBrands);
|
|
15
|
+
return s(schema);
|
|
16
|
+
}, [acceptedBrands]);
|
|
17
|
+
const methods = useForm({
|
|
18
|
+
defaultValues,
|
|
19
|
+
resolver,
|
|
20
|
+
mode: validationMode,
|
|
21
|
+
shouldUseNativeValidation: false,
|
|
22
|
+
});
|
|
23
|
+
const inputContext = useMemo(() => ({
|
|
24
|
+
validationMode,
|
|
25
|
+
}), [validationMode]);
|
|
26
|
+
// Use refs to prevent closures from being captured
|
|
27
|
+
const onChangeRef = useRef(onChange);
|
|
28
|
+
onChangeRef.current = onChange;
|
|
29
|
+
const onErrorRef = useRef(onError);
|
|
30
|
+
onErrorRef.current = onError;
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (!onChange)
|
|
33
|
+
return;
|
|
34
|
+
let abortController;
|
|
35
|
+
function handleChange(values) {
|
|
36
|
+
if (abortController) {
|
|
37
|
+
abortController.abort();
|
|
38
|
+
}
|
|
39
|
+
abortController = new AbortController();
|
|
40
|
+
const signal = abortController.signal;
|
|
41
|
+
requestAnimationFrame(async () => {
|
|
42
|
+
try {
|
|
43
|
+
const payload = await formatPayload(values, {
|
|
44
|
+
encrypt: evervault.encrypt,
|
|
45
|
+
form: methods,
|
|
46
|
+
});
|
|
47
|
+
if (signal.aborted)
|
|
48
|
+
return;
|
|
49
|
+
onChangeRef.current?.(payload);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
onErrorRef.current?.(error);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
handleChange(methods.getValues());
|
|
57
|
+
const subscription = methods.watch(handleChange);
|
|
58
|
+
return () => subscription.unsubscribe();
|
|
59
|
+
}, [evervault.encrypt]);
|
|
60
|
+
useImperativeHandle(ref, useCallback(() => ({
|
|
61
|
+
reset() {
|
|
62
|
+
methods.reset();
|
|
63
|
+
},
|
|
64
|
+
}), []));
|
|
65
|
+
return (jsx(FormProvider, { ...methods, children: jsx(EvervaultInputContext.Provider, { value: inputContext, children: children }) }));
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
export { Card };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Card as Card$1 } from './Root.js';
|
|
2
|
+
import { CardHolder } from './Holder.js';
|
|
3
|
+
import { CardExpiry } from './Expiry.js';
|
|
4
|
+
import { CardCvc } from './Cvc.js';
|
|
5
|
+
import { CardNumber } from './Number.js';
|
|
6
|
+
|
|
7
|
+
const Card = Object.assign(Card$1, {
|
|
8
|
+
Holder: CardHolder,
|
|
9
|
+
Expiry: CardExpiry,
|
|
10
|
+
Cvc: CardCvc,
|
|
11
|
+
Number: CardNumber,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export { Card, CardCvc, CardExpiry, CardHolder, CardNumber };
|