ovr 7.0.0-next.2 → 7.0.0-next.21

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.
Files changed (52) hide show
  1. package/CHANGELOG.md +1157 -0
  2. package/dist/auth/client-source.d.ts +2 -2
  3. package/dist/auth/client-source.d.ts.map +1 -1
  4. package/dist/auth/client-source.js +2 -2
  5. package/dist/auth/client.d.ts.map +1 -1
  6. package/dist/auth/client.js +7 -4
  7. package/dist/auth/configure.d.ts +21 -8
  8. package/dist/auth/configure.d.ts.map +1 -1
  9. package/dist/auth/configure.js +172 -6
  10. package/dist/auth/index.d.ts +48 -0
  11. package/dist/auth/index.d.ts.map +1 -1
  12. package/dist/auth/index.js +19 -0
  13. package/dist/auth/passkey.d.ts +14 -2
  14. package/dist/auth/passkey.d.ts.map +1 -1
  15. package/dist/auth/passkey.js +18 -5
  16. package/dist/auth/state.d.ts +6 -0
  17. package/dist/auth/state.d.ts.map +1 -1
  18. package/dist/auth/state.js +28 -5
  19. package/dist/auth/storage.d.ts +38 -0
  20. package/dist/auth/storage.d.ts.map +1 -1
  21. package/dist/auth/storage.js +60 -3
  22. package/dist/context/index.d.ts +4 -4
  23. package/dist/context/index.d.ts.map +1 -1
  24. package/dist/context/index.js +6 -3
  25. package/dist/form/index.d.ts +239 -31
  26. package/dist/form/index.d.ts.map +1 -1
  27. package/dist/form/index.js +657 -66
  28. package/dist/markdown/index.d.ts +6 -1
  29. package/dist/markdown/index.d.ts.map +1 -1
  30. package/dist/markdown/index.js +180 -9
  31. package/dist/mcp/index.d.ts.map +1 -1
  32. package/dist/mcp/index.js +154 -57
  33. package/dist/schema/index.d.ts +88 -19
  34. package/dist/schema/index.d.ts.map +1 -1
  35. package/dist/schema/index.js +32 -11
  36. package/dist/util/index.d.ts +12 -0
  37. package/dist/util/index.d.ts.map +1 -1
  38. package/dist/util/index.js +19 -0
  39. package/package.json +2 -1
  40. package/src/auth/client-source.ts +2 -2
  41. package/src/auth/client.ts +7 -4
  42. package/src/auth/configure.ts +189 -13
  43. package/src/auth/index.ts +44 -0
  44. package/src/auth/passkey.ts +25 -7
  45. package/src/auth/state.ts +32 -7
  46. package/src/auth/storage.ts +66 -3
  47. package/src/context/index.ts +14 -6
  48. package/src/form/index.ts +1174 -195
  49. package/src/markdown/index.ts +203 -12
  50. package/src/mcp/index.ts +205 -72
  51. package/src/schema/index.ts +195 -52
  52. package/src/util/index.ts +23 -0
