@peers-app/peers-sdk 0.14.0 → 0.15.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.
- package/dist/context/data-context.d.ts +4 -4
- package/dist/context/data-context.js +1 -1
- package/dist/context/index.d.ts +3 -3
- package/dist/context/index.js +4 -0
- package/dist/context/user-context-singleton.js +13 -14
- package/dist/context/user-context.d.ts +4 -4
- package/dist/context/user-context.js +48 -31
- package/dist/data/assistants.d.ts +1 -1
- package/dist/data/assistants.js +35 -24
- package/dist/data/change-tracking.d.ts +8 -8
- package/dist/data/change-tracking.js +45 -39
- package/dist/data/channels.js +5 -5
- package/dist/data/data-locks.d.ts +2 -2
- package/dist/data/data-locks.js +21 -23
- package/dist/data/data-locks.test.js +73 -75
- package/dist/data/device-sync-info.d.ts +1 -1
- package/dist/data/device-sync-info.js +4 -4
- package/dist/data/devices.d.ts +1 -1
- package/dist/data/devices.js +9 -12
- package/dist/data/embeddings.js +14 -11
- package/dist/data/files/file-read-stream.d.ts +2 -2
- package/dist/data/files/file-read-stream.js +23 -14
- package/dist/data/files/file-write-stream.d.ts +2 -2
- package/dist/data/files/file-write-stream.js +8 -8
- package/dist/data/files/file.types.d.ts +2 -2
- package/dist/data/files/file.types.js +17 -11
- package/dist/data/files/files.d.ts +6 -6
- package/dist/data/files/files.js +17 -19
- package/dist/data/files/files.test.js +213 -214
- package/dist/data/files/index.d.ts +4 -4
- package/dist/data/files/index.js +4 -4
- package/dist/data/group-member-roles.js +2 -2
- package/dist/data/group-members.d.ts +5 -5
- package/dist/data/group-members.js +27 -18
- package/dist/data/group-members.test.js +73 -73
- package/dist/data/group-permissions.d.ts +3 -3
- package/dist/data/group-permissions.js +13 -11
- package/dist/data/group-share.d.ts +2 -2
- package/dist/data/group-share.js +29 -24
- package/dist/data/groups.d.ts +4 -4
- package/dist/data/groups.js +27 -19
- package/dist/data/groups.test.js +44 -44
- package/dist/data/index.d.ts +6 -6
- package/dist/data/index.js +6 -6
- package/dist/data/knowledge/peer-types.js +9 -9
- package/dist/data/messages.d.ts +5 -5
- package/dist/data/messages.js +43 -30
- package/dist/data/orm/client-proxy.data-source.d.ts +4 -4
- package/dist/data/orm/client-proxy.data-source.js +10 -12
- package/dist/data/orm/cursor.d.ts +1 -1
- package/dist/data/orm/cursor.js +2 -2
- package/dist/data/orm/cursor.test.js +92 -93
- package/dist/data/orm/data-query.d.ts +3 -3
- package/dist/data/orm/data-query.js +24 -18
- package/dist/data/orm/data-query.mongo.d.ts +1 -1
- package/dist/data/orm/data-query.mongo.js +49 -51
- package/dist/data/orm/data-query.mongo.test.js +173 -204
- package/dist/data/orm/data-query.sqlite.d.ts +1 -1
- package/dist/data/orm/data-query.sqlite.js +84 -73
- package/dist/data/orm/data-query.sqlite.test.js +164 -176
- package/dist/data/orm/data-query.test.js +216 -224
- package/dist/data/orm/decorators.js +3 -3
- package/dist/data/orm/dependency-injection.test.js +53 -56
- package/dist/data/orm/doc.d.ts +4 -4
- package/dist/data/orm/doc.js +17 -21
- package/dist/data/orm/event-registry.d.ts +1 -1
- package/dist/data/orm/event-registry.test.js +16 -16
- package/dist/data/orm/factory.d.ts +2 -2
- package/dist/data/orm/factory.js +33 -33
- package/dist/data/orm/index.d.ts +10 -10
- package/dist/data/orm/index.js +10 -10
- package/dist/data/orm/multi-cursors.d.ts +1 -1
- package/dist/data/orm/multi-cursors.js +6 -6
- package/dist/data/orm/multi-cursors.test.js +152 -144
- package/dist/data/orm/sql.data-source.d.ts +7 -7
- package/dist/data/orm/sql.data-source.js +88 -93
- package/dist/data/orm/sql.data-source.test.js +109 -101
- package/dist/data/orm/subscribable.data-source.d.ts +4 -4
- package/dist/data/orm/subscribable.data-source.js +5 -5
- package/dist/data/orm/table-container-events.test.js +34 -26
- package/dist/data/orm/table-container.d.ts +6 -6
- package/dist/data/orm/table-container.js +33 -21
- package/dist/data/orm/table-container.test.js +64 -53
- package/dist/data/orm/table-definitions.system.d.ts +3 -3
- package/dist/data/orm/table-definitions.system.js +3 -3
- package/dist/data/orm/table-definitions.type.d.ts +5 -5
- package/dist/data/orm/table-dependencies.d.ts +2 -2
- package/dist/data/orm/table.d.ts +5 -5
- package/dist/data/orm/table.event-source.test.js +105 -115
- package/dist/data/orm/table.js +35 -34
- package/dist/data/orm/types.d.ts +3 -3
- package/dist/data/orm/types.js +26 -25
- package/dist/data/orm/types.test.js +166 -92
- package/dist/data/package-permissions.d.ts +1 -1
- package/dist/data/package-permissions.js +2 -2
- package/dist/data/package-version-permissions.d.ts +1 -1
- package/dist/data/package-version-permissions.js +2 -2
- package/dist/data/package-versions.d.ts +9 -9
- package/dist/data/package-versions.js +47 -33
- package/dist/data/packages.d.ts +2 -2
- package/dist/data/packages.js +36 -18
- package/dist/data/packages.utils.d.ts +2 -2
- package/dist/data/packages.utils.js +4 -4
- package/dist/data/persistent-vars.d.ts +15 -15
- package/dist/data/persistent-vars.js +165 -154
- package/dist/data/table-definitions-table.d.ts +5 -5
- package/dist/data/table-definitions-table.js +13 -12
- package/dist/data/tool-tests.js +6 -6
- package/dist/data/tools.js +29 -19
- package/dist/data/user-permissions.d.ts +1 -1
- package/dist/data/user-permissions.js +5 -5
- package/dist/data/user-permissions.test.js +90 -88
- package/dist/data/user-trust-levels.js +10 -10
- package/dist/data/users.d.ts +4 -4
- package/dist/data/users.js +16 -15
- package/dist/data/voice-messages.d.ts +2 -2
- package/dist/data/voice-messages.js +13 -13
- package/dist/data/welcome-modal.pvar.js +3 -1
- package/dist/data/workflow-logs.js +26 -18
- package/dist/data/workflow-runs.d.ts +6 -6
- package/dist/data/workflow-runs.js +70 -44
- package/dist/data/workflows.d.ts +2 -2
- package/dist/data/workflows.js +7 -9
- package/dist/device/binary-peer-connection-v2.d.ts +7 -7
- package/dist/device/binary-peer-connection-v2.js +32 -28
- package/dist/device/binary-peer-connection-v2.test.js +80 -67
- package/dist/device/binary-peer-connection.d.ts +7 -7
- package/dist/device/binary-peer-connection.js +29 -28
- package/dist/device/binary-peer-connection.test.js +35 -31
- package/dist/device/connection.d.ts +5 -5
- package/dist/device/connection.js +59 -48
- package/dist/device/connection.test.js +74 -68
- package/dist/device/device-election.d.ts +2 -2
- package/dist/device/device-election.js +25 -20
- package/dist/device/device-election.test.js +35 -36
- package/dist/device/device.d.ts +2 -2
- package/dist/device/device.js +10 -4
- package/dist/device/device.test.js +16 -17
- package/dist/device/get-trust-level-fn.d.ts +2 -2
- package/dist/device/get-trust-level-fn.js +22 -11
- package/dist/device/get-trust-level-fn.test.js +58 -58
- package/dist/device/socket-io-binary-peer.d.ts +1 -1
- package/dist/device/socket-io-binary-peer.js +16 -13
- package/dist/device/socket.type.d.ts +2 -2
- package/dist/device/streamed-socket.d.ts +2 -2
- package/dist/device/streamed-socket.js +8 -8
- package/dist/device/streamed-socket.test.js +40 -40
- package/dist/device/tx-encoding.test.js +77 -77
- package/dist/events.d.ts +1 -1
- package/dist/events.js +5 -2
- package/dist/group-invite/group-invite.js +110 -19
- package/dist/group-invite/group-invite.pvars.d.ts +2 -2
- package/dist/group-invite/group-invite.pvars.js +21 -13
- package/dist/group-invite/group-invite.types.d.ts +1 -1
- package/dist/group-invite/index.d.ts +3 -3
- package/dist/group-invite/index.js +1 -1
- package/dist/index.d.ts +25 -24
- package/dist/index.js +30 -25
- package/dist/keys.d.ts +3 -3
- package/dist/keys.js +31 -30
- package/dist/keys.test.js +69 -61
- package/dist/logging/console-logger.d.ts +1 -1
- package/dist/logging/console-logger.js +35 -40
- package/dist/logging/console-logger.test.js +115 -115
- package/dist/logging/console-logs.table.d.ts +3 -3
- package/dist/logging/console-logs.table.js +28 -23
- package/dist/mentions.js +16 -12
- package/dist/observable.d.ts +2 -2
- package/dist/observable.js +15 -9
- package/dist/observable.test.js +47 -47
- package/dist/package-loader/get-require.js +3 -4
- package/dist/package-loader/package-loader.d.ts +2 -2
- package/dist/package-loader/package-loader.js +52 -34
- package/dist/peers-ui/peers-ui.d.ts +2 -2
- package/dist/peers-ui/peers-ui.js +2 -4
- package/dist/peers-ui/peers-ui.types.d.ts +3 -3
- package/dist/peers-ui/peers-ui.types.js +0 -1
- package/dist/rpc-types.d.ts +61 -59
- package/dist/rpc-types.js +61 -55
- package/dist/serial-json.d.ts +1 -1
- package/dist/serial-json.js +50 -43
- package/dist/serial-json.test.js +22 -22
- package/dist/system-ids.js +8 -8
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/tools-factory.d.ts +1 -1
- package/dist/tools/tools-factory.js +2 -2
- package/dist/types/assistant-runner-args.d.ts +3 -3
- package/dist/types/peer-device.d.ts +1 -1
- package/dist/types/peers-package.d.ts +3 -3
- package/dist/types/workflow-logger.d.ts +1 -1
- package/dist/types/workflow-run-context.d.ts +4 -4
- package/dist/types/workflow.d.ts +4 -4
- package/dist/types/workflow.js +27 -14
- package/dist/types/zod-types.d.ts +2 -1
- package/dist/types/zod-types.js +9 -3
- package/dist/user-connect/connection-code.d.ts +1 -1
- package/dist/user-connect/connection-code.js +7 -7
- package/dist/user-connect/connection-code.test.js +106 -106
- package/dist/user-connect/index.d.ts +3 -3
- package/dist/user-connect/index.js +1 -1
- package/dist/user-connect/user-connect.pvars.js +13 -11
- package/dist/user-connect/user-connect.types.d.ts +3 -3
- package/dist/users.query.d.ts +2 -2
- package/dist/users.query.js +40 -30
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +34 -32
- package/dist/utils.test.js +12 -8
- package/dist/workflow-log-formatter.d.ts +1 -1
- package/dist/workflow-log-formatter.js +17 -18
- package/package.json +14 -8
|
@@ -52,28 +52,31 @@ const types_1 = require("./orm/types");
|
|
|
52
52
|
const package_version_permissions_1 = require("./package-version-permissions");
|
|
53
53
|
const schema = zod_1.z.object({
|
|
54
54
|
packageVersionId: zod_types_1.zodPeerId,
|
|
55
|
-
packageId: zod_types_1.zodPeerId.describe(
|
|
55
|
+
packageId: zod_types_1.zodPeerId.describe("The package this version belongs to"),
|
|
56
56
|
version: zod_1.z.string().describe('Semantic version string (e.g., "1.0.0")'),
|
|
57
57
|
versionTag: zod_1.z.string().optional().describe('Version tag (e.g., "stable", "beta")'),
|
|
58
|
-
packageVersionHash: zod_1.z.string().describe(
|
|
59
|
-
packageBundleFileId: zod_types_1.zodPeerId.describe(
|
|
60
|
-
packageBundleFileHash: zod_1.z.string().describe(
|
|
61
|
-
routesBundleFileId: zod_types_1.zodPeerId.optional().describe(
|
|
62
|
-
routesBundleFileHash: zod_1.z.string().optional().describe(
|
|
63
|
-
uiBundleFileId: zod_types_1.zodPeerId.optional().describe(
|
|
64
|
-
uiBundleFileHash: zod_1.z.string().optional().describe(
|
|
65
|
-
appNavs: app_nav_1.appNavSchema
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
58
|
+
packageVersionHash: zod_1.z.string().describe("Hash of the combined bundle file hashes"),
|
|
59
|
+
packageBundleFileId: zod_types_1.zodPeerId.describe("File ID of the package bundle"),
|
|
60
|
+
packageBundleFileHash: zod_1.z.string().describe("Hash of the package bundle file"),
|
|
61
|
+
routesBundleFileId: zod_types_1.zodPeerId.optional().describe("File ID of the routes bundle"),
|
|
62
|
+
routesBundleFileHash: zod_1.z.string().optional().describe("Hash of the routes bundle"),
|
|
63
|
+
uiBundleFileId: zod_types_1.zodPeerId.optional().describe("File ID of the UI bundle"),
|
|
64
|
+
uiBundleFileHash: zod_1.z.string().optional().describe("Hash of the UI bundle"),
|
|
65
|
+
appNavs: app_nav_1.appNavSchema
|
|
66
|
+
.array()
|
|
67
|
+
.optional()
|
|
68
|
+
.describe("The app navigation items that this version provides"),
|
|
69
|
+
signature: zod_1.z.string().describe("The signed hash of this data excluding the signature itself"),
|
|
70
|
+
createdBy: zod_types_1.zodPeerId.describe("The user who created this version"),
|
|
71
|
+
createdAt: zod_1.z.string().describe("ISO timestamp of when this version was created"),
|
|
69
72
|
});
|
|
70
73
|
const metaData = {
|
|
71
|
-
name:
|
|
72
|
-
description:
|
|
73
|
-
primaryKeyName:
|
|
74
|
-
iconClassName:
|
|
74
|
+
name: "PackageVersions",
|
|
75
|
+
description: "Versioned builds of packages",
|
|
76
|
+
primaryKeyName: "packageVersionId",
|
|
77
|
+
iconClassName: "bi bi-tag-fill",
|
|
75
78
|
fields: (0, types_1.schemaToFields)(schema),
|
|
76
|
-
indexes: [{ fields: [
|
|
79
|
+
indexes: [{ fields: ["packageId"] }],
|
|
77
80
|
};
|
|
78
81
|
let PackageVersionsTable = (() => {
|
|
79
82
|
let _classSuper = table_1.Table;
|
|
@@ -105,20 +108,22 @@ let PackageVersionsTable = (() => {
|
|
|
105
108
|
await (0, package_version_permissions_1.verifyPackageVersionSignature)(packageVersion, this.groupId);
|
|
106
109
|
}
|
|
107
110
|
catch (err) {
|
|
108
|
-
throw new Error(
|
|
111
|
+
throw new Error("Package version verification failed. Did you mean to call `signAndSave`?", {
|
|
112
|
+
cause: err,
|
|
113
|
+
});
|
|
109
114
|
}
|
|
110
115
|
return super.save(packageVersion, opts);
|
|
111
116
|
}
|
|
112
117
|
async signAndSave(packageVersion, opts) {
|
|
113
118
|
if (!PackageVersionsTable.addSignatureToPackageVersion) {
|
|
114
|
-
throw new Error(
|
|
119
|
+
throw new Error("Package version signing is not enabled. Call PackageVersionsTable.enablePackageVersionSigning(fn) to enable it.");
|
|
115
120
|
}
|
|
116
121
|
packageVersion = await PackageVersionsTable.addSignatureToPackageVersion(packageVersion);
|
|
117
122
|
return super.save(packageVersion, opts);
|
|
118
123
|
}
|
|
119
124
|
static addSignatureToPackageVersion = undefined;
|
|
120
125
|
static enablePackageVersionSigning(fn) {
|
|
121
|
-
|
|
126
|
+
PackageVersionsTable.addSignatureToPackageVersion = fn;
|
|
122
127
|
}
|
|
123
128
|
constructor() {
|
|
124
129
|
super(...arguments);
|
|
@@ -135,18 +140,24 @@ function PackageVersions(dataContext) {
|
|
|
135
140
|
* Compute a hash combining the bundle file hashes to uniquely identify this version's content.
|
|
136
141
|
*/
|
|
137
142
|
function computePackageVersionHash(version, versionTag, packageBundleFileHash, routesBundleFileHash, uiBundleFileHash) {
|
|
138
|
-
return (0, keys_1.hashValue)([
|
|
143
|
+
return (0, keys_1.hashValue)([
|
|
144
|
+
version,
|
|
145
|
+
versionTag,
|
|
146
|
+
packageBundleFileHash,
|
|
147
|
+
routesBundleFileHash ?? "",
|
|
148
|
+
uiBundleFileHash ?? "",
|
|
149
|
+
].join(":"));
|
|
139
150
|
}
|
|
140
151
|
function isVersionInRange(activeVersion, incomingVersion, range) {
|
|
141
|
-
if (range ===
|
|
152
|
+
if (range === "pinned")
|
|
142
153
|
return false;
|
|
143
|
-
if (range ===
|
|
154
|
+
if (range === "latest")
|
|
144
155
|
return true;
|
|
145
|
-
const [aMaj, aMin] = activeVersion.split(
|
|
146
|
-
const [iMaj, iMin] = incomingVersion.split(
|
|
147
|
-
if (range ===
|
|
156
|
+
const [aMaj, aMin] = activeVersion.split(".").map(Number);
|
|
157
|
+
const [iMaj, iMin] = incomingVersion.split(".").map(Number);
|
|
158
|
+
if (range === "patch")
|
|
148
159
|
return aMaj === iMaj && aMin === iMin;
|
|
149
|
-
if (range ===
|
|
160
|
+
if (range === "minor")
|
|
150
161
|
return aMaj === iMaj;
|
|
151
162
|
return false;
|
|
152
163
|
}
|
|
@@ -154,8 +165,8 @@ function isVersionInRange(activeVersion, incomingVersion, range) {
|
|
|
154
165
|
* Returns true if incomingVersion is strictly newer than activeVersion (semver comparison).
|
|
155
166
|
*/
|
|
156
167
|
function isNewerVersion(activeVersion, incomingVersion) {
|
|
157
|
-
const [aMaj = 0, aMin = 0, aPat = 0] = activeVersion.split(
|
|
158
|
-
const [iMaj = 0, iMin = 0, iPat = 0] = incomingVersion.split(
|
|
168
|
+
const [aMaj = 0, aMin = 0, aPat = 0] = activeVersion.split(".").map(Number);
|
|
169
|
+
const [iMaj = 0, iMin = 0, iPat = 0] = incomingVersion.split(".").map(Number);
|
|
159
170
|
if (iMaj !== aMaj)
|
|
160
171
|
return iMaj > aMaj;
|
|
161
172
|
if (iMin !== aMin)
|
|
@@ -163,13 +174,16 @@ function isNewerVersion(activeVersion, incomingVersion) {
|
|
|
163
174
|
return iPat > aPat;
|
|
164
175
|
}
|
|
165
176
|
function doesTagMatch(activeVersionTag, incomingVersionTag, followVersionTags, deviceVersionTag) {
|
|
166
|
-
const inTag = incomingVersionTag ||
|
|
177
|
+
const inTag = incomingVersionTag || "stable";
|
|
167
178
|
if (deviceVersionTag)
|
|
168
179
|
return inTag === deviceVersionTag;
|
|
169
180
|
if (!followVersionTags) {
|
|
170
|
-
return inTag === (activeVersionTag ||
|
|
181
|
+
return inTag === (activeVersionTag || "stable");
|
|
171
182
|
}
|
|
172
|
-
if (followVersionTags ===
|
|
183
|
+
if (followVersionTags === "*")
|
|
173
184
|
return true;
|
|
174
|
-
return followVersionTags
|
|
185
|
+
return followVersionTags
|
|
186
|
+
.split(",")
|
|
187
|
+
.map((t) => t.trim())
|
|
188
|
+
.includes(inTag);
|
|
175
189
|
}
|
package/dist/data/packages.d.ts
CHANGED
|
@@ -33,8 +33,8 @@ declare const schema: z.ZodObject<{
|
|
|
33
33
|
name: string;
|
|
34
34
|
description: string;
|
|
35
35
|
signature: string;
|
|
36
|
-
createdBy: string;
|
|
37
36
|
packageId: string;
|
|
37
|
+
createdBy: string;
|
|
38
38
|
disabled?: boolean | undefined;
|
|
39
39
|
appNavs?: {
|
|
40
40
|
name: string;
|
|
@@ -50,8 +50,8 @@ declare const schema: z.ZodObject<{
|
|
|
50
50
|
name: string;
|
|
51
51
|
description: string;
|
|
52
52
|
signature: string;
|
|
53
|
-
createdBy: string;
|
|
54
53
|
packageId: string;
|
|
54
|
+
createdBy: string;
|
|
55
55
|
disabled?: boolean | undefined;
|
|
56
56
|
appNavs?: {
|
|
57
57
|
name: string;
|
package/dist/data/packages.js
CHANGED
|
@@ -50,20 +50,34 @@ const schema = zod_1.z.object({
|
|
|
50
50
|
packageId: zod_types_1.zodPeerId,
|
|
51
51
|
name: zod_1.z.string(),
|
|
52
52
|
description: zod_1.z.string(),
|
|
53
|
-
createdBy: zod_types_1.zodPeerId.describe(
|
|
54
|
-
disabled: zod_1.z
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
createdBy: zod_types_1.zodPeerId.describe("The user who created the package"),
|
|
54
|
+
disabled: zod_1.z
|
|
55
|
+
.boolean()
|
|
56
|
+
.optional()
|
|
57
|
+
.describe("Whether the package's components should be loaded and included in the app runtime"),
|
|
58
|
+
remoteRepo: zod_1.z.string().optional().describe("The remote repository where the package is stored"),
|
|
59
|
+
appNavs: app_nav_1.appNavSchema
|
|
60
|
+
.array()
|
|
61
|
+
.optional()
|
|
62
|
+
.describe("The app navigation items that this package provides"),
|
|
63
|
+
activePackageVersionId: zod_types_1.zodPeerId
|
|
64
|
+
.optional()
|
|
65
|
+
.describe("FK to PackageVersions — the currently active version"),
|
|
66
|
+
versionFollowRange: zod_1.z
|
|
67
|
+
.enum(["pinned", "patch", "minor", "latest"])
|
|
68
|
+
.optional()
|
|
69
|
+
.describe("Auto-update range: pinned=never, patch=same major.minor, minor=same major, latest=always"),
|
|
70
|
+
followVersionTags: zod_1.z
|
|
71
|
+
.string()
|
|
72
|
+
.optional()
|
|
73
|
+
.describe('Tag policy: undefined="current" (follow active tag), "*"=any tag, or CSV like "stable,prod"'),
|
|
74
|
+
signature: zod_1.z.string().describe("The signed hash of this data excluding the signature itself"),
|
|
61
75
|
});
|
|
62
76
|
const metaData = {
|
|
63
|
-
name:
|
|
64
|
-
description:
|
|
65
|
-
primaryKeyName:
|
|
66
|
-
iconClassName:
|
|
77
|
+
name: "Packages",
|
|
78
|
+
description: "The Peers packages that this computer is aware of (some may be disabled)",
|
|
79
|
+
primaryKeyName: "packageId",
|
|
80
|
+
iconClassName: "bi bi-box-fill",
|
|
67
81
|
fields: (0, types_1.schemaToFields)(schema),
|
|
68
82
|
};
|
|
69
83
|
let PackagesTable = (() => {
|
|
@@ -96,20 +110,22 @@ let PackagesTable = (() => {
|
|
|
96
110
|
await (0, package_permissions_1.verifyPackageSignature)(packageObj, this.groupId);
|
|
97
111
|
}
|
|
98
112
|
catch (err) {
|
|
99
|
-
throw new Error(
|
|
113
|
+
throw new Error("Package verification failed. Did you mean to call `signAndSave`?", {
|
|
114
|
+
cause: err,
|
|
115
|
+
});
|
|
100
116
|
}
|
|
101
117
|
return super.save(packageObj, opts);
|
|
102
118
|
}
|
|
103
119
|
async signAndSave(packageObj, opts) {
|
|
104
120
|
if (!PackagesTable.addSignatureToPackage) {
|
|
105
|
-
throw new Error(
|
|
121
|
+
throw new Error("Package signing is not enabled. Call PackagesTable.enablePackageSigning(fn) to enable it.");
|
|
106
122
|
}
|
|
107
123
|
packageObj = await PackagesTable.addSignatureToPackage(packageObj);
|
|
108
124
|
return super.save(packageObj, opts);
|
|
109
125
|
}
|
|
110
126
|
static addSignatureToPackage = undefined;
|
|
111
127
|
static enablePackageSigning(fn) {
|
|
112
|
-
|
|
128
|
+
PackagesTable.addSignatureToPackage = fn;
|
|
113
129
|
}
|
|
114
130
|
async delete(packageId) {
|
|
115
131
|
// anyone (with write permissions) can delete packages since that isn't a security risk (unless something else is relying on a package to be present?)
|
|
@@ -132,6 +148,8 @@ exports.PackagesTable = PackagesTable;
|
|
|
132
148
|
function Packages(dataContext) {
|
|
133
149
|
return (0, context_1.getTableContainer)(dataContext).getTable(metaData, schema, PackagesTable);
|
|
134
150
|
}
|
|
135
|
-
exports.packagesRootDir =
|
|
136
|
-
exports.reloadPackagesOnPageRefresh = (0, persistent_vars_1.deviceVar)(
|
|
137
|
-
|
|
151
|
+
exports.packagesRootDir = "~/peers/packages";
|
|
152
|
+
exports.reloadPackagesOnPageRefresh = (0, persistent_vars_1.deviceVar)("reloadPackagesOnPageRefresh", {
|
|
153
|
+
defaultValue: true,
|
|
154
|
+
});
|
|
155
|
+
exports.autoUpdatePeersCore = (0, persistent_vars_1.deviceVar)("autoUpdatePeersCore", { defaultValue: true });
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { DataContext } from "../context/data-context";
|
|
2
|
+
import { type IPackage } from "./packages";
|
|
3
3
|
export declare function copyPackageToAnotherDataContext(packageId: string, fromDataContext: DataContext, toDataContext: DataContext): Promise<IPackage>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.copyPackageToAnotherDataContext = copyPackageToAnotherDataContext;
|
|
4
|
-
const packages_1 = require("./packages");
|
|
5
4
|
const files_1 = require("./files");
|
|
6
5
|
const package_versions_1 = require("./package-versions");
|
|
6
|
+
const packages_1 = require("./packages");
|
|
7
7
|
async function copyBundleFile(fileId, fromFiles, toFiles, label) {
|
|
8
8
|
if (!fileId)
|
|
9
9
|
return;
|
|
@@ -29,9 +29,9 @@ async function copyPackageToAnotherDataContext(packageId, fromDataContext, toDat
|
|
|
29
29
|
const toPvTable = (0, package_versions_1.PackageVersions)(toDataContext);
|
|
30
30
|
const pv = await fromPvTable.get(pkg.activePackageVersionId);
|
|
31
31
|
if (pv) {
|
|
32
|
-
await copyBundleFile(pv.packageBundleFileId, fromFiles, toFiles,
|
|
33
|
-
await copyBundleFile(pv.routesBundleFileId, fromFiles, toFiles,
|
|
34
|
-
await copyBundleFile(pv.uiBundleFileId, fromFiles, toFiles,
|
|
32
|
+
await copyBundleFile(pv.packageBundleFileId, fromFiles, toFiles, "Version package bundle");
|
|
33
|
+
await copyBundleFile(pv.routesBundleFileId, fromFiles, toFiles, "Version routes bundle");
|
|
34
|
+
await copyBundleFile(pv.uiBundleFileId, fromFiles, toFiles, "Version UI bundle");
|
|
35
35
|
await toPvTable.signAndSave(pv, { saveAsSnapshot: true });
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
* (requires SQLite which is not available in peers-sdk)
|
|
6
6
|
*/
|
|
7
7
|
import { z } from "zod";
|
|
8
|
-
import { UserContext } from "../context";
|
|
8
|
+
import type { UserContext } from "../context";
|
|
9
9
|
import type { DataContext } from "../context/data-context";
|
|
10
|
-
import { Observable } from "../observable";
|
|
11
|
-
import { ISaveOptions } from "./orm";
|
|
10
|
+
import { type Observable } from "../observable";
|
|
11
|
+
import type { ISaveOptions } from "./orm";
|
|
12
12
|
import { Table } from "./orm/table";
|
|
13
|
-
import { ITableMetaData } from "./orm/types";
|
|
13
|
+
import { type ITableMetaData } from "./orm/types";
|
|
14
14
|
declare const schema: z.ZodObject<{
|
|
15
15
|
persistentVarId: z.ZodEffects<z.ZodString, string, string>;
|
|
16
16
|
name: z.ZodString;
|
|
@@ -65,7 +65,7 @@ export type PersistentVar<T> = Observable<T> & {
|
|
|
65
65
|
};
|
|
66
66
|
export declare function getPersistentVar(name: string, dataContext?: DataContext): Promise<IPersistentVar | undefined>;
|
|
67
67
|
interface IPersistentVarOptionsBase {
|
|
68
|
-
scope?:
|
|
68
|
+
scope?: "device" | "user" | "group" | "groupDevice" | "groupUser";
|
|
69
69
|
userContext?: UserContext;
|
|
70
70
|
dataContext?: DataContext;
|
|
71
71
|
isSecret?: boolean;
|
|
@@ -81,30 +81,30 @@ interface IPersistentVarOptionsWithoutDefault<T> extends IPersistentVarOptionsBa
|
|
|
81
81
|
/**
|
|
82
82
|
* A persistent variable that is stored only on this device, in the user's personal db
|
|
83
83
|
*/
|
|
84
|
-
export declare function deviceVar<T = string>(name: string, opts: Omit<IPersistentVarOptionsWithDefault<T>,
|
|
85
|
-
export declare function deviceVar<T = string>(name: string, opts?: Omit<IPersistentVarOptionsWithoutDefault<T>,
|
|
84
|
+
export declare function deviceVar<T = string>(name: string, opts: Omit<IPersistentVarOptionsWithDefault<T>, "scope" | "dataContext">): PersistentVar<T>;
|
|
85
|
+
export declare function deviceVar<T = string>(name: string, opts?: Omit<IPersistentVarOptionsWithoutDefault<T>, "scope" | "dataContext">): PersistentVar<T | undefined>;
|
|
86
86
|
/**
|
|
87
87
|
* A persistent variable that is stored in the user's personal db and synced across all their devices
|
|
88
88
|
*/
|
|
89
|
-
export declare function userVar<T = string>(name: string, opts: Omit<IPersistentVarOptionsWithDefault<T>,
|
|
90
|
-
export declare function userVar<T = string>(name: string, opts?: Omit<IPersistentVarOptionsWithoutDefault<T>,
|
|
89
|
+
export declare function userVar<T = string>(name: string, opts: Omit<IPersistentVarOptionsWithDefault<T>, "scope" | "dataContext">): PersistentVar<T>;
|
|
90
|
+
export declare function userVar<T = string>(name: string, opts?: Omit<IPersistentVarOptionsWithoutDefault<T>, "scope" | "dataContext">): PersistentVar<T | undefined>;
|
|
91
91
|
/**
|
|
92
92
|
* A persistent variable that is shared by all users in a group. It is stored in the group's db and synced across all users and devices in the group.
|
|
93
93
|
* It can have a different value for each group on the device.
|
|
94
94
|
* If secret=true, it is encrypted with the group's secret key
|
|
95
95
|
*/
|
|
96
|
-
export declare function groupVar<T = string>(name: string, opts: Omit<IPersistentVarOptionsWithDefault<T>,
|
|
97
|
-
export declare function groupVar<T = string>(name: string, opts?: Omit<IPersistentVarOptionsWithoutDefault<T>,
|
|
96
|
+
export declare function groupVar<T = string>(name: string, opts: Omit<IPersistentVarOptionsWithDefault<T>, "scope">): PersistentVar<T>;
|
|
97
|
+
export declare function groupVar<T = string>(name: string, opts?: Omit<IPersistentVarOptionsWithoutDefault<T>, "scope">): PersistentVar<T | undefined>;
|
|
98
98
|
/**
|
|
99
99
|
* A persistent variable that is stored only on this device, in the user's personal db.
|
|
100
100
|
* It can have a different value for each group on the device but is not synced to other devices.
|
|
101
101
|
*/
|
|
102
|
-
export declare function groupDeviceVar<T = string>(name: string, opts: Omit<IPersistentVarOptionsWithDefault<T>,
|
|
103
|
-
export declare function groupDeviceVar<T = string>(name: string, opts?: Omit<IPersistentVarOptionsWithoutDefault<T>,
|
|
102
|
+
export declare function groupDeviceVar<T = string>(name: string, opts: Omit<IPersistentVarOptionsWithDefault<T>, "scope">): PersistentVar<T>;
|
|
103
|
+
export declare function groupDeviceVar<T = string>(name: string, opts?: Omit<IPersistentVarOptionsWithoutDefault<T>, "scope">): PersistentVar<T | undefined>;
|
|
104
104
|
/**
|
|
105
105
|
* A persistent variable that is stored in the user's personal db and synced across all their devices in the group.
|
|
106
106
|
* It can have a different value for each user in the group and a different value for each group the user is in.
|
|
107
107
|
*/
|
|
108
|
-
export declare function groupUserVar<T = string>(name: string, opts: Omit<IPersistentVarOptionsWithDefault<T>,
|
|
109
|
-
export declare function groupUserVar<T = string>(name: string, opts?: Omit<IPersistentVarOptionsWithoutDefault<T>,
|
|
108
|
+
export declare function groupUserVar<T = string>(name: string, opts: Omit<IPersistentVarOptionsWithDefault<T>, "scope">): PersistentVar<T>;
|
|
109
|
+
export declare function groupUserVar<T = string>(name: string, opts?: Omit<IPersistentVarOptionsWithoutDefault<T>, "scope">): PersistentVar<T | undefined>;
|
|
110
110
|
export {};
|