xiongzhu 3 жил өмнө
parent
commit
c6decdf15c

+ 109 - 109
graph.json

@@ -14,7 +14,7 @@
         "transient": false,
         "exported": false,
         "token": "JwtModule",
-        "initTime": 2.703836999833584
+        "initTime": 1.9984169993549585
       }
     },
     "203550704": {
@@ -57,7 +57,7 @@
         "transient": false,
         "exported": false,
         "token": "InternalCoreModule",
-        "initTime": 4.6064669992774725
+        "initTime": 3.3319579996168613
       }
     },
     "233936880": {
@@ -73,7 +73,7 @@
         "transient": false,
         "exported": false,
         "token": "AppController",
-        "initTime": 1.223742000758648
+        "initTime": 0.7382089998573065
       }
     },
     "266839889": {
@@ -89,7 +89,7 @@
         "transient": false,
         "exported": true,
         "token": "EntityManager",
-        "initTime": 967.2324289996177
+        "initTime": 1023.4093329999596
       }
     },
     "303302557": {
@@ -121,7 +121,7 @@
         "transient": false,
         "exported": false,
         "token": "SandboxedCodeExecutor",
-        "initTime": 5.237732999026775
+        "initTime": 3.9130830001085997
       }
     },
     "385041166": {
@@ -137,7 +137,7 @@
         "transient": false,
         "exported": false,
         "token": "JwtStrategy",
-        "initTime": 4.255191000178456
+        "initTime": 3.1414590012282133
       }
     },
     "400681591": {
@@ -153,7 +153,7 @@
         "transient": false,
         "exported": true,
         "token": "DiscoveryService",
-        "initTime": 4.280860001221299
+        "initTime": 3.4062090013176203
       }
     },
     "422823200": {
@@ -186,7 +186,7 @@
         "transient": false,
         "exported": false,
         "token": "AliyunModule",
-        "initTime": 3.1228829994797707
+        "initTime": 2.3266660012304783
       }
     },
     "485644527": {
@@ -360,7 +360,7 @@
         "transient": false,
         "exported": true,
         "token": "Reflector",
-        "initTime": 4.493568999692798
+        "initTime": 3.2668329998850822
       }
     },
     "687352615": {
@@ -473,7 +473,7 @@
         "transient": false,
         "exported": false,
         "token": "TypeOrmCoreModule",
-        "initTime": 43.4224529992789
+        "initTime": 32.01300000026822
       }
     },
     "863216333": {
@@ -545,7 +545,7 @@
         "transient": false,
         "exported": true,
         "token": "Symbol(CONFIG_SERVICE)",
-        "initTime": 4.473619999364018
+        "initTime": 3.421458000317216
       }
     },
     "958198135": {
@@ -592,7 +592,7 @@
         "transient": false,
         "exported": true,
         "token": "CONFIGURATION_TOKEN",
-        "initTime": 3.3922749999910593
+        "initTime": 2.5850409995764494
       }
     },
     "1070370213": {
@@ -608,7 +608,7 @@
         "transient": false,
         "exported": true,
         "token": "JwtService",
-        "initTime": 5.515937000513077
+        "initTime": 4.125667000189424
       }
     },
     "1074192353": {
@@ -624,7 +624,7 @@
         "transient": false,
         "exported": false,
         "token": "ChatService",
-        "initTime": 2.6592510007321835
+        "initTime": 1.9568339996039867
       }
     },
     "1088881013": {
@@ -640,7 +640,7 @@
         "transient": false,
         "exported": true,
         "token": "JsapiTicketRepository",
-        "initTime": 966.8693530000746
+        "initTime": 1022.9690000005066
       }
     },
     "1144875719": {
@@ -721,7 +721,7 @@
         "transient": false,
         "exported": false,
         "token": "ChatModule",
-        "initTime": 2.663580998778343
+        "initTime": 1.9606670010834932
       }
     },
     "1197623157": {
@@ -753,7 +753,7 @@
         "transient": false,
         "exported": false,
         "token": "ChatController",
-        "initTime": 1.3939970005303621
+        "initTime": 0.8369580004364252
       }
     },
     "1219676411": {
@@ -779,7 +779,7 @@
         "transient": false,
         "exported": true,
         "token": "SmsRecordRepository",
-        "initTime": 967.2608669996262
+        "initTime": 1023.4031670000404
       }
     },
     "1310883338": {
@@ -795,7 +795,7 @@
         "transient": false,
         "exported": false,
         "token": "CONFIGURATION_LOADER",
-        "initTime": 4.4956310000270605
+        "initTime": 3.382915999740362
       }
     },
     "1333473084": {
@@ -811,7 +811,7 @@
         "transient": false,
         "exported": false,
         "token": "CONFIGURATION_LOADER",
-        "initTime": 4.177340000867844
+        "initTime": 3.078208999708295
       }
     },
     "1333473085": {
@@ -827,7 +827,7 @@
         "transient": false,
         "exported": false,
         "token": "CONFIGURATION_LOADER",
-        "initTime": 3.995862999930978
+        "initTime": 2.8877499997615814
       }
     },
     "1349506255": {
@@ -860,7 +860,7 @@
         "transient": false,
         "exported": false,
         "token": "FileModule",
-        "initTime": 2.6809800006449223
+        "initTime": 1.9770419988781214
       }
     },
     "1398129121": {
@@ -876,7 +876,7 @@
         "transient": false,
         "exported": false,
         "token": "MembershipService",
-        "initTime": 968.2502619996667
+        "initTime": 1024.2344589997083
       }
     },
     "1399306624": {
@@ -893,7 +893,7 @@
         "transient": false,
         "exported": false,
         "token": "ThrottlerModule",
-        "initTime": 3.3871360011398792
+        "initTime": 2.5796670001000166
       }
     },
     "1404752088": {
@@ -925,7 +925,7 @@
         "transient": false,
         "exported": true,
         "token": "Reflector",
-        "initTime": 5.638150000944734
+        "initTime": 4.207167001441121
       }
     },
     "1475573941": {
@@ -984,7 +984,7 @@
         "transient": false,
         "exported": true,
         "token": "Connection",
-        "initTime": 967.2096780017018
+        "initTime": 1023.3300419989973
       }
     },
     "1542581243": {
@@ -1016,10 +1016,10 @@
         "transient": false,
         "exported": false,
         "token": "FileController",
-        "initTime": 0.20798899978399277,
+        "initTime": 0.16699999943375587,
         "enhancers": [
           {
-            "id": "-291678924",
+            "id": "-449986825",
             "methodKey": "uploadFile",
             "subtype": "interceptor"
           }
@@ -1055,7 +1055,7 @@
         "transient": false,
         "exported": false,
         "token": "DevtoolsHttpServerHost",
-        "initTime": 6.859546998515725
+        "initTime": 5.1698749996721745
       }
     },
     "1690574933": {
@@ -1087,7 +1087,7 @@
         "transient": false,
         "exported": true,
         "token": "AliyunService",
-        "initTime": 4.636212999001145
+        "initTime": 3.432667000219226
       }
     },
     "1712628187": {
@@ -1130,7 +1130,7 @@
         "transient": false,
         "exported": false,
         "token": "ConfigModule",
-        "initTime": 3.539273999631405
+        "initTime": 2.694957999512553
       }
     },
     "1787828844": {
@@ -1147,7 +1147,7 @@
         "transient": false,
         "exported": false,
         "token": "ConfigHostModule",
-        "initTime": 3.399294000118971
+        "initTime": 2.5899999998509884
       }
     },
     "1817334964": {
@@ -1179,7 +1179,7 @@
         "transient": false,
         "exported": false,
         "token": "FileService",
-        "initTime": 5.565779998898506
+        "initTime": 4.159291999414563
       }
     },
     "1864578377": {
@@ -1195,7 +1195,7 @@
         "transient": false,
         "exported": true,
         "token": "SmsService",
-        "initTime": 968.6069090012461
+        "initTime": 1024.5841249991208
       }
     },
     "1919157847": {
@@ -1212,7 +1212,7 @@
         "transient": false,
         "exported": true,
         "token": "REQUEST",
-        "initTime": 3.491976000368595
+        "initTime": 2.678083000704646
       }
     },
     "1934208604": {
@@ -1229,7 +1229,7 @@
         "exported": false,
         "token": "APP_GUARD (UUID: 1201125561)",
         "subtype": "guard",
-        "initTime": 3.7867830004543066
+        "initTime": 2.839375000447035
       }
     },
     "1974892061": {
@@ -1245,7 +1245,7 @@
         "transient": false,
         "exported": true,
         "token": "AccessTokenRepository",
-        "initTime": 966.8768509998918
+        "initTime": 1023.0426249988377
       }
     },
     "1989588516": {
@@ -1277,7 +1277,7 @@
         "transient": false,
         "exported": false,
         "token": "TypeOrmModuleOptions",
-        "initTime": 7.142191998660564
+        "initTime": 5.473625000566244
       }
     },
     "2118694856": {
@@ -1342,7 +1342,7 @@
         "transient": true,
         "exported": true,
         "token": "INQUIRER",
-        "initTime": 3.486200001090765
+        "initTime": 2.6753340009599924
       }
     },
     "-26938366": {
@@ -1391,7 +1391,7 @@
         "transient": false,
         "exported": true,
         "token": "HttpAdapterHost",
-        "initTime": 4.448602000251412
+        "initTime": 3.511167000979185
       }
     },
     "-702581189": {
@@ -1407,7 +1407,7 @@
         "transient": false,
         "exported": true,
         "token": "LazyModuleLoader",
-        "initTime": 4.0531379990279675
+        "initTime": 3.1030420009046793
       }
     },
     "-1904419534": {
@@ -1450,7 +1450,7 @@
         "transient": false,
         "exported": false,
         "token": "AppModule",
-        "initTime": 4.04522000066936
+        "initTime": 3.1045830007642508
       }
     },
     "-71302842": {
@@ -1498,7 +1498,7 @@
         "transient": false,
         "exported": false,
         "token": "AppService",
-        "initTime": 3.9357040002942085
+        "initTime": 3.0422079991549253
       }
     },
     "-1033621697": {
@@ -1525,7 +1525,7 @@
         "transient": false,
         "exported": false,
         "token": "DevtoolsModule",
-        "initTime": 3.9059989992529154
+        "initTime": 2.9653329998254776
       }
     },
     "-751962311": {
@@ -1544,9 +1544,9 @@
         "token": "ModuleRef"
       }
     },
