@oxyhq/core 12.11.1 → 13.2.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.
Files changed (56) hide show
  1. package/README.md +36 -2
  2. package/dist/cjs/.tsbuildinfo +1 -1
  3. package/dist/cjs/index.js +4 -13
  4. package/dist/cjs/mixins/OxyServices.deviceBoot.js +0 -31
  5. package/dist/cjs/mixins/OxyServices.user.js +50 -44
  6. package/dist/cjs/server/index.js +9 -6
  7. package/dist/cjs/server/rateLimit.js +3 -0
  8. package/dist/cjs/server/securityHeaders.js +234 -0
  9. package/dist/cjs/session/accountDialogController.js +6 -8
  10. package/dist/cjs/utils/apiUtils.js +40 -10
  11. package/dist/cjs/utils/oauthPkce.js +1 -5
  12. package/dist/cjs/utils/officialOrigins.js +3 -73
  13. package/dist/esm/.tsbuildinfo +1 -1
  14. package/dist/esm/index.js +3 -4
  15. package/dist/esm/mixins/OxyServices.deviceBoot.js +1 -32
  16. package/dist/esm/mixins/OxyServices.user.js +51 -45
  17. package/dist/esm/server/index.js +4 -1
  18. package/dist/esm/server/rateLimit.js +3 -0
  19. package/dist/esm/server/securityHeaders.js +224 -0
  20. package/dist/esm/session/accountDialogController.js +6 -8
  21. package/dist/esm/utils/apiUtils.js +39 -10
  22. package/dist/esm/utils/oauthPkce.js +0 -4
  23. package/dist/esm/utils/officialOrigins.js +3 -68
  24. package/dist/types/.tsbuildinfo +1 -1
  25. package/dist/types/index.d.ts +5 -7
  26. package/dist/types/mixins/OxyServices.auth.d.ts +1 -12
  27. package/dist/types/mixins/OxyServices.deviceBoot.d.ts +1 -5
  28. package/dist/types/mixins/OxyServices.user.d.ts +27 -6
  29. package/dist/types/server/index.d.ts +3 -1
  30. package/dist/types/server/securityHeaders.d.ts +154 -0
  31. package/dist/types/session/accountDialogController.d.ts +9 -15
  32. package/dist/types/utils/apiUtils.d.ts +48 -6
  33. package/dist/types/utils/oauthPkce.d.ts +11 -7
  34. package/dist/types/utils/officialOrigins.d.ts +3 -13
  35. package/package.json +10 -5
  36. package/src/index.ts +9 -14
  37. package/src/mixins/OxyServices.auth.ts +6 -13
  38. package/src/mixins/OxyServices.deviceBoot.ts +0 -47
  39. package/src/mixins/OxyServices.user.ts +60 -49
  40. package/src/mixins/__tests__/commonsSignIn.test.ts +9 -2
  41. package/src/mixins/__tests__/followGraphPagination.test.ts +250 -0
  42. package/src/server/__tests__/securityHeaders.test.ts +244 -0
  43. package/src/server/index.ts +17 -8
  44. package/src/server/rateLimit.ts +3 -0
  45. package/src/server/securityHeaders.ts +304 -0
  46. package/src/session/__tests__/accountDialogController.test.ts +3 -5
  47. package/src/session/accountDialogController.ts +12 -18
  48. package/src/utils/__tests__/officialOrigins.test.ts +0 -57
  49. package/src/utils/apiUtils.ts +64 -15
  50. package/src/utils/oauthPkce.ts +11 -9
  51. package/src/utils/officialOrigins.ts +3 -70
  52. package/dist/cjs/session/hubSync.js +0 -55
  53. package/dist/esm/session/hubSync.js +0 -51
  54. package/dist/types/session/hubSync.d.ts +0 -20
  55. package/src/session/__tests__/hubSync.test.ts +0 -51
  56. package/src/session/hubSync.ts +0 -79
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Official first-party web origin allowlist — shared by hub-ticket issuance,
3
- * OAuth redirect validation, and cross-origin session restore.
2
+ * Official first-party web origin allowlist — shared by OAuth redirect
3
+ * validation and the server-side trusted-origin checks.
4
4
  */
5
5
  import { CENTRAL_IDP_APEX } from './authWebUrl.js';
6
6
  import { registrableApex } from './registrableApex.js';
@@ -17,30 +17,9 @@ const OFFICIAL_APEXES = new Set([
17
17
  'moovo.now',
18
18
  'mercaria.co',
19
19
  ]);
20
- export function buildIdpHubOrigin() {
21
- return `https://auth.${CENTRAL_IDP_APEX}`;
22
- }
23
- /** Whether the current web origin is the central IdP hub (`auth.oxy.so`). */
24
- export function isIdpHubOrigin() {
25
- if (typeof globalThis === 'undefined') {
26
- return false;
27
- }
28
- const location = globalThis.location;
29
- if (!location) {
30
- return false;
31
- }
32
- try {
33
- const { hostname } = new URL(location.href);
34
- return hostname === `auth.${CENTRAL_IDP_APEX}`;
35
- }
36
- catch {
37
- return false;
38
- }
39
- }
40
20
  /**
41
21
  * Whether an origin is a loopback / local-dev origin (`localhost`, `127.0.0.1`,
42
- * or `[::1]` on any port, http or https). Local dev must never be bounced to a
43
- * hosted IdP for cross-origin session restore.
22
+ * or `[::1]` on any port, http or https).
44
23
  */
45
24
  export function isLoopbackOrigin(origin) {
46
25
  try {
@@ -76,49 +55,5 @@ export function isOfficialWebOrigin(origin) {
76
55
  return false;
77
56
  }
78
57
  }
79
- /** Normalize and validate a return URL against official origins. Returns origin only. */
80
- export function normalizeOfficialReturnOrigin(raw) {
81
- try {
82
- const parsed = new URL(raw);
83
- if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {
84
- return null;
85
- }
86
- if (!isOfficialWebOrigin(parsed.origin)) {
87
- return null;
88
- }
89
- return parsed.origin;
90
- }
91
- catch {
92
- return null;
93
- }
94
- }
95
- /** Validate a hub-sync return URL; returns the full normalized URL string. */
96
- export function parseHubSyncReturnUrl(raw) {
97
- if (!raw) {
98
- return null;
99
- }
100
- try {
101
- const parsed = new URL(raw);
102
- if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {
103
- return null;
104
- }
105
- if (!isOfficialWebOrigin(parsed.origin)) {
106
- return null;
107
- }
108
- return parsed.toString();
109
- }
110
- catch {
111
- return null;
112
- }
113
- }
114
- /** Build auth.oxy.so/sync redirect URL with a one-time hub ticket. */
115
- export function buildHubSyncUrl(ticket, returnUrl) {
116
- const url = new URL('/sync', buildIdpHubOrigin());
117
- url.searchParams.set('ticket', ticket);
118
- if (returnUrl) {
119
- url.searchParams.set('return', returnUrl);
120
- }
121
- return url.toString();
122
- }
123
58
  /** @deprecated Use {@link isOfficialWebOrigin}. */
124
59
  export const isAllowedDeviceJoinOrigin = isOfficialWebOrigin;