typepki-strconv 0.1.0
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/LICENSE +21 -0
- package/README.md +22 -0
- package/dist/import/conv.d.mts +193 -0
- package/dist/import/conv.d.mts.map +1 -0
- package/dist/import/conv_arybuf.d.mts +30 -0
- package/dist/import/conv_arybuf.d.mts.map +1 -0
- package/dist/import/conv_ba.d.mts +27 -0
- package/dist/import/conv_ba.d.mts.map +1 -0
- package/dist/import/conv_ip.d.mts +69 -0
- package/dist/import/conv_ip.d.mts.map +1 -0
- package/dist/import/conv_iso88591.d.mts +19 -0
- package/dist/import/conv_iso88591.d.mts.map +1 -0
- package/dist/import/conv_pem.d.mts +109 -0
- package/dist/import/conv_pem.d.mts.map +1 -0
- package/dist/import/conv_ucs2.d.mts +14 -0
- package/dist/import/conv_ucs2.d.mts.map +1 -0
- package/dist/import/conv_uricmp.d.mts +29 -0
- package/dist/import/conv_uricmp.d.mts.map +1 -0
- package/dist/import/conv_zulu.d.mts +120 -0
- package/dist/import/conv_zulu.d.mts.map +1 -0
- package/dist/import/index.d.mts +22 -0
- package/dist/import/index.d.mts.map +1 -0
- package/dist/import/index.mjs +4 -0
- package/dist/require/index.cjs +4 -0
- package/dist/require/index.d.cts +2 -0
- package/dist/require/index.d.cts.map +1 -0
- package/package.json +72 -0
- package/src/conv.mts +367 -0
- package/src/conv.test.mts +99 -0
- package/src/conv_arybuf.mts +53 -0
- package/src/conv_arybuf.test.mts +16 -0
- package/src/conv_ba.mts +52 -0
- package/src/conv_ip.mts +226 -0
- package/src/conv_iso88591.mts +63 -0
- package/src/conv_pem.mts +160 -0
- package/src/conv_ucs2.mts +47 -0
- package/src/conv_uricmp.mts +48 -0
- package/src/conv_uricmp.test.mts +16 -0
- package/src/conv_zulu.mts +208 -0
- package/src/conv_zulu.test.mts +49 -0
- package/src/index.cts +1 -0
- package/src/index.mts +100 -0
- package/tsconfig.json +19 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Kenji Urushima
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
typepki-strconv: TypePKI string converters and utilities sub module for TypePKI library
|
|
2
|
+
====================================================================================
|
|
3
|
+
|
|
4
|
+
The 'TypePKI' library is an opensource free TypeScript PKI library which is the successor of the long lived [jsrsasign](https://kjur.github.io/jsrsasign) library.
|
|
5
|
+
|
|
6
|
+
The 'typepki-strconv' is a TypeScript string converters and utilities sub module for TypePKI library.
|
|
7
|
+
|
|
8
|
+
Following string types are supported:
|
|
9
|
+
- Base64 and Base64URL encoded string
|
|
10
|
+
- hexadecimal string
|
|
11
|
+
- ArrayBuffer
|
|
12
|
+
- Zule time
|
|
13
|
+
- UTF8 string
|
|
14
|
+
- raw string
|
|
15
|
+
- ISO 8859-1 latin string
|
|
16
|
+
- PEM string
|
|
17
|
+
- UCS2 string
|
|
18
|
+
- byte array
|
|
19
|
+
- IPv4 and v6 address
|
|
20
|
+
|
|
21
|
+
## FEATURE
|
|
22
|
+
- Dual CommonJS/ES module package supporting CommonJS(CJS) and ES modules
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
export declare function b64tohex(b64: string): string;
|
|
2
|
+
export declare function hextob64(hex: string): string;
|
|
3
|
+
export declare function b64toutf8(b64: string): string;
|
|
4
|
+
export declare function utf8tob64(u8: string): string;
|
|
5
|
+
export declare function b64utoutf8(b64u: string): string;
|
|
6
|
+
export declare function utf8tob64u(u8: string): string;
|
|
7
|
+
export declare function hextoutf8(hex: string): string;
|
|
8
|
+
export declare function utf8tohex(u8: string): string;
|
|
9
|
+
export declare function b64utohex(b64u: string): string;
|
|
10
|
+
export declare function hextob64u(hex: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* convert a hexadecimal string to raw string
|
|
13
|
+
* @param hex hexadecimal string
|
|
14
|
+
* @return rawstring
|
|
15
|
+
* @see {@link rstrtohex}
|
|
16
|
+
* @example
|
|
17
|
+
* hextorstr("616161") -> "aaa"
|
|
18
|
+
* hextorstr("610061") -> "a\x00a"
|
|
19
|
+
*/
|
|
20
|
+
export declare function hextorstr(hex: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* convert a raw string to a hexadecimal string
|
|
23
|
+
* @param s raw string
|
|
24
|
+
* @return hexadecimal string
|
|
25
|
+
* @see {@link hextorstr}
|
|
26
|
+
* @example
|
|
27
|
+
* rstrtohex("aaa") -> "616161"
|
|
28
|
+
* rstrtohex("a\x00a") -> "610061"
|
|
29
|
+
*/
|
|
30
|
+
export declare function rstrtohex(s: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* convert a raw string to a Base64 encoded string.
|
|
33
|
+
* @param s raw string
|
|
34
|
+
* @return Base64URL encoded string
|
|
35
|
+
* @example
|
|
36
|
+
* rstrtob64("aaa") -> "YWFh"
|
|
37
|
+
*/
|
|
38
|
+
export declare function rstrtob64(s: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* convert a Base64 encoded string to a Base64URL encoded string.
|
|
41
|
+
* @param sIn - Base64 encoded string
|
|
42
|
+
* @return Base64URL encoded string
|
|
43
|
+
* @see {@link b64utob64}
|
|
44
|
+
* @example
|
|
45
|
+
* b64tob64u("ab+c3f/==") → "ab-c3f_"
|
|
46
|
+
*/
|
|
47
|
+
export declare function b64tob64u(sIn: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* convert a Base64URL encoded string to a Base64 encoded string.
|
|
50
|
+
* @param sIn - Base64URL encoded string
|
|
51
|
+
* @return Base64 encoded string
|
|
52
|
+
* @see {@link b64tob64u}
|
|
53
|
+
* @example
|
|
54
|
+
* b64utob64("ab-c3f_") -> "ab+c3f/=="
|
|
55
|
+
*/
|
|
56
|
+
export declare function b64utob64(sIn: string): string;
|
|
57
|
+
/**
|
|
58
|
+
* convert from binary string to hexadecimal string of ASN.1 BitString value with unused bit<br/>
|
|
59
|
+
* @param s binary string (ex. "101")
|
|
60
|
+
* @return hexadecimal string of ASN.1 BitString value with unused bit
|
|
61
|
+
* @see {@link bitstrtobinstr}
|
|
62
|
+
*
|
|
63
|
+
* @description
|
|
64
|
+
* This function converts from an binary string (ex. "101") to
|
|
65
|
+
* hexadecimal string of ASN.1 BitString value
|
|
66
|
+
* with unused bit (ex. "05a0"). <br/>
|
|
67
|
+
* When "s" is not binary string, this returns null.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* binstrtobitstr("101") -> "05a0"
|
|
71
|
+
* binstrtobitstr("001") -> "0520"
|
|
72
|
+
* binstrtobitstr("11001") -> "03c8"
|
|
73
|
+
* binstrtobitstr("101000001") -> "07a080"
|
|
74
|
+
* binstrtobitstr(101) -> null // not number
|
|
75
|
+
* binstrtobitstr("xyz") -> null // not binary string
|
|
76
|
+
*/
|
|
77
|
+
export declare const binstrtobitstr: (s: string) => string | null;
|
|
78
|
+
/**
|
|
79
|
+
* convert from hexadecimal string of ASN.1 BitString value with unused bit to binary string
|
|
80
|
+
* @param h - hexadecimal string of ASN.1 BitString value with unused bit
|
|
81
|
+
* @return binary string
|
|
82
|
+
* @see {@link binstrtobitstr}
|
|
83
|
+
* @see {@link inttobitstr}
|
|
84
|
+
*
|
|
85
|
+
* @description
|
|
86
|
+
* This function converts from hexadecimal string of ASN.1 BitString
|
|
87
|
+
* value with unused bit to its integer value. <br/>
|
|
88
|
+
* When an improper hexadecimal string of BitString value
|
|
89
|
+
* is applied, this returns null.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* bitstrtobinstr("05a0") -> "101"
|
|
93
|
+
* bitstrtobinstr("0520") -> "001"
|
|
94
|
+
* bitstrtobinstr("07a080") -> "101000001"
|
|
95
|
+
* bitstrtobinstr(502) -> null // non ASN.1 BitString value
|
|
96
|
+
* bitstrtobinstr("ff00") -> null // for improper BitString value
|
|
97
|
+
*/
|
|
98
|
+
export declare function bitstrtobinstr(h: string): string | null;
|
|
99
|
+
/**
|
|
100
|
+
* convert from integer value to hexadecimal string of ASN.1 BitString value with unused bit
|
|
101
|
+
* @param n integer value of ASN.1 BitString
|
|
102
|
+
* @return hexadecimal string of ASN.1 BitString value with unused bit
|
|
103
|
+
* @see bitstrtoint
|
|
104
|
+
*
|
|
105
|
+
* @description
|
|
106
|
+
* This function converts from an integer value to
|
|
107
|
+
* hexadecimal string of ASN.1 BitString value
|
|
108
|
+
* with unused bit. <br/>
|
|
109
|
+
* When "n" is not non-negative number, this returns null
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* // 25 -> 11001b -> 11001000b unusedbit=03 -> 0xc8 unusedbit=03 -> "03c8"
|
|
113
|
+
* inttobitstr(25) -> "03c8"
|
|
114
|
+
* inttobitstr(-3) -> null
|
|
115
|
+
* inttobitstr("abc") -> null
|
|
116
|
+
* inttobitstr(parseInt("11001", 2)) -> "03c8"
|
|
117
|
+
* inttobitstr(parseInt("101", 2)) -> "05a0"
|
|
118
|
+
* inttobitstr(parseInt("101000001", 2)) -> "07a080"
|
|
119
|
+
*/
|
|
120
|
+
export declare function inttobitstr(n: number): string | null;
|
|
121
|
+
/**
|
|
122
|
+
* create padded string with specified length and padding string
|
|
123
|
+
* @param s input string
|
|
124
|
+
* @param len output string length
|
|
125
|
+
* @param defpadchar padding character (default is "0")
|
|
126
|
+
* @return padded string
|
|
127
|
+
* @example
|
|
128
|
+
* strpad("1234", 10, "0") -> "0000001234"
|
|
129
|
+
* strpad("1234", 10, " ") -> " 1234"
|
|
130
|
+
* strpad("1234", 10) -> "0000001234"
|
|
131
|
+
*/
|
|
132
|
+
export declare const strpad: (s: string, len: number, defpadchar?: string) => string;
|
|
133
|
+
/**
|
|
134
|
+
* represents JSON data structure
|
|
135
|
+
* @example
|
|
136
|
+
* let db: Dictionary<number> = { apple: 10, orange: 20 }
|
|
137
|
+
*/
|
|
138
|
+
export interface Dictionary<Type> {
|
|
139
|
+
/**
|
|
140
|
+
* key string
|
|
141
|
+
*/
|
|
142
|
+
[key: string]: Type;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* convert array of names to bit string
|
|
146
|
+
* @param namearray array of name string
|
|
147
|
+
* @param namedb associative array of name and value
|
|
148
|
+
* @return binary string (ex. "110001")
|
|
149
|
+
*
|
|
150
|
+
* @description
|
|
151
|
+
* This function converts from an array of names to
|
|
152
|
+
* a binary string. DB value bit will be set.
|
|
153
|
+
* Note that ordering of namearray items
|
|
154
|
+
* will be ignored.
|
|
155
|
+
* This function may be useful to implement ASN.1 BitString such as KeyUsage.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* let db: Dictionary<number> = { a: 0, b: 3, c: 8, d: 9, e: 17, f: 19 };
|
|
159
|
+
* namearraytobinstr(['a', 'c', 'd'], db) -> '1000000011'
|
|
160
|
+
* namearraytobinstr(['c', 'b'], db) -> '000100001'
|
|
161
|
+
*/
|
|
162
|
+
export declare function namearraytobinstr(namearray: Array<string>, namedb: Dictionary<number>): string;
|
|
163
|
+
/**
|
|
164
|
+
* get value of array by key name list<br/>
|
|
165
|
+
* @param valIn - array of associative array
|
|
166
|
+
* @param sKey - concatinated key list with dot (ex. 'type.name.0.info')
|
|
167
|
+
* @param defIn - default value if value is not found (OPTIONAL)
|
|
168
|
+
* @return value if found otherwise returns def
|
|
169
|
+
*
|
|
170
|
+
* @description
|
|
171
|
+
* This function returns the value of an array or associative array
|
|
172
|
+
* which referred by a concatinated key list string.
|
|
173
|
+
* If a value for key is not defined, it returns 'undefined' by default.
|
|
174
|
+
* When an optional argument 'def' is specified and a value for key is
|
|
175
|
+
* not defined, it returns a value of 'def'.
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* let p = {
|
|
179
|
+
* fruit: apple,
|
|
180
|
+
* info: [
|
|
181
|
+
* { toy: 4 },
|
|
182
|
+
* { pen: 6 }
|
|
183
|
+
* ]
|
|
184
|
+
* };
|
|
185
|
+
* aryval(p, 'fruit') -> "apple"
|
|
186
|
+
* aryval(p, 'info') -> [{toy: 4},{pen: 6}]
|
|
187
|
+
* aryval(p, 'info.1') -> {pen: 6}
|
|
188
|
+
* aryval(p, 'info.1.pen') -> 6
|
|
189
|
+
* aryval(p, 'money.amount') -> undefined
|
|
190
|
+
* aryval(p, 'money.amount', null) -> null
|
|
191
|
+
*/
|
|
192
|
+
export declare function aryval(valIn: any, sKey: string, defIn?: any): any;
|
|
193
|
+
//# sourceMappingURL=conv.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conv.d.mts","sourceRoot":"","sources":["../../src/conv.mts"],"names":[],"mappings":"AACA,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE5C;AAGD,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE5C;AAGD,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE7C;AAGD,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE5C;AAGD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAGD;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO7C;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAM3C;AAGD;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE3C;AAGD;;;;;;;GAOG;AAKH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM7C;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO7C;AAGD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,cAAc,MAAO,MAAM,KAAG,MAAM,GAAG,IAQnD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAoBvD;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AAQH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAWpD;AAOD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,MAAM,MAAO,MAAM,OAAO,MAAM,eAAe,MAAM,KAAG,MAIpE,CAAC;AAGF;;;;GAIG;AACH,MAAM,WAAW,UAAU,CAAC,IAAI;IAC9B;;OAEG;IACH,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;GAiBG;AAQH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,EACxB,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,GACzB,MAAM,CAYR;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,GAAG,CAejE"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* convert a hexadecimal string to an ArrayBuffer
|
|
3
|
+
* @param hex - hexadecimal string
|
|
4
|
+
* @return ArrayBuffer
|
|
5
|
+
*
|
|
6
|
+
* @description
|
|
7
|
+
* This function converts from a hexadecimal string to an ArrayBuffer.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* hextoArrayBuffer("fffa01") -> ArrayBuffer of [255, 250, 1]
|
|
11
|
+
*/
|
|
12
|
+
export declare function hextoArrayBuffer(hex: string): ArrayBuffer;
|
|
13
|
+
/**
|
|
14
|
+
* convert an ArrayBuffer to a hexadecimal string
|
|
15
|
+
* @param buffer - ArrayBuffer
|
|
16
|
+
* @return hexadecimal string
|
|
17
|
+
*
|
|
18
|
+
* @description
|
|
19
|
+
* This function converts from an ArrayBuffer to a hexadecimal string.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* var buffer = new ArrayBuffer(3);
|
|
23
|
+
* var view = new DataView(buffer);
|
|
24
|
+
* view.setUint8(0, 0xfa);
|
|
25
|
+
* view.setUint8(1, 0xfb);
|
|
26
|
+
* view.setUint8(2, 0x01);
|
|
27
|
+
* ArrayBuffertohex(buffer) -> "fafb01"
|
|
28
|
+
*/
|
|
29
|
+
export declare function ArrayBuffertohex(buffer: ArrayBuffer): string;
|
|
30
|
+
//# sourceMappingURL=conv_arybuf.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conv_arybuf.d.mts","sourceRoot":"","sources":["../../src/conv_arybuf.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAYzD;AAID;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAS5D"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* convert a ASCII string to a hexadecimal string of ASCII codes.
|
|
3
|
+
* @description
|
|
4
|
+
* NOTE: This can't be used for non ASCII characters.
|
|
5
|
+
* @param s - ASCII string
|
|
6
|
+
* @return hexadecimal string
|
|
7
|
+
*/
|
|
8
|
+
export declare function stohex(s: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* convert an array of bytes(Number) to hexadecimal string.
|
|
11
|
+
* @param a - a array of bytes
|
|
12
|
+
* @return hexadecimal string
|
|
13
|
+
*/
|
|
14
|
+
export declare function BAtohex(a: Array<number>): string;
|
|
15
|
+
/**
|
|
16
|
+
* convert a string to an array of character codes
|
|
17
|
+
* @param s - string
|
|
18
|
+
* @return array of character code value
|
|
19
|
+
*/
|
|
20
|
+
export declare function stoBA(s: string): Array<number>;
|
|
21
|
+
/**
|
|
22
|
+
* convert an array of character codes to a string
|
|
23
|
+
* @param a - a array of character codes
|
|
24
|
+
* @return string
|
|
25
|
+
*/
|
|
26
|
+
export declare function BAtos(a: Array<number>): string;
|
|
27
|
+
//# sourceMappingURL=conv_ba.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conv_ba.d.mts","sourceRoot":"","sources":["../../src/conv_ba.mts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAExC;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAQhD;AAGD;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAM9C;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAM9C"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* convert any IPv6 address to a 16 byte hexadecimal string
|
|
3
|
+
* @param sIn - ipv6 address string
|
|
4
|
+
* @return 16 byte hexadecimal string of IPv6 address
|
|
5
|
+
*
|
|
6
|
+
* @description
|
|
7
|
+
* This function converts any IPv6 address representation string
|
|
8
|
+
* to a 16 byte hexadecimal string of address.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
*/
|
|
12
|
+
export declare function ipv6tohex(sIn: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* convert a 16 byte hexadecimal string to RFC 5952 canonicalized IPv6 address
|
|
15
|
+
* @param hex - hexadecimal string of 16 byte IPv6 address
|
|
16
|
+
* @return IPv6 address string canonicalized by RFC 5952
|
|
17
|
+
*
|
|
18
|
+
* @description
|
|
19
|
+
* This function converts a 16 byte hexadecimal string to
|
|
20
|
+
* <a href="https://tools.ietf.org/html/rfc5952">RFC 5952</a>
|
|
21
|
+
* canonicalized IPv6 address string.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* hextoipv6("871020010db8000000000000000000000004") -> "2001:db8::4"
|
|
25
|
+
* hextoipv6("871020010db8000000000000000000") -> raise exception
|
|
26
|
+
* hextoipv6("xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz") -> raise exception
|
|
27
|
+
*/
|
|
28
|
+
export declare function hextoipv6(hex: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* convert a hexadecimal string to IP addresss
|
|
31
|
+
* @param s - hexadecimal string of IP address
|
|
32
|
+
* @return IP address string
|
|
33
|
+
*
|
|
34
|
+
* @description
|
|
35
|
+
* This function converts a hexadecimal string of IPv4 or
|
|
36
|
+
* IPv6 address to IPv4 or IPv6 address string.
|
|
37
|
+
* If byte length is not 4 nor 16, this returns a
|
|
38
|
+
* hexadecimal string without conversion.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* hextoip("c0a80101") -> "192.168.1.1"
|
|
42
|
+
* hextoip("871020010db8000000000000000000000004") -> "2001:db8::4"
|
|
43
|
+
* hextoip("c0a80100ffffff00") -> "192.168.1.0/24"
|
|
44
|
+
* hextoip("c0a801010203") -> "c0a801010203" // wrong 6 bytes
|
|
45
|
+
* hextoip("zzz")) -> raise exception because of not hexadecimal
|
|
46
|
+
*/
|
|
47
|
+
export declare function hextoip(s: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* convert IPv4/v6 addresss to a hexadecimal string
|
|
50
|
+
* @param sIn - IPv4/v6 address string
|
|
51
|
+
* @return hexadecimal string of IP address
|
|
52
|
+
* @see hextoip
|
|
53
|
+
* @see ipv6tohex
|
|
54
|
+
*
|
|
55
|
+
* @description
|
|
56
|
+
* This function converts IPv4 or IPv6 address string to
|
|
57
|
+
* a hexadecimal string of IPv4 or IPv6 address.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* iptohex("192.168.1.1") -> "c0a80101"
|
|
61
|
+
* iptohex("2001:db8::4") -> "871020010db8000000000000000000000004"
|
|
62
|
+
* iptohex("192.168.1.1/24") -> "c0a80101ffffff00"
|
|
63
|
+
* iptohex("2001:db8::/120") -> "871020010db8000000000000000000000000ffffffffffffffffffffffffffffffffff00"
|
|
64
|
+
* iptohex("zzz")) -> raise exception
|
|
65
|
+
*/
|
|
66
|
+
export declare function iptohex(sIn: string): string;
|
|
67
|
+
export declare function ipprefixlen(hMask: string): number;
|
|
68
|
+
export declare function ipnetmask(prefixlen: number, len: number): string;
|
|
69
|
+
//# sourceMappingURL=conv_ip.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conv_ip.d.mts","sourceRoot":"","sources":["../../src/conv_ip.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAqB7C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAmC7C;AAMD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAgCzC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA+B3C;AAOD,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAUjD;AAWD,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAMhE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* convert a hexadecimal ISO 8859-1 latin string to UTF-8 string
|
|
3
|
+
* @param h hexadecimal ISO 8859-1 latin string
|
|
4
|
+
* @return UTF-8 string
|
|
5
|
+
* @see {@link utf8toiso88591hex}
|
|
6
|
+
* @example
|
|
7
|
+
* iso88591hextoutf8("41a9fa") -> "A©ú"
|
|
8
|
+
*/
|
|
9
|
+
export declare function iso88591hextoutf8(h: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* convert UTF-8 string to a hexadecimal ISO 8859-1 latin string
|
|
12
|
+
* @param s hexadecimal ISO 8859-1 latin string
|
|
13
|
+
* @return UTF-8 string
|
|
14
|
+
* @see {@link iso88591hextoutf8}
|
|
15
|
+
* @example
|
|
16
|
+
* utf8toiso88591hex("A©ú") -> "41a9fa"
|
|
17
|
+
*/
|
|
18
|
+
export declare function utf8toiso88591hex(s: string): string;
|
|
19
|
+
//# sourceMappingURL=conv_iso88591.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conv_iso88591.d.mts","sourceRoot":"","sources":["../../src/conv_iso88591.mts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEnD"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* get PEM string from hexadecimal data and header string
|
|
3
|
+
* @param dataHex - hexadecimal string of PEM body
|
|
4
|
+
* @param pemHeader - PEM header string (ex. 'RSA PRIVATE KEY')
|
|
5
|
+
* @param separator - new line string
|
|
6
|
+
* @return PEM formatted string of input data
|
|
7
|
+
*
|
|
8
|
+
* @description
|
|
9
|
+
* This function converts a hexadecimal string to a PEM string with
|
|
10
|
+
* a specified header. Its line break will be CRLF("\r\n").
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* hextopem('616161', 'RSA PRIVATE KEY') ->
|
|
14
|
+
* -----BEGIN PRIVATE KEY-----
|
|
15
|
+
* YWFh
|
|
16
|
+
* -----END PRIVATE KEY-----
|
|
17
|
+
*/
|
|
18
|
+
export declare function hextopem(dataHex: string, pemHeader: string, separator?: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* get hexacedimal string from PEM format data
|
|
21
|
+
* @param s - PEM formatted string
|
|
22
|
+
* @param sHead - PEM header string without BEGIN/END
|
|
23
|
+
* @return hexadecimal string data of PEM contents
|
|
24
|
+
*
|
|
25
|
+
* @description
|
|
26
|
+
* This static method gets a hexacedimal string of contents
|
|
27
|
+
* from PEM format data. You can explicitly specify PEM header
|
|
28
|
+
* by sHead argument.
|
|
29
|
+
* Any space characters such as white space or new line
|
|
30
|
+
* will be omitted.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* pemtohex("-----BEGIN PUBLIC KEY...") -> "3082..."
|
|
34
|
+
* pemtohex("-----BEGIN CERTIFICATE...", "CERTIFICATE") -> "3082..."
|
|
35
|
+
* pemtohex(" \r\n-----BEGIN DSA PRIVATE KEY...") -> "3082..."
|
|
36
|
+
* pemtohex("-----BEGIN EC PARAMETERS...----BEGIN EC PRIVATE KEY...." -> "3082..."
|
|
37
|
+
*/
|
|
38
|
+
export declare function pemtohex(s: string, sHead?: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* get Base64 string from PEM format data
|
|
41
|
+
* @param pem - PEM formatted string
|
|
42
|
+
* @param sHead - PEM header string without BEGIN/END
|
|
43
|
+
* @return Base64 string
|
|
44
|
+
*
|
|
45
|
+
* @description
|
|
46
|
+
* This static method gets a Base64 string of contents
|
|
47
|
+
* from PEM format data.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* pemtob64("-----BEGIN CERTIFICATE...", "CERTIFICATE") -> "MIIBvTCC..."
|
|
51
|
+
* pemtob64("-----BEGIN CERTIFICATE...") -> "MIIBvTCC..."
|
|
52
|
+
*/
|
|
53
|
+
export declare function pemtob64(pem: string, sHead?: string): string;
|
|
54
|
+
/**
|
|
55
|
+
* get PEM string from Base64 string
|
|
56
|
+
* @param b64 - Base64 string of PEM body
|
|
57
|
+
* @param pemHeader - PEM header string (ex. 'RSA PRIVATE KEY')
|
|
58
|
+
* @param separator - new line string
|
|
59
|
+
* @return PEM formatted string of input data
|
|
60
|
+
*
|
|
61
|
+
* @description
|
|
62
|
+
* This function converts a Base64 string to a PEM string with
|
|
63
|
+
* a specified header. Its line break will be CRLF("\r\n").
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* b64topem('YWFh', 'RSA PRIVATE KEY') ->
|
|
67
|
+
* -----BEGIN PRIVATE KEY-----
|
|
68
|
+
* YWFh
|
|
69
|
+
* -----END PRIVATE KEY-----
|
|
70
|
+
*/
|
|
71
|
+
export declare function b64topem(b64: string, pemHeader: string, separator?: string): string;
|
|
72
|
+
/**
|
|
73
|
+
* convert a Base64 encoded string with new lines to a hexadecimal string
|
|
74
|
+
* @param s - Base64 encoded string with new lines
|
|
75
|
+
* @return hexadecimal string
|
|
76
|
+
*
|
|
77
|
+
* @description
|
|
78
|
+
* This function converts from a Base64 encoded
|
|
79
|
+
* string with new lines to a hexadecimal string.
|
|
80
|
+
* This is useful to handle PEM encoded file.
|
|
81
|
+
* This function removes any non-Base64 characters (i.e. not 0-9,A-Z,a-z,\,+,=)
|
|
82
|
+
* including new line.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* hextob64nl(
|
|
86
|
+
* "MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4\r\n" +
|
|
87
|
+
* "OTAxMjM0NTY3ODkwCg==\r\n")
|
|
88
|
+
* ->
|
|
89
|
+
* "123456789012345678901234567890123456789012345678901234567890"
|
|
90
|
+
*/
|
|
91
|
+
export declare function b64nltohex(s: string): string;
|
|
92
|
+
/**
|
|
93
|
+
* wrap string with new lines to fit in specified width
|
|
94
|
+
* @param sIn - string
|
|
95
|
+
* @param n - width
|
|
96
|
+
* @param separator - line separator
|
|
97
|
+
* @return wrapped string with new lines
|
|
98
|
+
*
|
|
99
|
+
* @description
|
|
100
|
+
* This function wrap a string with new lines to fit in specified width.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* foldnl("1234567890", 6)
|
|
104
|
+
* ->
|
|
105
|
+
* 123456
|
|
106
|
+
* 7890
|
|
107
|
+
*/
|
|
108
|
+
export declare function foldnl(sIn: string, n: number, separator?: string): string;
|
|
109
|
+
//# sourceMappingURL=conv_pem.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conv_pem.d.mts","sourceRoot":"","sources":["../../src/conv_pem.mts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,SAAS,SAAS,GACjB,MAAM,CAKR;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAY5D;AAID;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,QAAQ,CACtB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,SAAS,SAAS,GACjB,MAAM,CAMR;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAI5C;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,SAAS,SAAS,GAAG,MAAM,CAKzE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* convert UCS-2 hexadecimal stirng to UTF-8 string
|
|
3
|
+
* @param s - hexadecimal string of UCS-2 string (ex. "0066")
|
|
4
|
+
* @return UTF-8 string
|
|
5
|
+
*
|
|
6
|
+
* @description
|
|
7
|
+
* This function converts hexadecimal value of UCS-2 string to
|
|
8
|
+
* UTF-8 string.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ucs2hextoutf8("006600fc0072") -> "für"
|
|
12
|
+
*/
|
|
13
|
+
export declare function ucs2hextoutf8(s: string): string;
|
|
14
|
+
//# sourceMappingURL=conv_ucs2.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conv_ucs2.d.mts","sourceRoot":"","sources":["../../src/conv_ucs2.mts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AASH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAwB/C"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* convert a URLComponent string such like "%67%68" to a hexadecimal string.
|
|
3
|
+
* @param s - URIComponent string such like "%67%68"
|
|
4
|
+
* @return hexadecimal string
|
|
5
|
+
* @example
|
|
6
|
+
* uricmptohex("%67%68") -> "6768"
|
|
7
|
+
*/
|
|
8
|
+
export declare function uricmptohex(s: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* convert a hexadecimal string to a URLComponent string such like "%67%68".
|
|
11
|
+
* @param s - hexadecimal string
|
|
12
|
+
* @return URIComponent string such like "%67%68"
|
|
13
|
+
* @example
|
|
14
|
+
* hextouricmp("6768") -> "%67%68"
|
|
15
|
+
*/
|
|
16
|
+
export declare function hextouricmp(s: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* convert UTF8 hexadecimal string to a URLComponent string such like "%67%68".
|
|
19
|
+
* @param u8 - UTF8 hexadecimal string
|
|
20
|
+
* @return URIComponent string such like "%67%68"
|
|
21
|
+
*
|
|
22
|
+
* @description
|
|
23
|
+
* Note that these "<code>0-9A-Za-z!'()*-._~</code>" characters will not
|
|
24
|
+
* converted to "%xx" format by builtin 'encodeURIComponent()' function.
|
|
25
|
+
* However this 'encodeURIComponentAll()' function will convert
|
|
26
|
+
* all of characters into "%xx" format.
|
|
27
|
+
*/
|
|
28
|
+
export declare function encodeURIComponentAll(u8: string): string;
|
|
29
|
+
//# sourceMappingURL=conv_uricmp.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conv_uricmp.d.mts","sourceRoot":"","sources":["../../src/conv_uricmp.mts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAYxD"}
|