@atproto/identity 0.2.0 → 0.3.0
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/CHANGELOG.md +21 -0
- package/LICENSE +21 -0
- package/README.md +39 -2
- package/build.js +0 -8
- package/dist/did/atproto-data.d.ts +2 -5
- package/dist/did/base-resolver.d.ts +2 -2
- package/dist/index.js +992 -1105
- package/dist/index.js.map +4 -4
- package/dist/types.d.ts +6 -94
- package/jest.config.js +1 -1
- package/package.json +22 -24
- package/src/did/atproto-data.ts +22 -92
- package/src/did/base-resolver.ts +20 -9
- package/src/did/memory-cache.ts +1 -2
- package/src/handle/index.ts +1 -1
- package/src/types.ts +11 -24
- package/tsconfig.build.json +1 -1
- package/tsconfig.json +3 -3
- package/dist/atp-did.d.ts +0 -14
- package/dist/atproto-data.d.ts +0 -7
- package/dist/base-resolver.d.ts +0 -16
- package/dist/did/logger.d.ts +0 -2
- package/dist/did-cache.d.ts +0 -8
- package/dist/identity-resolver.d.ts +0 -8
- package/dist/logger.d.ts +0 -2
- package/dist/memory-cache.d.ts +0 -18
- package/dist/plc-resolver.d.ts +0 -9
- package/dist/resolver.d.ts +0 -9
- package/dist/src/atp-did.d.ts +0 -14
- package/dist/src/errors.d.ts +0 -5
- package/dist/src/index.d.ts +0 -4
- package/dist/src/logger.d.ts +0 -2
- package/dist/src/plc/resolver.d.ts +0 -6
- package/dist/src/plc-resolver.d.ts +0 -6
- package/dist/src/resolver.d.ts +0 -14
- package/dist/src/web/db.d.ts +0 -17
- package/dist/src/web/resolver.d.ts +0 -6
- package/dist/src/web/server.d.ts +0 -18
- package/dist/src/web-resolver.d.ts +0 -6
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- package/dist/web-resolver.d.ts +0 -10
- package/test.log +0 -4831
- package/tsconfig.build.tsbuildinfo +0 -1
- package/update-pkg.js +0 -14
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# @atproto/identity
|
|
2
|
+
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1773](https://github.com/bluesky-social/atproto/pull/1773) [`bb039d8e`](https://github.com/bluesky-social/atproto/commit/bb039d8e4ce5b7f70c4f3e86d1327e210ef24dc3) Thanks [@dholms](https://github.com/dholms)! - Pass stale did doc into refresh cache functions
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [`35d108ce`](https://github.com/bluesky-social/atproto/commit/35d108ce94866ce1b3d147cd0620a0ba1c4ebcd7) Thanks [@devinivy](https://github.com/devinivy)! - Allow pds to serve did doc with credentials, API client to respect PDS listed in the did doc.
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`35d108ce`](https://github.com/bluesky-social/atproto/commit/35d108ce94866ce1b3d147cd0620a0ba1c4ebcd7)]:
|
|
14
|
+
- @atproto/common-web@0.2.2
|
|
15
|
+
|
|
16
|
+
## 0.2.1
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [[`41ee177f`](https://github.com/bluesky-social/atproto/commit/41ee177f5a440490280d17acd8a89bcddaffb23b)]:
|
|
21
|
+
- @atproto/common-web@0.2.1
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022-2023 Bluesky PBC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,40 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @atproto/identity
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
TypeScript library for decentralized identities in [atproto](https://atproto.com) using DIDs and handles
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@atproto/identity)
|
|
6
|
+
[](https://github.com/bluesky-social/atproto/actions/workflows/repo.yaml)
|
|
7
|
+
|
|
8
|
+
## Example
|
|
9
|
+
|
|
10
|
+
Resolving a Handle and verifying against DID document:
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
const didres = new DidResolver({})
|
|
14
|
+
const hdlres = new HandleResolver({})
|
|
15
|
+
|
|
16
|
+
const handle = 'atproto.com'
|
|
17
|
+
const did = await hdlres.resolve(handle)
|
|
18
|
+
|
|
19
|
+
if (did == undefined) {
|
|
20
|
+
throw new Error('expected handle to resolve')
|
|
21
|
+
}
|
|
22
|
+
console.log(did) // did:plc:ewvi7nxzyoun6zhxrhs64oiz
|
|
23
|
+
|
|
24
|
+
const doc = await didres.resolve(did)
|
|
25
|
+
console.log(doc)
|
|
26
|
+
|
|
27
|
+
// additional resolutions of same DID will be cached for some time, unless forceRefresh flag is used
|
|
28
|
+
const doc2 = await didres.resolve(did, true)
|
|
29
|
+
|
|
30
|
+
// helper methods use the same cache
|
|
31
|
+
const data = await didres.resolveAtprotoData(did)
|
|
32
|
+
|
|
33
|
+
if (data.handle != handle) {
|
|
34
|
+
throw new Error('invalid handle (did not match DID document)')
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## License
|
|
39
|
+
|
|
40
|
+
MIT License
|
package/build.js
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
const pkgJson = require('@npmcli/package-json')
|
|
2
1
|
const { nodeExternalsPlugin } = require('esbuild-node-externals')
|
|
3
2
|
|
|
4
3
|
const buildShallow =
|
|
5
4
|
process.argv.includes('--shallow') || process.env.ATP_BUILD_SHALLOW === 'true'
|
|
6
5
|
|
|
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
6
|
require('esbuild').build({
|
|
15
7
|
logLevel: 'info',
|
|
16
8
|
entryPoints: ['src/index.ts'],
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { DidDocument, AtprotoData } from '../types';
|
|
2
|
-
|
|
2
|
+
import { getDid, getHandle, getPdsEndpoint, getFeedGenEndpoint, getNotifEndpoint } from '@atproto/common-web';
|
|
3
|
+
export { getDid, getHandle, getPdsEndpoint as getPds, getFeedGenEndpoint as getFeedGen, getNotifEndpoint as getNotif, };
|
|
3
4
|
export declare const getKey: (doc: DidDocument) => string | undefined;
|
|
4
|
-
export declare const getHandle: (doc: DidDocument) => string | undefined;
|
|
5
|
-
export declare const getPds: (doc: DidDocument) => string | undefined;
|
|
6
|
-
export declare const getFeedGen: (doc: DidDocument) => string | undefined;
|
|
7
|
-
export declare const getNotif: (doc: DidDocument) => string | undefined;
|
|
8
5
|
export declare const parseToAtprotoDocument: (doc: DidDocument) => Partial<AtprotoData>;
|
|
9
6
|
export declare const ensureAtpDocument: (doc: DidDocument) => AtprotoData;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { DidCache, AtprotoData, DidDocument } from '../types';
|
|
1
|
+
import { DidCache, AtprotoData, DidDocument, CacheResult } from '../types';
|
|
2
2
|
export declare abstract class BaseResolver {
|
|
3
3
|
cache?: DidCache | undefined;
|
|
4
4
|
constructor(cache?: DidCache | undefined);
|
|
5
5
|
abstract resolveNoCheck(did: string): Promise<unknown | null>;
|
|
6
6
|
validateDidDoc(did: string, val: unknown): DidDocument;
|
|
7
7
|
resolveNoCache(did: string): Promise<DidDocument | null>;
|
|
8
|
-
refreshCache(did: string): Promise<void>;
|
|
8
|
+
refreshCache(did: string, prevResult?: CacheResult): Promise<void>;
|
|
9
9
|
resolve(did: string, forceRefresh?: boolean): Promise<DidDocument | null>;
|
|
10
10
|
ensureResolve(did: string, forceRefresh?: boolean): Promise<DidDocument>;
|
|
11
11
|
resolveAtprotoData(did: string, forceRefresh?: boolean): Promise<AtprotoData>;
|