daf-data-store
Advanced tools
Comparing version 0.6.0 to 0.7.0
@@ -13,3 +13,8 @@ import { Types } from 'daf-core'; | ||
credentialsFieldsForClaimHash(hash: string): Promise<any>; | ||
findMessages({ iss, sub, tag, limit, }: { | ||
findCredentialsByFields({ iss, sub, claim_type, }: { | ||
iss?: string[]; | ||
sub?: string[]; | ||
claim_type: string; | ||
}): Promise<any>; | ||
findMessages({ iss, sub, tag, limit }: { | ||
iss?: string; | ||
@@ -16,0 +21,0 @@ sub?: string; |
@@ -117,2 +117,3 @@ "use strict"; | ||
nbf: row.nbf, | ||
iat: row.iat, | ||
}); })]; | ||
@@ -145,2 +146,3 @@ } | ||
nbf: row.nbf, | ||
iat: row.iat, | ||
exp: row.exp, | ||
@@ -180,2 +182,48 @@ }); })]; | ||
}; | ||
DataStore.prototype.findCredentialsByFields = function (_a) { | ||
var iss = _a.iss, sub = _a.sub, claim_type = _a.claim_type; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var where, query, rows, hashes, query2, rows2; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
where = {}; | ||
if (iss) | ||
where = sql_bricks_sqlite_1.default.and(where, sql_bricks_sqlite_1.default.in('iss', iss)); | ||
if (sub) | ||
where = sql_bricks_sqlite_1.default.and(where, sql_bricks_sqlite_1.default.in('sub', sub)); | ||
if (claim_type) | ||
where = sql_bricks_sqlite_1.default.and(where, { claim_type: claim_type }); | ||
query = sql_bricks_sqlite_1.default | ||
.select('rowid', '*') | ||
.from('verifiable_credentials_fields') | ||
.where(where) | ||
.toParams(); | ||
return [4 /*yield*/, this.db.rows(query.text, query.values)]; | ||
case 1: | ||
rows = _b.sent(); | ||
hashes = rows.map(function (row) { return row.parent_hash; }); | ||
query2 = sql_bricks_sqlite_1.default | ||
.select('rowid', '*') | ||
.from('verifiable_credentials') | ||
.where(sql_bricks_sqlite_1.default.in('hash', hashes)) | ||
.toParams(); | ||
return [4 /*yield*/, this.db.rows(query2.text, query2.values)]; | ||
case 2: | ||
rows2 = _b.sent(); | ||
return [2 /*return*/, rows2.map(function (row) { return ({ | ||
rowId: "" + row.rowid, | ||
hash: row.hash, | ||
parentHash: row.parent_hash, | ||
iss: { did: row.iss }, | ||
sub: { did: row.sub }, | ||
jwt: row.jwt, | ||
nbf: row.nbf, | ||
iat: row.iat, | ||
exp: row.exp, | ||
}); })]; | ||
} | ||
}); | ||
}); | ||
}; | ||
DataStore.prototype.findMessages = function (_a) { | ||
@@ -200,2 +248,3 @@ var iss = _a.iss, sub = _a.sub, tag = _a.tag, limit = _a.limit; | ||
where = sql_bricks_sqlite_1.default.and(where, { tag: tag }); | ||
where = sql_bricks_sqlite_1.default.or(where, { sub: null }); | ||
query = sql_bricks_sqlite_1.default | ||
@@ -219,2 +268,3 @@ .select('rowid', '*') | ||
type: row.type, | ||
tag: row.tag, | ||
data: row.data, | ||
@@ -249,2 +299,3 @@ jwt: row.jwt, | ||
type: row.type, | ||
tag: row.tag, | ||
jwt: row.jwt, | ||
@@ -375,2 +426,3 @@ data: row.data, | ||
type: message.type, | ||
tag: message.tag, | ||
jwt: message.raw, | ||
@@ -377,0 +429,0 @@ meta: message.meta && JSON.stringify(message.meta), |
@@ -6,2 +6,13 @@ # Change Log | ||
# [0.7.0](https://github.com/uport-project/daf/compare/v0.6.1...v0.7.0) (2019-11-29) | ||
### Features | ||
* Selective Disclosure Request ([9afe0c5](https://github.com/uport-project/daf/commit/9afe0c5a2fae7e3f778fe99ff4f88f44f61d3b94)) | ||
# [0.6.0](https://github.com/uport-project/daf/compare/v0.5.2...v0.6.0) (2019-11-27) | ||
@@ -8,0 +19,0 @@ |
{ | ||
"name": "daf-data-store", | ||
"description": "DID Agent Framework Data Store", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"main": "build/index.js", | ||
@@ -12,3 +12,3 @@ "types": "build/index.d.ts", | ||
"blakejs": "^1.1.0", | ||
"daf-core": "^0.6.0", | ||
"daf-core": "^0.7.0", | ||
"debug": "^4.1.1", | ||
@@ -31,3 +31,3 @@ "sql-bricks-sqlite": "^0.1.0" | ||
"keywords": [], | ||
"gitHead": "12f811511d19328edf219979729d68cb3de25556" | ||
"gitHead": "04b71a9befac9a79c02cf725b7a7959fcc90a406" | ||
} |
@@ -45,2 +45,3 @@ import { Types } from 'daf-core' | ||
nbf: row.nbf, | ||
iat: row.iat, | ||
})) | ||
@@ -66,2 +67,3 @@ } | ||
nbf: row.nbf, | ||
iat: row.iat, | ||
exp: row.exp, | ||
@@ -92,15 +94,51 @@ })) | ||
async findMessages({ | ||
async findCredentialsByFields({ | ||
iss, | ||
sub, | ||
tag, | ||
limit, | ||
claim_type, | ||
}: { | ||
iss?: string | ||
sub?: string | ||
tag?: string | ||
limit?: number | ||
iss?: string[] | ||
sub?: string[] | ||
claim_type: string | ||
}) { | ||
let where = {} | ||
if (iss) where = sql.and(where, sql.in('iss', iss)) | ||
if (sub) where = sql.and(where, sql.in('sub', sub)) | ||
if (claim_type) where = sql.and(where, { claim_type }) | ||
const query = sql | ||
.select('rowid', '*') | ||
.from('verifiable_credentials_fields') | ||
.where(where) | ||
.toParams() | ||
const rows = await this.db.rows(query.text, query.values) | ||
const hashes = rows.map((row: any) => row.parent_hash) | ||
const query2 = sql | ||
.select('rowid', '*') | ||
.from('verifiable_credentials') | ||
.where(sql.in('hash', hashes)) | ||
.toParams() | ||
const rows2 = await this.db.rows(query2.text, query2.values) | ||
return rows2.map((row: any) => ({ | ||
rowId: `${row.rowid}`, | ||
hash: row.hash, | ||
parentHash: row.parent_hash, | ||
iss: { did: row.iss }, | ||
sub: { did: row.sub }, | ||
jwt: row.jwt, | ||
nbf: row.nbf, | ||
iat: row.iat, | ||
exp: row.exp, | ||
})) | ||
} | ||
async findMessages({ iss, sub, tag, limit }: { iss?: string; sub?: string; tag?: string; limit?: number }) { | ||
let where = {} | ||
if (iss && sub) { | ||
@@ -113,2 +151,3 @@ where = sql.or(where, { iss, sub }) | ||
if (tag) where = sql.and(where, { tag }) | ||
where = sql.or(where, { sub: null }) | ||
@@ -134,2 +173,3 @@ let query = sql | ||
type: row.type, | ||
tag: row.tag, | ||
data: row.data, | ||
@@ -157,2 +197,3 @@ jwt: row.jwt, | ||
type: row.type, | ||
tag: row.tag, | ||
jwt: row.jwt, | ||
@@ -167,10 +208,4 @@ data: row.data, | ||
async allIdentities() { | ||
const vcSubjects = await this.db.rows( | ||
'select distinct sub as did from verifiable_credentials', | ||
null, | ||
) | ||
const vcIssuers = await this.db.rows( | ||
'select distinct iss as did from verifiable_credentials', | ||
null, | ||
) | ||
const vcSubjects = await this.db.rows('select distinct sub as did from verifiable_credentials', null) | ||
const vcIssuers = await this.db.rows('select distinct iss as did from verifiable_credentials', null) | ||
const messageSubjects = await this.db.rows( | ||
@@ -180,6 +215,3 @@ 'select distinct sub as did from messages where sub is not null', | ||
) | ||
const messageIssuers = await this.db.rows( | ||
'select distinct iss as did from messages', | ||
null, | ||
) | ||
const messageIssuers = await this.db.rows('select distinct iss as did from messages', null) | ||
const uniqueDids = [ | ||
@@ -215,8 +247,3 @@ ...new Set([ | ||
.from('messages') | ||
.where( | ||
sql.or( | ||
sql.and({ iss: did1 }, { sub: did2 }), | ||
sql.and({ iss: did2 }, { sub: did1 }), | ||
), | ||
) | ||
.where(sql.or(sql.and({ iss: did1 }, { sub: did2 }), sql.and({ iss: did2 }, { sub: did1 }))) | ||
.toParams() | ||
@@ -258,2 +285,3 @@ const rows = await this.db.rows(query.text, query.values) | ||
type: message.type, | ||
tag: message.tag, | ||
jwt: message.raw, | ||
@@ -301,4 +329,3 @@ meta: message.meta && JSON.stringify(message.meta), | ||
const value = claim[type] | ||
const isObj = | ||
typeof value === 'function' || (typeof value === 'object' && !!value) | ||
const isObj = typeof value === 'function' || (typeof value === 'object' && !!value) | ||
@@ -305,0 +332,0 @@ const fieldsQuery = sql |
Sorry, the diff of this file is not supported yet
116189
1890
+ Addeddaf-core@0.7.0(transitive)
- Removeddaf-core@0.6.0(transitive)
Updateddaf-core@^0.7.0