@velocitycareerlabs/vcl-react-native 1.4.0 → 1.5.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.
Files changed (54) hide show
  1. package/android/build.gradle +2 -2
  2. package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  3. package/android/gradle.properties +3 -3
  4. package/lib/commonjs/api/VCLApi.js +137 -0
  5. package/lib/commonjs/api/VCLApi.js.map +1 -1
  6. package/lib/commonjs/api/entities/VCLError.js +40 -0
  7. package/lib/commonjs/api/entities/VCLError.js.map +1 -0
  8. package/lib/commonjs/api/entities/VCLJwt.js +2 -0
  9. package/lib/commonjs/api/entities/{VCLJWT.js.map → VCLJwt.js.map} +0 -0
  10. package/lib/commonjs/index.js +10 -5
  11. package/lib/commonjs/index.js.map +1 -1
  12. package/lib/module/api/VCLApi.js +132 -1
  13. package/lib/module/api/VCLApi.js.map +1 -1
  14. package/lib/module/api/entities/VCLError.js +28 -0
  15. package/lib/module/api/entities/VCLError.js.map +1 -0
  16. package/lib/module/api/entities/VCLJwt.js +2 -0
  17. package/lib/module/api/entities/{VCLJWT.js.map → VCLJwt.js.map} +0 -0
  18. package/lib/module/index.js +4 -6
  19. package/lib/module/index.js.map +1 -1
  20. package/lib/typescript/api/Dictionary.d.ts +1 -1
  21. package/lib/typescript/api/VCLApi.d.ts +21 -21
  22. package/lib/typescript/api/entities/VCLCountry.d.ts +1 -1
  23. package/lib/typescript/api/entities/VCLCredentialManifest.d.ts +2 -2
  24. package/lib/typescript/api/entities/VCLCredentialType.d.ts +1 -1
  25. package/lib/typescript/api/entities/VCLCredentialTypeSchema.d.ts +1 -1
  26. package/lib/typescript/api/entities/VCLCredentialTypesUIFormSchema.d.ts +1 -1
  27. package/lib/typescript/api/entities/VCLError.d.ts +12 -0
  28. package/lib/typescript/api/entities/{VCLJWT.d.ts → VCLJwt.d.ts} +1 -1
  29. package/lib/typescript/api/entities/VCLJwtVerifiableCredentials.d.ts +2 -2
  30. package/lib/typescript/api/entities/VCLOffers.d.ts +1 -1
  31. package/lib/typescript/api/entities/VCLOrganization.d.ts +1 -1
  32. package/lib/typescript/api/entities/VCLPresentationRequest.d.ts +2 -2
  33. package/lib/typescript/api/entities/VCLRegion.d.ts +1 -1
  34. package/lib/typescript/api/entities/VCLVerifiedProfile.d.ts +1 -1
  35. package/lib/typescript/index.d.ts +7 -6
  36. package/package.json +6 -6
  37. package/src/api/VCLApi.ts +170 -46
  38. package/src/api/entities/VCLCountry.ts +1 -1
  39. package/src/api/entities/VCLCredentialManifest.ts +2 -2
  40. package/src/api/entities/VCLCredentialType.ts +1 -1
  41. package/src/api/entities/VCLCredentialTypeSchema.ts +1 -1
  42. package/src/api/entities/VCLCredentialTypesUIFormSchema.ts +1 -1
  43. package/src/api/entities/VCLError.ts +24 -0
  44. package/src/api/entities/{VCLJWT.ts → VCLJwt.ts} +1 -1
  45. package/src/api/entities/VCLJwtVerifiableCredentials.ts +2 -2
  46. package/src/api/entities/VCLOffers.ts +1 -1
  47. package/src/api/entities/VCLOrganization.ts +1 -1
  48. package/src/api/entities/VCLPresentationRequest.ts +2 -2
  49. package/src/api/entities/VCLRegion.ts +1 -1
  50. package/src/api/entities/VCLVerifiedProfile.ts +1 -1
  51. package/src/index.tsx +10 -8
  52. package/vcl-react-native.podspec +1 -1
  53. package/lib/commonjs/api/entities/VCLJWT.js +0 -2
  54. package/lib/module/api/entities/VCLJWT.js +0 -2
@@ -6,7 +6,6 @@
6
6
  */
7
7
  import type { VCLCredentialManifest } from './entities/VCLCredentialManifest';
8
8
  import type { VCLCredentialManifestDescriptor } from './entities/VCLCredentialManifestDescriptor';
9
- import type { VCLCredentialType } from './entities/VCLCredentialType';
10
9
  import type { VCLCredentialTypeSchemas } from './entities/VCLCredentialTypeSchemas';
