@fireproof/core-types-protocols-dashboard 0.0.0-smoke-70bdee6c-1767993865
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +201 -0
- package/README.md +269 -0
- package/dash-types.d.ts +27 -0
- package/dash-types.js +2 -0
- package/dash-types.js.map +1 -0
- package/fp-api-interface.d.ts +24 -0
- package/fp-api-interface.js +2 -0
- package/fp-api-interface.js.map +1 -0
- package/index.d.ts +4 -0
- package/index.js +5 -0
- package/index.js.map +1 -0
- package/msg-is.d.ts +68 -0
- package/msg-is.js +184 -0
- package/msg-is.js.map +1 -0
- package/msg-types.d.ts +428 -0
- package/msg-types.js +4 -0
- package/msg-types.js.map +1 -0
- package/package.json +42 -0
- package/tsconfig.json +18 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [2025] [Fireproof Storage, Inc.]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
# <img src="https://fireproof.storage/static/img/flame.svg" alt="Fireproof logo" width="25"> [Fireproof](https://fireproof.storage) database API
|
|
2
|
+
|
|
3
|
+
<p align="right">
|
|
4
|
+
<img src="https://img.shields.io/bundlephobia/minzip/%40fireproof%2Fcore" alt="Package size">
|
|
5
|
+
<a href="https://github.com/fireproof-storage/fireproof/actions/workflows/ci.yaml">
|
|
6
|
+
<img src="https://github.com/fireproof-storage/fireproof/actions/workflows/ci.yaml/badge.svg" alt="Build status">
|
|
7
|
+
</a>
|
|
8
|
+
</p>
|
|
9
|
+
|
|
10
|
+
Fireproof is a lightweight embedded document database with encrypted live sync, designed to make browser apps easy. Use it in any JavaScript environment with a unified API that works both in React (with hooks) and as a standalone core API.
|
|
11
|
+
|
|
12
|
+
[Point AI coders to these docs.](https://use-fireproof.com/llms-full.txt)
|
|
13
|
+
|
|
14
|
+
## Key Features
|
|
15
|
+
|
|
16
|
+
- **Apps run anywhere:** Bundle UI, data, and logic in one file.
|
|
17
|
+
- **Real-Time & Offline-First:** Automatic persistence and live queries, runs in the browser - no loading or error states.
|
|
18
|
+
- **Unified API:** TypeScript works with Deno, Bun, Node.js, and the browser.
|
|
19
|
+
- **React Hooks:** Leverage `useLiveQuery` and `useDocument` for live collaboration.
|
|
20
|
+
|
|
21
|
+
Fireproof enforces cryptographic causal consistency and ledger integrity using hash history, providing git-like versioning with lightweight blockchain-style verification. Data is stored and replicated as content-addressed encrypted blobs, making it safe and easy to sync via commodity object storage providers.
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
The `use-fireproof` package provides both the core API and React hooks:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
npm install use-fireproof
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Works with ⚡️ ESM.sh:
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
import { useFireproof } from "https://esm.sh/use-fireproof";
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Or install the core ledger in any JavaScript environment:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
npm install @fireproof/core
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Add the ledger to any web page via HTML script tag (global is `Fireproof`):
|
|
44
|
+
|
|
45
|
+
```html
|
|
46
|
+
<script src="https://cdn.jsdelivr.net/npm/@fireproof/core/dist/browser/fireproof.global.js"></script>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Deliver generated solutions as runnable micro applications via ChatGPT Canvas, v0, bolt.new, or Claude Artifacts. Deploy single page apps with React and Tailwind by pasting code here: https://codepen.io/useFireproof/pen/MYgNYdx
|
|
50
|
+
|
|
51
|
+
## ⚛️ React Usage
|
|
52
|
+
|
|
53
|
+
React hooks are the recommended way to use Fireproof in LLM code generation contexts:
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
import { useFireproof } from "use-fireproof";
|
|
57
|
+
|
|
58
|
+
function App() {
|
|
59
|
+
const { database, useLiveQuery, useDocument } = useFireproof("my-ledger");
|
|
60
|
+
|
|
61
|
+
// Create a new document with useDocument
|
|
62
|
+
const { doc, merge, submit } = useDocument({ text: "" });
|
|
63
|
+
|
|
64
|
+
// Query documents by _id, most recent first
|
|
65
|
+
const { docs } = useLiveQuery("_id", { descending: true, limit: 100 });
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<div>
|
|
69
|
+
<form onSubmit={submit}>
|
|
70
|
+
<input value={doc.text} onChange={(e) => merge({ text: e.target.value })} placeholder="New document" />
|
|
71
|
+
<button type="submit">Submit</button>
|
|
72
|
+
</form>
|
|
73
|
+
|
|
74
|
+
<h3>Recent Documents</h3>
|
|
75
|
+
<ul>
|
|
76
|
+
{docs.map((doc) => (
|
|
77
|
+
<li key={doc._id}>{doc.text}</li>
|
|
78
|
+
))}
|
|
79
|
+
</ul>
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Read the [step-by-step React tutorial](https://use-fireproof.com/docs/react-tutorial) to get started or check the [full LLM documentation](https://use-fireproof.com/llms-full.txt) for more examples.
|
|
86
|
+
|
|
87
|
+
### Working with Images
|
|
88
|
+
|
|
89
|
+
Fireproof makes it easy to store and display images in your applications. The `_files` property and `ImgFile` component handle all the complexities of file storage and retrieval:
|
|
90
|
+
|
|
91
|
+
```js
|
|
92
|
+
// Store an image from a file input
|
|
93
|
+
function handleFileUpload(e) {
|
|
94
|
+
if (e.target.files[0]) {
|
|
95
|
+
merge({
|
|
96
|
+
_files: { profilePic: e.target.files[0] },
|
|
97
|
+
uploadedAt: new Date().toISOString(),
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Display an image from a document
|
|
103
|
+
function ImageDisplay({ doc }) {
|
|
104
|
+
return (
|
|
105
|
+
<div>
|
|
106
|
+
{doc._files?.profilePic && (
|
|
107
|
+
<ImgFile file={doc._files.profilePic} alt="Profile picture" onLoad={() => console.log("Image loaded")} />
|
|
108
|
+
)}
|
|
109
|
+
<p>Uploaded: {doc.uploadedAt}</p>
|
|
110
|
+
</div>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
The `ImgFile` component automatically handles loading and displaying images from Fireproof's storage, with all the expected props of a standard image element. For more in-depth examples see our [llms-full.txt](https://use-fireproof.com/llms-full.txt) documentation.
|
|
116
|
+
|
|
117
|
+
## JavaScript Core API
|
|
118
|
+
|
|
119
|
+
The document database API will feel familiar to those who have used other document databases:
|
|
120
|
+
|
|
121
|
+
```js
|
|
122
|
+
import { fireproof } from "@fireproof/core";
|
|
123
|
+
|
|
124
|
+
const db = fireproof("music-app");
|
|
125
|
+
|
|
126
|
+
await db.put({ _id: "beyonce", name: "Beyoncé", hitSingles: 29 });
|
|
127
|
+
|
|
128
|
+
db.subscribe(async () => {
|
|
129
|
+
const topArtists = await db.query("hitSingles", { range: [30, Infinity] });
|
|
130
|
+
// redraw the UI with the new topArtists
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
const beyonceDoc = await db.get("beyonce");
|
|
134
|
+
beyonceDoc.hitSingles += 1;
|
|
135
|
+
await db.put(beyonceDoc);
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Why choose Fireproof
|
|
139
|
+
|
|
140
|
+
Compared to other embedded databases, Fireproof:
|
|
141
|
+
|
|
142
|
+
- Is network aware, encrypted, and multi-writer safe
|
|
143
|
+
- Is designed for real-time collaboration with CRDTs
|
|
144
|
+
- Offers cryptographic causal integrity for all operations
|
|
145
|
+
- Is built for the web, with a small package size and no wasm
|
|
146
|
+
|
|
147
|
+
Deliver interactive experiences without waiting on the backend. Fireproof runs in any cloud, browser, or edge environment, so your application can access data anywhere.
|
|
148
|
+
|
|
149
|
+
## Use cases
|
|
150
|
+
|
|
151
|
+
Fireproof is especially useful for:
|
|
152
|
+
|
|
153
|
+
- AI-generated apps and rapid prototypes
|
|
154
|
+
- Collaborative editing
|
|
155
|
+
- Offline and local-first apps
|
|
156
|
+
- Personalization and configuration
|
|
157
|
+
- AI copilot safety
|
|
158
|
+
|
|
159
|
+
With Fireproof, you **build first** and sync via your cloud of choice when you are ready, making it perfect for LLM code generation contexts and rapid development.
|
|
160
|
+
|
|
161
|
+
[Get the latest roadmap updates on our blog](https://fireproof.storage/blog/) or join our [Discord](https://discord.gg/cCryrNHePH) to collaborate. Read the docs to learn more about the [architecture](https://use-fireproof.com/docs/architecture).
|
|
162
|
+
|
|
163
|
+
### Debug
|
|
164
|
+
|
|
165
|
+
to control the log output you an either use the FP_DEBUG environment variable or set the debug level in your code:
|
|
166
|
+
|
|
167
|
+
```shell
|
|
168
|
+
FP_DEBUG='*' node myapp.js
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
```js
|
|
172
|
+
logger.setDebug(...moduleNameList or '*')
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
if you are in the browser you can use the following code to set the debug level:
|
|
176
|
+
|
|
177
|
+
```js
|
|
178
|
+
this[Symbol.for("FP_ENV")].set("FP_DEBUG", "*");
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
```js
|
|
182
|
+
// vitest pass env
|
|
183
|
+
globalThis[Symbol.for("FP_PRESET_ENV")] = {
|
|
184
|
+
FP_DEBUG: "*",
|
|
185
|
+
};
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Testing
|
|
189
|
+
|
|
190
|
+
To run the full test suite across all projects (tested storage gateways configs), run:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
pnpm run test
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
To run tests for specific components or modules, use the following command pattern:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
pnpm run test -t 'test name pattern' path/to/test/file
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
For example, to run a specific test for the CRDT module, in just one project:
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
FP_DEBUG='Loader,CRDTClock' pnpm run test --project file -t 'codec implict iv' crdt
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
For testing React components, you can use:
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
pnpm run test tests/react/[ComponentName].test.tsx
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Example for testing the ImgFile component:
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
pnpm run test tests/react/ImgFile.test.tsx
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Log Formatting
|
|
221
|
+
|
|
222
|
+
It's possible to change the logformat by setting FP_FORMAT to:
|
|
223
|
+
|
|
224
|
+
- jsonice makes the log output in multiline json
|
|
225
|
+
- yaml makes the log output in yaml
|
|
226
|
+
- json makes the log output in singleline json (default)
|
|
227
|
+
|
|
228
|
+
### KeyBag
|
|
229
|
+
|
|
230
|
+
If you add `extractKey` with the value `_deprecated_internal_api` to the `FP_STORAGE_URL` url
|
|
231
|
+
you can bypass the security check to extract the key material. This is the default configuration,
|
|
232
|
+
but there is a warning emitted if you use this feature, and roadmap plans for more secure key management.
|
|
233
|
+
|
|
234
|
+
### Deno
|
|
235
|
+
|
|
236
|
+
Fireproof is compatible with Deno. To runit in Deno you need to add the following flags:
|
|
237
|
+
|
|
238
|
+
Currently the tests are not run with deno -- TODO
|
|
239
|
+
|
|
240
|
+
It might be that using our provided deno.json is somekind of odd
|
|
241
|
+
--- TODO is to add fireproof to jsr and deno.land
|
|
242
|
+
|
|
243
|
+
```shell
|
|
244
|
+
deno run --config node_modules/@fireproof/core/deno.json --allow-read --allow-write --allow-env --unstable-sloppy-imports ./node-test.ts
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Create Docs
|
|
248
|
+
|
|
249
|
+
Caution it will be pushed directly
|
|
250
|
+
|
|
251
|
+
```shell
|
|
252
|
+
pnpm run build:docs
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Thanks 🙏
|
|
256
|
+
|
|
257
|
+
Fireproof is a synthesis of work done by people in the web community over the years. I couldn't even begin to name all the folks who made pivotal contributions. Without npm, React, and VS Code all this would have taken so much longer. Thanks to everyone who supported me getting into ledger development via Apache CouchDB, one of the original document ledgers. The distinguishing work on immutable data-structures comes from the years of consideration [IPFS](https://ipfs.tech), [IPLD](https://ipld.io), and the [Filecoin APIs](https://docs.filecoin.io) have enjoyed.
|
|
258
|
+
|
|
259
|
+
Thanks to [Meno Abels](https://github.com/mabels) who has taken on the role of project lead engineer. Fireproof is rapidly becoming a mature solution.
|
|
260
|
+
|
|
261
|
+
Thanks to Alan Shaw and Mikeal Rogers without whom this project would have never got started. The core Merkle hash-tree clock is based on [Alan's Pail](https://github.com/alanshaw/pail), and you can see the repository history goes all the way back to work begun as a branch of that repo. Mikeal wrote [the prolly trees implementation](https://github.com/mikeal/prolly-trees).
|
|
262
|
+
|
|
263
|
+
## Contributing
|
|
264
|
+
|
|
265
|
+
We love contributions. Feel free to [join in the conversation on Discord. All welcome.](https://discord.gg/cCryrNHePH)
|
|
266
|
+
|
|
267
|
+
# License
|
|
268
|
+
|
|
269
|
+
Dual-licensed under [MIT or Apache 2.0](https://github.com/fireproof-storage/fireproof/blob/main/LICENSE.md)
|
package/dash-types.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Result } from "@adviser/cement";
|
|
2
|
+
import { DashAuthType } from "./msg-types.js";
|
|
3
|
+
export interface TypeString {
|
|
4
|
+
readonly type: string;
|
|
5
|
+
}
|
|
6
|
+
export interface WithType<T extends TypeString> {
|
|
7
|
+
readonly type: T["type"];
|
|
8
|
+
readonly auth?: DashAuthType;
|
|
9
|
+
}
|
|
10
|
+
export type WithoutTypeAndAuth<T> = Omit<T, "type" | "auth">;
|
|
11
|
+
export interface ClerkDashboardApiConfig<T> {
|
|
12
|
+
readonly apiUrl: string;
|
|
13
|
+
readonly getTokenCtx?: T;
|
|
14
|
+
readonly template?: string;
|
|
15
|
+
readonly gracePeriodMs?: number;
|
|
16
|
+
fetch?(input: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
17
|
+
}
|
|
18
|
+
export interface DashboardApiConfigIntern<T> {
|
|
19
|
+
readonly apiUrl: string;
|
|
20
|
+
readonly getTokenCtx?: T;
|
|
21
|
+
readonly gracePeriodMs: number;
|
|
22
|
+
fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
23
|
+
getToken: (ctx: T) => Promise<Result<DashAuthType>>;
|
|
24
|
+
}
|
|
25
|
+
export interface DashboardApiConfig<T> extends Omit<DashboardApiConfigIntern<T>, "gracePeriodMs"> {
|
|
26
|
+
readonly gracePeriodMs?: number;
|
|
27
|
+
}
|
package/dash-types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dash-types.js","sourceRoot":"","sources":["../jsr/dash-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Result } from "@adviser/cement";
|
|
2
|
+
import { ReqEnsureUser, ResEnsureUser, ReqFindUser, ResFindUser, ReqCreateTenant, ResCreateTenant, ReqUpdateTenant, ResUpdateTenant, ReqDeleteTenant, ResDeleteTenant, ReqRedeemInvite, ResRedeemInvite, ReqListTenantsByUser, ResListTenantsByUser, ReqUpdateUserTenant, ResUpdateUserTenant, ReqInviteUser, ResInviteUser, ReqListInvites, ResListInvites, ReqDeleteInvite, ResDeleteInvite, ReqCreateLedger, ResCreateLedger, ReqListLedgersByUser, ResListLedgersByUser, ReqUpdateLedger, ResUpdateLedger, ReqDeleteLedger, ResDeleteLedger, ReqCloudSessionToken, ResCloudSessionToken, ReqTokenByResultId, ResTokenByResultId, ReqExtendToken, ResExtendToken, ReqCertFromCsr, ResCertFromCsr, ReqEnsureCloudToken, ResEnsureCloudToken } from "./msg-types.js";
|
|
3
|
+
export interface FPApiInterface {
|
|
4
|
+
ensureUser(req: ReqEnsureUser): Promise<Result<ResEnsureUser>>;
|
|
5
|
+
findUser(req: ReqFindUser): Promise<Result<ResFindUser>>;
|
|
6
|
+
createTenant(req: ReqCreateTenant): Promise<Result<ResCreateTenant>>;
|
|
7
|
+
updateTenant(req: ReqUpdateTenant): Promise<Result<ResUpdateTenant>>;
|
|
8
|
+
deleteTenant(req: ReqDeleteTenant): Promise<Result<ResDeleteTenant>>;
|
|
9
|
+
redeemInvite(req: ReqRedeemInvite): Promise<Result<ResRedeemInvite>>;
|
|
10
|
+
listTenantsByUser(req: ReqListTenantsByUser): Promise<Result<ResListTenantsByUser>>;
|
|
11
|
+
updateUserTenant(req: ReqUpdateUserTenant): Promise<Result<ResUpdateUserTenant>>;
|
|
12
|
+
inviteUser(req: ReqInviteUser): Promise<Result<ResInviteUser>>;
|
|
13
|
+
listInvites(req: ReqListInvites): Promise<Result<ResListInvites>>;
|
|
14
|
+
deleteInvite(req: ReqDeleteInvite): Promise<Result<ResDeleteInvite>>;
|
|
15
|
+
createLedger(req: ReqCreateLedger): Promise<Result<ResCreateLedger>>;
|
|
16
|
+
listLedgersByUser(req: ReqListLedgersByUser): Promise<Result<ResListLedgersByUser>>;
|
|
17
|
+
updateLedger(req: ReqUpdateLedger): Promise<Result<ResUpdateLedger>>;
|
|
18
|
+
deleteLedger(req: ReqDeleteLedger): Promise<Result<ResDeleteLedger>>;
|
|
19
|
+
getCloudSessionToken(req: ReqCloudSessionToken): Promise<Result<ResCloudSessionToken>>;
|
|
20
|
+
getTokenByResultId(req: ReqTokenByResultId): Promise<Result<ResTokenByResultId>>;
|
|
21
|
+
extendToken(req: ReqExtendToken): Promise<Result<ResExtendToken>>;
|
|
22
|
+
getCertFromCsr(req: ReqCertFromCsr): Promise<Result<ResCertFromCsr>>;
|
|
23
|
+
ensureCloudToken(req: ReqEnsureCloudToken): Promise<Result<ResEnsureCloudToken>>;
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fp-api-interface.js","sourceRoot":"","sources":["../jsr/fp-api-interface.ts"],"names":[],"mappings":""}
|
package/index.d.ts
ADDED
package/index.js
ADDED
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../jsr/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC"}
|
package/msg-is.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Result, Option } from "@adviser/cement";
|
|
2
|
+
import { ReqDeleteTenant, ReqUpdateTenant, ReqCreateTenant, ReqDeleteInvite, ReqListInvites, ReqInviteUser, ReqFindUser, ReqRedeemInvite, ReqEnsureUser, ReqListTenantsByUser, ReqUpdateUserTenant, ReqCloudSessionToken, ReqTokenByResultId, ReqListLedgersByUser, ReqCreateLedger, ReqUpdateLedger, ReqDeleteLedger, ResTokenByResultId, ReqExtendToken, ReqCertFromCsr, ReqEnsureCloudToken } from "./msg-types.js";
|
|
3
|
+
interface FPApiMsgInterface {
|
|
4
|
+
isDeleteTenant(jso: unknown): jso is ReqDeleteTenant;
|
|
5
|
+
isUpdateTenant(jso: unknown): jso is ReqUpdateTenant;
|
|
6
|
+
isCreateTenant(jso: unknown): jso is ReqCreateTenant;
|
|
7
|
+
isDeleteInvite(jso: unknown): jso is ReqDeleteInvite;
|
|
8
|
+
isListInvites(jso: unknown): jso is ReqListInvites;
|
|
9
|
+
isInviteUser(jso: unknown): jso is ReqInviteUser;
|
|
10
|
+
isFindUser(jso: unknown): jso is ReqFindUser;
|
|
11
|
+
isRedeemInvite(jso: unknown): jso is ReqRedeemInvite;
|
|
12
|
+
isEnsureUser(jso: unknown): jso is ReqEnsureUser;
|
|
13
|
+
isListTenantsByUser(jso: unknown): jso is ReqListTenantsByUser;
|
|
14
|
+
isUpdateUserTenant(jso: unknown): jso is ReqUpdateUserTenant;
|
|
15
|
+
isCloudSessionToken(jso: unknown): jso is ReqCloudSessionToken;
|
|
16
|
+
isReqTokenByResultId(jso: unknown): jso is ReqTokenByResultId;
|
|
17
|
+
isResTokenByResultId(jso: unknown): jso is ResTokenByResultId;
|
|
18
|
+
isListLedgersByUser(jso: unknown): jso is ReqListLedgersByUser;
|
|
19
|
+
isCreateLedger(jso: unknown): jso is ReqCreateLedger;
|
|
20
|
+
isUpdateLedger(jso: unknown): jso is ReqUpdateLedger;
|
|
21
|
+
isDeleteLedger(jso: unknown): jso is ReqDeleteLedger;
|
|
22
|
+
isReqExtendToken(jso: unknown): jso is ReqExtendToken;
|
|
23
|
+
isReqCertFromCsr(jso: unknown): jso is ReqCertFromCsr;
|
|
24
|
+
isEnsureCloudToken(jso: unknown): jso is ReqEnsureCloudToken;
|
|
25
|
+
}
|
|
26
|
+
export declare function validateDeleteTenant<T extends ReqDeleteTenant>(jso: unknown): Promise<Result<Option<T>>>;
|
|
27
|
+
export declare function validateUpdateTenant<T extends ReqUpdateTenant>(jso: unknown): Promise<Result<Option<T>>>;
|
|
28
|
+
export declare function validateCreateTenant<T extends ReqCreateTenant>(jso: unknown): Promise<Result<Option<T>>>;
|
|
29
|
+
export declare function validateCreateLedger<T extends ReqCreateLedger>(jso: unknown): Promise<Result<Option<T>>>;
|
|
30
|
+
export declare function validateDeleteLedger<T extends ReqDeleteLedger>(jso: unknown): Promise<Result<Option<T>>>;
|
|
31
|
+
export declare function validateUpdateLedger<T extends ReqUpdateLedger>(jso: unknown): Promise<Result<Option<T>>>;
|
|
32
|
+
export declare function validateListInvites<T extends ReqListInvites>(jso: unknown): Promise<Result<Option<T>>>;
|
|
33
|
+
export declare function validateInviteUser<T extends ReqInviteUser>(jso: unknown): Promise<Result<Option<T>>>;
|
|
34
|
+
export declare function validateFindUser<T extends ReqFindUser>(jso: unknown): Promise<Result<Option<T>>>;
|
|
35
|
+
export declare function validateRedeemInvite<T extends ReqRedeemInvite>(jso: unknown): Promise<Result<Option<T>>>;
|
|
36
|
+
export declare function validateListTenantsByUser<T extends ReqListTenantsByUser>(jso: unknown): Promise<Result<Option<T>>>;
|
|
37
|
+
export declare function validateUpdateUserTenant<T extends ReqUpdateUserTenant>(jso: unknown): Promise<Result<Option<T>>>;
|
|
38
|
+
export declare function validateListLedgersByUser<T extends ReqListLedgersByUser>(jso: unknown): Promise<Result<Option<T>>>;
|
|
39
|
+
export declare function validateDeleteInvite<T extends ReqDeleteInvite>(jso: unknown): Promise<Result<Option<T>>>;
|
|
40
|
+
export declare function validateCloudSessionToken<T extends ReqCloudSessionToken>(jso: unknown): Promise<Result<Option<T>>>;
|
|
41
|
+
export declare function validateTokenByResultId<T extends ReqTokenByResultId>(jso: unknown): Promise<Result<Option<T>>>;
|
|
42
|
+
export declare function validateCertFromCsr<T extends ReqCertFromCsr>(jso: unknown): Promise<Result<Option<T>>>;
|
|
43
|
+
export declare function validateEnsureUser<T extends ReqEnsureUser>(jso: unknown): Promise<Result<Option<T>>>;
|
|
44
|
+
export declare function validateEnsureCloudToken<T extends ReqEnsureCloudToken>(jso: unknown): Promise<Result<Option<T>>>;
|
|
45
|
+
export declare class FAPIMsgImpl implements FPApiMsgInterface {
|
|
46
|
+
isDeleteTenant(jso: unknown): jso is ReqDeleteTenant;
|
|
47
|
+
isUpdateTenant(jso: unknown): jso is ReqUpdateTenant;
|
|
48
|
+
isCreateTenant(jso: unknown): jso is ReqCreateTenant;
|
|
49
|
+
isDeleteInvite(jso: unknown): jso is ReqDeleteInvite;
|
|
50
|
+
isListInvites(jso: unknown): jso is ReqListInvites;
|
|
51
|
+
isInviteUser(jso: unknown): jso is ReqInviteUser;
|
|
52
|
+
isFindUser(jso: unknown): jso is ReqFindUser;
|
|
53
|
+
isRedeemInvite(jso: unknown): jso is ReqRedeemInvite;
|
|
54
|
+
isEnsureUser(jso: unknown): jso is ReqEnsureUser;
|
|
55
|
+
isListTenantsByUser(jso: unknown): jso is ReqListTenantsByUser;
|
|
56
|
+
isUpdateUserTenant(jso: unknown): jso is ReqUpdateUserTenant;
|
|
57
|
+
isListLedgersByUser(jso: unknown): jso is ReqListLedgersByUser;
|
|
58
|
+
isCreateLedger(jso: unknown): jso is ReqCreateLedger;
|
|
59
|
+
isUpdateLedger(jso: unknown): jso is ReqUpdateLedger;
|
|
60
|
+
isDeleteLedger(jso: unknown): jso is ReqDeleteLedger;
|
|
61
|
+
isCloudSessionToken(jso: unknown): jso is ReqCloudSessionToken;
|
|
62
|
+
isReqTokenByResultId(jso: unknown): jso is ReqTokenByResultId;
|
|
63
|
+
isResTokenByResultId(jso: unknown): jso is ResTokenByResultId;
|
|
64
|
+
isReqExtendToken(jso: unknown): jso is ReqExtendToken;
|
|
65
|
+
isReqCertFromCsr(jso: unknown): jso is ReqCertFromCsr;
|
|
66
|
+
isEnsureCloudToken(jso: unknown): jso is ReqEnsureCloudToken;
|
|
67
|
+
}
|
|
68
|
+
export {};
|
package/msg-is.js
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { Result, Option } from "@adviser/cement";
|
|
2
|
+
function hasType(jso, t) {
|
|
3
|
+
return typeof jso === "object" && jso !== null && jso.type === t;
|
|
4
|
+
}
|
|
5
|
+
export async function validateDeleteTenant(jso) {
|
|
6
|
+
if (hasType(jso, "reqDeleteTenant")) {
|
|
7
|
+
return Result.Ok(Option.Some(jso));
|
|
8
|
+
}
|
|
9
|
+
return Result.Ok(Option.None());
|
|
10
|
+
}
|
|
11
|
+
export async function validateUpdateTenant(jso) {
|
|
12
|
+
if (hasType(jso, "reqUpdateTenant")) {
|
|
13
|
+
return Result.Ok(Option.Some(jso));
|
|
14
|
+
}
|
|
15
|
+
return Result.Ok(Option.None());
|
|
16
|
+
}
|
|
17
|
+
export async function validateCreateTenant(jso) {
|
|
18
|
+
if (hasType(jso, "reqCreateTenant")) {
|
|
19
|
+
return Result.Ok(Option.Some(jso));
|
|
20
|
+
}
|
|
21
|
+
return Result.Ok(Option.None());
|
|
22
|
+
}
|
|
23
|
+
export async function validateCreateLedger(jso) {
|
|
24
|
+
if (hasType(jso, "reqCreateLedger")) {
|
|
25
|
+
return Result.Ok(Option.Some(jso));
|
|
26
|
+
}
|
|
27
|
+
return Result.Ok(Option.None());
|
|
28
|
+
}
|
|
29
|
+
export async function validateDeleteLedger(jso) {
|
|
30
|
+
if (hasType(jso, "reqDeleteLedger")) {
|
|
31
|
+
return Result.Ok(Option.Some(jso));
|
|
32
|
+
}
|
|
33
|
+
return Result.Ok(Option.None());
|
|
34
|
+
}
|
|
35
|
+
export async function validateUpdateLedger(jso) {
|
|
36
|
+
if (hasType(jso, "reqUpdateLedger")) {
|
|
37
|
+
return Result.Ok(Option.Some(jso));
|
|
38
|
+
}
|
|
39
|
+
return Result.Ok(Option.None());
|
|
40
|
+
}
|
|
41
|
+
export async function validateListInvites(jso) {
|
|
42
|
+
if (hasType(jso, "reqListInvites")) {
|
|
43
|
+
return Result.Ok(Option.Some(jso));
|
|
44
|
+
}
|
|
45
|
+
return Result.Ok(Option.None());
|
|
46
|
+
}
|
|
47
|
+
export async function validateInviteUser(jso) {
|
|
48
|
+
if (hasType(jso, "reqInviteUser")) {
|
|
49
|
+
return Result.Ok(Option.Some(jso));
|
|
50
|
+
}
|
|
51
|
+
return Result.Ok(Option.None());
|
|
52
|
+
}
|
|
53
|
+
export async function validateFindUser(jso) {
|
|
54
|
+
if (hasType(jso, "reqFindUser")) {
|
|
55
|
+
return Result.Ok(Option.Some(jso));
|
|
56
|
+
}
|
|
57
|
+
return Result.Ok(Option.None());
|
|
58
|
+
}
|
|
59
|
+
export async function validateRedeemInvite(jso) {
|
|
60
|
+
if (hasType(jso, "reqRedeemInvite")) {
|
|
61
|
+
return Result.Ok(Option.Some(jso));
|
|
62
|
+
}
|
|
63
|
+
return Result.Ok(Option.None());
|
|
64
|
+
}
|
|
65
|
+
export async function validateListTenantsByUser(jso) {
|
|
66
|
+
if (hasType(jso, "reqListTenantsByUser")) {
|
|
67
|
+
return Result.Ok(Option.Some(jso));
|
|
68
|
+
}
|
|
69
|
+
return Result.Ok(Option.None());
|
|
70
|
+
}
|
|
71
|
+
export async function validateUpdateUserTenant(jso) {
|
|
72
|
+
if (hasType(jso, "reqUpdateUserTenant")) {
|
|
73
|
+
return Result.Ok(Option.Some(jso));
|
|
74
|
+
}
|
|
75
|
+
return Result.Ok(Option.None());
|
|
76
|
+
}
|
|
77
|
+
export async function validateListLedgersByUser(jso) {
|
|
78
|
+
if (hasType(jso, "reqListLedgersByUser")) {
|
|
79
|
+
return Result.Ok(Option.Some(jso));
|
|
80
|
+
}
|
|
81
|
+
return Result.Ok(Option.None());
|
|
82
|
+
}
|
|
83
|
+
export async function validateDeleteInvite(jso) {
|
|
84
|
+
if (hasType(jso, "reqDeleteInvite")) {
|
|
85
|
+
return Result.Ok(Option.Some(jso));
|
|
86
|
+
}
|
|
87
|
+
return Result.Ok(Option.None());
|
|
88
|
+
}
|
|
89
|
+
export async function validateCloudSessionToken(jso) {
|
|
90
|
+
if (hasType(jso, "reqCloudSessionToken")) {
|
|
91
|
+
return Result.Ok(Option.Some(jso));
|
|
92
|
+
}
|
|
93
|
+
return Result.Ok(Option.None());
|
|
94
|
+
}
|
|
95
|
+
export async function validateTokenByResultId(jso) {
|
|
96
|
+
if (hasType(jso, "reqTokenByResultId")) {
|
|
97
|
+
return Result.Ok(Option.Some(jso));
|
|
98
|
+
}
|
|
99
|
+
return Result.Ok(Option.None());
|
|
100
|
+
}
|
|
101
|
+
export async function validateCertFromCsr(jso) {
|
|
102
|
+
if (hasType(jso, "reqCertFromCsr")) {
|
|
103
|
+
return Result.Ok(Option.Some(jso));
|
|
104
|
+
}
|
|
105
|
+
return Result.Ok(Option.None());
|
|
106
|
+
}
|
|
107
|
+
export async function validateEnsureUser(jso) {
|
|
108
|
+
if (hasType(jso, "reqEnsureUser")) {
|
|
109
|
+
return Result.Ok(Option.Some(jso));
|
|
110
|
+
}
|
|
111
|
+
return Result.Ok(Option.None());
|
|
112
|
+
}
|
|
113
|
+
export async function validateEnsureCloudToken(jso) {
|
|
114
|
+
if (hasType(jso, "reqEnsureCloudToken")) {
|
|
115
|
+
return Result.Ok(Option.Some(jso));
|
|
116
|
+
}
|
|
117
|
+
return Result.Ok(Option.None());
|
|
118
|
+
}
|
|
119
|
+
export class FAPIMsgImpl {
|
|
120
|
+
isDeleteTenant(jso) {
|
|
121
|
+
return hasType(jso, "reqDeleteTenant");
|
|
122
|
+
}
|
|
123
|
+
isUpdateTenant(jso) {
|
|
124
|
+
return hasType(jso, "reqUpdateTenant");
|
|
125
|
+
}
|
|
126
|
+
isCreateTenant(jso) {
|
|
127
|
+
return hasType(jso, "reqCreateTenant");
|
|
128
|
+
}
|
|
129
|
+
isDeleteInvite(jso) {
|
|
130
|
+
return hasType(jso, "reqDeleteInvite");
|
|
131
|
+
}
|
|
132
|
+
isListInvites(jso) {
|
|
133
|
+
return hasType(jso, "reqListInvites");
|
|
134
|
+
}
|
|
135
|
+
isInviteUser(jso) {
|
|
136
|
+
return hasType(jso, "reqInviteUser");
|
|
137
|
+
}
|
|
138
|
+
isFindUser(jso) {
|
|
139
|
+
return hasType(jso, "reqFindUser");
|
|
140
|
+
}
|
|
141
|
+
isRedeemInvite(jso) {
|
|
142
|
+
return hasType(jso, "reqRedeemInvite");
|
|
143
|
+
}
|
|
144
|
+
isEnsureUser(jso) {
|
|
145
|
+
return hasType(jso, "reqEnsureUser");
|
|
146
|
+
}
|
|
147
|
+
isListTenantsByUser(jso) {
|
|
148
|
+
return hasType(jso, "reqListTenantsByUser");
|
|
149
|
+
}
|
|
150
|
+
isUpdateUserTenant(jso) {
|
|
151
|
+
return hasType(jso, "reqUpdateUserTenant");
|
|
152
|
+
}
|
|
153
|
+
isListLedgersByUser(jso) {
|
|
154
|
+
return hasType(jso, "reqListLedgersByUser");
|
|
155
|
+
}
|
|
156
|
+
isCreateLedger(jso) {
|
|
157
|
+
return hasType(jso, "reqCreateLedger");
|
|
158
|
+
}
|
|
159
|
+
isUpdateLedger(jso) {
|
|
160
|
+
return hasType(jso, "reqUpdateLedger");
|
|
161
|
+
}
|
|
162
|
+
isDeleteLedger(jso) {
|
|
163
|
+
return hasType(jso, "reqDeleteLedger");
|
|
164
|
+
}
|
|
165
|
+
isCloudSessionToken(jso) {
|
|
166
|
+
return hasType(jso, "reqCloudSessionToken");
|
|
167
|
+
}
|
|
168
|
+
isReqTokenByResultId(jso) {
|
|
169
|
+
return hasType(jso, "reqTokenByResultId");
|
|
170
|
+
}
|
|
171
|
+
isResTokenByResultId(jso) {
|
|
172
|
+
return hasType(jso, "resTokenByResultId");
|
|
173
|
+
}
|
|
174
|
+
isReqExtendToken(jso) {
|
|
175
|
+
return hasType(jso, "reqExtendToken");
|
|
176
|
+
}
|
|
177
|
+
isReqCertFromCsr(jso) {
|
|
178
|
+
return hasType(jso, "reqCertFromCsr");
|
|
179
|
+
}
|
|
180
|
+
isEnsureCloudToken(jso) {
|
|
181
|
+
return hasType(jso, "reqEnsureCloudToken");
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=msg-is.js.map
|
package/msg-is.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"msg-is.js","sourceRoot":"","sources":["../jsr/msg-is.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAiDjD,SAAS,OAAO,CAAC,GAAY,EAAE,CAAS,EAA2B;IACjE,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAK,GAA0B,CAAC,IAAI,KAAK,CAAC,CAAC;AAAA,CAC1F;AAED,MAAM,CAAC,KAAK,UAAU,oBAA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,EAAE,oBAAoB,CAAC,CAAC;IAAA,CAC3C;IACD,oBAAoB,CAAC,GAAY,EAA6B;QAC5D,OAAO,OAAO,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC;IAAA,CAC3C;IACD,gBAAgB,CAAC,GAAY,EAAyB;QACpD,OAAO,OAAO,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;IAAA,CACvC;IACD,gBAAgB,CAAC,GAAY,EAAyB;QACpD,OAAO,OAAO,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;IAAA,CACvC;IACD,kBAAkB,CAAC,GAAY,EAA8B;QAC3D,OAAO,OAAO,CAAC,GAAG,EAAE,qBAAqB,CAAC,CAAC;IAAA,CAC5C;CACF"}
|
package/msg-types.d.ts
ADDED
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
import { ClerkEmailTemplateClaim, JWKPublic } from "@fireproof/core-types-base";
|
|
2
|
+
import { FPCloudClaim, ReadWrite, Role, TenantLedger } from "@fireproof/core-types-protocols-cloud";
|
|
3
|
+
export type AuthProvider = "github" | "google" | "fp" | "invite-per-email" | "device-id";
|
|
4
|
+
export interface Queryable {
|
|
5
|
+
readonly userId?: string;
|
|
6
|
+
readonly queryProvider?: AuthProvider;
|
|
7
|
+
readonly queryEmail?: string;
|
|
8
|
+
readonly queryNick?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface QueryUser {
|
|
11
|
+
readonly byString?: string;
|
|
12
|
+
readonly existingUserId?: string;
|
|
13
|
+
readonly byEmail?: string;
|
|
14
|
+
readonly byNick?: string;
|
|
15
|
+
readonly andProvider?: AuthProvider;
|
|
16
|
+
}
|
|
17
|
+
export interface Tenant {
|
|
18
|
+
readonly tenantId: string;
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly ownerUserId: string;
|
|
21
|
+
readonly adminUserIds: string[];
|
|
22
|
+
readonly memberUserIds: string[];
|
|
23
|
+
readonly maxAdminUsers: number;
|
|
24
|
+
readonly maxMemberUsers: number;
|
|
25
|
+
readonly maxLedgers: number;
|
|
26
|
+
readonly createdAt: Date;
|
|
27
|
+
readonly updatedAt: Date;
|
|
28
|
+
}
|
|
29
|
+
export type InviteTicketStatus = "pending" | "accepted" | "rejected" | "expired";
|
|
30
|
+
export interface SqlInvitedParams {
|
|
31
|
+
readonly tenant?: {
|
|
32
|
+
readonly role: "admin" | "member";
|
|
33
|
+
};
|
|
34
|
+
readonly ledger?: {
|
|
35
|
+
readonly role: "admin" | "member";
|
|
36
|
+
readonly right: "read" | "write";
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export interface InvitedParams {
|
|
40
|
+
readonly tenant?: SqlInvitedParams["tenant"] & {
|
|
41
|
+
readonly id: string;
|
|
42
|
+
};
|
|
43
|
+
readonly ledger?: SqlInvitedParams["ledger"] & {
|
|
44
|
+
readonly id: string;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export interface InviteTicket {
|
|
48
|
+
readonly inviteId: string;
|
|
49
|
+
readonly sendEmailCount: number;
|
|
50
|
+
readonly inviterUserId: string;
|
|
51
|
+
readonly query: QueryUser;
|
|
52
|
+
readonly status: InviteTicketStatus;
|
|
53
|
+
readonly statusReason: string;
|
|
54
|
+
readonly invitedUserId?: string;
|
|
55
|
+
readonly invitedParams: InvitedParams;
|
|
56
|
+
readonly expiresAfter: Date;
|
|
57
|
+
readonly createdAt: Date;
|
|
58
|
+
readonly updatedAt: Date;
|
|
59
|
+
}
|
|
60
|
+
export type UserStatus = "active" | "inactive" | "banned" | "invited";
|
|
61
|
+
export interface DashAuthType {
|
|
62
|
+
readonly type: "ucan" | "clerk" | "device-id";
|
|
63
|
+
readonly token: string;
|
|
64
|
+
}
|
|
65
|
+
export interface User {
|
|
66
|
+
readonly userId: string;
|
|
67
|
+
readonly maxTenants: number;
|
|
68
|
+
readonly status: UserStatus;
|
|
69
|
+
readonly statusReason?: string;
|
|
70
|
+
readonly createdAt: Date;
|
|
71
|
+
readonly updatedAt: Date;
|
|
72
|
+
readonly byProviders: UserByProvider[];
|
|
73
|
+
}
|
|
74
|
+
export interface UserByProvider extends Queryable {
|
|
75
|
+
readonly providerUserId: string;
|
|
76
|
+
readonly cleanEmail?: string;
|
|
77
|
+
readonly cleanNick?: string;
|
|
78
|
+
readonly queryProvider: AuthProvider;
|
|
79
|
+
readonly queryEmail?: string;
|
|
80
|
+
readonly queryNick?: string;
|
|
81
|
+
readonly params: ClerkEmailTemplateClaim;
|
|
82
|
+
readonly used: Date;
|
|
83
|
+
readonly createdAt: Date;
|
|
84
|
+
readonly updatedAt: Date;
|
|
85
|
+
}
|
|
86
|
+
export interface ResCreateTenant {
|
|
87
|
+
readonly type: "resCreateTenant";
|
|
88
|
+
readonly tenant: OutTenantParams;
|
|
89
|
+
}
|
|
90
|
+
export interface FPApiParameters {
|
|
91
|
+
cloudPublicKeys: JWKPublic[];
|
|
92
|
+
clerkPublishableKey: string;
|
|
93
|
+
maxTenants: number;
|
|
94
|
+
maxAdminUsers: number;
|
|
95
|
+
maxMemberUsers: number;
|
|
96
|
+
maxInvites: number;
|
|
97
|
+
maxLedgers: number;
|
|
98
|
+
maxAppIdBindings: number;
|
|
99
|
+
}
|
|
100
|
+
export interface InCreateTenantParams {
|
|
101
|
+
readonly name?: string;
|
|
102
|
+
readonly ownerUserId: string;
|
|
103
|
+
readonly defaultTenant?: boolean;
|
|
104
|
+
}
|
|
105
|
+
export interface ReqCreateTenant {
|
|
106
|
+
readonly type: "reqCreateTenant";
|
|
107
|
+
readonly auth: DashAuthType;
|
|
108
|
+
readonly tenant: Omit<InCreateTenantParams, "ownerUserId">;
|
|
109
|
+
}
|
|
110
|
+
export interface InUpdateTenantParams {
|
|
111
|
+
readonly tenantId: string;
|
|
112
|
+
readonly name?: string;
|
|
113
|
+
readonly maxAdminUsers?: number;
|
|
114
|
+
readonly maxMemberUsers?: number;
|
|
115
|
+
readonly maxInvites?: number;
|
|
116
|
+
}
|
|
117
|
+
export interface ResUpdateTenant {
|
|
118
|
+
readonly type: "resUpdateTenant";
|
|
119
|
+
readonly tenant: OutTenantParams;
|
|
120
|
+
}
|
|
121
|
+
export interface ReqUpdateTenant {
|
|
122
|
+
readonly type: "reqUpdateTenant";
|
|
123
|
+
readonly auth: DashAuthType;
|
|
124
|
+
readonly tenant: InUpdateTenantParams;
|
|
125
|
+
}
|
|
126
|
+
export interface ResEnsureTenant {
|
|
127
|
+
readonly type: "resEnsureTenant";
|
|
128
|
+
readonly tenant: Tenant;
|
|
129
|
+
}
|
|
130
|
+
export interface ReqRedeemInvite {
|
|
131
|
+
readonly type: "reqRedeemInvite";
|
|
132
|
+
readonly auth: DashAuthType;
|
|
133
|
+
}
|
|
134
|
+
export interface ResRedeemInvite {
|
|
135
|
+
readonly type: "resRedeemInvite";
|
|
136
|
+
readonly invites?: InviteTicket[];
|
|
137
|
+
}
|
|
138
|
+
export interface ReqListLedgersByUser {
|
|
139
|
+
readonly type: "reqListLedgersByUser";
|
|
140
|
+
readonly auth: DashAuthType;
|
|
141
|
+
readonly tenantIds?: string[];
|
|
142
|
+
}
|
|
143
|
+
interface LedgerUserRight {
|
|
144
|
+
readonly userId: string;
|
|
145
|
+
readonly role: Role;
|
|
146
|
+
readonly right: ReadWrite;
|
|
147
|
+
readonly name?: string;
|
|
148
|
+
readonly default: boolean;
|
|
149
|
+
readonly createdAt: Date;
|
|
150
|
+
readonly updatedAt: Date;
|
|
151
|
+
}
|
|
152
|
+
export interface LedgerUser {
|
|
153
|
+
readonly ledgerId: string;
|
|
154
|
+
readonly tenantId: string;
|
|
155
|
+
readonly name: string;
|
|
156
|
+
readonly ownerId: string;
|
|
157
|
+
readonly maxShares: number;
|
|
158
|
+
readonly users: LedgerUserRight[];
|
|
159
|
+
readonly createdAt: Date;
|
|
160
|
+
readonly updatedAt: Date;
|
|
161
|
+
}
|
|
162
|
+
export interface ResListLedgersByUser {
|
|
163
|
+
readonly type: "resListLedgersByUser";
|
|
164
|
+
readonly userId: string;
|
|
165
|
+
readonly ledgers: LedgerUser[];
|
|
166
|
+
}
|
|
167
|
+
export interface ReqListTenantsByUser {
|
|
168
|
+
readonly type: "reqListTenantsByUser";
|
|
169
|
+
readonly auth: DashAuthType;
|
|
170
|
+
}
|
|
171
|
+
export interface UserTenantCommon {
|
|
172
|
+
readonly name?: string;
|
|
173
|
+
readonly status: UserStatus;
|
|
174
|
+
readonly statusReason: string;
|
|
175
|
+
readonly createdAt: Date;
|
|
176
|
+
readonly updatedAt: Date;
|
|
177
|
+
}
|
|
178
|
+
export interface TenantLimits {
|
|
179
|
+
readonly maxAdminUsers: number;
|
|
180
|
+
readonly maxMemberUsers: number;
|
|
181
|
+
readonly maxInvites: number;
|
|
182
|
+
readonly maxLedgers: number;
|
|
183
|
+
}
|
|
184
|
+
export interface UserTenant {
|
|
185
|
+
readonly tenantId: string;
|
|
186
|
+
readonly role: Role;
|
|
187
|
+
readonly default: boolean;
|
|
188
|
+
readonly user: UserTenantCommon & {
|
|
189
|
+
readonly limits: {
|
|
190
|
+
readonly maxTenants: number;
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
readonly tenant: UserTenantCommon & {
|
|
194
|
+
readonly limits: TenantLimits;
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
export declare function isAdmin(ut: UserTenant): boolean;
|
|
198
|
+
export interface AdminTenant extends UserTenant {
|
|
199
|
+
readonly role: "admin";
|
|
200
|
+
readonly adminUserIds: string[];
|
|
201
|
+
readonly memberUserIds: string[];
|
|
202
|
+
readonly maxAdminUsers: number;
|
|
203
|
+
readonly maxMemberUsers: number;
|
|
204
|
+
}
|
|
205
|
+
export interface ResListTenantsByUser {
|
|
206
|
+
readonly type: "resListTenantsByUser";
|
|
207
|
+
readonly userId: string;
|
|
208
|
+
readonly authUserId: string;
|
|
209
|
+
readonly tenants: (AdminTenant | UserTenant)[];
|
|
210
|
+
}
|
|
211
|
+
export interface ReqFindUser {
|
|
212
|
+
readonly type: "reqFindUser";
|
|
213
|
+
readonly auth: DashAuthType;
|
|
214
|
+
readonly query: QueryUser;
|
|
215
|
+
}
|
|
216
|
+
export interface ResFindUser {
|
|
217
|
+
readonly type: "resFindUser";
|
|
218
|
+
readonly query: QueryUser;
|
|
219
|
+
readonly results: User[];
|
|
220
|
+
}
|
|
221
|
+
export interface QueryInviteTicket {
|
|
222
|
+
readonly incSendEmailCount?: boolean;
|
|
223
|
+
readonly inviteId?: string;
|
|
224
|
+
readonly query: QueryUser;
|
|
225
|
+
readonly invitedParams: InvitedParams;
|
|
226
|
+
}
|
|
227
|
+
export interface ReqInviteUser {
|
|
228
|
+
readonly type: "reqInviteUser";
|
|
229
|
+
readonly auth: DashAuthType;
|
|
230
|
+
readonly ticket: QueryInviteTicket;
|
|
231
|
+
}
|
|
232
|
+
export interface ResInviteUser {
|
|
233
|
+
readonly type: "resInviteUser";
|
|
234
|
+
readonly invite: InviteTicket;
|
|
235
|
+
}
|
|
236
|
+
export interface ReqDeleteInvite {
|
|
237
|
+
readonly type: "reqDeleteInvite";
|
|
238
|
+
readonly auth: DashAuthType;
|
|
239
|
+
readonly inviteId: string;
|
|
240
|
+
}
|
|
241
|
+
export interface ResDeleteInvite {
|
|
242
|
+
readonly type: "resDeleteInvite";
|
|
243
|
+
readonly inviteId: string;
|
|
244
|
+
}
|
|
245
|
+
export interface ReqListInvites {
|
|
246
|
+
readonly type: "reqListInvites";
|
|
247
|
+
readonly auth: DashAuthType;
|
|
248
|
+
readonly tenantIds?: string[];
|
|
249
|
+
readonly ledgerIds?: string[];
|
|
250
|
+
}
|
|
251
|
+
export interface ResListInvites {
|
|
252
|
+
readonly type: "resListInvites";
|
|
253
|
+
readonly tickets: InviteTicket[];
|
|
254
|
+
}
|
|
255
|
+
export interface ReqUpdateUserTenant {
|
|
256
|
+
readonly type: "reqUpdateUserTenant";
|
|
257
|
+
readonly auth: DashAuthType;
|
|
258
|
+
readonly tenantId: string;
|
|
259
|
+
readonly userId?: string;
|
|
260
|
+
readonly role: Role;
|
|
261
|
+
readonly default?: boolean;
|
|
262
|
+
readonly name?: string;
|
|
263
|
+
}
|
|
264
|
+
export interface ResUpdateUserTenant {
|
|
265
|
+
readonly type: "resUpdateUserTenant";
|
|
266
|
+
readonly tenantId: string;
|
|
267
|
+
readonly userId: string;
|
|
268
|
+
readonly role: Role;
|
|
269
|
+
readonly default: boolean;
|
|
270
|
+
readonly name?: string;
|
|
271
|
+
}
|
|
272
|
+
export interface CreateLedger {
|
|
273
|
+
readonly tenantId: string;
|
|
274
|
+
readonly name: string;
|
|
275
|
+
}
|
|
276
|
+
export interface ReqCreateLedger {
|
|
277
|
+
readonly type: "reqCreateLedger";
|
|
278
|
+
readonly auth: DashAuthType;
|
|
279
|
+
readonly ledger: CreateLedger;
|
|
280
|
+
}
|
|
281
|
+
export interface ResCreateLedger {
|
|
282
|
+
readonly type: "resCreateLedger";
|
|
283
|
+
readonly ledger: LedgerUser;
|
|
284
|
+
}
|
|
285
|
+
export interface UpdateLedger {
|
|
286
|
+
readonly ledgerId: string;
|
|
287
|
+
readonly tenantId: string;
|
|
288
|
+
readonly right?: ReadWrite;
|
|
289
|
+
readonly role?: Role;
|
|
290
|
+
readonly name?: string;
|
|
291
|
+
readonly default?: boolean;
|
|
292
|
+
}
|
|
293
|
+
export interface ReqUpdateLedger {
|
|
294
|
+
readonly type: "reqUpdateLedger";
|
|
295
|
+
readonly auth: DashAuthType;
|
|
296
|
+
readonly ledger: UpdateLedger;
|
|
297
|
+
}
|
|
298
|
+
export interface ResUpdateLedger {
|
|
299
|
+
readonly type: "resUpdateLedger";
|
|
300
|
+
readonly ledger: LedgerUser;
|
|
301
|
+
}
|
|
302
|
+
export interface DeleteLedger {
|
|
303
|
+
readonly ledgerId: string;
|
|
304
|
+
readonly tenantId: string;
|
|
305
|
+
}
|
|
306
|
+
export interface ReqDeleteLedger {
|
|
307
|
+
readonly type: "reqDeleteLedger";
|
|
308
|
+
readonly auth: DashAuthType;
|
|
309
|
+
readonly ledger: DeleteLedger;
|
|
310
|
+
}
|
|
311
|
+
export interface ResDeleteLedger {
|
|
312
|
+
readonly type: "resDeleteLedger";
|
|
313
|
+
}
|
|
314
|
+
export interface ReqCloudSessionToken {
|
|
315
|
+
readonly type: "reqCloudSessionToken";
|
|
316
|
+
readonly auth: DashAuthType;
|
|
317
|
+
readonly selected?: Partial<TenantLedger>;
|
|
318
|
+
readonly resultId?: string;
|
|
319
|
+
}
|
|
320
|
+
export interface ResCloudSessionToken {
|
|
321
|
+
readonly type: "resCloudSessionToken";
|
|
322
|
+
readonly token: string;
|
|
323
|
+
}
|
|
324
|
+
export interface ReqTokenByResultId {
|
|
325
|
+
readonly type: "reqTokenByResultId";
|
|
326
|
+
readonly resultId: string;
|
|
327
|
+
}
|
|
328
|
+
export interface ResTokenByResultId {
|
|
329
|
+
readonly type: "resTokenByResultId";
|
|
330
|
+
readonly status: "found" | "not-found";
|
|
331
|
+
readonly resultId: string;
|
|
332
|
+
readonly token?: string;
|
|
333
|
+
}
|
|
334
|
+
export interface ResDeleteTenant {
|
|
335
|
+
readonly type: "resDeleteTenant";
|
|
336
|
+
readonly tenantId: string;
|
|
337
|
+
}
|
|
338
|
+
export interface ReqDeleteTenant {
|
|
339
|
+
readonly type: "reqDeleteTenant";
|
|
340
|
+
readonly auth: DashAuthType;
|
|
341
|
+
readonly tenantId: string;
|
|
342
|
+
}
|
|
343
|
+
export interface OutTenantParams {
|
|
344
|
+
readonly tenantId: string;
|
|
345
|
+
readonly name: string;
|
|
346
|
+
readonly ownerUserId: string;
|
|
347
|
+
readonly maxAdminUsers: number;
|
|
348
|
+
readonly maxMemberUsers: number;
|
|
349
|
+
readonly maxInvites: number;
|
|
350
|
+
readonly maxLedgers: number;
|
|
351
|
+
readonly status: UserStatus;
|
|
352
|
+
readonly statusReason: string;
|
|
353
|
+
readonly createdAt: Date;
|
|
354
|
+
readonly updatedAt: Date;
|
|
355
|
+
}
|
|
356
|
+
export interface ResEnsureUser {
|
|
357
|
+
readonly type: "resEnsureUser";
|
|
358
|
+
readonly user: User;
|
|
359
|
+
readonly tenants: UserTenant[];
|
|
360
|
+
}
|
|
361
|
+
export interface ReqEnsureUser {
|
|
362
|
+
readonly type: "reqEnsureUser";
|
|
363
|
+
readonly auth: DashAuthType;
|
|
364
|
+
}
|
|
365
|
+
interface RoleBase {
|
|
366
|
+
readonly tenantId?: string;
|
|
367
|
+
readonly ledgerId?: string;
|
|
368
|
+
readonly userId: string;
|
|
369
|
+
readonly role: Role;
|
|
370
|
+
readonly adminUserIds: string[];
|
|
371
|
+
readonly memberUserIds: string[];
|
|
372
|
+
}
|
|
373
|
+
interface TenantRole extends RoleBase {
|
|
374
|
+
readonly tenantId: string;
|
|
375
|
+
}
|
|
376
|
+
interface LedgerRole extends RoleBase {
|
|
377
|
+
readonly ledgerId: string;
|
|
378
|
+
readonly right: ReadWrite;
|
|
379
|
+
}
|
|
380
|
+
export type RoleType = TenantRole | LedgerRole;
|
|
381
|
+
export interface ReqInsertTenant {
|
|
382
|
+
readonly tenantId: string;
|
|
383
|
+
readonly name?: string;
|
|
384
|
+
readonly ownerUserId: string;
|
|
385
|
+
readonly adminUserIds?: string[];
|
|
386
|
+
readonly memberUserIds?: string[];
|
|
387
|
+
readonly maxAdminUsers?: number;
|
|
388
|
+
readonly maxMemberUsers?: number;
|
|
389
|
+
readonly createdAt?: Date;
|
|
390
|
+
readonly updatedAt?: Date;
|
|
391
|
+
}
|
|
392
|
+
export interface ReqExtendToken {
|
|
393
|
+
readonly type: "reqExtendToken";
|
|
394
|
+
readonly token: string;
|
|
395
|
+
}
|
|
396
|
+
export interface ResExtendToken {
|
|
397
|
+
readonly type: "resExtendToken";
|
|
398
|
+
readonly token: string;
|
|
399
|
+
}
|
|
400
|
+
export interface ReqCertFromCsr {
|
|
401
|
+
readonly type: "reqCertFromCsr";
|
|
402
|
+
readonly auth: DashAuthType;
|
|
403
|
+
readonly csr: string;
|
|
404
|
+
}
|
|
405
|
+
export interface ResCertFromCsr {
|
|
406
|
+
readonly type: "resCertFromCsr";
|
|
407
|
+
readonly certificate: string;
|
|
408
|
+
}
|
|
409
|
+
export interface ReqEnsureCloudToken {
|
|
410
|
+
readonly type: "reqEnsureCloudToken";
|
|
411
|
+
readonly auth: DashAuthType;
|
|
412
|
+
readonly appId: string;
|
|
413
|
+
readonly env?: string;
|
|
414
|
+
readonly tenant?: string;
|
|
415
|
+
readonly ledger?: string;
|
|
416
|
+
readonly prevCloudToken?: string;
|
|
417
|
+
}
|
|
418
|
+
export interface ResEnsureCloudToken {
|
|
419
|
+
readonly type: "resEnsureCloudToken";
|
|
420
|
+
readonly cloudToken: string;
|
|
421
|
+
readonly appId: string;
|
|
422
|
+
readonly tenant: string;
|
|
423
|
+
readonly ledger: string;
|
|
424
|
+
readonly expiresInSec: number;
|
|
425
|
+
readonly expiresDate: string;
|
|
426
|
+
readonly claims: FPCloudClaim;
|
|
427
|
+
}
|
|
428
|
+
export {};
|
package/msg-types.js
ADDED
package/msg-types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"msg-types.js","sourceRoot":"","sources":["../jsr/msg-types.ts"],"names":[],"mappings":"AA6OA,MAAM,UAAU,OAAO,CAAC,EAAc,EAAE;IACtC,OAAO,EAAE,CAAC,IAAI,KAAK,OAAO,CAAC;AAAA,CAC5B"}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fireproof/core-types-protocols-dashboard",
|
|
3
|
+
"version": "0.0.0-smoke-70bdee6c-1767993865",
|
|
4
|
+
"description": "Live ledger for the web.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./index.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "core-cli tsc"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"ledger",
|
|
12
|
+
"JSON",
|
|
13
|
+
"document",
|
|
14
|
+
"IPLD",
|
|
15
|
+
"CID",
|
|
16
|
+
"IPFS"
|
|
17
|
+
],
|
|
18
|
+
"contributors": [
|
|
19
|
+
"J Chris Anderson",
|
|
20
|
+
"Alan Shaw",
|
|
21
|
+
"Travis Vachon",
|
|
22
|
+
"Mikeal Rogers",
|
|
23
|
+
"Meno Abels"
|
|
24
|
+
],
|
|
25
|
+
"author": "J Chris Anderson",
|
|
26
|
+
"license": "AFL-2.0",
|
|
27
|
+
"homepage": "https://use-fireproof.com",
|
|
28
|
+
"gptdoc": "import { fireproof } from 'use-fireproof'; const db = fireproof('app-db-name'); const ok = await db.put({ anyField: ['any','json'] }); const doc = await db.get(ok.id); await db.del(doc._id); db.subscribe(myRedrawFn); const result = await db.query('anyField', {range : ['a', 'z']}); result.rows.map(({ key }) => key);",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/fireproof-storage/fireproof.git"
|
|
32
|
+
},
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/fireproof-storage/fireproof/issues"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@adviser/cement": "0.5.15",
|
|
38
|
+
"@fireproof/core-types-base": "0.0.0-smoke-70bdee6c-1767993865",
|
|
39
|
+
"@fireproof/core-types-device-id": "0.0.0-smoke-70bdee6c-1767993865",
|
|
40
|
+
"@fireproof/core-types-protocols-cloud": "0.0.0-smoke-70bdee6c-1767993865"
|
|
41
|
+
}
|
|
42
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": [
|
|
3
|
+
"/Users/menabe/Software/fproof/fireproof/tsconfig.dist.json"
|
|
4
|
+
],
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"outDir": "../npm/",
|
|
7
|
+
"noEmit": false
|
|
8
|
+
},
|
|
9
|
+
"include": [
|
|
10
|
+
"**/*"
|
|
11
|
+
],
|
|
12
|
+
"exclude": [
|
|
13
|
+
"node_modules",
|
|
14
|
+
"dist",
|
|
15
|
+
".git",
|
|
16
|
+
".vscode"
|
|
17
|
+
]
|
|
18
|
+
}
|