Skip to content

Commit 0359931

Browse files
committed
fix: Fix code type checking
1 parent 87a9d0d commit 0359931

File tree

16 files changed

+4208
-7546
lines changed

16 files changed

+4208
-7546
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM oven/bun:slim
2+
3+
WORKDIR /app
4+
5+
COPY package.json bun.lockb ./
6+
7+
RUN bun install
8+
9+
COPY . .
10+
11+
RUN bun run test
12+

v3/docs/additional-verification/attack-protection-suite/initial-setup.mdx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ This SDK generates a unique request ID for each authentication event attempt.
5757
```tsx
5858
const ENVIRONMENT_ID = "<environment-id>"; // Your environment ID that you received from the SuperTokens team
5959
// Initialize the agent on page load using your public API key that you received from the SuperTokens team.
60+
// @ts-expect-error
6061
const supertokensRequestIdPromise = import("https://deviceid.supertokens.io/PqWNQ35Ydhm6WDUK/k9bwGCuvuA83Ad6s?apiKey=<PUBLIC_API_KEY>")
6162
.then((RequestId: any) => RequestId.load({
6263
endpoint: [
@@ -93,6 +94,7 @@ import EmailPassword from "supertokens-auth-react/recipe/emailpassword";
9394

9495
const ENVIRONMENT_ID = "<environment-id>"; // Your environment ID that you received from the SuperTokens team
9596
// Initialize the agent on page load using your public API key that you received from the SuperTokens team.
97+
// @ts-expect-error
9698
const supertokensRequestIdPromise = import("https://deviceid.supertokens.io/PqWNQ35Ydhm6WDUK/k9bwGCuvuA83Ad6s?apiKey=<PUBLIC_API_KEY>")
9799
.then((RequestId: any) => RequestId.load({
98100
endpoint: [
@@ -1133,8 +1135,6 @@ curl --location --request POST 'https://security-us-east-1.aws.supertokens.io/v1
11331135
<HTTPRequestCard.NodeJSExample showTenatSelection={false}>
11341136

11351137
```tsx
1136-
import axios from "axios";
1137-
11381138
const REGION = "us-east-1"; // or "eu-west-1" or "ap-southeast-1"
11391139
const SECRET_API_KEY = "<secret-api-key>";
11401140

@@ -1158,14 +1158,18 @@ const payload = {
11581158
],
11591159
};
11601160

1161-
const response = await axios.post(url, payload, {
1161+
1162+
fetch(url, {
1163+
method: 'POST',
11621164
headers: {
1163-
Authorization: `Bearer ${SECRET_API_KEY}`,
1164-
"Content-Type": "application/json",
1165+
'Authorization': 'Bearer ' + SECRET_API_KEY,
1166+
'Content-Type': 'application/json',
11651167
},
1166-
});
1167-
1168-
console.log(response.data);
1168+
body: JSON.stringify(payload)
1169+
})
1170+
.then(response => response.json())
1171+
.then(json => console.log(json))
1172+
.catch(err => console.error(err));
11691173
```
11701174

11711175
</HTTPRequestCard.NodeJSExample>

v3/docs/additional-verification/session-verification/claim-validation.mdx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ interface SessionClaim<T> {
7474
recipeUserId: RecipeUserId,
7575
tenantId: string,
7676
currentPayload: JSONObject | undefined,
77+
// @ts-expect-error
7778
userContext: UserContext
7879
): Promise<T | undefined> | T | undefined;
7980

@@ -82,13 +83,15 @@ interface SessionClaim<T> {
8283
*
8384
* @returns The modified payload object
8485
*/
86+
// @ts-expect-error
8587
removeFromPayload(payload: JSONObject, userContext: UserContext): JSONObject;
8688

8789
/**
8890
* Gets the value of the claim stored in the payload
8991
*
9092
* @returns Claim value
9193
*/
94+
// @ts-expect-error
9295
getValueFromPayload(payload: JSONObject, userContext: UserContext): T | undefined;
9396
}
9497
```
@@ -258,13 +261,22 @@ import SuperTokens from "supertokens-node";
258261
import Session from "supertokens-node/recipe/session";
259262

