Skip to content

Commit aa68246

Browse files
committed
1 parent bf586de commit aa68246

12 files changed

Lines changed: 244 additions & 44 deletions

File tree

.github/workflows/checks.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ jobs:
88
build_all:
99
name: Build All
1010
runs-on: [nix]
11+
permissions:
12+
# contents: read # to checkout the git repo
13+
pages: write
14+
id-token: write # Required for actions/deploy-pages
1115
steps:
1216
- name: git checkout
1317
uses: actions/checkout@v4
@@ -20,3 +24,11 @@ jobs:
2024
--no-update-lock-file \
2125
--print-build-logs \
2226
--show-trace
27+
nix build '.#doc' --no-update-lock-file
28+
29+
- name: Upload Artifact
30+
uses: actions/upload-pages-artifact@v3
31+
with:
32+
path: result/share/doc/
33+
- uses: actions/deploy-pages@v4
34+
# if: ${{ github.ref_name == 'v0' }}

doc/auth.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Authentication
2+
3+
TODO

doc/index.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Long-form API Docs
2+
3+
## Disclaimers
4+
5+
### Unstable
6+
7+
This crate and the API behind it are unstable in a number of ways:
8+
9+
1. The API of this crate may be broken at any time.
10+
2. This crate may expose experimental interfaces and services which are completely unsupported. There is no indication of which interfaces these are. Both the Rust APIs and the backing APIs and implementations may change at any time with no notice.
11+
12+
### Support
13+
14+
No support is provided for this code or for the API directly. However, if you are experiencing issues with your Obscura VPN service please contact <support@obscura.net>.
15+
16+
## Guides
17+
18+
- [Auth](crate::doc::auth).
19+
- [Payments](crate::doc::payments).

doc/payments.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Payments
2+
3+
TODO

flake.nix

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,35 @@
55
nixpkgs.url = "nixpkgs/nixos-25.05";
66
};
77

8-
outputs = { self, crane, nixpkgs, flake-utils }:
8+
outputs = { self, crane, nixpkgs, flake-utils }@inputs:
99
flake-utils.lib.eachDefaultSystem (system:
1010
let
11-
pkgs = import nixpkgs { inherit system; };
12-
craneLib = crane.mkLib pkgs;
11+
nixpkgs = import inputs.nixpkgs { inherit system; };
12+
inherit (nixpkgs) lib pkgs;
13+
craneLib = crane.mkLib nixpkgs;
1314

1415
depsArgs = {
15-
src = craneLib.cleanCargoSource self;
16+
src = lib.fileset.toSource {
17+
root = ./.;
18+
fileset = lib.fileset.unions [
19+
./about.toml
20+
./Cargo.lock
21+
./Cargo.toml
22+
./doc
23+
./rust-toolchain.toml
24+
./rustfmt.toml
25+
./src
26+
];
27+
};
1628
strictDeps = true;
1729
};
1830
cargoArgs = depsArgs // { cargoArtifacts = craneLib.buildDepsOnly depsArgs; };
31+
32+
doc = craneLib.cargoDoc (cargoArgs // { RUSTDOCFLAGS = "-Dwarnings"; });
1933
in {
2034
checks = {
35+
inherit doc;
36+
2137
actionlint = pkgs.runCommand "actionlint" { nativeBuildInputs = [ pkgs.actionlint ]; } ''
2238
actionlint -config-file ${./.github}/actionlint.yml ${./.github}/**/*.yml
2339
touch "$out"
@@ -52,5 +68,7 @@
5268
export OBSCURA_MAGIC_IN_NIX_SHELL=1
5369
'';
5470
};
71+
72+
packages = { inherit doc; };
5573
});
5674
}

src/cmd/lightning/create.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ pub struct LightningTopUpInfo {
1212

1313
#[derive(Debug, Serialize, Deserialize, Clone)]
1414
pub struct CreateLightningTopUp {
15+
/// The amount of months to purchase.
16+
///
17+
/// This must be an allowed value from the [`/api/prices` endpoint](crate::cmd::ListPrices).
1518
pub months: u16,
1619

1720
/// Sale ID for this price.
1821
///
19-
/// If specified it *must* apply to this price or the request will be rejected.
22+
/// If specified it *must* apply to this price or the request will be rejected with [`SaleNotFound`](crate::cmd::ApiErrorKind::SaleNotFound).
2023
pub sale: Option<SaleId>,
2124
}
2225

src/cmd/monero/check.rs

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,42 @@ pub struct CheckMoneroTopUpInfo {
1818
#[derive(Debug, Serialize, Deserialize, Clone)]
1919
#[serde(rename_all = "snake_case")]
2020
pub enum MoneroPaymentStatus {
21-
Unpaid,
22-
PartiallyPaid,
21+
/// A sufficient payment is detected but is awaiting confirmation.
2322
Confirming,
24-
Paid,
23+
24+
/// This top-up has expired.
25+
///
26+
/// This top-up is expired and must not be used. Create a new top-up to fund your account.
27+
///
28+
/// This is a terminal state.
2529
Expired,
30+
31+
/// The top-up has failed.
32+
///
33+
/// This is a terminal state. Contact support to see if we can help you.
2634
Failed,
35+
36+
/// The top-up has succeeded.
37+
///
38+
/// The account has been credited.
39+
///
40+
/// This is a terminal state.
41+
Paid,
42+
43+
/// A payment is detected but it isn't sufficient.
44+
///
45+
/// This is a terminal state. Contact support to see if we can help you.
46+
PartiallyPaid,
47+
48+
/// Base state, no activity detected.
49+
Unpaid,
2750
}
2851

52+
/// A Monero top-up ID
53+
///
54+
/// This is used both in the API and can be used when contacting support. This is the main payment reference and should be retained in case any issues come up.
55+
///
56+
/// The first 4 characters can be used when contacting support, the full ID must be used with the API.
2957
#[derive(Debug, Serialize, Deserialize, Clone)]
3058
pub struct MoneroTopUpId(pub String);
3159

src/cmd/monero/create.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,16 @@ pub struct MoneroTopUpInfo {
1212

1313
#[derive(Debug, Serialize, Deserialize, Clone)]
1414
pub struct CreateMoneroTopUp {
15+
/// The amount of months to purchase.
16+
///
17+
/// This must be at least 3 and an allowed value from the [`/api/prices` endpoint](crate::cmd::ListPrices).
18+
///
19+
// TODO: https://linear.app/soveng/issue/OBS-3809/indicate-in-api-what-month-amounts-are-allowed-for-monero
1520
pub months: u16,
21+
22+
/// Sale ID for this price.
23+
///
24+
/// If specified it *must* apply to this price or the request will be rejected with [`SaleNotFound`](crate::cmd::ApiErrorKind::SaleNotFound).
1625
pub sale: Option<SaleId>,
1726
}
1827

src/doc.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#![doc = include_str!("../doc/index.md")]
2+
3+
#[doc = include_str!("../doc/auth.md")]
4+
pub mod auth {}
5+
#[doc = include_str!("../doc/payments.md")]
6+
pub mod payments {}

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ extern crate core;
33

44
pub mod check;
55
pub mod cmd;
6+
pub mod doc;
7+
pub mod time;
68
pub mod token;
79
pub mod types;
810
pub mod wg_conf;

0 commit comments

Comments
 (0)