├── CODEOWNERS ├── features ├── extra │ ├── dummy.feature │ ├── fixtures │ │ └── testfile.txt │ ├── world.js │ └── assertions.js └── s3 │ └── step_definitions │ ├── hooks.js │ └── proxy.js ├── doc-src ├── yard-js │ ├── .gitignore │ ├── lib │ │ ├── yard-js │ │ │ ├── version.rb │ │ │ ├── code_objects.rb │ │ │ ├── code_objects │ │ │ │ ├── event_object.rb │ │ │ │ └── property_object.rb │ │ │ ├── handlers.rb │ │ │ ├── core_ext │ │ │ │ ├── parsejs.rb │ │ │ │ ├── yard.rb │ │ │ │ └── yard │ │ │ │ │ ├── yardoc.rb │ │ │ │ │ ├── registry.rb │ │ │ │ │ ├── code_objects.rb │ │ │ │ │ └── tags.rb │ │ │ ├── parser.rb │ │ │ ├── handlers │ │ │ │ ├── mixin_handler.rb │ │ │ │ ├── instance_method_handler.rb │ │ │ │ ├── comment_handler.rb │ │ │ │ ├── module_handler.rb │ │ │ │ ├── class_handler.rb │ │ │ │ ├── constant_handler.rb │ │ │ │ └── base.rb │ │ │ ├── tags.rb │ │ │ └── plugin.rb │ │ └── yard-js.rb │ ├── Gemfile │ ├── templates │ │ └── default │ │ │ ├── module │ │ │ ├── html │ │ │ │ ├── constructor_summary.erb │ │ │ │ ├── events_details.erb │ │ │ │ ├── methods_details.erb │ │ │ │ ├── properties_details.erb │ │ │ │ ├── method_summary.erb │ │ │ │ ├── properties_summary.erb │ │ │ │ ├── inherited_methods.erb │ │ │ │ ├── inherited_properties.erb │ │ │ │ ├── events_summary.erb │ │ │ │ └── item_summary.erb │ │ │ └── setup.rb │ │ │ ├── tags │ │ │ ├── value.erb │ │ │ ├── setup.rb │ │ │ └── callback.erb │ │ │ ├── class │ │ │ └── setup.rb │ │ │ ├── method_details │ │ │ └── setup.rb │ │ │ ├── fulldoc │ │ │ └── html │ │ │ │ ├── css │ │ │ │ ├── style.css │ │ │ │ └── highlight.github.css │ │ │ │ ├── full_list_property.erb │ │ │ │ └── setup.rb │ │ │ └── layout │ │ │ └── html │ │ │ ├── setup.rb │ │ │ └── headers.erb │ ├── yard-js.gemspec │ ├── samus.json │ └── LICENSE.txt ├── parsejs │ ├── Gemfile │ ├── lib │ │ ├── parsejs │ │ │ ├── version.rb │ │ │ └── ast.rb │ │ └── parsejs.rb │ ├── Rakefile │ └── test.rb └── templates │ ├── api-versions │ └── templates │ │ └── default │ │ ├── tags │ │ └── setup.rb │ │ ├── waiter_details │ │ └── html │ │ │ ├── setup.rb │ │ │ └── method_signature.erb │ │ ├── docstring │ │ ├── setup.rb │ │ └── html │ │ │ └── experimental.erb │ │ ├── class │ │ └── html │ │ │ ├── setup.rb │ │ │ ├── waiter_details_list.erb │ │ │ └── waiter_summary.erb │ │ ├── module │ │ └── html │ │ │ ├── children.erb │ │ │ └── box_info.erb │ │ ├── layout │ │ └── html │ │ │ ├── services.erb │ │ │ └── setup.rb │ │ └── fulldoc │ │ └── html │ │ ├── css │ │ └── common.css │ │ └── setup.rb │ └── default │ ├── layout │ └── html │ │ ├── setup.rb │ │ ├── footer.erb │ │ ├── v3note.erb │ │ ├── nodeVersionNotice.erb │ │ ├── headers.erb │ │ └── layout.erb │ └── fulldoc │ └── html │ ├── js │ └── custom.js │ └── css │ └── custom.css ├── .tesselinclude ├── clients ├── all.d.ts ├── browser_default.d.ts ├── all.js ├── browser_default.js └── s3.js ├── test ├── mocha.opts ├── .eslintrc ├── browser │ ├── sample │ │ ├── img │ │ │ └── loading.gif │ │ ├── css │ │ │ └── smoothness │ │ │ │ └── images │ │ │ │ ├── animated-overlay.gif │ │ │ │ ├── ui-icons_222222_256x240.png │ │ │ │ ├── ui-icons_2e83ff_256x240.png │ │ │ │ ├── ui-icons_454545_256x240.png │ │ │ │ ├── ui-icons_888888_256x240.png │ │ │ │ ├── ui-icons_cd0a0a_256x240.png │ │ │ │ ├── ui-bg_flat_0_aaaaaa_40x100.png │ │ │ │ ├── ui-bg_flat_75_ffffff_40x100.png │ │ │ │ ├── ui-bg_glass_55_fbf9ee_1x400.png │ │ │ │ ├── ui-bg_glass_65_ffffff_1x400.png │ │ │ │ ├── ui-bg_glass_75_dadada_1x400.png │ │ │ │ ├── ui-bg_glass_75_e6e6e6_1x400.png │ │ │ │ ├── ui-bg_glass_95_fef1ec_1x400.png │ │ │ │ └── ui-bg_highlight-soft_75_cccccc_1x100.png │ │ └── appinfo.sample.js │ ├── runner.html │ ├── jasmine-2.0.0 │ │ └── MIT.LICENSE │ └── runner.js ├── endpoint │ ├── test_cases_supported.json │ ├── fips │ │ └── fips.spec.js │ └── index.spec.js ├── xml │ ├── xml-text.spec.js │ ├── escape-attribute.spec.js │ └── escape-element.spec.js ├── mocks │ └── shaky-stream.js ├── s3 │ └── s3_param.spec.js ├── services │ └── s3util.spec.js ├── metadata_service │ ├── endpoint_config_options.spec.js │ ├── endpoint_mode_config_options.spec.js │ └── get_metadata_service_endpoint.spec.js ├── signers │ └── presign.spec.js ├── idempotent.spec.js └── region │ └── utils.spec.js ├── .eslintignore ├── global.js ├── .whitesource ├── lib ├── shared-ini │ ├── index.d.ts │ ├── index.js │ └── ini-loader.d.ts ├── metadata_service │ ├── get_endpoint_mode.js │ ├── get_endpoint.js │ └── get_metadata_service_endpoint.js ├── aws.js ├── model │ ├── index.d.ts │ ├── paginator.js │ ├── collection.js │ └── resource_waiter.js ├── token │ ├── static_token_provider.d.ts │ ├── static_token_provider.js │ └── token_provider_chain.d.ts ├── credentials │ ├── anonymous_credentials.d.ts │ ├── environment_credentials.d.ts │ ├── shared_json_file_credentials.d.ts │ ├── file_system_credentials.d.ts │ ├── shared_ini_file_credentials.d.ts │ ├── anonymous_credentials.js │ ├── credential_provider_chain.d.ts │ └── file_system_credentials.js ├── config_service_placeholders.d.ts ├── signers │ ├── none.js │ ├── bearer.js │ ├── v3https.js │ ├── iam.js │ ├── request_signer.js │ ├── v2.js │ ├── v3.js │ └── v4_credentials.js ├── xml │ ├── escape-attribute.js │ ├── xml-text.js │ ├── escape-element.js │ └── xml-node.js ├── browser.js ├── api_loader.js ├── config_use_dualstack.d.ts ├── endpoint.d.ts ├── browser_loader.js ├── services │ ├── s3util.js │ └── s3.d.ts ├── region │ └── utils.js ├── http_request.d.ts ├── http_response.d.ts ├── browserCryptoLib.js ├── core.d.ts ├── response.d.ts ├── state_machine.js ├── error.d.ts ├── browserHashUtils.js ├── event_listeners.d.ts ├── browserHmac.js ├── json │ ├── builder.js │ └── parser.js ├── metadata_service.d.ts ├── s3 │ └── presigned_post.d.ts ├── config.d.ts ├── query │ └── query_param_serializer.js └── core.js ├── index.js ├── apis ├── metadata.json ├── s3-2006-03-01.waiters2.json └── s3-2006-03-01.paginators.json ├── configuration.sample ├── global.d.ts ├── .metadata ├── index.d.ts ├── .gitignore ├── ts ├── endpoint.ts ├── tsconfig.json ├── core.ts ├── request.ts └── config.ts ├── scripts ├── changelog │ ├── create-changelog │ ├── release │ └── test │ │ └── change-creator.js ├── lib │ ├── ts-customizations.json │ ├── get-operation-shape-names.js │ ├── prune-shapes.js │ ├── visit-related-shape-names.js │ ├── set-s3-expires-string.js │ └── prune-shapes.spec.js ├── typings-generator.js └── translate-api ├── Rakefile ├── dist-tools ├── test │ └── helpers.coffee ├── create-all-services.js ├── transform.js └── browser-builder.js ├── tasks ├── docs.rake ├── util.rake └── lib │ └── cucumber_generator.rb ├── .npmignore ├── .yardopts ├── .eslintrc ├── Gemfile.lock ├── .yardopts_guide ├── Gemfile ├── config.js.sample └── .pre-commit-config.yaml /CODEOWNERS: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /features/extra/dummy.feature: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /doc-src/yard-js/.gitignore: -------------------------------------------------------------------------------- 1 | Gemfile.lock 2 | -------------------------------------------------------------------------------- /.tesselinclude: -------------------------------------------------------------------------------- 1 | apis/*.json 2 | lib/services/*.js 3 | -------------------------------------------------------------------------------- /clients/all.d.ts: -------------------------------------------------------------------------------- 1 | export import S3 = require('./s3'); 2 | -------------------------------------------------------------------------------- /features/extra/fixtures/testfile.txt: -------------------------------------------------------------------------------- 1 | CONTENTS OF FILE 2 | -------------------------------------------------------------------------------- /clients/browser_default.d.ts: -------------------------------------------------------------------------------- 1 | export import S3 = require('./s3'); 2 | -------------------------------------------------------------------------------- /test/mocha.opts: -------------------------------------------------------------------------------- 1 | --reporter dot 2 | --ui bdd 3 | --timeout 4000 4 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | dist/* 2 | test/browser/**/* 3 | test/configuration.js 4 | -------------------------------------------------------------------------------- /global.js: -------------------------------------------------------------------------------- 1 | require('./lib/node_loader'); 2 | module.exports = require('./lib/core'); -------------------------------------------------------------------------------- /doc-src/yard-js/lib/yard-js/version.rb: -------------------------------------------------------------------------------- 1 | module YARDJS 2 | VERSION = '0.1.3' 3 | end 4 | -------------------------------------------------------------------------------- /doc-src/parsejs/Gemfile: -------------------------------------------------------------------------------- 1 | source 'http://rubygems.org' 2 | 3 | gemspec 4 | 5 | gem "pry" 6 | -------------------------------------------------------------------------------- /doc-src/parsejs/lib/parsejs/version.rb: -------------------------------------------------------------------------------- 1 | module ParseJS 2 | VERSION = "0.0.1" 3 | end 4 | -------------------------------------------------------------------------------- /.whitesource: -------------------------------------------------------------------------------- 1 | { 2 | "settingsInheritedFrom": "whitesource-config/whitesource-config@master" 3 | } -------------------------------------------------------------------------------- /lib/shared-ini/index.d.ts: -------------------------------------------------------------------------------- 1 | import {IniLoader} from './ini-loader'; 2 | 3 | export const iniLoader: IniLoader; -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | // Convenience file to require the SDK from the root of the repository 2 | module.exports = require('./lib/aws'); 3 | -------------------------------------------------------------------------------- /test/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../.eslintrc", 3 | "parserOptions": { 4 | "ecmaVersion": 9 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/browser/sample/img/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/ibm-cos-sdk-js/HEAD/test/browser/sample/img/loading.gif -------------------------------------------------------------------------------- /apis/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "s3": { 3 | "name": "S3", 4 | "dualstackAvailable": true, 5 | "cors": true 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /configuration.sample: -------------------------------------------------------------------------------- 1 | { 2 | "region": "us-east-1", 3 | "s3": { 4 | "params": { "Bucket": "test-s3-bucket" } 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /clients/all.js: -------------------------------------------------------------------------------- 1 | require('../lib/node_loader'); 2 | var AWS = require('../lib/core'); 3 | 4 | module.exports = { 5 | S3: require('./s3') 6 | }; -------------------------------------------------------------------------------- /global.d.ts: -------------------------------------------------------------------------------- 1 | import {GlobalConfigInstance} from './lib/config'; 2 | 3 | export * from './lib/core'; 4 | export var config: GlobalConfigInstance -------------------------------------------------------------------------------- /doc-src/yard-js/Gemfile: -------------------------------------------------------------------------------- 1 | source :rubygems 2 | 3 | gem 'redcarpet' 4 | gem 'yard' 5 | gem 'parsejs', :git => 'git://github.com/wycats/parsejs.git' 6 | -------------------------------------------------------------------------------- /clients/browser_default.js: -------------------------------------------------------------------------------- 1 | require('../lib/node_loader'); 2 | var AWS = require('../lib/core'); 3 | 4 | module.exports = { 5 | S3: require('./s3') 6 | }; -------------------------------------------------------------------------------- /doc-src/templates/api-versions/templates/default/tags/setup.rb: -------------------------------------------------------------------------------- 1 | def param 2 | tag(:param) if [:property, :event, :waiter].include?(object.type) 3 | end 4 | -------------------------------------------------------------------------------- /doc-src/templates/default/layout/html/setup.rb: -------------------------------------------------------------------------------- 1 | def stylesheets 2 | super + %w(css/custom.css) 3 | end 4 | 5 | def javascripts 6 | super + %w(js/custom.js) 7 | end -------------------------------------------------------------------------------- /test/browser/sample/css/smoothness/images/animated-overlay.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/ibm-cos-sdk-js/HEAD/test/browser/sample/css/smoothness/images/animated-overlay.gif -------------------------------------------------------------------------------- /test/browser/sample/css/smoothness/images/ui-icons_222222_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/ibm-cos-sdk-js/HEAD/test/browser/sample/css/smoothness/images/ui-icons_222222_256x240.png -------------------------------------------------------------------------------- /test/browser/sample/css/smoothness/images/ui-icons_2e83ff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/ibm-cos-sdk-js/HEAD/test/browser/sample/css/smoothness/images/ui-icons_2e83ff_256x240.png -------------------------------------------------------------------------------- /test/browser/sample/css/smoothness/images/ui-icons_454545_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/ibm-cos-sdk-js/HEAD/test/browser/sample/css/smoothness/images/ui-icons_454545_256x240.png -------------------------------------------------------------------------------- /test/browser/sample/css/smoothness/images/ui-icons_888888_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/ibm-cos-sdk-js/HEAD/test/browser/sample/css/smoothness/images/ui-icons_888888_256x240.png -------------------------------------------------------------------------------- /test/browser/sample/css/smoothness/images/ui-icons_cd0a0a_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/ibm-cos-sdk-js/HEAD/test/browser/sample/css/smoothness/images/ui-icons_cd0a0a_256x240.png -------------------------------------------------------------------------------- /lib/metadata_service/get_endpoint_mode.js: -------------------------------------------------------------------------------- 1 | var getEndpointMode = function() { 2 | return { 3 | IPv4: 'IPv4', 4 | IPv6: 'IPv6', 5 | }; 6 | }; 7 | 8 | module.exports = getEndpointMode; 9 | -------------------------------------------------------------------------------- /test/browser/sample/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/ibm-cos-sdk-js/HEAD/test/browser/sample/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png -------------------------------------------------------------------------------- /test/browser/sample/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/ibm-cos-sdk-js/HEAD/test/browser/sample/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png -------------------------------------------------------------------------------- /test/browser/sample/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/ibm-cos-sdk-js/HEAD/test/browser/sample/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png -------------------------------------------------------------------------------- /test/browser/sample/css/smoothness/images/ui-bg_glass_65_ffffff_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/ibm-cos-sdk-js/HEAD/test/browser/sample/css/smoothness/images/ui-bg_glass_65_ffffff_1x400.png -------------------------------------------------------------------------------- /test/browser/sample/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/ibm-cos-sdk-js/HEAD/test/browser/sample/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png -------------------------------------------------------------------------------- /test/browser/sample/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/ibm-cos-sdk-js/HEAD/test/browser/sample/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png -------------------------------------------------------------------------------- /test/browser/sample/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/ibm-cos-sdk-js/HEAD/test/browser/sample/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | { 2 | "service": "cloud-object-storage", 3 | "production_code": "yes", 4 | "production_branches": [ 5 | "master" 6 | ], 7 | "security_sensitive": "no", 8 | "ip_sensitive": "no" 9 | } -------------------------------------------------------------------------------- /doc-src/templates/api-versions/templates/default/waiter_details/html/setup.rb: -------------------------------------------------------------------------------- 1 | include T('default/method_details/html') 2 | 3 | def init 4 | sections :header, [:method_signature, T('docstring')] 5 | end 6 | -------------------------------------------------------------------------------- /index.d.ts: -------------------------------------------------------------------------------- 1 | import {GlobalConfigInstance} from './lib/config'; 2 | 3 | export * from './lib/core'; 4 | export * from './clients/all'; 5 | export var config: GlobalConfigInstance 6 | 7 | export as namespace AWS; -------------------------------------------------------------------------------- /test/browser/sample/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/ibm-cos-sdk-js/HEAD/test/browser/sample/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png -------------------------------------------------------------------------------- /lib/metadata_service/get_endpoint.js: -------------------------------------------------------------------------------- 1 | var getEndpoint = function() { 2 | return { 3 | IPv4: 'http://169.254.169.254', 4 | IPv6: 'http://[fd00:ec2::254]', 5 | }; 6 | }; 7 | 8 | module.exports = getEndpoint; 9 | -------------------------------------------------------------------------------- /lib/aws.js: -------------------------------------------------------------------------------- 1 | require('./node_loader'); 2 | 3 | var AWS = require('./core'); 4 | 5 | // Load all service classes 6 | require('../clients/all'); 7 | 8 | /** 9 | * @api private 10 | */ 11 | module.exports = AWS; 12 | -------------------------------------------------------------------------------- /features/s3/step_definitions/hooks.js: -------------------------------------------------------------------------------- 1 | module.exports = function () { 2 | 3 | this.Before('@s3', function (callback) { 4 | this.service = this.s3 = new this.AWS.S3({maxRetries: 100}); 5 | callback(); 6 | }); 7 | 8 | }; 9 | -------------------------------------------------------------------------------- /lib/model/index.d.ts: -------------------------------------------------------------------------------- 1 | export type DocumentType = Scalar | Structure | List; 2 | type Scalar = string | number | boolean | null; 3 | type Structure = { [member: string]: DocumentType }; 4 | interface List extends Array {} 5 | -------------------------------------------------------------------------------- /doc-src/yard-js/lib/yard-js/code_objects.rb: -------------------------------------------------------------------------------- 1 | module YARDJS 2 | module CodeObjects 3 | include YARD::CodeObjects 4 | end 5 | end 6 | 7 | require_relative 'code_objects/event_object' 8 | require_relative 'code_objects/property_object' 9 | -------------------------------------------------------------------------------- /lib/shared-ini/index.js: -------------------------------------------------------------------------------- 1 | var IniLoader = require('./ini-loader').IniLoader; 2 | /** 3 | * Singleton object to load specified config/credentials files. 4 | * It will cache all the files ever loaded; 5 | */ 6 | module.exports.iniLoader = new IniLoader(); 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | configuration 3 | node_modules 4 | npm-debug.log 5 | coverage 6 | .yardoc 7 | doc 8 | test/browser/build 9 | test/browser/sample/appinfo.js 10 | dist/aws-sdk-all.js 11 | yarn.lock 12 | package-lock.json 13 | .idea/ 14 | .project 15 | -------------------------------------------------------------------------------- /lib/token/static_token_provider.d.ts: -------------------------------------------------------------------------------- 1 | import {Token, TokenOptions} from '../token'; 2 | 3 | export class StaticTokenProvider extends Token { 4 | /** 5 | * Creates a new StaticTokenProvider object. 6 | */ 7 | constructor(options?: TokenOptions); 8 | } -------------------------------------------------------------------------------- /test/endpoint/test_cases_supported.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "endpointPrefix": "s3", 4 | "clientName": "S3", 5 | "region": "af-south-1", 6 | "useDualstackEndpoint": true, 7 | "hostname": "s3.dualstack.af-south-1.amazonaws.com" 8 | } 9 | ] 10 | -------------------------------------------------------------------------------- /lib/credentials/anonymous_credentials.d.ts: -------------------------------------------------------------------------------- 1 | import {Credentials} from '../credentials'; 2 | export class AnonymousCredentials extends Credentials { 3 | /** 4 | * Creates a new AnonymousCredentials class for unauthenticated requests. 5 | */ 6 | constructor(); 7 | } -------------------------------------------------------------------------------- /lib/config_service_placeholders.d.ts: -------------------------------------------------------------------------------- 1 | import * as AWS from '../clients/all'; 2 | export abstract class ConfigurationServicePlaceholders { 3 | s3?: AWS.S3.Types.ClientConfiguration; 4 | } 5 | export interface ConfigurationServiceApiVersions { 6 | s3?: AWS.S3.Types.apiVersion; 7 | } 8 | -------------------------------------------------------------------------------- /ts/endpoint.ts: -------------------------------------------------------------------------------- 1 | import AWS = require('../index'); 2 | 3 | // create endpoint 4 | var endpoint = new AWS.Endpoint('awsproxy.example.com'); 5 | endpoint.host = 'host'; 6 | endpoint.hostname = 'hostname'; 7 | endpoint.href = 'url'; 8 | endpoint.port = 8080; 9 | endpoint.protocol = 'https'; -------------------------------------------------------------------------------- /scripts/changelog/create-changelog: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var util = require('./util'); 4 | 5 | var versions = util.listVersions(); 6 | 7 | util.startNewChangelog(); 8 | 9 | versions.forEach(util.readVersionJSONAndAddToChangelog); 10 | 11 | util.writeToChangelog(); 12 | -------------------------------------------------------------------------------- /lib/signers/none.js: -------------------------------------------------------------------------------- 1 | var AWS = require('../core'); 2 | 3 | /** 4 | * @api private 5 | */ 6 | AWS.Signers.None = AWS.util.inherit(AWS.Signers.RequestSigner, { 7 | addAuthorization: function() {}, 8 | signature: function() {} 9 | }); 10 | 11 | module.exports = AWS.Signers.IAM; 12 | -------------------------------------------------------------------------------- /doc-src/templates/api-versions/templates/default/docstring/setup.rb: -------------------------------------------------------------------------------- 1 | def init 2 | super 3 | sections.place(:experimental).before_any(:private) 4 | end 5 | 6 | def experimental 7 | return unless object.has_tag?(:api) && object.tag(:api).text == 'experimental' 8 | erb(:experimental) 9 | end 10 | -------------------------------------------------------------------------------- /doc-src/templates/api-versions/templates/default/docstring/html/experimental.erb: -------------------------------------------------------------------------------- 1 |

2 | This <%= object.property_type %> is part of an experimental API. 3 | You can use this <%= object.property_type %>, but it may be removed or be changed in the future. 4 |

5 | -------------------------------------------------------------------------------- /doc-src/yard-js/templates/default/module/html/constructor_summary.erb: -------------------------------------------------------------------------------- 1 |

Constructor Summary 2 | collapse 3 |

4 | 5 | 10 | -------------------------------------------------------------------------------- /doc-src/yard-js/templates/default/tags/value.erb: -------------------------------------------------------------------------------- 1 |

<%= @label ? @label : YARD::Tags::Library.labels[@name] %>:

2 |
3 | <% object.tags(@name).each do |tag| %> 4 |
<%= object.path %> = <%= h(tag.text) %>
5 | <% end %> 6 |
-------------------------------------------------------------------------------- /doc-src/templates/api-versions/templates/default/waiter_details/html/method_signature.erb: -------------------------------------------------------------------------------- 1 |

2 | <%= owner.tag(:service).text %>.waitFor('<%= object.name %>', params = {}, [callback]) ⇒ <%= linkify P('AWS.Request') %> 3 |

-------------------------------------------------------------------------------- /doc-src/yard-js/lib/yard-js/code_objects/event_object.rb: -------------------------------------------------------------------------------- 1 | module YARDJS 2 | module CodeObjects 3 | class EventObject < Base 4 | def constructor?; false end 5 | def property_type; :event end 6 | def aliases; [] end 7 | def sep; '~' end 8 | attr_accessor :parameters 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /doc-src/templates/api-versions/templates/default/class/html/setup.rb: -------------------------------------------------------------------------------- 1 | def init 2 | super 3 | @waiters = object.children.select {|x| x.type == :waiter } 4 | if @waiters.size > 0 5 | sections.place(:waiter_summary).before_any(:constant_summary) 6 | sections.push(:waiter_details_list, [T('waiter_details')]) 7 | end 8 | end 9 | 10 | -------------------------------------------------------------------------------- /doc-src/templates/api-versions/templates/default/class/html/waiter_details_list.erb: -------------------------------------------------------------------------------- 1 |
2 |

Waiter Resource Details

3 | 4 | <% @waiters.each_with_index do |waiter, i| %> 5 | <%= yieldall :object => waiter, :owner => object, :index => i %> 6 | <% end %> 7 |
8 | -------------------------------------------------------------------------------- /test/xml/xml-text.spec.js: -------------------------------------------------------------------------------- 1 | var XmlText = require('../../lib/xml/xml-text').XmlText; 2 | 3 | describe('XmlText', function() { 4 | it('escapes element text', function() { 5 | var text = new XmlText('this & that are < or > "most"'); 6 | expect(text.toString()).to.equal('this & that are < or > "most"'); 7 | }); 8 | }); 9 | -------------------------------------------------------------------------------- /doc-src/parsejs/Rakefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rake 2 | require "bundler/gem_tasks" 3 | require "bundler/setup" 4 | 5 | file "lib/parsejs/grammar.kpeg.rb" => "lib/parsejs/grammar.kpeg" do 6 | sh "kpeg -f lib/parsejs/grammar.kpeg --stand-alone --debug" 7 | end 8 | 9 | task :compile => "lib/parsejs/grammar.kpeg.rb" 10 | 11 | task :default => :compile 12 | -------------------------------------------------------------------------------- /doc-src/yard-js/templates/default/module/html/events_details.erb: -------------------------------------------------------------------------------- 1 | <% if event_listing.size > 0 %> 2 |
3 |

Event Details

4 | <% event_listing.each_with_index do |prop, i| %> 5 | <%= yieldall :object => prop, :owner => object, :index => i %> 6 | <% end %> 7 |
8 | <% end %> 9 | -------------------------------------------------------------------------------- /doc-src/templates/default/layout/html/footer.erb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /doc-src/yard-js/lib/yard-js/handlers.rb: -------------------------------------------------------------------------------- 1 | require_relative 'handlers/base' 2 | require_relative 'handlers/class_handler' 3 | require_relative 'handlers/comment_handler' 4 | require_relative 'handlers/constant_handler' 5 | require_relative 'handlers/instance_method_handler' 6 | require_relative 'handlers/mixin_handler' 7 | require_relative 'handlers/module_handler' 8 | -------------------------------------------------------------------------------- /doc-src/yard-js/templates/default/module/html/methods_details.erb: -------------------------------------------------------------------------------- 1 | <% if method_listing.size > 0 %> 2 |
3 |

Method Details

4 | <% method_listing.each_with_index do |prop, i| %> 5 | <%= yieldall :object => prop, :owner => object, :index => i %> 6 | <% end %> 7 |
8 | <% end %> 9 | -------------------------------------------------------------------------------- /ts/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "noImplicitAny": true, 4 | "strictNullChecks": true, 5 | "allowJs": true, 6 | "target": "es5", 7 | "module": "commonjs", 8 | "lib": [ 9 | "es5", 10 | "es2015.promise" 11 | ], 12 | "noEmit": true 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /doc-src/yard-js/templates/default/module/html/properties_details.erb: -------------------------------------------------------------------------------- 1 | <% if property_listing.size > 0 %> 2 |
3 |

