@algorandfoundation/algokit-utils 10.0.0-alpha.43 → 10.0.0-alpha.44
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/algorand-client-transaction-creator.d.ts +9 -9
- package/algorand-client-transaction-sender.d.ts +9 -9
- package/app-client.d.ts +12 -12
- package/app-factory.d.ts +9 -9
- package/package.json +1 -1
- package/packages/crypto/src/index.js +5 -5
- package/packages/crypto/src/index.js.map +1 -1
- package/packages/crypto/src/index.mjs +5 -5
- package/packages/crypto/src/index.mjs.map +1 -1
|
@@ -348,8 +348,8 @@ declare class AlgorandClientTransactionCreator {
|
|
|
348
348
|
* @returns The application create transaction
|
|
349
349
|
*/
|
|
350
350
|
appCreate: (params: {
|
|
351
|
-
sender: SendingAddress;
|
|
352
351
|
signer?: (TransactionSigner | AddressWithTransactionSigner) | undefined;
|
|
352
|
+
sender: SendingAddress;
|
|
353
353
|
rekeyTo?: ReadableAddress | undefined;
|
|
354
354
|
note?: (Uint8Array | string) | undefined;
|
|
355
355
|
lease?: (Uint8Array | string) | undefined;
|
|
@@ -568,9 +568,8 @@ declare class AlgorandClientTransactionCreator {
|
|
|
568
568
|
* @returns The application ABI method create transaction
|
|
569
569
|
*/
|
|
570
570
|
appCreateMethodCall: (params: {
|
|
571
|
-
appId?: 0 | undefined;
|
|
572
|
-
sender: SendingAddress;
|
|
573
571
|
signer?: (TransactionSigner | AddressWithTransactionSigner) | undefined;
|
|
572
|
+
sender: SendingAddress;
|
|
574
573
|
rekeyTo?: ReadableAddress | undefined;
|
|
575
574
|
note?: (Uint8Array | string) | undefined;
|
|
576
575
|
lease?: (Uint8Array | string) | undefined;
|
|
@@ -580,6 +579,7 @@ declare class AlgorandClientTransactionCreator {
|
|
|
580
579
|
validityWindow?: number | bigint | undefined;
|
|
581
580
|
firstValidRound?: bigint | undefined;
|
|
582
581
|
lastValidRound?: bigint | undefined;
|
|
582
|
+
appId?: 0 | undefined;
|
|
583
583
|
onComplete?: OnApplicationComplete.NoOp | OnApplicationComplete.OptIn | OnApplicationComplete.CloseOut | OnApplicationComplete.UpdateApplication | OnApplicationComplete.DeleteApplication | undefined;
|
|
584
584
|
accountReferences?: ReadableAddress[] | undefined;
|
|
585
585
|
appReferences?: bigint[] | undefined;
|
|
@@ -649,9 +649,8 @@ declare class AlgorandClientTransactionCreator {
|
|
|
649
649
|
* @returns The application ABI method update transaction
|
|
650
650
|
*/
|
|
651
651
|
appUpdateMethodCall: (params: {
|
|
652
|
-
appId: bigint;
|
|
653
|
-
sender: SendingAddress;
|
|
654
652
|
signer?: (TransactionSigner | AddressWithTransactionSigner) | undefined;
|
|
653
|
+
sender: SendingAddress;
|
|
655
654
|
rekeyTo?: ReadableAddress | undefined;
|
|
656
655
|
note?: (Uint8Array | string) | undefined;
|
|
657
656
|
lease?: (Uint8Array | string) | undefined;
|
|
@@ -661,6 +660,7 @@ declare class AlgorandClientTransactionCreator {
|
|
|
661
660
|
validityWindow?: number | bigint | undefined;
|
|
662
661
|
firstValidRound?: bigint | undefined;
|
|
663
662
|
lastValidRound?: bigint | undefined;
|
|
663
|
+
appId: bigint;
|
|
664
664
|
onComplete?: OnApplicationComplete.UpdateApplication | undefined;
|
|
665
665
|
accountReferences?: ReadableAddress[] | undefined;
|
|
666
666
|
appReferences?: bigint[] | undefined;
|
|
@@ -721,9 +721,8 @@ declare class AlgorandClientTransactionCreator {
|
|
|
721
721
|
* @returns The application ABI method delete transaction
|
|
722
722
|
*/
|
|
723
723
|
appDeleteMethodCall: (params: {
|
|
724
|
-
appId: bigint;
|
|
725
|
-
sender: SendingAddress;
|
|
726
724
|
signer?: (TransactionSigner | AddressWithTransactionSigner) | undefined;
|
|
725
|
+
sender: SendingAddress;
|
|
727
726
|
rekeyTo?: ReadableAddress | undefined;
|
|
728
727
|
note?: (Uint8Array | string) | undefined;
|
|
729
728
|
lease?: (Uint8Array | string) | undefined;
|
|
@@ -733,6 +732,7 @@ declare class AlgorandClientTransactionCreator {
|
|
|
733
732
|
validityWindow?: number | bigint | undefined;
|
|
734
733
|
firstValidRound?: bigint | undefined;
|
|
735
734
|
lastValidRound?: bigint | undefined;
|
|
735
|
+
appId: bigint;
|
|
736
736
|
onComplete?: OnApplicationComplete.DeleteApplication | undefined;
|
|
737
737
|
accountReferences?: ReadableAddress[] | undefined;
|
|
738
738
|
appReferences?: bigint[] | undefined;
|
|
@@ -791,9 +791,8 @@ declare class AlgorandClientTransactionCreator {
|
|
|
791
791
|
* @returns The application ABI method call transaction
|
|
792
792
|
*/
|
|
793
793
|
appCallMethodCall: (params: {
|
|
794
|
-
appId: bigint;
|
|
795
|
-
sender: SendingAddress;
|
|
796
794
|
signer?: (TransactionSigner | AddressWithTransactionSigner) | undefined;
|
|
795
|
+
sender: SendingAddress;
|
|
797
796
|
rekeyTo?: ReadableAddress | undefined;
|
|
798
797
|
note?: (Uint8Array | string) | undefined;
|
|
799
798
|
lease?: (Uint8Array | string) | undefined;
|
|
@@ -803,6 +802,7 @@ declare class AlgorandClientTransactionCreator {
|
|
|
803
802
|
validityWindow?: number | bigint | undefined;
|
|
804
803
|
firstValidRound?: bigint | undefined;
|
|
805
804
|
lastValidRound?: bigint | undefined;
|
|
805
|
+
appId: bigint;
|
|
806
806
|
onComplete?: OnApplicationComplete.NoOp | OnApplicationComplete.OptIn | OnApplicationComplete.CloseOut | OnApplicationComplete.DeleteApplication | undefined;
|
|
807
807
|
accountReferences?: ReadableAddress[] | undefined;
|
|
808
808
|
appReferences?: bigint[] | undefined;
|
|
@@ -473,8 +473,8 @@ declare class AlgorandClientTransactionSender {
|
|
|
473
473
|
* @returns The result of the app create transaction and the transaction that was sent
|
|
474
474
|
*/
|
|
475
475
|
appCreate: (params: {
|
|
476
|
-
sender: SendingAddress;
|
|
477
476
|
signer?: (TransactionSigner | AddressWithTransactionSigner) | undefined;
|
|
477
|
+
sender: SendingAddress;
|
|
478
478
|
rekeyTo?: ReadableAddress | undefined;
|
|
479
479
|
note?: (Uint8Array | string) | undefined;
|
|
480
480
|
lease?: (Uint8Array | string) | undefined;
|
|
@@ -746,9 +746,8 @@ declare class AlgorandClientTransactionSender {
|
|
|
746
746
|
* @returns The result of the application ABI method create transaction and the transaction that was sent
|
|
747
747
|
*/
|
|
748
748
|
appCreateMethodCall: (params: {
|
|
749
|
-
appId?: 0 | undefined;
|
|
750
|
-
sender: SendingAddress;
|
|
751
749
|
signer?: (TransactionSigner | AddressWithTransactionSigner) | undefined;
|
|
750
|
+
sender: SendingAddress;
|
|
752
751
|
rekeyTo?: ReadableAddress | undefined;
|
|
753
752
|
note?: (Uint8Array | string) | undefined;
|
|
754
753
|
lease?: (Uint8Array | string) | undefined;
|
|
@@ -758,6 +757,7 @@ declare class AlgorandClientTransactionSender {
|
|
|
758
757
|
validityWindow?: number | bigint | undefined;
|
|
759
758
|
firstValidRound?: bigint | undefined;
|
|
760
759
|
lastValidRound?: bigint | undefined;
|
|
760
|
+
appId?: 0 | undefined;
|
|
761
761
|
onComplete?: OnApplicationComplete.NoOp | OnApplicationComplete.OptIn | OnApplicationComplete.CloseOut | OnApplicationComplete.UpdateApplication | OnApplicationComplete.DeleteApplication | undefined;
|
|
762
762
|
accountReferences?: ReadableAddress[] | undefined;
|
|
763
763
|
appReferences?: bigint[] | undefined;
|
|
@@ -834,9 +834,8 @@ declare class AlgorandClientTransactionSender {
|
|
|
834
834
|
* @returns The result of the application ABI method update transaction and the transaction that was sent
|
|
835
835
|
*/
|
|
836
836
|
appUpdateMethodCall: (params: {
|
|
837
|
-
appId: bigint;
|
|
838
|
-
sender: SendingAddress;
|
|
839
837
|
signer?: (TransactionSigner | AddressWithTransactionSigner) | undefined;
|
|
838
|
+
sender: SendingAddress;
|
|
840
839
|
rekeyTo?: ReadableAddress | undefined;
|
|
841
840
|
note?: (Uint8Array | string) | undefined;
|
|
842
841
|
lease?: (Uint8Array | string) | undefined;
|
|
@@ -846,6 +845,7 @@ declare class AlgorandClientTransactionSender {
|
|
|
846
845
|
validityWindow?: number | bigint | undefined;
|
|
847
846
|
firstValidRound?: bigint | undefined;
|
|
848
847
|
lastValidRound?: bigint | undefined;
|
|
848
|
+
appId: bigint;
|
|
849
849
|
onComplete?: OnApplicationComplete.UpdateApplication | undefined;
|
|
850
850
|
accountReferences?: ReadableAddress[] | undefined;
|
|
851
851
|
appReferences?: bigint[] | undefined;
|
|
@@ -913,9 +913,8 @@ declare class AlgorandClientTransactionSender {
|
|
|
913
913
|
* @returns The result of the application ABI method delete transaction and the transaction that was sent
|
|
914
914
|
*/
|
|
915
915
|
appDeleteMethodCall: (params: {
|
|
916
|
-
appId: bigint;
|
|
917
|
-
sender: SendingAddress;
|
|
918
916
|
signer?: (TransactionSigner | AddressWithTransactionSigner) | undefined;
|
|
917
|
+
sender: SendingAddress;
|
|
919
918
|
rekeyTo?: ReadableAddress | undefined;
|
|
920
919
|
note?: (Uint8Array | string) | undefined;
|
|
921
920
|
lease?: (Uint8Array | string) | undefined;
|
|
@@ -925,6 +924,7 @@ declare class AlgorandClientTransactionSender {
|
|
|
925
924
|
validityWindow?: number | bigint | undefined;
|
|
926
925
|
firstValidRound?: bigint | undefined;
|
|
927
926
|
lastValidRound?: bigint | undefined;
|
|
927
|
+
appId: bigint;
|
|
928
928
|
onComplete?: OnApplicationComplete.DeleteApplication | undefined;
|
|
929
929
|
accountReferences?: ReadableAddress[] | undefined;
|
|
930
930
|
appReferences?: bigint[] | undefined;
|
|
@@ -990,9 +990,8 @@ declare class AlgorandClientTransactionSender {
|
|
|
990
990
|
* @returns The result of the application ABI method call transaction and the transaction that was sent
|
|
991
991
|
*/
|
|
992
992
|
appCallMethodCall: (params: {
|
|
993
|
-
appId: bigint;
|
|
994
|
-
sender: SendingAddress;
|
|
995
993
|
signer?: (TransactionSigner | AddressWithTransactionSigner) | undefined;
|
|
994
|
+
sender: SendingAddress;
|
|
996
995
|
rekeyTo?: ReadableAddress | undefined;
|
|
997
996
|
note?: (Uint8Array | string) | undefined;
|
|
998
997
|
lease?: (Uint8Array | string) | undefined;
|
|
@@ -1002,6 +1001,7 @@ declare class AlgorandClientTransactionSender {
|
|
|
1002
1001
|
validityWindow?: number | bigint | undefined;
|
|
1003
1002
|
firstValidRound?: bigint | undefined;
|
|
1004
1003
|
lastValidRound?: bigint | undefined;
|
|
1004
|
+
appId: bigint;
|
|
1005
1005
|
onComplete?: OnApplicationComplete.NoOp | OnApplicationComplete.OptIn | OnApplicationComplete.CloseOut | OnApplicationComplete.DeleteApplication | undefined;
|
|
1006
1006
|
accountReferences?: ReadableAddress[] | undefined;
|
|
1007
1007
|
appReferences?: bigint[] | undefined;
|
package/app-client.d.ts
CHANGED
|
@@ -458,9 +458,9 @@ declare class AppClient {
|
|
|
458
458
|
signer: AddressWithTransactionSigner | TransactionSigner | undefined;
|
|
459
459
|
method: ABIMethod;
|
|
460
460
|
onComplete: OnApplicationComplete.UpdateApplication;
|
|
461
|
-
args: (Transaction |
|
|
462
|
-
sender: SendingAddress;
|
|
461
|
+
args: (Transaction | ABIValue | TransactionWithSigner | AppMethodCall<{
|
|
463
462
|
signer?: (TransactionSigner | AddressWithTransactionSigner) | undefined;
|
|
463
|
+
sender: SendingAddress;
|
|
464
464
|
rekeyTo?: ReadableAddress | undefined;
|
|
465
465
|
note?: (Uint8Array | string) | undefined;
|
|
466
466
|
lease?: (Uint8Array | string) | undefined;
|
|
@@ -511,7 +511,7 @@ declare class AppClient {
|
|
|
511
511
|
rejectVersion?: number | undefined;
|
|
512
512
|
approvalProgram: string | Uint8Array;
|
|
513
513
|
clearStateProgram: string | Uint8Array;
|
|
514
|
-
}> | AppMethodCall<AppMethodCallParams> | undefined)[] | undefined;
|
|
514
|
+
}> | AppMethodCall<AppMethodCallParams> | Promise<Transaction> | undefined)[] | undefined;
|
|
515
515
|
}>;
|
|
516
516
|
/**
|
|
517
517
|
* Return params for an opt-in ABI call
|
|
@@ -519,9 +519,8 @@ declare class AppClient {
|
|
|
519
519
|
* @returns The parameters which can be used to create an opt-in ABI method call
|
|
520
520
|
*/
|
|
521
521
|
optIn: (params: AppClientMethodCallParams) => Promise<{
|
|
522
|
-
appId: bigint;
|
|
523
|
-
sender: SendingAddress;
|
|
524
522
|
signer?: (TransactionSigner | AddressWithTransactionSigner) | undefined;
|
|
523
|
+
sender: SendingAddress;
|
|
525
524
|
rekeyTo?: ReadableAddress | undefined;
|
|
526
525
|
note?: (Uint8Array | string) | undefined;
|
|
527
526
|
lease?: (Uint8Array | string) | undefined;
|
|
@@ -531,6 +530,7 @@ declare class AppClient {
|
|
|
531
530
|
validityWindow?: number | bigint | undefined;
|
|
532
531
|
firstValidRound?: bigint | undefined;
|
|
533
532
|
lastValidRound?: bigint | undefined;
|
|
533
|
+
appId: bigint;
|
|
534
534
|
onComplete?: OnApplicationComplete.NoOp | OnApplicationComplete.OptIn | OnApplicationComplete.CloseOut | OnApplicationComplete.DeleteApplication | undefined;
|
|
535
535
|
accountReferences?: ReadableAddress[] | undefined;
|
|
536
536
|
appReferences?: bigint[] | undefined;
|
|
@@ -547,9 +547,8 @@ declare class AppClient {
|
|
|
547
547
|
* @returns The parameters which can be used to create a delete ABI method call
|
|
548
548
|
*/
|
|
549
549
|
delete: (params: AppClientMethodCallParams) => Promise<{
|
|
550
|
-
appId: bigint;
|
|
551
|
-
sender: SendingAddress;
|
|
552
550
|
signer?: (TransactionSigner | AddressWithTransactionSigner) | undefined;
|
|
551
|
+
sender: SendingAddress;
|
|
553
552
|
rekeyTo?: ReadableAddress | undefined;
|
|
554
553
|
note?: (Uint8Array | string) | undefined;
|
|
555
554
|
lease?: (Uint8Array | string) | undefined;
|
|
@@ -559,6 +558,7 @@ declare class AppClient {
|
|
|
559
558
|
validityWindow?: number | bigint | undefined;
|
|
560
559
|
firstValidRound?: bigint | undefined;
|
|
561
560
|
lastValidRound?: bigint | undefined;
|
|
561
|
+
appId: bigint;
|
|
562
562
|
onComplete?: OnApplicationComplete.DeleteApplication | undefined;
|
|
563
563
|
accountReferences?: ReadableAddress[] | undefined;
|
|
564
564
|
appReferences?: bigint[] | undefined;
|
|
@@ -574,9 +574,8 @@ declare class AppClient {
|
|
|
574
574
|
* @returns The parameters which can be used to create a close out ABI method call
|
|
575
575
|
*/
|
|
576
576
|
closeOut: (params: AppClientMethodCallParams) => Promise<{
|
|
577
|
-
appId: bigint;
|
|
578
|
-
sender: SendingAddress;
|
|
579
577
|
signer?: (TransactionSigner | AddressWithTransactionSigner) | undefined;
|
|
578
|
+
sender: SendingAddress;
|
|
580
579
|
rekeyTo?: ReadableAddress | undefined;
|
|
581
580
|
note?: (Uint8Array | string) | undefined;
|
|
582
581
|
lease?: (Uint8Array | string) | undefined;
|
|
@@ -586,6 +585,7 @@ declare class AppClient {
|
|
|
586
585
|
validityWindow?: number | bigint | undefined;
|
|
587
586
|
firstValidRound?: bigint | undefined;
|
|
588
587
|
lastValidRound?: bigint | undefined;
|
|
588
|
+
appId: bigint;
|
|
589
589
|
onComplete?: OnApplicationComplete.NoOp | OnApplicationComplete.OptIn | OnApplicationComplete.CloseOut | OnApplicationComplete.DeleteApplication | undefined;
|
|
590
590
|
accountReferences?: ReadableAddress[] | undefined;
|
|
591
591
|
appReferences?: bigint[] | undefined;
|
|
@@ -601,9 +601,8 @@ declare class AppClient {
|
|
|
601
601
|
* @returns The parameters which can be used to create an ABI method call
|
|
602
602
|
*/
|
|
603
603
|
call: (params: AppClientMethodCallParams & CallOnComplete) => Promise<{
|
|
604
|
-
appId: bigint;
|
|
605
|
-
sender: SendingAddress;
|
|
606
604
|
signer?: (TransactionSigner | AddressWithTransactionSigner) | undefined;
|
|
605
|
+
sender: SendingAddress;
|
|
607
606
|
rekeyTo?: ReadableAddress | undefined;
|
|
608
607
|
note?: (Uint8Array | string) | undefined;
|
|
609
608
|
lease?: (Uint8Array | string) | undefined;
|
|
@@ -613,6 +612,7 @@ declare class AppClient {
|
|
|
613
612
|
validityWindow?: number | bigint | undefined;
|
|
614
613
|
firstValidRound?: bigint | undefined;
|
|
615
614
|
lastValidRound?: bigint | undefined;
|
|
615
|
+
appId: bigint;
|
|
616
616
|
onComplete?: OnApplicationComplete.NoOp | OnApplicationComplete.OptIn | OnApplicationComplete.CloseOut | OnApplicationComplete.DeleteApplication | undefined;
|
|
617
617
|
accountReferences?: ReadableAddress[] | undefined;
|
|
618
618
|
appReferences?: bigint[] | undefined;
|
|
@@ -709,8 +709,8 @@ declare class AppClient {
|
|
|
709
709
|
update: (params: AppClientMethodCallParams & AppClientCompilationParams & SendParams) => Promise<{
|
|
710
710
|
compiledApproval?: CompiledTeal | undefined;
|
|
711
711
|
compiledClear?: CompiledTeal | undefined;
|
|
712
|
-
transactions: Transaction[];
|
|
713
712
|
confirmations: PendingTransactionResponse[];
|
|
713
|
+
transactions: Transaction[];
|
|
714
714
|
groupId: string | undefined;
|
|
715
715
|
txIds: string[];
|
|
716
716
|
returns?: ABIReturn[] | undefined;
|
package/app-factory.d.ts
CHANGED
|
@@ -211,9 +211,9 @@ declare class AppFactory {
|
|
|
211
211
|
sender: Address;
|
|
212
212
|
signer: AddressWithTransactionSigner | TransactionSigner | undefined;
|
|
213
213
|
method: ABIMethod;
|
|
214
|
-
args: (Transaction |
|
|
215
|
-
sender: SendingAddress;
|
|
214
|
+
args: (Transaction | ABIValue | TransactionWithSigner | AppMethodCall<{
|
|
216
215
|
signer?: (TransactionSigner | AddressWithTransactionSigner) | undefined;
|
|
216
|
+
sender: SendingAddress;
|
|
217
217
|
rekeyTo?: ReadableAddress | undefined;
|
|
218
218
|
note?: (Uint8Array | string) | undefined;
|
|
219
219
|
lease?: (Uint8Array | string) | undefined;
|
|
@@ -264,7 +264,7 @@ declare class AppFactory {
|
|
|
264
264
|
rejectVersion?: number | undefined;
|
|
265
265
|
approvalProgram: string | Uint8Array;
|
|
266
266
|
clearStateProgram: string | Uint8Array;
|
|
267
|
-
}> | AppMethodCall<AppMethodCallParams> | undefined)[] | undefined;
|
|
267
|
+
}> | AppMethodCall<AppMethodCallParams> | Promise<Transaction> | undefined)[] | undefined;
|
|
268
268
|
onComplete: OnApplicationComplete.NoOp | OnApplicationComplete.OptIn | OnApplicationComplete.CloseOut | OnApplicationComplete.UpdateApplication | OnApplicationComplete.DeleteApplication;
|
|
269
269
|
}>;
|
|
270
270
|
/** Return params for a deployment update ABI call */
|
|
@@ -293,9 +293,9 @@ declare class AppFactory {
|
|
|
293
293
|
sender: Address;
|
|
294
294
|
signer: AddressWithTransactionSigner | TransactionSigner | undefined;
|
|
295
295
|
method: ABIMethod;
|
|
296
|
-
args: (Transaction |
|
|
297
|
-
sender: SendingAddress;
|
|
296
|
+
args: (Transaction | ABIValue | TransactionWithSigner | AppMethodCall<{
|
|
298
297
|
signer?: (TransactionSigner | AddressWithTransactionSigner) | undefined;
|
|
298
|
+
sender: SendingAddress;
|
|
299
299
|
rekeyTo?: ReadableAddress | undefined;
|
|
300
300
|
note?: (Uint8Array | string) | undefined;
|
|
301
301
|
lease?: (Uint8Array | string) | undefined;
|
|
@@ -346,7 +346,7 @@ declare class AppFactory {
|
|
|
346
346
|
rejectVersion?: number | undefined;
|
|
347
347
|
approvalProgram: string | Uint8Array;
|
|
348
348
|
clearStateProgram: string | Uint8Array;
|
|
349
|
-
}> | AppMethodCall<AppMethodCallParams> | undefined)[] | undefined;
|
|
349
|
+
}> | AppMethodCall<AppMethodCallParams> | Promise<Transaction> | undefined)[] | undefined;
|
|
350
350
|
onComplete: OnApplicationComplete.UpdateApplication;
|
|
351
351
|
};
|
|
352
352
|
/** Return params for a deployment delete ABI call */
|
|
@@ -375,9 +375,9 @@ declare class AppFactory {
|
|
|
375
375
|
sender: Address;
|
|
376
376
|
signer: AddressWithTransactionSigner | TransactionSigner | undefined;
|
|
377
377
|
method: ABIMethod;
|
|
378
|
-
args: (Transaction |
|
|
379
|
-
sender: SendingAddress;
|
|
378
|
+
args: (Transaction | ABIValue | TransactionWithSigner | AppMethodCall<{
|
|
380
379
|
signer?: (TransactionSigner | AddressWithTransactionSigner) | undefined;
|
|
380
|
+
sender: SendingAddress;
|
|
381
381
|
rekeyTo?: ReadableAddress | undefined;
|
|
382
382
|
note?: (Uint8Array | string) | undefined;
|
|
383
383
|
lease?: (Uint8Array | string) | undefined;
|
|
@@ -428,7 +428,7 @@ declare class AppFactory {
|
|
|
428
428
|
rejectVersion?: number | undefined;
|
|
429
429
|
approvalProgram: string | Uint8Array;
|
|
430
430
|
clearStateProgram: string | Uint8Array;
|
|
431
|
-
}> | AppMethodCall<AppMethodCallParams> | undefined)[] | undefined;
|
|
431
|
+
}> | AppMethodCall<AppMethodCallParams> | Promise<Transaction> | undefined)[] | undefined;
|
|
432
432
|
onComplete: OnApplicationComplete.DeleteApplication;
|
|
433
433
|
};
|
|
434
434
|
bare: {
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"**"
|
|
7
7
|
],
|
|
8
8
|
"name": "@algorandfoundation/algokit-utils",
|
|
9
|
-
"version": "10.0.0-alpha.
|
|
9
|
+
"version": "10.0.0-alpha.44",
|
|
10
10
|
"private": false,
|
|
11
11
|
"description": "A set of core Algorand utilities written in TypeScript and released via npm that make it easier to build solutions on Algorand.",
|
|
12
12
|
"author": "Algorand Foundation",
|
|
@@ -29,8 +29,8 @@ const throwWrapUnwrapErrors = (operationError, wrapError, operationName) => {
|
|
|
29
29
|
throw new AggregateError([operationError, wrapError], `${operationName} failed and failed to re-wrap Ed25519 secret. Check both errors for details.`);
|
|
30
30
|
};
|
|
31
31
|
function rawSign(extendedSecretKey, data) {
|
|
32
|
-
const scalar = (0, _noble_curves_utils_js.bytesToNumberLE)(extendedSecretKey.
|
|
33
|
-
const kR = extendedSecretKey.
|
|
32
|
+
const scalar = (0, _noble_curves_utils_js.bytesToNumberLE)(extendedSecretKey.subarray(0, 32));
|
|
33
|
+
const kR = extendedSecretKey.subarray(32, 64);
|
|
34
34
|
const publicKey = rawPubkey(extendedSecretKey);
|
|
35
35
|
const r = (0, _noble_curves_abstract_modular_js.mod)((0, _noble_curves_utils_js.bytesToNumberLE)((0, _noble_hashes_sha2_js.sha512)(new Uint8Array([...kR, ...data]))), _noble_curves_ed25519_js.ed25519.Point.Fn.ORDER);
|
|
36
36
|
const R = _noble_curves_ed25519_js.ed25519.Point.BASE.multiply(r);
|
|
@@ -42,7 +42,7 @@ function rawSign(extendedSecretKey, data) {
|
|
|
42
42
|
return new Uint8Array([...R.toBytes(), ...(0, _noble_curves_utils_js.numberToBytesLE)(S, 32)]);
|
|
43
43
|
}
|
|
44
44
|
function rawPubkey(extendedSecretKey) {
|
|
45
|
-
const reducedScalar = (0, _noble_curves_abstract_modular_js.mod)((0, _noble_curves_utils_js.bytesToNumberLE)(extendedSecretKey.
|
|
45
|
+
const reducedScalar = (0, _noble_curves_abstract_modular_js.mod)((0, _noble_curves_utils_js.bytesToNumberLE)(extendedSecretKey.subarray(0, 32)) & (1n << 255n) - 1n, _noble_curves_ed25519_js.ed25519.Point.Fn.ORDER);
|
|
46
46
|
return _noble_curves_ed25519_js.ed25519.Point.BASE.multiply(reducedScalar).toBytes();
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
@@ -71,7 +71,7 @@ const nobleEd25519SigningKeyFromWrappedSecret = async (wrapUnwrap) => {
|
|
|
71
71
|
} else if ("unwrapHdExtendedPrivateKey" in wrapUnwrap) {
|
|
72
72
|
secret = await wrapUnwrap.unwrapHdExtendedPrivateKey();
|
|
73
73
|
assertEd25519SecretLength(secret, "HD extended key");
|
|
74
|
-
signature = rawSign(secret.
|
|
74
|
+
signature = rawSign(secret.subarray(0, 64), bytesToSign);
|
|
75
75
|
} else throw new Error("Invalid WrappedEd25519Secret: missing unwrap function");
|
|
76
76
|
} catch (error) {
|
|
77
77
|
signingError = error;
|
|
@@ -102,7 +102,7 @@ const nobleEd25519SigningKeyFromWrappedSecret = async (wrapUnwrap) => {
|
|
|
102
102
|
} else if ("unwrapHdExtendedPrivateKey" in wrapUnwrap) {
|
|
103
103
|
secret = await wrapUnwrap.unwrapHdExtendedPrivateKey();
|
|
104
104
|
assertEd25519SecretLength(secret, "HD extended key");
|
|
105
|
-
pubkey = rawPubkey(secret.
|
|
105
|
+
pubkey = rawPubkey(secret.subarray(0, 64));
|
|
106
106
|
} else throw new Error("Invalid WrappedEd25519Secret: missing unwrap function");
|
|
107
107
|
} catch (error) {
|
|
108
108
|
pubkeyError = error;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["ed25519","ed"],"sources":["../../../../packages/crypto/src/index.ts"],"sourcesContent":["import { Ed25519SigningKey, WrappedEd25519Seed } from './ed25519'\nimport * as ed from '@noble/ed25519'\nimport { WrappedHdExtendedPrivateKey } from './hd'\nimport { ed25519 } from '@noble/curves/ed25519.js'\nimport { sha512 } from '@noble/hashes/sha2.js'\nimport { bytesToNumberLE, numberToBytesLE } from '@noble/curves/utils.js'\nimport { mod } from '@noble/curves/abstract/modular.js'\n\nexport * from './ed25519'\nexport * from './hash'\nexport * from './hd'\n\nexport type WrappedEd25519Secret = WrappedEd25519Seed | WrappedHdExtendedPrivateKey\n\nconst ED25519_SEED_LENGTH = 32\nconst ED25519_EXTENDED_PRIVATE_KEY_LENGTH = 96\n\nconst assertEd25519SecretLength = (secret: Uint8Array, secretType: 'ed25519 seed' | 'HD extended key'): void => {\n let expectedLength: number\n switch (secretType) {\n case 'ed25519 seed':\n expectedLength = ED25519_SEED_LENGTH\n break\n case 'HD extended key':\n expectedLength = ED25519_EXTENDED_PRIVATE_KEY_LENGTH\n break\n default:\n throw new Error(`Unknown secret type: ${secretType}`)\n }\n\n if (secret.length !== expectedLength) {\n throw new Error(`Expected unwrapped ${secretType} to be ${expectedLength} bytes, got ${secret.length}.`)\n }\n}\n\nconst throwWrapUnwrapErrors = (operationError: unknown, wrapError: unknown, operationName: string): never => {\n throw new AggregateError(\n [operationError, wrapError],\n `${operationName} failed and failed to re-wrap Ed25519 secret. Check both errors for details.`,\n )\n}\n\nfunction rawSign(extendedSecretKey: Uint8Array, data: Uint8Array): Uint8Array {\n const scalar = bytesToNumberLE(extendedSecretKey.
|
|
1
|
+
{"version":3,"file":"index.js","names":["ed25519","ed"],"sources":["../../../../packages/crypto/src/index.ts"],"sourcesContent":["import { Ed25519SigningKey, WrappedEd25519Seed } from './ed25519'\nimport * as ed from '@noble/ed25519'\nimport { WrappedHdExtendedPrivateKey } from './hd'\nimport { ed25519 } from '@noble/curves/ed25519.js'\nimport { sha512 } from '@noble/hashes/sha2.js'\nimport { bytesToNumberLE, numberToBytesLE } from '@noble/curves/utils.js'\nimport { mod } from '@noble/curves/abstract/modular.js'\n\nexport * from './ed25519'\nexport * from './hash'\nexport * from './hd'\n\nexport type WrappedEd25519Secret = WrappedEd25519Seed | WrappedHdExtendedPrivateKey\n\nconst ED25519_SEED_LENGTH = 32\nconst ED25519_EXTENDED_PRIVATE_KEY_LENGTH = 96\n\nconst assertEd25519SecretLength = (secret: Uint8Array, secretType: 'ed25519 seed' | 'HD extended key'): void => {\n let expectedLength: number\n switch (secretType) {\n case 'ed25519 seed':\n expectedLength = ED25519_SEED_LENGTH\n break\n case 'HD extended key':\n expectedLength = ED25519_EXTENDED_PRIVATE_KEY_LENGTH\n break\n default:\n throw new Error(`Unknown secret type: ${secretType}`)\n }\n\n if (secret.length !== expectedLength) {\n throw new Error(`Expected unwrapped ${secretType} to be ${expectedLength} bytes, got ${secret.length}.`)\n }\n}\n\nconst throwWrapUnwrapErrors = (operationError: unknown, wrapError: unknown, operationName: string): never => {\n throw new AggregateError(\n [operationError, wrapError],\n `${operationName} failed and failed to re-wrap Ed25519 secret. Check both errors for details.`,\n )\n}\n\nfunction rawSign(extendedSecretKey: Uint8Array, data: Uint8Array): Uint8Array {\n const scalar = bytesToNumberLE(extendedSecretKey.subarray(0, 32))\n\n const kR = extendedSecretKey.subarray(32, 64)\n\n // (1): pubKey = scalar * G\n const publicKey = rawPubkey(extendedSecretKey)\n\n // (2): h = hash(kR || msg) mod q\n const rHash = sha512(new Uint8Array([...kR, ...data]))\n const r = mod(bytesToNumberLE(rHash), ed25519.Point.Fn.ORDER)\n\n // (4): R = r * G\n const R = ed25519.Point.BASE.multiply(r)\n\n // h = hash(R || pubKey || msg) mod q\n const hHash = sha512(new Uint8Array([...R.toBytes(), ...publicKey, ...data]))\n const h = mod(bytesToNumberLE(hHash), ed25519.Point.Fn.ORDER)\n\n // (5): S = (r + h * k) mod q\n const S = mod(r + h * scalar, ed25519.Point.Fn.ORDER)\n\n return new Uint8Array([...R.toBytes(), ...numberToBytesLE(S, 32)])\n}\n\nfunction rawPubkey(extendedSecretKey: Uint8Array): Uint8Array {\n const scalar = bytesToNumberLE(extendedSecretKey.subarray(0, 32))\n const clearedTopBitScalar = scalar & ((1n << 255n) - 1n)\n const reducedScalar = mod(clearedTopBitScalar, ed25519.Point.Fn.ORDER)\n\n // pubKey = scalar * G\n const publicKey = ed25519.Point.BASE.multiply(reducedScalar)\n return publicKey.toBytes()\n}\n\n/**\n * Creates an Ed25519 signing key from a wrapped secret using the @noble/ed25519 implementation.\n *\n * NOTE: This function will zero out the unwrapped secret after the wrap function is called.\n *\n * @param wrapUnwrap - The wrapped secret provider that unwraps and re-wraps the Ed25519 secret.\n * @returns A promise that resolves to an Ed25519 signing key containing the public key and raw signer.\n */\nexport const nobleEd25519SigningKeyFromWrappedSecret = async (wrapUnwrap: WrappedEd25519Secret): Promise<Ed25519SigningKey> => {\n let wrapFunction: () => Promise<void>\n if ('wrapEd25519Seed' in wrapUnwrap) {\n wrapFunction = wrapUnwrap.wrapEd25519Seed\n } else if ('wrapHdExtendedPrivateKey' in wrapUnwrap) {\n wrapFunction = wrapUnwrap.wrapHdExtendedPrivateKey\n } else {\n throw new Error('Invalid WrappedEd25519Secret: missing wrap function')\n }\n\n const signer = async (bytesToSign: Uint8Array): Promise<Uint8Array> => {\n let secret: Uint8Array | undefined = undefined\n let signature: Uint8Array | undefined = undefined\n let signingError: unknown\n let wrapError: unknown\n try {\n if ('unwrapEd25519Seed' in wrapUnwrap) {\n secret = await wrapUnwrap.unwrapEd25519Seed()\n assertEd25519SecretLength(secret, 'ed25519 seed')\n signature = await ed.signAsync(bytesToSign, secret)\n } else if ('unwrapHdExtendedPrivateKey' in wrapUnwrap) {\n secret = await wrapUnwrap.unwrapHdExtendedPrivateKey()\n assertEd25519SecretLength(secret, 'HD extended key')\n signature = rawSign(secret.subarray(0, 64), bytesToSign)\n } else {\n throw new Error('Invalid WrappedEd25519Secret: missing unwrap function')\n }\n } catch (error) {\n signingError = error\n } finally {\n try {\n await wrapFunction()\n } catch (error) {\n wrapError = error\n } finally {\n secret?.fill(0)\n }\n }\n\n if (signingError !== undefined && wrapError !== undefined) {\n throwWrapUnwrapErrors(signingError, wrapError, 'Signing')\n }\n\n if (signingError !== undefined) {\n throw signingError\n }\n\n if (wrapError !== undefined) {\n throw wrapError\n }\n\n if (signature === undefined) {\n throw new Error('Signing failed unexpectedly without an error.')\n }\n\n return signature\n }\n\n let pubkey: Uint8Array | undefined = undefined\n let pubkeyError: unknown\n let wrapError: unknown\n let secret: Uint8Array | undefined = undefined\n try {\n if ('unwrapEd25519Seed' in wrapUnwrap) {\n secret = await wrapUnwrap.unwrapEd25519Seed()\n assertEd25519SecretLength(secret, 'ed25519 seed')\n pubkey = await ed.getPublicKeyAsync(secret)\n } else if ('unwrapHdExtendedPrivateKey' in wrapUnwrap) {\n secret = await wrapUnwrap.unwrapHdExtendedPrivateKey()\n assertEd25519SecretLength(secret, 'HD extended key')\n pubkey = rawPubkey(secret.subarray(0, 64))\n } else {\n throw new Error('Invalid WrappedEd25519Secret: missing unwrap function')\n }\n } catch (error) {\n pubkeyError = error\n } finally {\n try {\n await wrapFunction()\n } catch (error) {\n wrapError = error\n } finally {\n secret?.fill(0)\n }\n }\n\n if (pubkeyError !== undefined && wrapError !== undefined) {\n throwWrapUnwrapErrors(pubkeyError, wrapError, 'Deriving Ed25519 public key')\n }\n\n if (pubkeyError !== undefined) {\n throw pubkeyError\n }\n\n if (wrapError !== undefined) {\n throw wrapError\n }\n\n if (pubkey === undefined) {\n throw new Error('Deriving Ed25519 public key failed unexpectedly without an error.')\n }\n\n return {\n ed25519Pubkey: pubkey,\n rawEd25519Signer: signer,\n }\n}\n\n/**\n * Creates an ed25519 signing key from a wrapped secret using the default ed25519 implementation (currently @noble/ed25519).\n * The implementation may change in the future. To explicitly use the @noble/ed25519 implementation, use `nobleEd25519SigningKeyFromWrappedSecret`.\n *\n * NOTE: This function will zero out the unwrapped secret after the wrap function is called.\n *\n * @param wrapUnwrap - The wrapped secret provider that unwraps and re-wraps the ed25519 secret.\n * @returns A promise that resolves to an ed25519 signing key with public key and raw signer.\n */\nexport const ed25519SigningKeyFromWrappedSecret = nobleEd25519SigningKeyFromWrappedSecret\n"],"mappings":"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"}
|
|
@@ -27,8 +27,8 @@ const throwWrapUnwrapErrors = (operationError, wrapError, operationName) => {
|
|
|
27
27
|
throw new AggregateError([operationError, wrapError], `${operationName} failed and failed to re-wrap Ed25519 secret. Check both errors for details.`);
|
|
28
28
|
};
|
|
29
29
|
function rawSign(extendedSecretKey, data) {
|
|
30
|
-
const scalar = bytesToNumberLE(extendedSecretKey.
|
|
31
|
-
const kR = extendedSecretKey.
|
|
30
|
+
const scalar = bytesToNumberLE(extendedSecretKey.subarray(0, 32));
|
|
31
|
+
const kR = extendedSecretKey.subarray(32, 64);
|
|
32
32
|
const publicKey = rawPubkey(extendedSecretKey);
|
|
33
33
|
const r = mod(bytesToNumberLE(sha512(new Uint8Array([...kR, ...data]))), ed25519.Point.Fn.ORDER);
|
|
34
34
|
const R = ed25519.Point.BASE.multiply(r);
|
|
@@ -40,7 +40,7 @@ function rawSign(extendedSecretKey, data) {
|
|
|
40
40
|
return new Uint8Array([...R.toBytes(), ...numberToBytesLE(S, 32)]);
|
|
41
41
|
}
|
|
42
42
|
function rawPubkey(extendedSecretKey) {
|
|
43
|
-
const reducedScalar = mod(bytesToNumberLE(extendedSecretKey.
|
|
43
|
+
const reducedScalar = mod(bytesToNumberLE(extendedSecretKey.subarray(0, 32)) & (1n << 255n) - 1n, ed25519.Point.Fn.ORDER);
|
|
44
44
|
return ed25519.Point.BASE.multiply(reducedScalar).toBytes();
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
@@ -69,7 +69,7 @@ const nobleEd25519SigningKeyFromWrappedSecret = async (wrapUnwrap) => {
|
|
|
69
69
|
} else if ("unwrapHdExtendedPrivateKey" in wrapUnwrap) {
|
|
70
70
|
secret = await wrapUnwrap.unwrapHdExtendedPrivateKey();
|
|
71
71
|
assertEd25519SecretLength(secret, "HD extended key");
|
|
72
|
-
signature = rawSign(secret.
|
|
72
|
+
signature = rawSign(secret.subarray(0, 64), bytesToSign);
|
|
73
73
|
} else throw new Error("Invalid WrappedEd25519Secret: missing unwrap function");
|
|
74
74
|
} catch (error) {
|
|
75
75
|
signingError = error;
|
|
@@ -100,7 +100,7 @@ const nobleEd25519SigningKeyFromWrappedSecret = async (wrapUnwrap) => {
|
|
|
100
100
|
} else if ("unwrapHdExtendedPrivateKey" in wrapUnwrap) {
|
|
101
101
|
secret = await wrapUnwrap.unwrapHdExtendedPrivateKey();
|
|
102
102
|
assertEd25519SecretLength(secret, "HD extended key");
|
|
103
|
-
pubkey = rawPubkey(secret.
|
|
103
|
+
pubkey = rawPubkey(secret.subarray(0, 64));
|
|
104
104
|
} else throw new Error("Invalid WrappedEd25519Secret: missing unwrap function");
|
|
105
105
|
} catch (error) {
|
|
106
106
|
pubkeyError = error;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../packages/crypto/src/index.ts"],"sourcesContent":["import { Ed25519SigningKey, WrappedEd25519Seed } from './ed25519'\nimport * as ed from '@noble/ed25519'\nimport { WrappedHdExtendedPrivateKey } from './hd'\nimport { ed25519 } from '@noble/curves/ed25519.js'\nimport { sha512 } from '@noble/hashes/sha2.js'\nimport { bytesToNumberLE, numberToBytesLE } from '@noble/curves/utils.js'\nimport { mod } from '@noble/curves/abstract/modular.js'\n\nexport * from './ed25519'\nexport * from './hash'\nexport * from './hd'\n\nexport type WrappedEd25519Secret = WrappedEd25519Seed | WrappedHdExtendedPrivateKey\n\nconst ED25519_SEED_LENGTH = 32\nconst ED25519_EXTENDED_PRIVATE_KEY_LENGTH = 96\n\nconst assertEd25519SecretLength = (secret: Uint8Array, secretType: 'ed25519 seed' | 'HD extended key'): void => {\n let expectedLength: number\n switch (secretType) {\n case 'ed25519 seed':\n expectedLength = ED25519_SEED_LENGTH\n break\n case 'HD extended key':\n expectedLength = ED25519_EXTENDED_PRIVATE_KEY_LENGTH\n break\n default:\n throw new Error(`Unknown secret type: ${secretType}`)\n }\n\n if (secret.length !== expectedLength) {\n throw new Error(`Expected unwrapped ${secretType} to be ${expectedLength} bytes, got ${secret.length}.`)\n }\n}\n\nconst throwWrapUnwrapErrors = (operationError: unknown, wrapError: unknown, operationName: string): never => {\n throw new AggregateError(\n [operationError, wrapError],\n `${operationName} failed and failed to re-wrap Ed25519 secret. Check both errors for details.`,\n )\n}\n\nfunction rawSign(extendedSecretKey: Uint8Array, data: Uint8Array): Uint8Array {\n const scalar = bytesToNumberLE(extendedSecretKey.
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../packages/crypto/src/index.ts"],"sourcesContent":["import { Ed25519SigningKey, WrappedEd25519Seed } from './ed25519'\nimport * as ed from '@noble/ed25519'\nimport { WrappedHdExtendedPrivateKey } from './hd'\nimport { ed25519 } from '@noble/curves/ed25519.js'\nimport { sha512 } from '@noble/hashes/sha2.js'\nimport { bytesToNumberLE, numberToBytesLE } from '@noble/curves/utils.js'\nimport { mod } from '@noble/curves/abstract/modular.js'\n\nexport * from './ed25519'\nexport * from './hash'\nexport * from './hd'\n\nexport type WrappedEd25519Secret = WrappedEd25519Seed | WrappedHdExtendedPrivateKey\n\nconst ED25519_SEED_LENGTH = 32\nconst ED25519_EXTENDED_PRIVATE_KEY_LENGTH = 96\n\nconst assertEd25519SecretLength = (secret: Uint8Array, secretType: 'ed25519 seed' | 'HD extended key'): void => {\n let expectedLength: number\n switch (secretType) {\n case 'ed25519 seed':\n expectedLength = ED25519_SEED_LENGTH\n break\n case 'HD extended key':\n expectedLength = ED25519_EXTENDED_PRIVATE_KEY_LENGTH\n break\n default:\n throw new Error(`Unknown secret type: ${secretType}`)\n }\n\n if (secret.length !== expectedLength) {\n throw new Error(`Expected unwrapped ${secretType} to be ${expectedLength} bytes, got ${secret.length}.`)\n }\n}\n\nconst throwWrapUnwrapErrors = (operationError: unknown, wrapError: unknown, operationName: string): never => {\n throw new AggregateError(\n [operationError, wrapError],\n `${operationName} failed and failed to re-wrap Ed25519 secret. Check both errors for details.`,\n )\n}\n\nfunction rawSign(extendedSecretKey: Uint8Array, data: Uint8Array): Uint8Array {\n const scalar = bytesToNumberLE(extendedSecretKey.subarray(0, 32))\n\n const kR = extendedSecretKey.subarray(32, 64)\n\n // (1): pubKey = scalar * G\n const publicKey = rawPubkey(extendedSecretKey)\n\n // (2): h = hash(kR || msg) mod q\n const rHash = sha512(new Uint8Array([...kR, ...data]))\n const r = mod(bytesToNumberLE(rHash), ed25519.Point.Fn.ORDER)\n\n // (4): R = r * G\n const R = ed25519.Point.BASE.multiply(r)\n\n // h = hash(R || pubKey || msg) mod q\n const hHash = sha512(new Uint8Array([...R.toBytes(), ...publicKey, ...data]))\n const h = mod(bytesToNumberLE(hHash), ed25519.Point.Fn.ORDER)\n\n // (5): S = (r + h * k) mod q\n const S = mod(r + h * scalar, ed25519.Point.Fn.ORDER)\n\n return new Uint8Array([...R.toBytes(), ...numberToBytesLE(S, 32)])\n}\n\nfunction rawPubkey(extendedSecretKey: Uint8Array): Uint8Array {\n const scalar = bytesToNumberLE(extendedSecretKey.subarray(0, 32))\n const clearedTopBitScalar = scalar & ((1n << 255n) - 1n)\n const reducedScalar = mod(clearedTopBitScalar, ed25519.Point.Fn.ORDER)\n\n // pubKey = scalar * G\n const publicKey = ed25519.Point.BASE.multiply(reducedScalar)\n return publicKey.toBytes()\n}\n\n/**\n * Creates an Ed25519 signing key from a wrapped secret using the @noble/ed25519 implementation.\n *\n * NOTE: This function will zero out the unwrapped secret after the wrap function is called.\n *\n * @param wrapUnwrap - The wrapped secret provider that unwraps and re-wraps the Ed25519 secret.\n * @returns A promise that resolves to an Ed25519 signing key containing the public key and raw signer.\n */\nexport const nobleEd25519SigningKeyFromWrappedSecret = async (wrapUnwrap: WrappedEd25519Secret): Promise<Ed25519SigningKey> => {\n let wrapFunction: () => Promise<void>\n if ('wrapEd25519Seed' in wrapUnwrap) {\n wrapFunction = wrapUnwrap.wrapEd25519Seed\n } else if ('wrapHdExtendedPrivateKey' in wrapUnwrap) {\n wrapFunction = wrapUnwrap.wrapHdExtendedPrivateKey\n } else {\n throw new Error('Invalid WrappedEd25519Secret: missing wrap function')\n }\n\n const signer = async (bytesToSign: Uint8Array): Promise<Uint8Array> => {\n let secret: Uint8Array | undefined = undefined\n let signature: Uint8Array | undefined = undefined\n let signingError: unknown\n let wrapError: unknown\n try {\n if ('unwrapEd25519Seed' in wrapUnwrap) {\n secret = await wrapUnwrap.unwrapEd25519Seed()\n assertEd25519SecretLength(secret, 'ed25519 seed')\n signature = await ed.signAsync(bytesToSign, secret)\n } else if ('unwrapHdExtendedPrivateKey' in wrapUnwrap) {\n secret = await wrapUnwrap.unwrapHdExtendedPrivateKey()\n assertEd25519SecretLength(secret, 'HD extended key')\n signature = rawSign(secret.subarray(0, 64), bytesToSign)\n } else {\n throw new Error('Invalid WrappedEd25519Secret: missing unwrap function')\n }\n } catch (error) {\n signingError = error\n } finally {\n try {\n await wrapFunction()\n } catch (error) {\n wrapError = error\n } finally {\n secret?.fill(0)\n }\n }\n\n if (signingError !== undefined && wrapError !== undefined) {\n throwWrapUnwrapErrors(signingError, wrapError, 'Signing')\n }\n\n if (signingError !== undefined) {\n throw signingError\n }\n\n if (wrapError !== undefined) {\n throw wrapError\n }\n\n if (signature === undefined) {\n throw new Error('Signing failed unexpectedly without an error.')\n }\n\n return signature\n }\n\n let pubkey: Uint8Array | undefined = undefined\n let pubkeyError: unknown\n let wrapError: unknown\n let secret: Uint8Array | undefined = undefined\n try {\n if ('unwrapEd25519Seed' in wrapUnwrap) {\n secret = await wrapUnwrap.unwrapEd25519Seed()\n assertEd25519SecretLength(secret, 'ed25519 seed')\n pubkey = await ed.getPublicKeyAsync(secret)\n } else if ('unwrapHdExtendedPrivateKey' in wrapUnwrap) {\n secret = await wrapUnwrap.unwrapHdExtendedPrivateKey()\n assertEd25519SecretLength(secret, 'HD extended key')\n pubkey = rawPubkey(secret.subarray(0, 64))\n } else {\n throw new Error('Invalid WrappedEd25519Secret: missing unwrap function')\n }\n } catch (error) {\n pubkeyError = error\n } finally {\n try {\n await wrapFunction()\n } catch (error) {\n wrapError = error\n } finally {\n secret?.fill(0)\n }\n }\n\n if (pubkeyError !== undefined && wrapError !== undefined) {\n throwWrapUnwrapErrors(pubkeyError, wrapError, 'Deriving Ed25519 public key')\n }\n\n if (pubkeyError !== undefined) {\n throw pubkeyError\n }\n\n if (wrapError !== undefined) {\n throw wrapError\n }\n\n if (pubkey === undefined) {\n throw new Error('Deriving Ed25519 public key failed unexpectedly without an error.')\n }\n\n return {\n ed25519Pubkey: pubkey,\n rawEd25519Signer: signer,\n }\n}\n\n/**\n * Creates an ed25519 signing key from a wrapped secret using the default ed25519 implementation (currently @noble/ed25519).\n * The implementation may change in the future. To explicitly use the @noble/ed25519 implementation, use `nobleEd25519SigningKeyFromWrappedSecret`.\n *\n * NOTE: This function will zero out the unwrapped secret after the wrap function is called.\n *\n * @param wrapUnwrap - The wrapped secret provider that unwraps and re-wraps the ed25519 secret.\n * @returns A promise that resolves to an ed25519 signing key with public key and raw signer.\n */\nexport const ed25519SigningKeyFromWrappedSecret = nobleEd25519SigningKeyFromWrappedSecret\n"],"mappings":"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"}
|