@pithy-sh/auth 0.1.6 → 0.2.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/dist/capability.d.ts.map +1 -1
- package/dist/capability.js +2 -1
- package/dist/instance/secrets.d.ts +28 -0
- package/dist/instance/secrets.d.ts.map +1 -1
- package/dist/instance/secrets.js +36 -1
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +1 -1
- package/package.json +14 -10
- package/src/capability.ts +6 -1
- package/src/instance/secrets.ts +40 -0
- package/src/version.generated.ts +1 -1
package/dist/capability.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../src/capability.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAmB,MAAM,0CAA0C,CAAC;AAG5F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAGtE,OAAO,EAA0B,KAAK,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACnG,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA2BxB,mGAAmG;AACnG,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;iBAsE8B,CAAC;AACtD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC;AACrD,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEzD;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,UAAU,CAAC;IACnB,sGAAsG;IACtG,YAAY,EAAE,eAAe,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;IACrD,6FAA6F;IAC7F,SAAS,EAAE;QAAE,IAAI,EAAE,aAAa,CAAA;KAAE,GAAG,SAAS,CAAC;CAChD;AAED,6EAA6E;AAC7E,MAAM,WAAW,cAAe,SAAQ,UAAU;IAChD,UAAU,EAAE,UAAU,CAAC;CACxB;AAiCD;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,MAAM,EAAE,eAAe,GAAG,cAAc,
|
|
1
|
+
{"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../src/capability.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAmB,MAAM,0CAA0C,CAAC;AAG5F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAGtE,OAAO,EAA0B,KAAK,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACnG,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA2BxB,mGAAmG;AACnG,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;iBAsE8B,CAAC;AACtD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC;AACrD,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEzD;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,UAAU,CAAC;IACnB,sGAAsG;IACtG,YAAY,EAAE,eAAe,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;IACrD,6FAA6F;IAC7F,SAAS,EAAE;QAAE,IAAI,EAAE,aAAa,CAAA;KAAE,GAAG,SAAS,CAAC;CAChD;AAED,6EAA6E;AAC7E,MAAM,WAAW,cAAe,SAAQ,UAAU;IAChD,UAAU,EAAE,UAAU,CAAC;CACxB;AAiCD;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,MAAM,EAAE,eAAe,GAAG,cAAc,CAoI5D;AAED,0DAA0D;AAC1D,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,IAAI,cAAc,CAErF"}
|
package/dist/capability.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
import { authTables } from "./data/tables.js";
|
|
4
4
|
import { publishSameOrigin } from "./http/csrf.js";
|
|
5
|
-
import { authSecretsRegistry } from "./instance/secrets.js";
|
|
5
|
+
import { authSecretsRegistry, inapplicableProviderSecrets } from "./instance/secrets.js";
|
|
6
6
|
import { authDevSessionSeed } from "./seeds/devSession.js";
|
|
7
7
|
import { AuthPlugin, assertAdditivePlugins } from "./instance/plugins.js";
|
|
8
8
|
import { registerDevLoginRoute } from "./http/devLoginRoute.js";
|
|
@@ -89,6 +89,7 @@ function auth(config) {
|
|
|
89
89
|
config: AuthConfig,
|
|
90
90
|
dependsOn: ["secrets", "email"],
|
|
91
91
|
secretRegistry: authSecretsRegistry,
|
|
92
|
+
inapplicableSecrets: inapplicableProviderSecrets(resolved),
|
|
92
93
|
requiredBindings: [{
|
|
93
94
|
type: "d1",
|
|
94
95
|
name: resolved.database
|
|
@@ -152,6 +152,33 @@ export declare const authSecretsRegistry: {
|
|
|
152
152
|
};
|
|
153
153
|
};
|
|
154
154
|
};
|
|
155
|
+
/**
|
|
156
|
+
* Which provider a credential belongs to — the join the CLI must never make by spelling (#541).
|
|
157
|
+
*
|
|
158
|
+
* `auth-apple-credentials` and the `apple` config key look like each other and that is a coincidence:
|
|
159
|
+
* nothing makes a secret name and a config key the same thing, and a reporting command that matched
|
|
160
|
+
* them by substring would be right by luck. Stated here, once, beside both.
|
|
161
|
+
*/
|
|
162
|
+
declare const PROVIDER_CREDENTIALS: readonly [readonly ["google", "auth-google-credentials"], readonly ["apple", "auth-apple-credentials"], readonly ["facebook", "auth-facebook-credentials"], readonly ["github", "auth-github-credentials"]];
|
|
163
|
+
/** The four toggles this reads off the resolved `AuthConfig` — nothing else about it is its business. */
|
|
164
|
+
export type AuthProviderToggles = Record<(typeof PROVIDER_CREDENTIALS)[number][0], {
|
|
165
|
+
enabled: boolean;
|
|
166
|
+
}>;
|
|
167
|
+
/**
|
|
168
|
+
* **The provider credentials this composition cannot reach**, as the `inapplicableSecrets` contribution.
|
|
169
|
+
*
|
|
170
|
+
* Auth declares four credentials whether or not a project runs four providers, so a project on Google
|
|
171
|
+
* and GitHub carries two secrets nothing will ever read. `pithy doctor` asked for them every run under
|
|
172
|
+
* *"fine to leave until you need it"* — softening, not silence, and "until you need it" is wrong about a
|
|
173
|
+
* provider the configuration has not enabled.
|
|
174
|
+
*
|
|
175
|
+
* **The session secret is never in here**, and that is the line this draws: it is read on every sign-in
|
|
176
|
+
* whatever the providers are, so it is outstanding work in every project that has not set it.
|
|
177
|
+
*
|
|
178
|
+
* The reason names the call an adopter would edit, because the point is to answer *what would I have to
|
|
179
|
+
* do to turn this on* as well as *why am I being shown this*.
|
|
180
|
+
*/
|
|
181
|
+
export declare function inapplicableProviderSecrets(providers: AuthProviderToggles): Record<string, string>;
|
|
155
182
|
/** Resolve the Better Auth session secret for this invocation. */
|
|
156
183
|
export declare function resolveSessionSecret(env: SecretsStoreEnv): Promise<string>;
|
|
157
184
|
/** Resolve the Google OAuth credential pair for this invocation (only call when Google is enabled). */
|
|
@@ -162,4 +189,5 @@ export declare function resolveAppleCredentials(env: SecretsStoreEnv): Promise<A
|
|
|
162
189
|
export declare function resolveFacebookCredentials(env: SecretsStoreEnv): Promise<FacebookOAuthCredentials>;
|
|
163
190
|
/** Resolve the GitHub OAuth credential pair for this invocation (only call when GitHub is enabled). */
|
|
164
191
|
export declare function resolveGithubCredentials(env: SecretsStoreEnv): Promise<GithubOAuthCredentials>;
|
|
192
|
+
export {};
|
|
165
193
|
//# sourceMappingURL=secrets.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../../src/instance/secrets.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAG1E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,mBAAmB,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsD9B,CAAC;AAEH;;;;;;GAMG;AACH,QAAA,MAAM,oBAAoB,sBACvB,QAAQ,wCACR,OAAO,uCACP,UAAU,0CACV,QAAQ,6BACD,CAAC;AAEX,yGAAyG;AACzG,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAEzG;;;;;;;;;;;;;GAaG;AACH,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAOlG;AAED,kEAAkE;AAClE,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAGhF;AAED,uGAAuG;AACvG,wBAAsB,wBAAwB,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAGpG;AAED,mGAAmG;AACnG,wBAAsB,uBAAuB,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAGlG;AAED,2GAA2G;AAC3G,wBAAsB,0BAA0B,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAGxG;AAED,uGAAuG;AACvG,wBAAsB,wBAAwB,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAGpG"}
|
package/dist/instance/secrets.js
CHANGED
|
@@ -147,6 +147,41 @@ const authSecretsRegistry = defineSecretRegistry({
|
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
});
|
|
150
|
+
/**
|
|
151
|
+
* Which provider a credential belongs to — the join the CLI must never make by spelling (#541).
|
|
152
|
+
*
|
|
153
|
+
* `auth-apple-credentials` and the `apple` config key look like each other and that is a coincidence:
|
|
154
|
+
* nothing makes a secret name and a config key the same thing, and a reporting command that matched
|
|
155
|
+
* them by substring would be right by luck. Stated here, once, beside both.
|
|
156
|
+
*/
|
|
157
|
+
const PROVIDER_CREDENTIALS = [
|
|
158
|
+
["google", AUTH_GOOGLE_CREDENTIALS],
|
|
159
|
+
["apple", AUTH_APPLE_CREDENTIALS],
|
|
160
|
+
["facebook", AUTH_FACEBOOK_CREDENTIALS],
|
|
161
|
+
["github", AUTH_GITHUB_CREDENTIALS]
|
|
162
|
+
];
|
|
163
|
+
/**
|
|
164
|
+
* **The provider credentials this composition cannot reach**, as the `inapplicableSecrets` contribution.
|
|
165
|
+
*
|
|
166
|
+
* Auth declares four credentials whether or not a project runs four providers, so a project on Google
|
|
167
|
+
* and GitHub carries two secrets nothing will ever read. `pithy doctor` asked for them every run under
|
|
168
|
+
* *"fine to leave until you need it"* — softening, not silence, and "until you need it" is wrong about a
|
|
169
|
+
* provider the configuration has not enabled.
|
|
170
|
+
*
|
|
171
|
+
* **The session secret is never in here**, and that is the line this draws: it is read on every sign-in
|
|
172
|
+
* whatever the providers are, so it is outstanding work in every project that has not set it.
|
|
173
|
+
*
|
|
174
|
+
* The reason names the call an adopter would edit, because the point is to answer *what would I have to
|
|
175
|
+
* do to turn this on* as well as *why am I being shown this*.
|
|
176
|
+
*/
|
|
177
|
+
function inapplicableProviderSecrets(providers) {
|
|
178
|
+
const declared = {};
|
|
179
|
+
for (const [provider, secret] of PROVIDER_CREDENTIALS) {
|
|
180
|
+
if (providers[provider].enabled) continue;
|
|
181
|
+
declared[secret] = `auth() does not enable the ${provider} provider`;
|
|
182
|
+
}
|
|
183
|
+
return declared;
|
|
184
|
+
}
|
|
150
185
|
/** Resolve the Better Auth session secret for this invocation. */
|
|
151
186
|
async function resolveSessionSecret(env) {
|
|
152
187
|
return (await sharedSecretsStore(env, authSecretsRegistry)).get(AUTH_SESSION_SECRET);
|
|
@@ -168,4 +203,4 @@ async function resolveGithubCredentials(env) {
|
|
|
168
203
|
return (await sharedSecretsStore(env, authSecretsRegistry)).get(AUTH_GITHUB_CREDENTIALS);
|
|
169
204
|
}
|
|
170
205
|
//#endregion
|
|
171
|
-
export { AUTH_APPLE_CREDENTIALS, AUTH_FACEBOOK_CREDENTIALS, AUTH_GITHUB_CREDENTIALS, AUTH_GOOGLE_CREDENTIALS, AUTH_SESSION_SECRET, AppleOAuthCredentials, FacebookOAuthCredentials, GithubOAuthCredentials, GoogleOAuthCredentials, authSecretsRegistry, resolveAppleCredentials, resolveFacebookCredentials, resolveGithubCredentials, resolveGoogleCredentials, resolveSessionSecret };
|
|
206
|
+
export { AUTH_APPLE_CREDENTIALS, AUTH_FACEBOOK_CREDENTIALS, AUTH_GITHUB_CREDENTIALS, AUTH_GOOGLE_CREDENTIALS, AUTH_SESSION_SECRET, AppleOAuthCredentials, FacebookOAuthCredentials, GithubOAuthCredentials, GoogleOAuthCredentials, authSecretsRegistry, inapplicableProviderSecrets, resolveAppleCredentials, resolveFacebookCredentials, resolveGithubCredentials, resolveGoogleCredentials, resolveSessionSecret };
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
/** This package's npm name — the join key against a release feed. */
|
|
4
4
|
export declare const PACKAGE_NAME = "@pithy-sh/auth";
|
|
5
5
|
/** This package's version, stamped from its own package.json at generation time. */
|
|
6
|
-
export declare const PACKAGE_VERSION = "0.
|
|
6
|
+
export declare const PACKAGE_VERSION = "0.2.0";
|
|
7
7
|
//# sourceMappingURL=version.generated.d.ts.map
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
/** This package's npm name — the join key against a release feed. */
|
|
5
5
|
const PACKAGE_NAME = "@pithy-sh/auth";
|
|
6
6
|
/** This package's version, stamped from its own package.json at generation time. */
|
|
7
|
-
const PACKAGE_VERSION = "0.
|
|
7
|
+
const PACKAGE_VERSION = "0.2.0";
|
|
8
8
|
//#endregion
|
|
9
9
|
export { PACKAGE_NAME, PACKAGE_VERSION };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pithy-sh/auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -39,16 +39,25 @@
|
|
|
39
39
|
"@better-auth/i18n": "^1.7.1",
|
|
40
40
|
"@cloudflare/workers-types": "^5.20260729.1",
|
|
41
41
|
"@hono/zod-validator": "^0.9.0",
|
|
42
|
-
"@pithy-sh/core": "^0.3.0",
|
|
43
|
-
"@pithy-sh/email": "^0.1.7",
|
|
44
|
-
"@pithy-sh/secrets": "^0.1.6",
|
|
45
|
-
"@pithy-sh/turnstile": "^0.1.6",
|
|
46
42
|
"better-auth": "^1.7.1"
|
|
47
43
|
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"@pithy-sh/core": "^0.4.0",
|
|
46
|
+
"@pithy-sh/email": "^0.2.0",
|
|
47
|
+
"@pithy-sh/secrets": "^0.2.0",
|
|
48
|
+
"@pithy-sh/turnstile": "^0.2.0",
|
|
49
|
+
"hono": "^4.13.2",
|
|
50
|
+
"kysely": "^0.29.0",
|
|
51
|
+
"zod": "^4.4.0"
|
|
52
|
+
},
|
|
48
53
|
"devDependencies": {
|
|
49
54
|
"@cloudflare/vitest-plugin": "^1.0.0",
|
|
50
55
|
"@pithy-sh/cloudflare": "workspace:*",
|
|
56
|
+
"@pithy-sh/core": "workspace:*",
|
|
57
|
+
"@pithy-sh/email": "workspace:*",
|
|
58
|
+
"@pithy-sh/secrets": "workspace:*",
|
|
51
59
|
"@pithy-sh/tsconfig": "workspace:*",
|
|
60
|
+
"@pithy-sh/turnstile": "workspace:*",
|
|
52
61
|
"@types/node": "^22.15.0",
|
|
53
62
|
"@vitest/coverage-v8": "^4.1.0",
|
|
54
63
|
"hono": "^4.13.2",
|
|
@@ -60,10 +69,5 @@
|
|
|
60
69
|
"vitest": "^4.1.0",
|
|
61
70
|
"wrangler": "^4.115.0",
|
|
62
71
|
"zod": "^4.4.0"
|
|
63
|
-
},
|
|
64
|
-
"peerDependencies": {
|
|
65
|
-
"hono": "^4.13.2",
|
|
66
|
-
"kysely": "^0.29.0",
|
|
67
|
-
"zod": "^4.4.0"
|
|
68
72
|
}
|
|
69
73
|
}
|
package/src/capability.ts
CHANGED
|
@@ -18,7 +18,7 @@ import { createSessionMiddleware } from "./http/middleware";
|
|
|
18
18
|
import { createRateLimitMiddleware } from "./http/rateLimit";
|
|
19
19
|
import { createAuthRoutes } from "./http/routes";
|
|
20
20
|
import { AuthPlugin, assertAdditivePlugins } from "./instance/plugins";
|
|
21
|
-
import { authSecretsRegistry } from "./instance/secrets";
|
|
21
|
+
import { authSecretsRegistry, inapplicableProviderSecrets } from "./instance/secrets";
|
|
22
22
|
import { AUTH_MIGRATION_ORDER, auth_0001_init } from "./migrations/0001_init";
|
|
23
23
|
import { authPluginPlan } from "./migrations/pluginTables";
|
|
24
24
|
import { authDevSessionSeed } from "./seeds/devSession";
|
|
@@ -189,6 +189,11 @@ export function auth(config: AuthConfigInput): AuthCapability {
|
|
|
189
189
|
config: AuthConfig,
|
|
190
190
|
dependsOn: ["secrets", "email"],
|
|
191
191
|
secretRegistry: authSecretsRegistry,
|
|
192
|
+
// And which of those four credentials this composition cannot reach (#541). A provider that is off
|
|
193
|
+
// has no code path that reads its pair, so `pithy doctor` listing it as outstanding re-raised a
|
|
194
|
+
// settled question on every run. Declared rather than inferred: the config key and the secret name
|
|
195
|
+
// are spelled alike by coincidence, and this is the only place that holds both.
|
|
196
|
+
inapplicableSecrets: inapplicableProviderSecrets(resolved),
|
|
192
197
|
requiredBindings: [
|
|
193
198
|
{ type: "d1", name: resolved.database },
|
|
194
199
|
{ type: "ratelimit", name: resolved.rateLimiterBinding },
|
package/src/instance/secrets.ts
CHANGED
|
@@ -177,6 +177,46 @@ export const authSecretsRegistry = defineSecretRegistry({
|
|
|
177
177
|
},
|
|
178
178
|
});
|
|
179
179
|
|
|
180
|
+
/**
|
|
181
|
+
* Which provider a credential belongs to — the join the CLI must never make by spelling (#541).
|
|
182
|
+
*
|
|
183
|
+
* `auth-apple-credentials` and the `apple` config key look like each other and that is a coincidence:
|
|
184
|
+
* nothing makes a secret name and a config key the same thing, and a reporting command that matched
|
|
185
|
+
* them by substring would be right by luck. Stated here, once, beside both.
|
|
186
|
+
*/
|
|
187
|
+
const PROVIDER_CREDENTIALS = [
|
|
188
|
+
["google", AUTH_GOOGLE_CREDENTIALS],
|
|
189
|
+
["apple", AUTH_APPLE_CREDENTIALS],
|
|
190
|
+
["facebook", AUTH_FACEBOOK_CREDENTIALS],
|
|
191
|
+
["github", AUTH_GITHUB_CREDENTIALS],
|
|
192
|
+
] as const;
|
|
193
|
+
|
|
194
|
+
/** The four toggles this reads off the resolved `AuthConfig` — nothing else about it is its business. */
|
|
195
|
+
export type AuthProviderToggles = Record<(typeof PROVIDER_CREDENTIALS)[number][0], { enabled: boolean }>;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* **The provider credentials this composition cannot reach**, as the `inapplicableSecrets` contribution.
|
|
199
|
+
*
|
|
200
|
+
* Auth declares four credentials whether or not a project runs four providers, so a project on Google
|
|
201
|
+
* and GitHub carries two secrets nothing will ever read. `pithy doctor` asked for them every run under
|
|
202
|
+
* *"fine to leave until you need it"* — softening, not silence, and "until you need it" is wrong about a
|
|
203
|
+
* provider the configuration has not enabled.
|
|
204
|
+
*
|
|
205
|
+
* **The session secret is never in here**, and that is the line this draws: it is read on every sign-in
|
|
206
|
+
* whatever the providers are, so it is outstanding work in every project that has not set it.
|
|
207
|
+
*
|
|
208
|
+
* The reason names the call an adopter would edit, because the point is to answer *what would I have to
|
|
209
|
+
* do to turn this on* as well as *why am I being shown this*.
|
|
210
|
+
*/
|
|
211
|
+
export function inapplicableProviderSecrets(providers: AuthProviderToggles): Record<string, string> {
|
|
212
|
+
const declared: Record<string, string> = {};
|
|
213
|
+
for (const [provider, secret] of PROVIDER_CREDENTIALS) {
|
|
214
|
+
if (providers[provider].enabled) continue;
|
|
215
|
+
declared[secret] = `auth() does not enable the ${provider} provider`;
|
|
216
|
+
}
|
|
217
|
+
return declared;
|
|
218
|
+
}
|
|
219
|
+
|
|
180
220
|
/** Resolve the Better Auth session secret for this invocation. */
|
|
181
221
|
export async function resolveSessionSecret(env: SecretsStoreEnv): Promise<string> {
|
|
182
222
|
const secrets = await sharedSecretsStore(env, authSecretsRegistry);
|
package/src/version.generated.ts
CHANGED