kauth-sdk-node 0.1.24

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +280 -0
  2. package/README.md +58 -0
  3. package/dist/authenticator/authenticator.d.ts +29 -0
  4. package/dist/authenticator/authenticator.js +90 -0
  5. package/dist/authenticator/base.d.ts +16 -0
  6. package/dist/authenticator/base.js +6 -0
  7. package/dist/authenticator/google.d.ts +21 -0
  8. package/dist/authenticator/google.js +12 -0
  9. package/dist/authenticator/index.d.ts +3 -0
  10. package/dist/authenticator/index.js +11 -0
  11. package/dist/authenticator/manager.d.ts +38 -0
  12. package/dist/authenticator/manager.js +165 -0
  13. package/dist/authenticator/miniprogram.d.ts +15 -0
  14. package/dist/authenticator/miniprogram.js +12 -0
  15. package/dist/authenticator/mozi.d.ts +21 -0
  16. package/dist/authenticator/mozi.js +12 -0
  17. package/dist/authenticator/provider.d.ts +28 -0
  18. package/dist/authenticator/provider.js +76 -0
  19. package/dist/authorizer/index.d.ts +1 -0
  20. package/dist/authorizer/index.js +4 -0
  21. package/dist/authorizer/permission.d.ts +9 -0
  22. package/dist/authorizer/permission.js +53 -0
  23. package/dist/common/config/config.d.ts +37 -0
  24. package/dist/common/config/config.js +2 -0
  25. package/dist/common/constant/http.d.ts +42 -0
  26. package/dist/common/constant/http.js +47 -0
  27. package/dist/common/http/kauth.d.ts +50 -0
  28. package/dist/common/http/kauth.js +177 -0
  29. package/dist/common/http/kflow.d.ts +12 -0
  30. package/dist/common/http/kflow.js +36 -0
  31. package/dist/common/http/request/kauth.d.ts +89 -0
  32. package/dist/common/http/request/kauth.js +2 -0
  33. package/dist/common/http/request/kflow.d.ts +16 -0
  34. package/dist/common/http/request/kflow.js +2 -0
  35. package/dist/common/http/response/kauth.d.ts +86 -0
  36. package/dist/common/http/response/kauth.js +8 -0
  37. package/dist/common/http/response/kflow.d.ts +33 -0
  38. package/dist/common/http/response/kflow.js +2 -0
  39. package/dist/common/http/tool/marmot.d.ts +48 -0
  40. package/dist/common/http/tool/marmot.js +97 -0
  41. package/dist/common/util/converter/permission.d.ts +12 -0
  42. package/dist/common/util/converter/permission.js +36 -0
  43. package/dist/index.d.ts +9 -0
  44. package/dist/index.js +29 -0
  45. package/package.json +84 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,280 @@
