@sentio/sdk 1.31.5 → 1.31.6
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.
|
@@ -36,6 +36,7 @@ const crypto = __importStar(require("crypto"));
|
|
|
36
36
|
const chalk_1 = __importDefault(require("chalk"));
|
|
37
37
|
const key_1 = require("../key");
|
|
38
38
|
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
39
|
+
const open_1 = __importDefault(require("open"));
|
|
39
40
|
const port = 20000;
|
|
40
41
|
function runLogin(argv) {
|
|
41
42
|
const optionDefinitions = [
|
|
@@ -100,7 +101,11 @@ function runLogin(argv) {
|
|
|
100
101
|
prompt: 'login',
|
|
101
102
|
});
|
|
102
103
|
authURL.search = params.toString();
|
|
103
|
-
console.log('Continue your authorization
|
|
104
|
+
console.log('Continue your authorization in the browser');
|
|
105
|
+
(0, open_1.default)(authURL.toString()).catch((reason) => {
|
|
106
|
+
console.error(chalk_1.default.red('Unable to open browser: ' + reason));
|
|
107
|
+
console.error(chalk_1.default.red('Open this url in your browser: ' + authURL.toString()));
|
|
108
|
+
});
|
|
104
109
|
(0, login_server_1.startServer)({
|
|
105
110
|
serverPort: port,
|
|
106
111
|
sentioHost: options.host,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-login.js","sourceRoot":"","sources":["../../../src/cli/commands/run-login.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0EAA+C;AAC/C,4EAAiD;AACjD,sCAA2D;AAC3D,iDAA4C;AAC5C,2CAA8B;AAC9B,+CAAgC;AAChC,kDAAyB;AACzB,gCAAiC;AACjC,4DAA8B;
|
|
1
|
+
{"version":3,"file":"run-login.js","sourceRoot":"","sources":["../../../src/cli/commands/run-login.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0EAA+C;AAC/C,4EAAiD;AACjD,sCAA2D;AAC3D,iDAA4C;AAC5C,2CA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AC7D,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,iCAAiC,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;QAClF,CAAC,CAAC,CAAA;QAEF,IAAA,0BAAW,EAAC;YACV,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,OAAO,CAAC,IAAI;YACxB,YAAY,EAAE,QAAQ;SACvB,CAAC,CAAA;KACH;AACH,CAAC;AA3ED,4BA2EC;AAED,SAAS,eAAe,CAAC,GAAW;IAClC,OAAO,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;AACzF,CAAC;AAED,SAAS,MAAM,CAAC,GAAW;IACzB,OAAO,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAA;AACzD,CAAC;AAED,KAAK,UAAU,QAAQ,CAAC,IAAY,EAAE,MAAc;IAClD,MAAM,cAAc,GAAG,IAAI,SAAG,CAAC,8BAA8B,EAAE,IAAI,CAAC,CAAA;IACpE,OAAO,IAAA,oBAAK,EAAC,cAAc,EAAE;QAC3B,MAAM,EAAE,KAAK;QACb,OAAO,EAAE;YACP,SAAS,EAAE,MAAM;SAClB;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import commandLineArgs from 'command-line-args'\nimport commandLineUsage from 'command-line-usage'\nimport { getAuthConfig, getFinalizedHost } from '../config'\nimport { startServer } from './login-server'\nimport url, { URL } from 'url'\nimport * as crypto from 'crypto'\nimport chalk from 'chalk'\nimport { WriteKey } from '../key'\nimport fetch from 'node-fetch'\nimport open from 'open'\n\nconst port = 20000\n\nexport function runLogin(argv: string[]) {\n const optionDefinitions = [\n {\n name: 'help',\n alias: 'h',\n type: Boolean,\n description: 'Display this usage guide.',\n },\n {\n name: 'host',\n description: '(Optional) Override Sentio Host name',\n type: String,\n },\n {\n name: 'api-key',\n type: String,\n description: '(Optional) Your API key',\n },\n ]\n const options = commandLineArgs(optionDefinitions, { argv })\n\n if (options.help) {\n const usage = commandLineUsage([\n {\n header: 'Login to Sentio',\n content: 'sentio login',\n },\n {\n header: 'Options',\n optionList: optionDefinitions,\n },\n ])\n console.log(usage)\n } else if (options['api-key']) {\n const host = getFinalizedHost(options.host)\n console.log(chalk.blue('login to ' + host))\n const apiKey = options['api-key']\n checkKey(host, apiKey).then((res) => {\n if (res.status == 200) {\n WriteKey(host, apiKey)\n console.log(chalk.green('login success'))\n } else {\n console.error(chalk.red('login failed, code:', res.status, res.statusText))\n }\n })\n } else {\n // https://auth0.com/docs/get-started/authentication-and-authorization-flow/call-your-api-using-the-authorization-code-flow-with-pkce\n const verifier = base64URLEncode(crypto.randomBytes(32))\n const challenge = base64URLEncode(sha256(verifier))\n\n const conf = getAuthConfig(options.host)\n const authURL = new URL(conf.domain + `/authorize?`)\n const params = new url.URLSearchParams({\n response_type: 'code',\n code_challenge: challenge,\n code_challenge_method: 'S256',\n client_id: conf.clientId,\n redirect_uri: `http://localhost:${port}/callback`,\n audience: conf.audience,\n prompt: 'login',\n })\n authURL.search = params.toString()\n\n console.log('Continue your authorization in the browser')\n open(authURL.toString()).catch((reason) => {\n console.error(chalk.red('Unable to open browser: ' + reason))\n console.error(chalk.red('Open this url in your browser: ' + authURL.toString()))\n })\n\n startServer({\n serverPort: port,\n sentioHost: options.host,\n codeVerifier: verifier,\n })\n }\n}\n\nfunction base64URLEncode(str: Buffer) {\n return str.toString('base64').replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=/g, '')\n}\n\nfunction sha256(str: string) {\n return crypto.createHash('sha256').update(str).digest()\n}\n\nasync function checkKey(host: string, apiKey: string) {\n const checkApiKeyUrl = new URL('/api/v1/processors/check_key', host)\n return fetch(checkApiKeyUrl, {\n method: 'GET',\n headers: {\n 'api-key': apiKey,\n },\n })\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentio/sdk",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "1.31.
|
|
4
|
+
"version": "1.31.6",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"compile_target": "yarn tsc -b src/target-ethers-sentio/tsconfig.json",
|
|
7
7
|
"compile": "tsc -p . && cp src/cli/webpack.config.js lib/cli && cp src/utils/*.csv lib/utils",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"nice-grpc-client-middleware-retry": "^2.0.1",
|
|
46
46
|
"nice-grpc-error-details": "^0.1.4",
|
|
47
47
|
"node-fetch": "2",
|
|
48
|
+
"open": "^8.4.0",
|
|
48
49
|
"p-queue": "^6.6.2",
|
|
49
50
|
"ts-loader": "^9.3.0",
|
|
50
51
|
"typechain": "^8.0.0",
|
|
@@ -7,6 +7,7 @@ import * as crypto from 'crypto'
|
|
|
7
7
|
import chalk from 'chalk'
|
|
8
8
|
import { WriteKey } from '../key'
|
|
9
9
|
import fetch from 'node-fetch'
|
|
10
|
+
import open from 'open'
|
|
10
11
|
|
|
11
12
|
const port = 20000
|
|
12
13
|
|
|
@@ -72,7 +73,12 @@ export function runLogin(argv: string[]) {
|
|
|
72
73
|
prompt: 'login',
|
|
73
74
|
})
|
|
74
75
|
authURL.search = params.toString()
|
|
75
|
-
|
|
76
|
+
|
|
77
|
+
console.log('Continue your authorization in the browser')
|
|
78
|
+
open(authURL.toString()).catch((reason) => {
|
|
79
|
+
console.error(chalk.red('Unable to open browser: ' + reason))
|
|
80
|
+
console.error(chalk.red('Open this url in your browser: ' + authURL.toString()))
|
|
81
|
+
})
|
|
76
82
|
|
|
77
83
|
startServer({
|
|
78
84
|
serverPort: port,
|