@wishknish/knishio-client-ts 0.8.2 → 0.9.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/dist/index.cjs +425 -263
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +44 -17
- package/dist/index.d.ts +44 -17
- package/dist/index.iife.js +425 -265
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +447 -285
- package/dist/index.js.map +1 -1
- package/package.json +6 -9
- package/src/KnishIOClient.ts +180 -57
- package/src/constants.ts +1 -2
- package/src/core/Molecule.ts +53 -0
- package/src/core/Wallet.ts +84 -3
- package/src/libraries/Decimal.ts +1 -1
- package/src/libraries/GraphQLClient.ts +83 -0
- package/src/libraries/Hex.ts +4 -3
- package/src/libraries/UrqlClientWrapper.ts +13 -13
- package/src/libraries/crypto.ts +4 -4
- package/src/mutation/MutationClaimShadowWallet.ts +3 -1
- package/src/mutation/MutationTransferTokens.ts +18 -0
- package/src/query/QueryActiveSession.ts +0 -1
- package/src/query/QueryPolicy.ts +0 -1
- package/src/response/ResponseAuthorizationGuest.ts +2 -2
- package/src/response/ResponseBalance.ts +9 -6
- package/src/response/ResponseLinkIdentifier.ts +1 -1
- package/src/response/ResponseRequestAuthorizationGuest.ts +2 -2
- package/src/schemas/index.ts +2 -1
- package/src/subscribe/Subscribe.ts +3 -2
- package/src/types/assertions.ts +1 -6
- package/src/types/client.ts +12 -19
- package/src/types/guards.ts +2 -3
- package/src/types/index.ts +6 -0
- package/src/validation/UNIVERSAL_CONFIGURATION_INTERFACES.ts +3 -5
- package/src/validation/ValidationService.ts +6 -15
- package/src/validation/schemas.ts +5 -1
- package/src/versions/HashAtom.ts +11 -9
- package/src/query/QueryUserActivity.ts +0 -153
- package/src/response/ResponseQueryUserActivity.ts +0 -89
package/dist/index.d.cts
CHANGED
|
@@ -21,6 +21,13 @@ type PositionPattern = `${HexChar}${HexChar}${string}` & {
|
|
|
21
21
|
};
|
|
22
22
|
type TokenSlugPattern = `${Uppercase<string>}`;
|
|
23
23
|
|
|
24
|
+
interface TransferRecipientInput {
|
|
25
|
+
bundleHash: BundleHash | string;
|
|
26
|
+
units?: string[];
|
|
27
|
+
amount?: number | null;
|
|
28
|
+
batchId?: string | null;
|
|
29
|
+
}
|
|
30
|
+
|
|
24
31
|
type HashAlgorithm = 'SHAKE256' | 'SHA3-256' | 'BLAKE2B';
|
|
25
32
|
type SignatureAlgorithm = 'XMSS' | 'ML-KEM768' | 'SPHINCS+';
|
|
26
33
|
interface SHAKE256Options {
|
|
@@ -274,6 +281,7 @@ interface ValidationResult$1 {
|
|
|
274
281
|
expected?: string;
|
|
275
282
|
actual?: unknown;
|
|
276
283
|
}
|
|
284
|
+
type RequestPolicy = 'cache-first' | 'cache-only' | 'network-only' | 'cache-and-network';
|
|
277
285
|
interface GraphQLRequest {
|
|
278
286
|
query: string;
|
|
279
287
|
variables?: Record<string, unknown>;
|
|
@@ -514,6 +522,7 @@ declare class Wallet {
|
|
|
514
522
|
isRemainder?: boolean;
|
|
515
523
|
}): void;
|
|
516
524
|
splitUnits(units: string[], remainderWallet: Wallet, recipientWallet?: Wallet | null): void;
|
|
525
|
+
splitUnitsMulti(recipientUnitLists: string[][], recipientWallets: Wallet[], remainderWallet: Wallet): void;
|
|
517
526
|
getTokenUnitsData(): any[];
|
|
518
527
|
isShadow(): boolean;
|
|
519
528
|
initializeMLKEM(): void;
|
|
@@ -525,6 +534,16 @@ declare class Wallet {
|
|
|
525
534
|
cipherText: string;
|
|
526
535
|
encryptedMessage: string;
|
|
527
536
|
}): Promise<any>;
|
|
537
|
+
_mlkemDecryptToString(encryptedData: {
|
|
538
|
+
cipherText: string;
|
|
539
|
+
encryptedMessage: string;
|
|
540
|
+
}): Promise<string | null>;
|
|
541
|
+
hashShare(pubkey: string): string;
|
|
542
|
+
encryptStringML768(message: any, recipientPubkey: string): Promise<string>;
|
|
543
|
+
decryptMyMessageML768(map: Record<string, {
|
|
544
|
+
cipherText: string;
|
|
545
|
+
encryptedMessage: string;
|
|
546
|
+
}>): Promise<string | null>;
|
|
528
547
|
private encryptWithSharedSecret;
|
|
529
548
|
private decryptWithSharedSecret;
|
|
530
549
|
serializeKey(key: Uint8Array): string;
|
|
@@ -682,6 +701,10 @@ declare class Molecule {
|
|
|
682
701
|
recipientWallet: Wallet;
|
|
683
702
|
amount: number;
|
|
684
703
|
}): Molecule;
|
|
704
|
+
initValues({ recipientWallets, amounts }: {
|
|
705
|
+
recipientWallets: Wallet[];
|
|
706
|
+
amounts: number[];
|
|
707
|
+
}): Molecule;
|
|
685
708
|
sign({ bundle, anonymous, compressed }?: {
|
|
686
709
|
bundle?: string | null;
|
|
687
710
|
anonymous?: boolean;
|
|
@@ -840,6 +863,8 @@ declare class GraphQLClient implements GraphQLClient$1 {
|
|
|
840
863
|
encrypt?: boolean;
|
|
841
864
|
});
|
|
842
865
|
private createUrqlClient;
|
|
866
|
+
private shouldEncrypt;
|
|
867
|
+
private cipherFetch;
|
|
843
868
|
setAuthData({ token, pubkey, wallet }: {
|
|
844
869
|
token: string;
|
|
845
870
|
pubkey: string;
|
|
@@ -1119,6 +1144,7 @@ declare class KnishIOClient {
|
|
|
1119
1144
|
private $__client;
|
|
1120
1145
|
private $__serverSdkVersion;
|
|
1121
1146
|
private $__logging;
|
|
1147
|
+
private $__defaultRequestPolicy;
|
|
1122
1148
|
private $__authTokenObjects;
|
|
1123
1149
|
private $__authToken;
|
|
1124
1150
|
private $__authInProcess;
|
|
@@ -1137,8 +1163,9 @@ declare class KnishIOClient {
|
|
|
1137
1163
|
} | null;
|
|
1138
1164
|
serverSdkVersion?: number;
|
|
1139
1165
|
logging?: boolean;
|
|
1166
|
+
defaultRequestPolicy?: RequestPolicy | null;
|
|
1140
1167
|
});
|
|
1141
|
-
initialize({ uri, cellSlug, socket, client, serverSdkVersion, logging }: {
|
|
1168
|
+
initialize({ uri, cellSlug, socket, client, serverSdkVersion, logging, defaultRequestPolicy }: {
|
|
1142
1169
|
uri: string | string[];
|
|
1143
1170
|
cellSlug?: string | null;
|
|
1144
1171
|
socket?: {
|
|
@@ -1148,12 +1175,15 @@ declare class KnishIOClient {
|
|
|
1148
1175
|
client?: GraphQLClient | null;
|
|
1149
1176
|
serverSdkVersion?: number;
|
|
1150
1177
|
logging?: boolean;
|
|
1178
|
+
defaultRequestPolicy?: RequestPolicy | null;
|
|
1151
1179
|
}): void;
|
|
1152
1180
|
getRandomUri(): string;
|
|
1153
1181
|
switchEncryption(encrypt: boolean): boolean;
|
|
1154
1182
|
deinitialize(): void;
|
|
1155
1183
|
subscribe(): GraphQLClient;
|
|
1156
1184
|
getServerSdkVersion(): number;
|
|
1185
|
+
getDefaultRequestPolicy(): RequestPolicy | null;
|
|
1186
|
+
setDefaultRequestPolicy(policy: RequestPolicy | null): void;
|
|
1157
1187
|
reset(): void;
|
|
1158
1188
|
client(): GraphQLClient;
|
|
1159
1189
|
setUri(uri: string | string[]): void;
|
|
@@ -1191,6 +1221,11 @@ declare class KnishIOClient {
|
|
|
1191
1221
|
batchId?: string | null;
|
|
1192
1222
|
sourceWallet?: Wallet | null;
|
|
1193
1223
|
}): Promise<Response | null>;
|
|
1224
|
+
transferTokens({ token, recipients, sourceWallet }: {
|
|
1225
|
+
token: string;
|
|
1226
|
+
recipients: TransferRecipientInput[];
|
|
1227
|
+
sourceWallet?: Wallet | null;
|
|
1228
|
+
}): Promise<Response | null>;
|
|
1194
1229
|
requestAuthToken({ secret, seed, cellSlug, encrypt }?: {
|
|
1195
1230
|
secret?: string | null;
|
|
1196
1231
|
seed?: string | null;
|
|
@@ -1313,18 +1348,6 @@ declare class KnishIOClient {
|
|
|
1313
1348
|
metaType: MetaType | string;
|
|
1314
1349
|
metaId: MetaId | string;
|
|
1315
1350
|
}): Promise<Response>;
|
|
1316
|
-
queryUserActivity({ bundleHash, metaType, metaId, ipAddress, browser, osCpu, resolution, timeZone, countBy, interval }: {
|
|
1317
|
-
bundleHash: BundleHash | string;
|
|
1318
|
-
metaType: MetaType | string;
|
|
1319
|
-
metaId: MetaId | string;
|
|
1320
|
-
ipAddress?: string | null;
|
|
1321
|
-
browser?: string | null;
|
|
1322
|
-
osCpu?: string | null;
|
|
1323
|
-
resolution?: string | null;
|
|
1324
|
-
timeZone?: string | null;
|
|
1325
|
-
countBy?: string | null;
|
|
1326
|
-
interval?: string | null;
|
|
1327
|
-
}): Promise<Response>;
|
|
1328
1351
|
queryToken({ token }: {
|
|
1329
1352
|
token: TokenSlug | string;
|
|
1330
1353
|
}): Promise<Response>;
|
|
@@ -1348,7 +1371,7 @@ declare class KnishIOClient {
|
|
|
1348
1371
|
}): Promise<string>;
|
|
1349
1372
|
unsubscribe(operationName: string): void;
|
|
1350
1373
|
unsubscribeAll(): void;
|
|
1351
|
-
createToken({ token, amount, meta, batchId, units
|
|
1374
|
+
createToken({ token, amount, meta, batchId, units }: {
|
|
1352
1375
|
token: TokenSlug | string;
|
|
1353
1376
|
amount?: number | string | null;
|
|
1354
1377
|
meta?: Record<string, any> | null;
|
|
@@ -1683,6 +1706,10 @@ declare class MutationTransferTokens extends MutationProposeMolecule {
|
|
|
1683
1706
|
recipientWallet: Wallet;
|
|
1684
1707
|
amount: number | string;
|
|
1685
1708
|
}): void;
|
|
1709
|
+
fillMoleculeMulti({ recipientWallets, amounts }: {
|
|
1710
|
+
recipientWallets: Wallet[];
|
|
1711
|
+
amounts: number[];
|
|
1712
|
+
}): void;
|
|
1686
1713
|
createResponse(json: Record<string, unknown>): ResponseTransferTokens;
|
|
1687
1714
|
}
|
|
1688
1715
|
|
|
@@ -2088,9 +2115,9 @@ declare const DevUtils: {
|
|
|
2088
2115
|
};
|
|
2089
2116
|
};
|
|
2090
2117
|
} | {
|
|
2091
|
-
validateInstallation?:
|
|
2092
|
-
runFullCompatibilityTests?:
|
|
2093
|
-
getBuildInfo?:
|
|
2118
|
+
validateInstallation?: undefined;
|
|
2119
|
+
runFullCompatibilityTests?: undefined;
|
|
2120
|
+
getBuildInfo?: undefined;
|
|
2094
2121
|
};
|
|
2095
2122
|
declare const KnishIO: {
|
|
2096
2123
|
shake256: typeof shake256;
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,13 @@ type PositionPattern = `${HexChar}${HexChar}${string}` & {
|
|
|
21
21
|
};
|
|
22
22
|
type TokenSlugPattern = `${Uppercase<string>}`;
|
|
23
23
|
|
|
24
|
+
interface TransferRecipientInput {
|
|
25
|
+
bundleHash: BundleHash | string;
|
|
26
|
+
units?: string[];
|
|
27
|
+
amount?: number | null;
|
|
28
|
+
batchId?: string | null;
|
|
29
|
+
}
|
|
30
|
+
|
|
24
31
|
type HashAlgorithm = 'SHAKE256' | 'SHA3-256' | 'BLAKE2B';
|
|
25
32
|
type SignatureAlgorithm = 'XMSS' | 'ML-KEM768' | 'SPHINCS+';
|
|
26
33
|
interface SHAKE256Options {
|
|
@@ -274,6 +281,7 @@ interface ValidationResult$1 {
|
|
|
274
281
|
expected?: string;
|
|
275
282
|
actual?: unknown;
|
|
276
283
|
}
|
|
284
|
+
type RequestPolicy = 'cache-first' | 'cache-only' | 'network-only' | 'cache-and-network';
|
|
277
285
|
interface GraphQLRequest {
|
|
278
286
|
query: string;
|
|
279
287
|
variables?: Record<string, unknown>;
|
|
@@ -514,6 +522,7 @@ declare class Wallet {
|
|
|
514
522
|
isRemainder?: boolean;
|
|
515
523
|
}): void;
|
|
516
524
|
splitUnits(units: string[], remainderWallet: Wallet, recipientWallet?: Wallet | null): void;
|
|
525
|
+
splitUnitsMulti(recipientUnitLists: string[][], recipientWallets: Wallet[], remainderWallet: Wallet): void;
|
|
517
526
|
getTokenUnitsData(): any[];
|
|
518
527
|
isShadow(): boolean;
|
|
519
528
|
initializeMLKEM(): void;
|
|
@@ -525,6 +534,16 @@ declare class Wallet {
|
|
|
525
534
|
cipherText: string;
|
|
526
535
|
encryptedMessage: string;
|
|
527
536
|
}): Promise<any>;
|
|
537
|
+
_mlkemDecryptToString(encryptedData: {
|
|
538
|
+
cipherText: string;
|
|
539
|
+
encryptedMessage: string;
|
|
540
|
+
}): Promise<string | null>;
|
|
541
|
+
hashShare(pubkey: string): string;
|
|
542
|
+
encryptStringML768(message: any, recipientPubkey: string): Promise<string>;
|
|
543
|
+
decryptMyMessageML768(map: Record<string, {
|
|
544
|
+
cipherText: string;
|
|
545
|
+
encryptedMessage: string;
|
|
546
|
+
}>): Promise<string | null>;
|
|
528
547
|
private encryptWithSharedSecret;
|
|
529
548
|
private decryptWithSharedSecret;
|
|
530
549
|
serializeKey(key: Uint8Array): string;
|
|
@@ -682,6 +701,10 @@ declare class Molecule {
|
|
|
682
701
|
recipientWallet: Wallet;
|
|
683
702
|
amount: number;
|
|
684
703
|
}): Molecule;
|
|
704
|
+
initValues({ recipientWallets, amounts }: {
|
|
705
|
+
recipientWallets: Wallet[];
|
|
706
|
+
amounts: number[];
|
|
707
|
+
}): Molecule;
|
|
685
708
|
sign({ bundle, anonymous, compressed }?: {
|
|
686
709
|
bundle?: string | null;
|
|
687
710
|
anonymous?: boolean;
|
|
@@ -840,6 +863,8 @@ declare class GraphQLClient implements GraphQLClient$1 {
|
|
|
840
863
|
encrypt?: boolean;
|
|
841
864
|
});
|
|
842
865
|
private createUrqlClient;
|
|
866
|
+
private shouldEncrypt;
|
|
867
|
+
private cipherFetch;
|
|
843
868
|
setAuthData({ token, pubkey, wallet }: {
|
|
844
869
|
token: string;
|
|
845
870
|
pubkey: string;
|
|
@@ -1119,6 +1144,7 @@ declare class KnishIOClient {
|
|
|
1119
1144
|
private $__client;
|
|
1120
1145
|
private $__serverSdkVersion;
|
|
1121
1146
|
private $__logging;
|
|
1147
|
+
private $__defaultRequestPolicy;
|
|
1122
1148
|
private $__authTokenObjects;
|
|
1123
1149
|
private $__authToken;
|
|
1124
1150
|
private $__authInProcess;
|
|
@@ -1137,8 +1163,9 @@ declare class KnishIOClient {
|
|
|
1137
1163
|
} | null;
|
|
1138
1164
|
serverSdkVersion?: number;
|
|
1139
1165
|
logging?: boolean;
|
|
1166
|
+
defaultRequestPolicy?: RequestPolicy | null;
|
|
1140
1167
|
});
|
|
1141
|
-
initialize({ uri, cellSlug, socket, client, serverSdkVersion, logging }: {
|
|
1168
|
+
initialize({ uri, cellSlug, socket, client, serverSdkVersion, logging, defaultRequestPolicy }: {
|
|
1142
1169
|
uri: string | string[];
|
|
1143
1170
|
cellSlug?: string | null;
|
|
1144
1171
|
socket?: {
|
|
@@ -1148,12 +1175,15 @@ declare class KnishIOClient {
|
|
|
1148
1175
|
client?: GraphQLClient | null;
|
|
1149
1176
|
serverSdkVersion?: number;
|
|
1150
1177
|
logging?: boolean;
|
|
1178
|
+
defaultRequestPolicy?: RequestPolicy | null;
|
|
1151
1179
|
}): void;
|
|
1152
1180
|
getRandomUri(): string;
|
|
1153
1181
|
switchEncryption(encrypt: boolean): boolean;
|
|
1154
1182
|
deinitialize(): void;
|
|
1155
1183
|
subscribe(): GraphQLClient;
|
|
1156
1184
|
getServerSdkVersion(): number;
|
|
1185
|
+
getDefaultRequestPolicy(): RequestPolicy | null;
|
|
1186
|
+
setDefaultRequestPolicy(policy: RequestPolicy | null): void;
|
|
1157
1187
|
reset(): void;
|
|
1158
1188
|
client(): GraphQLClient;
|
|
1159
1189
|
setUri(uri: string | string[]): void;
|
|
@@ -1191,6 +1221,11 @@ declare class KnishIOClient {
|
|
|
1191
1221
|
batchId?: string | null;
|
|
1192
1222
|
sourceWallet?: Wallet | null;
|
|
1193
1223
|
}): Promise<Response | null>;
|
|
1224
|
+
transferTokens({ token, recipients, sourceWallet }: {
|
|
1225
|
+
token: string;
|
|
1226
|
+
recipients: TransferRecipientInput[];
|
|
1227
|
+
sourceWallet?: Wallet | null;
|
|
1228
|
+
}): Promise<Response | null>;
|
|
1194
1229
|
requestAuthToken({ secret, seed, cellSlug, encrypt }?: {
|
|
1195
1230
|
secret?: string | null;
|
|
1196
1231
|
seed?: string | null;
|
|
@@ -1313,18 +1348,6 @@ declare class KnishIOClient {
|
|
|
1313
1348
|
metaType: MetaType | string;
|
|
1314
1349
|
metaId: MetaId | string;
|
|
1315
1350
|
}): Promise<Response>;
|
|
1316
|
-
queryUserActivity({ bundleHash, metaType, metaId, ipAddress, browser, osCpu, resolution, timeZone, countBy, interval }: {
|
|
1317
|
-
bundleHash: BundleHash | string;
|
|
1318
|
-
metaType: MetaType | string;
|
|
1319
|
-
metaId: MetaId | string;
|
|
1320
|
-
ipAddress?: string | null;
|
|
1321
|
-
browser?: string | null;
|
|
1322
|
-
osCpu?: string | null;
|
|
1323
|
-
resolution?: string | null;
|
|
1324
|
-
timeZone?: string | null;
|
|
1325
|
-
countBy?: string | null;
|
|
1326
|
-
interval?: string | null;
|
|
1327
|
-
}): Promise<Response>;
|
|
1328
1351
|
queryToken({ token }: {
|
|
1329
1352
|
token: TokenSlug | string;
|
|
1330
1353
|
}): Promise<Response>;
|
|
@@ -1348,7 +1371,7 @@ declare class KnishIOClient {
|
|
|
1348
1371
|
}): Promise<string>;
|
|
1349
1372
|
unsubscribe(operationName: string): void;
|
|
1350
1373
|
unsubscribeAll(): void;
|
|
1351
|
-
createToken({ token, amount, meta, batchId, units
|
|
1374
|
+
createToken({ token, amount, meta, batchId, units }: {
|
|
1352
1375
|
token: TokenSlug | string;
|
|
1353
1376
|
amount?: number | string | null;
|
|
1354
1377
|
meta?: Record<string, any> | null;
|
|
@@ -1683,6 +1706,10 @@ declare class MutationTransferTokens extends MutationProposeMolecule {
|
|
|
1683
1706
|
recipientWallet: Wallet;
|
|
1684
1707
|
amount: number | string;
|
|
1685
1708
|
}): void;
|
|
1709
|
+
fillMoleculeMulti({ recipientWallets, amounts }: {
|
|
1710
|
+
recipientWallets: Wallet[];
|
|
1711
|
+
amounts: number[];
|
|
1712
|
+
}): void;
|
|
1686
1713
|
createResponse(json: Record<string, unknown>): ResponseTransferTokens;
|
|
1687
1714
|
}
|
|
1688
1715
|
|
|
@@ -2088,9 +2115,9 @@ declare const DevUtils: {
|
|
|
2088
2115
|
};
|
|
2089
2116
|
};
|
|
2090
2117
|
} | {
|
|
2091
|
-
validateInstallation?:
|
|
2092
|
-
runFullCompatibilityTests?:
|
|
2093
|
-
getBuildInfo?:
|
|
2118
|
+
validateInstallation?: undefined;
|
|
2119
|
+
runFullCompatibilityTests?: undefined;
|
|
2120
|
+
getBuildInfo?: undefined;
|
|
2094
2121
|
};
|
|
2095
2122
|
declare const KnishIO: {
|
|
2096
2123
|
shake256: typeof shake256;
|