11
10
  import type { VCLCredentialTypesUIFormSchema } from './entities/VCLCredentialTypesUIFormSchema';
12
11
  import type { VCLCredentialTypesUIFormSchemaDescriptor } from './entities/VCLCredentialTypesUIFormSchemaDescriptor';
@@ -14,7 +13,7 @@ import type { VCLExchange } from './entities/VCLExchange';
14
13
  import type { VCLExchangeDescriptor } from './entities/VCLExchangeDescriptor';
15
14
  import type { VCLFinalizeOffersDescriptor } from './entities/VCLFinalizeOffersDescriptor';
16
15
  import type { VCLGenerateOffersDescriptor } from './entities/VCLGenerateOffersDescriptor';
17
- import type { VCLJWT } from './entities/VCLJWT';
16
+ import type { VCLJwt } from './entities/VCLJwt';
18
17
  import type { VCLJwtVerifiableCredentials } from './entities/VCLJwtVerifiableCredentials';
19
18
  import type { VCLOffers } from './entities/VCLOffers';
20
19
  import type { VCLOrganizations } from './entities/VCLOrganizations';
@@ -30,23 +29,24 @@ import type { VCLInitializationDescriptor } from './entities/VCLInitializationDe
30
29
  import type { VCLSubmissionResult } from './entities/VCLSubmissionResult';
31
30
  import type { VCLPresentationRequestDescriptor } from './entities/VCLPresentationRequestDescriptor';
32
31
  import type { VCLJwtDescriptor } from './entities/VCLJwtDescriptor';