@@ -1,3 +1,3 @@
1
- export declare const source = "export function listen(e,t,n,r){let i=document.getElementById(e),a=i?.closest(`form`),o=i?.previousElementSibling,s=a?.querySelector(`[data-passkey-error]:not([data-passkey-fallback])`)??o;if(!(a instanceof HTMLFormElement)||!(s instanceof HTMLElement))return;s!==o&&o instanceof HTMLElement&&(o.hidden=!0);let c=e=>{let t=a.elements.namedItem(e);if(t instanceof HTMLInputElement)return t;let n=document.createElement(`input`);return n.type=`hidden`,n.name=e,a.append(n),n},l=c(`credential`),u=c(`ceremony`),d=!1,f=!1,p=!1,m,h=0,g,_=()=>`Too many requests. Try again in ${Math.ceil((h-Date.now())/1e3)} seconds.`,v=()=>{clearTimeout(g),g=void 0,d=f=p=!1,m=void 0,l.value=u.value=``,a.removeAttribute(`aria-busy`)},y=(e,t)=>{e instanceof HTMLElement&&`setCustomValidity`in e&&typeof e.setCustomValidity==`function`&&e.setCustomValidity(t)},b=e=>y(e.target,``);return a.addEventListener(`input`,b),a.addEventListener(`change`,b),a.addEventListener(`submit`,async e=>{if(!e.submitter?.hasAttribute(`formaction`)){if(f){p?m=e:e.preventDefault();return}if(e.preventDefault(),!d){if(h>Date.now()){s.textContent=_();return}d=!0,s.textContent=``,a.setAttribute(`aria-busy`,`true`);try{if(!window.PublicKeyCredential?.parseCreationOptionsFromJSON||!PublicKeyCredential.parseRequestOptionsFromJSON||!navigator.credentials)throw Error(`Passkeys are unavailable in this browser.`);let i=new FormData(a);i.delete(`credential`),i.delete(`ceremony`),i.set(`bootstrap`,t);let o=await fetch(n,{method:`POST`,body:i,credentials:`same-origin`,cache:`no-store`});if(o.status===429){let e=Date.now(),t=o.headers.get(`retry-after`)??`60`,n=/^\\d+$/.test(t)?e+Number(t)*1e3:Date.parse(t);throw h=Number.isNaN(n)?e+6e4:Math.min(e+36e5,Math.max(e+1e3,n)),Error(_())}if(o.status===422){let e=await o.json();if(Array.isArray(e.fields))for(let t of e.fields)typeof t==`string`&&y(a.elements.namedItem(t),`Check this field.`);throw a.reportValidity(),Error(`Check your registration details and try again.`)}if(o.status===410)throw Error(`This page has expired. Reload and try again.`);if(!o.ok)throw Error(`Could not start the passkey request. Try again.`);let c=await o.json();u.value=c.ceremony;let d=await(r===`register`?navigator.credentials.create({publicKey:PublicKeyCredential.parseCreationOptionsFromJSON(c.options)}):navigator.credentials.get({publicKey:PublicKeyCredential.parseRequestOptionsFromJSON(c.options)}));if(!(d instanceof PublicKeyCredential))throw Error(`No passkey was returned. Try again.`);l.value=JSON.stringify(d),f=!0,p=!0,m=void 0,HTMLFormElement.prototype.requestSubmit.call(a,e.submitter??void 0),p=!1,f=!!(m&&!m.defaultPrevented),f&&(g=setTimeout(()=>{v(),s.textContent=r===`register`?`If registration already completed, sign in; otherwise try again.`:`If sign-in did not finish, try again.`},12e4))}catch(e){v(),s.textContent=e instanceof DOMException&&e.name===`NotAllowedError`?`Passkey request canceled. Try again.`:e instanceof Error?e.message:`Could not complete the passkey request. Try again.`}finally{d=!1,p=!1,f||a.removeAttribute(`aria-busy`)}}}}),v}const t=new WeakMap,n=()=>document.querySelectorAll(`script[data-passkey]`),r=()=>{for(let r of n()){if(t.has(r))continue;let n=r.dataset.passkey;if(n===`register`||n===`login`){let i=listen(r.id,r.dataset.bootstrap??``,r.dataset.endpoint??``,n);i&&t.set(r,i)}}};typeof document<`u`&&(window.addEventListener(`pageshow`,e=>{if(e.persisted)for(let e of n())t.get(e)?.()}),r(),new MutationObserver(r).observe(document.documentElement,{childList:!0,subtree:!0}));";
2
- export declare const etag = "W/\"c904f3541cdce47df6c6e44e6ae8fddaa56155055b2b65bc580de00ff3741e7b\"";
1
+ export declare const source = "export function listen(e,t,n,r){let i=document.getElementById(e),a=i?.closest(`form`),o=i?.previousElementSibling,s=a?.querySelector(`[data-passkey-error]:not([data-passkey-fallback])`)??o;if(!(a instanceof HTMLFormElement)||!(s instanceof HTMLElement))return;s!==o&&o instanceof HTMLElement&&(o.hidden=!0);let c=e=>{let t=a.elements.namedItem(e);if(t instanceof HTMLInputElement)return t;let n=document.createElement(`input`);return n.type=`hidden`,n.name=e,a.append(n),n},l=c(`credential`),u=c(`ceremony`),d=!1,f=!1,p=!1,m,h=0,g,_=()=>`Too many requests. Try again in ${Math.ceil((h-Date.now())/1e3)} seconds.`,v=()=>{clearTimeout(g),g=void 0,d=f=p=!1,m=void 0,l.value=u.value=``,a.removeAttribute(`aria-busy`)},y=(e,t)=>{e instanceof HTMLElement&&`setCustomValidity`in e&&typeof e.setCustomValidity==`function`&&e.setCustomValidity(t)},b=e=>y(e.target,``);return a.addEventListener(`input`,b),a.addEventListener(`change`,b),a.addEventListener(`submit`,async e=>{if(!e.submitter?.hasAttribute(`formaction`)){if(f){p?m=e:e.preventDefault();return}if(e.preventDefault(),!d){if(h>Date.now()){s.textContent=_();return}d=!0,s.textContent=``,a.setAttribute(`aria-busy`,`true`);try{if(!window.PublicKeyCredential?.parseCreationOptionsFromJSON||!PublicKeyCredential.parseRequestOptionsFromJSON||!navigator.credentials)throw Error(`Passkeys are unavailable in this browser.`);let i=new FormData(a);i.delete(`credential`),i.delete(`ceremony`),i.set(`bootstrap`,t);let o=await fetch(n,{method:`POST`,body:i,credentials:`same-origin`,cache:`no-store`});if(o.status===429){let e=Date.now(),t=o.headers.get(`retry-after`)??`60`,n=/^\\d+$/.test(t)?e+Number(t)*1e3:Date.parse(t);throw h=Number.isNaN(n)?e+6e4:Math.min(e+36e5,Math.max(e+1e3,n)),Error(_())}if(o.status===422){let e=await o.json();if(e.fields&&typeof e.fields==`object`)for(let[t,n]of Object.entries(e.fields))typeof n==`string`&&y(a.elements.namedItem(t),n);throw a.reportValidity(),Error(`Check your registration details and try again.`)}if(o.status===410)throw Error(`This page has expired. Reload and try again.`);if(o.status===401)throw Error(`Sign in again, then add the passkey.`);if(!o.ok)throw Error(`Could not start the passkey request. Try again.`);let c=await o.json();u.value=c.ceremony;let d=await(r===`register`?navigator.credentials.create({publicKey:PublicKeyCredential.parseCreationOptionsFromJSON(c.options)}):navigator.credentials.get({publicKey:PublicKeyCredential.parseRequestOptionsFromJSON(c.options)}));if(!(d instanceof PublicKeyCredential))throw Error(`No passkey was returned. Try again.`);l.value=JSON.stringify(d),f=!0,p=!0,m=void 0,HTMLFormElement.prototype.requestSubmit.call(a,e.submitter??void 0),p=!1,f=!!(m&&!m.defaultPrevented),f&&(g=setTimeout(()=>{v(),s.textContent=r===`register`?`If registration already completed, sign in; otherwise try again.`:`If sign-in did not finish, try again.`},12e4))}catch(e){v(),s.textContent=e instanceof DOMException&&e.name===`NotAllowedError`?`Passkey request canceled. Try again.`:e instanceof Error?e.message:`Could not complete the passkey request. Try again.`}finally{d=!1,p=!1,f||a.removeAttribute(`aria-busy`)}}}}),v}const t=new WeakMap,n=()=>document.querySelectorAll(`script[data-passkey]`),r=()=>{for(let r of n()){if(t.has(r))continue;let n=r.dataset.passkey;if(n===`register`||n===`login`){let i=listen(r.id,r.dataset.bootstrap??``,r.dataset.endpoint??``,n);i&&t.set(r,i)}}};typeof document<`u`&&(window.addEventListener(`pageshow`,e=>{if(e.persisted)for(let e of n())t.get(e)?.()}),r(),new MutationObserver(r).observe(document.documentElement,{childList:!0,subtree:!0}));";
2
+ export declare const etag = "W/\"fc0a48d1caaf1b51b2b1bfef31c98c2019ea7938ff4ddcddae0b152d58ac5691\"";
3
3
  //# sourceMappingURL=client-source.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client-source.d.ts","sourceRoot":"","sources":["../../src/auth/client-source.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,MAAM,y8GAAy8G,CAAC;AAC79G,eAAO,MAAM,IAAI,2EAA2E,CAAC"}
