cgserver 7.10.2113 → 7.11.2113
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/package.json +1 -1
- package/src/Framework/AI/AiObject.ts +0 -12
- package/src/Framework/AI/Astar.ts +0 -157
- package/src/Framework/AI/BehaviorAI.ts +0 -382
- package/src/Framework/AI/Entity.ts +0 -37
- package/src/Framework/AI/Point.ts +0 -84
- package/src/Framework/AI/TriggerMgr.ts +0 -280
- package/src/Framework/Config/Config.ts +0 -61
- package/src/Framework/Config/FrameworkConfig.ts +0 -286
- package/src/Framework/Config/IServerConfig.ts +0 -28
- package/src/Framework/Config/_error_.ts +0 -32
- package/src/Framework/Core/Core.ts +0 -810
- package/src/Framework/Core/Timer.ts +0 -147
- package/src/Framework/Database/Decorator/AutoIncrement.ts +0 -9
- package/src/Framework/Database/Decorator/DBCache.ts +0 -74
- package/src/Framework/Database/Decorator/NotNull.ts +0 -9
- package/src/Framework/Database/Decorator/PrimaryKey.ts +0 -9
- package/src/Framework/Database/Decorator/Property.ts +0 -64
- package/src/Framework/Database/Decorator/Table.ts +0 -13
- package/src/Framework/Database/Decorator/Type.ts +0 -21
- package/src/Framework/Database/MSSqlManager.ts +0 -52
- package/src/Framework/Database/MongoBaseService.ts +0 -136
- package/src/Framework/Database/MongoManager.ts +0 -501
- package/src/Framework/Database/MysqlBaseService.ts +0 -345
- package/src/Framework/Database/MysqlManager.ts +0 -212
- package/src/Framework/Database/RedisManager.ts +0 -544
- package/src/Framework/Logic/CacheTool.ts +0 -85
- package/src/Framework/Logic/EventTool.ts +0 -31
- package/src/Framework/Logic/HttpTool.ts +0 -82
- package/src/Framework/Logic/Log.ts +0 -171
- package/src/Framework/Logic/SyncQueueTool.ts +0 -51
- package/src/Framework/Service/AccountService.ts +0 -508
- package/src/Framework/Service/MongoAccountService.ts +0 -456
- package/src/Framework/Service/MongoCacheService.ts +0 -48
- package/src/Framework/Service/MongoUserService.ts +0 -103
- package/src/Framework/Service/UserService.ts +0 -168
- package/src/Framework/Service/ini.ts +0 -33
- package/src/Framework/SocketServer/IClientWebSocket.ts +0 -50
- package/src/Framework/SocketServer/IRpc.ts +0 -12
- package/src/Framework/SocketServer/IRpcClientWebSocket.ts +0 -75
- package/src/Framework/SocketServer/IRpcServerWebSocket.ts +0 -76
- package/src/Framework/SocketServer/IServerWebSocket.ts +0 -88
- package/src/Framework/SocketServer/ISocketServer.ts +0 -243
- package/src/Framework/SocketServer/IWebSocket.ts +0 -243
- package/src/Framework/SocketServer/ProtoFilter/GoogleProtoFilter.ts +0 -68
- package/src/Framework/SocketServer/ProtoFilter/IProtoFilter.ts +0 -11
- package/src/Framework/SocketServer/ProtoFilter/JsonProtoFilter.ts +0 -34
- package/src/Framework/SocketServer/ProtoFilter/ProtoFactory.ts +0 -34
- package/src/Framework/ThirdParty/AlipayTool.ts +0 -224
- package/src/Framework/ThirdParty/Alisms.ts +0 -53
- package/src/Framework/ThirdParty/AppleTool.ts +0 -252
- package/src/Framework/ThirdParty/CgMq.ts +0 -153
- package/src/Framework/ThirdParty/EmailTool.ts +0 -37
- package/src/Framework/ThirdParty/OpenSocial.ts +0 -36
- package/src/Framework/ThirdParty/QQTool.ts +0 -124
- package/src/Framework/ThirdParty/QiniuTool.ts +0 -23
- package/src/Framework/ThirdParty/Rpc.ts +0 -75
- package/src/Framework/ThirdParty/WechatOATool.ts +0 -61
- package/src/Framework/ThirdParty/WechatTool.ts +0 -80
- package/src/Framework/WebServer/Controller/BaseController.ts +0 -140
- package/src/Framework/WebServer/Controller/BaseUserController.ts +0 -209
- package/src/Framework/WebServer/Controller/MongoBaseUserController.ts +0 -209
- package/src/Framework/WebServer/Decorator/AdminValidate.ts +0 -19
- package/src/Framework/WebServer/Decorator/AuthorityValidate.ts +0 -25
- package/src/Framework/WebServer/Decorator/CreatorValidate.ts +0 -19
- package/src/Framework/WebServer/Decorator/JsonAdminValidate.ts +0 -16
- package/src/Framework/WebServer/Decorator/JsonAuthorityValidate.d.ts +0 -2
- package/src/Framework/WebServer/Decorator/JsonAuthorityValidate.ts +0 -23
- package/src/Framework/WebServer/Decorator/JsonCreatorValidate.ts +0 -19
- package/src/Framework/WebServer/Decorator/SyncCall.ts +0 -20
- package/src/Framework/WebServer/Decorator/SyncCallServer.ts +0 -45
- package/src/Framework/WebServer/Engine/ControllerManager.ts +0 -134
- package/src/Framework/WebServer/Engine/Engine.ts +0 -186
- package/src/Framework/WebServer/Engine/RazorJs.ts +0 -720
- package/src/Framework/WebServer/Engine/Request.ts +0 -267
- package/src/Framework/WebServer/Engine/Response.ts +0 -123
- package/src/Framework/WebServer/IWebServer.ts +0 -61
- package/src/Framework/cgserver.ts +0 -112
- package/src/Framework/index.ts +0 -92
- package/src/test/test.ts +0 -12
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
import AlipaySdk from 'alipay-sdk';
|
|
2
|
-
import * as aliUtil from 'alipay-sdk/lib/util';
|
|
3
|
-
|
|
4
|
-
import { AliPayUtil, RsaSignParam } from "alipay_sdk2/AliPayUtil";
|
|
5
|
-
import * as fs from "fs";
|
|
6
|
-
import AlipayFormData from 'alipay-sdk/lib/form';
|
|
7
|
-
import { GLog } from '../Logic/Log';
|
|
8
|
-
import { GServerCfg } from '../Config/IServerConfig';
|
|
9
|
-
|
|
10
|
-
export class AlipayResult
|
|
11
|
-
{
|
|
12
|
-
alipay_trade_app_pay_response={
|
|
13
|
-
code:"10000",
|
|
14
|
-
msg:"Success",
|
|
15
|
-
app_id:"2021003143637369",
|
|
16
|
-
auth_app_id:"2021003143637369",
|
|
17
|
-
charset:"utf-8",
|
|
18
|
-
timestamp:"2022-08-10 16:38:04",
|
|
19
|
-
out_trade_no:"62f36e657a355ecc1cb8eec2",
|
|
20
|
-
total_amount:"0.05",
|
|
21
|
-
trade_no:"2022081022001489431433911625",
|
|
22
|
-
seller_id:"2088441785429273"
|
|
23
|
-
}
|
|
24
|
-
sign="d/Guf6QYnuk9fFlRS1EUFTY+n3/jQKp7IwQENG4WXO+qxMGglPXa3RhUHaJELTMwC4tcKhz8Z8GCiiI1Y7G84kAql1jyoekaOMWvdPRDOjkAqouP3oh5v9r23BziJUxgv/kanBRfOoTKvIT7R0L5DyfxMpEoHdssPHAtENMiniCVZlRUkAhHxjmgMrP0rzMtBvqctC5Me6UiV1yBdGWecLk9RNwMTZF8QSXKVpWXmhmimdjjFjGMcE6r7LoV9YW1Bsvjoq2kdRMX7CJZufGk1Y5Qz8Cv+E9QxTnDJMtA0XyYzte53/dSw0W3Z4Gbosn/kV4QDBRzN39NwwuoFwGuVg=="
|
|
25
|
-
sign_type="RSA2"
|
|
26
|
-
}
|
|
27
|
-
export class AlipayCallBack
|
|
28
|
-
{
|
|
29
|
-
gmt_create="2022-08-10 16=38=03"
|
|
30
|
-
charset="utf-8"
|
|
31
|
-
seller_email="zdpuke@163.com"
|
|
32
|
-
subject="一把砖石"
|
|
33
|
-
sign="gytkeBGeea9V05lI6Qvvut8CZnXtXJmbb0dMDd76a6fgN2k2IO0HH4wkJylMQG3EXYJQctysURDtIB0dhqaZbDVtePsM3iQVeI2jwT3YS3XGS4xi13k8foag9vCcSgojKjxJS3ihfzuyK/Pc+KDTOQftoWP2s1dPUpJNGLcZp4sUFysl0Iyzf+2vXh4OJUPQ3DvCqePnDUawq1+AUUj63WHWvdsGCP70+eTsbKxJxWBhHfMVrwkOmUI0zivcHpHLVHbfTFvaM5LAa/ivSU8jiDHqgHYFZqqzTyZ1DLxEy0Ypo3sKBs5eK/UhdsNf5tjse7PxYJwMU2ziIo9gnqv6fQ=="
|
|
34
|
-
buyer_id=2088202482689432
|
|
35
|
-
invoice_amount="0.05"
|
|
36
|
-
notify_id=2.022081000222164e+33
|
|
37
|
-
fund_bill_list=[{amount:"0.05",fundChannel:"PCREDIT"}]
|
|
38
|
-
notify_type="trade_status_sync"
|
|
39
|
-
trade_status="TRADE_SUCCESS"
|
|
40
|
-
receipt_amount="0.05"
|
|
41
|
-
app_id=2021003143637369
|
|
42
|
-
buyer_pay_amount="0.05"
|
|
43
|
-
sign_type="RSA2"
|
|
44
|
-
seller_id=2088441785429273
|
|
45
|
-
gmt_payment="2022-08-10 16:38:03"
|
|
46
|
-
notify_time="2022-08-10 16:38:04"
|
|
47
|
-
version=1
|
|
48
|
-
out_trade_no="62f36e657a355ecc1cb8eec2"
|
|
49
|
-
total_amount="0.05"
|
|
50
|
-
trade_no=2.0220810220014894e+27
|
|
51
|
-
auth_app_id=2021003143637369
|
|
52
|
-
buyer_logon_id="138****3531"
|
|
53
|
-
point_amount=0
|
|
54
|
-
}
|
|
55
|
-
export let GAlipayTool:AlipayTool=null
|
|
56
|
-
class AlipayTool
|
|
57
|
-
{
|
|
58
|
-
protected _alipaySdk:AlipaySdk=null
|
|
59
|
-
protected _aliPay:AliPayUtil=null
|
|
60
|
-
|
|
61
|
-
protected _cfg={
|
|
62
|
-
app_id: "",
|
|
63
|
-
app_key:"",
|
|
64
|
-
gateway:"",
|
|
65
|
-
//RSA1 RSA2
|
|
66
|
-
signType: <'RSA2'|'RSA'>'RSA2',
|
|
67
|
-
/** 指定private key类型, 默认: PKCS1, PKCS8: PRIVATE KEY, PKCS1: RSA PRIVATE KEY */
|
|
68
|
-
keyType: <'PKCS1'|'PKCS8'>'PKCS1',
|
|
69
|
-
alipay_root_cert_sn:"",
|
|
70
|
-
alipay_cert_sn:"",
|
|
71
|
-
app_cert_sn:"",
|
|
72
|
-
notify_url:""
|
|
73
|
-
}
|
|
74
|
-
init()
|
|
75
|
-
{
|
|
76
|
-
if(!GServerCfg.third_cfg.alipay
|
|
77
|
-
||!GServerCfg.third_cfg.alipay.open)
|
|
78
|
-
{
|
|
79
|
-
return false
|
|
80
|
-
}
|
|
81
|
-
let suffix=""
|
|
82
|
-
if(GServerCfg.third_cfg.alipay.dev)
|
|
83
|
-
{
|
|
84
|
-
suffix="_dev"
|
|
85
|
-
}
|
|
86
|
-
this._cfg={
|
|
87
|
-
app_id: GServerCfg.third_cfg.alipay["app_id"+suffix],
|
|
88
|
-
app_key: GServerCfg.third_cfg.alipay["app_key"+suffix],
|
|
89
|
-
gateway: GServerCfg.third_cfg.alipay["gateway"+suffix],
|
|
90
|
-
//RSA1 RSA2
|
|
91
|
-
signType: GServerCfg.third_cfg.alipay["signType"+suffix],
|
|
92
|
-
/** 指定private key类型, 默认: PKCS1, PKCS8: PRIVATE KEY, PKCS1: RSA PRIVATE KEY */
|
|
93
|
-
keyType: GServerCfg.third_cfg.alipay["signType"+suffix],
|
|
94
|
-
alipay_root_cert_sn: GServerCfg.third_cfg.alipay["alipay_root_cert_sn"+suffix],
|
|
95
|
-
alipay_cert_sn: GServerCfg.third_cfg.alipay["alipay_cert_sn"+suffix],
|
|
96
|
-
app_cert_sn: GServerCfg.third_cfg.alipay["app_cert_sn"+suffix],
|
|
97
|
-
notify_url: GServerCfg.third_cfg.alipay["notify_url"+suffix]
|
|
98
|
-
}
|
|
99
|
-
if(this._cfg.alipay_cert_sn)
|
|
100
|
-
{
|
|
101
|
-
this._aliPay = new AliPayUtil( this._cfg.alipay_cert_sn, this._cfg.app_key )
|
|
102
|
-
}
|
|
103
|
-
else
|
|
104
|
-
{
|
|
105
|
-
let app_key=""
|
|
106
|
-
if(this._cfg.app_key.indexOf(".pem")>0)
|
|
107
|
-
{
|
|
108
|
-
app_key=fs.readFileSync(this._cfg.app_key, 'ascii')
|
|
109
|
-
}
|
|
110
|
-
else
|
|
111
|
-
{
|
|
112
|
-
app_key=this._cfg.app_key
|
|
113
|
-
}
|
|
114
|
-
this._alipaySdk = new AlipaySdk({
|
|
115
|
-
appId: this._cfg.app_id,
|
|
116
|
-
privateKey: app_key,
|
|
117
|
-
gateway:this._cfg.gateway,
|
|
118
|
-
signType:this._cfg.signType,
|
|
119
|
-
keyType:this._cfg.keyType
|
|
120
|
-
})
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* charset:"utf-8",method:"alipay.trade.app.pay",sign_type:"RSA2,version:"1.0"
|
|
125
|
-
* @param out_trade_no
|
|
126
|
-
* @param total_amount
|
|
127
|
-
* @param subject
|
|
128
|
-
* @param body
|
|
129
|
-
* @param timeout_express
|
|
130
|
-
* @param product_code
|
|
131
|
-
* @returns
|
|
132
|
-
*/
|
|
133
|
-
protected _buildOrderParams(out_trade_no:string,total_amount:number,subject="1",body="我是测试数据",timeout_express="30m",product_code="QUICK_MSECURITY_PAY")
|
|
134
|
-
{
|
|
135
|
-
let order_params = {
|
|
136
|
-
notifyUrl:this._cfg.notify_url,
|
|
137
|
-
bizContent:{
|
|
138
|
-
timeout_express:timeout_express,
|
|
139
|
-
product_code:product_code,
|
|
140
|
-
total_amount:total_amount,
|
|
141
|
-
subject:encodeURIComponent(subject),
|
|
142
|
-
body:encodeURIComponent(body),
|
|
143
|
-
out_trade_no:out_trade_no
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
return order_params
|
|
147
|
-
}
|
|
148
|
-
protected _sign(order_params:any)
|
|
149
|
-
{
|
|
150
|
-
let sign=aliUtil.sign("alipay.trade.app.pay",order_params,this._alipaySdk.config)
|
|
151
|
-
return sign
|
|
152
|
-
}
|
|
153
|
-
getOrderInfo(out_trade_no:string,total_amount:number,subject="1",body="我是测试数据")
|
|
154
|
-
{
|
|
155
|
-
let order_params = this._buildOrderParams(out_trade_no,total_amount,subject,body)
|
|
156
|
-
let sign = this._sign(order_params)
|
|
157
|
-
let {url,execParams}=this._alipaySdk["formatUrl"]("",sign)
|
|
158
|
-
const order_info = (url + '&biz_content=' + encodeURIComponent(execParams.biz_content)).substring(1)
|
|
159
|
-
return order_info
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
*
|
|
163
|
-
* @param title
|
|
164
|
-
* @param order_id
|
|
165
|
-
* @param money
|
|
166
|
-
*/
|
|
167
|
-
doPay(title:string, order_id:string, money:number)
|
|
168
|
-
{
|
|
169
|
-
const param:RsaSignParam = {
|
|
170
|
-
app_id:this._cfg.app_id,
|
|
171
|
-
notify_url:this._cfg.notify_url,
|
|
172
|
-
app_cert_sn:this._cfg.app_cert_sn,
|
|
173
|
-
alipay_root_cert_sn:this._cfg.alipay_root_cert_sn,
|
|
174
|
-
subject:title,
|
|
175
|
-
trade_no: order_id,
|
|
176
|
-
total_amount: money,
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
var str=this._aliPay.getPayCode( param )
|
|
180
|
-
return str
|
|
181
|
-
}
|
|
182
|
-
rsaCheck(payInfo:any)
|
|
183
|
-
{
|
|
184
|
-
return this._aliPay.rsaCheck(payInfo)
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
*
|
|
188
|
-
* @param method get|post
|
|
189
|
-
* @param notifyUrl 通知回调
|
|
190
|
-
* @param returnUrl
|
|
191
|
-
* @param outTradeNo
|
|
192
|
-
* @param money 价格
|
|
193
|
-
* @param subject 标题
|
|
194
|
-
* @param body 内容介绍
|
|
195
|
-
*/
|
|
196
|
-
async getAlipayPage(method:"get" | "post",notifyUrl:string,returnUrl:string,outTradeNo:string,money:number,subject:string,body:string)
|
|
197
|
-
{
|
|
198
|
-
if(!this._alipaySdk)
|
|
199
|
-
{
|
|
200
|
-
GLog.error("并未配置alipay或者初始化失败")
|
|
201
|
-
return
|
|
202
|
-
}
|
|
203
|
-
const formData = new AlipayFormData();
|
|
204
|
-
// 调用 setMethod 并传入 get,会返回可以跳转到支付页面的 url
|
|
205
|
-
formData.setMethod(method)
|
|
206
|
-
formData.addField("return_url",returnUrl)
|
|
207
|
-
formData.addField('notifyUrl', notifyUrl)
|
|
208
|
-
formData.addField('bizContent', {
|
|
209
|
-
outTradeNo: outTradeNo,
|
|
210
|
-
productCode: "FAST_INSTANT_TRADE_PAY",
|
|
211
|
-
totalAmount: money,
|
|
212
|
-
subject: subject,
|
|
213
|
-
body: body,
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
let url_or_html = await this._alipaySdk.exec(
|
|
217
|
-
'alipay.trade.page.pay',
|
|
218
|
-
{},
|
|
219
|
-
{ formData: formData }
|
|
220
|
-
)
|
|
221
|
-
return url_or_html
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
GAlipayTool=new AlipayTool()
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { GServerCfg } from '../Config/IServerConfig';
|
|
2
|
-
import { GLog } from './../Logic/Log';
|
|
3
|
-
let SMSClient =require("@alicloud/sms-sdk")
|
|
4
|
-
|
|
5
|
-
export let GSmsTool:SMSTool=null
|
|
6
|
-
class SMSTool
|
|
7
|
-
{
|
|
8
|
-
protected _is_init=false
|
|
9
|
-
protected _sms_client=null
|
|
10
|
-
init()
|
|
11
|
-
{
|
|
12
|
-
if(this._is_init)
|
|
13
|
-
{
|
|
14
|
-
return true
|
|
15
|
-
}
|
|
16
|
-
this._is_init = true
|
|
17
|
-
this._sms_client = new SMSClient({accessKeyId:GServerCfg.third_cfg.aliSms.accessKeyId,secretAccessKey:GServerCfg.third_cfg.aliSms.secretAccessKey})
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* 发送短信验证码
|
|
21
|
-
* @param code 验证码
|
|
22
|
-
* @param phone 手机号
|
|
23
|
-
* @param callback 回调
|
|
24
|
-
*/
|
|
25
|
-
sendSMS(code:number,phone:string):Promise<String>
|
|
26
|
-
{
|
|
27
|
-
return new Promise((resolve,reject)=>
|
|
28
|
-
{
|
|
29
|
-
this._sms_client.sendSMS({
|
|
30
|
-
PhoneNumbers:phone,
|
|
31
|
-
SignName:GServerCfg.third_cfg.aliSms.signName,
|
|
32
|
-
TemplateCode:GServerCfg.third_cfg.aliSms.templateCode,
|
|
33
|
-
TemplateParam:JSON.stringify({code:code})
|
|
34
|
-
}).then((res)=>
|
|
35
|
-
{
|
|
36
|
-
if(res.Code=="OK")
|
|
37
|
-
{
|
|
38
|
-
resolve(null)
|
|
39
|
-
}
|
|
40
|
-
else
|
|
41
|
-
{
|
|
42
|
-
GLog.error("phone:"+phone+" code:"+res.Code)
|
|
43
|
-
resolve(res.Code)
|
|
44
|
-
}
|
|
45
|
-
},(err)=>
|
|
46
|
-
{
|
|
47
|
-
GLog.error(err)
|
|
48
|
-
resolve(err)
|
|
49
|
-
})
|
|
50
|
-
})
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
GSmsTool=new SMSTool()
|
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import { GLog } from '../Logic/Log';
|
|
2
|
-
import { GHttpTool } from './../Logic/HttpTool';
|
|
3
|
-
import ECKey from "ec-key";
|
|
4
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
5
|
-
|
|
6
|
-
import * as fs from "fs";
|
|
7
|
-
import { GServerCfg } from '../Config/IServerConfig';
|
|
8
|
-
//developer.apple.com/documentation/appstorereceipts/responsebody
|
|
9
|
-
class ReceiptInfo
|
|
10
|
-
{
|
|
11
|
-
cancellation_date=""
|
|
12
|
-
cancellation_date_ms=""
|
|
13
|
-
cancellation_date_pst=""
|
|
14
|
-
cancellation_date_reason=""
|
|
15
|
-
expires_date= "2021-03-10 14:25:54 Etc/GMT"
|
|
16
|
-
expires_date_ms= "1615386354000"
|
|
17
|
-
expires_date_pst= "2021-03-10 06:25:54 America/Los_Angeles"
|
|
18
|
-
in_app_ownership_type:"FAMILY_SHARED"|"PURCHASED"
|
|
19
|
-
is_in_intro_offer_period= false
|
|
20
|
-
is_trial_period= false
|
|
21
|
-
is_upgraded=false
|
|
22
|
-
offer_code_ref_name=""
|
|
23
|
-
original_purchase_date= "2021-03-10 08:22:26 Etc/GMT"
|
|
24
|
-
original_purchase_date_ms= "1615364546000"
|
|
25
|
-
original_purchase_date_pst= "2021-03-10 00:22:26 America/Los_Angeles"
|
|
26
|
-
original_transaction_id= "1000000786747716"
|
|
27
|
-
purchase_date= "2021-03-10 14:22:54 Etc/GMT"
|
|
28
|
-
purchase_date_ms= "1615386174000"
|
|
29
|
-
purchase_date_pst= "2021-03-10 06:22:54 America/Los_Angeles"
|
|
30
|
-
quantity= 1
|
|
31
|
-
subscription_group_identifier= "20745320"
|
|
32
|
-
web_order_line_item_id= "1000000060695307"
|
|
33
|
-
transaction_id= "1000000786974540"
|
|
34
|
-
product_id= "com.eryi.eyreader.week"
|
|
35
|
-
}
|
|
36
|
-
class PendingRenewalInfo
|
|
37
|
-
{
|
|
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
|
-
{
|
|
53
|
-
cancellation_date=""
|
|
54
|
-
cancellation_date_ms=""
|
|
55
|
-
cancellation_date_pst=""
|
|
56
|
-
cancellation_reason=""
|
|
57
|
-
expires_date= "2021-03-10 14:25:54 Etc/GMT"
|
|
58
|
-
expires_date_ms= "1615386354000"
|
|
59
|
-
expires_date_pst= "2021-03-10 06:25:54 America/Los_Angeles"
|
|
60
|
-
is_in_intro_offer_period= false
|
|
61
|
-
is_trial_period= false
|
|
62
|
-
original_purchase_date= "2021-03-10 08:22:26 Etc/GMT"
|
|
63
|
-
original_purchase_date_ms= "1615364546000"
|
|
64
|
-
original_purchase_date_pst= "2021-03-10 00:22:26 America/Los_Angeles"
|
|
65
|
-
original_transaction_id= "1000000786747716"
|
|
66
|
-
product_id= "com.eryi.eyreader.week"
|
|
67
|
-
promotional_offer_id=""
|
|
68
|
-
purchase_date= "2021-03-10 14:22:54 Etc/GMT"
|
|
69
|
-
purchase_date_ms= "1615386174000"
|
|
70
|
-
purchase_date_pst= "2021-03-10 06:22:54 America/Los_Angeles"
|
|
71
|
-
quantity= 1
|
|
72
|
-
transaction_id= "1000000786974540"
|
|
73
|
-
web_order_line_item_id= "1000000060695307"
|
|
74
|
-
}
|
|
75
|
-
class Receipt
|
|
76
|
-
{
|
|
77
|
-
adam_id=-1
|
|
78
|
-
app_item_id=-1
|
|
79
|
-
application_version=""
|
|
80
|
-
bundle_id=""
|
|
81
|
-
download_id=-1
|
|
82
|
-
expiration_date=""
|
|
83
|
-
expiration_date_ms=""
|
|
84
|
-
expiration_date_pst=""
|
|
85
|
-
in_app:InApp=null
|
|
86
|
-
original_application_version=""
|
|
87
|
-
original_purchase_date=""
|
|
88
|
-
original_purchase_date_ms=""
|
|
89
|
-
original_purchase_date_pst=""
|
|
90
|
-
preorder_date=""
|
|
91
|
-
preorder_date_ms=""
|
|
92
|
-
preorder_date_pst=""
|
|
93
|
-
receipt_creation_date=""
|
|
94
|
-
receipt_creation_date_ms=""
|
|
95
|
-
receipt_creation_date_pst=""
|
|
96
|
-
receipt_type=""
|
|
97
|
-
request_date=""
|
|
98
|
-
request_date_ms=""
|
|
99
|
-
request_date_pst=""
|
|
100
|
-
version_external_identifier=-1
|
|
101
|
-
}
|
|
102
|
-
export class ResponseBody
|
|
103
|
-
{
|
|
104
|
-
environment:"Sandbox"|"Production"="Sandbox"
|
|
105
|
-
is_retryable=false//出错之后的重试
|
|
106
|
-
latest_receipt="0OkG/Sw=="
|
|
107
|
-
latest_receipt_info: Array<ReceiptInfo>=null
|
|
108
|
-
pending_renewal_info: Array<PendingRenewalInfo>=null
|
|
109
|
-
receipt:Receipt=null
|
|
110
|
-
status=0
|
|
111
|
-
}
|
|
112
|
-
export class NotificationType
|
|
113
|
-
{
|
|
114
|
-
//退款
|
|
115
|
-
static CANCEL="CANCEL"
|
|
116
|
-
//变更续订方式,下次续订的时候生效,当前不变
|
|
117
|
-
static DID_CHANGE_RENEWAL_PREF="DID_CHANGE_RENEWAL_PREF"
|
|
118
|
-
/*
|
|
119
|
-
续订状态发生变化的时候通知
|
|
120
|
-
检查auto_renew_status_change_date_ms获取最新的状态更新时间.
|
|
121
|
-
通过auto_renew_status了解当前续订状态.
|
|
122
|
-
*/
|
|
123
|
-
static DID_CHANGE_RENEWAL_STATUS="DID_CHANGE_RENEWAL_STATUS"
|
|
124
|
-
//自动续订了一个之前续订失败了的续订
|
|
125
|
-
static DID_RECOVER="DID_RECOVER"
|
|
126
|
-
//自动续订成功
|
|
127
|
-
static DID_RENEW="DID_RENEW"
|
|
128
|
-
//客户交互更新订阅,订阅可以立刻生效
|
|
129
|
-
static INTERACTIVE_RENEWAL="INTERACTIVE_RENEWAL"
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
export class NotificationBody
|
|
133
|
-
{
|
|
134
|
-
unified_receipt: ResponseBody=null
|
|
135
|
-
environment="Sandbox"
|
|
136
|
-
auto_renew_status="false"
|
|
137
|
-
auto_renew_status_change_date="2021-03-11 03:03:14 Etc/GMT"
|
|
138
|
-
bvrs="1"
|
|
139
|
-
bid="com.eryi.eyreader"
|
|
140
|
-
password="5203c7781e254aac8942290a0a2467ac"
|
|
141
|
-
auto_renew_product_id="com.eryi.eyreader.week"
|
|
142
|
-
notification_type=NotificationType.DID_RECOVER
|
|
143
|
-
}
|
|
144
|
-
class RequestBody
|
|
145
|
-
{
|
|
146
|
-
"receipt-data"=""
|
|
147
|
-
password="5203c7781e254aac8942290a0a2467ac"
|
|
148
|
-
"exclude-old-transactions"=true
|
|
149
|
-
}
|
|
150
|
-
export let GAppleTool:AppleTool=null
|
|
151
|
-
class AppleTool
|
|
152
|
-
{
|
|
153
|
-
protected _verifyUrl="https://buy.itunes.apple.com/verifyReceipt"
|
|
154
|
-
protected _sandboxVerifyUrl="https://sandbox.itunes.apple.com/verifyReceipt"
|
|
155
|
-
async onNotify(nb:NotificationBody)
|
|
156
|
-
{
|
|
157
|
-
let ris=nb.unified_receipt?.latest_receipt_info
|
|
158
|
-
var latest_one:ReceiptInfo=(ris?.length>0?ris[0]:null)
|
|
159
|
-
let msg=
|
|
160
|
-
{
|
|
161
|
-
"notification_type":nb.notification_type,
|
|
162
|
-
"status":nb.unified_receipt.status,
|
|
163
|
-
"environment":nb.environment,
|
|
164
|
-
"auto_renew_status":nb.auto_renew_status,
|
|
165
|
-
"orginal_transaction_id":latest_one?.original_transaction_id,
|
|
166
|
-
"transaction_id":latest_one?.transaction_id,
|
|
167
|
-
"expire_date":latest_one?.expires_date,
|
|
168
|
-
"receipt_expire_date":nb.unified_receipt?.receipt?.expiration_date
|
|
169
|
-
}
|
|
170
|
-
GLog.info(msg)
|
|
171
|
-
GLog.info(nb)
|
|
172
|
-
}
|
|
173
|
-
async onVerify(receipt:string,environment:string)
|
|
174
|
-
{
|
|
175
|
-
GLog.info("begin onVerify============================"+environment)
|
|
176
|
-
let url = this._verifyUrl
|
|
177
|
-
// if(environment.toLowerCase()=="sandbox")
|
|
178
|
-
// {
|
|
179
|
-
// url=this._sandboxVerifyUrl
|
|
180
|
-
// }
|
|
181
|
-
GLog.info("url============================"+url)
|
|
182
|
-
let reqb = new RequestBody()
|
|
183
|
-
reqb['receipt-data']=receipt
|
|
184
|
-
//先验证生产环境
|
|
185
|
-
var resb:ResponseBody = (await GHttpTool.post({url,form:JSON.stringify(reqb)})).body
|
|
186
|
-
GLog.info("production end onVerify_Res============================status="+(resb?resb.status:"null"))
|
|
187
|
-
//状态21007表示是沙盒环境
|
|
188
|
-
if(resb&&resb.status==21007)
|
|
189
|
-
{
|
|
190
|
-
url=this._sandboxVerifyUrl
|
|
191
|
-
resb = (await GHttpTool.post({url,form:JSON.stringify(reqb)})).body
|
|
192
|
-
GLog.info("sandbox end onVerify_Res============================status="+(resb?resb.status:"null"))
|
|
193
|
-
}
|
|
194
|
-
GLog.info(resb)
|
|
195
|
-
return resb
|
|
196
|
-
}
|
|
197
|
-
signature(nickname:string,create_time:number,appBundleID:string,productIdentifier:string,offerIdentifier:string)
|
|
198
|
-
{
|
|
199
|
-
let keyIdentifier="";
|
|
200
|
-
for(var k in GServerCfg.third_cfg.apple.keyIds)
|
|
201
|
-
{
|
|
202
|
-
keyIdentifier=k
|
|
203
|
-
break
|
|
204
|
-
}
|
|
205
|
-
var nonce = uuidv4()
|
|
206
|
-
var payload = appBundleID + '\u2063' +
|
|
207
|
-
keyIdentifier + '\u2063' +
|
|
208
|
-
productIdentifier + '\u2063' +
|
|
209
|
-
offerIdentifier + '\u2063' +
|
|
210
|
-
nickname + '\u2063'+
|
|
211
|
-
nonce.toLowerCase() + '\u2063' +
|
|
212
|
-
create_time;
|
|
213
|
-
|
|
214
|
-
// Get the PEM-formatted private key string associated with the Key ID.
|
|
215
|
-
const path = GServerCfg.third_cfg.apple.keyIds[keyIdentifier]
|
|
216
|
-
const keyString = fs.readFileSync(path).toString()
|
|
217
|
-
|
|
218
|
-
// Create an Elliptic Curve Digital Signature Algorithm (ECDSA) object using the private key.
|
|
219
|
-
const key = new ECKey(keyString, 'pem')
|
|
220
|
-
|
|
221
|
-
// Set up the cryptographic format used to sign the key with the SHA-256 hashing algorithm.
|
|
222
|
-
const cryptoSign = key.createSign('SHA256');
|
|
223
|
-
|
|
224
|
-
// Add the payload string to sign.
|
|
225
|
-
cryptoSign.update(payload);
|
|
226
|
-
|
|
227
|
-
/*
|
|
228
|
-
The Node.js crypto library creates a DER-formatted binary value signature,
|
|
229
|
-
and then base-64 encodes it to create the string that you will use in StoreKit.
|
|
230
|
-
*/
|
|
231
|
-
const signature = cryptoSign.sign('base64');
|
|
232
|
-
|
|
233
|
-
/*
|
|
234
|
-
Check that the signature passes verification by using the ec-key library.
|
|
235
|
-
The verification process is similar to creating the signature, except it uses 'createVerify'
|
|
236
|
-
instead of 'createSign', and after updating it with the payload, it uses `verify` to pass in
|
|
237
|
-
the signature and encoding, instead of `sign` to get the signature.
|
|
238
|
-
|
|
239
|
-
This step is not required, but it's useful to check when implementing your signature code.
|
|
240
|
-
This helps debug issues with signing before sending transactions to Apple.
|
|
241
|
-
If verification succeeds, the next recommended testing step is attempting a purchase
|
|
242
|
-
in the Sandbox environment.
|
|
243
|
-
*/
|
|
244
|
-
const verificationResult = key.createVerify('SHA256').update(payload).verify(signature, 'base64');
|
|
245
|
-
if(verificationResult)
|
|
246
|
-
{
|
|
247
|
-
return { 'keyIdentifier': keyIdentifier, 'nonce': nonce, 'timestamp': create_time, 'signature': signature }
|
|
248
|
-
}
|
|
249
|
-
return
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
GAppleTool=new AppleTool()
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { core } from "../Core/Core";
|
|
2
|
-
import { GLog } from "../Logic/Log";
|
|
3
|
-
import { IRpcServerWebSocket } from "../SocketServer/IRpcServerWebSocket";
|
|
4
|
-
import { BaseMsg } from "../SocketServer/IWebSocket";
|
|
5
|
-
import * as _ from "underscore";
|
|
6
|
-
import { StringDecoder } from "string_decoder";
|
|
7
|
-
import { RpcBaseMsg } from "../SocketServer/IRpc";
|
|
8
|
-
|
|
9
|
-
//接受到的消息无需basemsg部分
|
|
10
|
-
class CgMqMsg extends RpcBaseMsg
|
|
11
|
-
{
|
|
12
|
-
/**
|
|
13
|
-
* 必填,目的身份
|
|
14
|
-
*/
|
|
15
|
-
to_identity=""
|
|
16
|
-
/**
|
|
17
|
-
* 消息携带的数据
|
|
18
|
-
*/
|
|
19
|
-
data:any=null
|
|
20
|
-
}
|
|
21
|
-
export class CgMqRetMsg extends CgMqMsg
|
|
22
|
-
{
|
|
23
|
-
/**
|
|
24
|
-
* 发送者身份
|
|
25
|
-
*/
|
|
26
|
-
from_identity=""
|
|
27
|
-
/**
|
|
28
|
-
* audience 数量
|
|
29
|
-
*/
|
|
30
|
-
count=0
|
|
31
|
-
}
|
|
32
|
-
class CgMqServerWebsocket extends IRpcServerWebSocket
|
|
33
|
-
{
|
|
34
|
-
protected _cgmq:CgMq=null
|
|
35
|
-
/**
|
|
36
|
-
* 自己的身份
|
|
37
|
-
*/
|
|
38
|
-
protected _identity=""
|
|
39
|
-
constructor(cgmq:CgMq)
|
|
40
|
-
{
|
|
41
|
-
super()
|
|
42
|
-
this._cgmq=cgmq
|
|
43
|
-
this._identity=this._cgmq.cfg.identity
|
|
44
|
-
this._debug_msg=true
|
|
45
|
-
}
|
|
46
|
-
onOpen(e?: any): void {
|
|
47
|
-
this.init(this._cgmq.cfg.identity)
|
|
48
|
-
}
|
|
49
|
-
async init(identity:string)
|
|
50
|
-
{
|
|
51
|
-
let msg = this.getNewMsg("init")
|
|
52
|
-
msg.identity=identity
|
|
53
|
-
let jsonData = await this.callRemote(msg)
|
|
54
|
-
return jsonData
|
|
55
|
-
}
|
|
56
|
-
async push(to_identity:string,data:any)
|
|
57
|
-
{
|
|
58
|
-
let msg = this.getNewMsg("msg") as CgMqMsg
|
|
59
|
-
msg.to_identity = to_identity
|
|
60
|
-
msg.data = data
|
|
61
|
-
let jsonData = await this.callRemote(msg)
|
|
62
|
-
return jsonData
|
|
63
|
-
}
|
|
64
|
-
async receive_msg(msg:CgMqRetMsg)
|
|
65
|
-
{
|
|
66
|
-
let data = await this._cgmq.onMsg(msg)
|
|
67
|
-
msg.data = data
|
|
68
|
-
msg.__return = true
|
|
69
|
-
msg.to_identity=msg.from_identity
|
|
70
|
-
msg.from_identity=this._identity
|
|
71
|
-
this.send(msg)
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
export class CgMqConfig
|
|
75
|
-
{
|
|
76
|
-
identity=""
|
|
77
|
-
host=""
|
|
78
|
-
port=-1
|
|
79
|
-
}
|
|
80
|
-
export class CgMq
|
|
81
|
-
{
|
|
82
|
-
protected _ws:CgMqServerWebsocket=null
|
|
83
|
-
protected _inited=false
|
|
84
|
-
protected _cfg:CgMqConfig=null
|
|
85
|
-
protected _onmsg:(msg:CgMqRetMsg)=>any=null
|
|
86
|
-
get cfg()
|
|
87
|
-
{
|
|
88
|
-
return this._cfg
|
|
89
|
-
}
|
|
90
|
-
get identity()
|
|
91
|
-
{
|
|
92
|
-
return this._cfg?.identity
|
|
93
|
-
}
|
|
94
|
-
async init(cfg:CgMqConfig,onmsg?:(msg:CgMqRetMsg)=>any)
|
|
95
|
-
{
|
|
96
|
-
if(!cfg)
|
|
97
|
-
{
|
|
98
|
-
return false
|
|
99
|
-
}
|
|
100
|
-
this._cfg=cfg
|
|
101
|
-
this._onmsg=onmsg
|
|
102
|
-
if(this._inited)
|
|
103
|
-
{
|
|
104
|
-
GLog.error("dulplicate init for CgMq")
|
|
105
|
-
return true
|
|
106
|
-
}
|
|
107
|
-
this._inited=true
|
|
108
|
-
if(!this._ws)
|
|
109
|
-
{
|
|
110
|
-
this._ws=new CgMqServerWebsocket(this)
|
|
111
|
-
}
|
|
112
|
-
return new Promise(async (resolve,reject)=>
|
|
113
|
-
{
|
|
114
|
-
this._ws.connect(cfg.host,cfg.port)
|
|
115
|
-
let pretime = Date.now()
|
|
116
|
-
while(true)
|
|
117
|
-
{
|
|
118
|
-
if(this._ws.connected)
|
|
119
|
-
{
|
|
120
|
-
resolve(true)
|
|
121
|
-
break
|
|
122
|
-
}
|
|
123
|
-
let now = Date.now()
|
|
124
|
-
if(now-pretime>=3*1000)
|
|
125
|
-
{
|
|
126
|
-
this._ws.close()
|
|
127
|
-
resolve(false)
|
|
128
|
-
break
|
|
129
|
-
}
|
|
130
|
-
await core.sleep(100)
|
|
131
|
-
}
|
|
132
|
-
})
|
|
133
|
-
}
|
|
134
|
-
async callRemote(to_identity:string,func_name:string,...args)
|
|
135
|
-
{
|
|
136
|
-
let data =
|
|
137
|
-
{
|
|
138
|
-
cmd:func_name,
|
|
139
|
-
args:args
|
|
140
|
-
}
|
|
141
|
-
let jsonData:CgMqRetMsg = (await this._ws.push(to_identity,data)) as CgMqRetMsg
|
|
142
|
-
return jsonData
|
|
143
|
-
}
|
|
144
|
-
async onMsg(msg:CgMqRetMsg)
|
|
145
|
-
{
|
|
146
|
-
if(this._onmsg)
|
|
147
|
-
{
|
|
148
|
-
let data = await core.safeCall(this._onmsg,null,msg)
|
|
149
|
-
return data
|
|
150
|
-
}
|
|
151
|
-
return
|
|
152
|
-
}
|
|
153
|
-
}
|