@rockcarver/frodo-lib 0.18.0 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -4
- package/cjs/api/ManagedObjectApi.js +15 -9
- package/cjs/api/ManagedObjectApi.js.map +1 -1
- package/cjs/ops/AuthenticateOps.js +5 -4
- package/cjs/ops/AuthenticateOps.js.map +1 -1
- package/cjs/ops/ConnectionProfileOps.js +47 -16
- package/cjs/ops/ConnectionProfileOps.js.map +1 -1
- package/cjs/ops/InfoOps.js +2 -2
- package/cjs/ops/InfoOps.js.map +1 -1
- package/cjs/ops/ManagedObjectOps.js +2 -2
- package/cjs/ops/ManagedObjectOps.js.map +1 -1
- package/cjs/ops/cloud/ServiceAccountOps.js +11 -0
- package/cjs/ops/cloud/ServiceAccountOps.js.map +1 -1
- package/cjs/utils/SetupPollyForFrodoLib.js +63 -20
- package/cjs/utils/SetupPollyForFrodoLib.js.map +1 -1
- package/esm/api/ManagedObjectApi.mjs +10 -5
- package/esm/ops/AuthenticateOps.mjs +5 -4
- package/esm/ops/ConnectionProfileOps.mjs +48 -17
- package/esm/ops/InfoOps.mjs +2 -2
- package/esm/ops/ManagedObjectOps.mjs +2 -2
- package/esm/ops/cloud/ServiceAccountOps.mjs +5 -1
- package/esm/utils/SetupPollyForFrodoLib.mjs +64 -19
- package/mocks/github_584874290/recording.har +12 -12
- package/mocks/info_263456517/am_1076162899/recording.har +596 -0
- package/mocks/{environment_1072573434 → info_263456517/environment_1072573434}/recording.har +10 -10
- package/mocks/info_263456517/oauth2_393036114/recording.har +424 -0
- package/mocks/{am_1076162899 → journey_3464291987/list_217798785/am_1076162899}/recording.har +18667 -18667
- package/mocks/{oauth2_393036114 → journey_3464291987/list_217798785/oauth2_393036114}/recording.har +37 -37
- package/mocks/npmjs_1455397529/recording.har +15 -15
- package/package.json +1 -1
- package/types/api/ManagedObjectApi.d.ts +5 -3
- package/types/api/ManagedObjectApi.d.ts.map +1 -1
- package/types/ops/AuthenticateOps.d.ts.map +1 -1
- package/types/ops/ConnectionProfileOps.d.ts.map +1 -1
- package/types/ops/InfoOps.d.ts.map +1 -1
- package/types/ops/ManagedObjectOps.d.ts.map +1 -1
- package/types/ops/cloud/ServiceAccountOps.d.ts +3 -1
- package/types/ops/cloud/ServiceAccountOps.d.ts.map +1 -1
- package/types/utils/SetupPollyForFrodoLib.d.ts.map +1 -1
- package/mocks/openidm_3290118515/recording.har +0 -150
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectionProfileOps.js","names":["crypto","DataProtection","fileOptions","indentation","legacyProfileFilename","newProfileFilename","getConnectionProfilesPath","state","process","env","FRODO_CONNECTION_PROFILES_PATH_KEY","os","homedir","findConnectionProfiles","connectionProfiles","host","profiles","tenant","includes","foundProfile","push","listConnectionProfiles","long","filename","data","fs","readFileSync","connectionsData","JSON","parse","table","createTable","Object","keys","forEach","c","username","logApiKey","printMessage","toString","e","message","migrateFromLegacyProfile","legacyPath","existsSync","copyFileSync","renameSync","initConnectionProfiles","folderName","path","dirname","mkdirSync","recursive","writeFileSync","stringify","convert","conn","encodedPassword","encrypt","encodedLogApiSecret","encodedSvcacctJwk","getConnectionProfileByHost","length","p","password","decrypt","logApiSecret","authenticationService","authenticationHeaderOverrides","svcacctId","svcacctJwk","getConnectionProfile","getHost","saveConnectionProfile","verboseMessage","profile","statSync","found","setHost","isValidUrl","error","getUsername","getPassword","getLogApiKey","getLogApiSecret","getServiceAccountId","getServiceAccountJwk","getAuthenticationService","getAuthenticationHeaderOverrides","entries","orderedProfiles","sort","reduce","obj","key","saveJsonToFile","deleteConnectionProfile","stat","err","code","describeConnectionProfile","showSecrets","present","jwk","keyMap","createObjectTable","addNewServiceAccount","debugMessage","name","Date","getTime","description","scope","jwkPrivate","createJwkRsa","jwkPublic","getJwkRsaPublic","jwks","createJwks","sa","createServiceAccount","_id","setServiceAccountId","setServiceAccountJwk"],"sources":["ops/ConnectionProfileOps.ts"],"sourcesContent":["import fs from 'fs';\nimport os from 'os';\nimport path from 'path';\nimport * as state from '../shared/State';\nimport DataProtection from './utils/DataProtection';\nimport {\n createObjectTable,\n createTable,\n debugMessage,\n printMessage,\n verboseMessage,\n} from './utils/Console';\nimport { FRODO_CONNECTION_PROFILES_PATH_KEY } from '../storage/StaticStorage';\nimport { createJwkRsa, createJwks, getJwkRsaPublic, JwkRsa } from './JoseOps';\nimport { createServiceAccount } from './cloud/ServiceAccountOps';\nimport { ObjectSkeletonInterface } from '../api/ApiTypes';\nimport { saveJsonToFile } from './utils/ExportImportUtils';\nimport { isValidUrl } from './utils/OpsUtils';\n\nconst crypto = new DataProtection();\n\nconst fileOptions = {\n indentation: 4,\n};\n\nexport interface SecureConnectionProfileInterface {\n tenant: string;\n username?: string | null;\n encodedPassword?: string | null;\n logApiKey?: string | null;\n encodedLogApiSecret?: string | null;\n authenticationService?: string | null;\n authenticationHeaderOverrides?: Record<string, string>;\n svcacctId?: string | null;\n encodedSvcacctJwk?: string | null;\n svcacctName?: string | null;\n}\n\nexport interface ConnectionProfileInterface {\n tenant: string;\n username?: string | null;\n password?: string | null;\n logApiKey?: string | null;\n logApiSecret?: string | null;\n authenticationService?: string | null;\n authenticationHeaderOverrides?: Record<string, string>;\n svcacctId?: string | null;\n svcacctJwk?: JwkRsa;\n svcacctName?: string | null;\n}\n\nexport interface ConnectionsFileInterface {\n [key: string]: SecureConnectionProfileInterface;\n}\n\nconst legacyProfileFilename = '.frodorc';\nconst newProfileFilename = 'Connections.json';\n\n/**\n * Get connection profiles file name\n * @returns {String} connection profiles file name\n */\nexport function getConnectionProfilesPath(): string {\n return (\n state.getConnectionProfilesPath() ||\n process.env[FRODO_CONNECTION_PROFILES_PATH_KEY] ||\n `${os.homedir()}/.frodo/${newProfileFilename}`\n );\n}\n\n/**\n * Find connection profiles\n * @param {ConnectionsFileInterface} connectionProfiles connection profile object\n * @param {string} host host url or unique substring\n * @returns {SecureConnectionProfileInterface[]} Array of connection profiles\n */\nfunction findConnectionProfiles(\n connectionProfiles: ConnectionsFileInterface,\n host: string\n): SecureConnectionProfileInterface[] {\n const profiles: SecureConnectionProfileInterface[] = [];\n for (const tenant in connectionProfiles) {\n if (tenant.includes(host)) {\n const foundProfile = { ...connectionProfiles[tenant] };\n foundProfile.tenant = tenant;\n profiles.push(foundProfile);\n }\n }\n return profiles;\n}\n\n/**\n * List connection profiles\n * @param {boolean} long Long list format with details\n */\nexport function listConnectionProfiles(long = false) {\n const filename = getConnectionProfilesPath();\n try {\n const data = fs.readFileSync(filename, 'utf8');\n const connectionsData = JSON.parse(data);\n if (long) {\n const table = createTable(['Host', 'Username', 'Log API Key']);\n Object.keys(connectionsData).forEach((c) => {\n table.push([\n c,\n connectionsData[c].username,\n connectionsData[c].logApiKey,\n ]);\n });\n printMessage(table.toString(), 'data');\n } else {\n Object.keys(connectionsData).forEach((c) => {\n printMessage(`${c}`, 'data');\n });\n }\n printMessage(\n 'Any unique substring of a saved host can be used as the value for host parameter in all commands',\n 'info'\n );\n } catch (e) {\n printMessage(`No connections found in ${filename} (${e.message})`, 'error');\n }\n}\n\n/**\n * Migrate from .frodorc to Connections.json\n */\nfunction migrateFromLegacyProfile() {\n const legacyPath = `${os.homedir()}/.frodo/${legacyProfileFilename}`;\n if (fs.existsSync(legacyPath)) {\n fs.copyFileSync(legacyPath, `${os.homedir()}/.frodo/${newProfileFilename}`);\n // for now, just add a \"deprecated\" suffix. May delete the old file\n // in a future release\n fs.renameSync(legacyPath, `${legacyPath}.deprecated`);\n }\n}\n\n/**\n * Initialize connection profiles\n *\n * This method is called from app.ts and runs before any of the message handlers are registered.\n * Therefore none of the Console message functions will produce any output.\n */\nexport async function initConnectionProfiles() {\n // create connections.json file if it doesn't exist\n const filename = getConnectionProfilesPath();\n const folderName = path.dirname(filename);\n if (!fs.existsSync(folderName)) {\n fs.mkdirSync(folderName, { recursive: true });\n if (!fs.existsSync(filename)) {\n fs.writeFileSync(\n filename,\n JSON.stringify({}, null, fileOptions.indentation)\n );\n }\n }\n // encrypt the password and logApiSecret from clear text to aes-256-GCM\n else {\n migrateFromLegacyProfile();\n const data = fs.readFileSync(filename, 'utf8');\n const connectionsData: ConnectionsFileInterface = JSON.parse(data);\n let convert = false;\n for (const conn of Object.keys(connectionsData)) {\n if (connectionsData[conn]['password']) {\n convert = true;\n connectionsData[conn].encodedPassword = await crypto.encrypt(\n connectionsData[conn]['password']\n );\n delete connectionsData[conn]['password'];\n }\n if (connectionsData[conn]['logApiSecret']) {\n convert = true;\n connectionsData[conn].encodedLogApiSecret = await crypto.encrypt(\n connectionsData[conn]['logApiSecret']\n );\n delete connectionsData[conn]['logApiSecret'];\n }\n if (connectionsData[conn]['svcacctJwk']) {\n convert = true;\n connectionsData[conn].encodedSvcacctJwk = await crypto.encrypt(\n connectionsData[conn]['svcacctJwk']\n );\n delete connectionsData[conn]['svcacctJwk'];\n }\n }\n if (convert) {\n fs.writeFileSync(\n filename,\n JSON.stringify(connectionsData, null, fileOptions.indentation)\n );\n }\n }\n}\n\n/**\n * Get connection profile by host\n * @param {String} host host tenant host url or unique substring\n * @returns {Object} connection profile or null\n */\nexport async function getConnectionProfileByHost(\n host: string\n): Promise<ConnectionProfileInterface> {\n try {\n const filename = getConnectionProfilesPath();\n const connectionsData = JSON.parse(fs.readFileSync(filename, 'utf8'));\n const profiles = findConnectionProfiles(connectionsData, host);\n if (profiles.length == 0) {\n printMessage(\n `Profile for ${host} not found. Please specify credentials on command line`,\n 'error'\n );\n return null;\n }\n if (profiles.length > 1) {\n printMessage(`Multiple matching profiles found.`, 'error');\n profiles.forEach((p) => {\n printMessage(`- ${p.tenant}`, 'error');\n });\n printMessage(`Please specify a unique sub-string`, 'error');\n return null;\n }\n return {\n tenant: profiles[0].tenant,\n username: profiles[0].username ? profiles[0].username : null,\n password: profiles[0].encodedPassword\n ? await crypto.decrypt(profiles[0].encodedPassword)\n : null,\n logApiKey: profiles[0].logApiKey ? profiles[0].logApiKey : null,\n logApiSecret: profiles[0].encodedLogApiSecret\n ? await crypto.decrypt(profiles[0].encodedLogApiSecret)\n : null,\n authenticationService: profiles[0].authenticationService\n ? profiles[0].authenticationService\n : null,\n authenticationHeaderOverrides: profiles[0].authenticationHeaderOverrides\n ? profiles[0].authenticationHeaderOverrides\n : {},\n svcacctId: profiles[0].svcacctId ? profiles[0].svcacctId : null,\n svcacctJwk: profiles[0].encodedSvcacctJwk\n ? await crypto.decrypt(profiles[0].encodedSvcacctJwk)\n : null,\n };\n } catch (e) {\n printMessage(\n `Can not read saved connection info, please specify credentials on command line: ${e}`,\n 'error'\n );\n return null;\n }\n}\n\n/**\n * Get connection profile\n * @returns {Object} connection profile or null\n */\nexport async function getConnectionProfile(): Promise<ConnectionProfileInterface> {\n return getConnectionProfileByHost(state.getHost());\n}\n\n/**\n * Save connection profile\n * @param {string} host host url for new profiles or unique substring for existing profiles\n * @returns {Promise<boolean>} true if the operation succeeded, false otherwise\n */\nexport async function saveConnectionProfile(host: string): Promise<boolean> {\n const filename = getConnectionProfilesPath();\n verboseMessage(`Saving connection profile in ${filename}`);\n let profiles: ConnectionsFileInterface = {};\n let profile: SecureConnectionProfileInterface = { tenant: '' };\n try {\n fs.statSync(filename);\n const data = fs.readFileSync(filename, 'utf8');\n profiles = JSON.parse(data);\n\n // find tenant\n const found = findConnectionProfiles(profiles, host);\n\n // replace tenant in session with real tenant url if necessary\n if (found.length === 1) {\n profile = found[0];\n state.setHost(profile.tenant);\n verboseMessage(`Existing profile: ${profile.tenant}`);\n }\n\n // connection profile not found, validate host is a real URL\n if (found.length === 0) {\n if (isValidUrl(host)) {\n state.setHost(host);\n verboseMessage(`New profile: ${host}`);\n } else {\n printMessage(\n `No existing profile found matching '${host}'. Provide a valid URL as the host argument to create a new profile.`,\n 'error'\n );\n return false;\n }\n }\n } catch (error) {\n verboseMessage(`New profiles file ${filename} with new profile ${host}`);\n }\n\n // user account\n if (state.getUsername()) profile.username = state.getUsername();\n if (state.getPassword())\n profile.encodedPassword = await crypto.encrypt(state.getPassword());\n\n // log API\n if (state.getLogApiKey()) profile.logApiKey = state.getLogApiKey();\n if (state.getLogApiSecret())\n profile.encodedLogApiSecret = await crypto.encrypt(state.getLogApiSecret());\n\n // service account\n if (state.getServiceAccountId())\n profile.svcacctId = state.getServiceAccountId();\n if (state.getServiceAccountJwk())\n profile.encodedSvcacctJwk = await crypto.encrypt(\n state.getServiceAccountJwk()\n );\n\n // advanced settings\n if (state.getAuthenticationService()) {\n profile.authenticationService = state.getAuthenticationService();\n printMessage(\n 'Advanced setting: Authentication Service: ' +\n state.getAuthenticationService(),\n 'info'\n );\n }\n if (\n state.getAuthenticationHeaderOverrides() &&\n Object.entries(state.getAuthenticationHeaderOverrides()).length\n ) {\n profile.authenticationHeaderOverrides =\n state.getAuthenticationHeaderOverrides();\n printMessage('Advanced setting: Authentication Header Overrides: ', 'info');\n printMessage(state.getAuthenticationHeaderOverrides(), 'info');\n }\n\n // remove the helper key 'tenant'\n delete profile.tenant;\n\n // update profiles\n profiles[state.getHost()] = profile;\n\n // sort profiles\n const orderedProfiles = Object.keys(profiles)\n .sort()\n .reduce((obj, key) => {\n obj[key] = profiles[key];\n return obj;\n }, {});\n\n // save profiles\n saveJsonToFile(orderedProfiles, filename, false);\n verboseMessage(`Saved connection profile ${state.getHost()} in ${filename}`);\n return true;\n}\n\n/**\n * Delete connection profile\n * @param {String} host host tenant host url or unique substring\n */\nexport function deleteConnectionProfile(host) {\n const filename = getConnectionProfilesPath();\n let connectionsData: ConnectionsFileInterface = {};\n fs.stat(filename, (err) => {\n if (err == null) {\n const data = fs.readFileSync(filename, 'utf8');\n connectionsData = JSON.parse(data);\n const profiles = findConnectionProfiles(connectionsData, host);\n if (profiles.length == 1) {\n delete connectionsData[profiles[0].tenant];\n fs.writeFileSync(filename, JSON.stringify(connectionsData, null, 2));\n printMessage(`Deleted connection profile ${profiles[0].tenant}`);\n } else {\n if (profiles.length > 1) {\n printMessage(`Multiple matching profiles found.`, 'error');\n profiles.forEach((p) => {\n printMessage(`- ${p.tenant}`, 'error');\n });\n printMessage(`Please specify a unique sub-string`, 'error');\n return null;\n } else {\n printMessage(`No connection profile ${host} found`);\n }\n }\n } else if (err.code === 'ENOENT') {\n printMessage(`Connection profile file ${filename} not found`);\n } else {\n printMessage(\n `Error in deleting connection profile: ${err.code}`,\n 'error'\n );\n }\n });\n}\n\n/**\n * Describe connection profile\n * @param {string} host Host URL or unique substring\n * @param {boolean} showSecrets Whether secrets should be shown in clear text or not\n */\nexport async function describeConnectionProfile(\n host: string,\n showSecrets: boolean\n) {\n const profile = await getConnectionProfileByHost(host);\n if (profile) {\n const present = '[present]';\n const jwk = profile.svcacctJwk;\n if (!showSecrets) {\n if (profile.password) profile.password = present;\n if (profile.logApiSecret) profile.logApiSecret = present;\n if (profile.svcacctJwk) (profile as unknown)['svcacctJwk'] = present;\n }\n if (!profile.username) {\n delete profile.username;\n delete profile.password;\n }\n if (!profile.logApiKey) {\n delete profile.logApiKey;\n delete profile.logApiSecret;\n }\n if (!profile.svcacctId) {\n delete profile.svcacctId;\n delete profile.svcacctJwk;\n }\n if (showSecrets && jwk) {\n (profile as unknown)['svcacctJwk'] = 'see below';\n }\n if (!profile.authenticationService) {\n delete profile.authenticationService;\n }\n const keyMap = {\n tenant: 'Host',\n username: 'Username',\n password: 'Password',\n logApiKey: 'Log API Key',\n logApiSecret: 'Log API Secret',\n authenticationService: 'Authentication Service',\n authenticationHeaderOverrides: 'Authentication Header Overrides',\n svcacctId: 'Service Account Id',\n svcacctJwk: 'Service Account JWK',\n };\n const table = createObjectTable(profile, keyMap);\n printMessage(table.toString(), 'data');\n if (showSecrets && jwk) {\n printMessage(jwk, 'data');\n }\n } else {\n printMessage(`No connection profile ${host} found`);\n }\n}\n\n/**\n * Create a new service account using auto-generated parameters\n * @returns {Promise<ObjectSkeletonInterface>} A promise resolving to a service account object\n */\nexport async function addNewServiceAccount(): Promise<ObjectSkeletonInterface> {\n debugMessage(`ConnectionProfileOps.addNewServiceAccount: start`);\n const name = `Frodo-SA-${new Date().getTime()}`;\n debugMessage(`ConnectionProfileOps.addNewServiceAccount: name=${name}...`);\n const description = `${state.getUsername()}'s Frodo Service Account`;\n const scope = ['fr:am:*', 'fr:idm:*', 'fr:idc:esv:*'];\n const jwkPrivate = await createJwkRsa();\n const jwkPublic = await getJwkRsaPublic(jwkPrivate);\n const jwks = createJwks(jwkPublic);\n const sa = await createServiceAccount(\n name,\n description,\n 'Active',\n scope,\n jwks\n );\n debugMessage(`ConnectionProfileOps.addNewServiceAccount: id=${sa._id}`);\n state.setServiceAccountId(sa._id);\n state.setServiceAccountJwk(jwkPrivate);\n debugMessage(`ConnectionProfileOps.addNewServiceAccount: end`);\n return sa;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AAEA;AACA;AAA8C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAE9C,IAAMA,MAAM,GAAG,IAAIC,uBAAc,EAAE;AAEnC,IAAMC,WAAW,GAAG;EAClBC,WAAW,EAAE;AACf,CAAC;AAgCD,IAAMC,qBAAqB,GAAG,UAAU;AACxC,IAAMC,kBAAkB,GAAG,kBAAkB;;AAE7C;AACA;AACA;AACA;AACO,SAASC,yBAAyB,GAAW;EAClD,OACEC,KAAK,CAACD,yBAAyB,EAAE,IACjCE,OAAO,CAACC,GAAG,CAACC,iDAAkC,CAAC,cAC5CC,WAAE,CAACC,OAAO,EAAE,qBAAWP,kBAAkB,CAAE;AAElD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASQ,sBAAsB,CAC7BC,kBAA4C,EAC5CC,IAAY,EACwB;EACpC,IAAMC,QAA4C,GAAG,EAAE;EACvD,KAAK,IAAMC,MAAM,IAAIH,kBAAkB,EAAE;IACvC,IAAIG,MAAM,CAACC,QAAQ,CAACH,IAAI,CAAC,EAAE;MACzB,IAAMI,YAAY,qBAAQL,kBAAkB,CAACG,MAAM,CAAC,CAAE;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CAAC;IAClC,IAAMI,EAAE,SAAS,IAAAC,uCAAoB,EACnCZ,IAAI,EACJG,WAAW,EACX,QAAQ,EACRC,KAAK,EACLK,IAAI,CACL;IACD,IAAAV,qBAAY,0DAAkDY,EAAE,CAACE,GAAG,EAAG;IACvElH,KAAK,CAACmH,mBAAmB,CAACH,EAAE,CAACE,GAAG,CAAC;IACjClH,KAAK,CAACoH,oBAAoB,CAACV,UAAU,CAAC;IACtC,IAAAN,qBAAY,mDAAkD;IAC9D,OAAOY,EAAE;EACX,CAAC;EAAA;AAAA"}
|
|
1
|
+
{"version":3,"file":"ConnectionProfileOps.js","names":["crypto","DataProtection","fileOptions","indentation","legacyProfileFilename","newProfileFilename","getConnectionProfilesPath","state","process","env","FRODO_CONNECTION_PROFILES_PATH_KEY","os","homedir","findConnectionProfiles","connectionProfiles","host","profiles","tenant","includes","foundProfile","push","listConnectionProfiles","long","filename","data","fs","readFileSync","connectionsData","JSON","parse","Object","keys","length","printMessage","table","createTable","forEach","c","svcacctName","svcacctId","username","logApiKey","toString","e","message","migrateFromLegacyProfile","legacyPath","newPath","existsSync","writeFileSync","stringify","copyFileSync","renameSync","initConnectionProfiles","folderName","path","dirname","mkdirSync","recursive","convert","conn","encodedPassword","encrypt","encodedLogApiSecret","encodedSvcacctJwk","getConnectionProfileByHost","p","password","decrypt","logApiSecret","authenticationService","authenticationHeaderOverrides","svcacctJwk","getConnectionProfile","getHost","saveConnectionProfile","debugMessage","profile","statSync","found","setHost","verboseMessage","isValidUrl","error","getUsername","getPassword","getLogApiKey","getLogApiSecret","getServiceAccountId","getServiceAccount","name","getServiceAccountJwk","getAuthenticationService","getAuthenticationHeaderOverrides","entries","orderedProfiles","sort","reduce","obj","key","saveJsonToFile","deleteConnectionProfile","stat","err","code","describeConnectionProfile","showSecrets","present","jwk","keyMap","createObjectTable","addNewServiceAccount","Date","getTime","description","scope","jwkPrivate","createJwkRsa","jwkPublic","getJwkRsaPublic","jwks","createJwks","sa","createServiceAccount","_id","setServiceAccountId","setServiceAccountJwk"],"sources":["ops/ConnectionProfileOps.ts"],"sourcesContent":["import fs from 'fs';\nimport os from 'os';\nimport path from 'path';\nimport * as state from '../shared/State';\nimport DataProtection from './utils/DataProtection';\nimport {\n createObjectTable,\n createTable,\n debugMessage,\n printMessage,\n verboseMessage,\n} from './utils/Console';\nimport { FRODO_CONNECTION_PROFILES_PATH_KEY } from '../storage/StaticStorage';\nimport { createJwkRsa, createJwks, getJwkRsaPublic, JwkRsa } from './JoseOps';\nimport {\n createServiceAccount,\n getServiceAccount,\n} from './cloud/ServiceAccountOps';\nimport { ObjectSkeletonInterface } from '../api/ApiTypes';\nimport { saveJsonToFile } from './utils/ExportImportUtils';\nimport { isValidUrl } from './utils/OpsUtils';\n\nconst crypto = new DataProtection();\n\nconst fileOptions = {\n indentation: 4,\n};\n\nexport interface SecureConnectionProfileInterface {\n tenant: string;\n username?: string | null;\n encodedPassword?: string | null;\n logApiKey?: string | null;\n encodedLogApiSecret?: string | null;\n authenticationService?: string | null;\n authenticationHeaderOverrides?: Record<string, string>;\n svcacctId?: string | null;\n encodedSvcacctJwk?: string | null;\n svcacctName?: string | null;\n}\n\nexport interface ConnectionProfileInterface {\n tenant: string;\n username?: string | null;\n password?: string | null;\n logApiKey?: string | null;\n logApiSecret?: string | null;\n authenticationService?: string | null;\n authenticationHeaderOverrides?: Record<string, string>;\n svcacctId?: string | null;\n svcacctJwk?: JwkRsa;\n svcacctName?: string | null;\n}\n\nexport interface ConnectionsFileInterface {\n [key: string]: SecureConnectionProfileInterface;\n}\n\nconst legacyProfileFilename = '.frodorc';\nconst newProfileFilename = 'Connections.json';\n\n/**\n * Get connection profiles file name\n * @returns {String} connection profiles file name\n */\nexport function getConnectionProfilesPath(): string {\n return (\n state.getConnectionProfilesPath() ||\n process.env[FRODO_CONNECTION_PROFILES_PATH_KEY] ||\n `${os.homedir()}/.frodo/${newProfileFilename}`\n );\n}\n\n/**\n * Find connection profiles\n * @param {ConnectionsFileInterface} connectionProfiles connection profile object\n * @param {string} host host url or unique substring\n * @returns {SecureConnectionProfileInterface[]} Array of connection profiles\n */\nfunction findConnectionProfiles(\n connectionProfiles: ConnectionsFileInterface,\n host: string\n): SecureConnectionProfileInterface[] {\n const profiles: SecureConnectionProfileInterface[] = [];\n for (const tenant in connectionProfiles) {\n if (tenant.includes(host)) {\n const foundProfile = { ...connectionProfiles[tenant] };\n foundProfile.tenant = tenant;\n profiles.push(foundProfile);\n }\n }\n return profiles;\n}\n\n/**\n * List connection profiles\n * @param {boolean} long Long list format with details\n */\nexport function listConnectionProfiles(long = false) {\n const filename = getConnectionProfilesPath();\n try {\n const data = fs.readFileSync(filename, 'utf8');\n const connectionsData = JSON.parse(data);\n if (Object.keys(connectionsData).length < 1) {\n printMessage(`No connections defined yet in ${filename}`, 'info');\n } else {\n if (long) {\n const table = createTable([\n 'Host',\n 'Service Account',\n 'Username',\n 'Log API Key',\n ]);\n Object.keys(connectionsData).forEach((c) => {\n table.push([\n c,\n connectionsData[c].svcacctName || connectionsData[c].svcacctId,\n connectionsData[c].username,\n connectionsData[c].logApiKey,\n ]);\n });\n printMessage(table.toString(), 'data');\n } else {\n Object.keys(connectionsData).forEach((c) => {\n printMessage(`${c}`, 'data');\n });\n // getUniqueNames(5, Object.keys(connectionsData));\n }\n printMessage(\n 'Any unique substring of a saved host can be used as the value for host parameter in all commands',\n 'info'\n );\n }\n } catch (e) {\n printMessage(`No connections found in ${filename} (${e.message})`, 'error');\n }\n}\n\n/**\n * Migrate from .frodorc to Connections.json\n */\nfunction migrateFromLegacyProfile() {\n const legacyPath = `${os.homedir()}/.frodo/${legacyProfileFilename}`;\n const newPath = `${os.homedir()}/.frodo/${newProfileFilename}`;\n if (!fs.existsSync(legacyPath) && !fs.existsSync(newPath)) {\n // no connections file (old or new), create empty new one\n fs.writeFileSync(\n newPath,\n JSON.stringify({}, null, fileOptions.indentation)\n );\n } else if (fs.existsSync(legacyPath) && !fs.existsSync(newPath)) {\n // old exists, new one does not - so copy old to new one\n fs.copyFileSync(legacyPath, newPath);\n // for now, just add a \"deprecated\" suffix. May delete the old file\n // in a future release\n fs.renameSync(legacyPath, `${legacyPath}.deprecated`);\n }\n // in other cases, where\n // (both old and new exist) OR (only new one exists) don't do anything\n}\n\n/**\n * Initialize connection profiles\n *\n * This method is called from app.ts and runs before any of the message handlers are registered.\n * Therefore none of the Console message functions will produce any output.\n */\nexport async function initConnectionProfiles() {\n // create connections.json file if it doesn't exist\n const filename = getConnectionProfilesPath();\n const folderName = path.dirname(filename);\n if (!fs.existsSync(folderName)) {\n fs.mkdirSync(folderName, { recursive: true });\n if (!fs.existsSync(filename)) {\n fs.writeFileSync(\n filename,\n JSON.stringify({}, null, fileOptions.indentation)\n );\n }\n }\n // encrypt the password and logApiSecret from clear text to aes-256-GCM\n else {\n migrateFromLegacyProfile();\n const data = fs.readFileSync(filename, 'utf8');\n const connectionsData: ConnectionsFileInterface = JSON.parse(data);\n let convert = false;\n for (const conn of Object.keys(connectionsData)) {\n if (connectionsData[conn]['password']) {\n convert = true;\n connectionsData[conn].encodedPassword = await crypto.encrypt(\n connectionsData[conn]['password']\n );\n delete connectionsData[conn]['password'];\n }\n if (connectionsData[conn]['logApiSecret']) {\n convert = true;\n connectionsData[conn].encodedLogApiSecret = await crypto.encrypt(\n connectionsData[conn]['logApiSecret']\n );\n delete connectionsData[conn]['logApiSecret'];\n }\n if (connectionsData[conn]['svcacctJwk']) {\n convert = true;\n connectionsData[conn].encodedSvcacctJwk = await crypto.encrypt(\n connectionsData[conn]['svcacctJwk']\n );\n delete connectionsData[conn]['svcacctJwk'];\n }\n }\n if (convert) {\n fs.writeFileSync(\n filename,\n JSON.stringify(connectionsData, null, fileOptions.indentation)\n );\n }\n }\n}\n\n/**\n * Get connection profile by host\n * @param {String} host host tenant host url or unique substring\n * @returns {Object} connection profile or null\n */\nexport async function getConnectionProfileByHost(\n host: string\n): Promise<ConnectionProfileInterface> {\n try {\n const filename = getConnectionProfilesPath();\n const connectionsData = JSON.parse(fs.readFileSync(filename, 'utf8'));\n const profiles = findConnectionProfiles(connectionsData, host);\n if (profiles.length == 0) {\n printMessage(\n `Profile for ${host} not found. Please specify credentials on command line`,\n 'error'\n );\n return null;\n }\n if (profiles.length > 1) {\n printMessage(`Multiple matching profiles found.`, 'error');\n profiles.forEach((p) => {\n printMessage(`- ${p.tenant}`, 'error');\n });\n printMessage(`Please specify a unique sub-string`, 'error');\n return null;\n }\n return {\n tenant: profiles[0].tenant,\n username: profiles[0].username ? profiles[0].username : null,\n password: profiles[0].encodedPassword\n ? await crypto.decrypt(profiles[0].encodedPassword)\n : null,\n logApiKey: profiles[0].logApiKey ? profiles[0].logApiKey : null,\n logApiSecret: profiles[0].encodedLogApiSecret\n ? await crypto.decrypt(profiles[0].encodedLogApiSecret)\n : null,\n authenticationService: profiles[0].authenticationService\n ? profiles[0].authenticationService\n : null,\n authenticationHeaderOverrides: profiles[0].authenticationHeaderOverrides\n ? profiles[0].authenticationHeaderOverrides\n : {},\n svcacctName: profiles[0].svcacctName ? profiles[0].svcacctName : null,\n svcacctId: profiles[0].svcacctId ? profiles[0].svcacctId : null,\n svcacctJwk: profiles[0].encodedSvcacctJwk\n ? await crypto.decrypt(profiles[0].encodedSvcacctJwk)\n : null,\n };\n } catch (e) {\n printMessage(\n `Can not read saved connection info, please specify credentials on command line: ${e}`,\n 'error'\n );\n return null;\n }\n}\n\n/**\n * Get connection profile\n * @returns {Object} connection profile or null\n */\nexport async function getConnectionProfile(): Promise<ConnectionProfileInterface> {\n return getConnectionProfileByHost(state.getHost());\n}\n\n/**\n * Save connection profile\n * @param {string} host host url for new profiles or unique substring for existing profiles\n * @returns {Promise<boolean>} true if the operation succeeded, false otherwise\n */\nexport async function saveConnectionProfile(host: string): Promise<boolean> {\n debugMessage(`ConnectionProfileOps.saveConnectionProfile: start`);\n const filename = getConnectionProfilesPath();\n debugMessage(`Saving connection profile in ${filename}`);\n let profiles: ConnectionsFileInterface = {};\n let profile: SecureConnectionProfileInterface = { tenant: '' };\n try {\n fs.statSync(filename);\n const data = fs.readFileSync(filename, 'utf8');\n profiles = JSON.parse(data);\n\n // find tenant\n const found = findConnectionProfiles(profiles, host);\n\n // replace tenant in session with real tenant url if necessary\n if (found.length === 1) {\n profile = found[0];\n state.setHost(profile.tenant);\n verboseMessage(`Existing profile: ${profile.tenant}`);\n debugMessage(profile);\n }\n\n // connection profile not found, validate host is a real URL\n if (found.length === 0) {\n if (isValidUrl(host)) {\n state.setHost(host);\n debugMessage(`New profile: ${host}`);\n } else {\n printMessage(\n `No existing profile found matching '${host}'. Provide a valid URL as the host argument to create a new profile.`,\n 'error'\n );\n debugMessage(`ConnectionProfileOps.saveConnectionProfile: end [false]`);\n return false;\n }\n }\n } catch (error) {\n debugMessage(`New profiles file ${filename} with new profile ${host}`);\n }\n\n // user account\n if (state.getUsername()) profile.username = state.getUsername();\n if (state.getPassword())\n profile.encodedPassword = await crypto.encrypt(state.getPassword());\n\n // log API\n if (state.getLogApiKey()) profile.logApiKey = state.getLogApiKey();\n if (state.getLogApiSecret())\n profile.encodedLogApiSecret = await crypto.encrypt(state.getLogApiSecret());\n\n // service account\n if (state.getServiceAccountId()) {\n profile.svcacctId = state.getServiceAccountId();\n profile.svcacctName = (\n await getServiceAccount(state.getServiceAccountId())\n ).name;\n }\n if (state.getServiceAccountJwk())\n profile.encodedSvcacctJwk = await crypto.encrypt(\n state.getServiceAccountJwk()\n );\n // update existing service account profile\n if (profile.svcacctId && !profile.svcacctName) {\n profile.svcacctName = (await getServiceAccount(profile.svcacctId)).name;\n debugMessage(\n `ConnectionProfileOps.saveConnectionProfile: added missing service account name`\n );\n }\n\n // advanced settings\n if (state.getAuthenticationService()) {\n profile.authenticationService = state.getAuthenticationService();\n printMessage(\n 'Advanced setting: Authentication Service: ' +\n state.getAuthenticationService(),\n 'info'\n );\n }\n if (\n state.getAuthenticationHeaderOverrides() &&\n Object.entries(state.getAuthenticationHeaderOverrides()).length\n ) {\n profile.authenticationHeaderOverrides =\n state.getAuthenticationHeaderOverrides();\n printMessage('Advanced setting: Authentication Header Overrides: ', 'info');\n printMessage(state.getAuthenticationHeaderOverrides(), 'info');\n }\n\n // remove the helper key 'tenant'\n delete profile.tenant;\n\n // update profiles\n profiles[state.getHost()] = profile;\n\n // sort profiles\n const orderedProfiles = Object.keys(profiles)\n .sort()\n .reduce((obj, key) => {\n obj[key] = profiles[key];\n return obj;\n }, {});\n\n // save profiles\n saveJsonToFile(orderedProfiles, filename, false);\n verboseMessage(`Saved connection profile ${state.getHost()} in ${filename}`);\n debugMessage(`ConnectionProfileOps.saveConnectionProfile: end [true]`);\n return true;\n}\n\n/**\n * Delete connection profile\n * @param {String} host host tenant host url or unique substring\n */\nexport function deleteConnectionProfile(host) {\n const filename = getConnectionProfilesPath();\n let connectionsData: ConnectionsFileInterface = {};\n fs.stat(filename, (err) => {\n if (err == null) {\n const data = fs.readFileSync(filename, 'utf8');\n connectionsData = JSON.parse(data);\n const profiles = findConnectionProfiles(connectionsData, host);\n if (profiles.length == 1) {\n delete connectionsData[profiles[0].tenant];\n fs.writeFileSync(filename, JSON.stringify(connectionsData, null, 2));\n printMessage(`Deleted connection profile ${profiles[0].tenant}`);\n } else {\n if (profiles.length > 1) {\n printMessage(`Multiple matching profiles found.`, 'error');\n profiles.forEach((p) => {\n printMessage(`- ${p.tenant}`, 'error');\n });\n printMessage(`Please specify a unique sub-string`, 'error');\n return null;\n } else {\n printMessage(`No connection profile ${host} found`);\n }\n }\n } else if (err.code === 'ENOENT') {\n printMessage(`Connection profile file ${filename} not found`);\n } else {\n printMessage(\n `Error in deleting connection profile: ${err.code}`,\n 'error'\n );\n }\n });\n}\n\n/**\n * Describe connection profile\n * @param {string} host Host URL or unique substring\n * @param {boolean} showSecrets Whether secrets should be shown in clear text or not\n */\nexport async function describeConnectionProfile(\n host: string,\n showSecrets: boolean\n) {\n debugMessage(`ConnectionProfileOps.describeConnectionProfile: start`);\n const profile = await getConnectionProfileByHost(host);\n if (profile) {\n debugMessage(profile);\n const present = '[present]';\n const jwk = profile.svcacctJwk;\n if (!showSecrets) {\n if (profile.password) profile.password = present;\n if (profile.logApiSecret) profile.logApiSecret = present;\n if (profile.svcacctJwk) (profile as unknown)['svcacctJwk'] = present;\n }\n if (!profile.username) {\n delete profile.username;\n delete profile.password;\n }\n if (!profile.logApiKey) {\n delete profile.logApiKey;\n delete profile.logApiSecret;\n }\n if (!profile.svcacctId) {\n delete profile.svcacctId;\n delete profile.svcacctJwk;\n delete profile.svcacctName;\n }\n if (showSecrets && jwk) {\n (profile as unknown)['svcacctJwk'] = 'see below';\n }\n if (!profile.authenticationService) {\n delete profile.authenticationService;\n }\n const keyMap = {\n tenant: 'Host',\n username: 'Username',\n password: 'Password',\n logApiKey: 'Log API Key',\n logApiSecret: 'Log API Secret',\n authenticationService: 'Authentication Service',\n authenticationHeaderOverrides: 'Authentication Header Overrides',\n svcacctName: 'Service Account Name',\n svcacctId: 'Service Account Id',\n svcacctJwk: 'Service Account JWK',\n };\n const table = createObjectTable(profile, keyMap);\n printMessage(table.toString(), 'data');\n if (showSecrets && jwk) {\n printMessage(jwk, 'data');\n }\n } else {\n printMessage(`No connection profile ${host} found`);\n }\n debugMessage(`ConnectionProfileOps.describeConnectionProfile: end`);\n}\n\n/**\n * Create a new service account using auto-generated parameters\n * @returns {Promise<ObjectSkeletonInterface>} A promise resolving to a service account object\n */\nexport async function addNewServiceAccount(): Promise<ObjectSkeletonInterface> {\n debugMessage(`ConnectionProfileOps.addNewServiceAccount: start`);\n const name = `Frodo-SA-${new Date().getTime()}`;\n debugMessage(`ConnectionProfileOps.addNewServiceAccount: name=${name}...`);\n const description = `${state.getUsername()}'s Frodo Service Account`;\n const scope = ['fr:am:*', 'fr:idm:*', 'fr:idc:esv:*'];\n const jwkPrivate = await createJwkRsa();\n const jwkPublic = await getJwkRsaPublic(jwkPrivate);\n const jwks = createJwks(jwkPublic);\n const sa = await createServiceAccount(\n name,\n description,\n 'Active',\n scope,\n jwks\n );\n debugMessage(`ConnectionProfileOps.addNewServiceAccount: id=${sa._id}`);\n state.setServiceAccountId(sa._id);\n state.setServiceAccountJwk(jwkPrivate);\n debugMessage(`ConnectionProfileOps.addNewServiceAccount: end`);\n return sa;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AAKA;AACA;AAA8C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAE9C,IAAMA,MAAM,GAAG,IAAIC,uBAAc,EAAE;AAEnC,IAAMC,WAAW,GAAG;EAClBC,WAAW,EAAE;AACf,CAAC;AAgCD,IAAMC,qBAAqB,GAAG,UAAU;AACxC,IAAMC,kBAAkB,GAAG,kBAAkB;;AAE7C;AACA;AACA;AACA;AACO,SAASC,yBAAyB,GAAW;EAClD,OACEC,KAAK,CAACD,yBAAyB,EAAE,IACjCE,OAAO,CAACC,GAAG,CAACC,iDAAkC,CAAC,cAC5CC,WAAE,CAACC,OAAO,EAAE,qBAAWP,kBAAkB,CAAE;AAElD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASQ,sBAAsB,CAC7BC,kBAA4C,EAC5CC,IAAY,EACwB;EACpC,IAAMC,QAA4C,GAAG,EAAE;EACvD,KAAK,IAAMC,MAAM,IAAIH,kBAAkB,EAAE;IACvC,IAAIG,MAAM,CAACC,QAAQ,CAACH,IAAI,CAAC,EAAE;MACzB,IAAMI,YAAY,qBAAQL,kBAAkB,CAACG,MAAM,CAAC,CAAE;MACtDE,YAAY,CAACF,MAAM,GAAGA,MAAM;MAC5BD,QAAQ,CAACI,IAAI,CAACD,YAAY,CAAC;IAC7B;EACF;EACA,OAAOH,QAAQ;AACjB;;AAEA;AACA;AACA;AACA;AACO,SAASK,sBAAsB,GAAe;EAAA,IAAdC,IAAI,uEAAG,KAAK;EACjD,IAAMC,QAAQ,GAAGjB,yBAAyB,EAAE;EAC5C,IAAI;IACF,IAAMkB,IAAI,GAAGC,WAAE,CAACC,YAAY,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AmB,CAACH,EAAE,CAACE,GAAG,CAAC;IACjCrH,KAAK,CAACuH,oBAAoB,CAACV,UAAU,CAAC;IACtC,IAAAxC,qBAAY,mDAAkD;IAC9D,OAAO8C,EAAE;EACX,CAAC;EAAA;AAAA"}
|
package/cjs/ops/InfoOps.js
CHANGED
|
@@ -8,8 +8,8 @@ var _EnvInfoApi = require("../api/cloud/EnvInfoApi");
|
|
|
8
8
|
var state = _interopRequireWildcard(require("../shared/State"));
|
|
9
9
|
var globalConfig = _interopRequireWildcard(require("../storage/StaticStorage"));
|
|
10
10
|
var _ServerInfoApi = require("../api/ServerInfoApi");
|
|
11
|
-
var _ManagedObjectApi = require("../api/ManagedObjectApi");
|
|
12
11
|
var _Console = require("./utils/Console");
|
|
12
|
+
var _ServiceAccountOps = require("./cloud/ServiceAccountOps");
|
|
13
13
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
14
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
15
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -61,7 +61,7 @@ function _getAuthenticatedSubject() {
|
|
|
61
61
|
_getAuthenticatedSubject = _asyncToGenerator(function* () {
|
|
62
62
|
var subjectString = "".concat(state.getUsername(), " (User)");
|
|
63
63
|
if (state.getUseBearerTokenForAmApis()) {
|
|
64
|
-
var name = (yield (0,
|
|
64
|
+
var name = (yield (0, _ServiceAccountOps.getServiceAccount)(state.getServiceAccountId())).name;
|
|
65
65
|
subjectString = "".concat(name, " [").concat(state.getServiceAccountId(), "] (Service Account)");
|
|
66
66
|
}
|
|
67
67
|
return subjectString;
|
package/cjs/ops/InfoOps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InfoOps.js","names":["getCloudInfo","info","getEnvInfo","message_box_html","message_box_title","message_variant","warning_message_html","placeholder_management_migration_date","error","printMessage","response","data","message","getAmVersion","versionObj","getServerVersionInfo","amVersion","getAuthenticatedSubject","subjectString","state","getUsername","getUseBearerTokenForAmApis","name","
|
|
1
|
+
{"version":3,"file":"InfoOps.js","names":["getCloudInfo","info","getEnvInfo","message_box_html","message_box_title","message_variant","warning_message_html","placeholder_management_migration_date","error","printMessage","response","data","message","getAmVersion","versionObj","getServerVersionInfo","amVersion","getAuthenticatedSubject","subjectString","state","getUsername","getUseBearerTokenForAmApis","name","getServiceAccount","getServiceAccountId","getInfo","host","getHost","authenticatedSubject","deploymentType","getDeploymentType","cookieName","getCookieName","sessionToken","getCookieValue","getBearerToken","bearerToken","globalConfig","CLOUD_DEPLOYMENT_TYPE_KEY"],"sources":["ops/InfoOps.ts"],"sourcesContent":["import { getEnvInfo } from '../api/cloud/EnvInfoApi';\nimport * as state from '../shared/State';\nimport { EnvInfoInterface } from '../api/cloud/EnvInfoApi';\nimport * as globalConfig from '../storage/StaticStorage';\nimport { getServerVersionInfo } from '../api/ServerInfoApi';\nimport { printMessage } from './utils/Console';\nimport { getServiceAccount } from './cloud/ServiceAccountOps';\n\nexport interface PlatformInfoInterface {\n host: string;\n authenticatedSubject: string;\n amVersion: string;\n cookieName: string;\n sessionToken: string;\n bearerToken?: string;\n deploymentType: string;\n}\n\nexport type PlatformInfo = PlatformInfoInterface & Partial<EnvInfoInterface>;\n\nasync function getCloudInfo(): Promise<Partial<EnvInfoInterface>> {\n let info: Partial<EnvInfoInterface> = {};\n try {\n info = await getEnvInfo();\n delete info.message_box_html;\n delete info.message_box_title;\n delete info.message_variant;\n delete info.warning_message_html;\n if (!info.placeholder_management_migration_date)\n delete info.placeholder_management_migration_date;\n } catch (error) {\n printMessage(error.response?.data, 'error');\n printMessage(`Error getting env info: ${error.message}`, 'error');\n }\n return info;\n}\n\nasync function getAmVersion(): Promise<string> {\n const versionObj = await getServerVersionInfo();\n const amVersion = `${versionObj['version']} Build ${versionObj['revision']} (${versionObj['date']})`;\n return amVersion;\n}\n\nasync function getAuthenticatedSubject(): Promise<string> {\n let subjectString = `${state.getUsername()} (User)`;\n if (state.getUseBearerTokenForAmApis()) {\n const name = (await getServiceAccount(state.getServiceAccountId())).name;\n subjectString = `${name} [${state.getServiceAccountId()}] (Service Account)`;\n }\n return subjectString;\n}\n\n/**\n * Get info about the platform instance\n * @returns {Promise<PlatformInfo>} a promise that resolves to a json blob with information about the instance and tokens\n */\nexport async function getInfo(): Promise<PlatformInfo> {\n const info: PlatformInfo = {\n host: state.getHost(),\n amVersion: await getAmVersion(),\n authenticatedSubject: await getAuthenticatedSubject(),\n deploymentType: state.getDeploymentType(),\n cookieName: state.getCookieName(),\n sessionToken: state.getCookieValue(),\n // only add bearerToken if we have it\n ...(state.getBearerToken() && { bearerToken: state.getBearerToken() }),\n // only add cloud env info if deployment type is cloud\n ...(state.getDeploymentType() === globalConfig.CLOUD_DEPLOYMENT_TYPE_KEY &&\n (await getCloudInfo())),\n };\n return info;\n}\n"],"mappings":";;;;;;AAAA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,aAAa,aAAMI,IAAI,eAAKH,KAAK,CAACK,mBAAmB,EAAE,wBAAqB;IAC9E;IACA,OAAON,aAAa;EACtB,CAAC;EAAA;AAAA;AAAA,SAMqBO,OAAO;EAAA;AAAA;AAAA;EAAA,6BAAtB,aAAgD;IACrD,IAAMxB,IAAkB;MACtByB,IAAI,EAAEP,KAAK,CAACQ,OAAO,EAAE;MACrBX,SAAS,QAAQH,YAAY,EAAE;MAC/Be,oBAAoB,QAAQX,uBAAuB,EAAE;MACrDY,cAAc,EAAEV,KAAK,CAACW,iBAAiB,EAAE;MACzCC,UAAU,EAAEZ,KAAK,CAACa,aAAa,EAAE;MACjCC,YAAY,EAAEd,KAAK,CAACe,cAAc;IAAE,GAEhCf,KAAK,CAACgB,cAAc,EAAE,IAAI;MAAEC,WAAW,EAAEjB,KAAK,CAACgB,cAAc;IAAG,CAAC,GAEjEhB,KAAK,CAACW,iBAAiB,EAAE,KAAKO,YAAY,CAACC,yBAAyB,WAC/DtC,YAAY,EAAE,CAAC,CACzB;IACD,OAAOC,IAAI;EACb,CAAC;EAAA;AAAA"}
|
|
@@ -26,7 +26,7 @@ function resolveUserName(_x, _x2) {
|
|
|
26
26
|
function _resolveUserName() {
|
|
27
27
|
_resolveUserName = _asyncToGenerator(function* (type, id) {
|
|
28
28
|
try {
|
|
29
|
-
return (yield (0, _ManagedObjectApi.getManagedObject)(type, id, ['userName'])).
|
|
29
|
+
return (yield (0, _ManagedObjectApi.getManagedObject)(type, id, ['userName'])).userName;
|
|
30
30
|
} catch (error) {
|
|
31
31
|
// eslint-disable-next-line no-empty
|
|
32
32
|
}
|
|
@@ -40,7 +40,7 @@ function resolveFullName(_x3, _x4) {
|
|
|
40
40
|
function _resolveFullName() {
|
|
41
41
|
_resolveFullName = _asyncToGenerator(function* (type, id) {
|
|
42
42
|
try {
|
|
43
|
-
var managedObject =
|
|
43
|
+
var managedObject = yield (0, _ManagedObjectApi.getManagedObject)(type, id, ['givenName', 'sn']);
|
|
44
44
|
return "".concat(managedObject.givenName, " ").concat(managedObject.sn);
|
|
45
45
|
} catch (error) {
|
|
46
46
|
// eslint-disable-next-line no-empty
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ManagedObjectOps.js","names":["resolveUserName","type","id","getManagedObject","
|
|
1
|
+
{"version":3,"file":"ManagedObjectOps.js","names":["resolveUserName","type","id","getManagedObject","userName","error","resolveFullName","managedObject","givenName","sn"],"sources":["ops/ManagedObjectOps.ts"],"sourcesContent":["import { getManagedObject } from '../api/ManagedObjectApi';\n\n/**\n * Resolve a managed object's uuid to a human readable username\n * @param {String} type managed object type, e.g. teammember or alpha_user\n * @param {String} id managed object _id\n * @returns {String} resolved username or uuid if any error occurs during reslution\n */\nexport async function resolveUserName(type, id) {\n try {\n return (await getManagedObject(type, id, ['userName'])).userName;\n } catch (error) {\n // eslint-disable-next-line no-empty\n }\n return id;\n}\n\n/**\n * Resolve a managed object's uuid to a human readable full name\n * @param {String} type managed object type, e.g. teammember or alpha_user\n * @param {String} id managed object _id\n * @returns {String} resolved full name or uuid if any error occurs during reslution\n */\nexport async function resolveFullName(type, id) {\n try {\n const managedObject = await getManagedObject(type, id, ['givenName', 'sn']);\n return `${managedObject.givenName} ${managedObject.sn}`;\n } catch (error) {\n // eslint-disable-next-line no-empty\n }\n return id;\n}\n"],"mappings":";;;;;;;AAAA;AAA2D;AAAA;AAE3D;AACA;AACA;AACA;AACA;AACA;AALA,SAMsBA,eAAe;EAAA;AAAA;AASrC;AACA;AACA;AACA;AACA;AACA;AALA;EAAA,qCATO,WAA+BC,IAAI,EAAEC,EAAE,EAAE;IAC9C,IAAI;MACF,OAAO,OAAO,IAAAC,kCAAgB,EAACF,IAAI,EAAEC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAEE,QAAQ;IAClE,CAAC,CAAC,OAAOC,KAAK,EAAE;MACd;IAAA;IAEF,OAAOH,EAAE;EACX,CAAC;EAAA;AAAA;AAAA,SAQqBI,eAAe;EAAA;AAAA;AAAA;EAAA,qCAA9B,WAA+BL,IAAI,EAAEC,EAAE,EAAE;IAC9C,IAAI;MACF,IAAMK,aAAa,SAAS,IAAAJ,kCAAgB,EAACF,IAAI,EAAEC,EAAE,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;MAC3E,iBAAUK,aAAa,CAACC,SAAS,cAAID,aAAa,CAACE,EAAE;IACvD,CAAC,CAAC,OAAOJ,KAAK,EAAE;MACd;IAAA;IAEF,OAAOH,EAAE;EACX,CAAC;EAAA;AAAA"}
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createServiceAccount = createServiceAccount;
|
|
7
|
+
exports.getServiceAccount = getServiceAccount;
|
|
7
8
|
exports.isServiceAccountsFeatureAvailable = isServiceAccountsFeatureAvailable;
|
|
8
9
|
var _ManagedObjectApi = require("../../api/ManagedObjectApi");
|
|
9
10
|
var _Console = require("../utils/Console");
|
|
@@ -64,4 +65,14 @@ function _createServiceAccount() {
|
|
|
64
65
|
});
|
|
65
66
|
return _createServiceAccount.apply(this, arguments);
|
|
66
67
|
}
|
|
68
|
+
function getServiceAccount(_x6) {
|
|
69
|
+
return _getServiceAccount.apply(this, arguments);
|
|
70
|
+
}
|
|
71
|
+
function _getServiceAccount() {
|
|
72
|
+
_getServiceAccount = _asyncToGenerator(function* (serviceAccountId) {
|
|
73
|
+
var serviceAccount = yield (0, _ManagedObjectApi.getManagedObject)(moType, serviceAccountId);
|
|
74
|
+
return serviceAccount;
|
|
75
|
+
});
|
|
76
|
+
return _getServiceAccount.apply(this, arguments);
|
|
77
|
+
}
|
|
67
78
|
//# sourceMappingURL=ServiceAccountOps.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceAccountOps.js","names":["moType","_featureAvailable","undefined","isServiceAccountsFeatureAvailable","debugMessage","hasFeature","createServiceAccount","name","description","accountStatus","scopes","jwks","payload","JSON","stringify","result","createManagedObject"],"sources":["ops/cloud/ServiceAccountOps.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"ServiceAccountOps.js","names":["moType","_featureAvailable","undefined","isServiceAccountsFeatureAvailable","debugMessage","hasFeature","createServiceAccount","name","description","accountStatus","scopes","jwks","payload","JSON","stringify","result","createManagedObject","getServiceAccount","serviceAccountId","serviceAccount","getManagedObject"],"sources":["ops/cloud/ServiceAccountOps.ts"],"sourcesContent":["import {\n createManagedObject,\n getManagedObject,\n} from '../../api/ManagedObjectApi';\nimport { JwksInterface } from '../JoseOps';\nimport { ObjectSkeletonInterface } from '../../api/ApiTypes';\nimport { debugMessage } from '../utils/Console';\nimport { hasFeature } from './FeatureOps';\n\nconst moType = 'svcacct';\n\nexport interface ServiceAccountPayloadInterface {\n name: string;\n description: string;\n accountStatus: 'Active' | 'Inactive';\n scopes: string[];\n jwks: string;\n}\n\nexport type ServiceAccount = ObjectSkeletonInterface &\n ServiceAccountPayloadInterface;\n\n/**\n * Global flag indicating if service accounts are available\n */\nlet _featureAvailable: boolean = undefined;\n\n/**\n * Check if service accounts are available\n * @returns {Promise<boolean>} true if service accounts are available, false otherwise\n */\nexport async function isServiceAccountsFeatureAvailable(): Promise<boolean> {\n debugMessage(`ServiceAccountOps.isServiceAccountsFeatureAvailable: start`);\n // only perform check once\n if (typeof _featureAvailable !== 'undefined') return _featureAvailable;\n\n _featureAvailable = await hasFeature('service-accounts');\n debugMessage(\n `ServiceAccountOps.isServiceAccountsFeatureAvailable: end, available=${_featureAvailable}`\n );\n return _featureAvailable;\n}\n\n/**\n * Create service account\n * @param {string} name Human-readable name of service account\n * @param {string} description Description of service account\n * @param {'Active' | 'Inactive'} accountStatus Service account status\n * @param {string[]} scopes Scopes.\n * @param {JwksInterface} jwks Java Web Key Set\n * @returns {Promise<ObjectSkeletonInterface>} A promise resolving to a service account object\n */\nexport async function createServiceAccount(\n name: string,\n description: string,\n accountStatus: 'Active' | 'Inactive',\n scopes: string[],\n jwks: JwksInterface\n): Promise<ObjectSkeletonInterface> {\n debugMessage(`ServiceAccountOps.createServiceAccount: start`);\n const payload: ServiceAccountPayloadInterface = {\n name,\n description,\n accountStatus,\n scopes,\n jwks: JSON.stringify(jwks),\n };\n debugMessage(`ServiceAccountOps: createServiceAccount: payload:`);\n debugMessage(payload);\n const result = await createManagedObject(moType, payload);\n debugMessage(`ServiceAccountOps.createServiceAccount: end`);\n return result;\n}\n\nexport async function getServiceAccount(serviceAccountId: string) {\n const serviceAccount = await getManagedObject(moType, serviceAccountId);\n return serviceAccount as ServiceAccount;\n}\n"],"mappings":";;;;;;;;AAAA;AAMA;AACA;AAA0C;AAAA;AAE1C,IAAMA,MAAM,GAAG,SAAS;AAaxB;AACA;AACA;AACA,IAAIC,iBAA0B,GAAGC,SAAS;;AAE1C;AACA;AACA;AACA;AAHA,SAIsBC,iCAAiC;EAAA;AAAA;AAYvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AARA;EAAA,uDAZO,aAAqE;IAC1E,IAAAC,qBAAY,+DAA8D;IAC1E;IACA,IAAI,OAAOH,iBAAiB,KAAK,WAAW,EAAE,OAAOA,iBAAiB;IAEtEA,iBAAiB,SAAS,IAAAI,sBAAU,EAAC,kBAAkB,CAAC;IACxD,IAAAD,qBAAY,gFAC6DH,iBAAiB,EACzF;IACD,OAAOA,iBAAiB;EAC1B,CAAC;EAAA;AAAA;AAAA,SAWqBK,oBAAoB;EAAA;AAAA;AAAA;EAAA,0CAAnC,WACLC,IAAY,EACZC,WAAmB,EACnBC,aAAoC,EACpCC,MAAgB,EAChBC,IAAmB,EACe;IAClC,IAAAP,qBAAY,kDAAiD;IAC7D,IAAMQ,OAAuC,GAAG;MAC9CL,IAAI;MACJC,WAAW;MACXC,aAAa;MACbC,MAAM;MACNC,IAAI,EAAEE,IAAI,CAACC,SAAS,CAACH,IAAI;IAC3B,CAAC;IACD,IAAAP,qBAAY,sDAAqD;IACjE,IAAAA,qBAAY,EAACQ,OAAO,CAAC;IACrB,IAAMG,MAAM,SAAS,IAAAC,qCAAmB,EAAChB,MAAM,EAAEY,OAAO,CAAC;IACzD,IAAAR,qBAAY,gDAA+C;IAC3D,OAAOW,MAAM;EACf,CAAC;EAAA;AAAA;AAAA,SAEqBE,iBAAiB;EAAA;AAAA;AAAA;EAAA,uCAAhC,WAAiCC,gBAAwB,EAAE;IAChE,IAAMC,cAAc,SAAS,IAAAC,kCAAgB,EAACpB,MAAM,EAAEkB,gBAAgB,CAAC;IACvE,OAAOC,cAAc;EACvB,CAAC;EAAA;AAAA"}
|
|
@@ -60,38 +60,75 @@ function authenticationMatchRequestsBy() {
|
|
|
60
60
|
// returns a delayed promise
|
|
61
61
|
function delay(_x) {
|
|
62
62
|
return _delay.apply(this, arguments);
|
|
63
|
-
}
|
|
63
|
+
}
|
|
64
64
|
function _delay() {
|
|
65
65
|
_delay = _asyncToGenerator(function* (ms) {
|
|
66
66
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
67
67
|
});
|
|
68
68
|
return _delay.apply(this, arguments);
|
|
69
69
|
}
|
|
70
|
-
function countdown(_x2
|
|
70
|
+
function countdown(_x2) {
|
|
71
71
|
return _countdown.apply(this, arguments);
|
|
72
72
|
}
|
|
73
73
|
function _countdown() {
|
|
74
|
-
_countdown = _asyncToGenerator(function* (
|
|
74
|
+
_countdown = _asyncToGenerator(function* (ms) {
|
|
75
75
|
yield delay(ms);
|
|
76
|
-
return --
|
|
76
|
+
return --ttl;
|
|
77
77
|
});
|
|
78
78
|
return _countdown.apply(this, arguments);
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
var timeout = 15;
|
|
81
|
+
var ttl = timeout;
|
|
82
|
+
function scheduleShutdown(_x3) {
|
|
81
83
|
return _scheduleShutdown.apply(this, arguments);
|
|
82
84
|
}
|
|
85
|
+
/*
|
|
86
|
+
argv:
|
|
87
|
+
[
|
|
88
|
+
'/Users/vscheuber/.nvm/versions/node/v18.7.0/bin/node',
|
|
89
|
+
'/usr/local/bin/frodo',
|
|
90
|
+
'journey',
|
|
91
|
+
'list',
|
|
92
|
+
'-l',
|
|
93
|
+
'https://openam-volker-dev.forgeblocks.com/am',
|
|
94
|
+
'alpha',
|
|
95
|
+
'volker.scheuber@forgerock.com',
|
|
96
|
+
'Sup3rS3cr3t!'
|
|
97
|
+
]
|
|
98
|
+
argv:
|
|
99
|
+
[
|
|
100
|
+
'/Users/vscheuber/.nvm/versions/node/v18.7.0/bin/node',
|
|
101
|
+
'/Users/vscheuber/Projects/frodo-cli/esm/cli/journey/journey-list.js',
|
|
102
|
+
'-l',
|
|
103
|
+
'https://openam-volker-dev.forgeblocks.com/am',
|
|
104
|
+
'alpha',
|
|
105
|
+
'volker.scheuber@forgerock.com',
|
|
106
|
+
'Sup3rS3cr3t!'
|
|
107
|
+
]
|
|
108
|
+
*/
|
|
83
109
|
function _scheduleShutdown() {
|
|
84
110
|
_scheduleShutdown = _asyncToGenerator(function* (polly) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
console.log("Polly stopping in ".concat(i, "s..."));
|
|
111
|
+
++ttl;
|
|
112
|
+
while (yield countdown(1000)) {
|
|
113
|
+
if (ttl < 4) console.log("Polly instance '".concat(getFrodoCommand(), "' stopping in ").concat(ttl, "s..."));
|
|
89
114
|
}
|
|
90
115
|
yield polly.stop();
|
|
91
|
-
console.log("Polly stopped.");
|
|
116
|
+
console.log("Polly instance '".concat(getFrodoCommand(), "' stopped."));
|
|
92
117
|
});
|
|
93
118
|
return _scheduleShutdown.apply(this, arguments);
|
|
94
119
|
}
|
|
120
|
+
function getFrodoCommand() {
|
|
121
|
+
try {
|
|
122
|
+
if (!process.argv[1].endsWith('frodo') && !process.argv[1].endsWith('frodo.exe')) {
|
|
123
|
+
return _path.default.parse(process.argv[1]).name.replace('-', '/');
|
|
124
|
+
}
|
|
125
|
+
return process.argv[2];
|
|
126
|
+
} catch (error) {
|
|
127
|
+
(0, _Console.printMessage)("SetupPollyForFrodoLib.getFrodoCommand: ".concat(error), 'error');
|
|
128
|
+
(0, _Console.printMessage)(process.argv, 'error');
|
|
129
|
+
return 'error';
|
|
130
|
+
}
|
|
131
|
+
}
|
|
95
132
|
function setupPollyForFrodoLib() {
|
|
96
133
|
var matchRequestsBy = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultMatchRequestsBy();
|
|
97
134
|
var polly = new _core.Polly('default');
|
|
@@ -113,27 +150,33 @@ function setupPollyForFrodoLib() {
|
|
|
113
150
|
for (var host of FRODO_MOCK_HOSTS) {
|
|
114
151
|
if (mode === _utils.MODES.RECORD) console.log("***** Host: ".concat(host));
|
|
115
152
|
polly.server.host(host, () => {
|
|
116
|
-
polly.server.any('/am/oauth2/*').recordingName(
|
|
153
|
+
polly.server.any('/am/oauth2/*').recordingName("".concat(getFrodoCommand(), "/oauth2")).on('request', req => {
|
|
117
154
|
req.configure({
|
|
118
155
|
matchRequestsBy: authenticationMatchRequestsBy()
|
|
119
156
|
});
|
|
120
157
|
});
|
|
121
|
-
polly.server.any('/am/json/*').recordingName(
|
|
122
|
-
polly.server.any('/openidm/*').recordingName(
|
|
123
|
-
polly.server.any('/environment/*').recordingName(
|
|
124
|
-
polly.server.any('/monitoring/*').recordingName(
|
|
125
|
-
polly.server.any('/feature').recordingName(
|
|
126
|
-
polly.server.any('/dashboard/*').recordingName(
|
|
158
|
+
polly.server.any('/am/json/*').recordingName("".concat(getFrodoCommand(), "/am"));
|
|
159
|
+
polly.server.any('/openidm/*').recordingName("".concat(getFrodoCommand(), "/openidm"));
|
|
160
|
+
polly.server.any('/environment/*').recordingName("".concat(getFrodoCommand(), "/environment"));
|
|
161
|
+
polly.server.any('/monitoring/*').recordingName("".concat(getFrodoCommand(), "/monitoring"));
|
|
162
|
+
polly.server.any('/feature').recordingName("".concat(getFrodoCommand(), "/feature"));
|
|
163
|
+
polly.server.any('/dashboard/*').recordingName("".concat(getFrodoCommand(), "/dashboard"));
|
|
127
164
|
});
|
|
128
165
|
}
|
|
129
166
|
polly.server.host('https://api.github.com', () => {
|
|
130
|
-
polly.server.any('/*').recordingName(
|
|
167
|
+
polly.server.any('/*').recordingName("github");
|
|
131
168
|
});
|
|
132
169
|
polly.server.host('https://registry.npmjs.org', () => {
|
|
133
|
-
polly.server.any('/*').recordingName(
|
|
170
|
+
polly.server.any('/*').recordingName("npmjs");
|
|
171
|
+
});
|
|
172
|
+
polly.server.any().on('request', () => {
|
|
173
|
+
if (ttl < timeout) {
|
|
174
|
+
// console.log(`Reset polly stop ttl (${ttl}) to ${timeout}`);
|
|
175
|
+
ttl = timeout;
|
|
176
|
+
}
|
|
134
177
|
});
|
|
135
178
|
if (mode === _utils.MODES.RECORD) {
|
|
136
|
-
scheduleShutdown(polly
|
|
179
|
+
scheduleShutdown(polly);
|
|
137
180
|
} else {
|
|
138
181
|
// only output debug messages if not recording as this polly instance is
|
|
139
182
|
// primarily used by frodo-cli e2e tests, which capture stdout in snapshots.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SetupPollyForFrodoLib.js","names":["__dirname","path","dirname","fileURLToPath","FRODO_MOCK_HOSTS","recordIfMissing","mode","MODES","REPLAY","recordingsDir","replace","process","env","FRODO_MOCK","Polly","register","NodeHttpAdapter","FSPersister","RECORD","defaultMatchRequestsBy","JSON","parse","stringify","method","headers","body","order","url","protocol","username","password","hostname","port","pathname","query","hash","authenticationMatchRequestsBy","matchRequestsBy","delay","ms","Promise","resolve","setTimeout","countdown","i","scheduleShutdown","polly","console","log","stop","setupPollyForFrodoLib","configure","adapters","flushRequestsOnStop","logLevel","FRODO_POLLY_LOG_LEVEL","recordFailedRequests","persister","persisterOptions","fs","host","server","any","recordingName","on","req","debugMessage","config"],"sources":["utils/SetupPollyForFrodoLib.ts"],"sourcesContent":["import path from 'path';\nimport { fileURLToPath } from 'url';\nimport { Polly } from '@pollyjs/core';\nimport { MODES } from '@pollyjs/utils';\nimport NodeHttpAdapter from '@pollyjs/adapter-node-http';\nimport FSPersister from '@pollyjs/persister-fs';\nimport { LogLevelDesc } from 'loglevel';\nimport { debugMessage } from '../ops/utils/Console';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nconst FRODO_MOCK_HOSTS = [\n 'https://openam-frodo-dev.forgeblocks.com',\n 'https://openam-service-accounts.forgeblocks.com',\n 'https://openam-volker-dev.forgeblocks.com',\n];\n\nlet recordIfMissing = false;\nlet mode = MODES.REPLAY;\n\n// resolve \"/home/sandeepc/work/ForgeRock/sources/frodo-lib/esm/api\" to\n// \"/home/sandeepc/work/ForgeRock/sources/frodo-lib/src/test/recordings\"\nconst recordingsDir = __dirname.replace(\n /^(.*\\/frodo-\\w{3})(.*)$/gi,\n '$1/mocks'\n);\n\nif (process.env.FRODO_MOCK) {\n Polly.register(NodeHttpAdapter);\n Polly.register(FSPersister);\n if (process.env.FRODO_MOCK === 'record') {\n mode = MODES.RECORD;\n recordIfMissing = true;\n }\n}\n\nfunction defaultMatchRequestsBy() {\n return JSON.parse(\n JSON.stringify({\n method: true,\n headers: false, // do not match headers, because \"Authorization\" header is sent only at recording time\n body: true,\n order: false,\n url: {\n protocol: false,\n username: false,\n password: false,\n hostname: false, // we will record from different envs but run tests always against `frodo-dev`\n port: false,\n pathname: true,\n query: true,\n hash: true,\n },\n })\n );\n}\n\nfunction authenticationMatchRequestsBy() {\n const matchRequestsBy = defaultMatchRequestsBy();\n matchRequestsBy.body = false;\n matchRequestsBy.order = true;\n return matchRequestsBy;\n}\n\n// returns a delayed promise\nasync function delay(ms) {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n// performs a specific (mathematical) operation every \"ms\" (milliseconds)\nasync function countdown(i, ms) {\n await delay(ms);\n return --i;\n}\n\nasync function scheduleShutdown(polly: Polly, i = 30) {\n ++i;\n while ((i = await countdown(i, 1000)))\n console.log(`Polly stopping in ${i}s...`);\n await polly.stop();\n console.log(`Polly stopped.`);\n}\n\nexport function setupPollyForFrodoLib(\n matchRequestsBy = defaultMatchRequestsBy()\n): Polly {\n const polly = new Polly('default');\n\n polly.configure({\n adapters: ['node-http'],\n mode,\n recordIfMissing,\n flushRequestsOnStop: true,\n logLevel: (process.env.FRODO_POLLY_LOG_LEVEL as LogLevelDesc) || 'warn',\n recordFailedRequests: true,\n persister: 'fs',\n persisterOptions: {\n fs: {\n recordingsDir,\n },\n },\n matchRequestsBy,\n });\n\n for (const host of FRODO_MOCK_HOSTS) {\n if (mode === MODES.RECORD) console.log(`***** Host: ${host}`);\n polly.server.host(host, () => {\n polly.server\n .any('/am/oauth2/*')\n .recordingName('oauth2')\n .on('request', (req) => {\n req.configure({ matchRequestsBy: authenticationMatchRequestsBy() });\n });\n polly.server.any('/am/json/*').recordingName('am');\n polly.server.any('/openidm/*').recordingName('openidm');\n polly.server.any('/environment/*').recordingName('environment');\n polly.server.any('/monitoring/*').recordingName('monitoring');\n polly.server.any('/feature').recordingName('feature');\n polly.server.any('/dashboard/*').recordingName('dashboard');\n });\n }\n polly.server.host('https://api.github.com', () => {\n polly.server.any('/*').recordingName('github');\n });\n polly.server.host('https://registry.npmjs.org', () => {\n polly.server.any('/*').recordingName('npmjs');\n });\n\n if (mode === MODES.RECORD) {\n scheduleShutdown(polly, 60);\n } else {\n // only output debug messages if not recording as this polly instance is\n // primarily used by frodo-cli e2e tests, which capture stdout in snapshots.\n // debug messages falsify the snapshot recordings.\n debugMessage(`Polly config:`);\n debugMessage(polly.config);\n }\n\n return polly;\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AAAoD;AAAA;AAAA;AAEpD,IAAMA,QAAS,GAAGC,aAAI,CAACC,OAAO,CAAC,IAAAC,kBAAa,sDAAiB,CAAC;AAE9D,IAAMC,gBAAgB,GAAG,CACvB,0CAA0C,EAC1C,iDAAiD,EACjD,2CAA2C,CAC5C;AAED,IAAIC,eAAe,GAAG,KAAK;AAC3B,IAAIC,IAAI,GAAGC,YAAK,CAACC,MAAM;;AAEvB;AACA;AACA,IAAMC,aAAa,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|
1
|
+
{"version":3,"file":"SetupPollyForFrodoLib.js","names":["__dirname","path","dirname","fileURLToPath","FRODO_MOCK_HOSTS","recordIfMissing","mode","MODES","REPLAY","recordingsDir","replace","process","env","FRODO_MOCK","Polly","register","NodeHttpAdapter","FSPersister","RECORD","defaultMatchRequestsBy","JSON","parse","stringify","method","headers","body","order","url","protocol","username","password","hostname","port","pathname","query","hash","authenticationMatchRequestsBy","matchRequestsBy","delay","ms","Promise","resolve","setTimeout","countdown","ttl","timeout","scheduleShutdown","polly","console","log","getFrodoCommand","stop","argv","endsWith","name","error","printMessage","setupPollyForFrodoLib","configure","adapters","flushRequestsOnStop","logLevel","FRODO_POLLY_LOG_LEVEL","recordFailedRequests","persister","persisterOptions","fs","host","server","any","recordingName","on","req","debugMessage","config"],"sources":["utils/SetupPollyForFrodoLib.ts"],"sourcesContent":["import path from 'path';\nimport { fileURLToPath } from 'url';\nimport { Polly } from '@pollyjs/core';\nimport { MODES } from '@pollyjs/utils';\nimport NodeHttpAdapter from '@pollyjs/adapter-node-http';\nimport FSPersister from '@pollyjs/persister-fs';\nimport { LogLevelDesc } from 'loglevel';\nimport { debugMessage, printMessage } from '../ops/utils/Console';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nconst FRODO_MOCK_HOSTS = [\n 'https://openam-frodo-dev.forgeblocks.com',\n 'https://openam-service-accounts.forgeblocks.com',\n 'https://openam-volker-dev.forgeblocks.com',\n];\n\nlet recordIfMissing = false;\nlet mode = MODES.REPLAY;\n\n// resolve \"/home/sandeepc/work/ForgeRock/sources/frodo-lib/esm/api\" to\n// \"/home/sandeepc/work/ForgeRock/sources/frodo-lib/src/test/recordings\"\nconst recordingsDir = __dirname.replace(\n /^(.*\\/frodo-\\w{3})(.*)$/gi,\n '$1/mocks'\n);\n\nif (process.env.FRODO_MOCK) {\n Polly.register(NodeHttpAdapter);\n Polly.register(FSPersister);\n if (process.env.FRODO_MOCK === 'record') {\n mode = MODES.RECORD;\n recordIfMissing = true;\n }\n}\n\nfunction defaultMatchRequestsBy() {\n return JSON.parse(\n JSON.stringify({\n method: true,\n headers: false, // do not match headers, because \"Authorization\" header is sent only at recording time\n body: true,\n order: false,\n url: {\n protocol: false,\n username: false,\n password: false,\n hostname: false, // we will record from different envs but run tests always against `frodo-dev`\n port: false,\n pathname: true,\n query: true,\n hash: true,\n },\n })\n );\n}\n\nfunction authenticationMatchRequestsBy() {\n const matchRequestsBy = defaultMatchRequestsBy();\n matchRequestsBy.body = false;\n matchRequestsBy.order = true;\n return matchRequestsBy;\n}\n\n// returns a delayed promise\nasync function delay(ms) {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nasync function countdown(ms) {\n await delay(ms);\n return --ttl;\n}\n\nconst timeout = 15;\nlet ttl = timeout;\nasync function scheduleShutdown(polly: Polly) {\n ++ttl;\n while (await countdown(1000)) {\n if (ttl < 4)\n console.log(\n `Polly instance '${getFrodoCommand()}' stopping in ${ttl}s...`\n );\n }\n await polly.stop();\n console.log(`Polly instance '${getFrodoCommand()}' stopped.`);\n}\n\n/*\nargv:\n[\n '/Users/vscheuber/.nvm/versions/node/v18.7.0/bin/node',\n '/usr/local/bin/frodo',\n 'journey',\n 'list',\n '-l',\n 'https://openam-volker-dev.forgeblocks.com/am',\n 'alpha',\n 'volker.scheuber@forgerock.com',\n 'Sup3rS3cr3t!'\n]\nargv:\n[\n '/Users/vscheuber/.nvm/versions/node/v18.7.0/bin/node',\n '/Users/vscheuber/Projects/frodo-cli/esm/cli/journey/journey-list.js',\n '-l',\n 'https://openam-volker-dev.forgeblocks.com/am',\n 'alpha',\n 'volker.scheuber@forgerock.com',\n 'Sup3rS3cr3t!'\n]\n*/\nfunction getFrodoCommand() {\n try {\n if (\n !process.argv[1].endsWith('frodo') &&\n !process.argv[1].endsWith('frodo.exe')\n ) {\n return path.parse(process.argv[1]).name.replace('-', '/');\n }\n return process.argv[2];\n } catch (error) {\n printMessage(`SetupPollyForFrodoLib.getFrodoCommand: ${error}`, 'error');\n printMessage(process.argv, 'error');\n return 'error';\n }\n}\n\nexport function setupPollyForFrodoLib(\n matchRequestsBy = defaultMatchRequestsBy()\n): Polly {\n const polly = new Polly('default');\n\n polly.configure({\n adapters: ['node-http'],\n mode,\n recordIfMissing,\n flushRequestsOnStop: true,\n logLevel: (process.env.FRODO_POLLY_LOG_LEVEL as LogLevelDesc) || 'warn',\n recordFailedRequests: true,\n persister: 'fs',\n persisterOptions: {\n fs: {\n recordingsDir,\n },\n },\n matchRequestsBy,\n });\n\n for (const host of FRODO_MOCK_HOSTS) {\n if (mode === MODES.RECORD) console.log(`***** Host: ${host}`);\n polly.server.host(host, () => {\n polly.server\n .any('/am/oauth2/*')\n .recordingName(`${getFrodoCommand()}/oauth2`)\n .on('request', (req) => {\n req.configure({ matchRequestsBy: authenticationMatchRequestsBy() });\n });\n polly.server.any('/am/json/*').recordingName(`${getFrodoCommand()}/am`);\n polly.server\n .any('/openidm/*')\n .recordingName(`${getFrodoCommand()}/openidm`);\n polly.server\n .any('/environment/*')\n .recordingName(`${getFrodoCommand()}/environment`);\n polly.server\n .any('/monitoring/*')\n .recordingName(`${getFrodoCommand()}/monitoring`);\n polly.server\n .any('/feature')\n .recordingName(`${getFrodoCommand()}/feature`);\n polly.server\n .any('/dashboard/*')\n .recordingName(`${getFrodoCommand()}/dashboard`);\n });\n }\n polly.server.host('https://api.github.com', () => {\n polly.server.any('/*').recordingName(`github`);\n });\n polly.server.host('https://registry.npmjs.org', () => {\n polly.server.any('/*').recordingName(`npmjs`);\n });\n polly.server.any().on('request', () => {\n if (ttl < timeout) {\n // console.log(`Reset polly stop ttl (${ttl}) to ${timeout}`);\n ttl = timeout;\n }\n });\n\n if (mode === MODES.RECORD) {\n scheduleShutdown(polly);\n } else {\n // only output debug messages if not recording as this polly instance is\n // primarily used by frodo-cli e2e tests, which capture stdout in snapshots.\n // debug messages falsify the snapshot recordings.\n debugMessage(`Polly config:`);\n debugMessage(polly.config);\n }\n\n return polly;\n}\n"],"mapp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A,qBAAY,EAAC1B,KAAK,CAAC2B,MAAM,CAAC;EAC5B;EAEA,OAAO3B,KAAK;AACd"}
|
|
@@ -9,13 +9,18 @@ const managedObjectQueryAllURLTemplate = `${managedObjectURLTemplate}?_queryFilt
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Get managed object
|
|
12
|
-
* @param {
|
|
13
|
-
* @
|
|
12
|
+
* @param {string} type managed object type, e.g. alpha_user or user
|
|
13
|
+
* @param {string} id managed object id
|
|
14
|
+
* @param {string[]} id array of fields to include
|
|
15
|
+
* @returns {Promise<ObjectSkeletonInterface>} a promise that resolves to an ObjectSkeletonInterface
|
|
14
16
|
*/
|
|
15
|
-
export async function getManagedObject(type, id, fields) {
|
|
16
|
-
const fieldsParam =
|
|
17
|
+
export async function getManagedObject(type, id, fields = ['*']) {
|
|
18
|
+
const fieldsParam = `_fields=${fields.join(',')}`;
|
|
17
19
|
const urlString = util.format(`${managedObjectByIdURLTemplate}?${fieldsParam}`, getTenantURL(state.getHost()), type, id);
|
|
18
|
-
|
|
20
|
+
const {
|
|
21
|
+
data
|
|
22
|
+
} = await generateIdmApi().get(urlString);
|
|
23
|
+
return data;
|
|
19
24
|
}
|
|
20
25
|
|
|
21
26
|
/**
|
|
@@ -12,7 +12,7 @@ import { getConnectionProfile } from './ConnectionProfileOps';
|
|
|
12
12
|
import { v4 } from 'uuid';
|
|
13
13
|
import { parseUrl } from '../api/utils/ApiUtils';
|
|
14
14
|
import { createSignedJwtToken } from './JoseOps';
|
|
15
|
-
import {
|
|
15
|
+
import { getServiceAccount } from './cloud/ServiceAccountOps';
|
|
16
16
|
const adminClientPassword = 'doesnotmatter';
|
|
17
17
|
const redirectUrlTemplate = '/platform/appAuthHelperRedirect.html';
|
|
18
18
|
const idmAdminScopes = 'fr:idm:* fr:idc:esv:*';
|
|
@@ -341,7 +341,7 @@ async function determineDeploymentTypeAndDefaultRealmAndVersion() {
|
|
|
341
341
|
async function getLoggedInSubject() {
|
|
342
342
|
let subjectString = `user ${state.getUsername()}`;
|
|
343
343
|
if (state.getUseBearerTokenForAmApis()) {
|
|
344
|
-
const name = (await
|
|
344
|
+
const name = (await getServiceAccount(state.getServiceAccountId())).name;
|
|
345
345
|
subjectString = `service account ${name} [${state.getServiceAccountId()}]`;
|
|
346
346
|
}
|
|
347
347
|
return subjectString;
|
|
@@ -386,8 +386,9 @@ export async function getTokens() {
|
|
|
386
386
|
state.setUseBearerTokenForAmApis(true);
|
|
387
387
|
await determineDeploymentTypeAndDefaultRealmAndVersion();
|
|
388
388
|
} catch (saErr) {
|
|
389
|
-
var _saErr$response, _saErr$
|
|
390
|
-
|
|
389
|
+
var _saErr$response, _saErr$response2, _saErr$response2$data, _saErr$response3, _saErr$response3$data;
|
|
390
|
+
debugMessage((_saErr$response = saErr.response) === null || _saErr$response === void 0 ? void 0 : _saErr$response.data);
|
|
391
|
+
throw new Error(`Service account login error: ${((_saErr$response2 = saErr.response) === null || _saErr$response2 === void 0 ? void 0 : (_saErr$response2$data = _saErr$response2.data) === null || _saErr$response2$data === void 0 ? void 0 : _saErr$response2$data.error_description) || ((_saErr$response3 = saErr.response) === null || _saErr$response3 === void 0 ? void 0 : (_saErr$response3$data = _saErr$response3.data) === null || _saErr$response3$data === void 0 ? void 0 : _saErr$response3$data.message)}`);
|
|
391
392
|
}
|
|
392
393
|
}
|
|
393
394
|
// use user account to login
|