1
+ {"version":3,"file":"client-source.d.ts","sourceRoot":"","sources":["../../src/auth/client-source.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,MAAM,2hHAA2hH,CAAC;AAC/iH,eAAO,MAAM,IAAI,2EAA2E,CAAC"}
@@ -1,3 +1,3 @@
1
1
  // Generated by scripts/client.js; edit client.ts instead.
2
- export const source = "export function listen(e,t,n,r){let i=document.getElementById(e),a=i?.closest(`form`),o=i?.previousElementSibling,s=a?.querySelector(`[data-passkey-error]:not([data-passkey-fallback])`)??o;if(!(a instanceof HTMLFormElement)||!(s instanceof HTMLElement))return;s!==o&&o instanceof HTMLElement&&(o.hidden=!0);let c=e=>{let t=a.elements.namedItem(e);if(t instanceof HTMLInputElement)return t;let n=document.createElement(`input`);return n.type=`hidden`,n.name=e,a.append(n),n},l=c(`credential`),u=c(`ceremony`),d=!1,f=!1,p=!1,m,h=0,g,_=()=>`Too many requests. Try again in ${Math.ceil((h-Date.now())/1e3)} seconds.`,v=()=>{clearTimeout(g),g=void 0,d=f=p=!1,m=void 0,l.value=u.value=``,a.removeAttribute(`aria-busy`)},y=(e,t)=>{e instanceof HTMLElement&&`setCustomValidity`in e&&typeof e.setCustomValidity==`function`&&e.setCustomValidity(t)},b=e=>y(e.target,``);return a.addEventListener(`input`,b),a.addEventListener(`change`,b),a.addEventListener(`submit`,async e=>{if(!e.submitter?.hasAttribute(`formaction`)){if(f){p?m=e:e.preventDefault();return}if(e.preventDefault(),!d){if(h>Date.now()){s.textContent=_();return}d=!0,s.textContent=``,a.setAttribute(`aria-busy`,`true`);try{if(!window.PublicKeyCredential?.parseCreationOptionsFromJSON||!PublicKeyCredential.parseRequestOptionsFromJSON||!navigator.credentials)throw Error(`Passkeys are unavailable in this browser.`);let i=new FormData(a);i.delete(`credential`),i.delete(`ceremony`),i.set(`bootstrap`,t);let o=await fetch(n,{method:`POST`,body:i,credentials:`same-origin`,cache:`no-store`});if(o.status===429){let e=Date.now(),t=o.headers.get(`retry-after`)??`60`,n=/^\\d+$/.test(t)?e+Number(t)*1e3:Date.parse(t);throw h=Number.isNaN(n)?e+6e4:Math.min(e+36e5,Math.max(e+1e3,n)),Error(_())}if(o.status===422){let e=await o.json();if(Array.isArray(e.fields))for(let t of e.fields)typeof t==`string`&&y(a.elements.namedItem(t),`Check this field.`);throw a.reportValidity(),Error(`Check your registration details and try again.`)}if(o.status===410)throw Error(`This page has expired. Reload and try again.`);if(!o.ok)throw Error(`Could not start the passkey request. Try again.`);let c=await o.json();u.value=c.ceremony;let d=await(r===`register`?navigator.credentials.create({publicKey:PublicKeyCredential.parseCreationOptionsFromJSON(c.options)}):navigator.credentials.get({publicKey:PublicKeyCredential.parseRequestOptionsFromJSON(c.options)}));if(!(d instanceof PublicKeyCredential))throw Error(`No passkey was returned. Try again.`);l.value=JSON.stringify(d),f=!0,p=!0,m=void 0,HTMLFormElement.prototype.requestSubmit.call(a,e.submitter??void 0),p=!1,f=!!(m&&!m.defaultPrevented),f&&(g=setTimeout(()=>{v(),s.textContent=r===`register`?`If registration already completed, sign in; otherwise try again.`:`If sign-in did not finish, try again.`},12e4))}catch(e){v(),s.textContent=e instanceof DOMException&&e.name===`NotAllowedError`?`Passkey request canceled. Try again.`:e instanceof Error?e.message:`Could not complete the passkey request. Try again.`}finally{d=!1,p=!1,f||a.removeAttribute(`aria-busy`)}}}}),v}const t=new WeakMap,n=()=>document.querySelectorAll(`script[data-passkey]`),r=()=>{for(let r of n()){if(t.has(r))continue;let n=r.dataset.passkey;if(n===`register`||n===`login`){let i=listen(r.id,r.dataset.bootstrap??``,r.dataset.endpoint??``,n);i&&t.set(r,i)}}};typeof document<`u`&&(window.addEventListener(`pageshow`,e=>{if(e.persisted)for(let e of n())t.get(e)?.()}),r(),new MutationObserver(r).observe(document.documentElement,{childList:!0,subtree:!0}));";
3
- export const etag = "W/\"c904f3541cdce47df6c6e44e6ae8fddaa56155055b2b65bc580de00ff3741e7b\"";
2
+ export const source = "export function listen(e,t,n,r){let i=document.getElementById(e),a=i?.closest(`form`),o=i?.previousElementSibling,s=a?.querySelector(`[data-passkey-error]:not([data-passkey-fallback])`)??o;if(!(a instanceof HTMLFormElement)||!(s instanceof HTMLElement))return;s!==o&&o instanceof HTMLElement&&(o.hidden=!0);let c=e=>{let t=a.elements.namedItem(e);if(t instanceof HTMLInputElement)return t;let n=document.createElement(`input`);return n.type=`hidden`,n.name=e,a.append(n),n},l=c(`credential`),u=c(`ceremony`),d=!1,f=!1,p=!1,m,h=0,g,_=()=>`Too many requests. Try again in ${Math.ceil((h-Date.now())/1e3)} seconds.`,v=()=>{clearTimeout(g),g=void 0,d=f=p=!1,m=void 0,l.value=u.value=``,a.removeAttribute(`aria-busy`)},y=(e,t)=>{e instanceof HTMLElement&&`setCustomValidity`in e&&typeof e.setCustomValidity==`function`&&e.setCustomValidity(t)},b=e=>y(e.target,``);return a.addEventListener(`input`,b),a.addEventListener(`change`,b),a.addEventListener(`submit`,async e=>{if(!e.submitter?.hasAttribute(`formaction`)){if(f){p?m=e:e.preventDefault();return}if(e.preventDefault(),!d){if(h>Date.now()){s.textContent=_();return}d=!0,s.textContent=``,a.setAttribute(`aria-busy`,`true`);try{if(!window.PublicKeyCredential?.parseCreationOptionsFromJSON||!PublicKeyCredential.parseRequestOptionsFromJSON||!navigator.credentials)throw Error(`Passkeys are unavailable in this browser.`);let i=new FormData(a);i.delete(`credential`),i.delete(`ceremony`),i.set(`bootstrap`,t);let o=await fetch(n,{method:`POST`,body:i,credentials:`same-origin`,cache:`no-store`});if(o.status===429){let e=Date.now(),t=o.headers.get(`retry-after`)??`60`,n=/^\\d+$/.test(t)?e+Number(t)*1e3:Date.parse(t);throw h=Number.isNaN(n)?e+6e4:Math.min(e+36e5,Math.max(e+1e3,n)),Error(_())}if(o.status===422){let e=await o.json();if(e.fields&&typeof e.fields==`object`)for(let[t,n]of Object.entries(e.fields))typeof n==`string`&&y(a.elements.namedItem(t),n);throw a.reportValidity(),Error(`Check your registration details and try again.`)}if(o.status===410)throw Error(`This page has expired. Reload and try again.`);if(o.status===401)throw Error(`Sign in again, then add the passkey.`);if(!o.ok)throw Error(`Could not start the passkey request. Try again.`);let c=await o.json();u.value=c.ceremony;let d=await(r===`register`?navigator.credentials.create({publicKey:PublicKeyCredential.parseCreationOptionsFromJSON(c.options)}):navigator.credentials.get({publicKey:PublicKeyCredential.parseRequestOptionsFromJSON(c.options)}));if(!(d instanceof PublicKeyCredential))throw Error(`No passkey was returned. Try again.`);l.value=JSON.stringify(d),f=!0,p=!0,m=void 0,HTMLFormElement.prototype.requestSubmit.call(a,e.submitter??void 0),p=!1,f=!!(m&&!m.defaultPrevented),f&&(g=setTimeout(()=>{v(),s.textContent=r===`register`?`If registration already completed, sign in; otherwise try again.`:`If sign-in did not finish, try again.`},12e4))}catch(e){v(),s.textContent=e instanceof DOMException&&e.name===`NotAllowedError`?`Passkey request canceled. Try again.`:e instanceof Error?e.message:`Could not complete the passkey request. Try again.`}finally{d=!1,p=!1,f||a.removeAttribute(`aria-busy`)}}}}),v}const t=new WeakMap,n=()=>document.querySelectorAll(`script[data-passkey]`),r=()=>{for(let r of n()){if(t.has(r))continue;let n=r.dataset.passkey;if(n===`register`||n===`login`){let i=listen(r.id,r.dataset.bootstrap??``,r.dataset.endpoint??``,n);i&&t.set(r,i)}}};typeof document<`u`&&(window.addEventListener(`pageshow`,e=>{if(e.persisted)for(let e of n())t.get(e)?.()}),r(),new MutationObserver(r).observe(document.documentElement,{childList:!0,subtree:!0}));";
3
+ export const etag = "W/\"fc0a48d1caaf1b51b2b1bfef31c98c2019ea7938ff4ddcddae0b152d58ac5691\"";
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/auth/client.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,wBAAgB,MAAM,CACrB,EAAE,EAAE,MAAM,EACV,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,UAAU,GAAG,OAAO,4BAyK5B"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/auth/client.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,wBAAgB,MAAM,CACrB,EAAE,EAAE,MAAM,EACV,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,UAAU,GAAG,OAAO,4BA4K5B"}
@@ -97,15 +97,18 @@ export function listen(id, bootstrap, endpoint, method) {
97
97
  }
