Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish E-Signet mock Docker image - rename server pckg #34

Merged
merged 5 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/docker-publish-esignet-mock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# https://docs.github.com/en/actions/use-cases-and-examples/publishing-packages/publishing-docker-images#publishing-images-to-github-packages

name: "🧪 E-Signet mock: Build and publish Docker image"

on:
push:
branches:
- main

env:
REGISTRY: ghcr.io
IMAGE_NAME: esignet-mock

jobs:
build-and-push-image:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha,prefix=
env:
DOCKER_METADATA_SHORT_SHA_LENGTH: 7

- name: Build and push Docker image
id: push
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75
with:
context: packages/esignet-mock
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
4 changes: 2 additions & 2 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
IMAGE_NAME: mosip-api

jobs:
build-and-push-image:
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
id: push
uses: docker/build-push-action@v6
with:
context: packages/server
context: packages/mosip-api
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This package ensures a secure and a robust integration between OpenCRVS and MOSI
## Development

```sh
# start the server and all the mocked servers
# start the mosip-api and all the mocked servers
yarn install
yarn dev

Expand Down
2 changes: 1 addition & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Installation

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.
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
This document describes how to setup the integration between OpenCRVS and MOSIP. In this example, we will deploy the [mosip-mock](./packages/mosip-mock), [esignet-mock](./packages/esignet-mock) & [mosip-api](./packages/mosip-api). In a real-world scenario, MOSIP would provide the details we're mocking.

4 changes: 2 additions & 2 deletions docs/playground.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Send a birth bundle to the server webhook without having to create a record in UI"
"### Send a birth bundle to the mosip-api webhook without having to create a record in UI"
]
},
{
Expand Down Expand Up @@ -46,7 +46,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Send a death bundle to the server webhook without having to create a record in UI"
"### Send a death bundle to the mosip-api webhook without having to create a record in UI"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opencrvs/mosip",
"version": "1.7.0-alpha.6",
"version": "1.7.0-alpha.7",
"license": "MPL-2.0",
"private": true,
"packageManager": "[email protected]",
Expand Down
2 changes: 1 addition & 1 deletion packages/country-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opencrvs/mosip",
"version": "1.7.0-alpha.6",
"version": "1.7.0-alpha.7",
"license": "MPL-2.0",
"main": "./build/index.js",
"exports": {
Expand Down
2 changes: 1 addition & 1 deletion packages/country-config/src/forms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const popupButton = ({

/**
*
* @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)
* @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)
*
*/

Expand Down
3 changes: 2 additions & 1 deletion packages/esignet-mock/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@opencrvs/esignet-mock",
"license": "MPL-2.0",
"version": "1.7.0-alpha.6",
"version": "1.7.0-alpha.7",
"main": "index.js",
"scripts": {
"dev": "NODE_ENV=development tsx watch src/index.ts",
Expand All @@ -11,6 +11,7 @@
"@fastify/formbody": "^8.0.1",
"@fastify/static": "^8.0.3",
"@types/node": "^22.4.1",
"casual": "^1.6.2",
"envalid": "^8.0.0",
"fastify": "^5.0.0",
"jose": "^5.9.6",
Expand Down
25 changes: 14 additions & 11 deletions packages/esignet-mock/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import formbody from "@fastify/formbody";
import * as jose from "jose";
import { readFileSync } from 'fs';
import { join } from 'path';
import casual from 'casual';

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

Expand Down Expand Up @@ -88,22 +89,24 @@ type OIDPUserInfo = {

app.post("/oidc/userinfo", {
handler: async (request: any, reply) => {
const firstName = casual.first_name
const lastName = casual.last_name
const userInfo: OIDPUserInfo = {
sub: "405710304278395",
name: "Niko",
given_name: "Simon",
family_name: "Bellic",
middle_name: "Stern",
nickname: "Nik",
preferred_username: "niko",
profile: "niko_bellic",
picture: "fnoudgoag",
website: "www.nikobellic.com",
email: "[email protected]",
name: `${firstName} ${lastName}`,
given_name: firstName,
family_name: lastName,
middle_name: "",
nickname: "",
preferred_username: "",
profile: "",
picture: "",
website: "",
email: casual.email,
email_verified: true,
gender: "male",
birthdate: "15/05/1990",
zoneinfo: "fsrthtst",
zoneinfo: "",
locale: "en-US",
phone_number: "0314412652",
phone_number_verified: true,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opencrvs/mosip-server",
"version": "1.7.0-alpha.6",
"name": "@opencrvs/mosip-api",
"version": "1.7.0-alpha.7",
"license": "MPL-2.0",
"scripts": {
"dev": "NODE_ENV=development tsx watch src/index.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ export const env = cleanEnv(process.env, {
devDefault: "http://localhost:7070/graphql",
desc: "The URL of the OpenCRVS GraphQL Gateway",
}),
GATEWAY_URL: url({ devDefault: "http://localhost:7070" }),
NATIONAL_ID_OIDP_REST_URL: url({ devDefault: "http://localhost:20260/" }),
OIDP_REST_URL: url({ devDefault: "http://localhost:20260/" }),
ESIGNET_USERINFO_URL: url({ devDefault: "http://localhost:20260/oidc/userinfo" }),
ESIGNET_TOKEN_URL: url({ devDefault: "http://localhost:20260/oauth/token" }),
OIDP_JWT_AUD_CLAIM: str({ devDefault: undefined }),
OIDP_CLIENT_PRIVATE_KEY: str({ devDefault: readFileSync(join(__dirname, './dev-secrets/jwk.txt')).toString() }),
});
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ type OIDPUserInfo = {

const JWT_EXPIRATION_TIME = "1h";
const JWT_ALG = "RS256";
const OIDP_USERINFO_ENDPOINT =
env.NATIONAL_ID_OIDP_REST_URL &&
new URL("oidc/userinfo", env.NATIONAL_ID_OIDP_REST_URL).toString();
const OIDP_TOKEN_ENDPOINT =
env.OIDP_REST_URL && new URL("oauth/token", env.OIDP_REST_URL).toString();

export const OIDPUserInfoSchema = z.object({
clientId: z.string(),
Expand Down Expand Up @@ -126,7 +121,7 @@ const fetchToken = async ({
client_assertion: await generateSignedJwt(clientId),
});

const request = await fetch(OIDP_TOKEN_ENDPOINT!, {
const request = await fetch(env.ESIGNET_TOKEN_URL!, {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Expand Down Expand Up @@ -170,7 +165,7 @@ export const fetchLocationFromFHIR = <T = any>(
method = "GET",
body: string | undefined = undefined
): Promise<T> => {
return fetch(`${env.GATEWAY_URL}${suffix}`, {
return fetch(`${env.OPENCRVS_GRAPHQL_GATEWAY_URL}${suffix}`, {
method,
headers: {
"Content-Type": "application/json",
Expand Down Expand Up @@ -244,7 +239,7 @@ const pickUserInfo = async (userInfo: OIDPUserInfo) => {
};

export const fetchUserInfo = async (accessToken: string) => {
const request = await fetch(OIDP_USERINFO_ENDPOINT!, {
const request = await fetch(env.ESIGNET_USERINFO_URL!, {
method: "POST",
headers: {
Authorization: "Bearer " + accessToken,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ async function run() {
});

console.log(
`OpenCRVS-MOSIP server running at http://${env.HOST}:${env.PORT}`
`OpenCRVS-MOSIP API running at http://${env.HOST}:${env.PORT}`
);
console.log(
`Swagger UI running at http://${env.HOST}:${env.PORT}/documentation`
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/mosip-mock/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opencrvs/mosip-mock",
"version": "1.7.0-alpha.6",
"version": "1.7.0-alpha.7",
"license": "MPL-2.0",
"scripts": {
"dev": "NODE_ENV=development tsx watch src/index.ts",
Expand Down
4 changes: 2 additions & 2 deletions packages/mosip-mock/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { bool, cleanEnv, email, port, str } from "envalid";
export const env = cleanEnv(process.env, {
PORT: port({ default: 20240 }),
HOST: str({ default: "0.0.0.0", devDefault: "localhost" }),
OPENCRVS_MOSIP_SERVER_URL: str({
OPENCRVS_MOSIP_API_URL: str({
devDefault: "http://localhost:2024/webhooks/mosip",
desc: "The URL where @opencrvs/mosip/server receives webhooks from MOSIP",
desc: "The URL where @opencrvs/mosip/mosip-api receives webhooks from MOSIP",
}),

SENDER_EMAIL_ADDRESS: email({
Expand Down
2 changes: 1 addition & 1 deletion packages/mosip-mock/src/webhooks/opencrvs-birth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const sendNid = async ({

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

const response = await fetch(env.OPENCRVS_MOSIP_SERVER_URL, {
const response = await fetch(env.OPENCRVS_MOSIP_API_URL, {
method: "POST",
body: JSON.stringify({ nid, token, eventId, trackingId }),
headers: {
Expand Down
Loading
Loading