@myapihq/sdk 2.1.0 → 2.2.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/dist/auth.d.ts CHANGED
@@ -32,11 +32,17 @@ export interface AuthUsage {
32
32
  period: string;
33
33
  active_users: number;
34
34
  price_cents_each: number;
35
+ as_of?: string;
35
36
  }
36
37
  export interface AuthDomain {
37
38
  domain: string;
38
- status: 'pending' | 'active';
39
- dns: {
39
+ status: 'awaiting_verification' | 'pending' | 'active';
40
+ verification?: {
41
+ type: string;
42
+ name: string;
43
+ value: string;
44
+ };
45
+ dns?: {
40
46
  type: string;
41
47
  name: string;
42
48
  value: string;
@@ -49,9 +55,15 @@ export declare function createTenant(apiKey: string, orgId: string, input?: Crea
49
55
  export declare function getTenant(apiKey: string, orgId: string): Promise<Tenant>;
50
56
  export declare function createClient(apiKey: string, orgId: string, input: CreateClientInput): Promise<AuthClient>;
51
57
  export declare function listClients(apiKey: string, orgId: string): Promise<ListClientsResponse>;
58
+ export declare function deleteClient(apiKey: string, orgId: string, clientId: string): Promise<{
59
+ client_id: string;
60
+ deleted: boolean;
61
+ }>;
62
+ export declare function rotateClient(apiKey: string, orgId: string, clientId: string): Promise<AuthClient>;
52
63
  export declare function getUsage(apiKey: string, orgId: string): Promise<AuthUsage>;
53
64
  export declare function registerDomain(apiKey: string, orgId: string, domain: string): Promise<AuthDomain>;
54
65
  export declare function getDomain(apiKey: string, orgId: string): Promise<AuthDomain>;
66
+ export declare function verifyDomain(apiKey: string, orgId: string): Promise<AuthDomain>;
55
67
  export declare function deleteDomain(apiKey: string, orgId: string, domain: string): Promise<{
56
68
  domain: string;
57
69
  status: string;
package/dist/auth.js CHANGED
@@ -5,9 +5,12 @@ exports.createTenant = createTenant;
5
5
  exports.getTenant = getTenant;
6
6
  exports.createClient = createClient;
7
7
  exports.listClients = listClients;
8
+ exports.deleteClient = deleteClient;
9
+ exports.rotateClient = rotateClient;
8
10
  exports.getUsage = getUsage;
9
11
  exports.registerDomain = registerDomain;
10
12
  exports.getDomain = getDomain;
13
+ exports.verifyDomain = verifyDomain;
11
14
  exports.deleteDomain = deleteDomain;
12
15
  const client_1 = require("./client");
13
16
  const config_1 = require("./config");
@@ -29,9 +32,12 @@ exports.EXPOSES = [
29
32
  'GET /auth/orgs/{org_id}/tenant',
30
33
  'POST /auth/orgs/{org_id}/clients',
31
34
  'GET /auth/orgs/{org_id}/clients',
35
+ 'DELETE /auth/orgs/{org_id}/clients/{client_id}',
36
+ 'POST /auth/orgs/{org_id}/clients/{client_id}/rotate',
32
37
  'GET /auth/orgs/{org_id}/usage',
33
38
  'POST /auth/orgs/{org_id}/domain',
34
39
  'GET /auth/orgs/{org_id}/domain',
40
+ 'POST /auth/orgs/{org_id}/domain/verify',
35
41
  'DELETE /auth/orgs/{org_id}/domain',
36
42
  ];
37
43
  // Create (or update) the org's auth tenant. Idempotent. `connections` selects
@@ -57,6 +63,17 @@ async function createClient(apiKey, orgId, input) {
57
63
  async function listClients(apiKey, orgId) {
58
64
  return (0, client_1.request)('GET', `${config_1.AUTH_BASE}/auth/orgs/${encodeURIComponent(orgId)}/clients`, apiKey);
59
65
  }
66
+ // Delete (revoke) an OIDC client. Irreversible — the client_id stops
67
+ // authenticating immediately.
68
+ async function deleteClient(apiKey, orgId, clientId) {
69
+ return (0, client_1.request)('DELETE', `${config_1.AUTH_BASE}/auth/orgs/${encodeURIComponent(orgId)}/clients/${encodeURIComponent(clientId)}`, apiKey);
70
+ }
71
+ // Rotate a confidential ('web') client's secret. Returns the NEW secret exactly
72
+ // once; the previous secret stops working immediately. (SPA clients have no
73
+ // secret — rotating one is rejected by the backend.)
74
+ async function rotateClient(apiKey, orgId, clientId) {
75
+ return (0, client_1.request)('POST', `${config_1.AUTH_BASE}/auth/orgs/${encodeURIComponent(orgId)}/clients/${encodeURIComponent(clientId)}/rotate`, apiKey);
76
+ }
60
77
  // Monthly-active-user usage for the current period (auth is billed per MAU).
61
78
  async function getUsage(apiKey, orgId) {
62
79
  return (0, client_1.request)('GET', `${config_1.AUTH_BASE}/auth/orgs/${encodeURIComponent(orgId)}/usage`, apiKey);
@@ -71,6 +88,13 @@ async function registerDomain(apiKey, orgId, domain) {
71
88
  async function getDomain(apiKey, orgId) {
72
89
  return (0, client_1.request)('GET', `${config_1.AUTH_BASE}/auth/orgs/${encodeURIComponent(orgId)}/domain`, apiKey);
73
90
  }
91
+ // Verify ownership of the org's custom auth domain by checking the published
92
+ // TXT challenge. On success the domain advances awaiting_verification → pending
93
+ // (and the response carries the A record). Rejects with 422 DOMAIN_NOT_VERIFIED
94
+ // if the TXT record isn't found yet. Idempotent once already pending/active.
95
+ async function verifyDomain(apiKey, orgId) {
96
+ return (0, client_1.request)('POST', `${config_1.AUTH_BASE}/auth/orgs/${encodeURIComponent(orgId)}/domain/verify`, apiKey);
97
+ }
74
98
  async function deleteDomain(apiKey, orgId, domain) {
75
99
  return (0, client_1.request)('DELETE', `${config_1.AUTH_BASE}/auth/orgs/${encodeURIComponent(orgId)}/domain`, apiKey, { domain });
76
100
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@myapihq/sdk",
3
3
  "license": "Apache-2.0",
4
- "version": "2.1.0",
4
+ "version": "2.2.0",
5
5
  "description": "TypeScript SDK for the MyAPI ecosystem",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
package/src/auth.ts CHANGED
@@ -20,9 +20,12 @@ export const EXPOSES: Exposes = [
20
20
  'GET /auth/orgs/{org_id}/tenant',
21
21
  'POST /auth/orgs/{org_id}/clients',
22
22
  'GET /auth/orgs/{org_id}/clients',
23
+ 'DELETE /auth/orgs/{org_id}/clients/{client_id}',
24
+ 'POST /auth/orgs/{org_id}/clients/{client_id}/rotate',
23
25
  'GET /auth/orgs/{org_id}/usage',
24
26
  'POST /auth/orgs/{org_id}/domain',
25
27
  'GET /auth/orgs/{org_id}/domain',
28
+ 'POST /auth/orgs/{org_id}/domain/verify',
26
29
  'DELETE /auth/orgs/{org_id}/domain',
27
30
  ];
28
31
 
@@ -70,13 +73,21 @@ export interface AuthUsage {
70
73
  period: string; // 'YYYY-MM'
71
74
  active_users: number;
72
75
  price_cents_each: number;
76
+ as_of?: string; // RFC3339 freshness marker — MAU is aggregated, not real-time
73
77
  }
74
78
 
75
- // A custom auth domain (e.g. auth.acme.com) for the tenant's hosted login + issuer.
79
+ // A custom auth domain (e.g. auth.acme.com) for the tenant's hosted login +
80
+ // issuer. Lifecycle: awaiting_verification (publish the TXT challenge, then
81
+ // `verify`) → pending (publish the A record, TLS provisions) → active.
76
82
  export interface AuthDomain {
77
83
  domain: string;
78
- status: 'pending' | 'active';
79
- dns: { type: string; name: string; value: string };
84
+ status: 'awaiting_verification' | 'pending' | 'active';
85
+ // Present while `awaiting_verification` the ownership-challenge TXT record
86
+ // to publish, then call verifyDomain().
87
+ verification?: { type: string; name: string; value: string };
88
+ // Present once `pending`/`active` — the A record to publish (withheld until
89
+ // ownership is verified).
90
+ dns?: { type: string; name: string; value: string };
80
91
  next?: string;
81
92
  issuer?: string; // present once active
82
93
  login_url?: string; // present once active
@@ -107,6 +118,19 @@ export async function listClients(apiKey: string, orgId: string): Promise<ListCl
107
118
  return request('GET', `${BASE_URL}/auth/orgs/${encodeURIComponent(orgId)}/clients`, apiKey);
108
119
  }
109
120
 
121
+ // Delete (revoke) an OIDC client. Irreversible — the client_id stops
122
+ // authenticating immediately.
123
+ export async function deleteClient(apiKey: string, orgId: string, clientId: string): Promise<{ client_id: string; deleted: boolean }> {
124
+ return request('DELETE', `${BASE_URL}/auth/orgs/${encodeURIComponent(orgId)}/clients/${encodeURIComponent(clientId)}`, apiKey);
125
+ }
126
+
127
+ // Rotate a confidential ('web') client's secret. Returns the NEW secret exactly
128
+ // once; the previous secret stops working immediately. (SPA clients have no
129
+ // secret — rotating one is rejected by the backend.)
130
+ export async function rotateClient(apiKey: string, orgId: string, clientId: string): Promise<AuthClient> {
131
+ return request('POST', `${BASE_URL}/auth/orgs/${encodeURIComponent(orgId)}/clients/${encodeURIComponent(clientId)}/rotate`, apiKey);
132
+ }
133
+
110
134
  // Monthly-active-user usage for the current period (auth is billed per MAU).
111
135
  export async function getUsage(apiKey: string, orgId: string): Promise<AuthUsage> {
112
136
  return request('GET', `${BASE_URL}/auth/orgs/${encodeURIComponent(orgId)}/usage`, apiKey);
@@ -124,6 +148,14 @@ export async function getDomain(apiKey: string, orgId: string): Promise<AuthDoma
124
148
  return request('GET', `${BASE_URL}/auth/orgs/${encodeURIComponent(orgId)}/domain`, apiKey);
125
149
  }
126
150
 
151
+ // Verify ownership of the org's custom auth domain by checking the published
152
+ // TXT challenge. On success the domain advances awaiting_verification → pending
153
+ // (and the response carries the A record). Rejects with 422 DOMAIN_NOT_VERIFIED
154
+ // if the TXT record isn't found yet. Idempotent once already pending/active.
155
+ export async function verifyDomain(apiKey: string, orgId: string): Promise<AuthDomain> {
156
+ return request('POST', `${BASE_URL}/auth/orgs/${encodeURIComponent(orgId)}/domain/verify`, apiKey);
157
+ }
158
+
127
159
  export async function deleteDomain(apiKey: string, orgId: string, domain: string): Promise<{ domain: string; status: string }> {
128
160
  return request('DELETE', `${BASE_URL}/auth/orgs/${encodeURIComponent(orgId)}/domain`, apiKey, { domain });
129
161
  }