@wishknish/knishio-client-js 0.6.4 → 0.7.4
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/client.cjs.js +513 -0
- package/dist/client.cjs.js.map +1 -0
- package/dist/client.es.mjs +8176 -0
- package/dist/client.es.mjs.map +1 -0
- package/dist/client.iife.js +30 -45
- package/dist/client.iife.js.map +1 -0
- package/package.json +48 -28
- package/src/Atom.js +132 -5
- package/src/AtomMeta.js +7 -8
- package/src/AuthToken.js +1 -1
- package/src/KnishIOClient.js +133 -76
- package/src/Meta.js +6 -2
- package/src/Molecule.js +289 -38
- package/src/PolicyMeta.js +1 -1
- package/src/Wallet.js +19 -11
- package/src/exception/AtomIndexException.js +1 -1
- package/src/exception/AtomsMissingException.js +1 -1
- package/src/exception/AuthorizationRejectedException.js +1 -1
- package/src/exception/BalanceInsufficientException.js +1 -1
- package/src/exception/BatchIdException.js +1 -1
- package/src/exception/CodeException.js +1 -1
- package/src/exception/DecryptionKeyException.js +1 -1
- package/src/exception/InvalidResponseException.js +1 -1
- package/src/exception/MetaMissingException.js +1 -1
- package/src/exception/MolecularHashMismatchException.js +1 -1
- package/src/exception/MolecularHashMissingException.js +1 -1
- package/src/exception/NegativeAmountException.js +1 -1
- package/src/exception/PolicyInvalidException.js +1 -1
- package/src/exception/SignatureMalformedException.js +1 -1
- package/src/exception/SignatureMismatchException.js +1 -1
- package/src/exception/StackableUnitAmountException.js +1 -1
- package/src/exception/StackableUnitDecimalsException.js +1 -1
- package/src/exception/TransferBalanceException.js +1 -1
- package/src/exception/TransferMalformedException.js +1 -1
- package/src/exception/TransferMismatchedException.js +1 -1
- package/src/exception/TransferRemainderException.js +1 -1
- package/src/exception/TransferToSelfException.js +1 -1
- package/src/exception/TransferUnbalancedException.js +1 -1
- package/src/exception/UnauthenticatedException.js +1 -1
- package/src/exception/WalletCredentialException.js +1 -1
- package/src/exception/WalletShadowException.js +1 -1
- package/src/exception/WrongTokenTypeException.js +1 -1
- package/src/exception/index.js +25 -25
- package/src/index.js +23 -9
- package/src/instance/Rules/Callback.js +5 -5
- package/src/instance/Rules/Condition.js +1 -1
- package/src/instance/Rules/Rule.js +4 -4
- package/src/instance/Rules/exception/RuleArgumentException.js +1 -1
- package/src/libraries/CheckMolecule.js +76 -24
- package/src/libraries/crypto.js +16 -2
- package/src/libraries/strings.js +1 -1
- package/src/libraries/urql/UrqlClientWrapper.js +3 -1
- package/src/mutation/Mutation.js +2 -2
- package/src/mutation/MutationActiveSession.js +2 -2
- package/src/mutation/MutationAppendRequest.js +91 -0
- package/src/mutation/MutationClaimShadowWallet.js +3 -3
- package/src/mutation/MutationCreateIdentifier.js +2 -2
- package/src/mutation/MutationCreateMeta.js +2 -2
- package/src/mutation/MutationCreateRule.js +2 -2
- package/src/mutation/MutationCreateToken.js +2 -2
- package/src/mutation/MutationCreateWallet.js +2 -2
- package/src/mutation/MutationDepositBufferToken.js +1 -1
- package/src/mutation/MutationLinkIdentifier.js +2 -2
- package/src/mutation/MutationPeering.js +82 -0
- package/src/mutation/MutationProposeMolecule.js +2 -2
- package/src/mutation/MutationRequestAuthorization.js +2 -2
- package/src/mutation/MutationRequestAuthorizationGuest.js +2 -2
- package/src/mutation/MutationRequestTokens.js +2 -2
- package/src/mutation/MutationTransferTokens.js +2 -2
- package/src/mutation/MutationWithdrawBufferToken.js +1 -1
- package/src/query/Query.js +2 -2
- package/src/query/QueryActiveSession.js +2 -2
- package/src/query/QueryAtom.js +2 -2
- package/src/query/QueryBalance.js +2 -2
- package/src/query/QueryBatch.js +2 -2
- package/src/query/QueryBatchHistory.js +3 -3
- package/src/query/QueryContinuId.js +2 -2
- package/src/query/QueryMetaType.js +11 -5
- package/src/query/QueryMetaTypeViaAtom.js +11 -4
- package/src/query/QueryPolicy.js +2 -2
- package/src/query/QueryToken.js +2 -2
- package/src/query/QueryUserActivity.js +2 -2
- package/src/query/QueryWalletBundle.js +2 -2
- package/src/query/QueryWalletList.js +2 -2
- package/src/response/Response.js +168 -4
- package/src/response/ResponseActiveSession.js +2 -2
- package/src/response/{ResponseMetaBatch.js → ResponseAppendRequest.js} +4 -21
- package/src/response/ResponseAtom.js +2 -2
- package/src/response/ResponseAuthorizationGuest.js +4 -4
- package/src/response/ResponseBalance.js +9 -4
- package/src/response/ResponseClaimShadowWallet.js +1 -1
- package/src/response/ResponseContinuId.js +3 -3
- package/src/response/ResponseCreateIdentifier.js +1 -1
- package/src/response/ResponseCreateMeta.js +1 -1
- package/src/response/ResponseCreateRule.js +1 -1
- package/src/response/ResponseCreateToken.js +1 -1
- package/src/response/ResponseCreateWallet.js +1 -1
- package/src/response/ResponseLinkIdentifier.js +3 -3
- package/src/response/ResponseMetaType.js +2 -2
- package/src/response/ResponseMetaTypeViaAtom.js +2 -2
- package/src/response/ResponsePeering.js +55 -0
- package/src/response/ResponsePolicy.js +2 -2
- package/src/response/ResponseProposeMolecule.js +3 -3
- package/src/response/ResponseQueryActiveSession.js +2 -2
- package/src/response/ResponseQueryUserActivity.js +2 -2
- package/src/response/ResponseRequestAuthorization.js +3 -3
- package/src/response/ResponseRequestAuthorizationGuest.js +3 -3
- package/src/response/ResponseRequestTokens.js +1 -1
- package/src/response/ResponseTransferTokens.js +1 -1
- package/src/response/ResponseWalletBundle.js +3 -3
- package/src/response/ResponseWalletList.js +4 -4
- package/src/subscribe/ActiveSessionSubscribe.js +1 -1
- package/src/subscribe/ActiveWalletSubscribe.js +1 -1
- package/src/subscribe/CreateMoleculeSubscribe.js +1 -1
- package/src/subscribe/Subscribe.js +1 -1
- package/src/subscribe/WalletStatusSubscribe.js +1 -1
- package/src/types/index.js +2 -2
- package/src/versions/Version4.js +1 -1
- package/src/versions/index.js +1 -1
|
@@ -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 BaseException from './BaseException'
|
|
48
|
+
import BaseException from './BaseException.js'
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Thrown when you try to transfer more tokens than you have available
|
|
@@ -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 BaseException from './BaseException'
|
|
48
|
+
import BaseException from './BaseException.js'
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Thrown when V isotope atoms are arranged incorrectly
|
|
@@ -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 BaseException from './BaseException'
|
|
48
|
+
import BaseException from './BaseException.js'
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Thrown when the token slugs of wallets involved in a transfer do not match
|
|
@@ -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 BaseException from './BaseException'
|
|
48
|
+
import BaseException from './BaseException.js'
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Thrown when the remainder atom in a V isotope transfer is incorrect
|
|
@@ -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 BaseException from './BaseException'
|
|
48
|
+
import BaseException from './BaseException.js'
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Thrown when attempting to transfer tokens to yourself
|
|
@@ -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 BaseException from './BaseException'
|
|
48
|
+
import BaseException from './BaseException.js'
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Thrown when V isotope atom amounts do not add up to zero
|
|
@@ -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 BaseException from './BaseException'
|
|
48
|
+
import BaseException from './BaseException.js'
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Thrown when attempting to transact without an auth token
|
|
@@ -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 BaseException from './BaseException'
|
|
48
|
+
import BaseException from './BaseException.js'
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Thrown when failing to retrieve shadow 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 BaseException from './BaseException'
|
|
48
|
+
import BaseException from './BaseException.js'
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Thrown when failing to retrieve shadow 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 BaseException from './BaseException'
|
|
48
|
+
import BaseException from './BaseException.js'
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Thrown when trying to use an inappropriate token slug for a particular isotope
|
package/src/exception/index.js
CHANGED
|
@@ -45,31 +45,31 @@ 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 './AtomIndexException'
|
|
49
|
-
import AtomsMissingException from './AtomsMissingException'
|
|
50
|
-
import AuthorizationRejectedException from './AuthorizationRejectedException'
|
|
51
|
-
import BalanceInsufficientException from './BalanceInsufficientException'
|
|
52
|
-
import BatchIdException from './BatchIdException'
|
|
53
|
-
import CodeException from './CodeException'
|
|
54
|
-
import InvalidResponseException from './InvalidResponseException'
|
|
55
|
-
import MetaMissingException from './MetaMissingException'
|
|
56
|
-
import MolecularHashMismatchException from './MolecularHashMismatchException'
|
|
57
|
-
import MolecularHashMissingException from './MolecularHashMissingException'
|
|
58
|
-
import NegativeAmountException from './NegativeAmountException'
|
|
59
|
-
import PolicyInvalidException from './PolicyInvalidException'
|
|
60
|
-
import SignatureMalformedException from './SignatureMalformedException'
|
|
61
|
-
import SignatureMismatchException from './SignatureMismatchException'
|
|
62
|
-
import StackableUnitAmountException from './StackableUnitAmountException'
|
|
63
|
-
import StackableUnitDecimalsException from './StackableUnitDecimalsException'
|
|
64
|
-
import TransferBalanceException from './TransferBalanceException'
|
|
65
|
-
import TransferMalformedException from './TransferMalformedException'
|
|
66
|
-
import TransferMismatchedException from './TransferMismatchedException'
|
|
67
|
-
import TransferRemainderException from './TransferRemainderException'
|
|
68
|
-
import TransferToSelfException from './TransferToSelfException'
|
|
69
|
-
import TransferUnbalancedException from './TransferUnbalancedException'
|
|
70
|
-
import UnauthenticatedException from './UnauthenticatedException'
|
|
71
|
-
import WalletShadowException from './WalletShadowException'
|
|
72
|
-
import WrongTokenTypeException from './WrongTokenTypeException'
|
|
48
|
+
import AtomIndexException from './AtomIndexException.js'
|
|
49
|
+
import AtomsMissingException from './AtomsMissingException.js'
|
|
50
|
+
import AuthorizationRejectedException from './AuthorizationRejectedException.js'
|
|
51
|
+
import BalanceInsufficientException from './BalanceInsufficientException.js'
|
|
52
|
+
import BatchIdException from './BatchIdException.js'
|
|
53
|
+
import CodeException from './CodeException.js'
|
|
54
|
+
import InvalidResponseException from './InvalidResponseException.js'
|
|
55
|
+
import MetaMissingException from './MetaMissingException.js'
|
|
56
|
+
import MolecularHashMismatchException from './MolecularHashMismatchException.js'
|
|
57
|
+
import MolecularHashMissingException from './MolecularHashMissingException.js'
|
|
58
|
+
import NegativeAmountException from './NegativeAmountException.js'
|
|
59
|
+
import PolicyInvalidException from './PolicyInvalidException.js'
|
|
60
|
+
import SignatureMalformedException from './SignatureMalformedException.js'
|
|
61
|
+
import SignatureMismatchException from './SignatureMismatchException.js'
|
|
62
|
+
import StackableUnitAmountException from './StackableUnitAmountException.js'
|
|
63
|
+
import StackableUnitDecimalsException from './StackableUnitDecimalsException.js'
|
|
64
|
+
import TransferBalanceException from './TransferBalanceException.js'
|
|
65
|
+
import TransferMalformedException from './TransferMalformedException.js'
|
|
66
|
+
import TransferMismatchedException from './TransferMismatchedException.js'
|
|
67
|
+
import TransferRemainderException from './TransferRemainderException.js'
|
|
68
|
+
import TransferToSelfException from './TransferToSelfException.js'
|
|
69
|
+
import TransferUnbalancedException from './TransferUnbalancedException.js'
|
|
70
|
+
import UnauthenticatedException from './UnauthenticatedException.js'
|
|
71
|
+
import WalletShadowException from './WalletShadowException.js'
|
|
72
|
+
import WrongTokenTypeException from './WrongTokenTypeException.js'
|
|
73
73
|
|
|
74
74
|
export {
|
|
75
75
|
AtomIndexException,
|
package/src/index.js
CHANGED
|
@@ -46,11 +46,15 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
|
|
|
46
46
|
License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
|
|
47
47
|
*/
|
|
48
48
|
|
|
49
|
-
import Atom from './Atom'
|
|
50
|
-
import Molecule from './Molecule'
|
|
51
|
-
import Wallet from './Wallet'
|
|
52
|
-
import Meta from './Meta'
|
|
53
|
-
import KnishIOClient from './KnishIOClient'
|
|
49
|
+
import Atom from './Atom.js'
|
|
50
|
+
import Molecule from './Molecule.js'
|
|
51
|
+
import Wallet from './Wallet.js'
|
|
52
|
+
import Meta from './Meta.js'
|
|
53
|
+
import KnishIOClient from './KnishIOClient.js'
|
|
54
|
+
import MutationPeering from './mutation/MutationPeering.js'
|
|
55
|
+
import MutationAppendRequest from './mutation/MutationAppendRequest.js'
|
|
56
|
+
import ResponsePeering from './response/ResponsePeering.js'
|
|
57
|
+
import ResponseAppendRequest from './response/ResponseAppendRequest.js'
|
|
54
58
|
import {
|
|
55
59
|
base64ToHex,
|
|
56
60
|
bufferToHexString,
|
|
@@ -60,11 +64,12 @@ import {
|
|
|
60
64
|
hexToBase64,
|
|
61
65
|
isHex,
|
|
62
66
|
randomString
|
|
63
|
-
} from './libraries/strings'
|
|
67
|
+
} from './libraries/strings.js'
|
|
64
68
|
import {
|
|
65
69
|
generateBundleHash,
|
|
66
|
-
generateSecret
|
|
67
|
-
|
|
70
|
+
generateSecret,
|
|
71
|
+
shake256
|
|
72
|
+
} from './libraries/crypto.js'
|
|
68
73
|
|
|
69
74
|
export {
|
|
70
75
|
Atom,
|
|
@@ -73,6 +78,14 @@ export {
|
|
|
73
78
|
Meta,
|
|
74
79
|
KnishIOClient,
|
|
75
80
|
|
|
81
|
+
// mutations
|
|
82
|
+
MutationPeering,
|
|
83
|
+
MutationAppendRequest,
|
|
84
|
+
|
|
85
|
+
// responses
|
|
86
|
+
ResponsePeering,
|
|
87
|
+
ResponseAppendRequest,
|
|
88
|
+
|
|
76
89
|
// strings
|
|
77
90
|
chunkSubstr,
|
|
78
91
|
base64ToHex,
|
|
@@ -85,5 +98,6 @@ export {
|
|
|
85
98
|
|
|
86
99
|
// crypto
|
|
87
100
|
generateSecret,
|
|
88
|
-
generateBundleHash
|
|
101
|
+
generateBundleHash,
|
|
102
|
+
shake256
|
|
89
103
|
}
|
|
@@ -46,11 +46,11 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
|
|
|
46
46
|
License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
|
|
47
47
|
*/
|
|
48
48
|
|
|
49
|
-
import Meta from './Meta'
|
|
50
|
-
import RuleArgumentException from './exception/RuleArgumentException'
|
|
51
|
-
import { isNumeric } from '../../libraries/strings'
|
|
52
|
-
import { intersect } from '../../libraries/array'
|
|
53
|
-
import CodeException from '../../exception/CodeException'
|
|
49
|
+
import Meta from './Meta.js'
|
|
50
|
+
import RuleArgumentException from './exception/RuleArgumentException.js'
|
|
51
|
+
import { isNumeric } from '../../libraries/strings.js'
|
|
52
|
+
import { intersect } from '../../libraries/array.js'
|
|
53
|
+
import CodeException from '../../exception/CodeException.js'
|
|
54
54
|
|
|
55
55
|
export default class Callback {
|
|
56
56
|
/**
|
|
@@ -46,7 +46,7 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
|
|
|
46
46
|
License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
|
|
47
47
|
*/
|
|
48
48
|
|
|
49
|
-
import RuleArgumentException from './exception/RuleArgumentException'
|
|
49
|
+
import RuleArgumentException from './exception/RuleArgumentException.js'
|
|
50
50
|
|
|
51
51
|
export default class Condition {
|
|
52
52
|
/**
|
|
@@ -46,10 +46,10 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
|
|
|
46
46
|
License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
|
|
47
47
|
*/
|
|
48
48
|
|
|
49
|
-
import Callback from './Callback'
|
|
50
|
-
import Condition from './Condition'
|
|
51
|
-
import RuleArgumentException from './exception/RuleArgumentException'
|
|
52
|
-
import MetaMissingException from '../../exception/MetaMissingException'
|
|
49
|
+
import Callback from './Callback.js'
|
|
50
|
+
import Condition from './Condition.js'
|
|
51
|
+
import RuleArgumentException from './exception/RuleArgumentException.js'
|
|
52
|
+
import MetaMissingException from '../../exception/MetaMissingException.js'
|
|
53
53
|
|
|
54
54
|
export default class Rule {
|
|
55
55
|
/**
|
|
@@ -45,32 +45,32 @@ 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 Wallet from './../Wallet.js'
|
|
67
|
+
import Rule from '../instance/Rules/Rule.js'
|
|
68
68
|
import {
|
|
69
69
|
base64ToHex,
|
|
70
70
|
chunkSubstr
|
|
71
|
-
} from './strings'
|
|
71
|
+
} from './strings.js'
|
|
72
72
|
import JsSHA from 'jssha'
|
|
73
|
-
import Dot from './../libraries/Dot'
|
|
73
|
+
import Dot from './../libraries/Dot.js'
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
76
|
*
|
|
@@ -117,6 +117,8 @@ export default class CheckMolecule {
|
|
|
117
117
|
this.isotopeU() &&
|
|
118
118
|
this.isotopeI() &&
|
|
119
119
|
this.isotopeR() &&
|
|
120
|
+
this.isotopeP() &&
|
|
121
|
+
this.isotopeA() &&
|
|
120
122
|
this.isotopeV(senderWallet)
|
|
121
123
|
}
|
|
122
124
|
|
|
@@ -332,6 +334,56 @@ export default class CheckMolecule {
|
|
|
332
334
|
return true
|
|
333
335
|
}
|
|
334
336
|
|
|
337
|
+
/**
|
|
338
|
+
* Validates P-isotope (Peering) atoms
|
|
339
|
+
*
|
|
340
|
+
* @returns {boolean}
|
|
341
|
+
*/
|
|
342
|
+
isotopeP () {
|
|
343
|
+
for (const atom of this.molecule.getIsotopes('P')) {
|
|
344
|
+
if (atom.token !== 'USER') {
|
|
345
|
+
throw new WrongTokenTypeException(`Check::isotopeP() - "${ atom.token }" is not a valid Token slug for "${ atom.isotope }" isotope Atoms!`)
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
const metas = atom.aggregatedMeta()
|
|
349
|
+
|
|
350
|
+
if (!Object.prototype.hasOwnProperty.call(metas, 'peerHost') || !metas.peerHost) {
|
|
351
|
+
throw new MetaMissingException('Check::isotopeP() - Required meta field "peerHost" is missing!')
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
return true
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Validates A-isotope (Append Request) atoms
|
|
360
|
+
*
|
|
361
|
+
* @returns {boolean}
|
|
362
|
+
*/
|
|
363
|
+
isotopeA () {
|
|
364
|
+
for (const atom of this.molecule.getIsotopes('A')) {
|
|
365
|
+
if (atom.token !== 'USER') {
|
|
366
|
+
throw new WrongTokenTypeException(`Check::isotopeA() - "${ atom.token }" is not a valid Token slug for "${ atom.isotope }" isotope Atoms!`)
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
if (!atom.metaType) {
|
|
370
|
+
throw new MetaMissingException('Check::isotopeA() - Required field "metaType" is missing!')
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
if (!atom.metaId) {
|
|
374
|
+
throw new MetaMissingException('Check::isotopeA() - Required field "metaId" is missing!')
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
const metas = atom.aggregatedMeta()
|
|
378
|
+
|
|
379
|
+
if (!Object.prototype.hasOwnProperty.call(metas, 'action') || !metas.action) {
|
|
380
|
+
throw new MetaMissingException('Check::isotopeA() - Required meta field "action" is missing!')
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
return true
|
|
385
|
+
}
|
|
386
|
+
|
|
335
387
|
/**
|
|
336
388
|
*
|
|
337
389
|
* @param senderWallet
|
|
@@ -402,8 +454,8 @@ export default class CheckMolecule {
|
|
|
402
454
|
}
|
|
403
455
|
}
|
|
404
456
|
|
|
405
|
-
//
|
|
406
|
-
if (sum !==
|
|
457
|
+
// All atoms must sum to zero for a balanced transaction
|
|
458
|
+
if (sum !== 0) {
|
|
407
459
|
throw new TransferUnbalancedException()
|
|
408
460
|
}
|
|
409
461
|
|
package/src/libraries/crypto.js
CHANGED
|
@@ -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:
|
|
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
|
/**
|
package/src/libraries/strings.js
CHANGED
package/src/mutation/Mutation.js
CHANGED
|
@@ -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
|