-    "-1266124403": {
-      "id": "-1266124403",
-      "label": "CONFIGURABLE_MODULE_OPTIONS[c44f37a71005e3aaa536d]",
+    "-9446185": {
+      "id": "-9446185",
+      "label": "CONFIGURABLE_MODULE_OPTIONS[99220ae20923f9df2ca67]",
       "parent": "-1033621697",
       "metadata": {
         "type": "provider",
@@ -1557,7 +1557,7 @@
         "scope": 0,
         "transient": false,
         "exported": false,
-        "token": "CONFIGURABLE_MODULE_OPTIONS[c44f37a71005e3aaa536d]"
+        "token": "CONFIGURABLE_MODULE_OPTIONS[99220ae20923f9df2ca67]"
       }
     },
     "-643397745": {
@@ -1584,7 +1584,7 @@
         "transient": false,
         "exported": false,
         "token": "DiscoveryModule",
-        "initTime": 3.6015999987721443
+        "initTime": 2.767041001468897
       }
     },
     "-501891371": {
@@ -1632,7 +1632,7 @@
         "transient": false,
         "exported": true,
         "token": "MetadataScanner",
-        "initTime": 3.615140000358224
+        "initTime": 2.7773749995976686
       }
     },
     "-503631789": {
@@ -1648,7 +1648,7 @@
         "transient": false,
         "exported": true,
         "token": "ConfigService",
-        "initTime": 6.3530029989778996
+        "initTime": 4.8198750000447035
       }
     },
     "-1952648617": {
@@ -1664,7 +1664,7 @@
         "transient": false,
         "exported": true,
         "token": "THROTTLER:MODULE_OPTIONS",
-        "initTime": 7.352739000692964
+        "initTime": 5.625499999150634
       }
     },
     "-470986226": {
@@ -1680,7 +1680,7 @@
         "transient": false,
         "exported": true,
         "token": "Symbol(ThrottlerStorage)",
-        "initTime": 43.53526799939573
+        "initTime": 32.10645799897611
       }
     },
     "-491114354": {
@@ -1697,7 +1697,7 @@
         "transient": false,
         "exported": false,
         "token": "ConfigModule",
-        "initTime": 3.3143899999558926
+        "initTime": 2.474166000261903
       }
     },
     "-408540750": {
@@ -1730,7 +1730,7 @@
         "transient": false,
         "exported": true,
         "token": "ConfigService",
-        "initTime": 6.2427940014749765
+        "initTime": 4.745083998888731
       }
     },
     "-2135742481": {
@@ -1757,7 +1757,7 @@
         "transient": false,
         "exported": false,
         "token": "TypeOrmModule",
-        "initTime": 3.3074019998311996
+        "initTime": 2.465750001370907
       }
     },
     "-1068388246": {
@@ -1815,7 +1815,7 @@
         "transient": false,
         "exported": true,
         "token": "DataSource",
-        "initTime": 967.037376999855
+        "initTime": 1023.16995799914
       }
     },
     "-184353870": {
@@ -1848,7 +1848,7 @@
         "transient": false,
         "exported": false,
         "token": "ConfigModule",
-        "initTime": 3.0874020010232925
+        "initTime": 2.3027910012751818
       }
     },
     "-408540749": {
@@ -1880,7 +1880,7 @@
         "transient": false,
         "exported": true,
         "token": "ConfigService",
-        "initTime": 5.9496389999985695
+        "initTime": 4.466874999925494
       }
     },
     "-1790226991": {
@@ -1896,7 +1896,7 @@
         "transient": false,
         "exported": true,
         "token": "CONFIGURATION(aliyun)",
-        "initTime": 3.0937280002981424
+        "initTime": 2.3081660009920597
       }
     },
     "-759474504": {
@@ -1923,7 +1923,7 @@
         "transient": false,
         "exported": false,
         "token": "SmsModule",
-        "initTime": 2.9608550015836954
+        "initTime": 2.263000000268221
       }
     },
     "-811664770": {
@@ -1971,7 +1971,7 @@
         "transient": false,
         "exported": false,
         "token": "TypeOrmModule",
-        "initTime": 2.8524730000644922
+        "initTime": 2.125416999682784
       }
     },
     "-223917668": {
@@ -2014,7 +2014,7 @@
         "transient": false,
         "exported": false,
         "token": "UsersModule",
-        "initTime": 2.8451950009912252
+        "initTime": 2.1180419996380806
       }
     },
     "-618964563": {
@@ -2062,7 +2062,7 @@
         "transient": false,
         "exported": false,
         "token": "HashingService",
-        "initTime": 2.8394559994339943
+        "initTime": 2.1131250001490116
       }
     },
     "-1102473136": {
@@ -2094,7 +2094,7 @@
         "transient": false,
         "exported": false,
         "token": "TypeOrmModule",
-        "initTime": 2.8081990014761686
+        "initTime": 2.090125000104308
       }
     },
     "-223917667": {
@@ -2126,7 +2126,7 @@
         "transient": false,
         "exported": true,
         "token": "UsersRepository",
-        "initTime": 967.1829280015081
+        "initTime": 1023.3412079997361
       }
     },
     "-1134487807": {
@@ -2153,7 +2153,7 @@
         "transient": false,
         "exported": false,
         "token": "AuthModule",
-        "initTime": 2.7990439999848604
+        "initTime": 2.0796250011771917
       }
     },
     "-120792986": {
@@ -2201,7 +2201,7 @@
         "exported": false,
         "token": "APP_GUARD (UUID: 1239237319)",
         "subtype": "guard",
-        "initTime": 5.315542999655008
+        "initTime": 4.0510839987546206
       }
     },
     "-491114352": {
@@ -2218,7 +2218,7 @@
         "transient": false,
         "exported": false,
         "token": "ConfigModule",
-        "initTime": 2.737238999456167
+        "initTime": 2.0292500015348196
       }
     },
     "-408540748": {
@@ -2250,7 +2250,7 @@
         "transient": false,
         "exported": true,
         "token": "ConfigService",
-        "initTime": 5.549033999443054
+        "initTime": 4.157415999099612
       }
     },
     "-1453472830": {
@@ -2266,7 +2266,7 @@
         "transient": false,
         "exported": true,
         "token": "CONFIGURATION(jwt)",
-        "initTime": 2.758816000074148
+        "initTime": 2.0497500002384186
       }
     },
     "-536515674": {
@@ -2308,7 +2308,7 @@
         "transient": false,
         "exported": false,
         "token": "JWT_MODULE_OPTIONS",
-        "initTime": 4.154202999547124
+        "initTime": 3.055790999904275
       }
     },
     "-1327562795": {
@@ -2337,9 +2337,9 @@
         "token": "ApplicationConfig"
       }
     },
