@credibledata/cred-cli 0.0.103 → 0.0.105
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/README.md +106 -1
- package/dist/agent-contract.spec.js +548 -0
- package/dist/agent-contract.spec.js.map +1 -0
- package/dist/browser.js +72 -0
- package/dist/browser.js.map +1 -0
- package/dist/browser.spec.js +125 -0
- package/dist/browser.spec.js.map +1 -0
- package/dist/client/api.js +4137 -1159
- package/dist/client/api.js.map +1 -1
- package/dist/client-codeassist/api.js +476 -0
- package/dist/client-codeassist/api.js.map +1 -0
- package/dist/client-codeassist/base.js +69 -0
- package/dist/client-codeassist/base.js.map +1 -0
- package/dist/client-codeassist/common.js +162 -0
- package/dist/client-codeassist/common.js.map +1 -0
- package/dist/client-codeassist/configuration.js +44 -0
- package/dist/client-codeassist/configuration.js.map +1 -0
- package/dist/client-codeassist/index.js +32 -0
- package/dist/client-codeassist/index.js.map +1 -0
- package/dist/clientconfiguration.js +17 -289
- package/dist/clientconfiguration.js.map +1 -1
- package/dist/clientconfiguration.spec.js +35 -96
- package/dist/clientconfiguration.spec.js.map +1 -1
- package/dist/commands/add.js +103 -3
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/add.spec.js +113 -0
- package/dist/commands/add.spec.js.map +1 -0
- package/dist/commands/connection/createconnections.js +104 -7
- package/dist/commands/connection/createconnections.js.map +1 -1
- package/dist/commands/connection/createconnections.spec.js +35 -1
- package/dist/commands/connection/createconnections.spec.js.map +1 -1
- package/dist/commands/connection/deleteconnection.js +4 -2
- package/dist/commands/connection/deleteconnection.js.map +1 -1
- package/dist/commands/connection/deleteconnection.spec.js +6 -1
- package/dist/commands/connection/deleteconnection.spec.js.map +1 -1
- package/dist/commands/connection/listconnections.js +2 -0
- package/dist/commands/connection/listconnections.js.map +1 -1
- package/dist/commands/connection/updateconnection.js +365 -0
- package/dist/commands/connection/updateconnection.js.map +1 -0
- package/dist/commands/connection/updateconnection.spec.js +625 -0
- package/dist/commands/connection/updateconnection.spec.js.map +1 -0
- package/dist/commands/database/createdatabase.js +52 -0
- package/dist/commands/database/createdatabase.js.map +1 -0
- package/dist/commands/database/database.spec.js +267 -0
- package/dist/commands/database/database.spec.js.map +1 -0
- package/dist/commands/database/deletedatabase.js +91 -0
- package/dist/commands/database/deletedatabase.js.map +1 -0
- package/dist/commands/database/getdatabase.js +97 -0
- package/dist/commands/database/getdatabase.js.map +1 -0
- package/dist/commands/database/listdatabases.js +36 -0
- package/dist/commands/database/listdatabases.js.map +1 -0
- package/dist/commands/database/shared.js +125 -0
- package/dist/commands/database/shared.js.map +1 -0
- package/dist/commands/database/shared.spec.js +109 -0
- package/dist/commands/database/shared.spec.js.map +1 -0
- package/dist/commands/database/updatedatabase.js +39 -0
- package/dist/commands/database/updatedatabase.js.map +1 -0
- package/dist/commands/environment/createenvironment.js +59 -28
- package/dist/commands/environment/createenvironment.js.map +1 -1
- package/dist/commands/environment/createenvironment.spec.js +29 -0
- package/dist/commands/environment/createenvironment.spec.js.map +1 -1
- package/dist/commands/environment/deleteenvironment.js +3 -2
- package/dist/commands/environment/deleteenvironment.js.map +1 -1
- package/dist/commands/environment/deleteenvironment.spec.js +5 -1
- package/dist/commands/environment/deleteenvironment.spec.js.map +1 -1
- package/dist/commands/environment/getenvironment.js +1 -0
- package/dist/commands/environment/getenvironment.js.map +1 -1
- package/dist/commands/environment/listenvironments.js +40 -8
- package/dist/commands/environment/listenvironments.js.map +1 -1
- package/dist/commands/environment/listenvironments.spec.js +41 -2
- package/dist/commands/environment/listenvironments.spec.js.map +1 -1
- package/dist/commands/environment/setenvironment.js +145 -6
- package/dist/commands/environment/setenvironment.js.map +1 -1
- package/dist/commands/environment/setenvironment.spec.js +256 -8
- package/dist/commands/environment/setenvironment.spec.js.map +1 -1
- package/dist/commands/environment/updateenvironment.js +12 -8
- package/dist/commands/environment/updateenvironment.js.map +1 -1
- package/dist/commands/environment/updateenvironment.spec.js +36 -2
- package/dist/commands/environment/updateenvironment.spec.js.map +1 -1
- package/dist/commands/get.js +64 -1
- package/dist/commands/get.js.map +1 -1
- package/dist/commands/group/addmember.js +3 -1
- package/dist/commands/group/addmember.js.map +1 -1
- package/dist/commands/group/addmember.spec.js +7 -2
- package/dist/commands/group/addmember.spec.js.map +1 -1
- package/dist/commands/group/creategroup.js +2 -0
- package/dist/commands/group/creategroup.js.map +1 -1
- package/dist/commands/group/deletegroup.js +3 -1
- package/dist/commands/group/deletegroup.js.map +1 -1
- package/dist/commands/group/deletegroup.spec.js +7 -1
- package/dist/commands/group/deletegroup.spec.js.map +1 -1
- package/dist/commands/group/getgroup.js +2 -0
- package/dist/commands/group/getgroup.js.map +1 -1
- package/dist/commands/group/listgroups.js +2 -0
- package/dist/commands/group/listgroups.js.map +1 -1
- package/dist/commands/group/removemember.js +3 -1
- package/dist/commands/group/removemember.js.map +1 -1
- package/dist/commands/group/removemember.spec.js +7 -2
- package/dist/commands/group/removemember.spec.js.map +1 -1
- package/dist/commands/groupaccesstoken/deleteToken.js +2 -1
- package/dist/commands/groupaccesstoken/deleteToken.js.map +1 -1
- package/dist/commands/groupaccesstoken/groupContainer.js +2 -0
- package/dist/commands/groupaccesstoken/groupContainer.js.map +1 -1
- package/dist/commands/list.js +24 -4
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/materialization/cancelrun.js +3 -1
- package/dist/commands/materialization/cancelrun.js.map +1 -1
- package/dist/commands/materialization/getindex.js +2 -0
- package/dist/commands/materialization/getindex.js.map +1 -1
- package/dist/commands/materialization/getmaterialization.js +2 -0
- package/dist/commands/materialization/getmaterialization.js.map +1 -1
- package/dist/commands/materialization/getpreaggregate.js +2 -0
- package/dist/commands/materialization/getpreaggregate.js.map +1 -1
- package/dist/commands/materialization/getrun.js +2 -0
- package/dist/commands/materialization/getrun.js.map +1 -1
- package/dist/commands/materialization/listindexes.js +2 -0
- package/dist/commands/materialization/listindexes.js.map +1 -1
- package/dist/commands/materialization/listmaterializations.js +2 -0
- package/dist/commands/materialization/listmaterializations.js.map +1 -1
- package/dist/commands/materialization/listpreaggregates.js +2 -0
- package/dist/commands/materialization/listpreaggregates.js.map +1 -1
- package/dist/commands/materialization/listruns.js +3 -1
- package/dist/commands/materialization/listruns.js.map +1 -1
- package/dist/commands/materialization/rerun.js +3 -1
- package/dist/commands/materialization/rerun.js.map +1 -1
- package/dist/commands/misc/inquirerHost.js +87 -0
- package/dist/commands/misc/inquirerHost.js.map +1 -0
- package/dist/commands/misc/inquirerHost.spec.js +91 -0
- package/dist/commands/misc/inquirerHost.spec.js.map +1 -0
- package/dist/commands/misc/login.js +348 -58
- package/dist/commands/misc/login.js.map +1 -1
- package/dist/commands/misc/login.spec.js +525 -7
- package/dist/commands/misc/login.spec.js.map +1 -1
- package/dist/commands/misc/logout.js +26 -3
- package/dist/commands/misc/logout.js.map +1 -1
- package/dist/commands/misc/logout.spec.js +52 -12
- package/dist/commands/misc/logout.spec.js.map +1 -1
- package/dist/commands/misc/resolveLoginTarget.spec.js +90 -0
- package/dist/commands/misc/resolveLoginTarget.spec.js.map +1 -0
- package/dist/commands/misc/scope.spec.js +108 -0
- package/dist/commands/misc/scope.spec.js.map +1 -0
- package/dist/commands/misc/set-access-token.js +1 -1
- package/dist/commands/misc/set-access-token.js.map +1 -1
- package/dist/commands/misc/set-access-token.spec.js +13 -2
- package/dist/commands/misc/set-access-token.spec.js.map +1 -1
- package/dist/commands/misc/setup.js +819 -0
- package/dist/commands/misc/setup.js.map +1 -0
- package/dist/commands/misc/setup.spec.js +783 -0
- package/dist/commands/misc/setup.spec.js.map +1 -0
- package/dist/commands/misc/status.js +168 -0
- package/dist/commands/misc/status.js.map +1 -0
- package/dist/commands/misc/status.spec.js +301 -0
- package/dist/commands/misc/status.spec.js.map +1 -0
- package/dist/commands/misc/token.js +57 -0
- package/dist/commands/misc/token.js.map +1 -0
- package/dist/commands/misc/token.spec.js +92 -0
- package/dist/commands/misc/token.spec.js.map +1 -0
- package/dist/commands/package/deletepackage.js +4 -2
- package/dist/commands/package/deletepackage.js.map +1 -1
- package/dist/commands/package/deletepackage.spec.js +7 -1
- package/dist/commands/package/deletepackage.spec.js.map +1 -1
- package/dist/commands/package/getpackage.js +142 -0
- package/dist/commands/package/getpackage.js.map +1 -0
- package/dist/commands/package/getpackage.spec.js +246 -0
- package/dist/commands/package/getpackage.spec.js.map +1 -0
- package/dist/commands/package/listpackages.js +2 -0
- package/dist/commands/package/listpackages.js.map +1 -1
- package/dist/commands/package/publish.archive.spec.js +570 -0
- package/dist/commands/package/publish.archive.spec.js.map +1 -0
- package/dist/commands/package/publish.js +780 -49
- package/dist/commands/package/publish.js.map +1 -1
- package/dist/commands/package/publish.spec.js +451 -8
- package/dist/commands/package/publish.spec.js.map +1 -1
- package/dist/commands/package/updatepackage.js +22 -19
- package/dist/commands/package/updatepackage.js.map +1 -1
- package/dist/commands/package/updatepackage.spec.js +36 -1
- package/dist/commands/package/updatepackage.spec.js.map +1 -1
- package/dist/commands/permission/createpermission.js +3 -1
- package/dist/commands/permission/createpermission.js.map +1 -1
- package/dist/commands/permission/deletepermission.js +6 -3
- package/dist/commands/permission/deletepermission.js.map +1 -1
- package/dist/commands/permission/getpermission.js +2 -0
- package/dist/commands/permission/getpermission.js.map +1 -1
- package/dist/commands/permission/listpermissions.js +2 -0
- package/dist/commands/permission/listpermissions.js.map +1 -1
- package/dist/commands/rm.js +21 -0
- package/dist/commands/rm.js.map +1 -1
- package/dist/commands/set.js +40 -6
- package/dist/commands/set.js.map +1 -1
- package/dist/commands/set.spec.js +123 -0
- package/dist/commands/set.spec.js.map +1 -0
- package/dist/commands/table/addtable.js +155 -0
- package/dist/commands/table/addtable.js.map +1 -0
- package/dist/commands/table/deletetable.js +45 -0
- package/dist/commands/table/deletetable.js.map +1 -0
- package/dist/commands/table/gettable.js +32 -0
- package/dist/commands/table/gettable.js.map +1 -0
- package/dist/commands/table/listtables.js +36 -0
- package/dist/commands/table/listtables.js.map +1 -0
- package/dist/commands/table/table.spec.js +304 -0
- package/dist/commands/table/table.spec.js.map +1 -0
- package/dist/commands/table/tablefile.js +195 -0
- package/dist/commands/table/tablefile.js.map +1 -0
- package/dist/commands/table/tablefile.spec.js +158 -0
- package/dist/commands/table/tablefile.spec.js.map +1 -0
- package/dist/commands/update.js +21 -0
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/version/archive-unarchive-version.js +4 -2
- package/dist/commands/version/archive-unarchive-version.js.map +1 -1
- package/dist/commands/version/archive-unarchive-version.spec.js +6 -1
- package/dist/commands/version/archive-unarchive-version.spec.js.map +1 -1
- package/dist/commands/version/listversions.js +2 -0
- package/dist/commands/version/listversions.js.map +1 -1
- package/dist/common/UserGroupId.js +9 -4
- package/dist/common/UserGroupId.js.map +1 -1
- package/dist/common/UserGroupId.spec.js +5 -0
- package/dist/common/UserGroupId.spec.js.map +1 -1
- package/dist/constants.js +37 -143
- package/dist/constants.js.map +1 -1
- package/dist/index.js +487 -90
- package/dist/index.js.map +1 -1
- package/dist/logger.js +42 -9
- package/dist/logger.js.map +1 -1
- package/dist/session.js +56 -0
- package/dist/session.js.map +1 -0
- package/dist/session.spec.js +103 -0
- package/dist/session.spec.js.map +1 -0
- package/dist/setup-core/briefing.js +176 -0
- package/dist/setup-core/briefing.js.map +1 -0
- package/dist/setup-core/credstore.js +415 -0
- package/dist/setup-core/credstore.js.map +1 -0
- package/dist/setup-core/credstore.spec.js +238 -0
- package/dist/setup-core/credstore.spec.js.map +1 -0
- package/dist/setup-core/environments.js +267 -0
- package/dist/setup-core/environments.js.map +1 -0
- package/dist/setup-core/flow.e2e.js +165 -0
- package/dist/setup-core/flow.e2e.js.map +1 -0
- package/dist/setup-core/flow.js +765 -0
- package/dist/setup-core/flow.js.map +1 -0
- package/dist/setup-core/flow.spec.js +1348 -0
- package/dist/setup-core/flow.spec.js.map +1 -0
- package/dist/setup-core/folderconfig.js +283 -0
- package/dist/setup-core/folderconfig.js.map +1 -0
- package/dist/setup-core/git.js +97 -0
- package/dist/setup-core/git.js.map +1 -0
- package/dist/setup-core/host.js +77 -0
- package/dist/setup-core/host.js.map +1 -0
- package/dist/setup-core/importconnections.js +470 -0
- package/dist/setup-core/importconnections.js.map +1 -0
- package/dist/setup-core/importconnections.spec.js +594 -0
- package/dist/setup-core/importconnections.spec.js.map +1 -0
- package/dist/setup-core/liveness.js +94 -0
- package/dist/setup-core/liveness.js.map +1 -0
- package/dist/setup-core/liveness.spec.js +59 -0
- package/dist/setup-core/liveness.spec.js.map +1 -0
- package/dist/setup-core/localpublisherconfig.js +26 -0
- package/dist/setup-core/localpublisherconfig.js.map +1 -0
- package/dist/setup-core/localpublisherconfig.spec.js +29 -0
- package/dist/setup-core/localpublisherconfig.spec.js.map +1 -0
- package/dist/setup-core/mcpconfig.js +198 -0
- package/dist/setup-core/mcpconfig.js.map +1 -0
- package/dist/setup-core/mcpconfig.spec.js +205 -0
- package/dist/setup-core/mcpconfig.spec.js.map +1 -0
- package/dist/setup-core/packagemanifest.js +55 -0
- package/dist/setup-core/packagemanifest.js.map +1 -0
- package/dist/setup-core/ports.js +182 -0
- package/dist/setup-core/ports.js.map +1 -0
- package/dist/setup-core/ports.spec.js +173 -0
- package/dist/setup-core/ports.spec.js.map +1 -0
- package/dist/setup-core/publisherconfig.js +268 -0
- package/dist/setup-core/publisherconfig.js.map +1 -0
- package/dist/setup-core/publisherconfig.oracle.js +166 -0
- package/dist/setup-core/publisherconfig.oracle.js.map +1 -0
- package/dist/setup-core/publisherconfig.spec.js +277 -0
- package/dist/setup-core/publisherconfig.spec.js.map +1 -0
- package/dist/setup-core/publisherversion.js +26 -0
- package/dist/setup-core/publisherversion.js.map +1 -0
- package/dist/setup-core/readiness.spec.js +161 -0
- package/dist/setup-core/readiness.spec.js.map +1 -0
- package/dist/setup-core/readylines.js +169 -0
- package/dist/setup-core/readylines.js.map +1 -0
- package/dist/setup-core/readylines.spec.js +70 -0
- package/dist/setup-core/readylines.spec.js.map +1 -0
- package/dist/setup-core/refresh.js +348 -0
- package/dist/setup-core/refresh.js.map +1 -0
- package/dist/setup-core/refresh.spec.js +501 -0
- package/dist/setup-core/refresh.spec.js.map +1 -0
- package/dist/setup-core/skills.js +279 -0
- package/dist/setup-core/skills.js.map +1 -0
- package/dist/setup-core/skills.spec.js +334 -0
- package/dist/setup-core/skills.spec.js.map +1 -0
- package/dist/setup-core/supervisor.js +879 -0
- package/dist/setup-core/supervisor.js.map +1 -0
- package/dist/setup-core/supervisor.spec.js +833 -0
- package/dist/setup-core/supervisor.spec.js.map +1 -0
- package/dist/setup-core/writefile.js +61 -0
- package/dist/setup-core/writefile.js.map +1 -0
- package/dist/setup-core/writefile.spec.js +68 -0
- package/dist/setup-core/writefile.spec.js.map +1 -0
- package/dist/utils.js +409 -3
- package/dist/utils.js.map +1 -1
- package/dist/utils.spec.js +373 -2
- package/dist/utils.spec.js.map +1 -1
- package/dist/versioncheck-refresh.js +18 -0
- package/dist/versioncheck-refresh.js.map +1 -0
- package/dist/versioncheck.js +324 -0
- package/dist/versioncheck.js.map +1 -0
- package/dist/versioncheck.spec.js +587 -0
- package/dist/versioncheck.spec.js.map +1 -0
- package/node_modules/@credibledata/cli-auth/dist/index.d.ts +86 -0
- package/node_modules/@credibledata/cli-auth/dist/index.js +102 -0
- package/node_modules/@credibledata/cli-auth/package.json +19 -0
- package/package.json +18 -6
- package/.github/workflows/build.yml +0 -23
- package/.mocharc.json +0 -10
- package/.prettierignore +0 -2
- package/.prettierrc +0 -4
- package/README-DEV.md +0 -40
- package/coverage/coverage-summary.json +0 -40
- package/coverage/tmp/coverage-2152-1789496974457-0.json +0 -1
- package/coverage/tmp/coverage-2153-1789496954404-0.json +0 -1
- package/docker/Dockerfile.ci +0 -18
- package/docker-compose.yml +0 -18
- package/eslint.config.mjs +0 -45
- package/generate-client.sh +0 -27
- package/mocha.setup.ts +0 -4
- package/openapitools.json +0 -10
- package/src/client/.openapi-generator/FILES +0 -9
- package/src/client/.openapi-generator/VERSION +0 -1
- package/src/client/.openapi-generator-ignore +0 -23
- package/src/client/api.ts +0 -15999
- package/src/client/base.ts +0 -86
- package/src/client/common.ts +0 -150
- package/src/client/configuration.ts +0 -110
- package/src/client/git_push.sh +0 -57
- package/src/client/index.ts +0 -18
- package/src/clientconfiguration.spec.ts +0 -615
- package/src/clientconfiguration.ts +0 -364
- package/src/commands/add.ts +0 -191
- package/src/commands/connection/createconnections.spec.ts +0 -413
- package/src/commands/connection/createconnections.ts +0 -109
- package/src/commands/connection/deleteconnection.spec.ts +0 -189
- package/src/commands/connection/deleteconnection.ts +0 -57
- package/src/commands/connection/listconnections.spec.ts +0 -132
- package/src/commands/connection/listconnections.ts +0 -58
- package/src/commands/environment/createenvironment.spec.ts +0 -249
- package/src/commands/environment/createenvironment.ts +0 -73
- package/src/commands/environment/deleteenvironment.spec.ts +0 -152
- package/src/commands/environment/deleteenvironment.ts +0 -48
- package/src/commands/environment/getenvironment.spec.ts +0 -110
- package/src/commands/environment/getenvironment.ts +0 -43
- package/src/commands/environment/listenvironments.spec.ts +0 -123
- package/src/commands/environment/listenvironments.ts +0 -67
- package/src/commands/environment/setenvironment.spec.ts +0 -63
- package/src/commands/environment/setenvironment.ts +0 -14
- package/src/commands/environment/updateenvironment.spec.ts +0 -386
- package/src/commands/environment/updateenvironment.ts +0 -168
- package/src/commands/get.ts +0 -153
- package/src/commands/group/addmember.spec.ts +0 -257
- package/src/commands/group/addmember.ts +0 -85
- package/src/commands/group/creategroup.spec.ts +0 -146
- package/src/commands/group/creategroup.ts +0 -54
- package/src/commands/group/deletegroup.spec.ts +0 -120
- package/src/commands/group/deletegroup.ts +0 -45
- package/src/commands/group/getgroup.spec.ts +0 -129
- package/src/commands/group/getgroup.ts +0 -47
- package/src/commands/group/listgroups.spec.ts +0 -137
- package/src/commands/group/listgroups.ts +0 -45
- package/src/commands/group/removemember.spec.ts +0 -224
- package/src/commands/group/removemember.ts +0 -75
- package/src/commands/groupaccesstoken/createToken.spec.ts +0 -211
- package/src/commands/groupaccesstoken/createToken.ts +0 -72
- package/src/commands/groupaccesstoken/deleteToken.spec.ts +0 -147
- package/src/commands/groupaccesstoken/deleteToken.ts +0 -29
- package/src/commands/groupaccesstoken/groupContainer.ts +0 -83
- package/src/commands/groupaccesstoken/listTokens.spec.ts +0 -147
- package/src/commands/groupaccesstoken/listTokens.ts +0 -29
- package/src/commands/legacy.ts +0 -5
- package/src/commands/list.ts +0 -326
- package/src/commands/materialization/cancelrun.ts +0 -70
- package/src/commands/materialization/getindex.ts +0 -55
- package/src/commands/materialization/getmaterialization.ts +0 -57
- package/src/commands/materialization/getpreaggregate.ts +0 -58
- package/src/commands/materialization/getrun.ts +0 -55
- package/src/commands/materialization/listindexes.ts +0 -69
- package/src/commands/materialization/listmaterializations.ts +0 -53
- package/src/commands/materialization/listpreaggregates.ts +0 -74
- package/src/commands/materialization/listruns.ts +0 -77
- package/src/commands/materialization/rerun.ts +0 -123
- package/src/commands/misc/login.spec.ts +0 -371
- package/src/commands/misc/login.ts +0 -343
- package/src/commands/misc/logout.spec.ts +0 -32
- package/src/commands/misc/logout.ts +0 -9
- package/src/commands/misc/loopbackOAuth.ts +0 -127
- package/src/commands/misc/set-access-token.spec.ts +0 -95
- package/src/commands/misc/set-access-token.ts +0 -32
- package/src/commands/package/deletepackage.spec.ts +0 -164
- package/src/commands/package/deletepackage.ts +0 -58
- package/src/commands/package/listpackages.spec.ts +0 -163
- package/src/commands/package/listpackages.ts +0 -74
- package/src/commands/package/publish.spec.ts +0 -642
- package/src/commands/package/publish.ts +0 -236
- package/src/commands/package/updatepackage.spec.ts +0 -319
- package/src/commands/package/updatepackage.ts +0 -95
- package/src/commands/permission/createpermission.spec.ts +0 -507
- package/src/commands/permission/createpermission.ts +0 -181
- package/src/commands/permission/deletepermission.ts +0 -117
- package/src/commands/permission/getpermission.ts +0 -115
- package/src/commands/permission/listpermissions.ts +0 -101
- package/src/commands/permission/scope.ts +0 -180
- package/src/commands/rm.ts +0 -146
- package/src/commands/set.ts +0 -25
- package/src/commands/update.ts +0 -107
- package/src/commands/version/archive-unarchive-version.spec.ts +0 -456
- package/src/commands/version/archive-unarchive-version.ts +0 -108
- package/src/commands/version/listversions.spec.ts +0 -138
- package/src/commands/version/listversions.ts +0 -45
- package/src/common/UserGroupId.spec.ts +0 -115
- package/src/common/UserGroupId.ts +0 -137
- package/src/constants.spec.ts +0 -111
- package/src/constants.ts +0 -228
- package/src/index.ts +0 -378
- package/src/logger.spec.ts +0 -158
- package/src/logger.ts +0 -90
- package/src/polyfills/file.polyfill.ts +0 -6
- package/src/utils.spec.ts +0 -135
- package/src/utils.ts +0 -115
- package/src/validator.spec.ts +0 -51
- package/src/validator.ts +0 -44
- package/tsconfig.json +0 -17
|
@@ -1,343 +0,0 @@
|
|
|
1
|
-
import axios, { isAxiosError } from "axios";
|
|
2
|
-
import { jwtDecode } from "jwt-decode";
|
|
3
|
-
import { URLSearchParams } from "url";
|
|
4
|
-
import { OrganizationsApi } from "../../client/api";
|
|
5
|
-
import { Configuration } from "../../client/configuration";
|
|
6
|
-
import { ClientConfiguration } from "../../clientconfiguration";
|
|
7
|
-
import {
|
|
8
|
-
auth0ConfigsByEnv,
|
|
9
|
-
AUTH_CLI_LOOPBACK_REDIRECT_URI,
|
|
10
|
-
Cluster,
|
|
11
|
-
Environment,
|
|
12
|
-
getAuth0OrganizationIdForCliLogin,
|
|
13
|
-
LOGIN_TIMEOUT_MS,
|
|
14
|
-
} from "../../constants";
|
|
15
|
-
import { logger } from "../../logger";
|
|
16
|
-
import { printOutError, sleep } from "../../utils";
|
|
17
|
-
import * as loopbackOAuth from "./loopbackOAuth";
|
|
18
|
-
|
|
19
|
-
const organizationsApi = new OrganizationsApi(new Configuration());
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* True when argv is a `cred login ...` invocation (argv = [node, script,
|
|
23
|
-
* command, ...args]).
|
|
24
|
-
*
|
|
25
|
-
* Recovery from a corrupt `~/.cred` is scoped to this command only and must run
|
|
26
|
-
* at startup (see index.ts), before the eager config reads there. `cred login`
|
|
27
|
-
* is the one command whose job is to (re)establish config and the documented
|
|
28
|
-
* reset path; every other command must stay fail-loud so a stray read never
|
|
29
|
-
* silently resets a user's tokens.
|
|
30
|
-
*/
|
|
31
|
-
export function isLoginInvocation(argv: string[]): boolean {
|
|
32
|
-
return argv[2] === "login";
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export async function login(
|
|
36
|
-
organizationName: string,
|
|
37
|
-
controlPlaneBaseURL?: string,
|
|
38
|
-
configPath?: string,
|
|
39
|
-
cluster?: Cluster,
|
|
40
|
-
) {
|
|
41
|
-
const config = new ClientConfiguration(configPath);
|
|
42
|
-
const environment = config.getEnvironment();
|
|
43
|
-
|
|
44
|
-
if (environment === "e2e-test") {
|
|
45
|
-
return loginM2M(organizationName, config);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const auth0OrganizationId = getAuth0OrganizationIdForCliLogin(
|
|
49
|
-
organizationName,
|
|
50
|
-
cluster,
|
|
51
|
-
);
|
|
52
|
-
if (auth0OrganizationId) {
|
|
53
|
-
return loginWithAuthCodePkceOrganization(
|
|
54
|
-
environment,
|
|
55
|
-
organizationName,
|
|
56
|
-
controlPlaneBaseURL,
|
|
57
|
-
config,
|
|
58
|
-
auth0OrganizationId,
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return loginWithDeviceCode(
|
|
63
|
-
environment,
|
|
64
|
-
organizationName,
|
|
65
|
-
controlPlaneBaseURL,
|
|
66
|
-
config,
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
async function persistTokensAndVerifyOrganization(
|
|
71
|
-
tokenPayload: {
|
|
72
|
-
id_token?: string;
|
|
73
|
-
access_token: string;
|
|
74
|
-
refresh_token?: string;
|
|
75
|
-
},
|
|
76
|
-
organizationName: string,
|
|
77
|
-
controlPlaneBaseURL: string,
|
|
78
|
-
config: ClientConfiguration,
|
|
79
|
-
): Promise<void> {
|
|
80
|
-
if (tokenPayload.id_token) {
|
|
81
|
-
const decoded = jwtDecode(tokenPayload.id_token);
|
|
82
|
-
if (
|
|
83
|
-
typeof decoded === "object" &&
|
|
84
|
-
decoded !== null &&
|
|
85
|
-
"email" in decoded &&
|
|
86
|
-
"name" in decoded
|
|
87
|
-
) {
|
|
88
|
-
const user = decoded as { email?: string; name?: string };
|
|
89
|
-
config.setVSCodeUser(user.name, user.email);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
config.setAccessToken(true, tokenPayload.access_token);
|
|
94
|
-
config.setJwtAccessToken(tokenPayload.access_token);
|
|
95
|
-
if (tokenPayload.refresh_token) {
|
|
96
|
-
config.setRefreshToken(tokenPayload.refresh_token);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
try {
|
|
100
|
-
const response = await organizationsApi.getOrganization(
|
|
101
|
-
organizationName,
|
|
102
|
-
{
|
|
103
|
-
baseURL: controlPlaneBaseURL,
|
|
104
|
-
headers: config.getHeaders(),
|
|
105
|
-
},
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
if (response.status === 200) {
|
|
109
|
-
if (organizationName !== config.getOrganization()) {
|
|
110
|
-
config.setOrganization(organizationName);
|
|
111
|
-
config.setProject(undefined);
|
|
112
|
-
}
|
|
113
|
-
logger.info("Login successful");
|
|
114
|
-
}
|
|
115
|
-
} catch (error) {
|
|
116
|
-
if (!controlPlaneBaseURL.startsWith("https://")) {
|
|
117
|
-
const errorMsg =
|
|
118
|
-
error instanceof Error ? error.message : String(error);
|
|
119
|
-
logger.warn(
|
|
120
|
-
"Error with organziation check- might be bootstrapping. Ignoring: " +
|
|
121
|
-
errorMsg,
|
|
122
|
-
);
|
|
123
|
-
config.setOrganization(organizationName);
|
|
124
|
-
config.setProject(undefined);
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if (isAxiosError(error)) {
|
|
129
|
-
if (error.response?.status === 403 || error.response?.status === 404) {
|
|
130
|
-
logger.error(
|
|
131
|
-
`The organization "${organizationName}" does not exist, or you do not have permission to access it.`,
|
|
132
|
-
);
|
|
133
|
-
process.exit(1);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
throw error;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
async function loginWithAuthCodePkceOrganization(
|
|
141
|
-
environment: Environment,
|
|
142
|
-
organizationName: string,
|
|
143
|
-
controlPlaneBaseURL: string,
|
|
144
|
-
config: ClientConfiguration,
|
|
145
|
-
auth0OrganizationId: string,
|
|
146
|
-
): Promise<void> {
|
|
147
|
-
const auth0Domain = auth0ConfigsByEnv[environment].domain;
|
|
148
|
-
const auth0ClientId = auth0ConfigsByEnv[environment].clientId;
|
|
149
|
-
const audience = auth0ConfigsByEnv[environment].audience;
|
|
150
|
-
|
|
151
|
-
const { codeVerifier, codeChallenge } = loopbackOAuth.generatePkcePair();
|
|
152
|
-
const state = loopbackOAuth.generateOAuthState();
|
|
153
|
-
|
|
154
|
-
const authorizeParams = new URLSearchParams({
|
|
155
|
-
response_type: "code",
|
|
156
|
-
client_id: auth0ClientId,
|
|
157
|
-
redirect_uri: AUTH_CLI_LOOPBACK_REDIRECT_URI,
|
|
158
|
-
scope: "openid profile email offline_access",
|
|
159
|
-
audience,
|
|
160
|
-
organization: auth0OrganizationId,
|
|
161
|
-
code_challenge: codeChallenge,
|
|
162
|
-
code_challenge_method: "S256",
|
|
163
|
-
state,
|
|
164
|
-
});
|
|
165
|
-
const authorizeUrl = `${auth0Domain}/authorize?${authorizeParams.toString()}`;
|
|
166
|
-
|
|
167
|
-
try {
|
|
168
|
-
const { code } = await loopbackOAuth.authorizationCodeViaLoopback({
|
|
169
|
-
redirectUri: AUTH_CLI_LOOPBACK_REDIRECT_URI,
|
|
170
|
-
expectedState: state,
|
|
171
|
-
authorizeUrl,
|
|
172
|
-
timeoutMs: LOGIN_TIMEOUT_MS,
|
|
173
|
-
onListening: () => {
|
|
174
|
-
logger.info(
|
|
175
|
-
`Please visit the following URL to login ${authorizeUrl}`,
|
|
176
|
-
);
|
|
177
|
-
logger.info("Waiting for login...");
|
|
178
|
-
},
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
const tokenResponse = await axios.request({
|
|
182
|
-
method: "POST",
|
|
183
|
-
url: `${auth0Domain}/oauth/token`,
|
|
184
|
-
headers: { "content-type": "application/x-www-form-urlencoded" },
|
|
185
|
-
data: new URLSearchParams({
|
|
186
|
-
grant_type: "authorization_code",
|
|
187
|
-
client_id: auth0ClientId,
|
|
188
|
-
code,
|
|
189
|
-
redirect_uri: AUTH_CLI_LOOPBACK_REDIRECT_URI,
|
|
190
|
-
code_verifier: codeVerifier,
|
|
191
|
-
}),
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
await persistTokensAndVerifyOrganization(
|
|
195
|
-
tokenResponse.data,
|
|
196
|
-
organizationName,
|
|
197
|
-
controlPlaneBaseURL,
|
|
198
|
-
config,
|
|
199
|
-
);
|
|
200
|
-
} catch (e) {
|
|
201
|
-
if (isAxiosError(e)) {
|
|
202
|
-
const d = e.response?.data;
|
|
203
|
-
if (
|
|
204
|
-
typeof d === "object" &&
|
|
205
|
-
d !== null &&
|
|
206
|
-
"error" in d &&
|
|
207
|
-
d.error === "redirect_uri_mismatch"
|
|
208
|
-
) {
|
|
209
|
-
logger.error(
|
|
210
|
-
`Auth0 rejected the CLI callback URL. Add ${AUTH_CLI_LOOPBACK_REDIRECT_URI} to this application's Allowed Callback URLs in Auth0.`,
|
|
211
|
-
);
|
|
212
|
-
}
|
|
213
|
-
printOutError(e, false);
|
|
214
|
-
} else {
|
|
215
|
-
const msg = e instanceof Error ? e.message : String(e);
|
|
216
|
-
logger.error(msg);
|
|
217
|
-
}
|
|
218
|
-
process.exit(1);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
async function loginWithDeviceCode(
|
|
223
|
-
environment: Environment,
|
|
224
|
-
organizationName: string,
|
|
225
|
-
controlPlaneBaseURL: string,
|
|
226
|
-
config: ClientConfiguration,
|
|
227
|
-
) {
|
|
228
|
-
const auth0Domain = auth0ConfigsByEnv[environment].domain;
|
|
229
|
-
const auth0ClientId = auth0ConfigsByEnv[environment].clientId;
|
|
230
|
-
let deviceCodeData = null;
|
|
231
|
-
|
|
232
|
-
try {
|
|
233
|
-
const deviceCode = await axios.request({
|
|
234
|
-
method: "POST",
|
|
235
|
-
url: `${auth0Domain}/oauth/device/code`,
|
|
236
|
-
headers: { "content-type": "application/x-www-form-urlencoded" },
|
|
237
|
-
data: {
|
|
238
|
-
client_id: auth0ClientId,
|
|
239
|
-
audience: auth0ConfigsByEnv[environment].audience,
|
|
240
|
-
scope: "openid profile email offline_access",
|
|
241
|
-
},
|
|
242
|
-
});
|
|
243
|
-
deviceCodeData = deviceCode.data;
|
|
244
|
-
|
|
245
|
-
logger.info(
|
|
246
|
-
`Please visit the following URL to login ${deviceCode.data.verification_uri_complete} and verify user code ${deviceCode.data.user_code}.`,
|
|
247
|
-
);
|
|
248
|
-
logger.info("Waiting for login...");
|
|
249
|
-
} catch (e) {
|
|
250
|
-
printOutError(e, false);
|
|
251
|
-
process.exit(1);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
const startTime = Date.now();
|
|
255
|
-
|
|
256
|
-
while (true) {
|
|
257
|
-
try {
|
|
258
|
-
const accessToken = await axios.request({
|
|
259
|
-
method: "POST",
|
|
260
|
-
url: `${auth0Domain}/oauth/token`,
|
|
261
|
-
headers: { "content-type": "application/x-www-form-urlencoded" },
|
|
262
|
-
data: new URLSearchParams({
|
|
263
|
-
grant_type: "urn:ietf:params:oauth:grant-type:device_code",
|
|
264
|
-
device_code: deviceCodeData.device_code,
|
|
265
|
-
client_id: auth0ClientId,
|
|
266
|
-
}),
|
|
267
|
-
});
|
|
268
|
-
await persistTokensAndVerifyOrganization(
|
|
269
|
-
accessToken.data,
|
|
270
|
-
organizationName,
|
|
271
|
-
controlPlaneBaseURL,
|
|
272
|
-
config,
|
|
273
|
-
);
|
|
274
|
-
break;
|
|
275
|
-
} catch (error) {
|
|
276
|
-
if (
|
|
277
|
-
isAxiosError(error) &&
|
|
278
|
-
error.response?.data?.error !== "authorization_pending"
|
|
279
|
-
) {
|
|
280
|
-
const errorData = error.response?.data;
|
|
281
|
-
if (errorData) {
|
|
282
|
-
if (typeof errorData === "string") {
|
|
283
|
-
logger.error(errorData);
|
|
284
|
-
} else if (errorData.error_description) {
|
|
285
|
-
logger.error(errorData.error_description);
|
|
286
|
-
} else if (errorData.error) {
|
|
287
|
-
logger.error(errorData.error);
|
|
288
|
-
} else {
|
|
289
|
-
logger.error(JSON.stringify(errorData));
|
|
290
|
-
}
|
|
291
|
-
} else {
|
|
292
|
-
const errorMsg =
|
|
293
|
-
error instanceof Error ? error.message : String(error);
|
|
294
|
-
logger.error(errorMsg || "Unknown error occurred");
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
if (Date.now() - startTime > LOGIN_TIMEOUT_MS) {
|
|
298
|
-
logger.info("Login timed out after 5 minutes");
|
|
299
|
-
process.exit(1);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
await sleep(deviceCodeData.interval * 1000);
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
async function loginM2M(
|
|
308
|
-
organizationName: string,
|
|
309
|
-
config: ClientConfiguration,
|
|
310
|
-
): Promise<void> {
|
|
311
|
-
const auth0Config = auth0ConfigsByEnv["e2e-test"];
|
|
312
|
-
|
|
313
|
-
if (!auth0Config) {
|
|
314
|
-
throw new Error("No environment variables present for e2e");
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
try {
|
|
318
|
-
const response = await axios.request({
|
|
319
|
-
method: "POST",
|
|
320
|
-
url: `${auth0Config.domain}/oauth/token`,
|
|
321
|
-
headers: { "content-type": "application/x-www-form-urlencoded" },
|
|
322
|
-
data: {
|
|
323
|
-
grant_type: "client_credentials",
|
|
324
|
-
client_id: auth0Config.clientId,
|
|
325
|
-
client_secret: auth0Config.clientSecret,
|
|
326
|
-
audience: auth0Config.audience,
|
|
327
|
-
},
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
const token = response.data.access_token;
|
|
331
|
-
|
|
332
|
-
if (!token) {
|
|
333
|
-
throw new Error("No access token received");
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
config.destroyConfig();
|
|
337
|
-
config.setAccessToken(true, token);
|
|
338
|
-
config.setOrganization(organizationName);
|
|
339
|
-
} catch (e) {
|
|
340
|
-
printOutError(e, false);
|
|
341
|
-
process.exit(1);
|
|
342
|
-
}
|
|
343
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import sinon from "sinon";
|
|
3
|
-
import { ClientConfiguration } from "../../clientconfiguration";
|
|
4
|
-
import { logger } from "../../logger";
|
|
5
|
-
import { logout } from "./logout";
|
|
6
|
-
|
|
7
|
-
describe("logout", () => {
|
|
8
|
-
let sandbox: sinon.SinonSandbox;
|
|
9
|
-
let destroyConfigStub: sinon.SinonStub;
|
|
10
|
-
let loggerStub: sinon.SinonStubbedInstance<typeof logger>;
|
|
11
|
-
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
sandbox = sinon.createSandbox();
|
|
14
|
-
loggerStub = sandbox.stub(logger);
|
|
15
|
-
destroyConfigStub = sandbox.stub(
|
|
16
|
-
ClientConfiguration.prototype,
|
|
17
|
-
"destroyConfig",
|
|
18
|
-
);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
afterEach(() => {
|
|
22
|
-
sandbox.restore();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("should destroy config and log success message", () => {
|
|
26
|
-
logout();
|
|
27
|
-
|
|
28
|
-
expect(destroyConfigStub.calledOnce).to.be.true;
|
|
29
|
-
expect(loggerStub.info.calledWith(sinon.match("Credentials reset"))).to.be
|
|
30
|
-
.true;
|
|
31
|
-
});
|
|
32
|
-
});
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { createHash, randomBytes } from "crypto";
|
|
2
|
-
import http from "http";
|
|
3
|
-
import { URL } from "url";
|
|
4
|
-
|
|
5
|
-
export function generatePkcePair(): {
|
|
6
|
-
codeVerifier: string;
|
|
7
|
-
codeChallenge: string;
|
|
8
|
-
} {
|
|
9
|
-
const codeVerifier = randomBytes(32).toString("base64url");
|
|
10
|
-
const codeChallenge = createHash("sha256")
|
|
11
|
-
.update(codeVerifier)
|
|
12
|
-
.digest("base64url");
|
|
13
|
-
return { codeVerifier, codeChallenge };
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function generateOAuthState(): string {
|
|
17
|
-
return randomBytes(24).toString("base64url");
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Listens on loopback `redirectUri` for the OAuth redirect, then exchanges are done by the caller.
|
|
22
|
-
* Caller should print `authorizeUrl` as plain text (e.g. in {@link onListening}) — no browser auto-open.
|
|
23
|
-
* Used when the CLI must send `organization` on `/authorize` (Auth0 Organizations); the documented
|
|
24
|
-
* device-code endpoint does not list an `organization` parameter
|
|
25
|
-
* (https://auth0.com/docs/get-started/authentication-and-authorization-flow/device-authorization-flow/call-your-api-using-the-device-authorization-flow#device-code-parameters).
|
|
26
|
-
*/
|
|
27
|
-
export async function authorizationCodeViaLoopback(options: {
|
|
28
|
-
redirectUri: string;
|
|
29
|
-
expectedState: string;
|
|
30
|
-
authorizeUrl: string;
|
|
31
|
-
timeoutMs: number;
|
|
32
|
-
/** Invoked once the loopback server is ready (safe to tell the user to open the URL). */
|
|
33
|
-
onListening?: () => void;
|
|
34
|
-
}): Promise<{ code: string }> {
|
|
35
|
-
const {
|
|
36
|
-
redirectUri,
|
|
37
|
-
expectedState,
|
|
38
|
-
authorizeUrl: _authorizeUrl,
|
|
39
|
-
timeoutMs,
|
|
40
|
-
onListening,
|
|
41
|
-
} = options;
|
|
42
|
-
const parsed = new URL(redirectUri);
|
|
43
|
-
const port = Number(parsed.port);
|
|
44
|
-
const pathname = parsed.pathname;
|
|
45
|
-
|
|
46
|
-
if (!Number.isFinite(port) || port <= 0) {
|
|
47
|
-
throw new Error(
|
|
48
|
-
`Invalid redirect URI (need explicit port): ${redirectUri}`,
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return new Promise((resolve, reject) => {
|
|
53
|
-
let settled = false;
|
|
54
|
-
// eslint-disable-next-line prefer-const -- assign after finish/timer (handler may run before `const` bindings exist)
|
|
55
|
-
let server: http.Server | undefined;
|
|
56
|
-
|
|
57
|
-
const finish = (err: Error | null, result?: { code: string }) => {
|
|
58
|
-
if (settled) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
settled = true;
|
|
62
|
-
clearTimeout(timer);
|
|
63
|
-
server?.close();
|
|
64
|
-
if (err) {
|
|
65
|
-
reject(err);
|
|
66
|
-
} else {
|
|
67
|
-
resolve(result!);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const timer = setTimeout(() => {
|
|
72
|
-
finish(
|
|
73
|
-
new Error(
|
|
74
|
-
`Login timed out after ${Math.round(timeoutMs / 1000)} seconds`,
|
|
75
|
-
),
|
|
76
|
-
);
|
|
77
|
-
}, timeoutMs);
|
|
78
|
-
|
|
79
|
-
server = http.createServer((req, res) => {
|
|
80
|
-
if (settled || !req.url) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
try {
|
|
84
|
-
const reqUrl = new URL(req.url, `http://127.0.0.1:${port}`);
|
|
85
|
-
if (reqUrl.pathname !== pathname) {
|
|
86
|
-
res.writeHead(404);
|
|
87
|
-
res.end();
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
const code = reqUrl.searchParams.get("code");
|
|
91
|
-
const state = reqUrl.searchParams.get("state");
|
|
92
|
-
const error = reqUrl.searchParams.get("error");
|
|
93
|
-
|
|
94
|
-
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
95
|
-
res.end(
|
|
96
|
-
"<!DOCTYPE html><html><body><p>You can close this tab and return to the terminal.</p></body></html>",
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
if (error) {
|
|
100
|
-
finish(
|
|
101
|
-
new Error(
|
|
102
|
-
reqUrl.searchParams.get("error_description") || error,
|
|
103
|
-
),
|
|
104
|
-
);
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
if (!code || state !== expectedState) {
|
|
108
|
-
finish(new Error("Invalid authorization response"));
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
finish(null, { code });
|
|
112
|
-
} catch (e) {
|
|
113
|
-
finish(e instanceof Error ? e : new Error(String(e)));
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
server.on("error", (err) => finish(err));
|
|
118
|
-
|
|
119
|
-
server.listen(port, "127.0.0.1", () => {
|
|
120
|
-
try {
|
|
121
|
-
onListening?.();
|
|
122
|
-
} catch (e) {
|
|
123
|
-
finish(e instanceof Error ? e : new Error(String(e)));
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import sinon from "sinon";
|
|
3
|
-
import { ClientConfiguration } from "../../clientconfiguration";
|
|
4
|
-
import { logger } from "../../logger";
|
|
5
|
-
import { setAccessToken } from "./set-access-token";
|
|
6
|
-
|
|
7
|
-
describe("set-access-token", () => {
|
|
8
|
-
let sandbox: sinon.SinonSandbox;
|
|
9
|
-
let setAccessTokenStub: sinon.SinonStub;
|
|
10
|
-
let setJwtAccessTokenStub: sinon.SinonStub;
|
|
11
|
-
let setOrganizationStub: sinon.SinonStub;
|
|
12
|
-
let loggerStub: sinon.SinonStubbedInstance<typeof logger>;
|
|
13
|
-
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
sandbox = sinon.createSandbox();
|
|
16
|
-
loggerStub = sandbox.stub(logger);
|
|
17
|
-
setAccessTokenStub = sandbox.stub(
|
|
18
|
-
ClientConfiguration.prototype,
|
|
19
|
-
"setAccessToken",
|
|
20
|
-
);
|
|
21
|
-
setJwtAccessTokenStub = sandbox.stub(
|
|
22
|
-
ClientConfiguration.prototype,
|
|
23
|
-
"setJwtAccessToken",
|
|
24
|
-
);
|
|
25
|
-
setOrganizationStub = sandbox.stub(
|
|
26
|
-
ClientConfiguration.prototype,
|
|
27
|
-
"setOrganization",
|
|
28
|
-
);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
afterEach(() => {
|
|
32
|
-
sandbox.restore();
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("should set access token successfully", () => {
|
|
36
|
-
const jwtToken = "test-jwt-token";
|
|
37
|
-
|
|
38
|
-
setAccessToken(jwtToken);
|
|
39
|
-
|
|
40
|
-
expect(setAccessTokenStub.calledOnce).to.be.true;
|
|
41
|
-
expect(setAccessTokenStub.firstCall.args).to.deep.equal([
|
|
42
|
-
false,
|
|
43
|
-
jwtToken,
|
|
44
|
-
]);
|
|
45
|
-
expect(setJwtAccessTokenStub.calledOnce).to.be.true;
|
|
46
|
-
expect(setJwtAccessTokenStub.firstCall.args[0]).to.equal(jwtToken);
|
|
47
|
-
expect(
|
|
48
|
-
loggerStub.info.calledWith(
|
|
49
|
-
sinon.match("Access token set successfully"),
|
|
50
|
-
),
|
|
51
|
-
).to.be.true;
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("should set access token and organization when provided", () => {
|
|
55
|
-
const jwtToken = "test-jwt-token";
|
|
56
|
-
const organizationName = "test-org";
|
|
57
|
-
|
|
58
|
-
setAccessToken(jwtToken, organizationName);
|
|
59
|
-
|
|
60
|
-
expect(setAccessTokenStub.calledOnce).to.be.true;
|
|
61
|
-
expect(setJwtAccessTokenStub.calledOnce).to.be.true;
|
|
62
|
-
expect(setOrganizationStub.calledOnce).to.be.true;
|
|
63
|
-
expect(setOrganizationStub.firstCall.args[0]).to.equal(organizationName);
|
|
64
|
-
expect(
|
|
65
|
-
loggerStub.info.calledWith(
|
|
66
|
-
sinon.match("Access token set successfully"),
|
|
67
|
-
),
|
|
68
|
-
).to.be.true;
|
|
69
|
-
expect(
|
|
70
|
-
loggerStub.info.calledWith(
|
|
71
|
-
sinon.match(`Organization set to: ${organizationName}`),
|
|
72
|
-
),
|
|
73
|
-
).to.be.true;
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it("should not set organization when not provided", () => {
|
|
77
|
-
const jwtToken = "test-jwt-token";
|
|
78
|
-
|
|
79
|
-
setAccessToken(jwtToken);
|
|
80
|
-
|
|
81
|
-
expect(setOrganizationStub.called).to.be.false;
|
|
82
|
-
expect(loggerStub.info.calledWith(sinon.match(/Organization set to:/))).to
|
|
83
|
-
.be.false;
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it("should handle custom config path", () => {
|
|
87
|
-
const jwtToken = "test-jwt-token";
|
|
88
|
-
const configPath = "/custom/path/config.json";
|
|
89
|
-
|
|
90
|
-
setAccessToken(jwtToken, undefined, configPath);
|
|
91
|
-
|
|
92
|
-
expect(setAccessTokenStub.calledOnce).to.be.true;
|
|
93
|
-
expect(setJwtAccessTokenStub.calledOnce).to.be.true;
|
|
94
|
-
});
|
|
95
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { ClientConfiguration } from "../../clientconfiguration";
|
|
2
|
-
import { logger } from "../../logger";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Sets a service account JWT token for CLI authentication.
|
|
6
|
-
*
|
|
7
|
-
* @param jwtToken The JWT token to use for authentication
|
|
8
|
-
* @param organizationName Optional organization name to set
|
|
9
|
-
* @param configPath Optional custom config path
|
|
10
|
-
*/
|
|
11
|
-
export function setAccessToken(
|
|
12
|
-
jwtToken: string,
|
|
13
|
-
organizationName?: string,
|
|
14
|
-
configPath?: string,
|
|
15
|
-
) {
|
|
16
|
-
const config = new ClientConfiguration(configPath);
|
|
17
|
-
|
|
18
|
-
// Set the JWT token as both access token and JWT access token
|
|
19
|
-
config.setAccessToken(false, jwtToken);
|
|
20
|
-
config.setJwtAccessToken(jwtToken);
|
|
21
|
-
|
|
22
|
-
// Set organization if provided
|
|
23
|
-
if (organizationName) {
|
|
24
|
-
config.setOrganization(organizationName);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
logger.info("Access token set successfully");
|
|
28
|
-
|
|
29
|
-
if (organizationName) {
|
|
30
|
-
logger.info(`Organization set to: ${organizationName}`);
|
|
31
|
-
}
|
|
32
|
-
}
|