@atproto/identity 0.3.2 → 0.3.3

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,15 @@
1
1
  # @atproto/identity
2
2
 
3
+ ## 0.3.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2302](https://github.com/bluesky-social/atproto/pull/2302) [`4eaadc0ac`](https://github.com/bluesky-social/atproto/commit/4eaadc0acb6b73b9745dd7a2b929d02e58083ab0) Thanks [@dholms](https://github.com/dholms)! - Added methods for parsing labeler verification methods and services in DID Documents
8
+
9
+ - Updated dependencies [[`4eaadc0ac`](https://github.com/bluesky-social/atproto/commit/4eaadc0acb6b73b9745dd7a2b929d02e58083ab0)]:
10
+ - @atproto/common-web@0.2.4
11
+ - @atproto/crypto@0.3.0
12
+
3
13
  ## 0.3.2
4
14
 
5
15
  ### Patch Changes
package/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  Dual MIT/Apache-2.0 License
2
2
 
3
- Copyright (c) 2022-2023 Bluesky PBC, and Contributors
3
+ Copyright (c) 2022-2024 Bluesky PBC, and Contributors
4
4
 
5
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
6
 
@@ -2,6 +2,10 @@ import { DidDocument, AtprotoData } from '../types';
2
2
  import { getDid, getHandle, getPdsEndpoint, getFeedGenEndpoint, getNotifEndpoint } from '@atproto/common-web';
3
3
  export { getDid, getHandle, getPdsEndpoint as getPds, getFeedGenEndpoint as getFeedGen, getNotifEndpoint as getNotif, };
4
4
  export declare const getKey: (doc: DidDocument) => string | undefined;
5
+ export declare const getDidKeyFromMultibase: (key: {
6
+ type: string;
7
+ publicKeyMultibase: string;
8
+ }) => string | undefined;
5
9
  export declare const parseToAtprotoDocument: (doc: DidDocument) => Partial<AtprotoData>;
6
10
  export declare const ensureAtpDocument: (doc: DidDocument) => AtprotoData;
7
11
  export declare const ensureAtprotoKey: (doc: DidDocument) => string;
@@ -1,5 +1,5 @@
1
1
  import { DidCache, CacheResult, DidDocument } from '../types';
2
- declare type CacheVal = {
2
+ type CacheVal = {
3
3
  doc: DidDocument;
4
4
  updatedAt: number;
5
5
  };
package/dist/index.js CHANGED
@@ -21172,6 +21172,7 @@ __export(src_exports3, {
21172
21172
  ensureAtpDocument: () => ensureAtpDocument,
21173
21173
  ensureAtprotoKey: () => ensureAtprotoKey,
21174
21174
  getDid: () => getDid,
21175
+ getDidKeyFromMultibase: () => getDidKeyFromMultibase,
21175
21176
  getFeedGen: () => getFeedGenEndpoint,
21176
21177
  getHandle: () => getHandle,
21177
21178
  getKey: () => getKey,
@@ -27995,6 +27996,9 @@ var getHandle = (doc) => {
27995
27996
  return found.slice(5);
27996
27997
  };
27997
27998
  var getSigningKey = (doc) => {
27999
+ return getVerificationMaterial(doc, "atproto");
28000
+ };
28001
+ var getVerificationMaterial = (doc, keyId) => {
27998
28002
  const did = getDid(doc);
27999
28003
  let keys = doc.verificationMethod;
28000
28004
  if (!keys)
@@ -28004,7 +28008,7 @@ var getSigningKey = (doc) => {
28004
28008
  if (!Array.isArray(keys)) {
28005
28009
  keys = [keys];
28006
28010
  }
28007
- const found = keys.find((key) => key.id === "#atproto" || key.id === `${did}#atproto`);
28011
+ const found = keys.find((key) => key.id === `#${keyId}` || key.id === `${did}#${keyId}`);
28008
28012
  if (!found?.publicKeyMultibase)
28009
28013
  return void 0;
28010
28014
  return {
@@ -28043,7 +28047,7 @@ var getServiceEndpoint = (doc, opts) => {
28043
28047
  const found = services.find((service2) => service2.id === opts.id || service2.id === `${did}${opts.id}`);
28044
28048
  if (!found)
28045
28049
  return void 0;
28046
- if (found.type !== opts.type) {
28050
+ if (opts.type && found.type !== opts.type) {
28047
28051
  return void 0;
28048
28052
  }
28049
28053
  if (typeof found.serviceEndpoint !== "string") {
@@ -28089,6 +28093,9 @@ var getKey = (doc) => {
28089
28093
  const key = getSigningKey(doc);
28090
28094
  if (!key)
28091
28095
  return void 0;
28096
+ return getDidKeyFromMultibase(key);
28097
+ };
28098
+ var getDidKeyFromMultibase = (key) => {
28092
28099
  const keyBytes = multibaseToBytes(key.publicKeyMultibase);
28093
28100
  let didKey = void 0;
28094
28101
  if (key.type === "EcdsaSecp256r1VerificationKey2019") {
@@ -28472,6 +28479,7 @@ var IdResolver = class {
28472
28479
  ensureAtpDocument,
28473
28480
  ensureAtprotoKey,
28474
28481
  getDid,
28482
+ getDidKeyFromMultibase,
28475
28483
  getFeedGen,
28476
28484
  getHandle,
28477
28485
  getKey,