@civitai/app-sdk 0.96.0 → 0.97.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.
@@ -88,7 +88,7 @@ export { isModelSlotContext, isPageSlotContext } from './types.js';
88
88
  * in `types.ts` for which of the two it uses and why.
89
89
  */
90
90
  export { isSignedIn } from './types.js';
91
- export type { BlockContext, KnownSlotId, ModelSlotId, PageSlotContext, PageSlotId, UnknownSlotContext, BlockAnalyticsDeclaration, BlockAnalyticsEventDeclaration, BlockAnalyticsPropertyDeclaration, BlockManifest, BlockManifestGood, BlockManifestV1, BlockSettings, BlockStorageCollectionDeclaration, BlockStorageCollectionHook, BlockStorageCollectionSchema, BlockStorageDeclaration, BlockStorageImport, BlockStorageIndexes, BlockStorageIndexType, BlockStorageMigrationKeyword, BlockStorageMigrationOp, BlockStoragePrivateCollectionDeclaration, BlockStorageSchemaType, BlockStorageSharedCollectionDeclaration, BlockToken, ContentRating, ManifestBooleanField, ManifestIframe, ManifestNumberField, ManifestPage, ManifestPreview, ManifestSettingField, ManifestSettings, ManifestStringField, ManifestTarget, ModelSlotContext, SettingScope, SettingWidget, Theme, ViewerInfo, BlockCheckpointInfo, BlockResourceInfo, BlockResourcePickerType, BlockSourceImage, BlockUploadedImageInfo, BlockGenerationSourceImageInfo, BlockUploadedGenerationSource, BlockPersistGenerationSourceRequest, BlockPersistedGenerationSource, BlockImagePickerSource, BlockPickedImageInfo, BlockMediaKind, BlockMediaUploadInfo, BlockMediaUploadBatchItemResult, BlockPendingImageInfo, BlockSharedUploadImageInfo, BlockSharedPendingImageInfo, BlockImageScanResult, BlockUploadPurpose, BlockNavigateScope, BlockShareLinkMethod, BlockShareLinkRequest, BlockShareLinkResult, BlockTextToImageParams, BlockWorkflowSnapshot, RateLimitMeta, BlockEstimateBatchAggregate, BlockModelSubstitution, ModelSubstitutionReason, KnownBlockWorkflowErrorCode, BlockStepToolCall, BlockTrainedEpoch, BlockPublishedModel, BuzzAccountType, ShowcaseImage, WorkflowBody, WorkflowBodyTextToImage, WorkflowBodyCustomComfy, WorkflowBodyCustomComfyRecipe, WorkflowBodyCustomComfyInline, InlineComfyNode, WorkflowBodyStep, WorkflowBodyPassThroughStep, WorkflowBodyWorkflow, WorkflowBodyWorkflowStep, WorkflowStepRef, WithWorkflowStepRefs, BlockWorkflowStepSnapshot, BlockWorkflowStepQueue, BlockWorkflowEta, KnownBlockWorkflowQueueSupport, BlockWorkflowOutput, BlockWorkflowAvailableOutput, BlockWorkflowRestrictedOutput, BlockWorkflowPendingOutput, BlockWorkflowBlockedOutput, KnownBlockWorkflowOutputRating, KnownBlockWorkflowRestrictionReason, KnownBlockOutputUnlockOutcome, BlockOutputUnlockResult, WorkflowStatus, BlockBuzzTransaction, BlockBuzzAccount, BlockDailyCompensationResource, BlockViewer, BlockWildcardPack, BlockWildcardPackErrorCode, BlockResourceFile, BlockResourceFileEntry, BlockResourceFileEntryFormat, BlockResourceFileErrorCode, BlockResourceFileMeta, AppWorkflow, AppWorkflowImage, BlockGatedImage, BlockCollectionFollowErrorCode, BlockCollectionFollowResult, BlockPostSource, BlockCreatePostRequest, BlockCreatePostResult, BlockCreatePostHostError, WorkflowBodyTraining, AiToolkitTrainingParams, AiToolkitTrainingParamsBase, AiToolkitPlainEcosystem, AiToolkitLrScheduler, AiToolkitOptimizerType, BlockTrainingQuote, BlockTrainingDatasetItem, BlockTrainingDataImage, BlockTrainingDataUploadResult, BlockRunTrainingHostError, BlockStepQuote, BlockModel3dOutput, BlockRunConfirmedStepHostError, } from './types.js';
91
+ export type { BlockContext, KnownSlotId, ModelSlotId, PageSlotContext, PageSlotId, UnknownSlotContext, BlockAnalyticsDeclaration, BlockAnalyticsEventDeclaration, BlockAnalyticsPropertyDeclaration, BlockManifest, BlockManifestGood, BlockManifestV1, BlockSettings, BlockStorageCollectionDeclaration, BlockStorageCollectionHook, BlockStorageCollectionSchema, BlockStorageDeclaration, BlockStorageImport, BlockStorageIndexes, BlockStorageIndexType, BlockStorageMigrationKeyword, BlockStorageMigrationOp, BlockStoragePrivateCollectionDeclaration, BlockStorageSchemaType, BlockStorageSharedCollectionDeclaration, BlockToken, ContentRating, ManifestBooleanField, ManifestIframe, ManifestNumberField, ManifestPage, ManifestPreview, ManifestSettingField, ManifestSettings, ManifestStringField, ManifestTarget, ModelSlotContext, SettingScope, SettingWidget, Theme, ViewerInfo, ViewerImage, BlockCheckpointInfo, BlockResourceInfo, BlockResourcePickerType, BlockSourceImage, BlockUploadedImageInfo, BlockGenerationSourceImageInfo, BlockUploadedGenerationSource, BlockPersistGenerationSourceRequest, BlockPersistedGenerationSource, BlockImagePickerSource, BlockPickedImageInfo, BlockMediaKind, BlockMediaUploadInfo, BlockMediaUploadBatchItemResult, BlockPendingImageInfo, BlockSharedUploadImageInfo, BlockSharedPendingImageInfo, BlockImageScanResult, BlockUploadPurpose, BlockNavigateScope, BlockShareLinkMethod, BlockShareLinkRequest, BlockShareLinkResult, BlockTextToImageParams, BlockWorkflowSnapshot, RateLimitMeta, BlockEstimateBatchAggregate, BlockModelSubstitution, ModelSubstitutionReason, KnownBlockWorkflowErrorCode, BlockStepToolCall, BlockTrainedEpoch, BlockPublishedModel, BuzzAccountType, ShowcaseImage, WorkflowBody, WorkflowBodyTextToImage, WorkflowBodyCustomComfy, WorkflowBodyCustomComfyRecipe, WorkflowBodyCustomComfyInline, InlineComfyNode, WorkflowBodyStep, WorkflowBodyPassThroughStep, WorkflowBodyWorkflow, WorkflowBodyWorkflowStep, WorkflowStepRef, WithWorkflowStepRefs, BlockWorkflowStepSnapshot, BlockWorkflowStepQueue, BlockWorkflowEta, KnownBlockWorkflowQueueSupport, BlockWorkflowOutput, BlockWorkflowAvailableOutput, BlockWorkflowRestrictedOutput, BlockWorkflowPendingOutput, BlockWorkflowBlockedOutput, KnownBlockWorkflowOutputRating, KnownBlockWorkflowRestrictionReason, KnownBlockOutputUnlockOutcome, BlockOutputUnlockResult, WorkflowStatus, BlockBuzzTransaction, BlockBuzzAccount, BlockDailyCompensationResource, BlockViewer, BlockWildcardPack, BlockWildcardPackErrorCode, BlockResourceFile, BlockResourceFileEntry, BlockResourceFileEntryFormat, BlockResourceFileErrorCode, BlockResourceFileMeta, AppWorkflow, AppWorkflowImage, BlockGatedImage, BlockCollectionFollowErrorCode, BlockCollectionFollowResult, BlockPostSource, BlockCreatePostRequest, BlockCreatePostResult, BlockCreatePostHostError, WorkflowBodyTraining, AiToolkitTrainingParams, AiToolkitTrainingParamsBase, AiToolkitPlainEcosystem, AiToolkitLrScheduler, AiToolkitOptimizerType, BlockTrainingQuote, BlockTrainingDatasetItem, BlockTrainingDataImage, BlockTrainingDataUploadResult, BlockRunTrainingHostError, BlockStepQuote, BlockModel3dOutput, BlockRunConfirmedStepHostError, } from './types.js';
92
92
  /**
93
93
  * Host bounds for an inline `customComfy` graph, mirrored from civitai/civitai —
94
94
  * see `WorkflowBodyCustomComfyInline.workflow`.
@@ -831,7 +831,8 @@ export interface ViewerInfo {
831
831
  * so there is no half-covered fleet.
832
832
  * - That repo's own contract test (`__tests__/projectBlockInit.test.ts`) now
833
833
  * pins the BLOCK_INIT viewer key set as exactly
834
- * `['id', 'signedIn', 'username']`, and asserts the value is literally
834
+ * `['id', 'signedIn', 'username']` — plus {@link ViewerInfo.image} when the
835
+ * token carries `user:read:self` — and asserts the value is literally
835
836
  * `true` rather than a computed boolean.
836
837
  * - It arrived with civitai/civitai#3707 (merged 2026-08-07). Earlier
837
838
  * revisions of this doc first told authors to write `viewer !== null`
@@ -869,7 +870,39 @@ export interface ViewerInfo {
869
870
  username: string | null;
870
871
  /** @deprecated Not sent by the platform to third-party iframes (civitai #2521). */
