@wishknish/knishio-client-js 0.6.4 → 0.7.5

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.
Files changed (121) hide show
  1. package/dist/client.cjs.js +567 -0
  2. package/dist/client.cjs.js.map +1 -0
  3. package/dist/client.es.mjs +8665 -0
  4. package/dist/client.es.mjs.map +1 -0
  5. package/dist/client.iife.js +84 -45
  6. package/dist/client.iife.js.map +1 -0
  7. package/package.json +48 -28
  8. package/src/Atom.js +132 -5
  9. package/src/AtomMeta.js +7 -8
  10. package/src/AuthToken.js +1 -1
  11. package/src/KnishIOClient.js +180 -78
  12. package/src/Meta.js +6 -2
  13. package/src/Molecule.js +383 -44
  14. package/src/PolicyMeta.js +1 -1
  15. package/src/Wallet.js +67 -12
  16. package/src/exception/AtomIndexException.js +1 -1
  17. package/src/exception/AtomsMissingException.js +1 -1
  18. package/src/exception/AuthorizationRejectedException.js +1 -1
  19. package/src/exception/BalanceInsufficientException.js +1 -1
  20. package/src/exception/BatchIdException.js +1 -1
  21. package/src/exception/CodeException.js +1 -1
  22. package/src/exception/DecryptionKeyException.js +1 -1
  23. package/src/exception/InvalidResponseException.js +1 -1
  24. package/src/exception/MetaMissingException.js +1 -1
  25. package/src/exception/MolecularHashMismatchException.js +1 -1
  26. package/src/exception/MolecularHashMissingException.js +1 -1
  27. package/src/exception/NegativeAmountException.js +1 -1
  28. package/src/exception/PolicyInvalidException.js +1 -1
  29. package/src/exception/SignatureMalformedException.js +1 -1
  30. package/src/exception/SignatureMismatchException.js +1 -1
  31. package/src/exception/StackableUnitAmountException.js +1 -1
  32. package/src/exception/StackableUnitDecimalsException.js +1 -1
  33. package/src/exception/TransferBalanceException.js +1 -1
  34. package/src/exception/TransferMalformedException.js +1 -1
  35. package/src/exception/TransferMismatchedException.js +1 -1
  36. package/src/exception/TransferRemainderException.js +1 -1
  37. package/src/exception/TransferToSelfException.js +1 -1
  38. package/src/exception/TransferUnbalancedException.js +1 -1
  39. package/src/exception/UnauthenticatedException.js +1 -1
  40. package/src/exception/WalletCredentialException.js +1 -1
  41. package/src/exception/WalletShadowException.js +1 -1
  42. package/src/exception/WrongTokenTypeException.js +1 -1
  43. package/src/exception/index.js +25 -25
  44. package/src/index.js +29 -9
  45. package/src/instance/Rules/Callback.js +5 -5
  46. package/src/instance/Rules/Condition.js +1 -1
  47. package/src/instance/Rules/Rule.js +4 -4
  48. package/src/instance/Rules/exception/RuleArgumentException.js +1 -1
  49. package/src/libraries/CheckMolecule.js +285 -27
  50. package/src/libraries/crypto.js +16 -2
  51. package/src/libraries/strings.js +1 -1
  52. package/src/libraries/urql/UrqlClientWrapper.js +3 -1
  53. package/src/mutation/Mutation.js +2 -2
  54. package/src/mutation/MutationActiveSession.js +2 -2
  55. package/src/mutation/MutationAppendRequest.js +91 -0
  56. package/src/mutation/MutationClaimShadowWallet.js +3 -3
  57. package/src/mutation/MutationCreateIdentifier.js +2 -2
  58. package/src/mutation/MutationCreateMeta.js +2 -2
  59. package/src/mutation/MutationCreateRule.js +2 -2
  60. package/src/mutation/MutationCreateToken.js +2 -2
  61. package/src/mutation/MutationCreateWallet.js +2 -2
  62. package/src/mutation/MutationDepositBufferToken.js +1 -1
  63. package/src/mutation/MutationLinkIdentifier.js +2 -2
  64. package/src/mutation/MutationPeering.js +82 -0
  65. package/src/mutation/MutationProposeMolecule.js +2 -2
  66. package/src/mutation/MutationRequestAuthorization.js +2 -2
  67. package/src/mutation/MutationRequestAuthorizationGuest.js +2 -2
  68. package/src/mutation/MutationRequestTokens.js +2 -2
  69. package/src/mutation/MutationTransferTokens.js +2 -2
  70. package/src/mutation/MutationWithdrawBufferToken.js +1 -1
  71. package/src/query/Query.js +2 -2
  72. package/src/query/QueryActiveSession.js +2 -2
  73. package/src/query/QueryAtom.js +2 -2
  74. package/src/query/QueryBalance.js +2 -2
  75. package/src/query/QueryBatch.js +2 -2
  76. package/src/query/QueryBatchHistory.js +3 -3
  77. package/src/query/QueryContinuId.js +2 -2
  78. package/src/query/QueryMetaType.js +11 -5
  79. package/src/query/QueryMetaTypeViaAtom.js +11 -4
  80. package/src/query/QueryMetaTypeViaMolecule.js +223 -0
  81. package/src/query/QueryPolicy.js +2 -2
  82. package/src/query/QueryToken.js +2 -2
  83. package/src/query/QueryUserActivity.js +2 -2
  84. package/src/query/QueryWalletBundle.js +2 -2
  85. package/src/query/QueryWalletList.js +2 -2
  86. package/src/response/Response.js +168 -4
  87. package/src/response/ResponseActiveSession.js +2 -2
  88. package/src/response/{ResponseMetaBatch.js → ResponseAppendRequest.js} +4 -21
  89. package/src/response/ResponseAtom.js +2 -2
  90. package/src/response/ResponseAuthorizationGuest.js +4 -4
  91. package/src/response/ResponseBalance.js +9 -4
  92. package/src/response/ResponseClaimShadowWallet.js +1 -1
  93. package/src/response/ResponseContinuId.js +4 -4
  94. package/src/response/ResponseCreateIdentifier.js +1 -1
  95. package/src/response/ResponseCreateMeta.js +1 -1
  96. package/src/response/ResponseCreateRule.js +1 -1
  97. package/src/response/ResponseCreateToken.js +1 -1
  98. package/src/response/ResponseCreateWallet.js +1 -1
  99. package/src/response/ResponseLinkIdentifier.js +3 -3
  100. package/src/response/ResponseMetaType.js +2 -2
  101. package/src/response/ResponseMetaTypeViaAtom.js +2 -2
  102. package/src/response/ResponseMetaTypeViaMolecule.js +210 -0
  103. package/src/response/ResponsePeering.js +55 -0
  104. package/src/response/ResponsePolicy.js +2 -2
  105. package/src/response/ResponseProposeMolecule.js +3 -3
  106. package/src/response/ResponseQueryActiveSession.js +2 -2
  107. package/src/response/ResponseQueryUserActivity.js +2 -2
  108. package/src/response/ResponseRequestAuthorization.js +3 -3
  109. package/src/response/ResponseRequestAuthorizationGuest.js +3 -3
  110. package/src/response/ResponseRequestTokens.js +1 -1
  111. package/src/response/ResponseTransferTokens.js +1 -1
  112. package/src/response/ResponseWalletBundle.js +3 -3
  113. package/src/response/ResponseWalletList.js +5 -5
  114. package/src/subscribe/ActiveSessionSubscribe.js +1 -1
  115. package/src/subscribe/ActiveWalletSubscribe.js +1 -1
  116. package/src/subscribe/CreateMoleculeSubscribe.js +1 -1
  117. package/src/subscribe/Subscribe.js +1 -1
  118. package/src/subscribe/WalletStatusSubscribe.js +1 -1
  119. package/src/types/index.js +2 -2
  120. package/src/versions/Version4.js +1 -1
  121. package/src/versions/index.js +1 -1