-    "-291678924": {
-      "id": "-291678924",
-      "label": "4f37a71005e3aaa536d52",
+    "-449986825": {
+      "id": "-449986825",
+      "label": "220ae20923f9df2ca6750",
       "parent": "-1327562795",
       "metadata": {
         "type": "injectable",
@@ -2349,9 +2349,9 @@
         "static": true,
         "transient": false,
         "exported": false,
-        "token": "4f37a71005e3aaa536d52",
+        "token": "220ae20923f9df2ca6750",
         "subtype": "interceptor",
-        "initTime": 0.463901000097394
+        "initTime": 0.29100000113248825
       }
     },
     "-493958991": {
@@ -2394,7 +2394,7 @@
         "transient": false,
         "exported": false,
         "token": "MembershipModule",
-        "initTime": 2.6556160002946854
+        "initTime": 1.951707998290658
       }
     },
     "-1902200172": {
@@ -2427,7 +2427,7 @@
         "transient": false,
         "exported": false,
         "token": "TypeOrmModule",
-        "initTime": 2.6218110006302595
+        "initTime": 1.9209170006215572
       }
     },
     "-223917666": {
@@ -2459,7 +2459,7 @@
         "transient": false,
         "exported": true,
         "token": "MembershipRepository",
-        "initTime": 966.9819319993258
+        "initTime": 1023.1709579993039
       }
     },
     "-1028500433": {
@@ -2475,7 +2475,7 @@
         "transient": false,
         "exported": true,
         "token": "MemberPlanRepository",
-        "initTime": 966.9714049994946
+        "initTime": 1023.1602090001106
       }
     },
     "-257450699": {
@@ -2492,7 +2492,7 @@
         "transient": false,
         "exported": false,
         "token": "TypeOrmModule",
-        "initTime": 2.615988999605179
+        "initTime": 1.9114169999957085
       }
     },
     "-223917665": {
@@ -2524,7 +2524,7 @@
         "transient": false,
         "exported": true,
         "token": "MemberPlanRepository",
-        "initTime": 966.9517310000956
+        "initTime": 1023.1317090000957
       }
     },
     "-133150180": {
@@ -2541,7 +2541,7 @@
         "transient": false,
         "exported": false,
         "token": "WeixinModule",
-        "initTime": 2.607796000316739
+        "initTime": 1.899583000689745
       }
     },
     "-465670943": {
@@ -2588,7 +2588,7 @@
         "transient": false,
         "exported": false,
         "token": "ConfigModule",
-        "initTime": 2.577945001423359
+        "initTime": 1.8674579989165068
       }
     },
     "-408540747": {
@@ -2620,7 +2620,7 @@
         "transient": false,
         "exported": true,
         "token": "ConfigService",
-        "initTime": 5.363270001485944
+        "initTime": 3.969165999442339
       }
     },
     "-904418141": {
@@ -2636,7 +2636,7 @@
         "transient": false,
         "exported": true,
         "token": "CONFIGURATION(weixin)",
-        "initTime": 2.5941620003432035
+        "initTime": 1.8879170008003712
       }
     },
     "-257450698": {
@@ -2653,7 +2653,7 @@
         "transient": false,
         "exported": false,
         "token": "TypeOrmModule",
-        "initTime": 2.5501419994980097
+        "initTime": 1.8289580009877682
       }
     },
     "-223917664": {
@@ -3257,6 +3257,21 @@
       },
       "id": "1033762794"
     },
