@subnoto/api-client 2.3.10 → 2.4.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/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var et=Object.create;var U=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var it=Object.getOwnPropertyNames;var rt=Object.getPrototypeOf,st=Object.prototype.hasOwnProperty;var ct=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ie=(e,t)=>{for(var i in t)U(e,i,{get:t[i],enumerable:!0})},pe=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of it(t))!st.call(e,s)&&s!==i&&U(e,s,{get:()=>t[s],enumerable:!(r=tt(t,s))||r.enumerable});return e};var q=(e,t,i)=>(i=e!=null?et(rt(e)):{},pe(t||!e||!e.__esModule?U(i,"default",{value:e,enumerable:!0}):i,e)),nt=e=>pe(U({},"__esModule",{value:!0}),e);var Ue=ct((xi,We)=>{"use strict";var Xt=require("path");We.exports=Xt.join(__dirname,"oak_session_wasm_nodejs_bg.wasm")});var y1={};ie(y1,{SubnotoClient:()=>te,SubnotoError:()=>m});module.exports=nt(y1);var Ze=q(require("openapi-fetch"));var X={};ie(X,{generateDigestHeaders:()=>ke,generateSignatureHeader:()=>Fe});var he=typeof Uint8Array=="function",b,V=class e{static decode(t){let i=typeof t=="string",r;if(b===void 0){let a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=`= \f
2
- \r \xA0\u2028\u2029`;for(b=[],r=0;r<64;++r)b[a.charCodeAt(r)]=r;for(r=0;r<u.length;++r)b[u.charCodeAt(r)]=-1;b[45]=b[43],b[95]=b[47]}let s=he?new Uint8Array(t.length*3>>2):[],o=0,d=0,c=0;for(r=0;r<t.length;++r){let a=i?t.charCodeAt(r):t[r];if(a==61)break;if(a=b[a],a!=-1){if(a===void 0)throw"Illegal character at offset "+r;o|=a,++d>=4?(s[c++]=o>>16,s[c++]=o>>8&255,s[c++]=o&255,o=0,d=0):o<<=6}}switch(d){case 1:throw"Base64 encoding incomplete: at least 2 bits missing";case 2:s[c++]=o>>10;break;case 3:s[c++]=o>>16,s[c++]=o>>8&255;break}return he&&s.length>c&&(s=s.subarray(0,c)),s}static pretty(t){let i=4-t.length%4;return i<4&&(t+="===".slice(0,i)),t=t.replace(/-/g,"+").replace(/_/g,"/"),t.replace(/.{80}/g,`$&
3
- `)}static unarmor(t){let i=e.re.exec(t);if(i)if(i[1])t=i[1];else if(i[2])t=i[2];else if(i[3])t=i[3];else throw"RegExp out of sync";return e.decode(t)}};V.re=/-----BEGIN [^-]+-----([A-Za-z0-9+/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+/=\s]+)====|^([A-Za-z0-9+/=\s]+)$/;var Se={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bits:6};var T={parse:function(t,i){return ot(t,Se,i)},stringify:function(t,i){return at(t,Se,i)}};function ot(e,t,i){var r;if(i===void 0&&(i={}),!t.codes){t.codes={};for(var s=0;s<t.chars.length;++s)t.codes[t.chars[s]]=s}if(!i.loose&&e.length*t.bits&7)throw new SyntaxError("Invalid padding");for(var o=e.length;e[o-1]==="=";)if(--o,!i.loose&&!((e.length-o)*t.bits&7))throw new SyntaxError("Invalid padding");for(var d=new((r=i.out)!=null?r:Uint8Array)(o*t.bits/8|0),c=0,a=0,u=0,S=0;S<o;++S){var n=t.codes[e[S]];if(n===void 0)throw new SyntaxError("Invalid character "+e[S]);a=a<<t.bits|n,c+=t.bits,c>=8&&(c-=8,d[u++]=255&a>>c)}if(c>=t.bits||255&a<<8-c)throw new SyntaxError("Unexpected end of data");return d}function at(e,t,i){i===void 0&&(i={});for(var r=i,s=r.pad,o=s===void 0?!0:s,d=(1<<t.bits)-1,c="",a=0,u=0,S=0;S<e.length;++S)for(u=u<<8|255&e[S],a+=8;a>t.bits;)a-=t.bits,c+=t.chars[d&u>>a];if(a&&(c+=t.chars[d&u<<t.bits-a]),o)for(;c.length*t.bits&7;)c+="=";return c}var dt=Object.create,Ie=Object.defineProperty,lt=Object.getOwnPropertyDescriptor,Ae=Object.getOwnPropertyNames,ut=Object.getPrototypeOf,pt=Object.prototype.hasOwnProperty,K=(e,t)=>function(){return t||(0,e[Ae(e)[0]])((t={exports:{}}).exports,t),t.exports},ht=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ae(t))!pt.call(e,s)&&s!==i&&Ie(e,s,{get:()=>t[s],enumerable:!(r=lt(t,s))||r.enumerable});return e},z=(e,t,i)=>(i=e!=null?dt(ut(e)):{},ht(t||!e||!e.__esModule?Ie(i,"default",{value:e,enumerable:!0}):i,e)),se=K({"node_modules/.pnpm/structured-headers@1.0.1/node_modules/structured-headers/dist/types.js"(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ByteSequence=void 0;var t=class{constructor(i){this.base64Value=i}toBase64(){return this.base64Value}};e.ByteSequence=t}}),j=K({"node_modules/.pnpm/structured-headers@1.0.1/node_modules/structured-headers/dist/util.js"(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isByteSequence=e.isInnerList=e.isValidKeyStr=e.isValidTokenStr=e.isAscii=void 0;var t=/^[\x20-\x7E]*$/,i=/^[a-zA-Z*][:/!#$%&'*+\-.^_`|~A-Za-z0-9]*$/,r=/^[a-z*][*\-_.a-z0-9]*$/;function s(u){return t.test(u)}e.isAscii=s;function o(u){return i.test(u)}e.isValidTokenStr=o;function d(u){return r.test(u)}e.isValidKeyStr=d;function c(u){return Array.isArray(u[0])}e.isInnerList=c;function a(u){return typeof u=="object"&&"base64Value"in u}e.isByteSequence=a}}),ce=K({"node_modules/.pnpm/structured-headers@1.0.1/node_modules/structured-headers/dist/token.js"(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Token=void 0;var t=j(),i=class{constructor(r){if(!(0,t.isValidTokenStr)(r))throw new TypeError("Invalid character in Token string. Tokens must start with *, A-Z and the rest of the string may only contain a-z, A-Z, 0-9, :/!#$%&'*+-.^_`|~");this.value=r}toString(){return this.value}};e.Token=i}}),St=K({"node_modules/.pnpm/structured-headers@1.0.1/node_modules/structured-headers/dist/serializer.js"(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.serializeKey=e.serializeParameters=e.serializeToken=e.serializeByteSequence=e.serializeBoolean=e.serializeString=e.serializeDecimal=e.serializeInteger=e.serializeBareItem=e.serializeInnerList=e.serializeItem=e.serializeDictionary=e.serializeList=e.SerializeError=void 0;var t=se(),i=ce(),r=j(),s=class extends Error{};e.SerializeError=s;function o(l){return l.map(C=>(0,r.isInnerList)(C)?a(C):c(C)).join(", ")}e.serializeList=o;function d(l){return Array.from(l.entries()).map(([C,A])=>{let E=N(C);return A[0]===!0?E+=I(A[1]):(E+="=",(0,r.isInnerList)(A)?E+=a(A):E+=c(A)),E}).join(", ")}e.serializeDictionary=d;function c(l){return u(l[0])+I(l[1])}e.serializeItem=c;function a(l){return`(${l[0].map(C=>c(C)).join(" ")})${I(l[1])}`}e.serializeInnerList=a;function u(l){if(typeof l=="number")return Number.isInteger(l)?S(l):n(l);if(typeof l=="string")return p(l);if(l instanceof i.Token)return W(l);if(l instanceof t.ByteSequence)return y(l);if(typeof l=="boolean")return f(l);throw new s(`Cannot serialize values of type ${typeof l}`)}e.serializeBareItem=u;function S(l){if(l<-999999999999999||l>999999999999999)throw new s("Structured headers can only encode integers in the range range of -999,999,999,999,999 to 999,999,999,999,999 inclusive");return l.toString()}e.serializeInteger=S;function n(l){let C=l.toFixed(3).replace(/0+$/,"");if(C.split(".")[0].replace("-","").length>12)throw new s("Fractional numbers are not allowed to have more than 12 significant digits before the decimal point");return C}e.serializeDecimal=n;function p(l){if(!(0,r.isAscii)(l))throw new s("Only ASCII strings may be serialized");return`"${l.replace(/("|\\)/g,C=>"\\"+C)}"`}e.serializeString=p;function f(l){return l?"?1":"?0"}e.serializeBoolean=f;function y(l){return`:${l.toBase64()}:`}e.serializeByteSequence=y;function W(l){return l.toString()}e.serializeToken=W;function I(l){return Array.from(l).map(([C,A])=>{let E=";"+N(C);return A!==!0&&(E+="="+u(A)),E}).join("")}e.serializeParameters=I;function N(l){if(!(0,r.isValidKeyStr)(l))throw new s("Keys in dictionaries must only contain lowercase letter, numbers, _-*. and must start with a letter or *");return l}e.serializeKey=N}}),ft=K({"node_modules/.pnpm/structured-headers@1.0.1/node_modules/structured-headers/dist/parser.js"(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ParseError=e.parseItem=e.parseList=e.parseDictionary=void 0;var t=se(),i=ce(),r=j();function s(n){return new a(n).parseDictionary()}e.parseDictionary=s;function o(n){return new a(n).parseList()}e.parseList=o;function d(n){return new a(n).parseItem()}e.parseItem=d;var c=class extends Error{constructor(n,p){super(`Parse error: ${p} at offset ${n}`)}};e.ParseError=c;var a=class{constructor(n){this.input=n,this.pos=0}parseDictionary(){this.skipWS();let n=new Map;for(;!this.eof();){let p=this.parseKey(),f;if(this.lookChar()==="="?(this.pos++,f=this.parseItemOrInnerList()):f=[!0,this.parseParameters()],n.set(p,f),this.skipOWS(),this.eof())return n;if(this.expectChar(","),this.pos++,this.skipOWS(),this.eof())throw new c(this.pos,"Dictionary contained a trailing comma")}return n}parseList(){this.skipWS();let n=[];for(;!this.eof();){if(n.push(this.parseItemOrInnerList()),this.skipOWS(),this.eof())return n;if(this.expectChar(","),this.pos++,this.skipOWS(),this.eof())throw new c(this.pos,"A list may not end with a trailing comma")}return n}parseItem(n=!0){n&&this.skipWS();let p=[this.parseBareItem(),this.parseParameters()];return n&&this.checkTrail(),p}parseItemOrInnerList(){return this.lookChar()==="("?this.parseInnerList():this.parseItem(!1)}parseInnerList(){this.expectChar("("),this.pos++;let n=[];for(;!this.eof();){if(this.skipWS(),this.lookChar()===")")return this.pos++,[n,this.parseParameters()];n.push(this.parseItem(!1));let p=this.lookChar();if(p!==" "&&p!==")")throw new c(this.pos,"Expected a whitespace or ) after every item in an inner list")}throw new c(this.pos,"Could not find end of inner list")}parseBareItem(){let n=this.lookChar();if(n===void 0)throw new c(this.pos,"Unexpected end of string");if(n.match(/^[-0-9]/))return this.parseIntegerOrDecimal();if(n==='"')return this.parseString();if(n.match(/^[A-Za-z*]/))return this.parseToken();if(n===":")return this.parseByteSequence();if(n==="?")return this.parseBoolean();throw new c(this.pos,"Unexpected input")}parseParameters(){let n=new Map;for(;!this.eof()&&this.lookChar()===";";){this.pos++,this.skipWS();let f=this.parseKey(),y=!0;this.lookChar()==="="&&(this.pos++,y=this.parseBareItem()),n.set(f,y)}return n}parseIntegerOrDecimal(){let n="integer",p=1,f="";if(this.lookChar()==="-"&&(p=-1,this.pos++),!S(this.lookChar()))throw new c(this.pos,"Expected a digit (0-9)");for(;!this.eof();){let y=this.getChar();if(S(y))f+=y;else if(n==="integer"&&y==="."){if(f.length>12)throw new c(this.pos,"Exceeded maximum decimal length");f+=".",n="decimal"}else{this.pos--;break}if(n==="integer"&&f.length>15)throw new c(this.pos,"Exceeded maximum integer length");if(n==="decimal"&&f.length>16)throw new c(this.pos,"Exceeded maximum decimal length")}if(n==="integer")return parseInt(f,10)*p;if(f.endsWith("."))throw new c(this.pos,"Decimal cannot end on a period");if(f.split(".")[1].length>3)throw new c(this.pos,"Number of digits after the decimal point cannot exceed 3");return parseFloat(f)*p}parseString(){let n="";for(this.expectChar('"'),this.pos++;!this.eof();){let p=this.getChar();if(p==="\\"){if(this.eof())throw new c(this.pos,"Unexpected end of input");let f=this.getChar();if(f!=="\\"&&f!=='"')throw new c(this.pos,"A backslash must be followed by another backslash or double quote");n+=f}else{if(p==='"')return n;if((0,r.isAscii)(p))n+=p;else throw new c(this.pos,"Strings must be in the ASCII range")}}throw new c(this.pos,"Unexpected end of input")}parseToken(){let n="";for(;!this.eof();){let p=this.lookChar();if(p===void 0||!/^[:/!#$%&'*+\-.^_`|~A-Za-z0-9]$/.test(p))return new i.Token(n);n+=this.getChar()}return new i.Token(n)}parseByteSequence(){this.expectChar(":"),this.pos++;let n=this.input.indexOf(":",this.pos);if(n===-1)throw new c(this.pos,'Could not find a closing ":" character to mark end of Byte Sequence');let p=this.input.substring(this.pos,n);if(this.pos+=p.length+1,!/^[A-Za-z0-9+/=]*$/.test(p))throw new c(this.pos,"ByteSequence does not contain a valid base64 string");return new t.ByteSequence(p)}parseBoolean(){this.expectChar("?"),this.pos++;let n=this.getChar();if(n==="1")return!0;if(n==="0")return!1;throw new c(this.pos,'Unexpected character. Expected a "1" or a "0"')}parseKey(){var n;if(!(!((n=this.lookChar())===null||n===void 0)&&n.match(/^[a-z*]/)))throw new c(this.pos,"A key must begin with an asterisk or letter (a-z)");let p="";for(;!this.eof();){let f=this.lookChar();if(f===void 0||!/^[a-z0-9_\-.*]$/.test(f))return p;p+=this.getChar()}return p}lookChar(){return this.input[this.pos]}expectChar(n){if(this.lookChar()!==n)throw new c(this.pos,`Expected ${n}`)}getChar(){return this.input[this.pos++]}eof(){return this.pos>=this.input.length}skipOWS(){for(;;){let n=this.input.substr(this.pos,1);if(n===" "||n===" ")this.pos++;else break}}skipWS(){for(;this.lookChar()===" ";)this.pos++}checkTrail(){if(this.skipWS(),!this.eof())throw new c(this.pos,"Unexpected characters at end of input")}};e.default=a;var u=/^[0-9]$/;function S(n){return n===void 0?!1:u.test(n)}}}),$=K({"node_modules/.pnpm/structured-headers@1.0.1/node_modules/structured-headers/dist/index.js"(e){"use strict";var t=e&&e.__createBinding||(Object.create?function(s,o,d,c){c===void 0&&(c=d);var a=Object.getOwnPropertyDescriptor(o,d);(!a||("get"in a?!o.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return o[d]}}),Object.defineProperty(s,c,a)}:function(s,o,d,c){c===void 0&&(c=d),s[c]=o[d]}),i=e&&e.__exportStar||function(s,o){for(var d in s)d!=="default"&&!Object.prototype.hasOwnProperty.call(o,d)&&t(o,s,d)};Object.defineProperty(e,"__esModule",{value:!0}),e.Token=void 0,i(St(),e),i(ft(),e),i(se(),e),i(j(),e);var r=ce();Object.defineProperty(e,"Token",{enumerable:!0,get:function(){return r.Token}})}});var B1=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);var be=new TextEncoder;async function mt(){return globalThis.crypto??(await import("node:crypto")).webcrypto}var gt=/[^\S\r\n]*\r?\n[^\S\r\n]+/g;function fe(e){return e.replaceAll(gt," ")}function k(e){if(typeof e=="number")return e.toString();if(!e)return"";if(typeof e=="string")return fe(e).trim();if(Array.isArray(e))return e.map(t=>{if(t==null)return"";if(typeof t=="number")return t.toString();if(typeof t=="string")return fe(t).trim();throw new Error(`Invalid header value type ${t}`)}).join(", ");throw new Error(`Invalid header value type ${e}`)}function L(e){return Object.entries(e).reduce((t,[i,r])=>(i==="__proto__"||(t[i.toLowerCase()]=r),t),{})}function me(e,t){t=t.toLowerCase();for(let[i,r]of Object.entries(e))if(i.toLowerCase()===t)return r}function Ct(e){return typeof e=="number"?e.toString():typeof e=="string"?e.toLowerCase():""}function re(e){return e.reduce((t,i,r)=>{if(r%2===0){if(typeof i!="string")throw new Error(`Invalid header key type '${typeof i}' of ${i}`);if(i.toLowerCase()in t)return t;t[i.toLowerCase()]=[]}else t[Ct(e[r-1])].push(i==null?"":i.toString());return t},{})}function _(e){if("rawHeaders"in e&&e.rawHeaders)return re(e.rawHeaders.flat(1));if("getHeaders"in e&&typeof e.getHeaders=="function")return L(e.getHeaders());if("headers"in e&&e.headers){if(typeof e.headers!="object")throw new Error("headers must be an object");return Te(e.headers)?re(Array.from(e.headers.entries()).flat(1)):Array.isArray(e.headers)?re(e.headers.flat(1)):L(e.headers)}throw new Error("Cannot get headers from request object")}function Ee(e,t,i){if("setHeader"in e&&typeof e.setHeader=="function")e.setHeader(t,i.toString());else if("headers"in e&&typeof e.headers=="object")Te(e.headers)?e.headers.set(t,i.toString()):e.headers[t]=i.toString();else throw new Error("Cannot set headers to request object")}function ge(e){return"Response"in globalThis&&typeof e=="object"&&e instanceof Response}function yt(e){return"Request"in globalThis&&typeof e=="object"&&e instanceof Request}function Te(e){return"Headers"in globalThis&&typeof e=="object"&&e instanceof Headers}function Pe(e){let t=new Uint8Array(e);return T.stringify(t)}var It={hash:"SHA-256",ec:"DSA"};function At(e,t){return{hash:t,...e}}function ne(e){return e instanceof Map?new Map(e):Array.isArray(e)?new Map(e):new Map(Object.entries(e))}function Ce(e){let t=ne(e);for(let[i,r]of t.entries())r===void 0&&t.delete(i);return t}var g=z($(),1),bt={signature:"dict","signature-input":"dict","accept-signature":"dict","content-digest":"dict","repr-digest":"dict","want-content-digest":"dict","want-repr-digest":"dict","accept-ch":"list","proxy-status":"list","cache-status":"list",priority:"dict","client-cert":"bs","client-cert-chain":"list"},Et=["@method","@authority","@scheme","@target-uri","@request-target","@path","@query"],Tt=["@status"],we=class{isRequest(){return this.response===null}isResponse(){return this.response!==null}constructor(e,t="https",i={},r,s=null){if(s&&!Array.isArray(s))throw new Error("requiredComponents must be an array");if(s&&s.length>0?this.requiredComponents=s.map(c=>{let a;return c.startsWith('"')?a=g.parseItem(c):a=[c,new Map],g.serializeItem(a)}):this.requiredComponents=null,this.sfvTypeDictionary=L({...bt,...i}),"req"in e)this.response=e,this.responseHeaders=_(e),this.request=e.req,this.requestHeaders=_(this.request);else if(ge(e)){if(!r)throw new Error("Request is not provided");this.response=e,this.responseHeaders=_(e),this.request=r,this.requestHeaders=_(this.request)}else this.response=null,this.responseHeaders=null,this.request=e,this.requestHeaders=_(e);if(!this.request.url)throw new Error("Request URL is empty");if(!this.request.method)throw new Error("Request method is empty");if(!("signature-input"in this.requestHeaders))throw new Error("Signature-Input header is not found in request");if(this.requestSignatureInput=g.parseDictionary(k(this.requestHeaders["signature-input"])),this.isResponse()){if(!this.responseHeaders)throw new Error("responseHeaders is empty");if(!("signature-input"in this.responseHeaders))throw new Error("Signature-Input header is not found in response");this.responseSignatureInput=g.parseDictionary(k(this.responseHeaders["signature-input"]))}this.sfvTypeDictionary=L(i),this.scheme=this.request.url.startsWith("/")?t:new URL(this.request.url).protocol.replace(":","");let o="httpVersionMajor"in this.request&&this.request.httpVersionMajor===2?this.requestHeaders[":authority"]:this.requestHeaders.host;if(!yt(this.request)&&!o)throw new Error("Host header is empty");let d=k(o);this.targetUri=this.request.url.startsWith("/")?new URL(this.request.url,`${t}://${d}`).href:this.request.url,this.url=new URL(this.targetUri)}get(e,t=new Map){let i=ne(t),r=g.serializeItem([e,i]);if(!e)throw new Error(`Type is empty: ${r}`);if(e.startsWith('"'))if(e.endsWith('"'))e=e.slice(1,-1);else throw new Error(`Invalid component type string: ${r}`);if(this.isResponse()&&i.get("req")!==!0&&Et.includes(e))throw new Error(`component is not available in response (must use with ;req, or provided object is unintentionally treated as response (existing req prop.)): ${e}`);if(this.isRequest()&&Tt.includes(e))throw new Error(`component is not available in request (provided object is unintentionally treated as request (including req prop.)): ${e}`);if(this.isRequest()&&i.get("req")===!0)throw new Error("req param is not available in request (provided object is treated as request, please set req param with Request)");let s=this.isRequest()||i.get("req")===!0;if(e==="@signature-params")throw new Error(`@signature-params is not available in get method: ${r}`);if(e==="@method"){if(!this.request.method)throw new Error("Request method is empty");return this.request.method.toUpperCase()}else{if(e==="@authority")return this.url.host;if(e==="@scheme")return this.scheme.toLocaleLowerCase();if(e==="@target-uri")return this.targetUri;if(e==="@request-target"){if(!this.request.method)throw new Error("Request method is empty");return`${this.request.method.toLowerCase()} ${this.url.pathname}`}else{if(e==="@path")return this.url.pathname;if(e==="@query")return this.url.search;if(e==="@query-param"){let o=i.get("name");if(o===void 0)throw new Error("Query parameter name not found or invalid");let d=this.url.searchParams.get(o.toString());if(d===null)throw new Error(`Query parameter not found: ${o} (${r})`);return d}else if(e==="@status"){if(!this.response)throw new Error("response is empty (@status)");return ge(this.response)?this.response.status.toString():this.response.statusCode.toString()}else{if(e.startsWith("@"))throw new Error(`Unknown derived component: ${e}`);{let o=i.get("key"),d=i.get("sf")===!0,c=i.get("bs")===!0,a=i.get("tr")===!0;if([o,d,c].filter(S=>S).length>1)throw new Error(`Invalid component: ${r} (multiple params are specified)`);let u=(()=>{if(s)if(a){if("trailers"in this.request&&this.request.trailers)return me(this.request.trailers,e);throw new Error(`Trailers not found in request object (${r})`)}else return this.requestHeaders[e];else{if(!this.response||!this.responseHeaders)throw new Error("response is not provided");if(a){if("trailers"in this.response&&this.response.trailers)return me(this.response.trailers,e);throw new Error(`Trailers not found in response object (${r})`)}else return this.responseHeaders[e]}})();if(u===void 0)throw new Error(`Header not found: ${r}`);if(d){if(!(e in this.sfvTypeDictionary))throw new Error(`Type not found in SFV type dictionary: ${e}`);let S=k(u);if(this.sfvTypeDictionary[e]==="dict")return g.serializeDictionary(g.parseDictionary(S));if(this.sfvTypeDictionary[e]==="list")return g.serializeList(g.parseList(S));if(["item","bs","int","dec","str","bool","token"].includes(this.sfvTypeDictionary[e]))return g.serializeItem(g.parseItem(S))}if(o){if(!(e in this.sfvTypeDictionary))throw new Error(`key specified but type unknown (Type not found in SFV type dictionary): ${r}`);if(typeof u!="string")throw new Error(`Key specified but value is not a string: ${r}`);if(this.sfvTypeDictionary[e]==="dict"){let n=g.parseDictionary(u).get(o);if(n===void 0)throw new Error(`Key not found in dictionary: ${o} (${r})`);return Array.isArray(n[0])?g.serializeList([n]):g.serializeItem(n)}else throw new Error(`"${e}" is not dict: ${this.sfvTypeDictionary[e]} (${r})`)}if(c){let S=(Array.isArray(u)?u:[u]).map(n=>{if(typeof n!="string")throw new Error(`Invalid header value type: ${typeof n}`);return[new g.ByteSequence(Pe(be.encode(k(n)).buffer)),new Map]});return g.serializeList(S)}return k(u)}}}}}generate(e){let t=this.isRequest()?this.requestSignatureInput?.get(e):this.responseSignatureInput?.get(e);if(!t)throw new Error(`label not found: ${e}`);if(!Array.isArray(t[0]))throw new Error(`item is not InnerList: ${g.serializeDictionary(new Map([[e,t]]))}`);let i=new Map;for(let r of t[0]){let s=r[0];if(s.startsWith('"'))if(s.endsWith('"'))s=s.slice(1,-1);else throw new Error(`Invalid component identifier name: ${s}`);r[0]=s;let o=g.serializeItem(r);if(i.has(o))throw new Error(`Duplicate key: ${s}`);i.set(o,this.get(s,r[1]))}if(this.requiredComponents){for(let r of this.requiredComponents)if(!i.has(r))throw new Error(`Required component not found: ${r}`)}return i.set('"@signature-params"',g.serializeInnerList(t)),Array.from(i.entries(),([r,s])=>`${r}: ${s}`).join(`
4
- `)}};function De(e){let t=ne(e),i=new Map;for(let[r,s]of t){if(!Array.isArray(s))throw new Error("item is not array");let[o,d]=s;i.set(r,[o.map(c=>typeof c=="string"?[c,new Map]:[c[0],Ce(c[1])]),Ce(d)])}return g.serializeDictionary(i)}var H1=z($(),1);async function Me(e,t,i=It){let r=await(await mt()).subtle.sign(At(e.algorithm,i.hash),e,be.encode(t));return Pe(r)}var W1=z($(),1);function ve(e){let t=e.toUpperCase();if(t==="SHA-256")return"sha-256";if(t==="SHA-512")return"sha-512";throw new Error(`Unsupported hash algorithm: ${e}`)}var V1=z($(),1);async function Q(){return globalThis.crypto??(await import("node:crypto")).webcrypto}var Ne=e=>{let t=new Uint8Array(e);return T.stringify(t)};var Pt=async(e,t="SHA-256")=>(t==="SHA"&&(t="SHA-1"),typeof e=="string"&&(e=new TextEncoder().encode(e)),(await Q()).subtle.digest(t,e)),ke=async e=>{let t="SHA-256",i=await Pt(e.body,t).then(Ne),r=`${t}=${i}`,s=`${ve(t)}=:${i}:`;return{digest:r,contentDigest:s}};var wt=/^[\x20-\x7E]*$/,Dt=/^[a-zA-Z*][:/!#$%&'*+\-.^_`|~A-Za-z0-9]*$/,Mt=/^[a-z*][*\-_.a-z0-9]*$/;function oe(e){return wt.test(e)}function Ke(e){return Dt.test(e)}function Re(e){return Mt.test(e)}function Oe(e){return Array.isArray(e[0])}function xe(e){let t=new Uint8Array(e),i="";for(let r of t)i+=String.fromCharCode(r);return btoa(i)}function ae(e){let t=atob(e),i=t.length,r=new Uint8Array(i);for(let s=0;s<i;s++)r[s]=t.charCodeAt(s);return r.buffer}var R=class{constructor(t){if(!Ke(t))throw new TypeError("Invalid character in Token string. Tokens must start with *, A-Z and the rest of the string may only contain a-z, A-Z, 0-9, :/!#$%&'*+-.^_`|~");this.value=t}toString(){return this.value}};var O=class{constructor(t){this.value=t}toString(){return this.value}};var w=class extends Error{};function Be(e){let t=e instanceof Map?e.entries():Object.entries(e);return Array.from(t).map(([i,r])=>{let s=Xe(i);return Array.isArray(r)?r[0]===!0?s+J(r[1]):Oe(r)?s+"="+vt(r):s+"="+_e(r):r===!0?s:s+"="+Z(r)}).join(", ")}function _e(e,t){return Array.isArray(e)?Z(e[0])+J(e[1]):Z(e)+(t?J(t):"")}function vt(e){return`(${e[0].map(t=>_e(t)).join(" ")})${J(e[1])}`}function Z(e){if(typeof e=="number")return Number.isInteger(e)?Nt(e):kt(e);if(typeof e=="string")return Kt(e);if(e instanceof R)return Bt(e);if(e instanceof ArrayBuffer)return xt(e);if(e instanceof O)return Rt(e);if(e instanceof Date)return _t(e);if(typeof e=="boolean")return Ot(e);throw new w(`Cannot serialize values of type ${typeof e}`)}function Nt(e){if(e<-999999999999999||e>999999999999999)throw new w("Structured headers can only encode integers in the range range of -999,999,999,999,999 to 999,999,999,999,999 inclusive");return e.toString()}function kt(e){let t=e.toFixed(3).replace(/0+$/,"");if(t.split(".")[0].replace("-","").length>12)throw new w("Fractional numbers are not allowed to have more than 12 significant digits before the decimal point");return t}function Kt(e){if(!oe(e))throw new w("Only ASCII strings may be serialized");return`"${e.replace(/("|\\)/g,t=>"\\"+t)}"`}function Rt(e){let t='%"',i=new TextEncoder;for(let r of i.encode(e.toString()))r===37||r===34||r<=31||r>=127?t+="%"+r.toString(16):t+=String.fromCharCode(r);return t+'"'}function Ot(e){return e?"?1":"?0"}function xt(e){return`:${xe(e)}:`}function Bt(e){return e.toString()}function _t(e){return"@"+Math.floor(e.getTime()/1e3)}function J(e){return Array.from(e).map(([t,i])=>{let r=";"+Xe(t);return i!==!0&&(r+="="+Z(i)),r}).join("")}function Xe(e){if(!Re(e))throw new w("Keys in dictionaries must only contain lowercase letter, numbers, _-*. and must start with a letter or *");return e}var Fe=async e=>{let{request:t,authenticationType:i,accessKey:r,secretKey:s,creationDate:o}=e,d={key_ops:["sign","verify"],ext:!0,kty:"oct",k:s,alg:"HS256"},c=await(await Q()).subtle.importKey("jwk",d,{name:"HMAC",hash:"SHA-256"},!0,["sign","verify"]),a=new Map,u=new Map;a.set(i,c),u.set(i,[["x-timestamp","@authority","content-type","content-digest","content-length"],{keyid:r,created:o,alg:"hmac-sha256"}]);let S=De(u);Ee(t,"Signature-Input",S);let n=new we(t),p=(n.isRequest()?n.requestSignatureInput:n.responseSignatureInput)?.keys();if(!p)throw new Error("signaturesEntries is undefined");let f=new Map,y=new Map;for(let I of p){let N=n.generate(I),l=a.get(I);if(!l)throw new Error(`key not found: ${I}`);y.set(I,N),f.set(I,[ae(await Me(l,N,{hash:"SHA-256",ec:"DSA"})),new Map])}let W=Be(f);return{signatureInputHeader:S,signatureHeader:W}};function He(e){return{async onRequest({request:t}){let i=t.clone(),r=i.url,s=await i.arrayBuffer()??JSON.stringify({}),o=i.method??"POST",d=await X.generateDigestHeaders({body:s}),c={headers:{"X-Timestamp":Date.now().toString(),Host:new URL(r).host,"Content-Type":i.headers.get("Content-Type")??"application/json","Content-Length":i.headers.get("Content-Length")??s.byteLength.toString(),Digest:d.digest,"Content-Digest":d.contentDigest},body:s.toString(),method:o,url:r},{signatureHeader:a,signatureInputHeader:u}=await X.generateSignatureHeader({request:c,authenticationType:"team",accessKey:e.accessKey,secretKey:Buffer.from(e.secretKey,"hex").toString("base64"),creationDate:Math.floor(Date.now()/1e3)});return t.headers.set("Signature",a),t.headers.set("Signature-Input",u),t.headers.set("X-Timestamp",c.headers["X-Timestamp"]),t.headers.set("Content-Type",c.headers["Content-Type"]),t.headers.set("Digest",c.headers.Digest),t.headers.set("Content-Digest",c.headers["Content-Digest"]),t}}}var m=class extends Error{statusCode;code;constructor(t,i,r){super(t),this.statusCode=i,this.code=r,this.name="SubnotoError"}};function Ge(e){return{async onRequest({request:t}){if(!t.url.includes("/tunnel/")&&!t.url.includes("/public/")||t.url.includes("/tunnel/session"))return t;try{await e.ensureSession();let i=t.clone(),r=Buffer.from(await i.arrayBuffer());if(!r||r.byteLength===0)throw new m("EMPTY_REQUEST_BODY");let s=e.encryptRequest(r);if(!s||s.byteLength===0)throw new m("Empty encrypted message");let o=e.getSessionId();if(!o)throw new m("Session ID not available");let d=new Headers(i.headers);d.set("X-Session-Id",o);let c=i.headers.get("Content-Type");c&&c.includes("multipart/form-data")&&d.set("X-Original-Content-Type",c),d.set("Content-Type","application/octet-stream"),d.set("Content-Length",s.byteLength.toString());let a=await e.getCookies(i.url);return a&&d.set("Cookie",a),new Request(i.url,{method:i.method,headers:d,body:s,mode:i.mode,credentials:i.credentials,cache:i.cache,redirect:i.redirect,referrer:i.referrer,referrerPolicy:i.referrerPolicy,integrity:i.integrity,keepalive:i.keepalive})}catch(i){throw console.error(`Error in tunnel middleware for ${t.url}:`,i),i}},async onResponse({response:t,request:i}){if(!i.url.includes("/tunnel/")&&!i.url.includes("/public/")||i.url.includes("/tunnel/session"))return t;try{if(!(t.headers.get("x-subnoto-encrypted-response")?.includes("true")&&t.headers.get("content-type")?.includes("application/octet-stream")))return t;let s=t.clone(),o=Buffer.from(await s.arrayBuffer());if(o.byteLength===0)throw new m("Empty encrypted response");let d=e.decryptResponse(o),c=new Headers(t.headers);return c.get("x-subnoto-content-type-response")?.includes("application/octet-stream")?(c.set("Content-Type","application/octet-stream"),c.delete("x-subnoto-encrypted-response"),new Response(d,{status:t.status,statusText:t.statusText,headers:c})):(c.set("Content-Type","application/json"),c.delete("x-subnoto-encrypted-response"),c.delete("x-subnoto-content-type-response"),new Response(d,{status:t.status,statusText:t.statusText,headers:c}))}catch(r){throw console.error(`Error decrypting response for ${i.url}:`,r),r}}}}var Le=q(Ue());var le={};ie(le,{PutIncomingMessageResult:()=>Wt,WasmClientSession:()=>v,__wbg___wbindgen_is_function_ee8a6c5833c90377:()=>Ut,__wbg___wbindgen_is_object_c818261d21f283a4:()=>qt,__wbg___wbindgen_is_string_fbb76cb2940daafd:()=>Vt,__wbg___wbindgen_is_undefined_2d472862bd29a478:()=>Lt,__wbg___wbindgen_throw_b855445ff6a94295:()=>zt,__wbg_call_525440f72fbfc0ea:()=>jt,__wbg_call_e762c39fa8ea36bf:()=>$t,__wbg_crypto_574e78ad8b13b65f:()=>Qt,__wbg_getRandomValues_b8f5dbd5f3995a9e:()=>Zt,__wbg_length_69bca3cb64fc8748:()=>Jt,__wbg_msCrypto_a61aeb35a24c1329:()=>Yt,__wbg_new_no_args_ee98eee5275000a4:()=>e1,__wbg_new_with_length_01aa0dc35aa13543:()=>t1,__wbg_node_905d3e251edff8a2:()=>i1,__wbg_now_793306c526e2e3b6:()=>r1,__wbg_process_dc0fbacc7c1c06f7:()=>s1,__wbg_prototypesetcall_2a6620b6922694b2:()=>c1,__wbg_randomFillSync_ac0988aba3254290:()=>n1,__wbg_require_60cc747a6bc5215a:()=>o1,__wbg_set_wasm:()=>Ht,__wbg_static_accessor_GLOBAL_89e1d9ac6a1b250e:()=>a1,__wbg_static_accessor_GLOBAL_THIS_8b530f326a9e48ac:()=>d1,__wbg_static_accessor_SELF_6fdf4b64710cc91b:()=>l1,__wbg_static_accessor_WINDOW_b45bfc5a37f6cfa2:()=>u1,__wbg_subarray_480600f3d6a9f26c:()=>p1,__wbg_versions_c01dfd4722a88165:()=>h1,__wbindgen_cast_2241b6af4c4b2941:()=>S1,__wbindgen_cast_cb9088102bce6b30:()=>f1,__wbindgen_init_externref_table:()=>m1});var h,Ft;function Ht(e,t){h=e,Ft=t}var Y=null;function de(){return(Y===null||Y.byteLength===0)&&(Y=new Uint8Array(h.memory.buffer)),Y}var Ve=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});Ve.decode();function Gt(e,t){return Ve.decode(de().subarray(e,e+t))}function F(e,t){return e=e>>>0,Gt(e,t)}function H(e){let t=h.__externref_table_alloc();return h.__wbindgen_externrefs.set(t,e),t}function G(e,t){try{return e.apply(this,t)}catch(i){let r=H(i);h.__wbindgen_exn_store(r)}}function M(e,t){return e=e>>>0,de().subarray(e/1,e/1+t)}function B(e){return e==null}var D=0;function x(e,t){let i=t(e.length*1,1)>>>0;return de().set(e,i/1),D=e.length,i}function P(e){let t=h.__wbindgen_externrefs.get(e);return h.__externref_table_dealloc(e),t}var Wt=Object.freeze({NoIncomingMessageExpected:0,0:"NoIncomingMessageExpected",Success:1,1:"Success"}),qe=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>h.__wbg_wasmclientsession_free(e>>>0,1)),v=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,qe.unregister(this),t}free(){let t=this.__destroy_into_raw();h.__wbg_wasmclientsession_free(t,0)}constructor(t,i){var r=B(i)?0:x(i,h.__wbindgen_malloc),s=D;let o=h.wasmclientsession_new(B(t)?16777215:t?1:0,r,s);if(o[2])throw P(o[1]);return this.__wbg_ptr=o[0]>>>0,qe.register(this,this.__wbg_ptr,this),this}is_open(){return h.wasmclientsession_is_open(this.__wbg_ptr)!==0}write(t){let i=x(t,h.__wbindgen_malloc),r=D,s=h.wasmclientsession_write(this.__wbg_ptr,i,r);if(s[3])throw P(s[2]);var o=M(s[0],s[1]).slice();return h.__wbindgen_free(s[0],s[1]*1,1),o}read(t){let i=x(t,h.__wbindgen_malloc),r=D,s=h.wasmclientsession_read(this.__wbg_ptr,i,r);if(s[3])throw P(s[2]);var o=M(s[0],s[1]).slice();return h.__wbindgen_free(s[0],s[1]*1,1),o}write_buffer(t){let i=x(t,h.__wbindgen_malloc),r=D,s=h.wasmclientsession_write_buffer(this.__wbg_ptr,i,r);if(s[3])throw P(s[2]);var o=M(s[0],s[1]).slice();return h.__wbindgen_free(s[0],s[1]*1,1),o}read_buffer(t){let i=x(t,h.__wbindgen_malloc),r=D,s=h.wasmclientsession_read_buffer(this.__wbg_ptr,i,r);if(s[3])throw P(s[2]);var o=M(s[0],s[1]).slice();return h.__wbindgen_free(s[0],s[1]*1,1),o}put_incoming_message(t){let i=x(t,h.__wbindgen_malloc),r=D,s=h.wasmclientsession_put_incoming_message(this.__wbg_ptr,i,r);if(s[2])throw P(s[1]);return s[0]}get_outgoing_message(){let t=h.wasmclientsession_get_outgoing_message(this.__wbg_ptr);if(t[3])throw P(t[2]);let i;return t[0]!==0&&(i=M(t[0],t[1]).slice(),h.__wbindgen_free(t[0],t[1]*1,1)),i}get_attestation_results_json(){let t=h.wasmclientsession_get_attestation_results_json(this.__wbg_ptr);if(t[3])throw P(t[2]);let i;return t[0]!==0&&(i=F(t[0],t[1]).slice(),h.__wbindgen_free(t[0],t[1]*1,1)),i}get_attestation_status(){let t,i;try{let r=h.wasmclientsession_get_attestation_status(this.__wbg_ptr);return t=r[0],i=r[1],F(r[0],r[1])}finally{h.__wbindgen_free(t,i,1)}}};Symbol.dispose&&(v.prototype[Symbol.dispose]=v.prototype.free);function Ut(e){return typeof e=="function"}function qt(e){let t=e;return typeof t=="object"&&t!==null}function Vt(e){return typeof e=="string"}function Lt(e){return e===void 0}function zt(e,t){throw new Error(F(e,t))}function jt(){return G(function(e,t,i){return e.call(t,i)},arguments)}function $t(){return G(function(e,t){return e.call(t)},arguments)}function Qt(e){return e.crypto}function Zt(){return G(function(e,t){e.getRandomValues(t)},arguments)}function Jt(e){return e.length}function Yt(e){return e.msCrypto}function e1(e,t){return new Function(F(e,t))}function t1(e){return new Uint8Array(e>>>0)}function i1(e){return e.node}function r1(){return Date.now()}function s1(e){return e.process}function c1(e,t,i){Uint8Array.prototype.set.call(M(e,t),i)}function n1(){return G(function(e,t){e.randomFillSync(t)},arguments)}function o1(){return G(function(){return module.require},arguments)}function a1(){let e=typeof global>"u"?null:global;return B(e)?0:H(e)}function d1(){let e=typeof globalThis>"u"?null:globalThis;return B(e)?0:H(e)}function l1(){let e=typeof self>"u"?null:self;return B(e)?0:H(e)}function u1(){let e=typeof window>"u"?null:window;return B(e)?0:H(e)}function p1(e,t,i){return e.subarray(t>>>0,i>>>0)}function h1(e){return e.versions}function S1(e,t){return F(e,t)}function f1(e,t){return M(e,t)}function m1(){let e=h.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)}var ze=require("node:fs"),ue={};ue["./oak_session_wasm_nodejs_bg.js"]=le;var g1=require("url").pathToFileURL(Le.default),C1=(0,ze.readFileSync)(g1),je=new WebAssembly.Module(C1),$e=new WebAssembly.Instance(je,ue).exports;ue["./oak_session_wasm_nodejs_bg.js"].__wbg_set_wasm($e,je);$e.__wbindgen_start();var Qe=require("tough-cookie");var ee=class{session=null;sessionId=null;config;handshakeInProgress=!1;cookieJar;constructor(t){this.config=t,this.cookieJar=new Qe.CookieJar}async ensureSession(){if(!(this.session&&this.session.is_open())){if(this.handshakeInProgress){for(;this.handshakeInProgress;)await new Promise(t=>setTimeout(t,50));return}await this.handshake()}}async handshake(){this.handshakeInProgress=!0;try{let t=this.config.unattested??!1;this.session=new v(t,t?void 0:this.config.attesterKey);let i=4,r=0;if(!this.session)throw new m("Failed to create session");for(;!this.session.is_open()&&r<i;){r++;let s=this.session.get_outgoing_message();if(!s||this.session.is_open())break;let o=`${this.config.apiBaseUrl}/tunnel/session`,d={"Content-Type":"application/octet-stream"};this.sessionId&&(d["X-Session-Id"]=this.sessionId);let c=await this.cookieJar.getCookieString(o);c&&(d.Cookie=c);let a=await fetch(o,{method:"POST",body:s,headers:d});if(!this.sessionId){let n=a.headers.get("X-Session-Id");if(!n)throw new m("No session ID received from server");this.sessionId=n}if(!a.ok){let n=await a.text().catch(()=>"Unable to read error");throw new m(`Handshake failed with status ${a.status}: ${n}`,a.status)}let u=a.headers.getSetCookie?.()||[];for(let n of u)await this.cookieJar.setCookie(n,o);let S=await a.arrayBuffer();if(S.byteLength>0)this.session.put_incoming_message(Buffer.from(S));else throw new m("Empty response from server during handshake")}if(!this.session.is_open()||!this.sessionId)throw new m("Failed to establish session after handshake")}finally{this.handshakeInProgress=!1}}encryptRequest(t){if(!this.session||!this.session.is_open())throw new m("Session not open");try{let i=typeof t=="string"?Buffer.from(t,"utf-8"):t,r=this.session.write(i);return Buffer.from(r)}catch(i){throw new m(`Encryption failed: ${i instanceof Error?i.message:"Unknown error"}`)}}decryptResponse(t){if(!this.session||!this.session.is_open())throw new m("Session not open");try{let i=Buffer.isBuffer(t)?t:Buffer.from(t),r=this.session.read(i);return Buffer.from(r)}catch(i){throw new m(`Decryption failed: ${i instanceof Error?i.message:"Unknown error"}`)}}getSessionId(){return this.sessionId}getCookies(t){return this.cookieJar.getCookieString(t)}destroy(){this.session=null,this.sessionId=null}getAttestationResults(){return this.session?this.session.get_attestation_results_json()??null:null}getAttestationStatus(){return this.session?this.session.get_attestation_status()??null:null}};function Je(e){let t=(0,Ze.default)({baseUrl:e.apiBaseUrl}),i=new ee(e);return t.use(Ge(i)),t.use(He({accessKey:e.accessKey,secretKey:e.secretKey})),{client:t,sessionManager:i}}async function Ye(e,t){let{workspaceUuid:i,fileBuffer:r,envelopeTitle:s}=t,o=new Blob([new Uint8Array(r)],{type:"application/pdf"}),d=await e.POST("/public/envelope/create-from-file",{body:{workspaceUuid:i,envelopeTitle:s,file:o},bodySerializer:c=>{let a=new FormData;return a.append("workspaceUuid",c.workspaceUuid),a.append("envelopeTitle",c.envelopeTitle),a.append("file",c.file,"document.pdf"),a}});if(d.error)throw new m(`Failed to upload document: ${JSON.stringify(d.error)}`,d.response?.status,typeof d.error=="object"&&"code"in d.error?String(d.error.code):void 0);return{envelopeUuid:d.data.envelopeUuid,documentUuid:d.data.documentUuid}}var te=class{client;sessionManager;constructor(t){let{client:i,sessionManager:r}=Je(t);this.client=i,this.sessionManager=r}get GET(){return this.client.GET}get POST(){return this.client.POST}get PUT(){return this.client.PUT}get DELETE(){return this.client.DELETE}get PATCH(){return this.client.PATCH}uploadDocument(t){return Ye(this,t)}getAttestationStatus(){let t=this.sessionManager.getAttestationStatus();return t?JSON.parse(t):null}getAttestationResults(){let t=this.sessionManager.getAttestationResults();return t?JSON.parse(t):null}};0&&(module.exports={SubnotoClient,SubnotoError});
1
+ "use strict";var et=Object.create;var U=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var it=Object.getOwnPropertyNames;var rt=Object.getPrototypeOf,st=Object.prototype.hasOwnProperty;var nt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ie=(e,t)=>{for(var i in t)U(e,i,{get:t[i],enumerable:!0})},pe=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of it(t))!st.call(e,s)&&s!==i&&U(e,s,{get:()=>t[s],enumerable:!(r=tt(t,s))||r.enumerable});return e};var q=(e,t,i)=>(i=e!=null?et(rt(e)):{},pe(t||!e||!e.__esModule?U(i,"default",{value:e,enumerable:!0}):i,e)),ct=e=>pe(U({},"__esModule",{value:!0}),e);var Ue=nt((xi,We)=>{"use strict";var Xt=require("path");We.exports=Xt.join(__dirname,"oak_session_wasm_nodejs_bg.wasm")});var y1={};ie(y1,{SubnotoClient:()=>te,SubnotoError:()=>m});module.exports=ct(y1);var Ze=q(require("openapi-fetch"));var X={};ie(X,{generateDigestHeaders:()=>ke,generateSignatureHeader:()=>Fe});var he=typeof Uint8Array=="function",b,V=class e{static decode(t){let i=typeof t=="string",r;if(b===void 0){let a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=`= \f
2
+ \r \xA0\u2028\u2029`;for(b=[],r=0;r<64;++r)b[a.charCodeAt(r)]=r;for(r=0;r<u.length;++r)b[u.charCodeAt(r)]=-1;b[45]=b[43],b[95]=b[47]}let s=he?new Uint8Array(t.length*3>>2):[],o=0,d=0,n=0;for(r=0;r<t.length;++r){let a=i?t.charCodeAt(r):t[r];if(a==61)break;if(a=b[a],a!=-1){if(a===void 0)throw"Illegal character at offset "+r;o|=a,++d>=4?(s[n++]=o>>16,s[n++]=o>>8&255,s[n++]=o&255,o=0,d=0):o<<=6}}switch(d){case 1:throw"Base64 encoding incomplete: at least 2 bits missing";case 2:s[n++]=o>>10;break;case 3:s[n++]=o>>16,s[n++]=o>>8&255;break}return he&&s.length>n&&(s=s.subarray(0,n)),s}static pretty(t){let i=4-t.length%4;return i<4&&(t+="===".slice(0,i)),t=t.replace(/-/g,"+").replace(/_/g,"/"),t.replace(/.{80}/g,`$&
3
+ `)}static unarmor(t){let i=e.re.exec(t);if(i)if(i[1])t=i[1];else if(i[2])t=i[2];else if(i[3])t=i[3];else throw"RegExp out of sync";return e.decode(t)}};V.re=/-----BEGIN [^-]+-----([A-Za-z0-9+/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+/=\s]+)====|^([A-Za-z0-9+/=\s]+)$/;var Se={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bits:6};var T={parse:function(t,i){return ot(t,Se,i)},stringify:function(t,i){return at(t,Se,i)}};function ot(e,t,i){var r;if(i===void 0&&(i={}),!t.codes){t.codes={};for(var s=0;s<t.chars.length;++s)t.codes[t.chars[s]]=s}if(!i.loose&&e.length*t.bits&7)throw new SyntaxError("Invalid padding");for(var o=e.length;e[o-1]==="=";)if(--o,!i.loose&&!((e.length-o)*t.bits&7))throw new SyntaxError("Invalid padding");for(var d=new((r=i.out)!=null?r:Uint8Array)(o*t.bits/8|0),n=0,a=0,u=0,S=0;S<o;++S){var c=t.codes[e[S]];if(c===void 0)throw new SyntaxError("Invalid character "+e[S]);a=a<<t.bits|c,n+=t.bits,n>=8&&(n-=8,d[u++]=255&a>>n)}if(n>=t.bits||255&a<<8-n)throw new SyntaxError("Unexpected end of data");return d}function at(e,t,i){i===void 0&&(i={});for(var r=i,s=r.pad,o=s===void 0?!0:s,d=(1<<t.bits)-1,n="",a=0,u=0,S=0;S<e.length;++S)for(u=u<<8|255&e[S],a+=8;a>t.bits;)a-=t.bits,n+=t.chars[d&u>>a];if(a&&(n+=t.chars[d&u<<t.bits-a]),o)for(;n.length*t.bits&7;)n+="=";return n}var dt=Object.create,Ie=Object.defineProperty,lt=Object.getOwnPropertyDescriptor,Ae=Object.getOwnPropertyNames,ut=Object.getPrototypeOf,pt=Object.prototype.hasOwnProperty,K=(e,t)=>function(){return t||(0,e[Ae(e)[0]])((t={exports:{}}).exports,t),t.exports},ht=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ae(t))!pt.call(e,s)&&s!==i&&Ie(e,s,{get:()=>t[s],enumerable:!(r=lt(t,s))||r.enumerable});return e},z=(e,t,i)=>(i=e!=null?dt(ut(e)):{},ht(t||!e||!e.__esModule?Ie(i,"default",{value:e,enumerable:!0}):i,e)),se=K({"node_modules/.pnpm/structured-headers@1.0.1/node_modules/structured-headers/dist/types.js"(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ByteSequence=void 0;var t=class{constructor(i){this.base64Value=i}toBase64(){return this.base64Value}};e.ByteSequence=t}}),j=K({"node_modules/.pnpm/structured-headers@1.0.1/node_modules/structured-headers/dist/util.js"(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isByteSequence=e.isInnerList=e.isValidKeyStr=e.isValidTokenStr=e.isAscii=void 0;var t=/^[\x20-\x7E]*$/,i=/^[a-zA-Z*][:/!#$%&'*+\-.^_`|~A-Za-z0-9]*$/,r=/^[a-z*][*\-_.a-z0-9]*$/;function s(u){return t.test(u)}e.isAscii=s;function o(u){return i.test(u)}e.isValidTokenStr=o;function d(u){return r.test(u)}e.isValidKeyStr=d;function n(u){return Array.isArray(u[0])}e.isInnerList=n;function a(u){return typeof u=="object"&&"base64Value"in u}e.isByteSequence=a}}),ne=K({"node_modules/.pnpm/structured-headers@1.0.1/node_modules/structured-headers/dist/token.js"(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Token=void 0;var t=j(),i=class{constructor(r){if(!(0,t.isValidTokenStr)(r))throw new TypeError("Invalid character in Token string. Tokens must start with *, A-Z and the rest of the string may only contain a-z, A-Z, 0-9, :/!#$%&'*+-.^_`|~");this.value=r}toString(){return this.value}};e.Token=i}}),St=K({"node_modules/.pnpm/structured-headers@1.0.1/node_modules/structured-headers/dist/serializer.js"(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.serializeKey=e.serializeParameters=e.serializeToken=e.serializeByteSequence=e.serializeBoolean=e.serializeString=e.serializeDecimal=e.serializeInteger=e.serializeBareItem=e.serializeInnerList=e.serializeItem=e.serializeDictionary=e.serializeList=e.SerializeError=void 0;var t=se(),i=ne(),r=j(),s=class extends Error{};e.SerializeError=s;function o(l){return l.map(C=>(0,r.isInnerList)(C)?a(C):n(C)).join(", ")}e.serializeList=o;function d(l){return Array.from(l.entries()).map(([C,A])=>{let E=N(C);return A[0]===!0?E+=I(A[1]):(E+="=",(0,r.isInnerList)(A)?E+=a(A):E+=n(A)),E}).join(", ")}e.serializeDictionary=d;function n(l){return u(l[0])+I(l[1])}e.serializeItem=n;function a(l){return`(${l[0].map(C=>n(C)).join(" ")})${I(l[1])}`}e.serializeInnerList=a;function u(l){if(typeof l=="number")return Number.isInteger(l)?S(l):c(l);if(typeof l=="string")return p(l);if(l instanceof i.Token)return W(l);if(l instanceof t.ByteSequence)return y(l);if(typeof l=="boolean")return f(l);throw new s(`Cannot serialize values of type ${typeof l}`)}e.serializeBareItem=u;function S(l){if(l<-999999999999999||l>999999999999999)throw new s("Structured headers can only encode integers in the range range of -999,999,999,999,999 to 999,999,999,999,999 inclusive");return l.toString()}e.serializeInteger=S;function c(l){let C=l.toFixed(3).replace(/0+$/,"");if(C.split(".")[0].replace("-","").length>12)throw new s("Fractional numbers are not allowed to have more than 12 significant digits before the decimal point");return C}e.serializeDecimal=c;function p(l){if(!(0,r.isAscii)(l))throw new s("Only ASCII strings may be serialized");return`"${l.replace(/("|\\)/g,C=>"\\"+C)}"`}e.serializeString=p;function f(l){return l?"?1":"?0"}e.serializeBoolean=f;function y(l){return`:${l.toBase64()}:`}e.serializeByteSequence=y;function W(l){return l.toString()}e.serializeToken=W;function I(l){return Array.from(l).map(([C,A])=>{let E=";"+N(C);return A!==!0&&(E+="="+u(A)),E}).join("")}e.serializeParameters=I;function N(l){if(!(0,r.isValidKeyStr)(l))throw new s("Keys in dictionaries must only contain lowercase letter, numbers, _-*. and must start with a letter or *");return l}e.serializeKey=N}}),ft=K({"node_modules/.pnpm/structured-headers@1.0.1/node_modules/structured-headers/dist/parser.js"(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ParseError=e.parseItem=e.parseList=e.parseDictionary=void 0;var t=se(),i=ne(),r=j();function s(c){return new a(c).parseDictionary()}e.parseDictionary=s;function o(c){return new a(c).parseList()}e.parseList=o;function d(c){return new a(c).parseItem()}e.parseItem=d;var n=class extends Error{constructor(c,p){super(`Parse error: ${p} at offset ${c}`)}};e.ParseError=n;var a=class{constructor(c){this.input=c,this.pos=0}parseDictionary(){this.skipWS();let c=new Map;for(;!this.eof();){let p=this.parseKey(),f;if(this.lookChar()==="="?(this.pos++,f=this.parseItemOrInnerList()):f=[!0,this.parseParameters()],c.set(p,f),this.skipOWS(),this.eof())return c;if(this.expectChar(","),this.pos++,this.skipOWS(),this.eof())throw new n(this.pos,"Dictionary contained a trailing comma")}return c}parseList(){this.skipWS();let c=[];for(;!this.eof();){if(c.push(this.parseItemOrInnerList()),this.skipOWS(),this.eof())return c;if(this.expectChar(","),this.pos++,this.skipOWS(),this.eof())throw new n(this.pos,"A list may not end with a trailing comma")}return c}parseItem(c=!0){c&&this.skipWS();let p=[this.parseBareItem(),this.parseParameters()];return c&&this.checkTrail(),p}parseItemOrInnerList(){return this.lookChar()==="("?this.parseInnerList():this.parseItem(!1)}parseInnerList(){this.expectChar("("),this.pos++;let c=[];for(;!this.eof();){if(this.skipWS(),this.lookChar()===")")return this.pos++,[c,this.parseParameters()];c.push(this.parseItem(!1));let p=this.lookChar();if(p!==" "&&p!==")")throw new n(this.pos,"Expected a whitespace or ) after every item in an inner list")}throw new n(this.pos,"Could not find end of inner list")}parseBareItem(){let c=this.lookChar();if(c===void 0)throw new n(this.pos,"Unexpected end of string");if(c.match(/^[-0-9]/))return this.parseIntegerOrDecimal();if(c==='"')return this.parseString();if(c.match(/^[A-Za-z*]/))return this.parseToken();if(c===":")return this.parseByteSequence();if(c==="?")return this.parseBoolean();throw new n(this.pos,"Unexpected input")}parseParameters(){let c=new Map;for(;!this.eof()&&this.lookChar()===";";){this.pos++,this.skipWS();let f=this.parseKey(),y=!0;this.lookChar()==="="&&(this.pos++,y=this.parseBareItem()),c.set(f,y)}return c}parseIntegerOrDecimal(){let c="integer",p=1,f="";if(this.lookChar()==="-"&&(p=-1,this.pos++),!S(this.lookChar()))throw new n(this.pos,"Expected a digit (0-9)");for(;!this.eof();){let y=this.getChar();if(S(y))f+=y;else if(c==="integer"&&y==="."){if(f.length>12)throw new n(this.pos,"Exceeded maximum decimal length");f+=".",c="decimal"}else{this.pos--;break}if(c==="integer"&&f.length>15)throw new n(this.pos,"Exceeded maximum integer length");if(c==="decimal"&&f.length>16)throw new n(this.pos,"Exceeded maximum decimal length")}if(c==="integer")return parseInt(f,10)*p;if(f.endsWith("."))throw new n(this.pos,"Decimal cannot end on a period");if(f.split(".")[1].length>3)throw new n(this.pos,"Number of digits after the decimal point cannot exceed 3");return parseFloat(f)*p}parseString(){let c="";for(this.expectChar('"'),this.pos++;!this.eof();){let p=this.getChar();if(p==="\\"){if(this.eof())throw new n(this.pos,"Unexpected end of input");let f=this.getChar();if(f!=="\\"&&f!=='"')throw new n(this.pos,"A backslash must be followed by another backslash or double quote");c+=f}else{if(p==='"')return c;if((0,r.isAscii)(p))c+=p;else throw new n(this.pos,"Strings must be in the ASCII range")}}throw new n(this.pos,"Unexpected end of input")}parseToken(){let c="";for(;!this.eof();){let p=this.lookChar();if(p===void 0||!/^[:/!#$%&'*+\-.^_`|~A-Za-z0-9]$/.test(p))return new i.Token(c);c+=this.getChar()}return new i.Token(c)}parseByteSequence(){this.expectChar(":"),this.pos++;let c=this.input.indexOf(":",this.pos);if(c===-1)throw new n(this.pos,'Could not find a closing ":" character to mark end of Byte Sequence');let p=this.input.substring(this.pos,c);if(this.pos+=p.length+1,!/^[A-Za-z0-9+/=]*$/.test(p))throw new n(this.pos,"ByteSequence does not contain a valid base64 string");return new t.ByteSequence(p)}parseBoolean(){this.expectChar("?"),this.pos++;let c=this.getChar();if(c==="1")return!0;if(c==="0")return!1;throw new n(this.pos,'Unexpected character. Expected a "1" or a "0"')}parseKey(){var c;if(!(!((c=this.lookChar())===null||c===void 0)&&c.match(/^[a-z*]/)))throw new n(this.pos,"A key must begin with an asterisk or letter (a-z)");let p="";for(;!this.eof();){let f=this.lookChar();if(f===void 0||!/^[a-z0-9_\-.*]$/.test(f))return p;p+=this.getChar()}return p}lookChar(){return this.input[this.pos]}expectChar(c){if(this.lookChar()!==c)throw new n(this.pos,`Expected ${c}`)}getChar(){return this.input[this.pos++]}eof(){return this.pos>=this.input.length}skipOWS(){for(;;){let c=this.input.substr(this.pos,1);if(c===" "||c===" ")this.pos++;else break}}skipWS(){for(;this.lookChar()===" ";)this.pos++}checkTrail(){if(this.skipWS(),!this.eof())throw new n(this.pos,"Unexpected characters at end of input")}};e.default=a;var u=/^[0-9]$/;function S(c){return c===void 0?!1:u.test(c)}}}),$=K({"node_modules/.pnpm/structured-headers@1.0.1/node_modules/structured-headers/dist/index.js"(e){"use strict";var t=e&&e.__createBinding||(Object.create?function(s,o,d,n){n===void 0&&(n=d);var a=Object.getOwnPropertyDescriptor(o,d);(!a||("get"in a?!o.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return o[d]}}),Object.defineProperty(s,n,a)}:function(s,o,d,n){n===void 0&&(n=d),s[n]=o[d]}),i=e&&e.__exportStar||function(s,o){for(var d in s)d!=="default"&&!Object.prototype.hasOwnProperty.call(o,d)&&t(o,s,d)};Object.defineProperty(e,"__esModule",{value:!0}),e.Token=void 0,i(St(),e),i(ft(),e),i(se(),e),i(j(),e);var r=ne();Object.defineProperty(e,"Token",{enumerable:!0,get:function(){return r.Token}})}});var B1=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);var be=new TextEncoder;async function mt(){return globalThis.crypto??(await import("node:crypto")).webcrypto}var gt=/[^\S\r\n]*\r?\n[^\S\r\n]+/g;function fe(e){return e.replaceAll(gt," ")}function k(e){if(typeof e=="number")return e.toString();if(!e)return"";if(typeof e=="string")return fe(e).trim();if(Array.isArray(e))return e.map(t=>{if(t==null)return"";if(typeof t=="number")return t.toString();if(typeof t=="string")return fe(t).trim();throw new Error(`Invalid header value type ${t}`)}).join(", ");throw new Error(`Invalid header value type ${e}`)}function L(e){return Object.entries(e).reduce((t,[i,r])=>(i==="__proto__"||(t[i.toLowerCase()]=r),t),{})}function me(e,t){t=t.toLowerCase();for(let[i,r]of Object.entries(e))if(i.toLowerCase()===t)return r}function Ct(e){return typeof e=="number"?e.toString():typeof e=="string"?e.toLowerCase():""}function re(e){return e.reduce((t,i,r)=>{if(r%2===0){if(typeof i!="string")throw new Error(`Invalid header key type '${typeof i}' of ${i}`);if(i.toLowerCase()in t)return t;t[i.toLowerCase()]=[]}else t[Ct(e[r-1])].push(i==null?"":i.toString());return t},{})}function _(e){if("rawHeaders"in e&&e.rawHeaders)return re(e.rawHeaders.flat(1));if("getHeaders"in e&&typeof e.getHeaders=="function")return L(e.getHeaders());if("headers"in e&&e.headers){if(typeof e.headers!="object")throw new Error("headers must be an object");return Te(e.headers)?re(Array.from(e.headers.entries()).flat(1)):Array.isArray(e.headers)?re(e.headers.flat(1)):L(e.headers)}throw new Error("Cannot get headers from request object")}function Ee(e,t,i){if("setHeader"in e&&typeof e.setHeader=="function")e.setHeader(t,i.toString());else if("headers"in e&&typeof e.headers=="object")Te(e.headers)?e.headers.set(t,i.toString()):e.headers[t]=i.toString();else throw new Error("Cannot set headers to request object")}function ge(e){return"Response"in globalThis&&typeof e=="object"&&e instanceof Response}function yt(e){return"Request"in globalThis&&typeof e=="object"&&e instanceof Request}function Te(e){return"Headers"in globalThis&&typeof e=="object"&&e instanceof Headers}function Pe(e){let t=new Uint8Array(e);return T.stringify(t)}var It={hash:"SHA-256",ec:"DSA"};function At(e,t){return{hash:t,...e}}function ce(e){return e instanceof Map?new Map(e):Array.isArray(e)?new Map(e):new Map(Object.entries(e))}function Ce(e){let t=ce(e);for(let[i,r]of t.entries())r===void 0&&t.delete(i);return t}var g=z($(),1),bt={signature:"dict","signature-input":"dict","accept-signature":"dict","content-digest":"dict","repr-digest":"dict","want-content-digest":"dict","want-repr-digest":"dict","accept-ch":"list","proxy-status":"list","cache-status":"list",priority:"dict","client-cert":"bs","client-cert-chain":"list"},Et=["@method","@authority","@scheme","@target-uri","@request-target","@path","@query"],Tt=["@status"],we=class{isRequest(){return this.response===null}isResponse(){return this.response!==null}constructor(e,t="https",i={},r,s=null){if(s&&!Array.isArray(s))throw new Error("requiredComponents must be an array");if(s&&s.length>0?this.requiredComponents=s.map(n=>{let a;return n.startsWith('"')?a=g.parseItem(n):a=[n,new Map],g.serializeItem(a)}):this.requiredComponents=null,this.sfvTypeDictionary=L({...bt,...i}),"req"in e)this.response=e,this.responseHeaders=_(e),this.request=e.req,this.requestHeaders=_(this.request);else if(ge(e)){if(!r)throw new Error("Request is not provided");this.response=e,this.responseHeaders=_(e),this.request=r,this.requestHeaders=_(this.request)}else this.response=null,this.responseHeaders=null,this.request=e,this.requestHeaders=_(e);if(!this.request.url)throw new Error("Request URL is empty");if(!this.request.method)throw new Error("Request method is empty");if(!("signature-input"in this.requestHeaders))throw new Error("Signature-Input header is not found in request");if(this.requestSignatureInput=g.parseDictionary(k(this.requestHeaders["signature-input"])),this.isResponse()){if(!this.responseHeaders)throw new Error("responseHeaders is empty");if(!("signature-input"in this.responseHeaders))throw new Error("Signature-Input header is not found in response");this.responseSignatureInput=g.parseDictionary(k(this.responseHeaders["signature-input"]))}this.sfvTypeDictionary=L(i),this.scheme=this.request.url.startsWith("/")?t:new URL(this.request.url).protocol.replace(":","");let o="httpVersionMajor"in this.request&&this.request.httpVersionMajor===2?this.requestHeaders[":authority"]:this.requestHeaders.host;if(!yt(this.request)&&!o)throw new Error("Host header is empty");let d=k(o);this.targetUri=this.request.url.startsWith("/")?new URL(this.request.url,`${t}://${d}`).href:this.request.url,this.url=new URL(this.targetUri)}get(e,t=new Map){let i=ce(t),r=g.serializeItem([e,i]);if(!e)throw new Error(`Type is empty: ${r}`);if(e.startsWith('"'))if(e.endsWith('"'))e=e.slice(1,-1);else throw new Error(`Invalid component type string: ${r}`);if(this.isResponse()&&i.get("req")!==!0&&Et.includes(e))throw new Error(`component is not available in response (must use with ;req, or provided object is unintentionally treated as response (existing req prop.)): ${e}`);if(this.isRequest()&&Tt.includes(e))throw new Error(`component is not available in request (provided object is unintentionally treated as request (including req prop.)): ${e}`);if(this.isRequest()&&i.get("req")===!0)throw new Error("req param is not available in request (provided object is treated as request, please set req param with Request)");let s=this.isRequest()||i.get("req")===!0;if(e==="@signature-params")throw new Error(`@signature-params is not available in get method: ${r}`);if(e==="@method"){if(!this.request.method)throw new Error("Request method is empty");return this.request.method.toUpperCase()}else{if(e==="@authority")return this.url.host;if(e==="@scheme")return this.scheme.toLocaleLowerCase();if(e==="@target-uri")return this.targetUri;if(e==="@request-target"){if(!this.request.method)throw new Error("Request method is empty");return`${this.request.method.toLowerCase()} ${this.url.pathname}`}else{if(e==="@path")return this.url.pathname;if(e==="@query")return this.url.search;if(e==="@query-param"){let o=i.get("name");if(o===void 0)throw new Error("Query parameter name not found or invalid");let d=this.url.searchParams.get(o.toString());if(d===null)throw new Error(`Query parameter not found: ${o} (${r})`);return d}else if(e==="@status"){if(!this.response)throw new Error("response is empty (@status)");return ge(this.response)?this.response.status.toString():this.response.statusCode.toString()}else{if(e.startsWith("@"))throw new Error(`Unknown derived component: ${e}`);{let o=i.get("key"),d=i.get("sf")===!0,n=i.get("bs")===!0,a=i.get("tr")===!0;if([o,d,n].filter(S=>S).length>1)throw new Error(`Invalid component: ${r} (multiple params are specified)`);let u=(()=>{if(s)if(a){if("trailers"in this.request&&this.request.trailers)return me(this.request.trailers,e);throw new Error(`Trailers not found in request object (${r})`)}else return this.requestHeaders[e];else{if(!this.response||!this.responseHeaders)throw new Error("response is not provided");if(a){if("trailers"in this.response&&this.response.trailers)return me(this.response.trailers,e);throw new Error(`Trailers not found in response object (${r})`)}else return this.responseHeaders[e]}})();if(u===void 0)throw new Error(`Header not found: ${r}`);if(d){if(!(e in this.sfvTypeDictionary))throw new Error(`Type not found in SFV type dictionary: ${e}`);let S=k(u);if(this.sfvTypeDictionary[e]==="dict")return g.serializeDictionary(g.parseDictionary(S));if(this.sfvTypeDictionary[e]==="list")return g.serializeList(g.parseList(S));if(["item","bs","int","dec","str","bool","token"].includes(this.sfvTypeDictionary[e]))return g.serializeItem(g.parseItem(S))}if(o){if(!(e in this.sfvTypeDictionary))throw new Error(`key specified but type unknown (Type not found in SFV type dictionary): ${r}`);if(typeof u!="string")throw new Error(`Key specified but value is not a string: ${r}`);if(this.sfvTypeDictionary[e]==="dict"){let c=g.parseDictionary(u).get(o);if(c===void 0)throw new Error(`Key not found in dictionary: ${o} (${r})`);return Array.isArray(c[0])?g.serializeList([c]):g.serializeItem(c)}else throw new Error(`"${e}" is not dict: ${this.sfvTypeDictionary[e]} (${r})`)}if(n){let S=(Array.isArray(u)?u:[u]).map(c=>{if(typeof c!="string")throw new Error(`Invalid header value type: ${typeof c}`);return[new g.ByteSequence(Pe(be.encode(k(c)).buffer)),new Map]});return g.serializeList(S)}return k(u)}}}}}generate(e){let t=this.isRequest()?this.requestSignatureInput?.get(e):this.responseSignatureInput?.get(e);if(!t)throw new Error(`label not found: ${e}`);if(!Array.isArray(t[0]))throw new Error(`item is not InnerList: ${g.serializeDictionary(new Map([[e,t]]))}`);let i=new Map;for(let r of t[0]){let s=r[0];if(s.startsWith('"'))if(s.endsWith('"'))s=s.slice(1,-1);else throw new Error(`Invalid component identifier name: ${s}`);r[0]=s;let o=g.serializeItem(r);if(i.has(o))throw new Error(`Duplicate key: ${s}`);i.set(o,this.get(s,r[1]))}if(this.requiredComponents){for(let r of this.requiredComponents)if(!i.has(r))throw new Error(`Required component not found: ${r}`)}return i.set('"@signature-params"',g.serializeInnerList(t)),Array.from(i.entries(),([r,s])=>`${r}: ${s}`).join(`
4
+ `)}};function De(e){let t=ce(e),i=new Map;for(let[r,s]of t){if(!Array.isArray(s))throw new Error("item is not array");let[o,d]=s;i.set(r,[o.map(n=>typeof n=="string"?[n,new Map]:[n[0],Ce(n[1])]),Ce(d)])}return g.serializeDictionary(i)}var H1=z($(),1);async function Me(e,t,i=It){let r=await(await mt()).subtle.sign(At(e.algorithm,i.hash),e,be.encode(t));return Pe(r)}var W1=z($(),1);function ve(e){let t=e.toUpperCase();if(t==="SHA-256")return"sha-256";if(t==="SHA-512")return"sha-512";throw new Error(`Unsupported hash algorithm: ${e}`)}var V1=z($(),1);async function Q(){return globalThis.crypto??(await import("node:crypto")).webcrypto}var Ne=e=>{let t=new Uint8Array(e);return T.stringify(t)};var Pt=async(e,t="SHA-256")=>(t==="SHA"&&(t="SHA-1"),typeof e=="string"&&(e=new TextEncoder().encode(e)),(await Q()).subtle.digest(t,e)),ke=async e=>{let t="SHA-256",i=await Pt(e.body,t).then(Ne),r=`${t}=${i}`,s=`${ve(t)}=:${i}:`;return{digest:r,contentDigest:s}};var wt=/^[\x20-\x7E]*$/,Dt=/^[a-zA-Z*][:/!#$%&'*+\-.^_`|~A-Za-z0-9]*$/,Mt=/^[a-z*][*\-_.a-z0-9]*$/;function oe(e){return wt.test(e)}function Ke(e){return Dt.test(e)}function Re(e){return Mt.test(e)}function Oe(e){return Array.isArray(e[0])}function xe(e){let t=new Uint8Array(e),i="";for(let r of t)i+=String.fromCharCode(r);return btoa(i)}function ae(e){let t=atob(e),i=t.length,r=new Uint8Array(i);for(let s=0;s<i;s++)r[s]=t.charCodeAt(s);return r.buffer}var R=class{constructor(t){if(!Ke(t))throw new TypeError("Invalid character in Token string. Tokens must start with *, A-Z and the rest of the string may only contain a-z, A-Z, 0-9, :/!#$%&'*+-.^_`|~");this.value=t}toString(){return this.value}};var O=class{constructor(t){this.value=t}toString(){return this.value}};var w=class extends Error{};function Be(e){let t=e instanceof Map?e.entries():Object.entries(e);return Array.from(t).map(([i,r])=>{let s=Xe(i);return Array.isArray(r)?r[0]===!0?s+J(r[1]):Oe(r)?s+"="+vt(r):s+"="+_e(r):r===!0?s:s+"="+Z(r)}).join(", ")}function _e(e,t){return Array.isArray(e)?Z(e[0])+J(e[1]):Z(e)+(t?J(t):"")}function vt(e){return`(${e[0].map(t=>_e(t)).join(" ")})${J(e[1])}`}function Z(e){if(typeof e=="number")return Number.isInteger(e)?Nt(e):kt(e);if(typeof e=="string")return Kt(e);if(e instanceof R)return Bt(e);if(e instanceof ArrayBuffer)return xt(e);if(e instanceof O)return Rt(e);if(e instanceof Date)return _t(e);if(typeof e=="boolean")return Ot(e);throw new w(`Cannot serialize values of type ${typeof e}`)}function Nt(e){if(e<-999999999999999||e>999999999999999)throw new w("Structured headers can only encode integers in the range range of -999,999,999,999,999 to 999,999,999,999,999 inclusive");return e.toString()}function kt(e){let t=e.toFixed(3).replace(/0+$/,"");if(t.split(".")[0].replace("-","").length>12)throw new w("Fractional numbers are not allowed to have more than 12 significant digits before the decimal point");return t}function Kt(e){if(!oe(e))throw new w("Only ASCII strings may be serialized");return`"${e.replace(/("|\\)/g,t=>"\\"+t)}"`}function Rt(e){let t='%"',i=new TextEncoder;for(let r of i.encode(e.toString()))r===37||r===34||r<=31||r>=127?t+="%"+r.toString(16):t+=String.fromCharCode(r);return t+'"'}function Ot(e){return e?"?1":"?0"}function xt(e){return`:${xe(e)}:`}function Bt(e){return e.toString()}function _t(e){return"@"+Math.floor(e.getTime()/1e3)}function J(e){return Array.from(e).map(([t,i])=>{let r=";"+Xe(t);return i!==!0&&(r+="="+Z(i)),r}).join("")}function Xe(e){if(!Re(e))throw new w("Keys in dictionaries must only contain lowercase letter, numbers, _-*. and must start with a letter or *");return e}var Fe=async e=>{let{request:t,authenticationType:i,accessKey:r,secretKey:s,creationDate:o}=e,d={key_ops:["sign","verify"],ext:!0,kty:"oct",k:s,alg:"HS256"},n=await(await Q()).subtle.importKey("jwk",d,{name:"HMAC",hash:"SHA-256"},!0,["sign","verify"]),a=new Map,u=new Map;a.set(i,n),u.set(i,[["x-timestamp","@authority","content-type","content-digest","content-length"],{keyid:r,created:o,alg:"hmac-sha256"}]);let S=De(u);Ee(t,"Signature-Input",S);let c=new we(t),p=(c.isRequest()?c.requestSignatureInput:c.responseSignatureInput)?.keys();if(!p)throw new Error("signaturesEntries is undefined");let f=new Map,y=new Map;for(let I of p){let N=c.generate(I),l=a.get(I);if(!l)throw new Error(`key not found: ${I}`);y.set(I,N),f.set(I,[ae(await Me(l,N,{hash:"SHA-256",ec:"DSA"})),new Map])}let W=Be(f);return{signatureInputHeader:S,signatureHeader:W}};function He(e){return{async onRequest({request:t}){let i=t.clone(),r=i.url,s=await i.arrayBuffer()??JSON.stringify({}),o=i.method??"POST",d=await X.generateDigestHeaders({body:s}),n={headers:{"X-Timestamp":Date.now().toString(),Host:new URL(r).host,"Content-Type":i.headers.get("Content-Type")??"application/json","Content-Length":i.headers.get("Content-Length")??s.byteLength.toString(),Digest:d.digest,"Content-Digest":d.contentDigest},body:s.toString(),method:o,url:r},{signatureHeader:a,signatureInputHeader:u}=await X.generateSignatureHeader({request:n,authenticationType:"team",accessKey:e.accessKey,secretKey:Buffer.from(e.secretKey,"hex").toString("base64"),creationDate:Math.floor(Date.now()/1e3)});return t.headers.set("Signature",a),t.headers.set("Signature-Input",u),t.headers.set("X-Timestamp",n.headers["X-Timestamp"]),t.headers.set("Content-Type",n.headers["Content-Type"]),t.headers.set("Digest",n.headers.Digest),t.headers.set("Content-Digest",n.headers["Content-Digest"]),t}}}var m=class extends Error{statusCode;code;constructor(t,i,r){super(t),this.statusCode=i,this.code=r,this.name="SubnotoError"}};function Ge(e){return{async onRequest({request:t}){if(!t.url.includes("/tunnel/")&&!t.url.includes("/public/")||t.url.includes("/tunnel/session"))return t;try{await e.ensureSession();let i=t.clone(),r=Buffer.from(await i.arrayBuffer());if(!r||r.byteLength===0)throw new m("EMPTY_REQUEST_BODY");let s=e.encryptRequest(r);if(!s||s.byteLength===0)throw new m("Empty encrypted message");let o=e.getSessionId();if(!o)throw new m("Session ID not available");let d=new Headers(i.headers);d.set("X-Session-Id",o);let n=i.headers.get("Content-Type");n&&n.includes("multipart/form-data")&&d.set("X-Original-Content-Type",n),d.set("Content-Type","application/octet-stream"),d.set("Content-Length",s.byteLength.toString());let a=await e.getCookies(i.url);return a&&d.set("Cookie",a),new Request(i.url,{method:i.method,headers:d,body:s,mode:i.mode,credentials:i.credentials,cache:i.cache,redirect:i.redirect,referrer:i.referrer,referrerPolicy:i.referrerPolicy,integrity:i.integrity,keepalive:i.keepalive})}catch(i){throw console.error(`Error in tunnel middleware for ${t.url}:`,i),i}},async onResponse({response:t,request:i}){if(!i.url.includes("/tunnel/")&&!i.url.includes("/public/")||i.url.includes("/tunnel/session"))return t;try{if(!(t.headers.get("x-subnoto-encrypted-response")?.includes("true")&&t.headers.get("content-type")?.includes("application/octet-stream")))return t;let s=t.clone(),o=Buffer.from(await s.arrayBuffer());if(o.byteLength===0)throw new m("Empty encrypted response");let d=e.decryptResponse(o),n=new Headers(t.headers);return n.get("x-subnoto-content-type-response")?.includes("application/octet-stream")?(n.set("Content-Type","application/octet-stream"),n.delete("x-subnoto-encrypted-response"),new Response(d,{status:t.status,statusText:t.statusText,headers:n})):(n.set("Content-Type","application/json"),n.delete("x-subnoto-encrypted-response"),n.delete("x-subnoto-content-type-response"),new Response(d,{status:t.status,statusText:t.statusText,headers:n}))}catch(r){throw console.error(`Error decrypting response for ${i.url}:`,r),r}}}}var Le=q(Ue());var le={};ie(le,{PutIncomingMessageResult:()=>Wt,WasmClientSession:()=>v,__wbg___wbindgen_is_function_ee8a6c5833c90377:()=>Ut,__wbg___wbindgen_is_object_c818261d21f283a4:()=>qt,__wbg___wbindgen_is_string_fbb76cb2940daafd:()=>Vt,__wbg___wbindgen_is_undefined_2d472862bd29a478:()=>Lt,__wbg___wbindgen_throw_b855445ff6a94295:()=>zt,__wbg_call_525440f72fbfc0ea:()=>jt,__wbg_call_e762c39fa8ea36bf:()=>$t,__wbg_crypto_86f2631e91b51511:()=>Qt,__wbg_getRandomValues_b3f15fcbfabb0f8b:()=>Zt,__wbg_length_69bca3cb64fc8748:()=>Jt,__wbg_msCrypto_d562bbe83e0d4b91:()=>Yt,__wbg_new_no_args_ee98eee5275000a4:()=>e1,__wbg_new_with_length_01aa0dc35aa13543:()=>t1,__wbg_node_e1f24f89a7336c2e:()=>i1,__wbg_now_793306c526e2e3b6:()=>r1,__wbg_process_3975fd6c72f520aa:()=>s1,__wbg_prototypesetcall_2a6620b6922694b2:()=>n1,__wbg_randomFillSync_f8c153b79f285817:()=>c1,__wbg_require_b74f47fc2d022fd6:()=>o1,__wbg_set_wasm:()=>Ht,__wbg_static_accessor_GLOBAL_89e1d9ac6a1b250e:()=>a1,__wbg_static_accessor_GLOBAL_THIS_8b530f326a9e48ac:()=>d1,__wbg_static_accessor_SELF_6fdf4b64710cc91b:()=>l1,__wbg_static_accessor_WINDOW_b45bfc5a37f6cfa2:()=>u1,__wbg_subarray_480600f3d6a9f26c:()=>p1,__wbg_versions_4e31226f5e8dc909:()=>h1,__wbindgen_cast_2241b6af4c4b2941:()=>S1,__wbindgen_cast_cb9088102bce6b30:()=>f1,__wbindgen_init_externref_table:()=>m1});var h,Ft;function Ht(e,t){h=e,Ft=t}var Y=null;function de(){return(Y===null||Y.byteLength===0)&&(Y=new Uint8Array(h.memory.buffer)),Y}var Ve=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});Ve.decode();function Gt(e,t){return Ve.decode(de().subarray(e,e+t))}function F(e,t){return e=e>>>0,Gt(e,t)}function H(e){let t=h.__externref_table_alloc();return h.__wbindgen_externrefs.set(t,e),t}function G(e,t){try{return e.apply(this,t)}catch(i){let r=H(i);h.__wbindgen_exn_store(r)}}function M(e,t){return e=e>>>0,de().subarray(e/1,e/1+t)}function B(e){return e==null}var D=0;function x(e,t){let i=t(e.length*1,1)>>>0;return de().set(e,i/1),D=e.length,i}function P(e){let t=h.__wbindgen_externrefs.get(e);return h.__externref_table_dealloc(e),t}var Wt=Object.freeze({NoIncomingMessageExpected:0,0:"NoIncomingMessageExpected",Success:1,1:"Success"}),qe=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>h.__wbg_wasmclientsession_free(e>>>0,1)),v=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,qe.unregister(this),t}free(){let t=this.__destroy_into_raw();h.__wbg_wasmclientsession_free(t,0)}constructor(t,i){var r=B(i)?0:x(i,h.__wbindgen_malloc),s=D;let o=h.wasmclientsession_new(B(t)?16777215:t?1:0,r,s);if(o[2])throw P(o[1]);return this.__wbg_ptr=o[0]>>>0,qe.register(this,this.__wbg_ptr,this),this}is_open(){return h.wasmclientsession_is_open(this.__wbg_ptr)!==0}write(t){let i=x(t,h.__wbindgen_malloc),r=D,s=h.wasmclientsession_write(this.__wbg_ptr,i,r);if(s[3])throw P(s[2]);var o=M(s[0],s[1]).slice();return h.__wbindgen_free(s[0],s[1]*1,1),o}read(t){let i=x(t,h.__wbindgen_malloc),r=D,s=h.wasmclientsession_read(this.__wbg_ptr,i,r);if(s[3])throw P(s[2]);var o=M(s[0],s[1]).slice();return h.__wbindgen_free(s[0],s[1]*1,1),o}write_buffer(t){let i=x(t,h.__wbindgen_malloc),r=D,s=h.wasmclientsession_write_buffer(this.__wbg_ptr,i,r);if(s[3])throw P(s[2]);var o=M(s[0],s[1]).slice();return h.__wbindgen_free(s[0],s[1]*1,1),o}read_buffer(t){let i=x(t,h.__wbindgen_malloc),r=D,s=h.wasmclientsession_read_buffer(this.__wbg_ptr,i,r);if(s[3])throw P(s[2]);var o=M(s[0],s[1]).slice();return h.__wbindgen_free(s[0],s[1]*1,1),o}put_incoming_message(t){let i=x(t,h.__wbindgen_malloc),r=D,s=h.wasmclientsession_put_incoming_message(this.__wbg_ptr,i,r);if(s[2])throw P(s[1]);return s[0]}get_outgoing_message(){let t=h.wasmclientsession_get_outgoing_message(this.__wbg_ptr);if(t[3])throw P(t[2]);let i;return t[0]!==0&&(i=M(t[0],t[1]).slice(),h.__wbindgen_free(t[0],t[1]*1,1)),i}get_attestation_results_json(){let t=h.wasmclientsession_get_attestation_results_json(this.__wbg_ptr);if(t[3])throw P(t[2]);let i;return t[0]!==0&&(i=F(t[0],t[1]).slice(),h.__wbindgen_free(t[0],t[1]*1,1)),i}get_attestation_status(){let t,i;try{let r=h.wasmclientsession_get_attestation_status(this.__wbg_ptr);return t=r[0],i=r[1],F(r[0],r[1])}finally{h.__wbindgen_free(t,i,1)}}};Symbol.dispose&&(v.prototype[Symbol.dispose]=v.prototype.free);function Ut(e){return typeof e=="function"}function qt(e){let t=e;return typeof t=="object"&&t!==null}function Vt(e){return typeof e=="string"}function Lt(e){return e===void 0}function zt(e,t){throw new Error(F(e,t))}function jt(){return G(function(e,t,i){return e.call(t,i)},arguments)}function $t(){return G(function(e,t){return e.call(t)},arguments)}function Qt(e){return e.crypto}function Zt(){return G(function(e,t){e.getRandomValues(t)},arguments)}function Jt(e){return e.length}function Yt(e){return e.msCrypto}function e1(e,t){return new Function(F(e,t))}function t1(e){return new Uint8Array(e>>>0)}function i1(e){return e.node}function r1(){return Date.now()}function s1(e){return e.process}function n1(e,t,i){Uint8Array.prototype.set.call(M(e,t),i)}function c1(){return G(function(e,t){e.randomFillSync(t)},arguments)}function o1(){return G(function(){return module.require},arguments)}function a1(){let e=typeof global>"u"?null:global;return B(e)?0:H(e)}function d1(){let e=typeof globalThis>"u"?null:globalThis;return B(e)?0:H(e)}function l1(){let e=typeof self>"u"?null:self;return B(e)?0:H(e)}function u1(){let e=typeof window>"u"?null:window;return B(e)?0:H(e)}function p1(e,t,i){return e.subarray(t>>>0,i>>>0)}function h1(e){return e.versions}function S1(e,t){return F(e,t)}function f1(e,t){return M(e,t)}function m1(){let e=h.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)}var ze=require("node:fs"),ue={};ue["./oak_session_wasm_nodejs_bg.js"]=le;var g1=require("url").pathToFileURL(Le.default),C1=(0,ze.readFileSync)(g1),je=new WebAssembly.Module(C1),$e=new WebAssembly.Instance(je,ue).exports;ue["./oak_session_wasm_nodejs_bg.js"].__wbg_set_wasm($e,je);$e.__wbindgen_start();var Qe=require("tough-cookie");var ee=class{session=null;sessionId=null;config;handshakeInProgress=!1;cookieJar;constructor(t){this.config=t,this.cookieJar=new Qe.CookieJar}async ensureSession(){if(!(this.session&&this.session.is_open())){if(this.handshakeInProgress){for(;this.handshakeInProgress;)await new Promise(t=>setTimeout(t,50));return}await this.handshake()}}async handshake(){this.handshakeInProgress=!0;try{let t=this.config.unattested??!1;this.session=new v(t,t?void 0:this.config.attesterKey);let i=4,r=0;if(!this.session)throw new m("Failed to create session");for(;!this.session.is_open()&&r<i;){r++;let s=this.session.get_outgoing_message();if(!s||this.session.is_open())break;let o=`${this.config.apiBaseUrl}/tunnel/session`,d={"Content-Type":"application/octet-stream"};this.sessionId&&(d["X-Session-Id"]=this.sessionId);let n=await this.cookieJar.getCookieString(o);n&&(d.Cookie=n);let a=await fetch(o,{method:"POST",body:s,headers:d});if(!this.sessionId){let c=a.headers.get("X-Session-Id");if(!c)throw new m("No session ID received from server");this.sessionId=c}if(!a.ok){let c=await a.text().catch(()=>"Unable to read error");throw new m(`Handshake failed with status ${a.status}: ${c}`,a.status)}let u=a.headers.getSetCookie?.()||[];for(let c of u)await this.cookieJar.setCookie(c,o);let S=await a.arrayBuffer();if(S.byteLength>0)this.session.put_incoming_message(Buffer.from(S));else throw new m("Empty response from server during handshake")}if(!this.session.is_open()||!this.sessionId)throw new m("Failed to establish session after handshake")}finally{this.handshakeInProgress=!1}}encryptRequest(t){if(!this.session||!this.session.is_open())throw new m("Session not open");try{let i=typeof t=="string"?Buffer.from(t,"utf-8"):t,r=this.session.write(i);return Buffer.from(r)}catch(i){throw new m(`Encryption failed: ${i instanceof Error?i.message:"Unknown error"}`)}}decryptResponse(t){if(!this.session||!this.session.is_open())throw new m("Session not open");try{let i=Buffer.isBuffer(t)?t:Buffer.from(t),r=this.session.read(i);return Buffer.from(r)}catch(i){throw new m(`Decryption failed: ${i instanceof Error?i.message:"Unknown error"}`)}}getSessionId(){return this.sessionId}getCookies(t){return this.cookieJar.getCookieString(t)}destroy(){this.session=null,this.sessionId=null}getAttestationResults(){return this.session?this.session.get_attestation_results_json()??null:null}getAttestationStatus(){return this.session?this.session.get_attestation_status()??null:null}};function Je(e){let t=(0,Ze.default)({baseUrl:e.apiBaseUrl}),i=new ee(e);return t.use(Ge(i)),t.use(He({accessKey:e.accessKey,secretKey:e.secretKey})),{client:t,sessionManager:i}}async function Ye(e,t){let{workspaceUuid:i,fileBuffer:r,envelopeTitle:s}=t,o=new Blob([new Uint8Array(r)],{type:"application/pdf"}),d=await e.POST("/public/envelope/create-from-file",{body:{workspaceUuid:i,envelopeTitle:s,file:o},bodySerializer:n=>{let a=new FormData;return a.append("workspaceUuid",n.workspaceUuid),a.append("envelopeTitle",n.envelopeTitle),a.append("file",n.file,"document.pdf"),a}});if(d.error)throw new m(`Failed to upload document: ${JSON.stringify(d.error)}`,d.response?.status,typeof d.error=="object"&&"code"in d.error?String(d.error.code):void 0);return{envelopeUuid:d.data.envelopeUuid,documentUuid:d.data.documentUuid}}var te=class{client;sessionManager;constructor(t){let{client:i,sessionManager:r}=Je(t);this.client=i,this.sessionManager=r}get GET(){return this.client.GET}get POST(){return this.client.POST}get PUT(){return this.client.PUT}get DELETE(){return this.client.DELETE}get PATCH(){return this.client.PATCH}uploadDocument(t){return Ye(this,t)}getAttestationStatus(){let t=this.sessionManager.getAttestationStatus();return t?JSON.parse(t):null}getAttestationResults(){let t=this.sessionManager.getAttestationResults();return t?JSON.parse(t):null}};0&&(module.exports={SubnotoClient,SubnotoError});
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  var Ve=Object.defineProperty;var de=(e,t)=>{for(var i in t)Ve(e,i,{get:t[i],enumerable:!0})};import c1 from"openapi-fetch";var X={};de(X,{generateDigestHeaders:()=>Me,generateSignatureHeader:()=>Be});var le=typeof Uint8Array=="function",b,U=class e{static decode(t){let i=typeof t=="string",r;if(b===void 0){let a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=`= \f
2
2
  \r \xA0\u2028\u2029`;for(b=[],r=0;r<64;++r)b[a.charCodeAt(r)]=r;for(r=0;r<u.length;++r)b[u.charCodeAt(r)]=-1;b[45]=b[43],b[95]=b[47]}let s=le?new Uint8Array(t.length*3>>2):[],o=0,d=0,c=0;for(r=0;r<t.length;++r){let a=i?t.charCodeAt(r):t[r];if(a==61)break;if(a=b[a],a!=-1){if(a===void 0)throw"Illegal character at offset "+r;o|=a,++d>=4?(s[c++]=o>>16,s[c++]=o>>8&255,s[c++]=o&255,o=0,d=0):o<<=6}}switch(d){case 1:throw"Base64 encoding incomplete: at least 2 bits missing";case 2:s[c++]=o>>10;break;case 3:s[c++]=o>>16,s[c++]=o>>8&255;break}return le&&s.length>c&&(s=s.subarray(0,c)),s}static pretty(t){let i=4-t.length%4;return i<4&&(t+="===".slice(0,i)),t=t.replace(/-/g,"+").replace(/_/g,"/"),t.replace(/.{80}/g,`$&
3
3
  `)}static unarmor(t){let i=e.re.exec(t);if(i)if(i[1])t=i[1];else if(i[2])t=i[2];else if(i[3])t=i[3];else throw"RegExp out of sync";return e.decode(t)}};U.re=/-----BEGIN [^-]+-----([A-Za-z0-9+/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+/=\s]+)====|^([A-Za-z0-9+/=\s]+)$/;var ue={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bits:6};var T={parse:function(t,i){return Le(t,ue,i)},stringify:function(t,i){return ze(t,ue,i)}};function Le(e,t,i){var r;if(i===void 0&&(i={}),!t.codes){t.codes={};for(var s=0;s<t.chars.length;++s)t.codes[t.chars[s]]=s}if(!i.loose&&e.length*t.bits&7)throw new SyntaxError("Invalid padding");for(var o=e.length;e[o-1]==="=";)if(--o,!i.loose&&!((e.length-o)*t.bits&7))throw new SyntaxError("Invalid padding");for(var d=new((r=i.out)!=null?r:Uint8Array)(o*t.bits/8|0),c=0,a=0,u=0,S=0;S<o;++S){var n=t.codes[e[S]];if(n===void 0)throw new SyntaxError("Invalid character "+e[S]);a=a<<t.bits|n,c+=t.bits,c>=8&&(c-=8,d[u++]=255&a>>c)}if(c>=t.bits||255&a<<8-c)throw new SyntaxError("Unexpected end of data");return d}function ze(e,t,i){i===void 0&&(i={});for(var r=i,s=r.pad,o=s===void 0?!0:s,d=(1<<t.bits)-1,c="",a=0,u=0,S=0;S<e.length;++S)for(u=u<<8|255&e[S],a+=8;a>t.bits;)a-=t.bits,c+=t.chars[d&u>>a];if(a&&(c+=t.chars[d&u<<t.bits-a]),o)for(;c.length*t.bits&7;)c+="=";return c}var je=Object.create,ge=Object.defineProperty,$e=Object.getOwnPropertyDescriptor,Ce=Object.getOwnPropertyNames,Qe=Object.getPrototypeOf,Ze=Object.prototype.hasOwnProperty,K=(e,t)=>function(){return t||(0,e[Ce(e)[0]])((t={exports:{}}).exports,t),t.exports},Je=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ce(t))!Ze.call(e,s)&&s!==i&&ge(e,s,{get:()=>t[s],enumerable:!(r=$e(t,s))||r.enumerable});return e},V=(e,t,i)=>(i=e!=null?je(Qe(e)):{},Je(t||!e||!e.__esModule?ge(i,"default",{value:e,enumerable:!0}):i,e)),ee=K({"node_modules/.pnpm/structured-headers@1.0.1/node_modules/structured-headers/dist/types.js"(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ByteSequence=void 0;var t=class{constructor(i){this.base64Value=i}toBase64(){return this.base64Value}};e.ByteSequence=t}}),L=K({"node_modules/.pnpm/structured-headers@1.0.1/node_modules/structured-headers/dist/util.js"(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isByteSequence=e.isInnerList=e.isValidKeyStr=e.isValidTokenStr=e.isAscii=void 0;var t=/^[\x20-\x7E]*$/,i=/^[a-zA-Z*][:/!#$%&'*+\-.^_`|~A-Za-z0-9]*$/,r=/^[a-z*][*\-_.a-z0-9]*$/;function s(u){return t.test(u)}e.isAscii=s;function o(u){return i.test(u)}e.isValidTokenStr=o;function d(u){return r.test(u)}e.isValidKeyStr=d;function c(u){return Array.isArray(u[0])}e.isInnerList=c;function a(u){return typeof u=="object"&&"base64Value"in u}e.isByteSequence=a}}),te=K({"node_modules/.pnpm/structured-headers@1.0.1/node_modules/structured-headers/dist/token.js"(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Token=void 0;var t=L(),i=class{constructor(r){if(!(0,t.isValidTokenStr)(r))throw new TypeError("Invalid character in Token string. Tokens must start with *, A-Z and the rest of the string may only contain a-z, A-Z, 0-9, :/!#$%&'*+-.^_`|~");this.value=r}toString(){return this.value}};e.Token=i}}),Ye=K({"node_modules/.pnpm/structured-headers@1.0.1/node_modules/structured-headers/dist/serializer.js"(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.serializeKey=e.serializeParameters=e.serializeToken=e.serializeByteSequence=e.serializeBoolean=e.serializeString=e.serializeDecimal=e.serializeInteger=e.serializeBareItem=e.serializeInnerList=e.serializeItem=e.serializeDictionary=e.serializeList=e.SerializeError=void 0;var t=ee(),i=te(),r=L(),s=class extends Error{};e.SerializeError=s;function o(l){return l.map(C=>(0,r.isInnerList)(C)?a(C):c(C)).join(", ")}e.serializeList=o;function d(l){return Array.from(l.entries()).map(([C,A])=>{let E=N(C);return A[0]===!0?E+=I(A[1]):(E+="=",(0,r.isInnerList)(A)?E+=a(A):E+=c(A)),E}).join(", ")}e.serializeDictionary=d;function c(l){return u(l[0])+I(l[1])}e.serializeItem=c;function a(l){return`(${l[0].map(C=>c(C)).join(" ")})${I(l[1])}`}e.serializeInnerList=a;function u(l){if(typeof l=="number")return Number.isInteger(l)?S(l):n(l);if(typeof l=="string")return p(l);if(l instanceof i.Token)return W(l);if(l instanceof t.ByteSequence)return y(l);if(typeof l=="boolean")return f(l);throw new s(`Cannot serialize values of type ${typeof l}`)}e.serializeBareItem=u;function S(l){if(l<-999999999999999||l>999999999999999)throw new s("Structured headers can only encode integers in the range range of -999,999,999,999,999 to 999,999,999,999,999 inclusive");return l.toString()}e.serializeInteger=S;function n(l){let C=l.toFixed(3).replace(/0+$/,"");if(C.split(".")[0].replace("-","").length>12)throw new s("Fractional numbers are not allowed to have more than 12 significant digits before the decimal point");return C}e.serializeDecimal=n;function p(l){if(!(0,r.isAscii)(l))throw new s("Only ASCII strings may be serialized");return`"${l.replace(/("|\\)/g,C=>"\\"+C)}"`}e.serializeString=p;function f(l){return l?"?1":"?0"}e.serializeBoolean=f;function y(l){return`:${l.toBase64()}:`}e.serializeByteSequence=y;function W(l){return l.toString()}e.serializeToken=W;function I(l){return Array.from(l).map(([C,A])=>{let E=";"+N(C);return A!==!0&&(E+="="+u(A)),E}).join("")}e.serializeParameters=I;function N(l){if(!(0,r.isValidKeyStr)(l))throw new s("Keys in dictionaries must only contain lowercase letter, numbers, _-*. and must start with a letter or *");return l}e.serializeKey=N}}),et=K({"node_modules/.pnpm/structured-headers@1.0.1/node_modules/structured-headers/dist/parser.js"(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ParseError=e.parseItem=e.parseList=e.parseDictionary=void 0;var t=ee(),i=te(),r=L();function s(n){return new a(n).parseDictionary()}e.parseDictionary=s;function o(n){return new a(n).parseList()}e.parseList=o;function d(n){return new a(n).parseItem()}e.parseItem=d;var c=class extends Error{constructor(n,p){super(`Parse error: ${p} at offset ${n}`)}};e.ParseError=c;var a=class{constructor(n){this.input=n,this.pos=0}parseDictionary(){this.skipWS();let n=new Map;for(;!this.eof();){let p=this.parseKey(),f;if(this.lookChar()==="="?(this.pos++,f=this.parseItemOrInnerList()):f=[!0,this.parseParameters()],n.set(p,f),this.skipOWS(),this.eof())return n;if(this.expectChar(","),this.pos++,this.skipOWS(),this.eof())throw new c(this.pos,"Dictionary contained a trailing comma")}return n}parseList(){this.skipWS();let n=[];for(;!this.eof();){if(n.push(this.parseItemOrInnerList()),this.skipOWS(),this.eof())return n;if(this.expectChar(","),this.pos++,this.skipOWS(),this.eof())throw new c(this.pos,"A list may not end with a trailing comma")}return n}parseItem(n=!0){n&&this.skipWS();let p=[this.parseBareItem(),this.parseParameters()];return n&&this.checkTrail(),p}parseItemOrInnerList(){return this.lookChar()==="("?this.parseInnerList():this.parseItem(!1)}parseInnerList(){this.expectChar("("),this.pos++;let n=[];for(;!this.eof();){if(this.skipWS(),this.lookChar()===")")return this.pos++,[n,this.parseParameters()];n.push(this.parseItem(!1));let p=this.lookChar();if(p!==" "&&p!==")")throw new c(this.pos,"Expected a whitespace or ) after every item in an inner list")}throw new c(this.pos,"Could not find end of inner list")}parseBareItem(){let n=this.lookChar();if(n===void 0)throw new c(this.pos,"Unexpected end of string");if(n.match(/^[-0-9]/))return this.parseIntegerOrDecimal();if(n==='"')return this.parseString();if(n.match(/^[A-Za-z*]/))return this.parseToken();if(n===":")return this.parseByteSequence();if(n==="?")return this.parseBoolean();throw new c(this.pos,"Unexpected input")}parseParameters(){let n=new Map;for(;!this.eof()&&this.lookChar()===";";){this.pos++,this.skipWS();let f=this.parseKey(),y=!0;this.lookChar()==="="&&(this.pos++,y=this.parseBareItem()),n.set(f,y)}return n}parseIntegerOrDecimal(){let n="integer",p=1,f="";if(this.lookChar()==="-"&&(p=-1,this.pos++),!S(this.lookChar()))throw new c(this.pos,"Expected a digit (0-9)");for(;!this.eof();){let y=this.getChar();if(S(y))f+=y;else if(n==="integer"&&y==="."){if(f.length>12)throw new c(this.pos,"Exceeded maximum decimal length");f+=".",n="decimal"}else{this.pos--;break}if(n==="integer"&&f.length>15)throw new c(this.pos,"Exceeded maximum integer length");if(n==="decimal"&&f.length>16)throw new c(this.pos,"Exceeded maximum decimal length")}if(n==="integer")return parseInt(f,10)*p;if(f.endsWith("."))throw new c(this.pos,"Decimal cannot end on a period");if(f.split(".")[1].length>3)throw new c(this.pos,"Number of digits after the decimal point cannot exceed 3");return parseFloat(f)*p}parseString(){let n="";for(this.expectChar('"'),this.pos++;!this.eof();){let p=this.getChar();if(p==="\\"){if(this.eof())throw new c(this.pos,"Unexpected end of input");let f=this.getChar();if(f!=="\\"&&f!=='"')throw new c(this.pos,"A backslash must be followed by another backslash or double quote");n+=f}else{if(p==='"')return n;if((0,r.isAscii)(p))n+=p;else throw new c(this.pos,"Strings must be in the ASCII range")}}throw new c(this.pos,"Unexpected end of input")}parseToken(){let n="";for(;!this.eof();){let p=this.lookChar();if(p===void 0||!/^[:/!#$%&'*+\-.^_`|~A-Za-z0-9]$/.test(p))return new i.Token(n);n+=this.getChar()}return new i.Token(n)}parseByteSequence(){this.expectChar(":"),this.pos++;let n=this.input.indexOf(":",this.pos);if(n===-1)throw new c(this.pos,'Could not find a closing ":" character to mark end of Byte Sequence');let p=this.input.substring(this.pos,n);if(this.pos+=p.length+1,!/^[A-Za-z0-9+/=]*$/.test(p))throw new c(this.pos,"ByteSequence does not contain a valid base64 string");return new t.ByteSequence(p)}parseBoolean(){this.expectChar("?"),this.pos++;let n=this.getChar();if(n==="1")return!0;if(n==="0")return!1;throw new c(this.pos,'Unexpected character. Expected a "1" or a "0"')}parseKey(){var n;if(!(!((n=this.lookChar())===null||n===void 0)&&n.match(/^[a-z*]/)))throw new c(this.pos,"A key must begin with an asterisk or letter (a-z)");let p="";for(;!this.eof();){let f=this.lookChar();if(f===void 0||!/^[a-z0-9_\-.*]$/.test(f))return p;p+=this.getChar()}return p}lookChar(){return this.input[this.pos]}expectChar(n){if(this.lookChar()!==n)throw new c(this.pos,`Expected ${n}`)}getChar(){return this.input[this.pos++]}eof(){return this.pos>=this.input.length}skipOWS(){for(;;){let n=this.input.substr(this.pos,1);if(n===" "||n===" ")this.pos++;else break}}skipWS(){for(;this.lookChar()===" ";)this.pos++}checkTrail(){if(this.skipWS(),!this.eof())throw new c(this.pos,"Unexpected characters at end of input")}};e.default=a;var u=/^[0-9]$/;function S(n){return n===void 0?!1:u.test(n)}}}),z=K({"node_modules/.pnpm/structured-headers@1.0.1/node_modules/structured-headers/dist/index.js"(e){"use strict";var t=e&&e.__createBinding||(Object.create?function(s,o,d,c){c===void 0&&(c=d);var a=Object.getOwnPropertyDescriptor(o,d);(!a||("get"in a?!o.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return o[d]}}),Object.defineProperty(s,c,a)}:function(s,o,d,c){c===void 0&&(c=d),s[c]=o[d]}),i=e&&e.__exportStar||function(s,o){for(var d in s)d!=="default"&&!Object.prototype.hasOwnProperty.call(o,d)&&t(o,s,d)};Object.defineProperty(e,"__esModule",{value:!0}),e.Token=void 0,i(Ye(),e),i(et(),e),i(ee(),e),i(L(),e);var r=te();Object.defineProperty(e,"Token",{enumerable:!0,get:function(){return r.Token}})}});var b1=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);var ye=new TextEncoder;async function tt(){return globalThis.crypto??(await import("node:crypto")).webcrypto}var it=/[^\S\r\n]*\r?\n[^\S\r\n]+/g;function pe(e){return e.replaceAll(it," ")}function k(e){if(typeof e=="number")return e.toString();if(!e)return"";if(typeof e=="string")return pe(e).trim();if(Array.isArray(e))return e.map(t=>{if(t==null)return"";if(typeof t=="number")return t.toString();if(typeof t=="string")return pe(t).trim();throw new Error(`Invalid header value type ${t}`)}).join(", ");throw new Error(`Invalid header value type ${e}`)}function q(e){return Object.entries(e).reduce((t,[i,r])=>(i==="__proto__"||(t[i.toLowerCase()]=r),t),{})}function he(e,t){t=t.toLowerCase();for(let[i,r]of Object.entries(e))if(i.toLowerCase()===t)return r}function rt(e){return typeof e=="number"?e.toString():typeof e=="string"?e.toLowerCase():""}function Y(e){return e.reduce((t,i,r)=>{if(r%2===0){if(typeof i!="string")throw new Error(`Invalid header key type '${typeof i}' of ${i}`);if(i.toLowerCase()in t)return t;t[i.toLowerCase()]=[]}else t[rt(e[r-1])].push(i==null?"":i.toString());return t},{})}function _(e){if("rawHeaders"in e&&e.rawHeaders)return Y(e.rawHeaders.flat(1));if("getHeaders"in e&&typeof e.getHeaders=="function")return q(e.getHeaders());if("headers"in e&&e.headers){if(typeof e.headers!="object")throw new Error("headers must be an object");return Ae(e.headers)?Y(Array.from(e.headers.entries()).flat(1)):Array.isArray(e.headers)?Y(e.headers.flat(1)):q(e.headers)}throw new Error("Cannot get headers from request object")}function Ie(e,t,i){if("setHeader"in e&&typeof e.setHeader=="function")e.setHeader(t,i.toString());else if("headers"in e&&typeof e.headers=="object")Ae(e.headers)?e.headers.set(t,i.toString()):e.headers[t]=i.toString();else throw new Error("Cannot set headers to request object")}function Se(e){return"Response"in globalThis&&typeof e=="object"&&e instanceof Response}function st(e){return"Request"in globalThis&&typeof e=="object"&&e instanceof Request}function Ae(e){return"Headers"in globalThis&&typeof e=="object"&&e instanceof Headers}function be(e){let t=new Uint8Array(e);return T.stringify(t)}var ct={hash:"SHA-256",ec:"DSA"};function nt(e,t){return{hash:t,...e}}function ie(e){return e instanceof Map?new Map(e):Array.isArray(e)?new Map(e):new Map(Object.entries(e))}function fe(e){let t=ie(e);for(let[i,r]of t.entries())r===void 0&&t.delete(i);return t}var m=V(z(),1),ot={signature:"dict","signature-input":"dict","accept-signature":"dict","content-digest":"dict","repr-digest":"dict","want-content-digest":"dict","want-repr-digest":"dict","accept-ch":"list","proxy-status":"list","cache-status":"list",priority:"dict","client-cert":"bs","client-cert-chain":"list"},at=["@method","@authority","@scheme","@target-uri","@request-target","@path","@query"],dt=["@status"],Ee=class{isRequest(){return this.response===null}isResponse(){return this.response!==null}constructor(e,t="https",i={},r,s=null){if(s&&!Array.isArray(s))throw new Error("requiredComponents must be an array");if(s&&s.length>0?this.requiredComponents=s.map(c=>{let a;return c.startsWith('"')?a=m.parseItem(c):a=[c,new Map],m.serializeItem(a)}):this.requiredComponents=null,this.sfvTypeDictionary=q({...ot,...i}),"req"in e)this.response=e,this.responseHeaders=_(e),this.request=e.req,this.requestHeaders=_(this.request);else if(Se(e)){if(!r)throw new Error("Request is not provided");this.response=e,this.responseHeaders=_(e),this.request=r,this.requestHeaders=_(this.request)}else this.response=null,this.responseHeaders=null,this.request=e,this.requestHeaders=_(e);if(!this.request.url)throw new Error("Request URL is empty");if(!this.request.method)throw new Error("Request method is empty");if(!("signature-input"in this.requestHeaders))throw new Error("Signature-Input header is not found in request");if(this.requestSignatureInput=m.parseDictionary(k(this.requestHeaders["signature-input"])),this.isResponse()){if(!this.responseHeaders)throw new Error("responseHeaders is empty");if(!("signature-input"in this.responseHeaders))throw new Error("Signature-Input header is not found in response");this.responseSignatureInput=m.parseDictionary(k(this.responseHeaders["signature-input"]))}this.sfvTypeDictionary=q(i),this.scheme=this.request.url.startsWith("/")?t:new URL(this.request.url).protocol.replace(":","");let o="httpVersionMajor"in this.request&&this.request.httpVersionMajor===2?this.requestHeaders[":authority"]:this.requestHeaders.host;if(!st(this.request)&&!o)throw new Error("Host header is empty");let d=k(o);this.targetUri=this.request.url.startsWith("/")?new URL(this.request.url,`${t}://${d}`).href:this.request.url,this.url=new URL(this.targetUri)}get(e,t=new Map){let i=ie(t),r=m.serializeItem([e,i]);if(!e)throw new Error(`Type is empty: ${r}`);if(e.startsWith('"'))if(e.endsWith('"'))e=e.slice(1,-1);else throw new Error(`Invalid component type string: ${r}`);if(this.isResponse()&&i.get("req")!==!0&&at.includes(e))throw new Error(`component is not available in response (must use with ;req, or provided object is unintentionally treated as response (existing req prop.)): ${e}`);if(this.isRequest()&&dt.includes(e))throw new Error(`component is not available in request (provided object is unintentionally treated as request (including req prop.)): ${e}`);if(this.isRequest()&&i.get("req")===!0)throw new Error("req param is not available in request (provided object is treated as request, please set req param with Request)");let s=this.isRequest()||i.get("req")===!0;if(e==="@signature-params")throw new Error(`@signature-params is not available in get method: ${r}`);if(e==="@method"){if(!this.request.method)throw new Error("Request method is empty");return this.request.method.toUpperCase()}else{if(e==="@authority")return this.url.host;if(e==="@scheme")return this.scheme.toLocaleLowerCase();if(e==="@target-uri")return this.targetUri;if(e==="@request-target"){if(!this.request.method)throw new Error("Request method is empty");return`${this.request.method.toLowerCase()} ${this.url.pathname}`}else{if(e==="@path")return this.url.pathname;if(e==="@query")return this.url.search;if(e==="@query-param"){let o=i.get("name");if(o===void 0)throw new Error("Query parameter name not found or invalid");let d=this.url.searchParams.get(o.toString());if(d===null)throw new Error(`Query parameter not found: ${o} (${r})`);return d}else if(e==="@status"){if(!this.response)throw new Error("response is empty (@status)");return Se(this.response)?this.response.status.toString():this.response.statusCode.toString()}else{if(e.startsWith("@"))throw new Error(`Unknown derived component: ${e}`);{let o=i.get("key"),d=i.get("sf")===!0,c=i.get("bs")===!0,a=i.get("tr")===!0;if([o,d,c].filter(S=>S).length>1)throw new Error(`Invalid component: ${r} (multiple params are specified)`);let u=(()=>{if(s)if(a){if("trailers"in this.request&&this.request.trailers)return he(this.request.trailers,e);throw new Error(`Trailers not found in request object (${r})`)}else return this.requestHeaders[e];else{if(!this.response||!this.responseHeaders)throw new Error("response is not provided");if(a){if("trailers"in this.response&&this.response.trailers)return he(this.response.trailers,e);throw new Error(`Trailers not found in response object (${r})`)}else return this.responseHeaders[e]}})();if(u===void 0)throw new Error(`Header not found: ${r}`);if(d){if(!(e in this.sfvTypeDictionary))throw new Error(`Type not found in SFV type dictionary: ${e}`);let S=k(u);if(this.sfvTypeDictionary[e]==="dict")return m.serializeDictionary(m.parseDictionary(S));if(this.sfvTypeDictionary[e]==="list")return m.serializeList(m.parseList(S));if(["item","bs","int","dec","str","bool","token"].includes(this.sfvTypeDictionary[e]))return m.serializeItem(m.parseItem(S))}if(o){if(!(e in this.sfvTypeDictionary))throw new Error(`key specified but type unknown (Type not found in SFV type dictionary): ${r}`);if(typeof u!="string")throw new Error(`Key specified but value is not a string: ${r}`);if(this.sfvTypeDictionary[e]==="dict"){let n=m.parseDictionary(u).get(o);if(n===void 0)throw new Error(`Key not found in dictionary: ${o} (${r})`);return Array.isArray(n[0])?m.serializeList([n]):m.serializeItem(n)}else throw new Error(`"${e}" is not dict: ${this.sfvTypeDictionary[e]} (${r})`)}if(c){let S=(Array.isArray(u)?u:[u]).map(n=>{if(typeof n!="string")throw new Error(`Invalid header value type: ${typeof n}`);return[new m.ByteSequence(be(ye.encode(k(n)).buffer)),new Map]});return m.serializeList(S)}return k(u)}}}}}generate(e){let t=this.isRequest()?this.requestSignatureInput?.get(e):this.responseSignatureInput?.get(e);if(!t)throw new Error(`label not found: ${e}`);if(!Array.isArray(t[0]))throw new Error(`item is not InnerList: ${m.serializeDictionary(new Map([[e,t]]))}`);let i=new Map;for(let r of t[0]){let s=r[0];if(s.startsWith('"'))if(s.endsWith('"'))s=s.slice(1,-1);else throw new Error(`Invalid component identifier name: ${s}`);r[0]=s;let o=m.serializeItem(r);if(i.has(o))throw new Error(`Duplicate key: ${s}`);i.set(o,this.get(s,r[1]))}if(this.requiredComponents){for(let r of this.requiredComponents)if(!i.has(r))throw new Error(`Required component not found: ${r}`)}return i.set('"@signature-params"',m.serializeInnerList(t)),Array.from(i.entries(),([r,s])=>`${r}: ${s}`).join(`
4
- `)}};function Te(e){let t=ie(e),i=new Map;for(let[r,s]of t){if(!Array.isArray(s))throw new Error("item is not array");let[o,d]=s;i.set(r,[o.map(c=>typeof c=="string"?[c,new Map]:[c[0],fe(c[1])]),fe(d)])}return m.serializeDictionary(i)}var w1=V(z(),1);async function Pe(e,t,i=ct){let r=await(await tt()).subtle.sign(nt(e.algorithm,i.hash),e,ye.encode(t));return be(r)}var M1=V(z(),1);function we(e){let t=e.toUpperCase();if(t==="SHA-256")return"sha-256";if(t==="SHA-512")return"sha-512";throw new Error(`Unsupported hash algorithm: ${e}`)}var k1=V(z(),1);async function j(){return globalThis.crypto??(await import("node:crypto")).webcrypto}var De=e=>{let t=new Uint8Array(e);return T.stringify(t)};var lt=async(e,t="SHA-256")=>(t==="SHA"&&(t="SHA-1"),typeof e=="string"&&(e=new TextEncoder().encode(e)),(await j()).subtle.digest(t,e)),Me=async e=>{let t="SHA-256",i=await lt(e.body,t).then(De),r=`${t}=${i}`,s=`${we(t)}=:${i}:`;return{digest:r,contentDigest:s}};var ut=/^[\x20-\x7E]*$/,pt=/^[a-zA-Z*][:/!#$%&'*+\-.^_`|~A-Za-z0-9]*$/,ht=/^[a-z*][*\-_.a-z0-9]*$/;function re(e){return ut.test(e)}function ve(e){return pt.test(e)}function Ne(e){return ht.test(e)}function ke(e){return Array.isArray(e[0])}function Ke(e){let t=new Uint8Array(e),i="";for(let r of t)i+=String.fromCharCode(r);return btoa(i)}function se(e){let t=atob(e),i=t.length,r=new Uint8Array(i);for(let s=0;s<i;s++)r[s]=t.charCodeAt(s);return r.buffer}var R=class{constructor(t){if(!ve(t))throw new TypeError("Invalid character in Token string. Tokens must start with *, A-Z and the rest of the string may only contain a-z, A-Z, 0-9, :/!#$%&'*+-.^_`|~");this.value=t}toString(){return this.value}};var O=class{constructor(t){this.value=t}toString(){return this.value}};var w=class extends Error{};function Re(e){let t=e instanceof Map?e.entries():Object.entries(e);return Array.from(t).map(([i,r])=>{let s=xe(i);return Array.isArray(r)?r[0]===!0?s+Q(r[1]):ke(r)?s+"="+St(r):s+"="+Oe(r):r===!0?s:s+"="+$(r)}).join(", ")}function Oe(e,t){return Array.isArray(e)?$(e[0])+Q(e[1]):$(e)+(t?Q(t):"")}function St(e){return`(${e[0].map(t=>Oe(t)).join(" ")})${Q(e[1])}`}function $(e){if(typeof e=="number")return Number.isInteger(e)?ft(e):mt(e);if(typeof e=="string")return gt(e);if(e instanceof R)return At(e);if(e instanceof ArrayBuffer)return It(e);if(e instanceof O)return Ct(e);if(e instanceof Date)return bt(e);if(typeof e=="boolean")return yt(e);throw new w(`Cannot serialize values of type ${typeof e}`)}function ft(e){if(e<-999999999999999||e>999999999999999)throw new w("Structured headers can only encode integers in the range range of -999,999,999,999,999 to 999,999,999,999,999 inclusive");return e.toString()}function mt(e){let t=e.toFixed(3).replace(/0+$/,"");if(t.split(".")[0].replace("-","").length>12)throw new w("Fractional numbers are not allowed to have more than 12 significant digits before the decimal point");return t}function gt(e){if(!re(e))throw new w("Only ASCII strings may be serialized");return`"${e.replace(/("|\\)/g,t=>"\\"+t)}"`}function Ct(e){let t='%"',i=new TextEncoder;for(let r of i.encode(e.toString()))r===37||r===34||r<=31||r>=127?t+="%"+r.toString(16):t+=String.fromCharCode(r);return t+'"'}function yt(e){return e?"?1":"?0"}function It(e){return`:${Ke(e)}:`}function At(e){return e.toString()}function bt(e){return"@"+Math.floor(e.getTime()/1e3)}function Q(e){return Array.from(e).map(([t,i])=>{let r=";"+xe(t);return i!==!0&&(r+="="+$(i)),r}).join("")}function xe(e){if(!Ne(e))throw new w("Keys in dictionaries must only contain lowercase letter, numbers, _-*. and must start with a letter or *");return e}var Be=async e=>{let{request:t,authenticationType:i,accessKey:r,secretKey:s,creationDate:o}=e,d={key_ops:["sign","verify"],ext:!0,kty:"oct",k:s,alg:"HS256"},c=await(await j()).subtle.importKey("jwk",d,{name:"HMAC",hash:"SHA-256"},!0,["sign","verify"]),a=new Map,u=new Map;a.set(i,c),u.set(i,[["x-timestamp","@authority","content-type","content-digest","content-length"],{keyid:r,created:o,alg:"hmac-sha256"}]);let S=Te(u);Ie(t,"Signature-Input",S);let n=new Ee(t),p=(n.isRequest()?n.requestSignatureInput:n.responseSignatureInput)?.keys();if(!p)throw new Error("signaturesEntries is undefined");let f=new Map,y=new Map;for(let I of p){let N=n.generate(I),l=a.get(I);if(!l)throw new Error(`key not found: ${I}`);y.set(I,N),f.set(I,[se(await Pe(l,N,{hash:"SHA-256",ec:"DSA"})),new Map])}let W=Re(f);return{signatureInputHeader:S,signatureHeader:W}};function _e(e){return{async onRequest({request:t}){let i=t.clone(),r=i.url,s=await i.arrayBuffer()??JSON.stringify({}),o=i.method??"POST",d=await X.generateDigestHeaders({body:s}),c={headers:{"X-Timestamp":Date.now().toString(),Host:new URL(r).host,"Content-Type":i.headers.get("Content-Type")??"application/json","Content-Length":i.headers.get("Content-Length")??s.byteLength.toString(),Digest:d.digest,"Content-Digest":d.contentDigest},body:s.toString(),method:o,url:r},{signatureHeader:a,signatureInputHeader:u}=await X.generateSignatureHeader({request:c,authenticationType:"team",accessKey:e.accessKey,secretKey:Buffer.from(e.secretKey,"hex").toString("base64"),creationDate:Math.floor(Date.now()/1e3)});return t.headers.set("Signature",a),t.headers.set("Signature-Input",u),t.headers.set("X-Timestamp",c.headers["X-Timestamp"]),t.headers.set("Content-Type",c.headers["Content-Type"]),t.headers.set("Digest",c.headers.Digest),t.headers.set("Content-Digest",c.headers["Content-Digest"]),t}}}var g=class extends Error{statusCode;code;constructor(t,i,r){super(t),this.statusCode=i,this.code=r,this.name="SubnotoError"}};function Xe(e){return{async onRequest({request:t}){if(!t.url.includes("/tunnel/")&&!t.url.includes("/public/")||t.url.includes("/tunnel/session"))return t;try{await e.ensureSession();let i=t.clone(),r=Buffer.from(await i.arrayBuffer());if(!r||r.byteLength===0)throw new g("EMPTY_REQUEST_BODY");let s=e.encryptRequest(r);if(!s||s.byteLength===0)throw new g("Empty encrypted message");let o=e.getSessionId();if(!o)throw new g("Session ID not available");let d=new Headers(i.headers);d.set("X-Session-Id",o);let c=i.headers.get("Content-Type");c&&c.includes("multipart/form-data")&&d.set("X-Original-Content-Type",c),d.set("Content-Type","application/octet-stream"),d.set("Content-Length",s.byteLength.toString());let a=await e.getCookies(i.url);return a&&d.set("Cookie",a),new Request(i.url,{method:i.method,headers:d,body:s,mode:i.mode,credentials:i.credentials,cache:i.cache,redirect:i.redirect,referrer:i.referrer,referrerPolicy:i.referrerPolicy,integrity:i.integrity,keepalive:i.keepalive})}catch(i){throw console.error(`Error in tunnel middleware for ${t.url}:`,i),i}},async onResponse({response:t,request:i}){if(!i.url.includes("/tunnel/")&&!i.url.includes("/public/")||i.url.includes("/tunnel/session"))return t;try{if(!(t.headers.get("x-subnoto-encrypted-response")?.includes("true")&&t.headers.get("content-type")?.includes("application/octet-stream")))return t;let s=t.clone(),o=Buffer.from(await s.arrayBuffer());if(o.byteLength===0)throw new g("Empty encrypted response");let d=e.decryptResponse(o),c=new Headers(t.headers);return c.get("x-subnoto-content-type-response")?.includes("application/octet-stream")?(c.set("Content-Type","application/octet-stream"),c.delete("x-subnoto-encrypted-response"),new Response(d,{status:t.status,statusText:t.statusText,headers:c})):(c.set("Content-Type","application/json"),c.delete("x-subnoto-encrypted-response"),c.delete("x-subnoto-content-type-response"),new Response(d,{status:t.status,statusText:t.statusText,headers:c}))}catch(r){throw console.error(`Error decrypting response for ${i.url}:`,r),r}}}}var ne={};de(ne,{PutIncomingMessageResult:()=>wt,WasmClientSession:()=>v,__wbg___wbindgen_is_function_ee8a6c5833c90377:()=>Dt,__wbg___wbindgen_is_object_c818261d21f283a4:()=>Mt,__wbg___wbindgen_is_string_fbb76cb2940daafd:()=>vt,__wbg___wbindgen_is_undefined_2d472862bd29a478:()=>Nt,__wbg___wbindgen_throw_b855445ff6a94295:()=>kt,__wbg_call_525440f72fbfc0ea:()=>Kt,__wbg_call_e762c39fa8ea36bf:()=>Rt,__wbg_crypto_574e78ad8b13b65f:()=>Ot,__wbg_getRandomValues_b8f5dbd5f3995a9e:()=>xt,__wbg_length_69bca3cb64fc8748:()=>Bt,__wbg_msCrypto_a61aeb35a24c1329:()=>_t,__wbg_new_no_args_ee98eee5275000a4:()=>Xt,__wbg_new_with_length_01aa0dc35aa13543:()=>Ft,__wbg_node_905d3e251edff8a2:()=>Ht,__wbg_now_793306c526e2e3b6:()=>Gt,__wbg_process_dc0fbacc7c1c06f7:()=>Wt,__wbg_prototypesetcall_2a6620b6922694b2:()=>Ut,__wbg_randomFillSync_ac0988aba3254290:()=>qt,__wbg_require_60cc747a6bc5215a:()=>Vt,__wbg_set_wasm:()=>Tt,__wbg_static_accessor_GLOBAL_89e1d9ac6a1b250e:()=>Lt,__wbg_static_accessor_GLOBAL_THIS_8b530f326a9e48ac:()=>zt,__wbg_static_accessor_SELF_6fdf4b64710cc91b:()=>jt,__wbg_static_accessor_WINDOW_b45bfc5a37f6cfa2:()=>$t,__wbg_subarray_480600f3d6a9f26c:()=>Qt,__wbg_versions_c01dfd4722a88165:()=>Zt,__wbindgen_cast_2241b6af4c4b2941:()=>Jt,__wbindgen_cast_cb9088102bce6b30:()=>Yt,__wbindgen_init_externref_table:()=>e1});var h,Et;function Tt(e,t){h=e,Et=t}var Z=null;function ce(){return(Z===null||Z.byteLength===0)&&(Z=new Uint8Array(h.memory.buffer)),Z}var He=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});He.decode();function Pt(e,t){return He.decode(ce().subarray(e,e+t))}function F(e,t){return e=e>>>0,Pt(e,t)}function H(e){let t=h.__externref_table_alloc();return h.__wbindgen_externrefs.set(t,e),t}function G(e,t){try{return e.apply(this,t)}catch(i){let r=H(i);h.__wbindgen_exn_store(r)}}function M(e,t){return e=e>>>0,ce().subarray(e/1,e/1+t)}function B(e){return e==null}var D=0;function x(e,t){let i=t(e.length*1,1)>>>0;return ce().set(e,i/1),D=e.length,i}function P(e){let t=h.__wbindgen_externrefs.get(e);return h.__externref_table_dealloc(e),t}var wt=Object.freeze({NoIncomingMessageExpected:0,0:"NoIncomingMessageExpected",Success:1,1:"Success"}),Fe=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>h.__wbg_wasmclientsession_free(e>>>0,1)),v=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Fe.unregister(this),t}free(){let t=this.__destroy_into_raw();h.__wbg_wasmclientsession_free(t,0)}constructor(t,i){var r=B(i)?0:x(i,h.__wbindgen_malloc),s=D;let o=h.wasmclientsession_new(B(t)?16777215:t?1:0,r,s);if(o[2])throw P(o[1]);return this.__wbg_ptr=o[0]>>>0,Fe.register(this,this.__wbg_ptr,this),this}is_open(){return h.wasmclientsession_is_open(this.__wbg_ptr)!==0}write(t){let i=x(t,h.__wbindgen_malloc),r=D,s=h.wasmclientsession_write(this.__wbg_ptr,i,r);if(s[3])throw P(s[2]);var o=M(s[0],s[1]).slice();return h.__wbindgen_free(s[0],s[1]*1,1),o}read(t){let i=x(t,h.__wbindgen_malloc),r=D,s=h.wasmclientsession_read(this.__wbg_ptr,i,r);if(s[3])throw P(s[2]);var o=M(s[0],s[1]).slice();return h.__wbindgen_free(s[0],s[1]*1,1),o}write_buffer(t){let i=x(t,h.__wbindgen_malloc),r=D,s=h.wasmclientsession_write_buffer(this.__wbg_ptr,i,r);if(s[3])throw P(s[2]);var o=M(s[0],s[1]).slice();return h.__wbindgen_free(s[0],s[1]*1,1),o}read_buffer(t){let i=x(t,h.__wbindgen_malloc),r=D,s=h.wasmclientsession_read_buffer(this.__wbg_ptr,i,r);if(s[3])throw P(s[2]);var o=M(s[0],s[1]).slice();return h.__wbindgen_free(s[0],s[1]*1,1),o}put_incoming_message(t){let i=x(t,h.__wbindgen_malloc),r=D,s=h.wasmclientsession_put_incoming_message(this.__wbg_ptr,i,r);if(s[2])throw P(s[1]);return s[0]}get_outgoing_message(){let t=h.wasmclientsession_get_outgoing_message(this.__wbg_ptr);if(t[3])throw P(t[2]);let i;return t[0]!==0&&(i=M(t[0],t[1]).slice(),h.__wbindgen_free(t[0],t[1]*1,1)),i}get_attestation_results_json(){let t=h.wasmclientsession_get_attestation_results_json(this.__wbg_ptr);if(t[3])throw P(t[2]);let i;return t[0]!==0&&(i=F(t[0],t[1]).slice(),h.__wbindgen_free(t[0],t[1]*1,1)),i}get_attestation_status(){let t,i;try{let r=h.wasmclientsession_get_attestation_status(this.__wbg_ptr);return t=r[0],i=r[1],F(r[0],r[1])}finally{h.__wbindgen_free(t,i,1)}}};Symbol.dispose&&(v.prototype[Symbol.dispose]=v.prototype.free);function Dt(e){return typeof e=="function"}function Mt(e){let t=e;return typeof t=="object"&&t!==null}function vt(e){return typeof e=="string"}function Nt(e){return e===void 0}function kt(e,t){throw new Error(F(e,t))}function Kt(){return G(function(e,t,i){return e.call(t,i)},arguments)}function Rt(){return G(function(e,t){return e.call(t)},arguments)}function Ot(e){return e.crypto}function xt(){return G(function(e,t){e.getRandomValues(t)},arguments)}function Bt(e){return e.length}function _t(e){return e.msCrypto}function Xt(e,t){return new Function(F(e,t))}function Ft(e){return new Uint8Array(e>>>0)}function Ht(e){return e.node}function Gt(){return Date.now()}function Wt(e){return e.process}function Ut(e,t,i){Uint8Array.prototype.set.call(M(e,t),i)}function qt(){return G(function(e,t){e.randomFillSync(t)},arguments)}function Vt(){return G(function(){return module.require},arguments)}function Lt(){let e=typeof global>"u"?null:global;return B(e)?0:H(e)}function zt(){let e=typeof globalThis>"u"?null:globalThis;return B(e)?0:H(e)}function jt(){let e=typeof self>"u"?null:self;return B(e)?0:H(e)}function $t(){let e=typeof window>"u"?null:window;return B(e)?0:H(e)}function Qt(e,t,i){return e.subarray(t>>>0,i>>>0)}function Zt(e){return e.versions}function Jt(e,t){return F(e,t)}function Yt(e,t){return M(e,t)}function e1(){let e=h.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)}import{readFileSync as t1}from"node:fs";var oe={};oe["./oak_session_wasm_nodejs_bg.js"]=ne;var i1=new URL("oak_session_wasm_nodejs_bg.wasm",import.meta.url),r1=t1(i1),Ge=new WebAssembly.Module(r1),We=new WebAssembly.Instance(Ge,oe).exports;oe["./oak_session_wasm_nodejs_bg.js"].__wbg_set_wasm(We,Ge);We.__wbindgen_start();import{CookieJar as s1}from"tough-cookie";var J=class{session=null;sessionId=null;config;handshakeInProgress=!1;cookieJar;constructor(t){this.config=t,this.cookieJar=new s1}async ensureSession(){if(!(this.session&&this.session.is_open())){if(this.handshakeInProgress){for(;this.handshakeInProgress;)await new Promise(t=>setTimeout(t,50));return}await this.handshake()}}async handshake(){this.handshakeInProgress=!0;try{let t=this.config.unattested??!1;this.session=new v(t,t?void 0:this.config.attesterKey);let i=4,r=0;if(!this.session)throw new g("Failed to create session");for(;!this.session.is_open()&&r<i;){r++;let s=this.session.get_outgoing_message();if(!s||this.session.is_open())break;let o=`${this.config.apiBaseUrl}/tunnel/session`,d={"Content-Type":"application/octet-stream"};this.sessionId&&(d["X-Session-Id"]=this.sessionId);let c=await this.cookieJar.getCookieString(o);c&&(d.Cookie=c);let a=await fetch(o,{method:"POST",body:s,headers:d});if(!this.sessionId){let n=a.headers.get("X-Session-Id");if(!n)throw new g("No session ID received from server");this.sessionId=n}if(!a.ok){let n=await a.text().catch(()=>"Unable to read error");throw new g(`Handshake failed with status ${a.status}: ${n}`,a.status)}let u=a.headers.getSetCookie?.()||[];for(let n of u)await this.cookieJar.setCookie(n,o);let S=await a.arrayBuffer();if(S.byteLength>0)this.session.put_incoming_message(Buffer.from(S));else throw new g("Empty response from server during handshake")}if(!this.session.is_open()||!this.sessionId)throw new g("Failed to establish session after handshake")}finally{this.handshakeInProgress=!1}}encryptRequest(t){if(!this.session||!this.session.is_open())throw new g("Session not open");try{let i=typeof t=="string"?Buffer.from(t,"utf-8"):t,r=this.session.write(i);return Buffer.from(r)}catch(i){throw new g(`Encryption failed: ${i instanceof Error?i.message:"Unknown error"}`)}}decryptResponse(t){if(!this.session||!this.session.is_open())throw new g("Session not open");try{let i=Buffer.isBuffer(t)?t:Buffer.from(t),r=this.session.read(i);return Buffer.from(r)}catch(i){throw new g(`Decryption failed: ${i instanceof Error?i.message:"Unknown error"}`)}}getSessionId(){return this.sessionId}getCookies(t){return this.cookieJar.getCookieString(t)}destroy(){this.session=null,this.sessionId=null}getAttestationResults(){return this.session?this.session.get_attestation_results_json()??null:null}getAttestationStatus(){return this.session?this.session.get_attestation_status()??null:null}};function Ue(e){let t=c1({baseUrl:e.apiBaseUrl}),i=new J(e);return t.use(Xe(i)),t.use(_e({accessKey:e.accessKey,secretKey:e.secretKey})),{client:t,sessionManager:i}}async function qe(e,t){let{workspaceUuid:i,fileBuffer:r,envelopeTitle:s}=t,o=new Blob([new Uint8Array(r)],{type:"application/pdf"}),d=await e.POST("/public/envelope/create-from-file",{body:{workspaceUuid:i,envelopeTitle:s,file:o},bodySerializer:c=>{let a=new FormData;return a.append("workspaceUuid",c.workspaceUuid),a.append("envelopeTitle",c.envelopeTitle),a.append("file",c.file,"document.pdf"),a}});if(d.error)throw new g(`Failed to upload document: ${JSON.stringify(d.error)}`,d.response?.status,typeof d.error=="object"&&"code"in d.error?String(d.error.code):void 0);return{envelopeUuid:d.data.envelopeUuid,documentUuid:d.data.documentUuid}}var ae=class{client;sessionManager;constructor(t){let{client:i,sessionManager:r}=Ue(t);this.client=i,this.sessionManager=r}get GET(){return this.client.GET}get POST(){return this.client.POST}get PUT(){return this.client.PUT}get DELETE(){return this.client.DELETE}get PATCH(){return this.client.PATCH}uploadDocument(t){return qe(this,t)}getAttestationStatus(){let t=this.sessionManager.getAttestationStatus();return t?JSON.parse(t):null}getAttestationResults(){let t=this.sessionManager.getAttestationResults();return t?JSON.parse(t):null}};export{ae as SubnotoClient,g as SubnotoError};
4
+ `)}};function Te(e){let t=ie(e),i=new Map;for(let[r,s]of t){if(!Array.isArray(s))throw new Error("item is not array");let[o,d]=s;i.set(r,[o.map(c=>typeof c=="string"?[c,new Map]:[c[0],fe(c[1])]),fe(d)])}return m.serializeDictionary(i)}var w1=V(z(),1);async function Pe(e,t,i=ct){let r=await(await tt()).subtle.sign(nt(e.algorithm,i.hash),e,ye.encode(t));return be(r)}var M1=V(z(),1);function we(e){let t=e.toUpperCase();if(t==="SHA-256")return"sha-256";if(t==="SHA-512")return"sha-512";throw new Error(`Unsupported hash algorithm: ${e}`)}var k1=V(z(),1);async function j(){return globalThis.crypto??(await import("node:crypto")).webcrypto}var De=e=>{let t=new Uint8Array(e);return T.stringify(t)};var lt=async(e,t="SHA-256")=>(t==="SHA"&&(t="SHA-1"),typeof e=="string"&&(e=new TextEncoder().encode(e)),(await j()).subtle.digest(t,e)),Me=async e=>{let t="SHA-256",i=await lt(e.body,t).then(De),r=`${t}=${i}`,s=`${we(t)}=:${i}:`;return{digest:r,contentDigest:s}};var ut=/^[\x20-\x7E]*$/,pt=/^[a-zA-Z*][:/!#$%&'*+\-.^_`|~A-Za-z0-9]*$/,ht=/^[a-z*][*\-_.a-z0-9]*$/;function re(e){return ut.test(e)}function ve(e){return pt.test(e)}function Ne(e){return ht.test(e)}function ke(e){return Array.isArray(e[0])}function Ke(e){let t=new Uint8Array(e),i="";for(let r of t)i+=String.fromCharCode(r);return btoa(i)}function se(e){let t=atob(e),i=t.length,r=new Uint8Array(i);for(let s=0;s<i;s++)r[s]=t.charCodeAt(s);return r.buffer}var R=class{constructor(t){if(!ve(t))throw new TypeError("Invalid character in Token string. Tokens must start with *, A-Z and the rest of the string may only contain a-z, A-Z, 0-9, :/!#$%&'*+-.^_`|~");this.value=t}toString(){return this.value}};var O=class{constructor(t){this.value=t}toString(){return this.value}};var w=class extends Error{};function Re(e){let t=e instanceof Map?e.entries():Object.entries(e);return Array.from(t).map(([i,r])=>{let s=xe(i);return Array.isArray(r)?r[0]===!0?s+Q(r[1]):ke(r)?s+"="+St(r):s+"="+Oe(r):r===!0?s:s+"="+$(r)}).join(", ")}function Oe(e,t){return Array.isArray(e)?$(e[0])+Q(e[1]):$(e)+(t?Q(t):"")}function St(e){return`(${e[0].map(t=>Oe(t)).join(" ")})${Q(e[1])}`}function $(e){if(typeof e=="number")return Number.isInteger(e)?ft(e):mt(e);if(typeof e=="string")return gt(e);if(e instanceof R)return At(e);if(e instanceof ArrayBuffer)return It(e);if(e instanceof O)return Ct(e);if(e instanceof Date)return bt(e);if(typeof e=="boolean")return yt(e);throw new w(`Cannot serialize values of type ${typeof e}`)}function ft(e){if(e<-999999999999999||e>999999999999999)throw new w("Structured headers can only encode integers in the range range of -999,999,999,999,999 to 999,999,999,999,999 inclusive");return e.toString()}function mt(e){let t=e.toFixed(3).replace(/0+$/,"");if(t.split(".")[0].replace("-","").length>12)throw new w("Fractional numbers are not allowed to have more than 12 significant digits before the decimal point");return t}function gt(e){if(!re(e))throw new w("Only ASCII strings may be serialized");return`"${e.replace(/("|\\)/g,t=>"\\"+t)}"`}function Ct(e){let t='%"',i=new TextEncoder;for(let r of i.encode(e.toString()))r===37||r===34||r<=31||r>=127?t+="%"+r.toString(16):t+=String.fromCharCode(r);return t+'"'}function yt(e){return e?"?1":"?0"}function It(e){return`:${Ke(e)}:`}function At(e){return e.toString()}function bt(e){return"@"+Math.floor(e.getTime()/1e3)}function Q(e){return Array.from(e).map(([t,i])=>{let r=";"+xe(t);return i!==!0&&(r+="="+$(i)),r}).join("")}function xe(e){if(!Ne(e))throw new w("Keys in dictionaries must only contain lowercase letter, numbers, _-*. and must start with a letter or *");return e}var Be=async e=>{let{request:t,authenticationType:i,accessKey:r,secretKey:s,creationDate:o}=e,d={key_ops:["sign","verify"],ext:!0,kty:"oct",k:s,alg:"HS256"},c=await(await j()).subtle.importKey("jwk",d,{name:"HMAC",hash:"SHA-256"},!0,["sign","verify"]),a=new Map,u=new Map;a.set(i,c),u.set(i,[["x-timestamp","@authority","content-type","content-digest","content-length"],{keyid:r,created:o,alg:"hmac-sha256"}]);let S=Te(u);Ie(t,"Signature-Input",S);let n=new Ee(t),p=(n.isRequest()?n.requestSignatureInput:n.responseSignatureInput)?.keys();if(!p)throw new Error("signaturesEntries is undefined");let f=new Map,y=new Map;for(let I of p){let N=n.generate(I),l=a.get(I);if(!l)throw new Error(`key not found: ${I}`);y.set(I,N),f.set(I,[se(await Pe(l,N,{hash:"SHA-256",ec:"DSA"})),new Map])}let W=Re(f);return{signatureInputHeader:S,signatureHeader:W}};function _e(e){return{async onRequest({request:t}){let i=t.clone(),r=i.url,s=await i.arrayBuffer()??JSON.stringify({}),o=i.method??"POST",d=await X.generateDigestHeaders({body:s}),c={headers:{"X-Timestamp":Date.now().toString(),Host:new URL(r).host,"Content-Type":i.headers.get("Content-Type")??"application/json","Content-Length":i.headers.get("Content-Length")??s.byteLength.toString(),Digest:d.digest,"Content-Digest":d.contentDigest},body:s.toString(),method:o,url:r},{signatureHeader:a,signatureInputHeader:u}=await X.generateSignatureHeader({request:c,authenticationType:"team",accessKey:e.accessKey,secretKey:Buffer.from(e.secretKey,"hex").toString("base64"),creationDate:Math.floor(Date.now()/1e3)});return t.headers.set("Signature",a),t.headers.set("Signature-Input",u),t.headers.set("X-Timestamp",c.headers["X-Timestamp"]),t.headers.set("Content-Type",c.headers["Content-Type"]),t.headers.set("Digest",c.headers.Digest),t.headers.set("Content-Digest",c.headers["Content-Digest"]),t}}}var g=class extends Error{statusCode;code;constructor(t,i,r){super(t),this.statusCode=i,this.code=r,this.name="SubnotoError"}};function Xe(e){return{async onRequest({request:t}){if(!t.url.includes("/tunnel/")&&!t.url.includes("/public/")||t.url.includes("/tunnel/session"))return t;try{await e.ensureSession();let i=t.clone(),r=Buffer.from(await i.arrayBuffer());if(!r||r.byteLength===0)throw new g("EMPTY_REQUEST_BODY");let s=e.encryptRequest(r);if(!s||s.byteLength===0)throw new g("Empty encrypted message");let o=e.getSessionId();if(!o)throw new g("Session ID not available");let d=new Headers(i.headers);d.set("X-Session-Id",o);let c=i.headers.get("Content-Type");c&&c.includes("multipart/form-data")&&d.set("X-Original-Content-Type",c),d.set("Content-Type","application/octet-stream"),d.set("Content-Length",s.byteLength.toString());let a=await e.getCookies(i.url);return a&&d.set("Cookie",a),new Request(i.url,{method:i.method,headers:d,body:s,mode:i.mode,credentials:i.credentials,cache:i.cache,redirect:i.redirect,referrer:i.referrer,referrerPolicy:i.referrerPolicy,integrity:i.integrity,keepalive:i.keepalive})}catch(i){throw console.error(`Error in tunnel middleware for ${t.url}:`,i),i}},async onResponse({response:t,request:i}){if(!i.url.includes("/tunnel/")&&!i.url.includes("/public/")||i.url.includes("/tunnel/session"))return t;try{if(!(t.headers.get("x-subnoto-encrypted-response")?.includes("true")&&t.headers.get("content-type")?.includes("application/octet-stream")))return t;let s=t.clone(),o=Buffer.from(await s.arrayBuffer());if(o.byteLength===0)throw new g("Empty encrypted response");let d=e.decryptResponse(o),c=new Headers(t.headers);return c.get("x-subnoto-content-type-response")?.includes("application/octet-stream")?(c.set("Content-Type","application/octet-stream"),c.delete("x-subnoto-encrypted-response"),new Response(d,{status:t.status,statusText:t.statusText,headers:c})):(c.set("Content-Type","application/json"),c.delete("x-subnoto-encrypted-response"),c.delete("x-subnoto-content-type-response"),new Response(d,{status:t.status,statusText:t.statusText,headers:c}))}catch(r){throw console.error(`Error decrypting response for ${i.url}:`,r),r}}}}var ne={};de(ne,{PutIncomingMessageResult:()=>wt,WasmClientSession:()=>v,__wbg___wbindgen_is_function_ee8a6c5833c90377:()=>Dt,__wbg___wbindgen_is_object_c818261d21f283a4:()=>Mt,__wbg___wbindgen_is_string_fbb76cb2940daafd:()=>vt,__wbg___wbindgen_is_undefined_2d472862bd29a478:()=>Nt,__wbg___wbindgen_throw_b855445ff6a94295:()=>kt,__wbg_call_525440f72fbfc0ea:()=>Kt,__wbg_call_e762c39fa8ea36bf:()=>Rt,__wbg_crypto_86f2631e91b51511:()=>Ot,__wbg_getRandomValues_b3f15fcbfabb0f8b:()=>xt,__wbg_length_69bca3cb64fc8748:()=>Bt,__wbg_msCrypto_d562bbe83e0d4b91:()=>_t,__wbg_new_no_args_ee98eee5275000a4:()=>Xt,__wbg_new_with_length_01aa0dc35aa13543:()=>Ft,__wbg_node_e1f24f89a7336c2e:()=>Ht,__wbg_now_793306c526e2e3b6:()=>Gt,__wbg_process_3975fd6c72f520aa:()=>Wt,__wbg_prototypesetcall_2a6620b6922694b2:()=>Ut,__wbg_randomFillSync_f8c153b79f285817:()=>qt,__wbg_require_b74f47fc2d022fd6:()=>Vt,__wbg_set_wasm:()=>Tt,__wbg_static_accessor_GLOBAL_89e1d9ac6a1b250e:()=>Lt,__wbg_static_accessor_GLOBAL_THIS_8b530f326a9e48ac:()=>zt,__wbg_static_accessor_SELF_6fdf4b64710cc91b:()=>jt,__wbg_static_accessor_WINDOW_b45bfc5a37f6cfa2:()=>$t,__wbg_subarray_480600f3d6a9f26c:()=>Qt,__wbg_versions_4e31226f5e8dc909:()=>Zt,__wbindgen_cast_2241b6af4c4b2941:()=>Jt,__wbindgen_cast_cb9088102bce6b30:()=>Yt,__wbindgen_init_externref_table:()=>e1});var h,Et;function Tt(e,t){h=e,Et=t}var Z=null;function ce(){return(Z===null||Z.byteLength===0)&&(Z=new Uint8Array(h.memory.buffer)),Z}var He=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});He.decode();function Pt(e,t){return He.decode(ce().subarray(e,e+t))}function F(e,t){return e=e>>>0,Pt(e,t)}function H(e){let t=h.__externref_table_alloc();return h.__wbindgen_externrefs.set(t,e),t}function G(e,t){try{return e.apply(this,t)}catch(i){let r=H(i);h.__wbindgen_exn_store(r)}}function M(e,t){return e=e>>>0,ce().subarray(e/1,e/1+t)}function B(e){return e==null}var D=0;function x(e,t){let i=t(e.length*1,1)>>>0;return ce().set(e,i/1),D=e.length,i}function P(e){let t=h.__wbindgen_externrefs.get(e);return h.__externref_table_dealloc(e),t}var wt=Object.freeze({NoIncomingMessageExpected:0,0:"NoIncomingMessageExpected",Success:1,1:"Success"}),Fe=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>h.__wbg_wasmclientsession_free(e>>>0,1)),v=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Fe.unregister(this),t}free(){let t=this.__destroy_into_raw();h.__wbg_wasmclientsession_free(t,0)}constructor(t,i){var r=B(i)?0:x(i,h.__wbindgen_malloc),s=D;let o=h.wasmclientsession_new(B(t)?16777215:t?1:0,r,s);if(o[2])throw P(o[1]);return this.__wbg_ptr=o[0]>>>0,Fe.register(this,this.__wbg_ptr,this),this}is_open(){return h.wasmclientsession_is_open(this.__wbg_ptr)!==0}write(t){let i=x(t,h.__wbindgen_malloc),r=D,s=h.wasmclientsession_write(this.__wbg_ptr,i,r);if(s[3])throw P(s[2]);var o=M(s[0],s[1]).slice();return h.__wbindgen_free(s[0],s[1]*1,1),o}read(t){let i=x(t,h.__wbindgen_malloc),r=D,s=h.wasmclientsession_read(this.__wbg_ptr,i,r);if(s[3])throw P(s[2]);var o=M(s[0],s[1]).slice();return h.__wbindgen_free(s[0],s[1]*1,1),o}write_buffer(t){let i=x(t,h.__wbindgen_malloc),r=D,s=h.wasmclientsession_write_buffer(this.__wbg_ptr,i,r);if(s[3])throw P(s[2]);var o=M(s[0],s[1]).slice();return h.__wbindgen_free(s[0],s[1]*1,1),o}read_buffer(t){let i=x(t,h.__wbindgen_malloc),r=D,s=h.wasmclientsession_read_buffer(this.__wbg_ptr,i,r);if(s[3])throw P(s[2]);var o=M(s[0],s[1]).slice();return h.__wbindgen_free(s[0],s[1]*1,1),o}put_incoming_message(t){let i=x(t,h.__wbindgen_malloc),r=D,s=h.wasmclientsession_put_incoming_message(this.__wbg_ptr,i,r);if(s[2])throw P(s[1]);return s[0]}get_outgoing_message(){let t=h.wasmclientsession_get_outgoing_message(this.__wbg_ptr);if(t[3])throw P(t[2]);let i;return t[0]!==0&&(i=M(t[0],t[1]).slice(),h.__wbindgen_free(t[0],t[1]*1,1)),i}get_attestation_results_json(){let t=h.wasmclientsession_get_attestation_results_json(this.__wbg_ptr);if(t[3])throw P(t[2]);let i;return t[0]!==0&&(i=F(t[0],t[1]).slice(),h.__wbindgen_free(t[0],t[1]*1,1)),i}get_attestation_status(){let t,i;try{let r=h.wasmclientsession_get_attestation_status(this.__wbg_ptr);return t=r[0],i=r[1],F(r[0],r[1])}finally{h.__wbindgen_free(t,i,1)}}};Symbol.dispose&&(v.prototype[Symbol.dispose]=v.prototype.free);function Dt(e){return typeof e=="function"}function Mt(e){let t=e;return typeof t=="object"&&t!==null}function vt(e){return typeof e=="string"}function Nt(e){return e===void 0}function kt(e,t){throw new Error(F(e,t))}function Kt(){return G(function(e,t,i){return e.call(t,i)},arguments)}function Rt(){return G(function(e,t){return e.call(t)},arguments)}function Ot(e){return e.crypto}function xt(){return G(function(e,t){e.getRandomValues(t)},arguments)}function Bt(e){return e.length}function _t(e){return e.msCrypto}function Xt(e,t){return new Function(F(e,t))}function Ft(e){return new Uint8Array(e>>>0)}function Ht(e){return e.node}function Gt(){return Date.now()}function Wt(e){return e.process}function Ut(e,t,i){Uint8Array.prototype.set.call(M(e,t),i)}function qt(){return G(function(e,t){e.randomFillSync(t)},arguments)}function Vt(){return G(function(){return module.require},arguments)}function Lt(){let e=typeof global>"u"?null:global;return B(e)?0:H(e)}function zt(){let e=typeof globalThis>"u"?null:globalThis;return B(e)?0:H(e)}function jt(){let e=typeof self>"u"?null:self;return B(e)?0:H(e)}function $t(){let e=typeof window>"u"?null:window;return B(e)?0:H(e)}function Qt(e,t,i){return e.subarray(t>>>0,i>>>0)}function Zt(e){return e.versions}function Jt(e,t){return F(e,t)}function Yt(e,t){return M(e,t)}function e1(){let e=h.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)}import{readFileSync as t1}from"node:fs";var oe={};oe["./oak_session_wasm_nodejs_bg.js"]=ne;var i1=new URL("oak_session_wasm_nodejs_bg.wasm",import.meta.url),r1=t1(i1),Ge=new WebAssembly.Module(r1),We=new WebAssembly.Instance(Ge,oe).exports;oe["./oak_session_wasm_nodejs_bg.js"].__wbg_set_wasm(We,Ge);We.__wbindgen_start();import{CookieJar as s1}from"tough-cookie";var J=class{session=null;sessionId=null;config;handshakeInProgress=!1;cookieJar;constructor(t){this.config=t,this.cookieJar=new s1}async ensureSession(){if(!(this.session&&this.session.is_open())){if(this.handshakeInProgress){for(;this.handshakeInProgress;)await new Promise(t=>setTimeout(t,50));return}await this.handshake()}}async handshake(){this.handshakeInProgress=!0;try{let t=this.config.unattested??!1;this.session=new v(t,t?void 0:this.config.attesterKey);let i=4,r=0;if(!this.session)throw new g("Failed to create session");for(;!this.session.is_open()&&r<i;){r++;let s=this.session.get_outgoing_message();if(!s||this.session.is_open())break;let o=`${this.config.apiBaseUrl}/tunnel/session`,d={"Content-Type":"application/octet-stream"};this.sessionId&&(d["X-Session-Id"]=this.sessionId);let c=await this.cookieJar.getCookieString(o);c&&(d.Cookie=c);let a=await fetch(o,{method:"POST",body:s,headers:d});if(!this.sessionId){let n=a.headers.get("X-Session-Id");if(!n)throw new g("No session ID received from server");this.sessionId=n}if(!a.ok){let n=await a.text().catch(()=>"Unable to read error");throw new g(`Handshake failed with status ${a.status}: ${n}`,a.status)}let u=a.headers.getSetCookie?.()||[];for(let n of u)await this.cookieJar.setCookie(n,o);let S=await a.arrayBuffer();if(S.byteLength>0)this.session.put_incoming_message(Buffer.from(S));else throw new g("Empty response from server during handshake")}if(!this.session.is_open()||!this.sessionId)throw new g("Failed to establish session after handshake")}finally{this.handshakeInProgress=!1}}encryptRequest(t){if(!this.session||!this.session.is_open())throw new g("Session not open");try{let i=typeof t=="string"?Buffer.from(t,"utf-8"):t,r=this.session.write(i);return Buffer.from(r)}catch(i){throw new g(`Encryption failed: ${i instanceof Error?i.message:"Unknown error"}`)}}decryptResponse(t){if(!this.session||!this.session.is_open())throw new g("Session not open");try{let i=Buffer.isBuffer(t)?t:Buffer.from(t),r=this.session.read(i);return Buffer.from(r)}catch(i){throw new g(`Decryption failed: ${i instanceof Error?i.message:"Unknown error"}`)}}getSessionId(){return this.sessionId}getCookies(t){return this.cookieJar.getCookieString(t)}destroy(){this.session=null,this.sessionId=null}getAttestationResults(){return this.session?this.session.get_attestation_results_json()??null:null}getAttestationStatus(){return this.session?this.session.get_attestation_status()??null:null}};function Ue(e){let t=c1({baseUrl:e.apiBaseUrl}),i=new J(e);return t.use(Xe(i)),t.use(_e({accessKey:e.accessKey,secretKey:e.secretKey})),{client:t,sessionManager:i}}async function qe(e,t){let{workspaceUuid:i,fileBuffer:r,envelopeTitle:s}=t,o=new Blob([new Uint8Array(r)],{type:"application/pdf"}),d=await e.POST("/public/envelope/create-from-file",{body:{workspaceUuid:i,envelopeTitle:s,file:o},bodySerializer:c=>{let a=new FormData;return a.append("workspaceUuid",c.workspaceUuid),a.append("envelopeTitle",c.envelopeTitle),a.append("file",c.file,"document.pdf"),a}});if(d.error)throw new g(`Failed to upload document: ${JSON.stringify(d.error)}`,d.response?.status,typeof d.error=="object"&&"code"in d.error?String(d.error.code):void 0);return{envelopeUuid:d.data.envelopeUuid,documentUuid:d.data.documentUuid}}var ae=class{client;sessionManager;constructor(t){let{client:i,sessionManager:r}=Ue(t);this.client=i,this.sessionManager=r}get GET(){return this.client.GET}get POST(){return this.client.POST}get PUT(){return this.client.PUT}get DELETE(){return this.client.DELETE}get PATCH(){return this.client.PATCH}uploadDocument(t){return qe(this,t)}getAttestationStatus(){let t=this.sessionManager.getAttestationStatus();return t?JSON.parse(t):null}getAttestationResults(){let t=this.sessionManager.getAttestationResults();return t?JSON.parse(t):null}};export{ae as SubnotoClient,g as SubnotoError};
@@ -294,12 +294,12 @@ export function __wbg_call_e762c39fa8ea36bf() { return handleError(function (arg
294
294
  return ret;
295
295
  }, arguments) };
