@lichen-wiki/client 0.1.0 → 0.2.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.
@@ -0,0 +1,17 @@
1
+ export declare const SYNC_PLUGIN_METADATA_PATH = "/oauth/lichen-sync/client-metadata.json";
2
+ export declare const SYNC_PLUGIN_CALLBACK_PATH = "/oauth/lichen-sync/callback";
3
+ /**
4
+ * The `obsidian://` action the callback page hands the authorization response to.
5
+ * @public Read by Lichen Sync alone.
6
+ */
7
+ export declare const SYNC_PLUGIN_PROTOCOL_ACTION = "lichen-sync";
8
+ /** Lichen Sync's client metadata on `origin`, before atcute fills in what every public client states. */
9
+ export declare function syncPluginClientMetadata(origin: string): {
10
+ client_id: string;
11
+ client_name: string;
12
+ client_uri: string;
13
+ redirect_uris: [string];
14
+ scope: string;
15
+ };
16
+ /** The `obsidian://` URL carrying an authorization response's parameters to the plugin. */
17
+ export declare function syncPluginReturnUrl(callback: URLSearchParams): string;
@@ -0,0 +1,37 @@
1
+ // Lichen Sync's OAuth client, hosted by lichen.wiki. The plugin presents this metadata and the server
2
+ // serves it, so a change reaches the server before a plugin release relies on it.
3
+ export const SYNC_PLUGIN_METADATA_PATH = "/oauth/lichen-sync/client-metadata.json";
4
+ export const SYNC_PLUGIN_CALLBACK_PATH = "/oauth/lichen-sync/callback";
5
+ /**
6
+ * The `obsidian://` action the callback page hands the authorization response to.
7
+ * @public Read by Lichen Sync alone.
8
+ */
9
+ export const SYNC_PLUGIN_PROTOCOL_ACTION = "lichen-sync";
10
+ /** The authorization response's parameters, which the callback page forwards and nothing else. */
11
+ const SYNC_PLUGIN_CALLBACK_PARAMS = [
12
+ "code",
13
+ "state",
14
+ "iss",
15
+ "error",
16
+ "error_description",
17
+ ];
18
+ /** Lichen Sync's client metadata on `origin`, before atcute fills in what every public client states. */
19
+ export function syncPluginClientMetadata(origin) {
20
+ return {
21
+ client_id: `${origin}${SYNC_PLUGIN_METADATA_PATH}`,
22
+ client_name: "Lichen Sync",
23
+ client_uri: origin,
24
+ redirect_uris: [`${origin}${SYNC_PLUGIN_CALLBACK_PATH}`],
25
+ scope: "atproto include:wiki.lichen.permissions",
26
+ };
27
+ }
28
+ /** The `obsidian://` URL carrying an authorization response's parameters to the plugin. */
29
+ export function syncPluginReturnUrl(callback) {
30
+ const forwarded = new URLSearchParams();
31
+ for (const name of SYNC_PLUGIN_CALLBACK_PARAMS) {
32
+ const value = callback.get(name);
33
+ if (value !== null)
34
+ forwarded.set(name, value);
35
+ }
36
+ return `obsidian://${SYNC_PLUGIN_PROTOCOL_ACTION}?${forwarded}`;
37
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lichen-wiki/client",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Read and write Lichen wikis on AT Protocol: record types and limits, validation, slugs and PDS writes.",
5
5
  "type": "module",
6
6
  "license": "MIT",