@@ -45,32 +45,33 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
45
45
 
46
46
  License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
47
  */
48
- import AtomIndexException from './../exception/AtomIndexException'
49
- import AtomsMissingException from './../exception/AtomsMissingException'
50
- import MolecularHashMismatchException from './../exception/MolecularHashMismatchException'
51
- import MolecularHashMissingException from './../exception/MolecularHashMissingException'
52
- import PolicyInvalidException from './../exception/PolicyInvalidException'
53
- import SignatureMalformedException from './../exception/SignatureMalformedException'
54
- import SignatureMismatchException from './../exception/SignatureMismatchException'
55
- import TransferBalanceException from './../exception/TransferBalanceException'
56
- import TransferMalformedException from './../exception/TransferMalformedException'
57
- import TransferMismatchedException from './../exception/TransferMismatchedException'
58
- import TransferRemainderException from './../exception/TransferRemainderException'
59
- import TransferToSelfException from './../exception/TransferToSelfException'
60
- import TransferUnbalancedException from './../exception/TransferUnbalancedException'
61
- import MetaMissingException from './../exception/MetaMissingException'
62
- import WrongTokenTypeException from './../exception/WrongTokenTypeException'
63
- import BatchIdException from './../exception/BatchIdException'
64
- import Atom from './../Atom'
65
- import Meta from './../Meta'
66
- import Wallet from './../Wallet'
67
- import Rule from '../instance/Rules/Rule'
48
+ import AtomIndexException from './../exception/AtomIndexException.js'
49
+ import AtomsMissingException from './../exception/AtomsMissingException.js'
50
+ import MolecularHashMismatchException from './../exception/MolecularHashMismatchException.js'
51
+ import MolecularHashMissingException from './../exception/MolecularHashMissingException.js'
52
+ import PolicyInvalidException from './../exception/PolicyInvalidException.js'
53
+ import SignatureMalformedException from './../exception/SignatureMalformedException.js'
54
+ import SignatureMismatchException from './../exception/SignatureMismatchException.js'
55
+ import TransferBalanceException from './../exception/TransferBalanceException.js'
56
+ import TransferMalformedException from './../exception/TransferMalformedException.js'
57
+ import TransferMismatchedException from './../exception/TransferMismatchedException.js'
58
+ import TransferRemainderException from './../exception/TransferRemainderException.js'
59
+ import TransferToSelfException from './../exception/TransferToSelfException.js'
60
+ import TransferUnbalancedException from './../exception/TransferUnbalancedException.js'
61
+ import MetaMissingException from './../exception/MetaMissingException.js'
62
+ import WrongTokenTypeException from './../exception/WrongTokenTypeException.js'
63
+ import BatchIdException from './../exception/BatchIdException.js'
64
+ import Atom from './../Atom.js'
65
+ import Meta from './../Meta.js'
66
+ import Molecule from './../Molecule.js'
67
+ import Wallet from './../Wallet.js'
68
+ import Rule from '../instance/Rules/Rule.js'
68
69
  import {
69
70
  base64ToHex,
70
71
  chunkSubstr
71
- } from './strings'
72
+ } from './strings.js'
72
73
  import JsSHA from 'jssha'
