@blockchyp/blockchyp-ts 1.0.0

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 (207) hide show
  1. package/.eslintrc.json +20 -0
  2. package/LICENSE +21 -0
  3. package/README.md +4314 -0
  4. package/index.js +24 -0
  5. package/index.ts +3 -0
  6. package/itest/ActivateTerminalITestSpec.js +87 -0
  7. package/itest/ActivateTerminalITestSpec.ts +58 -0
  8. package/itest/AddTestMerchantITestSpec.js +89 -0
  9. package/itest/AddTestMerchantITestSpec.ts +60 -0
  10. package/itest/BatchHistoryITestSpec.js +101 -0
  11. package/itest/BatchHistoryITestSpec.ts +73 -0
  12. package/itest/BooleanPromptITestSpec.js +104 -0
  13. package/itest/BooleanPromptITestSpec.ts +76 -0
  14. package/itest/CancelPaymentLinkITestSpec.js +116 -0
  15. package/itest/CancelPaymentLinkITestSpec.ts +93 -0
  16. package/itest/CaptureSignatureITestSpec.js +101 -0
  17. package/itest/CaptureSignatureITestSpec.ts +73 -0
  18. package/itest/DeactivateTerminalITestSpec.js +82 -0
  19. package/itest/DeactivateTerminalITestSpec.ts +52 -0
  20. package/itest/DeleteBrandingAssetITestSpec.js +96 -0
  21. package/itest/DeleteBrandingAssetITestSpec.ts +69 -0
  22. package/itest/DeleteCustomerITestSpec.js +102 -0
  23. package/itest/DeleteCustomerITestSpec.ts +75 -0
  24. package/itest/DeleteMediaAssetITestSpec.js +100 -0
  25. package/itest/DeleteMediaAssetITestSpec.ts +71 -0
  26. package/itest/DeleteQueuedTransactionITestSpec.js +117 -0
  27. package/itest/DeleteQueuedTransactionITestSpec.ts +89 -0
  28. package/itest/DeleteSlideShowITestSpec.js +96 -0
  29. package/itest/DeleteSlideShowITestSpec.ts +69 -0
  30. package/itest/DeleteSurveyQuestionITestSpec.js +97 -0
  31. package/itest/DeleteSurveyQuestionITestSpec.ts +70 -0
  32. package/itest/DeleteTestMerchantITestSpec.js +96 -0
  33. package/itest/DeleteTestMerchantITestSpec.ts +69 -0
  34. package/itest/DeleteTokenITestSpec.js +102 -0
  35. package/itest/DeleteTokenITestSpec.ts +75 -0
  36. package/itest/EmptyBrandingAssetITestSpec.js +85 -0
  37. package/itest/EmptyBrandingAssetITestSpec.ts +57 -0
  38. package/itest/EmptySlideShowITestSpec.js +87 -0
  39. package/itest/EmptySlideShowITestSpec.ts +58 -0
  40. package/itest/GatewayTimeoutITestSpec.js +103 -0
  41. package/itest/GatewayTimeoutITestSpec.ts +73 -0
  42. package/itest/GetCustomerITestSpec.js +102 -0
  43. package/itest/GetCustomerITestSpec.ts +75 -0
  44. package/itest/GetMerchantsITestSpec.js +84 -0
  45. package/itest/GetMerchantsITestSpec.ts +56 -0
  46. package/itest/InviteMerchantUserITestSpec.js +86 -0
  47. package/itest/InviteMerchantUserITestSpec.ts +58 -0
  48. package/itest/LinkTokenITestSpec.js +103 -0
  49. package/itest/LinkTokenITestSpec.ts +76 -0
  50. package/itest/ListQueuedTransactionsITestSpec.js +116 -0
  51. package/itest/ListQueuedTransactionsITestSpec.ts +88 -0
  52. package/itest/ListTerminalsITestSpec.js +83 -0
  53. package/itest/ListTerminalsITestSpec.ts +56 -0
  54. package/itest/MediaAssetITestSpec.js +105 -0
  55. package/itest/MediaAssetITestSpec.ts +75 -0
  56. package/itest/MediaITestSpec.js +83 -0
  57. package/itest/MediaITestSpec.ts +56 -0
  58. package/itest/MediaUploadITestSpec.js +94 -0
  59. package/itest/MediaUploadITestSpec.ts +63 -0
  60. package/itest/MerchantCredentialGenerationITestSpec.js +85 -0
  61. package/itest/MerchantCredentialGenerationITestSpec.ts +57 -0
  62. package/itest/MerchantInvoiceDetailITestSpec.js +84 -0
  63. package/itest/MerchantInvoiceDetailITestSpec.ts +56 -0
  64. package/itest/MerchantInvoicesITestSpec.js +84 -0
  65. package/itest/MerchantInvoicesITestSpec.ts +56 -0
  66. package/itest/MerchantPlatformsITestSpec.js +96 -0
  67. package/itest/MerchantPlatformsITestSpec.ts +69 -0
  68. package/itest/MerchantProfileITestSpec.js +84 -0
  69. package/itest/MerchantProfileITestSpec.ts +56 -0
  70. package/itest/MerchantUsersITestSpec.js +83 -0
  71. package/itest/MerchantUsersITestSpec.ts +56 -0
  72. package/itest/NewTransactionDisplayITestSpec.js +115 -0
  73. package/itest/NewTransactionDisplayITestSpec.ts +92 -0
  74. package/itest/PANChargeITestSpec.js +118 -0
  75. package/itest/PANChargeITestSpec.ts +88 -0
  76. package/itest/PANEnrollITestSpec.js +118 -0
  77. package/itest/PANEnrollITestSpec.ts +90 -0
  78. package/itest/PANPreauthITestSpec.js +116 -0
  79. package/itest/PANPreauthITestSpec.ts +87 -0
  80. package/itest/PartialRefundITestSpec.js +119 -0
  81. package/itest/PartialRefundITestSpec.ts +91 -0
  82. package/itest/PartnerCommissionBreakdownITestSpec.js +84 -0
  83. package/itest/PartnerCommissionBreakdownITestSpec.ts +56 -0
  84. package/itest/PartnerStatementDetailITestSpec.js +84 -0
  85. package/itest/PartnerStatementDetailITestSpec.ts +56 -0
  86. package/itest/PartnerStatementsITestSpec.js +84 -0
  87. package/itest/PartnerStatementsITestSpec.ts +56 -0
  88. package/itest/PaymentLinkStatusITestSpec.js +116 -0
  89. package/itest/PaymentLinkStatusITestSpec.ts +93 -0
  90. package/itest/PricingPolicyITestSpec.js +85 -0
  91. package/itest/PricingPolicyITestSpec.ts +57 -0
  92. package/itest/ResendPaymentLinkITestSpec.js +116 -0
  93. package/itest/ResendPaymentLinkITestSpec.ts +93 -0
  94. package/itest/SearchCustomerITestSpec.js +101 -0
  95. package/itest/SearchCustomerITestSpec.ts +75 -0
  96. package/itest/SendPaymentLinkITestSpec.js +107 -0
  97. package/itest/SendPaymentLinkITestSpec.ts +82 -0
  98. package/itest/SimpleBatchCloseITestSpec.js +101 -0
  99. package/itest/SimpleBatchCloseITestSpec.ts +73 -0
  100. package/itest/SimpleCaptureITestSpec.js +101 -0
  101. package/itest/SimpleCaptureITestSpec.ts +74 -0
  102. package/itest/SimpleGiftActivateITestSpec.js +104 -0
  103. package/itest/SimpleGiftActivateITestSpec.ts +75 -0
  104. package/itest/SimpleLocateITestSpec.js +85 -0
  105. package/itest/SimpleLocateITestSpec.ts +57 -0
  106. package/itest/SimpleMessageITestSpec.js +101 -0
  107. package/itest/SimpleMessageITestSpec.ts +73 -0
  108. package/itest/SimplePingITestSpec.js +100 -0
  109. package/itest/SimplePingITestSpec.ts +72 -0
  110. package/itest/SimpleRefundITestSpec.js +118 -0
  111. package/itest/SimpleRefundITestSpec.ts +90 -0
  112. package/itest/SimpleReversalITestSpec.js +103 -0
  113. package/itest/SimpleReversalITestSpec.ts +75 -0
  114. package/itest/SimpleVoidITestSpec.js +103 -0
  115. package/itest/SimpleVoidITestSpec.ts +75 -0
  116. package/itest/SlideShowITestSpec.js +98 -0
  117. package/itest/SlideShowITestSpec.ts +70 -0
  118. package/itest/SlideShowsITestSpec.js +95 -0
  119. package/itest/SlideShowsITestSpec.ts +69 -0
  120. package/itest/SurveyQuestionITestSpec.js +95 -0
  121. package/itest/SurveyQuestionITestSpec.ts +68 -0
  122. package/itest/SurveyQuestionsITestSpec.js +96 -0
  123. package/itest/SurveyQuestionsITestSpec.ts +70 -0
  124. package/itest/SurveyResultsITestSpec.js +95 -0
  125. package/itest/SurveyResultsITestSpec.ts +68 -0
  126. package/itest/TCDeleteTemplateITestSpec.js +98 -0
  127. package/itest/TCDeleteTemplateITestSpec.ts +70 -0
  128. package/itest/TCEntryITestSpec.js +103 -0
  129. package/itest/TCEntryITestSpec.ts +76 -0
  130. package/itest/TCLogITestSpec.js +83 -0
  131. package/itest/TCLogITestSpec.ts +56 -0
  132. package/itest/TCTemplateITestSpec.js +101 -0
  133. package/itest/TCTemplateITestSpec.ts +72 -0
  134. package/itest/TCTemplateUpdateITestSpec.js +91 -0
  135. package/itest/TCTemplateUpdateITestSpec.ts +61 -0
  136. package/itest/TCTemplatesITestSpec.js +83 -0
  137. package/itest/TCTemplatesITestSpec.ts +56 -0
  138. package/itest/TerminalBrandingITestSpec.js +83 -0
  139. package/itest/TerminalBrandingITestSpec.ts +56 -0
  140. package/itest/TerminalChargeITestSpec.js +113 -0
  141. package/itest/TerminalChargeITestSpec.ts +84 -0
  142. package/itest/TerminalClearITestSpec.js +100 -0
  143. package/itest/TerminalClearITestSpec.ts +72 -0
  144. package/itest/TerminalEBTBalanceITestSpec.js +103 -0
  145. package/itest/TerminalEBTBalanceITestSpec.ts +74 -0
  146. package/itest/TerminalEBTChargeITestSpec.js +115 -0
  147. package/itest/TerminalEBTChargeITestSpec.ts +86 -0
  148. package/itest/TerminalEnrollITestSpec.js +112 -0
  149. package/itest/TerminalEnrollITestSpec.ts +83 -0
  150. package/itest/TerminalGiftCardBalanceITestSpec.js +102 -0
  151. package/itest/TerminalGiftCardBalanceITestSpec.ts +73 -0
  152. package/itest/TerminalKeyedChargeITestSpec.js +114 -0
  153. package/itest/TerminalKeyedChargeITestSpec.ts +85 -0
  154. package/itest/TerminalManualEBTChargeITestSpec.js +116 -0
  155. package/itest/TerminalManualEBTChargeITestSpec.ts +87 -0
  156. package/itest/TerminalPreauthITestSpec.js +113 -0
  157. package/itest/TerminalPreauthITestSpec.ts +84 -0
  158. package/itest/TerminalQueuedTransactionITestSpec.js +108 -0
  159. package/itest/TerminalQueuedTransactionITestSpec.ts +78 -0
  160. package/itest/TerminalStatusITestSpec.js +100 -0
  161. package/itest/TerminalStatusITestSpec.ts +72 -0
  162. package/itest/TerminalTimeoutITestSpec.js +99 -0
  163. package/itest/TerminalTimeoutITestSpec.ts +70 -0
  164. package/itest/TermsAndConditionsITestSpec.js +105 -0
  165. package/itest/TermsAndConditionsITestSpec.ts +77 -0
  166. package/itest/TextPromptITestSpec.js +103 -0
  167. package/itest/TextPromptITestSpec.ts +74 -0
  168. package/itest/TokenMetadataITestSpec.js +102 -0
  169. package/itest/TokenMetadataITestSpec.ts +75 -0
  170. package/itest/TransactionHistoryITestSpec.js +101 -0
  171. package/itest/TransactionHistoryITestSpec.ts +73 -0
  172. package/itest/UnlinkTokenITestSpec.js +103 -0
  173. package/itest/UnlinkTokenITestSpec.ts +76 -0
  174. package/itest/UpdateBrandingAssetITestSpec.js +109 -0
  175. package/itest/UpdateBrandingAssetITestSpec.ts +80 -0
  176. package/itest/UpdateCustomerITestSpec.js +90 -0
  177. package/itest/UpdateCustomerITestSpec.ts +63 -0
  178. package/itest/UpdateMerchantITestSpec.js +92 -0
  179. package/itest/UpdateMerchantITestSpec.ts +65 -0
  180. package/itest/UpdateMerchantPlatformsITestSpec.js +98 -0
  181. package/itest/UpdateMerchantPlatformsITestSpec.ts +71 -0
  182. package/itest/UpdateSlideShowITestSpec.js +106 -0
  183. package/itest/UpdateSlideShowITestSpec.ts +78 -0
  184. package/itest/UpdateSurveyQuestionITestSpec.js +89 -0
  185. package/itest/UpdateSurveyQuestionITestSpec.ts +60 -0
  186. package/itest/UpdateTransactionDisplayITestSpec.js +115 -0
  187. package/itest/UpdateTransactionDisplayITestSpec.ts +92 -0
  188. package/itest/UploadStatusITestSpec.js +100 -0
  189. package/itest/UploadStatusITestSpec.ts +71 -0
  190. package/itest/support/aviato.png +0 -0
  191. package/itest/support/config.js +67 -0
  192. package/itest/support/config.ts +106 -0
  193. package/itest/support/jasmine.json +11 -0
  194. package/package.json +73 -0
  195. package/spec/CryptoSpec.js +35 -0
  196. package/spec/CryptoSpec.ts +35 -0
  197. package/spec/SanitySpec.js +26 -0
  198. package/spec/SanitySpec.ts +23 -0
  199. package/spec/support/jasmine.json +11 -0
  200. package/src/client.js +941 -0
  201. package/src/client.ts +1012 -0
  202. package/src/cryptoutils.js +89 -0
  203. package/src/cryptoutils.ts +80 -0
  204. package/src/global.js +9 -0
  205. package/src/global.ts +5 -0
  206. package/src/models.js +9382 -0
  207. package/src/models.ts +16509 -0
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Copyright 2019-2024 BlockChyp, Inc. All rights reserved. Use of this code is governed
3
+ * by a license that can be found in the LICENSE file.
4
+ *
5
+ * This file was generated automatically by the BlockChyp SDK Generator. Changes to this
6
+ * file will be lost every time the code is regenerated.
7
+ */
8
+ import * as fs from 'fs';
9
+ import { v4 as uuidv4 } from 'uuid';
10
+ import { Config } from './support/config';
11
+ import * as BlockChyp from '../index';
12
+
13
+ describe('UploadStatus', function () {
14
+ let originalTimeout: number;
15
+ let client: typeof BlockChyp.BlockChypClient;
16
+ Config.load();
17
+
18
+ beforeEach(function () {
19
+ originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
20
+ jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000;
21
+ });
22
+
23
+ it('checks the status of a file upload.', function (done) {
24
+ client = BlockChyp.newClient(Config.getCreds(""));
25
+ client.setGatewayHost(Config.getGatewayHost());
26
+ client.setTestGatewayHost(Config.getTestGatewayHost());
27
+ client.setDashboardHost(Config.getDashboardHost());
28
+
29
+ const testDelay = process.env.BC_TEST_DELAY;
30
+ let testDelayInt = 0;
31
+ if (testDelay) {
32
+ testDelayInt = parseInt(testDelay);
33
+ }
34
+
35
+ console.log('Running uploadStatus...');
36
+
37
+ setTimeout(async function () {
38
+ try {
39
+ // setup request object
40
+ const setupRequest = new BlockChyp.UploadMetadata();
41
+ setupRequest.fileName = 'aviato.png';
42
+ setupRequest.fileSize = 18843;
43
+ setupRequest.uploadId = uuidv4();
44
+ let setupResponse: BlockChyp.MediaMetadata = new BlockChyp.MediaMetadata();
45
+ const content = fs.readFileSync('support/aviato.png');
46
+ const setupHttpResponse = await client.uploadMedia(setupRequest, content);
47
+ if (setupHttpResponse.status !== 200) {
48
+ console.log('Error:', setupHttpResponse.statusText);
49
+ fail(setupHttpResponse.statusText);
50
+ done();
51
+ }
52
+ setupResponse = setupHttpResponse.data
53
+
54
+ // setup request object
55
+ const request = new BlockChyp.UploadStatusRequest();
56
+ request.uploadId = setupResponse.id;
57
+
58
+ const httpResponse = await client.uploadStatus(request)
59
+ const response: BlockChyp.UploadStatus = httpResponse.data;
60
+ // response assertions
61
+ expect(response.success).toBe(true);
62
+
63
+ } catch (error) {
64
+ console.log('Error:', error);
65
+ fail(error);
66
+ } finally {
67
+ done();
68
+ }
69
+ }, testDelayInt * 1000);
70
+ });
71
+ });
Binary file
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Config = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const is_windows_1 = __importDefault(require("is-windows"));
10
+ const ITestConfig = {
11
+ defaultTerminalAddress: '',
12
+ defaultTerminalName: '',
13
+ gatewayHost: '',
14
+ dashboardHost: '',
15
+ testGatewayHost: '',
16
+ apiKey: '',
17
+ bearerToken: '',
18
+ signingKey: '',
19
+ profiles: {},
20
+ load: function () {
21
+ let configHome = '';
22
+ if ((0, is_windows_1.default)()) {
23
+ configHome = process.env.userprofile || '';
24
+ }
25
+ else {
26
+ configHome = process.env.XDG_CONFIG_HOME || path_1.default.join(require('os').homedir(), '/.config');
27
+ }
28
+ const fileLocation = path_1.default.join(configHome, 'blockchyp', 'sdk-itest-config.json');
29
+ const data = fs_1.default.readFileSync(fileLocation, 'utf-8');
30
+ Object.assign(ITestConfig, JSON.parse(data));
31
+ },
32
+ getTerminalAddress: function () {
33
+ return ITestConfig.defaultTerminalAddress;
34
+ },
35
+ getTerminalName: function () {
36
+ return ITestConfig.defaultTerminalName;
37
+ },
38
+ getGatewayHost: function () {
39
+ return ITestConfig.gatewayHost;
40
+ },
41
+ getDashboardHost: function () {
42
+ return ITestConfig.dashboardHost;
43
+ },
44
+ getTestGatewayHost: function () {
45
+ return ITestConfig.testGatewayHost;
46
+ },
47
+ getApiKey: function () {
48
+ return ITestConfig.apiKey;
49
+ },
50
+ getBearerToken: function () {
51
+ return ITestConfig.bearerToken;
52
+ },
53
+ getSigningKey: function () {
54
+ return ITestConfig.signingKey;
55
+ },
56
+ getCreds: function (profile) {
57
+ if (profile) {
58
+ return ITestConfig.profiles[profile];
59
+ }
60
+ return {
61
+ apiKey: ITestConfig.apiKey,
62
+ bearerToken: ITestConfig.bearerToken,
63
+ signingKey: ITestConfig.signingKey,
64
+ };
65
+ },
66
+ };
67
+ exports.Config = ITestConfig;
@@ -0,0 +1,106 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import isWindows from 'is-windows';
4
+
5
+ interface ITestConfigData {
6
+ defaultTerminalAddress: string;
7
+ defaultTerminalName: string;
8
+ gatewayHost: string;
9
+ dashboardHost: string;
10
+ testGatewayHost: string;
11
+ apiKey: string;
12
+ bearerToken: string;
13
+ signingKey: string;
14
+ profiles: {
15
+ [key: string]: {
16
+ apiKey: string;
17
+ bearerToken: string;
18
+ signingKey: string;
19
+ };
20
+ };
21
+ }
22
+
23
+ interface ITestConfigFunctions {
24
+ load: () => void;
25
+ getTerminalAddress: () => string;
26
+ getTerminalName: () => string;
27
+ getGatewayHost: () => string;
28
+ getDashboardHost: () => string;
29
+ getTestGatewayHost: () => string;
30
+ getApiKey: () => string;
31
+ getBearerToken: () => string;
32
+ getSigningKey: () => string;
33
+ getCreds: (profile?: string) => { apiKey: string; bearerToken: string; signingKey: string };
34
+ }
35
+
36
+ type ITestConfig = ITestConfigData & ITestConfigFunctions;
37
+
38
+ const ITestConfig: ITestConfig = {
39
+ defaultTerminalAddress: '',
40
+ defaultTerminalName: '',
41
+ gatewayHost: '',
42
+ dashboardHost: '',
43
+ testGatewayHost: '',
44
+ apiKey: '',
45
+ bearerToken: '',
46
+ signingKey: '',
47
+ profiles: {},
48
+
49
+ load: function () {
50
+ let configHome = '';
51
+ if (isWindows()) {
52
+ configHome = process.env.userprofile || '';
53
+ } else {
54
+ configHome = process.env.XDG_CONFIG_HOME || path.join(require('os').homedir(), '/.config');
55
+ }
56
+
57
+ const fileLocation = path.join(configHome, 'blockchyp', 'sdk-itest-config.json');
58
+ const data = fs.readFileSync(fileLocation, 'utf-8');
59
+ Object.assign(ITestConfig, JSON.parse(data));
60
+ },
61
+
62
+ getTerminalAddress: function () {
63
+ return ITestConfig.defaultTerminalAddress;
64
+ },
65
+
66
+ getTerminalName: function () {
67
+ return ITestConfig.defaultTerminalName;
68
+ },
69
+
70
+ getGatewayHost: function () {
71
+ return ITestConfig.gatewayHost;
72
+ },
73
+
74
+ getDashboardHost: function () {
75
+ return ITestConfig.dashboardHost;
76
+ },
77
+
78
+ getTestGatewayHost: function () {
79
+ return ITestConfig.testGatewayHost;
80
+ },
81
+
82
+ getApiKey: function () {
83
+ return ITestConfig.apiKey;
84
+ },
85
+
86
+ getBearerToken: function () {
87
+ return ITestConfig.bearerToken;
88
+ },
89
+
90
+ getSigningKey: function () {
91
+ return ITestConfig.signingKey;
92
+ },
93
+
94
+ getCreds: function (profile?: string) {
95
+ if (profile) {
96
+ return ITestConfig.profiles[profile];
97
+ }
98
+ return {
99
+ apiKey: ITestConfig.apiKey,
100
+ bearerToken: ITestConfig.bearerToken,
101
+ signingKey: ITestConfig.signingKey,
102
+ };
103
+ },
104
+ };
105
+
106
+ export const Config: ITestConfig = ITestConfig;
@@ -0,0 +1,11 @@
1
+ {
2
+ "spec_dir": "spec",
3
+ "spec_files": [
4
+ "**/*[sS]pec.js"
5
+ ],
6
+ "helpers": [
7
+ "../node_modules/jasmine-expect/index.js"
8
+ ],
9
+ "stopSpecOnExpectationFailure": false,
10
+ "random": true
11
+ }
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@blockchyp/blockchyp-ts",
3
+ "version": "1.0.0",
4
+ "description": "BlockChyp Typescript Client",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "lint": "eslint . --ext .ts",
8
+ "clean": "tsc --build --clean",
9
+ "test": "npm run build && jasmine",
10
+ "build": "tsc",
11
+ "prod": "npm run lint && npm run build",
12
+ "prepare": "npm run prod"
13
+ },
14
+ "files": [
15
+ "index.ts",
16
+ "src/",
17
+ "spec/",
18
+ "itest/",
19
+ ".eslintrc.json"
20
+ ],
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/blockchyp/blockchyp-ts.git"
24
+ },
25
+ "keywords": [
26
+ "payments",
27
+ "blockchain"
28
+ ],
29
+ "author": "jeffreydpayne",
30
+ "license": "MIT",
31
+ "bugs": {
32
+ "url": "https://github.com/blockchyp/blockchyp-ts/issues"
33
+ },
34
+ "homepage": "https://github.com/blockchyp/blockchyp-ts#readme",
35
+ "devDependencies": {
36
+ "@types/aes-js": "^3.1.4",
37
+ "@types/create-hmac": "^1.1.3",
38
+ "@types/elliptic": "^6.4.18",
39
+ "@types/is-windows": "^1.0.2",
40
+ "@types/jasmine": "^5.1.4",
41
+ "@types/randombytes": "^2.0.3",
42
+ "@types/sha.js": "^2.4.4",
43
+ "@typescript-eslint/eslint-plugin": "^7.8.0",
44
+ "@typescript-eslint/parser": "^7.8.0",
45
+ "eslint": "^8.57.0",
46
+ "eslint-config-standard": "^11.0.0",
47
+ "eslint-plugin-import": "^2.12.0",
48
+ "eslint-plugin-node": "^6.0.1",
49
+ "eslint-plugin-promise": "^3.8.0",
50
+ "eslint-plugin-standard": "^3.1.0",
51
+ "fs": "0.0.1-security",
52
+ "is-windows": "^1.0.2",
53
+ "jasmine": "^3.99.0",
54
+ "jasmine-promises": "^0.4.1",
55
+ "ts-node": "^10.9.2",
56
+ "typescript": "^5.4.5",
57
+ "uuid": "^3.3.3"
58
+ },
59
+ "dependencies": {
60
+ "aes-js": "^3.1.1",
61
+ "axios": "^0.21.1",
62
+ "base32": "^0.0.7",
63
+ "bn.js": "^4.11.8",
64
+ "cached-path-relative": "^1.0.2",
65
+ "create-hmac": "^1.1.7",
66
+ "elliptic": "^6.5.5",
67
+ "moment": "^2.22.2",
68
+ "npm": "^6.13.4",
69
+ "randombytes": "^2.0.6",
70
+ "sha.js": "^2.4.11",
71
+ "uuidv4": "^6.2.13"
72
+ }
73
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const cryptoutils_1 = __importDefault(require("../src/cryptoutils"));
7
+ console.log(cryptoutils_1.default);
8
+ describe("Crypto", () => {
9
+ it("Should Exist", () => {
10
+ expect(cryptoutils_1.default).toBeDefined();
11
+ });
12
+ it("Should Generate Valid Headers", () => {
13
+ const creds = {
14
+ apiKey: "SGLATIFZD7PIMLAQJ2744MOEGI",
15
+ bearerToken: "FI2SWNNJHJVO6DBZEF26YEHHMY",
16
+ signingKey: "c3a8214c318dd470b0107d6c111f086b60ad695aaeb598bf7d1032eee95339a0"
17
+ };
18
+ const headers = cryptoutils_1.default.generateGatewayHeaders(creds);
19
+ console.log(JSON.stringify(headers));
20
+ expect(headers).toBeDefined();
21
+ });
22
+ it("Should Decrypt Go Encoded AES", () => {
23
+ const goCipher = '14b4e146a46ca9581d0900590b5d4bb9b945e7d3574834d239e9a695bc4ad5a7a7d05bc0e677f34cb8f125844b82a58c40ce2d1b07d44efe5a87a2dfc9cdd6d4';
24
+ const key = '7ef938ebbd24808f800bb368a4b97ba7';
25
+ const expectedPlainText = 'The quick brown fox jumped over the lazy dog.';
26
+ const plainText = cryptoutils_1.default.decrypt(key, goCipher);
27
+ expect(plainText).toBe(expectedPlainText);
28
+ });
29
+ it("Should Compute SHA 256 Hashes", () => {
30
+ const msg = 'f181167e704a9d06d66a2299b67882da7133d120c789e57d44041fa2a84ccad805a9f64788a905ac8734b990552c19070e18c09363b832680594b9aaa1dfc987179225d3cea9c8086aeaa04b3f72eb9fcf674dc6efd7ce158628b274677f0164beaf9eb0f54283b3fb7e592118db27069e231d1e4a3a500784ed123931db8240b7bbb99618b78348491bebe370b7850c459fb5390fb126b58c2212729d1e35c99880ca68e066949f03e6e56e261d15892828eddf250120e336a3580b5158ab32f5415bfce9ebeec70ef1e7bc8f50eec349d2175b9ec7dc4b6dfdc2201f4a55edf8becb860419871732c994e829caf7793ed695ca094a9154cb343659269addcf';
31
+ const expectedHash = 'f04e71b08dd61a4b9b88e695f09e4688b1d54dd0930450b52444bcd961b6ec6d';
32
+ const hash = cryptoutils_1.default.sha256Hash(msg);
33
+ expect(hash).toBe(expectedHash);
34
+ });
35
+ });
@@ -0,0 +1,35 @@
1
+ import Crypto from '../src/cryptoutils';
2
+
3
+ console.log(Crypto);
4
+
5
+ describe("Crypto", () => {
6
+ it("Should Exist", () => {
7
+ expect(Crypto).toBeDefined();
8
+ });
9
+
10
+ it("Should Generate Valid Headers", () => {
11
+ const creds = {
12
+ apiKey: "SGLATIFZD7PIMLAQJ2744MOEGI",
13
+ bearerToken: "FI2SWNNJHJVO6DBZEF26YEHHMY",
14
+ signingKey: "c3a8214c318dd470b0107d6c111f086b60ad695aaeb598bf7d1032eee95339a0"
15
+ };
16
+ const headers = Crypto.generateGatewayHeaders(creds);
17
+ console.log(JSON.stringify(headers));
18
+ expect(headers).toBeDefined();
19
+ });
20
+
21
+ it("Should Decrypt Go Encoded AES", () => {
22
+ const goCipher = '14b4e146a46ca9581d0900590b5d4bb9b945e7d3574834d239e9a695bc4ad5a7a7d05bc0e677f34cb8f125844b82a58c40ce2d1b07d44efe5a87a2dfc9cdd6d4';
23
+ const key = '7ef938ebbd24808f800bb368a4b97ba7';
24
+ const expectedPlainText = 'The quick brown fox jumped over the lazy dog.';
25
+ const plainText = Crypto.decrypt(key, goCipher);
26
+ expect(plainText).toBe(expectedPlainText);
27
+ });
28
+
29
+ it("Should Compute SHA 256 Hashes", () => {
30
+ const msg = 'f181167e704a9d06d66a2299b67882da7133d120c789e57d44041fa2a84ccad805a9f64788a905ac8734b990552c19070e18c09363b832680594b9aaa1dfc987179225d3cea9c8086aeaa04b3f72eb9fcf674dc6efd7ce158628b274677f0164beaf9eb0f54283b3fb7e592118db27069e231d1e4a3a500784ed123931db8240b7bbb99618b78348491bebe370b7850c459fb5390fb126b58c2212729d1e35c99880ca68e066949f03e6e56e261d15892828eddf250120e336a3580b5158ab32f5415bfce9ebeec70ef1e7bc8f50eec349d2175b9ec7dc4b6dfdc2201f4a55edf8becb860419871732c994e829caf7793ed695ca094a9154cb343659269addcf';
31
+ const expectedHash = 'f04e71b08dd61a4b9b88e695f09e4688b1d54dd0930450b52444bcd961b6ec6d';
32
+ const hash = Crypto.sha256Hash(msg);
33
+ expect(hash).toBe(expectedHash);
34
+ });
35
+ });
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const client_1 = __importDefault(require("../src/client"));
7
+ describe("SanityTest", () => {
8
+ it("Should Exist", () => {
9
+ expect(client_1.default).toBeDefined();
10
+ });
11
+ it("Should Fetch Heartbeat", (done) => {
12
+ client_1.default.setGatewayHost('https://api.dev.blockchyp.com/');
13
+ client_1.default.heartbeat()
14
+ .then((response) => {
15
+ const hb = response.data;
16
+ expect(hb.success).toBe(true);
17
+ expect(hb.timestamp).toBeDefined();
18
+ expect(hb.latestTick).toBeDefined();
19
+ done();
20
+ })
21
+ .catch((error) => {
22
+ console.log("Error:", error);
23
+ done();
24
+ });
25
+ });
26
+ });
@@ -0,0 +1,23 @@
1
+ import BlockChyp from '../src/client';
2
+
3
+ describe("SanityTest", () => {
4
+ it("Should Exist", () => {
5
+ expect(BlockChyp).toBeDefined();
6
+ });
7
+
8
+ it("Should Fetch Heartbeat", (done) => {
9
+ BlockChyp.setGatewayHost('https://api.dev.blockchyp.com/');
10
+ BlockChyp.heartbeat()
11
+ .then((response: any) => {
12
+ const hb = response.data;
13
+ expect(hb.success).toBe(true);
14
+ expect(hb.timestamp).toBeDefined();
15
+ expect(hb.latestTick).toBeDefined();
16
+ done();
17
+ })
18
+ .catch((error: any) => {
19
+ console.log("Error:", error);
20
+ done();
21
+ });
22
+ });
23
+ });
@@ -0,0 +1,11 @@
1
+ {
2
+ "spec_dir": "spec",
3
+ "spec_files": [
4
+ "**/*[sS]pec.?(m)js"
5
+ ],
6
+ "helpers": [
7
+ "helpers/**/*.?(m)js"
8
+ ],
9
+ "stopSpecOnExpectationFailure": false,
10
+ "random": true
11
+ }