98
98
  if (res.status === 422) {
99
99
  const result = await res.json();
100
- if (Array.isArray(result.fields))
101
- for (const name of result.fields)
102
- if (typeof name === "string")
103
- validity(form.elements.namedItem(name), "Check this field.");
100
+ if (result.fields && typeof result.fields === "object")
101
+ for (const [name, message] of Object.entries(result.fields))
102
+ if (typeof message === "string")
103
+ validity(form.elements.namedItem(name), message);
104
104
  form.reportValidity();
105
105
  throw new Error("Check your registration details and try again.");
106
106
  }
107
107
  if (res.status === 410)
108
108
  throw new Error("This page has expired. Reload and try again.");
109
+ // adding a passkey asks for a recent sign-in
110
+ if (res.status === 401)
111
+ throw new Error("Sign in again, then add the passkey.");
109
112
  if (!res.ok)
110
113
  throw new Error("Could not start the passkey request. Try again.");
111
114
  // creation options for a registration, request options for a login
@@ -9,17 +9,30 @@ import type { Storage } from "./storage.js";
9
9
  * @template U Users table
10
10
  */
11
11
  export declare function configure<U extends Auth.Users>(options: Auth.Options<U>, storage: Storage, state: (c: State.Context) => State): {
12
- routes: (Route.Used<Route.Get<"/_passkey/client.js", {}, Field.Shape>> | Route.Used<Route.Post<"/_passkey/options/login", {}, {
13
- bootstrap: Field.Instance<string, "input", "hidden", undefined, undefined>;
12
+ routes: (Route.Used<Route.Get<"/_passkey/client.js", {}, Field.Shape>> | Route.Used<Route.Post<"/_passkey/options/add", {}, {
13
+ name: Field.Instance<string | undefined, "input", "text", undefined, undefined, undefined>;
14
+ bootstrap: Field.Instance<string, "input", "hidden", undefined, undefined, undefined>;
15
+ }>> | Route.Used<Route.Post<"/_passkey/options/login", {}, {
16
+ bootstrap: Field.Instance<string, "input", "hidden", undefined, undefined, undefined>;
14
17
  }>> | Route.Used<Route.Post<"/_passkey/options/register", {}, {
15
- bootstrap: Field.Instance<string, "input", "hidden", undefined, undefined>;
18
+ bootstrap: Field.Instance<string, "input", "hidden", undefined, undefined, undefined>;
19
+ }>> | Route.Used<Route.Post<"/auth/link", {}, {
20
+ link: Field.Instance<string, "input", "hidden", undefined, undefined, undefined>;
16
21
  }>> | Route.Used<Route.Post<"/auth/login", {}, {
17
- credential: Field.Instance<unknown, "input", "hidden", undefined, undefined>;
18
- ceremony: Field.Instance<string, "input", "hidden", undefined, undefined>;
19
- }>> | Route.Used<Route.Post<"/auth/logout", {}, Field.Shape>> | Route.Used<Route.Post<"/auth/register", {}, {
20
- credential: Field.Instance<unknown, "input", "hidden", undefined, undefined>;
21
- ceremony: Field.Instance<string, "input", "hidden", undefined, undefined>;
22
+ credential: Field.Instance<unknown, "input", "hidden", undefined, undefined, undefined>;
23
+ ceremony: Field.Instance<string, "input", "hidden", undefined, undefined, undefined>;
24
+ }>> | Route.Used<Route.Post<"/auth/logout", {}, Field.Shape>> | Route.Used<Route.Post<"/auth/passkey", {}, {
25
+ credential: Field.Instance<unknown, "input", "hidden", undefined, undefined, undefined>;
26
+ ceremony: Field.Instance<string, "input", "hidden", undefined, undefined, undefined>;
27
+ name: Field.Instance<string | undefined, "input", "text", undefined, undefined, undefined>;
28
+ }>> | Route.Used<Route.Post<"/auth/register", {}, {
29
+ credential: Field.Instance<unknown, "input", "hidden", undefined, undefined, undefined>;
30
+ ceremony: Field.Instance<string, "input", "hidden", undefined, undefined, undefined>;
22
31
  }>>)[];
32
+ /** Make a link that signs a user in once, see `Auth.link`. */
33
+ link(user: string, { origin }?: {
34
+ origin?: string;
35
+ }): Promise<string>;
23
36
  /** Create forms in the handler before returning JSX, so ovr can set the binding cookie. */
24
37
  forms(c: Auth.Context, props?: {
25
38
  nonce?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../../src/auth/configure.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAe,MAAM,kBAAkB,CAAC;AAItD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGvC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,IAAI,CAAC,KAAK,EAC7C,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EACxB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,OAAO,KAAK,KAAK;;;;;;;;;;;;IA6MjC,2FAA2F;aAEvF,IAAI,CAAC,OAAO,UACR;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GACvB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;EAmD9B"}
1
+ {"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../../src/auth/configure.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAsB,MAAM,kBAAkB,CAAC;AAI7D,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGvC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAG5C;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,IAAI,CAAC,KAAK,EAC7C,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EACxB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,OAAO,KAAK,KAAK;;;;;;;;;;;;;;;;;;;;;IAoUjC,8DAA8D;eAEvD,MAAM,eACiB;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;IAiBjD,2FAA2F;aAEvF,IAAI,CAAC,OAAO,UACR;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GACvB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;EAuF9B"}
@@ -1,11 +1,12 @@
1
1
  import { Database } from "../database/index.js";
2
- import { Field, Form, field } from "../form/index.js";
2
+ import { Field, Form, field, taken } from "../form/index.js";
3
3
  import { jsx } from "../jsx/index.js";
4
4
  import { Limiter } from "../limiter/index.js";
5
5
  import { Route } from "../route/index.js";
6
6
  import { Header, Time, noStore } from "../util/index.js";
7
7
  import { Issue } from "./issue.js";
8
8
  import { Passkey } from "./passkey.js";
9
+ import { Token } from "./token.js";
9
10
  /**
10
11
  * Construct startup-complete handlers and request-scoped UI components.
11
12
  *
@@ -29,11 +30,14 @@ export function configure(options, storage, state) {
29
30
  const limits = {
30
31
  register: limiter("register", 5, 10 * Time.minute),
31
32
  login: limiter("login", 20, Time.minute),
33
+ add: limiter("add", 5, 10 * Time.minute),
32
34
  };
33
35
  const paths = {
34
36
  register: "/auth/register",
35
37
  login: "/auth/login",
36
38
  logout: "/auth/logout",
39
+ passkey: "/auth/passkey",
40
+ link: "/auth/link",
37
41
  options: "/_passkey/options",
38
42
  };
39
43
  const page = options.page ?? "/login";
@@ -50,15 +54,42 @@ export function configure(options, storage, state) {
50
54
  // Both routes validate this application shape before selecting its transformed values.
51
55
  return Object.fromEntries(fields.names.map((name) => [name, Reflect.get(data, name)]));
52
56
  };
57
+ /**
58
+ * @param data Registration values
59
+ * @returns The message of each `taken()` field whose value a user has
60
+ */
61
+ const conflicts = async (data) => {
62
+ const used = {};
63
+ for (const name of fields.names) {
64
+ const message = shape[name][taken];
65
+ const value = Reflect.get(data, name);
66
+ if (message === undefined || value == null || value === "")
67
+ continue;
68
+ const rows = await options.database
69
+ .sql `SELECT 1 FROM ${users} WHERE ${users.columns[name]} = ${value} LIMIT 1`;
70
+ if (rows.length)
71
+ used[name] = message;
72
+ }
73
+ return used;
74
+ };
75
+ /** @returns The page a form was on, if it said, or where a login goes */
76
+ const returning = (c) => {
77
+ const target = new URL(c.url.searchParams.get(Form.params[0]) ?? redirect, options.origin);
78
+ return target.origin === options.origin
79
+ ? target
80
+ : new URL(redirect, options.origin);
81
+ };
53
82
  const back = (c, method, retry = 0) => {
54
- const target = new URL(page, options.origin);
83
+ // a passkey is added from a page of the account, not the login page
84
+ const target = method === "add" ? returning(c) : new URL(page, options.origin);
55
85
  target.searchParams.set("_auth", method);
56
86
  if (retry)
57
87
  target.searchParams.set("_retry", String(retry));
58
88
  c.redirect(target, 303);
59
89
  };
60
90
  const admit = async (c, method, prompt) => {
61
- const admission = await limits[method].check(c, prompt ? "options" : "verify");
91
+ // a link signs in, so it shares a login's limit
92
+ const admission = await limits[method === "link" ? "login" : method].check(c, prompt ? "options" : "verify");
62
93
  if (admission === true)
63
94
  return true;
64
95
  const now = Date.now();
@@ -145,8 +176,15 @@ export function configure(options, storage, state) {
145
176
  if (!input)
146
177
  throw new Issue("registration request");
147
178
  if (input.issues) {
148
- const invalid = fields.names.filter((name) => input.issues.some((issue) => issue.path[0] === name));
149
- if (!invalid.length)
179
+ // each field's own message: checks of what the person typed,
180
+ // which say nothing about other accounts
181
+ const invalid = {};
182
+ for (const name of fields.names) {
183
+ const issue = input.issues.find((issue) => issue.path[0] === name);
184
+ if (issue)
185
+ invalid[name] = issue.message;
186
+ }
187
+ if (!Object.keys(invalid).length)
150
188
  throw new Issue("registration request");
151
189
  return c.json({ fields: invalid }, 422);
152
190
  }
@@ -155,6 +193,11 @@ export function configure(options, storage, state) {
155
193
  // The reserved bootstrap field is added to the validated application shape above.
156
194
  const data = input.data;
157
195
  const application = values(data);
196
+ // a public value already used, such as a username, is said before
197
+ // the passkey prompt, so no passkey is saved for a failed account
198
+ const used = await conflicts(application);
199
+ if (Object.keys(used).length)
200
+ return c.json({ fields: used }, 422);
158
201
  await Passkey.issue(c, state(c), data.bootstrap, {
159
202
  method: "register",
160
203
  action: paths.register,
@@ -173,16 +216,108 @@ export function configure(options, storage, state) {
173
216
  action: paths.login,
174
217
  });
175
218
  });
219
+ /** What a person calls a passkey they add, such as "Laptop" */
220
+ const naming = {
221
+ name: Field.text()
222
+ .max(64)
223
+ .optional()
224
+ .label("Name")
225
+ .hint("Such as the device it is on"),
226
+ };
227
+ const add = Route.post(paths.passkey)
228
+ .fields({ ...naming, ...Passkey.shape })
229
+ .use(guard("add"), async (c) => {
230
+ const input = await Issue.data(c);
231
+ if (!input || input.issues)
232
+ throw new Issue("passkey request");
233
+ const session = await state(c).session();
234
+ if (!session)
235
+ throw new Issue("session");
236
+ const credential = await new Passkey(c, state(c)).register();
237
+ // the account that started the ceremony is still the one signed in
238
+ if (credential.user !== session.user)
239
+ throw new Issue("user");
240
+ await storage
241
+ .register(() => { }, {
242
+ ...credential,
243
+ name: input.data.name?.trim() || null,
244
+ })
245
+ .catch((error) => {
246
+ // a passkey that is already an account's
247
+ if (Database.unique(error))
248
+ throw new Issue("passkey");
249
+ throw error;
250
+ });
251
+ c.redirect(returning(c), 303);
252
+ });
253
+ const adding = Route.post(`${paths.options}/add`)
254
+ // the form's own field is sent with it, and saved when it submits
255
+ .fields({ ...naming, bootstrap: Field.hidden() })
256
+ .use(guard("add", true), async (c) => {
257
+ const input = await Issue.data(c);
258
+ if (!input || input.issues)
259
+ throw new Issue("passkey request");
260
+ const session = await state(c).session();
261
+ // a passkey outlasts the session that adds it, so only a person
262
+ // who has just signed in adds one, not whoever holds an old session
263
+ if (!session || !(await state(c).recent(10 * Time.minute)))
264
+ return c.text("Sign in again to add a passkey.", 401);
265
+ const [[account], exclude] = await Promise.all([
266
+ options.database
267
+ .sql `SELECT * FROM ${users} WHERE ${users.columns.id} = ${session.user}`,
268
+ storage.credentials.list(session.user),
269
+ ]);
270
+ await Passkey.issue(c, state(c), input.data.bootstrap, {
271
+ method: "register",
272
+ action: paths.passkey,
273
+ name: name((account ?? {})),
274
+ user: session.user,
275
+ exclude,
276
+ });
277
+ });
278
+ /** The parameter of the authentication page a link's token is in */
279
+ const linked = "_link";
280
+ const link = Route.post(paths.link)
281
+ .fields({ link: Field.hidden() })
282
+ .use(guard("link"), async (c) => {
283
+ const input = await Issue.data(c);
284
+ if (!input || input.issues)
285
+ throw new Issue("link request");
286
+ // once, and only at the origin it was made for
287
+ const user = await storage.links.take(input.data.link, options.origin);
288
+ if (!user)
289
+ throw new Issue("link");
290
+ await enter(c, user);
291
+ });
176
292
  const routes = [
177
293
  register,
178
294
  login,
179
295
  logout,
296
+ add,
297
+ link,
180
298
  registration,
181
299
  assertion,
300
+ adding,
182
301
  Passkey.client,
183
302
  ];
184
303
  return {
185
304
  routes,
305
+ /** Make a link that signs a user in once, see `Auth.link`. */
306
+ async link(user, { origin = options.origin } = {}) {
307
+ const target = new URL(page, origin);
308
+ if (target.protocol !== "https:" || target.origin !== origin)
309
+ throw new TypeError("A link's origin must be an HTTPS origin");
310
+ const token = Token.random();
311
+ await storage.links.set(token, {
312
+ user,
313
+ origin,
314
+ // long enough to copy and open, and no longer: it signs in
315
+ // without a passkey
316
+ expiration: Date.now() + 5 * Time.minute,
317
+ });
318
+ target.searchParams.set(linked, token);
319
+ return target.href;
320
+ },
186
321
  /** Create forms in the handler before returning JSX, so ovr can set the binding cookie. */
187
322
  forms(c, props = {}) {
188
323
  const passkey = new Passkey(c, state(c));
@@ -212,17 +347,48 @@ export function configure(options, storage, state) {
212
347
  ? `Too many authentication requests. ${wait ? `Try again in ${wait} seconds.` : "Try again now."}${method === "register" ? " If you already registered, sign in." : ""}`
213
348
  : method === "register"
214
349
  ? "Registration could not be completed. If you already registered, sign in; otherwise try again."
215
- : "Authentication failed. Try again."
350
+ : method === "add"
351
+ ? "The passkey could not be added. Try again."
352
+ : method === "link"
353
+ ? "This link has expired or was already used."
354
+ : "Authentication failed. Try again."
216
355
  : undefined),
217
356
  });
357
+ // another passkey for the account signed in, such as on a new device
358
+ const Add = passkey.form(add, "register", {
359
+ ...props,
360
+ endpoint: adding.url(),
361
+ submit: "Add passkey",
362
+ });
218
363
  Register.Issue = error("register", Register.Issue);
219
364
  Login.Issue = error("login", Login.Issue);
365
+ Add.Issue = error("add", Add.Issue);
366
+ // a link's token, from the address the link opened
367
+ const token = c.url.searchParams.get(linked);
368
+ // the page's address holds the token, so it is sent to no other site
369
+ if (token)
370
+ c.res.headers.set("referrer-policy", "no-referrer");
371
+ const Link = Object.assign((props) => (token || failure === "link") &&
372
+ jsx(link.Form, {
373
+ ...props,
374
+ children: [
375
+ token && [
376
+ jsx("input", { type: "hidden", name: "link", value: token }),
377
+ props.children ?? jsx("button", { children: "Sign in" }),
378
+ ],
379
+ Link.Issue({}),
380
+ ],
381
+ }), {
382
+ Issue: error("link", (props) => jsx("p", { role: "status", "aria-live": "polite", ...props })),
383
+ });
220
384
  return {
221
385
  Register: Object.assign(Register, {
222
386
  Field: fields.Field,
223
387
  Fields: fields.Fields,
224
388
  }),
225
389
  Login,
390
+ Add,
391
+ Link,
226
392
  Logout: (props) => jsx(logout.Form, {
227
393
  ...props,
228
394
  children: props.children ?? jsx("button", { children: "Log out" }),
@@ -29,6 +29,21 @@ export declare namespace Auth {
29
29
  Login: Route.Form<string> & {
30
30
  Issue: (props: JSX.IntrinsicElements["p"]) => JSX.Element;
31
31
  };
32
+ /**
33
+ * Adds another passkey to the account signed in, such as on a new
34
+ * device. Pass `state={c.url}` to return to the page it is on.
35
+ */
36
+ Add: Route.Form<string> & {
37
+ Issue: (props: JSX.IntrinsicElements["p"]) => JSX.Element;
38
+ };
39
+ /**
40
+ * Signs in with a link from `auth.link`, on the authentication `page`
41
+ * the link opens. It is a button, so only a person uses the link, and
42
+ * renders nothing on a page opened without one.
43
+ */
44
+ Link: ((props: JSX.IntrinsicElements["form"]) => JSX.Element) & {
45
+ Issue: (props: JSX.IntrinsicElements["p"]) => JSX.Element;
46
+ };
32
47
  Logout: Route.Form<string>;
33
48
  }
34
49
  /** A revocable session with a fixed lifetime, from `c.session()`. */
@@ -152,6 +167,12 @@ export declare namespace Auth {
152
167
  eligible: boolean;
153
168
  /** Current backup state, which may change. */
154
169
  backedUp: boolean;
170
+ /** When it was made, in milliseconds. */
171
+ created: number;
172
+ /** Origin it was made at, the only one it signs in at. */
173
+ origin: string;
174
+ /** What the person called it when adding it, such as "Laptop". */
175
+ name: string | null;
155
176
  }
156
177
  export {};
157
178
  }
@@ -173,6 +194,9 @@ export declare class Auth<U extends Auth.Users = Auth.Users, P extends string =
173
194
  counter: Schema<number>;
174
195
  eligible: Schema<boolean>;
175
196
  backedUp: Schema<boolean>;
197
+ created: Schema<number>;
198
+ origin: Schema<string>;
199
+ name: Schema<string | null>;
176
200
  }, {}>, Table<"auth_sessions", {
177
201
  id: Schema<string>;
178
202
  user: Schema<string>;
@@ -204,6 +228,11 @@ export declare class Auth<U extends Auth.Users = Auth.Users, P extends string =
204
228
  challenge: Schema<string | null>;
205
229
  family: Schema<string>;
206
230
  expiration: Schema<number>;
231
+ }, {}>, Table<"auth_links", {
232
+ id: Schema<string>;
233
+ user: Schema<string>;
234
+ origin: Schema<string>;
235
+ expiration: Schema<number>;
207
236
  }, {}>];
208
237
  /**
209
238
  * Read an agent's authorization request on the consent page, with the form
@@ -216,6 +245,25 @@ export declare class Auth<U extends Auth.Users = Auth.Users, P extends string =
216
245
  readonly forms: (c: Auth.Context, props?: {
217
246
  nonce?: string;
218
247
  }) => Auth.Forms<Auth.Fields<U>>;
248
+ /**
249
+ * Make a link that signs a user in once, for when they have no passkey
250
+ * where they need one: at another origin that shares the users table,
251
+ * such as production after registering on `localhost`, or after losing
252
+ * their device. It opens the authentication `page`, where `<Link />` from
253
+ * `auth.forms(c)` signs them in, and they add a passkey.
254
+ *
255
+ * Anyone who has the link is the user until it is used or expires, so
256
+ * make one only for a user your code has already identified, and send it
257
+ * the way you would a password. It is best kept to a script or an admin
258
+ * page, not a form any signed-in user can use in production.
259
+ *
260
+ * @param user ID of the user it signs in
261
+ * @param options The origin it is opened at, this one by default
262
+ * @returns The link, which lasts 5 minutes
263
+ */
264
+ readonly link: (user: string, options?: {
265
+ origin?: string;
266
+ }) => Promise<string>;
219
267
  /** Configure passkeys, session helpers, and automatic authentication rate limits. */
220
268
  constructor(options: Auth.Options<U, P, R, C>);
221
269
  /** Mounted by `app.use(auth)`, and lets every request read its session. */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,KAAK,OAAO,IAAI,WAAW,EAAY,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,KAAK,QAAQ,EAAc,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAQ/C,yBAAiB,IAAI,CAAC;IACrB,uCAAuC;IAEvC,qEAAqE;IACrE,MAAM,MAAM,OAAO,GAAG,IAAI,CACzB,WAAW,EACX,KAAK,GAAG,QAAQ,GAAG,KAAK,GAAG,WAAW,CACtC,GAAG;QAAE,IAAI,E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Z,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,KACzB,OAAO,CAAC,MAAM,CAAC,CAAC;IAErB,qFAAqF;IACrF,YAAY,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EA4D5C;IAED,2EAA2E;IAC3E,CAAC,KAAK,CAAC,IAAI,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,KAAK,CAAC,CAAC,CAQ/C;IAgCD,2JAA2J;IAC3J,QAAQ,CAAC,KAAK,MACV,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,GAAG,QAAQ,GAAG,KAAK,CAAC,QACzC,MAAM;;;;OAGX;IAEF,kFAAkF;IAClF,QAAQ,CAAC,MAAM,MAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,GAAG,QAAQ,GAAG,KAAK,CAAC,mBAEhE;IAEF;;;;;;;;OAQG;IACH,QAAQ,CAAC,UAAU,MACf,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,GAAG,QAAQ,GAAG,KAAK,CAAC,UACvC,MAAM,mBAKb;CACF"}
@@ -24,6 +24,7 @@ export class Auth {
24
24
  Storage.challenges,
25
25
  Limiter.table,
26
26
  Storage.tokens,
27
+ Storage.links,
27
28
  ];
28
29
  #options;
29
30
  #states = new WeakMap();
@@ -42,6 +43,23 @@ export class Auth {
42
43
  [agents];
43
44
  /** Prepare request-scoped UI in the handler before returning JSX. */
44
45
  forms;
46
+ /**
47
+ * Make a link that signs a user in once, for when they have no passkey
48
+ * where they need one: at another origin that shares the users table,
49
+ * such as production after registering on `localhost`, or after losing
50
+ * their device. It opens the authentication `page`, where `<Link />` from
51
+ * `auth.forms(c)` signs them in, and they add a passkey.
52
+ *
53
+ * Anyone who has the link is the user until it is used or expires, so
54
+ * make one only for a user your code has already identified, and send it
55
+ * the way you would a password. It is best kept to a script or an admin
56
+ * page, not a form any signed-in user can use in production.
57
+ *
58
+ * @param user ID of the user it signs in
59
+ * @param options The origin it is opened at, this one by default
60
+ * @returns The link, which lasts 5 minutes
61
+ */
62
+ link;
45
63
  /** Configure passkeys, session helpers, and automatic authentication rate limits. */
46
64
  constructor(options) {
47
65
  const origin = new URL(options.origin);
@@ -77,6 +95,7 @@ export class Auth {
77
95
  const signin = oauth(options, storage, (c) => this.#state(c), resources);
78
96
  this.#routes = service.routes;
79
97
  this.forms = service.forms;
98
+ this.link = service.link;
80
99
  this.consent = signin.consent;
81
100
  this[agents] = {
82
101
  origin: options.origin,
@@ -32,6 +32,8 @@ export declare namespace Passkey {
32
32
  readonly nonce?: string;
33
33
  /** Form fields the ceremony is for, from `Passkey.fields`, checked when it starts. */
34
34
  readonly fields?: string;
35
+ /** Text of the form's own button, in place of the method's. */
36
+ readonly submit?: string;
35
37
  }
36
38
  /** The ceremony a signed form may start. */
37
39
  type Expected = {
@@ -43,6 +45,10 @@ export declare namespace Passkey {
43
45
  method: "register";
44
46
  /** Name of the new passkey, at most 256 characters, not blank */
45
47
  name: string;
48
+ /** The account the passkey is added to, a new account without it */
49
+ user?: string;
50
+ /** Credential IDs the account has, which the authenticator skips */
51
+ exclude?: readonly string[];
46
52
  } | {
47
53
  method: "login";
48
54
  /** Credential IDs a login is limited to, for a user already known */
@@ -54,8 +60,8 @@ export declare class Passkey {
54
60
  #private;
55
61
  /** Hidden fields the browser module fills, added to each ceremony route's own */
56
62
  static readonly shape: {
57
- credential: Field.Instance<unknown, "input", "hidden", undefined, undefined>;
58
- ceremony: Field.Instance<string, "input", "hidden", undefined, undefined>;
63
+ credential: Field.Instance<unknown, "input", "hidden", undefined, undefined, undefined>;
64
+ ceremony: Field.Instance<string, "input", "hidden", undefined, undefined, undefined>;
59
65
  };
60
66
  /** Create request-scoped passkey helpers. */
61
67
  constructor(c: Auth.Context, auth: State);
@@ -79,6 +85,9 @@ export declare class Passkey {
79
85
  counter: number;
80
86
  eligible: boolean;
81
87
  backedUp: boolean;
88
+ created: number;
89
+ origin: string;
90
+ name: string | null;
82
91
  }>;
83
92
  /**
84
93
  * Verify login and atomically update the credential.
@@ -96,6 +105,9 @@ export declare class Passkey {
96
105
  user: string;
97
106
  publicKey: string;
98
107
  eligible: boolean;
108
+ created: number;
109
+ origin: string;
110
+ name: string | null;
99
111
  }>;
100
112
  }
101
113
  //# sourceMappingURL=passkey.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"passkey.d.ts","sourceRoot":"","sources":["../../src/auth/passkey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,KAAK,GAAG,EAAO,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAO1C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,yBAAiB,OAAO,CAAC;IACxB;;;;OAIG;IACH,KAAY,SAAS,CAAC,OAAO,SAAS,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG;QACrE,KAAK,EAAE,CAAC,KAAK,EAAE,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC;KAC1D,CAAC;IACF;;;;OAIG;IACH,UAAiB,IAAI,CAAC,OAAO,SAAS,MAAM,CAAE,SAAQ,IAAI,CACzD,KAAK,CAAC,IAAI,EACV,QAAQ,CACR;QACA,OAAO,EAAE,OAAO,CAAC;QACjB,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1B,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC,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