296
296
 
297
- export function __wbg_crypto_574e78ad8b13b65f(arg0) {
297
+ export function __wbg_crypto_86f2631e91b51511(arg0) {
298
298
  const ret = arg0.crypto;
299
299
  return ret;
300
300
  };
301
301
 
302
- export function __wbg_getRandomValues_b8f5dbd5f3995a9e() { return handleError(function (arg0, arg1) {
302
+ export function __wbg_getRandomValues_b3f15fcbfabb0f8b() { return handleError(function (arg0, arg1) {
303
303
  arg0.getRandomValues(arg1);
304
304
  }, arguments) };
305
305
 
@@ -308,7 +308,7 @@ export function __wbg_length_69bca3cb64fc8748(arg0) {
308
308
  return ret;
309
309
  };
310
310
 
311
- export function __wbg_msCrypto_a61aeb35a24c1329(arg0) {
311
+ export function __wbg_msCrypto_d562bbe83e0d4b91(arg0) {
312
312
  const ret = arg0.msCrypto;
313
313
  return ret;
314
314
  };
@@ -323,7 +323,7 @@ export function __wbg_new_with_length_01aa0dc35aa13543(arg0) {
323
323
  return ret;
324
324
  };
325
325
 
326
- export function __wbg_node_905d3e251edff8a2(arg0) {
326
+ export function __wbg_node_e1f24f89a7336c2e(arg0) {
327
327
  const ret = arg0.node;
328
328
  return ret;
329
329
  };
@@ -333,7 +333,7 @@ export function __wbg_now_793306c526e2e3b6() {
333
333
  return ret;
334
334
  };
335
335
 
336
- export function __wbg_process_dc0fbacc7c1c06f7(arg0) {
336
+ export function __wbg_process_3975fd6c72f520aa(arg0) {
337
337
  const ret = arg0.process;
338
338
  return ret;
339
339
  };
@@ -342,11 +342,11 @@ export function __wbg_prototypesetcall_2a6620b6922694b2(arg0, arg1, arg2) {
342
342
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
343
343
  };
344
344
 
345
- export function __wbg_randomFillSync_ac0988aba3254290() { return handleError(function (arg0, arg1) {
345
+ export function __wbg_randomFillSync_f8c153b79f285817() { return handleError(function (arg0, arg1) {
346
346
  arg0.randomFillSync(arg1);
347
347
  }, arguments) };
348
348
 
349
- export function __wbg_require_60cc747a6bc5215a() { return handleError(function () {
349
+ export function __wbg_require_b74f47fc2d022fd6() { return handleError(function () {
350
350
  const ret = module.require;
351
351
  return ret;
352
352
  }, arguments) };
@@ -376,7 +376,7 @@ export function __wbg_subarray_480600f3d6a9f26c(arg0, arg1, arg2) {
376
376
  return ret;
377
377
  };
378
378
 
379
- export function __wbg_versions_c01dfd4722a88165(arg0) {
379
+ export function __wbg_versions_4e31226f5e8dc909(arg0) {
380
380
  const ret = arg0.versions;
381
381
  return ret;
382
382
  };
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@subnoto/api-client",
3
3
  "private": false,
4
- "version": "2.3.10",
4
+ "version": "2.4.0",
5
5
  "description": "TypeScript SDK for Subnoto Public API",
6
6
  "author": "Subnoto",
7
7
  "homepage": "https://subnoto.com",
@@ -46,7 +46,7 @@ export interface paths {
46
46
  * @description The language of the contact.
47
47
  * @enum {string}
48
48
  */
49
- language?: "fr" | "en";
49
+ language?: "en" | "fr" | "es" | "it" | "fi";
50
50
  /** @description The job title of the contact. */
51
51
  jobTitle?: string;
52
52
  /** @description The company of the contact. */
@@ -89,7 +89,7 @@ export interface paths {
89
89
  * @description The language of the contact.
90
90
  * @enum {string}
91
91
  */
92
- language?: "fr" | "en";
92
+ language?: "en" | "fr" | "es" | "it" | "fi";
93
93
  /** @description The job title of the contact. */
94
94
  jobTitle?: string;
95
95
  /** @description The company of the contact. */
@@ -292,7 +292,7 @@ export interface paths {
292
292
  * @description The language of the contact.
293
293
  * @enum {string}
294
294
  */
295
- language?: "fr" | "en";
295
+ language?: "en" | "fr" | "es" | "it" | "fi";
296
296
  /** @description The job title of the contact. */
297
297
  jobTitle?: string;
298
298
  /** @description The company of the contact. */
@@ -668,7 +668,7 @@ export interface paths {
668
668
  * @description The language of the contact.
669
669
  * @enum {string}
670
670
  */
671
- language?: "fr" | "en";
671
+ language?: "en" | "fr" | "es" | "it" | "fi";
672
672
  /** @description The job title of the contact. */
673
673
  jobTitle?: string;
674
674
  /** @description The company of the contact. */
@@ -857,7 +857,7 @@ export interface paths {
857
857
  * @description The language of the contact.
858
858
  * @enum {string}
859
859
  */
860
- language?: "fr" | "en";
860
+ language?: "en" | "fr" | "es" | "it" | "fi";
861
861
  /** @description The job title of the contact. */
862
862
  jobTitle?: string;
863
863
  /** @description The company of the contact. */
@@ -899,7 +899,7 @@ export interface paths {
899
899
  * @description The language of the contact.
900
900
  * @enum {string}
901
901
  */
902
- language?: "fr" | "en";
902
+ language?: "en" | "fr" | "es" | "it" | "fi";
903
903
  /** @description The job title of the contact. */
904
904
  jobTitle?: string;
905
905
  /** @description The company of the contact. */
@@ -1539,7 +1539,7 @@ export interface paths {
1539
1539
  * @description The language for the recipient (e.g., 'en', 'fr').
1540
1540
  * @enum {string}
1541
1541
  */
1542
- language?: "en" | "fr";
1542
+ language?: "en" | "fr" | "es" | "it" | "fi";
1543
1543
  /**
1544
1544
  * @description The verification type for the recipient.
1545
1545
  * @enum {string}
@@ -1554,7 +1554,7 @@ export interface paths {
1554
1554
  * @description The language for the recipient (e.g., 'en', 'fr').
1555
1555
  * @enum {string}
1556
1556
  */
1557
- language?: "en" | "fr";
1557
+ language?: "en" | "fr" | "es" | "it" | "fi";
1558
1558
  /**
1559
1559
  * @description The verification type for the recipient.
1560
1560
  * @enum {string}
@@ -1569,7 +1569,7 @@ export interface paths {
1569
1569
  * @description The language for the recipient (e.g., 'en', 'fr').
1570
1570
  * @enum {string}
1571
1571
  */
1572
- language?: "en" | "fr";
1572
+ language?: "en" | "fr" | "es" | "it" | "fi";
1573
1573
  /**
1574
1574
  * @description The verification type for the recipient.
1575
1575
  * @enum {string}
@@ -3037,7 +3037,7 @@ export interface paths {
3037
3037
  envelopeUuid: string;
3038
3038
  /**
3039
3039
  * Format: email
3040
- * @description The email of the recipient who is signing.
3040
+ * @description The email of the recipient who is signing. Must match the API key owner's email.
3041
3041
  */
3042
3042
  recipientEmail: string;
3043
3043
  /** @description Base64 encoded signature image to be merged with the watermark. */
@@ -3076,7 +3076,7 @@ export interface paths {
3076
3076
  * @description The error code
3077
3077
  * @enum {string}
3078
3078
  */
3079
- code: "WORKSPACE_NOT_FOUND" | "INVALID_TOKEN" | "ENVELOPE_INVITATION_EXPIRED" | "ENVELOPE_INVITATION_NOT_PENDING" | "ENVELOPE_NOT_FOUND" | "DOCUMENT_NOT_FOUND" | "DOCUMENT_REVISION_NOT_FOUND" | "ENVELOPE_ALREADY_SIGNED" | "INVALID_REQUEST_FORMAT";
3079
+ code: "WORKSPACE_NOT_FOUND" | "INVALID_TOKEN" | "ENVELOPE_INVITATION_EXPIRED" | "ENVELOPE_INVITATION_NOT_PENDING" | "ENVELOPE_NOT_FOUND" | "DOCUMENT_NOT_FOUND" | "DOCUMENT_REVISION_NOT_FOUND" | "ENVELOPE_ALREADY_SIGNED" | "RECIPIENT_EMAIL_MISMATCH" | "INVALID_REQUEST_FORMAT";
3080
3080
  /** @description The error message */
3081
3081
  message: string;
3082
3082
  /** @description A suggestion to resolve the error */