@oxyhq/core 12.10.5 → 12.10.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxyhq/core",
3
- "version": "12.10.5",
3
+ "version": "12.10.6",
4
4
  "description": "OxyHQ SDK Foundation — API client, authentication, cryptographic identity, and shared utilities",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -0,0 +1,51 @@
1
+ import { syncHubAfterSignIn } from '../hubSync';
2
+
3
+ jest.mock('../../utils/officialOrigins', () => {
4
+ const actual = jest.requireActual('../../utils/officialOrigins');
5
+ return {
6
+ ...actual,
7
+ isIdpHubOrigin: jest.fn(() => false),
8
+ isOfficialWebOrigin: jest.fn(() => true),
9
+ buildIdpHubOrigin: jest.fn(() => 'https://auth.oxy.so'),
10
+ };
11
+ });
12
+
13
+ describe('syncHubAfterSignIn', () => {
14
+ const originalLocation = globalThis.location;
15
+ const originalAssign = (globalThis as { location?: Location }).location?.assign;
16
+
17
+ afterEach(() => {
18
+ Object.defineProperty(globalThis, 'location', {
19
+ configurable: true,
20
+ value: originalLocation,
21
+ });
22
+ jest.restoreAllMocks();
23
+ });
24
+
25
+ it('includes the hash fragment in the hub-sync return URL', async () => {
26
+ const assign = jest.fn();
27
+ Object.defineProperty(globalThis, 'location', {
28
+ configurable: true,
29
+ value: {
30
+ origin: 'https://oxy.so',
31
+ pathname: '/pricing',
32
+ search: '?plan=pro',
33
+ hash: '#compare',
34
+ assign,
35
+ },
36
+ });
37
+ Object.defineProperty(globalThis, 'window', {
38
+ configurable: true,
39
+ value: { location: globalThis.location },
40
+ });
41
+
42
+ const issueHubTicket = jest.fn().mockResolvedValue({ ticket: 'tk-1' });
43
+
44
+ const redirected = await syncHubAfterSignIn({ issueHubTicket });
45
+
46
+ expect(redirected).toBe(true);
47
+ expect(issueHubTicket).toHaveBeenCalledWith('https://auth.oxy.so');
48
+ const syncUrl = new URL(String(assign.mock.calls[0]?.[0] ?? ''));
49
+ expect(syncUrl.searchParams.get('return')).toBe('https://oxy.so/pricing?plan=pro#compare');
50
+ });
51
+ });
@@ -51,7 +51,7 @@ export async function syncHubAfterSignIn(
51
51
 
52
52
  const hubOrigin = buildIdpHubOrigin();
53
53
  const issued = await oxy.issueHubTicket(hubOrigin);
54
- const returnUrl = `${location.origin}${location.pathname}${location.search}`;
54
+ const returnUrl = `${location.origin}${location.pathname}${location.search}${location.hash}`;
55
55
  const syncUrl = buildHubSyncUrl(issued.ticket, returnUrl);
56
56
 
57
57
  window.location.assign(syncUrl);