diff --git a/.cargo/config.toml b/.cargo/config.toml
new file mode 100644
index 0000000..8272c36
--- /dev/null
+++ b/.cargo/config.toml
@@ -0,0 +1,5 @@
+[registry]
+default = "gitea"
+
+[registries.gitea]
+index = "sparse+https://git.segubi.com/api/packages/segubi/cargo/"
diff --git a/.gitea/workflows/penerbitan.yml b/.gitea/workflows/penerbitan.yml
new file mode 100644
index 0000000..78bd263
--- /dev/null
+++ b/.gitea/workflows/penerbitan.yml
@@ -0,0 +1,37 @@
+name: Penerbitan Plugin
+
+on:
+ pull_request:
+ branches: ["main"]
+ types: ["opened", "synchronize"]
+
+jobs:
+ persiapan:
+ runs-on: ubuntu-latest
+ outputs:
+ organisasi: ${{ steps.var.outputs.organisasi }}
+ steps:
+ - name: Persiapan variabel
+ id: var
+ run: |
+ echo "organisasi=$(echo '${{ gitea.repository }}' | cut -d'/' -f1)" \
+ >> $GITEA_OUTPUT
+
+ penerbitan:
+ runs-on: ubuntu-latest
+ needs: persiapan
+ steps:
+ - name: Unduh program
+ uses: actions/checkout@v7
+ with:
+ fetch-depth: 0
+
+ - name: Unduh pnpm
+ uses: pnpm/setup@v2
+
+ - name: Unggah program
+ run: |
+ pnpm i
+ npm config set @${{ needs.persiapan.outputs.organisasi }}:registry=https://${{ vars.ALAMAT_GITEA }}/api/packages/${{ needs.persiapan.outputs.organisasi }}/npm/
+ npm config set -- '//${{ vars.ALAMAT_GITEA }}/api/packages/${{ needs.persiapan.outputs.organisasi }}/npm/:_authToken' "${{ secrets.GITEA_TOKEN }}"
+ npm publish
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..50d8e32
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,17 @@
+/.vs
+.DS_Store
+.Thumbs.db
+*.sublime*
+.idea/
+debug.log
+package-lock.json
+.vscode/settings.json
+yarn.lock
+
+/.tauri
+/target
+Cargo.lock
+node_modules/
+
+dist-js
+dist
diff --git a/Cargo.toml b/Cargo.toml
new file mode 100644
index 0000000..94f1ccd
--- /dev/null
+++ b/Cargo.toml
@@ -0,0 +1,33 @@
+[package]
+name = "tauri-plugin-auth"
+version = "0.1.0"
+authors = [ "Rizky Denianto" ]
+description = ""
+edition = "2024"
+rust-version = "1.98.0"
+exclude = ["/examples", "/dist-js", "/guest-js", "/node_modules"]
+links = "tauri-plugin-auth"
+
+[profile.release]
+lto = "fat"
+codegen-units = 1
+opt-level = 3
+panic = "abort"
+incremental = false
+strip = "symbols"
+debug = false
+
+[package.metadata.platforms.support]
+windows = { level = "full" }
+linux = { level = "full" }
+macos = { level = "none" }
+android = { level = "full" }
+ios = { level = "none" }
+
+[dependencies]
+tauri = { version = "2.11.5" }
+serde = "1.0"
+thiserror = "2"
+
+[build-dependencies]
+tauri-plugin = { version = "2.6.3", features = ["build"] }
diff --git a/build.rs b/build.rs
new file mode 100644
index 0000000..c9124b2
--- /dev/null
+++ b/build.rs
@@ -0,0 +1,8 @@
+const COMMANDS: &[&str] = &["autentikasi"];
+
+fn main() {
+ tauri_plugin::Builder::new(COMMANDS)
+ .android_path("android")
+ .ios_path("ios")
+ .build();
+}
diff --git a/guest-js/index.ts b/guest-js/index.ts
new file mode 100644
index 0000000..bf9ebba
--- /dev/null
+++ b/guest-js/index.ts
@@ -0,0 +1,5 @@
+import { invoke } from '@tauri-apps/api/core'
+
+export async function autentikasi(): Promise<[null]> {
+ return await invoke<[null]>("");
+}
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..4bb2cfc
--- /dev/null
+++ b/package.json
@@ -0,0 +1,33 @@
+{
+ "name": "tauri-plugin-auth-api",
+ "version": "0.1.0",
+ "author": "Rizky Denianto",
+ "description": "",
+ "type": "module",
+ "types": "./dist-js/index.d.ts",
+ "main": "./dist-js/index.cjs",
+ "module": "./dist-js/index.js",
+ "exports": {
+ "types": "./dist-js/index.d.ts",
+ "import": "./dist-js/index.js",
+ "require": "./dist-js/index.cjs"
+ },
+ "files": [
+ "dist-js",
+ "README.md"
+ ],
+ "scripts": {
+ "build": "rollup -c",
+ "prepublishOnly": "pnpm build",
+ "pretest": "pnpm build"
+ },
+ "dependencies": {
+ "@tauri-apps/api": "^2.11.1"
+ },
+ "devDependencies": {
+ "@rollup/plugin-typescript": "^12.3.0",
+ "rollup": "^4.63.1",
+ "typescript": "^6.0.3",
+ "tslib": "^2.8.1"
+ }
+}
diff --git a/permissions/autogenerated/commands/autentikasi.toml b/permissions/autogenerated/commands/autentikasi.toml
new file mode 100644
index 0000000..3bc72fc
--- /dev/null
+++ b/permissions/autogenerated/commands/autentikasi.toml
@@ -0,0 +1,13 @@
+# Automatically generated - DO NOT EDIT!
+
+"$schema" = "../../schemas/schema.json"
+
+[[permission]]
+identifier = "allow-autentikasi"
+description = "Enables the autentikasi command without any pre-configured scope."
+commands.allow = ["autentikasi"]
+
+[[permission]]
+identifier = "deny-autentikasi"
+description = "Denies the autentikasi command without any pre-configured scope."
+commands.deny = ["autentikasi"]
diff --git a/permissions/autogenerated/reference.md b/permissions/autogenerated/reference.md
new file mode 100644
index 0000000..e00bd04
--- /dev/null
+++ b/permissions/autogenerated/reference.md
@@ -0,0 +1,43 @@
+## Default Permission
+
+Default permissions for the plugin
+
+#### This default permission set includes the following:
+
+- `allow-autentikasi`
+
+## Permission Table
+
+
+
+| Identifier |
+Description |
+
+
+
+
+|
+
+`auth:allow-autentikasi`
+
+ |
+
+
+Enables the autentikasi command without any pre-configured scope.
+
+ |
+
+
+
+|
+
+`auth:deny-autentikasi`
+
+ |
+
+
+Denies the autentikasi command without any pre-configured scope.
+
+ |
+
+
diff --git a/permissions/default.toml b/permissions/default.toml
new file mode 100644
index 0000000..f5d7a6d
--- /dev/null
+++ b/permissions/default.toml
@@ -0,0 +1,3 @@
+[default]
+description = "Default permissions for the plugin"
+permissions = ["allow-autentikasi"]
diff --git a/permissions/schemas/schema.json b/permissions/schemas/schema.json
new file mode 100644
index 0000000..8208e01
--- /dev/null
+++ b/permissions/schemas/schema.json
@@ -0,0 +1,318 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "PermissionFile",
+ "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.",
+ "type": "object",
+ "properties": {
+ "default": {
+ "description": "The default permission set for the plugin",
+ "anyOf": [
+ {
+ "$ref": "#/definitions/DefaultPermission"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "set": {
+ "description": "A list of permissions sets defined",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/PermissionSet"
+ }
+ },
+ "permission": {
+ "description": "A list of inlined permissions",
+ "default": [],
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/Permission"
+ }
+ }
+ },
+ "definitions": {
+ "DefaultPermission": {
+ "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.",
+ "type": "object",
+ "required": [
+ "permissions"
+ ],
+ "properties": {
+ "version": {
+ "description": "The version of the permission.",
+ "type": [
+ "integer",
+ "null"
+ ],
+ "format": "uint64",
+ "minimum": 1.0
+ },
+ "description": {
+ "description": "Human-readable description of what the permission does. Tauri convention is to use `` headings in markdown content for Tauri documentation generation purposes.",
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "permissions": {
+ "description": "All permissions this set contains.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "PermissionSet": {
+ "description": "A set of direct permissions grouped together under a new name.",
+ "type": "object",
+ "required": [
+ "description",
+ "identifier",
+ "permissions"
+ ],
+ "properties": {
+ "identifier": {
+ "description": "A unique identifier for the permission.",
+ "type": "string"
+ },
+ "description": {
+ "description": "Human-readable description of what the permission does.",
+ "type": "string"
+ },
+ "permissions": {
+ "description": "All permissions this set contains.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/PermissionKind"
+ }
+ }
+ }
+ },
+ "Permission": {
+ "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.",
+ "type": "object",
+ "required": [
+ "identifier"
+ ],
+ "properties": {
+ "version": {
+ "description": "The version of the permission.",
+ "type": [
+ "integer",
+ "null"
+ ],
+ "format": "uint64",
+ "minimum": 1.0
+ },
+ "identifier": {
+ "description": "A unique identifier for the permission.",
+ "type": "string"
+ },
+ "description": {
+ "description": "Human-readable description of what the permission does. Tauri internal convention is to use `` headings in markdown content for Tauri documentation generation purposes.",
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "commands": {
+ "description": "Allowed or denied commands when using this permission.",
+ "default": {
+ "allow": [],
+ "deny": []
+ },
+ "allOf": [
+ {
+ "$ref": "#/definitions/Commands"
+ }
+ ]
+ },
+ "scope": {
+ "description": "Allowed or denied scoped when using this permission.",
+ "allOf": [
+ {
+ "$ref": "#/definitions/Scopes"
+ }
+ ]
+ },
+ "platforms": {
+ "description": "Target platforms this permission applies. By default all platforms are affected by this permission.",
+ "type": [
+ "array",
+ "null"
+ ],
+ "items": {
+ "$ref": "#/definitions/Target"
+ }
+ }
+ }
+ },
+ "Commands": {
+ "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.",
+ "type": "object",
+ "properties": {
+ "allow": {
+ "description": "Allowed command.",
+ "default": [],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "deny": {
+ "description": "Denied command, which takes priority.",
+ "default": [],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "Scopes": {
+ "description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```",
+ "type": "object",
+ "properties": {
+ "allow": {
+ "description": "Data that defines what is allowed by the scope.",
+ "type": [
+ "array",
+ "null"
+ ],
+ "items": {
+ "$ref": "#/definitions/Value"
+ }
+ },
+ "deny": {
+ "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.",
+ "type": [
+ "array",
+ "null"
+ ],
+ "items": {
+ "$ref": "#/definitions/Value"
+ }
+ }
+ }
+ },
+ "Value": {
+ "description": "All supported ACL values.",
+ "anyOf": [
+ {
+ "description": "Represents a null JSON value.",
+ "type": "null"
+ },
+ {
+ "description": "Represents a [`bool`].",
+ "type": "boolean"
+ },
+ {
+ "description": "Represents a valid ACL [`Number`].",
+ "allOf": [
+ {
+ "$ref": "#/definitions/Number"
+ }
+ ]
+ },
+ {
+ "description": "Represents a [`String`].",
+ "type": "string"
+ },
+ {
+ "description": "Represents a list of other [`Value`]s.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/Value"
+ }
+ },
+ {
+ "description": "Represents a map of [`String`] keys to [`Value`]s.",
+ "type": "object",
+ "additionalProperties": {
+ "$ref": "#/definitions/Value"
+ }
+ }
+ ]
+ },
+ "Number": {
+ "description": "A valid ACL number.",
+ "anyOf": [
+ {
+ "description": "Represents an [`i64`].",
+ "type": "integer",
+ "format": "int64"
+ },
+ {
+ "description": "Represents a [`f64`].",
+ "type": "number",
+ "format": "double"
+ }
+ ]
+ },
+ "Target": {
+ "description": "Platform target.",
+ "oneOf": [
+ {
+ "description": "MacOS.",
+ "type": "string",
+ "enum": [
+ "macOS"
+ ]
+ },
+ {
+ "description": "Windows.",
+ "type": "string",
+ "enum": [
+ "windows"
+ ]
+ },
+ {
+ "description": "Linux.",
+ "type": "string",
+ "enum": [
+ "linux"
+ ]
+ },
+ {
+ "description": "Android.",
+ "type": "string",
+ "enum": [
+ "android"
+ ]
+ },
+ {
+ "description": "iOS.",
+ "type": "string",
+ "enum": [
+ "iOS"
+ ]
+ }
+ ]
+ },
+ "PermissionKind": {
+ "type": "string",
+ "oneOf": [
+ {
+ "description": "Enables the autentikasi command without any pre-configured scope.",
+ "type": "string",
+ "const": "allow-autentikasi",
+ "markdownDescription": "Enables the autentikasi command without any pre-configured scope."
+ },
+ {
+ "description": "Denies the autentikasi command without any pre-configured scope.",
+ "type": "string",
+ "const": "deny-autentikasi",
+ "markdownDescription": "Denies the autentikasi command without any pre-configured scope."
+ },
+ {
+ "description": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-autentikasi`",
+ "type": "string",
+ "const": "default",
+ "markdownDescription": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-autentikasi`"
+ }
+ ]
+ }
+ }
+}
\ No newline at end of file
diff --git a/rollup.config.js b/rollup.config.js
new file mode 100644
index 0000000..8b4768f
--- /dev/null
+++ b/rollup.config.js
@@ -0,0 +1,31 @@
+import { readFileSync } from 'node:fs'
+import { dirname, join } from 'node:path'
+import { cwd } from 'node:process'
+import typescript from '@rollup/plugin-typescript'
+
+const pkg = JSON.parse(readFileSync(join(cwd(), 'package.json'), 'utf8'))
+
+export default {
+ input: 'guest-js/index.ts',
+ output: [
+ {
+ file: pkg.exports.import,
+ format: 'esm'
+ },
+ {
+ file: pkg.exports.require,
+ format: 'cjs'
+ }
+ ],
+ plugins: [
+ typescript({
+ declaration: true,
+ declarationDir: dirname(pkg.exports.import)
+ })
+ ],
+ external: [
+ /^@tauri-apps\/api/,
+ ...Object.keys(pkg.dependencies || {}),
+ ...Object.keys(pkg.peerDependencies || {})
+ ]
+}
diff --git a/src/commands.rs b/src/commands.rs
new file mode 100644
index 0000000..54c0590
--- /dev/null
+++ b/src/commands.rs
@@ -0,0 +1,9 @@
+use tauri::{AppHandle, Runtime, command};
+
+use crate::AuthExt;
+use crate::Result;
+
+#[command]
+pub(crate) async fn autentikasi(app: AppHandle) -> Result> {
+ return app.auth().autentikasi();
+}
diff --git a/src/desktop.rs b/src/desktop.rs
new file mode 100644
index 0000000..8f71e7d
--- /dev/null
+++ b/src/desktop.rs
@@ -0,0 +1,18 @@
+use serde::de::DeserializeOwned;
+use tauri::{AppHandle, Runtime, plugin::PluginApi};
+
+pub fn init(
+ app: &AppHandle,
+ _api: PluginApi,
+) -> crate::Result> {
+ Ok(Auth(app.clone()))
+}
+
+/// Access to the auth APIs.
+pub struct Auth(AppHandle);
+
+impl Auth {
+ pub fn autentikasi(&self) -> crate::Result> {
+ return Ok(vec![]);
+ }
+}
diff --git a/src/error.rs b/src/error.rs
new file mode 100644
index 0000000..895220d
--- /dev/null
+++ b/src/error.rs
@@ -0,0 +1,21 @@
+use serde::{ser::Serializer, Serialize};
+
+pub type Result = std::result::Result;
+
+#[derive(Debug, thiserror::Error)]
+pub enum Error {
+ #[error(transparent)]
+ Io(#[from] std::io::Error),
+ #[cfg(mobile)]
+ #[error(transparent)]
+ PluginInvoke(#[from] tauri::plugin::mobile::PluginInvokeError),
+}
+
+impl Serialize for Error {
+ fn serialize(&self, serializer: S) -> std::result::Result
+ where
+ S: Serializer,
+ {
+ serializer.serialize_str(self.to_string().as_ref())
+ }
+}
diff --git a/src/lib.rs b/src/lib.rs
new file mode 100644
index 0000000..c11c2e7
--- /dev/null
+++ b/src/lib.rs
@@ -0,0 +1,46 @@
+use tauri::{
+ Manager, Runtime,
+ plugin::{Builder, TauriPlugin},
+};
+
+#[cfg(desktop)]
+mod desktop;
+#[cfg(mobile)]
+mod mobile;
+
+mod commands;
+mod error;
+mod models;
+
+pub use error::{Error, Result};
+
+#[cfg(desktop)]
+use desktop::Auth;
+#[cfg(mobile)]
+use mobile::Auth;
+
+/// Extensions to [`tauri::App`], [`tauri::AppHandle`] and [`tauri::Window`] to access the auth APIs.
+pub trait AuthExt {
+ fn auth(&self) -> &Auth;
+}
+
+impl> crate::AuthExt for T {
+ fn auth(&self) -> &Auth {
+ self.state::>().inner()
+ }
+}
+
+/// Initializes the plugin.
+pub fn init() -> TauriPlugin {
+ Builder::new("auth")
+ .invoke_handler(tauri::generate_handler![commands::autentikasi])
+ .setup(|app, api| {
+ #[cfg(mobile)]
+ let auth = mobile::init(app, api)?;
+ #[cfg(desktop)]
+ let auth = desktop::init(app, api)?;
+ app.manage(auth);
+ Ok(())
+ })
+ .build()
+}
diff --git a/src/mobile.rs b/src/mobile.rs
new file mode 100644
index 0000000..8746200
--- /dev/null
+++ b/src/mobile.rs
@@ -0,0 +1,31 @@
+use serde::de::DeserializeOwned;
+use tauri::{
+ AppHandle, Runtime,
+ plugin::{PluginApi, PluginHandle},
+};
+
+use crate::models::*;
+
+#[cfg(target_os = "ios")]
+tauri::ios_plugin_binding!(init_plugin_auth);
+
+// initializes the Kotlin or Swift plugin classes
+pub fn init(
+ _app: &AppHandle,
+ api: PluginApi,
+) -> crate::Result> {
+ #[cfg(target_os = "android")]
+ let handle = api.register_android_plugin("", "ExamplePlugin")?;
+ #[cfg(target_os = "ios")]
+ let handle = api.register_ios_plugin(init_plugin_auth)?;
+ Ok(Auth(handle))
+}
+
+/// Access to the auth APIs.
+pub struct Auth(PluginHandle);
+
+impl Auth {
+ pub fn autentikasi(&self) -> crate::Result> {
+ return self.0.run_mobile_plugin("autentikasi").map_err(Into::into);
+ }
+}
diff --git a/src/models.rs b/src/models.rs
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/src/models.rs
@@ -0,0 +1 @@
+
diff --git a/tsconfig.json b/tsconfig.json
new file mode 100644
index 0000000..0591122
--- /dev/null
+++ b/tsconfig.json
@@ -0,0 +1,14 @@
+{
+ "compilerOptions": {
+ "target": "es2021",
+ "module": "esnext",
+ "moduleResolution": "bundler",
+ "skipLibCheck": true,
+ "strict": true,
+ "noUnusedLocals": true,
+ "noImplicitAny": true,
+ "noEmit": true
+ },
+ "include": ["guest-js/*.ts"],
+ "exclude": ["dist-js", "node_modules"]
+}