73
- import Dot from './../libraries/Dot'
74
+ import Dot from './../libraries/Dot.js'
74
75
 
75
76
  /**
76
77
  *
@@ -117,6 +118,10 @@ export default class CheckMolecule {
117
118
  this.isotopeU() &&
118
119
  this.isotopeI() &&
119
120
  this.isotopeR() &&
121
+ this.isotopeP() &&
122
+ this.isotopeA() &&
123
+ this.isotopeB() &&
124
+ this.isotopeF() &&
120
125
  this.isotopeV(senderWallet)
121
126
  }
122
127
 
@@ -332,6 +337,154 @@ export default class CheckMolecule {
332
337
  return true
333
338
  }
334
339
 
340
+ /**
341
+ * Validates P-isotope (Peering) atoms
342
+ *
343
+ * @returns {boolean}
344
+ */
345
+ isotopeP () {
346
+ for (const atom of this.molecule.getIsotopes('P')) {
347
+ if (atom.token !== 'USER') {
348
+ throw new WrongTokenTypeException(`Check::isotopeP() - "${ atom.token }" is not a valid Token slug for "${ atom.isotope }" isotope Atoms!`)
349
+ }
350
+
351
+ const metas = atom.aggregatedMeta()
352
+
353
+ if (!Object.prototype.hasOwnProperty.call(metas, 'peerHost') || !metas.peerHost) {
354
+ throw new MetaMissingException('Check::isotopeP() - Required meta field "peerHost" is missing!')
355
+ }
356
+ }
357
+
358
+ return true
359
+ }
360
+
361
+ /**
362
+ * Validates A-isotope (Append Request) atoms
363
+ *
364
+ * @returns {boolean}
365
+ */
366
+ isotopeA () {
367
+ for (const atom of this.molecule.getIsotopes('A')) {
368
+ if (atom.token !== 'USER') {
369
+ throw new WrongTokenTypeException(`Check::isotopeA() - "${ atom.token }" is not a valid Token slug for "${ atom.isotope }" isotope Atoms!`)
370
+ }
371
+
372
+ if (!atom.metaType) {
373
+ throw new MetaMissingException('Check::isotopeA() - Required field "metaType" is missing!')
374
+ }
375
+
376
+ if (!atom.metaId) {
377
+ throw new MetaMissingException('Check::isotopeA() - Required field "metaId" is missing!')
378
+ }
379
+
380
+ const metas = atom.aggregatedMeta()
381
+
382
+ if (!Object.prototype.hasOwnProperty.call(metas, 'action') || !metas.action) {
383
+ throw new MetaMissingException('Check::isotopeA() - Required meta field "action" is missing!')
384
+ }
385
+ }
386
+
387
+ return true
388
+ }
389
+
390
+ /**
391
+ * Validates B-isotope (Buffer/Exchange) atoms
392
+ *
393
+ * @returns {boolean}
394
+ */
395
+ isotopeB () {
396
+ const isotopeB = this.molecule.getIsotopes('B')
397
+
398
+ if (isotopeB.length === 0) {
399
+ return true
400
+ }
401
+
402
+ for (const atom of isotopeB) {
403
+ // B atoms must reference a wallet bundle
404
+ if (!atom.metaType || atom.metaType !== 'walletBundle') {
405
+ throw new MetaMissingException('Check::isotopeB() - B-isotope atoms must have metaType "walletBundle"!')
406
+ }
407
+
408
+ if (!atom.metaId) {
409
+ throw new MetaMissingException('Check::isotopeB() - B-isotope atoms must have a metaId!')
410
+ }
411
+
412
+ // Value must be parseable as a number
413
+ const value = Number(atom.value)
414
+ if (Number.isNaN(value)) {
415
+ throw new TransferMalformedException('Check::isotopeB() - B-isotope atom value is not a valid number!')
416
+ }
417
+ }
418
+
419
+ // V+B balance conservation: sum of all V and B atom values must equal zero
420
+ const vAtoms = this.molecule.getIsotopes('V')
421
+ if (vAtoms.length > 0) {
422
+ let sum = 0
423
+ for (const atom of [...vAtoms, ...isotopeB]) {
424
+ const value = Number(atom.value)
425
+ if (!Number.isNaN(value)) {
426
+ sum += value
427
+ }
428
+ }
429
+ if (sum !== 0) {
430
+ throw new TransferUnbalancedException('Check::isotopeB() - V+B atom values do not balance to zero!')
431
+ }
432
+ }
433
+
434
+ return true
435
+ }
436
+
437
+ /**
438
+ * Validates F-isotope (Fusion/NFT) atoms
439
+ *
440
+ * @returns {boolean}
441
+ */
442
+ isotopeF () {
443
+ const isotopeF = this.molecule.getIsotopes('F')
444
+
445
+ if (isotopeF.length === 0) {
446
+ return true
447
+ }
448
+
449
+ for (const atom of isotopeF) {
450
+ // F atoms must reference a wallet bundle
451
+ if (!atom.metaType || atom.metaType !== 'walletBundle') {
452
+ throw new MetaMissingException('Check::isotopeF() - F-isotope atoms must have metaType "walletBundle"!')
453
+ }
454
+
455
+ if (!atom.metaId) {
456
+ throw new MetaMissingException('Check::isotopeF() - F-isotope atoms must have a metaId!')
457
+ }
458
+
459
+ // Value must be parseable
460
+ const value = Number(atom.value)
461
+ if (Number.isNaN(value)) {
462
+ throw new TransferMalformedException('Check::isotopeF() - F-isotope atom value is not a valid number!')
463
+ }
464
+
465
+ if (value < 0) {
466
+ throw new TransferMalformedException('Check::isotopeF() - F-isotope atom value must not be negative!')
467
+ }
468
+ }
469
+
470
+ // V+F balance conservation: sum of all V and F atom values must equal zero
471
+ const vAtoms = this.molecule.getIsotopes('V')
472
+ if (vAtoms.length > 0) {
473
+ let sum = 0
474
+ for (const atom of [...vAtoms, ...isotopeF]) {
475
+ const value = Number(atom.value)
476
+ if (!Number.isNaN(value)) {
477
+ sum += value
478
+ }
479
+ }
480
+ if (sum !== 0) {
481
+ throw new TransferUnbalancedException('Check::isotopeF() - V+F atom values do not balance to zero!')
482
+ }
483
+ }
484
+
485
+ return true
486
+ }
487
+
335
488
  /**
336
489
  *
337
490
  * @param senderWallet
@@ -344,9 +497,14 @@ export default class CheckMolecule {
344
497
  return true
345
498
  }
346
499
 
500
+ // When B or F atoms are present, cross-isotope conservation is validated
501
+ // by isotopeB()/isotopeF() — skip V-only conservation check
502
+ const hasCrossIsotope = this.molecule.getIsotopes('B').length > 0 ||
503
+ this.molecule.getIsotopes('F').length > 0
504
+
347
505
  const firstAtom = this.molecule.atoms[0]
348
506
 
349
- if (firstAtom.isotope === 'V' && isotopeV.length === 2) {
507
+ if (!hasCrossIsotope && firstAtom.isotope === 'V' && isotopeV.length === 2) {
350
508
  const endAtom = isotopeV[isotopeV.length - 1]
351
509
 
352
510
  if (firstAtom.token !== endAtom.token) {
@@ -357,6 +515,11 @@ export default class CheckMolecule {
357
515
  throw new TransferMalformedException()
358
516
  }
359
517
 
518
+ // Conservation check for 2-atom transfers
519
+ if ((Number(firstAtom.value) + Number(endAtom.value)) !== 0) {
520
+ throw new TransferUnbalancedException()
521
+ }
522
+
360
523
  return true
361
524
  }
362
525
 
@@ -402,8 +565,8 @@ export default class CheckMolecule {
402
565
  }
403
566
  }
404
567
 
405
- // Does the total sum of all atoms equal the remainder atom's value? (all other atoms must add up to zero)
406
- if (sum !== value) {
568
+ // V-only conservation: all V atoms must sum to zero (skip for B/F cross-isotope)
569
+ if (!hasCrossIsotope && sum !== 0) {
407
570
  throw new TransferUnbalancedException()
408
571
  }
409
572
 
@@ -415,7 +578,7 @@ export default class CheckMolecule {
415
578
  throw new TypeError('Invalid isotope "V" values')
416
579
  }
417
580
 
418
- const remainder = senderWallet.balance + value
581
+ const remainder = Number(senderWallet.balance) + value
419
582
 
420
583
  // Is there enough balance to send?
421
584
  if (remainder < 0) {
@@ -423,7 +586,8 @@ export default class CheckMolecule {
423
586
  }
424
587
 
425
588
  // Does the remainder match what should be there in the source wallet, if provided?
426
- if (remainder !== sum) {
589
+ // Skip for cross-isotope (B/F) conservation is validated by isotopeB()/isotopeF()
590
+ if (!hasCrossIsotope && remainder !== sum) {
427
591
  throw new TransferRemainderException()
428
592
  }
429
593
  } else if (value !== 0) {
@@ -526,4 +690,98 @@ export default class CheckMolecule {
526
690
  // Looks like we passed all the tests!
527
691
  return true
528
692
  }
693
+
694
+ /**
695
+ * Converts server-side molecule data (from GraphQL meta query responses)
696
+ * into a Molecule instance suitable for verification via CheckMolecule.
697
+ *
698
+ * Handles field mapping differences between server and client:
699
+ * - tokenSlug → token
700
+ * - metasJson (JSON string) → meta (array of {key, value})
701
+ * - bundleHash → bundle
702
+ *
703
+ * @param {object} serverData - Molecule data from GraphQL response
704
+ * @param {string} serverData.molecularHash
705
+ * @param {string} serverData.bundleHash
706
+ * @param {string|null} serverData.cellSlug
707
+ * @param {string|null} serverData.status
708
+ * @param {string|null} serverData.createdAt
709
+ * @param {array} serverData.atoms - Array of server-format atom objects
710
+ * @return {Molecule}
711
+ */
712
+ static fromServerData ({
713
+ molecularHash,
714
+ bundleHash,
715
+ cellSlug = null,
716
+ status = null,
717
+ createdAt = null,
718
+ atoms = []
719
+ }) {
720
+ const mappedAtoms = atoms.map(serverAtom => {
721
+ let meta = []
722
+ if (serverAtom.metasJson) {
723
+ try {
724
+ const parsed = JSON.parse(serverAtom.metasJson)
725
+ if (Array.isArray(parsed)) {
726
+ // Already in [{key, value}] format
727
+ meta = parsed
728
+ } else if (parsed && typeof parsed === 'object') {
729
+ // Object format {key1: val1, key2: val2} — convert to [{key, value}] pairs
730
+ meta = Object.entries(parsed).map(([key, value]) => ({ key, value }))
731
+ }
732
+ } catch (e) {
733
+ meta = []
734
+ }
735
+ }
736
+
737
+ return {
738
+ position: serverAtom.position || null,
739
+ walletAddress: serverAtom.walletAddress || null,
740
+ isotope: serverAtom.isotope || null,
741
+ token: serverAtom.tokenSlug || serverAtom.token || null,
742
+ value: serverAtom.value != null ? String(serverAtom.value) : null,
743
+ batchId: serverAtom.batchId || null,
744
+ metaType: serverAtom.metaType || null,
745
+ metaId: serverAtom.metaId || null,
746
+ meta,
747
+ index: serverAtom.index != null ? serverAtom.index : null,
748
+ otsFragment: serverAtom.otsFragment || null,
749
+ createdAt: serverAtom.createdAt || null
750
+ }
751
+ })
752
+
753
+ return Molecule.fromJSON({
754
+ molecularHash,
755
+ bundle: bundleHash,
756
+ cellSlug,
757
+ status,
758
+ createdAt,
759
+ atoms: mappedAtoms
760
+ })
761
+ }
762
+
763
+ /**
764
+ * Verifies a molecule reconstructed from server-side GraphQL data.
765
+ * Returns an object with verification result and any error details.
766
+ *
767
+ * @param {object} moleculeData - Server molecule data (same format as fromServerData)
768
+ * @return {{ molecularHash: string, verified: boolean, error: string|null }}
769
+ */
770
+ static verifyFromServerData (moleculeData) {
771
+ try {
772
+ const molecule = CheckMolecule.fromServerData(moleculeData)
773
+ new CheckMolecule(molecule).verify()
774
+ return {
775
+ molecularHash: moleculeData.molecularHash,
776
+ verified: true,
777
+ error: null
778
+ }
779
+ } catch (error) {
780
+ return {
781
+ molecularHash: moleculeData.molecularHash || null,
782
+ verified: false,
783
+ error: error.message || String(error)
784
+ }
785
+ }
786
+ }
529
787
  }
