@opencrvs/mosip 1.7.0-alpha.1
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 +0 -0
- package/build/events.d.ts +4 -0
- package/build/events.js +25 -0
- package/build/forms.d.ts +31 -0
- package/build/forms.js +37 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +18 -0
- package/package.json +26 -0
- package/src/events.ts +24 -0
- package/src/forms.ts +42 -0
- package/src/index.ts +2 -0
- package/tsconfig.json +11 -0
package/README.md
ADDED
|
File without changes
|
package/build/events.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.mosipRegistrationHandler = void 0;
|
|
7
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
8
|
+
const mosipRegistrationHandler = ({ url }) => (async (request, h) => {
|
|
9
|
+
const OPENCRVS_MOSIP_GATEWAY_URL = new URL("./webhooks/opencrvs", url);
|
|
10
|
+
const response = await (0, node_fetch_1.default)(OPENCRVS_MOSIP_GATEWAY_URL, {
|
|
11
|
+
method: "POST",
|
|
12
|
+
body: JSON.stringify(request.payload),
|
|
13
|
+
headers: request.headers,
|
|
14
|
+
});
|
|
15
|
+
if (!response.ok) {
|
|
16
|
+
return h
|
|
17
|
+
.response({
|
|
18
|
+
error: "OpenCRVS-MOSIP gateway did not return a 200",
|
|
19
|
+
response: await response.text(),
|
|
20
|
+
})
|
|
21
|
+
.code(500);
|
|
22
|
+
}
|
|
23
|
+
return h.response({ success: true }).code(200);
|
|
24
|
+
});
|
|
25
|
+
exports.mosipRegistrationHandler = mosipRegistrationHandler;
|
package/build/forms.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* E-Signet popup button form definition
|
|
3
|
+
*/
|
|
4
|
+
export declare const popupButton: ({ url, }: {
|
|
5
|
+
url: string;
|
|
6
|
+
}) => {
|
|
7
|
+
name: string;
|
|
8
|
+
type: string;
|
|
9
|
+
url: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const hidden: () => {
|
|
12
|
+
name: string;
|
|
13
|
+
type: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* E-Signet popup button and hidden field form definitions
|
|
17
|
+
* @example
|
|
18
|
+
* ```
|
|
19
|
+
* [
|
|
20
|
+
* // ...other fields
|
|
21
|
+
* ...esignet({ url: "https://opencrvs-mosip-gateway.farajaland.opencrvs.org" })
|
|
22
|
+
* ]
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare const esignet: ({ url, }: {
|
|
26
|
+
/** URL to OpenCRVS-MOSIP gateway (e.g. https://opencrvs-mosip-gateway.farajaland.opencrvs.org) */
|
|
27
|
+
url: string;
|
|
28
|
+
}) => {
|
|
29
|
+
name: string;
|
|
30
|
+
type: string;
|
|
31
|
+
}[];
|
package/build/forms.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @TODO: we could start building these definitions to core tbh
|
|
3
|
+
// @TODO: add renovate or something to listen for core updates and create a PRs, then we get an error message if we have broken this
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.esignet = exports.hidden = exports.popupButton = void 0;
|
|
6
|
+
/**
|
|
7
|
+
* E-Signet popup button form definition
|
|
8
|
+
*/
|
|
9
|
+
const popupButton = ({
|
|
10
|
+
/** URL to OpenCRVS-MOSIP gateway (e.g. https://opencrvs-mosip-gateway.farajaland.opencrvs.org) */
|
|
11
|
+
url, }) => {
|
|
12
|
+
return {
|
|
13
|
+
name: "INFORMANT_AUTHENTICATION_POPUP_BUTTON",
|
|
14
|
+
type: "POPUP_BUTTON",
|
|
15
|
+
url,
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
exports.popupButton = popupButton;
|
|
19
|
+
const hidden = () => {
|
|
20
|
+
return {
|
|
21
|
+
name: "INFORMANT_PSUT_TOKEN",
|
|
22
|
+
type: "HIDDEN",
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
exports.hidden = hidden;
|
|
26
|
+
/**
|
|
27
|
+
* E-Signet popup button and hidden field form definitions
|
|
28
|
+
* @example
|
|
29
|
+
* ```
|
|
30
|
+
* [
|
|
31
|
+
* // ...other fields
|
|
32
|
+
* ...esignet({ url: "https://opencrvs-mosip-gateway.farajaland.opencrvs.org" })
|
|
33
|
+
* ]
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
const esignet = ({ url, }) => [(0, exports.popupButton)({ url }), (0, exports.hidden)()];
|
|
37
|
+
exports.esignet = esignet;
|
package/build/index.d.ts
ADDED
package/build/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./forms"), exports);
|
|
18
|
+
__exportStar(require("./events"), exports);
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@opencrvs/mosip",
|
|
3
|
+
"version": "1.7.0-alpha.1",
|
|
4
|
+
"license": "MPL-2.0",
|
|
5
|
+
"main": "./build/index.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./build/index.js",
|
|
8
|
+
"./form-definitions": "./build/form-definitions.js",
|
|
9
|
+
"./events": "./build/events.js"
|
|
10
|
+
},
|
|
11
|
+
"typings": "build/index.d.ts",
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@hapi/hapi": "^20.0.1"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/hapi__hapi": "^20.0.0",
|
|
20
|
+
"@types/node-fetch": "^2.6.11",
|
|
21
|
+
"typescript": "^5.6.3"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"node-fetch": "^3.3.2"
|
|
25
|
+
}
|
|
26
|
+
}
|
package/src/events.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type * as Hapi from "@hapi/hapi";
|
|
2
|
+
import fetch from "node-fetch";
|
|
3
|
+
|
|
4
|
+
export const mosipRegistrationHandler = ({ url }: { url: string }) =>
|
|
5
|
+
(async (request: Hapi.Request, h: Hapi.ResponseToolkit) => {
|
|
6
|
+
const OPENCRVS_MOSIP_GATEWAY_URL = new URL("./webhooks/opencrvs", url);
|
|
7
|
+
|
|
8
|
+
const response = await fetch(OPENCRVS_MOSIP_GATEWAY_URL, {
|
|
9
|
+
method: "POST",
|
|
10
|
+
body: JSON.stringify(request.payload),
|
|
11
|
+
headers: request.headers,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
if (!response.ok) {
|
|
15
|
+
return h
|
|
16
|
+
.response({
|
|
17
|
+
error: "OpenCRVS-MOSIP gateway did not return a 200",
|
|
18
|
+
response: await response.text(),
|
|
19
|
+
})
|
|
20
|
+
.code(500);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return h.response({ success: true }).code(200);
|
|
24
|
+
}) satisfies Hapi.ServerRoute["handler"];
|
package/src/forms.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// @TODO: we could start building these definitions to core tbh
|
|
2
|
+
// @TODO: add renovate or something to listen for core updates and create a PRs, then we get an error message if we have broken this
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* E-Signet popup button form definition
|
|
6
|
+
*/
|
|
7
|
+
export const popupButton = ({
|
|
8
|
+
/** URL to OpenCRVS-MOSIP gateway (e.g. https://opencrvs-mosip-gateway.farajaland.opencrvs.org) */
|
|
9
|
+
url,
|
|
10
|
+
}: {
|
|
11
|
+
url: string;
|
|
12
|
+
}) => {
|
|
13
|
+
return {
|
|
14
|
+
name: "INFORMANT_AUTHENTICATION_POPUP_BUTTON",
|
|
15
|
+
type: "POPUP_BUTTON",
|
|
16
|
+
url,
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const hidden = () => {
|
|
21
|
+
return {
|
|
22
|
+
name: "INFORMANT_PSUT_TOKEN",
|
|
23
|
+
type: "HIDDEN",
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* E-Signet popup button and hidden field form definitions
|
|
29
|
+
* @example
|
|
30
|
+
* ```
|
|
31
|
+
* [
|
|
32
|
+
* // ...other fields
|
|
33
|
+
* ...esignet({ url: "https://opencrvs-mosip-gateway.farajaland.opencrvs.org" })
|
|
34
|
+
* ]
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export const esignet = ({
|
|
38
|
+
url,
|
|
39
|
+
}: {
|
|
40
|
+
/** URL to OpenCRVS-MOSIP gateway (e.g. https://opencrvs-mosip-gateway.farajaland.opencrvs.org) */
|
|
41
|
+
url: string;
|
|
42
|
+
}) => [popupButton({ url }), hidden()];
|
package/src/index.ts
ADDED