@tinycloud/web-sdk 3.12.0-beta.8 → 3.12.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.
Files changed (49) hide show
  1. package/README.md +30 -8
  2. package/dist/adapters/BrowserSessionStorage.d.ts +13 -3
  3. package/dist/adapters/BrowserWasmBindings.d.ts +2 -0
  4. package/dist/delegations-issued.cjs +2 -1
  5. package/dist/delegations-issued.cjs.LICENSE.txt +5 -0
  6. package/dist/delegations-issued.mjs +2 -1
  7. package/dist/delegations-issued.mjs.LICENSE.txt +5 -0
  8. package/dist/delegations-renewal-entry.d.ts +3 -0
  9. package/dist/delegations-renewal.cjs +2 -0
  10. package/dist/delegations-renewal.cjs.LICENSE.txt +21 -0
  11. package/dist/delegations-renewal.mjs +2 -0
  12. package/dist/delegations-renewal.mjs.LICENSE.txt +21 -0
  13. package/dist/encryption-keys.cjs +1 -1
  14. package/dist/encryption-keys.cjs.LICENSE.txt +4 -0
  15. package/dist/encryption-keys.mjs +1 -1
  16. package/dist/encryption-keys.mjs.LICENSE.txt +4 -0
  17. package/dist/index.cjs +1 -1
  18. package/dist/index.cjs.LICENSE.txt +2 -0
  19. package/dist/index.d.ts +2 -0
  20. package/dist/index.mjs +1 -1
  21. package/dist/index.mjs.LICENSE.txt +2 -0
  22. package/dist/modals.cjs +1 -1
  23. package/dist/modals.mjs +1 -1
  24. package/dist/modules/Storage/tinycloud/module.d.ts +1 -0
  25. package/dist/modules/Storage/tinycloud/types.schema.d.ts +10 -10
  26. package/dist/modules/requestPermissionsCore.d.ts +0 -7
  27. package/dist/modules/restoreAccount.d.ts +13 -0
  28. package/dist/modules/runtimeGrantPersistence.d.ts +4 -2
  29. package/dist/modules/tcw.d.ts +27 -6
  30. package/dist/panel.cjs +1 -1
  31. package/dist/panel.mjs +1 -1
  32. package/dist/registry-verdict-cache-entry.d.ts +2 -0
  33. package/dist/registry-verdict-cache.cjs +1 -0
  34. package/dist/registry-verdict-cache.mjs +1 -0
  35. package/dist/replica.cjs +1 -1
  36. package/dist/replica.mjs +1 -1
  37. package/dist/share-placement-core-bridge.d.ts +2 -0
  38. package/dist/share-placement-core.d.ts +13 -0
  39. package/dist/share-placement-entry.d.ts +2 -0
  40. package/dist/share-placement.cjs +2 -0
  41. package/dist/share-placement.cjs.LICENSE.txt +3 -0
  42. package/dist/share-placement.mjs +2 -0
  43. package/dist/share-placement.mjs.LICENSE.txt +3 -0
  44. package/dist/space-hosting-entry.d.ts +1 -1
  45. package/dist/space-hosting.cjs +1 -1
  46. package/dist/space-hosting.mjs +1 -1
  47. package/dist/ui/pending.d.ts +1 -1
  48. package/dist/ui/strings.d.ts +2 -0
  49. package/package.json +7 -7
