@tinycloud/web-sdk 3.12.0-beta.11 → 3.12.0-beta.13
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/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/modules/Storage/tinycloud/types.schema.d.ts +4 -4
- package/dist/modules/requestPermissionsCore.d.ts +0 -7
- package/dist/modules/tcw.d.ts +0 -2
- package/dist/space-hosting-entry.d.ts +1 -1
- package/dist/space-hosting.cjs +1 -1
- package/dist/space-hosting.mjs +1 -1
- package/package.json +4 -4
|
@@ -36,10 +36,10 @@ export declare const SessionConfigSchema: z.ZodObject<{
|
|
|
36
36
|
domain?: string;
|
|
37
37
|
actions?: Record<string, Record<string, string[]>>;
|
|
38
38
|
spaceId?: string;
|
|
39
|
-
jwk?: Record<string, unknown>;
|
|
40
39
|
address?: string;
|
|
41
40
|
chainId?: number;
|
|
42
41
|
issuedAt?: string;
|
|
42
|
+
jwk?: Record<string, unknown>;
|
|
43
43
|
notBefore?: string;
|
|
44
44
|
expirationTime?: string;
|
|
45
45
|
parents?: string[];
|
|
@@ -47,10 +47,10 @@ export declare const SessionConfigSchema: z.ZodObject<{
|
|
|
47
47
|
domain?: string;
|
|
48
48
|
actions?: Record<string, Record<string, string[]>>;
|
|
49
49
|
spaceId?: string;
|
|
50
|
-
jwk?: Record<string, unknown>;
|
|
51
50
|
address?: string;
|
|
52
51
|
chainId?: number;
|
|
53
52
|
issuedAt?: string;
|
|
53
|
+
jwk?: Record<string, unknown>;
|
|
54
54
|
notBefore?: string;
|
|
55
55
|
expirationTime?: string;
|
|
56
56
|
parents?: string[];
|
|
@@ -78,18 +78,18 @@ export declare const SessionSchema: z.ZodObject<{
|
|
|
78
78
|
verificationMethod: z.ZodString;
|
|
79
79
|
}, "strip", z.ZodTypeAny, {
|
|
80
80
|
spaceId?: string;
|
|
81
|
-
jwk?: Record<string, unknown>;
|
|
82
81
|
delegationHeader?: {
|
|
83
82
|
Authorization?: string;
|
|
84
83
|
};
|
|
84
|
+
jwk?: Record<string, unknown>;
|
|
85
85
|
delegationCid?: string;
|
|
86
86
|
verificationMethod?: string;
|
|
87
87
|
}, {
|
|
88
88
|
spaceId?: string;
|
|
89
|
-
jwk?: Record<string, unknown>;
|
|
90
89
|
delegationHeader?: {
|
|
91
90
|
Authorization?: string;
|
|
92
91
|
};
|
|
92
|
+
jwk?: Record<string, unknown>;
|
|
93
93
|
delegationCid?: string;
|
|
94
94
|
verificationMethod?: string;
|
|
95
95
|
}>;
|
|
@@ -15,8 +15,6 @@ import type { PortableDelegation } from "@tinycloud/node-sdk/core";
|
|
|
15
15
|
export interface RequestPermissionsCoreDeps {
|
|
16
16
|
/** Current stored manifest. Must be defined — caller validates first. */
|
|
17
17
|
manifest: Manifest;
|
|
18
|
-
/** Authenticated owner from the current node, never from a requested resource. */
|
|
19
|
-
ownerDid?: string;
|
|
20
18
|
/**
|
|
21
19
|
* Show the permission request modal. Resolves with `{ approved }`
|
|
22
20
|
* once the user interacts. In tests this is a stub; in production it
|
|
@@ -51,11 +49,6 @@ export interface RequestPermissionsOptions {
|
|
|
51
49
|
* the same error text.
|
|
52
50
|
*/
|
|
53
51
|
export declare function validateAdditionalPermissions(additional: PermissionEntry[]): void;
|
|
54
|
-
/**
|
|
55
|
-
* Normalize only encryption key creation here. Other runtime entries retain
|
|
56
|
-
* their existing Web consent representation; the node validates them.
|
|
57
|
-
*/
|
|
58
|
-
export declare function normalizeRuntimeKeyCreatePermissions(additional: PermissionEntry[], ownerDid?: string): PermissionEntry[];
|
|
59
52
|
/**
|
|
60
53
|
* Core escalation flow. See the TinyCloudWeb.requestPermissions JSDoc
|
|
61
54
|
* for the full spec-level description — this function is the plumbing.
|
package/dist/modules/tcw.d.ts
CHANGED
|
@@ -521,8 +521,6 @@ export declare class TinyCloudWeb {
|
|
|
521
521
|
* On approve, this does not mutate the manifest or force a new sign-in.
|
|
522
522
|
* The underlying node creates a secondary delegation to the current
|
|
523
523
|
* session key and records it in the invocation permission map.
|
|
524
|
-
* Exact current-owner `default/share/<id>` key creation is bound to this
|
|
525
|
-
* live signed session across consent. Native shells cannot request it.
|
|
526
524
|
*
|
|
527
525
|
* `options.expiryMs` sets the requested lifetime of the issued step-up
|
|
528
526
|
* delegation, in milliseconds. Omitted, the node's default applies. The
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/** Space hosting probe and space creation, loaded when the first hosting check or creation runs. */
|
|
2
|
-
export { askSpaceHosting, createPrimarySpace } from "@tinycloud/node-sdk/space-hosting";
|
|
2
|
+
export { askSpaceHosting, createPrimarySpace, withHostExpiry } from "@tinycloud/node-sdk/space-hosting";
|
|
3
3
|
//# sourceMappingURL=space-hosting-entry.d.ts.map
|
package/dist/space-hosting.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";var e={d:(t,a)=>{for(var s in a)e.o(a,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:a[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{askSpaceHosting:()=>u,createPrimarySpace:()=>w});var a=new WeakMap,s=5e3,
|
|
1
|
+
(()=>{"use strict";var e={d:(t,a)=>{for(var s in a)e.o(a,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:a[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{askSpaceHosting:()=>u,createPrimarySpace:()=>w,withHostExpiry:()=>f});var a=new WeakMap,s=5e3,n="tinycloud.kv/list",o="tinycloud.kv/metadata",i="tinycloud.kv/get",r="tinycloud.space/info",c=e=>""===e||e.endsWith("/")||e.endsWith("/*")||e.endsWith("/**"),d=e=>e.endsWith("/**")?e.slice(0,-2):e.endsWith("/*")?e.slice(0,-1):"/"===e?"":e,p=e=>c(e)?`${d(e)}.tinycloud-space-probe`:e;async function h(e,t){try{const{spaceId:a}=e,n=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(s)});return n.ok?(n.body instanceof ReadableStream&&await n.body.cancel().catch(()=>{}),"hosted"):401===n.status||403===n.status?"refused":404===n.status?/space not found/i.test(await n.text())?"not-hosted":"hosted":"unknown"}catch{return"unknown"}}async function u(e){const t=function({spaceId:e,operations:t,covers:a}){const s=t.filter(t=>!t.caveats?.length&&a(t,{spaceId:e,service:t.service,path:t.path,action:t.action})),h=(t,n)=>s.filter(s=>a(s,{spaceId:e,service:t,path:s.path,action:n}));return[...h("kv",n).map(e=>({service:"kv",path:c(e.path)?d(e.path):e.path,action:n,headers:{"x-tinycloud-limit":"1"}})),...h("kv",o).map(e=>({service:"kv",path:p(e.path),action:o})),...h("space",r).map(()=>({service:"space",path:"",action:r,body:"{}"})),...h("kv",i).map(e=>({service:"kv",path:p(e.path),action:i}))].find(t=>s.some(s=>a(s,{spaceId:e,service:t.service,path:t.path,action:t.action})))}(e);if(!t)return"unknown";const u=`${e.host} ${e.spaceId.replace(/^(tinycloud:pkh:eip155:\d+:)(0x[0-9a-fA-F]{40})/,(e,t,a)=>t+a.toLowerCase())}`;if(a.get(e.scope)?.has(u))return"hosted";let l=await h(e,t);if("refused"===l){try{await e.activate(AbortSignal.timeout(s))}catch{return"unknown"}l=await h(e,t)}return"hosted"===l&&a.set(e.scope,(a.get(e.scope)??new Set).add(u)),"refused"===l?"unknown":l}function l(e){const t=e.error?.trim();return t?`${e.status} - ${t}`:`${e.status}`}async function w({handler:e,session:t,context:a,currentSession:s,signerAddress:n,resolveHost:o,domain:i,hostName:r,guard:c,host:d,onHosted:p,activate:h,signal:u}){const w=()=>{if(u?.throwIfAborted(),t&&s?.()!==t)throw new Error("Space hosting session changed")};if(w(),t&&n&&(await n()).toLowerCase()!==t.address.toLowerCase())return;w();const f=a??(t&&{address:t.address,chainId:t.chainId,spaceId:t.spaceId,host:await(o?.())??r??""});if(!f)throw new Error("Space hosting requires a session context");w(),await c(f),w();const m=await e.confirmSpaceCreation(f);if(w(),!m)return;try{const e=await d(f,w,e=>({address:f.address,chainId:f.chainId,domain:i??"",issuedAt:(new Date).toISOString(),spaceId:f.spaceId,peerId:e}));if(!e.success)throw Object.assign(new Error(`Failed to create space ${f.spaceId}: ${l(e)}`),{cause:e})}catch(t){throw e.onSpaceCreationFailed?.(f,t instanceof Error?t:new Error(String(t))),t}w(),p(f),await new Promise(e=>setTimeout(e,100)),w();const g=await h(f);if(w(),!g.success){const t=Object.assign(new Error(`Failed to activate session after creating space: ${l(g)}`),{cause:g});throw e.onSpaceCreationFailed?.(f,t),t}e.onSpaceCreated?.(f)}function f(e,t,a,s){if(/[\r\u0085\u2028\u2029]/.test(e))throw new Error("Host SIWE contains an unsupported line separator");const n=e.split("\n");if(n.some(e=>e.startsWith("Expiration Time:")))throw new Error("Host SIWE already contains Expiration Time");const o=""===n[3]?4:5,i=o+4;if(!n[o]?.startsWith("URI: ")||!n[i]?.startsWith("Issued At: "))throw new Error("Host SIWE has no positional Issued At field");const r=new Date(t),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 p=void 0===s?r.getTime():Date.parse(s);if(!Number.isFinite(p)||p<=t.getTime())throw new Error("Host expiry must be a valid future timestamp");const h=new Date(Math.min(p,r.getTime())).toISOString();return n.splice(i+1,0,`Expiration Time: ${h}`),n.join("\n")}module.exports=t})();
|
package/dist/space-hosting.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
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};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinycloud/web-sdk",
|
|
3
|
-
"version": "3.12.0-beta.
|
|
3
|
+
"version": "3.12.0-beta.13",
|
|
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,11 +67,11 @@
|
|
|
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.
|
|
70
|
+
"@tinycloud/node-sdk": "3.12.0-beta.13",
|
|
71
71
|
"@tinycloud/replica": "0.4.5-beta.4",
|
|
72
|
-
"@tinycloud/sdk-core": "3.12.0-beta.
|
|
72
|
+
"@tinycloud/sdk-core": "3.12.0-beta.13",
|
|
73
73
|
"@tinycloud/share-envelope": "1.5.0",
|
|
74
|
-
"@tinycloud/share-sdk": "1.
|
|
74
|
+
"@tinycloud/share-sdk": "1.5.0-beta.0",
|
|
75
75
|
"@tinycloud/web-sdk-wasm": "1.7.7",
|
|
76
76
|
"axios": "^1.7.9",
|
|
77
77
|
"viem": "^2.45.0",
|