@witnium-tech/witniumchain 0.6.1 → 0.7.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.d.mts +158 -2
- package/dist/index.d.ts +158 -2
- package/dist/index.js +63 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +59 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -127,12 +127,13 @@ var WitniumchainClient = class {
|
|
|
127
127
|
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
128
128
|
this.chainBaseUrl = config.chainBaseUrl?.replace(/\/$/, "");
|
|
129
129
|
this.timeout = config.timeout ?? 3e4;
|
|
130
|
-
|
|
131
|
-
if (!
|
|
130
|
+
const resolvedFetch = config.fetch ?? (globalThis.fetch ? globalThis.fetch.bind(globalThis) : void 0);
|
|
131
|
+
if (!resolvedFetch) {
|
|
132
132
|
throw new Error(
|
|
133
133
|
"WitniumchainClient: no fetch implementation available. Pass `config.fetch`."
|
|
134
134
|
);
|
|
135
135
|
}
|
|
136
|
+
this.fetchImpl = resolvedFetch;
|
|
136
137
|
this.accessToken = config.accessToken;
|
|
137
138
|
this.oauthClientId = config.oauthClientId;
|
|
138
139
|
this.verifierStorage = config.verifierStorage;
|
|
@@ -412,6 +413,16 @@ var WitniumchainClient = class {
|
|
|
412
413
|
getLedger() {
|
|
413
414
|
return this.req("GET", "/v1/account/ledger", { auth: "SessionCookie" });
|
|
414
415
|
}
|
|
416
|
+
/**
|
|
417
|
+
* DEV-ONLY: hard-delete the authenticated user + their org + contracts +
|
|
418
|
+
* delegated keys so signup can be re-run from scratch. Gated behind
|
|
419
|
+
* WITNIUM_PRE_LAUNCH on the server (throws 403 otherwise). The on-chain
|
|
420
|
+
* contract is orphaned (immutable). Removed before customer onboarding —
|
|
421
|
+
* do not build product UI on this; it's a dev-loop convenience.
|
|
422
|
+
*/
|
|
423
|
+
deleteAccount() {
|
|
424
|
+
return this.req("DELETE", "/v1/account", { auth: "SessionCookie" });
|
|
425
|
+
}
|
|
415
426
|
// ────────────────────────────────────────────────────────────────────────
|
|
416
427
|
// MFA (/v1/account/mfa/*)
|
|
417
428
|
//
|
|
@@ -1382,7 +1393,7 @@ var WitniumchainChainAdminClient = class {
|
|
|
1382
1393
|
this.adminToken = config.adminToken;
|
|
1383
1394
|
this.adminTokenProvider = config.adminTokenProvider;
|
|
1384
1395
|
this.timeout = config.timeout ?? 3e4;
|
|
1385
|
-
this.fetchImpl = config.fetch ?? globalThis.fetch;
|
|
1396
|
+
this.fetchImpl = config.fetch ?? globalThis.fetch.bind(globalThis);
|
|
1386
1397
|
}
|
|
1387
1398
|
async deployContract(body) {
|
|
1388
1399
|
return this.req("POST", "/v5/contracts/deploy", body);
|
|
@@ -1503,6 +1514,50 @@ var OrgUsers = class {
|
|
|
1503
1514
|
}
|
|
1504
1515
|
};
|
|
1505
1516
|
|
|
1506
|
-
|
|
1517
|
+
// src/owner-ops.ts
|
|
1518
|
+
var OWNER_OP = {
|
|
1519
|
+
addSigningKey: 1,
|
|
1520
|
+
revokeSigningKey: 2,
|
|
1521
|
+
pause: 3,
|
|
1522
|
+
unpause: 4
|
|
1523
|
+
};
|
|
1524
|
+
function build(op, contractAddress, nonce, payload = {}) {
|
|
1525
|
+
if (!/^0x[0-9a-fA-F]{40}$/.test(contractAddress)) {
|
|
1526
|
+
throw new Error("contractAddress must be 0x + 40 hex chars");
|
|
1527
|
+
}
|
|
1528
|
+
if (!Number.isInteger(nonce) || nonce < 0) {
|
|
1529
|
+
throw new Error("nonce must be a non-negative integer");
|
|
1530
|
+
}
|
|
1531
|
+
return JSON.stringify({
|
|
1532
|
+
op,
|
|
1533
|
+
contract: contractAddress.toLowerCase(),
|
|
1534
|
+
nonce,
|
|
1535
|
+
...payload
|
|
1536
|
+
});
|
|
1537
|
+
}
|
|
1538
|
+
function buildPausePayload(args) {
|
|
1539
|
+
return build(OWNER_OP.pause, args.contractAddress, args.nonce);
|
|
1540
|
+
}
|
|
1541
|
+
function buildUnpausePayload(args) {
|
|
1542
|
+
return build(OWNER_OP.unpause, args.contractAddress, args.nonce);
|
|
1543
|
+
}
|
|
1544
|
+
function buildAddSigningKeyPayload(args) {
|
|
1545
|
+
if (!/^[0-9a-fA-F]{64}$/.test(args.newKey)) {
|
|
1546
|
+
throw new Error("newKey must be 64 hex chars (no 0x)");
|
|
1547
|
+
}
|
|
1548
|
+
return build(OWNER_OP.addSigningKey, args.contractAddress, args.nonce, {
|
|
1549
|
+
newKey: args.newKey
|
|
1550
|
+
});
|
|
1551
|
+
}
|
|
1552
|
+
function buildRevokeSigningKeyPayload(args) {
|
|
1553
|
+
if (!/^[0-9a-fA-F]{64}$/.test(args.key)) {
|
|
1554
|
+
throw new Error("key must be 64 hex chars (no 0x)");
|
|
1555
|
+
}
|
|
1556
|
+
return build(OWNER_OP.revokeSigningKey, args.contractAddress, args.nonce, {
|
|
1557
|
+
key: args.key
|
|
1558
|
+
});
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
export { DelegatedKeys, MfaNamespace, MfaRecoveryCodes, MfaTotp, OWNER_OP, OauthNamespace, OauthSessions, OrgUsers, SigningKeys, Subscriptions, WitniumchainAdminClient, WitniumchainApiError, WitniumchainChainAdminClient, WitniumchainClient, WitniumchainOrgClient, buildAddSigningKeyPayload, buildPausePayload, buildRevokeSigningKeyPayload, buildUnpausePayload, defaultVerifierStorage };
|
|
1507
1562
|
//# sourceMappingURL=index.mjs.map
|
|
1508
1563
|
//# sourceMappingURL=index.mjs.map
|