@wishknish/knishio-client-js 0.5.2 → 0.6.1
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/README.md +207 -274
- package/dist/client.iife.js +533 -0
- package/package.json +37 -79
- package/src/.babelrc +0 -22
- package/src/Atom.js +171 -132
- package/src/AtomMeta.js +76 -50
- package/src/AuthToken.js +38 -47
- package/src/KnishIOClient.js +934 -987
- package/src/Meta.js +15 -17
- package/src/Molecule.js +423 -494
- package/src/PolicyMeta.js +32 -41
- package/src/TokenUnit.js +30 -32
- package/src/Wallet.js +275 -265
- package/src/exception/AtomIndexException.js +4 -8
- package/src/exception/AtomsMissingException.js +4 -6
- package/src/exception/AuthorizationRejectedException.js +4 -5
- package/src/exception/BalanceInsufficientException.js +4 -8
- package/src/exception/BaseException.js +6 -8
- package/src/exception/BatchIdException.js +5 -7
- package/src/exception/CodeException.js +4 -8
- package/src/{libraries/ApolloLink/HttpLink.js → exception/DecryptionKeyException.js} +12 -15
- package/src/exception/InvalidResponseException.js +4 -5
- package/src/exception/MetaMissingException.js +4 -6
- package/src/exception/MolecularHashMismatchException.js +4 -6
- package/src/exception/MolecularHashMissingException.js +4 -5
- package/src/exception/NegativeAmountException.js +4 -5
- package/src/exception/PolicyInvalidException.js +4 -4
- package/src/exception/SignatureMalformedException.js +4 -5
- package/src/exception/SignatureMismatchException.js +4 -5
- package/src/exception/StackableUnitAmountException.js +4 -5
- package/src/exception/StackableUnitDecimalsException.js +4 -5
- package/src/exception/TransferBalanceException.js +4 -5
- package/src/exception/TransferMalformedException.js +4 -5
- package/src/exception/TransferMismatchedException.js +4 -5
- package/src/exception/TransferRemainderException.js +4 -5
- package/src/exception/TransferToSelfException.js +4 -5
- package/src/exception/TransferUnbalancedException.js +4 -5
- package/src/exception/UnauthenticatedException.js +4 -5
- package/src/{libraries/ApolloLink/AuthLink.js → exception/WalletCredentialException.js} +12 -40
- package/src/exception/WalletShadowException.js +4 -5
- package/src/exception/WrongTokenTypeException.js +4 -5
- package/src/exception/index.js +26 -26
- package/src/index.js +8 -10
- package/src/instance/Rules/Callback.js +91 -93
- package/src/instance/Rules/Condition.js +21 -23
- package/src/instance/Rules/Meta.js +13 -14
- package/src/instance/Rules/Rule.js +39 -43
- package/src/instance/Rules/exception/RuleArgumentException.js +4 -4
- package/src/libraries/CheckMolecule.js +253 -232
- package/src/libraries/Decimal.js +13 -17
- package/src/libraries/Dot.js +74 -48
- package/src/libraries/Hex.js +49 -54
- package/src/libraries/array.js +50 -41
- package/src/libraries/crypto.js +20 -27
- package/src/libraries/strings.js +58 -91
- package/src/libraries/urql/UrqlClientWrapper.js +166 -0
- package/src/mutation/Mutation.js +44 -25
- package/src/mutation/MutationActiveSession.js +12 -12
- package/src/mutation/MutationClaimShadowWallet.js +15 -17
- package/src/mutation/MutationCreateIdentifier.js +11 -12
- package/src/mutation/MutationCreateMeta.js +11 -12
- package/src/mutation/MutationCreateRule.js +11 -12
- package/src/mutation/MutationCreateToken.js +18 -13
- package/src/mutation/MutationCreateWallet.js +9 -11
- package/src/mutation/MutationDepositBufferToken.js +7 -9
- package/src/mutation/MutationLinkIdentifier.js +12 -14
- package/src/mutation/MutationProposeMolecule.js +24 -25
- package/src/mutation/MutationRequestAuthorization.js +9 -10
- package/src/mutation/MutationRequestAuthorizationGuest.js +12 -15
- package/src/mutation/MutationRequestTokens.js +11 -14
- package/src/mutation/MutationTransferTokens.js +11 -14
- package/src/mutation/MutationWithdrawBufferToken.js +7 -10
- package/src/query/Query.js +62 -36
- package/src/query/QueryActiveSession.js +11 -13
- package/src/query/QueryAtom.js +75 -76
- package/src/query/QueryBalance.js +11 -12
- package/src/query/QueryBatch.js +17 -14
- package/src/query/QueryBatchHistory.js +16 -13
- package/src/query/QueryContinuId.js +13 -10
- package/src/query/QueryMetaType.js +45 -57
- package/src/query/QueryMetaTypeViaAtom.js +49 -57
- package/src/query/QueryPolicy.js +11 -12
- package/src/query/QueryToken.js +11 -13
- package/src/query/QueryUserActivity.js +11 -13
- package/src/query/QueryWalletBundle.js +15 -47
- package/src/query/QueryWalletList.js +15 -16
- package/src/response/Response.js +29 -34
- package/src/response/ResponseActiveSession.js +6 -6
- package/src/response/ResponseAtom.js +29 -30
- package/src/response/ResponseAuthorizationGuest.js +17 -18
- package/src/response/ResponseBalance.js +12 -13
- package/src/response/ResponseClaimShadowWallet.js +1 -1
- package/src/response/ResponseContinuId.js +21 -22
- 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 +9 -10
- package/src/response/ResponseMetaBatch.js +6 -8
- package/src/response/ResponseMetaType.js +19 -20
- package/src/response/ResponseMetaTypeViaAtom.js +19 -19
- package/src/response/ResponsePolicy.js +14 -15
- package/src/response/ResponseProposeMolecule.js +27 -30
- package/src/response/ResponseQueryActiveSession.js +20 -23
- package/src/response/ResponseQueryUserActivity.js +11 -12
- package/src/response/ResponseRequestAuthorization.js +11 -16
- package/src/response/ResponseRequestAuthorizationGuest.js +18 -21
- package/src/response/ResponseRequestTokens.js +1 -1
- package/src/response/ResponseTransferTokens.js +8 -9
- package/src/response/ResponseWalletBundle.js +16 -17
- package/src/response/ResponseWalletList.js +44 -47
- package/src/subscribe/ActiveSessionSubscribe.js +5 -6
- package/src/subscribe/ActiveWalletSubscribe.js +5 -6
- package/src/subscribe/CreateMoleculeSubscribe.js +5 -5
- package/src/subscribe/Subscribe.js +26 -26
- package/src/subscribe/WalletStatusSubscribe.js +5 -6
- package/src/versions/HashAtom.js +78 -0
- package/src/versions/Version4.js +34 -0
- package/src/versions/index.js +5 -0
- package/dist/client.umd.js +0 -453
- package/src/httpClient/ApolloClient.js +0 -245
- package/src/libraries/ApolloLink/CipherLink.js +0 -117
- package/src/libraries/ApolloLink/Client.js +0 -231
- package/src/libraries/ApolloLink/PusherLink.js +0 -234
- package/src/libraries/ApolloLink/handler.js +0 -106
- package/src/libraries/Base58.js +0 -71
- package/src/libraries/Base64.js +0 -40
- package/src/libraries/BaseX.js +0 -91
- package/src/libraries/Soda.js +0 -93
- package/src/query/QueryMetaInstance.js +0 -99
- package/src/test/Test.js +0 -670
- package/src/test/TestTokenUnit.js +0 -340
|
@@ -46,29 +46,28 @@ 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
|
|
50
|
-
import
|
|
49
|
+
import Query from '../query/Query'
|
|
50
|
+
import Response from './Response'
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* Response for MetaType Query
|
|
54
54
|
*/
|
|
55
55
|
export default class ResponseMetaType extends Response {
|
|
56
|
-
|
|
57
56
|
/**
|
|
58
57
|
* Class constructor
|
|
59
58
|
*
|
|
60
59
|
* @param {Query} query
|
|
61
60
|
* @param {object} json
|
|
62
61
|
*/
|
|
63
|
-
constructor (
|
|
62
|
+
constructor ({
|
|
64
63
|
query,
|
|
65
64
|
json
|
|
66
|
-
}
|
|
67
|
-
super(
|
|
65
|
+
}) {
|
|
66
|
+
super({
|
|
68
67
|
query,
|
|
69
68
|
json,
|
|
70
69
|
dataKey: 'data.MetaType'
|
|
71
|
-
}
|
|
70
|
+
})
|
|
72
71
|
}
|
|
73
72
|
|
|
74
73
|
/**
|
|
@@ -77,32 +76,32 @@ export default class ResponseMetaType extends Response {
|
|
|
77
76
|
* @return {null|*}
|
|
78
77
|
*/
|
|
79
78
|
payload () {
|
|
80
|
-
const metaTypeData = this.data()
|
|
79
|
+
const metaTypeData = this.data()
|
|
81
80
|
|
|
82
|
-
if (
|
|
83
|
-
return null
|
|
81
|
+
if (!metaTypeData || metaTypeData.length === 0) {
|
|
82
|
+
return null
|
|
84
83
|
}
|
|
85
84
|
|
|
86
|
-
|
|
85
|
+
const response = {
|
|
87
86
|
instances: {},
|
|
88
87
|
instanceCount: {},
|
|
89
88
|
paginatorInfo: {}
|
|
90
|
-
}
|
|
89
|
+
}
|
|
91
90
|
|
|
92
|
-
|
|
91
|
+
const metaData = metaTypeData.pop()
|
|
93
92
|
|
|
94
|
-
if (
|
|
95
|
-
response.instances = metaData.instances
|
|
93
|
+
if (metaData.instances) {
|
|
94
|
+
response.instances = metaData.instances
|
|
96
95
|
}
|
|
97
96
|
|
|
98
|
-
if (
|
|
99
|
-
response.instanceCount = metaData.instanceCount
|
|
97
|
+
if (metaData.instanceCount) {
|
|
98
|
+
response.instanceCount = metaData.instanceCount
|
|
100
99
|
}
|
|
101
100
|
|
|
102
|
-
if (
|
|
103
|
-
response.paginatorInfo = metaData.paginatorInfo
|
|
101
|
+
if (metaData.paginatorInfo) {
|
|
102
|
+
response.paginatorInfo = metaData.paginatorInfo
|
|
104
103
|
}
|
|
105
104
|
|
|
106
|
-
return response
|
|
105
|
+
return response
|
|
107
106
|
}
|
|
108
107
|
}
|
|
@@ -46,8 +46,8 @@ 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
|
|
50
|
-
import
|
|
49
|
+
import Query from '../query/Query'
|
|
50
|
+
import Response from './Response'
|
|
51
51
|
|
|
52
52
|
export default class ResponseMetaTypeViaAtom extends Response {
|
|
53
53
|
/**
|
|
@@ -56,44 +56,44 @@ export default class ResponseMetaTypeViaAtom extends Response {
|
|
|
56
56
|
* @param {Query} query
|
|
57
57
|
* @param {object} json
|
|
58
58
|
*/
|
|
59
|
-
constructor (
|
|
59
|
+
constructor ({
|
|
60
60
|
query,
|
|
61
61
|
json
|
|
62
|
-
}
|
|
63
|
-
super(
|
|
62
|
+
}) {
|
|
63
|
+
super({
|
|
64
64
|
query,
|
|
65
65
|
json,
|
|
66
66
|
dataKey: 'data.MetaTypeViaAtom'
|
|
67
|
-
}
|
|
67
|
+
})
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
payload () {
|
|
71
|
-
const metaTypeData = this.data()
|
|
71
|
+
const metaTypeData = this.data()
|
|
72
72
|
|
|
73
|
-
if (
|
|
74
|
-
return null
|
|
73
|
+
if (!metaTypeData || metaTypeData.length === 0) {
|
|
74
|
+
return null
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
const response = {
|
|
78
78
|
instances: {},
|
|
79
79
|
instanceCount: {},
|
|
80
80
|
paginatorInfo: {}
|
|
81
|
-
}
|
|
81
|
+
}
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
const metaData = metaTypeData.pop()
|
|
84
84
|
|
|
85
|
-
if (
|
|
86
|
-
response.instances = metaData.instances
|
|
85
|
+
if (metaData.instances) {
|
|
86
|
+
response.instances = metaData.instances
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
if (
|
|
90
|
-
response.instanceCount = metaData.instanceCount
|
|
89
|
+
if (metaData.instanceCount) {
|
|
90
|
+
response.instanceCount = metaData.instanceCount
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
if (
|
|
94
|
-
response.paginatorInfo = metaData.paginatorInfo
|
|
93
|
+
if (metaData.paginatorInfo) {
|
|
94
|
+
response.paginatorInfo = metaData.paginatorInfo
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
return response
|
|
97
|
+
return response
|
|
98
98
|
}
|
|
99
99
|
}
|
|
@@ -46,8 +46,8 @@ 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
|
|
50
|
-
import
|
|
49
|
+
import Query from '../query/Query'
|
|
50
|
+
import Response from './Response'
|
|
51
51
|
|
|
52
52
|
export default class ResponsePolicy extends Response {
|
|
53
53
|
/**
|
|
@@ -56,16 +56,16 @@ export default class ResponsePolicy extends Response {
|
|
|
56
56
|
* @param {Query} query
|
|
57
57
|
* @param {object} json
|
|
58
58
|
*/
|
|
59
|
-
constructor (
|
|
59
|
+
constructor ({
|
|
60
60
|
query,
|
|
61
61
|
json
|
|
62
|
-
}
|
|
63
|
-
super(
|
|
62
|
+
}) {
|
|
63
|
+
super({
|
|
64
64
|
query,
|
|
65
65
|
json
|
|
66
|
-
}
|
|
67
|
-
this.dataKey = 'data.Policy'
|
|
68
|
-
this.init()
|
|
66
|
+
})
|
|
67
|
+
this.dataKey = 'data.Policy'
|
|
68
|
+
this.init()
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
/**
|
|
@@ -73,17 +73,16 @@ export default class ResponsePolicy extends Response {
|
|
|
73
73
|
* @returns {null|object}
|
|
74
74
|
*/
|
|
75
75
|
payload () {
|
|
76
|
+
const policy = this.data()
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if ( !policy ) {
|
|
80
|
-
return null;
|
|
78
|
+
if (!policy) {
|
|
79
|
+
return null
|
|
81
80
|
}
|
|
82
81
|
|
|
83
|
-
if (
|
|
84
|
-
return JSON.parse(
|
|
82
|
+
if (policy.callback) {
|
|
83
|
+
return JSON.parse(policy.callback)
|
|
85
84
|
}
|
|
86
85
|
|
|
87
|
-
return null
|
|
86
|
+
return null
|
|
88
87
|
}
|
|
89
88
|
}
|
|
@@ -45,52 +45,51 @@ 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 Response from './Response'
|
|
49
|
-
import Dot from '../libraries/Dot'
|
|
50
|
-
import Molecule from '../Molecule'
|
|
48
|
+
import Response from './Response'
|
|
49
|
+
import Dot from '../libraries/Dot'
|
|
50
|
+
import Molecule from '../Molecule'
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* Response for proposing new Molecules
|
|
54
54
|
*/
|
|
55
55
|
export default class ResponseProposeMolecule extends Response {
|
|
56
|
-
|
|
57
56
|
/**
|
|
58
57
|
* Class constructor
|
|
59
58
|
*
|
|
60
59
|
* @param {MutationProposeMolecule} query
|
|
61
60
|
* @param {object} json
|
|
62
61
|
*/
|
|
63
|
-
constructor (
|
|
62
|
+
constructor ({
|
|
64
63
|
query,
|
|
65
64
|
json
|
|
66
|
-
}
|
|
67
|
-
super(
|
|
65
|
+
}) {
|
|
66
|
+
super({
|
|
68
67
|
query,
|
|
69
68
|
json,
|
|
70
69
|
dataKey: 'data.ProposeMolecule'
|
|
71
|
-
}
|
|
72
|
-
this.$__clientMolecule = query.molecule()
|
|
70
|
+
})
|
|
71
|
+
this.$__clientMolecule = query.molecule()
|
|
73
72
|
}
|
|
74
73
|
|
|
75
74
|
/**
|
|
76
75
|
* Initialize response object with payload data
|
|
77
76
|
*/
|
|
78
77
|
init () {
|
|
79
|
-
const payloadJson = Dot.get(
|
|
78
|
+
const payloadJson = Dot.get(this.data(), 'payload')
|
|
80
79
|
try {
|
|
81
|
-
this.$__payload = Object.prototype.toString.call(
|
|
82
|
-
JSON.parse(
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
this.$__payload = Object.prototype.toString.call(payloadJson) === '[object String]'
|
|
81
|
+
? JSON.parse(payloadJson)
|
|
82
|
+
: payloadJson
|
|
83
|
+
} catch (err) {
|
|
84
|
+
this.$__payload = null
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
|
|
89
88
|
/**
|
|
90
89
|
* Returns the client molecule
|
|
91
90
|
*/
|
|
92
91
|
clientMolecule () {
|
|
93
|
-
return this.$__clientMolecule
|
|
92
|
+
return this.$__clientMolecule
|
|
94
93
|
}
|
|
95
94
|
|
|
96
95
|
/**
|
|
@@ -99,20 +98,19 @@ export default class ResponseProposeMolecule extends Response {
|
|
|
99
98
|
* @return {Molecule|null}
|
|
100
99
|
*/
|
|
101
100
|
molecule () {
|
|
101
|
+
const data = this.data()
|
|
102
102
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
if ( !data ) {
|
|
106
|
-
return null;
|
|
103
|
+
if (!data) {
|
|
104
|
+
return null
|
|
107
105
|
}
|
|
108
106
|
|
|
109
|
-
const molecule = new Molecule(
|
|
107
|
+
const molecule = new Molecule({})
|
|
110
108
|
|
|
111
|
-
molecule.molecularHash = Dot.get(
|
|
112
|
-
molecule.status = Dot.get(
|
|
113
|
-
molecule.createdAt = Dot.get(
|
|
109
|
+
molecule.molecularHash = Dot.get(data, 'molecularHash')
|
|
110
|
+
molecule.status = Dot.get(data, 'status')
|
|
111
|
+
molecule.createdAt = Dot.get(data, 'createdAt')
|
|
114
112
|
|
|
115
|
-
return molecule
|
|
113
|
+
return molecule
|
|
116
114
|
}
|
|
117
115
|
|
|
118
116
|
/**
|
|
@@ -121,7 +119,7 @@ export default class ResponseProposeMolecule extends Response {
|
|
|
121
119
|
* @return {boolean}
|
|
122
120
|
*/
|
|
123
121
|
success () {
|
|
124
|
-
return this.status() === 'accepted'
|
|
122
|
+
return this.status() === 'accepted'
|
|
125
123
|
}
|
|
126
124
|
|
|
127
125
|
/**
|
|
@@ -130,7 +128,7 @@ export default class ResponseProposeMolecule extends Response {
|
|
|
130
128
|
* @return {string}
|
|
131
129
|
*/
|
|
132
130
|
status () {
|
|
133
|
-
return Dot.get(
|
|
131
|
+
return Dot.get(this.data(), 'status', 'rejected')
|
|
134
132
|
}
|
|
135
133
|
|
|
136
134
|
/**
|
|
@@ -139,7 +137,7 @@ export default class ResponseProposeMolecule extends Response {
|
|
|
139
137
|
* @return {string}
|
|
140
138
|
*/
|
|
141
139
|
reason () {
|
|
142
|
-
return Dot.get(
|
|
140
|
+
return Dot.get(this.data(), 'reason', 'Invalid response from server')
|
|
143
141
|
}
|
|
144
142
|
|
|
145
143
|
/**
|
|
@@ -148,7 +146,6 @@ export default class ResponseProposeMolecule extends Response {
|
|
|
148
146
|
* @return {null}
|
|
149
147
|
*/
|
|
150
148
|
payload () {
|
|
151
|
-
return this.$__payload
|
|
149
|
+
return this.$__payload
|
|
152
150
|
}
|
|
153
|
-
|
|
154
151
|
}
|
|
@@ -46,60 +46,57 @@ 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 Query from '../query/Query'
|
|
50
|
-
import Response from './Response'
|
|
49
|
+
import Query from '../query/Query'
|
|
50
|
+
import Response from './Response'
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* Response for QueryActiveSession
|
|
54
54
|
*/
|
|
55
55
|
export default class ResponseQueryActiveSession extends Response {
|
|
56
|
-
|
|
57
56
|
/**
|
|
58
57
|
* Class constructor
|
|
59
58
|
*
|
|
60
59
|
* @param {Query} query
|
|
61
60
|
* @param {object} json
|
|
62
61
|
*/
|
|
63
|
-
constructor (
|
|
62
|
+
constructor ({
|
|
64
63
|
query,
|
|
65
64
|
json
|
|
66
|
-
}
|
|
67
|
-
super(
|
|
65
|
+
}) {
|
|
66
|
+
super({
|
|
68
67
|
query,
|
|
69
68
|
json,
|
|
70
69
|
dataKey: 'data.ActiveUser'
|
|
71
|
-
}
|
|
70
|
+
})
|
|
72
71
|
}
|
|
73
72
|
|
|
74
73
|
payload () {
|
|
75
|
-
const list = this.data()
|
|
74
|
+
const list = this.data()
|
|
76
75
|
|
|
77
|
-
if (
|
|
78
|
-
return null
|
|
76
|
+
if (!list) {
|
|
77
|
+
return null
|
|
79
78
|
}
|
|
80
79
|
|
|
81
|
-
const activeUsers = []
|
|
82
|
-
|
|
83
|
-
for ( let item of list ) {
|
|
80
|
+
const activeUsers = []
|
|
84
81
|
|
|
85
|
-
|
|
82
|
+
for (const item of list) {
|
|
83
|
+
const activeSession = { ...item }
|
|
86
84
|
|
|
87
|
-
if (
|
|
88
|
-
activeSession.jsonData = JSON.parse(
|
|
85
|
+
if (activeSession.jsonData) {
|
|
86
|
+
activeSession.jsonData = JSON.parse(activeSession.jsonData)
|
|
89
87
|
}
|
|
90
88
|
|
|
91
|
-
if (
|
|
92
|
-
activeSession.createdAt = new Date(
|
|
89
|
+
if (activeSession.createdAt) {
|
|
90
|
+
activeSession.createdAt = new Date(activeSession.createdAt)
|
|
93
91
|
}
|
|
94
92
|
|
|
95
|
-
if (
|
|
96
|
-
activeSession.updatedAt = new Date(
|
|
93
|
+
if (activeSession.updatedAt) {
|
|
94
|
+
activeSession.updatedAt = new Date(activeSession.updatedAt)
|
|
97
95
|
}
|
|
98
96
|
|
|
99
|
-
activeUsers.push(
|
|
97
|
+
activeUsers.push(activeSession)
|
|
100
98
|
}
|
|
101
99
|
|
|
102
|
-
return activeUsers
|
|
100
|
+
return activeUsers
|
|
103
101
|
}
|
|
104
|
-
|
|
105
102
|
}
|
|
@@ -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'
|
|
48
|
+
import Query from '../query/Query'
|
|
49
|
+
import Response from './Response'
|
|
50
50
|
|
|
51
51
|
export default class ResponseQueryUserActivity extends Response {
|
|
52
52
|
/**
|
|
@@ -55,27 +55,26 @@ export default class ResponseQueryUserActivity extends Response {
|
|
|
55
55
|
* @param {Query} query
|
|
56
56
|
* @param {object} json
|
|
57
57
|
*/
|
|
58
|
-
constructor (
|
|
58
|
+
constructor ({
|
|
59
59
|
query,
|
|
60
60
|
json
|
|
61
|
-
}
|
|
62
|
-
super(
|
|
61
|
+
}) {
|
|
62
|
+
super({
|
|
63
63
|
query,
|
|
64
64
|
json,
|
|
65
65
|
dataKey: 'data.UserActivity'
|
|
66
|
-
}
|
|
66
|
+
})
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
payload () {
|
|
70
|
-
const data = JSON.parse(
|
|
70
|
+
const data = JSON.parse(JSON.stringify(this.data()))
|
|
71
71
|
|
|
72
|
-
if (
|
|
73
|
-
for (
|
|
74
|
-
datum.jsonData = JSON.parse(
|
|
72
|
+
if (data.instances) {
|
|
73
|
+
for (const datum of data.instances) {
|
|
74
|
+
datum.jsonData = JSON.parse(datum.jsonData)
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
return data
|
|
78
|
+
return data
|
|
79
79
|
}
|
|
80
|
-
|
|
81
80
|
}
|
|
@@ -45,37 +45,34 @@ 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 Dot from '../libraries/Dot'
|
|
49
|
-
import InvalidResponseException from '../exception/InvalidResponseException'
|
|
50
|
-
import ResponseProposeMolecule from './ResponseProposeMolecule'
|
|
48
|
+
import Dot from '../libraries/Dot'
|
|
49
|
+
import InvalidResponseException from '../exception/InvalidResponseException'
|
|
50
|
+
import ResponseProposeMolecule from './ResponseProposeMolecule'
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* Response for auth token mutation
|
|
54
54
|
*/
|
|
55
55
|
export default class ResponseRequestAuthorization extends ResponseProposeMolecule {
|
|
56
|
-
|
|
57
|
-
|
|
58
56
|
/**
|
|
59
57
|
* return the authorization key
|
|
60
58
|
*
|
|
61
59
|
* @param key
|
|
62
60
|
* @return {*}
|
|
63
61
|
*/
|
|
64
|
-
payloadKey (
|
|
65
|
-
if (
|
|
66
|
-
throw new InvalidResponseException(
|
|
62
|
+
payloadKey (key) {
|
|
63
|
+
if (!Dot.has(this.payload(), key)) {
|
|
64
|
+
throw new InvalidResponseException(`ResponseRequestAuthorization::payloadKey() - '${ key }' key was not found in the payload!`)
|
|
67
65
|
}
|
|
68
|
-
return Dot.get(
|
|
66
|
+
return Dot.get(this.payload(), key)
|
|
69
67
|
}
|
|
70
68
|
|
|
71
|
-
|
|
72
69
|
/**
|
|
73
70
|
* Returns the auth token
|
|
74
71
|
*
|
|
75
72
|
* @return {string}
|
|
76
73
|
*/
|
|
77
74
|
token () {
|
|
78
|
-
return this.payloadKey(
|
|
75
|
+
return this.payloadKey('token')
|
|
79
76
|
}
|
|
80
77
|
|
|
81
78
|
/**
|
|
@@ -84,7 +81,7 @@ export default class ResponseRequestAuthorization extends ResponseProposeMolecul
|
|
|
84
81
|
* @return {string}
|
|
85
82
|
*/
|
|
86
83
|
time () {
|
|
87
|
-
return this.payloadKey(
|
|
84
|
+
return this.payloadKey('time')
|
|
88
85
|
}
|
|
89
86
|
|
|
90
87
|
/**
|
|
@@ -92,7 +89,7 @@ export default class ResponseRequestAuthorization extends ResponseProposeMolecul
|
|
|
92
89
|
* @return {string}
|
|
93
90
|
*/
|
|
94
91
|
encrypt () {
|
|
95
|
-
return this.payloadKey(
|
|
92
|
+
return this.payloadKey('encrypt')
|
|
96
93
|
}
|
|
97
94
|
|
|
98
95
|
/**
|
|
@@ -100,8 +97,6 @@ export default class ResponseRequestAuthorization extends ResponseProposeMolecul
|
|
|
100
97
|
* @return {string}
|
|
101
98
|
*/
|
|
102
99
|
pubKey () {
|
|
103
|
-
return this.payloadKey(
|
|
100
|
+
return this.payloadKey('key')
|
|
104
101
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
102
|
}
|
|
@@ -45,30 +45,29 @@ 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 Response from './Response'
|
|
49
|
-
import Dot from '../libraries/Dot'
|
|
50
|
-
import InvalidResponseException from '../exception/InvalidResponseException'
|
|
48
|
+
import Response from './Response'
|
|
49
|
+
import Dot from '../libraries/Dot'
|
|
50
|
+
import InvalidResponseException from '../exception/InvalidResponseException'
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* Response for guest auth mutation
|
|
54
54
|
*/
|
|
55
55
|
export default class ResponseRequestAuthorizationGuest extends Response {
|
|
56
|
-
|
|
57
56
|
/**
|
|
58
57
|
* Class constructor
|
|
59
58
|
*
|
|
60
59
|
* @param {MutationRequestAuthorizationGuest} query
|
|
61
60
|
* @param json
|
|
62
61
|
*/
|
|
63
|
-
constructor (
|
|
62
|
+
constructor ({
|
|
64
63
|
query,
|
|
65
64
|
json
|
|
66
|
-
}
|
|
67
|
-
super(
|
|
65
|
+
}) {
|
|
66
|
+
super({
|
|
68
67
|
query,
|
|
69
68
|
json,
|
|
70
69
|
dataKey: 'data.AccessToken'
|
|
71
|
-
}
|
|
70
|
+
})
|
|
72
71
|
}
|
|
73
72
|
|
|
74
73
|
/**
|
|
@@ -77,7 +76,7 @@ export default class ResponseRequestAuthorizationGuest extends Response {
|
|
|
77
76
|
* @return {string}
|
|
78
77
|
*/
|
|
79
78
|
reason () {
|
|
80
|
-
return 'Invalid response from server'
|
|
79
|
+
return 'Invalid response from server'
|
|
81
80
|
}
|
|
82
81
|
|
|
83
82
|
/**
|
|
@@ -86,7 +85,7 @@ export default class ResponseRequestAuthorizationGuest extends Response {
|
|
|
86
85
|
* @return {boolean}
|
|
87
86
|
*/
|
|
88
87
|
success () {
|
|
89
|
-
return this.payload() !== null
|
|
88
|
+
return this.payload() !== null
|
|
90
89
|
}
|
|
91
90
|
|
|
92
91
|
/**
|
|
@@ -95,7 +94,7 @@ export default class ResponseRequestAuthorizationGuest extends Response {
|
|
|
95
94
|
* @return {null|Wallet}
|
|
96
95
|
*/
|
|
97
96
|
payload () {
|
|
98
|
-
return this.data()
|
|
97
|
+
return this.data()
|
|
99
98
|
}
|
|
100
99
|
|
|
101
100
|
/**
|
|
@@ -104,11 +103,11 @@ export default class ResponseRequestAuthorizationGuest extends Response {
|
|
|
104
103
|
* @param key
|
|
105
104
|
* @return {*}
|
|
106
105
|
*/
|
|
107
|
-
payloadKey (
|
|
108
|
-
if (
|
|
109
|
-
throw new InvalidResponseException(
|
|
106
|
+
payloadKey (key) {
|
|
107
|
+
if (!Dot.has(this.payload(), key)) {
|
|
108
|
+
throw new InvalidResponseException(`ResponseAuthorizationGuest::payloadKey() - '${ key }' key is not found in the payload!`)
|
|
110
109
|
}
|
|
111
|
-
return Dot.get(
|
|
110
|
+
return Dot.get(this.payload(), key)
|
|
112
111
|
}
|
|
113
112
|
|
|
114
113
|
/**
|
|
@@ -117,7 +116,7 @@ export default class ResponseRequestAuthorizationGuest extends Response {
|
|
|
117
116
|
* @return {*}
|
|
118
117
|
*/
|
|
119
118
|
token () {
|
|
120
|
-
return this.payloadKey(
|
|
119
|
+
return this.payloadKey('token')
|
|
121
120
|
}
|
|
122
121
|
|
|
123
122
|
/**
|
|
@@ -126,7 +125,7 @@ export default class ResponseRequestAuthorizationGuest extends Response {
|
|
|
126
125
|
* @return {*}
|
|
127
126
|
*/
|
|
128
127
|
time () {
|
|
129
|
-
return this.payloadKey(
|
|
128
|
+
return this.payloadKey('time')
|
|
130
129
|
}
|
|
131
130
|
|
|
132
131
|
/**
|
|
@@ -135,7 +134,7 @@ export default class ResponseRequestAuthorizationGuest extends Response {
|
|
|
135
134
|
* @return {string}
|
|
136
135
|
*/
|
|
137
136
|
pubKey () {
|
|
138
|
-
return this.payloadKey(
|
|
137
|
+
return this.payloadKey('key')
|
|
139
138
|
}
|
|
140
139
|
|
|
141
140
|
/**
|
|
@@ -143,8 +142,6 @@ export default class ResponseRequestAuthorizationGuest extends Response {
|
|
|
143
142
|
* @return {string}
|
|
144
143
|
*/
|
|
145
144
|
encrypt () {
|
|
146
|
-
return this.payloadKey(
|
|
145
|
+
return this.payloadKey('encrypt')
|
|
147
146
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
147
|
}
|
|
@@ -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 ResponseProposeMolecule from './ResponseProposeMolecule'
|
|
48
|
+
import ResponseProposeMolecule from './ResponseProposeMolecule'
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Response for identifier creation
|