@descope/vue-sdk 0.0.0-next-9f057a11-20230706 → 0.0.0-next-c146b936-20230712

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@descope/web-component"),s=require("vue"),o=require("@descope/web-js-sdk");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=r(e),n=r(o);const i=Symbol("$descope"),u={"x-descope-sdk-name":"vue","x-descope-sdk-version":"0.0.0-next-9f057a11-20230706"},a="undefined"!=typeof window,l=()=>{const e=s.inject(i);if(!e)throw Error("Missing Descope context, make sure you are using the Descope plugin");return e},c=()=>l().sdk;t.default.sdkConfigOverrides={baseHeaders:u};var d={name:"Descope",props:{flowId:{type:String,required:!0},tenant:{type:String},theme:{type:String},debug:{type:Boolean},telemetryKey:{type:String},redirectUrl:{type:String},autoFocus:{type:Boolean},errorTransformer:{type:Function}},emits:["success","error"],setup(e,{emit:s}){const{projectId:o,baseUrl:r,sessionTokenViaCookie:t}=l().options,n=c();return{projectId:o,baseUrl:r,sessionTokenViaCookie:t,onSuccess:async e=>{s("success",e),await(n.httpClient.hooks?.afterRequest?.({},new Response(JSON.stringify(e.detail))))},onError:e=>s("error",e)}},mounted(){this.$refs.webComponentRef.errorTransformer=this.errorTransformer}};const p=["project-id","base-url","flow-id","^theme","^tenant","^debug","^telemetryKey","redirect-url","auto-focus"];d.render=function(e,o,r,t,n,i){return s.openBlock(),s.createElementBlock("div",null,[s.createElementVNode("descope-wc",{"project-id":t.projectId,"base-url":t.baseUrl,"flow-id":r.flowId,"^theme":r.theme,"^tenant":r.tenant,"^debug":r.debug,"^telemetryKey":r.telemetryKey,"redirect-url":r.redirectUrl,"auto-focus":r.autoFocus,onSuccess:o[0]||(o[0]=(...e)=>t.onSuccess&&t.onSuccess(...e)),onError:o[1]||(o[1]=(...e)=>t.onError&&t.onError(...e)),ref:"webComponentRef"},null,40,p)])},d.__file="src/Descope.vue";const f=e=>(...s)=>{let o;try{o=e(...s)}catch(e){console.error(e)}return o};let v;const m=e=>{const s=n.default({...e,persistTokens:a,autoRefresh:a});return v=s,s};v=m({projectId:"temp pid"});const g=()=>a?v?.getSessionToken():(console.warn("Get session token is not supported in SSR"),""),y=f(((e=g(),s)=>v?.getJwtPermissions(e,s))),h=f(((e=g(),s)=>v?.getJwtRoles(e,s))),k=s.ref(null);let S;var w={install:function(e,o){const r=m({...o,persistTokens:!0,autoRefresh:!0,baseHeaders:u});S=r;const t=s.ref(null),n=s.ref(""),a=s.ref(null),l=s.ref(null);r.onSessionTokenChange((e=>{n.value=e})),r.onUserChange((e=>{l.value=e}));const c=async()=>{t.value=!0,await r.refresh(),t.value=!1},d=s.computed((()=>null===t.value)),p=s.computed((()=>null===a.value));k.value=async()=>(!n.value&&d.value&&await c(),!!s.unref(n)),e.provide(i,{session:{fetchSession:c,isLoading:s.readonly(t),session:s.readonly(n),isFetchSessionWasNeverCalled:d},user:{fetchUser:async()=>{a.value=!0,await r.me(),a.value=!1},isLoading:s.readonly(a),user:s.readonly(l),isFetchUserWasNeverCalled:p},sdk:r,options:o})}};exports.Descope=d,exports.default=w,exports.getJwtPermissions=y,exports.getJwtRoles=h,exports.getRefreshToken=()=>a?v?.getRefreshToken():(console.warn("Get refresh token is not supported in SSR"),""),exports.getSdk=()=>S,exports.getSessionToken=g,exports.routeGuard=()=>s.unref(k)?.(),exports.useDescope=c,exports.useSession=()=>{const{session:e}=l();return e.isFetchSessionWasNeverCalled.value&&e.fetchSession(),{isLoading:s.computed((()=>e.isLoading.value||e.isFetchSessionWasNeverCalled.value)),sessionToken:e.session,isAuthenticated:s.computed((()=>!!e.session.value))}},exports.useUser=()=>{const{user:e,session:o}=l(),r=()=>{!e.user.value&&o.session.value&&e.fetchUser()};return r(),s.watch(o.session,r),{isLoading:s.computed((()=>e.isLoading.value||e.isFetchUserWasNeverCalled.value)),user:e.user}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue"),s=require("@descope/web-component"),r=require("@descope/web-js-sdk");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=t(s),n=t(r);const u=Symbol("$descope"),a={"x-descope-sdk-name":"vue","x-descope-sdk-version":"0.0.0-next-c146b936-20230712"},i="undefined"!=typeof window,l=()=>{const s=e.inject(u);if(!s)throw Error("Missing Descope context, make sure you are using the Descope plugin");return s},c=()=>l().sdk,d=["project-id","base-url","flow-id","^theme","^tenant","^debug","^telemetryKey","redirect-url","auto-focus",".errorTransformer"];var p=e.defineComponent({__name:"Descope",props:{flowId:{type:String,required:!0},tenant:{type:String},theme:{type:String},debug:{type:Boolean},telemetryKey:{type:String},redirectUrl:{type:String},autoFocus:{type:Boolean},errorTransformer:{type:Function}},emits:["success","error"],setup(s,{emit:r}){o.default.sdkConfigOverrides={baseHeaders:a};const{projectId:t,baseUrl:n}=l().options,u=c(),i=async e=>{r("success",e),await(u.httpClient.hooks?.afterRequest?.({},new Response(JSON.stringify(e.detail))))},p=e=>r("error",e);return(r,o)=>(e.openBlock(),e.createElementBlock("div",null,[e.createElementVNode("descope-wc",{"project-id":e.unref(t),"base-url":e.unref(n),"flow-id":s.flowId,"^theme":s.theme,"^tenant":s.tenant,"^debug":s.debug,"^telemetryKey":s.telemetryKey,"redirect-url":s.redirectUrl,"auto-focus":s.autoFocus,".errorTransformer":s.errorTransformer,onSuccess:i,onError:p},null,40,d)]))}});p.__file="src/Descope.vue";const f=e=>(...s)=>{let r;try{r=e(...s)}catch(e){console.error(e)}return r};let v;const g=e=>{const s=n.default({...e,persistTokens:i,autoRefresh:i});return v=s,s};v=g({projectId:"temp pid"});const m=()=>i?v?.getSessionToken():(console.warn("Get session token is not supported in SSR"),""),y=f(((e=m(),s)=>v?.getJwtPermissions(e,s))),h=f(((e=m(),s)=>v?.getJwtRoles(e,s))),w=e.ref(null);let S;var k={install:function(s,r){const t=g({...r,persistTokens:!0,autoRefresh:!0,baseHeaders:a});S=t;const o=e.ref(null),n=e.ref(""),i=e.ref(null),l=e.ref(null);t.onSessionTokenChange((e=>{n.value=e})),t.onUserChange((e=>{l.value=e}));const c=async()=>{o.value=!0,await t.refresh(),o.value=!1},d=e.computed((()=>null===o.value)),p=e.computed((()=>null===i.value));w.value=async()=>(!n.value&&d.value&&await c(),!!e.unref(n)),s.provide(u,{session:{fetchSession:c,isLoading:e.readonly(o),session:e.readonly(n),isFetchSessionWasNeverCalled:d},user:{fetchUser:async()=>{i.value=!0,await t.me(),i.value=!1},isLoading:e.readonly(i),user:e.readonly(l),isFetchUserWasNeverCalled:p},sdk:t,options:r})}};exports.Descope=p,exports.default=k,exports.getJwtPermissions=y,exports.getJwtRoles=h,exports.getRefreshToken=()=>i?v?.getRefreshToken():(console.warn("Get refresh token is not supported in SSR"),""),exports.getSdk=()=>S,exports.getSessionToken=m,exports.routeGuard=()=>e.unref(w)?.(),exports.useDescope=c,exports.useSession=()=>{const{session:s}=l();return s.isFetchSessionWasNeverCalled.value&&s.fetchSession(),{isLoading:e.computed((()=>s.isLoading.value||s.isFetchSessionWasNeverCalled.value)),sessionToken:s.session,isAuthenticated:e.computed((()=>!!s.session.value))}},exports.useUser=()=>{const{user:s,session:r}=l(),t=()=>{!s.user.value&&r.session.value&&s.fetchUser()};return t(),e.watch(r.session,t),{isLoading:e.computed((()=>s.isLoading.value||s.isFetchUserWasNeverCalled.value)),user:s.user}};
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/Descope.vue?vue&type=template&id=8a031dec&lang.js"],"sourcesContent":["<template>\n\t<div>\n\t\t<descope-wc\n\t\t\t:project-id=\"projectId\"\n\t\t\t:base-url=\"baseUrl\"\n\t\t\t:flow-id=\"flowId\"\n\t\t\t:theme.attr=\"theme\"\n\t\t\t:tenant.attr=\"tenant\"\n\t\t\t:debug.attr=\"debug\"\n\t\t\t:telemetryKey.attr=\"telemetryKey\"\n\t\t\t:redirect-url=\"redirectUrl\"\n\t\t\t:auto-focus=\"autoFocus\"\n\t\t\t@success=\"onSuccess\"\n\t\t\t@error=\"onError\"\n\t\t\tref=\"webComponentRef\"\n\t\t/>\n\t</div>\n</template>\n\n<script lang=\"ts\">\nimport DescopeWc from '@descope/web-component';\nimport { useOptions, useDescope } from './hooks';\nimport { baseHeaders } from './constants';\nimport { RequestConfig } from '@descope/core-js-sdk';\nimport { SetupContext } from 'vue';\n\nDescopeWc.sdkConfigOverrides = { baseHeaders };\n\nexport default {\n\t// eslint-disable-next-line vue/multi-word-component-names\n\tname: 'Descope',\n\tprops: {\n\t\tflowId: {\n\t\t\ttype: String,\n\t\t\trequired: true\n\t\t},\n\t\ttenant: {\n\t\t\ttype: String\n\t\t},\n\t\ttheme: {\n\t\t\ttype: String\n\t\t},\n\t\tdebug: {\n\t\t\ttype: Boolean\n\t\t},\n\t\ttelemetryKey: {\n\t\t\ttype: String\n\t\t},\n\t\tredirectUrl: {\n\t\t\ttype: String\n\t\t},\n\t\tautoFocus: {\n\t\t\ttype: Boolean\n\t\t},\n\t\terrorTransformer: {\n\t\t\ttype: Function\n\t\t}\n\t},\n\temits: ['success', 'error'],\n\tsetup(_: unknown, { emit }: SetupContext) {\n\t\tconst { projectId, baseUrl, sessionTokenViaCookie } = useOptions();\n\t\tconst sdk = useDescope();\n\n\t\tconst onSuccess = async (e: CustomEvent) => {\n\t\t\t// Note: We need to emit AFTER the afterRequest hook has been called, but for\n\t\t\t// an unknown reason, the emit is not called if we await the hook.\n\t\t\temit('success', e);\n\t\t\tawait sdk.httpClient.hooks?.afterRequest?.(\n\t\t\t\t{} as RequestConfig,\n\t\t\t\tnew Response(JSON.stringify(e.detail))\n\t\t\t);\n\t\t};\n\t\tconst onError = (e: Event) => emit('error', e);\n\n\t\treturn {\n\t\t\tprojectId,\n\t\t\tbaseUrl,\n\t\t\tsessionTokenViaCookie,\n\t\t\tonSuccess,\n\t\t\tonError\n\t\t};\n\t},\n\tmounted() {\n\t\t// Set the errorTransformer function on the web component ref\n\t\tthis.$refs.webComponentRef.errorTransformer = this.errorTransformer;\n\t}\n};\n</script>\n"],"names":["_createElementBlock","_createElementVNode","$setup","projectId","baseUrl","$props","flowId","theme","tenant","debug","telemetryKey","redirectUrl","autoFocus","onSuccess","args","onError","ref"],"mappings":"41CACCA,qBAeK,MAAA,KAAA,CAdJC,EAAAA,mBAaC,aAAA,CAZC,aAAYC,EAASC,UACrB,WAAUD,EAAOE,QACjB,UAASC,EAAMC,OACf,SAAYD,EAAKE,MACjB,UAAaF,EAAMG,OACnB,SAAYH,EAAKI,MACjB,gBAAmBJ,EAAYK,aAC/B,eAAcL,EAAWM,YACzB,aAAYN,EAASO,UACrBC,8BAASX,EAASW,WAAAX,EAAAW,aAAAC,IAClBC,4BAAOb,EAAOa,SAAAb,EAAAa,WAAAD,IACfE,IAAI"}
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/dist/index.d.ts CHANGED
@@ -1,46 +1,68 @@
1
1
  import * as vue from 'vue';
