@seayoo-io/combo-sdk-node 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  - 验证世游服务端签发的 Identity Token 和 Ads Token
10
10
  - 接收 Server GM Command 指令并回复响应
11
11
 
12
- ## breaking change
12
+ ## breaking changes
13
13
 
14
14
  v1 新增 gm 模块的 [IdempotencyKey](https://docs.seayoo.com/combo/server/gm/#idempotency),主要改动包括:
15
15
 
@@ -184,6 +184,11 @@ interface ShipOrderNotification {
184
184
  amount: number
185
185
  /** 游戏侧创建订单时提供的订单上下文,透传回游戏 */
186
186
  context?: string
187
+ /**
188
+ * 是否是沙盒订单。沙盒订单意味着此订单并未产生真实的付款。
189
+ * 预期此字段仅用于记录日志和数据埋点。无论是否是沙盒订单,游戏侧都应当发货。
190
+ */
191
+ is_sandbox: boolean
187
192
  }
188
193
 
189
194
  interface RefundNotification {
@@ -299,7 +304,7 @@ if(identityPayload instanceof Error) {
299
304
  // do something
300
305
  }
301
306
  // 游客登录判断
302
- if(identityPayload.idp === IdP.Device) {
307
+ if(identityPayload.idp === IdP.Guest) {
303
308
  // do something
304
309
  }
305
310
  // 更多 IdP 枚举可以查看源码定义 src/const.ts
@@ -331,6 +336,10 @@ interface IdentityPayload {
331
336
  * 注意:weixin_unionid 只在 IdP 为 weixin 时才会有值。
332
337
  */
333
338
  weixin_unionid: string
339
+ /**
340
+ * device_id 是用户在登录时使用的设备的唯一 ID。
341
+ */
342
+ device_id: string
334
343
  /**
335
344
  * distro 是游戏客户端的发行版本标识。
336
345
  * 游戏侧可将 distro 用于服务端数据埋点,以及特定的业务逻辑判断。
@@ -470,7 +479,7 @@ import { MemoryIdempotencyStore, RedisIdempotencyStore } from "@seayoo-io/combo-
470
479
 
471
480
  // MemoryIdempotencyStore 仅仅用于本地调试
472
481
  const storeHelper = new MemoryIdempotencyStore()
473
- // RedisIdempotencyStore 基于 ioredis 实现
482
+ // RedisIdempotencyStore 基于 ioredis 实现,需要 Redis 版本大于 7: https://redis.io/docs/latest/commands/set/
474
483
  const storeHelper = new RedisIdempotencyStore({
475
484
  /** 超时设定,单位秒,推荐不低于24小时 */
476
485
  ttl?: number
package/dist/const.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /** SDK 名称 */
2
2
  export declare const SDKName = "combo-sdk-node";
3
3
  /** SDK 版本,在编译前会被动态替换 */
4
- export declare const SDKVersion = "1.2.0";
4
+ export declare const SDKVersion = "1.3.0";
5
5
  /**
6
6
  * 世游支持的服务端点列表
7
7
  */
@@ -26,8 +26,8 @@ export declare enum Platform {
26
26
  }
27
27
  /** 支持的登录提供方 */
28
28
  export declare enum IdP {
29
- /** 设备登录(游客) */
30
- Device = "device",
29
+ /** 游客登录 */
30
+ Guest = "guest",
31
31
  /** 世游通行证 */
32
32
  Seayoo = "seayoo",
33
33
  /** Sign-in with Apple */
@@ -39,7 +39,37 @@ export declare enum IdP {
39
39
  /** 小米账号 */
40
40
  Xiaomi = "xiaomi",
41
41
  /** 微信登录 */
42
- Weixin = "weixin"
42
+ Weixin = "weixin",
43
+ /** OPPO 账号 */
44
+ Oppo = "oppo",
45
+ /** VIVO 账号 */
46
+ Vivo = "vivo",
47
+ /** 华为账号 */
48
+ Huawei = "huawei",
49
+ /** 荣耀账号 */
50
+ Honor = "honor",
51
+ /** UC(九游)登录 */
52
+ UC = "uc",
53
+ /** TapTap 登录 */
54
+ TapTap = "taptap",
55
+ /** 哔哩哔哩(B站)账号 */
56
+ Bilibili = "bilibili",
57
+ /** 应用宝 YSDK 登录 */
58
+ Yingyongbao = "yingyongbao",
59
+ /** 4399 账号登录 */
60
+ F4399 = "4399",
61
+ /** 雷电模拟器账号 */
62
+ Leidian = "leidian",
63
+ /** 猫窝游戏 */
64
+ Maowo = "maowo",
65
+ /** 联想 */
66
+ Lenovo = "lenovo",
67
+ /** 魅族 */
68
+ Meizu = "meizu",
69
+ /** 酷派 */
70
+ Coolpad = "coolpad",
71
+ /** 努比亚 */
72
+ Nubia = "nubia"
43
73
  }
44
74
  /** GM 错误类型枚举 */
45
75
  export declare const enum GMError {
@@ -9,7 +9,11 @@ export declare class MemoryIdempotencyStore implements IdempotencyKeyStoreHelper
9
9
  setNX(key: string, value: string): Promise<string>;
10
10
  setXX(key: string, value: string): Promise<void>;
11
11
  }
12
- /** 基于 ioredis 的 store helper */
12
+ /**
13
+ * 基于 ioredis 的 store helper,
14
+ *
15
+ * 需要 Redis >= 7.0,见 https://redis.io/docs/latest/commands/set/
16
+ */
13
17
  export declare class RedisIdempotencyStore implements IdempotencyKeyStoreHelper {
14
18
  client: Redis;
15
19
  ttl: number;
package/dist/index.cjs CHANGED
@@ -12,7 +12,7 @@ var https__default = /*#__PURE__*/_interopDefaultLegacy(https);
12
12
  /** SDK 名称 */
13
13
  const SDKName = "combo-sdk-node";
14
14
  /** SDK 版本,在编译前会被动态替换 */
15
- const SDKVersion = "1.2.0";
15
+ const SDKVersion = "1.3.0";
16
16
  /**
17
17
  * 世游支持的服务端点列表
18
18
  */
@@ -40,8 +40,8 @@ exports.Platform = void 0;
40
40
  /** 支持的登录提供方 */
41
41
  exports.IdP = void 0;
42
42
  (function (IdP) {
43
- /** 设备登录(游客) */
44
- IdP["Device"] = "device";
43
+ /** 游客登录 */
44
+ IdP["Guest"] = "guest";
45
45
  /** 世游通行证 */
46
46
  IdP["Seayoo"] = "seayoo";
47
47
  /** Sign-in with Apple */
@@ -54,6 +54,36 @@ exports.IdP = void 0;
54
54
  IdP["Xiaomi"] = "xiaomi";
55
55
  /** 微信登录 */
56
56
  IdP["Weixin"] = "weixin";
57
+ /** OPPO 账号 */
58
+ IdP["Oppo"] = "oppo";
59
+ /** VIVO 账号 */
60
+ IdP["Vivo"] = "vivo";
61
+ /** 华为账号 */
62
+ IdP["Huawei"] = "huawei";
63
+ /** 荣耀账号 */
64
+ IdP["Honor"] = "honor";
65
+ /** UC(九游)登录 */
66
+ IdP["UC"] = "uc";
67
+ /** TapTap 登录 */
68
+ IdP["TapTap"] = "taptap";
69
+ /** 哔哩哔哩(B站)账号 */
70
+ IdP["Bilibili"] = "bilibili";
71
+ /** 应用宝 YSDK 登录 */
72
+ IdP["Yingyongbao"] = "yingyongbao";
73
+ /** 4399 账号登录 */
74
+ IdP["F4399"] = "4399";
75
+ /** 雷电模拟器账号 */
76
+ IdP["Leidian"] = "leidian";
77
+ /** 猫窝游戏 */
78
+ IdP["Maowo"] = "maowo";
79
+ /** 联想 */
80
+ IdP["Lenovo"] = "lenovo";
81
+ /** 魅族 */
82
+ IdP["Meizu"] = "meizu";
83
+ /** 酷派 */
84
+ IdP["Coolpad"] = "coolpad";
85
+ /** 努比亚 */
86
+ IdP["Nubia"] = "nubia";
57
87
  })(exports.IdP || (exports.IdP = {}));
58
88
 
59
89
  function getUserAgent(game) {
@@ -1087,7 +1117,7 @@ function isCreateOrderResponse(data) {
1087
1117
  }
1088
1118
 
1089
1119
  function isIdentityJwtPayload(payload) {
1090
- return isObject(payload) && "sub" in payload && "iss" in payload && "scope" in payload && "idp" in payload && "external_id" in payload && "external_name" in payload;
1120
+ return isObject(payload) && "sub" in payload && "iss" in payload && "scope" in payload && "idp" in payload && "device_id" in payload && "external_id" in payload && "external_name" in payload;
1091
1121
  }
1092
1122
 
1093
1123
  function isAdJwtPayload(payload) {
@@ -1138,6 +1168,7 @@ class TokenVerifier {
1138
1168
  weixin_unionid: payload.weixin_unionid || "",
1139
1169
  distro: payload.distro || "",
1140
1170
  variant: payload.variant || "",
1171
+ device_id: payload.device_id || "",
1141
1172
  age: payload.age || 0
1142
1173
  };
1143
1174
  } catch (error) {
@@ -1173,7 +1204,7 @@ class TokenVerifier {
1173
1204
  }
1174
1205
 
1175
1206
  function isShipOrderPayload(data) {
1176
- return isObject(data) && "order_id" in data && "reference_id" in data && "combo_id" in data && "product_id" in data && "quantity" in data && "currency" in data && "amount" in data && typeof data.order_id === "string" && typeof data.combo_id === "string" && typeof data.quantity === "number" && typeof data.amount === "number" && Number.isSafeInteger(data.quantity) && Number.isSafeInteger(data.amount) && !!data.order_id && !!data.combo_id;
1207
+ return isObject(data) && "order_id" in data && "reference_id" in data && "combo_id" in data && "product_id" in data && "quantity" in data && "currency" in data && "amount" in data && "is_sandbox" in data && typeof data.order_id === "string" && typeof data.combo_id === "string" && typeof data.quantity === "number" && typeof data.amount === "number" && typeof data.is_sandbox === "boolean" && Number.isSafeInteger(data.quantity) && Number.isSafeInteger(data.amount) && !!data.order_id && !!data.combo_id;
1177
1208
  }
1178
1209
 
1179
1210
  function isRefundPayload(data) {
@@ -1371,7 +1402,11 @@ class MemoryIdempotencyStore {
1371
1402
  }
1372
1403
  }
1373
1404
  }
1374
- /** 基于 ioredis 的 store helper */
1405
+ /**
1406
+ * 基于 ioredis 的 store helper,
1407
+ *
1408
+ * 需要 Redis >= 7.0,见 https://redis.io/docs/latest/commands/set/
1409
+ */
1375
1410
  class RedisIdempotencyStore {
1376
1411
  constructor(options) {
1377
1412
  var _options$ttl;
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import { verify } from 'jsonwebtoken';
7
7
  /** SDK 名称 */
8
8
  const SDKName = "combo-sdk-node";
9
9
  /** SDK 版本,在编译前会被动态替换 */
10
- const SDKVersion = "1.2.0";
10
+ const SDKVersion = "1.3.0";
11
11
  /**
12
12
  * 世游支持的服务端点列表
13
13
  */
@@ -35,8 +35,8 @@ var Platform;
35
35
  /** 支持的登录提供方 */
36
36
  var IdP;
37
37
  (function (IdP) {
38
- /** 设备登录(游客) */
39
- IdP["Device"] = "device";
38
+ /** 游客登录 */
39
+ IdP["Guest"] = "guest";
40
40
  /** 世游通行证 */
41
41
  IdP["Seayoo"] = "seayoo";
42
42
  /** Sign-in with Apple */
@@ -49,6 +49,36 @@ var IdP;
49
49
  IdP["Xiaomi"] = "xiaomi";
50
50
  /** 微信登录 */
51
51
  IdP["Weixin"] = "weixin";
52
+ /** OPPO 账号 */
53
+ IdP["Oppo"] = "oppo";
54
+ /** VIVO 账号 */
55
+ IdP["Vivo"] = "vivo";
56
+ /** 华为账号 */
57
+ IdP["Huawei"] = "huawei";
58
+ /** 荣耀账号 */
59
+ IdP["Honor"] = "honor";
60
+ /** UC(九游)登录 */
61
+ IdP["UC"] = "uc";
62
+ /** TapTap 登录 */
63
+ IdP["TapTap"] = "taptap";
64
+ /** 哔哩哔哩(B站)账号 */
65
+ IdP["Bilibili"] = "bilibili";
66
+ /** 应用宝 YSDK 登录 */
67
+ IdP["Yingyongbao"] = "yingyongbao";
68
+ /** 4399 账号登录 */
69
+ IdP["F4399"] = "4399";
70
+ /** 雷电模拟器账号 */
71
+ IdP["Leidian"] = "leidian";
72
+ /** 猫窝游戏 */
73
+ IdP["Maowo"] = "maowo";
74
+ /** 联想 */
75
+ IdP["Lenovo"] = "lenovo";
76
+ /** 魅族 */
77
+ IdP["Meizu"] = "meizu";
78
+ /** 酷派 */
79
+ IdP["Coolpad"] = "coolpad";
80
+ /** 努比亚 */
81
+ IdP["Nubia"] = "nubia";
52
82
  })(IdP || (IdP = {}));
53
83
 
54
84
  function getUserAgent(game) {
@@ -1082,7 +1112,7 @@ function isCreateOrderResponse(data) {
1082
1112
  }
1083
1113
 
1084
1114
  function isIdentityJwtPayload(payload) {
1085
- return isObject(payload) && "sub" in payload && "iss" in payload && "scope" in payload && "idp" in payload && "external_id" in payload && "external_name" in payload;
1115
+ return isObject(payload) && "sub" in payload && "iss" in payload && "scope" in payload && "idp" in payload && "device_id" in payload && "external_id" in payload && "external_name" in payload;
1086
1116
  }
1087
1117
 
1088
1118
  function isAdJwtPayload(payload) {
@@ -1133,6 +1163,7 @@ class TokenVerifier {
1133
1163
  weixin_unionid: payload.weixin_unionid || "",
1134
1164
  distro: payload.distro || "",
1135
1165
  variant: payload.variant || "",
1166
+ device_id: payload.device_id || "",
1136
1167
  age: payload.age || 0
1137
1168
  };
1138
1169
  } catch (error) {
@@ -1168,7 +1199,7 @@ class TokenVerifier {
1168
1199
  }
1169
1200
 
1170
1201
  function isShipOrderPayload(data) {
1171
- return isObject(data) && "order_id" in data && "reference_id" in data && "combo_id" in data && "product_id" in data && "quantity" in data && "currency" in data && "amount" in data && typeof data.order_id === "string" && typeof data.combo_id === "string" && typeof data.quantity === "number" && typeof data.amount === "number" && Number.isSafeInteger(data.quantity) && Number.isSafeInteger(data.amount) && !!data.order_id && !!data.combo_id;
1202
+ return isObject(data) && "order_id" in data && "reference_id" in data && "combo_id" in data && "product_id" in data && "quantity" in data && "currency" in data && "amount" in data && "is_sandbox" in data && typeof data.order_id === "string" && typeof data.combo_id === "string" && typeof data.quantity === "number" && typeof data.amount === "number" && typeof data.is_sandbox === "boolean" && Number.isSafeInteger(data.quantity) && Number.isSafeInteger(data.amount) && !!data.order_id && !!data.combo_id;
1172
1203
  }
1173
1204
 
1174
1205
  function isRefundPayload(data) {
@@ -1366,7 +1397,11 @@ class MemoryIdempotencyStore {
1366
1397
  }
1367
1398
  }
1368
1399
  }
1369
- /** 基于 ioredis 的 store helper */
1400
+ /**
1401
+ * 基于 ioredis 的 store helper,
1402
+ *
1403
+ * 需要 Redis >= 7.0,见 https://redis.io/docs/latest/commands/set/
1404
+ */
1370
1405
  class RedisIdempotencyStore {
1371
1406
  constructor(options) {
1372
1407
  var _options$ttl;
@@ -16,5 +16,11 @@ export interface ShipOrderNotification {
16
16
  amount: number;
17
17
  /** 游戏侧创建订单时提供的订单上下文,透传回游戏 */
18
18
  context?: string;
19
+ /**
20
+ * 是否是沙盒订单。沙盒订单意味着此订单并未产生真实的付款。
21
+ *
22
+ * 预期此字段仅用于记录日志和数据埋点。无论是否是沙盒订单,游戏侧都应当发货。
23
+ */
24
+ is_sandbox: boolean;
19
25
  }
20
26
  export declare function isShipOrderPayload(data: unknown): data is ShipOrderNotification;
@@ -4,7 +4,7 @@ export interface IdentityPayload {
4
4
  /**
5
5
  * combo_id 是世游分配的聚合用户 ID
6
6
  *
7
- * 游戏侧应当使用 combo_id 作为用户的唯一标识。
7
+ * 游戏侧应当使用 combo_id 作为用户的唯一标识,即游戏帐号。
8
8
  */
9
9
  combo_id: string;
10
10
  /**
@@ -36,6 +36,10 @@ export interface IdentityPayload {
36
36
  * 注意:weixin_unionid 只在 IdP 为 weixin 时才会有值。
37
37
  */
38
38
  weixin_unionid: string;
39
+ /**
40
+ * DeviceId 是用户在登录时使用的设备的唯一 ID。
41
+ */
42
+ device_id: string;
39
43
  /**
40
44
  * distro 是游戏客户端的发行版本标识。
41
45
  * 游戏侧可将 distro 用于服务端数据埋点,以及特定的业务逻辑判断。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seayoo-io/combo-sdk-node",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Combo SDK for Node.js",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",