2023-07-22 18:50:40 +03:00
import { S as Ve , i as Le , s as Ee , M as je , e as s , w as k , b as h , c as z , f as p , g as r , h as a , m as I , x as he , N as xe , P as Je , k as Ne , Q as Qe , n as ze , t as V , a as L , o as c , d as K , T as Ie , C as We , p as Ke , r as G , u as Ge } from "./index-1097b3a4.js" ; import { S as Xe } from "./SdkTabs-cc2b5912.js" ; import { F as Ye } from "./FieldsQueryParam-b7007fe9.js" ; function Ue ( i , l , o ) { const n = i . slice ( ) ; return n [ 5 ] = l [ o ] , n } function Be ( i , l , o ) { const n = i . slice ( ) ; return n [ 5 ] = l [ o ] , n } function Fe ( i , l ) { let o , n = l [ 5 ] . code + "" , m , g , u , b ; function _ ( ) { return l [ 4 ] ( l [ 5 ] ) } return { key : i , first : null , c ( ) { o = s ( "button" ) , m = k ( n ) , g = h ( ) , p ( o , "class" , "tab-item" ) , G ( o , "active" , l [ 1 ] === l [ 5 ] . code ) , this . first = o } , m ( v , A ) { r ( v , o , A ) , a ( o , m ) , a ( o , g ) , u || ( b = Ge ( o , "click" , _ ) , u = ! 0 ) } , p ( v , A ) { l = v , A & 4 && n !== ( n = l [ 5 ] . code + "" ) && he ( m , n ) , A & 6 && G ( o , "active" , l [ 1 ] === l [ 5 ] . code ) } , d ( v ) { v && c ( o ) , u = ! 1 , b ( ) } } } function He ( i , l ) { let o , n , m , g ; return n = new je ( { props : { content : l [ 5 ] . body } } ) , { key : i , first : null , c ( ) { o = s ( "div" ) , z ( n . $$ . fragment ) , m = h ( ) , p ( o , "class" , "tab-item" ) , G ( o , "active" , l [ 1 ] === l [ 5 ] . code ) , this . first = o } , m ( u , b ) { r ( u , o , b ) , I ( n , o , null ) , a ( o , m ) , g = ! 0 } , p ( u , b ) { l = u ; const _ = { } ; b & 4 && ( _ . content = l [ 5 ] . body ) , n . $set ( _ ) , ( ! g || b & 6 ) && G ( o , "active" , l [ 1 ] === l [ 5 ] . code ) } , i ( u ) { g || ( V ( n . $$ . fragment , u ) , g = ! 0 ) } , o ( u ) { L ( n . $$ . fragment , u ) , g = ! 1 } , d ( u ) { u && c ( o ) , K ( n ) } } } function Ze ( i ) { let l , o , n = i [ 0 ] . name + "" , m , g , u , b , _ , v , A , P , X , S , E , pe , J , M , be , Y , N = i [ 0 ] . name + "" , Z , fe , ee , R , te , x , ae , W , le , y , oe , me , U , $ , se , ge , ne , ke , f , _e , C , ve , we , Oe , ie , Ae , re , Se , ye , $e , ce , Te , Ce , q , ue , B , de , T , F , O = [ ] , qe = new Map , De , H , w = [ ] , Pe = new Map , D ; v = new Xe ( { props : { js : `
2023-04-17 20:59:04 +03:00
import PocketBase from 'pocketbase' ;
const pb = new PocketBase ( '${i[3]}' ) ;
...
// OAuth2 authentication with a single realtime call.
//
// Make sure to register ${i[3]}/api/oauth2-redirect as redirect url.
const authData = await pb . collection ( 'users' ) . authWithOAuth2 ( { provider : 'google' } ) ;
// OR authenticate with manual OAuth2 code exchange
// const authData = await pb.collection('users').authWithOAuth2Code(...);
// 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 . model . id ) ;
// "logout" the last authenticated model
pb . authStore . clear ( ) ;
` ,dart: `
import 'package:pocketbase/pocketbase.dart' ;
import 'package:url_launcher/url_launcher.dart' ;
final pb = PocketBase ( '${i[3]}' ) ;
...
// OAuth2 authentication with a single realtime call.
//
// Make sure to register ${i[3]}/api/oauth2-redirect as redirect url.
final authData = await pb . collection ( 'users' ) . authWithOAuth2 ( 'google' , ( url ) async {
await launchUrl ( url ) ;
} ) ;
// OR authenticate with manual OAuth2 code exchange
// final authData = await pb.collection('users').authWithOAuth2Code(...);
// after the above you can also access the auth data from the authStore
print ( pb . authStore . isValid ) ;
print ( pb . authStore . token ) ;
print ( pb . authStore . model . id ) ;
// "logout" the last authenticated model
pb . authStore . clear ( ) ;
2023-05-20 05:58:52 +03:00
` }}),C=new je({props:{content:"?expand=relField1,relField2.subRelField"}}),q=new Ye({});let Q=i[2];const Me=e=>e[5].code;for(let e=0;e<Q.length;e+=1){let t=Be(i,Q,e),d=Me(t);qe.set(d,O[e]=Fe(d,t))}let j=i[2];const Re=e=>e[5].code;for(let e=0;e<j.length;e+=1){let t=Ue(i,j,e),d=Re(t);Pe.set(d,w[e]=He(d,t))}return{c(){l=s("h3"),o=k("Auth with OAuth2 ("),m=k(n),g=k(")"),u=h(),b=s("div"),b.innerHTML= ` < p > Authenticate with an OAuth2 provider and returns a new auth token and record data . < / p >
2023-04-17 20:59:04 +03:00
< p > For more details please check the
< a href = "https://pocketbase.io/docs/authentication/#oauth2-integration" target = "_blank" rel = "noopener noreferrer" > OAuth2 integration documentation
2023-05-20 05:58:52 +03:00
< / a > . < / p > ` , _ = h ( ) , z ( v . $ $ . f r a g m e n t ) , A = h ( ) , P = s ( " h 6 " ) , P . t e x t C o n t e n t = " A P I d e t a i l s " , X = h ( ) , S = s ( " d i v " ) , E = s ( " s t r o n g " ) , E . t e x t C o n t e n t = " P O S T " , p e = h ( ) , J = s ( " d i v " ) , M = s ( " p " ) , b e = k ( " / a p i / c o l l e c t i o n s / " ) , Y = s ( " s t r o n g " ) , Z = k ( N ) , f e = k ( " / a u t h - w i t h - o a u t h 2 " ) , e e = h ( ) , R = s ( " d i v " ) , R . t e x t C o n t e n t = " B o d y P a r a m e t e r s " , t e = h ( ) , x = s ( " t a b l e " ) , x . i n n e r H T M L = ` < t h e a d > < t r > < t h > P a r a m < / t h >
2023-04-17 20:59:04 +03:00
< th > Type < / t h >
< th width = "50%" > Description < / t h > < / t r > < / t h e a d >
< tbody > < tr > < td > < div class = "inline-flex" > < span class = "label label-success" > Required < / s p a n >
< span > provider < / s p a n > < / d i v > < / t d >
< td > < span class = "label" > String < / s p a n > < / t d >
< td > The name of the OAuth2 client provider ( eg . & quot ; google & quot ; ) . < / t d > < / t r >
< tr > < td > < div class = "inline-flex" > < span class = "label label-success" > Required < / s p a n >
< span > code < / s p a n > < / d i v > < / t d >
< td > < span class = "label" > String < / s p a n > < / t d >
< td > The authorization code returned from the initial request . < / t d > < / t r >
< tr > < td > < div class = "inline-flex" > < span class = "label label-success" > Required < / s p a n >
< span > codeVerifier < / s p a n > < / d i v > < / t d >
< td > < span class = "label" > String < / s p a n > < / t d >
< td > The code verifier sent with the initial request as part of the code _challenge . < / t d > < / t r >
< tr > < td > < div class = "inline-flex" > < span class = "label label-success" > Required < / s p a n >
< span > redirectUrl < / s p a n > < / d i v > < / t d >
< td > < span class = "label" > String < / s p a n > < / t d >
< td > The redirect url sent with the initial request . < / t d > < / t r >
< tr > < td > < div class = "inline-flex" > < span class = "label label-warning" > Optional < / s p a n >
< span > createData < / s p a n > < / d i v > < / t d >
< td > < span class = "label" > Object < / s p a n > < / t d >
< td > < p > Optional data that will be used when creating the auth record on OAuth2 sign - up . < / p >
< p > The created auth record must comply with the same requirements and validations in the
regular < strong > create < / s t r o n g > a c t i o n .
< br / >
< em > The data can only be in < code > json < / c o d e > , a k a . < c o d e > m u l t i p a r t / f o r m - d a t a < / c o d e > a n d f i l e s
2023-05-20 05:58:52 +03:00
upload currently are not supported during OAuth2 sign - ups . < / e m > < / p > < / t d > < / t r > < / t b o d y > ` , a e = h ( ) , W = s ( " d i v " ) , W . t e x t C o n t e n t = " Q u e r y p a r a m e t e r s " , l e = h ( ) , y = s ( " t a b l e " ) , o e = s ( " t h e a d " ) , o e . i n n e r H T M L = ` < t r > < t h > P a r a m < / t h >
2023-04-17 20:59:04 +03:00
< th > Type < / t h >
2023-05-20 05:58:52 +03:00
< th width = "60%" > Description < / t h > < / t r > ` , m e = h ( ) , U = s ( " t b o d y " ) , $ = s ( " t r " ) , s e = s ( " t d " ) , s e . t e x t C o n t e n t = " e x p a n d " , g e = h ( ) , n e = s ( " t d " ) , n e . i n n e r H T M L = ' < s p a n c l a s s = " l a b e l " > S t r i n g < / s p a n > ' , k e = h ( ) , f = s ( " t d " ) , _ e = k ( ` A u t o e x p a n d r e c o r d r e l a t i o n s . E x . :
` ),z(C. $ $ .fragment),ve=k( `
Supports up to 6 - levels depth nested relations expansion . ` ),we=s("br"),Oe=k( `
2023-04-17 20:59:04 +03:00
The expanded relations will be appended to the record under the
2023-05-20 05:58:52 +03:00
` ),ie=s("code"),ie.textContent="expand",Ae=k(" property (eg. "),re=s("code"),re.textContent='"expand": {"relField1": {...}, ...}',Se=k( ` ) .
` ),ye=s("br"), $ e=k( `
Only the relations to which the request user has permissions to ` ),ce=s("strong"),ce.textContent="view",Te=k(" will be expanded."),Ce=h(),z(q. $ $ .fragment),ue=h(),B=s("div"),B.textContent="Responses",de=h(),T=s("div"),F=s("div");for(let e=0;e<O.length;e+=1)O[e].c();De=h(),H=s("div");for(let e=0;e<w.length;e+=1)w[e].c();p(l,"class","m-b-sm"),p(b,"class","content txt-lg m-b-sm"),p(P,"class","m-b-xs"),p(E,"class","label label-primary"),p(J,"class","content"),p(S,"class","alert alert-success"),p(R,"class","section-title"),p(x,"class","table-compact table-border m-b-base"),p(W,"class","section-title"),p(y,"class","table-compact table-border m-b-base"),p(B,"class","section-title"),p(F,"class","tabs-header compact left"),p(H,"class","tabs-content"),p(T,"class","tabs")},m(e,t){r(e,l,t),a(l,o),a(l,m),a(l,g),r(e,u,t),r(e,b,t),r(e,_,t),I(v,e,t),r(e,A,t),r(e,P,t),r(e,X,t),r(e,S,t),a(S,E),a(S,pe),a(S,J),a(J,M),a(M,be),a(M,Y),a(Y,Z),a(M,fe),r(e,ee,t),r(e,R,t),r(e,te,t),r(e,x,t),r(e,ae,t),r(e,W,t),r(e,le,t),r(e,y,t),a(y,oe),a(y,me),a(y,U),a(U, $ ),a( $ ,se),a( $ ,ge),a( $ ,ne),a( $ ,ke),a( $ ,f),a(f,_e),I(C,f,null),a(f,ve),a(f,we),a(f,Oe),a(f,ie),a(f,Ae),a(f,re),a(f,Se),a(f,ye),a(f, $ e),a(f,ce),a(f,Te),a(U,Ce),I(q,U,null),r(e,ue,t),r(e,B,t),r(e,de,t),r(e,T,t),a(T,F);for(let d=0;d<O.length;d+=1)O[d]&&O[d].m(F,null);a(T,De),a(T,H);for(let d=0;d<w.length;d+=1)w[d]&&w[d].m(H,null);D=!0},p(e,[t]){(!D||t&1)&&n!==(n=e[0].name+"")&&he(m,n);const d={};t&8&&(d.js= `
2023-04-17 20:59:04 +03:00
import PocketBase from 'pocketbase' ;
const pb = new PocketBase ( '${e[3]}' ) ;
...
// OAuth2 authentication with a single realtime call.
//
// Make sure to register ${e[3]}/api/oauth2-redirect as redirect url.
const authData = await pb . collection ( 'users' ) . authWithOAuth2 ( { provider : 'google' } ) ;
// OR authenticate with manual OAuth2 code exchange
// const authData = await pb.collection('users').authWithOAuth2Code(...);
// 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 . model . id ) ;
// "logout" the last authenticated model
pb . authStore . clear ( ) ;
` ),t&8&&(d.dart= `
import 'package:pocketbase/pocketbase.dart' ;
import 'package:url_launcher/url_launcher.dart' ;
final pb = PocketBase ( '${e[3]}' ) ;
...
// OAuth2 authentication with a single realtime call.
//
// Make sure to register ${e[3]}/api/oauth2-redirect as redirect url.
final authData = await pb . collection ( 'users' ) . authWithOAuth2 ( 'google' , ( url ) async {
await launchUrl ( url ) ;
} ) ;
// OR authenticate with manual OAuth2 code exchange
// final authData = await pb.collection('users').authWithOAuth2Code(...);
// after the above you can also access the auth data from the authStore
print ( pb . authStore . isValid ) ;
print ( pb . authStore . token ) ;
print ( pb . authStore . model . id ) ;
// "logout" the last authenticated model
pb . authStore . clear ( ) ;
2023-05-20 05:58:52 +03:00
` ),v. $ set(d),(!D||t&1)&&N!==(N=e[0].name+"")&&he(Z,N),t&6&&(Q=e[2],O=xe(O,t,Me,1,e,Q,qe,F,Je,Fe,null,Be)),t&6&&(j=e[2],Ne(),w=xe(w,t,Re,1,e,j,Pe,H,Qe,He,null,Ue),ze())},i(e){if(!D){V(v. $ $ .fragment,e),V(C. $ $ .fragment,e),V(q. $ $ .fragment,e);for(let t=0;t<j.length;t+=1)V(w[t]);D=!0}},o(e){L(v. $ $ .fragment,e),L(C. $ $ .fragment,e),L(q. $ $ .fragment,e);for(let t=0;t<w.length;t+=1)L(w[t]);D=!1},d(e){e&&c(l),e&&c(u),e&&c(b),e&&c(_),K(v,e),e&&c(A),e&&c(P),e&&c(X),e&&c(S),e&&c(ee),e&&c(R),e&&c(te),e&&c(x),e&&c(ae),e&&c(W),e&&c(le),e&&c(y),K(C),K(q),e&&c(ue),e&&c(B),e&&c(de),e&&c(T);for(let t=0;t<O.length;t+=1)O[t].d();for(let t=0;t<w.length;t+=1)w[t].d()}}}function et(i,l,o){let n,{collection:m=new Ie}=l,g=200,u=[];const b=_=>o(1,g=_.code);return i. $ $ set=_=>{"collection"in _&&o(0,m=_.collection)},i. $ $ .update=()=>{i. $ $ .dirty&1&&o(2,u=[{code:200,body:JSON.stringify({token:"JWT_AUTH_TOKEN",record:We.dummyCollectionRecord(m),meta:{id:"abc123",name:"John Doe",username:"john.doe",email:"test@example.com",avatarUrl:"https://example.com/avatar.png",accessToken:"...",refreshToken:"...",rawUser:{}}},null,2)},{code:400,body: `
2023-04-17 20:59:04 +03:00
{
"code" : 400 ,
"message" : "An error occurred while submitting the form." ,
"data" : {
"provider" : {
"code" : "validation_required" ,
"message" : "Missing required value."
}
}
}
2023-05-20 05:58:52 +03:00
` }])},o(3,n=We.getApiExampleUrl(Ke.baseUrl)),[m,g,u,n,b]}class ot extends Ve{constructor(l){super(),Le(this,l,et,Ze,Ee,{collection:0})}}export{ot as default};