cgserver 8.9.3 → 8.9.4
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/README.md +2 -0
- package/dist/lib/Framework/AI/AiObject.js +10 -10
- package/dist/lib/Framework/AI/Astar.js +133 -133
- package/dist/lib/Framework/AI/BehaviorAI.js +307 -307
- package/dist/lib/Framework/AI/Entity.js +33 -33
- package/dist/lib/Framework/AI/Point.js +68 -68
- package/dist/lib/Framework/AI/TriggerMgr.js +201 -201
- package/dist/lib/Framework/Config/Config.js +53 -53
- package/dist/lib/Framework/Config/DbConfig.js +14 -14
- package/dist/lib/Framework/Config/FrameworkConfig.js +207 -207
- package/dist/lib/Framework/Config/IServerConfig.js +26 -26
- package/dist/lib/Framework/Config/_error_.js +35 -35
- package/dist/lib/Framework/Core/Core.js +665 -639
- package/dist/lib/Framework/Core/Timer.js +116 -116
- package/dist/lib/Framework/Database/Decorator/AutoIncrement.js +11 -11
- package/dist/lib/Framework/Database/Decorator/DBCache.js +64 -64
- package/dist/lib/Framework/Database/Decorator/NotNull.js +11 -11
- package/dist/lib/Framework/Database/Decorator/PrimaryKey.js +11 -11
- package/dist/lib/Framework/Database/Decorator/Property.js +61 -61
- package/dist/lib/Framework/Database/Decorator/Table.js +15 -15
- package/dist/lib/Framework/Database/Decorator/Type.js +20 -20
- package/dist/lib/Framework/Database/MSSqlManager.js +53 -53
- package/dist/lib/Framework/Database/MongoBaseService.js +117 -117
- package/dist/lib/Framework/Database/MongoManager.js +467 -467
- package/dist/lib/Framework/Database/MysqlBaseService.js +281 -281
- package/dist/lib/Framework/Database/MysqlManager.js +179 -179
- package/dist/lib/Framework/Database/RedisManager.js +61 -61
- package/dist/lib/Framework/Decorator/AdminValidate.js +19 -19
- package/dist/lib/Framework/Decorator/AuthorityValidate.js +22 -22
- package/dist/lib/Framework/Decorator/CreatorValidate.js +19 -19
- package/dist/lib/Framework/Decorator/JsonAdminValidate.js +15 -15
- package/dist/lib/Framework/Decorator/JsonAuthorityValidate.js +20 -20
- package/dist/lib/Framework/Decorator/JsonCreatorValidate.js +19 -19
- package/dist/lib/Framework/Decorator/SyncCall.js +42 -42
- package/dist/lib/Framework/Decorator/SyncCallServer.js +77 -77
- package/dist/lib/Framework/Logic/CacheTool.js +73 -73
- package/dist/lib/Framework/Logic/EventTool.js +27 -27
- package/dist/lib/Framework/Logic/HttpTool.js +75 -75
- package/dist/lib/Framework/Logic/Log.js +140 -140
- package/dist/lib/Framework/Logic/SyncQueueTool.js +43 -43
- package/dist/lib/Framework/Service/MongoAccountService.js +367 -367
- package/dist/lib/Framework/Service/MongoCacheService.js +42 -42
- package/dist/lib/Framework/Service/MongoUserService.js +100 -100
- package/dist/lib/Framework/Service/MysqlAccountService.js +441 -441
- package/dist/lib/Framework/Service/MysqlUserService.js +171 -171
- package/dist/lib/Framework/Service/ini.js +36 -36
- package/dist/lib/Framework/SocketServer/IClientWebSocket.js +44 -44
- package/dist/lib/Framework/SocketServer/IRpc.js +12 -12
- package/dist/lib/Framework/SocketServer/IRpcClientWebSocket.js +63 -63
- package/dist/lib/Framework/SocketServer/IRpcServerWebSocket.js +63 -63
- package/dist/lib/Framework/SocketServer/IServerWebSocket.js +75 -75
- package/dist/lib/Framework/SocketServer/ISocketServer.js +205 -205
- package/dist/lib/Framework/SocketServer/IWebSocket.js +195 -195
- package/dist/lib/Framework/SocketServer/ProtoFilter/GoogleProtoFilter.js +57 -57
- package/dist/lib/Framework/SocketServer/ProtoFilter/IProtoFilter.js +8 -8
- package/dist/lib/Framework/SocketServer/ProtoFilter/JsonProtoFilter.js +29 -29
- package/dist/lib/Framework/SocketServer/ProtoFilter/ProtoFactory.js +31 -31
- package/dist/lib/Framework/ThirdParty/AlipayTool.js +203 -203
- package/dist/lib/Framework/ThirdParty/Alisms.js +46 -46
- package/dist/lib/Framework/ThirdParty/AppleTool.js +234 -234
- package/dist/lib/Framework/ThirdParty/CgMq.js +132 -132
- package/dist/lib/Framework/ThirdParty/EmailTool.js +33 -33
- package/dist/lib/Framework/ThirdParty/OpenSocial.js +32 -32
- package/dist/lib/Framework/ThirdParty/QQTool.js +118 -118
- package/dist/lib/Framework/ThirdParty/QiniuTool.js +21 -21
- package/dist/lib/Framework/ThirdParty/Rpc.js +63 -63
- package/dist/lib/Framework/ThirdParty/WechatOATool.js +61 -61
- package/dist/lib/Framework/ThirdParty/WechatTool.js +74 -74
- package/dist/lib/Framework/WebServer/Controller/BaseController.js +112 -112
- package/dist/lib/Framework/WebServer/Controller/MongoBaseUserController.js +169 -169
- package/dist/lib/Framework/WebServer/Controller/MysqlBaseUserController.js +169 -169
- package/dist/lib/Framework/WebServer/Engine/ControllerManager.js +112 -112
- package/dist/lib/Framework/WebServer/Engine/Engine.js +152 -152
- package/dist/lib/Framework/WebServer/Engine/RazorJs.js +544 -544
- package/dist/lib/Framework/WebServer/Engine/Request.js +237 -237
- package/dist/lib/Framework/WebServer/Engine/Response.js +100 -100
- package/dist/lib/Framework/WebServer/IWebServer.js +59 -59
- package/dist/lib/Framework/cgserver.js +121 -121
- package/dist/lib/Framework/index.js +202 -202
- package/dist/lib/test/test.js +21 -21
- package/dist/types/Framework/AI/AiObject.d.ts +5 -5
- package/dist/types/Framework/AI/Astar.d.ts +38 -38
- package/dist/types/Framework/AI/BehaviorAI.d.ts +24 -24
- package/dist/types/Framework/AI/Entity.d.ts +12 -12
- package/dist/types/Framework/AI/Point.d.ts +17 -17
- package/dist/types/Framework/AI/TriggerMgr.d.ts +52 -52
- package/dist/types/Framework/Config/Config.d.ts +12 -12
- package/dist/types/Framework/Config/DbConfig.d.ts +10 -10
- package/dist/types/Framework/Config/FrameworkConfig.d.ts +203 -203
- package/dist/types/Framework/Config/IServerConfig.d.ts +9 -9
- package/dist/types/Framework/Config/_error_.d.ts +99 -99
- package/dist/types/Framework/Core/Core.d.ts +111 -108
- package/dist/types/Framework/Core/Timer.d.ts +16 -16
- package/dist/types/Framework/Database/Decorator/AutoIncrement.d.ts +1 -1
- package/dist/types/Framework/Database/Decorator/DBCache.d.ts +23 -23
- package/dist/types/Framework/Database/Decorator/NotNull.d.ts +1 -1
- package/dist/types/Framework/Database/Decorator/PrimaryKey.d.ts +1 -1
- package/dist/types/Framework/Database/Decorator/Property.d.ts +57 -57
- package/dist/types/Framework/Database/Decorator/Table.d.ts +1 -1
- package/dist/types/Framework/Database/Decorator/Type.d.ts +1 -1
- package/dist/types/Framework/Database/MSSqlManager.d.ts +27 -27
- package/dist/types/Framework/Database/MongoBaseService.d.ts +81 -81
- package/dist/types/Framework/Database/MongoManager.d.ts +155 -155
- package/dist/types/Framework/Database/MysqlBaseService.d.ts +34 -34
- package/dist/types/Framework/Database/MysqlManager.d.ts +53 -53
- package/dist/types/Framework/Database/RedisManager.d.ts +24 -24
- package/dist/types/Framework/Decorator/AdminValidate.d.ts +1 -1
- package/dist/types/Framework/Decorator/AuthorityValidate.d.ts +2 -2
- package/dist/types/Framework/Decorator/CreatorValidate.d.ts +1 -1
- package/dist/types/Framework/Decorator/JsonAdminValidate.d.ts +1 -1
- package/dist/types/Framework/Decorator/JsonAuthorityValidate.d.ts +2 -2
- package/dist/types/Framework/Decorator/JsonCreatorValidate.d.ts +1 -1
- package/dist/types/Framework/Decorator/SyncCall.d.ts +12 -12
- package/dist/types/Framework/Decorator/SyncCallServer.d.ts +14 -14
- package/dist/types/Framework/Logic/CacheTool.d.ts +27 -27
- package/dist/types/Framework/Logic/EventTool.d.ts +13 -13
- package/dist/types/Framework/Logic/HttpTool.d.ts +15 -15
- package/dist/types/Framework/Logic/Log.d.ts +25 -25
- package/dist/types/Framework/Logic/SyncQueueTool.d.ts +21 -21
- package/dist/types/Framework/Service/MongoAccountService.d.ts +69 -69
- package/dist/types/Framework/Service/MongoCacheService.d.ts +14 -14
- package/dist/types/Framework/Service/MongoUserService.d.ts +35 -35
- package/dist/types/Framework/Service/MysqlAccountService.d.ts +74 -74
- package/dist/types/Framework/Service/MysqlUserService.d.ts +33 -33
- package/dist/types/Framework/Service/ini.d.ts +29 -29
- package/dist/types/Framework/SocketServer/IClientWebSocket.d.ts +17 -17
- package/dist/types/Framework/SocketServer/IRpc.d.ts +8 -8
- package/dist/types/Framework/SocketServer/IRpcClientWebSocket.d.ts +16 -16
- package/dist/types/Framework/SocketServer/IRpcServerWebSocket.d.ts +16 -16
- package/dist/types/Framework/SocketServer/IServerWebSocket.d.ts +28 -28
- package/dist/types/Framework/SocketServer/ISocketServer.d.ts +45 -45
- package/dist/types/Framework/SocketServer/IWebSocket.d.ts +60 -60
- package/dist/types/Framework/SocketServer/ProtoFilter/GoogleProtoFilter.d.ts +9 -9
- package/dist/types/Framework/SocketServer/ProtoFilter/IProtoFilter.d.ts +9 -9
- package/dist/types/Framework/SocketServer/ProtoFilter/JsonProtoFilter.d.ts +6 -6
- package/dist/types/Framework/SocketServer/ProtoFilter/ProtoFactory.d.ts +8 -8
- package/dist/types/Framework/ThirdParty/AlipayTool.d.ts +109 -109
- package/dist/types/Framework/ThirdParty/Alisms.d.ts +14 -14
- package/dist/types/Framework/ThirdParty/AppleTool.d.ts +131 -131
- package/dist/types/Framework/ThirdParty/CgMq.d.ts +51 -51
- package/dist/types/Framework/ThirdParty/EmailTool.d.ts +5 -5
- package/dist/types/Framework/ThirdParty/OpenSocial.d.ts +7 -7
- package/dist/types/Framework/ThirdParty/QQTool.d.ts +41 -41
- package/dist/types/Framework/ThirdParty/QiniuTool.d.ts +6 -6
- package/dist/types/Framework/ThirdParty/Rpc.d.ts +20 -20
- package/dist/types/Framework/ThirdParty/WechatOATool.d.ts +13 -13
- package/dist/types/Framework/ThirdParty/WechatTool.d.ts +20 -20
- package/dist/types/Framework/WebServer/Controller/BaseController.d.ts +33 -33
- package/dist/types/Framework/WebServer/Controller/MongoBaseUserController.d.ts +27 -27
- package/dist/types/Framework/WebServer/Controller/MysqlBaseUserController.d.ts +27 -27
- package/dist/types/Framework/WebServer/Engine/ControllerManager.d.ts +35 -35
- package/dist/types/Framework/WebServer/Engine/Engine.d.ts +22 -21
- package/dist/types/Framework/WebServer/Engine/RazorJs.d.ts +21 -21
- package/dist/types/Framework/WebServer/Engine/Request.d.ts +36 -35
- package/dist/types/Framework/WebServer/Engine/Response.d.ts +30 -30
- package/dist/types/Framework/WebServer/IWebServer.d.ts +20 -20
- package/dist/types/Framework/cgserver.d.ts +27 -27
- package/dist/types/Framework/index.d.ts +91 -91
- package/dist/types/test/test.d.ts +1 -1
- package/package.json +1 -1
- package/dist/lib/Framework/WebServer/Decorator/AdminValidate.js +0 -19
- package/dist/lib/Framework/WebServer/Decorator/AuthorityValidate.js +0 -22
- package/dist/lib/Framework/WebServer/Decorator/CreatorValidate.js +0 -19
- package/dist/lib/Framework/WebServer/Decorator/JsonAdminValidate.js +0 -15
- package/dist/lib/Framework/WebServer/Decorator/JsonAuthorityValidate.js +0 -20
- package/dist/lib/Framework/WebServer/Decorator/JsonCreatorValidate.js +0 -19
- package/dist/lib/Framework/WebServer/Decorator/SyncCall.js +0 -41
- package/dist/lib/Framework/WebServer/Decorator/SyncCallServer.js +0 -77
- package/dist/types/Framework/WebServer/Decorator/AdminValidate.d.ts +0 -1
- package/dist/types/Framework/WebServer/Decorator/AuthorityValidate.d.ts +0 -2
- package/dist/types/Framework/WebServer/Decorator/CreatorValidate.d.ts +0 -1
- package/dist/types/Framework/WebServer/Decorator/JsonAdminValidate.d.ts +0 -1
- package/dist/types/Framework/WebServer/Decorator/JsonAuthorityValidate.d.ts +0 -2
- package/dist/types/Framework/WebServer/Decorator/JsonCreatorValidate.d.ts +0 -1
- package/dist/types/Framework/WebServer/Decorator/SyncCall.d.ts +0 -12
- package/dist/types/Framework/WebServer/Decorator/SyncCallServer.d.ts +0 -14
|
@@ -1,234 +1,234 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GAppleTool = exports.NotificationBody = exports.NotificationType = exports.ResponseBody = void 0;
|
|
4
|
-
const Log_1 = require("../Logic/Log");
|
|
5
|
-
const HttpTool_1 = require("./../Logic/HttpTool");
|
|
6
|
-
const ec_key_1 = require("ec-key");
|
|
7
|
-
const uuid_1 = require("uuid");
|
|
8
|
-
const fs = require("fs");
|
|
9
|
-
const IServerConfig_1 = require("../Config/IServerConfig");
|
|
10
|
-
//developer.apple.com/documentation/appstorereceipts/responsebody
|
|
11
|
-
class ReceiptInfo {
|
|
12
|
-
cancellation_date = "";
|
|
13
|
-
cancellation_date_ms = "";
|
|
14
|
-
cancellation_date_pst = "";
|
|
15
|
-
cancellation_date_reason = "";
|
|
16
|
-
expires_date = "2021-03-10 14:25:54 Etc/GMT";
|
|
17
|
-
expires_date_ms = "1615386354000";
|
|
18
|
-
expires_date_pst = "2021-03-10 06:25:54 America/Los_Angeles";
|
|
19
|
-
in_app_ownership_type;
|
|
20
|
-
is_in_intro_offer_period = false;
|
|
21
|
-
is_trial_period = false;
|
|
22
|
-
is_upgraded = false;
|
|
23
|
-
offer_code_ref_name = "";
|
|
24
|
-
original_purchase_date = "2021-03-10 08:22:26 Etc/GMT";
|
|
25
|
-
original_purchase_date_ms = "1615364546000";
|
|
26
|
-
original_purchase_date_pst = "2021-03-10 00:22:26 America/Los_Angeles";
|
|
27
|
-
original_transaction_id = "1000000786747716";
|
|
28
|
-
purchase_date = "2021-03-10 14:22:54 Etc/GMT";
|
|
29
|
-
purchase_date_ms = "1615386174000";
|
|
30
|
-
purchase_date_pst = "2021-03-10 06:22:54 America/Los_Angeles";
|
|
31
|
-
quantity = 1;
|
|
32
|
-
subscription_group_identifier = "20745320";
|
|
33
|
-
web_order_line_item_id = "1000000060695307";
|
|
34
|
-
transaction_id = "1000000786974540";
|
|
35
|
-
product_id = "com.eryi.eyreader.week";
|
|
36
|
-
}
|
|
37
|
-
class PendingRenewalInfo {
|
|
38
|
-
auto_renew_product_id = "com.eryi.eyreader.week";
|
|
39
|
-
auto_renew_status = 0;
|
|
40
|
-
expiration_intent = 1;
|
|
41
|
-
grace_period_expires_date = "";
|
|
42
|
-
grace_period_expires_date_ms = "";
|
|
43
|
-
grace_period_expires_date_pst = "";
|
|
44
|
-
is_in_billing_retry_period = 0;
|
|
45
|
-
offer_code_ref_name = "";
|
|
46
|
-
original_transaction_id = "1000000786747716";
|
|
47
|
-
price_consent_status = "";
|
|
48
|
-
product_id = "com.eryi.eyreader.week";
|
|
49
|
-
promotional_offer_id = "";
|
|
50
|
-
}
|
|
51
|
-
class InApp {
|
|
52
|
-
cancellation_date = "";
|
|
53
|
-
cancellation_date_ms = "";
|
|
54
|
-
cancellation_date_pst = "";
|
|
55
|
-
cancellation_reason = "";
|
|
56
|
-
expires_date = "2021-03-10 14:25:54 Etc/GMT";
|
|
57
|
-
expires_date_ms = "1615386354000";
|
|
58
|
-
expires_date_pst = "2021-03-10 06:25:54 America/Los_Angeles";
|
|
59
|
-
is_in_intro_offer_period = false;
|
|
60
|
-
is_trial_period = false;
|
|
61
|
-
original_purchase_date = "2021-03-10 08:22:26 Etc/GMT";
|
|
62
|
-
original_purchase_date_ms = "1615364546000";
|
|
63
|
-
original_purchase_date_pst = "2021-03-10 00:22:26 America/Los_Angeles";
|
|
64
|
-
original_transaction_id = "1000000786747716";
|
|
65
|
-
product_id = "com.eryi.eyreader.week";
|
|
66
|
-
promotional_offer_id = "";
|
|
67
|
-
purchase_date = "2021-03-10 14:22:54 Etc/GMT";
|
|
68
|
-
purchase_date_ms = "1615386174000";
|
|
69
|
-
purchase_date_pst = "2021-03-10 06:22:54 America/Los_Angeles";
|
|
70
|
-
quantity = 1;
|
|
71
|
-
transaction_id = "1000000786974540";
|
|
72
|
-
web_order_line_item_id = "1000000060695307";
|
|
73
|
-
}
|
|
74
|
-
class Receipt {
|
|
75
|
-
adam_id = -1;
|
|
76
|
-
app_item_id = -1;
|
|
77
|
-
application_version = "";
|
|
78
|
-
bundle_id = "";
|
|
79
|
-
download_id = -1;
|
|
80
|
-
expiration_date = "";
|
|
81
|
-
expiration_date_ms = "";
|
|
82
|
-
expiration_date_pst = "";
|
|
83
|
-
in_app = null;
|
|
84
|
-
original_application_version = "";
|
|
85
|
-
original_purchase_date = "";
|
|
86
|
-
original_purchase_date_ms = "";
|
|
87
|
-
original_purchase_date_pst = "";
|
|
88
|
-
preorder_date = "";
|
|
89
|
-
preorder_date_ms = "";
|
|
90
|
-
preorder_date_pst = "";
|
|
91
|
-
receipt_creation_date = "";
|
|
92
|
-
receipt_creation_date_ms = "";
|
|
93
|
-
receipt_creation_date_pst = "";
|
|
94
|
-
receipt_type = "";
|
|
95
|
-
request_date = "";
|
|
96
|
-
request_date_ms = "";
|
|
97
|
-
request_date_pst = "";
|
|
98
|
-
version_external_identifier = -1;
|
|
99
|
-
}
|
|
100
|
-
class ResponseBody {
|
|
101
|
-
environment = "Sandbox";
|
|
102
|
-
is_retryable = false; //出错之后的重试
|
|
103
|
-
latest_receipt = "0OkG/Sw==";
|
|
104
|
-
latest_receipt_info = null;
|
|
105
|
-
pending_renewal_info = null;
|
|
106
|
-
receipt = null;
|
|
107
|
-
status = 0;
|
|
108
|
-
}
|
|
109
|
-
exports.ResponseBody = ResponseBody;
|
|
110
|
-
class NotificationType {
|
|
111
|
-
//退款
|
|
112
|
-
static CANCEL = "CANCEL";
|
|
113
|
-
//变更续订方式,下次续订的时候生效,当前不变
|
|
114
|
-
static DID_CHANGE_RENEWAL_PREF = "DID_CHANGE_RENEWAL_PREF";
|
|
115
|
-
/*
|
|
116
|
-
续订状态发生变化的时候通知
|
|
117
|
-
检查auto_renew_status_change_date_ms获取最新的状态更新时间.
|
|
118
|
-
通过auto_renew_status了解当前续订状态.
|
|
119
|
-
*/
|
|
120
|
-
static DID_CHANGE_RENEWAL_STATUS = "DID_CHANGE_RENEWAL_STATUS";
|
|
121
|
-
//自动续订了一个之前续订失败了的续订
|
|
122
|
-
static DID_RECOVER = "DID_RECOVER";
|
|
123
|
-
//自动续订成功
|
|
124
|
-
static DID_RENEW = "DID_RENEW";
|
|
125
|
-
//客户交互更新订阅,订阅可以立刻生效
|
|
126
|
-
static INTERACTIVE_RENEWAL = "INTERACTIVE_RENEWAL";
|
|
127
|
-
}
|
|
128
|
-
exports.NotificationType = NotificationType;
|
|
129
|
-
class NotificationBody {
|
|
130
|
-
unified_receipt = null;
|
|
131
|
-
environment = "Sandbox";
|
|
132
|
-
auto_renew_status = "false";
|
|
133
|
-
auto_renew_status_change_date = "2021-03-11 03:03:14 Etc/GMT";
|
|
134
|
-
bvrs = "1";
|
|
135
|
-
bid = "com.eryi.eyreader";
|
|
136
|
-
password = "5203c7781e254aac8942290a0a2467ac";
|
|
137
|
-
auto_renew_product_id = "com.eryi.eyreader.week";
|
|
138
|
-
notification_type = NotificationType.DID_RECOVER;
|
|
139
|
-
}
|
|
140
|
-
exports.NotificationBody = NotificationBody;
|
|
141
|
-
class RequestBody {
|
|
142
|
-
"receipt-data" = "";
|
|
143
|
-
password = "5203c7781e254aac8942290a0a2467ac";
|
|
144
|
-
"exclude-old-transactions" = true;
|
|
145
|
-
}
|
|
146
|
-
exports.GAppleTool = null;
|
|
147
|
-
class AppleTool {
|
|
148
|
-
_verifyUrl = "https://buy.itunes.apple.com/verifyReceipt";
|
|
149
|
-
_sandboxVerifyUrl = "https://sandbox.itunes.apple.com/verifyReceipt";
|
|
150
|
-
async onNotify(nb) {
|
|
151
|
-
let ris = nb.unified_receipt?.latest_receipt_info;
|
|
152
|
-
var latest_one = (ris?.length > 0 ? ris[0] : null);
|
|
153
|
-
let msg = {
|
|
154
|
-
"notification_type": nb.notification_type,
|
|
155
|
-
"status": nb.unified_receipt.status,
|
|
156
|
-
"environment": nb.environment,
|
|
157
|
-
"auto_renew_status": nb.auto_renew_status,
|
|
158
|
-
"orginal_transaction_id": latest_one?.original_transaction_id,
|
|
159
|
-
"transaction_id": latest_one?.transaction_id,
|
|
160
|
-
"expire_date": latest_one?.expires_date,
|
|
161
|
-
"receipt_expire_date": nb.unified_receipt?.receipt?.expiration_date
|
|
162
|
-
};
|
|
163
|
-
Log_1.GLog.info(msg);
|
|
164
|
-
Log_1.GLog.info(nb);
|
|
165
|
-
}
|
|
166
|
-
async onVerify(receipt, environment) {
|
|
167
|
-
Log_1.GLog.info("begin onVerify============================" + environment);
|
|
168
|
-
let url = this._verifyUrl;
|
|
169
|
-
// if(environment.toLowerCase()=="sandbox")
|
|
170
|
-
// {
|
|
171
|
-
// url=this._sandboxVerifyUrl
|
|
172
|
-
// }
|
|
173
|
-
Log_1.GLog.info("url============================" + url);
|
|
174
|
-
let reqb = new RequestBody();
|
|
175
|
-
reqb['receipt-data'] = receipt;
|
|
176
|
-
//先验证生产环境
|
|
177
|
-
var resb = (await HttpTool_1.GHttpTool.post({ url, form: JSON.stringify(reqb) })).body;
|
|
178
|
-
Log_1.GLog.info("production end onVerify_Res============================status=" + (resb ? resb.status : "null"));
|
|
179
|
-
//状态21007表示是沙盒环境
|
|
180
|
-
if (resb && resb.status == 21007) {
|
|
181
|
-
url = this._sandboxVerifyUrl;
|
|
182
|
-
resb = (await HttpTool_1.GHttpTool.post({ url, form: JSON.stringify(reqb) })).body;
|
|
183
|
-
Log_1.GLog.info("sandbox end onVerify_Res============================status=" + (resb ? resb.status : "null"));
|
|
184
|
-
}
|
|
185
|
-
Log_1.GLog.info(resb);
|
|
186
|
-
return resb;
|
|
187
|
-
}
|
|
188
|
-
signature(nickname, create_time, appBundleID, productIdentifier, offerIdentifier) {
|
|
189
|
-
let keyIdentifier = "";
|
|
190
|
-
for (var k in IServerConfig_1.GServerCfg.third_cfg.apple.keyIds) {
|
|
191
|
-
keyIdentifier = k;
|
|
192
|
-
break;
|
|
193
|
-
}
|
|
194
|
-
var nonce = (0, uuid_1.v4)();
|
|
195
|
-
var payload = appBundleID + '\u2063' +
|
|
196
|
-
keyIdentifier + '\u2063' +
|
|
197
|
-
productIdentifier + '\u2063' +
|
|
198
|
-
offerIdentifier + '\u2063' +
|
|
199
|
-
nickname + '\u2063' +
|
|
200
|
-
nonce.toLowerCase() + '\u2063' +
|
|
201
|
-
create_time;
|
|
202
|
-
// Get the PEM-formatted private key string associated with the Key ID.
|
|
203
|
-
const path = IServerConfig_1.GServerCfg.third_cfg.apple.keyIds[keyIdentifier];
|
|
204
|
-
const keyString = fs.readFileSync(path).toString();
|
|
205
|
-
// Create an Elliptic Curve Digital Signature Algorithm (ECDSA) object using the private key.
|
|
206
|
-
const key = new ec_key_1.default(keyString, 'pem');
|
|
207
|
-
// Set up the cryptographic format used to sign the key with the SHA-256 hashing algorithm.
|
|
208
|
-
const cryptoSign = key.createSign('SHA256');
|
|
209
|
-
// Add the payload string to sign.
|
|
210
|
-
cryptoSign.update(payload);
|
|
211
|
-
/*
|
|
212
|
-
The Node.js crypto library creates a DER-formatted binary value signature,
|
|
213
|
-
and then base-64 encodes it to create the string that you will use in StoreKit.
|
|
214
|
-
*/
|
|
215
|
-
const signature = cryptoSign.sign('base64');
|
|
216
|
-
/*
|
|
217
|
-
Check that the signature passes verification by using the ec-key library.
|
|
218
|
-
The verification process is similar to creating the signature, except it uses 'createVerify'
|
|
219
|
-
instead of 'createSign', and after updating it with the payload, it uses `verify` to pass in
|
|
220
|
-
the signature and encoding, instead of `sign` to get the signature.
|
|
221
|
-
|
|
222
|
-
This step is not required, but it's useful to check when implementing your signature code.
|
|
223
|
-
This helps debug issues with signing before sending transactions to Apple.
|
|
224
|
-
If verification succeeds, the next recommended testing step is attempting a purchase
|
|
225
|
-
in the Sandbox environment.
|
|
226
|
-
*/
|
|
227
|
-
const verificationResult = key.createVerify('SHA256').update(payload).verify(signature, 'base64');
|
|
228
|
-
if (verificationResult) {
|
|
229
|
-
return { 'keyIdentifier': keyIdentifier, 'nonce': nonce, 'timestamp': create_time, 'signature': signature };
|
|
230
|
-
}
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
exports.GAppleTool = new AppleTool();
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GAppleTool = exports.NotificationBody = exports.NotificationType = exports.ResponseBody = void 0;
|
|
4
|
+
const Log_1 = require("../Logic/Log");
|
|
5
|
+
const HttpTool_1 = require("./../Logic/HttpTool");
|
|
6
|
+
const ec_key_1 = require("ec-key");
|
|
7
|
+
const uuid_1 = require("uuid");
|
|
8
|
+
const fs = require("fs");
|
|
9
|
+
const IServerConfig_1 = require("../Config/IServerConfig");
|
|
10
|
+
//developer.apple.com/documentation/appstorereceipts/responsebody
|
|
11
|
+
class ReceiptInfo {
|
|
12
|
+
cancellation_date = "";
|
|
13
|
+
cancellation_date_ms = "";
|
|
14
|
+
cancellation_date_pst = "";
|
|
15
|
+
cancellation_date_reason = "";
|
|
16
|
+
expires_date = "2021-03-10 14:25:54 Etc/GMT";
|
|
17
|
+
expires_date_ms = "1615386354000";
|
|
18
|
+
expires_date_pst = "2021-03-10 06:25:54 America/Los_Angeles";
|
|
19
|
+
in_app_ownership_type;
|
|
20
|
+
is_in_intro_offer_period = false;
|
|
21
|
+
is_trial_period = false;
|
|
22
|
+
is_upgraded = false;
|
|
23
|
+
offer_code_ref_name = "";
|
|
24
|
+
original_purchase_date = "2021-03-10 08:22:26 Etc/GMT";
|
|
25
|
+
original_purchase_date_ms = "1615364546000";
|
|
26
|
+
original_purchase_date_pst = "2021-03-10 00:22:26 America/Los_Angeles";
|
|
27
|
+
original_transaction_id = "1000000786747716";
|
|
28
|
+
purchase_date = "2021-03-10 14:22:54 Etc/GMT";
|
|
29
|
+
purchase_date_ms = "1615386174000";
|
|
30
|
+
purchase_date_pst = "2021-03-10 06:22:54 America/Los_Angeles";
|
|
31
|
+
quantity = 1;
|
|
32
|
+
subscription_group_identifier = "20745320";
|
|
33
|
+
web_order_line_item_id = "1000000060695307";
|
|
34
|
+
transaction_id = "1000000786974540";
|
|
35
|
+
product_id = "com.eryi.eyreader.week";
|
|
36
|
+
}
|
|
37
|
+
class PendingRenewalInfo {
|
|
38
|
+
auto_renew_product_id = "com.eryi.eyreader.week";
|
|
39
|
+
auto_renew_status = 0;
|
|
40
|
+
expiration_intent = 1;
|
|
41
|
+
grace_period_expires_date = "";
|
|
42
|
+
grace_period_expires_date_ms = "";
|
|
43
|
+
grace_period_expires_date_pst = "";
|
|
44
|
+
is_in_billing_retry_period = 0;
|
|
45
|
+
offer_code_ref_name = "";
|
|
46
|
+
original_transaction_id = "1000000786747716";
|
|
47
|
+
price_consent_status = "";
|
|
48
|
+
product_id = "com.eryi.eyreader.week";
|
|
49
|
+
promotional_offer_id = "";
|
|
50
|
+
}
|
|
51
|
+
class InApp {
|
|
52
|
+
cancellation_date = "";
|
|
53
|
+
cancellation_date_ms = "";
|
|
54
|
+
cancellation_date_pst = "";
|
|
55
|
+
cancellation_reason = "";
|
|
56
|
+
expires_date = "2021-03-10 14:25:54 Etc/GMT";
|
|
57
|
+
expires_date_ms = "1615386354000";
|
|
58
|
+
expires_date_pst = "2021-03-10 06:25:54 America/Los_Angeles";
|
|
59
|
+
is_in_intro_offer_period = false;
|
|
60
|
+
is_trial_period = false;
|
|
61
|
+
original_purchase_date = "2021-03-10 08:22:26 Etc/GMT";
|
|
62
|
+
original_purchase_date_ms = "1615364546000";
|
|
63
|
+
original_purchase_date_pst = "2021-03-10 00:22:26 America/Los_Angeles";
|
|
64
|
+
original_transaction_id = "1000000786747716";
|
|
65
|
+
product_id = "com.eryi.eyreader.week";
|
|
66
|
+
promotional_offer_id = "";
|
|
67
|
+
purchase_date = "2021-03-10 14:22:54 Etc/GMT";
|
|
68
|
+
purchase_date_ms = "1615386174000";
|
|
69
|
+
purchase_date_pst = "2021-03-10 06:22:54 America/Los_Angeles";
|
|
70
|
+
quantity = 1;
|
|
71
|
+
transaction_id = "1000000786974540";
|
|
72
|
+
web_order_line_item_id = "1000000060695307";
|
|
73
|
+
}
|
|
74
|
+
class Receipt {
|
|
75
|
+
adam_id = -1;
|
|
76
|
+
app_item_id = -1;
|
|
77
|
+
application_version = "";
|
|
78
|
+
bundle_id = "";
|
|
79
|
+
download_id = -1;
|
|
80
|
+
expiration_date = "";
|
|
81
|
+
expiration_date_ms = "";
|
|
82
|
+
expiration_date_pst = "";
|
|
83
|
+
in_app = null;
|
|
84
|
+
original_application_version = "";
|
|
85
|
+
original_purchase_date = "";
|
|
86
|
+
original_purchase_date_ms = "";
|
|
87
|
+
original_purchase_date_pst = "";
|
|
88
|
+
preorder_date = "";
|
|
89
|
+
preorder_date_ms = "";
|
|
90
|
+
preorder_date_pst = "";
|
|
91
|
+
receipt_creation_date = "";
|
|
92
|
+
receipt_creation_date_ms = "";
|
|
93
|
+
receipt_creation_date_pst = "";
|
|
94
|
+
receipt_type = "";
|
|
95
|
+
request_date = "";
|
|
96
|
+
request_date_ms = "";
|
|
97
|
+
request_date_pst = "";
|
|
98
|
+
version_external_identifier = -1;
|
|
99
|
+
}
|
|
100
|
+
class ResponseBody {
|
|
101
|
+
environment = "Sandbox";
|
|
102
|
+
is_retryable = false; //出错之后的重试
|
|
103
|
+
latest_receipt = "0OkG/Sw==";
|
|
104
|
+
latest_receipt_info = null;
|
|
105
|
+
pending_renewal_info = null;
|
|
106
|
+
receipt = null;
|
|
107
|
+
status = 0;
|
|
108
|
+
}
|
|
109
|
+
exports.ResponseBody = ResponseBody;
|
|
110
|
+
class NotificationType {
|
|
111
|
+
//退款
|
|
112
|
+
static CANCEL = "CANCEL";
|
|
113
|
+
//变更续订方式,下次续订的时候生效,当前不变
|
|
114
|
+
static DID_CHANGE_RENEWAL_PREF = "DID_CHANGE_RENEWAL_PREF";
|
|
115
|
+
/*
|
|
116
|
+
续订状态发生变化的时候通知
|
|
117
|
+
检查auto_renew_status_change_date_ms获取最新的状态更新时间.
|
|
118
|
+
通过auto_renew_status了解当前续订状态.
|
|
119
|
+
*/
|
|
120
|
+
static DID_CHANGE_RENEWAL_STATUS = "DID_CHANGE_RENEWAL_STATUS";
|
|
121
|
+
//自动续订了一个之前续订失败了的续订
|
|
122
|
+
static DID_RECOVER = "DID_RECOVER";
|
|
123
|
+
//自动续订成功
|
|
124
|
+
static DID_RENEW = "DID_RENEW";
|
|
125
|
+
//客户交互更新订阅,订阅可以立刻生效
|
|
126
|
+
static INTERACTIVE_RENEWAL = "INTERACTIVE_RENEWAL";
|
|
127
|
+
}
|
|
128
|
+
exports.NotificationType = NotificationType;
|
|
129
|
+
class NotificationBody {
|
|
130
|
+
unified_receipt = null;
|
|
131
|
+
environment = "Sandbox";
|
|
132
|
+
auto_renew_status = "false";
|
|
133
|
+
auto_renew_status_change_date = "2021-03-11 03:03:14 Etc/GMT";
|
|
134
|
+
bvrs = "1";
|
|
135
|
+
bid = "com.eryi.eyreader";
|
|
136
|
+
password = "5203c7781e254aac8942290a0a2467ac";
|
|
137
|
+
auto_renew_product_id = "com.eryi.eyreader.week";
|
|
138
|
+
notification_type = NotificationType.DID_RECOVER;
|
|
139
|
+
}
|
|
140
|
+
exports.NotificationBody = NotificationBody;
|
|
141
|
+
class RequestBody {
|
|
142
|
+
"receipt-data" = "";
|
|
143
|
+
password = "5203c7781e254aac8942290a0a2467ac";
|
|
144
|
+
"exclude-old-transactions" = true;
|
|
145
|
+
}
|
|
146
|
+
exports.GAppleTool = null;
|
|
147
|
+
class AppleTool {
|
|
148
|
+
_verifyUrl = "https://buy.itunes.apple.com/verifyReceipt";
|
|
149
|
+
_sandboxVerifyUrl = "https://sandbox.itunes.apple.com/verifyReceipt";
|
|
150
|
+
async onNotify(nb) {
|
|
151
|
+
let ris = nb.unified_receipt?.latest_receipt_info;
|
|
152
|
+
var latest_one = (ris?.length > 0 ? ris[0] : null);
|
|
153
|
+
let msg = {
|
|
154
|
+
"notification_type": nb.notification_type,
|
|
155
|
+
"status": nb.unified_receipt.status,
|
|
156
|
+
"environment": nb.environment,
|
|
157
|
+
"auto_renew_status": nb.auto_renew_status,
|
|
158
|
+
"orginal_transaction_id": latest_one?.original_transaction_id,
|
|
159
|
+
"transaction_id": latest_one?.transaction_id,
|
|
160
|
+
"expire_date": latest_one?.expires_date,
|
|
161
|
+
"receipt_expire_date": nb.unified_receipt?.receipt?.expiration_date
|
|
162
|
+
};
|
|
163
|
+
Log_1.GLog.info(msg);
|
|
164
|
+
Log_1.GLog.info(nb);
|
|
165
|
+
}
|
|
166
|
+
async onVerify(receipt, environment) {
|
|
167
|
+
Log_1.GLog.info("begin onVerify============================" + environment);
|
|
168
|
+
let url = this._verifyUrl;
|
|
169
|
+
// if(environment.toLowerCase()=="sandbox")
|
|
170
|
+
// {
|
|
171
|
+
// url=this._sandboxVerifyUrl
|
|
172
|
+
// }
|
|
173
|
+
Log_1.GLog.info("url============================" + url);
|
|
174
|
+
let reqb = new RequestBody();
|
|
175
|
+
reqb['receipt-data'] = receipt;
|
|
176
|
+
//先验证生产环境
|
|
177
|
+
var resb = (await HttpTool_1.GHttpTool.post({ url, form: JSON.stringify(reqb) })).body;
|
|
178
|
+
Log_1.GLog.info("production end onVerify_Res============================status=" + (resb ? resb.status : "null"));
|
|
179
|
+
//状态21007表示是沙盒环境
|
|
180
|
+
if (resb && resb.status == 21007) {
|
|
181
|
+
url = this._sandboxVerifyUrl;
|
|
182
|
+
resb = (await HttpTool_1.GHttpTool.post({ url, form: JSON.stringify(reqb) })).body;
|
|
183
|
+
Log_1.GLog.info("sandbox end onVerify_Res============================status=" + (resb ? resb.status : "null"));
|
|
184
|
+
}
|
|
185
|
+
Log_1.GLog.info(resb);
|
|
186
|
+
return resb;
|
|
187
|
+
}
|
|
188
|
+
signature(nickname, create_time, appBundleID, productIdentifier, offerIdentifier) {
|
|
189
|
+
let keyIdentifier = "";
|
|
190
|
+
for (var k in IServerConfig_1.GServerCfg.third_cfg.apple.keyIds) {
|
|
191
|
+
keyIdentifier = k;
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
var nonce = (0, uuid_1.v4)();
|
|
195
|
+
var payload = appBundleID + '\u2063' +
|
|
196
|
+
keyIdentifier + '\u2063' +
|
|
197
|
+
productIdentifier + '\u2063' +
|
|
198
|
+
offerIdentifier + '\u2063' +
|
|
199
|
+
nickname + '\u2063' +
|
|
200
|
+
nonce.toLowerCase() + '\u2063' +
|
|
201
|
+
create_time;
|
|
202
|
+
// Get the PEM-formatted private key string associated with the Key ID.
|
|
203
|
+
const path = IServerConfig_1.GServerCfg.third_cfg.apple.keyIds[keyIdentifier];
|
|
204
|
+
const keyString = fs.readFileSync(path).toString();
|
|
205
|
+
// Create an Elliptic Curve Digital Signature Algorithm (ECDSA) object using the private key.
|
|
206
|
+
const key = new ec_key_1.default(keyString, 'pem');
|
|
207
|
+
// Set up the cryptographic format used to sign the key with the SHA-256 hashing algorithm.
|
|
208
|
+
const cryptoSign = key.createSign('SHA256');
|
|
209
|
+
// Add the payload string to sign.
|
|
210
|
+
cryptoSign.update(payload);
|
|
211
|
+
/*
|
|
212
|
+
The Node.js crypto library creates a DER-formatted binary value signature,
|
|
213
|
+
and then base-64 encodes it to create the string that you will use in StoreKit.
|
|
214
|
+
*/
|
|
215
|
+
const signature = cryptoSign.sign('base64');
|
|
216
|
+
/*
|
|
217
|
+
Check that the signature passes verification by using the ec-key library.
|
|
218
|
+
The verification process is similar to creating the signature, except it uses 'createVerify'
|
|
219
|
+
instead of 'createSign', and after updating it with the payload, it uses `verify` to pass in
|
|
220
|
+
the signature and encoding, instead of `sign` to get the signature.
|
|
221
|
+
|
|
222
|
+
This step is not required, but it's useful to check when implementing your signature code.
|
|
223
|
+
This helps debug issues with signing before sending transactions to Apple.
|
|
224
|
+
If verification succeeds, the next recommended testing step is attempting a purchase
|
|
225
|
+
in the Sandbox environment.
|
|
226
|
+
*/
|
|
227
|
+
const verificationResult = key.createVerify('SHA256').update(payload).verify(signature, 'base64');
|
|
228
|
+
if (verificationResult) {
|
|
229
|
+
return { 'keyIdentifier': keyIdentifier, 'nonce': nonce, 'timestamp': create_time, 'signature': signature };
|
|
230
|
+
}
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
exports.GAppleTool = new AppleTool();
|