@castleio/react-native-castle 1.1.3 → 2.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.
- package/android/build.gradle +2 -2
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/android/gradle.properties +5 -4
- package/android/src/main/java/com/reactnativecastle/CastleModule.kt +12 -47
- package/ios/RCTCastle.m +22 -75
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/index.d.ts +3 -6
- package/package.json +1 -1
- package/react-native-castle.podspec +1 -1
- package/src/index.tsx +3 -6
package/android/build.gradle
CHANGED
|
@@ -9,7 +9,7 @@ buildscript {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
dependencies {
|
|
12
|
-
classpath 'com.android.tools.build:gradle:7.
|
|
12
|
+
classpath 'com.android.tools.build:gradle:7.1.2'
|
|
13
13
|
// noinspection DifferentKotlinGradleVersion
|
|
14
14
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
15
15
|
}
|
|
@@ -125,5 +125,5 @@ dependencies {
|
|
|
125
125
|
// noinspection GradleDynamicVersion
|
|
126
126
|
api 'com.facebook.react:react-native:+'
|
|
127
127
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
128
|
-
api 'io.castle.android:castle:
|
|
128
|
+
api 'io.castle.android:castle:3.0.0'
|
|
129
129
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
distributionBase=GRADLE_USER_HOME
|
|
2
2
|
distributionPath=wrapper/dists
|
|
3
|
-
distributionUrl=https\://services.gradle.org/distributions/gradle-
|
|
3
|
+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
|
|
4
4
|
zipStoreBase=GRADLE_USER_HOME
|
|
5
5
|
zipStorePath=wrapper/dists
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
Castle_kotlinVersion=1.
|
|
2
|
-
Castle_compileSdkVersion=
|
|
3
|
-
Castle_buildToolsVersion=30.0.
|
|
4
|
-
Castle_targetSdkVersion=
|
|
1
|
+
Castle_kotlinVersion=1.6.10
|
|
2
|
+
Castle_compileSdkVersion=31
|
|
3
|
+
Castle_buildToolsVersion=30.0.3
|
|
4
|
+
Castle_targetSdkVersion=31
|
|
5
|
+
android.useAndroidX=true
|
|
@@ -16,11 +16,6 @@ class CastleModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
|
|
16
16
|
promise.resolve(Castle.requestTokenHeaderName)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
@ReactMethod
|
|
20
|
-
fun clientIdHeaderName(promise: Promise) {
|
|
21
|
-
promise.resolve(Castle.clientIdHeaderName)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
19
|
@ReactMethod
|
|
25
20
|
fun configure(options: ReadableMap?, promise: Promise) {
|
|
26
21
|
if (options != null) {
|
|
@@ -36,15 +31,6 @@ class CastleModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
|
|
36
31
|
if (options.hasKey("flushLimit")) {
|
|
37
32
|
builder.flushLimit(options.getInt("flushLimit"))
|
|
38
33
|
}
|
|
39
|
-
if (options.hasKey("useCloudflareApp")) {
|
|
40
|
-
builder.useCloudflareApp(options.getBoolean("useCloudflareApp"))
|
|
41
|
-
}
|
|
42
|
-
if (options.hasKey("apiDomain")) {
|
|
43
|
-
builder.apiDomain(options.getString("apiDomain"))
|
|
44
|
-
}
|
|
45
|
-
if (options.hasKey("apiPath")) {
|
|
46
|
-
builder.apiPath(options.getString("apiPath"))
|
|
47
|
-
}
|
|
48
34
|
if (options.hasKey("baseURLAllowList")) {
|
|
49
35
|
val array = options.getArray("baseURLAllowList")
|
|
50
36
|
array?.let {
|
|
@@ -77,28 +63,23 @@ class CastleModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
|
|
77
63
|
}
|
|
78
64
|
|
|
79
65
|
@ReactMethod
|
|
80
|
-
fun
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
while (itr.hasNextKey()) {
|
|
84
|
-
val key = itr.nextKey()
|
|
85
|
-
if (traits.getType(key) == ReadableType.String) {
|
|
86
|
-
val value = traits.getString(key)
|
|
87
|
-
value?.let { traitsMap.put(key, it) }
|
|
88
|
-
}
|
|
89
|
-
}
|
|
66
|
+
fun userJwt(userJwt: String) {
|
|
67
|
+
Castle.userJwt(userJwt)
|
|
68
|
+
}
|
|
90
69
|
|
|
91
|
-
|
|
70
|
+
@ReactMethod
|
|
71
|
+
fun custom(name: String) {
|
|
72
|
+
Castle.custom(name)
|
|
92
73
|
}
|
|
93
74
|
|
|
94
75
|
@ReactMethod
|
|
95
|
-
fun
|
|
96
|
-
Castle.
|
|
76
|
+
fun customWithProperties(name: String, properties: ReadableMap) {
|
|
77
|
+
Castle.custom(name, properties.toHashMap())
|
|
97
78
|
}
|
|
98
79
|
|
|
99
80
|
@ReactMethod
|
|
100
|
-
fun screen(
|
|
101
|
-
Castle.screen(
|
|
81
|
+
fun screen(name: String) {
|
|
82
|
+
Castle.screen(name)
|
|
102
83
|
}
|
|
103
84
|
|
|
104
85
|
@ReactMethod
|
|
@@ -116,35 +97,19 @@ class CastleModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
|
|
116
97
|
Castle.reset()
|
|
117
98
|
}
|
|
118
99
|
|
|
119
|
-
@ReactMethod
|
|
120
|
-
fun isWhitelistUrl(url: String, promise: Promise) {
|
|
121
|
-
promise.resolve(true)
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
100
|
@ReactMethod
|
|
126
101
|
fun baseUrl(promise: Promise) {
|
|
127
102
|
promise.resolve(Castle.baseUrl())
|
|
128
103
|
}
|
|
129
104
|
|
|
130
|
-
@ReactMethod
|
|
131
|
-
fun clientId(promise: Promise) {
|
|
132
|
-
promise.resolve(Castle.createRequestToken())
|
|
133
|
-
}
|
|
134
|
-
|
|
135
105
|
@ReactMethod
|
|
136
106
|
fun createRequestToken(promise: Promise) {
|
|
137
107
|
promise.resolve(Castle.createRequestToken())
|
|
138
108
|
}
|
|
139
109
|
|
|
140
110
|
@ReactMethod
|
|
141
|
-
fun
|
|
142
|
-
promise.resolve(Castle.
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
@ReactMethod
|
|
146
|
-
fun userSignature(promise: Promise) {
|
|
147
|
-
promise.resolve(Castle.userSignature())
|
|
111
|
+
fun userJwt(promise: Promise) {
|
|
112
|
+
promise.resolve(Castle.userJwt())
|
|
148
113
|
}
|
|
149
114
|
|
|
150
115
|
@ReactMethod
|
package/ios/RCTCastle.m
CHANGED
|
@@ -11,16 +11,6 @@ RCT_EXPORT_MODULE()
|
|
|
11
11
|
return dispatch_get_main_queue();
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
/**
|
|
15
|
-
Get client id header name
|
|
16
|
-
*/
|
|
17
|
-
RCT_EXPORT_METHOD(clientIdHeaderName
|
|
18
|
-
:(RCTPromiseResolveBlock)resolver
|
|
19
|
-
:(RCTPromiseRejectBlock)rejecter)
|
|
20
|
-
{
|
|
21
|
-
resolver(CastleClientIdHeaderName);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
14
|
/**
|
|
25
15
|
Get request token header name
|
|
26
16
|
*/
|
|
@@ -60,18 +50,6 @@ RCT_EXPORT_METHOD(configure:(nonnull NSDictionary *)options
|
|
|
60
50
|
configuration.flushLimit = [options[@"flushLimit"] integerValue];
|
|
61
51
|
}
|
|
62
52
|
|
|
63
|
-
if (options[@"useCloudflareApp"]) {
|
|
64
|
-
configuration.useCloudflareApp = [options[@"useCloudflareApp"] boolValue];
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (options[@"apiDomain"]) {
|
|
68
|
-
configuration.apiDomain = [options[@"apiDomain"] stringValue];
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (options[@"apiPath"]) {
|
|
72
|
-
configuration.apiPath = [options[@"apiPath"] stringValue];
|
|
73
|
-
}
|
|
74
|
-
|
|
75
53
|
if (options[@"baseURLAllowList"]) {
|
|
76
54
|
configuration.baseURLAllowList = options[@"baseURLAllowList"];
|
|
77
55
|
}
|
|
@@ -116,26 +94,34 @@ RCT_EXPORT_METHOD(resetConfiguration
|
|
|
116
94
|
#pragma mark - Tracking
|
|
117
95
|
|
|
118
96
|
/**
|
|
119
|
-
|
|
120
|
-
Provided user traits will be included in the identify event sent to the Castle API.
|
|
97
|
+
Set user jwt, will be persisted. A call to userJwt or reset will clear the stored user identity.
|
|
121
98
|
|
|
122
|
-
@param
|
|
123
|
-
@param traits user traits
|
|
99
|
+
@param userJwt user jwt
|
|
124
100
|
*/
|
|
125
|
-
RCT_EXPORT_METHOD(
|
|
101
|
+
RCT_EXPORT_METHOD(userJwt:(NSString *)userJwt)
|
|
126
102
|
{
|
|
127
|
-
[Castle
|
|
103
|
+
[Castle setUserJwt:userJwt];
|
|
128
104
|
}
|
|
129
105
|
|
|
130
106
|
/**
|
|
131
|
-
|
|
132
|
-
A stored user signature will be removed when the user signature or reset methods are called.
|
|
107
|
+
Track custom event with a specified name
|
|
133
108
|
|
|
134
|
-
@param
|
|
109
|
+
@param name Event name
|
|
135
110
|
*/
|
|
136
|
-
RCT_EXPORT_METHOD(
|
|
111
|
+
RCT_EXPORT_METHOD(custom:(NSString *)name)
|
|
137
112
|
{
|
|
138
|
-
[Castle
|
|
113
|
+
[Castle customWithName:name];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
Track custom event with a specified name and properties
|
|
118
|
+
|
|
119
|
+
@param name Event name
|
|
120
|
+
@param properties Properties
|
|
121
|
+
*/
|
|
122
|
+
RCT_EXPORT_METHOD(customWithProperties:(NSString *)name properties:(NSDictionary *)properties)
|
|
123
|
+
{
|
|
124
|
+
[Castle customWithName:name properties:properties];
|
|
139
125
|
}
|
|
140
126
|
|
|
141
127
|
/**
|
|
@@ -145,7 +131,7 @@ RCT_EXPORT_METHOD(secure:(NSString *)signature)
|
|
|
145
131
|
*/
|
|
146
132
|
RCT_EXPORT_METHOD(screen:(NSString *)screenName)
|
|
147
133
|
{
|
|
148
|
-
[Castle
|
|
134
|
+
[Castle screenWithName:screenName];
|
|
149
135
|
}
|
|
150
136
|
|
|
151
137
|
/**
|
|
@@ -189,19 +175,6 @@ RCT_EXPORT_METHOD(baseUrl
|
|
|
189
175
|
|
|
190
176
|
#pragma mark - Metadata
|
|
191
177
|
|
|
192
|
-
/**
|
|
193
|
-
Get client id
|
|
194
|
-
|
|
195
|
-
@return request token
|
|
196
|
-
*/
|
|
197
|
-
RCT_EXPORT_METHOD(clientId
|
|
198
|
-
:(RCTPromiseResolveBlock)resolver
|
|
199
|
-
:(RCTPromiseRejectBlock)rejecter)
|
|
200
|
-
{
|
|
201
|
-
NSString *clientId = [Castle createRequestToken];
|
|
202
|
-
return resolver(clientId);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
178
|
/**
|
|
206
179
|
Create request token
|
|
207
180
|
|
|
@@ -211,34 +184,8 @@ RCT_EXPORT_METHOD(createRequestToken
|
|
|
211
184
|
:(RCTPromiseResolveBlock)resolver
|
|
212
185
|
:(RCTPromiseRejectBlock)rejecter)
|
|
213
186
|
{
|
|
214
|
-
NSString *
|
|
215
|
-
return resolver(
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
Get stored user id from last identify call, returns nil if not set
|
|
220
|
-
|
|
221
|
-
@return User Id
|
|
222
|
-
*/
|
|
223
|
-
RCT_EXPORT_METHOD(userId
|
|
224
|
-
:(RCTPromiseResolveBlock)resolver
|
|
225
|
-
:(RCTPromiseRejectBlock)rejecter)
|
|
226
|
-
{
|
|
227
|
-
NSString *userId = [Castle userId];
|
|
228
|
-
return resolver(userId);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
Get stored signature from secure call, returns nil if not set
|
|
233
|
-
|
|
234
|
-
@return Signature
|
|
235
|
-
*/
|
|
236
|
-
RCT_EXPORT_METHOD(userSignature
|
|
237
|
-
:(RCTPromiseResolveBlock)resolver
|
|
238
|
-
:(RCTPromiseRejectBlock)rejecter)
|
|
239
|
-
{
|
|
240
|
-
NSString *userSignature = [Castle userSignature];
|
|
241
|
-
return resolver(userSignature);
|
|
187
|
+
NSString *token = [Castle createRequestToken];
|
|
188
|
+
return resolver(token);
|
|
242
189
|
}
|
|
243
190
|
|
|
244
191
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":["Castle","NativeModules","Error"],"mappings":";;;;;;;AAAA;;
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":["Castle","NativeModules","Error"],"mappings":";;;;;;;AAAA;;AAqCO,MAAM;AAAEA,EAAAA;AAAF,IAAaC,0BAAnB;;;AAEP,IAAI,CAACD,MAAL,EAAa;AACX,QAAM,IAAIE,KAAJ,CAAU,sCAAV,CAAN;AACD;;eAEcF,M","sourcesContent":["import { NativeModules } from 'react-native';\n\nexport interface Configuration {\n publishableKey: string;\n debugLoggingEnabled?: boolean;\n maxQueueLimit?: number;\n flushLimit?: number;\n useCloudflareApp?: boolean;\n apiDomain?: string;\n apiPath?: string;\n baseURLAllowList?: string[];\n}\n\nexport type JsonValue = boolean | number | string | null | JsonList | JsonMap;\nexport interface JsonMap {\n [key: string]: JsonValue;\n [index: number]: JsonValue;\n}\nexport interface JsonList extends Array<JsonValue> {}\n\ntype CastleType = {\n configure(configuration: Configuration): Promise<void>;\n configureWithPublishableKey(publishableKey: string): Promise<void>;\n userJwt(userJwt: string): Promise<void>;\n screen(name: string): Promise<void>;\n custom(name: string): Promise<void>;\n customWithProperties(name: string, properties: JsonMap): Promise<void>;\n flush(): Promise<void>;\n flushIfNeeded(url: string): Promise<boolean>;\n reset(): Promise<void>;\n baseUrl(): Promise<string>;\n createRequestToken(): Promise<string>;\n requestTokenHeaderName(): Promise<string>;\n userAgent(): Promise<string>;\n queueSize(): Promise<number>;\n};\n\nexport const { Castle } = NativeModules;\n\nif (!Castle) {\n throw new Error('Failed to load Castle native module.');\n}\n\nexport default Castle as CastleType;\n"]}
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":["NativeModules","Castle","Error"],"mappings":"AAAA,SAASA,aAAT,QAA8B,cAA9B;
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":["NativeModules","Castle","Error"],"mappings":"AAAA,SAASA,aAAT,QAA8B,cAA9B;AAqCA,OAAO,MAAM;AAAEC,EAAAA;AAAF,IAAaD,aAAnB;;AAEP,IAAI,CAACC,MAAL,EAAa;AACX,QAAM,IAAIC,KAAJ,CAAU,sCAAV,CAAN;AACD;;AAED,eAAeD,MAAf","sourcesContent":["import { NativeModules } from 'react-native';\n\nexport interface Configuration {\n publishableKey: string;\n debugLoggingEnabled?: boolean;\n maxQueueLimit?: number;\n flushLimit?: number;\n useCloudflareApp?: boolean;\n apiDomain?: string;\n apiPath?: string;\n baseURLAllowList?: string[];\n}\n\nexport type JsonValue = boolean | number | string | null | JsonList | JsonMap;\nexport interface JsonMap {\n [key: string]: JsonValue;\n [index: number]: JsonValue;\n}\nexport interface JsonList extends Array<JsonValue> {}\n\ntype CastleType = {\n configure(configuration: Configuration): Promise<void>;\n configureWithPublishableKey(publishableKey: string): Promise<void>;\n userJwt(userJwt: string): Promise<void>;\n screen(name: string): Promise<void>;\n custom(name: string): Promise<void>;\n customWithProperties(name: string, properties: JsonMap): Promise<void>;\n flush(): Promise<void>;\n flushIfNeeded(url: string): Promise<boolean>;\n reset(): Promise<void>;\n baseUrl(): Promise<string>;\n createRequestToken(): Promise<string>;\n requestTokenHeaderName(): Promise<string>;\n userAgent(): Promise<string>;\n queueSize(): Promise<number>;\n};\n\nexport const { Castle } = NativeModules;\n\nif (!Castle) {\n throw new Error('Failed to load Castle native module.');\n}\n\nexport default Castle as CastleType;\n"]}
|
|
@@ -18,19 +18,16 @@ export interface JsonList extends Array<JsonValue> {
|
|
|
18
18
|
declare type CastleType = {
|
|
19
19
|
configure(configuration: Configuration): Promise<void>;
|
|
20
20
|
configureWithPublishableKey(publishableKey: string): Promise<void>;
|
|
21
|
-
|
|
22
|
-
secure(identifier: string): Promise<string>;
|
|
21
|
+
userJwt(userJwt: string): Promise<void>;
|
|
23
22
|
screen(name: string): Promise<void>;
|
|
23
|
+
custom(name: string): Promise<void>;
|
|
24
|
+
customWithProperties(name: string, properties: JsonMap): Promise<void>;
|
|
24
25
|
flush(): Promise<void>;
|
|
25
26
|
flushIfNeeded(url: string): Promise<boolean>;
|
|
26
27
|
reset(): Promise<void>;
|
|
27
28
|
baseUrl(): Promise<string>;
|
|
28
|
-
clientId(): Promise<string>;
|
|
29
|
-
clientIdHeaderName(): Promise<string>;
|
|
30
29
|
createRequestToken(): Promise<string>;
|
|
31
30
|
requestTokenHeaderName(): Promise<string>;
|
|
32
|
-
userId(): Promise<string>;
|
|
33
|
-
userSignature(): Promise<string>;
|
|
34
31
|
userAgent(): Promise<string>;
|
|
35
32
|
queueSize(): Promise<number>;
|
|
36
33
|
};
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -21,19 +21,16 @@ export interface JsonList extends Array<JsonValue> {}
|
|
|
21
21
|
type CastleType = {
|
|
22
22
|
configure(configuration: Configuration): Promise<void>;
|
|
23
23
|
configureWithPublishableKey(publishableKey: string): Promise<void>;
|
|
24
|
-
|
|
25
|
-
secure(identifier: string): Promise<string>;
|
|
24
|
+
userJwt(userJwt: string): Promise<void>;
|
|
26
25
|
screen(name: string): Promise<void>;
|
|
26
|
+
custom(name: string): Promise<void>;
|
|
27
|
+
customWithProperties(name: string, properties: JsonMap): Promise<void>;
|
|
27
28
|
flush(): Promise<void>;
|
|
28
29
|
flushIfNeeded(url: string): Promise<boolean>;
|
|
29
30
|
reset(): Promise<void>;
|
|
30
31
|
baseUrl(): Promise<string>;
|
|
31
|
-
clientId(): Promise<string>;
|
|
32
|
-
clientIdHeaderName(): Promise<string>;
|
|
33
32
|
createRequestToken(): Promise<string>;
|
|
34
33
|
requestTokenHeaderName(): Promise<string>;
|
|
35
|
-
userId(): Promise<string>;
|
|
36
|
-
userSignature(): Promise<string>;
|
|
37
34
|
userAgent(): Promise<string>;
|
|
38
35
|
queueSize(): Promise<number>;
|
|
39
36
|
};
|