+    "1049432644": {
+      "source": "1609867136",
+      "target": "-449986825",
+      "metadata": {
+        "type": "class-to-class",
+        "sourceModuleName": "FileModule",
+        "sourceClassName": "FileController",
+        "targetClassName": "220ae20923f9df2ca6750",
+        "sourceClassToken": "FileController",
+        "targetClassToken": "220ae20923f9df2ca6750",
+        "targetModuleName": "FileModule",
+        "injectionType": "decorator"
+      },
+      "id": "1049432644"
+    },
     "1056428433": {
       "source": "-19112576",
       "target": "555176277",
@@ -3547,21 +3562,6 @@
       },
       "id": "1498156362"
     },
-    "1554301336": {
-      "source": "1609867136",
-      "target": "-291678924",
-      "metadata": {
-        "type": "class-to-class",
-        "sourceModuleName": "FileModule",
-        "sourceClassName": "FileController",
-        "targetClassName": "4f37a71005e3aaa536d52",
-        "sourceClassToken": "FileController",
-        "targetClassToken": "4f37a71005e3aaa536d52",
-        "targetModuleName": "FileModule",
-        "injectionType": "decorator"
-      },
-      "id": "1554301336"
-    },
     "1571031686": {
       "source": "1219676411",
       "target": "211572259",
@@ -4119,21 +4119,21 @@
       },
       "id": "-1609063867"
     },
