@oneaddress/setup 1.2.1 → 1.3.0
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/dist/index.js +30 -40
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -856,7 +856,7 @@ var _R = ["\u2588\u2588\u2588\u2588\u2588\u2588 ", "\u2588\u2588 \u2588\u2588"
|
|
|
856
856
|
var _S = [" \u2588\u2588\u2588\u2588\u2588\u2588", "\u2588\u2588 ", "\u2588\u2588 ", " \u2588\u2588\u2588\u2588\u2588 ", " \u2588\u2588", " \u2588\u2588", "\u2588\u2588\u2588\u2588\u2588\u2588 "];
|
|
857
857
|
var ONE_ROWS = Array.from({ length: 7 }, (_3, i) => [_O[i], _N[i], _E[i]].join(" "));
|
|
858
858
|
var ADDR_ROWS = Array.from({ length: 7 }, (_3, i) => [_A[i], _D2[i], _D2[i], _R[i], _E[i], _S[i], _S[i]].join(" "));
|
|
859
|
-
var WIZARD_VERSION = true ? "1.
|
|
859
|
+
var WIZARD_VERSION = true ? "1.3.0" : "?";
|
|
860
860
|
function printHeader() {
|
|
861
861
|
const BAR_LEN = 85;
|
|
862
862
|
const TOP_BAR = fn("\u250C") + dm("\u2500".repeat(BAR_LEN)) + fn("\u2510");
|
|
@@ -5201,7 +5201,7 @@ async function scaffold(platform, outputDir, partnerId, webhookSecret, webhookUr
|
|
|
5201
5201
|
|
|
5202
5202
|
// src/register.ts
|
|
5203
5203
|
var import_node_crypto = require("crypto");
|
|
5204
|
-
var PKG_VERSION = true ? "1.
|
|
5204
|
+
var PKG_VERSION = true ? "1.3.0" : "dev";
|
|
5205
5205
|
var REGISTER_URL = "https://partners.oneaddress.io/api/partner/installs";
|
|
5206
5206
|
function hmacSha256(secret, message) {
|
|
5207
5207
|
return (0, import_node_crypto.createHmac)("sha256", secret).update(message).digest("hex");
|
|
@@ -5759,20 +5759,26 @@ async function registerWebhookUrl(partnerId, webhookSecret, webhookUrl) {
|
|
|
5759
5759
|
}
|
|
5760
5760
|
}
|
|
5761
5761
|
|
|
5762
|
-
// src/
|
|
5762
|
+
// src/cli-gate.ts
|
|
5763
5763
|
var MAX_ATTEMPTS = 3;
|
|
5764
5764
|
var AUTH_URL = "https://partners.oneaddress.io/api/cli/auth";
|
|
5765
|
-
async function
|
|
5765
|
+
async function checkToken(token) {
|
|
5766
5766
|
try {
|
|
5767
5767
|
const res = await fetch(AUTH_URL, {
|
|
5768
5768
|
method: "POST",
|
|
5769
5769
|
headers: { "Content-Type": "application/json" },
|
|
5770
|
-
body: JSON.stringify({
|
|
5770
|
+
body: JSON.stringify({ token: token.trim() }),
|
|
5771
5771
|
signal: AbortSignal.timeout(8e3)
|
|
5772
5772
|
});
|
|
5773
|
-
if (res.status === 200)
|
|
5774
|
-
|
|
5775
|
-
|
|
5773
|
+
if (res.status === 200) {
|
|
5774
|
+
const data = await res.json().catch(() => ({}));
|
|
5775
|
+
if (data.ok && typeof data.partnerId === "string" && data.partnerId) {
|
|
5776
|
+
return { ok: true, partnerId: data.partnerId };
|
|
5777
|
+
}
|
|
5778
|
+
return { ok: false, reason: "Portal did not return a partner for this token, is it a CLI token from Profile \u2192 CLI Access?" };
|
|
5779
|
+
}
|
|
5780
|
+
if (res.status === 401) return { ok: false, reason: "Token not accepted" };
|
|
5781
|
+
if (res.status === 429) return { ok: false, reason: "Rate-limited, wait 60 s and retry", retryable: true };
|
|
5776
5782
|
const body = await res.json().catch(() => ({}));
|
|
5777
5783
|
return {
|
|
5778
5784
|
ok: false,
|
|
@@ -5787,35 +5793,26 @@ async function checkCredentials(user, pass) {
|
|
|
5787
5793
|
};
|
|
5788
5794
|
}
|
|
5789
5795
|
}
|
|
5790
|
-
async function
|
|
5796
|
+
async function cliGate() {
|
|
5791
5797
|
for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) {
|
|
5792
|
-
const
|
|
5793
|
-
message: attempt === 1 ? "OneAddress CLI
|
|
5794
|
-
|
|
5795
|
-
validate: (v2) => v2.trim() ? void 0 : "Username is required"
|
|
5796
|
-
});
|
|
5797
|
-
if (pD(user)) {
|
|
5798
|
-
xe("Cancelled.");
|
|
5799
|
-
process.exit(0);
|
|
5800
|
-
}
|
|
5801
|
-
const pass = await ge({
|
|
5802
|
-
message: "OneAddress CLI Password",
|
|
5803
|
-
validate: (v2) => v2.trim() ? void 0 : "Password is required"
|
|
5798
|
+
const token = await ge({
|
|
5799
|
+
message: attempt === 1 ? "OneAddress CLI token (Profile \u2192 CLI Access in the portal)" : `OneAddress CLI token (attempt ${attempt}/${MAX_ATTEMPTS})`,
|
|
5800
|
+
validate: (v2) => v2.trim() ? void 0 : "CLI token is required"
|
|
5804
5801
|
});
|
|
5805
|
-
if (pD(
|
|
5802
|
+
if (pD(token)) {
|
|
5806
5803
|
xe("Cancelled.");
|
|
5807
5804
|
process.exit(0);
|
|
5808
5805
|
}
|
|
5809
|
-
const result = await
|
|
5810
|
-
if (result.ok) return;
|
|
5806
|
+
const result = await checkToken(token);
|
|
5807
|
+
if (result.ok) return { partnerId: result.partnerId };
|
|
5811
5808
|
if (result.retryable) {
|
|
5812
|
-
M2.warn(` ${result.reason}
|
|
5809
|
+
M2.warn(` ${result.reason}, retry the same token.`);
|
|
5813
5810
|
attempt--;
|
|
5814
5811
|
continue;
|
|
5815
5812
|
}
|
|
5816
5813
|
if (attempt < MAX_ATTEMPTS) {
|
|
5817
5814
|
const remaining = MAX_ATTEMPTS - attempt;
|
|
5818
|
-
M2.error(` ${result.reason}
|
|
5815
|
+
M2.error(` ${result.reason}, ${remaining} attempt${remaining === 1 ? "" : "s"} remaining.`);
|
|
5819
5816
|
} else {
|
|
5820
5817
|
M2.error(` ${result.reason}.`);
|
|
5821
5818
|
}
|
|
@@ -5989,22 +5986,16 @@ function stripControlChars(line) {
|
|
|
5989
5986
|
async function main() {
|
|
5990
5987
|
printHeader();
|
|
5991
5988
|
Ie("OneAddress Partner Setup");
|
|
5992
|
-
await
|
|
5989
|
+
const { partnerId: pid } = await cliGate();
|
|
5990
|
+
if (!UUID_RE.test(pid)) {
|
|
5991
|
+
xe("The portal returned an unexpected partner id. Please retry, or contact support.");
|
|
5992
|
+
process.exit(1);
|
|
5993
|
+
}
|
|
5993
5994
|
M2.info("We will:");
|
|
5994
|
-
M2.info(" 1. Collect your credentials from the Partner Portal");
|
|
5995
|
+
M2.info(" 1. Collect your remaining credentials from the Partner Portal");
|
|
5995
5996
|
M2.info(" 2. Scaffold a working webhook server for your platform");
|
|
5996
5997
|
M2.info(" 3. Get it live with a passing conformance check \u2014 in under 5 minutes");
|
|
5997
|
-
M2.info("\nOpen partners.oneaddress.io \u2192 My Profile to find
|
|
5998
|
-
const partnerId = await he({
|
|
5999
|
-
message: "Your Partner ID (UUID format)",
|
|
6000
|
-
placeholder: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
|
|
6001
|
-
validate: (v2) => {
|
|
6002
|
-
if (!v2.trim()) return "Partner ID is required";
|
|
6003
|
-
if (!UUID_RE.test(v2.trim()))
|
|
6004
|
-
return "Must be a valid UUID \u2014 find it at partners.oneaddress.io \u2192 My Profile";
|
|
6005
|
-
}
|
|
6006
|
-
});
|
|
6007
|
-
assertNotCancelled(partnerId);
|
|
5998
|
+
M2.info("\nOpen partners.oneaddress.io \u2192 My Profile to find the two values below.\n");
|
|
6008
5999
|
const webhookSecret = await ge({
|
|
6009
6000
|
message: "Your Webhook Secret (min 20 chars)",
|
|
6010
6001
|
validate: (v2) => {
|
|
@@ -6024,7 +6015,6 @@ async function main() {
|
|
|
6024
6015
|
}
|
|
6025
6016
|
});
|
|
6026
6017
|
assertNotCancelled(privateKeyRaw);
|
|
6027
|
-
const pid = partnerId.trim();
|
|
6028
6018
|
const secret = webhookSecret.trim();
|
|
6029
6019
|
const normalised = normalisePrivateKey(privateKeyRaw.trim());
|
|
6030
6020
|
if (normalised.error) {
|