@atproto/xrpc 0.3.2 → 0.4.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 CHANGED
@@ -1,5 +1,25 @@
1
1
  # @atproto/xrpc
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1801](https://github.com/bluesky-social/atproto/pull/1801) [`ce49743d`](https://github.com/bluesky-social/atproto/commit/ce49743d7f8800d33116b88001d7b512553c2c89) Thanks [@gaearon](https://github.com/gaearon)! - Methods that accepts lexicons now take `LexiconDoc` type instead of `unknown`
8
+
9
+ ### Patch Changes
10
+
11
+ - [#1788](https://github.com/bluesky-social/atproto/pull/1788) [`84e2d4d2`](https://github.com/bluesky-social/atproto/commit/84e2d4d2b6694f344d80c18672c78b650189d423) Thanks [@bnewbold](https://github.com/bnewbold)! - update license to "MIT or Apache2"
12
+
13
+ - Updated dependencies [[`ce49743d`](https://github.com/bluesky-social/atproto/commit/ce49743d7f8800d33116b88001d7b512553c2c89), [`84e2d4d2`](https://github.com/bluesky-social/atproto/commit/84e2d4d2b6694f344d80c18672c78b650189d423)]:
14
+ - @atproto/lexicon@0.3.0
15
+
16
+ ## 0.3.3
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies []:
21
+ - @atproto/lexicon@0.2.3
22
+
3
23
  ## 0.3.2
4
24
 
5
25
  ### Patch Changes
package/LICENSE.txt ADDED
@@ -0,0 +1,7 @@
1
+ Dual MIT/Apache-2.0 License
2
+
3
+ Copyright (c) 2022-2023 Bluesky PBC, and Contributors
4
+
5
+ Except as otherwise noted in individual files, this software is licensed under the MIT license (<http://opensource.org/licenses/MIT>), or the Apache License, Version 2.0 (<http://www.apache.org/licenses/LICENSE-2.0>).
6
+
7
+ Downstream projects and end users may chose either license individually, or both together, at their discretion. The motivation for this dual-licensing is the additional software patent assurance provided by Apache 2.0.
package/README.md CHANGED
@@ -8,9 +8,10 @@ TypeScript client library for talking to [atproto](https://atproto.com) services
8
8
  ## Usage
9
9
 
10
10
  ```typescript
11
+ import { LexiconDoc } from '@atproto/lexicon'
11
12
  import xrpc from '@atproto/xrpc'
12
13
 
13
- xrpc.addLexicon({
14
+ const pingLexicon: LexiconDoc = {
14
15
  lexicon: 1,
15
16
  id: 'io.example.ping',
16
17
  defs: {
@@ -31,7 +32,8 @@ xrpc.addLexicon({
31
32
  },
32
33
  },
33
34
  },
34
- })
35
+ }
36
+ xrpc.addLexicon(pingLexicon)
35
37
 
36
38
  const res1 = await xrpc.call('https://example.com', 'io.example.ping', {
37
39
  message: 'hello world',
@@ -44,7 +46,7 @@ const res2 = await xrpc
44
46
  res2.encoding // => 'application/json'
45
47
  res2.body // => {message: 'hello world'}
46
48
 
47
- xrpc.addLexicon({
49
+ const writeJsonLexicon: LexiconDoc = {
48
50
  lexicon: 1,
49
51
  id: 'io.example.writeJsonFile',
50
52
  defs: {
@@ -60,7 +62,8 @@ xrpc.addLexicon({
60
62
  },
61
63
  },
62
64
  },
63
- })
65
+ }
66
+ xrpc.addLexicon(writeJsonLexicon)
64
67
 
65
68
  const res3 = await xrpc.service('https://example.com').call(
66
69
  'io.example.writeJsonFile',
@@ -71,4 +74,9 @@ const res3 = await xrpc.service('https://example.com').call(
71
74
 
72
75
  ## License
73
76
 
74
- MIT
77
+ This project is dual-licensed under MIT and Apache 2.0 terms:
78
+
79
+ - MIT license ([LICENSE-MIT.txt](https://github.com/bluesky-social/atproto/blob/main/LICENSE-MIT.txt) or http://opensource.org/licenses/MIT)
80
+ - Apache License, Version 2.0, ([LICENSE-APACHE.txt](https://github.com/bluesky-social/atproto/blob/main/LICENSE-APACHE.txt) or http://www.apache.org/licenses/LICENSE-2.0)
81
+
82
+ Downstream projects and end users may chose either license individually, or both together, at their discretion. The motivation for this dual-licensing is the additional software patent assurance provided by Apache 2.0.
package/dist/client.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { Lexicons } from '@atproto/lexicon';
1
+ import { LexiconDoc, Lexicons } from '@atproto/lexicon';
2
2
  import { FetchHandler, FetchHandlerResponse, Headers, CallOptions, QueryParams, XRPCResponse } from './types';
3
3
  export declare class Client {
4
4
  fetch: FetchHandler;
5
5
  lex: Lexicons;
6
6
  call(serviceUri: string | URL, methodNsid: string, params?: QueryParams, data?: unknown, opts?: CallOptions): Promise<XRPCResponse>;
7
7
  service(serviceUri: string | URL): ServiceClient;
8
- addLexicon(doc: unknown): void;
9
- addLexicons(docs: unknown[]): void;
8
+ addLexicon(doc: LexiconDoc): void;
9
+ addLexicons(docs: LexiconDoc[]): void;
10
10
  removeLexicon(uri: string): void;
11
11
  }
12
12
  export declare class ServiceClient {
package/dist/index.js CHANGED
@@ -13960,6 +13960,25 @@ var validateLanguage = (langTag) => {
13960
13960
  };
13961
13961
  var bcp47Regexp = /^((?<grandfathered>(en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)|(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang))|((?<language>([A-Za-z]{2,3}(-(?<extlang>[A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-(?<script>[A-Za-z]{4}))?(-(?<region>[A-Za-z]{2}|[0-9]{3}))?(-(?<variant>[A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-(?<extension>[0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(?<privateUseA>x(-[A-Za-z0-9]{1,8})+))?)|(?<privateUseB>x(-[A-Za-z0-9]{1,8})+))$/;
13962
13962
 
13963
+ // ../common-web/src/did-doc.ts
13964
+ var verificationMethod = z.object({
13965
+ id: z.string(),
13966
+ type: z.string(),
13967
+ controller: z.string(),
13968
+ publicKeyMultibase: z.string().optional()
13969
+ });
13970
+ var service = z.object({
13971
+ id: z.string(),
13972
+ type: z.string(),
13973
+ serviceEndpoint: z.union([z.string(), z.record(z.unknown())])
13974
+ });
13975
+ var didDocument = z.object({
13976
+ id: z.string(),
13977
+ alsoKnownAs: z.array(z.string()).optional(),
13978
+ verificationMethod: z.array(verificationMethod).optional(),
13979
+ service: z.array(service).optional()
13980
+ });
13981
+
13963
13982
  // ../lexicon/src/validators/formats.ts
13964
13983
  var import_iso_datestring_validator = __toESM(require_dist());
13965
13984
  function datetime(path, value) {
@@ -14805,15 +14824,6 @@ var discriminatedObject = z.object({ $type: z.string() });
14805
14824
  function isDiscriminatedObject(value) {
14806
14825
  return discriminatedObject.safeParse(value).success;
14807
14826
  }
14808
- var LexiconDocMalformedError = class extends Error {
14809
- constructor(message, schemaDef, issues) {
14810
- super(message);
14811
- this.schemaDef = schemaDef;
14812
- this.issues = issues;
14813
- this.schemaDef = schemaDef;
14814
- this.issues = issues;
14815
- }
14816
- };
14817
14827
  var ValidationError = class extends Error {
14818
14828
  };
14819
14829
  var InvalidLexiconError = class extends Error {
@@ -14894,23 +14904,13 @@ var Lexicons = class {
14894
14904
  }
14895
14905
  }
14896
14906
  add(doc) {
14897
- try {
14898
- lexiconDoc.parse(doc);
14899
- } catch (e) {
14900
- if (e instanceof ZodError) {
14901
- throw new LexiconDocMalformedError(`Failed to parse schema definition ${doc.id}`, doc, e.issues);
14902
- } else {
14903
- throw e;
14904
- }
14905
- }
14906
- const validatedDoc = doc;
14907
- const uri2 = toLexUri(validatedDoc.id);
14907
+ const uri2 = toLexUri(doc.id);
14908
14908
  if (this.docs.has(uri2)) {
14909
14909
  throw new Error(`${uri2} has already been registered`);
14910
14910
  }
14911
- resolveRefUris(validatedDoc, uri2);
14912
- this.docs.set(uri2, validatedDoc);
14913
- for (const [defUri, def2] of iterDefs(validatedDoc)) {
14911
+ resolveRefUris(doc, uri2);
14912
+ this.docs.set(uri2, doc);
14913
+ for (const [defUri, def2] of iterDefs(doc)) {
14914
14914
  this.defs.set(defUri, def2);
14915
14915
  }
14916
14916
  }