@@ -45,7 +45,7 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
45
45
 
46
46
  License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
47
  */
48
- import { randomString } from './strings'
48
+ import { randomString } from './strings.js'
49
49
  import JsSHA from 'jssha'
50
50
 
51
51
  /**
@@ -60,6 +60,7 @@ export function generateSecret (seed = null, length = 2048) {
60
60
  if (seed) {
61
61
  const sponge = new JsSHA('SHAKE256', 'TEXT')
62
62
  sponge.update(seed)
63
+ // Fix: outputLen is in BITS, so for 'length' hex chars (length/2 bytes), we need length*2 bits
63
64
  return sponge.getHash('HEX', { outputLen: length * 2 })
64
65
  } else {
65
66
  return randomString(length)
@@ -76,7 +77,20 @@ export function generateSecret (seed = null, length = 2048) {
76
77
  export function generateBundleHash (secret, source = null) {
77
78
  const sponge = new JsSHA('SHAKE256', 'TEXT')
78
79
  sponge.update(secret)
79
- return sponge.getHash('HEX', { outputLen: 256 })
80
+ return sponge.getHash('HEX', { outputLen: 64 * 4 }) // 64 bytes = 512 bits
81
+ }
82
+
83
+ /**
84
+ * SHAKE256 hash function
85
+ *
86
+ * @param {string} input - The input string to hash
87
+ * @param {number} outputLength - The desired output length in bits
88
+ * @return {string} The hex-encoded hash
89
+ */
90
+ export function shake256 (input, outputLength) {
91
+ const sponge = new JsSHA('SHAKE256', 'TEXT')
92
+ sponge.update(input)
93
+ return sponge.getHash('HEX', { outputLen: outputLength })
80
94
  }