1
+ ## [0.1.24](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/compare/v0.1.23...v0.1.24) (2021-09-28)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * bugs ([48e5bd2](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/48e5bd28f20236679be58dac3e38aaeefa2ab2ae))
7
+
8
+
9
+ ### Features
10
+
11
+ * add procinst user ([1338f92](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/1338f92d8384af4ce152c3150d731ae38c65f2e4))
12
+
13
+
14
+
15
+ ## [0.1.23](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/compare/v0.1.22...v0.1.23) (2021-07-14)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * create role bugs ([817b2d9](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/817b2d98663c51101601a5c8007bb97f592014dc))
21
+
22
+
23
+
24
+ ## [0.1.22](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/compare/v0.1.21...v0.1.22) (2021-07-13)
25
+
26
+
27
+ ### Bug Fixes
28
+
29
+ * bugs ([92eee5d](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/92eee5d3b8d6fcf3d1ddf6d27333c585ecd31ce7))
30
+ * role api ([f1c160c](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/f1c160cb858363fd4a1c6e308ece8ef48cab0b47))
31
+
32
+
33
+
34
+ ## [0.1.21](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/compare/v0.1.20...v0.1.21) (2021-07-08)
35
+
36
+
37
+ ### Bug Fixes
38
+
39
+ * kflow api bugs ([0456be6](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/0456be63def42398ff918763cfc2e9a691ae5a89))
40
+
41
+
42
+
43
+ ## [0.1.20](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/compare/v0.1.19...v0.1.20) (2021-06-21)
44
+
45
+
46
+ ### Bug Fixes
47
+
48
+ * add owners ([24a0ccf](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/24a0ccfde9b3edbb5d1c6cd71e6e249091a481ea))
49
+ * change coverage ([4528962](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/452896206546823c73985c9e47068ac0ba55c765))
50
+
51
+
52
+ ### Features
53
+
54
+ * add role uri ([3507999](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/3507999d777d3324883b45cc89c1ec5ab46bb30b))
55
+
56
+
57
+
58
+ ## [0.1.19](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/compare/v0.1.18...v0.1.19) (2021-06-10)
59
+
60
+
61
+ ### Bug Fixes
62
+
63
+ * add updateRolesWithPermissions ([eb0fd33](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/eb0fd33df5e42edfdbc9086c2c147a0a17cd0ff9))
64
+
65
+
66
+
67
+ ## [0.1.18](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/compare/v0.1.17...v0.1.18) (2021-03-12)
68
+
69
+
70
+ ### Features
71
+
72
+ * bind user with status ([993cf4d](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/993cf4d23cdf8e23b424bb6aa397f8d218de6ad6))
73
+
74
+
75
+
76
+ ## [0.1.17](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/compare/v0.1.16...v0.1.17) (2021-03-01)
77
+
78
+
79
+ ### Features
80
+
81
+ * jwt refresh ([61aa920](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/61aa920bb0614b3c9e6b21e47a0bb04853ab8d50))
82
+
83
+
84
+
85
+ ## [0.1.16](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/compare/v0.1.15...v0.1.16) (2021-02-09)
86
+
87
+
88
+ ### Bug Fixes
89
+
90
+ * export PrimaryPrincipal interface ([f2bdb23](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/f2bdb23a2afb3adc3a17edb3b80908ec209cd756))
91
+
92
+
93
+
94
+ ## [0.1.15](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/compare/v0.1.14...v0.1.15) (2021-02-04)
95
+
96
+
97
+ ### Features
98
+
99
+ * add listUsersWithUserAccountsAndRolesByRoleExtendValue and unauthorizedRedirectIgnore ([5086c1a](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/5086c1a0b2976869a1a504eee0984117d33499cb))
100
+
101
+
102
+
103
+ ## [0.1.14](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/compare/v0.1.13...v0.1.14) (2021-01-29)
104
+
105
+
106
+ ### Bug Fixes
107
+
108
+ * types ([1061e6e](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/1061e6eeb99d0f3d3d42390347f8a791eed7550e))
109
+
110
+
111
+
112
+ ## [0.1.13](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/compare/v0.1.12...v0.1.13) (2021-01-22)
113
+
114
+
115
+ ### Bug Fixes
116
+
117
+ * add cache ([14a0d20](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/14a0d206b8056bc249f923904f00a51681f91363))
118
+
119
+
120
+
121
+ ## [0.1.12](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/compare/v0.1.11...v0.1.12) (2021-01-21)
122
+
123
+
124
+ ### Features
125
+
126
+ * permission inject ([561d737](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/561d737ae73fbe03f45812998a406c92625bf9f7))
127
+
128
+
129
+
130
+ ## [0.1.11](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/compare/v0.1.10...v0.1.11) (2021-01-21)
131
+
132
+
133
+ ### Features
134
+
135
+ * createRolesByUsersAndPermissions, listRolesByExtendValue and bindUserByRolesAndExtendValue ([3f0b90f](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/3f0b90f20a1a67d74c5ecab69030ac530eabf51e))
136
+
137
+
138
+
139
+ ## [0.1.10](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/compare/v0.1.9...v0.1.10) (2021-01-14)
140
+
141
+
142
+ ### Features
143
+
144
+ * mock handler ([8c8f4c6](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/8c8f4c6000ebfe7df3916e689c9bb26a69927715))
145
+
146
+
147
+
148
+ ## [0.1.9](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/compare/v0.1.8...v0.1.9) (2021-01-08)
149
+
150
+
151
+ ### Bug Fixes
152
+
153
+ * promisify loginHandler and authHandler ([d758895](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/d758895e946c5cf7e4358d166a5bf4b81125d237))
154
+
155
+
156
+
157
+ ## [0.1.8](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/compare/v0.1.7...v0.1.8) (2021-01-08)
158
+
159
+
160
+
161
+ ## [0.1.7](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/compare/v0.1.6...v0.1.7) (2020-12-29)
162
+
163
+
164
+ ### Bug Fixes
165
+
166
+ * replace config.origin by ctx.request.origin ([7ad507d](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/7ad507de86d7ffe77fc610e6d328ec0a3e82abb6))
167
+
168
+
169
+
170
+ ## [0.1.6](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/compare/v0.1.5...v0.1.6) (2020-12-24)
171
+
172
+
173
+ ### Features
174
+
175
+ * members and connections ([f5a1f65](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/f5a1f65a0cb819f29818bb300f5f983ec365c1e4))
176
+
177
+
178
+
179
+ ## [0.1.5](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/compare/v0.1.4...v0.1.5) (2020-10-29)
180
+
181
+
182
+ ### Bug Fixes
183
+
184
+ * prompt config ([2cd40a8](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/2cd40a8b96bc3c8b4adda0ece4df295e9eb1ac5f))
185
+
186
+
187
+
188
+ ## [0.1.4](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/compare/v0.1.3...v0.1.4) (2020-10-29)
189
+
190
+
191
+ ### Bug Fixes
192
+
193
+ * add prompt ([c9316c8](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/c9316c82c87451a05476924eb24ea6f91c5a2fa9))
194
+
195
+
196
+
197
+ ## [0.1.3](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/compare/v0.1.2...v0.1.3) (2020-10-29)
198
+
199
+
200
+ ### Bug Fixes
201
+
202
+ * authenticationInformationHandler params ([6188960](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/61889603dbf4f5f177ff6ca545afaaab155bda4a))
203
+
204
+
205
+
206
+ ## [0.1.2](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/compare/v0.1.1...v0.1.2) (2020-10-29)
207
+
208
+
209
+ ### Features
210
+
211
+ * logout uri and authenticationInformationHandler ([5b972a7](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/5b972a7dad84dd0c93a5b3e6f32f4d396c85035c))
212
+
213
+
214
+
215
+ ## [0.1.1](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/compare/v0.1.0...v0.1.1) (2020-09-27)
216
+
217
+
218
+ ### Features
219
+
220
+ * rbac and connect ([0f75aac](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/0f75aaca8b5f2418d677e6e2583f105b42b970b2))
221
+ * reviewer robot ([c379ef4](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/c379ef44b8fa2c21e3739d9eca88339ae4a4254b))
222
+
223
+
224
+
225
+ # [0.1.0](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/compare/v0.0.16...v0.1.0) (2020-09-07)
226
+
227
+
228
+ ### Features
229
+
230
+ * add watch ([7f3bee3](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/7f3bee325d1dcc3e342efff059a77fe5c01db665))
231
+ * support miniprogram login ([21452fe](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/21452fe600db1910ee7082fbef7bd7fea3fc992c))
232
+ * update git repo ([a043b92](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/a043b92c10f9c37463dd15133659a0652cefe83f))
233
+
234
+
235
+
236
+ ## [0.0.17](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/compare/v0.0.16...v0.0.17) (2020-08-27)
237
+
238
+
239
+ ### Features
240
+
241
+ * add watch ([7f3bee3](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/7f3bee325d1dcc3e342efff059a77fe5c01db665))
242
+ * update git repo ([a043b92](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/a043b92c10f9c37463dd15133659a0652cefe83f))
243
+
244
+
245
+
246
+ ## 0.0.16 (2020-08-26)
247
+
248
+ ### Bug Fixes
249
+
250
+ - add avatar ([3afa26f](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/3afa26f669ede87f5e40a39da0e9f45160742cd7))
251
+ - add enum and remove public ([de81327](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/de8132788aca556500f2afd2b30b2496a709f3d9))
252
+ - add npm version and publish hook ([ee798ba](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/ee798baedc8b6f6c41d5630b199f3f366aabfe46))
253
+ - bugs ([232f413](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/232f4137c4d8da15e575615b13b1244f77dcbfe6))
254
+ - bugs ([f2d2024](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/f2d2024d93759208f02d820d190003a680597372))
255
+ - bugs ([ebb8852](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/ebb88528931334236120275074790a7a3e3a8a1c))
256
+ - bugs ([06d4049](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/06d4049aa6754e3557e3593297f1fa8743497a91))
257
+ - convert babel env to node 12 ([4b16fed](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/4b16fed53b2df50978f030432dacbae603ff7fa6))
258
+ - export mozi auth info and google auth info, fix readme.md ([30392f6](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/30392f6854852651271691a7870c6ee878720290))
259
+ - export mozi principal and google principal ([991295f](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/991295fb5fea6d30742fd14d070d21f013ab74c4))
260
+ - kflow api indexed ([06cbcbe](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/06cbcbecc0fab5aeccd80d39f698e3670ab15f99))
261
+ - marmot utils axios params nullable ([d870314](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/d8703147cfc3d715366ab3d2663e4b21af23c6fe))
262
+ - move gulp to tsc ([5618ba7](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/5618ba74fbc7d199846b00f6d599a6efae2787ba))
263
+ - mv build to dist ([071c03a](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/071c03ac7c699474a5c957ed4d4cf83ec7ca7d38))
264
+ - nyc coverage ([32c7bc0](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/32c7bc01017f9ad79a3309aa3f03262b839d62b3))
265
+
266
+ ### Features
267
+
268
+ - add marmot api ([e084578](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/e08457805c59e6e3266cacb1502745ef22ca6bf8))
269
+ - add OWNERS ([390881d](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/390881d17ef8e7fef95785a56cd25fe6e21b4edd))
270
+ - build ([1da5d6d](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/1da5d6d18b07d761bf3306c71388a0a3e223f47b))
271
+ - egg middleware ([30278b1](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/30278b16efef8ab4b1c43787994f9ddca6daf8c6))
272
+ - initialized ([41fe73d](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/41fe73def8662563e2f7ae29580056e6944c5ab1))
273
+ - kflow api support ([bd53d2e](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/bd53d2e954e62afa2f9a2211d4c3c9266093fedd))
274
+ - permissions and watch ([d0cd323](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/d0cd323b1e547783db193dc699d8f8ae84114fb5))
275
+ - remove egg middleware ([4266f37](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/4266f37309bc02bf7ffe69f472feb45203532bda))
276
+ - v0.0.11 ([e0887c6](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/e0887c6a55ab68a85b97a2ac562073fd88e7921a))
277
+ - v0.0.12 ([47c6d5d](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/47c6d5de3c04d47aa8e4d1d23bd95323d064c826))
278
+ - v0.0.13 ([48518e4](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/48518e42814f11cd73d4199f59aa4069844685c1))
279
+ - v0.0.9 ([2f1f32b](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/2f1f32bb7cf508d97ae597a20777b2925a44f653))
280
+ - version ([2babee1](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/2babee12614cf682e46a442188463ddbd7d8265e))
package/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # kauth-sdk-node
2
+
3
+ Kauth-sdk-node, as base stone of series of concrete SDK for egg or any other nodejs web framework.
4
+
5
+ It provides authentications like BUC authentication, alipay miniprogram authentication, and some other authentication abilities.
6
+
7
+ ## kauthApi
8
+
9
+ You can use it to request kauth
10
+
11
+ ```js
12
+ import { KauthApi } from 'kauth-sdk-node';
13
+ ```
14
+
15
+ ## KflowApi
16
+
17
+ You can use it to request kflow
18
+
19
+ ```js
20
+ import { KflowApi } from 'kauth-sdk-node';
21
+ ```
22
+
23
+ ## GoogleAuthenticator
24
+
25
+ You can use it to authenticate user info by Google oauth2
26
+
27
+ ```js
28
+ import { GoogleAuthenticator } from 'kauth-sdk-node';
29
+ ```
30
+
31
+ ## MoziAUthenticator
32
+
33
+ You can use it to authenticate user info by Mozi oauth2
34
+
35
+ ```js
36
+ import { MoziAuthenticator } from 'kauth-sdk-node';
37
+ ```
38
+
39
+ ## JsonWebTokenAuthenticationProvider
40
+
41
+ You can use it to verify jwt or create a jwt by authentication information
42
+
43
+ ```js
44
+ import { JsonWebTokenAuthenticationProvider } from 'kauth-sdk-node';
45
+ ```
46
+
47
+ ## Publish
48
+
49
+ ```bash
50
+ # 1. update version
51
+ $ npm version minor
52
+
53
+ > Or you can update version by patch
54
+ $ npm version patch
55
+
56
+ # 2. build and publish
57
+ $ npm publish
58
+ ```
@@ -0,0 +1,29 @@
1
+ import { KauthApi } from '../common/http/kauth';
2
+ import { AuthenticationInformation } from './base';
3
+ interface Authenticator {
4
+ authorizeURL(callback: string, state: string, prompt?: string): Promise<string>;
5
+ authenticate(token: string, redirectUri: string): Promise<AuthenticationInformation>;
6
+ bind(userId: number, token: string, redirectUri: string): Promise<void>;
7
+ }
8
+ export declare class GoogleAuthenticator implements Authenticator {
9
+ private kauthApi;
10
+ constructor(kauthApi: KauthApi);
11
+ authenticate(token: string, redirectUri: string): Promise<AuthenticationInformation>;
12
+ bind(userId: number, token: string, redirectUri: string): Promise<void>;
13
+ authorizeURL(callback: string, state: string, prompt?: string): Promise<string>;
14
+ }
15
+ export declare class MoziAuthenticator implements Authenticator {
16
+ private kauthApi;
17
+ constructor(kauthApi: KauthApi);
18
+ authenticate(token: string, redirectUri: string): Promise<AuthenticationInformation>;
19
+ bind(userId: number, token: string, redirectUri: string): Promise<void>;
20
+ authorizeURL(callback: string, state: string, prompt?: string): Promise<string>;
21
+ }
22
+ export declare class MiniprogramAuthenticator implements Authenticator {
23
+ private kauthApi;
24
+ constructor(kauthApi: KauthApi);
25
+ authenticate(token: string, redirectUri: string): Promise<AuthenticationInformation>;
26
+ bind(userId: number, token: string, redirectUri: string): Promise<void>;
27
+ authorizeURL(callback: string, state: string, prompt?: string): Promise<string>;
28
+ }
29
+ export {};
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MiniprogramAuthenticator = exports.MoziAuthenticator = exports.GoogleAuthenticator = void 0;
4
+ const mozi_1 = require("./mozi");
5
+ const google_1 = require("./google");
6
+ const miniprogram_1 = require("./miniprogram");
7
+ class GoogleAuthenticator {
8
+ constructor(kauthApi) {
9
+ this.kauthApi = kauthApi;
10
+ }
11
+ async authenticate(token, redirectUri) {
12
+ const request = {
13
+ code: token,
14
+ redirect_uri: redirectUri,
15
+ };
16
+ const result = await this.kauthApi.googleAuthenticate(request);
17
+ const authenticationInformation = new google_1.GoogleAuthenticationInformation();
18
+ authenticationInformation.primaryPrincipal = result.primaryPrincipal;
19
+ authenticationInformation.principal = result.principal;
20
+ authenticationInformation.credential = result.credential;
21
+ return authenticationInformation;
22
+ }
23
+ async bind(userId, token, redirectUri) {
24
+ return this.kauthApi.googleBind({
25
+ user_id: userId,
26
+ code: token,
27
+ redirect_uri: redirectUri,
28
+ });
29
+ }
30
+ authorizeURL(callback, state, prompt = '') {
31
+ return this.kauthApi.googleAuthorizeURL(callback, state, prompt);
32
+ }
33
+ }
34
+ exports.GoogleAuthenticator = GoogleAuthenticator;
35
+ class MoziAuthenticator {
36
+ constructor(kauthApi) {
37
+ this.kauthApi = kauthApi;
38
+ }
39
+ async authenticate(token, redirectUri) {
40
+ const request = {
41
+ code: token,
42
+ redirect_uri: redirectUri,
43
+ };
44
+ const result = await this.kauthApi.moziAuthenticate(request);
45
+ const authenticationInformation = new mozi_1.MoziAuthenticationInformation();
46
+ authenticationInformation.primaryPrincipal = result.primaryPrincipal;
47
+ authenticationInformation.principal = result.principal;
48
+ authenticationInformation.credential = result.credential;
49
+ return authenticationInformation;
50
+ }
51
+ async bind(userId, token, redirectUri) {
52
+ return this.kauthApi.moziBind({
53
+ user_id: userId,
54
+ code: token,
55
+ redirect_uri: redirectUri,
56
+ });
57
+ }
58
+ authorizeURL(callback, state, prompt = '') {
59
+ return this.kauthApi.moziAuthorizeURL(callback, state, prompt);
60
+ }
61
+ }
62
+ exports.MoziAuthenticator = MoziAuthenticator;
63
+ class MiniprogramAuthenticator {
64
+ constructor(kauthApi) {
65
+ this.kauthApi = kauthApi;
66
+ }
67
+ async authenticate(token, redirectUri) {
68
+ const request = {
69
+ code: token,
70
+ redirect_uri: redirectUri,
71
+ };
72
+ const result = await this.kauthApi.miniprogramAuthenticate(request);
73
+ const authenticationInformation = new miniprogram_1.MiniprogramAuthenticationInformation();
74
+ authenticationInformation.primaryPrincipal = result.primaryPrincipal;
75
+ authenticationInformation.principal = result.principal;
76
+ authenticationInformation.credential = result.credential;
77
+ return authenticationInformation;
78
+ }
79
+ async bind(userId, token, redirectUri) {
80
+ return this.kauthApi.miniprogramBind({
81
+ user_id: userId,
82
+ code: token,
83
+ redirect_uri: redirectUri,
84
+ });
85
+ }
86
+ authorizeURL(callback, state, prompt = '') {
87
+ return this.kauthApi.miniprogramAuthorizeURL(callback, state, prompt);
88
+ }
89
+ }
90
+ exports.MiniprogramAuthenticator = MiniprogramAuthenticator;
@@ -0,0 +1,16 @@
1
+ export interface Principal {
2
+ }
3
+ export interface Credential {
4
+ }
5
+ export interface AuthenticationInformation {
6
+ primaryPrincipal: PrimaryPrincipal;
7
+ principal: Principal;
8
+ credential: Credential;
9
+ }
10
+ export declare class PrimaryPrincipal implements Principal {
11
+ id: number;
12
+ name: string;
13
+ email: string;
14
+ avatar: string;
15
+ status: number;
16
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PrimaryPrincipal = void 0;
4
+ class PrimaryPrincipal {
5
+ }
6
+ exports.PrimaryPrincipal = PrimaryPrincipal;
@@ -0,0 +1,21 @@
1
+ import { Principal, PrimaryPrincipal, Credential, AuthenticationInformation } from './base';
2
+ export declare class GooglePrincipal implements Principal {
3
+ sub: string;
4
+ name: string;
5
+ givenName: string;
6
+ familyName: string;
7
+ picture: string;
8
+ email: string;
9
+ emailVerified: boolean;
10
+ locale: string;
11
+ }
12
+ export declare class GoogleCredential implements Credential {
13
+ accessToken: string;
14
+ expiresIn: number;
15
+ refreshToken: string;
16
+ }
17
+ export declare class GoogleAuthenticationInformation implements AuthenticationInformation {
18
+ primaryPrincipal: PrimaryPrincipal;
19
+ principal: GooglePrincipal;
20
+ credential: GoogleCredential;
21
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GoogleAuthenticationInformation = exports.GoogleCredential = exports.GooglePrincipal = void 0;
4
+ class GooglePrincipal {
5
+ }
6
+ exports.GooglePrincipal = GooglePrincipal;
7
+ class GoogleCredential {
8
+ }
9
+ exports.GoogleCredential = GoogleCredential;
10
+ class GoogleAuthenticationInformation {
11
+ }
12
+ exports.GoogleAuthenticationInformation = GoogleAuthenticationInformation;
@@ -0,0 +1,3 @@
1
+ export { GoogleAuthenticator, MoziAuthenticator, MiniprogramAuthenticator } from './authenticator';
2
+ export { AuthenticationInformation, PrimaryPrincipal } from './base';
3
+ export { JsonWebTokenSubjectProvider, JsonWebTokenAuthenticationProvider } from './provider';
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var authenticator_1 = require("./authenticator");
4
+ Object.defineProperty(exports, "GoogleAuthenticator", { enumerable: true, get: function () { return authenticator_1.GoogleAuthenticator; } });
5
+ Object.defineProperty(exports, "MoziAuthenticator", { enumerable: true, get: function () { return authenticator_1.MoziAuthenticator; } });
6
+ Object.defineProperty(exports, "MiniprogramAuthenticator", { enumerable: true, get: function () { return authenticator_1.MiniprogramAuthenticator; } });
7
+ var base_1 = require("./base");
8
+ Object.defineProperty(exports, "PrimaryPrincipal", { enumerable: true, get: function () { return base_1.PrimaryPrincipal; } });
9
+ var provider_1 = require("./provider");
10
+ Object.defineProperty(exports, "JsonWebTokenSubjectProvider", { enumerable: true, get: function () { return provider_1.JsonWebTokenSubjectProvider; } });
11
+ Object.defineProperty(exports, "JsonWebTokenAuthenticationProvider", { enumerable: true, get: function () { return provider_1.JsonWebTokenAuthenticationProvider; } });
@@ -0,0 +1,38 @@
1
+ import { AuthenticationInformation } from './base';
2
+ import { GoogleAuthenticationInformation } from './google';
3
+ import { MoziAuthenticationInformation } from './mozi';
4
+ import { KauthApi } from '../common/http/kauth';
5
+ import { MiniprogramAuthenticationInformation } from './miniprogram';
6
+ export interface Claims {
7
+ [key: string]: any;
8
+ }
9
+ export interface AuthenticationInfoManger {
10
+ append(information: AuthenticationInformation, claims: Claims): boolean;
11
+ transform(claims: Claims): Promise<AuthenticationInformation>;
12
+ }
13
+ export declare class DelegatedAuthenticationInfoManager implements AuthenticationInfoManger {
14
+ private googleAuthenticationInfoManager;
15
+ private moziAuthenticationInfoManager;
16
+ private miniprogramAuthenticationInfoManager;
17
+ constructor(kauthApi: KauthApi);
18
+ append(information: AuthenticationInformation, claims: Claims): boolean;
19
+ transform(claims: Claims): Promise<AuthenticationInformation>;
20
+ }
21
+ export declare class GoogleAuthenticationInfoManger implements AuthenticationInfoManger {
22
+ private kauthApi;
23
+ constructor(kauthApi: KauthApi);
24
+ append(information: AuthenticationInformation, claims: Claims): boolean;
25
+ transform(claims: Claims): Promise<GoogleAuthenticationInformation>;
26
+ }
27
+ export declare class MoziAuthenticationInfoManager implements AuthenticationInfoManger {
28
+ private kauthApi;
29
+ constructor(kauthApi: KauthApi);
30
+ append(information: AuthenticationInformation, claims: Claims): boolean;
31
+ transform(claims: Claims): Promise<MoziAuthenticationInformation>;
32
+ }
33
+ export declare class MiniprogramAuthenticationInfoManager implements AuthenticationInfoManger {
34
+ private kauthApi;
35
+ constructor(kauthApi: KauthApi);
36
+ append(information: AuthenticationInformation, claims: Claims): boolean;
37
+ transform(claims: Claims): Promise<MiniprogramAuthenticationInformation>;
38
+ }