+8
-8
app/server/oauth/client.ts
+8
-8
app/server/oauth/client.ts
···
1
1
import { JoseKey } from "@atproto/jwk-jose";
2
+
import type { NodeOAuthClientOptions } from "@atproto/oauth-client-node";
2
3
import { NodeOAuthClient } from "@atproto/oauth-client-node";
3
4
4
5
import { env, isProduction } from "~/utils/env";
···
17
18
"base64",
18
19
).toString();
19
20
const privateKey = await JoseKey.fromImportable(privateKeyPKCS8, "key1");
20
-
oauthClient = new NodeOAuthClient({
21
+
const oauthClientOptions: NodeOAuthClientOptions = {
21
22
clientMetadata: {
22
23
client_name: "Linkat",
23
24
client_id: isProduction
···
38
39
plcDirectoryUrl: env.ATPROTO_PLC_URL,
39
40
stateStore: new StateStore(),
40
41
sessionStore: new SessionStore(),
41
-
// 以下、開発時用の設定
42
-
// ローカル開発環境ではalice.testという名前を通常didに解決できないため、
43
-
// pnpm patchでhandleResolverを上書き可能にしたうえで、ローカル環境のbsky AppViewを使用してハンドルを解決している
44
-
// 参照:https://github.com/bluesky-social/atproto/blob/670b6b5de2bf91e6944761c98eb1126fb6a681ee/packages/oauth/oauth-client/src/oauth-client.ts#L212-L215
45
-
handleResolver: !isProduction ? env.BSKY_PUBLIC_API_URL : undefined,
46
-
allowHttp: !isProduction, // httpを許可しないとOAuthProtectedResourceMetadataResolverがエラーを投げる
47
-
});
42
+
};
43
+
if (!isProduction) {
44
+
oauthClientOptions.handleResolver = env.BSKY_PUBLIC_API_URL;
45
+
oauthClientOptions.allowHttp = true; // httpを許可しないとOAuthProtectedResourceMetadataResolverがエラーを投げる
46
+
}
47
+
oauthClient = new NodeOAuthClient(oauthClientOptions);
48
48
return oauthClient;
49
49
};