@oxyhq/core 1.11.24 → 2.1.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.
- package/README.md +5 -6
- package/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/AuthManager.js +678 -4
- package/dist/cjs/AuthManagerTypes.js +13 -0
- package/dist/cjs/CrossDomainAuth.js +45 -3
- package/dist/cjs/OxyServices.base.js +16 -0
- package/dist/cjs/i18n/locales/ar-SA.json +83 -0
- package/dist/cjs/i18n/locales/ca-ES.json +83 -0
- package/dist/cjs/i18n/locales/de-DE.json +83 -0
- package/dist/cjs/i18n/locales/en-US.json +83 -0
- package/dist/cjs/i18n/locales/es-ES.json +99 -4
- package/dist/cjs/i18n/locales/fr-FR.json +83 -0
- package/dist/cjs/i18n/locales/it-IT.json +83 -0
- package/dist/cjs/i18n/locales/ja-JP.json +83 -0
- package/dist/cjs/i18n/locales/ko-KR.json +83 -0
- package/dist/cjs/i18n/locales/locales/ar-SA.json +83 -1
- package/dist/cjs/i18n/locales/locales/ca-ES.json +83 -1
- package/dist/cjs/i18n/locales/locales/de-DE.json +83 -1
- package/dist/cjs/i18n/locales/locales/en-US.json +83 -0
- package/dist/cjs/i18n/locales/locales/es-ES.json +99 -4
- package/dist/cjs/i18n/locales/locales/fr-FR.json +83 -1
- package/dist/cjs/i18n/locales/locales/it-IT.json +83 -1
- package/dist/cjs/i18n/locales/locales/ja-JP.json +200 -117
- package/dist/cjs/i18n/locales/locales/ko-KR.json +83 -1
- package/dist/cjs/i18n/locales/locales/pt-PT.json +83 -1
- package/dist/cjs/i18n/locales/locales/zh-CN.json +83 -1
- package/dist/cjs/i18n/locales/pt-PT.json +83 -0
- package/dist/cjs/i18n/locales/zh-CN.json +83 -0
- package/dist/cjs/index.js +121 -57
- package/dist/cjs/mixins/OxyServices.auth.js +235 -0
- package/dist/cjs/mixins/OxyServices.fedcm.js +36 -0
- package/dist/cjs/mixins/OxyServices.popup.js +61 -1
- package/dist/cjs/mixins/OxyServices.user.js +18 -0
- package/dist/cjs/utils/accountUtils.js +64 -1
- package/dist/cjs/utils/coldBoot.js +71 -0
- package/dist/cjs/utils/fapiAutoDetect.js +88 -0
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/AuthManager.js +678 -4
- package/dist/esm/AuthManagerTypes.js +12 -0
- package/dist/esm/CrossDomainAuth.js +45 -3
- package/dist/esm/OxyServices.base.js +16 -0
- package/dist/esm/i18n/locales/ar-SA.json +83 -0
- package/dist/esm/i18n/locales/ca-ES.json +83 -0
- package/dist/esm/i18n/locales/de-DE.json +83 -0
- package/dist/esm/i18n/locales/en-US.json +83 -0
- package/dist/esm/i18n/locales/es-ES.json +99 -4
- package/dist/esm/i18n/locales/fr-FR.json +83 -0
- package/dist/esm/i18n/locales/it-IT.json +83 -0
- package/dist/esm/i18n/locales/ja-JP.json +83 -0
- package/dist/esm/i18n/locales/ko-KR.json +83 -0
- package/dist/esm/i18n/locales/locales/ar-SA.json +83 -1
- package/dist/esm/i18n/locales/locales/ca-ES.json +83 -1
- package/dist/esm/i18n/locales/locales/de-DE.json +83 -1
- package/dist/esm/i18n/locales/locales/en-US.json +83 -0
- package/dist/esm/i18n/locales/locales/es-ES.json +99 -4
- package/dist/esm/i18n/locales/locales/fr-FR.json +83 -1
- package/dist/esm/i18n/locales/locales/it-IT.json +83 -1
- package/dist/esm/i18n/locales/locales/ja-JP.json +200 -117
- package/dist/esm/i18n/locales/locales/ko-KR.json +83 -1
- package/dist/esm/i18n/locales/locales/pt-PT.json +83 -1
- package/dist/esm/i18n/locales/locales/zh-CN.json +83 -1
- package/dist/esm/i18n/locales/pt-PT.json +83 -0
- package/dist/esm/i18n/locales/zh-CN.json +83 -0
- package/dist/esm/index.js +74 -26
- package/dist/esm/mixins/OxyServices.auth.js +235 -0
- package/dist/esm/mixins/OxyServices.fedcm.js +36 -0
- package/dist/esm/mixins/OxyServices.popup.js +61 -1
- package/dist/esm/mixins/OxyServices.user.js +18 -0
- package/dist/esm/utils/accountUtils.js +61 -0
- package/dist/esm/utils/coldBoot.js +68 -0
- package/dist/esm/utils/fapiAutoDetect.js +85 -0
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/AuthManager.d.ts +243 -3
- package/dist/types/AuthManagerTypes.d.ts +68 -0
- package/dist/types/CrossDomainAuth.d.ts +23 -0
- package/dist/types/OxyServices.base.d.ts +14 -0
- package/dist/types/OxyServices.d.ts +7 -0
- package/dist/types/index.d.ts +31 -17
- package/dist/types/mixins/OxyServices.analytics.d.ts +1 -0
- package/dist/types/mixins/OxyServices.appData.d.ts +1 -0
- package/dist/types/mixins/OxyServices.assets.d.ts +4 -1
- package/dist/types/mixins/OxyServices.auth.d.ts +73 -1
- package/dist/types/mixins/OxyServices.contacts.d.ts +1 -0
- package/dist/types/mixins/OxyServices.developer.d.ts +1 -0
- package/dist/types/mixins/OxyServices.devices.d.ts +1 -0
- package/dist/types/mixins/OxyServices.features.d.ts +2 -5
- package/dist/types/mixins/OxyServices.fedcm.d.ts +34 -0
- package/dist/types/mixins/OxyServices.karma.d.ts +1 -0
- package/dist/types/mixins/OxyServices.language.d.ts +1 -0
- package/dist/types/mixins/OxyServices.location.d.ts +1 -0
- package/dist/types/mixins/OxyServices.managedAccounts.d.ts +1 -0
- package/dist/types/mixins/OxyServices.payment.d.ts +1 -0
- package/dist/types/mixins/OxyServices.popup.d.ts +40 -0
- package/dist/types/mixins/OxyServices.privacy.d.ts +1 -0
- package/dist/types/mixins/OxyServices.redirect.d.ts +1 -0
- package/dist/types/mixins/OxyServices.security.d.ts +1 -0
- package/dist/types/mixins/OxyServices.topics.d.ts +1 -0
- package/dist/types/mixins/OxyServices.user.d.ts +16 -1
- package/dist/types/mixins/OxyServices.utility.d.ts +1 -0
- package/dist/types/models/interfaces.d.ts +98 -0
- package/dist/types/models/session.d.ts +8 -0
- package/dist/types/utils/accountUtils.d.ts +33 -0
- package/dist/types/utils/coldBoot.d.ts +102 -0
- package/dist/types/utils/fapiAutoDetect.d.ts +37 -0
- package/package.json +9 -18
- package/src/AuthManager.ts +776 -7
- package/src/AuthManagerTypes.ts +72 -0
- package/src/CrossDomainAuth.ts +54 -3
- package/src/OxyServices.base.ts +17 -0
- package/src/OxyServices.ts +7 -0
- package/src/__tests__/authManager.cookiePath.test.ts +339 -0
- package/src/__tests__/authManager.security.test.ts +342 -0
- package/src/__tests__/crossDomainAuth.test.ts +191 -0
- package/src/i18n/locales/ar-SA.json +83 -1
- package/src/i18n/locales/ca-ES.json +83 -1
- package/src/i18n/locales/de-DE.json +83 -1
- package/src/i18n/locales/en-US.json +83 -0
- package/src/i18n/locales/es-ES.json +99 -4
- package/src/i18n/locales/fr-FR.json +83 -1
- package/src/i18n/locales/it-IT.json +83 -1
- package/src/i18n/locales/ja-JP.json +200 -117
- package/src/i18n/locales/ko-KR.json +83 -1
- package/src/i18n/locales/pt-PT.json +83 -1
- package/src/i18n/locales/zh-CN.json +83 -1
- package/src/index.ts +309 -112
- package/src/mixins/OxyServices.auth.ts +268 -1
- package/src/mixins/OxyServices.fedcm.ts +63 -0
- package/src/mixins/OxyServices.popup.ts +79 -1
- package/src/mixins/OxyServices.user.ts +33 -1
- package/src/mixins/__tests__/popup.test.ts +307 -0
- package/src/mixins/__tests__/sessionBaseUrl.test.ts +61 -0
- package/src/models/interfaces.ts +116 -0
- package/src/models/session.ts +8 -0
- package/src/utils/__tests__/coldBoot.test.ts +226 -0
- package/src/utils/__tests__/fapiAutoDetect.test.ts +93 -0
- package/src/utils/accountUtils.ts +84 -0
- package/src/utils/coldBoot.ts +136 -0
- package/src/utils/fapiAutoDetect.ts +82 -0
- package/dist/cjs/crypto/index.js +0 -22
- package/dist/cjs/shared/index.js +0 -70
- package/dist/cjs/utils/index.js +0 -26
- package/dist/esm/crypto/index.js +0 -13
- package/dist/esm/shared/index.js +0 -31
- package/dist/esm/utils/index.js +0 -7
- package/dist/types/crypto/index.d.ts +0 -11
- package/dist/types/shared/index.d.ts +0 -28
- package/dist/types/utils/index.d.ts +0 -6
- package/src/crypto/index.ts +0 -30
- package/src/shared/index.ts +0 -82
- package/src/utils/index.ts +0 -21
|
@@ -114,6 +114,89 @@
|
|
|
114
114
|
"email": "Email",
|
|
115
115
|
"password": "Palavra-passe",
|
|
116
116
|
"confirmPassword": "Confirmar palavra-passe"
|
|
117
|
+
},
|
|
118
|
+
"revoke": "Revoke"
|
|
119
|
+
},
|
|
120
|
+
"notifications": {
|
|
121
|
+
"title": "Notifications",
|
|
122
|
+
"subtitle": "Manage push, email, and security alerts",
|
|
123
|
+
"updateError": "Failed to update notification preferences",
|
|
124
|
+
"sections": {
|
|
125
|
+
"channels": "Channels",
|
|
126
|
+
"alerts": "Alerts",
|
|
127
|
+
"marketing": "Marketing"
|
|
128
|
+
},
|
|
129
|
+
"items": {
|
|
130
|
+
"push": {
|
|
131
|
+
"title": "Push notifications",
|
|
132
|
+
"subtitle": "Real-time alerts on your devices"
|
|
133
|
+
},
|
|
134
|
+
"emailDigest": {
|
|
135
|
+
"title": "Email digest",
|
|
136
|
+
"subtitle": "Periodic summary of your account activity"
|
|
137
|
+
},
|
|
138
|
+
"securityAlerts": {
|
|
139
|
+
"title": "Security alerts",
|
|
140
|
+
"subtitle": "Sign-ins, recovery codes, and key changes"
|
|
141
|
+
},
|
|
142
|
+
"marketingEmails": {
|
|
143
|
+
"title": "Marketing emails",
|
|
144
|
+
"subtitle": "Product news and occasional offers"
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
"preferences": {
|
|
149
|
+
"title": "Preferences",
|
|
150
|
+
"subtitle": "Theme, motion, and regional settings",
|
|
151
|
+
"sections": {
|
|
152
|
+
"appearance": "Appearance",
|
|
153
|
+
"language": "Language",
|
|
154
|
+
"region": "Region"
|
|
155
|
+
},
|
|
156
|
+
"theme": {
|
|
157
|
+
"light": "Light",
|
|
158
|
+
"dark": "Dark",
|
|
159
|
+
"system": "System default"
|
|
160
|
+
},
|
|
161
|
+
"items": {
|
|
162
|
+
"theme": {
|
|
163
|
+
"title": "Theme"
|
|
164
|
+
},
|
|
165
|
+
"reduceMotion": {
|
|
166
|
+
"title": "Reduce motion",
|
|
167
|
+
"subtitle": "Minimise animations across Oxy apps",
|
|
168
|
+
"systemOn": "Following system: reduce motion is on"
|
|
169
|
+
},
|
|
170
|
+
"language": {
|
|
171
|
+
"title": "Language"
|
|
172
|
+
},
|
|
173
|
+
"timezone": {
|
|
174
|
+
"title": "Timezone",
|
|
175
|
+
"unknown": "Unable to detect timezone"
|
|
176
|
+
},
|
|
177
|
+
"about": {
|
|
178
|
+
"title": "About preferences",
|
|
179
|
+
"subtitle": "Preferences sync across every Oxy app you sign into"
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
"connectedApps": {
|
|
184
|
+
"title": "Connected apps",
|
|
185
|
+
"subtitle": "Manage third-party app access",
|
|
186
|
+
"empty": {
|
|
187
|
+
"title": "No connected apps",
|
|
188
|
+
"subtitle": "Apps you authorize to sign in with your Oxy account will appear here"
|
|
189
|
+
},
|
|
190
|
+
"item": {
|
|
191
|
+
"lastUsed": "Last used {{relative}}"
|
|
192
|
+
},
|
|
193
|
+
"confirm": {
|
|
194
|
+
"title": "Revoke access",
|
|
195
|
+
"message": "Revoke {{name}}'s access to your Oxy account?"
|
|
196
|
+
},
|
|
197
|
+
"toasts": {
|
|
198
|
+
"revoked": "Revoked access for {{name}}",
|
|
199
|
+
"revokeFailed": "Failed to revoke access"
|
|
117
200
|
}
|
|
118
201
|
}
|
|
119
202
|
}
|
|
@@ -114,6 +114,89 @@
|
|
|
114
114
|
"email": "电子邮件",
|
|
115
115
|
"password": "密码",
|
|
116
116
|
"confirmPassword": "确认密码"
|
|
117
|
+
},
|
|
118
|
+
"revoke": "Revoke"
|
|
119
|
+
},
|
|
120
|
+
"notifications": {
|
|
121
|
+
"title": "Notifications",
|
|
122
|
+
"subtitle": "Manage push, email, and security alerts",
|
|
123
|
+
"updateError": "Failed to update notification preferences",
|
|
124
|
+
"sections": {
|
|
125
|
+
"channels": "Channels",
|
|
126
|
+
"alerts": "Alerts",
|
|
127
|
+
"marketing": "Marketing"
|
|
128
|
+
},
|
|
129
|
+
"items": {
|
|
130
|
+
"push": {
|
|
131
|
+
"title": "Push notifications",
|
|
132
|
+
"subtitle": "Real-time alerts on your devices"
|
|
133
|
+
},
|
|
134
|
+
"emailDigest": {
|
|
135
|
+
"title": "Email digest",
|
|
136
|
+
"subtitle": "Periodic summary of your account activity"
|
|
137
|
+
},
|
|
138
|
+
"securityAlerts": {
|
|
139
|
+
"title": "Security alerts",
|
|
140
|
+
"subtitle": "Sign-ins, recovery codes, and key changes"
|
|
141
|
+
},
|
|
142
|
+
"marketingEmails": {
|
|
143
|
+
"title": "Marketing emails",
|
|
144
|
+
"subtitle": "Product news and occasional offers"
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
"preferences": {
|
|
149
|
+
"title": "Preferences",
|
|
150
|
+
"subtitle": "Theme, motion, and regional settings",
|
|
151
|
+
"sections": {
|
|
152
|
+
"appearance": "Appearance",
|
|
153
|
+
"language": "Language",
|
|
154
|
+
"region": "Region"
|
|
155
|
+
},
|
|
156
|
+
"theme": {
|
|
157
|
+
"light": "Light",
|
|
158
|
+
"dark": "Dark",
|
|
159
|
+
"system": "System default"
|
|
160
|
+
},
|
|
161
|
+
"items": {
|
|
162
|
+
"theme": {
|
|
163
|
+
"title": "Theme"
|
|
164
|
+
},
|
|
165
|
+
"reduceMotion": {
|
|
166
|
+
"title": "Reduce motion",
|
|
167
|
+
"subtitle": "Minimise animations across Oxy apps",
|
|
168
|
+
"systemOn": "Following system: reduce motion is on"
|
|
169
|
+
},
|
|
170
|
+
"language": {
|
|
171
|
+
"title": "Language"
|
|
172
|
+
},
|
|
173
|
+
"timezone": {
|
|
174
|
+
"title": "Timezone",
|
|
175
|
+
"unknown": "Unable to detect timezone"
|
|
176
|
+
},
|
|
177
|
+
"about": {
|
|
178
|
+
"title": "About preferences",
|
|
179
|
+
"subtitle": "Preferences sync across every Oxy app you sign into"
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
"connectedApps": {
|
|
184
|
+
"title": "Connected apps",
|
|
185
|
+
"subtitle": "Manage third-party app access",
|
|
186
|
+
"empty": {
|
|
187
|
+
"title": "No connected apps",
|
|
188
|
+
"subtitle": "Apps you authorize to sign in with your Oxy account will appear here"
|
|
189
|
+
},
|
|
190
|
+
"item": {
|
|
191
|
+
"lastUsed": "Last used {{relative}}"
|
|
192
|
+
},
|
|
193
|
+
"confirm": {
|
|
194
|
+
"title": "Revoke access",
|
|
195
|
+
"message": "Revoke {{name}}'s access to your Oxy account?"
|
|
196
|
+
},
|
|
197
|
+
"toasts": {
|
|
198
|
+
"revoked": "Revoked access for {{name}}",
|
|
199
|
+
"revokeFailed": "Failed to revoke access"
|
|
117
200
|
}
|
|
118
201
|
}
|
|
119
202
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -12,53 +12,101 @@
|
|
|
12
12
|
*
|
|
13
13
|
* const user = await oxyClient.signIn(publicKey);
|
|
14
14
|
* ```
|
|
15
|
+
*
|
|
16
|
+
* Every export below is NOMINAL — no `export *`, no barrels, no compat shims.
|
|
17
|
+
* If a symbol does not appear here, it is NOT part of the public API.
|
|
15
18
|
*/
|
|
16
19
|
// Ensure crypto polyfills are loaded before anything else
|
|
17
20
|
import './crypto/polyfill.js';
|
|
18
|
-
//
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
// API client
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
19
24
|
export { OxyServices, OxyAuthenticationError, OxyAuthenticationTimeoutError } from './OxyServices.js';
|
|
20
25
|
export { OXY_CLOUD_URL, oxyClient } from './OxyServices.js';
|
|
21
|
-
//
|
|
26
|
+
// ---------------------------------------------------------------------------
|
|
27
|
+
// Authentication
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
22
29
|
export { AuthManager, createAuthManager } from './AuthManager.js';
|
|
23
30
|
export { CrossDomainAuth, createCrossDomainAuth } from './CrossDomainAuth.js';
|
|
24
31
|
export { ServiceCredentialMismatchError } from './mixins/OxyServices.auth.js';
|
|
25
32
|
export { OxyAppDataIdentifierError } from './mixins/OxyServices.appData.js';
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
//
|
|
29
|
-
export
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
//
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
// Auth helpers (token refresh, error normalisation, retry policies)
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
export { SessionSyncRequiredError, AuthenticationFailedError, ensureValidToken, isAuthenticationError, withAuthErrorHandling, authenticatedApiCall, } from './utils/authHelpers.js';
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
// Sessions
|
|
39
|
+
// ---------------------------------------------------------------------------
|
|
40
|
+
export { mergeSessions, normalizeAndSortSessions, sessionsArraysEqual, } from './utils/sessionUtils.js';
|
|
41
|
+
// ---------------------------------------------------------------------------
|
|
42
|
+
// Crypto / identity
|
|
43
|
+
// ---------------------------------------------------------------------------
|
|
44
|
+
export { KeyManager, IdentityAlreadyExistsError, IdentityPersistError, } from './crypto/keyManager.js';
|
|
45
|
+
export { SignatureService } from './crypto/signatureService.js';
|
|
46
|
+
export { RecoveryPhraseService } from './crypto/recoveryPhrase.js';
|
|
47
|
+
// ---------------------------------------------------------------------------
|
|
48
|
+
// Devices
|
|
49
|
+
// ---------------------------------------------------------------------------
|
|
33
50
|
export { DeviceManager } from './utils/deviceManager.js';
|
|
34
|
-
|
|
51
|
+
export { SECURITY_EVENT_SEVERITY_MAP } from './models/interfaces.js';
|
|
52
|
+
// Topic enums + type
|
|
53
|
+
export { TopicType, TopicSource } from './models/Topic.js';
|
|
54
|
+
// ---------------------------------------------------------------------------
|
|
55
|
+
// Languages
|
|
56
|
+
// ---------------------------------------------------------------------------
|
|
35
57
|
export { SUPPORTED_LANGUAGES, getLanguageMetadata, getLanguageName, getNativeLanguageName, normalizeLanguageCode, isRTLLocale, } from './utils/languageUtils.js';
|
|
36
|
-
//
|
|
58
|
+
// ---------------------------------------------------------------------------
|
|
59
|
+
// Platform detection
|
|
60
|
+
// ---------------------------------------------------------------------------
|
|
37
61
|
export { getPlatformOS, setPlatformOS, isWeb, isNative, isIOS, isAndroid, } from './utils/platform.js';
|
|
38
|
-
//
|
|
62
|
+
// ---------------------------------------------------------------------------
|
|
63
|
+
// Colour / theme utilities
|
|
64
|
+
// ---------------------------------------------------------------------------
|
|
39
65
|
export { darkenColor, lightenColor, hexToRgb, rgbToHex, withOpacity, isLightColor, getContrastTextColor, } from './shared/utils/colorUtils.js';
|
|
40
66
|
export { normalizeTheme, normalizeColorScheme, getOppositeTheme, systemPrefersDarkMode, getSystemColorScheme, } from './shared/utils/themeUtils.js';
|
|
67
|
+
// ---------------------------------------------------------------------------
|
|
68
|
+
// HTTP / error / network helpers
|
|
69
|
+
// ---------------------------------------------------------------------------
|
|
41
70
|
export { HttpStatus, getErrorStatus, getErrorMessage, isAlreadyRegisteredError, isUnauthorizedError, isForbiddenError, isNotFoundError, isRateLimitError, isServerError, isNetworkError, isRetryableError, } from './shared/utils/errorUtils.js';
|
|
42
71
|
export { DEFAULT_CIRCUIT_BREAKER_CONFIG, createCircuitBreakerState, calculateBackoffInterval, recordFailure, recordSuccess, shouldAllowRequest, delay, withRetry, } from './shared/utils/networkUtils.js';
|
|
43
72
|
export { isDev, debugLog, debugWarn, debugError, createDebugLogger, } from './shared/utils/debugUtils.js';
|
|
44
|
-
//
|
|
73
|
+
// ---------------------------------------------------------------------------
|
|
74
|
+
// i18n
|
|
75
|
+
// ---------------------------------------------------------------------------
|
|
45
76
|
export { translate } from './i18n/index.js';
|
|
46
|
-
//
|
|
47
|
-
|
|
48
|
-
//
|
|
49
|
-
export {
|
|
50
|
-
// --- Constants ---
|
|
51
|
-
export { packageInfo } from './constants/version.js';
|
|
52
|
-
// --- API & Error Utilities ---
|
|
53
|
-
export * from './utils/apiUtils.js';
|
|
77
|
+
// ---------------------------------------------------------------------------
|
|
78
|
+
// API request / URL helpers
|
|
79
|
+
// ---------------------------------------------------------------------------
|
|
80
|
+
export { buildSearchParams, buildUrl, buildPaginationParams, safeJsonParse, } from './utils/apiUtils.js';
|
|
54
81
|
export { ErrorCodes, createApiError, handleHttpError, validateRequiredFields, } from './utils/errorUtils.js';
|
|
55
82
|
export { retryAsync } from './utils/asyncUtils.js';
|
|
56
|
-
|
|
83
|
+
// ---------------------------------------------------------------------------
|
|
84
|
+
// Validation
|
|
85
|
+
// ---------------------------------------------------------------------------
|
|
86
|
+
export { EMAIL_REGEX, USERNAME_REGEX, PASSWORD_REGEX, isValidEmail, isValidUsername, isValidPassword, isRequiredString, isRequiredNumber, isRequiredBoolean, isValidArray, isValidObject, isValidUUID, isValidURL, isValidDate, isValidFileSize, isValidFileType, sanitizeString, sanitizeHTML, isValidObjectId, validateAndSanitizeUserInput, } from './utils/validationUtils.js';
|
|
87
|
+
// ---------------------------------------------------------------------------
|
|
88
|
+
// Logging
|
|
89
|
+
// ---------------------------------------------------------------------------
|
|
57
90
|
export { logger, LogLevel, logAuth, logApi, logSession, logUser, logDevice, logPayment, logPerformance, } from './utils/loggerUtils.js';
|
|
58
|
-
//
|
|
91
|
+
// ---------------------------------------------------------------------------
|
|
92
|
+
// Avatars
|
|
93
|
+
// ---------------------------------------------------------------------------
|
|
59
94
|
export { updateAvatarVisibility } from './utils/avatarUtils.js';
|
|
60
|
-
//
|
|
61
|
-
|
|
62
|
-
//
|
|
95
|
+
// ---------------------------------------------------------------------------
|
|
96
|
+
// Accounts
|
|
97
|
+
// ---------------------------------------------------------------------------
|
|
98
|
+
export { buildAccountsArray, createQuickAccount, getAccountDisplayName, getAccountFallbackHandle, formatPublicKeyHandle, mergeAccountsFromRefreshAll, getAccountColor, } from './utils/accountUtils.js';
|
|
99
|
+
// ---------------------------------------------------------------------------
|
|
100
|
+
// Cross-domain SSO infrastructure
|
|
101
|
+
// ---------------------------------------------------------------------------
|
|
102
|
+
export { autoDetectAuthWebUrl } from './utils/fapiAutoDetect.js';
|
|
103
|
+
export { runColdBoot } from './utils/coldBoot.js';
|
|
104
|
+
// ---------------------------------------------------------------------------
|
|
105
|
+
// Constants
|
|
106
|
+
// ---------------------------------------------------------------------------
|
|
107
|
+
export { packageInfo } from './constants/version.js';
|
|
108
|
+
// ---------------------------------------------------------------------------
|
|
109
|
+
// Default export (back-compat — OxyServices is the most common consumer entry)
|
|
110
|
+
// ---------------------------------------------------------------------------
|
|
63
111
|
import { OxyServices } from './OxyServices.js';
|
|
64
112
|
export default OxyServices;
|
|
@@ -380,6 +380,241 @@ export function OxyServicesAuthMixin(Base) {
|
|
|
380
380
|
throw this.handleError(error);
|
|
381
381
|
}
|
|
382
382
|
}
|
|
383
|
+
/**
|
|
384
|
+
* Refresh every device-local refresh-cookie slot in a single round trip
|
|
385
|
+
* (Google-style multi-account rebuild).
|
|
386
|
+
*
|
|
387
|
+
* Calls `POST {sessionBaseUrl}/auth/refresh-all` with `credentials: 'include'`
|
|
388
|
+
* and NO bearer. The browser attaches every `oxy_rt*` cookie it has; the
|
|
389
|
+
* server rotates each in parallel and returns one entry per VALID account.
|
|
390
|
+
*
|
|
391
|
+
* Failure handling:
|
|
392
|
+
* - 401 → no signed-in accounts on this device → returns `{ accounts: [] }`
|
|
393
|
+
* (NOT an error; this is the cold-boot "not signed in" path).
|
|
394
|
+
* - 404 → server is older than the multi-account endpoint. We fall back to
|
|
395
|
+
* `POST /auth/refresh` (single-slot) and wrap its response in the
|
|
396
|
+
* refresh-all shape so callers can treat the two paths uniformly. The
|
|
397
|
+
* fallback entry has `authuser: 0` (the legacy slot maps to slot 0 by
|
|
398
|
+
* convention) and a minimal `user` shape — consumers needing the full
|
|
399
|
+
* user must fetch it separately. Always exactly one account in this
|
|
400
|
+
* shape.
|
|
401
|
+
* - Any other non-2xx → throws via `handleError`.
|
|
402
|
+
*
|
|
403
|
+
* The refresh cookie itself never enters JS — only the rotated access
|
|
404
|
+
* tokens do. Each access token still needs to be planted via
|
|
405
|
+
* `setTokens(...)` (or per-account in-memory storage) at the consumer.
|
|
406
|
+
*/
|
|
407
|
+
async refreshAllSessions() {
|
|
408
|
+
const url = `${this.getSessionBaseUrl().replace(/\/$/, '')}/auth/refresh-all`;
|
|
409
|
+
let response;
|
|
410
|
+
try {
|
|
411
|
+
response = await fetch(url, {
|
|
412
|
+
method: 'POST',
|
|
413
|
+
credentials: 'include',
|
|
414
|
+
headers: { Accept: 'application/json' },
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
catch (error) {
|
|
418
|
+
throw this.handleError(error);
|
|
419
|
+
}
|
|
420
|
+
if (response.status === 401) {
|
|
421
|
+
return { accounts: [] };
|
|
422
|
+
}
|
|
423
|
+
if (response.status === 404) {
|
|
424
|
+
// Legacy single-account refresh fallback. Wrap the response so the
|
|
425
|
+
// caller can treat both paths identically.
|
|
426
|
+
const legacy = await this._refreshCookieRaw();
|
|
427
|
+
if (!legacy) {
|
|
428
|
+
return { accounts: [] };
|
|
429
|
+
}
|
|
430
|
+
const fallbackAccount = {
|
|
431
|
+
authuser: 0,
|
|
432
|
+
accessToken: legacy.accessToken,
|
|
433
|
+
expiresAt: legacy.expiresAt,
|
|
434
|
+
sessionId: this._decodeSessionIdFromAccessToken(legacy.accessToken) ?? '',
|
|
435
|
+
// Legacy /auth/refresh does NOT project the user shape; the caller
|
|
436
|
+
// (AuthManager) is expected to hydrate via /users/me after planting.
|
|
437
|
+
user: null,
|
|
438
|
+
};
|
|
439
|
+
return { accounts: [fallbackAccount] };
|
|
440
|
+
}
|
|
441
|
+
if (!response.ok) {
|
|
442
|
+
throw this.handleError(new Error(`Refresh-all failed with HTTP ${response.status}`));
|
|
443
|
+
}
|
|
444
|
+
const payload = (await response.json());
|
|
445
|
+
const raw = Array.isArray(payload.accounts) ? payload.accounts : [];
|
|
446
|
+
const accounts = [];
|
|
447
|
+
for (const entry of raw) {
|
|
448
|
+
if (entry === null || typeof entry !== 'object') {
|
|
449
|
+
continue;
|
|
450
|
+
}
|
|
451
|
+
const e = entry;
|
|
452
|
+
if (!e.accessToken || !e.expiresAt || !e.sessionId || !e.user) {
|
|
453
|
+
continue;
|
|
454
|
+
}
|
|
455
|
+
const userId = e.user.id ?? e.user._id;
|
|
456
|
+
if (!userId || !e.user.username) {
|
|
457
|
+
continue;
|
|
458
|
+
}
|
|
459
|
+
// Normalise the legacy un-suffixed cookie (`authuser: null` on the
|
|
460
|
+
// wire) to slot 0. The SDK surface always operates on numeric indices.
|
|
461
|
+
const authuser = typeof e.authuser === 'number' ? e.authuser : 0;
|
|
462
|
+
accounts.push({
|
|
463
|
+
authuser,
|
|
464
|
+
accessToken: e.accessToken,
|
|
465
|
+
expiresAt: e.expiresAt,
|
|
466
|
+
sessionId: e.sessionId,
|
|
467
|
+
user: {
|
|
468
|
+
id: userId,
|
|
469
|
+
username: e.user.username,
|
|
470
|
+
name: e.user.name,
|
|
471
|
+
avatar: e.user.avatar ?? null,
|
|
472
|
+
email: e.user.email,
|
|
473
|
+
color: e.user.color ?? null,
|
|
474
|
+
},
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
return { accounts };
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Rotate a single refresh-cookie slot and return the fresh access token.
|
|
481
|
+
*
|
|
482
|
+
* When `authuser` is provided, the server rotates ONLY that slot
|
|
483
|
+
* (`oxy_rt_${authuser}`) — sibling accounts on the same device stay
|
|
484
|
+
* untouched. When omitted, the server picks the lowest indexed slot
|
|
485
|
+
* present (legacy fallback applies). The refresh cookie itself never
|
|
486
|
+
* enters JS.
|
|
487
|
+
*
|
|
488
|
+
* Returns `null` on 401 (no cookie / expired / reused) so the caller can
|
|
489
|
+
* fall through cleanly to the unauthenticated path.
|
|
490
|
+
*/
|
|
491
|
+
async refreshTokenViaCookie(opts = {}) {
|
|
492
|
+
const result = await this._refreshCookieRaw(opts.authuser);
|
|
493
|
+
return result;
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Sign out a single device-local account by its authuser slot index.
|
|
497
|
+
*
|
|
498
|
+
* Revokes that slot's refresh-token family and deactivates its session;
|
|
499
|
+
* sibling indexed slots stay signed in. The browser-side `oxy_rt_${n}`
|
|
500
|
+
* cookie is cleared by the server's `Set-Cookie` response header.
|
|
501
|
+
*/
|
|
502
|
+
async logoutSessionByAuthuser(authuser) {
|
|
503
|
+
const url = `${this.getSessionBaseUrl().replace(/\/$/, '')}/auth/logout?authuser=${encodeURIComponent(String(authuser))}`;
|
|
504
|
+
try {
|
|
505
|
+
const response = await fetch(url, {
|
|
506
|
+
method: 'POST',
|
|
507
|
+
credentials: 'include',
|
|
508
|
+
headers: { Accept: 'application/json' },
|
|
509
|
+
});
|
|
510
|
+
if (!response.ok && response.status !== 401) {
|
|
511
|
+
throw new Error(`Logout (authuser=${authuser}) failed with HTTP ${response.status}`);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
catch (error) {
|
|
515
|
+
throw this.handleError(error);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* Sign out EVERY device-local account on this device by clearing every
|
|
520
|
+
* presented refresh-cookie slot at once. Revokes every family + clears
|
|
521
|
+
* every slot. Always succeeds (idempotent on unknown/garbage tokens).
|
|
522
|
+
*/
|
|
523
|
+
async logoutAllSessionsViaCookie() {
|
|
524
|
+
const url = `${this.getSessionBaseUrl().replace(/\/$/, '')}/auth/logout`;
|
|
525
|
+
try {
|
|
526
|
+
const response = await fetch(url, {
|
|
527
|
+
method: 'POST',
|
|
528
|
+
credentials: 'include',
|
|
529
|
+
headers: { Accept: 'application/json' },
|
|
530
|
+
});
|
|
531
|
+
if (!response.ok && response.status !== 401) {
|
|
532
|
+
throw new Error(`Logout-all failed with HTTP ${response.status}`);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
catch (error) {
|
|
536
|
+
throw this.handleError(error);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Internal: raw `POST /auth/refresh[?authuser=N]` call returning the
|
|
541
|
+
* minted access token. Returns `null` on 401 / non-2xx. Used as both the
|
|
542
|
+
* implementation of `refreshTokenViaCookie` and the legacy fallback for
|
|
543
|
+
* `refreshAllSessions` against older servers.
|
|
544
|
+
*
|
|
545
|
+
* @internal
|
|
546
|
+
*/
|
|
547
|
+
async _refreshCookieRaw(authuser) {
|
|
548
|
+
const base = this.getSessionBaseUrl().replace(/\/$/, '');
|
|
549
|
+
const url = typeof authuser === 'number'
|
|
550
|
+
? `${base}/auth/refresh?authuser=${encodeURIComponent(String(authuser))}`
|
|
551
|
+
: `${base}/auth/refresh`;
|
|
552
|
+
let response;
|
|
553
|
+
try {
|
|
554
|
+
response = await fetch(url, {
|
|
555
|
+
method: 'POST',
|
|
556
|
+
credentials: 'include',
|
|
557
|
+
headers: { Accept: 'application/json' },
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
catch (error) {
|
|
561
|
+
throw this.handleError(error);
|
|
562
|
+
}
|
|
563
|
+
if (!response.ok) {
|
|
564
|
+
return null;
|
|
565
|
+
}
|
|
566
|
+
const payload = (await response.json());
|
|
567
|
+
if (typeof payload.accessToken !== 'string' || !payload.accessToken) {
|
|
568
|
+
return null;
|
|
569
|
+
}
|
|
570
|
+
const expiresAt = typeof payload.expiresAt === 'string' ? payload.expiresAt : '';
|
|
571
|
+
const respAuthuser = typeof payload.authuser === 'number' ? payload.authuser : null;
|
|
572
|
+
return {
|
|
573
|
+
accessToken: payload.accessToken,
|
|
574
|
+
expiresAt,
|
|
575
|
+
authuser: respAuthuser,
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* Internal: decode (without verifying) the `sessionId` claim from a
|
|
580
|
+
* server-signed access token. The server already verified the signature;
|
|
581
|
+
* the client only reads the claim to drive multi-session state.
|
|
582
|
+
*
|
|
583
|
+
* @internal
|
|
584
|
+
*/
|
|
585
|
+
_decodeSessionIdFromAccessToken(token) {
|
|
586
|
+
if (!token || typeof token !== 'string') {
|
|
587
|
+
return null;
|
|
588
|
+
}
|
|
589
|
+
const segments = token.split('.');
|
|
590
|
+
if (segments.length !== 3) {
|
|
591
|
+
return null;
|
|
592
|
+
}
|
|
593
|
+
const payloadSegment = segments[1];
|
|
594
|
+
if (!payloadSegment) {
|
|
595
|
+
return null;
|
|
596
|
+
}
|
|
597
|
+
try {
|
|
598
|
+
const base64 = payloadSegment.replace(/-/g, '+').replace(/_/g, '/');
|
|
599
|
+
const padded = base64.padEnd(base64.length + ((4 - (base64.length % 4)) % 4), '=');
|
|
600
|
+
if (typeof atob !== 'function') {
|
|
601
|
+
return null;
|
|
602
|
+
}
|
|
603
|
+
const json = decodeURIComponent(atob(padded)
|
|
604
|
+
.split('')
|
|
605
|
+
.map((char) => `%${`00${char.charCodeAt(0).toString(16)}`.slice(-2)}`)
|
|
606
|
+
.join(''));
|
|
607
|
+
const parsed = JSON.parse(json);
|
|
608
|
+
if (parsed === null || typeof parsed !== 'object') {
|
|
609
|
+
return null;
|
|
610
|
+
}
|
|
611
|
+
const claims = parsed;
|
|
612
|
+
return typeof claims.sessionId === 'string' ? claims.sessionId : null;
|
|
613
|
+
}
|
|
614
|
+
catch {
|
|
615
|
+
return null;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
383
618
|
/**
|
|
384
619
|
* Get sessions by session ID
|
|
385
620
|
*/
|
|
@@ -697,6 +697,42 @@ export function OxyServicesFedCMMixin(Base) {
|
|
|
697
697
|
// Storage blocked
|
|
698
698
|
}
|
|
699
699
|
}
|
|
700
|
+
/**
|
|
701
|
+
* List the authenticated user's authorized RP apps.
|
|
702
|
+
*
|
|
703
|
+
* Returns the intersection of the user's FedCM grants and the currently-
|
|
704
|
+
* approved RP catalog — what powers the "Connected apps" management UI in
|
|
705
|
+
* @oxyhq/services. Requires a real user session; service tokens are
|
|
706
|
+
* rejected by the underlying endpoint.
|
|
707
|
+
*/
|
|
708
|
+
async listAuthorizedApps() {
|
|
709
|
+
try {
|
|
710
|
+
const response = await this.makeRequest('GET', '/fedcm/me/authorized-apps', undefined, {
|
|
711
|
+
cache: true,
|
|
712
|
+
cacheTTL: 30 * 1000, // 30 second cache — short, this drives a manageable UI
|
|
713
|
+
});
|
|
714
|
+
return response.apps ?? [];
|
|
715
|
+
}
|
|
716
|
+
catch (error) {
|
|
717
|
+
throw this.handleError(error);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
/**
|
|
721
|
+
* Revoke the authenticated user's authorization for a specific RP origin.
|
|
722
|
+
*
|
|
723
|
+
* The next FedCM sign-in from that origin will require explicit re-consent.
|
|
724
|
+
* The corresponding cache entry is invalidated so a subsequent
|
|
725
|
+
* `listAuthorizedApps()` call sees fresh data.
|
|
726
|
+
*/
|
|
727
|
+
async revokeAuthorizedApp(origin) {
|
|
728
|
+
try {
|
|
729
|
+
await this.makeRequest('DELETE', `/fedcm/me/authorized-apps/${encodeURIComponent(origin)}`, undefined, { cache: false });
|
|
730
|
+
this.clearCacheEntry('GET:/fedcm/me/authorized-apps');
|
|
731
|
+
}
|
|
732
|
+
catch (error) {
|
|
733
|
+
throw this.handleError(error);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
700
736
|
},
|
|
701
737
|
_a.DEFAULT_CONFIG_URL = 'https://auth.oxy.so/fedcm.json',
|
|
702
738
|
_a.FEDCM_TIMEOUT = 15000 // 15 seconds for interactive
|