Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
b95aba5
feat: add DPoP core storage layer (ENG-4782)
mrudatsprint Jul 15, 2026
9f3e0bc
feat: fix file formatting.
mrudatsprint Jul 15, 2026
7738bb4
fix: DPoPStorage openDb() error handling and test coverage
mrudatsprint Jul 15, 2026
d386a32
fix: fix copilot warnings.
mrudatsprint Jul 15, 2026
bd37ddf
fix: resolve DPoP transactions on tx.oncomplete, not req.onsuccess
mrudatsprint Jul 16, 2026
d91e5b7
feat: the workflow will run regardless of the branch being merged into.
mrudatsprint Jul 16, 2026
7eeb367
feat: implement DPoPManager central coordinator (ENG-4784)
mrudatsprint Jul 16, 2026
06a557e
feat: re-generate lock file.
mrudatsprint Jul 16, 2026
00a0acb
feat: re-generate lock file.
mrudatsprint Jul 16, 2026
14b9b4a
feat: update lock file.
mrudatsprint Jul 16, 2026
e9a8048
Merge branches 'miker/eng-4784/central-coordinator' and 'miker/eng-47…
mrudatsprint Jul 16, 2026
ec6372e
test: add DPoP smoke tests against real FusionAuth instance (pre-SDKC…
mrudatsprint Jul 16, 2026
324d970
feat: fix format and lint errors.
mrudatsprint Jul 17, 2026
952cd03
refactor: make DPoPStorage IndexedDB constants configurable via confi…
mrudatsprint Jul 17, 2026
b7e6feb
feature: delete contrived test to intercept a successful even and the…
mrudatsprint Jul 17, 2026
2c27865
Merge branch 'miker/eng-4782/core-storage-layer' into miker/eng-4784/…
mrudatsprint Jul 17, 2026
b5601e2
fix: update DPoPStorage constructor calls to use config object after …
mrudatsprint Jul 17, 2026
252322a
feature: update lock file
mrudatsprint Jul 17, 2026
eb01796
feat: implement SDKCore.startLogin() for DPoP authorization code gran…
mrudatsprint Jul 18, 2026
ce41545
fix: add @vitest-environment jsdom to SDKCore.test.ts; fix handlePreR…
mrudatsprint Jul 18, 2026
f29df57
fix: suppress cookie console.error noise in Tier 0 e2e tests
mrudatsprint Jul 18, 2026
7babfae
feat: update lock file.
mrudatsprint Jul 18, 2026
bfc666a
fix: update Angular onRedirect test to use 3-segment redirect-value f…
mrudatsprint Jul 18, 2026
27b9ab6
fix: update Vue and React onRedirect tests to use 3-segment redirect-…
mrudatsprint Jul 18, 2026
14c1d0c
fix: merge Request and init headers in DPoPManager.fetch() instead of…
mrudatsprint Jul 20, 2026
b1567a6
feat: fix angular and vue tests.
mrudatsprint Jul 20, 2026
f7cefc8
fix: clone Request before retry in fetch() to avoid double body consu…
mrudatsprint Jul 20, 2026
ddb5509
fix: normalize htu and htm in generateProof() per RFC 9449 (PR #202 C…
mrudatsprint Jul 20, 2026
185357c
fix: remove dead captured header variables and misleading comment in …
mrudatsprint Jul 20, 2026
098bbfb
feat: update approvers.
mrudatsprint Jul 20, 2026
13db934
feat: fix merge conflict.
mrudatsprint Jul 20, 2026
2b6e6de
feat: fix failing tests.
mrudatsprint Jul 20, 2026
920081d
test: add deterministic nonce-retry smoke test (T2-4)
mrudatsprint Jul 20, 2026
b711f2d
fix: revert startLogin() to void, address Copilot PR review comment (…
mrudatsprint Jul 20, 2026
8cfc607
docs: fix stale/ambiguous state-reconstruction description in Redirec…
mrudatsprint Jul 20, 2026
a03dd2e
fix: preserve state from legacy 2-segment redirect values (Copilot PR…
mrudatsprint Jul 21, 2026
50b852f
feat: update comments.
mrudatsprint Jul 21, 2026
8f8f5bc
feat: SDKCore: implement handlePostRedirect() authorization code exch…
mrudatsprint Jul 21, 2026
d5f4569
feat: remove references to ENG- linear issues.
mrudatsprint Jul 21, 2026
5f517f0
feat: remove redundant comments.
mrudatsprint Jul 21, 2026
1f4de60
feat: merge and remove verbose comments.
mrudatsprint Jul 22, 2026
aa7bbdc
feat: merge in the parent branch.
mrudatsprint Jul 22, 2026
9acf888
feat: remove file not needed until adding end to end tests.
mrudatsprint Jul 22, 2026
24b7337
feat: remove lengthy comment.
mrudatsprint Jul 22, 2026
e5342e3
feat: remote unnecessary comments.
mrudatsprint Jul 22, 2026
ac12953
feat: merge in the parent branch.
mrudatsprint Jul 22, 2026
81f46f4
feat: remove verbose comment.
mrudatsprint Jul 22, 2026
ab79bf8
feat: copilot review warnings.
mrudatsprint Jul 22, 2026
fd4353e
feat: failing smoke test.
mrudatsprint Jul 22, 2026
d138ca3
feat: minimize verbose comments.
mrudatsprint Jul 22, 2026
0232d82
feat: clean up comments.
mrudatsprint Jul 22, 2026
1a58211
feat: minimize verbose comments.
mrudatsprint Jul 22, 2026
44cd888
feat: SDKCore - implement startLogout() and getAccessToken() for DPoP…
mrudatsprint Jul 23, 2026
595c4e4
feat: rebuild the lock file.
mrudatsprint Jul 23, 2026
ff619a3
feat: remove verbose comments.
mrudatsprint Jul 23, 2026
16859d9
feat: remove verbose comments.
mrudatsprint Jul 23, 2026
4d8985d
Merge branch 'parent/dpop-in-the-javascript-sdk' into miker/eng-4800/…
mrudatsprint Jul 26, 2026
4a990cf
feat: copilot recommendation .
mrudatsprint Jul 27, 2026
c5e1f35
feat: cleanup comments.
mrudatsprint Jul 27, 2026
31cb1ad
feat: reduce commenting.
mrudatsprint Jul 27, 2026
46984e9
Merge branch 'miker/eng-4800/code-grant-finish' into miker/eng-4802/s…
mrudatsprint Jul 27, 2026
7861863
feat: insure logout url is called.
mrudatsprint Jul 27, 2026
ed1f063
feat: use hosted backend mode versus cookie mode in comments.
mrudatsprint Jul 27, 2026
e716fee
feat: remove verbose comments.
mrudatsprint Jul 27, 2026
fe643bf
Merge branch 'parent/dpop-in-the-javascript-sdk' into miker/eng-4802/…
mrudatsprint Jul 28, 2026
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
30 changes: 29 additions & 1 deletion e2e/tests/dpop-smoke.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ test.describe('DPoP smoke tests', () => {
let accessToken: string;
let refreshToken: string;
let thumbprint: string;
let core: SDKCore;

test.beforeAll(async ({ browser }) => {
context = await browser.newContext();
Expand Down Expand Up @@ -398,7 +399,7 @@ test.describe('DPoP smoke tests', () => {
let notify:
((result: { state?: string } | { error: Error }) => void) | undefined;

const core = new SDKCore({
core = new SDKCore({
serverUrl: FA_URL,
clientId: CLIENT_ID,
redirectUri: REDIRECT_URI,
Expand Down Expand Up @@ -501,6 +502,33 @@ test.describe('DPoP smoke tests', () => {
expect(manager.isLoggedIn).toBe(true);
});

test('startLogout() clears DPoP state and redirects to the logout URL', async () => {
test.skip(!accessToken, 'No access token from previous test');

expect(core.isLoggedIn).toBe(true);
expect(core.getAccessToken()).toBe(accessToken);

const { assign, waitForUrl } = createAssignWaiter();
// @ts-ignore
globalThis.window.location = { assign };

core.startLogout();
const assignedUrl = new URL(String(await waitForUrl()));

expect(assignedUrl.origin).toBe(FA_URL);
expect(assignedUrl.pathname).toBe('/app/logout/');
expect(assignedUrl.searchParams.get('client_id')).toBe(CLIENT_ID);
expect(assignedUrl.searchParams.get('post_logout_redirect_uri')).toBe(
REDIRECT_URI,
);

expect(core.isLoggedIn).toBe(false);
expect(core.getAccessToken()).toBeNull();

const tokenStore = new DPoPTokenStore(CLIENT_ID, 'localStorage');
expect(tokenStore.get()).toBeNull();
});

test('refresh token grant — issues new DPoP-bound tokens', async () => {
test.skip(!refreshToken, 'No refresh token from previous test');

Expand Down
22 changes: 22 additions & 0 deletions packages/core/src/DPoP/DPoPManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,28 @@ describe('getExpiresAt()', () => {
});
});

describe('getAccessToken()', () => {
it('returns null when no tokens are stored', () => {
const manager = makeManager();
expect(manager.getAccessToken()).toBeNull();
});

it('returns the accessToken of the stored tokens', () => {
const manager = makeManager();
manager.setTokens(makeTokens({ accessToken: 'stored-access-token' }));
expect(manager.getAccessToken()).toBe('stored-access-token');
});

it('returns null after clear()', async () => {
const manager = makeManager();
manager.setTokens(makeTokens());

await manager.clear();

expect(manager.getAccessToken()).toBeNull();
});
});

describe('clear()', () => {
it('removes the key pair from DPoPStorage', async () => {
const manager = makeManager();
Expand Down
7 changes: 7 additions & 0 deletions packages/core/src/DPoP/DPoPManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ export class DPoPManager {
return this.tokenStore.get()?.refreshToken ?? null;
}

/**
* Returns the stored access token string, or `null` if none is stored.
*/
getAccessToken(): string | null {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is exposed so the application can call a resource server and is not able to use fetch. In this case the application needs to call generateProof and would need the accessToken in order to add it to the Authorization: DPoP header.

return this.tokenStore.getAccessToken();
}

/**
* Returns the expiration moment (ms since epoch) of the stored access
* token, or `-1` if no tokens are stored. Mirrors the `-1` convention used
Expand Down
34 changes: 34 additions & 0 deletions packages/core/src/SDKCore/SDKCore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,40 @@ describe('SDKCore', () => {
);
});

it('getAccessToken() returns the stored access token when useDpop: true', () => {
vi.spyOn(DPoPManager.prototype, 'getOrCreateKeyPair').mockResolvedValue(
{} as any,
);
const core = new SDKCore(dpopConfig);

const dpopManager = (core as any).dpopManager as DPoPManager;
dpopManager.setTokens({
accessToken: 'mock-access-token',
refreshToken: undefined,
expiresAt: Date.now() + 60_000,
tokenType: 'DPoP',
});

expect(core.getAccessToken()).toBe('mock-access-token');
});

it('getAccessToken() returns null when logged out in DPoP mode', () => {
vi.spyOn(DPoPManager.prototype, 'getOrCreateKeyPair').mockResolvedValue(
{} as any,
);
const core = new SDKCore(dpopConfig);

expect(core.getAccessToken()).toBeNull();
});

it('getAccessToken() throws when useDpop: false', () => {
const core = new SDKCore(config); // no useDpop

expect(() => core.getAccessToken()).toThrow(
'getAccessToken() is only available in DPoP mode. In hosted backend mode, tokens are stored in HttpOnly cookies and are not accessible to JavaScript.',
);
});

describe('handlePostRedirect() in DPoP mode', () => {
const MOCK_PROOF = 'mock-dpop-proof-jwt';
const MOCK_CODE = 'mock-authorization-code';
Expand Down
45 changes: 44 additions & 1 deletion packages/core/src/SDKCore/SDKCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,57 @@ export class SDKCore {
window.location.assign(this.urlHelper.getRegisterUrl(state));
}

startLogout() {
/**
* Initiates the logout flow.
*
* In DPoP mode, this synchronously returns after starting an
* asynchronous flow.
*
* In hosted backend mode, the flow is synchronous.
*/
startLogout(): void {
if (this.dpopManager) {
this.startDpopLogout().catch(error => {
console.error('FusionAuth SDK: startLogout failed', error);
});
return;
}

window.location.assign(this.urlHelper.getLogoutUrl());
}

/**
* Performs the DPoP mode logout flow, clearing the key pair, stored
* tokens, and in-memory nonces.
*/
private async startDpopLogout(): Promise<void> {
try {
await this.dpopManager!.clear();
} finally {
window.location.assign(this.urlHelper.getLogoutUrl());
}
}
Comment thread
Copilot marked this conversation as resolved.

manageAccount() {
window.location.assign(this.urlHelper.getAccountManagementUrl());
}

/**
* Returns the current DPoP mode access token. In hosted backend mode, tokens
* are stored in HttpOnly cookies and are never accessible to JavaScript,
* so this method throws instead.
*
* @throws {Error} if called in hosted backend mode
*/
getAccessToken(): string | null {
if (!this.dpopManager) {
throw new Error(
'getAccessToken() is only available in DPoP mode. In hosted backend mode, tokens are stored in HttpOnly cookies and are not accessible to JavaScript.',
);
}
return this.dpopManager.getAccessToken();
}

async fetchUserInfo<T = UserInfo>() {
const userInfoResponse = await fetch(this.urlHelper.getMeUrl(), {
credentials: 'include',
Expand Down
Loading
Loading