+
+Denies the fetchProjectOverviewData command without any pre-configured scope.
+
+
+
+
+
+
+
+`revenue-cat:allow-getCustomersData`
+
+
+
+
+Enables the getCustomersData command without any pre-configured scope.
+
+
+
+
+
+
+
+`revenue-cat:deny-getCustomersData`
+
+
+
+
+Denies the getCustomersData command without any pre-configured scope.
+
+
+
+
+
+
+
+`revenue-cat:allow-ping`
+
+
+
+
+Enables the ping command without any pre-configured scope.
+
+
+
+
+
+
+
+`revenue-cat:deny-ping`
+
+
+
+
+Denies the ping command without any pre-configured scope.
+
+
+
+
diff --git a/plugins/tauri-plugin-revenue-cat/permissions/default.toml b/plugins/tauri-plugin-revenue-cat/permissions/default.toml
new file mode 100644
index 00000000..343220b9
--- /dev/null
+++ b/plugins/tauri-plugin-revenue-cat/permissions/default.toml
@@ -0,0 +1,3 @@
+[default]
+description = "Default permissions for the plugin"
+permissions = ["allow-ping", "allow-createCustomer", "allow-fetchProjectOverviewData", "allow-getCustomersData"]
diff --git a/plugins/tauri-plugin-revenue-cat/permissions/schemas/schema.json b/plugins/tauri-plugin-revenue-cat/permissions/schemas/schema.json
new file mode 100644
index 00000000..bccfc81c
--- /dev/null
+++ b/plugins/tauri-plugin-revenue-cat/permissions/schemas/schema.json
@@ -0,0 +1,345 @@
+{
+ "$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 createCustomer command without any pre-configured scope.",
+ "type": "string",
+ "const": "allow-createCustomer"
+ },
+ {
+ "description": "Denies the createCustomer command without any pre-configured scope.",
+ "type": "string",
+ "const": "deny-createCustomer"
+ },
+ {
+ "description": "Enables the fetchProjectOverviewData command without any pre-configured scope.",
+ "type": "string",
+ "const": "allow-fetchProjectOverviewData"
+ },
+ {
+ "description": "Denies the fetchProjectOverviewData command without any pre-configured scope.",
+ "type": "string",
+ "const": "deny-fetchProjectOverviewData"
+ },
+ {
+ "description": "Enables the getCustomersData command without any pre-configured scope.",
+ "type": "string",
+ "const": "allow-getCustomersData"
+ },
+ {
+ "description": "Denies the getCustomersData command without any pre-configured scope.",
+ "type": "string",
+ "const": "deny-getCustomersData"
+ },
+ {
+ "description": "Enables the ping command without any pre-configured scope.",
+ "type": "string",
+ "const": "allow-ping"
+ },
+ {
+ "description": "Denies the ping command without any pre-configured scope.",
+ "type": "string",
+ "const": "deny-ping"
+ },
+ {
+ "description": "Default permissions for the plugin",
+ "type": "string",
+ "const": "default"
+ }
+ ]
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugins/tauri-plugin-revenue-cat/rollup.config.js b/plugins/tauri-plugin-revenue-cat/rollup.config.js
new file mode 100644
index 00000000..d8343635
--- /dev/null
+++ b/plugins/tauri-plugin-revenue-cat/rollup.config.js
@@ -0,0 +1,31 @@
+import { readFileSync } from 'fs'
+import { join } from 'path'
+import { cwd } from '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: `./${pkg.exports.import.split('/')[0]}`
+ })
+ ],
+ external: [
+ /^@tauri-apps\/api/,
+ ...Object.keys(pkg.dependencies || {}),
+ ...Object.keys(pkg.peerDependencies || {})
+ ]
+}
diff --git a/plugins/tauri-plugin-revenue-cat/src/commands.rs b/plugins/tauri-plugin-revenue-cat/src/commands.rs
new file mode 100644
index 00000000..d3370cb1
--- /dev/null
+++ b/plugins/tauri-plugin-revenue-cat/src/commands.rs
@@ -0,0 +1,13 @@
+use tauri::{AppHandle, command, Runtime};
+
+use crate::models::*;
+use crate::Result;
+use crate::RevenueCatExt;
+
+#[command]
+pub(crate) async fn ping(
+ app: AppHandle,
+ payload: PingRequest,
+) -> Result {
+ app.revenue_cat().ping(payload)
+}
diff --git a/plugins/tauri-plugin-revenue-cat/src/desktop.rs b/plugins/tauri-plugin-revenue-cat/src/desktop.rs
new file mode 100644
index 00000000..6bde5951
--- /dev/null
+++ b/plugins/tauri-plugin-revenue-cat/src/desktop.rs
@@ -0,0 +1,22 @@
+use serde::de::DeserializeOwned;
+use tauri::{plugin::PluginApi, AppHandle, Runtime};
+
+use crate::models::*;
+
+pub fn init(
+ app: &AppHandle,
+ _api: PluginApi,
+) -> crate::Result> {
+ Ok(RevenueCat(app.clone()))
+}
+
+/// Access to the revenue-cat APIs.
+pub struct RevenueCat(AppHandle);
+
+impl RevenueCat {
+ pub fn ping(&self, payload: PingRequest) -> crate::Result {
+ Ok(PingResponse {
+ value: payload.value,
+ })
+ }
+}
diff --git a/plugins/tauri-plugin-revenue-cat/src/error.rs b/plugins/tauri-plugin-revenue-cat/src/error.rs
new file mode 100644
index 00000000..895220da
--- /dev/null
+++ b/plugins/tauri-plugin-revenue-cat/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/plugins/tauri-plugin-revenue-cat/src/lib.rs b/plugins/tauri-plugin-revenue-cat/src/lib.rs
new file mode 100644
index 00000000..e6daf4d2
--- /dev/null
+++ b/plugins/tauri-plugin-revenue-cat/src/lib.rs
@@ -0,0 +1,48 @@
+use tauri::{
+ plugin::{Builder, TauriPlugin},
+ Manager, Runtime,
+};
+
+pub use models::*;
+
+#[cfg(desktop)]
+mod desktop;
+#[cfg(mobile)]
+mod mobile;
+
+mod commands;
+mod error;
+mod models;
+
+pub use error::{Error, Result};
+
+#[cfg(desktop)]
+use desktop::RevenueCat;
+#[cfg(mobile)]
+use mobile::RevenueCat;
+
+/// Extensions to [`tauri::App`], [`tauri::AppHandle`] and [`tauri::Window`] to access the revenue-cat APIs.
+pub trait RevenueCatExt {
+ fn revenue_cat(&self) -> &RevenueCat;
+}
+
+impl> crate::RevenueCatExt for T {
+ fn revenue_cat(&self) -> &RevenueCat {
+ self.state::>().inner()
+ }
+}
+
+/// Initializes the plugin.
+pub fn init() -> TauriPlugin {
+ Builder::new("revenue-cat")
+ .invoke_handler(tauri::generate_handler![commands::ping])
+ .setup(|app, api| {
+ #[cfg(mobile)]
+ let revenue_cat = mobile::init(app, api)?;
+ #[cfg(desktop)]
+ let revenue_cat = desktop::init(app, api)?;
+ app.manage(revenue_cat);
+ Ok(())
+ })
+ .build()
+}
diff --git a/plugins/tauri-plugin-revenue-cat/src/mobile.rs b/plugins/tauri-plugin-revenue-cat/src/mobile.rs
new file mode 100644
index 00000000..105e5662
--- /dev/null
+++ b/plugins/tauri-plugin-revenue-cat/src/mobile.rs
@@ -0,0 +1,34 @@
+use serde::de::DeserializeOwned;
+use tauri::{
+ plugin::{PluginApi, PluginHandle},
+ AppHandle, Runtime,
+};
+
+use crate::models::*;
+
+#[cfg(target_os = "ios")]
+tauri::ios_plugin_binding!(init_plugin_revenue_cat);
+
+// 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("com.plugin.revenue-cat", "ExamplePlugin")?;
+ #[cfg(target_os = "ios")]
+ let handle = api.register_ios_plugin(init_plugin_revenue_cat)?;
+ Ok(RevenueCat(handle))
+}
+
+/// Access to the revenue-cat APIs.
+pub struct RevenueCat(PluginHandle);
+
+impl RevenueCat {
+ pub fn ping(&self, payload: PingRequest) -> crate::Result {
+ self
+ .0
+ .run_mobile_plugin("ping", payload)
+ .map_err(Into::into)
+ }
+}
diff --git a/plugins/tauri-plugin-revenue-cat/src/models.rs b/plugins/tauri-plugin-revenue-cat/src/models.rs
new file mode 100644
index 00000000..1b53e9e2
--- /dev/null
+++ b/plugins/tauri-plugin-revenue-cat/src/models.rs
@@ -0,0 +1,13 @@
+use serde::{Deserialize, Serialize};
+
+#[derive(Debug, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct PingRequest {
+ pub value: Option,
+}
+
+#[derive(Debug, Clone, Default, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct PingResponse {
+ pub value: Option,
+}
diff --git a/plugins/tauri-plugin-revenue-cat/tsconfig.json b/plugins/tauri-plugin-revenue-cat/tsconfig.json
new file mode 100644
index 00000000..05911227
--- /dev/null
+++ b/plugins/tauri-plugin-revenue-cat/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"]
+}