Skip to content

Commit 4459d2f

Browse files
authored
Merge pull request hyperledger-indy#822 from Artemkaaas/wallet-service
Inmemory wallet storage
2 parents d0f11e2 + 12da371 commit 4459d2f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2209
-1808
lines changed

libindy/include/indy_non_secrets.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ extern "C" {
1616
/// tags_json: the record tags used for search and storing meta information as json:
1717
/// {
1818
/// "tagName1": <str>, // string tag (will be stored encrypted)
19-
/// "tagName2": <int>, // int tag (will be stored encrypted)
19+
/// "tagName2": <str>, // string tag (will be stored encrypted)
2020
/// "~tagName3": <str>, // string tag (will be stored un-encrypted)
21-
/// "~tagName4": <int>, // int tag (will be stored un-encrypted)
21+
/// "~tagName4": <str>, // string tag (will be stored un-encrypted)
2222
/// }
2323
/// Note that null means no tags
2424
/// If tag name starts with "~" the tag will be stored un-encrypted that will allow
@@ -63,9 +63,9 @@ extern "C" {
6363
/// tags_json: the record tags used for search and storing meta information as json:
6464
/// {
6565
/// "tagName1": <str>, // string tag (will be stored encrypted)
66-
/// "tagName2": <int>, // int tag (will be stored encrypted)
66+
/// "tagName2": <str>, // string tag (will be stored encrypted)
6767
/// "~tagName3": <str>, // string tag (will be stored un-encrypted)
68-
/// "~tagName4": <int>, // int tag (will be stored un-encrypted)
68+
/// "~tagName4": <str>, // string tag (will be stored un-encrypted)
6969
/// }
7070
/// If tag name starts with "~" the tag will be stored un-encrypted that will allow
7171
/// usage of this tag in complex search queries (comparison, predicates)
@@ -90,9 +90,9 @@ extern "C" {
9090
/// tags_json: the record tags used for search and storing meta information as json:
9191
/// {
9292
/// "tagName1": <str>, // string tag (will be stored encrypted)
93-
/// "tagName2": <int>, // int tag (will be stored encrypted)
93+
/// "tagName2": <str>, // string tag (will be stored encrypted)
9494
/// "~tagName3": <str>, // string tag (will be stored un-encrypted)
95-
/// "~tagName4": <int>, // int tag (will be stored un-encrypted)
95+
/// "~tagName4": <str>, // string tag (will be stored un-encrypted)
9696
/// }
9797
/// If tag name starts with "~" the tag will be stored un-encrypted that will allow
9898
/// usage of this tag in complex search queries (comparison, predicates)
@@ -190,7 +190,7 @@ extern "C" {
190190
/// "tagName": "tagValue",
191191
/// $or: {
192192
/// "tagName2": { $regex: 'pattern' },
193-
/// "tagName3": { $gte: 123 },
193+
/// "tagName3": { $gte: '123' },
194194
/// },
195195
/// }
196196
/// options_json: //TODO: FIXME: Think about replacing by bitmaks

libindy/include/indy_wallet.h

Lines changed: 129 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,61 +5,143 @@
55
extern "C" {
66
#endif
77

8-
/// Registers custom wallet implementation.
8+
/// Registers custom wallet storage implementation.
99
///
1010
/// It allows library user to provide custom wallet implementation.
1111
///
1212
/// #Params
1313
/// command_handle: Command handle to map callback to caller context.
14-
/// xtype: Wallet type name.
14+
/// type_: Wallet type name.
1515
/// create: WalletType create operation handler
1616
/// open: WalletType open operation handler
17-
/// set: Wallet set operation handler
18-
/// get: Wallet get operation handler
19-
/// get_not_expired: Wallet get_not_expired operation handler
20-
/// list: Wallet list operation handler
2117
/// close: Wallet close operation handler
2218
/// delete: WalletType delete operation handler
19+
/// add_record: WalletType add record operation handler
20+
/// update_record_value: WalletType update record value operation handler
21+
/// update_record_tags: WalletType update record tags operation handler
22+
/// add_record_tags: WalletType add record tags operation handler
23+
/// delete_record_tags: WalletType delete record tags operation handler
24+
/// delete_record: WalletType delete record operation handler
25+
/// get_record: WalletType get record operation handler
26+
/// get_record_id: WalletType get record id operation handler
27+
/// get_record_type: WalletType get record type operation handler
28+
/// get_record_value: WalletType get record value operation handler
29+
/// get_record_tags: WalletType get record tags operation handler
30+
/// free_record: WalletType free record operation handler
31+
/// search_records: WalletType search records operation handler
32+
/// search_all_records: WalletType search all records operation handler
33+
/// get_search_total_count: WalletType get search total count operation handler
34+
/// fetch_search_next_record: WalletType fetch search next record operation handler
35+
/// free_search: WalletType free search operation handler
2336
/// free: Handler that allows to de-allocate strings allocated in caller code
2437
///
2538
/// #Returns
2639
/// Error code
2740

2841

2942
extern indy_error_t indy_register_wallet_type(indy_handle_t command_handle,
30-
const char* xtype,
43+
const char* type_,
3144
indy_error_t (*createFn)(const char* name,
32-
const char* config,
33-
const char* credentials),
45+
const char* config,
46+
const char* credentials_json,
47+
const char* metadata),
3448

3549
indy_error_t (*openFn)(const char* name,
3650
const char* config,
3751
const char* runtime_config,
3852
const char* credentials,
3953
indy_handle_t* handle),
4054

41-
indy_error_t (*setFn)(indy_handle_t handle,
42-
const char* key,
43-
const char* value),
44-
45-
indy_error_t (*getFn)(indy_handle_t handle,
46-
const char* key,
47-
const char ** const value_ptr),
48-
49-
indy_error_t (*getNotExpiredFn)(indy_handle_t handle,
50-
const char* key,
51-
const char ** const value_ptr),
52-
53-
indy_error_t (*listFn)(indy_handle_t handle,
54-
const char* key,
55-
const char ** const values_json_ptr),
56-
5755
indy_error_t (*closeFn)(indy_handle_t handle),
56+
5857
indy_error_t (*deleteFn)(const char* name,
5958
const char* config,
6059
const char* credentials),
6160

62-
indy_error_t (*freeFn)(indy_handle_t handle, const char* str),
61+
indy_error_t (*addRecordFn)(indy_handle_t handle,
62+
const char* type_,
63+
const char* id,
64+
const indy_u8_t * value,
65+
indy_u32_t value_len,
66+
const char* tags_json),
67+
68+
indy_error_t (*updateRecordValueFn)(indy_handle_t handle,
69+
const char* type_,
70+
const char* id,
71+
const indy_u8_t * value,
72+
indy_u32_t value_len),
73+
74+
indy_error_t (*updateRecordTagsFn)(indy_handle_t handle,
75+
const char* type_,
76+
const char* id,
77+
const char* tags_json),
78+
79+
indy_error_t (*addRecordTagsFn)(indy_handle_t handle,
80+
const char* type_,
81+
const char* id,
82+
const char* tags_json),
83+
84+
indy_error_t (*deleteRecordTagsFn)(indy_handle_t handle,
85+
const char* type_,
86+
const char* id,
87+
const char* tags_names),
88+
89+
indy_error_t (*deleteRecordFn)(indy_handle_t handle,
90+
const char* type_,
91+
const char* id),
92+
93+
indy_error_t (*getRecordFn)(indy_handle_t handle,
94+
const char* type_,
95+
const char* id,
96+
const char* options_json,
97+
int32_t* record_handle), // TODO: clarify mutable param
98+
99+
indy_error_t (*getRecordIdFn)(indy_handle_t handle,
100+
indy_handle_t record_handle,
101+
char* id),
102+
103+
indy_error_t (*getRecordValueFn)(indy_handle_t handle,
104+
indy_handle_t record_handle,
105+
indy_u8_t * value,
106+
indy_u32_t value_len),
107+
108+
indy_error_t (*getRecordTagsFn)(indy_handle_t handle,
109+
indy_handle_t record_handle,
110+
char* tags_json),
111+
112+
indy_error_t (*freeRecordFn)(indy_handle_t handle,
113+
indy_handle_t record_handle),
114+
115+
indy_error_t (*getStorageMetadataFn)(indy_handle_t handle,
116+
char* metadata,
117+
indy_handle_t metadata_handle),
118+
119+
indy_error_t (*setStorageMetadataFn)(indy_handle_t handle,
120+
const char* metadata),
121+
122+
indy_error_t (*freeStorageMetadataFn)(indy_handle_t handle,
123+
indy_handle_t metadata_handle),
124+
125+
indy_error_t (*openSearchFn)(indy_handle_t handle,
126+
const char* type_,
127+
const char* query,
128+
const char* options,
129+
int32_t* search_handle),
130+
131+
indy_error_t (*openSearchAllFn)(indy_handle_t handle,
132+
indy_handle_t search_handle),
133+
134+
indy_error_t (*getSearchTotalCountFn)(indy_handle_t handle,
135+
indy_handle_t search_handle,
136+
indy_u32_t* total_count),
137+
138+
indy_error_t (*fetchSearchNextRecordsFn)(indy_handle_t handle,
139+
indy_handle_t search_handle,
140+
indy_handle_t record_handle),
141+
142+
indy_error_t (*freeSearchFn)(indy_handle_t handle,
143+
indy_handle_t search_handle),
144+
63145
void (*fn)(indy_handle_t xcommand_handle, indy_error_t err)
64146
);
65147

@@ -72,8 +154,13 @@ extern "C" {
72154
/// Custom types can be registered with indy_register_wallet_type call.
73155
/// config(optional): Wallet configuration json. List of supported keys are defined by wallet type.
74156
/// if NULL, then default config will be used.
75-
/// credentials(optional): Wallet credentials json. List of supported keys are defined by wallet type.
76-
/// if NULL, then default config will be used.
157+
/// credentials: Wallet credentials json
158+
/// {
159+
/// "key": string,
160+
/// "rekey": Optional<string>,
161+
/// "storage": Optional<object> List of supported keys are defined by wallet type.
162+
///
163+
/// }
77164
///
78165
/// #Returns
79166
/// Error code
@@ -102,8 +189,13 @@ extern "C" {
102189
/// "freshness_time": string (optional), Amount of minutes to consider wallet value as fresh. Defaults to 24*60.
103190
/// ... List of additional supported keys are defined by wallet type.
104191
/// }
105-
/// credentials(optional): Wallet credentials json. List of supported keys are defined by wallet type.
106-
/// if NULL, then default credentials will be used.
192+
/// credentials: Wallet credentials json
193+
/// {
194+
/// "key": string,
195+
/// "rekey": Optional<string>,
196+
/// "storage": Optional<object> List of supported keys are defined by wallet type.
197+
///
198+
/// }
107199
///
108200
/// #Returns
109201
/// Handle to opened wallet to use in methods that require wallet access.
@@ -145,8 +237,13 @@ extern "C" {
145237
///
146238
/// #Params
147239
/// name: Name of the wallet to delete.
148-
/// credentials(optional): Wallet credentials json. List of supported keys are defined by wallet type.
149-
/// if NULL, then default credentials will be used.
240+
/// credentials: Wallet credentials json
241+
/// {
242+
/// "key": string,
243+
/// "rekey": Optional<string>,
244+
/// "storage": Optional<object> List of supported keys are defined by wallet type.
245+
///
246+
/// }
150247
///
151248
/// #Returns
152249
/// Error code

libindy/src/api/non_secrets.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ use self::libc::c_char;
2020
/// tags_json: the record tags used for search and storing meta information as json:
2121
/// {
2222
/// "tagName1": <str>, // string tag (will be stored encrypted)
23-
/// "tagName2": <int>, // int tag (will be stored encrypted)
23+
/// "tagName2": <str>, // string tag (will be stored encrypted)
2424
/// "~tagName3": <str>, // string tag (will be stored un-encrypted)
25-
/// "~tagName4": <int>, // int tag (will be stored un-encrypted)
25+
/// "~tagName4": <str>, // string tag (will be stored un-encrypted)
2626
/// }
2727
/// Note that null means no tags
2828
/// If tag name starts with "~" the tag will be stored un-encrypted that will allow
@@ -123,9 +123,9 @@ pub extern fn indy_update_wallet_record_value(command_handle: i32,
123123
/// tags_json: the record tags used for search and storing meta information as json:
124124
/// {
125125
/// "tagName1": <str>, // string tag (will be stored encrypted)
126-
/// "tagName2": <int>, // int tag (will be stored encrypted)
126+
/// "tagName2": <str>, // string tag (will be stored encrypted)
127127
/// "~tagName3": <str>, // string tag (will be stored un-encrypted)
128-
/// "~tagName4": <int>, // int tag (will be stored un-encrypted)
128+
/// "~tagName4": <str>, // string tag (will be stored un-encrypted)
129129
/// }
130130
/// If tag name starts with "~" the tag will be stored un-encrypted that will allow
131131
/// usage of this tag in complex search queries (comparison, predicates)
@@ -177,9 +177,9 @@ pub extern fn indy_update_wallet_record_tags(command_handle: i32,
177177
/// tags_json: the record tags used for search and storing meta information as json:
178178
/// {
179179
/// "tagName1": <str>, // string tag (will be stored encrypted)
180-
/// "tagName2": <int>, // int tag (will be stored encrypted)
180+
/// "tagName2": <str>, // string tag (will be stored encrypted)
181181
/// "~tagName3": <str>, // string tag (will be stored un-encrypted)
182-
/// "~tagName4": <int>, // int tag (will be stored un-encrypted)
182+
/// "~tagName4": <str>, // string tag (will be stored un-encrypted)
183183
/// }
184184
/// If tag name starts with "~" the tag will be stored un-encrypted that will allow
185185
/// usage of this tag in complex search queries (comparison, predicates)
@@ -384,7 +384,7 @@ pub extern fn indy_get_wallet_record(command_handle: i32,
384384
/// "tagName": "tagValue",
385385
/// $or: {
386386
/// "tagName2": { $regex: 'pattern' },
387-
/// "tagName3": { $gte: 123 },
387+
/// "tagName3": { $gte: '123' },
388388
/// },
389389
/// }
390390
/// options_json: //TODO: FIXME: Think about replacing by bitmaks
@@ -448,7 +448,7 @@ pub extern fn indy_open_wallet_search(command_handle: i32,
448448
/// #Returns
449449
/// wallet records json:
450450
/// {
451-
/// totalCount: <int>, // present only if retrieveTotalCount set to true
451+
/// totalCount: <str>, // present only if retrieveTotalCount set to true
452452
/// records: [{ // present only if retrieveRecords set to true
453453
/// id: "Some id",
454454
/// type: "Some type", // present only if retrieveType set to true

0 commit comments

Comments
 (0)