@anthusai/papyrus 1.14.0 → 1.15.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.
@@ -49,6 +49,7 @@ export interface ProspectusRequest {
49
49
  body?: unknown;
50
50
  humanAccessToken?: string;
51
51
  identityToken?: string;
52
+ idempotencyKey?: string;
52
53
  }
53
54
 
54
55
  export type ProspectusTransport = (request: ProspectusRequest) => Promise<unknown>;
@@ -84,7 +85,7 @@ export function signedProspectusTransport(options: SignedProspectusTransportOpti
84
85
  }
85
86
  const runtimeCredentials = options.runtimeCredentials ?? defaultProvider();
86
87
  const fetcher = options.fetcher ?? fetch;
87
- return async ({ path, method, body, humanAccessToken, identityToken }) => {
88
+ return async ({ path, method, body, humanAccessToken, identityToken, idempotencyKey }) => {
88
89
  const credentials = await runtimeCredentials();
89
90
  if (!credentials.sessionToken || (credentials.expiration && credentials.expiration.getTime() <= Date.now())) {
90
91
  throw new Error("Prospectus calls require the site's temporary runtime credentials; static access keys are refused.");
@@ -95,6 +96,7 @@ export function signedProspectusTransport(options: SignedProspectusTransportOpti
95
96
  host: url.host,
96
97
  ...(humanAccessToken ? { "x-prospectus-human-token": humanAccessToken } : {}),
97
98
  ...(identityToken ? { "x-prospectus-identity-token": identityToken } : {}),
99
+ ...(idempotencyKey ? { "idempotency-key": idempotencyKey } : {}),
98
100
  ...(payload ? { "content-type": "application/json" } : {}),
99
101
  };
100
102
  const signer = new SignatureV4({ service: "execute-api", region: options.region, credentials, sha256: Sha256 });
@@ -144,6 +146,16 @@ export class ProspectusSiteAccounts {
144
146
  }) as Promise<ProspectusAccountAuthorization>;
145
147
  }
146
148
 
149
+ createAccount(humanAccessToken: string, accountName: string, idempotencyKey: string): Promise<{ account: { id: string; name: string; role: ProspectusRole } }> {
150
+ return this.transport({
151
+ path: "/v1/accounts",
152
+ method: "POST",
153
+ body: { name: accountName },
154
+ humanAccessToken,
155
+ idempotencyKey,
156
+ }) as Promise<{ account: { id: string; name: string; role: ProspectusRole } }>;
157
+ }
158
+
147
159
  accountDirectory(humanAccessToken: string): Promise<{ person: ProspectusPerson | null; accounts: ProspectusDirectoryAccount[] }> {
148
160
  return this.transport({ path: "/v1/account-directory", method: "GET", humanAccessToken }) as Promise<{
149
161
  person: ProspectusPerson | null;
package/package.json CHANGED
@@ -302,6 +302,7 @@
302
302
  "./app/[year]/[month]/[day]/page/[pageNumber]/page": "./app/[year]/[month]/[day]/page/[pageNumber]/page.tsx",
303
303
  "./app/[year]/[month]/[day]/section/[sectionKey]/page": "./app/[year]/[month]/[day]/section/[sectionKey]/page.tsx",
304
304
  "./app/api/archive/editions/route": "./app/api/archive/editions/route.ts",
305
+ "./app/api/auth/prospectus/accounts/route": "./app/api/auth/prospectus/accounts/route.ts",
305
306
  "./app/api/auth/prospectus/callback/route": "./app/api/auth/prospectus/callback/route.ts",
306
307
  "./app/api/auth/prospectus/selection/route": "./app/api/auth/prospectus/selection/route.ts",
307
308
  "./app/api/auth/prospectus/session/route": "./app/api/auth/prospectus/session/route.ts",
@@ -376,7 +377,7 @@
376
377
  "optional": true
377
378
  }
378
379
  },
379
- "version": "1.14.0",
380
+ "version": "1.15.0",
380
381
  "dependencies": {
381
382
  "@aws-amplify/adapter-nextjs": "^1.7.3",
382
383
  "@aws-crypto/sha256-js": "5.2.0",
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.14.0",
2
+ "version": "1.15.0",
3
3
  "routes": [
4
4
  {
5
5
  "file": "app/%5F_preview/[[...path]]/route.ts",
@@ -66,6 +66,17 @@
66
66
  "revalidate": "60"
67
67
  }
68
68
  },
69
+ {
70
+ "file": "app/api/auth/prospectus/accounts/route.ts",
71
+ "hasDefault": false,
72
+ "exports": [
73
+ "POST"
74
+ ],
75
+ "config": {
76
+ "dynamic": "\"force-dynamic\"",
77
+ "runtime": "\"nodejs\""
78
+ }
79
+ },
69
80
  {
70
81
  "file": "app/api/auth/prospectus/callback/route.ts",
71
82
  "hasDefault": false,