@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.cjs
CHANGED
|
@@ -6411,6 +6411,9 @@ var Decimal = class _Decimal {
|
|
|
6411
6411
|
return _Decimal.cmp(value1, value2) === 0;
|
|
6412
6412
|
}
|
|
6413
6413
|
};
|
|
6414
|
+
|
|
6415
|
+
// src/libraries/GraphQLClient.ts
|
|
6416
|
+
init_exception();
|
|
6414
6417
|
var CIPHER_HASH_QUERY = "query ( $Hash: String! ) { CipherHash ( Hash: $Hash ) { hash } }";
|
|
6415
6418
|
function parseOperation(query) {
|
|
6416
6419
|
const typeMatch = (query || "").match(/\b(query|mutation|subscription)\b/i);
|
|
@@ -6518,15 +6521,21 @@ var GraphQLClient = class {
|
|
|
6518
6521
|
async cipherFetch(input, init) {
|
|
6519
6522
|
const wallet = this.$__wallet;
|
|
6520
6523
|
const serverPubkey = this.$__pubkey;
|
|
6521
|
-
let
|
|
6524
|
+
let cipherWallet = null;
|
|
6522
6525
|
let requestInit = init;
|
|
6523
|
-
if (
|
|
6526
|
+
if (init && typeof init.body === "string" && this.shouldEncrypt(init.body)) {
|
|
6527
|
+
if (!wallet) {
|
|
6528
|
+
throw new CodeException("Authorized wallet missing.");
|
|
6529
|
+
}
|
|
6530
|
+
if (!serverPubkey) {
|
|
6531
|
+
throw new CodeException("Server public key missing.");
|
|
6532
|
+
}
|
|
6524
6533
|
const hashVar = await wallet.encryptStringML(init.body, serverPubkey);
|
|
6525
6534
|
requestInit = { ...init, body: JSON.stringify({ query: CIPHER_HASH_QUERY, variables: { Hash: hashVar } }) };
|
|
6526
|
-
|
|
6535
|
+
cipherWallet = wallet;
|
|
6527
6536
|
}
|
|
6528
6537
|
const response = await fetch(input, requestInit);
|
|
6529
|
-
if (!
|
|
6538
|
+
if (!cipherWallet) {
|
|
6530
6539
|
return response;
|
|
6531
6540
|
}
|
|
6532
6541
|
const text = await response.text();
|
|
@@ -6541,7 +6550,7 @@ var GraphQLClient = class {
|
|
|
6541
6550
|
if (typeof hash !== "string") {
|
|
6542
6551
|
return new Response(text, init2);
|
|
6543
6552
|
}
|
|
6544
|
-
const decrypted = await
|
|
6553
|
+
const decrypted = await cipherWallet.decryptMyMessageML(JSON.parse(hash));
|
|
6545
6554
|
return new Response(decrypted != null ? decrypted : text, init2);
|
|
6546
6555
|
}
|
|
6547
6556
|
setAuthData({
|
|
@@ -14029,7 +14038,7 @@ function createDefaultSecretStorage(options = {}) {
|
|
|
14029
14038
|
}
|
|
14030
14039
|
|
|
14031
14040
|
// src/index.ts
|
|
14032
|
-
var SDK_VERSION = "1.
|
|
14041
|
+
var SDK_VERSION = "1.2.0";
|
|
14033
14042
|
var SDK_NAME = "KnishIO-Client-TS";
|
|
14034
14043
|
var COMPATIBLE_SERVER_VERSIONS = [4, 5];
|
|
14035
14044
|
var SDK_INFO = {
|