Skip to content

Commit a91c61f

Browse files
authored
Publish E-Signet mock Docker image - rename server pckg (#34)
* Publish E-Signet mock Docker image * Rename server package * remove duplicate env var * generate random names
1 parent 854d42b commit a91c61f

32 files changed

+254
-195
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# https://docs.github.com/en/actions/use-cases-and-examples/publishing-packages/publishing-docker-images#publishing-images-to-github-packages
2+
3+
name: "🧪 E-Signet mock: Build and publish Docker image"
4+
5+
on:
6+
push:
7+
branches:
8+
- main
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: esignet-mock
13+
14+
jobs:
15+
build-and-push-image:
16+
runs-on: ubuntu-latest
17+
18+
permissions:
19+
contents: read
20+
packages: write
21+
id-token: write
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
27+
- name: Log in to the Container registry
28+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
29+
with:
30+
registry: ${{ env.REGISTRY }}
31+
username: ${{ github.actor }}
32+
password: ${{ secrets.GITHUB_TOKEN }}
33+
34+
- name: Extract metadata (tags, labels) for Docker
35+
id: meta
36+
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81
37+
with:
38+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
39+
tags: |
40+
type=sha,prefix=
41+
env:
42+
DOCKER_METADATA_SHORT_SHA_LENGTH: 7
43+
44+
- name: Build and push Docker image
45+
id: push
46+
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75
47+
with:
48+
context: packages/esignet-mock
49+
push: true
50+
tags: ${{ steps.meta.outputs.tags }}
51+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/docker-publish.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
env:
1111
REGISTRY: ghcr.io
12-
IMAGE_NAME: ${{ github.repository }}
12+
IMAGE_NAME: mosip-api
1313

1414
jobs:
1515
build-and-push-image:
@@ -45,7 +45,7 @@ jobs:
4545
id: push
4646
uses: docker/build-push-action@v6
4747
with:
48-
context: packages/server
48+
context: packages/mosip-api
4949
push: true
5050
tags: ${{ steps.meta.outputs.tags }}
5151
labels: ${{ steps.meta.outputs.labels }}

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This package ensures a secure and a robust integration between OpenCRVS and MOSI
88
## Development
99

1010
```sh
11-
# start the server and all the mocked servers
11+
# start the mosip-api and all the mocked servers
1212
yarn install
1313
yarn dev
1414

docs/installation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Installation
22

3-
This document describes how to setup the integration between OpenCRVS and MOSIP. In this example, we will deploy the [mosip-mock](./packages/mosip-mock) server as the MOSIP server. In a real-world scenario, MOSIP would provide the details we're mocking.
3+
This document describes how to setup the integration between OpenCRVS and MOSIP. In this example, we will deploy the [mosip-mock](./packages/mosip-mock), [esigneet-mock](./packages/esigneet-mock) & [mosip-api](./packages/mosip-api). In a real-world scenario, MOSIP would provide the details we're mocking.

docs/playground.ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"### Send a birth bundle to the server webhook without having to create a record in UI"
7+
"### Send a birth bundle to the mosip-api webhook without having to create a record in UI"
88
]
99
},
1010
{
@@ -46,7 +46,7 @@
4646
"cell_type": "markdown",
4747
"metadata": {},
4848
"source": [
49-
"### Send a death bundle to the server webhook without having to create a record in UI"
49+
"### Send a death bundle to the mosip-api webhook without having to create a record in UI"
5050
]
5151
},
5252
{

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@opencrvs/mosip",
3-
"version": "1.7.0-alpha.8",
3+
"version": "1.7.0-alpha.9",
44
"license": "MPL-2.0",
55
"private": true,
66
"packageManager": "yarn@1.0.0",

packages/country-config/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@opencrvs/mosip",
3-
"version": "1.7.0-alpha.8",
3+
"version": "1.7.0-alpha.9",
44
"license": "MPL-2.0",
55
"main": "./build/index.js",
66
"exports": {

packages/country-config/src/forms.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export const popupButton = ({
8888

8989
/**
9090
*
91-
* @description esignet callback button form definition. Calls server/esignet-api /esignet/get-oidp-user-info (this field may not be supported in the latest release of OpenCRVS yet)
91+
* @description esignet callback button form definition. Calls mosip-api/esignet-api /esignet/get-oidp-user-info (this field may not be supported in the latest release of OpenCRVS yet)
9292
*
9393
*/
9494

packages/esignet-mock/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@opencrvs/esignet-mock",
33
"license": "MPL-2.0",
4-
"version": "1.7.0-alpha.8",
4+
"version": "1.7.0-alpha.9",
55
"main": "index.js",
66
"scripts": {
77
"dev": "NODE_ENV=development tsx watch src/index.ts",
@@ -11,6 +11,7 @@
1111
"@fastify/formbody": "^8.0.1",
1212
"@fastify/static": "^8.0.3",
1313
"@types/node": "^22.4.1",
14+
"casual": "^1.6.2",
1415
"envalid": "^8.0.0",
1516
"fastify": "^5.0.0",
1617
"jose": "^5.9.6",

packages/esignet-mock/src/index.ts

+14-11
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import formbody from "@fastify/formbody";
77
import * as jose from "jose";
88
import { readFileSync } from 'fs';
99
import { join } from 'path';
10+
import casual from 'casual';
1011

1112
const app = Fastify({ logger: true });
1213

@@ -88,22 +89,24 @@ type OIDPUserInfo = {
8889

8990
app.post("/oidc/userinfo", {
9091
handler: async (request: any, reply) => {
92+
const firstName = casual.first_name
93+
const lastName = casual.last_name
9194
const userInfo: OIDPUserInfo = {
9295
sub: "405710304278395",
93-
name: "Niko",
94-
given_name: "Simon",
95-
family_name: "Bellic",
96-
middle_name: "Stern",
97-
nickname: "Nik",
98-
preferred_username: "niko",
99-
profile: "niko_bellic",
100-
picture: "fnoudgoag",
101-
website: "www.nikobellic.com",
102-
email: "nikobel@gmail.com",
96+
name: `${firstName} ${lastName}`,
97+
given_name: firstName,
98+
family_name: lastName,
99+
middle_name: "",
100+
nickname: "",
101+
preferred_username: "",
102+
profile: "",
103+
picture: "",
104+
website: "",
105+
email: casual.email,
103106
email_verified: true,
104107
gender: "male",
105108
birthdate: "15/05/1990",
106-
zoneinfo: "fsrthtst",
109+
zoneinfo: "",
107110
locale: "en-US",
108111
phone_number: "0314412652",
109112
phone_number_verified: true,
File renamed without changes.
File renamed without changes.
File renamed without changes.

packages/server/package.json packages/mosip-api/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "@opencrvs/mosip-server",
3-
"version": "1.7.0-alpha.8",
2+
"name": "@opencrvs/mosip-api",
3+
"version": "1.7.0-alpha.9",
44
"license": "MPL-2.0",
55
"scripts": {
66
"dev": "NODE_ENV=development tsx watch src/index.ts",

packages/server/src/constants.ts packages/mosip-api/src/constants.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ export const env = cleanEnv(process.env, {
1818
devDefault: "http://localhost:7070/graphql",
1919
desc: "The URL of the OpenCRVS GraphQL Gateway",
2020
}),
21-
GATEWAY_URL: url({ devDefault: "http://localhost:7070" }),
22-
NATIONAL_ID_OIDP_REST_URL: url({ devDefault: "http://localhost:20260/" }),
23-
OIDP_REST_URL: url({ devDefault: "http://localhost:20260/" }),
21+
ESIGNET_USERINFO_URL: url({ devDefault: "http://localhost:20260/oidc/userinfo" }),
22+
ESIGNET_TOKEN_URL: url({ devDefault: "http://localhost:20260/oauth/token" }),
2423
OIDP_JWT_AUD_CLAIM: str({ devDefault: undefined }),
2524
OIDP_CLIENT_PRIVATE_KEY: str({ devDefault: readFileSync(join(__dirname, './dev-secrets/jwk.txt')).toString() }),
2625
});

packages/server/src/esignet-api.ts packages/mosip-api/src/esignet-api.ts

+3-8
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@ type OIDPUserInfo = {
5757

5858
const JWT_EXPIRATION_TIME = "1h";
5959
const JWT_ALG = "RS256";
60-
const OIDP_USERINFO_ENDPOINT =
61-
env.NATIONAL_ID_OIDP_REST_URL &&
62-
new URL("oidc/userinfo", env.NATIONAL_ID_OIDP_REST_URL).toString();
63-
const OIDP_TOKEN_ENDPOINT =
64-
env.OIDP_REST_URL && new URL("oauth/token", env.OIDP_REST_URL).toString();
6560

6661
export const OIDPUserInfoSchema = z.object({
6762
clientId: z.string(),
@@ -126,7 +121,7 @@ const fetchToken = async ({
126121
client_assertion: await generateSignedJwt(clientId),
127122
});
128123

129-
const request = await fetch(OIDP_TOKEN_ENDPOINT!, {
124+
const request = await fetch(env.ESIGNET_TOKEN_URL!, {
130125
method: "POST",
131126
headers: {
132127
"Content-Type": "application/x-www-form-urlencoded",
@@ -170,7 +165,7 @@ export const fetchLocationFromFHIR = <T = any>(
170165
method = "GET",
171166
body: string | undefined = undefined
172167
): Promise<T> => {
173-
return fetch(`${env.GATEWAY_URL}${suffix}`, {
168+
return fetch(`${env.OPENCRVS_GRAPHQL_GATEWAY_URL}${suffix}`, {
174169
method,
175170
headers: {
176171
"Content-Type": "application/json",
@@ -244,7 +239,7 @@ const pickUserInfo = async (userInfo: OIDPUserInfo) => {
244239
};
245240

246241
export const fetchUserInfo = async (accessToken: string) => {
247-
const request = await fetch(OIDP_USERINFO_ENDPOINT!, {
242+
const request = await fetch(env.ESIGNET_USERINFO_URL!, {
248243
method: "POST",
249244
headers: {
250245
Authorization: "Bearer " + accessToken,

packages/server/src/index.ts packages/mosip-api/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ async function run() {
7171
});
7272

7373
console.log(
74-
`OpenCRVS-MOSIP server running at http://${env.HOST}:${env.PORT}`
74+
`OpenCRVS-MOSIP API running at http://${env.HOST}:${env.PORT}`
7575
);
7676
console.log(
7777
`Swagger UI running at http://${env.HOST}:${env.PORT}/documentation`
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

packages/mosip-mock/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@opencrvs/mosip-mock",
3-
"version": "1.7.0-alpha.8",
3+
"version": "1.7.0-alpha.9",
44
"license": "MPL-2.0",
55
"scripts": {
66
"dev": "NODE_ENV=development tsx watch src/index.ts",

packages/mosip-mock/src/constants.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { bool, cleanEnv, email, port, str } from "envalid";
33
export const env = cleanEnv(process.env, {
44
PORT: port({ default: 20240 }),
55
HOST: str({ default: "0.0.0.0", devDefault: "localhost" }),
6-
OPENCRVS_MOSIP_SERVER_URL: str({
6+
OPENCRVS_MOSIP_API_URL: str({
77
devDefault: "http://localhost:2024/webhooks/mosip",
8-
desc: "The URL where @opencrvs/mosip/server receives webhooks from MOSIP",
8+
desc: "The URL where @opencrvs/mosip/mosip-api receives webhooks from MOSIP",
99
}),
1010

1111
SENDER_EMAIL_ADDRESS: email({

packages/mosip-mock/src/webhooks/opencrvs-birth.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const sendNid = async ({
2323

2424
await sendEmail(`NID created for tracking ID ${trackingId}`, `NID: ${nid}`);
2525

26-
const response = await fetch(env.OPENCRVS_MOSIP_SERVER_URL, {
26+
const response = await fetch(env.OPENCRVS_MOSIP_API_URL, {
2727
method: "POST",
2828
body: JSON.stringify({ nid, token, eventId, trackingId }),
2929
headers: {

0 commit comments

Comments
 (0)