How to use the Signers function from aws-sdk

Find comprehensive JavaScript aws-sdk.Signers code examples handpicked from public code repositorys.

22
23
24
25
26
27
28
29
30
31
req.headers['presigned-expires'] = false;
req.headers['Host'] = openSearchDomain.endpoint;
req.headers['Content-Type'] = 'application/json';

// Sign the request (Sigv4)
var signer = new AWS.Signers.V4(req, 'es');
signer.addAuthorization(creds, new Date());

// Post document to the OpenSearch Service
var send = new AWS.NodeHttpClient();
fork icon201
star icon952
watch icon0

100
101
102
103
104
105
106
107
108
109
110
111
    }
  }); 
}


function makePercolatorRequest(req, callback) {
  const signer = new AWS.Signers.V4(req, 'es');
  signer.addAuthorization(creds, new Date());


  const client = new AWS.NodeHttpClient();
  client.handleRequest(req, null, function(httpResp) {
fork icon5
star icon12
watch icon0

87
88
89
90
91
92
93
94
95
96
// Content-Length is only needed for DELETE requests that include a request
// body, but including it for all requests doesn't seem to hurt anything.
request.headers['Content-Length'] = Buffer.byteLength(request.body);

var credentials = new AWS.EnvironmentCredentials('AWS');
var signer = new AWS.Signers.V4(request, 'es');
signer.addAuthorization(credentials, new Date());

var client = new AWS.HttpClient();
client.handleRequest(request, null, function (response) {
fork icon2
star icon4
watch icon0

26
27
28
29
30
31
32
33
34
request.headers['host'] = domain;
// returns an object, but needs to be a string
// turns out including it does, in fact, hurt anything
// request.headers['Content-Length'] = Buffer.byteLength(request.body);

// const signer = new AWS.Signers.V4(request, 'es');
// signer.addAuthorization(credentials, new Date());

console.log('REQUEST, YO : ', request);
fork icon0
star icon1
watch icon0

25
26
27
28
29
30
31
32
33
34
request.headers['host'] = domain;
request.headers['Content-Type'] = 'application/json';
request.headers['Content-Length'] = request.body.length;

var credentials = new AWS.EnvironmentCredentials('AWS');
var signer = new AWS.Signers.V3(request, 'es');
signer.addAuthorization(credentials, new Date());

var client = new AWS.HttpClient();
client.handleRequest(request, null, function(response) {
fork icon3
star icon0
watch icon0

59
60
61
62
63
64
65
66
67
68
// Content-Length is only needed for DELETE requests that include a request
// body, but including it for all requests doesn't seem to hurt anything.
aws_request.headers['Content-Length'] = Buffer.byteLength(aws_request.body);

const credentials = new AWS.EnvironmentCredentials('AWS');
const signer = new AWS.Signers.V4(aws_request, 'es');
signer.addAuthorization(credentials, new Date());

const client = new AWS.HttpClient();
response = await new Promise((resolve, reject) => {
fork icon1
star icon0
watch icon0

845
846
847
848
849
850
851
852
853
854
req.headers['Content-Type'] = 'application/json';
req.body = JSON.stringify(initiateChatRequest);
req.headers.Host = endpoint.host;
req.headers['Content-Length'] = Buffer.byteLength(req.body);

const signer = new AWS.Signers.V4(req, 'execute-api');
signer.addAuthorization(awsCredentials, new Date());

const reqInit = {
  method: 'POST',
fork icon0
star icon0
watch icon1

+ 33 other calls in file

46
47
48
49
50
51
52
53
54
55
56
57
    return request;
};


const prepareCredentials = async (request) => {
    AWS.config.credentials = new AWS.SharedIniFileCredentials({ profile: 'default' });
    const signer = new AWS.Signers.V4(request, 'es');
    signer.addAuthorization(AWS.config.credentials, new Date());
}


async function esQuery(method, path, body = null) {
fork icon0
star icon0
watch icon0

54
55
56
57
58
59
60
61
62
63
let chain = new AWS.CredentialProviderChain();
chain.resolve((err, credentials) => {
  if (err) {
    console.error("Returning unsigned request: ", err);
  } else {
    var signer = new AWS.Signers.V4(request, "es");
    signer.addAuthorization(credentials, new Date());
  }
  resolve(request);
});
fork icon0
star icon0
watch icon0

+ 2 other calls in file

15
16
17
18
19
20
21
22
23
24
25
26
  accessKeySecret: accessKeySecret,
})


const signRequest = (request) => {
  const credentials = new AWS.EnvironmentCredentials('AWS')
  const signer = new AWS.Signers.V4(request, 'es')
  signer.addAuthorization(credentials, new Date())
}


const createRequest = () => {
fork icon0
star icon0
watch icon0

19
20
21
22
23
24
25
26
27
28
29
30
request.headers['host'] = domain;
request.headers['Content-Type'] = contentType;
request.headers['Content-Length'] = Buffer.byteLength(request.body).toString();


let credentials = new AWS.EnvironmentCredentials('AWS');
let signer = new AWS.Signers.V4(request, service);
signer.addAuthorization(credentials, new Date());


let client = new AWS.HttpClient();

fork icon0
star icon0
watch icon0

50
51
52
53
54
55
56
57
58
req.headers['host'] = endpointVehicle.host;
req.headers['content-type'] = "application/json";
if (body !== undefined) {
    req.body = body;
}
var signer = new AWS.Signers.V4(req, 'es');  // es: service code
signer.addAuthorization(credentials, new Date());

log("ES request: " + JSON.stringify(req));
fork icon0
star icon0
watch icon0