@velocitycareerlabs/vcl-react-native 2.9.0 → 2.10.0-rc

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.
Files changed (42) hide show
  1. package/README.md +12 -1
  2. package/VclReactNative.podspec +1 -1
  3. package/android/build.gradle +1 -1
  4. package/android/src/main/java/io/velocitycareerlabs/reactnative/VclReactNativeModule.kt +58 -74
  5. package/android/src/main/java/io/velocitycareerlabs/reactnative/extensions/VCLErrorExtensions.kt +62 -2
  6. package/android/src/main/java/io/velocitycareerlabs/reactnative/utlis/Converter.kt +10 -2
  7. package/ios/Utils/Converter.swift +12 -1
  8. package/ios/VCLErrorBridge.swift +89 -0
  9. package/ios/VclReactNativeImpl.swift +29 -23
  10. package/lib/module/api/VCLApi.js +44 -18
  11. package/lib/module/api/VCLApi.js.map +1 -1
  12. package/lib/module/api/entities/error/VCLError.js +9 -13
  13. package/lib/module/api/entities/error/VCLError.js.map +1 -1
  14. package/lib/module/api/entities/error/VCLErrorCode.js +17 -0
  15. package/lib/module/api/entities/error/VCLErrorCode.js.map +1 -1
  16. package/lib/module/api/entities/error/VCLErrorDeserializer.js +98 -0
  17. package/lib/module/api/entities/error/VCLErrorDeserializer.js.map +1 -0
  18. package/lib/module/api/entities/initialization/VCLErrorCodeCompatibilityMode.js +15 -0
  19. package/lib/module/api/entities/initialization/VCLErrorCodeCompatibilityMode.js.map +1 -0
  20. package/lib/module/index.js +2 -1
  21. package/lib/module/index.js.map +1 -1
  22. package/lib/typescript/src/api/VCLApi.d.ts.map +1 -1
  23. package/lib/typescript/src/api/entities/error/VCLError.d.ts +22 -1
  24. package/lib/typescript/src/api/entities/error/VCLError.d.ts.map +1 -1
  25. package/lib/typescript/src/api/entities/error/VCLErrorCode.d.ts +15 -0
  26. package/lib/typescript/src/api/entities/error/VCLErrorCode.d.ts.map +1 -1
  27. package/lib/typescript/src/api/entities/error/VCLErrorDeserializer.d.ts +19 -0
  28. package/lib/typescript/src/api/entities/error/VCLErrorDeserializer.d.ts.map +1 -0
  29. package/lib/typescript/src/api/entities/initialization/VCLErrorCodeCompatibilityMode.d.ts +11 -0
  30. package/lib/typescript/src/api/entities/initialization/VCLErrorCodeCompatibilityMode.d.ts.map +1 -0
  31. package/lib/typescript/src/api/entities/initialization/VCLInitializationDescriptor.d.ts +12 -0
  32. package/lib/typescript/src/api/entities/initialization/VCLInitializationDescriptor.d.ts.map +1 -1
  33. package/lib/typescript/src/index.d.ts +4 -2
  34. package/lib/typescript/src/index.d.ts.map +1 -1
  35. package/package.json +1 -1
  36. package/src/api/VCLApi.ts +58 -18
  37. package/src/api/entities/error/VCLError.ts +33 -13
  38. package/src/api/entities/error/VCLErrorCode.ts +18 -0
  39. package/src/api/entities/error/VCLErrorDeserializer.ts +151 -0
  40. package/src/api/entities/initialization/VCLErrorCodeCompatibilityMode.ts +11 -0
  41. package/src/api/entities/initialization/VCLInitializationDescriptor.ts +12 -0
  42. package/src/index.tsx +10 -0
@@ -4,12 +4,33 @@
4
4
  * Copyright 2022 Velocity Career Labs inc.
5
5
  * SPDX-License-Identifier: Apache-2.0
6
6
  */
7
+ export type VCLNativeCauseDiagnostics = {
8
+ type?: string;
9
+ message?: string;
10
+ stackFrames?: string[];
11
+ };
12
+ export type VCLDiagnostics = {
13
+ nativePlatform?: 'ios' | 'android';
14
+ nativeType?: string;
15
+ nativeStackFrames?: string[];
16
+ nativeCause?: VCLNativeCauseDiagnostics;
17
+ };
18
+ export type VCLErrorInit = {
19
+ payload?: string;
20
+ error?: string;
21
+ errorCode?: string;
22
+ requestId?: string;
23
+ message?: string;
24
+ statusCode?: number;
25
+ diagnostics?: VCLDiagnostics;
26
+ };
7
27
  export declare class VCLError extends Error {
8
28
  payload?: string;
9
29
  error?: string;
10
30
  errorCode?: string;
11
31
  requestId?: string;
12
32
  statusCode?: number;
13
- constructor(error: any);
33
+ diagnostics?: VCLDiagnostics;
34
+ constructor(error?: VCLErrorInit);
14
35
  }
