typepki-strconv 0.9.0 → 0.10.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.
@@ -121,7 +121,8 @@ export declare function timetogen(s: string): string;
121
121
  * convert GeneralizedTime or UTCTime string to ISO8601 time string
122
122
  * @param s - GeneralizedTime or UTCTime string (ex. 20170412235959Z)
123
123
  * @return ISO8601 time string (ex. 2020-07-14T13:03:42Z)
124
- * @since 0.8.0
124
+ * @see {@link iso8601tozulu}
125
+ * @since 0.9.0
125
126
  *
126
127
  * @example
127
128
  * zulutoiso8601( "071231235959Z") -> "2007-12-31T23:59:59Z"
@@ -131,4 +132,19 @@ export declare function timetogen(s: string): string;
131
132
  * zulutoiso8601( "aaaaaaaaaa") -> raise error
132
133
  */
133
134
  export declare function zulutoiso8601(s: string): string;
135
+ /**
136
+ * convert ISO8601 time string to GeneralizedTime or UTCTime string
137
+ * @param s - ISO8601 time string (ex. 2020-07-14T13:03:42Z)
138
+ * @param flagUTC - return UTCTime when this flag is true
139
+ * @return GeneralizedTime or UTCTime string (ex. 20170412235959Z or 170412235959Z)
140
+ * @see {@link zulutoiso8601}
141
+ * @since 0.10.0
142
+ *
143
+ * @example
144
+ * iso8601tozulu("2007-12-31T23:59:59Z") -> "20071231235959Z"
145
+ * iso8601tozulu( "aaaaaaaaaa") -> raise error
146
+ * iso8601tozulu("2007-12-31T23:59:59Z", true) -> "071231235959Z"
147
+ * iso8601tozulu("2107-12-31T23:59:59Z", true) -> raise error, year shall be from 1950 to 2049
148
+ */
149
+ export declare function iso8601tozulu(s: string, flagUTC?: boolean): string;
134
150
  //# sourceMappingURL=conv_zulu.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"conv_zulu.d.mts","sourceRoot":"","sources":["../../src/conv_zulu.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAkChD;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,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAK3C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAmB/C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAC3B,CAAC,EAAE,MAAM,EACT,OAAO,UAAQ,GACd,MAAM,CAoBR"}
@@ -13,8 +13,8 @@ import { b64nltohex, b64topem, foldnl, hextopem, pemtob64, pemtohex } from "./co
13
13
  export { pemtohex, hextopem, pemtob64, b64topem, b64nltohex, foldnl };
14
14
  import { ArrayBuffertohex, hextoArrayBuffer } from "./conv_arybuf.mts";
15
15
  export { hextoArrayBuffer, ArrayBuffertohex };
16
- import { datetozulu, msectozulu, timetogen, zulutodate, zulutoiso8601, zulutomsec, zulutosec } from "./conv_zulu.mts";
17
- export { zulutomsec, msectozulu, zulutosec, zulutodate, datetozulu, timetogen, zulutoiso8601, };
16
+ import { datetozulu, iso8601tozulu, msectozulu, timetogen, zulutodate, zulutoiso8601, zulutomsec, zulutosec } from "./conv_zulu.mts";
17
+ export { datetozulu, iso8601tozulu, msectozulu, timetogen, zulutodate, zulutoiso8601, zulutomsec, zulutosec, };
18
18
  import { encodeURIComponentAll, hextouricmp, uricmptohex } from "./conv_uricmp.mts";
19
19
  export { encodeURIComponentAll, hextouricmp, uricmptohex };
20
20
  import { hextoip, hextoipv6, ipnetmask, ipprefixlen, iptohex, ipv6tohex } from "./conv_ip.mts";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/index.mts"],"names":[],"mappings":"AAAA,QAAA,MAAM,OAAO,EAAE,MAA+D,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,CAAC;AAEnB,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC;AAExC,O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AAC;AAEF,OAAO,EACL,qBAAqB,EACrB,WAAW,EACX,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;AAE3D,OAAO,EACL,OAAO,EACP,SAAS,EACT,SAAS,EACT,WAAW,EACX,OAAO,EACP,SAAS,EACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC;AAE1E,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,CAAC;AAEzB,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -1,4 +1,4 @@
