Unggahan awal

This commit is contained in:
rizky_denianto committed 2026-09-01 23:19:26 +07:00
1 parent 7915065d1c
commit 8c96423e9b
19 files changed
+686

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
[registry]
default = "gitea"
[registries.gitea]
index = "sparse+https://git.segubi.com/api/packages/segubi/cargo/"
+37
View File
@@ -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
+17
View File
@@ -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
+33
View File
@@ -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"] }
+8
View File
@@ -0,0 +1,8 @@
const COMMANDS: &[&str] = &["autentikasi"];
fn main() {
tauri_plugin::Builder::new(COMMANDS)
.android_path("android")
.ios_path("ios")
.build();
}
+5
View File
@@ -0,0 +1,5 @@
import { invoke } from '@tauri-apps/api/core'
export async function autentikasi(): Promise<[null]> {
return await invoke<[null]>("");
}
+33
View File
@@ -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"
}
}
@@ -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"]
+43
View File
@@ -0,0 +1,43 @@
## Default Permission
Default permissions for the plugin
#### This default permission set includes the following:
- `allow-autentikasi`
## Permission Table
<table>
<tr>
<th>Identifier</th>
<th>Description</th>
</tr>
<tr>
<td>
`auth:allow-autentikasi`
</td>
<td>
Enables the autentikasi command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`auth:deny-autentikasi`
</td>
<td>
Denies the autentikasi command without any pre-configured scope.
</td>
</tr>
</table>
+3
View File
@@ -0,0 +1,3 @@
[default]
description = "Default permissions for the plugin"
permissions = ["allow-autentikasi"]
+318
View File
@@ -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 `<h4>` 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 `<h4>` 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`"
}
]
}
}
}
+31
View File
@@ -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 || {})
]
}
+9
View File
@@ -0,0 +1,9 @@
use tauri::{AppHandle, Runtime, command};
use crate::AuthExt;
use crate::Result;
#[command]
pub(crate) async fn autentikasi<R: Runtime>(app: AppHandle<R>) -> Result<Vec<()>> {
return app.auth().autentikasi();
}
+18
View File
@@ -0,0 +1,18 @@
use serde::de::DeserializeOwned;
use tauri::{AppHandle, Runtime, plugin::PluginApi};
pub fn init<R: Runtime, C: DeserializeOwned>(
app: &AppHandle<R>,
_api: PluginApi<R, C>,
) -> crate::Result<Auth<R>> {
Ok(Auth(app.clone()))
}
/// Access to the auth APIs.
pub struct Auth<R: Runtime>(AppHandle<R>);
impl<R: Runtime> Auth<R> {
pub fn autentikasi(&self) -> crate::Result<Vec<()>> {
return Ok(vec![]);
}
}
+21
View File
@@ -0,0 +1,21 @@
use serde::{ser::Serializer, Serialize};
pub type Result<T> = std::result::Result<T, Error>;
#[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<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_str(self.to_string().as_ref())
}
}
+46
View File
@@ -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<R: Runtime> {
fn auth(&self) -> &Auth<R>;
}
impl<R: Runtime, T: Manager<R>> crate::AuthExt<R> for T {
fn auth(&self) -> &Auth<R> {
self.state::<Auth<R>>().inner()
}
}
/// Initializes the plugin.
pub fn init<R: Runtime>() -> TauriPlugin<R> {
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()
}
+31
View File
@@ -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<R: Runtime, C: DeserializeOwned>(
_app: &AppHandle<R>,
api: PluginApi<R, C>,
) -> crate::Result<Auth<R>> {
#[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<R: Runtime>(PluginHandle<R>);
impl<R: Runtime> Auth<R> {
pub fn autentikasi(&self) -> crate::Result<Vec<()>> {
return self.0.run_mobile_plugin("autentikasi").map_err(Into::into);
}
}
+1
View File
@@ -0,0 +1 @@
+14
View File
@@ -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"]
}