Repository: neet/masto.js (ts)

Issue:
Add `identitiy_proofs` API
Add identity proofs API on `GET /api/v1/accounts/$id/identity_proofs`

Pull request:
Support Identity proofs
Ref: https://github.com/tootsuite/mastodon/pull/10297
Closes #53 

Patch:
diff --git a/src/client/masto.ts b/src/client/masto.ts
index a1b3d7f8..7a0e2854 100644
--- a/src/client/masto.ts
+++ b/src/client/masto.ts
@@ -1,4 +1,8 @@
-import { Account, AccountCredentials } from '../entities/account';
+import {
+  Account,
+  AccountCredentials,
+  IdentityProof,
+} from '../entities/account';
 import { Application } from '../entities/application';
 import { Attachment } from '../entities/attachment';
 import { Card } from '../entities/card';
@@ -199,6 +203,19 @@ export class Masto {
     return this.gateway.get<Account>(`/api/v1/accounts/${id}`);
   }
 
+  /**
+   * Fetch identity proofs of the account
+   * @param id ID of the account
+   * @return Returns identity proofs
+   * @see https://github.com/tootsuite/mastodon/pull/10297
+   */
+  @available({ since: '2.8.0' })
+  public fetchAccountIdentityProofs(id: string) {
+    return this.gateway.get<IdentityProof[]>(
+      `/api/v1/accounts/${id}/identity_proofs`,
+    );
+  }
+
   /**
    * Create an account with given profile
    * @param params Data of the user to create
diff --git a/src/entities/account.ts b/src/entities/account.ts
index 651eff9d..e707fbfc 100644
--- a/src/entities/account.ts
+++ b/src/entities/account.ts
@@ -49,6 +49,19 @@ export interface AccountField {
   value?: string | null;
 }
 
+export interface IdentityProof {
+  /** Name of provider (such as "Keybase") */
+  provider: string;
+  /** Username in the provider */
+  provider_username: string;
+  /** The time the proof was updated */
+  updated_at: string;
+  /** URL of proof */
+  proof_url: string;
+  /** URL of profile on the provider */
+  profile_url: string;
+}
+
 export interface AccountCredentials extends Account {
   source: AccountSource;
 }


Test patch:
diff --git a/src/client/__tests__/__snapshots__/masto.spec.ts.snap b/src/client/__tests__/__snapshots__/masto.spec.ts.snap
index 77ed8a4e..02e6b0d6 100644
--- a/src/client/__tests__/__snapshots__/masto.spec.ts.snap
+++ b/src/client/__tests__/__snapshots__/masto.spec.ts.snap
@@ -434,6 +434,22 @@ exports[`Masto fetchAccountFollowing 1`] = `
 }
 `;
 
+exports[`Masto fetchAccountIdentityProofs 1`] = `
+[MockFunction] {
+  "calls": Array [
+    Array [
+      "/api/v1/accounts/123123123/identity_proofs",
+    ],
+  ],
+  "results": Array [
+    Object {
+      "type": "return",
+      "value": Promise {},
+    },
+  ],
+}
+`;
+
 exports[`Masto fetchAccountLists 1`] = `
 [MockFunction] {
   "calls": Array [
diff --git a/src/client/__tests__/masto.spec.ts b/src/client/__tests__/masto.spec.ts
index 87f21b59..4dc34408 100644
--- a/src/client/__tests__/masto.spec.ts
+++ b/src/client/__tests__/masto.spec.ts
@@ -121,6 +121,12 @@ describe('Masto', () => {
     expect(getMock).toMatchSnapshot();
   });
 
+  test('fetchAccountIdentityProofs', async () => {
+    await masto.fetchAccountIdentityProofs('123123123');
+    expect(getMock).toBeCalledTimes(1);
+    expect(getMock).toMatchSnapshot();
+  });
+
   test('createAccount', async () => {
     await masto.createAccount({
       username: 'username',