@wishknish/knishio-client-ts 1.2.0 → 1.3.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 +150 -123
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -11
- package/dist/index.d.ts +12 -11
- package/dist/index.iife.js +155 -124
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +150 -123
- package/dist/index.js.map +1 -1
- package/package.json +6 -2
- package/src/AuthToken.ts +6 -2
- package/src/KnishIOClient.ts +151 -79
- package/src/core/AtomMeta.ts +0 -19
- package/src/core/Molecule.ts +6 -35
- package/src/index.ts +1 -1
- package/src/libraries/CheckMolecule.ts +5 -19
- package/src/mutation/MutationWithdrawBufferToken.ts +3 -7
- package/src/query/QueryContinuId.ts +2 -2
- package/src/response/ResponseProposeMolecule.ts +18 -1
package/dist/index.d.cts
CHANGED
|
@@ -425,7 +425,6 @@ declare class AtomMeta {
|
|
|
425
425
|
setAtomWallet(wallet: any): AtomMeta;
|
|
426
426
|
setMetaWallet(wallet: any): AtomMeta;
|
|
427
427
|
setShadowWalletClaim(shadowWalletClaim: boolean | number): AtomMeta;
|
|
428
|
-
setSigningWallet(signingWallet: any): AtomMeta;
|
|
429
428
|
addPolicy(policy: Record<string, any>): AtomMeta;
|
|
430
429
|
get(): NormalizedMeta[];
|
|
431
430
|
toObject(): Record<string, any>;
|
|
@@ -817,7 +816,7 @@ declare class Molecule {
|
|
|
817
816
|
metaType: string;
|
|
818
817
|
metaId: string;
|
|
819
818
|
rule: Rule[] | any[] | any;
|
|
820
|
-
policy?: Record<string, any
|
|
819
|
+
policy?: Record<string, any> | null;
|
|
821
820
|
}): Molecule;
|
|
822
821
|
initTokenRequest({ token, amount, metaType, metaId, meta, batchId }: {
|
|
823
822
|
token: string;
|
|
@@ -846,9 +845,8 @@ declare class Molecule {
|
|
|
846
845
|
amount: number;
|
|
847
846
|
tradeRates?: Record<string, any>;
|
|
848
847
|
}): Molecule;
|
|
849
|
-
initWithdrawBuffer({ recipients
|
|
848
|
+
initWithdrawBuffer({ recipients }: {
|
|
850
849
|
recipients: Record<string, number>;
|
|
851
|
-
signingWallet?: any | null;
|
|
852
850
|
}): Molecule;
|
|
853
851
|
initShadowWalletClaim(wallet: Wallet): Molecule;
|
|
854
852
|
initIdentifierCreation({ type, contact, code }: {
|
|
@@ -980,6 +978,7 @@ type AuthTokenSnapshot = {
|
|
|
980
978
|
pubkey: string;
|
|
981
979
|
encrypt: boolean;
|
|
982
980
|
wallet?: {
|
|
981
|
+
token?: string;
|
|
983
982
|
position: string | null;
|
|
984
983
|
characters: string | null;
|
|
985
984
|
mlKemParameterSet?: 1024 | 768;
|
|
@@ -1343,8 +1342,9 @@ declare class KnishIOClient {
|
|
|
1343
1342
|
fields?: string[] | null;
|
|
1344
1343
|
raw?: boolean;
|
|
1345
1344
|
}): Promise<any>;
|
|
1346
|
-
queryContinuId({ bundle }: {
|
|
1345
|
+
queryContinuId({ bundle, token }: {
|
|
1347
1346
|
bundle: BundleHash | string;
|
|
1347
|
+
token?: string | null;
|
|
1348
1348
|
}): Promise<Response>;
|
|
1349
1349
|
queryMeta({ metaType, metaId, key, value, latest, fields: _fields, filter, queryArgs, count, countBy, throughAtom, throughMolecule, values, keys, atomValues, requestPolicy }: {
|
|
1350
1350
|
metaType: MetaType | string;
|
|
@@ -1543,11 +1543,10 @@ declare class KnishIOClient {
|
|
|
1543
1543
|
tradeRates: Record<string, number>;
|
|
1544
1544
|
sourceWallet?: Wallet | null;
|
|
1545
1545
|
}): Promise<Response>;
|
|
1546
|
-
withdrawBufferToken({ tokenSlug, amount, sourceWallet
|
|
1546
|
+
withdrawBufferToken({ tokenSlug, amount, sourceWallet }: {
|
|
1547
1547
|
tokenSlug: TokenSlug | string;
|
|
1548
1548
|
amount: number | string;
|
|
1549
1549
|
sourceWallet?: Wallet | null;
|
|
1550
|
-
signingWallet?: Wallet | null;
|
|
1551
1550
|
}): Promise<Response>;
|
|
1552
1551
|
requestGuestAuthToken({ cellSlug, encrypt }?: {
|
|
1553
1552
|
cellSlug?: CellSlug | string | null;
|
|
@@ -1557,6 +1556,8 @@ declare class KnishIOClient {
|
|
|
1557
1556
|
secret: string;
|
|
1558
1557
|
encrypt?: boolean;
|
|
1559
1558
|
}): Promise<ResponseRequestAuthorization>;
|
|
1559
|
+
private proposeProfileAuthorization;
|
|
1560
|
+
private acceptProfileAuthorization;
|
|
1560
1561
|
registerPeer({ host }: {
|
|
1561
1562
|
host: string;
|
|
1562
1563
|
}): Promise<Response>;
|
|
@@ -2339,12 +2340,12 @@ declare function withSecureBytes<T>(bytes: Uint8Array, fn: (bytes: Uint8Array) =
|
|
|
2339
2340
|
declare function withSecureString<T>(secret: string, fn: (cleanSecret: string) => Promise<T> | T): Promise<T>;
|
|
2340
2341
|
declare function constantTimeCompare(a: Uint8Array | string, b: Uint8Array | string): boolean;
|
|
2341
2342
|
|
|
2342
|
-
declare const SDK_VERSION = "1.
|
|
2343
|
+
declare const SDK_VERSION = "1.3.0";
|
|
2343
2344
|
declare const SDK_NAME = "KnishIO-Client-TS";
|
|
2344
2345
|
declare const COMPATIBLE_SERVER_VERSIONS: number[];
|
|
2345
2346
|
declare const SDK_INFO: {
|
|
2346
2347
|
readonly name: "KnishIO-Client-TS";
|
|
2347
|
-
readonly version: "1.
|
|
2348
|
+
readonly version: "1.3.0";
|
|
2348
2349
|
readonly description: "TypeScript SDK for Knish.IO post-blockchain distributed ledger";
|
|
2349
2350
|
readonly compatibleServerVersions: number[];
|
|
2350
2351
|
readonly features: readonly ["Post-quantum cryptography (XMSS, ML-KEM-1024)", "Cross-platform compatibility", "Type-safe APIs", "DAG-based transaction processing", "GraphQL integration", "Real-time subscriptions", "Cellular architecture support"];
|
|
@@ -2372,7 +2373,7 @@ declare const DevUtils: {
|
|
|
2372
2373
|
nodeVersion: string;
|
|
2373
2374
|
environment: string;
|
|
2374
2375
|
name: "KnishIO-Client-TS";
|
|
2375
|
-
version: "1.
|
|
2376
|
+
version: "1.3.0";
|
|
2376
2377
|
description: "TypeScript SDK for Knish.IO post-blockchain distributed ledger";
|
|
2377
2378
|
compatibleServerVersions: number[];
|
|
2378
2379
|
features: readonly ["Post-quantum cryptography (XMSS, ML-KEM-1024)", "Cross-platform compatibility", "Type-safe APIs", "DAG-based transaction processing", "GraphQL integration", "Real-time subscriptions", "Cellular architecture support"];
|
|
@@ -2399,7 +2400,7 @@ declare const KnishIO: {
|
|
|
2399
2400
|
SDK_VERSION: string;
|
|
2400
2401
|
SDK_INFO: {
|
|
2401
2402
|
readonly name: "KnishIO-Client-TS";
|
|
2402
|
-
readonly version: "1.
|
|
2403
|
+
readonly version: "1.3.0";
|
|
2403
2404
|
readonly description: "TypeScript SDK for Knish.IO post-blockchain distributed ledger";
|
|
2404
2405
|
readonly compatibleServerVersions: number[];
|
|
2405
2406
|
readonly features: readonly ["Post-quantum cryptography (XMSS, ML-KEM-1024)", "Cross-platform compatibility", "Type-safe APIs", "DAG-based transaction processing", "GraphQL integration", "Real-time subscriptions", "Cellular architecture support"];
|
package/dist/index.d.ts
CHANGED
|
@@ -425,7 +425,6 @@ declare class AtomMeta {
|
|
|
425
425
|
setAtomWallet(wallet: any): AtomMeta;
|
|
426
426
|
setMetaWallet(wallet: any): AtomMeta;
|
|
427
427
|
setShadowWalletClaim(shadowWalletClaim: boolean | number): AtomMeta;
|
|
428
|
-
setSigningWallet(signingWallet: any): AtomMeta;
|
|
429
428
|
addPolicy(policy: Record<string, any>): AtomMeta;
|
|
430
429
|
get(): NormalizedMeta[];
|
|
431
430
|
toObject(): Record<string, any>;
|
|
@@ -817,7 +816,7 @@ declare class Molecule {
|
|
|
817
816
|
metaType: string;
|
|
818
817
|
metaId: string;
|
|
819
818
|
rule: Rule[] | any[] | any;
|
|
820
|
-
policy?: Record<string, any
|
|
819
|
+
policy?: Record<string, any> | null;
|
|
821
820
|
}): Molecule;
|
|
822
821
|
initTokenRequest({ token, amount, metaType, metaId, meta, batchId }: {
|
|
823
822
|
token: string;
|
|
@@ -846,9 +845,8 @@ declare class Molecule {
|
|
|
846
845
|
amount: number;
|
|
847
846
|
tradeRates?: Record<string, any>;
|
|
848
847
|
}): Molecule;
|
|
849
|
-
initWithdrawBuffer({ recipients
|
|
848
|
+
initWithdrawBuffer({ recipients }: {
|
|
850
849
|
recipients: Record<string, number>;
|
|
851
|
-
signingWallet?: any | null;
|
|
852
850
|
}): Molecule;
|
|
853
851
|
initShadowWalletClaim(wallet: Wallet): Molecule;
|
|
854
852
|
initIdentifierCreation({ type, contact, code }: {
|
|
@@ -980,6 +978,7 @@ type AuthTokenSnapshot = {
|
|
|
980
978
|
pubkey: string;
|
|
981
979
|
encrypt: boolean;
|
|
982
980
|
wallet?: {
|
|
981
|
+
token?: string;
|
|
983
982
|
position: string | null;
|
|
984
983
|
characters: string | null;
|
|
985
984
|
mlKemParameterSet?: 1024 | 768;
|
|
@@ -1343,8 +1342,9 @@ declare class KnishIOClient {
|
|
|
1343
1342
|
fields?: string[] | null;
|
|
1344
1343
|
raw?: boolean;
|
|
1345
1344
|
}): Promise<any>;
|
|
1346
|
-
queryContinuId({ bundle }: {
|
|
1345
|
+
queryContinuId({ bundle, token }: {
|
|
1347
1346
|
bundle: BundleHash | string;
|
|
1347
|
+
token?: string | null;
|
|
1348
1348
|
}): Promise<Response>;
|
|
1349
1349
|
queryMeta({ metaType, metaId, key, value, latest, fields: _fields, filter, queryArgs, count, countBy, throughAtom, throughMolecule, values, keys, atomValues, requestPolicy }: {
|
|
1350
1350
|
metaType: MetaType | string;
|
|
@@ -1543,11 +1543,10 @@ declare class KnishIOClient {
|
|
|
1543
1543
|
tradeRates: Record<string, number>;
|
|
1544
1544
|
sourceWallet?: Wallet | null;
|
|
1545
1545
|
}): Promise<Response>;
|
|
1546
|
-
withdrawBufferToken({ tokenSlug, amount, sourceWallet
|
|
1546
|
+
withdrawBufferToken({ tokenSlug, amount, sourceWallet }: {
|
|
1547
1547
|
tokenSlug: TokenSlug | string;
|
|
1548
1548
|
amount: number | string;
|
|
1549
1549
|
sourceWallet?: Wallet | null;
|
|
1550
|
-
signingWallet?: Wallet | null;
|
|
1551
1550
|
}): Promise<Response>;
|
|
1552
1551
|
requestGuestAuthToken({ cellSlug, encrypt }?: {
|
|
1553
1552
|
cellSlug?: CellSlug | string | null;
|
|
@@ -1557,6 +1556,8 @@ declare class KnishIOClient {
|
|
|
1557
1556
|
secret: string;
|
|
1558
1557
|
encrypt?: boolean;
|
|
1559
1558
|
}): Promise<ResponseRequestAuthorization>;
|
|
1559
|
+
private proposeProfileAuthorization;
|
|
1560
|
+
private acceptProfileAuthorization;
|
|
1560
1561
|
registerPeer({ host }: {
|
|
1561
1562
|
host: string;
|
|
1562
1563
|
}): Promise<Response>;
|
|
@@ -2339,12 +2340,12 @@ declare function withSecureBytes<T>(bytes: Uint8Array, fn: (bytes: Uint8Array) =
|
|
|
2339
2340
|
declare function withSecureString<T>(secret: string, fn: (cleanSecret: string) => Promise<T> | T): Promise<T>;
|
|
2340
2341
|
declare function constantTimeCompare(a: Uint8Array | string, b: Uint8Array | string): boolean;
|
|
2341
2342
|
|
|
2342
|
-
declare const SDK_VERSION = "1.
|
|
2343
|
+
declare const SDK_VERSION = "1.3.0";
|
|
2343
2344
|
declare const SDK_NAME = "KnishIO-Client-TS";
|
|
2344
2345
|
declare const COMPATIBLE_SERVER_VERSIONS: number[];
|
|
2345
2346
|
declare const SDK_INFO: {
|
|
2346
2347
|
readonly name: "KnishIO-Client-TS";
|
|
2347
|
-
readonly version: "1.
|
|
2348
|
+
readonly version: "1.3.0";
|
|
2348
2349
|
readonly description: "TypeScript SDK for Knish.IO post-blockchain distributed ledger";
|
|
2349
2350
|
readonly compatibleServerVersions: number[];
|
|
2350
2351
|
readonly features: readonly ["Post-quantum cryptography (XMSS, ML-KEM-1024)", "Cross-platform compatibility", "Type-safe APIs", "DAG-based transaction processing", "GraphQL integration", "Real-time subscriptions", "Cellular architecture support"];
|
|
@@ -2372,7 +2373,7 @@ declare const DevUtils: {
|
|
|
2372
2373
|
nodeVersion: string;
|
|
2373
2374
|
environment: string;
|
|
2374
2375
|
name: "KnishIO-Client-TS";
|
|
2375
|
-
version: "1.
|
|
2376
|
+
version: "1.3.0";
|
|
2376
2377
|
description: "TypeScript SDK for Knish.IO post-blockchain distributed ledger";
|
|
2377
2378
|
compatibleServerVersions: number[];
|
|
2378
2379
|
features: readonly ["Post-quantum cryptography (XMSS, ML-KEM-1024)", "Cross-platform compatibility", "Type-safe APIs", "DAG-based transaction processing", "GraphQL integration", "Real-time subscriptions", "Cellular architecture support"];
|
|
@@ -2399,7 +2400,7 @@ declare const KnishIO: {
|
|
|
2399
2400
|
SDK_VERSION: string;
|
|
2400
2401
|
SDK_INFO: {
|
|
2401
2402
|
readonly name: "KnishIO-Client-TS";
|
|
2402
|
-
readonly version: "1.
|
|
2403
|
+
readonly version: "1.3.0";
|
|
2403
2404
|
readonly description: "TypeScript SDK for Knish.IO post-blockchain distributed ledger";
|
|
2404
2405
|
readonly compatibleServerVersions: number[];
|
|
2405
2406
|
readonly features: readonly ["Post-quantum cryptography (XMSS, ML-KEM-1024)", "Cross-platform compatibility", "Type-safe APIs", "DAG-based transaction processing", "GraphQL integration", "Real-time subscriptions", "Cellular architecture support"];
|
package/dist/index.iife.js
CHANGED
|
@@ -54,11 +54,20 @@ var KnishIO = (function (exports) {
|
|
|
54
54
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
55
55
|
var __getProtoOf = Object.getPrototypeOf;
|
|
56
56
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
57
|
-
var __esm = (fn, res) => function __init() {
|
|
58
|
-
|
|
57
|
+
var __esm = (fn, res, err) => function __init() {
|
|
58
|
+
if (err) throw err[0];
|
|
59
|
+
try {
|
|
60
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
61
|
+
} catch (e4) {
|
|
62
|
+
throw err = [e4], e4;
|
|
63
|
+
}
|
|
59
64
|
};
|
|
60
65
|
var __commonJS = (cb, mod) => function __require() {
|
|
61
|
-
|
|
66
|
+
try {
|
|
67
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
68
|
+
} catch (e4) {
|
|
69
|
+
throw mod = 0, e4;
|
|
70
|
+
}
|
|
62
71
|
};
|
|
63
72
|
var __export = (target, all) => {
|
|
64
73
|
for (var name2 in all)
|
|
@@ -41540,24 +41549,6 @@ ${operationTypes.join("\n")}
|
|
|
41540
41549
|
this.merge({ shadowWalletClaim: Number(shadowWalletClaim) });
|
|
41541
41550
|
return this;
|
|
41542
41551
|
}
|
|
41543
|
-
/**
|
|
41544
|
-
* Set signing wallet metadata
|
|
41545
|
-
* @param signingWallet - Wallet used for signing
|
|
41546
|
-
* @return This instance for chaining
|
|
41547
|
-
*/
|
|
41548
|
-
setSigningWallet(signingWallet) {
|
|
41549
|
-
this.merge({
|
|
41550
|
-
signingWallet: JSON.stringify({
|
|
41551
|
-
tokenSlug: signingWallet.token,
|
|
41552
|
-
bundleHash: signingWallet.bundle,
|
|
41553
|
-
address: signingWallet.address,
|
|
41554
|
-
position: signingWallet.position,
|
|
41555
|
-
pubkey: signingWallet.pubkey,
|
|
41556
|
-
characters: signingWallet.characters
|
|
41557
|
-
})
|
|
41558
|
-
});
|
|
41559
|
-
return this;
|
|
41560
|
-
}
|
|
41561
41552
|
/**
|
|
41562
41553
|
* Add policy metadata
|
|
41563
41554
|
* @param policy - Policy object to add
|
|
@@ -44508,7 +44499,6 @@ ${operationTypes.join("\n")}
|
|
|
44508
44499
|
|
|
44509
44500
|
// src/libraries/CheckMolecule.ts
|
|
44510
44501
|
init_exception();
|
|
44511
|
-
init_Dot();
|
|
44512
44502
|
var CheckMolecule = class _CheckMolecule {
|
|
44513
44503
|
molecule;
|
|
44514
44504
|
/**
|
|
@@ -44596,12 +44586,13 @@ ${operationTypes.join("\n")}
|
|
|
44596
44586
|
/**
|
|
44597
44587
|
* Validate isotope U atoms
|
|
44598
44588
|
* @return True if valid
|
|
44599
|
-
* @throws WrongTokenTypeException if token is
|
|
44589
|
+
* @throws WrongTokenTypeException if token is neither AUTH (fresh login) nor USER (re-login
|
|
44590
|
+
* signed from the ContinuID pointer)
|
|
44600
44591
|
* @throws AtomIndexException if index is not 0
|
|
44601
44592
|
*/
|
|
44602
44593
|
isotopeU() {
|
|
44603
44594
|
for (const atom of this.molecule.getIsotopes("U")) {
|
|
44604
|
-
if (atom.token !== "AUTH") {
|
|
44595
|
+
if (atom.token !== "AUTH" && atom.token !== "USER") {
|
|
44605
44596
|
throw new WrongTokenTypeException(`Check::isotopeU() - "${atom.token}" is not a valid Token slug for "${atom.isotope}" isotope Atoms!`);
|
|
44606
44597
|
}
|
|
44607
44598
|
if (atom.index !== 0) {
|
|
@@ -44990,16 +44981,7 @@ ${operationTypes.join("\n")}
|
|
|
44990
44981
|
if (!signingAtom) {
|
|
44991
44982
|
throw new exports.SignatureMismatchException();
|
|
44992
44983
|
}
|
|
44993
|
-
|
|
44994
|
-
const signingWallet = exports.Dot.get(signingAtom.aggregatedMeta(), "signingWallet");
|
|
44995
|
-
if (signingWallet) {
|
|
44996
|
-
const parsedWallet = JSON.parse(signingWallet);
|
|
44997
|
-
const walletAddress = exports.Dot.get(parsedWallet, "address");
|
|
44998
|
-
if (walletAddress) {
|
|
44999
|
-
signingAddress = walletAddress;
|
|
45000
|
-
}
|
|
45001
|
-
}
|
|
45002
|
-
if (address !== signingAddress) {
|
|
44984
|
+
if (address !== signingAtom.walletAddress) {
|
|
45003
44985
|
throw new exports.SignatureMismatchException();
|
|
45004
44986
|
}
|
|
45005
44987
|
return true;
|
|
@@ -45334,18 +45316,7 @@ ${operationTypes.join("\n")}
|
|
|
45334
45316
|
if (!signingAtom) {
|
|
45335
45317
|
throw new SignatureMalformedException("No atoms available for signing!");
|
|
45336
45318
|
}
|
|
45337
|
-
|
|
45338
|
-
const signingWalletMeta = signingAtom.aggregatedMeta ? signingAtom.aggregatedMeta() : null;
|
|
45339
|
-
const signingWalletJson = signingWalletMeta?.signingWallet;
|
|
45340
|
-
if (signingWalletJson) {
|
|
45341
|
-
try {
|
|
45342
|
-
const parsedSigningWallet = JSON.parse(signingWalletJson);
|
|
45343
|
-
if (parsedSigningWallet.position) {
|
|
45344
|
-
signingPosition = parsedSigningWallet.position;
|
|
45345
|
-
}
|
|
45346
|
-
} catch {
|
|
45347
|
-
}
|
|
45348
|
-
}
|
|
45319
|
+
const signingPosition = signingAtom.position;
|
|
45349
45320
|
if (!signingPosition) {
|
|
45350
45321
|
throw new SignatureMalformedException("Signing wallet must have a position!");
|
|
45351
45322
|
}
|
|
@@ -45748,9 +45719,7 @@ ${operationTypes.join("\n")}
|
|
|
45748
45719
|
const atomMeta = new AtomMeta({
|
|
45749
45720
|
rule: JSON.stringify(rules)
|
|
45750
45721
|
});
|
|
45751
|
-
|
|
45752
|
-
atomMeta.addPolicy(policy);
|
|
45753
|
-
}
|
|
45722
|
+
atomMeta.addPolicy(policy ?? {});
|
|
45754
45723
|
this.addAtom(Atom.create({
|
|
45755
45724
|
isotope: "R",
|
|
45756
45725
|
wallet: this.sourceWallet,
|
|
@@ -46003,12 +45972,10 @@ ${operationTypes.join("\n")}
|
|
|
46003
45972
|
* Matches JavaScript SDK Molecule.initWithdrawBuffer implementation exactly
|
|
46004
45973
|
*
|
|
46005
45974
|
* @param recipients - Map of recipientBundle → amount
|
|
46006
|
-
* @param signingWallet - Optional signing wallet for reconciliation
|
|
46007
45975
|
* @return This molecule instance for chaining
|
|
46008
45976
|
*/
|
|
46009
45977
|
initWithdrawBuffer({
|
|
46010
|
-
recipients
|
|
46011
|
-
signingWallet = null
|
|
45978
|
+
recipients
|
|
46012
45979
|
}) {
|
|
46013
45980
|
if (!this.sourceWallet) {
|
|
46014
45981
|
throw new Error("Source wallet required for buffer withdrawal");
|
|
@@ -46020,15 +45987,10 @@ ${operationTypes.join("\n")}
|
|
|
46020
45987
|
if (Number(this.sourceWallet.balance) - amount < 0) {
|
|
46021
45988
|
throw new BalanceInsufficientException();
|
|
46022
45989
|
}
|
|
46023
|
-
const firstAtomMeta = new AtomMeta();
|
|
46024
|
-
if (signingWallet) {
|
|
46025
|
-
firstAtomMeta.setSigningWallet(signingWallet);
|
|
46026
|
-
}
|
|
46027
45990
|
this.addAtom(Atom.create({
|
|
46028
45991
|
isotope: "B",
|
|
46029
45992
|
wallet: this.sourceWallet,
|
|
46030
45993
|
value: -Number(this.sourceWallet.balance),
|
|
46031
|
-
meta: firstAtomMeta,
|
|
46032
45994
|
metaType: "walletBundle",
|
|
46033
45995
|
metaId: this.sourceWallet.bundle
|
|
46034
45996
|
}));
|
|
@@ -48887,7 +48849,7 @@ ${operationTypes.join("\n")}
|
|
|
48887
48849
|
static restore(snapshot, secret) {
|
|
48888
48850
|
const wallet = new Wallet({
|
|
48889
48851
|
secret,
|
|
48890
|
-
token: "AUTH",
|
|
48852
|
+
token: snapshot.wallet?.token ?? "AUTH",
|
|
48891
48853
|
position: snapshot.wallet?.position ?? null,
|
|
48892
48854
|
characters: snapshot.wallet?.characters ?? null,
|
|
48893
48855
|
mlKemParameterSet: _AuthToken.resolveMlKemParameterSet(snapshot)
|
|
@@ -48970,6 +48932,7 @@ ${operationTypes.join("\n")}
|
|
|
48970
48932
|
encrypt: this.$__encrypt,
|
|
48971
48933
|
...this.$__wallet ? {
|
|
48972
48934
|
wallet: {
|
|
48935
|
+
token: this.$__wallet.token,
|
|
48973
48936
|
position: this.$__wallet.position,
|
|
48974
48937
|
characters: this.$__wallet.characters,
|
|
48975
48938
|
mlKemParameterSet: this.$__wallet.mlKemParameterSet
|
|
@@ -50469,8 +50432,8 @@ ${operationTypes.join("\n")}
|
|
|
50469
50432
|
*/
|
|
50470
50433
|
constructor(graphQLClient, knishIOClient) {
|
|
50471
50434
|
super(graphQLClient, knishIOClient);
|
|
50472
|
-
this.$__query = gql`query ($bundle: String
|
|
50473
|
-
ContinuId(bundle: $bundle) {
|
|
50435
|
+
this.$__query = gql`query ($bundle: String!, $token: String) {
|
|
50436
|
+
ContinuId(bundle: $bundle, token: $token) {
|
|
50474
50437
|
address,
|
|
50475
50438
|
bundleHash,
|
|
50476
50439
|
tokenSlug,
|
|
@@ -51770,7 +51733,7 @@ ${operationTypes.join("\n")}
|
|
|
51770
51733
|
code: "HASH_MISMATCH"
|
|
51771
51734
|
});
|
|
51772
51735
|
}
|
|
51773
|
-
if (/ots.*position.*reuse|position.*already.*used|ots.*verification/.test(lc)) {
|
|
51736
|
+
if (/ots.*(?:position|key).*reuse|position.*already.*(?:used|consumed)|ots.*verification/.test(lc)) {
|
|
51774
51737
|
return new exports.SignatureMismatchException(reason, {
|
|
51775
51738
|
details: { reason },
|
|
51776
51739
|
code: "OTS_VERIFICATION_FAILED"
|
|
@@ -51788,6 +51751,18 @@ ${operationTypes.join("\n")}
|
|
|
51788
51751
|
code: "VERIFICATION_FAILED"
|
|
51789
51752
|
});
|
|
51790
51753
|
}
|
|
51754
|
+
if (/signer address mismatch/.test(lc)) {
|
|
51755
|
+
return new exports.SignatureMismatchException(reason, {
|
|
51756
|
+
details: { reason },
|
|
51757
|
+
code: "SIGNER_ADDRESS_MISMATCH"
|
|
51758
|
+
});
|
|
51759
|
+
}
|
|
51760
|
+
if (/no accepted origin available/.test(lc)) {
|
|
51761
|
+
return new exports.AtomIndexException(reason, {
|
|
51762
|
+
details: { reason },
|
|
51763
|
+
code: "ORIGIN_PENDING"
|
|
51764
|
+
});
|
|
51765
|
+
}
|
|
51791
51766
|
return null;
|
|
51792
51767
|
}
|
|
51793
51768
|
/**
|
|
@@ -52289,12 +52264,10 @@ ${operationTypes.join("\n")}
|
|
|
52289
52264
|
* Fills the molecule with buffer withdrawal data
|
|
52290
52265
|
*/
|
|
52291
52266
|
fillMolecule({
|
|
52292
|
-
recipients
|
|
52293
|
-
signingWallet
|
|
52267
|
+
recipients
|
|
52294
52268
|
}) {
|
|
52295
52269
|
this.$__molecule.initWithdrawBuffer({
|
|
52296
|
-
recipients
|
|
52297
|
-
signingWallet
|
|
52270
|
+
recipients
|
|
52298
52271
|
});
|
|
52299
52272
|
this.$__molecule.sign({});
|
|
52300
52273
|
this.$__molecule.check(this.$__molecule.sourceWallet);
|
|
@@ -53792,24 +53765,27 @@ ${operationTypes.join("\n")}
|
|
|
53792
53765
|
this.setCellSlug(cellSlug);
|
|
53793
53766
|
}
|
|
53794
53767
|
this.$__authInProcess = true;
|
|
53795
|
-
|
|
53796
|
-
|
|
53797
|
-
|
|
53798
|
-
|
|
53799
|
-
|
|
53800
|
-
|
|
53801
|
-
|
|
53802
|
-
|
|
53803
|
-
|
|
53804
|
-
|
|
53805
|
-
|
|
53806
|
-
|
|
53807
|
-
|
|
53808
|
-
|
|
53768
|
+
try {
|
|
53769
|
+
let response;
|
|
53770
|
+
if (secret) {
|
|
53771
|
+
response = await this.requestProfileAuthToken({
|
|
53772
|
+
secret,
|
|
53773
|
+
encrypt
|
|
53774
|
+
});
|
|
53775
|
+
} else {
|
|
53776
|
+
response = await this.requestGuestAuthToken({
|
|
53777
|
+
cellSlug: cellSlug || this.getCellSlug(),
|
|
53778
|
+
encrypt
|
|
53779
|
+
});
|
|
53780
|
+
}
|
|
53781
|
+
if (this.$__authToken) {
|
|
53782
|
+
this.log("info", `KnishIOClient::requestAuthToken() - Successfully retrieved auth token...`);
|
|
53783
|
+
}
|
|
53784
|
+
this.switchEncryption(encrypt);
|
|
53785
|
+
return response;
|
|
53786
|
+
} finally {
|
|
53787
|
+
this.$__authInProcess = false;
|
|
53809
53788
|
}
|
|
53810
|
-
this.switchEncryption(encrypt);
|
|
53811
|
-
this.$__authInProcess = false;
|
|
53812
|
-
return response;
|
|
53813
53789
|
}
|
|
53814
53790
|
/**
|
|
53815
53791
|
* Logging utility
|
|
@@ -53953,14 +53929,16 @@ ${operationTypes.join("\n")}
|
|
|
53953
53929
|
}
|
|
53954
53930
|
/**
|
|
53955
53931
|
* Query next ContinuId wallet
|
|
53932
|
+
*
|
|
53933
|
+
* @param token - Restricts the lookup to wallets of this token. Without it the validator falls
|
|
53934
|
+
* back to the bundle's newest wallet of ANY token when the bundle has no ContinuID pointer.
|
|
53956
53935
|
*/
|
|
53957
53936
|
async queryContinuId({
|
|
53958
|
-
bundle
|
|
53937
|
+
bundle,
|
|
53938
|
+
token = null
|
|
53959
53939
|
}) {
|
|
53960
53940
|
const query = this.createQuery(QueryContinuId);
|
|
53961
|
-
return this.executeQuery(query, {
|
|
53962
|
-
bundle
|
|
53963
|
-
});
|
|
53941
|
+
return this.executeQuery(query, token ? { bundle, token } : { bundle });
|
|
53964
53942
|
}
|
|
53965
53943
|
/**
|
|
53966
53944
|
* Query metadata
|
|
@@ -54777,8 +54755,7 @@ ${operationTypes.join("\n")}
|
|
|
54777
54755
|
async withdrawBufferToken({
|
|
54778
54756
|
tokenSlug,
|
|
54779
54757
|
amount,
|
|
54780
|
-
sourceWallet = null
|
|
54781
|
-
signingWallet = null
|
|
54758
|
+
sourceWallet = null
|
|
54782
54759
|
}) {
|
|
54783
54760
|
this.log("info", `KnishIOClient::withdrawBufferToken() - Withdrawing ${amount} of ${tokenSlug} from buffer...`);
|
|
54784
54761
|
if (!sourceWallet) {
|
|
@@ -54787,11 +54764,7 @@ ${operationTypes.join("\n")}
|
|
|
54787
54764
|
const mutation = await this.createMoleculeMutation({ mutationClass: MutationWithdrawBufferToken });
|
|
54788
54765
|
const recipients = {};
|
|
54789
54766
|
recipients[this.getBundle()] = amount;
|
|
54790
|
-
|
|
54791
|
-
if (signingWallet) {
|
|
54792
|
-
fillMoleculeParams.signingWallet = signingWallet;
|
|
54793
|
-
}
|
|
54794
|
-
await mutation.fillMolecule(fillMoleculeParams);
|
|
54767
|
+
await mutation.fillMolecule({ recipients });
|
|
54795
54768
|
const response = await this.executeQuery(mutation);
|
|
54796
54769
|
if (!response) {
|
|
54797
54770
|
throw new CodeException("Buffer token withdrawal failed");
|
|
@@ -54809,21 +54782,33 @@ ${operationTypes.join("\n")}
|
|
|
54809
54782
|
encrypt = false
|
|
54810
54783
|
} = {}) {
|
|
54811
54784
|
this.log("info", "KnishIOClient::requestGuestAuthToken() - Requesting guest auth token...");
|
|
54812
|
-
const
|
|
54813
|
-
|
|
54814
|
-
|
|
54815
|
-
|
|
54816
|
-
|
|
54817
|
-
|
|
54818
|
-
|
|
54819
|
-
|
|
54820
|
-
|
|
54785
|
+
const authInProcess = this.$__authInProcess;
|
|
54786
|
+
this.$__authInProcess = true;
|
|
54787
|
+
try {
|
|
54788
|
+
const mutation = this.createQuery(MutationRequestAuthorizationGuest);
|
|
54789
|
+
const response = await this.executeQuery(mutation, {
|
|
54790
|
+
cellSlug: cellSlug || this.getCellSlug()
|
|
54791
|
+
});
|
|
54792
|
+
if (!response) {
|
|
54793
|
+
throw new CodeException("Guest auth token request failed");
|
|
54794
|
+
}
|
|
54795
|
+
if (encrypt) {
|
|
54796
|
+
this.switchEncryption(true);
|
|
54797
|
+
}
|
|
54798
|
+
return response;
|
|
54799
|
+
} finally {
|
|
54800
|
+
this.$__authInProcess = authInProcess;
|
|
54821
54801
|
}
|
|
54822
|
-
return response;
|
|
54823
54802
|
}
|
|
54824
54803
|
/**
|
|
54825
54804
|
* Request profile authentication token
|
|
54826
|
-
*
|
|
54805
|
+
*
|
|
54806
|
+
* A returning user (the bundle has a USER ContinuID pointer) signs from the USER wallet
|
|
54807
|
+
* registered at that pointer, so validator 0.5.0+ marks the token proven and the identity keeps
|
|
54808
|
+
* read/subscription access to permissioned and private cells. A first login — or a pointer this
|
|
54809
|
+
* secret does not own — signs from a fresh AUTH wallet as before. A rejected pointer-signed
|
|
54810
|
+
* login falls back to the AUTH login exactly once, so one call sends at most two
|
|
54811
|
+
* authorization molecules (testnet allows 3 auths/min/IP).
|
|
54827
54812
|
*/
|
|
54828
54813
|
async requestProfileAuthToken({
|
|
54829
54814
|
secret,
|
|
@@ -54831,13 +54816,58 @@ ${operationTypes.join("\n")}
|
|
|
54831
54816
|
}) {
|
|
54832
54817
|
this.log("info", "KnishIOClient::requestProfileAuthToken() - Requesting profile auth token...");
|
|
54833
54818
|
this.setSecret(secret);
|
|
54834
|
-
const
|
|
54835
|
-
|
|
54836
|
-
|
|
54837
|
-
|
|
54838
|
-
|
|
54819
|
+
const authInProcess = this.$__authInProcess;
|
|
54820
|
+
this.$__authInProcess = true;
|
|
54821
|
+
try {
|
|
54822
|
+
const pointer = (await this.queryContinuId({
|
|
54823
|
+
bundle: this.getBundle(),
|
|
54824
|
+
token: "USER"
|
|
54825
|
+
}))?.payload();
|
|
54826
|
+
let pointerWallet = null;
|
|
54827
|
+
if (pointer && pointer.token === "USER" && pointer.position) {
|
|
54828
|
+
const wallet2 = new Wallet({
|
|
54829
|
+
secret,
|
|
54830
|
+
token: "USER",
|
|
54831
|
+
position: pointer.position,
|
|
54832
|
+
mlKemParameterSet: this.getMlKemParameterSet()
|
|
54833
|
+
});
|
|
54834
|
+
if (!pointer.address || wallet2.address === pointer.address) {
|
|
54835
|
+
pointerWallet = wallet2;
|
|
54836
|
+
} else {
|
|
54837
|
+
this.log("warn", "KnishIOClient::requestProfileAuthToken() - ContinuID wallet address does not derive from this secret; signing from a fresh AUTH wallet");
|
|
54838
|
+
}
|
|
54839
|
+
}
|
|
54840
|
+
if (pointerWallet) {
|
|
54841
|
+
const response2 = await this.proposeProfileAuthorization(pointerWallet, encrypt);
|
|
54842
|
+
if (response2.success()) {
|
|
54843
|
+
this.log("info", "KnishIOClient::requestProfileAuthToken() - Auth token signed from the ContinuID pointer (proven)");
|
|
54844
|
+
return this.acceptProfileAuthorization(response2, pointerWallet, encrypt);
|
|
54845
|
+
}
|
|
54846
|
+
this.log("warn", `KnishIOClient::requestProfileAuthToken() - Pointer-signed authorization rejected (${response2.reason()}); falling back once to an AUTH-wallet login`);
|
|
54847
|
+
}
|
|
54848
|
+
const wallet = new Wallet({
|
|
54849
|
+
secret,
|
|
54850
|
+
token: "AUTH",
|
|
54851
|
+
mlKemParameterSet: this.getMlKemParameterSet()
|
|
54852
|
+
});
|
|
54853
|
+
const response = await this.proposeProfileAuthorization(wallet, encrypt);
|
|
54854
|
+
if (!response.success()) {
|
|
54855
|
+
throw new AuthorizationRejectedException_default(
|
|
54856
|
+
`KnishIOClient::requestProfileAuthToken() - Authorization attempt rejected by ledger. Reason: ${response.reason()}`
|
|
54857
|
+
);
|
|
54858
|
+
}
|
|
54859
|
+
this.log("info", `KnishIOClient::requestProfileAuthToken() - Auth token signed from a fresh AUTH wallet (${pointerWallet ? "fallback after the pointer-signed login was rejected" : "no usable ContinuID pointer"})`);
|
|
54860
|
+
return this.acceptProfileAuthorization(response, wallet, encrypt);
|
|
54861
|
+
} finally {
|
|
54862
|
+
this.$__authInProcess = authInProcess;
|
|
54863
|
+
}
|
|
54864
|
+
}
|
|
54865
|
+
/**
|
|
54866
|
+
* Signs and proposes a profile authorization molecule from the given source wallet.
|
|
54867
|
+
*/
|
|
54868
|
+
async proposeProfileAuthorization(wallet, encrypt) {
|
|
54839
54869
|
const molecule = await this.createMolecule({
|
|
54840
|
-
secret,
|
|
54870
|
+
secret: this.getSecret(),
|
|
54841
54871
|
sourceWallet: wallet
|
|
54842
54872
|
});
|
|
54843
54873
|
const mutation = await this.createMoleculeMutation({
|
|
@@ -54855,19 +54885,20 @@ ${operationTypes.join("\n")}
|
|
|
54855
54885
|
if (!response) {
|
|
54856
54886
|
throw new CodeException("Profile auth token request failed");
|
|
54857
54887
|
}
|
|
54858
|
-
|
|
54859
|
-
|
|
54860
|
-
|
|
54861
|
-
|
|
54862
|
-
|
|
54863
|
-
|
|
54864
|
-
|
|
54865
|
-
|
|
54866
|
-
|
|
54867
|
-
|
|
54868
|
-
|
|
54869
|
-
|
|
54870
|
-
|
|
54888
|
+
return response;
|
|
54889
|
+
}
|
|
54890
|
+
/**
|
|
54891
|
+
* Binds the accepted authorization's token to the wallet that signed it.
|
|
54892
|
+
*/
|
|
54893
|
+
acceptProfileAuthorization(response, wallet, encrypt) {
|
|
54894
|
+
const authToken = AuthToken.create({
|
|
54895
|
+
token: response.token(),
|
|
54896
|
+
expiresAt: response.expiresAt(),
|
|
54897
|
+
encrypt: String(response.encrypt()) === "true",
|
|
54898
|
+
pubkey: response.pubKey()
|
|
54899
|
+
}, wallet);
|
|
54900
|
+
this.setAuthToken(authToken);
|
|
54901
|
+
this.lastMoleculeQuery = null;
|
|
54871
54902
|
if (encrypt) {
|
|
54872
54903
|
this.switchEncryption(true);
|
|
54873
54904
|
}
|
|
@@ -56225,7 +56256,7 @@ ${operationTypes.join("\n")}
|
|
|
56225
56256
|
}
|
|
56226
56257
|
|
|
56227
56258
|
// src/index.ts
|
|
56228
|
-
var SDK_VERSION = "1.
|
|
56259
|
+
var SDK_VERSION = "1.3.0";
|
|
56229
56260
|
var SDK_NAME = "KnishIO-Client-TS";
|
|
56230
56261
|
var COMPATIBLE_SERVER_VERSIONS = [4, 5];
|
|
56231
56262
|
var SDK_INFO = {
|