@tinycloud/node-sdk 3.0.0-beta.8 → 3.0.0-beta.9
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/{core-WJQ9KiSD.d.cts → core-BTuD37zN.d.cts} +10 -64
- package/dist/{core-WJQ9KiSD.d.ts → core-BTuD37zN.d.ts} +10 -64
- package/dist/core.cjs +24 -9
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +25 -9
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +24 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +25 -9
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -19874,6 +19874,29 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19874
19874
|
const authHosts = this.auth?.hosts ?? [];
|
|
19875
19875
|
return authHosts.length > 0 ? authHosts : [this.config.host];
|
|
19876
19876
|
}
|
|
19877
|
+
/** The registry-resolved Node endpoint and the identity returned by that exact Node. */
|
|
19878
|
+
async activeNodeIdentity() {
|
|
19879
|
+
const host = this.hosts[0];
|
|
19880
|
+
if (host === void 0) throw new Error("TinyCloud node host has not been resolved");
|
|
19881
|
+
const parsed = new URL(host);
|
|
19882
|
+
if (parsed.protocol !== "https:" && !(parsed.protocol === "http:" && (parsed.hostname === "127.0.0.1" || parsed.hostname === "localhost")) || parsed.origin !== host) {
|
|
19883
|
+
throw new Error("TinyCloud node host is not a canonical origin");
|
|
19884
|
+
}
|
|
19885
|
+
const nodeDid = await this.fetchNodeId();
|
|
19886
|
+
if (!nodeDid.startsWith("did:key:z")) throw new Error("TinyCloud node identity is not a did:key");
|
|
19887
|
+
return Object.freeze({ origin: parsed.origin, nodeDid });
|
|
19888
|
+
}
|
|
19889
|
+
/** Publish the active owner Node as a session-signed registry record. */
|
|
19890
|
+
async publishActiveNodeLocation(registryUrl, fetchFn = globalThis.fetch.bind(globalThis)) {
|
|
19891
|
+
const node = await this.activeNodeIdentity();
|
|
19892
|
+
return (0, import_sdk_core7.publishLocationRecord)({
|
|
19893
|
+
registryUrl,
|
|
19894
|
+
subject: this.credentialHolderDid,
|
|
19895
|
+
nodeOrigin: node.origin,
|
|
19896
|
+
signer: { type: "did:key", signBytes: (bytes) => this.signSessionBytes(bytes) },
|
|
19897
|
+
fetch: fetchFn
|
|
19898
|
+
});
|
|
19899
|
+
}
|
|
19877
19900
|
/**
|
|
19878
19901
|
* Get the primary identity DID for this user.
|
|
19879
19902
|
* - If wallet connected and signed in: returns PKH DID (did:pkh:eip155:{chainId}:{address})
|
|
@@ -22230,11 +22253,6 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22230
22253
|
fetch: globalThis.fetch.bind(globalThis)
|
|
22231
22254
|
});
|
|
22232
22255
|
}
|
|
22233
|
-
/** @deprecated Policy/v2 delivery transport is retired. Use authorizeShareDeliveryV3. */
|
|
22234
|
-
async authorizeShareDelivery(input) {
|
|
22235
|
-
void input;
|
|
22236
|
-
throw new Error("Policy/v2 share delivery is retired; use authorizeShareDeliveryV3");
|
|
22237
|
-
}
|
|
22238
22256
|
/** Authorize one short-lived v3 delivery against the signed v3 envelope and registered roots. */
|
|
22239
22257
|
async authorizeShareDeliveryV3(input) {
|
|
22240
22258
|
const session = this.currentTinyCloudSession();
|
|
@@ -22242,8 +22260,6 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22242
22260
|
if (!session || !serviceSession) throw new Error("Share delivery requires an authenticated session");
|
|
22243
22261
|
const body = {
|
|
22244
22262
|
envelope: input.envelope,
|
|
22245
|
-
sealedEnvelope: input.sealedEnvelope,
|
|
22246
|
-
envelopeKey: input.envelopeKey,
|
|
22247
22263
|
shareCid: input.shareCid,
|
|
22248
22264
|
recipientEmail: input.recipientEmail,
|
|
22249
22265
|
shareUrl: input.shareUrl,
|
|
@@ -22263,9 +22279,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22263
22279
|
const verified = (0, import_sdk_core7.validateShareDeliveryAuthorizationV3Bytes)(new Uint8Array(await response.arrayBuffer()), {
|
|
22264
22280
|
request,
|
|
22265
22281
|
senderKeyDid: this.credentialHolderDid,
|
|
22266
|
-
|
|
22282
|
+
deliveryAudience: input.deliveryAudience
|
|
22267
22283
|
});
|
|
22268
|
-
void input.nodeProof;
|
|
22269
22284
|
const requestDigest = new Uint8Array(await crypto.subtle.digest(
|
|
22270
22285
|
"SHA-256",
|
|
22271
22286
|
new TextEncoder().encode(`${import_sdk_core7.CREDENTIAL_INVITATION_REQUEST_DOMAIN}${(0, import_sdk_core7.canonicalizeEncryptionJson)(verified.request)}`)
|