piral-cli 0.15.0-beta.4739 → 0.15.0-beta.4756
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/lib/common/interactive.js +34 -10
- package/lib/common/interactive.js.map +1 -1
- package/lib/external/index.js +4 -4
- package/package.json +3 -3
- package/src/common/interactive.ts +26 -10
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.getTokenInteractively = exports.promptConfirm = exports.promptSelect = void 0;
|
|
4
13
|
const browser_1 = require("./browser");
|
|
@@ -43,21 +52,36 @@ function getTokenInteractively(url, httpsAgent) {
|
|
|
43
52
|
headers: Object.assign(Object.assign({}, info_1.standardHeaders), { 'content-type': 'application/json' }),
|
|
44
53
|
httpsAgent,
|
|
45
54
|
})
|
|
46
|
-
.then((res) => {
|
|
55
|
+
.then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
47
56
|
const { loginUrl, callbackUrl, expires } = res.data;
|
|
48
57
|
const now = new Date();
|
|
49
58
|
const then = new Date(expires);
|
|
50
59
|
const diff = ~~((then.valueOf() - now.valueOf()) / (60 * 1000));
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
60
|
+
(0, log_1.logInfo)(`Use the URL below to complete the login. The link expires in ${diff} minutes (${then}).`);
|
|
61
|
+
(0, log_1.logInfo)('===');
|
|
62
|
+
(0, log_1.logInfo)(loginUrl);
|
|
63
|
+
(0, log_1.logInfo)('===');
|
|
55
64
|
(0, browser_1.openBrowserAt)(loginUrl);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
65
|
+
try {
|
|
66
|
+
while (true) {
|
|
67
|
+
const { data, status } = yield external_1.axios.default.get(callbackUrl);
|
|
68
|
+
if (status === 202) {
|
|
69
|
+
yield new Promise(resolve => setTimeout(resolve, 5000));
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (status === 200) {
|
|
73
|
+
return Object.assign({}, data);
|
|
74
|
+
}
|
|
75
|
+
throw new Error(`Could not get status from interactive login endpoint.`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch (ex) {
|
|
79
|
+
throw ex;
|
|
80
|
+
}
|
|
81
|
+
finally {
|
|
82
|
+
logResume();
|
|
83
|
+
}
|
|
84
|
+
}));
|
|
61
85
|
}
|
|
62
86
|
return tokenRetrievers[url];
|
|
63
87
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive.js","sourceRoot":"","sources":["../../src/common/interactive.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"interactive.js","sourceRoot":"","sources":["../../src/common/interactive.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,uCAA0C;AAC1C,iCAAyC;AACzC,+BAA4C;AAC5C,0CAA8C;AAG9C,SAAgB,YAAY,CAAC,OAAe,EAAE,MAAqB,EAAE,YAAoB;IACvF,MAAM,SAAS,GAAG;QAChB;YACE,IAAI,EAAE,GAAG;YACT,IAAI,EAAE,MAAe;YACrB,OAAO,EAAE,MAAM;YACf,OAAO;YACP,OAAO,EAAE,YAAY;SACtB;KACF,CAAC;IACF,OAAO,mBAAQ,CAAC,MAAM,CAAC,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AAE,GAAG,IAAI,CAAC,CAAC,CAAC;YAEhE,IAAA,aAAO,EAAC,gEAAgE,IAAI,aAAa,IAAI,IAAI,CAAC,CAAC;YACnG,IAAA,aAAO,EAAC,KAAK,CAAC,CAAC;YACf,IAAA,aAAO,EAAC,QAAQ,CAAC,CAAC;YAClB,IAAA,aAAO,EAAC,KAAK,CAAC,CAAC;YAEf,IAAA,uBAAa,EAAC,QAAQ,CAAC,CAAC;YAExB,IAAI;gBACF,OAAO,IAAI,EAAE;oBACX,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,gBAAK,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;oBAE9D,IAAI,MAAM,KAAK,GAAG,EAAE;wBAClB,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;wBACxD,SAAS;qBACV;oBAED,IAAI,MAAM,KAAK,GAAG,EAAE;wBAClB,yBAAY,IAAI,EAAG;qBACpB;oBAED,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;iBAC1E;aACF;YAAC,OAAO,EAAE,EAAE;gBACX,MAAM,EAAE,CAAC;aACV;oBAAS;gBACR,SAAS,EAAE,CAAC;aACb;QACH,CAAC,CAAA,CAAC,CAAC;KACN;IAED,OAAO,eAAe,CAAC,GAAG,CAAC,CAAC;AAC9B,CAAC;AAzDD,sDAyDC"}
|
package/lib/external/index.js
CHANGED
|
@@ -56876,9 +56876,9 @@ var require_asynckit = __commonJS({
|
|
|
56876
56876
|
}
|
|
56877
56877
|
});
|
|
56878
56878
|
|
|
56879
|
-
//
|
|
56879
|
+
// node_modules/form-data/lib/populate.js
|
|
56880
56880
|
var require_populate = __commonJS({
|
|
56881
|
-
"
|
|
56881
|
+
"node_modules/form-data/lib/populate.js"(exports, module2) {
|
|
56882
56882
|
module2.exports = function(dst, src) {
|
|
56883
56883
|
Object.keys(src).forEach(function(prop) {
|
|
56884
56884
|
dst[prop] = dst[prop] || src[prop];
|
|
@@ -56888,9 +56888,9 @@ var require_populate = __commonJS({
|
|
|
56888
56888
|
}
|
|
56889
56889
|
});
|
|
56890
56890
|
|
|
56891
|
-
//
|
|
56891
|
+
// node_modules/form-data/lib/form_data.js
|
|
56892
56892
|
var require_form_data = __commonJS({
|
|
56893
|
-
"
|
|
56893
|
+
"node_modules/form-data/lib/form_data.js"(exports, module2) {
|
|
56894
56894
|
var CombinedStream = require_combined_stream();
|
|
56895
56895
|
var util = require("util");
|
|
56896
56896
|
var path = require("path");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-cli",
|
|
3
|
-
"version": "0.15.0-beta.
|
|
3
|
+
"version": "0.15.0-beta.4756",
|
|
4
4
|
"description": "The standard CLI for creating and building a Piral instance or a Pilet.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"portal",
|
|
@@ -75,10 +75,10 @@
|
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
77
|
"dets": "^0.12.0",
|
|
78
|
-
"kras": "^0.15.
|
|
78
|
+
"kras": "^0.15.2",
|
|
79
79
|
"rimraf": "^3.0.0",
|
|
80
80
|
"typescript": "^4.7.3",
|
|
81
81
|
"yargs": "^15.4.1"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "ef910b00c2fca5f4df24f6e370bfda8e2ab7822e"
|
|
84
84
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Agent } from 'https';
|
|
2
2
|
import { openBrowserAt } from './browser';
|
|
3
3
|
import { standardHeaders } from './info';
|
|
4
|
-
import { logSuspend } from './log';
|
|
4
|
+
import { logSuspend, logInfo } from './log';
|
|
5
5
|
import { axios, inquirer } from '../external';
|
|
6
6
|
import { PiletPublishScheme } from '../types';
|
|
7
7
|
|
|
@@ -54,23 +54,39 @@ export function getTokenInteractively(url: string, httpsAgent: Agent): TokenResu
|
|
|
54
54
|
httpsAgent,
|
|
55
55
|
},
|
|
56
56
|
)
|
|
57
|
-
.then((res) => {
|
|
57
|
+
.then(async (res) => {
|
|
58
58
|
const { loginUrl, callbackUrl, expires } = res.data;
|
|
59
59
|
const now = new Date();
|
|
60
60
|
const then = new Date(expires);
|
|
61
61
|
const diff = ~~((then.valueOf() - now.valueOf()) / (60 * 1000));
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
logInfo(`Use the URL below to complete the login. The link expires in ${diff} minutes (${then}).`);
|
|
64
|
+
logInfo('===');
|
|
65
|
+
logInfo(loginUrl);
|
|
66
|
+
logInfo('===');
|
|
67
67
|
|
|
68
68
|
openBrowserAt(loginUrl);
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
try {
|
|
71
|
+
while (true) {
|
|
72
|
+
const { data, status } = await axios.default.get(callbackUrl);
|
|
73
|
+
|
|
74
|
+
if (status === 202) {
|
|
75
|
+
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (status === 200) {
|
|
80
|
+
return { ...data };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
throw new Error(`Could not get status from interactive login endpoint.`);
|
|
84
|
+
}
|
|
85
|
+
} catch (ex) {
|
|
86
|
+
throw ex;
|
|
87
|
+
} finally {
|
|
88
|
+
logResume();
|
|
89
|
+
}
|
|
74
90
|
});
|
|
75
91
|
}
|
|
76
92
|
|