15
36
  //# sourceMappingURL=VCLError.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"VCLError.d.ts","sourceRoot":"","sources":["../../../../../../src/api/entities/error/VCLError.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,qBAAa,QAAS,SAAQ,KAAK;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;gBAER,KAAK,EAAE,GAAG;CAcvB"}
1
+ {"version":3,"file":"VCLError.d.ts","sourceRoot":"","sources":["../../../../../../src/api/entities/error/VCLError.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,cAAc,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,WAAW,CAAC,EAAE,yBAAyB,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,cAAc,CAAC;CAC9B,CAAC;AAEF,qBAAa,QAAS,SAAQ,KAAK;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,cAAc,CAAC;gBAEjB,KAAK,GAAE,YAAiB;CAUrC"}
@@ -5,6 +5,8 @@
5
5
  * SPDX-License-Identifier: Apache-2.0
6
6
  */
7
7
  export declare enum VCLErrorCode {
8
+ RemoteServicesUrlsNotFound = "remote_services_urls_not_found",
9
+ InjectedServicesNotFound = "injected_services_not_found",
8
10
  CredentialTypeNotRegistered = "credential_type_not_registered",
9
11
  IssuerRequiresIdentityPermission = "issuer_requires_identity_permission",
10
12
  IssuerRequiresNotaryPermission = "issuer_requires_notary_permission",
@@ -16,6 +18,19 @@ export declare enum VCLErrorCode {
16
18
  MismatchedOfferIssuerDid = "mismatched_offer_issuer_did",
17
19
  MismatchedCredentialIssuerDid = "mismatched_credential_issuer_did",
18
20
  MismatchedPresentationRequestInspectorDid = "mismatched_presentation_request_inspector_did",
21
+ InvalidLink = "invalid_link",
22
+ ConnectivityFailure = "connectivity_failure",
23
+ ClientRequestUnauthorized = "client_request_unauthorized",
24
+ ClientRequestRejected = "client_request_rejected",
25
+ IssuerDidUnresolvable = "issuer_did_unresolvable",
26
+ VerifierDidUnresolvable = "verifier_did_unresolvable",
27
+ RegistrationCheckInconclusive = "registration_check_inconclusive",
28
+ IssuerNotRegistered = "issuer_not_registered",
29
+ VerifierNotRegistered = "verifier_not_registered",
30
+ IssuerRequestInvalid = "issuer_request_invalid",
31
+ VerifierRequestInvalid = "verifier_request_invalid",
32
+ IssuerRequestUnauthorized = "issuer_request_unauthorized",
33
+ VerifierRequestUnauthorized = "verifier_request_unauthorized",
19
34
  SdkError = "sdk_error"
20
35
  }
21
36
  //# sourceMappingURL=VCLErrorCode.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"VCLErrorCode.d.ts","sourceRoot":"","sources":["../../../../../../src/api/entities/error/VCLErrorCode.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,oBAAY,YAAY;IAEtB,2BAA2B,mCAAmC;IAC9D,gCAAgC,wCAAwC;IACxE,8BAA8B,sCAAsC;IACpE,+BAA+B,uCAAuC;IACtE,4BAA4B,oCAAoC;IAChE,+BAA+B,uCAAuC;IACtE,iCAAiC,yCAAyC;IAE1E,0BAA0B,kCAAkC;IAC5D,wBAAwB,gCAAgC;IACxD,6BAA6B,qCAAqC;IAClE,yCAAyC,kDAAkD;IAE3F,QAAQ,cAAc;CACvB"}
1
+ {"version":3,"file":"VCLErrorCode.d.ts","sourceRoot":"","sources":["../../../../../../src/api/entities/error/VCLErrorCode.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,oBAAY,YAAY;IAEtB,0BAA0B,mCAAmC;IAC7D,wBAAwB,gCAAgC;IAGxD,2BAA2B,mCAAmC;IAC9D,gCAAgC,wCAAwC;IACxE,8BAA8B,sCAAsC;IACpE,+BAA+B,uCAAuC;IACtE,4BAA4B,oCAAoC;IAChE,+BAA+B,uCAAuC;IACtE,iCAAiC,yCAAyC;IAE1E,0BAA0B,kCAAkC;IAC5D,wBAAwB,gCAAgC;IACxD,6BAA6B,qCAAqC;IAClE,yCAAyC,kDAAkD;IAE3F,WAAW,iBAAiB;IAC5B,mBAAmB,yBAAyB;IAC5C,yBAAyB,gCAAgC;IACzD,qBAAqB,4BAA4B;IACjD,qBAAqB,4BAA4B;IACjD,uBAAuB,8BAA8B;IACrD,6BAA6B,oCAAoC;IACjE,mBAAmB,0BAA0B;IAC7C,qBAAqB,4BAA4B;IACjD,oBAAoB,2BAA2B;IAC/C,sBAAsB,6BAA6B;IACnD,yBAAyB,gCAAgC;IACzD,2BAA2B,kCAAkC;IAE7D,QAAQ,cAAc;CACvB"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Created by Michael Avoyan.
3
+ *
4
+ * Copyright 2022 Velocity Career Labs inc.
5
+ * SPDX-License-Identifier: Apache-2.0
6
+ */
7
+ import { VCLError } from './VCLError';
8
+ export declare const BRIDGED_VCL_ERROR_CODE = "VCL_BRIDGED_ERROR_V1";
9
+ export declare class VCLErrorDeserializer {
10
+ static fromJsonString(jsonString: string): VCLError;
11
+ private static isSerializedVCLError;
12
+ private static parseStatusCode;
13
+ private static parseDiagnostics;
14
+ private static parseNativeCause;
15
+ private static parseNativePlatform;
16
+ private static parseString;
17
+ private static parseStringArray;
18
+ }
19
+ //# sourceMappingURL=VCLErrorDeserializer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VCLErrorDeserializer.d.ts","sourceRoot":"","sources":["../../../../../../src/api/entities/error/VCLErrorDeserializer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,QAAQ,EAGT,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,sBAAsB,yBAAyB,CAAC;AAY7D,qBAAa,oBAAoB;IAC/B,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ;IAuBnD,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAMnC,OAAO,CAAC,MAAM,CAAC,eAAe;IAS9B,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAqC/B,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAwB/B,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAUlC,OAAO,CAAC,MAAM,CAAC,WAAW;IAI1B,OAAO,CAAC,MAAM,CAAC,gBAAgB;CAWhC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Created by Michael Avoyan.
3
+ *
4
+ * Copyright 2022 Velocity Career Labs inc.
5
+ * SPDX-License-Identifier: Apache-2.0
6
+ */
7
+ export declare enum VCLErrorCodeCompatibilityMode {
8
+ Taxonomy = "taxonomy",
9
+ Legacy = "legacy"
10
+ }
11
+ //# sourceMappingURL=VCLErrorCodeCompatibilityMode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VCLErrorCodeCompatibilityMode.d.ts","sourceRoot":"","sources":["../../../../../../src/api/entities/initialization/VCLErrorCodeCompatibilityMode.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,oBAAY,6BAA6B;IACvC,QAAQ,aAAa;IACrB,MAAM,WAAW;CAClB"}
@@ -6,6 +6,7 @@
6
6
  */
7
7
  import type { VCLEnvironment } from '../../VCLEnvironment';
8
8
  import type { VCLCryptoServicesDescriptor } from './VCLCryptoServicesDescriptor';
9
+ import type { VCLErrorCodeCompatibilityMode } from './VCLErrorCodeCompatibilityMode';
9
10
  import type { VCLXVnfProtocolVersion } from '../../VCLXVnfProtocolVersion';
10
11
  export interface VCLInitializationDescriptor {
11
12
  environment?: VCLEnvironment;
@@ -14,5 +15,16 @@ export interface VCLInitializationDescriptor {
14
15
  isDebugOn?: boolean;
15
16
  cryptoServicesDescriptor?: VCLCryptoServicesDescriptor;
16
17
  isDirectIssuerCheckOn?: boolean;
18
+ /**
19
+ * Controls whether native SDK errors use the new taxonomy codes or legacy
20
+ * backward-compatible mappings. Native SDKs default to taxonomy mode.
21
+ */
22
+ errorCodeCompatibilityMode?: VCLErrorCodeCompatibilityMode;
23
+ /**
24
+ * Maximum number of native stack frames to include in bridged error diagnostics.
25
+ * Native implementations clamp values to the range `0..20`.
26
+ * Use `0` to disable native stack frames.
27
+ */
28
+ nativeErrorStackFrameLimit?: number;
17
29
  }
18
30
  //# sourceMappingURL=VCLInitializationDescriptor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"VCLInitializationDescriptor.d.ts","sourceRoot":"","sources":["../../../../../../src/api/entities/initialization/VCLInitializationDescriptor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAE3E,MAAM,WAAW,2BAA2B;IAC1C,WAAW,CAAC,EAAE,cAAc,CAAC;IAC7B,mBAAmB,CAAC,EAAE,sBAAsB,CAAC;IAC7C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,wBAAwB,CAAC,EAAE,2BAA2B,CAAC;IACvD,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC"}
1
+ {"version":3,"file":"VCLInitializationDescriptor.d.ts","sourceRoot":"","sources":["../../../../../../src/api/entities/initialization/VCLInitializationDescriptor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AACrF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAE3E,MAAM,WAAW,2BAA2B;IAC1C,WAAW,CAAC,EAAE,cAAc,CAAC;IAC7B,mBAAmB,CAAC,EAAE,sBAAsB,CAAC;IAC7C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,wBAAwB,CAAC,EAAE,2BAA2B,CAAC;IACvD,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;;OAGG;IACH,0BAA0B,CAAC,EAAE,6BAA6B,CAAC;IAC3D;;;;OAIG;IACH,0BAA0B,CAAC,EAAE,MAAM,CAAC;CACrC"}
@@ -9,6 +9,7 @@ import { VCLEnvironment } from './api/VCLEnvironment';
9
9
  import { VCLXVnfProtocolVersion } from './api/VCLXVnfProtocolVersion';
10
10
  import { VCLCryptoServiceType } from './api/VCLCryptoServiceType';
11
11
  import { VCLSignatureAlgorithm } from './api/VCLSignatureAlgorithm';
12
+ import { VCLErrorCodeCompatibilityMode } from './api/entities/initialization/VCLErrorCodeCompatibilityMode';
12
13
  import type { VCLCryptoServicesDescriptor } from './api/entities/initialization/VCLCryptoServicesDescriptor';
13
14
  import type { VCLJwtServiceUrls } from './api/entities/initialization/VCLJwtServiceUrls';
14
15
  import type { VCLKeyServiceUrls } from './api/entities/initialization/VCLKeyServiceUrls';
@@ -67,7 +68,8 @@ import { VCLStatusCode } from './api/entities/error/VCLStatusCode';
67
68
  import { VCLErrorCode } from './api/entities/error/VCLErrorCode';
68
69
  import type { VCLAuthToken } from './api/entities/VCLAuthToken';
69
70
  import type { VCLAuthTokenDescriptor } from './api/entities/VCLAuthTokenDescriptor';
71
+ import type { VCLDiagnostics, VCLNativeCauseDiagnostics, VCLErrorInit } from './api/entities/error/VCLError';
70
72
  export default VclApi;
71
- export { VCLEnvironment, VCLCryptoServiceType, VCLSignatureAlgorithm, VCLXVnfProtocolVersion, VCLCountryCodes, VCLServiceType, VCLIssuingType, VCLError, VCLStatusCode, VCLErrorCode, };
72
- export type { Dictionary, VCLCountry, VCLCountries, VCLRegion, VCLRegions, VCLCredentialManifest, VCLCredentialManifestDescriptor, VCLCredentialManifestDescriptorByDeepLink, VCLCredentialManifestDescriptorByService, VCLCredentialType, VCLCredentialTypes, VCLCredentialTypeSchema, VCLCredentialTypeSchemas, VCLCredentialTypesUIFormSchema, VCLCredentialTypesUIFormSchemaDescriptor, VCLCredentialManifestDescriptorRefresh, VCLDeepLink, VCLExchange, VCLExchangeDescriptor, VCLFilter, VCLFinalizeOffersDescriptor, VCLGenerateOffersDescriptor, VCLJwt, VCLJwtVerifiableCredentials, VCLOffers, VCLOffer, VCLOrganization, VCLOrganizations, VCLOrganizationsSearchDescriptor, VCLPage, VCLPresentationRequest, VCLPresentationSubmission, VCLPublicJwk, VCLPushDelegate, VCLService, VCLServiceTypes, VCLSubmissionResult, VCLToken, VCLVerifiableCredential, VCLVerifiedProfile, VCLVerifiedProfileDescriptor, VCLInitializationDescriptor, VCLPresentationRequestDescriptor, VCLJwtDescriptor, VCLDidJwkDescriptor, VCLDidJwk, VCLCryptoServicesDescriptor, VCLJwtServiceUrls, VCLKeyServiceUrls, VCLRemoteCryptoServicesUrlsDescriptor, VCLAuthToken, VCLAuthTokenDescriptor, };
73
+ export { VCLEnvironment, VCLCryptoServiceType, VCLSignatureAlgorithm, VCLXVnfProtocolVersion, VCLCountryCodes, VCLServiceType, VCLIssuingType, VCLError, VCLStatusCode, VCLErrorCode, VCLErrorCodeCompatibilityMode, };
74
+ export type { Dictionary, VCLCountry, VCLCountries, VCLRegion, VCLRegions, VCLCredentialManifest, VCLCredentialManifestDescriptor, VCLCredentialManifestDescriptorByDeepLink, VCLCredentialManifestDescriptorByService, VCLCredentialType, VCLCredentialTypes, VCLCredentialTypeSchema, VCLCredentialTypeSchemas, VCLCredentialTypesUIFormSchema, VCLCredentialTypesUIFormSchemaDescriptor, VCLCredentialManifestDescriptorRefresh, VCLDeepLink, VCLExchange, VCLExchangeDescriptor, VCLFilter, VCLFinalizeOffersDescriptor, VCLGenerateOffersDescriptor, VCLJwt, VCLJwtVerifiableCredentials, VCLOffers, VCLOffer, VCLOrganization, VCLOrganizations, VCLOrganizationsSearchDescriptor, VCLPage, VCLPresentationRequest, VCLPresentationSubmission, VCLPublicJwk, VCLPushDelegate, VCLService, VCLServiceTypes, VCLSubmissionResult, VCLToken, VCLVerifiableCredential, VCLVerifiedProfile, VCLVerifiedProfileDescriptor, VCLInitializationDescriptor, VCLPresentationRequestDescriptor, VCLJwtDescriptor, VCLDidJwkDescriptor, VCLDidJwk, VCLCryptoServicesDescriptor, VCLJwtServiceUrls, VCLKeyServiceUrls, VCLRemoteCryptoServicesUrlsDescriptor, VCLAuthToken, VCLAuthTokenDescriptor, VCLDiagnostics, VCLNativeCauseDiagnostics, VCLErrorInit, };
73
75
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAA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,eAAe,EACf,cAAc,EACd,cAAc,EACd,QAAQ,EACR,aAAa,EACb,YAAY,GACb,CAAC;AACF,YAAY,EACV,UAAU,EACV,UAAU,EACV,YAAY,EACZ,SAAS,EACT,UAAU,EACV,qBAAqB,EACrB,+BAA+B,EAC/B,yCAAyC,EACzC,wCAAwC,EACxC,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,wBAAwB,EACxB,8BAA8B,EAC9B,wCAAwC,EACxC,sCAAsC,EACtC,WAAW,EACX,WAAW,EACX,qBAAqB,EACrB,SAAS,EACT,2BAA2B,EAC3B,2BAA2B,EAC3B,MAAM,EACN,2BAA2B,EAC3B,SAAS,EACT,QAAQ,EACR,eAAe,EACf,gBAAgB,EAChB,gCAAgC,EAChC,OAAO,EACP,sBAAsB,EACtB,yBAAyB,EACzB,YAAY,EACZ,eAAe,EACf,UAAU,EACV,eAAe,EACf,mBAAmB,EACnB,QAAQ,EACR,uBAAuB,EACvB,kBAAkB,EAClB,4BAA4B,EAC5B,2BAA2B,EAC3B,gCAAgC,EAChC,gBAAgB,EAChB,mBAAmB,EACnB,SAAS,EACT,2BAA2B,EAC3B,iBAAiB,EACjB,iBAAiB,EACjB,qCAAqC,EACrC,YAAY,EACZ,sBAAsB,GACvB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,6BAA6B,EAAE,MAAM,6DAA6D,CAAC;AAC5G,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM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C,EACxC,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,wBAAwB,EACxB,8BAA8B,EAC9B,wCAAwC,EACxC,sCAAsC,EACtC,WAAW,EACX,WAAW,EACX,qBAAqB,EACrB,SAAS,EACT,2BAA2B,EAC3B,2BAA2B,EAC3B,MAAM,EACN,2BAA2B,EAC3B,SAAS,EACT,QAAQ,EACR,eAAe,EACf,gBAAgB,EAChB,gCAAgC,EAChC,OAAO,EACP,sBAAsB,EACtB,yBAAyB,EACzB,YAAY,EACZ,eAAe,EACf,UAAU,EACV,eAAe,EACf,mBAAmB,EACnB,QAAQ,EACR,uBAAuB,EACvB,kBAAkB,EAClB,4BAA4B,EAC5B,2BAA2B,EAC3B,gCAAgC,EAChC,gBAAgB,EAChB,mBAAmB,EACnB,SAAS,EACT,2BAA2B,EAC3B,iBAAiB,EACjB,iBAAiB,EACjB,qCAAqC,EACrC,YAAY,EACZ,sBAAsB,EACtB,cAAc,EACd,yBAAyB,EACzB,YAAY,GACb,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velocitycareerlabs/vcl-react-native",
3
- "version": "2.9.0",
3
+ "version": "2.10.0-rc",
4
4
  "description": "Velocity Career Labs React Native SDK",
5
5
  "license": "Apache-2.0",
6
6
  "publishConfig": {
package/src/api/VCLApi.ts CHANGED
@@ -39,6 +39,10 @@ import {
39
39
  type VCLDidJwkDescriptor,
40
40
  VCLError,
41
41
  } from '@velocitycareerlabs/vcl-react-native';
42
+ import {
43
+ BRIDGED_VCL_ERROR_CODE,
44
+ VCLErrorDeserializer,
45
+ } from './entities/error/VCLErrorDeserializer';
42
46
 
43
47
  const { VclReactNative } = NativeModules;
44
48
 
@@ -49,7 +53,7 @@ export const VclApi = {
49
53
  try {
50
54
  return await VclReactNative.initialize(initializationDescriptor);
51
55
  } catch (e) {
52
- throw new VCLError(e);
56
+ throw toVCLError(e);
53
57
  }
54
58
  },
55
59
 
@@ -57,7 +61,7 @@ export const VclApi = {
57
61
  try {
58
62
  return await VclReactNative.getCountries();
59
63
  } catch (e) {
60
- throw new VCLError(e);
64
+ throw toVCLError(e);
61
65
  }
62
66
  },
63
67
 
@@ -65,7 +69,7 @@ export const VclApi = {
65
69
  try {
66
70
  return await VclReactNative.getCredentialTypes();
67
71
  } catch (e) {
68
- throw new VCLError(e);
72
+ throw toVCLError(e);
69
73
  }
70
74
  },
71
75
 
@@ -73,7 +77,7 @@ export const VclApi = {
73
77
  try {
74
78
  return await VclReactNative.getCredentialTypeSchemas();
75
79
  } catch (e) {
76
- throw new VCLError(e);
80
+ throw toVCLError(e);
77
81
  }
78
82
  },
79
83
 
@@ -85,7 +89,7 @@ export const VclApi = {
85
89
  presentationRequestDescriptor
86
90
  );
87
91
  } catch (e) {
88
- throw new VCLError(e);
92
+ throw toVCLError(e);
89
93
  }
90
94
  },
91
95
 
@@ -99,7 +103,7 @@ export const VclApi = {
99
103
  authToken
100
104
  );
101
105
  } catch (e) {
102
- throw new VCLError(e);
106
+ throw toVCLError(e);
103
107
  }
104
108
  },
105
109
 
@@ -109,7 +113,7 @@ export const VclApi = {
109
113
  try {
110
114
  return await VclReactNative.getExchangeProgress(exchangeDescriptor);
111
115
  } catch (e) {
112
- throw new VCLError(e);
116
+ throw toVCLError(e);
113
117
  }
114
118
  },
115
119
 
@@ -121,7 +125,7 @@ export const VclApi = {
121
125
  organizationsSearchDescriptor
122
126
  );
123
127
  } catch (e) {
124
- throw new VCLError(e);
128
+ throw toVCLError(e);
125
129
  }
126
130
  },
127
131
 
@@ -133,7 +137,7 @@ export const VclApi = {
133
137
  credentialManifestDescriptor
134
138
  );
135
139
  } catch (e) {
136
- throw new VCLError(e);
140
+ throw toVCLError(e);
137
141
  }
