@oxyhq/core 3.4.1 → 3.4.3
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/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/AuthManager.js +91 -319
- package/dist/cjs/CrossDomainAuth.js +19 -106
- package/dist/cjs/HttpService.js +49 -73
- package/dist/cjs/OxyServices.base.js +2 -2
- package/dist/cjs/i18n/index.js +7 -1
- package/dist/cjs/i18n/locales/ar-SA.json +18 -2
- package/dist/cjs/i18n/locales/ca-ES.json +18 -2
- package/dist/cjs/i18n/locales/de-DE.json +18 -2
- package/dist/cjs/i18n/locales/en-US.json +16 -2
- package/dist/cjs/i18n/locales/es-ES.json +16 -2
- package/dist/cjs/i18n/locales/fr-FR.json +18 -2
- package/dist/cjs/i18n/locales/it-IT.json +18 -2
- package/dist/cjs/i18n/locales/ja-JP.json +18 -2
- package/dist/cjs/i18n/locales/ko-KR.json +18 -2
- package/dist/cjs/i18n/locales/locales/ar-SA.json +18 -2
- package/dist/cjs/i18n/locales/locales/ca-ES.json +18 -2
- package/dist/cjs/i18n/locales/locales/de-DE.json +18 -2
- package/dist/cjs/i18n/locales/locales/en-US.json +17 -3
- package/dist/cjs/i18n/locales/locales/es-ES.json +16 -2
- package/dist/cjs/i18n/locales/locales/fr-FR.json +18 -2
- package/dist/cjs/i18n/locales/locales/it-IT.json +18 -2
- package/dist/cjs/i18n/locales/locales/ja-JP.json +18 -2
- package/dist/cjs/i18n/locales/locales/ko-KR.json +18 -2
- package/dist/cjs/i18n/locales/locales/pt-PT.json +18 -2
- package/dist/cjs/i18n/locales/locales/zh-CN.json +18 -2
- package/dist/cjs/i18n/locales/pt-PT.json +18 -2
- package/dist/cjs/i18n/locales/zh-CN.json +18 -2
- package/dist/cjs/mixins/OxyServices.auth.js +20 -63
- package/dist/cjs/mixins/OxyServices.fedcm.js +10 -12
- package/dist/cjs/mixins/OxyServices.popup.js +50 -299
- package/dist/cjs/mixins/OxyServices.redirect.js +84 -348
- package/dist/cjs/mixins/OxyServices.silent.js +204 -0
- package/dist/cjs/mixins/OxyServices.sso.js +4 -5
- package/dist/cjs/mixins/OxyServices.utility.js +6 -15
- package/dist/cjs/mixins/index.js +5 -6
- package/dist/cjs/server/index.js +21 -0
- package/dist/cjs/server/rateLimit.js +77 -0
- package/dist/cjs/shared/utils/debugUtils.js +1 -1
- package/dist/cjs/utils/accountUtils.js +4 -4
- package/dist/cjs/utils/authHelpers.js +21 -15
- package/dist/cjs/utils/coldBoot.js +3 -3
- package/dist/cjs/utils/fapiAutoDetect.js +1 -1
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/AuthManager.js +91 -319
- package/dist/esm/CrossDomainAuth.js +19 -106
- package/dist/esm/HttpService.js +49 -73
- package/dist/esm/OxyServices.base.js +2 -2
- package/dist/esm/i18n/index.js +7 -1
- package/dist/esm/i18n/locales/ar-SA.json +18 -2
- package/dist/esm/i18n/locales/ca-ES.json +18 -2
- package/dist/esm/i18n/locales/de-DE.json +18 -2
- package/dist/esm/i18n/locales/en-US.json +16 -2
- package/dist/esm/i18n/locales/es-ES.json +16 -2
- package/dist/esm/i18n/locales/fr-FR.json +18 -2
- package/dist/esm/i18n/locales/it-IT.json +18 -2
- package/dist/esm/i18n/locales/ja-JP.json +18 -2
- package/dist/esm/i18n/locales/ko-KR.json +18 -2
- package/dist/esm/i18n/locales/locales/ar-SA.json +18 -2
- package/dist/esm/i18n/locales/locales/ca-ES.json +18 -2
- package/dist/esm/i18n/locales/locales/de-DE.json +18 -2
- package/dist/esm/i18n/locales/locales/en-US.json +17 -3
- package/dist/esm/i18n/locales/locales/es-ES.json +16 -2
- package/dist/esm/i18n/locales/locales/fr-FR.json +18 -2
- package/dist/esm/i18n/locales/locales/it-IT.json +18 -2
- package/dist/esm/i18n/locales/locales/ja-JP.json +18 -2
- package/dist/esm/i18n/locales/locales/ko-KR.json +18 -2
- package/dist/esm/i18n/locales/locales/pt-PT.json +18 -2
- package/dist/esm/i18n/locales/locales/zh-CN.json +18 -2
- package/dist/esm/i18n/locales/pt-PT.json +18 -2
- package/dist/esm/i18n/locales/zh-CN.json +18 -2
- package/dist/esm/mixins/OxyServices.auth.js +20 -63
- package/dist/esm/mixins/OxyServices.fedcm.js +10 -12
- package/dist/esm/mixins/OxyServices.popup.js +52 -301
- package/dist/esm/mixins/OxyServices.redirect.js +84 -349
- package/dist/esm/mixins/OxyServices.silent.js +202 -0
- package/dist/esm/mixins/OxyServices.sso.js +4 -5
- package/dist/esm/mixins/OxyServices.utility.js +6 -15
- package/dist/esm/mixins/index.js +5 -6
- package/dist/esm/server/index.js +17 -0
- package/dist/esm/server/rateLimit.js +71 -0
- package/dist/esm/shared/utils/debugUtils.js +1 -1
- package/dist/esm/utils/accountUtils.js +4 -4
- package/dist/esm/utils/authHelpers.js +21 -15
- package/dist/esm/utils/coldBoot.js +3 -3
- package/dist/esm/utils/fapiAutoDetect.js +1 -1
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/AuthManager.d.ts +26 -53
- package/dist/types/AuthManagerTypes.d.ts +5 -9
- package/dist/types/CrossDomainAuth.d.ts +13 -52
- package/dist/types/HttpService.d.ts +9 -8
- package/dist/types/OxyServices.base.d.ts +1 -1
- package/dist/types/OxyServices.d.ts +4 -10
- package/dist/types/index.d.ts +1 -1
- package/dist/types/mixins/OxyServices.analytics.d.ts +1 -1
- package/dist/types/mixins/OxyServices.appData.d.ts +1 -1
- package/dist/types/mixins/OxyServices.applications.d.ts +1 -1
- package/dist/types/mixins/OxyServices.assets.d.ts +1 -1
- package/dist/types/mixins/OxyServices.auth.d.ts +10 -31
- package/dist/types/mixins/OxyServices.contacts.d.ts +1 -1
- package/dist/types/mixins/OxyServices.devices.d.ts +1 -1
- package/dist/types/mixins/OxyServices.features.d.ts +1 -1
- package/dist/types/mixins/OxyServices.fedcm.d.ts +5 -5
- package/dist/types/mixins/OxyServices.language.d.ts +1 -1
- package/dist/types/mixins/OxyServices.location.d.ts +1 -1
- package/dist/types/mixins/OxyServices.managedAccounts.d.ts +1 -1
- package/dist/types/mixins/OxyServices.payment.d.ts +1 -1
- package/dist/types/mixins/OxyServices.popup.d.ts +18 -120
- package/dist/types/mixins/OxyServices.privacy.d.ts +1 -1
- package/dist/types/mixins/OxyServices.redirect.d.ts +13 -174
- package/dist/types/mixins/OxyServices.reputation.d.ts +1 -1
- package/dist/types/mixins/OxyServices.security.d.ts +1 -1
- package/dist/types/mixins/OxyServices.silent.d.ts +131 -0
- package/dist/types/mixins/OxyServices.sso.d.ts +4 -5
- package/dist/types/mixins/OxyServices.topics.d.ts +1 -1
- package/dist/types/mixins/OxyServices.user.d.ts +1 -1
- package/dist/types/mixins/OxyServices.utility.d.ts +3 -8
- package/dist/types/mixins/OxyServices.workspaces.d.ts +1 -1
- package/dist/types/mixins/index.d.ts +3 -3
- package/dist/types/models/interfaces.d.ts +5 -16
- package/dist/types/models/session.d.ts +0 -2
- package/dist/types/server/index.d.ts +18 -0
- package/dist/types/server/rateLimit.d.ts +40 -0
- package/dist/types/shared/utils/debugUtils.d.ts +1 -1
- package/dist/types/utils/authHelpers.d.ts +4 -3
- package/dist/types/utils/coldBoot.d.ts +2 -2
- package/dist/types/utils/fapiAutoDetect.d.ts +1 -1
- package/package.json +24 -2
- package/src/AuthManager.ts +100 -370
- package/src/AuthManagerTypes.ts +5 -9
- package/src/CrossDomainAuth.ts +22 -129
- package/src/HttpService.ts +55 -73
- package/src/OxyServices.base.ts +2 -3
- package/src/OxyServices.ts +9 -11
- package/src/__tests__/authManager.cookiePath.test.ts +19 -17
- package/src/__tests__/authManager.security.test.ts +7 -3
- package/src/__tests__/crossDomainAuth.test.ts +26 -118
- package/src/i18n/index.ts +7 -1
- package/src/i18n/locales/ar-SA.json +18 -2
- package/src/i18n/locales/ca-ES.json +18 -2
- package/src/i18n/locales/de-DE.json +18 -2
- package/src/i18n/locales/en-US.json +17 -3
- package/src/i18n/locales/es-ES.json +16 -2
- package/src/i18n/locales/fr-FR.json +18 -2
- package/src/i18n/locales/it-IT.json +18 -2
- package/src/i18n/locales/ja-JP.json +18 -2
- package/src/i18n/locales/ko-KR.json +18 -2
- package/src/i18n/locales/pt-PT.json +18 -2
- package/src/i18n/locales/zh-CN.json +18 -2
- package/src/index.ts +1 -1
- package/src/mixins/OxyServices.auth.ts +23 -75
- package/src/mixins/OxyServices.fedcm.ts +10 -12
- package/src/mixins/OxyServices.redirect.ts +82 -371
- package/src/mixins/OxyServices.silent.ts +272 -0
- package/src/mixins/OxyServices.sso.ts +5 -6
- package/src/mixins/OxyServices.utility.ts +9 -22
- package/src/mixins/__tests__/appData.test.ts +1 -1
- package/src/mixins/__tests__/onTokensChanged.test.ts +1 -1
- package/src/mixins/__tests__/reputation.test.ts +1 -1
- package/src/mixins/__tests__/serviceAuth.test.ts +7 -5
- package/src/mixins/__tests__/silent.test.ts +102 -0
- package/src/mixins/__tests__/verifyChallenge.test.ts +9 -14
- package/src/mixins/index.ts +6 -8
- package/src/models/interfaces.ts +5 -16
- package/src/models/session.ts +1 -3
- package/src/server/index.ts +19 -0
- package/src/server/rateLimit.ts +170 -0
- package/src/shared/utils/debugUtils.ts +1 -1
- package/src/utils/accountUtils.ts +4 -4
- package/src/utils/authHelpers.ts +23 -15
- package/src/utils/coldBoot.ts +4 -4
- package/src/utils/fapiAutoDetect.ts +1 -1
- package/src/mixins/OxyServices.popup.ts +0 -631
- package/src/mixins/__tests__/popup.test.ts +0 -374
|
@@ -34,13 +34,8 @@ export interface ServiceApp {
|
|
|
34
34
|
appId: string;
|
|
35
35
|
appName: string;
|
|
36
36
|
scopes: string[];
|
|
37
|
-
/**
|
|
38
|
-
|
|
39
|
-
* Carried by newer service-token JWTs alongside `appId`; absent on tokens
|
|
40
|
-
* issued before credential-level audit linking. Use for per-credential audit
|
|
41
|
-
* trails and rotation alignment (GitHub #215).
|
|
42
|
-
*/
|
|
43
|
-
credentialId?: string;
|
|
37
|
+
/** The credentialId of the specific service credential that minted this token. */
|
|
38
|
+
credentialId: string;
|
|
44
39
|
}
|
|
45
40
|
/**
|
|
46
41
|
* Options for oxyClient.auth() middleware
|
|
@@ -273,7 +268,7 @@ export declare function OxyServicesUtilityMixin<T extends typeof OxyServicesBase
|
|
|
273
268
|
hitRate: number;
|
|
274
269
|
};
|
|
275
270
|
getCloudURL(): string;
|
|
276
|
-
setTokens(accessToken: string
|
|
271
|
+
setTokens(accessToken: string): void;
|
|
277
272
|
clearTokens(): void;
|
|
278
273
|
onTokensChanged(listener: (accessToken: string | null) => void): () => void;
|
|
279
274
|
_cachedUserId: string | null | undefined;
|
|
@@ -177,7 +177,7 @@ export declare function OxyServicesWorkspacesMixin<T extends typeof OxyServicesB
|
|
|
177
177
|
hitRate: number;
|
|
178
178
|
};
|
|
179
179
|
getCloudURL(): string;
|
|
180
|
-
setTokens(accessToken: string
|
|
180
|
+
setTokens(accessToken: string): void;
|
|
181
181
|
clearTokens(): void;
|
|
182
182
|
onTokensChanged(listener: (accessToken: string | null) => void): () => void;
|
|
183
183
|
_cachedUserId: string | null | undefined;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { OxyServicesBase } from '../OxyServices.base';
|
|
8
8
|
import { OxyServicesAuthMixin } from './OxyServices.auth';
|
|
9
9
|
import { OxyServicesFedCMMixin } from './OxyServices.fedcm';
|
|
10
|
-
import {
|
|
10
|
+
import { OxyServicesSilentAuthMixin } from './OxyServices.silent';
|
|
11
11
|
import { OxyServicesRedirectAuthMixin } from './OxyServices.redirect';
|
|
12
12
|
import { OxyServicesSsoMixin } from './OxyServices.sso';
|
|
13
13
|
import { OxyServicesUserMixin } from './OxyServices.user';
|
|
@@ -37,7 +37,7 @@ import { OxyServicesAppDataMixin } from './OxyServices.appData';
|
|
|
37
37
|
* If you add a new mixin to `MIXIN_PIPELINE`, add it here too so its methods
|
|
38
38
|
* are visible without a cast.
|
|
39
39
|
*/
|
|
40
|
-
type AllMixinInstances = InstanceType<ReturnType<typeof OxyServicesAuthMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesFedCMMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof
|
|
40
|
+
type AllMixinInstances = InstanceType<ReturnType<typeof OxyServicesAuthMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesFedCMMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesSilentAuthMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesRedirectAuthMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesSsoMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesUserMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesPrivacyMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesLanguageMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesPaymentMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesReputationMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesAssetsMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesApplicationsMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesWorkspacesMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesLocationMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesAnalyticsMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesDevicesMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesSecurityMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesFeaturesMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesTopicsMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesManagedAccountsMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesContactsMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesAppDataMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesUtilityMixin<typeof OxyServicesBase>>>;
|
|
41
41
|
/**
|
|
42
42
|
* Constructor type for the fully composed mixin pipeline. Each mixin returns
|
|
43
43
|
* a new constructor that augments its input; reducing across the pipeline
|
|
@@ -56,7 +56,7 @@ type MixinFunction = (Base: new (...args: unknown[]) => OxyServicesBase) => new
|
|
|
56
56
|
*
|
|
57
57
|
* Order matters for dependencies:
|
|
58
58
|
* 1. Base auth mixin first (required by all others)
|
|
59
|
-
* 2. Cross-domain auth mixins (FedCM,
|
|
59
|
+
* 2. Cross-domain auth mixins (FedCM, silent iframe, Redirect)
|
|
60
60
|
* 3. User mixin (requires auth)
|
|
61
61
|
* 4. Feature mixins (can depend on user)
|
|
62
62
|
* 5. Utility mixin last (augments all)
|
|
@@ -155,8 +155,6 @@ export interface UserPreferences {
|
|
|
155
155
|
}
|
|
156
156
|
export interface LoginResponse {
|
|
157
157
|
accessToken?: string;
|
|
158
|
-
refreshToken?: string;
|
|
159
|
-
token?: string;
|
|
160
158
|
user: User;
|
|
161
159
|
message?: string;
|
|
162
160
|
}
|
|
@@ -548,15 +546,7 @@ export interface RefreshAllAccountUser {
|
|
|
548
546
|
}
|
|
549
547
|
/**
|
|
550
548
|
* One rotated account entry returned by `POST /auth/refresh-all`. `authuser` is
|
|
551
|
-
* the device-local slot index (0..N-1) the cookie was bound to.
|
|
552
|
-
* un-suffixed `oxy_rt` cookie yields `authuser: null` server-side, but the SDK
|
|
553
|
-
* normalises that to `0` before exposing it (the chooser always operates on
|
|
554
|
-
* numeric indices).
|
|
555
|
-
*
|
|
556
|
-
* `user` is `null` only on the SDK-side synthesised legacy fallback (when the
|
|
557
|
-
* server is too old to support `/auth/refresh-all` and we wrap a
|
|
558
|
-
* `/auth/refresh` response — that endpoint does not project a user shape).
|
|
559
|
-
* On the modern path every accepted entry carries a non-null user.
|
|
549
|
+
* the device-local slot index (0..N-1) the cookie was bound to.
|
|
560
550
|
*/
|
|
561
551
|
export interface RefreshAllAccount {
|
|
562
552
|
authuser: number;
|
|
@@ -574,13 +564,12 @@ export interface RefreshAllResponse {
|
|
|
574
564
|
accounts: RefreshAllAccount[];
|
|
575
565
|
}
|
|
576
566
|
/**
|
|
577
|
-
* Wire shape of `POST /auth/refresh` (single-
|
|
578
|
-
*
|
|
579
|
-
* the response
|
|
580
|
-
* `authuser: null`.
|
|
567
|
+
* Wire shape of `POST /auth/refresh` (single-slot refresh, optionally targeting
|
|
568
|
+
* a specific `?authuser=N` slot). The server always includes the numeric slot in
|
|
569
|
+
* the response.
|
|
581
570
|
*/
|
|
582
571
|
export interface RefreshCookieResponse {
|
|
583
572
|
accessToken: string;
|
|
584
573
|
expiresAt: string;
|
|
585
|
-
authuser: number
|
|
574
|
+
authuser: number;
|
|
586
575
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @oxyhq/core/server — Server-only utilities for Oxy backends
|
|
3
|
+
*
|
|
4
|
+
* This subpath export provides Express middleware and Node.js-specific
|
|
5
|
+
* utilities that are not available in React Native or browser environments.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createOxyRateLimit } from '@oxyhq/core/server';
|
|
10
|
+
* import { oxyClient } from '@oxyhq/core';
|
|
11
|
+
*
|
|
12
|
+
* const oxy = oxyClient({ apiUrl: 'https://api.oxy.so' });
|
|
13
|
+
*
|
|
14
|
+
* app.use(createOxyRateLimit(oxy, { store: redisStore }));
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export { createOxyRateLimit } from './rateLimit';
|
|
18
|
+
export type { OxyRateLimitOptions } from './rateLimit';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Request, RequestHandler } from 'express';
|
|
2
|
+
import { type Store } from 'express-rate-limit';
|
|
3
|
+
import type { OxyServices } from '../OxyServices';
|
|
4
|
+
export interface OxyRateLimitOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Max requests per window for AUTHENTICATED users (keyed per user).
|
|
7
|
+
* Default 5000 — ~5.5 req/s sustained, comfortable for a media client that
|
|
8
|
+
* fans out into many small requests per screen.
|
|
9
|
+
*/
|
|
10
|
+
authenticatedMax?: number;
|
|
11
|
+
/**
|
|
12
|
+
* Max requests per window for ANONYMOUS callers (keyed per IP).
|
|
13
|
+
* Default 600 — enough to browse public pages while bounding abuse.
|
|
14
|
+
*/
|
|
15
|
+
anonymousMax?: number;
|
|
16
|
+
/** Rate-limit window in milliseconds. Default 15 minutes. */
|
|
17
|
+
windowMs?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Optional `express-rate-limit` store (e.g. a Redis store) for distributed
|
|
20
|
+
* limiting across instances. Defaults to the library's in-memory store.
|
|
21
|
+
*/
|
|
22
|
+
store?: Store;
|
|
23
|
+
/**
|
|
24
|
+
* Extra path predicates to exempt from limiting, in addition to the built-in
|
|
25
|
+
* exemptions (uploads, image proxy, streaming sub-requests, health probes,
|
|
26
|
+
* CORS preflight). Return `true` to skip limiting for the request.
|
|
27
|
+
*/
|
|
28
|
+
exempt?: (req: Request) => boolean;
|
|
29
|
+
/** Response message body sent with a 429. */
|
|
30
|
+
message?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Options forwarded to the internal `oxy.auth({ optional: true })` resolver
|
|
33
|
+
* (e.g. `{ jwtSecret }` to verify service tokens). `optional` is forced true.
|
|
34
|
+
*/
|
|
35
|
+
auth?: Parameters<OxyServices['auth']>[0];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Build the composed Oxy rate-limit middleware. See module docs for rationale.
|
|
39
|
+
*/
|
|
40
|
+
export declare function createOxyRateLimit(oxy: OxyServices, options?: OxyRateLimitOptions): RequestHandler;
|
|
@@ -30,7 +30,7 @@ export declare const debugWarn: (prefix: string, ...args: unknown[]) => void;
|
|
|
30
30
|
export declare const debugError: (prefix: string, ...args: unknown[]) => void;
|
|
31
31
|
/**
|
|
32
32
|
* Create a namespaced debug logger
|
|
33
|
-
* @param namespace - Logger namespace (e.g., 'FedCM', '
|
|
33
|
+
* @param namespace - Logger namespace (e.g., 'FedCM', 'SilentAuth')
|
|
34
34
|
* @returns Object with log, warn, error methods
|
|
35
35
|
*
|
|
36
36
|
* @example
|
|
@@ -17,12 +17,13 @@ export declare class AuthenticationFailedError extends Error {
|
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* Ensures a valid token exists before making authenticated API calls.
|
|
20
|
-
* If no valid token exists
|
|
21
|
-
*
|
|
20
|
+
* If no valid token exists, callers may provide a session synchronizer that
|
|
21
|
+
* uses the platform-appropriate new flow (cookie restore, device claim, or
|
|
22
|
+
* native secure restore). This helper never exchanges a session id for a token.
|
|
22
23
|
*
|
|
23
24
|
* @throws {SessionSyncRequiredError} If the session needs to be synced (offline session)
|
|
24
25
|
*/
|
|
25
|
-
export declare function ensureValidToken(oxyServices: OxyServices,
|
|
26
|
+
export declare function ensureValidToken(oxyServices: OxyServices, _activeSessionId: string | null | undefined, syncSession?: () => Promise<unknown>): Promise<void>;
|
|
26
27
|
/**
|
|
27
28
|
* Options for handling API authentication errors
|
|
28
29
|
*/
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* On a fresh page load / app launch the SDK may have several ways to recover an
|
|
6
6
|
* existing session (silent FedCM, a persisted refresh token, a cross-domain
|
|
7
|
-
* claim,
|
|
7
|
+
* claim, a redirect SSO return, ...). They must be attempted in a deterministic
|
|
8
8
|
* order*, and the FIRST one that yields a session wins — every later step is
|
|
9
9
|
* skipped. This module encodes exactly that contract and nothing else.
|
|
10
10
|
*
|
|
@@ -100,7 +100,7 @@ export interface RunColdBootOptions<S> {
|
|
|
100
100
|
* Per-step timeouts inside `run()` remain the first line of defense and
|
|
101
101
|
* should keep every step well under this budget on a healthy load; this only
|
|
102
102
|
* trips when one of them regresses (the production FedCM-silent hang). When
|
|
103
|
-
* omitted there is
|
|
103
|
+
* omitted there is no overall deadline.
|
|
104
104
|
*/
|
|
105
105
|
readonly overallDeadlineMs?: number;
|
|
106
106
|
/**
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* Clerk-style multi-domain SSO depends on the IdP being reachable on a
|
|
9
9
|
* subdomain of the RP's own apex (e.g. `auth.mention.earth` CNAMEd to the
|
|
10
10
|
* central Oxy IdP). That way every FedCM endpoint, the session cookie,
|
|
11
|
-
* and any
|
|
11
|
+
* and any redirect target are same-site with the RP — the only way
|
|
12
12
|
* to get first-party cookies in Safari ITP and Firefox Total Cookie
|
|
13
13
|
* Protection.
|
|
14
14
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxyhq/core",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.3",
|
|
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",
|
|
@@ -23,6 +23,17 @@
|
|
|
23
23
|
},
|
|
24
24
|
"default": "./dist/esm/index.js"
|
|
25
25
|
},
|
|
26
|
+
"./server": {
|
|
27
|
+
"import": {
|
|
28
|
+
"types": "./dist/types/server/index.d.ts",
|
|
29
|
+
"default": "./dist/esm/server/index.js"
|
|
30
|
+
},
|
|
31
|
+
"require": {
|
|
32
|
+
"types": "./dist/types/server/index.d.ts",
|
|
33
|
+
"default": "./dist/cjs/server/index.js"
|
|
34
|
+
},
|
|
35
|
+
"default": "./dist/esm/server/index.js"
|
|
36
|
+
},
|
|
26
37
|
"./package.json": "./package.json"
|
|
27
38
|
},
|
|
28
39
|
"react-native": {
|
|
@@ -91,7 +102,9 @@
|
|
|
91
102
|
"peerDependencies": {
|
|
92
103
|
"@react-native-async-storage/async-storage": "*",
|
|
93
104
|
"expo-crypto": "*",
|
|
94
|
-
"expo-secure-store": "*"
|
|
105
|
+
"expo-secure-store": "*",
|
|
106
|
+
"express": "^4.0.0",
|
|
107
|
+
"express-rate-limit": "^7.0.0"
|
|
95
108
|
},
|
|
96
109
|
"peerDependenciesMeta": {
|
|
97
110
|
"@react-native-async-storage/async-storage": {
|
|
@@ -102,16 +115,25 @@
|
|
|
102
115
|
},
|
|
103
116
|
"expo-secure-store": {
|
|
104
117
|
"optional": true
|
|
118
|
+
},
|
|
119
|
+
"express": {
|
|
120
|
+
"optional": true
|
|
121
|
+
},
|
|
122
|
+
"express-rate-limit": {
|
|
123
|
+
"optional": true
|
|
105
124
|
}
|
|
106
125
|
},
|
|
107
126
|
"devDependencies": {
|
|
108
127
|
"@biomejs/biome": "^1.9.4",
|
|
109
128
|
"@react-native-async-storage/async-storage": "^2.2.0",
|
|
110
129
|
"@types/elliptic": "^6.4.18",
|
|
130
|
+
"@types/express": "^4.17.21",
|
|
111
131
|
"@types/invariant": "^2.2.34",
|
|
112
132
|
"@types/node": "^20.19.9",
|
|
113
133
|
"expo-crypto": "~56.0.3",
|
|
114
134
|
"expo-secure-store": "~56.0.4",
|
|
135
|
+
"express": "^4.21.2",
|
|
136
|
+
"express-rate-limit": "^7.5.0",
|
|
115
137
|
"release-it": "^19.0.6",
|
|
116
138
|
"typescript": "^5.9.2"
|
|
117
139
|
}
|