@pithy-sh/auth 0.6.3 → 0.6.5
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 +7 -0
- package/dist/capability.d.ts.map +1 -1
- package/dist/capability.js +5 -1
- package/dist/peer.d.ts +54 -0
- package/dist/peer.d.ts.map +1 -0
- package/dist/peer.js +31 -0
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +1 -1
- package/package.json +5 -5
- package/src/capability.ts +8 -1
- package/src/peer.ts +29 -0
- package/src/version.generated.ts +1 -1
package/dist/capability.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type { EmailCapability } from "@pithy-sh/email/src/capability";
|
|
|
6
6
|
import { type TurnstileMode } from "@pithy-sh/turnstile/src/config/config";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
import type { GithubUserInfoResolver } from "./instance/githubUserInfo";
|
|
9
|
+
import { type AuthPeer } from "./peer";
|
|
9
10
|
/** The auth capability's configuration — the thin surface an adopter owns in `pithy.config.ts`. */
|
|
10
11
|
export declare const AuthConfig: z.ZodObject<{
|
|
11
12
|
basePath: z.ZodDefault<z.ZodString>;
|
|
@@ -117,6 +118,12 @@ export type AuthOptions = AuthConfigInput & {
|
|
|
117
118
|
/** The auth capability, with its resolved config attached for inspection. */
|
|
118
119
|
export interface AuthCapability extends Capability {
|
|
119
120
|
authConfig: AuthConfig;
|
|
121
|
+
/**
|
|
122
|
+
* What a capability composed beside this one reads an account through — `matchmaking`, `support`,
|
|
123
|
+
* `testers`. Found in their `compose` hooks, so none of them imports this package and a project without
|
|
124
|
+
* auth bundles them (#645). See `peer.ts`.
|
|
125
|
+
*/
|
|
126
|
+
authPeer: AuthPeer;
|
|
120
127
|
}
|
|
121
128
|
/**
|
|
122
129
|
* The auth capability. Passwordless sign-in (magic link, OTP, Google, Apple), the hybrid bearer +
|
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,EAAE,MAAM,2BAA2B,CAAC;AAC5D,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;AASxB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../src/capability.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,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;AASxB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAMxE,OAAO,EAAE,KAAK,QAAQ,EAAY,MAAM,QAAQ,CAAC;AA8BjD,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,8GAA8G;IAC9G,qBAAqB,EAAE,sBAAsB,GAAG,SAAS,CAAC;IAC1D,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;IAC/C;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,sBAAsB,GAAG,SAAS,CAAC;CACvD;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE,EAAE,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEhH;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,eAAe,GAAG;IAC1C;;;;;;;;;;;;;OAaG;IACH,qBAAqB,CAAC,EAAE,sBAAsB,CAAC;IAC/C;;;;;;;;;;;;;;OAcG;IACH,gBAAgB,CAAC,EAAE,sBAAsB,CAAC;CAC3C,CAAC;AAEF,6EAA6E;AAC7E,MAAM,WAAW,cAAe,SAAQ,UAAU;IAChD,UAAU,EAAE,UAAU,CAAC;IACvB;;;;OAIG;IACH,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAiCD;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,cAAc,CA+JzD;AAED,0DAA0D;AAC1D,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,IAAI,cAAc,CAErF"}
|
package/dist/capability.js
CHANGED
|
@@ -13,6 +13,7 @@ import { createAuthRoutes } from "./http/routes.js";
|
|
|
13
13
|
import "./migrations/0001_init.js";
|
|
14
14
|
import { authPluginPlan } from "./migrations/pluginTables.js";
|
|
15
15
|
import { AUTH_MIGRATIONS } from "./migrations/set.js";
|
|
16
|
+
import { authPeer } from "./peer.js";
|
|
16
17
|
import { authExampleSeed } from "./seeds/example.js";
|
|
17
18
|
import { PACKAGE_NAME, PACKAGE_VERSION } from "./version.generated.js";
|
|
18
19
|
import { defineCapability } from "@pithy-sh/core/src/capability/capability";
|
|
@@ -185,7 +186,10 @@ function auth(options) {
|
|
|
185
186
|
adminRoutes: authAdminRoutes(resolved.basePath),
|
|
186
187
|
seeds: [authExampleSeed, authDevSessionSeed]
|
|
187
188
|
});
|
|
188
|
-
return Object.assign(capability, {
|
|
189
|
+
return Object.assign(capability, {
|
|
190
|
+
authConfig: resolved,
|
|
191
|
+
authPeer
|
|
192
|
+
});
|
|
189
193
|
}
|
|
190
194
|
/** Type guard: is this capability the auth capability? */
|
|
191
195
|
function isAuthCapability(capability) {
|
package/dist/peer.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
import { authDatabase } from "./data/tables";
|
|
4
|
+
/**
|
|
5
|
+
* **What a capability composed beside auth may read — handed to it, never imported by it** (#645).
|
|
6
|
+
*
|
|
7
|
+
* `@pithy-sh/auth` is an optional peer of `matchmaking` (an invite resolved by address), `support` (a sender
|
|
8
|
+
* linked to an account) and `testers` (whether a tester has used the app). Each reached these modules by
|
|
9
|
+
* `import()` behind a `try`, and a literal specifier is one a bundler resolves whether or not the branch
|
|
10
|
+
* holding it ever runs — so a project without auth could not bundle any of the three.
|
|
11
|
+
*
|
|
12
|
+
* So `auth()` carries this object as `authPeer`, a dependent finds it among the composed capabilities in its
|
|
13
|
+
* `compose` hook, and a host Worker — which composes nothing — is handed it by the entry `pithy` generates when
|
|
14
|
+
* the project composes auth. The dependent names this package only in a type, which a bundler never sees.
|
|
15
|
+
*
|
|
16
|
+
* Read access to the account tables and the schemas that decode them, and nothing that writes: every
|
|
17
|
+
* dependent reads who someone is, and none of them may decide it.
|
|
18
|
+
*
|
|
19
|
+
* Its own module, so that generated host entry imports these and not `capability.ts`, which brings Better
|
|
20
|
+
* Auth and every route with it.
|
|
21
|
+
*/
|
|
22
|
+
export declare const authPeer: {
|
|
23
|
+
readonly authDatabase: typeof authDatabase;
|
|
24
|
+
readonly User: import("zod").ZodObject<{
|
|
25
|
+
id: import("zod").ZodString;
|
|
26
|
+
name: import("zod").ZodString;
|
|
27
|
+
email: import("zod").ZodString;
|
|
28
|
+
emailVerified: import("zod").ZodCodec<import("zod").ZodUnion<readonly [import("zod").ZodLiteral<0>, import("zod").ZodLiteral<1>, import("zod").ZodBoolean, import("zod").ZodString]>, import("zod").ZodBoolean>;
|
|
29
|
+
image: import("zod").ZodNullable<import("zod").ZodString>;
|
|
30
|
+
locale: import("zod").ZodNullable<import("zod").ZodString>;
|
|
31
|
+
createdAt: import("zod").ZodCodec<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodNumber, import("zod").ZodDate]>, import("zod").ZodDate>;
|
|
32
|
+
updatedAt: import("zod").ZodCodec<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodNumber, import("zod").ZodDate]>, import("zod").ZodDate>;
|
|
33
|
+
}, import("zod/v4/core").$strip>;
|
|
34
|
+
readonly Device: import("zod").ZodObject<{
|
|
35
|
+
id: import("zod").ZodString;
|
|
36
|
+
userId: import("zod").ZodString;
|
|
37
|
+
platform: import("zod").ZodEnum<{
|
|
38
|
+
android: "android";
|
|
39
|
+
ios: "ios";
|
|
40
|
+
web: "web";
|
|
41
|
+
}>;
|
|
42
|
+
name: import("zod").ZodNullable<import("zod").ZodString>;
|
|
43
|
+
model: import("zod").ZodNullable<import("zod").ZodString>;
|
|
44
|
+
osVersion: import("zod").ZodNullable<import("zod").ZodString>;
|
|
45
|
+
appVersion: import("zod").ZodNullable<import("zod").ZodString>;
|
|
46
|
+
pushToken: import("zod").ZodNullable<import("zod").ZodString>;
|
|
47
|
+
lastIp: import("zod").ZodNullable<import("zod").ZodString>;
|
|
48
|
+
lastSeenAt: import("zod").ZodCodec<import("zod").ZodUnion<readonly [import("zod").ZodNumber, import("zod").ZodString, import("zod").ZodDate]>, import("zod").ZodDate>;
|
|
49
|
+
createdAt: import("zod").ZodCodec<import("zod").ZodUnion<readonly [import("zod").ZodNumber, import("zod").ZodString, import("zod").ZodDate]>, import("zod").ZodDate>;
|
|
50
|
+
}, import("zod/v4/core").$strip>;
|
|
51
|
+
};
|
|
52
|
+
/** Auth's peer surface, by type — what `authPeer` holds. */
|
|
53
|
+
export type AuthPeer = typeof authPeer;
|
|
54
|
+
//# sourceMappingURL=peer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"peer.d.ts","sourceRoot":"","sources":["../src/peer.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAA0C,CAAC;AAEhE,4DAA4D;AAC5D,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC"}
|
package/dist/peer.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
import { User } from "./data/betterAuth.js";
|
|
4
|
+
import { Device } from "./data/device.js";
|
|
5
|
+
import { authDatabase } from "./data/tables.js";
|
|
6
|
+
//#region src/peer.ts
|
|
7
|
+
/**
|
|
8
|
+
* **What a capability composed beside auth may read — handed to it, never imported by it** (#645).
|
|
9
|
+
*
|
|
10
|
+
* `@pithy-sh/auth` is an optional peer of `matchmaking` (an invite resolved by address), `support` (a sender
|
|
11
|
+
* linked to an account) and `testers` (whether a tester has used the app). Each reached these modules by
|
|
12
|
+
* `import()` behind a `try`, and a literal specifier is one a bundler resolves whether or not the branch
|
|
13
|
+
* holding it ever runs — so a project without auth could not bundle any of the three.
|
|
14
|
+
*
|
|
15
|
+
* So `auth()` carries this object as `authPeer`, a dependent finds it among the composed capabilities in its
|
|
16
|
+
* `compose` hook, and a host Worker — which composes nothing — is handed it by the entry `pithy` generates when
|
|
17
|
+
* the project composes auth. The dependent names this package only in a type, which a bundler never sees.
|
|
18
|
+
*
|
|
19
|
+
* Read access to the account tables and the schemas that decode them, and nothing that writes: every
|
|
20
|
+
* dependent reads who someone is, and none of them may decide it.
|
|
21
|
+
*
|
|
22
|
+
* Its own module, so that generated host entry imports these and not `capability.ts`, which brings Better
|
|
23
|
+
* Auth and every route with it.
|
|
24
|
+
*/
|
|
25
|
+
const authPeer = {
|
|
26
|
+
authDatabase,
|
|
27
|
+
User,
|
|
28
|
+
Device
|
|
29
|
+
};
|
|
30
|
+
//#endregion
|
|
31
|
+
export { authPeer };
|
|
@@ -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.
|
|
6
|
+
export declare const PACKAGE_VERSION = "0.6.5";
|
|
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.6.
|
|
7
|
+
const PACKAGE_VERSION = "0.6.5";
|
|
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.6.
|
|
3
|
+
"version": "0.6.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"better-auth": "^1.7.1"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@pithy-sh/core": "^0.7.
|
|
46
|
-
"@pithy-sh/email": "^0.3.
|
|
47
|
-
"@pithy-sh/secrets": "^0.
|
|
48
|
-
"@pithy-sh/turnstile": "^0.3.
|
|
45
|
+
"@pithy-sh/core": "^0.7.4",
|
|
46
|
+
"@pithy-sh/email": "^0.3.9",
|
|
47
|
+
"@pithy-sh/secrets": "^0.3.0",
|
|
48
|
+
"@pithy-sh/turnstile": "^0.3.2",
|
|
49
49
|
"hono": "^4.13.2",
|
|
50
50
|
"kysely": "^0.29.0",
|
|
51
51
|
"zod": "^4.4.0"
|
package/src/capability.ts
CHANGED
|
@@ -24,6 +24,7 @@ import { authSecretsRegistry, inapplicableProviderSecrets } from "./instance/sec
|
|
|
24
24
|
import { AUTH_MIGRATION_ORDER } from "./migrations/0001_init";
|
|
25
25
|
import { authPluginPlan } from "./migrations/pluginTables";
|
|
26
26
|
import { AUTH_MIGRATIONS } from "./migrations/set";
|
|
27
|
+
import { type AuthPeer, authPeer } from "./peer";
|
|
27
28
|
import { authDevSessionSeed } from "./seeds/devSession";
|
|
28
29
|
import { authExampleSeed } from "./seeds/example";
|
|
29
30
|
import { PACKAGE_NAME, PACKAGE_VERSION } from "./version.generated";
|
|
@@ -205,6 +206,12 @@ export type AuthOptions = AuthConfigInput & {
|
|
|
205
206
|
/** The auth capability, with its resolved config attached for inspection. */
|
|
206
207
|
export interface AuthCapability extends Capability {
|
|
207
208
|
authConfig: AuthConfig;
|
|
209
|
+
/**
|
|
210
|
+
* What a capability composed beside this one reads an account through — `matchmaking`, `support`,
|
|
211
|
+
* `testers`. Found in their `compose` hooks, so none of them imports this package and a project without
|
|
212
|
+
* auth bundles them (#645). See `peer.ts`.
|
|
213
|
+
*/
|
|
214
|
+
authPeer: AuthPeer;
|
|
208
215
|
}
|
|
209
216
|
|
|
210
217
|
/**
|
|
@@ -402,7 +409,7 @@ export function auth(options: AuthOptions): AuthCapability {
|
|
|
402
409
|
seeds: [authExampleSeed, authDevSessionSeed],
|
|
403
410
|
});
|
|
404
411
|
|
|
405
|
-
return Object.assign(capability, { authConfig: resolved });
|
|
412
|
+
return Object.assign(capability, { authConfig: resolved, authPeer });
|
|
406
413
|
}
|
|
407
414
|
|
|
408
415
|
/** Type guard: is this capability the auth capability? */
|
package/src/peer.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { User } from "./data/betterAuth";
|
|
5
|
+
import { Device } from "./data/device";
|
|
6
|
+
import { authDatabase } from "./data/tables";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* **What a capability composed beside auth may read — handed to it, never imported by it** (#645).
|
|
10
|
+
*
|
|
11
|
+
* `@pithy-sh/auth` is an optional peer of `matchmaking` (an invite resolved by address), `support` (a sender
|
|
12
|
+
* linked to an account) and `testers` (whether a tester has used the app). Each reached these modules by
|
|
13
|
+
* `import()` behind a `try`, and a literal specifier is one a bundler resolves whether or not the branch
|
|
14
|
+
* holding it ever runs — so a project without auth could not bundle any of the three.
|
|
15
|
+
*
|
|
16
|
+
* So `auth()` carries this object as `authPeer`, a dependent finds it among the composed capabilities in its
|
|
17
|
+
* `compose` hook, and a host Worker — which composes nothing — is handed it by the entry `pithy` generates when
|
|
18
|
+
* the project composes auth. The dependent names this package only in a type, which a bundler never sees.
|
|
19
|
+
*
|
|
20
|
+
* Read access to the account tables and the schemas that decode them, and nothing that writes: every
|
|
21
|
+
* dependent reads who someone is, and none of them may decide it.
|
|
22
|
+
*
|
|
23
|
+
* Its own module, so that generated host entry imports these and not `capability.ts`, which brings Better
|
|
24
|
+
* Auth and every route with it.
|
|
25
|
+
*/
|
|
26
|
+
export const authPeer = { authDatabase, User, Device } as const;
|
|
27
|
+
|
|
28
|
+
/** Auth's peer surface, by type — what `authPeer` holds. */
|
|
29
|
+
export type AuthPeer = typeof authPeer;
|
package/src/version.generated.ts
CHANGED