@alteran/astro 0.8.1 → 0.8.3
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/index.d.ts +1 -1
- package/index.js +38 -3
- package/package.json +1 -1
- package/src/env.d.ts +1 -4
- package/src/lib/secrets.ts +1 -1
- package/types/public-env.d.ts +63 -0
- package/types/env.d.ts +0 -81
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -83,6 +83,43 @@ const pkgRoot = new URL('.', import.meta.url);
|
|
|
83
83
|
|
|
84
84
|
const resolvePackagePath = (relative) => fileURLToPath(new URL(relative, pkgRoot));
|
|
85
85
|
|
|
86
|
+
const replaceRequired = (content, search, replacement) => {
|
|
87
|
+
if (!content.includes(search)) {
|
|
88
|
+
throw new Error(`[alteran] Unable to derive injected env types: missing marker "${search}"`);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return content.replace(search, replacement);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const buildInjectedEnvTypes = () => {
|
|
95
|
+
const publicEnvTypes = readFileSync(resolvePackagePath('./types/public-env.d.ts'), 'utf-8');
|
|
96
|
+
const ambientEnvTypes = [
|
|
97
|
+
['export type Env = {', 'type AlteranEnv = {'],
|
|
98
|
+
['export type PdsLocals = {', 'type AlteranPdsLocals = {'],
|
|
99
|
+
['env: Env;', 'env: AlteranEnv;'],
|
|
100
|
+
].reduce(
|
|
101
|
+
(content, [search, replacement]) => replaceRequired(content, search, replacement),
|
|
102
|
+
publicEnvTypes
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
return `/// <reference types="astro/client" />
|
|
106
|
+
|
|
107
|
+
${ambientEnvTypes}
|
|
108
|
+
|
|
109
|
+
declare global {
|
|
110
|
+
interface Env extends AlteranEnv {}
|
|
111
|
+
|
|
112
|
+
namespace App {
|
|
113
|
+
interface Locals extends AlteranPdsLocals {}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export type Env = globalThis.Env;
|
|
118
|
+
export type PdsLocals = globalThis.App.Locals;
|
|
119
|
+
export {};
|
|
120
|
+
`;
|
|
121
|
+
};
|
|
122
|
+
|
|
86
123
|
export default function alteran(options = {}) {
|
|
87
124
|
const {
|
|
88
125
|
debugRoutes = false,
|
|
@@ -213,9 +250,7 @@ export default function alteran(options = {}) {
|
|
|
213
250
|
},
|
|
214
251
|
|
|
215
252
|
'astro:config:done'({ config, injectTypes, logger }) {
|
|
216
|
-
|
|
217
|
-
const envTypes = readFileSync(envTypesPath, 'utf-8');
|
|
218
|
-
injectTypes({ filename: 'astro-cloudflare-pds.d.ts', content: envTypes });
|
|
253
|
+
injectTypes({ filename: 'astro-cloudflare-pds.d.ts', content: buildInjectedEnvTypes() });
|
|
219
254
|
|
|
220
255
|
const adapterName = config.adapter?.name ?? 'unknown adapter';
|
|
221
256
|
if (!adapterName.toLowerCase().includes('cloudflare')) {
|
package/package.json
CHANGED
package/src/env.d.ts
CHANGED
package/src/lib/secrets.ts
CHANGED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
D1Database,
|
|
3
|
+
DurableObjectNamespace,
|
|
4
|
+
ExecutionContext,
|
|
5
|
+
R2Bucket,
|
|
6
|
+
} from "@cloudflare/workers-types";
|
|
7
|
+
|
|
8
|
+
export type SecretsStoreSecret = {
|
|
9
|
+
get(): Promise<string>;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type Env = {
|
|
13
|
+
ALTERAN_DB: D1Database;
|
|
14
|
+
ALTERAN_BLOBS: R2Bucket;
|
|
15
|
+
ALTERAN_SEQUENCER?: DurableObjectNamespace;
|
|
16
|
+
ASSETS?: {
|
|
17
|
+
fetch: (request: Request | string) => Promise<Response>;
|
|
18
|
+
};
|
|
19
|
+
PDS_HANDLE?: string | SecretsStoreSecret;
|
|
20
|
+
PDS_DID?: string | SecretsStoreSecret;
|
|
21
|
+
PDS_HOSTNAME?: string;
|
|
22
|
+
PDS_EMAIL?: string;
|
|
23
|
+
PDS_ALLOWED_MIME?: string;
|
|
24
|
+
USER_PASSWORD?: string | SecretsStoreSecret;
|
|
25
|
+
PDS_MAX_BLOB_SIZE?: string;
|
|
26
|
+
PDS_BLOB_QUOTA_BYTES?: string;
|
|
27
|
+
REFRESH_TOKEN?: string | SecretsStoreSecret;
|
|
28
|
+
REFRESH_TOKEN_SECRET?: string | SecretsStoreSecret;
|
|
29
|
+
SESSION_JWT_SECRET?: string | SecretsStoreSecret;
|
|
30
|
+
PDS_ACCESS_TTL_SEC?: string;
|
|
31
|
+
PDS_REFRESH_TTL_SEC?: string;
|
|
32
|
+
REPO_SIGNING_KEY?: string | SecretsStoreSecret;
|
|
33
|
+
PDS_PLC_ROTATION_KEY?: string | SecretsStoreSecret;
|
|
34
|
+
PDS_RATE_LIMIT_PER_MIN?: string;
|
|
35
|
+
PDS_MAX_JSON_BYTES?: string;
|
|
36
|
+
PDS_CORS_ORIGIN?: string;
|
|
37
|
+
PDS_SEQ_WINDOW?: string;
|
|
38
|
+
PDS_WS_HIBERNATE?: string;
|
|
39
|
+
ENVIRONMENT?: string;
|
|
40
|
+
PDS_BSKY_APP_VIEW_URL?: string;
|
|
41
|
+
PDS_BSKY_APP_VIEW_DID?: string;
|
|
42
|
+
PDS_BSKY_APP_VIEW_CDN_URL_PATTERN?: string;
|
|
43
|
+
PDS_APPVIEW_FORCE_FALLBACK?: string;
|
|
44
|
+
PDS_BSKY_CHAT_URL?: string;
|
|
45
|
+
PDS_BSKY_CHAT_DID?: string;
|
|
46
|
+
PDS_OZONE_URL?: string;
|
|
47
|
+
PDS_OZONE_DID?: string;
|
|
48
|
+
PDS_LINK_PRIVACY?: string;
|
|
49
|
+
PDS_LINK_TOS?: string;
|
|
50
|
+
PDS_CONTACT_EMAIL?: string;
|
|
51
|
+
PDS_RELAY_HOSTS?: string;
|
|
52
|
+
PDS_RELAY_NOTIFY?: string;
|
|
53
|
+
PDS_OAUTH_CLIENT_HOSTS?: string;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export type PdsLocals = {
|
|
57
|
+
runtime: {
|
|
58
|
+
env: Env;
|
|
59
|
+
ctx: ExecutionContext;
|
|
60
|
+
request: Request;
|
|
61
|
+
};
|
|
62
|
+
requestId?: string;
|
|
63
|
+
};
|
package/types/env.d.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/// <reference types="astro/client" />
|
|
2
|
-
|
|
3
|
-
import type {
|
|
4
|
-
D1Database,
|
|
5
|
-
DurableObjectNamespace,
|
|
6
|
-
ExecutionContext,
|
|
7
|
-
R2Bucket,
|
|
8
|
-
} from "@cloudflare/workers-types";
|
|
9
|
-
|
|
10
|
-
// Minimal Secret Store binding interface. Cloudflare exposes each bound secret
|
|
11
|
-
// as an object with an async `get()` that returns the secret value.
|
|
12
|
-
// If @cloudflare/workers-types defines this already, our local type is compatible.
|
|
13
|
-
export interface SecretsStoreSecret {
|
|
14
|
-
get(): Promise<string>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
declare global {
|
|
18
|
-
interface Env {
|
|
19
|
-
ALTERAN_DB: D1Database;
|
|
20
|
-
ALTERAN_BLOBS: R2Bucket;
|
|
21
|
-
ALTERAN_SEQUENCER?: DurableObjectNamespace;
|
|
22
|
-
ASSETS?: {
|
|
23
|
-
fetch: (req: Request | string) => Promise<Response>;
|
|
24
|
-
};
|
|
25
|
-
// Secrets can be provided either as Wrangler Secrets (string)
|
|
26
|
-
// or via Secret Store bindings (SecretsStoreSecret).
|
|
27
|
-
PDS_HANDLE?: string | SecretsStoreSecret;
|
|
28
|
-
PDS_DID?: string | SecretsStoreSecret;
|
|
29
|
-
PDS_HOSTNAME?: string;
|
|
30
|
-
PDS_EMAIL?: string;
|
|
31
|
-
PDS_ALLOWED_MIME?: string;
|
|
32
|
-
USER_PASSWORD?: string | SecretsStoreSecret;
|
|
33
|
-
PDS_MAX_BLOB_SIZE?: string;
|
|
34
|
-
PDS_BLOB_QUOTA_BYTES?: string;
|
|
35
|
-
REFRESH_TOKEN?: string | SecretsStoreSecret;
|
|
36
|
-
REFRESH_TOKEN_SECRET?: string | SecretsStoreSecret;
|
|
37
|
-
SESSION_JWT_SECRET?: string | SecretsStoreSecret;
|
|
38
|
-
PDS_ACCESS_TTL_SEC?: string;
|
|
39
|
-
PDS_REFRESH_TTL_SEC?: string;
|
|
40
|
-
// secp256k1 signing private key (hex or base64 32 bytes) used for commits and service-auth
|
|
41
|
-
REPO_SIGNING_KEY?: string | SecretsStoreSecret;
|
|
42
|
-
PDS_PLC_ROTATION_KEY?: string | SecretsStoreSecret;
|
|
43
|
-
PDS_RATE_LIMIT_PER_MIN?: string;
|
|
44
|
-
PDS_MAX_JSON_BYTES?: string;
|
|
45
|
-
PDS_CORS_ORIGIN?: string;
|
|
46
|
-
PDS_SEQ_WINDOW?: string;
|
|
47
|
-
PDS_WS_HIBERNATE?: string;
|
|
48
|
-
ENVIRONMENT?: string;
|
|
49
|
-
PDS_BSKY_APP_VIEW_URL?: string;
|
|
50
|
-
PDS_BSKY_APP_VIEW_DID?: string;
|
|
51
|
-
PDS_BSKY_APP_VIEW_CDN_URL_PATTERN?: string;
|
|
52
|
-
PDS_APPVIEW_FORCE_FALLBACK?: string;
|
|
53
|
-
PDS_BSKY_CHAT_URL?: string;
|
|
54
|
-
PDS_BSKY_CHAT_DID?: string;
|
|
55
|
-
PDS_OZONE_URL?: string;
|
|
56
|
-
PDS_OZONE_DID?: string;
|
|
57
|
-
PDS_LINK_PRIVACY?: string;
|
|
58
|
-
PDS_LINK_TOS?: string;
|
|
59
|
-
PDS_CONTACT_EMAIL?: string;
|
|
60
|
-
// Relay crawl configuration
|
|
61
|
-
PDS_RELAY_HOSTS?: string; // CSV of relay hostnames (no scheme). Default: bsky.network
|
|
62
|
-
PDS_RELAY_NOTIFY?: string; // 'false' to disable auto notify
|
|
63
|
-
PDS_OAUTH_CLIENT_HOSTS?: string; // CSV of trusted OAuth client metadata/JWKS hostnames
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
namespace App {
|
|
67
|
-
interface Locals {
|
|
68
|
-
runtime: {
|
|
69
|
-
env: Env;
|
|
70
|
-
ctx: ExecutionContext;
|
|
71
|
-
request: Request;
|
|
72
|
-
};
|
|
73
|
-
requestId?: string;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export {};
|
|
79
|
-
|
|
80
|
-
export type Env = globalThis.Env;
|
|
81
|
-
export type PdsLocals = globalThis.App.Locals;
|