@oxyhq/core 5.5.0 → 6.0.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 (181) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/HttpService.js +6 -3
  3. package/dist/cjs/OxyServices.base.js +7 -102
  4. package/dist/cjs/boot/coldBootV2.js +350 -0
  5. package/dist/cjs/boot/deviceBootReturn.js +152 -0
  6. package/dist/cjs/crypto/keyManager.js +95 -0
  7. package/dist/cjs/i18n/locales/en-US.json +13 -1
  8. package/dist/cjs/i18n/locales/es-ES.json +13 -1
  9. package/dist/cjs/i18n/locales/locales/en-US.json +13 -1
  10. package/dist/cjs/i18n/locales/locales/es-ES.json +13 -1
  11. package/dist/cjs/index.js +47 -44
  12. package/dist/cjs/mixins/OxyServices.accounts.js +6 -13
  13. package/dist/cjs/mixins/OxyServices.auth.js +66 -201
  14. package/dist/cjs/mixins/OxyServices.authorizedApps.js +38 -0
  15. package/dist/cjs/mixins/OxyServices.deviceBoot.js +119 -0
  16. package/dist/cjs/mixins/index.js +13 -17
  17. package/dist/cjs/session/SessionClient.js +40 -1
  18. package/dist/cjs/session/authStateStore.js +284 -0
  19. package/dist/cjs/session/refresh.js +264 -0
  20. package/dist/cjs/utils/accountUtils.js +1 -55
  21. package/dist/cjs/utils/authWebUrl.js +6 -15
  22. package/dist/cjs/utils/fapiAutoDetect.js +16 -64
  23. package/dist/cjs/utils/platform.js +19 -0
  24. package/dist/cjs/utils/ssoBounce.js +15 -362
  25. package/dist/cjs/utils/validationUtils.js +57 -0
  26. package/dist/esm/.tsbuildinfo +1 -1
  27. package/dist/esm/HttpService.js +6 -3
  28. package/dist/esm/OxyServices.base.js +7 -102
  29. package/dist/esm/boot/coldBootV2.js +344 -0
  30. package/dist/esm/boot/deviceBootReturn.js +146 -0
  31. package/dist/esm/crypto/keyManager.js +95 -0
  32. package/dist/esm/i18n/locales/en-US.json +13 -1
  33. package/dist/esm/i18n/locales/es-ES.json +13 -1
  34. package/dist/esm/i18n/locales/locales/en-US.json +13 -1
  35. package/dist/esm/i18n/locales/locales/es-ES.json +13 -1
  36. package/dist/esm/index.js +28 -18
  37. package/dist/esm/mixins/OxyServices.accounts.js +6 -13
  38. package/dist/esm/mixins/OxyServices.auth.js +66 -201
  39. package/dist/esm/mixins/OxyServices.authorizedApps.js +35 -0
  40. package/dist/esm/mixins/OxyServices.deviceBoot.js +116 -0
  41. package/dist/esm/mixins/index.js +13 -17
  42. package/dist/esm/session/SessionClient.js +40 -1
  43. package/dist/esm/session/authStateStore.js +278 -0
  44. package/dist/esm/session/refresh.js +257 -0
  45. package/dist/esm/utils/accountUtils.js +0 -53
  46. package/dist/esm/utils/authWebUrl.js +6 -14
  47. package/dist/esm/utils/fapiAutoDetect.js +16 -63
  48. package/dist/esm/utils/platform.js +18 -0
  49. package/dist/esm/utils/ssoBounce.js +14 -345
  50. package/dist/esm/utils/validationUtils.js +56 -0
  51. package/dist/types/.tsbuildinfo +1 -1
  52. package/dist/types/HttpService.d.ts +13 -0
  53. package/dist/types/OxyServices.base.d.ts +0 -52
  54. package/dist/types/OxyServices.d.ts +0 -25
  55. package/dist/types/boot/coldBootV2.d.ts +76 -0
  56. package/dist/types/boot/deviceBootReturn.d.ts +83 -0
  57. package/dist/types/crypto/keyManager.d.ts +21 -0
  58. package/dist/types/index.d.ts +15 -21
  59. package/dist/types/mixins/OxyServices.accounts.d.ts +0 -2
  60. package/dist/types/mixins/OxyServices.analytics.d.ts +0 -2
  61. package/dist/types/mixins/OxyServices.appData.d.ts +0 -2
  62. package/dist/types/mixins/OxyServices.assets.d.ts +0 -2
  63. package/dist/types/mixins/OxyServices.auth.d.ts +35 -77
  64. package/dist/types/mixins/{OxyServices.redirect.d.ts → OxyServices.authorizedApps.d.ts} +35 -33
  65. package/dist/types/mixins/OxyServices.civic.d.ts +0 -2
  66. package/dist/types/mixins/OxyServices.connectedApps.d.ts +0 -2
  67. package/dist/types/mixins/OxyServices.contacts.d.ts +0 -2
  68. package/dist/types/mixins/OxyServices.deviceBoot.d.ts +110 -0
  69. package/dist/types/mixins/OxyServices.devices.d.ts +0 -2
  70. package/dist/types/mixins/OxyServices.features.d.ts +0 -2
  71. package/dist/types/mixins/OxyServices.identity.d.ts +0 -2
  72. package/dist/types/mixins/OxyServices.language.d.ts +0 -2
  73. package/dist/types/mixins/OxyServices.links.d.ts +0 -2
  74. package/dist/types/mixins/OxyServices.location.d.ts +0 -2
  75. package/dist/types/mixins/OxyServices.nodes.d.ts +0 -2
  76. package/dist/types/mixins/OxyServices.payment.d.ts +0 -2
  77. package/dist/types/mixins/OxyServices.privacy.d.ts +0 -2
  78. package/dist/types/mixins/OxyServices.reputation.d.ts +0 -2
  79. package/dist/types/mixins/OxyServices.security.d.ts +0 -2
  80. package/dist/types/mixins/OxyServices.topics.d.ts +0 -2
  81. package/dist/types/mixins/OxyServices.user.d.ts +0 -2
  82. package/dist/types/mixins/OxyServices.utility.d.ts +0 -2
  83. package/dist/types/mixins/index.d.ts +6 -9
  84. package/dist/types/models/interfaces.d.ts +0 -67
  85. package/dist/types/session/SessionClient.d.ts +25 -0
  86. package/dist/types/session/authStateStore.d.ts +119 -0
  87. package/dist/types/session/refresh.d.ts +93 -0
  88. package/dist/types/utils/accountUtils.d.ts +0 -14
  89. package/dist/types/utils/authWebUrl.d.ts +6 -12
  90. package/dist/types/utils/fapiAutoDetect.d.ts +15 -38
  91. package/dist/types/utils/platform.d.ts +14 -0
  92. package/dist/types/utils/ssoBounce.d.ts +14 -280
  93. package/dist/types/utils/validationUtils.d.ts +15 -0
  94. package/package.json +2 -2
  95. package/src/HttpService.ts +19 -3
  96. package/src/OxyServices.base.ts +7 -112
  97. package/src/OxyServices.ts +0 -38
  98. package/src/boot/__tests__/coldBootV2.test.ts +317 -0
  99. package/src/boot/__tests__/deviceBootReturn.test.ts +158 -0
  100. package/src/boot/coldBootV2.ts +426 -0
  101. package/src/boot/deviceBootReturn.ts +195 -0
  102. package/src/crypto/__tests__/sharedDeviceToken.test.ts +24 -0
  103. package/src/crypto/keyManager.ts +101 -0
  104. package/src/i18n/locales/en-US.json +13 -1
  105. package/src/i18n/locales/es-ES.json +13 -1
  106. package/src/index.ts +74 -65
  107. package/src/mixins/OxyServices.accounts.ts +6 -13
  108. package/src/mixins/OxyServices.auth.ts +78 -253
  109. package/src/mixins/OxyServices.authorizedApps.ts +75 -0
  110. package/src/mixins/OxyServices.deviceBoot.ts +146 -0
  111. package/src/mixins/__tests__/OxyServices.deviceBoot.test.ts +107 -0
  112. package/src/mixins/__tests__/accounts.test.ts +17 -44
  113. package/src/mixins/__tests__/authorizedApps.test.ts +63 -0
  114. package/src/mixins/__tests__/passwordSignIn.test.ts +91 -0
  115. package/src/mixins/index.ts +16 -22
  116. package/src/models/interfaces.ts +0 -79
  117. package/src/session/SessionClient.ts +52 -1
  118. package/src/session/__tests__/SessionClient.additive.test.ts +92 -0
  119. package/src/session/__tests__/SessionClient.rest.test.ts +25 -0
  120. package/src/session/__tests__/SessionClient.state.test.ts +18 -5
  121. package/src/session/__tests__/authStateStore.test.ts +209 -0
  122. package/src/session/__tests__/refresh.test.ts +256 -0
  123. package/src/session/authStateStore.ts +335 -0
  124. package/src/session/refresh.ts +334 -0
  125. package/src/utils/__tests__/authWebUrl.test.ts +5 -29
  126. package/src/utils/__tests__/fapiAutoDetect.test.ts +5 -126
  127. package/src/utils/__tests__/validationUtils.test.ts +30 -0
  128. package/src/utils/accountUtils.ts +0 -62
  129. package/src/utils/authWebUrl.ts +6 -15
  130. package/src/utils/fapiAutoDetect.ts +16 -60
  131. package/src/utils/platform.ts +21 -0
  132. package/src/utils/ssoBounce.ts +14 -393
  133. package/src/utils/validationUtils.ts +62 -0
  134. package/dist/cjs/AuthManager.js +0 -1110
  135. package/dist/cjs/AuthManagerTypes.js +0 -13
  136. package/dist/cjs/CrossDomainAuth.js +0 -206
  137. package/dist/cjs/mixins/OxyServices.fedcm.js +0 -823
  138. package/dist/cjs/mixins/OxyServices.redirect.js +0 -95
  139. package/dist/cjs/mixins/OxyServices.silent.js +0 -204
  140. package/dist/cjs/mixins/OxyServices.sso.js +0 -208
  141. package/dist/cjs/utils/ssoEstablish.js +0 -110
  142. package/dist/cjs/utils/ssoReturn.js +0 -275
  143. package/dist/esm/AuthManager.js +0 -1105
  144. package/dist/esm/AuthManagerTypes.js +0 -12
  145. package/dist/esm/CrossDomainAuth.js +0 -201
  146. package/dist/esm/mixins/OxyServices.fedcm.js +0 -821
  147. package/dist/esm/mixins/OxyServices.redirect.js +0 -92
  148. package/dist/esm/mixins/OxyServices.silent.js +0 -202
  149. package/dist/esm/mixins/OxyServices.sso.js +0 -204
  150. package/dist/esm/utils/ssoEstablish.js +0 -107
  151. package/dist/esm/utils/ssoReturn.js +0 -271
  152. package/dist/types/AuthManager.d.ts +0 -380
  153. package/dist/types/AuthManagerTypes.d.ts +0 -81
  154. package/dist/types/CrossDomainAuth.d.ts +0 -164
  155. package/dist/types/mixins/OxyServices.fedcm.d.ts +0 -331
  156. package/dist/types/mixins/OxyServices.silent.d.ts +0 -132
  157. package/dist/types/mixins/OxyServices.sso.d.ts +0 -138
  158. package/dist/types/utils/ssoEstablish.d.ts +0 -85
  159. package/dist/types/utils/ssoReturn.d.ts +0 -156
  160. package/src/AuthManager.ts +0 -1269
  161. package/src/AuthManagerTypes.ts +0 -86
  162. package/src/CrossDomainAuth.ts +0 -243
  163. package/src/__tests__/authManager.cookiePath.test.ts +0 -390
  164. package/src/__tests__/authManager.security.test.ts +0 -377
  165. package/src/__tests__/crossDomainAuth.test.ts +0 -116
  166. package/src/__tests__/establishDeviceRefreshSlot.test.ts +0 -221
  167. package/src/mixins/OxyServices.fedcm.ts +0 -1026
  168. package/src/mixins/OxyServices.redirect.ts +0 -122
  169. package/src/mixins/OxyServices.silent.ts +0 -272
  170. package/src/mixins/OxyServices.sso.ts +0 -261
  171. package/src/mixins/__tests__/constructorAuthWebUrl.test.ts +0 -85
  172. package/src/mixins/__tests__/fedcm.test.ts +0 -667
  173. package/src/mixins/__tests__/sessionBaseUrl.test.ts +0 -61
  174. package/src/mixins/__tests__/silent.test.ts +0 -102
  175. package/src/mixins/__tests__/sso.test.ts +0 -228
  176. package/src/utils/__tests__/consumeSsoReturn.test.ts +0 -816
  177. package/src/utils/__tests__/ssoBounce.test.ts +0 -219
  178. package/src/utils/__tests__/ssoEstablish.test.ts +0 -204
  179. package/src/utils/__tests__/ssoReturn.test.ts +0 -276
  180. package/src/utils/ssoEstablish.ts +0 -174
  181. package/src/utils/ssoReturn.ts +0 -389
