@strivacity/sdk-nuxt 3.0.2 → 4.0.0-beta.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/.nuxt/app-component.mjs +1 -1
- package/.nuxt/app.config.mjs +21 -0
- package/.nuxt/component-names.mjs +1 -1
- package/.nuxt/components.d.ts +48 -48
- package/.nuxt/components.islands.mjs +6 -2
- package/.nuxt/error-component.mjs +1 -1
- package/.nuxt/fetch.d.ts +1 -0
- package/.nuxt/fetch.mjs +4 -3
- package/.nuxt/imports.d.ts +15 -5
- package/.nuxt/imports.mjs +15 -5
- package/.nuxt/island-renderer.mjs +2 -0
- package/.nuxt/middleware.mjs +3 -1
- package/.nuxt/nuxt.config.mjs +103 -0
- package/.nuxt/nuxt.d.ts +3 -4
- package/.nuxt/nuxt.node.d.ts +4 -4
- package/.nuxt/nuxt.shared.d.ts +3 -1
- package/.nuxt/plugins.client.mjs +10 -14
- package/.nuxt/plugins.server.mjs +6 -6
- package/.nuxt/root-component.mjs +1 -1
- package/.nuxt/route-rules.mjs +22 -0
- package/.nuxt/test-component-wrapper.mjs +1 -1
- package/.nuxt/tsconfig.app.json +211 -0
- package/.nuxt/tsconfig.json +212 -0
- package/.nuxt/tsconfig.node.json +117 -0
- package/.nuxt/tsconfig.server.json +161 -0
- package/.nuxt/tsconfig.shared.json +165 -0
- package/.nuxt/types/app.config.d.ts +35 -0
- package/.nuxt/types/components.d.ts +48 -48
- package/.nuxt/types/imports.d.ts +1 -1
- package/.nuxt/types/layouts.d.ts +16 -0
- package/.nuxt/types/modules.d.ts +20 -20
- package/.nuxt/types/nitro-imports.d.ts +9 -4
- package/.nuxt/types/nitro-layouts.d.ts +17 -0
- package/.nuxt/types/nitro-nuxt.d.ts +19 -5
- package/.nuxt/types/nitro-routes.d.ts +25 -1
- package/.nuxt/types/plugins.d.ts +8 -9
- package/.nuxt/types/runtime-config.d.ts +6 -12
- package/.nuxt/types/shared-app.config.d.ts +28 -0
- package/.nuxt/types/shared-imports.d.ts +2 -0
- package/.nuxt/unhead-options.mjs +2 -1
- package/.nuxt/unhead.config.mjs +1 -0
- package/CHANGELOG.md +16 -14
- package/README.md +1577 -406
- package/build.config.ts +5 -0
- package/dist/module.d.mts +3 -193
- package/dist/module.json +2 -2
- package/dist/module.mjs +78 -57
- package/dist/module.mjs.map +1 -1
- package/dist/runtime/composables/use-native-login-context.d.ts +10 -0
- package/dist/runtime/composables/use-native-login-context.js +9 -0
- package/dist/runtime/composables/use-native-login.d.ts +10 -0
- package/dist/runtime/composables/use-native-login.js +143 -0
- package/dist/runtime/composables/use-session.d.ts +8 -0
- package/dist/runtime/composables/use-session.js +2 -0
- package/dist/runtime/composables/use-strivacity.d.ts +9 -0
- package/dist/runtime/composables/use-strivacity.js +77 -0
- package/dist/runtime/middleware/auth.server.d.ts +2 -0
- package/dist/runtime/middleware/auth.server.js +12 -0
- package/dist/runtime/server/api/auth/backchannel-logout.get.d.ts +2 -0
- package/dist/runtime/server/api/auth/backchannel-logout.get.js +2 -0
- package/dist/runtime/server/api/auth/callback.get.d.ts +2 -0
- package/dist/runtime/server/api/auth/callback.get.js +2 -0
- package/dist/runtime/server/api/auth/entry.get.d.ts +2 -0
- package/dist/runtime/server/api/auth/entry.get.js +2 -0
- package/dist/runtime/server/api/auth/login.get.d.ts +2 -0
- package/dist/runtime/server/api/auth/login.get.js +2 -0
- package/dist/runtime/server/api/auth/logout.get.d.ts +2 -0
- package/dist/runtime/server/api/auth/logout.get.js +2 -0
- package/dist/runtime/server/api/auth/refresh.get.d.ts +2 -0
- package/dist/runtime/server/api/auth/refresh.get.js +2 -0
- package/dist/runtime/server/api/auth/register.get.d.ts +2 -0
- package/dist/runtime/server/api/auth/register.get.js +2 -0
- package/dist/runtime/server/api/auth/revoke.get.d.ts +2 -0
- package/dist/runtime/server/api/auth/revoke.get.js +2 -0
- package/dist/runtime/server/composables/use-strivacity.d.ts +2 -0
- package/dist/runtime/server/composables/use-strivacity.js +9 -0
- package/dist/runtime/server/plugins/auth.server.d.ts +10 -0
- package/dist/runtime/server/plugins/auth.server.js +66 -0
- package/dist/runtime/server/utils/helpers.d.ts +18 -0
- package/dist/runtime/server/utils/helpers.js +39 -0
- package/dist/runtime/storages/core.d.ts +1 -0
- package/dist/runtime/storages/core.js +13 -0
- package/dist/runtime/storages/default.d.ts +21 -0
- package/dist/runtime/storages/default.js +71 -0
- package/dist/runtime/types.d.ts +219 -0
- package/dist/runtime/types.js +1 -0
- package/dist/runtime/utils/core.d.ts +1 -0
- package/dist/runtime/utils/core.js +64 -0
- package/dist/runtime/utils/noop.d.ts +1 -0
- package/dist/runtime/utils/noop.js +3 -0
- package/dist/types.d.mts +4 -16
- package/eslint.config.mjs +5 -0
- package/nuxt.config.ts +5 -0
- package/package.json +31 -5
- package/project.json +44 -0
- package/src/module.ts +107 -0
- package/src/runtime/composables/use-native-login-context.ts +20 -0
- package/src/runtime/composables/use-native-login.ts +182 -0
- package/src/runtime/composables/use-session.ts +10 -0
- package/src/runtime/composables/use-strivacity.ts +95 -0
- package/src/runtime/middleware/auth.server.ts +16 -0
- package/src/runtime/server/api/auth/backchannel-logout.get.ts +3 -0
- package/src/runtime/server/api/auth/callback.get.ts +3 -0
- package/src/runtime/server/api/auth/entry.get.ts +3 -0
- package/src/runtime/server/api/auth/login.get.ts +3 -0
- package/src/runtime/server/api/auth/logout.get.ts +3 -0
- package/src/runtime/server/api/auth/refresh.get.ts +3 -0
- package/src/runtime/server/api/auth/register.get.ts +3 -0
- package/src/runtime/server/api/auth/revoke.get.ts +3 -0
- package/src/runtime/server/composables/use-strivacity.ts +13 -0
- package/src/runtime/server/plugins/auth.server.ts +84 -0
- package/src/runtime/server/utils/helpers.ts +67 -0
- package/src/runtime/storages/core.ts +13 -0
- package/src/runtime/storages/default.ts +111 -0
- package/src/runtime/types.ts +289 -0
- package/src/runtime/utils/core.ts +64 -0
- package/src/runtime/utils/noop.ts +3 -0
- package/testing/stubs/app.ts +6 -0
- package/testing/stubs/imports.ts +19 -0
- package/testing/stubs/options-httpClient.ts +8 -0
- package/testing/stubs/options-logging.ts +8 -0
- package/testing/stubs/options-stateStorage.ts +8 -0
- package/testing/stubs/options-storage.ts +8 -0
- package/testing/tests/composables.spec.ts +512 -0
- package/testing/tests/server/helpers.spec.ts +86 -0
- package/testing/tests/server/plugin.spec.ts +138 -0
- package/testing/tests/server/routes.spec.ts +34 -0
- package/testing/tests/server/use-strivacity.spec.ts +22 -0
- package/testing/tests/storages-default.spec.ts +151 -0
- package/testing/tests/storages.spec.ts +16 -0
- package/testing/tests/utils.spec.ts +10 -0
- package/testing/utils/common.ts +33 -0
- package/testing/utils/http.ts +58 -0
- package/tsconfig.json +3 -0
- package/vite.config.mts +20 -0
- package/.nuxt/strivacity-sdk-logging.d.ts +0 -13
- package/.nuxt/strivacity-sdk-logging.mjs +0 -1
- package/.nuxt/strivacity-sdk-storage.d.ts +0 -10
- package/.nuxt/strivacity-sdk-storage.mjs +0 -1
- package/dist/runtime/composables.d.ts +0 -12
- package/dist/runtime/composables.js +0 -83
- package/dist/runtime/login-renderer.vue +0 -174
- package/dist/runtime/login-renderer.vue.d.ts +0 -39
- /package/.nuxt/manifest/meta/{b47927c0-b36b-4d2c-b650-8d55c5ec676a.json → cb11df97-b0c9-4a91-9d4b-60c25c918599.json} +0 -0
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
<script setup>
|
|
2
|
-
import { defineComponent, provide, ref, h, onMounted } from "vue";
|
|
3
|
-
import { FallbackError } from "@strivacity/sdk-core";
|
|
4
|
-
import { unflattenObject } from "@strivacity/sdk-core/utils/object";
|
|
5
|
-
import { useStrivacity } from "./composables";
|
|
6
|
-
const { sdk } = useStrivacity();
|
|
7
|
-
const props = defineProps({
|
|
8
|
-
params: { type: Object, required: false, default: () => ({}) },
|
|
9
|
-
widgets: { type: null, required: false, default: () => ({}) },
|
|
10
|
-
language: { type: [String, null], required: false, default: navigator.language },
|
|
11
|
-
sessionId: { type: [String, null], required: false, default: null }
|
|
12
|
-
});
|
|
13
|
-
const emit = defineEmits(["login", "fallback", "close", "error", "globalMessage", "blockReady", "update:language"]);
|
|
14
|
-
const WidgetRenderer = defineComponent({
|
|
15
|
-
props: {
|
|
16
|
-
items: {
|
|
17
|
-
type: Array,
|
|
18
|
-
default: () => []
|
|
19
|
-
},
|
|
20
|
-
widgets: {
|
|
21
|
-
type: Object,
|
|
22
|
-
default: () => ({})
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
setup: (props2) => () => props2.items.map((item) => {
|
|
26
|
-
if (item.type === "widget") {
|
|
27
|
-
const form = state.value?.forms?.find((form2) => form2.id === item.formId);
|
|
28
|
-
const widget = form?.widgets.find((widget2) => widget2.id === item.widgetId);
|
|
29
|
-
if (!form || !widget) {
|
|
30
|
-
triggerFallback(void 0, `Unable to find form or widget for item: formId=${item.formId}, widgetId=${item.widgetId}`);
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
const component = props2.widgets[widget.type];
|
|
34
|
-
if (!component) {
|
|
35
|
-
triggerFallback(void 0, `No component found for widget type ${widget.type}`);
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
return h(component, { key: `${form.id}.${widget.id}`, formId: form.id, config: widget });
|
|
39
|
-
} else if (item.type === "vertical" || item.type === "horizontal") {
|
|
40
|
-
if (!props2.widgets.layout) {
|
|
41
|
-
triggerFallback(void 0, "No layout component provided");
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
return h(
|
|
45
|
-
props2.widgets.layout,
|
|
46
|
-
{ formId: item.items[0].formId, type: item.type },
|
|
47
|
-
() => h(WidgetRenderer, { items: item.items, widgets: props2.widgets })
|
|
48
|
-
);
|
|
49
|
-
} else {
|
|
50
|
-
triggerFallback(void 0, "Unknown item type in layout");
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
})
|
|
54
|
-
});
|
|
55
|
-
const loginHandler = sdk.login(props.params);
|
|
56
|
-
const loading = ref(false);
|
|
57
|
-
const forms = ref({});
|
|
58
|
-
const messages = ref({});
|
|
59
|
-
const state = ref({});
|
|
60
|
-
provide("nativeFlowContext", {
|
|
61
|
-
loading,
|
|
62
|
-
forms,
|
|
63
|
-
messages,
|
|
64
|
-
state,
|
|
65
|
-
submitForm,
|
|
66
|
-
triggerFallback,
|
|
67
|
-
triggerClose,
|
|
68
|
-
setFormValue,
|
|
69
|
-
setMessage
|
|
70
|
-
});
|
|
71
|
-
onMounted(async () => {
|
|
72
|
-
try {
|
|
73
|
-
const data = await loginHandler.startSession(props.sessionId, props.language);
|
|
74
|
-
emit("update:language", loginHandler.language);
|
|
75
|
-
if (data) {
|
|
76
|
-
await handleResponse(data);
|
|
77
|
-
}
|
|
78
|
-
} catch (error) {
|
|
79
|
-
if (error instanceof FallbackError) {
|
|
80
|
-
emit("fallback", error);
|
|
81
|
-
} else {
|
|
82
|
-
emit("error", error);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
function triggerFallback(hostedUrl, message) {
|
|
87
|
-
const url = hostedUrl || state.value.hostedUrl;
|
|
88
|
-
sdk.logging?.warn(message ? `Triggering fallback due to: ${message}` : "Triggering fallback");
|
|
89
|
-
if (!url) {
|
|
90
|
-
const error = new Error("No hosted URL provided");
|
|
91
|
-
sdk.logging?.error("Fallback error", error);
|
|
92
|
-
throw error;
|
|
93
|
-
}
|
|
94
|
-
emit("fallback", new FallbackError(new URL(url)));
|
|
95
|
-
}
|
|
96
|
-
function triggerClose() {
|
|
97
|
-
emit("close");
|
|
98
|
-
}
|
|
99
|
-
function setFormValue(formId, widgetId, value) {
|
|
100
|
-
if (value === "") {
|
|
101
|
-
value = null;
|
|
102
|
-
}
|
|
103
|
-
if (forms.value[formId] === void 0) {
|
|
104
|
-
forms.value[formId] = {};
|
|
105
|
-
}
|
|
106
|
-
forms.value[formId][widgetId] = value;
|
|
107
|
-
}
|
|
108
|
-
function setMessage(formId, widgetId, value) {
|
|
109
|
-
if (messages.value[formId] === void 0) {
|
|
110
|
-
messages.value[formId] = {};
|
|
111
|
-
}
|
|
112
|
-
messages.value[formId][widgetId] = value;
|
|
113
|
-
}
|
|
114
|
-
async function submitForm(formId) {
|
|
115
|
-
try {
|
|
116
|
-
loading.value = true;
|
|
117
|
-
const data = await loginHandler.submitForm(formId, unflattenObject(forms.value[formId]));
|
|
118
|
-
await handleResponse(data);
|
|
119
|
-
loading.value = false;
|
|
120
|
-
} catch (error) {
|
|
121
|
-
if (error instanceof FallbackError) {
|
|
122
|
-
emit("fallback", error);
|
|
123
|
-
} else {
|
|
124
|
-
emit("error", error);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
async function handleResponse(data) {
|
|
129
|
-
if (await sdk.isAuthenticated) {
|
|
130
|
-
emit("login", sdk.idTokenClaims);
|
|
131
|
-
} else {
|
|
132
|
-
const previousState = JSON.parse(JSON.stringify(state.value));
|
|
133
|
-
const newState = {
|
|
134
|
-
hostedUrl: data?.hostedUrl ?? state.value.hostedUrl,
|
|
135
|
-
finalizeUrl: data?.finalizeUrl ?? state.value.finalizeUrl,
|
|
136
|
-
screen: data?.screen ?? state.value.screen,
|
|
137
|
-
forms: data?.forms ?? state.value.forms,
|
|
138
|
-
layout: data?.layout ?? state.value.layout,
|
|
139
|
-
messages: data?.messages ?? {},
|
|
140
|
-
branding: data?.branding ?? state.value.branding
|
|
141
|
-
};
|
|
142
|
-
if (newState.screen != state.value.screen) {
|
|
143
|
-
forms.value = {};
|
|
144
|
-
messages.value = {};
|
|
145
|
-
for (const form of newState.forms ?? []) {
|
|
146
|
-
forms.value[form.id] = {};
|
|
147
|
-
messages.value[form.id] = {};
|
|
148
|
-
}
|
|
149
|
-
} else {
|
|
150
|
-
sdk.logging?.info(`Updating screen: ${newState.screen}`);
|
|
151
|
-
}
|
|
152
|
-
Object.keys(newState.messages ?? {}).forEach((formId) => {
|
|
153
|
-
if (formId === "global") {
|
|
154
|
-
emit("globalMessage", newState.messages?.global?.text ?? "");
|
|
155
|
-
} else {
|
|
156
|
-
messages.value[formId] = newState.messages[formId];
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
state.value = newState;
|
|
160
|
-
setTimeout(() => {
|
|
161
|
-
emit("blockReady", { previousState, state: JSON.parse(JSON.stringify(state.value)) });
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
</script>
|
|
166
|
-
|
|
167
|
-
<template>
|
|
168
|
-
<div class="login-renderer">
|
|
169
|
-
<component :is="widgets.layout" v-if="state.screen" :formId="(state.layout?.items[0]).formId" :type="state.layout?.type" tag="form">
|
|
170
|
-
<WidgetRenderer :items="state.layout?.items" :widgets="widgets" />
|
|
171
|
-
</component>
|
|
172
|
-
<component :is="widgets.loading" v-else />
|
|
173
|
-
</div>
|
|
174
|
-
</template>
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { Component } from 'vue';
|
|
2
|
-
import type { PartialRecord, NativeParams, WidgetType, LoginFlowState, IdTokenClaims } from '@strivacity/sdk-core';
|
|
3
|
-
import { FallbackError } from '@strivacity/sdk-core';
|
|
4
|
-
type __VLS_Props = {
|
|
5
|
-
params?: NativeParams;
|
|
6
|
-
widgets?: PartialRecord<WidgetType, Component>;
|
|
7
|
-
language?: string | null;
|
|
8
|
-
sessionId?: string | null;
|
|
9
|
-
};
|
|
10
|
-
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
11
|
-
login: (args_0: IdTokenClaims | null | undefined) => any;
|
|
12
|
-
error: (args_0: any) => any;
|
|
13
|
-
close: () => any;
|
|
14
|
-
fallback: (args_0: FallbackError) => any;
|
|
15
|
-
globalMessage: (args_0: string) => any;
|
|
16
|
-
blockReady: (args_0: {
|
|
17
|
-
previousState: LoginFlowState;
|
|
18
|
-
state: LoginFlowState;
|
|
19
|
-
}) => any;
|
|
20
|
-
"update:language": (args_0: string | null) => any;
|
|
21
|
-
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
22
|
-
onLogin?: ((args_0: IdTokenClaims | null | undefined) => any) | undefined;
|
|
23
|
-
onError?: ((args_0: any) => any) | undefined;
|
|
24
|
-
onClose?: (() => any) | undefined;
|
|
25
|
-
onFallback?: ((args_0: FallbackError) => any) | undefined;
|
|
26
|
-
onGlobalMessage?: ((args_0: string) => any) | undefined;
|
|
27
|
-
onBlockReady?: ((args_0: {
|
|
28
|
-
previousState: LoginFlowState;
|
|
29
|
-
state: LoginFlowState;
|
|
30
|
-
}) => any) | undefined;
|
|
31
|
-
"onUpdate:language"?: ((args_0: string | null) => any) | undefined;
|
|
32
|
-
}>, {
|
|
33
|
-
params: NativeParams;
|
|
34
|
-
widgets: PartialRecord<WidgetType, Component>;
|
|
35
|
-
language: string | null;
|
|
36
|
-
sessionId: string | null;
|
|
37
|
-
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
38
|
-
declare const _default: typeof __VLS_export;
|
|
39
|
-
export default _default;
|
|
File without changes
|