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