-    "-1308301887": {
+    "-915642753": {
       "source": "1688619051",
-      "target": "-1266124403",
+      "target": "-9446185",
       "metadata": {
         "type": "class-to-class",
         "sourceModuleName": "DevtoolsModule",
         "sourceClassName": "DevtoolsHttpServerHost",
-        "targetClassName": "CONFIGURABLE_MODULE_OPTIONS[c44f37a71005e3aaa536d]",
+        "targetClassName": "CONFIGURABLE_MODULE_OPTIONS[99220ae20923f9df2ca67]",
         "sourceClassToken": "DevtoolsHttpServerHost",
-        "targetClassToken": "CONFIGURABLE_MODULE_OPTIONS[c44f37a71005e3aaa536d]",
+        "targetClassToken": "CONFIGURABLE_MODULE_OPTIONS[99220ae20923f9df2ca67]",
         "targetModuleName": "DevtoolsModule",
         "keyOrIndex": 2,
         "injectionType": "constructor"
       },
-      "id": "-1308301887"
+      "id": "-915642753"
     },
     "-1851085465": {
       "source": "-503631788",
@@ -5090,7 +5090,7 @@
         "errno": -2,
         "syscall": "open",
         "code": "ENOENT",
-        "path": "/Users/drew/Projects/Node/cert/apiclient_key.pem"
+        "path": "src/cert/platform_key.pem"
       }
     }
   }

