Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

## [3.16.0] - 2026-10-09
### Added
- Added Id service credit calculator

## [3.15.6] - 2026-10-2

### Changed
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
"scripts": {
"serve": "vue-cli-service serve --mode production",
"dev": "vue-cli-service serve --mode staging",
"catalog:cache": "node scripts/cache-kyc-catalog.js",
"catalog:refresh": "node scripts/cache-kyc-catalog.js --refresh",
"prebuild": "npm run catalog:cache",
"setEnv": "cp .env.staging .env",
"build": "vue-cli-service build",
"prebuild-stage": "npm run catalog:cache",
"build-stage": "vue-cli-service build --mode staging",
"lint": "vue-cli-service lint",
"test:unit": "vue-cli-service test:unit",
Expand Down
57 changes: 57 additions & 0 deletions scripts/cache-kyc-catalog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
const fs = require('fs');
const https = require('https');
const path = require('path');

const catalogUrl = 'https://raw.githubusercontent.com/hypersign-protocol/hypersign-credits-middleware/refs/heads/ADR000/src/catalogs/catalog.kyc.json';
const catalogPath = path.resolve(__dirname, '../src/catalogs/catalog.kyc.json');
const shouldRefresh = process.argv.includes('--refresh');

function hasValidCache() {
if (!fs.existsSync(catalogPath)) return false;

try {
const catalog = JSON.parse(fs.readFileSync(catalogPath, 'utf8'));
return Array.isArray(catalog.routes) && catalog.routes.length > 0;
} catch (_) {
return false;
}
}

if (!shouldRefresh && hasValidCache()) {
console.log(`Using cached KYC credit catalog at ${catalogPath}`);
process.exit(0);
}

fs.mkdirSync(path.dirname(catalogPath), { recursive: true });

https.get(catalogUrl, response => {
if (response.statusCode >= 300 && response.statusCode < 400 && response.headers.location) {
console.error('The KYC catalog URL redirected. Update the pinned catalog URL before building.');
process.exit(1);
}

if (response.statusCode !== 200) {
console.error(`Unable to download KYC catalog: HTTP ${response.statusCode}`);
process.exit(1);
}

let body = '';
response.setEncoding('utf8');
response.on('data', chunk => { body += chunk; });
response.on('end', () => {
try {
const catalog = JSON.parse(body);
if (!Array.isArray(catalog.routes) || catalog.routes.length === 0) {
throw new Error('catalog does not contain routes');
}
fs.writeFileSync(catalogPath, `${JSON.stringify(catalog, null, 2)}\n`);
console.log(`Cached KYC credit catalog at ${catalogPath}`);
} catch (error) {
console.error(`Unable to cache KYC catalog: ${error.message}`);
process.exit(1);
}
});
}).on('error', error => {
console.error(`Unable to download KYC catalog: ${error.message}`);
process.exit(1);
});
Loading
Loading