@flink-app/s3-plugin 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/.flink/generated-schemas.json +311 -0
  2. package/.flink/generatedHandlers.ts +7 -0
  3. package/.flink/generatedRepos.ts +5 -0
  4. package/.flink/schemas/schemas.json +5 -0
  5. package/.flink/schemas/schemas.ts +1 -0
  6. package/.flink/start.ts +4 -0
  7. package/dist/.flink/generatedHandlers.d.ts +1 -0
  8. package/dist/.flink/generatedHandlers.js +7 -0
  9. package/dist/.flink/generatedRepos.d.ts +1 -0
  10. package/dist/.flink/generatedRepos.js +7 -0
  11. package/dist/.flink/schemas/schemas.d.ts +0 -0
  12. package/dist/.flink/schemas/schemas.js +2 -0
  13. package/dist/.flink/schemas/schemas.json +5 -0
  14. package/dist/.flink/start.d.ts +3 -0
  15. package/dist/.flink/start.js +6 -0
  16. package/dist/index.d.ts +4 -0
  17. package/dist/index.js +172 -0
  18. package/dist/s3Client.d.ts +36 -0
  19. package/dist/s3Client.js +233 -0
  20. package/dist/s3PluginContext.d.ts +6 -0
  21. package/dist/s3PluginContext.js +2 -0
  22. package/dist/schemas/ListObjectsResponse.d.ts +5 -0
  23. package/dist/schemas/ListObjectsResponse.js +2 -0
  24. package/dist/schemas/s3ClientOptions.d.ts +7 -0
  25. package/dist/schemas/s3ClientOptions.js +2 -0
  26. package/dist/schemas/s3PluginOptions.d.ts +11 -0
  27. package/dist/schemas/s3PluginOptions.js +2 -0
  28. package/dist/src/Ctx.d.ts +19 -0
  29. package/dist/src/Ctx.js +2 -0
  30. package/dist/src/handlers/HandlebarsTemplateHandler.d.ts +5 -0
  31. package/dist/src/handlers/HandlebarsTemplateHandler.js +63 -0
  32. package/dist/src/handlers/Management/Get.d.ts +7 -0
  33. package/dist/src/handlers/Management/Get.js +53 -0
  34. package/dist/src/handlers/Management/GetManagement.d.ts +8 -0
  35. package/dist/src/handlers/Management/GetManagement.js +53 -0
  36. package/dist/src/handlers/User/DeleteByUserid.d.ts +9 -0
  37. package/dist/src/handlers/User/DeleteByUserid.js +70 -0
  38. package/dist/src/handlers/User/GetByUserid.d.ts +9 -0
  39. package/dist/src/handlers/User/GetByUserid.js +71 -0
  40. package/dist/src/handlers/User/GetList.d.ts +9 -0
  41. package/dist/src/handlers/User/GetList.js +64 -0
  42. package/dist/src/handlers/User/GetMe.d.ts +8 -0
  43. package/dist/src/handlers/User/GetMe.js +81 -0
  44. package/dist/src/handlers/User/Post.d.ts +10 -0
  45. package/dist/src/handlers/User/Post.js +87 -0
  46. package/dist/src/handlers/User/PostLogin.d.ts +10 -0
  47. package/dist/src/handlers/User/PostLogin.js +86 -0
  48. package/dist/src/handlers/User/PutByUserid.d.ts +9 -0
  49. package/dist/src/handlers/User/PutByUserid.js +97 -0
  50. package/dist/src/index.d.ts +4 -0
  51. package/dist/src/index.js +380 -0
  52. package/dist/src/lib/customer.d.ts +6 -0
  53. package/dist/src/lib/customer.js +121 -0
  54. package/dist/src/lib/payment.d.ts +6 -0
  55. package/dist/src/lib/payment.js +113 -0
  56. package/dist/src/managementApiContext.d.ts +7 -0
  57. package/dist/src/managementApiContext.js +2 -0
  58. package/dist/src/models/ManagementApi.d.ts +28 -0
  59. package/dist/src/models/ManagementApi.js +8 -0
  60. package/dist/src/repos/ConnectSessionRepo.d.ts +5 -0
  61. package/dist/src/repos/ConnectSessionRepo.js +26 -0
  62. package/dist/src/repos/ManagementUserRepo.d.ts +5 -0
  63. package/dist/src/repos/ManagementUserRepo.js +26 -0
  64. package/dist/src/reposx/ConnectSessionRepo.d.ts +5 -0
  65. package/dist/src/reposx/ConnectSessionRepo.js +26 -0
  66. package/dist/src/schemas/ConnectSession.d.ts +4 -0
  67. package/dist/src/schemas/ConnectSession.js +2 -0
  68. package/dist/src/schemas/Management/GetReq.d.ts +2 -0
  69. package/dist/src/schemas/Management/GetReq.js +2 -0
  70. package/dist/src/schemas/Management/GetRes.d.ts +3 -0
  71. package/dist/src/schemas/Management/GetRes.js +2 -0
  72. package/dist/src/schemas/ManagementUser.d.ts +6 -0
  73. package/dist/src/schemas/ManagementUser.js +2 -0
  74. package/dist/src/schemas/ManagementUserViewModel.d.ts +4 -0
  75. package/dist/src/schemas/ManagementUserViewModel.js +19 -0
  76. package/dist/src/schemas/ModuleList.d.ts +18 -0
  77. package/dist/src/schemas/ModuleList.js +2 -0
  78. package/dist/src/schemas/User/DeleteByUseridReq.d.ts +2 -0
  79. package/dist/src/schemas/User/DeleteByUseridReq.js +2 -0
  80. package/dist/src/schemas/User/DeleteByUseridRes.d.ts +2 -0
  81. package/dist/src/schemas/User/DeleteByUseridRes.js +2 -0
  82. package/dist/src/schemas/User/GetByUseridReq.d.ts +2 -0
  83. package/dist/src/schemas/User/GetByUseridReq.js +2 -0
  84. package/dist/src/schemas/User/GetByUseridRes.d.ts +3 -0
  85. package/dist/src/schemas/User/GetByUseridRes.js +2 -0
  86. package/dist/src/schemas/User/GetListReq.d.ts +2 -0
  87. package/dist/src/schemas/User/GetListReq.js +2 -0
  88. package/dist/src/schemas/User/GetListRes.d.ts +4 -0
  89. package/dist/src/schemas/User/GetListRes.js +2 -0
  90. package/dist/src/schemas/User/GetMeReq.d.ts +2 -0
  91. package/dist/src/schemas/User/GetMeReq.js +2 -0
  92. package/dist/src/schemas/User/GetMeRes.d.ts +3 -0
  93. package/dist/src/schemas/User/GetMeRes.js +2 -0
  94. package/dist/src/schemas/User/PostLoginReq.d.ts +4 -0
  95. package/dist/src/schemas/User/PostLoginReq.js +2 -0
  96. package/dist/src/schemas/User/PostLoginRes.d.ts +5 -0
  97. package/dist/src/schemas/User/PostLoginRes.js +2 -0
  98. package/dist/src/schemas/User/PostReq.d.ts +3 -0
  99. package/dist/src/schemas/User/PostReq.js +2 -0
  100. package/dist/src/schemas/User/PostRes.d.ts +3 -0
  101. package/dist/src/schemas/User/PostRes.js +2 -0
  102. package/dist/src/schemas/User/PutByUseridReq.d.ts +3 -0
  103. package/dist/src/schemas/User/PutByUseridReq.js +2 -0
  104. package/dist/src/schemas/User/PutByUseridRes.d.ts +3 -0
  105. package/dist/src/schemas/User/PutByUseridRes.js +2 -0
  106. package/dist/src/schemas/createStripeCustomerOptions.d.ts +11 -0
  107. package/dist/src/schemas/createStripeCustomerOptions.js +2 -0
  108. package/dist/src/schemas/customer/connectToStripeConnectOptions.d.ts +3 -0
  109. package/dist/src/schemas/customer/connectToStripeConnectOptions.js +2 -0
  110. package/dist/src/schemas/customer/hasPaymentMethodOptions.d.ts +3 -0
  111. package/dist/src/schemas/customer/hasPaymentMethodOptions.js +2 -0
  112. package/dist/src/schemas/customer/setupCardOptions.d.ts +3 -0
  113. package/dist/src/schemas/customer/setupCardOptions.js +2 -0
  114. package/dist/src/schemas/customer/setupCardResponse.d.ts +4 -0
  115. package/dist/src/schemas/customer/setupCardResponse.js +2 -0
  116. package/dist/src/schemas/customer/setupCardTokenOptions.d.ts +4 -0
  117. package/dist/src/schemas/customer/setupCardTokenOptions.js +2 -0
  118. package/dist/src/schemas/payment/capturePaymentOptions.d.ts +4 -0
  119. package/dist/src/schemas/payment/capturePaymentOptions.js +2 -0
  120. package/dist/src/schemas/payment/confirmPaymentOptions.d.ts +4 -0
  121. package/dist/src/schemas/payment/confirmPaymentOptions.js +2 -0
  122. package/dist/src/schemas/payment/confirmPaymentResponse.d.ts +7 -0
  123. package/dist/src/schemas/payment/confirmPaymentResponse.js +2 -0
  124. package/dist/src/schemas/payment/confirmPaymentTokenOptions.d.ts +4 -0
  125. package/dist/src/schemas/payment/confirmPaymentTokenOptions.js +2 -0
  126. package/dist/src/schemas/payment/createPaymentResponse.d.ts +5 -0
  127. package/dist/src/schemas/payment/createPaymentResponse.js +2 -0
  128. package/dist/src/schemas/stripeAPIToken.d.ts +4 -0
  129. package/dist/src/schemas/stripeAPIToken.js +2 -0
  130. package/dist/src/schemas/stripePluginOptions.d.ts +31 -0
  131. package/dist/src/schemas/stripePluginOptions.js +2 -0
  132. package/dist/src/stripeAPI.d.ts +32 -0
  133. package/dist/src/stripeAPI.js +163 -0
  134. package/dist/src/stripePlguinContext.d.ts +5 -0
  135. package/dist/src/stripePlguinContext.js +2 -0
  136. package/dist/src/stripePluginContext.d.ts +6 -0
  137. package/dist/src/stripePluginContext.js +2 -0
  138. package/dist/src/templates/connect-done.d.ts +1 -0
  139. package/dist/src/templates/connect-done.js +4 -0
  140. package/dist/src/templates/error.d.ts +1 -0
  141. package/dist/src/templates/error.js +4 -0
  142. package/dist/src/templates/master.d.ts +1 -0
  143. package/dist/src/templates/master.js +4 -0
  144. package/dist/src/templates/pay-enter-card.d.ts +1 -0
  145. package/dist/src/templates/pay-enter-card.js +4 -0
  146. package/dist/src/templates/pay-select-card.d.ts +1 -0
  147. package/dist/src/templates/pay-select-card.js +4 -0
  148. package/dist/src/templates/setup-card.d.ts +1 -0
  149. package/dist/src/templates/setup-card.js +4 -0
  150. package/dist/src/templates/setup-done.d.ts +1 -0
  151. package/dist/src/templates/setup-done.js +4 -0
  152. package/dist/src/templates/style.d.ts +1 -0
  153. package/dist/src/templates/style.js +4 -0
  154. package/dist/src/utils/bcrypt.d.ts +2 -0
  155. package/dist/src/utils/bcrypt.js +28 -0
  156. package/nodemon.json +7 -0
  157. package/package.json +34 -0
  158. package/readme.md +57 -0
  159. package/src/index.ts +100 -0
  160. package/src/s3Client.ts +150 -0
  161. package/src/s3PluginContext.ts +8 -0
  162. package/src/schemas/ListObjectsResponse.ts +3 -0
  163. package/src/schemas/s3ClientOptions.ts +7 -0
  164. package/src/schemas/s3PluginOptions.ts +11 -0
  165. package/tsconfig.json +23 -0
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = exports.Route = void 0;
40
+ var flink_1 = require("@flink-app/flink");
41
+ var ManagementUserViewModel_1 = require("../../schemas/ManagementUserViewModel");
42
+ exports.Route = {
43
+ path: "/user/:userid",
44
+ method: flink_1.HttpMethod.get,
45
+ };
46
+ // type Params = {
47
+ // userid: string;
48
+ // };
49
+ var GetUserByUserid = function (_a) {
50
+ var ctx = _a.ctx, req = _a.req;
51
+ return __awaiter(void 0, void 0, void 0, function () {
52
+ var user;
53
+ return __generator(this, function (_b) {
54
+ switch (_b.label) {
55
+ case 0: return [4 /*yield*/, ctx.repos.managementuserRepo.getById(req.params.userid)];
56
+ case 1:
57
+ user = _b.sent();
58
+ if (user == null) {
59
+ return [2 /*return*/, flink_1.notFound()];
60
+ }
61
+ return [2 /*return*/, {
62
+ data: ManagementUserViewModel_1.GetManagementUserViewModel(user),
63
+ status: 200,
64
+ }];
65
+ }
66
+ });
67
+ });
68
+ };
69
+ exports.default = GetUserByUserid;
70
+ exports.__assumedHttpMethod = "get", exports.__file = "GetByUserid.ts", exports.__query = [], exports.__params = [];
71
+ exports.__schemas = { reqSchema: { "type": "object", "additionalProperties": false, "properties": {} }, resSchema: { "type": "object", "additionalProperties": false, "properties": { "_id": { "type": "string" }, "username": { "type": "string" } }, "required": ["_id", "username"] } };
@@ -0,0 +1,9 @@
1
+ import { Handler } from "@flink-app/flink";
2
+ import { GetUserListReq } from "../../schemas/User/GetListReq";
3
+ import { GetUserListRes } from "../../schemas/User/GetListRes";
4
+ import { Ctx } from "../../Ctx";
5
+ declare type Params = {};
6
+ declare const GetUserList: Handler<Ctx, GetUserListReq, GetUserListRes, Params>;
7
+ export default GetUserList;
8
+ export declare const __assumedHttpMethod = "get", __file = "GetList.ts", __query: never[], __params: never[];
9
+ export declare const __schemas: any;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = void 0;
40
+ var ManagementUserViewModel_1 = require("../../schemas/ManagementUserViewModel");
41
+ var GetUserList = function (_a) {
42
+ var ctx = _a.ctx, req = _a.req;
43
+ return __awaiter(void 0, void 0, void 0, function () {
44
+ var repo, users;
45
+ return __generator(this, function (_b) {
46
+ switch (_b.label) {
47
+ case 0:
48
+ repo = ctx.repos.managementuserRepo;
49
+ return [4 /*yield*/, repo.findAll()];
50
+ case 1:
51
+ users = _b.sent();
52
+ return [2 /*return*/, {
53
+ data: {
54
+ users: users.map(ManagementUserViewModel_1.GetManagementUserViewModel)
55
+ },
56
+ status: 200
57
+ }];
58
+ }
59
+ });
60
+ });
61
+ };
62
+ exports.default = GetUserList;
63
+ exports.__assumedHttpMethod = "get", exports.__file = "GetList.ts", exports.__query = [], exports.__params = [];
64
+ exports.__schemas = { reqSchema: { "type": "object", "additionalProperties": false, "properties": {} }, resSchema: { "type": "object", "additionalProperties": false, "properties": { "users": { "type": "array", "items": { "type": "object", "additionalProperties": false, "properties": { "_id": { "type": "string" }, "username": { "type": "string" } }, "required": ["_id", "username"] } } }, "required": ["users"] } };
@@ -0,0 +1,8 @@
1
+ import { Handler } from "@flink-app/flink";
2
+ import { Ctx } from "../../Ctx";
3
+ import { GetUserMeReq } from "../../schemas/User/GetMeReq";
4
+ import { GetUserMeRes } from "../../schemas/User/GetMeRes";
5
+ declare const GetUserMe: Handler<Ctx, GetUserMeReq, GetUserMeRes>;
6
+ export default GetUserMe;
7
+ export declare const __assumedHttpMethod = "get", __file = "GetMe.ts", __query: never[], __params: never[];
8
+ export declare const __schemas: any;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __rest = (this && this.__rest) || function (s, e) {
39
+ var t = {};
40
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
41
+ t[p] = s[p];
42
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
43
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
44
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
45
+ t[p[i]] = s[p[i]];
46
+ }
47
+ return t;
48
+ };
49
+ var __importDefault = (this && this.__importDefault) || function (mod) {
50
+ return (mod && mod.__esModule) ? mod : { "default": mod };
51
+ };
52
+ Object.defineProperty(exports, "__esModule", { value: true });
53
+ exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = void 0;
54
+ var flink_1 = require("@flink-app/flink");
55
+ var jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
56
+ var GetUserMe = function (_a) {
57
+ var ctx = _a.ctx, req = _a.req;
58
+ return __awaiter(void 0, void 0, void 0, function () {
59
+ var user, iat, rest;
60
+ return __generator(this, function (_b) {
61
+ try {
62
+ user = jsonwebtoken_1.default.verify(req.headers["management-token"], ctx.plugins.managementApi.jwtSecret);
63
+ iat = user.iat, rest = __rest(user, ["iat"]);
64
+ return [2 /*return*/, {
65
+ data: {
66
+ token: req.headers["management-token"],
67
+ user: rest
68
+ },
69
+ status: 200
70
+ }];
71
+ }
72
+ catch (ex) {
73
+ return [2 /*return*/, flink_1.unauthorized()];
74
+ }
75
+ return [2 /*return*/];
76
+ });
77
+ });
78
+ };
79
+ exports.default = GetUserMe;
80
+ exports.__assumedHttpMethod = "get", exports.__file = "GetMe.ts", exports.__query = [], exports.__params = [];
81
+ exports.__schemas = { reqSchema: { "type": "object", "additionalProperties": false, "properties": {} }, resSchema: { "type": "object", "additionalProperties": false, "properties": { "user": { "type": "object", "additionalProperties": false, "properties": { "_id": { "type": "string" }, "username": { "type": "string" } }, "required": ["_id", "username"] }, "token": { "type": "string" } }, "required": ["token", "user"] } };
@@ -0,0 +1,10 @@
1
+ import { Handler, RouteProps } from "@flink-app/flink";
2
+ import { Ctx } from "../../Ctx";
3
+ import { PostUserReq } from "../../schemas/User/PostReq";
4
+ import { PostUserRes } from "../../schemas/User/PostRes";
5
+ export declare const Route: RouteProps;
6
+ declare type Params = {};
7
+ declare const PostUser: Handler<Ctx, PostUserReq, PostUserRes, Params>;
8
+ export default PostUser;
9
+ export declare const __assumedHttpMethod = "post", __file = "Post.ts", __query: never[], __params: never[];
10
+ export declare const __schemas: any;
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = exports.Route = void 0;
40
+ var flink_1 = require("@flink-app/flink");
41
+ var bcrypt_1 = require("../../utils/bcrypt");
42
+ var ManagementUserViewModel_1 = require("../../schemas/ManagementUserViewModel");
43
+ exports.Route = {
44
+ path: "/user",
45
+ method: flink_1.HttpMethod.post,
46
+ };
47
+ var PostUser = function (_a) {
48
+ var ctx = _a.ctx, req = _a.req;
49
+ return __awaiter(void 0, void 0, void 0, function () {
50
+ var existingUser, salt, hash, obj, user;
51
+ return __generator(this, function (_b) {
52
+ switch (_b.label) {
53
+ case 0:
54
+ if (req.body.username.length == 0 || req.body.password.length == 0) {
55
+ return [2 /*return*/, flink_1.badRequest("Username and password must be specified")];
56
+ }
57
+ return [4 /*yield*/, ctx.repos.managementuserRepo.getOne({ username: req.body.username })];
58
+ case 1:
59
+ existingUser = _b.sent();
60
+ if (existingUser != null) {
61
+ return [2 /*return*/, flink_1.conflict("Username already taken")];
62
+ }
63
+ return [4 /*yield*/, bcrypt_1.genSalt(10)];
64
+ case 2:
65
+ salt = _b.sent();
66
+ return [4 /*yield*/, bcrypt_1.encrypt(req.body.password, salt)];
67
+ case 3:
68
+ hash = _b.sent();
69
+ obj = {
70
+ username: req.body.username,
71
+ password: hash,
72
+ salt: salt
73
+ };
74
+ return [4 /*yield*/, ctx.repos.managementuserRepo.create(obj)];
75
+ case 4:
76
+ user = _b.sent();
77
+ return [2 /*return*/, {
78
+ data: ManagementUserViewModel_1.GetManagementUserViewModel(user),
79
+ status: 200
80
+ }];
81
+ }
82
+ });
83
+ });
84
+ };
85
+ exports.default = PostUser;
86
+ exports.__assumedHttpMethod = "post", exports.__file = "Post.ts", exports.__query = [], exports.__params = [];
87
+ exports.__schemas = { reqSchema: { "type": "object", "additionalProperties": false, "properties": { "username": { "type": "string" }, "password": { "type": "string" } }, "required": ["password", "username"] }, resSchema: { "type": "object", "additionalProperties": false, "properties": { "_id": { "type": "string" }, "username": { "type": "string" } }, "required": ["_id", "username"] } };
@@ -0,0 +1,10 @@
1
+ import { Handler, RouteProps } from "@flink-app/flink";
2
+ import { Ctx } from "../../Ctx";
3
+ import { PostUserLoginReq } from "../../schemas/User/PostLoginReq";
4
+ import { PostUserLoginRes } from "../../schemas/User/PostLoginRes";
5
+ export declare const Route: RouteProps;
6
+ declare type Params = {};
7
+ declare const PostUserLogin: Handler<Ctx, PostUserLoginReq, PostUserLoginRes, Params>;
8
+ export default PostUserLogin;
9
+ export declare const __assumedHttpMethod = "post", __file = "PostLogin.ts", __query: never[], __params: never[];
10
+ export declare const __schemas: any;
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = exports.Route = void 0;
43
+ var flink_1 = require("@flink-app/flink");
44
+ var jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
45
+ var ManagementUserViewModel_1 = require("../../schemas/ManagementUserViewModel");
46
+ var bcrypt_1 = require("../../utils/bcrypt");
47
+ exports.Route = {
48
+ path: "/user/login",
49
+ method: flink_1.HttpMethod.post,
50
+ };
51
+ var PostUserLogin = function (_a) {
52
+ var ctx = _a.ctx, req = _a.req;
53
+ return __awaiter(void 0, void 0, void 0, function () {
54
+ var user, hashCandidate, viewUser, token;
55
+ return __generator(this, function (_b) {
56
+ switch (_b.label) {
57
+ case 0: return [4 /*yield*/, ctx.repos.managementuserRepo.getOne({
58
+ username: req.body.username,
59
+ })];
60
+ case 1:
61
+ user = _b.sent();
62
+ if (user == null) {
63
+ return [2 /*return*/, flink_1.unauthorized("Username or password invalid")];
64
+ }
65
+ return [4 /*yield*/, bcrypt_1.encrypt(req.body.password, user.salt)];
66
+ case 2:
67
+ hashCandidate = _b.sent();
68
+ if (hashCandidate !== user.password) {
69
+ return [2 /*return*/, flink_1.unauthorized("Username or password invalid")];
70
+ }
71
+ viewUser = ManagementUserViewModel_1.GetManagementUserViewModel(user);
72
+ token = jsonwebtoken_1.default.sign(viewUser, ctx.plugins.managementApi.jwtSecret);
73
+ return [2 /*return*/, {
74
+ data: {
75
+ user: viewUser,
76
+ token: token,
77
+ },
78
+ status: 200,
79
+ }];
80
+ }
81
+ });
82
+ });
83
+ };
84
+ exports.default = PostUserLogin;
85
+ exports.__assumedHttpMethod = "post", exports.__file = "PostLogin.ts", exports.__query = [], exports.__params = [];
86
+ exports.__schemas = { reqSchema: { "type": "object", "additionalProperties": false, "properties": { "username": { "type": "string" }, "password": { "type": "string" } }, "required": ["password", "username"] }, resSchema: { "type": "object", "additionalProperties": false, "properties": { "user": { "type": "object", "additionalProperties": false, "properties": { "_id": { "type": "string" }, "username": { "type": "string" } }, "required": ["_id", "username"] }, "token": { "type": "string" } }, "required": ["token", "user"] } };
@@ -0,0 +1,9 @@
1
+ import { Handler, RouteProps } from "@flink-app/flink";
2
+ import { Ctx } from "../../Ctx";
3
+ import { PutUserByUseridReq } from "../../schemas/User/PutByUseridReq";
4
+ import { PutUserByUseridRes } from "../../schemas/User/PutByUseridRes";
5
+ export declare const Route: RouteProps;
6
+ declare const PutUserByUserid: Handler<Ctx, PutUserByUseridReq, PutUserByUseridRes>;
7
+ export default PutUserByUserid;
8
+ export declare const __assumedHttpMethod = "put", __file = "PutByUserid.ts", __query: never[], __params: never[];
9
+ export declare const __schemas: any;
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = exports.Route = void 0;
40
+ var flink_1 = require("@flink-app/flink");
41
+ var ManagementUserViewModel_1 = require("../../schemas/ManagementUserViewModel");
42
+ var bcrypt_1 = require("../../utils/bcrypt");
43
+ exports.Route = {
44
+ path: "/user/:userid",
45
+ method: flink_1.HttpMethod.put,
46
+ };
47
+ // type Params = {
48
+ // userid: string;
49
+ // };
50
+ var PutUserByUserid = function (_a) {
51
+ var ctx = _a.ctx, req = _a.req;
52
+ return __awaiter(void 0, void 0, void 0, function () {
53
+ var model, existingUser, salt, hash, updated;
54
+ return __generator(this, function (_b) {
55
+ switch (_b.label) {
56
+ case 0:
57
+ model = req.body;
58
+ if (!(model.username != null)) return [3 /*break*/, 2];
59
+ return [4 /*yield*/, ctx.repos.managementuserRepo.getOne({
60
+ username: model.username,
61
+ })];
62
+ case 1:
63
+ existingUser = _b.sent();
64
+ if (existingUser != null) {
65
+ if (existingUser._id != req.params.userid) {
66
+ return [2 /*return*/, flink_1.conflict("Username already taken")];
67
+ }
68
+ }
69
+ _b.label = 2;
70
+ case 2:
71
+ if (!(model.password != null)) return [3 /*break*/, 5];
72
+ return [4 /*yield*/, bcrypt_1.genSalt(10)];
73
+ case 3:
74
+ salt = _b.sent();
75
+ return [4 /*yield*/, bcrypt_1.encrypt(model.password, salt)];
76
+ case 4:
77
+ hash = _b.sent();
78
+ model.password = hash;
79
+ model.salt = salt;
80
+ _b.label = 5;
81
+ case 5: return [4 /*yield*/, ctx.repos.managementuserRepo.updateOne(req.params.userid, model)];
82
+ case 6:
83
+ updated = _b.sent();
84
+ if (updated == null) {
85
+ return [2 /*return*/, flink_1.notFound()];
86
+ }
87
+ return [2 /*return*/, {
88
+ data: ManagementUserViewModel_1.GetManagementUserViewModel(updated),
89
+ status: 200,
90
+ }];
91
+ }
92
+ });
93
+ });
94
+ };
95
+ exports.default = PutUserByUserid;
96
+ exports.__assumedHttpMethod = "put", exports.__file = "PutByUserid.ts", exports.__query = [], exports.__params = [];
97
+ exports.__schemas = { reqSchema: { "type": "object", "additionalProperties": false, "properties": { "username": { "type": "string" }, "password": { "type": "string" } } }, resSchema: { "type": "object", "additionalProperties": false, "properties": { "_id": { "type": "string" }, "username": { "type": "string" } }, "required": ["_id", "username"] } };
@@ -0,0 +1,4 @@
1
+ import { FlinkPlugin } from "@flink-app/flink";
2
+ import { stripePluginOptions } from "./schemas/stripePluginOptions";
3
+ export * from "./stripePluginContext";
4
+ export declare const stripePlugin: (options: stripePluginOptions) => FlinkPlugin;