+ 24 - 0
src/cert/platform_cert.pem

@@ -0,0 +1,24 @@
+-----BEGIN CERTIFICATE-----
+MIIEFDCCAvygAwIBAgIUOLcd3WMB5BSgOavY0U/mHGe7YuUwDQYJKoZIhvcNAQEL
+BQAwXjELMAkGA1UEBhMCQ04xEzARBgNVBAoTClRlbnBheS5jb20xHTAbBgNVBAsT
+FFRlbnBheS5jb20gQ0EgQ2VudGVyMRswGQYDVQQDExJUZW5wYXkuY29tIFJvb3Qg
+Q0EwHhcNMjMwNDE4MDcwMDQwWhcNMjgwNDE2MDcwMDQwWjBuMRgwFgYDVQQDDA9U
+ZW5wYXkuY29tIHNpZ24xEzARBgNVBAoMClRlbnBheS5jb20xHTAbBgNVBAsMFFRl
+bnBheS5jb20gQ0EgQ2VudGVyMQswCQYDVQQGDAJDTjERMA8GA1UEBwwIU2hlblpo
+ZW4wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDStHfUxUIb01xR5axp
+aQe4SdmMPAAgxB+8YGJndSUuIxb4pm0U8p2ssUE0qzIO9mZW4J8tPF+Wkr4vLzp0
+ayHKDSKdl+lgEmNx3WLsuzjPTurdWct8RsEbTP8oCT7mDaOSYva5NrZPjCIyj5nM
+zgfnPSounCjnzulEFgli/VyJQqiolZOt/qkRALIZFMN1NGs3PRlaVzGhRi3KJbVV
+EKXURHrPl2Efy2cvwV4E4iUjgFvRZ3kt3MPCCld6b8EM8pXVhUOxj5WICVNUc565
+ySpqQrbqqNitIwpx+pe/YtF2qoZg6DVdZy+tvexoAp7WWlJSlNbiCWBErKVeqprk
+j1ZdAgMBAAGjgbkwgbYwCQYDVR0TBAIwADALBgNVHQ8EBAMCA/gwgZsGA1UdHwSB
+kzCBkDCBjaCBiqCBh4aBhGh0dHA6Ly9ldmNhLml0cnVzLmNvbS5jbi9wdWJsaWMv
+aXRydXNjcmw/Q0E9MUJENDIyMEU1MERCQzA0QjA2QUQzOTc1NDk4NDZDMDFDM0U4
+RUJEMiZzZz1IQUNDNDcxQjY1NDIyRTEyQjI3QTlEMzNBODdBRDFDREY1OTI2RTE0
+MDM3MTANBgkqhkiG9w0BAQsFAAOCAQEAoSmerBMFyiplNhMgEX3pa9WcIqKFA+aG
+07TGqMT/GdAAakKnk43ukj+yfeIy2g0J6olxS8TR/HUq0zj+DhnHidDfu/m++PZ+
+OiPjEI5Lgu4m0VgJUCcAAQbbXt+YF7TUlptXZZK8VqAaHAqOg15Yu9ykrPbKPkC0
+vW2Mkz1N9zA9axBEVtaZHDylWghbAemsT6OTmU9gH2qONygYjVOVj0rue8gKqQih
+0He/X+EujrvSB7aLP56IvOCBeM18zGg0Wc+P7cWmbgSpheoR3v/3e3F92qV133YH
+b7kXwhk76WqjZaoALdyrsFRnpwj7YzNgnHwtJBrQImFfpPp5L5+kmg==
+-----END CERTIFICATE-----

+ 5 - 4
src/weixin/entities/jsapiTicket.entity.ts → src/weixin/entities/access-token-cache.entity.ts

@@ -1,18 +1,19 @@
 import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm'
 
 @Entity()
