@mathrunet/masamune 1.10.3 → 2.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 (79) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/LICENSE +19 -22
  3. package/dist/functions/agora_cloud_recording.js +48 -38
  4. package/dist/functions/agora_cloud_recording.js.map +1 -1
  5. package/dist/functions/agora_token.js +40 -30
  6. package/dist/functions/agora_token.js.map +1 -1
  7. package/dist/functions/android_auth_code.js +25 -15
  8. package/dist/functions/android_auth_code.js.map +1 -1
  9. package/dist/functions/android_token.js +46 -34
  10. package/dist/functions/android_token.js.map +1 -1
  11. package/dist/functions/consumable_verify_android.js +45 -35
  12. package/dist/functions/consumable_verify_android.js.map +1 -1
  13. package/dist/functions/consumable_verify_ios.js +39 -29
  14. package/dist/functions/consumable_verify_ios.js.map +1 -1
  15. package/dist/functions/geocoding.js +29 -19
  16. package/dist/functions/geocoding.js.map +1 -1
  17. package/dist/functions/gmail.js +36 -26
  18. package/dist/functions/gmail.js.map +1 -1
  19. package/dist/functions/nonconsumable_verify_android.js +44 -34
  20. package/dist/functions/nonconsumable_verify_android.js.map +1 -1
  21. package/dist/functions/nonconsumable_verify_ios.js +38 -28
  22. package/dist/functions/nonconsumable_verify_ios.js.map +1 -1
  23. package/dist/functions/openai_chat_gpt.js +39 -29
  24. package/dist/functions/openai_chat_gpt.js.map +1 -1
  25. package/dist/functions/purchase_webhook_android.js +26 -18
  26. package/dist/functions/purchase_webhook_android.js.map +1 -1
  27. package/dist/functions/purchase_webhook_ios.js +92 -78
  28. package/dist/functions/purchase_webhook_ios.js.map +1 -1
  29. package/dist/functions/scheduler.js +15 -9
  30. package/dist/functions/scheduler.js.map +1 -1
  31. package/dist/functions/send_grid.js +35 -25
  32. package/dist/functions/send_grid.js.map +1 -1
  33. package/dist/functions/send_notification.js +37 -24
  34. package/dist/functions/send_notification.js.map +1 -1
  35. package/dist/functions/stripe.js +866 -858
  36. package/dist/functions/stripe.js.map +1 -1
  37. package/dist/functions/stripe_webhook.js +370 -363
  38. package/dist/functions/stripe_webhook.js.map +1 -1
  39. package/dist/functions/stripe_webhook_connect.js +72 -63
  40. package/dist/functions/stripe_webhook_connect.js.map +1 -1
  41. package/dist/functions/stripe_webhook_secure.js +72 -63
  42. package/dist/functions/stripe_webhook_secure.js.map +1 -1
  43. package/dist/functions/subscription_verify_android.js +61 -52
  44. package/dist/functions/subscription_verify_android.js.map +1 -1
  45. package/dist/functions/subscription_verify_ios.js +59 -50
  46. package/dist/functions/subscription_verify_ios.js.map +1 -1
  47. package/dist/functions.d.ts +22 -68
  48. package/dist/functions.js +22 -22
  49. package/dist/functions.js.map +1 -1
  50. package/dist/index.js +1 -1
  51. package/dist/index.js.map +1 -1
  52. package/dist/lib/call_process_function_base.d.ts +2 -15
  53. package/dist/lib/call_process_function_base.js +13 -13
  54. package/dist/lib/call_process_function_base.js.map +1 -1
  55. package/dist/lib/functions_base.d.ts +97 -9
  56. package/dist/lib/functions_base.js +10 -7
  57. package/dist/lib/functions_base.js.map +1 -1
  58. package/dist/lib/functions_data.d.ts +2 -36
  59. package/dist/lib/functions_data.js +2 -29
  60. package/dist/lib/functions_data.js.map +1 -1
  61. package/dist/lib/gmail.d.ts +2 -2
  62. package/dist/lib/gmail.js +4 -29
  63. package/dist/lib/gmail.js.map +1 -1
  64. package/dist/lib/request_process_function_base.d.ts +4 -16
  65. package/dist/lib/request_process_function_base.js +13 -13
  66. package/dist/lib/request_process_function_base.js.map +1 -1
  67. package/dist/lib/schedule_process_function_base.d.ts +13 -11
  68. package/dist/lib/schedule_process_function_base.js +15 -9
  69. package/dist/lib/schedule_process_function_base.js.map +1 -1
  70. package/dist/lib/send_grid.d.ts +1 -1
  71. package/dist/lib/send_grid.js +3 -27
  72. package/dist/lib/send_grid.js.map +1 -1
  73. package/dist/lib/send_notification.js +1 -1
  74. package/dist/lib/send_notification.js.map +1 -1
  75. package/dist/lib/verify_android.js +1 -1
  76. package/dist/lib/verify_android.js.map +1 -1
  77. package/dist/lib/verify_ios.js +1 -1
  78. package/dist/lib/verify_ios.js.map +1 -1
  79. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ # [2.0.0](https://github.com/mathrunet/node_masamune/compare/v1.10.4...v2.0.0) (2024-01-15)
