@hw-agconnect/cloud-server 1.0.1

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 (211) hide show
  1. package/README.md +258 -0
  2. package/auth-service/agconnect-auth.json +7 -0
  3. package/auth-service/auth.d.ts +48 -0
  4. package/auth-service/auth.js +1 -0
  5. package/auth-service/backend/auth-backend.d.ts +11 -0
  6. package/auth-service/backend/auth-backend.js +1 -0
  7. package/auth-service/entity/auth-access-token-impl.d.ts +67 -0
  8. package/auth-service/entity/auth-access-token-impl.js +1 -0
  9. package/auth-service/entity/auth-access-token.d.ts +54 -0
  10. package/auth-service/entity/auth-access-token.js +1 -0
  11. package/auth-service/entity/provider.d.ts +17 -0
  12. package/auth-service/entity/provider.js +1 -0
  13. package/auth-service/entity/token-provider-info.d.ts +18 -0
  14. package/auth-service/entity/token-provider-info.js +1 -0
  15. package/auth-service/entity/user-import-export-result.d.ts +33 -0
  16. package/auth-service/entity/user-import-export-result.js +1 -0
  17. package/auth-service/error/agc-auth-error-message.d.ts +39 -0
  18. package/auth-service/error/agc-auth-error-message.js +1 -0
  19. package/auth-service/error/agc-auth-error.d.ts +7 -0
  20. package/auth-service/error/agc-auth-error.js +1 -0
  21. package/auth-service/index.d.ts +13 -0
  22. package/auth-service/index.js +1 -0
  23. package/auth-service/jwt/agc-auth-jwt.d.ts +17 -0
  24. package/auth-service/jwt/agc-auth-jwt.js +1 -0
  25. package/auth-service/jwt/agc-auth-jwttoken.d.ts +10 -0
  26. package/auth-service/jwt/agc-auth-jwttoken.js +1 -0
  27. package/auth-service/jwt/agc-auth-public-keys-manager.d.ts +4 -0
  28. package/auth-service/jwt/agc-auth-public-keys-manager.js +1 -0
  29. package/auth-service/jwt/agc-auth-rsa-verifier.d.ts +6 -0
  30. package/auth-service/jwt/agc-auth-rsa-verifier.js +1 -0
  31. package/auth-service/jwt/rsa-key-pair.d.ts +15 -0
  32. package/auth-service/jwt/rsa-key-pair.js +1 -0
  33. package/auth-service/params/fileParams.d.ts +6 -0
  34. package/auth-service/params/fileParams.js +1 -0
  35. package/auth-service/params/index.d.ts +7 -0
  36. package/auth-service/params/index.js +1 -0
  37. package/auth-service/params/signParams.d.ts +9 -0
  38. package/auth-service/params/signParams.js +1 -0
  39. package/auth-service/params/tokenParams.d.ts +7 -0
  40. package/auth-service/params/tokenParams.js +1 -0
  41. package/auth-service/params/uidParams.d.ts +6 -0
  42. package/auth-service/params/uidParams.js +1 -0
  43. package/auth-service/request/export-user-list-req.d.ts +13 -0
  44. package/auth-service/request/export-user-list-req.js +1 -0
  45. package/auth-service/request/export-user-req.d.ts +13 -0
  46. package/auth-service/request/export-user-req.js +1 -0
  47. package/auth-service/request/import-export-user-info.d.ts +40 -0
  48. package/auth-service/request/import-export-user-info.js +1 -0
  49. package/auth-service/request/import-user-req.d.ts +14 -0
  50. package/auth-service/request/import-user-req.js +1 -0
  51. package/auth-service/request/provider-info.d.ts +20 -0
  52. package/auth-service/request/provider-info.js +1 -0
  53. package/auth-service/request/public-key-req.d.ts +9 -0
  54. package/auth-service/request/public-key-req.js +1 -0
  55. package/auth-service/request/revoke-token-req.d.ts +13 -0
  56. package/auth-service/request/revoke-token-req.js +1 -0
  57. package/auth-service/request/verify-token-req.d.ts +13 -0
  58. package/auth-service/request/verify-token-req.js +1 -0
  59. package/auth-service/response/auth-operate-rsp.d.ts +7 -0
  60. package/auth-service/response/auth-operate-rsp.js +1 -0
  61. package/auth-service/response/export-user-list-rsp.d.ts +13 -0
  62. package/auth-service/response/export-user-list-rsp.js +1 -0
  63. package/auth-service/response/export-user-rsp.d.ts +14 -0
  64. package/auth-service/response/export-user-rsp.js +1 -0
  65. package/auth-service/response/import-success-user.d.ts +11 -0
  66. package/auth-service/response/import-success-user.js +1 -0
  67. package/auth-service/response/import-user-rsp.d.ts +11 -0
  68. package/auth-service/response/import-user-rsp.js +1 -0
  69. package/auth-service/response/publickey-rsp.d.ts +9 -0
  70. package/auth-service/response/publickey-rsp.js +1 -0
  71. package/auth-service/response/token-info.d.ts +11 -0
  72. package/auth-service/response/token-info.js +1 -0
  73. package/auth-service/response/verify-token-rsp.d.ts +14 -0
  74. package/auth-service/response/verify-token-rsp.js +1 -0
  75. package/auth-service/service/agc-auth.d.ts +4 -0
  76. package/auth-service/service/agc-auth.js +1 -0
  77. package/auth-service/service/impl/agc-auth-service-impl.d.ts +46 -0
  78. package/auth-service/service/impl/agc-auth-service-impl.js +1 -0
  79. package/auth-service/service/impl/agc-auth-service.d.ts +54 -0
  80. package/auth-service/service/impl/agc-auth-service.js +1 -0
  81. package/auth-service/utils/auth-service-api-util.d.ts +11 -0
  82. package/auth-service/utils/auth-service-api-util.js +1 -0
  83. package/auth-service/utils/key-header-util.d.ts +19 -0
  84. package/auth-service/utils/key-header-util.js +1 -0
  85. package/cloud.d.ts +24 -0
  86. package/cloud.js +1 -0
  87. package/common-server/agc-client/agc-client.d.ts +41 -0
  88. package/common-server/agc-client/agc-client.js +1 -0
  89. package/common-server/agconnect-common.json +29 -0
  90. package/common-server/config/cloud-gw-url-util.d.ts +7 -0
  91. package/common-server/config/cloud-gw-url-util.js +1 -0
  92. package/common-server/config/configService.d.ts +12 -0
  93. package/common-server/config/configService.js +1 -0
  94. package/common-server/credential-service/access-token.d.ts +11 -0
  95. package/common-server/credential-service/access-token.js +1 -0
  96. package/common-server/credential-service/clientid-credential.d.ts +27 -0
  97. package/common-server/credential-service/clientid-credential.js +1 -0
  98. package/common-server/credential-service/credential-parser.d.ts +23 -0
  99. package/common-server/credential-service/credential-parser.js +1 -0
  100. package/common-server/credential-service/credential-service.d.ts +41 -0
  101. package/common-server/credential-service/credential-service.js +1 -0
  102. package/common-server/credential-service/credential-type.d.ts +7 -0
  103. package/common-server/credential-service/credential-type.js +1 -0
  104. package/common-server/error/error-message.d.ts +30 -0
  105. package/common-server/error/error-message.js +1 -0
  106. package/common-server/error/error.d.ts +36 -0
  107. package/common-server/error/error.js +1 -0
  108. package/common-server/http-client/base-response.d.ts +11 -0
  109. package/common-server/http-client/base-response.js +1 -0
  110. package/common-server/http-client/common-headers.d.ts +37 -0
  111. package/common-server/http-client/common-headers.js +1 -0
  112. package/common-server/http-client/connect-ret.d.ts +12 -0
  113. package/common-server/http-client/connect-ret.js +1 -0
  114. package/common-server/http-client/http-client.d.ts +5 -0
  115. package/common-server/http-client/http-client.js +1 -0
  116. package/common-server/http-client/http-clinet-api.d.ts +66 -0
  117. package/common-server/http-client/http-clinet-api.js +1 -0
  118. package/common-server/http-client/request-constructor.d.ts +8 -0
  119. package/common-server/http-client/request-constructor.js +1 -0
  120. package/common-server/index.d.ts +19 -0
  121. package/common-server/index.js +1 -0
  122. package/common-server/service/agc-service.d.ts +14 -0
  123. package/common-server/service/agc-service.js +1 -0
  124. package/common-server/service/service-factory.d.ts +9 -0
  125. package/common-server/service/service-factory.js +1 -0
  126. package/common-server/utils/utils.d.ts +4 -0
  127. package/common-server/utils/utils.js +1 -0
  128. package/database-service/CloudDB.d.ts +13 -0
  129. package/database-service/CloudDB.js +1 -0
  130. package/database-service/CloudDBCollection.d.ts +108 -0
  131. package/database-service/CloudDBCollection.js +1 -0
  132. package/database-service/agconnect-database.json +4 -0
  133. package/database-service/communicator/https/HttpsCommunicator.d.ts +69 -0
  134. package/database-service/communicator/https/HttpsCommunicator.js +1 -0
  135. package/database-service/communicator/https/RequestHeader.d.ts +13 -0
  136. package/database-service/communicator/https/RequestHeader.js +1 -0
  137. package/database-service/exception/AGConnectCloudDBException.d.ts +10 -0
  138. package/database-service/exception/AGConnectCloudDBException.js +1 -0
  139. package/database-service/exception/CloudDBErrorCode.d.ts +672 -0
  140. package/database-service/exception/CloudDBErrorCode.js +1 -0
  141. package/database-service/exception/ErrorCodeMessage.d.ts +1 -0
  142. package/database-service/exception/ErrorCodeMessage.js +1 -0
  143. package/database-service/index.d.ts +14 -0
  144. package/database-service/index.js +1 -0
  145. package/database-service/model/DatabaseConfig.d.ts +7 -0
  146. package/database-service/model/DatabaseConfig.js +1 -0
  147. package/database-service/model/index.d.ts +4 -0
  148. package/database-service/model/index.js +1 -0
  149. package/database-service/query/CloudDBZoneConfig.d.ts +23 -0
  150. package/database-service/query/CloudDBZoneConfig.js +1 -0
  151. package/database-service/query/CloudDBZoneObjectOperator.d.ts +39 -0
  152. package/database-service/query/CloudDBZoneObjectOperator.js +1 -0
  153. package/database-service/query/CloudDBZoneObjectOperatorConstraint.d.ts +127 -0
  154. package/database-service/query/CloudDBZoneObjectOperatorConstraint.js +1 -0
  155. package/database-service/query/CloudDBZoneQuery.d.ts +188 -0
  156. package/database-service/query/CloudDBZoneQuery.js +1 -0
  157. package/database-service/query/CloudDBZoneSnapshot.d.ts +16 -0
  158. package/database-service/query/CloudDBZoneSnapshot.js +1 -0
  159. package/database-service/request/CloudDBZoneGenericObject.d.ts +58 -0
  160. package/database-service/request/CloudDBZoneGenericObject.js +1 -0
  161. package/database-service/services/AGConnectCloudDB.d.ts +63 -0
  162. package/database-service/services/AGConnectCloudDB.js +1 -0
  163. package/database-service/services/CloudDBService.d.ts +75 -0
  164. package/database-service/services/CloudDBService.js +1 -0
  165. package/database-service/services/CloudDBZone.d.ts +254 -0
  166. package/database-service/services/CloudDBZone.js +1 -0
  167. package/database-service/services/Transaction.d.ts +73 -0
  168. package/database-service/services/Transaction.js +1 -0
  169. package/database-service/utils/AggregareType.d.ts +10 -0
  170. package/database-service/utils/AggregareType.js +1 -0
  171. package/database-service/utils/CloudDBSdkUtils.d.ts +30 -0
  172. package/database-service/utils/CloudDBSdkUtils.js +1 -0
  173. package/database-service/utils/ConditionType.d.ts +26 -0
  174. package/database-service/utils/ConditionType.js +1 -0
  175. package/database-service/utils/ConditionValidate.d.ts +40 -0
  176. package/database-service/utils/ConditionValidate.js +1 -0
  177. package/database-service/utils/Constant.d.ts +9 -0
  178. package/database-service/utils/Constant.js +1 -0
  179. package/database-service/utils/DataModelHelper.d.ts +28 -0
  180. package/database-service/utils/DataModelHelper.js +1 -0
  181. package/database-service/utils/FieldType.d.ts +18 -0
  182. package/database-service/utils/FieldType.js +1 -0
  183. package/database-service/utils/SchemaUtils.d.ts +24 -0
  184. package/database-service/utils/SchemaUtils.js +1 -0
  185. package/database-service/utils/Utils.d.ts +134 -0
  186. package/database-service/utils/Utils.js +1 -0
  187. package/function-service/cloudFunction.d.ts +10 -0
  188. package/function-service/cloudFunction.js +1 -0
  189. package/function-service/exception/AGCFunctionException.d.ts +7 -0
  190. package/function-service/exception/AGCFunctionException.js +1 -0
  191. package/function-service/exception/FunctionErrorCode.d.ts +26 -0
  192. package/function-service/exception/FunctionErrorCode.js +1 -0
  193. package/function-service/index.d.ts +8 -0
  194. package/function-service/index.js +1 -0
  195. package/function-service/params/functionParams.d.ts +9 -0
  196. package/function-service/params/functionParams.js +1 -0
  197. package/function-service/params/index.d.ts +4 -0
  198. package/function-service/params/index.js +1 -0
  199. package/function-service/server/AGCFunction.d.ts +20 -0
  200. package/function-service/server/AGCFunction.js +1 -0
  201. package/function-service/server/FunctionCallable.d.ts +40 -0
  202. package/function-service/server/FunctionCallable.js +1 -0
  203. package/function-service/server/FunctionResult.d.ts +8 -0
  204. package/function-service/server/FunctionResult.js +1 -0
  205. package/function-service/server/request/RequestHeaders.d.ts +10 -0
  206. package/function-service/server/request/RequestHeaders.js +1 -0
  207. package/function-service/util/HashUtil.d.ts +10 -0
  208. package/function-service/util/HashUtil.js +1 -0
  209. package/index.d.ts +7 -0
  210. package/index.js +1 -0
  211. package/package.json +58 -0