138
142
  },
139
143
 
@@ -143,7 +147,7 @@ export const VclApi = {
143
147
  try {
144
148
  return await VclReactNative.generateOffers(generateOffersDescriptor);
145
149
  } catch (e) {
146
- throw new VCLError(e);
150
+ throw toVCLError(e);
147
151
  }
148
152
  },
149
153
 
@@ -157,7 +161,7 @@ export const VclApi = {
157
161
  sessionToken
158
162
  );
159
163
  } catch (e) {
160
- throw new VCLError(e);
164
+ throw toVCLError(e);
161
165
  }
162
166
  },
163
167
 
@@ -171,7 +175,7 @@ export const VclApi = {
171
175
  sessionToken
172
176
  );
173
177
  } catch (e) {
174
- throw new VCLError(e);
178
+ throw toVCLError(e);
175
179
  }
176
180
  },
177
181
 
@@ -181,7 +185,7 @@ export const VclApi = {
181
185
  try {
182
186
  return await VclReactNative.getAuthToken(authTokenDescriptor);
183
187
  } catch (e) {
184
- throw new VCLError(e);
188
+ throw toVCLError(e);
185
189
  }
186
190
  },
187
191
 
@@ -193,7 +197,7 @@ export const VclApi = {
193
197
  credentialTypesUIFormSchemaDescriptor
194
198
  );