81
95
 
82
96
  /**
@@ -1,4 +1,4 @@
1
- import Hex from './Hex'
1
+ import Hex from './Hex.js'
2
2
 
3
3
  if (!String.prototype.trim) {
4
4
  String.prototype.trim = function () {
@@ -47,7 +47,9 @@ class UrqlClientWrapper {
47
47
  fetchOptions: () => ({
48
48
  headers: {
49
49
  'X-Auth-Token': this.$__authToken
50
- }
50
+ },
51
+ // Add 60 second timeout for debugging
52
+ signal: AbortSignal.timeout(60000)
51
53
  })
52
54
  })
53
55
  }
@@ -45,8 +45,8 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
45
45
 
46
46
  License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
47
  */
48
- import Query from '../query/Query'
49
- import Response from '../response/Response'
48
+ import Query from '../query/Query.js'
49
+ import Response from '../response/Response.js'
50
50
 
51
51
  /**
52
52
  * Base class used to construct various GraphQL mutations
@@ -45,8 +45,8 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
45
45
 
46
46
  License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
47
  */
48
- import Mutation from '../mutation/Mutation'
49
- import ResponseActiveSession from '../response/ResponseActiveSession'
48
+ import Mutation from '../mutation/Mutation.js'
49
+ import ResponseActiveSession from '../response/ResponseActiveSession.js'
50
50
  import { gql } from '@urql/core'
