@descope/vue-sdk 0.0.0-next-fe60cdb6-20230614

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/dist/index.mjs ADDED
@@ -0,0 +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 a,ref as i,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-fe60cdb6-20230614"},v=()=>{const e=r(d);if(!e)throw Error("Missing Descope context, make sure you are using the Descope plugin");return e},f=()=>v().sdk,g=()=>{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))}},h=()=>{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 m={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}},emits:["success","error"],setup(e,{emit:s}){const{projectId:o,baseUrl:r,sessionTokenViaCookie:n}=v().options,t=f();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)}}};const y=["project-id","base-url","flow-id","^theme","^tenant","^debug","^telemetryKey","redirect-url","auto-focus"];m.render=function(e,s,o,r,i,u){return n(),t("div",null,[a("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))},null,40,y)])},m.__file="src/Descope.vue";const S=i(null),b=()=>u(S)?.();var k={install:function(e,o){const r=c({persistTokens:!0,autoRefresh:!0,baseHeaders:p,...o}),n=i(null),t=i(""),a=i(null),v=i(null);r.onSessionTokenChange((e=>{t.value=e})),r.onUserChange((e=>{v.value=e}));const f=async()=>{n.value=!0,await r.refresh(),n.value=!1},g=s((()=>null===n.value)),h=s((()=>null===a.value));S.value=async()=>(!t.value&&g.value&&await f(),!!u(t)),e.provide(d,{session:{fetchSession:f,isLoading:l(n),session:l(t),isFetchSessionWasNeverCalled:g},user:{fetchUser:async()=>{a.value=!0,await r.me(),a.value=!1},isLoading:l(a),user:l(v),isFetchUserWasNeverCalled:h},sdk:r,options:o})}};export{m as Descope,k as default,b as routeGuard,f as useDescope,g as useSession,h as useUser};
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +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/>\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},\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};\n</script>\n"],"names":["_createElementBlock","_createElementVNode","$setup","projectId","baseUrl","$props","flowId","theme","tenant","debug","telemetryKey","redirectUrl","autoFocus","onSuccess","args","onError"],"mappings":"olDACCA,EAcK,MAAA,KAAA,CAbJC,EAYC,aAAA,CAXC,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"}
package/package.json ADDED
@@ -0,0 +1,79 @@
1
+ {
2
+ "name": "@descope/vue-sdk",
3
+ "version": "0.0.0-next-fe60cdb6-20230614",
4
+ "main": "dist/index.cjs",
5
+ "module": "dist/index.mjs",
6
+ "type": "module",
7
+ "license": "MIT",
8
+ "exports": {
9
+ "require": "./dist/index.cjs",
10
+ "import": "./dist/index.mjs"
11
+ },
12
+ "types": "dist/index.d.ts",
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "scripts": {
17
+ "start": "vue-cli-service serve",
18
+ "build": "rollup -m -c rollup.config.js",
19
+ "test": "vue-cli-service test:unit",
20
+ "lint": "vue-cli-service lint",
21
+ "format-lint": "pretty-quick --staged --ignore-path .gitignore && lint-staged",
22
+ "format": "prettier . -w --ignore-path .gitignore",
23
+ "format-check": "prettier . --check --ignore-path .gitignore",
24
+ "leaks": "bash ./scripts/gitleaks/gitleaks.sh",
25
+ "prepare": "husky install",
26
+ "prepublishOnly": "npm run build"
27
+ },
28
+ "lint-staged": {
29
+ "+(src|tests|example)/**/*.{js,ts,jsx,tsx}": [
30
+ "npm run lint"
31
+ ]
32
+ },
33
+ "dependencies": {
34
+ "@descope/web-component": "2.0.17"
35
+ },
36
+ "peerDependencies": {
37
+ "@descope/web-js-sdk": "1.2.8",
38
+ "vue": ">=3"
39
+ },
40
+ "devDependencies": {
41
+ "@rollup/plugin-typescript": "^11.1.0",
42
+ "@types/jest": "^27.0.1",
43
+ "@typescript-eslint/eslint-plugin": "^5.4.0",
44
+ "@typescript-eslint/parser": "^5.4.0",
45
+ "@vue/cli-plugin-babel": "~5.0.0",
46
+ "@vue/cli-plugin-eslint": "~5.0.0",
47
+ "@vue/cli-plugin-typescript": "~5.0.0",
48
+ "@vue/cli-plugin-unit-jest": "~5.0.0",
49
+ "@vue/cli-service": "~5.0.0",
50
+ "@vue/eslint-config-typescript": "^9.1.0",
51
+ "@vue/test-utils": "^2.0.0-0",
52
+ "@vue/vue3-jest": "^27.0.0-alpha.1",
53
+ "babel-jest": "^27.0.6",
54
+ "eslint": "^7.32.0",
55
+ "eslint-config-prettier": "^8.3.0",
56
+ "eslint-plugin-prettier": "^4.0.0",
57
+ "eslint-plugin-vue": "^8.0.3",
58
+ "husky": "^8.0.1",
59
+ "jest": "^27.0.5",
60
+ "lint-staged": "^13.0.3",
61
+ "prettier": "^2.4.1",
62
+ "pretty-quick": "^3.1.3",
63
+ "rollup": "^2.79.1",
64
+ "rollup-plugin-auto-external": "^2.0.0",
65
+ "rollup-plugin-commonjs": "^10.1.0",
66
+ "rollup-plugin-define": "1.0.1",
67
+ "rollup-plugin-delete": "^2.0.0",
68
+ "rollup-plugin-dts": "^4.2.2",
69
+ "rollup-plugin-node-resolve": "^5.2.0",
70
+ "rollup-plugin-terser": "^7.0.2",
71
+ "rollup-plugin-typescript2": "^0.34.1",
72
+ "rollup-plugin-vue": "^6.0.0",
73
+ "ts-jest": "^27.0.4",
74
+ "tslib": "^2.3.1",
75
+ "typescript": "^4.9.3",
76
+ "vue": "^3.2.13",
77
+ "vue-router": "^4.1.6"
78
+ }
79
+ }