diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 41a2e9c5d..5ea232d4b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -207,6 +207,30 @@ CODE_TYPE_CHECK=all npm run start You may need to add something to the code that is necessary for type checking but shouldn't appear in the output documentation. You can do this by adding a comment to the end of the line stating: `typecheck-only, removed from output`. Lines ending with this comment will be removed from the output but kept for type checking. +Omitting substrings from the final output while retaining them for type checking can be achieved using the `__OMIT_START__` and `__OMIT_END__` specifier. This is particularly useful for incorporating type annotations into code snippets without including them in the end result. Consider the following example: + +```mjs +function square(num__OMIT_START__: number__OMIT_END__) { + return num * num; +} +``` + +During code checking, the plugin will analyze the following code: + +```mjs +function square(num: number) { + return num * num; +} +``` + +However, the final output will exclude type annotations: + +```mjs +function square(num) { + return num * num; +} +``` + #### Tips JS / TS - If you need to purposely tell TS to ignore errors in the next line, you can add a `// @ts-ignore` comment in your code snippets. This will make the TS checker pass. The type checking engine will also remove these from the final code output so that users don't see this unnecessarily. - If you are working with snippets that use an older version of supertokens-node you can use a custom import for that version. For example some snippets use `supertokens-node7` as the import to fix typing. The type checking engine replaces this with `supertokens-node`. NOTE: If you need to add another node version as a custom import, please modify the type checking script to replace the import statement to use `supertokens-node` diff --git a/v2/emailpassword/serverless/with-aws-lambda/authorizer.mdx b/v2/emailpassword/serverless/with-aws-lambda/authorizer.mdx index 45ebf1fbb..1ca705d24 100644 --- a/v2/emailpassword/serverless/with-aws-lambda/authorizer.mdx +++ b/v2/emailpassword/serverless/with-aws-lambda/authorizer.mdx @@ -151,8 +151,8 @@ Use the code below as the handler for the lambda. Remember that whenever we want ```tsx title="index.mjs" import supertokens from "supertokens-node"; -import { SessionEvent } from "supertokens-node/framework/awsLambda"; -import { APIGatewayAuthorizerEvent, PolicyDocument, Statement, AuthResponse } from "aws-lambda"; +import { SessionEvent } from "supertokens-node/framework/awsLambda"; // typecheck-only, removed from output +import { APIGatewayAuthorizerEvent, PolicyDocument, Statement, AuthResponse } from "aws-lambda"; // typecheck-only, removed from output import Session from "supertokens-node/recipe/session"; // @ts-ignore @@ -160,9 +160,9 @@ import { getBackendConfig } from "./config.mjs"; supertokens.init(getBackendConfig()); -type AuthorizerEvent = SessionEvent & APIGatewayAuthorizerEvent; +type AuthorizerEvent = SessionEvent & APIGatewayAuthorizerEvent; // typecheck-only, removed from output -export const handler = async function (event: AuthorizerEvent) { +export const handler = async function (event__OMIT_START__: AuthorizerEvent__OMIT_END__) { try { const session = await Session.getSession(event, event, { sessionRequired: false }); if (session) { @@ -198,14 +198,14 @@ export const handler = async function (event: AuthorizerEvent) { } // Help function to generate an IAM policy -const generatePolicy = function (principalId: string, effect: string, resource: string, context?: any) { +const generatePolicy = function (principalId__OMIT_START__: string__OMIT_END__, effect__OMIT_START__: string__OMIT_END__, resource__OMIT_START__: string__OMIT_END__, context__OMIT_START__?: any__OMIT_END__) { // Required output: - const policyDocument: PolicyDocument = { + const policyDocument__OMIT_START__: PolicyDocument__OMIT_END__ = { Version: '2012-10-17', Statement: [], }; - const statementOne: Statement = { + const statementOne__OMIT_START__: Statement__OMIT_END__ = { Action: 'execute-api:Invoke', Effect: effect, Resource: resource, @@ -213,7 +213,7 @@ const generatePolicy = function (principalId: string, effect: string, resource: policyDocument.Statement[0] = statementOne; - const authResponse: AuthResponse = { + const authResponse__OMIT_START__: AuthResponse__OMIT_END__ = { principalId: principalId, policyDocument: policyDocument, // Optional output with custom properties of the String, Number or Boolean type. @@ -223,11 +223,11 @@ const generatePolicy = function (principalId: string, effect: string, resource: return authResponse; } -const generateAllow = function (principalId: string, resource: string, context?: any) { +const generateAllow = function (principalId__OMIT_START__: string__OMIT_END__, resource__OMIT_START__: string__OMIT_END__, context__OMIT_START__?: any__OMIT_END__) { return generatePolicy(principalId, 'Allow', resource, context); }; -const generateDeny = function (principalId: string, resource: string, context?: any) { +const generateDeny = function (principalId__OMIT_START__: string__OMIT_END__, resource__OMIT_START__: string__OMIT_END__, context__OMIT_START__?: any__OMIT_END__) { return generatePolicy(principalId, 'Deny', resource, context); }; ``` diff --git a/v2/emailpassword/serverless/with-aws-lambda/jwt-authorizer.mdx b/v2/emailpassword/serverless/with-aws-lambda/jwt-authorizer.mdx index 109de3c64..ae937766b 100644 --- a/v2/emailpassword/serverless/with-aws-lambda/jwt-authorizer.mdx +++ b/v2/emailpassword/serverless/with-aws-lambda/jwt-authorizer.mdx @@ -35,9 +35,9 @@ AWS supports JWT authorizers for HTTP APIs and not REST APIs on the API Gateway ```tsx title="config.mjs" import Session from 'supertokens-node/recipe/session' -import SuperTokensTypes from 'supertokens-node/types'; +import SuperTokensTypes from 'supertokens-node/types'; // typecheck-only, removed from output -export function getBackendConfig(): SuperTokensTypes.TypeInput { +export function getBackendConfig()__OMIT_START__: SuperTokensTypes.TypeInput__OMIT_END__ { return { framework: "awsLambda", supertokens: { diff --git a/v2/passwordless/serverless/with-aws-lambda/authorizer.mdx b/v2/passwordless/serverless/with-aws-lambda/authorizer.mdx index 1260f5f89..79b62439b 100644 --- a/v2/passwordless/serverless/with-aws-lambda/authorizer.mdx +++ b/v2/passwordless/serverless/with-aws-lambda/authorizer.mdx @@ -151,8 +151,8 @@ Use the code below as the handler for the lambda. Remember that whenever we want ```tsx title="index.mjs" import supertokens from "supertokens-node"; -import { SessionEvent } from "supertokens-node/framework/awsLambda"; -import { APIGatewayAuthorizerEvent, PolicyDocument, Statement, AuthResponse } from "aws-lambda"; +import { SessionEvent } from "supertokens-node/framework/awsLambda"; // typecheck-only, removed from output +import { APIGatewayAuthorizerEvent, PolicyDocument, Statement, AuthResponse } from "aws-lambda"; // typecheck-only, removed from output import Session from "supertokens-node/recipe/session"; // @ts-ignore @@ -160,9 +160,9 @@ import { getBackendConfig } from "./config.mjs"; supertokens.init(getBackendConfig()); -type AuthorizerEvent = SessionEvent & APIGatewayAuthorizerEvent; +type AuthorizerEvent = SessionEvent & APIGatewayAuthorizerEvent; // typecheck-only, removed from output -export const handler = async function (event: AuthorizerEvent) { +export const handler = async function (event__OMIT_START__: AuthorizerEvent__OMIT_END__) { try { const session = await Session.getSession(event, event, { sessionRequired: false }); if (session) { @@ -198,14 +198,14 @@ export const handler = async function (event: AuthorizerEvent) { } // Help function to generate an IAM policy -const generatePolicy = function (principalId: string, effect: string, resource: string, context?: any) { +const generatePolicy = function (principalId__OMIT_START__: string__OMIT_END__, effect__OMIT_START__: string__OMIT_END__, resource__OMIT_START__: string__OMIT_END__, context__OMIT_START__?: any__OMIT_END__) { // Required output: - const policyDocument: PolicyDocument = { + const policyDocument__OMIT_START__: PolicyDocument__OMIT_END__ = { Version: '2012-10-17', Statement: [], }; - const statementOne: Statement = { + const statementOne__OMIT_START__: Statement__OMIT_END__ = { Action: 'execute-api:Invoke', Effect: effect, Resource: resource, @@ -213,7 +213,7 @@ const generatePolicy = function (principalId: string, effect: string, resource: policyDocument.Statement[0] = statementOne; - const authResponse: AuthResponse = { + const authResponse__OMIT_START__: AuthResponse__OMIT_END__ = { principalId: principalId, policyDocument: policyDocument, // Optional output with custom properties of the String, Number or Boolean type. @@ -223,11 +223,11 @@ const generatePolicy = function (principalId: string, effect: string, resource: return authResponse; } -const generateAllow = function (principalId: string, resource: string, context?: any) { +const generateAllow = function (principalId__OMIT_START__: string__OMIT_END__, resource__OMIT_START__: string__OMIT_END__, context__OMIT_START__?: any__OMIT_END__) { return generatePolicy(principalId, 'Allow', resource, context); }; -const generateDeny = function (principalId: string, resource: string, context?: any) { +const generateDeny = function (principalId__OMIT_START__: string__OMIT_END__, resource__OMIT_START__: string__OMIT_END__, context__OMIT_START__?: any__OMIT_END__) { return generatePolicy(principalId, 'Deny', resource, context); }; ``` diff --git a/v2/passwordless/serverless/with-aws-lambda/jwt-authorizer.mdx b/v2/passwordless/serverless/with-aws-lambda/jwt-authorizer.mdx index 109de3c64..ae937766b 100644 --- a/v2/passwordless/serverless/with-aws-lambda/jwt-authorizer.mdx +++ b/v2/passwordless/serverless/with-aws-lambda/jwt-authorizer.mdx @@ -35,9 +35,9 @@ AWS supports JWT authorizers for HTTP APIs and not REST APIs on the API Gateway ```tsx title="config.mjs" import Session from 'supertokens-node/recipe/session' -import SuperTokensTypes from 'supertokens-node/types'; +import SuperTokensTypes from 'supertokens-node/types'; // typecheck-only, removed from output -export function getBackendConfig(): SuperTokensTypes.TypeInput { +export function getBackendConfig()__OMIT_START__: SuperTokensTypes.TypeInput__OMIT_END__ { return { framework: "awsLambda", supertokens: { diff --git a/v2/session/serverless/with-aws-lambda/authorizer.mdx b/v2/session/serverless/with-aws-lambda/authorizer.mdx index 45ebf1fbb..1ca705d24 100644 --- a/v2/session/serverless/with-aws-lambda/authorizer.mdx +++ b/v2/session/serverless/with-aws-lambda/authorizer.mdx @@ -151,8 +151,8 @@ Use the code below as the handler for the lambda. Remember that whenever we want ```tsx title="index.mjs" import supertokens from "supertokens-node"; -import { SessionEvent } from "supertokens-node/framework/awsLambda"; -import { APIGatewayAuthorizerEvent, PolicyDocument, Statement, AuthResponse } from "aws-lambda"; +import { SessionEvent } from "supertokens-node/framework/awsLambda"; // typecheck-only, removed from output +import { APIGatewayAuthorizerEvent, PolicyDocument, Statement, AuthResponse } from "aws-lambda"; // typecheck-only, removed from output import Session from "supertokens-node/recipe/session"; // @ts-ignore @@ -160,9 +160,9 @@ import { getBackendConfig } from "./config.mjs"; supertokens.init(getBackendConfig()); -type AuthorizerEvent = SessionEvent & APIGatewayAuthorizerEvent; +type AuthorizerEvent = SessionEvent & APIGatewayAuthorizerEvent; // typecheck-only, removed from output -export const handler = async function (event: AuthorizerEvent) { +export const handler = async function (event__OMIT_START__: AuthorizerEvent__OMIT_END__) { try { const session = await Session.getSession(event, event, { sessionRequired: false }); if (session) { @@ -198,14 +198,14 @@ export const handler = async function (event: AuthorizerEvent) { } // Help function to generate an IAM policy -const generatePolicy = function (principalId: string, effect: string, resource: string, context?: any) { +const generatePolicy = function (principalId__OMIT_START__: string__OMIT_END__, effect__OMIT_START__: string__OMIT_END__, resource__OMIT_START__: string__OMIT_END__, context__OMIT_START__?: any__OMIT_END__) { // Required output: - const policyDocument: PolicyDocument = { + const policyDocument__OMIT_START__: PolicyDocument__OMIT_END__ = { Version: '2012-10-17', Statement: [], }; - const statementOne: Statement = { + const statementOne__OMIT_START__: Statement__OMIT_END__ = { Action: 'execute-api:Invoke', Effect: effect, Resource: resource, @@ -213,7 +213,7 @@ const generatePolicy = function (principalId: string, effect: string, resource: policyDocument.Statement[0] = statementOne; - const authResponse: AuthResponse = { + const authResponse__OMIT_START__: AuthResponse__OMIT_END__ = { principalId: principalId, policyDocument: policyDocument, // Optional output with custom properties of the String, Number or Boolean type. @@ -223,11 +223,11 @@ const generatePolicy = function (principalId: string, effect: string, resource: return authResponse; } -const generateAllow = function (principalId: string, resource: string, context?: any) { +const generateAllow = function (principalId__OMIT_START__: string__OMIT_END__, resource__OMIT_START__: string__OMIT_END__, context__OMIT_START__?: any__OMIT_END__) { return generatePolicy(principalId, 'Allow', resource, context); }; -const generateDeny = function (principalId: string, resource: string, context?: any) { +const generateDeny = function (principalId__OMIT_START__: string__OMIT_END__, resource__OMIT_START__: string__OMIT_END__, context__OMIT_START__?: any__OMIT_END__) { return generatePolicy(principalId, 'Deny', resource, context); }; ``` diff --git a/v2/session/serverless/with-aws-lambda/jwt-authorizer.mdx b/v2/session/serverless/with-aws-lambda/jwt-authorizer.mdx index 109de3c64..ae937766b 100644 --- a/v2/session/serverless/with-aws-lambda/jwt-authorizer.mdx +++ b/v2/session/serverless/with-aws-lambda/jwt-authorizer.mdx @@ -35,9 +35,9 @@ AWS supports JWT authorizers for HTTP APIs and not REST APIs on the API Gateway ```tsx title="config.mjs" import Session from 'supertokens-node/recipe/session' -import SuperTokensTypes from 'supertokens-node/types'; +import SuperTokensTypes from 'supertokens-node/types'; // typecheck-only, removed from output -export function getBackendConfig(): SuperTokensTypes.TypeInput { +export function getBackendConfig()__OMIT_START__: SuperTokensTypes.TypeInput__OMIT_END__ { return { framework: "awsLambda", supertokens: { diff --git a/v2/static/img/integration-lambda/add-a-layer.png b/v2/static/img/integration-lambda/add-a-layer.png index b182b769b..3fbfaae15 100644 Binary files a/v2/static/img/integration-lambda/add-a-layer.png and b/v2/static/img/integration-lambda/add-a-layer.png differ diff --git a/v2/static/img/integration-lambda/add-auth-middleware-node.png b/v2/static/img/integration-lambda/add-auth-middleware-node.png index 6f03cc2f5..165c1dbda 100644 Binary files a/v2/static/img/integration-lambda/add-auth-middleware-node.png and b/v2/static/img/integration-lambda/add-auth-middleware-node.png differ diff --git a/v2/static/img/integration-lambda/add-env-var-node.png b/v2/static/img/integration-lambda/add-env-var-node.png index 1d9e54bc5..5c4f15f4a 100644 Binary files a/v2/static/img/integration-lambda/add-env-var-node.png and b/v2/static/img/integration-lambda/add-env-var-node.png differ diff --git a/v2/static/img/integration-lambda/add-layer-detail-node.png b/v2/static/img/integration-lambda/add-layer-detail-node.png index 9ae96b62e..534f91f40 100644 Binary files a/v2/static/img/integration-lambda/add-layer-detail-node.png and b/v2/static/img/integration-lambda/add-layer-detail-node.png differ diff --git a/v2/static/img/integration-lambda/click-enable-cors.png b/v2/static/img/integration-lambda/click-enable-cors.png index 6a2ca2ff2..818d03df5 100644 Binary files a/v2/static/img/integration-lambda/click-enable-cors.png and b/v2/static/img/integration-lambda/click-enable-cors.png differ diff --git a/v2/static/img/integration-lambda/configure-cors.png b/v2/static/img/integration-lambda/configure-cors.png index b4fd54d7a..d50b72c4b 100644 Binary files a/v2/static/img/integration-lambda/configure-cors.png and b/v2/static/img/integration-lambda/configure-cors.png differ diff --git a/v2/static/img/integration-lambda/configure-lambda-integration.png b/v2/static/img/integration-lambda/configure-lambda-integration.png index 945c6af53..746ab7931 100644 Binary files a/v2/static/img/integration-lambda/configure-lambda-integration.png and b/v2/static/img/integration-lambda/configure-lambda-integration.png differ diff --git a/v2/static/img/integration-lambda/create-api-gateway.png b/v2/static/img/integration-lambda/create-api-gateway.png index 580d7b699..79e074ce1 100644 Binary files a/v2/static/img/integration-lambda/create-api-gateway.png and b/v2/static/img/integration-lambda/create-api-gateway.png differ diff --git a/v2/static/img/integration-lambda/create-function-node.png b/v2/static/img/integration-lambda/create-function-node.png index f438c3639..d13fa9941 100644 Binary files a/v2/static/img/integration-lambda/create-function-node.png and b/v2/static/img/integration-lambda/create-function-node.png differ diff --git a/v2/static/img/integration-lambda/create-function-python.png b/v2/static/img/integration-lambda/create-function-python.png index d1a4d6e20..bc6227978 100644 Binary files a/v2/static/img/integration-lambda/create-function-python.png and b/v2/static/img/integration-lambda/create-function-python.png differ diff --git a/v2/static/img/integration-lambda/create-proxy-route.png b/v2/static/img/integration-lambda/create-proxy-route.png index 44df23692..63587fc1c 100644 Binary files a/v2/static/img/integration-lambda/create-proxy-route.png and b/v2/static/img/integration-lambda/create-proxy-route.png differ diff --git a/v2/static/img/integration-lambda/node-lambda-layer.png b/v2/static/img/integration-lambda/node-lambda-layer.png index 9dc5f37f8..5189fcba0 100644 Binary files a/v2/static/img/integration-lambda/node-lambda-layer.png and b/v2/static/img/integration-lambda/node-lambda-layer.png differ diff --git a/v2/static/img/integration-lambda/route-creation-complete.png b/v2/static/img/integration-lambda/route-creation-complete.png index 835530a99..db30114d3 100644 Binary files a/v2/static/img/integration-lambda/route-creation-complete.png and b/v2/static/img/integration-lambda/route-creation-complete.png differ diff --git a/v2/thirdparty/serverless/with-aws-lambda/authorizer.mdx b/v2/thirdparty/serverless/with-aws-lambda/authorizer.mdx index 45ebf1fbb..1ca705d24 100644 --- a/v2/thirdparty/serverless/with-aws-lambda/authorizer.mdx +++ b/v2/thirdparty/serverless/with-aws-lambda/authorizer.mdx @@ -151,8 +151,8 @@ Use the code below as the handler for the lambda. Remember that whenever we want ```tsx title="index.mjs" import supertokens from "supertokens-node"; -import { SessionEvent } from "supertokens-node/framework/awsLambda"; -import { APIGatewayAuthorizerEvent, PolicyDocument, Statement, AuthResponse } from "aws-lambda"; +import { SessionEvent } from "supertokens-node/framework/awsLambda"; // typecheck-only, removed from output +import { APIGatewayAuthorizerEvent, PolicyDocument, Statement, AuthResponse } from "aws-lambda"; // typecheck-only, removed from output import Session from "supertokens-node/recipe/session"; // @ts-ignore @@ -160,9 +160,9 @@ import { getBackendConfig } from "./config.mjs"; supertokens.init(getBackendConfig()); -type AuthorizerEvent = SessionEvent & APIGatewayAuthorizerEvent; +type AuthorizerEvent = SessionEvent & APIGatewayAuthorizerEvent; // typecheck-only, removed from output -export const handler = async function (event: AuthorizerEvent) { +export const handler = async function (event__OMIT_START__: AuthorizerEvent__OMIT_END__) { try { const session = await Session.getSession(event, event, { sessionRequired: false }); if (session) { @@ -198,14 +198,14 @@ export const handler = async function (event: AuthorizerEvent) { } // Help function to generate an IAM policy -const generatePolicy = function (principalId: string, effect: string, resource: string, context?: any) { +const generatePolicy = function (principalId__OMIT_START__: string__OMIT_END__, effect__OMIT_START__: string__OMIT_END__, resource__OMIT_START__: string__OMIT_END__, context__OMIT_START__?: any__OMIT_END__) { // Required output: - const policyDocument: PolicyDocument = { + const policyDocument__OMIT_START__: PolicyDocument__OMIT_END__ = { Version: '2012-10-17', Statement: [], }; - const statementOne: Statement = { + const statementOne__OMIT_START__: Statement__OMIT_END__ = { Action: 'execute-api:Invoke', Effect: effect, Resource: resource, @@ -213,7 +213,7 @@ const generatePolicy = function (principalId: string, effect: string, resource: policyDocument.Statement[0] = statementOne; - const authResponse: AuthResponse = { + const authResponse__OMIT_START__: AuthResponse__OMIT_END__ = { principalId: principalId, policyDocument: policyDocument, // Optional output with custom properties of the String, Number or Boolean type. @@ -223,11 +223,11 @@ const generatePolicy = function (principalId: string, effect: string, resource: return authResponse; } -const generateAllow = function (principalId: string, resource: string, context?: any) { +const generateAllow = function (principalId__OMIT_START__: string__OMIT_END__, resource__OMIT_START__: string__OMIT_END__, context__OMIT_START__?: any__OMIT_END__) { return generatePolicy(principalId, 'Allow', resource, context); }; -const generateDeny = function (principalId: string, resource: string, context?: any) { +const generateDeny = function (principalId__OMIT_START__: string__OMIT_END__, resource__OMIT_START__: string__OMIT_END__, context__OMIT_START__?: any__OMIT_END__) { return generatePolicy(principalId, 'Deny', resource, context); }; ``` diff --git a/v2/thirdparty/serverless/with-aws-lambda/jwt-authorizer.mdx b/v2/thirdparty/serverless/with-aws-lambda/jwt-authorizer.mdx index 109de3c64..ae937766b 100644 --- a/v2/thirdparty/serverless/with-aws-lambda/jwt-authorizer.mdx +++ b/v2/thirdparty/serverless/with-aws-lambda/jwt-authorizer.mdx @@ -35,9 +35,9 @@ AWS supports JWT authorizers for HTTP APIs and not REST APIs on the API Gateway ```tsx title="config.mjs" import Session from 'supertokens-node/recipe/session' -import SuperTokensTypes from 'supertokens-node/types'; +import SuperTokensTypes from 'supertokens-node/types'; // typecheck-only, removed from output -export function getBackendConfig(): SuperTokensTypes.TypeInput { +export function getBackendConfig()__OMIT_START__: SuperTokensTypes.TypeInput__OMIT_END__ { return { framework: "awsLambda", supertokens: { diff --git a/v2/thirdpartyemailpassword/serverless/with-aws-lambda/authorizer.mdx b/v2/thirdpartyemailpassword/serverless/with-aws-lambda/authorizer.mdx index 45ebf1fbb..1ca705d24 100644 --- a/v2/thirdpartyemailpassword/serverless/with-aws-lambda/authorizer.mdx +++ b/v2/thirdpartyemailpassword/serverless/with-aws-lambda/authorizer.mdx @@ -151,8 +151,8 @@ Use the code below as the handler for the lambda. Remember that whenever we want ```tsx title="index.mjs" import supertokens from "supertokens-node"; -import { SessionEvent } from "supertokens-node/framework/awsLambda"; -import { APIGatewayAuthorizerEvent, PolicyDocument, Statement, AuthResponse } from "aws-lambda"; +import { SessionEvent } from "supertokens-node/framework/awsLambda"; // typecheck-only, removed from output +import { APIGatewayAuthorizerEvent, PolicyDocument, Statement, AuthResponse } from "aws-lambda"; // typecheck-only, removed from output import Session from "supertokens-node/recipe/session"; // @ts-ignore @@ -160,9 +160,9 @@ import { getBackendConfig } from "./config.mjs"; supertokens.init(getBackendConfig()); -type AuthorizerEvent = SessionEvent & APIGatewayAuthorizerEvent; +type AuthorizerEvent = SessionEvent & APIGatewayAuthorizerEvent; // typecheck-only, removed from output -export const handler = async function (event: AuthorizerEvent) { +export const handler = async function (event__OMIT_START__: AuthorizerEvent__OMIT_END__) { try { const session = await Session.getSession(event, event, { sessionRequired: false }); if (session) { @@ -198,14 +198,14 @@ export const handler = async function (event: AuthorizerEvent) { } // Help function to generate an IAM policy -const generatePolicy = function (principalId: string, effect: string, resource: string, context?: any) { +const generatePolicy = function (principalId__OMIT_START__: string__OMIT_END__, effect__OMIT_START__: string__OMIT_END__, resource__OMIT_START__: string__OMIT_END__, context__OMIT_START__?: any__OMIT_END__) { // Required output: - const policyDocument: PolicyDocument = { + const policyDocument__OMIT_START__: PolicyDocument__OMIT_END__ = { Version: '2012-10-17', Statement: [], }; - const statementOne: Statement = { + const statementOne__OMIT_START__: Statement__OMIT_END__ = { Action: 'execute-api:Invoke', Effect: effect, Resource: resource, @@ -213,7 +213,7 @@ const generatePolicy = function (principalId: string, effect: string, resource: policyDocument.Statement[0] = statementOne; - const authResponse: AuthResponse = { + const authResponse__OMIT_START__: AuthResponse__OMIT_END__ = { principalId: principalId, policyDocument: policyDocument, // Optional output with custom properties of the String, Number or Boolean type. @@ -223,11 +223,11 @@ const generatePolicy = function (principalId: string, effect: string, resource: return authResponse; } -const generateAllow = function (principalId: string, resource: string, context?: any) { +const generateAllow = function (principalId__OMIT_START__: string__OMIT_END__, resource__OMIT_START__: string__OMIT_END__, context__OMIT_START__?: any__OMIT_END__) { return generatePolicy(principalId, 'Allow', resource, context); }; -const generateDeny = function (principalId: string, resource: string, context?: any) { +const generateDeny = function (principalId__OMIT_START__: string__OMIT_END__, resource__OMIT_START__: string__OMIT_END__, context__OMIT_START__?: any__OMIT_END__) { return generatePolicy(principalId, 'Deny', resource, context); }; ``` diff --git a/v2/thirdpartyemailpassword/serverless/with-aws-lambda/jwt-authorizer.mdx b/v2/thirdpartyemailpassword/serverless/with-aws-lambda/jwt-authorizer.mdx index 109de3c64..ae937766b 100644 --- a/v2/thirdpartyemailpassword/serverless/with-aws-lambda/jwt-authorizer.mdx +++ b/v2/thirdpartyemailpassword/serverless/with-aws-lambda/jwt-authorizer.mdx @@ -35,9 +35,9 @@ AWS supports JWT authorizers for HTTP APIs and not REST APIs on the API Gateway ```tsx title="config.mjs" import Session from 'supertokens-node/recipe/session' -import SuperTokensTypes from 'supertokens-node/types'; +import SuperTokensTypes from 'supertokens-node/types'; // typecheck-only, removed from output -export function getBackendConfig(): SuperTokensTypes.TypeInput { +export function getBackendConfig()__OMIT_START__: SuperTokensTypes.TypeInput__OMIT_END__ { return { framework: "awsLambda", supertokens: { diff --git a/v2/thirdpartypasswordless/serverless/with-aws-lambda/authorizer.mdx b/v2/thirdpartypasswordless/serverless/with-aws-lambda/authorizer.mdx index 1260f5f89..79b62439b 100644 --- a/v2/thirdpartypasswordless/serverless/with-aws-lambda/authorizer.mdx +++ b/v2/thirdpartypasswordless/serverless/with-aws-lambda/authorizer.mdx @@ -151,8 +151,8 @@ Use the code below as the handler for the lambda. Remember that whenever we want ```tsx title="index.mjs" import supertokens from "supertokens-node"; -import { SessionEvent } from "supertokens-node/framework/awsLambda"; -import { APIGatewayAuthorizerEvent, PolicyDocument, Statement, AuthResponse } from "aws-lambda"; +import { SessionEvent } from "supertokens-node/framework/awsLambda"; // typecheck-only, removed from output +import { APIGatewayAuthorizerEvent, PolicyDocument, Statement, AuthResponse } from "aws-lambda"; // typecheck-only, removed from output import Session from "supertokens-node/recipe/session"; // @ts-ignore @@ -160,9 +160,9 @@ import { getBackendConfig } from "./config.mjs"; supertokens.init(getBackendConfig()); -type AuthorizerEvent = SessionEvent & APIGatewayAuthorizerEvent; +type AuthorizerEvent = SessionEvent & APIGatewayAuthorizerEvent; // typecheck-only, removed from output -export const handler = async function (event: AuthorizerEvent) { +export const handler = async function (event__OMIT_START__: AuthorizerEvent__OMIT_END__) { try { const session = await Session.getSession(event, event, { sessionRequired: false }); if (session) { @@ -198,14 +198,14 @@ export const handler = async function (event: AuthorizerEvent) { } // Help function to generate an IAM policy -const generatePolicy = function (principalId: string, effect: string, resource: string, context?: any) { +const generatePolicy = function (principalId__OMIT_START__: string__OMIT_END__, effect__OMIT_START__: string__OMIT_END__, resource__OMIT_START__: string__OMIT_END__, context__OMIT_START__?: any__OMIT_END__) { // Required output: - const policyDocument: PolicyDocument = { + const policyDocument__OMIT_START__: PolicyDocument__OMIT_END__ = { Version: '2012-10-17', Statement: [], }; - const statementOne: Statement = { + const statementOne__OMIT_START__: Statement__OMIT_END__ = { Action: 'execute-api:Invoke', Effect: effect, Resource: resource, @@ -213,7 +213,7 @@ const generatePolicy = function (principalId: string, effect: string, resource: policyDocument.Statement[0] = statementOne; - const authResponse: AuthResponse = { + const authResponse__OMIT_START__: AuthResponse__OMIT_END__ = { principalId: principalId, policyDocument: policyDocument, // Optional output with custom properties of the String, Number or Boolean type. @@ -223,11 +223,11 @@ const generatePolicy = function (principalId: string, effect: string, resource: return authResponse; } -const generateAllow = function (principalId: string, resource: string, context?: any) { +const generateAllow = function (principalId__OMIT_START__: string__OMIT_END__, resource__OMIT_START__: string__OMIT_END__, context__OMIT_START__?: any__OMIT_END__) { return generatePolicy(principalId, 'Allow', resource, context); }; -const generateDeny = function (principalId: string, resource: string, context?: any) { +const generateDeny = function (principalId__OMIT_START__: string__OMIT_END__, resource__OMIT_START__: string__OMIT_END__, context__OMIT_START__?: any__OMIT_END__) { return generatePolicy(principalId, 'Deny', resource, context); }; ``` diff --git a/v2/thirdpartypasswordless/serverless/with-aws-lambda/jwt-authorizer.mdx b/v2/thirdpartypasswordless/serverless/with-aws-lambda/jwt-authorizer.mdx index 109de3c64..ae937766b 100644 --- a/v2/thirdpartypasswordless/serverless/with-aws-lambda/jwt-authorizer.mdx +++ b/v2/thirdpartypasswordless/serverless/with-aws-lambda/jwt-authorizer.mdx @@ -35,9 +35,9 @@ AWS supports JWT authorizers for HTTP APIs and not REST APIs on the API Gateway ```tsx title="config.mjs" import Session from 'supertokens-node/recipe/session' -import SuperTokensTypes from 'supertokens-node/types'; +import SuperTokensTypes from 'supertokens-node/types'; // typecheck-only, removed from output -export function getBackendConfig(): SuperTokensTypes.TypeInput { +export function getBackendConfig()__OMIT_START__: SuperTokensTypes.TypeInput__OMIT_END__ { return { framework: "awsLambda", supertokens: {