51
51
 
52
52
  /**
@@ -0,0 +1,91 @@
1
+ /*
2
+ (
3
+ (/(
4
+ (//(
5
+ (///(
6
+ (/////(
7
+ (//////( )
8
+ (////////( (/)
9
+ (////////( (///)
10
+ (//////////( (////)
11
+ (//////////( (//////)
12
+ (////////////( (///////)
13
+ (/////////////( (/////////)
14
+ (//////////////( (///////////)
15
+ (///////////////( (/////////////)
16
+ (////////////////( (//////////////)
17
+ ((((((((((((((((((( (((((((((((((((
18
+ ((((((((((((((((((( ((((((((((((((
19
+ ((((((((((((((((((( ((((((((((((((
20
+ (((((((((((((((((((( (((((((((((((
21
+ (((((((((((((((((((( ((((((((((((
22
+ ((((((((((((((((((( ((((((((((((
23
+ ((((((((((((((((((( ((((((((((
24
+ ((((((((((((((((((/ (((((((((
25
+ (((((((((((((((((( ((((((((
26
+ ((((((((((((((((( (((((((
27
+ (((((((((((((((((( (((((
28
+ ################# ##
29
+ ################ #
30
+ ################# ##
31
+ %################ ###
32
+ ###############( ####
33
+ ############### ####
34
+ ############### ######
35
+ %#############( (#######
36
+ %############# #########
37
+ ############( ##########
38
+ ########### #############
39
+ ######### ##############
40
+ %######
41
+
42
+ Powered by Knish.IO: Connecting a Decentralized World
43
+
44
+ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
45
+
46
+ License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
+ */
48
+ import MutationProposeMolecule from './MutationProposeMolecule.js'
49
+ import ResponseAppendRequest from '../response/ResponseAppendRequest.js'
50
+
51
+ /**
52
+ * Mutation for submitting an append request via the A-isotope
53
+ */
54
+ export default class MutationAppendRequest extends MutationProposeMolecule {
55
+ /**
56
+ * Fills a molecule with an A-isotope append request atom
57
+ *
58
+ * @param {string} metaType
59
+ * @param {string} metaId
60
+ * @param {string} action
61
+ * @param {object} meta
62
+ */
63
+ fillMolecule ({
64
+ metaType,
65
+ metaId,
66
+ action,
67
+ meta = {}
68
+ }) {
69
+ this.$__molecule.initAppendRequest({
70
+ metaType,
71
+ metaId,
72
+ action,
73
+ meta
74
+ })
75
+ this.$__molecule.sign({})
76
+ this.$__molecule.check()
77
+ }
78
+
79
+ /**
80
+ * Builds a new Response object from a JSON string
81
+ *
82
+ * @param {object} json
83
+ * @return {ResponseAppendRequest}
84
+ */
85
+ createResponse (json) {
86
+ return new ResponseAppendRequest({
87
+ query: this,
88
+ json
89
+ })
90
+ }
91
+ }
@@ -45,9 +45,9 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
45
45
 