@@ -1,13 +0,0 @@
1
- "use strict";
2
- /**
3
- * AuthManager — public types for the multi-account cookie path.
4
- *
5
- * Lives in its own module (rather than the 670-line `models/interfaces.ts`)
6
- * so consumers can `import type` exactly the multi-account surface without
7
- * pulling in the full interfaces graph, and so `AuthManager.ts` stays
8
- * decoupled from the wire shapes — these types re-state the wire as the
9
- * AuthManager's in-memory representation.
10
- *
11
- * @module core/AuthManagerTypes
12
- */
13
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,206 +0,0 @@
1
- "use strict";
2
- /**
3
- * Cross-Domain Authentication Helper
4
- *
5
- * Provides a simplified API for cross-domain SSO authentication. The
6
- * automatic sign-in path uses a full-page redirect through the central IdP
7
- * (`auth.oxy.so`) — a tokenless, universal mechanism that works in every
8
- * browser.
9
- *
10
- * FedCM (`signInWithFedCM`) is intentionally NOT part of the automatic
11
- * (`'auto'`) path: it is a Chrome-only browser API, and a misconfigured or
12
- * unreachable FedCM endpoint fails fast and silently, which — combined with a
13
- * caller's auth-guard effect re-invoking `signIn()` whenever the user is still
14
- * unauthenticated — produced a real production incident (an accelerating
15
- * `autoSignIn` → FedCM-fails → redirect retry loop). `signInWithFedCM` remains
16
- * available for callers that want to opt into it EXPLICITLY
17
- * (`signIn({ method: 'fedcm' })`).
18
- *
19
- * Usage:
20
- * ```typescript
21
- * import { CrossDomainAuth } from '@oxyhq/core';
22
- *
23
- * const auth = new CrossDomainAuth(oxyServices);
24
- *
25
- * // Automatic method selection (always redirect)
26
- * const session = await auth.signIn();
27
- *
28
- * // Or use a specific method
29
- * auth.signInWithRedirect();
30
- * ```
31
- */
32
- Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.CrossDomainAuth = void 0;
34
- exports.createCrossDomainAuth = createCrossDomainAuth;
35
- const loggerUtils_1 = require("./utils/loggerUtils");
36
- class CrossDomainAuth {
37
- constructor(oxyServices) {
38
- this.oxyServices = oxyServices;
39
- }
40
- /**
41
- * Sign in with automatic method selection.
42
- *
43
- * Auto mode always uses the full-page redirect (see the class doc comment
44
- * for why FedCM was removed from this path). Pass `{ method: 'fedcm' }` to
45
- * opt into FedCM explicitly.
46
- *
47
- * @param options - Authentication options
48
- * @returns Session with user data and access token
49
- */
50
- async signIn(options = {}) {
51
- const method = options.method || 'auto';
52
- if (method === 'fedcm') {
53
- return this.signInWithFedCM(options);
54
- }
55
- if (method === 'redirect') {
56
- this.signInWithRedirect(options);
57
- return null; // Redirect doesn't return immediately
58
- }
59
- // Auto mode: try methods in order of preference.
60
- return this.autoSignIn(options);
61
- }
62
- /**
63
- * Automatic sign-in.
64
- *
65
- * Goes straight to the full-page redirect — the sole automatic method.
66
- * FedCM is deliberately NOT attempted here (see the class doc comment):
67
- * it is Chrome-only, and its fast/silent failure mode combined with a
68
- * caller's auth-guard effect re-invoking `signIn()` produced a real
69
- * production sign-in loop. Use `signIn({ method: 'fedcm' })` to opt in
70
- * explicitly.
71
- *
72
- * @private
73
- */
74
- async autoSignIn(options) {
75
- options.onMethodSelected?.('redirect');
76
- this.signInWithRedirect(options);
77
- return null;
78
- }
79
- /**
80
- * Sign in using FedCM (Federated Credential Management)
81
- *
82
- * Best method - browser-native, Google-like experience
83
- */
84
- async signInWithFedCM(options = {}) {
85
- return this.oxyServices.signInWithFedCM({
86
- context: options.isSignup ? 'signup' : 'signin',
87
- });
88
- }
89
- /**
90
- * Sign in using full-page redirect
91
- *
92
- * Fallback method - works everywhere but loses app state
93
- */
94
- signInWithRedirect(options = {}) {
95
- this.oxyServices.signInWithRedirect({
96
- redirectUri: options.redirectUri,
97
- mode: options.isSignup ? 'signup' : 'login',
98
- });
99
- }
100
- /**
101
- * Handle redirect callback
102
- *
103
- * Call this on app startup to check if we're returning from auth redirect
104
- */
105
- handleRedirectCallback() {
106
- return this.oxyServices.handleAuthCallback();
107
- }
108
- /**
109
- * Silent sign-in (check for existing session)
110
- *
111
- * Tries to automatically sign in without user interaction, via the
112
- * iframe-based silent auth against the per-apex `/auth/silent` IdP host.
113
- * FedCM is deliberately NOT attempted here (see the class doc comment).
114
- *
115
- * @returns Session if user is already signed in, null otherwise
116
- */
117
- async silentSignIn() {
118
- try {
119
- return await this.oxyServices.silentSignIn();
120
- }
121
- catch (error) {
122
- loggerUtils_1.logger.debug('iframe silent sign-in did not resolve', { component: 'CrossDomainAuth', method: 'silentSignIn' }, error);
123
- return null;
124
- }
125
- }
126
- /**
127
- * Restore session from storage.
128
- *
129
- * Access tokens are no longer persisted in browser storage; providers restore
130
- * through refresh cookies / SSO code exchange instead.
131
- */
132
- restoreSession() {
133
- return false;
134
- }
135
- /**
136
- * Check if FedCM is supported in current browser
137
- */
138
- isFedCMSupported() {
139
- // FedCM support is exposed both as a static and an instance method on
140
- // OxyServices; the instance method is reliable across mixin composition.
141
- return this.oxyServices.isFedCMSupported?.() || false;
142
- }
143
- /**
144
- * Get recommended authentication method for current environment
145
- *
146
- * Redirect is the sole recommended automatic method — it works in every
147
- * browser, unlike FedCM (Chrome-only). Callers that want FedCM must opt in
148
- * explicitly via `signIn({ method: 'fedcm' })`.
149
- *
150
- * @returns Recommended method name and reason
151
- */
152
- getRecommendedMethod() {
153
- if (typeof window !== 'undefined') {
154
- return {
155
- method: 'redirect',
156
- reason: 'Browser environment - redirect SSO works without token callback URLs',
157
- };
158
- }
159
- return {
160
- method: 'redirect',
161
- reason: 'Fallback method - works in all environments',
162
- };
163
- }
164
- /**
165
- * Initialize cross-domain auth on app startup
166
- *
167
- * This handles:
168
- * 1. Redirect callback (if returning from auth.oxy.so)
169
- * 2. Silent sign-in (check for existing SSO session)
170
- *
171
- * @returns Session if user is authenticated, null otherwise
172
- */
173
- async initialize() {
174
- // 1. Check if this is a redirect callback
175
- const callbackSession = this.handleRedirectCallback();
176
- if (callbackSession) {
177
- return callbackSession;
178
- }
179
- // 2. Try silent sign-in (check for SSO session at auth.oxy.so)
180
- return await this.silentSignIn();
181
- }
182
- }
183
- exports.CrossDomainAuth = CrossDomainAuth;
184
- /**
185
- * Helper function to create CrossDomainAuth instance
186
- *
187
- * @example
188
- * ```typescript
189
- * import { createCrossDomainAuth } from '@oxyhq/core';
190
- *
191
- * const oxyServices = new OxyServices({ baseURL: 'https://api.oxy.so' });
192
- * const auth = createCrossDomainAuth(oxyServices);
193
- *
194
- * // On app startup
195
- * const session = await auth.initialize();
196
- * if (session) {
197
- * console.log('User is signed in:', session.user);
198
- * }
199
- *
200
- * // Sign in button click
201
- * const session = await auth.signIn();
202
- * ```
203
- */
204
- function createCrossDomainAuth(oxyServices) {
205
- return new CrossDomainAuth(oxyServices);
206
- }