summaryrefslogtreecommitdiff
path: root/src/client/Disfluid-0.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/Disfluid-0.h')
-rw-r--r--src/client/Disfluid-0.h126
1 files changed, 126 insertions, 0 deletions
diff --git a/src/client/Disfluid-0.h b/src/client/Disfluid-0.h
new file mode 100644
index 0000000..52afe0c
--- /dev/null
+++ b/src/client/Disfluid-0.h
@@ -0,0 +1,126 @@
+// disfluid, implementation of the Solid specification
+// Copyright (C) 2020, 2021 Vivien Kraus
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+#ifndef H_DISFLUID_INCLUDED
+#define H_DISFLUID_INCLUDED
+
+#include <stdlib.h>
+
+/**
+ * DisfluidApi:
+ *
+ * The context associated with the API is loaded when entering the
+ * @disfluid_init function, and unloaded when the function exits.
+ */
+struct DisfluidApi;
+typedef struct DisfluidApi DisfluidApi;
+
+/**
+ * DisfluidUser:
+ *
+ * @data: (closure):
+ *
+ * The type of function that is called with the API loaded.
+ */
+typedef void *(*DisfluidUser) (const struct DisfluidApi * api, void *data);
+
+/**
+ * disfluid_api_init:
+ *
+ * @func: (scope call) (not nullable): the function to call with the API loaded.
+ * @data: (closure func): the second argument for @func.
+ *
+ * Call @func in a context where the API function can be called. The
+ * API is unloaded when the function exits.
+ *
+ * Returns: (transfer none): the result of the callback.
+ */
+void *disfluid_api_init (DisfluidUser func, void *data);
+
+/**
+ * DisfluidClient: (unref-func disfluid_client_free):
+ *
+ * A client contains a client ID, redirection URI and an associated
+ * key pair.
+ */
+struct DisfluidClient;
+typedef struct DisfluidClient DisfluidClient;
+
+/**
+ * disfluid_client_make:
+ * @api: the context loaded with @disfluid_init.
+ * @client_id: the URI serving a client manifest on the web.
+ * @redirect_uri: the URI where we can get back an authorization code.
+ * @jwk: the JWK encoding of the key pair used by the client.
+ *
+ * Create a new client.
+ *
+ * Returns: (transfer full): the allocated client.
+ */
+struct DisfluidClient *disfluid_client_make (const struct DisfluidApi *api,
+ const char *client_id,
+ const char *redirect_uri,
+ const char *jwk);
+
+/**
+ * disfluid_client_free:
+ * @client: the client to free.
+ *
+ * Delete @client.
+ */
+void disfluid_client_free (struct DisfluidClient *client);
+
+/**
+ * disfluid_client_get_id:
+ * @api: the context API.
+ * @client: the client whose ID to lookup.
+ * @start: how many URL prefix bytes to skip.
+ * @max: how many URL bytes to copy after the skipped prefix.
+ * @id: (array length=max) (element-type char): where to copy the URL bytes.
+ * Returns: the total number of bytes in the URL.
+ */
+size_t disfluid_client_get_id (const struct DisfluidApi *api,
+ const struct DisfluidClient *client,
+ size_t start, size_t max, char *id);
+
+/**
+ * disfluid_client_get_redirect_uri:
+ * @api: the context API.
+ * @client: the client whose redirection URI to lookup.
+ * @start: how many URL prefix bytes to skip.
+ * @max: how many URL bytes to copy after the skipped prefix.
+ * @redirect_uri: (array length=max) (element-type char): where to copy the URL bytes.
+ * Returns: the total number of bytes in the URL.
+ */
+size_t disfluid_client_get_redirect_uri (const struct DisfluidApi *api,
+ const struct DisfluidClient *client,
+ size_t start, size_t max,
+ char *redirect_uri);
+
+/**
+ * disfluid_client_get_key_pair:
+ * @api: the context API.
+ * @client: the client whose key pair to dump.
+ * @start: how many JWK prefix bytes to skip.
+ * @max: how many JWK bytes to copy after the skipped prefix.
+ * @jwk: (array length=max) (element-type char): where to copy the JWK bytes.
+ * Returns: the total number of bytes in the JWK.
+ */
+size_t disfluid_client_get_key_pair (const struct DisfluidApi *api,
+ const struct DisfluidClient *client,
+ size_t start, size_t max, char *jwk);
+
+#endif