@strivacity/sdk-nuxt 4.0.0-beta.0 → 4.0.0-beta.1
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/tsconfig.app.json +1 -1
- package/.nuxt/tsconfig.json +1 -1
- package/.nuxt/tsconfig.shared.json +1 -1
- package/dist/module.json +1 -1
- package/dist/runtime/composables/use-native-login.js +2 -2
- package/package.json +2 -2
- package/src/runtime/composables/use-native-login.ts +2 -2
- package/testing/tests/composables.spec.ts +1 -1
- /package/.nuxt/manifest/meta/{cb11df97-b0c9-4a91-9d4b-60c25c918599.json → b2d6b125-90fd-44d4-9916-0898f71676da.json} +0 -0
package/.nuxt/tsconfig.app.json
CHANGED
package/.nuxt/tsconfig.json
CHANGED
package/dist/module.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { STRIVACITY_LOGIN_CONTEXT } from "./use-native-login-context.js";
|
|
2
2
|
import { provide, ref, onMounted, onUnmounted } from "vue";
|
|
3
3
|
import { FallbackError } from "@strivacity/sdk-core/utils/errors";
|
|
4
|
-
import { unflattenObject } from "@strivacity/sdk-core/utils";
|
|
4
|
+
import { isSessionExpired, unflattenObject } from "@strivacity/sdk-core/utils";
|
|
5
5
|
import { useStrivacity } from "./use-strivacity.js";
|
|
6
6
|
export function useNativeLogin(options = {}) {
|
|
7
7
|
const abortController = new AbortController();
|
|
@@ -25,7 +25,7 @@ export function useNativeLogin(options = {}) {
|
|
|
25
25
|
});
|
|
26
26
|
onUnmounted(() => abortController.abort());
|
|
27
27
|
function handleResponse(nextState) {
|
|
28
|
-
if (sdk.session) {
|
|
28
|
+
if (sdk.session && !isSessionExpired(sdk.session)) {
|
|
29
29
|
return void options.onLogin?.(sdk.session);
|
|
30
30
|
}
|
|
31
31
|
const newState = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strivacity/sdk-nuxt",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.1",
|
|
4
4
|
"description": "Strivacity Nuxt SDK client",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "strivacity <opensource@strivacity.com>",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@strivacity/sdk-core": "4.0.0-beta.
|
|
45
|
+
"@strivacity/sdk-core": "4.0.0-beta.1"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"nuxt": ">=4.0"
|
|
@@ -3,7 +3,7 @@ import type { LoginContext, UseNativeLoginOptions } from '../types';
|
|
|
3
3
|
import { STRIVACITY_LOGIN_CONTEXT, type useNativeLoginContext } from './use-native-login-context';
|
|
4
4
|
import { provide, ref, onMounted, onUnmounted } from 'vue';
|
|
5
5
|
import { FallbackError } from '@strivacity/sdk-core/utils/errors';
|
|
6
|
-
import { unflattenObject } from '@strivacity/sdk-core/utils';
|
|
6
|
+
import { isSessionExpired, unflattenObject } from '@strivacity/sdk-core/utils';
|
|
7
7
|
import { useStrivacity } from './use-strivacity';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -41,7 +41,7 @@ export function useNativeLogin(options: UseNativeLoginOptions = {}): ReturnType<
|
|
|
41
41
|
onUnmounted(() => abortController.abort());
|
|
42
42
|
|
|
43
43
|
function handleResponse(nextState: Partial<NativeFlowState>) {
|
|
44
|
-
if (sdk.session) {
|
|
44
|
+
if (sdk.session && !isSessionExpired(sdk.session)) {
|
|
45
45
|
return void options.onLogin?.(sdk.session);
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -330,7 +330,7 @@ describe('useNativeLogin', () => {
|
|
|
330
330
|
});
|
|
331
331
|
|
|
332
332
|
test('calls onLogin and leaves the tracked state untouched when the sdk already has a session', async () => {
|
|
333
|
-
const session = { access_token: 'access-token' } as unknown as SessionData;
|
|
333
|
+
const session = { access_token: 'access-token', expires_at: Math.floor(Date.now() / 1000) + 3600 } as unknown as SessionData;
|
|
334
334
|
vi.doMock('../../src/runtime/composables/use-session', () => ({ useSession: () => ({ value: session }) }));
|
|
335
335
|
|
|
336
336
|
const sdk = createMockFlow<NativeFlow>();
|
|
File without changes
|