@@ -32,7 +32,8 @@ const encoded = [
32
32
[ 'base64pad' , 'MRGVjZW50cmFsaXplIGV2ZXJ5dGhpbmchIQ==' ] ,
33
33
[ 'base64url' , 'uRGVjZW50cmFsaXplIGV2ZXJ5dGhpbmchIQ' ] ,
34
34
[ 'base64urlpad' , 'URGVjZW50cmFsaXplIGV2ZXJ5dGhpbmchIQ==' ] ,
35
- [ 'base256emoji' , '🚀💛✋💃✋😻😈🥺🤤🍀🌟💐✋😅✋💦✋🥺🏃😈😴🌟😻😝👏👏' ]
35
+ [ 'base256emoji' , '🚀💛✋💃✋😻😈🥺🤤🍀🌟💐✋😅✋💦✋🥺🏃😈😴🌟😻😝👏👏' ] ,
36
+ [ 'proquint' , 'phidoj-katoj-kunuh-lanod-kudon-lonoj-fadoj-linoj-lanun-lidom-kojov-kisod-fah' ]
36
37
]
37
38
} ,
38
39
{
@@ -62,7 +63,8 @@ const encoded = [
62
63
[ 'base64pad' , 'MeWVzIG1hbmkgIQ==' ] ,
63
64
[ 'base64url' , 'ueWVzIG1hbmkgIQ' ] ,
64
65
[ 'base64urlpad' , 'UeWVzIG1hbmkgIQ==' ] ,
65
- [ 'base256emoji' , '🚀🏃✋🌈😅🌷🤤😻🌟😅👏' ]
66
+ [ 'base256emoji' , '🚀🏃✋🌈😅🌷🤤😻🌟😅👏' ] ,
67
+ [ 'proquint' , 'plojoj-lasob-kujod-kunon-fabod' ]
66
68
]
67
69
} ,
68
70
{
@@ -92,7 +94,8 @@ const encoded = [
92
94
[ 'base64pad' , 'MaGVsbG8gd29ybGQ=' ] ,
93
95
[ 'base64url' , 'uaGVsbG8gd29ybGQ' ] ,
94
96
[ 'base64urlpad' , 'UaGVsbG8gd29ybGQ=' ] ,
95
- [ 'base256emoji' , '🚀😴✋🍀🍀😓😅✔😓🥺🍀😳' ]
97
+ [ 'base256emoji' , '🚀😴✋🍀🍀😓😅✔😓🥺🍀😳' ] ,
98
+ [ 'proquint' , 'pkodoj-kudos-kusob-litoz-lanos-kib' ]
96
99
]
97
100
} ,
98
101
{
@@ -122,7 +125,8 @@ const encoded = [
122
125
[ 'base64pad' , 'MAHllcyBtYW5pICE=' ] ,
123
126
[ 'base64url' , 'uAHllcyBtYW5pICE' ] ,
124
127
[ 'base64urlpad' , 'UAHllcyBtYW5pICE=' ] ,
125
- [ 'base256emoji' , '🚀🚀🏃✋🌈😅🌷🤤😻🌟😅👏' ]
128
+ [ 'base256emoji' , '🚀🚀🏃✋🌈😅🌷🤤😻🌟😅👏' ] ,
129
+ [ 'proquint' , 'pbadun-kijug-fadot-kajov-kohob-fah' ]
126
130
]
127
131
} ,
128
132
{
@@ -152,13 +156,31 @@ const encoded = [
152
156
[ 'base64pad' , 'MAAB5ZXMgbWFuaSAh' ] ,
153
157
[ 'base64url' , 'uAAB5ZXMgbWFuaSAh' ] ,
154
158
[ 'base64urlpad' , 'UAAB5ZXMgbWFuaSAh' ] ,
155
- [ 'base256emoji' , '🚀🚀🚀🏃✋🌈😅🌷🤤😻🌟😅👏' ]
159
+ [ 'base256emoji' , '🚀🚀🚀🏃✋🌈😅🌷🤤😻🌟😅👏' ] ,
160
+ [ 'proquint' , 'pbabab-lojoj-lasob-kujod-kunon-fabod' ]
156
161
]
157
162
} ,
163
+
164
+ // RFC9285 examples
158
165
{ input : 'AB' , tests : [ [ 'base45' , 'RBB8' ] ] } ,
159
166
{ input : 'Hello!!' , tests : [ [ 'base45' , 'R%69 VD92EX0' ] ] } ,
160
167
{ input : 'base-45' , tests : [ [ 'base45' , 'RUJCLQE7W581' ] ] } ,
161
168
{ input : 'ietf!' , tests : [ [ 'base45' , 'RQED8WEX0' ] ] }
169
+
170
+ // proquint spec examples, IPv4 addresses
171
+ { input : Uint8Array . from ( [ 127 , 0 , 0 , 1 ] ) , tests : [ [ 'proquint' , 'plusab-babad' ] ] } , // 127.0.0.1
172
+ { input : Uint8Array . from ( [ 63 , 84 , 220 , 193 ] ) , tests : [ [ 'proquint' , 'pgutih-tugad' ] ] } , // 63.84.220.193
173
+ { input : Uint8Array . from ( [ 63 , 118 , 7 , 35 ] ) , tests : [ [ 'proquint' , 'pgutuk-bisog' ] ] } , // 63.118.7.35
174
+ { input : Uint8Array . from ( [ 140 , 98 , 193 , 141 ] ) , tests : [ [ 'proquint' , 'pmudof-sakat' ] ] } , // 140.98.193.141
175
+ { input : Uint8Array . from ( [ 64 , 255 , 6 , 200 ] ) , tests : [ [ 'proquint' , 'phaguz-biram' ] ] } , // 64.255.6.200
176
+ { input : Uint8Array . from ( [ 128 , 30 , 52 , 45 ] ) , tests : [ [ 'proquint' , 'pmabiv-gibot' ] ] } , // 128.30.52.45
177
+ { input : Uint8Array . from ( [ 147 , 67 , 119 , 2 ] ) , tests : [ [ 'proquint' , 'pnatag-lisaf' ] ] } , // 147.67.119.2
178
+ { input : Uint8Array . from ( [ 212 , 58 , 253 , 68 ] ) , tests : [ [ 'proquint' , 'ptibup-zujah' ] ] } , // 212.58.253.68
179
+ { input : Uint8Array . from ( [ 216 , 35 , 68 , 215 ] ) , tests : [ [ 'proquint' , 'ptobog-higil' ] ] } , // 216.35.68.215
180
+ { input : Uint8Array . from ( [ 216 , 68 , 232 , 21 ] ) , tests : [ [ 'proquint' , 'ptodah-vobij' ] ] } , // 216.68.232.21
181
+ { input : Uint8Array . from ( [ 198 , 81 , 129 , 136 ] ) , tests : [ [ 'proquint' , 'psinid-makam' ] ] } , // 198.81.129.136
182
+ { input : Uint8Array . from ( [ 12 , 110 , 110 , 204 ] ) , tests : [ [ 'proquint' , 'pbudov-kuras' ] ] } // 12.110.110.204
183
+ >>> > >>> bc54e9a ( feat : add proquint multibase )
162
184
]
163
185
164
186
describe ( 'spec test' , ( ) => {
@@ -169,13 +191,15 @@ describe('spec test', () => {
169
191
const base = bases [ name as keyof typeof bases ]
170
192
171
193
describe ( name , ( ) => {
194
+ const byteInput = typeof input === 'string' ? fromString ( input ) : input
195
+
172
196
it ( `should encode from buffer [${ input } ]` , ( ) => {
173
- const out = base . encode ( fromString ( input ) )
197
+ const out = base . encode ( byteInput )
174
198
assert . deepStrictEqual ( out , output )
175
199
} )
176
200
177
201
it ( `should decode from string [${ input } ]` , ( ) => {
178
- assert . deepStrictEqual ( base . decode ( output ) , fromString ( input ) )
202
+ assert . deepStrictEqual ( base . decode ( output ) , byteInput )
179
203
} )
180
204
} )
181
205
}
@@ -196,4 +220,11 @@ describe('spec test', () => {
196
220
// not enough input chars, should be multiple of 3 or multiple of 3 + 2
197
221
assert . throws ( ( ) => bases . base45 . decode ( 'R%69 VD92EX' ) , 'Unexpected end of data' )
198
222
} )
223
+
224
+ it ( 'proquint should fail with invalid input' , ( ) => {
225
+ assert . throws ( ( ) => bases . proquint . decode ( 'plojoj-lasob-kujod-kunon-' ) , 'Unexpected end of data' )
226
+ assert . throws ( ( ) => bases . proquint . decode ( 'plojoj-lasob-kujod-kunon-f' ) , 'Unexpected end of data' )
227
+ assert . throws ( ( ) => bases . proquint . decode ( 'plojoj-lasob-kujod-kunon-fa' ) , 'Unexpected end of data' )
228
+ assert . throws ( ( ) => bases . proquint . decode ( 'plojoj-lasob-kujod-kunon-fabo' ) , 'Unexpected end of data' )
229
+ } )
199
230
} )
0 commit comments