config validation

This commit is contained in:
Ryosuke Abe
2023-08-17 09:23:22 +09:00
parent 56c5c61420
commit c50a5f13e6
4 changed files with 31 additions and 2 deletions

14
package-lock.json generated
View File

@ -11,6 +11,7 @@
"dependencies": {
"did-jwt": "^6.0.0",
"jose": "^4.6.0",
"readline-sync": "^1.4.10",
"web-did-resolver": "^2.0.14"
}
},
@ -299,6 +300,14 @@
}
}
},
"node_modules/readline-sync": {
"version": "1.4.10",
"resolved": "https://registry.npmjs.org/readline-sync/-/readline-sync-1.4.10.tgz",
"integrity": "sha512-gNva8/6UAe8QYepIQH/jQ2qn91Qj0B9sYjMBBs3QOB8F2CXcKgLxQaJRP76sWVRQt+QU+8fAkCbCvjjMFu7Ycw==",
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
@ -608,6 +617,11 @@
"whatwg-url": "^5.0.0"
}
},
"readline-sync": {
"version": "1.4.10",
"resolved": "https://registry.npmjs.org/readline-sync/-/readline-sync-1.4.10.tgz",
"integrity": "sha512-gNva8/6UAe8QYepIQH/jQ2qn91Qj0B9sYjMBBs3QOB8F2CXcKgLxQaJRP76sWVRQt+QU+8fAkCbCvjjMFu7Ycw=="
},
"tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",

View File

@ -13,6 +13,7 @@
"dependencies": {
"did-jwt": "^6.0.0",
"jose": "^4.6.0",
"readline-sync": "^1.4.10",
"web-did-resolver": "^2.0.14"
}
}
}

View File

@ -1,4 +1,4 @@
{
"DOMAIN": "chike.xyz",
"DOMAIN": "{GitHubUserName}.github.io",
"REPOSITORY": "did-web-on-gh-pages"
}

View File

@ -1,9 +1,23 @@
const jose = require('jose');
const fs = require('fs');
const readlineSync = require('readline-sync');
// Setting
const CONFIG = require('./config.json');
const { exit } = require('process');
// Validate Config
if (CONFIG.DOMAIN == '{GitHubUserName}.github.io') {
console.log(`ERROR: Domain in config.json is default ({GitHubUserName}.github.io). Please set your domain.`)
exit(1);
}
if (CONFIG.REPOSITORY == 'did-web-on-gh-pages') {
console.log(`WARN: Domain in config.json is default (did-web-on-gh-pages).`);
if (!readlineSync.keyInYN(`Is the repository name correct?`)) {
exit(1);
}
}
// Templates
const DID = `did:web:${CONFIG.DOMAIN}:${CONFIG.REPOSITORY}`;