46
46
  License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
47
  */
48
- import MutationProposeMolecule from './MutationProposeMolecule'
49
- import Wallet from '../Wallet'
50
- import ResponseClaimShadowWallet from '../response/ResponseClaimShadowWallet'
48
+ import MutationProposeMolecule from './MutationProposeMolecule.js'
49
+ import Wallet from '../Wallet.js'
50
+ import ResponseClaimShadowWallet from '../response/ResponseClaimShadowWallet.js'
51
51
 
52
52
  /**
53
53
  * Mutation for claiming a Shadow Wallet
@@ -45,8 +45,8 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
45
45
 
46
46
  License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
47
  */
48
- import MutationProposeMolecule from './MutationProposeMolecule'
49
- import ResponseCreateIdentifier from '../response/ResponseCreateIdentifier'
48
+ import MutationProposeMolecule from './MutationProposeMolecule.js'
49
+ import ResponseCreateIdentifier from '../response/ResponseCreateIdentifier.js'
50
50
 
51
51
  /**
52
52
  * Query for creating a new Identifier
@@ -45,8 +45,8 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
45
45
 
46
46
  License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
47
  */
48
- import MutationProposeMolecule from './MutationProposeMolecule'
49
- import ResponseCreateMeta from '../response/ResponseCreateMeta'
48
+ import MutationProposeMolecule from './MutationProposeMolecule.js'
49
+ import ResponseCreateMeta from '../response/ResponseCreateMeta.js'
50
50
 