871
872
  status?: 'active' | 'banned' | 'muted';
873
+ /**
874
+ * The viewer's avatar — see {@link ViewerImage}. Sent only when the block token
875
+ * carries `user:read:self`; ABSENT otherwise, and on a host that predates the
876
+ * field. Computed when the token is minted and not re-sent after a later consent
877
+ * grant: read `useViewer()` / `blocks/me` for a fresh value.
878
+ */
879
+ image?: ViewerImage;
872
880
  }
881
+ /**
882
+ * The viewer's avatar as the platform lets an app see it — the same value on
883
+ * `BLOCK_INIT.viewer.image`, `useViewer()` (`GET_VIEWER`) and
884
+ * `GET /api/v1/blocks/me`. The platform judges it against the block token's
885
+ * maturity ceiling — the one that restricts workflow outputs — and fails closed:
886
+ *
887
+ * - `{ url, nsfwLevel }` — a ready-to-render CDN image url and the avatar's
888
+ * rating (the same vocabulary as a workflow output's `nsfwLevel`:
889
+ * {@link KnownBlockWorkflowOutputRating}, open-ended).
890
+ * - `{ restricted: true }` — the viewer HAS an avatar this app may not show:
891
+ * rated above what this app may show this viewer (e.g. an X avatar in an SFW
892
+ * app), or not rated (still being scanned, or never). No url, and no reason —
893
+ * which of the two it is would disclose the avatar's rating.
894
+ * - `null` — the viewer has no avatar to show.
895
+ *
896
+ * Mirrors civitai/civitai's `BlockInitViewerImage`
897
+ * (`src/components/AppBlocks/types.ts`) and `projectBlockViewerImage`
898
+ * (`src/server/services/blocks/block-viewer-image.ts`).
899
+ */
900
+ export type ViewerImage = {
901
+ url: string;
902
+ nsfwLevel: KnownBlockWorkflowOutputRating | (string & {});
903
+ } | {
904
+ restricted: true;
905
+ } | null;
873
906
  /**
874
907
  * THE sign-in gate. Pass `useBlockContext().viewer` (or a `BlockInitPayload`'s
875
908
  * `viewer`) and render the signed-in branch when it returns `true`.
@@ -4121,6 +4154,8 @@ export interface BlockViewer {
4121
4154
  status: 'active' | 'muted';
4122
4155
  /** The viewer's current Buzz budget, or `null` when the token lacks the claim. */
