@mathrunet/masamune 0.4.4 → 0.5.2
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 +27 -0
- package/dist/functions/android_auth_code.d.ts +1 -0
- package/dist/functions/android_auth_code.js +76 -0
- package/dist/functions/android_auth_code.js.map +1 -0
- package/dist/functions/android_token.d.ts +1 -0
- package/dist/functions/android_token.js +117 -0
- package/dist/functions/android_token.js.map +1 -0
- package/dist/functions/consumable_verify_android.d.ts +1 -0
- package/dist/functions/consumable_verify_android.js +132 -0
- package/dist/functions/consumable_verify_android.js.map +1 -0
- package/dist/functions/consumable_verify_ios.d.ts +1 -0
- package/dist/functions/consumable_verify_ios.js +92 -0
- package/dist/functions/consumable_verify_ios.js.map +1 -0
- package/dist/functions/gmail.js +8 -3
- package/dist/functions/gmail.js.map +1 -1
- package/dist/functions/nonconsumable_verify_android.d.ts +1 -0
- package/dist/functions/nonconsumable_verify_android.js +126 -0
- package/dist/functions/nonconsumable_verify_android.js.map +1 -0
- package/dist/functions/nonconsumable_verify_ios.d.ts +1 -0
- package/dist/functions/nonconsumable_verify_ios.js +86 -0
- package/dist/functions/nonconsumable_verify_ios.js.map +1 -0
- package/dist/functions/purchase_hook_android.d.ts +1 -0
- package/dist/functions/purchase_hook_android.js +237 -0
- package/dist/functions/purchase_hook_android.js.map +1 -0
- package/dist/functions/purchase_hook_ios.d.ts +1 -0
- package/dist/functions/purchase_hook_ios.js +135 -0
- package/dist/functions/purchase_hook_ios.js.map +1 -0
- package/dist/functions/send_grid.js +6 -1
- package/dist/functions/send_grid.js.map +1 -1
- package/dist/functions/stripe.js +46 -12
- package/dist/functions/stripe.js.map +1 -1
- package/dist/functions/stripe_hook_secure.js +5 -1
- package/dist/functions/stripe_hook_secure.js.map +1 -1
- package/dist/functions/subscription_verify_android.d.ts +1 -0
- package/dist/functions/subscription_verify_android.js +159 -0
- package/dist/functions/subscription_verify_android.js.map +1 -0
- package/dist/functions/subscription_verify_ios.d.ts +1 -0
- package/dist/functions/subscription_verify_ios.js +128 -0
- package/dist/functions/subscription_verify_ios.js.map +1 -0
- package/dist/functions.d.ts +62 -0
- package/dist/functions.js +62 -0
- package/dist/functions.js.map +1 -1
- package/dist/lib/gmail.d.ts +6 -1
- package/dist/lib/gmail.js +1 -1
- package/dist/lib/gmail.js.map +1 -1
- package/dist/lib/send_grid.d.ts +6 -1
- package/dist/lib/send_grid.js +1 -1
- package/dist/lib/send_grid.js.map +1 -1
- package/dist/lib/update_subscription.d.ts +83 -0
- package/dist/lib/update_subscription.js +142 -0
- package/dist/lib/update_subscription.js.map +1 -0
- package/dist/lib/update_unlock.d.ts +13 -0
- package/dist/lib/update_unlock.js +64 -0
- package/dist/lib/update_unlock.js.map +1 -0
- package/dist/lib/update_wallet.d.ts +19 -0
- package/dist/lib/update_wallet.js +70 -0
- package/dist/lib/update_wallet.js.map +1 -0
- package/dist/lib/utils.d.ts +10 -2
- package/dist/lib/utils.js +2 -2
- package/dist/lib/utils.js.map +1 -1
- package/dist/lib/verify_android.d.ts +56 -0
- package/dist/lib/verify_android.js +128 -0
- package/dist/lib/verify_android.js.map +1 -0
- package/dist/lib/verify_ios.d.ts +26 -0
- package/dist/lib/verify_ios.js +115 -0
- package/dist/lib/verify_ios.js.map +1 -0
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
## [0.5.2](https://github.com/mathrunet/node_masamune/compare/v0.5.1...v0.5.2) (2023-06-22)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### fix
|
|
5
|
+
|
|
6
|
+
* Align the Key of UserId. ([5eec039](https://github.com/mathrunet/node_masamune/commit/5eec0398a794cab15c71760b45b328452eb50dbe))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## [0.5.1](https://github.com/mathrunet/node_masamune/compare/v0.5.0...v0.5.1) (2023-06-20)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### fix
|
|
14
|
+
|
|
15
|
+
* Name the parameter. ([1393a59](https://github.com/mathrunet/node_masamune/commit/1393a598e7c25835b13f869d8c3a153bcda9311e))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# [0.5.0](https://github.com/mathrunet/node_masamune/compare/v0.4.4...v0.5.0) (2023-06-20)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### feat
|
|
23
|
+
|
|
24
|
+
* Added Functions for mobile billing. ([62309a4](https://github.com/mathrunet/node_masamune/commit/62309a47dbde32101c521f3c0510f53c109f3844))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
1
28
|
## [0.4.4](https://github.com/mathrunet/node_masamune/compare/v0.4.3...v0.4.4) (2023-06-05)
|
|
2
29
|
|
|
3
30
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
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
|
+
const functions = __importStar(require("firebase-functions"));
|
|
36
|
+
/**
|
|
37
|
+
* After being redirected from [android_auth_code], you will get a refresh token to connect to Google's API.
|
|
38
|
+
* Please execute [android_auth_code] after registering the required information.
|
|
39
|
+
*
|
|
40
|
+
* [android_auth_code]からリダイレクトされた後、GoogleのAPIに接続するためのリフレッシュトークンを取得します。
|
|
41
|
+
* 必要情報を登録した後[android_auth_code]を実行してください。
|
|
42
|
+
*
|
|
43
|
+
* @param purchase.android.redirect_uri
|
|
44
|
+
* Describe the absolute URL where [android_token] exists.
|
|
45
|
+
* You will be redirected to this URL to obtain a refresh token.
|
|
46
|
+
*
|
|
47
|
+
* [android_token]が存在する絶対URLを記述します。
|
|
48
|
+
* このURLにリダイレクトされリフレッシュトークンを取得できます。
|
|
49
|
+
*
|
|
50
|
+
* @param purchase.android.client_id
|
|
51
|
+
* Google's OAuth 2.0 client ID.
|
|
52
|
+
* Create an OAuth consent screen from the URL below.
|
|
53
|
+
* https://console.cloud.google.com/apis/credentials/consent
|
|
54
|
+
* Then create an OAuth 2.0 client ID from the credentials.
|
|
55
|
+
* https://console.cloud.google.com/apis/credentials
|
|
56
|
+
*
|
|
57
|
+
* GoogleのOAuth2.0のクライアントID。
|
|
58
|
+
* 下記のURLからOAuthの同意画面を作成します。
|
|
59
|
+
* https://console.cloud.google.com/apis/credentials/consent
|
|
60
|
+
* その後、認証情報からOAuth 2.0 クライアントIDを作成します。
|
|
61
|
+
* https://console.cloud.google.com/apis/credentials
|
|
62
|
+
*/
|
|
63
|
+
module.exports = (regions) => functions.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.");
|
|
68
|
+
}
|
|
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
|
+
}));
|
|
76
|
+
//# sourceMappingURL=android_auth_code.js.map
|
|
@@ -0,0 +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,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,KAAK,CAAC,SAAS,CAChF,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,117 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
const functions = __importStar(require("firebase-functions"));
|
|
39
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
40
|
+
const form_data_1 = __importDefault(require("form-data"));
|
|
41
|
+
/**
|
|
42
|
+
* After being redirected from [android_auth_code], you will get a refresh token to connect to Google's API.
|
|
43
|
+
* Please execute [android_auth_code] after registering the required information.
|
|
44
|
+
*
|
|
45
|
+
* [android_auth_code]からリダイレクトされた後、GoogleのAPIに接続するためのリフレッシュトークンを取得します。
|
|
46
|
+
* 必要情報を登録した後[android_auth_code]を実行してください。
|
|
47
|
+
*
|
|
48
|
+
* @param purchase.android.redirect_uri
|
|
49
|
+
* Describe the absolute URL where [android_token] exists.
|
|
50
|
+
* You will be redirected to this URL to obtain a refresh token.
|
|
51
|
+
*
|
|
52
|
+
* [android_token]が存在する絶対URLを記述します。
|
|
53
|
+
* このURLにリダイレクトされリフレッシュトークンを取得できます。
|
|
54
|
+
*
|
|
55
|
+
* @param purchase.android.client_id
|
|
56
|
+
* Google's OAuth 2.0 client ID.
|
|
57
|
+
* Create an OAuth consent screen from the URL below.
|
|
58
|
+
* https://console.cloud.google.com/apis/credentials/consent
|
|
59
|
+
* Then create an OAuth 2.0 client ID from the credentials.
|
|
60
|
+
* https://console.cloud.google.com/apis/credentials
|
|
61
|
+
*
|
|
62
|
+
* GoogleのOAuth2.0のクライアントID。
|
|
63
|
+
* 下記のURLからOAuthの同意画面を作成します。
|
|
64
|
+
* https://console.cloud.google.com/apis/credentials/consent
|
|
65
|
+
* その後、認証情報からOAuth 2.0 クライアントIDを作成します。
|
|
66
|
+
* https://console.cloud.google.com/apis/credentials
|
|
67
|
+
*
|
|
68
|
+
* @param purchase.android.client_secret
|
|
69
|
+
* Google's OAuth 2.0 client secret.
|
|
70
|
+
* Create an OAuth consent screen from the URL below.
|
|
71
|
+
* https://console.cloud.google.com/apis/credentials/consent
|
|
72
|
+
* Then create an OAuth 2.0 client ID from the credentials.
|
|
73
|
+
* https://console.cloud.google.com/apis/credentials
|
|
74
|
+
*
|
|
75
|
+
* GoogleのOAuth2.0のクライアントシークレット。
|
|
76
|
+
* 下記のURLからOAuthの同意画面を作成します。
|
|
77
|
+
* https://console.cloud.google.com/apis/credentials/consent
|
|
78
|
+
* その後、認証情報からOAuth 2.0 クライアントIDを作成します。
|
|
79
|
+
* https://console.cloud.google.com/apis/credentials
|
|
80
|
+
*/
|
|
81
|
+
module.exports = (regions) => functions.region(...regions).https.onRequest((req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
82
|
+
try {
|
|
83
|
+
const config = functions.config().purchase;
|
|
84
|
+
if (!req.query.code || !config.android.client_id || !config.android.client_secret || !config.android.redirect_uri) {
|
|
85
|
+
throw new functions.https.HttpsError("invalid-argument", "Query parameter is invalid.");
|
|
86
|
+
}
|
|
87
|
+
const formData = new form_data_1.default();
|
|
88
|
+
formData.append("grant_type", "authorization_code");
|
|
89
|
+
formData.append("client_id", config.android.client_id);
|
|
90
|
+
formData.append("client_secret", config.android.client_secret);
|
|
91
|
+
formData.append("redirect_uri", config.android.redirect_uri);
|
|
92
|
+
formData.append("access_type", "offline");
|
|
93
|
+
formData.append("code", req.query.code);
|
|
94
|
+
const resp = yield (0, node_fetch_1.default)("https://accounts.google.com/o/oauth2/token", {
|
|
95
|
+
method: "POST",
|
|
96
|
+
timeout: 30 * 1000,
|
|
97
|
+
headers: {
|
|
98
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
99
|
+
},
|
|
100
|
+
body: formData,
|
|
101
|
+
});
|
|
102
|
+
if (!resp) {
|
|
103
|
+
throw new functions.https.HttpsError("data-loss", "Cannot get access token.");
|
|
104
|
+
}
|
|
105
|
+
const json = (yield resp.json());
|
|
106
|
+
if (json === null) {
|
|
107
|
+
throw new functions.https.HttpsError("data-loss", "Cannot get access token.");
|
|
108
|
+
}
|
|
109
|
+
console.log(json);
|
|
110
|
+
res.send(`RefreshToken:${json["refresh_token"]}`);
|
|
111
|
+
}
|
|
112
|
+
catch (err) {
|
|
113
|
+
console.error(err);
|
|
114
|
+
res.end();
|
|
115
|
+
}
|
|
116
|
+
}));
|
|
117
|
+
//# sourceMappingURL=android_token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"android_token.js","sourceRoot":"","sources":["../../src/functions/android_token.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAgD;AAChD,4DAA+B;AAC/B,0DAAiC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,CAAC,OAAO,GAAG,CAAC,OAAiB,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,KAAK,CAAC,SAAS,CAChF,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,QAAQ,GAAG,IAAI,mBAAQ,EAAE,CAAC;QAChC,QAAQ,CAAC,MAAM,CAAC,YAAY,EAAE,oBAAoB,CAAC,CAAC;QACpD,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACvD,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QAC/D,QAAQ,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC7D,QAAQ,CAAC,MAAM,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;QAC1C,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACxC,MAAM,IAAI,GAAG,MAAM,IAAA,oBAAK,EAAC,4CAA4C,EAAE;YACnE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE,GAAG,IAAI;YAClB,OAAO,EAAE;gBACL,cAAc,EAAE,mCAAmC;aACtD;YACD,IAAI,EAAE,QAAQ;SACjB,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,EAAE;YACP,MAAM,IAAI,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,WAAW,EAAE,0BAA0B,CAAC,CAAC;SACjF;QACD,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAA2B,CAAC;QAC3D,IAAI,IAAI,KAAK,IAAI,EAAE;YACf,MAAM,IAAI,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,WAAW,EAAE,0BAA0B,CAAC,CAAC;SACjF;QACD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClB,GAAG,CAAC,IAAI,CAAC,gBAAgB,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;KACrD;IAAC,OAAO,GAAG,EAAE;QACV,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,GAAG,CAAC,GAAG,EAAE,CAAC;KACb;AACL,CAAC,CAAA,CACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,132 @@
|
|
|
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
|
+
const functions = __importStar(require("firebase-functions"));
|
|
36
|
+
const verifier = __importStar(require("../lib/verify_android"));
|
|
37
|
+
const updater = __importStar(require("../lib/update_wallet"));
|
|
38
|
+
/**
|
|
39
|
+
* Performs a consumption-type in-app purchase. The value of the field in the document specified in [path] is added to [value].
|
|
40
|
+
*
|
|
41
|
+
* 消費型のアプリ内課金を行います。[path]に指定したドキュメント内のフィールドの値を[value]に加算します。
|
|
42
|
+
*
|
|
43
|
+
* @param purchase.android.refresh_token
|
|
44
|
+
* Describe the refresh token that can be obtained by accessing [android_auth_code].
|
|
45
|
+
*
|
|
46
|
+
* [android_auth_code]にアクセスすることで取得できるリフレッシュトークンを記述します。
|
|
47
|
+
*
|
|
48
|
+
* @param purchase.android.client_id
|
|
49
|
+
* Google's OAuth 2.0 client ID.
|
|
50
|
+
* Create an OAuth consent screen from the URL below.
|
|
51
|
+
* https://console.cloud.google.com/apis/credentials/consent
|
|
52
|
+
* Then create an OAuth 2.0 client ID from the credentials.
|
|
53
|
+
* https://console.cloud.google.com/apis/credentials
|
|
54
|
+
*
|
|
55
|
+
* GoogleのOAuth2.0のクライアントID。
|
|
56
|
+
* 下記のURLからOAuthの同意画面を作成します。
|
|
57
|
+
* https://console.cloud.google.com/apis/credentials/consent
|
|
58
|
+
* その後、認証情報からOAuth 2.0 クライアントIDを作成します。
|
|
59
|
+
* https://console.cloud.google.com/apis/credentials
|
|
60
|
+
*
|
|
61
|
+
* @param purchase.android.client_secret
|
|
62
|
+
* Google's OAuth 2.0 client secret.
|
|
63
|
+
* Create an OAuth consent screen from the URL below.
|
|
64
|
+
* https://console.cloud.google.com/apis/credentials/consent
|
|
65
|
+
* Then create an OAuth 2.0 client ID from the credentials.
|
|
66
|
+
* https://console.cloud.google.com/apis/credentials
|
|
67
|
+
*
|
|
68
|
+
* GoogleのOAuth2.0のクライアントシークレット。
|
|
69
|
+
* 下記のURLからOAuthの同意画面を作成します。
|
|
70
|
+
* https://console.cloud.google.com/apis/credentials/consent
|
|
71
|
+
* その後、認証情報からOAuth 2.0 クライアントIDを作成します。
|
|
72
|
+
* https://console.cloud.google.com/apis/credentials
|
|
73
|
+
*
|
|
74
|
+
* @param path
|
|
75
|
+
* The path, including the key, of the field in the document that stores the in-app wallet information.
|
|
76
|
+
*
|
|
77
|
+
* アプリ内ウォレット情報を保存するドキュメント内のフィールドのキーを含めたパス。
|
|
78
|
+
*
|
|
79
|
+
* @param value
|
|
80
|
+
* Value of the amount to be added.
|
|
81
|
+
*
|
|
82
|
+
* 加算する金額の値。
|
|
83
|
+
*
|
|
84
|
+
* @param packageName
|
|
85
|
+
* Application package name.
|
|
86
|
+
*
|
|
87
|
+
* アプリケーションのパッケージ名。
|
|
88
|
+
*
|
|
89
|
+
* @param productId
|
|
90
|
+
* Item ID issued by Google Play.
|
|
91
|
+
*
|
|
92
|
+
* GooglePlayで発行されたアイテムID。
|
|
93
|
+
*
|
|
94
|
+
* @param purchaseToken
|
|
95
|
+
* The purchase token issued at the time of purchase.
|
|
96
|
+
*
|
|
97
|
+
* 購入したときに発行された購入トークン。
|
|
98
|
+
*/
|
|
99
|
+
module.exports = (regions) => functions.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) {
|
|
117
|
+
return res;
|
|
118
|
+
}
|
|
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
|
+
}));
|
|
132
|
+
//# sourceMappingURL=consumable_verify_android.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consumable_verify_android.js","sourceRoot":"","sources":["../../src/functions/consumable_verify_android.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAgD;AAChD,gEAAkD;AAClD,8DAAgD;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,MAAM,CAAC,OAAO,GAAG,CAAC,OAAiB,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,CAC7E,CAAO,KAAK,EAAE,EAAE;IACZ,IAAI;QACA,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC;QAC3C,6BAA6B;QAC7B,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,aAAa,CAAC;YACrC,IAAI,EAAE,UAAU;YAChB,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS;YAClC,YAAY,EAAE,MAAM,CAAC,OAAO,CAAC,aAAa;YAC1C,YAAY,EAAE,MAAM,CAAC,OAAO,CAAC,aAAa;YAC1C,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,aAAa,EAAE,KAAK,CAAC,aAAa;SACrC,CAAC,CAAC;QACH,IAAI,GAAG,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE;YAC5B,MAAM,IAAI,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,CAAC;SAC/E;QACD,6BAA6B;QAC7B,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE;YAC7B,OAAO,GAAG,CAAC;SACd;QACD,gCAAgC;QAChC,MAAM,OAAO,CAAC,YAAY,CAAC;YACvB,uBAAuB,EAAE,KAAK,CAAC,IAAI;YACnC,KAAK,EAAE,KAAK,CAAC,KAAK;SACrB,CAAC,CAAC;QACH,gCAAgC;QAChC,OAAO,GAAG,CAAC;KACd;IAAC,OAAO,GAAG,EAAE;QACV,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,MAAM,GAAG,CAAC;KACb;AACL,CAAC,CAAA,CACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
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
|
+
const functions = __importStar(require("firebase-functions"));
|
|
36
|
+
const verifier = __importStar(require("../lib/verify_ios"));
|
|
37
|
+
const updater = __importStar(require("../lib/update_wallet"));
|
|
38
|
+
/**
|
|
39
|
+
* Performs a consumption-type in-app purchase. The value of the field in the document specified in [path] is added to [value].
|
|
40
|
+
*
|
|
41
|
+
* 消費型のアプリ内課金を行います。[path]に指定したドキュメント内のフィールドの値を[value]に加算します。
|
|
42
|
+
*
|
|
43
|
+
* @param purchase.ios.shared_secret
|
|
44
|
+
* SharedSecret for AppStore, obtained from [Apps]->[App Info]->[Shared Secret for App] in the AppStore.
|
|
45
|
+
*
|
|
46
|
+
* AppStoreのSharedSecret。AppStoreの[アプリ]->[App情報]->[App用共有シークレット]から取得します。
|
|
47
|
+
*
|
|
48
|
+
* @param path
|
|
49
|
+
* The path, including the key, of the field in the document that stores the in-app wallet information.
|
|
50
|
+
*
|
|
51
|
+
* アプリ内ウォレット情報を保存するドキュメント内のフィールドのキーを含めたパス。
|
|
52
|
+
*
|
|
53
|
+
* @param value
|
|
54
|
+
* Value of the amount to be added.
|
|
55
|
+
*
|
|
56
|
+
* 加算する金額の値。
|
|
57
|
+
*
|
|
58
|
+
* @param receiptData
|
|
59
|
+
* Receipt data for purchases.
|
|
60
|
+
*
|
|
61
|
+
* 購入の際のレシートデータ。
|
|
62
|
+
*/
|
|
63
|
+
module.exports = (regions) => functions.region(...regions).https.onCall((query) => __awaiter(void 0, void 0, void 0, function* () {
|
|
64
|
+
try {
|
|
65
|
+
const config = functions.config().purchase;
|
|
66
|
+
/* ==== IOS検証ここから ==== */
|
|
67
|
+
const res = yield verifier.verifyIOS({
|
|
68
|
+
receiptData: query.receiptData,
|
|
69
|
+
password: config.ios.shared_secret,
|
|
70
|
+
});
|
|
71
|
+
const status = res["status"];
|
|
72
|
+
if (status !== 0) {
|
|
73
|
+
throw new functions.https.HttpsError("unauthenticated", "Illegal receipt.");
|
|
74
|
+
}
|
|
75
|
+
/* ==== ここまでIOS検証 ==== */
|
|
76
|
+
if (!query.path || !query.value) {
|
|
77
|
+
return res;
|
|
78
|
+
}
|
|
79
|
+
/* ==== Firestoreの更新ここから ==== */
|
|
80
|
+
yield updater.updateWallet({
|
|
81
|
+
targetDocumentFieldPath: query.path,
|
|
82
|
+
value: query.value,
|
|
83
|
+
});
|
|
84
|
+
/* ==== ここまでFirestoreの更新 ==== */
|
|
85
|
+
return res;
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
console.error(err);
|
|
89
|
+
throw err;
|
|
90
|
+
}
|
|
91
|
+
}));
|
|
92
|
+
//# sourceMappingURL=consumable_verify_ios.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consumable_verify_ios.js","sourceRoot":"","sources":["../../src/functions/consumable_verify_ios.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAgD;AAChD,4DAA8C;AAC9C,8DAAgD;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,OAAO,GAAG,CAAC,OAAiB,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,CAC7E,CAAO,KAAK,EAAE,EAAE;IACZ,IAAI;QACA,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC;QAC3C,yBAAyB;QACzB,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,SAAS,CAAC;YACjC,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,aAAa;SACrC,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC7B,IAAI,MAAM,KAAK,CAAC,EAAE;YACd,MAAM,IAAI,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,CAAC;SAC/E;QACD,yBAAyB;QACzB,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE;YAC7B,OAAO,GAAG,CAAC;SACd;QACD,gCAAgC;QAChC,MAAM,OAAO,CAAC,YAAY,CAAC;YACvB,uBAAuB,EAAE,KAAK,CAAC,IAAI;YACnC,KAAK,EAAE,KAAK,CAAC,KAAK;SACrB,CACA,CAAC;QACF,gCAAgC;QAChC,OAAO,GAAG,CAAC;KACd;IAAC,OAAO,GAAG,EAAE;QACV,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,MAAM,GAAG,CAAC;KACb;AACL,CAAC,CAAA,CACJ,CAAC"}
|
package/dist/functions/gmail.js
CHANGED
|
@@ -39,7 +39,7 @@ const gmail = __importStar(require("../lib/gmail"));
|
|
|
39
39
|
*
|
|
40
40
|
* Gmailでメールを送信します。
|
|
41
41
|
*
|
|
42
|
-
* @param {string}
|
|
42
|
+
* @param {string} mail.gmail.id
|
|
43
43
|
* Gmail user ID. Follow the steps below to obtain a Gmail user ID.
|
|
44
44
|
* 1. Press your icon in the upper right corner of the Google top screen and open "Manage Google Account".
|
|
45
45
|
* 2. open "Security" on the left side of the screen and open "App Password
|
|
@@ -47,7 +47,7 @@ const gmail = __importStar(require("../lib/gmail"));
|
|
|
47
47
|
* 1. Googleのトップ画面の画面右上の自分のアイコンを押下し、「Google アカウントを管理」を開く
|
|
48
48
|
* 2. 画面左の「セキュリティ」を開き、「アプリ パスワード」を開く
|
|
49
49
|
*
|
|
50
|
-
* @param {string}
|
|
50
|
+
* @param {string} mail.gmail.password
|
|
51
51
|
* Gmail user password. Enter the password obtained in the above procedure.
|
|
52
52
|
* Gmailのユーザーパスワード。上記の手順で取得したパスワードを入力します。
|
|
53
53
|
*
|
|
@@ -76,7 +76,12 @@ module.exports = (regions) => functions.region(...regions).https.onCall((query)
|
|
|
76
76
|
if (!from || !to || !title || !content) {
|
|
77
77
|
throw new functions.https.HttpsError("invalid-argument", "Query parameter is invalid.");
|
|
78
78
|
}
|
|
79
|
-
yield gmail.send(
|
|
79
|
+
yield gmail.send({
|
|
80
|
+
from: from,
|
|
81
|
+
to: to,
|
|
82
|
+
title: title,
|
|
83
|
+
content: content,
|
|
84
|
+
});
|
|
80
85
|
return {
|
|
81
86
|
success: true,
|
|
82
87
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gmail.js","sourceRoot":"","sources":["../../src/functions/gmail.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAgD;AAChD,oDAAsC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,CAAC,OAAO,GAAG,CAAC,OAAiB,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,CAC7E,CAAO,KAAK,EAAE,EAAE;IACZ,IAAI;QACA,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACxB,MAAM,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC;QACpB,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QAC1B,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC9B,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC,OAAO,EAAE;YACpC,MAAM,IAAI,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,kBAAkB,EAAE,6BAA6B,CAAC,CAAC;SAC3F;QACD,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"gmail.js","sourceRoot":"","sources":["../../src/functions/gmail.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAgD;AAChD,oDAAsC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,CAAC,OAAO,GAAG,CAAC,OAAiB,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,CAC7E,CAAO,KAAK,EAAE,EAAE;IACZ,IAAI;QACA,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACxB,MAAM,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC;QACpB,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QAC1B,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC9B,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC,OAAO,EAAE;YACpC,MAAM,IAAI,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,kBAAkB,EAAE,6BAA6B,CAAC,CAAC;SAC3F;QACD,MAAM,KAAK,CAAC,IAAI,CAAC;YACb,IAAI,EAAE,IAAI;YACV,EAAE,EAAE,EAAE;YACN,KAAK,EAAE,KAAK;YACZ,OAAO,EAAE,OAAO;SACnB,CAAC,CAAC;QACH,OAAO;YACH,OAAO,EAAE,IAAI;SAChB,CAAC;KACL;IAAC,OAAO,GAAG,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACjB,MAAM,GAAG,CAAC;KACb;AACL,CAAC,CAAA,CACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,126 @@
|
|
|
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
|
+
const functions = __importStar(require("firebase-functions"));
|
|
36
|
+
const verifier = __importStar(require("../lib/verify_android"));
|
|
37
|
+
const updater = __importStar(require("../lib/update_unlock"));
|
|
38
|
+
/**
|
|
39
|
+
* Performs non-consumable in-app purchases. Unlock by setting the value of the field in the document specified in [path] to `true`.
|
|
40
|
+
*
|
|
41
|
+
* 非消費型のアプリ内課金を行います。[path]に指定したドキュメント内のフィールドの値を`true`にすることでアンロックを行います。
|
|
42
|
+
*
|
|
43
|
+
* @param purchase.android.refresh_token
|
|
44
|
+
* Describe the refresh token that can be obtained by accessing [android_auth_code].
|
|
45
|
+
*
|
|
46
|
+
* [android_auth_code]にアクセスすることで取得できるリフレッシュトークンを記述します。
|
|
47
|
+
*
|
|
48
|
+
* @param purchase.android.client_id
|
|
49
|
+
* Google's OAuth 2.0 client ID.
|
|
50
|
+
* Create an OAuth consent screen from the URL below.
|
|
51
|
+
* https://console.cloud.google.com/apis/credentials/consent
|
|
52
|
+
* Then create an OAuth 2.0 client ID from the credentials.
|
|
53
|
+
* https://console.cloud.google.com/apis/credentials
|
|
54
|
+
*
|
|
55
|
+
* GoogleのOAuth2.0のクライアントID。
|
|
56
|
+
* 下記のURLからOAuthの同意画面を作成します。
|
|
57
|
+
* https://console.cloud.google.com/apis/credentials/consent
|
|
58
|
+
* その後、認証情報からOAuth 2.0 クライアントIDを作成します。
|
|
59
|
+
* https://console.cloud.google.com/apis/credentials
|
|
60
|
+
*
|
|
61
|
+
* @param purchase.android.client_secret
|
|
62
|
+
* Google's OAuth 2.0 client secret.
|
|
63
|
+
* Create an OAuth consent screen from the URL below.
|
|
64
|
+
* https://console.cloud.google.com/apis/credentials/consent
|
|
65
|
+
* Then create an OAuth 2.0 client ID from the credentials.
|
|
66
|
+
* https://console.cloud.google.com/apis/credentials
|
|
67
|
+
*
|
|
68
|
+
* GoogleのOAuth2.0のクライアントシークレット。
|
|
69
|
+
* 下記のURLからOAuthの同意画面を作成します。
|
|
70
|
+
* https://console.cloud.google.com/apis/credentials/consent
|
|
71
|
+
* その後、認証情報からOAuth 2.0 クライアントIDを作成します。
|
|
72
|
+
* https://console.cloud.google.com/apis/credentials
|
|
73
|
+
*
|
|
74
|
+
* @param path
|
|
75
|
+
* The path, including the key, of the field in the document where the unlock information is to be stored.
|
|
76
|
+
*
|
|
77
|
+
* アンロック情報を保存するドキュメント内のフィールドのキーを含めたパス。
|
|
78
|
+
*
|
|
79
|
+
* @param packageName
|
|
80
|
+
* Application package name.
|
|
81
|
+
*
|
|
82
|
+
* アプリケーションのパッケージ名。
|
|
83
|
+
*
|
|
84
|
+
* @param productId
|
|
85
|
+
* Item ID issued by Google Play.
|
|
86
|
+
*
|
|
87
|
+
* GooglePlayで発行されたアイテムID。
|
|
88
|
+
*
|
|
89
|
+
* @param purchaseToken
|
|
90
|
+
* The purchase token issued at the time of purchase.
|
|
91
|
+
*
|
|
92
|
+
* 購入したときに発行された購入トークン。
|
|
93
|
+
*/
|
|
94
|
+
module.exports = (regions) => functions.region(...regions).https.onCall((query) => __awaiter(void 0, void 0, void 0, function* () {
|
|
95
|
+
try {
|
|
96
|
+
const config = functions.config().purchase;
|
|
97
|
+
/* ==== Android検証ここから ==== */
|
|
98
|
+
const res = yield verifier.verifyAndroid({
|
|
99
|
+
type: "products",
|
|
100
|
+
clientId: config.android.client_id,
|
|
101
|
+
clientSecret: config.android.client_secret,
|
|
102
|
+
refreshToken: config.android.refresh_token,
|
|
103
|
+
packageName: query.packageName,
|
|
104
|
+
productId: query.productId,
|
|
105
|
+
purchaseToken: query.purchaseToken
|
|
106
|
+
});
|
|
107
|
+
if (res["purchaseState"] !== 0) {
|
|
108
|
+
throw new functions.https.HttpsError("unauthenticated", "Illegal receipt.");
|
|
109
|
+
}
|
|
110
|
+
/* ==== ここまでAndroid検証 ==== */
|
|
111
|
+
if (!query.path) {
|
|
112
|
+
return res;
|
|
113
|
+
}
|
|
114
|
+
/* ==== Firestoreの更新ここから ==== */
|
|
115
|
+
yield updater.updateUnlock({
|
|
116
|
+
targetDocumentFieldPath: query.path,
|
|
117
|
+
});
|
|
118
|
+
/* ==== ここまでFirestoreの更新 ==== */
|
|
119
|
+
return res;
|
|
120
|
+
}
|
|
121
|
+
catch (err) {
|
|
122
|
+
console.error(err);
|
|
123
|
+
throw err;
|
|
124
|
+
}
|
|
125
|
+
}));
|
|
126
|
+
//# sourceMappingURL=nonconsumable_verify_android.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nonconsumable_verify_android.js","sourceRoot":"","sources":["../../src/functions/nonconsumable_verify_android.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAgD;AAChD,gEAAkD;AAClD,8DAAgD;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,MAAM,CAAC,OAAO,GAAG,CAAC,OAAiB,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,CAC7E,CAAO,KAAK,EAAE,EAAE;IACZ,IAAI;QACA,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC;QAC3C,6BAA6B;QAC7B,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,aAAa,CAAC;YACrC,IAAI,EAAE,UAAU;YAChB,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS;YAClC,YAAY,EAAE,MAAM,CAAC,OAAO,CAAC,aAAa;YAC1C,YAAY,EAAE,MAAM,CAAC,OAAO,CAAC,aAAa;YAC1C,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,aAAa,EAAE,KAAK,CAAC,aAAa;SACrC,CAAC,CAAC;QACH,IAAI,GAAG,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE;YAC5B,MAAM,IAAI,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,CAAC;SAC/E;QACD,6BAA6B;QAC7B,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;YACb,OAAO,GAAG,CAAC;SACd;QACD,gCAAgC;QAChC,MAAM,OAAO,CAAC,YAAY,CAAC;YACvB,uBAAuB,EAAE,KAAK,CAAC,IAAI;SACtC,CAAC,CAAC;QACH,gCAAgC;QAChC,OAAO,GAAG,CAAC;KACd;IAAC,OAAO,GAAG,EAAE;QACV,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,MAAM,GAAG,CAAC;KACb;AACL,CAAC,CAAA,CACJ,CAAC"}
|