create-sia-app 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +179 -0
- package/package.json +29 -0
- package/template/CLAUDE.md +160 -0
- package/template/README.md +102 -0
- package/template/_gitignore +5 -0
- package/template/biome.json +40 -0
- package/template/index.html +13 -0
- package/template/package.json +30 -0
- package/template/rust/README.md +16 -0
- package/template/rust/sia-sdk-rs/.changeset/added_cancel_function_to_cancel_inflight_packed_uploads.md +6 -0
- package/template/rust/sia-sdk-rs/.changeset/check_if_we_have_enough_hosts_prior_to_encoding_in_upload_slabs.md +16 -0
- package/template/rust/sia-sdk-rs/.changeset/fix_slab_length_in_packed_object.md +5 -0
- package/template/rust/sia-sdk-rs/.changeset/fix_upload_racing_race_conditon.md +13 -0
- package/template/rust/sia-sdk-rs/.changeset/improved_parallelism_of_packed_uploads.md +5 -0
- package/template/rust/sia-sdk-rs/.changeset/progress_callback_will_now_be_called_as_expected_for_packed_uploads.md +5 -0
- package/template/rust/sia-sdk-rs/.github/dependabot.yml +10 -0
- package/template/rust/sia-sdk-rs/.github/workflows/main.yml +36 -0
- package/template/rust/sia-sdk-rs/.github/workflows/prepare-release.yml +34 -0
- package/template/rust/sia-sdk-rs/.github/workflows/release.yml +30 -0
- package/template/rust/sia-sdk-rs/.rustfmt.toml +4 -0
- package/template/rust/sia-sdk-rs/Cargo.lock +4127 -0
- package/template/rust/sia-sdk-rs/Cargo.toml +3 -0
- package/template/rust/sia-sdk-rs/LICENSE +21 -0
- package/template/rust/sia-sdk-rs/README.md +30 -0
- package/template/rust/sia-sdk-rs/indexd/CHANGELOG.md +79 -0
- package/template/rust/sia-sdk-rs/indexd/Cargo.toml +79 -0
- package/template/rust/sia-sdk-rs/indexd/benches/upload.rs +258 -0
- package/template/rust/sia-sdk-rs/indexd/src/app_client.rs +1710 -0
- package/template/rust/sia-sdk-rs/indexd/src/builder.rs +354 -0
- package/template/rust/sia-sdk-rs/indexd/src/download.rs +379 -0
- package/template/rust/sia-sdk-rs/indexd/src/hosts.rs +659 -0
- package/template/rust/sia-sdk-rs/indexd/src/lib.rs +827 -0
- package/template/rust/sia-sdk-rs/indexd/src/mock.rs +162 -0
- package/template/rust/sia-sdk-rs/indexd/src/object_encryption.rs +125 -0
- package/template/rust/sia-sdk-rs/indexd/src/quic.rs +575 -0
- package/template/rust/sia-sdk-rs/indexd/src/rhp4.rs +52 -0
- package/template/rust/sia-sdk-rs/indexd/src/slabs.rs +497 -0
- package/template/rust/sia-sdk-rs/indexd/src/upload.rs +629 -0
- package/template/rust/sia-sdk-rs/indexd/src/wasm_time.rs +41 -0
- package/template/rust/sia-sdk-rs/indexd/src/web_transport.rs +398 -0
- package/template/rust/sia-sdk-rs/indexd_ffi/CHANGELOG.md +76 -0
- package/template/rust/sia-sdk-rs/indexd_ffi/Cargo.toml +47 -0
- package/template/rust/sia-sdk-rs/indexd_ffi/examples/python/README.md +10 -0
- package/template/rust/sia-sdk-rs/indexd_ffi/examples/python/example.py +130 -0
- package/template/rust/sia-sdk-rs/indexd_ffi/src/bin/uniffi-bindgen.rs +3 -0
- package/template/rust/sia-sdk-rs/indexd_ffi/src/builder.rs +377 -0
- package/template/rust/sia-sdk-rs/indexd_ffi/src/io.rs +155 -0
- package/template/rust/sia-sdk-rs/indexd_ffi/src/lib.rs +1039 -0
- package/template/rust/sia-sdk-rs/indexd_ffi/src/logging.rs +58 -0
- package/template/rust/sia-sdk-rs/indexd_ffi/src/tls.rs +23 -0
- package/template/rust/sia-sdk-rs/indexd_wasm/Cargo.toml +33 -0
- package/template/rust/sia-sdk-rs/indexd_wasm/src/lib.rs +818 -0
- package/template/rust/sia-sdk-rs/knope.toml +54 -0
- package/template/rust/sia-sdk-rs/sia_derive/CHANGELOG.md +38 -0
- package/template/rust/sia-sdk-rs/sia_derive/Cargo.toml +19 -0
- package/template/rust/sia-sdk-rs/sia_derive/src/lib.rs +278 -0
- package/template/rust/sia-sdk-rs/sia_sdk/CHANGELOG.md +91 -0
- package/template/rust/sia-sdk-rs/sia_sdk/Cargo.toml +59 -0
- package/template/rust/sia-sdk-rs/sia_sdk/benches/merkle_root.rs +12 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/blake2.rs +22 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/consensus.rs +767 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/encoding/v1.rs +257 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/encoding/v2.rs +291 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/encoding.rs +26 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/encoding_async/v2.rs +367 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/encoding_async.rs +6 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/encryption.rs +303 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/erasure_coding.rs +347 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/lib.rs +15 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/macros.rs +435 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/merkle.rs +112 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/rhp/merkle.rs +357 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/rhp/rpc.rs +1507 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/rhp/types.rs +146 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/rhp.rs +7 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/seed.rs +278 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/signing.rs +236 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/types/common.rs +677 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/types/currency.rs +450 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/types/specifier.rs +110 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/types/spendpolicy.rs +778 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/types/utils.rs +117 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/types/v1.rs +1737 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/types/v2.rs +1726 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/types/work.rs +59 -0
- package/template/rust/sia-sdk-rs/sia_sdk/src/types.rs +16 -0
- package/template/scripts/setup-rust.js +29 -0
- package/template/src/App.tsx +13 -0
- package/template/src/components/DevNote.tsx +21 -0
- package/template/src/components/auth/ApproveScreen.tsx +84 -0
- package/template/src/components/auth/AuthFlow.tsx +77 -0
- package/template/src/components/auth/ConnectScreen.tsx +214 -0
- package/template/src/components/auth/LoadingScreen.tsx +8 -0
- package/template/src/components/auth/RecoveryScreen.tsx +182 -0
- package/template/src/components/upload/UploadZone.tsx +314 -0
- package/template/src/index.css +9 -0
- package/template/src/lib/constants.ts +8 -0
- package/template/src/lib/format.ts +35 -0
- package/template/src/lib/hex.ts +13 -0
- package/template/src/lib/sdk.ts +25 -0
- package/template/src/lib/wasm-env.ts +5 -0
- package/template/src/main.tsx +12 -0
- package/template/src/stores/auth.ts +86 -0
- package/template/tsconfig.app.json +31 -0
- package/template/tsconfig.json +7 -0
- package/template/tsconfig.node.json +26 -0
- package/template/vite.config.ts +18 -0
- package/template/wasm/indexd_wasm/indexd_wasm.d.ts +309 -0
- package/template/wasm/indexd_wasm/indexd_wasm.js +1507 -0
- package/template/wasm/indexd_wasm/indexd_wasm_bg.wasm +0 -0
- package/template/wasm/indexd_wasm/package.json +31 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/// helper module for base64 serialization
|
|
2
|
+
pub(crate) mod base64 {
|
|
3
|
+
use base64::Engine;
|
|
4
|
+
use base64::engine::general_purpose::STANDARD;
|
|
5
|
+
use serde::{Deserialize, Deserializer, Serializer};
|
|
6
|
+
|
|
7
|
+
pub fn serialize<S: Serializer>(v: &[u8], s: S) -> Result<S::Ok, S::Error> {
|
|
8
|
+
let base64 = STANDARD.encode(v);
|
|
9
|
+
s.serialize_str(&base64)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
pub fn deserialize<'de, D: Deserializer<'de>>(d: D) -> Result<Vec<u8>, D::Error> {
|
|
13
|
+
let base64 = String::deserialize(d)?;
|
|
14
|
+
STANDARD
|
|
15
|
+
.decode(base64.as_bytes())
|
|
16
|
+
.map_err(|e| serde::de::Error::custom(e.to_string()))
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
pub(crate) mod timestamp_array {
|
|
21
|
+
use core::fmt;
|
|
22
|
+
|
|
23
|
+
use chrono::{DateTime, FixedOffset, Utc};
|
|
24
|
+
use serde::de::{SeqAccess, Visitor};
|
|
25
|
+
use serde::{Deserializer, Serializer};
|
|
26
|
+
|
|
27
|
+
pub fn serialize<S>(timestamps: &[DateTime<Utc>; 11], serializer: S) -> Result<S::Ok, S::Error>
|
|
28
|
+
where
|
|
29
|
+
S: Serializer,
|
|
30
|
+
{
|
|
31
|
+
use serde::ser::SerializeSeq;
|
|
32
|
+
let mut seq = serializer.serialize_seq(Some(11))?;
|
|
33
|
+
for timestamp in timestamps {
|
|
34
|
+
let rfc3339_string = timestamp.to_rfc3339();
|
|
35
|
+
seq.serialize_element(&rfc3339_string)?;
|
|
36
|
+
}
|
|
37
|
+
seq.end()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
pub fn deserialize<'de, D>(deserializer: D) -> Result<[DateTime<Utc>; 11], D::Error>
|
|
41
|
+
where
|
|
42
|
+
D: Deserializer<'de>,
|
|
43
|
+
{
|
|
44
|
+
struct TimestampVisitor;
|
|
45
|
+
|
|
46
|
+
impl<'de> Visitor<'de> for TimestampVisitor {
|
|
47
|
+
type Value = [DateTime<Utc>; 11];
|
|
48
|
+
|
|
49
|
+
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
|
50
|
+
formatter.write_str("an array of 11 RC3339 timestamps")
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>
|
|
54
|
+
where
|
|
55
|
+
A: SeqAccess<'de>,
|
|
56
|
+
{
|
|
57
|
+
let mut timestamps = [DateTime::UNIX_EPOCH; 11];
|
|
58
|
+
|
|
59
|
+
let mut idx = 0;
|
|
60
|
+
while let Some(value) = seq.next_element::<String>()? {
|
|
61
|
+
if idx >= 11 {
|
|
62
|
+
return Err(serde::de::Error::custom("too many timestamps"));
|
|
63
|
+
}
|
|
64
|
+
timestamps[idx] = DateTime::<FixedOffset>::parse_from_rfc3339(&value)
|
|
65
|
+
.map(|dt| dt.to_utc())
|
|
66
|
+
.map_err(serde::de::Error::custom)?;
|
|
67
|
+
idx += 1;
|
|
68
|
+
}
|
|
69
|
+
Ok(timestamps)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
deserializer.deserialize_seq(TimestampVisitor)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/// Helper module for base64 serialization of `Vec<Vec<u8>>`.
|
|
77
|
+
pub(crate) mod vec_base64 {
|
|
78
|
+
use base64::Engine as _;
|
|
79
|
+
use base64::engine::general_purpose::STANDARD;
|
|
80
|
+
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
|
81
|
+
|
|
82
|
+
pub fn serialize<S>(v: &[Vec<u8>], serializer: S) -> Result<S::Ok, S::Error>
|
|
83
|
+
where
|
|
84
|
+
S: Serializer,
|
|
85
|
+
{
|
|
86
|
+
let encoded: Vec<String> = v.iter().map(|bytes| STANDARD.encode(bytes)).collect();
|
|
87
|
+
encoded.serialize(serializer)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
pub fn deserialize<'de, D>(deserializer: D) -> Result<Vec<Vec<u8>>, D::Error>
|
|
91
|
+
where
|
|
92
|
+
D: Deserializer<'de>,
|
|
93
|
+
{
|
|
94
|
+
let encoded: Vec<String> = Vec::deserialize(deserializer)?;
|
|
95
|
+
encoded
|
|
96
|
+
.into_iter()
|
|
97
|
+
.map(|s| STANDARD.decode(s).map_err(serde::de::Error::custom))
|
|
98
|
+
.collect()
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
pub(crate) mod nano_second_duration {
|
|
103
|
+
use chrono::Duration;
|
|
104
|
+
use serde::{Deserialize, Deserializer, Serializer};
|
|
105
|
+
|
|
106
|
+
pub fn serialize<S: Serializer>(v: &Duration, s: S) -> Result<S::Ok, S::Error> {
|
|
107
|
+
s.serialize_u64(
|
|
108
|
+
v.num_nanoseconds()
|
|
109
|
+
.ok_or(serde::ser::Error::custom("invalid duration"))? as u64,
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
pub fn deserialize<'de, D: Deserializer<'de>>(d: D) -> Result<Duration, D::Error> {
|
|
114
|
+
let nanos = u64::deserialize(d)?;
|
|
115
|
+
Ok(Duration::nanoseconds(nanos as i64))
|
|
116
|
+
}
|
|
117
|
+
}
|