@meshsdk/wallet 1.8.8 → 1.8.10
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 +36 -15
- package/dist/index.d.cts +26 -5
- package/dist/index.d.ts +26 -5
- package/dist/index.js +36 -15
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -711,9 +711,22 @@ var EmbeddedWallet = class extends WalletStaticMethods {
|
|
|
711
711
|
}
|
|
712
712
|
return _account;
|
|
713
713
|
}
|
|
714
|
+
/**
|
|
715
|
+
* Get wallet network ID.
|
|
716
|
+
*
|
|
717
|
+
* @returns network ID
|
|
718
|
+
*/
|
|
714
719
|
getNetworkId() {
|
|
715
720
|
return this._networkId;
|
|
716
721
|
}
|
|
722
|
+
/**
|
|
723
|
+
* This endpoint utilizes the [CIP-8 - Message Signing](https://cips.cardano.org/cips/cip8/) to sign arbitrary data, to verify the data was signed by the owner of the private key.
|
|
724
|
+
*
|
|
725
|
+
* @param address - bech32 address to sign the data with
|
|
726
|
+
* @param payload - the data to be signed
|
|
727
|
+
* @param accountIndex account index (default: 0)
|
|
728
|
+
* @returns a signature
|
|
729
|
+
*/
|
|
717
730
|
signData(address, payload, accountIndex = 0, keyIndex = 0) {
|
|
718
731
|
try {
|
|
719
732
|
const { baseAddress, enterpriseAddress, rewardAddress, paymentKey } = this.getAccount(accountIndex, keyIndex);
|
|
@@ -734,6 +747,14 @@ var EmbeddedWallet = class extends WalletStaticMethods {
|
|
|
734
747
|
);
|
|
735
748
|
}
|
|
736
749
|
}
|
|
750
|
+
/**
|
|
751
|
+
* This endpoints sign the provided transaction (unsignedTx) with the private key of the owner.
|
|
752
|
+
*
|
|
753
|
+
* @param unsignedTx - a transaction in CBOR
|
|
754
|
+
* @param accountIndex account index (default: 0)
|
|
755
|
+
* @param keyIndex key index (default: 0)
|
|
756
|
+
* @returns VkeyWitness
|
|
757
|
+
*/
|
|
737
758
|
signTx(unsignedTx, accountIndex = 0, keyIndex = 0) {
|
|
738
759
|
try {
|
|
739
760
|
const txHash = (0, import_core_cst.deserializeTxHash)((0, import_core_cst.resolveTxHash)(unsignedTx));
|
|
@@ -847,7 +868,7 @@ var AppWallet = class {
|
|
|
847
868
|
);
|
|
848
869
|
return utxos.map((utxo) => (0, import_core_cst2.toTxUnspentOutput)(utxo));
|
|
849
870
|
}
|
|
850
|
-
signData(address, payload, accountIndex = 0, keyIndex = 0) {
|
|
871
|
+
async signData(address, payload, accountIndex = 0, keyIndex = 0) {
|
|
851
872
|
try {
|
|
852
873
|
return this._wallet.signData(address, payload, accountIndex, keyIndex);
|
|
853
874
|
} catch (error) {
|
|
@@ -856,7 +877,7 @@ var AppWallet = class {
|
|
|
856
877
|
);
|
|
857
878
|
}
|
|
858
879
|
}
|
|
859
|
-
signTx(unsignedTx, partialSign = false, accountIndex = 0, keyIndex = 0) {
|
|
880
|
+
async signTx(unsignedTx, partialSign = false, accountIndex = 0, keyIndex = 0) {
|
|
860
881
|
try {
|
|
861
882
|
const tx = (0, import_core_cst2.deserializeTx)(unsignedTx);
|
|
862
883
|
if (!partialSign && tx.witnessSet().vkeys() !== void 0 && tx.witnessSet().vkeys().size() !== 0)
|
|
@@ -1428,7 +1449,7 @@ async function login({
|
|
|
1428
1449
|
serverUrl,
|
|
1429
1450
|
username
|
|
1430
1451
|
}) {
|
|
1431
|
-
const initAuthRes = await fetch(`${serverUrl}/init
|
|
1452
|
+
const initAuthRes = await fetch(`${serverUrl}/auth-init`, {
|
|
1432
1453
|
credentials: "include",
|
|
1433
1454
|
method: "POST",
|
|
1434
1455
|
headers: {
|
|
@@ -1446,9 +1467,9 @@ async function login({
|
|
|
1446
1467
|
errorCode: initAuth.errorCode
|
|
1447
1468
|
};
|
|
1448
1469
|
}
|
|
1449
|
-
const optionsJSON = initAuth.optionsJSON;
|
|
1470
|
+
const optionsJSON = initAuth.data.optionsJSON;
|
|
1450
1471
|
const authJSON = await (0, import_browser.startAuthentication)({ optionsJSON });
|
|
1451
|
-
const verifyAuthRes = await fetch(`${serverUrl}/verify
|
|
1472
|
+
const verifyAuthRes = await fetch(`${serverUrl}/auth-verify`, {
|
|
1452
1473
|
credentials: "include",
|
|
1453
1474
|
method: "POST",
|
|
1454
1475
|
headers: {
|
|
@@ -1460,7 +1481,7 @@ async function login({
|
|
|
1460
1481
|
if (!verifyAuthRes.ok) {
|
|
1461
1482
|
return { success: false, error: verifyAuth.error };
|
|
1462
1483
|
}
|
|
1463
|
-
if (verifyAuth.verified) {
|
|
1484
|
+
if (verifyAuth.data.verified) {
|
|
1464
1485
|
return { success: true, authJSON };
|
|
1465
1486
|
} else {
|
|
1466
1487
|
return { success: false, error: "Failed to log in" };
|
|
@@ -1473,7 +1494,7 @@ async function register({
|
|
|
1473
1494
|
serverUrl,
|
|
1474
1495
|
username
|
|
1475
1496
|
}) {
|
|
1476
|
-
const initRegisterRes = await fetch(`${serverUrl}/init
|
|
1497
|
+
const initRegisterRes = await fetch(`${serverUrl}/register-init`, {
|
|
1477
1498
|
credentials: "include",
|
|
1478
1499
|
method: "POST",
|
|
1479
1500
|
headers: {
|
|
@@ -1491,9 +1512,9 @@ async function register({
|
|
|
1491
1512
|
errorCode: initRegister.errorCode
|
|
1492
1513
|
};
|
|
1493
1514
|
}
|
|
1494
|
-
const optionsJSON = initRegister.optionsJSON;
|
|
1515
|
+
const optionsJSON = initRegister.data.optionsJSON;
|
|
1495
1516
|
const registrationJSON = await (0, import_browser2.startRegistration)({ optionsJSON });
|
|
1496
|
-
const verifyResponse = await fetch(`${serverUrl}/verify
|
|
1517
|
+
const verifyResponse = await fetch(`${serverUrl}/register-verify`, {
|
|
1497
1518
|
credentials: "include",
|
|
1498
1519
|
method: "POST",
|
|
1499
1520
|
headers: {
|
|
@@ -1510,7 +1531,7 @@ async function register({
|
|
|
1510
1531
|
errorCode: verifyData.errorCode
|
|
1511
1532
|
};
|
|
1512
1533
|
}
|
|
1513
|
-
if (verifyData.verified) {
|
|
1534
|
+
if (verifyData.data.verified) {
|
|
1514
1535
|
console.log(`Successfully registered ${username}`);
|
|
1515
1536
|
return { success: true };
|
|
1516
1537
|
} else {
|
|
@@ -1526,7 +1547,7 @@ async function connect({
|
|
|
1526
1547
|
serverUrl
|
|
1527
1548
|
}) {
|
|
1528
1549
|
const responseRegister = await register({ serverUrl, username });
|
|
1529
|
-
if (responseRegister.success || responseRegister.errorCode == ERRORCODES.USEREXISTS) {
|
|
1550
|
+
if (responseRegister.success || responseRegister.error.errorCode == ERRORCODES.USEREXISTS) {
|
|
1530
1551
|
const loginRes = await handleLogin({ serverUrl, username });
|
|
1531
1552
|
if (loginRes.success && loginRes.authJSON) {
|
|
1532
1553
|
const wallet = await buildWalletFromPasskey(
|
|
@@ -1779,7 +1800,7 @@ var MeshWallet = class {
|
|
|
1779
1800
|
* @param address - the address to use for signing (optional)
|
|
1780
1801
|
* @returns a signature
|
|
1781
1802
|
*/
|
|
1782
|
-
signData(payload, address) {
|
|
1803
|
+
async signData(payload, address) {
|
|
1783
1804
|
if (!this._wallet) {
|
|
1784
1805
|
throw new Error(
|
|
1785
1806
|
"[MeshWallet] Read only wallet does not support signing data."
|
|
@@ -1802,7 +1823,7 @@ var MeshWallet = class {
|
|
|
1802
1823
|
* @param partialSign - if the transaction is partially signed (default: false)
|
|
1803
1824
|
* @returns a signed transaction in CBOR
|
|
1804
1825
|
*/
|
|
1805
|
-
signTx(unsignedTx, partialSign = false) {
|
|
1826
|
+
async signTx(unsignedTx, partialSign = false) {
|
|
1806
1827
|
if (!this._wallet) {
|
|
1807
1828
|
throw new Error(
|
|
1808
1829
|
"[MeshWallet] Read only wallet does not support signing data."
|
|
@@ -1828,7 +1849,7 @@ var MeshWallet = class {
|
|
|
1828
1849
|
* @param partialSign - if the transactions are signed partially
|
|
1829
1850
|
* @returns array of signed transactions CborHex string
|
|
1830
1851
|
*/
|
|
1831
|
-
signTxs(unsignedTxs, partialSign = false) {
|
|
1852
|
+
async signTxs(unsignedTxs, partialSign = false) {
|
|
1832
1853
|
if (!this._wallet) {
|
|
1833
1854
|
throw new Error(
|
|
1834
1855
|
"[MeshWallet] Read only wallet does not support signing data."
|
|
@@ -1836,7 +1857,7 @@ var MeshWallet = class {
|
|
|
1836
1857
|
}
|
|
1837
1858
|
const signedTxs = [];
|
|
1838
1859
|
for (const unsignedTx of unsignedTxs) {
|
|
1839
|
-
const signedTx = this.signTx(unsignedTx, partialSign);
|
|
1860
|
+
const signedTx = await this.signTx(unsignedTx, partialSign);
|
|
1840
1861
|
signedTxs.push(signedTx);
|
|
1841
1862
|
}
|
|
1842
1863
|
return signedTxs;
|
package/dist/index.d.cts
CHANGED
|
@@ -91,8 +91,8 @@ declare class AppWallet implements ISigner, ISubmitter {
|
|
|
91
91
|
getNetworkId(): number;
|
|
92
92
|
getUsedAddress(accountIndex?: number, keyIndex?: number, addressType?: GetAddressType): Address;
|
|
93
93
|
getUnspentOutputs(accountIndex?: number, addressType?: GetAddressType): Promise<TransactionUnspentOutput[]>;
|
|
94
|
-
signData(address: string, payload: string, accountIndex?: number, keyIndex?: number): DataSignature
|
|
95
|
-
signTx(unsignedTx: string, partialSign?: boolean, accountIndex?: number, keyIndex?: number): string
|
|
94
|
+
signData(address: string, payload: string, accountIndex?: number, keyIndex?: number): Promise<DataSignature>;
|
|
95
|
+
signTx(unsignedTx: string, partialSign?: boolean, accountIndex?: number, keyIndex?: number): Promise<string>;
|
|
96
96
|
signTxSync(unsignedTx: string, partialSign?: boolean, accountIndex?: number, keyIndex?: number): string;
|
|
97
97
|
signTxs(unsignedTxs: string[], partialSign: boolean): Promise<string[]>;
|
|
98
98
|
submitTx(tx: string): Promise<string>;
|
|
@@ -433,8 +433,29 @@ declare class EmbeddedWallet extends WalletStaticMethods {
|
|
|
433
433
|
private readonly _networkId;
|
|
434
434
|
constructor(options: CreateEmbeddedWalletOptions);
|
|
435
435
|
getAccount(accountIndex?: number, keyIndex?: number): Account;
|
|
436
|
+
/**
|
|
437
|
+
* Get wallet network ID.
|
|
438
|
+
*
|
|
439
|
+
* @returns network ID
|
|
440
|
+
*/
|
|
436
441
|
getNetworkId(): number;
|
|
442
|
+
/**
|
|
443
|
+
* This endpoint utilizes the [CIP-8 - Message Signing](https://cips.cardano.org/cips/cip8/) to sign arbitrary data, to verify the data was signed by the owner of the private key.
|
|
444
|
+
*
|
|
445
|
+
* @param address - bech32 address to sign the data with
|
|
446
|
+
* @param payload - the data to be signed
|
|
447
|
+
* @param accountIndex account index (default: 0)
|
|
448
|
+
* @returns a signature
|
|
449
|
+
*/
|
|
437
450
|
signData(address: string, payload: string, accountIndex?: number, keyIndex?: number): DataSignature;
|
|
451
|
+
/**
|
|
452
|
+
* This endpoints sign the provided transaction (unsignedTx) with the private key of the owner.
|
|
453
|
+
*
|
|
454
|
+
* @param unsignedTx - a transaction in CBOR
|
|
455
|
+
* @param accountIndex account index (default: 0)
|
|
456
|
+
* @param keyIndex key index (default: 0)
|
|
457
|
+
* @returns VkeyWitness
|
|
458
|
+
*/
|
|
438
459
|
signTx(unsignedTx: string, accountIndex?: number, keyIndex?: number): VkeyWitness;
|
|
439
460
|
}
|
|
440
461
|
|
|
@@ -617,7 +638,7 @@ declare class MeshWallet implements IWallet {
|
|
|
617
638
|
* @param address - the address to use for signing (optional)
|
|
618
639
|
* @returns a signature
|
|
619
640
|
*/
|
|
620
|
-
signData(payload: string, address?: string): DataSignature
|
|
641
|
+
signData(payload: string, address?: string): Promise<DataSignature>;
|
|
621
642
|
/**
|
|
622
643
|
* Requests user to sign the provided transaction (tx). The wallet should ask the user for permission, and if given, try to sign the supplied body and return a signed transaction. partialSign should be true if the transaction provided requires multiple signatures.
|
|
623
644
|
*
|
|
@@ -625,7 +646,7 @@ declare class MeshWallet implements IWallet {
|
|
|
625
646
|
* @param partialSign - if the transaction is partially signed (default: false)
|
|
626
647
|
* @returns a signed transaction in CBOR
|
|
627
648
|
*/
|
|
628
|
-
signTx(unsignedTx: string, partialSign?: boolean): string
|
|
649
|
+
signTx(unsignedTx: string, partialSign?: boolean): Promise<string>;
|
|
629
650
|
/**
|
|
630
651
|
* Experimental feature - sign multiple transactions at once.
|
|
631
652
|
*
|
|
@@ -633,7 +654,7 @@ declare class MeshWallet implements IWallet {
|
|
|
633
654
|
* @param partialSign - if the transactions are signed partially
|
|
634
655
|
* @returns array of signed transactions CborHex string
|
|
635
656
|
*/
|
|
636
|
-
signTxs(unsignedTxs: string[], partialSign?: boolean): string[]
|
|
657
|
+
signTxs(unsignedTxs: string[], partialSign?: boolean): Promise<string[]>;
|
|
637
658
|
/**
|
|
638
659
|
* Submits the signed transaction to the blockchain network.
|
|
639
660
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -91,8 +91,8 @@ declare class AppWallet implements ISigner, ISubmitter {
|
|
|
91
91
|
getNetworkId(): number;
|
|
92
92
|
getUsedAddress(accountIndex?: number, keyIndex?: number, addressType?: GetAddressType): Address;
|
|
93
93
|
getUnspentOutputs(accountIndex?: number, addressType?: GetAddressType): Promise<TransactionUnspentOutput[]>;
|
|
94
|
-
signData(address: string, payload: string, accountIndex?: number, keyIndex?: number): DataSignature
|
|
95
|
-
signTx(unsignedTx: string, partialSign?: boolean, accountIndex?: number, keyIndex?: number): string
|
|
94
|
+
signData(address: string, payload: string, accountIndex?: number, keyIndex?: number): Promise<DataSignature>;
|
|
95
|
+
signTx(unsignedTx: string, partialSign?: boolean, accountIndex?: number, keyIndex?: number): Promise<string>;
|
|
96
96
|
signTxSync(unsignedTx: string, partialSign?: boolean, accountIndex?: number, keyIndex?: number): string;
|
|
97
97
|
signTxs(unsignedTxs: string[], partialSign: boolean): Promise<string[]>;
|
|
98
98
|
submitTx(tx: string): Promise<string>;
|
|
@@ -433,8 +433,29 @@ declare class EmbeddedWallet extends WalletStaticMethods {
|
|
|
433
433
|
private readonly _networkId;
|
|
434
434
|
constructor(options: CreateEmbeddedWalletOptions);
|
|
435
435
|
getAccount(accountIndex?: number, keyIndex?: number): Account;
|
|
436
|
+
/**
|
|
437
|
+
* Get wallet network ID.
|
|
438
|
+
*
|
|
439
|
+
* @returns network ID
|
|
440
|
+
*/
|
|
436
441
|
getNetworkId(): number;
|
|
442
|
+
/**
|
|
443
|
+
* This endpoint utilizes the [CIP-8 - Message Signing](https://cips.cardano.org/cips/cip8/) to sign arbitrary data, to verify the data was signed by the owner of the private key.
|
|
444
|
+
*
|
|
445
|
+
* @param address - bech32 address to sign the data with
|
|
446
|
+
* @param payload - the data to be signed
|
|
447
|
+
* @param accountIndex account index (default: 0)
|
|
448
|
+
* @returns a signature
|
|
449
|
+
*/
|
|
437
450
|
signData(address: string, payload: string, accountIndex?: number, keyIndex?: number): DataSignature;
|
|
451
|
+
/**
|
|
452
|
+
* This endpoints sign the provided transaction (unsignedTx) with the private key of the owner.
|
|
453
|
+
*
|
|
454
|
+
* @param unsignedTx - a transaction in CBOR
|
|
455
|
+
* @param accountIndex account index (default: 0)
|
|
456
|
+
* @param keyIndex key index (default: 0)
|
|
457
|
+
* @returns VkeyWitness
|
|
458
|
+
*/
|
|
438
459
|
signTx(unsignedTx: string, accountIndex?: number, keyIndex?: number): VkeyWitness;
|
|
439
460
|
}
|
|
440
461
|
|
|
@@ -617,7 +638,7 @@ declare class MeshWallet implements IWallet {
|
|
|
617
638
|
* @param address - the address to use for signing (optional)
|
|
618
639
|
* @returns a signature
|
|
619
640
|
*/
|
|
620
|
-
signData(payload: string, address?: string): DataSignature
|
|
641
|
+
signData(payload: string, address?: string): Promise<DataSignature>;
|
|
621
642
|
/**
|
|
622
643
|
* Requests user to sign the provided transaction (tx). The wallet should ask the user for permission, and if given, try to sign the supplied body and return a signed transaction. partialSign should be true if the transaction provided requires multiple signatures.
|
|
623
644
|
*
|
|
@@ -625,7 +646,7 @@ declare class MeshWallet implements IWallet {
|
|
|
625
646
|
* @param partialSign - if the transaction is partially signed (default: false)
|
|
626
647
|
* @returns a signed transaction in CBOR
|
|
627
648
|
*/
|
|
628
|
-
signTx(unsignedTx: string, partialSign?: boolean): string
|
|
649
|
+
signTx(unsignedTx: string, partialSign?: boolean): Promise<string>;
|
|
629
650
|
/**
|
|
630
651
|
* Experimental feature - sign multiple transactions at once.
|
|
631
652
|
*
|
|
@@ -633,7 +654,7 @@ declare class MeshWallet implements IWallet {
|
|
|
633
654
|
* @param partialSign - if the transactions are signed partially
|
|
634
655
|
* @returns array of signed transactions CborHex string
|
|
635
656
|
*/
|
|
636
|
-
signTxs(unsignedTxs: string[], partialSign?: boolean): string[]
|
|
657
|
+
signTxs(unsignedTxs: string[], partialSign?: boolean): Promise<string[]>;
|
|
637
658
|
/**
|
|
638
659
|
* Submits the signed transaction to the blockchain network.
|
|
639
660
|
*
|
package/dist/index.js
CHANGED
|
@@ -720,9 +720,22 @@ var EmbeddedWallet = class extends WalletStaticMethods {
|
|
|
720
720
|
}
|
|
721
721
|
return _account;
|
|
722
722
|
}
|
|
723
|
+
/**
|
|
724
|
+
* Get wallet network ID.
|
|
725
|
+
*
|
|
726
|
+
* @returns network ID
|
|
727
|
+
*/
|
|
723
728
|
getNetworkId() {
|
|
724
729
|
return this._networkId;
|
|
725
730
|
}
|
|
731
|
+
/**
|
|
732
|
+
* This endpoint utilizes the [CIP-8 - Message Signing](https://cips.cardano.org/cips/cip8/) to sign arbitrary data, to verify the data was signed by the owner of the private key.
|
|
733
|
+
*
|
|
734
|
+
* @param address - bech32 address to sign the data with
|
|
735
|
+
* @param payload - the data to be signed
|
|
736
|
+
* @param accountIndex account index (default: 0)
|
|
737
|
+
* @returns a signature
|
|
738
|
+
*/
|
|
726
739
|
signData(address, payload, accountIndex = 0, keyIndex = 0) {
|
|
727
740
|
try {
|
|
728
741
|
const { baseAddress, enterpriseAddress, rewardAddress, paymentKey } = this.getAccount(accountIndex, keyIndex);
|
|
@@ -743,6 +756,14 @@ var EmbeddedWallet = class extends WalletStaticMethods {
|
|
|
743
756
|
);
|
|
744
757
|
}
|
|
745
758
|
}
|
|
759
|
+
/**
|
|
760
|
+
* This endpoints sign the provided transaction (unsignedTx) with the private key of the owner.
|
|
761
|
+
*
|
|
762
|
+
* @param unsignedTx - a transaction in CBOR
|
|
763
|
+
* @param accountIndex account index (default: 0)
|
|
764
|
+
* @param keyIndex key index (default: 0)
|
|
765
|
+
* @returns VkeyWitness
|
|
766
|
+
*/
|
|
746
767
|
signTx(unsignedTx, accountIndex = 0, keyIndex = 0) {
|
|
747
768
|
try {
|
|
748
769
|
const txHash = deserializeTxHash(resolveTxHash(unsignedTx));
|
|
@@ -856,7 +877,7 @@ var AppWallet = class {
|
|
|
856
877
|
);
|
|
857
878
|
return utxos.map((utxo) => toTxUnspentOutput(utxo));
|
|
858
879
|
}
|
|
859
|
-
signData(address, payload, accountIndex = 0, keyIndex = 0) {
|
|
880
|
+
async signData(address, payload, accountIndex = 0, keyIndex = 0) {
|
|
860
881
|
try {
|
|
861
882
|
return this._wallet.signData(address, payload, accountIndex, keyIndex);
|
|
862
883
|
} catch (error) {
|
|
@@ -865,7 +886,7 @@ var AppWallet = class {
|
|
|
865
886
|
);
|
|
866
887
|
}
|
|
867
888
|
}
|
|
868
|
-
signTx(unsignedTx, partialSign = false, accountIndex = 0, keyIndex = 0) {
|
|
889
|
+
async signTx(unsignedTx, partialSign = false, accountIndex = 0, keyIndex = 0) {
|
|
869
890
|
try {
|
|
870
891
|
const tx = deserializeTx2(unsignedTx);
|
|
871
892
|
if (!partialSign && tx.witnessSet().vkeys() !== void 0 && tx.witnessSet().vkeys().size() !== 0)
|
|
@@ -1457,7 +1478,7 @@ async function login({
|
|
|
1457
1478
|
serverUrl,
|
|
1458
1479
|
username
|
|
1459
1480
|
}) {
|
|
1460
|
-
const initAuthRes = await fetch(`${serverUrl}/init
|
|
1481
|
+
const initAuthRes = await fetch(`${serverUrl}/auth-init`, {
|
|
1461
1482
|
credentials: "include",
|
|
1462
1483
|
method: "POST",
|
|
1463
1484
|
headers: {
|
|
@@ -1475,9 +1496,9 @@ async function login({
|
|
|
1475
1496
|
errorCode: initAuth.errorCode
|
|
1476
1497
|
};
|
|
1477
1498
|
}
|
|
1478
|
-
const optionsJSON = initAuth.optionsJSON;
|
|
1499
|
+
const optionsJSON = initAuth.data.optionsJSON;
|
|
1479
1500
|
const authJSON = await startAuthentication({ optionsJSON });
|
|
1480
|
-
const verifyAuthRes = await fetch(`${serverUrl}/verify
|
|
1501
|
+
const verifyAuthRes = await fetch(`${serverUrl}/auth-verify`, {
|
|
1481
1502
|
credentials: "include",
|
|
1482
1503
|
method: "POST",
|
|
1483
1504
|
headers: {
|
|
@@ -1489,7 +1510,7 @@ async function login({
|
|
|
1489
1510
|
if (!verifyAuthRes.ok) {
|
|
1490
1511
|
return { success: false, error: verifyAuth.error };
|
|
1491
1512
|
}
|
|
1492
|
-
if (verifyAuth.verified) {
|
|
1513
|
+
if (verifyAuth.data.verified) {
|
|
1493
1514
|
return { success: true, authJSON };
|
|
1494
1515
|
} else {
|
|
1495
1516
|
return { success: false, error: "Failed to log in" };
|
|
@@ -1502,7 +1523,7 @@ async function register({
|
|
|
1502
1523
|
serverUrl,
|
|
1503
1524
|
username
|
|
1504
1525
|
}) {
|
|
1505
|
-
const initRegisterRes = await fetch(`${serverUrl}/init
|
|
1526
|
+
const initRegisterRes = await fetch(`${serverUrl}/register-init`, {
|
|
1506
1527
|
credentials: "include",
|
|
1507
1528
|
method: "POST",
|
|
1508
1529
|
headers: {
|
|
@@ -1520,9 +1541,9 @@ async function register({
|
|
|
1520
1541
|
errorCode: initRegister.errorCode
|
|
1521
1542
|
};
|
|
1522
1543
|
}
|
|
1523
|
-
const optionsJSON = initRegister.optionsJSON;
|
|
1544
|
+
const optionsJSON = initRegister.data.optionsJSON;
|
|
1524
1545
|
const registrationJSON = await startRegistration({ optionsJSON });
|
|
1525
|
-
const verifyResponse = await fetch(`${serverUrl}/verify
|
|
1546
|
+
const verifyResponse = await fetch(`${serverUrl}/register-verify`, {
|
|
1526
1547
|
credentials: "include",
|
|
1527
1548
|
method: "POST",
|
|
1528
1549
|
headers: {
|
|
@@ -1539,7 +1560,7 @@ async function register({
|
|
|
1539
1560
|
errorCode: verifyData.errorCode
|
|
1540
1561
|
};
|
|
1541
1562
|
}
|
|
1542
|
-
if (verifyData.verified) {
|
|
1563
|
+
if (verifyData.data.verified) {
|
|
1543
1564
|
console.log(`Successfully registered ${username}`);
|
|
1544
1565
|
return { success: true };
|
|
1545
1566
|
} else {
|
|
@@ -1555,7 +1576,7 @@ async function connect({
|
|
|
1555
1576
|
serverUrl
|
|
1556
1577
|
}) {
|
|
1557
1578
|
const responseRegister = await register({ serverUrl, username });
|
|
1558
|
-
if (responseRegister.success || responseRegister.errorCode == ERRORCODES.USEREXISTS) {
|
|
1579
|
+
if (responseRegister.success || responseRegister.error.errorCode == ERRORCODES.USEREXISTS) {
|
|
1559
1580
|
const loginRes = await handleLogin({ serverUrl, username });
|
|
1560
1581
|
if (loginRes.success && loginRes.authJSON) {
|
|
1561
1582
|
const wallet = await buildWalletFromPasskey(
|
|
@@ -1823,7 +1844,7 @@ var MeshWallet = class {
|
|
|
1823
1844
|
* @param address - the address to use for signing (optional)
|
|
1824
1845
|
* @returns a signature
|
|
1825
1846
|
*/
|
|
1826
|
-
signData(payload, address) {
|
|
1847
|
+
async signData(payload, address) {
|
|
1827
1848
|
if (!this._wallet) {
|
|
1828
1849
|
throw new Error(
|
|
1829
1850
|
"[MeshWallet] Read only wallet does not support signing data."
|
|
@@ -1846,7 +1867,7 @@ var MeshWallet = class {
|
|
|
1846
1867
|
* @param partialSign - if the transaction is partially signed (default: false)
|
|
1847
1868
|
* @returns a signed transaction in CBOR
|
|
1848
1869
|
*/
|
|
1849
|
-
signTx(unsignedTx, partialSign = false) {
|
|
1870
|
+
async signTx(unsignedTx, partialSign = false) {
|
|
1850
1871
|
if (!this._wallet) {
|
|
1851
1872
|
throw new Error(
|
|
1852
1873
|
"[MeshWallet] Read only wallet does not support signing data."
|
|
@@ -1872,7 +1893,7 @@ var MeshWallet = class {
|
|
|
1872
1893
|
* @param partialSign - if the transactions are signed partially
|
|
1873
1894
|
* @returns array of signed transactions CborHex string
|
|
1874
1895
|
*/
|
|
1875
|
-
signTxs(unsignedTxs, partialSign = false) {
|
|
1896
|
+
async signTxs(unsignedTxs, partialSign = false) {
|
|
1876
1897
|
if (!this._wallet) {
|
|
1877
1898
|
throw new Error(
|
|
1878
1899
|
"[MeshWallet] Read only wallet does not support signing data."
|
|
@@ -1880,7 +1901,7 @@ var MeshWallet = class {
|
|
|
1880
1901
|
}
|
|
1881
1902
|
const signedTxs = [];
|
|
1882
1903
|
for (const unsignedTx of unsignedTxs) {
|
|
1883
|
-
const signedTx = this.signTx(unsignedTx, partialSign);
|
|
1904
|
+
const signedTx = await this.signTx(unsignedTx, partialSign);
|
|
1884
1905
|
signedTxs.push(signedTx);
|
|
1885
1906
|
}
|
|
1886
1907
|
return signedTxs;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meshsdk/wallet",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.10",
|
|
4
4
|
"description": "Wallets - https://meshjs.dev/apis/wallets",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"browser": "./dist/index.js",
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"typescript": "^5.3.3"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@meshsdk/common": "1.8.
|
|
39
|
-
"@meshsdk/core-csl": "1.8.
|
|
40
|
-
"@meshsdk/core-cst": "1.8.
|
|
41
|
-
"@meshsdk/transaction": "1.8.
|
|
38
|
+
"@meshsdk/common": "1.8.10",
|
|
39
|
+
"@meshsdk/core-csl": "1.8.10",
|
|
40
|
+
"@meshsdk/core-cst": "1.8.10",
|
|
41
|
+
"@meshsdk/transaction": "1.8.10",
|
|
42
42
|
"@simplewebauthn/browser": "^13.0.0"
|
|
43
43
|
},
|
|
44
44
|
"prettier": "@meshsdk/configs/prettier",
|