@wishknish/knishio-client-ts 0.8.2 → 0.9.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.cjs +425 -263
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +44 -17
- package/dist/index.d.ts +44 -17
- package/dist/index.iife.js +425 -265
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +447 -285
- package/dist/index.js.map +1 -1
- package/package.json +6 -9
- package/src/KnishIOClient.ts +180 -57
- package/src/constants.ts +1 -2
- package/src/core/Molecule.ts +53 -0
- package/src/core/Wallet.ts +84 -3
- package/src/libraries/Decimal.ts +1 -1
- package/src/libraries/GraphQLClient.ts +83 -0
- package/src/libraries/Hex.ts +4 -3
- package/src/libraries/UrqlClientWrapper.ts +13 -13
- package/src/libraries/crypto.ts +4 -4
- package/src/mutation/MutationClaimShadowWallet.ts +3 -1
- package/src/mutation/MutationTransferTokens.ts +18 -0
- package/src/query/QueryActiveSession.ts +0 -1
- package/src/query/QueryPolicy.ts +0 -1
- package/src/response/ResponseAuthorizationGuest.ts +2 -2
- package/src/response/ResponseBalance.ts +9 -6
- package/src/response/ResponseLinkIdentifier.ts +1 -1
- package/src/response/ResponseRequestAuthorizationGuest.ts +2 -2
- package/src/schemas/index.ts +2 -1
- package/src/subscribe/Subscribe.ts +3 -2
- package/src/types/assertions.ts +1 -6
- package/src/types/client.ts +12 -19
- package/src/types/guards.ts +2 -3
- package/src/types/index.ts +6 -0
- package/src/validation/UNIVERSAL_CONFIGURATION_INTERFACES.ts +3 -5
- package/src/validation/ValidationService.ts +6 -15
- package/src/validation/schemas.ts +5 -1
- package/src/versions/HashAtom.ts +11 -9
- package/src/query/QueryUserActivity.ts +0 -153
- package/src/response/ResponseQueryUserActivity.ts +0 -89
package/dist/index.js
CHANGED
|
@@ -939,9 +939,19 @@ var init_StackableUnitAmountException = __esm({
|
|
|
939
939
|
});
|
|
940
940
|
|
|
941
941
|
// src/exception/StackableUnitDecimalsException.ts
|
|
942
|
+
var StackableUnitDecimalsException, StackableUnitDecimalsException_default;
|
|
942
943
|
var init_StackableUnitDecimalsException = __esm({
|
|
943
944
|
"src/exception/StackableUnitDecimalsException.ts"() {
|
|
944
945
|
init_BaseException();
|
|
946
|
+
StackableUnitDecimalsException = class extends BaseException {
|
|
947
|
+
/**
|
|
948
|
+
* Constructor using proper error type
|
|
949
|
+
*/
|
|
950
|
+
constructor(message = "Stackable tokens with unit IDs cannot have decimal places!") {
|
|
951
|
+
super("STACKABLE_UNIT_DECIMALS_ERROR", message);
|
|
952
|
+
}
|
|
953
|
+
};
|
|
954
|
+
StackableUnitDecimalsException_default = StackableUnitDecimalsException;
|
|
945
955
|
}
|
|
946
956
|
});
|
|
947
957
|
|
|
@@ -1560,15 +1570,15 @@ var init_EnhancedResponse = __esm({
|
|
|
1560
1570
|
// src/response/Response.ts
|
|
1561
1571
|
var Response_exports = {};
|
|
1562
1572
|
__export(Response_exports, {
|
|
1563
|
-
default: () =>
|
|
1573
|
+
default: () => Response2
|
|
1564
1574
|
});
|
|
1565
|
-
var
|
|
1575
|
+
var Response2;
|
|
1566
1576
|
var init_Response = __esm({
|
|
1567
1577
|
"src/response/Response.ts"() {
|
|
1568
1578
|
init_exception();
|
|
1569
1579
|
init_Dot();
|
|
1570
1580
|
init_EnhancedResponse();
|
|
1571
|
-
|
|
1581
|
+
Response2 = class {
|
|
1572
1582
|
dataKey;
|
|
1573
1583
|
errorKey = "exception";
|
|
1574
1584
|
$__payload = null;
|
|
@@ -1923,9 +1933,6 @@ function generateSecret(seed = null, length = CRYPTO_CONSTANTS.SECRET_LENGTH) {
|
|
|
1923
1933
|
}
|
|
1924
1934
|
}
|
|
1925
1935
|
function generateBundleHash(secret, _source = null) {
|
|
1926
|
-
if (!secret || secret.length === 0) {
|
|
1927
|
-
throw new Error("Secret is required for bundle hash generation");
|
|
1928
|
-
}
|
|
1929
1936
|
const hash = shake256(secret, CRYPTO_CONSTANTS.BUNDLE_HASH_LENGTH * 4);
|
|
1930
1937
|
return hash;
|
|
1931
1938
|
}
|
|
@@ -3336,8 +3343,7 @@ var QUERY_TYPES = [
|
|
|
3336
3343
|
"Batch",
|
|
3337
3344
|
"ActiveSession",
|
|
3338
3345
|
"Policy",
|
|
3339
|
-
"Token"
|
|
3340
|
-
"UserActivity"
|
|
3346
|
+
"Token"
|
|
3341
3347
|
];
|
|
3342
3348
|
function createLookup(values) {
|
|
3343
3349
|
return values.reduce((acc, value) => {
|
|
@@ -3596,6 +3602,29 @@ var Wallet = class _Wallet {
|
|
|
3596
3602
|
}
|
|
3597
3603
|
remainderWallet.tokenUnits = remainderTokenUnits;
|
|
3598
3604
|
}
|
|
3605
|
+
/**
|
|
3606
|
+
* Split token units across MULTIPLE recipients (N-way sibling of splitUnits).
|
|
3607
|
+
*
|
|
3608
|
+
* The source retains the SENT union (all units leaving), each recipient gets its own
|
|
3609
|
+
* subset, and the remainder keeps the KEPT units (those not assigned to any recipient).
|
|
3610
|
+
* recipientUnitLists is parallel to recipientWallets. No-op when no units are sent.
|
|
3611
|
+
*
|
|
3612
|
+
* @param recipientUnitLists - per-recipient arrays of token unit IDs (parallel to recipientWallets)
|
|
3613
|
+
* @param recipientWallets - destination wallets
|
|
3614
|
+
* @param remainderWallet - wallet to receive the KEPT units
|
|
3615
|
+
*/
|
|
3616
|
+
splitUnitsMulti(recipientUnitLists, recipientWallets, remainderWallet) {
|
|
3617
|
+
const sentIds = new Set(recipientUnitLists.flat());
|
|
3618
|
+
if (sentIds.size === 0) {
|
|
3619
|
+
return;
|
|
3620
|
+
}
|
|
3621
|
+
recipientWallets.forEach((recipientWallet, i) => {
|
|
3622
|
+
const ids = recipientUnitLists[i] ?? [];
|
|
3623
|
+
recipientWallet.tokenUnits = this.tokenUnits.filter((tokenUnit) => ids.includes(tokenUnit.id));
|
|
3624
|
+
});
|
|
3625
|
+
remainderWallet.tokenUnits = this.tokenUnits.filter((tokenUnit) => !sentIds.has(tokenUnit.id));
|
|
3626
|
+
this.tokenUnits = this.tokenUnits.filter((tokenUnit) => sentIds.has(tokenUnit.id));
|
|
3627
|
+
}
|
|
3599
3628
|
/**
|
|
3600
3629
|
* Get token units data
|
|
3601
3630
|
* Stub for compatibility
|
|
@@ -3642,6 +3671,15 @@ var Wallet = class _Wallet {
|
|
|
3642
3671
|
};
|
|
3643
3672
|
}
|
|
3644
3673
|
async decryptMessage(encryptedData) {
|
|
3674
|
+
const decryptedString = await this._mlkemDecryptToString(encryptedData);
|
|
3675
|
+
return decryptedString === null ? null : JSON.parse(decryptedString);
|
|
3676
|
+
}
|
|
3677
|
+
/**
|
|
3678
|
+
* ML-KEM768 decapsulate + AES-256-GCM decrypt → the RAW decrypted UTF-8 string (no JSON.parse).
|
|
3679
|
+
* Shared by {@link decryptMessage} (which JSON.parses the result) and the PQ CipherHash transport
|
|
3680
|
+
* ({@link decryptMyMessageML768}, which needs the raw response JSON text). PQ-transport Phase E.
|
|
3681
|
+
*/
|
|
3682
|
+
async _mlkemDecryptToString(encryptedData) {
|
|
3645
3683
|
const { cipherText, encryptedMessage } = encryptedData;
|
|
3646
3684
|
let sharedSecret;
|
|
3647
3685
|
try {
|
|
@@ -3670,9 +3708,8 @@ var Wallet = class _Wallet {
|
|
|
3670
3708
|
console.info("Wallet::decryptMessage() - deserialized encrypted message", deserializedEncryptedMessage);
|
|
3671
3709
|
return null;
|
|
3672
3710
|
}
|
|
3673
|
-
let decryptedString;
|
|
3674
3711
|
try {
|
|
3675
|
-
|
|
3712
|
+
return new TextDecoder().decode(decryptedUint8);
|
|
3676
3713
|
} catch (e) {
|
|
3677
3714
|
console.warn("Wallet::decryptMessage() - Decoding failed", e);
|
|
3678
3715
|
console.info("Wallet::decryptMessage() - my public key", this.pubkey);
|
|
@@ -3681,7 +3718,40 @@ var Wallet = class _Wallet {
|
|
|
3681
3718
|
console.info("Wallet::decryptMessage() - decrypted Uint8Array", decryptedUint8);
|
|
3682
3719
|
return null;
|
|
3683
3720
|
}
|
|
3684
|
-
|
|
3721
|
+
}
|
|
3722
|
+
/**
|
|
3723
|
+
* Canonical cross-SDK hashShare for a public key: standard base64 of SHAKE256(pubkey_utf8, 8 bytes)
|
|
3724
|
+
* — byte-matches the validator's hash_share and the JS/Kotlin/PHP hashShare. `shake256(pubkey, 64)`
|
|
3725
|
+
* = 64 bits = 8 bytes (hex) → hex-decode → standard base64 via serializeKey. PQ-transport Phase E.
|
|
3726
|
+
*/
|
|
3727
|
+
hashShare(pubkey) {
|
|
3728
|
+
const hex = shake256(pubkey, 64);
|
|
3729
|
+
const bytes = new Uint8Array(hex.length / 2);
|
|
3730
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
3731
|
+
bytes[i] = parseInt(hex.substr(i * 2, 2), 16);
|
|
3732
|
+
}
|
|
3733
|
+
return this.serializeKey(bytes);
|
|
3734
|
+
}
|
|
3735
|
+
/**
|
|
3736
|
+
* Post-quantum (ML-KEM768) CipherHash request envelope: a stringified single-recipient map
|
|
3737
|
+
* `{ "<hashShare(recipientPubkey)>": {cipherText, encryptedMessage} }` (object-valued, via
|
|
3738
|
+
* {@link encryptMessage}). Matches the Rust validator's CipherHash handler. PQ-transport Phase E.
|
|
3739
|
+
*/
|
|
3740
|
+
async encryptStringML768(message, recipientPubkey) {
|
|
3741
|
+
const envelope = await this.encryptMessage(message, recipientPubkey);
|
|
3742
|
+
return JSON.stringify({ [this.hashShare(recipientPubkey)]: envelope });
|
|
3743
|
+
}
|
|
3744
|
+
/**
|
|
3745
|
+
* Decrypt a CipherHash response map addressed to THIS wallet's ML-KEM pubkey
|
|
3746
|
+
* (`hashShare(this.pubkey)`) → the RAW decrypted GraphQL response JSON text (NOT JSON.parsed;
|
|
3747
|
+
* it replaces the HTTP response body for the normal parser). `null` if no entry / decrypt fails.
|
|
3748
|
+
*/
|
|
3749
|
+
async decryptMyMessageML768(map) {
|
|
3750
|
+
const envelope = map[this.hashShare(this.pubkey)];
|
|
3751
|
+
if (!envelope) {
|
|
3752
|
+
return null;
|
|
3753
|
+
}
|
|
3754
|
+
return this._mlkemDecryptToString(envelope);
|
|
3685
3755
|
}
|
|
3686
3756
|
// =============================================================================
|
|
3687
3757
|
// SYMMETRIC ENCRYPTION HELPERS (AES-GCM with shared secret)
|
|
@@ -3806,7 +3876,8 @@ z.object({
|
|
|
3806
3876
|
client: z.unknown().optional(),
|
|
3807
3877
|
socket: z.unknown().optional(),
|
|
3808
3878
|
serverSdkVersion: z.number().int().min(1).optional(),
|
|
3809
|
-
logging: z.boolean().optional()
|
|
3879
|
+
logging: z.boolean().optional(),
|
|
3880
|
+
defaultRequestPolicy: z.enum(["cache-first", "cache-only", "network-only", "cache-and-network"]).nullable().optional()
|
|
3810
3881
|
}).strict();
|
|
3811
3882
|
z.object({
|
|
3812
3883
|
token: z.string().min(1, "Auth token cannot be empty"),
|
|
@@ -4979,6 +5050,46 @@ var Molecule = class _Molecule {
|
|
|
4979
5050
|
}));
|
|
4980
5051
|
return this;
|
|
4981
5052
|
}
|
|
5053
|
+
/**
|
|
5054
|
+
* Initialize a MULTI-recipient V-type molecule: one source debits its FULL balance to fund
|
|
5055
|
+
* N recipients (each its own amount + stackable units) plus a remainder back to the sender.
|
|
5056
|
+
* Multi-recipient sibling of initValue (WP line 544: fund multiple recipients with one
|
|
5057
|
+
* transaction). recipientWallets is parallel to amounts.
|
|
5058
|
+
*/
|
|
5059
|
+
initValues({
|
|
5060
|
+
recipientWallets,
|
|
5061
|
+
amounts
|
|
5062
|
+
}) {
|
|
5063
|
+
if (!this.sourceWallet) {
|
|
5064
|
+
throw new Error("Source wallet required for value transfer");
|
|
5065
|
+
}
|
|
5066
|
+
const total = amounts.reduce((sum, amount) => sum + amount, 0);
|
|
5067
|
+
if (Number(this.sourceWallet.balance) - total < 0) {
|
|
5068
|
+
throw new BalanceInsufficientException();
|
|
5069
|
+
}
|
|
5070
|
+
this.addAtom(Atom.create({
|
|
5071
|
+
isotope: "V",
|
|
5072
|
+
wallet: this.sourceWallet,
|
|
5073
|
+
value: -Number(this.sourceWallet.balance)
|
|
5074
|
+
}));
|
|
5075
|
+
recipientWallets.forEach((recipientWallet, i) => {
|
|
5076
|
+
this.addAtom(Atom.create({
|
|
5077
|
+
isotope: "V",
|
|
5078
|
+
wallet: recipientWallet,
|
|
5079
|
+
value: amounts[i],
|
|
5080
|
+
metaType: "walletBundle",
|
|
5081
|
+
metaId: recipientWallet.bundle
|
|
5082
|
+
}));
|
|
5083
|
+
});
|
|
5084
|
+
this.addAtom(Atom.create({
|
|
5085
|
+
isotope: "V",
|
|
5086
|
+
wallet: this.remainderWallet,
|
|
5087
|
+
value: Number(this.sourceWallet.balance) - total,
|
|
5088
|
+
metaType: "walletBundle",
|
|
5089
|
+
metaId: this.remainderWallet.bundle
|
|
5090
|
+
}));
|
|
5091
|
+
return this;
|
|
5092
|
+
}
|
|
4982
5093
|
/**
|
|
4983
5094
|
* Sign the molecule with one-time signature
|
|
4984
5095
|
* Matches JavaScript SDK sign method
|
|
@@ -5736,7 +5847,7 @@ var Decimal = class _Decimal {
|
|
|
5736
5847
|
* @param debug Enable debug logging
|
|
5737
5848
|
* @returns 0 if equal, 1 if value1 > value2, -1 if value1 < value2
|
|
5738
5849
|
*/
|
|
5739
|
-
static cmp(value1, value2,
|
|
5850
|
+
static cmp(value1, value2, _debug = false) {
|
|
5740
5851
|
const val1 = _Decimal.val(value1) * MULTIPLIER;
|
|
5741
5852
|
const val2 = _Decimal.val(value2) * MULTIPLIER;
|
|
5742
5853
|
if (Math.abs(val1 - val2) < 1) {
|
|
@@ -5751,6 +5862,14 @@ var Decimal = class _Decimal {
|
|
|
5751
5862
|
return _Decimal.cmp(value1, value2) === 0;
|
|
5752
5863
|
}
|
|
5753
5864
|
};
|
|
5865
|
+
var CIPHER_HASH_QUERY = "query ( $Hash: String! ) { CipherHash ( Hash: $Hash ) { hash } }";
|
|
5866
|
+
function parseOperation(query) {
|
|
5867
|
+
const typeMatch = (query || "").match(/\b(query|mutation|subscription)\b/i);
|
|
5868
|
+
const type = typeMatch?.[1]?.toLowerCase() ?? "query";
|
|
5869
|
+
const braceIdx = (query || "").indexOf("{");
|
|
5870
|
+
const nameMatch = braceIdx >= 0 ? query.slice(braceIdx + 1).match(/[A-Za-z_][A-Za-z0-9_]*/) : null;
|
|
5871
|
+
return { type, name: nameMatch?.[0] ?? "" };
|
|
5872
|
+
}
|
|
5754
5873
|
var GraphQLClient = class {
|
|
5755
5874
|
$__client;
|
|
5756
5875
|
$__authToken = "";
|
|
@@ -5796,6 +5915,10 @@ var GraphQLClient = class {
|
|
|
5796
5915
|
return createClient$1({
|
|
5797
5916
|
url: serverUri,
|
|
5798
5917
|
exchanges,
|
|
5918
|
+
// PQ-transport Phase E: when encryption is on, route fetch through the CipherHash wrapper
|
|
5919
|
+
// (encrypt the request body to the validator's ML-KEM pubkey, decrypt the response).
|
|
5920
|
+
// Omitted → urql uses the global fetch (plaintext).
|
|
5921
|
+
...this.cipherLink ? { fetch: ((input, init) => this.cipherFetch(input, init)) } : {},
|
|
5799
5922
|
fetchOptions: () => ({
|
|
5800
5923
|
headers: {
|
|
5801
5924
|
"X-Auth-Token": this.$__authToken
|
|
@@ -5805,6 +5928,62 @@ var GraphQLClient = class {
|
|
|
5805
5928
|
})
|
|
5806
5929
|
});
|
|
5807
5930
|
}
|
|
5931
|
+
/**
|
|
5932
|
+
* Whether an outgoing GraphQL request body should be wrapped in CipherHash. Bypass (plaintext):
|
|
5933
|
+
* introspection `__schema`, `ContinuId`, the `AccessToken` mutation, and the U-isotope
|
|
5934
|
+
* `ProposeMolecule` (auth bootstrap — the key exchange itself can't be encrypted). Mirrors the
|
|
5935
|
+
* Kotlin/PHP/validator bypass set.
|
|
5936
|
+
*/
|
|
5937
|
+
shouldEncrypt(body) {
|
|
5938
|
+
let parsed;
|
|
5939
|
+
try {
|
|
5940
|
+
parsed = JSON.parse(body);
|
|
5941
|
+
} catch (e) {
|
|
5942
|
+
return false;
|
|
5943
|
+
}
|
|
5944
|
+
const { type, name } = parseOperation(parsed.query);
|
|
5945
|
+
if (type === "query" && (name === "__schema" || name === "ContinuId")) return false;
|
|
5946
|
+
if (type === "mutation" && name === "AccessToken") return false;
|
|
5947
|
+
if (type === "mutation" && name === "ProposeMolecule") {
|
|
5948
|
+
const isotope = parsed.variables?.molecule?.atoms?.[0]?.isotope;
|
|
5949
|
+
if (isotope === "U") return false;
|
|
5950
|
+
}
|
|
5951
|
+
return true;
|
|
5952
|
+
}
|
|
5953
|
+
/**
|
|
5954
|
+
* Custom `fetch` that wraps a GraphQL request in the ML-KEM CipherHash envelope and decrypts the
|
|
5955
|
+
* response (PQ-transport Phase E). Operates on the raw POST body (mirrors the JS/Kotlin transform).
|
|
5956
|
+
* Reads the CURRENT client wallet + validator pubkey from auth.
|
|
5957
|
+
*/
|
|
5958
|
+
async cipherFetch(input, init) {
|
|
5959
|
+
const wallet = this.$__wallet;
|
|
5960
|
+
const serverPubkey = this.$__pubkey;
|
|
5961
|
+
let encryptedRequest = false;
|
|
5962
|
+
let requestInit = init;
|
|
5963
|
+
if (wallet && serverPubkey && init && typeof init.body === "string" && this.shouldEncrypt(init.body)) {
|
|
5964
|
+
const hashVar = await wallet.encryptStringML768(init.body, serverPubkey);
|
|
5965
|
+
requestInit = { ...init, body: JSON.stringify({ query: CIPHER_HASH_QUERY, variables: { Hash: hashVar } }) };
|
|
5966
|
+
encryptedRequest = true;
|
|
5967
|
+
}
|
|
5968
|
+
const response = await fetch(input, requestInit);
|
|
5969
|
+
if (!encryptedRequest) {
|
|
5970
|
+
return response;
|
|
5971
|
+
}
|
|
5972
|
+
const text = await response.text();
|
|
5973
|
+
const init2 = { status: response.status, statusText: response.statusText, headers: response.headers };
|
|
5974
|
+
let parsed;
|
|
5975
|
+
try {
|
|
5976
|
+
parsed = JSON.parse(text);
|
|
5977
|
+
} catch (e) {
|
|
5978
|
+
return new Response(text, init2);
|
|
5979
|
+
}
|
|
5980
|
+
const hash = parsed?.data?.CipherHash?.hash;
|
|
5981
|
+
if (typeof hash !== "string") {
|
|
5982
|
+
return new Response(text, init2);
|
|
5983
|
+
}
|
|
5984
|
+
const decrypted = await wallet.decryptMyMessageML768(JSON.parse(hash));
|
|
5985
|
+
return new Response(decrypted != null ? decrypted : text, init2);
|
|
5986
|
+
}
|
|
5808
5987
|
setAuthData({
|
|
5809
5988
|
token,
|
|
5810
5989
|
pubkey,
|
|
@@ -6099,8 +6278,8 @@ var Query = class {
|
|
|
6099
6278
|
* Returns a Response object
|
|
6100
6279
|
*/
|
|
6101
6280
|
createResponse(json) {
|
|
6102
|
-
const
|
|
6103
|
-
return new
|
|
6281
|
+
const Response3 = (init_Response(), __toCommonJS(Response_exports)).default;
|
|
6282
|
+
return new Response3({
|
|
6104
6283
|
query: this,
|
|
6105
6284
|
json
|
|
6106
6285
|
});
|
|
@@ -6170,8 +6349,8 @@ var Query = class {
|
|
|
6170
6349
|
} catch (error) {
|
|
6171
6350
|
if (error.name === "AbortError") {
|
|
6172
6351
|
this.knishIOClient.log("warn", "Query was cancelled");
|
|
6173
|
-
const
|
|
6174
|
-
return new
|
|
6352
|
+
const Response3 = (init_Response(), __toCommonJS(Response_exports)).default;
|
|
6353
|
+
return new Response3({
|
|
6175
6354
|
query: this,
|
|
6176
6355
|
json: { data: null, errors: [{ message: "Query was cancelled" }] }
|
|
6177
6356
|
});
|
|
@@ -6215,8 +6394,8 @@ var Mutation = class extends Query {
|
|
|
6215
6394
|
} catch (error) {
|
|
6216
6395
|
if (error.name === "AbortError") {
|
|
6217
6396
|
this.knishIOClient.log("warn", "Mutation was cancelled");
|
|
6218
|
-
const
|
|
6219
|
-
return new
|
|
6397
|
+
const Response3 = (init_Response(), __toCommonJS(Response_exports)).default;
|
|
6398
|
+
return new Response3({
|
|
6220
6399
|
query: this,
|
|
6221
6400
|
json: { data: null, errors: [{ message: "Mutation was cancelled" }] }
|
|
6222
6401
|
});
|
|
@@ -6336,7 +6515,11 @@ var KnishIOClientConfigSchema2 = z.object({
|
|
|
6336
6515
|
client: z.unknown().optional(),
|
|
6337
6516
|
socket: z.unknown().optional(),
|
|
6338
6517
|
serverSdkVersion: z.number().int().min(1).max(10).default(4),
|
|
6339
|
-
logging: z.boolean().default(false)
|
|
6518
|
+
logging: z.boolean().default(false),
|
|
6519
|
+
// Optional default urql request policy for reads (server/sync clients pass
|
|
6520
|
+
// 'network-only'). Permitted by the strict schema so the constructor option
|
|
6521
|
+
// isn't rejected.
|
|
6522
|
+
defaultRequestPolicy: z.enum(["cache-first", "cache-only", "network-only", "cache-and-network"]).nullable().optional()
|
|
6340
6523
|
}).strict();
|
|
6341
6524
|
var EnvironmentConfigSchema = z.object({
|
|
6342
6525
|
NODE_ENV: z.enum(["development", "production", "test"]).default("development"),
|
|
@@ -7148,7 +7331,90 @@ var ConfigValidator = class _ConfigValidator {
|
|
|
7148
7331
|
|
|
7149
7332
|
// src/response/ResponseBalance.ts
|
|
7150
7333
|
init_Response();
|
|
7151
|
-
|
|
7334
|
+
|
|
7335
|
+
// src/core/TokenUnit.ts
|
|
7336
|
+
var TokenUnit = class _TokenUnit {
|
|
7337
|
+
id;
|
|
7338
|
+
name;
|
|
7339
|
+
metas;
|
|
7340
|
+
/**
|
|
7341
|
+
* Create new TokenUnit instance
|
|
7342
|
+
* Matches JavaScript SDK constructor signature exactly
|
|
7343
|
+
*/
|
|
7344
|
+
constructor(id, name, metas) {
|
|
7345
|
+
this.id = id;
|
|
7346
|
+
this.name = name;
|
|
7347
|
+
this.metas = metas || {};
|
|
7348
|
+
}
|
|
7349
|
+
/**
|
|
7350
|
+
* Create TokenUnit from GraphQL response data
|
|
7351
|
+
* Matches JavaScript SDK createFromGraphQL method exactly
|
|
7352
|
+
*/
|
|
7353
|
+
static createFromGraphQL(data) {
|
|
7354
|
+
let metas = data.metas || {};
|
|
7355
|
+
if (Array.isArray(metas) && metas.length) {
|
|
7356
|
+
try {
|
|
7357
|
+
metas = JSON.parse(metas);
|
|
7358
|
+
if (!metas) {
|
|
7359
|
+
metas = {};
|
|
7360
|
+
}
|
|
7361
|
+
} catch (error) {
|
|
7362
|
+
metas = {};
|
|
7363
|
+
}
|
|
7364
|
+
}
|
|
7365
|
+
return new _TokenUnit(
|
|
7366
|
+
data.id,
|
|
7367
|
+
data.name,
|
|
7368
|
+
metas
|
|
7369
|
+
);
|
|
7370
|
+
}
|
|
7371
|
+
/**
|
|
7372
|
+
* Create TokenUnit from database array data
|
|
7373
|
+
* Matches JavaScript SDK createFromDB method exactly
|
|
7374
|
+
*/
|
|
7375
|
+
static createFromDB(data) {
|
|
7376
|
+
return new _TokenUnit(
|
|
7377
|
+
data[0],
|
|
7378
|
+
data[1],
|
|
7379
|
+
data.length > 2 ? data[2] : {}
|
|
7380
|
+
);
|
|
7381
|
+
}
|
|
7382
|
+
/**
|
|
7383
|
+
* Get fragment zone from metadata
|
|
7384
|
+
* Matches JavaScript SDK getFragmentZone method exactly
|
|
7385
|
+
*/
|
|
7386
|
+
getFragmentZone() {
|
|
7387
|
+
return this.metas.fragmentZone || null;
|
|
7388
|
+
}
|
|
7389
|
+
/**
|
|
7390
|
+
* Get fused token units from metadata
|
|
7391
|
+
* Matches JavaScript SDK getFusedTokenUnits method exactly
|
|
7392
|
+
*/
|
|
7393
|
+
getFusedTokenUnits() {
|
|
7394
|
+
return this.metas.fusedTokenUnits || null;
|
|
7395
|
+
}
|
|
7396
|
+
/**
|
|
7397
|
+
* Convert to data array format
|
|
7398
|
+
* Matches JavaScript SDK toData method exactly
|
|
7399
|
+
*/
|
|
7400
|
+
toData() {
|
|
7401
|
+
return [this.id, this.name, this.metas];
|
|
7402
|
+
}
|
|
7403
|
+
/**
|
|
7404
|
+
* Convert to GraphQL response format
|
|
7405
|
+
* Matches JavaScript SDK toGraphQLResponse method exactly
|
|
7406
|
+
*/
|
|
7407
|
+
toGraphQLResponse() {
|
|
7408
|
+
return {
|
|
7409
|
+
id: this.id,
|
|
7410
|
+
name: this.name,
|
|
7411
|
+
metas: JSON.stringify(this.metas)
|
|
7412
|
+
};
|
|
7413
|
+
}
|
|
7414
|
+
};
|
|
7415
|
+
|
|
7416
|
+
// src/response/ResponseBalance.ts
|
|
7417
|
+
var ResponseBalance = class _ResponseBalance extends Response2 {
|
|
7152
7418
|
/**
|
|
7153
7419
|
* Class constructor
|
|
7154
7420
|
*/
|
|
@@ -7210,6 +7476,11 @@ var ResponseBalance = class _ResponseBalance extends Response {
|
|
|
7210
7476
|
wallet.tokenSupply = data.token.supply;
|
|
7211
7477
|
wallet.tokenFungibility = data.token.fungibility;
|
|
7212
7478
|
}
|
|
7479
|
+
if (data.tokenUnits && data.tokenUnits.length) {
|
|
7480
|
+
for (const tokenUnitData of data.tokenUnits) {
|
|
7481
|
+
wallet.tokenUnits.push(TokenUnit.createFromGraphQL(tokenUnitData));
|
|
7482
|
+
}
|
|
7483
|
+
}
|
|
7213
7484
|
if (data.tradeRates && data.tradeRates.length) {
|
|
7214
7485
|
for (const tradeRate of data.tradeRates) {
|
|
7215
7486
|
wallet.tradeRates[tradeRate.tokenSlug] = tradeRate.amount;
|
|
@@ -7267,90 +7538,7 @@ var QueryBalance = class extends Query {
|
|
|
7267
7538
|
|
|
7268
7539
|
// src/response/ResponseWalletList.ts
|
|
7269
7540
|
init_Response();
|
|
7270
|
-
|
|
7271
|
-
// src/core/TokenUnit.ts
|
|
7272
|
-
var TokenUnit = class _TokenUnit {
|
|
7273
|
-
id;
|
|
7274
|
-
name;
|
|
7275
|
-
metas;
|
|
7276
|
-
/**
|
|
7277
|
-
* Create new TokenUnit instance
|
|
7278
|
-
* Matches JavaScript SDK constructor signature exactly
|
|
7279
|
-
*/
|
|
7280
|
-
constructor(id, name, metas) {
|
|
7281
|
-
this.id = id;
|
|
7282
|
-
this.name = name;
|
|
7283
|
-
this.metas = metas || {};
|
|
7284
|
-
}
|
|
7285
|
-
/**
|
|
7286
|
-
* Create TokenUnit from GraphQL response data
|
|
7287
|
-
* Matches JavaScript SDK createFromGraphQL method exactly
|
|
7288
|
-
*/
|
|
7289
|
-
static createFromGraphQL(data) {
|
|
7290
|
-
let metas = data.metas || {};
|
|
7291
|
-
if (Array.isArray(metas) && metas.length) {
|
|
7292
|
-
try {
|
|
7293
|
-
metas = JSON.parse(metas);
|
|
7294
|
-
if (!metas) {
|
|
7295
|
-
metas = {};
|
|
7296
|
-
}
|
|
7297
|
-
} catch (error) {
|
|
7298
|
-
metas = {};
|
|
7299
|
-
}
|
|
7300
|
-
}
|
|
7301
|
-
return new _TokenUnit(
|
|
7302
|
-
data.id,
|
|
7303
|
-
data.name,
|
|
7304
|
-
metas
|
|
7305
|
-
);
|
|
7306
|
-
}
|
|
7307
|
-
/**
|
|
7308
|
-
* Create TokenUnit from database array data
|
|
7309
|
-
* Matches JavaScript SDK createFromDB method exactly
|
|
7310
|
-
*/
|
|
7311
|
-
static createFromDB(data) {
|
|
7312
|
-
return new _TokenUnit(
|
|
7313
|
-
data[0],
|
|
7314
|
-
data[1],
|
|
7315
|
-
data.length > 2 ? data[2] : {}
|
|
7316
|
-
);
|
|
7317
|
-
}
|
|
7318
|
-
/**
|
|
7319
|
-
* Get fragment zone from metadata
|
|
7320
|
-
* Matches JavaScript SDK getFragmentZone method exactly
|
|
7321
|
-
*/
|
|
7322
|
-
getFragmentZone() {
|
|
7323
|
-
return this.metas.fragmentZone || null;
|
|
7324
|
-
}
|
|
7325
|
-
/**
|
|
7326
|
-
* Get fused token units from metadata
|
|
7327
|
-
* Matches JavaScript SDK getFusedTokenUnits method exactly
|
|
7328
|
-
*/
|
|
7329
|
-
getFusedTokenUnits() {
|
|
7330
|
-
return this.metas.fusedTokenUnits || null;
|
|
7331
|
-
}
|
|
7332
|
-
/**
|
|
7333
|
-
* Convert to data array format
|
|
7334
|
-
* Matches JavaScript SDK toData method exactly
|
|
7335
|
-
*/
|
|
7336
|
-
toData() {
|
|
7337
|
-
return [this.id, this.name, this.metas];
|
|
7338
|
-
}
|
|
7339
|
-
/**
|
|
7340
|
-
* Convert to GraphQL response format
|
|
7341
|
-
* Matches JavaScript SDK toGraphQLResponse method exactly
|
|
7342
|
-
*/
|
|
7343
|
-
toGraphQLResponse() {
|
|
7344
|
-
return {
|
|
7345
|
-
id: this.id,
|
|
7346
|
-
name: this.name,
|
|
7347
|
-
metas: JSON.stringify(this.metas)
|
|
7348
|
-
};
|
|
7349
|
-
}
|
|
7350
|
-
};
|
|
7351
|
-
|
|
7352
|
-
// src/response/ResponseWalletList.ts
|
|
7353
|
-
var ResponseWalletList = class _ResponseWalletList extends Response {
|
|
7541
|
+
var ResponseWalletList = class _ResponseWalletList extends Response2 {
|
|
7354
7542
|
/**
|
|
7355
7543
|
* Class constructor
|
|
7356
7544
|
* Matches JavaScript SDK constructor signature exactly
|
|
@@ -7489,7 +7677,7 @@ var QueryWalletList = class extends Query {
|
|
|
7489
7677
|
|
|
7490
7678
|
// src/response/ResponseWalletBundle.ts
|
|
7491
7679
|
init_Response();
|
|
7492
|
-
var ResponseWalletBundle = class extends
|
|
7680
|
+
var ResponseWalletBundle = class extends Response2 {
|
|
7493
7681
|
/**
|
|
7494
7682
|
* Class constructor
|
|
7495
7683
|
*/
|
|
@@ -7556,7 +7744,7 @@ var QueryWalletBundle = class extends Query {
|
|
|
7556
7744
|
|
|
7557
7745
|
// src/response/ResponseContinuId.ts
|
|
7558
7746
|
init_Response();
|
|
7559
|
-
var ResponseContinuId = class extends
|
|
7747
|
+
var ResponseContinuId = class extends Response2 {
|
|
7560
7748
|
/**
|
|
7561
7749
|
* Class constructor
|
|
7562
7750
|
* Matches JavaScript SDK constructor signature exactly
|
|
@@ -7636,7 +7824,7 @@ var QueryContinuId = class extends Query {
|
|
|
7636
7824
|
|
|
7637
7825
|
// src/response/ResponseMetaType.ts
|
|
7638
7826
|
init_Response();
|
|
7639
|
-
var ResponseMetaType = class extends
|
|
7827
|
+
var ResponseMetaType = class extends Response2 {
|
|
7640
7828
|
/**
|
|
7641
7829
|
* Class constructor
|
|
7642
7830
|
* Matches JavaScript SDK constructor signature exactly
|
|
@@ -7861,7 +8049,7 @@ var QueryBatch = class _QueryBatch extends Query {
|
|
|
7861
8049
|
* Matches JavaScript SDK createResponse method exactly
|
|
7862
8050
|
*/
|
|
7863
8051
|
createResponse(json) {
|
|
7864
|
-
const responseObject = new
|
|
8052
|
+
const responseObject = new Response2({
|
|
7865
8053
|
query: this,
|
|
7866
8054
|
json
|
|
7867
8055
|
});
|
|
@@ -7890,7 +8078,7 @@ var QueryBatchHistory = class extends Query {
|
|
|
7890
8078
|
* Returns a Response object
|
|
7891
8079
|
*/
|
|
7892
8080
|
createResponse(json) {
|
|
7893
|
-
const responseObject = new
|
|
8081
|
+
const responseObject = new Response2({
|
|
7894
8082
|
query: this,
|
|
7895
8083
|
json
|
|
7896
8084
|
});
|
|
@@ -7901,7 +8089,7 @@ var QueryBatchHistory = class extends Query {
|
|
|
7901
8089
|
|
|
7902
8090
|
// src/response/ResponseAtom.ts
|
|
7903
8091
|
init_Response();
|
|
7904
|
-
var ResponseAtom = class extends
|
|
8092
|
+
var ResponseAtom = class extends Response2 {
|
|
7905
8093
|
/**
|
|
7906
8094
|
* Class constructor
|
|
7907
8095
|
* Matches JavaScript SDK constructor signature exactly
|
|
@@ -8142,7 +8330,7 @@ var QueryAtom = class extends Query {
|
|
|
8142
8330
|
|
|
8143
8331
|
// src/response/ResponsePolicy.ts
|
|
8144
8332
|
init_Response();
|
|
8145
|
-
var ResponsePolicy = class extends
|
|
8333
|
+
var ResponsePolicy = class extends Response2 {
|
|
8146
8334
|
/**
|
|
8147
8335
|
* Constructor
|
|
8148
8336
|
*/
|
|
@@ -8204,7 +8392,7 @@ var QueryPolicy = class extends Query {
|
|
|
8204
8392
|
|
|
8205
8393
|
// src/response/ResponseQueryActiveSession.ts
|
|
8206
8394
|
init_Response();
|
|
8207
|
-
var ResponseQueryActiveSession = class extends
|
|
8395
|
+
var ResponseQueryActiveSession = class extends Response2 {
|
|
8208
8396
|
/**
|
|
8209
8397
|
* Constructor
|
|
8210
8398
|
*/
|
|
@@ -8273,131 +8461,6 @@ var QueryActiveSession = class extends Query {
|
|
|
8273
8461
|
}
|
|
8274
8462
|
};
|
|
8275
8463
|
|
|
8276
|
-
// src/response/ResponseQueryUserActivity.ts
|
|
8277
|
-
init_Response();
|
|
8278
|
-
var ResponseQueryUserActivity = class extends Response {
|
|
8279
|
-
/**
|
|
8280
|
-
* Constructor
|
|
8281
|
-
*/
|
|
8282
|
-
constructor({
|
|
8283
|
-
query,
|
|
8284
|
-
json
|
|
8285
|
-
}) {
|
|
8286
|
-
super({
|
|
8287
|
-
query,
|
|
8288
|
-
json,
|
|
8289
|
-
dataKey: "data.UserActivity"
|
|
8290
|
-
});
|
|
8291
|
-
}
|
|
8292
|
-
/**
|
|
8293
|
-
* Returns processed user activity data
|
|
8294
|
-
*/
|
|
8295
|
-
payload() {
|
|
8296
|
-
const data = JSON.parse(JSON.stringify(this.data()));
|
|
8297
|
-
if (data.instances) {
|
|
8298
|
-
for (const datum of data.instances) {
|
|
8299
|
-
if (datum.jsonData) {
|
|
8300
|
-
datum.jsonData = JSON.parse(datum.jsonData);
|
|
8301
|
-
}
|
|
8302
|
-
}
|
|
8303
|
-
}
|
|
8304
|
-
return data;
|
|
8305
|
-
}
|
|
8306
|
-
};
|
|
8307
|
-
var QueryUserActivity = class extends Query {
|
|
8308
|
-
/**
|
|
8309
|
-
* Constructor
|
|
8310
|
-
*/
|
|
8311
|
-
constructor(graphQLClient, knishIOClient) {
|
|
8312
|
-
super(graphQLClient, knishIOClient);
|
|
8313
|
-
this.$__query = gql`
|
|
8314
|
-
query UserActivity(
|
|
8315
|
-
$bundleHash: String
|
|
8316
|
-
$metaType: String
|
|
8317
|
-
$metaId: String
|
|
8318
|
-
$ipAddress: String
|
|
8319
|
-
$browser: String
|
|
8320
|
-
$osCpu: String
|
|
8321
|
-
$resolution: String
|
|
8322
|
-
$timeZone: String
|
|
8323
|
-
$countBy: [CountByUserActivity]
|
|
8324
|
-
$interval: span
|
|
8325
|
-
) {
|
|
8326
|
-
UserActivity(
|
|
8327
|
-
bundleHash: $bundleHash
|
|
8328
|
-
metaType: $metaType
|
|
8329
|
-
metaId: $metaId
|
|
8330
|
-
ipAddress: $ipAddress
|
|
8331
|
-
browser: $browser
|
|
8332
|
-
osCpu: $osCpu
|
|
8333
|
-
resolution: $resolution
|
|
8334
|
-
timeZone: $timeZone
|
|
8335
|
-
countBy: $countBy
|
|
8336
|
-
interval: $interval
|
|
8337
|
-
) {
|
|
8338
|
-
createdAt
|
|
8339
|
-
bundleHash
|
|
8340
|
-
metaType
|
|
8341
|
-
metaId
|
|
8342
|
-
instances {
|
|
8343
|
-
bundleHash
|
|
8344
|
-
metaType
|
|
8345
|
-
metaId
|
|
8346
|
-
jsonData
|
|
8347
|
-
createdAt
|
|
8348
|
-
updatedAt
|
|
8349
|
-
}
|
|
8350
|
-
instanceCount {
|
|
8351
|
-
...SubFields
|
|
8352
|
-
...Recursive
|
|
8353
|
-
}
|
|
8354
|
-
}
|
|
8355
|
-
}
|
|
8356
|
-
|
|
8357
|
-
fragment SubFields on InstanceCountType {
|
|
8358
|
-
id
|
|
8359
|
-
count
|
|
8360
|
-
}
|
|
8361
|
-
|
|
8362
|
-
fragment Recursive on InstanceCountType {
|
|
8363
|
-
instances {
|
|
8364
|
-
...SubFields
|
|
8365
|
-
instances {
|
|
8366
|
-
...SubFields
|
|
8367
|
-
instances {
|
|
8368
|
-
...SubFields
|
|
8369
|
-
instances {
|
|
8370
|
-
...SubFields
|
|
8371
|
-
instances {
|
|
8372
|
-
...SubFields
|
|
8373
|
-
instances {
|
|
8374
|
-
...SubFields
|
|
8375
|
-
instances {
|
|
8376
|
-
...SubFields
|
|
8377
|
-
instances {
|
|
8378
|
-
...SubFields
|
|
8379
|
-
}
|
|
8380
|
-
}
|
|
8381
|
-
}
|
|
8382
|
-
}
|
|
8383
|
-
}
|
|
8384
|
-
}
|
|
8385
|
-
}
|
|
8386
|
-
}
|
|
8387
|
-
}
|
|
8388
|
-
`;
|
|
8389
|
-
}
|
|
8390
|
-
/**
|
|
8391
|
-
* Returns a Response object
|
|
8392
|
-
*/
|
|
8393
|
-
createResponse(json) {
|
|
8394
|
-
return new ResponseQueryUserActivity({
|
|
8395
|
-
query: this,
|
|
8396
|
-
json
|
|
8397
|
-
});
|
|
8398
|
-
}
|
|
8399
|
-
};
|
|
8400
|
-
|
|
8401
8464
|
// src/query/QueryToken.ts
|
|
8402
8465
|
init_Response();
|
|
8403
8466
|
var QueryToken = class extends Query {
|
|
@@ -8424,7 +8487,7 @@ var QueryToken = class extends Query {
|
|
|
8424
8487
|
* Creates a Response object
|
|
8425
8488
|
*/
|
|
8426
8489
|
createResponse(json) {
|
|
8427
|
-
return new
|
|
8490
|
+
return new Response2({
|
|
8428
8491
|
query: this,
|
|
8429
8492
|
json,
|
|
8430
8493
|
dataKey: "data.Token"
|
|
@@ -8434,7 +8497,7 @@ var QueryToken = class extends Query {
|
|
|
8434
8497
|
|
|
8435
8498
|
// src/response/ResponseMetaTypeViaAtom.ts
|
|
8436
8499
|
init_Response();
|
|
8437
|
-
var ResponseMetaTypeViaAtom = class extends
|
|
8500
|
+
var ResponseMetaTypeViaAtom = class extends Response2 {
|
|
8438
8501
|
/**
|
|
8439
8502
|
* Class constructor
|
|
8440
8503
|
* Matches JavaScript SDK constructor signature exactly
|
|
@@ -8592,7 +8655,7 @@ var QueryMetaTypeViaAtom = class extends Query {
|
|
|
8592
8655
|
|
|
8593
8656
|
// src/response/ResponseMetaTypeViaMolecule.ts
|
|
8594
8657
|
init_Response();
|
|
8595
|
-
var ResponseMetaTypeViaMolecule = class _ResponseMetaTypeViaMolecule extends
|
|
8658
|
+
var ResponseMetaTypeViaMolecule = class _ResponseMetaTypeViaMolecule extends Response2 {
|
|
8596
8659
|
/**
|
|
8597
8660
|
* Class constructor
|
|
8598
8661
|
*/
|
|
@@ -8838,7 +8901,7 @@ var QueryMetaTypeViaMolecule = class extends Query {
|
|
|
8838
8901
|
|
|
8839
8902
|
// src/response/ResponseEmbeddingStatus.ts
|
|
8840
8903
|
init_Response();
|
|
8841
|
-
var ResponseEmbeddingStatus = class extends
|
|
8904
|
+
var ResponseEmbeddingStatus = class extends Response2 {
|
|
8842
8905
|
/**
|
|
8843
8906
|
* Class constructor
|
|
8844
8907
|
*/
|
|
@@ -8921,7 +8984,7 @@ init_Dot();
|
|
|
8921
8984
|
init_MolecularHashMismatchException();
|
|
8922
8985
|
init_SignatureMismatchException();
|
|
8923
8986
|
init_AtomIndexException();
|
|
8924
|
-
var ResponseProposeMolecule = class extends
|
|
8987
|
+
var ResponseProposeMolecule = class extends Response2 {
|
|
8925
8988
|
$__clientMolecule;
|
|
8926
8989
|
/**
|
|
8927
8990
|
* Class constructor
|
|
@@ -9231,6 +9294,20 @@ var MutationTransferTokens = class extends MutationProposeMolecule {
|
|
|
9231
9294
|
this.$__molecule.sign({});
|
|
9232
9295
|
this.$__molecule.check(this.$__molecule.sourceWallet);
|
|
9233
9296
|
}
|
|
9297
|
+
/**
|
|
9298
|
+
* Fills the Molecule for a MULTI-recipient transfer (one source funds N recipients)
|
|
9299
|
+
*/
|
|
9300
|
+
fillMoleculeMulti({
|
|
9301
|
+
recipientWallets,
|
|
9302
|
+
amounts
|
|
9303
|
+
}) {
|
|
9304
|
+
this.$__molecule.initValues({
|
|
9305
|
+
recipientWallets,
|
|
9306
|
+
amounts
|
|
9307
|
+
});
|
|
9308
|
+
this.$__molecule.sign({});
|
|
9309
|
+
this.$__molecule.check(this.$__molecule.sourceWallet);
|
|
9310
|
+
}
|
|
9234
9311
|
/**
|
|
9235
9312
|
* Builds a Response object out of a JSON object
|
|
9236
9313
|
* Matches JavaScript SDK createResponse method signature exactly
|
|
@@ -9291,7 +9368,8 @@ var MutationClaimShadowWallet = class extends MutationProposeMolecule {
|
|
|
9291
9368
|
bundle: this.$__molecule.bundle,
|
|
9292
9369
|
token,
|
|
9293
9370
|
batchId
|
|
9294
|
-
})
|
|
9371
|
+
});
|
|
9372
|
+
this.$__molecule.initShadowWalletClaim(wallet);
|
|
9295
9373
|
this.$__molecule.sign({});
|
|
9296
9374
|
this.$__molecule.check();
|
|
9297
9375
|
}
|
|
@@ -9417,7 +9495,7 @@ var MutationCreateIdentifier = class extends MutationProposeMolecule {
|
|
|
9417
9495
|
|
|
9418
9496
|
// src/response/ResponseActiveSession.ts
|
|
9419
9497
|
init_Response();
|
|
9420
|
-
var ResponseActiveSession = class extends
|
|
9498
|
+
var ResponseActiveSession = class extends Response2 {
|
|
9421
9499
|
/**
|
|
9422
9500
|
* Constructor
|
|
9423
9501
|
*/
|
|
@@ -9608,7 +9686,7 @@ var MutationRequestAuthorization = class extends MutationProposeMolecule {
|
|
|
9608
9686
|
init_Response();
|
|
9609
9687
|
init_Dot();
|
|
9610
9688
|
init_exception();
|
|
9611
|
-
var ResponseRequestAuthorizationGuest = class extends
|
|
9689
|
+
var ResponseRequestAuthorizationGuest = class extends Response2 {
|
|
9612
9690
|
/**
|
|
9613
9691
|
* Constructor
|
|
9614
9692
|
*/
|
|
@@ -9724,7 +9802,7 @@ var MutationRequestAuthorizationGuest = class extends Mutation {
|
|
|
9724
9802
|
// src/response/ResponseLinkIdentifier.ts
|
|
9725
9803
|
init_Response();
|
|
9726
9804
|
init_Dot();
|
|
9727
|
-
var ResponseLinkIdentifier = class extends
|
|
9805
|
+
var ResponseLinkIdentifier = class extends Response2 {
|
|
9728
9806
|
/**
|
|
9729
9807
|
* Constructor
|
|
9730
9808
|
*/
|
|
@@ -10064,6 +10142,10 @@ var KnishIOClient = class {
|
|
|
10064
10142
|
$__client;
|
|
10065
10143
|
$__serverSdkVersion = 3;
|
|
10066
10144
|
$__logging = false;
|
|
10145
|
+
// Default urql request policy applied to reads when the caller doesn't pass
|
|
10146
|
+
// one. null = urql's default (cache-first). Server/sync clients set this to
|
|
10147
|
+
// 'network-only' so a long-lived client never serves a stale cached read.
|
|
10148
|
+
$__defaultRequestPolicy = null;
|
|
10067
10149
|
$__authTokenObjects = {};
|
|
10068
10150
|
$__authToken = null;
|
|
10069
10151
|
$__authInProcess = false;
|
|
@@ -10103,13 +10185,15 @@ var KnishIOClient = class {
|
|
|
10103
10185
|
serverSdkVersion = 3,
|
|
10104
10186
|
logging = false
|
|
10105
10187
|
} = validatedConfig;
|
|
10188
|
+
const defaultRequestPolicy = config.defaultRequestPolicy ?? null;
|
|
10106
10189
|
this.initialize({
|
|
10107
10190
|
uri,
|
|
10108
10191
|
cellSlug,
|
|
10109
10192
|
socket,
|
|
10110
10193
|
client,
|
|
10111
10194
|
serverSdkVersion,
|
|
10112
|
-
logging
|
|
10195
|
+
logging,
|
|
10196
|
+
defaultRequestPolicy
|
|
10113
10197
|
});
|
|
10114
10198
|
}
|
|
10115
10199
|
/**
|
|
@@ -10121,7 +10205,8 @@ var KnishIOClient = class {
|
|
|
10121
10205
|
socket = null,
|
|
10122
10206
|
client = null,
|
|
10123
10207
|
serverSdkVersion = 3,
|
|
10124
|
-
logging = false
|
|
10208
|
+
logging = false,
|
|
10209
|
+
defaultRequestPolicy = null
|
|
10125
10210
|
}) {
|
|
10126
10211
|
this.reset();
|
|
10127
10212
|
this.$__logging = logging;
|
|
@@ -10143,6 +10228,7 @@ var KnishIOClient = class {
|
|
|
10143
10228
|
encrypt: this.$__encrypt
|
|
10144
10229
|
});
|
|
10145
10230
|
this.$__serverSdkVersion = serverSdkVersion;
|
|
10231
|
+
this.$__defaultRequestPolicy = defaultRequestPolicy;
|
|
10146
10232
|
}
|
|
10147
10233
|
/**
|
|
10148
10234
|
* Get random uri from specified this.$__uris
|
|
@@ -10190,6 +10276,20 @@ var KnishIOClient = class {
|
|
|
10190
10276
|
getServerSdkVersion() {
|
|
10191
10277
|
return this.$__serverSdkVersion;
|
|
10192
10278
|
}
|
|
10279
|
+
/**
|
|
10280
|
+
* Gets the client's default urql request policy (null = urql default).
|
|
10281
|
+
*/
|
|
10282
|
+
getDefaultRequestPolicy() {
|
|
10283
|
+
return this.$__defaultRequestPolicy;
|
|
10284
|
+
}
|
|
10285
|
+
/**
|
|
10286
|
+
* Sets the default urql request policy applied to reads that don't specify
|
|
10287
|
+
* one. Pass 'network-only' on a long-lived server/sync client so it never
|
|
10288
|
+
* serves a stale cached read; null restores urql's default (cache-first).
|
|
10289
|
+
*/
|
|
10290
|
+
setDefaultRequestPolicy(policy) {
|
|
10291
|
+
this.$__defaultRequestPolicy = policy;
|
|
10292
|
+
}
|
|
10193
10293
|
/**
|
|
10194
10294
|
* Reset common properties
|
|
10195
10295
|
*/
|
|
@@ -10394,7 +10494,8 @@ var KnishIOClient = class {
|
|
|
10394
10494
|
return response;
|
|
10395
10495
|
});
|
|
10396
10496
|
}
|
|
10397
|
-
|
|
10497
|
+
const effectiveContext = this.$__defaultRequestPolicy && !context.requestPolicy ? { requestPolicy: this.$__defaultRequestPolicy, ...context } : context;
|
|
10498
|
+
return await query.execute({ variables: variables || {}, context: effectiveContext });
|
|
10398
10499
|
}
|
|
10399
10500
|
/**
|
|
10400
10501
|
* When a ProposeMolecule submission is rejected for a position-related
|
|
@@ -10514,6 +10615,75 @@ var KnishIOClient = class {
|
|
|
10514
10615
|
});
|
|
10515
10616
|
return await this.executeQuery(query);
|
|
10516
10617
|
}
|
|
10618
|
+
/**
|
|
10619
|
+
* Fund N recipients from a single source in ONE molecule (multi-recipient sibling of
|
|
10620
|
+
* transferToken). Each recipient gets its own subset of stackable units (or a fungible
|
|
10621
|
+
* amount); a remainder returns the rest to the sender. Conserves:
|
|
10622
|
+
* -balance + Σamounts + (balance - Σ) === 0.
|
|
10623
|
+
*
|
|
10624
|
+
* @param token - token slug
|
|
10625
|
+
* @param recipients - destinations (bundleHash + units OR amount + optional batchId)
|
|
10626
|
+
* @param sourceWallet - optional pre-resolved source (defaults to the client's own wallet)
|
|
10627
|
+
*/
|
|
10628
|
+
async transferTokens({
|
|
10629
|
+
token,
|
|
10630
|
+
recipients,
|
|
10631
|
+
sourceWallet = null
|
|
10632
|
+
}) {
|
|
10633
|
+
const amounts = recipients.map((recipient) => {
|
|
10634
|
+
const unitCount = recipient.units ? recipient.units.length : 0;
|
|
10635
|
+
if (unitCount > 0) {
|
|
10636
|
+
if (recipient.amount !== null && recipient.amount !== void 0 && recipient.amount > 0) {
|
|
10637
|
+
throw new StackableUnitAmountException_default();
|
|
10638
|
+
}
|
|
10639
|
+
return unitCount;
|
|
10640
|
+
}
|
|
10641
|
+
return recipient.amount ?? 0;
|
|
10642
|
+
});
|
|
10643
|
+
const total = amounts.reduce((sum, amount) => sum + amount, 0);
|
|
10644
|
+
if (sourceWallet === null) {
|
|
10645
|
+
sourceWallet = await this.querySourceWallet({
|
|
10646
|
+
token,
|
|
10647
|
+
amount: total
|
|
10648
|
+
});
|
|
10649
|
+
}
|
|
10650
|
+
if (sourceWallet === null || Decimal.cmp(Number(sourceWallet.balance), total) < 0) {
|
|
10651
|
+
throw new TransferBalanceException();
|
|
10652
|
+
}
|
|
10653
|
+
const recipientWallets = recipients.map((recipient) => {
|
|
10654
|
+
const recipientWallet = Wallet.create({
|
|
10655
|
+
bundle: recipient.bundleHash,
|
|
10656
|
+
token
|
|
10657
|
+
});
|
|
10658
|
+
if (recipient.batchId !== null && recipient.batchId !== void 0) {
|
|
10659
|
+
recipientWallet.batchId = recipient.batchId;
|
|
10660
|
+
} else {
|
|
10661
|
+
recipientWallet.initBatchId({ sourceWallet });
|
|
10662
|
+
}
|
|
10663
|
+
return recipientWallet;
|
|
10664
|
+
});
|
|
10665
|
+
const remainderWallet = sourceWallet.createRemainder(this.getSecret());
|
|
10666
|
+
if (recipients.some((recipient) => recipient.units && recipient.units.length > 0)) {
|
|
10667
|
+
sourceWallet.splitUnitsMulti(
|
|
10668
|
+
recipients.map((recipient) => recipient.units ?? []),
|
|
10669
|
+
recipientWallets,
|
|
10670
|
+
remainderWallet
|
|
10671
|
+
);
|
|
10672
|
+
}
|
|
10673
|
+
const molecule = await this.createMolecule({
|
|
10674
|
+
sourceWallet,
|
|
10675
|
+
remainderWallet
|
|
10676
|
+
});
|
|
10677
|
+
const query = await this.createMoleculeMutation({
|
|
10678
|
+
mutationClass: MutationTransferTokens,
|
|
10679
|
+
molecule
|
|
10680
|
+
});
|
|
10681
|
+
query.fillMoleculeMulti({
|
|
10682
|
+
recipientWallets,
|
|
10683
|
+
amounts
|
|
10684
|
+
});
|
|
10685
|
+
return await this.executeQuery(query);
|
|
10686
|
+
}
|
|
10517
10687
|
/**
|
|
10518
10688
|
* Request authorization token (guest or profile)
|
|
10519
10689
|
*
|
|
@@ -10970,36 +11140,6 @@ var KnishIOClient = class {
|
|
|
10970
11140
|
metaId
|
|
10971
11141
|
});
|
|
10972
11142
|
}
|
|
10973
|
-
/**
|
|
10974
|
-
* Query user activity
|
|
10975
|
-
*/
|
|
10976
|
-
async queryUserActivity({
|
|
10977
|
-
bundleHash,
|
|
10978
|
-
metaType,
|
|
10979
|
-
metaId,
|
|
10980
|
-
ipAddress = null,
|
|
10981
|
-
browser = null,
|
|
10982
|
-
osCpu = null,
|
|
10983
|
-
resolution = null,
|
|
10984
|
-
timeZone = null,
|
|
10985
|
-
countBy = null,
|
|
10986
|
-
interval = null
|
|
10987
|
-
}) {
|
|
10988
|
-
const query = this.createQuery(QueryUserActivity);
|
|
10989
|
-
const variables = {
|
|
10990
|
-
bundleHash,
|
|
10991
|
-
metaType,
|
|
10992
|
-
metaId
|
|
10993
|
-
};
|
|
10994
|
-
if (ipAddress !== null) variables.ipAddress = ipAddress;
|
|
10995
|
-
if (browser !== null) variables.browser = browser;
|
|
10996
|
-
if (osCpu !== null) variables.osCpu = osCpu;
|
|
10997
|
-
if (resolution !== null) variables.resolution = resolution;
|
|
10998
|
-
if (timeZone !== null) variables.timeZone = timeZone;
|
|
10999
|
-
if (countBy !== null) variables.countBy = countBy;
|
|
11000
|
-
if (interval !== null) variables.interval = interval;
|
|
11001
|
-
return this.executeQuery(query, variables);
|
|
11002
|
-
}
|
|
11003
11143
|
/**
|
|
11004
11144
|
* Query token information
|
|
11005
11145
|
*/
|
|
@@ -11108,9 +11248,27 @@ var KnishIOClient = class {
|
|
|
11108
11248
|
amount = null,
|
|
11109
11249
|
meta = null,
|
|
11110
11250
|
batchId = null,
|
|
11111
|
-
units
|
|
11251
|
+
units = null
|
|
11112
11252
|
}) {
|
|
11113
11253
|
this.log("info", `KnishIOClient::createToken() - Creating token ${token}...`);
|
|
11254
|
+
const tokenMeta = meta || {};
|
|
11255
|
+
const fungibility = tokenMeta.fungibility;
|
|
11256
|
+
let resolvedAmount = amount ?? 0;
|
|
11257
|
+
if (fungibility === "stackable") {
|
|
11258
|
+
tokenMeta.batchId = batchId || generateBatchId({});
|
|
11259
|
+
}
|
|
11260
|
+
if ((fungibility === "stackable" || fungibility === "nonfungible" || fungibility === "non-fungible") && units && units.length > 0) {
|
|
11261
|
+
if (Number(tokenMeta.decimals ?? 0) > 0) {
|
|
11262
|
+
throw new StackableUnitDecimalsException_default();
|
|
11263
|
+
}
|
|
11264
|
+
if (Number(amount ?? 0) > 0) {
|
|
11265
|
+
throw new StackableUnitAmountException_default();
|
|
11266
|
+
}
|
|
11267
|
+
resolvedAmount = units.length;
|
|
11268
|
+
tokenMeta.splittable = "1";
|
|
11269
|
+
tokenMeta.decimals = "0";
|
|
11270
|
+
tokenMeta.tokenUnits = JSON.stringify(units);
|
|
11271
|
+
}
|
|
11114
11272
|
const mutation = await this.createMoleculeMutation({ mutationClass: MutationCreateToken });
|
|
11115
11273
|
const recipientWallet = new Wallet({
|
|
11116
11274
|
secret: this.getSecret(),
|
|
@@ -11120,8 +11278,8 @@ var KnishIOClient = class {
|
|
|
11120
11278
|
});
|
|
11121
11279
|
await mutation.fillMolecule({
|
|
11122
11280
|
recipientWallet,
|
|
11123
|
-
amount:
|
|
11124
|
-
meta
|
|
11281
|
+
amount: resolvedAmount,
|
|
11282
|
+
meta: tokenMeta
|
|
11125
11283
|
});
|
|
11126
11284
|
const response = await this.executeQuery(mutation);
|
|
11127
11285
|
if (!response) {
|
|
@@ -11562,8 +11720,12 @@ var KnishIOClient = class {
|
|
|
11562
11720
|
mutationClass: MutationRequestAuthorization,
|
|
11563
11721
|
molecule
|
|
11564
11722
|
});
|
|
11723
|
+
const authMeta = { encrypt: encrypt ? "true" : "false" };
|
|
11724
|
+
if (wallet.pubkey) {
|
|
11725
|
+
authMeta.walletPubkey = wallet.pubkey;
|
|
11726
|
+
}
|
|
11565
11727
|
mutation.fillMolecule({
|
|
11566
|
-
meta:
|
|
11728
|
+
meta: authMeta
|
|
11567
11729
|
});
|
|
11568
11730
|
const response = await this.executeQuery(mutation);
|
|
11569
11731
|
if (!response) {
|
|
@@ -11815,6 +11977,6 @@ var KnishIO = {
|
|
|
11815
11977
|
SDK_INFO
|
|
11816
11978
|
};
|
|
11817
11979
|
|
|
11818
|
-
export { Atom, AtomIndexException, AtomMeta, AtomsMissingException, AuthToken, BaseException, COMPATIBLE_SERVER_VERSIONS, CRYPTO_CONSTANTS, CheckMolecule, DevUtils, Dot, EXCEPTION_CODES, EXCEPTION_TYPES, EXTENDED_COMPATIBILITY_TEST_VECTORS, ExceptionFactory, GraphQLClient, InvalidResponseException, KnishIO, KnishIOClient, Meta, MolecularHashMismatchException, Molecule, Mutation, MutationAppendRequest, MutationCreateMeta, MutationCreateToken, MutationCreateWallet, MutationPeering, MutationProposeMolecule, MutationRequestAuthorization, MutationRequestTokens, MutationTransferTokens, PolicyMeta, Query, QueryAtom, QueryBalance, QueryBatch, QueryContinuId, QueryEmbeddingStatus, QueryMetaType, QueryMetaTypeViaAtom, QueryWalletBundle, QueryWalletList, Response, ResponseAppendRequest, ResponseAtom, ResponseBalance, ResponseContinuId, ResponseCreateMeta, ResponseCreateToken, ResponseCreateWallet, ResponseEmbeddingStatus, ResponseMetaType, ResponseMetaTypeViaAtom, ResponsePeering, ResponseProposeMolecule, ResponseRequestAuthorization, ResponseRequestTokens, ResponseTransferTokens, ResponseWalletBundle, ResponseWalletList, SDK_INFO, SDK_NAME, SDK_VERSION, SignatureMismatchException, TokenUnit, TransferBalanceException, Wallet, WalletCredentialException, base64ToHex, bufferToHexString, capitalize, charsetBaseConvert, chunkArray, chunkSubstr, configureSDK, convertToBase17, createBundleHash, createMolecularHash, createPosition, createTokenSlug, createWalletAddress, deepCloning, diff, enumerateMolecularHash, generateBatchId, generateBundleHash, generateOTSSignature, generatePosition, generateSecret, generateWalletAddress, generateWalletKey, getSDKConfig, hexStringToBuffer, hexToBase64, intersect, isAtomIsotope, isBundleHash, isHex, isHexString, isMolecularHash, isNumeric, isPosition2 as isPosition, isWalletAddress2 as isWalletAddress, normalizeMolecularHash, randomString, runCompatibilityTests, runExtendedCompatibilityTests, shake256, toCamelCase, toSnakeCase, truncate, validateBundleHash, validateMolecularHashForSignature, validateOTSSignature, validatePosition, validateSecret, validateWalletAddress, verifyOTSSignature };
|
|
11980
|
+
export { Atom, AtomIndexException, AtomMeta, AtomsMissingException, AuthToken, BaseException, COMPATIBLE_SERVER_VERSIONS, CRYPTO_CONSTANTS, CheckMolecule, DevUtils, Dot, EXCEPTION_CODES, EXCEPTION_TYPES, EXTENDED_COMPATIBILITY_TEST_VECTORS, ExceptionFactory, GraphQLClient, InvalidResponseException, KnishIO, KnishIOClient, Meta, MolecularHashMismatchException, Molecule, Mutation, MutationAppendRequest, MutationCreateMeta, MutationCreateToken, MutationCreateWallet, MutationPeering, MutationProposeMolecule, MutationRequestAuthorization, MutationRequestTokens, MutationTransferTokens, PolicyMeta, Query, QueryAtom, QueryBalance, QueryBatch, QueryContinuId, QueryEmbeddingStatus, QueryMetaType, QueryMetaTypeViaAtom, QueryWalletBundle, QueryWalletList, Response2 as Response, ResponseAppendRequest, ResponseAtom, ResponseBalance, ResponseContinuId, ResponseCreateMeta, ResponseCreateToken, ResponseCreateWallet, ResponseEmbeddingStatus, ResponseMetaType, ResponseMetaTypeViaAtom, ResponsePeering, ResponseProposeMolecule, ResponseRequestAuthorization, ResponseRequestTokens, ResponseTransferTokens, ResponseWalletBundle, ResponseWalletList, SDK_INFO, SDK_NAME, SDK_VERSION, SignatureMismatchException, TokenUnit, TransferBalanceException, Wallet, WalletCredentialException, base64ToHex, bufferToHexString, capitalize, charsetBaseConvert, chunkArray, chunkSubstr, configureSDK, convertToBase17, createBundleHash, createMolecularHash, createPosition, createTokenSlug, createWalletAddress, deepCloning, diff, enumerateMolecularHash, generateBatchId, generateBundleHash, generateOTSSignature, generatePosition, generateSecret, generateWalletAddress, generateWalletKey, getSDKConfig, hexStringToBuffer, hexToBase64, intersect, isAtomIsotope, isBundleHash, isHex, isHexString, isMolecularHash, isNumeric, isPosition2 as isPosition, isWalletAddress2 as isWalletAddress, normalizeMolecularHash, randomString, runCompatibilityTests, runExtendedCompatibilityTests, shake256, toCamelCase, toSnakeCase, truncate, validateBundleHash, validateMolecularHashForSignature, validateOTSSignature, validatePosition, validateSecret, validateWalletAddress, verifyOTSSignature };
|
|
11819
11981
|
//# sourceMappingURL=index.js.map
|
|
11820
11982
|
//# sourceMappingURL=index.js.map
|