mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
add CustomAuthorizerCallback & AuthResponse
This commit is contained in:
parent
5a634f7fdb
commit
60bda6cf4f
@ -12,6 +12,10 @@ var clientContextClient: AWSLambda.ClientContextClient;
|
||||
var context: AWSLambda.Context;
|
||||
var identity: AWSLambda.CognitoIdentity;
|
||||
var proxyResult: AWSLambda.ProxyResult;
|
||||
var authResponse: AWSLambda.AuthResponse;
|
||||
var policyDocument: AWSLambda.PolicyDocument;
|
||||
var statement: AWSLambda.Statement;
|
||||
var authResponseContext: AWSLambda.AuthResponseContext;
|
||||
var snsEvt: AWSLambda.SNSEvent;
|
||||
var snsEvtRecs: AWSLambda.SNSEventRecord[];
|
||||
var snsEvtRec: AWSLambda.SNSEventRecord;
|
||||
@ -125,6 +129,41 @@ proxyResult.headers["example"] = b;
|
||||
proxyResult.headers["example"] = num;
|
||||
str = proxyResult.body;
|
||||
|
||||
/* API Gateway CustomAuthorizer AuthResponse */
|
||||
authResponseContext = {
|
||||
stringKey: str,
|
||||
numberKey: num,
|
||||
booleanKey: b
|
||||
};
|
||||
|
||||
statement = {
|
||||
Action: str,
|
||||
Effect: str,
|
||||
Resource: str
|
||||
};
|
||||
|
||||
statement = {
|
||||
Action: str,
|
||||
Effect: str,
|
||||
Resource: [str, str]
|
||||
};
|
||||
|
||||
policyDocument = {
|
||||
Version: str,
|
||||
Statement: [statement]
|
||||
};
|
||||
|
||||
authResponse = {
|
||||
principalId: str,
|
||||
policyDocument: policyDocument,
|
||||
context: authResponseContext
|
||||
};
|
||||
|
||||
authResponse = {
|
||||
principalId: str,
|
||||
policyDocument: policyDocument
|
||||
};
|
||||
|
||||
/* Context */
|
||||
b = context.callbackWaitsForEmptyEventLoop;
|
||||
str = context.functionName;
|
||||
@ -176,6 +215,14 @@ function proxyCallback(cb: AWSLambda.ProxyCallback) {
|
||||
cb(null, proxyResult);
|
||||
}
|
||||
|
||||
/* CustomAuthorizerCallback */
|
||||
function customAuthorizerCallback(cb: AWSLambda.CustomAuthorizerCallback) {
|
||||
cb();
|
||||
cb(null);
|
||||
cb(error);
|
||||
cb(null, authResponse);
|
||||
}
|
||||
|
||||
/* Compatibility functions */
|
||||
context.done();
|
||||
context.done(error);
|
||||
@ -189,4 +236,4 @@ context.fail(str);
|
||||
/* Handler */
|
||||
let handler: AWSLambda.Handler = (event: any, context: AWSLambda.Context, cb: AWSLambda.Callback) => { };
|
||||
let proxyHandler: AWSLambda.ProxyHandler = (event: AWSLambda.APIGatewayEvent, context: AWSLambda.Context, cb: AWSLambda.ProxyCallback) => { };
|
||||
let CustomAuthorizerHandler: AWSLambda.CustomAuthorizerHandler = (event: AWSLambda.CustomAuthorizerEvent, context: AWSLambda.Context, cb: AWSLambda.Callback) => { };
|
||||
let CustomAuthorizerHandler: AWSLambda.CustomAuthorizerHandler = (event: AWSLambda.CustomAuthorizerEvent, context: AWSLambda.Context, cb: AWSLambda.CustomAuthorizerCallback) => { };
|
||||
|
||||
42
types/aws-lambda/index.d.ts
vendored
42
types/aws-lambda/index.d.ts
vendored
@ -187,6 +187,45 @@ interface ProxyResult {
|
||||
body: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* API Gateway CustomAuthorizer AuthResponse.
|
||||
* http://docs.aws.amazon.com/apigateway/latest/developerguide/use-custom-authorizer.html#api-gateway-custom-authorizer-output
|
||||
*/
|
||||
interface AuthResponse {
|
||||
principalId: string;
|
||||
policyDocument: PolicyDocument;
|
||||
context?: AuthResponseContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* API Gateway CustomAuthorizer AuthResponse.PolicyDocument.
|
||||
* http://docs.aws.amazon.com/apigateway/latest/developerguide/use-custom-authorizer.html#api-gateway-custom-authorizer-output
|
||||
*/
|
||||
interface PolicyDocument {
|
||||
Version: string;
|
||||
Statement: [Statement];
|
||||
}
|
||||
|
||||
/**
|
||||
* API Gateway CustomAuthorizer AuthResponse.PolicyDocument.Statement.
|
||||
* http://docs.aws.amazon.com/apigateway/latest/developerguide/use-custom-authorizer.html#api-gateway-custom-authorizer-output
|
||||
*/
|
||||
interface Statement {
|
||||
Action: string;
|
||||
Effect: string;
|
||||
Resource: string | [string];
|
||||
}
|
||||
|
||||
/**
|
||||
* API Gateway CustomAuthorizer AuthResponse.PolicyDocument.Statement.
|
||||
* http://docs.aws.amazon.com/apigateway/latest/developerguide/use-custom-authorizer.html#api-gateway-custom-authorizer-output
|
||||
*/
|
||||
interface AuthResponseContext {
|
||||
stringKey: string;
|
||||
numberKey: number;
|
||||
booleanKey: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* AWS Lambda handler function.
|
||||
* http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html
|
||||
@ -197,7 +236,7 @@ interface ProxyResult {
|
||||
*/
|
||||
export type Handler = (event: any, context: Context, callback?: Callback) => void;
|
||||
export type ProxyHandler = (event: APIGatewayEvent, context: Context, callback?: ProxyCallback) => void;
|
||||
export type CustomAuthorizerHandler = (event: CustomAuthorizerEvent, context: Context, callback?: Callback) => void;
|
||||
export type CustomAuthorizerHandler = (event: CustomAuthorizerEvent, context: Context, callback?: CustomAuthorizerCallback) => void;
|
||||
|
||||
/**
|
||||
* Optional callback parameter.
|
||||
@ -208,5 +247,6 @@ export type CustomAuthorizerHandler = (event: CustomAuthorizerEvent, context: Co
|
||||
*/
|
||||
export type Callback = (error?: Error, result?: any) => void;
|
||||
export type ProxyCallback = (error?: Error, result?: ProxyResult) => void;
|
||||
export type CustomAuthorizerCallback = (error?: Error, result?: AuthResponse) => void;
|
||||
|
||||
export as namespace AWSLambda;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user