@@ -18,7 +18,7 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions) {
18
18
19
19
private var loginCompletableFuture: CompletableFuture <Web3AuthResponse > = CompletableFuture ()
20
20
21
- private var web3AuthResponse = Web3AuthResponse ()
21
+ private var web3AuthResponse: Web3AuthResponse ? = null
22
22
private var web3AuthOption = web3AuthOptions
23
23
private var sessionManager: SessionManager = SessionManager (web3AuthOption.context)
24
24
@@ -108,22 +108,22 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions) {
108
108
decodeBase64URLString(hash).toString(Charsets .UTF_8 ), Web3AuthResponse ::class .java
109
109
)
110
110
111
- if (web3AuthResponse.error?.isNotBlank() == true ) {
111
+ if (web3AuthResponse? .error?.isNotBlank() == true ) {
112
112
loginCompletableFuture.completeExceptionally(
113
113
UnKnownException (
114
- web3AuthResponse.error ? : Web3AuthError .getError(ErrorCode .SOMETHING_WENT_WRONG )
114
+ web3AuthResponse? .error ? : Web3AuthError .getError(ErrorCode .SOMETHING_WENT_WRONG )
115
115
)
116
116
)
117
- } else if (web3AuthResponse.privKey.isNullOrBlank()) {
117
+ } else if (web3AuthResponse? .privKey.isNullOrBlank()) {
118
118
loginCompletableFuture.completeExceptionally(Exception (Web3AuthError .getError(ErrorCode .SOMETHING_WENT_WRONG )))
119
119
} else {
120
- web3AuthResponse.sessionId?.let { sessionManager.saveSessionId(it) }
120
+ web3AuthResponse? .sessionId?.let { sessionManager.saveSessionId(it) }
121
121
122
- if (web3AuthResponse.userInfo?.dappShare?.isNotEmpty() == true ) {
122
+ if (web3AuthResponse? .userInfo?.dappShare?.isNotEmpty() == true ) {
123
123
KeyStoreManagerUtils .encryptData(
124
- web3AuthResponse.userInfo?.verifier.plus(" | " )
125
- .plus(web3AuthResponse.userInfo?.verifierId),
126
- web3AuthResponse.userInfo?.dappShare!! ,
124
+ web3AuthResponse? .userInfo?.verifier.plus(" | " )
125
+ .plus(web3AuthResponse? .userInfo?.verifierId),
126
+ web3AuthResponse? .userInfo?.dappShare!! ,
127
127
)
128
128
}
129
129
loginCompletableFuture.complete(web3AuthResponse)
@@ -177,15 +177,15 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions) {
177
177
val tempJson = JSONObject (response)
178
178
web3AuthResponse =
179
179
gson.fromJson(tempJson.toString(), Web3AuthResponse ::class .java)
180
- if (web3AuthResponse.error?.isNotBlank() == true ) {
180
+ if (web3AuthResponse? .error?.isNotBlank() == true ) {
181
181
sessionCompletableFuture.completeExceptionally(
182
182
UnKnownException (
183
- web3AuthResponse.error ? : Web3AuthError .getError(
183
+ web3AuthResponse? .error ? : Web3AuthError .getError(
184
184
ErrorCode .SOMETHING_WENT_WRONG
185
185
)
186
186
)
187
187
)
188
- } else if (web3AuthResponse.privKey.isNullOrBlank()) {
188
+ } else if (web3AuthResponse? .privKey.isNullOrBlank()) {
189
189
sessionCompletableFuture.completeExceptionally(
190
190
Exception (
191
191
Web3AuthError .getError(ErrorCode .SOMETHING_WENT_WRONG )
@@ -207,37 +207,37 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions) {
207
207
return sessionCompletableFuture
208
208
}
209
209
210
- fun getPrivkey (): String? {
210
+ fun getPrivkey (): String {
211
211
val privKey: String? = if (web3AuthResponse == null ) {
212
- throw Error ( Web3AuthError .getError( ErrorCode . NOUSERFOUND ))
212
+ " "
213
213
} else {
214
214
if (web3AuthOption.useCoreKitKey == true ) {
215
- web3AuthResponse.coreKitKey
215
+ web3AuthResponse? .coreKitKey
216
216
} else {
217
- web3AuthResponse.privKey
217
+ web3AuthResponse? .privKey
218
218
}
219
219
}
220
- return privKey
220
+ return privKey ? : " "
221
221
}
222
222
223
- fun getEd25519PrivKey (): String? {
223
+ fun getEd25519PrivKey (): String {
224
224
val ed25519Key: String? = if (web3AuthResponse == null ) {
225
- throw Error ( Web3AuthError .getError( ErrorCode . NOUSERFOUND ))
225
+ " "
226
226
} else {
227
227
if (web3AuthOption.useCoreKitKey == true ) {
228
- web3AuthResponse.coreKitEd25519PrivKey
228
+ web3AuthResponse? .coreKitEd25519PrivKey
229
229
} else {
230
- web3AuthResponse.ed25519PrivKey
230
+ web3AuthResponse? .ed25519PrivKey
231
231
}
232
232
}
233
- return ed25519Key
233
+ return ed25519Key ? : " "
234
234
}
235
235
236
236
fun getUserInfo (): UserInfo ? {
237
237
return if (web3AuthResponse == null ) {
238
238
throw Error (Web3AuthError .getError(ErrorCode .NOUSERFOUND ))
239
239
} else {
240
- web3AuthResponse.userInfo
240
+ web3AuthResponse? .userInfo
241
241
}
242
242
}
243
243
}
0 commit comments