@dstorage-tech/dstorage-sdk 0.0.6 → 0.0.8

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.
Files changed (33) hide show
  1. package/dist/KeypairEncryptionAdapter-EOBRCIGP-5PFPNLLA.mjs +8 -0
  2. package/dist/{KeypairEncryptionAdapter-XUKCLRFU-AYDAZ2TZ.mjs → KeypairEncryptionAdapter-EOBRCIGP-FLPJIL26.mjs} +3 -3
  3. package/dist/{MnemonicEncryptionAdapter-RCHUETBP-M7NHGSHO.mjs → MnemonicEncryptionAdapter-S56YG63Q-B3F3TO3T.mjs} +3 -3
  4. package/dist/MnemonicEncryptionAdapter-S56YG63Q-POTD74UN.mjs +8 -0
  5. package/dist/{PasswordEncryptionAdapter-ECHND672-MUTHAMZY.mjs → PasswordEncryptionAdapter-B2UG7MWB-M4C3KJ4S.mjs} +3 -3
  6. package/dist/{PasswordEncryptionAdapter-ECHND672-3DEFO6FP.mjs → PasswordEncryptionAdapter-B2UG7MWB-QCSOIQJA.mjs} +3 -3
  7. package/dist/browser.d.mts +91 -8
  8. package/dist/browser.mjs +171 -67
  9. package/dist/{chunk-HDD6SUU4.mjs → chunk-42O7KEL4.mjs} +30 -11
  10. package/dist/{chunk-X4LEBNK6.mjs → chunk-5F3HZ2RJ.mjs} +30 -11
  11. package/dist/{chunk-6IAQVMSM.mjs → chunk-E73HFT6J.mjs} +5 -5
  12. package/dist/{chunk-UDYXMII2.mjs → chunk-EOPUNIUH.mjs} +5 -5
  13. package/dist/{chunk-O37NHERH.mjs → chunk-L6WCT64V.mjs} +4 -2
  14. package/dist/{chunk-4X5K43JF.mjs → chunk-M3F2LR3B.mjs} +3 -1
  15. package/dist/{chunk-JMPRZK5D.mjs → chunk-O6COTUD4.mjs} +3 -1
  16. package/dist/{chunk-BWLEAAFW.mjs → chunk-PCXBQRCO.mjs} +55 -2056
  17. package/dist/{chunk-OLGVVM5Y.mjs → chunk-QFJ2Y4XE.mjs} +5 -5
  18. package/dist/{chunk-Z6DUAI5B.mjs → chunk-XW4RZG2X.mjs} +5 -5
  19. package/dist/{contract-api-TJ7JPHZA-6FUBJ6DS.mjs → contract-api-NUY4UEKE-ZANT3ICG.mjs} +3 -3
  20. package/dist/{contract-api-AO4RGPLT-ENC72WCG.mjs → contract-api-P6YEDYQ6-2X6BMD64.mjs} +3 -3
  21. package/dist/{dist-INTAFXQ7.mjs → dist-AGNOIJI4.mjs} +3 -1
  22. package/dist/{dist-MOLWJ4Y7.mjs → dist-J4JUJ2J5.mjs} +3 -1
  23. package/dist/errors.d.mts +2 -0
  24. package/dist/errors.d.ts +2 -0
  25. package/dist/errors.js +10 -2054
  26. package/dist/errors.mjs +10 -2054
  27. package/dist/index.d.mts +108 -8
  28. package/dist/index.d.ts +108 -8
  29. package/dist/index.js +306 -2187
  30. package/dist/index.mjs +174 -70
  31. package/package.json +3 -2
  32. package/dist/KeypairEncryptionAdapter-XUKCLRFU-ERPYK5S4.mjs +0 -8
  33. package/dist/MnemonicEncryptionAdapter-RCHUETBP-DZPBGQG6.mjs +0 -8
package/dist/index.js CHANGED
@@ -33,2062 +33,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
33
33
  ));
34
34
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
35
 
