@civitai/blocks-react 0.19.0 → 0.21.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 +23 -0
- package/dist/api/generationResources.d.ts +62 -0
- package/dist/api/generationResources.d.ts.map +1 -0
- package/dist/api/generationResources.js +89 -0
- package/dist/api/generationResources.js.map +1 -0
- package/dist/hooks/useGenerationResources.d.ts +27 -0
- package/dist/hooks/useGenerationResources.d.ts.map +1 -0
- package/dist/hooks/useGenerationResources.js +46 -0
- package/dist/hooks/useGenerationResources.js.map +1 -0
- package/dist/hooks/useHostOrigin.d.ts +34 -0
- package/dist/hooks/useHostOrigin.d.ts.map +1 -0
- package/dist/hooks/useHostOrigin.js +44 -0
- package/dist/hooks/useHostOrigin.js.map +1 -0
- package/dist/hooks/useImageUpload.d.ts +30 -0
- package/dist/hooks/useImageUpload.d.ts.map +1 -0
- package/dist/hooks/useImageUpload.js +39 -0
- package/dist/hooks/useImageUpload.js.map +1 -0
- package/dist/hooks/useSharedStorage.d.ts +10 -6
- package/dist/hooks/useSharedStorage.d.ts.map +1 -1
- package/dist/hooks/useSharedStorage.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/iframeTransport.d.ts +18 -0
- package/dist/internal/iframeTransport.d.ts.map +1 -1
- package/dist/internal/iframeTransport.js +20 -0
- package/dist/internal/iframeTransport.js.map +1 -1
- package/dist/internal/inlineTransport.d.ts +7 -0
- package/dist/internal/inlineTransport.d.ts.map +1 -1
- package/dist/internal/inlineTransport.js +22 -1
- package/dist/internal/inlineTransport.js.map +1 -1
- package/dist/internal/mockHost.d.ts +9 -2
- package/dist/internal/mockHost.d.ts.map +1 -1
- package/dist/internal/mockHost.js +49 -1
- package/dist/internal/mockHost.js.map +1 -1
- package/dist/internal/transport.d.ts +16 -0
- package/dist/internal/transport.d.ts.map +1 -1
- package/dist/internal/transport.js.map +1 -1
- package/dist/internal/validate.d.ts +18 -0
- package/dist/internal/validate.d.ts.map +1 -1
- package/dist/internal/validate.js +34 -0
- package/dist/internal/validate.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -113,6 +113,29 @@ const { raw, scopes, expiresAt, buzzBudget, refresh } = useBlockToken();
|
|
|
113
113
|
// after a 401: await refresh(); then retry the request once with the new `raw`.
|
|
114
114
|
```
|
|
115
115
|
|
|
116
|
+
### `useHostOrigin()`
|
|
117
|
+
|
|
118
|
+
The validated host origin to direct-fetch the App Blocks HTTP API against —
|
|
119
|
+
`undefined` until init. Use it as the base URL when you need to bypass the host
|
|
120
|
+
bridge, always paired with the bearer token from `useBlockToken()`.
|
|
121
|
+
|
|
122
|
+
```tsx
|
|
123
|
+
const host = useHostOrigin(); // e.g. "https://civitai.com" (undefined until BLOCK_INIT)
|
|
124
|
+
const { raw } = useBlockToken();
|
|
125
|
+
// Once `host` is set, fetch the API on that validated origin with the block token:
|
|
126
|
+
if (host) {
|
|
127
|
+
const res = await fetch(`${host}/api/v1/blocks/me`, {
|
|
128
|
+
headers: { authorization: `Bearer ${raw}` },
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
> **Security:** this is ONLY ever the origin that passed the SDK's origin
|
|
134
|
+
> allowlist (the same gate `BLOCK_INIT` passes) — never `document.referrer` or
|
|
135
|
+
> `window.location` of the parent. The block token is a money-scoped bearer
|
|
136
|
+
> credential, so always send it to *this* origin. Never derive the API host
|
|
137
|
+
> from a spoofable browser signal.
|
|
138
|
+
|
|
116
139
|
### `useBlockSettings()`
|
|
117
140
|
|
|
118
141
|
Shorthand for `useBlockContext().settings`. Read-only from the iframe — settings
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* REST client for `GET /api/v1/blocks/generation-resources` — the block-token-
|
|
3
|
+
* gated REHYDRATE of generation resources by version id (App Blocks Phase-2a
|
|
4
|
+
* PR-C). When a block loads a saved set of resources it holds only the picked
|
|
5
|
+
* modelVersionIds; this endpoint returns the SAME public "safe subset" the
|
|
6
|
+
* `OPEN_RESOURCE_PICKER` result carries (`projectSafeGenerationResource` on the
|
|
7
|
+
* host), WITHOUT re-opening the picker. It never returns availability /
|
|
8
|
+
* hasAccess / early-access / usageControl / minor / poi / sfwOnly / cover-image
|
|
9
|
+
* internals — only the public recommended settings + trained words a block
|
|
10
|
+
* renders (strength + min/max clamp, trigger words, clipSkip, names).
|
|
11
|
+
*
|
|
12
|
+
* MONEY-SAFETY: the returned data is DISCOVERY ONLY. Every `versionId` is a
|
|
13
|
+
* HINT, never an entitlement — the server re-validates AND re-prices at
|
|
14
|
+
* estimate/submit. The maturity ceiling is AUTHORITATIVELY CLAMPED server-side
|
|
15
|
+
* to the block token's signed `maxBrowsingLevel`; the client sends no maturity.
|
|
16
|
+
*
|
|
17
|
+
* The URL/param builder + response mapper are PURE + node-testable (mirrors the
|
|
18
|
+
* `internal/catalog.ts` pure-builder split); {@link useGenerationResources}
|
|
19
|
+
* layers the React `useHostOrigin()` + bearer-token fetch on top.
|
|
20
|
+
*/
|
|
21
|
+
import type { BlockResourceInfo } from '@civitai/app-sdk/blocks';
|
|
22
|
+
/** The block-token-gated generation-resources rehydrate base. */
|
|
23
|
+
export declare const GENERATION_RESOURCES_API_BASE = "/api/v1/blocks/generation-resources";
|
|
24
|
+
/** Server cap on the number of ids per request (mirrors the endpoint's `MAX_IDS`). */
|
|
25
|
+
export declare const MAX_GENERATION_RESOURCE_IDS = 30;
|
|
26
|
+
/**
|
|
27
|
+
* Build the rehydrate URL for a set of version ids: `?ids=csv`. Ids are
|
|
28
|
+
* sanitized + capped at {@link MAX_GENERATION_RESOURCE_IDS} (extra/junk ids are
|
|
29
|
+
* dropped rather than sent, so the request never 400s on the server's cap).
|
|
30
|
+
* Pure + deterministic. `base` defaults to {@link GENERATION_RESOURCES_API_BASE}.
|
|
31
|
+
*/
|
|
32
|
+
export declare function buildGenerationResourcesUrl(versionIds: number[], base?: string): string;
|
|
33
|
+
interface RawGenerationResource {
|
|
34
|
+
versionId?: number;
|
|
35
|
+
modelId?: number;
|
|
36
|
+
modelName?: string;
|
|
37
|
+
versionName?: string;
|
|
38
|
+
baseModel?: string;
|
|
39
|
+
modelType?: string;
|
|
40
|
+
strength?: number;
|
|
41
|
+
minStrength?: number;
|
|
42
|
+
maxStrength?: number;
|
|
43
|
+
trainedWords?: string[];
|
|
44
|
+
clipSkip?: number | null;
|
|
45
|
+
}
|
|
46
|
+
interface RawGenerationResourcesResponse {
|
|
47
|
+
items?: RawGenerationResource[];
|
|
48
|
+
maturity?: {
|
|
49
|
+
browsingLevel?: number;
|
|
50
|
+
sfwOnly?: boolean;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Map a raw `{ items: [...] }` response → the widened {@link BlockResourceInfo}[]
|
|
55
|
+
* a block consumes. Skips any row without a usable `versionId`. Carries the
|
|
56
|
+
* public recommended settings (strength + clamp, trained words, clipSkip)
|
|
57
|
+
* through unchanged — the host already applied its defaults in
|
|
58
|
+
* `projectSafeGenerationResource`. Never throws.
|
|
59
|
+
*/
|
|
60
|
+
export declare function responseToResources(raw: RawGenerationResourcesResponse | null | undefined): BlockResourceInfo[];
|
|
61
|
+
export {};
|
|
62
|
+
//# sourceMappingURL=generationResources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generationResources.d.ts","sourceRoot":"","sources":["../../src/api/generationResources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,iEAAiE;AACjE,eAAO,MAAM,6BAA6B,wCAAwC,CAAC;AAEnF,sFAAsF;AACtF,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAoB9C;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,MAAM,EAAE,EACpB,IAAI,GAAE,MAAsC,GAC3C,MAAM,CAKR;AAOD,UAAU,qBAAqB;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,UAAU,8BAA8B;IACtC,KAAK,CAAC,EAAE,qBAAqB,EAAE,CAAC;IAChC,QAAQ,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CAC1D;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,8BAA8B,GAAG,IAAI,GAAG,SAAS,GACrD,iBAAiB,EAAE,CAsBrB"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* REST client for `GET /api/v1/blocks/generation-resources` — the block-token-
|
|
3
|
+
* gated REHYDRATE of generation resources by version id (App Blocks Phase-2a
|
|
4
|
+
* PR-C). When a block loads a saved set of resources it holds only the picked
|
|
5
|
+
* modelVersionIds; this endpoint returns the SAME public "safe subset" the
|
|
6
|
+
* `OPEN_RESOURCE_PICKER` result carries (`projectSafeGenerationResource` on the
|
|
7
|
+
* host), WITHOUT re-opening the picker. It never returns availability /
|
|
8
|
+
* hasAccess / early-access / usageControl / minor / poi / sfwOnly / cover-image
|
|
9
|
+
* internals — only the public recommended settings + trained words a block
|
|
10
|
+
* renders (strength + min/max clamp, trigger words, clipSkip, names).
|
|
11
|
+
*
|
|
12
|
+
* MONEY-SAFETY: the returned data is DISCOVERY ONLY. Every `versionId` is a
|
|
13
|
+
* HINT, never an entitlement — the server re-validates AND re-prices at
|
|
14
|
+
* estimate/submit. The maturity ceiling is AUTHORITATIVELY CLAMPED server-side
|
|
15
|
+
* to the block token's signed `maxBrowsingLevel`; the client sends no maturity.
|
|
16
|
+
*
|
|
17
|
+
* The URL/param builder + response mapper are PURE + node-testable (mirrors the
|
|
18
|
+
* `internal/catalog.ts` pure-builder split); {@link useGenerationResources}
|
|
19
|
+
* layers the React `useHostOrigin()` + bearer-token fetch on top.
|
|
20
|
+
*/
|
|
21
|
+
/** The block-token-gated generation-resources rehydrate base. */
|
|
22
|
+
export const GENERATION_RESOURCES_API_BASE = '/api/v1/blocks/generation-resources';
|
|
23
|
+
/** Server cap on the number of ids per request (mirrors the endpoint's `MAX_IDS`). */
|
|
24
|
+
export const MAX_GENERATION_RESOURCE_IDS = 30;
|
|
25
|
+
/**
|
|
26
|
+
* Sanitize a list of version ids the way the server's zod schema does: keep only
|
|
27
|
+
* positive integers, de-dupe (preserving first-seen order), and cap the count at
|
|
28
|
+
* {@link MAX_GENERATION_RESOURCE_IDS}. Pure + total.
|
|
29
|
+
*/
|
|
30
|
+
function sanitizeIds(versionIds) {
|
|
31
|
+
const seen = new Set();
|
|
32
|
+
const out = [];
|
|
33
|
+
for (const n of versionIds) {
|
|
34
|
+
if (!Number.isInteger(n) || n <= 0)
|
|
35
|
+
continue;
|
|
36
|
+
if (seen.has(n))
|
|
37
|
+
continue;
|
|
38
|
+
seen.add(n);
|
|
39
|
+
out.push(n);
|
|
40
|
+
if (out.length >= MAX_GENERATION_RESOURCE_IDS)
|
|
41
|
+
break; // enforce the ≤30 cap
|
|
42
|
+
}
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Build the rehydrate URL for a set of version ids: `?ids=csv`. Ids are
|
|
47
|
+
* sanitized + capped at {@link MAX_GENERATION_RESOURCE_IDS} (extra/junk ids are
|
|
48
|
+
* dropped rather than sent, so the request never 400s on the server's cap).
|
|
49
|
+
* Pure + deterministic. `base` defaults to {@link GENERATION_RESOURCES_API_BASE}.
|
|
50
|
+
*/
|
|
51
|
+
export function buildGenerationResourcesUrl(versionIds, base = GENERATION_RESOURCES_API_BASE) {
|
|
52
|
+
const ids = sanitizeIds(versionIds);
|
|
53
|
+
const params = new URLSearchParams();
|
|
54
|
+
params.set('ids', ids.join(','));
|
|
55
|
+
return `${base}?${params.toString()}`;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Map a raw `{ items: [...] }` response → the widened {@link BlockResourceInfo}[]
|
|
59
|
+
* a block consumes. Skips any row without a usable `versionId`. Carries the
|
|
60
|
+
* public recommended settings (strength + clamp, trained words, clipSkip)
|
|
61
|
+
* through unchanged — the host already applied its defaults in
|
|
62
|
+
* `projectSafeGenerationResource`. Never throws.
|
|
63
|
+
*/
|
|
64
|
+
export function responseToResources(raw) {
|
|
65
|
+
const items = Array.isArray(raw?.items) ? raw.items : [];
|
|
66
|
+
const out = [];
|
|
67
|
+
for (const r of items) {
|
|
68
|
+
if (!r || typeof r !== 'object')
|
|
69
|
+
continue;
|
|
70
|
+
const versionId = r.versionId;
|
|
71
|
+
if (typeof versionId !== 'number' || !Number.isFinite(versionId))
|
|
72
|
+
continue;
|
|
73
|
+
out.push({
|
|
74
|
+
versionId,
|
|
75
|
+
modelId: typeof r.modelId === 'number' ? r.modelId : 0,
|
|
76
|
+
modelName: typeof r.modelName === 'string' ? r.modelName : '',
|
|
77
|
+
versionName: typeof r.versionName === 'string' ? r.versionName : '',
|
|
78
|
+
baseModel: typeof r.baseModel === 'string' ? r.baseModel : '',
|
|
79
|
+
modelType: typeof r.modelType === 'string' ? r.modelType : '',
|
|
80
|
+
...(typeof r.strength === 'number' ? { strength: r.strength } : {}),
|
|
81
|
+
...(typeof r.minStrength === 'number' ? { minStrength: r.minStrength } : {}),
|
|
82
|
+
...(typeof r.maxStrength === 'number' ? { maxStrength: r.maxStrength } : {}),
|
|
83
|
+
...(Array.isArray(r.trainedWords) ? { trainedWords: r.trainedWords } : {}),
|
|
84
|
+
...(r.clipSkip === null || typeof r.clipSkip === 'number' ? { clipSkip: r.clipSkip } : {}),
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return out;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=generationResources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generationResources.js","sourceRoot":"","sources":["../../src/api/generationResources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,iEAAiE;AACjE,MAAM,CAAC,MAAM,6BAA6B,GAAG,qCAAqC,CAAC;AAEnF,sFAAsF;AACtF,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,CAAC;AAE9C;;;;GAIG;AACH,SAAS,WAAW,CAAC,UAAoB;IACvC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC;QAC3B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,SAAS;QAC7C,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YAAE,SAAS;QAC1B,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACZ,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACZ,IAAI,GAAG,CAAC,MAAM,IAAI,2BAA2B;YAAE,MAAM,CAAC,sBAAsB;IAC9E,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CACzC,UAAoB,EACpB,OAAe,6BAA6B;IAE5C,MAAM,GAAG,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S,CAAC,CAAC,CAAC,EAAE;YAC7D,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE;YAC7D,GAAG,CAAC,OAAO,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACnE,GAAG,CAAC,OAAO,CAAC,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5E,GAAG,CAAC,OAAO,CAAC,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5E,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC1E,GAAG,CAAC,CAAC,CAAC,QAAQ,KAAK,IAAI,IAAI,OAAO,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC3F,CAAC,CAAC;IACL,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { BlockResourceInfo } from '@civitai/app-sdk/blocks';
|
|
2
|
+
/**
|
|
3
|
+
* Rehydrate a saved set of generation resources by version id, WITHOUT
|
|
4
|
+
* re-opening the resource picker. `fetch(versionIds)` GETs the block-token-gated
|
|
5
|
+
* `/api/v1/blocks/generation-resources` endpoint and returns the SAME widened
|
|
6
|
+
* {@link BlockResourceInfo} projection `useResourcePicker()` yields (public
|
|
7
|
+
* recommended settings — strength + min/max clamp, trained words, clipSkip — plus
|
|
8
|
+
* names), so a picked resource and a rehydrated one look identical to the block.
|
|
9
|
+
*
|
|
10
|
+
* Direct-fetch (bypasses the postMessage bridge) against the VALIDATED host
|
|
11
|
+
* origin (`useHostOrigin()`) with the block bearer token (`useBlockToken().raw`)
|
|
12
|
+
* — the same security-reviewed pattern as any block REST call. The maturity
|
|
13
|
+
* ceiling is server-clamped to the token's signed `maxBrowsingLevel`; the client
|
|
14
|
+
* sends no maturity. Ids are sanitized + capped at 30 by the URL builder.
|
|
15
|
+
*
|
|
16
|
+
* DISCOVERY ONLY: every returned `versionId` is a hint, never an entitlement —
|
|
17
|
+
* the server re-validates + re-prices at estimate/submit.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* const { fetch } = useGenerationResources();
|
|
21
|
+
* const resources = await fetch([691639, 666002]); // by saved versionIds
|
|
22
|
+
* // resources[0].strength / .minStrength / .maxStrength / .trainedWords / .clipSkip
|
|
23
|
+
*/
|
|
24
|
+
export declare function useGenerationResources(): {
|
|
25
|
+
fetch: (versionIds: number[]) => Promise<BlockResourceInfo[]>;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=useGenerationResources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGenerationResources.d.ts","sourceRoot":"","sources":["../../src/hooks/useGenerationResources.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AASjE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,sBAAsB,IAAI;IACxC,KAAK,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC;CAC/D,CAyBA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { buildGenerationResourcesUrl, responseToResources, } from '../api/generationResources.js';
|
|
3
|
+
import { useHostOrigin } from './useHostOrigin.js';
|
|
4
|
+
import { useBlockToken } from './useBlockToken.js';
|
|
5
|
+
/**
|
|
6
|
+
* Rehydrate a saved set of generation resources by version id, WITHOUT
|
|
7
|
+
* re-opening the resource picker. `fetch(versionIds)` GETs the block-token-gated
|
|
8
|
+
* `/api/v1/blocks/generation-resources` endpoint and returns the SAME widened
|
|
9
|
+
* {@link BlockResourceInfo} projection `useResourcePicker()` yields (public
|
|
10
|
+
* recommended settings — strength + min/max clamp, trained words, clipSkip — plus
|
|
11
|
+
* names), so a picked resource and a rehydrated one look identical to the block.
|
|
12
|
+
*
|
|
13
|
+
* Direct-fetch (bypasses the postMessage bridge) against the VALIDATED host
|
|
14
|
+
* origin (`useHostOrigin()`) with the block bearer token (`useBlockToken().raw`)
|
|
15
|
+
* — the same security-reviewed pattern as any block REST call. The maturity
|
|
16
|
+
* ceiling is server-clamped to the token's signed `maxBrowsingLevel`; the client
|
|
17
|
+
* sends no maturity. Ids are sanitized + capped at 30 by the URL builder.
|
|
18
|
+
*
|
|
19
|
+
* DISCOVERY ONLY: every returned `versionId` is a hint, never an entitlement —
|
|
20
|
+
* the server re-validates + re-prices at estimate/submit.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* const { fetch } = useGenerationResources();
|
|
24
|
+
* const resources = await fetch([691639, 666002]); // by saved versionIds
|
|
25
|
+
* // resources[0].strength / .minStrength / .maxStrength / .trainedWords / .clipSkip
|
|
26
|
+
*/
|
|
27
|
+
export function useGenerationResources() {
|
|
28
|
+
const host = useHostOrigin();
|
|
29
|
+
const { raw } = useBlockToken();
|
|
30
|
+
const doFetch = useCallback(async (versionIds) => {
|
|
31
|
+
if (!host) {
|
|
32
|
+
throw new Error('useGenerationResources: host origin not established yet (wait for BLOCK_INIT).');
|
|
33
|
+
}
|
|
34
|
+
const url = host + buildGenerationResourcesUrl(versionIds);
|
|
35
|
+
const res = await fetch(url, {
|
|
36
|
+
headers: { Authorization: `Bearer ${raw}` },
|
|
37
|
+
});
|
|
38
|
+
if (!res.ok) {
|
|
39
|
+
throw new Error(`generation-resources request failed (${res.status})`);
|
|
40
|
+
}
|
|
41
|
+
const body = (await res.json());
|
|
42
|
+
return responseToResources(body);
|
|
43
|
+
}, [host, raw]);
|
|
44
|
+
return { fetch: doFetch };
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=useGenerationResources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGenerationResources.js","sourceRoot":"","sources":["../../src/hooks/useGenerationResources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAIpC,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,GACpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,sBAAsB;IAGpC,MAAM,IAAI,GAAG,aAAa,EAAE,CAAC;IAC7B,MAAM,EAAE,GAAG,EAAE,GAAG,aAAa,EAAE,CAAC;IAEhC,MAAM,OAAO,GAAG,WAAW,CACzB,KAAK,EAAE,UAAoB,EAAgC,EAAE;QAC3D,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CACb,gFAAgF,CACjF,CAAC;QACJ,CAAC;QACD,MAAM,GAAG,GAAG,IAAI,GAAG,2BAA2B,CAAC,UAAU,CAAC,CAAC;QAC3D,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;YAC3B,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,GAAG,EAAE,EAAE;SAC5C,CAAC,CAAC;QACH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,wCAAwC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;QACzE,CAAC;QACD,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAY,CAAC;QAC3C,OAAO,mBAAmB,CAAC,IAAiD,CAAC,CAAC;IAChF,CAAC,EACD,CAAC,IAAI,EAAE,GAAG,CAAC,CACZ,CAAC;IAEF,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the validated host (parent) origin the block may safely direct-fetch
|
|
3
|
+
* the civitai App Blocks HTTP API against — `undefined` until the transport
|
|
4
|
+
* has established it (iframe: the first allowlist-passing `BLOCK_INIT`;
|
|
5
|
+
* inline: bootstrap present).
|
|
6
|
+
*
|
|
7
|
+
* Use this as the base URL for a direct `fetch` to the App Blocks API when you
|
|
8
|
+
* need to bypass the host bridge — always paired with the bearer token from
|
|
9
|
+
* `useBlockToken()`:
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const host = useHostOrigin();
|
|
13
|
+
* const { raw } = useBlockToken();
|
|
14
|
+
* if (!host) return null; // not initialized yet
|
|
15
|
+
* const res = await fetch(`${host}/api/v1/blocks/me`, {
|
|
16
|
+
* headers: { authorization: `Bearer ${raw}` },
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* SECURITY INVARIANT — the whole reason this hook exists: the value it returns
|
|
20
|
+
* is ONLY ever an origin that passed the transport's trust gate (the iframe
|
|
21
|
+
* `OriginMatcher` allowlist, or the inline same-origin host). It is NEVER
|
|
22
|
+
* derived from `document.referrer`, `window.location` of a cross-origin
|
|
23
|
+
* parent, or any unvalidated `event.origin`. `useBlockToken().raw` is a
|
|
24
|
+
* money-scoped bearer credential, so sending it to an unvalidated origin would
|
|
25
|
+
* be a token-exfiltration vector — always send the token to THIS origin, never
|
|
26
|
+
* to a host you read off a spoofable browser signal.
|
|
27
|
+
*
|
|
28
|
+
* Built on the same `useSyncExternalStore` subscription as `useBlockToken` /
|
|
29
|
+
* `useBlockContext`: the iframe transport captures the origin and emits in the
|
|
30
|
+
* same tick it applies `BLOCK_INIT`, so the hook re-renders with the origin the
|
|
31
|
+
* moment init lands.
|
|
32
|
+
*/
|
|
33
|
+
export declare function useHostOrigin(): string | undefined;
|
|
34
|
+
//# sourceMappingURL=useHostOrigin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHostOrigin.d.ts","sourceRoot":"","sources":["../../src/hooks/useHostOrigin.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,aAAa,IAAI,MAAM,GAAG,SAAS,CAWlD"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useSyncExternalStore } from 'react';
|
|
2
|
+
import { getTransport } from '../internal/singleton.js';
|
|
3
|
+
/**
|
|
4
|
+
* Returns the validated host (parent) origin the block may safely direct-fetch
|
|
5
|
+
* the civitai App Blocks HTTP API against — `undefined` until the transport
|
|
6
|
+
* has established it (iframe: the first allowlist-passing `BLOCK_INIT`;
|
|
7
|
+
* inline: bootstrap present).
|
|
8
|
+
*
|
|
9
|
+
* Use this as the base URL for a direct `fetch` to the App Blocks API when you
|
|
10
|
+
* need to bypass the host bridge — always paired with the bearer token from
|
|
11
|
+
* `useBlockToken()`:
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const host = useHostOrigin();
|
|
15
|
+
* const { raw } = useBlockToken();
|
|
16
|
+
* if (!host) return null; // not initialized yet
|
|
17
|
+
* const res = await fetch(`${host}/api/v1/blocks/me`, {
|
|
18
|
+
* headers: { authorization: `Bearer ${raw}` },
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* SECURITY INVARIANT — the whole reason this hook exists: the value it returns
|
|
22
|
+
* is ONLY ever an origin that passed the transport's trust gate (the iframe
|
|
23
|
+
* `OriginMatcher` allowlist, or the inline same-origin host). It is NEVER
|
|
24
|
+
* derived from `document.referrer`, `window.location` of a cross-origin
|
|
25
|
+
* parent, or any unvalidated `event.origin`. `useBlockToken().raw` is a
|
|
26
|
+
* money-scoped bearer credential, so sending it to an unvalidated origin would
|
|
27
|
+
* be a token-exfiltration vector — always send the token to THIS origin, never
|
|
28
|
+
* to a host you read off a spoofable browser signal.
|
|
29
|
+
*
|
|
30
|
+
* Built on the same `useSyncExternalStore` subscription as `useBlockToken` /
|
|
31
|
+
* `useBlockContext`: the iframe transport captures the origin and emits in the
|
|
32
|
+
* same tick it applies `BLOCK_INIT`, so the hook re-renders with the origin the
|
|
33
|
+
* moment init lands.
|
|
34
|
+
*/
|
|
35
|
+
export function useHostOrigin() {
|
|
36
|
+
const transport = getTransport();
|
|
37
|
+
const origin = useSyncExternalStore((cb) => transport.subscribe(cb), () => transport.getHostOrigin(),
|
|
38
|
+
// Server snapshot: no host origin is known before hydration.
|
|
39
|
+
() => transport.getHostOrigin());
|
|
40
|
+
// Normalize the transport's `null` sentinel to `undefined` for the hook's
|
|
41
|
+
// "not yet available" contract (mirrors the optional-field hook convention).
|
|
42
|
+
return origin ?? undefined;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=useHostOrigin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHostOrigin.js","sourceRoot":"","sources":["../../src/hooks/useHostOrigin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IACjC,MAAM,MAAM,GAAG,oBAAoB,CACjC,CAAC,EAAE,EAAE,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,EAC/B,GAAG,EAAE,CAAC,SAAS,CAAC,aAAa,EAAE;IAC/B,6DAA6D;IAC7D,GAAG,EAAE,CAAC,SAAS,CAAC,aAAa,EAAE,CAChC,CAAC;IACF,0EAA0E;IAC1E,6EAA6E;IAC7E,OAAO,MAAM,IAAI,SAAS,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { BlockUploadedImageInfo } from '@civitai/app-sdk/blocks';
|
|
2
|
+
/**
|
|
3
|
+
* Drives the platform-side image-upload flow for App Blocks (Design 1 —
|
|
4
|
+
* host-chrome). Mirrors {@link useResourcePicker}: `open` asks the host to open
|
|
5
|
+
* its OWN native upload modal; the iframe never handles the bytes. The upload
|
|
6
|
+
* routes through civitai's session-authed scan pipeline (real `createImage` +
|
|
7
|
+
* `ingestImage`) and a hard SFW + no-moderation-flag gate — so the host returns
|
|
8
|
+
* ONLY a MODERATED image (scanned clean, within the SFW ceiling, unflagged).
|
|
9
|
+
*
|
|
10
|
+
* Resolves with the chosen {@link BlockUploadedImageInfo}, or `null` when the
|
|
11
|
+
* user dismissed the modal without a successful upload. The returned `url` is a
|
|
12
|
+
* Civitai-hosted image URL usable directly as a `WorkflowBody.sourceImage.url`
|
|
13
|
+
* (img2img) — feed `{ url, width, height }` into the generation body and submit.
|
|
14
|
+
*
|
|
15
|
+
* Human-interactive, so it uses the same generous {@link PICKER_REQUEST_TIMEOUT_MS}
|
|
16
|
+
* as the pickers (the host still resolves earlier on upload/dismiss/close).
|
|
17
|
+
* Host-mediated, same trust model as `useResourcePicker` / `useBuzzWorkflow`.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* const { open } = useImageUpload();
|
|
21
|
+
* const img = await open();
|
|
22
|
+
* if (!img) return; // user dismissed
|
|
23
|
+
* // img2img: feed the moderated image into the generation body
|
|
24
|
+
* await submit({ kind: 'textToImage', modelId, modelVersionId,
|
|
25
|
+
* sourceImage: { url: img.url, width: 1024, height: 1024 }, params: { prompt } });
|
|
26
|
+
*/
|
|
27
|
+
export declare function useImageUpload(): {
|
|
28
|
+
open: () => Promise<BlockUploadedImageInfo | null>;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=useImageUpload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useImageUpload.d.ts","sourceRoot":"","sources":["../../src/hooks/useImageUpload.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAMtE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,cAAc,IAAI;IAAE,IAAI,EAAE,MAAM,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CAAA;CAAE,CAcvF"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { getTransport } from '../internal/singleton.js';
|
|
3
|
+
import { sendTypedRequest } from '../internal/transport.js';
|
|
4
|
+
import { PICKER_REQUEST_TIMEOUT_MS } from './useCheckpointPicker.js';
|
|
5
|
+
/**
|
|
6
|
+
* Drives the platform-side image-upload flow for App Blocks (Design 1 —
|
|
7
|
+
* host-chrome). Mirrors {@link useResourcePicker}: `open` asks the host to open
|
|
8
|
+
* its OWN native upload modal; the iframe never handles the bytes. The upload
|
|
9
|
+
* routes through civitai's session-authed scan pipeline (real `createImage` +
|
|
10
|
+
* `ingestImage`) and a hard SFW + no-moderation-flag gate — so the host returns
|
|
11
|
+
* ONLY a MODERATED image (scanned clean, within the SFW ceiling, unflagged).
|
|
12
|
+
*
|
|
13
|
+
* Resolves with the chosen {@link BlockUploadedImageInfo}, or `null` when the
|
|
14
|
+
* user dismissed the modal without a successful upload. The returned `url` is a
|
|
15
|
+
* Civitai-hosted image URL usable directly as a `WorkflowBody.sourceImage.url`
|
|
16
|
+
* (img2img) — feed `{ url, width, height }` into the generation body and submit.
|
|
17
|
+
*
|
|
18
|
+
* Human-interactive, so it uses the same generous {@link PICKER_REQUEST_TIMEOUT_MS}
|
|
19
|
+
* as the pickers (the host still resolves earlier on upload/dismiss/close).
|
|
20
|
+
* Host-mediated, same trust model as `useResourcePicker` / `useBuzzWorkflow`.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* const { open } = useImageUpload();
|
|
24
|
+
* const img = await open();
|
|
25
|
+
* if (!img) return; // user dismissed
|
|
26
|
+
* // img2img: feed the moderated image into the generation body
|
|
27
|
+
* await submit({ kind: 'textToImage', modelId, modelVersionId,
|
|
28
|
+
* sourceImage: { url: img.url, width: 1024, height: 1024 }, params: { prompt } });
|
|
29
|
+
*/
|
|
30
|
+
export function useImageUpload() {
|
|
31
|
+
const open = useCallback(async () => {
|
|
32
|
+
const { selected } = await sendTypedRequest(getTransport(), { type: 'OPEN_IMAGE_UPLOAD', payload: {} }, 'IMAGE_UPLOAD_RESULT', { timeoutMs: PICKER_REQUEST_TIMEOUT_MS });
|
|
33
|
+
// Normalize the "dismissed" case to an explicit null so callers can
|
|
34
|
+
// `if (!img) return;` without an `undefined` ambiguity.
|
|
35
|
+
return selected ?? null;
|
|
36
|
+
}, []);
|
|
37
|
+
return { open };
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=useImageUpload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useImageUpload.js","sourceRoot":"","sources":["../../src/hooks/useImageUpload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAIpC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,IAAI,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QAClC,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,gBAAgB,CACzC,YAAY,EAAE,EACd,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,EAAE,EAAE,EAC1C,qBAAqB,EACrB,EAAE,SAAS,EAAE,yBAAyB,EAAE,CACzC,CAAC;QACF,oEAAoE;QACpE,wDAAwD;QACxD,OAAO,QAAQ,IAAI,IAAI,CAAC;IAC1B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,EAAE,IAAI,EAAE,CAAC;AAClB,CAAC"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { SharedStorageValue } from '@civitai/app-sdk/blocks';
|
|
2
2
|
/**
|
|
3
|
-
* The value a viewer contributes to the SHARED store: a required `title
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* The value a viewer contributes to the SHARED store: a required `title`, an
|
|
4
|
+
* optional long-form `body`, and an optional opaque app-owned `data` blob.
|
|
5
|
+
* `title`/`body` are the MODERATED, user-visible TEXT; `data` is UNMODERATED
|
|
6
|
+
* structured app state (keep all user-visible text in title/body). Re-exported
|
|
7
|
+
* from the app-sdk contract so block authors get one canonical shape.
|
|
6
8
|
*/
|
|
7
9
|
export type SharedAppendValue = SharedStorageValue;
|
|
8
10
|
/**
|
|
@@ -42,9 +44,11 @@ export interface UseSharedStorage {
|
|
|
42
44
|
*/
|
|
43
45
|
getCounts(keys: string[]): Promise<Record<string, number>>;
|
|
44
46
|
/**
|
|
45
|
-
* Append a new entry on behalf of the viewer.
|
|
46
|
-
* `
|
|
47
|
-
*
|
|
47
|
+
* Append a new entry on behalf of the viewer. Accepts the generic
|
|
48
|
+
* `{ title, body?, data? }` value — `data` is an optional opaque app-owned
|
|
49
|
+
* payload stored alongside the moderated title/body. Resolves with the
|
|
50
|
+
* host-minted `key`. Rejects with the host's `error` string on validation/host
|
|
51
|
+
* failure (or when the viewer is anonymous).
|
|
48
52
|
*/
|
|
49
53
|
append(value: SharedAppendValue): Promise<{
|
|
50
54
|
key: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSharedStorage.d.ts","sourceRoot":"","sources":["../../src/hooks/useSharedStorage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAKlE
|
|
1
|
+
{"version":3,"file":"useSharedStorage.d.ts","sourceRoot":"","sources":["../../src/hooks/useSharedStorage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAKlE;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,kBAAkB,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,iBAAiB,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB,sFAAsF;IACtF,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,IAAI,CAAC,IAAI,CAAC,EAAE;QACV,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC9B,8EAA8E;IAC9E,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACvC;;;OAGG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC3D;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC3D;;;OAGG;IACH,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACnC;;;OAGG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACrC;;;OAGG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACnE;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,gBAAgB,IAAI,gBAAgB,CAwFnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSharedStorage.js","sourceRoot":"","sources":["../../src/hooks/useSharedStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAIhC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"useSharedStorage.js","sourceRoot":"","sources":["../../src/hooks/useSharedStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAIhC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AA0E5D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,OAAO,CAAmB,GAAG,EAAE;QACpC,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;QACjC,OAAO;YACL,KAAK,CAAC,IAAI,CAAC,IAA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KAAK,CAAC,QAAQ,CAAC,GAAG;gBAChB,MAAM,MAAM,GAAG,MAAM,gBAAgB,CACnC,SAAS,EACT,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,EAAE,EAC7C,wBAAwB,CACzB,CAAC;gBACF,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;oBAC/B,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,wBAAwB,CAAC,CAAC;gBAC5D,CAAC;gBACD,OAAO,EAAE,EAAE,EAAE,IAAa,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;YACxD,CAAC;SACF,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export type { BlockSnapshot, BlockTransport, OutboundRequest, } from './internal
|
|
|
16
16
|
export { useBlockContext } from './hooks/useBlockContext.js';
|
|
17
17
|
export { useBlockSettings } from './hooks/useBlockSettings.js';
|
|
18
18
|
export { useBlockToken } from './hooks/useBlockToken.js';
|
|
19
|
+
export { useHostOrigin } from './hooks/useHostOrigin.js';
|
|
19
20
|
export { useBuzzWorkflow } from './hooks/useBuzzWorkflow.js';
|
|
20
21
|
export { useBlockResize } from './hooks/useBlockResize.js';
|
|
21
22
|
export { useBuzzPurchase } from './hooks/useBuzzPurchase.js';
|
|
@@ -23,6 +24,9 @@ export { useBuzzBalance } from './hooks/useBuzzBalance.js';
|
|
|
23
24
|
export type { BuzzBalance, UseBuzzBalance } from './hooks/useBuzzBalance.js';
|
|
24
25
|
export { useCheckpointPicker } from './hooks/useCheckpointPicker.js';
|
|
25
26
|
export { useResourcePicker } from './hooks/useResourcePicker.js';
|
|
27
|
+
export { useImageUpload } from './hooks/useImageUpload.js';
|
|
28
|
+
export { useGenerationResources } from './hooks/useGenerationResources.js';
|
|
29
|
+
export { GENERATION_RESOURCES_API_BASE, MAX_GENERATION_RESOURCE_IDS, buildGenerationResourcesUrl, responseToResources, } from './api/generationResources.js';
|
|
26
30
|
export { useCivitaiNavigate } from './hooks/useCivitaiNavigate.js';
|
|
27
31
|
export { useRequestSignIn } from './hooks/useRequestSignIn.js';
|
|
28
32
|
export { useRequestConsent } from './hooks/useRequestConsent.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,YAAY,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAE5E,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAC3F,YAAY,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,YAAY,EACV,aAAa,EACb,cAAc,EACd,eAAe,GAChB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,2BAA2B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AAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,YAAY,EACV,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,aAAa,GACd,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,YAAY,EACV,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,6BAA6B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -14,12 +14,16 @@ export { sendTypedRequest } from './internal/transport.js';
|
|
|
14
14
|
export { useBlockContext } from './hooks/useBlockContext.js';
|
|
15
15
|
export { useBlockSettings } from './hooks/useBlockSettings.js';
|
|
16
16
|
export { useBlockToken } from './hooks/useBlockToken.js';
|
|
17
|
+
export { useHostOrigin } from './hooks/useHostOrigin.js';
|
|
17
18
|
export { useBuzzWorkflow } from './hooks/useBuzzWorkflow.js';
|
|
18
19
|
export { useBlockResize } from './hooks/useBlockResize.js';
|
|
19
20
|
export { useBuzzPurchase } from './hooks/useBuzzPurchase.js';
|
|
20
21
|
export { useBuzzBalance } from './hooks/useBuzzBalance.js';
|
|
21
22
|
export { useCheckpointPicker } from './hooks/useCheckpointPicker.js';
|
|
22
23
|
export { useResourcePicker } from './hooks/useResourcePicker.js';
|
|
24
|
+
export { useImageUpload } from './hooks/useImageUpload.js';
|
|
25
|
+
export { useGenerationResources } from './hooks/useGenerationResources.js';
|
|
26
|
+
export { GENERATION_RESOURCES_API_BASE, MAX_GENERATION_RESOURCE_IDS, buildGenerationResourcesUrl, responseToResources, } from './api/generationResources.js';
|
|
23
27
|
export { useCivitaiNavigate } from './hooks/useCivitaiNavigate.js';
|
|
24
28
|
export { useRequestSignIn } from './hooks/useRequestSignIn.js';
|
|
25
29
|
export { useRequestConsent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AAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAOzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -37,6 +37,24 @@ export declare class IframeTransport implements BlockTransport {
|
|
|
37
37
|
private readonly messageListener;
|
|
38
38
|
constructor(opts: IframeTransportOptions);
|
|
39
39
|
getSnapshot(): BlockSnapshot;
|
|
40
|
+
/**
|
|
41
|
+
* The validated parent origin — `null` until `BLOCK_INIT` lands.
|
|
42
|
+
*
|
|
43
|
+
* SECURITY INVARIANT — do NOT change what this returns: it hands back ONLY
|
|
44
|
+
* `this.parentOrigin`, which is set exactly once, in `handleMessage`, from
|
|
45
|
+
* the `event.origin` of the FIRST `BLOCK_INIT` — AND only after that message
|
|
46
|
+
* cleared `this.originMatcher.matches(event.origin)` (the allowlist gate at
|
|
47
|
+
* the very top of `handleMessage`, the same gate every inbound message
|
|
48
|
+
* passes). It is therefore guaranteed to be a legitimate civitai origin.
|
|
49
|
+
*
|
|
50
|
+
* It is NEVER derived from `document.referrer`, `window.location`, or an
|
|
51
|
+
* unvalidated `event.origin`. Blocks send a money-scoped bearer token
|
|
52
|
+
* (`useBlockToken().raw`) to this origin, so returning a spoofable value
|
|
53
|
+
* would be a token-exfiltration vector. This is the same value already
|
|
54
|
+
* trusted as the `targetOrigin` of every `postMessage` to the parent
|
|
55
|
+
* (see `postToParent`).
|
|
56
|
+
*/
|
|
57
|
+
getHostOrigin(): string | null;
|
|
40
58
|
subscribe(listener: () => void): () => void;
|
|
41
59
|
waitForInit(): Promise<BlockInitPayload>;
|
|
42
60
|
sendMessage(message: BlockToParentMessage): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iframeTransport.d.ts","sourceRoot":"","sources":["../../src/internal/iframeTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EAEzB,KAAK,wBAAwB,EAC9B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAKL,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,eAAe,EACrB,MAAM,gBAAgB,CAAC;AASxB,MAAM,WAAW,sBAAsB;IACrC;;;;;;;OAOG;IACH,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,iEAAiE;IACjE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AASD;;;;;GAKG;AACH,qBAAa,eAAgB,YAAW,cAAc;IACpD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAC9C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC,OAAO,CAAC,QAAQ,CAAiC;IACjD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAyB;IAEnD,yEAAyE;IACzE,OAAO,CAAC,YAAY,CAAuB;IAE3C,2EAA2E;IAC3E,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAiD;IAC1E,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqC;IAE7D,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA4B;IACxD,OAAO,CAAC,WAAW,CAAuC;IAC1D,OAAO,CAAC,UAAU,CAAwB;IAC1C,OAAO,CAAC,aAAa,CAAgC;IACrD,OAAO,CAAC,YAAY,CAAS;IAE7B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAgC;gBAEpD,IAAI,EAAE,sBAAsB;IAoCxC,WAAW,IAAI,aAAa;IAI5B,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,I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,CAAC,OAAO,CAAqC;IAE7D,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA4B;IACxD,OAAO,CAAC,WAAW,CAAuC;IAC1D,OAAO,CAAC,UAAU,CAAwB;IAC1C,OAAO,CAAC,aAAa,CAAgC;IACrD,OAAO,CAAC,YAAY,CAAS;IAE7B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAgC;gBAEpD,IAAI,EAAE,sBAAsB;IAoCxC,WAAW,IAAI,aAAa;IAI5B;;;;;;;;;;;;;;;;OAgBG;IACH,aAAa,IAAI,MAAM,GAAG,IAAI;IAI9B,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAO3C,WAAW,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAIxC,WAAW,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI;IAIhD,WAAW,CACT,OAAO,EAAE,eAAe,EACxB,YAAY,EAAE,wBAAwB,EACtC,IAAI,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GAChC,OAAO,CAAC,OAAO,CAAC;IAmBnB,uDAAuD;IACvD,OAAO,IAAI,IAAI;IAWf,OAAO,CAAC,QAAQ;IAQhB,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,aAAa;IA2FrB,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,IAAI;CAGb"}
|
|
@@ -56,6 +56,26 @@ export class IframeTransport {
|
|
|
56
56
|
getSnapshot() {
|
|
57
57
|
return this.snapshot;
|
|
58
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* The validated parent origin — `null` until `BLOCK_INIT` lands.
|
|
61
|
+
*
|
|
62
|
+
* SECURITY INVARIANT — do NOT change what this returns: it hands back ONLY
|
|
63
|
+
* `this.parentOrigin`, which is set exactly once, in `handleMessage`, from
|
|
64
|
+
* the `event.origin` of the FIRST `BLOCK_INIT` — AND only after that message
|
|
65
|
+
* cleared `this.originMatcher.matches(event.origin)` (the allowlist gate at
|
|
66
|
+
* the very top of `handleMessage`, the same gate every inbound message
|
|
67
|
+
* passes). It is therefore guaranteed to be a legitimate civitai origin.
|
|
68
|
+
*
|
|
69
|
+
* It is NEVER derived from `document.referrer`, `window.location`, or an
|
|
70
|
+
* unvalidated `event.origin`. Blocks send a money-scoped bearer token
|
|
71
|
+
* (`useBlockToken().raw`) to this origin, so returning a spoofable value
|
|
72
|
+
* would be a token-exfiltration vector. This is the same value already
|
|
73
|
+
* trusted as the `targetOrigin` of every `postMessage` to the parent
|
|
74
|
+
* (see `postToParent`).
|
|
75
|
+
*/
|
|
76
|
+
getHostOrigin() {
|
|
77
|
+
return this.parentOrigin;
|
|
78
|
+
}
|
|
59
79
|
subscribe(listener) {
|
|
60
80
|
this.listeners.add(listener);
|
|
61
81
|
return () => {
|