ovr 7.0.0-next.20 → 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.
- package/CHANGELOG.md +6 -0
- package/dist/auth/client-source.d.ts +2 -2
- package/dist/auth/client-source.d.ts.map +1 -1
- package/dist/auth/client-source.js +2 -2
- package/dist/auth/client.d.ts.map +1 -1
- package/dist/auth/client.js +3 -0
- package/dist/auth/configure.d.ts.map +1 -1
- package/dist/auth/configure.js +4 -2
- package/dist/auth/state.d.ts +6 -0
- package/dist/auth/state.d.ts.map +1 -1
- package/dist/auth/state.js +14 -1
- package/package.json +1 -1
- package/src/auth/client-source.ts +2 -2
- package/src/auth/client.ts +3 -0
- package/src/auth/configure.ts +4 -1
- package/src/auth/state.ts +16 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# ovr
|
|
2
2
|
|
|
3
|
+
## 7.0.0-next.21
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- cdfc7de: Adding a passkey asks for a sign-in within the last ten minutes, in that browser. A passkey outlasts the session that adds it, so a session taken over later cannot make itself a permanent way in. The form says to sign in again.
|
|
8
|
+
|
|
3
9
|
## 7.0.0-next.20
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -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(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.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/\"
|
|
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,
|
|
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(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.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/\"
|
|
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,
|
|
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"}
|
package/dist/auth/client.js
CHANGED
|
@@ -106,6 +106,9 @@ export function listen(id, bootstrap, endpoint, method) {
|
|
|
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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../../src/auth/configure.ts"],"names":[],"mappings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E,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GACvB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;EAuF9B"}
|
package/dist/auth/configure.js
CHANGED
|
@@ -258,8 +258,10 @@ export function configure(options, storage, state) {
|
|
|
258
258
|
if (!input || input.issues)
|
|
259
259
|
throw new Issue("passkey request");
|
|
260
260
|
const session = await state(c).session();
|
|
261
|
-
|
|
262
|
-
|
|
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);
|
|
263
265
|
const [[account], exclude] = await Promise.all([
|
|
264
266
|
options.database
|
|
265
267
|
.sql `SELECT * FROM ${users} WHERE ${users.columns.id} = ${session.user}`,
|
package/dist/auth/state.d.ts
CHANGED
|
@@ -25,6 +25,12 @@ export declare class State {
|
|
|
25
25
|
browser(create?: boolean): string | undefined;
|
|
26
26
|
/** Read a non-expired, non-revoked session, renewing it while it is used. */
|
|
27
27
|
session(): Promise<ContextType.Session | null>;
|
|
28
|
+
/**
|
|
29
|
+
* @param within Milliseconds
|
|
30
|
+
* @returns `true` when the person signed in that recently, in this
|
|
31
|
+
* browser: what a session taken over later cannot say
|
|
32
|
+
*/
|
|
33
|
+
recent(within: number): Promise<boolean>;
|
|
28
34
|
/**
|
|
29
35
|
* Return to a local path after the next login, such as an agent's
|
|
30
36
|
* authorization request, or the page that sent the user to log in. Any
|
package/dist/auth/state.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/auth/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,IAAI,WAAW,EAAS,MAAM,qBAAqB,CAAC;AAEzE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,O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AAyE;AACzE,qBAAa,KAAK;;IAQjB,+CAA+C;IAC/C,QAAQ,CAAC,OAAO;;;;;;;MAAC;IAEjB,6DAA6D;IAC7D,YAAY,CAAC,EAAE,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EASnD;IAeD,oFAAoF;IACpF,OAAO,CAAC,MAAM,UAAQ,sBAQrB;IAiFD,6EAA6E;IAC7E,OAAO,wCAEN;IAKD;;;;OAIG;IACG,MAAM,CAAC,MAAM,EAAE,MAAM,oBAG1B;IAED;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,QAMpB;IAED;;;OAGG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,UAQtB;IA0BD,yEAAyE;IACnE,KAAK,CAAC,IAAI,EAAE,MAAM;;;;OAqBvB;IAED,kFAAkF;IAC5E,MAAM,kBAOX;CACD"}
|
package/dist/auth/state.js
CHANGED
|
@@ -92,8 +92,10 @@ export class State {
|
|
|
92
92
|
if (session &&
|
|
93
93
|
session.id === id &&
|
|
94
94
|
session.expiration > now &&
|
|
95
|
-
session.started + this.options.lifetime > now)
|
|
95
|
+
session.started + this.options.lifetime > now) {
|
|
96
|
+
this.#started = session.started;
|
|
96
97
|
return this.#renew(session, now);
|
|
98
|
+
}
|
|
97
99
|
this.#clear();
|
|
98
100
|
return null;
|
|
99
101
|
}
|
|
@@ -122,6 +124,17 @@ export class State {
|
|
|
122
124
|
session() {
|
|
123
125
|
return (this.#session ??= this.#read());
|
|
124
126
|
}
|
|
127
|
+
/** When the browser's session signed in, once it is read */
|
|
128
|
+
#started;
|
|
129
|
+
/**
|
|
130
|
+
* @param within Milliseconds
|
|
131
|
+
* @returns `true` when the person signed in that recently, in this
|
|
132
|
+
* browser: what a session taken over later cannot say
|
|
133
|
+
*/
|
|
134
|
+
async recent(within) {
|
|
135
|
+
await this.session();
|
|
136
|
+
return this.#started !== undefined && Date.now() - this.#started <= within;
|
|
137
|
+
}
|
|
125
138
|
/**
|
|
126
139
|
* Return to a local path after the next login, such as an agent's
|
|
127
140
|
* authorization request, or the page that sent the user to log in. Any
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ovr",
|
|
3
3
|
"description": "Web apps anyone can use. Each route serves people a page and agents Markdown and MCP tools, with forms, Postgres, and passkey sign-in built in.",
|
|
4
|
-
"version": "7.0.0-next.
|
|
4
|
+
"version": "7.0.0-next.21",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -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(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.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/\"
|
|
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\"";
|
package/src/auth/client.ts
CHANGED
|
@@ -114,6 +114,9 @@ export function listen(
|
|
|
114
114
|
}
|
|
115
115
|
if (res.status === 410)
|
|
116
116
|
throw new Error("This page has expired. Reload and try again.");
|
|
117
|
+
// adding a passkey asks for a recent sign-in
|
|
118
|
+
if (res.status === 401)
|
|
119
|
+
throw new Error("Sign in again, then add the passkey.");
|
|
117
120
|
if (!res.ok)
|
|
118
121
|
throw new Error("Could not start the passkey request. Try again.");
|
|
119
122
|
|
package/src/auth/configure.ts
CHANGED
|
@@ -303,7 +303,10 @@ export function configure<U extends Auth.Users>(
|
|
|
303
303
|
const input = await Issue.data(c);
|
|
304
304
|
if (!input || input.issues) throw new Issue("passkey request");
|
|
305
305
|
const session = await state(c).session();
|
|
306
|
-
|
|
306
|
+
// a passkey outlasts the session that adds it, so only a person
|
|
307
|
+
// who has just signed in adds one, not whoever holds an old session
|
|
308
|
+
if (!session || !(await state(c).recent(10 * Time.minute)))
|
|
309
|
+
return c.text("Sign in again to add a passkey.", 401);
|
|
307
310
|
const [[account], exclude] = await Promise.all([
|
|
308
311
|
options.database
|
|
309
312
|
.sql`SELECT * FROM ${users} WHERE ${users.columns.id!} = ${session.user}`,
|
package/src/auth/state.ts
CHANGED
|
@@ -113,8 +113,10 @@ export class State {
|
|
|
113
113
|
session.id === id &&
|
|
114
114
|
session.expiration > now &&
|
|
115
115
|
session.started + this.options.lifetime > now
|
|
116
|
-
)
|
|
116
|
+
) {
|
|
117
|
+
this.#started = session.started;
|
|
117
118
|
return this.#renew(session, now);
|
|
119
|
+
}
|
|
118
120
|
this.#clear();
|
|
119
121
|
return null;
|
|
120
122
|
}
|
|
@@ -146,6 +148,19 @@ export class State {
|
|
|
146
148
|
return (this.#session ??= this.#read());
|
|
147
149
|
}
|
|
148
150
|
|
|
151
|
+
/** When the browser's session signed in, once it is read */
|
|
152
|
+
#started: number | undefined;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* @param within Milliseconds
|
|
156
|
+
* @returns `true` when the person signed in that recently, in this
|
|
157
|
+
* browser: what a session taken over later cannot say
|
|
158
|
+
*/
|
|
159
|
+
async recent(within: number) {
|
|
160
|
+
await this.session();
|
|
161
|
+
return this.#started !== undefined && Date.now() - this.#started <= within;
|
|
162
|
+
}
|
|
163
|
+
|
|
149
164
|
/**
|
|
150
165
|
* Return to a local path after the next login, such as an agent's
|
|
151
166
|
* authorization request, or the page that sent the user to log in. Any
|