@oxyhq/core 20.0.0 → 20.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.
@@ -39,6 +39,7 @@ export type { CanonicalUserHandleInput, UserHandleInput } from './utils/userHand
39
39
  export { normalizeProfileLinks } from './utils/profileLinks';
40
40
  export type { ProfileLink, ProfileLinkMetadata } from './utils/profileLinks';
41
41
  export type { PublicApplication, ConnectedApp, } from './mixins/OxyServices.connectedApps';
42
+ export type { StoreCategory, StoreRating, StoreListingSummary, StoreListingDetail, StoreScreenshot, StoreScreenshotPlatform, StoreReview, StoreOwnReview, WriteStoreReviewInput, StoreListingStatus, PublisherListing, WriteListingInput, AddScreenshotInput, UpdateScreenshotInput, StorePage, StorePageOptions, StoreReviewsOptions, } from './mixins/OxyServices.store';
42
43
  export type { AccountKind, AccountCategoryId, AccountRelationship, AccountRole, AccountMemberStatus, AccountMemberSource, AccountMember, AccountNode, AccountCredentialType, AccountCredentialEnvironment, AccountCredentialStatus, AccountCredential, AccountCredentialWithSecret, RotateAccountCredentialResult, ListAccountsOptions, CreateAccountInput, UpdateAccountInput, ProvisionChannelInput, ProvisionChannelMemberInput, ProvisionChannelResult, InviteAccountMemberInput, UpdateAccountMemberInput, TransferAccountOwnershipInput, CreateAccountCredentialInput, AccountSuccessResult, SwitchAccountResult, Application, ApplicationType, ApplicationStatus, ApplicationCredential, ApplicationCredentialType, ApplicationCredentialStatus, ApplicationEnvironment, CreateApplicationInput, UpdateApplicationInput, CreateApplicationCredentialInput, ApplicationCredentialWithSecret, RotateApplicationCredentialResult, ApplicationUsagePeriod, ApplicationUsageSummary, ApplicationUsageByDay, ApplicationUsageByEndpoint, ApplicationUsageStats, } from './mixins/OxyServices.accounts';
43
44
  export { ACCOUNT_CATEGORY_IDS, MAX_ACCOUNT_CATEGORIES, SELECTABLE_ACCOUNT_CATEGORY_IDS, isSelectableAccountCategoryId, kindAcceptsAccountCategories, } from './mixins/OxyServices.accounts';
44
45
  export { buildUserDid } from './mixins/OxyServices.identity';