2
- import { SetupContext, App } from 'vue';
2
+ import { App } from 'vue';
3
3
  import * as _descope_core_js_sdk from '@descope/core-js-sdk';
4
4
 
5
- declare const _default$1: {
6
- name: string;
7
- props: {
8
- flowId: {
9
- type: StringConstructor;
10
- required: boolean;
11
- };
12
- tenant: {
13
- type: StringConstructor;
14
- };
15
- theme: {
16
- type: StringConstructor;
17
- };
18
- debug: {
19
- type: BooleanConstructor;
20
- };
21
- telemetryKey: {
22
- type: StringConstructor;
23
- };
24
- redirectUrl: {
25
- type: StringConstructor;
26
- };
27
- autoFocus: {
28
- type: BooleanConstructor;
29
- };
30
- errorTransformer: {
31
- type: FunctionConstructor;
32
- };
5
+ declare const _default$1: vue.DefineComponent<{
6
+ flowId: {
7
+ type: StringConstructor;
8
+ required: true;
33
9
  };
34
- emits: string[];
35
- setup(_: unknown, { emit }: SetupContext): {
36
- projectId: string;
37
- baseUrl: string;
38
- sessionTokenViaCookie: boolean;
39
- onSuccess: (e: CustomEvent) => Promise<void>;
40
- onError: (e: Event) => void;
10
+ tenant: {
11
+ type: StringConstructor;
41
12
  };
42
- mounted(): void;
43
- };
13
+ theme: {
14
+ type: StringConstructor;
15
+ };
16
+ debug: {
17
+ type: BooleanConstructor;
18
+ };
19
+ telemetryKey: {
20
+ type: StringConstructor;
21
+ };
22
+ redirectUrl: {
23
+ type: StringConstructor;
24
+ };
25
+ autoFocus: {
26
+ type: BooleanConstructor;
27
+ };
28
+ errorTransformer: {
29
+ type: FunctionConstructor;
30
+ };
31
+ }, (_ctx: any, _cache: any) => vue.VNode<vue.RendererNode, vue.RendererElement, {
32
+ [key: string]: any;
33
+ }>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("success" | "error")[], "success" | "error", vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
34
+ flowId: {
35
+ type: StringConstructor;
36
+ required: true;
37
+ };
38
+ tenant: {
39
+ type: StringConstructor;
40
+ };
41
+ theme: {
42
+ type: StringConstructor;
43
+ };
44
+ debug: {
45
+ type: BooleanConstructor;
46
+ };
47
+ telemetryKey: {
48
+ type: StringConstructor;
49
+ };
50
+ redirectUrl: {
51
+ type: StringConstructor;
52
+ };
53
+ autoFocus: {
54
+ type: BooleanConstructor;
55
+ };
56
+ errorTransformer: {
57
+ type: FunctionConstructor;
58
+ };
59
+ }>> & {
60
+ onSuccess?: (...args: any[]) => any;
61
+ onError?: (...args: any[]) => any;
62
+ }, {
63
+ debug: boolean;
64
+ autoFocus: boolean;
65
+ }>;
44
66
 
45
67
  type Options = {
46
68
  projectId: string;
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import e from"@descope/web-component";import{computed as s,watch as o,inject as r,openBlock as n,createElementBlock as t,createElementVNode as i,ref as a,unref as u,readonly as l}from"vue";import c from"@descope/web-js-sdk";const d=Symbol("$descope"),p={"x-descope-sdk-name":"vue","x-descope-sdk-version":"0.0.0-next-9f057a11-20230706"},f="undefined"!=typeof window,v=()=>{const e=r(d);if(!e)throw Error("Missing Descope context, make sure you are using the Descope plugin");return e},m=()=>v().sdk,h=()=>{const{session:e}=v();return e.isFetchSessionWasNeverCalled.value&&e.fetchSession(),{isLoading:s((()=>e.isLoading.value||e.isFetchSessionWasNeverCalled.value)),sessionToken:e.session,isAuthenticated:s((()=>!!e.session.value))}},g=()=>{const{user:e,session:r}=v(),n=()=>{!e.user.value&&r.session.value&&e.fetchUser()};return n(),o(r.session,n),{isLoading:s((()=>e.isLoading.value||e.isFetchUserWasNeverCalled.value)),user:e.user}};e.sdkConfigOverrides={baseHeaders:p};var y={name:"Descope",props:{flowId:{type:String,required:!0},tenant:{type:String},theme:{type:String},debug:{type:Boolean},telemetryKey:{type:String},redirectUrl:{type:String},autoFocus:{type:Boolean},errorTransformer:{type:Function}},emits:["success","error"],setup(e,{emit:s}){const{projectId:o,baseUrl:r,sessionTokenViaCookie:n}=v().options,t=m();return{projectId:o,baseUrl:r,sessionTokenViaCookie:n,onSuccess:async e=>{s("success",e),await(t.httpClient.hooks?.afterRequest?.({},new Response(JSON.stringify(e.detail))))},onError:e=>s("error",e)}},mounted(){this.$refs.webComponentRef.errorTransformer=this.errorTransformer}};const S=["project-id","base-url","flow-id","^theme","^tenant","^debug","^telemetryKey","redirect-url","auto-focus"];y.render=function(e,s,o,r,a,u){return n(),t("div",null,[i("descope-wc",{"project-id":r.projectId,"base-url":r.baseUrl,"flow-id":o.flowId,"^theme":o.theme,"^tenant":o.tenant,"^debug":o.debug,"^telemetryKey":o.telemetryKey,"redirect-url":o.redirectUrl,"auto-focus":o.autoFocus,onSuccess:s[0]||(s[0]=(...e)=>r.onSuccess&&r.onSuccess(...e)),onError:s[1]||(s[1]=(...e)=>r.onError&&r.onError(...e)),ref:"webComponentRef"},null,40,S)])},y.__file="src/Descope.vue";const w=e=>(...s)=>{let o;try{o=e(...s)}catch(e){console.error(e)}return o};let k;const b=e=>{const s=c({...e,persistTokens:f,autoRefresh:f});return k=s,s};k=b({projectId:"temp pid"});const C=()=>f?k?.getSessionToken():(console.warn("Get session token is not supported in SSR"),""),T=()=>f?k?.getRefreshToken():(console.warn("Get refresh token is not supported in SSR"),""),R=w(((e=C(),s)=>k?.getJwtPermissions(e,s))),U=w(((e=C(),s)=>k?.getJwtRoles(e,s))),F=a(null),j=()=>u(F)?.();let I;const L=()=>I;var N={install:function(e,o){const r=b({...o,persistTokens:!0,autoRefresh:!0,baseHeaders:p});I=r;const n=a(null),t=a(""),i=a(null),c=a(null);r.onSessionTokenChange((e=>{t.value=e})),r.onUserChange((e=>{c.value=e}));const f=async()=>{n.value=!0,await r.refresh(),n.value=!1},v=s((()=>null===n.value)),m=s((()=>null===i.value));F.value=async()=>(!t.value&&v.value&&await f(),!!u(t)),e.provide(d,{session:{fetchSession:f,isLoading:l(n),session:l(t),isFetchSessionWasNeverCalled:v},user:{fetchUser:async()=>{i.value=!0,await r.me(),i.value=!1},isLoading:l(i),user:l(c),isFetchUserWasNeverCalled:m},sdk:r,options:o})}};export{y as Descope,N as default,R as getJwtPermissions,U as getJwtRoles,T as getRefreshToken,L as getSdk,C as getSessionToken,j as routeGuard,m as useDescope,h as useSession,g as useUser};
1
+ import{computed as e,watch as s,inject as o,defineComponent as r,openBlock as t,createElementBlock as n,createElementVNode as i,unref as a,ref as l,readonly as u}from"vue";import c from"@descope/web-component";import d from"@descope/web-js-sdk";const p=Symbol("$descope"),v={"x-descope-sdk-name":"vue","x-descope-sdk-version":"0.0.0-next-c146b936-20230712"},f="undefined"!=typeof window,m=()=>{const e=o(p);if(!e)throw Error("Missing Descope context, make sure you are using the Descope plugin");return e},g=()=>m().sdk,h=()=>{const{session:s}=m();return s.isFetchSessionWasNeverCalled.value&&s.fetchSession(),{isLoading:e((()=>s.isLoading.value||s.isFetchSessionWasNeverCalled.value)),sessionToken:s.session,isAuthenticated:e((()=>!!s.session.value))}},y=()=>{const{user:o,session:r}=m(),t=()=>{!o.user.value&&r.session.value&&o.fetchUser()};return t(),s(r.session,t),{isLoading:e((()=>o.isLoading.value||o.isFetchUserWasNeverCalled.value)),user:o.user}},w=["project-id","base-url","flow-id","^theme","^tenant","^debug","^telemetryKey","redirect-url","auto-focus",".errorTransformer"];var S=r({__name:"Descope",props:{flowId:{type:String,required:!0},tenant:{type:String},theme:{type:String},debug:{type:Boolean},telemetryKey:{type:String},redirectUrl:{type:String},autoFocus:{type:Boolean},errorTransformer:{type:Function}},emits:["success","error"],setup(e,{emit:s}){c.sdkConfigOverrides={baseHeaders:v};const{projectId:o,baseUrl:r}=m().options,l=g(),u=async e=>{s("success",e),await(l.httpClient.hooks?.afterRequest?.({},new Response(JSON.stringify(e.detail))))},d=e=>s("error",e);return(s,l)=>(t(),n("div",null,[i("descope-wc",{"project-id":a(o),"base-url":a(r),"flow-id":e.flowId,"^theme":e.theme,"^tenant":e.tenant,"^debug":e.debug,"^telemetryKey":e.telemetryKey,"redirect-url":e.redirectUrl,"auto-focus":e.autoFocus,".errorTransformer":e.errorTransformer,onSuccess:u,onError:d},null,40,w)]))}});S.__file="src/Descope.vue";const k=e=>(...s)=>{let o;try{o=e(...s)}catch(e){console.error(e)}return o};let b;const T=e=>{const s=d({...e,persistTokens:f,autoRefresh:f});return b=s,s};b=T({projectId:"temp pid"});const C=()=>f?b?.getSessionToken():(console.warn("Get session token is not supported in SSR"),""),F=()=>f?b?.getRefreshToken():(console.warn("Get refresh token is not supported in SSR"),""),R=k(((e=C(),s)=>b?.getJwtPermissions(e,s))),U=k(((e=C(),s)=>b?.getJwtRoles(e,s))),L=l(null),N=()=>a(L)?.();let j;const x=()=>j;var D={install:function(s,o){const r=T({...o,persistTokens:!0,autoRefresh:!0,baseHeaders:v});j=r;const t=l(null),n=l(""),i=l(null),c=l(null);r.onSessionTokenChange((e=>{n.value=e})),r.onUserChange((e=>{c.value=e}));const d=async()=>{t.value=!0,await r.refresh(),t.value=!1},f=e((()=>null===t.value)),m=e((()=>null===i.value));L.value=async()=>(!n.value&&f.value&&await d(),!!a(n)),s.provide(p,{session:{fetchSession:d,isLoading:u(t),session:u(n),isFetchSessionWasNeverCalled:f},user:{fetchUser:async()=>{i.value=!0,await r.me(),i.value=!1},isLoading:u(i),user:u(c),isFetchUserWasNeverCalled:m},sdk:r,options:o})}};export{S as Descope,D as default,R as getJwtPermissions,U as getJwtRoles,F as getRefreshToken,x as getSdk,C as getSessionToken,N as routeGuard,g as useDescope,h as useSession,y as useUser};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/Descope.vue?vue&type=template&id=8a031dec&lang.js"],"sourcesContent":["<template>\n\t<div>\n\t\t<descope-wc\n\t\t\t:project-id=\"projectId\"\n\t\t\t:base-url=\"baseUrl\"\n\t\t\t:flow-id=\"flowId\"\n\t\t\t:theme.attr=\"theme\"\n\t\t\t:tenant.attr=\"tenant\"\n\t\t\t:debug.attr=\"debug\"\n\t\t\t:telemetryKey.attr=\"telemetryKey\"\n\t\t\t:redirect-url=\"redirectUrl\"\n\t\t\t:auto-focus=\"autoFocus\"\n\t\t\t@success=\"onSuccess\"\n\t\t\t@error=\"onError\"\n\t\t\tref=\"webComponentRef\"\n\t\t/>\n\t</div>\n</template>\n\n<script lang=\"ts\">\nimport DescopeWc from '@descope/web-component';\nimport { useOptions, useDescope } from './hooks';\nimport { baseHeaders } from './constants';\nimport { RequestConfig } from '@descope/core-js-sdk';\nimport { SetupContext } from 'vue';\n\nDescopeWc.sdkConfigOverrides = { baseHeaders };\n\nexport default {\n\t// eslint-disable-next-line vue/multi-word-component-names\n\tname: 'Descope',\n\tprops: {\n\t\tflowId: {\n\t\t\ttype: String,\n\t\t\trequired: true\n\t\t},\n\t\ttenant: {\n\t\t\ttype: String\n\t\t},\n\t\ttheme: {\n\t\t\ttype: String\n\t\t},\n\t\tdebug: {\n\t\t\ttype: Boolean\n\t\t},\n\t\ttelemetryKey: {\n\t\t\ttype: String\n\t\t},\n\t\tredirectUrl: {\n\t\t\ttype: String\n\t\t},\n\t\tautoFocus: {\n\t\t\ttype: Boolean\n\t\t},\n\t\terrorTransformer: {\n\t\t\ttype: Function\n\t\t}\n\t},\n\temits: ['success', 'error'],\n\tsetup(_: unknown, { emit }: SetupContext) {\n\t\tconst { projectId, baseUrl, sessionTokenViaCookie } = useOptions();\n\t\tconst sdk = useDescope();\n\n\t\tconst onSuccess = async (e: CustomEvent) => {\n\t\t\t// Note: We need to emit AFTER the afterRequest hook has been called, but for\n\t\t\t// an unknown reason, the emit is not called if we await the hook.\n\t\t\temit('success', e);\n\t\t\tawait sdk.httpClient.hooks?.afterRequest?.(\n\t\t\t\t{} as RequestConfig,\n\t\t\t\tnew Response(JSON.stringify(e.detail))\n\t\t\t);\n\t\t};\n\t\tconst onError = (e: Event) => emit('error', e);\n\n\t\treturn {\n\t\t\tprojectId,\n\t\t\tbaseUrl,\n\t\t\tsessionTokenViaCookie,\n\t\t\tonSuccess,\n\t\t\tonError\n\t\t};\n\t},\n\tmounted() {\n\t\t// Set the errorTransformer function on the web component ref\n\t\tthis.$refs.webComponentRef.errorTransformer = this.errorTransformer;\n\t}\n};\n</script>\n"],"names":["_createElementBlock","_createElementVNode","$setup","projectId","baseUrl","$props","flowId","theme","tenant","debug","telemetryKey","redirectUrl","autoFocus","onSuccess","args","onError","ref"],"mappings":"+tDACCA,EAeK,MAAA,KAAA,CAdJC,EAaC,aAAA,CAZC,aAAYC,EAASC,UACrB,WAAUD,EAAOE,QACjB,UAASC,EAAMC,OACf,SAAYD,EAAKE,MACjB,UAAaF,EAAMG,OACnB,SAAYH,EAAKI,MACjB,gBAAmBJ,EAAYK,aAC/B,eAAcL,EAAWM,YACzB,aAAYN,EAASO,UACrBC,8BAASX,EAASW,WAAAX,EAAAW,aAAAC,IAClBC,4BAAOb,EAAOa,SAAAb,EAAAa,WAAAD,IACfE,IAAI"}
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope/vue-sdk",
3
- "version": "0.0.0-next-9f057a11-20230706",
3
+ "version": "0.0.0-next-c146b936-20230712",
4
4
  "main": "dist/index.cjs",
5
5
  "module": "dist/index.mjs",
6
6
  "type": "module",