@originallyus/feedback-rn-sdk 4.0.0-beta.6 → 4.0.0-beta.7
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.
Potentially problematic release.
This version of @originallyus/feedback-rn-sdk might be problematic. Click here for more details.
- package/package.json +2 -3
- package/src/AIAContentUsefulness.tsx +0 -296
- package/src/AIAFeedback.tsx +0 -354
- package/src/AIAFeedbackForm.tsx +0 -267
- package/src/AIAFeedbackSplash.tsx +0 -49
- package/src/AIAFeedbackStyles.ts +0 -311
- package/src/AIAFeedbackSuccess.tsx +0 -67
- package/src/assets/CheckIcon.tsx +0 -18
- package/src/assets/CloseIcon.tsx +0 -18
- package/src/assets/ErrorIcon.tsx +0 -18
- package/src/assets/PlusIcon.tsx +0 -18
- package/src/assets/StarIcon.tsx +0 -18
- package/src/component/Button.tsx +0 -68
- package/src/component/ButtonSubmit.tsx +0 -335
- package/src/component/Input.tsx +0 -288
- package/src/component/MultiSelectButtons.tsx +0 -272
- package/src/component/README.md +0 -215
- package/src/component/READMEVI.md +0 -192
- package/src/component/Rating.tsx +0 -248
- package/src/component/RatingNumber.tsx +0 -421
- package/src/component/Textarea.tsx +0 -282
- package/src/component/YesNoButtons.tsx +0 -236
- package/src/index.tsx +0 -33
- package/src/service/feedbackService.ts +0 -108
- package/src/utils/common.ts +0 -241
- package/src/utils/constants.ts +0 -60
- package/src/utils/index.ts +0 -167
- package/src/utils/networking.ts +0 -134
package/src/utils/common.ts
DELETED
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
import {Dimensions, I18nManager, Platform, Settings, NativeModules} from 'react-native'
|
|
2
|
-
|
|
3
|
-
const isExpo = !NativeModules || Object.keys(NativeModules).length === 0 || !NativeModules.RNDeviceInfo
|
|
4
|
-
|
|
5
|
-
type DeviceInfoLike = {
|
|
6
|
-
getUniqueId: () => string | Promise<string>
|
|
7
|
-
getSystemVersion: () => string | Promise<string>
|
|
8
|
-
getVersion: () => string | Promise<string>
|
|
9
|
-
getBuildNumber: () => string | Promise<string>
|
|
10
|
-
getModel: () => string | Promise<string>
|
|
11
|
-
getBundleId: () => string | Promise<string>
|
|
12
|
-
getManufacturer: () => string | Promise<string>
|
|
13
|
-
getDeviceType: () => string | Promise<string>
|
|
14
|
-
getDeviceId: () => string | Promise<string>
|
|
15
|
-
getBrand: () => string | Promise<string>
|
|
16
|
-
isTablet: () => boolean
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
let DeviceInfo: DeviceInfoLike = {
|
|
20
|
-
getUniqueId: function getUniqueIdDefault() {
|
|
21
|
-
return ''
|
|
22
|
-
},
|
|
23
|
-
getSystemVersion: function getSystemVersionDefault() {
|
|
24
|
-
return ''
|
|
25
|
-
},
|
|
26
|
-
getVersion: function getVersionDefault() {
|
|
27
|
-
return ''
|
|
28
|
-
},
|
|
29
|
-
getBuildNumber: function getBuildNumberDefault() {
|
|
30
|
-
return ''
|
|
31
|
-
},
|
|
32
|
-
getModel: function getModelDefault() {
|
|
33
|
-
return ''
|
|
34
|
-
},
|
|
35
|
-
getBundleId: function getBundleIdDefault() {
|
|
36
|
-
return ''
|
|
37
|
-
},
|
|
38
|
-
getManufacturer: function getManufacturerDefault() {
|
|
39
|
-
return ''
|
|
40
|
-
},
|
|
41
|
-
getDeviceType: function getDeviceTypeDefault() {
|
|
42
|
-
return ''
|
|
43
|
-
},
|
|
44
|
-
getDeviceId: function getDeviceIdDefault() {
|
|
45
|
-
return ''
|
|
46
|
-
},
|
|
47
|
-
getBrand: function getBrandDefault() {
|
|
48
|
-
return ''
|
|
49
|
-
},
|
|
50
|
-
isTablet: function isTabletDefault() {
|
|
51
|
-
return false
|
|
52
|
-
},
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (isExpo) {
|
|
56
|
-
const expoDevice = require('expo-device')
|
|
57
|
-
|
|
58
|
-
const expoApplication = require('expo-application')
|
|
59
|
-
|
|
60
|
-
DeviceInfo = {
|
|
61
|
-
getUniqueId: function getUniqueIdForExpo() {
|
|
62
|
-
if (Platform.OS === 'android') {
|
|
63
|
-
return expoApplication.getAndroidId()
|
|
64
|
-
}
|
|
65
|
-
return expoApplication.getIosIdForVendorAsync()
|
|
66
|
-
},
|
|
67
|
-
getSystemVersion: function getSystemVersionForExpo() {
|
|
68
|
-
return expoDevice.osVersion || ''
|
|
69
|
-
},
|
|
70
|
-
getVersion: function getVersionForExpo() {
|
|
71
|
-
return expoApplication.nativeApplicationVersion || ''
|
|
72
|
-
},
|
|
73
|
-
getBuildNumber: function getBuildNumberForExpo() {
|
|
74
|
-
return expoApplication.nativeBuildVersion || ''
|
|
75
|
-
},
|
|
76
|
-
getModel: function getModelForExpo() {
|
|
77
|
-
return expoDevice.modelName || ''
|
|
78
|
-
},
|
|
79
|
-
getBundleId: function getBundleIdForExpo() {
|
|
80
|
-
return expoApplication.applicationId || ''
|
|
81
|
-
},
|
|
82
|
-
getManufacturer: function getManufacturerForExpo() {
|
|
83
|
-
if (expoDevice.getManufacturerAsync) {
|
|
84
|
-
return expoDevice.getManufacturerAsync()
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return expoDevice.manufacturer || ''
|
|
88
|
-
},
|
|
89
|
-
getDeviceType: function getDeviceTypeForExpo() {
|
|
90
|
-
if (expoDevice.deviceType) {
|
|
91
|
-
return String(expoDevice.deviceType)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return ''
|
|
95
|
-
},
|
|
96
|
-
getDeviceId: function getDeviceIdForExpo() {
|
|
97
|
-
if (expoDevice.modelId) {
|
|
98
|
-
return expoDevice.modelId
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (expoDevice.modelName) {
|
|
102
|
-
return expoDevice.modelName
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return ''
|
|
106
|
-
},
|
|
107
|
-
getBrand: function getBrandForExpo() {
|
|
108
|
-
return expoDevice.brand || ''
|
|
109
|
-
},
|
|
110
|
-
isTablet: function isTabletForExpo() {
|
|
111
|
-
if (expoDevice.deviceType === 'tablet' || expoDevice.deviceType === 2) {
|
|
112
|
-
return true
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return false
|
|
116
|
-
},
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
if (!isExpo) {
|
|
120
|
-
const rnDeviceInfo = require('react-native-device-info') as DeviceInfoLike
|
|
121
|
-
DeviceInfo = rnDeviceInfo
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export const isTablet: boolean = DeviceInfo.isTablet()
|
|
125
|
-
const {width, height} = Dimensions.get('window')
|
|
126
|
-
|
|
127
|
-
export function isObject(value: unknown): value is object {
|
|
128
|
-
const type = typeof value
|
|
129
|
-
return value != null && (type === 'object' || type === 'function')
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export function sample<T>(array: T[] | null | undefined): T | undefined {
|
|
133
|
-
const length = array == null ? 0 : array.length
|
|
134
|
-
const timestampSeconds = Math.floor(Date.now() / 1000)
|
|
135
|
-
return length && array ? array[timestampSeconds % length] : undefined
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export function isNil(value: unknown): value is null | undefined {
|
|
139
|
-
return value == null
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export function w_p(widthVal: number, paddingNumber: number): number {
|
|
143
|
-
return (paddingNumber / 375) * widthVal
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export function w_p21(widthVal: number): number {
|
|
147
|
-
return (21 / 375) * widthVal
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
export function w_p16(widthVal: number): number {
|
|
151
|
-
return (16 / 375) * widthVal
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
export function h_p21(heightVal: number): number {
|
|
155
|
-
return (21 / 667) * heightVal
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export function h_p16(heightVal: number): number {
|
|
159
|
-
return (16 / 667) * heightVal
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export function getAppWidth(isIntrusive: boolean): number {
|
|
163
|
-
let appWidth = width
|
|
164
|
-
if (isTablet) {
|
|
165
|
-
appWidth = isIntrusive ? 768 : 375
|
|
166
|
-
}
|
|
167
|
-
return appWidth
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
export function getAppHeight(isIntrusive: boolean): number {
|
|
171
|
-
let appHeight = height
|
|
172
|
-
if (isTablet) {
|
|
173
|
-
appHeight = isIntrusive ? (height * 3) / 4 : 450
|
|
174
|
-
}
|
|
175
|
-
return appHeight
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
export const getUniqueID = async (): Promise<string> => {
|
|
179
|
-
const result = DeviceInfo.getUniqueId()
|
|
180
|
-
return typeof result === 'object' ? await result : result
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
export const getSystemVersion = async (): Promise<string> => {
|
|
184
|
-
const result = DeviceInfo.getSystemVersion()
|
|
185
|
-
return typeof result === 'object' ? await result : result
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export const getVersion = async (): Promise<string> => {
|
|
189
|
-
const result = DeviceInfo.getVersion()
|
|
190
|
-
return typeof result === 'object' ? await result : result
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
export const getBuildNumber = async (): Promise<string> => {
|
|
194
|
-
const result = DeviceInfo.getBuildNumber()
|
|
195
|
-
return typeof result === 'object' ? await result : result
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
export const getModel = async (): Promise<string> => {
|
|
199
|
-
const result = DeviceInfo.getModel()
|
|
200
|
-
return typeof result === 'object' ? await result : result
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
export const getBundleId = async (): Promise<string> => {
|
|
204
|
-
const result = DeviceInfo.getBundleId()
|
|
205
|
-
return typeof result === 'object' ? await result : result
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
export const getManufacturer = async (): Promise<string> => {
|
|
209
|
-
const result = DeviceInfo.getManufacturer()
|
|
210
|
-
return typeof result === 'object' ? await result : result
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
export const getDeviceType = async (): Promise<string> => {
|
|
214
|
-
const result = DeviceInfo.getDeviceType()
|
|
215
|
-
return typeof result === 'object' ? await result : result
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
export const getDeviceId = async (): Promise<string> => {
|
|
219
|
-
const result = DeviceInfo.getDeviceId()
|
|
220
|
-
return typeof result === 'object' ? await result : result
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
export const getBrand = async (): Promise<string> => {
|
|
224
|
-
const result = DeviceInfo.getBrand()
|
|
225
|
-
return typeof result === 'object' ? await result : result
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
export const getLocale = async (): Promise<string> => {
|
|
229
|
-
let currentLocale = 'en'
|
|
230
|
-
|
|
231
|
-
if (Platform.OS === 'ios') {
|
|
232
|
-
const settings = Settings.get('AppleLocale') as string | undefined
|
|
233
|
-
const locale = settings
|
|
234
|
-
if (locale) currentLocale = typeof locale === 'string' ? locale : String(locale)
|
|
235
|
-
} else {
|
|
236
|
-
const locale = I18nManager.getConstants().localeIdentifier
|
|
237
|
-
if (locale) currentLocale = locale
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
return currentLocale
|
|
241
|
-
}
|
package/src/utils/constants.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
// Brand Colors
|
|
2
|
-
export const PRIMARY_COLOR = 'rgba(224, 8, 66, 1)'
|
|
3
|
-
export const PRESSED_COLOR = 'hsl(344, 92.90%, 38.40%)'
|
|
4
|
-
export const ERROR_COLOR = '#D40C74'
|
|
5
|
-
|
|
6
|
-
// Background Colors
|
|
7
|
-
export const BG_DEFAULT = '#FFFFFF'
|
|
8
|
-
export const BG_SECONDARY = '#EBEDF3'
|
|
9
|
-
export const BG_DISABLED = 'rgba(224, 224, 224, 1)'
|
|
10
|
-
export const BG_DISABLED_SECONDARY = 'rgba(240, 240, 240, 1)'
|
|
11
|
-
export const BG_BUTTON_SECONDARY = 'rgba(255, 237, 241, 1)'
|
|
12
|
-
|
|
13
|
-
export const BG_SELECTED = '#ebedf3'
|
|
14
|
-
// Border Colors
|
|
15
|
-
export const BORDER_DEFAULT = '#858b91'
|
|
16
|
-
export const BORDER_SECONDARY = 'rgba(133, 139, 145, 1)'
|
|
17
|
-
export const BORDER_FOCUS = '#082065'
|
|
18
|
-
export const BORDER_SELECTED = '#082065'
|
|
19
|
-
|
|
20
|
-
// Text Colors
|
|
21
|
-
export const TEXT_DEFAULT = '#082065'
|
|
22
|
-
export const TEXT_DARK = '#000000'
|
|
23
|
-
export const TEXT_WHITE = '#FFFFFF'
|
|
24
|
-
export const TEXT_PLACEHOLDER = '#9E9E9E'
|
|
25
|
-
export const TEXT_NOTE = '#757575'
|
|
26
|
-
export const TEXT_DISABLED = 'rgba(168, 168, 168, 1)'
|
|
27
|
-
|
|
28
|
-
// Component Specific Colors
|
|
29
|
-
export const COLOR_STAR_NORMAL = '#D0D0D0'
|
|
30
|
-
export const COLOR_STAR_SELECTED = '#F7C926'
|
|
31
|
-
|
|
32
|
-
export interface InitOptions {
|
|
33
|
-
language?: string
|
|
34
|
-
userId?: string | null
|
|
35
|
-
formSlug?: string
|
|
36
|
-
debug?: boolean
|
|
37
|
-
eventTag?: string
|
|
38
|
-
metadata?: any
|
|
39
|
-
appSec?: string
|
|
40
|
-
packageId?: string
|
|
41
|
-
deviceUuid?: string
|
|
42
|
-
[key: string]: any
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export const OUS_VARS: any = {
|
|
46
|
-
ratingStars: 0,
|
|
47
|
-
fonts: null,
|
|
48
|
-
theme: null,
|
|
49
|
-
sdkCallbackFunction: null,
|
|
50
|
-
version: '4.0.0.beta.16', // Aligning with web version for compatibility
|
|
51
|
-
uuid: '',
|
|
52
|
-
language: 'en',
|
|
53
|
-
options: null,
|
|
54
|
-
ENDPOINTS: ['VlAI2Q1FDHvASMhqTXe0', 'rNwrNi5Iw36epJS9gprO', 'Ij8Ji87IpdZTXSw1kAFV'],
|
|
55
|
-
API_URL: 'https://aia-dfs.originally.us/backend',
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export const xmlsUrl = 'http://www.w3.org/2000/svg'
|
|
59
|
-
export const containerId = 'sdk_view_container'
|
|
60
|
-
export const inlineComponentId = 'sdk_inline_view_container'
|
package/src/utils/index.ts
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import {Dimensions, Platform, PixelRatio} from 'react-native'
|
|
2
|
-
|
|
3
|
-
const randomFrom = <T>(arr: T[]): T | undefined => {
|
|
4
|
-
return arr.length ? arr[Math.floor(Math.random() * arr.length)] : undefined
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
const trimLeft = (str: string, charlist?: string): string => {
|
|
8
|
-
if (!charlist) return str.replace(/^\s+/, '')
|
|
9
|
-
return str.replace(new RegExp('^[' + charlist + ']+'), '')
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const trimRight = (str: string, charlist?: string): string => {
|
|
13
|
-
if (!charlist) return str.replace(/\s+$/, '')
|
|
14
|
-
return str.replace(new RegExp('[' + charlist + ']+$'), '')
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const trim = (str: string, charlist?: string): string => {
|
|
18
|
-
if (charlist === undefined || charlist === null || charlist === '') {
|
|
19
|
-
return str.replace(/^\s+|\s+$/g, '')
|
|
20
|
-
}
|
|
21
|
-
return trimLeft(trimRight(str, charlist), charlist)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const sha256 = async (str: string): Promise<string> => {
|
|
25
|
-
const utf8 = (s: string) => {
|
|
26
|
-
const out: number[] = []
|
|
27
|
-
for (let i = 0; i < s.length; i++) {
|
|
28
|
-
let c = s.charCodeAt(i)
|
|
29
|
-
|
|
30
|
-
if (c < 0x80) out.push(c)
|
|
31
|
-
// eslint-disable-next-line no-bitwise
|
|
32
|
-
else if (c < 0x800) out.push(0xc0 | (c >> 6), 0x80 | (c & 0x3f))
|
|
33
|
-
// eslint-disable-next-line no-bitwise
|
|
34
|
-
else if (c < 0xd800 || c >= 0xe000) out.push(0xe0 | (c >> 12), 0x80 | ((c >> 6) & 0x3f), 0x80 | (c & 0x3f))
|
|
35
|
-
else {
|
|
36
|
-
// eslint-disable-next-line no-bitwise
|
|
37
|
-
c = 0x10000 + (((c & 0x3ff) << 10) | (s.charCodeAt(++i) & 0x3ff))
|
|
38
|
-
// eslint-disable-next-line no-bitwise
|
|
39
|
-
out.push(0xf0 | (c >> 18), 0x80 | ((c >> 12) & 0x3f), 0x80 | ((c >> 6) & 0x3f), 0x80 | (c & 0x3f))
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return new Uint8Array(out)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// eslint-disable-next-line no-bitwise
|
|
46
|
-
const rotr = (n: number, b: number) => (n >>> b) | (n << (32 - b))
|
|
47
|
-
// eslint-disable-next-line no-bitwise
|
|
48
|
-
const sig0 = (x: number) => rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22)
|
|
49
|
-
// eslint-disable-next-line no-bitwise
|
|
50
|
-
const sig1 = (x: number) => rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25)
|
|
51
|
-
// eslint-disable-next-line no-bitwise
|
|
52
|
-
const gam0 = (x: number) => rotr(x, 7) ^ rotr(x, 18) ^ (x >>> 3)
|
|
53
|
-
// eslint-disable-next-line no-bitwise
|
|
54
|
-
const gam1 = (x: number) => rotr(x, 17) ^ rotr(x, 19) ^ (x >>> 10)
|
|
55
|
-
// eslint-disable-next-line no-bitwise
|
|
56
|
-
const ch = (x: number, y: number, z: number) => (x & y) ^ (~x & z)
|
|
57
|
-
// eslint-disable-next-line no-bitwise
|
|
58
|
-
const maj = (x: number, y: number, z: number) => (x & y) ^ (x & z) ^ (y & z)
|
|
59
|
-
|
|
60
|
-
const K = new Uint32Array([
|
|
61
|
-
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98,
|
|
62
|
-
0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786,
|
|
63
|
-
0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8,
|
|
64
|
-
0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
|
|
65
|
-
0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819,
|
|
66
|
-
0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a,
|
|
67
|
-
0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7,
|
|
68
|
-
0xc67178f2,
|
|
69
|
-
])
|
|
70
|
-
|
|
71
|
-
const h = new Uint32Array([
|
|
72
|
-
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,
|
|
73
|
-
])
|
|
74
|
-
|
|
75
|
-
const m = utf8(str)
|
|
76
|
-
const l = m.length
|
|
77
|
-
// eslint-disable-next-line no-bitwise
|
|
78
|
-
const n = ((l + 8) >> 6) + 1
|
|
79
|
-
// eslint-disable-next-line no-bitwise
|
|
80
|
-
const w = new Uint32Array(n << 4)
|
|
81
|
-
|
|
82
|
-
for (let i = 0; i < l; i++) {
|
|
83
|
-
const byte = m[i] ?? 0
|
|
84
|
-
// eslint-disable-next-line no-bitwise
|
|
85
|
-
w[i >> 2]! |= byte << (24 - (i % 4) * 8)
|
|
86
|
-
}
|
|
87
|
-
// eslint-disable-next-line no-bitwise
|
|
88
|
-
w[l >> 2]! |= 0x80 << (24 - (l % 4) * 8)
|
|
89
|
-
// eslint-disable-next-line no-bitwise
|
|
90
|
-
w[(n << 4) - 1] = l * 8
|
|
91
|
-
|
|
92
|
-
// eslint-disable-next-line no-bitwise
|
|
93
|
-
for (let i = 0; i < n << 4; i += 16) {
|
|
94
|
-
const W = new Uint32Array(64)
|
|
95
|
-
for (let t = 0; t < 16; t++) W[t] = w[i + t]!
|
|
96
|
-
for (let t = 16; t < 64; t++) W[t] = (gam1(W[t - 2]!) + W[t - 7]! + gam0(W[t - 15]!) + W[t - 16]!) | 0
|
|
97
|
-
|
|
98
|
-
let [a, b, c, d, e, f, g, hh] = h
|
|
99
|
-
|
|
100
|
-
for (let t = 0; t < 64; t++) {
|
|
101
|
-
// eslint-disable-next-line no-bitwise
|
|
102
|
-
const t1 = (hh! + sig1(e!) + ch(e!, f!, g!) + K[t]! + W[t]!) | 0
|
|
103
|
-
// eslint-disable-next-line no-bitwise
|
|
104
|
-
const t2 = (sig0(a!) + maj(a!, b!, c!)) | 0
|
|
105
|
-
hh = g
|
|
106
|
-
g = f
|
|
107
|
-
f = e
|
|
108
|
-
// eslint-disable-next-line no-bitwise
|
|
109
|
-
e = (d! + t1) | 0
|
|
110
|
-
d = c
|
|
111
|
-
c = b
|
|
112
|
-
b = a
|
|
113
|
-
// eslint-disable-next-line no-bitwise
|
|
114
|
-
a = (t1 + t2) | 0
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// eslint-disable-next-line no-bitwise
|
|
118
|
-
h[0] = (h[0]! + a!) | 0
|
|
119
|
-
// eslint-disable-next-line no-bitwise
|
|
120
|
-
h[1] = (h[1]! + b!) | 0
|
|
121
|
-
// eslint-disable-next-line no-bitwise
|
|
122
|
-
h[2] = (h[2]! + c!) | 0
|
|
123
|
-
// eslint-disable-next-line no-bitwise
|
|
124
|
-
h[3] = (h[3]! + d!) | 0
|
|
125
|
-
// eslint-disable-next-line no-bitwise
|
|
126
|
-
h[4] = (h[4]! + e!) | 0
|
|
127
|
-
// eslint-disable-next-line no-bitwise
|
|
128
|
-
h[5] = (h[5]! + f!) | 0
|
|
129
|
-
// eslint-disable-next-line no-bitwise
|
|
130
|
-
h[6] = (h[6]! + g!) | 0
|
|
131
|
-
// eslint-disable-next-line no-bitwise
|
|
132
|
-
h[7] = (h[7]! + hh!) | 0
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return Array.from(h)
|
|
136
|
-
.map(x => (x >>> 0).toString(16).padStart(8, '0'))
|
|
137
|
-
.join('')
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const sigma256 = async (apiPath: string, timeStamp: number) => {
|
|
141
|
-
return sha256('∑' + apiPath + (timeStamp + 2272) + '∆')
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const copyright256 = async (apiPath: string, timeStamp: number) => {
|
|
145
|
-
return sha256('©' + apiPath + (timeStamp + 5524) + '®')
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
const delay = (ms: number) => {
|
|
149
|
-
return new Promise(resolve => setTimeout(resolve, ms))
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export {delay, randomFrom, trim, trimLeft, trimRight, sigma256, copyright256, sha256}
|
|
153
|
-
|
|
154
|
-
export var {width: SCREEN_WIDTH, height: SCREEN_HEIGHT} = Dimensions.get('window')
|
|
155
|
-
|
|
156
|
-
// based on iPhone 8's scale
|
|
157
|
-
const wscale: number = SCREEN_WIDTH / 375
|
|
158
|
-
const hscale: number = SCREEN_HEIGHT / 667
|
|
159
|
-
|
|
160
|
-
export default function normalize(size: number, based: 'width' | 'height' = 'width') {
|
|
161
|
-
const newSize = based === 'height' ? size * hscale : size * wscale
|
|
162
|
-
if (Platform.OS === 'ios') {
|
|
163
|
-
return Math.round(PixelRatio.roundToNearestPixel(newSize))
|
|
164
|
-
} else {
|
|
165
|
-
return Math.round(PixelRatio.roundToNearestPixel(newSize)) - 2
|
|
166
|
-
}
|
|
167
|
-
}
|
package/src/utils/networking.ts
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import {Platform} from 'react-native'
|
|
2
|
-
import '@/utils' // load prototype extensions
|
|
3
|
-
import {OUS_VARS, type InitOptions} from '@/utils/constants'
|
|
4
|
-
import {sha256, sigma256, copyright256} from '@/utils'
|
|
5
|
-
|
|
6
|
-
export interface CustomFetchParams {
|
|
7
|
-
_shouldRetry: boolean
|
|
8
|
-
_url: string
|
|
9
|
-
_data: any
|
|
10
|
-
_callback: (response: any) => void
|
|
11
|
-
options?: InitOptions
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
var ousFeedbackSdkTimestampDelta: number | null = null
|
|
15
|
-
|
|
16
|
-
const customFetch = async ({_shouldRetry, _url, _data, _callback, options}: CustomFetchParams) => {
|
|
17
|
-
const currentOptions = options || OUS_VARS.options
|
|
18
|
-
if (!currentOptions) {
|
|
19
|
-
console.warn('FeedbackSDK Error', 'Missing initialization options')
|
|
20
|
-
return
|
|
21
|
-
}
|
|
22
|
-
if (!currentOptions.appSec) {
|
|
23
|
-
console.warn('FeedbackSDK Error', 'Code 298761: missing credential appSec')
|
|
24
|
-
return
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
let packageId = currentOptions.packageId || currentOptions.pakageId
|
|
28
|
-
if (!packageId) {
|
|
29
|
-
console.error('FeedbackSDK Error', 'Code 289769: missing packageId')
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const mandatoryHeaders = new Headers()
|
|
33
|
-
mandatoryHeaders.set('x-app-sec', currentOptions.appSec || '')
|
|
34
|
-
mandatoryHeaders.set('x-package-id', packageId || '')
|
|
35
|
-
mandatoryHeaders.set('x-sdk-platform', Platform.OS)
|
|
36
|
-
mandatoryHeaders.set('x-device-uuid', currentOptions.deviceUuid || OUS_VARS.uuid || '')
|
|
37
|
-
mandatoryHeaders.set('x-version', OUS_VARS.version || '')
|
|
38
|
-
mandatoryHeaders.set('x-lang', currentOptions.language || OUS_VARS.language || 'en')
|
|
39
|
-
mandatoryHeaders.set('x-app-user-id', currentOptions.userId || '')
|
|
40
|
-
// TODO: add x-app-user-id mode debug
|
|
41
|
-
if (currentOptions.debug) {
|
|
42
|
-
mandatoryHeaders.set('x-debug', '1')
|
|
43
|
-
}
|
|
44
|
-
mandatoryHeaders.set('content-type', 'application/json')
|
|
45
|
-
|
|
46
|
-
if (currentOptions.debug) {
|
|
47
|
-
console.log('Feedback SDK Headers:', JSON.stringify(Object.fromEntries((mandatoryHeaders as any).entries())))
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
var api_path = _url
|
|
51
|
-
if (!api_path) {
|
|
52
|
-
console.error("Feedback SDK: Invalid 'api_path' ", api_path)
|
|
53
|
-
return
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// remove leading and trailing slashes from the api path
|
|
57
|
-
api_path = `${api_path}`.replace(/^\/+|\/+$/g, '')
|
|
58
|
-
|
|
59
|
-
// Random endpoint selection
|
|
60
|
-
const randomEndpoint = Array.isArray(OUS_VARS.ENDPOINTS)
|
|
61
|
-
? OUS_VARS.ENDPOINTS[Math.floor(Math.random() * OUS_VARS.ENDPOINTS.length)]
|
|
62
|
-
: OUS_VARS.ENDPOINTS.random()
|
|
63
|
-
var url = `${OUS_VARS.API_URL}/${randomEndpoint}`
|
|
64
|
-
|
|
65
|
-
// Calculate server timestamp
|
|
66
|
-
const device_timestamp = Math.round(new Date().getTime() / 1000)
|
|
67
|
-
const server_timestamp = device_timestamp - (ousFeedbackSdkTimestampDelta || 0)
|
|
68
|
-
|
|
69
|
-
// Hashed of server clock
|
|
70
|
-
const x_server_timestamp = await sha256('Ω' + server_timestamp + '994')
|
|
71
|
-
|
|
72
|
-
// Hash the API paths
|
|
73
|
-
if (!url.includes(api_path)) {
|
|
74
|
-
const evenTime = Math.floor(Math.random() * 10) % 2
|
|
75
|
-
const hashAlgorithm = evenTime ? sigma256 : copyright256
|
|
76
|
-
api_path = await hashAlgorithm(api_path, server_timestamp)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
mandatoryHeaders.set('last-modify', `${server_timestamp}`)
|
|
80
|
-
mandatoryHeaders.set('if-non-matched', `${x_server_timestamp}`)
|
|
81
|
-
mandatoryHeaders.set('if-matched', `${api_path}`)
|
|
82
|
-
|
|
83
|
-
try {
|
|
84
|
-
const response = await fetch(url, {
|
|
85
|
-
method: 'POST',
|
|
86
|
-
headers: mandatoryHeaders,
|
|
87
|
-
body: JSON.stringify(_data),
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
if (!response.ok) {
|
|
91
|
-
console.error('Feedback SDK: Network error', response.status)
|
|
92
|
-
_callback(null)
|
|
93
|
-
return null
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const res = await response.json()
|
|
97
|
-
if (!res) {
|
|
98
|
-
console.error('Feedback SDK: Network error - empty response')
|
|
99
|
-
_callback(null)
|
|
100
|
-
return null
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// Sync with server timestamp
|
|
104
|
-
if (res && res.timestamp) {
|
|
105
|
-
const tmp_device_timestamp = Math.round(new Date().getTime() / 1000)
|
|
106
|
-
const tmp_server_timestamp = res.timestamp
|
|
107
|
-
ousFeedbackSdkTimestampDelta = tmp_device_timestamp - tmp_server_timestamp
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// Local timestamp is wrong, sync & call again
|
|
111
|
-
if (res && _shouldRetry) {
|
|
112
|
-
var isTimingError = res['🍩'] || res['🎧'] || res['\ud83c\udf69'] || res['\ud83c\udfa7']
|
|
113
|
-
if (isTimingError) {
|
|
114
|
-
customFetch({
|
|
115
|
-
_shouldRetry: false,
|
|
116
|
-
_url: _url,
|
|
117
|
-
_data: _data,
|
|
118
|
-
_callback: _callback,
|
|
119
|
-
options: options,
|
|
120
|
-
})
|
|
121
|
-
return
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
_callback(res)
|
|
126
|
-
} catch (error) {
|
|
127
|
-
console.error('FeedbackSDK Error', error)
|
|
128
|
-
_callback(null)
|
|
129
|
-
return null
|
|
130
|
-
}
|
|
131
|
-
return
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export {customFetch}
|