@enbox/api 0.0.8 → 0.1.1
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/browser.mjs +46 -53
- package/dist/browser.mjs.map +4 -4
- package/dist/esm/define-protocol.js +37 -0
- package/dist/esm/define-protocol.js.map +1 -0
- package/dist/esm/dwn-api.js +54 -26
- package/dist/esm/dwn-api.js.map +1 -1
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/live-query.js +153 -0
- package/dist/esm/live-query.js.map +1 -0
- package/dist/esm/protocol-types.js +8 -0
- package/dist/esm/protocol-types.js.map +1 -0
- package/dist/esm/record.js.map +1 -1
- package/dist/esm/typed-dwn-api.js +182 -0
- package/dist/esm/typed-dwn-api.js.map +1 -0
- package/dist/esm/web5.js +3 -2
- package/dist/esm/web5.js.map +1 -1
- package/dist/types/define-protocol.d.ts +37 -0
- package/dist/types/define-protocol.d.ts.map +1 -0
- package/dist/types/dwn-api.d.ts +32 -17
- package/dist/types/dwn-api.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/live-query.d.ts +136 -0
- package/dist/types/live-query.d.ts.map +1 -0
- package/dist/types/protocol-types.d.ts +95 -0
- package/dist/types/protocol-types.d.ts.map +1 -0
- package/dist/types/record.d.ts +1 -1
- package/dist/types/record.d.ts.map +1 -1
- package/dist/types/typed-dwn-api.d.ts +193 -0
- package/dist/types/typed-dwn-api.d.ts.map +1 -0
- package/dist/types/web5.d.ts.map +1 -1
- package/package.json +14 -17
- package/src/define-protocol.ts +48 -0
- package/src/dwn-api.ts +87 -49
- package/src/index.ts +4 -0
- package/src/live-query.ts +245 -0
- package/src/protocol-types.ts +171 -0
- package/src/record.ts +3 -3
- package/src/typed-dwn-api.ts +370 -0
- package/src/web5.ts +3 -2
- package/dist/browser.js +0 -2224
- package/dist/browser.js.map +0 -7
- package/dist/esm/subscription-util.js +0 -35
- package/dist/esm/subscription-util.js.map +0 -1
- package/dist/types/subscription-util.d.ts +0 -19
- package/dist/types/subscription-util.d.ts.map +0 -1
- package/src/subscription-util.ts +0 -44
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { getRecordAuthor } from '@enbox/agent';
|
|
11
|
-
import { Record } from './record.js';
|
|
12
|
-
/**
|
|
13
|
-
* Utility class for dealing with subscriptions.
|
|
14
|
-
*/
|
|
15
|
-
export class SubscriptionUtil {
|
|
16
|
-
/**
|
|
17
|
-
* Creates a record subscription handler that can be used to process incoming {Record} messages.
|
|
18
|
-
*/
|
|
19
|
-
static recordSubscriptionHandler({ agent, connectedDid, request, delegateDid, protocolRole, permissionsApi }) {
|
|
20
|
-
const { subscriptionHandler, from: remoteOrigin } = request;
|
|
21
|
-
return (event) => __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
const { message, initialWrite } = event;
|
|
23
|
-
const author = getRecordAuthor(message);
|
|
24
|
-
const recordOptions = {
|
|
25
|
-
author,
|
|
26
|
-
connectedDid,
|
|
27
|
-
remoteOrigin,
|
|
28
|
-
initialWrite
|
|
29
|
-
};
|
|
30
|
-
const record = new Record(agent, Object.assign(Object.assign(Object.assign({}, message), recordOptions), { protocolRole, delegateDid: delegateDid }), permissionsApi);
|
|
31
|
-
subscriptionHandler(record);
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=subscription-util.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"subscription-util.js","sourceRoot":"","sources":["../../src/subscription-util.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAC3B;;OAEG;IACH,MAAM,CAAC,yBAAyB,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,cAAc,EAOzG;QACC,MAAM,EAAE,mBAAmB,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;QAE5D,OAAO,CAAO,KAAK,EAAE,EAAE;YACrB,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC;YACxC,MAAM,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;YACxC,MAAM,aAAa,GAAG;gBACpB,MAAM;gBACN,YAAY;gBACZ,YAAY;gBACZ,YAAY;aACb,CAAC;YAEF,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,KAAK,gDAC1B,OAAO,GACP,aAAa,KAChB,YAAY,EACZ,WAAW,EAAE,WAAW,KACvB,cAAc,CAAC,CAAC;YAEnB,mBAAmB,CAAC,MAAM,CAAC,CAAC;QAC9B,CAAC,CAAA,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { DwnRecordSubscriptionHandler, PermissionsApi, Web5Agent } from '@enbox/agent';
|
|
2
|
-
import type { RecordsSubscribeRequest } from './dwn-api.js';
|
|
3
|
-
/**
|
|
4
|
-
* Utility class for dealing with subscriptions.
|
|
5
|
-
*/
|
|
6
|
-
export declare class SubscriptionUtil {
|
|
7
|
-
/**
|
|
8
|
-
* Creates a record subscription handler that can be used to process incoming {Record} messages.
|
|
9
|
-
*/
|
|
10
|
-
static recordSubscriptionHandler({ agent, connectedDid, request, delegateDid, protocolRole, permissionsApi }: {
|
|
11
|
-
agent: Web5Agent;
|
|
12
|
-
connectedDid: string;
|
|
13
|
-
delegateDid?: string;
|
|
14
|
-
protocolRole?: string;
|
|
15
|
-
permissionsApi?: PermissionsApi;
|
|
16
|
-
request: RecordsSubscribeRequest;
|
|
17
|
-
}): DwnRecordSubscriptionHandler;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=subscription-util.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"subscription-util.d.ts","sourceRoot":"","sources":["../../src/subscription-util.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,4BAA4B,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAG5F,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAE5D;;GAEG;AACH,qBAAa,gBAAgB;IAC3B;;OAEG;IACH,MAAM,CAAC,yBAAyB,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,cAAc,EAAE,EAAC;QAC3G,KAAK,EAAE,SAAS,CAAC;QACjB,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,cAAc,CAAC,EAAE,cAAc,CAAC;QAChC,OAAO,EAAE,uBAAuB,CAAC;KAClC,GAAG,4BAA4B;CAuBjC"}
|
package/src/subscription-util.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { getRecordAuthor } from '@enbox/agent';
|
|
2
|
-
import type { DwnRecordSubscriptionHandler, PermissionsApi, Web5Agent } from '@enbox/agent';
|
|
3
|
-
|
|
4
|
-
import { Record } from './record.js';
|
|
5
|
-
import type { RecordsSubscribeRequest } from './dwn-api.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Utility class for dealing with subscriptions.
|
|
9
|
-
*/
|
|
10
|
-
export class SubscriptionUtil {
|
|
11
|
-
/**
|
|
12
|
-
* Creates a record subscription handler that can be used to process incoming {Record} messages.
|
|
13
|
-
*/
|
|
14
|
-
static recordSubscriptionHandler({ agent, connectedDid, request, delegateDid, protocolRole, permissionsApi }:{
|
|
15
|
-
agent: Web5Agent;
|
|
16
|
-
connectedDid: string;
|
|
17
|
-
delegateDid?: string;
|
|
18
|
-
protocolRole?: string;
|
|
19
|
-
permissionsApi?: PermissionsApi;
|
|
20
|
-
request: RecordsSubscribeRequest;
|
|
21
|
-
}): DwnRecordSubscriptionHandler {
|
|
22
|
-
const { subscriptionHandler, from: remoteOrigin } = request;
|
|
23
|
-
|
|
24
|
-
return async (event) => {
|
|
25
|
-
const { message, initialWrite } = event;
|
|
26
|
-
const author = getRecordAuthor(message);
|
|
27
|
-
const recordOptions = {
|
|
28
|
-
author,
|
|
29
|
-
connectedDid,
|
|
30
|
-
remoteOrigin,
|
|
31
|
-
initialWrite
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const record = new Record(agent, {
|
|
35
|
-
...message,
|
|
36
|
-
...recordOptions,
|
|
37
|
-
protocolRole,
|
|
38
|
-
delegateDid: delegateDid,
|
|
39
|
-
}, permissionsApi);
|
|
40
|
-
|
|
41
|
-
subscriptionHandler(record);
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
}
|