@seed-hypermedia/client 0.0.12 → 0.0.13
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/capability.d.ts +7 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +11 -0
- package/package.json +1 -1
- package/src/index.ts +1 -1
package/dist/capability.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Capability SDK — create capabilities (delegate access to other accounts).
|
|
2
|
+
* Capability SDK — create and resolve capabilities (delegate access to other accounts).
|
|
3
3
|
*/
|
|
4
4
|
import type { HMPublishBlobsInput, HMSigner } from './hm-types';
|
|
5
|
+
import type { SeedClient } from './client';
|
|
5
6
|
/** Role values for capability blobs. */
|
|
6
7
|
export type CapabilityRole = 'WRITER' | 'AGENT';
|
|
7
8
|
export type CreateCapabilityInput = {
|
|
@@ -19,3 +20,8 @@ export type CreateCapabilityInput = {
|
|
|
19
20
|
* The signer is the issuer granting access to the delegate.
|
|
20
21
|
*/
|
|
21
22
|
export declare function createCapability(input: CreateCapabilityInput, signer: HMSigner): Promise<HMPublishBlobsInput>;
|
|
23
|
+
/**
|
|
24
|
+
* Find a WRITER or AGENT capability for `signerAccount` on `targetAccount`.
|
|
25
|
+
* Returns the capability CID if found, undefined if not needed (same account) or not found.
|
|
26
|
+
*/
|
|
27
|
+
export declare function resolveCapability(client: SeedClient, targetAccount: string, signerAccount: string): Promise<string | undefined>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { createCapability } from './capability';
|
|
1
|
+
export { createCapability, resolveCapability } from './capability';
|
|
2
2
|
export type { CapabilityRole, CreateCapabilityInput } from './capability';
|
|
3
3
|
export { createChange, createChangeOps, createDocumentChange, createDocumentChangeFromOps, createGenesisChange, signDocumentChange, signPreparedChange, } from './change';
|
|
4
4
|
export type { CreateChangeOpsInput, CreateDocumentChangeFromOpsInput, CreateDocumentChangeInput, DocumentOperation, SignDocumentChangeInput, } from './change';
|
package/dist/index.mjs
CHANGED
|
@@ -72,6 +72,16 @@ async function createCapability(input, signer) {
|
|
|
72
72
|
unsigned.sig = await signObject(signer, unsigned);
|
|
73
73
|
return toPublishInput(cborEncode2(unsigned));
|
|
74
74
|
}
|
|
75
|
+
async function resolveCapability(client, targetAccount, signerAccount) {
|
|
76
|
+
if (targetAccount === signerAccount) return void 0;
|
|
77
|
+
const targetId = unpackHmId(`hm://${targetAccount}`);
|
|
78
|
+
if (!targetId) return void 0;
|
|
79
|
+
const caps = await client.request("ListCapabilities", { targetId });
|
|
80
|
+
const match = caps.capabilities.find(
|
|
81
|
+
(c) => c.delegate === signerAccount && (c.role === "WRITER" || c.role === "AGENT")
|
|
82
|
+
);
|
|
83
|
+
return match == null ? void 0 : match.id;
|
|
84
|
+
}
|
|
75
85
|
|
|
76
86
|
// src/change.ts
|
|
77
87
|
import { decode as cborDecode, encode as cborEncode4 } from "@ipld/dag-cbor";
|
|
@@ -3910,6 +3920,7 @@ export {
|
|
|
3910
3920
|
pdfToBlocks,
|
|
3911
3921
|
processFulltextDocument,
|
|
3912
3922
|
pushSpanToAnnotation,
|
|
3923
|
+
resolveCapability,
|
|
3913
3924
|
resolveDocumentState,
|
|
3914
3925
|
resolveFileLinksInBlocks,
|
|
3915
3926
|
resolveHypermediaUrl,
|
package/package.json
CHANGED
package/src/index.ts
CHANGED