@did-plc/lib 0.0.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/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # DID Placeholder Library
2
+
package/build.js ADDED
@@ -0,0 +1,26 @@
1
+ const pkgJson = require('@npmcli/package-json')
2
+ const { nodeExternalsPlugin } = require('esbuild-node-externals')
3
+
4
+ const buildShallow =
5
+ process.argv.includes('--shallow') || process.env.PLC_BUILD_SHALLOW === 'true'
6
+
7
+ if (process.argv.includes('--update-main-to-dist')) {
8
+ return pkgJson
9
+ .load(__dirname)
10
+ .then((pkg) => pkg.update({ main: 'dist/index.js' }))
11
+ .then((pkg) => pkg.save())
12
+ }
13
+
14
+ require('esbuild').build({
15
+ logLevel: 'info',
16
+ entryPoints: [
17
+ 'src/index.ts',
18
+ ],
19
+ bundle: true,
20
+ sourcemap: true,
21
+ treeShaking: true,
22
+ outdir: 'dist',
23
+ platform: 'node',
24
+ assetNames: 'src/static',
25
+ plugins: buildShallow ? [nodeExternalsPlugin()] : [],
26
+ })
@@ -0,0 +1,39 @@
1
+ import { Keypair } from '@atproto/crypto';
2
+ import { AxiosError } from 'axios';
3
+ import * as t from './types';
4
+ export declare class Client {
5
+ url: string;
6
+ constructor(url: string);
7
+ private makeGetReq;
8
+ getDocument(did: string): Promise<t.DidDocument>;
9
+ getDocumentData(did: string): Promise<t.DocumentData>;
10
+ getOperationLog(did: string): Promise<t.CompatibleOpOrTombstone[]>;
11
+ getAuditableLog(did: string): Promise<t.ExportedOp[]>;
12
+ postOpUrl(did: string): string;
13
+ getLastOp(did: string): Promise<t.CompatibleOpOrTombstone>;
14
+ sendOperation(did: string, op: t.OpOrTombstone): Promise<void>;
15
+ export(after?: string, count?: number): Promise<t.ExportedOp[]>;
16
+ createDid(opts: {
17
+ signingKey: string;
18
+ handle: string;
19
+ pds: string;
20
+ rotationKeys: string[];
21
+ signer: Keypair;
22
+ }): Promise<string>;
23
+ private ensureLastOp;
24
+ updateData(did: string, signer: Keypair, fn: (lastOp: t.UnsignedOperation) => Omit<t.UnsignedOperation, 'prev'>): Promise<void>;
25
+ updateAtprotoKey(did: string, signer: Keypair, atprotoKey: string): Promise<void>;
26
+ updateHandle(did: string, signer: Keypair, handle: string): Promise<void>;
27
+ updatePds(did: string, signer: Keypair, endpoint: string): Promise<void>;
28
+ updateRotationKeys(did: string, signer: Keypair, keys: string[]): Promise<void>;
29
+ tombstone(did: string, signer: Keypair): Promise<void>;
30
+ health(): Promise<any>;
31
+ }
32
+ export declare class PlcClientError extends Error {
33
+ status: number;
34
+ data: unknown;
35
+ message: string;
36
+ constructor(status: number, data: unknown, message: string);
37
+ static fromAxiosError(err: AxiosError): PlcClientError;
38
+ }
39
+ export default Client;
package/dist/data.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { CID } from 'multiformats/cid';
2
+ import * as t from './types';
3
+ export declare const assureValidNextOp: (did: string, ops: t.IndexedOperation[], proposed: t.OpOrTombstone) => Promise<{
4
+ nullified: CID[];
5
+ prev: CID | null;
6
+ }>;
7
+ export declare const validateOperationLog: (did: string, ops: t.CompatibleOpOrTombstone[]) => Promise<t.DocumentData | null>;
8
+ export declare const getLastOpWithCid: (ops: t.CompatibleOpOrTombstone[]) => Promise<{
9
+ op: t.CompatibleOpOrTombstone;
10
+ cid: CID;
11
+ }>;
@@ -0,0 +1,2 @@
1
+ import * as t from './types';
2
+ export declare const formatDidDoc: (data: t.DocumentData) => t.DidDocument;
@@ -0,0 +1,34 @@
1
+ export declare class PlcError extends Error {
2
+ plcError: boolean;
3
+ constructor(msg: string);
4
+ static is(obj: unknown): obj is PlcError;
5
+ }
6
+ export declare class ImproperOperationError extends PlcError {
7
+ reason: string;
8
+ op: unknown;
9
+ constructor(reason: string, op: unknown);
10
+ }
11
+ export declare class MisorderedOperationError extends PlcError {
12
+ constructor();
13
+ }
14
+ export declare class LateRecoveryError extends PlcError {
15
+ timeLapsed: number;
16
+ constructor(timeLapsed: number);
17
+ }
18
+ export declare class GenesisHashError extends PlcError {
19
+ expected: string;
20
+ constructor(expected: string);
21
+ }
22
+ export declare class InvalidSignatureError extends PlcError {
23
+ op: unknown;
24
+ constructor(op: unknown);
25
+ }
26
+ export declare class UnsupportedKeyError extends PlcError {
27
+ key: string;
28
+ err: unknown;
29
+ constructor(key: string, err: unknown);
30
+ }
31
+ export declare class ImproperlyFormattedDidError extends PlcError {
32
+ reason: string;
33
+ constructor(reason: string);
34
+ }
@@ -0,0 +1,6 @@
1
+ export * from './client';
2
+ export * from './data';
3
+ export * from './document';
4
+ export * from './error';
5
+ export * from './operations';
6
+ export * from './types';