36
- // ../../node_modules/@scure/bip39/wordlists/english.js
37
- var wordlist;
38
- var init_english = __esm({
39
- "../../node_modules/@scure/bip39/wordlists/english.js"() {
40
- "use strict";
41
- wordlist = `abandon
42
- ability
43
- able
44
- about
45
- above
46
- absent
47
- absorb
48
- abstract
49
- absurd
50
- abuse
51
- access
52
- accident
53
- account
54
- accuse
55
- achieve
56
- acid
57
- acoustic
58
- acquire
59
- across
60
- act
61
- action
62
- actor
63
- actress
64
- actual
65
- adapt
66
- add
67
- addict
68
- address
69
- adjust
70
- admit
71
- adult
72
- advance
73
- advice
74
- aerobic
75
- affair
76
- afford
77
- afraid
78
- again
79
- age
80
- agent
81
- agree
82
- ahead
83
- aim
84
- air
85
- airport
86
- aisle
87
- alarm
88
- album
89
- alcohol
90
- alert
91
- alien
92
- all
93
- alley
94
- allow
95
- almost
96
- alone
97
- alpha
98
- already
99
- also
100
- alter
101
- always
102
- amateur
103
- amazing
104
- among
105
- amount
106
- amused
107
- analyst
108
- anchor
109
- ancient
110
- anger
111
- angle
112
- angry
113
- animal
114
- ankle
115
- announce
116
- annual
117
- another
118
- answer
119
- antenna
120
- antique
121
- anxiety
122
- any
123
- apart
124
- apology
125
- appear
126
- apple
127
- approve
128
- april
129
- arch
130
- arctic
131
- area
132
- arena
133
- argue
134
- arm
135
- armed
136
- armor
137
- army
138
- around
139
- arrange
140
- arrest
141
- arrive
142
- arrow
143
- art
144
- artefact
145
- artist
146
- artwork
147
- ask
148
- aspect
149
- assault
150
- asset
151
- assist
152
- assume
153
- asthma
154
- athlete
155
- atom
156
- attack
157
- attend
158
- attitude
159
- attract
160
- auction
161
- audit
162
- august
163
- aunt
164
- author
165
- auto
166
- autumn
167
- average
168
- avocado
169
- avoid
170
- awake
171
- aware
172
- away
173
- awesome
174
- awful
175
- awkward
176
- axis
177
- baby
178
- bachelor
179
- bacon
180
- badge
181
- bag
182
- balance
183
- balcony
184
- ball
185
- bamboo
186
- banana
187
- banner
188
- bar
189
- barely
190
- bargain
191
- barrel
192
- base
193
- basic
194
- basket
195
- battle
196
- beach
197
- bean
198
- beauty
199
- because
200
- become
201
- beef
202
- before
203
- begin
204
- behave
205
- behind
206
- believe
207
- below
208
- belt
209
- bench
210
- benefit
211
- best
212
- betray
213
- better
214
- between
215
- beyond
216
- bicycle
217
- bid
218
- bike
219
- bind
220
- biology
221
- bird
222
- birth
223
- bitter
224
- black
225
- blade
226
- blame
227
- blanket
228
- blast
229
- bleak
230
- bless
231
- blind
232
- blood
233
- blossom
234
- blouse
235
- blue
236
- blur
237
- blush
238
- board
239
- boat
240
- body
241
- boil
242
- bomb
243
- bone
244
- bonus
245
- book
246
- boost
247
- border
248
- boring
249
- borrow
250
- boss
251
- bottom
252
- bounce
253
- box
254
- boy
255
- bracket
256
- brain
257
- brand
258
- brass
259
- brave
260
- bread
261
- breeze
262
- brick
263
- bridge
264
- brief
265
- bright
266
- bring
267
- brisk
268
- broccoli
269
- broken
270
- bronze
271
- broom
272
- brother
273
- brown
274
- brush
275
- bubble
276
- buddy
277
- budget
278
- buffalo
279
- build
280
- bulb
281
- bulk
282
- bullet
283
- bundle
284
- bunker
285
- burden
286
- burger
287
- burst
288
- bus
289
- business
290
- busy
291
- butter
292
- buyer
293
- buzz
294
- cabbage
295
- cabin
296
- cable
297
- cactus
298
- cage
299
- cake
300
- call
301
- calm
302
- camera
303
- camp
304
- can
305
- canal
306
- cancel
307
- candy
308
- cannon
309
- canoe
310
- canvas
311
- canyon
312
- capable
313
- capital
314
- captain
315
- car
316
- carbon
317
- card
318
- cargo
319
- carpet
320
- carry
321
- cart
322
- case
323
- cash
324
- casino
325
- castle
326
- casual
327
- cat
328
- catalog
329
- catch
330
- category
331
- cattle
332
- caught
333
- cause
334
- caution
335
- cave
336
- ceiling
337
- celery
338
- cement
339
- census
340
- century
341
- cereal
342
- certain
343
- chair
344
- chalk
345
- champion
346
- change
347
- chaos
348
- chapter
349
- charge
350
- chase
351
- chat
352
- cheap
353
- check
354
- cheese
355
- chef
356
- cherry
357
- chest
358
- chicken
359
- chief
360
- child
361
- chimney
362
- choice
363
- choose
364
- chronic
365
- chuckle
366
- chunk
367
- churn
368
- cigar
369
- cinnamon
370
- circle
371
- citizen
372
- city
373
- civil
374
- claim
375
- clap
376
- clarify
377
- claw
378
- clay
379
- clean
380
- clerk
381
- clever
382
- click
383
- client
384
- cliff
385
- climb
386
- clinic
387
- clip
388
- clock
389
- clog
390
- close
391
- cloth
392
- cloud
393
- clown
394
- club
395
- clump
396
- cluster
397
- clutch
398
- coach
399
- coast
400
- coconut
401
- code
402
- coffee
403
- coil
404
- coin
405
- collect
406
- color
407
- column
408
- combine
409
- come
410
- comfort
411
- comic
412
- common
413
- company
414
- concert
415
- conduct
416
- confirm
417
- congress
418
- connect
419
- consider
420
- control
421
- convince
422
- cook
423
- cool
424
- copper
425
- copy
426
- coral
427
- core
428
- corn
429
- correct
430
- cost
431
- cotton
432
- couch
433
- country
434
- couple
435
- course
436
- cousin
437
- cover
438
- coyote
439
- crack
440
- cradle
441
- craft
442
- cram
443
- crane
444
- crash
445
- crater
446
- crawl
447
- crazy
448
- cream
449
- credit
450
- creek
451
- crew
452
- cricket
453
- crime
454
- crisp
455
- critic
456
- crop
457
- cross
458
- crouch
459
- crowd
460
- crucial
461
- cruel
462
- cruise
463
- crumble
464
- crunch
465
- crush
466
- cry
467
- crystal
468
- cube
469
- culture
470
- cup
471
- cupboard
472
- curious
473
- current
474
- curtain
475
- curve
476
- cushion
477
- custom
478
- cute
479
- cycle
480
- dad
481
- damage
482
- damp
483
- dance
484
- danger
485
- daring
486
- dash
487
- daughter
488
- dawn
489
- day
490
- deal
491
- debate
492
- debris
493
- decade
494
- december
495
- decide
496
- decline
497
- decorate
498
- decrease
499
- deer
500
- defense
501
- define
502
- defy
503
- degree
504
- delay
505
- deliver
506
- demand
507
- demise
508
- denial
509
- dentist
510
- deny
511
- depart
512
- depend
513
- deposit
514
- depth
515
- deputy
516
- derive
517
- describe
518
- desert
519
- design
520
- desk
521
- despair
522
- destroy
523
- detail
524
- detect
525
- develop
526
- device
527
- devote
528
- diagram
529
- dial
530
- diamond
531
- diary
532
- dice
533
- diesel
534
- diet
535
- differ
536
- digital
537
- dignity
538
- dilemma
539
- dinner
540
- dinosaur
541
- direct
542
- dirt
543
- disagree
544
- discover
545
- disease
546
- dish
547
- dismiss
548
- disorder
549
- display
550
- distance
551
- divert
552
- divide
553
- divorce
554
- dizzy
555
- doctor
556
- document
557
- dog
558
- doll
559
- dolphin
560
- domain
561
- donate
562
- donkey
563
- donor
564
- door
565
- dose
566
- double
567
- dove
568
- draft
569
- dragon
570
- drama
571
- drastic
572
- draw
573
- dream
574
- dress
575
- drift
576
- drill
577
- drink
578
- drip
579
- drive
580
- drop
581
- drum
582
- dry
583
- duck
584
- dumb
585
- dune
586
- during
587
- dust
588
- dutch
589
- duty
590
- dwarf
591
- dynamic
592
- eager
593
- eagle
594
- early
595
- earn
596
- earth
597
- easily
598
- east
599
- easy
600
- echo
601
- ecology
602
- economy
603
- edge
604
- edit
605
- educate
606
- effort
607
- egg
608
- eight
609
- either
610
- elbow
611
- elder
612
- electric
613
- elegant
614
- element
615
- elephant
616
- elevator
617
- elite
618
- else
619
- embark
620
- embody
621
- embrace
622
- emerge
623
- emotion
624
- employ
625
- empower
626
- empty
627
- enable
628
- enact
629
- end
630
- endless
631
- endorse
632
- enemy
633
- energy
634
- enforce
635
- engage
636
- engine
637
- enhance
638
- enjoy
639
- enlist
640
- enough
641
- enrich
642
- enroll
643
- ensure
644
- enter
645
- entire
646
- entry
647
- envelope
648
- episode
649
- equal
650
- equip
651
- era
652
- erase
653
- erode
654
- erosion
655
- error
656
- erupt
657
- escape
658
- essay
659
- essence
660
- estate
661
- eternal
662
- ethics
663
- evidence
664
- evil
665
- evoke
666
- evolve
667
- exact
668
- example
669
- excess
670
- exchange
671
- excite
672
- exclude
673
- excuse
674
- execute
675
- exercise
676
- exhaust
677
- exhibit
678
- exile
679
- exist
680
- exit
681
- exotic
682
- expand
683
- expect
684
- expire
685
- explain
686
- expose
687
- express
688
- extend
689
- extra
690
- eye
691
- eyebrow
692
- fabric
693
- face
694
- faculty
695
- fade
696
- faint
697
- faith
698
- fall
699
- false
700
- fame
701
- family
702
- famous
703
- fan
704
- fancy
705
- fantasy
706
- farm
707
- fashion
708
- fat
709
- fatal
710
- father
711
- fatigue
712
- fault
713
- favorite
714
- feature
715
- february
716
- federal
717
- fee
718
- feed
719
- feel
720
- female
721
- fence
722
- festival
723
- fetch
724
- fever
725
- few
726
- fiber
727
- fiction
728
- field
729
- figure
730
- file
731
- film
732
- filter
733
- final
734
- find
735
- fine
736
- finger
737
- finish
738
- fire
739
- firm
740
- first
741
- fiscal
742
- fish
743
- fit
744
- fitness
745
- fix
746
- flag
747
- flame
748
- flash
749
- flat
750
- flavor
751
- flee
752
- flight
753
- flip
754
- float
755
- flock
756
- floor
757
- flower
758
- fluid
759
- flush
760
- fly
761
- foam
762
- focus
763
- fog
764
- foil
765
- fold
766
- follow
767
- food
768
- foot
769
- force
770
- forest
771
- forget
772
- fork
773
- fortune
774
- forum
775
- forward
776
- fossil
777
- foster
778
- found
779
- fox
780
- fragile
781
- frame
782
- frequent
783
- fresh
784
- friend
785
- fringe
786
- frog
787
- front
788
- frost
789
- frown
790
- frozen
791
- fruit
792
- fuel
793
- fun
794
- funny
795
- furnace
796
- fury
797
- future
798
- gadget
799
- gain
800
- galaxy
801
- gallery
802
- game
803
- gap
804
- garage
805
- garbage
806
- garden
807
- garlic
808
- garment
809
- gas
810
- gasp
811
- gate
812
- gather
813
- gauge
814
- gaze
815
- general
816
- genius
817
- genre
818
- gentle
819
- genuine
820
- gesture
821
- ghost
822
- giant
823
- gift
824
- giggle
825
- ginger
826
- giraffe
827
- girl
828
- give
829
- glad
830
- glance
831
- glare
832
- glass
833
- glide
834
- glimpse
835
- globe
836
- gloom
837
- glory
838
- glove
839
- glow
840
- glue
841
- goat
842
- goddess
843
- gold
844
- good
845
- goose
846
- gorilla
847
- gospel
848
- gossip
849
- govern
850
- gown
851
- grab
852
- grace
853
- grain
854
- grant
855
- grape
856
- grass
857
- gravity
858
- great
859
- green
860
- grid
861
- grief
862
- grit
863
- grocery
864
- group
865
- grow
866
- grunt
867
- guard
868
- guess
869
- guide
870
- guilt
871
- guitar
872
- gun
873
- gym
874
- habit
875
- hair
876
- half
877
- hammer
878
- hamster
879
- hand
880
- happy
881
- harbor
882
- hard
883
- harsh
884
- harvest
885
- hat
886
- have
887
- hawk
888
- hazard
889
- head
890
- health
891
- heart
892
- heavy
893
- hedgehog
894
- height
895
- hello
896
- helmet
897
- help
898
- hen
899
- hero
900
- hidden
901
- high
902
- hill
903
- hint
904
- hip
905
- hire
906
- history
907
- hobby
908
- hockey
909
- hold
910
- hole
911
- holiday
912
- hollow
913
- home
914
- honey
915
- hood
916
- hope
917
- horn
918
- horror
919
- horse
920
- hospital
921
- host
922
- hotel
923
- hour
924
- hover
925
- hub
926
- huge
927
- human
928
- humble
929
- humor
930
- hundred
931
- hungry
932
- hunt
933
- hurdle
934
- hurry
935
- hurt
936
- husband
937
- hybrid
938
- ice
939
- icon
940
- idea
941
- identify
942
- idle
943
- ignore
944
- ill
945
- illegal
946
- illness
947
- image
948
- imitate
949
- immense
950
- immune
951
- impact
952
- impose
953
- improve
954
- impulse
955
- inch
956
- include
957
- income
958
- increase
959
- index
960
- indicate
961
- indoor
962
- industry
963
- infant
964
- inflict
965
- inform
966
- inhale
967
- inherit
968
- initial
969
- inject
970
- injury
971
- inmate
972
- inner
973
- innocent
974
- input
975
- inquiry
976
- insane
977
- insect
978
- inside
979
- inspire
980
- install
981
- intact
982
- interest
983
- into
984
- invest
985
- invite
986
- involve
987
- iron
988
- island
989
- isolate
990
- issue
991
- item
992
- ivory
993
- jacket
994
- jaguar
995
- jar
996
- jazz
997
- jealous
998
- jeans
999
- jelly
1000
- jewel
1001
- job
1002
- join
1003
- joke
1004
- journey
1005
- joy
1006
- judge
1007
- juice
1008
- jump
1009
- jungle
1010
- junior
1011
- junk
1012
- just
1013
- kangaroo
1014
- keen
1015
- keep
1016
- ketchup
1017
- key
1018
- kick
1019
- kid
1020
- kidney
1021
- kind
1022
- kingdom
1023
- kiss
1024
- kit
1025
- kitchen
1026
- kite
1027
- kitten
1028
- kiwi
1029
- knee
1030
- knife
1031
- knock
1032
- know
1033
- lab
1034
- label
1035
- labor
1036
- ladder
1037
- lady
1038
- lake
1039
- lamp
1040
- language
1041
- laptop
1042
- large
1043
- later
1044
- latin
1045
- laugh
1046
- laundry
1047
- lava
1048
- law
1049
- lawn
1050
- lawsuit
1051
- layer
1052
- lazy
1053
- leader
1054
- leaf
1055
- learn
1056
- leave
1057
- lecture
1058
- left
1059
- leg
1060
- legal
1061
- legend
1062
- leisure
1063
- lemon
1064
- lend
1065
- length
1066
- lens
1067
- leopard
1068
- lesson
1069
- letter
1070
- level
1071
- liar
1072
- liberty
1073
- library
1074
- license
1075
- life
1076
- lift
1077
- light
1078
- like
1079
- limb
1080
- limit
1081
- link
1082
- lion
1083
- liquid
1084
- list
1085
- little
1086
- live
1087
- lizard
1088
- load
1089
- loan
1090
- lobster
1091
- local
1092
- lock
1093
- logic
1094
- lonely
1095
- long
1096
- loop
1097
- lottery
1098
- loud
1099
- lounge
1100
- love
1101
- loyal
1102
- lucky
1103
- luggage
1104
- lumber
1105
- lunar
1106
- lunch
1107
- luxury
1108
- lyrics
1109
- machine
1110
- mad
1111
- magic
1112
- magnet
1113
- maid
1114
- mail
1115
- main
1116
- major
1117
- make
1118
- mammal
1119
- man
1120
- manage
1121
- mandate
1122
- mango
1123
- mansion
1124
- manual
1125
- maple
1126
- marble
1127
- march
1128
- margin
1129
- marine
1130
- market
1131
- marriage
1132
- mask
1133
- mass
1134
- master
1135
- match
1136
- material
1137
- math
1138
- matrix
1139
- matter
1140
- maximum
1141
- maze
1142
- meadow
1143
- mean
1144
- measure
1145
- meat
1146
- mechanic
1147
- medal
1148
- media
1149
- melody
1150
- melt
1151
- member
1152
- memory
1153
- mention
1154
- menu
1155
- mercy
1156
- merge
1157
- merit
1158
- merry
1159
- mesh
1160
- message
1161
- metal
1162
- method
1163
- middle
1164
- midnight
1165
- milk
1166
- million
1167
- mimic
1168
- mind
1169
- minimum
1170
- minor
1171
- minute
1172
- miracle
1173
- mirror
1174
- misery
1175
- miss
1176
- mistake
1177
- mix
1178
- mixed
1179
- mixture
1180
- mobile
1181
- model
1182
- modify
1183
- mom
1184
- moment
1185
- monitor
1186
- monkey
1187
- monster
1188
- month
1189
- moon
1190
- moral
1191
- more
1192
- morning
1193
- mosquito
1194
- mother
1195
- motion
1196
- motor
1197
- mountain
1198
- mouse
1199
- move
1200
- movie
1201
- much
1202
- muffin
1203
- mule
1204
- multiply
1205
- muscle
1206
- museum
1207
- mushroom
1208
- music
1209
- must
1210
- mutual
1211
- myself
1212
- mystery
1213
- myth
1214
- naive
1215
- name
1216
- napkin
1217
- narrow
1218
- nasty
1219
- nation
1220
- nature
1221
- near
1222
- neck
1223
- need
1224
- negative
1225
- neglect
1226
- neither
1227
- nephew
1228
- nerve
1229
- nest
1230
- net
1231
- network
1232
- neutral
1233
- never
1234
- news
1235
- next
1236
- nice
1237
- night
1238
- noble
1239
- noise
1240
- nominee
1241
- noodle
1242
- normal
1243
- north
1244
- nose
1245
- notable
1246
- note
1247
- nothing
1248
- notice
1249
- novel
1250
- now
1251
- nuclear
1252
- number
1253
- nurse
1254
- nut
1255
- oak
1256
- obey
1257
- object
1258
- oblige
1259
- obscure
1260
- observe
1261
- obtain
1262
- obvious
1263
- occur
1264
- ocean
1265
- october
1266
- odor
1267
- off
1268
- offer
1269
- office
1270
- often
1271
- oil
1272
- okay
1273
- old
1274
- olive
1275
- olympic
1276
- omit
1277
- once
1278
- one
1279
- onion
1280
- online
1281
- only
1282
- open
1283
- opera
1284
- opinion
1285
- oppose
1286
- option
1287
- orange
1288
- orbit
1289
- orchard
1290
- order
1291
- ordinary
1292
- organ
1293
- orient
1294
- original
1295
- orphan
1296
- ostrich
1297
- other
1298
- outdoor
1299
- outer
1300
- output
1301
- outside
1302
- oval
1303
- oven
1304
- over
1305
- own
1306
- owner
1307
- oxygen
1308
- oyster
1309
- ozone
1310
- pact
1311
- paddle
1312
- page
1313
- pair
1314
- palace
1315
- palm
1316
- panda
1317
- panel
1318
- panic
1319
- panther
1320
- paper
1321
- parade
1322
- parent
1323
- park
1324
- parrot
1325
- party
1326
- pass
1327
- patch
1328
- path
1329
- patient
1330
- patrol
1331
- pattern
1332
- pause
1333
- pave
1334
- payment
1335
- peace
1336
- peanut
1337
- pear
1338
- peasant
1339
- pelican
1340
- pen
1341
- penalty
1342
- pencil
1343
- people
1344
- pepper
1345
- perfect
1346
- permit
1347
- person
1348
- pet
1349
- phone
1350
- photo
1351
- phrase
1352
- physical
1353
- piano
1354
- picnic
1355
- picture
1356
- piece
1357
- pig
1358
- pigeon
1359
- pill
1360
- pilot
1361
- pink
1362
- pioneer
1363
- pipe
1364
- pistol
1365
- pitch
1366
- pizza
1367
- place
1368
- planet
1369
- plastic
1370
- plate
1371
- play
1372
- please
1373
- pledge
1374
- pluck
1375
- plug
1376
- plunge
1377
- poem
1378
- poet
1379
- point
1380
- polar
1381
- pole
1382
- police
1383
- pond
1384
- pony
1385
- pool
1386
- popular
1387
- portion
1388
- position
1389
- possible
1390
- post
1391
- potato
1392
- pottery
1393
- poverty
1394
- powder
1395
- power
1396
- practice
1397
- praise
1398
- predict
1399
- prefer
1400
- prepare
1401
- present
1402
- pretty
1403
- prevent
1404
- price
1405
- pride
1406
- primary
1407
- print
1408
- priority
1409
- prison
1410
- private
1411
- prize
1412
- problem
1413
- process
1414
- produce
1415
- profit
1416
- program
1417
- project
1418
- promote
1419
- proof
1420
- property
1421
- prosper
1422
- protect
1423
- proud
1424
- provide
1425
- public
1426
- pudding
1427
- pull
1428
- pulp
1429
- pulse
1430
- pumpkin
1431
- punch
1432
- pupil
1433
- puppy
1434
- purchase
1435
- purity
1436
- purpose
1437
- purse
1438
- push
1439
- put
1440
- puzzle
1441
- pyramid
1442
- quality
1443
- quantum
1444
- quarter
1445
- question
1446
- quick
1447
- quit
1448
- quiz
1449
- quote
1450
- rabbit
1451
- raccoon
1452
- race
1453
- rack
1454
- radar
1455
- radio
1456
- rail
1457
- rain
1458
- raise
1459
- rally
1460
- ramp
1461
- ranch
1462
- random
1463
- range
1464
- rapid
1465
- rare
1466
- rate
1467
- rather
1468
- raven
1469
- raw
1470
- razor
1471
- ready
1472
- real
1473
- reason
1474
- rebel
1475
- rebuild
1476
- recall
1477
- receive
1478
- recipe
1479
- record
1480
- recycle
1481
- reduce
1482
- reflect
1483
- reform
1484
- refuse
1485
- region
1486
- regret
1487
- regular
1488
- reject
1489
- relax
1490
- release
1491
- relief
1492
- rely
1493
- remain
1494
- remember
1495
- remind
1496
- remove
1497
- render
1498
- renew
1499
- rent
1500
- reopen
1501
- repair
1502
- repeat
1503
- replace
1504
- report
1505
- require
1506
- rescue
1507
- resemble
1508
- resist
1509
- resource
1510
- response
1511
- result
1512
- retire
1513
- retreat
1514
- return
1515
- reunion
1516
- reveal
1517
- review
1518
- reward
1519
- rhythm
1520
- rib
1521
- ribbon
1522
- rice
1523
- rich
1524
- ride
1525
- ridge
1526
- rifle
1527
- right
1528
- rigid
1529
- ring
1530
- riot
1531
- ripple
1532
- risk
1533
- ritual
1534
- rival
1535
- river
1536
- road
1537
- roast
1538
- robot
1539
- robust
1540
- rocket
1541
- romance
1542
- roof
1543
- rookie
1544
- room
1545
- rose
1546
- rotate
1547
- rough
1548
- round
1549
- route
1550
- royal
1551
- rubber
1552
- rude
1553
- rug
1554
- rule
1555
- run
1556
- runway
1557
- rural
1558
- sad
1559
- saddle
1560
- sadness
1561
- safe
1562
- sail
1563
- salad
1564
- salmon
1565
- salon
1566
- salt
1567
- salute
1568
- same
1569
- sample
1570
- sand
1571
- satisfy
1572
- satoshi
1573
- sauce
1574
- sausage
1575
- save
1576
- say
1577
- scale
1578
- scan
1579
- scare
1580
- scatter
1581
- scene
1582
- scheme
1583
- school
1584
- science
1585
- scissors
1586
- scorpion
1587
- scout
1588
- scrap
1589
- screen
1590
- script
1591
- scrub
1592
- sea
1593
- search
1594
- season
1595
- seat
1596
- second
1597
- secret
1598
- section
1599
- security
1600
- seed
1601
- seek
1602
- segment
1603
- select
1604
- sell
1605
- seminar
1606
- senior
1607
- sense
1608
- sentence
1609
- series
1610
- service
1611
- session
1612
- settle
1613
- setup
1614
- seven
1615
- shadow
1616
- shaft
1617
- shallow
1618
- share
1619
- shed
1620
- shell
1621
- sheriff
1622
- shield
1623
- shift
1624
- shine
1625
- ship
1626
- shiver
1627
- shock
1628
- shoe
1629
- shoot
1630
- shop
1631
- short
1632
- shoulder
1633
- shove
1634
- shrimp
1635
- shrug
1636
- shuffle
1637
- shy
1638
- sibling
1639
- sick
1640
- side
1641
- siege
1642
- sight
1643
- sign
1644
- silent
1645
- silk
1646
- silly
1647
- silver
1648
- similar
1649
- simple
1650
- since
1651
- sing
1652
- siren
1653
- sister
1654
- situate
1655
- six
1656
- size
1657
- skate
1658
- sketch
1659
- ski
1660
- skill
1661
- skin
1662
- skirt
1663
- skull
1664
- slab
1665
- slam
1666
- sleep
1667
- slender
1668
- slice
1669
- slide
1670
- slight
1671
- slim
1672
- slogan
1673
- slot
1674
- slow
1675
- slush
1676
- small
1677
- smart
1678
- smile
1679
- smoke
1680
- smooth
1681
- snack
1682
- snake
1683
- snap
1684
- sniff
1685
- snow
1686
- soap
1687
- soccer
1688
- social
1689
- sock
1690
- soda
1691
- soft
1692
- solar
1693
- soldier
1694
- solid
1695
- solution
1696
- solve
1697
- someone
1698
- song
1699
- soon
1700
- sorry
1701
- sort
1702
- soul
1703
- sound
1704
- soup
1705
- source
1706
- south
1707
- space
1708
- spare
1709
- spatial
1710
- spawn
1711
- speak
1712
- special
1713
- speed
1714
- spell
1715
- spend
1716
- sphere
1717
- spice
1718
- spider
1719
- spike
1720
- spin
1721
- spirit
1722
- split
1723
- spoil
1724
- sponsor
1725
- spoon
1726
- sport
1727
- spot
1728
- spray
1729
- spread
1730
- spring
1731
- spy
1732
- square
1733
- squeeze
1734
- squirrel
1735
- stable
1736
- stadium
1737
- staff
1738
- stage
1739
- stairs
1740
- stamp
1741
- stand
1742
- start
1743
- state
1744
- stay
1745
- steak
1746
- steel
1747
- stem
1748
- step
1749
- stereo
1750
- stick
1751
- still
1752
- sting
1753
- stock
1754
- stomach
1755
- stone
1756
- stool
1757
- story
1758
- stove
1759
- strategy
1760
- street
1761
- strike
1762
- strong
1763
- struggle
1764
- student
1765
- stuff
1766
- stumble
1767
- style
1768
- subject
1769
- submit
1770
- subway
1771
- success
1772
- such
1773
- sudden
1774
- suffer
1775
- sugar
1776
- suggest
1777
- suit
1778
- summer
1779
- sun
1780
- sunny
1781
- sunset
1782
- super
1783
- supply
1784
- supreme
1785
- sure
1786
- surface
1787
- surge
1788
- surprise
1789
- surround
1790
- survey
1791
- suspect
1792
- sustain
1793
- swallow
1794
- swamp
1795
- swap
1796
- swarm
1797
- swear
1798
- sweet
1799
- swift
1800
- swim
1801
- swing
1802
- switch
1803
- sword
1804
- symbol
1805
- symptom
1806
- syrup
1807
- system
1808
- table
1809
- tackle
1810
- tag
1811
- tail
1812
- talent
1813
- talk
1814
- tank
1815
- tape
1816
- target
1817
- task
1818
- taste
1819
- tattoo
1820
- taxi
1821
- teach
1822
- team
1823
- tell
1824
- ten
1825
- tenant
1826
- tennis
1827
- tent
1828
- term
1829
- test
1830
- text
1831
- thank
1832
- that
1833
- theme
1834
- then
1835
- theory
1836
- there
1837
- they
1838
- thing
1839
- this
1840
- thought
1841
- three
1842
- thrive
1843
- throw
1844
- thumb
1845
- thunder
1846
- ticket
1847
- tide
1848
- tiger
1849
- tilt
1850
- timber
1851
- time
1852
- tiny
1853
- tip
1854
- tired
1855
- tissue
1856
- title
1857
- toast
1858
- tobacco
1859
- today
1860
- toddler
1861
- toe
1862
- together
1863
- toilet
1864
- token
1865
- tomato
1866
- tomorrow
1867
- tone
1868
- tongue
1869
- tonight
1870
- tool
1871
- tooth
1872
- top
1873
- topic
1874
- topple
1875
- torch
1876
- tornado
1877
- tortoise
1878
- toss
1879
- total
1880
- tourist
1881
- toward
1882
- tower
1883
- town
1884
- toy
1885
- track
1886
- trade
1887
- traffic
1888
- tragic
1889
- train
1890
- transfer
1891
- trap
1892
- trash
1893
- travel
1894
- tray
1895
- treat
1896
- tree
1897
- trend
1898
- trial
1899
- tribe
1900
- trick
1901
- trigger
1902
- trim
1903
- trip
1904
- trophy
1905
- trouble
1906
- truck
1907
- true
1908
- truly
1909
- trumpet
1910
- trust
1911
- truth
1912
- try
1913
- tube
1914
- tuition
1915
- tumble
1916
- tuna
1917
- tunnel
1918
- turkey
1919
- turn
1920
- turtle
1921
- twelve
1922
- twenty
1923
- twice
1924
- twin
1925
- twist
1926
- two
1927
- type
1928
- typical
1929
- ugly
1930
- umbrella
1931
- unable
1932
- unaware
1933
- uncle
1934
- uncover
1935
- under
1936
- undo
1937
- unfair
1938
- unfold
1939
- unhappy
1940
- uniform
1941
- unique
1942
- unit
1943
- universe
1944
- unknown
1945
- unlock
1946
- until
1947
- unusual
1948
- unveil
1949
- update
1950
- upgrade
1951
- uphold
1952
- upon
1953
- upper
1954
- upset
1955
- urban
1956
- urge
1957
- usage
1958
- use
1959
- used
1960
- useful
1961
- useless
1962
- usual
1963
- utility
1964
- vacant
1965
- vacuum
1966
- vague
1967
- valid
1968
- valley
1969
- valve
1970
- van
1971
- vanish
1972
- vapor
1973
- various
1974
- vast
1975
- vault
1976
- vehicle
1977
- velvet
1978
- vendor
1979
- venture
1980
- venue
1981
- verb
1982
- verify
1983
- version
1984
- very
1985
- vessel
1986
- veteran
1987
- viable
1988
- vibrant
1989
- vicious
1990
- victory
1991
- video
1992
- view
1993
- village
1994
- vintage
1995
- violin
1996
- virtual
1997
- virus
1998
- visa
1999
- visit
2000
- visual
2001
- vital
2002
- vivid
2003
- vocal
2004
- voice
2005
- void
2006
- volcano
2007
- volume
2008
- vote
2009
- voyage
2010
- wage
2011
- wagon
2012
- wait
2013
- walk
2014
- wall
2015
- walnut
2016
- want
2017
- warfare
2018
- warm
2019
- warrior
2020
- wash
2021
- wasp
2022
- waste
2023
- water
2024
- wave
2025
- way
2026
- wealth
2027
- weapon
2028
- wear
2029
- weasel
2030
- weather
2031
- web
2032
- wedding
2033
- weekend
2034
- weird
2035
- welcome
2036
- west
2037
- wet
2038
- whale
2039
- what
2040
- wheat
2041
- wheel
2042
- when
2043
- where
2044
- whip
2045
- whisper
2046
- wide
2047
- width
2048
- wife
2049
- wild
2050
- will
2051
- win
2052
- window
2053
- wine
2054
- wing
2055
- wink
2056
- winner
2057
- winter
2058
- wire
2059
- wisdom
2060
- wise
2061
- wish
2062
- witness
2063
- wolf
2064
- woman
2065
- wonder
2066
- wood
2067
- wool
2068
- word
2069
- work
2070
- world
2071
- worry
2072
- worth
2073
- wrap
2074
- wreck
2075
- wrestle
2076
- wrist
2077
- write
2078
- wrong
2079
- yard
2080
- year
2081
- yellow
2082
- you
2083
- young
2084
- youth
2085
- zebra
2086
- zero
2087
- zone
2088
- zoo`.split("\n");
2089
- }
2090
- });
2091
-
2092
36
  // ../crypto/dist/index.mjs