@@ -46,6 +47,12 @@ export type { IdentityRecordType, UnlinkableAuthMethodType, LinkAuthMethodResult
46
47
  export { parseIdPayload, parseAttestPayload, verifyPublicCardAttestation, } from './mixins/OxyServices.civic';
47
48
  export type { CivicCardResult, IdCardRef, AttestQrPayload, ParsedAttestPayload, SubmitRealLifeAttestationInput, DenyValidationResult, VouchForPersonInput, WithdrawVouchResult, IssueCredentialInput, RevokeCredentialResult, } from './mixins/OxyServices.civic';
48
49
  export type { UserNodeStatus, UserNodeMode, UserNodeController, UserNodeLivenessStatus, RegisterNodeInput, RemoveNodeResult } from './mixins/OxyServices.nodes';
50
+ /**
51
+ * Chains — the shared per-person record log. `ChainRecord` is generic over the
52
+ * app's own lexicon payload, so a consumer types its records without Oxy
53
+ * knowing any app's schema.
54
+ */
55
+ export type { ChainRecord, ChainRecordPage, AppendedChainRecord } from './mixins/OxyServices.chains';
49
56
  export { SessionSyncRequiredError, AuthenticationFailedError, ensureValidToken, isAuthenticationError, withAuthErrorHandling, authenticatedApiCall, } from './utils/authHelpers';
50
57
  export type { HandleApiErrorOptions } from './utils/authHelpers';
51
58
  export { mergeSessions, normalizeAndSortSessions, sessionsArraysEqual, } from './utils/sessionUtils';
@@ -0,0 +1,156 @@
1
+ /**
2
+ * Chains — the shared record log every Oxy app reads and writes.
3
+ *
4
+ * A person has ONE chain. An app appends its own records to it and projects its
5
+ * feeds from what it reads back, instead of keeping a private copy of the same
6
+ * person's activity. This mixin is the client half of `/chains` in oxy-api, and
7
+ * it exists so that adopting the chain costs an app no HTTP of its own — the
8
+ * whole point of the shared substrate is that the second app writes less code
9
+ * than the first, not the same amount in a different file.
10
+ *
11
+ * ## Both calls are SERVICE-authenticated
12
+ *
13
+ * They go through `makeServiceRequest`, so they only work on a backend that has
14
+ * called `configureServiceAuth()`. That is not an accident of implementation: an
15
+ * append writes to someone else's chain and a read spans many subjects, so
16
+ * neither belongs in a browser holding a user session. A frontend that needs
17
+ * this asks its own backend.
18
+ *
19
+ * The authority is checked server-side and cannot be talked out of from here:
20
+ * `chains:write` plus the application's own `chainNamespaces` for an append,
21
+ * `chains:read` plus the public-collection policy for a read. A call that
22
+ * violates either gets a 403 or an empty page — this client adds no
23
+ * pre-validation that could drift from the server's answer.
24
+ */
25
+ import type { OxyServicesBase } from '../OxyServices.base';
26
+ /** A signed record as it comes back from a read. */
27
+ export interface ChainRecord<TRecord = Record<string, unknown>> {
28
+ recordId: string;
29
+ /** The subject whose chain it is — the person the record is about. */
30
+ oxyUserId: string;
31
+ /** The lexicon NSID, e.g. `app.mention.feed.post`. */
32
+ collection: string;
33
+ envelope: {
34
+ version: number;
35
+ type: string;
36
+ subject: string;
37
+ issuer: string;
38
+ record: TRecord;
39
+ issuedAt: number;
40
+ seq?: number;
41
+ prev?: string | null;
42
+ collection?: string;
43
+ rkey?: string;
44
+ publicKey: string;
45
+ alg: string;
46
+ signature: string;
47
+ };
48
+ }
49
+ /** One page of a multi-subject read. */
50
+ export interface ChainRecordPage<TRecord = Record<string, unknown>> {
51
+ records: ChainRecord<TRecord>[];
52
+ /**
53
+ * Opaque. Hand it back as `since` to continue; `null` at the end of the
54
+ * stream as of this snapshot. Never construct one.
55
+ */
56
+ nextCursor: string | null;
57
+ }
58
+ /** What an append returns once the record is on the chain. */
59
+ export interface AppendedChainRecord {
60
+ recordId: string;
61
+ seq: number;
62
+ envelope: ChainRecord['envelope'];
63
+ verified: boolean;
64
+ }
65
+ export declare function OxyServicesChainsMixin<T extends typeof OxyServicesBase>(Base: T): {
66
+ new (...args: any[]): {
67
+ /** Service-token request, implemented by the auth mixin earlier in the pipeline. */
68
+ makeServiceRequest: <R = unknown>(method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", url: string, data?: unknown, userId?: string) => Promise<R>;
69
+ /**
70
+ * Append a record to `oxyUserId`'s chain under `collection`/`rkey`.
71
+ *
72
+ * Oxy issues and signs it; the calling app never holds a chain signing key.
73
+ * `rkey` is the app's own id for the thing — reusing it later supersedes the
74
+ * earlier record for that key, which is how an edit works.
75
+ *
76
+ * Requires the `chains:write` scope AND `collection` falling under one of
77
+ * this application's granted `chainNamespaces`. Both are enforced by the
78
+ * server; a violation throws with a 403.
79
+ */
80
+ appendChainRecord(params: {
81
+ oxyUserId: string;
82
+ collection: string;
83
+ rkey: string;
84
+ record: Record<string, unknown>;
85
+ }): Promise<AppendedChainRecord>;
86
+ /**
87
+ * Records published by any of `oxyUserIds` under any of `collections`,
88
+ * oldest first — the read a cross-app feed is projected from.
89
+ *
90
+ * Only collections Oxy declares PUBLIC come back, whatever is asked for; a
91
+ * private one yields nothing rather than an error.
92
+ *
93
+ * **Re-poll from slightly BEFORE your last cursor and dedupe by
94
+ * `recordId`.** The chain's pagination axis is a transaction-start
95
+ * timestamp, so a record can commit behind a cursor that already passed it.
96
+ * Re-delivering one costs bytes; skipping one costs a record that never
97
+ * appears. Projections are expected to be idempotent for exactly this
98
+ * reason.
99
+ */
100
+ readChainRecords<TRecord = Record<string, unknown>>(params: {
101
+ oxyUserIds: readonly string[];
102
+ collections: readonly string[];
103
+ since?: string | null;
104
+ limit?: number;
105
+ }): Promise<ChainRecordPage<TRecord>>;
106
+ httpService: import("../HttpService").HttpService;
107
+ cloudURL: string;
108
+ config: import("../OxyServices.base").OxyConfig;
109
+ __resetTokensForTests(): void;
110
+ makeRequest<T_1>(method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", url: string, data?: any, options?: import("../HttpService").RequestOptions): Promise<T_1>;
111
+ getBaseURL(): string;
112
+ getClient(): import("../HttpService").HttpService;
113
+ createLinkedClient(config: import("../OxyServices.base").OxyConfig): import("..").LinkedHttpClient;
114
+ getMetrics(): {
115
+ totalRequests: number;
116
+ successfulRequests: number;
117
+ failedRequests: number;
118
+ cacheHits: number;
119
+ cacheMisses: number;
120
+ averageResponseTime: number;
121
+ };
122
+ clearCache(): void;
123
+ clearCacheEntry(key: string): void;
124
+ clearCacheByPrefix(prefix: string): number;
125
+ getCacheStats(): {
126
+ size: number;
127
+ hits: number;
128
+ misses: number;
129
+ hitRate: number;
130
+ };
131
+ getCloudURL(): string;
132
+ setTokens(accessToken: string): void;
133
+ clearTokens(): void;
134
+ onTokensChanged(listener: (accessToken: string | null) => void): () => void;
135
+ _cachedUserId: string | null | undefined;
136
+ _cachedAccessToken: string | null;
137
+ getCurrentUserId(): string | null;
138
+ hasValidToken(): boolean;
139
+ getAccessToken(): string | null;
140
+ getAccessTokenExpiry(): number | null;
141
+ waitForAuth(timeoutMs?: number): Promise<boolean>;
142
+ withAuthRetry<T_1>(operation: () => Promise<T_1>, operationName: string, options?: {
143
+ maxRetries?: number;
144
+ retryDelay?: number;
145
+ authTimeoutMs?: number;
146
+ }): Promise<T_1>;
147
+ validate(): Promise<boolean>;
148
+ handleError(error: unknown): Error;
149
+ healthCheck(): Promise<{
150
+ status: string;
151
+ users?: number;
152
+ timestamp?: string;
153
+ [key: string]: any;
154
+ }>;
155
+ };
156
+ } & T;
@@ -0,0 +1,334 @@
1
+ /**
2
+ * App Store Methods Mixin
3
+ *
4
+ * The client surface for the Oxy app store: the public storefront (`/store`),
5
+ * the reviews people write there, and the listing a publisher edits for an
6
+ * application they own (`/applications/:appId/listing`).
7
+ *
8
+ * Deliberately separate from `OxyServices.accounts.ts` even though the
9
+ * publisher's routes hang off an application, for the same reason
10
+ * `OxyServices.connectedApps.ts` is: those mixins answer "may this program act
11
+ * for this person?", and this one answers "should this person choose it?". Turn
12
+ * the store off and OAuth still works — which is the test that says the store is
13
+ * a module over the platform rather than part of it.
14
+ *
15
+ * The two prefixes are one domain. A listing IS the store's page for an
16
+ * application, so both halves of its life belong to the same surface; the API
17
+ * puts the publisher's half beside credentials and webhooks because that is
18
+ * where the permission that guards it already lives, and reusing that permission
19
+ * is what stops a store page becoming a second, weaker way to act for somebody's
20
+ * app.
21
+ *
22
+ * ## What is NOT duplicated here
23
+ *
24
+ * A listing carries no name, icon or legal links: `applications` already holds
25
+ * them and the storefront joins them in. A rating is computed from the visible
26
+ * reviews on every read rather than stored, so a hidden review stops counting
27
+ * the moment it is hidden. Reference listings by their `slug` in the storefront
28
+ * (it is what every link carries) and applications by their `_id` in the
29
+ * publisher's calls.
30
+ */
31
+ import type { OxyServicesBase } from '../OxyServices.base';
32
+ /** A shelf on the storefront. */
33
+ export interface StoreCategory {
34
+ /** The public identifier a link carries. Never the row id. */
35
+ slug: string;
36
+ /** What a person reads. Never derived from the slug at render time. */
37
+ label: string;
38
+ description?: string | null;
39
+ }
40
+ /** The rating of an app, computed from its visible reviews. */
41
+ export interface StoreRating {
42
+ /** Rounded to one decimal, or `null` when nobody has reviewed it — never 0. */
43
+ average: number | null;
44
+ count: number;
45
+ }
46
+ /** An app as a card on the storefront: what a listing page needs, and no more. */
47
+ export interface StoreListingSummary {
48
+ slug: string;
49
+ /** From the APPLICATION, joined in — the listing keeps no copy. */
50
+ name: string;
51
+ tagline: string | null;
52
+ /** A file id for the app's icon, resolved through the usual image resolver. */
53
+ icon: string | null;
54
+ category: StoreCategory | null;
55
+ rating: StoreRating;
56
+ }
57
+ /** A store page in full. */
58
+ export interface StoreListingDetail extends StoreListingSummary {
59
+ description: string | null;
60
+ /** These four come from the application; the consent screen shows the same values. */
61
+ websiteUrl: string | null;
62
+ privacyPolicyUrl: string | null;
63
+ termsUrl: string | null;
64
+ supportUrl: string | null;
65
+ supportEmail: string | null;
66
+ publishedAt: string | null;
67
+ screenshots: StoreScreenshot[];
68
+ /** How many visible reviews gave each of 1..5. Absent keys are zero. */
69
+ ratingBreakdown: Record<number, number>;
70
+ }
71
+ /** Which frame a screenshot was taken in. The store groups by it on the page. */
72
+ export type StoreScreenshotPlatform = 'phone' | 'tablet' | 'desktop' | 'web';
73
+ export interface StoreScreenshot {
74
+ id: string;
75
+ /** The uploaded asset's file id. Upload through the assets surface first. */
76
+ fileId: string;
77
+ platform: StoreScreenshotPlatform;
78
+ caption: string | null;
79
+ position: number;
80
+ }
81
+ /** Somebody's review, as it appears on a store page. */
82
+ export interface StoreReview {
83
+ id: string;
84
+ rating: number;
85
+ title: string | null;
86
+ body: string | null;
87
+ createdAt: string;
88
+ author: {
89
+ id: string;
90
+ username: string | null;
91
+ };
92
+ /** The publisher's answer, when there is one. */
93
+ reply: {
94
+ body: string;
95
+ createdAt: string;
96
+ } | null;
97
+ /**
98
+ * Whether this author has authorized the application, read from their grant
99
+ * at request time rather than stored on the review.
100
+ *
101
+ * It is not a claim that they still use it, and it is `false` for a
102
+ * first-party app nobody has to consent to — so render its absence as nothing
103
+ * at all rather than as a demotion.
104
+ */
105
+ authorUsesApp: boolean;
106
+ }
107
+ /** A review as its own author sees it, whatever its moderation state. */
108
+ export interface StoreOwnReview {
109
+ id: string;
110
+ rating: number;
111
+ title: string | null;
112
+ body: string | null;
113
+ /** An author is told when their review is hidden; the public list is not. */
114
+ status: 'visible' | 'hidden' | 'flagged' | 'removed';
115
+ createdAt: string;
116
+ updatedAt: string;
117
+ }
118
+ /** What a person submits about an app. One review each; writing again replaces it. */
119
+ export interface WriteStoreReviewInput {
120
+ /** Whole stars, 1 to 5. The database enforces the bound too. */
121
+ rating: number;
122
+ title?: string | null;
123
+ body?: string | null;
124
+ }
125
+ /** Where a listing is in its life. `pending_review` is the STORE's review of the page. */
126
+ export type StoreListingStatus = 'draft' | 'pending_review' | 'published' | 'rejected';
127
+ /** A listing as its publisher sees it: whatever state it is in. */
128
+ export interface PublisherListing {
129
+ id: string;
130
+ applicationId: string;
131
+ slug: string;
132
+ tagline: string | null;
133
+ description: string | null;
134
+ category: StoreCategory | null;
135
+ supportUrl: string | null;
136
+ supportEmail: string | null;
137
+ status: StoreListingStatus;
138
+ publishedAt: string | null;
139
+ createdAt: string;
140
+ updatedAt: string;
141
+ }
142
+ /**
143
+ * The whole page, not a patch: sending everything is what makes "clear the
144
+ * tagline" expressible at all.
145
+ *
146
+ * `status` is absent on purpose. Publishing is the store's decision and has its
147
+ * own calls, so a publisher cannot publish themselves by putting a field in a
148
+ * body.
149
+ */
150
+ export interface WriteListingInput {
151
+ /** Lowercase letters, digits and single hyphens. What every link carries. */
152
+ slug: string;
153
+ tagline?: string | null;
154
+ description?: string | null;
155
+ /** A category SLUG, never its id. */
156
+ categorySlug?: string | null;
157
+ supportUrl?: string | null;
158
+ supportEmail?: string | null;
159
+ }
160
+ export interface AddScreenshotInput {
161
+ /** An already-uploaded image. Must be live, an image, and yours to publish. */
162
+ fileId: string;
163
+ platform?: StoreScreenshotPlatform;
164
+ caption?: string | null;
165
+ }
166
+ export interface UpdateScreenshotInput {
167
+ platform?: StoreScreenshotPlatform;
168
+ caption?: string | null;
169
+ }
170
+ /**
171
+ * One page of a paginated store read.
172
+ *
173
+ * `hasMore` comes from the API rather than being derived here, so a caller that
174
+ * pages does not have to re-implement the boundary the server already computed.
175
+ */
176
+ export interface StorePage<T> {
177
+ items: T[];
178
+ total: number;
179
+ hasMore: boolean;
180
+ }
181
+ /** Options for paging the storefront and the reviews under an app. */
182
+ export interface StorePageOptions {
183
+ limit?: number;
184
+ offset?: number;
185
+ }
186
+ export interface StoreReviewsOptions extends StorePageOptions {
187
+ /** Newest first by default; `rating` surfaces the strongest opinions. */
188
+ sort?: 'recent' | 'rating';
189
+ }
190
+ export declare function OxyServicesStoreMixin<T extends typeof OxyServicesBase>(Base: T): {
191
+ new (...args: any[]): {
192
+ /** The shelves, in the order the store curates them. */
193
+ listStoreCategories(): Promise<StoreCategory[]>;
194
+ /**
195
+ * Published listings, newest first, optionally one shelf.
196
+ *
197
+ * An unknown category slug is an EMPTY shelf, not every app on the store —
198
+ * so a typo shows nothing rather than showing everything.
199
+ *
200
+ * @param options - `category` is a category slug; `limit` defaults to 24.
201
+ */
202
+ listStoreApps(options?: StorePageOptions & {
203
+ category?: string;
204
+ }): Promise<StorePage<StoreListingSummary>>;
205
+ /**
206
+ * One store page.
207
+ *
208
+ * A draft answers 404 exactly as an unknown slug does: whether an
209
+ * unpublished page exists under a name is not something a visitor learns.
210
+ *
211
+ * @param slug - The listing's public slug, not an application id.
212
+ */
213
+ getStoreApp(slug: string): Promise<StoreListingDetail>;
214
+ /** Visible reviews for a published app, each with the publisher's reply. */
215
+ listStoreReviews(slug: string, options?: StoreReviewsOptions): Promise<StorePage<StoreReview>>;
216
+ /** The caller's own review of an app, or `null` if they have not written one. */
217
+ getMyStoreReview(slug: string): Promise<StoreOwnReview | null>;
218
+ /**
219
+ * Write the caller's review, or replace what they said before.
220
+ *
221
+ * A person has one review per app, so this sets it rather than adding one.
222
+ * Rewriting does not clear a moderator's decision: a hidden review stays
223
+ * hidden when its author edits it.
224
+ */
225
+ writeStoreReview(slug: string, input: WriteStoreReviewInput): Promise<StoreOwnReview>;
226
+ /** Withdraw the caller's own review. A real delete — the words were theirs. */
227
+ deleteMyStoreReview(slug: string): Promise<void>;
228
+ /**
229
+ * Answer a review on the publisher's behalf.
230
+ *
231
+ * Requires `app:update` over the application's owning account — the same
232
+ * permission that guards every other write to that application. Addressed
233
+ * by review id because the reply belongs to the review, and a listing can be
234
+ * renamed or withdrawn out from under it.
235
+ */
236
+ replyToStoreReview(reviewId: string, body: string): Promise<{
237
+ id: string;
238
+ reviewId: string;
239
+ body: string;
240
+ }>;
241
+ /** Withdraw the publisher's answer. Same permission that wrote it. */
242
+ deleteStoreReviewReply(reviewId: string): Promise<void>;
243
+ /** The application's store page in whatever state, or `null` if it has none. */
244
+ getAppListing(applicationId: string): Promise<PublisherListing | null>;
245
+ /**
246
+ * Create the page or replace its content. Never its status.
247
+ *
248
+ * Editing does not move a page: correcting a typo on a live listing leaves
249
+ * it live, and fixing a rejected one does not re-submit it.
250
+ */
251
+ writeAppListing(applicationId: string, input: WriteListingInput): Promise<PublisherListing>;
252
+ /** Hand the page to the store for review. From a draft, or a rejected page once fixed. */
253
+ submitAppListing(applicationId: string): Promise<PublisherListing>;
254
+ /**
255
+ * Take the page down, or withdraw it from the queue.
256
+ *
257
+ * Back to a draft, never deleted: the slug, the words and the screenshots
258
+ * are the publisher's work, and the reviews were never the listing's to take
259
+ * with them.
260
+ */
261
+ unpublishAppListing(applicationId: string): Promise<PublisherListing>;
262
+ /** Every picture on the listing, in the author's order. */
263
+ listAppListingScreenshots(applicationId: string): Promise<StoreScreenshot[]>;
264
+ /**
265
+ * Attach an already-uploaded image, appended to the end.
266
+ *
267
+ * Upload through the assets surface first; the store keeps a reference
268
+ * rather than a second copy of the asset pipeline. The file must be live, an
269
+ * image, and one the caller is entitled to.
270
+ */
271
+ addAppListingScreenshot(applicationId: string, input: AddScreenshotInput): Promise<StoreScreenshot>;
272
+ /** Edit a picture's caption or the frame it was taken in. Order is {@link reorderAppListingScreenshots}. */
273
+ updateAppListingScreenshot(applicationId: string, screenshotId: string, input: UpdateScreenshotInput): Promise<StoreScreenshot>;
274
+ /** Remove a picture. The uploaded file stays — it may be in use elsewhere. */
275
+ deleteAppListingScreenshot(applicationId: string, screenshotId: string): Promise<void>;
276
+ /**
277
+ * Set the order of every picture at once.
278
+ *
279
+ * Send EVERY id on the listing, exactly once, in the order they should
280
+ * appear. A partial list is rejected rather than applied: it would leave the
281
+ * pictures it omits at their old positions, interleaved with the new ones.
282
+ */
283
+ reorderAppListingScreenshots(applicationId: string, screenshotIds: string[]): Promise<StoreScreenshot[]>;
284
+ httpService: import("../HttpService").HttpService;
285
+ cloudURL: string;
286
+ config: import("../OxyServices.base").OxyConfig;
287
+ __resetTokensForTests(): void;
288
+ makeRequest<T_1>(method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", url: string, data?: any, options?: import("../HttpService").RequestOptions): Promise<T_1>;
289
+ getBaseURL(): string;
290
+ getClient(): import("../HttpService").HttpService;
291
+ createLinkedClient(config: import("../OxyServices.base").OxyConfig): import("..").LinkedHttpClient;
292
+ getMetrics(): {
293
+ totalRequests: number;
294
+ successfulRequests: number;
295
+ failedRequests: number;
296
+ cacheHits: number;
297
+ cacheMisses: number;
298
+ averageResponseTime: number;
299
+ };
300
+ clearCache(): void;
301
+ clearCacheEntry(key: string): void;
302
+ clearCacheByPrefix(prefix: string): number;
303
+ getCacheStats(): {
304
+ size: number;
305
+ hits: number;
306
+ misses: number;
307
+ hitRate: number;
308
+ };
309
+ getCloudURL(): string;
310
+ setTokens(accessToken: string): void;
311
+ clearTokens(): void;
312
+ onTokensChanged(listener: (accessToken: string | null) => void): () => void;
313
+ _cachedUserId: string | null | undefined;
314
+ _cachedAccessToken: string | null;
315
+ getCurrentUserId(): string | null;
316
+ hasValidToken(): boolean;
317
+ getAccessToken(): string | null;
318
+ getAccessTokenExpiry(): number | null;
319
+ waitForAuth(timeoutMs?: number): Promise<boolean>;
320
+ withAuthRetry<T_1>(operation: () => Promise<T_1>, operationName: string, options?: {
321
+ maxRetries?: number;
322
+ retryDelay?: number;
323
+ authTimeoutMs?: number;
324
+ }): Promise<T_1>;
325
+ validate(): Promise<boolean>;
326
+ handleError(error: unknown): Error;
327
+ healthCheck(): Promise<{
328
+ status: string;
329
+ users?: number;
330
+ timestamp?: string;
331
+ [key: string]: any;
332
+ }>;
333
+ };
334
+ } & T;
@@ -109,18 +109,41 @@ export declare function OxyServicesUtilityMixin<T extends typeof OxyServicesBase
109
109
  * Uses server-side session validation for security (not just JWT decode).
110
110
  *
111
111
  * **Design note — jwtDecode vs jwt.verify:**
112
- * This middleware intentionally uses `jwtDecode()` (decode-only, no signature
113
- * verification) for user tokens. This is by design, NOT a security gap:
114
- * - Third-party apps using `oxy.auth()` don't have the Oxy JWT secret
115
- * - Security comes from API-based session validation (`validateSession()`)
116
- * which checks the session server-side on every request
117
- * - Service tokens (type: 'service') DO use cryptographic HMAC verification
118
- * via the `jwtSecret` option, since they are stateless. Service tokens
119
- * are additionally checked for `aud`, `iss`, and `type` claims to prevent
112
+ * This middleware uses `jwtDecode()` (decode-only, NO signature check) for
113
+ * user tokens, because third-party apps mounting `oxy.auth()` do not hold
114
+ * the Oxy signing secret. **Every claim in a user token is therefore
115
+ * attacker-controlled and proves nothing on its own.** The identity comes
116
+ * from somewhere else entirely:
117
+ * - A user token MUST carry a `sessionId`. That session is validated
118
+ * server-side on every request via `validateSession()`, and the user id
119
+ * is read off the VALIDATED SESSION never off the token. A token whose
120
+ * `userId` claim disagrees with the session is refused
121
+ * (`SESSION_USER_MISMATCH`); a token with no `sessionId` at all is
122
+ * refused outright (`SESSION_REQUIRED`). There is no local-claims path.
123
+ * - Service tokens (type: 'service') ARE stateless, so they use
124
+ * cryptographic HMAC verification via the `jwtSecret` option, and are
125
+ * additionally checked for `aud`, `iss`, and `type` claims to prevent
120
126
  * cross-token-type confusion attacks.
121
127
  * - The backend's own `authMiddleware` uses `jwt.verify()` because it has
122
128
  * direct access to `SERVICE_TOKEN_SECRET` / `ACCESS_TOKEN_SECRET`.
123
129
  *
130
+ * **Why session-less user tokens are refused rather than trusted:**
131
+ * every user access token the Oxy API issues carries a `sessionId` (see
132
+ * `packages/api/src/utils/sessionUtils.ts`, `generateSessionTokens` — the
133
+ * only mint site for user tokens, including the OAuth code exchange). So
134
+ * refusing session-less user tokens costs nothing legitimate, while
135
+ * accepting them let anyone authenticate as anyone by hand-rolling a JWT
136
+ * with a `userId` claim and a garbage signature.
137
+ *
138
+ * **Why the claimed user id is cross-checked against the session:**
139
+ * `GET /session/validate/:sessionId` is UNAUTHENTICATED and does not bind
140
+ * the bearer token — it returns whoever owns the session id it was handed.
141
+ * Trusting the token's `userId` claim after a successful validation would
142
+ * therefore let a caller holding ANY live session id (their own, for
143
+ * instance) pair it with a forged `userId` and be trusted as that user.
144
+ * `authSocket()` has always cross-checked this; the HTTP middleware now
145
+ * does too.
146
+ *
124
147
  * **Service-token delegation (X-Oxy-User-Id):**
125
148
  * When a service token is accompanied by `X-Oxy-User-Id`, the SDK calls
126
149
  * `verifyServiceActingAs(appId, userId)` to confirm an explicit delegation
@@ -16,6 +16,7 @@ import { OxyServicesReputationMixin } from './OxyServices.reputation';
16
16
  import { OxyServicesAssetsMixin } from './OxyServices.assets';
17
17
  import { OxyServicesAccountsMixin } from './OxyServices.accounts';
18
18
  import { OxyServicesConnectedAppsMixin } from './OxyServices.connectedApps';
19
+ import { OxyServicesStoreMixin } from './OxyServices.store';
19
20
  import { OxyServicesLocationMixin } from './OxyServices.location';
20
21
  import { OxyServicesAnalyticsMixin } from './OxyServices.analytics';
21
22
  import { OxyServicesDevicesMixin } from './OxyServices.devices';
@@ -27,6 +28,7 @@ import { OxyServicesContactsMixin } from './OxyServices.contacts';
27
28
  import { OxyServicesNotificationsMixin } from './OxyServices.notifications';
28
29
  import { OxyServicesAppDataMixin } from './OxyServices.appData';
29
30
  import { OxyServicesCivicMixin } from './OxyServices.civic';
31
+ import { OxyServicesChainsMixin } from './OxyServices.chains';
30
32
  import { OxyServicesNodesMixin } from './OxyServices.nodes';
31
33
  import { OxyServicesLinksMixin } from './OxyServices.links';
32
34
  import { OxyServicesFollowGraphMixin } from './OxyServices.followGraph';
@@ -41,7 +43,7 @@ import { OxyServicesDeviceTransferMixin } from './OxyServices.deviceTransfer';
41
43
  * If you add a new mixin to `MIXIN_PIPELINE`, add it here too so its methods
42
44
  * are visible without a cast.
43
45
  */
44
- type AllMixinInstances = InstanceType<ReturnType<typeof OxyServicesAuthMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesUserMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesIdentityMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesIdentityBackupMixin<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 OxyServicesAccountsMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesConnectedAppsMixin<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 OxyServicesContactsMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesNotificationsMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesAppDataMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesCivicMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesNodesMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesLinksMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesFollowGraphMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesDeviceBootMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesDeviceTransferMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesUtilityMixin<typeof OxyServicesBase>>>;
46
+ type AllMixinInstances = InstanceType<ReturnType<typeof OxyServicesAuthMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesUserMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesIdentityMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesIdentityBackupMixin<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 OxyServicesAccountsMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesConnectedAppsMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesStoreMixin<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 OxyServicesContactsMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesNotificationsMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesAppDataMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesCivicMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesChainsMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesNodesMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesLinksMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesFollowGraphMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesDeviceBootMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesDeviceTransferMixin<typeof OxyServicesBase>>> & InstanceType<ReturnType<typeof OxyServicesUtilityMixin<typeof OxyServicesBase>>>;
45
47
  /**
46
48
  * Constructor type for the fully composed mixin pipeline. Each mixin returns
47
49
  * a new constructor that augments its input; reducing across the pipeline
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxyhq/core",
3
- "version": "20.0.0",
3
+ "version": "20.1.0",
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",
package/src/index.ts CHANGED
@@ -116,6 +116,29 @@ export type {
116
116
  ConnectedApp,
117
117
  } from './mixins/OxyServices.connectedApps';
118
118
 
119
+ // ---------------------------------------------------------------------------
120
+ // App store (public storefront + reviews + the listing a publisher edits)
121
+ // ---------------------------------------------------------------------------
122
+ export type {
123
+ StoreCategory,
124
+ StoreRating,
125
+ StoreListingSummary,
126
+ StoreListingDetail,
127
+ StoreScreenshot,
128
+ StoreScreenshotPlatform,
129
+ StoreReview,
130
+ StoreOwnReview,
131
+ WriteStoreReviewInput,
132
+ StoreListingStatus,
133
+ PublisherListing,
134
+ WriteListingInput,
135
+ AddScreenshotInput,
136
+ UpdateScreenshotInput,
137
+ StorePage,
138
+ StorePageOptions,
139
+ StoreReviewsOptions,
140
+ } from './mixins/OxyServices.store';
141
+
119
142
  // ---------------------------------------------------------------------------
120
143
  // Accounts (unified account graph: tree, membership, roles, bot credentials)
121
144
  // plus the applications owned within it (Application = OAuth client).
@@ -230,6 +253,13 @@ export type {
230
253
  } from './mixins/OxyServices.civic';
231
254
  export type { UserNodeStatus, UserNodeMode, UserNodeController, UserNodeLivenessStatus, RegisterNodeInput, RemoveNodeResult } from './mixins/OxyServices.nodes';
232
255
 
256
+ /**
257
+ * Chains — the shared per-person record log. `ChainRecord` is generic over the
258
+ * app's own lexicon payload, so a consumer types its records without Oxy
259
+ * knowing any app's schema.
260
+ */
261
+ export type { ChainRecord, ChainRecordPage, AppendedChainRecord } from './mixins/OxyServices.chains';
262
+
233
263
  // ---------------------------------------------------------------------------
234
264
  // Auth helpers (token refresh, error normalisation, retry policies)
235
265
  // ---------------------------------------------------------------------------