Import IKAR messenger client and server
This commit is contained in:
Vendored
+121
@@ -0,0 +1,121 @@
|
||||
declare module 'komet:api' {
|
||||
export type Permission =
|
||||
| 'chat.write'
|
||||
| 'chat.edit'
|
||||
| 'chat.photo'
|
||||
| 'chat.file'
|
||||
| 'ui.notify'
|
||||
| 'contact.read'
|
||||
| 'message.readReply'
|
||||
| 'network'
|
||||
| 'storage';
|
||||
|
||||
export type AttachmentType =
|
||||
| 'photo'
|
||||
| 'video'
|
||||
| 'audio'
|
||||
| 'file'
|
||||
| 'contact'
|
||||
| 'location'
|
||||
| 'sticker'
|
||||
| 'control'
|
||||
| 'poll'
|
||||
| 'share'
|
||||
| 'call'
|
||||
| 'inlineKeyboard'
|
||||
| 'forward'
|
||||
| 'unknown';
|
||||
|
||||
export interface ReplyMessage {
|
||||
readonly id: string;
|
||||
readonly senderId: number;
|
||||
readonly text: string | null;
|
||||
readonly time: number;
|
||||
readonly attachments: ReadonlyArray<{ readonly type: AttachmentType }>;
|
||||
}
|
||||
|
||||
export interface CommandContext {
|
||||
readonly args: string;
|
||||
readonly arguments: Readonly<Record<string, string>>;
|
||||
readonly reply: ReplyMessage | null;
|
||||
readonly apiVersion: number;
|
||||
}
|
||||
|
||||
export type CommandHandler = (context: CommandContext) => void | Promise<void>;
|
||||
|
||||
export type MediaSource =
|
||||
| { readonly base64: string; readonly url?: string }
|
||||
| { readonly url: string; readonly base64?: string };
|
||||
|
||||
export type PhotoOptions = MediaSource & {
|
||||
readonly filename?: string;
|
||||
readonly caption?: string;
|
||||
};
|
||||
|
||||
export type FileOptions = MediaSource & {
|
||||
readonly filename?: string;
|
||||
};
|
||||
|
||||
export interface Peer {
|
||||
readonly id: number;
|
||||
readonly displayName: string;
|
||||
readonly country: string | null;
|
||||
readonly registrationTime: number | null;
|
||||
readonly updateTime: number | null;
|
||||
readonly options: ReadonlyArray<string>;
|
||||
}
|
||||
|
||||
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
||||
|
||||
export interface FetchOptions {
|
||||
readonly method?: HttpMethod;
|
||||
readonly headers?: Readonly<Record<string, string>>;
|
||||
readonly body?: string;
|
||||
}
|
||||
|
||||
export interface FetchResponse {
|
||||
readonly status: number;
|
||||
readonly headers: Readonly<Record<string, string>>;
|
||||
readonly body: string;
|
||||
readonly base64: string;
|
||||
}
|
||||
|
||||
export type JsonValue =
|
||||
| null
|
||||
| boolean
|
||||
| number
|
||||
| string
|
||||
| JsonValue[]
|
||||
| { [key: string]: JsonValue };
|
||||
|
||||
export const chat: {
|
||||
sendText(text: string): Promise<string>;
|
||||
editText(messageId: string, text: string): Promise<void>;
|
||||
sendPhoto(options: PhotoOptions): Promise<void>;
|
||||
sendFile(options: FileOptions): Promise<void>;
|
||||
};
|
||||
|
||||
export const network: {
|
||||
fetch(url: string, options?: FetchOptions): Promise<FetchResponse>;
|
||||
};
|
||||
|
||||
export const ui: {
|
||||
notify(message: string): Promise<void>;
|
||||
};
|
||||
|
||||
export const contact: {
|
||||
getPeer(): Promise<Peer | null>;
|
||||
};
|
||||
|
||||
export const runtime: {
|
||||
sleep(milliseconds: number): Promise<void>;
|
||||
isOnline(): Promise<boolean>;
|
||||
isActive(): Promise<boolean>;
|
||||
};
|
||||
|
||||
export const storage: {
|
||||
get(key: string): Promise<JsonValue>;
|
||||
set(key: string, value: JsonValue): Promise<void>;
|
||||
remove(key: string): Promise<void>;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://raw.githubusercontent.com/KometTeam/Komet/main/plugin_sdk/manifest.schema.json",
|
||||
"title": "Komet plugin manifest",
|
||||
"description": "manifest.json в корне пакета .kinet. Описание полей — PLUGINS.md.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"schemaVersion",
|
||||
"id",
|
||||
"name",
|
||||
"version",
|
||||
"apiVersion",
|
||||
"main",
|
||||
"permissions",
|
||||
"commands"
|
||||
],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"$schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"schemaVersion": {
|
||||
"const": 1
|
||||
},
|
||||
"id": {
|
||||
"description": "Уникальный id в обратной доменной записи. Префикс pw.komet. зарезервирован за встроенными плагинами.",
|
||||
"type": "string",
|
||||
"pattern": "^[a-z][a-z0-9]*(?:\\.[a-z0-9]+)+$"
|
||||
},
|
||||
"name": {
|
||||
"$ref": "#/$defs/nonEmptyString"
|
||||
},
|
||||
"version": {
|
||||
"$ref": "#/$defs/version"
|
||||
},
|
||||
"apiVersion": {
|
||||
"description": "Версия komet:api, которую ждёт плагин.",
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"maximum": 1
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"author": {
|
||||
"type": "string"
|
||||
},
|
||||
"main": {
|
||||
"description": "Путь к главному модулю внутри пакета.",
|
||||
"type": "string",
|
||||
"pattern": "^(?!/)(?!.*\\\\)(?!.*//)(?!(?:.*/)?\\.\\.(?:/|$)).+\\.js$"
|
||||
},
|
||||
"permissions": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/$defs/permission"
|
||||
},
|
||||
"uniqueItems": true
|
||||
},
|
||||
"commands": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"$ref": "#/$defs/command"
|
||||
}
|
||||
},
|
||||
"updateUrl": {
|
||||
"description": "HTTPS-адрес манифеста обновлений (update-manifest.schema.json).",
|
||||
"type": "string",
|
||||
"format": "uri",
|
||||
"pattern": "^https://"
|
||||
},
|
||||
"signature": {
|
||||
"$ref": "#/$defs/signature"
|
||||
}
|
||||
},
|
||||
"$defs": {
|
||||
"nonEmptyString": {
|
||||
"type": "string",
|
||||
"pattern": "\\S"
|
||||
},
|
||||
"version": {
|
||||
"description": "SemVer: 1.2.3, 1.2.3-beta.1, 1.2.3+build.5.",
|
||||
"type": "string",
|
||||
"pattern": "^\\d+\\.\\d+\\.\\d+(?:[-+][0-9A-Za-z.-]+)?$"
|
||||
},
|
||||
"permission": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"chat.write",
|
||||
"chat.edit",
|
||||
"chat.photo",
|
||||
"chat.file",
|
||||
"ui.notify",
|
||||
"contact.read",
|
||||
"message.readReply",
|
||||
"network",
|
||||
"storage"
|
||||
]
|
||||
},
|
||||
"command": {
|
||||
"type": "object",
|
||||
"required": ["name", "description", "handler"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"name": {
|
||||
"description": "Имя команды; ведущий / можно не писать.",
|
||||
"type": "string",
|
||||
"pattern": "^/?[A-Za-z][A-Za-z0-9_-]{0,31}$"
|
||||
},
|
||||
"description": {
|
||||
"$ref": "#/$defs/nonEmptyString"
|
||||
},
|
||||
"handler": {
|
||||
"description": "Имя функции, экспортированной из main.",
|
||||
"type": "string",
|
||||
"pattern": "^[A-Za-z_$][A-Za-z0-9_$]*$"
|
||||
},
|
||||
"arguments": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/$defs/argument"
|
||||
}
|
||||
},
|
||||
"hidden": {
|
||||
"description": "Не показывать команду в подсказках.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"argument": {
|
||||
"type": "object",
|
||||
"required": ["name"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"pattern": "^[A-Za-z][A-Za-z0-9_-]{0,31}$"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"required": {
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
},
|
||||
"rest": {
|
||||
"description": "Забирает весь остаток строки. Только у последнего аргумента.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"signature": {
|
||||
"description": "Добавляется tool/kinet_sign.dart, вручную не заполняется.",
|
||||
"type": "object",
|
||||
"required": ["algorithm", "publicKey", "value"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"algorithm": {
|
||||
"const": "ed25519"
|
||||
},
|
||||
"publicKey": {
|
||||
"description": "32 байта в base64.",
|
||||
"type": "string",
|
||||
"contentEncoding": "base64"
|
||||
},
|
||||
"value": {
|
||||
"description": "64 байта в base64.",
|
||||
"type": "string",
|
||||
"contentEncoding": "base64"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://raw.githubusercontent.com/KometTeam/Komet/main/plugin_sdk/update-manifest.schema.json",
|
||||
"title": "Komet plugin update manifest",
|
||||
"description": "JSON по адресу updateUrl из manifest.json. Описание полей — PLUGINS.md.",
|
||||
"type": "object",
|
||||
"required": ["version", "packageUrl", "size", "sha256"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"$schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"version": {
|
||||
"description": "Версия нового пакета; должна совпадать с version в его manifest.json.",
|
||||
"type": "string",
|
||||
"pattern": "^\\d+\\.\\d+\\.\\d+(?:[-+][0-9A-Za-z.-]+)?$"
|
||||
},
|
||||
"packageUrl": {
|
||||
"description": "Адрес .kinet, абсолютный или относительный к updateUrl. Итоговый адрес — только HTTPS.",
|
||||
"type": "string",
|
||||
"format": "uri-reference",
|
||||
"pattern": "^(?:https://|(?![A-Za-z][A-Za-z0-9+.-]*:))"
|
||||
},
|
||||
"size": {
|
||||
"description": "Размер пакета в байтах; 0 отключает проверку.",
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"sha256": {
|
||||
"description": "SHA-256 пакета в hex; пустая строка отключает проверку.",
|
||||
"type": "string",
|
||||
"pattern": "^(?:[0-9A-Fa-f]{64})?$"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user