@lichen-wiki/client 0.1.0 → 0.3.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/dist/sync-plugin-oauth.d.ts +17 -0
- package/dist/sync-plugin-oauth.js +37 -0
- package/dist/writes.d.ts +6 -0
- package/dist/writes.js +12 -0
- package/package.json +2 -2
|
@@ -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/dist/writes.d.ts
CHANGED
|
@@ -51,6 +51,12 @@ export type MembershipRecordFields = Omit<WikiLichenMembership.Main, "$type" | "
|
|
|
51
51
|
role: MemberRole;
|
|
52
52
|
};
|
|
53
53
|
export declare function membershipWrite(repo: Did, rkey: string, membership: MembershipRecordFields): RecordWrite;
|
|
54
|
+
/** A wiki and its owner's admin grant, which a client publishes in one commit. */
|
|
55
|
+
export interface NewWikiWrites {
|
|
56
|
+
wiki: RecordWrite;
|
|
57
|
+
grant: RecordWrite;
|
|
58
|
+
}
|
|
59
|
+
export declare function newWikiWrites(repo: Did, slug: string, wiki: WikiRecordFields): NewWikiWrites;
|
|
54
60
|
export type BookmarkRecordFields = Pick<CommunityLexiconBookmarksBookmark.Main, "subject" | "createdAt">;
|
|
55
61
|
export declare function bookmarkWrite(repo: Did, rkey: string, bookmark: BookmarkRecordFields): RecordWrite;
|
|
56
62
|
export {};
|
package/dist/writes.js
CHANGED
|
@@ -110,6 +110,18 @@ export function membershipWrite(repo, rkey, membership) {
|
|
|
110
110
|
createdAt: membership.createdAt,
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
|
+
export function newWikiWrites(repo, slug, wiki) {
|
|
114
|
+
const record = wikiWrite(repo, slug, wiki);
|
|
115
|
+
return {
|
|
116
|
+
wiki: record,
|
|
117
|
+
grant: membershipWrite(repo, TID.now(), {
|
|
118
|
+
memberDid: repo,
|
|
119
|
+
wikiRef: record.uri,
|
|
120
|
+
role: "admin",
|
|
121
|
+
createdAt: wiki.createdAt,
|
|
122
|
+
}),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
113
125
|
export function bookmarkWrite(repo, rkey, bookmark) {
|
|
114
126
|
return recordWrite(repo, rkey, {
|
|
115
127
|
$type: COLLECTIONS.bookmark,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lichen-wiki/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.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",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"diff-match-patch": "^1.0.5"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@atcute/atproto": "^4.0.
|
|
39
|
+
"@atcute/atproto": "^4.0.5",
|
|
40
40
|
"@types/diff-match-patch": "^1.0.36"
|
|
41
41
|
}
|
|
42
42
|
}
|