@wishknish/knishio-client-ts 0.7.4 → 0.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2670 -1039
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +336 -105
- package/dist/index.d.ts +336 -105
- package/dist/index.iife.js +22097 -20047
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +2667 -1040
- package/dist/index.js.map +1 -1
- package/package.json +10 -4
- package/src/AuthToken.ts +8 -2
- package/src/KnishIOClient.ts +306 -50
- package/src/constants.ts +5 -3
- package/src/core/Atom.ts +167 -100
- package/src/core/AtomMeta.ts +11 -28
- package/src/core/Meta.ts +18 -15
- package/src/core/Molecule.ts +582 -140
- package/src/core/Wallet.ts +19 -24
- package/src/index.ts +8 -0
- package/src/instance/rules/Rule.ts +128 -19
- package/src/libraries/CheckMolecule.ts +88 -1
- package/src/libraries/crypto.ts +14 -30
- package/src/libraries/strings.ts +26 -25
- package/src/mutation/MutationAppendRequest.ts +52 -0
- package/src/mutation/MutationCreateRule.ts +2 -2
- package/src/mutation/MutationPeering.ts +37 -0
- package/src/mutation/MutationRequestAuthorization.ts +3 -3
- package/src/query/QueryActiveSession.ts +0 -1
- package/src/query/QueryContinuId.ts +8 -0
- package/src/query/QueryMetaTypeViaMolecule.ts +221 -0
- package/src/query/QueryWalletList.ts +2 -2
- package/src/response/ResponseAppendRequest.ts +17 -0
- package/src/response/ResponseBalance.ts +8 -3
- package/src/response/ResponseContinuId.ts +1 -1
- package/src/response/ResponseMetaType.ts +32 -19
- package/src/response/ResponseMetaTypeViaMolecule.ts +224 -0
- package/src/response/ResponsePeering.ts +17 -0
- package/src/response/ResponsePolicy.ts +2 -3
- package/src/response/ResponseProposeMolecule.ts +0 -1
- package/src/response/ResponseRequestAuthorization.ts +32 -2
- package/src/response/ResponseRequestAuthorizationGuest.ts +25 -1
- package/src/response/ResponseWalletList.ts +1 -1
- package/src/types/guards.ts +18 -5
- package/src/types/index.ts +3 -3
|
@@ -111,12 +111,36 @@ export default class ResponseRequestAuthorizationGuest extends Response {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
/**
|
|
114
|
-
* Returns
|
|
114
|
+
* Returns raw time value from payload
|
|
115
115
|
*/
|
|
116
116
|
time(): any {
|
|
117
117
|
return this.payloadKey('time')
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
/**
|
|
121
|
+
* Returns the expiration timestamp as Unix seconds.
|
|
122
|
+
* Handles both server formats:
|
|
123
|
+
* - PHP server: time = lifetime in ms, expiresAt = Unix timestamp in payload
|
|
124
|
+
* - Rust server: time = Unix timestamp in seconds
|
|
125
|
+
*/
|
|
126
|
+
expiresAt(): number {
|
|
127
|
+
try {
|
|
128
|
+
const ea = this.payloadKey('expiresAt')
|
|
129
|
+
if (ea) {
|
|
130
|
+
return Number(ea)
|
|
131
|
+
}
|
|
132
|
+
} catch (_e) {
|
|
133
|
+
// Not available in payload, fall back
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const timeValue = Number(this.time())
|
|
137
|
+
if (timeValue >= 1577836800) {
|
|
138
|
+
return timeValue
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return Math.floor(Date.now() / 1000) + Math.floor(timeValue / 1000)
|
|
142
|
+
}
|
|
143
|
+
|
|
120
144
|
/**
|
|
121
145
|
* Returns public key
|
|
122
146
|
*/
|
|
@@ -125,7 +125,7 @@ export default class ResponseWalletList extends Response {
|
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
wallet.balance =
|
|
128
|
+
wallet.balance = String(data.amount != null ? data.amount : 0)
|
|
129
129
|
wallet.pubkey = data.pubkey
|
|
130
130
|
wallet.createdAt = data.createdAt
|
|
131
131
|
|
package/src/types/guards.ts
CHANGED
|
@@ -115,8 +115,8 @@ export function assertExhaustive<T>(
|
|
|
115
115
|
* Exhaustive isotope type guard with compile-time checking
|
|
116
116
|
*/
|
|
117
117
|
export function isAtomIsotope(value: unknown): value is AtomIsotope {
|
|
118
|
-
return typeof value === 'string' &&
|
|
119
|
-
(['C', 'V', 'U', 'T', 'M', 'I', 'R', 'B', 'F'] as const).includes(value as AtomIsotope)
|
|
118
|
+
return typeof value === 'string' &&
|
|
119
|
+
(['C', 'V', 'U', 'T', 'M', 'I', 'R', 'B', 'F', 'P', 'A'] as const).includes(value as AtomIsotope)
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
/**
|
|
@@ -158,6 +158,14 @@ export function isFuseIsotope(value: unknown): value is 'F' {
|
|
|
158
158
|
return value === 'F'
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
+
export function isPeerIsotope(value: unknown): value is 'P' {
|
|
162
|
+
return value === 'P'
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function isAppendIsotope(value: unknown): value is 'A' {
|
|
166
|
+
return value === 'A'
|
|
167
|
+
}
|
|
168
|
+
|
|
161
169
|
/**
|
|
162
170
|
* Exhaustive isotope handler with compile-time completeness
|
|
163
171
|
*/
|
|
@@ -173,6 +181,8 @@ export function handleIsotope<T>(
|
|
|
173
181
|
readonly R: () => T
|
|
174
182
|
readonly B: () => T
|
|
175
183
|
readonly F: () => T
|
|
184
|
+
readonly P: () => T
|
|
185
|
+
readonly A: () => T
|
|
176
186
|
}
|
|
177
187
|
): T {
|
|
178
188
|
switch (isotope) {
|
|
@@ -185,6 +195,8 @@ export function handleIsotope<T>(
|
|
|
185
195
|
case 'R': return handlers.R()
|
|
186
196
|
case 'B': return handlers.B()
|
|
187
197
|
case 'F': return handlers.F()
|
|
198
|
+
case 'P': return handlers.P()
|
|
199
|
+
case 'A': return handlers.A()
|
|
188
200
|
default: return assertNever(isotope)
|
|
189
201
|
}
|
|
190
202
|
}
|
|
@@ -378,11 +390,10 @@ export function isCellSlug(value: unknown): value is CellSlug {
|
|
|
378
390
|
}
|
|
379
391
|
|
|
380
392
|
/**
|
|
381
|
-
* Batch ID validation (
|
|
393
|
+
* Batch ID validation (64-char hex string, matching JS SDK)
|
|
382
394
|
*/
|
|
383
395
|
export function isBatchId(value: unknown): value is BatchId {
|
|
384
|
-
return typeof value === 'string' &&
|
|
385
|
-
/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value)
|
|
396
|
+
return typeof value === 'string' && /^[a-f0-9]{64}$/i.test(value)
|
|
386
397
|
}
|
|
387
398
|
|
|
388
399
|
// =============================================================================
|
|
@@ -594,6 +605,8 @@ export const Guards = {
|
|
|
594
605
|
rule: isRuleIsotope,
|
|
595
606
|
buffer: isBufferIsotope,
|
|
596
607
|
fuse: isFuseIsotope,
|
|
608
|
+
peer: isPeerIsotope,
|
|
609
|
+
append: isAppendIsotope,
|
|
597
610
|
handle: handleIsotope
|
|
598
611
|
},
|
|
599
612
|
|
package/src/types/index.ts
CHANGED
|
@@ -172,8 +172,8 @@ export interface AtomMetaData extends MetaData {
|
|
|
172
172
|
export interface AtomParams {
|
|
173
173
|
position?: string | null
|
|
174
174
|
walletAddress?: WalletAddress | null
|
|
175
|
-
isotope?: AtomIsotope
|
|
176
|
-
token?: TokenSlug | string
|
|
175
|
+
isotope?: AtomIsotope | null
|
|
176
|
+
token?: TokenSlug | string | null
|
|
177
177
|
value?: string | number | null
|
|
178
178
|
batchId?: BatchId | string | null
|
|
179
179
|
metaType?: MetaType | string | null
|
|
@@ -182,7 +182,7 @@ export interface AtomParams {
|
|
|
182
182
|
otsFragment?: string | null
|
|
183
183
|
index?: number | null
|
|
184
184
|
createdAt?: string | null
|
|
185
|
-
version?: number | null
|
|
185
|
+
version?: string | number | null | undefined
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
export interface WalletParams {
|