File tree Expand file tree Collapse file tree 2 files changed +59
-0
lines changed Expand file tree Collapse file tree 2 files changed +59
-0
lines changed Original file line number Diff line number Diff line change
1
+ /// <reference path="urlsafe-base64.d.ts" />
2
+
3
+ import URLSafeBase64 = require( 'urlsafe-base64' ) ;
4
+
5
+ var base64 = URLSafeBase64 . encode ( new Buffer ( '3Rpbmd1aXNoZWQ' , 'base64' ) ) ;
6
+
7
+ var buf = URLSafeBase64 . decode ( '3Rpbmd1aXNoZWQ' ) ;
8
+
9
+ var isValid = URLSafeBase64 . validate ( '3Rpbmd1aXNoZWQ' ) ;
Original file line number Diff line number Diff line change
1
+ // Type definitions for urlsafe-base64 v1.0.0
2
+ // Project: https://github.com/RGBboy/urlsafe-base64
3
+ // Definitions by: Tanguy Krotoff <https://github.com/tkrotoff>
4
+ // Definitions: https://github.com/borisyankov/DefinitelyTyped
5
+
6
+ /// <reference path="../node/node.d.ts"/>
7
+
8
+ declare module 'urlsafe-base64' {
9
+ /**
10
+ * Library version.
11
+ */
12
+ export var version : string ;
13
+
14
+ /**
15
+ * .encode
16
+ *
17
+ * return an encoded Buffer as URL Safe Base64
18
+ *
19
+ * Note: This function encodes to the RFC 4648 Spec where '+' is encoded
20
+ * as '-' and '/' is encoded as '_'. The padding character '=' is
21
+ * removed.
22
+ *
23
+ * @param {Buffer } buffer
24
+ * @return {String }
25
+ * @api public
26
+ */
27
+ export function encode ( buffer : Buffer ) : string ;
28
+
29
+ /**
30
+ * .decode
31
+ *
32
+ * return an decoded URL Safe Base64 as Buffer
33
+ *
34
+ * @param {String }
35
+ * @return {Buffer }
36
+ * @api public
37
+ */
38
+ export function decode ( base64 : string ) : Buffer ;
39
+
40
+ /**
41
+ * .validate
42
+ *
43
+ * Validates a string if it is URL Safe Base64 encoded.
44
+ *
45
+ * @param {String }
46
+ * @return {Boolean }
47
+ * @api public
48
+ */
49
+ export function validate ( base64 : string ) : boolean ;
50
+ }
You can’t perform that action at this time.
0 commit comments