@atproto/lexicon-resolver 0.2.6 → 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 +13 -0
- package/dist/lexicon.d.ts +13 -13
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lexicon.js +46 -20
- package/dist/lexicon.js.map +1 -1
- package/dist/lexicons/com/atproto/lexicon/schema.d.ts +3 -0
- package/dist/lexicons/com/atproto/lexicon/schema.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/lexicon/schema.defs.d.ts +50 -0
- package/dist/lexicons/com/atproto/lexicon/schema.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/lexicon/schema.defs.js +15 -0
- package/dist/lexicons/com/atproto/lexicon/schema.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/lexicon/schema.js +45 -0
- package/dist/lexicons/com/atproto/lexicon/schema.js.map +1 -0
- package/dist/lexicons/com/atproto/lexicon.d.ts +2 -0
- package/dist/lexicons/com/atproto/lexicon.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/lexicon.js +41 -0
- package/dist/lexicons/com/atproto/lexicon.js.map +1 -0
- package/dist/lexicons/com/atproto/sync/getRecord.d.ts +3 -0
- package/dist/lexicons/com/atproto/sync/getRecord.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/sync/getRecord.defs.d.ts +31 -0
- package/dist/lexicons/com/atproto/sync/getRecord.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/sync/getRecord.defs.js +24 -0
- package/dist/lexicons/com/atproto/sync/getRecord.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/sync/getRecord.js +45 -0
- package/dist/lexicons/com/atproto/sync/getRecord.js.map +1 -0
- package/dist/lexicons/com/atproto/sync.d.ts +2 -0
- package/dist/lexicons/com/atproto/sync.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/sync.js +41 -0
- package/dist/lexicons/com/atproto/sync.js.map +1 -0
- package/dist/lexicons/com/atproto.d.ts +3 -0
- package/dist/lexicons/com/atproto.d.ts.map +1 -0
- package/dist/lexicons/com/atproto.js +42 -0
- package/dist/lexicons/com/atproto.js.map +1 -0
- package/dist/lexicons/com.d.ts +2 -0
- package/dist/lexicons/com.d.ts.map +1 -0
- package/dist/lexicons/com.js +41 -0
- package/dist/lexicons/com.js.map +1 -0
- package/dist/lexicons/index.d.ts +2 -0
- package/dist/lexicons/index.d.ts.map +1 -0
- package/dist/lexicons/index.js +41 -0
- package/dist/lexicons/index.js.map +1 -0
- package/dist/record.d.ts +9 -10
- package/dist/record.d.ts.map +1 -1
- package/dist/record.js +10 -13
- package/dist/record.js.map +1 -1
- package/package.json +7 -9
- package/src/lexicon.ts +29 -37
- package/src/lexicons/com/atproto/lexicon/schema.defs.ts +43 -0
- package/src/lexicons/com/atproto/lexicon/schema.ts +6 -0
- package/src/lexicons/com/atproto/lexicon.ts +5 -0
- package/src/lexicons/com/atproto/sync/getRecord.defs.ts +39 -0
- package/src/lexicons/com/atproto/sync/getRecord.ts +6 -0
- package/src/lexicons/com/atproto/sync.ts +5 -0
- package/src/lexicons/com/atproto.ts +6 -0
- package/src/lexicons/com.ts +5 -0
- package/src/lexicons/index.ts +5 -0
- package/src/record.ts +42 -25
- package/tests/lexicon.test.ts +4 -3
- package/tests/record.test.ts +8 -5
- package/tsconfig.build.tsbuildinfo +1 -1
- package/dist/client/index.d.ts +0 -28
- package/dist/client/index.d.ts.map +0 -1
- package/dist/client/index.js +0 -118
- package/dist/client/index.js.map +0 -1
- package/dist/client/lexicons.d.ts +0 -105
- package/dist/client/lexicons.d.ts.map +0 -1
- package/dist/client/lexicons.js +0 -75
- package/dist/client/lexicons.js.map +0 -1
- package/dist/client/types/com/atproto/sync/getRecord.d.ts +0 -38
- package/dist/client/types/com/atproto/sync/getRecord.d.ts.map +0 -1
- package/dist/client/types/com/atproto/sync/getRecord.js +0 -58
- package/dist/client/types/com/atproto/sync/getRecord.js.map +0 -1
- package/dist/client/util.d.ts +0 -37
- package/dist/client/util.d.ts.map +0 -1
- package/dist/client/util.js +0 -38
- package/dist/client/util.js.map +0 -1
- package/src/client/index.ts +0 -67
- package/src/client/lexicons.ts +0 -98
- package/src/client/types/com/atproto/sync/getRecord.ts +0 -78
- package/src/client/util.ts +0 -82
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../../../src/lexicons/com/atproto/sync.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,iEAAgD","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nexport * as getRecord from './sync/getRecord.js'\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atproto.d.ts","sourceRoot":"","sources":["../../../src/lexicons/com/atproto.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAA;AAC/C,OAAO,KAAK,IAAI,MAAM,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* THIS FILE WAS GENERATED BY "@atproto/lex". DO NOT EDIT.
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.sync = exports.lexicon = void 0;
|
|
40
|
+
exports.lexicon = __importStar(require("./atproto/lexicon.js"));
|
|
41
|
+
exports.sync = __importStar(require("./atproto/sync.js"));
|
|
42
|
+
//# sourceMappingURL=atproto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atproto.js","sourceRoot":"","sources":["../../../src/lexicons/com/atproto.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,gEAA+C;AAC/C,0DAAyC","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nexport * as lexicon from './atproto/lexicon.js'\nexport * as sync from './atproto/sync.js'\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"com.d.ts","sourceRoot":"","sources":["../../src/lexicons/com.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* THIS FILE WAS GENERATED BY "@atproto/lex". DO NOT EDIT.
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.atproto = void 0;
|
|
40
|
+
exports.atproto = __importStar(require("./com/atproto.js"));
|
|
41
|
+
//# sourceMappingURL=com.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"com.js","sourceRoot":"","sources":["../../src/lexicons/com.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4DAA2C","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nexport * as atproto from './com/atproto.js'\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lexicons/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* THIS FILE WAS GENERATED BY "@atproto/lex". DO NOT EDIT.
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.com = void 0;
|
|
40
|
+
exports.com = __importStar(require("./com.js"));
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lexicons/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,gDAA+B","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nexport * as com from './com.js'\n"]}
|
package/dist/record.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { CID } from 'multiformats/cid';
|
|
2
1
|
import { IdResolver } from '@atproto/identity';
|
|
3
|
-
import {
|
|
2
|
+
import { AgentConfig, Cid, DidString, FetchHandler, LexMap } from '@atproto/lex';
|
|
4
3
|
import { Commit } from '@atproto/repo';
|
|
5
|
-
import { AtUri } from '@atproto/syntax';
|
|
6
|
-
|
|
4
|
+
import { AtUri, AtUriString } from '@atproto/syntax';
|
|
5
|
+
export { AtUri, IdResolver };
|
|
6
|
+
export type { AgentConfig, AtUriString, Cid, Commit, DidString, FetchHandler, LexMap, };
|
|
7
7
|
/**
|
|
8
8
|
* Resolve a record from the network.
|
|
9
9
|
*/
|
|
10
|
-
export type RecordResolver = (uri: AtUri |
|
|
10
|
+
export type RecordResolver = (uri: AtUri | AtUriString) => Promise<RecordResolution>;
|
|
11
11
|
/**
|
|
12
12
|
* Resolve a record from the network, verifying its authenticity.
|
|
13
13
|
*/
|
|
14
|
-
export type AtprotoRecordResolver = (uri: AtUri |
|
|
14
|
+
export type AtprotoRecordResolver = (uri: AtUri | AtUriString, options?: ResolveRecordOptions) => Promise<RecordResolution>;
|
|
15
15
|
export type BuildRecordResolverOptions = {
|
|
16
16
|
idResolver?: IdResolver;
|
|
17
|
-
rpc?: Partial<
|
|
17
|
+
rpc?: Partial<AgentConfig> | FetchHandler;
|
|
18
18
|
};
|
|
19
19
|
export type ResolveRecordOptions = {
|
|
20
20
|
forceRefresh?: boolean;
|
|
@@ -22,10 +22,9 @@ export type ResolveRecordOptions = {
|
|
|
22
22
|
export type RecordResolution = {
|
|
23
23
|
commit: Commit;
|
|
24
24
|
uri: AtUri;
|
|
25
|
-
cid:
|
|
26
|
-
record:
|
|
25
|
+
cid: Cid;
|
|
26
|
+
record: LexMap;
|
|
27
27
|
};
|
|
28
|
-
export { AtUri, CID, type Commit, IdResolver, type RepoRecord };
|
|
29
28
|
/**
|
|
30
29
|
* Build a record resolver function.
|
|
31
30
|
*/
|
package/dist/record.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../src/record.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../src/record.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA0B,MAAM,mBAAmB,CAAA;A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AM,EAAE,OAAO,CAAC,EAAE,YAAY;CAIrD"}
|
package/dist/record.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RecordResolutionError = exports.safeFetch = exports.resolveRecord = exports.IdResolver = exports.
|
|
3
|
+
exports.RecordResolutionError = exports.safeFetch = exports.resolveRecord = exports.IdResolver = exports.AtUri = void 0;
|
|
4
4
|
exports.buildRecordResolver = buildRecordResolver;
|
|
5
|
-
const cid_1 = require("multiformats/cid");
|
|
6
|
-
Object.defineProperty(exports, "CID", { enumerable: true, get: function () { return cid_1.CID; } });
|
|
7
5
|
const identity_1 = require("@atproto/identity");
|
|
8
6
|
Object.defineProperty(exports, "IdResolver", { enumerable: true, get: function () { return identity_1.IdResolver; } });
|
|
7
|
+
const lex_1 = require("@atproto/lex");
|
|
9
8
|
const repo_1 = require("@atproto/repo");
|
|
10
9
|
const syntax_1 = require("@atproto/syntax");
|
|
11
10
|
Object.defineProperty(exports, "AtUri", { enumerable: true, get: function () { return syntax_1.AtUri; } });
|
|
12
11
|
const fetch_node_1 = require("@atproto-labs/fetch-node");
|
|
13
|
-
const index_js_1 = require("./
|
|
14
|
-
const util_js_1 = require("./util.js");
|
|
12
|
+
const index_js_1 = require("./lexicons/index.js");
|
|
15
13
|
/**
|
|
16
14
|
* Build a record resolver function.
|
|
17
15
|
*/
|
|
@@ -34,15 +32,15 @@ function buildRecordResolver(options = {}) {
|
|
|
34
32
|
if (!signingKey) {
|
|
35
33
|
throw new RecordResolutionError('Incomplete DID identity data: missing signing key');
|
|
36
34
|
}
|
|
37
|
-
const client = new
|
|
38
|
-
? rpc
|
|
35
|
+
const client = new lex_1.Client(typeof rpc === 'function'
|
|
36
|
+
? { fetchHandler: rpc }
|
|
39
37
|
: {
|
|
40
38
|
...rpc,
|
|
41
39
|
service: rpc?.service ?? pds,
|
|
42
40
|
fetch: rpc?.fetch ?? exports.safeFetch,
|
|
43
41
|
});
|
|
44
|
-
const
|
|
45
|
-
.getRecord
|
|
42
|
+
const proofBytes = await client
|
|
43
|
+
.call(index_js_1.com.atproto.sync.getRecord, {
|
|
46
44
|
did,
|
|
47
45
|
collection: uri.collection,
|
|
48
46
|
rkey: uri.rkey,
|
|
@@ -73,12 +71,11 @@ class RecordResolutionError extends Error {
|
|
|
73
71
|
}
|
|
74
72
|
exports.RecordResolutionError = RecordResolutionError;
|
|
75
73
|
async function getDidFromUri(uri, { idResolver }) {
|
|
76
|
-
if (uri.host
|
|
77
|
-
(0, syntax_1.ensureValidDid)(uri.host);
|
|
74
|
+
if (lex_1.l.isDidString(uri.host)) {
|
|
78
75
|
return uri.host;
|
|
79
76
|
}
|
|
80
77
|
const resolved = await idResolver.handle.resolve(uri.host);
|
|
81
|
-
if (!resolved || !
|
|
78
|
+
if (!resolved || !lex_1.l.isDidString(resolved)) {
|
|
82
79
|
throw new RecordResolutionError('Could not resolve handle found in AT-URI');
|
|
83
80
|
}
|
|
84
81
|
return resolved;
|
|
@@ -105,7 +102,7 @@ async function verifyRecordProof(proofBytes, { uri, signingKey }) {
|
|
|
105
102
|
if (!cid) {
|
|
106
103
|
throw new RecordResolutionError('Record not found in proof');
|
|
107
104
|
}
|
|
108
|
-
const record = await blockstore.readRecord(cid);
|
|
105
|
+
const record = (await blockstore.readRecord(cid));
|
|
109
106
|
return { commit, uri, cid, record };
|
|
110
107
|
}
|
|
111
108
|
//# sourceMappingURL=record.js.map
|
package/dist/record.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record.js","sourceRoot":"","sources":["../src/record.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"record.js","sourceRoot":"","sources":["../src/record.ts"],"names":[],"mappings":";;;AAmEA,kDAsDC;AAzHD,gDAAsE;AAsBtD,2FAtBP,qBAAU,OAsBO;AArB1B,sCAQqB;AACrB,wCAOsB;AACtB,4CAAoD;AAI3C,sFAJA,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CAAgC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAClD,CAAA;IACH,CAAC;IACD,MAAM,GAAG,GAAG,UAAG,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;IAC7C,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,UAAU,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC,CAAA;IAC1D,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,qBAAqB,CAAC,2BAA2B,CAAC,CAAA;IAC9D,CAAC;IACD,MAAM,MAAM,GAAG,CAAC,MAAM,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,CAAW,CAAA;IAC3D,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,CAAA;AACrC,CAAC","sourcesContent":["import { IdResolver, parseToAtprotoDocument } from '@atproto/identity'\nimport {\n AgentConfig,\n Cid,\n Client,\n DidString,\n FetchHandler,\n LexMap,\n l,\n} from '@atproto/lex'\nimport {\n Commit,\n MST,\n MemoryBlockstore,\n def as repoDef,\n readCarWithRoot,\n verifyCommitSig,\n} from '@atproto/repo'\nimport { AtUri, AtUriString } from '@atproto/syntax'\nimport { safeFetchWrap } from '@atproto-labs/fetch-node'\nimport { com } from './lexicons/index.js'\n\nexport { AtUri, IdResolver }\nexport type {\n AgentConfig,\n AtUriString,\n Cid,\n Commit,\n DidString,\n FetchHandler,\n LexMap,\n}\n\n/**\n * Resolve a record from the network.\n */\nexport type RecordResolver = (\n uri: AtUri | AtUriString,\n) => Promise<RecordResolution>\n\n/**\n * Resolve a record from the network, verifying its authenticity.\n */\nexport type AtprotoRecordResolver = (\n uri: AtUri | AtUriString,\n options?: ResolveRecordOptions,\n) => Promise<RecordResolution>\n\nexport type BuildRecordResolverOptions = {\n idResolver?: IdResolver\n rpc?: Partial<AgentConfig> | FetchHandler\n}\n\nexport type ResolveRecordOptions = {\n forceRefresh?: boolean\n}\n\nexport type RecordResolution = {\n commit: Commit\n uri: AtUri\n cid: Cid\n record: LexMap\n}\n\n/**\n * Build a record resolver function.\n */\nexport function buildRecordResolver(\n options: BuildRecordResolverOptions = {},\n): AtprotoRecordResolver {\n const { idResolver = new IdResolver(), rpc } = options\n return async function resolveRecord(\n uriStr: AtUri | AtUriString,\n opts: ResolveRecordOptions = {},\n ): Promise<RecordResolution> {\n const uri = typeof uriStr === 'string' ? new AtUri(uriStr) : uriStr\n const did = await getDidFromUri(uri, { idResolver })\n const identityDoc = await idResolver.did\n .ensureResolve(did, opts.forceRefresh)\n .catch((err) => {\n throw new RecordResolutionError('Could not resolve DID identity data', {\n cause: err,\n })\n })\n const { pds, signingKey } = parseToAtprotoDocument(identityDoc)\n if (!pds) {\n throw new RecordResolutionError(\n 'Incomplete DID identity data: missing pds',\n )\n }\n if (!signingKey) {\n throw new RecordResolutionError(\n 'Incomplete DID identity data: missing signing key',\n )\n }\n const client = new Client(\n typeof rpc === 'function'\n ? { fetchHandler: rpc }\n : {\n ...rpc,\n service: rpc?.service ?? pds,\n fetch: rpc?.fetch ?? safeFetch,\n },\n )\n const proofBytes = await client\n .call(com.atproto.sync.getRecord, {\n did,\n collection: uri.collection as l.NsidString,\n rkey: uri.rkey as l.RecordKeyString,\n })\n .catch((err) => {\n throw new RecordResolutionError('Could not fetch record proof', {\n cause: err,\n })\n })\n const verified = await verifyRecordProof(proofBytes, {\n uri: AtUri.make(did, uri.collection, uri.rkey),\n signingKey,\n })\n return verified\n }\n}\n\nexport const resolveRecord = buildRecordResolver()\n\nexport const safeFetch = safeFetchWrap({\n allowIpHost: false,\n allowImplicitRedirect: true,\n responseMaxSize: (1024 + 10) * 1024, // 1MB + 10kB, just a bit larger than max record size\n})\n\nexport class RecordResolutionError extends Error {\n constructor(message?: string, options?: ErrorOptions) {\n super(message, options)\n this.name = 'RecordResolutionError'\n }\n}\n\nasync function getDidFromUri(\n uri: AtUri,\n { idResolver }: { idResolver: IdResolver },\n): Promise<DidString> {\n if (l.isDidString(uri.host)) {\n return uri.host\n }\n\n const resolved = await idResolver.handle.resolve(uri.host)\n if (!resolved || !l.isDidString(resolved)) {\n throw new RecordResolutionError('Could not resolve handle found in AT-URI')\n }\n\n return resolved\n}\n\nasync function verifyRecordProof(\n proofBytes: Uint8Array,\n { uri, signingKey }: { uri: AtUri; signingKey: string },\n): Promise<RecordResolution> {\n const { root, blocks } = await readCarWithRoot(proofBytes).catch((err) => {\n throw new RecordResolutionError('Malformed record proof', { cause: err })\n })\n const blockstore = new MemoryBlockstore(blocks)\n const commit = await blockstore.readObj(root, repoDef.commit).catch((err) => {\n throw new RecordResolutionError('Invalid commit in record proof', {\n cause: err,\n })\n })\n if (commit.did !== uri.host) {\n throw new RecordResolutionError(`Invalid repo did: ${commit.did}`)\n }\n const validSig = await verifyCommitSig(commit, signingKey)\n if (!validSig) {\n throw new RecordResolutionError(\n `Invalid signature on commit: ${root.toString()}`,\n )\n }\n const mst = MST.load(blockstore, commit.data)\n const cid = await mst.get(`${uri.collection}/${uri.rkey}`)\n if (!cid) {\n throw new RecordResolutionError('Record not found in proof')\n }\n const record = (await blockstore.readRecord(cid)) as LexMap\n return { commit, uri, cid, record }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atproto/lexicon-resolver",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "ATProto Lexicon resolution",
|
|
@@ -23,23 +23,21 @@
|
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"multiformats": "^9.9.0",
|
|
27
26
|
"@atproto-labs/fetch-node": "^0.2.0",
|
|
28
|
-
"@atproto/
|
|
29
|
-
"@atproto/
|
|
27
|
+
"@atproto/lex": "^0.0.20",
|
|
28
|
+
"@atproto/identity": "^0.4.12",
|
|
29
|
+
"@atproto/lex-document": "^0.0.15",
|
|
30
30
|
"@atproto/repo": "^0.8.12",
|
|
31
|
-
"@atproto/syntax": "^0.
|
|
32
|
-
"@atproto/xrpc": "^0.7.7"
|
|
31
|
+
"@atproto/syntax": "^0.5.0"
|
|
33
32
|
},
|
|
34
33
|
"devDependencies": {
|
|
35
34
|
"jest": "^28.1.2",
|
|
36
35
|
"typescript": "^5.6.3",
|
|
37
|
-
"@atproto/
|
|
38
|
-
"@atproto/lex-cli": "^0.9.8"
|
|
36
|
+
"@atproto/lex-cbor": "^0.0.14"
|
|
39
37
|
},
|
|
40
38
|
"scripts": {
|
|
41
39
|
"test": "jest",
|
|
42
40
|
"build": "tsc --build tsconfig.build.json",
|
|
43
|
-
"codegen": "lex
|
|
41
|
+
"codegen": "lex build --indexFile --lexicons ../../lexicons --clear --include com.atproto.sync.getRecord --include com.atproto.lexicon.schema"
|
|
44
42
|
}
|
|
45
43
|
}
|
package/src/lexicon.ts
CHANGED
|
@@ -1,56 +1,52 @@
|
|
|
1
1
|
import dns from 'node:dns/promises'
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { Cid, l } from '@atproto/lex'
|
|
3
|
+
import { LexiconDocument, lexiconDocumentSchema } from '@atproto/lex-document'
|
|
4
4
|
import { Commit } from '@atproto/repo'
|
|
5
|
-
import { AtUri, NSID,
|
|
5
|
+
import { AtUri, DidString, NSID, NsidString } from '@atproto/syntax'
|
|
6
|
+
import * as lexiconsSchema from './lexicons/com/atproto/lexicon/schema.js'
|
|
6
7
|
import {
|
|
7
8
|
BuildRecordResolverOptions,
|
|
8
9
|
ResolveRecordOptions,
|
|
9
10
|
buildRecordResolver,
|
|
10
11
|
} from './record.js'
|
|
11
|
-
import { isValidDid } from './util.js'
|
|
12
12
|
|
|
13
13
|
const DNS_SUBDOMAIN = '_lexicon'
|
|
14
14
|
const DNS_PREFIX = 'did='
|
|
15
|
-
|
|
15
|
+
|
|
16
|
+
export type LexiconDocumentRecord = lexiconsSchema.Main & LexiconDocument
|
|
17
|
+
export const LEXICON_SCHEMA_NSID = lexiconsSchema.$nsid
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
20
|
* Resolve Lexicon from an NSID
|
|
19
21
|
*/
|
|
20
22
|
export type LexiconResolver = (
|
|
21
|
-
nsid: NSID |
|
|
23
|
+
nsid: NSID | NsidString,
|
|
22
24
|
) => Promise<LexiconResolution>
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
* Resolve Lexicon from an NSID using Lexicon DID authority and record resolution
|
|
26
28
|
*/
|
|
27
29
|
export type AtprotoLexiconResolver = (
|
|
28
|
-
nsid: NSID |
|
|
30
|
+
nsid: NSID | NsidString,
|
|
29
31
|
options?: ResolveLexiconOptions,
|
|
30
32
|
) => Promise<LexiconResolution>
|
|
31
33
|
|
|
32
34
|
export type BuildLexiconResolverOptions = BuildRecordResolverOptions
|
|
33
35
|
|
|
34
36
|
export type ResolveLexiconOptions = ResolveRecordOptions & {
|
|
35
|
-
didAuthority?:
|
|
37
|
+
didAuthority?: DidString
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
export type LexiconResolution = {
|
|
39
41
|
commit: Commit
|
|
40
42
|
uri: AtUri
|
|
41
|
-
cid:
|
|
43
|
+
cid: Cid
|
|
42
44
|
nsid: NSID
|
|
43
|
-
lexicon:
|
|
45
|
+
lexicon: LexiconDocumentRecord
|
|
44
46
|
}
|
|
45
47
|
|
|
46
|
-
export {
|
|
47
|
-
|
|
48
|
-
CID,
|
|
49
|
-
type Commit,
|
|
50
|
-
type LexiconDoc,
|
|
51
|
-
type LexiconSchemaRecord,
|
|
52
|
-
NSID,
|
|
53
|
-
}
|
|
48
|
+
export { AtUri, NSID }
|
|
49
|
+
export type { Cid, Commit, DidString, LexiconDocument, NsidString }
|
|
54
50
|
|
|
55
51
|
/**
|
|
56
52
|
* Build a Lexicon resolver function.
|
|
@@ -60,13 +56,13 @@ export function buildLexiconResolver(
|
|
|
60
56
|
): AtprotoLexiconResolver {
|
|
61
57
|
const resolveRecord = buildRecordResolver(options)
|
|
62
58
|
return async function (
|
|
63
|
-
input: NSID |
|
|
59
|
+
input: NSID | NsidString,
|
|
64
60
|
opts: ResolveLexiconOptions = {},
|
|
65
61
|
): Promise<LexiconResolution> {
|
|
66
62
|
const nsid = NSID.from(input)
|
|
67
63
|
const didAuthority = await getDidAuthority(nsid, opts)
|
|
68
64
|
const verified = await resolveRecord(
|
|
69
|
-
AtUri.make(didAuthority,
|
|
65
|
+
AtUri.make(didAuthority, lexiconsSchema.$nsid, nsid.toString()),
|
|
70
66
|
{ forceRefresh: opts.forceRefresh },
|
|
71
67
|
).catch((err) => {
|
|
72
68
|
throw new LexiconResolutionError(
|
|
@@ -75,17 +71,19 @@ export function buildLexiconResolver(
|
|
|
75
71
|
{ cause: err },
|
|
76
72
|
)
|
|
77
73
|
})
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
74
|
+
|
|
75
|
+
if (!lexiconsSchema.$matches(verified.record)) {
|
|
76
|
+
throw new LexiconResolutionError(nsid, 'Invalid Lexicon schema record')
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const validationResult = lexiconDocumentSchema.safeValidate(verified.record)
|
|
80
|
+
if (!validationResult.success) {
|
|
82
81
|
throw new LexiconResolutionError(nsid, 'Invalid Lexicon document', {
|
|
83
|
-
cause:
|
|
82
|
+
cause: validationResult.reason,
|
|
84
83
|
})
|
|
85
84
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
85
|
+
|
|
86
|
+
const lexicon = validationResult.value
|
|
89
87
|
if (lexicon.id !== nsid.toString()) {
|
|
90
88
|
throw new LexiconResolutionError(
|
|
91
89
|
nsid,
|
|
@@ -104,11 +102,11 @@ export const resolveLexicon = buildLexiconResolver()
|
|
|
104
102
|
* @param input NSID or string representing one for which to lookup its Lexicon DID authority.
|
|
105
103
|
*/
|
|
106
104
|
export async function resolveLexiconDidAuthority(
|
|
107
|
-
input: NSID |
|
|
108
|
-
): Promise<
|
|
105
|
+
input: NSID | NsidString,
|
|
106
|
+
): Promise<DidString | undefined> {
|
|
109
107
|
const nsid = NSID.from(input)
|
|
110
108
|
const did = await resolveDns(nsid.authority)
|
|
111
|
-
if (did == null || !
|
|
109
|
+
if (did == null || !l.isDidString(did)) return
|
|
112
110
|
return did
|
|
113
111
|
}
|
|
114
112
|
|
|
@@ -134,7 +132,6 @@ export class LexiconResolutionError extends Error {
|
|
|
134
132
|
|
|
135
133
|
async function getDidAuthority(nsid: NSID, options: ResolveLexiconOptions) {
|
|
136
134
|
if (options.didAuthority) {
|
|
137
|
-
ensureValidDid(options.didAuthority)
|
|
138
135
|
return options.didAuthority
|
|
139
136
|
}
|
|
140
137
|
const did = await resolveLexiconDidAuthority(nsid)
|
|
@@ -165,8 +162,3 @@ function parseDnsResult(chunkedResults: string[][]): string | undefined {
|
|
|
165
162
|
}
|
|
166
163
|
return found[0].slice(DNS_PREFIX.length)
|
|
167
164
|
}
|
|
168
|
-
|
|
169
|
-
type LexiconSchemaRecord = { $type: typeof LEXICON_SCHEMA_NSID }
|
|
170
|
-
function isLexiconSchemaRecord(v: unknown): v is LexiconSchemaRecord {
|
|
171
|
-
return v?.['$type'] === LEXICON_SCHEMA_NSID
|
|
172
|
-
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* THIS FILE WAS GENERATED BY "@atproto/lex". DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { l } from '@atproto/lex'
|
|
6
|
+
|
|
7
|
+
const $nsid = 'com.atproto.lexicon.schema'
|
|
8
|
+
|
|
9
|
+
export { $nsid }
|
|
10
|
+
|
|
11
|
+
/** Representation of Lexicon schemas themselves, when published as atproto records. Note that the schema language is not defined in Lexicon; this meta schema currently only includes a single version field ('lexicon'). See the atproto specifications for description of the other expected top-level fields ('id', 'defs', etc). */
|
|
12
|
+
type Main = {
|
|
13
|
+
$type: 'com.atproto.lexicon.schema'
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Indicates the 'version' of the Lexicon language. Must be '1' for the current atproto/Lexicon schema system.
|
|
17
|
+
*/
|
|
18
|
+
lexicon: number
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type { Main }
|
|
22
|
+
|
|
23
|
+
/** Representation of Lexicon schemas themselves, when published as atproto records. Note that the schema language is not defined in Lexicon; this meta schema currently only includes a single version field ('lexicon'). See the atproto specifications for description of the other expected top-level fields ('id', 'defs', etc). */
|
|
24
|
+
const main = l.record<'nsid', Main>(
|
|
25
|
+
'nsid',
|
|
26
|
+
$nsid,
|
|
27
|
+
l.object({ lexicon: l.integer() }),
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
export { main }
|
|
31
|
+
|
|
32
|
+
export const $isTypeOf = /*#__PURE__*/ main.isTypeOf.bind(main),
|
|
33
|
+
$build = /*#__PURE__*/ main.build.bind(main),
|
|
34
|
+
$type = /*#__PURE__*/ main.$type
|
|
35
|
+
export const $assert = /*#__PURE__*/ main.assert.bind(main),
|
|
36
|
+
$check = /*#__PURE__*/ main.check.bind(main),
|
|
37
|
+
$cast = /*#__PURE__*/ main.cast.bind(main),
|
|
38
|
+
$ifMatches = /*#__PURE__*/ main.ifMatches.bind(main),
|
|
39
|
+
$matches = /*#__PURE__*/ main.matches.bind(main),
|
|
40
|
+
$parse = /*#__PURE__*/ main.parse.bind(main),
|
|
41
|
+
$safeParse = /*#__PURE__*/ main.safeParse.bind(main),
|
|
42
|
+
$validate = /*#__PURE__*/ main.validate.bind(main),
|
|
43
|
+
$safeValidate = /*#__PURE__*/ main.safeValidate.bind(main)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* THIS FILE WAS GENERATED BY "@atproto/lex". DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { l } from '@atproto/lex'
|
|
6
|
+
|
|
7
|
+
const $nsid = 'com.atproto.sync.getRecord'
|
|
8
|
+
|
|
9
|
+
export { $nsid }
|
|
10
|
+
|
|
11
|
+
/** Get data blocks needed to prove the existence or non-existence of record in the current version of repo. Does not require auth. */
|
|
12
|
+
const main = l.query(
|
|
13
|
+
$nsid,
|
|
14
|
+
l.params({
|
|
15
|
+
did: l.string({ format: 'did' }),
|
|
16
|
+
collection: l.string({ format: 'nsid' }),
|
|
17
|
+
rkey: l.string({ format: 'record-key' }),
|
|
18
|
+
}),
|
|
19
|
+
l.payload('application/vnd.ipld.car'),
|
|
20
|
+
[
|
|
21
|
+
'RecordNotFound',
|
|
22
|
+
'RepoNotFound',
|
|
23
|
+
'RepoTakendown',
|
|
24
|
+
'RepoSuspended',
|
|
25
|
+
'RepoDeactivated',
|
|
26
|
+
],
|
|
27
|
+
)
|
|
28
|
+
export { main }
|
|
29
|
+
|
|
30
|
+
export type $Params = l.InferMethodParams<typeof main>
|
|
31
|
+
export type $Output<B = l.BinaryData> = l.InferMethodOutput<typeof main, B>
|
|
32
|
+
export type $OutputBody<B = l.BinaryData> = l.InferMethodOutputBody<
|
|
33
|
+
typeof main,
|
|
34
|
+
B
|
|
35
|
+
>
|
|
36
|
+
|
|
37
|
+
export const $lxm = main.nsid,
|
|
38
|
+
$params = main.parameters,
|
|
39
|
+
$output = main.output
|