@oxyhq/core 10.2.0 → 11.0.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.
Files changed (103) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/boot/sessionColdBoot.js +3 -3
  3. package/dist/cjs/crypto/keyManager.js +68 -69
  4. package/dist/cjs/crypto/signatureService.js +2 -2
  5. package/dist/cjs/index.js +17 -20
  6. package/dist/cjs/logger/index.js +149 -0
  7. package/dist/cjs/mixins/OxyServices.assets.js +4 -4
  8. package/dist/cjs/mixins/OxyServices.auth.js +104 -2
  9. package/dist/cjs/mixins/OxyServices.language.js +3 -5
  10. package/dist/cjs/mixins/OxyServices.privacy.js +2 -4
  11. package/dist/cjs/mixins/OxyServices.security.js +7 -11
  12. package/dist/cjs/mixins/OxyServices.topics.js +25 -15
  13. package/dist/cjs/mixins/OxyServices.user.js +4 -4
  14. package/dist/cjs/mixins/OxyServices.utility.js +18 -18
  15. package/dist/cjs/session/SessionClient.js +17 -17
  16. package/dist/cjs/session/accountDialogController.js +12 -12
  17. package/dist/cjs/session/authStateStore.js +5 -5
  18. package/dist/cjs/session/refresh.js +4 -4
  19. package/dist/cjs/session/socketLoader.js +2 -2
  20. package/dist/cjs/utils/asyncUtils.js +2 -2
  21. package/dist/cjs/utils/avatarUtils.js +2 -1
  22. package/dist/cjs/utils/deviceManager.js +7 -5
  23. package/dist/cjs/utils/errorUtils.js +3 -3
  24. package/dist/cjs/utils/oauthPkce.js +3 -3
  25. package/dist/cjs/utils/requestUtils.js +1 -1
  26. package/dist/cjs/utils/webauthnOrigin.js +51 -0
  27. package/dist/esm/.tsbuildinfo +1 -1
  28. package/dist/esm/boot/sessionColdBoot.js +1 -1
  29. package/dist/esm/crypto/keyManager.js +1 -2
  30. package/dist/esm/crypto/signatureService.js +1 -1
  31. package/dist/esm/index.js +6 -3
  32. package/dist/esm/logger/index.js +140 -0
  33. package/dist/esm/mixins/OxyServices.assets.js +2 -2
  34. package/dist/esm/mixins/OxyServices.auth.js +103 -1
  35. package/dist/esm/mixins/OxyServices.language.js +3 -5
  36. package/dist/esm/mixins/OxyServices.privacy.js +2 -4
  37. package/dist/esm/mixins/OxyServices.security.js +7 -11
  38. package/dist/esm/mixins/OxyServices.topics.js +25 -15
  39. package/dist/esm/mixins/OxyServices.user.js +1 -1
  40. package/dist/esm/mixins/OxyServices.utility.js +1 -1
  41. package/dist/esm/session/SessionClient.js +1 -1
  42. package/dist/esm/session/accountDialogController.js +1 -1
  43. package/dist/esm/session/authStateStore.js +1 -1
  44. package/dist/esm/session/refresh.js +1 -1
  45. package/dist/esm/session/socketLoader.js +1 -1
  46. package/dist/esm/utils/asyncUtils.js +1 -1
  47. package/dist/esm/utils/avatarUtils.js +2 -1
  48. package/dist/esm/utils/deviceManager.js +7 -5
  49. package/dist/esm/utils/errorUtils.js +1 -1
  50. package/dist/esm/utils/oauthPkce.js +1 -1
  51. package/dist/esm/utils/requestUtils.js +1 -1
  52. package/dist/esm/utils/webauthnOrigin.js +48 -0
  53. package/dist/types/.tsbuildinfo +1 -1
  54. package/dist/types/index.d.ts +4 -4
  55. package/dist/types/logger/index.d.ts +104 -0
  56. package/dist/types/mixins/OxyServices.auth.d.ts +58 -0
  57. package/dist/types/mixins/OxyServices.topics.d.ts +3 -3
  58. package/dist/types/models/Topic.d.ts +10 -0
  59. package/dist/types/utils/requestUtils.d.ts +1 -1
  60. package/dist/types/utils/webauthnOrigin.d.ts +32 -0
  61. package/package.json +17 -2
  62. package/src/boot/sessionColdBoot.ts +1 -1
  63. package/src/crypto/keyManager.ts +1 -2
  64. package/src/crypto/signatureService.ts +1 -1
  65. package/src/index.ts +22 -19
  66. package/src/logger/__tests__/logger.test.ts +207 -0
  67. package/src/logger/index.ts +217 -0
  68. package/src/mixins/OxyServices.assets.ts +3 -3
  69. package/src/mixins/OxyServices.auth.ts +134 -1
  70. package/src/mixins/OxyServices.language.ts +3 -5
  71. package/src/mixins/OxyServices.privacy.ts +2 -4
  72. package/src/mixins/OxyServices.security.ts +7 -11
  73. package/src/mixins/OxyServices.topics.ts +47 -17
  74. package/src/mixins/OxyServices.user.ts +1 -1
  75. package/src/mixins/OxyServices.utility.ts +1 -1
  76. package/src/mixins/__tests__/discoveryErrorHandling.test.ts +1 -1
  77. package/src/mixins/__tests__/topics.test.ts +156 -0
  78. package/src/mixins/__tests__/webauthnAuth.test.ts +206 -0
  79. package/src/models/Topic.ts +11 -0
  80. package/src/session/SessionClient.ts +1 -1
  81. package/src/session/__tests__/SessionClient.diagnostics.test.ts +1 -1
  82. package/src/session/__tests__/accountDialogController.test.ts +1 -1
  83. package/src/session/accountDialogController.ts +1 -1
  84. package/src/session/authStateStore.ts +1 -1
  85. package/src/session/refresh.ts +1 -1
  86. package/src/session/socketLoader.ts +1 -1
  87. package/src/utils/__tests__/webauthnOrigin.test.ts +83 -0
  88. package/src/utils/asyncUtils.ts +1 -1
  89. package/src/utils/avatarUtils.ts +3 -1
  90. package/src/utils/deviceManager.ts +8 -5
  91. package/src/utils/errorUtils.ts +1 -1
  92. package/src/utils/oauthPkce.ts +1 -1
  93. package/src/utils/requestUtils.ts +1 -1
  94. package/src/utils/webauthnOrigin.ts +52 -0
  95. package/dist/cjs/shared/utils/debugUtils.js +0 -80
  96. package/dist/cjs/utils/loggerUtils.js +0 -126
  97. package/dist/esm/shared/utils/debugUtils.js +0 -72
  98. package/dist/esm/utils/loggerUtils.js +0 -115
  99. package/dist/types/shared/utils/debugUtils.d.ts +0 -48
  100. package/dist/types/utils/loggerUtils.d.ts +0 -48
  101. package/src/shared/utils/__tests__/debugUtils.test.ts +0 -55
  102. package/src/shared/utils/debugUtils.ts +0 -78
  103. package/src/utils/loggerUtils.ts +0 -153
