@strivacity/sdk-vue 2.1.2 → 2.3.0
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 +20 -0
- package/README.md +83 -0
- package/dist/assets/login-renderer.vue_vue_type_script_setup_true_lang.cjs +1 -1
- package/dist/assets/login-renderer.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/assets/login-renderer.vue_vue_type_script_setup_true_lang.mjs +1 -1
- package/dist/assets/login-renderer.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
## 2.3.0 (2026-02-10)
|
|
2
|
+
|
|
3
|
+
### 🧱 Updated Dependencies
|
|
4
|
+
|
|
5
|
+
- Updated sdk-core to 2.3.0
|
|
6
|
+
|
|
7
|
+
## 2.2.0 (2026-02-06)
|
|
8
|
+
|
|
9
|
+
### 🚀 Features
|
|
10
|
+
|
|
11
|
+
- logging implemented ([032dc8a](https://github.com/Strivacity/sdk-js/commit/032dc8a))
|
|
12
|
+
|
|
13
|
+
### 🩹 Fixes
|
|
14
|
+
|
|
15
|
+
- error message rendering fixed ([9e67051](https://github.com/Strivacity/sdk-js/commit/9e67051))
|
|
16
|
+
|
|
17
|
+
### 🧱 Updated Dependencies
|
|
18
|
+
|
|
19
|
+
- Updated sdk-core to 2.2.0
|
|
20
|
+
|
|
1
21
|
## 2.1.2 (2026-01-13)
|
|
2
22
|
|
|
3
23
|
### 🧱 Updated Dependencies
|
package/README.md
CHANGED
|
@@ -408,6 +408,89 @@ Same as the profile page example in redirect/popup mode.
|
|
|
408
408
|
|
|
409
409
|
Same as the logout page example in redirect/popup mode.
|
|
410
410
|
|
|
411
|
+
## Logging
|
|
412
|
+
|
|
413
|
+
The SDK supports optional logging to help you debug authentication flows and monitor SDK behavior. You can enable the built-in console logger or provide your own custom logger implementation.
|
|
414
|
+
|
|
415
|
+
### Using the Default Logger
|
|
416
|
+
|
|
417
|
+
Enable the default console logger by adding the `logging` option when creating the SDK:
|
|
418
|
+
|
|
419
|
+
```js
|
|
420
|
+
import { createApp } from 'vue';
|
|
421
|
+
import { createStrivacitySDK, DefaultLogging } from '@strivacity/sdk-vue';
|
|
422
|
+
|
|
423
|
+
const app = createApp(App);
|
|
424
|
+
const sdk = createStrivacitySDK({
|
|
425
|
+
mode: 'redirect',
|
|
426
|
+
issuer: 'https://<YOUR_DOMAIN>',
|
|
427
|
+
scopes: ['openid', 'profile'],
|
|
428
|
+
clientId: '<YOUR_CLIENT_ID>',
|
|
429
|
+
redirectUri: '<YOUR_REDIRECT_URI>',
|
|
430
|
+
logging: DefaultLogging, // Enable built-in console logging
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
app.use(sdk);
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
The default logger writes to the browser console and automatically prefixes messages with a correlation ID when available (via the `xEventId` property).
|
|
437
|
+
|
|
438
|
+
### Creating a Custom Logger
|
|
439
|
+
|
|
440
|
+
You can provide your own logger by implementing the `SDKLogging` interface with four methods: `debug`, `info`, `warn`, and `error`. An optional `xEventId` property is honored for log correlation.
|
|
441
|
+
|
|
442
|
+
```typescript
|
|
443
|
+
import type { SDKLogging } from '@strivacity/sdk-vue';
|
|
444
|
+
|
|
445
|
+
export class MyLogger implements SDKLogging {
|
|
446
|
+
xEventId?: string;
|
|
447
|
+
|
|
448
|
+
debug(message: string): void {
|
|
449
|
+
// Send to your logging pipeline
|
|
450
|
+
console.debug(this.xEventId ? `[${this.xEventId}] ${message}` : message);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
info(message: string): void {
|
|
454
|
+
console.info(this.xEventId ? `[${this.xEventId}] ${message}` : message);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
warn(message: string): void {
|
|
458
|
+
console.warn(this.xEventId ? `[${this.xEventId}] ${message}` : message);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
error(message: string, error: Error): void {
|
|
462
|
+
console.error(this.xEventId ? `[${this.xEventId}] ${message}` : message, error);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
Then register your custom logger when creating the SDK:
|
|
468
|
+
|
|
469
|
+
```js
|
|
470
|
+
import { createStrivacitySDK } from '@strivacity/sdk-vue';
|
|
471
|
+
import { MyLogger } from './logging/MyLogger';
|
|
472
|
+
|
|
473
|
+
const sdk = createStrivacitySDK({
|
|
474
|
+
mode: 'redirect',
|
|
475
|
+
issuer: 'https://<YOUR_DOMAIN>',
|
|
476
|
+
scopes: ['openid', 'profile'],
|
|
477
|
+
clientId: '<YOUR_CLIENT_ID>',
|
|
478
|
+
redirectUri: '<YOUR_REDIRECT_URI>',
|
|
479
|
+
logging: MyLogger, // Use your custom logger
|
|
480
|
+
});
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
### Logger Interface
|
|
484
|
+
|
|
485
|
+
The `SDKLogging` interface requires the following methods:
|
|
486
|
+
|
|
487
|
+
- **`debug(message: string): void`** - Log debug-level messages
|
|
488
|
+
- **`info(message: string): void`** - Log informational messages
|
|
489
|
+
- **`warn(message: string): void`** - Log warning messages
|
|
490
|
+
- **`error(message: string, error: Error): void`** - Log error messages with error objects
|
|
491
|
+
|
|
492
|
+
The optional `xEventId` property, when set by the SDK, provides a correlation ID to trace related log messages across the authentication flow.
|
|
493
|
+
|
|
411
494
|
## API Documentation
|
|
412
495
|
|
|
413
496
|
#### `useStrivacity` composable
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const o=require("vue"),m=require("@strivacity/sdk-core"),N=require("@strivacity/sdk-core/utils/object"),S=require("../composables.cjs"),I={class:"login-renderer"},O=o.defineComponent({__name:"login-renderer",props:{params:{default:()=>({})},widgets:{default:()=>({})},sessionId:{default:null}},emits:["login","fallback","close","error","globalMessage","blockReady"],setup(d,{emit:k}){const{sdk:c}=S.useStrivacity(),v=d,l=k,y=o.defineComponent({props:{items:{type:Array,default:()=>[]},widgets:{type:Object,default:()=>({})}},setup:e=>()=>e.items.map(t=>{if(t.type==="widget"){const n=r.value?.forms?.find(g=>g.id===t.formId),s=n?.widgets.find(g=>g.id===t.widgetId);if(!n||!s)return u(void 0,`Unable to find form or widget for item: formId=${t.formId}, widgetId=${t.widgetId}`),null;const b=e.widgets[s.type];return b?o.h(b,{key:`${n.id}.${s.id}`,formId:n.id,config:s}):(u(void 0,`No component found for widget type ${s.type}`),null)}else return t.type==="vertical"||t.type==="horizontal"?e.widgets.layout?o.h(e.widgets.layout,{formId:t.items[0].formId,type:t.type},()=>o.h(y,{items:t.items,widgets:e.widgets})):(u(void 0,"No layout component provided"),null):(u(void 0,"Unknown item type in layout"),null)})}),w=c.login(v.params),f=o.ref(!1),a=o.ref({}),i=o.ref({}),r=o.ref({});o.provide("nativeFlowContext",{loading:f,forms:a,messages:i,state:r,submitForm:F,triggerFallback:u,triggerClose:h,setFormValue:U,setMessage:C}),o.onMounted(async()=>{try{const e=await w.startSession(v.sessionId);e&&await p(e)}catch(e){e instanceof m.FallbackError?l("fallback",e):l("error",e)}});function u(e,t){const n=e||r.value.hostedUrl;if(c.logging?.warn(t?`Triggering fallback due to: ${t}`:"Triggering fallback"),!n){const s=new Error("No hosted URL provided");throw c.logging?.error("Fallback error",s),s}l("fallback",new m.FallbackError(new URL(n)))}function h(){l("close")}function U(e,t,n){n===""&&(n=null),a.value[e]===void 0&&(a.value[e]={}),a.value[e][t]=n}function C(e,t,n){i.value[e]===void 0&&(i.value[e]={}),i.value[e][t]=n}async function F(e){try{f.value=!0;const t=await w.submitForm(e,N.unflattenObject(a.value[e]));await p(t),f.value=!1}catch(t){t instanceof m.FallbackError?l("fallback",t):l("error",t)}}async function p(e){if(await c.isAuthenticated)l("login",c.idTokenClaims);else{const t=JSON.parse(JSON.stringify(r.value)),n={hostedUrl:e?.hostedUrl??r.value.hostedUrl,finalizeUrl:e?.finalizeUrl??r.value.finalizeUrl,screen:e?.screen??r.value.screen,forms:e?.forms??r.value.forms,layout:e?.layout??r.value.layout,messages:e?.messages??{},branding:e?.branding??r.value.branding};if(n.screen!=r.value.screen){a.value={},i.value={};for(const s of n.forms??[])a.value[s.id]={},i.value[s.id]={}}else c.logging?.info(`Updating screen: ${n.screen}`);Object.keys(n.messages??{}).forEach(s=>{s==="global"?l("globalMessage",n.messages?.global?.text??""):i.value[s]=n.messages[s]}),r.value=n,setTimeout(()=>{l("blockReady",{previousState:t,state:JSON.parse(JSON.stringify(r.value))})})}}return(e,t)=>(o.openBlock(),o.createElementBlock("div",I,[r.value.screen?(o.openBlock(),o.createBlock(o.resolveDynamicComponent(d.widgets.layout),{key:0,formId:(r.value.layout?.items[0]).formId,type:r.value.layout?.type,tag:"form"},{default:o.withCtx(()=>[o.createVNode(o.unref(y),{items:r.value.layout?.items,widgets:d.widgets},null,8,["items","widgets"])]),_:1},8,["formId","type"])):(o.openBlock(),o.createBlock(o.resolveDynamicComponent(d.widgets.loading),{key:1}))]))}});exports._sfc_main=O;
|
|
2
2
|
//# sourceMappingURL=login-renderer.vue_vue_type_script_setup_true_lang.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login-renderer.vue_vue_type_script_setup_true_lang.cjs","sources":["../../src/login-renderer.vue"],"sourcesContent":["<!-- eslint-disable no-console -->\n<script lang=\"ts\" setup>\nimport type { VNode, Component, PropType } from 'vue';\nimport type { PartialRecord, NativeParams, WidgetType, LayoutWidget, LoginFlowState, Widget, IdTokenClaims, LoginFlowMessage } from '@strivacity/sdk-core';\nimport type { NativeContext, NativeFlowContextValue } from './types';\nimport { defineComponent, provide, ref, h, onMounted } from 'vue';\nimport { FallbackError } from '@strivacity/sdk-core';\nimport { unflattenObject } from '@strivacity/sdk-core/utils/object';\nimport { useStrivacity } from './composables';\n\nconst { sdk } = useStrivacity<NativeContext>();\n\nconst props = withDefaults(\n\tdefineProps<{\n\t\tparams?: NativeParams;\n\t\twidgets?: PartialRecord<WidgetType, Component>;\n\t\tsessionId?: string | null;\n\t}>(),\n\t{\n\t\tparams: () => ({}),\n\t\twidgets: () => ({}),\n\t\tsessionId: null,\n\t},\n);\nconst emit = defineEmits<{\n\tlogin: [IdTokenClaims | null | undefined];\n\tfallback: [FallbackError];\n\tclose: [];\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\terror: [any];\n\tglobalMessage: [string];\n\tblockReady: [{ previousState: LoginFlowState; state: LoginFlowState }];\n}>();\n\nconst WidgetRenderer = defineComponent({\n\tprops: {\n\t\titems: {\n\t\t\ttype: Array as PropType<LayoutWidget['items']>,\n\t\t\tdefault: () => [],\n\t\t},\n\t\twidgets: {\n\t\t\ttype: Object as PropType<PartialRecord<WidgetType, Component>>,\n\t\t\tdefault: () => ({}),\n\t\t},\n\t},\n\tsetup: (props) => () =>\n\t\tprops.items.map((item): VNode | null => {\n\t\t\tif (item.type === 'widget') {\n\t\t\t\tconst form = state.value?.forms?.find((form) => form.id === item.formId);\n\t\t\t\tconst widget = form?.widgets.find((widget) => widget.id === item.widgetId);\n\n\t\t\t\tif (!form || !widget) {\n\t\t\t\t\ttriggerFallback();\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tconst component = props.widgets[widget.type];\n\n\t\t\t\tif (!component) {\n\t\t\t\t\ttriggerFallback();\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn h(component, { key: `${form.id}.${widget.id}`, formId: form.id, config: widget });\n\t\t\t} else if (item.type === 'vertical' || item.type === 'horizontal') {\n\t\t\t\tif (!props.widgets.layout) {\n\t\t\t\t\ttriggerFallback();\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn h(props.widgets.layout, { formId: (item.items[0] as Widget).formId, type: item.type }, () =>\n\t\t\t\t\th(WidgetRenderer, { items: item.items, widgets: props.widgets }),\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\ttriggerFallback();\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}),\n});\n\nconst loginHandler = sdk.login(props.params);\nconst loading = ref<boolean>(false);\nconst forms = ref<Record<string, Record<string, unknown>>>({});\nconst messages = ref<Record<string, Record<string, LoginFlowMessage>>>({});\nconst state = ref<LoginFlowState>({});\n\nprovide<NativeFlowContextValue>('nativeFlowContext', {\n\tloading,\n\tforms,\n\tmessages,\n\tstate,\n\tsubmitForm,\n\ttriggerFallback,\n\ttriggerClose,\n\tsetFormValue,\n\tsetMessage,\n});\n\nonMounted(async () => {\n\ttry {\n\t\tconst data = await loginHandler.startSession(props.sessionId);\n\n\t\tif (data) {\n\t\t\tawait handleResponse(data);\n\t\t}\n\t} catch (error) {\n\t\tif (error instanceof FallbackError) {\n\t\t\temit('fallback', error);\n\t\t} else {\n\t\t\temit('error', error);\n\t\t}\n\t}\n});\n\nfunction triggerFallback(hostedUrl?: string): void {\n\tconst url = hostedUrl || state.value.hostedUrl;\n\n\tif (!url) {\n\t\tthrow new Error('No hosted URL provided');\n\t}\n\n\temit('fallback', new FallbackError(new URL(url)));\n}\n\nfunction triggerClose(): void {\n\temit('close');\n}\n\nfunction setFormValue(formId: string, widgetId: string, value: unknown) {\n\tif (value === '') {\n\t\tvalue = null;\n\t}\n\n\tif (forms.value[formId] === undefined) {\n\t\tforms.value[formId] = {};\n\t}\n\n\tforms.value[formId][widgetId] = value;\n}\n\nfunction setMessage(formId: string, widgetId: string, value: LoginFlowMessage) {\n\tif (messages.value[formId] === undefined) {\n\t\tmessages.value[formId] = {};\n\t}\n\n\tmessages.value[formId][widgetId] = value;\n}\n\nasync function submitForm(formId: string): Promise<void> {\n\ttry {\n\t\tloading.value = true;\n\n\t\tconst data = await loginHandler.submitForm(formId, unflattenObject(forms.value[formId]));\n\t\tawait handleResponse(data);\n\n\t\tloading.value = false;\n\t} catch (error) {\n\t\tif (error instanceof FallbackError) {\n\t\t\temit('fallback', error);\n\t\t} else {\n\t\t\temit('error', error);\n\t\t}\n\t}\n}\n\nasync function handleResponse(data?: LoginFlowState) {\n\tif (await sdk.isAuthenticated) {\n\t\temit('login', sdk.idTokenClaims);\n\t} else {\n\t\tconst previousState = JSON.parse(JSON.stringify(state.value));\n\t\tconst newState: LoginFlowState = {\n\t\t\thostedUrl: data?.hostedUrl ?? state.value.hostedUrl,\n\t\t\tfinalizeUrl: data?.finalizeUrl ?? state.value.finalizeUrl,\n\t\t\tscreen: data?.screen ?? state.value.screen,\n\t\t\tforms: data?.forms ?? state.value.forms,\n\t\t\tlayout: data?.layout ?? state.value.layout,\n\t\t\tmessages: data?.messages ?? state.value.messages,\n\t\t\tbranding: data?.branding ?? state.value.branding,\n\t\t};\n\n\t\tif (newState.screen != state.value.screen) {\n\t\t\tforms.value = {};\n\t\t\tmessages.value = {};\n\n\t\t\tfor (const form of newState.forms ?? []) {\n\t\t\t\tforms.value[form.id] = {};\n\t\t\t\tmessages.value[form.id] = {};\n\t\t\t}\n\t\t}\n\n\t\tObject.keys(newState.messages ?? {}).forEach((formId) => {\n\t\t\tif (formId === 'global') {\n\t\t\t\temit('globalMessage', newState.messages?.global?.text ?? '');\n\t\t\t} else {\n\t\t\t\tmessages.value[formId] = newState.messages![formId];\n\t\t\t}\n\t\t});\n\n\t\tstate.value = newState;\n\n\t\tsetTimeout(() => {\n\t\t\temit('blockReady', { previousState, state: JSON.parse(JSON.stringify(state.value)) });\n\t\t});\n\t}\n}\n</script>\n\n<template>\n\t<div class=\"login-renderer\">\n\t\t<component :is=\"widgets.layout\" v-if=\"state.screen\" :formId=\"(state.layout?.items[0] as Widget).formId\" :type=\"state.layout?.type\" tag=\"form\">\n\t\t\t<WidgetRenderer :items=\"state.layout?.items\" :widgets=\"widgets\" />\n\t\t</component>\n\t\t<component :is=\"widgets.loading\" v-else />\n\t</div>\n</template>\n"],"names":["sdk","useStrivacity","props","__props","emit","__emit","WidgetRenderer","defineComponent","item","form","state","widget","triggerFallback","component","h","loginHandler","loading","ref","forms","messages","provide","submitForm","triggerClose","setFormValue","setMessage","onMounted","data","handleResponse","error","FallbackError","hostedUrl","url","formId","widgetId","value","unflattenObject","previousState","newState","_openBlock","_createElementBlock","_hoisted_1","_createBlock","_resolveDynamicComponent","_createVNode","_unref"],"mappings":"6YAUA,KAAM,CAAE,IAAAA,CAAA,EAAQC,gBAAA,EAEVC,EAAQC,EAYRC,EAAOC,EAUPC,EAAiBC,EAAAA,gBAAgB,CACtC,MAAO,CACN,MAAO,CACN,KAAM,MACN,QAAS,IAAM,CAAA,CAAC,EAEjB,QAAS,CACR,KAAM,OACN,QAAS,KAAO,CAAA,EAAC,CAClB,EAED,MAAQL,GAAU,IACjBA,EAAM,MAAM,IAAKM,GAAuB,CACvC,GAAIA,EAAK,OAAS,SAAU,CAC3B,MAAMC,EAAOC,EAAM,OAAO,OAAO,KAAMD,GAASA,EAAK,KAAOD,EAAK,MAAM,EACjEG,EAASF,GAAM,QAAQ,KAAME,GAAWA,EAAO,KAAOH,EAAK,QAAQ,EAEzE,GAAI,CAACC,GAAQ,CAACE,EACb,OAAAC,EAAA,EACO,KAGR,MAAMC,EAAYX,EAAM,QAAQS,EAAO,IAAI,EAE3C,OAAKE,EAKEC,EAAAA,EAAED,EAAW,CAAE,IAAK,GAAGJ,EAAK,EAAE,IAAIE,EAAO,EAAE,GAAI,OAAQF,EAAK,GAAI,OAAQE,EAAQ,GAJtFC,EAAA,EACO,KAIT,aAAWJ,EAAK,OAAS,YAAcA,EAAK,OAAS,eAC/CN,EAAM,QAAQ,OAKZY,EAAAA,EAAEZ,EAAM,QAAQ,OAAQ,CAAE,OAASM,EAAK,MAAM,CAAC,EAAa,OAAQ,KAAMA,EAAK,IAAA,EAAQ,IAC7FM,EAAAA,EAAER,EAAgB,CAAE,MAAOE,EAAK,MAAO,QAASN,EAAM,OAAA,CAAS,CAAA,GAGhEU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AAQ2B,EAEd,WAAW,IAAM,CAChBjC,EAAK,aAAc,CAAE,cAAAgC,EAAe,MAAO,KAAK,MAAM,KAAK,UAAU1B,EAAM,KAAK,CAAC,CAAA,CAAG,CACrF,CAAC,CACF,CACD,eAIC4B,YAAA,EAAAC,qBAKM,MALNC,EAKM,CAJiC9B,EAAA,MAAM,sBAA5C+B,cAEYC,EAAAA,wBAFIvC,EAAA,QAAQ,MAAM,EAAA,OAAuB,QAASO,EAAA,MAAM,QAAQ,UAAoB,OAAS,KAAMA,EAAA,MAAM,QAAQ,KAAM,IAAI,MAAA,qBACtI,IAAkE,CAAlEiC,cAAkEC,EAAAA,MAAAtC,CAAA,EAAA,CAAjD,MAAOI,EAAA,MAAM,QAAQ,MAAQ,QAASP,EAAA,OAAA,0EAExDsC,EAAAA,YAA0CC,EAAAA,wBAA1BvC,EAAA,QAAQ,OAAO,EAAA,CAAA,IAAA,EAAA,EAAA"}
|
|
1
|
+
{"version":3,"file":"login-renderer.vue_vue_type_script_setup_true_lang.cjs","sources":["../../src/login-renderer.vue"],"sourcesContent":["<!-- eslint-disable no-console -->\n<script lang=\"ts\" setup>\nimport type { VNode, Component, PropType } from 'vue';\nimport type { PartialRecord, NativeParams, WidgetType, LayoutWidget, LoginFlowState, Widget, IdTokenClaims, LoginFlowMessage } from '@strivacity/sdk-core';\nimport type { NativeContext, NativeFlowContextValue } from './types';\nimport { defineComponent, provide, ref, h, onMounted } from 'vue';\nimport { FallbackError } from '@strivacity/sdk-core';\nimport { unflattenObject } from '@strivacity/sdk-core/utils/object';\nimport { useStrivacity } from './composables';\n\nconst { sdk } = useStrivacity<NativeContext>();\n\nconst props = withDefaults(\n\tdefineProps<{\n\t\tparams?: NativeParams;\n\t\twidgets?: PartialRecord<WidgetType, Component>;\n\t\tsessionId?: string | null;\n\t}>(),\n\t{\n\t\tparams: () => ({}),\n\t\twidgets: () => ({}),\n\t\tsessionId: null,\n\t},\n);\nconst emit = defineEmits<{\n\tlogin: [IdTokenClaims | null | undefined];\n\tfallback: [FallbackError];\n\tclose: [];\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\terror: [any];\n\tglobalMessage: [string];\n\tblockReady: [{ previousState: LoginFlowState; state: LoginFlowState }];\n}>();\n\nconst WidgetRenderer = defineComponent({\n\tprops: {\n\t\titems: {\n\t\t\ttype: Array as PropType<LayoutWidget['items']>,\n\t\t\tdefault: () => [],\n\t\t},\n\t\twidgets: {\n\t\t\ttype: Object as PropType<PartialRecord<WidgetType, Component>>,\n\t\t\tdefault: () => ({}),\n\t\t},\n\t},\n\tsetup: (props) => () =>\n\t\tprops.items.map((item): VNode | null => {\n\t\t\tif (item.type === 'widget') {\n\t\t\t\tconst form = state.value?.forms?.find((form) => form.id === item.formId);\n\t\t\t\tconst widget = form?.widgets.find((widget) => widget.id === item.widgetId);\n\n\t\t\t\tif (!form || !widget) {\n\t\t\t\t\ttriggerFallback(undefined, `Unable to find form or widget for item: formId=${item.formId}, widgetId=${item.widgetId}`);\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tconst component = props.widgets[widget.type];\n\n\t\t\t\tif (!component) {\n\t\t\t\t\ttriggerFallback(undefined, `No component found for widget type ${widget.type}`);\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn h(component, { key: `${form.id}.${widget.id}`, formId: form.id, config: widget });\n\t\t\t} else if (item.type === 'vertical' || item.type === 'horizontal') {\n\t\t\t\tif (!props.widgets.layout) {\n\t\t\t\t\ttriggerFallback(undefined, 'No layout component provided');\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn h(props.widgets.layout, { formId: (item.items[0] as Widget).formId, type: item.type }, () =>\n\t\t\t\t\th(WidgetRenderer, { items: item.items, widgets: props.widgets }),\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\ttriggerFallback(undefined, 'Unknown item type in layout');\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}),\n});\n\nconst loginHandler = sdk.login(props.params);\nconst loading = ref<boolean>(false);\nconst forms = ref<Record<string, Record<string, unknown>>>({});\nconst messages = ref<Record<string, Record<string, LoginFlowMessage>>>({});\nconst state = ref<LoginFlowState>({});\n\nprovide<NativeFlowContextValue>('nativeFlowContext', {\n\tloading,\n\tforms,\n\tmessages,\n\tstate,\n\tsubmitForm,\n\ttriggerFallback,\n\ttriggerClose,\n\tsetFormValue,\n\tsetMessage,\n});\n\nonMounted(async () => {\n\ttry {\n\t\tconst data = await loginHandler.startSession(props.sessionId);\n\n\t\tif (data) {\n\t\t\tawait handleResponse(data);\n\t\t}\n\t} catch (error) {\n\t\tif (error instanceof FallbackError) {\n\t\t\temit('fallback', error);\n\t\t} else {\n\t\t\temit('error', error);\n\t\t}\n\t}\n});\n\nfunction triggerFallback(hostedUrl?: string, message?: string): void {\n\tconst url = hostedUrl || state.value.hostedUrl;\n\n\tsdk.logging?.warn(message ? `Triggering fallback due to: ${message}` : 'Triggering fallback');\n\n\tif (!url) {\n\t\tconst error = new Error('No hosted URL provided');\n\t\tsdk.logging?.error('Fallback error', error);\n\t\tthrow error;\n\t}\n\n\temit('fallback', new FallbackError(new URL(url)));\n}\n\nfunction triggerClose(): void {\n\temit('close');\n}\n\nfunction setFormValue(formId: string, widgetId: string, value: unknown) {\n\tif (value === '') {\n\t\tvalue = null;\n\t}\n\n\tif (forms.value[formId] === undefined) {\n\t\tforms.value[formId] = {};\n\t}\n\n\tforms.value[formId][widgetId] = value;\n}\n\nfunction setMessage(formId: string, widgetId: string, value: LoginFlowMessage) {\n\tif (messages.value[formId] === undefined) {\n\t\tmessages.value[formId] = {};\n\t}\n\n\tmessages.value[formId][widgetId] = value;\n}\n\nasync function submitForm(formId: string): Promise<void> {\n\ttry {\n\t\tloading.value = true;\n\n\t\tconst data = await loginHandler.submitForm(formId, unflattenObject(forms.value[formId]));\n\t\tawait handleResponse(data);\n\n\t\tloading.value = false;\n\t} catch (error) {\n\t\tif (error instanceof FallbackError) {\n\t\t\temit('fallback', error);\n\t\t} else {\n\t\t\temit('error', error);\n\t\t}\n\t}\n}\n\nasync function handleResponse(data?: LoginFlowState) {\n\tif (await sdk.isAuthenticated) {\n\t\temit('login', sdk.idTokenClaims);\n\t} else {\n\t\tconst previousState = JSON.parse(JSON.stringify(state.value));\n\t\tconst newState: LoginFlowState = {\n\t\t\thostedUrl: data?.hostedUrl ?? state.value.hostedUrl,\n\t\t\tfinalizeUrl: data?.finalizeUrl ?? state.value.finalizeUrl,\n\t\t\tscreen: data?.screen ?? state.value.screen,\n\t\t\tforms: data?.forms ?? state.value.forms,\n\t\t\tlayout: data?.layout ?? state.value.layout,\n\t\t\tmessages: data?.messages ?? {},\n\t\t\tbranding: data?.branding ?? state.value.branding,\n\t\t};\n\n\t\tif (newState.screen != state.value.screen) {\n\t\t\tforms.value = {};\n\t\t\tmessages.value = {};\n\n\t\t\tfor (const form of newState.forms ?? []) {\n\t\t\t\tforms.value[form.id] = {};\n\t\t\t\tmessages.value[form.id] = {};\n\t\t\t}\n\t\t} else {\n\t\t\tsdk.logging?.info(`Updating screen: ${newState.screen}`);\n\t\t}\n\n\t\tObject.keys(newState.messages ?? {}).forEach((formId) => {\n\t\t\tif (formId === 'global') {\n\t\t\t\temit('globalMessage', newState.messages?.global?.text ?? '');\n\t\t\t} else {\n\t\t\t\tmessages.value[formId] = newState.messages![formId];\n\t\t\t}\n\t\t});\n\n\t\tstate.value = newState;\n\n\t\tsetTimeout(() => {\n\t\t\temit('blockReady', { previousState, state: JSON.parse(JSON.stringify(state.value)) });\n\t\t});\n\t}\n}\n</script>\n\n<template>\n\t<div class=\"login-renderer\">\n\t\t<component :is=\"widgets.layout\" v-if=\"state.screen\" :formId=\"(state.layout?.items[0] as Widget).formId\" :type=\"state.layout?.type\" tag=\"form\">\n\t\t\t<WidgetRenderer :items=\"state.layout?.items\" :widgets=\"widgets\" />\n\t\t</component>\n\t\t<component :is=\"widgets.loading\" v-else />\n\t</div>\n</template>\n"],"names":["sdk","useStrivacity","props","__props","emit","__emit","WidgetRenderer","defineComponent","item","form","state","widget","triggerFallback","component","h","loginHandler","loading","ref","forms","messages","provide","submitForm","triggerClose","setFormValue","setMessage","onMounted","data","handleResponse","error","FallbackError","hostedUrl","message","url","formId","widgetId","value","unflattenObject","previousState","newState","_openBlock","_createElementBlock","_hoisted_1","_createBlock","_resolveDynamicComponent","_createVNode","_unref"],"mappings":"6YAUA,KAAM,CAAE,IAAAA,CAAA,EAAQC,gBAAA,EAEVC,EAAQC,EAYRC,EAAOC,EAUPC,EAAiBC,EAAAA,gBAAgB,CACtC,MAAO,CACN,MAAO,CACN,KAAM,MACN,QAAS,IAAM,CAAA,CAAC,EAEjB,QAAS,CACR,KAAM,OACN,QAAS,KAAO,CAAA,EAAC,CAClB,EAED,MAAQL,GAAU,IACjBA,EAAM,MAAM,IAAKM,GAAuB,CACvC,GAAIA,EAAK,OAAS,SAAU,CAC3B,MAAMC,EAAOC,EAAM,OAAO,OAAO,KAAMD,GAASA,EAAK,KAAOD,EAAK,MAAM,EACjEG,EAASF,GAAM,QAAQ,KAAME,GAAWA,EAAO,KAAOH,EAAK,QAAQ,EAEzE,GAAI,CAACC,GAAQ,CAACE,EACb,OAAAC,EAAgB,OAAW,kDAAkDJ,EAAK,MAAM,cAAcA,EAAK,QAAQ,EAAE,EAC9G,KAGR,MAAMK,EAAYX,EAAM,QAAQS,EAAO,IAAI,EAE3C,OAAKE,EAKEC,EAAAA,EAAED,EAAW,CAAE,IAAK,GAAGJ,EAAK,EAAE,IAAIE,EAAO,EAAE,GAAI,OAAQF,EAAK,GAAI,OAAQE,EAAQ,GAJtFC,EAAgB,OAAW,sCAAsCD,EAAO,IAAI,EAAE,EACvE,KAIT,aAAWH,EAAK,OAAS,YAAcA,EAAK,OAAS,aAC/CN,EAAM,QAAQ,OAKZY,EAAAA,EAAEZ,EAAM,QAAQ,OAAQ,CAAE,OAASM,EAAK,MAAM,CAAC,EAAa,OAAQ,KAAMA,EAAK,IAAA,EAAQ,IAC7FM,EAAAA,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BU,EAAS,MAAMV,EAAK,EAAE,EAAI,CAAA,CAE5B,MACCT,EAAI,SAAS,KAAK,oBAAoBsC,EAAS,MAAM,EAAE,EAGxD,OAAO,KAAKA,EAAS,UAAY,CAAA,CAAE,EAAE,QAASL,GAAW,CACpDA,IAAW,SACd7B,EAAK,gBAAiBkC,EAAS,UAAU,QAAQ,MAAQ,EAAE,EAE3DnB,EAAS,MAAMc,CAAM,EAAIK,EAAS,SAAUL,CAAM,CAEpD,CAAC,EAEDvB,EAAM,MAAQ4B,EAEd,WAAW,IAAM,CAChBlC,EAAK,aAAc,CAAE,cAAAiC,EAAe,MAAO,KAAK,MAAM,KAAK,UAAU3B,EAAM,KAAK,CAAC,CAAA,CAAG,CACrF,CAAC,CACF,CACD,eAIC6B,YAAA,EAAAC,qBAKM,MALNC,EAKM,CAJiC/B,EAAA,MAAM,sBAA5CgC,cAEYC,EAAAA,wBAFIxC,EAAA,QAAQ,MAAM,EAAA,OAAuB,QAASO,EAAA,MAAM,QAAQ,UAAoB,OAAS,KAAMA,EAAA,MAAM,QAAQ,KAAM,IAAI,MAAA,qBACtI,IAAkE,CAAlEkC,cAAkEC,EAAAA,MAAAvC,CAAA,EAAA,CAAjD,MAAOI,EAAA,MAAM,QAAQ,MAAQ,QAASP,EAAA,OAAA,0EAExDuC,EAAAA,YAA0CC,EAAAA,wBAA1BxC,EAAA,QAAQ,OAAO,EAAA,CAAA,IAAA,EAAA,EAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{defineComponent as U,ref as
|
|
1
|
+
import{defineComponent as U,ref as d,h as m,provide as R,onMounted as x,createElementBlock as z,openBlock as v,createBlock as N,resolveDynamicComponent as S,withCtx as E,createVNode as J,unref as M}from"vue";import{FallbackError as y}from"@strivacity/sdk-core";import{unflattenObject as T}from"@strivacity/sdk-core/utils/object";import{useStrivacity as _}from"../composables.mjs";const j={class:"login-renderer"},D=U({__name:"login-renderer",props:{params:{default:()=>({})},widgets:{default:()=>({})},sessionId:{default:null}},emits:["login","fallback","close","error","globalMessage","blockReady"],setup(c,{emit:F}){const{sdk:i}=_(),w=c,s=F,p=U({props:{items:{type:Array,default:()=>[]},widgets:{type:Object,default:()=>({})}},setup:e=>()=>e.items.map(t=>{if(t.type==="widget"){const o=n.value?.forms?.find(g=>g.id===t.formId),l=o?.widgets.find(g=>g.id===t.widgetId);if(!o||!l)return u(void 0,`Unable to find form or widget for item: formId=${t.formId}, widgetId=${t.widgetId}`),null;const h=e.widgets[l.type];return h?m(h,{key:`${o.id}.${l.id}`,formId:o.id,config:l}):(u(void 0,`No component found for widget type ${l.type}`),null)}else return t.type==="vertical"||t.type==="horizontal"?e.widgets.layout?m(e.widgets.layout,{formId:t.items[0].formId,type:t.type},()=>m(p,{items:t.items,widgets:e.widgets})):(u(void 0,"No layout component provided"),null):(u(void 0,"Unknown item type in layout"),null)})}),b=i.login(w.params),f=d(!1),r=d({}),a=d({}),n=d({});R("nativeFlowContext",{loading:f,forms:r,messages:a,state:n,submitForm:C,triggerFallback:u,triggerClose:I,setFormValue:O,setMessage:$}),x(async()=>{try{const e=await b.startSession(w.sessionId);e&&await k(e)}catch(e){e instanceof y?s("fallback",e):s("error",e)}});function u(e,t){const o=e||n.value.hostedUrl;if(i.logging?.warn(t?`Triggering fallback due to: ${t}`:"Triggering fallback"),!o){const l=new Error("No hosted URL provided");throw i.logging?.error("Fallback error",l),l}s("fallback",new y(new URL(o)))}function I(){s("close")}function O(e,t,o){o===""&&(o=null),r.value[e]===void 0&&(r.value[e]={}),r.value[e][t]=o}function $(e,t,o){a.value[e]===void 0&&(a.value[e]={}),a.value[e][t]=o}async function C(e){try{f.value=!0;const t=await b.submitForm(e,T(r.value[e]));await k(t),f.value=!1}catch(t){t instanceof y?s("fallback",t):s("error",t)}}async function k(e){if(await i.isAuthenticated)s("login",i.idTokenClaims);else{const t=JSON.parse(JSON.stringify(n.value)),o={hostedUrl:e?.hostedUrl??n.value.hostedUrl,finalizeUrl:e?.finalizeUrl??n.value.finalizeUrl,screen:e?.screen??n.value.screen,forms:e?.forms??n.value.forms,layout:e?.layout??n.value.layout,messages:e?.messages??{},branding:e?.branding??n.value.branding};if(o.screen!=n.value.screen){r.value={},a.value={};for(const l of o.forms??[])r.value[l.id]={},a.value[l.id]={}}else i.logging?.info(`Updating screen: ${o.screen}`);Object.keys(o.messages??{}).forEach(l=>{l==="global"?s("globalMessage",o.messages?.global?.text??""):a.value[l]=o.messages[l]}),n.value=o,setTimeout(()=>{s("blockReady",{previousState:t,state:JSON.parse(JSON.stringify(n.value))})})}}return(e,t)=>(v(),z("div",j,[n.value.screen?(v(),N(S(c.widgets.layout),{key:0,formId:(n.value.layout?.items[0]).formId,type:n.value.layout?.type,tag:"form"},{default:E(()=>[J(M(p),{items:n.value.layout?.items,widgets:c.widgets},null,8,["items","widgets"])]),_:1},8,["formId","type"])):(v(),N(S(c.widgets.loading),{key:1}))]))}});export{D as _};
|
|
2
2
|
//# sourceMappingURL=login-renderer.vue_vue_type_script_setup_true_lang.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login-renderer.vue_vue_type_script_setup_true_lang.mjs","sources":["../../src/login-renderer.vue"],"sourcesContent":["<!-- eslint-disable no-console -->\n<script lang=\"ts\" setup>\nimport type { VNode, Component, PropType } from 'vue';\nimport type { PartialRecord, NativeParams, WidgetType, LayoutWidget, LoginFlowState, Widget, IdTokenClaims, LoginFlowMessage } from '@strivacity/sdk-core';\nimport type { NativeContext, NativeFlowContextValue } from './types';\nimport { defineComponent, provide, ref, h, onMounted } from 'vue';\nimport { FallbackError } from '@strivacity/sdk-core';\nimport { unflattenObject } from '@strivacity/sdk-core/utils/object';\nimport { useStrivacity } from './composables';\n\nconst { sdk } = useStrivacity<NativeContext>();\n\nconst props = withDefaults(\n\tdefineProps<{\n\t\tparams?: NativeParams;\n\t\twidgets?: PartialRecord<WidgetType, Component>;\n\t\tsessionId?: string | null;\n\t}>(),\n\t{\n\t\tparams: () => ({}),\n\t\twidgets: () => ({}),\n\t\tsessionId: null,\n\t},\n);\nconst emit = defineEmits<{\n\tlogin: [IdTokenClaims | null | undefined];\n\tfallback: [FallbackError];\n\tclose: [];\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\terror: [any];\n\tglobalMessage: [string];\n\tblockReady: [{ previousState: LoginFlowState; state: LoginFlowState }];\n}>();\n\nconst WidgetRenderer = defineComponent({\n\tprops: {\n\t\titems: {\n\t\t\ttype: Array as PropType<LayoutWidget['items']>,\n\t\t\tdefault: () => [],\n\t\t},\n\t\twidgets: {\n\t\t\ttype: Object as PropType<PartialRecord<WidgetType, Component>>,\n\t\t\tdefault: () => ({}),\n\t\t},\n\t},\n\tsetup: (props) => () =>\n\t\tprops.items.map((item): VNode | null => {\n\t\t\tif (item.type === 'widget') {\n\t\t\t\tconst form = state.value?.forms?.find((form) => form.id === item.formId);\n\t\t\t\tconst widget = form?.widgets.find((widget) => widget.id === item.widgetId);\n\n\t\t\t\tif (!form || !widget) {\n\t\t\t\t\ttriggerFallback();\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tconst component = props.widgets[widget.type];\n\n\t\t\t\tif (!component) {\n\t\t\t\t\ttriggerFallback();\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn h(component, { key: `${form.id}.${widget.id}`, formId: form.id, config: widget });\n\t\t\t} else if (item.type === 'vertical' || item.type === 'horizontal') {\n\t\t\t\tif (!props.widgets.layout) {\n\t\t\t\t\ttriggerFallback();\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn h(props.widgets.layout, { formId: (item.items[0] as Widget).formId, type: item.type }, () =>\n\t\t\t\t\th(WidgetRenderer, { items: item.items, widgets: props.widgets }),\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\ttriggerFallback();\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}),\n});\n\nconst loginHandler = sdk.login(props.params);\nconst loading = ref<boolean>(false);\nconst forms = ref<Record<string, Record<string, unknown>>>({});\nconst messages = ref<Record<string, Record<string, LoginFlowMessage>>>({});\nconst state = ref<LoginFlowState>({});\n\nprovide<NativeFlowContextValue>('nativeFlowContext', {\n\tloading,\n\tforms,\n\tmessages,\n\tstate,\n\tsubmitForm,\n\ttriggerFallback,\n\ttriggerClose,\n\tsetFormValue,\n\tsetMessage,\n});\n\nonMounted(async () => {\n\ttry {\n\t\tconst data = await loginHandler.startSession(props.sessionId);\n\n\t\tif (data) {\n\t\t\tawait handleResponse(data);\n\t\t}\n\t} catch (error) {\n\t\tif (error instanceof FallbackError) {\n\t\t\temit('fallback', error);\n\t\t} else {\n\t\t\temit('error', error);\n\t\t}\n\t}\n});\n\nfunction triggerFallback(hostedUrl?: string): void {\n\tconst url = hostedUrl || state.value.hostedUrl;\n\n\tif (!url) {\n\t\tthrow new Error('No hosted URL provided');\n\t}\n\n\temit('fallback', new FallbackError(new URL(url)));\n}\n\nfunction triggerClose(): void {\n\temit('close');\n}\n\nfunction setFormValue(formId: string, widgetId: string, value: unknown) {\n\tif (value === '') {\n\t\tvalue = null;\n\t}\n\n\tif (forms.value[formId] === undefined) {\n\t\tforms.value[formId] = {};\n\t}\n\n\tforms.value[formId][widgetId] = value;\n}\n\nfunction setMessage(formId: string, widgetId: string, value: LoginFlowMessage) {\n\tif (messages.value[formId] === undefined) {\n\t\tmessages.value[formId] = {};\n\t}\n\n\tmessages.value[formId][widgetId] = value;\n}\n\nasync function submitForm(formId: string): Promise<void> {\n\ttry {\n\t\tloading.value = true;\n\n\t\tconst data = await loginHandler.submitForm(formId, unflattenObject(forms.value[formId]));\n\t\tawait handleResponse(data);\n\n\t\tloading.value = false;\n\t} catch (error) {\n\t\tif (error instanceof FallbackError) {\n\t\t\temit('fallback', error);\n\t\t} else {\n\t\t\temit('error', error);\n\t\t}\n\t}\n}\n\nasync function handleResponse(data?: LoginFlowState) {\n\tif (await sdk.isAuthenticated) {\n\t\temit('login', sdk.idTokenClaims);\n\t} else {\n\t\tconst previousState = JSON.parse(JSON.stringify(state.value));\n\t\tconst newState: LoginFlowState = {\n\t\t\thostedUrl: data?.hostedUrl ?? state.value.hostedUrl,\n\t\t\tfinalizeUrl: data?.finalizeUrl ?? state.value.finalizeUrl,\n\t\t\tscreen: data?.screen ?? state.value.screen,\n\t\t\tforms: data?.forms ?? state.value.forms,\n\t\t\tlayout: data?.layout ?? state.value.layout,\n\t\t\tmessages: data?.messages ?? state.value.messages,\n\t\t\tbranding: data?.branding ?? state.value.branding,\n\t\t};\n\n\t\tif (newState.screen != state.value.screen) {\n\t\t\tforms.value = {};\n\t\t\tmessages.value = {};\n\n\t\t\tfor (const form of newState.forms ?? []) {\n\t\t\t\tforms.value[form.id] = {};\n\t\t\t\tmessages.value[form.id] = {};\n\t\t\t}\n\t\t}\n\n\t\tObject.keys(newState.messages ?? {}).forEach((formId) => {\n\t\t\tif (formId === 'global') {\n\t\t\t\temit('globalMessage', newState.messages?.global?.text ?? '');\n\t\t\t} else {\n\t\t\t\tmessages.value[formId] = newState.messages![formId];\n\t\t\t}\n\t\t});\n\n\t\tstate.value = newState;\n\n\t\tsetTimeout(() => {\n\t\t\temit('blockReady', { previousState, state: JSON.parse(JSON.stringify(state.value)) });\n\t\t});\n\t}\n}\n</script>\n\n<template>\n\t<div class=\"login-renderer\">\n\t\t<component :is=\"widgets.layout\" v-if=\"state.screen\" :formId=\"(state.layout?.items[0] as Widget).formId\" :type=\"state.layout?.type\" tag=\"form\">\n\t\t\t<WidgetRenderer :items=\"state.layout?.items\" :widgets=\"widgets\" />\n\t\t</component>\n\t\t<component :is=\"widgets.loading\" v-else />\n\t</div>\n</template>\n"],"names":["sdk","useStrivacity","props","__props","emit","__emit","WidgetRenderer","defineComponent","item","form","state","widget","triggerFallback","component","h","loginHandler","loading","ref","forms","messages","provide","submitForm","triggerClose","setFormValue","setMessage","onMounted","data","handleResponse","error","FallbackError","hostedUrl","url","formId","widgetId","value","unflattenObject","previousState","newState","_openBlock","_createElementBlock","_hoisted_1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AMA,EAAA,MAAM,QAAQ,KAAM,IAAI,MAAA,aACtI,IAAkE,CAAlEiC,EAAkEC,EAAAtC,CAAA,EAAA,CAAjD,MAAOI,EAAA,MAAM,QAAQ,MAAQ,QAASP,EAAA,OAAA,gEAExDsC,EAA0CC,EAA1BvC,EAAA,QAAQ,OAAO,EAAA,CAAA,IAAA,EAAA,EAAA"}
|
|
1
|
+
{"version":3,"file":"login-renderer.vue_vue_type_script_setup_true_lang.mjs","sources":["../../src/login-renderer.vue"],"sourcesContent":["<!-- eslint-disable no-console -->\n<script lang=\"ts\" setup>\nimport type { VNode, Component, PropType } from 'vue';\nimport type { PartialRecord, NativeParams, WidgetType, LayoutWidget, LoginFlowState, Widget, IdTokenClaims, LoginFlowMessage } from '@strivacity/sdk-core';\nimport type { NativeContext, NativeFlowContextValue } from './types';\nimport { defineComponent, provide, ref, h, onMounted } from 'vue';\nimport { FallbackError } from '@strivacity/sdk-core';\nimport { unflattenObject } from '@strivacity/sdk-core/utils/object';\nimport { useStrivacity } from './composables';\n\nconst { sdk } = useStrivacity<NativeContext>();\n\nconst props = withDefaults(\n\tdefineProps<{\n\t\tparams?: NativeParams;\n\t\twidgets?: PartialRecord<WidgetType, Component>;\n\t\tsessionId?: string | null;\n\t}>(),\n\t{\n\t\tparams: () => ({}),\n\t\twidgets: () => ({}),\n\t\tsessionId: null,\n\t},\n);\nconst emit = defineEmits<{\n\tlogin: [IdTokenClaims | null | undefined];\n\tfallback: [FallbackError];\n\tclose: [];\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\terror: [any];\n\tglobalMessage: [string];\n\tblockReady: [{ previousState: LoginFlowState; state: LoginFlowState }];\n}>();\n\nconst WidgetRenderer = defineComponent({\n\tprops: {\n\t\titems: {\n\t\t\ttype: Array as PropType<LayoutWidget['items']>,\n\t\t\tdefault: () => [],\n\t\t},\n\t\twidgets: {\n\t\t\ttype: Object as PropType<PartialRecord<WidgetType, Component>>,\n\t\t\tdefault: () => ({}),\n\t\t},\n\t},\n\tsetup: (props) => () =>\n\t\tprops.items.map((item): VNode | null => {\n\t\t\tif (item.type === 'widget') {\n\t\t\t\tconst form = state.value?.forms?.find((form) => form.id === item.formId);\n\t\t\t\tconst widget = form?.widgets.find((widget) => widget.id === item.widgetId);\n\n\t\t\t\tif (!form || !widget) {\n\t\t\t\t\ttriggerFallback(undefined, `Unable to find form or widget for item: formId=${item.formId}, widgetId=${item.widgetId}`);\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tconst component = props.widgets[widget.type];\n\n\t\t\t\tif (!component) {\n\t\t\t\t\ttriggerFallback(undefined, `No component found for widget type ${widget.type}`);\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn h(component, { key: `${form.id}.${widget.id}`, formId: form.id, config: widget });\n\t\t\t} else if (item.type === 'vertical' || item.type === 'horizontal') {\n\t\t\t\tif (!props.widgets.layout) {\n\t\t\t\t\ttriggerFallback(undefined, 'No layout component provided');\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn h(props.widgets.layout, { formId: (item.items[0] as Widget).formId, type: item.type }, () =>\n\t\t\t\t\th(WidgetRenderer, { items: item.items, widgets: props.widgets }),\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\ttriggerFallback(undefined, 'Unknown item type in layout');\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}),\n});\n\nconst loginHandler = sdk.login(props.params);\nconst loading = ref<boolean>(false);\nconst forms = ref<Record<string, Record<string, unknown>>>({});\nconst messages = ref<Record<string, Record<string, LoginFlowMessage>>>({});\nconst state = ref<LoginFlowState>({});\n\nprovide<NativeFlowContextValue>('nativeFlowContext', {\n\tloading,\n\tforms,\n\tmessages,\n\tstate,\n\tsubmitForm,\n\ttriggerFallback,\n\ttriggerClose,\n\tsetFormValue,\n\tsetMessage,\n});\n\nonMounted(async () => {\n\ttry {\n\t\tconst data = await loginHandler.startSession(props.sessionId);\n\n\t\tif (data) {\n\t\t\tawait handleResponse(data);\n\t\t}\n\t} catch (error) {\n\t\tif (error instanceof FallbackError) {\n\t\t\temit('fallback', error);\n\t\t} else {\n\t\t\temit('error', error);\n\t\t}\n\t}\n});\n\nfunction triggerFallback(hostedUrl?: string, message?: string): void {\n\tconst url = hostedUrl || state.value.hostedUrl;\n\n\tsdk.logging?.warn(message ? `Triggering fallback due to: ${message}` : 'Triggering fallback');\n\n\tif (!url) {\n\t\tconst error = new Error('No hosted URL provided');\n\t\tsdk.logging?.error('Fallback error', error);\n\t\tthrow error;\n\t}\n\n\temit('fallback', new FallbackError(new URL(url)));\n}\n\nfunction triggerClose(): void {\n\temit('close');\n}\n\nfunction setFormValue(formId: string, widgetId: string, value: unknown) {\n\tif (value === '') {\n\t\tvalue = null;\n\t}\n\n\tif (forms.value[formId] === undefined) {\n\t\tforms.value[formId] = {};\n\t}\n\n\tforms.value[formId][widgetId] = value;\n}\n\nfunction setMessage(formId: string, widgetId: string, value: LoginFlowMessage) {\n\tif (messages.value[formId] === undefined) {\n\t\tmessages.value[formId] = {};\n\t}\n\n\tmessages.value[formId][widgetId] = value;\n}\n\nasync function submitForm(formId: string): Promise<void> {\n\ttry {\n\t\tloading.value = true;\n\n\t\tconst data = await loginHandler.submitForm(formId, unflattenObject(forms.value[formId]));\n\t\tawait handleResponse(data);\n\n\t\tloading.value = false;\n\t} catch (error) {\n\t\tif (error instanceof FallbackError) {\n\t\t\temit('fallback', error);\n\t\t} else {\n\t\t\temit('error', error);\n\t\t}\n\t}\n}\n\nasync function handleResponse(data?: LoginFlowState) {\n\tif (await sdk.isAuthenticated) {\n\t\temit('login', sdk.idTokenClaims);\n\t} else {\n\t\tconst previousState = JSON.parse(JSON.stringify(state.value));\n\t\tconst newState: LoginFlowState = {\n\t\t\thostedUrl: data?.hostedUrl ?? state.value.hostedUrl,\n\t\t\tfinalizeUrl: data?.finalizeUrl ?? state.value.finalizeUrl,\n\t\t\tscreen: data?.screen ?? state.value.screen,\n\t\t\tforms: data?.forms ?? state.value.forms,\n\t\t\tlayout: data?.layout ?? state.value.layout,\n\t\t\tmessages: data?.messages ?? {},\n\t\t\tbranding: data?.branding ?? state.value.branding,\n\t\t};\n\n\t\tif (newState.screen != state.value.screen) {\n\t\t\tforms.value = {};\n\t\t\tmessages.value = {};\n\n\t\t\tfor (const form of newState.forms ?? []) {\n\t\t\t\tforms.value[form.id] = {};\n\t\t\t\tmessages.value[form.id] = {};\n\t\t\t}\n\t\t} else {\n\t\t\tsdk.logging?.info(`Updating screen: ${newState.screen}`);\n\t\t}\n\n\t\tObject.keys(newState.messages ?? {}).forEach((formId) => {\n\t\t\tif (formId === 'global') {\n\t\t\t\temit('globalMessage', newState.messages?.global?.text ?? '');\n\t\t\t} else {\n\t\t\t\tmessages.value[formId] = newState.messages![formId];\n\t\t\t}\n\t\t});\n\n\t\tstate.value = newState;\n\n\t\tsetTimeout(() => {\n\t\t\temit('blockReady', { previousState, state: JSON.parse(JSON.stringify(state.value)) });\n\t\t});\n\t}\n}\n</script>\n\n<template>\n\t<div class=\"login-renderer\">\n\t\t<component :is=\"widgets.layout\" v-if=\"state.screen\" :formId=\"(state.layout?.items[0] as Widget).formId\" :type=\"state.layout?.type\" tag=\"form\">\n\t\t\t<WidgetRenderer :items=\"state.layout?.items\" :widgets=\"widgets\" />\n\t\t</component>\n\t\t<component :is=\"widgets.loading\" v-else />\n\t</div>\n</template>\n"],"names":["sdk","useStrivacity","props","__props","emit","__emit","WidgetRenderer","defineComponent","item","form","state","widget","triggerFallback","component","h","loginHandler","loading","ref","forms","messages","provide","submitForm","triggerClose","setFormValue","setMessage","onMounted","data","handleResponse","error","FallbackError","hostedUrl","message","url","formId","widgetId","value","unflattenObject","previousState","newState","_openBlock","_createElementBlock","_hoisted_1","_createBlock","_resolveDynamicComponent","_createVNode","_unref"],"mappings":"0mBAUA,KAAM,CAAE,IAAAA,CAAA,EAAQC,EAAA,EAEVC,EAAQC,EAYRC,EAAOC,EAUPC,EAAiBC,EAAgB,CACtC,MAAO,CAC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rF,CAAC,CACF,CACD,eAIC6B,EAAA,EAAAC,EAKM,MALNC,EAKM,CAJiC/B,EAAA,MAAM,YAA5CgC,EAEYC,EAFIxC,EAAA,QAAQ,MAAM,EAAA,OAAuB,QAASO,EAAA,MAAM,QAAQ,UAAoB,OAAS,KAAMA,EAAA,MAAM,QAAQ,KAAM,IAAI,MAAA,aACtI,IAAkE,CAAlEkC,EAAkEC,EAAAvC,CAAA,EAAA,CAAjD,MAAOI,EAAA,MAAM,QAAQ,MAAQ,QAASP,EAAA,OAAA,gEAExDuC,EAA0CC,EAA1BxC,EAAA,QAAQ,OAAO,EAAA,CAAA,IAAA,EAAA,EAAA"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("vue"),o=require("@strivacity/sdk-core"),y=require("@strivacity/sdk-core/utils/HttpClient"),T=require("@strivacity/sdk-core/utils/Logging"),k=require("@strivacity/sdk-core/storages/LocalStorage"),S=require("@strivacity/sdk-core/storages/SessionStorage"),b=require("./composables.cjs"),h=require("./assets/login-renderer.vue_vue_type_script_setup_true_lang.cjs"),v=require("@strivacity/sdk-core/utils/credentials");require("@strivacity/sdk-core/utils/object");exports.isAuthenticated=()=>Promise.resolve(!1);const m=i=>{const e=o.initFlow(i);return{install:s=>{const a=r.ref(!0),p=r.ref(e.options),c=r.ref(!1),l=r.ref(null),u=r.ref(null),d=r.ref(null),g=r.ref(!0),f=r.ref(null),t=async()=>{c.value=await e.isAuthenticated,l.value=e.idTokenClaims||null,u.value=e.accessToken||null,d.value=e.refreshToken||null,g.value=e.accessTokenExpired,f.value=e.accessTokenExpirationDate||null,a.value&&(a.value=!1)};exports.isAuthenticated=()=>e.isAuthenticated,e.subscribeToEvent("init",t),e.subscribeToEvent("loggedIn",t),e.subscribeToEvent("sessionLoaded",t),e.subscribeToEvent("tokenRefreshed",t),e.subscribeToEvent("tokenRefreshFailed",t),e.subscribeToEvent("logoutInitiated",t),e.subscribeToEvent("tokenRevoked",t),e.subscribeToEvent("tokenRevokeFailed",t),s.component("StyLoginRenderer",h._sfc_main),s.provide(b.STRIVACITY_SDK,{sdk:e,loading:a,options:p,isAuthenticated:c,idTokenClaims:l,accessToken:u,refreshToken:d,accessTokenExpired:g,accessTokenExpirationDate:f,login:async n=>{if(e.options.mode==="native")return e.login(n);await e.login(n),await t()},register:async n=>{if(e.options.mode==="native")return e.register(n);await e.register(n),await t()},entry:async n=>await e.entry(n),refresh:async()=>{await e.refresh(),await t()},revoke:async()=>{await e.revoke(),await t()},logout:async n=>{await e.logout(n),await t()},handleCallback:async n=>{await e.handleCallback(n),await t()}})}}};Object.defineProperty(exports,"HttpClient",{enumerable:!0,get:()=>y.HttpClient});Object.defineProperty(exports,"DefaultLogging",{enumerable:!0,get:()=>T.DefaultLogging});Object.defineProperty(exports,"LocalStorage",{enumerable:!0,get:()=>k.LocalStorage});Object.defineProperty(exports,"SessionStorage",{enumerable:!0,get:()=>S.SessionStorage});exports.useStrivacity=b.useStrivacity;Object.defineProperty(exports,"createCredential",{enumerable:!0,get:()=>v.createCredential});Object.defineProperty(exports,"getCredential",{enumerable:!0,get:()=>v.getCredential});exports.createStrivacitySDK=m;Object.keys(o).forEach(i=>{i!=="default"&&!Object.prototype.hasOwnProperty.call(exports,i)&&Object.defineProperty(exports,i,{enumerable:!0,get:()=>o[i]})});
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import type { IdTokenClaims, SDKOptions } from '@strivacity/sdk-core';\nimport type { PopupFlow } from '@strivacity/sdk-core/flows/PopupFlow';\nimport type { RedirectFlow } from '@strivacity/sdk-core/flows/RedirectFlow';\nimport type { NativeFlow } from '@strivacity/sdk-core/flows/NativeFlow';\nimport { type App, ref } from 'vue';\nimport { initFlow } from '@strivacity/sdk-core';\nimport { HttpClient } from '@strivacity/sdk-core/utils/HttpClient';\nimport { LocalStorage } from '@strivacity/sdk-core/storages/LocalStorage';\nimport { SessionStorage } from '@strivacity/sdk-core/storages/SessionStorage';\nimport { STRIVACITY_SDK, useStrivacity } from './composables';\nimport LoginRendererComponent from './login-renderer.vue';\n\nexport * from '@strivacity/sdk-core';\nexport { createCredential, getCredential } from '@strivacity/sdk-core/utils/credentials';\nexport type * from './types';\nexport type { PopupFlow, RedirectFlow, NativeFlow };\nexport { HttpClient, LocalStorage, SessionStorage, useStrivacity };\n\n/**\n * Checks if the user is authenticated.\n *\n * @returns {Promise<boolean>} A promise that resolves to `true` if the user is authenticated, otherwise `false`.\n */\nexport let isAuthenticated: () => Promise<boolean> = () => Promise.resolve(false);\n\n/**\n * Creates a Strivacity SDK plugin for Vue.\n *\n * @param {SDKOptions} options - The options used to configure the SDK.\n *\n * @returns {Plugin} A Vue plugin that can be installed in the application.\n */\nexport const createStrivacitySDK = (options: SDKOptions) => {\n\tconst sdk = initFlow(options);\n\n\tconst plugin = {\n\t\tinstall: (app: App) => {\n\t\t\tconst loadingRef = ref<boolean>(true);\n\t\t\tconst optionsRef = ref<SDKOptions>(sdk.options);\n\t\t\tconst isAuthenticatedRef = ref<boolean>(false);\n\t\t\tconst idTokenClaimsRef = ref<IdTokenClaims | null>(null);\n\t\t\tconst accessTokenRef = ref<string | null>(null);\n\t\t\tconst refreshTokenRef = ref<string | null>(null);\n\t\t\tconst accessTokenExpiredRef = ref<boolean>(true);\n\t\t\tconst accessTokenExpirationDateRef = ref<number | null>(null);\n\n\t\t\tconst updateSession = async () => {\n\t\t\t\tisAuthenticatedRef.value = await sdk.isAuthenticated;\n\t\t\t\tidTokenClaimsRef.value = sdk.idTokenClaims || null;\n\t\t\t\taccessTokenRef.value = sdk.accessToken || null;\n\t\t\t\trefreshTokenRef.value = sdk.refreshToken || null;\n\t\t\t\taccessTokenExpiredRef.value = sdk.accessTokenExpired;\n\t\t\t\taccessTokenExpirationDateRef.value = sdk.accessTokenExpirationDate || null;\n\n\t\t\t\tif (loadingRef.value) {\n\t\t\t\t\tloadingRef.value = false;\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tisAuthenticated = () => sdk.isAuthenticated;\n\n\t\t\tsdk.subscribeToEvent('init', updateSession);\n\t\t\tsdk.subscribeToEvent('loggedIn', updateSession);\n\t\t\tsdk.subscribeToEvent('sessionLoaded', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRefreshed', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRefreshFailed', updateSession);\n\t\t\tsdk.subscribeToEvent('logoutInitiated', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRevoked', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRevokeFailed', updateSession);\n\n\t\t\tapp.component('StyLoginRenderer', LoginRendererComponent);\n\t\t\tapp.provide(STRIVACITY_SDK, {\n\t\t\t\tsdk: sdk,\n\t\t\t\tloading: loadingRef,\n\t\t\t\toptions: optionsRef,\n\t\t\t\tisAuthenticated: isAuthenticatedRef,\n\t\t\t\tidTokenClaims: idTokenClaimsRef,\n\t\t\t\taccessToken: accessTokenRef,\n\t\t\t\trefreshToken: refreshTokenRef,\n\t\t\t\taccessTokenExpired: accessTokenExpiredRef,\n\t\t\t\taccessTokenExpirationDate: accessTokenExpirationDateRef,\n\n\t\t\t\tlogin: async (options?: Parameters<PopupFlow['login'] | RedirectFlow['login'] | NativeFlow['login']>[0]) => {\n\t\t\t\t\tif (sdk.options.mode === 'native') {\n\t\t\t\t\t\treturn sdk.login(options);\n\t\t\t\t\t}\n\n\t\t\t\t\tawait sdk.login(options);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\tregister: async (options?: Parameters<PopupFlow['register'] | RedirectFlow['register'] | NativeFlow['register']>[0]) => {\n\t\t\t\t\tif (sdk.options.mode === 'native') {\n\t\t\t\t\t\treturn sdk.register(options);\n\t\t\t\t\t}\n\n\t\t\t\t\tawait sdk.register(options);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\tentry: async (url?: string) => {\n\t\t\t\t\treturn await sdk.entry(url);\n\t\t\t\t},\n\t\t\t\trefresh: async () => {\n\t\t\t\t\tawait sdk.refresh();\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\trevoke: async () => {\n\t\t\t\t\tawait sdk.revoke();\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\tlogout: async (options?: Parameters<PopupFlow['logout'] | RedirectFlow['logout']>[0]) => {\n\t\t\t\t\tawait sdk.logout(options);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\thandleCallback: async (url?: Parameters<PopupFlow['handleCallback'] | RedirectFlow['handleCallback'] | NativeFlow['handleCallback']>[0]) => {\n\t\t\t\t\tawait sdk.handleCallback(url);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t};\n\n\treturn plugin;\n};\n"],"names":["isAuthenticated","createStrivacitySDK","options","sdk","initFlow","app","loadingRef","ref","optionsRef","isAuthenticatedRef","idTokenClaimsRef","accessTokenRef","refreshTokenRef","accessTokenExpiredRef","accessTokenExpirationDateRef","updateSession","LoginRendererComponent","STRIVACITY_SDK","url"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import type { IdTokenClaims, SDKOptions } from '@strivacity/sdk-core';\nimport type { PopupFlow } from '@strivacity/sdk-core/flows/PopupFlow';\nimport type { RedirectFlow } from '@strivacity/sdk-core/flows/RedirectFlow';\nimport type { NativeFlow } from '@strivacity/sdk-core/flows/NativeFlow';\nimport { type App, ref } from 'vue';\nimport { initFlow } from '@strivacity/sdk-core';\nimport { HttpClient } from '@strivacity/sdk-core/utils/HttpClient';\nimport { DefaultLogging } from '@strivacity/sdk-core/utils/Logging';\nimport { LocalStorage } from '@strivacity/sdk-core/storages/LocalStorage';\nimport { SessionStorage } from '@strivacity/sdk-core/storages/SessionStorage';\nimport { STRIVACITY_SDK, useStrivacity } from './composables';\nimport LoginRendererComponent from './login-renderer.vue';\n\nexport * from '@strivacity/sdk-core';\nexport { createCredential, getCredential } from '@strivacity/sdk-core/utils/credentials';\nexport type * from './types';\nexport type { PopupFlow, RedirectFlow, NativeFlow };\nexport { HttpClient, DefaultLogging, LocalStorage, SessionStorage, useStrivacity };\n\n/**\n * Checks if the user is authenticated.\n *\n * @returns {Promise<boolean>} A promise that resolves to `true` if the user is authenticated, otherwise `false`.\n */\nexport let isAuthenticated: () => Promise<boolean> = () => Promise.resolve(false);\n\n/**\n * Creates a Strivacity SDK plugin for Vue.\n *\n * @param {SDKOptions} options - The options used to configure the SDK.\n *\n * @returns {Plugin} A Vue plugin that can be installed in the application.\n */\nexport const createStrivacitySDK = (options: SDKOptions) => {\n\tconst sdk = initFlow(options);\n\n\tconst plugin = {\n\t\tinstall: (app: App) => {\n\t\t\tconst loadingRef = ref<boolean>(true);\n\t\t\tconst optionsRef = ref<SDKOptions>(sdk.options);\n\t\t\tconst isAuthenticatedRef = ref<boolean>(false);\n\t\t\tconst idTokenClaimsRef = ref<IdTokenClaims | null>(null);\n\t\t\tconst accessTokenRef = ref<string | null>(null);\n\t\t\tconst refreshTokenRef = ref<string | null>(null);\n\t\t\tconst accessTokenExpiredRef = ref<boolean>(true);\n\t\t\tconst accessTokenExpirationDateRef = ref<number | null>(null);\n\n\t\t\tconst updateSession = async () => {\n\t\t\t\tisAuthenticatedRef.value = await sdk.isAuthenticated;\n\t\t\t\tidTokenClaimsRef.value = sdk.idTokenClaims || null;\n\t\t\t\taccessTokenRef.value = sdk.accessToken || null;\n\t\t\t\trefreshTokenRef.value = sdk.refreshToken || null;\n\t\t\t\taccessTokenExpiredRef.value = sdk.accessTokenExpired;\n\t\t\t\taccessTokenExpirationDateRef.value = sdk.accessTokenExpirationDate || null;\n\n\t\t\t\tif (loadingRef.value) {\n\t\t\t\t\tloadingRef.value = false;\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tisAuthenticated = () => sdk.isAuthenticated;\n\n\t\t\tsdk.subscribeToEvent('init', updateSession);\n\t\t\tsdk.subscribeToEvent('loggedIn', updateSession);\n\t\t\tsdk.subscribeToEvent('sessionLoaded', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRefreshed', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRefreshFailed', updateSession);\n\t\t\tsdk.subscribeToEvent('logoutInitiated', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRevoked', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRevokeFailed', updateSession);\n\n\t\t\tapp.component('StyLoginRenderer', LoginRendererComponent);\n\t\t\tapp.provide(STRIVACITY_SDK, {\n\t\t\t\tsdk: sdk,\n\t\t\t\tloading: loadingRef,\n\t\t\t\toptions: optionsRef,\n\t\t\t\tisAuthenticated: isAuthenticatedRef,\n\t\t\t\tidTokenClaims: idTokenClaimsRef,\n\t\t\t\taccessToken: accessTokenRef,\n\t\t\t\trefreshToken: refreshTokenRef,\n\t\t\t\taccessTokenExpired: accessTokenExpiredRef,\n\t\t\t\taccessTokenExpirationDate: accessTokenExpirationDateRef,\n\n\t\t\t\tlogin: async (options?: Parameters<PopupFlow['login'] | RedirectFlow['login'] | NativeFlow['login']>[0]) => {\n\t\t\t\t\tif (sdk.options.mode === 'native') {\n\t\t\t\t\t\treturn sdk.login(options);\n\t\t\t\t\t}\n\n\t\t\t\t\tawait sdk.login(options);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\tregister: async (options?: Parameters<PopupFlow['register'] | RedirectFlow['register'] | NativeFlow['register']>[0]) => {\n\t\t\t\t\tif (sdk.options.mode === 'native') {\n\t\t\t\t\t\treturn sdk.register(options);\n\t\t\t\t\t}\n\n\t\t\t\t\tawait sdk.register(options);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\tentry: async (url?: string) => {\n\t\t\t\t\treturn await sdk.entry(url);\n\t\t\t\t},\n\t\t\t\trefresh: async () => {\n\t\t\t\t\tawait sdk.refresh();\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\trevoke: async () => {\n\t\t\t\t\tawait sdk.revoke();\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\tlogout: async (options?: Parameters<PopupFlow['logout'] | RedirectFlow['logout']>[0]) => {\n\t\t\t\t\tawait sdk.logout(options);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\thandleCallback: async (url?: Parameters<PopupFlow['handleCallback'] | RedirectFlow['handleCallback'] | NativeFlow['handleCallback']>[0]) => {\n\t\t\t\t\tawait sdk.handleCallback(url);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t};\n\n\treturn plugin;\n};\n"],"names":["isAuthenticated","createStrivacitySDK","options","sdk","initFlow","app","loadingRef","ref","optionsRef","isAuthenticatedRef","idTokenClaimsRef","accessTokenRef","refreshTokenRef","accessTokenExpiredRef","accessTokenExpirationDateRef","updateSession","LoginRendererComponent","STRIVACITY_SDK","url"],"mappings":"2iBAwBWA,QAAAA,gBAA0C,IAAM,QAAQ,QAAQ,EAAK,EASzE,MAAMC,EAAuBC,GAAwB,CAC3D,MAAMC,EAAMC,EAAAA,SAASF,CAAO,EAwF5B,MAtFe,CACd,QAAUG,GAAa,CACtB,MAAMC,EAAaC,EAAAA,IAAa,EAAI,EAC9BC,EAAaD,EAAAA,IAAgBJ,EAAI,OAAO,EACxCM,EAAqBF,EAAAA,IAAa,EAAK,EACvCG,EAAmBH,EAAAA,IAA0B,IAAI,EACjDI,EAAiBJ,EAAAA,IAAmB,IAAI,EACxCK,EAAkBL,EAAAA,IAAmB,IAAI,EACzCM,EAAwBN,EAAAA,IAAa,EAAI,EACzCO,EAA+BP,EAAAA,IAAmB,IAAI,EAEtDQ,EAAgB,SAAY,CAC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ACV,MAAMY,EAAA,CACP,EACA,OAAQ,MAAOb,GAA0E,CACxF,MAAMC,EAAI,OAAOD,CAAO,EACxB,MAAMa,EAAA,CACP,EACA,eAAgB,MAAOG,GAAqH,CAC3I,MAAMf,EAAI,eAAee,CAAG,EAC5B,MAAMH,EAAA,CACP,CAAA,CACA,CACF,CAAA,CAIF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { RedirectFlow } from '@strivacity/sdk-core/flows/RedirectFlow';
|
|
|
4
4
|
import { NativeFlow } from '@strivacity/sdk-core/flows/NativeFlow';
|
|
5
5
|
import { App } from 'vue';
|
|
6
6
|
import { HttpClient } from '@strivacity/sdk-core/utils/HttpClient';
|
|
7
|
+
import { DefaultLogging } from '@strivacity/sdk-core/utils/Logging';
|
|
7
8
|
import { LocalStorage } from '@strivacity/sdk-core/storages/LocalStorage';
|
|
8
9
|
import { SessionStorage } from '@strivacity/sdk-core/storages/SessionStorage';
|
|
9
10
|
import { useStrivacity } from './composables';
|
|
@@ -11,7 +12,7 @@ export * from '@strivacity/sdk-core';
|
|
|
11
12
|
export { createCredential, getCredential } from '@strivacity/sdk-core/utils/credentials';
|
|
12
13
|
export type * from './types';
|
|
13
14
|
export type { PopupFlow, RedirectFlow, NativeFlow };
|
|
14
|
-
export { HttpClient, LocalStorage, SessionStorage, useStrivacity };
|
|
15
|
+
export { HttpClient, DefaultLogging, LocalStorage, SessionStorage, useStrivacity };
|
|
15
16
|
/**
|
|
16
17
|
* Checks if the user is authenticated.
|
|
17
18
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ref as n}from"vue";import{initFlow as
|
|
1
|
+
import{ref as n}from"vue";import{initFlow as p}from"@strivacity/sdk-core";export*from"@strivacity/sdk-core";import{HttpClient as A}from"@strivacity/sdk-core/utils/HttpClient";import{DefaultLogging as I}from"@strivacity/sdk-core/utils/Logging";import{LocalStorage as _}from"@strivacity/sdk-core/storages/LocalStorage";import{SessionStorage as K}from"@strivacity/sdk-core/storages/SessionStorage";import{STRIVACITY_SDK as v}from"./composables.mjs";import{useStrivacity as P}from"./composables.mjs";import{_ as T}from"./assets/login-renderer.vue_vue_type_script_setup_true_lang.mjs";import{createCredential as Y,getCredential as j}from"@strivacity/sdk-core/utils/credentials";import"@strivacity/sdk-core/utils/object";let m=()=>Promise.resolve(!1);const R=d=>{const e=p(d);return{install:i=>{const a=n(!0),k=n(e.options),s=n(!1),r=n(null),c=n(null),l=n(null),u=n(!0),f=n(null),t=async()=>{s.value=await e.isAuthenticated,r.value=e.idTokenClaims||null,c.value=e.accessToken||null,l.value=e.refreshToken||null,u.value=e.accessTokenExpired,f.value=e.accessTokenExpirationDate||null,a.value&&(a.value=!1)};m=()=>e.isAuthenticated,e.subscribeToEvent("init",t),e.subscribeToEvent("loggedIn",t),e.subscribeToEvent("sessionLoaded",t),e.subscribeToEvent("tokenRefreshed",t),e.subscribeToEvent("tokenRefreshFailed",t),e.subscribeToEvent("logoutInitiated",t),e.subscribeToEvent("tokenRevoked",t),e.subscribeToEvent("tokenRevokeFailed",t),i.component("StyLoginRenderer",T),i.provide(v,{sdk:e,loading:a,options:k,isAuthenticated:s,idTokenClaims:r,accessToken:c,refreshToken:l,accessTokenExpired:u,accessTokenExpirationDate:f,login:async o=>{if(e.options.mode==="native")return e.login(o);await e.login(o),await t()},register:async o=>{if(e.options.mode==="native")return e.register(o);await e.register(o),await t()},entry:async o=>await e.entry(o),refresh:async()=>{await e.refresh(),await t()},revoke:async()=>{await e.revoke(),await t()},logout:async o=>{await e.logout(o),await t()},handleCallback:async o=>{await e.handleCallback(o),await t()}})}}};export{I as DefaultLogging,A as HttpClient,_ as LocalStorage,K as SessionStorage,Y as createCredential,R as createStrivacitySDK,j as getCredential,m as isAuthenticated,P as useStrivacity};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import type { IdTokenClaims, SDKOptions } from '@strivacity/sdk-core';\nimport type { PopupFlow } from '@strivacity/sdk-core/flows/PopupFlow';\nimport type { RedirectFlow } from '@strivacity/sdk-core/flows/RedirectFlow';\nimport type { NativeFlow } from '@strivacity/sdk-core/flows/NativeFlow';\nimport { type App, ref } from 'vue';\nimport { initFlow } from '@strivacity/sdk-core';\nimport { HttpClient } from '@strivacity/sdk-core/utils/HttpClient';\nimport { LocalStorage } from '@strivacity/sdk-core/storages/LocalStorage';\nimport { SessionStorage } from '@strivacity/sdk-core/storages/SessionStorage';\nimport { STRIVACITY_SDK, useStrivacity } from './composables';\nimport LoginRendererComponent from './login-renderer.vue';\n\nexport * from '@strivacity/sdk-core';\nexport { createCredential, getCredential } from '@strivacity/sdk-core/utils/credentials';\nexport type * from './types';\nexport type { PopupFlow, RedirectFlow, NativeFlow };\nexport { HttpClient, LocalStorage, SessionStorage, useStrivacity };\n\n/**\n * Checks if the user is authenticated.\n *\n * @returns {Promise<boolean>} A promise that resolves to `true` if the user is authenticated, otherwise `false`.\n */\nexport let isAuthenticated: () => Promise<boolean> = () => Promise.resolve(false);\n\n/**\n * Creates a Strivacity SDK plugin for Vue.\n *\n * @param {SDKOptions} options - The options used to configure the SDK.\n *\n * @returns {Plugin} A Vue plugin that can be installed in the application.\n */\nexport const createStrivacitySDK = (options: SDKOptions) => {\n\tconst sdk = initFlow(options);\n\n\tconst plugin = {\n\t\tinstall: (app: App) => {\n\t\t\tconst loadingRef = ref<boolean>(true);\n\t\t\tconst optionsRef = ref<SDKOptions>(sdk.options);\n\t\t\tconst isAuthenticatedRef = ref<boolean>(false);\n\t\t\tconst idTokenClaimsRef = ref<IdTokenClaims | null>(null);\n\t\t\tconst accessTokenRef = ref<string | null>(null);\n\t\t\tconst refreshTokenRef = ref<string | null>(null);\n\t\t\tconst accessTokenExpiredRef = ref<boolean>(true);\n\t\t\tconst accessTokenExpirationDateRef = ref<number | null>(null);\n\n\t\t\tconst updateSession = async () => {\n\t\t\t\tisAuthenticatedRef.value = await sdk.isAuthenticated;\n\t\t\t\tidTokenClaimsRef.value = sdk.idTokenClaims || null;\n\t\t\t\taccessTokenRef.value = sdk.accessToken || null;\n\t\t\t\trefreshTokenRef.value = sdk.refreshToken || null;\n\t\t\t\taccessTokenExpiredRef.value = sdk.accessTokenExpired;\n\t\t\t\taccessTokenExpirationDateRef.value = sdk.accessTokenExpirationDate || null;\n\n\t\t\t\tif (loadingRef.value) {\n\t\t\t\t\tloadingRef.value = false;\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tisAuthenticated = () => sdk.isAuthenticated;\n\n\t\t\tsdk.subscribeToEvent('init', updateSession);\n\t\t\tsdk.subscribeToEvent('loggedIn', updateSession);\n\t\t\tsdk.subscribeToEvent('sessionLoaded', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRefreshed', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRefreshFailed', updateSession);\n\t\t\tsdk.subscribeToEvent('logoutInitiated', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRevoked', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRevokeFailed', updateSession);\n\n\t\t\tapp.component('StyLoginRenderer', LoginRendererComponent);\n\t\t\tapp.provide(STRIVACITY_SDK, {\n\t\t\t\tsdk: sdk,\n\t\t\t\tloading: loadingRef,\n\t\t\t\toptions: optionsRef,\n\t\t\t\tisAuthenticated: isAuthenticatedRef,\n\t\t\t\tidTokenClaims: idTokenClaimsRef,\n\t\t\t\taccessToken: accessTokenRef,\n\t\t\t\trefreshToken: refreshTokenRef,\n\t\t\t\taccessTokenExpired: accessTokenExpiredRef,\n\t\t\t\taccessTokenExpirationDate: accessTokenExpirationDateRef,\n\n\t\t\t\tlogin: async (options?: Parameters<PopupFlow['login'] | RedirectFlow['login'] | NativeFlow['login']>[0]) => {\n\t\t\t\t\tif (sdk.options.mode === 'native') {\n\t\t\t\t\t\treturn sdk.login(options);\n\t\t\t\t\t}\n\n\t\t\t\t\tawait sdk.login(options);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\tregister: async (options?: Parameters<PopupFlow['register'] | RedirectFlow['register'] | NativeFlow['register']>[0]) => {\n\t\t\t\t\tif (sdk.options.mode === 'native') {\n\t\t\t\t\t\treturn sdk.register(options);\n\t\t\t\t\t}\n\n\t\t\t\t\tawait sdk.register(options);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\tentry: async (url?: string) => {\n\t\t\t\t\treturn await sdk.entry(url);\n\t\t\t\t},\n\t\t\t\trefresh: async () => {\n\t\t\t\t\tawait sdk.refresh();\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\trevoke: async () => {\n\t\t\t\t\tawait sdk.revoke();\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\tlogout: async (options?: Parameters<PopupFlow['logout'] | RedirectFlow['logout']>[0]) => {\n\t\t\t\t\tawait sdk.logout(options);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\thandleCallback: async (url?: Parameters<PopupFlow['handleCallback'] | RedirectFlow['handleCallback'] | NativeFlow['handleCallback']>[0]) => {\n\t\t\t\t\tawait sdk.handleCallback(url);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t};\n\n\treturn plugin;\n};\n"],"names":["isAuthenticated","createStrivacitySDK","options","sdk","initFlow","app","loadingRef","ref","optionsRef","isAuthenticatedRef","idTokenClaimsRef","accessTokenRef","refreshTokenRef","accessTokenExpiredRef","accessTokenExpirationDateRef","updateSession","LoginRendererComponent","STRIVACITY_SDK","url"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import type { IdTokenClaims, SDKOptions } from '@strivacity/sdk-core';\nimport type { PopupFlow } from '@strivacity/sdk-core/flows/PopupFlow';\nimport type { RedirectFlow } from '@strivacity/sdk-core/flows/RedirectFlow';\nimport type { NativeFlow } from '@strivacity/sdk-core/flows/NativeFlow';\nimport { type App, ref } from 'vue';\nimport { initFlow } from '@strivacity/sdk-core';\nimport { HttpClient } from '@strivacity/sdk-core/utils/HttpClient';\nimport { DefaultLogging } from '@strivacity/sdk-core/utils/Logging';\nimport { LocalStorage } from '@strivacity/sdk-core/storages/LocalStorage';\nimport { SessionStorage } from '@strivacity/sdk-core/storages/SessionStorage';\nimport { STRIVACITY_SDK, useStrivacity } from './composables';\nimport LoginRendererComponent from './login-renderer.vue';\n\nexport * from '@strivacity/sdk-core';\nexport { createCredential, getCredential } from '@strivacity/sdk-core/utils/credentials';\nexport type * from './types';\nexport type { PopupFlow, RedirectFlow, NativeFlow };\nexport { HttpClient, DefaultLogging, LocalStorage, SessionStorage, useStrivacity };\n\n/**\n * Checks if the user is authenticated.\n *\n * @returns {Promise<boolean>} A promise that resolves to `true` if the user is authenticated, otherwise `false`.\n */\nexport let isAuthenticated: () => Promise<boolean> = () => Promise.resolve(false);\n\n/**\n * Creates a Strivacity SDK plugin for Vue.\n *\n * @param {SDKOptions} options - The options used to configure the SDK.\n *\n * @returns {Plugin} A Vue plugin that can be installed in the application.\n */\nexport const createStrivacitySDK = (options: SDKOptions) => {\n\tconst sdk = initFlow(options);\n\n\tconst plugin = {\n\t\tinstall: (app: App) => {\n\t\t\tconst loadingRef = ref<boolean>(true);\n\t\t\tconst optionsRef = ref<SDKOptions>(sdk.options);\n\t\t\tconst isAuthenticatedRef = ref<boolean>(false);\n\t\t\tconst idTokenClaimsRef = ref<IdTokenClaims | null>(null);\n\t\t\tconst accessTokenRef = ref<string | null>(null);\n\t\t\tconst refreshTokenRef = ref<string | null>(null);\n\t\t\tconst accessTokenExpiredRef = ref<boolean>(true);\n\t\t\tconst accessTokenExpirationDateRef = ref<number | null>(null);\n\n\t\t\tconst updateSession = async () => {\n\t\t\t\tisAuthenticatedRef.value = await sdk.isAuthenticated;\n\t\t\t\tidTokenClaimsRef.value = sdk.idTokenClaims || null;\n\t\t\t\taccessTokenRef.value = sdk.accessToken || null;\n\t\t\t\trefreshTokenRef.value = sdk.refreshToken || null;\n\t\t\t\taccessTokenExpiredRef.value = sdk.accessTokenExpired;\n\t\t\t\taccessTokenExpirationDateRef.value = sdk.accessTokenExpirationDate || null;\n\n\t\t\t\tif (loadingRef.value) {\n\t\t\t\t\tloadingRef.value = false;\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tisAuthenticated = () => sdk.isAuthenticated;\n\n\t\t\tsdk.subscribeToEvent('init', updateSession);\n\t\t\tsdk.subscribeToEvent('loggedIn', updateSession);\n\t\t\tsdk.subscribeToEvent('sessionLoaded', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRefreshed', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRefreshFailed', updateSession);\n\t\t\tsdk.subscribeToEvent('logoutInitiated', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRevoked', updateSession);\n\t\t\tsdk.subscribeToEvent('tokenRevokeFailed', updateSession);\n\n\t\t\tapp.component('StyLoginRenderer', LoginRendererComponent);\n\t\t\tapp.provide(STRIVACITY_SDK, {\n\t\t\t\tsdk: sdk,\n\t\t\t\tloading: loadingRef,\n\t\t\t\toptions: optionsRef,\n\t\t\t\tisAuthenticated: isAuthenticatedRef,\n\t\t\t\tidTokenClaims: idTokenClaimsRef,\n\t\t\t\taccessToken: accessTokenRef,\n\t\t\t\trefreshToken: refreshTokenRef,\n\t\t\t\taccessTokenExpired: accessTokenExpiredRef,\n\t\t\t\taccessTokenExpirationDate: accessTokenExpirationDateRef,\n\n\t\t\t\tlogin: async (options?: Parameters<PopupFlow['login'] | RedirectFlow['login'] | NativeFlow['login']>[0]) => {\n\t\t\t\t\tif (sdk.options.mode === 'native') {\n\t\t\t\t\t\treturn sdk.login(options);\n\t\t\t\t\t}\n\n\t\t\t\t\tawait sdk.login(options);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\tregister: async (options?: Parameters<PopupFlow['register'] | RedirectFlow['register'] | NativeFlow['register']>[0]) => {\n\t\t\t\t\tif (sdk.options.mode === 'native') {\n\t\t\t\t\t\treturn sdk.register(options);\n\t\t\t\t\t}\n\n\t\t\t\t\tawait sdk.register(options);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\tentry: async (url?: string) => {\n\t\t\t\t\treturn await sdk.entry(url);\n\t\t\t\t},\n\t\t\t\trefresh: async () => {\n\t\t\t\t\tawait sdk.refresh();\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\trevoke: async () => {\n\t\t\t\t\tawait sdk.revoke();\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\tlogout: async (options?: Parameters<PopupFlow['logout'] | RedirectFlow['logout']>[0]) => {\n\t\t\t\t\tawait sdk.logout(options);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t\thandleCallback: async (url?: Parameters<PopupFlow['handleCallback'] | RedirectFlow['handleCallback'] | NativeFlow['handleCallback']>[0]) => {\n\t\t\t\t\tawait sdk.handleCallback(url);\n\t\t\t\t\tawait updateSession();\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t};\n\n\treturn plugin;\n};\n"],"names":["isAuthenticated","createStrivacitySDK","options","sdk","initFlow","app","loadingRef","ref","optionsRef","isAuthenticatedRef","idTokenClaimsRef","accessTokenRef","refreshTokenRef","accessTokenExpiredRef","accessTokenExpirationDateRef","updateSession","LoginRendererComponent","STRIVACITY_SDK","url"],"mappings":"2sBAwBO,IAAIA,EAA0C,IAAM,QAAQ,QAAQ,EAAK,EASzE,MAAMC,EAAuBC,GAAwB,CAC3D,MAAMC,EAAMC,EAASF,CAAO,EAwF5B,MAtFe,CACd,QAAUG,GAAa,CACtB,MAAMC,EAAaC,EAAa,EAAI,EAC9BC,EAAaD,EAAgBJ,EAAI,OAAO,EACxCM,EAAqBF,EAAa,EAAK,EACvCG,EAAmBH,EAA0B,IAAI,EACjDI,EAAiBJ,EAAmB,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,QAAS,SAAY,CACpB,MAAMf,EAAI,QAAA,EACV,MAAMY,EAAA,CACP,EACA,OAAQ,SAAY,CACnB,MAAMZ,EAAI,OAAA,EACV,MAAMY,EAAA,CACP,EACA,OAAQ,MAAOb,GAA0E,CACxF,MAAMC,EAAI,OAAOD,CAAO,EACxB,MAAMa,EAAA,CACP,EACA,eAAgB,MAAOG,GAAqH,CAC3I,MAAMf,EAAI,eAAee,CAAG,EAC5B,MAAMH,EAAA,CACP,CAAA,CACA,CACF,CAAA,CAIF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strivacity/sdk-vue",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Strivacity Vue.js SDK client",
|
|
6
6
|
"author": "strivacity <opensource@strivacity.com>",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"url": "https://github.com/Strivacity/sdk-js"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@strivacity/sdk-core": "2.
|
|
12
|
+
"@strivacity/sdk-core": "2.3.0"
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
15
|
"vue": ">=3"
|