33
- import type { VCLDidJwk } from 'src/api/entities/VCLDidJwk';
34
- export declare type VclApi = {
35
- initialize(initializationDescriptor: VCLInitializationDescriptor): Promise<void>;
36
- getCountries(): Promise<VCLCountries>;
37
- getCredentialTypeSchemas(): Promise<VCLCredentialTypeSchemas>;
38
- getCredentialTypes(): Promise<Array<VCLCredentialType>>;
39
- getPresentationRequest(presentationRequestDescriptor: VCLPresentationRequestDescriptor): Promise<VCLPresentationRequest>;
40
- submitPresentation(presentationSubmission: VCLPresentationSubmission): Promise<VCLSubmissionResult>;
41
- getExchangeProgress(exchangeDescriptor: VCLExchangeDescriptor): Promise<VCLExchange>;
42
- searchForOrganizations(organizationsSearchDescriptor: VCLOrganizationsSearchDescriptor): Promise<VCLOrganizations>;
43
- getCredentialManifest(credentialManifestDescriptor: VCLCredentialManifestDescriptor): Promise<VCLCredentialManifest>;
44
- generateOffers(generateOffersDescriptor: VCLGenerateOffersDescriptor): Promise<VCLOffers>;
45
- checkForOffers(generateOffersDescriptor: VCLGenerateOffersDescriptor, token: VCLToken): Promise<VCLOffers>;
46
- finalizeOffers(finalizeOffersDescriptor: VCLFinalizeOffersDescriptor, token: VCLToken): Promise<VCLJwtVerifiableCredentials>;
47
- getCredentialTypesUIFormSchema(credentialTypesUIFormSchemaDescriptor: VCLCredentialTypesUIFormSchemaDescriptor): Promise<VCLCredentialTypesUIFormSchema>;
48
- getVerifiedProfile(verifiedProfileDescriptor: VCLVerifiedProfileDescriptor): Promise<VCLVerifiedProfile>;
49
- verifyJwt(jwt: VCLJWT, jwkPublic: VCLJwkPublic): Promise<boolean>;
50
- generateSignedJwt(jwtDescriptor: VCLJwtDescriptor): Promise<VCLJWT>;
51
- generateDidJwk(): Promise<VCLDidJwk>;
32
+ import type { VCLDidJwk } from './entities/VCLDidJwk';
33
+ import type { VCLCredentialTypes } from './entities/VCLCredentialTypes';
34
+ export declare const VclApi: {
35
+ initialize: (initializationDescriptor: VCLInitializationDescriptor) => Promise<void>;
36
+ getCountries: () => Promise<VCLCountries>;
37
+ getCredentialTypes: () => Promise<VCLCredentialTypes>;
38
+ getCredentialTypeSchemas: () => Promise<VCLCredentialTypeSchemas>;
39
+ getPresentationRequest: (presentationRequestDescriptor: VCLPresentationRequestDescriptor) => Promise<VCLPresentationRequest>;
40
+ submitPresentation: (presentationSubmission: VCLPresentationSubmission) => Promise<VCLSubmissionResult>;
41
+ getExchangeProgress: (exchangeDescriptor: VCLExchangeDescriptor) => Promise<VCLExchange>;
42
+ searchForOrganizations: (organizationsSearchDescriptor: VCLOrganizationsSearchDescriptor) => Promise<VCLOrganizations>;
43
+ getCredentialManifest: (credentialManifestDescriptor: VCLCredentialManifestDescriptor) => Promise<VCLCredentialManifest>;
44
+ generateOffers: (generateOffersDescriptor: VCLGenerateOffersDescriptor) => Promise<VCLOffers>;
45
+ checkForOffers: (generateOffersDescriptor: VCLGenerateOffersDescriptor, token: VCLToken) => Promise<VCLOffers>;
46
+ finalizeOffers: (finalizeOffersDescriptor: VCLFinalizeOffersDescriptor, token: VCLToken) => Promise<VCLJwtVerifiableCredentials>;
47
+ getCredentialTypesUIFormSchema: (credentialTypesUIFormSchemaDescriptor: VCLCredentialTypesUIFormSchemaDescriptor) => Promise<VCLCredentialTypesUIFormSchema>;
48
+ getVerifiedProfile: (verifiedProfileDescriptor: VCLVerifiedProfileDescriptor) => Promise<VCLVerifiedProfile>;
49
+ verifyJwt: (jwt: VCLJwt, jwkPublic: VCLJwkPublic) => Promise<boolean>;
50
+ generateSignedJwt: (jwtDescriptor: VCLJwtDescriptor) => Promise<VCLJwt>;
51
+ generateDidJwk: () => Promise<VCLDidJwk>;
52
52
  };
@@ -7,7 +7,7 @@
7
7
  import type { Dictionary } from '../Dictionary';
8
8
  import type { VCLRegions } from './VCLRegions';
9
9
  export interface VCLCountry {
10
- payload: Dictionary<string>;
10
+ payload: Dictionary<any>;
11
11
  code: string;
12
12
  name: string;
13
13
  regions: VCLRegions;
@@ -4,9 +4,9 @@
4
4
  * Copyright 2022 Velocity Career Labs inc.
5
5
  * SPDX-License-Identifier: Apache-2.0
6
6
  */
7
- import type { VCLJWT } from './VCLJWT';
7
+ import type { VCLJwt } from './VCLJwt';
8
8
  export interface VCLCredentialManifest {
9
- jwt: VCLJWT;
9
+ jwt: VCLJwt;
10
10
  iss: string;
11
11
  did: string;
12
12
  exchangeId: string;
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import type { Dictionary } from '../Dictionary';
8
8
  export interface VCLCredentialType {
9
- payload: Dictionary<string>;
9
+ payload: Dictionary<any>;
10
10
  id: string;
11
11
  schema: string;
12
12
  createdAt: string;
@@ -6,5 +6,5 @@
6
6
  */
7
7
  import type { Dictionary } from '../Dictionary';
8
8
  export interface VCLCredentialTypeSchema {
9
- payload: Dictionary<string>;
9
+ payload: Dictionary<any>;
10
10
  }
@@ -6,5 +6,5 @@
6
6
  */
7
7
  import type { Dictionary } from '../Dictionary';
8
8
  export interface VCLCredentialTypesUIFormSchema {
9
- payload: Dictionary<string>;
9
+ payload: Dictionary<any>;
10
10
  }
@@ -0,0 +1,12 @@
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 class VCLError extends Error {
8
+ description?: string;
9
+ code?: number;
10
+ constructor(error: any);
11
+ }
12
+ export declare const toVclError: (error: any) => VCLError;
@@ -4,6 +4,6 @@
4
4
  * Copyright 2022 Velocity Career Labs inc.
5
5
  * SPDX-License-Identifier: Apache-2.0
6
6
  */
7
- export interface VCLJWT {
7
+ export interface VCLJwt {
8
8
  encodedJwt: string;
9
9
  }
@@ -4,7 +4,7 @@
4
4
  * Copyright 2022 Velocity Career Labs inc.
5
5
  * SPDX-License-Identifier: Apache-2.0
6
6
  */
7
- import type { VCLJWT } from './VCLJWT';
7
+ import type { VCLJwt } from './VCLJwt';
8
8
  export interface VCLJwtVerifiableCredentials {
9
- all: VCLJWT[];
9
+ all: VCLJwt[];
10
10
  }
@@ -7,7 +7,7 @@
7
7
  import type { Dictionary } from '../Dictionary';
8
8
  import type { VCLToken } from './VCLToken';
9
9
  export interface VCLOffers {
10
- all: Dictionary<string>[];
10
+ all: Dictionary<any>[];
11
11
  responseCode: number;
12
12
  token: VCLToken;
13
13
  }
@@ -7,6 +7,6 @@
7
7
  import type { Dictionary } from '../Dictionary';
8
8
  import type { VCLServiceCredentialAgentIssuer } from './VCLServiceCredentialAgentIssuer';
9
9
  export interface VCLOrganization {
10
- payload: Dictionary<string>;
10
+ payload: Dictionary<any>;
11
11
  serviceCredentialAgentIssuers: VCLServiceCredentialAgentIssuer[];
12
12
  }
@@ -4,11 +4,11 @@
4
4
  * Copyright 2022 Velocity Career Labs inc.
5
5
  * SPDX-License-Identifier: Apache-2.0
6
6
  */
7
- import type { VCLJWT } from './VCLJWT';
7
+ import type { VCLJwt } from './VCLJwt';
8
8
  import type { VCLJwkPublic } from './VCLJwkPublic';
9
9
  export interface VCLPresentationRequest {
10
10
  exchangeId: string;
11
- jwt: VCLJWT;
11
+ jwt: VCLJwt;
12
12
  jwkPublic: VCLJwkPublic;
13
13
  keyID: string;
14
14
  presentationDefinitionId: string;
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import type { Dictionary } from '../Dictionary';
8
8
  export interface VCLRegion {
9
- payload: Dictionary<string>;
9
+ payload: Dictionary<any>;
10
10
  code: string;
11
11
  name: string;
12
12
  }
@@ -7,7 +7,7 @@
7
7
  import type { VCLServiceTypes } from './VCLServiceTypes';
8
8
  import type { Dictionary } from '../Dictionary';
9
9
  export interface VCLVerifiedProfile {
10
- payload: Dictionary<string>;
10
+ payload: Dictionary<any>;
11
11
  credentialSubject: Dictionary<string>;
12
12
  name: string;
13
13
  logo: string;
@@ -4,7 +4,7 @@
4
4
  * Copyright 2022 Velocity Career Labs inc.
5
5
  * SPDX-License-Identifier: Apache-2.0
6
6
  */
7
- import type { VclApi } from './api/VCLApi';
7
+ import { VclApi } from './api/VCLApi';
8
8
  import type { VCLEnvironment } from './api/VCLEnvironment';
9
9
  import { VCLEnvTypes } from './api/VCLEnvironment';
10
10
  import type { VCLCountry } from './api/entities/VCLCountry';
@@ -18,6 +18,7 @@ import type { VCLCredentialManifestDescriptorByDeepLink } from './api/entities/V
18
18
  import type { VCLCredentialManifestDescriptorByService } from './api/entities/VCLCredentialManifestDescriptorByService';
19
19
  import type { VCLCredentialManifestDescriptorRefresh } from './api/entities/VCLCredentialManifestDescriptorRefresh';
20
20
  import type { VCLCredentialType } from './api/entities/VCLCredentialType';
21
+ import type { VCLCredentialTypes } from './api/entities/VCLCredentialTypes';
21
22
  import type { VCLCredentialTypeSchema } from './api/entities/VCLCredentialTypeSchema';
22
23
  import type { VCLCredentialTypeSchemas } from './api/entities/VCLCredentialTypeSchemas';
23
24
  import type { VCLCredentialTypesUIFormSchemaDescriptor } from './api/entities/VCLCredentialTypesUIFormSchemaDescriptor';
@@ -28,7 +29,7 @@ import type { VCLExchangeDescriptor } from './api/entities/VCLExchangeDescriptor
28
29
  import type { VCLFilter } from './api/entities/VCLFilter';
29
30
  import type { VCLFinalizeOffersDescriptor } from './api/entities/VCLFinalizeOffersDescriptor';
30
31
  import type { VCLGenerateOffersDescriptor } from './api/entities/VCLGenerateOffersDescriptor';
31
- import type { VCLJWT } from './api/entities/VCLJWT';
32
+ import type { VCLJwt } from './api/entities/VCLJwt';
32
33
  import type { VCLJwtVerifiableCredentials } from './api/entities/VCLJwtVerifiableCredentials';
33
34
  import type { VCLOffers } from './api/entities/VCLOffers';
34
35
  import type { VCLOrganization } from './api/entities/VCLOrganization';
@@ -52,7 +53,7 @@ import type { VCLInitializationDescriptor } from './api/entities/VCLInitializati
52
53
  import type { VCLPresentationRequestDescriptor } from './api/entities/VCLPresentationRequestDescriptor';
53
54
  import type { VCLJwtDescriptor } from './api/entities/VCLJwtDescriptor';
54
55
  import type { VCLDidJwk } from './api/entities/VCLDidJwk';
55
- import type { VCLErrorCode } from './api/entities/VCLErrorCode';
56
- declare const _default: VclApi;
57
- export default _default;
58
- export { Dictionary, VCLEnvironment, VCLEnvTypes, VCLCountry, VCLCountries, VCLCountryCodes, VCLRegion, VCLRegions, VCLCredentialManifest, VCLCredentialManifestDescriptor, VCLCredentialManifestDescriptorByDeepLink, VCLCredentialManifestDescriptorByService, VCLCredentialType, VCLCredentialTypeSchema, VCLCredentialTypeSchemas, VCLCredentialTypesUIFormSchema, VCLCredentialTypesUIFormSchemaDescriptor, VCLCredentialManifestDescriptorRefresh, VCLDeepLink, VCLExchange, VCLExchangeDescriptor, VCLFilter, VCLFinalizeOffersDescriptor, VCLGenerateOffersDescriptor, VCLJWT, VCLJwtVerifiableCredentials, VCLOffers, VCLOrganization, VCLOrganizations, VCLOrganizationsSearchDescriptor, VCLPage, VCLPresentationRequest, VCLPresentationSubmission, VCLJwkPublic, VCLPushDelegate, VCLService, VCLServiceCredentialAgentIssuer, VCLServiceType, VCLSubmissionResult, VCLToken, VCLVerifiableCredential, VCLVerifiedProfile, VCLVerifiedProfileDescriptor, VCLInitializationDescriptor, VCLPresentationRequestDescriptor, VCLJwtDescriptor, VCLDidJwk, VCLErrorCode, };
56
+ import { VCLErrorCode } from './api/entities/VCLErrorCode';
57
+ import type { VCLError, toVclError } from './api/entities/VCLError';
58
+ export default VclApi;
59
+ export { Dictionary, VCLEnvironment, VCLEnvTypes, VCLCountry, VCLCountries, VCLCountryCodes, VCLRegion, VCLRegions, VCLCredentialManifest, VCLCredentialManifestDescriptor, VCLCredentialManifestDescriptorByDeepLink, VCLCredentialManifestDescriptorByService, VCLCredentialType, VCLCredentialTypes, VCLCredentialTypeSchema, VCLCredentialTypeSchemas, VCLCredentialTypesUIFormSchema, VCLCredentialTypesUIFormSchemaDescriptor, VCLCredentialManifestDescriptorRefresh, VCLDeepLink, VCLExchange, VCLExchangeDescriptor, VCLFilter, VCLFinalizeOffersDescriptor, VCLGenerateOffersDescriptor, VCLJwt, VCLJwtVerifiableCredentials, VCLOffers, VCLOrganization, VCLOrganizations, VCLOrganizationsSearchDescriptor, VCLPage, VCLPresentationRequest, VCLPresentationSubmission, VCLJwkPublic, VCLPushDelegate, VCLService, VCLServiceCredentialAgentIssuer, VCLServiceType, VCLSubmissionResult, VCLToken, VCLVerifiableCredential, VCLVerifiedProfile, VCLVerifiedProfileDescriptor, VCLInitializationDescriptor, VCLPresentationRequestDescriptor, VCLJwtDescriptor, VCLDidJwk, VCLErrorCode, VCLError, toVclError, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velocitycareerlabs/vcl-react-native",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Velocity Career Labs React Native SDK",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -50,22 +50,22 @@
50
50
  "@commitlint/config-conventional": "^11.0.0",
51
51
  "@react-native-community/eslint-config": "^2.0.0",
52
52
  "@release-it/conventional-changelog": "^2.0.0",
53
- "@types/jest": "^26.0.0",
53
+ "@types/jest": "^27.4.1",
54
54
  "@types/react": "^17.0.39",
55
- "@types/react-native": "0.66.15",
55
+ "@types/react-native": "^0.66.15",
56
56
  "commitlint": "^11.0.0",
57
57
  "eslint": "^7.2.0",
58
58
  "eslint-config-prettier": "^7.0.0",
59
59
  "eslint-plugin-prettier": "^3.1.3",
60
- "husky": "^4.2.5",
61
- "jest": "^26.0.1",
60
+ "husky": "^4.3.0",
61
+ "jest": "^27.5.1",
62
62
  "pod-install": "^0.1.0",
63
63
  "prettier": "^2.0.5",
64
64
  "react": "17.0.2",
65
65
  "react-native": "0.67.5",
66
66
  "react-native-builder-bob": "^0.18.0",
67
67
  "release-it": "^14.2.2",
68
- "typescript": "^4.1.3"
68
+ "typescript": "^4.6.2"
69
69
  },
70
70
  "peerDependencies": {
71
71
  "react": "*",
package/src/api/VCLApi.ts CHANGED
@@ -7,7 +7,6 @@
7
7
 
8
8
  import type { VCLCredentialManifest } from './entities/VCLCredentialManifest';
9
9
  import type { VCLCredentialManifestDescriptor } from './entities/VCLCredentialManifestDescriptor';
10
- import type { VCLCredentialType } from './entities/VCLCredentialType';
11
10
  import type { VCLCredentialTypeSchemas } from './entities/VCLCredentialTypeSchemas';
12
11
  import type { VCLCredentialTypesUIFormSchema } from './entities/VCLCredentialTypesUIFormSchema';
13
12
  import type { VCLCredentialTypesUIFormSchemaDescriptor } from './entities/VCLCredentialTypesUIFormSchemaDescriptor';
@@ -15,7 +14,7 @@ import type { VCLExchange } from './entities/VCLExchange';
15
14
  import type { VCLExchangeDescriptor } from './entities/VCLExchangeDescriptor';
16
15
  import type { VCLFinalizeOffersDescriptor } from './entities/VCLFinalizeOffersDescriptor';
17
16
  import type { VCLGenerateOffersDescriptor } from './entities/VCLGenerateOffersDescriptor';
18
- import type { VCLJWT } from './entities/VCLJWT';
17
+ import type { VCLJwt } from './entities/VCLJwt';
19
18
  import type { VCLJwtVerifiableCredentials } from './entities/VCLJwtVerifiableCredentials';
20
19
  import type { VCLOffers } from './entities/VCLOffers';
21
20
  import type { VCLOrganizations } from './entities/VCLOrganizations';
@@ -31,62 +30,187 @@ import type { VCLInitializationDescriptor } from './entities/VCLInitializationDe
31
30
  import type { VCLSubmissionResult } from './entities/VCLSubmissionResult';
32
31
  import type { VCLPresentationRequestDescriptor } from './entities/VCLPresentationRequestDescriptor';
33
32
  import type { VCLJwtDescriptor } from './entities/VCLJwtDescriptor';
34
- import type { VCLDidJwk } from 'src/api/entities/VCLDidJwk';
33
+ import type { VCLDidJwk } from './entities/VCLDidJwk';
34
+ import { toVclError } from './entities/VCLError';
35
+ import type { VCLCredentialTypes } from './entities/VCLCredentialTypes';
35
36
 
36
- export type VclApi = {
37
- initialize(
38
- initializationDescriptor: VCLInitializationDescriptor
39
- ): Promise<void>;
40
-
41
- getCountries(): Promise<VCLCountries>;
42
- getCredentialTypeSchemas(): Promise<VCLCredentialTypeSchemas>;
43
- getCredentialTypes(): Promise<Array<VCLCredentialType>>;
37
+ import { NativeModules } from 'react-native';
38
+ const { VclReactNative } = NativeModules;
44
39
 
45
- getPresentationRequest(
40
+ export const VclApi = {
41
+ initialize: async (
42
+ initializationDescriptor: VCLInitializationDescriptor
43
+ ): Promise<void> => {
44
+ try {
45
+ return await VclReactNative.initialize(initializationDescriptor);
46
+ } catch (e) {
47
+ throw toVclError(e);
48
+ }
49
+ },
50
+
51
+ getCountries: async (): Promise<VCLCountries> => {
52
+ try {
53
+ return await VclReactNative.getCountries();
54
+ } catch (e) {
55
+ throw toVclError(e);
56
+ }
57
+ },
58
+
59
+ getCredentialTypes: async (): Promise<VCLCredentialTypes> => {
60
+ try {
61
+ return await VclReactNative.getCredentialTypes();
62
+ } catch (e) {
63
+ throw toVclError(e);
64
+ }
65
+ },
66
+
67
+ getCredentialTypeSchemas: async (): Promise<VCLCredentialTypeSchemas> => {
68
+ try {
69
+ return await VclReactNative.getCredentialTypeSchemas();
70
+ } catch (e) {
71
+ throw toVclError(e);
72
+ }
73
+ },
74
+
75
+ getPresentationRequest: async (
46
76
  presentationRequestDescriptor: VCLPresentationRequestDescriptor
47
- ): Promise<VCLPresentationRequest>;
48
-
49
- submitPresentation(
77
+ ): Promise<VCLPresentationRequest> => {
78
+ try {
79
+ return await VclReactNative.getPresentationRequest(
80
+ presentationRequestDescriptor
81
+ );
82
+ } catch (e) {
83
+ throw toVclError(e);
84
+ }
85
+ },
86
+
87
+ submitPresentation: async (
50
88
  presentationSubmission: VCLPresentationSubmission
51
- ): Promise<VCLSubmissionResult>;
52
-
53
- getExchangeProgress(
89
+ ): Promise<VCLSubmissionResult> => {
90
+ try {
91
+ return await VclReactNative.submitPresentation(presentationSubmission);
92
+ } catch (e) {
93
+ throw toVclError(e);
94
+ }
95
+ },
96
+
97
+ getExchangeProgress: async (
54
98
  exchangeDescriptor: VCLExchangeDescriptor
55
- ): Promise<VCLExchange>;
56
-
57
- searchForOrganizations(
99
+ ): Promise<VCLExchange> => {
100
+ try {
101
+ return await VclReactNative.getExchangeProgress(exchangeDescriptor);
102
+ } catch (e) {
103
+ throw toVclError(e);
104
+ }
105
+ },
106
+
107
+ searchForOrganizations: async (
58
108
  organizationsSearchDescriptor: VCLOrganizationsSearchDescriptor
59
- ): Promise<VCLOrganizations>;
60
-
61
- getCredentialManifest(
109
+ ): Promise<VCLOrganizations> => {
110
+ try {
111
+ return await VclReactNative.searchForOrganizations(
112
+ organizationsSearchDescriptor
113
+ );
114
+ } catch (e) {
115
+ throw toVclError(e);
116
+ }
117
+ },
118
+
119
+ getCredentialManifest: async (
62
120
  credentialManifestDescriptor: VCLCredentialManifestDescriptor
63
- ): Promise<VCLCredentialManifest>;
64
-
65
- generateOffers(
121
+ ): Promise<VCLCredentialManifest> => {
122
+ try {
123
+ return await VclReactNative.getCredentialManifest(
124
+ credentialManifestDescriptor
125
+ );
126
+ } catch (e) {
127
+ throw toVclError(e);
128
+ }
129
+ },
130
+
131
+ generateOffers: async (
66
132
  generateOffersDescriptor: VCLGenerateOffersDescriptor
67
- ): Promise<VCLOffers>;
68
-
69
- checkForOffers(
133
+ ): Promise<VCLOffers> => {
134
+ try {
135
+ return await VclReactNative.generateOffers(generateOffersDescriptor);
136
+ } catch (e) {
137
+ throw toVclError(e);
138
+ }
139
+ },
140
+
141
+ checkForOffers: async (
70
142
  generateOffersDescriptor: VCLGenerateOffersDescriptor,
71
143
  token: VCLToken
72
- ): Promise<VCLOffers>;
73
-
74
- finalizeOffers(
144
+ ): Promise<VCLOffers> => {
145
+ try {
146
+ return await VclReactNative.checkForOffers(
147
+ generateOffersDescriptor,
148
+ token
149
+ );
150
+ } catch (e) {
151
+ throw toVclError(e);
152
+ }
153
+ },
154
+
155
+ finalizeOffers: async (
75
156
  finalizeOffersDescriptor: VCLFinalizeOffersDescriptor,
76
157
  token: VCLToken
77
- ): Promise<VCLJwtVerifiableCredentials>;
78
-
79
- getCredentialTypesUIFormSchema(
158
+ ): Promise<VCLJwtVerifiableCredentials> => {
159
+ try {
160
+ return await VclReactNative.finalizeOffers(
161
+ finalizeOffersDescriptor,
162
+ token
163
+ );
164
+ } catch (e) {
165
+ throw toVclError(e);
166
+ }
167
+ },
168
+
169
+ getCredentialTypesUIFormSchema: async (
80
170
  credentialTypesUIFormSchemaDescriptor: VCLCredentialTypesUIFormSchemaDescriptor
81
- ): Promise<VCLCredentialTypesUIFormSchema>;
82
-
83
- getVerifiedProfile(
171
+ ): Promise<VCLCredentialTypesUIFormSchema> => {
172
+ try {
173
+ return await VclReactNative.getCredentialTypesUIFormSchema(
174
+ credentialTypesUIFormSchemaDescriptor
175
+ );
176
+ } catch (e) {
177
+ throw toVclError(e);
178
+ }
179
+ },
180
+
181
+ getVerifiedProfile: async (
84
182
  verifiedProfileDescriptor: VCLVerifiedProfileDescriptor
85
- ): Promise<VCLVerifiedProfile>;
86
-
87
- verifyJwt(jwt: VCLJWT, jwkPublic: VCLJwkPublic): Promise<boolean>;
88
-
89
- generateSignedJwt(jwtDescriptor: VCLJwtDescriptor): Promise<VCLJWT>;
90
-
91
- generateDidJwk(): Promise<VCLDidJwk>;
183
+ ): Promise<VCLVerifiedProfile> => {
184
+ try {
185
+ return await VclReactNative.getVerifiedProfile(verifiedProfileDescriptor);
186
+ } catch (e) {
187
+ throw toVclError(e);
188
+ }
189
+ },
190
+
191
+ verifyJwt: async (jwt: VCLJwt, jwkPublic: VCLJwkPublic): Promise<boolean> => {
192
+ try {
193
+ return await VclReactNative.verifyJwt(jwt, jwkPublic);
194
+ } catch (e) {
195
+ throw toVclError(e);
196
+ }
197
+ },
198
+
199
+ generateSignedJwt: async (
200
+ jwtDescriptor: VCLJwtDescriptor
201
+ ): Promise<VCLJwt> => {
202
+ try {
203
+ return await VclReactNative.generateSignedJwt(jwtDescriptor);
204
+ } catch (e) {
205
+ throw toVclError(e);
206
+ }
207
+ },
208
+
209
+ generateDidJwk: async (): Promise<VCLDidJwk> => {
210
+ try {
211
+ return await VclReactNative.generateDidJwk();
212
+ } catch (e) {
213
+ throw toVclError(e);
214
+ }
215
+ },
92
216
  };
@@ -9,7 +9,7 @@ import type { Dictionary } from '../Dictionary';
9
9
  import type { VCLRegions } from './VCLRegions';
10
10
 
11
11
  export interface VCLCountry {
12
- payload: Dictionary<string>;
12
+ payload: Dictionary<any>;
13
13
  code: string;
14
14
  name: string;
15
15
  regions: VCLRegions;
@@ -5,10 +5,10 @@
5
5
  * SPDX-License-Identifier: Apache-2.0
6
6
  */
7
7
 
8
- import type { VCLJWT } from './VCLJWT';
8
+ import type { VCLJwt } from './VCLJwt';
9
9
 
10
10
  export interface VCLCredentialManifest {
11
- jwt: VCLJWT;
11
+ jwt: VCLJwt;
12
12
  iss: string;
13
13
  did: string;
14
14
  exchangeId: string;
@@ -8,7 +8,7 @@
8
8
  import type { Dictionary } from '../Dictionary';
9
9
 
10
10
  export interface VCLCredentialType {
11
- payload: Dictionary<string>;
11
+ payload: Dictionary<any>;
12
12
  id: string;
13
13
  schema: string;
14
14
  createdAt: string;
@@ -8,5 +8,5 @@
8
8
  import type { Dictionary } from '../Dictionary';
9
9
 
10
10
  export interface VCLCredentialTypeSchema {
11
- payload: Dictionary<string>;
11
+ payload: Dictionary<any>;
12
12
  }
@@ -8,5 +8,5 @@
8
8
  import type { Dictionary } from '../Dictionary';
9
9
 
10
10
  export interface VCLCredentialTypesUIFormSchema {
11
- payload: Dictionary<string>;
11
+ payload: Dictionary<any>;
12
12
  }
@@ -0,0 +1,24 @@
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 class VCLError extends Error {
9
+ description?: string;
10
+ code?: number;
11
+
12
+ constructor(error: any) {
13
+ super(error);
14
+ try {
15
+ const errorJson = JSON.parse(error.message);
16
+ this.description = errorJson.description;
17
+ this.code = parseInt(errorJson.code, 10);
18
+ } catch (e) {}
19
+ }
20
+ }
21
+
22
+ export const toVclError = (error: any) => {
23
+ return new VCLError(error);
24
+ };
@@ -5,6 +5,6 @@
5
5
  * SPDX-License-Identifier: Apache-2.0
6
6
  */
7
7
 
8
- export interface VCLJWT {
8
+ export interface VCLJwt {
9
9
  encodedJwt: string; // 3 base64Url strings splitted by a dot
10
10
  }
@@ -5,8 +5,8 @@
5
5
  * SPDX-License-Identifier: Apache-2.0
6
6
  */
7
7
 
8
- import type { VCLJWT } from './VCLJWT';
8
+ import type { VCLJwt } from './VCLJwt';
9
9
 
10
10
  export interface VCLJwtVerifiableCredentials {
11
- all: VCLJWT[];
11
+ all: VCLJwt[];
12
12
  }
@@ -9,7 +9,7 @@ import type { Dictionary } from '../Dictionary';
9
9
  import type { VCLToken } from './VCLToken';
10
10
 
11
11
  export interface VCLOffers {
12
- all: Dictionary<string>[];
12
+ all: Dictionary<any>[];
13
13
  responseCode: number;
14
14
  token: VCLToken;
15
15
  }
@@ -9,6 +9,6 @@ import type { Dictionary } from '../Dictionary';
9
9
  import type { VCLServiceCredentialAgentIssuer } from './VCLServiceCredentialAgentIssuer';
10
10
 
11
11
  export interface VCLOrganization {
12
- payload: Dictionary<string>;
12
+ payload: Dictionary<any>;
13
13
  serviceCredentialAgentIssuers: VCLServiceCredentialAgentIssuer[];
14
14
  }