195
199
  } catch (e) {
196
- throw new VCLError(e);
200
+ throw toVCLError(e);
197
201
  }
198
202
  },
199
203
 
@@ -203,7 +207,7 @@ export const VclApi = {
203
207
  try {
204
208
  return await VclReactNative.getVerifiedProfile(verifiedProfileDescriptor);
205
209
  } catch (e) {
206
- throw new VCLError(e);
210
+ throw toVCLError(e);
207
211
  }
208
212
  },
209
213
 
@@ -219,7 +223,7 @@ export const VclApi = {
219
223
  remoteCryptoServicesToken
220
224
  );
221
225
  } catch (e) {
222
- throw new VCLError(e);
226
+ throw toVCLError(e);
223
227
  }
224
228
  },
225
229
 
@@ -235,7 +239,7 @@ export const VclApi = {
235
239
  remoteCryptoServicesToken
236
240
  );
237
241
  } catch (e) {
238
- throw new VCLError(e);
242
+ throw toVCLError(e);
239
243
  }
240
244
  },
241
245
 
@@ -245,7 +249,43 @@ export const VclApi = {
245
249
  try {
246
250
  return await VclReactNative.generateDidJwk(didJwkDescriptor);
247
251
  } catch (e) {
248
- throw new VCLError(e);
252
+ throw toVCLError(e);
249
253
  }
250
254
  },
