@mblaney/holster 1.0.23 → 1.0.24

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mblaney/holster",
3
- "version": "1.0.23",
3
+ "version": "1.0.24",
4
4
  "description": "Holster is a service that allows synchronising data between devices using Node, Deno, Bun or the browser.",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/src/user.js CHANGED
@@ -72,49 +72,36 @@ const User = (opt, wire) => {
72
72
  return
73
73
  }
74
74
 
75
- // Migrate old per-node signatures to per-property signatures
76
- // Check if data has per-property signatures
77
- if (
78
- !data._ ||
79
- !data._["s"] ||
80
- Object.keys(data._["s"]).length === 0
81
- ) {
82
- // Data has old per-node signatures, migrate to per-property
83
- // Copy all properties from existing data, excluding metadata
84
- const migrationData = {}
85
- for (const key of Object.keys(data)) {
86
- if (
87
- key !== "_" &&
88
- key !== userPublicKey &&
89
- key !== userSignature
90
- ) {
91
- migrationData[key] = data[key]
92
- }
75
+ // TODO: Remove this migration once all peers have updated to the new
76
+ // version and have received per-property signatures. This temporarily
77
+ // broadcasts signed data on every login to ensure new peers can
78
+ // persist it.
79
+ const migrationData = {}
80
+ for (const key of Object.keys(data)) {
81
+ if (key !== "_" && key !== userPublicKey && key !== userSignature) {
82
+ migrationData[key] = data[key]
93
83
  }
94
- // Sign each property individually
95
- const propertySignatures = await SEA.signProperties(
96
- migrationData,
97
- user.is,
98
- )
99
- const graph = utils.graph(
100
- pub,
101
- migrationData,
102
- propertySignatures,
103
- data.pub,
104
- )
105
- wire.put(graph, err => {
106
- if (err) {
107
- // Log migration error but don't fail authentication
108
- console.log(
109
- `warning: failed to migrate signatures on login: ${err}`,
110
- )
111
- }
112
- done(null)
113
- })
114
- return
115
84
  }
116
-
117
- return done(null)
85
+ // Sign each property individually
86
+ const propertySignatures = await SEA.signProperties(
87
+ migrationData,
88
+ user.is,
89
+ )
90
+ const graph = utils.graph(
91
+ pub,
92
+ migrationData,
93
+ propertySignatures,
94
+ data.pub,
95
+ )
96
+ wire.put(graph, err => {
97
+ if (err) {
98
+ // Log migration error but don't fail authentication
99
+ console.log(
100
+ `warning: failed to migrate signatures on login: ${err}`,
101
+ )
102
+ }
103
+ done(null)
104
+ })
118
105
  },
119
106
  {wait: 5000},
120
107
  )