Add npm package for browser auth SDK and update WASM crate
- Add `sdk/npm/smbcloud-auth` with package.json, README, LICENSE, and build script for packaging the browser Auth SDK using wasm-pack - Add .gitignore and dist/ staging for generated WASM artifacts - Add LICENSE to `crates/smbcloud-networking-account-wasm` - Update description in `crates/smbcloud-networking-account-wasm/Cargo.toml` - Move Ruby gem files from `gems/` to `sdk/gems/` - Fix conditional import of `log::debug` in `smbcloud-network` for wasm targets
Seto Elkahfi committed
Mar 28, 2026 at 17:56 UTC
53639c0fd501169aa063f851d666cbd1d7fb7bea
29 files changed
+243
-2
crates/smbcloud-network/src/network.rs
+4
-1
@@ -1,5 +1,5 @@
1
use {
2
- log::{debug, error},
2
+ log::error,
3
reqwest::{RequestBuilder, Response, StatusCode},
4
serde::de::DeserializeOwned,
5
smbcloud_model::{
@@ -9,6 +9,9 @@ use {
9
},
10
};
11
12
+#[cfg(not(target_arch = "wasm32"))]
13
+use log::debug;
14
+
15
//use std::time::Duration;
16
#[cfg(debug_assertions)]
17
const LOG_RESPONSE_BODY: bool = true; // You know what to do here.
crates/smbcloud-networking-account-wasm/Cargo.toml
+1
-1
@@ -3,7 +3,7 @@ name = "smbcloud-networking-account-wasm"
3
version = "0.3.29"
4
edition = "2024"
5
authors = ["Seto Elkahfi <hej@setoelkahfi.se>"]
6
-description = "Command line tool for deploying NextJS app on the smbCloud platform."
6
+description = "smbCloud Auth sdk"
7
license = "Apache-2.0"
8
repository = "https://github.com/smbcloudXYZ/smbcloud-cli"
9
documentation = "https://docs.smbcloud.xyz/cli"
crates/smbcloud-networking-account-wasm/LICENSE
new
+21
@@ -0,0 +1,21 @@
1
+MIT License
2
+
3
+Copyright (c) 2026 smbCloud
4
+
5
+Permission is hereby granted, free of charge, to any person obtaining a copy
6
+of this software and associated documentation files (the "Software"), to deal
7
+in the Software without restriction, including without limitation the rights
8
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+copies of the Software, and to permit persons to whom the Software is
10
+furnished to do so, subject to the following conditions:
11
+
12
+The above copyright notice and this permission notice shall be included in all
13
+copies or substantial portions of the Software.
14
+
15
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+SOFTWARE.
sdk/gems/.keep
renamed
sdk/gems/model/.gitignore
renamed
sdk/gems/model/.ruby-version
renamed
sdk/gems/model/CHANGELOG.md
renamed
sdk/gems/model/Cargo.lock
renamed
sdk/gems/model/Cargo.toml
renamed
sdk/gems/model/Gemfile
renamed
sdk/gems/model/Gemfile.lock
renamed
sdk/gems/model/README.md
renamed
sdk/gems/model/Rakefile
renamed
sdk/gems/model/bin/console
renamed
sdk/gems/model/bin/setup
renamed
sdk/gems/model/ext/.keep
renamed
sdk/gems/model/ext/model/Cargo.toml
renamed
sdk/gems/model/ext/model/extconf.rb
renamed
sdk/gems/model/ext/model/src/lib.rs
renamed
sdk/gems/model/lib/model.rb
renamed
sdk/gems/model/lib/model/version.rb
renamed
sdk/gems/model/model.gemspec
renamed
sdk/gems/model/sig/model.rbs
renamed
sdk/npm/.keep
sdk/npm/smbcloud-auth/.gitignore
new
+5
@@ -0,0 +1,5 @@
1
+dist/
2
+smbcloud_networking_account_wasm.js
3
+smbcloud_networking_account_wasm.d.ts
4
+smbcloud_networking_account_wasm_bg.wasm
5
+smbcloud_networking_account_wasm_bg.wasm.d.ts
sdk/npm/smbcloud-auth/LICENSE
new
+21
@@ -0,0 +1,21 @@
1
+MIT License
2
+
3
+Copyright (c) 2026 smbCloud
4
+
5
+Permission is hereby granted, free of charge, to any person obtaining a copy
6
+of this software and associated documentation files (the "Software"), to deal
7
+in the Software without restriction, including without limitation the rights
8
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+copies of the Software, and to permit persons to whom the Software is
10
+furnished to do so, subject to the following conditions:
11
+
12
+The above copyright notice and this permission notice shall be included in all
13
+copies or substantial portions of the Software.
14
+
15
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+SOFTWARE.
sdk/npm/smbcloud-auth/README.md
new
+79
@@ -0,0 +1,79 @@
1
+<!-- LOGO -->
2
+<h1>
3
+<p align="center">
4
+ <img src="https://avatars.githubusercontent.com/u/89791739?s=200&v=4" alt="Logo" width="128">
5
+ <br>smbCloud SDK Auth
6
+</h1>
7
+ <p align="center">
8
+ Browser authentication SDK for smbCloud, built from Rust and WebAssembly.
9
+ <br />
10
+ <a href="README.md#about">About</a>
11
+ ·
12
+ <a href="README.md#install">Install</a>
13
+ ·
14
+ <a href="README.md#usage">Usage</a>
15
+ ·
16
+ <a href="README.md#license">License</a>
17
+ </p>
18
+</p>
19
+
20
+## About
21
+
22
+`@smbcloud/sdk-auth` is the browser SDK for smbCloud Auth. It wraps the shared Rust
23
+account crate through WebAssembly so browser apps can use the same auth
24
+contract as desktop and mobile clients.
25
+
26
+Current exported browser APIs include:
27
+
28
+- `signup_with_client`
29
+- `login_with_client`
30
+- `logout_with_client`
31
+- `me_with_client`
32
+- `remove_with_client`
33
+- `Environment`
34
+
35
+## Install
36
+
37
+```bash
38
+npm install @smbcloud/sdk-auth
39
+```
40
+
41
+## Usage
42
+
43
+```js
44
+import init, {
45
+ Environment,
46
+ login_with_client,
47
+ signup_with_client,
48
+} from "@smbcloud/sdk-auth";
49
+
50
+await init();
51
+
52
+await signup_with_client(
53
+ Environment.Production,
54
+ "app-id",
55
+ "app-secret",
56
+ "name@example.com",
57
+ "password123",
58
+);
59
+```
60
+
61
+## Local packaging
62
+
63
+From `sdk/npm/smbcloud-auth`:
64
+
65
+```bash
66
+npm run prepare:package
67
+npm run pack:dry-run
68
+```
69
+
70
+This builds the wasm crate, stages the generated artifacts into the npm package
71
+folder, and lets you verify the publish payload before release.
72
+
73
+## License
74
+
75
+MIT
76
+
77
+## Credits
78
+
79
+2026 [smbCloud](https://github.com/smbCloudXYZ). Built for [SplitFire AI](https://splitfire.ai).
sdk/npm/smbcloud-auth/package.json
new
+48
@@ -0,0 +1,48 @@
1
+{
2
+ "name": "@smbcloud/sdk-auth",
3
+ "description": "Browser Auth SDK for smbCloud, built from Rust and WebAssembly.",
4
+ "version": "0.3.29",
5
+ "type": "module",
6
+ "main": "dist/smbcloud_networking_account_wasm.js",
7
+ "module": "dist/smbcloud_networking_account_wasm.js",
8
+ "types": "dist/smbcloud_networking_account_wasm.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/smbcloud_networking_account_wasm.d.ts",
12
+ "default": "./dist/smbcloud_networking_account_wasm.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md",
18
+ "LICENSE"
19
+ ],
20
+ "keywords": [
21
+ "smbcloud",
22
+ "auth",
23
+ "wasm",
24
+ "sdk",
25
+ "browser"
26
+ ],
27
+ "license": "MIT",
28
+ "homepage": "https://github.com/smbcloudXYZ/smbcloud-cli/tree/main/sdk/npm/smbcloud-auth",
29
+ "bugs": {
30
+ "url": "https://github.com/smbcloudXYZ/smbcloud-cli/issues"
31
+ },
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/smbcloudXYZ/smbcloud-cli.git",
35
+ "directory": "sdk/npm/smbcloud-auth"
36
+ },
37
+ "sideEffects": [
38
+ "./snippets/*"
39
+ ],
40
+ "scripts": {
41
+ "prepare:package": "node ./prepare-package.mjs",
42
+ "pack:dry-run": "npm run prepare:package && npm pack --dry-run",
43
+ "publish:package": "npm run prepare:package && npm publish --access public"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ }
48
+}
sdk/npm/smbcloud-auth/prepare-package.mjs
new
+64
@@ -0,0 +1,64 @@
1
+import { cpSync, existsSync, mkdirSync, readFileSync, rmSync } from "node:fs";
2
+import { resolve } from "node:path";
3
+import { execFileSync } from "node:child_process";
4
+
5
+const packageDir = resolve(import.meta.dirname);
6
+const repoRoot = resolve(packageDir, "../../..");
7
+const crateDir = resolve(repoRoot, "crates/smbcloud-networking-account-wasm");
8
+const stageDir = resolve(repoRoot, "target/npm/sdk-auth");
9
+const distDir = resolve(packageDir, "dist");
10
+const npmPackageJsonPath = resolve(packageDir, "package.json");
11
+const cargoTomlPath = resolve(crateDir, "Cargo.toml");
12
+
13
+const stageFiles = [
14
+ "smbcloud_networking_account_wasm.js",
15
+ "smbcloud_networking_account_wasm.d.ts",
16
+ "smbcloud_networking_account_wasm_bg.wasm",
17
+ "smbcloud_networking_account_wasm_bg.wasm.d.ts",
18
+];
19
+
20
+const npmPackage = JSON.parse(readFileSync(npmPackageJsonPath, "utf8"));
21
+const cargoToml = readFileSync(cargoTomlPath, "utf8");
22
+const cargoVersionMatch = cargoToml.match(/^version\s*=\s*"([^"]+)"/m);
23
+
24
+if (!cargoVersionMatch) {
25
+ throw new Error(`Unable to find version in ${cargoTomlPath}`);
26
+}
27
+
28
+const crateVersion = cargoVersionMatch[1];
29
+const npmVersion = npmPackage.version;
30
+
31
+if (crateVersion !== npmVersion) {
32
+ throw new Error(
33
+ [
34
+ "Version mismatch for @smbcloud/sdk-auth.",
35
+ `npm package version: ${npmVersion}`,
36
+ `Rust crate version: ${crateVersion}`,
37
+ "Update sdk/npm/smbcloud-auth/package.json or crates/smbcloud-networking-account-wasm/Cargo.toml so they match before publishing.",
38
+ ].join("\n"),
39
+ );
40
+}
41
+
42
+rmSync(stageDir, { recursive: true, force: true });
43
+rmSync(distDir, { recursive: true, force: true });
44
+mkdirSync(stageDir, { recursive: true });
45
+mkdirSync(distDir, { recursive: true });
46
+
47
+execFileSync(
48
+ "wasm-pack",
49
+ ["build", crateDir, "--target", "web", "--out-dir", stageDir],
50
+ { cwd: repoRoot, stdio: "inherit" },
51
+);
52
+
53
+for (const file of stageFiles) {
54
+ const source = resolve(stageDir, file);
55
+ const destination = resolve(distDir, file);
56
+
57
+ if (!existsSync(source)) {
58
+ throw new Error(`Missing generated artifact: ${source}`);
59
+ }
60
+
61
+ cpSync(source, destination);
62
+}
63
+
64
+console.log("Prepared @smbcloud/sdk-auth package in", packageDir);