@tiddlywiki/mws 0.0.14 → 0.0.16

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.
@@ -1,5 +1,5 @@
1
- created: 20250426194618683
2
- list: [[MWS and SQLite]] HelloThere Installation Usage Reference
3
- modified: 20250426194618683
1
+ created: 20250428174600355
2
+ list: [[Access Control]] [[Moduler Design]] [[MWS and SQLite]] [[Request Server]] Architecture HelloThere Installation Usage Reference
3
+ modified: 20250428174603436
4
4
  title: $:/StoryList
5
5
  type: text/vnd.tiddlywiki
@@ -0,0 +1,17 @@
1
+ Access Control is implemented separately for both recipes and bags, but bags can inherit the ACL of recipes they are added to.
2
+
3
+ ### Permission Inheritance
4
+ - Users receive combined permissions from all assigned roles
5
+ - When roles grant different permission levels for the same resource, the higher access level is granted. For example, if one role grants "read" and another grants "write" access to a recipe, the user receives "write" access since it includes all lower-level permissions. If a role grants "admin", it inherits both "read" and "write".
6
+
7
+ ### "Readonly" permission
8
+
9
+ If this were reversed, and users with explicit "read" access were forbidden from writing, it would significantly complicate roles.
10
+
11
+ Imagine a group of engineers working on several projects. Each project has people who are responsible for editing the documentation for everyone else. So everyone needs to be granted the read permission on all projects, but only a few people are granted the write permission on each project.
12
+
13
+ The easiest approach is to maintain one role which grants "read" access to all users, and then maintain additional roles to grant "write" access to the users responsible for each project.
14
+
15
+ If granting read access explicitly prevented a user from writing, we would need to create two roles for each project, one which which grants write access for the project, and another which grants read access to all other projects.
16
+
17
+ Every time a new project is added, all other projects would need to grant "read" access to that new "all projects but one" role on every single wiki for every single project in the entire organization.
@@ -0,0 +1,5 @@
1
+ created: 20250428145509001
2
+ modified: 20250428174641314
3
+ tags: Architecture
4
+ title: Access Control
5
+ type: text/markdown
@@ -0,0 +1,98 @@
1
+
2
+ Users can be administered through two interfaces:
3
+
4
+ 1. Web-based Administrative Interface
5
+ - Accessible to all users.
6
+ - Provides graphical interface for user operations
7
+ - Real-time validation and feedback
8
+ 1. Command-line Interface (CLI) Tools
9
+ - Only available to server owner.
10
+ - Suitable for automation and scripting
11
+ - Enables batch operations
12
+ - Useful for system initialization
13
+
14
+ Each user account contains the following essential components:
15
+
16
+ - **Username**
17
+ - Must be unique across the system
18
+ - Case-sensitive
19
+ - Used for authentication and audit trails
20
+ - **Password**
21
+ - Stored using secure hashing algorithms
22
+ - Never stored in plaintext
23
+ - Subject to complexity requirements
24
+ - **Email**
25
+ - Eventually used for the obvious password reset.
26
+ - **Role Assignments**
27
+ - Multiple roles can be assigned
28
+ - Inherited permissions from all assigned roles
29
+ - Dynamic permission calculation based on role combination
30
+
31
+ ## Access Levels
32
+
33
+ Conceptually, there are 6 access levels.
34
+
35
+ - **Site owner** - has file system access to the server, and can run CLI commands. Presumably they also have a site admin account.
36
+ - **Site admin** - Users with the admin *role*. They can assign owners and change permissions, and have full read and write access. Most ACL checks are skipped for the admin role.
37
+ - **Entity owner** - Users who "own" an entity (bag or recipe). They can change permissions for that entity, and have full read and write access. *Entity admins* cannot change the owner.
38
+ - **Entity admin** - Users granted the admin *permission* on an entity. They cannot change the owner, but they can change the permissions of other users for that entity.
39
+ - **Entity write** - Users granted the write *permission* on an enitity. They can list, read, create, update, and delete tiddlers, but cannot change permissions.
40
+ - **Entity read** - Users granted the read *permission* on an entity. They can list and read tiddlers, but cannot do anything else.
41
+
42
+ ## Entities
43
+
44
+ - **Bag** - A collection of tiddlers with unique titles
45
+ - **Recipe** - A stack of bags in a specific order. Bags may inherit the ACL of a recipe they are included in.
46
+
47
+ ## Roles
48
+
49
+ - Roles have names and descriptions
50
+ - Multiple users can be assigned to a role
51
+
52
+ ## Permissions
53
+
54
+ - **READ** - Read tiddlers from an entity.
55
+ - **WRITE** - Write tiddlers to an entity.
56
+ - **ADMIN** - Update ACL for an entity.
57
+
58
+ ## Admin
59
+
60
+ - There is an admin *role* and an admin *permission*.
61
+ - Roles are given specific permissions for specific entities (bags and recipes).
62
+ - The admin *role* has automatic admin *permission* for everything.
63
+
64
+ ## ACL
65
+
66
+ - Grants the **Permission** for an **Entity** to a **Role**.
67
+ - Entities without an ACL are either public or private (configurable).
68
+
69
+ ## Ownership
70
+
71
+ - Ownership of an entity grants the "admin" *permission*.
72
+ - Only site admins can change the owner of an entity.
73
+ - Users with "admin" *permission* **cannot** change ownership.
74
+
75
+ ## User Types
76
+
77
+ #### Administrator (ADMIN) Role
78
+
79
+ - Full system access and configuration rights
80
+ - Most access checks are skipped
81
+ - Can create, modify, and delete user accounts
82
+ - Manages role assignments and permissions
83
+ - Has full permissions on all recipes and bags
84
+
85
+ #### Regular Users
86
+
87
+ - Created by administrators
88
+ - Permissions determined by assigned roles
89
+ - Access limited to specific recipes based on role permissions
90
+ - Access to recipes without an ACL is based on recipe config
91
+
92
+ #### Guest Users
93
+
94
+ - Users not logged in.
95
+ - No inherent permissions
96
+ - Can access recipes which allow it
97
+ - Read/write can be enabled by server config
98
+ - Useful for public wikis or documentation sites
@@ -0,0 +1,5 @@
1
+ created: 20250428144431745
2
+ modified: 20250428152640317
3
+ tags: Reference
4
+ title: Application Access & Security
5
+ type: text/markdown
@@ -0,0 +1,17 @@
1
+ The MultiWikiServer HTTP API provides management and tiddler endpoints.
2
+
3
+ The design goals of the API are:
4
+
5
+ - Connect the client and server as transparently as possible.
6
+ - Be easy to understand and use via Javascript.
7
+ - Have strict validation of incoming requests.
8
+
9
+ ## Management
10
+
11
+ - On the client, most request paths are defined by a single adaptor function which accepts the input for the server and returns a promise which resolves to the server's parsed response.
12
+ - The server may throw a user error (or a string), which is expected to return to the client. It should give them an actionable understanding of what went wrong.
13
+ - The API essentially forwards a function call from the client to the server, using `fetch`. It expects a Javascript client, and is not intended to support form submissions directly.
14
+
15
+ ## Tiddler
16
+
17
+ The tiddler API was based on [the API of TiddlyWeb](https://tank.peermore.com/tanks/tiddlyweb/HTTP%20API), first developed in 2008 by Chris Dent, but is more oriented around JSON and Typescript. The concept of resources remains and in the future it will hopefully be adapted to serve static versions of tiddlers.
@@ -0,0 +1,5 @@
1
+ created: 20250428152532763
2
+ modified: 20250428152617476
3
+ tags: Reference
4
+ title: HTTP API
5
+ type: text/markdown
@@ -1,5 +1,5 @@
1
1
  created: 20241105133737778
2
- modified: 20250417165800863
2
+ modified: 20250428144159846
3
3
  tags: TableOfContents
4
4
  title: Installation
5
5
  type: text/vnd.tiddlywiki
@@ -20,5 +20,14 @@ See [[Troubleshooting]] if you encounter any errors.
20
20
  To update your copy of MWS in the future with newer changes will require re-downloading the code, taking care not to lose any changes you might have made.
21
21
 
22
22
  # Make a backup: Copy or zip your project folder to a safe backup folder. <<.copy-code-to-clipboard "tar -cf archive.tar my_folder">>
23
- # Get the latest version. Notice that the second word is `install` instead of `init`. This pulls the latest version from NPM and installs it. <<.copy-code-to-clipboard "npm install @tiddlywiki/mws@latest">>
23
+ # Get the latest version. Notice that the second word is `install` instead of `init`. This pulls the latest version from NPM and installs it. <<.copy-code-to-clipboard "npm install @tiddlywiki/mws@latest --save-exact">>
24
24
  # Start the server. On startup, MWS checks the database schema and updates it automatically if there are changes. Normally this works just fine, but it can fail, which is why it's important to save a backup first. <<.copy-code-to-clipboard "npm start">>
25
+
26
+ !!! Git repo
27
+
28
+ It is optionally recommended to save a history of your project configuration using git.
29
+
30
+ * On Windows you can use [[GitHub Desktop|https://github.com/apps/desktop]].
31
+ * On Linux, git is usually preinstalled or available via the default package manager for your distro.
32
+
33
+ If you decide to do this, you should move the wiki folder out of the project folder, and change the `wikiPath` setting accordingly.
@@ -22,3 +22,8 @@
22
22
 
23
23
  - Maps route definitions into service handlers
24
24
  - HTTP, Websockets
25
+
26
+ ### Database Connector
27
+ - Prisma handles query translation (wasm or native addon)
28
+ - Prisma supports custom adapters, and also provides standard ones
29
+ - Connector classes in MWS take care of database setup and schema updates
@@ -1,5 +1,5 @@
1
1
  created: 20250418140335465
2
- modified: 20250418183050517
2
+ modified: 20250428143321351
3
3
  tags: Architecture
4
4
  title: Moduler Design
5
5
  type: text/markdown
@@ -1,149 +0,0 @@
1
- # Authentication & Authorization
2
-
3
- ## Overview
4
-
5
- Our application has transitioned from a conventional username/password authentication system to a more robust Authentication and Authorization implementation. This new system supports multiple user accounts, roles, permissions, and a comprehensive access control list.
6
-
7
- ## Key Features
8
-
9
- 1. Multiple User Accounts
10
- 1. Role-based Access Control
11
- 1. Granular Permissions
12
- 1. Access Control List (ACL)
13
-
14
- ## Application Access & Security
15
-
16
- ### Access Levels
17
-
18
- Conceptually, there are 6 access levels.
19
-
20
- - **Site owner** - has file system access to the server, and can run CLI commands. Presumably they also have a site admin account.
21
- - **Site admin** - Users with the admin *role*. They can assign owners and change permissions, and have full read and write access.
22
- - **Entity owner** - Users who "own" an entity (bag or recipe). They can change permissions for that entity, and have full read and write access.
23
- - **Entity admin** - Users granted the admin *permission* on an entity. They cannot change the owner, but they can change the permissions of other users for that entity.
24
- - **Entity write** - Users granted the write *permission* on an enitity. They can list, read, create, update, and delete tiddlers, but cannot change permissions.
25
- - **Entity read** - Users granted the read *permission* on an entity. They can list and read tiddlers, but cannot do anything else.
26
-
27
- ### Initial Setup
28
-
29
- When you first launch the Multiwiki Server, it creates a default admin user. The username is `admin` and the password is `1234`. To secure your installation you should change this immediately.
30
-
31
- ### Entities
32
-
33
- - **Bag** - A collection of tiddlers with unique titles
34
- - **Recipe** - A stack of bags in a specific order. Bags may inherit the ACL of a recipe they are included in.
35
-
36
- ### Roles
37
-
38
- - Roles have names and descriptions
39
- - Multiple users can be assigned to a role
40
-
41
- ### Permissions
42
-
43
- - **READ** - Read tiddlers from an entity.
44
- - **WRITE** - Write tiddlers to an entity.
45
- - **ADMIN** - Update ACL for an entity.
46
-
47
- ### ACL
48
-
49
- - Grants the **Permission** for an **Entity** to a **Role**.
50
- - Entities without an ACL are either public or private (configurable).
51
-
52
- ### Ownership
53
-
54
- - Ownership of an entity grants the "admin" *permission*.
55
- - Only site admins can change the owner of an entity.
56
- - Users with "admin" *permission* **cannot** change ownership.
57
-
58
- ### User Types
59
-
60
- #### Administrator (ADMIN) Role
61
-
62
- - Full system access and configuration rights
63
- - Most access checks are skipped
64
- - Can create, modify, and delete user accounts
65
- - Manages role assignments and permissions
66
- - Has full permissions on all recipes and bags
67
-
68
- #### Regular Users
69
-
70
- - Created by administrators
71
- - Permissions determined by assigned roles
72
- - Access limited to specific recipes based on role permissions
73
- - Access to recipes without an ACL is based on recipe config
74
-
75
- #### Guest Users
76
-
77
- - Users not logged in.
78
- - No inherent permissions
79
- - Can access recipes which allow it
80
- - Read/write can be enabled by server config
81
- - Useful for public wikis or documentation sites
82
-
83
- ### Access Control
84
-
85
- Access Control is implemented separately for both recipes and bags, but bags can in inherit the ACL of recipes they are added to.
86
-
87
- #### Permission Inheritance
88
- - Users receive combined permissions from all assigned roles
89
- - When roles grant different permission levels for the same resource, the higher access level is granted. For example, if one role grants "read" and another grants "write" access to a recipe, the user receives "write" access since it includes all lower-level permissions.
90
-
91
- If this were reversed, and users with explicit "read" access were forbidden from writing, it would significantly complicate roles.
92
-
93
- Imagine a group of engineers working on several projects. Each project has people who are responsible for editing the documentation for everyone else. So everyone needs to be granted the read permission on all projects, but only a few people are granted the write permission on each project.
94
-
95
- The easiest approach is to maintain one role which grants "read" access to all users, and then maintain additional roles to grant "write" access to the users responsible for each project.
96
-
97
- If granting read access explicitly prevented a user from writing, we would need to create two roles for each project, one which which grants write access for the project, and another which grants read access to all other projects.
98
-
99
- Every time a new project is added, all other projects would need to grant "read" access to that new "all projects but one" role on every single wiki for every single project in the entire organization.
100
-
101
- ## User Management & Security Architecture
102
-
103
- ### User Account Management
104
-
105
- Users can be administered through two interfaces:
106
-
107
- 1. Web-based Administrative Interface
108
- - Accessible to all users.
109
- - Provides graphical interface for user operations
110
- - Real-time validation and feedback
111
- 1. Command-line Interface (CLI) Tools
112
- - Only available to server owner.
113
- - Suitable for automation and scripting
114
- - Enables batch operations
115
- - Useful for system initialization
116
-
117
- Each user account contains the following essential components:
118
-
119
- - **Username**
120
- - Must be unique across the system
121
- - Case-sensitive
122
- - Used for authentication and audit trails
123
- - **Password**
124
- - Stored using secure hashing algorithms
125
- - Never stored in plaintext
126
- - Subject to complexity requirements
127
- - **Email**
128
- - Eventually used for the obvious password reset.
129
- - **Role Assignments**
130
- - Multiple roles can be assigned
131
- - Inherited permissions from all assigned roles
132
- - Dynamic permission calculation based on role combination
133
-
134
- # HTTP API
135
-
136
- The MultiWikiServer HTTP API provides management and tiddler endpoints. It was based on [the API of TiddlyWeb](https://tank.peermore.com/tanks/tiddlyweb/HTTP%20API), first developed in 2008 by Chris Dent, but is more oriented around JSON and Typescript.
137
-
138
- The design goals of the API are:
139
-
140
- - Connect the client and server as transparently as possible.
141
- - Follow the principles of remote procedure calls.
142
- - Be easy to understand and use via Javascript.
143
- - Have strict validation of incoming requests.
144
-
145
- General points about the design:
146
-
147
- - On the client, most request paths are defined by a single adaptor function which accepts the input for the server and returns a promise which resolves to the server's parsed response.
148
- - The server may throw a user error, which is expected to return to the client. It should give them an actionable understanding of what went wrong.
149
-
@@ -1,2 +1,5 @@
1
+ created: 20250428144428969
2
+ modified: 20250428152626286
3
+ tags: TableOfContents
1
4
  title: Reference
2
- tags: TableOfContents
5
+ type: text/x-markdown
@@ -1,5 +1,5 @@
1
1
  created: 20241105133737778
2
- modified: 20250417170530535
2
+ modified: 20250428144341860
3
3
  tags: TableOfContents
4
4
  title: Usage
5
5
  type: text/vnd.tiddlywiki
@@ -8,7 +8,7 @@ Once MWS is successfully [[installed|Installation]], you can access it by visiti
8
8
 
9
9
  On first start, a default user is created with username `admin` and password `1234`. However, also by default, the server is only accessible to browsers on the same machine.
10
10
 
11
- If you intend to put an MWS installation on a public network like the Internet, the server will need to be secured with the following steps:
11
+ If you intend to make an MWS installation available on the Internet, the server should first be secured with the following steps:
12
12
 
13
- * Change the administrator password.
13
+ * Change the administrator password
14
14
  * Install HTTPS server certificates.
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@tiddlywiki/mws",
3
+ "description": "TiddlyWiki Multiple Wiki Server",
3
4
  "private": false,
4
- "version": "0.0.14",
5
+ "version": "0.0.16",
5
6
  "type": "module",
6
7
  "exports": {
7
8
  "types": "./src/server.ts",
@@ -33,7 +34,7 @@
33
34
  "prisma": "npm run gen:client && npm run gen:sql",
34
35
  "prisma:studio": "DATABASE_URL=file:../editions/mws/store/database.sqlite prisma studio",
35
36
  "certs": "(cd runtime-config && bash localhost_certs.sh)",
36
- "start": "npm run build && node mws.dev.mjs",
37
+ "start": "SKIPDTS=1 npm run build && node mws.dev.mjs init-store && node mws.dev.mjs listen",
37
38
  "build": "npm run tsc && tsup",
38
39
  "install-android": "GYP_DEFINES=\"android_ndk_path=''\" npm install",
39
40
  "postinstall": "env-cmd -e prisma-env prisma generate",
@@ -42,7 +43,8 @@
42
43
  "test": "(git clean -dfx tests && cd tests && npm install .. --no-save && npm test)",
43
44
  "fulltest": "mv node_modules node_modules_old; npm run test:pack; mv node_modules_old node_modules",
44
45
  "prisma:adapter:better": "cp -rfv ../prisma/packages/adapter-better-sqlite3/src/* src/adapter-better-sqlite3",
45
- "prisma:adapter:libsql": "cp -rfv ../prisma/packages/adapter-libsql/src/* src/adapter-libsql"
46
+ "prisma:adapter:libsql": "cp -rfv ../prisma/packages/adapter-libsql/src/* src/adapter-libsql",
47
+ "prepublishOnly": "npm run build && node mws.dev.mjs --client-build"
46
48
  },
47
49
  "dependencies": {
48
50
  "@prisma/adapter-better-sqlite3": "6.7.0-dev.48",
@@ -59,6 +61,7 @@
59
61
  "zod": "^3.24.2"
60
62
  },
61
63
  "devDependencies": {
64
+ "commander": "^13.1.0",
62
65
  "esbuild": "0.25.2",
63
66
  "mime-types": "^2.1.35",
64
67
  "send": "^1.1.0",