251
255
  };
256
+
257
+ const toVCLError = (error: unknown): VCLError => {
258
+ if (error instanceof VCLError) {
259
+ return error;
260
+ }
261
+
262
+ if (isBridgedVCLError(error)) {
263
+ return VCLErrorDeserializer.fromJsonString(error.message);
264
+ }
265
+
266
+ return new VCLError({ message: toErrorMessage(error) });
267
+ };
268
+
269
+ const isBridgedVCLError = (
270
+ error: unknown
271
+ ): error is { code: typeof BRIDGED_VCL_ERROR_CODE; message: string } =>
272
+ typeof error === 'object' &&
273
+ error != null &&
274
+ (error as { code?: unknown }).code === BRIDGED_VCL_ERROR_CODE &&
275
+ typeof (error as { message?: unknown }).message === 'string';
276
+
277
+ const toErrorMessage = (error: unknown): string => {
278
+ if (error instanceof Error) {
279
+ return error.message;
280
+ }
281
+
282
+ if (typeof error === 'string') {
283
+ return error;
284
+ }
285
+
286
+ try {
287
+ return JSON.stringify(error) ?? String(error);
288
+ } catch (_stringifyError) {
289
+ return String(error);
290
+ }
291
+ };
@@ -5,25 +5,45 @@
5
5
  * SPDX-License-Identifier: Apache-2.0
