import{S as be,i as _e,s as ve,W as ge,X as V,h as d,j as T,z as R,c as x,k as g,n as b,o as s,m as ee,H as ce,Y as de,Z as je,E as ue,_ as Qe,G as he,t as E,a as j,v as _,d as te,J as ke,l as J,q as $e,V as ze,$ as Me,p as Ge,a0 as Be}from"./index-CUlXN_4f.js";import{F as Ke}from"./FieldsQueryParam-CluSqIw-.js";function De(a,t,e){const l=a.slice();return l[4]=t[e],l}function Ie(a,t,e){const l=a.slice();return l[4]=t[e],l}function We(a,t){let e,l=t[4].code+"",h,i,c,n;function m(){return t[3](t[4])}return{key:a,first:null,c(){e=d("button"),h=R(l),i=T(),g(e,"class","tab-item"),J(e,"active",t[1]===t[4].code),this.first=e},m(v,C){b(v,e,C),s(e,h),s(e,i),c||(n=$e(e,"click",m),c=!0)},p(v,C){t=v,C&4&&l!==(l=t[4].code+"")&&ce(h,l),C&6&&J(e,"active",t[1]===t[4].code)},d(v){v&&_(e),c=!1,n()}}}function Fe(a,t){let e,l,h,i;return l=new ge({props:{content:t[4].body}}),{key:a,first:null,c(){e=d("div"),x(l.$$.fragment),h=T(),g(e,"class","tab-item"),J(e,"active",t[1]===t[4].code),this.first=e},m(c,n){b(c,e,n),ee(l,e,null),s(e,h),i=!0},p(c,n){t=c;const m={};n&4&&(m.content=t[4].body),l.$set(m),(!i||n&6)&&J(e,"active",t[1]===t[4].code)},i(c){i||(E(l.$$.fragment,c),i=!0)},o(c){j(l.$$.fragment,c),i=!1},d(c){c&&_(e),te(l)}}}function Xe(a){let t,e,l,h,i,c,n,m=a[0].name+"",v,C,F,D,I,M,Q,B,H,y,O,q,k,L,Y,A,G,N,o,$,P,X,u,p,S,w,K,we,Te,Pe,pe,Oe,ye,le,fe,oe,me,Z,ae,z=[],Se=new Map,qe,ne,U=[],Ce=new Map,se;P=new ge({props:{content:"?expand=relField1,relField2.subRelField"}}),le=new Ke({props:{prefix:"record."}});let re=V(a[2]);const Ae=r=>r[4].code;for(let r=0;rr[4].code;for(let r=0;rParam Type Description
Required otpId
String The id of the OTP request.
Required password
String The one-time password.',Q=T(),B=d("div"),B.textContent="Query parameters",H=T(),y=d("table"),O=d("thead"),O.innerHTML='Param Type Description',q=T(),k=d("tbody"),L=d("tr"),Y=d("td"),Y.textContent="expand",A=T(),G=d("td"),G.innerHTML='String',N=T(),o=d("td"),$=R(`Auto expand record relations. Ex.: `),x(P.$$.fragment),X=R(` Supports up to 6-levels depth nested relations expansion. `),u=d("br"),p=R(` The expanded relations will be appended to the record under the `),S=d("code"),S.textContent="expand",w=R(" property (eg. "),K=d("code"),K.textContent='"expand": {"relField1": {...}, ...}',we=R(`). `),Te=d("br"),Pe=R(` Only the relations to which the request user has permissions to `),pe=d("strong"),pe.textContent="view",Oe=R(" will be expanded."),ye=T(),x(le.$$.fragment),fe=T(),oe=d("div"),oe.textContent="Responses",me=T(),Z=d("div"),ae=d("div");for(let r=0;re(1,h=n.code);return a.$$set=n=>{"collection"in n&&e(0,l=n.collection)},a.$$.update=()=>{a.$$.dirty&1&&e(2,i=[{code:200,body:JSON.stringify({token:"JWT_TOKEN",record:ke.dummyCollectionRecord(l)},null,2)},{code:400,body:` { "status": 400, "message": "Failed to authenticate.", "data": { "otpId": { "code": "validation_required", "message": "Missing required value." } } } `}])},[l,h,i,c]}class xe extends be{constructor(t){super(),_e(this,t,Ze,Xe,ve,{collection:0})}}function He(a,t,e){const l=a.slice();return l[4]=t[e],l}function Ue(a,t,e){const l=a.slice();return l[4]=t[e],l}function Le(a,t){let e,l=t[4].code+"",h,i,c,n;function m(){return t[3](t[4])}return{key:a,first:null,c(){e=d("button"),h=R(l),i=T(),g(e,"class","tab-item"),J(e,"active",t[1]===t[4].code),this.first=e},m(v,C){b(v,e,C),s(e,h),s(e,i),c||(n=$e(e,"click",m),c=!0)},p(v,C){t=v,C&4&&l!==(l=t[4].code+"")&&ce(h,l),C&6&&J(e,"active",t[1]===t[4].code)},d(v){v&&_(e),c=!1,n()}}}function Ye(a,t){let e,l,h,i;return l=new ge({props:{content:t[4].body}}),{key:a,first:null,c(){e=d("div"),x(l.$$.fragment),h=T(),g(e,"class","tab-item"),J(e,"active",t[1]===t[4].code),this.first=e},m(c,n){b(c,e,n),ee(l,e,null),s(e,h),i=!0},p(c,n){t=c;const m={};n&4&&(m.content=t[4].body),l.$set(m),(!i||n&6)&&J(e,"active",t[1]===t[4].code)},i(c){i||(E(l.$$.fragment,c),i=!0)},o(c){j(l.$$.fragment,c),i=!1},d(c){c&&_(e),te(l)}}}function et(a){let t,e,l,h,i,c,n,m=a[0].name+"",v,C,F,D,I,M,Q,B,H,y,O,q=[],k=new Map,L,Y,A=[],G=new Map,N,o=V(a[2]);const $=u=>u[4].code;for(let u=0;uu[4].code;for(let u=0;uParam Type Description
Required email
String The auth record email address to send the OTP request (if exists).',Q=T(),B=d("div"),B.textContent="Responses",H=T(),y=d("div"),O=d("div");for(let u=0;ue(1,h=n.code);return a.$$set=n=>{"collection"in n&&e(0,l=n.collection)},e(2,i=[{code:200,body:JSON.stringify({otpId:ke.randomString(15)},null,2)},{code:400,body:` { "status": 400, "message": "An error occurred while validating the submitted data.", "data": { "email": { "code": "validation_is_email", "message": "Must be a valid email address." } } } `},{code:429,body:` { "status": 429, "message": "You've send too many OTP requests, please try again later.", "data": {} } `}]),[l,h,i,c]}class lt extends be{constructor(t){super(),_e(this,t,tt,et,ve,{collection:0})}}function Ve(a,t,e){const l=a.slice();return l[5]=t[e],l[7]=e,l}function Ee(a,t,e){const l=a.slice();return l[5]=t[e],l[7]=e,l}function Je(a){let t,e,l,h,i;function c(){return a[4](a[7])}return{c(){t=d("button"),e=d("div"),e.textContent=`${a[5].title}`,l=T(),g(e,"class","txt"),g(t,"class","tab-item"),J(t,"active",a[1]==a[7])},m(n,m){b(n,t,m),s(t,e),s(t,l),h||(i=$e(t,"click",c),h=!0)},p(n,m){a=n,m&2&&J(t,"active",a[1]==a[7])},d(n){n&&_(t),h=!1,i()}}}function Ne(a){let t,e,l,h;var i=a[5].component;function c(n,m){return{props:{collection:n[0]}}}return i&&(e=Be(i,c(a))),{c(){t=d("div"),e&&x(e.$$.fragment),l=T(),g(t,"class","tab-item"),J(t,"active",a[1]==a[7])},m(n,m){b(n,t,m),e&&ee(e,t,null),s(t,l),h=!0},p(n,m){if(i!==(i=n[5].component)){if(e){ue();const v=e;j(v.$$.fragment,1,0,()=>{te(v,1)}),he()}i?(e=Be(i,c(n)),x(e.$$.fragment),E(e.$$.fragment,1),ee(e,t,l)):e=null}else if(i){const v={};m&1&&(v.collection=n[0]),e.$set(v)}(!h||m&2)&&J(t,"active",n[1]==n[7])},i(n){h||(e&&E(e.$$.fragment,n),h=!0)},o(n){e&&j(e.$$.fragment,n),h=!1},d(n){n&&_(t),e&&te(e)}}}function ot(a){var Y,A,G,N;let t,e,l=a[0].name+"",h,i,c,n,m,v,C,F,D,I,M,Q,B,H;v=new ze({props:{js:` import PocketBase from 'pocketbase'; const pb = new PocketBase('${a[2]}'); ... // send OTP email to the provided auth record const req = await pb.collection('${(Y=a[0])==null?void 0:Y.name}').requestOTP('test@example.com'); // ... show a screen/popup to enter the password from the email ... // authenticate with the requested OTP id and the email password const authData = await pb.collection('${(A=a[0])==null?void 0:A.name}').authWithOTP( req.otpId, "YOUR_OTP", ); // after the above you can also access the auth data from the authStore console.log(pb.authStore.isValid); console.log(pb.authStore.token); console.log(pb.authStore.record.id); // "logout" pb.authStore.clear(); `,dart:` import 'package:pocketbase/pocketbase.dart'; final pb = PocketBase('${a[2]}'); ... // send OTP email to the provided auth record final req = await pb.collection('${(G=a[0])==null?void 0:G.name}').requestOTP('test@example.com'); // ... show a screen/popup to enter the password from the email ... // authenticate with the requested OTP id and the email password final authData = await pb.collection('${(N=a[0])==null?void 0:N.name}').authWithOTP( req.otpId, "YOUR_OTP", ); // after the above you can also access the auth data from the authStore print(pb.authStore.isValid); print(pb.authStore.token); print(pb.authStore.record.id); // "logout" pb.authStore.clear(); `}});let y=V(a[3]),O=[];for(let o=0;oj(k[o],1,1,()=>{k[o]=null});return{c(){t=d("h3"),e=R("Auth with OTP ("),h=R(l),i=R(")"),c=T(),n=d("div"),n.innerHTML=`

Authenticate with an one-time password (OTP).

Note that when requesting an OTP we return an otpId even if a user with the provided email doesn't exist as a very basic enumeration protection.

`,m=T(),x(v.$$.fragment),C=T(),F=d("h6"),F.textContent="API details",D=T(),I=d("div"),M=d("div");for(let o=0;oe(1,c=m);return a.$$set=m=>{"collection"in m&&e(0,h=m.collection)},e(2,l=ke.getApiExampleUrl(Ge.baseURL)),[h,c,l,i,n]}class it extends be{constructor(t){super(),_e(this,t,at,ot,ve,{collection:0})}}export{it as default};