@@ -16,7 +16,7 @@
16
16
  * React Native. No `require()`, so the ESM build stays bundler-clean.
17
17
  */
18
18
  import { isNodeJS, isReactNative, loadExpoCrypto, loadNodeCrypto, sha256 } from '@oxyhq/protocol';
19
- import { logger } from './loggerUtils.js';
19
+ import { logger } from '../logger/index.js';
20
20
  /** The central Oxy IdP authorization endpoint used by default. */
21
21
  export const OXY_AUTHORIZE_URL = 'https://auth.oxy.so/authorize';
22
22
  /** Default OAuth scope requested for a "Sign in with Oxy" third-party flow. */
@@ -149,7 +149,7 @@ export class RequestQueue {
149
149
  * Simple logger with level support
150
150
  *
151
151
  * Lightweight logger for HTTP clients and utilities.
152
- * For more advanced logging, use loggerUtils.ts
152
+ * For structured, namespaced, level-gated logging, use `@oxyhq/core/logger`.
153
153
  *
154
154
  * @example
155
155
  * ```typescript
@@ -0,0 +1,48 @@
1
+ /**
2
+ * WebAuthn relying-party origin guard (client side).
3
+ *
4
+ * The passkey ceremonies (`OxyServices.webauthn*`) are only meaningful when the
5
+ * page is served from a first-party Oxy web origin: a credential minted with
6
+ * `WEBAUTHN_RP_ID=oxy.so` can only be created/asserted from `oxy.so`, one of its
7
+ * subdomains, or a loopback dev server. This is the browser-side mirror of the
8
+ * server's `isOxyApexOrigin` (`packages/api/src/utils/origin.ts`), which forms
9
+ * the server's `expectedOrigin` allow-set — consumers use it to decide whether to
10
+ * even offer the passkey UI on the current page.
11
+ *
12
+ * It reads `globalThis.location` directly (no argument) because that is the only
13
+ * origin the browser will let a WebAuthn ceremony run against. On native / SSR /
14
+ * any environment without a DOM `location`, it returns `false` (there is no
15
+ * relying-party origin, so passkeys are not applicable).
16
+ */
17
+ /**
18
+ * True iff the current page's host is a first-party Oxy relying-party origin:
19
+ * `oxy.so`, any `*.oxy.so` subdomain, or a loopback dev host
20
+ * (`localhost` / `127.0.0.1` / `[::1]`).
21
+ *
22
+ * Fails closed: no `location` (native/SSR), a non-string/empty hostname, or a
23
+ * host that merely ends in the literal `oxy.so` without the dot boundary
24
+ * (`evil-oxy.so`, `oxy.so.evil.com`) all return `false`.
25
+ *
26
+ * @example
27
+ * isOxyRpOrigin() // true on https://accounts.oxy.so
28
+ * isOxyRpOrigin() // true on http://localhost:8081
29
+ * isOxyRpOrigin() // false on https://evil.com
30
+ * isOxyRpOrigin() // false in a React Native / SSR context (no location)
31
+ */
32
+ export function isOxyRpOrigin() {
33
+ // `globalThis.location` is typed `Location` by the DOM lib, but is genuinely
34
+ // `undefined` on native/SSR — widen to a nullable local so the guard is a real
35
+ // runtime check, not a type-level no-op.
36
+ const location = globalThis.location;
37
+ if (!location || typeof location.hostname !== 'string') {
38
+ return false;
39
+ }
40
+ const hostname = location.hostname.toLowerCase();
41
+ if (hostname.length === 0) {
42
+ return false;
43
+ }
44
+ if (hostname === 'oxy.so' || hostname.endsWith('.oxy.so')) {
45
+ return true;
46
+ }
47
+ return hostname === 'localhost' || hostname === '127.0.0.1' || hostname === '[::1]';
48
+ }