@wishknish/knishio-client-ts 1.1.0 → 1.2.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 +15 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.iife.js +1762 -941
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +15 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/libraries/GraphQLClient.ts +18 -5
package/dist/index.js
CHANGED
|
@@ -6405,6 +6405,9 @@ var Decimal = class _Decimal {
|
|
|
6405
6405
|
return _Decimal.cmp(value1, value2) === 0;
|
|
6406
6406
|
}
|
|
6407
6407
|
};
|
|
6408
|
+
|
|
6409
|
+
// src/libraries/GraphQLClient.ts
|
|
6410
|
+
init_exception();
|
|
6408
6411
|
var CIPHER_HASH_QUERY = "query ( $Hash: String! ) { CipherHash ( Hash: $Hash ) { hash } }";
|
|
6409
6412
|
function parseOperation(query) {
|
|
6410
6413
|
const typeMatch = (query || "").match(/\b(query|mutation|subscription)\b/i);
|
|
@@ -6512,15 +6515,21 @@ var GraphQLClient = class {
|
|
|
6512
6515
|
async cipherFetch(input, init) {
|
|
6513
6516
|
const wallet = this.$__wallet;
|
|
6514
6517
|
const serverPubkey = this.$__pubkey;
|
|
6515
|
-
let
|
|
6518
|
+
let cipherWallet = null;
|
|
6516
6519
|
let requestInit = init;
|
|
6517
|
-
if (
|
|
6520
|
+
if (init && typeof init.body === "string" && this.shouldEncrypt(init.body)) {
|
|
6521
|
+
if (!wallet) {
|
|
6522
|
+
throw new CodeException("Authorized wallet missing.");
|
|
6523
|
+
}
|
|
6524
|
+
if (!serverPubkey) {
|
|
6525
|
+
throw new CodeException("Server public key missing.");
|
|
6526
|
+
}
|
|
6518
6527
|
const hashVar = await wallet.encryptStringML(init.body, serverPubkey);
|
|
6519
6528
|
requestInit = { ...init, body: JSON.stringify({ query: CIPHER_HASH_QUERY, variables: { Hash: hashVar } }) };
|
|
6520
|
-
|
|
6529
|
+
cipherWallet = wallet;
|
|
6521
6530
|
}
|
|
6522
6531
|
const response = await fetch(input, requestInit);
|
|
6523
|
-
if (!
|
|
6532
|
+
if (!cipherWallet) {
|
|
6524
6533
|
return response;
|
|
6525
6534
|
}
|
|
6526
6535
|
const text = await response.text();
|
|
@@ -6535,7 +6544,7 @@ var GraphQLClient = class {
|
|
|
6535
6544
|
if (typeof hash !== "string") {
|
|
6536
6545
|
return new Response(text, init2);
|
|
6537
6546
|
}
|
|
6538
|
-
const decrypted = await
|
|
6547
|
+
const decrypted = await cipherWallet.decryptMyMessageML(JSON.parse(hash));
|
|
6539
6548
|
return new Response(decrypted != null ? decrypted : text, init2);
|
|
6540
6549
|
}
|
|
6541
6550
|
setAuthData({
|
|
@@ -14023,7 +14032,7 @@ function createDefaultSecretStorage(options = {}) {
|
|
|
14023
14032
|
}
|
|
14024
14033
|
|
|
14025
14034
|
// src/index.ts
|
|
14026
|
-
var SDK_VERSION = "1.
|
|
14035
|
+
var SDK_VERSION = "1.2.0";
|
|
14027
14036
|
var SDK_NAME = "KnishIO-Client-TS";
|
|
14028
14037
|
var COMPATIBLE_SERVER_VERSIONS = [4, 5];
|
|
14029
14038
|
var SDK_INFO = {
|