@opencrvs/mosip 1.7.0-alpha.3 → 1.7.0-alpha.5

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/build/forms.d.ts CHANGED
@@ -13,7 +13,7 @@
13
13
  * @description E-Signet REDIRECT button form definition. Calls E-Signet /authorize (this field may not be supported in the latest release of OpenCRVS yet)
14
14
  *
15
15
  */
16
- export declare const esignet: (esignetAuthUrl: string, openIdProviderClientId: string, openIdProviderClaims: string, fieldName: string, callbackFieldName: string) => {
16
+ export declare const esignet: (event: string, sectionId: string, esignetAuthUrl: string, openIdProviderClientId: string, openIdProviderClaims: string | undefined, fieldName: string, callbackFieldName: string) => {
17
17
  name: string;
18
18
  validator: never[];
19
19
  icon: {
@@ -35,7 +35,7 @@ export declare const esignet: (esignetAuthUrl: string, openIdProviderClientId: s
35
35
  url: string;
36
36
  callback: {
37
37
  params: {
38
- code: string;
38
+ state: string;
39
39
  };
40
40
  trigger: string;
41
41
  };
@@ -72,17 +72,11 @@ export declare const esignetCallback: ({ fieldName, getOIDPUserInfoUrl, openIdPr
72
72
  'Content-type': string;
73
73
  };
74
74
  body: {
75
- code: string;
76
75
  clientId: string;
77
- redirectUri: string;
78
76
  };
79
77
  method: string;
80
78
  };
81
79
  };
82
- export declare const returnExpression: (fieldName: string) => {
83
- dependsOn: string[];
84
- expression: string;
85
- };
86
80
  export declare const esignetHidden: () => {
87
81
  name: string;
88
82
  type: string;
@@ -119,3 +113,70 @@ export declare const idReader: (event: string, sectionId: string, conditionals:
119
113
  export declare const qr: () => {
120
114
  type: string;
121
115
  };
116
+ export declare const verified: (event: string, sectionId: string) => {
117
+ name: string;
118
+ fieldId: string;
119
+ customQuestionMappingId: string;
120
+ type: string;
121
+ custom: boolean;
122
+ label: {
123
+ id: string;
124
+ defaultMessage: string;
125
+ };
126
+ initialValue: {
127
+ dependsOn: string[];
128
+ expression: string;
129
+ };
130
+ validator: never[];
131
+ };
132
+ export declare const idPendingVerificationBanner: (event: string, sectionId: string) => {
133
+ name: string;
134
+ type: string;
135
+ fieldId: string;
136
+ hideInPreview: boolean;
137
+ custom: boolean;
138
+ bannerType: string;
139
+ idFieldName: string;
140
+ label: {
141
+ id: string;
142
+ defaultMessage: string;
143
+ };
144
+ validator: never[];
145
+ conditionals: {
146
+ action: string;
147
+ expression: string;
148
+ }[];
149
+ };
150
+ export declare const idVerificationFields: (event: string, sectionId: string) => ({
151
+ name: string;
152
+ fieldId: string;
153
+ customQuestionMappingId: string;
154
+ type: string;
155
+ custom: boolean;
156
+ label: {
157
+ id: string;
158
+ defaultMessage: string;
159
+ };
160
+ initialValue: {
161
+ dependsOn: string[];
162
+ expression: string;
163
+ };
164
+ validator: never[];
165
+ } | {
166
+ name: string;
167
+ type: string;
168
+ fieldId: string;
169
+ hideInPreview: boolean;
170
+ custom: boolean;
171
+ bannerType: string;
172
+ idFieldName: string;
173
+ label: {
174
+ id: string;
175
+ defaultMessage: string;
176
+ };
177
+ validator: never[];
178
+ conditionals: {
179
+ action: string;
180
+ expression: string;
181
+ }[];
182
+ })[];
package/build/forms.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  // @TODO: Yet to be implemented! Placeholders for NPM publish.
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.qr = exports.idReader = exports.esignetHidden = exports.returnExpression = exports.esignetCallback = exports.popupButton = exports.esignet = void 0;
4
+ exports.idVerificationFields = exports.idPendingVerificationBanner = exports.verified = exports.qr = exports.idReader = exports.esignetHidden = exports.esignetCallback = exports.popupButton = exports.esignet = void 0;
5
5
  /**
6
6
  * E-Signet popup button and hidden field form definitions
7
7
  * @example
@@ -17,30 +17,15 @@ exports.qr = exports.idReader = exports.esignetHidden = exports.returnExpression
17
17
  * @description E-Signet REDIRECT button form definition. Calls E-Signet /authorize (this field may not be supported in the latest release of OpenCRVS yet)
18
18
  *
19
19
  */
20
- const esignet = (esignetAuthUrl, openIdProviderClientId, openIdProviderClaims, fieldName, callbackFieldName) => {
20
+ const esignet = (event, sectionId, esignetAuthUrl, openIdProviderClientId, openIdProviderClaims = "name,family_name,given_name,middle_name,birthdate,address", fieldName, callbackFieldName) => {
21
21
  const url = new URL(esignetAuthUrl);
22
22
  url.searchParams.append('client_id', openIdProviderClientId || 'mock-client_id');
23
23
  url.searchParams.append('response_type', 'code');
24
24
  url.searchParams.append('scope', 'openid profile');
25
25
  url.searchParams.append('acr_values', 'mosip:idp:acr:static-code');
26
- url.searchParams.append('claims', openIdProviderClaims || 'mock-claims');
27
- url.searchParams.append('state', 'trigger-onmount');
28
- /*
29
-
30
- TODO: Understand from Tahmid about how to handle this:
31
-
32
- url.searchParams.append(
33
- 'redirect_uri',
34
- `${window.location.origin}${OIDP_VERIFICATION_CALLBACK}`
35
- )
36
- const stateToBeSent: INidCallbackState = {
37
- pathname: currentPathname,
38
- declarationId: declarationId,
39
- section: currentSection
40
- }
41
- url.searchParams.append('state', JSON.stringify(stateToBeSent))
42
- */
43
- window.location.href = url.toString();
26
+ url.searchParams.append('claims', openIdProviderClaims);
27
+ url.searchParams.append('state', 'fetch-on-mount');
28
+ url.searchParams.append('redirect_uri', `${window.location.origin}/drafts/${window.location.pathname.split("/")[2]}/events/${event}/${sectionId}/group/${sectionId}`);
44
29
  return {
45
30
  name: fieldName,
46
31
  validator: [],
@@ -48,7 +33,7 @@ const esignet = (esignetAuthUrl, openIdProviderClientId, openIdProviderClaims, f
48
33
  desktop: 'Globe',
49
34
  mobile: 'Fingerprint'
50
35
  },
51
- type: "REDIRECT",
36
+ type: 'LINK_BUTTON',
52
37
  custom: true,
53
38
  label: {
54
39
  id: 'views.idReader.label.eSignet',
@@ -57,19 +42,19 @@ const esignet = (esignetAuthUrl, openIdProviderClientId, openIdProviderClaims, f
57
42
  hideInPreview: true,
58
43
  conditionals: [
59
44
  {
60
- action: "disable",
61
- expression: "!!$form.redirectCallbackFetch",
62
- },
45
+ action: 'disable',
46
+ expression: '!!$form.redirectCallbackFetch'
47
+ }
63
48
  ],
64
49
  options: {
65
- url: esignetAuthUrl,
50
+ url: url.toString(),
66
51
  callback: {
67
52
  params: {
68
- code: "esignet-mock-code",
53
+ state: 'fetch-on-mount'
69
54
  },
70
55
  trigger: callbackFieldName
71
- },
72
- },
56
+ }
57
+ }
73
58
  };
74
59
  };
75
60
  exports.esignet = esignet;
@@ -103,21 +88,12 @@ const esignetCallback = ({ fieldName, getOIDPUserInfoUrl, openIdProviderClientId
103
88
  'Content-type': 'application/json'
104
89
  },
105
90
  body: {
106
- code: "esignet-mock-code",
107
- clientId: openIdProviderClientId,
108
- redirectUri: ""
91
+ clientId: openIdProviderClientId
109
92
  },
110
93
  method: 'POST'
111
94
  }
112
95
  });
113
96
  exports.esignetCallback = esignetCallback;
114
- const returnExpression = (fieldName) => {
115
- return {
116
- dependsOn: ["redirectCallbackFetch"],
117
- expression: `$form.redirectCallbackFetch?.data?.${fieldName}`,
118
- };
119
- };
120
- exports.returnExpression = returnExpression;
121
97
  const esignetHidden = () => {
122
98
  return {
123
99
  name: 'INFORMANT_PSUT_TOKEN',
@@ -163,3 +139,56 @@ const qr = () => ({
163
139
  type: 'QR'
164
140
  });
165
141
  exports.qr = qr;
142
+ const verified = (event, sectionId) => {
143
+ const fieldName = 'verified';
144
+ const fieldId = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}`;
145
+ return {
146
+ name: 'verified',
147
+ fieldId,
148
+ customQuestionMappingId: fieldId,
149
+ type: 'HIDDEN',
150
+ custom: true,
151
+ label: {
152
+ id: 'messages.empty',
153
+ defaultMessage: ''
154
+ },
155
+ initialValue: {
156
+ dependsOn: ['idReader'],
157
+ expression: 'Boolean($form?.idReader)? "pending":""'
158
+ },
159
+ validator: []
160
+ };
161
+ };
162
+ exports.verified = verified;
163
+ const idPendingVerificationBanner = (event, sectionId) => {
164
+ const fieldName = 'verified';
165
+ const fieldId = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}`;
166
+ return {
167
+ name: 'idPending',
168
+ type: 'ID_VERIFICATION_BANNER',
169
+ fieldId,
170
+ hideInPreview: true,
171
+ custom: true,
172
+ bannerType: 'pending',
173
+ idFieldName: 'idReader',
174
+ label: {
175
+ id: 'messages.empty',
176
+ defaultMessage: ''
177
+ },
178
+ validator: [],
179
+ conditionals: [
180
+ {
181
+ action: 'hide',
182
+ expression: '$form?.verified !== "pending"'
183
+ }
184
+ ]
185
+ };
186
+ };
187
+ exports.idPendingVerificationBanner = idPendingVerificationBanner;
188
+ const idVerificationFields = (event, sectionId) => {
189
+ return [
190
+ (0, exports.verified)(event, sectionId),
191
+ (0, exports.idPendingVerificationBanner)(event, sectionId)
192
+ ];
193
+ };
194
+ exports.idVerificationFields = idVerificationFields;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencrvs/mosip",
3
- "version": "1.7.0-alpha.3",
3
+ "version": "1.7.0-alpha.5",
4
4
  "license": "MPL-2.0",
5
5
  "main": "./build/index.js",
6
6
  "exports": {
package/src/forms.ts CHANGED
@@ -16,36 +16,31 @@
16
16
  * @description E-Signet REDIRECT button form definition. Calls E-Signet /authorize (this field may not be supported in the latest release of OpenCRVS yet)
17
17
  *
18
18
  */
19
- export const esignet = (esignetAuthUrl: string, openIdProviderClientId: string, openIdProviderClaims: string, fieldName: string, callbackFieldName: string) => {
20
-
21
- const url = new URL(esignetAuthUrl)
19
+ export const esignet = (
20
+ event: string,
21
+ sectionId: string,
22
+ esignetAuthUrl: string,
23
+ openIdProviderClientId: string,
24
+ openIdProviderClaims: string = "name,family_name,given_name,middle_name,birthdate,address",
25
+ fieldName: string,
26
+ callbackFieldName: string
27
+ ) => {
28
+ const url = new URL(esignetAuthUrl);
22
29
 
23
30
  url.searchParams.append(
24
31
  'client_id',
25
32
  openIdProviderClientId || 'mock-client_id'
26
- )
27
- url.searchParams.append('response_type', 'code')
28
- url.searchParams.append('scope', 'openid profile')
29
- url.searchParams.append('acr_values', 'mosip:idp:acr:static-code')
30
- url.searchParams.append('claims', openIdProviderClaims || 'mock-claims')
31
- url.searchParams.append('state', 'trigger-onmount')
32
-
33
- /*
34
-
35
- TODO: Understand from Tahmid about how to handle this:
36
-
33
+ );
34
+ url.searchParams.append('response_type', 'code');
35
+ url.searchParams.append('scope', 'openid profile');
36
+ url.searchParams.append('acr_values', 'mosip:idp:acr:static-code');
37
+ url.searchParams.append('claims', openIdProviderClaims);
38
+ url.searchParams.append('state', 'fetch-on-mount');
37
39
  url.searchParams.append(
38
40
  'redirect_uri',
39
- `${window.location.origin}${OIDP_VERIFICATION_CALLBACK}`
41
+ `${window.location.origin}/drafts/${window.location.pathname.split("/")[2]}/events/${event}/${sectionId}/group/${sectionId}`
40
42
  )
41
- const stateToBeSent: INidCallbackState = {
42
- pathname: currentPathname,
43
- declarationId: declarationId,
44
- section: currentSection
45
- }
46
- url.searchParams.append('state', JSON.stringify(stateToBeSent))
47
- */
48
- window.location.href = url.toString()
43
+
49
44
 
50
45
  return {
51
46
  name: fieldName,
@@ -54,28 +49,28 @@ export const esignet = (esignetAuthUrl: string, openIdProviderClientId: string,
54
49
  desktop: 'Globe',
55
50
  mobile: 'Fingerprint'
56
51
  },
57
- type: "REDIRECT",
52
+ type: 'LINK_BUTTON',
58
53
  custom: true,
59
- label: {
54
+ label: {
60
55
  id: 'views.idReader.label.eSignet',
61
56
  defaultMessage: 'E-signet'
62
57
  },
63
58
  hideInPreview: true,
64
59
  conditionals: [
65
60
  {
66
- action: "disable",
67
- expression: "!!$form.redirectCallbackFetch",
68
- },
61
+ action: 'disable',
62
+ expression: '!!$form.redirectCallbackFetch'
63
+ }
69
64
  ],
70
65
  options: {
71
- url: esignetAuthUrl,
66
+ url: url.toString(),
72
67
  callback: {
73
68
  params: {
74
- code: "esignet-mock-code",
75
- },
69
+ state: 'fetch-on-mount'
70
+ },
76
71
  trigger: callbackFieldName
77
- },
78
- },
72
+ }
73
+ }
79
74
  };
80
75
  };
81
76
 
@@ -101,7 +96,7 @@ export const popupButton = ({
101
96
  export const esignetCallback = ({
102
97
  fieldName,
103
98
  getOIDPUserInfoUrl,
104
- openIdProviderClientId
99
+ openIdProviderClientId
105
100
  }: {
106
101
  fieldName: string;
107
102
  getOIDPUserInfoUrl: string;
@@ -121,21 +116,13 @@ export const esignetCallback = ({
121
116
  'Content-type': 'application/json'
122
117
  },
123
118
  body: {
124
- code: "esignet-mock-code",
125
- clientId: openIdProviderClientId,
126
- redirectUri: ""
119
+ clientId: openIdProviderClientId
127
120
  },
121
+
128
122
  method: 'POST'
129
123
  }
130
124
  });
131
125
 
132
- export const returnExpression = (fieldName: string) => {
133
- return {
134
- dependsOn: ["redirectCallbackFetch"],
135
- expression: `$form.redirectCallbackFetch?.data?.${fieldName}`,
136
- };
137
- };
138
-
139
126
  export const esignetHidden = () => {
140
127
  return {
141
128
  name: 'INFORMANT_PSUT_TOKEN',
@@ -187,5 +174,58 @@ export const qr = () => ({
187
174
  type: 'QR'
188
175
  });
189
176
 
177
+ export const verified = (event: string, sectionId: string) => {
178
+ const fieldName = 'verified';
179
+ const fieldId = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}`;
180
+ return {
181
+ name: 'verified',
182
+ fieldId,
183
+ customQuestionMappingId: fieldId,
184
+ type: 'HIDDEN',
185
+ custom: true,
186
+ label: {
187
+ id: 'messages.empty',
188
+ defaultMessage: ''
189
+ },
190
+ initialValue: {
191
+ dependsOn: ['idReader'],
192
+ expression: 'Boolean($form?.idReader)? "pending":""'
193
+ },
194
+ validator: []
195
+ };
196
+ };
190
197
 
198
+ export const idPendingVerificationBanner = (
199
+ event: string,
200
+ sectionId: string
201
+ ) => {
202
+ const fieldName = 'verified';
203
+ const fieldId = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}`;
204
+ return {
205
+ name: 'idPending',
206
+ type: 'ID_VERIFICATION_BANNER',
207
+ fieldId,
208
+ hideInPreview: true,
209
+ custom: true,
210
+ bannerType: 'pending',
211
+ idFieldName: 'idReader',
212
+ label: {
213
+ id: 'messages.empty',
214
+ defaultMessage: ''
215
+ },
216
+ validator: [],
217
+ conditionals: [
218
+ {
219
+ action: 'hide',
220
+ expression: '$form?.verified !== "pending"'
221
+ }
222
+ ]
223
+ };
224
+ };
191
225
 
226
+ export const idVerificationFields = (event: string, sectionId: string) => {
227
+ return [
228
+ verified(event, sectionId),
229
+ idPendingVerificationBanner(event, sectionId)
230
+ ];
231
+ };