1
- function m(r){return C(U(r))}function C(r){let t="";for(let e=0;e<r.length;e++){let n=r[e].toString(16);n.length===1&&(n=`0${n}`),t=t+n}return t}function j(r){let t=[];for(let e=0;e<r.length;e+=2)t.push(parseInt(r.slice(e,e+2),16));return t}function U(r){let t=new Array;for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}function Z(r){let t="";for(let e=0;e<r.length;e++)t=t+String.fromCharCode(r[e]);return t}function k(r){return r.replace(/%/g,"")}function b(r){return r.replace(/(..)/g,"%$1")}function N(r){let t=encodeURIComponent(r),e="";for(let n=0;n<t.length;n++)t[n]==="%"?(e=e+t.substr(n,3),n=n+2):e=`${e}%${m(t[n])}`;return e}function a(r){return Buffer.from(r,"base64").toString("hex")}function x(r){return Buffer.from(r,"hex").toString("base64")}function f(r){try{return decodeURIComponent(b(r))}catch{throw new Error("malformed hexadecimal UTF-8 string")}}function $(r){return Buffer.from(r,"utf8").toString("hex")}function Y(r){return Buffer.from(r,"base64").toString("utf8")}function F(r){return Buffer.from(r,"utf8").toString("base64")}function L(r){return Buffer.from(p(r),"base64").toString("utf8")}function O(r){return d(Buffer.from(r,"utf8").toString("base64"))}function V(r){return a(p(r))}function G(r){return d(x(r))}function _(r){let t="";for(let e=0;e<r.length;e+=2){let n=parseInt(r.substr(e,2),16);t+=String.fromCharCode(n)}return t}function P(r){let t="";for(let e=0;e<r.length;e++)t+=`0${r.charCodeAt(e).toString(16)}`.slice(-2);return t}function H(r){return Buffer.from(r).toString("base64")}function d(r){let t=r;return t=t.replace(/\=/g,""),t=t.replace(/\+/g,"-"),t=t.replace(/\//g,"_"),t}function p(r){let t=r;return t.length%4===2?t=`${t}==`:t.length%4===3&&(t=`${t}=`),t=t.replace(/-/g,"+"),t=t.replace(/_/g,"/"),t}var K=r=>{if(r.match(/^[01]+$/)==null)return null;try{let t=parseInt(r,2);return E(t)}catch{return null}};function q(r){if(typeof r!="string"||r.length%2!==0||!r.match(/^[0-9a-f]+$/))return null;try{let t=parseInt(r.substr(0,2),16);if(t<0||7<t)return null;let e=r.substr(2),n="";for(let i=0;i<e.length;i+=2){let o=e.substr(i,2),s=parseInt(o,16).toString(2);s=`0000000${s}`.slice(-8),n+=s}return n.substr(0,n.length-t)}catch{return null}}function E(r){if(typeof r!="number"||r<0)return null;let t=Number(r).toString(2),e=8-t.length%8;e===8&&(e=0),t=t+T("",e,"0");let n=parseInt(t,2).toString(16);return n.length%2===1&&(n=`0${n}`),`0${e}`+n}var T=(r,t,e)=>{let n=e===void 0?"0":e;return r.length>=t?r:new Array(t-r.length+1).join(n)+r};function J(r,t){let e=0;for(let o=0;o<r.length;o++)e|=1<<t[r[o]];let n=e.toString(2),i="";for(let o=n.length-1;o>=0;o--)i+=n[o];return i}function Q(r,t){let n=Object.keys(t).map(s=>t[s]),i={};Object.keys(t).map(s=>{i[t[s]]=s});let o=[];return r.split("").map((s,l)=>{s==="1"&&o.push(i[l.toString()])}),o}function W(r,t,e){let n=r,i=t.split(".");for(let o=0;o<i.length&&n;o++){let s=i[o];if(typeof n=="object"&&"length"in n&&s.match(/^[0-9]+$/))n=n[parseInt(s)];else if(typeof n=="object"&&s in n)n=n[s];else return e}return n||n===!1?n:e}function X(r){return!(r.length%2===1||r.match(/^[0-9a-f]+$/)==null)}function D(r){let t=r.replace(/\s+/g,"");return!!(t.match(/^[0-9A-Za-z+\/]+={0,3}$/)&&t.length%4===0)}function tt(r){if(r.match(/[+/=]/))return!1;let t=p(r);return D(t)}function rt(r){return f(nt(r))}function et(r){return ot($(r))}function nt(r){let t=r.match(/.{1,2}/g);if(t==null)return"";let e=[];for(let n=0;n<t.length;n++){let i=parseInt(t[n],16);161<=i&&i<=191?(e.push("c2"),e.push(t[n])):192<=i&&i<=255?(e.push("c3"),e.push((i-64).toString(16))):e.push(t[n])}return e.join("")}function ot(r){let t=r.match(/.{1,2}/g);if(t==null)return"";let e=[];for(let n=0;n<t.length;n++)if(t[n]==="c2")n++,e.push(t[n]);else if(t[n]==="c3"){n++;let i=parseInt(t[n],16)+64;e.push(i.toString(16))}else e.push(t[n]);return e.join("")}function it(r,t,e=`\r
2
- `){return`-----BEGIN ${t}-----${e}${y(x(r),64)}${e}-----END ${t}-----${e}`}function st(r,t){return a(v(r,t))}function v(r,t){let e=r;if(e.indexOf("-----BEGIN ")===-1)throw new Error("can't find PEM header");return t!==void 0?(e=e.replace(new RegExp(`^[^-]*-----BEGIN ${t}-----`),""),e=e.replace(new RegExp(`-----END ${t}-----[^-]*$`),"")):(e=e.replace(/^[^-]*-----BEGIN [^-]+-----/,""),e=e.replace(/-----END [^-]+-----[^-]*$/,"")),e.replace(/\s+/g,"")}function ut(r,t,e=`\r
1
+ function x(r){return S(U(r))}function S(r){let t="";for(let e=0;e<r.length;e++){let n=r[e].toString(16);n.length===1&&(n=`0${n}`),t=t+n}return t}function R(r){let t=[];for(let e=0;e<r.length;e+=2)t.push(parseInt(r.slice(e,e+2),16));return t}function U(r){let t=new Array;for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}function Y(r){let t="";for(let e=0;e<r.length;e++)t=t+String.fromCharCode(r[e]);return t}function j(r){return r.replace(/%/g,"")}function b(r){return r.replace(/(..)/g,"%$1")}function k(r){let t=encodeURIComponent(r),e="";for(let n=0;n<t.length;n++)t[n]==="%"?(e=e+t.substr(n,3),n=n+2):e=`${e}%${x(t[n])}`;return e}function a(r){return Buffer.from(r,"base64").toString("hex")}function m(r){return Buffer.from(r,"hex").toString("base64")}function g(r){try{return decodeURIComponent(b(r))}catch{throw new Error("malformed hexadecimal UTF-8 string")}}function $(r){return Buffer.from(r,"utf8").toString("hex")}function N(r){return Buffer.from(r,"base64").toString("utf8")}function F(r){return Buffer.from(r,"utf8").toString("base64")}function L(r){return Buffer.from(p(r),"base64").toString("utf8")}function O(r){return d(Buffer.from(r,"utf8").toString("base64"))}function V(r){return a(p(r))}function G(r){return d(m(r))}function _(r){let t="";for(let e=0;e<r.length;e+=2){let n=parseInt(r.substr(e,2),16);t+=String.fromCharCode(n)}return t}function H(r){let t="";for(let e=0;e<r.length;e++)t+=`0${r.charCodeAt(e).toString(16)}`.slice(-2);return t}function P(r){return Buffer.from(r).toString("base64")}function d(r){let t=r;return t=t.replace(/\=/g,""),t=t.replace(/\+/g,"-"),t=t.replace(/\//g,"_"),t}function p(r){let t=r;return t.length%4===2?t=`${t}==`:t.length%4===3&&(t=`${t}=`),t=t.replace(/-/g,"+"),t=t.replace(/_/g,"/"),t}var K=r=>{if(r.match(/^[01]+$/)==null)return null;try{let t=parseInt(r,2);return E(t)}catch{return null}};function q(r){if(typeof r!="string"||r.length%2!==0||!r.match(/^[0-9a-f]+$/))return null;try{let t=parseInt(r.substr(0,2),16);if(t<0||7<t)return null;let e=r.substr(2),n="";for(let i=0;i<e.length;i+=2){let o=e.substr(i,2),s=parseInt(o,16).toString(2);s=`0000000${s}`.slice(-8),n+=s}return n.substr(0,n.length-t)}catch{return null}}function E(r){if(typeof r!="number"||r<0)return null;let t=Number(r).toString(2),e=8-t.length%8;e===8&&(e=0),t=t+T("",e,"0");let n=parseInt(t,2).toString(16);return n.length%2===1&&(n=`0${n}`),`0${e}`+n}var T=(r,t,e)=>{let n=e===void 0?"0":e;return r.length>=t?r:new Array(t-r.length+1).join(n)+r};function J(r,t){let e=0;for(let o=0;o<r.length;o++)e|=1<<t[r[o]];let n=e.toString(2),i="";for(let o=n.length-1;o>=0;o--)i+=n[o];return i}function Q(r,t){let n=Object.keys(t).map(s=>t[s]),i={};Object.keys(t).map(s=>{i[t[s]]=s});let o=[];return r.split("").map((s,l)=>{s==="1"&&o.push(i[l.toString()])}),o}function W(r,t,e){let n=r,i=t.split(".");for(let o=0;o<i.length&&n;o++){let s=i[o];if(typeof n=="object"&&"length"in n&&s.match(/^[0-9]+$/))n=n[parseInt(s)];else if(typeof n=="object"&&s in n)n=n[s];else return e}return n||n===!1?n:e}function X(r){return!(r.length%2===1||r.match(/^[0-9a-f]+$/)==null)}function D(r){let t=r.replace(/\s+/g,"");return!!(t.match(/^[0-9A-Za-z+\/]+={0,3}$/)&&t.length%4===0)}function tt(r){if(r.match(/[+/=]/))return!1;let t=p(r);return D(t)}function rt(r){return g(nt(r))}function et(r){return ot($(r))}function nt(r){let t=r.match(/.{1,2}/g);if(t==null)return"";let e=[];for(let n=0;n<t.length;n++){let i=parseInt(t[n],16);161<=i&&i<=191?(e.push("c2"),e.push(t[n])):192<=i&&i<=255?(e.push("c3"),e.push((i-64).toString(16))):e.push(t[n])}return e.join("")}function ot(r){let t=r.match(/.{1,2}/g);if(t==null)return"";let e=[];for(let n=0;n<t.length;n++)if(t[n]==="c2")n++,e.push(t[n]);else if(t[n]==="c3"){n++;let i=parseInt(t[n],16)+64;e.push(i.toString(16))}else e.push(t[n]);return e.join("")}function it(r,t,e=`\r
2
+ `){return`-----BEGIN ${t}-----${e}${y(m(r),64)}${e}-----END ${t}-----${e}`}function st(r,t){return a(v(r,t))}function v(r,t){let e=r;if(e.indexOf("-----BEGIN ")===-1)throw new Error("can't find PEM header");return t!==void 0?(e=e.replace(new RegExp(`^[^-]*-----BEGIN ${t}-----`),""),e=e.replace(new RegExp(`-----END ${t}-----[^-]*$`),"")):(e=e.replace(/^[^-]*-----BEGIN [^-]+-----/,""),e=e.replace(/-----END [^-]+-----[^-]*$/,"")),e.replace(/\s+/g,"")}function ut(r,t,e=`\r
3
3
  `){return`-----BEGIN ${t}-----${e}${y(r,64,e)}${e}-----END ${t}-----${e}`}function lt(r){let t=r.replace(/[^0-9A-Za-z\/+=]*/g,"");return a(t)}function y(r,t,e=`\r
4
- `){let n=r;return n=n.replace(new RegExp(`(.{${t}})`,"g"),`$1${e}`),n=n.replace(/\s+$/,""),n}function ct(r){if(r.length%2!==0)throw"input is not even length";if(r.match(/^[0-9A-Fa-f]+$/)==null)throw"input is not hexadecimal";let t=new ArrayBuffer(r.length/2),e=new DataView(t);for(let n=0;n<r.length/2;n++)e.setUint8(n,parseInt(r.substr(n*2,2),16));return t}function ft(r){let t="",e=new DataView(r);for(let n=0;n<r.byteLength;n++)t+=`00${e.getUint8(n).toString(16)}`.slice(-2);return t}function w(r){let t=r,e,n,i,o,s,l,u,g,h;t=M(t);let c=t.match(/^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(|\.\d+)Z$/);if(c)return e=parseInt(c[1]),n=parseInt(c[2])-1,i=parseInt(c[3]),o=parseInt(c[4]),s=parseInt(c[5]),l=parseInt(c[6]),u=0,g=c[7],g!==""&&(h=`${g.substr(1)}00`.substr(0,3),u=parseInt(h)),Date.UTC(e,n,i,o,s,l,u);throw new Error(`unsupported zulu format: ${t}`)}function gt(r){let t=new Date(r),e=`0000${t.getUTCFullYear()}`.slice(-4),n=`00${t.getUTCMonth()+1}`.slice(-2),i=`00${t.getUTCDate()}`.slice(-2),o=`00${t.getUTCHours()}`.slice(-2),s=`00${t.getUTCMinutes()}`.slice(-2),l=`00${t.getUTCSeconds()}`.slice(-2),u=`000${t.getUTCMilliseconds()}`.slice(-3);return u=u.replace(/0+$/,""),u=u!==""?`.${u}`:u,`${e+n+i+o+s+l+u}Z`}function at(r){return Math.round(w(r)/1e3)}function pt(r){return new Date(w(r))}function ht(r,t=!1,e=!1){let n,i=r.getUTCFullYear();if(t){if(i<1950||2049<i)throw new Error(`not proper year for UTCTime: ${i}`);n=`${i}`.slice(-2)}else n=`000${i}`.slice(-4);if(n+=`0${r.getUTCMonth()+1}`.slice(-2),n+=`0${r.getUTCDate()}`.slice(-2),n+=`0${r.getUTCHours()}`.slice(-2),n+=`0${r.getUTCMinutes()}`.slice(-2),n+=`0${r.getUTCSeconds()}`.slice(-2),e){let o=r.getUTCMilliseconds();if(o!==0){let s=`00${o}`.slice(-3);s=s.replace(/0+$/g,""),n+=`.${s}`}}return n+="Z",n}function M(r){return r.match(/^[0-9]{12}Z$/)||r.match(/^[0-9]{12}[.][0-9]*Z$/)?r.match(/^[0-4]/)?`20${r}`:`19${r}`:r}function xt(r){let t=r.match(/^(\d{2,4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z$/);if(!t)throw new Error("Invalid format: expected YYYYMMDDHHmmssZ or YYYYMMDDHHmmssZ");let[,e,n,i,o,s,l]=t,u=e;return u.length===2&&(parseInt(u.slice(0,1))<5?u=`20${u}`:u=`19${u}`),`${u}-${n}-${i}T${o}:${s}:${l}Z`}function I(r){let t=r,e="malformed IPv6 address";if(!t.match(/^[0-9A-Fa-f:]+$/))throw e;t=t.toLowerCase();let n=t.split(":").length-1;if(n<2)throw e;let i=":".repeat(7-n+2);t=t.replace("::",i);let o=t.split(":");if(o.length!==8)throw e;for(let s=0;s<8;s++)o[s]=`0000${o[s]}`.slice(-4);return o.join("")}function A(r){let t=r;if(!t.match(/^[0-9A-Fa-f]{32}$/))throw new Error(`malformed IPv6 address: ${t}`);t=t.toLowerCase();let e=t.match(/.{1,4}/g)||[];e=e.map(o=>o.replace(/^0+/,"")),e=e.map(o=>o===""?"0":o),t=`:${e.join(":")}:`;let n=t.match(/:(0:){2,}/g);if(n==null)return t.slice(1,-1);let i=n.sort().slice(-1)[0];return t=t.replace(i.substr(0,i.length-1),":"),t.substr(0,2)!=="::"&&(t=t.substr(1)),t.substr(-2,2)!=="::"&&(t=t.substr(0,t.length-1)),t}function z(r){let t=new Error("malformed hex value");if(!r.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw t;if(r.length===8){let e;try{return e=`${parseInt(r.substr(0,2),16)}.${parseInt(r.substr(2,2),16)}.${parseInt(r.substr(4,2),16)}.${parseInt(r.substr(6,2),16)}`,e}catch{throw t}}else if(r.length===16)try{return`${z(r.substr(0,8))}/${B(r.substr(8))}`}catch{throw t}else{if(r.length===32)return A(r);if(r.length===64)try{return`${A(r.substr(0,32))}/${B(r.substr(32))}`}catch{throw t}else return r}}function R(r){let t=r,e=new Error("malformed IP address");if(t=t.toLowerCase(),!t.match(/^[0-9a-f.:/]+$/))throw e;if(t.match(/^[0-9.]+$/)){let n=t.split(".");if(n.length!==4)throw e;let i="";try{for(let o=0;o<4;o++){let s=parseInt(n[o]);i+=`0${s.toString(16)}`.slice(-2)}return i}catch{throw e}}else if(t.match(/^[0-9.]+\/[0-9]+$/)){let n=t.split("/");return R(n[0])+S(parseInt(n[1]),32)}else{if(t.match(/^[0-9a-f:]+$/)&&t.indexOf(":")!==-1)return I(t);if(t.match(/^[0-9a-f:]+\/[0-9]+$/)&&t.indexOf(":")!==-1){let n=t.split("/");return I(n[0])+S(parseInt(n[1]),128)}else throw e}}function B(r){let t=new Error("malformed mask"),e;try{e=parseInt(r,16).toString(2)}catch{throw t}if(!e.match(/^1*0*$/))throw t;return e.replace(/0+$/,"").length}function S(r,t){if(t===32&&r===0)return"00000000";if(t===128&&r===0)return"00000000000000000000000000000000";let e=Array(r+1).join("1")+Array(t-r+1).join("0");return parseInt(e,2).toString(16)}function mt(r){function t(i){let o=parseInt(i.substr(0,2),16),s=parseInt(i.substr(2),16);if(o===0&&s<128)return String.fromCharCode(s);if(o<8){let h=192|(o&7)<<3|(s&192)>>6,c=128|s&63;return f(h.toString(16)+c.toString(16))}let l=224|(o&240)>>4,u=128|(o&15)<<2|(s&192)>>6,g=128|s&63;return f(l.toString(16)+u.toString(16)+g.toString(16))}let e=r.match(/.{4}/g);return e==null?"":e.map(t).join("")}function bt(r){return r.length%2===1?`0${r}`:r}var jt="typepki-strconv 0.9.0 kjur.github.io/typepki-strconv";export{ft as ArrayBuffertohex,C as BAtohex,Z as BAtos,jt as VERSION,W as aryval,lt as b64nltohex,d as b64tob64u,a as b64tohex,ut as b64topem,Y as b64toutf8,p as b64utob64,V as b64utohex,L as b64utoutf8,K as binstrtobitstr,Q as binstrtonamearray,q as bitstrtobinstr,ht as datetozulu,N as encodeURIComponentAll,y as foldnl,bt as hexpad,ct as hextoArrayBuffer,j as hextoBA,x as hextob64,G as hextob64u,z as hextoip,A as hextoipv6,it as hextopem,_ as hextorstr,b as hextouricmp,f as hextoutf8,E as inttobitstr,S as ipnetmask,B as ipprefixlen,R as iptohex,I as ipv6tohex,D as isBase64,tt as isBase64URL,X as ishex,rt as iso88591hextoutf8,gt as msectozulu,J as namearraytobinstr,v as pemtob64,st as pemtohex,H as rstrtob64,P as rstrtohex,U as stoBA,m as stohex,T as strpad,M as timetogen,mt as ucs2hextoutf8,k as uricmptohex,F as utf8tob64,O as utf8tob64u,$ as utf8tohex,et as utf8toiso88591hex,pt as zulutodate,xt as zulutoiso8601,w as zulutomsec,at as zulutosec};
4
+ `){let n=r;return n=n.replace(new RegExp(`(.{${t}})`,"g"),`$1${e}`),n=n.replace(/\s+$/,""),n}function ft(r){if(r.length%2!==0)throw"input is not even length";if(r.match(/^[0-9A-Fa-f]+$/)==null)throw"input is not hexadecimal";let t=new ArrayBuffer(r.length/2),e=new DataView(t);for(let n=0;n<r.length/2;n++)e.setUint8(n,parseInt(r.substr(n*2,2),16));return t}function ct(r){let t="",e=new DataView(r);for(let n=0;n<r.byteLength;n++)t+=`00${e.getUint8(n).toString(16)}`.slice(-2);return t}function w(r){let t=r,e,n,i,o,s,l,u,c,h;t=M(t);let f=t.match(/^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(|\.\d+)Z$/);if(f)return e=parseInt(f[1]),n=parseInt(f[2])-1,i=parseInt(f[3]),o=parseInt(f[4]),s=parseInt(f[5]),l=parseInt(f[6]),u=0,c=f[7],c!==""&&(h=`${c.substr(1)}00`.substr(0,3),u=parseInt(h)),Date.UTC(e,n,i,o,s,l,u);throw new Error(`unsupported zulu format: ${t}`)}function gt(r){let t=new Date(r),e=`0000${t.getUTCFullYear()}`.slice(-4),n=`00${t.getUTCMonth()+1}`.slice(-2),i=`00${t.getUTCDate()}`.slice(-2),o=`00${t.getUTCHours()}`.slice(-2),s=`00${t.getUTCMinutes()}`.slice(-2),l=`00${t.getUTCSeconds()}`.slice(-2),u=`000${t.getUTCMilliseconds()}`.slice(-3);return u=u.replace(/0+$/,""),u=u!==""?`.${u}`:u,`${e+n+i+o+s+l+u}Z`}function at(r){return Math.round(w(r)/1e3)}function pt(r){return new Date(w(r))}function ht(r,t=!1,e=!1){let n,i=r.getUTCFullYear();if(t){if(i<1950||2049<i)throw new Error(`not proper year for UTCTime: ${i}`);n=`${i}`.slice(-2)}else n=`000${i}`.slice(-4);if(n+=`0${r.getUTCMonth()+1}`.slice(-2),n+=`0${r.getUTCDate()}`.slice(-2),n+=`0${r.getUTCHours()}`.slice(-2),n+=`0${r.getUTCMinutes()}`.slice(-2),n+=`0${r.getUTCSeconds()}`.slice(-2),e){let o=r.getUTCMilliseconds();if(o!==0){let s=`00${o}`.slice(-3);s=s.replace(/0+$/g,""),n+=`.${s}`}}return n+="Z",n}function M(r){return r.match(/^[0-9]{12}Z$/)||r.match(/^[0-9]{12}[.][0-9]*Z$/)?r.match(/^[0-4]/)?`20${r}`:`19${r}`:r}function mt(r){let t=r.match(/^(\d{2,4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z$/);if(!t)throw new Error("Invalid format: expected YYYYMMDDHHmmssZ or YYYYMMDDHHmmssZ");let[,e,n,i,o,s,l]=t,u=e;return u.length===2&&(parseInt(u.slice(0,1))<5?u=`20${u}`:u=`19${u}`),`${u}-${n}-${i}T${o}:${s}:${l}Z`}function xt(r,t=!1){let e=r.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z$/);if(!e)throw new Error("Invalid format: expected YYYY-MM-DDTHH:mm:ssZ");let[,n,i,o,s,l,u]=e,c=parseInt(n);if(t)if(1950<=c&&c<=2049)n=n.slice(2,4);else throw new Error(`Invalid year for UTCTime: ${n}`);return`${n}${i}${o}${s}${l}${u}Z`}function I(r){let t=r,e="malformed IPv6 address";if(!t.match(/^[0-9A-Fa-f:]+$/))throw e;t=t.toLowerCase();let n=t.split(":").length-1;if(n<2)throw e;let i=":".repeat(7-n+2);t=t.replace("::",i);let o=t.split(":");if(o.length!==8)throw e;for(let s=0;s<8;s++)o[s]=`0000${o[s]}`.slice(-4);return o.join("")}function A(r){let t=r;if(!t.match(/^[0-9A-Fa-f]{32}$/))throw new Error(`malformed IPv6 address: ${t}`);t=t.toLowerCase();let e=t.match(/.{1,4}/g)||[];e=e.map(o=>o.replace(/^0+/,"")),e=e.map(o=>o===""?"0":o),t=`:${e.join(":")}:`;let n=t.match(/:(0:){2,}/g);if(n==null)return t.slice(1,-1);let i=n.sort().slice(-1)[0];return t=t.replace(i.substr(0,i.length-1),":"),t.substr(0,2)!=="::"&&(t=t.substr(1)),t.substr(-2,2)!=="::"&&(t=t.substr(0,t.length-1)),t}function z(r){let t=new Error("malformed hex value");if(!r.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw t;if(r.length===8){let e;try{return e=`${parseInt(r.substr(0,2),16)}.${parseInt(r.substr(2,2),16)}.${parseInt(r.substr(4,2),16)}.${parseInt(r.substr(6,2),16)}`,e}catch{throw t}}else if(r.length===16)try{return`${z(r.substr(0,8))}/${B(r.substr(8))}`}catch{throw t}else{if(r.length===32)return A(r);if(r.length===64)try{return`${A(r.substr(0,32))}/${B(r.substr(32))}`}catch{throw t}else return r}}function Z(r){let t=r,e=new Error("malformed IP address");if(t=t.toLowerCase(),!t.match(/^[0-9a-f.:/]+$/))throw e;if(t.match(/^[0-9.]+$/)){let n=t.split(".");if(n.length!==4)throw e;let i="";try{for(let o=0;o<4;o++){let s=parseInt(n[o]);i+=`0${s.toString(16)}`.slice(-2)}return i}catch{throw e}}else if(t.match(/^[0-9.]+\/[0-9]+$/)){let n=t.split("/");return Z(n[0])+C(parseInt(n[1]),32)}else{if(t.match(/^[0-9a-f:]+$/)&&t.indexOf(":")!==-1)return I(t);if(t.match(/^[0-9a-f:]+\/[0-9]+$/)&&t.indexOf(":")!==-1){let n=t.split("/");return I(n[0])+C(parseInt(n[1]),128)}else throw e}}function B(r){let t=new Error("malformed mask"),e;try{e=parseInt(r,16).toString(2)}catch{throw t}if(!e.match(/^1*0*$/))throw t;return e.replace(/0+$/,"").length}function C(r,t){if(t===32&&r===0)return"00000000";if(t===128&&r===0)return"00000000000000000000000000000000";let e=Array(r+1).join("1")+Array(t-r+1).join("0");return parseInt(e,2).toString(16)}function bt(r){function t(i){let o=parseInt(i.substr(0,2),16),s=parseInt(i.substr(2),16);if(o===0&&s<128)return String.fromCharCode(s);if(o<8){let h=192|(o&7)<<3|(s&192)>>6,f=128|s&63;return g(h.toString(16)+f.toString(16))}let l=224|(o&240)>>4,u=128|(o&15)<<2|(s&192)>>6,c=128|s&63;return g(l.toString(16)+u.toString(16)+c.toString(16))}let e=r.match(/.{4}/g);return e==null?"":e.map(t).join("")}function $t(r){return r.length%2===1?`0${r}`:r}var Yt="typepki-strconv 0.10.0 kjur.github.io/typepki-strconv";export{ct as ArrayBuffertohex,S as BAtohex,Y as BAtos,Yt as VERSION,W as aryval,lt as b64nltohex,d as b64tob64u,a as b64tohex,ut as b64topem,N as b64toutf8,p as b64utob64,V as b64utohex,L as b64utoutf8,K as binstrtobitstr,Q as binstrtonamearray,q as bitstrtobinstr,ht as datetozulu,k as encodeURIComponentAll,y as foldnl,$t as hexpad,ft as hextoArrayBuffer,R as hextoBA,m as hextob64,G as hextob64u,z as hextoip,A as hextoipv6,it as hextopem,_ as hextorstr,b as hextouricmp,g as hextoutf8,E as inttobitstr,C as ipnetmask,B as ipprefixlen,Z as iptohex,I as ipv6tohex,D as isBase64,tt as isBase64URL,X as ishex,xt as iso8601tozulu,rt as iso88591hextoutf8,gt as msectozulu,J as namearraytobinstr,v as pemtob64,st as pemtohex,P as rstrtob64,H as rstrtohex,U as stoBA,x as stohex,T as strpad,M as timetogen,bt as ucs2hextoutf8,j as uricmptohex,F as utf8tob64,O as utf8tob64u,$ as utf8tohex,et as utf8toiso88591hex,pt as zulutodate,mt as zulutoiso8601,w as zulutomsec,at as zulutosec};
@@ -1,4 +1,4 @@
1
- "use strict";var E=Object.defineProperty;var vt=Object.getOwnPropertyDescriptor;var Mt=Object.getOwnPropertyNames;var zt=Object.prototype.hasOwnProperty;var l=(r,t)=>()=>(r&&(t=r(r=0)),t);var Rt=(r,t)=>{for(var e in t)E(r,e,{get:t[e],enumerable:!0})},jt=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Mt(t))!zt.call(r,o)&&o!==e&&E(r,o,{get:()=>t[o],enumerable:!(n=vt(t,o))||n.enumerable});return r};var Zt=r=>jt(E({},"__esModule",{value:!0}),r);function $(r){return T(D(r))}function T(r){let t="";for(let e=0;e<r.length;e++){let n=r[e].toString(16);n.length===1&&(n=`0${n}`),t=t+n}return t}function F(r){let t=[];for(let e=0;e<r.length;e+=2)t.push(parseInt(r.slice(e,e+2),16));return t}function D(r){let t=new Array;for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}function L(r){let t="";for(let e=0;e<r.length;e++)t=t+String.fromCharCode(r[e]);return t}var v=l(()=>{"use strict"});function O(r){return r.replace(/%/g,"")}function d(r){return r.replace(/(..)/g,"%$1")}function V(r){let t=encodeURIComponent(r),e="";for(let n=0;n<t.length;n++)t[n]==="%"?(e=e+t.substr(n,3),n=n+2):e=`${e}%${$(t[n])}`;return e}var M=l(()=>{"use strict";v()});function a(r){return Buffer.from(r,"base64").toString("hex")}function m(r){return Buffer.from(r,"hex").toString("base64")}function g(r){try{return decodeURIComponent(d(r))}catch{throw new Error("malformed hexadecimal UTF-8 string")}}function y(r){return Buffer.from(r,"utf8").toString("hex")}function G(r){return Buffer.from(r,"base64").toString("utf8")}function _(r){return Buffer.from(r,"utf8").toString("base64")}function P(r){return Buffer.from(p(r),"base64").toString("utf8")}function H(r){return w(Buffer.from(r,"utf8").toString("base64"))}function K(r){return a(p(r))}function q(r){return w(m(r))}function J(r){let t="";for(let e=0;e<r.length;e+=2){let n=parseInt(r.substr(e,2),16);t+=String.fromCharCode(n)}return t}function Q(r){let t="";for(let e=0;e<r.length;e++)t+=`0${r.charCodeAt(e).toString(16)}`.slice(-2);return t}function W(r){return Buffer.from(r).toString("base64")}function w(r){let t=r;return t=t.replace(/\=/g,""),t=t.replace(/\+/g,"-"),t=t.replace(/\//g,"_"),t}function p(r){let t=r;return t.length%4===2?t=`${t}==`:t.length%4===3&&(t=`${t}=`),t=t.replace(/-/g,"+"),t=t.replace(/_/g,"/"),t}function tt(r){if(typeof r!="string"||r.length%2!==0||!r.match(/^[0-9a-f]+$/))return null;try{let t=parseInt(r.substr(0,2),16);if(t<0||7<t)return null;let e=r.substr(2),n="";for(let o=0;o<e.length;o+=2){let i=e.substr(o,2),s=parseInt(i,16).toString(2);s=`0000000${s}`.slice(-8),n+=s}return n.substr(0,n.length-t)}catch{return null}}function z(r){if(typeof r!="number"||r<0)return null;let t=Number(r).toString(2),e=8-t.length%8;e===8&&(e=0),t=t+R("",e,"0");let n=parseInt(t,2).toString(16);return n.length%2===1&&(n=`0${n}`),`0${e}`+n}function rt(r,t){let e=0;for(let i=0;i<r.length;i++)e|=1<<t[r[i]];let n=e.toString(2),o="";for(let i=n.length-1;i>=0;i--)o+=n[i];return o}function et(r,t){let n=Object.keys(t).map(s=>t[s]),o={};Object.keys(t).map(s=>{o[t[s]]=s});let i=[];return r.split("").map((s,c)=>{s==="1"&&i.push(o[c.toString()])}),i}function nt(r,t,e){let n=r,o=t.split(".");for(let i=0;i<o.length&&n;i++){let s=o[i];if(typeof n=="object"&&"length"in n&&s.match(/^[0-9]+$/))n=n[parseInt(s)];else if(typeof n=="object"&&s in n)n=n[s];else return e}return n||n===!1?n:e}var X,R,h=l(()=>{"use strict";M();X=r=>{if(r.match(/^[01]+$/)==null)return null;try{let t=parseInt(r,2);return z(t)}catch{return null}};R=(r,t,e)=>{let n=e===void 0?"0":e;return r.length>=t?r:new Array(t-r.length+1).join(n)+r}});function ot(r){return!(r.length%2===1||r.match(/^[0-9a-f]+$/)==null)}function j(r){let t=r.replace(/\s+/g,"");return!!(t.match(/^[0-9A-Za-z+\/]+={0,3}$/)&&t.length%4===0)}function it(r){if(r.match(/[+/=]/))return!1;let t=p(r);return j(t)}var st=l(()=>{"use strict";h()});function ut(r){return g(kt(r))}function lt(r){return Nt(y(r))}function kt(r){let t=r.match(/.{1,2}/g);if(t==null)return"";let e=[];for(let n=0;n<t.length;n++){let o=parseInt(t[n],16);161<=o&&o<=191?(e.push("c2"),e.push(t[n])):192<=o&&o<=255?(e.push("c3"),e.push((o-64).toString(16))):e.push(t[n])}return e.join("")}function Nt(r){let t=r.match(/.{1,2}/g);if(t==null)return"";let e=[];for(let n=0;n<t.length;n++)if(t[n]==="c2")n++,e.push(t[n]);else if(t[n]==="c3"){n++;let o=parseInt(t[n],16)+64;e.push(o.toString(16))}else e.push(t[n]);return e.join("")}var ct=l(()=>{"use strict";h()});function ft(r,t,e=`\r
2
- `){return`-----BEGIN ${t}-----${e}${I(m(r),64)}${e}-----END ${t}-----${e}`}function gt(r,t){return a(Z(r,t))}function Z(r,t){let e=r;if(e.indexOf("-----BEGIN ")===-1)throw new Error("can't find PEM header");return t!==void 0?(e=e.replace(new RegExp(`^[^-]*-----BEGIN ${t}-----`),""),e=e.replace(new RegExp(`-----END ${t}-----[^-]*$`),"")):(e=e.replace(/^[^-]*-----BEGIN [^-]+-----/,""),e=e.replace(/-----END [^-]+-----[^-]*$/,"")),e.replace(/\s+/g,"")}function at(r,t,e=`\r
3
- `){return`-----BEGIN ${t}-----${e}${I(r,64,e)}${e}-----END ${t}-----${e}`}function pt(r){let t=r.replace(/[^0-9A-Za-z\/+=]*/g,"");return a(t)}function I(r,t,e=`\r
4
- `){let n=r;return n=n.replace(new RegExp(`(.{${t}})`,"g"),`$1${e}`),n=n.replace(/\s+$/,""),n}var ht=l(()=>{"use strict";h()});function xt(r){if(r.length%2!==0)throw"input is not even length";if(r.match(/^[0-9A-Fa-f]+$/)==null)throw"input is not hexadecimal";let t=new ArrayBuffer(r.length/2),e=new DataView(t);for(let n=0;n<r.length/2;n++)e.setUint8(n,parseInt(r.substr(n*2,2),16));return t}function mt(r){let t="",e=new DataView(r);for(let n=0;n<r.byteLength;n++)t+=`00${e.getUint8(n).toString(16)}`.slice(-2);return t}var bt=l(()=>{"use strict"});function A(r){let t=r,e,n,o,i,s,c,u,x,b;t=k(t);let f=t.match(/^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(|\.\d+)Z$/);if(f)return e=parseInt(f[1]),n=parseInt(f[2])-1,o=parseInt(f[3]),i=parseInt(f[4]),s=parseInt(f[5]),c=parseInt(f[6]),u=0,x=f[7],x!==""&&(b=`${x.substr(1)}00`.substr(0,3),u=parseInt(b)),Date.UTC(e,n,o,i,s,c,u);throw new Error(`unsupported zulu format: ${t}`)}function $t(r){let t=new Date(r),e=`0000${t.getUTCFullYear()}`.slice(-4),n=`00${t.getUTCMonth()+1}`.slice(-2),o=`00${t.getUTCDate()}`.slice(-2),i=`00${t.getUTCHours()}`.slice(-2),s=`00${t.getUTCMinutes()}`.slice(-2),c=`00${t.getUTCSeconds()}`.slice(-2),u=`000${t.getUTCMilliseconds()}`.slice(-3);return u=u.replace(/0+$/,""),u=u!==""?`.${u}`:u,`${e+n+o+i+s+c+u}Z`}function dt(r){return Math.round(A(r)/1e3)}function yt(r){return new Date(A(r))}function wt(r,t=!1,e=!1){let n,o=r.getUTCFullYear();if(t){if(o<1950||2049<o)throw new Error(`not proper year for UTCTime: ${o}`);n=`${o}`.slice(-2)}else n=`000${o}`.slice(-4);if(n+=`0${r.getUTCMonth()+1}`.slice(-2),n+=`0${r.getUTCDate()}`.slice(-2),n+=`0${r.getUTCHours()}`.slice(-2),n+=`0${r.getUTCMinutes()}`.slice(-2),n+=`0${r.getUTCSeconds()}`.slice(-2),e){let i=r.getUTCMilliseconds();if(i!==0){let s=`00${i}`.slice(-3);s=s.replace(/0+$/g,""),n+=`.${s}`}}return n+="Z",n}function k(r){return r.match(/^[0-9]{12}Z$/)||r.match(/^[0-9]{12}[.][0-9]*Z$/)?r.match(/^[0-4]/)?`20${r}`:`19${r}`:r}function It(r){let t=r.match(/^(\d{2,4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z$/);if(!t)throw new Error("Invalid format: expected YYYYMMDDHHmmssZ or YYYYMMDDHHmmssZ");let[,e,n,o,i,s,c]=t,u=e;return u.length===2&&(parseInt(u.slice(0,1))<5?u=`20${u}`:u=`19${u}`),`${u}-${n}-${o}T${i}:${s}:${c}Z`}var At=l(()=>{"use strict"});function B(r){let t=r,e="malformed IPv6 address";if(!t.match(/^[0-9A-Fa-f:]+$/))throw e;t=t.toLowerCase();let n=t.split(":").length-1;if(n<2)throw e;let o=":".repeat(7-n+2);t=t.replace("::",o);let i=t.split(":");if(i.length!==8)throw e;for(let s=0;s<8;s++)i[s]=`0000${i[s]}`.slice(-4);return i.join("")}function S(r){let t=r;if(!t.match(/^[0-9A-Fa-f]{32}$/))throw new Error(`malformed IPv6 address: ${t}`);t=t.toLowerCase();let e=t.match(/.{1,4}/g)||[];e=e.map(i=>i.replace(/^0+/,"")),e=e.map(i=>i===""?"0":i),t=`:${e.join(":")}:`;let n=t.match(/:(0:){2,}/g);if(n==null)return t.slice(1,-1);let o=n.sort().slice(-1)[0];return t=t.replace(o.substr(0,o.length-1),":"),t.substr(0,2)!=="::"&&(t=t.substr(1)),t.substr(-2,2)!=="::"&&(t=t.substr(0,t.length-1)),t}function N(r){let t=new Error("malformed hex value");if(!r.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw t;if(r.length===8){let e;try{return e=`${parseInt(r.substr(0,2),16)}.${parseInt(r.substr(2,2),16)}.${parseInt(r.substr(4,2),16)}.${parseInt(r.substr(6,2),16)}`,e}catch{throw t}}else if(r.length===16)try{return`${N(r.substr(0,8))}/${C(r.substr(8))}`}catch{throw t}else{if(r.length===32)return S(r);if(r.length===64)try{return`${S(r.substr(0,32))}/${C(r.substr(32))}`}catch{throw t}else return r}}function Y(r){let t=r,e=new Error("malformed IP address");if(t=t.toLowerCase(),!t.match(/^[0-9a-f.:/]+$/))throw e;if(t.match(/^[0-9.]+$/)){let n=t.split(".");if(n.length!==4)throw e;let o="";try{for(let i=0;i<4;i++){let s=parseInt(n[i]);o+=`0${s.toString(16)}`.slice(-2)}return o}catch{throw e}}else if(t.match(/^[0-9.]+\/[0-9]+$/)){let n=t.split("/");return Y(n[0])+U(parseInt(n[1]),32)}else{if(t.match(/^[0-9a-f:]+$/)&&t.indexOf(":")!==-1)return B(t);if(t.match(/^[0-9a-f:]+\/[0-9]+$/)&&t.indexOf(":")!==-1){let n=t.split("/");return B(n[0])+U(parseInt(n[1]),128)}else throw e}}function C(r){let t=new Error("malformed mask"),e;try{e=parseInt(r,16).toString(2)}catch{throw t}if(!e.match(/^1*0*$/))throw t;return e.replace(/0+$/,"").length}function U(r,t){if(t===32&&r===0)return"00000000";if(t===128&&r===0)return"00000000000000000000000000000000";let e=Array(r+1).join("1")+Array(t-r+1).join("0");return parseInt(e,2).toString(16)}var Bt=l(()=>{"use strict"});function St(r){function t(o){let i=parseInt(o.substr(0,2),16),s=parseInt(o.substr(2),16);if(i===0&&s<128)return String.fromCharCode(s);if(i<8){let b=192|(i&7)<<3|(s&192)>>6,f=128|s&63;return g(b.toString(16)+f.toString(16))}let c=224|(i&240)>>4,u=128|(i&15)<<2|(s&192)>>6,x=128|s&63;return g(c.toString(16)+u.toString(16)+x.toString(16))}let e=r.match(/.{4}/g);return e==null?"":e.map(t).join("")}var Ct=l(()=>{"use strict";h()});function Ut(r){return r.length%2===1?`0${r}`:r}var Et=l(()=>{"use strict"});var Tt={};Rt(Tt,{ArrayBuffertohex:()=>mt,BAtohex:()=>T,BAtos:()=>L,VERSION:()=>Yt,aryval:()=>nt,b64nltohex:()=>pt,b64tob64u:()=>w,b64tohex:()=>a,b64topem:()=>at,b64toutf8:()=>G,b64utob64:()=>p,b64utohex:()=>K,b64utoutf8:()=>P,binstrtobitstr:()=>X,binstrtonamearray:()=>et,bitstrtobinstr:()=>tt,datetozulu:()=>wt,encodeURIComponentAll:()=>V,foldnl:()=>I,hexpad:()=>Ut,hextoArrayBuffer:()=>xt,hextoBA:()=>F,hextob64:()=>m,hextob64u:()=>q,hextoip:()=>N,hextoipv6:()=>S,hextopem:()=>ft,hextorstr:()=>J,hextouricmp:()=>d,hextoutf8:()=>g,inttobitstr:()=>z,ipnetmask:()=>U,ipprefixlen:()=>C,iptohex:()=>Y,ipv6tohex:()=>B,isBase64:()=>j,isBase64URL:()=>it,ishex:()=>ot,iso88591hextoutf8:()=>ut,msectozulu:()=>$t,namearraytobinstr:()=>rt,pemtob64:()=>Z,pemtohex:()=>gt,rstrtob64:()=>W,rstrtohex:()=>Q,stoBA:()=>D,stohex:()=>$,strpad:()=>R,timetogen:()=>k,ucs2hextoutf8:()=>St,uricmptohex:()=>O,utf8tob64:()=>_,utf8tob64u:()=>H,utf8tohex:()=>y,utf8toiso88591hex:()=>lt,zulutodate:()=>yt,zulutoiso8601:()=>It,zulutomsec:()=>A,zulutosec:()=>dt});var Yt,Dt=l(()=>{"use strict";st();v();h();ct();ht();bt();At();M();Bt();Ct();Et();Yt="typepki-strconv 0.9.0 kjur.github.io/typepki-strconv"});module.exports=(Dt(),Zt(Tt));
1
+ "use strict";var E=Object.defineProperty;var Mt=Object.getOwnPropertyDescriptor;var zt=Object.getOwnPropertyNames;var Zt=Object.prototype.hasOwnProperty;var f=(r,t)=>()=>(r&&(t=r(r=0)),t);var Rt=(r,t)=>{for(var e in t)E(r,e,{get:t[e],enumerable:!0})},Yt=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of zt(t))!Zt.call(r,o)&&o!==e&&E(r,o,{get:()=>t[o],enumerable:!(n=Mt(t,o))||n.enumerable});return r};var jt=r=>Yt(E({},"__esModule",{value:!0}),r);function $(r){return T(D(r))}function T(r){let t="";for(let e=0;e<r.length;e++){let n=r[e].toString(16);n.length===1&&(n=`0${n}`),t=t+n}return t}function F(r){let t=[];for(let e=0;e<r.length;e+=2)t.push(parseInt(r.slice(e,e+2),16));return t}function D(r){let t=new Array;for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}function L(r){let t="";for(let e=0;e<r.length;e++)t=t+String.fromCharCode(r[e]);return t}var v=f(()=>{"use strict"});function O(r){return r.replace(/%/g,"")}function d(r){return r.replace(/(..)/g,"%$1")}function V(r){let t=encodeURIComponent(r),e="";for(let n=0;n<t.length;n++)t[n]==="%"?(e=e+t.substr(n,3),n=n+2):e=`${e}%${$(t[n])}`;return e}var M=f(()=>{"use strict";v()});function p(r){return Buffer.from(r,"base64").toString("hex")}function x(r){return Buffer.from(r,"hex").toString("base64")}function a(r){try{return decodeURIComponent(d(r))}catch{throw new Error("malformed hexadecimal UTF-8 string")}}function y(r){return Buffer.from(r,"utf8").toString("hex")}function G(r){return Buffer.from(r,"base64").toString("utf8")}function _(r){return Buffer.from(r,"utf8").toString("base64")}function H(r){return Buffer.from(h(r),"base64").toString("utf8")}function P(r){return w(Buffer.from(r,"utf8").toString("base64"))}function K(r){return p(h(r))}function q(r){return w(x(r))}function J(r){let t="";for(let e=0;e<r.length;e+=2){let n=parseInt(r.substr(e,2),16);t+=String.fromCharCode(n)}return t}function Q(r){let t="";for(let e=0;e<r.length;e++)t+=`0${r.charCodeAt(e).toString(16)}`.slice(-2);return t}function W(r){return Buffer.from(r).toString("base64")}function w(r){let t=r;return t=t.replace(/\=/g,""),t=t.replace(/\+/g,"-"),t=t.replace(/\//g,"_"),t}function h(r){let t=r;return t.length%4===2?t=`${t}==`:t.length%4===3&&(t=`${t}=`),t=t.replace(/-/g,"+"),t=t.replace(/_/g,"/"),t}function tt(r){if(typeof r!="string"||r.length%2!==0||!r.match(/^[0-9a-f]+$/))return null;try{let t=parseInt(r.substr(0,2),16);if(t<0||7<t)return null;let e=r.substr(2),n="";for(let o=0;o<e.length;o+=2){let i=e.substr(o,2),s=parseInt(i,16).toString(2);s=`0000000${s}`.slice(-8),n+=s}return n.substr(0,n.length-t)}catch{return null}}function z(r){if(typeof r!="number"||r<0)return null;let t=Number(r).toString(2),e=8-t.length%8;e===8&&(e=0),t=t+Z("",e,"0");let n=parseInt(t,2).toString(16);return n.length%2===1&&(n=`0${n}`),`0${e}`+n}function rt(r,t){let e=0;for(let i=0;i<r.length;i++)e|=1<<t[r[i]];let n=e.toString(2),o="";for(let i=n.length-1;i>=0;i--)o+=n[i];return o}function et(r,t){let n=Object.keys(t).map(s=>t[s]),o={};Object.keys(t).map(s=>{o[t[s]]=s});let i=[];return r.split("").map((s,l)=>{s==="1"&&i.push(o[l.toString()])}),i}function nt(r,t,e){let n=r,o=t.split(".");for(let i=0;i<o.length&&n;i++){let s=o[i];if(typeof n=="object"&&"length"in n&&s.match(/^[0-9]+$/))n=n[parseInt(s)];else if(typeof n=="object"&&s in n)n=n[s];else return e}return n||n===!1?n:e}var X,Z,m=f(()=>{"use strict";M();X=r=>{if(r.match(/^[01]+$/)==null)return null;try{let t=parseInt(r,2);return z(t)}catch{return null}};Z=(r,t,e)=>{let n=e===void 0?"0":e;return r.length>=t?r:new Array(t-r.length+1).join(n)+r}});function ot(r){return!(r.length%2===1||r.match(/^[0-9a-f]+$/)==null)}function R(r){let t=r.replace(/\s+/g,"");return!!(t.match(/^[0-9A-Za-z+\/]+={0,3}$/)&&t.length%4===0)}function it(r){if(r.match(/[+/=]/))return!1;let t=h(r);return R(t)}var st=f(()=>{"use strict";m()});function ut(r){return a(kt(r))}function lt(r){return Nt(y(r))}function kt(r){let t=r.match(/.{1,2}/g);if(t==null)return"";let e=[];for(let n=0;n<t.length;n++){let o=parseInt(t[n],16);161<=o&&o<=191?(e.push("c2"),e.push(t[n])):192<=o&&o<=255?(e.push("c3"),e.push((o-64).toString(16))):e.push(t[n])}return e.join("")}function Nt(r){let t=r.match(/.{1,2}/g);if(t==null)return"";let e=[];for(let n=0;n<t.length;n++)if(t[n]==="c2")n++,e.push(t[n]);else if(t[n]==="c3"){n++;let o=parseInt(t[n],16)+64;e.push(o.toString(16))}else e.push(t[n]);return e.join("")}var ft=f(()=>{"use strict";m()});function ct(r,t,e=`\r
2
+ `){return`-----BEGIN ${t}-----${e}${I(x(r),64)}${e}-----END ${t}-----${e}`}function gt(r,t){return p(Y(r,t))}function Y(r,t){let e=r;if(e.indexOf("-----BEGIN ")===-1)throw new Error("can't find PEM header");return t!==void 0?(e=e.replace(new RegExp(`^[^-]*-----BEGIN ${t}-----`),""),e=e.replace(new RegExp(`-----END ${t}-----[^-]*$`),"")):(e=e.replace(/^[^-]*-----BEGIN [^-]+-----/,""),e=e.replace(/-----END [^-]+-----[^-]*$/,"")),e.replace(/\s+/g,"")}function at(r,t,e=`\r
3
+ `){return`-----BEGIN ${t}-----${e}${I(r,64,e)}${e}-----END ${t}-----${e}`}function pt(r){let t=r.replace(/[^0-9A-Za-z\/+=]*/g,"");return p(t)}function I(r,t,e=`\r
4
+ `){let n=r;return n=n.replace(new RegExp(`(.{${t}})`,"g"),`$1${e}`),n=n.replace(/\s+$/,""),n}var ht=f(()=>{"use strict";m()});function mt(r){if(r.length%2!==0)throw"input is not even length";if(r.match(/^[0-9A-Fa-f]+$/)==null)throw"input is not hexadecimal";let t=new ArrayBuffer(r.length/2),e=new DataView(t);for(let n=0;n<r.length/2;n++)e.setUint8(n,parseInt(r.substr(n*2,2),16));return t}function xt(r){let t="",e=new DataView(r);for(let n=0;n<r.byteLength;n++)t+=`00${e.getUint8(n).toString(16)}`.slice(-2);return t}var bt=f(()=>{"use strict"});function A(r){let t=r,e,n,o,i,s,l,u,g,b;t=j(t);let c=t.match(/^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(|\.\d+)Z$/);if(c)return e=parseInt(c[1]),n=parseInt(c[2])-1,o=parseInt(c[3]),i=parseInt(c[4]),s=parseInt(c[5]),l=parseInt(c[6]),u=0,g=c[7],g!==""&&(b=`${g.substr(1)}00`.substr(0,3),u=parseInt(b)),Date.UTC(e,n,o,i,s,l,u);throw new Error(`unsupported zulu format: ${t}`)}function $t(r){let t=new Date(r),e=`0000${t.getUTCFullYear()}`.slice(-4),n=`00${t.getUTCMonth()+1}`.slice(-2),o=`00${t.getUTCDate()}`.slice(-2),i=`00${t.getUTCHours()}`.slice(-2),s=`00${t.getUTCMinutes()}`.slice(-2),l=`00${t.getUTCSeconds()}`.slice(-2),u=`000${t.getUTCMilliseconds()}`.slice(-3);return u=u.replace(/0+$/,""),u=u!==""?`.${u}`:u,`${e+n+o+i+s+l+u}Z`}function dt(r){return Math.round(A(r)/1e3)}function yt(r){return new Date(A(r))}function wt(r,t=!1,e=!1){let n,o=r.getUTCFullYear();if(t){if(o<1950||2049<o)throw new Error(`not proper year for UTCTime: ${o}`);n=`${o}`.slice(-2)}else n=`000${o}`.slice(-4);if(n+=`0${r.getUTCMonth()+1}`.slice(-2),n+=`0${r.getUTCDate()}`.slice(-2),n+=`0${r.getUTCHours()}`.slice(-2),n+=`0${r.getUTCMinutes()}`.slice(-2),n+=`0${r.getUTCSeconds()}`.slice(-2),e){let i=r.getUTCMilliseconds();if(i!==0){let s=`00${i}`.slice(-3);s=s.replace(/0+$/g,""),n+=`.${s}`}}return n+="Z",n}function j(r){return r.match(/^[0-9]{12}Z$/)||r.match(/^[0-9]{12}[.][0-9]*Z$/)?r.match(/^[0-4]/)?`20${r}`:`19${r}`:r}function It(r){let t=r.match(/^(\d{2,4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z$/);if(!t)throw new Error("Invalid format: expected YYYYMMDDHHmmssZ or YYYYMMDDHHmmssZ");let[,e,n,o,i,s,l]=t,u=e;return u.length===2&&(parseInt(u.slice(0,1))<5?u=`20${u}`:u=`19${u}`),`${u}-${n}-${o}T${i}:${s}:${l}Z`}function At(r,t=!1){let e=r.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z$/);if(!e)throw new Error("Invalid format: expected YYYY-MM-DDTHH:mm:ssZ");let[,n,o,i,s,l,u]=e,g=parseInt(n);if(t)if(1950<=g&&g<=2049)n=n.slice(2,4);else throw new Error(`Invalid year for UTCTime: ${n}`);return`${n}${o}${i}${s}${l}${u}Z`}var Bt=f(()=>{"use strict"});function B(r){let t=r,e="malformed IPv6 address";if(!t.match(/^[0-9A-Fa-f:]+$/))throw e;t=t.toLowerCase();let n=t.split(":").length-1;if(n<2)throw e;let o=":".repeat(7-n+2);t=t.replace("::",o);let i=t.split(":");if(i.length!==8)throw e;for(let s=0;s<8;s++)i[s]=`0000${i[s]}`.slice(-4);return i.join("")}function C(r){let t=r;if(!t.match(/^[0-9A-Fa-f]{32}$/))throw new Error(`malformed IPv6 address: ${t}`);t=t.toLowerCase();let e=t.match(/.{1,4}/g)||[];e=e.map(i=>i.replace(/^0+/,"")),e=e.map(i=>i===""?"0":i),t=`:${e.join(":")}:`;let n=t.match(/:(0:){2,}/g);if(n==null)return t.slice(1,-1);let o=n.sort().slice(-1)[0];return t=t.replace(o.substr(0,o.length-1),":"),t.substr(0,2)!=="::"&&(t=t.substr(1)),t.substr(-2,2)!=="::"&&(t=t.substr(0,t.length-1)),t}function k(r){let t=new Error("malformed hex value");if(!r.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw t;if(r.length===8){let e;try{return e=`${parseInt(r.substr(0,2),16)}.${parseInt(r.substr(2,2),16)}.${parseInt(r.substr(4,2),16)}.${parseInt(r.substr(6,2),16)}`,e}catch{throw t}}else if(r.length===16)try{return`${k(r.substr(0,8))}/${S(r.substr(8))}`}catch{throw t}else{if(r.length===32)return C(r);if(r.length===64)try{return`${C(r.substr(0,32))}/${S(r.substr(32))}`}catch{throw t}else return r}}function N(r){let t=r,e=new Error("malformed IP address");if(t=t.toLowerCase(),!t.match(/^[0-9a-f.:/]+$/))throw e;if(t.match(/^[0-9.]+$/)){let n=t.split(".");if(n.length!==4)throw e;let o="";try{for(let i=0;i<4;i++){let s=parseInt(n[i]);o+=`0${s.toString(16)}`.slice(-2)}return o}catch{throw e}}else if(t.match(/^[0-9.]+\/[0-9]+$/)){let n=t.split("/");return N(n[0])+U(parseInt(n[1]),32)}else{if(t.match(/^[0-9a-f:]+$/)&&t.indexOf(":")!==-1)return B(t);if(t.match(/^[0-9a-f:]+\/[0-9]+$/)&&t.indexOf(":")!==-1){let n=t.split("/");return B(n[0])+U(parseInt(n[1]),128)}else throw e}}function S(r){let t=new Error("malformed mask"),e;try{e=parseInt(r,16).toString(2)}catch{throw t}if(!e.match(/^1*0*$/))throw t;return e.replace(/0+$/,"").length}function U(r,t){if(t===32&&r===0)return"00000000";if(t===128&&r===0)return"00000000000000000000000000000000";let e=Array(r+1).join("1")+Array(t-r+1).join("0");return parseInt(e,2).toString(16)}var Ct=f(()=>{"use strict"});function St(r){function t(o){let i=parseInt(o.substr(0,2),16),s=parseInt(o.substr(2),16);if(i===0&&s<128)return String.fromCharCode(s);if(i<8){let b=192|(i&7)<<3|(s&192)>>6,c=128|s&63;return a(b.toString(16)+c.toString(16))}let l=224|(i&240)>>4,u=128|(i&15)<<2|(s&192)>>6,g=128|s&63;return a(l.toString(16)+u.toString(16)+g.toString(16))}let e=r.match(/.{4}/g);return e==null?"":e.map(t).join("")}var Ut=f(()=>{"use strict";m()});function Et(r){return r.length%2===1?`0${r}`:r}var Tt=f(()=>{"use strict"});var Dt={};Rt(Dt,{ArrayBuffertohex:()=>xt,BAtohex:()=>T,BAtos:()=>L,VERSION:()=>Ft,aryval:()=>nt,b64nltohex:()=>pt,b64tob64u:()=>w,b64tohex:()=>p,b64topem:()=>at,b64toutf8:()=>G,b64utob64:()=>h,b64utohex:()=>K,b64utoutf8:()=>H,binstrtobitstr:()=>X,binstrtonamearray:()=>et,bitstrtobinstr:()=>tt,datetozulu:()=>wt,encodeURIComponentAll:()=>V,foldnl:()=>I,hexpad:()=>Et,hextoArrayBuffer:()=>mt,hextoBA:()=>F,hextob64:()=>x,hextob64u:()=>q,hextoip:()=>k,hextoipv6:()=>C,hextopem:()=>ct,hextorstr:()=>J,hextouricmp:()=>d,hextoutf8:()=>a,inttobitstr:()=>z,ipnetmask:()=>U,ipprefixlen:()=>S,iptohex:()=>N,ipv6tohex:()=>B,isBase64:()=>R,isBase64URL:()=>it,ishex:()=>ot,iso8601tozulu:()=>At,iso88591hextoutf8:()=>ut,msectozulu:()=>$t,namearraytobinstr:()=>rt,pemtob64:()=>Y,pemtohex:()=>gt,rstrtob64:()=>W,rstrtohex:()=>Q,stoBA:()=>D,stohex:()=>$,strpad:()=>Z,timetogen:()=>j,ucs2hextoutf8:()=>St,uricmptohex:()=>O,utf8tob64:()=>_,utf8tob64u:()=>P,utf8tohex:()=>y,utf8toiso88591hex:()=>lt,zulutodate:()=>yt,zulutoiso8601:()=>It,zulutomsec:()=>A,zulutosec:()=>dt});var Ft,vt=f(()=>{"use strict";st();v();m();ft();ht();bt();Bt();M();Ct();Ut();Tt();Ft="typepki-strconv 0.10.0 kjur.github.io/typepki-strconv"});module.exports=(vt(),jt(Dt));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typepki-strconv",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "author": "Kenji Urushima <kenji.urushima@gmail.com>",
5
5
  "description": "TypeScript string converters and utilities sub module for TypePKI library (alpha version)",
6
6
  "homepage": "https://kjur.github.io/typepki-strconv",
package/src/conv_zulu.mts CHANGED
@@ -211,7 +211,8 @@ export function timetogen(s: string): string {
211
211
  * convert GeneralizedTime or UTCTime string to ISO8601 time string
212
212
  * @param s - GeneralizedTime or UTCTime string (ex. 20170412235959Z)
213
213
  * @return ISO8601 time string (ex. 2020-07-14T13:03:42Z)
214
- * @since 0.8.0
214
+ * @see {@link iso8601tozulu}
215
+ * @since 0.9.0
215
216
  *
216
217
  * @example
217
218
  * zulutoiso8601( "071231235959Z") -> "2007-12-31T23:59:59Z"
@@ -240,3 +241,43 @@ export function zulutoiso8601(s: string): string {
240
241
 
241
242
  return `${y2}-${mm}-${dd}T${hh}:${min}:${ss}Z`;
242
243
  }
244
+
245
+ /**
246
+ * convert ISO8601 time string to GeneralizedTime or UTCTime string
247
+ * @param s - ISO8601 time string (ex. 2020-07-14T13:03:42Z)
248
+ * @param flagUTC - return UTCTime when this flag is true
249
+ * @return GeneralizedTime or UTCTime string (ex. 20170412235959Z or 170412235959Z)
250
+ * @see {@link zulutoiso8601}
251
+ * @since 0.10.0
252
+ *
253
+ * @example
254
+ * iso8601tozulu("2007-12-31T23:59:59Z") -> "20071231235959Z"
255
+ * iso8601tozulu( "aaaaaaaaaa") -> raise error
256
+ * iso8601tozulu("2007-12-31T23:59:59Z", true) -> "071231235959Z"
257
+ * iso8601tozulu("2107-12-31T23:59:59Z", true) -> raise error, year shall be from 1950 to 2049
258
+ */
259
+ export function iso8601tozulu(
260
+ s: string,
261
+ flagUTC = false,
262
+ ): string {
263
+ const m = s.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z$/);
264
+ if (!m) {
265
+ throw new Error(
266
+ "Invalid format: expected YYYY-MM-DDTHH:mm:ssZ",
267
+ );
268
+ }
269
+
270
+ let [, yyyy, mm, dd, hh, min, ss] = m;
271
+
272
+ let y :number = parseInt(yyyy);
273
+ if (flagUTC) {
274
+ if (1950 <= y && y <= 2049) {
275
+ yyyy = yyyy.slice(2, 4);
276
+ } else {
277
+ throw new Error(`Invalid year for UTCTime: ${yyyy}`);
278
+ }
279
+ }
280
+
281
+ return `${yyyy}${mm}${dd}${hh}${min}${ss}Z`;
282
+ }
283
+
@@ -2,7 +2,9 @@ import { describe, expect, test } from "bun:test";
2
2
 
3
3
  import {
4
4
  datetozulu,
5
+ iso8601tozulu,
5
6
  msectozulu,
7
+ timetogen,
6
8
  zulutodate,
7
9
  zulutoiso8601,
8
10
  zulutomsec,
@@ -49,6 +51,13 @@ test("datetozulu", () => {
49
51
  expect(datetozulu(d, false, true)).toBe("20170520235959.67Z");
50
52
  });
51
53
 
54
+ test("timetogen", () => {
55
+ expect(timetogen( "071231235959Z")).toBe("20071231235959Z");
56
+ expect(timetogen( "971231235959Z")).toBe("19971231235959Z");
57
+ expect(timetogen("20071231235959Z")).toBe("20071231235959Z");
58
+ expect(timetogen( "971231235959.123Z")).toBe("19971231235959.123Z");
59
+ });
60
+
52
61
  test("zulutoiso8601", () => {
53
62
  expect(zulutoiso8601("071231235959Z")).toBe("2007-12-31T23:59:59Z");
54
63
  expect(zulutoiso8601("471231235959Z")).toBe("2047-12-31T23:59:59Z");
@@ -62,3 +71,15 @@ test("zulutoiso8601", () => {
62
71
  zulutoiso8601("aaaaaaa");
63
72
  }).toThrow(/Invalid format/);
64
73
  });
74
+
75
+ test("iso8601tozulu", () => {
76
+ expect(iso8601tozulu("2007-12-31T23:59:59Z")).toBe("20071231235959Z");
77
+ expect(iso8601tozulu("2007-12-31T23:59:59Z", true)).toBe("071231235959Z");
78
+ expect(iso8601tozulu("1988-12-31T23:59:59Z", true)).toBe("881231235959Z");
79
+ expect(() => {
80
+ iso8601tozulu("aaa");
81
+ }).toThrow(/Invalid format/);
82
+ expect(() => {
83
+ iso8601tozulu("2107-12-31T23:59:59Z", true);
84
+ }).toThrow(/Invalid year for UTCTime/);
85
+ });
package/src/index.mts CHANGED
@@ -1,4 +1,4 @@
1
- const VERSION: string = "typepki-strconv 0.9.0 kjur.github.io/typepki-strconv";
1
+ const VERSION: string = "typepki-strconv 0.10.0 kjur.github.io/typepki-strconv";
2
2
  export { VERSION };
3
3
 
4
4
  import { isBase64, isBase64URL, ishex } from "./checker.mts";
@@ -76,6 +76,7 @@ export { hextoArrayBuffer, ArrayBuffertohex };
76
76
 
77
77
  import {
78
78
  datetozulu,
79
+ iso8601tozulu,
79
80
  msectozulu,
80
81
  timetogen,
81
82
  zulutodate,
@@ -84,13 +85,14 @@ import {
84
85
  zulutosec,
85
86
  } from "./conv_zulu.mts";
86
87
  export {
87
- zulutomsec,
88
- msectozulu,
89
- zulutosec,
90
- zulutodate,
91
88
  datetozulu,
89
+ iso8601tozulu,
90
+ msectozulu,
92
91
  timetogen,
92
+ zulutodate,
93
93
  zulutoiso8601,
94
+ zulutomsec,
95
+ zulutosec,
94
96
  };
95
97
 
96
98
  import {