4123
4156
  buzzBudget: number | null;
4157
+ /** The viewer's avatar — see {@link ViewerImage}. Absent from a host that predates it. */
4158
+ image?: ViewerImage;
4124
4159
  }
4125
4160
  /**
4126
4161
  * The DISCRIMINATED error enum a `WILDCARD_PACK_RESULT` carries on failure —
package/dist/index.d.ts CHANGED
@@ -25,11 +25,11 @@
25
25
  *
26
26
  * - **`./blocks`** — importing it RUNS `./safe-storage` for its side effect
27
27
  * (repairing `localStorage`/`sessionStorage` at an opaque origin). Folding
28
- * 245 symbols and that side effect into the root would make every OAuth app
28
+ * 246 symbols and that side effect into the root would make every OAuth app
29
29
  * that writes `import { exchangeCode } from '@civitai/app-sdk'` pay for the
30
30
  * Civitai-Apps contract it does not use. Blocks and OAuth apps are disjoint
31
31
  * audiences; see this package's README.
32
- * 🔴 That 245 is ASSERTED, not merely quoted — by
32
+ * 🔴 That 246 is ASSERTED, not merely quoted — by
33
33
  * `packages/civitai-app-sdk/test/export-surface.test.ts`, which pins
34
34
  * `surface.get('./blocks').size`. It said 119 here against a real 125 until
35
35
  * 2026-10-04, because the existing checks pin the root as an exact union and
package/dist/index.js CHANGED
@@ -25,11 +25,11 @@
25
25
  *
26
26
  * - **`./blocks`** — importing it RUNS `./safe-storage` for its side effect
27
27
  * (repairing `localStorage`/`sessionStorage` at an opaque origin). Folding
28
- * 245 symbols and that side effect into the root would make every OAuth app
28
+ * 246 symbols and that side effect into the root would make every OAuth app
29
29
  * that writes `import { exchangeCode } from '@civitai/app-sdk'` pay for the
30
30
  * Civitai-Apps contract it does not use. Blocks and OAuth apps are disjoint
31
31
  * audiences; see this package's README.
32
- * 🔴 That 245 is ASSERTED, not merely quoted — by
32
+ * 🔴 That 246 is ASSERTED, not merely quoted — by
33
33
  * `packages/civitai-app-sdk/test/export-surface.test.ts`, which pins
34
34
  * `surface.get('./blocks').size`. It said 119 here against a real 125 until
35
35
  * 2026-10-04, because the existing checks pin the root as an exact union and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@civitai/app-sdk",
3
- "version": "0.96.0",
3
+ "version": "0.97.0",
4
4
  "description": "OAuth + PKCE, encrypted-cookie sessions, scopes, and orchestrator helpers for building third-party Civitai apps.",
5
5
  "license": "MIT",
6
6
  "type": "module",