@procivis/react-native-one-core 1.26999.0 → 1.33398.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 +66 -17
- package/android/build.gradle +19 -7
- package/android/src/main/java/ch/procivis/one/core/Deserialize.kt +5 -1
- package/android/src/main/java/ch/procivis/one/core/DeserializeSpecific.kt +10 -3
- package/android/src/main/java/ch/procivis/one/core/ProcivisOneCoreModule.kt +158 -73
- package/android/src/main/java/ch/procivis/one/core/SerializeSpecific.kt +7 -1
- package/android/src/main/java/ch/procivis/one/core/Util.kt +42 -10
- package/core-sdk.json +6 -6
- package/dist/index.d.ts +3 -8
- package/dist/index.js +22 -22
- package/dist/src/cache.d.ts +12 -0
- package/dist/src/cache.js +14 -0
- package/dist/src/config.d.ts +29 -4
- package/dist/src/config.js +19 -0
- package/dist/src/core.d.ts +18 -6
- package/dist/src/core.js +1 -0
- package/dist/src/credential.d.ts +14 -1
- package/dist/src/credential.js +5 -0
- package/dist/src/did.d.ts +9 -5
- package/dist/src/error.d.ts +10 -17
- package/dist/src/error.js +5 -14
- package/dist/src/history.d.ts +0 -1
- package/dist/src/history.js +0 -1
- package/dist/src/key.d.ts +3 -0
- package/dist/src/proof.d.ts +13 -1
- package/dist/src/proof.js +5 -0
- package/dist/src/proofSchema.d.ts +2 -0
- package/dist/src/trust.d.ts +85 -19
- package/dist/src/trust.js +28 -7
- package/ios/Deserialize.swift +162 -21
- package/ios/ProcivisOneCoreModule.m +46 -4
- package/ios/ProcivisOneCoreModule.swift +179 -82
- package/ios/Serialize.swift +72 -15
- package/ios/Util.swift +20 -24
- package/package.json +2 -2
|
@@ -1,66 +1,63 @@
|
|
|
1
1
|
package ch.procivis.one.core
|
|
2
2
|
|
|
3
3
|
import ch.procivis.one.core.Deserialize.construct
|
|
4
|
+
import ch.procivis.one.core.DeserializeSpecific.enumList
|
|
4
5
|
import ch.procivis.one.core.Serialize.convertToRN
|
|
5
6
|
import ch.procivis.one.core.Util.asyncCall
|
|
7
|
+
import ch.procivis.one.core.Util.syncCall
|
|
6
8
|
import com.facebook.react.bridge.Promise
|
|
7
9
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
8
10
|
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
9
11
|
import com.facebook.react.bridge.ReactMethod
|
|
10
12
|
import com.facebook.react.bridge.ReadableArray
|
|
11
13
|
import com.facebook.react.bridge.ReadableMap
|
|
14
|
+
import kotlinx.coroutines.CoroutineScope
|
|
15
|
+
import kotlin.coroutines.EmptyCoroutineContext
|
|
12
16
|
|
|
13
17
|
class ProcivisOneCoreModule(reactContext: ReactApplicationContext) :
|
|
14
18
|
ReactContextBaseJavaModule(reactContext) {
|
|
15
19
|
override fun getName() = "ProcivisOneCoreModule"
|
|
16
20
|
|
|
17
21
|
private var oneCore: OneCoreBindingInterface? = null
|
|
22
|
+
private val scope = CoroutineScope(EmptyCoroutineContext)
|
|
18
23
|
|
|
19
24
|
private fun getCore(): OneCoreBindingInterface {
|
|
20
|
-
return oneCore ?: throw BindingException.
|
|
25
|
+
return oneCore ?: throw BindingException.ErrorResponse(
|
|
26
|
+
ErrorResponseBindingDto(
|
|
27
|
+
"BR_0184",
|
|
28
|
+
"core not initialized",
|
|
29
|
+
null
|
|
30
|
+
)
|
|
31
|
+
)
|
|
21
32
|
}
|
|
22
33
|
|
|
23
34
|
@ReactMethod
|
|
24
|
-
fun
|
|
25
|
-
|
|
35
|
+
fun initialize(configJson: String, promise: Promise) {
|
|
36
|
+
syncCall(promise) {
|
|
26
37
|
val dataDirPath = this.reactApplicationContext.filesDir.absolutePath
|
|
27
38
|
oneCore =
|
|
28
|
-
|
|
39
|
+
initializeCore(
|
|
40
|
+
configJson,
|
|
29
41
|
dataDirPath,
|
|
30
42
|
AndroidKeyStoreKeyStorage(this.reactApplicationContext),
|
|
31
43
|
AndroidBLECentral(this.reactApplicationContext),
|
|
32
44
|
AndroidBLEPeripheral(this.reactApplicationContext)
|
|
33
45
|
)
|
|
34
|
-
return@
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
@ReactMethod
|
|
39
|
-
fun initializeVerifier(promise: Promise) {
|
|
40
|
-
asyncCall(promise) {
|
|
41
|
-
val dataDirPath = this.reactApplicationContext.filesDir.absolutePath
|
|
42
|
-
oneCore =
|
|
43
|
-
initializeVerifierCore(
|
|
44
|
-
dataDirPath,
|
|
45
|
-
AndroidKeyStoreKeyStorage(this.reactApplicationContext),
|
|
46
|
-
AndroidBLECentral(this.reactApplicationContext),
|
|
47
|
-
AndroidBLEPeripheral(this.reactApplicationContext)
|
|
48
|
-
)
|
|
49
|
-
return@asyncCall null
|
|
46
|
+
return@syncCall null
|
|
50
47
|
}
|
|
51
48
|
}
|
|
52
49
|
|
|
53
50
|
@ReactMethod
|
|
54
51
|
fun getVersion(promise: Promise) {
|
|
55
|
-
|
|
52
|
+
syncCall(promise) {
|
|
56
53
|
val version = getCore().version()
|
|
57
|
-
return@
|
|
54
|
+
return@syncCall convertToRN(version)
|
|
58
55
|
}
|
|
59
56
|
}
|
|
60
57
|
|
|
61
58
|
@ReactMethod
|
|
62
59
|
fun getConfig(promise: Promise) {
|
|
63
|
-
asyncCall(promise) {
|
|
60
|
+
asyncCall(promise, scope) {
|
|
64
61
|
val config = getCore().getConfig()
|
|
65
62
|
return@asyncCall convertToRN(config)
|
|
66
63
|
}
|
|
@@ -68,22 +65,30 @@ class ProcivisOneCoreModule(reactContext: ReactApplicationContext) :
|
|
|
68
65
|
|
|
69
66
|
@ReactMethod
|
|
70
67
|
fun runTask(task: String, promise: Promise) {
|
|
71
|
-
asyncCall(promise) {
|
|
68
|
+
asyncCall(promise, scope) {
|
|
72
69
|
return@asyncCall getCore().runTask(task)
|
|
73
70
|
}
|
|
74
71
|
}
|
|
75
72
|
|
|
76
73
|
@ReactMethod
|
|
77
74
|
fun deleteProofClaims(proofId: String, promise: Promise) {
|
|
78
|
-
asyncCall(promise) {
|
|
75
|
+
asyncCall(promise, scope) {
|
|
79
76
|
getCore().deleteProofClaims(proofId)
|
|
80
77
|
return@asyncCall null
|
|
81
78
|
}
|
|
82
79
|
}
|
|
83
80
|
|
|
81
|
+
@ReactMethod
|
|
82
|
+
fun checkCertificate(keyId: String, certificate: ReadableMap, promise: Promise) {
|
|
83
|
+
asyncCall(promise, scope) {
|
|
84
|
+
getCore().checkCertificate(keyId, construct(certificate))
|
|
85
|
+
return@asyncCall null
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
84
89
|
@ReactMethod
|
|
85
90
|
fun shareCredentialSchema(credentialSchemaId: String, promise: Promise) {
|
|
86
|
-
asyncCall(promise) {
|
|
91
|
+
asyncCall(promise, scope) {
|
|
87
92
|
val result = getCore().shareCredentialSchema(credentialSchemaId)
|
|
88
93
|
return@asyncCall convertToRN(result)
|
|
89
94
|
}
|
|
@@ -91,7 +96,7 @@ class ProcivisOneCoreModule(reactContext: ReactApplicationContext) :
|
|
|
91
96
|
|
|
92
97
|
@ReactMethod
|
|
93
98
|
fun shareProofSchema(proofSchemaId: String, promise: Promise) {
|
|
94
|
-
asyncCall(promise) {
|
|
99
|
+
asyncCall(promise, scope) {
|
|
95
100
|
val result = getCore().shareProofSchema(proofSchemaId)
|
|
96
101
|
return@asyncCall convertToRN(result)
|
|
97
102
|
}
|
|
@@ -99,28 +104,28 @@ class ProcivisOneCoreModule(reactContext: ReactApplicationContext) :
|
|
|
99
104
|
|
|
100
105
|
@ReactMethod
|
|
101
106
|
fun createOrganisation(uuid: String?, promise: Promise) {
|
|
102
|
-
asyncCall(promise) {
|
|
107
|
+
asyncCall(promise, scope) {
|
|
103
108
|
return@asyncCall getCore().createOrganisation(uuid)
|
|
104
109
|
}
|
|
105
110
|
}
|
|
106
111
|
|
|
107
112
|
@ReactMethod
|
|
108
113
|
fun generateKey(keyRequest: ReadableMap, promise: Promise) {
|
|
109
|
-
asyncCall(promise) {
|
|
114
|
+
asyncCall(promise, scope) {
|
|
110
115
|
return@asyncCall getCore().generateKey(construct(keyRequest))
|
|
111
116
|
}
|
|
112
117
|
}
|
|
113
118
|
|
|
114
119
|
@ReactMethod
|
|
115
120
|
fun createDid(didRequest: ReadableMap, promise: Promise) {
|
|
116
|
-
asyncCall(promise) {
|
|
121
|
+
asyncCall(promise, scope) {
|
|
117
122
|
return@asyncCall getCore().createDid(construct(didRequest))
|
|
118
123
|
}
|
|
119
124
|
}
|
|
120
125
|
|
|
121
126
|
@ReactMethod
|
|
122
127
|
fun getDids(query: ReadableMap, promise: Promise) {
|
|
123
|
-
asyncCall(promise) {
|
|
128
|
+
asyncCall(promise, scope) {
|
|
124
129
|
val dids = getCore().getDids(construct(query))
|
|
125
130
|
return@asyncCall convertToRN(dids)
|
|
126
131
|
}
|
|
@@ -133,7 +138,7 @@ class ProcivisOneCoreModule(reactContext: ReactApplicationContext) :
|
|
|
133
138
|
transport: ReadableArray?,
|
|
134
139
|
promise: Promise
|
|
135
140
|
) {
|
|
136
|
-
asyncCall(promise) {
|
|
141
|
+
asyncCall(promise, scope) {
|
|
137
142
|
val transportList = transport?.let { DeserializeSpecific.ids(it) }
|
|
138
143
|
val invitationResult = getCore().handleInvitation(url, organisationId, transportList)
|
|
139
144
|
return@asyncCall convertToRN(invitationResult)
|
|
@@ -145,17 +150,18 @@ class ProcivisOneCoreModule(reactContext: ReactApplicationContext) :
|
|
|
145
150
|
interactionId: String,
|
|
146
151
|
didId: String,
|
|
147
152
|
keyId: String?,
|
|
153
|
+
txCode: String?,
|
|
148
154
|
promise: Promise
|
|
149
155
|
) {
|
|
150
|
-
asyncCall(promise) {
|
|
151
|
-
getCore().holderAcceptCredential(interactionId, didId, keyId)
|
|
156
|
+
asyncCall(promise, scope) {
|
|
157
|
+
getCore().holderAcceptCredential(interactionId, didId, keyId, txCode)
|
|
152
158
|
return@asyncCall null
|
|
153
159
|
}
|
|
154
160
|
}
|
|
155
161
|
|
|
156
162
|
@ReactMethod
|
|
157
163
|
fun holderRejectCredential(interactionId: String, promise: Promise) {
|
|
158
|
-
asyncCall(promise) {
|
|
164
|
+
asyncCall(promise, scope) {
|
|
159
165
|
getCore().holderRejectCredential(interactionId)
|
|
160
166
|
return@asyncCall null
|
|
161
167
|
}
|
|
@@ -163,7 +169,7 @@ class ProcivisOneCoreModule(reactContext: ReactApplicationContext) :
|
|
|
163
169
|
|
|
164
170
|
@ReactMethod
|
|
165
171
|
fun getPresentationDefinition(proofId: String, promise: Promise) {
|
|
166
|
-
asyncCall(promise) {
|
|
172
|
+
asyncCall(promise, scope) {
|
|
167
173
|
val presentationDefinition = getCore().getPresentationDefinition(proofId)
|
|
168
174
|
return@asyncCall convertToRN(presentationDefinition)
|
|
169
175
|
}
|
|
@@ -171,7 +177,7 @@ class ProcivisOneCoreModule(reactContext: ReactApplicationContext) :
|
|
|
171
177
|
|
|
172
178
|
@ReactMethod
|
|
173
179
|
fun holderRejectProof(interactionId: String, promise: Promise) {
|
|
174
|
-
asyncCall(promise) {
|
|
180
|
+
asyncCall(promise, scope) {
|
|
175
181
|
getCore().holderRejectProof(interactionId)
|
|
176
182
|
return@asyncCall null
|
|
177
183
|
}
|
|
@@ -185,7 +191,7 @@ class ProcivisOneCoreModule(reactContext: ReactApplicationContext) :
|
|
|
185
191
|
keyId: String?,
|
|
186
192
|
promise: Promise
|
|
187
193
|
) {
|
|
188
|
-
asyncCall(promise) {
|
|
194
|
+
asyncCall(promise, scope) {
|
|
189
195
|
val submitCredentials =
|
|
190
196
|
mutableMapOf<String, PresentationSubmitCredentialRequestBindingDto>()
|
|
191
197
|
for (entry in credentials.entryIterator) {
|
|
@@ -199,7 +205,7 @@ class ProcivisOneCoreModule(reactContext: ReactApplicationContext) :
|
|
|
199
205
|
|
|
200
206
|
@ReactMethod
|
|
201
207
|
fun getCredentials(query: ReadableMap, promise: Promise) {
|
|
202
|
-
asyncCall(promise) {
|
|
208
|
+
asyncCall(promise, scope) {
|
|
203
209
|
val credentials = getCore().getCredentials(construct(query))
|
|
204
210
|
return@asyncCall convertToRN(credentials)
|
|
205
211
|
}
|
|
@@ -207,7 +213,7 @@ class ProcivisOneCoreModule(reactContext: ReactApplicationContext) :
|
|
|
207
213
|
|
|
208
214
|
@ReactMethod
|
|
209
215
|
fun getCredential(credentialId: String, promise: Promise) {
|
|
210
|
-
asyncCall(promise) {
|
|
216
|
+
asyncCall(promise, scope) {
|
|
211
217
|
val credential = getCore().getCredential(credentialId)
|
|
212
218
|
return@asyncCall convertToRN(credential)
|
|
213
219
|
}
|
|
@@ -215,7 +221,7 @@ class ProcivisOneCoreModule(reactContext: ReactApplicationContext) :
|
|
|
215
221
|
|
|
216
222
|
@ReactMethod
|
|
217
223
|
fun deleteCredential(credentialId: String, promise: Promise) {
|
|
218
|
-
asyncCall(promise) {
|
|
224
|
+
asyncCall(promise, scope) {
|
|
219
225
|
getCore().deleteCredential(credentialId)
|
|
220
226
|
return@asyncCall null
|
|
221
227
|
}
|
|
@@ -223,14 +229,14 @@ class ProcivisOneCoreModule(reactContext: ReactApplicationContext) :
|
|
|
223
229
|
|
|
224
230
|
@ReactMethod
|
|
225
231
|
fun importCredentialSchema(request: ReadableMap, promise: Promise) {
|
|
226
|
-
asyncCall(promise) {
|
|
232
|
+
asyncCall(promise, scope) {
|
|
227
233
|
return@asyncCall getCore().importCredentialSchema(construct(request))
|
|
228
234
|
}
|
|
229
235
|
}
|
|
230
236
|
|
|
231
237
|
@ReactMethod
|
|
232
238
|
fun getCredentialSchema(credentialSchemaId: String, promise: Promise) {
|
|
233
|
-
asyncCall(promise) {
|
|
239
|
+
asyncCall(promise, scope) {
|
|
234
240
|
val schema = getCore().getCredentialSchema(credentialSchemaId)
|
|
235
241
|
return@asyncCall convertToRN(schema)
|
|
236
242
|
}
|
|
@@ -238,7 +244,7 @@ class ProcivisOneCoreModule(reactContext: ReactApplicationContext) :
|
|
|
238
244
|
|
|
239
245
|
@ReactMethod
|
|
240
246
|
fun getCredentialSchemas(query: ReadableMap, promise: Promise) {
|
|
241
|
-
asyncCall(promise) {
|
|
247
|
+
asyncCall(promise, scope) {
|
|
242
248
|
val schemas = getCore().getCredentialSchemas(construct(query))
|
|
243
249
|
return@asyncCall convertToRN(schemas)
|
|
244
250
|
}
|
|
@@ -246,7 +252,7 @@ class ProcivisOneCoreModule(reactContext: ReactApplicationContext) :
|
|
|
246
252
|
|
|
247
253
|
@ReactMethod
|
|
248
254
|
fun deleteCredentialSchema(credentialSchemaId: String, promise: Promise) {
|
|
249
|
-
asyncCall(promise) {
|
|
255
|
+
asyncCall(promise, scope) {
|
|
250
256
|
getCore().deleteCredentialSchema(credentialSchemaId)
|
|
251
257
|
return@asyncCall null
|
|
252
258
|
}
|
|
@@ -254,22 +260,22 @@ class ProcivisOneCoreModule(reactContext: ReactApplicationContext) :
|
|
|
254
260
|
|
|
255
261
|
@ReactMethod
|
|
256
262
|
fun createProof(request: ReadableMap, promise: Promise) {
|
|
257
|
-
asyncCall(promise) {
|
|
263
|
+
asyncCall(promise, scope) {
|
|
258
264
|
return@asyncCall getCore().createProof(construct(request))
|
|
259
265
|
}
|
|
260
266
|
}
|
|
261
267
|
|
|
262
268
|
@ReactMethod
|
|
263
|
-
fun shareProof(proofId: String, promise: Promise) {
|
|
264
|
-
asyncCall(promise) {
|
|
265
|
-
val shareProof = getCore().shareProof(proofId)
|
|
269
|
+
fun shareProof(proofId: String, request: ReadableMap, promise: Promise) {
|
|
270
|
+
asyncCall(promise, scope) {
|
|
271
|
+
val shareProof = getCore().shareProof(proofId, construct(request))
|
|
266
272
|
return@asyncCall convertToRN(shareProof)
|
|
267
273
|
}
|
|
268
274
|
}
|
|
269
275
|
|
|
270
276
|
@ReactMethod
|
|
271
277
|
fun getProof(proofId: String, promise: Promise) {
|
|
272
|
-
asyncCall(promise) {
|
|
278
|
+
asyncCall(promise, scope) {
|
|
273
279
|
val proof = getCore().getProof(proofId)
|
|
274
280
|
return@asyncCall convertToRN(proof)
|
|
275
281
|
}
|
|
@@ -277,7 +283,7 @@ class ProcivisOneCoreModule(reactContext: ReactApplicationContext) :
|
|
|
277
283
|
|
|
278
284
|
@ReactMethod
|
|
279
285
|
fun getProofs(query: ReadableMap, promise: Promise) {
|
|
280
|
-
asyncCall(promise) {
|
|
286
|
+
asyncCall(promise, scope) {
|
|
281
287
|
val proofs = getCore().getProofs(construct(query))
|
|
282
288
|
return@asyncCall convertToRN(proofs)
|
|
283
289
|
}
|
|
@@ -285,14 +291,14 @@ class ProcivisOneCoreModule(reactContext: ReactApplicationContext) :
|
|
|
285
291
|
|
|
286
292
|
@ReactMethod
|
|
287
293
|
fun retractProof(proofId: String, promise: Promise) {
|
|
288
|
-
asyncCall(promise) {
|
|
294
|
+
asyncCall(promise, scope) {
|
|
289
295
|
return@asyncCall getCore().retractProof(proofId)
|
|
290
296
|
}
|
|
291
297
|
}
|
|
292
298
|
|
|
293
299
|
@ReactMethod
|
|
294
300
|
fun proposeProof(exchange: String, organisationId: String, promise: Promise) {
|
|
295
|
-
asyncCall(promise) {
|
|
301
|
+
asyncCall(promise, scope) {
|
|
296
302
|
val result = getCore().proposeProof(exchange, organisationId)
|
|
297
303
|
return@asyncCall convertToRN(result)
|
|
298
304
|
}
|
|
@@ -300,14 +306,14 @@ class ProcivisOneCoreModule(reactContext: ReactApplicationContext) :
|
|
|
300
306
|
|
|
301
307
|
@ReactMethod
|
|
302
308
|
fun createProofSchema(request: ReadableMap, promise: Promise) {
|
|
303
|
-
asyncCall(promise) {
|
|
309
|
+
asyncCall(promise, scope) {
|
|
304
310
|
return@asyncCall getCore().createProofSchema(construct(request))
|
|
305
311
|
}
|
|
306
312
|
}
|
|
307
313
|
|
|
308
314
|
@ReactMethod
|
|
309
315
|
fun getProofSchemas(query: ReadableMap, promise: Promise) {
|
|
310
|
-
asyncCall(promise) {
|
|
316
|
+
asyncCall(promise, scope) {
|
|
311
317
|
val schemas = getCore().getProofSchemas(construct(query))
|
|
312
318
|
return@asyncCall convertToRN(schemas)
|
|
313
319
|
}
|
|
@@ -315,7 +321,7 @@ class ProcivisOneCoreModule(reactContext: ReactApplicationContext) :
|
|
|
315
321
|
|
|
316
322
|
@ReactMethod
|
|
317
323
|
fun getProofSchema(proofSchemaId: String, promise: Promise) {
|
|
318
|
-
asyncCall(promise) {
|
|
324
|
+
asyncCall(promise, scope) {
|
|
319
325
|
val schema = getCore().getProofSchema(proofSchemaId)
|
|
320
326
|
return@asyncCall convertToRN(schema)
|
|
321
327
|
}
|
|
@@ -323,7 +329,7 @@ class ProcivisOneCoreModule(reactContext: ReactApplicationContext) :
|
|
|
323
329
|
|
|
324
330
|
@ReactMethod
|
|
325
331
|
fun deleteProofSchema(proofSchemaId: String, promise: Promise) {
|
|
326
|
-
asyncCall(promise) {
|
|
332
|
+
asyncCall(promise, scope) {
|
|
327
333
|
getCore().deleteProofSchema(proofSchemaId)
|
|
328
334
|
return@asyncCall null
|
|
329
335
|
}
|
|
@@ -331,23 +337,28 @@ class ProcivisOneCoreModule(reactContext: ReactApplicationContext) :
|
|
|
331
337
|
|
|
332
338
|
@ReactMethod
|
|
333
339
|
fun importProofSchema(request: ReadableMap, promise: Promise) {
|
|
334
|
-
asyncCall(promise) {
|
|
340
|
+
asyncCall(promise, scope) {
|
|
335
341
|
return@asyncCall getCore().importProofSchema(construct(request))
|
|
336
342
|
}
|
|
337
343
|
}
|
|
338
344
|
|
|
339
345
|
@ReactMethod
|
|
340
|
-
fun checkRevocation(
|
|
341
|
-
|
|
346
|
+
fun checkRevocation(
|
|
347
|
+
credentialIds: ReadableArray,
|
|
348
|
+
bypassCache: ReadableArray?,
|
|
349
|
+
promise: Promise
|
|
350
|
+
) {
|
|
351
|
+
asyncCall(promise, scope) {
|
|
342
352
|
val ids = DeserializeSpecific.ids(credentialIds)
|
|
343
|
-
val
|
|
353
|
+
val bypass = bypassCache?.let { enumList(it, BypassCacheBindingDto::valueOf) }
|
|
354
|
+
val results = getCore().checkRevocation(ids, bypass)
|
|
344
355
|
return@asyncCall convertToRN(results)
|
|
345
356
|
}
|
|
346
357
|
}
|
|
347
358
|
|
|
348
359
|
@ReactMethod
|
|
349
360
|
fun getHistory(query: ReadableMap, promise: Promise) {
|
|
350
|
-
asyncCall(promise) {
|
|
361
|
+
asyncCall(promise, scope) {
|
|
351
362
|
val listQuery = DeserializeSpecific.historyListQuery(query)
|
|
352
363
|
val history = getCore().getHistoryList(listQuery)
|
|
353
364
|
return@asyncCall convertToRN(history)
|
|
@@ -356,7 +367,7 @@ class ProcivisOneCoreModule(reactContext: ReactApplicationContext) :
|
|
|
356
367
|
|
|
357
368
|
@ReactMethod
|
|
358
369
|
fun getHistoryEntry(historyId: String, promise: Promise) {
|
|
359
|
-
asyncCall(promise) {
|
|
370
|
+
asyncCall(promise, scope) {
|
|
360
371
|
val result = getCore().getHistoryEntry(historyId)
|
|
361
372
|
return@asyncCall convertToRN(result)
|
|
362
373
|
}
|
|
@@ -364,14 +375,21 @@ class ProcivisOneCoreModule(reactContext: ReactApplicationContext) :
|
|
|
364
375
|
|
|
365
376
|
@ReactMethod
|
|
366
377
|
fun createTrustAnchor(request: ReadableMap, promise: Promise) {
|
|
367
|
-
asyncCall(promise) {
|
|
378
|
+
asyncCall(promise, scope) {
|
|
368
379
|
return@asyncCall getCore().createTrustAnchor(construct(request))
|
|
369
380
|
}
|
|
370
381
|
}
|
|
371
382
|
|
|
383
|
+
@ReactMethod
|
|
384
|
+
fun deleteTrustAnchor(trustAnchorId: String, promise: Promise) {
|
|
385
|
+
asyncCall(promise, scope) {
|
|
386
|
+
return@asyncCall getCore().deleteTrustAnchor(trustAnchorId)
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
372
390
|
@ReactMethod
|
|
373
391
|
fun getTrustAnchor(trustAnchorId: String, promise: Promise) {
|
|
374
|
-
asyncCall(promise) {
|
|
392
|
+
asyncCall(promise, scope) {
|
|
375
393
|
val trustAnchor = getCore().getTrustAnchor(trustAnchorId)
|
|
376
394
|
return@asyncCall convertToRN(trustAnchor)
|
|
377
395
|
}
|
|
@@ -379,15 +397,70 @@ class ProcivisOneCoreModule(reactContext: ReactApplicationContext) :
|
|
|
379
397
|
|
|
380
398
|
@ReactMethod
|
|
381
399
|
fun getTrustAnchors(query: ReadableMap, promise: Promise) {
|
|
382
|
-
asyncCall(promise) {
|
|
400
|
+
asyncCall(promise, scope) {
|
|
383
401
|
val trustAnchors = getCore().listTrustAnchors(construct(query))
|
|
384
402
|
return@asyncCall convertToRN(trustAnchors)
|
|
385
403
|
}
|
|
386
404
|
}
|
|
387
405
|
|
|
406
|
+
@ReactMethod
|
|
407
|
+
fun createTrustEntity(request: ReadableMap, promise: Promise) {
|
|
408
|
+
asyncCall(promise, scope) {
|
|
409
|
+
return@asyncCall getCore().createTrustEntity(construct(request))
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
@ReactMethod
|
|
414
|
+
fun getTrustEntity(trustEntityId: String, promise: Promise) {
|
|
415
|
+
asyncCall(promise, scope) {
|
|
416
|
+
val trustEntity = getCore().getTrustEntity(trustEntityId)
|
|
417
|
+
return@asyncCall convertToRN(trustEntity)
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
@ReactMethod
|
|
422
|
+
fun getTrustEntities(query: ReadableMap, promise: Promise) {
|
|
423
|
+
asyncCall(promise, scope) {
|
|
424
|
+
val trustEntity = getCore().listTrustEntities(construct(query))
|
|
425
|
+
return@asyncCall convertToRN(trustEntity)
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
@ReactMethod
|
|
431
|
+
fun getTrustEntityByDid(didId: String, promise: Promise) {
|
|
432
|
+
asyncCall(promise, scope) {
|
|
433
|
+
val trustEntity = getCore().getTrustEntityByDid(didId)
|
|
434
|
+
return@asyncCall convertToRN(trustEntity)
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
@ReactMethod
|
|
439
|
+
fun createRemoteTrustEntity(request: ReadableMap, promise: Promise) {
|
|
440
|
+
asyncCall(promise, scope) {
|
|
441
|
+
return@asyncCall getCore().createRemoteTrustEntity(construct(request))
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
@ReactMethod
|
|
446
|
+
fun updateRemoteTrustEntity(request: ReadableMap, promise: Promise) {
|
|
447
|
+
asyncCall(promise, scope) {
|
|
448
|
+
getCore().updateRemoteTrustEntity(construct(request))
|
|
449
|
+
return@asyncCall null
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
@ReactMethod
|
|
454
|
+
fun getRemoteTrustEntity(didId: String, promise: Promise) {
|
|
455
|
+
asyncCall(promise, scope) {
|
|
456
|
+
val trustEntity = getCore().getRemoteTrustEntity(didId)
|
|
457
|
+
return@asyncCall convertToRN(trustEntity)
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
388
461
|
@ReactMethod
|
|
389
462
|
fun createBackup(password: String, outputPath: String, promise: Promise) {
|
|
390
|
-
asyncCall(promise) {
|
|
463
|
+
asyncCall(promise, scope) {
|
|
391
464
|
val result = getCore().createBackup(password, outputPath)
|
|
392
465
|
return@asyncCall convertToRN(result)
|
|
393
466
|
}
|
|
@@ -395,7 +468,7 @@ class ProcivisOneCoreModule(reactContext: ReactApplicationContext) :
|
|
|
395
468
|
|
|
396
469
|
@ReactMethod
|
|
397
470
|
fun backupInfo(promise: Promise) {
|
|
398
|
-
asyncCall(promise) {
|
|
471
|
+
asyncCall(promise, scope) {
|
|
399
472
|
val backupInfo = getCore().backupInfo()
|
|
400
473
|
return@asyncCall convertToRN(backupInfo)
|
|
401
474
|
}
|
|
@@ -403,7 +476,7 @@ class ProcivisOneCoreModule(reactContext: ReactApplicationContext) :
|
|
|
403
476
|
|
|
404
477
|
@ReactMethod
|
|
405
478
|
fun unpackBackup(password: String, inputPath: String, promise: Promise) {
|
|
406
|
-
asyncCall(promise) {
|
|
479
|
+
asyncCall(promise, scope) {
|
|
407
480
|
val result = getCore().unpackBackup(password, inputPath)
|
|
408
481
|
return@asyncCall convertToRN(result)
|
|
409
482
|
}
|
|
@@ -411,7 +484,7 @@ class ProcivisOneCoreModule(reactContext: ReactApplicationContext) :
|
|
|
411
484
|
|
|
412
485
|
@ReactMethod
|
|
413
486
|
fun finalizeImport(promise: Promise) {
|
|
414
|
-
asyncCall(promise) {
|
|
487
|
+
asyncCall(promise, scope) {
|
|
415
488
|
getCore().finalizeImport()
|
|
416
489
|
return@asyncCall null
|
|
417
490
|
}
|
|
@@ -419,7 +492,7 @@ class ProcivisOneCoreModule(reactContext: ReactApplicationContext) :
|
|
|
419
492
|
|
|
420
493
|
@ReactMethod
|
|
421
494
|
fun rollbackImport(promise: Promise) {
|
|
422
|
-
asyncCall(promise) {
|
|
495
|
+
asyncCall(promise, scope) {
|
|
423
496
|
getCore().rollbackImport()
|
|
424
497
|
return@asyncCall null
|
|
425
498
|
}
|
|
@@ -427,15 +500,27 @@ class ProcivisOneCoreModule(reactContext: ReactApplicationContext) :
|
|
|
427
500
|
|
|
428
501
|
@ReactMethod
|
|
429
502
|
fun resolveJsonldContext(url: String, promise: Promise) {
|
|
430
|
-
asyncCall(promise) {
|
|
503
|
+
asyncCall(promise, scope) {
|
|
431
504
|
val result = getCore().resolveJsonldContext(url)
|
|
432
505
|
return@asyncCall convertToRN(result)
|
|
433
506
|
}
|
|
434
507
|
}
|
|
435
508
|
|
|
509
|
+
@ReactMethod
|
|
510
|
+
fun deleteCache(types: ReadableArray?, promise: Promise) {
|
|
511
|
+
asyncCall(promise, scope) {
|
|
512
|
+
var cacheTypeList: List<CacheTypeBindingDto>? = null;
|
|
513
|
+
if (types != null) {
|
|
514
|
+
cacheTypeList = enumList(types, CacheTypeBindingDto::valueOf)
|
|
515
|
+
}
|
|
516
|
+
getCore().deleteCache(cacheTypeList)
|
|
517
|
+
return@asyncCall null
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
436
521
|
@ReactMethod
|
|
437
522
|
fun uninitialize(deleteData: Boolean, promise: Promise) {
|
|
438
|
-
asyncCall(promise) {
|
|
523
|
+
asyncCall(promise, scope) {
|
|
439
524
|
getCore().uninitialize(deleteData)
|
|
440
525
|
oneCore = null
|
|
441
526
|
return@asyncCall null
|
|
@@ -53,7 +53,13 @@ object SerializeSpecific {
|
|
|
53
53
|
when (val value = c.value) {
|
|
54
54
|
is ClaimValueBindingDto.Boolean -> result.putBoolean("value", value.value)
|
|
55
55
|
is ClaimValueBindingDto.Float -> result.putDouble("value", value.value)
|
|
56
|
-
is ClaimValueBindingDto.Integer ->
|
|
56
|
+
is ClaimValueBindingDto.Integer -> {
|
|
57
|
+
if (value.value < Int.MIN_VALUE || value.value > Int.MAX_VALUE) {
|
|
58
|
+
result.putDouble("value", value.value.toDouble())
|
|
59
|
+
} else {
|
|
60
|
+
result.putInt("value", value.value.toInt())
|
|
61
|
+
}
|
|
62
|
+
}
|
|
57
63
|
is ClaimValueBindingDto.String -> result.putString("value", value.value)
|
|
58
64
|
is ClaimValueBindingDto.Nested ->
|
|
59
65
|
result.putArray("value", convertToRN(value.value) as ReadableArray)
|
|
@@ -1,20 +1,52 @@
|
|
|
1
1
|
package ch.procivis.one.core
|
|
2
2
|
|
|
3
|
+
import com.facebook.react.bridge.Arguments
|
|
3
4
|
import com.facebook.react.bridge.Promise
|
|
4
5
|
import com.facebook.react.bridge.ReadableMap
|
|
6
|
+
import kotlinx.coroutines.CoroutineScope
|
|
7
|
+
import kotlinx.coroutines.launch
|
|
5
8
|
|
|
6
9
|
object Util {
|
|
7
|
-
// error handling
|
|
8
|
-
fun
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
error.
|
|
14
|
-
|
|
15
|
-
error
|
|
16
|
-
|
|
10
|
+
// error handling + running core code outside JS thread
|
|
11
|
+
fun syncCall(promise: Promise, function: () -> Any?) {
|
|
12
|
+
object : Thread() {
|
|
13
|
+
override fun run() {
|
|
14
|
+
try {
|
|
15
|
+
promise.resolve(function())
|
|
16
|
+
} catch (error: BindingException.ErrorResponse) {
|
|
17
|
+
handleBindingException(promise, error)
|
|
18
|
+
} catch (error: Throwable) {
|
|
19
|
+
promise.reject(error)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}.start()
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
fun asyncCall(promise: Promise, scope: CoroutineScope, function: suspend () -> Any?) {
|
|
26
|
+
scope.launch {
|
|
27
|
+
try {
|
|
28
|
+
promise.resolve(function())
|
|
29
|
+
} catch (error: BindingException.ErrorResponse) {
|
|
30
|
+
handleBindingException(promise, error)
|
|
31
|
+
} catch (error: Throwable) {
|
|
32
|
+
promise.reject(error)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private fun handleBindingException(promise: Promise, error: BindingException.ErrorResponse) {
|
|
38
|
+
val userInfo = Arguments.createMap()
|
|
39
|
+
val cause = error.data.cause?.message
|
|
40
|
+
if (!cause.isNullOrEmpty()) {
|
|
41
|
+
userInfo.putString("cause", cause)
|
|
17
42
|
}
|
|
43
|
+
|
|
44
|
+
promise.reject(
|
|
45
|
+
error.data.code,
|
|
46
|
+
error.data.message,
|
|
47
|
+
error,
|
|
48
|
+
userInfo
|
|
49
|
+
)
|
|
18
50
|
}
|
|
19
51
|
}
|
|
20
52
|
|
package/core-sdk.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"android": {
|
|
3
3
|
"debug": {
|
|
4
|
-
"url": "https://onetfstatestorage.blob.core.windows.net/core-sdk/android/
|
|
5
|
-
"sha1": "
|
|
4
|
+
"url": "https://onetfstatestorage.blob.core.windows.net/core-sdk/android/33398/onecore-debug.aar",
|
|
5
|
+
"sha1": "06d7af07daa1a98ff1aad434aae6eeabac8531f0"
|
|
6
6
|
},
|
|
7
7
|
"release": {
|
|
8
|
-
"url": "https://onetfstatestorage.blob.core.windows.net/core-sdk/android/
|
|
9
|
-
"sha1": "
|
|
8
|
+
"url": "https://onetfstatestorage.blob.core.windows.net/core-sdk/android/33398/onecore-release.aar",
|
|
9
|
+
"sha1": "f5f0f535ef83e4c10019736fe86367b36c359d33"
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
12
|
"ios": {
|
|
13
|
-
"url": "https://onetfstatestorage.blob.core.windows.net/core-sdk/ios/
|
|
14
|
-
"sha1": "
|
|
13
|
+
"url": "https://onetfstatestorage.blob.core.windows.net/core-sdk/ios/33398/deploy.zip",
|
|
14
|
+
"sha1": "66f87203d8b3b36443c2bf6e1f2f577ccdf95907"
|
|
15
15
|
}
|
|
16
16
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,14 +2,9 @@ import { ONECore } from "./src/core";
|
|
|
2
2
|
export * from "./src/core";
|
|
3
3
|
export * from "./src/error";
|
|
4
4
|
/**
|
|
5
|
-
* Initialize ONE Core
|
|
5
|
+
* Initialize ONE Core
|
|
6
6
|
* @note Beware that only one instance can be initialized at a time, repeated calls will fail
|
|
7
|
+
* @param config one-core configuration
|
|
7
8
|
* @returns ONE Core instance
|
|
8
9
|
*/
|
|
9
|
-
export declare function
|
|
10
|
-
/**
|
|
11
|
-
* Initialize ONE Core for Verifier
|
|
12
|
-
* @note Beware that only one instance can be initialized at a time, repeated calls will fail
|
|
13
|
-
* @returns ONE Core instance
|
|
14
|
-
*/
|
|
15
|
-
export declare function initializeVerifierCore(): Promise<ONECore>;
|
|
10
|
+
export declare function initializeCore(config?: Record<string, unknown>): Promise<ONECore>;
|