@fire-spark/ai 0.0.0-stage → 0.36.1
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/dist/auth/index.d.ts +137 -0
- package/dist/auth/index.js +912 -0
- package/dist/index.d.ts +734 -0
- package/dist/index.js +3813 -0
- package/package.json +82 -3
- package/README.md +0 -3
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { Provider } from "oidc-provider";
|
|
2
|
+
import { IncomingMessage, ServerResponse } from "node:http";
|
|
3
|
+
//#region src/auth/policy.d.ts
|
|
4
|
+
interface ClientDomainPolicy {
|
|
5
|
+
allowDcr: boolean;
|
|
6
|
+
allowCimd: boolean;
|
|
7
|
+
allowedDomains: string[];
|
|
8
|
+
blockedDomains: string[];
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/auth/ssrf.d.ts
|
|
12
|
+
type AddressLookup = (hostname: string) => Promise<string[]>;
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/auth/store.d.ts
|
|
15
|
+
interface AuthRecord {
|
|
16
|
+
payload: unknown;
|
|
17
|
+
grantId?: string;
|
|
18
|
+
uid?: string;
|
|
19
|
+
userCode?: string;
|
|
20
|
+
expiresAt?: number;
|
|
21
|
+
consumed?: boolean;
|
|
22
|
+
}
|
|
23
|
+
interface ClientRow {
|
|
24
|
+
clientId: string;
|
|
25
|
+
source: "dcr" | "cimd";
|
|
26
|
+
name: string;
|
|
27
|
+
redirectUris: string[];
|
|
28
|
+
status: "ACTIVE" | "BLOCKED";
|
|
29
|
+
secretHash: string | null;
|
|
30
|
+
}
|
|
31
|
+
interface GrantRow {
|
|
32
|
+
clientId: string;
|
|
33
|
+
customerId: string;
|
|
34
|
+
scopes: string;
|
|
35
|
+
revoked: boolean;
|
|
36
|
+
}
|
|
37
|
+
/** What the authorization server persists. Plaintext never leaves this process. */
|
|
38
|
+
interface AuthStore {
|
|
39
|
+
upsert(model: string, id: string, record: AuthRecord): Promise<void>;
|
|
40
|
+
find(model: string, id: string): Promise<AuthRecord | undefined>;
|
|
41
|
+
findByUid(model: string, uid: string): Promise<AuthRecord | undefined>;
|
|
42
|
+
findByUserCode(model: string, userCode: string): Promise<AuthRecord | undefined>;
|
|
43
|
+
consume(model: string, id: string): Promise<void>;
|
|
44
|
+
destroy(model: string, id: string): Promise<void>;
|
|
45
|
+
revokeByGrantId(grantId: string): Promise<void>;
|
|
46
|
+
upsertClient(row: ClientRow): Promise<void>;
|
|
47
|
+
findClient(clientId: string): Promise<ClientRow | undefined>;
|
|
48
|
+
touchGrant(row: Omit<GrantRow, "revoked">): Promise<{
|
|
49
|
+
revoked: boolean;
|
|
50
|
+
}>;
|
|
51
|
+
findGrant(clientId: string, customerId: string): Promise<GrantRow | undefined>;
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/auth/provider.d.ts
|
|
55
|
+
interface AgentAsConfig {
|
|
56
|
+
issuer: string;
|
|
57
|
+
mcpUrl: string;
|
|
58
|
+
merchantId: string;
|
|
59
|
+
scopes: string[];
|
|
60
|
+
accessTokenTtlSeconds: number;
|
|
61
|
+
refreshTokenTtlSeconds: number;
|
|
62
|
+
policy: ClientDomainPolicy;
|
|
63
|
+
jwks: {
|
|
64
|
+
keys: Record<string, unknown>[];
|
|
65
|
+
};
|
|
66
|
+
cookieKeys: string[];
|
|
67
|
+
store: AuthStore;
|
|
68
|
+
brand: string;
|
|
69
|
+
firebase?: {
|
|
70
|
+
apiKey: string;
|
|
71
|
+
authDomain: string;
|
|
72
|
+
projectId: string;
|
|
73
|
+
appId: string;
|
|
74
|
+
};
|
|
75
|
+
oidc?: {
|
|
76
|
+
issuer: string;
|
|
77
|
+
clientId: string;
|
|
78
|
+
clientSecret: string;
|
|
79
|
+
};
|
|
80
|
+
/** Test-only login that posts customer_id. Never enable on a deploy. */
|
|
81
|
+
testLogin?: boolean;
|
|
82
|
+
lookup?: AddressLookup;
|
|
83
|
+
/** OIDC registration path. Defaults to /register. */
|
|
84
|
+
registrationPath?: string;
|
|
85
|
+
}
|
|
86
|
+
declare const createAgentProvider: (config: AgentAsConfig) => Provider;
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/auth/server.d.ts
|
|
89
|
+
declare const handleAgentHttp: (req: IncomingMessage, res: ServerResponse, provider: Provider, config: AgentAsConfig) => Promise<void>;
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/auth/spark.d.ts
|
|
92
|
+
interface SparkOptions {
|
|
93
|
+
apiUrl: string;
|
|
94
|
+
token: () => Promise<string>;
|
|
95
|
+
channelId: string;
|
|
96
|
+
secret: string;
|
|
97
|
+
fetchImpl?: typeof fetch;
|
|
98
|
+
}
|
|
99
|
+
/** Persists ciphertext in Spark. The raw code and refresh token stay here. */
|
|
100
|
+
declare class SparkAuthStore implements AuthStore {
|
|
101
|
+
private options;
|
|
102
|
+
constructor(options: SparkOptions);
|
|
103
|
+
private call;
|
|
104
|
+
upsert(model: string, id: string, record: AuthRecord): Promise<void>;
|
|
105
|
+
private open;
|
|
106
|
+
find(model: string, id: string): Promise<AuthRecord | undefined>;
|
|
107
|
+
findByUid(model: string, uid: string): Promise<AuthRecord | undefined>;
|
|
108
|
+
findByUserCode(model: string, userCode: string): Promise<AuthRecord | undefined>;
|
|
109
|
+
consume(model: string, id: string): Promise<void>;
|
|
110
|
+
destroy(model: string, id: string): Promise<void>;
|
|
111
|
+
revokeByGrantId(grantId: string): Promise<void>;
|
|
112
|
+
upsertClient(row: ClientRow): Promise<void>;
|
|
113
|
+
findClient(clientId: string): Promise<{
|
|
114
|
+
clientId: string;
|
|
115
|
+
source: "cimd" | "dcr";
|
|
116
|
+
name: string;
|
|
117
|
+
redirectUris: string[];
|
|
118
|
+
status: "ACTIVE" | "BLOCKED";
|
|
119
|
+
secretHash: string | null;
|
|
120
|
+
} | undefined>;
|
|
121
|
+
touchGrant(row: Omit<GrantRow, "revoked">): Promise<{
|
|
122
|
+
revoked: boolean;
|
|
123
|
+
}>;
|
|
124
|
+
findGrant(clientId: string, customerId: string): Promise<{
|
|
125
|
+
clientId: string;
|
|
126
|
+
customerId: string;
|
|
127
|
+
scopes: string;
|
|
128
|
+
revoked: boolean;
|
|
129
|
+
} | undefined>;
|
|
130
|
+
}
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region src/auth/bridge.d.ts
|
|
133
|
+
type Listener = (req: IncomingMessage, res: ServerResponse) => Promise<void>;
|
|
134
|
+
/** Adapts a Web Request to the Node listener oidc-provider expects. */
|
|
135
|
+
declare const dispatchWeb: (request: Request, listener: Listener) => Promise<Response>;
|
|
136
|
+
//#endregion
|
|
137
|
+
export { type AgentAsConfig, SparkAuthStore, createAgentProvider, dispatchWeb, handleAgentHttp };
|