2
+
3
+
4
+ ### feat
5
+
6
+ * Compatible with FirebaseFunctionsV2. ([df2cc6d](https://github.com/mathrunet/node_masamune/commit/df2cc6d050fe249781fe42afb5633e6d39b32f74))
7
+
8
+
9
+
10
+ ## [1.10.4](https://github.com/mathrunet/node_masamune/compare/v1.10.3...v1.10.4) (2024-01-03)
11
+
12
+
13
+ ### fix
14
+
15
+ * Changed license. ([b77a5f2](https://github.com/mathrunet/node_masamune/commit/b77a5f24019b1ff94188aaa1f6053d968152148e))
16
+
17
+
18
+
1
19
  ## [1.10.3](https://github.com/mathrunet/node_masamune/compare/v1.10.2...v1.10.3) (2023-12-22)
2
20
 
3
21
 
package/LICENSE CHANGED
@@ -1,24 +1,21 @@
1
- Copyright (c) 2023, mathru (https://mathru.net)
2
- All rights reserved.
1
+ MIT License
3
2
 
4
- Redistribution and use in source and binary forms, with or without
5
- modification, are permitted provided that the following conditions are met:
6
- * Redistributions of source code must retain the above copyright notice,
7
- this list of conditions and the following disclaimer.
8
- * Redistributions in binary form must reproduce the above copyright notice,
9
- this list of conditions and the following disclaimer in the documentation
10
- and/or other materials provided with the distribution.
11
- * Neither the name of the <organization> nor the names of its contributors
12
- may be used to endorse or promote products derived from this software
13
- without specific prior written permission.
3
+ Copyright (c) 2024 mathru (https://mathru.net)
14
4
 
15
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
- DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
19
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -32,7 +32,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
32
32
  });
33
33
  };
34
34
  Object.defineProperty(exports, "__esModule", { value: true });
35
- const functions = __importStar(require("firebase-functions"));
35
+ const functions = __importStar(require("firebase-functions/v2"));
36
36
  const admin = __importStar(require("firebase-admin"));
37
37
  /**
38
38
  * Convert files generated by Agora.io's cloud recording into an easy-to-handle format from within the app.
@@ -43,62 +43,72 @@ const admin = __importStar(require("firebase-admin"));
43
43
  *
44
44
  * FirebaseStorageにファイルが保存されたタイミングで実行されます。
45
45
  */
46
- module.exports = (regions, timeoutSeconds, data) => functions.runWith({ timeoutSeconds: timeoutSeconds }).storage.object().onFinalize((object) => __awaiter(void 0, void 0, void 0, function* () {
47
- try {
48
- const source = object.name;
49
- if (!source) {
50
- return;
51
- }
52
- const bucket = admin.storage().bucket(object.bucket);
53
- const targetScreenShot = source.toString().match(/([a-z0-9A-Z]+)_([a-z0-9A-Z]+)__uid_s_([0-9]+)__uid_e_video_([0-9]+).jp(e)?g/);
54
- if (targetScreenShot) {
55
- const target = targetScreenShot[2] + ".jpg";
56
- if (target == source.toString()) {
57
- console.log("Jpeg file is not replaced.");
46
+ module.exports = (regions, options, data) => {
47
+ var _a;
48
+ return functions.storage.onObjectFinalized({
49
+ region: regions[0],
50
+ timeoutSeconds: options.timeoutSeconds,
51
+ memory: options.memory,
52
+ minInstances: options.minInstances,
53
+ concurrency: options.concurrency,
54
+ maxInstances: (_a = options.maxInstances) !== null && _a !== void 0 ? _a : undefined,
55
+ }, (object) => __awaiter(void 0, void 0, void 0, function* () {
56
+ try {
57
+ const source = object.data.name;
58
+ if (!source) {
58
59
  return;
59
60
  }
60
- yield bucket.file(source).copy(target, {
61
- contentType: "image/jpeg",
62
- });
63
- yield bucket.file(source).delete();
64
- yield bucket.file(target).makePublic();
65
- }
66
- else {
67
- const targetM3U8 = source.toString().match(/([a-z0-9A-Z]+)_([a-z0-9A-Z]+).m3u8/);
68
- if (targetM3U8) {
69
- const target = targetM3U8[2] + ".m3u8";
61
+ const bucket = admin.storage().bucket(object.bucket);
62
+ const targetScreenShot = source.toString().match(/([a-z0-9A-Z]+)_([a-z0-9A-Z]+)__uid_s_([0-9]+)__uid_e_video_([0-9]+).jp(e)?g/);
63
+ if (targetScreenShot) {
64
+ const target = targetScreenShot[2] + ".jpg";
70
65
  if (target == source.toString()) {
71
- console.log("M3U8 file is not replaced.");
66
+ console.log("Jpeg file is not replaced.");
72
67
  return;
73
68
  }
74
69
  yield bucket.file(source).copy(target, {
75
- cacheControl: "no-cache",
76
- contentType: "application/x-mpegURL",
70
+ contentType: "image/jpeg",
77
71
  });
78
72
  yield bucket.file(source).delete();
79
73
  yield bucket.file(target).makePublic();
80
74
  }
81
75
  else {
82
- const targetTS = source.toString().match(/([a-z0-9A-Z]+)_([a-z0-9A-Z]+)_([a-z0-9A-Z]+).ts/);
83
- if (targetTS) {
84
- const target = targetTS[0];
76
+ const targetM3U8 = source.toString().match(/([a-z0-9A-Z]+)_([a-z0-9A-Z]+).m3u8/);
77
+ if (targetM3U8) {
78
+ const target = targetM3U8[2] + ".m3u8";
85
79
  if (target == source.toString()) {
86
- console.log("Ts file is not replaced.");
80
+ console.log("M3U8 file is not replaced.");
87
81
  return;
88
82
  }
89
- console.log("Ts file is replaced.");
90
83
  yield bucket.file(source).copy(target, {
91
- contentType: "video/MP2T",
84
+ cacheControl: "no-cache",
85
+ contentType: "application/x-mpegURL",
92
86
  });
93
87
  yield bucket.file(source).delete();
94
88
  yield bucket.file(target).makePublic();
95
89
  }
90
+ else {
91
+ const targetTS = source.toString().match(/([a-z0-9A-Z]+)_([a-z0-9A-Z]+)_([a-z0-9A-Z]+).ts/);
92
+ if (targetTS) {
93
+ const target = targetTS[0];
94
+ if (target == source.toString()) {
95
+ console.log("Ts file is not replaced.");
96
+ return;
97
+ }
98
+ console.log("Ts file is replaced.");
99
+ yield bucket.file(source).copy(target, {
100
+ contentType: "video/MP2T",
101
+ });
102
+ yield bucket.file(source).delete();
103
+ yield bucket.file(target).makePublic();
104
+ }
105
+ }
96
106
  }
97
107
  }
98
- }
99
- catch (err) {
100
- console.error(err);
101
- throw err;
102
- }
103
- }));
108
+ catch (err) {
109
+ console.error(err);
110
+ throw err;
111
+ }
112
+ }));
113
+ };
104
114
  //# sourceMappingURL=agora_cloud_recording.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"agora_cloud_recording.js","sourceRoot":"","sources":["../../src/functions/agora_cloud_recording.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAgD;AAChD,sDAAwC;AAExC;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,GAAG,CAAC,OAAiB,EAAE,cAAsB,EAAE,IAA+B,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,EAAC,cAAc,EAAE,cAAc,EAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,UAAU,CAC5K,CAAO,MAAM,EAAE,EAAE;IACb,IAAI;QACA,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC;QAC3B,IAAI,CAAC,MAAM,EAAE;YACT,OAAO;SACV;QACD,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACrD,MAAM,gBAAgB,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,6EAA6E,CAAC,CAAC;QAChI,IAAI,gBAAgB,EAAE;YAClB,MAAM,MAAM,GAAG,gBAAgB,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;YAC5C,IAAI,MAAM,IAAI,MAAM,CAAC,QAAQ,EAAE,EAAE;gBAC7B,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;gBAC1C,OAAO;aACV;YACD,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAC1B,MAAM,EACN;gBACI,WAAW,EAAE,YAAY;aAC5B,CACJ,CAAC;YACF,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;YACnC,MAAM,MAAM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C;oBACnC,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,CAAC;iBAC1C;aACJ;SACJ;KACJ;IAAC,OAAO,GAAG,EAAE;QACV,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,MAAM,GAAG,CAAC;KACb;AACL,CAAC,CAAA,CACJ,CAAC"}
1
+ {"version":3,"file":"agora_cloud_recording.js","sourceRoot":"","sources":["../../src/functions/agora_cloud_recording.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iEAAmD;AACnD,sDAAwC;AAGxC;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,GAAG,CACb,OAAiB,EACjB,OAAyB,EACzB,IAA+B,EACjC,EAAE;;IAAC,OAAA,SAAS,CAAC,OAAO,CAAC,iBAAiB,CACpC;QACI,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QAClB,cAAc,EAAE,OAAO,CAAC,cAAc;QACtC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,YAAY,EAAE,MAAA,OAAO,CAAC,YAAY,mCAAI,SAAS;KAClD,EACD,CAAO,MAAM,EAAE,EAAE;QACb,IAAI;YACA,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;YAChC,IAAI,CAAC,MAAM,EAAE;gBACT,OAAO;aACV;YACD,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACrD,MAAM,gBAAgB,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,6EAA6E,CAAC,CAAC;YAChI,IAAI,gBAAgB,EAAE;gBAClB,MAAM,MAAM,GAAG,gBAAgB,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;gBAC5C,IAAI,MAA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,EAAE,EAAE;4BAC7B,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;4BACxC,OAAO;yBACV;wBACD,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;wBACpC,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAC1B,MAAM,EACN;4BACI,WAAW,EAAE,YAAY;yBAC5B,CACJ,CAAC;wBACF,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;wBACnC,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,CAAC;qBAC1C;iBACJ;aACJ;SACJ;QAAC,OAAO,GAAG,EAAE;YACV,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnB,MAAM,GAAG,CAAC;SACb;IACL,CAAC,CAAA,CACJ,CAAA;CAAA,CAAC"}
@@ -32,14 +32,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
32
32
  });
33
33
  };
34
34
  Object.defineProperty(exports, "__esModule", { value: true });
35
- const functions = __importStar(require("firebase-functions"));
35
+ const functions = __importStar(require("firebase-functions/v2"));
36
36
  const agora_token_1 = require("agora-token");
37
37
  /**
38
38
  * Obtain an Agora.io security token.
39
39
  *
40
40
  * Agora.ioのセキュリティトークンを取得します。
41
41
  *
42
- * @param agora.app_id
42
+ * @param process.env.AGORA_APPID
43
43
  * AppID for Agora.
44
44
  * Log in to the following URL and create a project.
45
45
  * After the project is created, the AppID can be copied.
@@ -50,7 +50,7 @@ const agora_token_1 = require("agora-token");
50
50
  *
51
51
  * https://console.agora.io/projects
52
52
  *
53
- * @param agora.app_certificate
53
+ * @param process.env.AGORA_APPCERTIFICATE
54
54
  * AppCertificate for Agora.
55
55
  * You can obtain the certificate after entering the project you created and activating it in Security -> App certificate.
56
56
  *
@@ -74,33 +74,43 @@ const agora_token_1 = require("agora-token");
74
74
  *
75
75
  * 役割。"audience"か"broadcaster"が指定できます。
76
76
  */
77
- module.exports = (regions, timeoutSeconds, data) => functions.runWith({ timeoutSeconds: timeoutSeconds }).region(...regions).https.onCall((query) => __awaiter(void 0, void 0, void 0, function* () {
78
- try {
79
- const config = functions.config().agora;
80
- const appId = config.app_id;
81
- const appCertificate = config.app_certificate;
82
- const expirationTimeInSeconds = 3600;
83
- let role = agora_token_1.RtcRole.PUBLISHER;
84
- if (query.role === "audience") {
85
- role = agora_token_1.RtcRole.SUBSCRIBER;
77
+ module.exports = (regions, options, data) => {
78
+ var _a;
79
+ return functions.https.onCall({
80
+ region: regions,
81
+ timeoutSeconds: options.timeoutSeconds,
82
+ memory: options.memory,
83
+ minInstances: options.minInstances,
84
+ concurrency: options.concurrency,
85
+ maxInstances: (_a = options.maxInstances) !== null && _a !== void 0 ? _a : undefined,
86
+ }, (query) => __awaiter(void 0, void 0, void 0, function* () {
87
+ var _b, _c;
88
+ try {
89
+ const appId = (_b = process.env.AGORA_APPID) !== null && _b !== void 0 ? _b : "";
90
+ const appCertificate = (_c = process.env.AGORA_APPCERTIFICATE) !== null && _c !== void 0 ? _c : "";
91
+ const expirationTimeInSeconds = 3600;
92
+ let role = agora_token_1.RtcRole.PUBLISHER;
93
+ if (query.data.role === "audience") {
94
+ role = agora_token_1.RtcRole.SUBSCRIBER;
95
+ }
96
+ const channelName = query.data.name;
97
+ let uid = 0;
98
+ if (query.data.uid) {
99
+ uid = query.data.uid;
100
+ }
101
+ if (!channelName) {
102
+ throw new functions.https.HttpsError("invalid-argument", "Channel is invalid.");
103
+ }
104
+ const token = agora_token_1.RtcTokenBuilder.buildTokenWithUid(appId, appCertificate, channelName, uid, role, expirationTimeInSeconds, expirationTimeInSeconds);
105
+ return {
106
+ channel: channelName,
107
+ token: token,
108
+ };
86
109
  }
87
- const channelName = query.name;
88
- let uid = 0;
89
- if (query.uid) {
90
- uid = query.uid;
110
+ catch (err) {
111
+ console.error(err);
112
+ throw err;
91
113
  }
92
- if (!channelName) {
93
- throw new functions.https.HttpsError("invalid-argument", "Channel is invalid.");
94
- }
95
- const token = agora_token_1.RtcTokenBuilder.buildTokenWithUid(appId, appCertificate, channelName, uid, role, expirationTimeInSeconds, expirationTimeInSeconds);
96
- return {
97
- channel: channelName,
98
- token: token,
99
- };
100
- }
101
- catch (err) {
102
- console.error(err);
103
- throw err;
104
- }
105
- }));
114
+ }));
115
+ };
106
116
  //# sourceMappingURL=agora_token.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"agora_token.js","sourceRoot":"","sources":["../../src/functions/agora_token.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAgD;AAChD,6CAAuD;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,CAAC,OAAO,GAAG,CAAC,OAAiB,EAAE,cAAsB,EAAE,IAA+B,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,EAAC,cAAc,EAAE,cAAc,EAAC,CAAC,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,CAChL,CAAO,KAAK,EAAE,EAAE;IACZ,IAAI;QACA,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC;QACxC,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,MAAM,cAAc,GAAG,MAAM,CAAC,eAAe,CAAC;QAC9C,MAAM,uBAAuB,GAAG,IAAI,CAAC;QACrC,IAAI,IAAI,GAAG,qBAAO,CAAC,SAAS,CAAC;QAC7B,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE;YAC3B,IAAI,GAAG,qBAAO,CAAC,UAAU,CAAC;SAC7B;QACD,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC;QAC/B,IAAI,GAAG,GAAG,CAAC,CAAC;QACZ,IAAI,KAAK,CAAC,GAAG,EAAE;YACX,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC;SACnB;QACD,IAAI,CAAC,WAAW,EAAE;YACd,MAAM,IAAI,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,CAAC;SACnF;QACD,MAAM,KAAK,GAAG,6BAAe,CAAC,iBAAiB,CAC3C,KAAK,EACL,cAAc,EACd,WAAW,EACX,GAAG,EACH,IAAI,EACJ,uBAAuB,EACvB,uBAAuB,CAC1B,CAAC;QACF,OAAO;YACH,OAAO,EAAE,WAAW;YACpB,KAAK,EAAE,KAAK;SACf,CAAC;KACL;IAAC,OAAO,GAAG,EAAE;QACV,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,MAAM,GAAG,CAAC;KACb;AACL,CAAC,CAAA,CACJ,CAAC"}
1
+ {"version":3,"file":"agora_token.js","sourceRoot":"","sources":["../../src/functions/agora_token.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iEAAmD;AACnD,6CAAuD;AAGvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,CAAC,OAAO,GAAG,CACb,OAAiB,EACjB,OAAyB,EACzB,IAA+B,EACjC,EAAE;;IAAC,OAAA,SAAS,CAAC,KAAK,CAAC,MAAM,CACvB;QACI,MAAM,EAAE,OAAO;QACf,cAAc,EAAE,OAAO,CAAC,cAAc;QACtC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,YAAY,EAAE,MAAA,OAAO,CAAC,YAAY,mCAAI,SAAS;KAClD,EACD,CAAO,KAAK,EAAE,EAAE;;QACZ,IAAI;YACA,MAAM,KAAK,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,WAAW,mCAAI,EAAE,CAAC;YAC5C,MAAM,cAAc,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,oBAAoB,mCAAI,EAAE,CAAC;YAC9D,MAAM,uBAAuB,GAAG,IAAI,CAAC;YACrC,IAAI,IAAI,GAAG,qBAAO,CAAC,SAAS,CAAC;YAC7B,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE;gBAChC,IAAI,GAAG,qBAAO,CAAC,UAAU,CAAC;aAC7B;YACD,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;YACpC,IAAI,GAAG,GAAG,CAAC,CAAC;YACZ,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE;gBAChB,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;aACxB;YACD,IAAI,CAAC,WAAW,EAAE;gBACd,MAAM,IAAI,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,CAAC;aACnF;YACD,MAAM,KAAK,GAAG,6BAAe,CAAC,iBAAiB,CAC3C,KAAK,EACL,cAAc,EACd,WAAW,EACX,GAAG,EACH,IAAI,EACJ,uBAAuB,EACvB,uBAAuB,CAC1B,CAAC;YACF,OAAO;gBACH,OAAO,EAAE,WAAW;gBACpB,KAAK,EAAE,KAAK;aACf,CAAC;SACL;QAAC,OAAO,GAAG,EAAE;YACV,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnB,MAAM,GAAG,CAAC;SACb;IACL,CAAC,CAAA,CACJ,CAAA;CAAA,CAAC"}
@@ -32,7 +32,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
32
32
  });
33
33
  };
34
34
  Object.defineProperty(exports, "__esModule", { value: true });
35
- const functions = __importStar(require("firebase-functions"));
35
+ const functions = __importStar(require("firebase-functions/v2"));
36
36
  /**
37
37
  * After being redirected from [android_auth_code], you will get a refresh token to connect to Google's API.
38
38
  * Please execute [android_auth_code] after registering the required information.
@@ -40,14 +40,14 @@ const functions = __importStar(require("firebase-functions"));
40
40
  * [android_auth_code]からリダイレクトされた後、GoogleのAPIに接続するためのリフレッシュトークンを取得します。
41
41
  * 必要情報を登録した後[android_auth_code]を実行してください。
42
42
  *
43
- * @param purchase.android.redirect_uri
43
+ * @param process.env.PURCHASE_ANDROID_REDIRECTURI
44
44
  * Describe the absolute URL where [android_token] exists.
45
45
  * You will be redirected to this URL to obtain a refresh token.
46
46
  *
47
47
  * [android_token]が存在する絶対URLを記述します。
48
48
  * このURLにリダイレクトされリフレッシュトークンを取得できます。
49
49
  *
50
- * @param purchase.android.client_id
50
+ * @param process.env.PURCHASE_ANDROID_CLIENTID
51
51
  * Google's OAuth 2.0 client ID.
52
52
  * Create an OAuth consent screen from the URL below.
53
53
  * https://console.cloud.google.com/apis/credentials/consent
@@ -60,17 +60,27 @@ const functions = __importStar(require("firebase-functions"));
60
60
  * その後、認証情報からOAuth 2.0 クライアントIDを作成します。
61
61
  * https://console.cloud.google.com/apis/credentials
62
62
  */
63
- module.exports = (regions, timeoutSeconds, data) => functions.runWith({ timeoutSeconds: timeoutSeconds }).region(...regions).https.onRequest((req, res) => __awaiter(void 0, void 0, void 0, function* () {
64
- try {
65
- const config = functions.config().purchase;
66
- if (!req.query.id || !config.android.redirect_uri) {
67
- throw new functions.https.HttpsError("invalid-argument", "Query parameter is invalid.");
63
+ module.exports = (regions, options, data) => {
64
+ var _a;
65
+ return functions.https.onRequest({
66
+ region: regions,
67
+ timeoutSeconds: options.timeoutSeconds,
68
+ memory: options.memory,
69
+ minInstances: options.minInstances,
70
+ concurrency: options.concurrency,
71
+ maxInstances: (_a = options.maxInstances) !== null && _a !== void 0 ? _a : undefined,
72
+ }, (req, res) => __awaiter(void 0, void 0, void 0, function* () {
73
+ try {
74
+ const redirectUri = process.env.PURCHASE_ANDROID_REDIRECTURI;
75
+ if (!req.query.id || !redirectUri) {
76
+ throw new functions.https.HttpsError("invalid-argument", "Query parameter is invalid.");
77
+ }
78
+ res.redirect(`https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=${req.query.id}&redirect_uri=${redirectUri}&scope=https://www.googleapis.com/auth/androidpublisher&access_type=offline&approval_prompt=force`);
68
79
  }
69
- res.redirect(`https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=${req.query.id}&redirect_uri=${config.android.redirect_uri}&scope=https://www.googleapis.com/auth/androidpublisher&access_type=offline&approval_prompt=force`);
70
- }
71
- catch (err) {
72
- console.error(err);
73
- res.end();
74
- }
75
- }));
80
+ catch (err) {
81
+ console.error(err);
82
+ res.end();
83
+ }
84
+ }));
85
+ };
76
86
  //# sourceMappingURL=android_auth_code.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"android_auth_code.js","sourceRoot":"","sources":["../../src/functions/android_auth_code.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAgD;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,OAAO,GAAG,CAAC,OAAiB,EAAE,cAAsB,EAAE,IAA+B,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,EAAC,cAAc,EAAE,cAAc,EAAC,CAAC,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,KAAK,CAAC,SAAS,CACnL,CAAO,GAAG,EAAE,GAAG,EAAE,EAAE;IACf,IAAI;QACA,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC;QAC3C,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE;YAC/C,MAAM,IAAI,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,kBAAkB,EAAE,6BAA6B,CAAC,CAAC;SAC3F;QACD,GAAG,CAAC,QAAQ,CACR,0EAA0E,GAAG,CAAC,KAAK,CAAC,EAAE,iBAAiB,MAAM,CAAC,OAAO,CAAC,YAAY,mGAAmG,CACxO,CAAC;KACL;IAAC,OAAO,GAAG,EAAE;QACV,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,GAAG,CAAC,GAAG,EAAE,CAAC;KACb;AACL,CAAC,CAAA,CACJ,CAAC"}
1
+ {"version":3,"file":"android_auth_code.js","sourceRoot":"","sources":["../../src/functions/android_auth_code.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iEAAmD;AAGnD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,OAAO,GAAG,CACb,OAAiB,EACjB,OAAyB,EACzB,IAA+B,EACjC,EAAE;;IAAC,OAAA,SAAS,CAAC,KAAK,CAAC,SAAS,CAC1B;QACI,MAAM,EAAE,OAAO;QACf,cAAc,EAAE,OAAO,CAAC,cAAc;QACtC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,YAAY,EAAE,MAAA,OAAO,CAAC,YAAY,mCAAI,SAAS;KAClD,EACD,CAAO,GAAG,EAAE,GAAG,EAAE,EAAE;QACf,IAAI;YACA,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC;YAC7D,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE;gBAC/B,MAAM,IAAI,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,kBAAkB,EAAE,6BAA6B,CAAC,CAAC;aAC3F;YACD,GAAG,CAAC,QAAQ,CACR,0EAA0E,GAAG,CAAC,KAAK,CAAC,EAAE,iBAAiB,WAAW,mGAAmG,CACxN,CAAC;SACL;QAAC,OAAO,GAAG,EAAE;YACV,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnB,GAAG,CAAC,GAAG,EAAE,CAAC;SACb;IACL,CAAC,CAAA,CACJ,CAAA;CAAA,CAAC"}
@@ -32,7 +32,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
32
32
  });
33
33
  };
34
34
  Object.defineProperty(exports, "__esModule", { value: true });
35
- const functions = __importStar(require("firebase-functions"));
35
+ const functions = __importStar(require("firebase-functions/v2"));
36
36
  const api_1 = require("../lib/api");
37
37
  /**
38
38
  * After being redirected from [android_auth_code], you will get a refresh token to connect to Google's API.
@@ -41,14 +41,14 @@ const api_1 = require("../lib/api");
41
41
  * [android_auth_code]からリダイレクトされた後、GoogleのAPIに接続するためのリフレッシュトークンを取得します。
42
42
  * 必要情報を登録した後[android_auth_code]を実行してください。
43
43
  *
44
- * @param purchase.android.redirect_uri
44
+ * @param process.env.PURCHASE_ANDROID_REDIRECTURI
45
45
  * Describe the absolute URL where [android_token] exists.
46
46
  * You will be redirected to this URL to obtain a refresh token.
47
47
  *
48
48
  * [android_token]が存在する絶対URLを記述します。
49
49
  * このURLにリダイレクトされリフレッシュトークンを取得できます。
50
50
  *
51
- * @param purchase.android.client_id
51
+ * @param process.env.PURCHASE_ANDROID_CLIENTID
52
52
  * Google's OAuth 2.0 client ID.
53
53
  * Create an OAuth consent screen from the URL below.
54
54
  * https://console.cloud.google.com/apis/credentials/consent
@@ -61,7 +61,7 @@ const api_1 = require("../lib/api");
61
61
  * その後、認証情報からOAuth 2.0 クライアントIDを作成します。
62
62
  * https://console.cloud.google.com/apis/credentials
63
63
  *
64
- * @param purchase.android.client_secret
64
+ * @param process.env.PURCHASE_ANDROID_CLIENTSECRET
65
65
  * Google's OAuth 2.0 client secret.
66
66
  * Create an OAuth consent screen from the URL below.
67
67
  * https://console.cloud.google.com/apis/credentials/consent
@@ -74,36 +74,48 @@ const api_1 = require("../lib/api");
74
74
  * その後、認証情報からOAuth 2.0 クライアントIDを作成します。
75
75
  * https://console.cloud.google.com/apis/credentials
76
76
  */
77
- module.exports = (regions, timeoutSeconds, data) => functions.runWith({ timeoutSeconds: timeoutSeconds }).region(...regions).https.onRequest((req, res) => __awaiter(void 0, void 0, void 0, function* () {
78
- try {
79
- const config = functions.config().purchase;
80
- if (!req.query.code || !config.android.client_id || !config.android.client_secret || !config.android.redirect_uri) {
81
- throw new functions.https.HttpsError("invalid-argument", "Query parameter is invalid.");
77
+ module.exports = (regions, options, data) => {
78
+ var _a;
79
+ return functions.https.onRequest({
80
+ region: regions,
81
+ timeoutSeconds: options.timeoutSeconds,
82
+ memory: options.memory,
83
+ minInstances: options.minInstances,
84
+ concurrency: options.concurrency,
85
+ maxInstances: (_a = options.maxInstances) !== null && _a !== void 0 ? _a : undefined,
86
+ }, (req, res) => __awaiter(void 0, void 0, void 0, function* () {
87
+ try {
88
+ const redirectUri = process.env.PURCHASE_ANDROID_REDIRECTURI;
89
+ const clientId = process.env.PURCHASE_ANDROID_CLIENTID;
90
+ const clientSecret = process.env.PURCHASE_ANDROID_CLIENTSECRET;
91
+ if (!req.query.code || !clientId || !clientSecret || !redirectUri) {
92
+ throw new functions.https.HttpsError("invalid-argument", "Query parameter is invalid.");
93
+ }
94
+ const resp = yield api_1.Api.post("https://accounts.google.com/o/oauth2/token", {
95
+ timeout: 30 * 1000,
96
+ data: {
97
+ "grant_type": "authorization_code",
98
+ "client_id": clientId,
99
+ "client_secret": clientSecret,
100
+ "redirect_uri": redirectUri,
101
+ "access_type": "offline",
102
+ "code": req.query.code,
103
+ },
104
+ });
105
+ if (!resp) {
106
+ throw new functions.https.HttpsError("data-loss", "Cannot get access token.");
107
+ }
108
+ const json = (yield resp.json());
109
+ if (json === null) {
110
+ throw new functions.https.HttpsError("data-loss", "Cannot get access token.");
111
+ }
112
+ console.log(json);
113
+ res.send(`RefreshToken:${json["refresh_token"]}`);
82
114
  }
83
- const resp = yield api_1.Api.post("https://accounts.google.com/o/oauth2/token", {
84
- timeout: 30 * 1000,
85
- data: {
86
- "grant_type": "authorization_code",
87
- "client_id": config.android.client_id,
88
- "client_secret": config.android.client_secret,
89
- "redirect_uri": config.android.redirect_uri,
90
- "access_type": "offline",
91
- "code": req.query.code,
92
- },
93
- });
94
- if (!resp) {
95
- throw new functions.https.HttpsError("data-loss", "Cannot get access token.");
115
+ catch (err) {
116
+ console.error(err);
117
+ res.end();
96
118
  }
97
- const json = (yield resp.json());
98
- if (json === null) {
99
- throw new functions.https.HttpsError("data-loss", "Cannot get access token.");
100
- }
101
- console.log(json);
102
- res.send(`RefreshToken:${json["refresh_token"]}`);
103
- }
104
- catch (err) {
105
- console.error(err);
106
- res.end();
107
- }
108
- }));
119
+ }));
120
+ };
109
121
  //# sourceMappingURL=android_token.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"android_token.js","sourceRoot":"","sources":["../../src/functions/android_token.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAgD;AAChD,oCAAiC;AAGjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,CAAC,OAAO,GAAG,CAAC,OAAiB,EAAE,cAAsB,EAAE,IAA+B,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,EAAC,cAAc,EAAE,cAAc,EAAC,CAAC,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,KAAK,CAAC,SAAS,CACnL,CAAO,GAAG,EAAE,GAAG,EAAE,EAAE;IACf,IAAI;QACA,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC;QAC3C,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE;YAC/G,MAAM,IAAI,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,kBAAkB,EAAE,6BAA6B,CAAC,CAAC;SAC3F;QACD,MAAM,IAAI,GAAG,MAAM,SAAG,CAAC,IAAI,CAAC,4CAA4C,EAAE;YACtE,OAAO,EAAE,EAAE,GAAG,IAA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ACf,MAAM,IAAI,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,WAAW,EAAE,0BAA0B,CAAC,CAAC;aACjF;YACD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAClB,GAAG,CAAC,IAAI,CAAC,gBAAgB,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;SACrD;QAAC,OAAO,GAAG,EAAE;YACV,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnB,GAAG,CAAC,GAAG,EAAE,CAAC;SACb;IACL,CAAC,CAAA,CACJ,CAAA;CAAA,CAAC"}
@@ -32,7 +32,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
32
32
  });
33
33
  };
34
34
  Object.defineProperty(exports, "__esModule", { value: true });
35
- const functions = __importStar(require("firebase-functions"));
35
+ const functions = __importStar(require("firebase-functions/v2"));
36
36
  const verifier = __importStar(require("../lib/verify_android"));
37
37
  const updater = __importStar(require("../lib/update_wallet"));
38
38
  /**
@@ -40,12 +40,12 @@ const updater = __importStar(require("../lib/update_wallet"));
40
40
  *
41
41
  * 消費型のアプリ内課金を行います。[path]に指定したドキュメント内のフィールドの値を[value]に加算します。
42
42
  *
43
- * @param purchase.android.refresh_token
43
+ * @param process.env.PURCHASE_ANDROID_REFRESHTOKEN
44
44
  * Describe the refresh token that can be obtained by accessing [android_auth_code].
45
45
  *
46
46
  * [android_auth_code]にアクセスすることで取得できるリフレッシュトークンを記述します。
47
47
  *
48
- * @param purchase.android.client_id
48
+ * @param process.env.PURCHASE_ANDROID_CLIENTID
49
49
  * Google's OAuth 2.0 client ID.
50
50
  * Create an OAuth consent screen from the URL below.
51
51
  * https://console.cloud.google.com/apis/credentials/consent
@@ -58,7 +58,7 @@ const updater = __importStar(require("../lib/update_wallet"));
58
58
  * その後、認証情報からOAuth 2.0 クライアントIDを作成します。
59
59
  * https://console.cloud.google.com/apis/credentials
60
60
  *
61
- * @param purchase.android.client_secret
61
+ * @param process.env.PURCHASE_ANDROID_CLIENTSECRET
62
62
  * Google's OAuth 2.0 client secret.
63
63
  * Create an OAuth consent screen from the URL below.
64
64
  * https://console.cloud.google.com/apis/credentials/consent
@@ -96,37 +96,47 @@ const updater = __importStar(require("../lib/update_wallet"));
96
96
  *
97
97
  * 購入したときに発行された購入トークン。
98
98
  */
99
- module.exports = (regions, timeoutSeconds, data) => functions.runWith({ timeoutSeconds: timeoutSeconds }).region(...regions).https.onCall((query) => __awaiter(void 0, void 0, void 0, function* () {
100
- try {
101
- const config = functions.config().purchase;
102
- /* ==== Android検証ここから ==== */
103
- const res = yield verifier.verifyAndroid({
104
- type: "products",
105
- clientId: config.android.client_id,
106
- clientSecret: config.android.client_secret,
107
- refreshToken: config.android.refresh_token,
108
- packageName: query.packageName,
109
- productId: query.productId,
110
- purchaseToken: query.purchaseToken,
111
- });
112
- if (res["purchaseState"] !== 0) {
113
- throw new functions.https.HttpsError("unauthenticated", "Illegal receipt.");
114
- }
115
- /* ==== ここまでAndroid検証 ==== */
116
- if (!query.path || !query.value) {
99
+ module.exports = (regions, options, data) => {
100
+ var _a;
101
+ return functions.https.onCall({
102
+ region: regions,
103
+ timeoutSeconds: options.timeoutSeconds,
104
+ memory: options.memory,
105
+ minInstances: options.minInstances,
106
+ concurrency: options.concurrency,
107
+ maxInstances: (_a = options.maxInstances) !== null && _a !== void 0 ? _a : undefined,
108
+ }, (query) => __awaiter(void 0, void 0, void 0, function* () {
109
+ var _b, _c, _d;
110
+ try {
111
+ /* ==== Android検証ここから ==== */
112
+ const res = yield verifier.verifyAndroid({
113
+ type: "products",
114
+ clientId: (_b = process.env.PURCHASE_ANDROID_CLIENTID) !== null && _b !== void 0 ? _b : "",
115
+ clientSecret: (_c = process.env.PURCHASE_ANDROID_CLIENTSECRET) !== null && _c !== void 0 ? _c : "",
116
+ refreshToken: (_d = process.env.PURCHASE_ANDROID_REFRESHTOKEN) !== null && _d !== void 0 ? _d : "",
117
+ packageName: query.data.packageName,
118
+ productId: query.data.productId,
119
+ purchaseToken: query.data.purchaseToken,
120
+ });
121
+ if (res["purchaseState"] !== 0) {
122
+ throw new functions.https.HttpsError("unauthenticated", "Illegal receipt.");
123
+ }
124
+ /* ==== ここまでAndroid検証 ==== */
125
+ if (!query.data.path || !query.data.value) {
126
+ return res;
127
+ }
128
+ /* ==== Firestoreの更新ここから ==== */
129
+ yield updater.updateWallet({
130
+ targetDocumentFieldPath: query.data.path,
131
+ value: query.data.value,
132
+ });
133
+ /* ==== ここまでFirestoreの更新 ==== */
117
134
  return res;
118
135
  }
119
- /* ==== Firestoreの更新ここから ==== */
120
- yield updater.updateWallet({
121
- targetDocumentFieldPath: query.path,
122
- value: query.value,
123
- });
124
- /* ==== ここまでFirestoreの更新 ==== */
125
- return res;
126
- }
127
- catch (err) {
128
- console.error(err);
129
- throw err;
130
- }
131
- }));
136
+ catch (err) {
137
+ console.error(err);
138
+ throw err;
139
+ }
140
+ }));
141
+ };
132
142
  //# sourceMappingURL=consumable_verify_android.js.map