From 45e0b998caf547d6e212e79462be71d9396abf95 Mon Sep 17 00:00:00 2001 From: Diane Huxley Date: Thu, 2 Nov 2023 14:22:54 -0700 Subject: [PATCH 1/4] Bump dwn-sdk-js to v0.2.5 --- package-lock.json | 31 ++++++++++++++++++++++--------- package.json | 2 +- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 63ed2a2..fb82ee5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "Apache-2.0", "dependencies": { "@ipld/dag-cbor": "^9.0.5", - "@tbd54566975/dwn-sdk-js": "0.2.4", + "@tbd54566975/dwn-sdk-js": "0.2.5", "kysely": "0.26.3", "multiformats": "12.0.1", "readable-stream": "4.4.2" @@ -705,6 +705,14 @@ "npm": ">=7.0.0" } }, + "node_modules/@noble/ciphers": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@noble/ciphers/-/ciphers-0.3.0.tgz", + "integrity": "sha512-ldbrnOjmNRwFdXcTM6uXDcxpMIFrbzAWNnpBPp4oTJTFF0XByGD6vf45WrehZGXRQTRVV+Zm8YP+EgEf+e4cWA==", + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/@noble/curves": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.2.0.tgz", @@ -884,9 +892,9 @@ "dev": true }, "node_modules/@tbd54566975/dwn-sdk-js": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/@tbd54566975/dwn-sdk-js/-/dwn-sdk-js-0.2.4.tgz", - "integrity": "sha512-d2/8o0sA+kNqyyFovReyviczABPyi5wPNuaS7oPojrmMDN2GC+okifF/rqr4qO393Dk/m07ngk8eXnPPk/oiMQ==", + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/@tbd54566975/dwn-sdk-js/-/dwn-sdk-js-0.2.5.tgz", + "integrity": "sha512-IZYcCLKjGz6qtUcEymM1uZc9RmQCHbcfSyAwPB5IAnOKCuktw2Gr3wXoIvePAif+A+/9qMBc6aJWrrPzecbTKg==", "dependencies": { "@ipld/dag-cbor": "9.0.3", "@js-temporal/polyfill": "0.4.4", @@ -896,7 +904,7 @@ "ajv": "8.12.0", "blockstore-core": "4.2.0", "cross-fetch": "4.0.0", - "eciesjs": "0.4.0", + "eciesjs": "0.4.5", "flat": "5.0.2", "interface-blockstore": "5.2.3", "interface-store": "5.1.2", @@ -2152,11 +2160,16 @@ "dev": true }, "node_modules/eciesjs": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/eciesjs/-/eciesjs-0.4.0.tgz", - "integrity": "sha512-z4dEeaH16xxYVgtxJ8YVwpifH4Keg4gyp5F451mnDNwbAN3MgL5jcoEQGpqJrapv/zW8KwDnXG21Dw5B0hqvmw==", + "version": "0.4.5", + "resolved": "https://registry.npmjs.org/eciesjs/-/eciesjs-0.4.5.tgz", + "integrity": "sha512-2zSRIygO48LpdS95Rwt9ryIkJNO37IdbkjRsnYyAn7gx7e4WPBNimnk6jGNdx2QQYr/VJRPnSVdwQpO5bycYZw==", "dependencies": { - "@noble/curves": "^1.1.0" + "@noble/ciphers": "^0.3.0", + "@noble/curves": "^1.2.0", + "@noble/hashes": "^1.3.2" + }, + "engines": { + "node": ">=16.0.0" } }, "node_modules/emoji-regex": { diff --git a/package.json b/package.json index fe2a92e..0b8e716 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "react-native": "./dist/esm/src/main.js", "dependencies": { "@ipld/dag-cbor": "^9.0.5", - "@tbd54566975/dwn-sdk-js": "0.2.4", + "@tbd54566975/dwn-sdk-js": "0.2.5", "kysely": "0.26.3", "multiformats": "12.0.1", "readable-stream": "4.4.2" From 9220e0903c7dbedeea17c1b27a4b308f776c3315 Mon Sep 17 00:00:00 2001 From: Diane Huxley Date: Thu, 2 Nov 2023 14:23:56 -0700 Subject: [PATCH 2/4] Bump package version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index fb82ee5..10010d4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@tbd54566975/dwn-sql-store", - "version": "0.2.1", + "version": "0.2.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@tbd54566975/dwn-sql-store", - "version": "0.2.1", + "version": "0.2.2", "license": "Apache-2.0", "dependencies": { "@ipld/dag-cbor": "^9.0.5", diff --git a/package.json b/package.json index 0b8e716..499f1a4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tbd54566975/dwn-sql-store", - "version": "0.2.1", + "version": "0.2.2", "description": "SQL backed implementations of DWN MessageStore, DataStore, and EventLog", "type": "module", "license": "Apache-2.0", From 3b1cfa4efc612eb389600499d21485117e458210 Mon Sep 17 00:00:00 2001 From: Diane Huxley Date: Mon, 6 Nov 2023 14:36:44 -0800 Subject: [PATCH 3/4] Bump to v0.2.6 --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 10010d4..93e77d9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "Apache-2.0", "dependencies": { "@ipld/dag-cbor": "^9.0.5", - "@tbd54566975/dwn-sdk-js": "0.2.5", + "@tbd54566975/dwn-sdk-js": "0.2.6", "kysely": "0.26.3", "multiformats": "12.0.1", "readable-stream": "4.4.2" @@ -892,9 +892,9 @@ "dev": true }, "node_modules/@tbd54566975/dwn-sdk-js": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/@tbd54566975/dwn-sdk-js/-/dwn-sdk-js-0.2.5.tgz", - "integrity": "sha512-IZYcCLKjGz6qtUcEymM1uZc9RmQCHbcfSyAwPB5IAnOKCuktw2Gr3wXoIvePAif+A+/9qMBc6aJWrrPzecbTKg==", + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/@tbd54566975/dwn-sdk-js/-/dwn-sdk-js-0.2.6.tgz", + "integrity": "sha512-q9HjMhW9KyUD94XVjuO4N+tkeZaOsgtRINIioMKucuZZTCb8Z2lilUleZqc7LiVePCMzlqdRBVeJpMKbnAGj8Q==", "dependencies": { "@ipld/dag-cbor": "9.0.3", "@js-temporal/polyfill": "0.4.4", diff --git a/package.json b/package.json index 499f1a4..296236b 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "react-native": "./dist/esm/src/main.js", "dependencies": { "@ipld/dag-cbor": "^9.0.5", - "@tbd54566975/dwn-sdk-js": "0.2.5", + "@tbd54566975/dwn-sdk-js": "0.2.6", "kysely": "0.26.3", "multiformats": "12.0.1", "readable-stream": "4.4.2" From f982683871eee065920ae2666c13191d5e06b2d9 Mon Sep 17 00:00:00 2001 From: Liran Cohen Date: Mon, 6 Nov 2023 20:27:44 -0500 Subject: [PATCH 4/4] sanitized values accepts strings or numbers --- src/database.ts | 2 +- src/message-store-sql.ts | 2 +- src/utils/filter.ts | 12 ++++++------ src/utils/sanitize.ts | 8 +++++--- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/database.ts b/src/database.ts index 5159162..aad7723 100644 --- a/src/database.ts +++ b/src/database.ts @@ -17,7 +17,7 @@ export interface MessageStoreTable { method: string | null; schema: string | null; dataCid: string | null; - dataSize: string | null; + dataSize: number | null; dateCreated: string | null; messageTimestamp: string | null; dataFormat: string | null; diff --git a/src/message-store-sql.ts b/src/message-store-sql.ts index 38aa6e5..3af72a5 100644 --- a/src/message-store-sql.ts +++ b/src/message-store-sql.ts @@ -46,7 +46,7 @@ export class MessageStoreSql implements MessageStore { .addColumn('method', 'text') .addColumn('schema', 'text') .addColumn('dataCid', 'text') - .addColumn('dataSize', 'text') + .addColumn('dataSize', 'integer') .addColumn('dateCreated', 'text') .addColumn('messageTimestamp', 'text') .addColumn('dataFormat', 'text') diff --git a/src/utils/filter.ts b/src/utils/filter.ts index 56e4485..3f7be13 100644 --- a/src/utils/filter.ts +++ b/src/utils/filter.ts @@ -1,6 +1,6 @@ import { Filter } from '@tbd54566975/dwn-sdk-js'; import { DynamicModule, ExpressionBuilder, OperandExpression, SelectQueryBuilder, SqlBool } from 'kysely'; -import { sanitizedString } from './sanitize.js'; +import { sanitizedValue } from './sanitize.js'; /** * Takes multiple Filters and returns a single query. @@ -48,19 +48,19 @@ function processFilter( andOperands.push(eb(column, 'in', value)); } else if (typeof value === 'object') { // RangeFilter if (value.gt) { - andOperands.push(eb(column, '>', sanitizedString(value.gt))); + andOperands.push(eb(column, '>', sanitizedValue(value.gt))); } if (value.gte) { - andOperands.push(eb(column, '>=', sanitizedString(value.gte))); + andOperands.push(eb(column, '>=', sanitizedValue(value.gte))); } if (value.lt) { - andOperands.push(eb(column, '<', sanitizedString(value.lt))); + andOperands.push(eb(column, '<', sanitizedValue(value.lt))); } if (value.lte) { - andOperands.push(eb(column, '<=', sanitizedString(value.lte))); + andOperands.push(eb(column, '<=', sanitizedValue(value.lte))); } } else { // EqualFilter - andOperands.push(eb(column, '=', sanitizedString(value))); + andOperands.push(eb(column, '=', sanitizedValue(value))); } } diff --git a/src/utils/sanitize.ts b/src/utils/sanitize.ts index 867b149..20101e5 100644 --- a/src/utils/sanitize.ts +++ b/src/utils/sanitize.ts @@ -1,13 +1,15 @@ -export function sanitizeRecords(records: Record) { +export function sanitizeRecords(records: Record) { for (let key in records) { let value = records[key]; - records[key] = sanitizedString(value); + records[key] = sanitizedValue(value); } } -export function sanitizedString(value: any): string { +export function sanitizedValue(value: any): string | number { if (typeof value === 'string') { return value; + } else if (typeof value === 'number') { + return value; } else { return JSON.stringify(value); }