@tinycloud/node-sdk 2.4.0-beta.6 → 2.4.0-beta.7
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-zT0sxgtZ.d.cts → core-iwTdsebf.d.cts} +2 -0
- package/dist/{core-zT0sxgtZ.d.ts → core-iwTdsebf.d.ts} +2 -0
- package/dist/core.cjs +45 -12
- 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 +45 -12
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +45 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +45 -12
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -986,6 +986,8 @@ declare class TinyCloudNode {
|
|
|
986
986
|
signIn(options?: SignInOptions): Promise<void>;
|
|
987
987
|
private ownedSpaceId;
|
|
988
988
|
private writeManifestRegistryRecords;
|
|
989
|
+
private scheduleAccountRegistrySync;
|
|
990
|
+
private withAccountRegistryRetry;
|
|
989
991
|
private requestedEncryptionNetworkIds;
|
|
990
992
|
private ensureRequestedEncryptionNetworks;
|
|
991
993
|
private ensureOwnedSpaceHosted;
|
|
@@ -986,6 +986,8 @@ declare class TinyCloudNode {
|
|
|
986
986
|
signIn(options?: SignInOptions): Promise<void>;
|
|
987
987
|
private ownedSpaceId;
|
|
988
988
|
private writeManifestRegistryRecords;
|
|
989
|
+
private scheduleAccountRegistrySync;
|
|
990
|
+
private withAccountRegistryRetry;
|
|
989
991
|
private requestedEncryptionNetworkIds;
|
|
990
992
|
private ensureRequestedEncryptionNetworks;
|
|
991
993
|
private ensureOwnedSpaceHosted;
|
package/dist/core.cjs
CHANGED
|
@@ -1958,7 +1958,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
1958
1958
|
if (this.config.manifest === void 0 && this.config.capabilityRequest === void 0) {
|
|
1959
1959
|
await this.ensureOwnedSpaceHosted(this.ownedSpaceId("secrets"));
|
|
1960
1960
|
}
|
|
1961
|
-
|
|
1961
|
+
this.scheduleAccountRegistrySync();
|
|
1962
1962
|
this.notificationHandler.success("Successfully signed in");
|
|
1963
1963
|
}
|
|
1964
1964
|
ownedSpaceId(name) {
|
|
@@ -1977,19 +1977,40 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
1977
1977
|
}
|
|
1978
1978
|
const accountSpaceId = this.ownedSpaceId(import_sdk_core7.ACCOUNT_REGISTRY_SPACE);
|
|
1979
1979
|
await this.ensureOwnedSpaceHosted(accountSpaceId);
|
|
1980
|
-
const
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1980
|
+
const result = await this.account.applications.register(request.manifests);
|
|
1981
|
+
if (!result.ok) {
|
|
1982
|
+
throw new Error(
|
|
1983
|
+
`Failed to write manifest registry records: ${result.error.message}`
|
|
1984
|
+
);
|
|
1985
|
+
}
|
|
1986
|
+
}
|
|
1987
|
+
scheduleAccountRegistrySync() {
|
|
1988
|
+
void this.withAccountRegistryRetry(async () => {
|
|
1989
|
+
await this.writeManifestRegistryRecords();
|
|
1990
|
+
const spaces = await this.account.spaces.syncAccessible();
|
|
1991
|
+
if (!spaces.ok) {
|
|
1992
|
+
throw new Error(`Failed to sync account spaces: ${spaces.error.message}`);
|
|
1993
|
+
}
|
|
1994
|
+
});
|
|
1995
|
+
}
|
|
1996
|
+
async withAccountRegistryRetry(task) {
|
|
1997
|
+
const delays = [250, 1e3, 3e3];
|
|
1998
|
+
let lastError;
|
|
1999
|
+
for (let attempt = 0; attempt < delays.length; attempt += 1) {
|
|
2000
|
+
try {
|
|
2001
|
+
await task();
|
|
2002
|
+
return;
|
|
2003
|
+
} catch (error) {
|
|
2004
|
+
lastError = error;
|
|
2005
|
+
if (attempt < delays.length - 1) {
|
|
2006
|
+
await new Promise((resolve) => setTimeout(resolve, delays[attempt]));
|
|
2007
|
+
}
|
|
1991
2008
|
}
|
|
1992
2009
|
}
|
|
2010
|
+
console.warn(
|
|
2011
|
+
"TinyCloud account registry sync failed after retries",
|
|
2012
|
+
lastError
|
|
2013
|
+
);
|
|
1993
2014
|
}
|
|
1994
2015
|
requestedEncryptionNetworkIds() {
|
|
1995
2016
|
const request = this.capabilityRequest;
|
|
@@ -2093,6 +2114,15 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2093
2114
|
`Failed to activate session for owned space ${spaceId}: ${activation.error ?? "space was skipped"}`
|
|
2094
2115
|
);
|
|
2095
2116
|
}
|
|
2117
|
+
void this.account.spaces.register({
|
|
2118
|
+
spaceId,
|
|
2119
|
+
name,
|
|
2120
|
+
ownerDid: this.did,
|
|
2121
|
+
type: "owned",
|
|
2122
|
+
permissions: ["*"],
|
|
2123
|
+
status: "active"
|
|
2124
|
+
}).catch(() => {
|
|
2125
|
+
});
|
|
2096
2126
|
return spaceId;
|
|
2097
2127
|
}
|
|
2098
2128
|
/**
|
|
@@ -2710,6 +2740,9 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2710
2740
|
}
|
|
2711
2741
|
};
|
|
2712
2742
|
}
|
|
2743
|
+
},
|
|
2744
|
+
onSpaceRegistered: async (space) => {
|
|
2745
|
+
await this.account.spaces.register(space);
|
|
2713
2746
|
}
|
|
2714
2747
|
});
|
|
2715
2748
|
this._sharingService.updateConfig({
|