1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
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
|