Skip to content

Commit

Permalink
Merge pull request #242 from holashchand/issue-timezone
Browse files Browse the repository at this point in the history
added timezone to certificate signer
  • Loading branch information
srprasanna authored Aug 2, 2023
2 parents 8d06f38 + b7566fd commit f9a3122
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 8 deletions.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ services:
image: dockerhub/sunbird-rc-certificate-signer:${RELEASE_VERSION}
environment:
- PORT=8079
- TIME_ZONE=Asia/Kolkata
ports:
- "8079:8079"
volumes:
Expand Down
5 changes: 3 additions & 2 deletions services/certificate-signer/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ const CERTIFICATE_CONTROLLER_ID = process.env.CERTIFICATE_CONTROLLER_ID || 'http
const CERTIFICATE_ISSUER = process.env.CERTIFICATE_ISSUER || "https://sunbird.org/";
const CUSTOM_TEMPLATE_DELIMITERS = process.env.CUSTOM_TEMPLATE_DELIMITERS?.split(',') || "{{,}}".split(",");
const CACHE_CONTEXT_URLS = process.env.CACHE_CONTEXT_URLS || "";

const TIME_ZONE = process.env.TIME_ZONE;
module.exports = {
CERTIFICATE_CONTROLLER_ID,
CERTIFICATE_ISSUER,
CUSTOM_TEMPLATE_DELIMITERS,
CACHE_CONTEXT_URLS
CACHE_CONTEXT_URLS,
TIME_ZONE
};
33 changes: 33 additions & 0 deletions services/certificate-signer/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions services/certificate-signer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"handlebars-delimiters": "^1.0.0",
"jsonld-signatures": "^6.0.0",
"kafkajs": "^1.15.0",
"moment-timezone": "^0.5.43",
"mustache": "^4.2.0",
"node-cache": "^5.1.2",
"object-hash": "^3.0.0",
Expand Down
12 changes: 11 additions & 1 deletion services/certificate-signer/src/services/signerService.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const jsigs = require('jsonld-signatures');
const {Ed25519KeyPair, RSAKeyPair} = require('crypto-ld');
const {Ed25519Signature2018, RsaSignature2018} = jsigs.suites;
const {AssertionProofPurpose} = jsigs.purposes;
const {CERTIFICATE_CONTROLLER_ID, CUSTOM_TEMPLATE_DELIMITERS} = require('../../config/config');
const {CERTIFICATE_CONTROLLER_ID, CUSTOM_TEMPLATE_DELIMITERS, TIME_ZONE} = require('../../config/config');
const vc = require('vc-js');
const Handlebars = require("handlebars");
const delimiters = require('handlebars-delimiters');
Expand All @@ -15,6 +15,16 @@ delimiters(Handlebars, CUSTOM_TEMPLATE_DELIMITERS);
const {documentLoaders} = require('jsonld');
const {node: documentLoader} = documentLoaders;
const DEFAULT = "default";
const moment = require("moment-timezone");

Handlebars.registerHelper('formatTime', function (date) {
try {
if(!!TIME_ZONE) return moment.tz(date, TIME_ZONE).format();
} catch (err) {
console.log("Failed converting to timezone ", TIME_ZONE);
}
return date;
});

const KeyType = {
RSA: "RSA", ED25519: "ED25519"
Expand Down
17 changes: 12 additions & 5 deletions services/certificate-signer/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1706,11 +1706,6 @@
"resolved" "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz"
"version" "1.0.0"

"fsevents@^2.1.2", "fsevents@~2.3.2":
"integrity" "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA=="
"resolved" "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz"
"version" "2.3.2"

"function-bind@^1.1.1":
"integrity" "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
"resolved" "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz"
Expand Down Expand Up @@ -3018,6 +3013,18 @@
"for-in" "^1.0.2"
"is-extendable" "^1.0.1"

"moment-timezone@^0.5.43":
"integrity" "sha512-72j3aNyuIsDxdF1i7CEgV2FfxM1r6aaqJyLB2vwb33mXYyoyLly+F1zbWqhA3/bVIoJ4szlUoMbUnVdid32NUQ=="
"resolved" "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.43.tgz"
"version" "0.5.43"
dependencies:
"moment" "^2.29.4"

"moment@^2.29.4":
"integrity" "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w=="
"resolved" "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz"
"version" "2.29.4"

"ms@^2.1.1", "[email protected]":
"integrity" "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
"resolved" "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz"
Expand Down

0 comments on commit f9a3122

Please sign in to comment.