@mathrunet/masamune 0.2.0 → 0.3.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.
- package/CHANGELOG.md +13 -0
- package/dist/functions/stripe.d.ts +1 -0
- package/dist/functions/stripe.js +1172 -0
- package/dist/functions/stripe.js.map +1 -0
- package/dist/functions/stripe_hook.d.ts +1 -0
- package/dist/functions/stripe_hook.js +574 -0
- package/dist/functions/stripe_hook.js.map +1 -0
- package/dist/functions/stripe_hook_connect.d.ts +1 -0
- package/dist/functions/stripe_hook_connect.js +140 -0
- package/dist/functions/stripe_hook_connect.js.map +1 -0
- package/dist/functions/stripe_hook_secure.d.ts +1 -0
- package/dist/functions/stripe_hook_secure.js +148 -0
- package/dist/functions/stripe_hook_secure.js.map +1 -0
- package/dist/functions.d.ts +56 -0
- package/dist/functions.js +56 -0
- package/dist/functions.js.map +1 -1
- package/dist/lib/send_gmail.d.ts +34 -0
- package/dist/lib/send_gmail.js +90 -0
- package/dist/lib/send_gmail.js.map +1 -0
- package/dist/lib/send_grid.d.ts +28 -0
- package/dist/lib/send_grid.js +79 -0
- package/dist/lib/send_grid.js.map +1 -0
- package/dist/lib/utils.d.ts +56 -0
- package/dist/lib/utils.js +124 -0
- package/dist/lib/utils.js.map +1 -0
- package/package.json +14 -4
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.send = void 0;
|
|
36
|
+
const functions = __importStar(require("firebase-functions"));
|
|
37
|
+
const sendgrid = __importStar(require("@sendgrid/mail"));
|
|
38
|
+
/**
|
|
39
|
+
* Send mail through SendGrid.
|
|
40
|
+
*
|
|
41
|
+
* SendGridでメールを送信します。
|
|
42
|
+
*
|
|
43
|
+
* @param {string} purchase.mail.sendgrid.api_key
|
|
44
|
+
* API key for SendGrid. Issue it according to the following procedure.
|
|
45
|
+
* https://mathru.notion.site/SendGrid-bb87b2ffa8174dbda944812f43856d6c
|
|
46
|
+
* SendGridのAPIキー。下記の手順で発行します。
|
|
47
|
+
* https://mathru.notion.site/SendGrid-bb87b2ffa8174dbda944812f43856d6c
|
|
48
|
+
*
|
|
49
|
+
* @param {string} from
|
|
50
|
+
* Sender's email address.
|
|
51
|
+
* 送信元メールアドレス。
|
|
52
|
+
*
|
|
53
|
+
* @param {string} to
|
|
54
|
+
* Email address to be sent to.
|
|
55
|
+
* 送信先メールアドレス。
|
|
56
|
+
*
|
|
57
|
+
* @param {string} title
|
|
58
|
+
* Email Title.
|
|
59
|
+
* メールタイトル。
|
|
60
|
+
*
|
|
61
|
+
* @param {string} content
|
|
62
|
+
* Email content.
|
|
63
|
+
* メール本文。
|
|
64
|
+
*/
|
|
65
|
+
function send(from, to, title, content) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
const config = functions.config().mail;
|
|
68
|
+
sendgrid.setApiKey(config.sendgrid.api_key);
|
|
69
|
+
const msg = {
|
|
70
|
+
to: to,
|
|
71
|
+
from: from,
|
|
72
|
+
subject: title,
|
|
73
|
+
text: content,
|
|
74
|
+
};
|
|
75
|
+
yield sendgrid.send(msg);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
exports.send = send;
|
|
79
|
+
//# sourceMappingURL=send_grid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send_grid.js","sourceRoot":"","sources":["../../src/lib/send_grid.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAgD;AAChD,yDAA2C;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,SAAsB,IAAI,CACxB,IAAY,EACZ,EAAU,EACV,KAAa,EACb,OAAe;;QAEf,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC;QACvC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC5C,MAAM,GAAG,GAAG;YACV,EAAE,EAAE,EAAE;YACN,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,KAAK;YACd,IAAI,EAAE,OAAO;SACd,CAAC;QACF,MAAM,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;CAAA;AAfD,oBAeC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts strings, numbers, etc. to the appropriate type.
|
|
3
|
+
*
|
|
4
|
+
* 文字列や数値などを適切な型に変換します。
|
|
5
|
+
*
|
|
6
|
+
* @param {string | number} value
|
|
7
|
+
* Strings and numbers.
|
|
8
|
+
* 文字列か数値。
|
|
9
|
+
*
|
|
10
|
+
* @return {bool | number | string}
|
|
11
|
+
* If it is a string, a numeric value is returned;
|
|
12
|
+
* otherwise, the input value is returned.
|
|
13
|
+
* 文字列なら数値、そうでなければ入力値が返却されます。
|
|
14
|
+
*/
|
|
15
|
+
export declare function parse(value: string | number): string | number | boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Encrypts a string.
|
|
18
|
+
* 文字列を暗号化します。
|
|
19
|
+
*
|
|
20
|
+
* @param {string} raw
|
|
21
|
+
* The string to encrypt.
|
|
22
|
+
* 暗号化する文字列。
|
|
23
|
+
*
|
|
24
|
+
* @param {string} key
|
|
25
|
+
* Encryption key #1. (32 bytes)
|
|
26
|
+
* 暗号化キー1。(32バイト)
|
|
27
|
+
*
|
|
28
|
+
* @param {string} ivKey
|
|
29
|
+
* Encryption key 2. (16 bytes)
|
|
30
|
+
* 暗号化キー2。(16バイト)
|
|
31
|
+
*
|
|
32
|
+
* @return {string}
|
|
33
|
+
* Encrypted string.
|
|
34
|
+
* 暗号化された文字列。
|
|
35
|
+
*/
|
|
36
|
+
export declare function encrypt(raw: string, key: string, ivKey: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Decrypts a string.
|
|
39
|
+
* 文字列を復号化します。
|
|
40
|
+
*
|
|
41
|
+
* @param {string} encrypted
|
|
42
|
+
* The string to encrypted.
|
|
43
|
+
* 暗号化された文字列。
|
|
44
|
+
*
|
|
45
|
+
* @param {string} key
|
|
46
|
+
* Encryption key #1. (32 bytes)
|
|
47
|
+
* 暗号化キー1。(32バイト)
|
|
48
|
+
* @param {string} ivKey
|
|
49
|
+
* Encryption key 2. (16 bytes)
|
|
50
|
+
* 暗号化キー2。(16バイト)
|
|
51
|
+
*
|
|
52
|
+
* @return {string}
|
|
53
|
+
* Decrypted string.
|
|
54
|
+
* 復号化された文字列。
|
|
55
|
+
*/
|
|
56
|
+
export declare function decrypt(encrypted: string, key: string, ivKey: string): string;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.decrypt = exports.encrypt = exports.parse = void 0;
|
|
27
|
+
const crypto = __importStar(require("crypto"));
|
|
28
|
+
/**
|
|
29
|
+
* Converts strings, numbers, etc. to the appropriate type.
|
|
30
|
+
*
|
|
31
|
+
* 文字列や数値などを適切な型に変換します。
|
|
32
|
+
*
|
|
33
|
+
* @param {string | number} value
|
|
34
|
+
* Strings and numbers.
|
|
35
|
+
* 文字列か数値。
|
|
36
|
+
*
|
|
37
|
+
* @return {bool | number | string}
|
|
38
|
+
* If it is a string, a numeric value is returned;
|
|
39
|
+
* otherwise, the input value is returned.
|
|
40
|
+
* 文字列なら数値、そうでなければ入力値が返却されます。
|
|
41
|
+
*/
|
|
42
|
+
function parse(value) {
|
|
43
|
+
if (typeof value === "string") {
|
|
44
|
+
if (value === "false") {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
else if (value === "true") {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
else if (value.match(new RegExp("^[0-9]+$"))) {
|
|
51
|
+
const i = parseInt(value);
|
|
52
|
+
if (isNaN(i)) {
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
return i;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
return value;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.parse = parse;
|
|
68
|
+
/**
|
|
69
|
+
* Encrypts a string.
|
|
70
|
+
* 文字列を暗号化します。
|
|
71
|
+
*
|
|
72
|
+
* @param {string} raw
|
|
73
|
+
* The string to encrypt.
|
|
74
|
+
* 暗号化する文字列。
|
|
75
|
+
*
|
|
76
|
+
* @param {string} key
|
|
77
|
+
* Encryption key #1. (32 bytes)
|
|
78
|
+
* 暗号化キー1。(32バイト)
|
|
79
|
+
*
|
|
80
|
+
* @param {string} ivKey
|
|
81
|
+
* Encryption key 2. (16 bytes)
|
|
82
|
+
* 暗号化キー2。(16バイト)
|
|
83
|
+
*
|
|
84
|
+
* @return {string}
|
|
85
|
+
* Encrypted string.
|
|
86
|
+
* 暗号化された文字列。
|
|
87
|
+
*/
|
|
88
|
+
function encrypt(raw, key, ivKey) {
|
|
89
|
+
const iv = Buffer.from(ivKey);
|
|
90
|
+
const cipher = crypto.createCipheriv("aes-256-cbc", Buffer.from(key), iv);
|
|
91
|
+
let encrypted = cipher.update(raw);
|
|
92
|
+
encrypted = Buffer.concat([encrypted, cipher.final()]);
|
|
93
|
+
return encrypted.toString("hex");
|
|
94
|
+
}
|
|
95
|
+
exports.encrypt = encrypt;
|
|
96
|
+
/**
|
|
97
|
+
* Decrypts a string.
|
|
98
|
+
* 文字列を復号化します。
|
|
99
|
+
*
|
|
100
|
+
* @param {string} encrypted
|
|
101
|
+
* The string to encrypted.
|
|
102
|
+
* 暗号化された文字列。
|
|
103
|
+
*
|
|
104
|
+
* @param {string} key
|
|
105
|
+
* Encryption key #1. (32 bytes)
|
|
106
|
+
* 暗号化キー1。(32バイト)
|
|
107
|
+
* @param {string} ivKey
|
|
108
|
+
* Encryption key 2. (16 bytes)
|
|
109
|
+
* 暗号化キー2。(16バイト)
|
|
110
|
+
*
|
|
111
|
+
* @return {string}
|
|
112
|
+
* Decrypted string.
|
|
113
|
+
* 復号化された文字列。
|
|
114
|
+
*/
|
|
115
|
+
function decrypt(encrypted, key, ivKey) {
|
|
116
|
+
const iv = Buffer.from(ivKey);
|
|
117
|
+
const encryptedText = Buffer.from(encrypted, "hex");
|
|
118
|
+
const decipher = crypto.createDecipheriv("aes-256-cbc", Buffer.from(key), iv);
|
|
119
|
+
let decrypted = decipher.update(encryptedText);
|
|
120
|
+
decrypted = Buffer.concat([decrypted, decipher.final()]);
|
|
121
|
+
return decrypted.toString();
|
|
122
|
+
}
|
|
123
|
+
exports.decrypt = decr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AC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC;AAND,0BAMC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,OAAO,CAAC,SAAkB,EAAE,GAAY,EAAE,KAAc;IACtE,MAAM,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC9B,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IACpD,MAAM,QAAQ,GAAG,MAAM,CAAC,gBAAgB,CAAC,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;IAC9E,IAAI,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAC/C,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACzD,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;AAC9B,CAAC;AAPD,0BAOC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mathrunet/masamune",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Manages packages for the server portion (NodeJS) of the Masamune framework.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
"prepare": "npm run build",
|
|
10
10
|
"test": "jest",
|
|
11
11
|
"postversion": "npm run changelog",
|
|
12
|
-
"changelog": "conventional-changelog -p eslint -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md && git commit -m 'chore(release): publish package'"
|
|
12
|
+
"changelog": "conventional-changelog -p eslint -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md && git commit -m 'chore(release): publish package'",
|
|
13
|
+
"minor_update": "npm verion minor",
|
|
14
|
+
"major_update": "npm verion major",
|
|
15
|
+
"patch_update": "npm verion patch"
|
|
13
16
|
},
|
|
14
17
|
"repository": {
|
|
15
18
|
"type": "git",
|
|
@@ -29,16 +32,23 @@
|
|
|
29
32
|
},
|
|
30
33
|
"homepage": "https://github.com/mathrunet/node_masamune#readme",
|
|
31
34
|
"dependencies": {
|
|
35
|
+
"@sendgrid/mail": "^7.7.0",
|
|
32
36
|
"agora-token": "^2.0.2",
|
|
37
|
+
"crypto": "^1.0.1",
|
|
33
38
|
"firebase-admin": "^11.4.1",
|
|
34
39
|
"firebase-functions": "^4.1.1",
|
|
35
40
|
"node-fetch": "^2.6.9",
|
|
36
|
-
"
|
|
41
|
+
"nodemailer": "^6.9.2",
|
|
42
|
+
"stripe": "^12.7.0",
|
|
43
|
+
"typescript": "^4.9.4",
|
|
44
|
+
"uuid": "^9.0.0"
|
|
37
45
|
},
|
|
38
46
|
"devDependencies": {
|
|
39
47
|
"@types/jest": "^29.2.5",
|
|
40
48
|
"@types/node-fetch": "^2.6.3",
|
|
41
|
-
"
|
|
49
|
+
"@types/nodemailer": "^6.4.8",
|
|
50
|
+
"@types/uuid": "^9.0.1",
|
|
51
|
+
"conventional-changelog-cli": "2.2.2",
|
|
42
52
|
"jest": "^29.3.1",
|
|
43
53
|
"ts-jest": "^29.0.3"
|
|
44
54
|
}
|