원클릭으로
extension-core-infrastructure
Core infrastructure providing backend connection configuration, storage client, and React app entry point.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Core infrastructure providing backend connection configuration, storage client, and React app entry point.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Quick reference for the Caffeine Data Intelligence agent to query an OQL-exposing canister (schema() + execute()) through the `icp` CLI against the project's `backend` canister: read the schema, form JSON queries (filter / order / paginate / aggregate / dotted-path edges), and parse the Candid result rows.
Make a canister's data queryable by the Caffeine Data Intelligence agent. Use whenever an app stores structured data (Maps/Lists/arrays of records) that should be answerable in natural language — "top customers", "revenue by region", "active projects". Adds a discoverable `schema()` and a JSON `execute()` query endpoint via the `caffeineai-oql` mops package's `Expose` mixin.
General file/object storage, such as for images, videos, files, documents and other bulk data. Perfect fit for image galleries, video galleries, and other file or object management. Supports large files beyond IC limit, with browser-cached HTTP URL access.
Use the `googlemail-client` mops package whenever the user asks the canister to send email, compose a draft, list or read Gmail messages, or fetch the authenticated user's Gmail profile. The package wraps the Gmail REST API v1 at `https://gmail.googleapis.com` via outbound HTTPS calls.
HTTP outcalls performed by the backend canister (not in the frontend).
Payment support based on Stripe, supporting credit cards and debit cards
| name | extension-core-infrastructure |
| description | Core infrastructure providing backend connection configuration, storage client, and React app entry point. |
| version | 1.1.0 |
| compatibility | {"npm":{"@caffeineai/core-infrastructure":"^1.1.0","@caffeineai/object-storage":"^1.1.0"}} |
| caffeineai-subscription | ["none"] |
Core infrastructure extension for Caffeine AI.
This component provides the foundational infrastructure for all projects: backend connection configuration, Internet Identity authentication hooks, and actor management utilities.
"@caffeineai/core-infrastructure": "^1.1.0"
"@caffeineai/object-storage": "^1.1.0"
"@icp-sdk/auth": "^7.1.0"
"@icp-sdk/core": "^5.3.0"
@caffeineai/object-storage is a peer dependency of core-infrastructure. Every project must install it as a direct npm dependency (the build template includes both packages).
Core infrastructure is automatically included in every project. No manual integration steps are required.
The core-infrastructure frontend package (@caffeineai/core-infrastructure) is automatically included in every project.
Wrap the app with InternetIdentityProvider and QueryClientProvider:
import { InternetIdentityProvider } from "@caffeineai/core-infrastructure";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import ReactDOM from "react-dom/client";
import App from "./App";
const queryClient = new QueryClient();
ReactDOM.createRoot(document.getElementById("root")!).render(
<QueryClientProvider client={queryClient}>
<InternetIdentityProvider>
<App />
</InternetIdentityProvider>
</QueryClientProvider>,
);
useInternetIdentity() — Authentication HookProvides identity state, login, and logout for Internet Identity.
| Field | Type | Description |
|---|---|---|
identity | Identity | undefined | The user's identity (available after login or session restore) |
login | () => void | Opens the II popup. Fire-and-forget — do not await. |
clear | () => void | Logs out and clears stored identity. Fire-and-forget. |
isAuthenticated | boolean | true when user has a valid identity. Use this for UI gating. |
isInitializing | boolean | true while AuthClient is loading from IndexedDB |
isLoggingIn | boolean | true while the II popup is open |
isLoginSuccess | boolean | true only after interactive login (NOT after page reload restore) |
isLoginError | boolean | true if login or initialization failed |
loginError | Error | undefined | The error object when isLoginError is true |
| Scenario | loginStatus | isAuthenticated |
|---|---|---|
| Page load, no stored session | "idle" | false |
| Restoring stored session | "initializing" | false → true |
| Stored session restored after reload | "idle" | true |
| Interactive login in progress | "logging-in" | false |
| Interactive login just completed | "success" | true |
| Login popup failed / cancelled | "loginError" | false |
IMPORTANT: isLoginSuccess is only true after an interactive login via the popup — NOT when a stored identity is restored on page reload. Always use isAuthenticated for conditional rendering.
Gate authenticated UI on isAuthenticated:
const { isAuthenticated } = useInternetIdentity();
{isAuthenticated ? <AuthenticatedApp /> : <LoginScreen />}
Disable the login button while initializing or logging in:
const { login, isInitializing, isLoggingIn } = useInternetIdentity();
<button onClick={() => login()} disabled={isInitializing || isLoggingIn}>
Sign in
</button>
login() and clear() are fire-and-forget — the hook's state fields (isLoggingIn, isInitializing) track the async lifecycle. Do not wrap them in local useState / isPending logic.
useActor() — Backend Actor HookCreates and manages a typed backend actor instance. Automatically re-creates the actor when the user's identity changes (login/logout).
import { useActor } from "@caffeineai/core-infrastructure";
import { createActor } from "declarations/backend";
function MyComponent() {
const { actor, isFetching } = useActor(createActor);
// actor is null while loading, then the typed backend actor
if (!actor || isFetching) return <Loading />;
// Call backend methods directly
const data = await actor.myBackendMethod();
}
| Field | Type | Description |
|---|---|---|
actor | T | null | The typed backend actor, or null while loading |
isFetching | boolean | true while the actor is being created |
When the identity changes (login, logout, or session restore), the actor is automatically re-created with the new identity and all dependent queries are invalidated and refetched.