@witnium-tech/witniumchain 0.6.2 → 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 +59 -1
- package/dist/index.d.ts +59 -1
- package/dist/index.js +53 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +49 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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;
|
|
@@ -1392,7 +1393,7 @@ var WitniumchainChainAdminClient = class {
|
|
|
1392
1393
|
this.adminToken = config.adminToken;
|
|
1393
1394
|
this.adminTokenProvider = config.adminTokenProvider;
|
|
1394
1395
|
this.timeout = config.timeout ?? 3e4;
|
|
1395
|
-
this.fetchImpl = config.fetch ?? globalThis.fetch;
|
|
1396
|
+
this.fetchImpl = config.fetch ?? globalThis.fetch.bind(globalThis);
|
|
1396
1397
|
}
|
|
1397
1398
|
async deployContract(body) {
|
|
1398
1399
|
return this.req("POST", "/v5/contracts/deploy", body);
|
|
@@ -1513,6 +1514,50 @@ var OrgUsers = class {
|
|
|
1513
1514
|
}
|
|
1514
1515
|
};
|
|
1515
1516
|
|
|
1516
|
-
|
|
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 };
|
|
1517
1562
|
//# sourceMappingURL=index.mjs.map
|
|
1518
1563
|
//# sourceMappingURL=index.mjs.map
|