Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/sdks/core-js-sdk/src/constants/apiPaths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default {
myTenants: '/v1/auth/me/tenants',
history: '/v1/auth/me/history',
flow: {
start: '/v1/flow/start',
next: '/v1/flow/next',
start: '/v2/flow/start',
next: '/v2/flow/next',
},
};
6 changes: 3 additions & 3 deletions packages/sdks/core-js-sdk/test/sdk/flow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('Flows', () => {

it('should send the correct request', async () => {
await sdk.flow.start('flow1');
expect(mockHttpClient.post).toHaveBeenCalledWith('/v1/flow/start', {
expect(mockHttpClient.post).toHaveBeenCalledWith('/v2/flow/start', {
flowId: 'flow1',
isCustomScreen: false,
});
Expand Down Expand Up @@ -92,7 +92,7 @@ describe('Flows', () => {

it('should send the correct request without input', async () => {
await sdk.flow.next('e1', 's1', 'a1');
expect(mockHttpClient.post).toHaveBeenCalledWith('/v1/flow/next', {
expect(mockHttpClient.post).toHaveBeenCalledWith('/v2/flow/next', {
executionId: 'e1',
stepId: 's1',
interactionId: 'a1',
Expand All @@ -103,7 +103,7 @@ describe('Flows', () => {
it('should send the correct request with input', () => {
const input = { key1: 'val1' };
sdk.flow.next('e1', 's1', 'a1', 'v1', 'cv1', input);
expect(mockHttpClient.post).toHaveBeenCalledWith('/v1/flow/next', {
expect(mockHttpClient.post).toHaveBeenCalledWith('/v2/flow/next', {
executionId: 'e1',
stepId: 's1',
interactionId: 'a1',
Expand Down
2 changes: 1 addition & 1 deletion packages/sdks/web-component/e2e/descope-wc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ test.describe('descope-wc', () => {
await page.route('**/start', async (route) =>
route.fulfill({
json: {
executionId: 'pass|#|2tlLFAOthDriBZIOVXahmLnYv8Q',
executionId: 'pass---2tlLFAOthDriBZIOVXahmLnYv8Q',
stepId: '4',
status: 'waiting',
action: '',
Expand Down
2 changes: 1 addition & 1 deletion packages/sdks/web-component/src/lib/helpers/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function resetUrlParam(paramName: string) {
}

const getFlowIdFromExecId = (executionId: string) => {
const regex = /(.*)\|#\|.*/;
const regex = /(.*)---.*/;
return regex.exec(executionId)?.[1] || '';
};

Expand Down
6 changes: 3 additions & 3 deletions packages/sdks/web-component/test/helpers/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ describe('helpers', () => {
writable: true,
value: new URL('http://localhost'),
});
window.location.search = `?${URL_RUN_IDS_PARAM_NAME}=8|#|a_9`;
window.location.search = `?${URL_RUN_IDS_PARAM_NAME}=8---a_9`;
expect(getRunIdsFromUrl('8')).toEqual({
executionFlowId: '8',
executionId: '8|#|a',
executionId: '8---a',
stepId: '9',
});
});
Expand All @@ -77,7 +77,7 @@ describe('helpers', () => {
writable: true,
value: new URL('http://localhost'),
});
window.location.search = `?${URL_RUN_IDS_PARAM_NAME}=8|#|a_9`;
window.location.search = `?${URL_RUN_IDS_PARAM_NAME}=8---a_9`;
expect(getRunIdsFromUrl('')).toEqual({
executionFlowId: '8',
executionId: '',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export const FLOW_NONCE_PREFIX = 'descopeFlowNonce';
export const FLOW_NONCE_HEADER = 'X-Descope-Flow-Nonce';

export const FLOW_START_PATH = '/v1/flow/start';
export const FLOW_NEXT_PATH = '/v1/flow/next';
export const FLOW_START_PATH = '/v2/flow/start';
export const FLOW_NEXT_PATH = '/v2/flow/next';

export const FLOW_NEXT_TTL = 3 * 60 * 60; // 3 hours in seconds
export const FLOW_START_TTL = 2 * 24 * 60 * 60; // 2 days in seconds
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const removeFlowNonce = (

// Extract execution ID from special format
const extractExecId = (executionId: string): string | null => {
const regex = /.*\|#\|(.*)/;
const regex = /.*---(.*)/;
return regex.exec(executionId)?.[1] || null;
};

Expand Down
10 changes: 5 additions & 5 deletions packages/sdks/web-js-sdk/test/beforeRequest-dtd.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('beforeRequest hook - DTD header', () => {
localStorage.setItem(TRUSTED_DEVICE_TOKEN_KEY, 'my-dtd-token');

const config = {
path: '/v1/flow/start',
path: '/v2/flow/start',
method: 'POST' as HTTPMethods,
body: { flowId: 'test-flow' },
};
Expand All @@ -41,7 +41,7 @@ describe('beforeRequest hook - DTD header', () => {
);

const config = {
path: '/v1/flow/start',
path: '/v2/flow/start',
method: 'POST' as HTTPMethods,
body: { flowId: 'test-flow' },
};
Expand All @@ -56,7 +56,7 @@ describe('beforeRequest hook - DTD header', () => {

it('should not add x-descope-trusted-device-token header when DTD does not exist', () => {
const config = {
path: '/v1/flow/start',
path: '/v2/flow/start',
method: 'POST' as HTTPMethods,
body: { flowId: 'test-flow' },
};
Expand All @@ -71,7 +71,7 @@ describe('beforeRequest hook - DTD header', () => {
localStorage.setItem(TRUSTED_DEVICE_TOKEN_KEY, 'my-dtd-token');

const config = {
path: '/v1/flow/start',
path: '/v2/flow/start',
method: 'POST' as HTTPMethods,
body: { flowId: 'test-flow' },
headers: {
Expand Down Expand Up @@ -102,7 +102,7 @@ describe('beforeRequest hook - DTD header', () => {
localStorage.setItem('DSR', 'refresh-token');

const config = {
path: '/v1/flow/start',
path: '/v2/flow/start',
method: 'POST' as HTTPMethods,
body: { flowId: 'test-flow' },
};
Expand Down
28 changes: 14 additions & 14 deletions packages/sdks/web-js-sdk/test/flowNonce.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('flowNonce', () => {

const mockFetch = jest
.fn()
.mockResolvedValue(createResponse(`flow|#|${executionId}`, nonce));
.mockResolvedValue(createResponse(`flow---${executionId}`, nonce));
global.fetch = mockFetch;

const sdk = createSdk({ projectId: 'pid' });
Expand All @@ -91,11 +91,11 @@ describe('flowNonce', () => {

const mockFetch = jest
.fn()
.mockResolvedValue(createResponse(`flow|#|${executionId}`, nonce));
.mockResolvedValue(createResponse(`flow---${executionId}`, nonce));
global.fetch = mockFetch;

const sdk = createSdk({ projectId: 'pid' });
await sdk.flow.next(`flow|#|${executionId}`, 'stepId', 'interactionId');
await sdk.flow.next(`flow---${executionId}`, 'stepId', 'interactionId');

const key = `${FLOW_NONCE_PREFIX}${executionId}`;
const stored = localStorage.getItem(key);
Expand All @@ -115,7 +115,7 @@ describe('flowNonce', () => {
global.fetch = mockFetch;

const sdk = createSdk({ projectId: 'pid' });
await sdk.flow.next(`flow|#|${executionId}`, 'stepId', 'interactionId');
await sdk.flow.next(`flow---${executionId}`, 'stepId', 'interactionId');

const [url, options] = mockFetch.mock.calls[0];
expect(url).toContain('flow/next');
Expand Down Expand Up @@ -149,7 +149,7 @@ describe('flowNonce', () => {
global.fetch = mockFetch;

const sdk = createSdk({ projectId: 'pid' });
await sdk.flow.next(`flow|#|${executionId}`, 'stepId', 'interactionId');
await sdk.flow.next(`flow---${executionId}`, 'stepId', 'interactionId');

const [url, options] = mockFetch.mock.calls[0];
expect(hasHeader(options, FLOW_NONCE_HEADER)).toBe(false);
Expand All @@ -159,7 +159,7 @@ describe('flowNonce', () => {
it('extracts execution ID from complex formats', async () => {
const executionId = 'test-execution-id';
const nonce = 'test-nonce-value';
const complexId = `flow|#|${executionId}`;
const complexId = `flow---${executionId}`;

const mockFetch = jest
.fn()
Expand Down Expand Up @@ -224,7 +224,7 @@ describe('flowNonce', () => {

const mockFetch = jest
.fn()
.mockResolvedValue(createResponse(`flow|#|${executionId}`, null));
.mockResolvedValue(createResponse(`flow---${executionId}`, null));
global.fetch = mockFetch;

const sdk = createSdk({ projectId: 'pid' });
Expand Down Expand Up @@ -282,7 +282,7 @@ describe('flowNonce', () => {
const sdk = createSdk({ projectId: 'pid' });

// Call the SDK method that would typically store the nonce
await sdk.flow.next(`flow|#|${executionId}`, 'stepId', 'interactionId');
await sdk.flow.next(`flow---${executionId}`, 'stepId', 'interactionId');

// Instead of checking actual localStorage, just verify the call was made correctly
expect(mockFetch).toHaveBeenCalled();
Expand Down Expand Up @@ -315,7 +315,7 @@ describe('flowNonce', () => {
// Verify the item exists before the test
expect(localStorage.getItem(storageKey)).not.toBeNull();

await sdk.flow.next(`flow|#|${executionId}`, 'stepId', 'interactionId');
await sdk.flow.next(`flow---${executionId}`, 'stepId', 'interactionId');

// Verify the item was removed from localStorage
expect(localStorage.getItem(storageKey)).toBeNull();
Expand All @@ -332,7 +332,7 @@ describe('flowNonce', () => {

const mockFetch = jest
.fn()
.mockResolvedValue(createResponse(`flow|#|${executionId}`, nonce));
.mockResolvedValue(createResponse(`flow---${executionId}`, nonce));
global.fetch = mockFetch;

const sdk = createSdk({
Expand All @@ -351,7 +351,7 @@ describe('flowNonce', () => {

const mockFetch = jest
.fn()
.mockResolvedValue(createResponse(`flow|#|${executionId}`, nonce));
.mockResolvedValue(createResponse(`flow---${executionId}`, nonce));
global.fetch = mockFetch;

const sdk = createSdk({
Expand Down Expand Up @@ -391,7 +391,7 @@ describe('flowNonce', () => {
global.fetch = mockFetch;

const sdk = createSdk({ projectId: 'pid' });
await sdk.flow.next(`flow|#|${executionId}`, 'stepId', 'interactionId');
await sdk.flow.next(`flow---${executionId}`, 'stepId', 'interactionId');

// Verify the operation completes without throwing
expect(mockFetch).toHaveBeenCalled();
Expand All @@ -414,7 +414,7 @@ describe('flowNonce', () => {
try {
const mockFetch = jest
.fn()
.mockResolvedValue(createResponse(`flow|#|${executionId}`, nonce));
.mockResolvedValue(createResponse(`flow---${executionId}`, nonce));
global.fetch = mockFetch;

const sdk = createSdk({ projectId: 'pid' });
Expand Down Expand Up @@ -446,7 +446,7 @@ describe('flowNonce', () => {
global.fetch = mockFetch;

const sdk = createSdk({ projectId: 'pid' });
await sdk.flow.next(`flow|#|${executionId}`, 'stepId', 'interactionId');
await sdk.flow.next(`flow---${executionId}`, 'stepId', 'interactionId');

// Verify the operation completes without throwing
expect(mockFetch).toHaveBeenCalled();
Expand Down
8 changes: 4 additions & 4 deletions packages/sdks/web-js-sdk/test/lastLoggedInUser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('lastLoggedInUser', () => {
const sdk = createSdk({ projectId: 'pid' });
await sdk.flow.start('id', { tenant: 'yo' });
expect(mockFetch).toBeCalledWith(
'https://api.descope.com/v1/flow/start',
'https://api.descope.com/v2/flow/start',
expect.any(Object),
);
expect(JSON.parse(mockFetch.mock.calls[0][1].body)).toMatchObject({
Expand All @@ -46,7 +46,7 @@ describe('lastLoggedInUser', () => {
const sdk = createSdk({ projectId: 'pid' });
await sdk.flow.start('id');
expect(mockFetch).toBeCalledWith(
'https://api.descope.com/v1/flow/start',
'https://api.descope.com/v2/flow/start',
expect.any(Object),
);
expect(localStorage.getItem(LOCAL_STORAGE_LAST_USER_LOGIN_ID)).toBe(
Expand All @@ -65,7 +65,7 @@ describe('lastLoggedInUser', () => {
const sdk = createSdk({ projectId: 'pid' });
await sdk.flow.next('id', 'stepId', 'interactionId');
expect(mockFetch).toBeCalledWith(
'https://api.descope.com/v1/flow/next',
'https://api.descope.com/v2/flow/next',
expect.any(Object),
);
expect(localStorage.getItem(LOCAL_STORAGE_LAST_USER_LOGIN_ID)).toBe(
Expand Down Expand Up @@ -109,7 +109,7 @@ describe('lastLoggedInUser', () => {
});
await sdk.flow.start('id');
expect(mockFetch).toBeCalledWith(
'https://api.descope.com/v1/flow/start',
'https://api.descope.com/v2/flow/start',
expect.any(Object),
);
expect(localStorage.getItem(LOCAL_STORAGE_LAST_USER_LOGIN_ID)).toBeFalsy();
Expand Down
6 changes: 3 additions & 3 deletions packages/sdks/web-js-sdk/test/sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('sdk', () => {
const sdk = createSdk({ projectId: 'pid' });
await sdk.flow.start('id');
expect(mockFetch).toBeCalledWith(
'https://api.descope.com/v1/flow/start',
'https://api.descope.com/v2/flow/start',
expect.any(Object),
);
expect(JSON.parse(mockFetch.mock.calls[0][1].body)).toMatchObject({
Expand Down Expand Up @@ -55,7 +55,7 @@ describe('sdk', () => {
const sdk = createSdk({ projectId: 'pid' });
await sdk.flow.start('id', { tenant: 'yo', preview: true });
expect(mockFetch).toBeCalledWith(
'https://api.descope.com/v1/flow/start',
'https://api.descope.com/v2/flow/start',
expect.any(Object),
);
expect(JSON.parse(mockFetch.mock.calls[0][1].body)).toMatchObject({
Expand All @@ -74,7 +74,7 @@ describe('sdk', () => {
const sdk = createSdk({ projectId: 'pid' });
await sdk.flow.start('id', { oidcResource: 'https://api.example.com' });
expect(mockFetch).toBeCalledWith(
'https://api.descope.com/v1/flow/start',
'https://api.descope.com/v2/flow/start',
expect.any(Object),
);
expect(JSON.parse(mockFetch.mock.calls[0][1].body)).toMatchObject({
Expand Down
Loading