UNPKG

workspace-integrations

Version:
28 lines (27 loc) • 1.18 kB
#!/usr/bin/env node "use strict"; /** * Script to decode and validate a Workspace Integration JWT from Control Hub */ Object.defineProperty(exports, "__esModule", { value: true }); const jwt_1 = require("./jwt"); const [, , userJwt, outputFormat] = process.argv; if (!userJwt) { console.log('USAGE: cli.js <jwt>'); console.log('or, for INI file format: cli.js <jwt> env'); process.exit(1); } async function decode(jwt, format) { const res = await (0, jwt_1.decodeAndVerify)(jwt); if (!res) { console.log('\nšŸ›‘ Not able to verify activation code (JWT)! Are you sure you copied the whole string?'); process.exit(1); } console.log('\nšŸŽ‰ JWT Successfully verified. Copy and paste the data below for connecting your integration:'); const { oauthUrl, appUrl, webexapisBaseUrl, refreshToken } = res; const config = format === 'env' ? 'OAUTH_URL=' + oauthUrl + '\nAPP_URL=' + appUrl + '\nWEBEXAPIS_BASE_URL=' + webexapisBaseUrl + '\nREFRESH_TOKEN=' + refreshToken : JSON.stringify({ oauthUrl, appUrl, webexapisBaseUrl, refreshToken }, null, 2); console.log('\n' + config + '\n'); } decode(userJwt, outputFormat);