agora-token 2.0.0 → 2.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.
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/nodejs.iml +8 -0
- package/.idea/vcs.xml +6 -0
- package/.idea/workspace.xml +294 -0
- package/index.d.ts +29 -0
- package/index.js +2 -1
- package/package.json +1 -1
- package/sample/ChatTokenBuilderSample.js +11 -0
- package/src/ChatTokenBuilder.js +46 -0
- package/test/ChatTokenBuilderTest.js +34 -0
package/.idea/misc.xml
ADDED
package/.idea/nodejs.iml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$" />
|
|
5
|
+
<orderEntry type="inheritedJdk" />
|
|
6
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
7
|
+
</component>
|
|
8
|
+
</module>
|
package/.idea/vcs.xml
ADDED
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="BranchesTreeState">
|
|
4
|
+
<expand>
|
|
5
|
+
<path>
|
|
6
|
+
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
7
|
+
<item name="LOCAL_ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
8
|
+
</path>
|
|
9
|
+
<path>
|
|
10
|
+
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
11
|
+
<item name="LOCAL_ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
12
|
+
<item name="GROUP_NODE:dev" type="e8cecc67:BranchNodeDescriptor" />
|
|
13
|
+
</path>
|
|
14
|
+
<path>
|
|
15
|
+
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
16
|
+
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
17
|
+
</path>
|
|
18
|
+
<path>
|
|
19
|
+
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
20
|
+
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
21
|
+
<item name="GROUP_NODE:origin" type="e8cecc67:BranchNodeDescriptor" />
|
|
22
|
+
</path>
|
|
23
|
+
<path>
|
|
24
|
+
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
25
|
+
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
26
|
+
<item name="GROUP_NODE:origin" type="e8cecc67:BranchNodeDescriptor" />
|
|
27
|
+
<item name="GROUP_NODE:dependabot" type="e8cecc67:BranchNodeDescriptor" />
|
|
28
|
+
</path>
|
|
29
|
+
<path>
|
|
30
|
+
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
31
|
+
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
32
|
+
<item name="GROUP_NODE:origin" type="e8cecc67:BranchNodeDescriptor" />
|
|
33
|
+
<item name="GROUP_NODE:dependabot" type="e8cecc67:BranchNodeDescriptor" />
|
|
34
|
+
<item name="GROUP_NODE:maven" type="e8cecc67:BranchNodeDescriptor" />
|
|
35
|
+
</path>
|
|
36
|
+
<path>
|
|
37
|
+
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
38
|
+
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
39
|
+
<item name="GROUP_NODE:origin" type="e8cecc67:BranchNodeDescriptor" />
|
|
40
|
+
<item name="GROUP_NODE:dependabot" type="e8cecc67:BranchNodeDescriptor" />
|
|
41
|
+
<item name="GROUP_NODE:maven" type="e8cecc67:BranchNodeDescriptor" />
|
|
42
|
+
<item name="GROUP_NODE:DynamicKey" type="e8cecc67:BranchNodeDescriptor" />
|
|
43
|
+
</path>
|
|
44
|
+
<path>
|
|
45
|
+
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
46
|
+
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
47
|
+
<item name="GROUP_NODE:origin" type="e8cecc67:BranchNodeDescriptor" />
|
|
48
|
+
<item name="GROUP_NODE:dependabot" type="e8cecc67:BranchNodeDescriptor" />
|
|
49
|
+
<item name="GROUP_NODE:maven" type="e8cecc67:BranchNodeDescriptor" />
|
|
50
|
+
<item name="GROUP_NODE:DynamicKey" type="e8cecc67:BranchNodeDescriptor" />
|
|
51
|
+
<item name="GROUP_NODE:AgoraDynamicKey" type="e8cecc67:BranchNodeDescriptor" />
|
|
52
|
+
</path>
|
|
53
|
+
<path>
|
|
54
|
+
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
55
|
+
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
56
|
+
<item name="GROUP_NODE:origin" type="e8cecc67:BranchNodeDescriptor" />
|
|
57
|
+
<item name="GROUP_NODE:dependabot" type="e8cecc67:BranchNodeDescriptor" />
|
|
58
|
+
<item name="GROUP_NODE:maven" type="e8cecc67:BranchNodeDescriptor" />
|
|
59
|
+
<item name="GROUP_NODE:DynamicKey" type="e8cecc67:BranchNodeDescriptor" />
|
|
60
|
+
<item name="GROUP_NODE:AgoraDynamicKey" type="e8cecc67:BranchNodeDescriptor" />
|
|
61
|
+
<item name="GROUP_NODE:java" type="e8cecc67:BranchNodeDescriptor" />
|
|
62
|
+
</path>
|
|
63
|
+
<path>
|
|
64
|
+
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
65
|
+
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
66
|
+
<item name="GROUP_NODE:origin" type="e8cecc67:BranchNodeDescriptor" />
|
|
67
|
+
<item name="GROUP_NODE:dependabot" type="e8cecc67:BranchNodeDescriptor" />
|
|
68
|
+
<item name="GROUP_NODE:npm_and_yarn" type="e8cecc67:BranchNodeDescriptor" />
|
|
69
|
+
</path>
|
|
70
|
+
<path>
|
|
71
|
+
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
72
|
+
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
73
|
+
<item name="GROUP_NODE:origin" type="e8cecc67:BranchNodeDescriptor" />
|
|
74
|
+
<item name="GROUP_NODE:dependabot" type="e8cecc67:BranchNodeDescriptor" />
|
|
75
|
+
<item name="GROUP_NODE:npm_and_yarn" type="e8cecc67:BranchNodeDescriptor" />
|
|
76
|
+
<item name="GROUP_NODE:DynamicKey" type="e8cecc67:BranchNodeDescriptor" />
|
|
77
|
+
</path>
|
|
78
|
+
<path>
|
|
79
|
+
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
80
|
+
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
81
|
+
<item name="GROUP_NODE:origin" type="e8cecc67:BranchNodeDescriptor" />
|
|
82
|
+
<item name="GROUP_NODE:dependabot" type="e8cecc67:BranchNodeDescriptor" />
|
|
83
|
+
<item name="GROUP_NODE:npm_and_yarn" type="e8cecc67:BranchNodeDescriptor" />
|
|
84
|
+
<item name="GROUP_NODE:DynamicKey" type="e8cecc67:BranchNodeDescriptor" />
|
|
85
|
+
<item name="GROUP_NODE:AgoraDynamicKey" type="e8cecc67:BranchNodeDescriptor" />
|
|
86
|
+
</path>
|
|
87
|
+
<path>
|
|
88
|
+
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
89
|
+
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
90
|
+
<item name="GROUP_NODE:origin" type="e8cecc67:BranchNodeDescriptor" />
|
|
91
|
+
<item name="GROUP_NODE:dependabot" type="e8cecc67:BranchNodeDescriptor" />
|
|
92
|
+
<item name="GROUP_NODE:npm_and_yarn" type="e8cecc67:BranchNodeDescriptor" />
|
|
93
|
+
<item name="GROUP_NODE:DynamicKey" type="e8cecc67:BranchNodeDescriptor" />
|
|
94
|
+
<item name="GROUP_NODE:AgoraDynamicKey" type="e8cecc67:BranchNodeDescriptor" />
|
|
95
|
+
<item name="GROUP_NODE:nodejs" type="e8cecc67:BranchNodeDescriptor" />
|
|
96
|
+
</path>
|
|
97
|
+
<path>
|
|
98
|
+
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
99
|
+
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
100
|
+
<item name="GROUP_NODE:origin" type="e8cecc67:BranchNodeDescriptor" />
|
|
101
|
+
<item name="GROUP_NODE:dependabot" type="e8cecc67:BranchNodeDescriptor" />
|
|
102
|
+
<item name="GROUP_NODE:npm_and_yarn" type="e8cecc67:BranchNodeDescriptor" />
|
|
103
|
+
<item name="GROUP_NODE:DynamicKey" type="e8cecc67:BranchNodeDescriptor" />
|
|
104
|
+
<item name="GROUP_NODE:AgoraDynamicKey" type="e8cecc67:BranchNodeDescriptor" />
|
|
105
|
+
<item name="GROUP_NODE:nodejs" type="e8cecc67:BranchNodeDescriptor" />
|
|
106
|
+
<item name="GROUP_NODE:server" type="e8cecc67:BranchNodeDescriptor" />
|
|
107
|
+
</path>
|
|
108
|
+
<path>
|
|
109
|
+
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
110
|
+
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
111
|
+
<item name="GROUP_NODE:origin" type="e8cecc67:BranchNodeDescriptor" />
|
|
112
|
+
<item name="GROUP_NODE:dependabot" type="e8cecc67:BranchNodeDescriptor" />
|
|
113
|
+
<item name="GROUP_NODE:npm_and_yarn" type="e8cecc67:BranchNodeDescriptor" />
|
|
114
|
+
<item name="GROUP_NODE:TroubleShooting" type="e8cecc67:BranchNodeDescriptor" />
|
|
115
|
+
</path>
|
|
116
|
+
<path>
|
|
117
|
+
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
118
|
+
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
119
|
+
<item name="GROUP_NODE:origin" type="e8cecc67:BranchNodeDescriptor" />
|
|
120
|
+
<item name="GROUP_NODE:dependabot" type="e8cecc67:BranchNodeDescriptor" />
|
|
121
|
+
<item name="GROUP_NODE:npm_and_yarn" type="e8cecc67:BranchNodeDescriptor" />
|
|
122
|
+
<item name="GROUP_NODE:TroubleShooting" type="e8cecc67:BranchNodeDescriptor" />
|
|
123
|
+
<item name="GROUP_NODE:Agora-WebRTC-Troubleshooting" type="e8cecc67:BranchNodeDescriptor" />
|
|
124
|
+
</path>
|
|
125
|
+
<path>
|
|
126
|
+
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
127
|
+
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
128
|
+
<item name="GROUP_NODE:origin" type="e8cecc67:BranchNodeDescriptor" />
|
|
129
|
+
<item name="GROUP_NODE:dev" type="e8cecc67:BranchNodeDescriptor" />
|
|
130
|
+
</path>
|
|
131
|
+
<path>
|
|
132
|
+
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
133
|
+
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
|
134
|
+
<item name="GROUP_NODE:origin" type="e8cecc67:BranchNodeDescriptor" />
|
|
135
|
+
<item name="GROUP_NODE:golem" type="e8cecc67:BranchNodeDescriptor" />
|
|
136
|
+
</path>
|
|
137
|
+
</expand>
|
|
138
|
+
<select />
|
|
139
|
+
</component>
|
|
140
|
+
<component name="ChangeListManager">
|
|
141
|
+
<list default="true" id="d6507ff0-2195-45b1-a54e-445b180f6ba8" name="Default Changelist" comment="chore(nodejs): remove chat_user_id" />
|
|
142
|
+
<option name="SHOW_DIALOG" value="false" />
|
|
143
|
+
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
144
|
+
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
|
145
|
+
<option name="LAST_RESOLUTION" value="IGNORE" />
|
|
146
|
+
</component>
|
|
147
|
+
<component name="ComposerSettings">
|
|
148
|
+
<execution />
|
|
149
|
+
</component>
|
|
150
|
+
<component name="Git.Settings">
|
|
151
|
+
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/../../.." />
|
|
152
|
+
</component>
|
|
153
|
+
<component name="MarkdownSettingsMigration">
|
|
154
|
+
<option name="stateVersion" value="1" />
|
|
155
|
+
</component>
|
|
156
|
+
<component name="ProjectId" id="1xG1JQ4BoYLfSQMJPv43drgX0sB" />
|
|
157
|
+
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
|
|
158
|
+
<component name="ProjectViewState">
|
|
159
|
+
<option name="hideEmptyMiddlePackages" value="true" />
|
|
160
|
+
<option name="showLibraryContents" value="true" />
|
|
161
|
+
</component>
|
|
162
|
+
<component name="PropertiesComponent"><![CDATA[{
|
|
163
|
+
"keyToString": {
|
|
164
|
+
"WebServerToolWindowFactoryState": "false",
|
|
165
|
+
"dart.analysis.tool.window.visible": "false",
|
|
166
|
+
"nodejs_package_manager_path": "npm",
|
|
167
|
+
"vue.rearranger.settings.migration": "true"
|
|
168
|
+
}
|
|
169
|
+
}]]></component>
|
|
170
|
+
<component name="RecentsManager">
|
|
171
|
+
<key name="CopyFile.RECENT_KEYS">
|
|
172
|
+
<recent name="$PROJECT_DIR$/sample" />
|
|
173
|
+
<recent name="$PROJECT_DIR$/test" />
|
|
174
|
+
<recent name="$PROJECT_DIR$/src" />
|
|
175
|
+
</key>
|
|
176
|
+
</component>
|
|
177
|
+
<component name="RunManager" selected="Node.js.AccessToken2Test.js">
|
|
178
|
+
<configuration name="AccessToken2Sample.js" type="NodeJSConfigurationType" temporary="true" nameIsGenerated="true" path-to-js-file="$PROJECT_DIR$/sample/AccessToken2Sample.js" working-dir="$PROJECT_DIR$/sample">
|
|
179
|
+
<method v="2" />
|
|
180
|
+
</configuration>
|
|
181
|
+
<configuration name="AccessToken2Test.js" type="NodeJSConfigurationType" temporary="true" nameIsGenerated="true" path-to-js-file="$PROJECT_DIR$/test/AccessToken2Test.js" working-dir="$PROJECT_DIR$/test">
|
|
182
|
+
<method v="2" />
|
|
183
|
+
</configuration>
|
|
184
|
+
<configuration name="FpaTokenBuilderSample.js" type="NodeJSConfigurationType" temporary="true" nameIsGenerated="true" path-to-js-file="$PROJECT_DIR$/sample/FpaTokenBuilderSample.js" working-dir="$PROJECT_DIR$/sample">
|
|
185
|
+
<method v="2" />
|
|
186
|
+
</configuration>
|
|
187
|
+
<configuration name="RtcTokenBuilder2Sample.js" type="NodeJSConfigurationType" temporary="true" nameIsGenerated="true" path-to-js-file="$PROJECT_DIR$/sample/RtcTokenBuilder2Sample.js" working-dir="$PROJECT_DIR$/sample">
|
|
188
|
+
<method v="2" />
|
|
189
|
+
</configuration>
|
|
190
|
+
<configuration name="RtcTokenBuilder2Test.js" type="NodeJSConfigurationType" temporary="true" nameIsGenerated="true" path-to-js-file="$PROJECT_DIR$/test/RtcTokenBuilder2Test.js" working-dir="$PROJECT_DIR$/test">
|
|
191
|
+
<method v="2" />
|
|
192
|
+
</configuration>
|
|
193
|
+
<recent_temporary>
|
|
194
|
+
<list>
|
|
195
|
+
<item itemvalue="Node.js.AccessToken2Test.js" />
|
|
196
|
+
<item itemvalue="Node.js.RtcTokenBuilder2Sample.js" />
|
|
197
|
+
<item itemvalue="Node.js.AccessToken2Sample.js" />
|
|
198
|
+
<item itemvalue="Node.js.RtcTokenBuilder2Test.js" />
|
|
199
|
+
<item itemvalue="Node.js.FpaTokenBuilderSample.js" />
|
|
200
|
+
</list>
|
|
201
|
+
</recent_temporary>
|
|
202
|
+
</component>
|
|
203
|
+
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
|
204
|
+
<component name="SvnConfiguration">
|
|
205
|
+
<configuration />
|
|
206
|
+
</component>
|
|
207
|
+
<component name="TaskManager">
|
|
208
|
+
<task active="true" id="Default" summary="Default task">
|
|
209
|
+
<changelist id="d6507ff0-2195-45b1-a54e-445b180f6ba8" name="Default Changelist" comment="" />
|
|
210
|
+
<created>1629966538838</created>
|
|
211
|
+
<option name="number" value="Default" />
|
|
212
|
+
<option name="presentableId" value="Default" />
|
|
213
|
+
<updated>1629966538838</updated>
|
|
214
|
+
<workItem from="1629966540332" duration="4662000" />
|
|
215
|
+
<workItem from="1629982312897" duration="898000" />
|
|
216
|
+
<workItem from="1631965358288" duration="642000" />
|
|
217
|
+
<workItem from="1636426199825" duration="19504000" />
|
|
218
|
+
<workItem from="1636513011845" duration="73000" />
|
|
219
|
+
<workItem from="1636514196185" duration="205000" />
|
|
220
|
+
<workItem from="1640083978203" duration="1072000" />
|
|
221
|
+
<workItem from="1644560749223" duration="594000" />
|
|
222
|
+
<workItem from="1645514970967" duration="696000" />
|
|
223
|
+
<workItem from="1646282495653" duration="34000" />
|
|
224
|
+
<workItem from="1658144373539" duration="146000" />
|
|
225
|
+
</task>
|
|
226
|
+
<task id="LOCAL-00001" summary="chore(nodejs): remove chat_user_id">
|
|
227
|
+
<created>1645515622711</created>
|
|
228
|
+
<option name="number" value="00001" />
|
|
229
|
+
<option name="presentableId" value="LOCAL-00001" />
|
|
230
|
+
<option name="project" value="LOCAL" />
|
|
231
|
+
<updated>1645515622711</updated>
|
|
232
|
+
</task>
|
|
233
|
+
<option name="localTasksCounter" value="2" />
|
|
234
|
+
<servers />
|
|
235
|
+
</component>
|
|
236
|
+
<component name="TypeScriptGeneratedFilesManager">
|
|
237
|
+
<option name="version" value="3" />
|
|
238
|
+
</component>
|
|
239
|
+
<component name="Vcs.Log.History.Properties">
|
|
240
|
+
<option name="COLUMN_ORDER">
|
|
241
|
+
<list>
|
|
242
|
+
<option value="0" />
|
|
243
|
+
<option value="2" />
|
|
244
|
+
<option value="3" />
|
|
245
|
+
<option value="1" />
|
|
246
|
+
</list>
|
|
247
|
+
</option>
|
|
248
|
+
</component>
|
|
249
|
+
<component name="Vcs.Log.Tabs.Properties">
|
|
250
|
+
<option name="TAB_STATES">
|
|
251
|
+
<map>
|
|
252
|
+
<entry key="MAIN">
|
|
253
|
+
<value>
|
|
254
|
+
<State />
|
|
255
|
+
</value>
|
|
256
|
+
</entry>
|
|
257
|
+
<entry key="fdebcdb2-373f-442c-a682-22825be581ed">
|
|
258
|
+
<value>
|
|
259
|
+
<State>
|
|
260
|
+
<option name="SHOW_ONLY_AFFECTED_CHANGES" value="true" />
|
|
261
|
+
<option name="FILTERS">
|
|
262
|
+
<map>
|
|
263
|
+
<entry key="branch">
|
|
264
|
+
<value>
|
|
265
|
+
<list>
|
|
266
|
+
<option value="HEAD" />
|
|
267
|
+
</list>
|
|
268
|
+
</value>
|
|
269
|
+
</entry>
|
|
270
|
+
<entry key="structure">
|
|
271
|
+
<value>
|
|
272
|
+
<list>
|
|
273
|
+
<option value="dir:/Users/lxh/sunshine/www/pj/agora/github.com/AgoraIO/Tools/DynamicKey/AgoraDynamicKey/nodejs" />
|
|
274
|
+
</list>
|
|
275
|
+
</value>
|
|
276
|
+
</entry>
|
|
277
|
+
</map>
|
|
278
|
+
</option>
|
|
279
|
+
</State>
|
|
280
|
+
</value>
|
|
281
|
+
</entry>
|
|
282
|
+
</map>
|
|
283
|
+
</option>
|
|
284
|
+
<option name="OPEN_GENERIC_TABS">
|
|
285
|
+
<map>
|
|
286
|
+
<entry key="fdebcdb2-373f-442c-a682-22825be581ed" value="TOOL_WINDOW" />
|
|
287
|
+
</map>
|
|
288
|
+
</option>
|
|
289
|
+
</component>
|
|
290
|
+
<component name="VcsManagerConfiguration">
|
|
291
|
+
<MESSAGE value="chore(nodejs): remove chat_user_id" />
|
|
292
|
+
<option name="LAST_COMMIT_MESSAGE" value="chore(nodejs): remove chat_user_id" />
|
|
293
|
+
</component>
|
|
294
|
+
</project>
|
package/index.d.ts
CHANGED
|
@@ -230,3 +230,32 @@ export namespace FpaTokenBuilder {
|
|
|
230
230
|
*/
|
|
231
231
|
export function buildToken(appId: string, appCertificate: string): string;
|
|
232
232
|
}
|
|
233
|
+
|
|
234
|
+
export namespace ChatTokenBuilder {
|
|
235
|
+
/**
|
|
236
|
+
* Build the Chat user token.
|
|
237
|
+
*
|
|
238
|
+
* @param appId The App ID issued to you by Agora. Apply for a new App ID from
|
|
239
|
+
* Agora Dashboard if it is missing from your kit. See Get an App ID.
|
|
240
|
+
* @param appCertificate Certificate of the application that you registered in
|
|
241
|
+
* the Agora Dashboard. See Get an App Certificate.
|
|
242
|
+
* @param userUuid The user's id, must be unique.
|
|
243
|
+
* @param expire represented by the number of seconds elapsed since now. If, for example, you want to access the
|
|
244
|
+
* Agora Service within 10 minutes after the token is generated, set expireTimestamp as 600(seconds).
|
|
245
|
+
* @return The chat user token.
|
|
246
|
+
*/
|
|
247
|
+
export function buildUserToken(appId: string, appCertificate: string, userId: string | number, expire: number): string;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Build the Chat App token.
|
|
251
|
+
*
|
|
252
|
+
* @param appId The App ID issued to you by Agora. Apply for a new App ID from
|
|
253
|
+
* Agora Dashboard if it is missing from your kit. See Get an App ID.
|
|
254
|
+
* @param appCertificate Certificate of the application that you registered in
|
|
255
|
+
* the Agora Dashboard. See Get an App Certificate.
|
|
256
|
+
* @param expire represented by the number of seconds elapsed since now. If, for example, you want to access the
|
|
257
|
+
* Agora Service within 10 minutes after the token is generated, set expireTimestamp as 600(seconds).
|
|
258
|
+
* @return The chat App token.
|
|
259
|
+
*/
|
|
260
|
+
export function buildAppToken(appId: string, appCertificate: string, expire: number): string;
|
|
261
|
+
}
|
package/index.js
CHANGED
|
@@ -3,5 +3,6 @@ module.exports = {
|
|
|
3
3
|
RtcRole: require('./src/RtcTokenBuilder2').Role,
|
|
4
4
|
RtmTokenBuilder: require('./src/RtmTokenBuilder2').RtmTokenBuilder,
|
|
5
5
|
EducationTokenBuilder: require('./src/EducationTokenBuilder').EducationTokenBuilder,
|
|
6
|
-
FpaTokenBuilder: require('./src/FpaTokenBuilder').FpaTokenBuilder
|
|
6
|
+
FpaTokenBuilder: require('./src/FpaTokenBuilder').FpaTokenBuilder,
|
|
7
|
+
ChatTokenBuilder: require('./src/ChatTokenBuilder').ChatTokenBuilder
|
|
7
8
|
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const ChatTokenBuilder = require("../src/ChatTokenBuilder").ChatTokenBuilder;
|
|
2
|
+
const appId = "970CA35de60c44645bbae8a215061b33";
|
|
3
|
+
const appCertificate = "5CFd2fd1755d40ecb72977518be15d3b";
|
|
4
|
+
const userUuid = "a7180cb0-1d4a-11ed-9210-89ff47c9da5e";
|
|
5
|
+
const expirationInSeconds = 600;
|
|
6
|
+
|
|
7
|
+
const userToken = ChatTokenBuilder.buildUserToken(appId, appCertificate, userUuid, expirationInSeconds);
|
|
8
|
+
console.log("Chat User Token: " + userToken + "\n");
|
|
9
|
+
|
|
10
|
+
const appToken = ChatTokenBuilder.buildAppToken(appId, appCertificate, expirationInSeconds)
|
|
11
|
+
console.log("Chat App Token: " + appToken);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const AccessToken = require("../src/AccessToken2").AccessToken2;
|
|
2
|
+
const ServiceChat = require("../src/AccessToken2").ServiceChat;
|
|
3
|
+
|
|
4
|
+
class ChatTokenBuilder {
|
|
5
|
+
/**
|
|
6
|
+
* Build the Chat user token.
|
|
7
|
+
*
|
|
8
|
+
* @param appId The App ID issued to you by Agora. Apply for a new App ID from
|
|
9
|
+
* Agora Dashboard if it is missing from your kit. See Get an App ID.
|
|
10
|
+
* @param appCertificate Certificate of the application that you registered in
|
|
11
|
+
* the Agora Dashboard. See Get an App Certificate.
|
|
12
|
+
* @param userUuid The user's id, must be unique.
|
|
13
|
+
* @param expire represented by the number of seconds elapsed since now. If, for example, you want to access the
|
|
14
|
+
* Agora Service within 10 minutes after the token is generated, set expireTimestamp as 600(seconds).
|
|
15
|
+
* @return The chat user token.
|
|
16
|
+
*/
|
|
17
|
+
static buildUserToken(appId, appCertificate, userUuid, expire) {
|
|
18
|
+
const token = new AccessToken(appId, appCertificate, null, expire);
|
|
19
|
+
const serviceChat = new ServiceChat(userUuid);
|
|
20
|
+
serviceChat.add_privilege(ServiceChat.kPrivilegeUser, expire);
|
|
21
|
+
token.add_service(serviceChat);
|
|
22
|
+
return token.build();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Build the Chat App token.
|
|
27
|
+
*
|
|
28
|
+
* @param appId The App ID issued to you by Agora. Apply for a new App ID from
|
|
29
|
+
* Agora Dashboard if it is missing from your kit. See Get an App ID.
|
|
30
|
+
* @param appCertificate Certificate of the application that you registered in
|
|
31
|
+
* the Agora Dashboard. See Get an App Certificate.
|
|
32
|
+
* @param expire represented by the number of seconds elapsed since now. If, for example, you want to access the
|
|
33
|
+
* Agora Service within 10 minutes after the token is generated, set expireTimestamp as 600(seconds).
|
|
34
|
+
* @return The chat App token.
|
|
35
|
+
*/
|
|
36
|
+
static buildAppToken(appId, appCertificate, expire) {
|
|
37
|
+
const token = new AccessToken(appId, appCertificate, null, expire);
|
|
38
|
+
const serviceChat = new ServiceChat();
|
|
39
|
+
serviceChat.add_privilege(ServiceChat.kPrivilegeApp, expire);
|
|
40
|
+
token.add_service(serviceChat);
|
|
41
|
+
return token.build();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
exports.ChatTokenBuilder = ChatTokenBuilder;
|
|
46
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* run this test with command:
|
|
3
|
+
* nodeunit ChatTokenBuilderTest.js
|
|
4
|
+
* see https://github.com/caolan/nodeunit
|
|
5
|
+
*/
|
|
6
|
+
const ChatTokenBuilder = require("../src/ChatTokenBuilder").ChatTokenBuilder;
|
|
7
|
+
const { AccessToken2, ServiceChat, kChatServiceType } = require("../src/AccessToken2");
|
|
8
|
+
|
|
9
|
+
const appId = "970CA35de60c44645bbae8a215061b33";
|
|
10
|
+
const appCertificate = "5CFd2fd1755d40ecb72977518be15d3b";
|
|
11
|
+
const userUuid = "2882341273";
|
|
12
|
+
const expire = 600;
|
|
13
|
+
|
|
14
|
+
exports.buildUserToken_Test = function (test) {
|
|
15
|
+
let token = ChatTokenBuilder.buildUserToken(appId, appCertificate, userUuid, expire);
|
|
16
|
+
let accessToken = new AccessToken2("", "", 0, 0);
|
|
17
|
+
accessToken.from_string(token);
|
|
18
|
+
test.equal(appId, accessToken.appId);
|
|
19
|
+
test.equal(expire, accessToken.expire);
|
|
20
|
+
test.equal(userUuid, accessToken.services[kChatServiceType].__user_id);
|
|
21
|
+
test.equal(expire, accessToken.services[kChatServiceType].__privileges[ServiceChat.kPrivilegeUser]);
|
|
22
|
+
test.done();
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
exports.buildAppToken_Test = function (test) {
|
|
26
|
+
let token = ChatTokenBuilder.buildAppToken(appId, appCertificate, expire);
|
|
27
|
+
let accessToken = new AccessToken2("", "", 0, 0);
|
|
28
|
+
accessToken.from_string(token);
|
|
29
|
+
test.equal(appId, accessToken.appId);
|
|
30
|
+
test.equal(expire, accessToken.expire);
|
|
31
|
+
test.equal(expire, accessToken.services[kChatServiceType].__privileges[ServiceChat.kPrivilegeApp]);
|
|
32
|
+
test.done();
|
|
33
|
+
}
|
|
34
|
+
|