6
6
  */
7
7
 
8
+ export type VCLNativeCauseDiagnostics = {
9
+ type?: string;
10
+ message?: string;
11
+ stackFrames?: string[];
12
+ };
13
+
14
+ export type VCLDiagnostics = {
15
+ nativePlatform?: 'ios' | 'android';
16
+ nativeType?: string;
17
+ nativeStackFrames?: string[];
18
+ nativeCause?: VCLNativeCauseDiagnostics;
19
+ };
20
+
21
+ export type VCLErrorInit = {
22
+ payload?: string;
23
+ error?: string;
24
+ errorCode?: string;
25
+ requestId?: string;
26
+ message?: string;
27
+ statusCode?: number;
28
+ diagnostics?: VCLDiagnostics;
29
+ };
30
+
8
31
  export class VCLError extends Error {
9
32
  payload?: string;
10
33
  error?: string;
11
34
  errorCode?: string;
12
35
  requestId?: string;
13
36
  statusCode?: number;
37
+ diagnostics?: VCLDiagnostics;
14
38
 
15
- constructor(error: any) {
16
- super(error);
17
- try {
18
- const errorJson = JSON.parse(error.message);
19
- this.payload = errorJson.payload;
20
- this.error = errorJson.error;
21
- this.errorCode = errorJson.errorCode;
22
- this.requestId = errorJson.requestId;
23
- this.message = errorJson.message;
24
- this.statusCode = parseInt(errorJson.statusCode, 10);
25
- } catch (e) {
26
- this.message = JSON.stringify(error);
27
- }
39
+ constructor(error: VCLErrorInit = {}) {
40
+ super(error.message);
41
+ this.name = 'VCLError';
42
+ this.payload = error.payload;
43
+ this.error = error.error;
44
+ this.errorCode = error.errorCode;
45
+ this.requestId = error.requestId;
46
+ this.statusCode = error.statusCode;
47
+ this.diagnostics = error.diagnostics;
28
48
  }
29
49
  }
@@ -6,6 +6,10 @@
6
6
  */
7
7
 
8
8
  export enum VCLErrorCode {
9
+ // Initialization
10
+ RemoteServicesUrlsNotFound = 'remote_services_urls_not_found',
11
+ InjectedServicesNotFound = 'injected_services_not_found',
12
+
9
13
  // Credential issuer verification error codes:
10
14
  CredentialTypeNotRegistered = 'credential_type_not_registered',
11
15
  IssuerRequiresIdentityPermission = 'issuer_requires_identity_permission',
@@ -19,6 +23,20 @@ export enum VCLErrorCode {
19
23
  MismatchedOfferIssuerDid = 'mismatched_offer_issuer_did',
20
24
  MismatchedCredentialIssuerDid = 'mismatched_credential_issuer_did',
21
25
  MismatchedPresentationRequestInspectorDid = 'mismatched_presentation_request_inspector_did',
26
+ // Error taxonomy
27
+ InvalidLink = 'invalid_link',
28
+ ConnectivityFailure = 'connectivity_failure',
29
+ ClientRequestUnauthorized = 'client_request_unauthorized',
30
+ ClientRequestRejected = 'client_request_rejected',
31
+ IssuerDidUnresolvable = 'issuer_did_unresolvable',
32
+ VerifierDidUnresolvable = 'verifier_did_unresolvable',
33
+ RegistrationCheckInconclusive = 'registration_check_inconclusive',
34
+ IssuerNotRegistered = 'issuer_not_registered',
35
+ VerifierNotRegistered = 'verifier_not_registered',
36
+ IssuerRequestInvalid = 'issuer_request_invalid',
37
+ VerifierRequestInvalid = 'verifier_request_invalid',
38
+ IssuerRequestUnauthorized = 'issuer_request_unauthorized',
39
+ VerifierRequestUnauthorized = 'verifier_request_unauthorized',
22
40
  // General error
23
41
  SdkError = 'sdk_error',
24
42
  }
@@ -0,0 +1,151 @@
1
+ /**
2
+ * Created by Michael Avoyan.
3
+ *
4
+ * Copyright 2022 Velocity Career Labs inc.
5
+ * SPDX-License-Identifier: Apache-2.0
6
+ */
7
+
8
+ import {
9
+ VCLError,
10
+ type VCLDiagnostics,
11
+ type VCLNativeCauseDiagnostics,
12
+ } from './VCLError';
13
+
14
+ export const BRIDGED_VCL_ERROR_CODE = 'VCL_BRIDGED_ERROR_V1';
15
+
16
+ type SerializedVCLError = {
17
+ payload?: string;
18
+ error?: string;
19
+ errorCode?: string;
20
+ requestId?: string;
21
+ message?: string;
22
+ statusCode?: unknown;
23
+ diagnostics?: unknown;
24
+ };
25
+
26
+ export class VCLErrorDeserializer {
27
+ static fromJsonString(jsonString: string): VCLError {
28
+ try {
29
+ const parsedError = JSON.parse(jsonString);
30
+
31
+ if (!VCLErrorDeserializer.isSerializedVCLError(parsedError)) {
32
+ return new VCLError({ message: jsonString });
33
+ }
34
+
35
+ const error = parsedError as SerializedVCLError;
36
+ return new VCLError({
37
+ payload: error.payload,
38
+ error: error.error,
39
+ errorCode: error.errorCode,
40
+ requestId: error.requestId,
41
+ message: error.message,
42
+ statusCode: VCLErrorDeserializer.parseStatusCode(error.statusCode),
43
+ diagnostics: VCLErrorDeserializer.parseDiagnostics(error.diagnostics),
44
+ });
45
+ } catch (_parseError) {
46
+ return new VCLError({ message: jsonString });
47
+ }
48
+ }
49
+
50
+ private static isSerializedVCLError(
51
+ value: unknown
52
+ ): value is SerializedVCLError {
53
+ return typeof value === 'object' && value != null && !Array.isArray(value);
54
+ }
55
+
56
+ private static parseStatusCode(statusCode: unknown): number | undefined {
57
+ if (statusCode == null) {
58
+ return undefined;
59
+ }
60
+
61
+ const parsedStatusCode = parseInt(String(statusCode), 10);
62
+ return Number.isNaN(parsedStatusCode) ? undefined : parsedStatusCode;
63
+ }
64
+
65
+ private static parseDiagnostics(
66
+ diagnostics: unknown
67
+ ): VCLDiagnostics | undefined {
68
+ if (typeof diagnostics !== 'object' || diagnostics == null) {
69
+ return undefined;
70
+ }
71
+
72
+ const nativePlatform = VCLErrorDeserializer.parseNativePlatform(
73
+ (diagnostics as { nativePlatform?: unknown }).nativePlatform
74
+ );
75
+ const nativeType = VCLErrorDeserializer.parseString(
76
+ (diagnostics as { nativeType?: unknown }).nativeType
77
+ );
78
+ const nativeStackFrames = VCLErrorDeserializer.parseStringArray(
79
+ (diagnostics as { nativeStackFrames?: unknown }).nativeStackFrames
80
+ );
81
+ const nativeCause = VCLErrorDeserializer.parseNativeCause(
82
+ (diagnostics as { nativeCause?: unknown }).nativeCause
83
+ );
84
+
85
+ if (
86
+ nativePlatform == null &&
87
+ nativeType == null &&
88
+ nativeStackFrames == null &&
89
+ nativeCause == null
90
+ ) {
91
+ return undefined;
92
+ }
93
+
94
+ return {
95
+ nativePlatform,
96
+ nativeType,
97
+ nativeStackFrames,
98
+ nativeCause,
99
+ };
100
+ }
101
+
102
+ private static parseNativeCause(
103
+ nativeCause: unknown
104
+ ): VCLNativeCauseDiagnostics | undefined {
105
+ if (typeof nativeCause !== 'object' || nativeCause == null) {
106
+ return undefined;
107
+ }
108
+
109
+ const type = VCLErrorDeserializer.parseString(
110
+ (nativeCause as { type?: unknown }).type
111
+ );
112
+ const message = VCLErrorDeserializer.parseString(
113
+ (nativeCause as { message?: unknown }).message
114
+ );
115
+ const stackFrames = VCLErrorDeserializer.parseStringArray(
116
+ (nativeCause as { stackFrames?: unknown }).stackFrames
117
+ );
118
+
119
+ if (type == null && message == null && stackFrames == null) {
120
+ return undefined;
121
+ }
122
+
123
+ return { type, message, stackFrames };
124
+ }
125
+
126
+ private static parseNativePlatform(
127
+ nativePlatform: unknown
128
+ ): VCLDiagnostics['nativePlatform'] {
129
+ if (nativePlatform === 'ios' || nativePlatform === 'android') {
130
+ return nativePlatform;
131
+ }
132
+
133
+ return undefined;
134
+ }
135
+
136
+ private static parseString(value: unknown): string | undefined {
137
+ return typeof value === 'string' ? value : undefined;
138
+ }
139
+
140
+ private static parseStringArray(value: unknown): string[] | undefined {
141
+ if (!Array.isArray(value)) {
142
+ return undefined;
143
+ }
144
+
145
+ const stackFrames = value.filter(
146
+ (stackFrame): stackFrame is string => typeof stackFrame === 'string'
147
+ );
148
+
149
+ return stackFrames.length > 0 ? stackFrames : undefined;
150
+ }
151
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Created by Michael Avoyan.
3
+ *
4
+ * Copyright 2022 Velocity Career Labs inc.
5
+ * SPDX-License-Identifier: Apache-2.0
6
+ */
7
+
8
+ export enum VCLErrorCodeCompatibilityMode {
9
+ Taxonomy = 'taxonomy',
10
+ Legacy = 'legacy',
11
+ }