@farm.js/better-auth 0.1.51-beta.3 → 0.1.61
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/index.d.ts +4 -24
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -26
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,40 +1,20 @@
|
|
|
1
1
|
import type { FarmIntegrationLogger } from "@farm.js/core";
|
|
2
2
|
export interface BetterAuthInstance {
|
|
3
3
|
handler(request: Request): Promise<Response> | Response;
|
|
4
|
-
/** Present on every `betterAuth()` instance; Farm reads sessions through it. */
|
|
5
|
-
api?: {
|
|
6
|
-
getSession?(input: {
|
|
7
|
-
headers: Headers;
|
|
8
|
-
}): Promise<unknown> | unknown;
|
|
9
|
-
};
|
|
10
4
|
}
|
|
11
5
|
export interface BetterAuthIntegrationInput {
|
|
12
6
|
instance: BetterAuthInstance;
|
|
13
7
|
log?: FarmIntegrationLogger;
|
|
14
8
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
id: string;
|
|
18
|
-
userId?: string;
|
|
19
|
-
expiresAt?: Date;
|
|
20
|
-
}
|
|
21
|
-
export declare function betterAuth(input: BetterAuthIntegrationInput): {
|
|
22
|
-
/**
|
|
23
|
-
* Who the request's cookies sign in, through Better Auth's `api.getSession`. Mobile session
|
|
24
|
-
* tokens use it to issue and refresh native screens' device tokens.
|
|
25
|
-
*/
|
|
26
|
-
session(request: Request): Promise<BetterAuthIntegrationSession | null>;
|
|
9
|
+
export declare function betterAuth(input: BetterAuthIntegrationInput): import("@farm.js/core").DefinedIntegration<{
|
|
10
|
+
category: "auth";
|
|
27
11
|
type: string;
|
|
28
|
-
log: import("@farm.js/core/integrations").FarmIntegrationLogger | undefined;
|
|
29
12
|
instance: BetterAuthInstance;
|
|
13
|
+
log: import("@farm.js/core/integrations").FarmIntegrationLogger | undefined;
|
|
30
14
|
routes: {
|
|
31
15
|
path: string;
|
|
32
16
|
methods: import("@farm.js/core/integrations").FarmIntegrationRouteMethod[];
|
|
33
17
|
handler(request: Request, context: import("@farm.js/core").FarmIntegrationHandlerContext): Response | Promise<Response>;
|
|
34
18
|
}[];
|
|
35
|
-
|
|
36
|
-
category: import("@farm.js/core").FarmIntegrationCategory;
|
|
37
|
-
slot: import("@farm.js/core").FarmIntegrationCategory;
|
|
38
|
-
api: import("@farm.js/core").FarmIntegrationAPI | undefined;
|
|
39
|
-
};
|
|
19
|
+
}>;
|
|
40
20
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAG3D,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAG3D,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;CACzD;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,GAAG,CAAC,EAAE,qBAAqB,CAAC;CAC7B;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,0BAA0B;;;;;;;;;;GAW3D"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createAuthRouteIntegration } from "@farm.js/integration-utils";
|
|
2
2
|
export function betterAuth(input) {
|
|
3
|
-
|
|
3
|
+
return createAuthRouteIntegration({
|
|
4
4
|
type: "better-auth",
|
|
5
5
|
instance: input.instance,
|
|
6
6
|
log: input.log,
|
|
@@ -10,29 +10,4 @@ export function betterAuth(input) {
|
|
|
10
10
|
return input.instance.handler(request);
|
|
11
11
|
},
|
|
12
12
|
});
|
|
13
|
-
return {
|
|
14
|
-
...integration,
|
|
15
|
-
/**
|
|
16
|
-
* Who the request's cookies sign in, through Better Auth's `api.getSession`. Mobile session
|
|
17
|
-
* tokens use it to issue and refresh native screens' device tokens.
|
|
18
|
-
*/
|
|
19
|
-
async session(request) {
|
|
20
|
-
const getSession = input.instance.api?.getSession;
|
|
21
|
-
if (typeof getSession !== "function")
|
|
22
|
-
return null;
|
|
23
|
-
const result = (await getSession.call(input.instance.api, {
|
|
24
|
-
headers: request.headers,
|
|
25
|
-
}));
|
|
26
|
-
const session = result?.session;
|
|
27
|
-
if (!session || typeof session.id !== "string")
|
|
28
|
-
return null;
|
|
29
|
-
return {
|
|
30
|
-
id: session.id,
|
|
31
|
-
userId: typeof session.userId === "string" ? session.userId : undefined,
|
|
32
|
-
expiresAt: session.expiresAt === undefined
|
|
33
|
-
? undefined
|
|
34
|
-
: new Date(session.expiresAt),
|
|
35
|
-
};
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
13
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farm.js/better-auth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.61",
|
|
4
4
|
"description": "Better Auth integration for Farm.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@farm.js/core": "0.1.
|
|
29
|
-
"@farm.js/integration-utils": "0.1.
|
|
28
|
+
"@farm.js/core": "0.1.61",
|
|
29
|
+
"@farm.js/integration-utils": "0.1.61"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\" && tsc",
|