2093
37
  var dist_exports = {};
2094
38
  __export(dist_exports, {
@@ -2118,6 +62,7 @@ __export(dist_exports, {
2118
62
  mlkemUnwrapDek: () => mlkemUnwrapDek,
2119
63
  mlkemWrapDek: () => mlkemWrapDek,
2120
64
  parseKeyEnvelope: () => parseKeyEnvelope,
65
+ readResponseTextWithLimit: () => readResponseTextWithLimit,
2121
66
  serializeKeyEnvelope: () => serializeKeyEnvelope,
2122
67
  serializeXChaChaPayload: () => serializeXChaChaPayload,
2123
68
  unwrapKey: () => unwrapKey,
@@ -2130,7 +75,7 @@ function base64urlToBytes(b64url) {
2130
75
  if (!/^[A-Za-z0-9_-]*$/.test(b64url)) {
2131
76
  throw new DStorageError(
2132
77
  CryptoErrorCode.BASE64URL_INVALID,
2133
- `[dStorage/crypto] malformed base64url input \u2014 unexpected characters in "${b64url.slice(0, 32)}${b64url.length > 32 ? "\u2026" : ""}"`
78
+ `[dStorage/crypto] malformed base64url input \u2014 unexpected characters (length: ${b64url.length})`
2134
79
  );
2135
80
  }
2136
81
  const b64 = b64url.replace(/-/g, "+").replace(/_/g, "/");
@@ -2488,11 +433,60 @@ async function computeBlake3Hex(bytes) {
2488
433
  ""
2489
434
  );
2490
435
  }
2491
- var import_chacha, import_ml_kem, import_blake3, DStorageError, CryptoErrorCode, ENGLISH_WORD_SET, KeyDeriver, STORAGE_ID_AAD, XCHACHA_STORAGE_ID_BYTES, XChaChaScheme, OWNER_SECRET_DOMAIN, DEFAULT_VARIANT, MLKEM_ALGO_SUFFIX;
436
+ async function readResponseTextWithLimit(res, opts) {
437
+ const contentLength = res.headers?.get?.("content-length");
438
+ if (contentLength) {
439
+ const len = Number(contentLength);
440
+ if (Number.isFinite(len) && len > opts.maxBytes) {
441
+ throw new DStorageError(
442
+ opts.code,
443
+ `${opts.component} failed: response Content-Length (${len} bytes) exceeds the maximum allowed size of ${opts.maxBytes} bytes.`
444
+ );
445
+ }
446
+ }
447
+ if (!res.body) {
448
+ const text = await res.text();
449
+ if (text.length > opts.maxBytes) {
450
+ throw new DStorageError(
451
+ opts.code,
452
+ `${opts.component} failed: response body exceeds the maximum allowed size of ${opts.maxBytes} bytes.`
453
+ );
454
+ }
455
+ return text;
456
+ }
457
+ const reader = res.body.getReader();
458
+ const chunks = [];
459
+ let total = 0;
460
+ try {
461
+ for (; ; ) {
462
+ const { done, value } = await reader.read();
463
+ if (done) break;
464
+ total += value.byteLength;
465
+ if (total > opts.maxBytes) {
466
+ throw new DStorageError(
467
+ opts.code,
468
+ `${opts.component} failed: response body exceeds the maximum allowed size of ${opts.maxBytes} bytes.`
469
+ );
470
+ }
471
+ chunks.push(value);
472
+ }
473
+ } finally {
474
+ reader.releaseLock();
475
+ }
476
+ const combined = new Uint8Array(total);
477
+ let offset = 0;
478
+ for (const chunk of chunks) {
479
+ combined.set(chunk, offset);
480
+ offset += chunk.byteLength;
481
+ }
482
+ return new TextDecoder().decode(combined);
483
+ }
484
+ var import_english, import_bip39, import_chacha, import_ml_kem, import_blake3, DStorageError, CryptoErrorCode, KeyDeriver, STORAGE_ID_AAD, XCHACHA_STORAGE_ID_BYTES, XChaChaScheme, OWNER_SECRET_DOMAIN, DEFAULT_VARIANT, MLKEM_ALGO_SUFFIX;
2492
485
  var init_dist = __esm({
2493
486
  "../crypto/dist/index.mjs"() {
2494
487
  "use strict";
2495
- init_english();
488
+ import_english = require("@scure/bip39/wordlists/english.js");
489
+ import_bip39 = require("@scure/bip39");
2496
490
  import_chacha = require("@noble/ciphers/chacha.js");
2497
491
  import_ml_kem = require("@noble/post-quantum/ml-kem.js");
2498
492
  import_blake3 = require("@noble/hashes/blake3");
@@ -2527,7 +521,6 @@ var init_dist = __esm({
2527
521
  MLKEM_UNKNOWN_ALGORITHM: 12017,
2528
522
  MLKEM_UNKNOWN_VARIANT: 12018
2529
523
  };
2530
- ENGLISH_WORD_SET = new Set(wordlist);
2531
524
  KeyDeriver = class {
2532
525
  constructor(input) {
2533
526
  if (!input.mnemonic && !input.seedHex) {
@@ -2566,11 +559,10 @@ var init_dist = __esm({
2566
559
  }
2567
560
  return bytes;
2568
561
  }
2569
- const words = this.input.mnemonic.trim().split(/\s+/);
2570
- if (!words.every((w) => ENGLISH_WORD_SET.has(w))) {
562
+ if (!(0, import_bip39.validateMnemonic)(this.input.mnemonic, import_english.wordlist)) {
2571
563
  throw new DStorageError(
2572
564
  CryptoErrorCode.MNEMONIC_INVALID,
2573
- "[dStorage/crypto] Invalid BIP-39 mnemonic phrase."
565
+ "[dStorage/crypto] Invalid BIP-39 mnemonic phrase. Unrecognized word or failed checksum."
2574
566
  );
2575
567
  }
2576
568
  return mnemonicToSeed(this.input.mnemonic);
@@ -2642,10 +634,10 @@ var init_dist = __esm({
2642
634
  }
2643
635
  });
2644
636
 
2645
- // ../encryption/dist/chunk-WBLC4ONG.mjs
637
+ // ../encryption/dist/chunk-AGSZ3S6J.mjs
2646
638
  var EncryptionErrorCode;
2647
- var init_chunk_WBLC4ONG = __esm({
2648
- "../encryption/dist/chunk-WBLC4ONG.mjs"() {
639
+ var init_chunk_AGSZ3S6J = __esm({
640
+ "../encryption/dist/chunk-AGSZ3S6J.mjs"() {
2649
641
  "use strict";
2650
642
  EncryptionErrorCode = {
2651
643
  KEYPAIR_MISSING_SECRET_KEY: 13001,
@@ -2657,17 +649,19 @@ var init_chunk_WBLC4ONG = __esm({
2657
649
  PASSWORD_TOO_FEW_DISTINCT: 13007,
2658
650
  PASSWORD_SEQUENTIAL_RUN: 13008,
2659
651
  PASSWORD_KEYBOARD_WALK: 13009,
2660
- PASSWORD_ENTROPY_TOO_LOW: 13010
652
+ PASSWORD_ENTROPY_TOO_LOW: 13010,
653
+ PASSWORD_SCRYPT_N_TOO_LOW: 13011,
654
+ PASSWORD_SCRYPT_N_NOT_POWER_OF_TWO: 13012
2661
655
  };
2662
656
  }
2663
657
  });
2664
658
 
2665
- // ../encryption/dist/chunk-SW62VRE3.mjs
659
+ // ../encryption/dist/chunk-SOX5GKK4.mjs
2666
660
  var MnemonicEncryptionAdapter;
2667
- var init_chunk_SW62VRE3 = __esm({
2668
- "../encryption/dist/chunk-SW62VRE3.mjs"() {
661
+ var init_chunk_SOX5GKK4 = __esm({
662
+ "../encryption/dist/chunk-SOX5GKK4.mjs"() {
2669
663
  "use strict";
2670
- init_chunk_WBLC4ONG();
664
+ init_chunk_AGSZ3S6J();
2671
665
  init_dist();
2672
666
  init_dist();
2673
667
  MnemonicEncryptionAdapter = class {
@@ -2733,7 +727,7 @@ var init_chunk_SW62VRE3 = __esm({
2733
727
  * @param variant ML-KEM variant. Default: "mlkem768".
2734
728
  */
2735
729
  async intoKeypairEncryptionAdapter(context, variant) {
2736
- const { KeypairEncryptionAdapter: KeypairEncryptionAdapter2 } = await Promise.resolve().then(() => (init_KeypairEncryptionAdapter_XUKCLRFU(), KeypairEncryptionAdapter_XUKCLRFU_exports));
730
+ const { KeypairEncryptionAdapter: KeypairEncryptionAdapter2 } = await Promise.resolve().then(() => (init_KeypairEncryptionAdapter_EOBRCIGP(), KeypairEncryptionAdapter_EOBRCIGP_exports));
2737
731
  const { mlkemGenerateKeypairFromSeed: mlkemGenerateKeypairFromSeed2 } = await Promise.resolve().then(() => (init_dist(), dist_exports));
2738
732
  const kekMaterial = await this.kekMaterialPromise;
2739
733
  const mlkemBits = await globalThis.crypto.subtle.deriveBits(
@@ -2759,38 +753,38 @@ var init_chunk_SW62VRE3 = __esm({
2759
753
  }
2760
754
  });
2761
755
 
2762
- // ../encryption/dist/MnemonicEncryptionAdapter-RCHUETBP.mjs
2763
- var MnemonicEncryptionAdapter_RCHUETBP_exports = {};
2764
- __export(MnemonicEncryptionAdapter_RCHUETBP_exports, {
756
+ // ../encryption/dist/MnemonicEncryptionAdapter-S56YG63Q.mjs
757
+ var MnemonicEncryptionAdapter_S56YG63Q_exports = {};
758
+ __export(MnemonicEncryptionAdapter_S56YG63Q_exports, {
2765
759
  MnemonicEncryptionAdapter: () => MnemonicEncryptionAdapter
2766
760
  });
2767
- var init_MnemonicEncryptionAdapter_RCHUETBP = __esm({
2768
- "../encryption/dist/MnemonicEncryptionAdapter-RCHUETBP.mjs"() {
761
+ var init_MnemonicEncryptionAdapter_S56YG63Q = __esm({
762
+ "../encryption/dist/MnemonicEncryptionAdapter-S56YG63Q.mjs"() {
2769
763
  "use strict";
2770
- init_chunk_SW62VRE3();
764
+ init_chunk_SOX5GKK4();
2771
765
  }
2772
766
  });
2773
767
 
2774
- // ../encryption/dist/PasswordEncryptionAdapter-ECHND672.mjs
2775
- var PasswordEncryptionAdapter_ECHND672_exports = {};
2776
- __export(PasswordEncryptionAdapter_ECHND672_exports, {
768
+ // ../encryption/dist/PasswordEncryptionAdapter-B2UG7MWB.mjs
769
+ var PasswordEncryptionAdapter_B2UG7MWB_exports = {};
770
+ __export(PasswordEncryptionAdapter_B2UG7MWB_exports, {
2777
771
  KDF_PRESETS: () => KDF_PRESETS,
2778
772
  PasswordEncryptionAdapter: () => PasswordEncryptionAdapter,
2779
773
  generatePqsPassword: () => generatePqsPassword
2780
774
  });
2781
- var init_PasswordEncryptionAdapter_ECHND672 = __esm({
2782
- "../encryption/dist/PasswordEncryptionAdapter-ECHND672.mjs"() {
775
+ var init_PasswordEncryptionAdapter_B2UG7MWB = __esm({
776
+ "../encryption/dist/PasswordEncryptionAdapter-B2UG7MWB.mjs"() {
2783
777
  "use strict";
2784
- init_chunk_6IHXTW2Y();
778
+ init_chunk_ENX7VXEV();
2785
779
  }
2786
780
  });
2787
781
 
2788
- // ../encryption/dist/chunk-NAJYQ4J6.mjs
782
+ // ../encryption/dist/chunk-A7BIR2QB.mjs
2789
783
  var KeypairEncryptionAdapter;
2790
- var init_chunk_NAJYQ4J6 = __esm({
2791
- "../encryption/dist/chunk-NAJYQ4J6.mjs"() {
784
+ var init_chunk_A7BIR2QB = __esm({
785
+ "../encryption/dist/chunk-A7BIR2QB.mjs"() {
2792
786
  "use strict";
2793
- init_chunk_WBLC4ONG();
787
+ init_chunk_AGSZ3S6J();
2794
788
  init_dist();
2795
789
  init_dist();
2796
790
  KeypairEncryptionAdapter = class _KeypairEncryptionAdapter {
@@ -2848,7 +842,7 @@ var init_chunk_NAJYQ4J6 = __esm({
2848
842
  * @param variant Default: "mlkem768"
2849
843
  */
2850
844
  static async fromMnemonic(input, context, variant = "mlkem768") {
2851
- const { MnemonicEncryptionAdapter: MnemonicEncryptionAdapter2 } = await Promise.resolve().then(() => (init_MnemonicEncryptionAdapter_RCHUETBP(), MnemonicEncryptionAdapter_RCHUETBP_exports));
845
+ const { MnemonicEncryptionAdapter: MnemonicEncryptionAdapter2 } = await Promise.resolve().then(() => (init_MnemonicEncryptionAdapter_S56YG63Q(), MnemonicEncryptionAdapter_S56YG63Q_exports));
2852
846
  const ms = new MnemonicEncryptionAdapter2(input);
2853
847
  return ms.intoKeypairEncryptionAdapter(context, variant);
2854
848
  }
@@ -2868,7 +862,7 @@ var init_chunk_NAJYQ4J6 = __esm({
2868
862
  * @param params Optional custom scrypt params
2869
863
  */
2870
864
  static async fromPassword(password, salt, context, variant = "mlkem768", params) {
2871
- const { PasswordEncryptionAdapter: PasswordEncryptionAdapter2 } = await Promise.resolve().then(() => (init_PasswordEncryptionAdapter_ECHND672(), PasswordEncryptionAdapter_ECHND672_exports));
865
+ const { PasswordEncryptionAdapter: PasswordEncryptionAdapter2 } = await Promise.resolve().then(() => (init_PasswordEncryptionAdapter_B2UG7MWB(), PasswordEncryptionAdapter_B2UG7MWB_exports));
2872
866
  const ps = new PasswordEncryptionAdapter2({
2873
867
  password,
2874
868
  salt,
@@ -2902,19 +896,19 @@ var init_chunk_NAJYQ4J6 = __esm({
2902
896
  }
2903
897
  });
2904
898
 
2905
- // ../encryption/dist/KeypairEncryptionAdapter-XUKCLRFU.mjs
2906
- var KeypairEncryptionAdapter_XUKCLRFU_exports = {};
2907
- __export(KeypairEncryptionAdapter_XUKCLRFU_exports, {
899
+ // ../encryption/dist/KeypairEncryptionAdapter-EOBRCIGP.mjs
900
+ var KeypairEncryptionAdapter_EOBRCIGP_exports = {};
901
+ __export(KeypairEncryptionAdapter_EOBRCIGP_exports, {
2908
902
  KeypairEncryptionAdapter: () => KeypairEncryptionAdapter
2909
903
  });
2910
- var init_KeypairEncryptionAdapter_XUKCLRFU = __esm({
2911
- "../encryption/dist/KeypairEncryptionAdapter-XUKCLRFU.mjs"() {
904
+ var init_KeypairEncryptionAdapter_EOBRCIGP = __esm({
905
+ "../encryption/dist/KeypairEncryptionAdapter-EOBRCIGP.mjs"() {
2912
906
  "use strict";
2913
- init_chunk_NAJYQ4J6();
907
+ init_chunk_A7BIR2QB();
2914
908
  }
2915
909
  });
2916
910
 
2917
- // ../encryption/dist/chunk-6IHXTW2Y.mjs
911
+ // ../encryption/dist/chunk-ENX7VXEV.mjs
2918
912
  function resolveSalt(salt) {
2919
913
  const bytes = typeof salt === "string" ? new TextEncoder().encode(salt) : salt;
2920
914
  if (bytes.length === 0) {
@@ -2925,7 +919,22 @@ function resolveSalt(salt) {
2925
919
  }
2926
920
  return bytes;
2927
921
  }
922
+ function assertScryptCost(N) {
923
+ if (!Number.isInteger(N) || N < 2 || (N & N - 1) !== 0) {
924
+ throw new DStorageError(
925
+ EncryptionErrorCode.PASSWORD_SCRYPT_N_NOT_POWER_OF_TWO,
926
+ `[dStorage] PasswordEncryptionAdapter: scrypt N must be a power of two >= 2 (got ${N}).`
927
+ );
928
+ }
929
+ if (N < MIN_SCRYPT_N) {
930
+ throw new DStorageError(
931
+ EncryptionErrorCode.PASSWORD_SCRYPT_N_TOO_LOW,
932
+ `[dStorage] PasswordEncryptionAdapter: scrypt N=${N} is below the minimum cost floor of ${MIN_SCRYPT_N} (OWASP 2024 minimum, 32 MB memory-hard). A lower N makes the KDF cheap enough to brute-force offline. Use a preset ("v1" or "v1-lite") or a custom N >= 32768.`
933
+ );
934
+ }
935
+ }
2928
936
  function resolveParams(preset, params) {
937
+ let resolved;
2929
938
  if (preset !== void 0) {
2930
939
  if (!(preset in KDF_PRESETS)) {
2931
940
  throw new DStorageError(
@@ -2933,13 +942,16 @@ function resolveParams(preset, params) {
2933
942
  `[dStorage] PasswordEncryptionAdapter: unknown preset "${preset}". Valid presets: ${Object.keys(KDF_PRESETS).join(", ")}.`
2934
943
  );
2935
944
  }
2936
- return KDF_PRESETS[preset];
945
+ resolved = KDF_PRESETS[preset];
946
+ } else {
947
+ resolved = {
948
+ N: params?.N ?? KDF_PRESETS["v1"].N,
949
+ r: params?.r ?? KDF_PRESETS["v1"].r,
950
+ p: params?.p ?? KDF_PRESETS["v1"].p
951
+ };
2937
952
  }
2938
- return {
2939
- N: params?.N ?? KDF_PRESETS["v1"].N,
2940
- r: params?.r ?? KDF_PRESETS["v1"].r,
2941
- p: params?.p ?? KDF_PRESETS["v1"].p
2942
- };
953
+ assertScryptCost(resolved.N);
954
+ return resolved;
2943
955
  }
2944
956
  function estimateEntropyBits(password) {
2945
957
  let pool = 0;
@@ -3022,11 +1034,11 @@ function validatePassword(password, minLength, minEntropyBits, additionalValidat
3022
1034
  }
3023
1035
  }
3024
1036
  }
3025
- var import_scrypt, KDF_PRESETS, PasswordEncryptionAdapter, KEYBOARD_ROWS;
3026
- var init_chunk_6IHXTW2Y = __esm({
3027
- "../encryption/dist/chunk-6IHXTW2Y.mjs"() {
1037
+ var import_scrypt, KDF_PRESETS, PasswordEncryptionAdapter, MIN_SCRYPT_N, KEYBOARD_ROWS;
1038
+ var init_chunk_ENX7VXEV = __esm({
1039
+ "../encryption/dist/chunk-ENX7VXEV.mjs"() {
3028
1040
  "use strict";
3029
- init_chunk_WBLC4ONG();
1041
+ init_chunk_AGSZ3S6J();
3030
1042
  import_scrypt = require("@noble/hashes/scrypt.js");
3031
1043
  init_dist();
3032
1044
  KDF_PRESETS = {
@@ -3156,7 +1168,7 @@ var init_chunk_6IHXTW2Y = __esm({
3156
1168
  * @param variant ML-KEM variant. Default: "mlkem768".
3157
1169
  */
3158
1170
  async intoKeypairEncryptionAdapter(context, variant) {
3159
- const { KeypairEncryptionAdapter: KeypairEncryptionAdapter2 } = await Promise.resolve().then(() => (init_KeypairEncryptionAdapter_XUKCLRFU(), KeypairEncryptionAdapter_XUKCLRFU_exports));
1171
+ const { KeypairEncryptionAdapter: KeypairEncryptionAdapter2 } = await Promise.resolve().then(() => (init_KeypairEncryptionAdapter_EOBRCIGP(), KeypairEncryptionAdapter_EOBRCIGP_exports));
3160
1172
  const { mlkemGenerateKeypairFromSeed: mlkemGenerateKeypairFromSeed2 } = await Promise.resolve().then(() => (init_dist(), dist_exports));
3161
1173
  const kekMaterial = await this.kekMaterialPromise;
3162
1174
  const mlkemBits = await globalThis.crypto.subtle.deriveBits(
@@ -3179,14 +1191,15 @@ var init_chunk_6IHXTW2Y = __esm({
3179
1191
  }
3180
1192
  }
3181
1193
  };
1194
+ MIN_SCRYPT_N = 32768;
3182
1195
  KEYBOARD_ROWS = ["qwertyuiop", "asdfghjkl", "zxcvbnm", "1234567890"];
3183
1196
  }
3184
1197
  });
3185
1198
 
3186
- // ../chain/dist/chunk-AGLD4HA4.mjs
1199
+ // ../chain/dist/chunk-XMWGGIPS.mjs
3187
1200
  var ChainErrorCode;
3188
- var init_chunk_AGLD4HA4 = __esm({
3189
- "../chain/dist/chunk-AGLD4HA4.mjs"() {
1201
+ var init_chunk_XMWGGIPS = __esm({
1202
+ "../chain/dist/chunk-XMWGGIPS.mjs"() {
3190
1203
  "use strict";
3191
1204
  ChainErrorCode = {
3192
1205
  // mock.ts — 11001-11009
@@ -3210,6 +1223,8 @@ var init_chunk_AGLD4HA4 = __esm({
3210
1223
  GATEWAY_LIST_NOT_ARRAY: 11212,
3211
1224
  GATEWAY_REMOVE_FAILED: 11213,
3212
1225
  GATEWAY_REMOVE_HTTP_ERROR: 11214,
1226
+ GATEWAY_READ_RESPONSE_TOO_LARGE: 11215,
1227
+ GATEWAY_LIST_RESPONSE_TOO_LARGE: 11216,
3213
1228
  // contract-api.ts — 11401-11409
3214
1229
  CONTRACT_UNSUPPORTED_VERSION: 11401,
3215
1230
  CONTRACT_CIRCUIT_RESULT_MISSING: 11402,
@@ -14138,9 +12153,9 @@ var init_in_memory_private_state_NGOP37V7 = __esm({
14138
12153
  }
14139
12154
  });
14140
12155
 
14141
- // ../chain/dist/contract-api-TJ7JPHZA.mjs
14142
- var contract_api_TJ7JPHZA_exports = {};
14143
- __export(contract_api_TJ7JPHZA_exports, {
12156
+ // ../chain/dist/contract-api-NUY4UEKE.mjs
12157
+ var contract_api_NUY4UEKE_exports = {};
12158
+ __export(contract_api_NUY4UEKE_exports, {
14144
12159
  DataRegistryAPI: () => DataRegistryAPI,
14145
12160
  SUPPORTED_CONTRACT_VERSION: () => SUPPORTED_CONTRACT_VERSION,
14146
12161
  dataRegistryPrivateStateKey: () => dataRegistryPrivateStateKey,
@@ -14156,10 +12171,10 @@ function validateContractVersion(version, contractAddress) {
14156
12171
  }
14157
12172
  }
14158
12173
  var import_midnight_js_contracts, import_rxjs, import_midnight_js_utils, dataRegistryPrivateStateKey, SUPPORTED_CONTRACT_VERSION, DataRegistryAPI, randomBytes;
14159
- var init_contract_api_TJ7JPHZA = __esm({
14160
- "../chain/dist/contract-api-TJ7JPHZA.mjs"() {
12174
+ var init_contract_api_NUY4UEKE = __esm({
12175
+ "../chain/dist/contract-api-NUY4UEKE.mjs"() {
14161
12176
  "use strict";
14162
- init_chunk_AGLD4HA4();
12177
+ init_chunk_XMWGGIPS();
14163
12178
  init_chunk_I3XXA2G7();
14164
12179
  import_midnight_js_contracts = require("@midnight-ntwrk/midnight-js-contracts");
14165
12180
  import_rxjs = __toESM(require_cjs(), 1);
@@ -14470,6 +12485,7 @@ __export(index_publish_exports, {
14470
12485
  mlkemUnwrapDek: () => mlkemUnwrapDek,
14471
12486
  mlkemWrapDek: () => mlkemWrapDek,
14472
12487
  parseKeyEnvelope: () => parseKeyEnvelope,
12488
+ readResponseTextWithLimit: () => readResponseTextWithLimit,
14473
12489
  serializeKeyEnvelope: () => serializeKeyEnvelope,
14474
12490
  serializeXChaChaPayload: () => serializeXChaChaPayload,
14475
12491
  unwrapKey: () => unwrapKey,
@@ -14527,6 +12543,7 @@ var CoreErrorCode = {
14527
12543
  STORAGE_ADAPTER_MISMATCH: 10052,
14528
12544
  RETRIEVE_BY_REF_ID_ENVELOPE_EMPTY: 10053,
14529
12545
  CONTENT_HASH_MISMATCH: 10054,
12546
+ METADATA_PARSE_FAILED: 10055,
14530
12547
  // listReferences — 10060-10069
14531
12548
  LIST_REFS_REQUIRES_CHAIN: 10060,
14532
12549
  LIST_REFS_NOT_SUPPORTED: 10061,
@@ -14540,6 +12557,7 @@ var CoreErrorCode = {
14540
12557
  DECRYPT_CHUNK_FAILED: 10093,
14541
12558
  CHUNK_OVERFLOWS_TOTAL_SIZE: 10094,
14542
12559
  REASSEMBLY_SIZE_MISMATCH: 10095,
12560
+ MANIFEST_PARSE_FAILED: 10096,
14543
12561
  // init state — 10100-10109
14544
12562
  NOT_INITIALIZED: 10100,
14545
12563
  // generic catch-all — 10999
@@ -14562,7 +12580,7 @@ function isStorePartialError(err) {
14562
12580
  // package.json
14563
12581
  var package_default = {
14564
12582
  name: "@dstorage-tech/dstorage-sdk",
14565
- version: "0.0.6",
12583
+ version: "0.0.8",
14566
12584
  description: "Privacy-first decentralized storage SDK with pluggable adapters",
14567
12585
  license: "MIT",
14568
12586
  homepage: "https://dstorage.pro",
@@ -14638,10 +12656,11 @@ var package_default = {
14638
12656
  "@midnight-ntwrk/midnight-js-protocol": "4.1.1",
14639
12657
  "@midnight-ntwrk/midnight-js-types": "4.1.1",
14640
12658
  "@midnight-ntwrk/midnight-js-utils": "4.1.1",
14641
- "@midnight-ntwrk/wallet-sdk": "1.1.0",
12659
+ "@midnight-ntwrk/wallet-sdk": "1.2.0",
14642
12660
  "@noble/ciphers": "^2.2.0",
14643
12661
  "@noble/hashes": "^1.5.0",
14644
12662
  "@noble/post-quantum": "^0.6.1",
12663
+ "@scure/bip39": "^2.0.1",
14645
12664
  arweave: "^1.15.7"
14646
12665
  },
14647
12666
  devDependencies: {
@@ -14716,6 +12735,9 @@ var DStorage = class {
14716
12735
  }
14717
12736
  /** Tear down active state and clear all in-memory key material. */
14718
12737
  destroy() {
12738
+ for (const provider of this._encryptionProviders) {
12739
+ provider.destroy?.();
12740
+ }
14719
12741
  this.wallet = null;
14720
12742
  this._encryptionProviders = [];
14721
12743
  this._initialized = false;
@@ -14815,20 +12837,24 @@ var DStorage = class {
14815
12837
  );
14816
12838
  }
14817
12839
  const ownerSeed = generateDek();
14818
- const ownerSeedWrappers = await Promise.all(
14819
- this._encryptionProviders.map(async (provider) => ({
14820
- wrapKeyName: provider.name,
14821
- ...await provider.wrapDek(ownerSeed)
14822
- }))
14823
- );
14824
- keyEnvelope = serializeKeyEnvelope(
14825
- buildKeyEnvelope(ownerSeedWrappers)
14826
- );
14827
- ownerSecret = await deriveOwnerSecret(
14828
- ownerSeed,
14829
- new TextEncoder().encode(storageResult.id),
14830
- "dstorage:owner-secret:public:v1"
14831
- );
12840
+ try {
12841
+ const ownerSeedWrappers = await Promise.all(
12842
+ this._encryptionProviders.map(async (provider) => ({
12843
+ wrapKeyName: provider.name,
12844
+ ...await provider.wrapDek(ownerSeed)
12845
+ }))
12846
+ );
12847
+ keyEnvelope = serializeKeyEnvelope(
12848
+ buildKeyEnvelope(ownerSeedWrappers)
12849
+ );
12850
+ ownerSecret = await deriveOwnerSecret(
12851
+ ownerSeed,
12852
+ new TextEncoder().encode(storageResult.id),
12853
+ "dstorage:owner-secret:public:v1"
12854
+ );
12855
+ } finally {
12856
+ ownerSeed.fill(0);
12857
+ }
14832
12858
  }
14833
12859
  onChainStorageId = storageResult.id;
14834
12860
  } else {
@@ -14901,6 +12927,8 @@ var DStorage = class {
14901
12927
  };
14902
12928
  } catch {
14903
12929
  throw new StorePartialError(storeRecovery);
12930
+ } finally {
12931
+ dek?.fill(0);
14904
12932
  }
14905
12933
  }
14906
12934
  this.logger?.log(
@@ -15261,7 +13289,10 @@ var DStorage = class {
15261
13289
  async retrieveByStorageId(storageId, dekScheme, contentHash) {
15262
13290
  try {
15263
13291
  this.assertConnected();
15264
- const { bytes: rawBytes, tags } = await this.config.storageAdapter.retrieve(storageId);
13292
+ const { bytes: rawBytes, tags } = await this.config.storageAdapter.retrieve(
13293
+ storageId,
13294
+ contentHash !== void 0 ? { expectedContentHash: contentHash } : void 0
13295
+ );
15265
13296
  if (contentHash) {
15266
13297
  const computed = await computeBlake3Hex(rawBytes);
15267
13298
  if (computed !== contentHash) {
@@ -15402,9 +13433,16 @@ var DStorage = class {
15402
13433
  } catch {
15403
13434
  }
15404
13435
  if (manifestBytes !== null) {
15405
- const parsed = JSON.parse(
15406
- new TextDecoder().decode(manifestBytes)
15407
- );
13436
+ let parsed;
13437
+ try {
13438
+ parsed = JSON.parse(new TextDecoder().decode(manifestBytes));
13439
+ } catch (err) {
13440
+ throw new DStorageError(
13441
+ CoreErrorCode.MANIFEST_PARSE_FAILED,
13442
+ `[dStorage] Payload authenticated as manifest but is not valid JSON: ${err}`,
13443
+ { cause: err }
13444
+ );
13445
+ }
15408
13446
  if (!isManifest(parsed)) {
15409
13447
  throw new DStorageError(
15410
13448
  CoreErrorCode.MANIFEST_INVALID_STRUCTURE,
@@ -15528,7 +13566,15 @@ var DStorage = class {
15528
13566
  base64urlToBytes(ref.encryptedMetadata),
15529
13567
  METADATA_AAD
15530
13568
  );
15531
- metadata = JSON.parse(new TextDecoder().decode(raw));
13569
+ try {
13570
+ metadata = JSON.parse(new TextDecoder().decode(raw));
13571
+ } catch (err) {
13572
+ throw new DStorageError(
13573
+ CoreErrorCode.METADATA_PARSE_FAILED,
13574
+ `[dStorage] Decrypted metadata is not valid JSON: ${err}`,
13575
+ { cause: err }
13576
+ );
13577
+ }
15532
13578
  }
15533
13579
  return { bytes: contentBytes, tags: contentTags, metadata };
15534
13580
  } catch (err) {
@@ -15873,12 +13919,17 @@ var DStorage = class {
15873
13919
  };
15874
13920
  } catch {
15875
13921
  throw new StorePartialError(storeRecovery);
13922
+ } finally {
13923
+ chunkDek?.fill(0);
13924
+ ownerSeed?.fill(0);
15876
13925
  }
15877
13926
  }
15878
13927
  this.logger?.log(
15879
13928
  "dStorage",
15880
13929
  `Chunked upload complete (storage-only) \u2192 ${totalChunks} chunks + manifest, storageId: ${manifestResult.id}`
15881
13930
  );
13931
+ chunkDek?.fill(0);
13932
+ ownerSeed?.fill(0);
15882
13933
  return {
15883
13934
  storageId: manifestResult.id,
15884
13935
  storageProvider: manifestResult.provider,
@@ -15971,15 +14022,15 @@ var DStorage = class {
15971
14022
  init_dist();
15972
14023
 
15973
14024
  // ../encryption/dist/index.mjs
15974
- init_chunk_6IHXTW2Y();
15975
- init_chunk_NAJYQ4J6();
15976
- init_chunk_SW62VRE3();
15977
- init_chunk_WBLC4ONG();
14025
+ init_chunk_ENX7VXEV();
14026
+ init_chunk_A7BIR2QB();
14027
+ init_chunk_SOX5GKK4();
14028
+ init_chunk_AGSZ3S6J();
15978
14029
 
15979
14030
  // src/index.publish.ts
15980
14031
  init_dist();
15981
14032
 
15982
- // ../storage/dist/chunk-URI7FNOW.mjs
14033
+ // ../storage/dist/chunk-3LIX4E3N.mjs
15983
14034
  var StorageErrorCode = {
15984
14035
  // adapters/mock.ts (15000–15049)
15985
14036
  MOCK_AUTH_TOKEN_REQUIRED: 15001,
@@ -16018,7 +14069,8 @@ var StorageErrorCode = {
16018
14069
  ARWEAVE_BUNDLER_INVALID_AUTH_TOKEN_FORMAT: 15411,
16019
14070
  ARWEAVE_BUNDLER_INVALID_AUTH_TOKEN_KEY: 15412,
16020
14071
  ARWEAVE_BUNDLER_NO_TX_ID_RETURNED: 15413,
16021
- ARWEAVE_BUNDLER_UPLOAD_FAILED: 15414
14072
+ ARWEAVE_BUNDLER_UPLOAD_FAILED: 15414,
14073
+ ARWEAVE_BUNDLER_METADATA_TOO_LARGE: 15415
16022
14074
  };
16023
14075
 
16024
14076
  // ../payment/dist/chunk-IVL4WQ5Y.mjs
@@ -16689,7 +14741,7 @@ var ManagedPaymentAdapter = class _ManagedPaymentAdapter extends ArweavePaymentA
16689
14741
  }
16690
14742
  };
16691
14743
 
16692
- // ../storage/dist/chunk-BIT7XMIA.mjs
14744
+ // ../storage/dist/chunk-AE5AGNHP.mjs
16693
14745
  init_dist();
16694
14746
  var memoryStore = /* @__PURE__ */ new Map();
16695
14747
  function bytesToBase64url2(bytes) {
@@ -16972,7 +15024,7 @@ var ArweaveStorageAdapter = class {
16972
15024
  };
16973
15025
  }
16974
15026
  // ── retrieve ───────────────────────────────────────────────────────────────────
16975
- async retrieve(id) {
15027
+ async retrieve(id, options) {
16976
15028
  if (!/^[A-Za-z0-9_-]{43}$/.test(id)) {
16977
15029
  throw new DStorageError(
16978
15030
  StorageErrorCode.ARWEAVE_INVALID_TX_ID,
@@ -17036,14 +15088,15 @@ Check status at: https://viewblock.io/arweave/tx/${id}`
17036
15088
  );
17037
15089
  }
17038
15090
  if (!this.skipIntegrityCheck) {
17039
- if (!storedHash) {
15091
+ const anchorHash = options?.expectedContentHash;
15092
+ if (!anchorHash && !storedHash) {
17040
15093
  throw new DStorageError(
17041
15094
  StorageErrorCode.ARWEAVE_HASH_TAG_MISSING,
17042
- `[dStorage/arweave] ${CONTENT_HASH_TAG2} tag not found for txId: ${id}.
15095
+ `[dStorage/arweave] Cannot verify content integrity for txId: ${id} \u2014 no expectedContentHash anchor was provided and the ${CONTENT_HASH_TAG2} tag was not found.
17043
15096
  Set skipIntegrityCheck: true to bypass integrity checking for fully trusted gateways.`
17044
15097
  );
17045
15098
  }
17046
- await assertContentHash(id, bytes, storedHash, "arweave");
15099
+ await assertContentHash(id, bytes, anchorHash ?? storedHash, "arweave");
17047
15100
  }
17048
15101
  this.logger?.log("dStorage/arweave", `Retrieved txId: ${id}`);
17049
15102
  return { bytes, tags };
@@ -17167,14 +15220,19 @@ async function getTurboFactory() {
17167
15220
  return TurboFactory;
17168
15221
  }
17169
15222
  var ARWEAVE_GATEWAY_URL = "https://turbo-gateway.com";
15223
+ var DEFAULT_REQUEST_TIMEOUT_MS = 3e4;
15224
+ var DEFAULT_MAX_METADATA_RESPONSE_BYTES = 1024 * 1024;
15225
+ var DEFAULT_MAX_RETRIEVE_SIZE_BYTES = 256 * 1024 * 1024;
17170
15226
  var ArweaveBundlerStorageAdapter = class _ArweaveBundlerStorageAdapter {
17171
15227
  constructor(config = {}) {
17172
15228
  this.name = "arweave_bundler";
17173
15229
  this.providerName = "Arweave (Bundler)";
17174
15230
  this.signingServerUrl = config.signingServerUrl ? config.signingServerUrl.replace(/\/$/, "") : null;
17175
15231
  this.gateway = config.gateway ?? ARWEAVE_GATEWAY_URL;
17176
- this.maxRetrieveSizeBytes = config.maxRetrieveSizeBytes ?? 256 * 1024 * 1024;
15232
+ this.maxRetrieveSizeBytes = config.maxRetrieveSizeBytes ?? DEFAULT_MAX_RETRIEVE_SIZE_BYTES;
17177
15233
  this.skipIntegrityCheck = config.skipIntegrityCheck ?? false;
15234
+ this.requestTimeoutMs = config.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
15235
+ this.maxMetadataResponseBytes = config.maxMetadataResponseBytes ?? DEFAULT_MAX_METADATA_RESPONSE_BYTES;
17178
15236
  this.logger = config.logger;
17179
15237
  if (config.signingServerUrl) {
17180
15238
  if (!config.authToken?.trim()) {
@@ -17225,8 +15283,13 @@ var ArweaveBundlerStorageAdapter = class _ArweaveBundlerStorageAdapter {
17225
15283
  );
17226
15284
  return { id: txId, provider: this.name, url, uploadedAt: Date.now() };
17227
15285
  }
15286
+ /** Adds an AbortSignal.timeout() to a fetch init object (when requestTimeoutMs > 0). */
15287
+ _withTimeout(init = {}) {
15288
+ const signal = this.requestTimeoutMs > 0 ? AbortSignal.timeout(this.requestTimeoutMs) : void 0;
15289
+ return { ...init, ...signal !== void 0 ? { signal } : {} };
15290
+ }
17228
15291
  // ── retrieve ───────────────────────────────────────────────────────────────────
17229
- async retrieve(id) {
15292
+ async retrieve(id, options) {
17230
15293
  if (!/^[A-Za-z0-9_-]{43}$/.test(id)) {
17231
15294
  throw new DStorageError(
17232
15295
  StorageErrorCode.ARWEAVE_BUNDLER_INVALID_TX_ID,
@@ -17236,29 +15299,37 @@ var ArweaveBundlerStorageAdapter = class _ArweaveBundlerStorageAdapter {
17236
15299
  let storedHash;
17237
15300
  const tags = {};
17238
15301
  if (!this.skipIntegrityCheck) {
17239
- const metaResp = await fetch(`${this.gateway}/tx/${id}`);
15302
+ const metaResp = await fetch(
15303
+ `${this.gateway}/tx/${id}`,
15304
+ this._withTimeout()
15305
+ );
17240
15306
  if (!metaResp.ok) {
17241
15307
  throw new DStorageError(
17242
15308
  StorageErrorCode.ARWEAVE_BUNDLER_TX_METADATA_FAILED,
17243
15309
  `[dStorage/arweave-bundler] Could not fetch transaction metadata for txId: ${id} \u2014 content hash cannot be verified. Set skipIntegrityCheck: true to bypass integrity checking for fully trusted gateways.`
17244
15310
  );
17245
15311
  }
17246
- const tx = await metaResp.json();
15312
+ const metaText = await readResponseTextWithLimit(metaResp, {
15313
+ maxBytes: this.maxMetadataResponseBytes,
15314
+ code: StorageErrorCode.ARWEAVE_BUNDLER_METADATA_TOO_LARGE,
15315
+ component: `[dStorage/arweave-bundler] retrieve(${id}) metadata`
15316
+ });
15317
+ const tx = JSON.parse(metaText);
17247
15318
  for (const tag of tx.tags ?? []) {
17248
15319
  const name = new TextDecoder().decode(_base64urlToBytes(tag.name));
17249
15320
  const value = new TextDecoder().decode(_base64urlToBytes(tag.value));
17250
15321
  tags[name] = value;
17251
15322
  if (name === CONTENT_HASH_TAG2) storedHash = value;
17252
15323
  }
17253
- if (!storedHash) {
15324
+ if (!options?.expectedContentHash && !storedHash) {
17254
15325
  throw new DStorageError(
17255
15326
  StorageErrorCode.ARWEAVE_BUNDLER_HASH_TAG_MISSING,
17256
- `[dStorage/arweave-bundler] ${CONTENT_HASH_TAG2} tag not found for txId: ${id}.
15327
+ `[dStorage/arweave-bundler] Cannot verify content integrity for txId: ${id} \u2014 no expectedContentHash anchor was provided and the ${CONTENT_HASH_TAG2} tag was not found.
17257
15328
  Set skipIntegrityCheck: true to bypass integrity checking for fully trusted gateways.`
17258
15329
  );
17259
15330
  }
17260
15331
  }
17261
- const resp = await fetch(`${this.gateway}/${id}`);
15332
+ const resp = await fetch(`${this.gateway}/${id}`, this._withTimeout());
17262
15333
  if (!resp.ok) {
17263
15334
  throw new DStorageError(
17264
15335
  StorageErrorCode.ARWEAVE_BUNDLER_RETRIEVE_HTTP_ERROR,
@@ -17283,8 +15354,14 @@ Check: https://viewblock.io/arweave/tx/${id}`
17283
15354
  `[dStorage/arweave-bundler] Downloaded ${bytes.byteLength} bytes for txId: ${id}, which exceeds the configured limit of ${this.maxRetrieveSizeBytes} bytes.`
17284
15355
  );
17285
15356
  }
17286
- if (!this.skipIntegrityCheck && storedHash) {
17287
- await assertContentHash(id, bytes, storedHash, "arweave-bundler");
15357
+ const anchorHash = options?.expectedContentHash;
15358
+ if (!this.skipIntegrityCheck && (anchorHash || storedHash)) {
15359
+ await assertContentHash(
15360
+ id,
15361
+ bytes,
15362
+ anchorHash ?? storedHash,
15363
+ "arweave-bundler"
15364
+ );
17288
15365
  }
17289
15366
  this.logger?.log("dStorage/arweave-bundler", `Retrieved txId: ${id}`);
17290
15367
  return { bytes, tags };
@@ -17731,8 +15808,8 @@ var ArweaveLocalError = class extends Error {
17731
15808
  }
17732
15809
  };
17733
15810
 
17734
- // ../chain/dist/chunk-BK2EFMQI.mjs
17735
- init_chunk_AGLD4HA4();
15811
+ // ../chain/dist/chunk-5EPK5N7O.mjs
15812
+ init_chunk_XMWGGIPS();
17736
15813
  init_dist();
17737
15814
  var refs = /* @__PURE__ */ new Map();
17738
15815
  var commitments = /* @__PURE__ */ new Map();
@@ -17894,7 +15971,7 @@ var MockChainAdapter = class {
17894
15971
  };
17895
15972
 
17896
15973
  // ../chain/dist/index.mjs
17897
- init_chunk_AGLD4HA4();
15974
+ init_chunk_XMWGGIPS();
17898
15975
  init_dist();
17899
15976
  init_dist();
17900
15977
  init_dist();
@@ -18102,6 +16179,8 @@ var MidnightSimulatorChainAdapter = class {
18102
16179
  }
18103
16180
  };
18104
16181
  var COMPONENT = "[dStorage/http-gateway-chain]";
16182
+ var DEFAULT_REQUEST_TIMEOUT_MS2 = 3e4;
16183
+ var DEFAULT_MAX_RESPONSE_BYTES = 10 * 1024 * 1024;
18105
16184
  function generateRefId2() {
18106
16185
  const id = typeof crypto !== "undefined" && typeof crypto.randomUUID === "function" ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(36).slice(2)}`;
18107
16186
  return `ref_${id}`;
@@ -18117,6 +16196,13 @@ var HttpGatewayChainAdapter = class {
18117
16196
  this.readUrl = `${config.baseUrl}${config.readPath}`;
18118
16197
  this.listUrl = `${config.baseUrl}${config.listPath}`;
18119
16198
  this.deleteUrl = `${config.baseUrl}${config.deletePath}`;
16199
+ this.requestTimeoutMs = config.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS2;
16200
+ this.maxResponseBytes = config.maxResponseBytes ?? DEFAULT_MAX_RESPONSE_BYTES;
16201
+ }
16202
+ /** Adds an AbortSignal.timeout() to a fetch init object (when requestTimeoutMs > 0). */
16203
+ _withTimeout(init) {
16204
+ const signal = this.requestTimeoutMs > 0 ? AbortSignal.timeout(this.requestTimeoutMs) : void 0;
16205
+ return { ...init, ...signal !== void 0 ? { signal } : {} };
18120
16206
  }
18121
16207
  async writeReference(ref) {
18122
16208
  const { ownerSecret: _omit, ...payload } = ref;
@@ -18124,11 +16210,17 @@ var HttpGatewayChainAdapter = class {
18124
16210
  const url = `${this.writeUrl}/${encodeURIComponent(refId)}`;
18125
16211
  let res;
18126
16212
  try {
18127
- res = await this.fetchFn(url, {
18128
- method: "POST",
18129
- headers: { "Content-Type": "application/json", ...this.extraHeaders },
18130
- body: JSON.stringify(payload)
18131
- });
16213
+ res = await this.fetchFn(
16214
+ url,
16215
+ this._withTimeout({
16216
+ method: "POST",
16217
+ headers: {
16218
+ "Content-Type": "application/json",
16219
+ ...this.extraHeaders
16220
+ },
16221
+ body: JSON.stringify(payload)
16222
+ })
16223
+ );
18132
16224
  } catch (err) {
18133
16225
  throw new DStorageError(
18134
16226
  ChainErrorCode.GATEWAY_WRITE_FAILED,
@@ -18154,11 +16246,17 @@ var HttpGatewayChainAdapter = class {
18154
16246
  const url = `${this.writeUrl}/${encodeURIComponent(refId)}`;
18155
16247
  let res;
18156
16248
  try {
18157
- res = await this.fetchFn(url, {
18158
- method: "POST",
18159
- headers: { "Content-Type": "application/json", ...this.extraHeaders },
18160
- body: JSON.stringify(update)
18161
- });
16249
+ res = await this.fetchFn(
16250
+ url,
16251
+ this._withTimeout({
16252
+ method: "POST",
16253
+ headers: {
16254
+ "Content-Type": "application/json",
16255
+ ...this.extraHeaders
16256
+ },
16257
+ body: JSON.stringify(update)
16258
+ })
16259
+ );
18162
16260
  } catch (err) {
18163
16261
  throw new DStorageError(
18164
16262
  ChainErrorCode.GATEWAY_UPDATE_FAILED,
@@ -18179,7 +16277,10 @@ var HttpGatewayChainAdapter = class {
18179
16277
  const url = `${this.readUrl}/${encodeURIComponent(refId)}`;
18180
16278
  let res;
18181
16279
  try {
18182
- res = await this.fetchFn(url, { headers: { ...this.extraHeaders } });
16280
+ res = await this.fetchFn(
16281
+ url,
16282
+ this._withTimeout({ headers: { ...this.extraHeaders } })
16283
+ );
18183
16284
  } catch (err) {
18184
16285
  throw new DStorageError(
18185
16286
  ChainErrorCode.GATEWAY_READ_FAILED,
@@ -18194,9 +16295,14 @@ var HttpGatewayChainAdapter = class {
18194
16295
  { httpStatus: res.status }
18195
16296
  );
18196
16297
  }
16298
+ const text = await readResponseTextWithLimit(res, {
16299
+ maxBytes: this.maxResponseBytes,
16300
+ code: ChainErrorCode.GATEWAY_READ_RESPONSE_TOO_LARGE,
16301
+ component: `${COMPONENT} readReference`
16302
+ });
18197
16303
  let data;
18198
16304
  try {
18199
- data = await res.json();
16305
+ data = JSON.parse(text);
18200
16306
  } catch {
18201
16307
  throw new DStorageError(
18202
16308
  ChainErrorCode.GATEWAY_READ_INVALID_JSON,
@@ -18215,9 +16321,10 @@ var HttpGatewayChainAdapter = class {
18215
16321
  async listReferences() {
18216
16322
  let res;
18217
16323
  try {
18218
- res = await this.fetchFn(this.listUrl, {
18219
- headers: { ...this.extraHeaders }
18220
- });
16324
+ res = await this.fetchFn(
16325
+ this.listUrl,
16326
+ this._withTimeout({ headers: { ...this.extraHeaders } })
16327
+ );
18221
16328
  } catch (err) {
18222
16329
  throw new DStorageError(
18223
16330
  ChainErrorCode.GATEWAY_LIST_FAILED,
@@ -18232,9 +16339,14 @@ var HttpGatewayChainAdapter = class {
18232
16339
  { httpStatus: res.status }
18233
16340
  );
18234
16341
  }
16342
+ const text = await readResponseTextWithLimit(res, {
16343
+ maxBytes: this.maxResponseBytes,
16344
+ code: ChainErrorCode.GATEWAY_LIST_RESPONSE_TOO_LARGE,
16345
+ component: `${COMPONENT} listReferences`
16346
+ });
18235
16347
  let data;
18236
16348
  try {
18237
- data = await res.json();
16349
+ data = JSON.parse(text);
18238
16350
  } catch {
18239
16351
  throw new DStorageError(
18240
16352
  ChainErrorCode.GATEWAY_LIST_INVALID_JSON,
@@ -18267,11 +16379,17 @@ var HttpGatewayChainAdapter = class {
18267
16379
  const body = ownerSecret !== void 0 ? { ownerSecret: bytesToBase64url(ownerSecret) } : {};
18268
16380
  let res;
18269
16381
  try {
18270
- res = await this.fetchFn(url, {
18271
- method: "DELETE",
18272
- headers: { "Content-Type": "application/json", ...this.extraHeaders },
18273
- body: JSON.stringify(body)
18274
- });
16382
+ res = await this.fetchFn(
16383
+ url,
16384
+ this._withTimeout({
16385
+ method: "DELETE",
16386
+ headers: {
16387
+ "Content-Type": "application/json",
16388
+ ...this.extraHeaders
16389
+ },
16390
+ body: JSON.stringify(body)
16391
+ })
16392
+ );
18275
16393
  } catch (err) {
18276
16394
  throw new DStorageError(
18277
16395
  ChainErrorCode.GATEWAY_REMOVE_FAILED,
@@ -18318,16 +16436,16 @@ var NETWORKS = {
18318
16436
  networkId: "preprod",
18319
16437
  nodeHttp: "https://rpc.preprod.midnight.network",
18320
16438
  nodeWs: "wss://rpc.preprod.midnight.network",
18321
- indexerHttp: "https://indexer.preprod.midnight.network/api/v3/graphql",
18322
- indexerWs: "wss://indexer.preprod.midnight.network/api/v3/graphql/ws",
16439
+ indexerHttp: "https://indexer.preprod.midnight.network/api/v4/graphql",
16440
+ indexerWs: "wss://indexer.preprod.midnight.network/api/v4/graphql/ws",
18323
16441
  proofServer: "http://127.0.0.1:6300"
18324
16442
  },
18325
16443
  undeployed: {
18326
16444
  networkId: "undeployed",
18327
16445
  nodeHttp: "http://127.0.0.1:9944",
18328
16446
  nodeWs: "ws://127.0.0.1:9944",
18329
- indexerHttp: "http://127.0.0.1:8088/api/v3/graphql",
18330
- indexerWs: "ws://127.0.0.1:8088/api/v3/graphql/ws",
16447
+ indexerHttp: "http://127.0.0.1:8088/api/v4/graphql",
16448
+ indexerWs: "ws://127.0.0.1:8088/api/v4/graphql/ws",
18331
16449
  proofServer: "http://127.0.0.1:6300"
18332
16450
  }
18333
16451
  };
@@ -18737,7 +16855,7 @@ var MidnightChainAdapter = class _MidnightChainAdapter {
18737
16855
  } else {
18738
16856
  providers = await this._buildWalletProviderMode();
18739
16857
  }
18740
- const { DataRegistryAPI: DataRegistryAPI2 } = await Promise.resolve().then(() => (init_contract_api_TJ7JPHZA(), contract_api_TJ7JPHZA_exports));
16858
+ const { DataRegistryAPI: DataRegistryAPI2 } = await Promise.resolve().then(() => (init_contract_api_NUY4UEKE(), contract_api_NUY4UEKE_exports));
18741
16859
  if (!this._contractAddress) {
18742
16860
  this.logger?.log("dStorage/midnight", "Deploying DataRegistry contract\u2026");
18743
16861
  this._api = await DataRegistryAPI2.deploy(providers, this.logger);
@@ -19276,6 +17394,7 @@ var MidnightChainAdapter = class _MidnightChainAdapter {
19276
17394
  mlkemUnwrapDek,
19277
17395
  mlkemWrapDek,
19278
17396
  parseKeyEnvelope,
17397
+ readResponseTextWithLimit,
19279
17398
  serializeKeyEnvelope,
19280
17399
  serializeXChaChaPayload,
19281
17400
  unwrapKey,