@@ -1 +1 @@
1
- var e=new WeakMap,t="tinycloud.kv/list",a="tinycloud.kv/metadata",s="tinycloud.kv/get",n="tinycloud.space/info",o=e=>""===e||e.endsWith("/")||e.endsWith("/*")||e.endsWith("/**"),i=e=>e.endsWith("/**")?e.slice(0,-2):e.endsWith("/*")?e.slice(0,-1):"/"===e?"":e,c=e=>o(e)?`${i(e)}.tinycloud-space-probe`:e;async function r(e,t){try{const{spaceId:a}=e,s=await e.fetch(`${e.host}/invoke`,{method:"POST",headers:{...e.sign([{spaceId:a,service:t.service,path:t.path,action:t.action}]),...t.headers},body:t.body,signal:AbortSignal.timeout(5e3)});return s.ok?(s.body instanceof ReadableStream&&await s.body.cancel().catch(()=>{}),"hosted"):401===s.status||403===s.status?"refused":404===s.status?/space not found/i.test(await s.text())?"not-hosted":"hosted":"unknown"}catch{return"unknown"}}async function d(d){const h=function({spaceId:e,operations:r,covers:d}){const h=r.filter(t=>!t.caveats?.length&&d(t,{spaceId:e,service:t.service,path:t.path,action:t.action})),p=(t,a)=>h.filter(s=>d(s,{spaceId:e,service:t,path:s.path,action:a}));return[...p("kv",t).map(e=>({service:"kv",path:o(e.path)?i(e.path):e.path,action:t,headers:{"x-tinycloud-limit":"1"}})),...p("kv",a).map(e=>({service:"kv",path:c(e.path),action:a})),...p("space",n).map(()=>({service:"space",path:"",action:n,body:"{}"})),...p("kv",s).map(e=>({service:"kv",path:c(e.path),action:s}))].find(t=>h.some(a=>d(a,{spaceId:e,service:t.service,path:t.path,action:t.action})))}(d);if(!h)return"unknown";const p=`${d.host} ${d.spaceId.replace(/^(tinycloud:pkh:eip155:\d+:)(0x[0-9a-fA-F]{40})/,(e,t,a)=>t+a.toLowerCase())}`;if(e.get(d.scope)?.has(p))return"hosted";let u=await r(d,h);if("refused"===u){try{await d.activate(AbortSignal.timeout(5e3))}catch{return"unknown"}u=await r(d,h)}return"hosted"===u&&e.set(d.scope,(e.get(d.scope)??new Set).add(p)),"refused"===u?"unknown":u}function h(e){const t=e.error?.trim();return t?`${e.status} - ${t}`:`${e.status}`}async function p({handler:e,session:t,context:a,currentSession:s,signerAddress:n,resolveHost:o,domain:i,hostName:c,guard:r,host:d,onHosted:p,activate:u,signal:w}){const f=()=>{if(w?.throwIfAborted(),t&&s?.()!==t)throw new Error("Space hosting session changed")};if(f(),t&&n&&(await n()).toLowerCase()!==t.address.toLowerCase())return;f();const l=a??(t&&{address:t.address,chainId:t.chainId,spaceId:t.spaceId,host:await(o?.())??c??""});if(!l)throw new Error("Space hosting requires a session context");f(),await r(l),f();const v=await e.confirmSpaceCreation(l);if(f(),!v)return;try{const e=await d(l,f,e=>({address:l.address,chainId:l.chainId,domain:i??"",issuedAt:(new Date).toISOString(),spaceId:l.spaceId,peerId:e}));if(!e.success)throw Object.assign(new Error(`Failed to create space ${l.spaceId}: ${h(e)}`),{cause:e})}catch(t){throw e.onSpaceCreationFailed?.(l,t instanceof Error?t:new Error(String(t))),t}f(),p(l),await new Promise(e=>setTimeout(e,100)),f();const g=await u(l);if(f(),!g.success){const t=Object.assign(new Error(`Failed to activate session after creating space: ${h(g)}`),{cause:g});throw e.onSpaceCreationFailed?.(l,t),t}e.onSpaceCreated?.(l)}export{d as askSpaceHosting,p as createPrimarySpace};
1
+ var t=new WeakMap,e="tinycloud.kv/list",a="tinycloud.kv/metadata",s="tinycloud.kv/get",n="tinycloud.space/info",i=t=>""===t||t.endsWith("/")||t.endsWith("/*")||t.endsWith("/**"),o=t=>t.endsWith("/**")?t.slice(0,-2):t.endsWith("/*")?t.slice(0,-1):"/"===t?"":t,r=t=>i(t)?`${o(t)}.tinycloud-space-probe`:t;async function c(t,e){try{const{spaceId:a}=t,s=await t.fetch(`${t.host}/invoke`,{method:"POST",headers:{...t.sign([{spaceId:a,service:e.service,path:e.path,action:e.action}]),...e.headers},body:e.body,signal:AbortSignal.timeout(5e3)});return s.ok?(s.body instanceof ReadableStream&&await s.body.cancel().catch(()=>{}),"hosted"):401===s.status||403===s.status?"refused":404===s.status?/space not found/i.test(await s.text())?"not-hosted":"hosted":"unknown"}catch{return"unknown"}}async function d(d){const h=function({spaceId:t,operations:c,covers:d}){const h=c.filter(e=>!e.caveats?.length&&d(e,{spaceId:t,service:e.service,path:e.path,action:e.action})),p=(e,a)=>h.filter(s=>d(s,{spaceId:t,service:e,path:s.path,action:a}));return[...p("kv",e).map(t=>({service:"kv",path:i(t.path)?o(t.path):t.path,action:e,headers:{"x-tinycloud-limit":"1"}})),...p("kv",a).map(t=>({service:"kv",path:r(t.path),action:a})),...p("space",n).map(()=>({service:"space",path:"",action:n,body:"{}"})),...p("kv",s).map(t=>({service:"kv",path:r(t.path),action:s}))].find(e=>h.some(a=>d(a,{spaceId:t,service:e.service,path:e.path,action:e.action})))}(d);if(!h)return"unknown";const p=`${d.host} ${d.spaceId.replace(/^(tinycloud:pkh:eip155:\d+:)(0x[0-9a-fA-F]{40})/,(t,e,a)=>e+a.toLowerCase())}`;if(t.get(d.scope)?.has(p))return"hosted";let u=await c(d,h);if("refused"===u){try{await d.activate(AbortSignal.timeout(5e3))}catch{return"unknown"}u=await c(d,h)}return"hosted"===u&&t.set(d.scope,(t.get(d.scope)??new Set).add(p)),"refused"===u?"unknown":u}function h(t){const e=t.error?.trim();return e?`${t.status} - ${e}`:`${t.status}`}async function p({handler:t,session:e,context:a,currentSession:s,signerAddress:n,resolveHost:i,domain:o,hostName:r,guard:c,host:d,onHosted:p,activate:u,signal:w}){const l=()=>{if(w?.throwIfAborted(),e&&s?.()!==e)throw new Error("Space hosting session changed")};if(l(),e&&n&&(await n()).toLowerCase()!==e.address.toLowerCase())return;l();const f=a??(e&&{address:e.address,chainId:e.chainId,spaceId:e.spaceId,host:await(i?.())??r??""});if(!f)throw new Error("Space hosting requires a session context");l(),await c(f),l();const m=await t.confirmSpaceCreation(f);if(l(),!m)return;try{const t=await d(f,l,t=>({address:f.address,chainId:f.chainId,domain:o??"",issuedAt:(new Date).toISOString(),spaceId:f.spaceId,peerId:t}));if(!t.success)throw Object.assign(new Error(`Failed to create space ${f.spaceId}: ${h(t)}`),{cause:t})}catch(e){throw t.onSpaceCreationFailed?.(f,e instanceof Error?e:new Error(String(e))),e}l(),p(f),await new Promise(t=>setTimeout(t,100)),l();const v=await u(f);if(l(),!v.success){const e=Object.assign(new Error(`Failed to activate session after creating space: ${h(v)}`),{cause:v});throw t.onSpaceCreationFailed?.(f,e),e}t.onSpaceCreated?.(f)}function u(t,e,a,s){if(/[\r\u0085\u2028\u2029]/.test(t))throw new Error("Host SIWE contains an unsupported line separator");const n=t.split("\n");if(n.some(t=>t.startsWith("Expiration Time:")))throw new Error("Host SIWE already contains Expiration Time");const i=""===n[3]?4:5,o=i+4;if(!n[i]?.startsWith("URI: ")||!n[o]?.startsWith("Issued At: "))throw new Error("Host SIWE has no positional Issued At field");const r=new Date(e),c=r.getUTCDate();r.setUTCDate(1),r.setUTCFullYear(r.getUTCFullYear()+a);const d=new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth()+1,0)).getUTCDate();r.setUTCDate(Math.min(c,d));const h=void 0===s?r.getTime():Date.parse(s);if(!Number.isFinite(h)||h<=e.getTime())throw new Error("Host expiry must be a valid future timestamp");const p=new Date(Math.min(h,r.getTime())).toISOString();return n.splice(o+1,0,`Expiration Time: ${p}`),n.join("\n")}export{d as askSpaceHosting,p as createPrimarySpace,u as withHostExpiry};
@@ -7,7 +7,7 @@ export interface PendingPanel {
7
7
  readonly el: HTMLElement;
8
8
  setOpen(open: boolean): void;
9
9
  showLoading(): void;
10
- showError(retry: () => void): void;
10
+ showError(reloadPage: () => void): void;
11
11
  }