51
51
  /**
52
52
  * Query for creating new Meta attached to some MetaType
@@ -45,8 +45,8 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
45
45
 
46
46
  License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
47
  */
48
- import MutationProposeMolecule from './MutationProposeMolecule'
49
- import ResponseCreateRule from '../response/ResponseCreateRule'
48
+ import MutationProposeMolecule from './MutationProposeMolecule.js'
49
+ import ResponseCreateRule from '../response/ResponseCreateRule.js'
50
50
 
51
51
  /**
52
52
  * Query for creating new Meta attached to some MetaType
@@ -45,8 +45,8 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
45
45
 
46
46
  License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
47
  */
48
- import MutationProposeMolecule from './MutationProposeMolecule'
49
- import ResponseCreateToken from '../response/ResponseCreateToken'
48
+ import MutationProposeMolecule from './MutationProposeMolecule.js'
49
+ import ResponseCreateToken from '../response/ResponseCreateToken.js'
50
50
 
51
51
  /**
52
52
  * Query for creating new Tokens
@@ -45,8 +45,8 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
45
45
 
46
46
  License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
47
  */
48
- import MutationProposeMolecule from './MutationProposeMolecule'
49
- import ResponseCreateWallet from '../response/ResponseCreateWallet'
48
+ import MutationProposeMolecule from './MutationProposeMolecule.js'
49
+ import ResponseCreateWallet from '../response/ResponseCreateWallet.js'
50
50
 
51
51
  /**
52
52
  * Query for creating new Wallets
@@ -45,7 +45,7 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
45
45
 
46
46
  License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
47
  */
48
- import MutationProposeMolecule from './MutationProposeMolecule'
48
+ import MutationProposeMolecule from './MutationProposeMolecule.js'
49
49
 
50
50
  /**
51
51
  *
@@ -45,8 +45,8 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
45
45
 
46
46
  License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
47
  */
48
- import Mutation from '../mutation/Mutation'
49
- import ResponseLinkIdentifier from '../response/ResponseLinkIdentifier'
48
+ import Mutation from '../mutation/Mutation.js'
49
+ import ResponseLinkIdentifier from '../response/ResponseLinkIdentifier.js'
50
50
  import { gql } from '@urql/core'
51
51
 
52
52
  /**