@pagopa/io-react-native-iso18013 0.6.0 → 0.7.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.
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
17
17
 
18
18
  # Module dependencies
19
19
  s.dependency "IOWalletCBOR", "0.2.1"
20
- s.dependency "IOWalletProximity", "1.3.0"
20
+ s.dependency "IOWalletProximity", "1.3.2"
21
21
 
22
22
  # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
23
23
  # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
@@ -386,7 +386,8 @@ class IoReactNativeIso18013Module(reactContext: ReactApplicationContext) :
386
386
  * },
387
387
  * {...}
388
388
  * }
389
- * @throw IllegalArgumentException if the ReadableMap is not consistent or contains an invalid value
389
+ * @throw IllegalArgumentException if the value provided is not a ReadableMap which contains
390
+ * at least a credential type. If a namespace doesn't contain at least one value.
390
391
  * @returns String representation of [acceptedFields]
391
392
  */
392
393
  fun parseAcceptedFields(acceptedFields: ReadableMap): String {
@@ -399,10 +400,7 @@ class IoReactNativeIso18013Module(reactContext: ReactApplicationContext) :
399
400
  throw IllegalArgumentException("Credential '$credentialName' must be a map")
400
401
  }
401
402
 
402
- // If no namespace is found then throw
403
- if(!credentialValue.entryIterator.hasNext()){
404
- throw IllegalArgumentException("Credential '$credentialName' must define at least one namespace")
405
- }
403
+ // We don't check for a namespace, if there's none that's a valid structure and thus should pass the validation
406
404
 
407
405
  // Loop for each namespace in credential and throw if something different than map is found
408
406
  credentialValue.entryIterator.forEach { namespaceEntry ->
@@ -414,6 +414,17 @@ class IoReactNativeIso18013Test {
414
414
  assert(result == "{}")
415
415
  }
416
416
 
417
+ @Test
418
+ fun `should parse a map with a credential type but without any namespace nor values`() {
419
+ val nativeMap = JavaOnlyMap.of(
420
+ "org.iso.18013.5.1.mDL",
421
+ JavaOnlyMap()
422
+ )
423
+ val result = IoReactNativeIso18013Module.parseAcceptedFields(nativeMap)
424
+ print(result)
425
+ assert(result == "{org.iso.18013.5.1.mDL={}}")
426
+ }
427
+
417
428
  @Test
418
429
  fun `should throw an IllegalArgumentException if the credential type is not a map`() {
419
430
  val nativeMap = JavaOnlyMap.of(
@@ -450,19 +461,6 @@ class IoReactNativeIso18013Test {
450
461
  }
451
462
  }
452
463
 
453
- @Test
454
- fun `should throw an IllegalArgumentException if no namespace are provided for the credential`() {
455
- val nativeMap = JavaOnlyMap.of(
456
- "org.iso.18013.5.1.mDL",
457
- JavaOnlyMap()
458
- )
459
- assertThrows(
460
- IllegalArgumentException::class.java
461
- ) {
462
- IoReactNativeIso18013Module.parseAcceptedFields(nativeMap)
463
- }
464
- }
465
-
466
464
  @Test
467
465
  fun `should throw an IllegalArgumentException if no fields are provided for the namespace`() {
468
466
  val nativeMap = JavaOnlyMap.of(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pagopa/io-react-native-iso18013",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "React Native bridge for iso18013 methods",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/module/index.js",