package/README.md ADDED
@@ -0,0 +1,258 @@
1
+ # AppGallery Connect Cloud Server SDK for NodeJS
2
+
3
+ ## Table of Contents
4
+ - [Introduction](#introduction)
5
+ - [Installation](#installation)
6
+ - [Prerequisites](#prerequisites)
7
+ - [Usage](#usage)
8
+ - [Initializing the SDK](#initializing-the-sdk)
9
+ - [Auth Service](#auth-service)
10
+ - [Cloud Functions](#cloud-functions)
11
+ - [Cloud DB](#cloud-db)
12
+ - [Initializing Cloud DB](#initializing-cloud-db)
13
+ - [Writing Data](#writing-data)
14
+ - [Querying Data](#querying-data)
15
+ - [Cloud Storage](#cloud-storage)
16
+ - [Constraints and Limitations](#constraints-and-limitations)
17
+ - [License](#license)
18
+
19
+ ## Introduction
20
+
21
+ AppGallery Connect provides in-depth support for application development. The platform offers variety of cloud services which supports mainstream application platforms and helps developers quickly and efficiently build applications.
22
+
23
+ The AGC Cloud-Server NodeJS SDK allows developers to access the AGC services from their server-side applications developed with NodeJS.
24
+
25
+ SDK Provides support for multiple AGC cloud services:
26
+ * Authentication service: helps applications quickly build a secure and reliable user authentication system.
27
+ * Cloud function: provides a serverless code development and running platform.
28
+ * Cloud database: Provides collaborative management of device-cloud data.
29
+ * Cloud storage: helps applications store images, audios, and videos, and provides high-quality upload, download, and sharing capabilities.
30
+
31
+ [Learn More (ZH)](https://developer.huawei.com/consumer/cn/doc/development/AppGallery-connect-Guides/agc-serverless-overview-0000001509965245)
32
+
33
+ [Learn More (EN)](https://developer.huawei.com/consumer/en/doc/AppGallery-connect-Guides/agc-introduction-0000001057492641)
34
+
35
+ ## Installation
36
+
37
+ ```bash
38
+ npm install @hw-agconnect/cloud-server
39
+ ```
40
+
41
+ ## Prerequisites
42
+
43
+
44
+ Ensure that:
45
+
46
+ - You have [installed Node.js and npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) on your development environment.
47
+ - You have registered an account on the [HUAWEI Developer](https://developer.huawei.com/consumer/en/) website and passed real-name authentication. For details, see [HUAWEI ID Registration](https://developer.huawei.com/consumer/en/doc/start/registration-and-verification-0000001053628148).
48
+ - You have created a project and app on the [AppGallery Connect console](https://developer.huawei.com/consumer/en/console). For details, see [Creating Your Project and App](https://developer.huawei.com/consumer/en/doc/distribution/app/agc-help-createproject-0000001100334664).
49
+ - [Create an API Client in AGC Console](https://developer.huawei.com/consumer/en/doc/AppGallery-connect-Guides/agc-get-started-server-0000001058092593#section1778162811430) and download your project credentials.
50
+
51
+ ## Usage
52
+
53
+ ### Initializing the SDK
54
+
55
+ Follow the steps below to initialize the Cloud-Server SDK in your application.
56
+
57
+ ```typescript
58
+ import { cloud } from '@hw-agconnect/cloud-server';
59
+ ```
60
+
61
+
62
+ - Method 1: Set the environment variable.
63
+ - On Linux, perform as follows:
64
+ For a permanent environment variable, add the following command to the .bashrc or .bash_profile file in the $HOME directory, and run the source .bashrc or source .bash_profile command for the variable to take effect. For a temporary environment variable, run the following command directly and change [PATH] to the actual path of the credential file.
65
+ ``` bash
66
+ export AGC_CONFIG="[PATH]/agc-apiclient-xxx-xxx.json"
67
+ ```
68
+ - On Windows, perform as follows:
69
+
70
+ To set permanent environment variables, go to Advanced system settings > Environment Variables on Windows. You are advised to restart the Windows system, or load the environment variables in another way for them to take effect.
71
+
72
+ For a temporary environment variable, run the following command directly and change [PATH] to the actual path of the credential file.
73
+
74
+ ``` bash
75
+ set AGC_CONFIG=[PATH]\agc-apiclient-xxx-xxx.json
76
+ ```
77
+ In this method you do not need anything more. Now on you can use services with directly like in example:
78
+
79
+ ```typescript
80
+ cloud.auth().sign(...)
81
+ ```
82
+ - Method 2 : Specify the authentication credential path as follows. Replace [PATH] with the actual credential path:
83
+
84
+ If you do not specify environment variable you must follow this method. You can also create multiple instances with credential files
85
+ ```typescript
86
+ const cloudInstance=cloud.createInstance('./api-client-project.json',"instancename",Region.REGION_CN);
87
+ ```
88
+ [REGION] indicates the data processing location of the client. The value can be CN (China), RU (Russia), SG (Singapore), or DE (Germany).
89
+
90
+
91
+ ### Auth Service
92
+ - Getting Auth Service
93
+
94
+ You can reach auth service with following ways:
95
+ ```typescript
96
+ const cloudInstance.auth()
97
+ ```
98
+ ```typescript
99
+ const cloud.auth()
100
+ ```
101
+ - Using methods
102
+
103
+ You must call functions with wrappers.
104
+ As you can see in example of sign method usage below
105
+
106
+ ```typescript
107
+ var token = cloudInstance.auth().sign({uid:"uid",displayName:"",photoUrl:"",privateKey:""})
108
+ ```
109
+ ### Cloud Functions
110
+ - Getting Function Service
111
+
112
+ You can reach function service with following ways:
113
+ ```typescript
114
+ const cloudInstance.function()
115
+ ```
116
+ ```typescript
117
+ const cloud.function()
118
+ ```
119
+ #### Calling a Function
120
+
121
+
122
+ ```
123
+ export interface FunctionParams {
124
+ name: string;
125
+ version?: string;
126
+ timeout?: number;
127
+ data?: any;
128
+ }
129
+ const functionResult = cloud.function().call({name: "your-cloud-function", data: {"simple":"example"}});
130
+ ```
131
+
132
+ ### Note
133
+ The default value of the version is the "-$latest" version.
134
+ The default value of the timeout is the 55000.
135
+
136
+
137
+ ### Cloud DB
138
+
139
+ #### Prerequisites
140
+
141
+ Before you start using the Cloud DB Server SDK you need to create and export you Database Object Types from AGC Console. [For more information, please check the official documentation.](https://developer.huawei.com/consumer/en/doc/AppGallery-connect-Guides/agc-clouddb-sdk-integration-nodejs-0000001518387192#section105953115325)
142
+
143
+ #### Initializing Cloud DB
144
+
145
+
146
+ - Creates an instance and collection for the cloud database.
147
+ - It need to be created the credential for server sdk (api-client-project.json).
148
+
149
+ > During local app development, you can directly add the JS file exported from AppGallery Connect to the local development environment. Then you do not need to create object types for local app development.
150
+
151
+
152
+ Put the obtained authentication credential in your custom directory. Call initialize to initialize the cloud-server instance corresponding to the data processing location.
153
+ ```
154
+ const instance = cloud.createInstance('./api-client-project.json', 'createinstance', Region.REGION_CN);
155
+ ```
156
+ Write the zone name that it created from AGC Console. It need to give class type of database object (It can export created object types from AGC Console). BookInfo is database object type that get AGC Console with exporting.
157
+ ```
158
+ const collection = instance.database({ zoneName: 'testZone' }).collection(BookInfo);
159
+ ```
160
+
161
+ #### Writing Data
162
+
163
+ The insertion of a single record into the database.
164
+
165
+ ```
166
+ const tempRecord = {
167
+ id: 1,
168
+ bookName: 'highway',
169
+ author: 'unknown',
170
+ publisher: 'huawei',
171
+ publishTime: new Date('1997-07-26T03:24:00'),
172
+ price: 44,
173
+ };
174
+ const result = await collection.insert(tempRecord);
175
+ ```
176
+
177
+ The "upsert" operation (update if exists, insert if not) for a record.
178
+
179
+ ```
180
+ const tempRecord = {
181
+ id: 1,
182
+ bookName: 'highway',
183
+ author: 'unknown',
184
+ publisher: 'huawei',
185
+ publishTime: new Date('1997-07-26T03:24:00'),
186
+ price: 44,
187
+ };
188
+ const result = await collection.upsert(tempRecord);
189
+ ```
190
+
191
+
192
+
193
+ #### Querying Data
194
+
195
+ The `query()` function must be called to query the database object type. After the filtering functions are run, the `get()` function must be called to get the result.
196
+
197
+ ```
198
+ const query = collection.query();
199
+ ```
200
+
201
+ The retrieval of records from the database.
202
+
203
+ ```
204
+ const result = await query.get();
205
+ ```
206
+
207
+ Querying records with a limit set to zero.
208
+
209
+ ```
210
+ const result = await query.limit(0).get();
211
+ ```
212
+
213
+ Querying records with a condition of price greater than or equal to 45.
214
+
215
+ ```
216
+ const result = await query.greaterThanOrEqualTo('price', 45).get();
217
+ ```
218
+
219
+
220
+ For more information about the Cloud DB Service, please check out the [Documentation Guide from the Huawei Developers Website.](https://developer.huawei.com/consumer/en/doc/AppGallery-connect-Guides/agc-clouddb-introduction-0000001054212760)
221
+
222
+ ## Cloud Storage
223
+
224
+ ### Constraints and Limitations
225
+
226
+ Paid services usually offer a certain amount of free quota. Once the free quota is about to be used up in a billing cycle, you can either [subscribe to the pay-as-you-go plan](https://developer.huawei.com/consumer/en/doc/AppGallery-connect-Guides/agc-service-billing-0000001058092595#section76943113539) to avoid service interruption, or wait until the next billing cycle. Before the next billing cycle arrives, the service will be unavailable.
227
+
228
+ See more detailed information on [Service Pricing and Subscription](https://developer.huawei.com/consumer/en/doc/AppGallery-connect-Guides/agc-service-billing-0000001058092595#section76943113539)
229
+
230
+ #### Creating Instance
231
+
232
+ - You can create an instance with the following way.
233
+ ```
234
+ const storageInstance = await cloud.storage({bucketName: "your-storage-bucket"});
235
+ ```
236
+
237
+ #### Bucket Upload
238
+
239
+ - Upload local files to a storage instance.
240
+
241
+ ```
242
+ const result: UploadResponse = await storageInstance.upload({localPath: "localPath"});
243
+ ```
244
+
245
+ #### File Download
246
+
247
+ - Downloading a file from the cloud to a local device.
248
+
249
+ ```
250
+ const result: DownloadResponse | void = await storageInstance.download({
251
+ localPath: "path/to/download_file",
252
+ cloudPath: "path/to/cloudFile"
253
+ });
254
+ ```
255
+
256
+ ## License
257
+
258
+ AGC Cloud-Server NodeJS SDK is licensed under the: "ISC"
@@ -0,0 +1,7 @@
1
+ {
2
+ "sdk_name": "cloud-server/auth-service",
3
+ "sdk_version": "1.0.0",
4
+ "jwt_expires_time": 48,
5
+ "import_user_limit_size": 1000,
6
+ "publickey_url": "https://developer.huawei.com/consumer/cn/service/josp/agc/auth/keys"
7
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Copyright (c) Huawei Technologies Co., Ltd. 2023 All rights reserved.
3
+ */
4
+ import { SignParams, FileParams, TokenParams, UidParams } from "./params";
5
+ import { AGCAuthJwtToken, AuthAccessToken, RSAKeyPair, UserImportExportResult } from "./";
6
+ export declare class Auth {
7
+ private readonly instance;
8
+ constructor(name: string);
9
+ /**
10
+ * @param {SignParams} params
11
+ * @return AGCAuthJwtToken include jwt and expire time
12
+ */
13
+ sign(params: SignParams): AGCAuthJwtToken;
14
+ /**
15
+ * generate rsa pair key
16
+ * @return rsa pair key
17
+ */
18
+ generateKey(): RSAKeyPair;
19
+ /**
20
+ * import user from firebase or agc
21
+ * @param {FileParams}params import file path
22
+ * @return import result
23
+ */
24
+ importUserData(params: FileParams): Promise<UserImportExportResult>;
25
+ /**
26
+ * export users of agc project
27
+ * @param {FileParams}params export user data to server path
28
+ * @return export result
29
+ */
30
+ exportUserData(params: FileParams): Promise<UserImportExportResult>;
31
+ /**
32
+ * revoke all refresh tokens for uid
33
+ * @param {UidParams}uid The user id for which tokens are revoked
34
+ */
35
+ revokeRefreshTokens(uid: UidParams): Promise<void>;
36
+ /**
37
+ * verifies auth access token
38
+ * <p>This method to verify that the token is valid,ensure that the token is correctly signed,
39
+ * has not expired
40
+ *
41
+ * <p> If {@code checkRevoked} is set to true, this method will check the access token
42
+ * has been revoke
43
+ *
44
+ * @param {TokenParams}params auth access token
45
+ * @return user login info
46
+ */
47
+ verifyAccessToken(params: TokenParams): Promise<AuthAccessToken>;
48
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Auth=void 0;var agc_auth_1=require("./service/agc-auth"),Auth=function(){function e(e){this.instance=agc_auth_1.AGCAuth.getInstance(e)}return e.prototype.sign=function(e){return this.instance.sign(e.uid,e.displayName,e.photoUrl,e.privateKey)},e.prototype.generateKey=function(){return this.instance.generateKey()},e.prototype.importUserData=function(e){return this.instance.importUserData(e.filePath)},e.prototype.exportUserData=function(e){return this.instance.exportUserData(e.filePath)},e.prototype.revokeRefreshTokens=function(e){return this.instance.revokeRefreshTokens(e.uid)},e.prototype.verifyAccessToken=function(e){return this.instance.verifyAccessToken(e.accessToken,e.checkRevoked)},e}();exports.Auth=Auth;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright (c) Huawei Technologies Co., Ltd. 2023 All rights reserved.
3
+ */
4
+ import { BaseResponse, RequestConstructor } from "../../common-server";
5
+ export declare class AuthBackend {
6
+ private static httpClient;
7
+ static post(request: RequestConstructor, response: BaseResponse, enableBackurl?: boolean): Promise<void>;
8
+ static get(request: RequestConstructor, response: BaseResponse, enableBackurl?: boolean, ignoreRet?: boolean): Promise<void>;
9
+ private static initHttpClient;
10
+ private static getAuthCommonHeader;
11
+ }
@@ -0,0 +1 @@
1
+ "use strict";var __awaiter=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,c){function a(e){try{s(r.next(e))}catch(e){c(e)}}function i(e){try{s(r.throw(e))}catch(e){c(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,i)}s((r=r.apply(e,t||[])).next())}))},__generator=this&&this.__generator||function(e,t){var n,r,o,c,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return c={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function i(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;c&&(c=0,i[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.AuthBackend=void 0;var common_server_1=require("../../common-server"),AuthBackend=function(){function e(){}return e.post=function(t,n,r){return __awaiter(this,void 0,void 0,(function(){var o,c=this;return __generator(this,(function(a){switch(a.label){case 0:return e.initHttpClient(),[4,t.getHeader()];case 1:return o=a.sent(),[4,e.httpClient.post(t.getUrl(),t.getBody(),null,o).then((function(e){0===e.data.ret.code&&n.constructResponse(e),n.setRet(new common_server_1.ConnectRet(e.data.ret.code,e.data.ret.msg))})).catch((function(a){return __awaiter(c,void 0,void 0,(function(){return __generator(this,(function(c){switch(c.label){case 0:return common_server_1.CloudGwUrlUtil.checkUseBackUrl(a,r)?[4,e.httpClient.post(t.getUrl(!0),t.getBody(),null,o).then((function(e){0===e.data.ret.code&&n.constructResponse(e),n.setRet(new common_server_1.ConnectRet(e.data.ret.code,e.data.ret.msg))})).catch((function(e){return Promise.reject(e)}))]:[3,2];case 1:return c.sent(),[3,3];case 2:return[2,Promise.reject(a)];case 3:return[2]}}))}))}))];case 2:return a.sent(),[2]}}))}))},e.get=function(t,n,r,o){return __awaiter(this,void 0,void 0,(function(){var c,a=this;return __generator(this,(function(i){switch(i.label){case 0:return e.initHttpClient(),[4,t.getHeader()];case 1:return c=i.sent(),[4,e.httpClient.get(t.getUrl(),t.getBody(),c).then((function(e){o?n.constructResponse(e):(0===e.data.ret.code&&n.constructResponse(e),n.setRet(new common_server_1.ConnectRet(e.data.ret.code,e.data.ret.msg)))})).catch((function(i){return __awaiter(a,void 0,void 0,(function(){return __generator(this,(function(a){switch(a.label){case 0:return common_server_1.CloudGwUrlUtil.checkUseBackUrl(i,r)?[4,e.httpClient.get(t.getUrl(!0),t.getBody(),c).then((function(e){o?n.constructResponse(e):(0===e.data.ret.code&&n.constructResponse(e),n.setRet(new common_server_1.ConnectRet(e.data.ret.code,e.data.ret.msg)))})).catch((function(e){return Promise.reject(e)}))]:[3,2];case 1:return a.sent(),[3,3];case 2:return[2,Promise.reject(i)];case 3:return[2]}}))}))}))];case 2:return i.sent(),[2]}}))}))},e.initHttpClient=function(){if(!e.httpClient){var t={commonHeaders:e.getAuthCommonHeader()};e.httpClient=(0,common_server_1.getHttpClient)(t)}},e.getAuthCommonHeader=function(){return{serverSdkName:common_server_1.CommonHeaders.SDK_PREFIX+common_server_1.ConfigService.getService("AUTH").getConfigValue(common_server_1.CommonHeaders.SDK_NAME),serverSdkVersion:common_server_1.ConfigService.getService("AUTH").getConfigValue(common_server_1.CommonHeaders.SDK_VERSION)}},e.httpClient=void 0,e}();exports.AuthBackend=AuthBackend;
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Copyright (c) Huawei Technologies Co., Ltd. 2023 All rights reserved.
3
+ */
4
+ import { TokenProviderInfo } from "./token-provider-info";
5
+ import { AuthAccessToken } from "./auth-access-token";
6
+ export declare class AuthAccessTokenImpl implements AuthAccessToken {
7
+ /**
8
+ * the user's display name
9
+ */
10
+ private name;
11
+ /**
12
+ * the user's avatar address
13
+ */
14
+ private picture;
15
+ /**
16
+ * Issuer of JWT
17
+ */
18
+ private iss;
19
+ /**
20
+ * projectId
21
+ */
22
+ private aud;
23
+ /**
24
+ * last login time
25
+ */
26
+ private authTime;
27
+ /**
28
+ * userId
29
+ */
30
+ private sub;
31
+ /**
32
+ * create time of jwt
33
+ */
34
+ private iat;
35
+ /**
36
+ * expire time of jwt
37
+ */
38
+ private exp;
39
+ private email;
40
+ private phone;
41
+ /**
42
+ * email address has been verified
43
+ */
44
+ private emailVerified;
45
+ /**
46
+ * user info
47
+ */
48
+ private providerInfo;
49
+ constructor(obj?: any);
50
+ getName(): string | undefined;
51
+ getPicture(): string | undefined;
52
+ getIss(): string | undefined;
53
+ setIss(iss: string): void;
54
+ getAud(): string | undefined;
55
+ setAud(aud: string): void;
56
+ getAuthTime(): number | undefined;
57
+ getSub(): string | undefined;
58
+ setSub(sub: string): void;
59
+ getIat(): number | undefined;
60
+ setIat(iat: number): void;
61
+ getExp(): number | undefined;
62
+ setExp(exp: number): void;
63
+ getEmail(): string | undefined;
64
+ getPhone(): string | undefined;
65
+ isEmailVerified(): boolean | undefined;
66
+ getProviderInfo(): TokenProviderInfo | undefined;
67
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AuthAccessTokenImpl=void 0;var token_provider_info_1=require("./token-provider-info"),provider_1=require("./provider"),AuthAccessTokenImpl=function(){function t(t){if(t&&(this.name=t.name,this.picture=t.picture,this.iss=t.iss,this.aud=t.aud,this.authTime=t.auth_time,this.sub=t.sub,this.iat=t.iat,this.exp=t.exp,this.email=t.email,this.phone=t.phone,this.emailVerified=t.email_verified,t.agc&&(this.providerInfo=new token_provider_info_1.TokenProviderInfo,this.providerInfo.setSignInProvider(t.agc.sign_in_provider),t.agc.providers&&Array.isArray(t.agc.providers)))){for(var e=[],i=0;i<t.agc.providers.length;i++){var r=new provider_1.Provider;r.setProvider(t.agc.providers[i].provider),r.setProviderUid(t.agc.providers[i].provider_uid),e.push(r)}this.providerInfo.setProviders(e)}}return t.prototype.getName=function(){return this.name},t.prototype.getPicture=function(){return this.picture},t.prototype.getIss=function(){return this.iss},t.prototype.setIss=function(t){this.iss=t},t.prototype.getAud=function(){return this.aud},t.prototype.setAud=function(t){this.aud=t},t.prototype.getAuthTime=function(){return this.authTime},t.prototype.getSub=function(){return this.sub},t.prototype.setSub=function(t){this.sub=t},t.prototype.getIat=function(){return this.iat},t.prototype.setIat=function(t){this.iat=t},t.prototype.getExp=function(){return this.exp},t.prototype.setExp=function(t){this.exp=t},t.prototype.getEmail=function(){return this.email},t.prototype.getPhone=function(){return this.phone},t.prototype.isEmailVerified=function(){return this.emailVerified},t.prototype.getProviderInfo=function(){return this.providerInfo},t}();exports.AuthAccessTokenImpl=AuthAccessTokenImpl;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Copyright (c) Huawei Technologies Co., Ltd. 2023 All rights reserved.
3
+ */
4
+ import { TokenProviderInfo } from "./token-provider-info";
5
+ export interface AuthAccessToken {
6
+ /**
7
+ * the user's display name
8
+ */
9
+ getName(): string | undefined;
10
+ /**
11
+ * the user's avatar address
12
+ */
13
+ getPicture(): string | undefined;
14
+ /**
15
+ * Issuer of JWT
16
+ */
17
+ getIss(): string | undefined;
18
+ /**
19
+ * projectId
20
+ */
21
+ getAud(): string | undefined;
22
+ /**
23
+ * last login time
24
+ */
25
+ getAuthTime(): number | undefined;
26
+ /**
27
+ * userId
28
+ */
29
+ getSub(): string | undefined;
30
+ /**
31
+ * create time of jwt
32
+ */
33
+ getIat(): number | undefined;
34
+ /**
35
+ * expire time of jwt
36
+ */
37
+ getExp(): number | undefined;
38
+ /**
39
+ * email
40
+ */
41
+ getEmail(): string | undefined;
42
+ /**
43
+ * phone
44
+ */
45
+ getPhone(): string | undefined;
46
+ /**
47
+ * email address has been verified
48
+ */
49
+ isEmailVerified(): boolean | undefined;
50
+ /**
51
+ * user info
52
+ */
53
+ getProviderInfo(): TokenProviderInfo | undefined;
54
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) Huawei Technologies Co., Ltd. 2023 All rights reserved.
3
+ */
4
+ export declare class Provider {
5
+ /**
6
+ * provider id
7
+ */
8
+ private provider;
9
+ /**
10
+ * provider user id
11
+ */
12
+ private providerUid;
13
+ getProvider(): number | undefined;
14
+ setProvider(provider: number): void;
15
+ getProviderUid(): string | undefined;
16
+ setProviderUid(providerUid: string): void;
17
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Provider=void 0;var Provider=function(){function r(){this.provider=void 0,this.providerUid=void 0}return r.prototype.getProvider=function(){return this.provider},r.prototype.setProvider=function(r){this.provider=r},r.prototype.getProviderUid=function(){return this.providerUid},r.prototype.setProviderUid=function(r){this.providerUid=r},r}();exports.Provider=Provider;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) Huawei Technologies Co., Ltd. 2023 All rights reserved.
3
+ */
4
+ import { Provider } from "./provider";
5
+ export declare class TokenProviderInfo {
6
+ /**
7
+ * authentication mode used for login
8
+ */
9
+ private signInProvider;
10
+ /**
11
+ * different authentication mode user info
12
+ */
13
+ private providers;
14
+ getSignInProvider(): number | undefined;
15
+ setSignInProvider(signInProvider: number): void;
16
+ getProviders(): Provider[] | undefined;
17
+ setProviders(providers: Provider[]): void;
18
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TokenProviderInfo=void 0;var TokenProviderInfo=function(){function r(){}return r.prototype.getSignInProvider=function(){return this.signInProvider},r.prototype.setSignInProvider=function(r){this.signInProvider=r},r.prototype.getProviders=function(){return this.providers},r.prototype.setProviders=function(r){this.providers=r},r}();exports.TokenProviderInfo=TokenProviderInfo;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Copyright (c) Huawei Technologies Co., Ltd. 2023 All rights reserved.
3
+ */
4
+ export declare class UserImportExportResult {
5
+ /**
6
+ * success user count
7
+ */
8
+ private successUsers;
9
+ /**
10
+ * error user count
11
+ */
12
+ private errorUsers;
13
+ /**
14
+ * error user list
15
+ */
16
+ private errorUsersList;
17
+ constructor(successList: string[], failList: string[]);
18
+ /**
19
+ * success user count
20
+ * @return count
21
+ */
22
+ getSuccessCount(): number | undefined;
23
+ /**
24
+ * error user count
25
+ * @return count
26
+ */
27
+ getErrorUsers(): number | undefined;
28
+ /**
29
+ * error user list
30
+ * @return list
31
+ */
32
+ getErrorUsersList(): string[] | undefined;
33
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.UserImportExportResult=void 0;var UserImportExportResult=function(){function r(r,s){this.successUsers=void 0,this.errorUsers=void 0,this.errorUsersList=void 0,this.successUsers=r.length,this.errorUsers=s.length,this.errorUsersList=s}return r.prototype.getSuccessCount=function(){return this.successUsers},r.prototype.getErrorUsers=function(){return this.errorUsers},r.prototype.getErrorUsersList=function(){return this.errorUsersList},r}();exports.UserImportExportResult=UserImportExportResult;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Copyright (c) Huawei Technologies Co., Ltd. 2023 All rights reserved.
3
+ */
4
+ import { ErrorCode } from "../../common-server";
5
+ /**
6
+ * Exception Definition Class.11000-11999
7
+ */
8
+ export declare class AuthErrorCode {
9
+ static readonly CLIENT_INITIALIZE_FAILED: ErrorCode;
10
+ static readonly PROJECT_DO_NOT_SET_REGION: ErrorCode;
11
+ static readonly UID_IS_INVALID: ErrorCode;
12
+ static readonly SIGN_PRIVATE_KEY_IS_INVALID: ErrorCode;
13
+ static readonly PHOTOURL_INVALID: ErrorCode;
14
+ static readonly FAILED_TO_SIGN_JWT_TOKEN: ErrorCode;
15
+ static readonly FAILED_TO_GENERATE_RSA_KEY_PAIR: ErrorCode;
16
+ static readonly INVALID_IMPORT_USER_DATA: ErrorCode;
17
+ static readonly IMPORT_USER_DATA_OVER_LIMIT_SIZE: ErrorCode;
18
+ static readonly INVALID_IMPORT_USER_FILE: ErrorCode;
19
+ static readonly INVALID_ACCESS_IMPORT_USER_FILE: ErrorCode;
20
+ static readonly IMPORT_USER_FAILED: ErrorCode;
21
+ static readonly EXPORT_USER_DATA_FILEPATH_IS_INVALID: ErrorCode;
22
+ static readonly GET_BLOCK_USER_LIST_FAILED: ErrorCode;
23
+ static readonly GET_EXPORT_USER_FAILED: ErrorCode;
24
+ static readonly INVALID_ACCESS_EXPORT_USER_FILE: ErrorCode;
25
+ static readonly EXPORT_USER_TO_FILE_FAILED: ErrorCode;
26
+ static readonly REVOKE_REFRESH_TOKENS_UID_IS_NULL: ErrorCode;
27
+ static readonly REVOKE_REFRESH_TOKENS_FAILED: ErrorCode;
28
+ static readonly VERIFY_ACCESS_TOKEN_ACCESS_TOKEN_IS_NULL: ErrorCode;
29
+ static readonly ACCESS_TOKEN_INVALID_FORMAT: ErrorCode;
30
+ static readonly ACCESS_TOKEN_VERIFY_FAILED: ErrorCode;
31
+ static readonly JWT_EXPIRE: ErrorCode;
32
+ static readonly GET_PUBLIC_KEY_FAILED: ErrorCode;
33
+ static readonly ACCESS_TOKEN_ALG_IS_INVALID: ErrorCode;
34
+ static readonly ACCESS_TOKEN_KID_IS_INVALID: ErrorCode;
35
+ static readonly JWT_VERIFY_FAILED: ErrorCode;
36
+ static readonly JWT_REVOKED: ErrorCode;
37
+ static readonly EXPORT_USER_FILE_DIR_NOT_EXIST: ErrorCode;
38
+ static readonly INVOKE_INTERFACE_FAIL: ErrorCode;
39
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AuthErrorCode=void 0;var AuthErrorCode=function(){function e(){}return e.CLIENT_INITIALIZE_FAILED={code:"11000",message:"failed to initialize the client"},e.PROJECT_DO_NOT_SET_REGION={code:"11001",message:"no data storage location is set for the project"},e.UID_IS_INVALID={code:"11002",message:"uid is invalid."},e.SIGN_PRIVATE_KEY_IS_INVALID={code:"11003",message:"the private key for user signature is invalid"},e.PHOTOURL_INVALID={code:"11004",message:"photo url invalid"},e.FAILED_TO_SIGN_JWT_TOKEN={code:"11005",message:"jwt signature failed."},e.FAILED_TO_GENERATE_RSA_KEY_PAIR={code:"11006",message:"failed to generate the rsa public and private keys"},e.INVALID_IMPORT_USER_DATA={code:"11007",message:"the imported user file data is invalid"},e.IMPORT_USER_DATA_OVER_LIMIT_SIZE={code:"11008",message:"the number of imported users exceeds the upper limit"},e.INVALID_IMPORT_USER_FILE={code:"11009",message:"the imported user file is invalid"},e.INVALID_ACCESS_IMPORT_USER_FILE={code:"11010",message:"no permission to read the imported user file"},e.IMPORT_USER_FAILED={code:"11011",message:"import user failed"},e.EXPORT_USER_DATA_FILEPATH_IS_INVALID={code:"11012",message:"the exported user file path is invalid"},e.GET_BLOCK_USER_LIST_FAILED={code:"11013",message:"get block user list failed"},e.GET_EXPORT_USER_FAILED={code:"11014",message:"get export user failed"},e.INVALID_ACCESS_EXPORT_USER_FILE={code:"11015",message:"no permission to write the file for exporting user"},e.EXPORT_USER_TO_FILE_FAILED={code:"11016",message:"export user to file failed"},e.REVOKE_REFRESH_TOKENS_UID_IS_NULL={code:"11017",message:"uid for revoke tokens is null"},e.REVOKE_REFRESH_TOKENS_FAILED={code:"11018",message:"revoke tokens failed"},e.VERIFY_ACCESS_TOKEN_ACCESS_TOKEN_IS_NULL={code:"11019",message:"accesstoken for verify access tokens is null"},e.ACCESS_TOKEN_INVALID_FORMAT={code:"11020",message:"access token invalid format"},e.ACCESS_TOKEN_VERIFY_FAILED={code:"11021",message:"access token varify failed"},e.JWT_EXPIRE={code:"11022",message:"jwt expire"},e.GET_PUBLIC_KEY_FAILED={code:"11023",message:"get public key failed"},e.ACCESS_TOKEN_ALG_IS_INVALID={code:"11024",message:"access token algorithm is invalid"},e.ACCESS_TOKEN_KID_IS_INVALID={code:"11025",message:"access token kid is invalid"},e.JWT_VERIFY_FAILED={code:"11026",message:"jwt verify failed"},e.JWT_REVOKED={code:"11027",message:"jwt revoked"},e.EXPORT_USER_FILE_DIR_NOT_EXIST={code:"11028",message:"folder of export user file does not exist"},e.INVOKE_INTERFACE_FAIL={code:"11029",message:"invoke interface failed"},e}();exports.AuthErrorCode=AuthErrorCode;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright (c) Huawei Technologies Co., Ltd. 2023 All rights reserved.
3
+ */
4
+ import { AGCError, ErrorCode } from "../../common-server";
5
+ export declare class AGCAuthError extends AGCError {
6
+ constructor(errorCode: ErrorCode, name: string, extra?: any);
7
+ }
@@ -0,0 +1 @@
1
+ "use strict";var __extends=this&&this.__extends||function(){var r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=t[e])},r(t,e)};return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.AGCAuthError=void 0;var common_server_1=require("../../common-server"),agc_auth_service_impl_1=require("../service/impl/agc-auth-service-impl"),AGCAuthError=function(r){function t(e,o,n){var s=this;return(s=n&&n.message&&"string"==typeof n.message?r.call(this,e,o,agc_auth_service_impl_1.SERVICE_NAME,n.message)||this:r.call(this,e,o,agc_auth_service_impl_1.SERVICE_NAME)||this).__proto__=t.prototype,s}return __extends(t,r),t}(common_server_1.AGCError);exports.AGCAuthError=AGCAuthError;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Copyright (c) Huawei Technologies Co., Ltd. 2023 All rights reserved.
3
+ */
4
+ export { TokenProviderInfo } from "./entity/token-provider-info";
5
+ export { Provider } from "./entity/provider";
6
+ export { RSAKeyPair } from "./jwt/rsa-key-pair";
7
+ export { AGCAuthJwtToken } from "./jwt/agc-auth-jwttoken";
8
+ export { UserImportExportResult } from "./entity/user-import-export-result";
9
+ export { AuthAccessToken } from "./entity/auth-access-token";
10
+ export { AuthErrorCode } from "./error/agc-auth-error-message";
11
+ export { AGCAuthError } from "./error/agc-auth-error";
12
+ export { Auth } from "./auth";
13
+ export * from "./params";
@@ -0,0 +1 @@
1
+ "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,t,o){void 0===o&&(o=t);var n=Object.getOwnPropertyDescriptor(r,t);n&&!("get"in n?!r.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,o,n)}:function(e,r,t,o){void 0===o&&(o=t),e[o]=r[t]}),__exportStar=this&&this.__exportStar||function(e,r){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(r,t)||__createBinding(r,e,t)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Auth=exports.AGCAuthError=exports.AuthErrorCode=exports.UserImportExportResult=exports.AGCAuthJwtToken=exports.Provider=exports.TokenProviderInfo=void 0;var token_provider_info_1=require("./entity/token-provider-info");Object.defineProperty(exports,"TokenProviderInfo",{enumerable:!0,get:function(){return token_provider_info_1.TokenProviderInfo}});var provider_1=require("./entity/provider");Object.defineProperty(exports,"Provider",{enumerable:!0,get:function(){return provider_1.Provider}});var agc_auth_jwttoken_1=require("./jwt/agc-auth-jwttoken");Object.defineProperty(exports,"AGCAuthJwtToken",{enumerable:!0,get:function(){return agc_auth_jwttoken_1.AGCAuthJwtToken}});var user_import_export_result_1=require("./entity/user-import-export-result");Object.defineProperty(exports,"UserImportExportResult",{enumerable:!0,get:function(){return user_import_export_result_1.UserImportExportResult}});var agc_auth_error_message_1=require("./error/agc-auth-error-message");Object.defineProperty(exports,"AuthErrorCode",{enumerable:!0,get:function(){return agc_auth_error_message_1.AuthErrorCode}});var agc_auth_error_1=require("./error/agc-auth-error");Object.defineProperty(exports,"AGCAuthError",{enumerable:!0,get:function(){return agc_auth_error_1.AGCAuthError}});var auth_1=require("./auth");Object.defineProperty(exports,"Auth",{enumerable:!0,get:function(){return auth_1.Auth}}),__exportStar(require("./params"),exports);
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) Huawei Technologies Co., Ltd. 2023 All rights reserved.
3
+ */
4
+ export declare class AGCAuthJwt {
5
+ private static SEP;
6
+ private static HEAD;
7
+ private static PAYLOAD;
8
+ private static SIGNATURE;
9
+ private header;
10
+ private payload;
11
+ private signature;
12
+ static parse(jwtToken: string): AGCAuthJwt;
13
+ parseAlg(): string | null;
14
+ parseKid(): string | null;
15
+ parsePayload(): string;
16
+ expire(): boolean;
17
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AGCAuthJwt=void 0;var AGCAuthJwt=function(){function e(){}return e.parse=function(r){var t=r.split(e.SEP),a=new e;return a.header=t[e.HEAD],a.payload=t[e.PAYLOAD],a.signature=t[e.SIGNATURE],a},e.prototype.parseAlg=function(){var e=JSON.parse(Buffer.from(this.header,"base64").toString());return e.alg?e.alg:null},e.prototype.parseKid=function(){var e=JSON.parse(Buffer.from(this.header,"base64").toString());return e.kid?e.kid:null},e.prototype.parsePayload=function(){return JSON.parse(Buffer.from(this.payload,"base64").toString())},e.prototype.expire=function(){var e=JSON.parse(Buffer.from(this.payload,"base64").toString());return e.exp>0&&Math.round((new Date).getTime()/1e3)>e.exp},e.SEP=".",e.HEAD=0,e.PAYLOAD=1,e.SIGNATURE=2,e}();exports.AGCAuthJwt=AGCAuthJwt;