@bbthorson/atproto-cf-auth 0.2.1 → 0.4.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/element.js CHANGED
@@ -2,43 +2,56 @@
2
2
  * `<bsky-sign-in>`: a handle field and a button that run the whole sign-in,
3
3
  * usable from any framework (or none). Importing this module registers it.
4
4
  *
5
- * <bsky-sign-in base-path="/auth" return-to="/campaigns"></bsky-sign-in>
5
+ * <bsky-sign-in base-path="/auth" return-to="/campaigns" typeahead remember-accounts></bsky-sign-in>
6
6
  *
7
- * It renders into the light DOM with plain class names
8
- * (`bsky-sign-in__form`, `__label`, `__input`, `__button`, `__error`) and a
9
- * `data-state` of `idle | loading | error`, so the app's own CSS styles it.
7
+ * It renders into the light DOM with plain class names (see README for the
8
+ * list) and a `data-state` of `idle | loading | error`, so the app's own CSS
9
+ * styles it. `@bbthorson/atproto-cf-auth/element.css` is an optional starting
10
+ * point that inherits the page's font and colours.
10
11
  *
11
12
  * Or bring your own markup and it only adds behaviour. It looks for a
12
- * `<form>`, an `<input name="handle">`, a submit button and an element with
13
- * `data-bsky-error`:
13
+ * `<form>`, an `<input name="handle">`, a submit button, an element with
14
+ * `data-bsky-error`, and optionally `data-bsky-accounts` (remembered accounts
15
+ * are drawn into it), `data-bsky-divider` (shown only when there are any) and
16
+ * `data-bsky-suggestions` (the typeahead list):
14
17
  *
15
- * <bsky-sign-in>
18
+ * <bsky-sign-in typeahead>
16
19
  * <form class="my-form">
17
20
  * <input name="handle" class="my-input" />
21
+ * <ul data-bsky-suggestions class="my-menu"></ul>
18
22
  * <button class="my-button">Continue with Bluesky</button>
19
23
  * <p data-bsky-error></p>
20
24
  * </form>
21
25
  * </bsky-sign-in>
22
26
  *
23
27
  * Without JavaScript the form still works: it posts to `{base-path}/login`,
24
- * which redirects to the Bluesky consent page.
28
+ * which redirects to the person's authorization server.
25
29
  *
26
30
  * Events (bubbling): `bsky-sign-in:error` with `{ code, message }`. Call
27
31
  * `preventDefault()` on it to show the error yourself.
28
32
  */
29
- import { AuthError, HANDLE_INPUT_ATTRIBUTES, createAuthClient, takeAuthError, } from "./client.js";
33
+ import { createRecentAccounts } from "./accounts.js";
34
+ import { HANDLE_INPUT_ATTRIBUTES, createAuthClient, takeAuthError, } from "./client.js";
35
+ import { createSignInController } from "./controller.js";
36
+ const C = "bsky-sign-in";
30
37
  let uid = 0;