-export class JsapiTicket {
+export class AccessTokenCache {
+
     @PrimaryGeneratedColumn()
     id: number
 
     @Column()
-    ticket: string
+    json: string
 
     @Column()
     expireAt: Date
 
-    constructor(ticket: string, expireAt: Date) {
-        this.ticket = ticket
+    constructor(json: string, expireAt: Date) {
+        this.json = json
         this.expireAt = expireAt
     }
 }

+ 4 - 4
src/weixin/entities/accessToken.entity.ts → src/weixin/entities/jsapi-ticket-cache.entity.ts

@@ -1,18 +1,18 @@
 import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm'
 
 @Entity()
-export class AccessToken {
+export class JsapiTicketCache {
     @PrimaryGeneratedColumn()
     id: number
 
     @Column()
-    accessToken: string
+    json: string
 
     @Column()
     expireAt: Date
 
-    constructor(accessToken: string, expireAt: Date) {
-        this.accessToken = accessToken
+    constructor(json: string, expireAt: Date) {
+        this.json = json
         this.expireAt = expireAt
     }
 }

+ 3 - 3
src/weixin/weixin.module.ts

@@ -4,11 +4,11 @@ import { WeixinService } from './weixin.service'
 import weixinConfig from './weixin.config'
 import { ConfigModule } from '@nestjs/config'
 import { TypeOrmModule } from '@nestjs/typeorm'
-import { AccessToken } from './entities/accessToken.entity'
-import { JsapiTicket } from './entities/jsapiTicket.entity'
+import { AccessTokenCache } from './entities/access-token-cache.entity'
+import { JsapiTicketCache } from './entities/jsapi-ticket-cache.entity'
 
 @Module({
-    imports: [ConfigModule.forFeature(weixinConfig), TypeOrmModule.forFeature([AccessToken, JsapiTicket])],
+    imports: [ConfigModule.forFeature(weixinConfig), TypeOrmModule.forFeature([AccessTokenCache, JsapiTicketCache])],
     controllers: [WeixinController],
     providers: [WeixinService]
 })

+ 2 - 2
src/weixin/weixin.service.spec.ts

@@ -5,14 +5,14 @@ import { AppModule } from '../app.module'
 import { ConfigModule } from '@nestjs/config'
 import { TypeOrmModule } from '@nestjs/typeorm'
 import weixinConfig from './weixin.config'
-import { AccessToken } from './entities/accessToken.entity'
+import { AccessTokenCache } from './entities/access-token-cache.entity'
 
 describe('WeixinService', () => {
     let weixinService: WeixinService
 
     beforeEach(async () => {
         const moduleRef = await Test.createTestingModule({
-            imports: [AppModule, ConfigModule.forFeature(weixinConfig), TypeOrmModule.forFeature([AccessToken])],
+            imports: [AppModule, ConfigModule.forFeature(weixinConfig), TypeOrmModule.forFeature([AccessTokenCache])],
             controllers: [],
             providers: [WeixinService]
         }).compile()

+ 43 - 47
src/weixin/weixin.service.ts

@@ -12,79 +12,75 @@ import {
     WX_API_TYPE,
     Kits,
     JsTicketApi,
-    JsApiType
+    JsApiType,
+    AccessToken,
+    JsTicket
 } from 'tnwx'
 import { InjectRepository } from '@nestjs/typeorm'
-import { AccessToken } from './entities/accessToken.entity'
+import { AccessTokenCache } from './entities/access-token-cache.entity'
 import { LessThan, Not, Repository } from 'typeorm'
 import { addSeconds } from 'date-fns'
 import * as fs from 'node:fs'
-import { JsapiTicket } from './entities/jsapiTicket.entity'
+import { JsapiTicketCache } from './entities/jsapi-ticket-cache.entity'
 
 @Injectable()
 export class WeixinService {
     private privateKey: Buffer
     private publicKey: Buffer
+    private platformPlublicKey: Buffer
     constructor(
         @Inject(weixinConfig.KEY)
         private readonly weixinConfiguration: ConfigType<typeof weixinConfig>,
-        @InjectRepository(AccessToken)
-        private readonly accessTokenRepository: Repository<AccessToken>,
-        @InjectRepository(JsapiTicket)
-        private readonly jsapiTicketRepository: Repository<JsapiTicket>
+        @InjectRepository(AccessTokenCache)
+        private readonly accessTokenRepository: Repository<AccessTokenCache>,
+        @InjectRepository(JsapiTicketCache)
+        private readonly jsapiTicketRepository: Repository<JsapiTicketCache>
     ) {
         let apiConfig = new ApiConfig(weixinConfiguration.appId, weixinConfiguration.appSecret, '')
         ApiConfigKit.putApiConfig(apiConfig)
-        // 开启开发模式,方便调试
         ApiConfigKit.devMode = true
-        // 设置当前应用
         ApiConfigKit.setCurrentAppId(apiConfig.getAppId)
         this.privateKey = fs.readFileSync(this.weixinConfiguration.certPath + 'apiclient_key.pem')
         this.publicKey = fs.readFileSync(this.weixinConfiguration.certPath + 'apiclient_cert.pem')
+        this.platformPlublicKey = fs.readFileSync(this.weixinConfiguration.certPath + 'platform_cert.pem')
     }
 
-    async getAccessToken() {
+    async getAccessToken(): Promise<AccessToken> {
         let accessToken = await this.accessTokenRepository.findOneBy({
             expireAt: LessThan(new Date())
         })
-        if (accessToken) {
-            if (accessToken.expireAt.getTime() - new Date().getTime() < 600 * 1000) {
-                this.refreshAccessToken()
-            }
-            return accessToken.accessToken
+        if (!accessToken || new Date() > accessToken.expireAt) {
+            return await this.refreshAccessToken()
         }
-        return await this.refreshAccessToken()
+        return new AccessToken(accessToken.json)
     }
 
     async getJsapiTicket() {
         let jsapiTicket = await this.jsapiTicketRepository.findOneBy({
             expireAt: LessThan(new Date())
         })
-        if (jsapiTicket) {
-            if (jsapiTicket.expireAt.getTime() - new Date().getTime() < 600 * 1000) {
-                this.refreshTicket()
-            }
-            return jsapiTicket.ticket
+        if (!jsapiTicket || new Date() > jsapiTicket.expireAt) {
+            return await this.refreshTicket()
         }
-        return await this.refreshTicket()
+        return new JsTicket(jsapiTicket.json)
     }
 
-    async refreshAccessToken() {
-        const res = await AccessTokenApi.getAccessToken()
+    async refreshAccessToken(): Promise<AccessToken> {
+        const res: AccessToken = await AccessTokenApi.getAccessToken()
         const newToken = await this.accessTokenRepository.save(
-            new AccessToken(res.getAccessToken, addSeconds(new Date(), res.getExpiresIn - 300))
+            new AccessTokenCache(res.getJson, addSeconds(new Date(), res.getExpiresIn - 300))
         )
         await this.jsapiTicketRepository.delete({ id: Not(newToken.id) })
-        return newToken.accessToken
+        return res
     }
 
     async refreshTicket() {
-        const res = await JsTicketApi.getTicket(JsApiType.JSAPI)
+        const res: JsTicket = await JsTicketApi.getTicket(JsApiType.JSAPI, await this.getAccessToken())
         const newTicket = await this.jsapiTicketRepository.save(
-            new JsapiTicket(res.getTicket, addSeconds(new Date(), res.getExpiresIn - 300))
+            new JsapiTicketCache(res.getJson, addSeconds(new Date(), res.getExpiresIn - 300))
         )
         await this.jsapiTicketRepository.delete({ id: Not(newTicket.id) })
-        return newTicket.ticket
+        return res
     }
 
     getRedirectUrl() {
@@ -162,33 +158,31 @@ export class WeixinService {
                 this.weixinConfiguration.certSerial,
                 this.privateKey
             )
-            Logger.log(`result.data:${result.data}`)
-
-            // 应答报文主体
+            Logger.log(JSON.stringify(result.data, null, 2), '获取微信证书')
             let data = JSON.stringify(result.data)
-            // 应答状态码
-            Logger.log(`status:${result.status}`)
-            Logger.log(`data:${data}`)
-            // http 请求头
             let headers = result.headers
-            // 证书序列号
             let serial = headers['wechatpay-serial']
-            // 应答时间戳
             let timestamp = headers['wechatpay-timestamp']
-            // 应答随机串
             let nonce = headers['wechatpay-nonce']
-            // 应答签名
             let signature = headers['wechatpay-signature']
 
-            Logger.log(`serial:\n${serial}`)
-            Logger.log(`timestamp:\n${timestamp}`)
-            Logger.log(`nonce:\n${nonce}`)
-            Logger.log(`signature:\n${signature}`)
-
             // 根据序列号查证书  验证签名
             // let verifySignature: boolean = PayKit.verifySignature(signature, data, nonce, timestamp, wxPublicKey)
-            let verifySignature: boolean = PayKit.verifySign(headers, data, this.publicKey)
-            Logger.log(`verifySignature:${verifySignature}`)
+            let verifySignature: boolean = PayKit.verifySign(headers, data, this.platformPlublicKey)
+            Logger.log(verifySignature, '验证签名')
+
+            let certPath = this.weixinConfiguration.certPath + 'platform_cert.pem'
+            result.data.data.sort((a, b) => {
+                return a.effective_time > b.effective_time ? -1 : 1
+            })
+            let decrypt = PayKit.aes256gcmDecrypt(
+                this.weixinConfiguration.mchKey,
+                result.data.data[0].encrypt_certificate.nonce,
+                result.data.data[0].encrypt_certificate.associated_data,
+                result.data.data[0].encrypt_certificate.ciphertext
+            )
+            // 保存证书
+            fs.writeFileSync(certPath, decrypt)
 
             return data
         } catch (error) {
@@ -209,4 +203,6 @@ export class WeixinService {
             signature
         }
     }
+
+    async notify(data: any) {}
 }