12
12
  export declare function createPendingPanel(onClose: () => void): PendingPanel;
13
13
  //# sourceMappingURL=pending.d.ts.map
@@ -12,7 +12,9 @@ export declare const STRINGS: {
12
12
  readonly "section.placeholder": "Not available yet.";
13
13
  readonly "view.loading": "Loading…";
14
14
  readonly "view.error": "This didn't load.";
15
+ readonly "panel.loadError": "This didn't load. Reloading the page can fix it. Save anything you're working on first.";
15
16
  readonly "view.retry": "Try again";
17
+ readonly "view.reloadPage": "Reload page";
16
18
  readonly "view.permission": "This session can't show this yet.";
17
19
  readonly "nodes.kind.hosted": "Hosted";
18
20
  readonly "nodes.status.down": "Down";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinycloud/web-sdk",
3
- "version": "3.12.0-beta.8",
3
+ "version": "3.12.0",
4
4
  "description": "A set of tools and utilities to help you build your app with TinyCloud.",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -67,12 +67,12 @@
67
67
  "@multiformats/multiaddr": "^13.0.1",
68
68
  "@multiformats/multiaddr-to-uri": "^12.0.0",
69
69
  "@noble/curves": "^1.9.7",
70
- "@tinycloud/node-sdk": "3.12.0-beta.8",
71
- "@tinycloud/replica": "0.4.5-beta.3",
72
- "@tinycloud/sdk-core": "3.12.0-beta.8",
73
- "@tinycloud/share-envelope": "1.5.0",
74
- "@tinycloud/share-sdk": "1.4.4",
75
- "@tinycloud/web-sdk-wasm": "1.7.7",
70
+ "@tinycloud/node-sdk": "3.12.0",
71
+ "@tinycloud/replica": "0.4.5",
72
+ "@tinycloud/sdk-core": "3.12.0",
73
+ "@tinycloud/share-envelope": "1.6.0",
74
+ "@tinycloud/share-sdk": "1.5.0",
75
+ "@tinycloud/web-sdk-wasm": "1.7.8",
76
76
  "axios": "^1.7.9",
77
77
  "viem": "^2.45.0",
78
78
  "zod": "^3.22.0"