better-near-auth 0.3.1 → 0.3.2
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/package.json +3 -2
- package/src/client.ts +2 -3
- package/src/index.ts +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "better-near-auth",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Sign in with NEAR (SIWN) plugin for Better Auth",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"module": "src/index.ts",
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
"test": "vitest",
|
|
21
21
|
"test:watch": "vitest --watch",
|
|
22
22
|
"lint": "tsc --noEmit",
|
|
23
|
-
"dev": "bun run src/index.ts"
|
|
23
|
+
"dev": "bun run src/index.ts",
|
|
24
|
+
"typecheck": "tsc --noEmit"
|
|
24
25
|
},
|
|
25
26
|
"keywords": [
|
|
26
27
|
"better-auth",
|
package/src/client.ts
CHANGED
|
@@ -151,7 +151,7 @@ export const siwnClient = (config: SIWNClientConfig): SIWNClientPlugin => {
|
|
|
151
151
|
id: "siwn",
|
|
152
152
|
$InferServerPlugin: {} as ReturnType<typeof siwn>,
|
|
153
153
|
|
|
154
|
-
getAtoms: ($fetch) => ({
|
|
154
|
+
getAtoms: (_$fetch) => ({
|
|
155
155
|
nearState,
|
|
156
156
|
cachedNonce,
|
|
157
157
|
}),
|
|
@@ -303,11 +303,10 @@ export const siwnClient = (config: SIWNClientConfig): SIWNClientPlugin => {
|
|
|
303
303
|
},
|
|
304
304
|
requestSignIn: {
|
|
305
305
|
near: async (
|
|
306
|
-
|
|
306
|
+
_params: { recipient: string },
|
|
307
307
|
callbacks?: AuthCallbacks
|
|
308
308
|
): Promise<void> => {
|
|
309
309
|
try {
|
|
310
|
-
const { recipient } = params;
|
|
311
310
|
|
|
312
311
|
clearNonce();
|
|
313
312
|
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { APIError, createAuthEndpoint, createAuthMiddleware, sessionMiddleware } from "better-auth/api";
|
|
2
2
|
import { setSessionCookie } from "better-auth/cookies";
|
|
3
3
|
import type { Account, BetterAuthPlugin, User } from "better-auth/types";
|
|
4
|
-
import { generateNonce,
|
|
4
|
+
import { generateNonce, verify, type VerificationResult, type VerifyOptions } from "near-sign-verify";
|
|
5
5
|
import { bytesToBase64 } from "./utils";
|
|
6
6
|
import z from "zod";
|
|
7
7
|
import { defaultGetProfile, getImageUrl, getNetworkFromAccountId } from "./profile";
|
|
@@ -115,7 +115,7 @@ export const siwn = (options: SIWNPluginOptions) =>
|
|
|
115
115
|
requireRequest: true,
|
|
116
116
|
},
|
|
117
117
|
async (ctx) => {
|
|
118
|
-
const { authToken, accountId
|
|
118
|
+
const { authToken, accountId } = ctx.body;
|
|
119
119
|
const network = getNetworkFromAccountId(accountId);
|
|
120
120
|
const session = ctx.context.session;
|
|
121
121
|
|
|
@@ -371,7 +371,7 @@ export const siwn = (options: SIWNPluginOptions) =>
|
|
|
371
371
|
body: NonceRequest,
|
|
372
372
|
},
|
|
373
373
|
async (ctx) => {
|
|
374
|
-
const { accountId,
|
|
374
|
+
const { accountId, networkId } = ctx.body;
|
|
375
375
|
const network = getNetworkFromAccountId(accountId);
|
|
376
376
|
|
|
377
377
|
if (networkId !== network) {
|