Property Details

4 | <% property_listing.each_with_index do |prop, i| %> 5 | <%= yieldall :object => prop, :owner => object, :index => i %> 6 | <% end %> 7 |
8 | <% end %> 9 | -------------------------------------------------------------------------------- /test/xml/escape-attribute.spec.js: -------------------------------------------------------------------------------- 1 | var escapeAttribute = require('../../lib/xml/escape-attribute').escapeAttribute; 2 | 3 | describe('escape-attribute', function() { 4 | it('escapes: & < > "\'', function() { 5 | var value = 'abc 123 &<>"%\''; 6 | expect(escapeAttribute(value)).to.equal('abc 123 &<>"%''); 7 | }); 8 | }); 9 | -------------------------------------------------------------------------------- /doc-src/templates/api-versions/templates/default/class/html/waiter_summary.erb: -------------------------------------------------------------------------------- 1 |

Waiter Resource States

2 |

This service supports a list of resource states that can be polled using 3 | the <%= resolve_links "{waitFor}" %> method. The resource states are:

4 | 5 |

6 | <%= @waiters.map {|waiter| linkify waiter }.join(", ") %> 7 |

8 | -------------------------------------------------------------------------------- /doc-src/yard-js/templates/default/module/html/method_summary.erb: -------------------------------------------------------------------------------- 1 | <% groups(method_listing, "Method") do |list, title| %> 2 |

<%= title %> 3 | collapse 4 |

5 | 6 | 11 | <% end %> 12 | -------------------------------------------------------------------------------- /doc-src/yard-js/templates/default/class/setup.rb: -------------------------------------------------------------------------------- 1 | def constructor_details 2 | object.inheritance_tree.find do |superclass| 3 | next if superclass.type == :proxy 4 | ctor = superclass.child(:name => :constructor) 5 | if ctor && !prune_method_listing([ctor]).empty? 6 | @ctor = ctor 7 | break 8 | end 9 | end 10 | erb(:constructor_details) if @ctor 11 | end 12 | -------------------------------------------------------------------------------- /doc-src/yard-js/templates/default/module/html/properties_summary.erb: -------------------------------------------------------------------------------- 1 | <% groups(property_listing, "Property") do |list, title| %> 2 |

<%= title %> 3 | collapse 4 |

5 | 6 | 11 | <% end %> 12 | -------------------------------------------------------------------------------- /test/xml/escape-element.spec.js: -------------------------------------------------------------------------------- 1 | var escapeElement = require('../../lib/xml/escape-element').escapeElement; 2 | 3 | describe('escape-element', function() { 4 | it('escapes: & < > \\r \\n \u0085\u2028', function() { 5 | var value = 'abc 123 &<>"%\r\n\u0085\u2028'; 6 | expect(escapeElement(value)).to.equal('abc 123 &<>"% …
'); 7 | }); 8 | }); 9 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | LOGLEVEL = ($DEBUG || ENV['DEBUG']) ? '' : '-s' 2 | 3 | task :default => 'test:all' 4 | 5 | # Vendor tasks 6 | root = File.dirname(__FILE__) 7 | Dir[File.join(root, 'vendor', '*', 'Rakefile')].each do |vendor_rakefile| 8 | load vendor_rakefile 9 | end 10 | 11 | # Local tasks 12 | Dir[File.join(root, 'tasks', '**', '*.rake')].each do |task_file| 13 | load task_file 14 | end 15 | -------------------------------------------------------------------------------- /doc-src/templates/api-versions/templates/default/module/html/children.erb: -------------------------------------------------------------------------------- 1 |

Defined Under Namespace

2 |

3 | <% @inner.each do |name, list| %> 4 | <% if list.size > 0 %> 5 | <%= name.to_s.capitalize %>: <%= list.map {|child| linkify(child, child.name.to_s.gsub(/_\d+/, '')) }.join(", ") %> 6 | <% end %> 7 | <% end %> 8 |

9 | -------------------------------------------------------------------------------- /lib/xml/escape-attribute.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Escapes characters that can not be in an XML attribute. 3 | */ 4 | function escapeAttribute(value) { 5 | return value.replace(/&/g, '&').replace(/'/g, ''').replace(//g, '>').replace(/"/g, '"'); 6 | } 7 | 8 | /** 9 | * @api private 10 | */ 11 | module.exports = { 12 | escapeAttribute: escapeAttribute 13 | }; 14 | -------------------------------------------------------------------------------- /doc-src/yard-js/lib/yard-js/core_ext/parsejs.rb: -------------------------------------------------------------------------------- 1 | $:.unshift(File.expand_path('~/parsejs/lib')) 2 | 3 | require 'parsejs' 4 | require 'parsejs/stringifier' 5 | 6 | class ParseJS::AST::Node 7 | def line; 0 end 8 | def show; ParseJS::Stringifier.to_string(self) end 9 | def comments_hash_flag; nil end 10 | def comments_range; nil end 11 | alias source show 12 | attr_accessor :comments 13 | end 14 | -------------------------------------------------------------------------------- /lib/credentials/environment_credentials.d.ts: -------------------------------------------------------------------------------- 1 | import {Credentials} from '../credentials'; 2 | export class EnvironmentCredentials extends Credentials { 3 | /** 4 | * Creates a new EnvironmentCredentials class with a given variable prefix envPrefix. 5 | * @param {string} envPrefix - The prefix for the environment variable names excluding the separating underscore. 6 | */ 7 | constructor(envPrefix: string); 8 | } -------------------------------------------------------------------------------- /doc-src/parsejs/lib/parsejs.rb: -------------------------------------------------------------------------------- 1 | require "parsejs/version" 2 | require "parsejs/grammar.kpeg" 3 | require "parsejs/stringifier" 4 | require "parsejs/ast" 5 | require "parsejs/scope" 6 | 7 | module ParseJS 8 | def self.parse(string) 9 | string = string.force_encoding('BINARY') if string.respond_to?(:force_encoding) 10 | parser = ParseJS::Parser.new(string) 11 | parser.parse 12 | parser.result 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /lib/signers/bearer.js: -------------------------------------------------------------------------------- 1 | var AWS = require('../core'); 2 | 3 | /** 4 | * @api private 5 | */ 6 | AWS.Signers.Bearer = AWS.util.inherit(AWS.Signers.RequestSigner, { 7 | constructor: function Bearer(request) { 8 | AWS.Signers.RequestSigner.call(this, request); 9 | }, 10 | 11 | addAuthorization: function addAuthorization(token) { 12 | this.request.headers['Authorization'] = 'Bearer ' + token.token; 13 | } 14 | }); 15 | -------------------------------------------------------------------------------- /dist-tools/test/helpers.coffee: -------------------------------------------------------------------------------- 1 | fs = require('fs') 2 | 3 | evalCode = (code, preamble) -> 4 | eval """ 5 | (function() { 6 | var window = global; 7 | #{preamble}; 8 | return #{code}; 9 | })(); 10 | """ 11 | 12 | module.exports = 13 | AWS: require('../../') 14 | build: require('../browser-builder') 15 | collector: require('../service-collector') 16 | chai: require('chai') 17 | evalCode: evalCode 18 | -------------------------------------------------------------------------------- /lib/xml/xml-text.js: -------------------------------------------------------------------------------- 1 | var escapeElement = require('./escape-element').escapeElement; 2 | 3 | /** 4 | * Represents an XML text value. 5 | * @api private 6 | */ 7 | function XmlText(value) { 8 | this.value = value; 9 | } 10 | 11 | XmlText.prototype.toString = function () { 12 | return escapeElement('' + this.value); 13 | }; 14 | 15 | /** 16 | * @api private 17 | */ 18 | module.exports = { 19 | XmlText: XmlText 20 | }; 21 | -------------------------------------------------------------------------------- /doc-src/yard-js/templates/default/method_details/setup.rb: -------------------------------------------------------------------------------- 1 | def source; end 2 | 3 | def method_signature 4 | if object.type == :event 5 | <<-eof 6 |

7 | '#{object.name}'function (#{object.parameters.map(&:first).join(", ")}) 8 |

9 | eof 10 | else 11 | erb(:method_signature) 12 | end 13 | end -------------------------------------------------------------------------------- /lib/credentials/shared_json_file_credentials.d.ts: -------------------------------------------------------------------------------- 1 | import {Credentials} from '../credentials'; 2 | export class SharedJSONFileCredentials extends Credentials { 3 | /** 4 | * Creates a new SharedJSONFileCredentials object. 5 | */ 6 | constructor(options?: SharedJSONFileCredentialsOptions); 7 | } 8 | 9 | interface SharedJSONFileCredentialsOptions { 10 | profile?: string 11 | filename?: string 12 | disableAssumeRole?: boolean 13 | } -------------------------------------------------------------------------------- /doc-src/templates/api-versions/templates/default/layout/html/services.erb: -------------------------------------------------------------------------------- 1 |

Services

2 | 3 | 10 |
-------------------------------------------------------------------------------- /doc-src/yard-js/templates/default/fulldoc/html/css/style.css: -------------------------------------------------------------------------------- 1 | {{{__super__}}} 2 | 3 | .tags .callback .callback_item { list-style: none; margin-bottom: 25px; } 4 | .tags .callback .callback_item .signature { 5 | padding: 6px 12px; 6 | margin-bottom: 7px; 7 | background: #fcfcfc; border: 1px solid #eee; border-radius: 3px; 8 | margin-left: -15px; font-family: monospace; display: block; font-size: 1em; 9 | } 10 | .summary .note.title.event { font-size: 1.1em; font-family: monospace; } -------------------------------------------------------------------------------- /lib/credentials/file_system_credentials.d.ts: -------------------------------------------------------------------------------- 1 | import {Credentials} from '../credentials'; 2 | export class FileSystemCredentials extends Credentials { 3 | /** 4 | * Creates a new FileSystemCredentials object from a filename. 5 | * @param {string} filename - The path on disk to the JSON file to load. 6 | */ 7 | constructor(filename: string); 8 | /** 9 | * The path to the JSON file on disk containing the credentials. 10 | */ 11 | filename: string 12 | } -------------------------------------------------------------------------------- /scripts/lib/ts-customizations.json: -------------------------------------------------------------------------------- 1 | { 2 | "s3": [ 3 | { 4 | "path": "lib/s3/managed_upload", 5 | "imports": [ 6 | { 7 | "name": "ManagedUpload", 8 | "alias": "managed_upload" 9 | } 10 | ] 11 | }, 12 | { 13 | "path": "lib/s3/presigned_post", 14 | "imports": [ 15 | { 16 | "name": "PresignedPost", 17 | "alias": "presigned_post" 18 | } 19 | ] 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /doc-src/yard-js/templates/default/fulldoc/html/full_list_property.erb: -------------------------------------------------------------------------------- 1 | <% n = 1 %> 2 | <% @items.each do |item| %> 3 |
  • 4 | <%= linkify item, h(item.name(true)) %> 5 | <% if item.namespace && !item.namespace.root? %> 6 | <%= item.namespace %> 7 | <% else %> 8 | Top Level Namespace 9 | <% end %> 10 |
  • 11 | <% n = n == 2 ? 1 : 2 %> 12 | <% end %> 13 | -------------------------------------------------------------------------------- /doc-src/yard-js/templates/default/module/html/inherited_methods.erb: -------------------------------------------------------------------------------- 1 | <% found_prop = false %> 2 | <% inherited_method_list do |superclass, props| %> 3 | <% if method_listing.size == 0 && !found_prop %>

    Method Summary

    <% end %> 4 | <% found_prop = true %> 5 |

    Methods <%= superclass.type == :class ? 'inherited' : 'included' %> 6 | from <%= linkify superclass %>

    7 |

    <%= props.map {|c| linkify c, c.name }.join(", ") %>

    8 | <% end %> 9 | -------------------------------------------------------------------------------- /lib/model/paginator.js: -------------------------------------------------------------------------------- 1 | var property = require('../util').property; 2 | 3 | function Paginator(name, paginator) { 4 | property(this, 'inputToken', paginator.input_token); 5 | property(this, 'limitKey', paginator.limit_key); 6 | property(this, 'moreResults', paginator.more_results); 7 | property(this, 'outputToken', paginator.output_token); 8 | property(this, 'resultKey', paginator.result_key); 9 | } 10 | 11 | /** 12 | * @api private 13 | */ 14 | module.exports = Paginator; 15 | -------------------------------------------------------------------------------- /doc-src/yard-js/templates/default/module/html/inherited_properties.erb: -------------------------------------------------------------------------------- 1 | <% found_prop = false %> 2 | <% inherited_property_list do |superclass, props| %> 3 | <% if property_listing.size == 0 && !found_prop %>

    Property Summary

    <% end %> 4 | <% found_prop = true %> 5 |

    Properties <%= superclass.type == :class ? 'inherited' : 'included' %> 6 | from <%= linkify superclass %>

    7 |

    <%= props.map {|c| linkify c, c.name }.join(", ") %>

    8 | <% end %> 9 | -------------------------------------------------------------------------------- /doc-src/templates/api-versions/templates/default/fulldoc/html/css/common.css: -------------------------------------------------------------------------------- 1 | #full_list li.expander { color: #038; } 2 | .service_list { list-style: none; padding: 0; margin: 0; font-size: 1.1em; clear: both; } 3 | .service_list li { border-bottom: 1px solid #ccc; padding-bottom: 5px; margin-bottom: 7px; width: 40%; float: left; margin-right: 7px; } 4 | #listing .service_list li small { font-size: 0.9em; } 5 | .clear { clear: both; } 6 | #capabilities-banner { margin-bottom: 12px; font-weight: bold; padding: 12px; } 7 | -------------------------------------------------------------------------------- /lib/browser.js: -------------------------------------------------------------------------------- 1 | require('./browser_loader'); 2 | 3 | var AWS = require('./core'); 4 | 5 | if (typeof window !== 'undefined') window.AWS = AWS; 6 | if (typeof module !== 'undefined') { 7 | /** 8 | * @api private 9 | */ 10 | module.exports = AWS; 11 | } 12 | if (typeof self !== 'undefined') self.AWS = AWS; 13 | 14 | /** 15 | * @private 16 | * DO NOT REMOVE 17 | * browser builder will strip out this line if services are supplied on the command line. 18 | */ 19 | require('../clients/browser_default'); 20 | -------------------------------------------------------------------------------- /lib/api_loader.js: -------------------------------------------------------------------------------- 1 | function apiLoader(svc, version) { 2 | if (!apiLoader.services.hasOwnProperty(svc)) { 3 | throw new Error('InvalidService: Failed to load api for ' + svc); 4 | } 5 | return apiLoader.services[svc][version]; 6 | } 7 | 8 | /** 9 | * @api private 10 | * 11 | * This member of AWS.apiLoader is private, but changing it will necessitate a 12 | * change to ../scripts/services-table-generator.ts 13 | */ 14 | apiLoader.services = {}; 15 | 16 | /** 17 | * @api private 18 | */ 19 | module.exports = apiLoader; 20 | -------------------------------------------------------------------------------- /doc-src/yard-js/lib/yard-js/parser.rb: -------------------------------------------------------------------------------- 1 | require_relative 'core_ext/yard' 2 | 3 | module YARDJS 4 | module Parser 5 | class JavaScriptParser < YARD::Parser::Base 6 | attr_accessor :file, :source, :ast 7 | 8 | def initialize(source, filename) 9 | self.source = source 10 | self.file = filename 11 | end 12 | 13 | def parse 14 | self.ast = ParseJS.parse(source) 15 | self 16 | end 17 | 18 | def enumerator 19 | ast.elements 20 | end 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /doc-src/yard-js/templates/default/layout/html/setup.rb: -------------------------------------------------------------------------------- 1 | def stylesheets 2 | super + %w(css/highlight.github.css) 3 | end 4 | 5 | def javascripts 6 | super + %w(js/highlight.pack.js) 7 | end 8 | 9 | def menu_lists 10 | [ { :type => 'class', :title => 'Classes', :search_title => 'Class List' }, 11 | { :type => 'method', :title => 'Methods', :search_title => 'Method List' }, 12 | { :type => 'property', :title => 'Properties', :search_title => 'Property List' }, 13 | { :type => 'file', :title => 'Files', :search_title => 'File List' } ] 14 | end 15 | -------------------------------------------------------------------------------- /tasks/docs.rake: -------------------------------------------------------------------------------- 1 | namespace :docs do 2 | task :directory do 3 | mkdir_p "doc" 4 | end 5 | 6 | desc "Build API documentation" 7 | task :api => [:directory] do 8 | ENV['SITEMAP_BASEURL'] = 'https://ibm-public-cos.github.io/crs-docs/node/' 9 | 10 | rm_rf "doc/latest" 11 | args = ENV['ARGS'] ? ENV['ARGS'] : [] 12 | sh "bundle exec yard #{args.join(' ')}" 13 | end 14 | end 15 | 16 | # TODO: move code for docs:api under docs once it's updated in internal release code 17 | desc "Builds API documentation" 18 | task :docs => ['docs:api'] 19 | -------------------------------------------------------------------------------- /test/browser/sample/appinfo.sample.js: -------------------------------------------------------------------------------- 1 | // Fill these in with your application details 2 | // Note that your accountId is usually the number portion of the roleArn 3 | // value, ex.: arn:aws:iam::: 4 | appInfo = { 5 | accountId: 'ACCOUNTID', 6 | roleArn: 'COGNITO-ROLE', 7 | identityPoolId: 'COGNITO-IDENTITY-POOL-ID', 8 | facebook: { appId: '...' }, 9 | amazon: { appId: '...' }, 10 | google: { appId: '...' } 11 | }; 12 | 13 | // Set any global configuration settings 14 | AWS.config.update({ 15 | region: 'us-east-1' 16 | }); 17 | -------------------------------------------------------------------------------- /lib/xml/escape-element.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Escapes characters that can not be in an XML element. 3 | */ 4 | function escapeElement(value) { 5 | return value.replace(/&/g, '&') 6 | .replace(//g, '>') 8 | .replace(/\r/g, ' ') 9 | .replace(/\n/g, ' ') 10 | .replace(/\u0085/g, '…') 11 | .replace(/\u2028/, '
'); 12 | } 13 | 14 | /** 15 | * @api private 16 | */ 17 | module.exports = { 18 | escapeElement: escapeElement 19 | }; 20 | -------------------------------------------------------------------------------- /doc-src/templates/default/fulldoc/html/js/custom.js: -------------------------------------------------------------------------------- 1 | hljs.initHighlightingOnLoad(); 2 | 3 | $(document).ready(function() { 4 | var trueValue = 'true'; 5 | var nodeVersionNoticeKey = 'nodeVersionNoticeDismissed'; 6 | var dismissNodeDepNotice = localStorage.getItem(nodeVersionNoticeKey); 7 | 8 | if (dismissNodeDepNotice !== trueValue) { 9 | $('#node-version-notice').slideDown(); 10 | $('#node-version-notice .alert-dismiss').click(function() { 11 | localStorage.setItem(nodeVersionNoticeKey, trueValue); 12 | $(this).parent().slideUp(); 13 | }); 14 | } 15 | }); 16 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .changes 2 | .yard* 3 | .eslintrc 4 | .eslintignore 5 | .travis.yml 6 | .github 7 | .gitignore 8 | .idea 9 | .jshintrc 10 | .npmignore 11 | .tesselinclude 12 | .travis.yml 13 | .vscode/ 14 | .yard* 15 | apis/*.normal.json 16 | appveyor.yml 17 | bower.json 18 | CHANGELOG.md 19 | CONTRIBUTING.md 20 | configuration 21 | configuration.sample 22 | codecov.yml 23 | coverage 24 | doc 25 | doc-src 26 | eslint-rules 27 | Gemfile 28 | Gemfile.lock 29 | features 30 | karma.conf.js 31 | Rakefile 32 | scripts/lib/*spec.js 33 | SERVICES.md 34 | test 35 | testem.json 36 | tasks 37 | ts 38 | UPGRADING.md 39 | -------------------------------------------------------------------------------- /doc-src/yard-js/lib/yard-js/handlers/mixin_handler.rb: -------------------------------------------------------------------------------- 1 | require_relative 'base' 2 | 3 | module YARDJS 4 | module Handlers 5 | class MixinHandler < Base 6 | handles CallExpression 7 | 8 | process do 9 | return unless statement.callee.source =~ YARDJS.options.mixin_module_expression 10 | 11 | obj = YARD::CodeObjects::ClassObject.new(:root, statement.args.first.source) 12 | obj.instance_mixins.push(*statement.args[1..-1].map do |arg| 13 | YARD::CodeObjects::ClassObject.new(:root, arg.source) 14 | end) 15 | end 16 | end 17 | end 18 | end -------------------------------------------------------------------------------- /doc-src/yard-js/templates/default/layout/html/headers.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | <%= h @page_title %> 4 | <% if options.title && @page_title != options.title %> 5 | — <%= h options.title %> 6 | <% end %> 7 | 8 | <% stylesheets.each do |stylesheet| %> 9 | 10 | <% end %> 11 | <%= erb :script_setup %> 12 | <% javascripts.each do |javascript| %> 13 | 14 | <% end %> -------------------------------------------------------------------------------- /.yardopts: -------------------------------------------------------------------------------- 1 | -m markdown 2 | --markup-provider rdiscount 3 | --exclude lib/aws.js 4 | --no-api private 5 | --api experimental 6 | --no-highlight 7 | --title "IBM COS SDK for JavaScript" 8 | --template-path doc-src/templates 9 | --plugin sitemap 10 | -o doc/latest 11 | -e doc-src/templates/api-versions/plugin.rb 12 | --plugin js 13 | --define-class-expr (AWS\.util\.)?inherit 14 | --update-class-expr (AWS\.util\.)?update 15 | --mixin-module-expr (AWS\.util\.)?mixin 16 | --tag class_abstract:"Abstract Class" 17 | --tag method_abstract:"Abstract Method" 18 | --list-undoc 19 | lib/core.js 20 | lib/**/*.js 21 | - 22 | README.md 23 | CHANGELOG.md 24 | -------------------------------------------------------------------------------- /dist-tools/create-all-services.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var path = require('path'); 4 | 5 | /* 6 | * Pass optional path to target directory as command line argument. 7 | * 8 | * The directory must include the apis/ folder and service customizations at 9 | * `lib/services`. Clients will be generated in `clients/`. 10 | * 11 | * If parameter is not passed the repository root will be used. 12 | */ 13 | 14 | var ClientCreator = require('./client-creator'); 15 | 16 | var cc = new ClientCreator(process.argv[2] || path.join(__dirname, '..')); 17 | 18 | cc.writeClientServices(); 19 | console.log('Finished updating services.'); 20 | -------------------------------------------------------------------------------- /ts/core.ts: -------------------------------------------------------------------------------- 1 | import * as core from '../global'; 2 | 3 | // Validate members exposed through global 4 | if (core.Config) { 5 | 6 | } else if (core.CredentialProviderChain) { 7 | 8 | } else if (core.Credentials) { 9 | 10 | } else if (core.Endpoint) { 11 | 12 | } else if (core.EnvironmentCredentials) { 13 | 14 | } else if (core.EventListeners) { 15 | 16 | } else if (core.FileSystemCredentials) { 17 | 18 | } else if (core.HttpRequest) { 19 | 20 | } else if (core.HttpResponse) { 21 | 22 | } else if (core.MetadataService) { 23 | 24 | } else if (core.Request) { 25 | 26 | } else if (core.Response) { 27 | 28 | } 29 | const document: core.DocumentType = {} -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "node": true 5 | }, 6 | "globals": { 7 | "Buffer": true, 8 | "escape": true 9 | }, 10 | "rules": { 11 | "quotes": [2, "single"], 12 | "strict": 0, 13 | "eol-last": ["error", "always"], 14 | "curly": 0, 15 | "no-empty": 0, 16 | "no-underscore-dangle": 0, 17 | "new-cap": 0, 18 | "dot-notation": 0, 19 | "no-use-before-define": 0, 20 | "semi": [2, "always"], 21 | "keyword-spacing": [2, {"before": true, "after": true}], 22 | "space-before-blocks": [2, "always"], 23 | "no-trailing-spaces": 2, 24 | "space-unary-ops": 0 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/signers/v3https.js: -------------------------------------------------------------------------------- 1 | var AWS = require('../core'); 2 | var inherit = AWS.util.inherit; 3 | 4 | require('./v3'); 5 | 6 | /** 7 | * @api private 8 | */ 9 | AWS.Signers.V3Https = inherit(AWS.Signers.V3, { 10 | authorization: function authorization(credentials) { 11 | return 'AWS3-HTTPS ' + 12 | 'AWSAccessKeyId=' + credentials.accessKeyId + ',' + 13 | 'Algorithm=HmacSHA256,' + 14 | 'Signature=' + this.signature(credentials); 15 | }, 16 | 17 | stringToSign: function stringToSign() { 18 | return this.request.headers['X-Amz-Date']; 19 | } 20 | }); 21 | 22 | /** 23 | * @api private 24 | */ 25 | module.exports = AWS.Signers.V3Https; 26 | -------------------------------------------------------------------------------- /lib/credentials/shared_ini_file_credentials.d.ts: -------------------------------------------------------------------------------- 1 | import {Credentials} from '../credentials'; 2 | import {HTTPOptions} from '../config-base'; 3 | export class SharedIniFileCredentials extends Credentials { 4 | /** 5 | * Creates a new SharedIniFileCredentials object. 6 | */ 7 | constructor(options?: SharedIniFileCredentialsOptions); 8 | } 9 | 10 | interface SharedIniFileCredentialsOptions { 11 | profile?: string 12 | filename?: string 13 | disableAssumeRole?: boolean 14 | tokenCodeFn?: (mfaSerial: string, callback: (err?: Error, token?: string) => void) => void 15 | httpOptions?: HTTPOptions 16 | callback?: (err?: Error) => void 17 | } 18 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | PATH 2 | remote: doc-src/parsejs 3 | specs: 4 | parsejs (0.0.1) 5 | kpeg 6 | yard 7 | 8 | PATH 9 | remote: doc-src/yard-js 10 | specs: 11 | yard-js (0.1.3) 12 | 13 | GEM 14 | remote: https://rubygems.org/ 15 | specs: 16 | kpeg (1.1.0) 17 | rake (13.0.6) 18 | rdiscount (2.2.0.2) 19 | redcarpet (3.5.1) 20 | samus (3.0.9) 21 | yard (0.9.36) 22 | yard-sitemap (1.0.1) 23 | 24 | PLATFORMS 25 | ruby 26 | 27 | DEPENDENCIES 28 | parsejs! 29 | rake 30 | rdiscount 31 | redcarpet (~> 3.0) 32 | samus 33 | yard (~> 0.9.36) 34 | yard-js! 35 | yard-sitemap (~> 1.0) 36 | 37 | BUNDLED WITH 38 | 2.4.19 39 | -------------------------------------------------------------------------------- /doc-src/yard-js/yard-js.gemspec: -------------------------------------------------------------------------------- 1 | require File.expand_path('../lib/yard-js/version', __FILE__) 2 | 3 | Gem::Specification.new do |s| 4 | s.name = "yard-js" 5 | s.summary = "YARD plugin for documenting JavaScript source code" 6 | s.version = YARDJS::VERSION 7 | s.date = Time.now.strftime('%Y-%m-%d') 8 | s.author = "Loren Segal" 9 | s.email = "lsegal@soen.ca" 10 | s.homepage = "http://github.com/lsegal/yard-js" 11 | s.platform = Gem::Platform::RUBY 12 | s.files = Dir.glob("{lib,templates}/**/*") + 13 | ['LICENSE.txt', 'README.md', __FILE__] 14 | s.require_paths = ['lib'] 15 | end 16 | -------------------------------------------------------------------------------- /.yardopts_guide: -------------------------------------------------------------------------------- 1 | --plugin sitemap 2 | -t flasky_sphinx_guide 3 | -p doc-src/templates 4 | --title "AWS SDK for JavaScript" 5 | --no-highlight 6 | -o doc/guide 7 | --readme doc-src/guide/index.md 8 | - 9 | doc-src/guide/browser-intro.md 10 | doc-src/guide/browser-configuring.md 11 | doc-src/guide/browser-services.md 12 | doc-src/guide/browser-making-requests.md 13 | doc-src/guide/browser-examples.md 14 | doc-src/guide/browser-building.md 15 | doc-src/guide/browser-configuring-wif.md 16 | doc-src/guide/node-intro.md 17 | doc-src/guide/node-configuring.md 18 | doc-src/guide/node-services.md 19 | doc-src/guide/node-making-requests.md 20 | doc-src/guide/node-examples.md 21 | UPGRADING.md 22 | -------------------------------------------------------------------------------- /doc-src/yard-js/templates/default/tags/setup.rb: -------------------------------------------------------------------------------- 1 | def init 2 | super 3 | sections.place(:callback, [T('docstring')]).after_any(:param) 4 | end 5 | 6 | def return 7 | if object.type == :property 8 | return if object.property_type == :literal 9 | return if object.constructor? 10 | return if object.tags(:return).size == 1 && object.tag(:return).text.empty? 11 | end 12 | tag(:return) 13 | end 14 | 15 | def param 16 | tag(:param) if object.type == :property || object.type == :event 17 | end 18 | 19 | def value 20 | return if object.tag(:constant) 21 | if object.has_tag?(:value) && !object.tag(:value).text.empty? 22 | erb(@name = :value) 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'rake' 4 | 5 | group :documentation do 6 | gem 'rdiscount' 7 | gem 'yard-sitemap', '~> 1.0' 8 | 9 | # Switch to yard-js gem when fix is published 10 | # Fix PR: https://github.com/lsegal/yard-js/pull/4 11 | gem 'yard-js', path: './doc-src/yard-js' 12 | 13 | # When updating yard, override app.js from upstream to doc-src/templates/default/fulldoc/js/app.js 14 | # and add patch from PR https://github.com/lsegal/yard/pull/1399 to support jQuery 3.6.0+ 15 | gem 'yard', '~> 0.9.36' 16 | 17 | gem 'parsejs', path: './doc-src/parsejs' 18 | end 19 | 20 | group :release do 21 | gem 'redcarpet', '~> 3.0' 22 | gem 'samus' 23 | end 24 | -------------------------------------------------------------------------------- /lib/config_use_dualstack.d.ts: -------------------------------------------------------------------------------- 1 | import {ConfigBase} from './config-base'; 2 | 3 | export interface UseDualstackConfigOptions { 4 | /** 5 | * Enables IPv6/IPv4 dualstack endpoint. When a DNS lookup is performed on an endpoint of this type, it returns an “A” record with an IPv4 address and an “AAAA” record with an IPv6 address. 6 | * In most cases the network stack in the client environment will automatically prefer the AAAA record and make a connection using the IPv6 address. 7 | * Note, however, that currently on Windows, the IPv4 address will be preferred. 8 | * @deprecated Use {@link ConfigBase.useDualstackEndpoint} 9 | */ 10 | useDualstack?: boolean; 11 | } 12 | -------------------------------------------------------------------------------- /lib/endpoint.d.ts: -------------------------------------------------------------------------------- 1 | export class Endpoint { 2 | /** 3 | * Constructs a new endpoint given an endpoint URL. 4 | */ 5 | constructor(url: string); 6 | 7 | /** 8 | * The host portion of the endpoint including the port, e.g., example.com:80. 9 | */ 10 | host: string; 11 | /** 12 | * The host portion of the endpoint, e.g., example.com. 13 | */ 14 | hostname: string; 15 | /** 16 | * The full URL of the endpoint. 17 | */ 18 | href: string; 19 | /** 20 | * The port of the endpoint. 21 | */ 22 | port: number; 23 | /** 24 | * The protocol (http or https) of the endpoint URL. 25 | */ 26 | protocol: string; 27 | } -------------------------------------------------------------------------------- /test/browser/runner.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | AWS SDK for JavaScript - Browser Tests 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /lib/model/collection.js: -------------------------------------------------------------------------------- 1 | var memoizedProperty = require('../util').memoizedProperty; 2 | 3 | function memoize(name, value, factory, nameTr) { 4 | memoizedProperty(this, nameTr(name), function() { 5 | return factory(name, value); 6 | }); 7 | } 8 | 9 | function Collection(iterable, options, factory, nameTr, callback) { 10 | nameTr = nameTr || String; 11 | var self = this; 12 | 13 | for (var id in iterable) { 14 | if (Object.prototype.hasOwnProperty.call(iterable, id)) { 15 | memoize.call(self, id, iterable[id], factory, nameTr); 16 | if (callback) callback(id, iterable[id]); 17 | } 18 | } 19 | } 20 | 21 | /** 22 | * @api private 23 | */ 24 | module.exports = Collection; 25 | -------------------------------------------------------------------------------- /scripts/lib/get-operation-shape-names.js: -------------------------------------------------------------------------------- 1 | function getOperationShapeNames(model) { 2 | var operationShapeNames = []; 3 | var operations = model.operations; 4 | 5 | for (var operationName of Object.keys(operations)) { 6 | var operation = operations[operationName]; 7 | if (operation.input && operation.input.shape) { 8 | operationShapeNames.push(operation.input.shape); 9 | } 10 | if (operation.output && operation.output.shape) { 11 | operationShapeNames.push(operation.output.shape); 12 | } 13 | } 14 | 15 | return operationShapeNames; 16 | }; 17 | 18 | module.exports = { 19 | getOperationShapeNames: getOperationShapeNames 20 | }; -------------------------------------------------------------------------------- /doc-src/yard-js/lib/yard-js/core_ext/yard.rb: -------------------------------------------------------------------------------- 1 | require 'yard' 2 | 3 | require_relative 'yard/code_objects' 4 | require_relative 'yard/registry' 5 | require_relative 'yard/tags' 6 | require_relative 'yard/templates' 7 | require_relative 'yard/yardoc' 8 | 9 | YARD::CodeObjects::NSEP = '.' 10 | YARD::CodeObjects.send(:remove_const, :NSEPQ) 11 | YARD::CodeObjects::NSEPQ = Regexp.quote(YARD::CodeObjects::NSEP) 12 | YARD::CodeObjects::CSEP = '.' 13 | YARD::CodeObjects.send(:remove_const, :CSEPQ) 14 | YARD::CodeObjects::CSEPQ = Regexp.quote(YARD::CodeObjects::CSEP) 15 | YARD::CodeObjects::ISEP = '.' 16 | YARD::CodeObjects.send(:remove_const, :ISEPQ) 17 | YARD::CodeObjects::ISEPQ = Regexp.quote(YARD::CodeObjects::ISEP) 18 | -------------------------------------------------------------------------------- /lib/browser_loader.js: -------------------------------------------------------------------------------- 1 | var util = require('./util'); 2 | 3 | // browser specific modules 4 | util.crypto.lib = require('./browserCryptoLib'); 5 | util.Buffer = require('buffer/').Buffer; 6 | util.url = require('url/'); 7 | util.querystring = require('querystring/'); 8 | 9 | var AWS = require('./core'); 10 | 11 | /** 12 | * @api private 13 | */ 14 | module.exports = AWS; 15 | 16 | // Use default API loader function 17 | require('./api_loader'); 18 | 19 | // Load the DOMParser XML parser 20 | AWS.XML.Parser = require('./xml/browser_parser'); 21 | 22 | // Load the XHR HttpClient 23 | require('./http/xhr'); 24 | 25 | if (typeof process === 'undefined') { 26 | var process = { 27 | browser: true 28 | }; 29 | } 30 | -------------------------------------------------------------------------------- /doc-src/templates/default/layout/html/v3note.erb: -------------------------------------------------------------------------------- 1 |
    2 |
    3 |
    4 |
    You are viewing the documentation for an older major version of the AWS SDK for JavaScript.
    5 |
    6 | The modular AWS SDK for JavaScript (v3), the latest major version of AWS SDK for JavaScript, is now stable and recommended for general use. 7 | For more information, see the 8 | Migration Guide and 9 | API Reference. 10 |
    11 |
    12 |
    -------------------------------------------------------------------------------- /doc-src/yard-js/templates/default/fulldoc/html/setup.rb: -------------------------------------------------------------------------------- 1 | def generate_method_list 2 | @items = prune_method_listing(Registry.all(:property), false) 3 | @items = @items.select {|m| m.property_type == :function } 4 | @items = @items.reject {|m| m.constructor? } 5 | @items = @items.sort_by {|m| m.name.to_s } 6 | @list_title = "Method List" 7 | @list_type = "method" 8 | generate_list_contents 9 | end 10 | 11 | def generate_property_list 12 | @items = prune_method_listing(Registry.all(:property), false) 13 | @items = @items.select {|m| m.property_type != :function } 14 | @items = @items.sort_by {|m| m.name.to_s } 15 | @list_title = "Property List" 16 | @list_type = "property" 17 | generate_list_contents 18 | end 19 | -------------------------------------------------------------------------------- /tasks/util.rake: -------------------------------------------------------------------------------- 1 | desc 'Install dependencies' 2 | task :setup do 3 | system "npm #{LOGLEVEL} install" 4 | system "bundle install" 5 | end 6 | 7 | namespace :test do 8 | desc "Runs all tests" 9 | task :all => :build do 10 | sh "npm #{LOGLEVEL} test" 11 | end 12 | 13 | desc "Runs unit tests" 14 | task :unit => :build do 15 | sh "npm #{LOGLEVEL} run-script unit" 16 | end 17 | 18 | desc "Runs integration tests" 19 | task :integration => :build do 20 | sh "npm #{LOGLEVEL} run-script integration" 21 | end 22 | 23 | end 24 | 25 | desc 'Runs JSHint' 26 | task :lint do 27 | sh "npm #{LOGLEVEL} run-script lint" 28 | end 29 | 30 | desc 'Interactive console' 31 | task :console do 32 | system './scripts/console' 33 | end 34 | -------------------------------------------------------------------------------- /doc-src/yard-js/lib/yard-js/core_ext/yard/yardoc.rb: -------------------------------------------------------------------------------- 1 | module YARD 2 | module CLI 3 | class Yardoc 4 | def general_options_yardjs(opts) 5 | general_options_orig(opts) 6 | 7 | opts.on('--define-class-expr EXPR') do |expr| 8 | YARDJS.options.define_class_expression = expr 9 | end 10 | 11 | opts.on('--update-class-expr EXPR') do |expr| 12 | YARDJS.options.update_class_expression = expr 13 | end 14 | 15 | opts.on('--mixin-module-expr EXPR') do |expr| 16 | YARDJS.options.mixin_module_expression = expr 17 | end 18 | end 19 | alias general_options_orig general_options 20 | alias general_options general_options_yardjs 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /clients/s3.js: -------------------------------------------------------------------------------- 1 | require('../lib/node_loader'); 2 | var AWS = require('../lib/core'); 3 | var Service = require('../lib/service'); 4 | var apiLoader = require('../lib/api_loader'); 5 | 6 | apiLoader.services['s3'] = {}; 7 | AWS.S3 = Service.defineService('s3', ['2006-03-01']); 8 | require('../lib/services/s3'); 9 | Object.defineProperty(apiLoader.services['s3'], '2006-03-01', { 10 | get: function get() { 11 | var model = require('../apis/s3-2006-03-01.min.json'); 12 | model.paginators = require('../apis/s3-2006-03-01.paginators.json').pagination; 13 | model.waiters = require('../apis/s3-2006-03-01.waiters2.json').waiters; 14 | return model; 15 | }, 16 | enumerable: true, 17 | configurable: true 18 | }); 19 | 20 | module.exports = AWS.S3; 21 | -------------------------------------------------------------------------------- /lib/services/s3util.js: -------------------------------------------------------------------------------- 1 | var AWS = require('../core'); 2 | var regionUtil = require('../region_config'); 3 | 4 | var s3util = { 5 | /** 6 | * Returns true if the bucket name is DNS compatible. Buckets created 7 | * outside of the classic region MUST be DNS compatible. 8 | * 9 | * @api private 10 | */ 11 | dnsCompatibleBucketName: function dnsCompatibleBucketName(bucketName) { 12 | var b = bucketName; 13 | var domain = new RegExp(/^[a-z0-9][a-z0-9\.\-]{1,61}[a-z0-9]$/); 14 | var ipAddress = new RegExp(/(\d+\.){3}\d+/); 15 | var dots = new RegExp(/\.\./); 16 | return (b.match(domain) && !b.match(ipAddress) && !b.match(dots)) ? true : false; 17 | }, 18 | }; 19 | 20 | /** 21 | * @api private 22 | */ 23 | module.exports = s3util; 24 | -------------------------------------------------------------------------------- /lib/model/resource_waiter.js: -------------------------------------------------------------------------------- 1 | var util = require('../util'); 2 | var property = util.property; 3 | 4 | function ResourceWaiter(name, waiter, options) { 5 | options = options || {}; 6 | property(this, 'name', name); 7 | property(this, 'api', options.api, false); 8 | 9 | if (waiter.operation) { 10 | property(this, 'operation', util.string.lowerFirst(waiter.operation)); 11 | } 12 | 13 | var self = this; 14 | var keys = [ 15 | 'type', 16 | 'description', 17 | 'delay', 18 | 'maxAttempts', 19 | 'acceptors' 20 | ]; 21 | 22 | keys.forEach(function(key) { 23 | var value = waiter[key]; 24 | if (value) { 25 | property(self, key, value); 26 | } 27 | }); 28 | } 29 | 30 | /** 31 | * @api private 32 | */ 33 | module.exports = ResourceWaiter; 34 | -------------------------------------------------------------------------------- /doc-src/templates/default/layout/html/nodeVersionNotice.erb: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/credentials/anonymous_credentials.js: -------------------------------------------------------------------------------- 1 | var AWS = require('../core'); 2 | 3 | /** 4 | * Represents anonymous credentials, which do not require any authentication. 5 | * 6 | * This can be used for Anonymous Access against buckets configured for 7 | * anonymous operations. 8 | * 9 | */ 10 | AWS.AnonymousCredentials = AWS.util.inherit(AWS.Credentials, { 11 | 12 | /** 13 | * Creates a new AnonymousCredentials class. 14 | */ 15 | constructor: function AnonymousCredentials() { 16 | AWS.Credentials.call(this); 17 | }, 18 | 19 | /** 20 | * Stub to satisfy the credentials provider chain. 21 | * 22 | * @callback callback function(err) 23 | * @see get 24 | */ 25 | refresh: function refresh(callback) { 26 | callback(); 27 | } 28 | 29 | }); 30 | -------------------------------------------------------------------------------- /lib/region/utils.js: -------------------------------------------------------------------------------- 1 | // IBM Unsupported 2 | // function isFipsRegion(region) { 3 | // return typeof region === 'string' && (region.startsWith('fips-') || region.endsWith('-fips')); 4 | // } 5 | 6 | function isGlobalRegion(region) { 7 | return typeof region === 'string' && ['aws-global', 'aws-us-gov-global'].includes(region); 8 | } 9 | 10 | function getRealRegion(region) { 11 | return ['fips-aws-global', 'aws-fips', 'aws-global'].includes(region) 12 | ? 'us-east-1' 13 | : ['fips-aws-us-gov-global', 'aws-us-gov-global'].includes(region) 14 | ? 'us-gov-west-1' 15 | : region.replace(/fips-(dkr-|prod-)?|-fips/, ''); 16 | } 17 | 18 | module.exports = { 19 | // IBM Unsupported 20 | // isFipsRegion: isFipsRegion, 21 | isGlobalRegion: isGlobalRegion, 22 | getRealRegion: getRealRegion 23 | }; 24 | -------------------------------------------------------------------------------- /features/extra/world.js: -------------------------------------------------------------------------------- 1 | var world = require('./helpers'); 2 | var path = require('path'); 3 | 4 | world.AWS = require('../../lib/aws'); 5 | try { 6 | world.AWS.config.loadFromPath(path.resolve('./configuration')); 7 | } catch (e) {} finally { 8 | process.env['CONFIGURED_REGION'] = world.AWS.config.region || new world.AWS.Config().region; 9 | } 10 | 11 | if (process.env['S3_ENDPOINT']) { 12 | var S3_constructor = world.AWS.S3; 13 | world.AWS.S3 = function () { 14 | var s3 = new S3_constructor(arguments); 15 | s3.endpoint = new world.AWS.Endpoint(process.env['S3_ENDPOINT']); 16 | return s3; 17 | } 18 | } 19 | 20 | var WorldConstructor = function WorldConstructor(callback) { 21 | callback(world); 22 | }; 23 | 24 | exports.World = WorldConstructor; 25 | exports.WorldInstance = world; 26 | -------------------------------------------------------------------------------- /scripts/typings-generator.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /* 4 | * Pass optional path to target directory as command line argument. 5 | * 6 | * The directory must include the apis/ folder and service customizations at 7 | * `lib/services`. Clients will be generated in `clients/`. 8 | * 9 | * If parameter is not passed the repository root will be used. 10 | */ 11 | 12 | var path = require('path'); 13 | var TSGenerator = require('./lib/ts-generator'); 14 | 15 | var basePath = process.argv[2] || path.join(__dirname, '..'); 16 | 17 | var tsGenerator = new TSGenerator({ 18 | SdkRootDirectory: basePath 19 | }); 20 | 21 | tsGenerator.generateAllClientTypings(); 22 | tsGenerator.generateGroupedClients(); 23 | tsGenerator.generateConfigurationServicePlaceholders(); 24 | console.log('TypeScript Definitions created.'); 25 | 26 | 27 | -------------------------------------------------------------------------------- /doc-src/yard-js/lib/yard-js/handlers/instance_method_handler.rb: -------------------------------------------------------------------------------- 1 | require_relative 'base' 2 | 3 | module YARDJS 4 | module Handlers 5 | class InstanceMethodHandler < Base 6 | handles Property 7 | 8 | process do 9 | return unless statement.value.is_a?(FunctionExpression) 10 | 11 | handle_default_comments 12 | 13 | name = statement.key.val 14 | params = statement.value.params.list.map {|t| [t.val, nil]} 15 | 16 | obj = register CodeObjects::PropertyObject.new(namespace, name) 17 | obj.property_type = :function 18 | obj.parameters = params 19 | obj.signature = "#{name}(#{params.join(', ')})" 20 | unless obj.has_tag?(:return) 21 | obj.docstring.add_tag(YARD::Tags::Tag.new(:return, '', ['void'])) 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /doc-src/yard-js/lib/yard-js.rb: -------------------------------------------------------------------------------- 1 | require 'ostruct' 2 | 3 | module YARDJS 4 | class Options 5 | %w(define_class_expression 6 | update_class_expression 7 | mixin_module_expression).each do |name| 8 | attr_reader(name) 9 | define_method("#{name}=") do |value| 10 | instance_variable_set("@#{name}", /\A#{value}\Z/) 11 | end 12 | end 13 | 14 | def initialize 15 | self.define_class_expression ||= 16 | ENV['DEFINE_CLASS_EXPR'] || 'inherit' 17 | self.update_class_expression ||= 18 | ENV['UPDATE_CLASS_EXPR'] || 'update' 19 | self.mixin_module_expression ||= 20 | ENV['MIXIN_MODULE_EXPR'] || 'mixin' 21 | end 22 | end 23 | 24 | def self.options 25 | @options ||= Options.new 26 | end 27 | end 28 | 29 | require_relative 'yard-js/plugin' 30 | require_relative 'yard-js/version' 31 | -------------------------------------------------------------------------------- /scripts/changelog/release: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var util = require('./util'); 4 | 5 | var input = process.argv[2]; 6 | var version; 7 | 8 | switch (input) { 9 | case 'major': 10 | version = util.bumpMajor(); 11 | break; 12 | case 'minor': 13 | version = util.bumpMinor(); 14 | break; 15 | case 'patch': 16 | case undefined: 17 | version = util.bumpPatch(); 18 | break; 19 | default: 20 | version = util.checkAndNormalizeVersion(input); 21 | } 22 | 23 | var nextReleaseFiles = util.listNextReleaseFiles(); 24 | 25 | var versionJSON = nextReleaseFiles.reduce(function(changes, filepath) { 26 | return changes.concat(util.readChangesFromJSON(filepath)); 27 | }, []); 28 | 29 | util.writeToVersionJSON(version, versionJSON); 30 | 31 | util.clearNextReleaseDir(); 32 | 33 | util.addVersionJSONToChangelog(version, versionJSON); 34 | 35 | util.writeToChangelog(); 36 | -------------------------------------------------------------------------------- /doc-src/templates/api-versions/templates/default/layout/html/setup.rb: -------------------------------------------------------------------------------- 1 | def init 2 | super 3 | sections.place(:services).before_any(:objects) 4 | end 5 | 6 | def services 7 | ids = {} 8 | svcs = Registry.all(:class).select {|x| x.has_tag?(:service) } 9 | svcs.each do |svc| 10 | id = svc.tag(:service).text 11 | (ids[id] ||= []) << svc 12 | end 13 | 14 | @services = ids.sort_by {|id| id } 15 | erb(:services) 16 | end 17 | 18 | def index 19 | @objects_by_letter = {} 20 | objects = Registry.all(:class, :module).sort_by {|o| o.name.to_s } 21 | objects = run_verifier(objects) 22 | objects = objects.reject {|x| 23 | next(false) unless x.respond_to?(:superclass) 24 | x.respond_to?(:superclass) && x.superclass.path =~ /^AWS\.(Service|Client)$/ 25 | } 26 | objects.each {|o| (@objects_by_letter[o.name.to_s[0,1].upcase] ||= []) << o } 27 | erb(:index) 28 | end 29 | -------------------------------------------------------------------------------- /doc-src/yard-js/lib/yard-js/handlers/comment_handler.rb: -------------------------------------------------------------------------------- 1 | require_relative 'base' 2 | 3 | module YARDJS 4 | module Handlers 5 | class CommentedStatementHandler < Base 6 | handles CommentedStatement 7 | 8 | process do 9 | parser.extra_state.comments = statement.comments 10 | parse_block(statement.statement) 11 | parser.extra_state.comments = nil 12 | end 13 | end 14 | 15 | class ExpressionStatementHandler < Base 16 | handles ExpressionStatement 17 | process { parse_block statement.expression } 18 | end 19 | 20 | class SequenceExpressionStatementHandler < Base 21 | handles SequenceExpression 22 | process { parse_block statement.expressions } 23 | end 24 | 25 | class CommentHandler < Base 26 | handles Comment 27 | 28 | process do 29 | register_docstring(nil) 30 | end 31 | end 32 | end 33 | end -------------------------------------------------------------------------------- /lib/signers/iam.js: -------------------------------------------------------------------------------- 1 | var AWS = require('../core'); 2 | var inherit = AWS.util.inherit; 3 | 4 | /** 5 | * @api private 6 | */ 7 | AWS.Signers.IAM = inherit(AWS.Signers.RequestSigner, { 8 | addAuthorization: function addAuthorization(credentials, date, req) { 9 | var token = credentials.tokenManager.getToken(); 10 | this.request.headers['Authorization'] = 'Bearer ' + (token.accessToken || token['access_token']); 11 | 12 | if (req.operation === 'createBucket' || 13 | req.operation === 'listBuckets' || 14 | req.operation === 'listBucketsExtended') { 15 | if (!this.request.headers['Ibm-Service-Instance-Id']) { 16 | this.request.headers['Ibm-Service-Instance-Id'] = credentials.serviceInstanceId; 17 | } 18 | } 19 | }, 20 | 21 | signature: function signature(credentials) { 22 | // not used 23 | } 24 | 25 | }); 26 | 27 | module.exports = AWS.Signers.IAM; 28 | -------------------------------------------------------------------------------- /doc-src/templates/default/layout/html/headers.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | <%= h @page_title %> 4 | <% if options.title && @page_title != options.title %> 5 | — <%= h options.title %> 6 | <% end %> 7 | 8 | <% stylesheets.each do |stylesheet| %> 9 | 10 | <% end %> 11 | <% javascripts.each do |javascript| %> 12 | <% if url_for(javascript) == '../js/app.js' %> 13 | 20 | <% else %> 21 | 22 | <% end %> 23 | <% end %> -------------------------------------------------------------------------------- /doc-src/templates/default/layout/html/layout.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | <%= erb(:headers) %> 8 | 9 | 10 | 14 | 15 |
    16 | 21 | 22 |
    23 | <%= erb(:v3note) %> 24 | 25 | <%= yieldall %> 26 |
    27 | 28 | <%= erb(:footer) %> 29 |
    30 | 31 | 32 | -------------------------------------------------------------------------------- /lib/token/static_token_provider.js: -------------------------------------------------------------------------------- 1 | var AWS = require('../core'); 2 | 3 | /** 4 | * Represents the simplest token provider. It returns a static token string 5 | * and has an optional expireTime. 6 | */ 7 | AWS.StaticTokenProvider = AWS.util.inherit(AWS.Token, { 8 | 9 | /** 10 | * Creates a new StaticTokenProvider class with a given {token} and 11 | * optional {expireTime}. 12 | * 13 | * ```javascript 14 | * var staticTokenProvider = new AWS.StaticTokenProvider({ 15 | * token: 'token' 16 | * }); 17 | * staticTokenProvider.token == 'token' // from constructor 18 | * ``` 19 | * 20 | * @option options token [String] represents the literal token string. 21 | * @option options expireTime [Date] optional field representing the time at which 22 | * the token expires. 23 | */ 24 | constructor: function StaticTokenProvider(options) { 25 | AWS.Token.call(this, options); 26 | } 27 | }); 28 | -------------------------------------------------------------------------------- /doc-src/yard-js/templates/default/tags/callback.erb: -------------------------------------------------------------------------------- 1 | <% if object.tags(:callback).size == 1 %> 2 | <% callback = object.tag(:callback) %> 3 |

    Callback (<%= callback.param_name %>):

    4 |
      5 |
    • 6 | <%= signature(callback, false, false) %> 7 | <%= yieldall :object => callback %> 8 |
    • 9 |
    10 | <% elsif object.has_tag?(:callback) && object.tags(:callback).any? {|o| !o.docstring.blank? } %> 11 |

    Callbacks:

    12 |
      13 | <% object.tags(:callback).each do |callback| %> 14 | <% next if callback.docstring.blank? %> 15 |
    • 16 | <%= signature(callback, false, false) %> 17 | <%= yieldall :object => callback %> 18 |
    • 19 | <% end %> 20 |
    21 | <% end %> 22 | -------------------------------------------------------------------------------- /doc-src/templates/default/fulldoc/html/css/custom.css: -------------------------------------------------------------------------------- 1 | .alert { 2 | border: 1px solid; 3 | border-radius: 2px; 4 | display: flex; 5 | margin: 10px 0px; 6 | padding: 12px 20px; 7 | } 8 | 9 | .alert.alert-info { 10 | border-color: #0073bb; 11 | background-color: #f1faff; 12 | } 13 | 14 | .alert.alert-warning { 15 | border-color: #d13212; 16 | background-color: #fdf3f1; 17 | } 18 | 19 | .alert .alert-icon:before { 20 | font-size: 2em; 21 | padding-right: 15px; 22 | } 23 | 24 | .alert-info .alert-icon:before { 25 | content: "ⓘ"; 26 | color: #0073bb; 27 | } 28 | 29 | .alert-warning .alert-icon:before { 30 | content: "⚠"; 31 | color: #d13212; 32 | } 33 | 34 | .alert .alert-header { 35 | font-weight: bold; 36 | padding-bottom: 5px; 37 | } 38 | 39 | .alert .alert-dismiss { 40 | cursor: pointer; 41 | margin-left: auto; 42 | } 43 | 44 | .alert .alert-dismiss:after { 45 | content: "✕"; 46 | padding-left: 10px; 47 | } -------------------------------------------------------------------------------- /features/extra/assertions.js: -------------------------------------------------------------------------------- 1 | var assert = require('assert'); 2 | 3 | assert.match = function assertMatches(string, matcher, message) { 4 | assert.ok(string.match(matcher), message || 5 | 'Expected ' + string + ' to match ' + matcher); 6 | }; 7 | 8 | assert.contains = function assertContains(list, matcher, message) { 9 | var found = false; 10 | for (var i in list) { 11 | if (!list.hasOwnProperty(i)) continue; 12 | if (typeof matcher === 'function') { 13 | found = matcher(list[i]); 14 | } else { 15 | found = (list[i] === matcher); 16 | } 17 | if (found) return; 18 | } 19 | assert.fail(list, matcher, message, 'does not contain'); 20 | }; 21 | 22 | assert.compare = function assertComparison(actual, operator, expected, message) { 23 | var compare = actual + ' ' + operator + ' ' + expected; 24 | assert.ok(eval(compare), message || compare); 25 | }; 26 | 27 | module.exports = { 28 | assert: assert 29 | }; 30 | -------------------------------------------------------------------------------- /lib/metadata_service/get_metadata_service_endpoint.js: -------------------------------------------------------------------------------- 1 | var AWS = require('../core'); 2 | 3 | var Endpoint = require('./get_endpoint')(); 4 | var EndpointMode = require('./get_endpoint_mode')(); 5 | 6 | // IBM Unsupported 7 | // var ENDPOINT_CONFIG_OPTIONS = require('./get_endpoint_config_options')(); 8 | // var ENDPOINT_MODE_CONFIG_OPTIONS = require('./get_endpoint_mode_config_options')(); 9 | 10 | var getMetadataServiceEndpoint = function() { 11 | var endpoint = AWS.util.loadConfig(ENDPOINT_CONFIG_OPTIONS); 12 | if (endpoint !== undefined) return endpoint; 13 | 14 | var endpointMode = AWS.util.loadConfig(ENDPOINT_MODE_CONFIG_OPTIONS); 15 | switch (endpointMode) { 16 | case EndpointMode.IPv4: 17 | return Endpoint.IPv4; 18 | case EndpointMode.IPv6: 19 | return Endpoint.IPv6; 20 | default: 21 | throw new Error('Unsupported endpoint mode: ' + endpointMode); 22 | } 23 | }; 24 | 25 | module.exports = getMetadataServiceEndpoint; 26 | -------------------------------------------------------------------------------- /scripts/lib/prune-shapes.js: -------------------------------------------------------------------------------- 1 | var getOperationShapeNames = require('./get-operation-shape-names').getOperationShapeNames; 2 | var visitRelatedShapeNames = require('./visit-related-shape-names').visitRelatedShapeNames; 3 | 4 | function pruneShapes(model) { 5 | 6 | // start by grabbing the input/output shapes on all operations 7 | var operationShapeNames = getOperationShapeNames(model); 8 | var shapeMap = model.shapes; 9 | 10 | for (operationShape of operationShapeNames) { 11 | // traverse the tree and store visited shapes 12 | visitRelatedShapeNames(operationShape, shapeMap); 13 | } 14 | 15 | // iterate over the shapeMap and remove any shape that wasn't visited 16 | var shapeNames = Object.keys(shapeMap); 17 | for (var name of shapeNames) { 18 | if (!shapeMap[name].visited) { 19 | delete shapeMap[name]; 20 | } 21 | } 22 | 23 | }; 24 | 25 | module.exports = { 26 | pruneShapes: pruneShapes 27 | }; -------------------------------------------------------------------------------- /lib/http_request.d.ts: -------------------------------------------------------------------------------- 1 | import {Endpoint} from './endpoint'; 2 | /** 3 | * The low level HTTP request object, encapsulating all HTTP header and body data sent by a service request. 4 | */ 5 | export class HttpRequest { 6 | /** 7 | * The part of the path excluding the query string. 8 | */ 9 | pathname(): string; 10 | /** 11 | * The query string portion of the path. 12 | */ 13 | search: string; 14 | /** 15 | * The request body payload. 16 | */ 17 | body: string | Buffer; 18 | /** 19 | * The endpoint for the request. 20 | */ 21 | endpoint: Endpoint; 22 | /** 23 | * A map of header keys and their respective values. 24 | */ 25 | headers: { 26 | [key: string]: string; 27 | } 28 | /** 29 | * The HTTP method of the request. 30 | */ 31 | method: string; 32 | /** 33 | * The path portion of the URI, e.g., "/list/?start=5&num=10". 34 | */ 35 | path: string; 36 | } -------------------------------------------------------------------------------- /doc-src/yard-js/templates/default/module/html/events_summary.erb: -------------------------------------------------------------------------------- 1 | <% groups(event_listing, "Event") do |list, title| %> 2 |

    <%= title %> 3 | collapse 4 |

    5 | 6 |
      7 | <% list.each do |event| %> 8 |
    • 9 | <%= link_object event, "'#{event.name}'" %> 10 | function (<%= event.parameters.map(&:first).join(", ") %>) 11 | 12 | <% if event.has_tag?(:deprecated) %> 13 | Deprecated. <%= htmlify_line event.tag(:deprecated).text %> 14 | <% else %> 15 | <%= htmlify_line docstring_summary(event) %> 16 | <% end %> 17 |
    • 18 | <% end %> 19 |
    20 | <% end %> 21 | -------------------------------------------------------------------------------- /config.js.sample: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | // Endpoint of the COS instance 3 | endpoint: 'http://', 4 | 5 | // AWS credentials. Not used if IAM credentials are set. 6 | accessKey: '', 7 | secretAccessKey: '', 8 | 9 | // IAM credentials 10 | apiKeyId: '', 11 | serviceInstanceId: '', 12 | 13 | // Only set this if you need to override the IAM authentication endpoint 14 | // ibmAuthEndpoint: '', 15 | 16 | // Optional IAM token manager to test with 17 | // tokenManager: (function() { 18 | // var token = { 19 | // 'tokenType': 'bearer', 20 | // 'accessToken': '', 21 | // 'refreshToken': '', 22 | // 'expiration': '' 23 | // } 24 | // return { 25 | // getToken: function() { 26 | // return token 27 | // }, 28 | // refreshToken: function() { 29 | // return Promise.resolve(token); 30 | // } 31 | // } 32 | // })() 33 | } -------------------------------------------------------------------------------- /doc-src/yard-js/lib/yard-js/core_ext/yard/registry.rb: -------------------------------------------------------------------------------- 1 | module YARD 2 | module Registry 3 | def self.resolve(namespace, name, inheritance = false, proxy_fallback = false, type = nil) 4 | if namespace.is_a?(CodeObjects::Proxy) 5 | return proxy_fallback ? CodeObjects::Proxy.new(namespace, name, type) : nil 6 | end 7 | 8 | if namespace == :root || !namespace 9 | namespace = root 10 | else 11 | namespace = namespace.parent until namespace.is_a?(CodeObjects::NamespaceObject) 12 | end 13 | orignamespace = namespace 14 | 15 | name = name.to_s.sub(/^\./, '') 16 | nss = namespace.path.split('.') 17 | nss = [] if nss == [''] 18 | while nss.size >= 0 19 | if obj = at((nss + [name]).compact.join('.')) 20 | return obj 21 | end 22 | break if nss.size == 0 23 | nss.pop 24 | end 25 | 26 | proxy_fallback ? CodeObjects::Proxy.new(orignamespace, name, type) : nil 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /tasks/lib/cucumber_generator.rb: -------------------------------------------------------------------------------- 1 | # Generates features/service/* files 2 | class CucumberGenerator 3 | def initialize(klass, service, api) 4 | @klass = klass 5 | @service = service 6 | @api = api 7 | end 8 | 9 | def features_file 10 | <<-eof 11 | # language: en 12 | @#{@service} 13 | Feature: #{@api['service_full_name']} 14 | 15 | I want to use #{@api['service_full_name']} 16 | 17 | Scenario: Feature 18 | Given I create something with the service 19 | Then the request should be successful 20 | And I delete the thing I created 21 | 22 | Scenario: Error handling 23 | Given I do something with the service 24 | Then the error code should be "ValidationError" 25 | eof 26 | end 27 | 28 | def step_definitions_file 29 | <<-eof 30 | module.exports = function() { 31 | this.Before("@#{@service}", function (callback) { 32 | this.service = new this.AWS.#{@klass}(); 33 | callback(); 34 | }); 35 | 36 | // Add step definitions 37 | }; 38 | eof 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /doc-src/yard-js/lib/yard-js/handlers/module_handler.rb: -------------------------------------------------------------------------------- 1 | require_relative 'base' 2 | 3 | module YARDJS 4 | module Handlers 5 | class ModuleHandler < Base 6 | handles AssignmentExpression 7 | handles VariableDeclaration 8 | handles Property 9 | 10 | process do 11 | case statement 12 | when VariableDeclaration 13 | left = statement.declarations.first.id 14 | right = statement.declarations.first.init 15 | when AssignmentExpression 16 | left = statement.left 17 | right = statement.right 18 | when Property 19 | left = statement.key 20 | right = statement.value 21 | end 22 | 23 | return unless ObjectExpression === right 24 | 25 | statement.comments ||= parser.extra_state.comments 26 | handle_default_comments 27 | 28 | obj = register YARD::CodeObjects::ModuleObject.new(namespace, left.source) 29 | parse_block(right.properties, :namespace => obj) 30 | end 31 | end 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /lib/token/token_provider_chain.d.ts: -------------------------------------------------------------------------------- 1 | import {Token} from '../token'; 2 | import {AWSError} from '../error'; 3 | export class TokenProviderChain { 4 | /** 5 | * Creates a new TokenProviderChain with a default set of providers specified by defaultProviders. 6 | */ 7 | constructor(providers?: provider[]) 8 | /** 9 | * Resolves the provider chain by searching for the first set of token in providers. 10 | */ 11 | resolve(callback:(err: AWSError|null, token?: Token) => void): TokenProviderChain; 12 | /** 13 | * Return a Promise on resolve() function 14 | */ 15 | resolvePromise(): Promise; 16 | /** 17 | * Returns a list of token objects or functions that return token objects. If the provider is a function, the function will be executed lazily when the provider needs to be checked for valid token. By default, this object will be set to the defaultProviders. 18 | */ 19 | providers: Array; 20 | 21 | static defaultProviders: provider[] 22 | } 23 | 24 | type provider = () => Token; 25 | -------------------------------------------------------------------------------- /lib/shared-ini/ini-loader.d.ts: -------------------------------------------------------------------------------- 1 | export interface LoadFileOptions { 2 | filename?: string, 3 | isConfig?: boolean, 4 | } 5 | 6 | export interface IniFileContent { 7 | [key: string]: {[key: string]: string} 8 | } 9 | 10 | /** 11 | * Ini file loader class the same as that used in the SDK. It loads and 12 | * parses config and credentials files in .ini format and cache the content 13 | * to assure files are only read once. 14 | * Note that calling operations on the instance instantiated from this class 15 | * won't affect the behavior of SDK since SDK uses an internal singleton of 16 | * this class. 17 | */ 18 | export class IniLoader{ 19 | 20 | /** Remove all cached files. Used after config files are updated. */ 21 | clearCachedFiles():void; 22 | 23 | /** 24 | * Load configurations from config/credentials files and cache them 25 | * for later use. If no file is specified it will try to load default 26 | * files. 27 | * @returns {object} object of all profile information in the file 28 | */ 29 | loadFrom(options: LoadFileOptions): IniFileContent; 30 | } -------------------------------------------------------------------------------- /doc-src/yard-js/samus.json: -------------------------------------------------------------------------------- 1 | { 2 | "actions": [ 3 | { 4 | "action": "fs-sedfiles", 5 | "files": ["lib/*/version.rb"], 6 | "arguments": { 7 | "search": "VERSION = ['\"](.+?)['\"]", 8 | "replace": "VERSION = '$version'" 9 | } 10 | }, 11 | { 12 | "action": "git-commit", 13 | "files": ["lib/*/version.rb"] 14 | }, 15 | { 16 | "action": "git-merge", 17 | "arguments": { 18 | "branch": "master" 19 | } 20 | }, 21 | { 22 | "action": "archive-git-full", 23 | "files": ["git.tgz"], 24 | "publish": [{ 25 | "action": "git-push", 26 | "arguments": { 27 | "remotes": "origin", 28 | "refs": "master v$version" 29 | } 30 | }] 31 | }, 32 | { 33 | "action": "gem-build", 34 | "files": ["*.gemspec"], 35 | "publish": [ 36 | { 37 | "action": "gem-push", 38 | "files": ["*.gem"], 39 | "credentials": "lsegal.rubygems" 40 | } 41 | ] 42 | } 43 | ] 44 | } 45 | -------------------------------------------------------------------------------- /lib/http_response.d.ts: -------------------------------------------------------------------------------- 1 | import * as stream from 'stream'; 2 | interface XMLHttpRequest {} 3 | /** 4 | * The low level HTTP response object, encapsulating all HTTP header and body data returned from the request. 5 | */ 6 | export class HttpResponse { 7 | /** 8 | * Disables buffering on the HTTP response and returns the stream for reading. 9 | */ 10 | createUnbufferedStream(): stream.Readable|XMLHttpRequest 11 | /** 12 | * The response body payload. 13 | */ 14 | body: string|Buffer|Uint8Array; 15 | /** 16 | * A map of response header keys and their respective values. 17 | */ 18 | headers: { 19 | [key: string]: string; 20 | } 21 | /** 22 | * The HTTP status code of the response (e.g., 200, 404). 23 | */ 24 | statusCode: number; 25 | /** 26 | * The HTTP status message of the response (e.g., 'Bad Request', 'Not Found') 27 | */ 28 | statusMessage: string; 29 | /** 30 | * Whether this response is being streamed at a low-level. 31 | */ 32 | streaming: boolean; 33 | } 34 | -------------------------------------------------------------------------------- /doc-src/yard-js/lib/yard-js/core_ext/yard/code_objects.rb: -------------------------------------------------------------------------------- 1 | require 'yard' 2 | 3 | module YARD 4 | module CodeObjects 5 | class Base 6 | alias old_relative_path relative_path 7 | def relative_path(other) 8 | if other.is_a?(NamespaceObject) 9 | other.path 10 | else 11 | old_relative_path(other) 12 | end 13 | end 14 | end 15 | 16 | class NamespaceObject 17 | def properties 18 | children.select {|o| o.type == :property } 19 | end 20 | 21 | def events 22 | children.select {|o| o.type == :event } 23 | end 24 | 25 | def constants(opts = {}) 26 | properties.select {|o| o.has_tag?(:constant) } 27 | end 28 | 29 | def relative_path(other) 30 | if self == other.parent 31 | other.name.to_s 32 | else 33 | other.path 34 | end 35 | end 36 | end 37 | 38 | class ClassObject 39 | def initialize(namespace, name, *args, &block) 40 | super 41 | self.superclass = "Object" 42 | end 43 | end 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /doc-src/yard-js/lib/yard-js/tags.rb: -------------------------------------------------------------------------------- 1 | require 'yard' 2 | 3 | module YARDJS 4 | module Tags 5 | include YARD::Tags 6 | 7 | class CallbackTag < OverloadTag 8 | attr_accessor :param_name 9 | 10 | def initialize(tag_name, text) 11 | name, text = *text.split(" ", 2) 12 | self.param_name = name 13 | super(tag_name, text) 14 | end 15 | end 16 | 17 | class EventDirective < Directive 18 | def call 19 | overload = YARD::Tags::OverloadTag.new(:overload, tag.name) 20 | name = overload.name 21 | ns = YARD::CodeObjects::NamespaceObject === object ? object : handler.namespace 22 | obj = CodeObjects::EventObject.new(ns, name) 23 | ds = YARD::DocstringParser.new 24 | handler.register_group(obj) 25 | obj.parameters = overload.parameters 26 | obj.docstring = ds.parse(tag.text, obj, parser.handler).to_docstring 27 | obj 28 | end 29 | end 30 | 31 | class IgnoreDirective < Directive 32 | def call 33 | handler.extra_state.ignore_next_statement = true 34 | end 35 | end 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /test/endpoint/fips/fips.spec.js: -------------------------------------------------------------------------------- 1 | // IBM Unsupported 2 | // const test_cases = require('./test_cases_supported.json'); 3 | // const helpers = require('../../helpers'); 4 | // const AWS = helpers.AWS; 5 | 6 | // function testApiCall(input, done) { 7 | // const { clientName, region, hostname } = input; 8 | 9 | // if (!AWS[clientName]) { 10 | // throw new Error(`${clientName} does not exist`); 11 | // } 12 | 13 | // const client = new AWS[clientName]({ region }); 14 | 15 | // const req = client[Object.keys(client.api.operations)[0]](); 16 | // req.on('complete', function() { 17 | // expect(hostname).to.equal(req.httpRequest.endpoint.host); 18 | // done(); 19 | // }); 20 | 21 | // req.send(function() {}); 22 | // }; 23 | 24 | // describe('endpoints.fips', function() { 25 | // beforeEach(function () { 26 | // helpers.mockResponse({ 27 | // data: {} 28 | // }); 29 | // }); 30 | 31 | // for (const test_case of test_cases) { 32 | // it(`testing ${test_case.clientName} with region: ${test_case.region}`, function(done) { 33 | // testApiCall(test_case, done); 34 | // }); 35 | // } 36 | // }); 37 | -------------------------------------------------------------------------------- /lib/credentials/credential_provider_chain.d.ts: -------------------------------------------------------------------------------- 1 | import {Credentials} from '../credentials'; 2 | import {AWSError} from '../error'; 3 | export class CredentialProviderChain { 4 | /** 5 | * Creates a new CredentialProviderChain with a default set of providers specified by defaultProviders. 6 | */ 7 | constructor(providers?: provider[]) 8 | /** 9 | * Resolves the provider chain by searching for the first set of credentials in providers. 10 | */ 11 | resolve(callback:(err: AWSError|null, credentials?: Credentials) => void): CredentialProviderChain; 12 | /** 13 | * Return a Promise on resolve() function 14 | */ 15 | resolvePromise(): Promise; 16 | /** 17 | * Returns a list of credentials objects or functions that return credentials objects. If the provider is a function, the function will be executed lazily when the provider needs to be checked for valid credentials. By default, this object will be set to the defaultProviders. 18 | */ 19 | providers: Array; 20 | 21 | static defaultProviders: provider[] 22 | } 23 | 24 | type provider = () => Credentials; 25 | -------------------------------------------------------------------------------- /doc-src/yard-js/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2007-2013 Loren Segal 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /test/browser/jasmine-2.0.0/MIT.LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2008-2011 Pivotal Labs 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /test/endpoint/index.spec.js: -------------------------------------------------------------------------------- 1 | const testCases = require('./test_cases_supported.json'); 2 | const helpers = require('../helpers'); 3 | const AWS = helpers.AWS; 4 | 5 | describe('endpoints', () => { 6 | beforeEach(function () { 7 | helpers.mockResponse({ 8 | data: {}, 9 | }); 10 | }); 11 | 12 | for (const { 13 | clientName, 14 | region, 15 | // IBM Unsupported 16 | // useFipsEndpoint, 17 | useDualstackEndpoint, 18 | hostname, 19 | } of testCases) { 20 | it(`testing "${clientName}" with region: ${region}`, (done) => { 21 | if (!AWS[clientName]) { 22 | throw new Error(`${clientName} does not exist`); 23 | } 24 | 25 | const client = new AWS[clientName]({ 26 | region, 27 | // IBM Unsupported 28 | // useFipsEndpoint, 29 | useDualstackEndpoint, 30 | hostPrefixEnabled: false 31 | }); 32 | 33 | const req = client[Object.keys(client.api.operations)[0]](); 34 | 35 | req.on('complete', function () { 36 | expect(hostname).to.equal(req.httpRequest.endpoint.host); 37 | done(); 38 | }); 39 | 40 | req.send(function () {}); 41 | }); 42 | } 43 | }); 44 | -------------------------------------------------------------------------------- /doc-src/yard-js/lib/yard-js/plugin.rb: -------------------------------------------------------------------------------- 1 | require_relative 'core_ext/yard' 2 | require_relative 'code_objects' 3 | require_relative 'handlers' 4 | require_relative 'tags' 5 | require_relative 'parser' 6 | 7 | YARD::Parser::SourceParser.register_parser_type(:js, YARDJS::Parser::JavaScriptParser, ['js']) 8 | YARD::Handlers::Processor.register_handler_namespace(:js, YARDJS::Handlers) 9 | 10 | YARD::Templates::Engine.register_template_path(File.dirname(__FILE__) + '/../../templates') 11 | 12 | [:readonly, :writeonly, :static].each do |tag| 13 | YARD::Tags::Library.define_tag(tag.to_s.capitalize, tag) 14 | end 15 | YARD::Tags::Library.define_tag 'Default Value', :default, :with_name 16 | YARD::Tags::Library.define_tag 'Default Value', :value 17 | YARD::Tags::Library.define_tag 'Constant', :constant 18 | YARD::Tags::Library.define_tag 'Context (this)', :context, :with_types 19 | YARD::Tags::Library.define_tag 'Callback', :callback, YARDJS::Tags::CallbackTag 20 | YARD::Tags::Library.visible_tags.unshift(:value, :context) 21 | 22 | YARD::Tags::Library.define_directive(:ignore, YARDJS::Tags::IgnoreDirective) 23 | YARD::Tags::Library.define_directive(:event, :with_title_and_text, YARDJS::Tags::EventDirective) 24 | -------------------------------------------------------------------------------- /lib/browserCryptoLib.js: -------------------------------------------------------------------------------- 1 | var Hmac = require('./browserHmac'); 2 | var Md5 = require('./browserMd5'); 3 | var Sha1 = require('./browserSha1'); 4 | var Sha256 = require('./browserSha256'); 5 | 6 | /** 7 | * @api private 8 | */ 9 | module.exports = exports = { 10 | createHash: function createHash(alg) { 11 | alg = alg.toLowerCase(); 12 | if (alg === 'md5') { 13 | return new Md5(); 14 | } else if (alg === 'sha256') { 15 | return new Sha256(); 16 | } else if (alg === 'sha1') { 17 | return new Sha1(); 18 | } 19 | 20 | throw new Error('Hash algorithm ' + alg + ' is not supported in the browser SDK'); 21 | }, 22 | createHmac: function createHmac(alg, key) { 23 | alg = alg.toLowerCase(); 24 | if (alg === 'md5') { 25 | return new Hmac(Md5, key); 26 | } else if (alg === 'sha256') { 27 | return new Hmac(Sha256, key); 28 | } else if (alg === 'sha1') { 29 | return new Hmac(Sha1, key); 30 | } 31 | 32 | throw new Error('HMAC algorithm ' + alg + ' is not supported in the browser SDK'); 33 | }, 34 | createSign: function() { 35 | throw new Error('createSign is not implemented in the browser'); 36 | } 37 | }; 38 | -------------------------------------------------------------------------------- /lib/signers/request_signer.js: -------------------------------------------------------------------------------- 1 | var AWS = require('../core'); 2 | 3 | var inherit = AWS.util.inherit; 4 | 5 | /** 6 | * @api private 7 | */ 8 | AWS.Signers.RequestSigner = inherit({ 9 | constructor: function RequestSigner(request) { 10 | this.request = request; 11 | }, 12 | 13 | setServiceClientId: function setServiceClientId(id) { 14 | this.serviceClientId = id; 15 | }, 16 | 17 | getServiceClientId: function getServiceClientId() { 18 | return this.serviceClientId; 19 | } 20 | }); 21 | 22 | AWS.Signers.RequestSigner.getVersion = function getVersion(version) { 23 | switch (version) { 24 | case 'v2': return AWS.Signers.V2; 25 | case 'v3': return AWS.Signers.V3; 26 | case 's3v4': return AWS.Signers.V4; 27 | case 'v4': return AWS.Signers.V4; 28 | case 's3': return AWS.Signers.S3; 29 | case 'v3https': return AWS.Signers.V3Https; 30 | case 'iam': return AWS.Signers.IAM; 31 | case 'none': return AWS.Signers.None; 32 | case 'bearer': return AWS.Signers.Bearer; 33 | } 34 | throw new Error('Unknown signing version ' + version); 35 | }; 36 | 37 | require('./v2'); 38 | require('./v3'); 39 | require('./v3https'); 40 | require('./v4'); 41 | require('./s3'); 42 | require('./presign'); 43 | require('./iam'); 44 | require('./none'); 45 | require('./bearer'); 46 | -------------------------------------------------------------------------------- /lib/core.d.ts: -------------------------------------------------------------------------------- 1 | export {AnonymousCredentials} from './credentials/anonymous_credentials'; 2 | export {Config} from './config'; 3 | export {HTTPOptions, ConfigurationOptions} from './config-base'; 4 | export {Credentials} from './credentials'; 5 | export {CredentialProviderChain} from './credentials/credential_provider_chain'; 6 | export {EnvironmentCredentials} from './credentials/environment_credentials'; 7 | export {FileSystemCredentials} from './credentials/file_system_credentials'; 8 | export {SharedJSONFileCredentials} from './credentials/shared_json_file_credentials'; 9 | export {SharedIniFileCredentials} from './credentials/shared_ini_file_credentials'; 10 | export {Token} from './token'; 11 | export {StaticTokenProvider} from './token/static_token_provider'; 12 | export {TokenProviderChain} from './token/token_provider_chain'; 13 | export {Endpoint} from './endpoint'; 14 | export {EventListeners} from './event_listeners'; 15 | export {HttpRequest} from './http_request'; 16 | export {HttpResponse} from './http_response'; 17 | export {MetadataService} from './metadata_service'; 18 | export {Request} from './request'; 19 | export {Response} from './response'; 20 | export {Service} from './service'; 21 | export {AWSError} from './error'; 22 | export {IniLoader} from './shared-ini/ini-loader'; 23 | export {DocumentType} from './model'; 24 | -------------------------------------------------------------------------------- /dist-tools/transform.js: -------------------------------------------------------------------------------- 1 | var Transform = require('stream').Transform; 2 | var collector = require('./service-collector'); 3 | var license = require('./browser-builder').license; 4 | 5 | module.exports = function(file) { 6 | var stream = new Transform(); 7 | 8 | var didDefineServices = !!process.env.AWS_SERVICES; 9 | 10 | var isEntryPoint = !!file.match(/[\/\\]lib[\/\\]browser\.js$/); 11 | 12 | stream._transform = function(data, encoding, callback) { 13 | callback(null, data); 14 | }; 15 | 16 | if (isEntryPoint) { 17 | if (didDefineServices) { 18 | // We need to strip out the default requires statement 19 | stream._transform = function(data, encoding, callback) { 20 | var code = data.toString(); 21 | code = code.trim(); 22 | var lines = code.split('\n'); 23 | lines = lines.filter(function(line) { 24 | return !line.match(/^require\(.+browser_default['"]\);$/); 25 | }); 26 | 27 | code = lines.join('\n'); 28 | data = Buffer.from(code); 29 | callback(null, data); 30 | }; 31 | 32 | var src = collector(process.env.AWS_SERVICES); 33 | stream._flush = function(callback) { 34 | stream.push(src); 35 | callback(); 36 | }; 37 | } 38 | 39 | stream.push(license); 40 | } 41 | 42 | return stream; 43 | }; 44 | -------------------------------------------------------------------------------- /lib/response.d.ts: -------------------------------------------------------------------------------- 1 | import {HttpResponse} from './http_response'; 2 | import {Request} from './request'; 3 | export class Response { 4 | /** 5 | * Whether more pages of data can be returned by further requests. 6 | */ 7 | hasNextPage(): boolean; 8 | /** 9 | * Creates a new request for the next page of response data, calling the callback with the page data if a callback is provided. 10 | */ 11 | nextPage(callback?: (err: E, data: D) => void): Request|void; 12 | /** 13 | * The de-serialized response data from the service. 14 | * Can be null if an error occurred. 15 | */ 16 | data: D|void 17 | /** 18 | * A structure containing information about a service or networking error. 19 | */ 20 | error: E|void 21 | /** 22 | * Returns the unique request ID associated with the response. 23 | * Log this value when debugging requests for AWS support. 24 | */ 25 | requestId: string 26 | /** 27 | * The number of redirects that were followed before the request was completed. 28 | */ 29 | redirectCount: number 30 | /** 31 | * The number of retries that were attempted before the request was completed. 32 | */ 33 | retryCount: number 34 | /** 35 | * The raw HTTP response object containing the response headers and body information from the server. 36 | */ 37 | httpResponse: HttpResponse; 38 | } 39 | -------------------------------------------------------------------------------- /scripts/lib/visit-related-shape-names.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * 4 | * @param {string} startingShape 5 | * @param {{[key: string]: any}} shapeMap 6 | */ 7 | function visitRelatedShapeNames(startingShape, shapeMap) { 8 | var shape = shapeMap[startingShape]; 9 | if (shape.visited) { 10 | // exit early if the shape has been visited 11 | return; 12 | } 13 | 14 | shape.visited = true; 15 | 16 | if (['structure', 'map', 'list'].indexOf(shape.type) < 0) { 17 | // not a complex shape, so it's a terminal shape 18 | return; 19 | } 20 | 21 | if (shape.type === 'structure') { 22 | var members = shape.members; 23 | for (var memberName of Object.keys(members)) { 24 | var memberShapeName = members[memberName].shape; 25 | visitRelatedShapeNames(memberShapeName, shapeMap); 26 | } 27 | } else if (shape.type === 'map') { 28 | var keyShape = shape.key.shape; 29 | var valueShape = shape.value.shape; 30 | visitRelatedShapeNames(keyShape, shapeMap); 31 | visitRelatedShapeNames(valueShape, shapeMap); 32 | } else if (shape.type === 'list') { 33 | var memberShape = shape.member.shape; 34 | visitRelatedShapeNames(memberShape, shapeMap); 35 | } 36 | } 37 | 38 | module.exports = { 39 | visitRelatedShapeNames: visitRelatedShapeNames 40 | }; -------------------------------------------------------------------------------- /ts/request.ts: -------------------------------------------------------------------------------- 1 | import AWS = require('../index'); 2 | 3 | // create request without optional params 4 | var request: AWS.Request<{content: string}, Error> = new AWS.Request(new AWS.Service(), 'operation'); 5 | // create request with params 6 | request = new AWS.Request(new AWS.Service(), 'operation', {}); 7 | 8 | //test request.send with callback 9 | request.send(function(err, data) { 10 | if (err) { 11 | console.log(err.stack); 12 | } else { 13 | console.log(data.content); 14 | } 15 | }); 16 | 17 | // test request event listeners 18 | request.on('error', function(err, response) { 19 | 20 | }); 21 | request.on('build', function(request) { 22 | // test body as string 23 | request.httpRequest.body = 'Hello' 24 | // test body as buffer 25 | request.httpRequest.body = Buffer.from('Hello') 26 | 27 | console.log(request.httpRequest.method); 28 | }); 29 | request.on('complete', function(response) { 30 | if (response.error) { 31 | console.log(response.error.message); 32 | } else if (response.data) { 33 | response.data.content; 34 | } 35 | }); 36 | 37 | // test promises 38 | request.promise().then( 39 | data => { 40 | console.log(data.content); 41 | console.log(data.$response.requestId); 42 | console.log(data.$response.hasNextPage()); 43 | }, 44 | error => { 45 | console.error(error); 46 | } 47 | ); 48 | -------------------------------------------------------------------------------- /features/s3/step_definitions/proxy.js: -------------------------------------------------------------------------------- 1 | var url = require('url'); 2 | var http = require('http'); 3 | 4 | module.exports = function() { 5 | this.Before('@s3', '@proxy', function(callback) { 6 | setupProxyServer.call(this); 7 | 8 | this.service = this.s3 = new this.AWS.S3({ 9 | httpOptions: { proxy: 'http://localhost:' + this.proxyPort } 10 | }); 11 | 12 | callback(); 13 | }); 14 | 15 | this.Then(/^I teardown the local proxy server$/, function(callback) { 16 | this.service = this.s3 = new this.AWS.S3(); 17 | this.proxyServer.close(callback); 18 | }); 19 | 20 | function setupProxyServer() { 21 | if (this.proxyServer) return; 22 | this.proxyPort = 8000 + parseInt(Math.random() * 100); 23 | this.proxyServer = http.createServer(function (req, res) { 24 | var uri = url.parse(req.url); 25 | var options = { 26 | host: uri.hostname, 27 | port: uri.port || 80, 28 | method: req.method, 29 | path: uri.path, 30 | headers: req.headers 31 | }; 32 | options.headers.host = uri.hostname; 33 | 34 | var s = http.request(options, function (res2) { 35 | res.writeHead(res2.statusCode, res2.headers); 36 | res2.on('data', function(ch) { 37 | res.write(ch); 38 | }).on('end', function() { res.end(); }); 39 | }); 40 | req.pipe(s); 41 | }); 42 | this.proxyServer.listen(this.proxyPort); 43 | } 44 | }; 45 | -------------------------------------------------------------------------------- /test/mocks/shaky-stream.js: -------------------------------------------------------------------------------- 1 | var stream = require('stream'); 2 | var util = require('util'); 3 | var toBuffer = require('../helpers').AWS.util.buffer.toBuffer; 4 | 5 | var Readable = stream.Readable; 6 | 7 | var timeoutFn = typeof setTimeoutOrig === 'function' ? setTimeoutOrig : setTimeout; 8 | 9 | /** 10 | * ShakyStream will send data in 2 parts, pausing between parts. 11 | */ 12 | function ShakyStream(options) { 13 | if (!(this instanceof ShakyStream)) { 14 | return new ShakyStream(options); 15 | } 16 | if (!options.highWaterMark) { 17 | options.highWaterMark = 1024 * 16; 18 | } 19 | this._shakyTime = options.pauseFor; 20 | this._didStart = false; 21 | this._isPaused = false; 22 | 23 | Readable.call(this, options); 24 | 25 | } 26 | 27 | util.inherits(ShakyStream, Readable); 28 | 29 | ShakyStream.prototype._read = function _read(size) { 30 | if (!this._didStart) { 31 | this._didStart = true; 32 | this.push(toBuffer('{"Count":1,"Items":[{"id":{"S":"2016-12-11"},"dateUTC":{"N":"1481494545591"},')); 33 | } 34 | if (this._didStart && this._isPaused) { 35 | return; 36 | } else if (this._didStart) { 37 | this._isPaused = true; 38 | var self = this; 39 | timeoutFn(function() { 40 | self.push(toBuffer('"javascript":{"M":{"foo":{"S":"bar"},"baz":{"S":"buz"}}}}],"ScannedCount":1}')); 41 | self.push(null); 42 | }, this._shakyTime); 43 | } 44 | }; 45 | 46 | module.exports = ShakyStream; 47 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # This is an example configuration to enable detect-secrets in the pre-commit hook. 2 | # Add this file to the root folder of your repository. 3 | # 4 | # Read pre-commit hook framework https://pre-commit.com/ for more details about the structure of config yaml file and how git pre-commit would invoke each hook. 5 | # 6 | # This line indicates we will use the hook from ibm/detect-secrets to run scan during committing phase. 7 | repos: 8 | - repo: https://github.com/ibm/detect-secrets 9 | # If you desire to use a specific version of detect-secrets, you can replace `master` with other git revisions such as branch, tag or commit sha. 10 | # You are encouraged to use static refs such as tags, instead of branch name 11 | # 12 | # Running "pre-commit autoupdate" automatically updates rev to latest tag 13 | rev: 0.13.1+ibm.61.dss 14 | hooks: 15 | - id: detect-secrets # pragma: whitelist secret 16 | # Add options for detect-secrets-hook binary. You can run `detect-secrets-hook --help` to list out all possible options. 17 | # You may also run `pre-commit run detect-secrets` to preview the scan result. 18 | # when "--baseline" without "--use-all-plugins", pre-commit scan with just plugins in baseline file 19 | # when "--baseline" with "--use-all-plugins", pre-commit scan with all available plugins 20 | # add "--fail-on-unaudited" to fail pre-commit for unaudited potential secrets 21 | args: [--baseline, .secrets.baseline, --use-all-plugins] 22 | -------------------------------------------------------------------------------- /lib/signers/v2.js: -------------------------------------------------------------------------------- 1 | var AWS = require('../core'); 2 | var inherit = AWS.util.inherit; 3 | 4 | /** 5 | * @api private 6 | */ 7 | AWS.Signers.V2 = inherit(AWS.Signers.RequestSigner, { 8 | addAuthorization: function addAuthorization(credentials, date) { 9 | 10 | if (!date) date = AWS.util.date.getDate(); 11 | 12 | var r = this.request; 13 | 14 | r.params.Timestamp = AWS.util.date.iso8601(date); 15 | r.params.SignatureVersion = '2'; 16 | r.params.SignatureMethod = 'HmacSHA256'; 17 | r.params.AWSAccessKeyId = credentials.accessKeyId; 18 | 19 | if (credentials.sessionToken) { 20 | r.params.SecurityToken = credentials.sessionToken; 21 | } 22 | 23 | delete r.params.Signature; // delete old Signature for re-signing 24 | r.params.Signature = this.signature(credentials); 25 | 26 | r.body = AWS.util.queryParamsToString(r.params); 27 | r.headers['Content-Length'] = r.body.length; 28 | }, 29 | 30 | signature: function signature(credentials) { 31 | return AWS.util.crypto.hmac(credentials.secretAccessKey, this.stringToSign(), 'base64'); 32 | }, 33 | 34 | stringToSign: function stringToSign() { 35 | var parts = []; 36 | parts.push(this.request.method); 37 | parts.push(this.request.endpoint.host.toLowerCase()); 38 | parts.push(this.request.pathname()); 39 | parts.push(AWS.util.queryParamsToString(this.request.params)); 40 | return parts.join('\n'); 41 | } 42 | 43 | }); 44 | 45 | /** 46 | * @api private 47 | */ 48 | module.exports = AWS.Signers.V2; 49 | -------------------------------------------------------------------------------- /doc-src/yard-js/lib/yard-js/handlers/class_handler.rb: -------------------------------------------------------------------------------- 1 | require_relative 'base' 2 | 3 | module YARDJS 4 | module Handlers 5 | class ClassHandler < Base 6 | handles AssignmentExpression 7 | handles Property 8 | 9 | process do 10 | statement.comments ||= parser.extra_state.comments 11 | handle_default_comments 12 | 13 | if statement.is_a?(AssignmentExpression) 14 | left, right = statement.left, statement.right 15 | else 16 | left, right = statement.key, statement.value 17 | end 18 | 19 | return unless right.is_a?(CallExpression) && 20 | right.callee.source =~ YARDJS.options.define_class_expression 21 | 22 | obj = register YARD::CodeObjects::ClassObject.new(namespace, left.source) 23 | obj.superclass = right.args.first.source if right.args.size > 1 24 | 25 | defs = right.args.last.properties 26 | parse_block(defs, :namespace => obj) 27 | end 28 | end 29 | 30 | class UpdateClassHandler < Base 31 | handles CallExpression 32 | 33 | process do 34 | return unless statement.callee.source =~ 35 | YARDJS.options.update_class_expression 36 | 37 | ns = P(statement.args.first.source.gsub(/\.prototype/, '')) 38 | ensure_loaded!(ns) 39 | 40 | statement.comments ||= parser.extra_state.comments 41 | register(ns) if statement.comments && statement.comments.size > 0 42 | 43 | parse_block(statement.args.last.properties, :namespace => ns) 44 | end 45 | end 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /lib/xml/xml-node.js: -------------------------------------------------------------------------------- 1 | var escapeAttribute = require('./escape-attribute').escapeAttribute; 2 | 3 | /** 4 | * Represents an XML node. 5 | * @api private 6 | */ 7 | function XmlNode(name, children) { 8 | if (children === void 0) { children = []; } 9 | this.name = name; 10 | this.children = children; 11 | this.attributes = {}; 12 | } 13 | XmlNode.prototype.addAttribute = function (name, value) { 14 | this.attributes[name] = value; 15 | return this; 16 | }; 17 | XmlNode.prototype.addChildNode = function (child) { 18 | this.children.push(child); 19 | return this; 20 | }; 21 | XmlNode.prototype.removeAttribute = function (name) { 22 | delete this.attributes[name]; 23 | return this; 24 | }; 25 | XmlNode.prototype.toString = function () { 26 | var hasChildren = Boolean(this.children.length); 27 | var xmlText = '<' + this.name; 28 | // add attributes 29 | var attributes = this.attributes; 30 | for (var i = 0, attributeNames = Object.keys(attributes); i < attributeNames.length; i++) { 31 | var attributeName = attributeNames[i]; 32 | var attribute = attributes[attributeName]; 33 | if (typeof attribute !== 'undefined' && attribute !== null) { 34 | xmlText += ' ' + attributeName + '=\"' + escapeAttribute('' + attribute) + '\"'; 35 | } 36 | } 37 | return xmlText += !hasChildren ? '/>' : '>' + this.children.map(function (c) { return c.toString(); }).join('') + ''; 38 | }; 39 | 40 | /** 41 | * @api private 42 | */ 43 | module.exports = { 44 | XmlNode: XmlNode 45 | }; 46 | -------------------------------------------------------------------------------- /doc-src/yard-js/lib/yard-js/handlers/constant_handler.rb: -------------------------------------------------------------------------------- 1 | require_relative 'base' 2 | 3 | module YARDJS 4 | module Handlers 5 | class ConstantHandler < Base 6 | handles AssignmentExpression 7 | handles Property 8 | 9 | process do 10 | if statement.is_a?(AssignmentExpression) 11 | name, value = statement.left.source, statement.right 12 | else 13 | name, value = statement.key.val, statement.value 14 | end 15 | 16 | return if value.is_a?(FunctionExpression) 17 | return if value.is_a?(ObjectExpression) 18 | return if value.is_a?(CallExpression) 19 | 20 | handle_default_comments 21 | 22 | obj = register CodeObjects::PropertyObject.new(namespace, name) 23 | if value.is_a?(Literal) 24 | obj.property_type = :literal 25 | if type = parse_type(value.val) 26 | obj.docstring.add_tag(YARD::Tags::Tag.new(:return, '', [type])) 27 | end 28 | else 29 | obj.property_type = :object 30 | end 31 | 32 | unless obj.has_tag?(:value) 33 | obj.docstring.add_tag(YARD::Tags::Tag.new(:value, value.source)) 34 | end 35 | 36 | unless obj.has_tag?(:static) 37 | obj.docstring.add_tag(YARD::Tags::Tag.new(:static, '')) 38 | end 39 | end 40 | 41 | def parse_type(type) 42 | case type 43 | when Node; type.class.to_s[/::([^:]+)$/, 1] 44 | when FalseClass, TrueClass; 'Boolean' 45 | when NilClass; 'null' 46 | end 47 | end 48 | end 49 | end 50 | end 51 | -------------------------------------------------------------------------------- /lib/state_machine.js: -------------------------------------------------------------------------------- 1 | function AcceptorStateMachine(states, state) { 2 | this.currentState = state || null; 3 | this.states = states || {}; 4 | } 5 | 6 | AcceptorStateMachine.prototype.runTo = function runTo(finalState, done, bindObject, inputError) { 7 | if (typeof finalState === 'function') { 8 | inputError = bindObject; bindObject = done; 9 | done = finalState; finalState = null; 10 | } 11 | 12 | var self = this; 13 | var state = self.states[self.currentState]; 14 | state.fn.call(bindObject || self, inputError, function(err) { 15 | if (err) { 16 | if (state.fail) self.currentState = state.fail; 17 | else return done ? done.call(bindObject, err) : null; 18 | } else { 19 | if (state.accept) self.currentState = state.accept; 20 | else return done ? done.call(bindObject) : null; 21 | } 22 | if (self.currentState === finalState) { 23 | return done ? done.call(bindObject, err) : null; 24 | } 25 | 26 | self.runTo(finalState, done, bindObject, err); 27 | }); 28 | }; 29 | 30 | AcceptorStateMachine.prototype.addState = function addState(name, acceptState, failState, fn) { 31 | if (typeof acceptState === 'function') { 32 | fn = acceptState; acceptState = null; failState = null; 33 | } else if (typeof failState === 'function') { 34 | fn = failState; failState = null; 35 | } 36 | 37 | if (!this.currentState) this.currentState = name; 38 | this.states[name] = { accept: acceptState, fail: failState, fn: fn }; 39 | return this; 40 | }; 41 | 42 | /** 43 | * @api private 44 | */ 45 | module.exports = AcceptorStateMachine; 46 | -------------------------------------------------------------------------------- /test/s3/s3_param.spec.js: -------------------------------------------------------------------------------- 1 | var helpers = require('../helpers'); 2 | var AWS = helpers.AWS; 3 | 4 | describe('AWS.S3.Parameters', function () { 5 | describe('extended listing', function () { 6 | var extendedListingMockResponseBasic = { 7 | IsTruncated: false, 8 | Buckets: [ 9 | { 10 | Name: 'bucketnamefoo', 11 | CreationDate: new Date(2015, 1, 1).toUTCString(), 12 | LocationConstraint: 'bar-standard' 13 | } 14 | ], 15 | Owner: { 16 | DisplayName: 'ownerfoo', 17 | ID: 'idfoo' 18 | } 19 | }; 20 | 21 | it('should add ?extended to path', function (done) { 22 | var service = new AWS.S3({ 23 | accessKeyId: 'aki', 24 | secretAccessKey: 'sac', 25 | serviceInstanceId: 'sid' 26 | }); 27 | helpers.mockResponse(extendedListingMockResponseBasic); 28 | 29 | var request = service.listBucketsExtended(); 30 | request.send(function (err) { 31 | if (err) { 32 | done(err); 33 | } else { 34 | var response = this; 35 | expect(request.httpRequest.method).to.eq('GET'); 36 | expect(request.httpRequest.path).to.eq('/?extended'); 37 | expect(response.Buckets).to.have.length(1); 38 | done(); 39 | } 40 | }); 41 | }); 42 | }); 43 | }); 44 | -------------------------------------------------------------------------------- /doc-src/yard-js/lib/yard-js/core_ext/yard/tags.rb: -------------------------------------------------------------------------------- 1 | module YARD 2 | module Tags 3 | class MethodDirective 4 | def method_name 5 | sig = sanitized_tag_signature 6 | if sig 7 | sig[/\A\s*([^\(; \t]+)/, 1] 8 | else 9 | handler.call_params.first 10 | end 11 | end 12 | 13 | def create_object 14 | name = method_name 15 | visibility = parser.state.visibility || handler.visibility 16 | ns = CodeObjects::NamespaceObject === object ? object : handler.namespace 17 | obj = YARDJS::CodeObjects::PropertyObject.new(ns, name) 18 | handler.register_file_info(obj) 19 | handler.register_source(obj) 20 | handler.register_visibility(obj, visibility) 21 | handler.register_group(obj) 22 | obj.signature = method_signature 23 | obj.parameters = OverloadTag.new(:overload, method_signature).parameters 24 | obj.docstring = Docstring.new!(parser.text, parser.tags, obj, 25 | parser.raw_text) 26 | obj.property_type = :function 27 | handler.register_module_function(obj) 28 | obj 29 | end 30 | end 31 | 32 | class AttributeDirective 33 | def method_name 34 | sanitized_tag_signature || handler.call_params.first 35 | end 36 | 37 | def method_signature; method_name end 38 | 39 | def create_attribute_data(object) 40 | if object.tag(:constant) 41 | object.property_type = :literal 42 | else 43 | object.property_type = :object 44 | end 45 | end 46 | end 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /lib/error.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * A structure containing information about a service or networking error. 3 | */ 4 | export type AWSError = Error & { 5 | /** 6 | * A unique short code representing the error that was emitted. 7 | */ 8 | code: string; 9 | /** 10 | * A longer human readable error message. 11 | */ 12 | message: string; 13 | /** 14 | * Whether the error message is retryable. 15 | */ 16 | retryable?: boolean; 17 | /** 18 | * In the case of a request that reached the service, this value contains the response status code. 19 | */ 20 | statusCode?: number; 21 | /** 22 | * The date time object when the error occurred. 23 | */ 24 | time: Date; 25 | /** 26 | * Set when a networking error occurs to easily identify the endpoint of the request. 27 | */ 28 | hostname?: string; 29 | /** 30 | * Set when a networking error occurs to easily identify the region of the request. 31 | */ 32 | region?: string; 33 | /** 34 | * Amount of time (in seconds) that the request waited before being resent. 35 | */ 36 | retryDelay?: number; 37 | /** 38 | * The unique request ID associated with the response. 39 | */ 40 | requestId?: string; 41 | /** 42 | * Second request ID associated with the response from S3. 43 | */ 44 | extendedRequestId?: string; 45 | /** 46 | * CloudFront request ID associated with the response. 47 | */ 48 | cfId?: string; 49 | /** 50 | * The original error which caused this Error 51 | */ 52 | originalError?: Error 53 | } 54 | -------------------------------------------------------------------------------- /lib/browserHashUtils.js: -------------------------------------------------------------------------------- 1 | var Buffer = require('buffer/').Buffer; 2 | 3 | /** 4 | * This is a polyfill for the static method `isView` of `ArrayBuffer`, which is 5 | * e.g. missing in IE 10. 6 | * 7 | * @api private 8 | */ 9 | if ( 10 | typeof ArrayBuffer !== 'undefined' && 11 | typeof ArrayBuffer.isView === 'undefined' 12 | ) { 13 | ArrayBuffer.isView = function(arg) { 14 | return viewStrings.indexOf(Object.prototype.toString.call(arg)) > -1; 15 | }; 16 | } 17 | 18 | /** 19 | * @api private 20 | */ 21 | var viewStrings = [ 22 | '[object Int8Array]', 23 | '[object Uint8Array]', 24 | '[object Uint8ClampedArray]', 25 | '[object Int16Array]', 26 | '[object Uint16Array]', 27 | '[object Int32Array]', 28 | '[object Uint32Array]', 29 | '[object Float32Array]', 30 | '[object Float64Array]', 31 | '[object DataView]', 32 | ]; 33 | 34 | /** 35 | * @api private 36 | */ 37 | function isEmptyData(data) { 38 | if (typeof data === 'string') { 39 | return data.length === 0; 40 | } 41 | return data.byteLength === 0; 42 | } 43 | 44 | /** 45 | * @api private 46 | */ 47 | function convertToBuffer(data) { 48 | if (typeof data === 'string') { 49 | data = new Buffer(data, 'utf8'); 50 | } 51 | 52 | if (ArrayBuffer.isView(data)) { 53 | return new Uint8Array(data.buffer, data.byteOffset, data.byteLength / Uint8Array.BYTES_PER_ELEMENT); 54 | } 55 | 56 | return new Uint8Array(data); 57 | } 58 | 59 | /** 60 | * @api private 61 | */ 62 | module.exports = exports = { 63 | isEmptyData: isEmptyData, 64 | convertToBuffer: convertToBuffer, 65 | }; 66 | -------------------------------------------------------------------------------- /lib/event_listeners.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The namespace used to register global event listeners for request building and sending. 3 | */ 4 | export namespace EventListeners { 5 | /** 6 | * The namespace used to register global event listeners for request building and sending. 7 | */ 8 | export namespace Core { 9 | /** 10 | * Removes an event listener from all requests. 11 | */ 12 | export function removeListener(eventName: string, eventListener: Function): void; 13 | /** 14 | * A request listener that reads data from the HTTP connection in order to build the response data. Handles the 'httpData' Request event. 15 | * Remove this handler if you are overriding the 'httpData' event and do not want extra data processing and buffering overhead. 16 | */ 17 | export function HTTP_DATA(): void; 18 | /** 19 | * A request listener that initiates the HTTP connection for a request being sent. Handles the 'send' Request event. 20 | */ 21 | export function SEND(): void; 22 | /** 23 | * A request listener that validates whether the request is being sent with credentials. Handles the 'validate' Request event 24 | */ 25 | export function VALIDATE_CREDENTIALS(): void; 26 | /** 27 | * A request listener that validates input parameters in a request. Handles the 'validate' Request event. 28 | */ 29 | export function VALIDATE_PARAMETERS(): void; 30 | /** 31 | * A request listener that validates whether the region is set for a request. Handles the 'validate' Request event. 32 | */ 33 | export function VALIDATE_REGION():void; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /doc-src/templates/api-versions/templates/default/module/html/box_info.erb: -------------------------------------------------------------------------------- 1 |
    2 | <% if CodeObjects::ClassObject === object && object.superclass %> 3 |
    4 |
    Inherits:
    5 |
    6 | <%= linkify object.superclass %> 7 | <% if object.superclass.name != :BasicObject %> 8 |
      9 |
    • <%= linkify P(:Object) %>
    • 10 | <% object.inheritance_tree.reverse.each_with_index do |obj, i| %> 11 | 12 | <% end %> 13 |
    14 | show all 15 | <% end %> 16 |
    17 |
    18 | <% end %> 19 | 20 | <% [[:class, "Extended by"], [:instance, "Includes"]].each do |scope, name| %> 21 | <% if (mix = run_verifier(object.mixins(scope))).size > 0 %> 22 |
    23 |
    <%= name %>:
    24 |
    <%= mix.sort_by {|o| o.path }.map {|o| linkify(o) }.join(", ") %>
    25 |
    26 | <% end %> 27 | <% end %> 28 | 29 | <% if (mixed_into = mixed_into(object)).size > 0 %> 30 |
    31 |
    Included in:
    32 |
    <%= mixed_into.sort_by {|o| o.path }.map {|o| linkify(o) }.join(", ") %>
    33 |
    34 | <% end %> 35 | 36 | <% if object.has_tag?(:service) %> 37 |
    38 |
    Identifier:
    39 |
    <%= object.tag(:service).text %>
    40 |
    41 |
    42 |
    API Version:
    43 |
    <%= object.tag(:version).text %>
    44 |
    45 | <% end %> 46 | 47 | <% unless object.root? %> 48 |
    49 |
    Defined in:
    50 |
    <%= erb(:defines) %>
    51 |
    52 | <% end %> 53 |
    54 | -------------------------------------------------------------------------------- /lib/browserHmac.js: -------------------------------------------------------------------------------- 1 | var hashUtils = require('./browserHashUtils'); 2 | 3 | /** 4 | * @api private 5 | */ 6 | function Hmac(hashCtor, secret) { 7 | this.hash = new hashCtor(); 8 | this.outer = new hashCtor(); 9 | 10 | var inner = bufferFromSecret(hashCtor, secret); 11 | var outer = new Uint8Array(hashCtor.BLOCK_SIZE); 12 | outer.set(inner); 13 | 14 | for (var i = 0; i < hashCtor.BLOCK_SIZE; i++) { 15 | inner[i] ^= 0x36; 16 | outer[i] ^= 0x5c; 17 | } 18 | 19 | this.hash.update(inner); 20 | this.outer.update(outer); 21 | 22 | // Zero out the copied key buffer. 23 | for (var i = 0; i < inner.byteLength; i++) { 24 | inner[i] = 0; 25 | } 26 | } 27 | 28 | /** 29 | * @api private 30 | */ 31 | module.exports = exports = Hmac; 32 | 33 | Hmac.prototype.update = function (toHash) { 34 | if (hashUtils.isEmptyData(toHash) || this.error) { 35 | return this; 36 | } 37 | 38 | try { 39 | this.hash.update(hashUtils.convertToBuffer(toHash)); 40 | } catch (e) { 41 | this.error = e; 42 | } 43 | 44 | return this; 45 | }; 46 | 47 | Hmac.prototype.digest = function (encoding) { 48 | if (!this.outer.finished) { 49 | this.outer.update(this.hash.digest()); 50 | } 51 | 52 | return this.outer.digest(encoding); 53 | }; 54 | 55 | function bufferFromSecret(hashCtor, secret) { 56 | var input = hashUtils.convertToBuffer(secret); 57 | if (input.byteLength > hashCtor.BLOCK_SIZE) { 58 | var bufferHash = new hashCtor; 59 | bufferHash.update(input); 60 | input = bufferHash.digest(); 61 | } 62 | var buffer = new Uint8Array(hashCtor.BLOCK_SIZE); 63 | buffer.set(input); 64 | return buffer; 65 | } 66 | -------------------------------------------------------------------------------- /test/services/s3util.spec.js: -------------------------------------------------------------------------------- 1 | var helpers = require('../helpers'); 2 | var s3util = require('../../lib/services/s3util'); 3 | 4 | describe('dnsCompatibleBucketName', function() { 5 | it('must be at least 3 characters', function() { 6 | expect(s3util.dnsCompatibleBucketName('aa')).to.equal(false); 7 | }); 8 | 9 | it('must not be longer than 63 characters', function() { 10 | var b; 11 | b = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'; 12 | expect(s3util.dnsCompatibleBucketName(b)).to.equal(false); 13 | }); 14 | 15 | it('must start with a lower-cased letter or number', function() { 16 | expect(s3util.dnsCompatibleBucketName('Abc')).to.equal(false); 17 | expect(s3util.dnsCompatibleBucketName('-bc')).to.equal(false); 18 | }); 19 | 20 | it('must end with a lower-cased letter or number', function() { 21 | expect(s3util.dnsCompatibleBucketName('abC')).to.equal(false); 22 | expect(s3util.dnsCompatibleBucketName('ab-')).to.equal(false); 23 | expect(s3util.dnsCompatibleBucketName('abc')).to.equal(true); 24 | }); 25 | 26 | it('may not contain multiple contiguous dots', function() { 27 | expect(s3util.dnsCompatibleBucketName('abc.123')).to.equal(true); 28 | expect(s3util.dnsCompatibleBucketName('abc..123')).to.equal(false); 29 | }); 30 | 31 | it('may only contain letters numbers and dots', function() { 32 | expect(s3util.dnsCompatibleBucketName('abc123')).to.equal(true); 33 | expect(s3util.dnsCompatibleBucketName('abc_123')).to.equal(false); 34 | }); 35 | 36 | it('must not look like an ip address', function() { 37 | expect(s3util.dnsCompatibleBucketName('1.2.3.4')).to.equal(false); 38 | expect(s3util.dnsCompatibleBucketName('a.b.c.d')).to.equal(true); 39 | }); 40 | }); 41 | -------------------------------------------------------------------------------- /apis/s3-2006-03-01.waiters2.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 2, 3 | "waiters": { 4 | "BucketExists": { 5 | "delay": 5, 6 | "operation": "HeadBucket", 7 | "maxAttempts": 20, 8 | "acceptors": [ 9 | { 10 | "expected": 200, 11 | "matcher": "status", 12 | "state": "success" 13 | }, 14 | { 15 | "expected": 301, 16 | "matcher": "status", 17 | "state": "success" 18 | }, 19 | { 20 | "expected": 403, 21 | "matcher": "status", 22 | "state": "success" 23 | }, 24 | { 25 | "expected": 404, 26 | "matcher": "status", 27 | "state": "retry" 28 | } 29 | ] 30 | }, 31 | "BucketNotExists": { 32 | "delay": 5, 33 | "operation": "HeadBucket", 34 | "maxAttempts": 20, 35 | "acceptors": [ 36 | { 37 | "expected": 404, 38 | "matcher": "status", 39 | "state": "success" 40 | } 41 | ] 42 | }, 43 | "ObjectExists": { 44 | "delay": 5, 45 | "operation": "HeadObject", 46 | "maxAttempts": 20, 47 | "acceptors": [ 48 | { 49 | "expected": 200, 50 | "matcher": "status", 51 | "state": "success" 52 | }, 53 | { 54 | "expected": 404, 55 | "matcher": "status", 56 | "state": "retry" 57 | } 58 | ] 59 | }, 60 | "ObjectNotExists": { 61 | "delay": 5, 62 | "operation": "HeadObject", 63 | "maxAttempts": 20, 64 | "acceptors": [ 65 | { 66 | "expected": 404, 67 | "matcher": "status", 68 | "state": "success" 69 | } 70 | ] 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /test/metadata_service/endpoint_config_options.spec.js: -------------------------------------------------------------------------------- 1 | var helpers = require('./../helpers'); 2 | var ENDPOINT_CONFIG_OPTIONS = require('../../lib/metadata_service/get_endpoint_config_options')(); 3 | 4 | var AWS = helpers.AWS; 5 | var ENV_ENDPOINT_NAME = 'AWS_EC2_METADATA_SERVICE_ENDPOINT'; 6 | var CONFIG_ENDPOINT_NAME = 'ec2_metadata_service_endpoint'; 7 | 8 | if (AWS.util.isNode()) { 9 | describe('endpointConfigOptions', function() { 10 | describe('environmentVariableSelector', function() { 11 | var environmentVariableSelector = ENDPOINT_CONFIG_OPTIONS.environmentVariableSelector; 12 | [undefined, 'mockEndpoint'].forEach(function(mockEndpoint) { 13 | it( 14 | 'when env[' + ENV_ENDPOINT_NAME + ']: ' + mockEndpoint, 15 | function() { 16 | expect( 17 | environmentVariableSelector({ 18 | [ENV_ENDPOINT_NAME]: mockEndpoint, 19 | }) 20 | ).to.equal(mockEndpoint); 21 | } 22 | ); 23 | }); 24 | }); 25 | 26 | describe('configFileSelector', function() { 27 | var configFileSelector = ENDPOINT_CONFIG_OPTIONS.configFileSelector; 28 | [undefined, 'mockEndpoint'].forEach(function(mockEndpoint) { 29 | it( 30 | 'when env[' + CONFIG_ENDPOINT_NAME + ']: ' + mockEndpoint, 31 | function() { 32 | expect( 33 | configFileSelector({ 34 | [CONFIG_ENDPOINT_NAME]: mockEndpoint, 35 | }) 36 | ).to.equal(mockEndpoint); 37 | } 38 | ); 39 | }); 40 | }); 41 | 42 | it('default returns undefined', function() { 43 | var defaultKey = ENDPOINT_CONFIG_OPTIONS.default; 44 | expect(defaultKey).to.equal(undefined); 45 | }); 46 | }); 47 | }; 48 | -------------------------------------------------------------------------------- /doc-src/yard-js/lib/yard-js/handlers/base.rb: -------------------------------------------------------------------------------- 1 | require_relative '../core_ext/yard' 2 | require_relative '../core_ext/parsejs' 3 | 4 | module YARDJS 5 | module Handlers 6 | class Base < YARD::Handlers::Base 7 | include ParseJS::AST 8 | 9 | def self.handles?(node) 10 | handlers.any? {|h| node.is_a?(h) } 11 | end 12 | 13 | def call_params; [] end 14 | def caller_method; nil end 15 | 16 | def parse_block(inner_node, opts = {}) 17 | push_state(opts) { parser.process([inner_node].flatten) } 18 | end 19 | 20 | def handle_default_comments(comments = statement.comments) 21 | return if comments.size == 1 22 | comments[0...-1].each do |comment| 23 | register_docstring(nil, clean_comment(comment.body)) 24 | end 25 | 26 | if parser.extra_state.ignore_next_statement 27 | parser.extra_state.ignore_next_statement = nil 28 | abort! 29 | end 30 | end 31 | 32 | def clean_comment(comment) 33 | comment = comment.body if comment.respond_to?(:body) 34 | return "" if comment.nil? 35 | comment.gsub(/^[ \t]*\*[ \t]{0,1}/, '') 36 | end 37 | 38 | def register_docstring(object, docstring = statement.comments, stmt = statement) 39 | docstring = docstring.last if Array === docstring 40 | docstring = clean_comment(docstring) if docstring 41 | docstring.force_encoding('utf-8') if docstring 42 | 43 | super(object, docstring, stmt) 44 | end 45 | 46 | def register_source(object, source = statement.source, type = parser.parser_type) 47 | return unless object.is_a?(CodeObjects::PropertyObject) 48 | object.source ||= source 49 | object.source_type = type 50 | end 51 | end 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /scripts/lib/set-s3-expires-string.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sets model overrides for S3 ExpiresString. 3 | */ 4 | module.exports = function setS3ExpiresString(model) { 5 | if (model.metadata.serviceId === 'S3') { 6 | var newShapes = {}; 7 | for (var shapeId in model.shapes) { 8 | newShapes[shapeId] = model.shapes[shapeId]; 9 | if (shapeId === 'Expires') { 10 | // preserve timestamp type for Expires. 11 | newShapes[shapeId] = {}; 12 | newShapes[shapeId].type = 'timestamp'; 13 | 14 | // add ExpiresString 15 | newShapes['ExpiresString'] = { 16 | type: 'string' 17 | }; 18 | } 19 | } 20 | model.shapes = newShapes; 21 | 22 | for (var operationKey in model.operations) { 23 | var op = model.operations[operationKey]; 24 | if (!op.output || !op.output.shape) { 25 | continue; 26 | } 27 | var output = model.shapes[op.output.shape]; 28 | if (!output || !output.members) { 29 | continue; 30 | } 31 | if ('Expires' in output.members) { 32 | var newMembers = {}; 33 | for (var memberKey in output.members) { 34 | newMembers[memberKey] = output.members[memberKey]; 35 | if (memberKey === 'Expires') { 36 | newMembers['ExpiresString'] = Object.assign({}, newMembers[memberKey], { 37 | 'shape': 'ExpiresString', 38 | 'location': 'header', 39 | 'locationName': 'ExpiresString' 40 | }); 41 | 42 | newMembers[memberKey].deprecated = true; 43 | newMembers[memberKey].documentation = 'Deprecated in favor of ExpiresString.'; 44 | } 45 | } 46 | output.members = newMembers; 47 | } 48 | } 49 | 50 | return true; 51 | } 52 | return false; 53 | }; 54 | -------------------------------------------------------------------------------- /lib/json/builder.js: -------------------------------------------------------------------------------- 1 | var util = require('../util'); 2 | 3 | function JsonBuilder() { } 4 | 5 | JsonBuilder.prototype.build = function(value, shape) { 6 | return JSON.stringify(translate(value, shape)); 7 | }; 8 | 9 | function translate(value, shape) { 10 | if (!shape || value === undefined || value === null) return undefined; 11 | 12 | switch (shape.type) { 13 | case 'structure': return translateStructure(value, shape); 14 | case 'map': return translateMap(value, shape); 15 | case 'list': return translateList(value, shape); 16 | default: return translateScalar(value, shape); 17 | } 18 | } 19 | 20 | function translateStructure(structure, shape) { 21 | if (shape.isDocument) { 22 | return structure; 23 | } 24 | var struct = {}; 25 | util.each(structure, function(name, value) { 26 | var memberShape = shape.members[name]; 27 | if (memberShape) { 28 | if (memberShape.location !== 'body') return; 29 | var locationName = memberShape.isLocationName ? memberShape.name : name; 30 | var result = translate(value, memberShape); 31 | if (result !== undefined) struct[locationName] = result; 32 | } 33 | }); 34 | return struct; 35 | } 36 | 37 | function translateList(list, shape) { 38 | var out = []; 39 | util.arrayEach(list, function(value) { 40 | var result = translate(value, shape.member); 41 | if (result !== undefined) out.push(result); 42 | }); 43 | return out; 44 | } 45 | 46 | function translateMap(map, shape) { 47 | var out = {}; 48 | util.each(map, function(key, value) { 49 | var result = translate(value, shape.value); 50 | if (result !== undefined) out[key] = result; 51 | }); 52 | return out; 53 | } 54 | 55 | function translateScalar(value, shape) { 56 | return shape.toWireFormat(value); 57 | } 58 | 59 | /** 60 | * @api private 61 | */ 62 | module.exports = JsonBuilder; 63 | -------------------------------------------------------------------------------- /scripts/changelog/test/change-creator.js: -------------------------------------------------------------------------------- 1 | var expect = require('chai').expect; 2 | 3 | describe('The ChangeCreator class', function() { 4 | var ChangeCreator = require('../change-creator').ChangeCreator; 5 | describe('validateChange', function() { 6 | var changeCreator; 7 | var changeFields = ['Type', 'Category', 'Description']; 8 | var changeObj; 9 | beforeEach(function() { 10 | changeCreator = new ChangeCreator(); 11 | changeObj = { 12 | Type: 'feature', 13 | Category: 's3', 14 | Description: 'new feature' 15 | }; 16 | }); 17 | 18 | // Verify all fields are required. 19 | changeFields.forEach(function(field) { 20 | it ('throws an error when `' + field +'` is missing', function() { 21 | delete changeObj[field]; 22 | var keys = Object.keys(changeObj); 23 | keys.forEach(function(key) { 24 | changeCreator['setChange' + key](changeObj[key]); 25 | }); 26 | expect(function() { 27 | changeCreator.validateChange(changeObj); 28 | }).to.throw(); 29 | }); 30 | }); 31 | 32 | it('throws an error when no argument provided', function() { 33 | expect(function() { 34 | changeCreator.validateChange(); 35 | }).to.throw(); 36 | }); 37 | 38 | it('does not throw if all fields are supplied', function() { 39 | var keys = Object.keys(changeObj); 40 | keys.forEach(function(key) { 41 | changeCreator['setChange' + key](changeObj[key]); 42 | }); 43 | expect(function() { 44 | changeCreator.validateChange(); 45 | }).to.not.throw(); 46 | }); 47 | }); 48 | }); -------------------------------------------------------------------------------- /doc-src/parsejs/lib/parsejs/ast.rb: -------------------------------------------------------------------------------- 1 | require "parsejs/scope" 2 | 3 | module ParseJS 4 | module AST 5 | class Node 6 | def type?(string) 7 | self.class.name.split("::").last == string 8 | end 9 | 10 | def cuddly? 11 | false 12 | end 13 | 14 | def statement? 15 | false 16 | end 17 | 18 | def needs_newline? 19 | false 20 | end 21 | end 22 | 23 | class Comment 24 | def multiline? 25 | @type == 'multiline' 26 | end 27 | end 28 | 29 | class SequenceExpression 30 | attr_accessor :parens 31 | end 32 | 33 | class BlockStatement 34 | attr_accessor :cuddly 35 | 36 | def cuddle! 37 | @cuddly = true 38 | end 39 | 40 | def needs_newline? 41 | !@cuddly 42 | end 43 | 44 | def cuddly? 45 | true 46 | end 47 | 48 | def statement? 49 | true 50 | end 51 | end 52 | 53 | class FunctionExpression 54 | include ParseJS::AST::Scope 55 | end 56 | 57 | class FunctionDeclaration 58 | include ParseJS::AST::Scope 59 | end 60 | 61 | class Program 62 | include ParseJS::AST::Scope 63 | end 64 | 65 | statements = [VariableDeclaration, EmptyStatement, ExpressionStatement, IfStatement] 66 | statements += [WhileStatement, ForStatement, ForInStatement, DoWhileStatement] 67 | statements += [ContinueStatement, BreakStatement, ReturnStatement, WithStatement] 68 | statements += [LabeledStatement, SwitchStatement, ThrowStatement, TryStatement] 69 | statements += [DebuggerStatement, FunctionDeclaration] 70 | 71 | statements.each do |statement| 72 | statement.class_eval do 73 | def needs_newline? 74 | true 75 | end 76 | 77 | def statement? 78 | true 79 | end 80 | end 81 | end 82 | end 83 | end 84 | 85 | -------------------------------------------------------------------------------- /apis/s3-2006-03-01.paginators.json: -------------------------------------------------------------------------------- 1 | { 2 | "pagination": { 3 | "ListBuckets": { 4 | "input_token": "ContinuationToken", 5 | "limit_key": "MaxBuckets", 6 | "output_token": "ContinuationToken", 7 | "result_key": "Buckets" 8 | }, 9 | "ListMultipartUploads": { 10 | "input_token": [ 11 | "KeyMarker", 12 | "UploadIdMarker" 13 | ], 14 | "limit_key": "MaxUploads", 15 | "more_results": "IsTruncated", 16 | "output_token": [ 17 | "NextKeyMarker", 18 | "NextUploadIdMarker" 19 | ], 20 | "result_key": [ 21 | "Uploads", 22 | "CommonPrefixes" 23 | ] 24 | }, 25 | "ListObjectVersions": { 26 | "input_token": [ 27 | "KeyMarker", 28 | "VersionIdMarker" 29 | ], 30 | "limit_key": "MaxKeys", 31 | "more_results": "IsTruncated", 32 | "output_token": [ 33 | "NextKeyMarker", 34 | "NextVersionIdMarker" 35 | ], 36 | "result_key": [ 37 | "Versions", 38 | "DeleteMarkers", 39 | "CommonPrefixes" 40 | ] 41 | }, 42 | "ListObjects": { 43 | "input_token": "Marker", 44 | "limit_key": "MaxKeys", 45 | "more_results": "IsTruncated", 46 | "output_token": "NextMarker || Contents[-1].Key", 47 | "result_key": [ 48 | "Contents", 49 | "CommonPrefixes" 50 | ] 51 | }, 52 | "ListObjectsV2": { 53 | "input_token": "ContinuationToken", 54 | "limit_key": "MaxKeys", 55 | "output_token": "NextContinuationToken", 56 | "result_key": [ 57 | "Contents", 58 | "CommonPrefixes" 59 | ] 60 | }, 61 | "ListParts": { 62 | "input_token": "PartNumberMarker", 63 | "limit_key": "MaxParts", 64 | "more_results": "IsTruncated", 65 | "output_token": "NextPartNumberMarker", 66 | "result_key": "Parts" 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /lib/metadata_service.d.ts: -------------------------------------------------------------------------------- 1 | 2 | import {AWSError} from './error'; 3 | /** 4 | * Represents a metadata service available on EC2 instances. Using the request() method, you can receieve metadata about any available resource on the metadata service. 5 | */ 6 | export class MetadataService { 7 | /** 8 | * Creates a new MetadataService object with a given set of options. 9 | */ 10 | constructor(options?: MetadataServiceOptions); 11 | /** 12 | * Sends a request to the instance metadata service for a given resource. 13 | */ 14 | request(path: string, callback: (err: AWSError, data: string) => void): void; 15 | request( 16 | path: string, 17 | options: {method?: string, headers?: {[key: string]: String} }, 18 | callback: (err: AWSError, data: string) => void 19 | ): void; 20 | /** 21 | * 169.254.169.254 22 | */ 23 | static host: string 24 | /** 25 | * A map of options to pass to the underlying HTTP request. 26 | */ 27 | httpOptions: { 28 | /** 29 | * a timeout value in milliseconds to wait before aborting the connection. Set to 0 for no timeout. 30 | */ 31 | timeout: number; 32 | } 33 | } 34 | 35 | interface MetadataServiceOptions { 36 | /** 37 | * the hostname of the instance metadata service. 38 | */ 39 | host?: string; 40 | /** 41 | * a map of options to pass to the underlying HTTP request. 42 | */ 43 | httpOptions?: { 44 | /** 45 | * a timeout value in milliseconds to wait before aborting the connection. Set to 0 for no timeout. 46 | */ 47 | timeout?: number; 48 | } 49 | /** 50 | * the maximum number of retries to perform for timeout errors. 51 | */ 52 | maxRetries?: number; 53 | /** 54 | * A set of options to configure the retry delay on retryable errors. See AWS.Config for details. 55 | */ 56 | retryDelayOptions?: any 57 | } 58 | -------------------------------------------------------------------------------- /doc-src/parsejs/test.rb: -------------------------------------------------------------------------------- 1 | require "rubygems" 2 | require "bundler/setup" 3 | require "lattescript" 4 | require "benchmark" 5 | 6 | require "ruby-prof" 7 | 8 | file = <<-FOO 9 | /** 10 | some docs 11 | */ 12 | App.Foo = SC.View.extend({ 13 | /** 14 | some docs 15 | */ 16 | hi: function() { 17 | 18 | } 19 | }); 20 | FOO 21 | 22 | parser = LatteScript::Parser.new(file) 23 | parser.parse 24 | ast = parser.result 25 | new_string = LatteScript::Stringifier.to_string(ast) do |stringifier| 26 | stringifier.include_comments = true 27 | end 28 | 29 | puts new_string 30 | 31 | __END__ 32 | 33 | #result = RubyProf.profile do 34 | 35 | Dir[File.expand_path("~/Code/cool_stuff/sproutcore20/packages/**/lib/**/*.js")].each do |file| 36 | #Dir[File.expand_path("~/Code/cool_stuff/jquery/src/**/*.js")].each do |file| 37 | #Dir["/Users/wycats/Code/cool_stuff/jquery/src/queue.js"].each do |file| 38 | next if file =~ /jquery-|packages\/handlebars|packages\/metamorph/ 39 | #next if file =~ /intro|outro|sizzle\/(speed|test)|sizzle-jquery/ 40 | string = File.read(file) 41 | 42 | puts "#{file}: " 43 | puts 44 | 45 | result = Benchmark.measure { 46 | LatteScript::Parser.new(string).parse 47 | } 48 | 49 | #puts "#{string.size} bytes in #{result.total.round(2)}s = #{(string.size / result.total).round}bps" 50 | end 51 | #end 52 | 53 | #printer = RubyProf::CallTreePrinter.new(result) 54 | #printer.print(File.open("call.grind", "w")) 55 | 56 | __END__ 57 | 58 | string = File.read("spec/fixtures/jquery.js") 59 | 60 | #require "ruby-prof" 61 | 62 | ast = nil 63 | 64 | #result = RubyProf.profile do 65 | parser = LatteScript::Parser.new(string) 66 | ast = parser.parse 67 | #end 68 | 69 | #printer = RubyProf::FlatPrinter.new(result) 70 | #printer.print(STDOUT) 71 | #printer.print(File.open("profile.html", "w")) 72 | 73 | #new_string = LatteScript::Stringifier.to_string(ast) do |stringifier| 74 | #stringifier.include_comments = true 75 | #end 76 | 77 | -------------------------------------------------------------------------------- /test/metadata_service/endpoint_mode_config_options.spec.js: -------------------------------------------------------------------------------- 1 | var helpers = require('./../helpers'); 2 | var ENDPOINT_MODE_CONFIG_OPTIONS = require('../../lib/metadata_service/get_endpoint_mode_config_options')(); 3 | var EndpointMode = require('../../lib/metadata_service/get_endpoint_mode')(); 4 | 5 | var AWS = helpers.AWS; 6 | var ENV_ENDPOINT_MODE_NAME = 'AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE'; 7 | var CONFIG_ENDPOINT_MODE_NAME = 'ec2_metadata_service_endpoint_mode'; 8 | 9 | if (AWS.util.isNode()) { 10 | describe('endpointModeConfigOptions', function() { 11 | describe('environmentVariableSelector', function() { 12 | var environmentVariableSelector = ENDPOINT_MODE_CONFIG_OPTIONS.environmentVariableSelector; 13 | [undefined, 'mockEndpointMode'].forEach(function(mockEndpointMode) { 14 | it( 15 | 'when env[' + ENV_ENDPOINT_MODE_NAME + ']: ' + mockEndpointMode, 16 | function() { 17 | expect( 18 | environmentVariableSelector({ 19 | [ENV_ENDPOINT_MODE_NAME]: mockEndpointMode, 20 | }) 21 | ).to.equal(mockEndpointMode); 22 | } 23 | ); 24 | }); 25 | }); 26 | 27 | describe('configFileSelector', function() { 28 | var configFileSelector = ENDPOINT_MODE_CONFIG_OPTIONS.configFileSelector; 29 | [undefined, 'mockEndpointMode'].forEach(function(mockEndpointMode) { 30 | it( 31 | 'when env[' + CONFIG_ENDPOINT_MODE_NAME + ']: ' + mockEndpointMode, 32 | function() { 33 | expect( 34 | configFileSelector({ 35 | [CONFIG_ENDPOINT_MODE_NAME]: mockEndpointMode, 36 | }) 37 | ).to.equal(mockEndpointMode); 38 | } 39 | ); 40 | }); 41 | }); 42 | 43 | it('default returns ' + EndpointMode.IPv4, function() { 44 | var defaultKey = ENDPOINT_MODE_CONFIG_OPTIONS.default; 45 | expect(defaultKey).to.equal(EndpointMode.IPv4); 46 | }); 47 | }); 48 | }; 49 | -------------------------------------------------------------------------------- /lib/s3/presigned_post.d.ts: -------------------------------------------------------------------------------- 1 | export class PresignedPost { 2 | /** 3 | * The URL that should be used as the action of the form. 4 | */ 5 | url: string; 6 | 7 | /** 8 | * The fields that must be included as hidden inputs on the form. 9 | */ 10 | fields: PresignedPost.Fields; 11 | } 12 | 13 | export namespace PresignedPost { 14 | export interface Params { 15 | /** 16 | * The S3 bucket to which the form should upload an attached file. 17 | */ 18 | Bucket?: string; 19 | 20 | /** 21 | * An array of conditions that must be met for the form upload to be 22 | * accepted by S3. 23 | */ 24 | Conditions?: Array<{[key: string]: any}|[string, any, any]>; 25 | 26 | /** 27 | * The number of seconds for which the POST form's signed policy should be 28 | * valid. Defaults to 3600 (one hour). 29 | */ 30 | Expires?: number; 31 | 32 | /** 33 | * A hash of form fields to include in the presigned POST form. All fields 34 | * (except 'key') will be included as exact match conditions in the 35 | * presigned policy. 36 | */ 37 | Fields?: {[key: string]: any}; 38 | } 39 | 40 | export interface Fields { 41 | /** 42 | * A base64-encoded policy detailing what constitutes an acceptable POST 43 | * upload. Composed of the conditions and expiration provided to 44 | * s3.createPresignedPost 45 | */ 46 | Policy: string; 47 | 48 | /** 49 | * A hex-encoded HMAC of the POST policy, signed with the credentials 50 | * provided to the S3 client. 51 | */ 52 | 'X-Amz-Signature': string; 53 | 54 | /** 55 | * Additional keys that must be included in the form to be submitted. This 56 | * will include signature metadata as well as any fields provided to 57 | * s3.createPresignedPost 58 | */ 59 | [key: string]: string; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /doc-src/yard-js/templates/default/module/html/item_summary.erb: -------------------------------------------------------------------------------- 1 |
  • 2 | 3 | <% if @item.tags(:overload).size == 1 %> 4 | <%= signature(@item.tag(:overload), true, @item.respond_to?(:attr_info) && !@item.attr_info) %> 5 | <% else %> 6 | <%= signature(@item, true, false, @item.respond_to?(:attr_info) && !@item.attr_info) %> 7 | <% end %> 8 | 9 | <% if @item.aliases.size > 0 %> 10 | (also: <%= @item.aliases.map {|o| h(o.name(true)) }.join(", ") %>) 11 | <% end %> 12 | 13 | <% if @item.has_tag?(:static) %> 14 | static 15 | <% end %> 16 | <% if @item.respond_to?(:constructor?) && @item.constructor? %> 17 | constructor 18 | <% end %> 19 | <% if !@item.tag(:readonly) && !@item.tag(:writeonly) && ![:function, :event].include?(@item.property_type) %> 20 | readwrite 21 | <% end %> 22 | <% if @item.has_tag?(:readonly) %> 23 | readonly 24 | <% end %> 25 | <% if @item.has_tag?(:writeonly) %> 26 | writeonly 27 | <% end %> 28 | <% if @item.visibility != :public %><%= @item.visibility %><% end %> 29 | <% if @item.has_tag?(:abstract) %>abstract<% end %> 30 | <% if @item.has_tag?(:deprecated) %>deprecated<% end %> 31 | <% if @item.has_tag?(:api) && @item.tag(:api).text == 'private' %>private<% end %> 32 | 33 | <% if @item.has_tag?(:deprecated) %> 34 | Deprecated. <%= htmlify_line @item.tag(:deprecated).text %> 35 | <% else %> 36 | <%= htmlify_line docstring_summary(@item) %> 37 | <% end %> 38 |
  • 39 | -------------------------------------------------------------------------------- /test/metadata_service/get_metadata_service_endpoint.spec.js: -------------------------------------------------------------------------------- 1 | var helpers = require('./../helpers'); 2 | var getMetadataServiceEndpoint = require('../../lib/metadata_service/get_metadata_service_endpoint'); 3 | 4 | var Endpoint = require('../../lib/metadata_service/get_endpoint')(); 5 | var EndpointMode = require('../../lib/metadata_service/get_endpoint_mode')(); 6 | 7 | var AWS = helpers.AWS; 8 | 9 | if (AWS.util.isNode()) { 10 | describe('getMetadataServiceEndpoint', function() { 11 | describe('when endpoint is defined', function() { 12 | it('returns endpoint', function() { 13 | var mockEndpoint = 'http://127.0.0.1'; 14 | helpers.spyOn(AWS.util, 'loadConfig').andReturn(mockEndpoint); 15 | expect(getMetadataServiceEndpoint()).to.equal(mockEndpoint); 16 | }); 17 | }); 18 | 19 | describe('when endpoint is not defined', function() { 20 | [ 21 | [Endpoint.IPv4, EndpointMode.IPv4], 22 | [Endpoint.IPv6, EndpointMode.IPv6], 23 | ].forEach(function([endpoint, endpointMode]) { 24 | it('returns endpoint: "'+ endpoint + '" for endpointMode: ' + endpointMode, function() { 25 | let loadConfigFirstCall = true; 26 | helpers.spyOn(AWS.util, 'loadConfig').andCallFake(function(options) { 27 | if (loadConfigFirstCall) { 28 | loadConfigFirstCall = false; 29 | return undefined; 30 | } 31 | return endpointMode; 32 | }); 33 | expect(getMetadataServiceEndpoint()).to.equal(endpoint); 34 | }); 35 | }); 36 | 37 | it('throws error for invalid endpointMode:invalid', function() { 38 | let loadConfigFirstCall = true; 39 | const invalidEndpointMode = 'invalid'; 40 | helpers.spyOn(AWS.util, 'loadConfig').andCallFake(function(options) { 41 | if (loadConfigFirstCall) { 42 | loadConfigFirstCall = false; 43 | return undefined; 44 | } 45 | return invalidEndpointMode; 46 | }); 47 | expect(function() { 48 | getMetadataServiceEndpoint(); 49 | }).to['throw']('Unsupported endpoint mode: ' + invalidEndpointMode); 50 | }); 51 | }); 52 | }); 53 | } 54 | -------------------------------------------------------------------------------- /scripts/lib/prune-shapes.spec.js: -------------------------------------------------------------------------------- 1 | var expect = require('chai').expect; 2 | var pruneShapes = require('./prune-shapes').pruneShapes; 3 | var extraModel = require('./extra-2018-08-02.normal.json'); 4 | 5 | describe('pruneShapes', function() { 6 | it('removes unused shapes from model', function() { 7 | var model = deepCopyObject(extraModel); 8 | 9 | var originalOperationNames = Object.keys(model.operations); 10 | var originalShapeNames = Object.keys(model.shapes); 11 | 12 | expect(originalShapeNames.sort()).to.eql([ 13 | 'BarOperationInput', 14 | 'BarOperationOutput', 15 | 'BazOperationInput', 16 | 'BazStringShape', 17 | 'EventStreamPayload', 18 | 'EventStreamStructure', 19 | 'FancyStructure', 20 | 'ListOfList', 21 | 'ListOfString', 22 | 'MapOfList', 23 | 'MapOfString', 24 | 'String', 25 | 'StringShape' 26 | ]); 27 | 28 | pruneShapes(model); 29 | 30 | // Unused shapes should now be removed 31 | var visitedShapeNames = Object.keys(model.shapes); 32 | expect(visitedShapeNames.sort()).to.eql([ 33 | 'FancyStructure', 34 | 'ListOfString', 35 | 'MapOfList', 36 | 'String' 37 | ]); 38 | 39 | expect(originalOperationNames.sort()).to.eql(Object.keys(model.operations).sort()); 40 | }); 41 | }); 42 | 43 | function deepCopyObject(original) { 44 | if (typeof original !== 'object' || original === null) { 45 | return original; 46 | } 47 | var newObject = {}; 48 | var keys = Object.keys(original); 49 | for (var i = 0; i < keys.length; i++) { 50 | var key = keys[i]; 51 | var value = original[key]; 52 | if (Array.isArray(value)) { 53 | newObject[key] = []; 54 | for (var j = 0; j < value.length; j++) { 55 | newObject[key].push(deepCopyObject(value[j])); 56 | } 57 | } else if (typeof value === 'object' && value !== null) { 58 | newObject[key] = deepCopyObject(value) 59 | } else { 60 | newObject[key] = value; 61 | } 62 | } 63 | return newObject; 64 | } 65 | -------------------------------------------------------------------------------- /lib/services/s3.d.ts: -------------------------------------------------------------------------------- 1 | import {Service} from '../service'; 2 | import {ManagedUpload} from '../s3/managed_upload'; 3 | import S3 = require('../../clients/s3'); 4 | 5 | export class S3Customizations extends Service { 6 | /** 7 | * Get a pre-signed URL for a given operation name. 8 | */ 9 | getSignedUrl(operation: string, params: any, callback: (err: Error, url: string) => void): void; 10 | /** 11 | * Get a pre-signed URL for a given operation name. 12 | */ 13 | getSignedUrl(operation: string, params: any): string; 14 | 15 | /** 16 | * Returns a 'thenable' promise that will be resolved with a pre-signed URL for a given operation name. 17 | */ 18 | getSignedUrlPromise(operation: string, params: any): Promise; 19 | 20 | /** 21 | * Get the form fields and target URL for direct POST uploading. 22 | */ 23 | createPresignedPost( 24 | params: S3.PresignedPost.Params, 25 | callback: (err: Error, data: S3.PresignedPost) => void 26 | ): void; 27 | /** 28 | * Get the form fields and target URL for direct POST uploading. 29 | */ 30 | createPresignedPost(params: S3.PresignedPost.Params): S3.PresignedPost; 31 | 32 | /** 33 | * Uploads an arbitrarily sized buffer, blob, or stream, using intelligent 34 | * concurrent handling of parts if the payload is large enough. You can 35 | * configure the concurrent queue size by setting `options`. Note that this 36 | * is the only operation for which the SDK can retry requests with stream 37 | * bodies. 38 | */ 39 | upload(params: S3.Types.PutObjectRequest, options?: ManagedUpload.ManagedUploadOptions, callback?: (err: Error, data: ManagedUpload.SendData) => void): ManagedUpload; 40 | /** 41 | * Uploads an arbitrarily sized buffer, blob, or stream, using intelligent 42 | * concurrent handling of parts if the payload is large enough. You can 43 | * configure the concurrent queue size by setting `options`. Note that this 44 | * is the only operation for which the SDK can retry requests with stream 45 | * bodies. 46 | */ 47 | upload(params: S3.Types.PutObjectRequest, callback?: (err: Error, data: ManagedUpload.SendData) => void): ManagedUpload; 48 | static ManagedUpload: typeof ManagedUpload; 49 | } 50 | -------------------------------------------------------------------------------- /doc-src/yard-js/templates/default/fulldoc/html/css/highlight.github.css: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | github.com style (c) Vasily Polovnyov 4 | 5 | */ 6 | 7 | pre code { 8 | display: block; padding: 0.5em; 9 | color: #333; 10 | /*background: #f8f8ff*/ 11 | } 12 | 13 | pre .comment, 14 | pre .template_comment, 15 | pre .diff .header, 16 | pre .javadoc { 17 | color: #998; 18 | font-style: italic 19 | } 20 | 21 | pre .keyword, 22 | pre .css .rule .keyword, 23 | pre .winutils, 24 | pre .javascript .title, 25 | pre .nginx .title, 26 | pre .subst, 27 | pre .request, 28 | pre .status { 29 | color: #333; 30 | font-weight: bold 31 | } 32 | 33 | pre .number, 34 | pre .hexcolor, 35 | pre .ruby .constant { 36 | color: #099; 37 | } 38 | 39 | pre .string, 40 | pre .tag .value, 41 | pre .phpdoc, 42 | pre .tex .formula { 43 | color: #d14 44 | } 45 | 46 | pre .title, 47 | pre .id { 48 | color: #900; 49 | font-weight: bold 50 | } 51 | 52 | pre .javascript .title, 53 | pre .lisp .title, 54 | pre .clojure .title, 55 | pre .subst { 56 | font-weight: normal 57 | } 58 | 59 | pre .class .title, 60 | pre .haskell .type, 61 | pre .vhdl .literal, 62 | pre .tex .command { 63 | color: #458; 64 | font-weight: bold 65 | } 66 | 67 | pre .tag, 68 | pre .tag .title, 69 | pre .rules .property, 70 | pre .django .tag .keyword { 71 | color: #000080; 72 | font-weight: normal 73 | } 74 | 75 | pre .attribute, 76 | pre .variable, 77 | pre .lisp .body { 78 | color: #008080 79 | } 80 | 81 | pre .regexp { 82 | color: #009926 83 | } 84 | 85 | pre .class { 86 | color: #458; 87 | font-weight: bold 88 | } 89 | 90 | pre .symbol, 91 | pre .ruby .symbol .string, 92 | pre .lisp .keyword, 93 | pre .tex .special, 94 | pre .prompt { 95 | color: #990073 96 | } 97 | 98 | pre .built_in, 99 | pre .lisp .title, 100 | pre .clojure .built_in { 101 | color: #0086b3 102 | } 103 | 104 | pre .preprocessor, 105 | pre .pi, 106 | pre .doctype, 107 | pre .shebang, 108 | pre .cdata { 109 | color: #999; 110 | font-weight: bold 111 | } 112 | 113 | pre .deletion { 114 | background: #fdd 115 | } 116 | 117 | pre .addition { 118 | background: #dfd 119 | } 120 | 121 | pre .diff .change { 122 | background: #0086b3 123 | } 124 | 125 | pre .chunk { 126 | color: #aaa 127 | } 128 | -------------------------------------------------------------------------------- /scripts/translate-api: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var fs = require('fs'); 4 | var Translator = require('./lib/translator'); 5 | var util = require('util'); 6 | var path = require('path'); 7 | 8 | /* 9 | * Minimizes all .normal.json files by flattening shapes, removing 10 | * documentation and removing unused shapes. The result will be written to 11 | * `.min.json` file. 12 | * 13 | * The passed parameter is base path. The directory must include the apis/ 14 | * folder. 15 | */ 16 | function ApiTranslator(basePath) { 17 | this._apisPath = path.join(basePath, 'apis'); 18 | } 19 | 20 | /* 21 | * minimize passed .normal.json filepath into .min.json 22 | */ 23 | ApiTranslator.prototype.minimizeFile = function minimizeFile(filepath) { 24 | var opath = filepath.replace(/\.normal\.json$/, '.min.json'); 25 | var data = JSON.parse(fs.readFileSync(path.join(this._apisPath, filepath)).toString()); 26 | var translated = new Translator(data, {documentation: false}); 27 | var json = JSON.stringify(translated, null, ' '); 28 | fs.writeFileSync(path.join(this._apisPath, opath), json); 29 | }; 30 | 31 | /* 32 | * minimize files in api path. If optional modelName is passed only that model 33 | * is minimized otherwise all .normal.json files found. 34 | */ 35 | ApiTranslator.prototype.translateAll = function translateAll(modelName) { 36 | var paths = fs.readdirSync(this._apisPath); 37 | var self = this; 38 | paths.forEach(function(filepath) { 39 | if (filepath.endsWith('.normal.json')) { 40 | if (!modelName || filepath.startsWith(modelName)) { 41 | self.minimizeFile(filepath); 42 | } 43 | } 44 | }); 45 | }; 46 | 47 | /* 48 | * if executed as script initialize the ApiTranslator and minimize API files 49 | * 50 | * Optional first parameter specifies which model to minimize. If omitted all 51 | * files are selected. 52 | * 53 | * Optional second parameter specifies base path. The directory must include 54 | * the apis/ folder with .normal.json files. Output is written into the same 55 | * path. If parameter is not passed the repository root will be used. 56 | */ 57 | if (require.main === module) { 58 | var modelName = process.argv[2] || ''; 59 | var basePath = process.argv[3] || path.join(__dirname, '..'); 60 | new ApiTranslator(basePath).translateAll(modelName); 61 | } 62 | 63 | module.exports = ApiTranslator; 64 | -------------------------------------------------------------------------------- /doc-src/yard-js/lib/yard-js/code_objects/property_object.rb: -------------------------------------------------------------------------------- 1 | module YARDJS 2 | module CodeObjects 3 | class PropertyObject < Base 4 | attr_accessor :parameters, :property_type 5 | 6 | def aliases; [] end 7 | 8 | # @return whether or not the method is the #initialize constructor method 9 | def constructor? 10 | name == :constructor && namespace.is_a?(YARD::CodeObjects::ClassObject) 11 | end 12 | 13 | def relative_path(other) 14 | case other 15 | when PropertyObject 16 | if other.parent == parent 17 | other.name.to_s 18 | else 19 | other.path 20 | end 21 | else 22 | if parent == other 23 | other.name.to_s 24 | else 25 | other.path 26 | end 27 | end 28 | end 29 | 30 | def scope; :class end 31 | def attr_info; nil end 32 | 33 | # @return [Boolean] whether or not this method was created as a module 34 | # function 35 | # @since 0.8.0 36 | def module_function? 37 | false 38 | end 39 | 40 | # @return [Boolean] whether the method is a writer attribute 41 | # @since 0.5.3 42 | def writer? 43 | true 44 | end 45 | 46 | # @return [Boolean] whether the method is a reader attribute 47 | # @since 0.5.3 48 | def reader? 49 | true 50 | end 51 | 52 | # Tests if the object is defined as an attribute in the namespace 53 | # @return [Boolean] whether the object is an attribute 54 | def is_attribute? 55 | false 56 | end 57 | 58 | # Tests if the object is defined as an alias of another method 59 | # @return [Boolean] whether the object is an alias 60 | def is_alias? 61 | false 62 | end 63 | 64 | # Tests boolean {#explicit} value. 65 | # 66 | # @return [Boolean] whether the method is explicitly defined in source 67 | def is_explicit? 68 | true 69 | end 70 | 71 | # @return [MethodObject] the object that this method overrides 72 | # @return [nil] if it does not override a method 73 | # @since 0.6.0 74 | def overridden_method 75 | nil 76 | end 77 | 78 | def value 79 | tag(:value) ? tag(:value).text : '' 80 | end 81 | end 82 | end 83 | end 84 | -------------------------------------------------------------------------------- /lib/json/parser.js: -------------------------------------------------------------------------------- 1 | var util = require('../util'); 2 | 3 | function JsonParser() { } 4 | 5 | JsonParser.prototype.parse = function(value, shape) { 6 | return translate(JSON.parse(value), shape); 7 | }; 8 | 9 | function translate(value, shape) { 10 | if (!shape || value === undefined) return undefined; 11 | 12 | switch (shape.type) { 13 | case 'structure': return translateStructure(value, shape); 14 | case 'map': return translateMap(value, shape); 15 | case 'list': return translateList(value, shape); 16 | default: return translateScalar(value, shape); 17 | } 18 | } 19 | 20 | function translateStructure(structure, shape) { 21 | if (structure == null) return undefined; 22 | if (shape.isDocument) return structure; 23 | 24 | var struct = {}; 25 | var shapeMembers = shape.members; 26 | var isAwsQueryCompatible = shape.api && shape.api.awsQueryCompatible; 27 | util.each(shapeMembers, function(name, memberShape) { 28 | var locationName = memberShape.isLocationName ? memberShape.name : name; 29 | if (Object.prototype.hasOwnProperty.call(structure, locationName)) { 30 | var value = structure[locationName]; 31 | var result = translate(value, memberShape); 32 | if (result !== undefined) struct[name] = result; 33 | } else if (isAwsQueryCompatible && memberShape.defaultValue) { 34 | if (memberShape.type === 'list') { 35 | struct[name] = typeof memberShape.defaultValue === 'function' ? memberShape.defaultValue() : memberShape.defaultValue; 36 | } 37 | } 38 | }); 39 | return struct; 40 | } 41 | 42 | function translateList(list, shape) { 43 | if (list == null) return undefined; 44 | 45 | var out = []; 46 | util.arrayEach(list, function(value) { 47 | var result = translate(value, shape.member); 48 | if (result === undefined) out.push(null); 49 | else out.push(result); 50 | }); 51 | return out; 52 | } 53 | 54 | function translateMap(map, shape) { 55 | if (map == null) return undefined; 56 | 57 | var out = {}; 58 | util.each(map, function(key, value) { 59 | var result = translate(value, shape.value); 60 | if (result === undefined) out[key] = null; 61 | else out[key] = result; 62 | }); 63 | return out; 64 | } 65 | 66 | function translateScalar(value, shape) { 67 | return shape.toType(value); 68 | } 69 | 70 | /** 71 | * @api private 72 | */ 73 | module.exports = JsonParser; 74 | -------------------------------------------------------------------------------- /lib/credentials/file_system_credentials.js: -------------------------------------------------------------------------------- 1 | var AWS = require('../core'); 2 | 3 | /** 4 | * Represents credentials from a JSON file on disk. 5 | * If the credentials expire, the SDK can {refresh} the credentials 6 | * from the file. 7 | * 8 | * The format of the file should be similar to the options passed to 9 | * {AWS.Config}: 10 | * 11 | * ```javascript 12 | * {accessKeyId: 'akid', secretAccessKey: 'secret', sessionToken: 'optional'} 13 | * ``` 14 | * 15 | * @example Loading credentials from disk 16 | * var creds = new AWS.FileSystemCredentials('./configuration.json'); 17 | * creds.accessKeyId == 'AKID' 18 | * 19 | * @!attribute filename 20 | * @readonly 21 | * @return [String] the path to the JSON file on disk containing the 22 | * credentials. 23 | * @!macro nobrowser 24 | */ 25 | AWS.FileSystemCredentials = AWS.util.inherit(AWS.Credentials, { 26 | 27 | /** 28 | * @overload AWS.FileSystemCredentials(filename) 29 | * Creates a new FileSystemCredentials object from a filename 30 | * 31 | * @param filename [String] the path on disk to the JSON file to load. 32 | */ 33 | constructor: function FileSystemCredentials(filename) { 34 | AWS.Credentials.call(this); 35 | this.filename = filename; 36 | this.get(function() {}); 37 | }, 38 | 39 | /** 40 | * Loads the credentials from the {filename} on disk. 41 | * 42 | * @callback callback function(err) 43 | * Called after the JSON file on disk is read and parsed. When this callback 44 | * is called with no error, it means that the credentials information 45 | * has been loaded into the object (as the `accessKeyId`, `secretAccessKey`, 46 | * and `sessionToken` properties). 47 | * @param err [Error] if an error occurred, this value will be filled 48 | * @see get 49 | */ 50 | refresh: function refresh(callback) { 51 | if (!callback) callback = AWS.util.fn.callback; 52 | try { 53 | var creds = JSON.parse(AWS.util.readFileSync(this.filename)); 54 | AWS.Credentials.call(this, creds); 55 | if (!this.accessKeyId || !this.secretAccessKey) { 56 | throw AWS.util.error( 57 | new Error('Credentials not set in ' + this.filename), 58 | { code: 'FileSystemCredentialsProviderFailure' } 59 | ); 60 | } 61 | this.expired = false; 62 | callback(); 63 | } catch (err) { 64 | callback(err); 65 | } 66 | } 67 | 68 | }); 69 | -------------------------------------------------------------------------------- /test/signers/presign.spec.js: -------------------------------------------------------------------------------- 1 | // Generated by CoffeeScript 1.12.3 2 | (function() { 3 | var AWS, cw, helpers; 4 | 5 | helpers = require('../helpers'); 6 | 7 | AWS = helpers.AWS; 8 | 9 | cw = new AWS.CloudWatch({ 10 | paramValidation: true 11 | }); 12 | 13 | describe('AWS.Signers.Presign', function() { 14 | var resultUrl; 15 | resultUrl = 'https://monitoring.mock-region.amazonaws.com/?' + ('Action=ListMetrics&Version=' + cw.api.apiVersion + '&') + 'X-Amz-Algorithm=AWS4-HMAC-SHA256&' + 'X-Amz-Credential=akid%2F19700101%2Fmock-region%2Fmonitoring%2Faws4_request&' + 'X-Amz-Date=19700101T000000Z&X-Amz-Expires=3600&X-Amz-Security-Token=session&' + 'X-Amz-Signature=953bd6d74e86c12adc305f656473d614269d2f20a0c18c5edbb3d7f57ca2b439&' + 'X-Amz-SignedHeaders=host'; 16 | beforeEach(function() { 17 | helpers.spyOn(cw, 'getSkewCorrectedDate').andReturn(new Date(0)); 18 | return helpers.spyOn(AWS.util.date, 'getDate').andReturn(new Date(0)); 19 | }); 20 | it('presigns requests', function() { 21 | return cw.listMetrics().presign(function(err, url) { 22 | return expect(url).to.equal(resultUrl); 23 | }); 24 | }); 25 | it('presigns synchronously', function() { 26 | return expect(cw.listMetrics().presign()).to.equal(resultUrl); 27 | }); 28 | it('throws errors on synchronous presign failures', function() { 29 | return expect(function() { 30 | return cw.listMetrics({ 31 | InvalidParameter: true 32 | }).presign(); 33 | }).to['throw'](/Unexpected key/); 34 | }); 35 | it('allows specifying different expiry time', function() { 36 | return expect(cw.listMetrics().presign(900)).to.contain('X-Amz-Expires=900&'); 37 | }); 38 | it('limits expiry time to a week in SigV4', function() { 39 | return cw.listMetrics().presign(9999999, function(err) { 40 | expect(err.code).to.equal('InvalidExpiryTime'); 41 | return expect(err.message).to.equal('Presigning does not support expiry time greater than a week with SigV4 signing.'); 42 | }); 43 | }); 44 | return it('only supports s3 or v4 signers', function() { 45 | return new AWS.SimpleDB().listDomains().presign(function(err) { 46 | expect(err.code).to.equal('UnsupportedSigner'); 47 | return expect(err.message).to.equal('Presigning only supports S3 or SigV4 signing.'); 48 | }); 49 | }); 50 | }); 51 | 52 | }).call(this); 53 | -------------------------------------------------------------------------------- /lib/signers/v3.js: -------------------------------------------------------------------------------- 1 | var AWS = require('../core'); 2 | var inherit = AWS.util.inherit; 3 | 4 | /** 5 | * @api private 6 | */ 7 | AWS.Signers.V3 = inherit(AWS.Signers.RequestSigner, { 8 | addAuthorization: function addAuthorization(credentials, date) { 9 | 10 | var datetime = AWS.util.date.rfc822(date); 11 | 12 | this.request.headers['X-Amz-Date'] = datetime; 13 | 14 | if (credentials.sessionToken) { 15 | this.request.headers['x-amz-security-token'] = credentials.sessionToken; 16 | } 17 | 18 | this.request.headers['X-Amzn-Authorization'] = 19 | this.authorization(credentials, datetime); 20 | 21 | }, 22 | 23 | authorization: function authorization(credentials) { 24 | return 'AWS3 ' + 25 | 'AWSAccessKeyId=' + credentials.accessKeyId + ',' + 26 | 'Algorithm=HmacSHA256,' + 27 | 'SignedHeaders=' + this.signedHeaders() + ',' + 28 | 'Signature=' + this.signature(credentials); 29 | }, 30 | 31 | signedHeaders: function signedHeaders() { 32 | var headers = []; 33 | AWS.util.arrayEach(this.headersToSign(), function iterator(h) { 34 | headers.push(h.toLowerCase()); 35 | }); 36 | return headers.sort().join(';'); 37 | }, 38 | 39 | canonicalHeaders: function canonicalHeaders() { 40 | var headers = this.request.headers; 41 | var parts = []; 42 | AWS.util.arrayEach(this.headersToSign(), function iterator(h) { 43 | parts.push(h.toLowerCase().trim() + ':' + String(headers[h]).trim()); 44 | }); 45 | return parts.sort().join('\n') + '\n'; 46 | }, 47 | 48 | headersToSign: function headersToSign() { 49 | var headers = []; 50 | AWS.util.each(this.request.headers, function iterator(k) { 51 | if (k === 'Host' || k === 'Content-Encoding' || k.match(/^X-Amz/i)) { 52 | headers.push(k); 53 | } 54 | }); 55 | return headers; 56 | }, 57 | 58 | signature: function signature(credentials) { 59 | return AWS.util.crypto.hmac(credentials.secretAccessKey, this.stringToSign(), 'base64'); 60 | }, 61 | 62 | stringToSign: function stringToSign() { 63 | var parts = []; 64 | parts.push(this.request.method); 65 | parts.push('/'); 66 | parts.push(''); 67 | parts.push(this.canonicalHeaders()); 68 | parts.push(this.request.body); 69 | return AWS.util.crypto.sha256(parts.join('\n')); 70 | } 71 | 72 | }); 73 | 74 | /** 75 | * @api private 76 | */ 77 | module.exports = AWS.Signers.V3; 78 | -------------------------------------------------------------------------------- /dist-tools/browser-builder.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var path = require('path'); 4 | 5 | var AWS = require('../'); 6 | 7 | var license = [ 8 | '// AWS SDK for JavaScript v' + AWS.VERSION, 9 | '// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.', 10 | '// License at https://sdk.amazonaws.com/js/BUNDLE_LICENSE.txt' 11 | ].join('\n') + '\n'; 12 | 13 | function minify(code) { 14 | var uglify = require('uglify-js'); 15 | var minified = uglify.minify(code, {fromString: true}); 16 | return minified.code; 17 | } 18 | 19 | function stripComments(code) { 20 | var lines = code.split(/\r?\n/); 21 | var multiLine = false; 22 | lines = lines.map(function (line) { 23 | var rLine = line; 24 | if (line.match(/^\s*\/\//)) { 25 | rLine = null; 26 | } else if (line.match(/^\s*\/\*/)) { 27 | multiLine = true; 28 | rLine = null; 29 | } 30 | 31 | if (multiLine) { 32 | var multiLineEnd = line.match(/\*\/(.*)/); 33 | if (multiLineEnd) { 34 | multiLine = false; 35 | rLine = multiLineEnd[1]; 36 | } else { 37 | rLine = null; 38 | } 39 | } 40 | 41 | return rLine; 42 | }).filter(function(l) { return l !== null; }); 43 | 44 | var newCode = lines.join('\n'); 45 | newCode = newCode.replace(/\/\*\*[\s\S]+?Copyright\s+.+?Amazon[\s\S]+?\*\//g, ''); 46 | return newCode; 47 | } 48 | 49 | function build(options, callback) { 50 | if (arguments.length === 1) { 51 | callback = options; 52 | options = {}; 53 | } 54 | 55 | var img = require('insert-module-globals'); 56 | img.vars.process = function() { return '{browser:true}'; }; 57 | 58 | if (options.services) process.env.AWS_SERVICES = options.services; 59 | 60 | var browserify = require('browserify'); 61 | var brOpts = { basedir: path.resolve(__dirname, '..') }; 62 | browserify(brOpts).add('./').ignore('domain').bundle(function(err, data) { 63 | if (err) return callback(err); 64 | 65 | var code = (data || '').toString(); 66 | if (options.minify) code = minify(code); 67 | else code = stripComments(code); 68 | 69 | code = license + code; 70 | callback(null, code); 71 | }); 72 | } 73 | 74 | // run if we called this tool directly 75 | if (require.main === module) { 76 | var opts = { 77 | services: process.argv[2] || process.env.SERVICES, 78 | minify: process.env.MINIFY ? true : false 79 | }; 80 | build(opts, function(err, code) { 81 | if (err) console.error(err.message); 82 | else console.log(code); 83 | }); 84 | } 85 | 86 | build.license = license; 87 | module.exports = build; 88 | -------------------------------------------------------------------------------- /doc-src/yard-js/templates/default/module/setup.rb: -------------------------------------------------------------------------------- 1 | def init 2 | sections :header, :box_info, :pre_docstring, T('docstring'), :children, 3 | :constant_summary, [T('docstring')], :inherited_constants, 4 | :constructor_summary, [:item_summary], 5 | :events_summary, [:item_summary], 6 | :properties_summary, [:item_summary], :inherited_properties, 7 | :method_summary, [:item_summary], :inherited_methods, 8 | :methodmissing, 9 | :events_details, [T('method_details')], 10 | :properties_details, [T('method_details')], 11 | :methods_details, [T('method_details')] 12 | end 13 | 14 | # Placeholder for class inheritance 15 | def methodmissing; end 16 | 17 | def constructor_summary 18 | list = object.properties.select {|p| p.constructor? } 19 | list = sort_listing(prune_method_listing(list)) 20 | if @constructor = list.first 21 | erb(:constructor_summary) 22 | end 23 | end 24 | 25 | def event_listing 26 | @event_listing ||= object.events 27 | end 28 | 29 | def property_listing 30 | return @property_listing if @property_listing 31 | 32 | list = object.properties. 33 | select {|p| p.property_type != :function }. 34 | reject {|p| p.constructor? || p.tag(:constant) } 35 | list = sort_listing(prune_method_listing(list)) 36 | @property_listing = list 37 | end 38 | 39 | def inherited_property_list 40 | object.inheritance_tree(true)[1..-1].each do |superclass| 41 | next if superclass.is_a?(YARD::CodeObjects::Proxy) 42 | props = prune_method_listing(superclass.properties, false) 43 | props = props. 44 | select {|p| p.property_type != :function }. 45 | reject {|p| object.child(:name => p.name) }. 46 | reject {|p| p.constructor? || p.tag(:constant) } 47 | yield superclass, props if props.size > 0 48 | end 49 | end 50 | 51 | def method_listing 52 | return @method_listing if @method_listing 53 | 54 | list = object.properties. 55 | select {|p| p.property_type == :function }. 56 | reject {|p| p.constructor? } 57 | list = sort_listing(prune_method_listing(list)) 58 | @method_listing = list 59 | end 60 | 61 | def inherited_method_list 62 | object.inheritance_tree(true)[1..-1].each do |superclass| 63 | next if superclass.is_a?(YARD::CodeObjects::Proxy) 64 | props = prune_method_listing(superclass.properties, false) 65 | props = props. 66 | select {|p| p.property_type == :function }. 67 | reject {|p| object.child(:name => p.name) }. 68 | reject {|p| p.constructor? } 69 | yield superclass, props if props.size > 0 70 | end 71 | end 72 | 73 | def scopes(list) 74 | yield(list, '') if list.size > 0 75 | end 76 | -------------------------------------------------------------------------------- /test/idempotent.spec.js: -------------------------------------------------------------------------------- 1 | var helpers = require('./helpers'); 2 | var AWS = helpers.AWS; 3 | 4 | // Create a mock service 5 | var apiJson = { 6 | metadata: { 7 | apiVersion: '2016-11-22', 8 | endpointPrefix: 'fake', 9 | jsonVersion: '1.1', 10 | protocol: 'json', 11 | signatureVersion: 'v4', 12 | targetPrefix: 'Fake' 13 | }, 14 | operations: { 15 | fakeOp: { 16 | input: { 17 | type: 'structure', 18 | required: [ 19 | 'foo' 20 | ], 21 | members: { 22 | foo: { 23 | idempotencyToken: true 24 | }, 25 | bar: { 26 | idempotencyToken: true 27 | }, 28 | baz: {} 29 | } 30 | } 31 | } 32 | } 33 | }; 34 | var mockService = new AWS.Service({ 35 | paramValidation: true 36 | }); 37 | mockService.api = new AWS.Model.Api(apiJson); 38 | 39 | describe('AWS.EventListeners.Core.BUILD_IDEMPOTENCY_TOKENS', function() { 40 | var buildIdempotencyTokens = AWS.EventListeners.Core.BUILD_IDEMPOTENCY_TOKENS; 41 | 42 | it('automatically fills in fields marked as idempotent', function(done) { 43 | var params = {}; 44 | var req = mockService.makeRequest('fakeOp', params); 45 | buildIdempotencyTokens(req); 46 | expect(params).to.eql({}); 47 | expect(typeof req.params.foo).to.equal('string'); 48 | expect(typeof req.params.bar).to.equal('string'); 49 | expect(typeof req.params.baz).to.equal('undefined'); 50 | done(); 51 | }); 52 | 53 | it('will defer to user input if provided', function(done) { 54 | var params = {foo: 'token'}; 55 | var req = mockService.makeRequest('fakeOp', params); 56 | buildIdempotencyTokens(req); 57 | expect(params).to.eql({foo: 'token'}); 58 | expect(req.params.foo).to.equal('token'); 59 | expect(typeof req.params.bar).to.equal('string'); 60 | expect(typeof req.params.baz).to.equal('undefined'); 61 | done(); 62 | }); 63 | 64 | it('will use a version 4 UUID as the token', function(done) { 65 | var uuidV4Regex = new RegExp('[a-zA-Z0-9]{8}-[a-zA-Z0-9]{4}-4[a-zA-Z0-9]{3}-[ab89][a-zA-Z0-9]{3}-[a-zA-Z0-9]{12}'); 66 | var params = {}; 67 | var req = mockService.makeRequest('fakeOp', params); 68 | buildIdempotencyTokens(req); 69 | expect(params).to.eql({}); 70 | expect(typeof req.params.foo).to.equal('string'); 71 | expect(typeof req.params.bar).to.equal('string'); 72 | expect(typeof req.params.baz).to.equal('undefined'); 73 | expect(req.params.foo.search(uuidV4Regex)).to.equal(0); 74 | expect(req.params.bar.search(uuidV4Regex)).to.equal(0); 75 | done(); 76 | }); 77 | 78 | }); 79 | -------------------------------------------------------------------------------- /lib/signers/v4_credentials.js: -------------------------------------------------------------------------------- 1 | var AWS = require('../core'); 2 | 3 | /** 4 | * @api private 5 | */ 6 | var cachedSecret = {}; 7 | 8 | /** 9 | * @api private 10 | */ 11 | var cacheQueue = []; 12 | 13 | /** 14 | * @api private 15 | */ 16 | var maxCacheEntries = 50; 17 | 18 | /** 19 | * @api private 20 | */ 21 | var v4Identifier = 'aws4_request'; 22 | 23 | /** 24 | * @api private 25 | */ 26 | module.exports = { 27 | /** 28 | * @api private 29 | * 30 | * @param date [String] 31 | * @param region [String] 32 | * @param serviceName [String] 33 | * @return [String] 34 | */ 35 | createScope: function createScope(date, region, serviceName) { 36 | return [ 37 | date.substr(0, 8), 38 | region, 39 | serviceName, 40 | v4Identifier 41 | ].join('/'); 42 | }, 43 | 44 | /** 45 | * @api private 46 | * 47 | * @param credentials [Credentials] 48 | * @param date [String] 49 | * @param region [String] 50 | * @param service [String] 51 | * @param shouldCache [Boolean] 52 | * @return [String] 53 | */ 54 | getSigningKey: function getSigningKey( 55 | credentials, 56 | date, 57 | region, 58 | service, 59 | shouldCache 60 | ) { 61 | var credsIdentifier = AWS.util.crypto 62 | .hmac(credentials.secretAccessKey, credentials.accessKeyId, 'base64'); 63 | var cacheKey = [credsIdentifier, date, region, service].join('_'); 64 | shouldCache = shouldCache !== false; 65 | if (shouldCache && (cacheKey in cachedSecret)) { 66 | return cachedSecret[cacheKey]; 67 | } 68 | 69 | var kDate = AWS.util.crypto.hmac( 70 | 'AWS4' + credentials.secretAccessKey, 71 | date, 72 | 'buffer' 73 | ); 74 | var kRegion = AWS.util.crypto.hmac(kDate, region, 'buffer'); 75 | var kService = AWS.util.crypto.hmac(kRegion, service, 'buffer'); 76 | 77 | var signingKey = AWS.util.crypto.hmac(kService, v4Identifier, 'buffer'); 78 | if (shouldCache) { 79 | cachedSecret[cacheKey] = signingKey; 80 | cacheQueue.push(cacheKey); 81 | if (cacheQueue.length > maxCacheEntries) { 82 | // remove the oldest entry (not the least recently used) 83 | delete cachedSecret[cacheQueue.shift()]; 84 | } 85 | } 86 | 87 | return signingKey; 88 | }, 89 | 90 | /** 91 | * @api private 92 | * 93 | * Empties the derived signing key cache. Made available for testing purposes 94 | * only. 95 | */ 96 | emptyCache: function emptyCache() { 97 | cachedSecret = {}; 98 | cacheQueue = []; 99 | } 100 | }; 101 | -------------------------------------------------------------------------------- /lib/config.d.ts: -------------------------------------------------------------------------------- 1 | import {ConfigurationServicePlaceholders, ConfigurationServiceApiVersions} from './config_service_placeholders'; 2 | import {ConfigBase, ConfigurationOptions} from './config-base'; 3 | 4 | export class Config extends ConfigBase { 5 | /** 6 | * Creates a new configuration object. 7 | * This is the object that passes option data along to service requests, including credentials, security, region information, and some service specific settings. 8 | */ 9 | constructor(options?: ConfigurationOptions & ConfigurationServicePlaceholders & APIVersions); 10 | /** 11 | * Loads configuration data from a JSON file into this config object. 12 | * Loading configuration will reset all existing configuration on the object. 13 | * This feature is not supported in the browser environment of the SDK. 14 | * 15 | * @param {string} path - the path relative to your process's current working directory to load configuration from. 16 | */ 17 | loadFromPath(path: string): Config & ConfigurationServicePlaceholders & APIVersions; 18 | /** 19 | * Updates the current configuration object with new options. 20 | * 21 | * @param {ConfigurationOptions} options - a map of option keys and values. 22 | * @param {boolean} allowUnknownKeys - Whether unknown keys can be set on the configuration object. 23 | */ 24 | update(options: ConfigurationOptions & ConfigurationServicePlaceholders & APIVersions & {[key: string]: any}, allowUnknownKeys: true): void; 25 | /** 26 | * Updates the current configuration object with new options. 27 | * 28 | * @param {ConfigurationOptions} options - a map of option keys and values. 29 | * @param {boolean} allowUnknownKeys - Defaults to false. Whether unknown keys can be set on the configuration object. 30 | */ 31 | update(options: ConfigurationOptions & ConfigurationServicePlaceholders & APIVersions, allowUnknownKeys?: false): void; 32 | } 33 | 34 | export type GlobalConfigInstance = Config & ConfigurationServicePlaceholders & APIVersions; 35 | 36 | 37 | export interface APIVersions { 38 | /** 39 | * A string in YYYY-MM-DD format that represents the latest possible API version that can be used in all services (unless overridden by apiVersions). Specify \'latest\' to use the latest possible version. 40 | */ 41 | apiVersion?: "latest"|string; 42 | /** 43 | * A map of service identifiers (the lowercase service class name) with the API version to use when instantiating a service. Specify 'latest' for each individual that can use the latest available version. 44 | */ 45 | apiVersions?: ConfigurationServiceApiVersions; 46 | } 47 | 48 | // for backwards compatible client generation 49 | export { ConfigBase } from "./config-base"; 50 | -------------------------------------------------------------------------------- /lib/query/query_param_serializer.js: -------------------------------------------------------------------------------- 1 | var util = require('../util'); 2 | 3 | function QueryParamSerializer() { 4 | } 5 | 6 | QueryParamSerializer.prototype.serialize = function(params, shape, fn) { 7 | serializeStructure('', params, shape, fn); 8 | }; 9 | 10 | function ucfirst(shape) { 11 | if (shape.isQueryName || shape.api.protocol !== 'ec2') { 12 | return shape.name; 13 | } else { 14 | return shape.name[0].toUpperCase() + shape.name.substr(1); 15 | } 16 | } 17 | 18 | function serializeStructure(prefix, struct, rules, fn) { 19 | util.each(rules.members, function(name, member) { 20 | var value = struct[name]; 21 | if (value === null || value === undefined) return; 22 | 23 | var memberName = ucfirst(member); 24 | memberName = prefix ? prefix + '.' + memberName : memberName; 25 | serializeMember(memberName, value, member, fn); 26 | }); 27 | } 28 | 29 | function serializeMap(name, map, rules, fn) { 30 | var i = 1; 31 | util.each(map, function (key, value) { 32 | var prefix = rules.flattened ? '.' : '.entry.'; 33 | var position = prefix + (i++) + '.'; 34 | var keyName = position + (rules.key.name || 'key'); 35 | var valueName = position + (rules.value.name || 'value'); 36 | serializeMember(name + keyName, key, rules.key, fn); 37 | serializeMember(name + valueName, value, rules.value, fn); 38 | }); 39 | } 40 | 41 | function serializeList(name, list, rules, fn) { 42 | var memberRules = rules.member || {}; 43 | 44 | if (list.length === 0) { 45 | if (rules.api.protocol !== 'ec2') { 46 | fn.call(this, name, null); 47 | } 48 | return; 49 | } 50 | 51 | util.arrayEach(list, function (v, n) { 52 | var suffix = '.' + (n + 1); 53 | if (rules.api.protocol === 'ec2') { 54 | // Do nothing for EC2 55 | suffix = suffix + ''; // make linter happy 56 | } else if (rules.flattened) { 57 | if (memberRules.name) { 58 | var parts = name.split('.'); 59 | parts.pop(); 60 | parts.push(ucfirst(memberRules)); 61 | name = parts.join('.'); 62 | } 63 | } else { 64 | suffix = '.' + (memberRules.name ? memberRules.name : 'member') + suffix; 65 | } 66 | serializeMember(name + suffix, v, memberRules, fn); 67 | }); 68 | } 69 | 70 | function serializeMember(name, value, rules, fn) { 71 | if (value === null || value === undefined) return; 72 | if (rules.type === 'structure') { 73 | serializeStructure(name, value, rules, fn); 74 | } else if (rules.type === 'list') { 75 | serializeList(name, value, rules, fn); 76 | } else if (rules.type === 'map') { 77 | serializeMap(name, value, rules, fn); 78 | } else { 79 | fn(name, rules.toWireFormat(value).toString()); 80 | } 81 | } 82 | 83 | /** 84 | * @api private 85 | */ 86 | module.exports = QueryParamSerializer; 87 | -------------------------------------------------------------------------------- /lib/core.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The main AWS namespace 3 | */ 4 | var AWS = { util: require('./util') }; 5 | 6 | /** 7 | * @api private 8 | * @!macro [new] nobrowser 9 | * @note This feature is not supported in the browser environment of the SDK. 10 | */ 11 | var _hidden = {}; _hidden.toString(); // hack to parse macro 12 | 13 | /** 14 | * @api private 15 | */ 16 | module.exports = AWS; 17 | 18 | AWS.util.update(AWS, { 19 | 20 | /** 21 | * @constant 22 | */ 23 | VERSION: '1.14.2', 24 | 25 | /** 26 | * @api private 27 | */ 28 | Signers: {}, 29 | 30 | /** 31 | * @api private 32 | */ 33 | Protocol: { 34 | Json: require('./protocol/json'), 35 | Query: require('./protocol/query'), 36 | Rest: require('./protocol/rest'), 37 | RestJson: require('./protocol/rest_json'), 38 | RestXml: require('./protocol/rest_xml') 39 | }, 40 | 41 | /** 42 | * @api private 43 | */ 44 | XML: { 45 | Builder: require('./xml/builder'), 46 | Parser: null // conditionally set based on environment 47 | }, 48 | 49 | /** 50 | * @api private 51 | */ 52 | JSON: { 53 | Builder: require('./json/builder'), 54 | Parser: require('./json/parser') 55 | }, 56 | 57 | /** 58 | * @api private 59 | */ 60 | Model: { 61 | Api: require('./model/api'), 62 | Operation: require('./model/operation'), 63 | Shape: require('./model/shape'), 64 | Paginator: require('./model/paginator'), 65 | ResourceWaiter: require('./model/resource_waiter') 66 | }, 67 | 68 | /** 69 | * @api private 70 | */ 71 | apiLoader: require('./api_loader'), 72 | 73 | /** 74 | * @api private 75 | */ 76 | util: require('./util'), 77 | }); 78 | require('./sequential_executor'); 79 | require('./service'); 80 | require('./config'); 81 | require('./credentials'); 82 | require('./credentials/credential_provider_chain'); 83 | require('./http'); 84 | require('./event_listeners'); 85 | require('./request'); 86 | require('./response'); 87 | require('./resource_waiter'); 88 | require('./signers/request_signer'); 89 | require('./param_validator'); 90 | 91 | /** 92 | * @readonly 93 | * @return [AWS.SequentialExecutor] a collection of global event listeners that 94 | * are attached to every sent request. 95 | * @see AWS.Request AWS.Request for a list of events to listen for 96 | * @example Logging the time taken to send a request 97 | * AWS.events.on('send', function startSend(resp) { 98 | * resp.startTime = new Date().getTime(); 99 | * }).on('complete', function calculateTime(resp) { 100 | * var time = (new Date().getTime() - resp.startTime) / 1000; 101 | * console.log('Request took ' + time + ' seconds'); 102 | * }); 103 | * 104 | * new AWS.S3().listBuckets(); // prints 'Request took 0.285 seconds' 105 | */ 106 | AWS.events = new AWS.SequentialExecutor(); 107 | -------------------------------------------------------------------------------- /test/browser/runner.js: -------------------------------------------------------------------------------- 1 | var system = require('system'); 2 | 3 | function waitFor(testFx, onReady, timeOutMillis) { 4 | var maxtimeOutMillis = timeOutMillis ? timeOutMillis : 30000, 5 | start = new Date().getTime(), 6 | condition = false, 7 | interval = setInterval(function() { 8 | if ( (new Date().getTime() - start < maxtimeOutMillis) && !condition ) { 9 | condition = (typeof(testFx) === "string" ? eval(testFx) : testFx()); 10 | } else { 11 | if(!condition) { 12 | console.log("'waitFor()' timeout"); 13 | setTimeout(function(){ phantom.exit(1); }, 0); 14 | } else { 15 | typeof(onReady) === "string" ? eval(onReady) : onReady(); 16 | clearInterval(interval); 17 | } 18 | } 19 | }, 100); 20 | }; 21 | 22 | var page = require('webpage').create(); 23 | 24 | page.onConsoleMessage = function(msg) { 25 | console.log(msg); 26 | }; 27 | 28 | page.open(system.args[1] || 'test/browser/runner.html', function(status){ 29 | if (status !== "success") { 30 | console.log("Unable to access network"); 31 | setTimeout(function(){ phantom.exit(); }, 0); 32 | } else { 33 | var index = 0; 34 | function printStatus() { 35 | var items = page.evaluate(function() { return jsApiReporter.specs(); }); 36 | for (; index < items.length; index++) { 37 | if (items[index] === 'pending') break; 38 | var item = ''; 39 | switch (items[index].status) { 40 | case 'skipped': item = 'S'; break; 41 | case 'passed': item = '.'; break; 42 | case 'failed': item = 'X'; break; 43 | } 44 | system.stdout.write(item); 45 | } 46 | } 47 | 48 | var interval = setInterval(printStatus, 10); 49 | 50 | waitFor(function(){ 51 | return page.evaluate(function(){ 52 | return jsApiReporter.status() === 'done'; 53 | }); 54 | }, function(){ 55 | clearInterval(interval); 56 | var exitCode = page.evaluate(function(){ 57 | console.log(''); 58 | console.log(''); 59 | var list = document.body.querySelectorAll('.results > .failures > .spec-detail.failed'); 60 | if (list && list.length > 0) { 61 | console.log(''); 62 | console.log(list.length + ' test(s) FAILED:'); 63 | for (i = 0; i < list.length; ++i) { 64 | var el = list[i], 65 | desc = el.querySelector('.description'), 66 | msg = el.querySelector('.result-message'); 67 | console.log(''); 68 | console.log(desc.innerText); 69 | console.log(msg.innerText); 70 | console.log(''); 71 | } 72 | return 1; 73 | } else { 74 | console.log(document.body.querySelector('.alert > .bar').innerText); 75 | return 0; 76 | } 77 | }); 78 | setTimeout(function() { phantom.exit(exitCode); }, 0); 79 | }); 80 | } 81 | }); 82 | -------------------------------------------------------------------------------- /ts/config.ts: -------------------------------------------------------------------------------- 1 | import AWS = require('../index'); 2 | import {Agent} from 'https'; 3 | 4 | // Create Config 5 | AWS.config = new AWS.Config({ 6 | region: 'us-east-1', 7 | credentials: { 8 | accessKeyId: 'fake', 9 | secretAccessKey: 'key' 10 | }, 11 | correctClockSkew: true, 12 | s3: { 13 | region: 'us-west-2', 14 | params: { 15 | Bucket: 'bucket' 16 | }, 17 | useDualstack: true 18 | }, 19 | apiVersion: 'latest', 20 | }); 21 | 22 | // Lock api versions 23 | AWS.config.apiVersions = { 24 | s3: "2006-03-01" 25 | }; 26 | 27 | // update credentials 28 | AWS.config.update({ 29 | credentials: new AWS.Credentials('accessKeyId', 'secretAccessKey', 'sessionToken') 30 | }); 31 | 32 | // update credentials using direct CredentialsOptions 33 | AWS.config.update({ 34 | accessKeyId: 'accessKeyId', 35 | secretAccessKey: 'secretAccessKey', 36 | sessionToken: 'sessionToken' 37 | }); 38 | 39 | // set all normal config 40 | AWS.config.update({ 41 | apiVersion: "latest", 42 | computeChecksums: true, 43 | convertResponseTypes: true, 44 | correctClockSkew: false, 45 | credentials: { 46 | accessKeyId: 'id', 47 | secretAccessKey: 'secret', 48 | sessionToken: 'token' 49 | }, 50 | httpOptions: { 51 | agent: new Agent(), 52 | proxy: 'http://localhost:8080', 53 | timeout: 1000 * 60, 54 | xhrAsync: true, 55 | xhrWithCredentials: true 56 | }, 57 | logger: console, 58 | maxRedirects: 2, 59 | maxRetries: 3, 60 | paramValidation: { 61 | min: true, 62 | max: false, 63 | pattern: false, 64 | enum: false 65 | }, 66 | region: 'us-east-1', 67 | retryDelayOptions: { 68 | base: 100, 69 | customBackoff: function(retryCount){return 0;} 70 | }, 71 | s3BucketEndpoint: false, 72 | s3DisableBodySigning: false, 73 | s3ForcePathStyle: true, 74 | signatureCache: false, 75 | signatureVersion: 'v4', 76 | sslEnabled: true, 77 | systemClockOffset: 0, 78 | useAccelerateEndpoint: true 79 | }); 80 | 81 | //test config methods 82 | AWS.config.getCredentials(function(err) {}); 83 | // make sure we can get the Promise constructor 84 | var Promise = AWS.config.getPromisesDependency(); 85 | if (Promise) { 86 | console.log(typeof Promise.resolve); 87 | } 88 | AWS.config.setPromisesDependency(Promise); 89 | 90 | var config = AWS.config.loadFromPath('/to/path'); 91 | 92 | // test update allowing unknown keys 93 | AWS.config.update({ 94 | fake: 'fake' 95 | }, true); 96 | 97 | // Test constructing with a CredentialProviderChain 98 | var options = { 99 | credentialProvider: new AWS.CredentialProviderChain([ 100 | () => new AWS.FileSystemCredentials('fake') 101 | ]) 102 | }; 103 | var s3 = new AWS.S3(options); 104 | -------------------------------------------------------------------------------- /test/region/utils.spec.js: -------------------------------------------------------------------------------- 1 | require('../helpers'); 2 | 3 | var region_utils = require('../../lib/region/utils'); 4 | 5 | // IBM Unsupported 6 | // var isFipsRegion = region_utils.isFipsRegion; 7 | var isGlobalRegion = region_utils.isGlobalRegion; 8 | var getRealRegion = region_utils.getRealRegion; 9 | 10 | // IBM Unsupported 11 | // describe(isFipsRegion.name, () => { 12 | // [ 13 | // [true, 'fips-us-east-1'], 14 | // [true, 'us-east-1-fips'], 15 | // [false, 'us-east-1'], 16 | // ].forEach(([output, input]) => { 17 | // it('returns "' + output + '" for region "' + input + '"', () => { 18 | // expect(isFipsRegion(input)).to.equal(output); 19 | // }); 20 | // }); 21 | 22 | // [undefined, null].forEach((input) => { 23 | // it('returns false for ' + input, () => { 24 | // expect(isFipsRegion(input)).to.equal(false); 25 | // }); 26 | // }); 27 | // }); 28 | 29 | describe(isGlobalRegion.name, () => { 30 | [ 31 | [true, 'aws-global'], 32 | [true, 'aws-us-gov-global'], 33 | [false, 'us-east-1'], 34 | ].forEach(([output, input]) => { 35 | it('returns "' + output + '" for region "' + input + '"', () => { 36 | expect(isGlobalRegion(input)).to.equal(output); 37 | }); 38 | }); 39 | 40 | [undefined, null].forEach((input) => { 41 | it('returns false for ' + input, () => { 42 | expect(isGlobalRegion(input)).to.equal(false); 43 | }); 44 | }); 45 | }); 46 | 47 | describe(getRealRegion.name, () => { 48 | describe('returns real region if is pseudo region', () => { 49 | describe('special cases', () => { 50 | const cases = [ 51 | // IBM Unsupported 52 | // ['fips-aws-global', 'us-east-1'], 53 | // ['aws-fips', 'us-east-1'], 54 | ['aws-global', 'us-east-1'], 55 | // IBM Unsupported 56 | // ['fips-aws-us-gov-global', 'us-gov-west-1'], 57 | ['aws-us-gov-global', 'us-gov-west-1'], 58 | ]; 59 | for (const [input, output] of cases) { 60 | it(`returns "${output}" for "${input}"`, () => { 61 | expect(getRealRegion(input)).to.equal(output); 62 | }); 63 | } 64 | }); 65 | 66 | // IBM Unsupported 67 | // describe('removes fips and optional dkr/prod from provided region', () => { 68 | // const cases = [ 69 | // ['fips-us-east-1', 'us-east-1'], 70 | // ['us-east-1-fips', 'us-east-1'], 71 | // ['fips-dkr-us-east-1', 'us-east-1'], 72 | // ['fips-prod-us-east-1', 'us-east-1'], 73 | // ['fips-cn-north-1', 'cn-north-1'], 74 | // ]; 75 | // for (const [input, output] of cases) { 76 | // it(`returns "${output}" for "${input}"`, () => { 77 | // expect(getRealRegion(input)).to.equal(output); 78 | // }); 79 | // } 80 | // }); 81 | }); 82 | 83 | it('returns passed region if it is real', () => { 84 | const cases = ['us-east-1', 'sa-east-1', 'me-south-1', 'eu-central-1', 'cn-north-1']; 85 | for (const region of cases) { 86 | expect(getRealRegion(region)).to.equal(region); 87 | } 88 | }); 89 | }); 90 | -------------------------------------------------------------------------------- /doc-src/templates/api-versions/templates/default/fulldoc/html/setup.rb: -------------------------------------------------------------------------------- 1 | # @return [String] HTML output of the classes to be displayed in the 2 | # full_list_class template. 3 | def class_list(root = Registry.root, tree = TreeContext.new) 4 | out = "" 5 | children = run_verifier(root.children) 6 | if root == Registry.root 7 | children += @items.select {|o| o.namespace.is_a?(CodeObjects::Proxy) } 8 | end 9 | 10 | if root == Registry.root 11 | out << '
  • ' 12 | out << ' Services
      ' 13 | svcs = Registry.at('AWS').children.select {|c| c.has_tag?(:service) } 14 | 15 | ids = {} 16 | svcs.each do |svc| 17 | id = svc.tag(:service).text 18 | (ids[id] ||= []) << svc 19 | end 20 | 21 | row_class = '' 22 | next_class = -> { row_class = row_class == 'even' ? 'odd' : 'even' } 23 | 24 | ids.sort_by {|id| id }.each do |id, versions| 25 | versions = versions.sort_by {|v| v.tag(:version).text }.reverse 26 | latest = versions.first 27 | out << "" 48 | end 49 | out << '
  • ' 50 | end 51 | 52 | children.compact.sort_by(&:path).each do |child| 53 | if child.is_a?(CodeObjects::NamespaceObject) 54 | name = child.namespace.is_a?(CodeObjects::Proxy) ? child.path : child.name 55 | next if child.is_a?(CodeObjects::ClassObject) && child.superclass.path == 'AWS.Service' 56 | has_children = run_verifier(child.children).any? {|o| o.is_a?(CodeObjects::NamespaceObject) } 57 | out << "
  • " 58 | out << "
    " 59 | out << " " if has_children 60 | out << linkify(child, name) 61 | out << " < #{child.superclass.name}" if child.is_a?(CodeObjects::ClassObject) && child.superclass 62 | out << "" 63 | out << child.namespace.title 64 | out << "" 65 | out << "
    " 66 | tree.nest do 67 | out << "
      #{class_list(child, tree)}
    " if has_children 68 | end 69 | out << "
  • " 70 | end 71 | end 72 | out 73 | end 74 | --------------------------------------------------------------------------------