Compare commits
5 commits
bbfc07478f
...
74f79ae0b7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
74f79ae0b7 | ||
|
|
a716cf6852 | ||
|
|
e549d7b088 | ||
|
|
31194c8c41 | ||
|
|
4e9f7f634d |
|
|
@ -1,27 +0,0 @@
|
|||
{
|
||||
"version": 1,
|
||||
"log": [
|
||||
{
|
||||
"kind": "stdout",
|
||||
"data": {
|
||||
"threshold": "info",
|
||||
"format": "jsonl_structured"
|
||||
}
|
||||
}
|
||||
],
|
||||
"session_management": {
|
||||
"in_memory": false,
|
||||
"lifetime": 3600
|
||||
},
|
||||
"authentication": {
|
||||
"kind": "internal",
|
||||
"data": {
|
||||
}
|
||||
},
|
||||
"database": {
|
||||
"kind": "sqlite",
|
||||
"data": {
|
||||
"path": "../zeitbild.sqlite"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
"id": 2,
|
||||
"name": "bob",
|
||||
"email_address": "bob@example.org",
|
||||
"dav_token": "a5f10bc2d4ded8c5a07c5cb1c4e8b74363abce59d626574f0a83e67d499d9d5f",
|
||||
"dav_token": "bob_dav",
|
||||
"password": "bob"
|
||||
},
|
||||
{
|
||||
|
|
|
|||
22
lib/plankton/plankton.d.ts
vendored
22
lib/plankton/plankton.d.ts
vendored
|
|
@ -1,11 +1,11 @@
|
|||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
type int = number;
|
||||
declare type int = number;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
type float = number;
|
||||
declare type float = number;
|
||||
declare var process: any;
|
||||
declare var require: any;
|
||||
declare class Buffer {
|
||||
|
|
@ -22,7 +22,7 @@ declare namespace lib_plankton.base {
|
|||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
type type_pseudopointer<type_value> = {
|
||||
declare type type_pseudopointer<type_value> = {
|
||||
value: type_value;
|
||||
};
|
||||
/**
|
||||
|
|
@ -1498,7 +1498,7 @@ declare namespace lib_plankton.conf {
|
|||
*/
|
||||
type type_schema = ({
|
||||
enum?: Array<any>;
|
||||
default?: any;
|
||||
default?: (null | any);
|
||||
description?: string;
|
||||
} | {
|
||||
type: "null";
|
||||
|
|
@ -1507,32 +1507,32 @@ declare namespace lib_plankton.conf {
|
|||
type: "boolean";
|
||||
nullable?: boolean;
|
||||
enum?: Array<boolean>;
|
||||
default?: boolean;
|
||||
default?: (null | boolean);
|
||||
description?: string;
|
||||
} | {
|
||||
type: "integer";
|
||||
nullable?: boolean;
|
||||
enum?: Array<int>;
|
||||
default?: int;
|
||||
default?: (null | int);
|
||||
description?: string;
|
||||
} | {
|
||||
type: "number";
|
||||
nullable?: boolean;
|
||||
enum?: Array<number>;
|
||||
default?: number;
|
||||
default?: (null | number);
|
||||
description?: string;
|
||||
} | {
|
||||
type: "string";
|
||||
nullable?: boolean;
|
||||
enum?: Array<string>;
|
||||
default?: string;
|
||||
default?: (null | string);
|
||||
description?: string;
|
||||
} | {
|
||||
type: "array";
|
||||
nullable?: boolean;
|
||||
items: type_schema;
|
||||
enum?: Array<Array<any>>;
|
||||
default?: Array<any>;
|
||||
default?: (null | Array<any>);
|
||||
description?: string;
|
||||
} | {
|
||||
type: "object";
|
||||
|
|
@ -1541,7 +1541,7 @@ declare namespace lib_plankton.conf {
|
|||
required?: Array<string>;
|
||||
additionalProperties?: (false | type_schema);
|
||||
enum?: Array<Record<string, any>>;
|
||||
default?: Record<string, any>;
|
||||
default?: (Record<string, any> | null);
|
||||
description?: string;
|
||||
} | {
|
||||
anyOf: Array<type_schema>;
|
||||
|
|
@ -2315,7 +2315,7 @@ declare namespace lib_plankton.storage.memory {
|
|||
clear(): Promise<void>;
|
||||
write(key: any, value: any): Promise<boolean>;
|
||||
delete(key: any): Promise<void>;
|
||||
read(key: any): Promise<Awaited<type_item>>;
|
||||
read(key: any): Promise<type_item>;
|
||||
search(term: any): Promise<{
|
||||
key: string;
|
||||
preview: string;
|
||||
|
|
|
|||
|
|
@ -1486,7 +1486,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
|
|
@ -6814,7 +6814,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
|
|
@ -10266,7 +10266,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
|
|
@ -15148,7 +15148,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
|
|
|
|||
58
misc/conf-example.json
Normal file
58
misc/conf-example.json
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
{
|
||||
"version": 1,
|
||||
"log": [
|
||||
{
|
||||
"kind": "stdout",
|
||||
"data": {
|
||||
"threshold": "info",
|
||||
"format": "jsonl_structured"
|
||||
}
|
||||
}
|
||||
],
|
||||
"session_management": {
|
||||
"in_memory": false,
|
||||
"lifetime": 3600
|
||||
},
|
||||
"authentication": {
|
||||
"kind": "internal",
|
||||
"data": {
|
||||
}
|
||||
},
|
||||
"database": {
|
||||
"kind": "sqlite",
|
||||
"data": {
|
||||
"path": "../zeitbild.sqlite"
|
||||
}
|
||||
},
|
||||
"caldav": {
|
||||
"address": "http://localhost:8000/calendars/-/lampukistan",
|
||||
"username": "lampukistan-{{username}}",
|
||||
"password": "{{password}}",
|
||||
"setup_hints": [
|
||||
{
|
||||
"label": "Android",
|
||||
"link": "https://www.android-user.de/caldavcarddav-kalender-und-adressbuecher-ohne-google-synchronisieren/",
|
||||
"remark": null
|
||||
},
|
||||
{
|
||||
"label": "iOS",
|
||||
"link": "https://all-inkl.com/wichtig/anleitungen/programme/e-mail/caldav-kalenderfunktion/ios-mail_460.html",
|
||||
"remark": "eigentlich für Server 'all-inkl.com' — Zugangsdaten müssen entsprechend geändert werden"
|
||||
},
|
||||
{
|
||||
"label": "Thunderbird",
|
||||
"link": "https://www.uni-bielefeld.de/einrichtungen/bits/services/kuz/e-mail-und-kalender/anleitung/kalender-konfiguration-unter-thunderbird/",
|
||||
"remark": "eigentlich für Server 'uni-bielefeld.de' — Zugangsdaten müssen entsprechend geändert werden"
|
||||
},
|
||||
{
|
||||
"label": "Evolution",
|
||||
"link": "https://help.gnome.org/users/evolution/stable/calendar-caldav.html.de"
|
||||
},
|
||||
{
|
||||
"label": "MS Outlook",
|
||||
"link": "https://www.united-domains.de/help/faq-article/wie-synchronisiere-ich-meinen-kalender-caldav-mit-ms-outlook/",
|
||||
"remark": null
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
152
source/api/actions/user_dav_conf.ts
Normal file
152
source/api/actions/user_dav_conf.ts
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
namespace _zeitbild.api
|
||||
{
|
||||
|
||||
/**
|
||||
*/
|
||||
export function register_user_dav_conf(
|
||||
rest_subject : lib_plankton.rest_http.type_rest
|
||||
) : void
|
||||
{
|
||||
register<
|
||||
null,
|
||||
(
|
||||
null
|
||||
|
|
||||
{
|
||||
address : string;
|
||||
username : string;
|
||||
password : (null | string);
|
||||
setup_hints : Array<
|
||||
{
|
||||
label : string;
|
||||
link : string;
|
||||
remark : (null | string);
|
||||
}
|
||||
>;
|
||||
}
|
||||
)
|
||||
>(
|
||||
rest_subject,
|
||||
lib_plankton.http.enum_method.get,
|
||||
"/user_dav_conf",
|
||||
{
|
||||
"description": "gibt die CalDAV-Zugangsdaten eines Nutzers aus",
|
||||
"output_schema": () => ({
|
||||
"nullable": true,
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"address": {
|
||||
"nullable": false,
|
||||
"type": "string"
|
||||
},
|
||||
"username": {
|
||||
"nullable": false,
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"nullable": true,
|
||||
"type": "string"
|
||||
},
|
||||
"setup_hints": {
|
||||
"nullable": false,
|
||||
"type": "array",
|
||||
"items": {
|
||||
"nullable": false,
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"label": {
|
||||
"nullable": false,
|
||||
"type": "string"
|
||||
},
|
||||
"link": {
|
||||
"nullable": false,
|
||||
"type": "string"
|
||||
},
|
||||
"remark": {
|
||||
"nullable": true,
|
||||
"type": "string",
|
||||
"default": null,
|
||||
},
|
||||
},
|
||||
"required": [
|
||||
"label",
|
||||
"link",
|
||||
],
|
||||
"additionalProperties": false
|
||||
},
|
||||
"default": []
|
||||
},
|
||||
},
|
||||
"required": [
|
||||
"address",
|
||||
"username",
|
||||
"password",
|
||||
"setup_hints",
|
||||
],
|
||||
"additionalProperties": false
|
||||
}),
|
||||
"restriction": restriction_logged_in,
|
||||
"execution": async (stuff) => {
|
||||
let result : (
|
||||
null
|
||||
|
|
||||
{
|
||||
address : string;
|
||||
username : string;
|
||||
password : (null | string);
|
||||
setup_hints : Array<
|
||||
{
|
||||
label : string;
|
||||
link : string;
|
||||
remark : (null | string);
|
||||
}
|
||||
>;
|
||||
}
|
||||
) = null;
|
||||
const raw : (null | any) = _zeitbild.conf.get()["caldav"];
|
||||
if (raw === null)
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
const session : {key : string; value : lib_plankton.session.type_session;} = await session_from_stuff(stuff);
|
||||
const user_id : _zeitbild.type_user_id = await _zeitbild.service.user.identify(session.value.name);
|
||||
const user_object : _zeitbild.type_user_object = await _zeitbild.service.user.get(user_id);
|
||||
const arguments_ : Record<string, string> = Object.fromEntries(
|
||||
[
|
||||
{"key": "username", "value": user_object.name},
|
||||
{"key": "password", "value": user_object.dav_token},
|
||||
]
|
||||
.filter(
|
||||
entry => (entry.value !== null)
|
||||
)
|
||||
.map(
|
||||
entry => ([entry.key, entry.value as string])
|
||||
)
|
||||
);
|
||||
result = {
|
||||
"address": lib_plankton.string.coin(raw["address"], arguments_),
|
||||
"username": lib_plankton.string.coin(raw["username"], arguments_),
|
||||
"password": (
|
||||
(user_object.dav_token === null)
|
||||
?
|
||||
null
|
||||
:
|
||||
lib_plankton.string.coin(raw["password"], arguments_)
|
||||
),
|
||||
"setup_hints": raw["setup_hints"],
|
||||
};
|
||||
}
|
||||
return Promise.resolve(
|
||||
{
|
||||
"status_code": 200,
|
||||
"data": result,
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
53
source/api/actions/user_dav_token.ts
Normal file
53
source/api/actions/user_dav_token.ts
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
namespace _zeitbild.api
|
||||
{
|
||||
|
||||
/**
|
||||
*/
|
||||
export function register_user_dav_token(
|
||||
rest_subject : lib_plankton.rest_http.type_rest
|
||||
) : void
|
||||
{
|
||||
register<
|
||||
// string,
|
||||
null,
|
||||
null
|
||||
>(
|
||||
rest_subject,
|
||||
lib_plankton.http.enum_method.patch,
|
||||
"/user_dav_token",
|
||||
{
|
||||
"description": "setzt/überschreibt den DAV-Token eines Nutzers",
|
||||
/*
|
||||
"input_schema": () => ({
|
||||
"nullable": false,
|
||||
"type": "string"
|
||||
}),
|
||||
*/
|
||||
"input_schema": () => ({
|
||||
"nullable": true,
|
||||
}),
|
||||
"output_schema": () => ({
|
||||
"nullable": true
|
||||
}),
|
||||
"restriction": restriction_logged_in,
|
||||
"execution": async (stuff) => {
|
||||
const session : {key : string; value : lib_plankton.session.type_session;} = await session_from_stuff(stuff);
|
||||
const user_id : _zeitbild.type_user_id = await _zeitbild.service.user.identify(session.value.name);
|
||||
// TODO: outsource to user service?
|
||||
const user_object : _zeitbild.type_user_object = await _zeitbild.service.user.get(user_id);
|
||||
// user_object.dav_token = stuff.input;
|
||||
user_object.dav_token = lib_plankton.random.generate_string({"length": 12});
|
||||
await _zeitbild.service.user.change(user_id, user_object);
|
||||
return Promise.resolve(
|
||||
{
|
||||
"status_code": 200,
|
||||
"data": null,
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -31,6 +31,15 @@ namespace _zeitbild.api
|
|||
_zeitbild.api.register_session_end(rest_subject);
|
||||
_zeitbild.api.register_session_oidc(rest_subject);
|
||||
}
|
||||
// user
|
||||
{
|
||||
_zeitbild.api.register_users(rest_subject);
|
||||
// caldav
|
||||
{
|
||||
_zeitbild.api.register_user_dav_conf(rest_subject);
|
||||
_zeitbild.api.register_user_dav_token(rest_subject);
|
||||
}
|
||||
}
|
||||
// calendar
|
||||
{
|
||||
_zeitbild.api.register_calendar_list(rest_subject);
|
||||
|
|
@ -52,7 +61,6 @@ namespace _zeitbild.api
|
|||
}
|
||||
// misc
|
||||
{
|
||||
_zeitbild.api.register_users(rest_subject);
|
||||
_zeitbild.api.register_events(rest_subject);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -299,6 +299,60 @@ namespace _zeitbild.conf
|
|||
"default": {
|
||||
}
|
||||
},
|
||||
"caldav": {
|
||||
"nullable": true,
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"address": {
|
||||
"nullable": false,
|
||||
"type": "string"
|
||||
},
|
||||
"username": {
|
||||
"nullable": false,
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"nullable": false,
|
||||
"type": "string"
|
||||
},
|
||||
"setup_hints": {
|
||||
"nullable": false,
|
||||
"type": "array",
|
||||
"items": {
|
||||
"nullable": false,
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"label": {
|
||||
"nullable": false,
|
||||
"type": "string"
|
||||
},
|
||||
"link": {
|
||||
"nullable": false,
|
||||
"type": "string"
|
||||
},
|
||||
"remark": {
|
||||
"nullable": true,
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
},
|
||||
"required": [
|
||||
"label",
|
||||
"link",
|
||||
],
|
||||
"additionalProperties": false
|
||||
},
|
||||
"default": []
|
||||
},
|
||||
},
|
||||
"required": [
|
||||
"address",
|
||||
"username",
|
||||
"password"
|
||||
],
|
||||
"additionalProperties": false,
|
||||
"default": null
|
||||
},
|
||||
"misc": {
|
||||
"nullable": false,
|
||||
"type": "object",
|
||||
|
|
|
|||
|
|
@ -121,6 +121,19 @@ namespace _zeitbild.repository.user
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export async function update(
|
||||
user_id : _zeitbild.type_user_id,
|
||||
user_object : _zeitbild.type_user_object
|
||||
) : Promise<void>
|
||||
{
|
||||
const dispersal : Record<string, any> = encode(user_object);
|
||||
await get_store().update(user_id, dispersal);
|
||||
return Promise.resolve<void>(undefined);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export async function identify(
|
||||
|
|
|
|||
|
|
@ -47,4 +47,15 @@ namespace _zeitbild.service.user
|
|||
return _zeitbild.repository.user.create(user_object);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export function change(
|
||||
user_id : _zeitbild.type_user_id,
|
||||
user_object : _zeitbild.type_user_object
|
||||
) : Promise<void>
|
||||
{
|
||||
return _zeitbild.repository.user.update(user_id, user_object);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,6 +65,8 @@ ${dir_temp}/zeitbild-unlinked.js: \
|
|||
${dir_source}/api/actions/session_oidc.ts \
|
||||
${dir_source}/api/actions/session_end.ts \
|
||||
${dir_source}/api/actions/users.ts \
|
||||
${dir_source}/api/actions/user_dav_conf.ts \
|
||||
${dir_source}/api/actions/user_dav_token.ts \
|
||||
${dir_source}/api/actions/calendar_list.ts \
|
||||
${dir_source}/api/actions/calendar_get.ts \
|
||||
${dir_source}/api/actions/calendar_add.ts \
|
||||
|
|
|
|||
|
|
@ -34,15 +34,17 @@ modules="${modules} map"
|
|||
modules="${modules} pit"
|
||||
modules="${modules} auth"
|
||||
modules="${modules} sha256"
|
||||
modules="${modules} random"
|
||||
|
||||
|
||||
## exec
|
||||
|
||||
mkdir -p ${dir}
|
||||
mkdir /tmp/sandbox -p
|
||||
cd /tmp/sandbox
|
||||
ptk fetch node ${modules}
|
||||
schwamm --include=plankton.swm.json --output=dump:logic-decl > ${dir}/plankton.d.ts
|
||||
schwamm --include=plankton.swm.json --output=dump:logic-impl > ${dir}/plankton.js
|
||||
schwamm --include=/tmp/sandboxplankton.swm.json --output=dump:logic-decl > ${dir}/plankton.d.ts
|
||||
schwamm --include=/tmp/sandboxplankton.swm.json --output=dump:logic-impl > ${dir}/plankton.js
|
||||
exit
|
||||
|
||||
mkdir -p ${dir}
|
||||
|
|
|
|||
Loading…
Reference in a new issue