rasler 0.1.0

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 ADDED
@@ -0,0 +1,180 @@
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 made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other transformations
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
48
+ in the Work by the copyright owner or by an individual or Legal Entity
49
+ authorized to submit on behalf of the copyright owner. For the purposes
50
+ of this definition, "submitted" means any form of electronic, verbal,
51
+ or written communication sent to the Licensor or its representatives,
52
+ including but not limited to communication on electronic mailing lists,
53
+ source code control systems, and issue tracking systems that are managed
54
+ by, or on behalf of, the Licensor for the purpose of submitting the Work,
55
+ but excluding communication that is conspicuously marked or designated
56
+ in writing by the copyright owner as "Not a Contribution."
57
+
58
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
59
+ whom a Contribution has been received by the Licensor and included
60
+ within the Work.
61
+
62
+ 2. Grant of Copyright License. Subject to the terms and conditions of
63
+ this License, each Contributor hereby grants to You a perpetual,
64
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
65
+ copyright license to reproduce, prepare Derivative Works of,
66
+ publicly display, publicly perform, sublicense, and distribute the
67
+ Work and such Derivative Works in Source or Object form.
68
+
69
+ 3. Grant of Patent License. Subject to the terms and conditions of
70
+ this License, each Contributor hereby grants to You a perpetual,
71
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
72
+ (except as stated in this section) patent license to make, have made,
73
+ use, offer to sell, sell, import, and otherwise transfer the Work,
74
+ where such license applies only to those patent claims licensable
75
+ by such Contributor that are necessarily infringed by their
76
+ Contribution(s) alone or by the combined work (Contribution(s) with
77
+ the Work to which such Contribution(s) was submitted). If You
78
+ institute patent litigation against any entity (including a cross-claim
79
+ or counterclaim in a lawsuit) alleging that the Work or any Works
80
+ constitute patent infringement, then any and all patent licenses
81
+ granted to You under this License for that Work shall terminate as
82
+ of the date such litigation is filed.
83
+
84
+ 4. Redistribution. You may reproduce and distribute copies of the
85
+ Work or Derivative Works thereof in any medium, with or without
86
+ modifications, and in Source or Object form, provided that You
87
+ meet the following conditions:
88
+
89
+ (a) You must give any other recipients of the Work or Derivative
90
+ Works a copy of this License; and
91
+
92
+ (b) You must cause any modified files to carry prominent notices
93
+ stating that You changed the files; and
94
+
95
+ (c) You must retain, in the Source form of any Derivative Works
96
+ that You distribute, all copyright, patent, trademark, and
97
+ attribution notices from the Source form of the Work,
98
+ excluding those notices that do not pertain to any part of
99
+ the Derivative Works; and
100
+
101
+ (d) If the Work includes a "NOTICE" text file as part of its
102
+ distribution, You must include a readable copy of the
103
+ attribution notices contained within such NOTICE file, in
104
+ at least one of the following places: within a NOTICE text
105
+ file distributed as part of the Derivative Works; within
106
+ the Source form or documentation, if provided along with the
107
+ Derivative Works; or, within a display generated by the
108
+ Derivative Works, if and wherever such third-party notices
109
+ normally appear. The contents of the NOTICE file are for
110
+ informational purposes only and do not modify the License.
111
+ You may add Your own attribution notices within Derivative
112
+ Works that You distribute, alongside or in addition to the
113
+ NOTICE text from the Work, provided that such additional
114
+ attribution notices cannot be construed as modifying the License.
115
+
116
+ You may add Your own license statement for Your modifications and
117
+ may provide additional grant of rights to use, copy, modify, merge,
118
+ publish, distribute, sublicense, and/or sell copies of the
119
+ Derivative Works, and to permit persons to whom the Derivative Works
120
+ is furnished to do so, subject to the following conditions:
121
+
122
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
123
+ any Contribution intentionally submitted for inclusion in the Work
124
+ by You to the Licensor shall be under the terms and conditions of
125
+ this License, without any additional terms or conditions.
126
+ Notwithstanding the above, nothing herein shall supersede or modify
127
+ the terms of any separate license agreement you may have executed
128
+ with Licensor regarding such Contributions.
129
+
130
+ 6. Trademarks. This License does not grant permission to use the trade
131
+ names, trademarks, service marks, or product names of the Licensor,
132
+ except as required for reasonable and customary use in describing the
133
+ origin of the Work and reproducing the content of the NOTICE file.
134
+
135
+ 7. Disclaimer of Warranty. Unless required by applicable law or
136
+ agreed to in writing, Licensor provides the Work (and each
137
+ Contributor provides its Contributions) on an "AS IS" BASIS,
138
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
139
+ implied, including, without limitation, any warranties or conditions
140
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
141
+ PARTICULAR PURPOSE. You are solely responsible for determining the
142
+ appropriateness of using or reproducing the Work and assume any
143
+ risks associated with Your exercise of permissions under this License.
144
+
145
+ 8. Limitation of Liability. In no event and under no legal theory,
146
+ whether in tort (including negligence), contract, or otherwise,
147
+ unless required by applicable law (such as deliberate and grossly
148
+ negligent acts) or agreed to in writing, shall any Contributor be
149
+ liable to You for damages, including any direct, indirect, special,
150
+ incidental, or exemplary damages of any character arising as a
151
+ result of this License or out of the use or inability to use the
152
+ Work (including but not limited to damages for loss of goodwill,
153
+ work stoppage, computer failure or malfunction, or all other
154
+ commercial damages or losses), even if such Contributor has been
155
+ advised of the possibility of such damages.
156
+
157
+ 9. Accepting Warranty or Liability. While redistributing the Work or
158
+ Derivative Works thereof, You may choose to offer, and charge a fee
159
+ for, acceptance of support, warranty, indemnity, or other liability
160
+ obligations and/or rights consistent with this License. However, in
161
+ accepting such obligations, You may offer only conditions that are
162
+ consistent with the terms of this License, and may require that each
163
+ Contributor, on behalf of the Licensor, provides such warranty,
164
+ indemnity, or other obligations as set forth in this License.
165
+
166
+ END OF TERMS AND CONDITIONS
167
+
168
+ Copyright 2025 Wes Biggs
169
+
170
+ Licensed under the Apache License, Version 2.0 (the "License");
171
+ you may not use this file except in compliance with the License.
172
+ You may obtain a copy of the License at
173
+
174
+ http://www.apache.org/licenses/LICENSE-2.0
175
+
176
+ Unless required by applicable law or agreed to in writing, software
177
+ distributed under the License is distributed on an "AS IS" BASIS,
178
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
179
+ See the License for the specific language governing permissions and
180
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,140 @@
1
+ # RASLer
2
+
3
+ RASLer is a HTTP server that implements [RASL](https://dasl.ing/rasl.html)'s `/.well-known/rasl/` endpoint, backed by content-addressed storage, [MASL](https://dasl.ing/masl.html) metadata support, and a full-featured operator API.
4
+
5
+ ## Features
6
+
7
+ - **Storage** — content blobs are stored by CID on disk, backed by a SQLite database that enables capacity management and a pluggable eviction policy
8
+ - **DASL & MASL CIDs** — content serving by simple DASL CIDs, or via MASL CIDs with path-based resolution for both single files and website bundles as per the proposed specification (see ["RASL Path Resolution via MASL"](RASL_MASL_PROPOSAL.md))
9
+ - **Static roots** — serve files from local directories by CID without copying them into the blob store
10
+ - **Mount points** - use human-friendly URLs with virtual hosts and MASL paths
11
+ - **Operator API** — upload raw files or CARs, pin/unpin, and evict; manage mount points; status, etc.
12
+ - **Server factory** — compose your own server including RASL functionality
13
+
14
+ ## Quick start
15
+
16
+ ```bash
17
+ npm install
18
+ cp .env.example .env
19
+ # edit .env and set API_SECRET
20
+ cp rasler.config.example.json rasler.config.json # optional — configure static roots, mount points, CORS
21
+ npm start
22
+ # open http://localhost:3000/api-docs in a browser
23
+ ```
24
+
25
+ From the API docs UI, you can:
26
+ - Enter `API_SECRET` to authenticate
27
+ - Upload one or more files (or CARs with MASL metadata, see [Utilities](#utilities) for help building) and record their MASL CIDs
28
+
29
+ Once uploaded, you can access the files at `http://localhost:3000/.well-known/rasl/<cid>/`.
30
+
31
+ ## Slow start
32
+
33
+ See [USE_CASES](USE_CASES.md) for an overview of common deployment patterns including virtual hosting and static roots.
34
+
35
+ ## Configuration
36
+
37
+ ### Environment variables (`.env`)
38
+
39
+ | Variable | Required | Default | Description |
40
+ |---|---|---|---|
41
+ | `ORIGIN` | No | `http://localhost:<PORT>` | This node's public origin, protocol included (e.g. `https://node1.example.com`). Used in `Link: rel="duplicate"` headers. A bare hostname without protocol is accepted and defaults to `https://`. |
42
+ | `API_SECRET` | Yes | — | Pre-shared secret to send as `x-rasl-operator-secret` header |
43
+ | `PORT` | No | `3000` | HTTP listen port |
44
+ | `DATA_DIR` | No | `./data` | Directory for the SQLite database and content blobs |
45
+ | `TOTAL_CAPACITY` | No | `1G` | Storage budget (`200M`, `1G`, `2GB`, plain bytes) |
46
+ | `OPERATOR_API_PATH_PREFIX` | No | — | Mount operator API under a path prefix (e.g. `/admin`) |
47
+ | `SWAGGER_UI` | No | `true` | Set `false` to disable the interactive API docs at `<operator-api-path-prefix>/api-docs` |
48
+
49
+ ### `rasler.config.json`
50
+
51
+ Static roots, mount points, and CORS origins are configured in an optional `rasler.config.json` file in the working directory. Copy `rasler.config.example.json` to get started.
52
+
53
+ ```json
54
+ {
55
+ "staticRoots": [
56
+ { "path": "/var/www/assets", "watch": true, "ignore": ["**/*.log", ".DS_Store"] }
57
+ ],
58
+ "mountPoints": [
59
+ { "hostname": "example.com", "directory": "/var/www/html" },
60
+ { "hostname": "example.com", "prefix": "/docs", "directory": "/var/www/docs" }
61
+ ],
62
+ "operatorCorsOrigins": ["http://localhost:5173", "https://admin.example.com"]
63
+ }
64
+ ```
65
+
66
+ | Key | Description |
67
+ |---|---|
68
+ | `staticRoots` | Directories to serve as static RASL roots. String entries use defaults; object entries add `watch` (re-index on change) and `ignore` (glob patterns to skip). See [STATIC_ROOTS](STATIC_ROOTS.md). |
69
+ | `staticMaxHistory` | Maximum pinned MASL versions per static root; older versions are unpinned for LRU eviction. Omit for unlimited. |
70
+ | `mountPoints` | Virtual host mappings: `{ hostname, prefix?, directory }`. See [MOUNT_POINTS](MOUNT_POINTS.md). |
71
+ | `operatorCorsOrigins` | Origins allowed to call the Operator API cross-origin. |
72
+
73
+ **Implicit `./public` mount** — if a `./public` directory exists and no root-level mount point is configured for the origin domain, RASLer automatically serves it at the document root with `Link: rel="duplicate"` headers.
74
+
75
+ ## API
76
+
77
+ ### RASL retrieval (public)
78
+
79
+ | Method | Path | Description |
80
+ |---|---|---|
81
+ | `GET` | `/.well-known/rasl/:cid` | Retrieve raw content by CID |
82
+ | `HEAD` | `/.well-known/rasl/:cid` | Same as GET, no body |
83
+ | `GET` | `/.well-known/rasl/:cid/*` | Retrieve content via MASL document CID; path suffix resolved against MASL resources |
84
+ | `HEAD` | `/.well-known/rasl/:cid/*` | Same as GET, no body |
85
+
86
+ ### Operator API (requires `x-rasl-operator-secret` header)
87
+
88
+ | Method | Path | Description |
89
+ |---|---|---|
90
+ | `GET` | `/status` | Show server status (including storage usage) |
91
+ | `POST` | `/upload` | Upload files (multipart or CAR) |
92
+ | `POST` | `/pin` | Pin CIDs |
93
+ | `DELETE` | `/pin/:cid` | Unpin a CID |
94
+ | `GET` | `/content` | List held content |
95
+ | `GET` | `/content/:cid` | Get content metadata |
96
+ | `DELETE` | `/content/:cid` | Evict a CID |
97
+ | `GET` | `/static-roots` | List configured static roots and their current MASL CIDs |
98
+ | `GET` | `/mount-points` | List all mount points (static and runtime) with their MASL CIDs |
99
+ | `PUT` | `/mount-points/:hostname[/:prefix]` | Map a hostname (with optional path prefix) to a held bundle MASL CID (runtime, persisted) |
100
+ | `DELETE` | `/mount-points/:hostname[/:prefix]` | Remove a runtime mount point mapping |
101
+
102
+ The Operator API can be relocated via the `OPERATOR_API_PATH_PREFIX` environment option.
103
+
104
+ Full request/response details are in `openapi.json` and can be viewed and used interactively if `SWAGGER_UI=true`.
105
+
106
+ ## Utilities
107
+
108
+ The following utility script is included.
109
+
110
+ ```bash
111
+ # Build a CAR file (with MASL bundle header) from a static website directory tree
112
+ npm run get-in-the-car <input-dir> [output.car]
113
+ ```
114
+
115
+ ## Development
116
+
117
+ Contributions are welcome! Please use GitHub Issues to discuss or propose improvements or file bugs.
118
+
119
+ See [ARCHITECTURE](ARCHITECTURE.md) for a code walkthrough as well as details on using RASLer as a library.
120
+
121
+ Pull requests that make changes to the API should include updated JSDoc and a freshly generated `openapi.json`.
122
+
123
+ ### Scripts
124
+
125
+ ```bash
126
+ # Run the node
127
+ npm start
128
+
129
+ # Run tests (includes lint)
130
+ npm test
131
+
132
+ # Lint only
133
+ npm run lint
134
+
135
+ # Regenerate openapi.json from JSDoc in src/routes/operator.js
136
+ npm run generate:openapi
137
+
138
+ # Generate HTML docs from *.md files into ./public
139
+ npm run generate:docs
140
+ ```