31
38
  export function defineSignInElement(tagName = "bsky-sign-in") {
32
39
  if (typeof customElements === "undefined" || customElements.get(tagName))
33
40
  return;
34
41
  class BskySignIn extends HTMLElement {
35
42
  static observedAttributes = ["label", "placeholder", "button-label"];
36
- client;
43
+ controller;
44
+ unsubscribe;
45
+ rendered;
37
46
  form = null;
38
47
  input = null;
39
48
  button = null;
40
49
  errorEl = null;
50
+ accountsEl = null;
51
+ dividerEl = null;
52
+ suggestionsEl = null;
41
53
  buttonText = "";
54
+ baseId = `${C}-${++uid}`;
42
55
  get basePath() {
43
56
  return (this.getAttribute("base-path") ?? "/auth").replace(/\/+$/, "");
44
57
  }
@@ -66,6 +79,9 @@ export function defineSignInElement(tagName = "bsky-sign-in") {
66
79
  this.input = this.querySelector('input[name="handle"]');
67
80
  this.button = this.form?.querySelector('button:not([type="button"]), input[type="submit"]') ?? null;
68
81
  this.errorEl = this.querySelector("[data-bsky-error]");
82
+ this.accountsEl = this.querySelector("[data-bsky-accounts]");
83
+ this.dividerEl = this.querySelector("[data-bsky-divider]");
84
+ this.suggestionsEl = this.querySelector("[data-bsky-suggestions]");
69
85
  if (!this.form || !this.input)
70
86
  return;
71
87
  // No-JS fallback and the attributes phones need.
@@ -85,103 +101,245 @@ export function defineSignInElement(tagName = "bsky-sign-in") {
85
101
  hidden.value = returnTo;
86
102
  this.form.append(hidden);
87
103
  }
88
- this.client = createAuthClient({ basePath: this.basePath });
89
- this.dataset["state"] = "idle";
104
+ const typeahead = this.hasAttribute("typeahead") && !!this.suggestionsEl;
105
+ if (typeahead && this.suggestionsEl) {
106
+ if (!this.suggestionsEl.id)
107
+ this.suggestionsEl.id = `${this.baseId}-suggestions`;
108
+ this.suggestionsEl.setAttribute("role", "listbox");
109
+ this.input.setAttribute("role", "combobox");
110
+ this.input.setAttribute("aria-autocomplete", "list");
111
+ this.input.setAttribute("aria-expanded", "false");
112
+ this.input.setAttribute("aria-controls", this.suggestionsEl.id);
113
+ // The browser's own autofill dropdown would sit on top of ours.
114
+ this.input.setAttribute("autocomplete", "off");
115
+ }
116
+ if (this.suggestionsEl)
117
+ this.suggestionsEl.hidden = true;
118
+ if (this.accountsEl)
119
+ this.accountsEl.hidden = true;
120
+ if (this.dividerEl)
121
+ this.dividerEl.hidden = true;
122
+ const client = createAuthClient({ basePath: this.basePath });
123
+ this.controller = createSignInController({
124
+ signIn: (handle) => client.signIn(handle, returnTo ? { returnTo } : {}),
125
+ accounts: this.hasAttribute("remember-accounts") && this.accountsEl ? createRecentAccounts() : null,
126
+ typeahead,
127
+ });
90
128
  this.buttonText = this.button?.textContent ?? "";
129
+ this.dataset["state"] = "idle";
130
+ this.unsubscribe = this.controller.subscribe(() => this.render());
91
131
  this.form.addEventListener("submit", this.onSubmit);
92
132
  this.input.addEventListener("input", this.onInput);
133
+ this.input.addEventListener("keydown", this.onKeyDown);
134
+ this.input.addEventListener("blur", this.onBlur);
135
+ this.accountsEl?.addEventListener("click", this.onAccountClick);
136
+ this.suggestionsEl?.addEventListener("mousedown", this.onSuggestionMouseDown);
137
+ this.suggestionsEl?.addEventListener("click", this.onSuggestionClick);
93
138
  // A failed redirect lands back here with ?auth_error=.
94
139
  if (!this.hasAttribute("ignore-redirect-errors")) {
95
140
  const error = takeAuthError();
96
141
  if (error)
97
- this.showError(error);
142
+ this.controller.setError(error);
98
143
  }
99
144
  }
100
145
  disconnectedCallback() {
101
146
  this.form?.removeEventListener("submit", this.onSubmit);
102
147
  this.input?.removeEventListener("input", this.onInput);
148
+ this.input?.removeEventListener("keydown", this.onKeyDown);
149
+ this.input?.removeEventListener("blur", this.onBlur);
150
+ this.accountsEl?.removeEventListener("click", this.onAccountClick);
151
+ this.suggestionsEl?.removeEventListener("mousedown", this.onSuggestionMouseDown);
152
+ this.suggestionsEl?.removeEventListener("click", this.onSuggestionClick);
153
+ this.unsubscribe?.();
154
+ this.controller?.destroy();
155
+ this.controller = undefined;
156
+ this.rendered = undefined;
103
157
  this.form = null;
104
158
  }
105
159
  attributeChangedCallback() {
106
160
  if (!this.form)
107
161
  return;
108
- const label = this.querySelector(".bsky-sign-in__label");
162
+ const label = this.querySelector(`.${C}__label`);
109
163
  if (label)
110
164
  label.textContent = this.getAttribute("label") ?? "Bluesky handle";
111
165
  if (this.input && this.hasAttribute("placeholder"))
112
166
  this.input.placeholder = this.getAttribute("placeholder");
113
- if (this.button?.classList.contains("bsky-sign-in__button")) {
167
+ if (this.button?.classList.contains(`${C}__button`)) {
114
168
  this.buttonText = this.getAttribute("button-label") ?? "Sign in with Bluesky";
115
169
  if (this.dataset["state"] !== "loading")
116
170
  this.button.textContent = this.buttonText;
117
171
  }
118
172
  }
119
173
  renderDefault() {
120
- const id = `bsky-sign-in-${++uid}`;
121
- const form = document.createElement("form");
122
- form.className = "bsky-sign-in__form";
174
+ const id = this.baseId;
175
+ const form = el("form", `${C}__form`);
123
176
  form.noValidate = true;
124
- const label = document.createElement("label");
125
- label.className = "bsky-sign-in__label";
177
+ const accounts = el("div", `${C}__accounts`);
178
+ accounts.setAttribute("data-bsky-accounts", "");
179
+ accounts.setAttribute("role", "list");
180
+ accounts.setAttribute("aria-label", "Recent accounts");
181
+ const divider = el("p", `${C}__divider`);
182
+ divider.setAttribute("data-bsky-divider", "");
183
+ divider.append(el("span", "", this.getAttribute("divider-label") ?? "or"));
184
+ const label = el("label", `${C}__label`, this.getAttribute("label") ?? "Bluesky handle");
126
185
  label.htmlFor = id;
127
- label.textContent = this.getAttribute("label") ?? "Bluesky handle";
128
- const input = document.createElement("input");
129
- input.className = "bsky-sign-in__input";
186
+ const field = el("div", `${C}__field`);
187
+ const input = el("input", `${C}__input`);
130
188
  input.id = id;
131
189
  input.name = "handle";
132
190
  input.required = true;
133
191
  const placeholder = this.getAttribute("placeholder");
134
192
  if (placeholder)
135
193
  input.placeholder = placeholder;
136
- const button = document.createElement("button");
137
- button.className = "bsky-sign-in__button";
194
+ const suggestions = el("ul", `${C}__suggestions`);
195
+ suggestions.setAttribute("data-bsky-suggestions", "");
196
+ suggestions.setAttribute("aria-label", "Suggested accounts");
197
+ field.append(input, suggestions);
198
+ const button = el("button", `${C}__button`, this.getAttribute("button-label") ?? "Sign in with Bluesky");
138
199
  button.type = "submit";
139
- button.textContent = this.getAttribute("button-label") ?? "Sign in with Bluesky";
140
- const error = document.createElement("p");
141
- error.className = "bsky-sign-in__error";
200
+ const error = el("p", `${C}__error`);
142
201
  error.id = `${id}-error`;
143
202
  error.setAttribute("data-bsky-error", "");
144
203
  error.setAttribute("role", "alert");
145
204
  error.hidden = true;
146
- form.append(label, input, button, error);
205
+ form.append(accounts, divider, label, field, button, error);
147
206
  this.append(form);
148
207
  }
149
- onInput = () => {
150
- if (this.dataset["state"] === "error")
151
- this.clearError();
152
- };
153
- onSubmit = async (event) => {
154
- event.preventDefault();
155
- if (!this.client || !this.input || this.dataset["state"] === "loading")
208
+ /** Bring the DOM in line with the controller's state, touching only what changed. */
209
+ render() {
210
+ const state = this.controller?.getState();
211
+ if (!state)
156
212
  return;
157
- this.clearError();
158
- this.setLoading(true);
159
- try {
160
- const returnTo = this.getAttribute("return-to");
161
- await this.client.signIn(this.input.value, returnTo ? { returnTo } : {});
162
- // Navigation is under way; stay in the loading state.
213
+ const prev = this.rendered;
214
+ this.rendered = state;
215
+ if (state.accounts !== prev?.accounts)
216
+ this.renderAccounts(state.accounts);
217
+ if (state.suggestions !== prev?.suggestions || state.activeIndex !== prev?.activeIndex) {
218
+ this.renderSuggestions(state.suggestions, state.activeIndex);
163
219
  }
164
- catch (err) {
165
- this.setLoading(false);
166
- this.showError(err instanceof AuthError ? err : new AuthError("authorize_failed"));
167
- }
168
- };
169
- setLoading(loading) {
170
- this.dataset["state"] = loading ? "loading" : "idle";
220
+ if (this.input && this.input.value !== state.query && state.status === "loading")
221
+ this.input.value = state.query;
222
+ if (state.status !== prev?.status || state.error !== prev?.error)
223
+ this.renderStatus(state, prev);
224
+ }
225
+ renderStatus(state, prev) {
226
+ this.dataset["state"] = state.status;
227
+ const loading = state.status === "loading";
171
228
  this.toggleAttribute("aria-busy", loading);
172
229
  if (this.input)
173
230
  this.input.readOnly = loading;
174
- if (!this.button)
231
+ for (const b of this.querySelectorAll(`[data-bsky-choose], [data-bsky-forget]`))
232
+ b.disabled = loading;
233
+ if (this.button) {
234
+ this.button.disabled = loading;
235
+ const loadingLabel = this.getAttribute("loading-label");
236
+ if (loadingLabel)
237
+ this.button.textContent = loading ? loadingLabel : this.buttonText;
238
+ }
239
+ if (state.error && state.error !== prev?.error)
240
+ this.showError(state.error);
241
+ else if (!state.error)
242
+ this.clearError();
243
+ }
244
+ renderAccounts(accounts) {
245
+ if (!this.accountsEl)
175
246
  return;
176
- this.button.disabled = loading;
177
- const loadingLabel = this.getAttribute("loading-label");
178
- if (loadingLabel)
179
- this.button.textContent = loading ? loadingLabel : this.buttonText;
247
+ this.accountsEl.replaceChildren(...accounts.map((account) => {
248
+ const item = el("div", `${C}__account`);
249
+ item.setAttribute("role", "listitem");
250
+ const choose = el("button", `${C}__account-choose`);
251
+ choose.type = "button";
252
+ choose.dataset["bskyChoose"] = account.did;
253
+ choose.setAttribute("aria-label", `Continue as ${describe(account)}`);
254
+ choose.append(avatar(account), identity(account));
255
+ const forget = el("button", `${C}__account-forget`, "×");
256
+ forget.type = "button";
257
+ forget.dataset["bskyForget"] = account.did;
258
+ forget.setAttribute("aria-label", `Forget @${account.handle} on this device`);
259
+ item.append(choose, forget);
260
+ return item;
261
+ }));
262
+ this.accountsEl.hidden = accounts.length === 0;
263
+ if (this.dividerEl)
264
+ this.dividerEl.hidden = accounts.length === 0;
180
265
  }
266
+ renderSuggestions(suggestions, activeIndex) {
267
+ if (!this.suggestionsEl || !this.input)
268
+ return;
269
+ this.suggestionsEl.replaceChildren(...suggestions.map((suggestion, index) => {
270
+ const option = el("li", `${C}__suggestion`);
271
+ option.id = `${this.baseId}-option-${index}`;
272
+ option.setAttribute("role", "option");
273
+ option.setAttribute("aria-selected", String(index === activeIndex));
274
+ option.dataset["index"] = String(index);
275
+ option.append(avatar(suggestion), identity(suggestion));
276
+ return option;
277
+ }));
278
+ const open = suggestions.length > 0;
279
+ this.suggestionsEl.hidden = !open;
280
+ this.input.setAttribute("aria-expanded", String(open));
281
+ if (open && activeIndex >= 0) {
282
+ this.input.setAttribute("aria-activedescendant", `${this.baseId}-option-${activeIndex}`);
283
+ this.suggestionsEl.children[activeIndex]?.scrollIntoView?.({ block: "nearest" });
284
+ }
285
+ else {
286
+ this.input.removeAttribute("aria-activedescendant");
287
+ }
288
+ }
289
+ onInput = () => {
290
+ this.controller?.setQuery(this.input?.value ?? "");
291
+ };
292
+ onSubmit = (event) => {
293
+ event.preventDefault();
294
+ if (!this.controller)
295
+ return;
296
+ // The field is the source of truth: autofill doesn't always fire `input`.
297
+ if (this.input && this.input.value !== this.controller.getState().query)
298
+ this.controller.setQuery(this.input.value);
299
+ void this.controller.submit();
300
+ };
301
+ onKeyDown = (event) => {
302
+ const controller = this.controller;
303
+ if (!controller || !controller.getState().suggestions.length)
304
+ return;
305
+ if (event.key === "ArrowDown" || event.key === "ArrowUp") {
306
+ event.preventDefault();
307
+ controller.moveActive(event.key === "ArrowDown" ? 1 : -1);
308
+ }
309
+ else if (event.key === "Escape") {
310
+ event.preventDefault();
311
+ controller.closeSuggestions();
312
+ }
313
+ };
314
+ onBlur = () => {
315
+ this.controller?.closeSuggestions();
316
+ };
317
+ onAccountClick = (event) => {
318
+ const target = event.target instanceof Element ? event.target : null;
319
+ const choose = target?.closest("[data-bsky-choose]");
320
+ const forget = target?.closest("[data-bsky-forget]");
321
+ const accounts = this.controller?.getState().accounts ?? [];
322
+ if (forget) {
323
+ void this.controller?.forget(forget.dataset["bskyForget"] ?? "");
324
+ this.input?.focus();
325
+ }
326
+ else if (choose) {
327
+ const account = accounts.find((a) => a.did === choose.dataset["bskyChoose"]);
328
+ if (account)
329
+ void this.controller?.choose(account);
330
+ }
331
+ };
332
+ // Keep focus in the field, so choosing doesn't blur (and close) the list first.
333
+ onSuggestionMouseDown = (event) => event.preventDefault();
334
+ onSuggestionClick = (event) => {
335
+ const option = event.target instanceof Element ? event.target.closest("[role=option]") : null;
336
+ const suggestion = this.controller?.getState().suggestions[Number(option?.dataset["index"])];
337
+ if (suggestion)
338
+ void this.controller?.choose(suggestion);
339
+ };
181
340
  showError(error) {
182
341
  const detail = { code: error.code, message: error.message };
183
342
  const proceed = this.dispatchEvent(new CustomEvent("bsky-sign-in:error", { detail, bubbles: true, cancelable: true }));
184
- this.dataset["state"] = "error";
185
343
  this.input?.setAttribute("aria-invalid", "true");
186
344
  if (proceed && this.errorEl) {
187
345
  this.errorEl.textContent = error.message;
@@ -191,7 +349,6 @@ export function defineSignInElement(tagName = "bsky-sign-in") {
191
349
  }
192
350
  }
193
351
  clearError() {
194
- this.dataset["state"] = "idle";
195
352
  this.input?.removeAttribute("aria-invalid");
196
353
  if (this.errorEl) {
197
354
  this.errorEl.textContent = "";
@@ -201,5 +358,38 @@ export function defineSignInElement(tagName = "bsky-sign-in") {
201
358
  }
202
359
  customElements.define(tagName, BskySignIn);
203
360
  }
361
+ function el(tag, className, text) {
362
+ const node = document.createElement(tag);
363
+ if (className)
364
+ node.className = className;
365
+ if (text !== undefined)
366
+ node.textContent = text;
367
+ return node;
368
+ }
369
+ function describe(account) {
370
+ return account.displayName ? `${account.displayName} (@${account.handle})` : `@${account.handle}`;
371
+ }
372
+ /** The avatar, or an empty circle holding the name's first letter. */
373
+ function avatar(account) {
374
+ if (account.avatar) {
375
+ const img = el("img", `${C}__avatar`);
376
+ img.src = account.avatar;
377
+ img.alt = "";
378
+ img.loading = "lazy";
379
+ img.decoding = "async";
380
+ img.referrerPolicy = "no-referrer";
381
+ return img;
382
+ }
383
+ const initial = el("span", `${C}__avatar ${C}__avatar--empty`, (account.displayName || account.handle).charAt(0).toUpperCase());
384
+ initial.setAttribute("aria-hidden", "true");
385
+ return initial;
386
+ }
387
+ function identity(account) {
388
+ const wrap = el("span", `${C}__identity`);
389
+ if (account.displayName)
390
+ wrap.append(el("span", `${C}__name`, account.displayName));
391
+ wrap.append(el("span", `${C}__handle`, `@${account.handle}`));
392
+ return wrap;
393
+ }
204
394
  defineSignInElement();
205
395
  //# sourceMappingURL=element.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"element.js","sourceRoot":"","sources":["../src/element.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EACL,SAAS,EACT,uBAAuB,EACvB,gBAAgB,EAChB,aAAa,GAEd,MAAM,aAAa,CAAC;AAOrB,IAAI,GAAG,GAAG,CAAC,CAAC;AAEZ,MAAM,UAAU,mBAAmB,CAAC,OAAO,GAAG,cAAc;IAC1D,IAAI,OAAO,cAAc,KAAK,WAAW,IAAI,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE,OAAO;IAEjF,MAAM,UAAW,SAAQ,WAAW;QAClC,MAAM,CAAC,kBAAkB,GAAG,CAAC,OAAO,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC;QAE7D,MAAM,CAAyB;QAC/B,IAAI,GAA2B,IAAI,CAAC;QACpC,KAAK,GAA4B,IAAI,CAAC;QACtC,MAAM,GAA6B,IAAI,CAAC;QACxC,OAAO,GAAuB,IAAI,CAAC;QACnC,UAAU,GAAG,EAAE,CAAC;QAExB,IAAI,QAAQ;YACV,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACzE,CAAC;QAED,iBAAiB;YACf,wEAAwE;YACxE,oEA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AAC;QACrB,GAAG,CAAC,QAAQ,GAAG,OAAO,CAAC;QACvB,GAAG,CAAC,cAAc,GAAG,aAAa,CAAC;QACnC,OAAO,GAAG,CAAC;IACb,CAAC;IACD,MAAM,OAAO,GAAG,EAAE,CAAC,MAAM,EAAE,GAAG,CAAC,YAAY,CAAC,iBAAiB,EAAE,CAAC,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;IAChI,OAAO,CAAC,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IAC5C,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,QAAQ,CAAC,OAAiD;IACjE,MAAM,IAAI,GAAG,EAAE,CAAC,MAAM,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC;IAC1C,IAAI,OAAO,CAAC,WAAW;QAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;IACpF,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,EAAE,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAC9D,OAAO,IAAI,CAAC;AACd,CAAC;AAED,mBAAmB,EAAE,CAAC"}
@@ -0,0 +1,16 @@
1
+ export interface HandleSuggestion {
2
+ did: string;
3
+ handle: string;
4
+ displayName?: string;
5
+ avatar?: string;
6
+ }
7
+ /**
8
+ * Handle typeahead from Bluesky's public AppView. Optional, and it sends what
9
+ * the person types to Bluesky as they type, so only use it where that's fine.
10
+ * Pass an `AbortSignal` and abort the previous call on each keystroke.
11
+ */
12
+ export declare function searchHandles(query: string, options?: {
13
+ limit?: number;
14
+ signal?: AbortSignal;
15
+ fetch?: typeof fetch;
16
+ }): Promise<HandleSuggestion[]>;
package/dist/search.js ADDED
@@ -0,0 +1,38 @@
1
+ import { httpsUrl } from "./accounts.js";
2
+ /**
3
+ * Handle typeahead from Bluesky's public AppView. Optional, and it sends what
4
+ * the person types to Bluesky as they type, so only use it where that's fine.
5
+ * Pass an `AbortSignal` and abort the previous call on each keystroke.
6
+ */
7
+ export async function searchHandles(query, options = {}) {
8
+ const q = query.normalize("NFKC").trim().replace(/^@/, "");
9
+ if (q.length < 2)
10
+ return [];
11
+ const url = new URL("https://public.api.bsky.app/xrpc/app.bsky.actor.searchActorsTypeahead");
12
+ url.searchParams.set("q", q);
13
+ url.searchParams.set("limit", String(options.limit ?? 5));
14
+ const doFetch = options.fetch ?? ((input, init) => globalThis.fetch(input, init));
15
+ const res = await doFetch(url, options.signal ? { signal: options.signal } : {});
16
+ if (!res.ok)
17
+ return [];
18
+ const body = await res.json();
19
+ if (typeof body !== "object" || body === null || !("actors" in body) || !Array.isArray(body.actors))
20
+ return [];
21
+ return body.actors.flatMap((actor) => {
22
+ if (typeof actor !== "object" || actor === null)
23
+ return [];
24
+ const a = actor;
25
+ if (typeof a["did"] !== "string" || typeof a["handle"] !== "string")
26
+ return [];
27
+ const avatar = httpsUrl(a["avatar"]);
28
+ return [
29
+ {
30
+ did: a["did"],
31
+ handle: a["handle"],
32
+ ...(typeof a["displayName"] === "string" && a["displayName"] ? { displayName: a["displayName"] } : {}),
33
+ ...(avatar ? { avatar } : {}),
34
+ },
35
+ ];
36
+ });
37
+ }
38
+ //# sourceMappingURL=search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.js","sourceRoot":"","sources":["../src/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AASzC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,KAAa,EACb,UAA0E,EAAE;IAE5E,MAAM,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,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O,CAAC,CAAC,QAAQ,CAAC,KAAK,QAAQ;YAAE,OAAO,EAAE,CAAC;QAC/E,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;QACrC,OAAO;YACL;gBACE,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC;gBACb,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC;gBACnB,GAAG,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACtG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC9B;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { type HandleResolver, type OAuthClientMetadataInput, type OAuthSession, type RuntimeLock } from "@atproto/oauth-client";
2
2
  import { type User } from "../shared.js";
3
+ import { type ConditionalScope } from "./scopes.js";
3
4
  import type { AuthStore } from "./stores/types.js";
4
5
  export interface BlueskyAuthOptions {
5
6
  /** Shown on the Bluesky consent screen. */
@@ -12,8 +13,35 @@ export interface BlueskyAuthOptions {
12
13
  basePath?: string;
13
14
  /** Where the browser lands after sign-in or sign-out, unless the sign-in named a `returnTo`. Default `/`. */
14
15
  redirectTo?: string;
15
- /** OAuth scope. Default `atproto` (identity only). Add e.g. `transition:generic` to write to the PDS. */
16
+ /**
17
+ * The OAuth scope asked for at every sign-in. Default `atproto` (identity
18
+ * only). Add granular scopes (`repo:com.example.post`, `rpc:…?aud=…`,
19
+ * `space:…`) or `transition:generic` to act on the person's PDS.
20
+ */
16
21
  scope?: string;
22
+ /**
23
+ * Scopes asked for only when the PDS signing someone in can honour them, such
24
+ * as space scopes, which most PDSes don't support yet and which fail the whole
25
+ * sign-in where they aren't. Each is still published in the client metadata,
26
+ * which bounds what the client may ask for. See `pdsServesMethod`.
27
+ */
28
+ conditionalScopes?: ConditionalScope[];
29
+ /**
30
+ * Private signing keys (ES256 JWKs with a `kid`, as objects or JSON strings)
31
+ * that make this a confidential client: token requests are authenticated with
32
+ * `private_key_jwt`, and the public halves are served at
33
+ * `{basePath}/jwks.json`. Authorization servers give confidential clients far
34
+ * longer sessions. Loopback development stays a public client. Rotating keys:
35
+ * list the new one first and keep the old one until its sessions have
36
+ * refreshed.
37
+ */
38
+ privateKeys?: Array<string | Record<string, unknown>>;
39
+ /**
40
+ * The app's public origin (`https://app.example`), for work outside a request:
41
+ * `restore` and `obtainSession` without an `origin` of their own. The client
42
+ * identity is named for an origin, so these need one.
43
+ */
44
+ origin?: string;
17
45
  /** How long a sign-in lasts, in seconds. Default 30 days. */
18
46
  sessionTtlSeconds?: number;
19
47
  /** Name of the session cookie. Default `bsky_sid`. */
@@ -52,6 +80,37 @@ export interface BlueskyAuth {
52
80
  * (`new Agent(session)` from `@atproto/api`). Refreshes tokens as needed.
53
81
  */
54
82
  getOAuthSession(request: Request): Promise<OAuthSession | null>;
83
+ /**
84
+ * The OAuth session stored for `did`, outside any request: background work,
85
+ * or acting as an account whose session was handed over (`obtainSession`).
86
+ * `null` when none is stored or it can no longer be refreshed. Uses `origin`,
87
+ * or the `origin` option.
88
+ */
89
+ restore(did: string, opts?: {
90
+ origin?: string;
91
+ }): Promise<OAuthSession | null>;
92
+ /**
93
+ * Accept a session for another account, handed over by that account's own
94
+ * authorization server outside the redirect flow: a group host creating a
95
+ * group account for this app, for instance.
96
+ *
97
+ * POSTs `body` as JSON to `url` the way a token request is made: with this
98
+ * app's `client_id` (and a client assertion when confidential), a DPoP proof
99
+ * for a fresh key, and `headers` (service auth from the person asking,
100
+ * typically). The response must hold an OAuth token response, at `session` or
101
+ * as the whole body. The session is kept only if `url` belongs to the
102
+ * account's own authorization server, so no endpoint can hand over an account
103
+ * it doesn't serve; it is then stored like a sign-in's, and `restore(did)`
104
+ * returns it. Throws `ObtainSessionError` otherwise.
105
+ */
106
+ obtainSession(url: string, body: Record<string, unknown>, opts?: {
107
+ headers?: Record<string, string>;
108
+ origin?: string;
109
+ }): Promise<{
110
+ did: string;
111
+ session: OAuthSession;
112
+ response: Record<string, unknown>;
113
+ }>;
55
114
  /** The client metadata document served for an origin. */
56
115
  clientMetadata(origin: string): OAuthClientMetadataInput;
57
116
  }