@civitai/app-sdk 0.25.1 → 0.27.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 +73 -0
- package/dist/blocks/index.d.ts +4 -1
- package/dist/blocks/index.d.ts.map +1 -1
- package/dist/blocks/index.js +8 -0
- package/dist/blocks/index.js.map +1 -1
- package/dist/blocks/scopes.d.ts +1 -4
- package/dist/blocks/scopes.d.ts.map +1 -1
- package/dist/blocks/scopes.js +1 -4
- package/dist/blocks/scopes.js.map +1 -1
- package/dist/blocks/types.d.ts +79 -5
- package/dist/blocks/types.d.ts.map +1 -1
- package/dist/safe-storage/index.d.ts +76 -0
- package/dist/safe-storage/index.d.ts.map +1 -0
- package/dist/safe-storage/index.js +341 -0
- package/dist/safe-storage/index.js.map +1 -0
- package/package.json +9 -1
- package/schemas/app-block/v1.json +0 -3
package/README.md
CHANGED
|
@@ -24,6 +24,8 @@ pnpm add @civitai/app-sdk
|
|
|
24
24
|
|
|
25
25
|
```ts
|
|
26
26
|
import { defineBlock, BLOCK_SCOPES } from '@civitai/app-sdk/blocks';
|
|
27
|
+
// Opaque-origin storage shim — see "Web storage in a block" below:
|
|
28
|
+
import '@civitai/app-sdk/safe-storage';
|
|
27
29
|
// JSON Schema for the manifest, e.g. for IDE validation:
|
|
28
30
|
import manifestSchema from '@civitai/app-sdk/schemas/app-block/v1.json' with { type: 'json' };
|
|
29
31
|
```
|
|
@@ -129,10 +131,81 @@ Mirrors a strict subset of the civitai/civitai server gate. It throws on:
|
|
|
129
131
|
> **server-side** at submit time (gotcha #33). Keep `iframe.src` =
|
|
130
132
|
> `https://<blockId>.civit.ai/` (root, no path prefix) and your Vite `base: '/'`.
|
|
131
133
|
|
|
134
|
+
### Web storage in a block (`@civitai/app-sdk/safe-storage`)
|
|
135
|
+
|
|
136
|
+
Block iframes are sandboxed **without `allow-same-origin`**, so the document has
|
|
137
|
+
an *opaque origin*. There is no origin to key web storage against, and the
|
|
138
|
+
platform doesn't hand back an empty store — merely **reading** the property
|
|
139
|
+
throws:
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
SecurityError: Failed to read the 'localStorage' property from 'Window':
|
|
143
|
+
The document is sandboxed and lacks the 'allow-same-origin' flag.
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
> **The usual guard does not work here.** `typeof localStorage === 'undefined'`
|
|
147
|
+
> **also throws** in the sandbox — `typeof` still resolves the property and runs
|
|
148
|
+
> the throwing getter; only `typeof` of an *undeclared identifier* is safe.
|
|
149
|
+
> `'localStorage' in window` is the check that survives, and it returns `true`:
|
|
150
|
+
> the global exists, it's just unreadable.
|
|
151
|
+
|
|
152
|
+
Guarding your own call sites isn't enough anyway: **any dependency** that
|
|
153
|
+
touches storage unguarded takes the app down, and libraries routinely mislabel
|
|
154
|
+
the failure — one popular viewer catches the SecurityError and reports "your browser
|
|
155
|
+
does not support WebGL", so the app's own fallback never runs and the user
|
|
156
|
+
dead-ends on a wrong error message.
|
|
157
|
+
|
|
158
|
+
So the SDK repairs it for you. Importing `@civitai/app-sdk/blocks` (or
|
|
159
|
+
`@civitai/blocks-react`, which imports it) installs a spec-shaped in-memory
|
|
160
|
+
`Storage` over `localStorage` / `sessionStorage` — **only** when a real
|
|
161
|
+
round-trip probe shows they're unusable. Rules:
|
|
162
|
+
|
|
163
|
+
- **No-op where storage works.** A healthy `Storage` is never replaced, and its
|
|
164
|
+
contents are never read or written (beyond a probe key it removes).
|
|
165
|
+
- **No-op where storage is absent** (Node / SSR / workers). Nothing is
|
|
166
|
+
fabricated, so `typeof localStorage === 'undefined'` feature detection keeps
|
|
167
|
+
working server-side.
|
|
168
|
+
- **Idempotent**, and safe to call as often as you like.
|
|
169
|
+
- **Never loses readable data.** A store that reads fine but refuses writes (a
|
|
170
|
+
full quota, storage disabled) still gets replaced — writes have to stop
|
|
171
|
+
throwing — but the fallback **inherits its entries first**, so the shim can't
|
|
172
|
+
shadow a live session.
|
|
173
|
+
- **Never throws.** It installs at import, so an error escaping it would reject
|
|
174
|
+
`import '@civitai/app-sdk/blocks'` and take the whole block down. Even a
|
|
175
|
+
revoked `Proxy` or a throwing getter sitting on `localStorage` is classified,
|
|
176
|
+
not propagated.
|
|
177
|
+
- The fallback is **session-scoped** — nothing survives a reload. That's the
|
|
178
|
+
honest semantic at an opaque origin. Treat storage as a cache; use the
|
|
179
|
+
platform's app-storage messages (`useAppStorage` in `@civitai/blocks-react`)
|
|
180
|
+
for anything durable.
|
|
181
|
+
|
|
182
|
+
Most apps need to do nothing. Two cases where you reach for it explicitly:
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
// 1. A dependency reads storage while its module EVALUATES, and it's imported
|
|
186
|
+
// before anything from the SDK. Import statements are hoisted above every
|
|
187
|
+
// statement, so only another import can win the race — put this first in
|
|
188
|
+
// your entry file.
|
|
189
|
+
import '@civitai/app-sdk/safe-storage';
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
```ts
|
|
193
|
+
// 2. Right before dynamically importing such a dependency.
|
|
194
|
+
import { installSafeStorage } from '@civitai/app-sdk/blocks';
|
|
195
|
+
|
|
196
|
+
installSafeStorage(); // no-op if already healthy
|
|
197
|
+
const { Viewer } = await import(viewerModuleSpecifier);
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
`installSafeStorage(scope?)` returns `{ localStorage, sessionStorage }` — `true`
|
|
201
|
+
for each global it actually replaced. `createMemoryStorage()` is exported too,
|
|
202
|
+
if you want the standalone `Storage` work-alike.
|
|
203
|
+
|
|
132
204
|
### Version compatibility
|
|
133
205
|
|
|
134
206
|
| `@civitai/app-sdk` | adds (blocks surface) |
|
|
135
207
|
|---|---|
|
|
208
|
+
| `0.27.0` | `@civitai/app-sdk/safe-storage` — opaque-origin `localStorage`/`sessionStorage` shim, auto-installed by the `blocks` subpath |
|
|
136
209
|
| `0.24.0` | `QUERY_APP_WORKFLOWS` / `CANCEL_APP_WORKFLOW` messages + the `AppWorkflow` type (app generator subqueue, PR #3164) |
|
|
137
210
|
| `0.7.0` | `CANCEL_WORKFLOW` / `WORKFLOW_CANCELED` messages (real cancel, gotcha #51) |
|
|
138
211
|
| `0.6.0` | `APP_STORAGE_*` messages, `ManifestSettings` types |
|
package/dist/blocks/index.d.ts
CHANGED
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
* a separate package (see `@civitai/blocks-react`) so this module stays usable
|
|
7
7
|
* from any runtime — Node, browsers, workers — with no React dependency.
|
|
8
8
|
*/
|
|
9
|
+
import '../safe-storage/index.js';
|
|
10
|
+
export { installSafeStorage, createMemoryStorage } from '../safe-storage/index.js';
|
|
11
|
+
export type { SafeStorageInstallResult, SafeStorageName } from '../safe-storage/index.js';
|
|
9
12
|
export { defineBlock, BlockManifestError } from './defineBlock.js';
|
|
10
13
|
export type { DefineBlockConfig } from './defineBlock.js';
|
|
11
14
|
export { BLOCK_SCOPES, BLOCK_SCOPE_PATTERN, BLOCK_CATEGORIES } from './scopes.js';
|
|
@@ -14,5 +17,5 @@ export { BrowsingLevel, SFW_LEVELS, NSFW_LEVELS, isSfwCeiling, isLevelAllowed, }
|
|
|
14
17
|
export type { BrowsingLevelKey, BrowsingLevelBit, ColorDomain } from './browsingLevel.js';
|
|
15
18
|
export { isMessage } from './messages.js';
|
|
16
19
|
export type { BlockInitPayload, BlockToParentMessage, BlockToParentMessageType, ParentToBlockMessage, ParentToBlockMessageType, SharedStorageItemWire, SharedStorageValue, WrappedToken, BlockBuzzTransactionsParams, BlockDailyCompensationParams, AppWorkflowsParams, } from './messages.js';
|
|
17
|
-
export type { BlockContext, BlockManifest, BlockManifestV1, BlockSettings, BlockToken, ContentRating, ManifestAsset, ManifestBooleanField, ManifestIframe, ManifestNumberField, ManifestPreview, ManifestSettingField, ManifestSettings, ManifestStringField, ManifestTarget, ModelSlotContext, SettingScope, SettingWidget, Theme, ViewerInfo, BlockCheckpointInfo, BlockResourceInfo, BlockResourcePickerType, BlockSourceImage, BlockUploadedImageInfo, BlockGenerationSourceImageInfo, BlockPendingImageInfo, BlockImageScanResult, BlockUploadPurpose, BlockTextToImageParams, BlockWorkflowSnapshot, BuzzAccountType, ShowcaseImage, WorkflowBody, WorkflowStatus, BlockBuzzTransaction, BlockBuzzAccount, BlockDailyCompensationResource, BlockViewer, BlockWildcardPack, BlockWildcardPackErrorCode, AppWorkflow, AppWorkflowImage, BlockGatedImage, } from './types.js';
|
|
20
|
+
export type { BlockContext, BlockManifest, BlockManifestV1, BlockSettings, BlockToken, ContentRating, ManifestAsset, ManifestBooleanField, ManifestIframe, ManifestNumberField, ManifestPreview, ManifestSettingField, ManifestSettings, ManifestStringField, ManifestTarget, ModelSlotContext, SettingScope, SettingWidget, Theme, ViewerInfo, BlockCheckpointInfo, BlockResourceInfo, BlockResourcePickerType, BlockSourceImage, BlockUploadedImageInfo, BlockGenerationSourceImageInfo, BlockPendingImageInfo, BlockImageScanResult, BlockUploadPurpose, BlockTextToImageParams, BlockWorkflowSnapshot, BuzzAccountType, ShowcaseImage, WorkflowBody, WorkflowBodyTextToImage, WorkflowBodyCustomComfy, WorkflowStatus, BlockBuzzTransaction, BlockBuzzAccount, BlockDailyCompensationResource, BlockViewer, BlockWildcardPack, BlockWildcardPackErrorCode, AppWorkflow, AppWorkflowImage, BlockGatedImage, } from './types.js';
|
|
18
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/blocks/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/blocks/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAQH,OAAO,0BAA0B,CAAC;AAElC,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACnF,YAAY,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE1F,OAAO,EAAE,WAA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0B,EAC1B,WAAW,EACX,gBAAgB,EAChB,eAAe,GAChB,MAAM,YAAY,CAAC"}
|
package/dist/blocks/index.js
CHANGED
|
@@ -6,6 +6,14 @@
|
|
|
6
6
|
* a separate package (see `@civitai/blocks-react`) so this module stays usable
|
|
7
7
|
* from any runtime — Node, browsers, workers — with no React dependency.
|
|
8
8
|
*/
|
|
9
|
+
// FIRST import, on purpose. Blocks are framed at an opaque origin (sandbox
|
|
10
|
+
// without `allow-same-origin`), where touching `localStorage`/`sessionStorage`
|
|
11
|
+
// THROWS — including from third-party dependencies nobody can guard from the
|
|
12
|
+
// outside. Importing this repairs those globals before anything else in the
|
|
13
|
+
// block's module graph can trip over them. It is inert wherever storage works
|
|
14
|
+
// or is absent (Node/SSR/workers); see `../safe-storage/index.ts`.
|
|
15
|
+
import '../safe-storage/index.js';
|
|
16
|
+
export { installSafeStorage, createMemoryStorage } from '../safe-storage/index.js';
|
|
9
17
|
export { defineBlock, BlockManifestError } from './defineBlock.js';
|
|
10
18
|
export { BLOCK_SCOPES, BLOCK_SCOPE_PATTERN, BLOCK_CATEGORIES } from './scopes.js';
|
|
11
19
|
export { BrowsingLevel, SFW_LEVELS, NSFW_LEVELS, isSfwCeiling, isLevelAllowed, } from './browsingLevel.js';
|
package/dist/blocks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/blocks/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAGnE,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGlF,OAAO,EACL,aAAa,EACb,UAAU,EACV,WAAW,EACX,YAAY,EACZ,cAAc,GACf,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/blocks/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,2EAA2E;AAC3E,+EAA+E;AAC/E,6EAA6E;AAC7E,4EAA4E;AAC5E,8EAA8E;AAC9E,mEAAmE;AACnE,OAAO,0BAA0B,CAAC;AAElC,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAGnF,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAGnE,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGlF,OAAO,EACL,aAAa,EACb,UAAU,EACV,WAAW,EACX,YAAY,EACZ,cAAc,GACf,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/blocks/scopes.d.ts
CHANGED
|
@@ -12,12 +12,9 @@
|
|
|
12
12
|
*/
|
|
13
13
|
export declare const BLOCK_SCOPES: {
|
|
14
14
|
readonly MODELS_READ_SELF: "models:read:self";
|
|
15
|
-
readonly MEDIA_READ_OWNED: "media:read:owned";
|
|
16
15
|
readonly USER_READ_SELF: "user:read:self";
|
|
17
16
|
readonly AI_WRITE_BUDGETED: "ai:write:budgeted";
|
|
18
17
|
readonly BUZZ_READ_SELF: "buzz:read:self";
|
|
19
|
-
readonly BLOCK_SETTINGS_READ: "block:settings:read";
|
|
20
|
-
readonly BLOCK_SETTINGS_WRITE: "block:settings:write";
|
|
21
18
|
readonly SOCIAL_TIP_SELF: "social:tip:self";
|
|
22
19
|
readonly APPS_STORAGE_READ: "apps:storage:read";
|
|
23
20
|
readonly APPS_STORAGE_WRITE: "apps:storage:write";
|
|
@@ -35,7 +32,7 @@ export type BlockScope = (typeof BLOCK_SCOPES)[BlockScopeKey];
|
|
|
35
32
|
*
|
|
36
33
|
* NOTE: this regex is **not** the authoritative validity contract. The
|
|
37
34
|
* canonical manifest schema (https://civitai.com/schemas/app-block/v1.json)
|
|
38
|
-
* validates `scopes` by MEMBERSHIP in a fixed enum — i.e. the
|
|
35
|
+
* validates `scopes` by MEMBERSHIP in a fixed enum — i.e. the 12 values in
|
|
39
36
|
* {@link BLOCK_SCOPES}. `defineBlock` therefore gates on membership in
|
|
40
37
|
* `BLOCK_SCOPES`; this pattern is kept only as a FORMAT HEURISTIC to give a
|
|
41
38
|
* pointed error message (e.g. distinguishing a malformed/PascalCase scope from
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scopes.d.ts","sourceRoot":"","sources":["../../src/blocks/scopes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"scopes.d.ts","sourceRoot":"","sources":["../../src/blocks/scopes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;CA2Bf,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,YAAY,CAAC;AACtD,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,aAAa,CAAC,CAAC;AAE9D;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,mBAAmB,QAAuC,CAAC;AAExE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,8FAQnB,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC"}
|
package/dist/blocks/scopes.js
CHANGED
|
@@ -12,12 +12,9 @@
|
|
|
12
12
|
*/
|
|
13
13
|
export const BLOCK_SCOPES = {
|
|
14
14
|
MODELS_READ_SELF: 'models:read:self',
|
|
15
|
-
MEDIA_READ_OWNED: 'media:read:owned',
|
|
16
15
|
USER_READ_SELF: 'user:read:self',
|
|
17
16
|
AI_WRITE_BUDGETED: 'ai:write:budgeted',
|
|
18
17
|
BUZZ_READ_SELF: 'buzz:read:self',
|
|
19
|
-
BLOCK_SETTINGS_READ: 'block:settings:read',
|
|
20
|
-
BLOCK_SETTINGS_WRITE: 'block:settings:write',
|
|
21
18
|
SOCIAL_TIP_SELF: 'social:tip:self',
|
|
22
19
|
// apps:storage:* — the per-app KV datastore (W4). These have no OAuth bit
|
|
23
20
|
// (storage never touches the user's civitai resources); the server gates them
|
|
@@ -47,7 +44,7 @@ export const BLOCK_SCOPES = {
|
|
|
47
44
|
*
|
|
48
45
|
* NOTE: this regex is **not** the authoritative validity contract. The
|
|
49
46
|
* canonical manifest schema (https://civitai.com/schemas/app-block/v1.json)
|
|
50
|
-
* validates `scopes` by MEMBERSHIP in a fixed enum — i.e. the
|
|
47
|
+
* validates `scopes` by MEMBERSHIP in a fixed enum — i.e. the 12 values in
|
|
51
48
|
* {@link BLOCK_SCOPES}. `defineBlock` therefore gates on membership in
|
|
52
49
|
* `BLOCK_SCOPES`; this pattern is kept only as a FORMAT HEURISTIC to give a
|
|
53
50
|
* pointed error message (e.g. distinguishing a malformed/PascalCase scope from
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scopes.js","sourceRoot":"","sources":["../../src/blocks/scopes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,gBAAgB,EAAE,kBAAkB;IACpC,
|
|
1
|
+
{"version":3,"file":"scopes.js","sourceRoot":"","sources":["../../src/blocks/scopes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,gBAAgB,EAAE,kBAAkB;IACpC,cAAc,EAAE,gBAAgB;IAChC,iBAAiB,EAAE,mBAAmB;IACtC,cAAc,EAAE,gBAAgB;IAChC,eAAe,EAAE,iBAAiB;IAClC,0EAA0E;IAC1E,8EAA8E;IAC9E,gEAAgE;IAChE,iBAAiB,EAAE,mBAAmB;IACtC,kBAAkB,EAAE,oBAAoB;IACxC,+EAA+E;IAC/E,+EAA+E;IAC/E,6EAA6E;IAC7E,6EAA6E;IAC7E,wBAAwB,EAAE,0BAA0B;IACpD,yBAAyB,EAAE,2BAA2B;IACtD,8EAA8E;IAC9E,6EAA6E;IAC7E,0EAA0E;IAC1E,4EAA4E;IAC5E,kFAAkF;IAClF,yEAAyE;IACzE,qFAAqF;IACrF,qBAAqB,EAAE,uBAAuB;IAC9C,sBAAsB,EAAE,wBAAwB;IAChD,wBAAwB,EAAE,0BAA0B;CAC5C,CAAC;AAKX;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,oCAAoC,CAAC;AAExE;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,YAAY;IACZ,OAAO;IACP,SAAS;IACT,WAAW;IACX,YAAY;IACZ,WAAW;IACX,OAAO;CACC,CAAC"}
|
package/dist/blocks/types.d.ts
CHANGED
|
@@ -374,10 +374,11 @@ export interface BlockTextToImageParams {
|
|
|
374
374
|
quantity?: number;
|
|
375
375
|
}
|
|
376
376
|
/**
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
380
|
-
*
|
|
377
|
+
* The text-to-image member of the {@link WorkflowBody} discriminated union
|
|
378
|
+
* (`kind: 'textToImage'`). This is the original, single-member shape — kept
|
|
379
|
+
* byte-identical for backward compatibility. An existing
|
|
380
|
+
* `{ kind: 'textToImage', modelId, modelVersionId, params }` body must
|
|
381
|
+
* continue to satisfy {@link WorkflowBody} unchanged.
|
|
381
382
|
*
|
|
382
383
|
* Both `modelId` and `modelVersionId` are required even though they're
|
|
383
384
|
* conceptually redundant — the host validates that `modelId` matches the
|
|
@@ -385,7 +386,7 @@ export interface BlockTextToImageParams {
|
|
|
385
386
|
* that model (DB lookup). The block always has both values from
|
|
386
387
|
* `useBlockContext().context as ModelSlotContext`.
|
|
387
388
|
*/
|
|
388
|
-
export type
|
|
389
|
+
export type WorkflowBodyTextToImage = {
|
|
389
390
|
kind: 'textToImage';
|
|
390
391
|
modelId: number;
|
|
391
392
|
modelVersionId: number;
|
|
@@ -433,6 +434,79 @@ export type WorkflowBody = {
|
|
|
433
434
|
accountType?: BuzzAccountType;
|
|
434
435
|
params: BlockTextToImageParams;
|
|
435
436
|
};
|
|
437
|
+
/**
|
|
438
|
+
* The `customComfy` member of the {@link WorkflowBody} discriminated union
|
|
439
|
+
* (`kind: 'customComfy'`) — runs a **server-registered, code-reviewed ComfyUI
|
|
440
|
+
* recipe** end-to-end. This is a bounded, fail-closed primitive: the iframe
|
|
441
|
+
* NEVER sends a Comfy graph. It sends only a registered `recipe` id plus a
|
|
442
|
+
* small, per-recipe-validated `params` object; the civitai server owns the
|
|
443
|
+
* entire graph (built by object construction, so the prompt is a leaf value
|
|
444
|
+
* that cannot perturb graph topology).
|
|
445
|
+
*
|
|
446
|
+
* Trust / safety model (all SERVER-ENFORCED — mirrors civitai's forthcoming
|
|
447
|
+
* `blockCustomComfyBodySchema`):
|
|
448
|
+
* - `recipe` is a **registered recipe id** resolved against a code-reviewed,
|
|
449
|
+
* in-repo recipe registry. An unknown id is **rejected server-side, fail-
|
|
450
|
+
* closed** (the schema enum is derived from the registry keys) — there is
|
|
451
|
+
* no way for a block to run an arbitrary/unreviewed graph.
|
|
452
|
+
* - `params` are **bounded and validated per-recipe** by the server's
|
|
453
|
+
* `.strict()` Zod param schema (extra fields rejected); each recipe pins
|
|
454
|
+
* its own resources (checkpoint/LoRA/diffusion AIRs) — the block cannot
|
|
455
|
+
* supply them.
|
|
456
|
+
*
|
|
457
|
+
* Billing is **post-paid** (the underlying orchestrator `customComfy` step
|
|
458
|
+
* bills measured GPU runtime at a fixed rate, so there is NO exact pre-price):
|
|
459
|
+
* - `estimate` returns a per-recipe **display estimate**, not a firm quote —
|
|
460
|
+
* surface it as an estimate; the actual cost is known only on terminal.
|
|
461
|
+
* - Each recipe declares a hard per-job `maxBuzz` ceiling backed by an
|
|
462
|
+
* aggressive step `timeout`; the orchestrator physically caps the job at
|
|
463
|
+
* that ceiling server-side (worst-case Buzz = the timeout in seconds), and
|
|
464
|
+
* the host gates `maxBuzz <= token.buzzBudget` before submit. A single job
|
|
465
|
+
* therefore cannot exceed the recipe's declared ceiling no matter what.
|
|
466
|
+
*/
|
|
467
|
+
export type WorkflowBodyCustomComfy = {
|
|
468
|
+
kind: 'customComfy';
|
|
469
|
+
/**
|
|
470
|
+
* A **registered recipe id** (e.g. `'seamless-pano-360'`). Resolved server-
|
|
471
|
+
* side against the code-reviewed recipe registry; an unknown id is rejected
|
|
472
|
+
* fail-closed. The recipe fixes the graph, the resource allowlist, the
|
|
473
|
+
* checkpoint policy, and the `maxBuzz`/`timeout` budget ceiling — none of
|
|
474
|
+
* which the block can influence beyond selecting the recipe + `params`.
|
|
475
|
+
*/
|
|
476
|
+
recipe: string;
|
|
477
|
+
/**
|
|
478
|
+
* Bounded, per-recipe-validated parameters. Only the fields a recipe's
|
|
479
|
+
* `.strict()` Zod schema accepts are honored; extra fields are rejected
|
|
480
|
+
* server-side. The common shape:
|
|
481
|
+
* - `prompt` — the generation prompt (a leaf string; injected into the
|
|
482
|
+
* server-built graph by object construction, never string-templated).
|
|
483
|
+
* - `seed` — optional; `null`/omitted lets the orchestrator pick.
|
|
484
|
+
* - `engine` — optional recipe engine-variant selector (e.g. a DiT engine);
|
|
485
|
+
* the recipe defaults it when omitted.
|
|
486
|
+
* - `accountType` — optional preferred Buzz pool (a preference, clamped
|
|
487
|
+
* server-side to pools the viewer actually holds; see {@link BuzzAccountType}).
|
|
488
|
+
*/
|
|
489
|
+
params: {
|
|
490
|
+
prompt: string;
|
|
491
|
+
seed?: number | null;
|
|
492
|
+
engine?: string;
|
|
493
|
+
accountType?: BuzzAccountType;
|
|
494
|
+
};
|
|
495
|
+
};
|
|
496
|
+
/**
|
|
497
|
+
* Body the block sends to `useBuzzWorkflow().{submit,estimate}`. A real
|
|
498
|
+
* discriminated union keyed by `kind`:
|
|
499
|
+
* - {@link WorkflowBodyTextToImage} (`kind: 'textToImage'`) — the original
|
|
500
|
+
* checkpoint/LoRA/img2img generation body (unchanged, back-compatible).
|
|
501
|
+
* - {@link WorkflowBodyCustomComfy} (`kind: 'customComfy'`) — a bounded,
|
|
502
|
+
* server-registered ComfyUI recipe (post-paid; the iframe never sends a
|
|
503
|
+
* graph).
|
|
504
|
+
*
|
|
505
|
+
* New kinds extend this union as the host gains support for them. Narrow on
|
|
506
|
+
* `body.kind` before touching member-specific fields (e.g. `modelId`/`params`
|
|
507
|
+
* live only on the `textToImage` member).
|
|
508
|
+
*/
|
|
509
|
+
export type WorkflowBody = WorkflowBodyTextToImage | WorkflowBodyCustomComfy;
|
|
436
510
|
/**
|
|
437
511
|
* The host-mediated view of an orchestrator workflow that an iframe block
|
|
438
512
|
* receives over `postMessage`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/blocks/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAMjD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,uBAAuB,GAAG,YAAY,GAAG,MAAM,CAAC;AAE5D;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,iBAAiB;IAChC;uDACmD;IACnD,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAA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AAG,SAAS,GAAG,UAAU,CAAC;IACnF,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,gBAAgB;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAMD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,eAAe,GACvB;IACE,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,SAAS,CAAC;IAClB,iDAAiD;IACjD,SAAS,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,aAAa,EAAE,aAAa,CAAC;IAC7B,8EAA8E;IAC9E,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,GACD;IACE,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,QAAQ,CAAC;CAClB,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@civitai/app-sdk/safe-storage` — survive an opaque-origin sandbox.
|
|
3
|
+
*
|
|
4
|
+
* Civitai Apps run in an iframe sandboxed as `allow-scripts allow-forms`,
|
|
5
|
+
* deliberately WITHOUT `allow-same-origin`. The document therefore has an
|
|
6
|
+
* **opaque origin**, and there is no origin to key web storage against, so the
|
|
7
|
+
* platform does not merely return an empty store — merely *reading* the
|
|
8
|
+
* property throws:
|
|
9
|
+
*
|
|
10
|
+
* SecurityError: Failed to read the 'localStorage' property from 'Window':
|
|
11
|
+
* The document is sandboxed and lacks the 'allow-same-origin' flag.
|
|
12
|
+
*
|
|
13
|
+
* Guarding your own call sites is not enough: any third-party dependency that
|
|
14
|
+
* touches storage unguarded takes the whole app down, and libraries routinely
|
|
15
|
+
* *mislabel* the failure. A real production example — Photo Sphere Viewer's
|
|
16
|
+
* `SYSTEM.load()` runs an unguarded ``TOUCH_KEY in localStorage`` touch probe,
|
|
17
|
+
* its `Viewer` constructor catches the resulting SecurityError, reports the
|
|
18
|
+
* generic "Your browser does not seem to support WebGL", and returns without
|
|
19
|
+
* rethrowing. The app's own fallback never ran and users with perfectly good
|
|
20
|
+
* GPUs saw a WebGL error. (The sandbox does not block WebGL — only storage.)
|
|
21
|
+
*
|
|
22
|
+
* So this module installs a spec-shaped in-memory `Storage` over any
|
|
23
|
+
* `localStorage`/`sessionStorage` that is present but unusable. Importing it
|
|
24
|
+
* runs the install (see the bottom of the file); it is also re-exported as a
|
|
25
|
+
* function for explicit use.
|
|
26
|
+
*
|
|
27
|
+
* The fallback is session-scoped — nothing survives a reload — which is the
|
|
28
|
+
* honest semantic at an opaque origin: there is no origin to persist against.
|
|
29
|
+
* Treat storage in a block as a cache, never a source of truth; the durable
|
|
30
|
+
* per-user store is the platform's app-storage API.
|
|
31
|
+
*/
|
|
32
|
+
/** Which globals a call to {@link installSafeStorage} actually replaced. */
|
|
33
|
+
export interface SafeStorageInstallResult {
|
|
34
|
+
/** `true` when `localStorage` was replaced by the in-memory fallback. */
|
|
35
|
+
localStorage: boolean;
|
|
36
|
+
/** `true` when `sessionStorage` was replaced by the in-memory fallback. */
|
|
37
|
+
sessionStorage: boolean;
|
|
38
|
+
}
|
|
39
|
+
declare const STORAGE_NAMES: readonly ["localStorage", "sessionStorage"];
|
|
40
|
+
/** The web-storage globals this module can repair. */
|
|
41
|
+
export type SafeStorageName = (typeof STORAGE_NAMES)[number];
|
|
42
|
+
/**
|
|
43
|
+
* A `Storage` work-alike backed by a `Map`.
|
|
44
|
+
*
|
|
45
|
+
* Implemented as a **Proxy, not a class**, because real `Storage` is an exotic
|
|
46
|
+
* object: `s.foo = 1`, `'foo' in s`, `s.foo` and `delete s.foo` are aliases for
|
|
47
|
+
* `setItem`/`getItem`/`removeItem`. Libraries use exactly that form (PSV's
|
|
48
|
+
* touch probe is literally ``KEY in localStorage`` then
|
|
49
|
+
* `localStorage[KEY] === 'true'`), so a plain class would still break them.
|
|
50
|
+
*/
|
|
51
|
+
export declare function createMemoryStorage(): Storage;
|
|
52
|
+
/**
|
|
53
|
+
* Replace any present-but-unusable `localStorage`/`sessionStorage` on `scope`
|
|
54
|
+
* with an in-memory `Storage`, so third-party code that touches it unguarded
|
|
55
|
+
* cannot throw.
|
|
56
|
+
*
|
|
57
|
+
* - **No-op where storage works.** A healthy `Storage` is never replaced, and
|
|
58
|
+
* its contents are never touched.
|
|
59
|
+
* - **No-op where storage is absent** (Node/SSR/workers). Nothing is invented.
|
|
60
|
+
* - **Never loses readable data.** When the old store reads but refuses writes
|
|
61
|
+
* (full / disabled), its entries are copied into the fallback first, so the
|
|
62
|
+
* shim cannot shadow a live session.
|
|
63
|
+
* - **Idempotent.** Once the fallback is installed the round-trip probe
|
|
64
|
+
* succeeds, so a second call is a no-op and values already written survive.
|
|
65
|
+
* - **Never throws.** Every step is guarded; a shim that could fail at import
|
|
66
|
+
* would be a worse outage than the bug it fixes.
|
|
67
|
+
*
|
|
68
|
+
* This module installs on import, so most apps never need to call it. Call it
|
|
69
|
+
* explicitly when you want the guarantee at a specific moment — e.g. right
|
|
70
|
+
* before `await import('some-lib')` that reads storage while evaluating.
|
|
71
|
+
*
|
|
72
|
+
* @param scope Object carrying the storage globals. Defaults to `globalThis`.
|
|
73
|
+
*/
|
|
74
|
+
export declare function installSafeStorage(scope?: object): SafeStorageInstallResult;
|
|
75
|
+
export {};
|
|
76
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/safe-storage/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,4EAA4E;AAC5E,MAAM,WAAW,wBAAwB;IACvC,yEAAyE;IACzE,YAAY,EAAE,OAAO,CAAC;IACtB,2EAA2E;IAC3E,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,QAAA,MAAM,aAAa,6CAA8C,CAAC;AAElE,sDAAsD;AACtD,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAI7D;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAiF7C;AAgKD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,GAAE,MAAmB,GAAG,wBAAwB,CAmCvF"}
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@civitai/app-sdk/safe-storage` — survive an opaque-origin sandbox.
|
|
3
|
+
*
|
|
4
|
+
* Civitai Apps run in an iframe sandboxed as `allow-scripts allow-forms`,
|
|
5
|
+
* deliberately WITHOUT `allow-same-origin`. The document therefore has an
|
|
6
|
+
* **opaque origin**, and there is no origin to key web storage against, so the
|
|
7
|
+
* platform does not merely return an empty store — merely *reading* the
|
|
8
|
+
* property throws:
|
|
9
|
+
*
|
|
10
|
+
* SecurityError: Failed to read the 'localStorage' property from 'Window':
|
|
11
|
+
* The document is sandboxed and lacks the 'allow-same-origin' flag.
|
|
12
|
+
*
|
|
13
|
+
* Guarding your own call sites is not enough: any third-party dependency that
|
|
14
|
+
* touches storage unguarded takes the whole app down, and libraries routinely
|
|
15
|
+
* *mislabel* the failure. A real production example — Photo Sphere Viewer's
|
|
16
|
+
* `SYSTEM.load()` runs an unguarded ``TOUCH_KEY in localStorage`` touch probe,
|
|
17
|
+
* its `Viewer` constructor catches the resulting SecurityError, reports the
|
|
18
|
+
* generic "Your browser does not seem to support WebGL", and returns without
|
|
19
|
+
* rethrowing. The app's own fallback never ran and users with perfectly good
|
|
20
|
+
* GPUs saw a WebGL error. (The sandbox does not block WebGL — only storage.)
|
|
21
|
+
*
|
|
22
|
+
* So this module installs a spec-shaped in-memory `Storage` over any
|
|
23
|
+
* `localStorage`/`sessionStorage` that is present but unusable. Importing it
|
|
24
|
+
* runs the install (see the bottom of the file); it is also re-exported as a
|
|
25
|
+
* function for explicit use.
|
|
26
|
+
*
|
|
27
|
+
* The fallback is session-scoped — nothing survives a reload — which is the
|
|
28
|
+
* honest semantic at an opaque origin: there is no origin to persist against.
|
|
29
|
+
* Treat storage in a block as a cache, never a source of truth; the durable
|
|
30
|
+
* per-user store is the platform's app-storage API.
|
|
31
|
+
*/
|
|
32
|
+
const STORAGE_NAMES = ['localStorage', 'sessionStorage'];
|
|
33
|
+
const PROBE_KEY = '__civitai_app_sdk_storage_probe__';
|
|
34
|
+
/**
|
|
35
|
+
* A `Storage` work-alike backed by a `Map`.
|
|
36
|
+
*
|
|
37
|
+
* Implemented as a **Proxy, not a class**, because real `Storage` is an exotic
|
|
38
|
+
* object: `s.foo = 1`, `'foo' in s`, `s.foo` and `delete s.foo` are aliases for
|
|
39
|
+
* `setItem`/`getItem`/`removeItem`. Libraries use exactly that form (PSV's
|
|
40
|
+
* touch probe is literally ``KEY in localStorage`` then
|
|
41
|
+
* `localStorage[KEY] === 'true'`), so a plain class would still break them.
|
|
42
|
+
*/
|
|
43
|
+
export function createMemoryStorage() {
|
|
44
|
+
const map = new Map();
|
|
45
|
+
const api = {
|
|
46
|
+
getItem(key) {
|
|
47
|
+
const k = String(key);
|
|
48
|
+
return map.has(k) ? map.get(k) : null;
|
|
49
|
+
},
|
|
50
|
+
setItem(key, value) {
|
|
51
|
+
map.set(String(key), String(value));
|
|
52
|
+
},
|
|
53
|
+
removeItem(key) {
|
|
54
|
+
map.delete(String(key));
|
|
55
|
+
},
|
|
56
|
+
clear() {
|
|
57
|
+
map.clear();
|
|
58
|
+
},
|
|
59
|
+
key(index) {
|
|
60
|
+
return Array.from(map.keys())[index] ?? null;
|
|
61
|
+
},
|
|
62
|
+
get length() {
|
|
63
|
+
return map.size;
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
// `Reflect.has` walks the prototype chain, so `'toString' in storage` stays
|
|
67
|
+
// true exactly as it is for a real Storage instance. Only keys that are NOT
|
|
68
|
+
// part of the Storage API fall through to the backing map.
|
|
69
|
+
const isApiKey = (prop) => typeof prop === 'symbol' || Reflect.has(api, prop);
|
|
70
|
+
return new Proxy(api, {
|
|
71
|
+
get(target, prop, receiver) {
|
|
72
|
+
if (isApiKey(prop))
|
|
73
|
+
return Reflect.get(target, prop, receiver);
|
|
74
|
+
return map.get(prop);
|
|
75
|
+
},
|
|
76
|
+
set(target, prop, value, receiver) {
|
|
77
|
+
if (isApiKey(prop))
|
|
78
|
+
return Reflect.set(target, prop, value, receiver);
|
|
79
|
+
map.set(prop, String(value));
|
|
80
|
+
return true;
|
|
81
|
+
},
|
|
82
|
+
has(_target, prop) {
|
|
83
|
+
return isApiKey(prop) || map.has(prop);
|
|
84
|
+
},
|
|
85
|
+
deleteProperty(_target, prop) {
|
|
86
|
+
// `delete storage.getItem` must NOT destroy the method, and
|
|
87
|
+
// `delete storage.length` must NOT leave `length` undefined — a
|
|
88
|
+
// `for (i < storage.length)` loop would then silently iterate zero
|
|
89
|
+
// times. Real `Storage` is unbothered: its API lives on
|
|
90
|
+
// `Storage.prototype`, so deleting it from the instance finds no own
|
|
91
|
+
// property, reports success and changes nothing. Mirror that exactly.
|
|
92
|
+
if (isApiKey(prop))
|
|
93
|
+
return true;
|
|
94
|
+
map.delete(prop);
|
|
95
|
+
return true;
|
|
96
|
+
},
|
|
97
|
+
// Enumeration sees only stored keys — matching real Storage, where
|
|
98
|
+
// `Object.keys(localStorage)` lists the entries, not the methods.
|
|
99
|
+
ownKeys() {
|
|
100
|
+
return Array.from(map.keys());
|
|
101
|
+
},
|
|
102
|
+
// A non-extensible target would make the `ownKeys` trap above violate a
|
|
103
|
+
// proxy invariant (it must then report every own key of the target), so a
|
|
104
|
+
// single `Object.freeze(localStorage)` — from a SES/`harden()` lockdown
|
|
105
|
+
// sweep, say — would make `Object.keys` / spread / `JSON.stringify` /
|
|
106
|
+
// `for...in` throw on this object FOREVER. Refusing keeps enumeration
|
|
107
|
+
// alive and matches the platform: `Storage` is a legacy platform object
|
|
108
|
+
// with a named-property handler, whose `[[PreventExtensions]]` also
|
|
109
|
+
// returns false.
|
|
110
|
+
preventExtensions: () => false,
|
|
111
|
+
getOwnPropertyDescriptor(target, prop) {
|
|
112
|
+
if (!isApiKey(prop) && map.has(prop)) {
|
|
113
|
+
return {
|
|
114
|
+
value: map.get(prop),
|
|
115
|
+
writable: true,
|
|
116
|
+
enumerable: true,
|
|
117
|
+
configurable: true,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
return Reflect.getOwnPropertyDescriptor(target, prop);
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Is `scope[name]` Node's *disabled* web-storage stub?
|
|
126
|
+
*
|
|
127
|
+
* Node >= 22 defines `globalThis.localStorage` / `sessionStorage` as lazy
|
|
128
|
+
* accessors. Without `--localstorage-file` they return `undefined` **and emit
|
|
129
|
+
* `ExperimentalWarning: localStorage is not available because
|
|
130
|
+
* --localstorage-file was not provided.` on every read** — so importing this
|
|
131
|
+
* module would print that on every server boot and in CI. `in` does not trip
|
|
132
|
+
* the warning, but it does report `true` there, so existence alone is not
|
|
133
|
+
* enough to skip the read.
|
|
134
|
+
*
|
|
135
|
+
* Both signals must agree, and anything ambiguous falls through to a real
|
|
136
|
+
* probe:
|
|
137
|
+
*
|
|
138
|
+
* 1. we are running on Node;
|
|
139
|
+
* 2. the property is an **own, non-enumerable accessor with a setter** —
|
|
140
|
+
* Node's replaceable global. The web platform can never match this:
|
|
141
|
+
* `Window.localStorage` is a WebIDL *readonly* attribute, so it is
|
|
142
|
+
* `enumerable: true` with `set: undefined`, in a sandbox exactly as much as
|
|
143
|
+
* anywhere else. That is a spec guarantee, not a guess, and it is why the
|
|
144
|
+
* check does not also test for `window` — happy-dom-style test
|
|
145
|
+
* environments expose a `window` while `globalThis.localStorage` is still
|
|
146
|
+
* Node's stub underneath.
|
|
147
|
+
*
|
|
148
|
+
* Skipping costs nothing either way. Without `--localstorage-file` the read
|
|
149
|
+
* would have returned `undefined` → `absent`, which is what we return; *with*
|
|
150
|
+
* it the storage works → `usable`, which is also a no-op.
|
|
151
|
+
*/
|
|
152
|
+
function isNodeWebStorageStub(scope, name) {
|
|
153
|
+
const runtime = globalThis;
|
|
154
|
+
if (typeof runtime.process?.versions?.node !== 'string')
|
|
155
|
+
return false;
|
|
156
|
+
const descriptor = Object.getOwnPropertyDescriptor(scope, name);
|
|
157
|
+
return (descriptor !== undefined &&
|
|
158
|
+
typeof descriptor.get === 'function' &&
|
|
159
|
+
typeof descriptor.set === 'function' &&
|
|
160
|
+
descriptor.enumerable === false);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Classify `scope[name]`.
|
|
164
|
+
*
|
|
165
|
+
* Reading the property can succeed while writing still throws (storage
|
|
166
|
+
* disabled, private-browsing quirks, quota exhausted), so probe a real
|
|
167
|
+
* round-trip rather than trusting the getter.
|
|
168
|
+
*
|
|
169
|
+
* `absent` is deliberately distinct from `broken`: a runtime with no web
|
|
170
|
+
* storage at all (Node/SSR, a worker) must be left alone. Inventing a
|
|
171
|
+
* `localStorage` there would flip isomorphic libraries onto their browser code
|
|
172
|
+
* path and cause a *different* class of bug than the one we are fixing.
|
|
173
|
+
*
|
|
174
|
+
* **Never throws.** `installSafeStorage()` runs at module scope, so an escaping
|
|
175
|
+
* error would reject `import '@civitai/app-sdk/blocks'` outright and take down
|
|
176
|
+
* every block that imports it — a worse failure than the one being fixed.
|
|
177
|
+
*/
|
|
178
|
+
function probe(scope, name) {
|
|
179
|
+
// `in` is the only safe existence check, and it has to come first.
|
|
180
|
+
//
|
|
181
|
+
// It runs [[HasProperty]], which does NOT invoke the getter — on an ordinary
|
|
182
|
+
// object (`globalThis` included) it runs no user code at all, so it cannot
|
|
183
|
+
// throw and cannot trip Node's stub (above).
|
|
184
|
+
//
|
|
185
|
+
// The conventional `typeof localStorage === 'undefined'` guard is NOT a
|
|
186
|
+
// substitute: inside a real opaque-origin sandbox `typeof localStorage`
|
|
187
|
+
// ALSO throws, because `typeof` on a member/global reference still resolves
|
|
188
|
+
// the property and runs the throwing getter — only `typeof` of an
|
|
189
|
+
// *undeclared identifier* is safe, and this identifier is declared.
|
|
190
|
+
// `'localStorage' in window` is the probe that survives there, and it
|
|
191
|
+
// correctly answers `true`: in the sandbox the global exists, it is merely
|
|
192
|
+
// unreadable. So the sandbox is classified `broken` below, never `absent`.
|
|
193
|
+
if (!(name in scope))
|
|
194
|
+
return { health: 'absent' };
|
|
195
|
+
if (isNodeWebStorageStub(scope, name))
|
|
196
|
+
return { health: 'absent' };
|
|
197
|
+
let storage;
|
|
198
|
+
try {
|
|
199
|
+
storage = scope[name];
|
|
200
|
+
}
|
|
201
|
+
catch {
|
|
202
|
+
// The opaque-origin case: the getter itself throws.
|
|
203
|
+
return { health: 'broken' };
|
|
204
|
+
}
|
|
205
|
+
if (storage === undefined || storage === null)
|
|
206
|
+
return { health: 'absent' };
|
|
207
|
+
// Everything below TOUCHES the object we were handed, and every one of those
|
|
208
|
+
// touches can throw — a revoked `Proxy` answers even a plain property read
|
|
209
|
+
// with a TypeError, and any exotic object can have a throwing getter. So the
|
|
210
|
+
// shape check lives inside the `try` alongside the round-trip probe rather
|
|
211
|
+
// than in front of it.
|
|
212
|
+
//
|
|
213
|
+
// A property read that throws is classified `broken`, not `usable`: every
|
|
214
|
+
// consumer's `localStorage.getItem(...)` would throw exactly the same way, so
|
|
215
|
+
// the global is unusable by definition — the same conclusion the throwing
|
|
216
|
+
// *getter* above already reaches. Leaving it in place would keep a provably
|
|
217
|
+
// lethal global on the page; replacing it cannot produce a false positive,
|
|
218
|
+
// because a healthy `Storage` never throws on method access.
|
|
219
|
+
try {
|
|
220
|
+
if (typeof storage.getItem !== 'function' || typeof storage.setItem !== 'function') {
|
|
221
|
+
return { health: 'broken', storage };
|
|
222
|
+
}
|
|
223
|
+
storage.setItem(PROBE_KEY, '1');
|
|
224
|
+
storage.removeItem(PROBE_KEY);
|
|
225
|
+
return { health: 'usable', storage };
|
|
226
|
+
}
|
|
227
|
+
catch {
|
|
228
|
+
return { health: 'broken', storage };
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Copy whatever `existing` still holds into `into`, best-effort.
|
|
233
|
+
*
|
|
234
|
+
* The write probe fails for two very different reasons. At an opaque origin
|
|
235
|
+
* there is nothing to read and nothing to preserve. But a *full* (or
|
|
236
|
+
* write-disabled) storage on an ordinary origin — historically the
|
|
237
|
+
* Safari-private-mode shape, and the likeliest real-world trigger — reads
|
|
238
|
+
* perfectly well: swapping a bare in-memory `Storage` over it would shadow
|
|
239
|
+
* live data, turning "can't save" into "the session is gone". So the fallback
|
|
240
|
+
* inherits the current entries first.
|
|
241
|
+
*
|
|
242
|
+
* Values written *after* the swap are session-scoped and lost on reload, the
|
|
243
|
+
* same as every other install path — the fallback never claims to persist.
|
|
244
|
+
*
|
|
245
|
+
* Reading the old store is itself unguarded territory (revoked proxies,
|
|
246
|
+
* throwing getters, an object that is not `Storage`-shaped at all), so the
|
|
247
|
+
* whole copy is best-effort: an empty fallback still beats a global that
|
|
248
|
+
* throws.
|
|
249
|
+
*/
|
|
250
|
+
function seedFrom(existing, into) {
|
|
251
|
+
try {
|
|
252
|
+
const size = existing.length;
|
|
253
|
+
if (typeof size !== 'number' || typeof existing.key !== 'function')
|
|
254
|
+
return;
|
|
255
|
+
if (typeof existing.getItem !== 'function')
|
|
256
|
+
return;
|
|
257
|
+
for (let index = 0; index < size; index += 1) {
|
|
258
|
+
const key = existing.key(index);
|
|
259
|
+
if (key === null || key === undefined || key === PROBE_KEY)
|
|
260
|
+
continue;
|
|
261
|
+
const value = existing.getItem(key);
|
|
262
|
+
if (value !== null && value !== undefined)
|
|
263
|
+
into.setItem(key, value);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
catch {
|
|
267
|
+
// Unreadable after all. Nothing to inherit; carry on with an empty store.
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Replace any present-but-unusable `localStorage`/`sessionStorage` on `scope`
|
|
272
|
+
* with an in-memory `Storage`, so third-party code that touches it unguarded
|
|
273
|
+
* cannot throw.
|
|
274
|
+
*
|
|
275
|
+
* - **No-op where storage works.** A healthy `Storage` is never replaced, and
|
|
276
|
+
* its contents are never touched.
|
|
277
|
+
* - **No-op where storage is absent** (Node/SSR/workers). Nothing is invented.
|
|
278
|
+
* - **Never loses readable data.** When the old store reads but refuses writes
|
|
279
|
+
* (full / disabled), its entries are copied into the fallback first, so the
|
|
280
|
+
* shim cannot shadow a live session.
|
|
281
|
+
* - **Idempotent.** Once the fallback is installed the round-trip probe
|
|
282
|
+
* succeeds, so a second call is a no-op and values already written survive.
|
|
283
|
+
* - **Never throws.** Every step is guarded; a shim that could fail at import
|
|
284
|
+
* would be a worse outage than the bug it fixes.
|
|
285
|
+
*
|
|
286
|
+
* This module installs on import, so most apps never need to call it. Call it
|
|
287
|
+
* explicitly when you want the guarantee at a specific moment — e.g. right
|
|
288
|
+
* before `await import('some-lib')` that reads storage while evaluating.
|
|
289
|
+
*
|
|
290
|
+
* @param scope Object carrying the storage globals. Defaults to `globalThis`.
|
|
291
|
+
*/
|
|
292
|
+
export function installSafeStorage(scope = globalThis) {
|
|
293
|
+
const result = { localStorage: false, sessionStorage: false };
|
|
294
|
+
for (const name of STORAGE_NAMES) {
|
|
295
|
+
const { health, storage } = probe(scope, name);
|
|
296
|
+
if (health !== 'broken')
|
|
297
|
+
continue;
|
|
298
|
+
// Inherit anything the old store still holds, so a storage that reads
|
|
299
|
+
// fine but refuses writes (full / disabled) does not lose its data behind
|
|
300
|
+
// the shim. Skipped at an opaque origin, where the read itself threw and
|
|
301
|
+
// there is nothing to inherit.
|
|
302
|
+
const fallback = createMemoryStorage();
|
|
303
|
+
if (storage)
|
|
304
|
+
seedFrom(storage, fallback);
|
|
305
|
+
try {
|
|
306
|
+
Object.defineProperty(scope, name, {
|
|
307
|
+
value: fallback,
|
|
308
|
+
// `configurable: true` on purpose — a consumer (or a second call) can
|
|
309
|
+
// still swap in its own store via `Object.defineProperty`.
|
|
310
|
+
configurable: true,
|
|
311
|
+
// `writable: false` matches the browser: `window.localStorage = x` is
|
|
312
|
+
// a no-op in sloppy mode and a TypeError in strict mode on the real
|
|
313
|
+
// thing, sandboxed or not. A writable shim would quietly accept that
|
|
314
|
+
// assignment and hand blocks a *different* behaviour from production.
|
|
315
|
+
writable: false,
|
|
316
|
+
enumerable: false,
|
|
317
|
+
});
|
|
318
|
+
result[name] = true;
|
|
319
|
+
}
|
|
320
|
+
catch {
|
|
321
|
+
// Non-configurable in this engine — nothing more we can do. Swallowing
|
|
322
|
+
// keeps a best-effort shim from becoming its own boot failure.
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return result;
|
|
326
|
+
}
|
|
327
|
+
// Install on import.
|
|
328
|
+
//
|
|
329
|
+
// Import order is the whole game: ES module imports are hoisted, so a
|
|
330
|
+
// *statement* can never run before a sibling `import` of a dependency that
|
|
331
|
+
// reads storage while evaluating. Only an import side effect can, which is why
|
|
332
|
+
// this is not opt-in — `@civitai/app-sdk/blocks` and `@civitai/blocks-react`
|
|
333
|
+
// import this module first, and an app can put
|
|
334
|
+
// `import '@civitai/app-sdk/safe-storage';` at the very top of its entry to be
|
|
335
|
+
// ahead of everything.
|
|
336
|
+
//
|
|
337
|
+
// The blast radius is bounded by the rules above: it only ever replaces a
|
|
338
|
+
// global that is already *provably* unusable, so in every healthy runtime this
|
|
339
|
+
// is a couple of `setItem`/`removeItem` calls and nothing else.
|
|
340
|
+
installSafeStorage();
|
|
341
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/safe-storage/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAUH,MAAM,aAAa,GAAG,CAAC,cAAc,EAAE,gBAAgB,CAAU,CAAC;AAKlE,MAAM,SAAS,G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AI;gBAClB,sEAAsE;gBACtE,oEAAoE;gBACpE,qEAAqE;gBACrE,sEAAsE;gBACtE,QAAQ,EAAE,KAAK;gBACf,UAAU,EAAE,KAAK;aAClB,CAAC,CAAC;YACH,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QACtB,CAAC;QAAC,MAAM,CAAC;YACP,uEAAuE;YACvE,+DAA+D;QACjE,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,qBAAqB;AACrB,EAAE;AACF,sEAAsE;AACtE,2EAA2E;AAC3E,+EAA+E;AAC/E,6EAA6E;AAC7E,+CAA+C;AAC/C,+EAA+E;AAC/E,uBAAuB;AACvB,EAAE;AACF,0EAA0E;AAC1E,+EAA+E;AAC/E,gEAAgE;AAChE,kBAAkB,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@civitai/app-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.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",
|
|
7
7
|
"main": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
|
+
"sideEffects": [
|
|
10
|
+
"./dist/safe-storage/index.js",
|
|
11
|
+
"./dist/blocks/index.js"
|
|
12
|
+
],
|
|
9
13
|
"exports": {
|
|
10
14
|
".": {
|
|
11
15
|
"types": "./dist/index.d.ts",
|
|
@@ -31,6 +35,10 @@
|
|
|
31
35
|
"types": "./dist/blocks/index.d.ts",
|
|
32
36
|
"import": "./dist/blocks/index.js"
|
|
33
37
|
},
|
|
38
|
+
"./safe-storage": {
|
|
39
|
+
"types": "./dist/safe-storage/index.d.ts",
|
|
40
|
+
"import": "./dist/safe-storage/index.js"
|
|
41
|
+
},
|
|
34
42
|
"./schemas/app-block/v1.json": "./schemas/app-block/v1.json"
|
|
35
43
|
},
|
|
36
44
|
"files": [
|
|
@@ -69,12 +69,9 @@
|
|
|
69
69
|
"type": "string",
|
|
70
70
|
"enum": [
|
|
71
71
|
"models:read:self",
|
|
72
|
-
"media:read:owned",
|
|
73
72
|
"user:read:self",
|
|
74
73
|
"ai:write:budgeted",
|
|
75
74
|
"buzz:read:self",
|
|
76
|
-
"block:settings:read",
|
|
77
|
-
"block:settings:write",
|
|
78
75
|
"social:tip:self",
|
|
79
76
|
"apps:storage:read",
|
|
80
77
|
"apps:storage:write",
|