space-data-module-sdk 0.9.8 → 0.9.10
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/docs/_shell/consumer-assets.html +3 -3
- package/docs/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-callback.0f2dee485c8f0d7afe5f70b4b42093a382c92d32af551bd71b41733336091c7a.js +1 -0
- package/docs/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.9ab041131df957fcb6ef7e3d87bf9d19fe313bc5d7f1e53337752faf0ba354da.js +1 -0
- package/docs/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.c3f68d1cfd88478f10d836a5e829d1dfc6a10157972cf0f7d4d319d0636f2cc4.css +32 -0
- package/docs/assets/vendor/sdn-stack-nav/1.0.1/sdn-stack-nav.24eb3001afc5448a90cef87e53bb4e599c0ae4dc9e14bafb6d1236e0233c6008.js +283 -0
- package/docs/assets/vendor/sdn-stack-nav/1.0.1/sdn-stack-nav.36a36359ce18322185e9ff179f88175bab67d5ad84a14d9c08a54f2ff27267e7.css +118 -0
- package/docs/browser-wasmedge-isomorphic.html +3 -3
- package/docs/byo-wasm-quickstart.html +3 -3
- package/docs/conformance.html +3 -3
- package/docs/events-abi.html +4 -4
- package/docs/events-abi.md +1 -1
- package/docs/families/analytics.html +3 -3
- package/docs/families/attitude.html +3 -3
- package/docs/families/behavior.html +3 -3
- package/docs/families/breakup.html +3 -3
- package/docs/families/conjunction.html +3 -3
- package/docs/families/data-source.html +3 -3
- package/docs/families/effects.html +3 -3
- package/docs/families/environment.html +3 -3
- package/docs/families/estimation.html +3 -3
- package/docs/families/gnc.html +3 -3
- package/docs/families/maneuver.html +3 -3
- package/docs/families/obstruction.html +3 -3
- package/docs/families/propagator.html +3 -3
- package/docs/families/propulsion.html +3 -3
- package/docs/families/reentry.html +3 -3
- package/docs/families/rf.html +3 -3
- package/docs/families/scheduler.html +3 -3
- package/docs/families/sensor.html +3 -3
- package/docs/families/signature.html +3 -3
- package/docs/flatsql-host-contract.html +3 -3
- package/docs/flatsql-streaming-standard.html +3 -3
- package/docs/gpu-module-abi.html +3 -3
- package/docs/index.html +3 -3
- package/docs/isomorphic-pthreads.html +3 -3
- package/docs/isomorphic-sdn-runtime-plan.html +3 -3
- package/docs/language-runtime-matrix.html +3 -3
- package/docs/module-bundle-runtime-plan.html +3 -3
- package/docs/module-publication-standard.html +3 -3
- package/docs/node-red-default-node-parity.html +3 -3
- package/docs/protect-and-sign.html +3 -3
- package/docs/protocol-installation.html +3 -3
- package/docs/publication-submission.html +3 -3
- package/docs/secrets-capability.html +3 -3
- package/docs/testing-harness.html +3 -3
- package/docs/tri-runtime-parity-gate.html +3 -3
- package/docs/tri-runtime-parity.html +3 -3
- package/docs/wallet-callback.html +1 -1
- package/package.json +1 -1
- package/schemas/orbpro/Propagator.fbs +4 -4
- package/schemas/orbpro/reference-frame-crosswalk.json +4 -4
- package/src/compiler/compileModule.js +51 -2
- package/src/flow/flowCompiler.js +1 -1
- package/src/flow/flowRuntimeHost.js +2 -2
- package/src/host/abi.js +2 -3
- package/src/host/hostWorkerBundleSources.js +3 -3
- package/src/host/hostcallWire.js +3 -2
- package/src/host/providerAccess.js +2 -3
- package/src/host/typedDispatch.js +2 -2
- package/src/host/wasiShim.js +5 -1
- package/src/runtime-host/flatsqlRuntimeStore.js +2 -2
- package/src/testing/headlessShell.js +80 -0
- package/src/testing/parityGate.js +17 -28
- package/src/testing/parityLanes.js +4 -22
- package/src/utils/guestText.js +12 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<!-- SDN_CONSUMER_ASSETS_START -->
|
|
2
|
-
<link rel="stylesheet" href="
|
|
3
|
-
<script defer src="
|
|
4
|
-
<script defer src="
|
|
2
|
+
<link rel="stylesheet" href="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.c3f68d1cfd88478f10d836a5e829d1dfc6a10157972cf0f7d4d319d0636f2cc4.css" integrity="sha384-fICuhN4I9xqOK1F5vGGzl26opuO+xQIvTZXMSV76lWTBiQ6AfzztMGLLDw8yRT8i" crossorigin="anonymous">
|
|
3
|
+
<script defer src="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.9ab041131df957fcb6ef7e3d87bf9d19fe313bc5d7f1e53337752faf0ba354da.js" integrity="sha384-FNcHq8FI7eBz2YUhfO3jNfmdObbCXmfg4ugmBEHzXW/KBpbUdJXqIzpn30OWJBuB" crossorigin="anonymous" data-sdn-wallet-public-client="v1"></script>
|
|
4
|
+
<script defer src="/space-data-module-sdk/assets/vendor/sdn-stack-nav/1.0.1/sdn-stack-nav.24eb3001afc5448a90cef87e53bb4e599c0ae4dc9e14bafb6d1236e0233c6008.js" integrity="sha384-g8NCFtcgbsW5bHeGiPtPb2Q+NJVlJLfwbaAZ7/Ium1YAVtxE/SqawvG/Ny0iMl56" crossorigin="anonymous" data-nav-style-url="/space-data-module-sdk/assets/vendor/sdn-stack-nav/1.0.1/sdn-stack-nav.36a36359ce18322185e9ff179f88175bab67d5ad84a14d9c08a54f2ff27267e7.css" data-nav-style-integrity="sha384-c4M8Fg+kYaeOYYtJVr7jJsde24IhSWkWaRyAOHEZU9jozhRck089aw+mnHwxymds" data-wallet-client-url="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.9ab041131df957fcb6ef7e3d87bf9d19fe313bc5d7f1e53337752faf0ba354da.js" data-wallet-client-integrity="sha384-FNcHq8FI7eBz2YUhfO3jNfmdObbCXmfg4ugmBEHzXW/KBpbUdJXqIzpn30OWJBuB" data-wallet-style-url="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.c3f68d1cfd88478f10d836a5e829d1dfc6a10157972cf0f7d4d319d0636f2cc4.css" data-wallet-style-integrity="sha384-fICuhN4I9xqOK1F5vGGzl26opuO+xQIvTZXMSV76lWTBiQ6AfzztMGLLDw8yRT8i" data-wallet-client-id="sdn-module-sdk-pages-v1" data-wallet-callback-uri="https://digitalarsenal.github.io/space-data-module-sdk/wallet-callback.html" data-wallet-registry-sha256="63784143e2ad8e2542d22148ff4a0a4da7a10f4b3f9909ae91a20dc0f60db06b"></script>
|
|
5
5
|
<!-- SDN_CONSUMER_ASSETS_END -->
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){"use strict";const l="Wallet return could not be completed. Close this page and try Login again.",h=/^#code=([0-9a-f]{64})&state=([0-9a-f]{64})$/u;function a(){throw new Error(l)}function w(t,e,o,c){let n;try{n=t.hash;const g=typeof t.pathname=="string"&&t.pathname.startsWith("/")?t.pathname:"/",S=typeof t.search=="string"&&t.search.startsWith("?")?t.search:"";o.replaceState(null,"",`${g}${S}`)}catch{a()}const r=h.exec(n);r||a();const[,f,i]=r,m=new Date(Date.now()+12e4).toISOString(),y=`sdn.wallet.callback.v1:${i}`,u=JSON.stringify({schemaVersion:1,code:f,state:i,expiresAt:m});try{e.setItem(y,u)}catch{a()}try{c()}catch{}}const d="Wallet return could not be completed. Close this page and try Login again.";function s(){window.document?.body&&(window.document.body.textContent=d)}function p(){const t=typeof window.location?.pathname=="string"&&window.location.pathname.startsWith("/")?window.location.pathname:"/",e=typeof window.location?.search=="string"&&window.location.search.startsWith("?")?window.location.search:"";window.history.replaceState(null,"",`${t}${e}`)}if(window.top!==window){try{p()}catch{}s()}else{let t=!1;const e=()=>{if(!t){t=!0;try{window.close()}catch{}}};try{const o={setItem(c,n){window.localStorage.setItem(c,n)}};w(window.location,o,window.history,e)}catch{s()}}})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){"use strict";const xe=Object.freeze({cm:.01,km:1e3,m:1,mm:.001}),Ce=Object.freeze({metersPerSourceUnit:xe,quaternionNormTolerance:1e-6,scaleComponentExclusiveMin:0,scaleComponentInclusiveMax:1e6,translationComponentAbsMax:1e6,upAxes:Object.freeze(["X_UP","Y_UP","Z_UP"])}),Pe=Object.freeze({reviewedTransform:Ce,schemaVersion:1}),k=new TextEncoder,Z=Object.getPrototypeOf(Uint8Array.prototype);Object.getOwnPropertyDescriptor(Z,"buffer").get,Object.getOwnPropertyDescriptor(Z,"length").get,Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,"byteLength").get,typeof SharedArrayBuffer>"u"||Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype,"byteLength").get;const B="sdn-bip32-slip10-purpose-v1",$="password-scrypt-v2",G="ed25519-over-sha256-jcs-v1",Ne=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/u,U=/^[0-9a-f]{64}$/u,ge=/^sha256:[0-9a-f]{64}$/u,De=/^[1-9A-HJ-NP-Za-km-z]+$/u,je=131072,ke=["accountFingerprint","accountIndex","accountLabel","accountPeerId","accountXpub","identityScheme","keys","schemaVersion","seedProfile"],Be=["bip32Fingerprint","curve","derivation","encoding","identityScheme","keyId","path","publicKeyHex","purpose","seedProfile","signatureProfile"],$e=["connectionExpiresAt","event","identity","schemaVersion"];function u(r){throw new TypeError(r)}function ee(r){if(r===null||typeof r!="object"||Array.isArray(r))return!1;const e=Object.getPrototypeOf(r);return e===Object.prototype||e===null}function v(r,e){typeof r!="string"&&u(`${e} must be a string`);for(let t=0;t<r.length;t+=1){const s=r.charCodeAt(t);let i=s;if(s>=55296&&s<=56319){const o=r.charCodeAt(t+1);o>=56320&&o<=57343||u(`${e} contains an unpaired surrogate`),i=65536+(s-55296<<10)+(o-56320),t+=1}else s>=56320&&s<=57343&&u(`${e} contains an unpaired surrogate`);((i&65535)===65534||(i&65535)===65535||i>=64976&&i<=65007)&&u(`${e} contains a Unicode noncharacter`)}return r}function Ue(r){typeof r!="string"&&u("wire JSON must be a string"),k.encode(r).byteLength>je&&u("wire JSON is too large"),r.charCodeAt(0)===65279&&u("wire JSON must not contain a BOM");let e=0,t=0;const s=()=>{for(;e<r.length&&/[\u0009\u000a\u000d\u0020]/u.test(r[e]);)e+=1},i=()=>{r[e]!=='"'&&u("invalid JSON string");const a=e;for(e+=1;e<r.length;){const l=r.charCodeAt(e);if(l===34){e+=1;let f;try{f=JSON.parse(r.slice(a,e))}catch{u("invalid JSON string")}return v(f,"JSON string")}l<32&&u("invalid JSON control character"),l===92&&(e+=1,e>=r.length&&u("unterminated JSON escape")),e+=1}u("unterminated JSON string")},o=(a=0)=>{a>32&&u("wire JSON nesting is too deep"),t+=1,t>4096&&u("wire JSON contains too many values"),s();const l=r[e];if(l==='"')return i();if(l==="{"){e+=1;const d=Object.create(null),y=new Set;if(s(),r[e]==="}")return e+=1,d;for(;e<r.length;){s();const m=i();if(y.has(m)&&u(`duplicate JSON field: ${m}`),y.add(m),s(),r[e]!==":"&&u("missing JSON object colon"),e+=1,d[m]=o(a+1),s(),r[e]==="}")return e+=1,d;r[e]!==","&&u("invalid JSON object separator"),e+=1}u("unterminated JSON object")}if(l==="["){e+=1;const d=[];if(s(),r[e]==="]")return e+=1,d;for(;e<r.length;){if(d.push(o(a+1)),s(),r[e]==="]")return e+=1,d;r[e]!==","&&u("invalid JSON array separator"),e+=1}u("unterminated JSON array")}for(const[d,y]of[["true",!0],["false",!1],["null",null]])if(r.startsWith(d,e))return e+=d.length,y;const f=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/u.exec(r.slice(e));f||u("invalid JSON value"),e+=f[0].length;const h=Number(f[0]);return Number.isFinite(h)||u("wire JSON number must be finite"),h};s();const n=o();return s(),e!==r.length&&u("wire JSON contains trailing bytes"),n}function Me(r){return typeof r=="string"?Ue(r):r}function Ve(r,e){if(r.byteLength!==e.byteLength)return!1;let t=0;for(let s=0;s<r.byteLength;s+=1)t|=r[s]^e[s];return t===0}function R(r,e,t){const s=Me(r);ee(s)||u(`${t} must be a JSON object`),Object.getOwnPropertySymbols(s).length!==0&&u(`${t} has an unknown symbol field`);const i=Object.getOwnPropertyNames(s).sort(),o=[...e].sort(),n=k.encode(i.join("\0")),a=k.encode(o.join("\0"));Ve(n,a)||u(`${t} has missing or unknown fields`);for(const l of i){const f=Object.getOwnPropertyDescriptor(s,l);(!f||!f.enumerable||!("value"in f))&&u(`${t}.${l} must be an enumerable data field`),f.value===void 0&&u(`${t}.${l} must not be undefined`)}return s}function L(r){if(!r||typeof r!="object"||Object.isFrozen(r))return r;for(const e of Object.values(r))L(e);return Object.freeze(r)}function b(r){return L(Object.fromEntries([...r].sort(([e],[t])=>e<t?-1:e>t?1:0)))}function x(r,e,t){(!Array.isArray(r)||Object.getPrototypeOf(r)!==Array.prototype||r.length!==e)&&u(`${t} must be a plain array with exactly ${e} values`);const s=[...Array.from({length:e},(o,n)=>String(n)),"length"],i=Reflect.ownKeys(r);(i.length!==s.length||i.some((o,n)=>o!==s[n]))&&u(`${t} must be a dense plain array`);for(let o=0;o<e;o+=1){const n=Object.getOwnPropertyDescriptor(r,String(o));(!n||!n.enumerable||!("value"in n)||n.value===void 0)&&u(`${t} must contain enumerable data values`)}}function Ye(r){const e=R(r,["reviewedTransform","schemaVersion"],"asset review protocol policy");p(e.schemaVersion,1,"asset review protocol schemaVersion");const t=R(e.reviewedTransform,["metersPerSourceUnit","quaternionNormTolerance","scaleComponentExclusiveMin","scaleComponentInclusiveMax","translationComponentAbsMax","upAxes"],"asset review transform policy"),s=R(t.metersPerSourceUnit,["cm","km","m","mm"],"asset review unit policy");for(const[i,o]of Object.entries(s))(typeof o!="number"||!Number.isFinite(o)||o<=0)&&u(`asset review unit policy ${i} must be positive and finite`);for(const[i,o]of[["quaternionNormTolerance",t.quaternionNormTolerance],["scaleComponentExclusiveMin",t.scaleComponentExclusiveMin],["scaleComponentInclusiveMax",t.scaleComponentInclusiveMax],["translationComponentAbsMax",t.translationComponentAbsMax]])(typeof o!="number"||!Number.isFinite(o))&&u(`asset review transform policy ${i} must be finite`);return(t.quaternionNormTolerance<=0||t.scaleComponentInclusiveMax<=t.scaleComponentExclusiveMin||t.translationComponentAbsMax<=0)&&u("asset review transform policy bounds are inconsistent"),x(t.upAxes,3,"asset review up-axis policy"),t.upAxes.join("\0")!=="X_UP\0Y_UP\0Z_UP"&&u("asset review up-axis policy is invalid"),b([["metersPerSourceUnit",b(Object.entries(s))],["quaternionNormTolerance",t.quaternionNormTolerance],["scaleComponentExclusiveMin",t.scaleComponentExclusiveMin],["scaleComponentInclusiveMax",t.scaleComponentInclusiveMax],["translationComponentAbsMax",t.translationComponentAbsMax],["upAxes",Object.freeze(Array.from({length:3},(i,o)=>t.upAxes[o]))]])}Ye(Pe);function p(r,e,t){return r!==e&&u(`${t} must equal ${JSON.stringify(e)}`),r}function Fe(r,e,t){return e.includes(r)||u(`${t} is not an allowed value`),r}function T(r,e,t){return v(r,t),e.test(r)||u(`${t} has an invalid encoding`),r}function Ke(r,e){return v(r,e),(!Ne.test(r)||new Date(r).toISOString()!==r)&&u(`${e} must be exact RFC3339 milliseconds UTC`),r}function qe(r,e){const t=R(r,Be,`identity key ${e.purpose}`);return p(t.purpose,e.purpose,"key purpose"),p(t.identityScheme,B,"key identityScheme"),p(t.seedProfile,$,"key seedProfile"),p(t.signatureProfile,e.signatureProfile,"key signatureProfile"),p(t.curve,e.curve,"key curve"),p(t.derivation,"slip10","key derivation"),p(t.path,e.path,"key path"),p(t.encoding,"raw","key encoding"),T(t.publicKeyHex,U,"key publicKeyHex"),p(t.bip32Fingerprint,null,"key bip32Fingerprint"),T(t.keyId,ge,"key keyId"),b([["bip32Fingerprint",null],["curve",t.curve],["derivation","slip10"],["encoding","raw"],["identityScheme",B],["keyId",t.keyId],["path",t.path],["publicKeyHex",t.publicKeyHex],["purpose",t.purpose],["seedProfile",$],["signatureProfile",t.signatureProfile]])}function ze(r){const e=R(r,ke,"WalletPublicIdentity");p(e.schemaVersion,1,"identity schemaVersion"),p(e.identityScheme,B,"identity identityScheme"),p(e.seedProfile,$,"identity seedProfile"),e.accountIndex!==0&&u("public wallet identity must use account 0"),p(e.accountLabel,null,"identity accountLabel"),v(e.accountXpub,"identity accountXpub"),/^xpub[1-9A-HJ-NP-Za-km-z]{107}$/u.test(e.accountXpub)||u("identity accountXpub is invalid"),v(e.accountPeerId,"identity accountPeerId"),(!e.accountPeerId.startsWith("16Uiu2H")||e.accountPeerId.length<40||e.accountPeerId.length>64||!De.test(e.accountPeerId))&&u("identity accountPeerId is invalid"),T(e.accountFingerprint,/^[0-9a-f]{8}$/u,"identity accountFingerprint"),x(e.keys,3,"public identity keys array");const t=[{purpose:"asset-review-approval",curve:"ed25519",signatureProfile:G,path:"m/44'/0'/0'/2'/0'"},{purpose:"contact-encryption",curve:"x25519",signatureProfile:null,path:"m/44'/0'/0'/1'/0'"},{purpose:"sdn-authentication",curve:"ed25519",signatureProfile:G,path:"m/44'/0'/0'/0'/0'"}],s=Array.from({length:3},(i,o)=>qe(e.keys[o],t[o]));return b([["accountFingerprint",e.accountFingerprint],["accountIndex",0],["accountLabel",null],["accountPeerId",e.accountPeerId],["accountXpub",e.accountXpub],["identityScheme",B],["keys",L(s)],["schemaVersion",1],["seedProfile",$]])}function te(r,e){const t=R(r,$e,`${e} result`);p(t.schemaVersion,1,"connection result schemaVersion"),Fe(t.event,["connected","disconnected"],"connection event"),e==="connect"&&t.event!=="connected"&&u("connect result must be connected");let s=null,i=null;return t.event==="connected"?(s=ze(t.identity),i=Ke(t.connectionExpiresAt,"connectionExpiresAt")):(t.identity!==null||t.connectionExpiresAt!==null)&&u("disconnected result must clear identity and expiry"),b([["connectionExpiresAt",i],["event",t.event],["identity",s],["schemaVersion",1]])}function re(r,e){return R(r,[],e),L({})}function He(r={}){return re(r,"wallet connect request")}function Je(r){return te(r,"connect")}function We(r={}){return re(r,"wallet account request")}function Xe(r){return te(r,"account")}const E=Object.freeze({envelopeBytes:512,fieldBytes:4096,batchBytes:12288,fields:16,contextBytes:256}),Qe=/^sdn-field-encryption\/v1\|[A-Za-z0-9_.-]{1,64}\|[A-Za-z0-9_.-]{1,64}\|[A-Za-z0-9_.-]{1,64}\|k[1-9][0-9]{0,8}$/u,se=["ciphertextBase64url","context","encBase64url","fieldId"],Ze=["fields","protocolVersion","replyPublicKeyHex"],ie=["context","encBase64url","kmfBase64url","protocolVersion","replyPublicKeyHex"],Ge=["fields","replyEphemeralPublicKeyHex","schemaVersion"],et=/^[A-Za-z0-9_-]*$/u;function M(r,e){return(!ArrayBuffer.isView(r)||!(r instanceof Uint8Array)||Object.getPrototypeOf(r)!==Uint8Array.prototype)&&u(`${e} must be a plain Uint8Array`),Uint8Array.from(r)}function C(r){let e="";for(let t=0;t<r.length;t+=1)e+=String.fromCharCode(r[t]);return globalThis.btoa(e).replace(/\+/gu,"-").replace(/\//gu,"_").replace(/=+$/gu,"")}function I(r,e,t,s){v(r,s),(!et.test(r)||r.length%4===1||r.length>Math.ceil(t*4/3))&&u(`${s} must be canonical unpadded base64url`);let i;try{i=globalThis.atob(r.replace(/-/gu,"+").replace(/_/gu,"/").padEnd(Math.ceil(r.length/4)*4,"="))}catch{u(`${s} must be valid base64url`)}const o=Uint8Array.from(i,n=>n.charCodeAt(0));return(o.length<e||o.length>t||C(o)!==r)&&u(`${s} must canonically encode ${e}..${t} bytes`),o}function H(r,e){return v(r,e),(k.encode(r).byteLength>E.contextBytes||!Qe.test(r))&&u(`${e} must be sdn-field-encryption/v1|<site>|<schema>|<field>|k<version>`),r}function tt(r){return H(r,"context").split("|")[1]}function ne(r){const e=R(r,Ze,"field-open request");p(e.protocolVersion,1,"field-open protocolVersion"),T(e.replyPublicKeyHex,U,"replyPublicKeyHex"),(!Array.isArray(e.fields)||e.fields.length<1||e.fields.length>E.fields)&&u(`field-open request carries 1..${E.fields} fields`),x(e.fields,e.fields.length,"field-open fields");let t=0;const s=e.fields.map((i,o)=>{const n=R(i,se,`field ${o}`);return I(n.encBase64url,1,E.envelopeBytes,`field ${o} encBase64url`),t+=I(n.ciphertextBase64url,1,E.fieldBytes,`field ${o} ciphertextBase64url`).length,H(n.context,`field ${o} context`),(!Number.isInteger(n.fieldId)||n.fieldId<0||n.fieldId>65535)&&u(`field ${o} fieldId must be 0..65535`),b(se.map(a=>[a,n[a]]))});return t>E.batchBytes&&u(`field-open ciphertext exceeds ${E.batchBytes} bytes`),b([["fields",L(s)],["protocolVersion",1],["replyPublicKeyHex",e.replyPublicKeyHex]])}function oe(r){const e=R(r,ie,"key-unwrap request");return p(e.protocolVersion,1,"key-unwrap protocolVersion"),T(e.replyPublicKeyHex,U,"replyPublicKeyHex"),H(e.context,"key-unwrap context"),I(e.encBase64url,1,E.envelopeBytes,"key-unwrap encBase64url"),I(e.kmfBase64url,1,E.envelopeBytes,"key-unwrap kmfBase64url"),b(ie.map(t=>[t,e[t]]))}function ce(r,e){const t=R(r,Ge,"field result");p(t.schemaVersion,1,"field result schemaVersion"),T(t.replyEphemeralPublicKeyHex,U,"replyEphemeralPublicKeyHex"),(!Array.isArray(t.fields)||t.fields.length<1||t.fields.length>e)&&u(`field result carries 1..${e} fields`),x(t.fields,t.fields.length,"field result fields");const s=t.fields.map((i,o)=>{if((ee(i)?i.status:void 0)==="opened"){const l=R(i,["ciphertextBase64url","status"],`field result ${o}`);return I(l.ciphertextBase64url,1,E.fieldBytes,`field result ${o} ciphertext`),b([["ciphertextBase64url",l.ciphertextBase64url],["status","opened"]])}const a=R(i,["reason","status"],`field result ${o}`);return p(a.status,"refused",`field result ${o} status`),p(a.reason,"NOT_ADDRESSED_TO_ACCOUNT",`field result ${o} reason`),b([["reason","NOT_ADDRESSED_TO_ACCOUNT"],["status","refused"]])});return b([["fields",L(s)],["replyEphemeralPublicKeyHex",t.replyEphemeralPublicKeyHex],["schemaVersion",1]])}function rt(r,e="0".repeat(64)){const t=R(r,["fields"],"openFields input");return Array.isArray(t.fields)||u("openFields fields must be an array"),x(t.fields,t.fields.length,"openFields fields"),ne({fields:t.fields.map((s,i)=>{const o=R(s,["ciphertext","context","enc","fieldId"],`openFields field ${i}`);return{ciphertextBase64url:C(M(o.ciphertext,`field ${i} ciphertext`)),context:o.context,encBase64url:C(M(o.enc,`field ${i} enc`)),fieldId:o.fieldId}}),protocolVersion:1,replyPublicKeyHex:e})}function st(r){return ne(r)}function it(r){return ce(r,E.fields)}function nt(r,e="0".repeat(64)){const t=R(r,["context","enc","kmf"],"unwrapKey input");return oe({context:t.context,encBase64url:C(M(t.enc,"enc")),kmfBase64url:C(M(t.kmf,"kmf")),protocolVersion:1,replyPublicKeyHex:e})}function ot(r){return oe(r)}function ct(r){return ce(r,1)}const at=new TextEncoder().encode("sdn-wallet-reply/v1"),lt=new TextEncoder().encode("flatbuffers-field"),ut=new TextEncoder().encode("flatbuffers-iv");function ft(r){return Array.from(r,e=>e.toString(16).padStart(2,"0")).join("")}function ht(r){return Uint8Array.from(r.match(/../gu),e=>Number.parseInt(e,16))}function ae(r,e){const t=new Uint8Array(r.length+6);return t.set(r),t[r.length]=e>>8,t[r.length+1]=e&255,t}async function J(r,e,t,s){const i=await r.importKey("raw",e,"HKDF",!1,["deriveBits"]);return new Uint8Array(await r.deriveBits({hash:"SHA-256",info:t,name:"HKDF",salt:new Uint8Array(0)},i,s))}async function dt(r){const e=r?.subtle;if(!e)throw new Error("Web Crypto is unavailable");const t=await e.generateKey({name:"X25519"},!1,["deriveBits"]),s=new Uint8Array(await e.exportKey("raw",t.publicKey));if(s.length!==32)throw new Error("X25519 public key is not 32 bytes");let i=t.privateKey;return Object.freeze({publicKeyHex:ft(s),async open(o,n){if(!i)throw new Error("reply key already used");const a=i;i=null;const l=await e.importKey("raw",ht(o),{name:"X25519"},!1,[]),f=new Uint8Array(await e.deriveBits({name:"X25519",public:l},a,256)),h=await J(e,f,at,256);f.fill(0);try{return await Promise.all(n.map(async(d,y)=>{if(d===null)return null;const m=await J(e,h,ae(lt,y),256),w=await J(e,h,ae(ut,y),128),Q=await e.importKey("raw",m,"AES-CTR",!1,["decrypt"]);return m.fill(0),new Uint8Array(await e.decrypt({counter:w,length:128,name:"AES-CTR"},Q,d))}))}finally{h.fill(0)}}})}const P="https://wallet.spacedatanetwork.org",V="sdn.wallet.callback.v1:",N=/^[0-9a-f]{64}$/u,le=/^[A-Za-z0-9_-]{43}$/u,yt=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/u,pt=250,mt=3e4,Rt=3e5,Et=9e5,bt=12e4,At=8,ue=4096,fe=70*1024,wt=64,he=Object.freeze({CALLBACK_ERROR:"The wallet return could not be verified. Try again.",CRYPTO_UNAVAILABLE:"Secure browser cryptography is unavailable.",DESTROYED:"This wallet client has been destroyed.",DISCONNECTED:"The wallet was disconnected.",EXPIRED:"The wallet connection expired.",INVALID_CLIENT:"This wallet client is not registered.",INVALID_REQUEST:"The wallet request is invalid.",NOT_ADDRESSED_TO_ACCOUNT:"This data is not sealed to your wallet.",RELAY_ERROR:"The wallet service could not complete the request. Try again.",REPLACED:"A newer wallet request replaced this one.",WALLET_NOT_COMPLETED:"The wallet did not complete. Check popup settings and try again."}),de=new TextEncoder,Ot=new TextDecoder("utf-8",{fatal:!0});class g extends Error{constructor(e){super(he[e]),this.name="WalletClientError",Object.defineProperty(this,"code",{configurable:!1,enumerable:!0,value:e,writable:!1})}}function c(r){return Object.hasOwn(he,r)?new g(r):new g("RELAY_ERROR")}function _t(r){if(r===null||typeof r!="object"||Array.isArray(r))return!1;const e=Object.getPrototypeOf(r);return e===Object.prototype||e===null}function Y(r,e){if(typeof r!="string"||r.length>e||de.encode(r).byteLength>e||r.charCodeAt(0)===65279)throw c("RELAY_ERROR");let t=0,s=0;const i=()=>{for(;t<r.length&&/[\u0009\u000a\u000d\u0020]/u.test(r[t]);)t+=1},o=()=>{if(r[t]!=='"')throw c("RELAY_ERROR");const l=t;for(t+=1;t<r.length;){const f=r.charCodeAt(t);if(f===34){t+=1;let h;try{h=JSON.parse(r.slice(l,t))}catch{throw c("RELAY_ERROR")}for(let d=0;d<h.length;d+=1){const y=h.charCodeAt(d);if(y>=55296&&y<=56319){const m=h.charCodeAt(d+1);if(!(m>=56320&&m<=57343))throw c("RELAY_ERROR");d+=1}else if(y>=56320&&y<=57343)throw c("RELAY_ERROR")}return h}if(f<32||f===92&&(t+=1,t>=r.length))throw c("RELAY_ERROR");t+=1}throw c("RELAY_ERROR")},n=(l=0)=>{if(l>32||++s>4096)throw c("RELAY_ERROR");i();const f=r[t];if(f==='"')return o();if(f==="{"){t+=1;const y=Object.create(null),m=new Set;if(i(),r[t]==="}")return t+=1,y;for(;t<r.length;){i();const w=o();if(m.has(w)||(m.add(w),i(),r[t]!==":"))throw c("RELAY_ERROR");if(t+=1,y[w]=n(l+1),i(),r[t]==="}")return t+=1,y;if(r[t]!==",")throw c("RELAY_ERROR");t+=1}throw c("RELAY_ERROR")}if(f==="["){t+=1;const y=[];if(i(),r[t]==="]")return t+=1,y;for(;t<r.length;){if(y.push(n(l+1)),i(),r[t]==="]")return t+=1,y;if(r[t]!==",")throw c("RELAY_ERROR");t+=1}throw c("RELAY_ERROR")}for(const[y,m]of[["true",!0],["false",!1],["null",null]])if(r.startsWith(y,t))return t+=y.length,m;const h=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/u.exec(r.slice(t));if(!h)throw c("RELAY_ERROR");t+=h[0].length;const d=Number(h[0]);if(!Number.isFinite(d))throw c("RELAY_ERROR");return d};i();const a=n();if(i(),t!==r.length)throw c("RELAY_ERROR");return a}function F(r,e,t="RELAY_ERROR"){if(!_t(r)||Object.getOwnPropertySymbols(r).length!==0)throw c(t);const s=Object.getOwnPropertyNames(r).sort(),i=[...e].sort();if(s.length!==i.length||s.some((o,n)=>o!==i[n]))throw c(t);for(const o of s){const n=Object.getOwnPropertyDescriptor(r,o);if(!n?.enumerable||!("value"in n)||n.value===void 0)throw c(t)}return r}function K(r,e="RELAY_ERROR"){if(typeof r!="string"||!yt.test(r))throw c(e);const t=Date.parse(r);if(!Number.isFinite(t)||new Date(t).toISOString()!==r)throw c(e);return t}function _(r){return Array.isArray(r)?Object.freeze(r.map(_)):r&&typeof r=="object"?Object.freeze(Object.fromEntries(Object.entries(r).map(([e,t])=>[e,_(t)]))):r}function ye(r){const e={identity:r.identity===null?null:_(r.identity),status:r.status};return r.connectionExpiresAt!==void 0&&(e.connectionExpiresAt=r.connectionExpiresAt),r.error!==void 0&&(e.error=_(r.error)),_(e)}function D(r){return Object.freeze({code:r.code,message:r.message})}function pe(r){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";let t=0,s=0,i="";for(const o of r)for(t=t<<8|o,s+=8;s>=6;)s-=6,i+=e[t>>>s&63],t&=(1<<s)-1;return s!==0&&(i+=e[t<<6-s&63]),i}function me(r){let e="";for(const t of r)e+=t.toString(16).padStart(2,"0");return e}function W(r,e){const t=new Uint8Array(32);return Reflect.apply(e,r,[t]),t}function vt(r){const e=r?.headers?.get?.("content-type");return typeof e=="string"&&/^application\/json(?:\s*;\s*charset=utf-8)?$/iu.test(e.trim())}function X(r){try{Promise.resolve(r).catch(()=>{})}catch{}}function j(r){try{const e=r?.body,t=e?.cancel;typeof t=="function"&&X(Reflect.apply(t,e,[]))}catch{}}function Re(r){try{const e=r?.cancel;typeof e=="function"&&X(Reflect.apply(e,r,[]))}catch{}}function Lt(r){try{const e=r?.releaseLock;typeof e=="function"&&Reflect.apply(e,r,[])}catch{}}function S(r,e,t=null){try{r.abort()}catch{}t&&Re(t),j(e)}function q(r,e,t=null){let s;try{s=Promise.resolve(r)}catch(i){return Promise.reject(i)}return new Promise((i,o)=>{let n=!1;const a=()=>{try{e.removeEventListener("abort",f)}catch{}},l=(h,d)=>n?!1:(n=!0,a(),h(d),!0),f=()=>{l(o,c("RELAY_ERROR"))};try{e.addEventListener("abort",f,{once:!0}),e.aborted&&f()}catch{f()}s.then(h=>{if(n){try{t?.(h)}catch{}return}l(i,h)},h=>{n||l(o,h)})})}async function Ee(r,e,t){let s=null;const i=[];let o=0;try{if(!vt(r)||typeof r?.body?.getReader!="function")throw c("RELAY_ERROR");for(s=r.body.getReader();;){const l=s.read(),{done:f,value:h}=await q(l,t.signal);if(f)break;if(!(h instanceof Uint8Array)||(o+=h.byteLength,o>e))throw c("RELAY_ERROR");i.push(h)}const n=new Uint8Array(o);let a=0;for(const l of i)n.set(l,a),a+=l.byteLength;return Ot.decode(n)}catch{try{t.abort()}catch{}throw s&&Re(s),c("RELAY_ERROR")}finally{s&&Lt(s)}}function z(r,e){const t={body:JSON.stringify(r),cache:"no-store",credentials:"omit",headers:{"Content-Type":"application/json"},method:"POST",mode:"cors",redirect:"error",referrerPolicy:"no-referrer"};return e!==void 0&&(t.signal=e),t}function Tt(r,e,t){let s;try{s=Y(r,2048),F(s,["code","expiresAt","schemaVersion","state"],"CALLBACK_ERROR")}catch{throw c("CALLBACK_ERROR")}if(s.schemaVersion!==1||s.state!==e||!N.test(s.code))throw c("CALLBACK_ERROR");const i=K(s.expiresAt,"CALLBACK_ERROR");if(i<=t||i-t>bt)throw c("CALLBACK_ERROR");return{code:s.code,expiresAt:i,state:s.state}}function It(){let r;return{promise:new Promise(t=>{r=t}),resolve:r}}function be(){let r,e;return{promise:new Promise((s,i)=>{r=i,e=s}),reject:r,resolve:e}}function St(){const r=globalThis.window;return Object.freeze({AbortController:globalThis.AbortController,clearInterval:globalThis.clearInterval.bind(globalThis),clearTimeout:globalThis.clearTimeout.bind(globalThis),crypto:globalThis.crypto,fetch:typeof globalThis.fetch=="function"?globalThis.fetch.bind(globalThis):void 0,getStorage:()=>{try{return r?.localStorage??null}catch{return null}},now:()=>Date.now(),setInterval:globalThis.setInterval.bind(globalThis),setTimeout:globalThis.setTimeout.bind(globalThis),window:r})}class xt{#k;#B;#x=!1;#l=!1;#$=!1;#n=null;#O=null;#b=new Set;#e;#_=null;#r=!1;#m=0;#v=0;#L=new Set;#C=[];#o=null;#P=!1;#y=new Set;#U=Object.freeze({identity:null,status:"dormant"});#u=null;#T=null;#A=null;#R=new Set;#p;constructor({adapters:e,clientId:t,dependencies:s}){this.#k=e,this.#B=t,this.#e=s??St(),this.#p=this.#e.window}getSnapshot(){return this.#Y(),ye(this.#U)}subscribe(e){if(typeof e!="function")throw c("INVALID_REQUEST");if(this.#r)throw c("DESTROYED");this.#L.add(e);try{e(this.getSnapshot())}catch{}let t=!0;return()=>{t&&(t=!1,this.#L.delete(e))}}execute(e,t){if(this.#r)return Promise.reject(c("DESTROYED"));const s=this.#m,i=this.#k[e];if(!i)return Promise.reject(c("INVALID_REQUEST"));let o;try{o=i.buildRequest(t)}catch{const A=this.#t(s);return A?Promise.reject(A):Promise.reject(c("INVALID_REQUEST"))}let n=this.#t(s);if(n)return Promise.reject(n);if(this.#x)return this.#l=!0,Promise.reject(c("REPLACED"));const a=++this.#m;if(this.#Q(),n=this.#t(a),n)return Promise.reject(n);if(this.#l)return Promise.reject(c("CALLBACK_ERROR"));if(this.#Y(),n=this.#t(a),n)return Promise.reject(n);const l=this.#i();if(n=this.#t(a),n)return Promise.reject(n);const f=this.#n&&this.#n.expiresAtMs>l?this.#n:null;if(n=this.#t(a),n)return Promise.reject(n);const h=this.#o;let d,y,m;try{const A=this.#e.crypto,O=A?.getRandomValues,Bt=A?.subtle?.digest,Se=this.#p?.open;if(n=this.#t(a),n)throw n;if(typeof O!="function"||typeof Bt!="function"||typeof Se!="function")throw c("CRYPTO_UNAVAILABLE");if(d=me(W(A,O)),n=this.#t(a),n||(y=me(W(A,O)),n=this.#t(a),n)||(m=pe(W(A,O)),n=this.#t(a),n))throw n;if(!N.test(d)||!N.test(y)||!le.test(m))throw c("CRYPTO_UNAVAILABLE");if(Reflect.apply(Se,this.#p,[`${P}/transaction/${d}`,"_blank","noopener"]),n=this.#t(a),n)throw n}catch(A){if(n=this.#t(a),n)return Promise.reject(n);let O;try{O=A instanceof g?A:c("CRYPTO_UNAVAILABLE")}catch{O=c("CRYPTO_UNAVAILABLE")}return h&&(this.#I(h,"REPLACED",!1),n=this.#t(a),n)?Promise.reject(n):(this.#M(null,O,f,i.kind),Promise.reject(O))}if(h&&(this.#I(h,"REPLACED",!1),n=this.#t(a),n))return Promise.reject(n);const w=be(),Q=It(),Ie={active:!0,adapter:i,callbackBusy:!1,challenge:null,cleanup:Q,cleanupFinished:!1,cleanupStarted:!1,controllers:new Set,expiryTimer:null,generation:++this.#v,operationTimer:null,phase:"hashing",pollTimer:null,priorConnection:f,promise:w.promise,registrationDeadlineMs:l+mt,registrationOutcome:"none",reject:w.reject,openResult:null,request:o,resolve:w.resolve,retryResolve:null,retryTimer:null,state:y,transactionExpiresAtMs:null,transactionId:d,verifier:m};return this.#o=Ie,this.#s({...f?{connectionExpiresAt:f.expiresAt,identity:f.identity}:{identity:null},status:"opening"}),this.#q(Ie),w.promise}async disconnect(){if(this.#r)throw c("DESTROYED");const e=++this.#m;this.#h();const t=this.#o;let s=Promise.resolve();t&&(s=this.#I(t,"DISCONNECTED",!1));let i=this.#t(e);if(i)throw await s,i;if(this.#s({identity:null,status:"dormant"}),await s,i=this.#t(e),i)throw i}destroy(){if(this.#_)return this.#_;const e=be();this.#_=e.promise,this.#m+=1;try{this.#K(),e.resolve()}catch{e.reject(c("RELAY_ERROR"))}return this.#_}#K(){this.#r=!0,this.#v+=1,this.#h();const e=[],t=this.#o;t&&(t.active=!1,this.#o=null,this.#S(t),t.reject(c("DESTROYED")),t.challenge&&t.verifier&&e.push(t));for(const s of this.#y)s.challenge&&s.verifier&&e.push(s);for(const s of this.#b)s.abort();this.#b.clear();for(const s of this.#R)this.#e.clearTimeout(s),this.#e.clearInterval(s);if(this.#R.clear(),this.#A)try{this.#A()}catch{}this.#T=null,this.#A=null,this.#u=null,this.#L.clear();for(const s of e)this.#X(s);t&&this.#a(t);for(const s of[...this.#y])this.#a(s);this.#s({error:D(c("DESTROYED")),identity:null,status:"error"})}async#q(e){if(!(!this.#c(e)||e.cleanupFinished))try{if(e.operationTimer=this.#w(()=>{if(!e.cleanupFinished){if(e.phase==="hashing"){this.#c(e)&&this.#f(e,"CRYPTO_UNAVAILABLE",!1);return}if(e.phase==="registering")for(const a of e.controllers)a.abort()}},Math.max(0,e.registrationDeadlineMs-this.#i())),typeof e.adapter.seal=="function"){const a=await e.adapter.seal(e.request,this.#e.crypto);e.request=a.request,e.openResult=a.open}const t=await this.#e.crypto.subtle.digest("SHA-256",de.encode(e.verifier)),s=pe(new Uint8Array(t));if(!le.test(s))throw c("CRYPTO_UNAVAILABLE");if(!this.#c(e)){e.registrationOutcome="not-started",this.#a(e);return}e.challenge=s,e.phase="registering";const i=this.#g(e);let o,n=null;try{try{const l=this.#e.fetch(`${P}/relay/v1/transactions`,z({clientId:this.#B,codeChallenge:e.challenge,codeChallengeMethod:"S256",operation:e.adapter.operation,request:e.request,schemaVersion:1,state:e.state,transactionId:e.transactionId},i.signal));n=await q(l,i.signal,j)}catch{e.registrationOutcome="ambiguous",e.active?this.#f(e,"RELAY_ERROR"):this.#E(e);return}e.registrationOutcome="ambiguous";let a;try{a=n.status}catch{S(i,n),e.active?this.#f(e,"RELAY_ERROR"):this.#E(e);return}if(a!==201){e.registrationOutcome="definitive-failure",S(i,n),e.active?this.#f(e,"RELAY_ERROR",!1):this.#a(e);return}try{const l=await Ee(n,ue,i),f=F(Y(l,ue),["expiresAt","schemaVersion","transactionId"]);if(f.schemaVersion!==1||f.transactionId!==e.transactionId)throw c("RELAY_ERROR");o=K(f.expiresAt);const h=this.#i();if(o<=h||o-h>Rt)throw c("RELAY_ERROR")}catch{e.registrationOutcome="ambiguous",S(i,n),e.active?this.#f(e,"RELAY_ERROR"):this.#E(e);return}}finally{try{i.abort()}catch{}this.#D(e,i),this.#d(e.operationTimer),e.operationTimer=null}if(e.transactionExpiresAtMs=o,e.registrationOutcome="registered",!this.#c(e)){this.#E(e);return}e.phase="waiting-callback",e.expiryTimer=this.#w(()=>{this.#c(e)&&this.#f(e,"WALLET_NOT_COMPLETED")},Math.max(0,e.transactionExpiresAtMs-this.#i())),e.pollTimer=this.#W(()=>{this.#N(e,!1)},pt),await this.#N(e,!1)}catch(t){if(!e.active){e.registrationOutcome==="ambiguous"||e.registrationOutcome==="registered"?this.#E(e):this.#a(e);return}const s=t instanceof g?t.code:e.phase==="hashing"?"CRYPTO_UNAVAILABLE":"RELAY_ERROR";this.#f(e,s,e.registrationOutcome!=="none")}}async#N(e,t){if(!this.#c(e)||e.phase!=="waiting-callback"||e.callbackBusy||!this.#u)return;const s=`${V}${e.state}`;let i;try{i=this.#u.getItem(s)}catch{t&&this.#f(e,"CALLBACK_ERROR");return}if(i===null)return;e.callbackBusy=!0;let o;try{o=Tt(i,e.state,this.#i()),this.#u.removeItem(s)}catch{try{this.#u.removeItem(s)}catch{}this.#f(e,"CALLBACK_ERROR");return}if(!this.#c(e))return;e.phase="redeeming",this.#d(e.pollTimer,!0),e.pollTimer=null;const n=this.#g(e);let a=null;try{const l=this.#e.fetch(`${P}/relay/v1/codes/redeem`,z({code:o.code,codeVerifier:e.verifier,schemaVersion:1,state:e.state,transactionId:e.transactionId},n.signal));if(a=await q(l,n.signal,j),a.status!==200)throw c("RELAY_ERROR");const f=await Ee(a,fe,n),h=F(Y(f,fe),["result","schemaVersion","transactionId"]);if(h.schemaVersion!==1||h.transactionId!==e.transactionId)throw c("RELAY_ERROR");let d;try{d=e.adapter.parseResult(h.result)}catch{throw c("RELAY_ERROR")}if(e.openResult&&(d=await e.openResult(d)),!this.#c(e))return;this.#z(e,d)}catch(l){if(a&&S(n,a),!this.#c(e))return;const f=l instanceof g?l.code:"RELAY_ERROR";this.#f(e,f)}finally{try{n.abort()}catch{}this.#D(e,n)}}#z(e,t){if(!this.#c(e))return;let s=null;(e.adapter.kind==="connect"||e.adapter.kind==="account"&&t.event==="connected")&&(s=this.#H(t)),e.active=!1,this.#o=null,this.#S(e);let i=t;e.adapter.kind==="connect"?(this.#V(s),i=_(t.identity)):e.adapter.kind==="account"?(t.event==="connected"?this.#V(s):(this.#h(),this.#s({identity:null,status:"dormant"})),i=void 0):this.#J(e,void 0),e.resolve(i),this.#a(e)}#f(e,t,s=!0){this.#c(e)&&this.#I(e,t,!0,s)}#I(e,t,s,i=!0){if(!e.active)return e.cleanup.promise;const o=this.#m;e.active=!1,this.#o===e&&(this.#o=null),this.#v+=1,this.#S(e);for(const l of e.controllers)e.phase!=="registering"&&l.abort();const n=this.#t(o),a=n??c(t);return e.reject(a),s&&!n&&this.#M(e,a,e.priorConnection,e.adapter.kind),this.#r?(e.challenge&&e.verifier&&this.#F(e),this.#a(e),e.cleanup.promise):(!i||e.registrationOutcome==="definitive-failure"||e.registrationOutcome==="not-started"?this.#a(e):e.phase==="hashing"?(e.registrationOutcome="not-started",this.#a(e)):e.phase==="registering"&&e.registrationOutcome==="none"?this.#j(e):(this.#j(e),this.#E(e)),e.cleanup.promise)}#M(e,t,s,i){if(s?.expiresAtMs>this.#i()){this.#n=s,this.#s({connectionExpiresAt:s.expiresAt,error:D(t),identity:s.identity,status:"connected"});return}this.#h(),this.#s({error:D(t),identity:null,status:"error"})}#H(e){const t=K(e.connectionExpiresAt),s=this.#i();if(t<=s||t-s>Et)throw c("RELAY_ERROR");return{expiresAt:e.connectionExpiresAt,expiresAtMs:t,identity:_(e.identity)}}#V(e){const t=this.#i();this.#h(),this.#n=e;const s=this.#n;this.#O=this.#w(()=>{this.#n===s&&(this.#n=null,this.#O=null,this.#o?this.#s({identity:null,status:"opening"}):this.#s({identity:null,status:"dormant"}))},Math.max(0,e.expiresAtMs-t)),this.#s({connectionExpiresAt:e.expiresAt,identity:this.#n.identity,status:"connected"})}#J(e,t){const s=e.priorConnection;s?.expiresAtMs>this.#i()?(this.#n=s,this.#s({connectionExpiresAt:s.expiresAt,...t?{error:D(t)}:{},identity:s.identity,status:"connected"})):t?(this.#h(),this.#s({error:D(t),identity:null,status:"error"})):(this.#h(),this.#s({identity:null,status:"dormant"}))}#Y(){!this.#n||this.#n.expiresAtMs>this.#i()||(this.#h(),this.#o?this.#s({identity:null,status:"opening"}):this.#s({identity:null,status:"dormant"}))}#h(){this.#n=null,this.#d(this.#O),this.#O=null}#s(e){const t=_(e);if(this.#U=t,this.#C.push(t),!this.#P){this.#P=!0;try{for(;this.#C.length!==0;){const s=this.#C.shift();for(const i of[...this.#L])try{i(ye(s))}catch{}}}finally{this.#P=!1}}}#c(e){return!this.#r&&e.active&&this.#o===e&&e.generation===this.#v}#t(e){return this.#r?c("DESTROYED"):e!==this.#m?c("REPLACED"):null}#i(){return this.#e.now()}#g(e){const t=new this.#e.AbortController;return e.controllers.add(t),this.#b.add(t),t}#D(e,t){e.controllers.delete(t),this.#b.delete(t)}#w(e,t){let s;return s=this.#e.setTimeout(()=>{this.#R.delete(s),e()},Math.max(0,t)),this.#R.add(s),s}#W(e,t){const s=this.#e.setInterval(e,t);return this.#R.add(s),s}#d(e,t=!1){e!=null&&(t?this.#e.clearInterval(e):this.#e.clearTimeout(e),this.#R.delete(e))}#S(e){this.#d(e.expiryTimer),this.#d(e.pollTimer,!0),e.expiryTimer=null,e.pollTimer=null}#j(e){if(!(e.cleanupFinished||this.#y.has(e)))for(this.#y.add(e);this.#y.size>At;){const t=this.#y.values().next().value;for(const s of t.controllers)s.abort();this.#a(t)}}async#E(e){if(e.cleanupFinished||e.cleanupStarted||this.#r)return e.cleanup.promise;e.cleanupStarted=!0,this.#j(e);let t=100,s=!0;for(;!this.#r&&!e.cleanupFinished&&(s||this.#i()<=e.registrationDeadlineMs);){s=!1;const i=await this.#F(e);if(e.cleanupFinished)return e.cleanup.promise;if(i==="done")return this.#a(e),e.cleanup.promise;const o=e.registrationDeadlineMs-this.#i();if(o<=0)break;await new Promise(n=>{e.retryResolve=n,e.retryTimer=this.#w(()=>{e.retryResolve=null,n()},Math.min(t,o))}),e.retryResolve=null,e.retryTimer=null,t=Math.min(t*2,4e3)}return this.#a(e),e.cleanup.promise}async#F(e){if(!e.verifier||!e.challenge)return"done";const t=this.#g(e),s=e.registrationDeadlineMs-this.#i(),i=s>0?Math.min(4e3,s):1e3,o=this.#w(()=>t.abort(),Math.max(1,i));let n=null;try{const a=this.#e.fetch(`${P}/relay/v1/transactions/${e.transactionId}/cancel`,z({codeVerifier:e.verifier,schemaVersion:1,state:e.state,transactionId:e.transactionId},t.signal));n=await q(a,t.signal,j);const l=n.status;return S(t,n),n=null,l===204||l===400||l===403||l===409||l===410?"done":"retry"}catch{return n&&S(t,n),"retry"}finally{try{t.abort()}catch{}this.#d(o),this.#D(e,t)}}#X(e){let t;try{t=this.#e.fetch(`${P}/relay/v1/transactions/${e.transactionId}/cancel`,{...z({codeVerifier:e.verifier,schemaVersion:1,state:e.state,transactionId:e.transactionId}),keepalive:!0})}catch{return}X(Promise.resolve(t).then(j))}#a(e){if(!e.cleanupFinished){e.cleanupFinished=!0,this.#d(e.retryTimer),e.retryResolve?.(),e.retryResolve=null,e.retryTimer=null,this.#d(e.operationTimer),e.operationTimer=null,this.#S(e);for(const t of e.controllers)t.abort(),this.#b.delete(t);e.controllers.clear(),this.#y.delete(e),e.adapter=null,e.challenge=null,e.priorConnection=null,e.request=null,e.state=null,e.transactionExpiresAtMs=null,e.transactionId=null,e.verifier=null,e.cleanup.resolve()}}#Q(){if(!(this.#$||this.#r)){this.#$=!0,this.#x=!0;try{let e=null;try{const o=this.#e.getStorage;e=typeof o=="function"?Reflect.apply(o,void 0,[]):this.#e.storage??null}catch{e=null,this.#l=!0}try{(!e||typeof e.getItem!="function"||typeof e.removeItem!="function")&&(this.#l=!0)}catch{this.#l=!0}if(this.#r||this.#l){this.#u=null;return}if(this.#u=e,this.#Z(),this.#r||this.#l){this.#u=null;return}const t=o=>{const n=this.#o;if(!n||!this.#c(n))return;const a=`${V}${n.state}`;o?.key===a&&this.#N(n,!0)};this.#T=t;let s=!1,i=null;try{const o=this.#p?.addEventListener,n=this.#p?.removeEventListener;if(typeof o!="function"||typeof n!="function")throw new TypeError("storage events unavailable");i=()=>Reflect.apply(n,this.#p,["storage",t]),this.#A=i,Reflect.apply(o,this.#p,["storage",this.#T]),s=!0}catch{this.#l=!0}if(!s||this.#r||this.#l){try{i?.()}catch{}this.#T=null,this.#A=null,this.#u=null}}finally{this.#x=!1}}}#Z(){const e=this.#u;if(!e)return;let t;try{t=e.length}catch{return}if(!Number.isSafeInteger(t)||t<0)return;const s=Math.min(t,wt),i=[];for(let o=0;o<s&&!this.#r&&!this.#l;o+=1){let n;try{n=e.key(o)}catch{continue}i.push(n)}for(const o of i){if(this.#r||this.#l)return;if(typeof o!="string"||!o.startsWith(V))continue;const n=o.slice(V.length);if(N.test(n))try{const a=e.getItem(o);if(a===null)continue;const l=F(Y(a,2048),["code","expiresAt","schemaVersion","state"],"CALLBACK_ERROR");if(l.schemaVersion!==1||l.state!==n||!N.test(l.code))continue;K(l.expiresAt,"CALLBACK_ERROR")<=this.#i()&&e.removeItem(o)}catch{}}}}function Ae(r){return new xt(r)}function we(r,e={}){const t=(i,o)=>i!==0?Promise.reject(c("INVALID_REQUEST")):o(),s={connect(...i){return t(i.length,()=>r.execute("connect",void 0))},destroy(...i){return t(i.length,()=>r.destroy())},disconnect(...i){return t(i.length,()=>r.disconnect())},getSnapshot(...i){if(i.length!==0)throw c("INVALID_REQUEST");return r.getSnapshot()},openAccount(...i){return t(i.length,()=>r.execute("account",void 0))},subscribe(i,...o){if(o.length!==0)throw c("INVALID_REQUEST");return r.subscribe(i)}};for(const[i,o]of Object.entries(e))s[i]=function(a,...l){return l.length!==0?Promise.reject(c("INVALID_REQUEST")):r.execute(o,a)};return Object.freeze(s)}const Ct=Object.freeze(["orbpro-pages-v1","sdn-asset-models-pages-v1","sdn-asset-review-v1","sdn-flatbuffers-pages-v1","sdn-flatsql-pages-v1","sdn-landing-web-v1","sdn-module-sdk-pages-v1","sdn-node-console-v1","sdn-standards-web-v1","spaceaware-web-v1"]);function Pt(r){let e;try{const t=Reflect.ownKeys(r);if(r===null||typeof r!="object"||Array.isArray(r)||Object.getPrototypeOf(r)!==Object.prototype||t.length!==1||t[0]!=="clientId")throw c("INVALID_REQUEST");e=Object.getOwnPropertyDescriptor(r,"clientId")}catch{throw c("INVALID_REQUEST")}if(!e?.enumerable||!("value"in e)||typeof e.value!="string")throw c("INVALID_REQUEST");if(!Ct.includes(e.value))throw c("INVALID_CLIENT");return e.value}const Oe=Object.freeze({account:Object.freeze({buildRequest:()=>We({}),kind:"account",operation:"sdn.wallet.account.v1",parseResult:Xe}),connect:Object.freeze({buildRequest:()=>He({}),kind:"connect",operation:"sdn.wallet.connect.v1",parseResult:Je})});function _e(r,e){if(tt(r)!==e)throw c("INVALID_REQUEST")}function ve({operation:r,buildRequest:e,parseRequest:t,parseResult:s,openResult:i}){return Object.freeze({buildRequest:e,kind:"typed",operation:r,parseResult:s,async seal(o,n){let a;try{a=await dt(n)}catch{throw c("CRYPTO_UNAVAILABLE")}return Object.freeze({request:t({...o,replyPublicKeyHex:a.publicKeyHex}),async open(l){const f=l.fields.map(d=>d.status==="opened"?I(d.ciphertextBase64url,1,E.fieldBytes,"reply"):null);let h;try{h=await a.open(l.replyEphemeralPublicKeyHex,f)}catch{throw c("CRYPTO_UNAVAILABLE")}return i(h)}})}})}const Nt=r=>ve({operation:"sdn.wallet.field-open.v1",buildRequest(e){const t=rt(e);for(const s of t.fields)_e(s.context,r);return t},parseRequest:st,parseResult:it,openResult:e=>Object.freeze(e.map(t=>Object.freeze(t===null?{refused:"NOT_ADDRESSED_TO_ACCOUNT"}:{plaintext:t})))}),gt=r=>ve({operation:"sdn.wallet.key-unwrap.v1",buildRequest(e){const t=nt(e);return _e(t.context,r),t},parseRequest:ot,parseResult:ct,openResult([e]){if(e===null)throw c("NOT_ADDRESSED_TO_ACCOUNT");if(e.length!==32)throw c("RELAY_ERROR");return Object.freeze({contentKey:e})}}),Dt=Object.freeze({"sdn-flatbuffers-pages-v1":Object.freeze({method:"openFields",adapter:Nt("flatbuffers")}),"sdn-flatsql-pages-v1":Object.freeze({method:"unwrapKey",adapter:gt("flatsql")})});function Le(r){if(arguments.length!==1)throw c("INVALID_REQUEST");const e=Pt(r),t=Dt[e];if(!t){const i=Ae({adapters:Oe,clientId:e});return we(i)}const s=Ae({adapters:Object.freeze({...Oe,sealed:t.adapter}),clientId:e});return we(s,{[t.method]:"sealed"})}const Te="SDNWalletPublicClient";if(Object.prototype.hasOwnProperty.call(globalThis,Te))throw new Error("SDN wallet public client global already exists");function jt(r){return arguments.length!==1?Le(...arguments):Le(r)}const kt=Object.freeze({create:jt});Object.defineProperty(globalThis,Te,{configurable:!1,enumerable:!1,value:kt,writable:!1})})();
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
.sdn-wallet-control {
|
|
2
|
+
align-items: center;
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
gap: 0.5rem;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.sdn-wallet-control__button {
|
|
8
|
+
appearance: none;
|
|
9
|
+
background: #0b1f33;
|
|
10
|
+
border: 1px solid #5ea8ff;
|
|
11
|
+
border-radius: 0.375rem;
|
|
12
|
+
color: #fff;
|
|
13
|
+
cursor: pointer;
|
|
14
|
+
font: inherit;
|
|
15
|
+
min-height: 2.25rem;
|
|
16
|
+
padding: 0.375rem 0.75rem;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.sdn-wallet-control__button:disabled {
|
|
20
|
+
cursor: wait;
|
|
21
|
+
opacity: 0.65;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.sdn-wallet-control__button:focus-visible {
|
|
25
|
+
outline: 3px solid #f5b942;
|
|
26
|
+
outline-offset: 2px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.sdn-wallet-control__status {
|
|
30
|
+
color: currentColor;
|
|
31
|
+
font-size: 0.875rem;
|
|
32
|
+
}
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
(() => {
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const footerHeight = "40px";
|
|
5
|
+
const documentClientKey = Symbol.for("sdn.wallet.public-client.v1");
|
|
6
|
+
const links = Object.freeze([
|
|
7
|
+
Object.freeze({
|
|
8
|
+
key: "onboarding",
|
|
9
|
+
label: "Onboarding",
|
|
10
|
+
href: "https://spacedatanetwork.org/onboarding.html",
|
|
11
|
+
}),
|
|
12
|
+
Object.freeze({
|
|
13
|
+
key: "standards",
|
|
14
|
+
label: "Standards",
|
|
15
|
+
href: "https://spacedatastandards.org/",
|
|
16
|
+
}),
|
|
17
|
+
Object.freeze({
|
|
18
|
+
key: "flatbuffers",
|
|
19
|
+
label: "FlatBuffers",
|
|
20
|
+
href: "https://digitalarsenal.github.io/flatbuffers/",
|
|
21
|
+
}),
|
|
22
|
+
Object.freeze({
|
|
23
|
+
key: "flatsql",
|
|
24
|
+
label: "FlatSQL",
|
|
25
|
+
href: "https://digitalarsenal.github.io/flatsql/",
|
|
26
|
+
}),
|
|
27
|
+
Object.freeze({
|
|
28
|
+
key: "sdn",
|
|
29
|
+
label: "SDN",
|
|
30
|
+
href: "https://spacedatanetwork.org/",
|
|
31
|
+
}),
|
|
32
|
+
Object.freeze({
|
|
33
|
+
key: "module-sdk",
|
|
34
|
+
label: "Module SDK",
|
|
35
|
+
href: "https://digitalarsenal.github.io/space-data-module-sdk/",
|
|
36
|
+
}),
|
|
37
|
+
]);
|
|
38
|
+
const loader = document.currentScript;
|
|
39
|
+
const sha256 = /^[0-9a-f]{64}$/u;
|
|
40
|
+
const sha384 = /^sha384-[A-Za-z0-9+/]{64}$/u;
|
|
41
|
+
const clientId = /^[a-z0-9]+(?:-[a-z0-9]+)*-v[0-9]+$/u;
|
|
42
|
+
const vendorPath = /^(?:\/(?!\.\.?(?:\/|$))[A-Za-z0-9._-]+)?\/assets\/vendor\/[a-z0-9][a-z0-9.-]*\/[0-9]+(?:\.[0-9]+)*\/[a-z0-9-]+\.[0-9a-f]{64}\.[a-z]+$/u;
|
|
43
|
+
|
|
44
|
+
function attribute(element, name) {
|
|
45
|
+
if (!element || typeof element.getAttribute !== "function") return null;
|
|
46
|
+
const value = element.getAttribute(name);
|
|
47
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function immutableAsset(urlValue, integrityValue, extension) {
|
|
51
|
+
if (
|
|
52
|
+
!urlValue
|
|
53
|
+
|| !vendorPath.test(urlValue)
|
|
54
|
+
|| !integrityValue
|
|
55
|
+
|| !sha384.test(integrityValue)
|
|
56
|
+
) return null;
|
|
57
|
+
const filename = urlValue.slice(urlValue.lastIndexOf("/") + 1);
|
|
58
|
+
const digest = filename.split(".").at(-2);
|
|
59
|
+
if (!filename.endsWith(`.${extension}`) || !sha256.test(digest ?? "")) return null;
|
|
60
|
+
return Object.freeze({ integrity: integrityValue, url: urlValue });
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function exactPreloadedAsset(element, tagName, sourceName, asset) {
|
|
64
|
+
if (!element || element.tagName !== tagName || !asset) return false;
|
|
65
|
+
return attribute(element, sourceName) === asset.url
|
|
66
|
+
&& attribute(element, "integrity") === asset.integrity
|
|
67
|
+
&& attribute(element, "crossorigin") === "anonymous";
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function readConfiguration() {
|
|
71
|
+
const navStyle = immutableAsset(
|
|
72
|
+
attribute(loader, "data-nav-style-url"),
|
|
73
|
+
attribute(loader, "data-nav-style-integrity"),
|
|
74
|
+
"css",
|
|
75
|
+
);
|
|
76
|
+
const walletClient = immutableAsset(
|
|
77
|
+
attribute(loader, "data-wallet-client-url"),
|
|
78
|
+
attribute(loader, "data-wallet-client-integrity"),
|
|
79
|
+
"js",
|
|
80
|
+
);
|
|
81
|
+
const walletStyle = immutableAsset(
|
|
82
|
+
attribute(loader, "data-wallet-style-url"),
|
|
83
|
+
attribute(loader, "data-wallet-style-integrity"),
|
|
84
|
+
"css",
|
|
85
|
+
);
|
|
86
|
+
const configuredClientId = attribute(loader, "data-wallet-client-id");
|
|
87
|
+
const callbackValue = attribute(loader, "data-wallet-callback-uri");
|
|
88
|
+
const registryDigest = attribute(loader, "data-wallet-registry-sha256");
|
|
89
|
+
let callback;
|
|
90
|
+
try {
|
|
91
|
+
callback = callbackValue ? new URL(callbackValue) : null;
|
|
92
|
+
} catch {
|
|
93
|
+
callback = null;
|
|
94
|
+
}
|
|
95
|
+
const publicClientScript = loader?.previousElementSibling ?? null;
|
|
96
|
+
const publicClientStyle = publicClientScript?.previousElementSibling ?? null;
|
|
97
|
+
const preloaded = exactPreloadedAsset(publicClientScript, "SCRIPT", "src", walletClient)
|
|
98
|
+
&& attribute(publicClientScript, "data-sdn-wallet-public-client") === "v1"
|
|
99
|
+
&& exactPreloadedAsset(publicClientStyle, "LINK", "href", walletStyle)
|
|
100
|
+
&& attribute(publicClientStyle, "rel") === "stylesheet";
|
|
101
|
+
const callbackValid = callback
|
|
102
|
+
&& callback.protocol === "https:"
|
|
103
|
+
&& callbackValue.startsWith(`${callback.origin}/`)
|
|
104
|
+
&& !callback.search
|
|
105
|
+
&& !callback.hash;
|
|
106
|
+
const wallet = navStyle
|
|
107
|
+
&& walletClient
|
|
108
|
+
&& walletStyle
|
|
109
|
+
&& clientId.test(configuredClientId ?? "")
|
|
110
|
+
&& callbackValid
|
|
111
|
+
&& sha256.test(registryDigest ?? "")
|
|
112
|
+
&& preloaded
|
|
113
|
+
? Object.freeze({
|
|
114
|
+
callbackUri: callbackValue,
|
|
115
|
+
clientId: configuredClientId,
|
|
116
|
+
registryDigest,
|
|
117
|
+
})
|
|
118
|
+
: null;
|
|
119
|
+
return Object.freeze({ navStyle, wallet });
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const config = readConfiguration();
|
|
123
|
+
|
|
124
|
+
function validClient(value) {
|
|
125
|
+
return Object.isFrozen(value)
|
|
126
|
+
&& typeof value.connect === "function"
|
|
127
|
+
&& typeof value.getSnapshot === "function"
|
|
128
|
+
&& typeof value.openAccount === "function"
|
|
129
|
+
&& typeof value.subscribe === "function";
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function validDocumentClient(value) {
|
|
133
|
+
return Object.isFrozen(value)
|
|
134
|
+
&& value.identity === "sdn.wallet.public-client.document.v1"
|
|
135
|
+
&& validClient(value.client)
|
|
136
|
+
&& typeof value.addPresenter === "function"
|
|
137
|
+
&& typeof value.getSnapshot === "function";
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function createDocumentClient() {
|
|
141
|
+
if (!config.wallet) return null;
|
|
142
|
+
const existing = document[documentClientKey];
|
|
143
|
+
if (existing !== undefined) return validDocumentClient(existing) ? existing : null;
|
|
144
|
+
const namespace = globalThis.SDNWalletPublicClient;
|
|
145
|
+
if (
|
|
146
|
+
!namespace
|
|
147
|
+
|| !Object.isFrozen(namespace)
|
|
148
|
+
|| Object.keys(namespace).length !== 1
|
|
149
|
+
|| Object.keys(namespace)[0] !== "create"
|
|
150
|
+
|| typeof namespace.create !== "function"
|
|
151
|
+
) return null;
|
|
152
|
+
|
|
153
|
+
try {
|
|
154
|
+
const client = namespace.create({ clientId: config.wallet.clientId });
|
|
155
|
+
if (!validClient(client)) return null;
|
|
156
|
+
const presenters = new Set();
|
|
157
|
+
let snapshot = client.getSnapshot();
|
|
158
|
+
const record = Object.freeze({
|
|
159
|
+
addPresenter(presenter) {
|
|
160
|
+
presenters.add(presenter);
|
|
161
|
+
},
|
|
162
|
+
client,
|
|
163
|
+
getSnapshot() {
|
|
164
|
+
return snapshot;
|
|
165
|
+
},
|
|
166
|
+
identity: "sdn.wallet.public-client.document.v1",
|
|
167
|
+
});
|
|
168
|
+
const unsubscribe = client.subscribe((nextSnapshot) => {
|
|
169
|
+
snapshot = nextSnapshot;
|
|
170
|
+
for (const presenter of presenters) presenter.render();
|
|
171
|
+
});
|
|
172
|
+
if (typeof unsubscribe !== "function") return null;
|
|
173
|
+
Object.defineProperty(document, documentClientKey, {
|
|
174
|
+
configurable: false,
|
|
175
|
+
enumerable: false,
|
|
176
|
+
value: record,
|
|
177
|
+
writable: false,
|
|
178
|
+
});
|
|
179
|
+
return record;
|
|
180
|
+
} catch {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
class SdnStackNav extends HTMLElement {
|
|
186
|
+
static get observedAttributes() {
|
|
187
|
+
return ["active", "wallet-presenter"];
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
connectedCallback() {
|
|
191
|
+
if (!this.shadowRoot) this.attachShadow({ mode: "open" });
|
|
192
|
+
if (this.getAttribute("wallet-presenter") !== "none" && !this.walletClient) {
|
|
193
|
+
this.walletClient = createDocumentClient();
|
|
194
|
+
this.walletClient?.addPresenter(this);
|
|
195
|
+
}
|
|
196
|
+
this.render();
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
attributeChangedCallback() {
|
|
200
|
+
if (!this.shadowRoot) return;
|
|
201
|
+
if (this.getAttribute("wallet-presenter") !== "none" && !this.walletClient) {
|
|
202
|
+
this.walletClient = createDocumentClient();
|
|
203
|
+
this.walletClient?.addPresenter(this);
|
|
204
|
+
}
|
|
205
|
+
this.render();
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
createWalletButton() {
|
|
209
|
+
const button = document.createElement("button");
|
|
210
|
+
const snapshot = this.walletClient.getSnapshot();
|
|
211
|
+
const connected = snapshot?.status === "connected";
|
|
212
|
+
const opening = snapshot?.status === "opening";
|
|
213
|
+
button.className = "sdn-stack-wallet";
|
|
214
|
+
button.type = "button";
|
|
215
|
+
button.textContent = connected ? "Account" : opening ? "Opening wallet…" : "Login";
|
|
216
|
+
button.disabled = opening;
|
|
217
|
+
button.dataset.status = opening ? "opening" : connected ? "connected" : "disconnected";
|
|
218
|
+
button.setAttribute("aria-label", connected ? "Open wallet account" : "Log in with SDN Wallet");
|
|
219
|
+
if (opening) button.setAttribute("aria-busy", "true");
|
|
220
|
+
button.addEventListener("click", (event) => {
|
|
221
|
+
if (event?.isTrusted !== true) return;
|
|
222
|
+
const client = this.walletClient?.client;
|
|
223
|
+
if (!client) return;
|
|
224
|
+
let completion;
|
|
225
|
+
try {
|
|
226
|
+
completion = client.getSnapshot()?.status === "connected"
|
|
227
|
+
? client.openAccount()
|
|
228
|
+
: client.connect();
|
|
229
|
+
} catch {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
if (completion && typeof completion.catch === "function") {
|
|
233
|
+
void completion.catch(() => {});
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
return button;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
render() {
|
|
240
|
+
if (!this.shadowRoot) return;
|
|
241
|
+
const active = this.getAttribute("active") || "";
|
|
242
|
+
const nodes = [];
|
|
243
|
+
if (config.navStyle) {
|
|
244
|
+
const style = document.createElement("link");
|
|
245
|
+
style.rel = "stylesheet";
|
|
246
|
+
style.href = config.navStyle.url;
|
|
247
|
+
style.integrity = config.navStyle.integrity;
|
|
248
|
+
style.crossOrigin = "anonymous";
|
|
249
|
+
nodes.push(style);
|
|
250
|
+
}
|
|
251
|
+
const footer = document.createElement("footer");
|
|
252
|
+
footer.className = "sdn-stack-bar";
|
|
253
|
+
const nav = document.createElement("nav");
|
|
254
|
+
nav.className = "sdn-stack-inner";
|
|
255
|
+
nav.setAttribute("aria-label", "SDN Stack sites");
|
|
256
|
+
const brand = document.createElement("div");
|
|
257
|
+
brand.className = "sdn-stack-brand";
|
|
258
|
+
brand.textContent = "SDN Stack";
|
|
259
|
+
const list = document.createElement("div");
|
|
260
|
+
list.className = "sdn-stack-links";
|
|
261
|
+
for (const link of links) {
|
|
262
|
+
const anchor = document.createElement("a");
|
|
263
|
+
anchor.href = link.href;
|
|
264
|
+
anchor.textContent = link.label;
|
|
265
|
+
anchor.dataset.active = String(link.key === active);
|
|
266
|
+
if (link.key === active) anchor.setAttribute("aria-current", "page");
|
|
267
|
+
list.append(anchor);
|
|
268
|
+
}
|
|
269
|
+
nav.append(brand, list);
|
|
270
|
+
if (this.getAttribute("wallet-presenter") !== "none" && this.walletClient) {
|
|
271
|
+
nav.append(this.createWalletButton());
|
|
272
|
+
}
|
|
273
|
+
footer.append(nav);
|
|
274
|
+
nodes.push(footer);
|
|
275
|
+
this.shadowRoot.replaceChildren(...nodes);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
document.documentElement.style.setProperty("--sdn-stack-footer-height", footerHeight);
|
|
280
|
+
if (!customElements.get("sdn-stack-nav")) {
|
|
281
|
+
customElements.define("sdn-stack-nav", SdnStackNav);
|
|
282
|
+
}
|
|
283
|
+
})();
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
color-scheme: dark;
|
|
3
|
+
font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.sdn-stack-bar {
|
|
7
|
+
position: fixed;
|
|
8
|
+
right: 0;
|
|
9
|
+
bottom: 0;
|
|
10
|
+
left: 0;
|
|
11
|
+
z-index: 2147483000;
|
|
12
|
+
height: var(--sdn-stack-footer-height, 40px);
|
|
13
|
+
border-top: 1px solid rgba(255, 255, 255, 0.12);
|
|
14
|
+
background: rgba(5, 7, 10, 0.94);
|
|
15
|
+
color: #f5f5f7;
|
|
16
|
+
backdrop-filter: blur(18px) saturate(140%);
|
|
17
|
+
-webkit-backdrop-filter: blur(18px) saturate(140%);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.sdn-stack-inner {
|
|
21
|
+
display: flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
justify-content: space-between;
|
|
24
|
+
gap: 12px;
|
|
25
|
+
height: 100%;
|
|
26
|
+
max-width: 1200px;
|
|
27
|
+
min-width: 0;
|
|
28
|
+
margin: 0 auto;
|
|
29
|
+
padding: 0 24px;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.sdn-stack-brand {
|
|
33
|
+
flex: 0 0 auto;
|
|
34
|
+
font-size: 12px;
|
|
35
|
+
font-weight: 700;
|
|
36
|
+
line-height: 1;
|
|
37
|
+
white-space: nowrap;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.sdn-stack-links {
|
|
41
|
+
display: flex;
|
|
42
|
+
align-items: center;
|
|
43
|
+
justify-content: flex-end;
|
|
44
|
+
gap: 2px;
|
|
45
|
+
min-width: 0;
|
|
46
|
+
overflow-x: auto;
|
|
47
|
+
scrollbar-width: none;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.sdn-stack-links::-webkit-scrollbar {
|
|
51
|
+
display: none;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
a,
|
|
55
|
+
.sdn-stack-wallet {
|
|
56
|
+
display: inline-flex;
|
|
57
|
+
align-items: center;
|
|
58
|
+
justify-content: center;
|
|
59
|
+
box-sizing: border-box;
|
|
60
|
+
height: 24px;
|
|
61
|
+
padding: 0 9px;
|
|
62
|
+
border: 1px solid transparent;
|
|
63
|
+
border-radius: 6px;
|
|
64
|
+
color: rgba(245, 245, 247, 0.74);
|
|
65
|
+
background: transparent;
|
|
66
|
+
font: inherit;
|
|
67
|
+
font-size: 12px;
|
|
68
|
+
font-weight: 600;
|
|
69
|
+
line-height: 1;
|
|
70
|
+
text-decoration: none;
|
|
71
|
+
white-space: nowrap;
|
|
72
|
+
transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
a:hover,
|
|
76
|
+
.sdn-stack-wallet:hover:not(:disabled) {
|
|
77
|
+
border-color: rgba(255, 255, 255, 0.12);
|
|
78
|
+
background: rgba(255, 255, 255, 0.08);
|
|
79
|
+
color: #ffffff;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
a[data-active="true"] {
|
|
83
|
+
border-color: rgba(41, 151, 255, 0.42);
|
|
84
|
+
background: rgba(10, 132, 255, 0.24);
|
|
85
|
+
color: #ffffff;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.sdn-stack-wallet {
|
|
89
|
+
flex: 0 0 auto;
|
|
90
|
+
cursor: pointer;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.sdn-stack-wallet[data-status="opening"] {
|
|
94
|
+
cursor: progress;
|
|
95
|
+
opacity: 0.72;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.sdn-stack-wallet:focus-visible {
|
|
99
|
+
outline: 2px solid #60a5fa;
|
|
100
|
+
outline-offset: 2px;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
@media (max-width: 640px) {
|
|
104
|
+
.sdn-stack-inner {
|
|
105
|
+
gap: 8px;
|
|
106
|
+
padding: 0 12px;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.sdn-stack-brand {
|
|
110
|
+
font-size: 11px;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
a,
|
|
114
|
+
.sdn-stack-wallet {
|
|
115
|
+
padding: 0 8px;
|
|
116
|
+
font-size: 11px;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
<script src="./assembly.js" defer></script>
|
|
13
13
|
<script src="./assets/ai-credits/ai-credits.js" defer></script>
|
|
14
14
|
<!-- SDN_CONSUMER_ASSETS_START -->
|
|
15
|
-
<link rel="stylesheet" href="
|
|
16
|
-
<script defer src="
|
|
17
|
-
<script defer src="
|
|
15
|
+
<link rel="stylesheet" href="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.c3f68d1cfd88478f10d836a5e829d1dfc6a10157972cf0f7d4d319d0636f2cc4.css" integrity="sha384-fICuhN4I9xqOK1F5vGGzl26opuO+xQIvTZXMSV76lWTBiQ6AfzztMGLLDw8yRT8i" crossorigin="anonymous">
|
|
16
|
+
<script defer src="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.9ab041131df957fcb6ef7e3d87bf9d19fe313bc5d7f1e53337752faf0ba354da.js" integrity="sha384-FNcHq8FI7eBz2YUhfO3jNfmdObbCXmfg4ugmBEHzXW/KBpbUdJXqIzpn30OWJBuB" crossorigin="anonymous" data-sdn-wallet-public-client="v1"></script>
|
|
17
|
+
<script defer src="/space-data-module-sdk/assets/vendor/sdn-stack-nav/1.0.1/sdn-stack-nav.24eb3001afc5448a90cef87e53bb4e599c0ae4dc9e14bafb6d1236e0233c6008.js" integrity="sha384-g8NCFtcgbsW5bHeGiPtPb2Q+NJVlJLfwbaAZ7/Ium1YAVtxE/SqawvG/Ny0iMl56" crossorigin="anonymous" data-nav-style-url="/space-data-module-sdk/assets/vendor/sdn-stack-nav/1.0.1/sdn-stack-nav.36a36359ce18322185e9ff179f88175bab67d5ad84a14d9c08a54f2ff27267e7.css" data-nav-style-integrity="sha384-c4M8Fg+kYaeOYYtJVr7jJsde24IhSWkWaRyAOHEZU9jozhRck089aw+mnHwxymds" data-wallet-client-url="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.9ab041131df957fcb6ef7e3d87bf9d19fe313bc5d7f1e53337752faf0ba354da.js" data-wallet-client-integrity="sha384-FNcHq8FI7eBz2YUhfO3jNfmdObbCXmfg4ugmBEHzXW/KBpbUdJXqIzpn30OWJBuB" data-wallet-style-url="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.c3f68d1cfd88478f10d836a5e829d1dfc6a10157972cf0f7d4d319d0636f2cc4.css" data-wallet-style-integrity="sha384-fICuhN4I9xqOK1F5vGGzl26opuO+xQIvTZXMSV76lWTBiQ6AfzztMGLLDw8yRT8i" data-wallet-client-id="sdn-module-sdk-pages-v1" data-wallet-callback-uri="https://digitalarsenal.github.io/space-data-module-sdk/wallet-callback.html" data-wallet-registry-sha256="63784143e2ad8e2542d22148ff4a0a4da7a10f4b3f9909ae91a20dc0f60db06b"></script>
|
|
18
18
|
<!-- SDN_CONSUMER_ASSETS_END -->
|
|
19
19
|
</head>
|
|
20
20
|
<body>
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
<script src="./assembly.js" defer></script>
|
|
13
13
|
<script src="./assets/ai-credits/ai-credits.js" defer></script>
|
|
14
14
|
<!-- SDN_CONSUMER_ASSETS_START -->
|
|
15
|
-
<link rel="stylesheet" href="
|
|
16
|
-
<script defer src="
|
|
17
|
-
<script defer src="
|
|
15
|
+
<link rel="stylesheet" href="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.c3f68d1cfd88478f10d836a5e829d1dfc6a10157972cf0f7d4d319d0636f2cc4.css" integrity="sha384-fICuhN4I9xqOK1F5vGGzl26opuO+xQIvTZXMSV76lWTBiQ6AfzztMGLLDw8yRT8i" crossorigin="anonymous">
|
|
16
|
+
<script defer src="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.9ab041131df957fcb6ef7e3d87bf9d19fe313bc5d7f1e53337752faf0ba354da.js" integrity="sha384-FNcHq8FI7eBz2YUhfO3jNfmdObbCXmfg4ugmBEHzXW/KBpbUdJXqIzpn30OWJBuB" crossorigin="anonymous" data-sdn-wallet-public-client="v1"></script>
|
|
17
|
+
<script defer src="/space-data-module-sdk/assets/vendor/sdn-stack-nav/1.0.1/sdn-stack-nav.24eb3001afc5448a90cef87e53bb4e599c0ae4dc9e14bafb6d1236e0233c6008.js" integrity="sha384-g8NCFtcgbsW5bHeGiPtPb2Q+NJVlJLfwbaAZ7/Ium1YAVtxE/SqawvG/Ny0iMl56" crossorigin="anonymous" data-nav-style-url="/space-data-module-sdk/assets/vendor/sdn-stack-nav/1.0.1/sdn-stack-nav.36a36359ce18322185e9ff179f88175bab67d5ad84a14d9c08a54f2ff27267e7.css" data-nav-style-integrity="sha384-c4M8Fg+kYaeOYYtJVr7jJsde24IhSWkWaRyAOHEZU9jozhRck089aw+mnHwxymds" data-wallet-client-url="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.9ab041131df957fcb6ef7e3d87bf9d19fe313bc5d7f1e53337752faf0ba354da.js" data-wallet-client-integrity="sha384-FNcHq8FI7eBz2YUhfO3jNfmdObbCXmfg4ugmBEHzXW/KBpbUdJXqIzpn30OWJBuB" data-wallet-style-url="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.c3f68d1cfd88478f10d836a5e829d1dfc6a10157972cf0f7d4d319d0636f2cc4.css" data-wallet-style-integrity="sha384-fICuhN4I9xqOK1F5vGGzl26opuO+xQIvTZXMSV76lWTBiQ6AfzztMGLLDw8yRT8i" data-wallet-client-id="sdn-module-sdk-pages-v1" data-wallet-callback-uri="https://digitalarsenal.github.io/space-data-module-sdk/wallet-callback.html" data-wallet-registry-sha256="63784143e2ad8e2542d22148ff4a0a4da7a10f4b3f9909ae91a20dc0f60db06b"></script>
|
|
18
18
|
<!-- SDN_CONSUMER_ASSETS_END -->
|
|
19
19
|
</head>
|
|
20
20
|
<body>
|
package/docs/conformance.html
CHANGED
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
<script src="./assembly.js" defer></script>
|
|
13
13
|
<script src="./assets/ai-credits/ai-credits.js" defer></script>
|
|
14
14
|
<!-- SDN_CONSUMER_ASSETS_START -->
|
|
15
|
-
<link rel="stylesheet" href="
|
|
16
|
-
<script defer src="
|
|
17
|
-
<script defer src="
|
|
15
|
+
<link rel="stylesheet" href="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.c3f68d1cfd88478f10d836a5e829d1dfc6a10157972cf0f7d4d319d0636f2cc4.css" integrity="sha384-fICuhN4I9xqOK1F5vGGzl26opuO+xQIvTZXMSV76lWTBiQ6AfzztMGLLDw8yRT8i" crossorigin="anonymous">
|
|
16
|
+
<script defer src="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.9ab041131df957fcb6ef7e3d87bf9d19fe313bc5d7f1e53337752faf0ba354da.js" integrity="sha384-FNcHq8FI7eBz2YUhfO3jNfmdObbCXmfg4ugmBEHzXW/KBpbUdJXqIzpn30OWJBuB" crossorigin="anonymous" data-sdn-wallet-public-client="v1"></script>
|
|
17
|
+
<script defer src="/space-data-module-sdk/assets/vendor/sdn-stack-nav/1.0.1/sdn-stack-nav.24eb3001afc5448a90cef87e53bb4e599c0ae4dc9e14bafb6d1236e0233c6008.js" integrity="sha384-g8NCFtcgbsW5bHeGiPtPb2Q+NJVlJLfwbaAZ7/Ium1YAVtxE/SqawvG/Ny0iMl56" crossorigin="anonymous" data-nav-style-url="/space-data-module-sdk/assets/vendor/sdn-stack-nav/1.0.1/sdn-stack-nav.36a36359ce18322185e9ff179f88175bab67d5ad84a14d9c08a54f2ff27267e7.css" data-nav-style-integrity="sha384-c4M8Fg+kYaeOYYtJVr7jJsde24IhSWkWaRyAOHEZU9jozhRck089aw+mnHwxymds" data-wallet-client-url="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.9ab041131df957fcb6ef7e3d87bf9d19fe313bc5d7f1e53337752faf0ba354da.js" data-wallet-client-integrity="sha384-FNcHq8FI7eBz2YUhfO3jNfmdObbCXmfg4ugmBEHzXW/KBpbUdJXqIzpn30OWJBuB" data-wallet-style-url="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.c3f68d1cfd88478f10d836a5e829d1dfc6a10157972cf0f7d4d319d0636f2cc4.css" data-wallet-style-integrity="sha384-fICuhN4I9xqOK1F5vGGzl26opuO+xQIvTZXMSV76lWTBiQ6AfzztMGLLDw8yRT8i" data-wallet-client-id="sdn-module-sdk-pages-v1" data-wallet-callback-uri="https://digitalarsenal.github.io/space-data-module-sdk/wallet-callback.html" data-wallet-registry-sha256="63784143e2ad8e2542d22148ff4a0a4da7a10f4b3f9909ae91a20dc0f60db06b"></script>
|
|
18
18
|
<!-- SDN_CONSUMER_ASSETS_END -->
|
|
19
19
|
</head>
|
|
20
20
|
<body>
|