You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To import an existing Key (as a JSON object or Key instance):
158
+
151
159
```
152
160
// input is either a:
153
161
// * jose.JWK.Key to copy from; or
@@ -161,6 +169,7 @@ keystore.add(input).
161
169
```
162
170
163
171
To generate a new Key:
172
+
164
173
```
165
174
// first argument is the key type (kty)
166
175
// second is the key size (in bits) or named curve ('crv') for "EC"
@@ -192,6 +201,7 @@ kestyore.remove(key);
192
201
### Importing and Exporting a Single Key ###
193
202
194
203
To import a single Key (as a JSON Object, or String serialized JSON Object):
204
+
195
205
```
196
206
jose.JWK.asKey(input).
197
207
then(function(result) {
@@ -215,6 +225,7 @@ var output = key.toJSON(true);
215
225
### Signing Content ###
216
226
217
227
At its simplest, to create a JWS:
228
+
218
229
```
219
230
// {input} is a Buffer
220
231
jose.JWS.createSign(key).
@@ -228,6 +239,7 @@ jose.JWS.createSign(key).
228
239
The JWS is signed using the preferred algorithm appropriate for the given Key. The preferred algorithm is the first item returned by `key.algorithms("sign")`.
229
240
230
241
To create a JWS using another serialization format:
To convert a [Typed Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays), [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer), or Array of Numbers to a Buffer:
435
+
411
436
```
412
437
buff = jose.util.asBuffer(input);
413
438
```
414
439
415
440
### URI-Safe Base64 ###
416
441
417
442
To convert from a Buffer to a base64uri-encoded String:
443
+
418
444
```
419
445
var output = jose.util.base64url.encode(input);
420
446
```
421
447
422
448
To convert a String to a base64uri-encoded String:
0 commit comments