@wishknish/knishio-client-ts 1.2.1 → 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 +142 -121
- 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 +142 -121
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +142 -121
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/AuthToken.ts +6 -2
- package/src/KnishIOClient.ts +151 -80
- 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 +16 -0
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
|
@@ -41549,24 +41549,6 @@ ${operationTypes.join("\n")}
|
|
|
41549
41549
|
this.merge({ shadowWalletClaim: Number(shadowWalletClaim) });
|
|
41550
41550
|
return this;
|
|
41551
41551
|
}
|
|
41552
|
-
/**
|
|
41553
|
-
* Set signing wallet metadata
|
|
41554
|
-
* @param signingWallet - Wallet used for signing
|
|
41555
|
-
* @return This instance for chaining
|
|
41556
|
-
*/
|
|
41557
|
-
setSigningWallet(signingWallet) {
|
|
41558
|
-
this.merge({
|
|
41559
|
-
signingWallet: JSON.stringify({
|
|
41560
|
-
tokenSlug: signingWallet.token,
|
|
41561
|
-
bundleHash: signingWallet.bundle,
|
|
41562
|
-
address: signingWallet.address,
|
|
41563
|
-
position: signingWallet.position,
|
|
41564
|
-
pubkey: signingWallet.pubkey,
|
|
41565
|
-
characters: signingWallet.characters
|
|
41566
|
-
})
|
|
41567
|
-
});
|
|
41568
|
-
return this;
|
|
41569
|
-
}
|
|
41570
41552
|
/**
|
|
41571
41553
|
* Add policy metadata
|
|
41572
41554
|
* @param policy - Policy object to add
|
|
@@ -44517,7 +44499,6 @@ ${operationTypes.join("\n")}
|
|
|
44517
44499
|
|
|
44518
44500
|
// src/libraries/CheckMolecule.ts
|
|
44519
44501
|
init_exception();
|
|
44520
|
-
init_Dot();
|
|
44521
44502
|
var CheckMolecule = class _CheckMolecule {
|
|
44522
44503
|
molecule;
|
|
44523
44504
|
/**
|
|
@@ -44605,12 +44586,13 @@ ${operationTypes.join("\n")}
|
|
|
44605
44586
|
/**
|
|
44606
44587
|
* Validate isotope U atoms
|
|
44607
44588
|
* @return True if valid
|
|
44608
|
-
* @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)
|
|
44609
44591
|
* @throws AtomIndexException if index is not 0
|
|
44610
44592
|
*/
|
|
44611
44593
|
isotopeU() {
|
|
44612
44594
|
for (const atom of this.molecule.getIsotopes("U")) {
|
|
44613
|
-
if (atom.token !== "AUTH") {
|
|
44595
|
+
if (atom.token !== "AUTH" && atom.token !== "USER") {
|
|
44614
44596
|
throw new WrongTokenTypeException(`Check::isotopeU() - "${atom.token}" is not a valid Token slug for "${atom.isotope}" isotope Atoms!`);
|
|
44615
44597
|
}
|
|
44616
44598
|
if (atom.index !== 0) {
|
|
@@ -44999,16 +44981,7 @@ ${operationTypes.join("\n")}
|
|
|
44999
44981
|
if (!signingAtom) {
|
|
45000
44982
|
throw new exports.SignatureMismatchException();
|
|
45001
44983
|
}
|
|
45002
|
-
|
|
45003
|
-
const signingWallet = exports.Dot.get(signingAtom.aggregatedMeta(), "signingWallet");
|
|
45004
|
-
if (signingWallet) {
|
|
45005
|
-
const parsedWallet = JSON.parse(signingWallet);
|
|
45006
|
-
const walletAddress = exports.Dot.get(parsedWallet, "address");
|
|
45007
|
-
if (walletAddress) {
|
|
45008
|
-
signingAddress = walletAddress;
|
|
45009
|
-
}
|
|
45010
|
-
}
|
|
45011
|
-
if (address !== signingAddress) {
|
|
44984
|
+
if (address !== signingAtom.walletAddress) {
|
|
45012
44985
|
throw new exports.SignatureMismatchException();
|
|
45013
44986
|
}
|
|
45014
44987
|
return true;
|
|
@@ -45343,18 +45316,7 @@ ${operationTypes.join("\n")}
|
|
|
45343
45316
|
if (!signingAtom) {
|
|
45344
45317
|
throw new SignatureMalformedException("No atoms available for signing!");
|
|
45345
45318
|
}
|
|
45346
|
-
|
|
45347
|
-
const signingWalletMeta = signingAtom.aggregatedMeta ? signingAtom.aggregatedMeta() : null;
|
|
45348
|
-
const signingWalletJson = signingWalletMeta?.signingWallet;
|
|
45349
|
-
if (signingWalletJson) {
|
|
45350
|
-
try {
|
|
45351
|
-
const parsedSigningWallet = JSON.parse(signingWalletJson);
|
|
45352
|
-
if (parsedSigningWallet.position) {
|
|
45353
|
-
signingPosition = parsedSigningWallet.position;
|
|
45354
|
-
}
|
|
45355
|
-
} catch {
|
|
45356
|
-
}
|
|
45357
|
-
}
|
|
45319
|
+
const signingPosition = signingAtom.position;
|
|
45358
45320
|
if (!signingPosition) {
|
|
45359
45321
|
throw new SignatureMalformedException("Signing wallet must have a position!");
|
|
45360
45322
|
}
|
|
@@ -45757,9 +45719,7 @@ ${operationTypes.join("\n")}
|
|
|
45757
45719
|
const atomMeta = new AtomMeta({
|
|
45758
45720
|
rule: JSON.stringify(rules)
|
|
45759
45721
|
});
|
|
45760
|
-
|
|
45761
|
-
atomMeta.addPolicy(policy);
|
|
45762
|
-
}
|
|
45722
|
+
atomMeta.addPolicy(policy ?? {});
|
|
45763
45723
|
this.addAtom(Atom.create({
|
|
45764
45724
|
isotope: "R",
|
|
45765
45725
|
wallet: this.sourceWallet,
|
|
@@ -46012,12 +45972,10 @@ ${operationTypes.join("\n")}
|
|
|
46012
45972
|
* Matches JavaScript SDK Molecule.initWithdrawBuffer implementation exactly
|
|
46013
45973
|
*
|
|
46014
45974
|
* @param recipients - Map of recipientBundle → amount
|
|
46015
|
-
* @param signingWallet - Optional signing wallet for reconciliation
|
|
46016
45975
|
* @return This molecule instance for chaining
|
|
46017
45976
|
*/
|
|
46018
45977
|
initWithdrawBuffer({
|
|
46019
|
-
recipients
|
|
46020
|
-
signingWallet = null
|
|
45978
|
+
recipients
|
|
46021
45979
|
}) {
|
|
46022
45980
|
if (!this.sourceWallet) {
|
|
46023
45981
|
throw new Error("Source wallet required for buffer withdrawal");
|
|
@@ -46029,15 +45987,10 @@ ${operationTypes.join("\n")}
|
|
|
46029
45987
|
if (Number(this.sourceWallet.balance) - amount < 0) {
|
|
46030
45988
|
throw new BalanceInsufficientException();
|
|
46031
45989
|
}
|
|
46032
|
-
const firstAtomMeta = new AtomMeta();
|
|
46033
|
-
if (signingWallet) {
|
|
46034
|
-
firstAtomMeta.setSigningWallet(signingWallet);
|
|
46035
|
-
}
|
|
46036
45990
|
this.addAtom(Atom.create({
|
|
46037
45991
|
isotope: "B",
|
|
46038
45992
|
wallet: this.sourceWallet,
|
|
46039
45993
|
value: -Number(this.sourceWallet.balance),
|
|
46040
|
-
meta: firstAtomMeta,
|
|
46041
45994
|
metaType: "walletBundle",
|
|
46042
45995
|
metaId: this.sourceWallet.bundle
|
|
46043
45996
|
}));
|
|
@@ -48896,7 +48849,7 @@ ${operationTypes.join("\n")}
|
|
|
48896
48849
|
static restore(snapshot, secret) {
|
|
48897
48850
|
const wallet = new Wallet({
|
|
48898
48851
|
secret,
|
|
48899
|
-
token: "AUTH",
|
|
48852
|
+
token: snapshot.wallet?.token ?? "AUTH",
|
|
48900
48853
|
position: snapshot.wallet?.position ?? null,
|
|
48901
48854
|
characters: snapshot.wallet?.characters ?? null,
|
|
48902
48855
|
mlKemParameterSet: _AuthToken.resolveMlKemParameterSet(snapshot)
|
|
@@ -48979,6 +48932,7 @@ ${operationTypes.join("\n")}
|
|
|
48979
48932
|
encrypt: this.$__encrypt,
|
|
48980
48933
|
...this.$__wallet ? {
|
|
48981
48934
|
wallet: {
|
|
48935
|
+
token: this.$__wallet.token,
|
|
48982
48936
|
position: this.$__wallet.position,
|
|
48983
48937
|
characters: this.$__wallet.characters,
|
|
48984
48938
|
mlKemParameterSet: this.$__wallet.mlKemParameterSet
|
|
@@ -50478,8 +50432,8 @@ ${operationTypes.join("\n")}
|
|
|
50478
50432
|
*/
|
|
50479
50433
|
constructor(graphQLClient, knishIOClient) {
|
|
50480
50434
|
super(graphQLClient, knishIOClient);
|
|
50481
|
-
this.$__query = gql`query ($bundle: String
|
|
50482
|
-
ContinuId(bundle: $bundle) {
|
|
50435
|
+
this.$__query = gql`query ($bundle: String!, $token: String) {
|
|
50436
|
+
ContinuId(bundle: $bundle, token: $token) {
|
|
50483
50437
|
address,
|
|
50484
50438
|
bundleHash,
|
|
50485
50439
|
tokenSlug,
|
|
@@ -51797,6 +51751,18 @@ ${operationTypes.join("\n")}
|
|
|
51797
51751
|
code: "VERIFICATION_FAILED"
|
|
51798
51752
|
});
|
|
51799
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
|
+
}
|
|
51800
51766
|
return null;
|
|
51801
51767
|
}
|
|
51802
51768
|
/**
|
|
@@ -52298,12 +52264,10 @@ ${operationTypes.join("\n")}
|
|
|
52298
52264
|
* Fills the molecule with buffer withdrawal data
|
|
52299
52265
|
*/
|
|
52300
52266
|
fillMolecule({
|
|
52301
|
-
recipients
|
|
52302
|
-
signingWallet
|
|
52267
|
+
recipients
|
|
52303
52268
|
}) {
|
|
52304
52269
|
this.$__molecule.initWithdrawBuffer({
|
|
52305
|
-
recipients
|
|
52306
|
-
signingWallet
|
|
52270
|
+
recipients
|
|
52307
52271
|
});
|
|
52308
52272
|
this.$__molecule.sign({});
|
|
52309
52273
|
this.$__molecule.check(this.$__molecule.sourceWallet);
|
|
@@ -53801,24 +53765,27 @@ ${operationTypes.join("\n")}
|
|
|
53801
53765
|
this.setCellSlug(cellSlug);
|
|
53802
53766
|
}
|
|
53803
53767
|
this.$__authInProcess = true;
|
|
53804
|
-
|
|
53805
|
-
|
|
53806
|
-
|
|
53807
|
-
|
|
53808
|
-
|
|
53809
|
-
|
|
53810
|
-
|
|
53811
|
-
|
|
53812
|
-
|
|
53813
|
-
|
|
53814
|
-
|
|
53815
|
-
|
|
53816
|
-
|
|
53817
|
-
|
|
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;
|
|
53818
53788
|
}
|
|
53819
|
-
this.switchEncryption(encrypt);
|
|
53820
|
-
this.$__authInProcess = false;
|
|
53821
|
-
return response;
|
|
53822
53789
|
}
|
|
53823
53790
|
/**
|
|
53824
53791
|
* Logging utility
|
|
@@ -53962,14 +53929,16 @@ ${operationTypes.join("\n")}
|
|
|
53962
53929
|
}
|
|
53963
53930
|
/**
|
|
53964
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.
|
|
53965
53935
|
*/
|
|
53966
53936
|
async queryContinuId({
|
|
53967
|
-
bundle
|
|
53937
|
+
bundle,
|
|
53938
|
+
token = null
|
|
53968
53939
|
}) {
|
|
53969
53940
|
const query = this.createQuery(QueryContinuId);
|
|
53970
|
-
return this.executeQuery(query, {
|
|
53971
|
-
bundle
|
|
53972
|
-
});
|
|
53941
|
+
return this.executeQuery(query, token ? { bundle, token } : { bundle });
|
|
53973
53942
|
}
|
|
53974
53943
|
/**
|
|
53975
53944
|
* Query metadata
|
|
@@ -54786,8 +54755,7 @@ ${operationTypes.join("\n")}
|
|
|
54786
54755
|
async withdrawBufferToken({
|
|
54787
54756
|
tokenSlug,
|
|
54788
54757
|
amount,
|
|
54789
|
-
sourceWallet = null
|
|
54790
|
-
signingWallet = null
|
|
54758
|
+
sourceWallet = null
|
|
54791
54759
|
}) {
|
|
54792
54760
|
this.log("info", `KnishIOClient::withdrawBufferToken() - Withdrawing ${amount} of ${tokenSlug} from buffer...`);
|
|
54793
54761
|
if (!sourceWallet) {
|
|
@@ -54796,11 +54764,7 @@ ${operationTypes.join("\n")}
|
|
|
54796
54764
|
const mutation = await this.createMoleculeMutation({ mutationClass: MutationWithdrawBufferToken });
|
|
54797
54765
|
const recipients = {};
|
|
54798
54766
|
recipients[this.getBundle()] = amount;
|
|
54799
|
-
|
|
54800
|
-
if (signingWallet) {
|
|
54801
|
-
fillMoleculeParams.signingWallet = signingWallet;
|
|
54802
|
-
}
|
|
54803
|
-
await mutation.fillMolecule(fillMoleculeParams);
|
|
54767
|
+
await mutation.fillMolecule({ recipients });
|
|
54804
54768
|
const response = await this.executeQuery(mutation);
|
|
54805
54769
|
if (!response) {
|
|
54806
54770
|
throw new CodeException("Buffer token withdrawal failed");
|
|
@@ -54818,21 +54782,33 @@ ${operationTypes.join("\n")}
|
|
|
54818
54782
|
encrypt = false
|
|
54819
54783
|
} = {}) {
|
|
54820
54784
|
this.log("info", "KnishIOClient::requestGuestAuthToken() - Requesting guest auth token...");
|
|
54821
|
-
const
|
|
54822
|
-
|
|
54823
|
-
|
|
54824
|
-
|
|
54825
|
-
|
|
54826
|
-
|
|
54827
|
-
|
|
54828
|
-
|
|
54829
|
-
|
|
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;
|
|
54830
54801
|
}
|
|
54831
|
-
return response;
|
|
54832
54802
|
}
|
|
54833
54803
|
/**
|
|
54834
54804
|
* Request profile authentication token
|
|
54835
|
-
*
|
|
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).
|
|
54836
54812
|
*/
|
|
54837
54813
|
async requestProfileAuthToken({
|
|
54838
54814
|
secret,
|
|
@@ -54840,13 +54816,58 @@ ${operationTypes.join("\n")}
|
|
|
54840
54816
|
}) {
|
|
54841
54817
|
this.log("info", "KnishIOClient::requestProfileAuthToken() - Requesting profile auth token...");
|
|
54842
54818
|
this.setSecret(secret);
|
|
54843
|
-
const
|
|
54844
|
-
|
|
54845
|
-
|
|
54846
|
-
|
|
54847
|
-
|
|
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) {
|
|
54848
54869
|
const molecule = await this.createMolecule({
|
|
54849
|
-
secret,
|
|
54870
|
+
secret: this.getSecret(),
|
|
54850
54871
|
sourceWallet: wallet
|
|
54851
54872
|
});
|
|
54852
54873
|
const mutation = await this.createMoleculeMutation({
|
|
@@ -54864,20 +54885,20 @@ ${operationTypes.join("\n")}
|
|
|
54864
54885
|
if (!response) {
|
|
54865
54886
|
throw new CodeException("Profile auth token request failed");
|
|
54866
54887
|
}
|
|
54867
|
-
|
|
54868
|
-
|
|
54869
|
-
|
|
54870
|
-
|
|
54871
|
-
|
|
54872
|
-
|
|
54873
|
-
|
|
54874
|
-
|
|
54875
|
-
|
|
54876
|
-
|
|
54877
|
-
|
|
54878
|
-
|
|
54879
|
-
|
|
54880
|
-
|
|
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;
|
|
54881
54902
|
if (encrypt) {
|
|
54882
54903
|
this.switchEncryption(true);
|
|
54883
54904
|
}
|
|
@@ -56235,7 +56256,7 @@ ${operationTypes.join("\n")}
|
|
|
56235
56256
|
}
|
|
56236
56257
|
|
|
56237
56258
|
// src/index.ts
|
|
56238
|
-
var SDK_VERSION = "1.
|
|
56259
|
+
var SDK_VERSION = "1.3.0";
|
|
56239
56260
|
var SDK_NAME = "KnishIO-Client-TS";
|
|
56240
56261
|
var COMPATIBLE_SERVER_VERSIONS = [4, 5];
|
|
56241
56262
|
var SDK_INFO = {
|