@wishknish/knishio-client-ts 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -0
- package/README.md +425 -0
- package/dist/index.cjs +9961 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.iife.js +32241 -0
- package/dist/index.iife.js.map +1 -0
- package/dist/index.js +9853 -0
- package/dist/index.js.map +1 -0
- package/package.json +113 -0
- package/src/AuthToken.ts +214 -0
- package/src/KnishIOClient.ts +2020 -0
- package/src/constants.ts +398 -0
- package/src/core/Atom.ts +646 -0
- package/src/core/AtomMeta.ts +278 -0
- package/src/core/Meta.ts +428 -0
- package/src/core/Molecule.ts +825 -0
- package/src/core/PolicyMeta.ts +130 -0
- package/src/core/TokenUnit.ts +148 -0
- package/src/core/Wallet.ts +467 -0
- package/src/exception/AtomIndexException.ts +97 -0
- package/src/exception/AtomsMissingException.ts +109 -0
- package/src/exception/AuthorizationRejectedException.ts +63 -0
- package/src/exception/BalanceInsufficientException.ts +58 -0
- package/src/exception/BaseException.ts +275 -0
- package/src/exception/BatchIdException.ts +58 -0
- package/src/exception/CodeException.ts +119 -0
- package/src/exception/DecryptionKeyException.ts +65 -0
- package/src/exception/InvalidResponseException.ts +112 -0
- package/src/exception/MetaMissingException.ts +58 -0
- package/src/exception/MolecularHashMismatchException.ts +115 -0
- package/src/exception/MolecularHashMissingException.ts +58 -0
- package/src/exception/NegativeAmountException.ts +58 -0
- package/src/exception/PolicyInvalidException.ts +58 -0
- package/src/exception/SignatureMalformedException.ts +58 -0
- package/src/exception/SignatureMismatchException.ts +98 -0
- package/src/exception/StackableUnitAmountException.ts +65 -0
- package/src/exception/StackableUnitDecimalsException.ts +65 -0
- package/src/exception/TransferBalanceException.ts +98 -0
- package/src/exception/TransferMalformedException.ts +58 -0
- package/src/exception/TransferMismatchedException.ts +58 -0
- package/src/exception/TransferRemainderException.ts +58 -0
- package/src/exception/TransferToSelfException.ts +58 -0
- package/src/exception/TransferUnbalancedException.ts +58 -0
- package/src/exception/UnauthenticatedException.ts +147 -0
- package/src/exception/WalletCredentialException.ts +108 -0
- package/src/exception/WalletShadowException.ts +65 -0
- package/src/exception/WrongTokenTypeException.ts +58 -0
- package/src/exception/index.ts +272 -0
- package/src/index.ts +512 -0
- package/src/instance/rules/Callback.ts +257 -0
- package/src/instance/rules/Condition.ts +96 -0
- package/src/instance/rules/Meta.ts +163 -0
- package/src/instance/rules/Rule.ts +29 -0
- package/src/instance/rules/exception/RuleArgumentException.ts +65 -0
- package/src/libraries/CheckMolecule.ts +581 -0
- package/src/libraries/Decimal.ts +94 -0
- package/src/libraries/Dot.ts +202 -0
- package/src/libraries/GraphQLClient.ts +276 -0
- package/src/libraries/Hex.ts +155 -0
- package/src/libraries/UrqlClientWrapper.ts +336 -0
- package/src/libraries/array.ts +91 -0
- package/src/libraries/crypto.ts +816 -0
- package/src/libraries/strings.ts +458 -0
- package/src/mutation/Mutation.ts +103 -0
- package/src/mutation/MutationActiveSession.ts +108 -0
- package/src/mutation/MutationClaimShadowWallet.ts +91 -0
- package/src/mutation/MutationCreateIdentifier.ts +86 -0
- package/src/mutation/MutationCreateMeta.ts +92 -0
- package/src/mutation/MutationCreateRule.ts +90 -0
- package/src/mutation/MutationCreateToken.ts +92 -0
- package/src/mutation/MutationCreateWallet.ts +78 -0
- package/src/mutation/MutationDepositBufferToken.ts +72 -0
- package/src/mutation/MutationLinkIdentifier.ts +87 -0
- package/src/mutation/MutationProposeMolecule.ts +147 -0
- package/src/mutation/MutationRequestAuthorization.ts +77 -0
- package/src/mutation/MutationRequestAuthorizationGuest.ts +85 -0
- package/src/mutation/MutationRequestTokens.ts +98 -0
- package/src/mutation/MutationTransferTokens.ts +87 -0
- package/src/mutation/MutationWithdrawBufferToken.ts +73 -0
- package/src/query/Query.ts +187 -0
- package/src/query/QueryActiveSession.ts +89 -0
- package/src/query/QueryAtom.ts +275 -0
- package/src/query/QueryBalance.ts +102 -0
- package/src/query/QueryBatch.ts +145 -0
- package/src/query/QueryBatchHistory.ts +86 -0
- package/src/query/QueryContinuId.ts +91 -0
- package/src/query/QueryMetaType.ts +177 -0
- package/src/query/QueryMetaTypeViaAtom.ts +199 -0
- package/src/query/QueryPolicy.ts +91 -0
- package/src/query/QueryToken.ts +90 -0
- package/src/query/QueryUserActivity.ts +153 -0
- package/src/query/QueryWalletBundle.ts +92 -0
- package/src/query/QueryWalletList.ts +106 -0
- package/src/response/EnhancedResponse.ts +345 -0
- package/src/response/Response.ts +254 -0
- package/src/response/ResponseActiveSession.ts +72 -0
- package/src/response/ResponseAtom.ts +132 -0
- package/src/response/ResponseAuthorizationGuest.ts +119 -0
- package/src/response/ResponseBalance.ts +153 -0
- package/src/response/ResponseClaimShadowWallet.ts +56 -0
- package/src/response/ResponseContinuId.ts +101 -0
- package/src/response/ResponseCreateIdentifier.ts +56 -0
- package/src/response/ResponseCreateMeta.ts +58 -0
- package/src/response/ResponseCreateRule.ts +56 -0
- package/src/response/ResponseCreateToken.ts +58 -0
- package/src/response/ResponseCreateWallet.ts +58 -0
- package/src/response/ResponseLinkIdentifier.ts +87 -0
- package/src/response/ResponseMetaBatch.ts +72 -0
- package/src/response/ResponseMetaType.ts +108 -0
- package/src/response/ResponseMetaTypeViaAtom.ts +108 -0
- package/src/response/ResponsePolicy.ts +90 -0
- package/src/response/ResponseProposeMolecule.ts +155 -0
- package/src/response/ResponseQueryActiveSession.ts +105 -0
- package/src/response/ResponseQueryUserActivity.ts +89 -0
- package/src/response/ResponseRequestAuthorization.ts +100 -0
- package/src/response/ResponseRequestAuthorizationGuest.ts +133 -0
- package/src/response/ResponseRequestTokens.ts +58 -0
- package/src/response/ResponseTransferTokens.ts +72 -0
- package/src/response/ResponseWalletBundle.ts +95 -0
- package/src/response/ResponseWalletList.ts +165 -0
- package/src/schemas/index.ts +457 -0
- package/src/subscribe/ActiveSessionSubscribe.ts +72 -0
- package/src/subscribe/ActiveWalletSubscribe.ts +99 -0
- package/src/subscribe/CreateMoleculeSubscribe.ts +106 -0
- package/src/subscribe/Subscribe.ts +182 -0
- package/src/subscribe/WalletStatusSubscribe.ts +70 -0
- package/src/subscribe/index.ts +59 -0
- package/src/types/assertions.ts +722 -0
- package/src/types/client.ts +567 -0
- package/src/types/crypto.ts +541 -0
- package/src/types/graphql.ts +630 -0
- package/src/types/guards.ts +659 -0
- package/src/types/index.ts +614 -0
- package/src/types/response.ts +133 -0
- package/src/types/template-literals.ts +382 -0
- package/src/validation/UNIVERSAL_CONFIGURATION_INTERFACES.ts +580 -0
- package/src/validation/ValidationService.ts +607 -0
- package/src/validation/schemas.ts +447 -0
- package/src/versions/HashAtom.ts +170 -0
- package/src/versions/Version4.ts +120 -0
- package/src/versions/index.ts +80 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,512 @@
|
|
|
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-TS for information.
|
|
45
|
+
|
|
46
|
+
License: https://github.com/WishKnish/KnishIO-Client-TS/blob/master/LICENSE
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* KnishIO TypeScript SDK - Main Export Module
|
|
51
|
+
*
|
|
52
|
+
* A comprehensive TypeScript implementation of the Knish.IO SDK for
|
|
53
|
+
* post-blockchain distributed ledger technology with enhanced type safety
|
|
54
|
+
* and perfect cross-platform compatibility.
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
// =============================================================================
|
|
58
|
+
// CORE CLASSES
|
|
59
|
+
// =============================================================================
|
|
60
|
+
|
|
61
|
+
// Core transaction classes
|
|
62
|
+
export { default as Atom } from './core/Atom'
|
|
63
|
+
export { default as Molecule } from './core/Molecule'
|
|
64
|
+
export { default as Wallet } from './core/Wallet'
|
|
65
|
+
export { default as Meta } from './core/Meta'
|
|
66
|
+
export { default as AtomMeta } from './core/AtomMeta'
|
|
67
|
+
|
|
68
|
+
// Validation
|
|
69
|
+
export { default as CheckMolecule } from './libraries/CheckMolecule'
|
|
70
|
+
|
|
71
|
+
// Utilities
|
|
72
|
+
export { default as Dot } from './libraries/Dot'
|
|
73
|
+
export { deepCloning, chunkArray, diff, intersect } from './libraries/array'
|
|
74
|
+
|
|
75
|
+
// Client and authentication
|
|
76
|
+
export { default as KnishIOClient } from './KnishIOClient'
|
|
77
|
+
export { default as AuthToken } from './AuthToken'
|
|
78
|
+
export { default as GraphQLClient } from './libraries/GraphQLClient'
|
|
79
|
+
|
|
80
|
+
// Base classes for queries and mutations
|
|
81
|
+
export { default as Query } from './query/Query'
|
|
82
|
+
export { default as Mutation } from './mutation/Mutation'
|
|
83
|
+
export { default as Response } from './response/Response'
|
|
84
|
+
|
|
85
|
+
// Essential Query classes (Phase 1)
|
|
86
|
+
export { default as QueryBalance } from './query/QueryBalance'
|
|
87
|
+
export { default as QueryWalletBundle } from './query/QueryWalletBundle'
|
|
88
|
+
|
|
89
|
+
// Phase 2 Tier 1 Query classes
|
|
90
|
+
export { default as QueryWalletList } from './query/QueryWalletList'
|
|
91
|
+
export { default as QueryAtom } from './query/QueryAtom'
|
|
92
|
+
|
|
93
|
+
// Phase 2 Tier 2 Priority 1: Meta Operations
|
|
94
|
+
export { default as QueryMetaType } from './query/QueryMetaType'
|
|
95
|
+
export { default as QueryMetaTypeViaAtom } from './query/QueryMetaTypeViaAtom'
|
|
96
|
+
|
|
97
|
+
// Phase 2 Tier 2 Priority 3: Essential Query Operations
|
|
98
|
+
export { default as QueryContinuId } from './query/QueryContinuId'
|
|
99
|
+
export { default as QueryBatch } from './query/QueryBatch'
|
|
100
|
+
|
|
101
|
+
// Essential Mutation classes (Phase 1)
|
|
102
|
+
export { default as MutationProposeMolecule } from './mutation/MutationProposeMolecule'
|
|
103
|
+
export { default as MutationTransferTokens } from './mutation/MutationTransferTokens'
|
|
104
|
+
|
|
105
|
+
// Phase 2 Tier 1 Mutation classes
|
|
106
|
+
export { default as MutationCreateWallet } from './mutation/MutationCreateWallet'
|
|
107
|
+
export { default as MutationRequestAuthorization } from './mutation/MutationRequestAuthorization'
|
|
108
|
+
|
|
109
|
+
// Phase 2 Tier 2 Priority 1: Meta Operations
|
|
110
|
+
export { default as MutationCreateMeta } from './mutation/MutationCreateMeta'
|
|
111
|
+
|
|
112
|
+
// Phase 2 Tier 2 Priority 2: Token Operations
|
|
113
|
+
export { default as MutationCreateToken } from './mutation/MutationCreateToken'
|
|
114
|
+
export { default as MutationRequestTokens } from './mutation/MutationRequestTokens'
|
|
115
|
+
|
|
116
|
+
// Essential Response classes (Phase 1)
|
|
117
|
+
export { default as ResponseBalance } from './response/ResponseBalance'
|
|
118
|
+
export { default as ResponseWalletBundle } from './response/ResponseWalletBundle'
|
|
119
|
+
export { default as ResponseProposeMolecule } from './response/ResponseProposeMolecule'
|
|
120
|
+
export { default as ResponseTransferTokens } from './response/ResponseTransferTokens'
|
|
121
|
+
|
|
122
|
+
// Phase 2 Tier 1 Response classes
|
|
123
|
+
export { default as ResponseWalletList } from './response/ResponseWalletList'
|
|
124
|
+
export { default as ResponseAtom } from './response/ResponseAtom'
|
|
125
|
+
export { default as ResponseCreateWallet } from './response/ResponseCreateWallet'
|
|
126
|
+
export { default as ResponseRequestAuthorization } from './response/ResponseRequestAuthorization'
|
|
127
|
+
|
|
128
|
+
// Phase 2 Tier 2 Priority 1: Meta Operations
|
|
129
|
+
export { default as ResponseCreateMeta } from './response/ResponseCreateMeta'
|
|
130
|
+
export { default as ResponseMetaType } from './response/ResponseMetaType'
|
|
131
|
+
export { default as ResponseMetaTypeViaAtom } from './response/ResponseMetaTypeViaAtom'
|
|
132
|
+
|
|
133
|
+
// Phase 2 Tier 2 Priority 2: Token Operations
|
|
134
|
+
export { default as ResponseCreateToken } from './response/ResponseCreateToken'
|
|
135
|
+
export { default as ResponseRequestTokens } from './response/ResponseRequestTokens'
|
|
136
|
+
|
|
137
|
+
// Phase 2 Tier 2 Priority 3: Essential Query Operations
|
|
138
|
+
export { default as ResponseContinuId } from './response/ResponseContinuId'
|
|
139
|
+
// QueryBatch uses base Response class directly
|
|
140
|
+
|
|
141
|
+
// Phase 2 Prerequisite classes (completed)
|
|
142
|
+
export { default as TokenUnit } from './core/TokenUnit'
|
|
143
|
+
export { default as PolicyMeta } from './core/PolicyMeta'
|
|
144
|
+
|
|
145
|
+
// =============================================================================
|
|
146
|
+
// LIBRARY FUNCTIONS AND UTILITIES
|
|
147
|
+
// =============================================================================
|
|
148
|
+
|
|
149
|
+
// String utilities - maintaining compatibility with JS SDK
|
|
150
|
+
import {
|
|
151
|
+
chunkSubstr,
|
|
152
|
+
randomString,
|
|
153
|
+
charsetBaseConvert,
|
|
154
|
+
bufferToHexString,
|
|
155
|
+
hexStringToBuffer,
|
|
156
|
+
hexToBase64,
|
|
157
|
+
base64ToHex,
|
|
158
|
+
isHex,
|
|
159
|
+
isNumeric,
|
|
160
|
+
toCamelCase,
|
|
161
|
+
toSnakeCase,
|
|
162
|
+
capitalize,
|
|
163
|
+
truncate
|
|
164
|
+
} from './libraries/strings'
|
|
165
|
+
|
|
166
|
+
// Re-export for external use
|
|
167
|
+
export {
|
|
168
|
+
chunkSubstr,
|
|
169
|
+
randomString,
|
|
170
|
+
charsetBaseConvert,
|
|
171
|
+
bufferToHexString,
|
|
172
|
+
hexStringToBuffer,
|
|
173
|
+
hexToBase64,
|
|
174
|
+
base64ToHex,
|
|
175
|
+
isHex,
|
|
176
|
+
isNumeric,
|
|
177
|
+
toCamelCase,
|
|
178
|
+
toSnakeCase,
|
|
179
|
+
capitalize,
|
|
180
|
+
truncate
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Cryptographic functions - ensuring cross-platform compatibility
|
|
184
|
+
import {
|
|
185
|
+
shake256,
|
|
186
|
+
generateSecret,
|
|
187
|
+
generateBundleHash,
|
|
188
|
+
generateBatchId,
|
|
189
|
+
generatePosition,
|
|
190
|
+
generateWalletKey,
|
|
191
|
+
generateWalletAddress,
|
|
192
|
+
validateSecret,
|
|
193
|
+
validateBundleHash,
|
|
194
|
+
validatePosition,
|
|
195
|
+
validateWalletAddress,
|
|
196
|
+
runCompatibilityTests,
|
|
197
|
+
CRYPTO_CONSTANTS,
|
|
198
|
+
// NEW: WOTS+ signature system and Base17 conversion
|
|
199
|
+
convertToBase17,
|
|
200
|
+
enumerateMolecularHash,
|
|
201
|
+
normalizeMolecularHash,
|
|
202
|
+
generateOTSSignature,
|
|
203
|
+
verifyOTSSignature,
|
|
204
|
+
validateOTSSignature,
|
|
205
|
+
validateMolecularHashForSignature,
|
|
206
|
+
runExtendedCompatibilityTests,
|
|
207
|
+
EXTENDED_COMPATIBILITY_TEST_VECTORS
|
|
208
|
+
} from './libraries/crypto'
|
|
209
|
+
|
|
210
|
+
// Re-export for external use
|
|
211
|
+
export {
|
|
212
|
+
shake256,
|
|
213
|
+
generateSecret,
|
|
214
|
+
generateBundleHash,
|
|
215
|
+
generateBatchId,
|
|
216
|
+
generatePosition,
|
|
217
|
+
generateWalletKey,
|
|
218
|
+
generateWalletAddress,
|
|
219
|
+
validateSecret,
|
|
220
|
+
validateBundleHash,
|
|
221
|
+
validatePosition,
|
|
222
|
+
validateWalletAddress,
|
|
223
|
+
runCompatibilityTests,
|
|
224
|
+
CRYPTO_CONSTANTS,
|
|
225
|
+
// NEW: WOTS+ signature system and Base17 conversion
|
|
226
|
+
convertToBase17,
|
|
227
|
+
enumerateMolecularHash,
|
|
228
|
+
normalizeMolecularHash,
|
|
229
|
+
generateOTSSignature,
|
|
230
|
+
verifyOTSSignature,
|
|
231
|
+
validateOTSSignature,
|
|
232
|
+
validateMolecularHashForSignature,
|
|
233
|
+
runExtendedCompatibilityTests,
|
|
234
|
+
EXTENDED_COMPATIBILITY_TEST_VECTORS
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// =============================================================================
|
|
238
|
+
// EXCEPTION SYSTEM
|
|
239
|
+
// =============================================================================
|
|
240
|
+
|
|
241
|
+
export {
|
|
242
|
+
BaseException,
|
|
243
|
+
AtomIndexException,
|
|
244
|
+
AtomsMissingException,
|
|
245
|
+
MolecularHashMismatchException,
|
|
246
|
+
SignatureMismatchException,
|
|
247
|
+
TransferBalanceException,
|
|
248
|
+
WalletCredentialException,
|
|
249
|
+
InvalidResponseException,
|
|
250
|
+
ExceptionFactory,
|
|
251
|
+
EXCEPTION_TYPES,
|
|
252
|
+
EXCEPTION_CODES
|
|
253
|
+
} from './exception'
|
|
254
|
+
|
|
255
|
+
// =============================================================================
|
|
256
|
+
// TYPE DEFINITIONS
|
|
257
|
+
// =============================================================================
|
|
258
|
+
|
|
259
|
+
export type {
|
|
260
|
+
// Core types
|
|
261
|
+
WalletAddress,
|
|
262
|
+
BundleHash,
|
|
263
|
+
Position,
|
|
264
|
+
MolecularHash,
|
|
265
|
+
TokenSlug,
|
|
266
|
+
MetaType,
|
|
267
|
+
MetaId,
|
|
268
|
+
CellSlug,
|
|
269
|
+
AtomIsotope,
|
|
270
|
+
HexString,
|
|
271
|
+
Base17Hash,
|
|
272
|
+
MetaData,
|
|
273
|
+
|
|
274
|
+
// Parameter types
|
|
275
|
+
AtomParams,
|
|
276
|
+
WalletParams,
|
|
277
|
+
MoleculeParams,
|
|
278
|
+
KnishIOClientConfig,
|
|
279
|
+
AuthParams,
|
|
280
|
+
TransferParams,
|
|
281
|
+
CreateTokenParams,
|
|
282
|
+
RequestTokensParams,
|
|
283
|
+
|
|
284
|
+
// Query types
|
|
285
|
+
BalanceQueryParams,
|
|
286
|
+
MetaQueryParams,
|
|
287
|
+
WalletQueryParams,
|
|
288
|
+
|
|
289
|
+
// Response types
|
|
290
|
+
BaseResponse,
|
|
291
|
+
ValidationResult,
|
|
292
|
+
|
|
293
|
+
// Cryptographic types
|
|
294
|
+
SHAKE256Options,
|
|
295
|
+
SecretGenerationOptions,
|
|
296
|
+
BundleHashOptions,
|
|
297
|
+
PositionGenerationOptions,
|
|
298
|
+
KeyGenerationOptions,
|
|
299
|
+
SignatureOptions,
|
|
300
|
+
VerificationOptions,
|
|
301
|
+
|
|
302
|
+
// GraphQL types
|
|
303
|
+
GraphQLRequest,
|
|
304
|
+
GraphQLResponse,
|
|
305
|
+
GraphQLError,
|
|
306
|
+
QueryOperation,
|
|
307
|
+
MutationOperation
|
|
308
|
+
} from './types'
|
|
309
|
+
|
|
310
|
+
// =============================================================================
|
|
311
|
+
// UTILITY FUNCTIONS
|
|
312
|
+
// =============================================================================
|
|
313
|
+
|
|
314
|
+
import {
|
|
315
|
+
isHexString,
|
|
316
|
+
isWalletAddress,
|
|
317
|
+
isBundleHash,
|
|
318
|
+
isPosition,
|
|
319
|
+
isMolecularHash,
|
|
320
|
+
isAtomIsotope,
|
|
321
|
+
createWalletAddress,
|
|
322
|
+
createBundleHash,
|
|
323
|
+
createPosition,
|
|
324
|
+
createTokenSlug,
|
|
325
|
+
createMolecularHash
|
|
326
|
+
} from './types'
|
|
327
|
+
|
|
328
|
+
// Re-export for external use
|
|
329
|
+
export {
|
|
330
|
+
isHexString,
|
|
331
|
+
isWalletAddress,
|
|
332
|
+
isBundleHash,
|
|
333
|
+
isPosition,
|
|
334
|
+
isMolecularHash,
|
|
335
|
+
isAtomIsotope,
|
|
336
|
+
createWalletAddress,
|
|
337
|
+
createBundleHash,
|
|
338
|
+
createPosition,
|
|
339
|
+
createTokenSlug,
|
|
340
|
+
createMolecularHash
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// =============================================================================
|
|
344
|
+
// VERSION AND SDK INFORMATION
|
|
345
|
+
// =============================================================================
|
|
346
|
+
|
|
347
|
+
export const SDK_VERSION = '1.0.0'
|
|
348
|
+
export const SDK_NAME = 'KnishIO-Client-TS'
|
|
349
|
+
export const COMPATIBLE_SERVER_VERSIONS = [4, 5]
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* SDK Information object
|
|
353
|
+
*/
|
|
354
|
+
export const SDK_INFO = {
|
|
355
|
+
name: SDK_NAME,
|
|
356
|
+
version: SDK_VERSION,
|
|
357
|
+
description: 'TypeScript SDK for Knish.IO post-blockchain distributed ledger',
|
|
358
|
+
compatibleServerVersions: COMPATIBLE_SERVER_VERSIONS,
|
|
359
|
+
features: [
|
|
360
|
+
'Post-quantum cryptography (XMSS, ML-KEM768)',
|
|
361
|
+
'Cross-platform compatibility',
|
|
362
|
+
'Type-safe APIs',
|
|
363
|
+
'DAG-based transaction processing',
|
|
364
|
+
'GraphQL integration',
|
|
365
|
+
'Real-time subscriptions',
|
|
366
|
+
'Cellular architecture support'
|
|
367
|
+
],
|
|
368
|
+
build: {
|
|
369
|
+
target: 'ES2022',
|
|
370
|
+
formats: ['esm', 'cjs', 'iife'],
|
|
371
|
+
typescript: true,
|
|
372
|
+
strictMode: true
|
|
373
|
+
}
|
|
374
|
+
} as const
|
|
375
|
+
|
|
376
|
+
// =============================================================================
|
|
377
|
+
// INITIALIZATION AND CONFIGURATION
|
|
378
|
+
// =============================================================================
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Initialize the KnishIO SDK with global configuration
|
|
382
|
+
* This is optional - the SDK can be used without global initialization
|
|
383
|
+
*/
|
|
384
|
+
export interface SDKConfig {
|
|
385
|
+
defaultUri?: string | string[]
|
|
386
|
+
defaultCellSlug?: string | null
|
|
387
|
+
logging?: boolean
|
|
388
|
+
cryptoValidation?: boolean
|
|
389
|
+
compatibilityChecks?: boolean
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
let globalConfig: SDKConfig = {
|
|
393
|
+
logging: false,
|
|
394
|
+
cryptoValidation: true,
|
|
395
|
+
compatibilityChecks: true
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Configure the SDK globally
|
|
400
|
+
*/
|
|
401
|
+
export function configureSDK(config: Partial<SDKConfig>): void {
|
|
402
|
+
globalConfig = { ...globalConfig, ...config }
|
|
403
|
+
|
|
404
|
+
if (config.compatibilityChecks) {
|
|
405
|
+
// Run basic compatibility tests on initialization
|
|
406
|
+
const compatibilityResult = runCompatibilityTests()
|
|
407
|
+
if (!compatibilityResult.passed) {
|
|
408
|
+
console.warn('KnishIO SDK: Compatibility tests failed. Cross-platform operations may not work correctly.')
|
|
409
|
+
if (globalConfig.logging) {
|
|
410
|
+
console.log('Compatibility test results:', compatibilityResult.results)
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Get current global SDK configuration
|
|
418
|
+
*/
|
|
419
|
+
export function getSDKConfig(): SDKConfig {
|
|
420
|
+
return { ...globalConfig }
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
// =============================================================================
|
|
424
|
+
// DEVELOPMENT AND DEBUGGING UTILITIES
|
|
425
|
+
// =============================================================================
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Development mode utilities (only available in development builds)
|
|
429
|
+
*/
|
|
430
|
+
export const DevUtils = process.env.NODE_ENV === 'development' ? {
|
|
431
|
+
/**
|
|
432
|
+
* Validate SDK installation and basic functionality
|
|
433
|
+
*/
|
|
434
|
+
validateInstallation(): boolean {
|
|
435
|
+
try {
|
|
436
|
+
// Test basic cryptographic functions
|
|
437
|
+
const testSecret = generateSecret('test-seed')
|
|
438
|
+
const testBundle = generateBundleHash(testSecret)
|
|
439
|
+
const testPosition = generatePosition()
|
|
440
|
+
|
|
441
|
+
// Test string utilities
|
|
442
|
+
const testChunks = chunkSubstr('abcdefghijklmnop', 4)
|
|
443
|
+
|
|
444
|
+
// Test type validation
|
|
445
|
+
const isValidBundle = isBundleHash(testBundle)
|
|
446
|
+
const isValidPosition = isPosition(testPosition)
|
|
447
|
+
|
|
448
|
+
return testSecret.length === 64 &&
|
|
449
|
+
testBundle.length === 64 &&
|
|
450
|
+
testPosition.length === 64 &&
|
|
451
|
+
testChunks.length === 4 &&
|
|
452
|
+
isValidBundle &&
|
|
453
|
+
isValidPosition
|
|
454
|
+
} catch (error) {
|
|
455
|
+
console.error('SDK installation validation failed:', error)
|
|
456
|
+
return false
|
|
457
|
+
}
|
|
458
|
+
},
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Run comprehensive compatibility tests
|
|
462
|
+
*/
|
|
463
|
+
runFullCompatibilityTests: runCompatibilityTests,
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Get SDK build information
|
|
467
|
+
*/
|
|
468
|
+
getBuildInfo() {
|
|
469
|
+
return {
|
|
470
|
+
...SDK_INFO,
|
|
471
|
+
buildTime: new Date().toISOString(),
|
|
472
|
+
nodeVersion: typeof process !== 'undefined' ? process.version : 'unknown',
|
|
473
|
+
environment: typeof window !== 'undefined' ? 'browser' : 'node'
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
} : {}
|
|
477
|
+
|
|
478
|
+
// =============================================================================
|
|
479
|
+
// COMPATIBILITY WITH JAVASCRIPT SDK
|
|
480
|
+
// =============================================================================
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Legacy export names for compatibility with JavaScript SDK
|
|
484
|
+
* These maintain the exact same naming convention
|
|
485
|
+
*/
|
|
486
|
+
export {
|
|
487
|
+
// Core exports (matching JS SDK exactly)
|
|
488
|
+
shake256 as default, // The JS SDK doesn't export a default, but this maintains compatibility
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
// Maintain exact export structure as JS SDK index.js
|
|
492
|
+
export const KnishIO = {
|
|
493
|
+
shake256,
|
|
494
|
+
generateSecret,
|
|
495
|
+
generateBundleHash,
|
|
496
|
+
generateBatchId,
|
|
497
|
+
chunkSubstr,
|
|
498
|
+
randomString,
|
|
499
|
+
isHex,
|
|
500
|
+
SDK_VERSION,
|
|
501
|
+
SDK_INFO
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
// =============================================================================
|
|
505
|
+
// FUTURE EXPORTS (PLACEHOLDERS)
|
|
506
|
+
// =============================================================================
|
|
507
|
+
|
|
508
|
+
// These will be uncommented as classes are implemented
|
|
509
|
+
// export { default as Query } from './query/Query'
|
|
510
|
+
// export { default as Mutation } from './mutation/Mutation'
|
|
511
|
+
// export { default as Response } from './response/Response'
|
|
512
|
+
// export { default as Subscribe } from './subscribe/Subscribe'
|