@happyvertical/smrt-secrets 0.62.5 → 0.62.7
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/AGENTS.md +14 -0
- package/dist/chunks/ConnectState-DUeYDO6b.js +289 -0
- package/dist/chunks/ConnectState-DUeYDO6b.js.map +1 -0
- package/dist/chunks/{SecretService-CEvXX8bj.js → SecretService-DyzsJCio.js} +13 -116
- package/dist/chunks/SecretService-DyzsJCio.js.map +1 -0
- package/dist/chunks/TenantKey-p_gp_teA.js +356 -0
- package/dist/chunks/TenantKey-p_gp_teA.js.map +1 -0
- package/dist/chunks/dist-kZ2KUDiZ.js +129 -0
- package/dist/chunks/dist-kZ2KUDiZ.js.map +1 -0
- package/dist/collections/ConnectStateCollection.d.ts +20 -0
- package/dist/collections/ConnectStateCollection.d.ts.map +1 -0
- package/dist/collections/index.d.ts +1 -0
- package/dist/collections/index.d.ts.map +1 -1
- package/dist/connect/index.d.ts +7 -0
- package/dist/connect/index.d.ts.map +1 -0
- package/dist/connect/index.js +215 -0
- package/dist/connect/index.js.map +1 -0
- package/dist/connect/oauth.d.ts +46 -0
- package/dist/connect/oauth.d.ts.map +1 -0
- package/dist/connect/state.d.ts +57 -0
- package/dist/connect/state.d.ts.map +1 -0
- package/dist/connect/types.d.ts +65 -0
- package/dist/connect/types.d.ts.map +1 -0
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +447 -2
- package/dist/models/ConnectState.d.ts +42 -0
- package/dist/models/ConnectState.d.ts.map +1 -0
- package/dist/models/index.d.ts +1 -0
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +4 -2
- package/dist/services/SecretService.d.ts +8 -0
- package/dist/services/SecretService.d.ts.map +1 -1
- package/dist/services/SecretService.js +1 -1
- package/dist/smrt-knowledge.json +185 -8
- package/dist/smrt-knowledge.okf.md +5 -2
- package/package.json +12 -8
- package/dist/chunks/SecretService-CEvXX8bj.js.map +0 -1
- package/dist/chunks/TenantKey-rATrKLq9.js +0 -366
- package/dist/chunks/TenantKey-rATrKLq9.js.map +0 -1
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import "../chunks/dist-kZ2KUDiZ.js";
|
|
2
|
+
import { t as ConnectState } from "../chunks/ConnectState-DUeYDO6b.js";
|
|
3
|
+
import { RuntimeError, SmrtCollection } from "@happyvertical/smrt-core";
|
|
4
|
+
//#region src/collections/ConnectStateCollection.ts
|
|
5
|
+
/**
|
|
6
|
+
* ConnectStateCollection: the `ConnectStateStore` smrt-secrets ships.
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
var ConnectStateCollection = class extends SmrtCollection {
|
|
10
|
+
static _itemClass = ConnectState;
|
|
11
|
+
/** The `ConnectStateStore` contract over this collection. */
|
|
12
|
+
asStore() {
|
|
13
|
+
return {
|
|
14
|
+
create: (input) => this.create({ ...input }),
|
|
15
|
+
findByState: (state) => this.findByState(state),
|
|
16
|
+
consume: (record) => this.consume(record)
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
async findByState(state) {
|
|
20
|
+
return this.get({ state });
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Delete a loaded state exactly once, with a revision-guarded delete: when
|
|
24
|
+
* two callbacks race on the same state only one removes the row.
|
|
25
|
+
*/
|
|
26
|
+
async consume(record) {
|
|
27
|
+
const row = record;
|
|
28
|
+
if (!row.id || !row.updated_at) return false;
|
|
29
|
+
try {
|
|
30
|
+
await row.delete({ expectedUpdatedAt: row.updated_at });
|
|
31
|
+
return true;
|
|
32
|
+
} catch (error) {
|
|
33
|
+
if (error instanceof RuntimeError && error.code === "RUNTIME_REVISION_CONFLICT") return false;
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async deleteExpired(now = /* @__PURE__ */ new Date()) {
|
|
38
|
+
const expired = await this.list({ where: { "expiresAt <=": now } });
|
|
39
|
+
await Promise.all(expired.map((row) => row.delete()));
|
|
40
|
+
return expired.length;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/connect/types.ts
|
|
45
|
+
/**
|
|
46
|
+
* Raised for every connect failure. Messages are safe to show to a user and
|
|
47
|
+
* never contain tokens, codes or client secrets.
|
|
48
|
+
*/
|
|
49
|
+
var ConnectError = class extends Error {
|
|
50
|
+
code;
|
|
51
|
+
constructor(code, message) {
|
|
52
|
+
super(message);
|
|
53
|
+
this.code = code;
|
|
54
|
+
this.name = "ConnectError";
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/connect/oauth.ts
|
|
59
|
+
function buildOAuth2AuthorizeUrl(config, request) {
|
|
60
|
+
const url = new URL(config.authorizeUrl);
|
|
61
|
+
url.searchParams.set("response_type", "code");
|
|
62
|
+
url.searchParams.set("client_id", request.client.clientId);
|
|
63
|
+
url.searchParams.set("redirect_uri", request.redirectUri);
|
|
64
|
+
if (request.scopes.length) url.searchParams.set("scope", request.scopes.join(" "));
|
|
65
|
+
url.searchParams.set("state", request.state);
|
|
66
|
+
if (request.codeChallenge) {
|
|
67
|
+
url.searchParams.set("code_challenge", request.codeChallenge);
|
|
68
|
+
url.searchParams.set("code_challenge_method", "S256");
|
|
69
|
+
}
|
|
70
|
+
for (const [key, value] of Object.entries(config.authorizeParams ?? {})) url.searchParams.set(key, value);
|
|
71
|
+
return url.toString();
|
|
72
|
+
}
|
|
73
|
+
/** Exchange an authorization code. Never echoes the response body. */
|
|
74
|
+
async function exchangeOAuth2Code(config, request) {
|
|
75
|
+
const body = new URLSearchParams({
|
|
76
|
+
grant_type: "authorization_code",
|
|
77
|
+
code: request.code,
|
|
78
|
+
redirect_uri: request.redirectUri,
|
|
79
|
+
client_id: request.client.clientId
|
|
80
|
+
});
|
|
81
|
+
if (request.codeVerifier) body.set("code_verifier", request.codeVerifier);
|
|
82
|
+
const headers = {
|
|
83
|
+
"content-type": "application/x-www-form-urlencoded",
|
|
84
|
+
accept: "application/json"
|
|
85
|
+
};
|
|
86
|
+
if ((config.clientAuth ?? "basic") === "basic") headers.authorization = `Basic ${btoa(`${request.client.clientId}:${request.client.clientSecret}`)}`;
|
|
87
|
+
else body.set("client_secret", request.client.clientSecret);
|
|
88
|
+
const response = await request.fetch(config.tokenUrl, {
|
|
89
|
+
method: "POST",
|
|
90
|
+
headers,
|
|
91
|
+
body
|
|
92
|
+
});
|
|
93
|
+
const json = await response.json().catch(() => null);
|
|
94
|
+
if (!response.ok || typeof json?.access_token !== "string" || !json.access_token) throw new ConnectError("token_exchange_failed", `${config.label} rejected the authorization code (HTTP ${response.status}).`);
|
|
95
|
+
const tokens = {
|
|
96
|
+
accessToken: json.access_token,
|
|
97
|
+
tokenType: typeof json.token_type === "string" ? json.token_type : void 0,
|
|
98
|
+
scopes: typeof json.scope === "string" && json.scope ? json.scope.split(" ") : []
|
|
99
|
+
};
|
|
100
|
+
if (typeof json.refresh_token === "string" && json.refresh_token) tokens.refreshToken = json.refresh_token;
|
|
101
|
+
if (typeof json.expires_in === "number") tokens.expiresAt = new Date(Date.now() + json.expires_in * 1e3);
|
|
102
|
+
return tokens;
|
|
103
|
+
}
|
|
104
|
+
async function fetchOidcUserInfo(config, accessToken, fetchImpl) {
|
|
105
|
+
if (!config.userinfoUrl) throw new ConnectError("profile_lookup_failed", `${config.label} has no userinfo endpoint configured.`);
|
|
106
|
+
const response = await fetchImpl(config.userinfoUrl, { headers: {
|
|
107
|
+
authorization: `Bearer ${accessToken}`,
|
|
108
|
+
accept: "application/json"
|
|
109
|
+
} });
|
|
110
|
+
const json = await response.json().catch(() => null);
|
|
111
|
+
if (!response.ok || typeof json?.sub !== "string" || !json.sub) throw new ConnectError("profile_lookup_failed", `Could not read the ${config.label} profile after connecting (HTTP ${response.status}).`);
|
|
112
|
+
const text = (value) => typeof value === "string" && value ? value : void 0;
|
|
113
|
+
return {
|
|
114
|
+
sub: json.sub,
|
|
115
|
+
email: text(json.email),
|
|
116
|
+
preferredUsername: text(json.preferred_username),
|
|
117
|
+
name: text(json.name)
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function requireHttps(url, what, label) {
|
|
121
|
+
if (typeof url === "string") try {
|
|
122
|
+
const parsed = new URL(url);
|
|
123
|
+
const local = [
|
|
124
|
+
"localhost",
|
|
125
|
+
"127.0.0.1",
|
|
126
|
+
"[::1]"
|
|
127
|
+
].includes(parsed.hostname);
|
|
128
|
+
if (parsed.protocol === "https:" || local && parsed.protocol === "http:") return parsed.toString();
|
|
129
|
+
} catch {}
|
|
130
|
+
throw new ConnectError("discovery_failed", `${label} returned an unusable ${what}.`);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Resolve endpoints from an OIDC issuer's discovery document
|
|
134
|
+
* (`/.well-known/openid-configuration`). The document's own `issuer` must equal
|
|
135
|
+
* the configured one, so a hijacked path cannot redirect the flow elsewhere.
|
|
136
|
+
*/
|
|
137
|
+
async function discoverOidcEndpoints(issuer, label, fetchImpl) {
|
|
138
|
+
const base = requireHttps(issuer, "issuer", label).replace(/\/$/, "");
|
|
139
|
+
const response = await fetchImpl(`${base}/.well-known/openid-configuration`, { headers: { accept: "application/json" } });
|
|
140
|
+
const json = await response.json().catch(() => null);
|
|
141
|
+
if (!response.ok || typeof json?.issuer !== "string" || json.issuer.replace(/\/$/, "") !== base) throw new ConnectError("discovery_failed", `Could not discover ${label} sign-in endpoints (HTTP ${response.status}).`);
|
|
142
|
+
return {
|
|
143
|
+
authorizeUrl: requireHttps(json.authorization_endpoint, "authorization endpoint", label),
|
|
144
|
+
tokenUrl: requireHttps(json.token_endpoint, "token endpoint", label),
|
|
145
|
+
userinfoUrl: json.userinfo_endpoint ? requireHttps(json.userinfo_endpoint, "userinfo endpoint", label) : void 0
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/connect/state.ts
|
|
150
|
+
var DEFAULT_CONNECT_STATE_TTL_MS = 600 * 1e3;
|
|
151
|
+
function generateConnectState() {
|
|
152
|
+
return crypto.randomUUID();
|
|
153
|
+
}
|
|
154
|
+
/** A PKCE code verifier (RFC 7636): 64 hex characters. */
|
|
155
|
+
function generateCodeVerifier() {
|
|
156
|
+
const bytes = /* @__PURE__ */ new Uint8Array(32);
|
|
157
|
+
crypto.getRandomValues(bytes);
|
|
158
|
+
return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
159
|
+
}
|
|
160
|
+
/** The S256 code challenge for a verifier. */
|
|
161
|
+
async function generateCodeChallenge(verifier) {
|
|
162
|
+
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(verifier));
|
|
163
|
+
return btoa(String.fromCharCode(...new Uint8Array(digest))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* A same-origin absolute path (`/settings/mail`), never a URL or a
|
|
167
|
+
* protocol-relative or backslash form. Hosts redirect only to this.
|
|
168
|
+
*/
|
|
169
|
+
function isSafeReturnPath(value) {
|
|
170
|
+
return typeof value === "string" && value.length <= 2048 && value.startsWith("/") && !value.startsWith("//") && !value.includes("\\") && !/[\u0000-\u001f\u007f]/.test(value);
|
|
171
|
+
}
|
|
172
|
+
/** Persist a single-use, tenant- and user-bound state. */
|
|
173
|
+
async function beginConnect(options) {
|
|
174
|
+
if (options.returnTo != null && !isSafeReturnPath(options.returnTo)) throw new ConnectError("invalid_return_to", "The return path must be a same-origin path.");
|
|
175
|
+
const state = generateConnectState();
|
|
176
|
+
const codeVerifier = options.usesPkce ? generateCodeVerifier() : null;
|
|
177
|
+
await options.store.create({
|
|
178
|
+
state,
|
|
179
|
+
kind: options.kind,
|
|
180
|
+
codeVerifier,
|
|
181
|
+
redirectUri: options.redirectUri,
|
|
182
|
+
scopes: options.scopes,
|
|
183
|
+
tenantId: options.tenantId,
|
|
184
|
+
initiatedByUserId: options.userId ?? null,
|
|
185
|
+
returnTo: options.returnTo ?? null,
|
|
186
|
+
expiresAt: new Date(Date.now() + (options.ttlMs ?? 6e5))
|
|
187
|
+
});
|
|
188
|
+
return {
|
|
189
|
+
state,
|
|
190
|
+
codeChallenge: codeVerifier ? await generateCodeChallenge(codeVerifier) : void 0
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Verify a callback and burn its state. The state is consumed before anything
|
|
195
|
+
* else, including for a refused grant, so a callback URL cannot be replayed;
|
|
196
|
+
* a mismatched kind, tenant, redirect URI or user is rejected before the
|
|
197
|
+
* state is spent.
|
|
198
|
+
*/
|
|
199
|
+
async function consumeConnect(options) {
|
|
200
|
+
const { code, state: token, error } = options.query;
|
|
201
|
+
const stored = token ? await options.store.findByState(token) : null;
|
|
202
|
+
if (!stored || stored.kind !== options.kind || stored.tenantId !== options.tenantId || stored.redirectUri !== options.redirectUri || stored.initiatedByUserId !== null && stored.initiatedByUserId !== (options.userId ?? null)) throw new ConnectError("invalid_state", "This connect link is not valid. Start the connection again.");
|
|
203
|
+
if (!await options.store.consume(stored)) throw new ConnectError("invalid_state", "This connect link was already used. Start the connection again.");
|
|
204
|
+
if (Date.now() >= stored.expiresAt.getTime()) throw new ConnectError("state_expired", "This connect link expired. Start the connection again.");
|
|
205
|
+
if (error) throw new ConnectError(error === "access_denied" ? "access_denied" : "provider_error", error === "access_denied" ? `${options.label} access was not granted.` : `${options.label} returned an error (${error.slice(0, 64)}).`);
|
|
206
|
+
if (!code) throw new ConnectError("provider_error", `${options.label} did not return an authorization code.`);
|
|
207
|
+
return {
|
|
208
|
+
record: stored,
|
|
209
|
+
code
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
//#endregion
|
|
213
|
+
export { ConnectError, ConnectState, ConnectStateCollection, DEFAULT_CONNECT_STATE_TTL_MS, beginConnect, buildOAuth2AuthorizeUrl, consumeConnect, discoverOidcEndpoints, exchangeOAuth2Code, fetchOidcUserInfo, generateCodeChallenge, generateCodeVerifier, generateConnectState, isSafeReturnPath };
|
|
214
|
+
|
|
215
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/collections/ConnectStateCollection.ts","../../src/connect/types.ts","../../src/connect/oauth.ts","../../src/connect/state.ts"],"sourcesContent":["/**\n * ConnectStateCollection: the `ConnectStateStore` smrt-secrets ships.\n * @packageDocumentation\n */\n\nimport { RuntimeError, SmrtCollection } from '@happyvertical/smrt-core';\nimport type {\n ConnectStateRecord,\n ConnectStateStore,\n} from '../connect/types.js';\nimport { ConnectState } from '../models/ConnectState.js';\n\nexport class ConnectStateCollection extends SmrtCollection<ConnectState> {\n static readonly _itemClass = ConnectState;\n\n /** The `ConnectStateStore` contract over this collection. */\n asStore(): ConnectStateStore {\n return {\n create: (input) => this.create({ ...input }),\n findByState: (state) => this.findByState(state),\n consume: (record) => this.consume(record),\n };\n }\n\n async findByState(state: string): Promise<ConnectState | null> {\n return this.get({ state });\n }\n\n /**\n * Delete a loaded state exactly once, with a revision-guarded delete: when\n * two callbacks race on the same state only one removes the row.\n */\n async consume(record: ConnectStateRecord): Promise<boolean> {\n const row = record as ConnectState;\n if (!row.id || !row.updated_at) return false;\n try {\n await row.delete({ expectedUpdatedAt: row.updated_at });\n return true;\n } catch (error) {\n if (\n error instanceof RuntimeError &&\n error.code === 'RUNTIME_REVISION_CONFLICT'\n ) {\n return false;\n }\n throw error;\n }\n }\n\n async deleteExpired(now: Date = new Date()): Promise<number> {\n const expired = await this.list({ where: { 'expiresAt <=': now } });\n await Promise.all(expired.map((row) => row.delete()));\n return expired.length;\n }\n}\n","/**\n * Provider-neutral credential connect: shared contracts.\n *\n * \"Connect\" is how a credential reaches smrt-secrets for an external account\n * a user owns: an OAuth 2.0 / OIDC redirect flow, or a write-only secret the\n * user types (an app password, handled by the owning package). This kernel\n * owns what every flow shares, the single-use state record, PKCE, a safe\n * return path, generic OAuth 2.0 / OIDC provider mechanics and one error type.\n * smrt-social and smrt-messages each bring their own account upsert.\n */\n\nexport type ConnectErrorCode =\n | 'unsupported_provider'\n | 'missing_client_credentials'\n | 'missing_tenant'\n | 'invalid_state'\n | 'state_expired'\n | 'access_denied'\n | 'provider_error'\n | 'token_exchange_failed'\n | 'profile_lookup_failed'\n | 'discovery_failed'\n | 'invalid_return_to'\n | 'forbidden';\n\n/**\n * Raised for every connect failure. Messages are safe to show to a user and\n * never contain tokens, codes or client secrets.\n */\nexport class ConnectError<\n Code extends string = ConnectErrorCode,\n> extends Error {\n constructor(\n readonly code: Code,\n message: string,\n ) {\n super(message);\n this.name = 'ConnectError';\n }\n}\n\n/** The persisted facts of one in-flight connect. */\nexport interface ConnectStateRecord {\n /** The unguessable value round-tripped through the provider. */\n state: string;\n /** Which provider/flow this state belongs to. */\n kind: string;\n codeVerifier: string | null;\n redirectUri: string;\n scopes: string[];\n tenantId: string | null;\n /** The signed-in user who started the connect. */\n initiatedByUserId: string | null;\n /** Same-origin path to return to after the callback. */\n returnTo?: string | null;\n expiresAt: Date;\n}\n\nexport type NewConnectState = ConnectStateRecord;\n\n/**\n * Where a package keeps its connect states. smrt-secrets ships\n * `ConnectStateCollection` for new flows; smrt-social adapts its own\n * `OAuthState` table to the same contract.\n */\nexport interface ConnectStateStore {\n create(input: NewConnectState): Promise<ConnectStateRecord>;\n findByState(state: string): Promise<ConnectStateRecord | null>;\n /**\n * Delete the record exactly once. Resolves `true` for the one caller that\n * removed it and `false` for every other racer.\n */\n consume(record: ConnectStateRecord): Promise<boolean>;\n}\n\n/** Client credentials issued by an OAuth provider's console. */\nexport interface OAuthClientCredentials {\n clientId: string;\n clientSecret: string;\n}\n\n/** Tokens returned by a token endpoint. */\nexport interface OAuthTokenSet {\n accessToken: string;\n refreshToken?: string;\n tokenType?: string;\n /** Absolute expiry of the access token, when the provider reports one. */\n expiresAt?: Date;\n scopes: string[];\n}\n","import {\n ConnectError,\n type OAuthClientCredentials,\n type OAuthTokenSet,\n} from './types.js';\n\n/** A fully resolved OAuth 2.0 authorization-code provider. */\nexport interface OAuth2Endpoints {\n authorizeUrl: string;\n tokenUrl: string;\n userinfoUrl?: string;\n}\n\nexport interface OAuth2ProviderConfig extends OAuth2Endpoints {\n /** Shown in user-facing messages. */\n label: string;\n /** How the client authenticates at the token endpoint. Default `basic`. */\n clientAuth?: 'basic' | 'post';\n /** Extra static authorize parameters, for example `access_type=offline`. */\n authorizeParams?: Record<string, string>;\n}\n\nexport interface OAuth2AuthorizeRequest {\n client: OAuthClientCredentials;\n redirectUri: string;\n state: string;\n scopes: string[];\n codeChallenge?: string;\n}\n\nexport function buildOAuth2AuthorizeUrl(\n config: OAuth2ProviderConfig,\n request: OAuth2AuthorizeRequest,\n): string {\n const url = new URL(config.authorizeUrl);\n url.searchParams.set('response_type', 'code');\n url.searchParams.set('client_id', request.client.clientId);\n url.searchParams.set('redirect_uri', request.redirectUri);\n if (request.scopes.length) {\n url.searchParams.set('scope', request.scopes.join(' '));\n }\n url.searchParams.set('state', request.state);\n if (request.codeChallenge) {\n url.searchParams.set('code_challenge', request.codeChallenge);\n url.searchParams.set('code_challenge_method', 'S256');\n }\n for (const [key, value] of Object.entries(config.authorizeParams ?? {})) {\n url.searchParams.set(key, value);\n }\n return url.toString();\n}\n\ninterface TokenBody {\n access_token?: unknown;\n refresh_token?: unknown;\n token_type?: unknown;\n expires_in?: unknown;\n scope?: unknown;\n}\n\n/** Exchange an authorization code. Never echoes the response body. */\nexport async function exchangeOAuth2Code(\n config: OAuth2ProviderConfig,\n request: {\n client: OAuthClientCredentials;\n redirectUri: string;\n code: string;\n codeVerifier?: string | null;\n fetch: typeof fetch;\n },\n): Promise<OAuthTokenSet> {\n const body = new URLSearchParams({\n grant_type: 'authorization_code',\n code: request.code,\n redirect_uri: request.redirectUri,\n client_id: request.client.clientId,\n });\n if (request.codeVerifier) body.set('code_verifier', request.codeVerifier);\n const headers: Record<string, string> = {\n 'content-type': 'application/x-www-form-urlencoded',\n accept: 'application/json',\n };\n if ((config.clientAuth ?? 'basic') === 'basic') {\n headers.authorization = `Basic ${btoa(\n `${request.client.clientId}:${request.client.clientSecret}`,\n )}`;\n } else {\n body.set('client_secret', request.client.clientSecret);\n }\n const response = await request.fetch(config.tokenUrl, {\n method: 'POST',\n headers,\n body,\n });\n const json = (await response.json().catch(() => null)) as TokenBody | null;\n if (\n !response.ok ||\n typeof json?.access_token !== 'string' ||\n !json.access_token\n ) {\n throw new ConnectError(\n 'token_exchange_failed',\n `${config.label} rejected the authorization code (HTTP ${response.status}).`,\n );\n }\n const tokens: OAuthTokenSet = {\n accessToken: json.access_token,\n tokenType:\n typeof json.token_type === 'string' ? json.token_type : undefined,\n scopes:\n typeof json.scope === 'string' && json.scope ? json.scope.split(' ') : [],\n };\n if (typeof json.refresh_token === 'string' && json.refresh_token) {\n tokens.refreshToken = json.refresh_token;\n }\n if (typeof json.expires_in === 'number') {\n tokens.expiresAt = new Date(Date.now() + json.expires_in * 1000);\n }\n return tokens;\n}\n\n/** OpenID Connect `userinfo` claims the connect flows read. */\nexport interface OidcUserInfo {\n sub: string;\n email?: string;\n preferredUsername?: string;\n name?: string;\n}\n\nexport async function fetchOidcUserInfo(\n config: Pick<OAuth2ProviderConfig, 'label' | 'userinfoUrl'>,\n accessToken: string,\n fetchImpl: typeof fetch,\n): Promise<OidcUserInfo> {\n if (!config.userinfoUrl) {\n throw new ConnectError(\n 'profile_lookup_failed',\n `${config.label} has no userinfo endpoint configured.`,\n );\n }\n const response = await fetchImpl(config.userinfoUrl, {\n headers: {\n authorization: `Bearer ${accessToken}`,\n accept: 'application/json',\n },\n });\n const json = (await response.json().catch(() => null)) as Record<\n string,\n unknown\n > | null;\n if (!response.ok || typeof json?.sub !== 'string' || !json.sub) {\n throw new ConnectError(\n 'profile_lookup_failed',\n `Could not read the ${config.label} profile after connecting (HTTP ${response.status}).`,\n );\n }\n const text = (value: unknown) =>\n typeof value === 'string' && value ? value : undefined;\n return {\n sub: json.sub,\n email: text(json.email),\n preferredUsername: text(json.preferred_username),\n name: text(json.name),\n };\n}\n\nfunction requireHttps(url: unknown, what: string, label: string): string {\n if (typeof url === 'string') {\n try {\n const parsed = new URL(url);\n const local = ['localhost', '127.0.0.1', '[::1]'].includes(\n parsed.hostname,\n );\n if (\n parsed.protocol === 'https:' ||\n (local && parsed.protocol === 'http:')\n ) {\n return parsed.toString();\n }\n } catch {\n // fall through\n }\n }\n throw new ConnectError(\n 'discovery_failed',\n `${label} returned an unusable ${what}.`,\n );\n}\n\n/**\n * Resolve endpoints from an OIDC issuer's discovery document\n * (`/.well-known/openid-configuration`). The document's own `issuer` must equal\n * the configured one, so a hijacked path cannot redirect the flow elsewhere.\n */\nexport async function discoverOidcEndpoints(\n issuer: string,\n label: string,\n fetchImpl: typeof fetch,\n): Promise<OAuth2Endpoints> {\n const base = requireHttps(issuer, 'issuer', label).replace(/\\/$/, '');\n const response = await fetchImpl(`${base}/.well-known/openid-configuration`, {\n headers: { accept: 'application/json' },\n });\n const json = (await response.json().catch(() => null)) as Record<\n string,\n unknown\n > | null;\n if (\n !response.ok ||\n typeof json?.issuer !== 'string' ||\n json.issuer.replace(/\\/$/, '') !== base\n ) {\n throw new ConnectError(\n 'discovery_failed',\n `Could not discover ${label} sign-in endpoints (HTTP ${response.status}).`,\n );\n }\n return {\n authorizeUrl: requireHttps(\n json.authorization_endpoint,\n 'authorization endpoint',\n label,\n ),\n tokenUrl: requireHttps(json.token_endpoint, 'token endpoint', label),\n userinfoUrl: json.userinfo_endpoint\n ? requireHttps(json.userinfo_endpoint, 'userinfo endpoint', label)\n : undefined,\n };\n}\n","import {\n ConnectError,\n type ConnectStateRecord,\n type ConnectStateStore,\n} from './types.js';\n\nexport const DEFAULT_CONNECT_STATE_TTL_MS = 10 * 60 * 1000;\n\nexport function generateConnectState(): string {\n return crypto.randomUUID();\n}\n\n/** A PKCE code verifier (RFC 7636): 64 hex characters. */\nexport function generateCodeVerifier(): string {\n const bytes = new Uint8Array(32);\n crypto.getRandomValues(bytes);\n return Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join(\n '',\n );\n}\n\n/** The S256 code challenge for a verifier. */\nexport async function generateCodeChallenge(verifier: string): Promise<string> {\n const digest = await crypto.subtle.digest(\n 'SHA-256',\n new TextEncoder().encode(verifier),\n );\n return btoa(String.fromCharCode(...new Uint8Array(digest)))\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_')\n .replace(/=/g, '');\n}\n\n/**\n * A same-origin absolute path (`/settings/mail`), never a URL or a\n * protocol-relative or backslash form. Hosts redirect only to this.\n */\nexport function isSafeReturnPath(value: unknown): value is string {\n return (\n typeof value === 'string' &&\n value.length <= 2048 &&\n value.startsWith('/') &&\n !value.startsWith('//') &&\n !value.includes('\\\\') &&\n // biome-ignore lint/suspicious/noControlCharactersInRegex: reject control characters\n !/[\\u0000-\\u001f\\u007f]/.test(value)\n );\n}\n\nexport interface BeginConnectOptions {\n store: ConnectStateStore;\n kind: string;\n tenantId: string;\n userId?: string | null;\n redirectUri: string;\n scopes: string[];\n usesPkce: boolean;\n returnTo?: string | null;\n /** State lifetime in ms. Default 10 minutes. */\n ttlMs?: number;\n}\n\nexport interface BegunConnect {\n state: string;\n codeChallenge?: string;\n}\n\n/** Persist a single-use, tenant- and user-bound state. */\nexport async function beginConnect(\n options: BeginConnectOptions,\n): Promise<BegunConnect> {\n if (options.returnTo != null && !isSafeReturnPath(options.returnTo)) {\n throw new ConnectError(\n 'invalid_return_to',\n 'The return path must be a same-origin path.',\n );\n }\n const state = generateConnectState();\n const codeVerifier = options.usesPkce ? generateCodeVerifier() : null;\n await options.store.create({\n state,\n kind: options.kind,\n codeVerifier,\n redirectUri: options.redirectUri,\n scopes: options.scopes,\n tenantId: options.tenantId,\n initiatedByUserId: options.userId ?? null,\n returnTo: options.returnTo ?? null,\n expiresAt: new Date(\n Date.now() + (options.ttlMs ?? DEFAULT_CONNECT_STATE_TTL_MS),\n ),\n });\n return {\n state,\n codeChallenge: codeVerifier\n ? await generateCodeChallenge(codeVerifier)\n : undefined,\n };\n}\n\nexport interface ConsumeConnectOptions {\n store: ConnectStateStore;\n kind: string;\n tenantId: string;\n userId?: string | null;\n redirectUri: string;\n /** The callback's query parameters. */\n query: { code?: string | null; state?: string | null; error?: string | null };\n /** Used in user-facing messages, for example `X`. */\n label: string;\n}\n\nexport interface ConsumedConnect {\n record: ConnectStateRecord;\n code: string;\n}\n\n/**\n * Verify a callback and burn its state. The state is consumed before anything\n * else, including for a refused grant, so a callback URL cannot be replayed;\n * a mismatched kind, tenant, redirect URI or user is rejected before the\n * state is spent.\n */\nexport async function consumeConnect(\n options: ConsumeConnectOptions,\n): Promise<ConsumedConnect> {\n const { code, state: token, error } = options.query;\n const stored = token ? await options.store.findByState(token) : null;\n if (\n !stored ||\n stored.kind !== options.kind ||\n stored.tenantId !== options.tenantId ||\n stored.redirectUri !== options.redirectUri ||\n (stored.initiatedByUserId !== null &&\n stored.initiatedByUserId !== (options.userId ?? null))\n ) {\n throw new ConnectError(\n 'invalid_state',\n 'This connect link is not valid. Start the connection again.',\n );\n }\n if (!(await options.store.consume(stored))) {\n throw new ConnectError(\n 'invalid_state',\n 'This connect link was already used. Start the connection again.',\n );\n }\n if (Date.now() >= stored.expiresAt.getTime()) {\n throw new ConnectError(\n 'state_expired',\n 'This connect link expired. Start the connection again.',\n );\n }\n if (error) {\n throw new ConnectError(\n error === 'access_denied' ? 'access_denied' : 'provider_error',\n error === 'access_denied'\n ? `${options.label} access was not granted.`\n : `${options.label} returned an error (${error.slice(0, 64)}).`,\n );\n }\n if (!code) {\n throw new ConnectError(\n 'provider_error',\n `${options.label} did not return an authorization code.`,\n );\n }\n return { record: stored, code };\n}\n"],"mappings":";;;;;;;;AAYA,IAAa,yBAAb,cAA4C,eAA6B;CACvE,OAAgB,aAAa;;CAG7B,UAA6B;EAC3B,OAAO;GACL,SAAS,UAAU,KAAK,OAAO,EAAE,GAAG,MAAM,CAAC;GAC3C,cAAc,UAAU,KAAK,YAAY,KAAK;G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from './types.js';
|
|
2
|
+
/** A fully resolved OAuth 2.0 authorization-code provider. */
|
|
3
|
+
export interface OAuth2Endpoints {
|
|
4
|
+
authorizeUrl: string;
|
|
5
|
+
tokenUrl: string;
|
|
6
|
+
userinfoUrl?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface OAuth2ProviderConfig extends OAuth2Endpoints {
|
|
9
|
+
/** Shown in user-facing messages. */
|
|
10
|
+
label: string;
|
|
11
|
+
/** How the client authenticates at the token endpoint. Default `basic`. */
|
|
12
|
+
clientAuth?: 'basic' | 'post';
|
|
13
|
+
/** Extra static authorize parameters, for example `access_type=offline`. */
|
|
14
|
+
authorizeParams?: Record<string, string>;
|
|
15
|
+
}
|
|
16
|
+
export interface OAuth2AuthorizeRequest {
|
|
17
|
+
client: OAuthClientCredentials;
|
|
18
|
+
redirectUri: string;
|
|
19
|
+
state: string;
|
|
20
|
+
scopes: string[];
|
|
21
|
+
codeChallenge?: string;
|
|
22
|
+
}
|
|
23
|
+
export declare function buildOAuth2AuthorizeUrl(config: OAuth2ProviderConfig, request: OAuth2AuthorizeRequest): string;
|
|
24
|
+
/** Exchange an authorization code. Never echoes the response body. */
|
|
25
|
+
export declare function exchangeOAuth2Code(config: OAuth2ProviderConfig, request: {
|
|
26
|
+
client: OAuthClientCredentials;
|
|
27
|
+
redirectUri: string;
|
|
28
|
+
code: string;
|
|
29
|
+
codeVerifier?: string | null;
|
|
30
|
+
fetch: typeof fetch;
|
|
31
|
+
}): Promise<OAuthTokenSet>;
|
|
32
|
+
/** OpenID Connect `userinfo` claims the connect flows read. */
|
|
33
|
+
export interface OidcUserInfo {
|
|
34
|
+
sub: string;
|
|
35
|
+
email?: string;
|
|
36
|
+
preferredUsername?: string;
|
|
37
|
+
name?: string;
|
|
38
|
+
}
|
|
39
|
+
export declare function fetchOidcUserInfo(config: Pick<OAuth2ProviderConfig, 'label' | 'userinfoUrl'>, accessToken: string, fetchImpl: typeof fetch): Promise<OidcUserInfo>;
|
|
40
|
+
/**
|
|
41
|
+
* Resolve endpoints from an OIDC issuer's discovery document
|
|
42
|
+
* (`/.well-known/openid-configuration`). The document's own `issuer` must equal
|
|
43
|
+
* the configured one, so a hijacked path cannot redirect the flow elsewhere.
|
|
44
|
+
*/
|
|
45
|
+
export declare function discoverOidcEndpoints(issuer: string, label: string, fetchImpl: typeof fetch): Promise<OAuth2Endpoints>;
|
|
46
|
+
//# sourceMappingURL=oauth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../src/connect/oauth.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EACnB,MAAM,YAAY,CAAC;AAEpB,8DAA8D;AAC9D,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,oBAAqB,SAAQ,eAAe;IAC3D,qCAAqC;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,2EAA2E;IAC3E,UAAU,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC9B,4EAA4E;IAC5E,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,sBAAsB,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,sBAAsB,GAC9B,MAAM,CAiBR;AAUD,sEAAsE;AACtE,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE;IACP,MAAM,EAAE,sBAAsB,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,KAAK,EAAE,OAAO,KAAK,CAAC;CACrB,GACA,OAAO,CAAC,aAAa,CAAC,CAiDxB;AAED,+DAA+D;AAC/D,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,IAAI,CAAC,oBAAoB,EAAE,OAAO,GAAG,aAAa,CAAC,EAC3D,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,OAAO,KAAK,GACtB,OAAO,CAAC,YAAY,CAAC,CA+BvB;AAyBD;;;;GAIG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,OAAO,KAAK,GACtB,OAAO,CAAC,eAAe,CAAC,CA8B1B"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type ConnectStateRecord, type ConnectStateStore } from './types.js';
|
|
2
|
+
export declare const DEFAULT_CONNECT_STATE_TTL_MS: number;
|
|
3
|
+
export declare function generateConnectState(): string;
|
|
4
|
+
/** A PKCE code verifier (RFC 7636): 64 hex characters. */
|
|
5
|
+
export declare function generateCodeVerifier(): string;
|
|
6
|
+
/** The S256 code challenge for a verifier. */
|
|
7
|
+
export declare function generateCodeChallenge(verifier: string): Promise<string>;
|
|
8
|
+
/**
|
|
9
|
+
* A same-origin absolute path (`/settings/mail`), never a URL or a
|
|
10
|
+
* protocol-relative or backslash form. Hosts redirect only to this.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isSafeReturnPath(value: unknown): value is string;
|
|
13
|
+
export interface BeginConnectOptions {
|
|
14
|
+
store: ConnectStateStore;
|
|
15
|
+
kind: string;
|
|
16
|
+
tenantId: string;
|
|
17
|
+
userId?: string | null;
|
|
18
|
+
redirectUri: string;
|
|
19
|
+
scopes: string[];
|
|
20
|
+
usesPkce: boolean;
|
|
21
|
+
returnTo?: string | null;
|
|
22
|
+
/** State lifetime in ms. Default 10 minutes. */
|
|
23
|
+
ttlMs?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface BegunConnect {
|
|
26
|
+
state: string;
|
|
27
|
+
codeChallenge?: string;
|
|
28
|
+
}
|
|
29
|
+
/** Persist a single-use, tenant- and user-bound state. */
|
|
30
|
+
export declare function beginConnect(options: BeginConnectOptions): Promise<BegunConnect>;
|
|
31
|
+
export interface ConsumeConnectOptions {
|
|
32
|
+
store: ConnectStateStore;
|
|
33
|
+
kind: string;
|
|
34
|
+
tenantId: string;
|
|
35
|
+
userId?: string | null;
|
|
36
|
+
redirectUri: string;
|
|
37
|
+
/** The callback's query parameters. */
|
|
38
|
+
query: {
|
|
39
|
+
code?: string | null;
|
|
40
|
+
state?: string | null;
|
|
41
|
+
error?: string | null;
|
|
42
|
+
};
|
|
43
|
+
/** Used in user-facing messages, for example `X`. */
|
|
44
|
+
label: string;
|
|
45
|
+
}
|
|
46
|
+
export interface ConsumedConnect {
|
|
47
|
+
record: ConnectStateRecord;
|
|
48
|
+
code: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Verify a callback and burn its state. The state is consumed before anything
|
|
52
|
+
* else, including for a refused grant, so a callback URL cannot be replayed;
|
|
53
|
+
* a mismatched kind, tenant, redirect URI or user is rejected before the
|
|
54
|
+
* state is spent.
|
|
55
|
+
*/
|
|
56
|
+
export declare function consumeConnect(options: ConsumeConnectOptions): Promise<ConsumedConnect>;
|
|
57
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/connect/state.ts"],"names":[],"m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AAM,GAAG,IAAI,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAC9E,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,eAAe,CAAC,CA2C1B"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider-neutral credential connect: shared contracts.
|
|
3
|
+
*
|
|
4
|
+
* "Connect" is how a credential reaches smrt-secrets for an external account
|
|
5
|
+
* a user owns: an OAuth 2.0 / OIDC redirect flow, or a write-only secret the
|
|
6
|
+
* user types (an app password, handled by the owning package). This kernel
|
|
7
|
+
* owns what every flow shares, the single-use state record, PKCE, a safe
|
|
8
|
+
* return path, generic OAuth 2.0 / OIDC provider mechanics and one error type.
|
|
9
|
+
* smrt-social and smrt-messages each bring their own account upsert.
|
|
10
|
+
*/
|
|
11
|
+
export type ConnectErrorCode = 'unsupported_provider' | 'missing_client_credentials' | 'missing_tenant' | 'invalid_state' | 'state_expired' | 'access_denied' | 'provider_error' | 'token_exchange_failed' | 'profile_lookup_failed' | 'discovery_failed' | 'invalid_return_to' | 'forbidden';
|
|
12
|
+
/**
|
|
13
|
+
* Raised for every connect failure. Messages are safe to show to a user and
|
|
14
|
+
* never contain tokens, codes or client secrets.
|
|
15
|
+
*/
|
|
16
|
+
export declare class ConnectError<Code extends string = ConnectErrorCode> extends Error {
|
|
17
|
+
readonly code: Code;
|
|
18
|
+
constructor(code: Code, message: string);
|
|
19
|
+
}
|
|
20
|
+
/** The persisted facts of one in-flight connect. */
|
|
21
|
+
export interface ConnectStateRecord {
|
|
22
|
+
/** The unguessable value round-tripped through the provider. */
|
|
23
|
+
state: string;
|
|
24
|
+
/** Which provider/flow this state belongs to. */
|
|
25
|
+
kind: string;
|
|
26
|
+
codeVerifier: string | null;
|
|
27
|
+
redirectUri: string;
|
|
28
|
+
scopes: string[];
|
|
29
|
+
tenantId: string | null;
|
|
30
|
+
/** The signed-in user who started the connect. */
|
|
31
|
+
initiatedByUserId: string | null;
|
|
32
|
+
/** Same-origin path to return to after the callback. */
|
|
33
|
+
returnTo?: string | null;
|
|
34
|
+
expiresAt: Date;
|
|
35
|
+
}
|
|
36
|
+
export type NewConnectState = ConnectStateRecord;
|
|
37
|
+
/**
|
|
38
|
+
* Where a package keeps its connect states. smrt-secrets ships
|
|
39
|
+
* `ConnectStateCollection` for new flows; smrt-social adapts its own
|
|
40
|
+
* `OAuthState` table to the same contract.
|
|
41
|
+
*/
|
|
42
|
+
export interface ConnectStateStore {
|
|
43
|
+
create(input: NewConnectState): Promise<ConnectStateRecord>;
|
|
44
|
+
findByState(state: string): Promise<ConnectStateRecord | null>;
|
|
45
|
+
/**
|
|
46
|
+
* Delete the record exactly once. Resolves `true` for the one caller that
|
|
47
|
+
* removed it and `false` for every other racer.
|
|
48
|
+
*/
|
|
49
|
+
consume(record: ConnectStateRecord): Promise<boolean>;
|
|
50
|
+
}
|
|
51
|
+
/** Client credentials issued by an OAuth provider's console. */
|
|
52
|
+
export interface OAuthClientCredentials {
|
|
53
|
+
clientId: string;
|
|
54
|
+
clientSecret: string;
|
|
55
|
+
}
|
|
56
|
+
/** Tokens returned by a token endpoint. */
|
|
57
|
+
export interface OAuthTokenSet {
|
|
58
|
+
accessToken: string;
|
|
59
|
+
refreshToken?: string;
|
|
60
|
+
tokenType?: string;
|
|
61
|
+
/** Absolute expiry of the access token, when the provider reports one. */
|
|
62
|
+
expiresAt?: Date;
|
|
63
|
+
scopes: string[];
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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,CAAC;CACvD;AAED,gEAAgE;AAChE,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,2CAA2C;AAC3C,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0EAA0E;IAC1E,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import "./chunks/dist-kZ2KUDiZ.js";
|
|
2
|
+
import { i as createAuditEntry, n as Secret, r as SecretAuditLog, t as TenantKey } from "./chunks/TenantKey-p_gp_teA.js";
|
|
3
|
+
import { a as SecretAuditLogCollection, i as SecretCollection, n as SecretService, r as TenantKeyCollection, t as SecretKeyDriftError } from "./chunks/SecretService-DyzsJCio.js";
|
|
3
4
|
import { AMKUnavailableError, DecryptionError, EncryptionError, InvalidKeyFormatError, KeyNotFoundError, KeyRotationError, SecretError, StoreNotInitializedError, TenantKeyMissingError } from "@happyvertical/secrets";
|
|
4
5
|
//#region src/index.ts
|
|
5
6
|
/** @internal */
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * @happyvertical/smrt-secrets\n *\n * Per-tenant secret management with envelope encryption for SMRT.\n *\n * @example\n * ```typescript\n * import { SecretService } from '@happyvertical/smrt-secrets';\n * import { withTenant } from '@happyvertical/smrt-tenancy';\n * import { getDatabase } from '@happyvertical/sql';\n *\n * // Create database connection\n * const db = await getDatabase({ type: 'sqlite', url: 'app.db' });\n *\n * // Create secret service\n * const service = await SecretService.create({ db });\n *\n * // Use within tenant context\n * await withTenant({ tenantId: 'tenant-123' }, async () => {\n * // Store a secret\n * await service.store('api-key', 'sk_live_xxx', {\n * category: 'stripe',\n * description: 'Production API key'\n * });\n *\n * // Retrieve the secret\n * const { value } = await service.retrieve('api-key');\n * console.log(value); // 'sk_live_xxx'\n *\n * // List secrets (names only)\n * const secrets = await service.list();\n *\n * // Rotate encryption key\n * await service.rotateKey();\n *\n * // Delete a secret\n * await service.delete('api-key');\n * });\n * ```\n *\n * @packageDocumentation\n */\n\n// Self-register this package's manifest before any @smrt() decorator fires\n// downstream. Must come first so the side effect runs ahead of the class\n// module loads below. See __smrt-register__.ts for issue #1132 context.\nimport './__smrt-register__.js';\n\n// Re-export SDK types for convenience\nexport type {\n ApplicationMasterKey,\n EncryptedEnvelope,\n SecretStore,\n TenantDataEncryptionKey,\n} from '@happyvertical/secrets';\n// Re-export SDK errors\nexport {\n AMKUnavailableError,\n DecryptionError,\n EncryptionError,\n InvalidKeyFormatError,\n KeyNotFoundError,\n KeyRotationError,\n SecretError,\n StoreNotInitializedError,\n TenantKeyMissingError,\n} from '@happyvertical/secrets';\n// Collections\nexport {\n type ListAuditLogsOptions,\n SecretAuditLogCollection,\n} from './collections/SecretAuditLogCollection.js';\nexport {\n type ListSecretsOptions,\n SecretCollection,\n} from './collections/SecretCollection.js';\nexport { TenantKeyCollection } from './collections/TenantKeyCollection.js';\n\n// Models\nexport {\n Secret,\n type SecretStatus,\n} from './models/Secret.js';\nexport {\n createAuditEntry,\n type SecretAuditAction,\n SecretAuditLog,\n type SecretAuditResult,\n} from './models/SecretAuditLog.js';\nexport {\n TenantKey,\n type TenantKeyStatus,\n} from './models/TenantKey.js';\n// Service\nexport {\n type DeleteSecretOptions,\n type DiagnoseTenantSecretKeyDriftOptions,\n type RepairTenantSecretKeyDriftOptions,\n type RetrievedSecret,\n SecretKeyDriftError,\n type SecretKeyDriftIssue,\n type SecretKeyDriftIssueCode,\n type SecretKeyDriftIssueSeverity,\n type SecretKeyDriftRepairAction,\n type SecretKeyDriftRepairResult,\n type SecretKeyDriftReport,\n type SecretMasterKeyProvider,\n SecretService,\n type SecretServiceOptions,\n type StoreSecretOptions,\n} from './services/SecretService.js';\n\n/** @internal */\nexport const PACKAGE_VERSION_INITIALIZED = true;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * @happyvertical/smrt-secrets\n *\n * Per-tenant secret management with envelope encryption for SMRT.\n *\n * @example\n * ```typescript\n * import { SecretService } from '@happyvertical/smrt-secrets';\n * import { withTenant } from '@happyvertical/smrt-tenancy';\n * import { getDatabase } from '@happyvertical/sql';\n *\n * // Create database connection\n * const db = await getDatabase({ type: 'sqlite', url: 'app.db' });\n *\n * // Create secret service\n * const service = await SecretService.create({ db });\n *\n * // Use within tenant context\n * await withTenant({ tenantId: 'tenant-123' }, async () => {\n * // Store a secret\n * await service.store('api-key', 'sk_live_xxx', {\n * category: 'stripe',\n * description: 'Production API key'\n * });\n *\n * // Retrieve the secret\n * const { value } = await service.retrieve('api-key');\n * console.log(value); // 'sk_live_xxx'\n *\n * // List secrets (names only)\n * const secrets = await service.list();\n *\n * // Rotate encryption key\n * await service.rotateKey();\n *\n * // Delete a secret\n * await service.delete('api-key');\n * });\n * ```\n *\n * @packageDocumentation\n */\n\n// Self-register this package's manifest before any @smrt() decorator fires\n// downstream. Must come first so the side effect runs ahead of the class\n// module loads below. See __smrt-register__.ts for issue #1132 context.\nimport './__smrt-register__.js';\n\n// Re-export SDK types for convenience\nexport type {\n ApplicationMasterKey,\n EncryptedEnvelope,\n SecretStore,\n TenantDataEncryptionKey,\n} from '@happyvertical/secrets';\n// Re-export SDK errors\nexport {\n AMKUnavailableError,\n DecryptionError,\n EncryptionError,\n InvalidKeyFormatError,\n KeyNotFoundError,\n KeyRotationError,\n SecretError,\n StoreNotInitializedError,\n TenantKeyMissingError,\n} from '@happyvertical/secrets';\n// Collections\nexport {\n type ListAuditLogsOptions,\n SecretAuditLogCollection,\n} from './collections/SecretAuditLogCollection.js';\nexport {\n type ListSecretsOptions,\n SecretCollection,\n} from './collections/SecretCollection.js';\nexport { TenantKeyCollection } from './collections/TenantKeyCollection.js';\n\n// Models\nexport {\n Secret,\n type SecretStatus,\n} from './models/Secret.js';\nexport {\n createAuditEntry,\n type SecretAuditAction,\n SecretAuditLog,\n type SecretAuditResult,\n} from './models/SecretAuditLog.js';\nexport {\n TenantKey,\n type TenantKeyStatus,\n} from './models/TenantKey.js';\n// Service\nexport {\n type DeleteSecretOptions,\n type DiagnoseTenantSecretKeyDriftOptions,\n type RepairTenantSecretKeyDriftOptions,\n type RetrievedSecret,\n SecretKeyDriftError,\n type SecretKeyDriftIssue,\n type SecretKeyDriftIssueCode,\n type SecretKeyDriftIssueSeverity,\n type SecretKeyDriftRepairAction,\n type SecretKeyDriftRepairResult,\n type SecretKeyDriftReport,\n type SecretMasterKeyProvider,\n SecretService,\n type SecretServiceOptions,\n type StoreSecretOptions,\n} from './services/SecretService.js';\n\n/** @internal */\nexport const PACKAGE_VERSION_INITIALIZED = true;\n"],"mappings":";;;;;;AAiHA,IAAa,8BAA8B"}
|