260263
SuperTokens.init({
264+
supertokens: {
265+
connectionURI: "...",
266+
},
267+
appInfo: {
268+
apiDomain: "...",
269+
appName: "...",
270+
websiteDomain: "...",
271+
},
261272
recipeList: [
262273
Session.init({
263274
override: {
264275
functions: (originalImplementation) => {
265276
return {
266277
...originalImplementation,
267278
getGlobalClaimValidators: async function (input) {
279+
// @ts-expect-error
268280
return [...input.claimValidatorsAddedByOtherRecipes, SecondFactorClaim.validators.isTrue()];
269281
},
270282
};
@@ -325,7 +337,9 @@ const AdminRoute = (props: React.PropsWithChildren<any>) => {
325337

326338
```tsx
327339
import { Error as STError } from "supertokens-node/recipe/session";
340+
import { UserRoleClaim } from "supertokens-node/recipe/userroles";
328341

342+
// @ts-expect-error
329343
if (roles === undefined || !roles.includes("admin")) {
330344
throw new STError({
331345
type: "INVALID_CLAIMS",
@@ -342,6 +356,9 @@ if (roles === undefined || !roles.includes("admin")) {
342356
#### Frontend redirection
343357

344358
```tsx
359+
import { SessionAuth } from "supertokens-auth-react/recipe/session";
360+
import { UserRoleClaim } from "supertokens-auth-react/recipe/userroles";
361+
345362
const AdminRoute = (props: React.PropsWithChildren<any>) => {
346363
return (
347364
<SessionAuth

v3/docs/authentication/social/_blocks/frontend-custom-ui-mobile-authorization-code-flow.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,8 @@ export const performGoogleSignIn = async (): Promise<boolean> => {
357357
});
358358

359359
try {
360-
const user = await GoogleSignin.signIn({});
361-
const authCode = user.serverAuthCode;
360+
const response = await GoogleSignin.signIn({});
361+
const authCode = response.data?.serverAuthCode;
362362

363363
// Refer to step 2
364364

v3/docs/quickstart/backend-setup.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ fastify.register(cors, {
237237
// highlight-next-line
238238
await fastify.register(plugin);
239239

240-
await fastify.listen(8000);
240+
await fastify.listen({ port: 8000 });
241241
})();
242242

243243
// ...your API routes

v3/docs/quickstart/integrations/nestjs.mdx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,12 @@ And, the global filter ensures that all authentication related errors get handle
9393
```tsx
9494
import supertokens from 'supertokens-node'
9595
import { SuperTokensExceptionFilter } from 'supertokens-nestjs'
96-
import { appInfo } from './config'
96+
import { NestFactory } from '@nestjs/core'
97+
// @ts-expect-error
98+
import { AppModule } from './app.module'
99+
// @ts-expect-error
100+
import { appInfo } from './config'
101+
97102

98103
async function bootstrap() {
99104
const app = await NestFactory.create(AppModule)

v3/docs/quickstart/integrations/nextjs/app-directory/protecting-route.mdx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,9 @@ const client = jwksClient({
191191
jwksUri: "^{coreInfo.uri}/.well-known/jwks.json",
192192
});
193193

194-
function getAccessToken(): string | undefined {
195-
return cookies().get("sAccessToken")?.value;
194+
async function getAccessToken() {
195+
const cookiesStore = await cookies();
196+
return cookiesStore.get("sAccessToken")?.value;
196197
}
197198

198199
function getPublicKey(header: JwtHeader, callback: SigningKeyCallback) {
@@ -231,7 +232,7 @@ async function getSSRSessionHelper(): Promise<{
231232
hasToken: boolean;
232233
error: Error | undefined;
233234
}> {
234-
const accessToken = getAccessToken();
235+
const accessToken = await getAccessToken();
235236
const hasToken = !!accessToken;
236237
try {
237238
if (accessToken) {
@@ -389,8 +390,9 @@ const client = jwksClient({
389390
jwksUri: "^{coreInfo.uri}/.well-known/jwks.json",
390391
});
391392

392-
function getAccessToken(): string | undefined {
393-
return cookies().get("sAccessToken")?.value;
393+
async function getAccessToken() {
394+
const cookiesStore = await cookies();
395+
return cookiesStore.get("sAccessToken")?.value;
394396
}
395397

396398
function getPublicKey(header: JwtHeader, callback: SigningKeyCallback) {
@@ -429,7 +431,7 @@ async function getSSRSessionHelper(): Promise<{
429431
hasToken: boolean;
430432
error: Error | undefined;
431433
}> {
432-
const accessToken = getAccessToken();
434+
const accessToken = await getAccessToken();
433435
const hasToken = !!accessToken;
434436
try {
435437
if (accessToken) {

v3/docs/quickstart/integrations/nextjs/app-directory/server-components-requests.mdx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ const client = jwksClient({
3434
jwksUri: "^{coreInfo.uri}/.well-known/jwks.json",
3535
});
3636

37-
function getAccessToken(): string | undefined {
38-
return cookies().get("sAccessToken")?.value;
37+
async function getAccessToken() {
38+
const cookiesStore = await cookies();
39+
return cookiesStore.get("sAccessToken")?.value;
3940
}
4041

4142
function getPublicKey(header: JwtHeader, callback: SigningKeyCallback) {
@@ -74,7 +75,7 @@ async function getSSRSessionHelper(): Promise<{
7475
hasToken: boolean;
7576
error: Error | undefined;
7677
}> {
77-
const accessToken = getAccessToken();
78+
const accessToken = await getAccessToken();
7879
const hasToken = !!accessToken;
7980
try {
8081
if (accessToken) {
@@ -89,6 +90,7 @@ async function getSSRSessionHelper(): Promise<{
8990

9091
export async function HomePage() {
9192
const { accessTokenPayload, hasToken, error } = await getSSRSessionHelper();
93+
const accessToken = await getAccessToken();
9294

9395
if (error) {
9496
return <div>Something went wrong while trying to get the session. Error - {error.message}</div>;
@@ -120,7 +122,7 @@ export async function HomePage() {
120122
* We read the access token from the cookies and use that as a Bearer token when
121123
* making network requests.
122124
*/
123-
Authorization: 'Bearer ' + getAccessToken(),
125+
Authorization: 'Bearer ' + accessToken,
124126
},
125127
});
126128

@@ -171,8 +173,9 @@ const client = jwksClient({
171173
jwksUri: "^{coreInfo.uri}/.well-known/jwks.json",
172174
});
173175

174-
function getAccessToken(): string | undefined {
175-
return cookies().get("sAccessToken")?.value;
176+
async function getAccessToken() {
177+
const cookiesStore = await cookies();
178+
return cookiesStore.get("sAccessToken")?.value;
176179
}
177180

178181
function getPublicKey(header: JwtHeader, callback: SigningKeyCallback) {
@@ -211,7 +214,7 @@ async function getSSRSessionHelper(): Promise<{
211214
hasToken: boolean;
212215
error: Error | undefined;
213216
}> {
214-
const accessToken = getAccessToken();
217+
const accessToken = await getAccessToken();
215218
const hasToken = !!accessToken;
216219
try {
217220
if (accessToken) {

v3/docs/references/backend-sdks/api-overrides.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,8 @@ SuperTokens.init({
486486
<TabItem value="lesser">
487487

488488
```tsx
489-
import SuperTokens from "supertokens-node7";
490-
import ThirdPartyEmailPassword from "supertokens-node7/recipe/thirdpartyemailpassword";
489+
import SuperTokens from "supertokens-node";
490+
import ThirdParty from "supertokens-node/recipe/thirdparty";
491491

492492
SuperTokens.init({
493493
appInfo: {
@@ -499,7 +499,7 @@ SuperTokens.init({
499499
connectionURI: "...",
500500
},
501501
recipeList: [
502-
ThirdPartyEmailPassword.init({
502+
ThirdParty.init({
503503
// highlight-start
504504
override: {
505505
apis: (originalImplementation) => {

v3/scripts/check-code-blocks.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ fi
77

88
cd ./scripts/code-type-checking/"$1" && docker build -t code-check-"$1" .
99
docker run code-check-"$1"
10+
echo $?

0 commit comments

Comments
 (0)